xref: /f-stack/dpdk/lib/librte_ethdev/rte_flow.h (revision 2d9fd380)
1d30ea906Sjfb8856606 /* SPDX-License-Identifier: BSD-3-Clause
2d30ea906Sjfb8856606  * Copyright 2016 6WIND S.A.
3d30ea906Sjfb8856606  * Copyright 2016 Mellanox Technologies, Ltd
4d30ea906Sjfb8856606  */
5d30ea906Sjfb8856606 
6d30ea906Sjfb8856606 #ifndef RTE_FLOW_H_
7d30ea906Sjfb8856606 #define RTE_FLOW_H_
8d30ea906Sjfb8856606 
9d30ea906Sjfb8856606 /**
10d30ea906Sjfb8856606  * @file
11d30ea906Sjfb8856606  * RTE generic flow API
12d30ea906Sjfb8856606  *
13d30ea906Sjfb8856606  * This interface provides the ability to program packet matching and
14d30ea906Sjfb8856606  * associated actions in hardware through flow rules.
15d30ea906Sjfb8856606  */
16d30ea906Sjfb8856606 
17d30ea906Sjfb8856606 #include <stddef.h>
18d30ea906Sjfb8856606 #include <stdint.h>
19d30ea906Sjfb8856606 
20d30ea906Sjfb8856606 #include <rte_arp.h>
21d30ea906Sjfb8856606 #include <rte_common.h>
22d30ea906Sjfb8856606 #include <rte_ether.h>
23d30ea906Sjfb8856606 #include <rte_icmp.h>
24d30ea906Sjfb8856606 #include <rte_ip.h>
25d30ea906Sjfb8856606 #include <rte_sctp.h>
26d30ea906Sjfb8856606 #include <rte_tcp.h>
27d30ea906Sjfb8856606 #include <rte_udp.h>
28d30ea906Sjfb8856606 #include <rte_byteorder.h>
29d30ea906Sjfb8856606 #include <rte_esp.h>
304418919fSjohnjiang #include <rte_higig.h>
31*2d9fd380Sjfb8856606 #include <rte_ecpri.h>
324418919fSjohnjiang #include <rte_mbuf.h>
334418919fSjohnjiang #include <rte_mbuf_dyn.h>
34d30ea906Sjfb8856606 
35d30ea906Sjfb8856606 #ifdef __cplusplus
36d30ea906Sjfb8856606 extern "C" {
37d30ea906Sjfb8856606 #endif
38d30ea906Sjfb8856606 
39d30ea906Sjfb8856606 /**
40d30ea906Sjfb8856606  * Flow rule attributes.
41d30ea906Sjfb8856606  *
42d30ea906Sjfb8856606  * Priorities are set on a per rule based within groups.
43d30ea906Sjfb8856606  *
44d30ea906Sjfb8856606  * Lower values denote higher priority, the highest priority for a flow rule
45d30ea906Sjfb8856606  * is 0, so that a flow that matches for than one rule, the rule with the
46d30ea906Sjfb8856606  * lowest priority value will always be matched.
47d30ea906Sjfb8856606  *
48d30ea906Sjfb8856606  * Although optional, applications are encouraged to group similar rules as
49d30ea906Sjfb8856606  * much as possible to fully take advantage of hardware capabilities
50d30ea906Sjfb8856606  * (e.g. optimized matching) and work around limitations (e.g. a single
51d30ea906Sjfb8856606  * pattern type possibly allowed in a given group). Applications should be
52d30ea906Sjfb8856606  * aware that groups are not linked by default, and that they must be
53d30ea906Sjfb8856606  * explicitly linked by the application using the JUMP action.
54d30ea906Sjfb8856606  *
55d30ea906Sjfb8856606  * Priority levels are arbitrary and up to the application, they
56d30ea906Sjfb8856606  * do not need to be contiguous nor start from 0, however the maximum number
57d30ea906Sjfb8856606  * varies between devices and may be affected by existing flow rules.
58d30ea906Sjfb8856606  *
59d30ea906Sjfb8856606  * If a packet is matched by several rules of a given group for a given
60d30ea906Sjfb8856606  * priority level, the outcome is undefined. It can take any path, may be
61d30ea906Sjfb8856606  * duplicated or even cause unrecoverable errors.
62d30ea906Sjfb8856606  *
63d30ea906Sjfb8856606  * Note that support for more than a single group and priority level is not
64d30ea906Sjfb8856606  * guaranteed.
65d30ea906Sjfb8856606  *
66d30ea906Sjfb8856606  * Flow rules can apply to inbound and/or outbound traffic (ingress/egress).
67d30ea906Sjfb8856606  *
68d30ea906Sjfb8856606  * Several pattern items and actions are valid and can be used in both
69d30ea906Sjfb8856606  * directions. Those valid for only one direction are described as such.
70d30ea906Sjfb8856606  *
71d30ea906Sjfb8856606  * At least one direction must be specified.
72d30ea906Sjfb8856606  *
73d30ea906Sjfb8856606  * Specifying both directions at once for a given rule is not recommended
74d30ea906Sjfb8856606  * but may be valid in a few cases (e.g. shared counter).
75d30ea906Sjfb8856606  */
76d30ea906Sjfb8856606 struct rte_flow_attr {
77d30ea906Sjfb8856606 	uint32_t group; /**< Priority group. */
78d30ea906Sjfb8856606 	uint32_t priority; /**< Rule priority level within group. */
79d30ea906Sjfb8856606 	uint32_t ingress:1; /**< Rule applies to ingress traffic. */
80d30ea906Sjfb8856606 	uint32_t egress:1; /**< Rule applies to egress traffic. */
81d30ea906Sjfb8856606 	/**
82d30ea906Sjfb8856606 	 * Instead of simply matching the properties of traffic as it would
83d30ea906Sjfb8856606 	 * appear on a given DPDK port ID, enabling this attribute transfers
84d30ea906Sjfb8856606 	 * a flow rule to the lowest possible level of any device endpoints
85d30ea906Sjfb8856606 	 * found in the pattern.
86d30ea906Sjfb8856606 	 *
87d30ea906Sjfb8856606 	 * When supported, this effectively enables an application to
88d30ea906Sjfb8856606 	 * re-route traffic not necessarily intended for it (e.g. coming
89d30ea906Sjfb8856606 	 * from or addressed to different physical ports, VFs or
90d30ea906Sjfb8856606 	 * applications) at the device level.
91d30ea906Sjfb8856606 	 *
92d30ea906Sjfb8856606 	 * It complements the behavior of some pattern items such as
93d30ea906Sjfb8856606 	 * RTE_FLOW_ITEM_TYPE_PHY_PORT and is meaningless without them.
94d30ea906Sjfb8856606 	 *
95d30ea906Sjfb8856606 	 * When transferring flow rules, ingress and egress attributes keep
96d30ea906Sjfb8856606 	 * their original meaning, as if processing traffic emitted or
97d30ea906Sjfb8856606 	 * received by the application.
98d30ea906Sjfb8856606 	 */
99d30ea906Sjfb8856606 	uint32_t transfer:1;
100d30ea906Sjfb8856606 	uint32_t reserved:29; /**< Reserved, must be zero. */
101d30ea906Sjfb8856606 };
102d30ea906Sjfb8856606 
103d30ea906Sjfb8856606 /**
104d30ea906Sjfb8856606  * Matching pattern item types.
105d30ea906Sjfb8856606  *
106d30ea906Sjfb8856606  * Pattern items fall in two categories:
107d30ea906Sjfb8856606  *
108d30ea906Sjfb8856606  * - Matching protocol headers and packet data, usually associated with a
109d30ea906Sjfb8856606  *   specification structure. These must be stacked in the same order as the
110d30ea906Sjfb8856606  *   protocol layers to match inside packets, starting from the lowest.
111d30ea906Sjfb8856606  *
112d30ea906Sjfb8856606  * - Matching meta-data or affecting pattern processing, often without a
113d30ea906Sjfb8856606  *   specification structure. Since they do not match packet contents, their
114d30ea906Sjfb8856606  *   position in the list is usually not relevant.
115d30ea906Sjfb8856606  *
116d30ea906Sjfb8856606  * See the description of individual types for more information. Those
117d30ea906Sjfb8856606  * marked with [META] fall into the second category.
118d30ea906Sjfb8856606  */
119d30ea906Sjfb8856606 enum rte_flow_item_type {
120d30ea906Sjfb8856606 	/**
121d30ea906Sjfb8856606 	 * [META]
122d30ea906Sjfb8856606 	 *
123d30ea906Sjfb8856606 	 * End marker for item lists. Prevents further processing of items,
124d30ea906Sjfb8856606 	 * thereby ending the pattern.
125d30ea906Sjfb8856606 	 *
126d30ea906Sjfb8856606 	 * No associated specification structure.
127d30ea906Sjfb8856606 	 */
128d30ea906Sjfb8856606 	RTE_FLOW_ITEM_TYPE_END,
129d30ea906Sjfb8856606 
130d30ea906Sjfb8856606 	/**
131d30ea906Sjfb8856606 	 * [META]
132d30ea906Sjfb8856606 	 *
133d30ea906Sjfb8856606 	 * Used as a placeholder for convenience. It is ignored and simply
134d30ea906Sjfb8856606 	 * discarded by PMDs.
135d30ea906Sjfb8856606 	 *
136d30ea906Sjfb8856606 	 * No associated specification structure.
137d30ea906Sjfb8856606 	 */
138d30ea906Sjfb8856606 	RTE_FLOW_ITEM_TYPE_VOID,
139d30ea906Sjfb8856606 
140d30ea906Sjfb8856606 	/**
141d30ea906Sjfb8856606 	 * [META]
142d30ea906Sjfb8856606 	 *
143d30ea906Sjfb8856606 	 * Inverted matching, i.e. process packets that do not match the
144d30ea906Sjfb8856606 	 * pattern.
145d30ea906Sjfb8856606 	 *
146d30ea906Sjfb8856606 	 * No associated specification structure.
147d30ea906Sjfb8856606 	 */
148d30ea906Sjfb8856606 	RTE_FLOW_ITEM_TYPE_INVERT,
149d30ea906Sjfb8856606 
150d30ea906Sjfb8856606 	/**
151d30ea906Sjfb8856606 	 * Matches any protocol in place of the current layer, a single ANY
152d30ea906Sjfb8856606 	 * may also stand for several protocol layers.
153d30ea906Sjfb8856606 	 *
154d30ea906Sjfb8856606 	 * See struct rte_flow_item_any.
155d30ea906Sjfb8856606 	 */
156d30ea906Sjfb8856606 	RTE_FLOW_ITEM_TYPE_ANY,
157d30ea906Sjfb8856606 
158d30ea906Sjfb8856606 	/**
159d30ea906Sjfb8856606 	 * [META]
160d30ea906Sjfb8856606 	 *
161d30ea906Sjfb8856606 	 * Matches traffic originating from (ingress) or going to (egress)
162d30ea906Sjfb8856606 	 * the physical function of the current device.
163d30ea906Sjfb8856606 	 *
164d30ea906Sjfb8856606 	 * No associated specification structure.
165d30ea906Sjfb8856606 	 */
166d30ea906Sjfb8856606 	RTE_FLOW_ITEM_TYPE_PF,
167d30ea906Sjfb8856606 
168d30ea906Sjfb8856606 	/**
169d30ea906Sjfb8856606 	 * [META]
170d30ea906Sjfb8856606 	 *
171d30ea906Sjfb8856606 	 * Matches traffic originating from (ingress) or going to (egress) a
172d30ea906Sjfb8856606 	 * given virtual function of the current device.
173d30ea906Sjfb8856606 	 *
174d30ea906Sjfb8856606 	 * See struct rte_flow_item_vf.
175d30ea906Sjfb8856606 	 */
176d30ea906Sjfb8856606 	RTE_FLOW_ITEM_TYPE_VF,
177d30ea906Sjfb8856606 
178d30ea906Sjfb8856606 	/**
179d30ea906Sjfb8856606 	 * [META]
180d30ea906Sjfb8856606 	 *
181d30ea906Sjfb8856606 	 * Matches traffic originating from (ingress) or going to (egress) a
182d30ea906Sjfb8856606 	 * physical port of the underlying device.
183d30ea906Sjfb8856606 	 *
184d30ea906Sjfb8856606 	 * See struct rte_flow_item_phy_port.
185d30ea906Sjfb8856606 	 */
186d30ea906Sjfb8856606 	RTE_FLOW_ITEM_TYPE_PHY_PORT,
187d30ea906Sjfb8856606 
188d30ea906Sjfb8856606 	/**
189d30ea906Sjfb8856606 	 * [META]
190d30ea906Sjfb8856606 	 *
191d30ea906Sjfb8856606 	 * Matches traffic originating from (ingress) or going to (egress) a
192d30ea906Sjfb8856606 	 * given DPDK port ID.
193d30ea906Sjfb8856606 	 *
194d30ea906Sjfb8856606 	 * See struct rte_flow_item_port_id.
195d30ea906Sjfb8856606 	 */
196d30ea906Sjfb8856606 	RTE_FLOW_ITEM_TYPE_PORT_ID,
197d30ea906Sjfb8856606 
198d30ea906Sjfb8856606 	/**
199d30ea906Sjfb8856606 	 * Matches a byte string of a given length at a given offset.
200d30ea906Sjfb8856606 	 *
201d30ea906Sjfb8856606 	 * See struct rte_flow_item_raw.
202d30ea906Sjfb8856606 	 */
203d30ea906Sjfb8856606 	RTE_FLOW_ITEM_TYPE_RAW,
204d30ea906Sjfb8856606 
205d30ea906Sjfb8856606 	/**
206d30ea906Sjfb8856606 	 * Matches an Ethernet header.
207d30ea906Sjfb8856606 	 *
208d30ea906Sjfb8856606 	 * See struct rte_flow_item_eth.
209d30ea906Sjfb8856606 	 */
210d30ea906Sjfb8856606 	RTE_FLOW_ITEM_TYPE_ETH,
211d30ea906Sjfb8856606 
212d30ea906Sjfb8856606 	/**
213d30ea906Sjfb8856606 	 * Matches an 802.1Q/ad VLAN tag.
214d30ea906Sjfb8856606 	 *
215d30ea906Sjfb8856606 	 * See struct rte_flow_item_vlan.
216d30ea906Sjfb8856606 	 */
217d30ea906Sjfb8856606 	RTE_FLOW_ITEM_TYPE_VLAN,
218d30ea906Sjfb8856606 
219d30ea906Sjfb8856606 	/**
220d30ea906Sjfb8856606 	 * Matches an IPv4 header.
221d30ea906Sjfb8856606 	 *
222d30ea906Sjfb8856606 	 * See struct rte_flow_item_ipv4.
223d30ea906Sjfb8856606 	 */
224d30ea906Sjfb8856606 	RTE_FLOW_ITEM_TYPE_IPV4,
225d30ea906Sjfb8856606 
226d30ea906Sjfb8856606 	/**
227d30ea906Sjfb8856606 	 * Matches an IPv6 header.
228d30ea906Sjfb8856606 	 *
229d30ea906Sjfb8856606 	 * See struct rte_flow_item_ipv6.
230d30ea906Sjfb8856606 	 */
231d30ea906Sjfb8856606 	RTE_FLOW_ITEM_TYPE_IPV6,
232d30ea906Sjfb8856606 
233d30ea906Sjfb8856606 	/**
234d30ea906Sjfb8856606 	 * Matches an ICMP header.
235d30ea906Sjfb8856606 	 *
236d30ea906Sjfb8856606 	 * See struct rte_flow_item_icmp.
237d30ea906Sjfb8856606 	 */
238d30ea906Sjfb8856606 	RTE_FLOW_ITEM_TYPE_ICMP,
239d30ea906Sjfb8856606 
240d30ea906Sjfb8856606 	/**
241d30ea906Sjfb8856606 	 * Matches a UDP header.
242d30ea906Sjfb8856606 	 *
243d30ea906Sjfb8856606 	 * See struct rte_flow_item_udp.
244d30ea906Sjfb8856606 	 */
245d30ea906Sjfb8856606 	RTE_FLOW_ITEM_TYPE_UDP,
246d30ea906Sjfb8856606 
247d30ea906Sjfb8856606 	/**
248d30ea906Sjfb8856606 	 * Matches a TCP header.
249d30ea906Sjfb8856606 	 *
250d30ea906Sjfb8856606 	 * See struct rte_flow_item_tcp.
251d30ea906Sjfb8856606 	 */
252d30ea906Sjfb8856606 	RTE_FLOW_ITEM_TYPE_TCP,
253d30ea906Sjfb8856606 
254d30ea906Sjfb8856606 	/**
255d30ea906Sjfb8856606 	 * Matches a SCTP header.
256d30ea906Sjfb8856606 	 *
257d30ea906Sjfb8856606 	 * See struct rte_flow_item_sctp.
258d30ea906Sjfb8856606 	 */
259d30ea906Sjfb8856606 	RTE_FLOW_ITEM_TYPE_SCTP,
260d30ea906Sjfb8856606 
261d30ea906Sjfb8856606 	/**
262d30ea906Sjfb8856606 	 * Matches a VXLAN header.
263d30ea906Sjfb8856606 	 *
264d30ea906Sjfb8856606 	 * See struct rte_flow_item_vxlan.
265d30ea906Sjfb8856606 	 */
266d30ea906Sjfb8856606 	RTE_FLOW_ITEM_TYPE_VXLAN,
267d30ea906Sjfb8856606 
268d30ea906Sjfb8856606 	/**
269d30ea906Sjfb8856606 	 * Matches a E_TAG header.
270d30ea906Sjfb8856606 	 *
271d30ea906Sjfb8856606 	 * See struct rte_flow_item_e_tag.
272d30ea906Sjfb8856606 	 */
273d30ea906Sjfb8856606 	RTE_FLOW_ITEM_TYPE_E_TAG,
274d30ea906Sjfb8856606 
275d30ea906Sjfb8856606 	/**
276d30ea906Sjfb8856606 	 * Matches a NVGRE header.
277d30ea906Sjfb8856606 	 *
278d30ea906Sjfb8856606 	 * See struct rte_flow_item_nvgre.
279d30ea906Sjfb8856606 	 */
280d30ea906Sjfb8856606 	RTE_FLOW_ITEM_TYPE_NVGRE,
281d30ea906Sjfb8856606 
282d30ea906Sjfb8856606 	/**
283d30ea906Sjfb8856606 	 * Matches a MPLS header.
284d30ea906Sjfb8856606 	 *
285d30ea906Sjfb8856606 	 * See struct rte_flow_item_mpls.
286d30ea906Sjfb8856606 	 */
287d30ea906Sjfb8856606 	RTE_FLOW_ITEM_TYPE_MPLS,
288d30ea906Sjfb8856606 
289d30ea906Sjfb8856606 	/**
290d30ea906Sjfb8856606 	 * Matches a GRE header.
291d30ea906Sjfb8856606 	 *
292d30ea906Sjfb8856606 	 * See struct rte_flow_item_gre.
293d30ea906Sjfb8856606 	 */
294d30ea906Sjfb8856606 	RTE_FLOW_ITEM_TYPE_GRE,
295d30ea906Sjfb8856606 
296d30ea906Sjfb8856606 	/**
297d30ea906Sjfb8856606 	 * [META]
298d30ea906Sjfb8856606 	 *
299d30ea906Sjfb8856606 	 * Fuzzy pattern match, expect faster than default.
300d30ea906Sjfb8856606 	 *
301d30ea906Sjfb8856606 	 * This is for device that support fuzzy matching option.
302d30ea906Sjfb8856606 	 * Usually a fuzzy matching is fast but the cost is accuracy.
303d30ea906Sjfb8856606 	 *
304d30ea906Sjfb8856606 	 * See struct rte_flow_item_fuzzy.
305d30ea906Sjfb8856606 	 */
306d30ea906Sjfb8856606 	RTE_FLOW_ITEM_TYPE_FUZZY,
307d30ea906Sjfb8856606 
308d30ea906Sjfb8856606 	/**
309d30ea906Sjfb8856606 	 * Matches a GTP header.
310d30ea906Sjfb8856606 	 *
311d30ea906Sjfb8856606 	 * Configure flow for GTP packets.
312d30ea906Sjfb8856606 	 *
313d30ea906Sjfb8856606 	 * See struct rte_flow_item_gtp.
314d30ea906Sjfb8856606 	 */
315d30ea906Sjfb8856606 	RTE_FLOW_ITEM_TYPE_GTP,
316d30ea906Sjfb8856606 
317d30ea906Sjfb8856606 	/**
318d30ea906Sjfb8856606 	 * Matches a GTP header.
319d30ea906Sjfb8856606 	 *
320d30ea906Sjfb8856606 	 * Configure flow for GTP-C packets.
321d30ea906Sjfb8856606 	 *
322d30ea906Sjfb8856606 	 * See struct rte_flow_item_gtp.
323d30ea906Sjfb8856606 	 */
324d30ea906Sjfb8856606 	RTE_FLOW_ITEM_TYPE_GTPC,
325d30ea906Sjfb8856606 
326d30ea906Sjfb8856606 	/**
327d30ea906Sjfb8856606 	 * Matches a GTP header.
328d30ea906Sjfb8856606 	 *
329d30ea906Sjfb8856606 	 * Configure flow for GTP-U packets.
330d30ea906Sjfb8856606 	 *
331d30ea906Sjfb8856606 	 * See struct rte_flow_item_gtp.
332d30ea906Sjfb8856606 	 */
333d30ea906Sjfb8856606 	RTE_FLOW_ITEM_TYPE_GTPU,
334d30ea906Sjfb8856606 
335d30ea906Sjfb8856606 	/**
336d30ea906Sjfb8856606 	 * Matches a ESP header.
337d30ea906Sjfb8856606 	 *
338d30ea906Sjfb8856606 	 * See struct rte_flow_item_esp.
339d30ea906Sjfb8856606 	 */
340d30ea906Sjfb8856606 	RTE_FLOW_ITEM_TYPE_ESP,
341d30ea906Sjfb8856606 
342d30ea906Sjfb8856606 	/**
343d30ea906Sjfb8856606 	 * Matches a GENEVE header.
344d30ea906Sjfb8856606 	 *
345d30ea906Sjfb8856606 	 * See struct rte_flow_item_geneve.
346d30ea906Sjfb8856606 	 */
347d30ea906Sjfb8856606 	RTE_FLOW_ITEM_TYPE_GENEVE,
348d30ea906Sjfb8856606 
349d30ea906Sjfb8856606 	/**
350d30ea906Sjfb8856606 	 * Matches a VXLAN-GPE header.
351d30ea906Sjfb8856606 	 *
352d30ea906Sjfb8856606 	 * See struct rte_flow_item_vxlan_gpe.
353d30ea906Sjfb8856606 	 */
354d30ea906Sjfb8856606 	RTE_FLOW_ITEM_TYPE_VXLAN_GPE,
355d30ea906Sjfb8856606 
356d30ea906Sjfb8856606 	/**
357d30ea906Sjfb8856606 	 * Matches an ARP header for Ethernet/IPv4.
358d30ea906Sjfb8856606 	 *
359d30ea906Sjfb8856606 	 * See struct rte_flow_item_arp_eth_ipv4.
360d30ea906Sjfb8856606 	 */
361d30ea906Sjfb8856606 	RTE_FLOW_ITEM_TYPE_ARP_ETH_IPV4,
362d30ea906Sjfb8856606 
363d30ea906Sjfb8856606 	/**
364d30ea906Sjfb8856606 	 * Matches the presence of any IPv6 extension header.
365d30ea906Sjfb8856606 	 *
366d30ea906Sjfb8856606 	 * See struct rte_flow_item_ipv6_ext.
367d30ea906Sjfb8856606 	 */
368d30ea906Sjfb8856606 	RTE_FLOW_ITEM_TYPE_IPV6_EXT,
369d30ea906Sjfb8856606 
370d30ea906Sjfb8856606 	/**
371d30ea906Sjfb8856606 	 * Matches any ICMPv6 header.
372d30ea906Sjfb8856606 	 *
373d30ea906Sjfb8856606 	 * See struct rte_flow_item_icmp6.
374d30ea906Sjfb8856606 	 */
375d30ea906Sjfb8856606 	RTE_FLOW_ITEM_TYPE_ICMP6,
376d30ea906Sjfb8856606 
377d30ea906Sjfb8856606 	/**
378d30ea906Sjfb8856606 	 * Matches an ICMPv6 neighbor discovery solicitation.
379d30ea906Sjfb8856606 	 *
380d30ea906Sjfb8856606 	 * See struct rte_flow_item_icmp6_nd_ns.
381d30ea906Sjfb8856606 	 */
382d30ea906Sjfb8856606 	RTE_FLOW_ITEM_TYPE_ICMP6_ND_NS,
383d30ea906Sjfb8856606 
384d30ea906Sjfb8856606 	/**
385d30ea906Sjfb8856606 	 * Matches an ICMPv6 neighbor discovery advertisement.
386d30ea906Sjfb8856606 	 *
387d30ea906Sjfb8856606 	 * See struct rte_flow_item_icmp6_nd_na.
388d30ea906Sjfb8856606 	 */
389d30ea906Sjfb8856606 	RTE_FLOW_ITEM_TYPE_ICMP6_ND_NA,
390d30ea906Sjfb8856606 
391d30ea906Sjfb8856606 	/**
392d30ea906Sjfb8856606 	 * Matches the presence of any ICMPv6 neighbor discovery option.
393d30ea906Sjfb8856606 	 *
394d30ea906Sjfb8856606 	 * See struct rte_flow_item_icmp6_nd_opt.
395d30ea906Sjfb8856606 	 */
396d30ea906Sjfb8856606 	RTE_FLOW_ITEM_TYPE_ICMP6_ND_OPT,
397d30ea906Sjfb8856606 
398d30ea906Sjfb8856606 	/**
399d30ea906Sjfb8856606 	 * Matches an ICMPv6 neighbor discovery source Ethernet link-layer
400d30ea906Sjfb8856606 	 * address option.
401d30ea906Sjfb8856606 	 *
402d30ea906Sjfb8856606 	 * See struct rte_flow_item_icmp6_nd_opt_sla_eth.
403d30ea906Sjfb8856606 	 */
404d30ea906Sjfb8856606 	RTE_FLOW_ITEM_TYPE_ICMP6_ND_OPT_SLA_ETH,
405d30ea906Sjfb8856606 
406d30ea906Sjfb8856606 	/**
407d30ea906Sjfb8856606 	 * Matches an ICMPv6 neighbor discovery target Ethernet link-layer
408d30ea906Sjfb8856606 	 * address option.
409d30ea906Sjfb8856606 	 *
410d30ea906Sjfb8856606 	 * See struct rte_flow_item_icmp6_nd_opt_tla_eth.
411d30ea906Sjfb8856606 	 */
412d30ea906Sjfb8856606 	RTE_FLOW_ITEM_TYPE_ICMP6_ND_OPT_TLA_ETH,
413d30ea906Sjfb8856606 
414d30ea906Sjfb8856606 	/**
415d30ea906Sjfb8856606 	 * Matches specified mark field.
416d30ea906Sjfb8856606 	 *
417d30ea906Sjfb8856606 	 * See struct rte_flow_item_mark.
418d30ea906Sjfb8856606 	 */
419d30ea906Sjfb8856606 	RTE_FLOW_ITEM_TYPE_MARK,
420d30ea906Sjfb8856606 
421d30ea906Sjfb8856606 	/**
422d30ea906Sjfb8856606 	 * [META]
423d30ea906Sjfb8856606 	 *
4244418919fSjohnjiang 	 * Matches a metadata value.
4254418919fSjohnjiang 	 *
426d30ea906Sjfb8856606 	 * See struct rte_flow_item_meta.
427d30ea906Sjfb8856606 	 */
428d30ea906Sjfb8856606 	RTE_FLOW_ITEM_TYPE_META,
4294418919fSjohnjiang 
4304418919fSjohnjiang 	/**
4314418919fSjohnjiang 	 * Matches a GRE optional key field.
4324418919fSjohnjiang 	 *
4334418919fSjohnjiang 	 * The value should a big-endian 32bit integer.
4344418919fSjohnjiang 	 *
4354418919fSjohnjiang 	 * When this item present the K bit is implicitly matched as "1"
4364418919fSjohnjiang 	 * in the default mask.
4374418919fSjohnjiang 	 *
4384418919fSjohnjiang 	 * @p spec/mask type:
4394418919fSjohnjiang 	 * @code rte_be32_t * @endcode
4404418919fSjohnjiang 	 */
4414418919fSjohnjiang 	RTE_FLOW_ITEM_TYPE_GRE_KEY,
4424418919fSjohnjiang 
4434418919fSjohnjiang 	/**
4444418919fSjohnjiang 	 * Matches a GTP extension header: PDU session container.
4454418919fSjohnjiang 	 *
4464418919fSjohnjiang 	 * Configure flow for GTP packets with extension header type 0x85.
4474418919fSjohnjiang 	 *
4484418919fSjohnjiang 	 * See struct rte_flow_item_gtp_psc.
4494418919fSjohnjiang 	 */
4504418919fSjohnjiang 	RTE_FLOW_ITEM_TYPE_GTP_PSC,
4514418919fSjohnjiang 
4524418919fSjohnjiang 	/**
4534418919fSjohnjiang 	 * Matches a PPPoE header.
4544418919fSjohnjiang 	 *
4554418919fSjohnjiang 	 * Configure flow for PPPoE session packets.
4564418919fSjohnjiang 	 *
4574418919fSjohnjiang 	 * See struct rte_flow_item_pppoe.
4584418919fSjohnjiang 	 */
4594418919fSjohnjiang 	RTE_FLOW_ITEM_TYPE_PPPOES,
4604418919fSjohnjiang 
4614418919fSjohnjiang 	/**
4624418919fSjohnjiang 	 * Matches a PPPoE header.
4634418919fSjohnjiang 	 *
4644418919fSjohnjiang 	 * Configure flow for PPPoE discovery packets.
4654418919fSjohnjiang 	 *
4664418919fSjohnjiang 	 * See struct rte_flow_item_pppoe.
4674418919fSjohnjiang 	 */
4684418919fSjohnjiang 	RTE_FLOW_ITEM_TYPE_PPPOED,
4694418919fSjohnjiang 
4704418919fSjohnjiang 	/**
4714418919fSjohnjiang 	 * Matches a PPPoE optional proto_id field.
4724418919fSjohnjiang 	 *
4734418919fSjohnjiang 	 * It only applies to PPPoE session packets.
4744418919fSjohnjiang 	 *
4754418919fSjohnjiang 	 * See struct rte_flow_item_pppoe_proto_id.
4764418919fSjohnjiang 	 */
4774418919fSjohnjiang 	RTE_FLOW_ITEM_TYPE_PPPOE_PROTO_ID,
4784418919fSjohnjiang 
4794418919fSjohnjiang 	/**
4804418919fSjohnjiang 	 * Matches Network service header (NSH).
4814418919fSjohnjiang 	 * See struct rte_flow_item_nsh.
4824418919fSjohnjiang 	 *
4834418919fSjohnjiang 	 */
4844418919fSjohnjiang 	RTE_FLOW_ITEM_TYPE_NSH,
4854418919fSjohnjiang 
4864418919fSjohnjiang 	/**
4874418919fSjohnjiang 	 * Matches Internet Group Management Protocol (IGMP).
4884418919fSjohnjiang 	 * See struct rte_flow_item_igmp.
4894418919fSjohnjiang 	 *
4904418919fSjohnjiang 	 */
4914418919fSjohnjiang 	RTE_FLOW_ITEM_TYPE_IGMP,
4924418919fSjohnjiang 
4934418919fSjohnjiang 	/**
4944418919fSjohnjiang 	 * Matches IP Authentication Header (AH).
4954418919fSjohnjiang 	 * See struct rte_flow_item_ah.
4964418919fSjohnjiang 	 *
4974418919fSjohnjiang 	 */
4984418919fSjohnjiang 	RTE_FLOW_ITEM_TYPE_AH,
4994418919fSjohnjiang 
5004418919fSjohnjiang 	/**
5014418919fSjohnjiang 	 * Matches a HIGIG header.
5024418919fSjohnjiang 	 * see struct rte_flow_item_higig2_hdr.
5034418919fSjohnjiang 	 */
5044418919fSjohnjiang 	RTE_FLOW_ITEM_TYPE_HIGIG2,
5054418919fSjohnjiang 
5064418919fSjohnjiang 	/**
5074418919fSjohnjiang 	 * [META]
5084418919fSjohnjiang 	 *
5094418919fSjohnjiang 	 * Matches a tag value.
5104418919fSjohnjiang 	 *
5114418919fSjohnjiang 	 * See struct rte_flow_item_tag.
5124418919fSjohnjiang 	 */
5134418919fSjohnjiang 	RTE_FLOW_ITEM_TYPE_TAG,
514*2d9fd380Sjfb8856606 
515*2d9fd380Sjfb8856606 	/**
516*2d9fd380Sjfb8856606 	 * Matches a L2TPv3 over IP header.
517*2d9fd380Sjfb8856606 	 *
518*2d9fd380Sjfb8856606 	 * Configure flow for L2TPv3 over IP packets.
519*2d9fd380Sjfb8856606 	 *
520*2d9fd380Sjfb8856606 	 * See struct rte_flow_item_l2tpv3oip.
521*2d9fd380Sjfb8856606 	 */
522*2d9fd380Sjfb8856606 	RTE_FLOW_ITEM_TYPE_L2TPV3OIP,
523*2d9fd380Sjfb8856606 
524*2d9fd380Sjfb8856606 	/**
525*2d9fd380Sjfb8856606 	 * Matches PFCP Header.
526*2d9fd380Sjfb8856606 	 * See struct rte_flow_item_pfcp.
527*2d9fd380Sjfb8856606 	 *
528*2d9fd380Sjfb8856606 	 */
529*2d9fd380Sjfb8856606 	RTE_FLOW_ITEM_TYPE_PFCP,
530*2d9fd380Sjfb8856606 
531*2d9fd380Sjfb8856606 	/**
532*2d9fd380Sjfb8856606 	 * Matches eCPRI Header.
533*2d9fd380Sjfb8856606 	 *
534*2d9fd380Sjfb8856606 	 * Configure flow for eCPRI over ETH or UDP packets.
535*2d9fd380Sjfb8856606 	 *
536*2d9fd380Sjfb8856606 	 * See struct rte_flow_item_ecpri.
537*2d9fd380Sjfb8856606 	 */
538*2d9fd380Sjfb8856606 	RTE_FLOW_ITEM_TYPE_ECPRI,
539*2d9fd380Sjfb8856606 
540*2d9fd380Sjfb8856606 	/**
541*2d9fd380Sjfb8856606 	 * Matches the presence of IPv6 fragment extension header.
542*2d9fd380Sjfb8856606 	 *
543*2d9fd380Sjfb8856606 	 * See struct rte_flow_item_ipv6_frag_ext.
544*2d9fd380Sjfb8856606 	 */
545*2d9fd380Sjfb8856606 	RTE_FLOW_ITEM_TYPE_IPV6_FRAG_EXT,
546d30ea906Sjfb8856606 };
547d30ea906Sjfb8856606 
548d30ea906Sjfb8856606 /**
5494418919fSjohnjiang  *
5504418919fSjohnjiang  * RTE_FLOW_ITEM_TYPE_HIGIG2
5514418919fSjohnjiang  * Matches higig2 header
5524418919fSjohnjiang  */
5534418919fSjohnjiang RTE_STD_C11
5544418919fSjohnjiang struct rte_flow_item_higig2_hdr {
5554418919fSjohnjiang 	struct rte_higig2_hdr hdr;
5564418919fSjohnjiang };
5574418919fSjohnjiang 
5584418919fSjohnjiang /** Default mask for RTE_FLOW_ITEM_TYPE_HIGIG2. */
5594418919fSjohnjiang #ifndef __cplusplus
5604418919fSjohnjiang static const struct rte_flow_item_higig2_hdr rte_flow_item_higig2_hdr_mask = {
5614418919fSjohnjiang 	.hdr = {
5624418919fSjohnjiang 		.ppt1 = {
5634418919fSjohnjiang 			.classification = 0xffff,
5644418919fSjohnjiang 			.vid = 0xfff,
5654418919fSjohnjiang 		},
5664418919fSjohnjiang 	},
5674418919fSjohnjiang };
5684418919fSjohnjiang #endif
5694418919fSjohnjiang 
5704418919fSjohnjiang /**
571d30ea906Sjfb8856606  * RTE_FLOW_ITEM_TYPE_ANY
572d30ea906Sjfb8856606  *
573d30ea906Sjfb8856606  * Matches any protocol in place of the current layer, a single ANY may also
574d30ea906Sjfb8856606  * stand for several protocol layers.
575d30ea906Sjfb8856606  *
576d30ea906Sjfb8856606  * This is usually specified as the first pattern item when looking for a
577d30ea906Sjfb8856606  * protocol anywhere in a packet.
578d30ea906Sjfb8856606  *
579d30ea906Sjfb8856606  * A zeroed mask stands for any number of layers.
580d30ea906Sjfb8856606  */
581d30ea906Sjfb8856606 struct rte_flow_item_any {
582d30ea906Sjfb8856606 	uint32_t num; /**< Number of layers covered. */
583d30ea906Sjfb8856606 };
584d30ea906Sjfb8856606 
585d30ea906Sjfb8856606 /** Default mask for RTE_FLOW_ITEM_TYPE_ANY. */
586d30ea906Sjfb8856606 #ifndef __cplusplus
587d30ea906Sjfb8856606 static const struct rte_flow_item_any rte_flow_item_any_mask = {
588d30ea906Sjfb8856606 	.num = 0x00000000,
589d30ea906Sjfb8856606 };
590d30ea906Sjfb8856606 #endif
591d30ea906Sjfb8856606 
592d30ea906Sjfb8856606 /**
593d30ea906Sjfb8856606  * RTE_FLOW_ITEM_TYPE_VF
594d30ea906Sjfb8856606  *
595d30ea906Sjfb8856606  * Matches traffic originating from (ingress) or going to (egress) a given
596d30ea906Sjfb8856606  * virtual function of the current device.
597d30ea906Sjfb8856606  *
598d30ea906Sjfb8856606  * If supported, should work even if the virtual function is not managed by
599d30ea906Sjfb8856606  * the application and thus not associated with a DPDK port ID.
600d30ea906Sjfb8856606  *
601d30ea906Sjfb8856606  * Note this pattern item does not match VF representors traffic which, as
602d30ea906Sjfb8856606  * separate entities, should be addressed through their own DPDK port IDs.
603d30ea906Sjfb8856606  *
604d30ea906Sjfb8856606  * - Can be specified multiple times to match traffic addressed to several
605d30ea906Sjfb8856606  *   VF IDs.
606d30ea906Sjfb8856606  * - Can be combined with a PF item to match both PF and VF traffic.
607d30ea906Sjfb8856606  *
608d30ea906Sjfb8856606  * A zeroed mask can be used to match any VF ID.
609d30ea906Sjfb8856606  */
610d30ea906Sjfb8856606 struct rte_flow_item_vf {
611d30ea906Sjfb8856606 	uint32_t id; /**< VF ID. */
612d30ea906Sjfb8856606 };
613d30ea906Sjfb8856606 
614d30ea906Sjfb8856606 /** Default mask for RTE_FLOW_ITEM_TYPE_VF. */
615d30ea906Sjfb8856606 #ifndef __cplusplus
616d30ea906Sjfb8856606 static const struct rte_flow_item_vf rte_flow_item_vf_mask = {
617d30ea906Sjfb8856606 	.id = 0x00000000,
618d30ea906Sjfb8856606 };
619d30ea906Sjfb8856606 #endif
620d30ea906Sjfb8856606 
621d30ea906Sjfb8856606 /**
622d30ea906Sjfb8856606  * RTE_FLOW_ITEM_TYPE_PHY_PORT
623d30ea906Sjfb8856606  *
624d30ea906Sjfb8856606  * Matches traffic originating from (ingress) or going to (egress) a
625d30ea906Sjfb8856606  * physical port of the underlying device.
626d30ea906Sjfb8856606  *
627d30ea906Sjfb8856606  * The first PHY_PORT item overrides the physical port normally associated
628d30ea906Sjfb8856606  * with the specified DPDK input port (port_id). This item can be provided
629d30ea906Sjfb8856606  * several times to match additional physical ports.
630d30ea906Sjfb8856606  *
631d30ea906Sjfb8856606  * Note that physical ports are not necessarily tied to DPDK input ports
632d30ea906Sjfb8856606  * (port_id) when those are not under DPDK control. Possible values are
633d30ea906Sjfb8856606  * specific to each device, they are not necessarily indexed from zero and
634d30ea906Sjfb8856606  * may not be contiguous.
635d30ea906Sjfb8856606  *
636d30ea906Sjfb8856606  * As a device property, the list of allowed values as well as the value
637d30ea906Sjfb8856606  * associated with a port_id should be retrieved by other means.
638d30ea906Sjfb8856606  *
639d30ea906Sjfb8856606  * A zeroed mask can be used to match any port index.
640d30ea906Sjfb8856606  */
641d30ea906Sjfb8856606 struct rte_flow_item_phy_port {
642d30ea906Sjfb8856606 	uint32_t index; /**< Physical port index. */
643d30ea906Sjfb8856606 };
644d30ea906Sjfb8856606 
645d30ea906Sjfb8856606 /** Default mask for RTE_FLOW_ITEM_TYPE_PHY_PORT. */
646d30ea906Sjfb8856606 #ifndef __cplusplus
647d30ea906Sjfb8856606 static const struct rte_flow_item_phy_port rte_flow_item_phy_port_mask = {
648d30ea906Sjfb8856606 	.index = 0x00000000,
649d30ea906Sjfb8856606 };
650d30ea906Sjfb8856606 #endif
651d30ea906Sjfb8856606 
652d30ea906Sjfb8856606 /**
653d30ea906Sjfb8856606  * RTE_FLOW_ITEM_TYPE_PORT_ID
654d30ea906Sjfb8856606  *
655d30ea906Sjfb8856606  * Matches traffic originating from (ingress) or going to (egress) a given
656d30ea906Sjfb8856606  * DPDK port ID.
657d30ea906Sjfb8856606  *
658d30ea906Sjfb8856606  * Normally only supported if the port ID in question is known by the
659d30ea906Sjfb8856606  * underlying PMD and related to the device the flow rule is created
660d30ea906Sjfb8856606  * against.
661d30ea906Sjfb8856606  *
662d30ea906Sjfb8856606  * This must not be confused with @p PHY_PORT which refers to the physical
663d30ea906Sjfb8856606  * port of a device, whereas @p PORT_ID refers to a struct rte_eth_dev
664d30ea906Sjfb8856606  * object on the application side (also known as "port representor"
665d30ea906Sjfb8856606  * depending on the kind of underlying device).
666d30ea906Sjfb8856606  */
667d30ea906Sjfb8856606 struct rte_flow_item_port_id {
668d30ea906Sjfb8856606 	uint32_t id; /**< DPDK port ID. */
669d30ea906Sjfb8856606 };
670d30ea906Sjfb8856606 
671d30ea906Sjfb8856606 /** Default mask for RTE_FLOW_ITEM_TYPE_PORT_ID. */
672d30ea906Sjfb8856606 #ifndef __cplusplus
673d30ea906Sjfb8856606 static const struct rte_flow_item_port_id rte_flow_item_port_id_mask = {
674d30ea906Sjfb8856606 	.id = 0xffffffff,
675d30ea906Sjfb8856606 };
676d30ea906Sjfb8856606 #endif
677d30ea906Sjfb8856606 
678d30ea906Sjfb8856606 /**
679d30ea906Sjfb8856606  * RTE_FLOW_ITEM_TYPE_RAW
680d30ea906Sjfb8856606  *
681d30ea906Sjfb8856606  * Matches a byte string of a given length at a given offset.
682d30ea906Sjfb8856606  *
683d30ea906Sjfb8856606  * Offset is either absolute (using the start of the packet) or relative to
684d30ea906Sjfb8856606  * the end of the previous matched item in the stack, in which case negative
685d30ea906Sjfb8856606  * values are allowed.
686d30ea906Sjfb8856606  *
687d30ea906Sjfb8856606  * If search is enabled, offset is used as the starting point. The search
688d30ea906Sjfb8856606  * area can be delimited by setting limit to a nonzero value, which is the
689d30ea906Sjfb8856606  * maximum number of bytes after offset where the pattern may start.
690d30ea906Sjfb8856606  *
691d30ea906Sjfb8856606  * Matching a zero-length pattern is allowed, doing so resets the relative
692d30ea906Sjfb8856606  * offset for subsequent items.
693d30ea906Sjfb8856606  *
694d30ea906Sjfb8856606  * This type does not support ranges (struct rte_flow_item.last).
695d30ea906Sjfb8856606  */
696d30ea906Sjfb8856606 struct rte_flow_item_raw {
697d30ea906Sjfb8856606 	uint32_t relative:1; /**< Look for pattern after the previous item. */
698d30ea906Sjfb8856606 	uint32_t search:1; /**< Search pattern from offset (see also limit). */
699d30ea906Sjfb8856606 	uint32_t reserved:30; /**< Reserved, must be set to zero. */
700d30ea906Sjfb8856606 	int32_t offset; /**< Absolute or relative offset for pattern. */
701d30ea906Sjfb8856606 	uint16_t limit; /**< Search area limit for start of pattern. */
702d30ea906Sjfb8856606 	uint16_t length; /**< Pattern length. */
703d30ea906Sjfb8856606 	const uint8_t *pattern; /**< Byte string to look for. */
704d30ea906Sjfb8856606 };
705d30ea906Sjfb8856606 
706d30ea906Sjfb8856606 /** Default mask for RTE_FLOW_ITEM_TYPE_RAW. */
707d30ea906Sjfb8856606 #ifndef __cplusplus
708d30ea906Sjfb8856606 static const struct rte_flow_item_raw rte_flow_item_raw_mask = {
709d30ea906Sjfb8856606 	.relative = 1,
710d30ea906Sjfb8856606 	.search = 1,
711d30ea906Sjfb8856606 	.reserved = 0x3fffffff,
712d30ea906Sjfb8856606 	.offset = 0xffffffff,
713d30ea906Sjfb8856606 	.limit = 0xffff,
714d30ea906Sjfb8856606 	.length = 0xffff,
715d30ea906Sjfb8856606 	.pattern = NULL,
716d30ea906Sjfb8856606 };
717d30ea906Sjfb8856606 #endif
718d30ea906Sjfb8856606 
719d30ea906Sjfb8856606 /**
720d30ea906Sjfb8856606  * RTE_FLOW_ITEM_TYPE_ETH
721d30ea906Sjfb8856606  *
722d30ea906Sjfb8856606  * Matches an Ethernet header.
723d30ea906Sjfb8856606  *
724d30ea906Sjfb8856606  * The @p type field either stands for "EtherType" or "TPID" when followed
725d30ea906Sjfb8856606  * by so-called layer 2.5 pattern items such as RTE_FLOW_ITEM_TYPE_VLAN. In
726d30ea906Sjfb8856606  * the latter case, @p type refers to that of the outer header, with the
727d30ea906Sjfb8856606  * inner EtherType/TPID provided by the subsequent pattern item. This is the
728d30ea906Sjfb8856606  * same order as on the wire.
729*2d9fd380Sjfb8856606  * If the @p type field contains a TPID value, then only tagged packets with the
730*2d9fd380Sjfb8856606  * specified TPID will match the pattern.
731*2d9fd380Sjfb8856606  * The field @p has_vlan can be used to match any type of tagged packets,
732*2d9fd380Sjfb8856606  * instead of using the @p type field.
733*2d9fd380Sjfb8856606  * If the @p type and @p has_vlan fields are not specified, then both tagged
734*2d9fd380Sjfb8856606  * and untagged packets will match the pattern.
735d30ea906Sjfb8856606  */
736d30ea906Sjfb8856606 struct rte_flow_item_eth {
7374418919fSjohnjiang 	struct rte_ether_addr dst; /**< Destination MAC. */
7384418919fSjohnjiang 	struct rte_ether_addr src; /**< Source MAC. */
739d30ea906Sjfb8856606 	rte_be16_t type; /**< EtherType or TPID. */
740*2d9fd380Sjfb8856606 	uint32_t has_vlan:1; /**< Packet header contains at least one VLAN. */
741*2d9fd380Sjfb8856606 	uint32_t reserved:31; /**< Reserved, must be zero. */
742d30ea906Sjfb8856606 };
743d30ea906Sjfb8856606 
744d30ea906Sjfb8856606 /** Default mask for RTE_FLOW_ITEM_TYPE_ETH. */
745d30ea906Sjfb8856606 #ifndef __cplusplus
746d30ea906Sjfb8856606 static const struct rte_flow_item_eth rte_flow_item_eth_mask = {
747d30ea906Sjfb8856606 	.dst.addr_bytes = "\xff\xff\xff\xff\xff\xff",
748d30ea906Sjfb8856606 	.src.addr_bytes = "\xff\xff\xff\xff\xff\xff",
749d30ea906Sjfb8856606 	.type = RTE_BE16(0x0000),
750d30ea906Sjfb8856606 };
751d30ea906Sjfb8856606 #endif
752d30ea906Sjfb8856606 
753d30ea906Sjfb8856606 /**
754d30ea906Sjfb8856606  * RTE_FLOW_ITEM_TYPE_VLAN
755d30ea906Sjfb8856606  *
756d30ea906Sjfb8856606  * Matches an 802.1Q/ad VLAN tag.
757d30ea906Sjfb8856606  *
758d30ea906Sjfb8856606  * The corresponding standard outer EtherType (TPID) values are
7594418919fSjohnjiang  * RTE_ETHER_TYPE_VLAN or RTE_ETHER_TYPE_QINQ. It can be overridden by
7604418919fSjohnjiang  * the preceding pattern item.
761*2d9fd380Sjfb8856606  * If a @p VLAN item is present in the pattern, then only tagged packets will
762*2d9fd380Sjfb8856606  * match the pattern.
763*2d9fd380Sjfb8856606  * The field @p has_more_vlan can be used to match any type of tagged packets,
764*2d9fd380Sjfb8856606  * instead of using the @p inner_type field.
765*2d9fd380Sjfb8856606  * If the @p inner_type and @p has_more_vlan fields are not specified,
766*2d9fd380Sjfb8856606  * then any tagged packets will match the pattern.
767d30ea906Sjfb8856606  */
768d30ea906Sjfb8856606 struct rte_flow_item_vlan {
769d30ea906Sjfb8856606 	rte_be16_t tci; /**< Tag control information. */
770d30ea906Sjfb8856606 	rte_be16_t inner_type; /**< Inner EtherType or TPID. */
771*2d9fd380Sjfb8856606 	uint32_t has_more_vlan:1;
772*2d9fd380Sjfb8856606 	/**< Packet header contains at least one more VLAN, after this VLAN. */
773*2d9fd380Sjfb8856606 	uint32_t reserved:31; /**< Reserved, must be zero. */
774d30ea906Sjfb8856606 };
775d30ea906Sjfb8856606 
776d30ea906Sjfb8856606 /** Default mask for RTE_FLOW_ITEM_TYPE_VLAN. */
777d30ea906Sjfb8856606 #ifndef __cplusplus
778d30ea906Sjfb8856606 static const struct rte_flow_item_vlan rte_flow_item_vlan_mask = {
779d30ea906Sjfb8856606 	.tci = RTE_BE16(0x0fff),
780d30ea906Sjfb8856606 	.inner_type = RTE_BE16(0x0000),
781d30ea906Sjfb8856606 };
782d30ea906Sjfb8856606 #endif
783d30ea906Sjfb8856606 
784d30ea906Sjfb8856606 /**
785d30ea906Sjfb8856606  * RTE_FLOW_ITEM_TYPE_IPV4
786d30ea906Sjfb8856606  *
787d30ea906Sjfb8856606  * Matches an IPv4 header.
788d30ea906Sjfb8856606  *
789d30ea906Sjfb8856606  * Note: IPv4 options are handled by dedicated pattern items.
790d30ea906Sjfb8856606  */
791d30ea906Sjfb8856606 struct rte_flow_item_ipv4 {
7924418919fSjohnjiang 	struct rte_ipv4_hdr hdr; /**< IPv4 header definition. */
793d30ea906Sjfb8856606 };
794d30ea906Sjfb8856606 
795d30ea906Sjfb8856606 /** Default mask for RTE_FLOW_ITEM_TYPE_IPV4. */
796d30ea906Sjfb8856606 #ifndef __cplusplus
797d30ea906Sjfb8856606 static const struct rte_flow_item_ipv4 rte_flow_item_ipv4_mask = {
798d30ea906Sjfb8856606 	.hdr = {
799d30ea906Sjfb8856606 		.src_addr = RTE_BE32(0xffffffff),
800d30ea906Sjfb8856606 		.dst_addr = RTE_BE32(0xffffffff),
801d30ea906Sjfb8856606 	},
802d30ea906Sjfb8856606 };
803d30ea906Sjfb8856606 #endif
804d30ea906Sjfb8856606 
805d30ea906Sjfb8856606 /**
806d30ea906Sjfb8856606  * RTE_FLOW_ITEM_TYPE_IPV6.
807d30ea906Sjfb8856606  *
808d30ea906Sjfb8856606  * Matches an IPv6 header.
809d30ea906Sjfb8856606  *
810*2d9fd380Sjfb8856606  * Dedicated flags indicate if header contains specific extension headers.
811d30ea906Sjfb8856606  */
812d30ea906Sjfb8856606 struct rte_flow_item_ipv6 {
8134418919fSjohnjiang 	struct rte_ipv6_hdr hdr; /**< IPv6 header definition. */
814*2d9fd380Sjfb8856606 	uint32_t has_hop_ext:1;
815*2d9fd380Sjfb8856606 	/**< Header contains Hop-by-Hop Options extension header. */
816*2d9fd380Sjfb8856606 	uint32_t has_route_ext:1;
817*2d9fd380Sjfb8856606 	/**< Header contains Routing extension header. */
818*2d9fd380Sjfb8856606 	uint32_t has_frag_ext:1;
819*2d9fd380Sjfb8856606 	/**< Header contains Fragment extension header. */
820*2d9fd380Sjfb8856606 	uint32_t has_auth_ext:1;
821*2d9fd380Sjfb8856606 	/**< Header contains Authentication extension header. */
822*2d9fd380Sjfb8856606 	uint32_t has_esp_ext:1;
823*2d9fd380Sjfb8856606 	/**< Header contains Encapsulation Security Payload extension header. */
824*2d9fd380Sjfb8856606 	uint32_t has_dest_ext:1;
825*2d9fd380Sjfb8856606 	/**< Header contains Destination Options extension header. */
826*2d9fd380Sjfb8856606 	uint32_t has_mobil_ext:1;
827*2d9fd380Sjfb8856606 	/**< Header contains Mobility extension header. */
828*2d9fd380Sjfb8856606 	uint32_t has_hip_ext:1;
829*2d9fd380Sjfb8856606 	/**< Header contains Host Identity Protocol extension header. */
830*2d9fd380Sjfb8856606 	uint32_t has_shim6_ext:1;
831*2d9fd380Sjfb8856606 	/**< Header contains Shim6 Protocol extension header. */
832*2d9fd380Sjfb8856606 	uint32_t reserved:23;
833*2d9fd380Sjfb8856606 	/**< Reserved for future extension headers, must be zero. */
834d30ea906Sjfb8856606 };
835d30ea906Sjfb8856606 
836d30ea906Sjfb8856606 /** Default mask for RTE_FLOW_ITEM_TYPE_IPV6. */
837d30ea906Sjfb8856606 #ifndef __cplusplus
838d30ea906Sjfb8856606 static const struct rte_flow_item_ipv6 rte_flow_item_ipv6_mask = {
839d30ea906Sjfb8856606 	.hdr = {
840d30ea906Sjfb8856606 		.src_addr =
841d30ea906Sjfb8856606 			"\xff\xff\xff\xff\xff\xff\xff\xff"
842d30ea906Sjfb8856606 			"\xff\xff\xff\xff\xff\xff\xff\xff",
843d30ea906Sjfb8856606 		.dst_addr =
844d30ea906Sjfb8856606 			"\xff\xff\xff\xff\xff\xff\xff\xff"
845d30ea906Sjfb8856606 			"\xff\xff\xff\xff\xff\xff\xff\xff",
846d30ea906Sjfb8856606 	},
847d30ea906Sjfb8856606 };
848d30ea906Sjfb8856606 #endif
849d30ea906Sjfb8856606 
850d30ea906Sjfb8856606 /**
851d30ea906Sjfb8856606  * RTE_FLOW_ITEM_TYPE_ICMP.
852d30ea906Sjfb8856606  *
853d30ea906Sjfb8856606  * Matches an ICMP header.
854d30ea906Sjfb8856606  */
855d30ea906Sjfb8856606 struct rte_flow_item_icmp {
8564418919fSjohnjiang 	struct rte_icmp_hdr hdr; /**< ICMP header definition. */
857d30ea906Sjfb8856606 };
858d30ea906Sjfb8856606 
859d30ea906Sjfb8856606 /** Default mask for RTE_FLOW_ITEM_TYPE_ICMP. */
860d30ea906Sjfb8856606 #ifndef __cplusplus
861d30ea906Sjfb8856606 static const struct rte_flow_item_icmp rte_flow_item_icmp_mask = {
862d30ea906Sjfb8856606 	.hdr = {
863d30ea906Sjfb8856606 		.icmp_type = 0xff,
864d30ea906Sjfb8856606 		.icmp_code = 0xff,
865d30ea906Sjfb8856606 	},
866d30ea906Sjfb8856606 };
867d30ea906Sjfb8856606 #endif
868d30ea906Sjfb8856606 
869d30ea906Sjfb8856606 /**
870d30ea906Sjfb8856606  * RTE_FLOW_ITEM_TYPE_UDP.
871d30ea906Sjfb8856606  *
872d30ea906Sjfb8856606  * Matches a UDP header.
873d30ea906Sjfb8856606  */
874d30ea906Sjfb8856606 struct rte_flow_item_udp {
8754418919fSjohnjiang 	struct rte_udp_hdr hdr; /**< UDP header definition. */
876d30ea906Sjfb8856606 };
877d30ea906Sjfb8856606 
878d30ea906Sjfb8856606 /** Default mask for RTE_FLOW_ITEM_TYPE_UDP. */
879d30ea906Sjfb8856606 #ifndef __cplusplus
880d30ea906Sjfb8856606 static const struct rte_flow_item_udp rte_flow_item_udp_mask = {
881d30ea906Sjfb8856606 	.hdr = {
882d30ea906Sjfb8856606 		.src_port = RTE_BE16(0xffff),
883d30ea906Sjfb8856606 		.dst_port = RTE_BE16(0xffff),
884d30ea906Sjfb8856606 	},
885d30ea906Sjfb8856606 };
886d30ea906Sjfb8856606 #endif
887d30ea906Sjfb8856606 
888d30ea906Sjfb8856606 /**
889d30ea906Sjfb8856606  * RTE_FLOW_ITEM_TYPE_TCP.
890d30ea906Sjfb8856606  *
891d30ea906Sjfb8856606  * Matches a TCP header.
892d30ea906Sjfb8856606  */
893d30ea906Sjfb8856606 struct rte_flow_item_tcp {
8944418919fSjohnjiang 	struct rte_tcp_hdr hdr; /**< TCP header definition. */
895d30ea906Sjfb8856606 };
896d30ea906Sjfb8856606 
897d30ea906Sjfb8856606 /** Default mask for RTE_FLOW_ITEM_TYPE_TCP. */
898d30ea906Sjfb8856606 #ifndef __cplusplus
899d30ea906Sjfb8856606 static const struct rte_flow_item_tcp rte_flow_item_tcp_mask = {
900d30ea906Sjfb8856606 	.hdr = {
901d30ea906Sjfb8856606 		.src_port = RTE_BE16(0xffff),
902d30ea906Sjfb8856606 		.dst_port = RTE_BE16(0xffff),
903d30ea906Sjfb8856606 	},
904d30ea906Sjfb8856606 };
905d30ea906Sjfb8856606 #endif
906d30ea906Sjfb8856606 
907d30ea906Sjfb8856606 /**
908d30ea906Sjfb8856606  * RTE_FLOW_ITEM_TYPE_SCTP.
909d30ea906Sjfb8856606  *
910d30ea906Sjfb8856606  * Matches a SCTP header.
911d30ea906Sjfb8856606  */
912d30ea906Sjfb8856606 struct rte_flow_item_sctp {
9134418919fSjohnjiang 	struct rte_sctp_hdr hdr; /**< SCTP header definition. */
914d30ea906Sjfb8856606 };
915d30ea906Sjfb8856606 
916d30ea906Sjfb8856606 /** Default mask for RTE_FLOW_ITEM_TYPE_SCTP. */
917d30ea906Sjfb8856606 #ifndef __cplusplus
918d30ea906Sjfb8856606 static const struct rte_flow_item_sctp rte_flow_item_sctp_mask = {
919d30ea906Sjfb8856606 	.hdr = {
920d30ea906Sjfb8856606 		.src_port = RTE_BE16(0xffff),
921d30ea906Sjfb8856606 		.dst_port = RTE_BE16(0xffff),
922d30ea906Sjfb8856606 	},
923d30ea906Sjfb8856606 };
924d30ea906Sjfb8856606 #endif
925d30ea906Sjfb8856606 
926d30ea906Sjfb8856606 /**
927d30ea906Sjfb8856606  * RTE_FLOW_ITEM_TYPE_VXLAN.
928d30ea906Sjfb8856606  *
929d30ea906Sjfb8856606  * Matches a VXLAN header (RFC 7348).
930d30ea906Sjfb8856606  */
931d30ea906Sjfb8856606 struct rte_flow_item_vxlan {
932d30ea906Sjfb8856606 	uint8_t flags; /**< Normally 0x08 (I flag). */
933d30ea906Sjfb8856606 	uint8_t rsvd0[3]; /**< Reserved, normally 0x000000. */
934d30ea906Sjfb8856606 	uint8_t vni[3]; /**< VXLAN identifier. */
935d30ea906Sjfb8856606 	uint8_t rsvd1; /**< Reserved, normally 0x00. */
936d30ea906Sjfb8856606 };
937d30ea906Sjfb8856606 
938d30ea906Sjfb8856606 /** Default mask for RTE_FLOW_ITEM_TYPE_VXLAN. */
939d30ea906Sjfb8856606 #ifndef __cplusplus
940d30ea906Sjfb8856606 static const struct rte_flow_item_vxlan rte_flow_item_vxlan_mask = {
941d30ea906Sjfb8856606 	.vni = "\xff\xff\xff",
942d30ea906Sjfb8856606 };
943d30ea906Sjfb8856606 #endif
944d30ea906Sjfb8856606 
945d30ea906Sjfb8856606 /**
946d30ea906Sjfb8856606  * RTE_FLOW_ITEM_TYPE_E_TAG.
947d30ea906Sjfb8856606  *
948d30ea906Sjfb8856606  * Matches a E-tag header.
949d30ea906Sjfb8856606  *
950d30ea906Sjfb8856606  * The corresponding standard outer EtherType (TPID) value is
9514418919fSjohnjiang  * RTE_ETHER_TYPE_ETAG. It can be overridden by the preceding pattern item.
952d30ea906Sjfb8856606  */
953d30ea906Sjfb8856606 struct rte_flow_item_e_tag {
954d30ea906Sjfb8856606 	/**
955d30ea906Sjfb8856606 	 * E-Tag control information (E-TCI).
956d30ea906Sjfb8856606 	 * E-PCP (3b), E-DEI (1b), ingress E-CID base (12b).
957d30ea906Sjfb8856606 	 */
958d30ea906Sjfb8856606 	rte_be16_t epcp_edei_in_ecid_b;
959d30ea906Sjfb8856606 	/** Reserved (2b), GRP (2b), E-CID base (12b). */
960d30ea906Sjfb8856606 	rte_be16_t rsvd_grp_ecid_b;
961d30ea906Sjfb8856606 	uint8_t in_ecid_e; /**< Ingress E-CID ext. */
962d30ea906Sjfb8856606 	uint8_t ecid_e; /**< E-CID ext. */
963d30ea906Sjfb8856606 	rte_be16_t inner_type; /**< Inner EtherType or TPID. */
964d30ea906Sjfb8856606 };
965d30ea906Sjfb8856606 
966d30ea906Sjfb8856606 /** Default mask for RTE_FLOW_ITEM_TYPE_E_TAG. */
967d30ea906Sjfb8856606 #ifndef __cplusplus
968d30ea906Sjfb8856606 static const struct rte_flow_item_e_tag rte_flow_item_e_tag_mask = {
969d30ea906Sjfb8856606 	.rsvd_grp_ecid_b = RTE_BE16(0x3fff),
970d30ea906Sjfb8856606 };
971d30ea906Sjfb8856606 #endif
972d30ea906Sjfb8856606 
973d30ea906Sjfb8856606 /**
974d30ea906Sjfb8856606  * RTE_FLOW_ITEM_TYPE_NVGRE.
975d30ea906Sjfb8856606  *
976d30ea906Sjfb8856606  * Matches a NVGRE header.
977d30ea906Sjfb8856606  */
978d30ea906Sjfb8856606 struct rte_flow_item_nvgre {
979d30ea906Sjfb8856606 	/**
980d30ea906Sjfb8856606 	 * Checksum (1b), undefined (1b), key bit (1b), sequence number (1b),
981d30ea906Sjfb8856606 	 * reserved 0 (9b), version (3b).
982d30ea906Sjfb8856606 	 *
983d30ea906Sjfb8856606 	 * c_k_s_rsvd0_ver must have value 0x2000 according to RFC 7637.
984d30ea906Sjfb8856606 	 */
985d30ea906Sjfb8856606 	rte_be16_t c_k_s_rsvd0_ver;
986d30ea906Sjfb8856606 	rte_be16_t protocol; /**< Protocol type (0x6558). */
987d30ea906Sjfb8856606 	uint8_t tni[3]; /**< Virtual subnet ID. */
988d30ea906Sjfb8856606 	uint8_t flow_id; /**< Flow ID. */
989d30ea906Sjfb8856606 };
990d30ea906Sjfb8856606 
991d30ea906Sjfb8856606 /** Default mask for RTE_FLOW_ITEM_TYPE_NVGRE. */
992d30ea906Sjfb8856606 #ifndef __cplusplus
993d30ea906Sjfb8856606 static const struct rte_flow_item_nvgre rte_flow_item_nvgre_mask = {
994d30ea906Sjfb8856606 	.tni = "\xff\xff\xff",
995d30ea906Sjfb8856606 };
996d30ea906Sjfb8856606 #endif
997d30ea906Sjfb8856606 
998d30ea906Sjfb8856606 /**
999d30ea906Sjfb8856606  * RTE_FLOW_ITEM_TYPE_MPLS.
1000d30ea906Sjfb8856606  *
1001d30ea906Sjfb8856606  * Matches a MPLS header.
1002d30ea906Sjfb8856606  */
1003d30ea906Sjfb8856606 struct rte_flow_item_mpls {
1004d30ea906Sjfb8856606 	/**
1005d30ea906Sjfb8856606 	 * Label (20b), TC (3b), Bottom of Stack (1b).
1006d30ea906Sjfb8856606 	 */
1007d30ea906Sjfb8856606 	uint8_t label_tc_s[3];
1008d30ea906Sjfb8856606 	uint8_t ttl; /** Time-to-Live. */
1009d30ea906Sjfb8856606 };
1010d30ea906Sjfb8856606 
1011d30ea906Sjfb8856606 /** Default mask for RTE_FLOW_ITEM_TYPE_MPLS. */
1012d30ea906Sjfb8856606 #ifndef __cplusplus
1013d30ea906Sjfb8856606 static const struct rte_flow_item_mpls rte_flow_item_mpls_mask = {
1014d30ea906Sjfb8856606 	.label_tc_s = "\xff\xff\xf0",
1015d30ea906Sjfb8856606 };
1016d30ea906Sjfb8856606 #endif
1017d30ea906Sjfb8856606 
1018d30ea906Sjfb8856606 /**
1019d30ea906Sjfb8856606  * RTE_FLOW_ITEM_TYPE_GRE.
1020d30ea906Sjfb8856606  *
1021d30ea906Sjfb8856606  * Matches a GRE header.
1022d30ea906Sjfb8856606  */
1023d30ea906Sjfb8856606 struct rte_flow_item_gre {
1024d30ea906Sjfb8856606 	/**
1025d30ea906Sjfb8856606 	 * Checksum (1b), reserved 0 (12b), version (3b).
1026d30ea906Sjfb8856606 	 * Refer to RFC 2784.
1027d30ea906Sjfb8856606 	 */
1028d30ea906Sjfb8856606 	rte_be16_t c_rsvd0_ver;
1029d30ea906Sjfb8856606 	rte_be16_t protocol; /**< Protocol type. */
1030d30ea906Sjfb8856606 };
1031d30ea906Sjfb8856606 
1032d30ea906Sjfb8856606 /** Default mask for RTE_FLOW_ITEM_TYPE_GRE. */
1033d30ea906Sjfb8856606 #ifndef __cplusplus
1034d30ea906Sjfb8856606 static const struct rte_flow_item_gre rte_flow_item_gre_mask = {
1035d30ea906Sjfb8856606 	.protocol = RTE_BE16(0xffff),
1036d30ea906Sjfb8856606 };
1037d30ea906Sjfb8856606 #endif
1038d30ea906Sjfb8856606 
1039d30ea906Sjfb8856606 /**
1040d30ea906Sjfb8856606  * RTE_FLOW_ITEM_TYPE_FUZZY
1041d30ea906Sjfb8856606  *
1042d30ea906Sjfb8856606  * Fuzzy pattern match, expect faster than default.
1043d30ea906Sjfb8856606  *
1044d30ea906Sjfb8856606  * This is for device that support fuzzy match option.
1045d30ea906Sjfb8856606  * Usually a fuzzy match is fast but the cost is accuracy.
1046d30ea906Sjfb8856606  * i.e. Signature Match only match pattern's hash value, but it is
1047d30ea906Sjfb8856606  * possible two different patterns have the same hash value.
1048d30ea906Sjfb8856606  *
1049d30ea906Sjfb8856606  * Matching accuracy level can be configure by threshold.
1050d30ea906Sjfb8856606  * Driver can divide the range of threshold and map to different
1051d30ea906Sjfb8856606  * accuracy levels that device support.
1052d30ea906Sjfb8856606  *
1053d30ea906Sjfb8856606  * Threshold 0 means perfect match (no fuzziness), while threshold
1054d30ea906Sjfb8856606  * 0xffffffff means fuzziest match.
1055d30ea906Sjfb8856606  */
1056d30ea906Sjfb8856606 struct rte_flow_item_fuzzy {
1057d30ea906Sjfb8856606 	uint32_t thresh; /**< Accuracy threshold. */
1058d30ea906Sjfb8856606 };
1059d30ea906Sjfb8856606 
1060d30ea906Sjfb8856606 /** Default mask for RTE_FLOW_ITEM_TYPE_FUZZY. */
1061d30ea906Sjfb8856606 #ifndef __cplusplus
1062d30ea906Sjfb8856606 static const struct rte_flow_item_fuzzy rte_flow_item_fuzzy_mask = {
1063d30ea906Sjfb8856606 	.thresh = 0xffffffff,
1064d30ea906Sjfb8856606 };
1065d30ea906Sjfb8856606 #endif
1066d30ea906Sjfb8856606 
1067d30ea906Sjfb8856606 /**
1068d30ea906Sjfb8856606  * RTE_FLOW_ITEM_TYPE_GTP.
1069d30ea906Sjfb8856606  *
1070d30ea906Sjfb8856606  * Matches a GTPv1 header.
1071d30ea906Sjfb8856606  */
1072d30ea906Sjfb8856606 struct rte_flow_item_gtp {
1073d30ea906Sjfb8856606 	/**
1074d30ea906Sjfb8856606 	 * Version (3b), protocol type (1b), reserved (1b),
1075d30ea906Sjfb8856606 	 * Extension header flag (1b),
1076d30ea906Sjfb8856606 	 * Sequence number flag (1b),
1077d30ea906Sjfb8856606 	 * N-PDU number flag (1b).
1078d30ea906Sjfb8856606 	 */
1079d30ea906Sjfb8856606 	uint8_t v_pt_rsv_flags;
1080d30ea906Sjfb8856606 	uint8_t msg_type; /**< Message type. */
1081d30ea906Sjfb8856606 	rte_be16_t msg_len; /**< Message length. */
1082d30ea906Sjfb8856606 	rte_be32_t teid; /**< Tunnel endpoint identifier. */
1083d30ea906Sjfb8856606 };
1084d30ea906Sjfb8856606 
1085d30ea906Sjfb8856606 /** Default mask for RTE_FLOW_ITEM_TYPE_GTP. */
1086d30ea906Sjfb8856606 #ifndef __cplusplus
1087d30ea906Sjfb8856606 static const struct rte_flow_item_gtp rte_flow_item_gtp_mask = {
1088d30ea906Sjfb8856606 	.teid = RTE_BE32(0xffffffff),
1089d30ea906Sjfb8856606 };
1090d30ea906Sjfb8856606 #endif
1091d30ea906Sjfb8856606 
1092d30ea906Sjfb8856606 /**
1093d30ea906Sjfb8856606  * RTE_FLOW_ITEM_TYPE_ESP
1094d30ea906Sjfb8856606  *
1095d30ea906Sjfb8856606  * Matches an ESP header.
1096d30ea906Sjfb8856606  */
1097d30ea906Sjfb8856606 struct rte_flow_item_esp {
10984418919fSjohnjiang 	struct rte_esp_hdr hdr; /**< ESP header definition. */
1099d30ea906Sjfb8856606 };
1100d30ea906Sjfb8856606 
1101d30ea906Sjfb8856606 /** Default mask for RTE_FLOW_ITEM_TYPE_ESP. */
1102d30ea906Sjfb8856606 #ifndef __cplusplus
1103d30ea906Sjfb8856606 static const struct rte_flow_item_esp rte_flow_item_esp_mask = {
1104d30ea906Sjfb8856606 	.hdr = {
11054b05018fSfengbojiang 		.spi = RTE_BE32(0xffffffff),
1106d30ea906Sjfb8856606 	},
1107d30ea906Sjfb8856606 };
1108d30ea906Sjfb8856606 #endif
1109d30ea906Sjfb8856606 
1110d30ea906Sjfb8856606 /**
1111d30ea906Sjfb8856606  * RTE_FLOW_ITEM_TYPE_GENEVE.
1112d30ea906Sjfb8856606  *
1113d30ea906Sjfb8856606  * Matches a GENEVE header.
1114d30ea906Sjfb8856606  */
1115d30ea906Sjfb8856606 struct rte_flow_item_geneve {
1116d30ea906Sjfb8856606 	/**
1117d30ea906Sjfb8856606 	 * Version (2b), length of the options fields (6b), OAM packet (1b),
1118d30ea906Sjfb8856606 	 * critical options present (1b), reserved 0 (6b).
1119d30ea906Sjfb8856606 	 */
1120d30ea906Sjfb8856606 	rte_be16_t ver_opt_len_o_c_rsvd0;
1121d30ea906Sjfb8856606 	rte_be16_t protocol; /**< Protocol type. */
1122d30ea906Sjfb8856606 	uint8_t vni[3]; /**< Virtual Network Identifier. */
1123d30ea906Sjfb8856606 	uint8_t rsvd1; /**< Reserved, normally 0x00. */
1124d30ea906Sjfb8856606 };
1125d30ea906Sjfb8856606 
1126d30ea906Sjfb8856606 /** Default mask for RTE_FLOW_ITEM_TYPE_GENEVE. */
1127d30ea906Sjfb8856606 #ifndef __cplusplus
1128d30ea906Sjfb8856606 static const struct rte_flow_item_geneve rte_flow_item_geneve_mask = {
1129d30ea906Sjfb8856606 	.vni = "\xff\xff\xff",
1130d30ea906Sjfb8856606 };
1131d30ea906Sjfb8856606 #endif
1132d30ea906Sjfb8856606 
1133d30ea906Sjfb8856606 /**
1134d30ea906Sjfb8856606  * RTE_FLOW_ITEM_TYPE_VXLAN_GPE (draft-ietf-nvo3-vxlan-gpe-05).
1135d30ea906Sjfb8856606  *
1136d30ea906Sjfb8856606  * Matches a VXLAN-GPE header.
1137d30ea906Sjfb8856606  */
1138d30ea906Sjfb8856606 struct rte_flow_item_vxlan_gpe {
1139d30ea906Sjfb8856606 	uint8_t flags; /**< Normally 0x0c (I and P flags). */
1140d30ea906Sjfb8856606 	uint8_t rsvd0[2]; /**< Reserved, normally 0x0000. */
1141d30ea906Sjfb8856606 	uint8_t protocol; /**< Protocol type. */
1142d30ea906Sjfb8856606 	uint8_t vni[3]; /**< VXLAN identifier. */
1143d30ea906Sjfb8856606 	uint8_t rsvd1; /**< Reserved, normally 0x00. */
1144d30ea906Sjfb8856606 };
1145d30ea906Sjfb8856606 
1146d30ea906Sjfb8856606 /** Default mask for RTE_FLOW_ITEM_TYPE_VXLAN_GPE. */
1147d30ea906Sjfb8856606 #ifndef __cplusplus
1148d30ea906Sjfb8856606 static const struct rte_flow_item_vxlan_gpe rte_flow_item_vxlan_gpe_mask = {
1149d30ea906Sjfb8856606 	.vni = "\xff\xff\xff",
1150d30ea906Sjfb8856606 };
1151d30ea906Sjfb8856606 #endif
1152d30ea906Sjfb8856606 
1153d30ea906Sjfb8856606 /**
1154d30ea906Sjfb8856606  * RTE_FLOW_ITEM_TYPE_ARP_ETH_IPV4
1155d30ea906Sjfb8856606  *
1156d30ea906Sjfb8856606  * Matches an ARP header for Ethernet/IPv4.
1157d30ea906Sjfb8856606  */
1158d30ea906Sjfb8856606 struct rte_flow_item_arp_eth_ipv4 {
1159d30ea906Sjfb8856606 	rte_be16_t hrd; /**< Hardware type, normally 1. */
1160d30ea906Sjfb8856606 	rte_be16_t pro; /**< Protocol type, normally 0x0800. */
1161d30ea906Sjfb8856606 	uint8_t hln; /**< Hardware address length, normally 6. */
1162d30ea906Sjfb8856606 	uint8_t pln; /**< Protocol address length, normally 4. */
1163d30ea906Sjfb8856606 	rte_be16_t op; /**< Opcode (1 for request, 2 for reply). */
11644418919fSjohnjiang 	struct rte_ether_addr sha; /**< Sender hardware address. */
1165d30ea906Sjfb8856606 	rte_be32_t spa; /**< Sender IPv4 address. */
11664418919fSjohnjiang 	struct rte_ether_addr tha; /**< Target hardware address. */
1167d30ea906Sjfb8856606 	rte_be32_t tpa; /**< Target IPv4 address. */
1168d30ea906Sjfb8856606 };
1169d30ea906Sjfb8856606 
1170d30ea906Sjfb8856606 /** Default mask for RTE_FLOW_ITEM_TYPE_ARP_ETH_IPV4. */
1171d30ea906Sjfb8856606 #ifndef __cplusplus
1172d30ea906Sjfb8856606 static const struct rte_flow_item_arp_eth_ipv4
1173d30ea906Sjfb8856606 rte_flow_item_arp_eth_ipv4_mask = {
1174d30ea906Sjfb8856606 	.sha.addr_bytes = "\xff\xff\xff\xff\xff\xff",
1175d30ea906Sjfb8856606 	.spa = RTE_BE32(0xffffffff),
1176d30ea906Sjfb8856606 	.tha.addr_bytes = "\xff\xff\xff\xff\xff\xff",
1177d30ea906Sjfb8856606 	.tpa = RTE_BE32(0xffffffff),
1178d30ea906Sjfb8856606 };
1179d30ea906Sjfb8856606 #endif
1180d30ea906Sjfb8856606 
1181d30ea906Sjfb8856606 /**
1182d30ea906Sjfb8856606  * RTE_FLOW_ITEM_TYPE_IPV6_EXT
1183d30ea906Sjfb8856606  *
1184d30ea906Sjfb8856606  * Matches the presence of any IPv6 extension header.
1185d30ea906Sjfb8856606  *
1186d30ea906Sjfb8856606  * Normally preceded by any of:
1187d30ea906Sjfb8856606  *
1188d30ea906Sjfb8856606  * - RTE_FLOW_ITEM_TYPE_IPV6
1189d30ea906Sjfb8856606  * - RTE_FLOW_ITEM_TYPE_IPV6_EXT
1190d30ea906Sjfb8856606  */
1191d30ea906Sjfb8856606 struct rte_flow_item_ipv6_ext {
1192d30ea906Sjfb8856606 	uint8_t next_hdr; /**< Next header. */
1193d30ea906Sjfb8856606 };
1194d30ea906Sjfb8856606 
1195d30ea906Sjfb8856606 /** Default mask for RTE_FLOW_ITEM_TYPE_IPV6_EXT. */
1196d30ea906Sjfb8856606 #ifndef __cplusplus
1197d30ea906Sjfb8856606 static const
1198d30ea906Sjfb8856606 struct rte_flow_item_ipv6_ext rte_flow_item_ipv6_ext_mask = {
1199d30ea906Sjfb8856606 	.next_hdr = 0xff,
1200d30ea906Sjfb8856606 };
1201d30ea906Sjfb8856606 #endif
1202d30ea906Sjfb8856606 
1203d30ea906Sjfb8856606 /**
1204*2d9fd380Sjfb8856606  * RTE_FLOW_ITEM_TYPE_IPV6_FRAG_EXT
1205*2d9fd380Sjfb8856606  *
1206*2d9fd380Sjfb8856606  * Matches the presence of IPv6 fragment extension header.
1207*2d9fd380Sjfb8856606  *
1208*2d9fd380Sjfb8856606  * Preceded by any of:
1209*2d9fd380Sjfb8856606  *
1210*2d9fd380Sjfb8856606  * - RTE_FLOW_ITEM_TYPE_IPV6
1211*2d9fd380Sjfb8856606  * - RTE_FLOW_ITEM_TYPE_IPV6_EXT
1212*2d9fd380Sjfb8856606  */
1213*2d9fd380Sjfb8856606 struct rte_flow_item_ipv6_frag_ext {
1214*2d9fd380Sjfb8856606 	struct rte_ipv6_fragment_ext hdr;
1215*2d9fd380Sjfb8856606 };
1216*2d9fd380Sjfb8856606 
1217*2d9fd380Sjfb8856606 /**
1218d30ea906Sjfb8856606  * RTE_FLOW_ITEM_TYPE_ICMP6
1219d30ea906Sjfb8856606  *
1220d30ea906Sjfb8856606  * Matches any ICMPv6 header.
1221d30ea906Sjfb8856606  */
1222d30ea906Sjfb8856606 struct rte_flow_item_icmp6 {
1223d30ea906Sjfb8856606 	uint8_t type; /**< ICMPv6 type. */
1224d30ea906Sjfb8856606 	uint8_t code; /**< ICMPv6 code. */
1225d30ea906Sjfb8856606 	uint16_t checksum; /**< ICMPv6 checksum. */
1226d30ea906Sjfb8856606 };
1227d30ea906Sjfb8856606 
1228d30ea906Sjfb8856606 /** Default mask for RTE_FLOW_ITEM_TYPE_ICMP6. */
1229d30ea906Sjfb8856606 #ifndef __cplusplus
1230d30ea906Sjfb8856606 static const struct rte_flow_item_icmp6 rte_flow_item_icmp6_mask = {
1231d30ea906Sjfb8856606 	.type = 0xff,
1232d30ea906Sjfb8856606 	.code = 0xff,
1233d30ea906Sjfb8856606 };
1234d30ea906Sjfb8856606 #endif
1235d30ea906Sjfb8856606 
1236d30ea906Sjfb8856606 /**
1237d30ea906Sjfb8856606  * RTE_FLOW_ITEM_TYPE_ICMP6_ND_NS
1238d30ea906Sjfb8856606  *
1239d30ea906Sjfb8856606  * Matches an ICMPv6 neighbor discovery solicitation.
1240d30ea906Sjfb8856606  */
1241d30ea906Sjfb8856606 struct rte_flow_item_icmp6_nd_ns {
1242d30ea906Sjfb8856606 	uint8_t type; /**< ICMPv6 type, normally 135. */
1243d30ea906Sjfb8856606 	uint8_t code; /**< ICMPv6 code, normally 0. */
1244d30ea906Sjfb8856606 	rte_be16_t checksum; /**< ICMPv6 checksum. */
1245d30ea906Sjfb8856606 	rte_be32_t reserved; /**< Reserved, normally 0. */
1246d30ea906Sjfb8856606 	uint8_t target_addr[16]; /**< Target address. */
1247d30ea906Sjfb8856606 };
1248d30ea906Sjfb8856606 
1249d30ea906Sjfb8856606 /** Default mask for RTE_FLOW_ITEM_TYPE_ICMP6_ND_NS. */
1250d30ea906Sjfb8856606 #ifndef __cplusplus
1251d30ea906Sjfb8856606 static const
1252d30ea906Sjfb8856606 struct rte_flow_item_icmp6_nd_ns rte_flow_item_icmp6_nd_ns_mask = {
1253d30ea906Sjfb8856606 	.target_addr =
1254d30ea906Sjfb8856606 		"\xff\xff\xff\xff\xff\xff\xff\xff"
1255d30ea906Sjfb8856606 		"\xff\xff\xff\xff\xff\xff\xff\xff",
1256d30ea906Sjfb8856606 };
1257d30ea906Sjfb8856606 #endif
1258d30ea906Sjfb8856606 
1259d30ea906Sjfb8856606 /**
1260d30ea906Sjfb8856606  * RTE_FLOW_ITEM_TYPE_ICMP6_ND_NA
1261d30ea906Sjfb8856606  *
1262d30ea906Sjfb8856606  * Matches an ICMPv6 neighbor discovery advertisement.
1263d30ea906Sjfb8856606  */
1264d30ea906Sjfb8856606 struct rte_flow_item_icmp6_nd_na {
1265d30ea906Sjfb8856606 	uint8_t type; /**< ICMPv6 type, normally 136. */
1266d30ea906Sjfb8856606 	uint8_t code; /**< ICMPv6 code, normally 0. */
1267d30ea906Sjfb8856606 	rte_be16_t checksum; /**< ICMPv6 checksum. */
1268d30ea906Sjfb8856606 	/**
1269d30ea906Sjfb8856606 	 * Route flag (1b), solicited flag (1b), override flag (1b),
1270d30ea906Sjfb8856606 	 * reserved (29b).
1271d30ea906Sjfb8856606 	 */
1272d30ea906Sjfb8856606 	rte_be32_t rso_reserved;
1273d30ea906Sjfb8856606 	uint8_t target_addr[16]; /**< Target address. */
1274d30ea906Sjfb8856606 };
1275d30ea906Sjfb8856606 
1276d30ea906Sjfb8856606 /** Default mask for RTE_FLOW_ITEM_TYPE_ICMP6_ND_NA. */
1277d30ea906Sjfb8856606 #ifndef __cplusplus
1278d30ea906Sjfb8856606 static const
1279d30ea906Sjfb8856606 struct rte_flow_item_icmp6_nd_na rte_flow_item_icmp6_nd_na_mask = {
1280d30ea906Sjfb8856606 	.target_addr =
1281d30ea906Sjfb8856606 		"\xff\xff\xff\xff\xff\xff\xff\xff"
1282d30ea906Sjfb8856606 		"\xff\xff\xff\xff\xff\xff\xff\xff",
1283d30ea906Sjfb8856606 };
1284d30ea906Sjfb8856606 #endif
1285d30ea906Sjfb8856606 
1286d30ea906Sjfb8856606 /**
1287d30ea906Sjfb8856606  * RTE_FLOW_ITEM_TYPE_ICMP6_ND_OPT
1288d30ea906Sjfb8856606  *
1289d30ea906Sjfb8856606  * Matches the presence of any ICMPv6 neighbor discovery option.
1290d30ea906Sjfb8856606  *
1291d30ea906Sjfb8856606  * Normally preceded by any of:
1292d30ea906Sjfb8856606  *
1293d30ea906Sjfb8856606  * - RTE_FLOW_ITEM_TYPE_ICMP6_ND_NA
1294d30ea906Sjfb8856606  * - RTE_FLOW_ITEM_TYPE_ICMP6_ND_NS
1295d30ea906Sjfb8856606  * - RTE_FLOW_ITEM_TYPE_ICMP6_ND_OPT
1296d30ea906Sjfb8856606  */
1297d30ea906Sjfb8856606 struct rte_flow_item_icmp6_nd_opt {
1298d30ea906Sjfb8856606 	uint8_t type; /**< ND option type. */
1299d30ea906Sjfb8856606 	uint8_t length; /**< ND option length. */
1300d30ea906Sjfb8856606 };
1301d30ea906Sjfb8856606 
1302d30ea906Sjfb8856606 /** Default mask for RTE_FLOW_ITEM_TYPE_ICMP6_ND_OPT. */
1303d30ea906Sjfb8856606 #ifndef __cplusplus
1304d30ea906Sjfb8856606 static const struct rte_flow_item_icmp6_nd_opt
1305d30ea906Sjfb8856606 rte_flow_item_icmp6_nd_opt_mask = {
1306d30ea906Sjfb8856606 	.type = 0xff,
1307d30ea906Sjfb8856606 };
1308d30ea906Sjfb8856606 #endif
1309d30ea906Sjfb8856606 
1310d30ea906Sjfb8856606 /**
1311d30ea906Sjfb8856606  * RTE_FLOW_ITEM_TYPE_ICMP6_ND_OPT_SLA_ETH
1312d30ea906Sjfb8856606  *
1313d30ea906Sjfb8856606  * Matches an ICMPv6 neighbor discovery source Ethernet link-layer address
1314d30ea906Sjfb8856606  * option.
1315d30ea906Sjfb8856606  *
1316d30ea906Sjfb8856606  * Normally preceded by any of:
1317d30ea906Sjfb8856606  *
1318d30ea906Sjfb8856606  * - RTE_FLOW_ITEM_TYPE_ICMP6_ND_NA
1319d30ea906Sjfb8856606  * - RTE_FLOW_ITEM_TYPE_ICMP6_ND_OPT
1320d30ea906Sjfb8856606  */
1321d30ea906Sjfb8856606 struct rte_flow_item_icmp6_nd_opt_sla_eth {
1322d30ea906Sjfb8856606 	uint8_t type; /**< ND option type, normally 1. */
1323d30ea906Sjfb8856606 	uint8_t length; /**< ND option length, normally 1. */
13244418919fSjohnjiang 	struct rte_ether_addr sla; /**< Source Ethernet LLA. */
1325d30ea906Sjfb8856606 };
1326d30ea906Sjfb8856606 
1327d30ea906Sjfb8856606 /** Default mask for RTE_FLOW_ITEM_TYPE_ICMP6_ND_OPT_SLA_ETH. */
1328d30ea906Sjfb8856606 #ifndef __cplusplus
1329d30ea906Sjfb8856606 static const struct rte_flow_item_icmp6_nd_opt_sla_eth
1330d30ea906Sjfb8856606 rte_flow_item_icmp6_nd_opt_sla_eth_mask = {
1331d30ea906Sjfb8856606 	.sla.addr_bytes = "\xff\xff\xff\xff\xff\xff",
1332d30ea906Sjfb8856606 };
1333d30ea906Sjfb8856606 #endif
1334d30ea906Sjfb8856606 
1335d30ea906Sjfb8856606 /**
1336d30ea906Sjfb8856606  * RTE_FLOW_ITEM_TYPE_ICMP6_ND_OPT_TLA_ETH
1337d30ea906Sjfb8856606  *
1338d30ea906Sjfb8856606  * Matches an ICMPv6 neighbor discovery target Ethernet link-layer address
1339d30ea906Sjfb8856606  * option.
1340d30ea906Sjfb8856606  *
1341d30ea906Sjfb8856606  * Normally preceded by any of:
1342d30ea906Sjfb8856606  *
1343d30ea906Sjfb8856606  * - RTE_FLOW_ITEM_TYPE_ICMP6_ND_NS
1344d30ea906Sjfb8856606  * - RTE_FLOW_ITEM_TYPE_ICMP6_ND_OPT
1345d30ea906Sjfb8856606  */
1346d30ea906Sjfb8856606 struct rte_flow_item_icmp6_nd_opt_tla_eth {
1347d30ea906Sjfb8856606 	uint8_t type; /**< ND option type, normally 2. */
1348d30ea906Sjfb8856606 	uint8_t length; /**< ND option length, normally 1. */
13494418919fSjohnjiang 	struct rte_ether_addr tla; /**< Target Ethernet LLA. */
1350d30ea906Sjfb8856606 };
1351d30ea906Sjfb8856606 
1352d30ea906Sjfb8856606 /** Default mask for RTE_FLOW_ITEM_TYPE_ICMP6_ND_OPT_TLA_ETH. */
1353d30ea906Sjfb8856606 #ifndef __cplusplus
1354d30ea906Sjfb8856606 static const struct rte_flow_item_icmp6_nd_opt_tla_eth
1355d30ea906Sjfb8856606 rte_flow_item_icmp6_nd_opt_tla_eth_mask = {
1356d30ea906Sjfb8856606 	.tla.addr_bytes = "\xff\xff\xff\xff\xff\xff",
1357d30ea906Sjfb8856606 };
1358d30ea906Sjfb8856606 #endif
1359d30ea906Sjfb8856606 
1360d30ea906Sjfb8856606 /**
13614418919fSjohnjiang  * RTE_FLOW_ITEM_TYPE_META
1362d30ea906Sjfb8856606  *
13634418919fSjohnjiang  * Matches a specified metadata value. On egress, metadata can be set
13644418919fSjohnjiang  * either by mbuf dynamic metadata field with PKT_TX_DYNF_METADATA flag or
13654418919fSjohnjiang  * RTE_FLOW_ACTION_TYPE_SET_META. On ingress, RTE_FLOW_ACTION_TYPE_SET_META
13664418919fSjohnjiang  * sets metadata for a packet and the metadata will be reported via mbuf
13674418919fSjohnjiang  * metadata dynamic field with PKT_RX_DYNF_METADATA flag. The dynamic mbuf
13684418919fSjohnjiang  * field must be registered in advance by rte_flow_dynf_metadata_register().
1369d30ea906Sjfb8856606  */
1370d30ea906Sjfb8856606 struct rte_flow_item_meta {
13714418919fSjohnjiang 	uint32_t data;
1372d30ea906Sjfb8856606 };
1373d30ea906Sjfb8856606 
1374d30ea906Sjfb8856606 /** Default mask for RTE_FLOW_ITEM_TYPE_META. */
1375d30ea906Sjfb8856606 #ifndef __cplusplus
1376d30ea906Sjfb8856606 static const struct rte_flow_item_meta rte_flow_item_meta_mask = {
13774418919fSjohnjiang 	.data = UINT32_MAX,
13784418919fSjohnjiang };
13794418919fSjohnjiang #endif
13804418919fSjohnjiang 
13814418919fSjohnjiang /**
13824418919fSjohnjiang  * RTE_FLOW_ITEM_TYPE_GTP_PSC.
13834418919fSjohnjiang  *
13844418919fSjohnjiang  * Matches a GTP PDU extension header with type 0x85.
13854418919fSjohnjiang  */
13864418919fSjohnjiang struct rte_flow_item_gtp_psc {
13874418919fSjohnjiang 	uint8_t pdu_type; /**< PDU type. */
13884418919fSjohnjiang 	uint8_t qfi; /**< QoS flow identifier. */
13894418919fSjohnjiang };
13904418919fSjohnjiang 
13914418919fSjohnjiang /** Default mask for RTE_FLOW_ITEM_TYPE_GTP_PSC. */
13924418919fSjohnjiang #ifndef __cplusplus
13934418919fSjohnjiang static const struct rte_flow_item_gtp_psc
13944418919fSjohnjiang rte_flow_item_gtp_psc_mask = {
13954418919fSjohnjiang 	.qfi = 0x3f,
13964418919fSjohnjiang };
13974418919fSjohnjiang #endif
13984418919fSjohnjiang 
13994418919fSjohnjiang /**
14004418919fSjohnjiang  * RTE_FLOW_ITEM_TYPE_PPPOE.
14014418919fSjohnjiang  *
14024418919fSjohnjiang  * Matches a PPPoE header.
14034418919fSjohnjiang  */
14044418919fSjohnjiang struct rte_flow_item_pppoe {
14054418919fSjohnjiang 	/**
14064418919fSjohnjiang 	 * Version (4b), type (4b).
14074418919fSjohnjiang 	 */
14084418919fSjohnjiang 	uint8_t version_type;
14094418919fSjohnjiang 	uint8_t code; /**< Message type. */
14104418919fSjohnjiang 	rte_be16_t session_id; /**< Session identifier. */
14114418919fSjohnjiang 	rte_be16_t length; /**< Payload length. */
14124418919fSjohnjiang };
14134418919fSjohnjiang 
14144418919fSjohnjiang /**
14154418919fSjohnjiang  * RTE_FLOW_ITEM_TYPE_PPPOE_PROTO_ID.
14164418919fSjohnjiang  *
14174418919fSjohnjiang  * Matches a PPPoE optional proto_id field.
14184418919fSjohnjiang  *
14194418919fSjohnjiang  * It only applies to PPPoE session packets.
14204418919fSjohnjiang  *
14214418919fSjohnjiang  * Normally preceded by any of:
14224418919fSjohnjiang  *
14234418919fSjohnjiang  * - RTE_FLOW_ITEM_TYPE_PPPOE
14244418919fSjohnjiang  * - RTE_FLOW_ITEM_TYPE_PPPOE_PROTO_ID
14254418919fSjohnjiang  */
14264418919fSjohnjiang struct rte_flow_item_pppoe_proto_id {
14274418919fSjohnjiang 	rte_be16_t proto_id; /**< PPP protocol identifier. */
14284418919fSjohnjiang };
14294418919fSjohnjiang 
14304418919fSjohnjiang /** Default mask for RTE_FLOW_ITEM_TYPE_PPPOE_PROTO_ID. */
14314418919fSjohnjiang #ifndef __cplusplus
14324418919fSjohnjiang static const struct rte_flow_item_pppoe_proto_id
14334418919fSjohnjiang rte_flow_item_pppoe_proto_id_mask = {
14344418919fSjohnjiang 	.proto_id = RTE_BE16(0xffff),
14354418919fSjohnjiang };
14364418919fSjohnjiang #endif
14374418919fSjohnjiang 
14384418919fSjohnjiang /**
14394418919fSjohnjiang  * @warning
14404418919fSjohnjiang  * @b EXPERIMENTAL: this structure may change without prior notice
14414418919fSjohnjiang  *
14424418919fSjohnjiang  * RTE_FLOW_ITEM_TYPE_TAG
14434418919fSjohnjiang  *
14444418919fSjohnjiang  * Matches a specified tag value at the specified index.
14454418919fSjohnjiang  */
14464418919fSjohnjiang struct rte_flow_item_tag {
14474418919fSjohnjiang 	uint32_t data;
14484418919fSjohnjiang 	uint8_t index;
14494418919fSjohnjiang };
14504418919fSjohnjiang 
14514418919fSjohnjiang /** Default mask for RTE_FLOW_ITEM_TYPE_TAG. */
14524418919fSjohnjiang #ifndef __cplusplus
14534418919fSjohnjiang static const struct rte_flow_item_tag rte_flow_item_tag_mask = {
14544418919fSjohnjiang 	.data = 0xffffffff,
14554418919fSjohnjiang 	.index = 0xff,
1456d30ea906Sjfb8856606 };
1457d30ea906Sjfb8856606 #endif
1458d30ea906Sjfb8856606 
1459d30ea906Sjfb8856606 /**
1460*2d9fd380Sjfb8856606  * RTE_FLOW_ITEM_TYPE_L2TPV3OIP.
1461*2d9fd380Sjfb8856606  *
1462*2d9fd380Sjfb8856606  * Matches a L2TPv3 over IP header.
1463*2d9fd380Sjfb8856606  */
1464*2d9fd380Sjfb8856606 struct rte_flow_item_l2tpv3oip {
1465*2d9fd380Sjfb8856606 	rte_be32_t session_id; /**< Session ID. */
1466*2d9fd380Sjfb8856606 };
1467*2d9fd380Sjfb8856606 
1468*2d9fd380Sjfb8856606 /** Default mask for RTE_FLOW_ITEM_TYPE_L2TPV3OIP. */
1469*2d9fd380Sjfb8856606 #ifndef __cplusplus
1470*2d9fd380Sjfb8856606 static const struct rte_flow_item_l2tpv3oip rte_flow_item_l2tpv3oip_mask = {
1471*2d9fd380Sjfb8856606 	.session_id = RTE_BE32(UINT32_MAX),
1472*2d9fd380Sjfb8856606 };
1473*2d9fd380Sjfb8856606 #endif
1474*2d9fd380Sjfb8856606 
1475*2d9fd380Sjfb8856606 
1476*2d9fd380Sjfb8856606 /**
1477d30ea906Sjfb8856606  * @warning
1478d30ea906Sjfb8856606  * @b EXPERIMENTAL: this structure may change without prior notice
1479d30ea906Sjfb8856606  *
1480d30ea906Sjfb8856606  * RTE_FLOW_ITEM_TYPE_MARK
1481d30ea906Sjfb8856606  *
1482d30ea906Sjfb8856606  * Matches an arbitrary integer value which was set using the ``MARK`` action
1483d30ea906Sjfb8856606  * in a previously matched rule.
1484d30ea906Sjfb8856606  *
1485d30ea906Sjfb8856606  * This item can only be specified once as a match criteria as the ``MARK``
1486d30ea906Sjfb8856606  * action can only be specified once in a flow action.
1487d30ea906Sjfb8856606  *
1488d30ea906Sjfb8856606  * This value is arbitrary and application-defined. Maximum allowed value
1489d30ea906Sjfb8856606  * depends on the underlying implementation.
1490d30ea906Sjfb8856606  *
1491d30ea906Sjfb8856606  * Depending on the underlying implementation the MARK item may be supported on
1492d30ea906Sjfb8856606  * the physical device, with virtual groups in the PMD or not at all.
1493d30ea906Sjfb8856606  */
1494d30ea906Sjfb8856606 struct rte_flow_item_mark {
1495d30ea906Sjfb8856606 	uint32_t id; /**< Integer value to match against. */
1496d30ea906Sjfb8856606 };
1497d30ea906Sjfb8856606 
14984418919fSjohnjiang /** Default mask for RTE_FLOW_ITEM_TYPE_MARK. */
14994418919fSjohnjiang #ifndef __cplusplus
15004418919fSjohnjiang static const struct rte_flow_item_mark rte_flow_item_mark_mask = {
15014418919fSjohnjiang 	.id = 0xffffffff,
15024418919fSjohnjiang };
15034418919fSjohnjiang #endif
15044418919fSjohnjiang 
15054418919fSjohnjiang /**
15064418919fSjohnjiang  * @warning
15074418919fSjohnjiang  * @b EXPERIMENTAL: this structure may change without prior notice
15084418919fSjohnjiang  *
15094418919fSjohnjiang  * RTE_FLOW_ITEM_TYPE_NSH
15104418919fSjohnjiang  *
15114418919fSjohnjiang  * Match network service header (NSH), RFC 8300
15124418919fSjohnjiang  *
15134418919fSjohnjiang  */
15144418919fSjohnjiang struct rte_flow_item_nsh {
15154418919fSjohnjiang 	uint32_t version:2;
15164418919fSjohnjiang 	uint32_t oam_pkt:1;
15174418919fSjohnjiang 	uint32_t reserved:1;
15184418919fSjohnjiang 	uint32_t ttl:6;
15194418919fSjohnjiang 	uint32_t length:6;
15204418919fSjohnjiang 	uint32_t reserved1:4;
15214418919fSjohnjiang 	uint32_t mdtype:4;
15224418919fSjohnjiang 	uint32_t next_proto:8;
15234418919fSjohnjiang 	uint32_t spi:24;
15244418919fSjohnjiang 	uint32_t sindex:8;
15254418919fSjohnjiang };
15264418919fSjohnjiang 
15274418919fSjohnjiang /** Default mask for RTE_FLOW_ITEM_TYPE_NSH. */
15284418919fSjohnjiang #ifndef __cplusplus
15294418919fSjohnjiang static const struct rte_flow_item_nsh rte_flow_item_nsh_mask = {
15304418919fSjohnjiang 	.mdtype = 0xf,
15314418919fSjohnjiang 	.next_proto = 0xff,
15324418919fSjohnjiang 	.spi = 0xffffff,
15334418919fSjohnjiang 	.sindex = 0xff,
15344418919fSjohnjiang };
15354418919fSjohnjiang #endif
15364418919fSjohnjiang 
15374418919fSjohnjiang /**
15384418919fSjohnjiang  * @warning
15394418919fSjohnjiang  * @b EXPERIMENTAL: this structure may change without prior notice
15404418919fSjohnjiang  *
15414418919fSjohnjiang  * RTE_FLOW_ITEM_TYPE_IGMP
15424418919fSjohnjiang  *
15434418919fSjohnjiang  * Match Internet Group Management Protocol (IGMP), RFC 2236
15444418919fSjohnjiang  *
15454418919fSjohnjiang  */
15464418919fSjohnjiang struct rte_flow_item_igmp {
15474418919fSjohnjiang 	uint32_t type:8;
15484418919fSjohnjiang 	uint32_t max_resp_time:8;
15494418919fSjohnjiang 	uint32_t checksum:16;
15504418919fSjohnjiang 	uint32_t group_addr;
15514418919fSjohnjiang };
15524418919fSjohnjiang 
15534418919fSjohnjiang /** Default mask for RTE_FLOW_ITEM_TYPE_IGMP. */
15544418919fSjohnjiang #ifndef __cplusplus
15554418919fSjohnjiang static const struct rte_flow_item_igmp rte_flow_item_igmp_mask = {
15564418919fSjohnjiang 	.group_addr = 0xffffffff,
15574418919fSjohnjiang };
15584418919fSjohnjiang #endif
15594418919fSjohnjiang 
15604418919fSjohnjiang /**
15614418919fSjohnjiang  * @warning
15624418919fSjohnjiang  * @b EXPERIMENTAL: this structure may change without prior notice
15634418919fSjohnjiang  *
15644418919fSjohnjiang  * RTE_FLOW_ITEM_TYPE_AH
15654418919fSjohnjiang  *
15664418919fSjohnjiang  * Match IP Authentication Header (AH), RFC 4302
15674418919fSjohnjiang  *
15684418919fSjohnjiang  */
15694418919fSjohnjiang struct rte_flow_item_ah {
15704418919fSjohnjiang 	uint32_t next_hdr:8;
15714418919fSjohnjiang 	uint32_t payload_len:8;
15724418919fSjohnjiang 	uint32_t reserved:16;
15734418919fSjohnjiang 	uint32_t spi;
15744418919fSjohnjiang 	uint32_t seq_num;
15754418919fSjohnjiang };
15764418919fSjohnjiang 
15774418919fSjohnjiang /** Default mask for RTE_FLOW_ITEM_TYPE_AH. */
15784418919fSjohnjiang #ifndef __cplusplus
15794418919fSjohnjiang static const struct rte_flow_item_ah rte_flow_item_ah_mask = {
15804418919fSjohnjiang 	.spi = 0xffffffff,
15814418919fSjohnjiang };
15824418919fSjohnjiang #endif
15834418919fSjohnjiang 
1584d30ea906Sjfb8856606 /**
1585*2d9fd380Sjfb8856606  * @warning
1586*2d9fd380Sjfb8856606  * @b EXPERIMENTAL: this structure may change without prior notice
1587*2d9fd380Sjfb8856606  *
1588*2d9fd380Sjfb8856606  * RTE_FLOW_ITEM_TYPE_PFCP
1589*2d9fd380Sjfb8856606  *
1590*2d9fd380Sjfb8856606  * Match PFCP Header
1591*2d9fd380Sjfb8856606  */
1592*2d9fd380Sjfb8856606 struct rte_flow_item_pfcp {
1593*2d9fd380Sjfb8856606 	uint8_t s_field;
1594*2d9fd380Sjfb8856606 	uint8_t msg_type;
1595*2d9fd380Sjfb8856606 	rte_be16_t msg_len;
1596*2d9fd380Sjfb8856606 	rte_be64_t seid;
1597*2d9fd380Sjfb8856606 };
1598*2d9fd380Sjfb8856606 
1599*2d9fd380Sjfb8856606 /** Default mask for RTE_FLOW_ITEM_TYPE_PFCP. */
1600*2d9fd380Sjfb8856606 #ifndef __cplusplus
1601*2d9fd380Sjfb8856606 static const struct rte_flow_item_pfcp rte_flow_item_pfcp_mask = {
1602*2d9fd380Sjfb8856606 	.s_field = 0x01,
1603*2d9fd380Sjfb8856606 	.seid = RTE_BE64(UINT64_C(0xffffffffffffffff)),
1604*2d9fd380Sjfb8856606 };
1605*2d9fd380Sjfb8856606 #endif
1606*2d9fd380Sjfb8856606 
1607*2d9fd380Sjfb8856606 /**
1608*2d9fd380Sjfb8856606  * @warning
1609*2d9fd380Sjfb8856606  * @b EXPERIMENTAL: this structure may change without prior notice
1610*2d9fd380Sjfb8856606  *
1611*2d9fd380Sjfb8856606  * RTE_FLOW_ITEM_TYPE_ECPRI
1612*2d9fd380Sjfb8856606  *
1613*2d9fd380Sjfb8856606  * Match eCPRI Header
1614*2d9fd380Sjfb8856606  */
1615*2d9fd380Sjfb8856606 struct rte_flow_item_ecpri {
1616*2d9fd380Sjfb8856606 	struct rte_ecpri_combined_msg_hdr hdr;
1617*2d9fd380Sjfb8856606 };
1618*2d9fd380Sjfb8856606 
1619*2d9fd380Sjfb8856606 /** Default mask for RTE_FLOW_ITEM_TYPE_ECPRI. */
1620*2d9fd380Sjfb8856606 #ifndef __cplusplus
1621*2d9fd380Sjfb8856606 static const struct rte_flow_item_ecpri rte_flow_item_ecpri_mask = {
1622*2d9fd380Sjfb8856606 	.hdr = {
1623*2d9fd380Sjfb8856606 		.common = {
1624*2d9fd380Sjfb8856606 			.u32 = 0x0,
1625*2d9fd380Sjfb8856606 		},
1626*2d9fd380Sjfb8856606 	},
1627*2d9fd380Sjfb8856606 };
1628*2d9fd380Sjfb8856606 #endif
1629*2d9fd380Sjfb8856606 
1630*2d9fd380Sjfb8856606 /**
1631d30ea906Sjfb8856606  * Matching pattern item definition.
1632d30ea906Sjfb8856606  *
1633d30ea906Sjfb8856606  * A pattern is formed by stacking items starting from the lowest protocol
1634d30ea906Sjfb8856606  * layer to match. This stacking restriction does not apply to meta items
1635d30ea906Sjfb8856606  * which can be placed anywhere in the stack without affecting the meaning
1636d30ea906Sjfb8856606  * of the resulting pattern.
1637d30ea906Sjfb8856606  *
1638d30ea906Sjfb8856606  * Patterns are terminated by END items.
1639d30ea906Sjfb8856606  *
1640d30ea906Sjfb8856606  * The spec field should be a valid pointer to a structure of the related
1641d30ea906Sjfb8856606  * item type. It may remain unspecified (NULL) in many cases to request
1642d30ea906Sjfb8856606  * broad (nonspecific) matching. In such cases, last and mask must also be
1643d30ea906Sjfb8856606  * set to NULL.
1644d30ea906Sjfb8856606  *
1645d30ea906Sjfb8856606  * Optionally, last can point to a structure of the same type to define an
1646d30ea906Sjfb8856606  * inclusive range. This is mostly supported by integer and address fields,
1647d30ea906Sjfb8856606  * may cause errors otherwise. Fields that do not support ranges must be set
1648d30ea906Sjfb8856606  * to 0 or to the same value as the corresponding fields in spec.
1649d30ea906Sjfb8856606  *
1650d30ea906Sjfb8856606  * Only the fields defined to nonzero values in the default masks (see
1651d30ea906Sjfb8856606  * rte_flow_item_{name}_mask constants) are considered relevant by
1652d30ea906Sjfb8856606  * default. This can be overridden by providing a mask structure of the
1653d30ea906Sjfb8856606  * same type with applicable bits set to one. It can also be used to
1654d30ea906Sjfb8856606  * partially filter out specific fields (e.g. as an alternate mean to match
1655d30ea906Sjfb8856606  * ranges of IP addresses).
1656d30ea906Sjfb8856606  *
1657d30ea906Sjfb8856606  * Mask is a simple bit-mask applied before interpreting the contents of
1658d30ea906Sjfb8856606  * spec and last, which may yield unexpected results if not used
1659d30ea906Sjfb8856606  * carefully. For example, if for an IPv4 address field, spec provides
1660d30ea906Sjfb8856606  * 10.1.2.3, last provides 10.3.4.5 and mask provides 255.255.0.0, the
1661d30ea906Sjfb8856606  * effective range becomes 10.1.0.0 to 10.3.255.255.
1662d30ea906Sjfb8856606  */
1663d30ea906Sjfb8856606 struct rte_flow_item {
1664d30ea906Sjfb8856606 	enum rte_flow_item_type type; /**< Item type. */
1665d30ea906Sjfb8856606 	const void *spec; /**< Pointer to item specification structure. */
1666d30ea906Sjfb8856606 	const void *last; /**< Defines an inclusive range (spec to last). */
1667d30ea906Sjfb8856606 	const void *mask; /**< Bit-mask applied to spec and last. */
1668d30ea906Sjfb8856606 };
1669d30ea906Sjfb8856606 
1670d30ea906Sjfb8856606 /**
1671d30ea906Sjfb8856606  * Action types.
1672d30ea906Sjfb8856606  *
16734418919fSjohnjiang  * Each possible action is represented by a type.
16744418919fSjohnjiang  * An action can have an associated configuration object.
16754418919fSjohnjiang  * Several actions combined in a list can be assigned
16764418919fSjohnjiang  * to a flow rule and are performed in order.
1677d30ea906Sjfb8856606  *
1678d30ea906Sjfb8856606  * They fall in three categories:
1679d30ea906Sjfb8856606  *
1680d30ea906Sjfb8856606  * - Actions that modify the fate of matching traffic, for instance by
1681d30ea906Sjfb8856606  *   dropping or assigning it a specific destination.
1682d30ea906Sjfb8856606  *
1683d30ea906Sjfb8856606  * - Actions that modify matching traffic contents or its properties. This
1684d30ea906Sjfb8856606  *   includes adding/removing encapsulation, encryption, compression and
1685d30ea906Sjfb8856606  *   marks.
1686d30ea906Sjfb8856606  *
1687d30ea906Sjfb8856606  * - Actions related to the flow rule itself, such as updating counters or
1688d30ea906Sjfb8856606  *   making it non-terminating.
1689d30ea906Sjfb8856606  *
1690d30ea906Sjfb8856606  * Flow rules being terminating by default, not specifying any action of the
1691d30ea906Sjfb8856606  * fate kind results in undefined behavior. This applies to both ingress and
1692d30ea906Sjfb8856606  * egress.
1693d30ea906Sjfb8856606  *
1694d30ea906Sjfb8856606  * PASSTHRU, when supported, makes a flow rule non-terminating.
1695d30ea906Sjfb8856606  */
1696d30ea906Sjfb8856606 enum rte_flow_action_type {
1697d30ea906Sjfb8856606 	/**
1698d30ea906Sjfb8856606 	 * End marker for action lists. Prevents further processing of
1699d30ea906Sjfb8856606 	 * actions, thereby ending the list.
1700d30ea906Sjfb8856606 	 *
1701d30ea906Sjfb8856606 	 * No associated configuration structure.
1702d30ea906Sjfb8856606 	 */
1703d30ea906Sjfb8856606 	RTE_FLOW_ACTION_TYPE_END,
1704d30ea906Sjfb8856606 
1705d30ea906Sjfb8856606 	/**
1706d30ea906Sjfb8856606 	 * Used as a placeholder for convenience. It is ignored and simply
1707d30ea906Sjfb8856606 	 * discarded by PMDs.
1708d30ea906Sjfb8856606 	 *
1709d30ea906Sjfb8856606 	 * No associated configuration structure.
1710d30ea906Sjfb8856606 	 */
1711d30ea906Sjfb8856606 	RTE_FLOW_ACTION_TYPE_VOID,
1712d30ea906Sjfb8856606 
1713d30ea906Sjfb8856606 	/**
1714d30ea906Sjfb8856606 	 * Leaves traffic up for additional processing by subsequent flow
1715d30ea906Sjfb8856606 	 * rules; makes a flow rule non-terminating.
1716d30ea906Sjfb8856606 	 *
1717d30ea906Sjfb8856606 	 * No associated configuration structure.
1718d30ea906Sjfb8856606 	 */
1719d30ea906Sjfb8856606 	RTE_FLOW_ACTION_TYPE_PASSTHRU,
1720d30ea906Sjfb8856606 
1721d30ea906Sjfb8856606 	/**
1722d30ea906Sjfb8856606 	 * RTE_FLOW_ACTION_TYPE_JUMP
1723d30ea906Sjfb8856606 	 *
1724d30ea906Sjfb8856606 	 * Redirects packets to a group on the current device.
1725d30ea906Sjfb8856606 	 *
1726d30ea906Sjfb8856606 	 * See struct rte_flow_action_jump.
1727d30ea906Sjfb8856606 	 */
1728d30ea906Sjfb8856606 	RTE_FLOW_ACTION_TYPE_JUMP,
1729d30ea906Sjfb8856606 
1730d30ea906Sjfb8856606 	/**
1731d30ea906Sjfb8856606 	 * Attaches an integer value to packets and sets PKT_RX_FDIR and
1732d30ea906Sjfb8856606 	 * PKT_RX_FDIR_ID mbuf flags.
1733d30ea906Sjfb8856606 	 *
1734d30ea906Sjfb8856606 	 * See struct rte_flow_action_mark.
1735d30ea906Sjfb8856606 	 */
1736d30ea906Sjfb8856606 	RTE_FLOW_ACTION_TYPE_MARK,
1737d30ea906Sjfb8856606 
1738d30ea906Sjfb8856606 	/**
1739d30ea906Sjfb8856606 	 * Flags packets. Similar to MARK without a specific value; only
1740d30ea906Sjfb8856606 	 * sets the PKT_RX_FDIR mbuf flag.
1741d30ea906Sjfb8856606 	 *
1742d30ea906Sjfb8856606 	 * No associated configuration structure.
1743d30ea906Sjfb8856606 	 */
1744d30ea906Sjfb8856606 	RTE_FLOW_ACTION_TYPE_FLAG,
1745d30ea906Sjfb8856606 
1746d30ea906Sjfb8856606 	/**
1747d30ea906Sjfb8856606 	 * Assigns packets to a given queue index.
1748d30ea906Sjfb8856606 	 *
1749d30ea906Sjfb8856606 	 * See struct rte_flow_action_queue.
1750d30ea906Sjfb8856606 	 */
1751d30ea906Sjfb8856606 	RTE_FLOW_ACTION_TYPE_QUEUE,
1752d30ea906Sjfb8856606 
1753d30ea906Sjfb8856606 	/**
1754d30ea906Sjfb8856606 	 * Drops packets.
1755d30ea906Sjfb8856606 	 *
1756d30ea906Sjfb8856606 	 * PASSTHRU overrides this action if both are specified.
1757d30ea906Sjfb8856606 	 *
1758d30ea906Sjfb8856606 	 * No associated configuration structure.
1759d30ea906Sjfb8856606 	 */
1760d30ea906Sjfb8856606 	RTE_FLOW_ACTION_TYPE_DROP,
1761d30ea906Sjfb8856606 
1762d30ea906Sjfb8856606 	/**
1763d30ea906Sjfb8856606 	 * Enables counters for this flow rule.
1764d30ea906Sjfb8856606 	 *
1765*2d9fd380Sjfb8856606 	 * These counters can be retrieved and reset through rte_flow_query() or
1766*2d9fd380Sjfb8856606 	 * rte_flow_shared_action_query() if the action provided via handle,
1767d30ea906Sjfb8856606 	 * see struct rte_flow_query_count.
1768d30ea906Sjfb8856606 	 *
1769d30ea906Sjfb8856606 	 * See struct rte_flow_action_count.
1770d30ea906Sjfb8856606 	 */
1771d30ea906Sjfb8856606 	RTE_FLOW_ACTION_TYPE_COUNT,
1772d30ea906Sjfb8856606 
1773d30ea906Sjfb8856606 	/**
1774d30ea906Sjfb8856606 	 * Similar to QUEUE, except RSS is additionally performed on packets
1775d30ea906Sjfb8856606 	 * to spread them among several queues according to the provided
1776d30ea906Sjfb8856606 	 * parameters.
1777d30ea906Sjfb8856606 	 *
1778d30ea906Sjfb8856606 	 * See struct rte_flow_action_rss.
1779d30ea906Sjfb8856606 	 */
1780d30ea906Sjfb8856606 	RTE_FLOW_ACTION_TYPE_RSS,
1781d30ea906Sjfb8856606 
1782d30ea906Sjfb8856606 	/**
1783d30ea906Sjfb8856606 	 * Directs matching traffic to the physical function (PF) of the
1784d30ea906Sjfb8856606 	 * current device.
1785d30ea906Sjfb8856606 	 *
1786d30ea906Sjfb8856606 	 * No associated configuration structure.
1787d30ea906Sjfb8856606 	 */
1788d30ea906Sjfb8856606 	RTE_FLOW_ACTION_TYPE_PF,
1789d30ea906Sjfb8856606 
1790d30ea906Sjfb8856606 	/**
1791d30ea906Sjfb8856606 	 * Directs matching traffic to a given virtual function of the
1792d30ea906Sjfb8856606 	 * current device.
1793d30ea906Sjfb8856606 	 *
1794d30ea906Sjfb8856606 	 * See struct rte_flow_action_vf.
1795d30ea906Sjfb8856606 	 */
1796d30ea906Sjfb8856606 	RTE_FLOW_ACTION_TYPE_VF,
1797d30ea906Sjfb8856606 
1798d30ea906Sjfb8856606 	/**
1799d30ea906Sjfb8856606 	 * Directs packets to a given physical port index of the underlying
1800d30ea906Sjfb8856606 	 * device.
1801d30ea906Sjfb8856606 	 *
1802d30ea906Sjfb8856606 	 * See struct rte_flow_action_phy_port.
1803d30ea906Sjfb8856606 	 */
1804d30ea906Sjfb8856606 	RTE_FLOW_ACTION_TYPE_PHY_PORT,
1805d30ea906Sjfb8856606 
1806d30ea906Sjfb8856606 	/**
1807d30ea906Sjfb8856606 	 * Directs matching traffic to a given DPDK port ID.
1808d30ea906Sjfb8856606 	 *
1809d30ea906Sjfb8856606 	 * See struct rte_flow_action_port_id.
1810d30ea906Sjfb8856606 	 */
1811d30ea906Sjfb8856606 	RTE_FLOW_ACTION_TYPE_PORT_ID,
1812d30ea906Sjfb8856606 
1813d30ea906Sjfb8856606 	/**
1814d30ea906Sjfb8856606 	 * Traffic metering and policing (MTR).
1815d30ea906Sjfb8856606 	 *
1816d30ea906Sjfb8856606 	 * See struct rte_flow_action_meter.
1817d30ea906Sjfb8856606 	 * See file rte_mtr.h for MTR object configuration.
1818d30ea906Sjfb8856606 	 */
1819d30ea906Sjfb8856606 	RTE_FLOW_ACTION_TYPE_METER,
1820d30ea906Sjfb8856606 
1821d30ea906Sjfb8856606 	/**
1822d30ea906Sjfb8856606 	 * Redirects packets to security engine of current device for security
1823d30ea906Sjfb8856606 	 * processing as specified by security session.
1824d30ea906Sjfb8856606 	 *
1825d30ea906Sjfb8856606 	 * See struct rte_flow_action_security.
1826d30ea906Sjfb8856606 	 */
1827d30ea906Sjfb8856606 	RTE_FLOW_ACTION_TYPE_SECURITY,
1828d30ea906Sjfb8856606 
1829d30ea906Sjfb8856606 	/**
1830d30ea906Sjfb8856606 	 * Implements OFPAT_SET_MPLS_TTL ("MPLS TTL") as defined by the
1831d30ea906Sjfb8856606 	 * OpenFlow Switch Specification.
1832d30ea906Sjfb8856606 	 *
1833d30ea906Sjfb8856606 	 * See struct rte_flow_action_of_set_mpls_ttl.
1834d30ea906Sjfb8856606 	 */
1835d30ea906Sjfb8856606 	RTE_FLOW_ACTION_TYPE_OF_SET_MPLS_TTL,
1836d30ea906Sjfb8856606 
1837d30ea906Sjfb8856606 	/**
1838d30ea906Sjfb8856606 	 * Implements OFPAT_DEC_MPLS_TTL ("decrement MPLS TTL") as defined
1839d30ea906Sjfb8856606 	 * by the OpenFlow Switch Specification.
1840d30ea906Sjfb8856606 	 *
1841d30ea906Sjfb8856606 	 * No associated configuration structure.
1842d30ea906Sjfb8856606 	 */
1843d30ea906Sjfb8856606 	RTE_FLOW_ACTION_TYPE_OF_DEC_MPLS_TTL,
1844d30ea906Sjfb8856606 
1845d30ea906Sjfb8856606 	/**
1846d30ea906Sjfb8856606 	 * Implements OFPAT_SET_NW_TTL ("IP TTL") as defined by the OpenFlow
1847d30ea906Sjfb8856606 	 * Switch Specification.
1848d30ea906Sjfb8856606 	 *
1849d30ea906Sjfb8856606 	 * See struct rte_flow_action_of_set_nw_ttl.
1850d30ea906Sjfb8856606 	 */
1851d30ea906Sjfb8856606 	RTE_FLOW_ACTION_TYPE_OF_SET_NW_TTL,
1852d30ea906Sjfb8856606 
1853d30ea906Sjfb8856606 	/**
1854d30ea906Sjfb8856606 	 * Implements OFPAT_DEC_NW_TTL ("decrement IP TTL") as defined by
1855d30ea906Sjfb8856606 	 * the OpenFlow Switch Specification.
1856d30ea906Sjfb8856606 	 *
1857d30ea906Sjfb8856606 	 * No associated configuration structure.
1858d30ea906Sjfb8856606 	 */
1859d30ea906Sjfb8856606 	RTE_FLOW_ACTION_TYPE_OF_DEC_NW_TTL,
1860d30ea906Sjfb8856606 
1861d30ea906Sjfb8856606 	/**
1862d30ea906Sjfb8856606 	 * Implements OFPAT_COPY_TTL_OUT ("copy TTL "outwards" -- from
1863d30ea906Sjfb8856606 	 * next-to-outermost to outermost") as defined by the OpenFlow
1864d30ea906Sjfb8856606 	 * Switch Specification.
1865d30ea906Sjfb8856606 	 *
1866d30ea906Sjfb8856606 	 * No associated configuration structure.
1867d30ea906Sjfb8856606 	 */
1868d30ea906Sjfb8856606 	RTE_FLOW_ACTION_TYPE_OF_COPY_TTL_OUT,
1869d30ea906Sjfb8856606 
1870d30ea906Sjfb8856606 	/**
1871d30ea906Sjfb8856606 	 * Implements OFPAT_COPY_TTL_IN ("copy TTL "inwards" -- from
1872d30ea906Sjfb8856606 	 * outermost to next-to-outermost") as defined by the OpenFlow
1873d30ea906Sjfb8856606 	 * Switch Specification.
1874d30ea906Sjfb8856606 	 *
1875d30ea906Sjfb8856606 	 * No associated configuration structure.
1876d30ea906Sjfb8856606 	 */
1877d30ea906Sjfb8856606 	RTE_FLOW_ACTION_TYPE_OF_COPY_TTL_IN,
1878d30ea906Sjfb8856606 
1879d30ea906Sjfb8856606 	/**
1880d30ea906Sjfb8856606 	 * Implements OFPAT_POP_VLAN ("pop the outer VLAN tag") as defined
1881d30ea906Sjfb8856606 	 * by the OpenFlow Switch Specification.
1882d30ea906Sjfb8856606 	 *
1883d30ea906Sjfb8856606 	 * No associated configuration structure.
1884d30ea906Sjfb8856606 	 */
1885d30ea906Sjfb8856606 	RTE_FLOW_ACTION_TYPE_OF_POP_VLAN,
1886d30ea906Sjfb8856606 
1887d30ea906Sjfb8856606 	/**
1888d30ea906Sjfb8856606 	 * Implements OFPAT_PUSH_VLAN ("push a new VLAN tag") as defined by
1889d30ea906Sjfb8856606 	 * the OpenFlow Switch Specification.
1890d30ea906Sjfb8856606 	 *
1891d30ea906Sjfb8856606 	 * See struct rte_flow_action_of_push_vlan.
1892d30ea906Sjfb8856606 	 */
1893d30ea906Sjfb8856606 	RTE_FLOW_ACTION_TYPE_OF_PUSH_VLAN,
1894d30ea906Sjfb8856606 
1895d30ea906Sjfb8856606 	/**
1896d30ea906Sjfb8856606 	 * Implements OFPAT_SET_VLAN_VID ("set the 802.1q VLAN id") as
1897d30ea906Sjfb8856606 	 * defined by the OpenFlow Switch Specification.
1898d30ea906Sjfb8856606 	 *
1899d30ea906Sjfb8856606 	 * See struct rte_flow_action_of_set_vlan_vid.
1900d30ea906Sjfb8856606 	 */
1901d30ea906Sjfb8856606 	RTE_FLOW_ACTION_TYPE_OF_SET_VLAN_VID,
1902d30ea906Sjfb8856606 
1903d30ea906Sjfb8856606 	/**
1904d30ea906Sjfb8856606 	 * Implements OFPAT_SET_LAN_PCP ("set the 802.1q priority") as
1905d30ea906Sjfb8856606 	 * defined by the OpenFlow Switch Specification.
1906d30ea906Sjfb8856606 	 *
1907d30ea906Sjfb8856606 	 * See struct rte_flow_action_of_set_vlan_pcp.
1908d30ea906Sjfb8856606 	 */
1909d30ea906Sjfb8856606 	RTE_FLOW_ACTION_TYPE_OF_SET_VLAN_PCP,
1910d30ea906Sjfb8856606 
1911d30ea906Sjfb8856606 	/**
1912d30ea906Sjfb8856606 	 * Implements OFPAT_POP_MPLS ("pop the outer MPLS tag") as defined
1913d30ea906Sjfb8856606 	 * by the OpenFlow Switch Specification.
1914d30ea906Sjfb8856606 	 *
1915d30ea906Sjfb8856606 	 * See struct rte_flow_action_of_pop_mpls.
1916d30ea906Sjfb8856606 	 */
1917d30ea906Sjfb8856606 	RTE_FLOW_ACTION_TYPE_OF_POP_MPLS,
1918d30ea906Sjfb8856606 
1919d30ea906Sjfb8856606 	/**
1920d30ea906Sjfb8856606 	 * Implements OFPAT_PUSH_MPLS ("push a new MPLS tag") as defined by
1921d30ea906Sjfb8856606 	 * the OpenFlow Switch Specification.
1922d30ea906Sjfb8856606 	 *
1923d30ea906Sjfb8856606 	 * See struct rte_flow_action_of_push_mpls.
1924d30ea906Sjfb8856606 	 */
1925d30ea906Sjfb8856606 	RTE_FLOW_ACTION_TYPE_OF_PUSH_MPLS,
1926d30ea906Sjfb8856606 
1927d30ea906Sjfb8856606 	/**
1928d30ea906Sjfb8856606 	 * Encapsulate flow in VXLAN tunnel as defined in
1929d30ea906Sjfb8856606 	 * rte_flow_action_vxlan_encap action structure.
1930d30ea906Sjfb8856606 	 *
1931d30ea906Sjfb8856606 	 * See struct rte_flow_action_vxlan_encap.
1932d30ea906Sjfb8856606 	 */
1933d30ea906Sjfb8856606 	RTE_FLOW_ACTION_TYPE_VXLAN_ENCAP,
1934d30ea906Sjfb8856606 
1935d30ea906Sjfb8856606 	/**
1936d30ea906Sjfb8856606 	 * Decapsulate outer most VXLAN tunnel from matched flow.
1937d30ea906Sjfb8856606 	 *
1938d30ea906Sjfb8856606 	 * If flow pattern does not define a valid VXLAN tunnel (as specified by
1939d30ea906Sjfb8856606 	 * RFC7348) then the PMD should return a RTE_FLOW_ERROR_TYPE_ACTION
1940d30ea906Sjfb8856606 	 * error.
1941d30ea906Sjfb8856606 	 */
1942d30ea906Sjfb8856606 	RTE_FLOW_ACTION_TYPE_VXLAN_DECAP,
1943d30ea906Sjfb8856606 
1944d30ea906Sjfb8856606 	/**
1945d30ea906Sjfb8856606 	 * Encapsulate flow in NVGRE tunnel defined in the
1946d30ea906Sjfb8856606 	 * rte_flow_action_nvgre_encap action structure.
1947d30ea906Sjfb8856606 	 *
1948d30ea906Sjfb8856606 	 * See struct rte_flow_action_nvgre_encap.
1949d30ea906Sjfb8856606 	 */
1950d30ea906Sjfb8856606 	RTE_FLOW_ACTION_TYPE_NVGRE_ENCAP,
1951d30ea906Sjfb8856606 
1952d30ea906Sjfb8856606 	/**
1953d30ea906Sjfb8856606 	 * Decapsulate outer most NVGRE tunnel from matched flow.
1954d30ea906Sjfb8856606 	 *
1955d30ea906Sjfb8856606 	 * If flow pattern does not define a valid NVGRE tunnel (as specified by
1956d30ea906Sjfb8856606 	 * RFC7637) then the PMD should return a RTE_FLOW_ERROR_TYPE_ACTION
1957d30ea906Sjfb8856606 	 * error.
1958d30ea906Sjfb8856606 	 */
1959d30ea906Sjfb8856606 	RTE_FLOW_ACTION_TYPE_NVGRE_DECAP,
1960d30ea906Sjfb8856606 
1961d30ea906Sjfb8856606 	/**
1962d30ea906Sjfb8856606 	 * Add outer header whose template is provided in its data buffer
1963d30ea906Sjfb8856606 	 *
1964d30ea906Sjfb8856606 	 * See struct rte_flow_action_raw_encap.
1965d30ea906Sjfb8856606 	 */
1966d30ea906Sjfb8856606 	RTE_FLOW_ACTION_TYPE_RAW_ENCAP,
1967d30ea906Sjfb8856606 
1968d30ea906Sjfb8856606 	/**
1969d30ea906Sjfb8856606 	 * Remove outer header whose template is provided in its data buffer.
1970d30ea906Sjfb8856606 	 *
1971d30ea906Sjfb8856606 	 * See struct rte_flow_action_raw_decap
1972d30ea906Sjfb8856606 	 */
1973d30ea906Sjfb8856606 	RTE_FLOW_ACTION_TYPE_RAW_DECAP,
1974d30ea906Sjfb8856606 
1975d30ea906Sjfb8856606 	/**
1976d30ea906Sjfb8856606 	 * Modify IPv4 source address in the outermost IPv4 header.
1977d30ea906Sjfb8856606 	 *
1978d30ea906Sjfb8856606 	 * If flow pattern does not define a valid RTE_FLOW_ITEM_TYPE_IPV4,
1979d30ea906Sjfb8856606 	 * then the PMD should return a RTE_FLOW_ERROR_TYPE_ACTION error.
1980d30ea906Sjfb8856606 	 *
1981d30ea906Sjfb8856606 	 * See struct rte_flow_action_set_ipv4.
1982d30ea906Sjfb8856606 	 */
1983d30ea906Sjfb8856606 	RTE_FLOW_ACTION_TYPE_SET_IPV4_SRC,
1984d30ea906Sjfb8856606 
1985d30ea906Sjfb8856606 	/**
1986d30ea906Sjfb8856606 	 * Modify IPv4 destination address in the outermost IPv4 header.
1987d30ea906Sjfb8856606 	 *
1988d30ea906Sjfb8856606 	 * If flow pattern does not define a valid RTE_FLOW_ITEM_TYPE_IPV4,
1989d30ea906Sjfb8856606 	 * then the PMD should return a RTE_FLOW_ERROR_TYPE_ACTION error.
1990d30ea906Sjfb8856606 	 *
1991d30ea906Sjfb8856606 	 * See struct rte_flow_action_set_ipv4.
1992d30ea906Sjfb8856606 	 */
1993d30ea906Sjfb8856606 	RTE_FLOW_ACTION_TYPE_SET_IPV4_DST,
1994d30ea906Sjfb8856606 
1995d30ea906Sjfb8856606 	/**
1996d30ea906Sjfb8856606 	 * Modify IPv6 source address in the outermost IPv6 header.
1997d30ea906Sjfb8856606 	 *
1998d30ea906Sjfb8856606 	 * If flow pattern does not define a valid RTE_FLOW_ITEM_TYPE_IPV6,
1999d30ea906Sjfb8856606 	 * then the PMD should return a RTE_FLOW_ERROR_TYPE_ACTION error.
2000d30ea906Sjfb8856606 	 *
2001d30ea906Sjfb8856606 	 * See struct rte_flow_action_set_ipv6.
2002d30ea906Sjfb8856606 	 */
2003d30ea906Sjfb8856606 	RTE_FLOW_ACTION_TYPE_SET_IPV6_SRC,
2004d30ea906Sjfb8856606 
2005d30ea906Sjfb8856606 	/**
2006d30ea906Sjfb8856606 	 * Modify IPv6 destination address in the outermost IPv6 header.
2007d30ea906Sjfb8856606 	 *
2008d30ea906Sjfb8856606 	 * If flow pattern does not define a valid RTE_FLOW_ITEM_TYPE_IPV6,
2009d30ea906Sjfb8856606 	 * then the PMD should return a RTE_FLOW_ERROR_TYPE_ACTION error.
2010d30ea906Sjfb8856606 	 *
2011d30ea906Sjfb8856606 	 * See struct rte_flow_action_set_ipv6.
2012d30ea906Sjfb8856606 	 */
2013d30ea906Sjfb8856606 	RTE_FLOW_ACTION_TYPE_SET_IPV6_DST,
2014d30ea906Sjfb8856606 
2015d30ea906Sjfb8856606 	/**
2016d30ea906Sjfb8856606 	 * Modify source port number in the outermost TCP/UDP header.
2017d30ea906Sjfb8856606 	 *
2018d30ea906Sjfb8856606 	 * If flow pattern does not define a valid RTE_FLOW_ITEM_TYPE_TCP
2019d30ea906Sjfb8856606 	 * or RTE_FLOW_ITEM_TYPE_UDP, then the PMD should return a
2020d30ea906Sjfb8856606 	 * RTE_FLOW_ERROR_TYPE_ACTION error.
2021d30ea906Sjfb8856606 	 *
2022d30ea906Sjfb8856606 	 * See struct rte_flow_action_set_tp.
2023d30ea906Sjfb8856606 	 */
2024d30ea906Sjfb8856606 	RTE_FLOW_ACTION_TYPE_SET_TP_SRC,
2025d30ea906Sjfb8856606 
2026d30ea906Sjfb8856606 	/**
2027d30ea906Sjfb8856606 	 * Modify destination port number in the outermost TCP/UDP header.
2028d30ea906Sjfb8856606 	 *
2029d30ea906Sjfb8856606 	 * If flow pattern does not define a valid RTE_FLOW_ITEM_TYPE_TCP
2030d30ea906Sjfb8856606 	 * or RTE_FLOW_ITEM_TYPE_UDP, then the PMD should return a
2031d30ea906Sjfb8856606 	 * RTE_FLOW_ERROR_TYPE_ACTION error.
2032d30ea906Sjfb8856606 	 *
2033d30ea906Sjfb8856606 	 * See struct rte_flow_action_set_tp.
2034d30ea906Sjfb8856606 	 */
2035d30ea906Sjfb8856606 	RTE_FLOW_ACTION_TYPE_SET_TP_DST,
2036d30ea906Sjfb8856606 
2037d30ea906Sjfb8856606 	/**
2038d30ea906Sjfb8856606 	 * Swap the source and destination MAC addresses in the outermost
2039d30ea906Sjfb8856606 	 * Ethernet header.
2040d30ea906Sjfb8856606 	 *
2041d30ea906Sjfb8856606 	 * If flow pattern does not define a valid RTE_FLOW_ITEM_TYPE_ETH,
2042d30ea906Sjfb8856606 	 * then the PMD should return a RTE_FLOW_ERROR_TYPE_ACTION error.
2043d30ea906Sjfb8856606 	 *
2044d30ea906Sjfb8856606 	 * No associated configuration structure.
2045d30ea906Sjfb8856606 	 */
2046d30ea906Sjfb8856606 	RTE_FLOW_ACTION_TYPE_MAC_SWAP,
2047d30ea906Sjfb8856606 
2048d30ea906Sjfb8856606 	/**
2049d30ea906Sjfb8856606 	 * Decrease TTL value directly
2050d30ea906Sjfb8856606 	 *
2051d30ea906Sjfb8856606 	 * No associated configuration structure.
2052d30ea906Sjfb8856606 	 */
2053d30ea906Sjfb8856606 	RTE_FLOW_ACTION_TYPE_DEC_TTL,
2054d30ea906Sjfb8856606 
2055d30ea906Sjfb8856606 	/**
2056d30ea906Sjfb8856606 	 * Set TTL value
2057d30ea906Sjfb8856606 	 *
2058d30ea906Sjfb8856606 	 * See struct rte_flow_action_set_ttl
2059d30ea906Sjfb8856606 	 */
2060d30ea906Sjfb8856606 	RTE_FLOW_ACTION_TYPE_SET_TTL,
2061d30ea906Sjfb8856606 
2062d30ea906Sjfb8856606 	/**
2063d30ea906Sjfb8856606 	 * Set source MAC address from matched flow.
2064d30ea906Sjfb8856606 	 *
2065d30ea906Sjfb8856606 	 * If flow pattern does not define a valid RTE_FLOW_ITEM_TYPE_ETH,
2066d30ea906Sjfb8856606 	 * the PMD should return a RTE_FLOW_ERROR_TYPE_ACTION error.
2067d30ea906Sjfb8856606 	 *
2068d30ea906Sjfb8856606 	 * See struct rte_flow_action_set_mac.
2069d30ea906Sjfb8856606 	 */
2070d30ea906Sjfb8856606 	RTE_FLOW_ACTION_TYPE_SET_MAC_SRC,
2071d30ea906Sjfb8856606 
2072d30ea906Sjfb8856606 	/**
2073d30ea906Sjfb8856606 	 * Set destination MAC address from matched flow.
2074d30ea906Sjfb8856606 	 *
2075d30ea906Sjfb8856606 	 * If flow pattern does not define a valid RTE_FLOW_ITEM_TYPE_ETH,
2076d30ea906Sjfb8856606 	 * the PMD should return a RTE_FLOW_ERROR_TYPE_ACTION error.
2077d30ea906Sjfb8856606 	 *
2078d30ea906Sjfb8856606 	 * See struct rte_flow_action_set_mac.
2079d30ea906Sjfb8856606 	 */
2080d30ea906Sjfb8856606 	RTE_FLOW_ACTION_TYPE_SET_MAC_DST,
20814418919fSjohnjiang 
20824418919fSjohnjiang 	/**
20834418919fSjohnjiang 	 * Increase sequence number in the outermost TCP header.
20844418919fSjohnjiang 	 *
20854418919fSjohnjiang 	 * Action configuration specifies the value to increase
20864418919fSjohnjiang 	 * TCP sequence number as a big-endian 32 bit integer.
20874418919fSjohnjiang 	 *
20884418919fSjohnjiang 	 * @p conf type:
20894418919fSjohnjiang 	 * @code rte_be32_t * @endcode
20904418919fSjohnjiang 	 *
20914418919fSjohnjiang 	 * Using this action on non-matching traffic will result in
20924418919fSjohnjiang 	 * undefined behavior.
20934418919fSjohnjiang 	 */
20944418919fSjohnjiang 	RTE_FLOW_ACTION_TYPE_INC_TCP_SEQ,
20954418919fSjohnjiang 
20964418919fSjohnjiang 	/**
20974418919fSjohnjiang 	 * Decrease sequence number in the outermost TCP header.
20984418919fSjohnjiang 	 *
20994418919fSjohnjiang 	 * Action configuration specifies the value to decrease
21004418919fSjohnjiang 	 * TCP sequence number as a big-endian 32 bit integer.
21014418919fSjohnjiang 	 *
21024418919fSjohnjiang 	 * @p conf type:
21034418919fSjohnjiang 	 * @code rte_be32_t * @endcode
21044418919fSjohnjiang 	 *
21054418919fSjohnjiang 	 * Using this action on non-matching traffic will result in
21064418919fSjohnjiang 	 * undefined behavior.
21074418919fSjohnjiang 	 */
21084418919fSjohnjiang 	RTE_FLOW_ACTION_TYPE_DEC_TCP_SEQ,
21094418919fSjohnjiang 
21104418919fSjohnjiang 	/**
21114418919fSjohnjiang 	 * Increase acknowledgment number in the outermost TCP header.
21124418919fSjohnjiang 	 *
21134418919fSjohnjiang 	 * Action configuration specifies the value to increase
21144418919fSjohnjiang 	 * TCP acknowledgment number as a big-endian 32 bit integer.
21154418919fSjohnjiang 	 *
21164418919fSjohnjiang 	 * @p conf type:
21174418919fSjohnjiang 	 * @code rte_be32_t * @endcode
21184418919fSjohnjiang 
21194418919fSjohnjiang 	 * Using this action on non-matching traffic will result in
21204418919fSjohnjiang 	 * undefined behavior.
21214418919fSjohnjiang 	 */
21224418919fSjohnjiang 	RTE_FLOW_ACTION_TYPE_INC_TCP_ACK,
21234418919fSjohnjiang 
21244418919fSjohnjiang 	/**
21254418919fSjohnjiang 	 * Decrease acknowledgment number in the outermost TCP header.
21264418919fSjohnjiang 	 *
21274418919fSjohnjiang 	 * Action configuration specifies the value to decrease
21284418919fSjohnjiang 	 * TCP acknowledgment number as a big-endian 32 bit integer.
21294418919fSjohnjiang 	 *
21304418919fSjohnjiang 	 * @p conf type:
21314418919fSjohnjiang 	 * @code rte_be32_t * @endcode
21324418919fSjohnjiang 	 *
21334418919fSjohnjiang 	 * Using this action on non-matching traffic will result in
21344418919fSjohnjiang 	 * undefined behavior.
21354418919fSjohnjiang 	 */
21364418919fSjohnjiang 	RTE_FLOW_ACTION_TYPE_DEC_TCP_ACK,
21374418919fSjohnjiang 
21384418919fSjohnjiang 	/**
21394418919fSjohnjiang 	 * Set Tag.
21404418919fSjohnjiang 	 *
21414418919fSjohnjiang 	 * Tag is for internal flow usage only and
21424418919fSjohnjiang 	 * is not delivered to the application.
21434418919fSjohnjiang 	 *
21444418919fSjohnjiang 	 * See struct rte_flow_action_set_tag.
21454418919fSjohnjiang 	 */
21464418919fSjohnjiang 	RTE_FLOW_ACTION_TYPE_SET_TAG,
21474418919fSjohnjiang 
21484418919fSjohnjiang 	/**
21494418919fSjohnjiang 	 * Set metadata on ingress or egress path.
21504418919fSjohnjiang 	 *
21514418919fSjohnjiang 	 * See struct rte_flow_action_set_meta.
21524418919fSjohnjiang 	 */
21534418919fSjohnjiang 	RTE_FLOW_ACTION_TYPE_SET_META,
2154*2d9fd380Sjfb8856606 
2155*2d9fd380Sjfb8856606 	/**
2156*2d9fd380Sjfb8856606 	 * Modify IPv4 DSCP in the outermost IP header.
2157*2d9fd380Sjfb8856606 	 *
2158*2d9fd380Sjfb8856606 	 * If flow pattern does not define a valid RTE_FLOW_ITEM_TYPE_IPV4,
2159*2d9fd380Sjfb8856606 	 * then the PMD should return a RTE_FLOW_ERROR_TYPE_ACTION error.
2160*2d9fd380Sjfb8856606 	 *
2161*2d9fd380Sjfb8856606 	 * See struct rte_flow_action_set_dscp.
2162*2d9fd380Sjfb8856606 	 */
2163*2d9fd380Sjfb8856606 	RTE_FLOW_ACTION_TYPE_SET_IPV4_DSCP,
2164*2d9fd380Sjfb8856606 
2165*2d9fd380Sjfb8856606 	/**
2166*2d9fd380Sjfb8856606 	 * Modify IPv6 DSCP in the outermost IP header.
2167*2d9fd380Sjfb8856606 	 *
2168*2d9fd380Sjfb8856606 	 * If flow pattern does not define a valid RTE_FLOW_ITEM_TYPE_IPV6,
2169*2d9fd380Sjfb8856606 	 * then the PMD should return a RTE_FLOW_ERROR_TYPE_ACTION error.
2170*2d9fd380Sjfb8856606 	 *
2171*2d9fd380Sjfb8856606 	 * See struct rte_flow_action_set_dscp.
2172*2d9fd380Sjfb8856606 	 */
2173*2d9fd380Sjfb8856606 	RTE_FLOW_ACTION_TYPE_SET_IPV6_DSCP,
2174*2d9fd380Sjfb8856606 
2175*2d9fd380Sjfb8856606 	/**
2176*2d9fd380Sjfb8856606 	 * Report as aged flow if timeout passed without any matching on the
2177*2d9fd380Sjfb8856606 	 * flow.
2178*2d9fd380Sjfb8856606 	 *
2179*2d9fd380Sjfb8856606 	 * See struct rte_flow_action_age.
2180*2d9fd380Sjfb8856606 	 * See function rte_flow_get_aged_flows
2181*2d9fd380Sjfb8856606 	 * see enum RTE_ETH_EVENT_FLOW_AGED
2182*2d9fd380Sjfb8856606 	 * See struct rte_flow_query_age
2183*2d9fd380Sjfb8856606 	 */
2184*2d9fd380Sjfb8856606 	RTE_FLOW_ACTION_TYPE_AGE,
2185*2d9fd380Sjfb8856606 
2186*2d9fd380Sjfb8856606 	/**
2187*2d9fd380Sjfb8856606 	 * The matching packets will be duplicated with specified ratio and
2188*2d9fd380Sjfb8856606 	 * applied with own set of actions with a fate action.
2189*2d9fd380Sjfb8856606 	 *
2190*2d9fd380Sjfb8856606 	 * See struct rte_flow_action_sample.
2191*2d9fd380Sjfb8856606 	 */
2192*2d9fd380Sjfb8856606 	RTE_FLOW_ACTION_TYPE_SAMPLE,
2193*2d9fd380Sjfb8856606 
2194*2d9fd380Sjfb8856606 	/**
2195*2d9fd380Sjfb8856606 	 * Describe action shared across multiple flow rules.
2196*2d9fd380Sjfb8856606 	 *
2197*2d9fd380Sjfb8856606 	 * Allow multiple rules reference the same action by handle (see
2198*2d9fd380Sjfb8856606 	 * struct rte_flow_shared_action).
2199*2d9fd380Sjfb8856606 	 */
2200*2d9fd380Sjfb8856606 	RTE_FLOW_ACTION_TYPE_SHARED,
2201d30ea906Sjfb8856606 };
2202d30ea906Sjfb8856606 
2203d30ea906Sjfb8856606 /**
2204d30ea906Sjfb8856606  * RTE_FLOW_ACTION_TYPE_MARK
2205d30ea906Sjfb8856606  *
2206d30ea906Sjfb8856606  * Attaches an integer value to packets and sets PKT_RX_FDIR and
2207d30ea906Sjfb8856606  * PKT_RX_FDIR_ID mbuf flags.
2208d30ea906Sjfb8856606  *
2209d30ea906Sjfb8856606  * This value is arbitrary and application-defined. Maximum allowed value
2210d30ea906Sjfb8856606  * depends on the underlying implementation. It is returned in the
2211d30ea906Sjfb8856606  * hash.fdir.hi mbuf field.
2212d30ea906Sjfb8856606  */
2213d30ea906Sjfb8856606 struct rte_flow_action_mark {
2214d30ea906Sjfb8856606 	uint32_t id; /**< Integer value to return with packets. */
2215d30ea906Sjfb8856606 };
2216d30ea906Sjfb8856606 
2217d30ea906Sjfb8856606 /**
2218d30ea906Sjfb8856606  * @warning
2219d30ea906Sjfb8856606  * @b EXPERIMENTAL: this structure may change without prior notice
2220d30ea906Sjfb8856606  *
2221d30ea906Sjfb8856606  * RTE_FLOW_ACTION_TYPE_JUMP
2222d30ea906Sjfb8856606  *
2223d30ea906Sjfb8856606  * Redirects packets to a group on the current device.
2224d30ea906Sjfb8856606  *
2225d30ea906Sjfb8856606  * In a hierarchy of groups, which can be used to represent physical or logical
2226d30ea906Sjfb8856606  * flow tables on the device, this action allows the action to be a redirect to
2227d30ea906Sjfb8856606  * a group on that device.
2228d30ea906Sjfb8856606  */
2229d30ea906Sjfb8856606 struct rte_flow_action_jump {
2230d30ea906Sjfb8856606 	uint32_t group;
2231d30ea906Sjfb8856606 };
2232d30ea906Sjfb8856606 
2233d30ea906Sjfb8856606 /**
2234d30ea906Sjfb8856606  * RTE_FLOW_ACTION_TYPE_QUEUE
2235d30ea906Sjfb8856606  *
2236d30ea906Sjfb8856606  * Assign packets to a given queue index.
2237d30ea906Sjfb8856606  */
2238d30ea906Sjfb8856606 struct rte_flow_action_queue {
2239d30ea906Sjfb8856606 	uint16_t index; /**< Queue index to use. */
2240d30ea906Sjfb8856606 };
2241d30ea906Sjfb8856606 
2242*2d9fd380Sjfb8856606 /**
2243*2d9fd380Sjfb8856606  * @warning
2244*2d9fd380Sjfb8856606  * @b EXPERIMENTAL: this structure may change without prior notice
2245*2d9fd380Sjfb8856606  *
2246*2d9fd380Sjfb8856606  * RTE_FLOW_ACTION_TYPE_AGE
2247*2d9fd380Sjfb8856606  *
2248*2d9fd380Sjfb8856606  * Report flow as aged-out if timeout passed without any matching
2249*2d9fd380Sjfb8856606  * on the flow. RTE_ETH_EVENT_FLOW_AGED event is triggered when a
2250*2d9fd380Sjfb8856606  * port detects new aged-out flows.
2251*2d9fd380Sjfb8856606  *
2252*2d9fd380Sjfb8856606  * The flow context and the flow handle will be reported by the
2253*2d9fd380Sjfb8856606  * rte_flow_get_aged_flows API.
2254*2d9fd380Sjfb8856606  */
2255*2d9fd380Sjfb8856606 struct rte_flow_action_age {
2256*2d9fd380Sjfb8856606 	uint32_t timeout:24; /**< Time in seconds. */
2257*2d9fd380Sjfb8856606 	uint32_t reserved:8; /**< Reserved, must be zero. */
2258*2d9fd380Sjfb8856606 	void *context;
2259*2d9fd380Sjfb8856606 		/**< The user flow context, NULL means the rte_flow pointer. */
2260*2d9fd380Sjfb8856606 };
2261*2d9fd380Sjfb8856606 
2262*2d9fd380Sjfb8856606 /**
2263*2d9fd380Sjfb8856606  * RTE_FLOW_ACTION_TYPE_AGE (query)
2264*2d9fd380Sjfb8856606  *
2265*2d9fd380Sjfb8856606  * Query structure to retrieve the aging status information of a
2266*2d9fd380Sjfb8856606  * shared AGE action, or a flow rule using the AGE action.
2267*2d9fd380Sjfb8856606  */
2268*2d9fd380Sjfb8856606 struct rte_flow_query_age {
2269*2d9fd380Sjfb8856606 	uint32_t reserved:6; /**< Reserved, must be zero. */
2270*2d9fd380Sjfb8856606 	uint32_t aged:1; /**< 1 if aging timeout expired, 0 otherwise. */
2271*2d9fd380Sjfb8856606 	uint32_t sec_since_last_hit_valid:1;
2272*2d9fd380Sjfb8856606 	/**< sec_since_last_hit value is valid. */
2273*2d9fd380Sjfb8856606 	uint32_t sec_since_last_hit:24; /**< Seconds since last traffic hit. */
2274*2d9fd380Sjfb8856606 };
2275d30ea906Sjfb8856606 
2276d30ea906Sjfb8856606 /**
2277d30ea906Sjfb8856606  * @warning
2278d30ea906Sjfb8856606  * @b EXPERIMENTAL: this structure may change without prior notice
2279d30ea906Sjfb8856606  *
2280d30ea906Sjfb8856606  * RTE_FLOW_ACTION_TYPE_COUNT
2281d30ea906Sjfb8856606  *
2282d30ea906Sjfb8856606  * Adds a counter action to a matched flow.
2283d30ea906Sjfb8856606  *
2284d30ea906Sjfb8856606  * If more than one count action is specified in a single flow rule, then each
2285d30ea906Sjfb8856606  * action must specify a unique id.
2286d30ea906Sjfb8856606  *
2287d30ea906Sjfb8856606  * Counters can be retrieved and reset through ``rte_flow_query()``, see
2288d30ea906Sjfb8856606  * ``struct rte_flow_query_count``.
2289d30ea906Sjfb8856606  *
2290*2d9fd380Sjfb8856606  * @deprecated Shared attribute is deprecated, use generic
2291*2d9fd380Sjfb8856606  * RTE_FLOW_ACTION_TYPE_SHARED action.
2292*2d9fd380Sjfb8856606  *
2293d30ea906Sjfb8856606  * The shared flag indicates whether the counter is unique to the flow rule the
2294d30ea906Sjfb8856606  * action is specified with, or whether it is a shared counter.
2295d30ea906Sjfb8856606  *
2296d30ea906Sjfb8856606  * For a count action with the shared flag set, then then a global device
2297d30ea906Sjfb8856606  * namespace is assumed for the counter id, so that any matched flow rules using
2298d30ea906Sjfb8856606  * a count action with the same counter id on the same port will contribute to
2299d30ea906Sjfb8856606  * that counter.
2300d30ea906Sjfb8856606  *
2301d30ea906Sjfb8856606  * For ports within the same switch domain then the counter id namespace extends
2302d30ea906Sjfb8856606  * to all ports within that switch domain.
2303d30ea906Sjfb8856606  */
2304d30ea906Sjfb8856606 struct rte_flow_action_count {
2305*2d9fd380Sjfb8856606 	/** @deprecated Share counter ID with other flow rules. */
2306*2d9fd380Sjfb8856606 	uint32_t shared:1;
2307d30ea906Sjfb8856606 	uint32_t reserved:31; /**< Reserved, must be zero. */
2308d30ea906Sjfb8856606 	uint32_t id; /**< Counter ID. */
2309d30ea906Sjfb8856606 };
2310d30ea906Sjfb8856606 
2311d30ea906Sjfb8856606 /**
2312d30ea906Sjfb8856606  * RTE_FLOW_ACTION_TYPE_COUNT (query)
2313d30ea906Sjfb8856606  *
2314d30ea906Sjfb8856606  * Query structure to retrieve and reset flow rule counters.
2315d30ea906Sjfb8856606  */
2316d30ea906Sjfb8856606 struct rte_flow_query_count {
2317d30ea906Sjfb8856606 	uint32_t reset:1; /**< Reset counters after query [in]. */
2318d30ea906Sjfb8856606 	uint32_t hits_set:1; /**< hits field is set [out]. */
2319d30ea906Sjfb8856606 	uint32_t bytes_set:1; /**< bytes field is set [out]. */
2320d30ea906Sjfb8856606 	uint32_t reserved:29; /**< Reserved, must be zero [in, out]. */
2321d30ea906Sjfb8856606 	uint64_t hits; /**< Number of hits for this rule [out]. */
2322d30ea906Sjfb8856606 	uint64_t bytes; /**< Number of bytes through this rule [out]. */
2323d30ea906Sjfb8856606 };
2324d30ea906Sjfb8856606 
2325d30ea906Sjfb8856606 /**
23264418919fSjohnjiang  * Hash function types.
23274418919fSjohnjiang  */
23284418919fSjohnjiang enum rte_eth_hash_function {
23294418919fSjohnjiang 	RTE_ETH_HASH_FUNCTION_DEFAULT = 0,
23304418919fSjohnjiang 	RTE_ETH_HASH_FUNCTION_TOEPLITZ, /**< Toeplitz */
23314418919fSjohnjiang 	RTE_ETH_HASH_FUNCTION_SIMPLE_XOR, /**< Simple XOR */
23324418919fSjohnjiang 	/**
23334418919fSjohnjiang 	 * Symmetric Toeplitz: src, dst will be replaced by
23344418919fSjohnjiang 	 * xor(src, dst). For the case with src/dst only,
23354418919fSjohnjiang 	 * src or dst address will xor with zero pair.
23364418919fSjohnjiang 	 */
23374418919fSjohnjiang 	RTE_ETH_HASH_FUNCTION_SYMMETRIC_TOEPLITZ,
23384418919fSjohnjiang 	RTE_ETH_HASH_FUNCTION_MAX,
23394418919fSjohnjiang };
23404418919fSjohnjiang 
23414418919fSjohnjiang /**
2342d30ea906Sjfb8856606  * RTE_FLOW_ACTION_TYPE_RSS
2343d30ea906Sjfb8856606  *
2344d30ea906Sjfb8856606  * Similar to QUEUE, except RSS is additionally performed on packets to
2345d30ea906Sjfb8856606  * spread them among several queues according to the provided parameters.
2346d30ea906Sjfb8856606  *
2347d30ea906Sjfb8856606  * Unlike global RSS settings used by other DPDK APIs, unsetting the
2348d30ea906Sjfb8856606  * @p types field does not disable RSS in a flow rule. Doing so instead
2349d30ea906Sjfb8856606  * requests safe unspecified "best-effort" settings from the underlying PMD,
2350d30ea906Sjfb8856606  * which depending on the flow rule, may result in anything ranging from
2351d30ea906Sjfb8856606  * empty (single queue) to all-inclusive RSS.
2352d30ea906Sjfb8856606  *
2353d30ea906Sjfb8856606  * Note: RSS hash result is stored in the hash.rss mbuf field which overlaps
2354d30ea906Sjfb8856606  * hash.fdir.lo. Since the MARK action sets the hash.fdir.hi field only,
2355d30ea906Sjfb8856606  * both can be requested simultaneously.
2356d30ea906Sjfb8856606  */
2357d30ea906Sjfb8856606 struct rte_flow_action_rss {
2358d30ea906Sjfb8856606 	enum rte_eth_hash_function func; /**< RSS hash function to apply. */
2359d30ea906Sjfb8856606 	/**
2360d30ea906Sjfb8856606 	 * Packet encapsulation level RSS hash @p types apply to.
2361d30ea906Sjfb8856606 	 *
2362d30ea906Sjfb8856606 	 * - @p 0 requests the default behavior. Depending on the packet
2363d30ea906Sjfb8856606 	 *   type, it can mean outermost, innermost, anything in between or
2364d30ea906Sjfb8856606 	 *   even no RSS.
2365d30ea906Sjfb8856606 	 *
2366d30ea906Sjfb8856606 	 *   It basically stands for the innermost encapsulation level RSS
2367d30ea906Sjfb8856606 	 *   can be performed on according to PMD and device capabilities.
2368d30ea906Sjfb8856606 	 *
2369d30ea906Sjfb8856606 	 * - @p 1 requests RSS to be performed on the outermost packet
2370d30ea906Sjfb8856606 	 *   encapsulation level.
2371d30ea906Sjfb8856606 	 *
2372d30ea906Sjfb8856606 	 * - @p 2 and subsequent values request RSS to be performed on the
2373d30ea906Sjfb8856606 	 *   specified inner packet encapsulation level, from outermost to
2374d30ea906Sjfb8856606 	 *   innermost (lower to higher values).
2375d30ea906Sjfb8856606 	 *
2376d30ea906Sjfb8856606 	 * Values other than @p 0 are not necessarily supported.
2377d30ea906Sjfb8856606 	 *
2378d30ea906Sjfb8856606 	 * Requesting a specific RSS level on unrecognized traffic results
2379d30ea906Sjfb8856606 	 * in undefined behavior. For predictable results, it is recommended
2380d30ea906Sjfb8856606 	 * to make the flow rule pattern match packet headers up to the
2381d30ea906Sjfb8856606 	 * requested encapsulation level so that only matching traffic goes
2382d30ea906Sjfb8856606 	 * through.
2383d30ea906Sjfb8856606 	 */
2384d30ea906Sjfb8856606 	uint32_t level;
2385d30ea906Sjfb8856606 	uint64_t types; /**< Specific RSS hash types (see ETH_RSS_*). */
2386d30ea906Sjfb8856606 	uint32_t key_len; /**< Hash key length in bytes. */
2387d30ea906Sjfb8856606 	uint32_t queue_num; /**< Number of entries in @p queue. */
2388d30ea906Sjfb8856606 	const uint8_t *key; /**< Hash key. */
2389d30ea906Sjfb8856606 	const uint16_t *queue; /**< Queue indices to use. */
2390d30ea906Sjfb8856606 };
2391d30ea906Sjfb8856606 
2392d30ea906Sjfb8856606 /**
2393d30ea906Sjfb8856606  * RTE_FLOW_ACTION_TYPE_VF
2394d30ea906Sjfb8856606  *
2395d30ea906Sjfb8856606  * Directs matching traffic to a given virtual function of the current
2396d30ea906Sjfb8856606  * device.
2397d30ea906Sjfb8856606  *
2398d30ea906Sjfb8856606  * Packets matched by a VF pattern item can be redirected to their original
2399d30ea906Sjfb8856606  * VF ID instead of the specified one. This parameter may not be available
2400d30ea906Sjfb8856606  * and is not guaranteed to work properly if the VF part is matched by a
2401d30ea906Sjfb8856606  * prior flow rule or if packets are not addressed to a VF in the first
2402d30ea906Sjfb8856606  * place.
2403d30ea906Sjfb8856606  */
2404d30ea906Sjfb8856606 struct rte_flow_action_vf {
2405d30ea906Sjfb8856606 	uint32_t original:1; /**< Use original VF ID if possible. */
2406d30ea906Sjfb8856606 	uint32_t reserved:31; /**< Reserved, must be zero. */
2407d30ea906Sjfb8856606 	uint32_t id; /**< VF ID. */
2408d30ea906Sjfb8856606 };
2409d30ea906Sjfb8856606 
2410d30ea906Sjfb8856606 /**
2411d30ea906Sjfb8856606  * RTE_FLOW_ACTION_TYPE_PHY_PORT
2412d30ea906Sjfb8856606  *
2413d30ea906Sjfb8856606  * Directs packets to a given physical port index of the underlying
2414d30ea906Sjfb8856606  * device.
2415d30ea906Sjfb8856606  *
2416d30ea906Sjfb8856606  * @see RTE_FLOW_ITEM_TYPE_PHY_PORT
2417d30ea906Sjfb8856606  */
2418d30ea906Sjfb8856606 struct rte_flow_action_phy_port {
2419d30ea906Sjfb8856606 	uint32_t original:1; /**< Use original port index if possible. */
2420d30ea906Sjfb8856606 	uint32_t reserved:31; /**< Reserved, must be zero. */
2421d30ea906Sjfb8856606 	uint32_t index; /**< Physical port index. */
2422d30ea906Sjfb8856606 };
2423d30ea906Sjfb8856606 
2424d30ea906Sjfb8856606 /**
2425d30ea906Sjfb8856606  * RTE_FLOW_ACTION_TYPE_PORT_ID
2426d30ea906Sjfb8856606  *
2427d30ea906Sjfb8856606  * Directs matching traffic to a given DPDK port ID.
2428d30ea906Sjfb8856606  *
2429d30ea906Sjfb8856606  * @see RTE_FLOW_ITEM_TYPE_PORT_ID
2430d30ea906Sjfb8856606  */
2431d30ea906Sjfb8856606 struct rte_flow_action_port_id {
2432d30ea906Sjfb8856606 	uint32_t original:1; /**< Use original DPDK port ID if possible. */
2433d30ea906Sjfb8856606 	uint32_t reserved:31; /**< Reserved, must be zero. */
2434d30ea906Sjfb8856606 	uint32_t id; /**< DPDK port ID. */
2435d30ea906Sjfb8856606 };
2436d30ea906Sjfb8856606 
2437d30ea906Sjfb8856606 /**
2438d30ea906Sjfb8856606  * RTE_FLOW_ACTION_TYPE_METER
2439d30ea906Sjfb8856606  *
2440d30ea906Sjfb8856606  * Traffic metering and policing (MTR).
2441d30ea906Sjfb8856606  *
2442d30ea906Sjfb8856606  * Packets matched by items of this type can be either dropped or passed to the
2443d30ea906Sjfb8856606  * next item with their color set by the MTR object.
2444d30ea906Sjfb8856606  */
2445d30ea906Sjfb8856606 struct rte_flow_action_meter {
2446d30ea906Sjfb8856606 	uint32_t mtr_id; /**< MTR object ID created with rte_mtr_create(). */
2447d30ea906Sjfb8856606 };
2448d30ea906Sjfb8856606 
2449d30ea906Sjfb8856606 /**
2450d30ea906Sjfb8856606  * RTE_FLOW_ACTION_TYPE_SECURITY
2451d30ea906Sjfb8856606  *
2452d30ea906Sjfb8856606  * Perform the security action on flows matched by the pattern items
2453d30ea906Sjfb8856606  * according to the configuration of the security session.
2454d30ea906Sjfb8856606  *
2455d30ea906Sjfb8856606  * This action modifies the payload of matched flows. For INLINE_CRYPTO, the
2456d30ea906Sjfb8856606  * security protocol headers and IV are fully provided by the application as
2457d30ea906Sjfb8856606  * specified in the flow pattern. The payload of matching packets is
2458d30ea906Sjfb8856606  * encrypted on egress, and decrypted and authenticated on ingress.
2459d30ea906Sjfb8856606  * For INLINE_PROTOCOL, the security protocol is fully offloaded to HW,
2460d30ea906Sjfb8856606  * providing full encapsulation and decapsulation of packets in security
2461d30ea906Sjfb8856606  * protocols. The flow pattern specifies both the outer security header fields
2462d30ea906Sjfb8856606  * and the inner packet fields. The security session specified in the action
2463d30ea906Sjfb8856606  * must match the pattern parameters.
2464d30ea906Sjfb8856606  *
2465d30ea906Sjfb8856606  * The security session specified in the action must be created on the same
2466d30ea906Sjfb8856606  * port as the flow action that is being specified.
2467d30ea906Sjfb8856606  *
2468d30ea906Sjfb8856606  * The ingress/egress flow attribute should match that specified in the
2469d30ea906Sjfb8856606  * security session if the security session supports the definition of the
2470d30ea906Sjfb8856606  * direction.
2471d30ea906Sjfb8856606  *
2472d30ea906Sjfb8856606  * Multiple flows can be configured to use the same security session.
2473*2d9fd380Sjfb8856606  *
2474*2d9fd380Sjfb8856606  * The NULL value is allowed for security session. If security session is NULL,
2475*2d9fd380Sjfb8856606  * then SPI field in ESP flow item and IP addresses in flow items 'IPv4' and
2476*2d9fd380Sjfb8856606  * 'IPv6' will be allowed to be a range. The rule thus created can enable
2477*2d9fd380Sjfb8856606  * security processing on multiple flows.
2478d30ea906Sjfb8856606  */
2479d30ea906Sjfb8856606 struct rte_flow_action_security {
2480d30ea906Sjfb8856606 	void *security_session; /**< Pointer to security session structure. */
2481d30ea906Sjfb8856606 };
2482d30ea906Sjfb8856606 
2483d30ea906Sjfb8856606 /**
2484d30ea906Sjfb8856606  * RTE_FLOW_ACTION_TYPE_OF_SET_MPLS_TTL
2485d30ea906Sjfb8856606  *
2486d30ea906Sjfb8856606  * Implements OFPAT_SET_MPLS_TTL ("MPLS TTL") as defined by the OpenFlow
2487d30ea906Sjfb8856606  * Switch Specification.
2488d30ea906Sjfb8856606  */
2489d30ea906Sjfb8856606 struct rte_flow_action_of_set_mpls_ttl {
2490d30ea906Sjfb8856606 	uint8_t mpls_ttl; /**< MPLS TTL. */
2491d30ea906Sjfb8856606 };
2492d30ea906Sjfb8856606 
2493d30ea906Sjfb8856606 /**
2494d30ea906Sjfb8856606  * RTE_FLOW_ACTION_TYPE_OF_SET_NW_TTL
2495d30ea906Sjfb8856606  *
2496d30ea906Sjfb8856606  * Implements OFPAT_SET_NW_TTL ("IP TTL") as defined by the OpenFlow Switch
2497d30ea906Sjfb8856606  * Specification.
2498d30ea906Sjfb8856606  */
2499d30ea906Sjfb8856606 struct rte_flow_action_of_set_nw_ttl {
2500d30ea906Sjfb8856606 	uint8_t nw_ttl; /**< IP TTL. */
2501d30ea906Sjfb8856606 };
2502d30ea906Sjfb8856606 
2503d30ea906Sjfb8856606 /**
2504d30ea906Sjfb8856606  * RTE_FLOW_ACTION_TYPE_OF_PUSH_VLAN
2505d30ea906Sjfb8856606  *
2506d30ea906Sjfb8856606  * Implements OFPAT_PUSH_VLAN ("push a new VLAN tag") as defined by the
2507d30ea906Sjfb8856606  * OpenFlow Switch Specification.
2508d30ea906Sjfb8856606  */
2509d30ea906Sjfb8856606 struct rte_flow_action_of_push_vlan {
2510d30ea906Sjfb8856606 	rte_be16_t ethertype; /**< EtherType. */
2511d30ea906Sjfb8856606 };
2512d30ea906Sjfb8856606 
2513d30ea906Sjfb8856606 /**
2514d30ea906Sjfb8856606  * RTE_FLOW_ACTION_TYPE_OF_SET_VLAN_VID
2515d30ea906Sjfb8856606  *
2516d30ea906Sjfb8856606  * Implements OFPAT_SET_VLAN_VID ("set the 802.1q VLAN id") as defined by
2517d30ea906Sjfb8856606  * the OpenFlow Switch Specification.
2518d30ea906Sjfb8856606  */
2519d30ea906Sjfb8856606 struct rte_flow_action_of_set_vlan_vid {
2520d30ea906Sjfb8856606 	rte_be16_t vlan_vid; /**< VLAN id. */
2521d30ea906Sjfb8856606 };
2522d30ea906Sjfb8856606 
2523d30ea906Sjfb8856606 /**
2524d30ea906Sjfb8856606  * RTE_FLOW_ACTION_TYPE_OF_SET_VLAN_PCP
2525d30ea906Sjfb8856606  *
2526d30ea906Sjfb8856606  * Implements OFPAT_SET_LAN_PCP ("set the 802.1q priority") as defined by
2527d30ea906Sjfb8856606  * the OpenFlow Switch Specification.
2528d30ea906Sjfb8856606  */
2529d30ea906Sjfb8856606 struct rte_flow_action_of_set_vlan_pcp {
2530d30ea906Sjfb8856606 	uint8_t vlan_pcp; /**< VLAN priority. */
2531d30ea906Sjfb8856606 };
2532d30ea906Sjfb8856606 
2533d30ea906Sjfb8856606 /**
2534d30ea906Sjfb8856606  * RTE_FLOW_ACTION_TYPE_OF_POP_MPLS
2535d30ea906Sjfb8856606  *
2536d30ea906Sjfb8856606  * Implements OFPAT_POP_MPLS ("pop the outer MPLS tag") as defined by the
2537d30ea906Sjfb8856606  * OpenFlow Switch Specification.
2538d30ea906Sjfb8856606  */
2539d30ea906Sjfb8856606 struct rte_flow_action_of_pop_mpls {
2540d30ea906Sjfb8856606 	rte_be16_t ethertype; /**< EtherType. */
2541d30ea906Sjfb8856606 };
2542d30ea906Sjfb8856606 
2543d30ea906Sjfb8856606 /**
2544d30ea906Sjfb8856606  * RTE_FLOW_ACTION_TYPE_OF_PUSH_MPLS
2545d30ea906Sjfb8856606  *
2546d30ea906Sjfb8856606  * Implements OFPAT_PUSH_MPLS ("push a new MPLS tag") as defined by the
2547d30ea906Sjfb8856606  * OpenFlow Switch Specification.
2548d30ea906Sjfb8856606  */
2549d30ea906Sjfb8856606 struct rte_flow_action_of_push_mpls {
2550d30ea906Sjfb8856606 	rte_be16_t ethertype; /**< EtherType. */
2551d30ea906Sjfb8856606 };
2552d30ea906Sjfb8856606 
2553d30ea906Sjfb8856606 /**
2554d30ea906Sjfb8856606  * @warning
2555d30ea906Sjfb8856606  * @b EXPERIMENTAL: this structure may change without prior notice
2556d30ea906Sjfb8856606  *
2557d30ea906Sjfb8856606  * RTE_FLOW_ACTION_TYPE_VXLAN_ENCAP
2558d30ea906Sjfb8856606  *
2559d30ea906Sjfb8856606  * VXLAN tunnel end-point encapsulation data definition
2560d30ea906Sjfb8856606  *
2561d30ea906Sjfb8856606  * The tunnel definition is provided through the flow item pattern, the
2562d30ea906Sjfb8856606  * provided pattern must conform to RFC7348 for the tunnel specified. The flow
2563d30ea906Sjfb8856606  * definition must be provided in order from the RTE_FLOW_ITEM_TYPE_ETH
2564d30ea906Sjfb8856606  * definition up the end item which is specified by RTE_FLOW_ITEM_TYPE_END.
2565d30ea906Sjfb8856606  *
2566d30ea906Sjfb8856606  * The mask field allows user to specify which fields in the flow item
2567d30ea906Sjfb8856606  * definitions can be ignored and which have valid data and can be used
2568d30ea906Sjfb8856606  * verbatim.
2569d30ea906Sjfb8856606  *
2570d30ea906Sjfb8856606  * Note: the last field is not used in the definition of a tunnel and can be
2571d30ea906Sjfb8856606  * ignored.
2572d30ea906Sjfb8856606  *
2573d30ea906Sjfb8856606  * Valid flow definition for RTE_FLOW_ACTION_TYPE_VXLAN_ENCAP include:
2574d30ea906Sjfb8856606  *
2575d30ea906Sjfb8856606  * - ETH / IPV4 / UDP / VXLAN / END
2576d30ea906Sjfb8856606  * - ETH / IPV6 / UDP / VXLAN / END
2577d30ea906Sjfb8856606  * - ETH / VLAN / IPV4 / UDP / VXLAN / END
2578d30ea906Sjfb8856606  *
2579d30ea906Sjfb8856606  */
2580d30ea906Sjfb8856606 struct rte_flow_action_vxlan_encap {
2581d30ea906Sjfb8856606 	/**
2582d30ea906Sjfb8856606 	 * Encapsulating vxlan tunnel definition
2583d30ea906Sjfb8856606 	 * (terminated by the END pattern item).
2584d30ea906Sjfb8856606 	 */
2585d30ea906Sjfb8856606 	struct rte_flow_item *definition;
2586d30ea906Sjfb8856606 };
2587d30ea906Sjfb8856606 
2588d30ea906Sjfb8856606 /**
2589d30ea906Sjfb8856606  * @warning
2590d30ea906Sjfb8856606  * @b EXPERIMENTAL: this structure may change without prior notice
2591d30ea906Sjfb8856606  *
2592d30ea906Sjfb8856606  * RTE_FLOW_ACTION_TYPE_NVGRE_ENCAP
2593d30ea906Sjfb8856606  *
2594d30ea906Sjfb8856606  * NVGRE tunnel end-point encapsulation data definition
2595d30ea906Sjfb8856606  *
2596d30ea906Sjfb8856606  * The tunnel definition is provided through the flow item pattern  the
2597d30ea906Sjfb8856606  * provided pattern must conform with RFC7637. The flow definition must be
2598d30ea906Sjfb8856606  * provided in order from the RTE_FLOW_ITEM_TYPE_ETH definition up the end item
2599d30ea906Sjfb8856606  * which is specified by RTE_FLOW_ITEM_TYPE_END.
2600d30ea906Sjfb8856606  *
2601d30ea906Sjfb8856606  * The mask field allows user to specify which fields in the flow item
2602d30ea906Sjfb8856606  * definitions can be ignored and which have valid data and can be used
2603d30ea906Sjfb8856606  * verbatim.
2604d30ea906Sjfb8856606  *
2605d30ea906Sjfb8856606  * Note: the last field is not used in the definition of a tunnel and can be
2606d30ea906Sjfb8856606  * ignored.
2607d30ea906Sjfb8856606  *
2608d30ea906Sjfb8856606  * Valid flow definition for RTE_FLOW_ACTION_TYPE_NVGRE_ENCAP include:
2609d30ea906Sjfb8856606  *
2610d30ea906Sjfb8856606  * - ETH / IPV4 / NVGRE / END
2611d30ea906Sjfb8856606  * - ETH / VLAN / IPV6 / NVGRE / END
2612d30ea906Sjfb8856606  *
2613d30ea906Sjfb8856606  */
2614d30ea906Sjfb8856606 struct rte_flow_action_nvgre_encap {
2615d30ea906Sjfb8856606 	/**
2616d30ea906Sjfb8856606 	 * Encapsulating vxlan tunnel definition
2617d30ea906Sjfb8856606 	 * (terminated by the END pattern item).
2618d30ea906Sjfb8856606 	 */
2619d30ea906Sjfb8856606 	struct rte_flow_item *definition;
2620d30ea906Sjfb8856606 };
2621d30ea906Sjfb8856606 
2622d30ea906Sjfb8856606 /**
2623d30ea906Sjfb8856606  * @warning
2624d30ea906Sjfb8856606  * @b EXPERIMENTAL: this structure may change without prior notice
2625d30ea906Sjfb8856606  *
2626d30ea906Sjfb8856606  * RTE_FLOW_ACTION_TYPE_RAW_ENCAP
2627d30ea906Sjfb8856606  *
2628d30ea906Sjfb8856606  * Raw tunnel end-point encapsulation data definition.
2629d30ea906Sjfb8856606  *
2630d30ea906Sjfb8856606  * The data holds the headers definitions to be applied on the packet.
2631d30ea906Sjfb8856606  * The data must start with ETH header up to the tunnel item header itself.
2632d30ea906Sjfb8856606  * When used right after RAW_DECAP (for decapsulating L3 tunnel type for
2633d30ea906Sjfb8856606  * example MPLSoGRE) the data will just hold layer 2 header.
2634d30ea906Sjfb8856606  *
2635d30ea906Sjfb8856606  * The preserve parameter holds which bits in the packet the PMD is not allowed
2636d30ea906Sjfb8856606  * to change, this parameter can also be NULL and then the PMD is allowed
2637d30ea906Sjfb8856606  * to update any field.
2638d30ea906Sjfb8856606  *
2639d30ea906Sjfb8856606  * size holds the number of bytes in @p data and @p preserve.
2640d30ea906Sjfb8856606  */
2641d30ea906Sjfb8856606 struct rte_flow_action_raw_encap {
2642d30ea906Sjfb8856606 	uint8_t *data; /**< Encapsulation data. */
2643d30ea906Sjfb8856606 	uint8_t *preserve; /**< Bit-mask of @p data to preserve on output. */
2644d30ea906Sjfb8856606 	size_t size; /**< Size of @p data and @p preserve. */
2645d30ea906Sjfb8856606 };
2646d30ea906Sjfb8856606 
2647d30ea906Sjfb8856606 /**
2648d30ea906Sjfb8856606  * @warning
2649d30ea906Sjfb8856606  * @b EXPERIMENTAL: this structure may change without prior notice
2650d30ea906Sjfb8856606  *
2651d30ea906Sjfb8856606  * RTE_FLOW_ACTION_TYPE_RAW_DECAP
2652d30ea906Sjfb8856606  *
2653d30ea906Sjfb8856606  * Raw tunnel end-point decapsulation data definition.
2654d30ea906Sjfb8856606  *
2655d30ea906Sjfb8856606  * The data holds the headers definitions to be removed from the packet.
2656d30ea906Sjfb8856606  * The data must start with ETH header up to the tunnel item header itself.
2657d30ea906Sjfb8856606  * When used right before RAW_DECAP (for encapsulating L3 tunnel type for
2658d30ea906Sjfb8856606  * example MPLSoGRE) the data will just hold layer 2 header.
2659d30ea906Sjfb8856606  *
2660d30ea906Sjfb8856606  * size holds the number of bytes in @p data.
2661d30ea906Sjfb8856606  */
2662d30ea906Sjfb8856606 struct rte_flow_action_raw_decap {
2663d30ea906Sjfb8856606 	uint8_t *data; /**< Encapsulation data. */
2664d30ea906Sjfb8856606 	size_t size; /**< Size of @p data and @p preserve. */
2665d30ea906Sjfb8856606 };
2666d30ea906Sjfb8856606 
2667d30ea906Sjfb8856606 /**
2668d30ea906Sjfb8856606  * @warning
2669d30ea906Sjfb8856606  * @b EXPERIMENTAL: this structure may change without prior notice
2670d30ea906Sjfb8856606  *
2671d30ea906Sjfb8856606  * RTE_FLOW_ACTION_TYPE_SET_IPV4_SRC
2672d30ea906Sjfb8856606  * RTE_FLOW_ACTION_TYPE_SET_IPV4_DST
2673d30ea906Sjfb8856606  *
2674d30ea906Sjfb8856606  * Allows modification of IPv4 source (RTE_FLOW_ACTION_TYPE_SET_IPV4_SRC)
2675d30ea906Sjfb8856606  * and destination address (RTE_FLOW_ACTION_TYPE_SET_IPV4_DST) in the
2676d30ea906Sjfb8856606  * specified outermost IPv4 header.
2677d30ea906Sjfb8856606  */
2678d30ea906Sjfb8856606 struct rte_flow_action_set_ipv4 {
2679d30ea906Sjfb8856606 	rte_be32_t ipv4_addr;
2680d30ea906Sjfb8856606 };
2681d30ea906Sjfb8856606 
2682d30ea906Sjfb8856606 /**
2683d30ea906Sjfb8856606  * @warning
2684d30ea906Sjfb8856606  * @b EXPERIMENTAL: this structure may change without prior notice
2685d30ea906Sjfb8856606  *
2686d30ea906Sjfb8856606  * RTE_FLOW_ACTION_TYPE_SET_IPV6_SRC
2687d30ea906Sjfb8856606  * RTE_FLOW_ACTION_TYPE_SET_IPV6_DST
2688d30ea906Sjfb8856606  *
2689d30ea906Sjfb8856606  * Allows modification of IPv6 source (RTE_FLOW_ACTION_TYPE_SET_IPV6_SRC)
2690d30ea906Sjfb8856606  * and destination address (RTE_FLOW_ACTION_TYPE_SET_IPV6_DST) in the
2691d30ea906Sjfb8856606  * specified outermost IPv6 header.
2692d30ea906Sjfb8856606  */
2693d30ea906Sjfb8856606 struct rte_flow_action_set_ipv6 {
2694d30ea906Sjfb8856606 	uint8_t ipv6_addr[16];
2695d30ea906Sjfb8856606 };
2696d30ea906Sjfb8856606 
2697d30ea906Sjfb8856606 /**
2698d30ea906Sjfb8856606  * @warning
2699d30ea906Sjfb8856606  * @b EXPERIMENTAL: this structure may change without prior notice
2700d30ea906Sjfb8856606  *
2701d30ea906Sjfb8856606  * RTE_FLOW_ACTION_TYPE_SET_TP_SRC
2702d30ea906Sjfb8856606  * RTE_FLOW_ACTION_TYPE_SET_TP_DST
2703d30ea906Sjfb8856606  *
2704d30ea906Sjfb8856606  * Allows modification of source (RTE_FLOW_ACTION_TYPE_SET_TP_SRC)
2705d30ea906Sjfb8856606  * and destination (RTE_FLOW_ACTION_TYPE_SET_TP_DST) port numbers
2706d30ea906Sjfb8856606  * in the specified outermost TCP/UDP header.
2707d30ea906Sjfb8856606  */
2708d30ea906Sjfb8856606 struct rte_flow_action_set_tp {
2709d30ea906Sjfb8856606 	rte_be16_t port;
2710d30ea906Sjfb8856606 };
2711d30ea906Sjfb8856606 
2712d30ea906Sjfb8856606 /**
2713d30ea906Sjfb8856606  * RTE_FLOW_ACTION_TYPE_SET_TTL
2714d30ea906Sjfb8856606  *
2715d30ea906Sjfb8856606  * Set the TTL value directly for IPv4 or IPv6
2716d30ea906Sjfb8856606  */
2717d30ea906Sjfb8856606 struct rte_flow_action_set_ttl {
2718d30ea906Sjfb8856606 	uint8_t ttl_value;
2719d30ea906Sjfb8856606 };
2720d30ea906Sjfb8856606 
2721d30ea906Sjfb8856606 /**
2722d30ea906Sjfb8856606  * RTE_FLOW_ACTION_TYPE_SET_MAC
2723d30ea906Sjfb8856606  *
2724d30ea906Sjfb8856606  * Set MAC address from the matched flow
2725d30ea906Sjfb8856606  */
2726d30ea906Sjfb8856606 struct rte_flow_action_set_mac {
27274418919fSjohnjiang 	uint8_t mac_addr[RTE_ETHER_ADDR_LEN];
2728d30ea906Sjfb8856606 };
2729d30ea906Sjfb8856606 
27304418919fSjohnjiang /**
27314418919fSjohnjiang  * @warning
27324418919fSjohnjiang  * @b EXPERIMENTAL: this structure may change without prior notice
27334418919fSjohnjiang  *
27344418919fSjohnjiang  * RTE_FLOW_ACTION_TYPE_SET_TAG
27354418919fSjohnjiang  *
27364418919fSjohnjiang  * Set a tag which is a transient data used during flow matching. This is not
27374418919fSjohnjiang  * delivered to application. Multiple tags are supported by specifying index.
27384418919fSjohnjiang  */
27394418919fSjohnjiang struct rte_flow_action_set_tag {
27404418919fSjohnjiang 	uint32_t data;
27414418919fSjohnjiang 	uint32_t mask;
27424418919fSjohnjiang 	uint8_t index;
27434418919fSjohnjiang };
27444418919fSjohnjiang 
27454418919fSjohnjiang /**
27464418919fSjohnjiang  * @warning
27474418919fSjohnjiang  * @b EXPERIMENTAL: this structure may change without prior notice
27484418919fSjohnjiang  *
27494418919fSjohnjiang  * RTE_FLOW_ACTION_TYPE_SET_META
27504418919fSjohnjiang  *
27514418919fSjohnjiang  * Set metadata. Metadata set by mbuf metadata dynamic field with
27524418919fSjohnjiang  * PKT_TX_DYNF_DATA flag on egress will be overridden by this action. On
27534418919fSjohnjiang  * ingress, the metadata will be carried by mbuf metadata dynamic field
27544418919fSjohnjiang  * with PKT_RX_DYNF_METADATA flag if set.  The dynamic mbuf field must be
27554418919fSjohnjiang  * registered in advance by rte_flow_dynf_metadata_register().
27564418919fSjohnjiang  *
27574418919fSjohnjiang  * Altering partial bits is supported with mask. For bits which have never
27584418919fSjohnjiang  * been set, unpredictable value will be seen depending on driver
27594418919fSjohnjiang  * implementation. For loopback/hairpin packet, metadata set on Rx/Tx may
27604418919fSjohnjiang  * or may not be propagated to the other path depending on HW capability.
27614418919fSjohnjiang  *
27624418919fSjohnjiang  * RTE_FLOW_ITEM_TYPE_META matches metadata.
27634418919fSjohnjiang  */
27644418919fSjohnjiang struct rte_flow_action_set_meta {
27654418919fSjohnjiang 	uint32_t data;
27664418919fSjohnjiang 	uint32_t mask;
27674418919fSjohnjiang };
27684418919fSjohnjiang 
2769*2d9fd380Sjfb8856606 /**
2770*2d9fd380Sjfb8856606  * RTE_FLOW_ACTION_TYPE_SET_IPV4_DSCP
2771*2d9fd380Sjfb8856606  * RTE_FLOW_ACTION_TYPE_SET_IPV6_DSCP
2772*2d9fd380Sjfb8856606  *
2773*2d9fd380Sjfb8856606  * Set the DSCP value for IPv4/IPv6 header.
2774*2d9fd380Sjfb8856606  * DSCP in low 6 bits, rest ignored.
2775*2d9fd380Sjfb8856606  */
2776*2d9fd380Sjfb8856606 struct rte_flow_action_set_dscp {
2777*2d9fd380Sjfb8856606 	uint8_t dscp;
2778*2d9fd380Sjfb8856606 };
2779*2d9fd380Sjfb8856606 
2780*2d9fd380Sjfb8856606 
2781*2d9fd380Sjfb8856606 /**
2782*2d9fd380Sjfb8856606  * RTE_FLOW_ACTION_TYPE_SHARED
2783*2d9fd380Sjfb8856606  *
2784*2d9fd380Sjfb8856606  * Opaque type returned after successfully creating a shared action.
2785*2d9fd380Sjfb8856606  *
2786*2d9fd380Sjfb8856606  * This handle can be used to manage and query the related action:
2787*2d9fd380Sjfb8856606  * - share it across multiple flow rules
2788*2d9fd380Sjfb8856606  * - update action configuration
2789*2d9fd380Sjfb8856606  * - query action data
2790*2d9fd380Sjfb8856606  * - destroy action
2791*2d9fd380Sjfb8856606  */
2792*2d9fd380Sjfb8856606 struct rte_flow_shared_action;
2793*2d9fd380Sjfb8856606 
27944418919fSjohnjiang /* Mbuf dynamic field offset for metadata. */
27950c6bd470Sfengbojiang extern int32_t rte_flow_dynf_metadata_offs;
27964418919fSjohnjiang 
27974418919fSjohnjiang /* Mbuf dynamic field flag mask for metadata. */
27984418919fSjohnjiang extern uint64_t rte_flow_dynf_metadata_mask;
27994418919fSjohnjiang 
28004418919fSjohnjiang /* Mbuf dynamic field pointer for metadata. */
28014418919fSjohnjiang #define RTE_FLOW_DYNF_METADATA(m) \
28024418919fSjohnjiang 	RTE_MBUF_DYNFIELD((m), rte_flow_dynf_metadata_offs, uint32_t *)
28034418919fSjohnjiang 
28044418919fSjohnjiang /* Mbuf dynamic flags for metadata. */
28054418919fSjohnjiang #define PKT_RX_DYNF_METADATA (rte_flow_dynf_metadata_mask)
28064418919fSjohnjiang #define PKT_TX_DYNF_METADATA (rte_flow_dynf_metadata_mask)
28074418919fSjohnjiang 
28084418919fSjohnjiang __rte_experimental
28094418919fSjohnjiang static inline uint32_t
rte_flow_dynf_metadata_get(struct rte_mbuf * m)28104418919fSjohnjiang rte_flow_dynf_metadata_get(struct rte_mbuf *m)
28114418919fSjohnjiang {
28124418919fSjohnjiang 	return *RTE_FLOW_DYNF_METADATA(m);
28134418919fSjohnjiang }
28144418919fSjohnjiang 
28154418919fSjohnjiang __rte_experimental
28164418919fSjohnjiang static inline void
rte_flow_dynf_metadata_set(struct rte_mbuf * m,uint32_t v)28174418919fSjohnjiang rte_flow_dynf_metadata_set(struct rte_mbuf *m, uint32_t v)
28184418919fSjohnjiang {
28194418919fSjohnjiang 	*RTE_FLOW_DYNF_METADATA(m) = v;
28204418919fSjohnjiang }
28214418919fSjohnjiang 
2822d30ea906Sjfb8856606 /*
2823d30ea906Sjfb8856606  * Definition of a single action.
2824d30ea906Sjfb8856606  *
2825d30ea906Sjfb8856606  * A list of actions is terminated by a END action.
2826d30ea906Sjfb8856606  *
28274418919fSjohnjiang  * For simple actions without a configuration object, conf remains NULL.
2828d30ea906Sjfb8856606  */
2829d30ea906Sjfb8856606 struct rte_flow_action {
2830d30ea906Sjfb8856606 	enum rte_flow_action_type type; /**< Action type. */
28314418919fSjohnjiang 	const void *conf; /**< Pointer to action configuration object. */
2832d30ea906Sjfb8856606 };
2833d30ea906Sjfb8856606 
2834d30ea906Sjfb8856606 /**
2835d30ea906Sjfb8856606  * Opaque type returned after successfully creating a flow.
2836d30ea906Sjfb8856606  *
2837d30ea906Sjfb8856606  * This handle can be used to manage and query the related flow (e.g. to
2838d30ea906Sjfb8856606  * destroy it or retrieve counters).
2839d30ea906Sjfb8856606  */
2840d30ea906Sjfb8856606 struct rte_flow;
2841d30ea906Sjfb8856606 
2842d30ea906Sjfb8856606 /**
2843*2d9fd380Sjfb8856606  * @warning
2844*2d9fd380Sjfb8856606  * @b EXPERIMENTAL: this structure may change without prior notice
2845*2d9fd380Sjfb8856606  *
2846*2d9fd380Sjfb8856606  * RTE_FLOW_ACTION_TYPE_SAMPLE
2847*2d9fd380Sjfb8856606  *
2848*2d9fd380Sjfb8856606  * Adds a sample action to a matched flow.
2849*2d9fd380Sjfb8856606  *
2850*2d9fd380Sjfb8856606  * The matching packets will be duplicated with specified ratio and applied
2851*2d9fd380Sjfb8856606  * with own set of actions with a fate action, the sampled packet could be
2852*2d9fd380Sjfb8856606  * redirected to queue or port. All the packets continue processing on the
2853*2d9fd380Sjfb8856606  * default flow path.
2854*2d9fd380Sjfb8856606  *
2855*2d9fd380Sjfb8856606  * When the sample ratio is set to 1 then the packets will be 100% mirrored.
2856*2d9fd380Sjfb8856606  * Additional action list be supported to add for sampled or mirrored packets.
2857*2d9fd380Sjfb8856606  */
2858*2d9fd380Sjfb8856606 struct rte_flow_action_sample {
2859*2d9fd380Sjfb8856606 	uint32_t ratio; /**< packets sampled equals to '1/ratio'. */
2860*2d9fd380Sjfb8856606 	const struct rte_flow_action *actions;
2861*2d9fd380Sjfb8856606 		/**< sub-action list specific for the sampling hit cases. */
2862*2d9fd380Sjfb8856606 };
2863*2d9fd380Sjfb8856606 
2864*2d9fd380Sjfb8856606 /**
2865d30ea906Sjfb8856606  * Verbose error types.
2866d30ea906Sjfb8856606  *
2867d30ea906Sjfb8856606  * Most of them provide the type of the object referenced by struct
2868d30ea906Sjfb8856606  * rte_flow_error.cause.
2869d30ea906Sjfb8856606  */
2870d30ea906Sjfb8856606 enum rte_flow_error_type {
2871d30ea906Sjfb8856606 	RTE_FLOW_ERROR_TYPE_NONE, /**< No error. */
2872d30ea906Sjfb8856606 	RTE_FLOW_ERROR_TYPE_UNSPECIFIED, /**< Cause unspecified. */
2873d30ea906Sjfb8856606 	RTE_FLOW_ERROR_TYPE_HANDLE, /**< Flow rule (handle). */
2874d30ea906Sjfb8856606 	RTE_FLOW_ERROR_TYPE_ATTR_GROUP, /**< Group field. */
2875d30ea906Sjfb8856606 	RTE_FLOW_ERROR_TYPE_ATTR_PRIORITY, /**< Priority field. */
2876d30ea906Sjfb8856606 	RTE_FLOW_ERROR_TYPE_ATTR_INGRESS, /**< Ingress field. */
2877d30ea906Sjfb8856606 	RTE_FLOW_ERROR_TYPE_ATTR_EGRESS, /**< Egress field. */
2878d30ea906Sjfb8856606 	RTE_FLOW_ERROR_TYPE_ATTR_TRANSFER, /**< Transfer field. */
2879d30ea906Sjfb8856606 	RTE_FLOW_ERROR_TYPE_ATTR, /**< Attributes structure. */
2880d30ea906Sjfb8856606 	RTE_FLOW_ERROR_TYPE_ITEM_NUM, /**< Pattern length. */
2881d30ea906Sjfb8856606 	RTE_FLOW_ERROR_TYPE_ITEM_SPEC, /**< Item specification. */
2882d30ea906Sjfb8856606 	RTE_FLOW_ERROR_TYPE_ITEM_LAST, /**< Item specification range. */
2883d30ea906Sjfb8856606 	RTE_FLOW_ERROR_TYPE_ITEM_MASK, /**< Item specification mask. */
2884d30ea906Sjfb8856606 	RTE_FLOW_ERROR_TYPE_ITEM, /**< Specific pattern item. */
2885d30ea906Sjfb8856606 	RTE_FLOW_ERROR_TYPE_ACTION_NUM, /**< Number of actions. */
2886d30ea906Sjfb8856606 	RTE_FLOW_ERROR_TYPE_ACTION_CONF, /**< Action configuration. */
2887d30ea906Sjfb8856606 	RTE_FLOW_ERROR_TYPE_ACTION, /**< Specific action. */
2888d30ea906Sjfb8856606 };
2889d30ea906Sjfb8856606 
2890d30ea906Sjfb8856606 /**
2891d30ea906Sjfb8856606  * Verbose error structure definition.
2892d30ea906Sjfb8856606  *
2893d30ea906Sjfb8856606  * This object is normally allocated by applications and set by PMDs, the
2894d30ea906Sjfb8856606  * message points to a constant string which does not need to be freed by
2895d30ea906Sjfb8856606  * the application, however its pointer can be considered valid only as long
2896d30ea906Sjfb8856606  * as its associated DPDK port remains configured. Closing the underlying
2897d30ea906Sjfb8856606  * device or unloading the PMD invalidates it.
2898d30ea906Sjfb8856606  *
2899d30ea906Sjfb8856606  * Both cause and message may be NULL regardless of the error type.
2900d30ea906Sjfb8856606  */
2901d30ea906Sjfb8856606 struct rte_flow_error {
2902d30ea906Sjfb8856606 	enum rte_flow_error_type type; /**< Cause field and error types. */
2903d30ea906Sjfb8856606 	const void *cause; /**< Object responsible for the error. */
2904d30ea906Sjfb8856606 	const char *message; /**< Human-readable error message. */
2905d30ea906Sjfb8856606 };
2906d30ea906Sjfb8856606 
2907d30ea906Sjfb8856606 /**
2908d30ea906Sjfb8856606  * Complete flow rule description.
2909d30ea906Sjfb8856606  *
2910d30ea906Sjfb8856606  * This object type is used when converting a flow rule description.
2911d30ea906Sjfb8856606  *
2912d30ea906Sjfb8856606  * @see RTE_FLOW_CONV_OP_RULE
2913d30ea906Sjfb8856606  * @see rte_flow_conv()
2914d30ea906Sjfb8856606  */
2915d30ea906Sjfb8856606 RTE_STD_C11
2916d30ea906Sjfb8856606 struct rte_flow_conv_rule {
2917d30ea906Sjfb8856606 	union {
2918d30ea906Sjfb8856606 		const struct rte_flow_attr *attr_ro; /**< RO attributes. */
2919d30ea906Sjfb8856606 		struct rte_flow_attr *attr; /**< Attributes. */
2920d30ea906Sjfb8856606 	};
2921d30ea906Sjfb8856606 	union {
2922d30ea906Sjfb8856606 		const struct rte_flow_item *pattern_ro; /**< RO pattern. */
2923d30ea906Sjfb8856606 		struct rte_flow_item *pattern; /**< Pattern items. */
2924d30ea906Sjfb8856606 	};
2925d30ea906Sjfb8856606 	union {
2926d30ea906Sjfb8856606 		const struct rte_flow_action *actions_ro; /**< RO actions. */
2927d30ea906Sjfb8856606 		struct rte_flow_action *actions; /**< List of actions. */
2928d30ea906Sjfb8856606 	};
2929d30ea906Sjfb8856606 };
2930d30ea906Sjfb8856606 
2931d30ea906Sjfb8856606 /**
2932d30ea906Sjfb8856606  * Conversion operations for flow API objects.
2933d30ea906Sjfb8856606  *
2934d30ea906Sjfb8856606  * @see rte_flow_conv()
2935d30ea906Sjfb8856606  */
2936d30ea906Sjfb8856606 enum rte_flow_conv_op {
2937d30ea906Sjfb8856606 	/**
2938d30ea906Sjfb8856606 	 * No operation to perform.
2939d30ea906Sjfb8856606 	 *
2940d30ea906Sjfb8856606 	 * rte_flow_conv() simply returns 0.
2941d30ea906Sjfb8856606 	 */
2942d30ea906Sjfb8856606 	RTE_FLOW_CONV_OP_NONE,
2943d30ea906Sjfb8856606 
2944d30ea906Sjfb8856606 	/**
2945d30ea906Sjfb8856606 	 * Convert attributes structure.
2946d30ea906Sjfb8856606 	 *
2947d30ea906Sjfb8856606 	 * This is a basic copy of an attributes structure.
2948d30ea906Sjfb8856606 	 *
2949d30ea906Sjfb8856606 	 * - @p src type:
2950d30ea906Sjfb8856606 	 *   @code const struct rte_flow_attr * @endcode
2951d30ea906Sjfb8856606 	 * - @p dst type:
2952d30ea906Sjfb8856606 	 *   @code struct rte_flow_attr * @endcode
2953d30ea906Sjfb8856606 	 */
2954d30ea906Sjfb8856606 	RTE_FLOW_CONV_OP_ATTR,
2955d30ea906Sjfb8856606 
2956d30ea906Sjfb8856606 	/**
2957d30ea906Sjfb8856606 	 * Convert a single item.
2958d30ea906Sjfb8856606 	 *
2959d30ea906Sjfb8856606 	 * Duplicates @p spec, @p last and @p mask but not outside objects.
2960d30ea906Sjfb8856606 	 *
2961d30ea906Sjfb8856606 	 * - @p src type:
2962d30ea906Sjfb8856606 	 *   @code const struct rte_flow_item * @endcode
2963d30ea906Sjfb8856606 	 * - @p dst type:
2964d30ea906Sjfb8856606 	 *   @code struct rte_flow_item * @endcode
2965d30ea906Sjfb8856606 	 */
2966d30ea906Sjfb8856606 	RTE_FLOW_CONV_OP_ITEM,
2967d30ea906Sjfb8856606 
2968d30ea906Sjfb8856606 	/**
2969d30ea906Sjfb8856606 	 * Convert a single action.
2970d30ea906Sjfb8856606 	 *
2971d30ea906Sjfb8856606 	 * Duplicates @p conf but not outside objects.
2972d30ea906Sjfb8856606 	 *
2973d30ea906Sjfb8856606 	 * - @p src type:
2974d30ea906Sjfb8856606 	 *   @code const struct rte_flow_action * @endcode
2975d30ea906Sjfb8856606 	 * - @p dst type:
2976d30ea906Sjfb8856606 	 *   @code struct rte_flow_action * @endcode
2977d30ea906Sjfb8856606 	 */
2978d30ea906Sjfb8856606 	RTE_FLOW_CONV_OP_ACTION,
2979d30ea906Sjfb8856606 
2980d30ea906Sjfb8856606 	/**
2981d30ea906Sjfb8856606 	 * Convert an entire pattern.
2982d30ea906Sjfb8856606 	 *
2983d30ea906Sjfb8856606 	 * Duplicates all pattern items at once with the same constraints as
2984d30ea906Sjfb8856606 	 * RTE_FLOW_CONV_OP_ITEM.
2985d30ea906Sjfb8856606 	 *
2986d30ea906Sjfb8856606 	 * - @p src type:
2987d30ea906Sjfb8856606 	 *   @code const struct rte_flow_item * @endcode
2988d30ea906Sjfb8856606 	 * - @p dst type:
2989d30ea906Sjfb8856606 	 *   @code struct rte_flow_item * @endcode
2990d30ea906Sjfb8856606 	 */
2991d30ea906Sjfb8856606 	RTE_FLOW_CONV_OP_PATTERN,
2992d30ea906Sjfb8856606 
2993d30ea906Sjfb8856606 	/**
2994d30ea906Sjfb8856606 	 * Convert a list of actions.
2995d30ea906Sjfb8856606 	 *
2996d30ea906Sjfb8856606 	 * Duplicates the entire list of actions at once with the same
2997d30ea906Sjfb8856606 	 * constraints as RTE_FLOW_CONV_OP_ACTION.
2998d30ea906Sjfb8856606 	 *
2999d30ea906Sjfb8856606 	 * - @p src type:
3000d30ea906Sjfb8856606 	 *   @code const struct rte_flow_action * @endcode
3001d30ea906Sjfb8856606 	 * - @p dst type:
3002d30ea906Sjfb8856606 	 *   @code struct rte_flow_action * @endcode
3003d30ea906Sjfb8856606 	 */
3004d30ea906Sjfb8856606 	RTE_FLOW_CONV_OP_ACTIONS,
3005d30ea906Sjfb8856606 
3006d30ea906Sjfb8856606 	/**
3007d30ea906Sjfb8856606 	 * Convert a complete flow rule description.
3008d30ea906Sjfb8856606 	 *
3009d30ea906Sjfb8856606 	 * Comprises attributes, pattern and actions together at once with
3010d30ea906Sjfb8856606 	 * the usual constraints.
3011d30ea906Sjfb8856606 	 *
3012d30ea906Sjfb8856606 	 * - @p src type:
3013d30ea906Sjfb8856606 	 *   @code const struct rte_flow_conv_rule * @endcode
3014d30ea906Sjfb8856606 	 * - @p dst type:
3015d30ea906Sjfb8856606 	 *   @code struct rte_flow_conv_rule * @endcode
3016d30ea906Sjfb8856606 	 */
3017d30ea906Sjfb8856606 	RTE_FLOW_CONV_OP_RULE,
3018d30ea906Sjfb8856606 
3019d30ea906Sjfb8856606 	/**
3020d30ea906Sjfb8856606 	 * Convert item type to its name string.
3021d30ea906Sjfb8856606 	 *
3022d30ea906Sjfb8856606 	 * Writes a NUL-terminated string to @p dst. Like snprintf(), the
3023d30ea906Sjfb8856606 	 * returned value excludes the terminator which is always written
3024d30ea906Sjfb8856606 	 * nonetheless.
3025d30ea906Sjfb8856606 	 *
3026d30ea906Sjfb8856606 	 * - @p src type:
3027d30ea906Sjfb8856606 	 *   @code (const void *)enum rte_flow_item_type @endcode
3028d30ea906Sjfb8856606 	 * - @p dst type:
3029d30ea906Sjfb8856606 	 *   @code char * @endcode
3030d30ea906Sjfb8856606 	 **/
3031d30ea906Sjfb8856606 	RTE_FLOW_CONV_OP_ITEM_NAME,
3032d30ea906Sjfb8856606 
3033d30ea906Sjfb8856606 	/**
3034d30ea906Sjfb8856606 	 * Convert action type to its name string.
3035d30ea906Sjfb8856606 	 *
3036d30ea906Sjfb8856606 	 * Writes a NUL-terminated string to @p dst. Like snprintf(), the
3037d30ea906Sjfb8856606 	 * returned value excludes the terminator which is always written
3038d30ea906Sjfb8856606 	 * nonetheless.
3039d30ea906Sjfb8856606 	 *
3040d30ea906Sjfb8856606 	 * - @p src type:
3041d30ea906Sjfb8856606 	 *   @code (const void *)enum rte_flow_action_type @endcode
3042d30ea906Sjfb8856606 	 * - @p dst type:
3043d30ea906Sjfb8856606 	 *   @code char * @endcode
3044d30ea906Sjfb8856606 	 **/
3045d30ea906Sjfb8856606 	RTE_FLOW_CONV_OP_ACTION_NAME,
3046d30ea906Sjfb8856606 
3047d30ea906Sjfb8856606 	/**
3048d30ea906Sjfb8856606 	 * Convert item type to pointer to item name.
3049d30ea906Sjfb8856606 	 *
3050d30ea906Sjfb8856606 	 * Retrieves item name pointer from its type. The string itself is
3051d30ea906Sjfb8856606 	 * not copied; instead, a unique pointer to an internal static
3052d30ea906Sjfb8856606 	 * constant storage is written to @p dst.
3053d30ea906Sjfb8856606 	 *
3054d30ea906Sjfb8856606 	 * - @p src type:
3055d30ea906Sjfb8856606 	 *   @code (const void *)enum rte_flow_item_type @endcode
3056d30ea906Sjfb8856606 	 * - @p dst type:
3057d30ea906Sjfb8856606 	 *   @code const char ** @endcode
3058d30ea906Sjfb8856606 	 */
3059d30ea906Sjfb8856606 	RTE_FLOW_CONV_OP_ITEM_NAME_PTR,
3060d30ea906Sjfb8856606 
3061d30ea906Sjfb8856606 	/**
3062d30ea906Sjfb8856606 	 * Convert action type to pointer to action name.
3063d30ea906Sjfb8856606 	 *
3064d30ea906Sjfb8856606 	 * Retrieves action name pointer from its type. The string itself is
3065d30ea906Sjfb8856606 	 * not copied; instead, a unique pointer to an internal static
3066d30ea906Sjfb8856606 	 * constant storage is written to @p dst.
3067d30ea906Sjfb8856606 	 *
3068d30ea906Sjfb8856606 	 * - @p src type:
3069d30ea906Sjfb8856606 	 *   @code (const void *)enum rte_flow_action_type @endcode
3070d30ea906Sjfb8856606 	 * - @p dst type:
3071d30ea906Sjfb8856606 	 *   @code const char ** @endcode
3072d30ea906Sjfb8856606 	 */
3073d30ea906Sjfb8856606 	RTE_FLOW_CONV_OP_ACTION_NAME_PTR,
3074d30ea906Sjfb8856606 };
3075d30ea906Sjfb8856606 
3076d30ea906Sjfb8856606 /**
3077*2d9fd380Sjfb8856606  * @warning
3078*2d9fd380Sjfb8856606  * @b EXPERIMENTAL: this API may change without prior notice.
3079*2d9fd380Sjfb8856606  *
3080*2d9fd380Sjfb8856606  * Dump hardware internal representation information of
3081*2d9fd380Sjfb8856606  * rte flow to file.
3082*2d9fd380Sjfb8856606  *
3083*2d9fd380Sjfb8856606  * @param[in] port_id
3084*2d9fd380Sjfb8856606  *    The port identifier of the Ethernet device.
3085*2d9fd380Sjfb8856606  * @param[in] file
3086*2d9fd380Sjfb8856606  *   A pointer to a file for output.
3087*2d9fd380Sjfb8856606  * @param[out] error
3088*2d9fd380Sjfb8856606  *   Perform verbose error reporting if not NULL. PMDs initialize this
3089*2d9fd380Sjfb8856606  *   structure in case of error only.
3090*2d9fd380Sjfb8856606  * @return
3091*2d9fd380Sjfb8856606  *   0 on success, a nagative value otherwise.
3092*2d9fd380Sjfb8856606  */
3093*2d9fd380Sjfb8856606 __rte_experimental
3094*2d9fd380Sjfb8856606 int
3095*2d9fd380Sjfb8856606 rte_flow_dev_dump(uint16_t port_id, FILE *file, struct rte_flow_error *error);
3096*2d9fd380Sjfb8856606 
3097*2d9fd380Sjfb8856606 /**
30984418919fSjohnjiang  * Check if mbuf dynamic field for metadata is registered.
30994418919fSjohnjiang  *
31004418919fSjohnjiang  * @return
31014418919fSjohnjiang  *   True if registered, false otherwise.
31024418919fSjohnjiang  */
31034418919fSjohnjiang __rte_experimental
31044418919fSjohnjiang static inline int
rte_flow_dynf_metadata_avail(void)31054418919fSjohnjiang rte_flow_dynf_metadata_avail(void)
31064418919fSjohnjiang {
31074418919fSjohnjiang 	return !!rte_flow_dynf_metadata_mask;
31084418919fSjohnjiang }
31094418919fSjohnjiang 
31104418919fSjohnjiang /**
31114418919fSjohnjiang  * Register mbuf dynamic field and flag for metadata.
31124418919fSjohnjiang  *
31134418919fSjohnjiang  * This function must be called prior to use SET_META action in order to
31144418919fSjohnjiang  * register the dynamic mbuf field. Otherwise, the data cannot be delivered to
31154418919fSjohnjiang  * application.
31164418919fSjohnjiang  *
31174418919fSjohnjiang  * @return
31184418919fSjohnjiang  *   0 on success, a negative errno value otherwise and rte_errno is set.
31194418919fSjohnjiang  */
31204418919fSjohnjiang __rte_experimental
31214418919fSjohnjiang int
31224418919fSjohnjiang rte_flow_dynf_metadata_register(void);
31234418919fSjohnjiang 
31244418919fSjohnjiang /**
3125d30ea906Sjfb8856606  * Check whether a flow rule can be created on a given port.
3126d30ea906Sjfb8856606  *
3127d30ea906Sjfb8856606  * The flow rule is validated for correctness and whether it could be accepted
3128d30ea906Sjfb8856606  * by the device given sufficient resources. The rule is checked against the
3129d30ea906Sjfb8856606  * current device mode and queue configuration. The flow rule may also
3130d30ea906Sjfb8856606  * optionally be validated against existing flow rules and device resources.
3131d30ea906Sjfb8856606  * This function has no effect on the target device.
3132d30ea906Sjfb8856606  *
3133d30ea906Sjfb8856606  * The returned value is guaranteed to remain valid only as long as no
3134d30ea906Sjfb8856606  * successful calls to rte_flow_create() or rte_flow_destroy() are made in
3135d30ea906Sjfb8856606  * the meantime and no device parameter affecting flow rules in any way are
3136d30ea906Sjfb8856606  * modified, due to possible collisions or resource limitations (although in
3137d30ea906Sjfb8856606  * such cases EINVAL should not be returned).
3138d30ea906Sjfb8856606  *
3139d30ea906Sjfb8856606  * @param port_id
3140d30ea906Sjfb8856606  *   Port identifier of Ethernet device.
3141d30ea906Sjfb8856606  * @param[in] attr
3142d30ea906Sjfb8856606  *   Flow rule attributes.
3143d30ea906Sjfb8856606  * @param[in] pattern
3144d30ea906Sjfb8856606  *   Pattern specification (list terminated by the END pattern item).
3145d30ea906Sjfb8856606  * @param[in] actions
3146d30ea906Sjfb8856606  *   Associated actions (list terminated by the END action).
3147d30ea906Sjfb8856606  * @param[out] error
3148d30ea906Sjfb8856606  *   Perform verbose error reporting if not NULL. PMDs initialize this
3149d30ea906Sjfb8856606  *   structure in case of error only.
3150d30ea906Sjfb8856606  *
3151d30ea906Sjfb8856606  * @return
3152d30ea906Sjfb8856606  *   0 if flow rule is valid and can be created. A negative errno value
3153d30ea906Sjfb8856606  *   otherwise (rte_errno is also set), the following errors are defined:
3154d30ea906Sjfb8856606  *
3155d30ea906Sjfb8856606  *   -ENOSYS: underlying device does not support this functionality.
3156d30ea906Sjfb8856606  *
3157d30ea906Sjfb8856606  *   -EIO: underlying device is removed.
3158d30ea906Sjfb8856606  *
3159d30ea906Sjfb8856606  *   -EINVAL: unknown or invalid rule specification.
3160d30ea906Sjfb8856606  *
3161d30ea906Sjfb8856606  *   -ENOTSUP: valid but unsupported rule specification (e.g. partial
3162d30ea906Sjfb8856606  *   bit-masks are unsupported).
3163d30ea906Sjfb8856606  *
3164d30ea906Sjfb8856606  *   -EEXIST: collision with an existing rule. Only returned if device
3165d30ea906Sjfb8856606  *   supports flow rule collision checking and there was a flow rule
3166d30ea906Sjfb8856606  *   collision. Not receiving this return code is no guarantee that creating
3167d30ea906Sjfb8856606  *   the rule will not fail due to a collision.
3168d30ea906Sjfb8856606  *
3169d30ea906Sjfb8856606  *   -ENOMEM: not enough memory to execute the function, or if the device
3170d30ea906Sjfb8856606  *   supports resource validation, resource limitation on the device.
3171d30ea906Sjfb8856606  *
3172d30ea906Sjfb8856606  *   -EBUSY: action cannot be performed due to busy device resources, may
3173d30ea906Sjfb8856606  *   succeed if the affected queues or even the entire port are in a stopped
3174d30ea906Sjfb8856606  *   state (see rte_eth_dev_rx_queue_stop() and rte_eth_dev_stop()).
3175d30ea906Sjfb8856606  */
3176d30ea906Sjfb8856606 int
3177d30ea906Sjfb8856606 rte_flow_validate(uint16_t port_id,
3178d30ea906Sjfb8856606 		  const struct rte_flow_attr *attr,
3179d30ea906Sjfb8856606 		  const struct rte_flow_item pattern[],
3180d30ea906Sjfb8856606 		  const struct rte_flow_action actions[],
3181d30ea906Sjfb8856606 		  struct rte_flow_error *error);
3182d30ea906Sjfb8856606 
3183d30ea906Sjfb8856606 /**
3184d30ea906Sjfb8856606  * Create a flow rule on a given port.
3185d30ea906Sjfb8856606  *
3186d30ea906Sjfb8856606  * @param port_id
3187d30ea906Sjfb8856606  *   Port identifier of Ethernet device.
3188d30ea906Sjfb8856606  * @param[in] attr
3189d30ea906Sjfb8856606  *   Flow rule attributes.
3190d30ea906Sjfb8856606  * @param[in] pattern
3191d30ea906Sjfb8856606  *   Pattern specification (list terminated by the END pattern item).
3192d30ea906Sjfb8856606  * @param[in] actions
3193d30ea906Sjfb8856606  *   Associated actions (list terminated by the END action).
3194d30ea906Sjfb8856606  * @param[out] error
3195d30ea906Sjfb8856606  *   Perform verbose error reporting if not NULL. PMDs initialize this
3196d30ea906Sjfb8856606  *   structure in case of error only.
3197d30ea906Sjfb8856606  *
3198d30ea906Sjfb8856606  * @return
3199d30ea906Sjfb8856606  *   A valid handle in case of success, NULL otherwise and rte_errno is set
3200d30ea906Sjfb8856606  *   to the positive version of one of the error codes defined for
3201d30ea906Sjfb8856606  *   rte_flow_validate().
3202d30ea906Sjfb8856606  */
3203d30ea906Sjfb8856606 struct rte_flow *
3204d30ea906Sjfb8856606 rte_flow_create(uint16_t port_id,
3205d30ea906Sjfb8856606 		const struct rte_flow_attr *attr,
3206d30ea906Sjfb8856606 		const struct rte_flow_item pattern[],
3207d30ea906Sjfb8856606 		const struct rte_flow_action actions[],
3208d30ea906Sjfb8856606 		struct rte_flow_error *error);
3209d30ea906Sjfb8856606 
3210d30ea906Sjfb8856606 /**
3211d30ea906Sjfb8856606  * Destroy a flow rule on a given port.
3212d30ea906Sjfb8856606  *
3213d30ea906Sjfb8856606  * Failure to destroy a flow rule handle may occur when other flow rules
3214d30ea906Sjfb8856606  * depend on it, and destroying it would result in an inconsistent state.
3215d30ea906Sjfb8856606  *
3216d30ea906Sjfb8856606  * This function is only guaranteed to succeed if handles are destroyed in
3217d30ea906Sjfb8856606  * reverse order of their creation.
3218d30ea906Sjfb8856606  *
3219d30ea906Sjfb8856606  * @param port_id
3220d30ea906Sjfb8856606  *   Port identifier of Ethernet device.
3221d30ea906Sjfb8856606  * @param flow
3222d30ea906Sjfb8856606  *   Flow rule handle to destroy.
3223d30ea906Sjfb8856606  * @param[out] error
3224d30ea906Sjfb8856606  *   Perform verbose error reporting if not NULL. PMDs initialize this
3225d30ea906Sjfb8856606  *   structure in case of error only.
3226d30ea906Sjfb8856606  *
3227d30ea906Sjfb8856606  * @return
3228d30ea906Sjfb8856606  *   0 on success, a negative errno value otherwise and rte_errno is set.
3229d30ea906Sjfb8856606  */
3230d30ea906Sjfb8856606 int
3231d30ea906Sjfb8856606 rte_flow_destroy(uint16_t port_id,
3232d30ea906Sjfb8856606 		 struct rte_flow *flow,
3233d30ea906Sjfb8856606 		 struct rte_flow_error *error);
3234d30ea906Sjfb8856606 
3235d30ea906Sjfb8856606 /**
3236d30ea906Sjfb8856606  * Destroy all flow rules associated with a port.
3237d30ea906Sjfb8856606  *
3238d30ea906Sjfb8856606  * In the unlikely event of failure, handles are still considered destroyed
3239d30ea906Sjfb8856606  * and no longer valid but the port must be assumed to be in an inconsistent
3240d30ea906Sjfb8856606  * state.
3241d30ea906Sjfb8856606  *
3242d30ea906Sjfb8856606  * @param port_id
3243d30ea906Sjfb8856606  *   Port identifier of Ethernet device.
3244d30ea906Sjfb8856606  * @param[out] error
3245d30ea906Sjfb8856606  *   Perform verbose error reporting if not NULL. PMDs initialize this
3246d30ea906Sjfb8856606  *   structure in case of error only.
3247d30ea906Sjfb8856606  *
3248d30ea906Sjfb8856606  * @return
3249d30ea906Sjfb8856606  *   0 on success, a negative errno value otherwise and rte_errno is set.
3250d30ea906Sjfb8856606  */
3251d30ea906Sjfb8856606 int
3252d30ea906Sjfb8856606 rte_flow_flush(uint16_t port_id,
3253d30ea906Sjfb8856606 	       struct rte_flow_error *error);
3254d30ea906Sjfb8856606 
3255d30ea906Sjfb8856606 /**
3256d30ea906Sjfb8856606  * Query an existing flow rule.
3257d30ea906Sjfb8856606  *
3258d30ea906Sjfb8856606  * This function allows retrieving flow-specific data such as counters.
3259d30ea906Sjfb8856606  * Data is gathered by special actions which must be present in the flow
3260d30ea906Sjfb8856606  * rule definition.
3261d30ea906Sjfb8856606  *
3262d30ea906Sjfb8856606  * \see RTE_FLOW_ACTION_TYPE_COUNT
3263d30ea906Sjfb8856606  *
3264d30ea906Sjfb8856606  * @param port_id
3265d30ea906Sjfb8856606  *   Port identifier of Ethernet device.
3266d30ea906Sjfb8856606  * @param flow
3267d30ea906Sjfb8856606  *   Flow rule handle to query.
3268d30ea906Sjfb8856606  * @param action
3269d30ea906Sjfb8856606  *   Action definition as defined in original flow rule.
3270d30ea906Sjfb8856606  * @param[in, out] data
3271d30ea906Sjfb8856606  *   Pointer to storage for the associated query data type.
3272d30ea906Sjfb8856606  * @param[out] error
3273d30ea906Sjfb8856606  *   Perform verbose error reporting if not NULL. PMDs initialize this
3274d30ea906Sjfb8856606  *   structure in case of error only.
3275d30ea906Sjfb8856606  *
3276d30ea906Sjfb8856606  * @return
3277d30ea906Sjfb8856606  *   0 on success, a negative errno value otherwise and rte_errno is set.
3278d30ea906Sjfb8856606  */
3279d30ea906Sjfb8856606 int
3280d30ea906Sjfb8856606 rte_flow_query(uint16_t port_id,
3281d30ea906Sjfb8856606 	       struct rte_flow *flow,
3282d30ea906Sjfb8856606 	       const struct rte_flow_action *action,
3283d30ea906Sjfb8856606 	       void *data,
3284d30ea906Sjfb8856606 	       struct rte_flow_error *error);
3285d30ea906Sjfb8856606 
3286d30ea906Sjfb8856606 /**
3287d30ea906Sjfb8856606  * Restrict ingress traffic to the defined flow rules.
3288d30ea906Sjfb8856606  *
3289d30ea906Sjfb8856606  * Isolated mode guarantees that all ingress traffic comes from defined flow
3290d30ea906Sjfb8856606  * rules only (current and future).
3291d30ea906Sjfb8856606  *
3292d30ea906Sjfb8856606  * Besides making ingress more deterministic, it allows PMDs to safely reuse
3293d30ea906Sjfb8856606  * resources otherwise assigned to handle the remaining traffic, such as
3294d30ea906Sjfb8856606  * global RSS configuration settings, VLAN filters, MAC address entries,
3295d30ea906Sjfb8856606  * legacy filter API rules and so on in order to expand the set of possible
3296d30ea906Sjfb8856606  * flow rule types.
3297d30ea906Sjfb8856606  *
3298d30ea906Sjfb8856606  * Calling this function as soon as possible after device initialization,
3299d30ea906Sjfb8856606  * ideally before the first call to rte_eth_dev_configure(), is recommended
3300d30ea906Sjfb8856606  * to avoid possible failures due to conflicting settings.
3301d30ea906Sjfb8856606  *
3302d30ea906Sjfb8856606  * Once effective, leaving isolated mode may not be possible depending on
3303d30ea906Sjfb8856606  * PMD implementation.
3304d30ea906Sjfb8856606  *
3305d30ea906Sjfb8856606  * Additionally, the following functionality has no effect on the underlying
3306d30ea906Sjfb8856606  * port and may return errors such as ENOTSUP ("not supported"):
3307d30ea906Sjfb8856606  *
3308d30ea906Sjfb8856606  * - Toggling promiscuous mode.
3309d30ea906Sjfb8856606  * - Toggling allmulticast mode.
3310d30ea906Sjfb8856606  * - Configuring MAC addresses.
3311d30ea906Sjfb8856606  * - Configuring multicast addresses.
3312d30ea906Sjfb8856606  * - Configuring VLAN filters.
3313d30ea906Sjfb8856606  * - Configuring Rx filters through the legacy API (e.g. FDIR).
3314d30ea906Sjfb8856606  * - Configuring global RSS settings.
3315d30ea906Sjfb8856606  *
3316d30ea906Sjfb8856606  * @param port_id
3317d30ea906Sjfb8856606  *   Port identifier of Ethernet device.
3318d30ea906Sjfb8856606  * @param set
3319d30ea906Sjfb8856606  *   Nonzero to enter isolated mode, attempt to leave it otherwise.
3320d30ea906Sjfb8856606  * @param[out] error
3321d30ea906Sjfb8856606  *   Perform verbose error reporting if not NULL. PMDs initialize this
3322d30ea906Sjfb8856606  *   structure in case of error only.
3323d30ea906Sjfb8856606  *
3324d30ea906Sjfb8856606  * @return
3325d30ea906Sjfb8856606  *   0 on success, a negative errno value otherwise and rte_errno is set.
3326d30ea906Sjfb8856606  */
3327d30ea906Sjfb8856606 int
3328d30ea906Sjfb8856606 rte_flow_isolate(uint16_t port_id, int set, struct rte_flow_error *error);
3329d30ea906Sjfb8856606 
3330d30ea906Sjfb8856606 /**
3331d30ea906Sjfb8856606  * Initialize flow error structure.
3332d30ea906Sjfb8856606  *
3333d30ea906Sjfb8856606  * @param[out] error
3334d30ea906Sjfb8856606  *   Pointer to flow error structure (may be NULL).
3335d30ea906Sjfb8856606  * @param code
3336d30ea906Sjfb8856606  *   Related error code (rte_errno).
3337d30ea906Sjfb8856606  * @param type
3338d30ea906Sjfb8856606  *   Cause field and error types.
3339d30ea906Sjfb8856606  * @param cause
3340d30ea906Sjfb8856606  *   Object responsible for the error.
3341d30ea906Sjfb8856606  * @param message
3342d30ea906Sjfb8856606  *   Human-readable error message.
3343d30ea906Sjfb8856606  *
3344d30ea906Sjfb8856606  * @return
3345d30ea906Sjfb8856606  *   Negative error code (errno value) and rte_errno is set.
3346d30ea906Sjfb8856606  */
3347d30ea906Sjfb8856606 int
3348d30ea906Sjfb8856606 rte_flow_error_set(struct rte_flow_error *error,
3349d30ea906Sjfb8856606 		   int code,
3350d30ea906Sjfb8856606 		   enum rte_flow_error_type type,
3351d30ea906Sjfb8856606 		   const void *cause,
3352d30ea906Sjfb8856606 		   const char *message);
3353d30ea906Sjfb8856606 
3354d30ea906Sjfb8856606 /**
3355d30ea906Sjfb8856606  * @deprecated
3356d30ea906Sjfb8856606  * @see rte_flow_copy()
3357d30ea906Sjfb8856606  */
3358d30ea906Sjfb8856606 struct rte_flow_desc {
3359d30ea906Sjfb8856606 	size_t size; /**< Allocated space including data[]. */
3360d30ea906Sjfb8856606 	struct rte_flow_attr attr; /**< Attributes. */
3361d30ea906Sjfb8856606 	struct rte_flow_item *items; /**< Items. */
3362d30ea906Sjfb8856606 	struct rte_flow_action *actions; /**< Actions. */
3363d30ea906Sjfb8856606 	uint8_t data[]; /**< Storage for items/actions. */
3364d30ea906Sjfb8856606 };
3365d30ea906Sjfb8856606 
3366d30ea906Sjfb8856606 /**
3367d30ea906Sjfb8856606  * @deprecated
3368d30ea906Sjfb8856606  * Copy an rte_flow rule description.
3369d30ea906Sjfb8856606  *
3370d30ea906Sjfb8856606  * This interface is kept for compatibility with older applications but is
3371d30ea906Sjfb8856606  * implemented as a wrapper to rte_flow_conv(). It is deprecated due to its
3372d30ea906Sjfb8856606  * lack of flexibility and reliance on a type unusable with C++ programs
3373d30ea906Sjfb8856606  * (struct rte_flow_desc).
3374d30ea906Sjfb8856606  *
3375d30ea906Sjfb8856606  * @param[in] fd
3376d30ea906Sjfb8856606  *   Flow rule description.
3377d30ea906Sjfb8856606  * @param[in] len
3378d30ea906Sjfb8856606  *   Total size of allocated data for the flow description.
3379d30ea906Sjfb8856606  * @param[in] attr
3380d30ea906Sjfb8856606  *   Flow rule attributes.
3381d30ea906Sjfb8856606  * @param[in] items
3382d30ea906Sjfb8856606  *   Pattern specification (list terminated by the END pattern item).
3383d30ea906Sjfb8856606  * @param[in] actions
3384d30ea906Sjfb8856606  *   Associated actions (list terminated by the END action).
3385d30ea906Sjfb8856606  *
3386d30ea906Sjfb8856606  * @return
3387d30ea906Sjfb8856606  *   If len is greater or equal to the size of the flow, the total size of the
3388d30ea906Sjfb8856606  *   flow description and its data.
3389d30ea906Sjfb8856606  *   If len is lower than the size of the flow, the number of bytes that would
3390d30ea906Sjfb8856606  *   have been written to desc had it been sufficient. Nothing is written.
3391d30ea906Sjfb8856606  */
3392d30ea906Sjfb8856606 __rte_deprecated
3393d30ea906Sjfb8856606 size_t
3394d30ea906Sjfb8856606 rte_flow_copy(struct rte_flow_desc *fd, size_t len,
3395d30ea906Sjfb8856606 	      const struct rte_flow_attr *attr,
3396d30ea906Sjfb8856606 	      const struct rte_flow_item *items,
3397d30ea906Sjfb8856606 	      const struct rte_flow_action *actions);
3398d30ea906Sjfb8856606 
3399d30ea906Sjfb8856606 /**
3400d30ea906Sjfb8856606  * Flow object conversion helper.
3401d30ea906Sjfb8856606  *
3402d30ea906Sjfb8856606  * This function performs conversion of various flow API objects to a
3403d30ea906Sjfb8856606  * pre-allocated destination buffer. See enum rte_flow_conv_op for possible
3404d30ea906Sjfb8856606  * operations and details about each of them.
3405d30ea906Sjfb8856606  *
3406d30ea906Sjfb8856606  * Since destination buffer must be large enough, it works in a manner
3407d30ea906Sjfb8856606  * reminiscent of snprintf():
3408d30ea906Sjfb8856606  *
3409d30ea906Sjfb8856606  * - If @p size is 0, @p dst may be a NULL pointer, otherwise @p dst must be
3410d30ea906Sjfb8856606  *   non-NULL.
3411d30ea906Sjfb8856606  * - If positive, the returned value represents the number of bytes needed
3412d30ea906Sjfb8856606  *   to store the conversion of @p src to @p dst according to @p op
3413d30ea906Sjfb8856606  *   regardless of the @p size parameter.
3414d30ea906Sjfb8856606  * - Since no more than @p size bytes can be written to @p dst, output is
3415d30ea906Sjfb8856606  *   truncated and may be inconsistent when the returned value is larger
3416d30ea906Sjfb8856606  *   than that.
3417d30ea906Sjfb8856606  * - In case of conversion error, a negative error code is returned and
3418d30ea906Sjfb8856606  *   @p dst contents are unspecified.
3419d30ea906Sjfb8856606  *
3420d30ea906Sjfb8856606  * @param op
3421d30ea906Sjfb8856606  *   Operation to perform, related to the object type of @p dst.
3422d30ea906Sjfb8856606  * @param[out] dst
3423d30ea906Sjfb8856606  *   Destination buffer address. Must be suitably aligned by the caller.
3424d30ea906Sjfb8856606  * @param size
3425d30ea906Sjfb8856606  *   Destination buffer size in bytes.
3426d30ea906Sjfb8856606  * @param[in] src
3427d30ea906Sjfb8856606  *   Source object to copy. Depending on @p op, its type may differ from
3428d30ea906Sjfb8856606  *   that of @p dst.
3429d30ea906Sjfb8856606  * @param[out] error
3430d30ea906Sjfb8856606  *   Perform verbose error reporting if not NULL. Initialized in case of
3431d30ea906Sjfb8856606  *   error only.
3432d30ea906Sjfb8856606  *
3433d30ea906Sjfb8856606  * @return
3434d30ea906Sjfb8856606  *   The number of bytes required to convert @p src to @p dst on success, a
3435d30ea906Sjfb8856606  *   negative errno value otherwise and rte_errno is set.
3436d30ea906Sjfb8856606  *
3437d30ea906Sjfb8856606  * @see rte_flow_conv_op
3438d30ea906Sjfb8856606  */
3439d30ea906Sjfb8856606 __rte_experimental
3440d30ea906Sjfb8856606 int
3441d30ea906Sjfb8856606 rte_flow_conv(enum rte_flow_conv_op op,
3442d30ea906Sjfb8856606 	      void *dst,
3443d30ea906Sjfb8856606 	      size_t size,
3444d30ea906Sjfb8856606 	      const void *src,
3445d30ea906Sjfb8856606 	      struct rte_flow_error *error);
3446d30ea906Sjfb8856606 
3447*2d9fd380Sjfb8856606 /**
3448*2d9fd380Sjfb8856606  * Get aged-out flows of a given port.
3449*2d9fd380Sjfb8856606  *
3450*2d9fd380Sjfb8856606  * RTE_ETH_EVENT_FLOW_AGED event will be triggered when at least one new aged
3451*2d9fd380Sjfb8856606  * out flow was detected after the last call to rte_flow_get_aged_flows.
3452*2d9fd380Sjfb8856606  * This function can be called to get the aged flows usynchronously from the
3453*2d9fd380Sjfb8856606  * event callback or synchronously regardless the event.
3454*2d9fd380Sjfb8856606  * This is not safe to call rte_flow_get_aged_flows function with other flow
3455*2d9fd380Sjfb8856606  * functions from multiple threads simultaneously.
3456*2d9fd380Sjfb8856606  *
3457*2d9fd380Sjfb8856606  * @param port_id
3458*2d9fd380Sjfb8856606  *   Port identifier of Ethernet device.
3459*2d9fd380Sjfb8856606  * @param[in, out] contexts
3460*2d9fd380Sjfb8856606  *   The address of an array of pointers to the aged-out flows contexts.
3461*2d9fd380Sjfb8856606  * @param[in] nb_contexts
3462*2d9fd380Sjfb8856606  *   The length of context array pointers.
3463*2d9fd380Sjfb8856606  * @param[out] error
3464*2d9fd380Sjfb8856606  *   Perform verbose error reporting if not NULL. Initialized in case of
3465*2d9fd380Sjfb8856606  *   error only.
3466*2d9fd380Sjfb8856606  *
3467*2d9fd380Sjfb8856606  * @return
3468*2d9fd380Sjfb8856606  *   if nb_contexts is 0, return the amount of all aged contexts.
3469*2d9fd380Sjfb8856606  *   if nb_contexts is not 0 , return the amount of aged flows reported
3470*2d9fd380Sjfb8856606  *   in the context array, otherwise negative errno value.
3471*2d9fd380Sjfb8856606  *
3472*2d9fd380Sjfb8856606  * @see rte_flow_action_age
3473*2d9fd380Sjfb8856606  * @see RTE_ETH_EVENT_FLOW_AGED
3474*2d9fd380Sjfb8856606  */
3475*2d9fd380Sjfb8856606 __rte_experimental
3476*2d9fd380Sjfb8856606 int
3477*2d9fd380Sjfb8856606 rte_flow_get_aged_flows(uint16_t port_id, void **contexts,
3478*2d9fd380Sjfb8856606 			uint32_t nb_contexts, struct rte_flow_error *error);
3479*2d9fd380Sjfb8856606 
3480*2d9fd380Sjfb8856606 /**
3481*2d9fd380Sjfb8856606  * Specify shared action configuration
3482*2d9fd380Sjfb8856606  */
3483*2d9fd380Sjfb8856606 struct rte_flow_shared_action_conf {
3484*2d9fd380Sjfb8856606 	/**
3485*2d9fd380Sjfb8856606 	 * Flow direction for shared action configuration.
3486*2d9fd380Sjfb8856606 	 *
3487*2d9fd380Sjfb8856606 	 * Shared action should be valid at least for one flow direction,
3488*2d9fd380Sjfb8856606 	 * otherwise it is invalid for both ingress and egress rules.
3489*2d9fd380Sjfb8856606 	 */
3490*2d9fd380Sjfb8856606 	uint32_t ingress:1;
3491*2d9fd380Sjfb8856606 	/**< Action valid for rules applied to ingress traffic. */
3492*2d9fd380Sjfb8856606 	uint32_t egress:1;
3493*2d9fd380Sjfb8856606 	/**< Action valid for rules applied to egress traffic. */
3494*2d9fd380Sjfb8856606 
3495*2d9fd380Sjfb8856606 	/**
3496*2d9fd380Sjfb8856606 	 * When set to 1, indicates that the action is valid for
3497*2d9fd380Sjfb8856606 	 * transfer traffic; otherwise, for non-transfer traffic.
3498*2d9fd380Sjfb8856606 	 *
3499*2d9fd380Sjfb8856606 	 * See struct rte_flow_attr.
3500*2d9fd380Sjfb8856606 	 */
3501*2d9fd380Sjfb8856606 	uint32_t transfer:1;
3502*2d9fd380Sjfb8856606 };
3503*2d9fd380Sjfb8856606 
3504*2d9fd380Sjfb8856606 /**
3505*2d9fd380Sjfb8856606  * @warning
3506*2d9fd380Sjfb8856606  * @b EXPERIMENTAL: this API may change without prior notice.
3507*2d9fd380Sjfb8856606  *
3508*2d9fd380Sjfb8856606  * Create shared action for reuse in multiple flow rules.
3509*2d9fd380Sjfb8856606  * The created shared action has single state and configuration
3510*2d9fd380Sjfb8856606  * across all flow rules using it.
3511*2d9fd380Sjfb8856606  *
3512*2d9fd380Sjfb8856606  * @param[in] port_id
3513*2d9fd380Sjfb8856606  *    The port identifier of the Ethernet device.
3514*2d9fd380Sjfb8856606  * @param[in] conf
3515*2d9fd380Sjfb8856606  *   Shared action configuration.
3516*2d9fd380Sjfb8856606  * @param[in] action
3517*2d9fd380Sjfb8856606  *   Action configuration for shared action creation.
3518*2d9fd380Sjfb8856606  * @param[out] error
3519*2d9fd380Sjfb8856606  *   Perform verbose error reporting if not NULL. PMDs initialize this
3520*2d9fd380Sjfb8856606  *   structure in case of error only.
3521*2d9fd380Sjfb8856606  * @return
3522*2d9fd380Sjfb8856606  *   A valid handle in case of success, NULL otherwise and rte_errno is set
3523*2d9fd380Sjfb8856606  *   to one of the error codes defined:
3524*2d9fd380Sjfb8856606  *   - (ENODEV) if *port_id* invalid.
3525*2d9fd380Sjfb8856606  *   - (ENOSYS) if underlying device does not support this functionality.
3526*2d9fd380Sjfb8856606  *   - (EIO) if underlying device is removed.
3527*2d9fd380Sjfb8856606  *   - (EINVAL) if *action* invalid.
3528*2d9fd380Sjfb8856606  *   - (ENOTSUP) if *action* valid but unsupported.
3529*2d9fd380Sjfb8856606  */
3530*2d9fd380Sjfb8856606 __rte_experimental
3531*2d9fd380Sjfb8856606 struct rte_flow_shared_action *
3532*2d9fd380Sjfb8856606 rte_flow_shared_action_create(uint16_t port_id,
3533*2d9fd380Sjfb8856606 			      const struct rte_flow_shared_action_conf *conf,
3534*2d9fd380Sjfb8856606 			      const struct rte_flow_action *action,
3535*2d9fd380Sjfb8856606 			      struct rte_flow_error *error);
3536*2d9fd380Sjfb8856606 
3537*2d9fd380Sjfb8856606 /**
3538*2d9fd380Sjfb8856606  * @warning
3539*2d9fd380Sjfb8856606  * @b EXPERIMENTAL: this API may change without prior notice.
3540*2d9fd380Sjfb8856606  *
3541*2d9fd380Sjfb8856606  * Destroy the shared action by handle.
3542*2d9fd380Sjfb8856606  *
3543*2d9fd380Sjfb8856606  * @param[in] port_id
3544*2d9fd380Sjfb8856606  *    The port identifier of the Ethernet device.
3545*2d9fd380Sjfb8856606  * @param[in] action
3546*2d9fd380Sjfb8856606  *   Handle for the shared action to be destroyed.
3547*2d9fd380Sjfb8856606  * @param[out] error
3548*2d9fd380Sjfb8856606  *   Perform verbose error reporting if not NULL. PMDs initialize this
3549*2d9fd380Sjfb8856606  *   structure in case of error only.
3550*2d9fd380Sjfb8856606  * @return
3551*2d9fd380Sjfb8856606  *   - (0) if success.
3552*2d9fd380Sjfb8856606  *   - (-ENODEV) if *port_id* invalid.
3553*2d9fd380Sjfb8856606  *   - (-ENOSYS) if underlying device does not support this functionality.
3554*2d9fd380Sjfb8856606  *   - (-EIO) if underlying device is removed.
3555*2d9fd380Sjfb8856606  *   - (-ENOENT) if action pointed by *action* handle was not found.
3556*2d9fd380Sjfb8856606  *   - (-EBUSY) if action pointed by *action* handle still used by some rules
3557*2d9fd380Sjfb8856606  *   rte_errno is also set.
3558*2d9fd380Sjfb8856606  */
3559*2d9fd380Sjfb8856606 __rte_experimental
3560*2d9fd380Sjfb8856606 int
3561*2d9fd380Sjfb8856606 rte_flow_shared_action_destroy(uint16_t port_id,
3562*2d9fd380Sjfb8856606 			       struct rte_flow_shared_action *action,
3563*2d9fd380Sjfb8856606 			       struct rte_flow_error *error);
3564*2d9fd380Sjfb8856606 
3565*2d9fd380Sjfb8856606 /**
3566*2d9fd380Sjfb8856606  * @warning
3567*2d9fd380Sjfb8856606  * @b EXPERIMENTAL: this API may change without prior notice.
3568*2d9fd380Sjfb8856606  *
3569*2d9fd380Sjfb8856606  * Update in-place the shared action configuration pointed by *action* handle
3570*2d9fd380Sjfb8856606  * with the configuration provided as *update* argument.
3571*2d9fd380Sjfb8856606  * The update of the shared action configuration effects all flow rules reusing
3572*2d9fd380Sjfb8856606  * the action via handle.
3573*2d9fd380Sjfb8856606  *
3574*2d9fd380Sjfb8856606  * @param[in] port_id
3575*2d9fd380Sjfb8856606  *    The port identifier of the Ethernet device.
3576*2d9fd380Sjfb8856606  * @param[in] action
3577*2d9fd380Sjfb8856606  *   Handle for the shared action to be updated.
3578*2d9fd380Sjfb8856606  * @param[in] update
3579*2d9fd380Sjfb8856606  *   Action specification used to modify the action pointed by handle.
3580*2d9fd380Sjfb8856606  *   *update* should be of same type with the action pointed by the *action*
3581*2d9fd380Sjfb8856606  *   handle argument, otherwise considered as invalid.
3582*2d9fd380Sjfb8856606  * @param[out] error
3583*2d9fd380Sjfb8856606  *   Perform verbose error reporting if not NULL. PMDs initialize this
3584*2d9fd380Sjfb8856606  *   structure in case of error only.
3585*2d9fd380Sjfb8856606  * @return
3586*2d9fd380Sjfb8856606  *   - (0) if success.
3587*2d9fd380Sjfb8856606  *   - (-ENODEV) if *port_id* invalid.
3588*2d9fd380Sjfb8856606  *   - (-ENOSYS) if underlying device does not support this functionality.
3589*2d9fd380Sjfb8856606  *   - (-EIO) if underlying device is removed.
3590*2d9fd380Sjfb8856606  *   - (-EINVAL) if *update* invalid.
3591*2d9fd380Sjfb8856606  *   - (-ENOTSUP) if *update* valid but unsupported.
3592*2d9fd380Sjfb8856606  *   - (-ENOENT) if action pointed by *ctx* was not found.
3593*2d9fd380Sjfb8856606  *   rte_errno is also set.
3594*2d9fd380Sjfb8856606  */
3595*2d9fd380Sjfb8856606 __rte_experimental
3596*2d9fd380Sjfb8856606 int
3597*2d9fd380Sjfb8856606 rte_flow_shared_action_update(uint16_t port_id,
3598*2d9fd380Sjfb8856606 			      struct rte_flow_shared_action *action,
3599*2d9fd380Sjfb8856606 			      const struct rte_flow_action *update,
3600*2d9fd380Sjfb8856606 			      struct rte_flow_error *error);
3601*2d9fd380Sjfb8856606 
3602*2d9fd380Sjfb8856606 /**
3603*2d9fd380Sjfb8856606  * @warning
3604*2d9fd380Sjfb8856606  * @b EXPERIMENTAL: this API may change without prior notice.
3605*2d9fd380Sjfb8856606  *
3606*2d9fd380Sjfb8856606  * Query the shared action by handle.
3607*2d9fd380Sjfb8856606  *
3608*2d9fd380Sjfb8856606  * Retrieve action-specific data such as counters.
3609*2d9fd380Sjfb8856606  * Data is gathered by special action which may be present/referenced in
3610*2d9fd380Sjfb8856606  * more than one flow rule definition.
3611*2d9fd380Sjfb8856606  *
3612*2d9fd380Sjfb8856606  * \see RTE_FLOW_ACTION_TYPE_COUNT
3613*2d9fd380Sjfb8856606  *
3614*2d9fd380Sjfb8856606  * @param port_id
3615*2d9fd380Sjfb8856606  *   Port identifier of Ethernet device.
3616*2d9fd380Sjfb8856606  * @param[in] action
3617*2d9fd380Sjfb8856606  *   Handle for the shared action to query.
3618*2d9fd380Sjfb8856606  * @param[in, out] data
3619*2d9fd380Sjfb8856606  *   Pointer to storage for the associated query data type.
3620*2d9fd380Sjfb8856606  * @param[out] error
3621*2d9fd380Sjfb8856606  *   Perform verbose error reporting if not NULL. PMDs initialize this
3622*2d9fd380Sjfb8856606  *   structure in case of error only.
3623*2d9fd380Sjfb8856606  *
3624*2d9fd380Sjfb8856606  * @return
3625*2d9fd380Sjfb8856606  *   0 on success, a negative errno value otherwise and rte_errno is set.
3626*2d9fd380Sjfb8856606  */
3627*2d9fd380Sjfb8856606 __rte_experimental
3628*2d9fd380Sjfb8856606 int
3629*2d9fd380Sjfb8856606 rte_flow_shared_action_query(uint16_t port_id,
3630*2d9fd380Sjfb8856606 			     const struct rte_flow_shared_action *action,
3631*2d9fd380Sjfb8856606 			     void *data,
3632*2d9fd380Sjfb8856606 			     struct rte_flow_error *error);
3633*2d9fd380Sjfb8856606 
3634*2d9fd380Sjfb8856606 /* Tunnel has a type and the key information. */
3635*2d9fd380Sjfb8856606 struct rte_flow_tunnel {
3636*2d9fd380Sjfb8856606 	/**
3637*2d9fd380Sjfb8856606 	 * Tunnel type, for example RTE_FLOW_ITEM_TYPE_VXLAN,
3638*2d9fd380Sjfb8856606 	 * RTE_FLOW_ITEM_TYPE_NVGRE etc.
3639*2d9fd380Sjfb8856606 	 */
3640*2d9fd380Sjfb8856606 	enum rte_flow_item_type	type;
3641*2d9fd380Sjfb8856606 	uint64_t tun_id; /**< Tunnel identification. */
3642*2d9fd380Sjfb8856606 
3643*2d9fd380Sjfb8856606 	RTE_STD_C11
3644*2d9fd380Sjfb8856606 	union {
3645*2d9fd380Sjfb8856606 		struct {
3646*2d9fd380Sjfb8856606 			rte_be32_t src_addr; /**< IPv4 source address. */
3647*2d9fd380Sjfb8856606 			rte_be32_t dst_addr; /**< IPv4 destination address. */
3648*2d9fd380Sjfb8856606 		} ipv4;
3649*2d9fd380Sjfb8856606 		struct {
3650*2d9fd380Sjfb8856606 			uint8_t src_addr[16]; /**< IPv6 source address. */
3651*2d9fd380Sjfb8856606 			uint8_t dst_addr[16]; /**< IPv6 destination address. */
3652*2d9fd380Sjfb8856606 		} ipv6;
3653*2d9fd380Sjfb8856606 	};
3654*2d9fd380Sjfb8856606 	rte_be16_t tp_src; /**< Tunnel port source. */
3655*2d9fd380Sjfb8856606 	rte_be16_t tp_dst; /**< Tunnel port destination. */
3656*2d9fd380Sjfb8856606 	uint16_t   tun_flags; /**< Tunnel flags. */
3657*2d9fd380Sjfb8856606 
3658*2d9fd380Sjfb8856606 	bool       is_ipv6; /**< True for valid IPv6 fields. Otherwise IPv4. */
3659*2d9fd380Sjfb8856606 
3660*2d9fd380Sjfb8856606 	/**
3661*2d9fd380Sjfb8856606 	 * the following members are required to restore packet
3662*2d9fd380Sjfb8856606 	 * after miss
3663*2d9fd380Sjfb8856606 	 */
3664*2d9fd380Sjfb8856606 	uint8_t    tos; /**< TOS for IPv4, TC for IPv6. */
3665*2d9fd380Sjfb8856606 	uint8_t    ttl; /**< TTL for IPv4, HL for IPv6. */
3666*2d9fd380Sjfb8856606 	uint32_t label; /**< Flow Label for IPv6. */
3667*2d9fd380Sjfb8856606 };
3668*2d9fd380Sjfb8856606 
3669*2d9fd380Sjfb8856606 /**
3670*2d9fd380Sjfb8856606  * Indicate that the packet has a tunnel.
3671*2d9fd380Sjfb8856606  */
3672*2d9fd380Sjfb8856606 #define RTE_FLOW_RESTORE_INFO_TUNNEL  (1ULL << 0)
3673*2d9fd380Sjfb8856606 
3674*2d9fd380Sjfb8856606 /**
3675*2d9fd380Sjfb8856606  * Indicate that the packet has a non decapsulated tunnel header.
3676*2d9fd380Sjfb8856606  */
3677*2d9fd380Sjfb8856606 #define RTE_FLOW_RESTORE_INFO_ENCAPSULATED  (1ULL << 1)
3678*2d9fd380Sjfb8856606 
3679*2d9fd380Sjfb8856606 /**
3680*2d9fd380Sjfb8856606  * Indicate that the packet has a group_id.
3681*2d9fd380Sjfb8856606  */
3682*2d9fd380Sjfb8856606 #define RTE_FLOW_RESTORE_INFO_GROUP_ID  (1ULL << 2)
3683*2d9fd380Sjfb8856606 
3684*2d9fd380Sjfb8856606 /**
3685*2d9fd380Sjfb8856606  * Restore information structure to communicate the current packet processing
3686*2d9fd380Sjfb8856606  * state when some of the processing pipeline is done in hardware and should
3687*2d9fd380Sjfb8856606  * continue in software.
3688*2d9fd380Sjfb8856606  */
3689*2d9fd380Sjfb8856606 struct rte_flow_restore_info {
3690*2d9fd380Sjfb8856606 	/**
3691*2d9fd380Sjfb8856606 	 * Bitwise flags (RTE_FLOW_RESTORE_INFO_*) to indicate validation of
3692*2d9fd380Sjfb8856606 	 * other fields in struct rte_flow_restore_info.
3693*2d9fd380Sjfb8856606 	 */
3694*2d9fd380Sjfb8856606 	uint64_t flags;
3695*2d9fd380Sjfb8856606 	uint32_t group_id; /**< Group ID where packed missed */
3696*2d9fd380Sjfb8856606 	struct rte_flow_tunnel tunnel; /**< Tunnel information. */
3697*2d9fd380Sjfb8856606 };
3698*2d9fd380Sjfb8856606 
3699*2d9fd380Sjfb8856606 /**
3700*2d9fd380Sjfb8856606  * Allocate an array of actions to be used in rte_flow_create, to implement
3701*2d9fd380Sjfb8856606  * tunnel-decap-set for the given tunnel.
3702*2d9fd380Sjfb8856606  * Sample usage:
3703*2d9fd380Sjfb8856606  *   actions vxlan_decap / tunnel-decap-set(tunnel properties) /
3704*2d9fd380Sjfb8856606  *            jump group 0 / end
3705*2d9fd380Sjfb8856606  *
3706*2d9fd380Sjfb8856606  * @param port_id
3707*2d9fd380Sjfb8856606  *   Port identifier of Ethernet device.
3708*2d9fd380Sjfb8856606  * @param[in] tunnel
3709*2d9fd380Sjfb8856606  *   Tunnel properties.
3710*2d9fd380Sjfb8856606  * @param[out] actions
3711*2d9fd380Sjfb8856606  *   Array of actions to be allocated by the PMD. This array should be
3712*2d9fd380Sjfb8856606  *   concatenated with the actions array provided to rte_flow_create.
3713*2d9fd380Sjfb8856606  * @param[out] num_of_actions
3714*2d9fd380Sjfb8856606  *   Number of actions allocated.
3715*2d9fd380Sjfb8856606  * @param[out] error
3716*2d9fd380Sjfb8856606  *   Perform verbose error reporting if not NULL. PMDs initialize this
3717*2d9fd380Sjfb8856606  *   structure in case of error only.
3718*2d9fd380Sjfb8856606  *
3719*2d9fd380Sjfb8856606  * @return
3720*2d9fd380Sjfb8856606  *   0 on success, a negative errno value otherwise and rte_errno is set.
3721*2d9fd380Sjfb8856606  */
3722*2d9fd380Sjfb8856606 __rte_experimental
3723*2d9fd380Sjfb8856606 int
3724*2d9fd380Sjfb8856606 rte_flow_tunnel_decap_set(uint16_t port_id,
3725*2d9fd380Sjfb8856606 			  struct rte_flow_tunnel *tunnel,
3726*2d9fd380Sjfb8856606 			  struct rte_flow_action **actions,
3727*2d9fd380Sjfb8856606 			  uint32_t *num_of_actions,
3728*2d9fd380Sjfb8856606 			  struct rte_flow_error *error);
3729*2d9fd380Sjfb8856606 
3730*2d9fd380Sjfb8856606 /**
3731*2d9fd380Sjfb8856606  * Allocate an array of items to be used in rte_flow_create, to implement
3732*2d9fd380Sjfb8856606  * tunnel-match for the given tunnel.
3733*2d9fd380Sjfb8856606  * Sample usage:
3734*2d9fd380Sjfb8856606  *   pattern tunnel-match(tunnel properties) / outer-header-matches /
3735*2d9fd380Sjfb8856606  *           inner-header-matches / end
3736*2d9fd380Sjfb8856606  *
3737*2d9fd380Sjfb8856606  * @param port_id
3738*2d9fd380Sjfb8856606  *   Port identifier of Ethernet device.
3739*2d9fd380Sjfb8856606  * @param[in] tunnel
3740*2d9fd380Sjfb8856606  *   Tunnel properties.
3741*2d9fd380Sjfb8856606  * @param[out] items
3742*2d9fd380Sjfb8856606  *   Array of items to be allocated by the PMD. This array should be
3743*2d9fd380Sjfb8856606  *   concatenated with the items array provided to rte_flow_create.
3744*2d9fd380Sjfb8856606  * @param[out] num_of_items
3745*2d9fd380Sjfb8856606  *   Number of items allocated.
3746*2d9fd380Sjfb8856606  * @param[out] error
3747*2d9fd380Sjfb8856606  *   Perform verbose error reporting if not NULL. PMDs initialize this
3748*2d9fd380Sjfb8856606  *   structure in case of error only.
3749*2d9fd380Sjfb8856606  *
3750*2d9fd380Sjfb8856606  * @return
3751*2d9fd380Sjfb8856606  *   0 on success, a negative errno value otherwise and rte_errno is set.
3752*2d9fd380Sjfb8856606  */
3753*2d9fd380Sjfb8856606 __rte_experimental
3754*2d9fd380Sjfb8856606 int
3755*2d9fd380Sjfb8856606 rte_flow_tunnel_match(uint16_t port_id,
3756*2d9fd380Sjfb8856606 		      struct rte_flow_tunnel *tunnel,
3757*2d9fd380Sjfb8856606 		      struct rte_flow_item **items,
3758*2d9fd380Sjfb8856606 		      uint32_t *num_of_items,
3759*2d9fd380Sjfb8856606 		      struct rte_flow_error *error);
3760*2d9fd380Sjfb8856606 
3761*2d9fd380Sjfb8856606 /**
3762*2d9fd380Sjfb8856606  * Populate the current packet processing state, if exists, for the given mbuf.
3763*2d9fd380Sjfb8856606  *
3764*2d9fd380Sjfb8856606  * @param port_id
3765*2d9fd380Sjfb8856606  *   Port identifier of Ethernet device.
3766*2d9fd380Sjfb8856606  * @param[in] m
3767*2d9fd380Sjfb8856606  *   Mbuf struct.
3768*2d9fd380Sjfb8856606  * @param[out] info
3769*2d9fd380Sjfb8856606  *   Restore information. Upon success contains the HW state.
3770*2d9fd380Sjfb8856606  * @param[out] error
3771*2d9fd380Sjfb8856606  *   Perform verbose error reporting if not NULL. PMDs initialize this
3772*2d9fd380Sjfb8856606  *   structure in case of error only.
3773*2d9fd380Sjfb8856606  *
3774*2d9fd380Sjfb8856606  * @return
3775*2d9fd380Sjfb8856606  *   0 on success, a negative errno value otherwise and rte_errno is set.
3776*2d9fd380Sjfb8856606  */
3777*2d9fd380Sjfb8856606 __rte_experimental
3778*2d9fd380Sjfb8856606 int
3779*2d9fd380Sjfb8856606 rte_flow_get_restore_info(uint16_t port_id,
3780*2d9fd380Sjfb8856606 			  struct rte_mbuf *m,
3781*2d9fd380Sjfb8856606 			  struct rte_flow_restore_info *info,
3782*2d9fd380Sjfb8856606 			  struct rte_flow_error *error);
3783*2d9fd380Sjfb8856606 
3784*2d9fd380Sjfb8856606 /**
3785*2d9fd380Sjfb8856606  * Release the action array as allocated by rte_flow_tunnel_decap_set.
3786*2d9fd380Sjfb8856606  *
3787*2d9fd380Sjfb8856606  * @param port_id
3788*2d9fd380Sjfb8856606  *   Port identifier of Ethernet device.
3789*2d9fd380Sjfb8856606  * @param[in] actions
3790*2d9fd380Sjfb8856606  *   Array of actions to be released.
3791*2d9fd380Sjfb8856606  * @param[in] num_of_actions
3792*2d9fd380Sjfb8856606  *   Number of elements in actions array.
3793*2d9fd380Sjfb8856606  * @param[out] error
3794*2d9fd380Sjfb8856606  *   Perform verbose error reporting if not NULL. PMDs initialize this
3795*2d9fd380Sjfb8856606  *   structure in case of error only.
3796*2d9fd380Sjfb8856606  *
3797*2d9fd380Sjfb8856606  * @return
3798*2d9fd380Sjfb8856606  *   0 on success, a negative errno value otherwise and rte_errno is set.
3799*2d9fd380Sjfb8856606  */
3800*2d9fd380Sjfb8856606 __rte_experimental
3801*2d9fd380Sjfb8856606 int
3802*2d9fd380Sjfb8856606 rte_flow_tunnel_action_decap_release(uint16_t port_id,
3803*2d9fd380Sjfb8856606 				     struct rte_flow_action *actions,
3804*2d9fd380Sjfb8856606 				     uint32_t num_of_actions,
3805*2d9fd380Sjfb8856606 				     struct rte_flow_error *error);
3806*2d9fd380Sjfb8856606 
3807*2d9fd380Sjfb8856606 /**
3808*2d9fd380Sjfb8856606  * Release the item array as allocated by rte_flow_tunnel_match.
3809*2d9fd380Sjfb8856606  *
3810*2d9fd380Sjfb8856606  * @param port_id
3811*2d9fd380Sjfb8856606  *   Port identifier of Ethernet device.
3812*2d9fd380Sjfb8856606  * @param[in] items
3813*2d9fd380Sjfb8856606  *   Array of items to be released.
3814*2d9fd380Sjfb8856606  * @param[in] num_of_items
3815*2d9fd380Sjfb8856606  *   Number of elements in item array.
3816*2d9fd380Sjfb8856606  * @param[out] error
3817*2d9fd380Sjfb8856606  *   Perform verbose error reporting if not NULL. PMDs initialize this
3818*2d9fd380Sjfb8856606  *   structure in case of error only.
3819*2d9fd380Sjfb8856606  *
3820*2d9fd380Sjfb8856606  * @return
3821*2d9fd380Sjfb8856606  *   0 on success, a negative errno value otherwise and rte_errno is set.
3822*2d9fd380Sjfb8856606  */
3823*2d9fd380Sjfb8856606 __rte_experimental
3824*2d9fd380Sjfb8856606 int
3825*2d9fd380Sjfb8856606 rte_flow_tunnel_item_release(uint16_t port_id,
3826*2d9fd380Sjfb8856606 			     struct rte_flow_item *items,
3827*2d9fd380Sjfb8856606 			     uint32_t num_of_items,
3828*2d9fd380Sjfb8856606 			     struct rte_flow_error *error);
3829d30ea906Sjfb8856606 #ifdef __cplusplus
3830d30ea906Sjfb8856606 }
3831d30ea906Sjfb8856606 #endif
3832d30ea906Sjfb8856606 
3833d30ea906Sjfb8856606 #endif /* RTE_FLOW_H_ */
3834