c0420797eb8fe8b60aba33cfa94e8bba7b0a538a
[dpdk.git] / drivers / net / ice / ice_generic_flow.c
1 /* SPDX-License-Identifier: BSD-3-Clause
2  * Copyright(c) 2019 Intel Corporation
3  */
4
5 #include <sys/queue.h>
6 #include <stdio.h>
7 #include <errno.h>
8 #include <stdint.h>
9 #include <string.h>
10 #include <unistd.h>
11 #include <stdarg.h>
12
13 #include <rte_ether.h>
14 #include <rte_ethdev_driver.h>
15 #include <rte_malloc.h>
16 #include <rte_tailq.h>
17
18 #include "ice_ethdev.h"
19 #include "ice_generic_flow.h"
20
21 /**
22  * Non-pipeline mode, fdir and switch both used as distributor,
23  * fdir used first, switch used as fdir's backup.
24  */
25 #define ICE_FLOW_CLASSIFY_STAGE_DISTRIBUTOR_ONLY 0
26 /*Pipeline mode, switch used at permission stage*/
27 #define ICE_FLOW_CLASSIFY_STAGE_PERMISSION 1
28 /*Pipeline mode, fdir used at distributor stage*/
29 #define ICE_FLOW_CLASSIFY_STAGE_DISTRIBUTOR 2
30
31 static struct ice_engine_list engine_list =
32                 TAILQ_HEAD_INITIALIZER(engine_list);
33
34 static int ice_flow_validate(struct rte_eth_dev *dev,
35                 const struct rte_flow_attr *attr,
36                 const struct rte_flow_item pattern[],
37                 const struct rte_flow_action actions[],
38                 struct rte_flow_error *error);
39 static struct rte_flow *ice_flow_create(struct rte_eth_dev *dev,
40                 const struct rte_flow_attr *attr,
41                 const struct rte_flow_item pattern[],
42                 const struct rte_flow_action actions[],
43                 struct rte_flow_error *error);
44 static int ice_flow_destroy(struct rte_eth_dev *dev,
45                 struct rte_flow *flow,
46                 struct rte_flow_error *error);
47 static int ice_flow_flush(struct rte_eth_dev *dev,
48                 struct rte_flow_error *error);
49 static int ice_flow_query(struct rte_eth_dev *dev,
50                 struct rte_flow *flow,
51                 const struct rte_flow_action *actions,
52                 void *data,
53                 struct rte_flow_error *error);
54
55 const struct rte_flow_ops ice_flow_ops = {
56         .validate = ice_flow_validate,
57         .create = ice_flow_create,
58         .destroy = ice_flow_destroy,
59         .flush = ice_flow_flush,
60         .query = ice_flow_query,
61 };
62
63 /* empty */
64 enum rte_flow_item_type pattern_empty[] = {
65         RTE_FLOW_ITEM_TYPE_END,
66 };
67
68 /* L2 */
69 enum rte_flow_item_type pattern_ethertype[] = {
70         RTE_FLOW_ITEM_TYPE_ETH,
71         RTE_FLOW_ITEM_TYPE_END,
72 };
73 enum rte_flow_item_type pattern_ethertype_vlan[] = {
74         RTE_FLOW_ITEM_TYPE_ETH,
75         RTE_FLOW_ITEM_TYPE_VLAN,
76         RTE_FLOW_ITEM_TYPE_END,
77 };
78 enum rte_flow_item_type pattern_ethertype_qinq[] = {
79         RTE_FLOW_ITEM_TYPE_ETH,
80         RTE_FLOW_ITEM_TYPE_VLAN,
81         RTE_FLOW_ITEM_TYPE_VLAN,
82         RTE_FLOW_ITEM_TYPE_END,
83 };
84
85 /* ARP */
86 enum rte_flow_item_type pattern_eth_arp[] = {
87         RTE_FLOW_ITEM_TYPE_ETH,
88         RTE_FLOW_ITEM_TYPE_ARP_ETH_IPV4,
89         RTE_FLOW_ITEM_TYPE_END,
90 };
91
92 /* non-tunnel IPv4 */
93 enum rte_flow_item_type pattern_eth_ipv4[] = {
94         RTE_FLOW_ITEM_TYPE_ETH,
95         RTE_FLOW_ITEM_TYPE_IPV4,
96         RTE_FLOW_ITEM_TYPE_END,
97 };
98 enum rte_flow_item_type pattern_eth_vlan_ipv4[] = {
99         RTE_FLOW_ITEM_TYPE_ETH,
100         RTE_FLOW_ITEM_TYPE_VLAN,
101         RTE_FLOW_ITEM_TYPE_IPV4,
102         RTE_FLOW_ITEM_TYPE_END,
103 };
104 enum rte_flow_item_type pattern_eth_qinq_ipv4[] = {
105         RTE_FLOW_ITEM_TYPE_ETH,
106         RTE_FLOW_ITEM_TYPE_VLAN,
107         RTE_FLOW_ITEM_TYPE_VLAN,
108         RTE_FLOW_ITEM_TYPE_IPV4,
109         RTE_FLOW_ITEM_TYPE_END,
110 };
111 enum rte_flow_item_type pattern_eth_ipv4_udp[] = {
112         RTE_FLOW_ITEM_TYPE_ETH,
113         RTE_FLOW_ITEM_TYPE_IPV4,
114         RTE_FLOW_ITEM_TYPE_UDP,
115         RTE_FLOW_ITEM_TYPE_END,
116 };
117 enum rte_flow_item_type pattern_eth_vlan_ipv4_udp[] = {
118         RTE_FLOW_ITEM_TYPE_ETH,
119         RTE_FLOW_ITEM_TYPE_VLAN,
120         RTE_FLOW_ITEM_TYPE_IPV4,
121         RTE_FLOW_ITEM_TYPE_UDP,
122         RTE_FLOW_ITEM_TYPE_END,
123 };
124 enum rte_flow_item_type pattern_eth_qinq_ipv4_udp[] = {
125         RTE_FLOW_ITEM_TYPE_ETH,
126         RTE_FLOW_ITEM_TYPE_VLAN,
127         RTE_FLOW_ITEM_TYPE_VLAN,
128         RTE_FLOW_ITEM_TYPE_IPV4,
129         RTE_FLOW_ITEM_TYPE_UDP,
130         RTE_FLOW_ITEM_TYPE_END,
131 };
132 enum rte_flow_item_type pattern_eth_ipv4_tcp[] = {
133         RTE_FLOW_ITEM_TYPE_ETH,
134         RTE_FLOW_ITEM_TYPE_IPV4,
135         RTE_FLOW_ITEM_TYPE_TCP,
136         RTE_FLOW_ITEM_TYPE_END,
137 };
138 enum rte_flow_item_type pattern_eth_vlan_ipv4_tcp[] = {
139         RTE_FLOW_ITEM_TYPE_ETH,
140         RTE_FLOW_ITEM_TYPE_VLAN,
141         RTE_FLOW_ITEM_TYPE_IPV4,
142         RTE_FLOW_ITEM_TYPE_TCP,
143         RTE_FLOW_ITEM_TYPE_END,
144 };
145 enum rte_flow_item_type pattern_eth_qinq_ipv4_tcp[] = {
146         RTE_FLOW_ITEM_TYPE_ETH,
147         RTE_FLOW_ITEM_TYPE_VLAN,
148         RTE_FLOW_ITEM_TYPE_VLAN,
149         RTE_FLOW_ITEM_TYPE_IPV4,
150         RTE_FLOW_ITEM_TYPE_TCP,
151         RTE_FLOW_ITEM_TYPE_END,
152 };
153 enum rte_flow_item_type pattern_eth_ipv4_sctp[] = {
154         RTE_FLOW_ITEM_TYPE_ETH,
155         RTE_FLOW_ITEM_TYPE_IPV4,
156         RTE_FLOW_ITEM_TYPE_SCTP,
157         RTE_FLOW_ITEM_TYPE_END,
158 };
159 enum rte_flow_item_type pattern_eth_vlan_ipv4_sctp[] = {
160         RTE_FLOW_ITEM_TYPE_ETH,
161         RTE_FLOW_ITEM_TYPE_VLAN,
162         RTE_FLOW_ITEM_TYPE_IPV4,
163         RTE_FLOW_ITEM_TYPE_SCTP,
164         RTE_FLOW_ITEM_TYPE_END,
165 };
166 enum rte_flow_item_type pattern_eth_qinq_ipv4_sctp[] = {
167         RTE_FLOW_ITEM_TYPE_ETH,
168         RTE_FLOW_ITEM_TYPE_VLAN,
169         RTE_FLOW_ITEM_TYPE_VLAN,
170         RTE_FLOW_ITEM_TYPE_IPV4,
171         RTE_FLOW_ITEM_TYPE_SCTP,
172         RTE_FLOW_ITEM_TYPE_END,
173 };
174 enum rte_flow_item_type pattern_eth_ipv4_icmp[] = {
175         RTE_FLOW_ITEM_TYPE_ETH,
176         RTE_FLOW_ITEM_TYPE_IPV4,
177         RTE_FLOW_ITEM_TYPE_ICMP,
178         RTE_FLOW_ITEM_TYPE_END,
179 };
180 enum rte_flow_item_type pattern_eth_vlan_ipv4_icmp[] = {
181         RTE_FLOW_ITEM_TYPE_ETH,
182         RTE_FLOW_ITEM_TYPE_VLAN,
183         RTE_FLOW_ITEM_TYPE_IPV4,
184         RTE_FLOW_ITEM_TYPE_ICMP,
185         RTE_FLOW_ITEM_TYPE_END,
186 };
187 enum rte_flow_item_type pattern_eth_qinq_ipv4_icmp[] = {
188         RTE_FLOW_ITEM_TYPE_ETH,
189         RTE_FLOW_ITEM_TYPE_VLAN,
190         RTE_FLOW_ITEM_TYPE_VLAN,
191         RTE_FLOW_ITEM_TYPE_IPV4,
192         RTE_FLOW_ITEM_TYPE_ICMP,
193         RTE_FLOW_ITEM_TYPE_END,
194 };
195
196 /* non-tunnel IPv6 */
197 enum rte_flow_item_type pattern_eth_ipv6[] = {
198         RTE_FLOW_ITEM_TYPE_ETH,
199         RTE_FLOW_ITEM_TYPE_IPV6,
200         RTE_FLOW_ITEM_TYPE_END,
201 };
202 enum rte_flow_item_type pattern_eth_vlan_ipv6[] = {
203         RTE_FLOW_ITEM_TYPE_ETH,
204         RTE_FLOW_ITEM_TYPE_VLAN,
205         RTE_FLOW_ITEM_TYPE_IPV6,
206         RTE_FLOW_ITEM_TYPE_END,
207 };
208 enum rte_flow_item_type pattern_eth_qinq_ipv6[] = {
209         RTE_FLOW_ITEM_TYPE_ETH,
210         RTE_FLOW_ITEM_TYPE_VLAN,
211         RTE_FLOW_ITEM_TYPE_VLAN,
212         RTE_FLOW_ITEM_TYPE_IPV6,
213         RTE_FLOW_ITEM_TYPE_END,
214 };
215 enum rte_flow_item_type pattern_eth_ipv6_udp[] = {
216         RTE_FLOW_ITEM_TYPE_ETH,
217         RTE_FLOW_ITEM_TYPE_IPV6,
218         RTE_FLOW_ITEM_TYPE_UDP,
219         RTE_FLOW_ITEM_TYPE_END,
220 };
221 enum rte_flow_item_type pattern_eth_vlan_ipv6_udp[] = {
222         RTE_FLOW_ITEM_TYPE_ETH,
223         RTE_FLOW_ITEM_TYPE_VLAN,
224         RTE_FLOW_ITEM_TYPE_IPV6,
225         RTE_FLOW_ITEM_TYPE_UDP,
226         RTE_FLOW_ITEM_TYPE_END,
227 };
228 enum rte_flow_item_type pattern_eth_qinq_ipv6_udp[] = {
229         RTE_FLOW_ITEM_TYPE_ETH,
230         RTE_FLOW_ITEM_TYPE_VLAN,
231         RTE_FLOW_ITEM_TYPE_VLAN,
232         RTE_FLOW_ITEM_TYPE_IPV6,
233         RTE_FLOW_ITEM_TYPE_UDP,
234         RTE_FLOW_ITEM_TYPE_END,
235 };
236 enum rte_flow_item_type pattern_eth_ipv6_tcp[] = {
237         RTE_FLOW_ITEM_TYPE_ETH,
238         RTE_FLOW_ITEM_TYPE_IPV6,
239         RTE_FLOW_ITEM_TYPE_TCP,
240         RTE_FLOW_ITEM_TYPE_END,
241 };
242 enum rte_flow_item_type pattern_eth_vlan_ipv6_tcp[] = {
243         RTE_FLOW_ITEM_TYPE_ETH,
244         RTE_FLOW_ITEM_TYPE_VLAN,
245         RTE_FLOW_ITEM_TYPE_IPV6,
246         RTE_FLOW_ITEM_TYPE_TCP,
247         RTE_FLOW_ITEM_TYPE_END,
248 };
249 enum rte_flow_item_type pattern_eth_qinq_ipv6_tcp[] = {
250         RTE_FLOW_ITEM_TYPE_ETH,
251         RTE_FLOW_ITEM_TYPE_VLAN,
252         RTE_FLOW_ITEM_TYPE_VLAN,
253         RTE_FLOW_ITEM_TYPE_IPV6,
254         RTE_FLOW_ITEM_TYPE_TCP,
255         RTE_FLOW_ITEM_TYPE_END,
256 };
257 enum rte_flow_item_type pattern_eth_ipv6_sctp[] = {
258         RTE_FLOW_ITEM_TYPE_ETH,
259         RTE_FLOW_ITEM_TYPE_IPV6,
260         RTE_FLOW_ITEM_TYPE_SCTP,
261         RTE_FLOW_ITEM_TYPE_END,
262 };
263 enum rte_flow_item_type pattern_eth_vlan_ipv6_sctp[] = {
264         RTE_FLOW_ITEM_TYPE_ETH,
265         RTE_FLOW_ITEM_TYPE_VLAN,
266         RTE_FLOW_ITEM_TYPE_IPV6,
267         RTE_FLOW_ITEM_TYPE_SCTP,
268         RTE_FLOW_ITEM_TYPE_END,
269 };
270 enum rte_flow_item_type pattern_eth_qinq_ipv6_sctp[] = {
271         RTE_FLOW_ITEM_TYPE_ETH,
272         RTE_FLOW_ITEM_TYPE_VLAN,
273         RTE_FLOW_ITEM_TYPE_VLAN,
274         RTE_FLOW_ITEM_TYPE_IPV6,
275         RTE_FLOW_ITEM_TYPE_SCTP,
276         RTE_FLOW_ITEM_TYPE_END,
277 };
278 enum rte_flow_item_type pattern_eth_ipv6_icmp6[] = {
279         RTE_FLOW_ITEM_TYPE_ETH,
280         RTE_FLOW_ITEM_TYPE_IPV6,
281         RTE_FLOW_ITEM_TYPE_ICMP6,
282         RTE_FLOW_ITEM_TYPE_END,
283 };
284 enum rte_flow_item_type pattern_eth_vlan_ipv6_icmp6[] = {
285         RTE_FLOW_ITEM_TYPE_ETH,
286         RTE_FLOW_ITEM_TYPE_VLAN,
287         RTE_FLOW_ITEM_TYPE_IPV6,
288         RTE_FLOW_ITEM_TYPE_ICMP6,
289         RTE_FLOW_ITEM_TYPE_END,
290 };
291 enum rte_flow_item_type pattern_eth_qinq_ipv6_icmp6[] = {
292         RTE_FLOW_ITEM_TYPE_ETH,
293         RTE_FLOW_ITEM_TYPE_VLAN,
294         RTE_FLOW_ITEM_TYPE_VLAN,
295         RTE_FLOW_ITEM_TYPE_IPV6,
296         RTE_FLOW_ITEM_TYPE_ICMP6,
297         RTE_FLOW_ITEM_TYPE_END,
298 };
299
300 /* IPv4 VXLAN IPv4 */
301 enum rte_flow_item_type pattern_eth_ipv4_udp_vxlan_ipv4[] = {
302         RTE_FLOW_ITEM_TYPE_ETH,
303         RTE_FLOW_ITEM_TYPE_IPV4,
304         RTE_FLOW_ITEM_TYPE_UDP,
305         RTE_FLOW_ITEM_TYPE_VXLAN,
306         RTE_FLOW_ITEM_TYPE_IPV4,
307         RTE_FLOW_ITEM_TYPE_END,
308 };
309 enum rte_flow_item_type pattern_eth_ipv4_udp_vxlan_ipv4_udp[] = {
310         RTE_FLOW_ITEM_TYPE_ETH,
311         RTE_FLOW_ITEM_TYPE_IPV4,
312         RTE_FLOW_ITEM_TYPE_UDP,
313         RTE_FLOW_ITEM_TYPE_VXLAN,
314         RTE_FLOW_ITEM_TYPE_IPV4,
315         RTE_FLOW_ITEM_TYPE_UDP,
316         RTE_FLOW_ITEM_TYPE_END,
317 };
318 enum rte_flow_item_type pattern_eth_ipv4_udp_vxlan_ipv4_tcp[] = {
319         RTE_FLOW_ITEM_TYPE_ETH,
320         RTE_FLOW_ITEM_TYPE_IPV4,
321         RTE_FLOW_ITEM_TYPE_UDP,
322         RTE_FLOW_ITEM_TYPE_VXLAN,
323         RTE_FLOW_ITEM_TYPE_IPV4,
324         RTE_FLOW_ITEM_TYPE_TCP,
325         RTE_FLOW_ITEM_TYPE_END,
326 };
327 enum rte_flow_item_type pattern_eth_ipv4_udp_vxlan_ipv4_sctp[] = {
328         RTE_FLOW_ITEM_TYPE_ETH,
329         RTE_FLOW_ITEM_TYPE_IPV4,
330         RTE_FLOW_ITEM_TYPE_UDP,
331         RTE_FLOW_ITEM_TYPE_VXLAN,
332         RTE_FLOW_ITEM_TYPE_IPV4,
333         RTE_FLOW_ITEM_TYPE_SCTP,
334         RTE_FLOW_ITEM_TYPE_END,
335 };
336 enum rte_flow_item_type pattern_eth_ipv4_udp_vxlan_ipv4_icmp[] = {
337         RTE_FLOW_ITEM_TYPE_ETH,
338         RTE_FLOW_ITEM_TYPE_IPV4,
339         RTE_FLOW_ITEM_TYPE_UDP,
340         RTE_FLOW_ITEM_TYPE_VXLAN,
341         RTE_FLOW_ITEM_TYPE_IPV4,
342         RTE_FLOW_ITEM_TYPE_ICMP,
343         RTE_FLOW_ITEM_TYPE_END,
344 };
345
346 /* IPv4 VXLAN MAC IPv4 */
347 enum rte_flow_item_type pattern_eth_ipv4_udp_vxlan_eth_ipv4[] = {
348         RTE_FLOW_ITEM_TYPE_ETH,
349         RTE_FLOW_ITEM_TYPE_IPV4,
350         RTE_FLOW_ITEM_TYPE_UDP,
351         RTE_FLOW_ITEM_TYPE_VXLAN,
352         RTE_FLOW_ITEM_TYPE_ETH,
353         RTE_FLOW_ITEM_TYPE_IPV4,
354         RTE_FLOW_ITEM_TYPE_END,
355 };
356 enum rte_flow_item_type pattern_eth_ipv4_udp_vxlan_eth_ipv4_udp[] = {
357         RTE_FLOW_ITEM_TYPE_ETH,
358         RTE_FLOW_ITEM_TYPE_IPV4,
359         RTE_FLOW_ITEM_TYPE_UDP,
360         RTE_FLOW_ITEM_TYPE_VXLAN,
361         RTE_FLOW_ITEM_TYPE_ETH,
362         RTE_FLOW_ITEM_TYPE_IPV4,
363         RTE_FLOW_ITEM_TYPE_UDP,
364         RTE_FLOW_ITEM_TYPE_END,
365 };
366 enum rte_flow_item_type pattern_eth_ipv4_udp_vxlan_eth_ipv4_tcp[] = {
367         RTE_FLOW_ITEM_TYPE_ETH,
368         RTE_FLOW_ITEM_TYPE_IPV4,
369         RTE_FLOW_ITEM_TYPE_UDP,
370         RTE_FLOW_ITEM_TYPE_VXLAN,
371         RTE_FLOW_ITEM_TYPE_ETH,
372         RTE_FLOW_ITEM_TYPE_IPV4,
373         RTE_FLOW_ITEM_TYPE_TCP,
374         RTE_FLOW_ITEM_TYPE_END,
375 };
376 enum rte_flow_item_type pattern_eth_ipv4_udp_vxlan_eth_ipv4_sctp[] = {
377         RTE_FLOW_ITEM_TYPE_ETH,
378         RTE_FLOW_ITEM_TYPE_IPV4,
379         RTE_FLOW_ITEM_TYPE_UDP,
380         RTE_FLOW_ITEM_TYPE_VXLAN,
381         RTE_FLOW_ITEM_TYPE_ETH,
382         RTE_FLOW_ITEM_TYPE_IPV4,
383         RTE_FLOW_ITEM_TYPE_SCTP,
384         RTE_FLOW_ITEM_TYPE_END,
385 };
386 enum rte_flow_item_type pattern_eth_ipv4_udp_vxlan_eth_ipv4_icmp[] = {
387         RTE_FLOW_ITEM_TYPE_ETH,
388         RTE_FLOW_ITEM_TYPE_IPV4,
389         RTE_FLOW_ITEM_TYPE_UDP,
390         RTE_FLOW_ITEM_TYPE_VXLAN,
391         RTE_FLOW_ITEM_TYPE_ETH,
392         RTE_FLOW_ITEM_TYPE_IPV4,
393         RTE_FLOW_ITEM_TYPE_ICMP,
394         RTE_FLOW_ITEM_TYPE_END,
395 };
396
397 /* IPv6 VXLAN IPv4 */
398 enum rte_flow_item_type pattern_eth_ipv6_udp_vxlan_ipv4[] = {
399         RTE_FLOW_ITEM_TYPE_ETH,
400         RTE_FLOW_ITEM_TYPE_IPV6,
401         RTE_FLOW_ITEM_TYPE_UDP,
402         RTE_FLOW_ITEM_TYPE_VXLAN,
403         RTE_FLOW_ITEM_TYPE_IPV4,
404         RTE_FLOW_ITEM_TYPE_END,
405 };
406 enum rte_flow_item_type pattern_eth_ipv6_udp_vxlan_ipv4_tcp[] = {
407         RTE_FLOW_ITEM_TYPE_ETH,
408         RTE_FLOW_ITEM_TYPE_IPV6,
409         RTE_FLOW_ITEM_TYPE_UDP,
410         RTE_FLOW_ITEM_TYPE_VXLAN,
411         RTE_FLOW_ITEM_TYPE_IPV4,
412         RTE_FLOW_ITEM_TYPE_TCP,
413         RTE_FLOW_ITEM_TYPE_END,
414 };
415 enum rte_flow_item_type pattern_eth_ipv6_udp_vxlan_ipv4_udp[] = {
416         RTE_FLOW_ITEM_TYPE_ETH,
417         RTE_FLOW_ITEM_TYPE_IPV6,
418         RTE_FLOW_ITEM_TYPE_UDP,
419         RTE_FLOW_ITEM_TYPE_VXLAN,
420         RTE_FLOW_ITEM_TYPE_IPV4,
421         RTE_FLOW_ITEM_TYPE_UDP,
422         RTE_FLOW_ITEM_TYPE_END,
423 };
424 enum rte_flow_item_type pattern_eth_ipv6_udp_vxlan_ipv4_sctp[] = {
425         RTE_FLOW_ITEM_TYPE_ETH,
426         RTE_FLOW_ITEM_TYPE_IPV6,
427         RTE_FLOW_ITEM_TYPE_UDP,
428         RTE_FLOW_ITEM_TYPE_VXLAN,
429         RTE_FLOW_ITEM_TYPE_IPV4,
430         RTE_FLOW_ITEM_TYPE_SCTP,
431         RTE_FLOW_ITEM_TYPE_END,
432 };
433 enum rte_flow_item_type pattern_eth_ipv6_udp_vxlan_ipv4_icmp[] = {
434         RTE_FLOW_ITEM_TYPE_ETH,
435         RTE_FLOW_ITEM_TYPE_IPV6,
436         RTE_FLOW_ITEM_TYPE_UDP,
437         RTE_FLOW_ITEM_TYPE_VXLAN,
438         RTE_FLOW_ITEM_TYPE_IPV4,
439         RTE_FLOW_ITEM_TYPE_ICMP,
440         RTE_FLOW_ITEM_TYPE_END,
441 };
442
443 /* IPv6 VXLAN MAC IPv4 */
444 enum rte_flow_item_type pattern_eth_ipv6_udp_vxlan_eth_ipv4[] = {
445         RTE_FLOW_ITEM_TYPE_ETH,
446         RTE_FLOW_ITEM_TYPE_IPV6,
447         RTE_FLOW_ITEM_TYPE_UDP,
448         RTE_FLOW_ITEM_TYPE_VXLAN,
449         RTE_FLOW_ITEM_TYPE_ETH,
450         RTE_FLOW_ITEM_TYPE_IPV4,
451         RTE_FLOW_ITEM_TYPE_END,
452 };
453 enum rte_flow_item_type pattern_eth_ipv6_udp_vxlan_eth_ipv4_tcp[] = {
454         RTE_FLOW_ITEM_TYPE_ETH,
455         RTE_FLOW_ITEM_TYPE_IPV6,
456         RTE_FLOW_ITEM_TYPE_UDP,
457         RTE_FLOW_ITEM_TYPE_VXLAN,
458         RTE_FLOW_ITEM_TYPE_ETH,
459         RTE_FLOW_ITEM_TYPE_IPV4,
460         RTE_FLOW_ITEM_TYPE_TCP,
461         RTE_FLOW_ITEM_TYPE_END,
462 };
463 enum rte_flow_item_type pattern_eth_ipv6_udp_vxlan_eth_ipv4_udp[] = {
464         RTE_FLOW_ITEM_TYPE_ETH,
465         RTE_FLOW_ITEM_TYPE_IPV6,
466         RTE_FLOW_ITEM_TYPE_UDP,
467         RTE_FLOW_ITEM_TYPE_VXLAN,
468         RTE_FLOW_ITEM_TYPE_ETH,
469         RTE_FLOW_ITEM_TYPE_IPV4,
470         RTE_FLOW_ITEM_TYPE_UDP,
471         RTE_FLOW_ITEM_TYPE_END,
472 };
473 enum rte_flow_item_type pattern_eth_ipv6_udp_vxlan_eth_ipv4_sctp[] = {
474         RTE_FLOW_ITEM_TYPE_ETH,
475         RTE_FLOW_ITEM_TYPE_IPV6,
476         RTE_FLOW_ITEM_TYPE_UDP,
477         RTE_FLOW_ITEM_TYPE_VXLAN,
478         RTE_FLOW_ITEM_TYPE_ETH,
479         RTE_FLOW_ITEM_TYPE_IPV4,
480         RTE_FLOW_ITEM_TYPE_SCTP,
481         RTE_FLOW_ITEM_TYPE_END,
482 };
483 enum rte_flow_item_type pattern_eth_ipv6_udp_vxlan_eth_ipv4_icmp[] = {
484         RTE_FLOW_ITEM_TYPE_ETH,
485         RTE_FLOW_ITEM_TYPE_IPV6,
486         RTE_FLOW_ITEM_TYPE_UDP,
487         RTE_FLOW_ITEM_TYPE_VXLAN,
488         RTE_FLOW_ITEM_TYPE_ETH,
489         RTE_FLOW_ITEM_TYPE_IPV4,
490         RTE_FLOW_ITEM_TYPE_ICMP,
491         RTE_FLOW_ITEM_TYPE_END,
492 };
493
494 /* IPv4 VXLAN IPv6 */
495 enum rte_flow_item_type pattern_eth_ipv4_udp_vxlan_ipv6[] = {
496         RTE_FLOW_ITEM_TYPE_ETH,
497         RTE_FLOW_ITEM_TYPE_IPV4,
498         RTE_FLOW_ITEM_TYPE_UDP,
499         RTE_FLOW_ITEM_TYPE_VXLAN,
500         RTE_FLOW_ITEM_TYPE_IPV6,
501         RTE_FLOW_ITEM_TYPE_END,
502 };
503 enum rte_flow_item_type pattern_eth_ipv4_udp_vxlan_ipv6_udp[] = {
504         RTE_FLOW_ITEM_TYPE_ETH,
505         RTE_FLOW_ITEM_TYPE_IPV4,
506         RTE_FLOW_ITEM_TYPE_UDP,
507         RTE_FLOW_ITEM_TYPE_VXLAN,
508         RTE_FLOW_ITEM_TYPE_IPV6,
509         RTE_FLOW_ITEM_TYPE_UDP,
510         RTE_FLOW_ITEM_TYPE_END,
511 };
512 enum rte_flow_item_type pattern_eth_ipv4_udp_vxlan_ipv6_tcp[] = {
513         RTE_FLOW_ITEM_TYPE_ETH,
514         RTE_FLOW_ITEM_TYPE_IPV4,
515         RTE_FLOW_ITEM_TYPE_UDP,
516         RTE_FLOW_ITEM_TYPE_VXLAN,
517         RTE_FLOW_ITEM_TYPE_IPV6,
518         RTE_FLOW_ITEM_TYPE_TCP,
519         RTE_FLOW_ITEM_TYPE_END,
520 };
521 enum rte_flow_item_type pattern_eth_ipv4_udp_vxlan_ipv6_sctp[] = {
522         RTE_FLOW_ITEM_TYPE_ETH,
523         RTE_FLOW_ITEM_TYPE_IPV4,
524         RTE_FLOW_ITEM_TYPE_UDP,
525         RTE_FLOW_ITEM_TYPE_VXLAN,
526         RTE_FLOW_ITEM_TYPE_IPV6,
527         RTE_FLOW_ITEM_TYPE_SCTP,
528         RTE_FLOW_ITEM_TYPE_END,
529 };
530 enum rte_flow_item_type pattern_eth_ipv4_udp_vxlan_ipv6_icmp6[] = {
531         RTE_FLOW_ITEM_TYPE_ETH,
532         RTE_FLOW_ITEM_TYPE_IPV4,
533         RTE_FLOW_ITEM_TYPE_UDP,
534         RTE_FLOW_ITEM_TYPE_VXLAN,
535         RTE_FLOW_ITEM_TYPE_IPV6,
536         RTE_FLOW_ITEM_TYPE_ICMP6,
537         RTE_FLOW_ITEM_TYPE_END,
538 };
539
540 /* IPv4 VXLAN MAC IPv6 */
541 enum rte_flow_item_type pattern_eth_ipv4_udp_vxlan_eth_ipv6[] = {
542         RTE_FLOW_ITEM_TYPE_ETH,
543         RTE_FLOW_ITEM_TYPE_IPV4,
544         RTE_FLOW_ITEM_TYPE_UDP,
545         RTE_FLOW_ITEM_TYPE_VXLAN,
546         RTE_FLOW_ITEM_TYPE_ETH,
547         RTE_FLOW_ITEM_TYPE_IPV6,
548         RTE_FLOW_ITEM_TYPE_END,
549 };
550 enum rte_flow_item_type pattern_eth_ipv4_udp_vxlan_eth_ipv6_udp[] = {
551         RTE_FLOW_ITEM_TYPE_ETH,
552         RTE_FLOW_ITEM_TYPE_IPV4,
553         RTE_FLOW_ITEM_TYPE_UDP,
554         RTE_FLOW_ITEM_TYPE_VXLAN,
555         RTE_FLOW_ITEM_TYPE_ETH,
556         RTE_FLOW_ITEM_TYPE_IPV6,
557         RTE_FLOW_ITEM_TYPE_UDP,
558         RTE_FLOW_ITEM_TYPE_END,
559 };
560 enum rte_flow_item_type pattern_eth_ipv4_udp_vxlan_eth_ipv6_tcp[] = {
561         RTE_FLOW_ITEM_TYPE_ETH,
562         RTE_FLOW_ITEM_TYPE_IPV4,
563         RTE_FLOW_ITEM_TYPE_UDP,
564         RTE_FLOW_ITEM_TYPE_VXLAN,
565         RTE_FLOW_ITEM_TYPE_ETH,
566         RTE_FLOW_ITEM_TYPE_IPV6,
567         RTE_FLOW_ITEM_TYPE_TCP,
568         RTE_FLOW_ITEM_TYPE_END,
569 };
570 enum rte_flow_item_type pattern_eth_ipv4_udp_vxlan_eth_ipv6_sctp[] = {
571         RTE_FLOW_ITEM_TYPE_ETH,
572         RTE_FLOW_ITEM_TYPE_IPV4,
573         RTE_FLOW_ITEM_TYPE_UDP,
574         RTE_FLOW_ITEM_TYPE_VXLAN,
575         RTE_FLOW_ITEM_TYPE_ETH,
576         RTE_FLOW_ITEM_TYPE_IPV6,
577         RTE_FLOW_ITEM_TYPE_SCTP,
578         RTE_FLOW_ITEM_TYPE_END,
579 };
580 enum rte_flow_item_type pattern_eth_ipv4_udp_vxlan_eth_ipv6_icmp6[] = {
581         RTE_FLOW_ITEM_TYPE_ETH,
582         RTE_FLOW_ITEM_TYPE_IPV4,
583         RTE_FLOW_ITEM_TYPE_UDP,
584         RTE_FLOW_ITEM_TYPE_VXLAN,
585         RTE_FLOW_ITEM_TYPE_ETH,
586         RTE_FLOW_ITEM_TYPE_IPV6,
587         RTE_FLOW_ITEM_TYPE_ICMP6,
588         RTE_FLOW_ITEM_TYPE_END,
589 };
590
591 /* IPv6 VXLAN IPv6 */
592 enum rte_flow_item_type pattern_eth_ipv6_udp_vxlan_ipv6[] = {
593         RTE_FLOW_ITEM_TYPE_ETH,
594         RTE_FLOW_ITEM_TYPE_IPV6,
595         RTE_FLOW_ITEM_TYPE_UDP,
596         RTE_FLOW_ITEM_TYPE_VXLAN,
597         RTE_FLOW_ITEM_TYPE_IPV6,
598         RTE_FLOW_ITEM_TYPE_END,
599 };
600 enum rte_flow_item_type pattern_eth_ipv6_udp_vxlan_ipv6_tcp[] = {
601         RTE_FLOW_ITEM_TYPE_ETH,
602         RTE_FLOW_ITEM_TYPE_IPV6,
603         RTE_FLOW_ITEM_TYPE_UDP,
604         RTE_FLOW_ITEM_TYPE_VXLAN,
605         RTE_FLOW_ITEM_TYPE_IPV6,
606         RTE_FLOW_ITEM_TYPE_TCP,
607         RTE_FLOW_ITEM_TYPE_END,
608 };
609 enum rte_flow_item_type pattern_eth_ipv6_udp_vxlan_ipv6_udp[] = {
610         RTE_FLOW_ITEM_TYPE_ETH,
611         RTE_FLOW_ITEM_TYPE_IPV6,
612         RTE_FLOW_ITEM_TYPE_UDP,
613         RTE_FLOW_ITEM_TYPE_VXLAN,
614         RTE_FLOW_ITEM_TYPE_IPV6,
615         RTE_FLOW_ITEM_TYPE_UDP,
616         RTE_FLOW_ITEM_TYPE_END,
617 };
618 enum rte_flow_item_type pattern_eth_ipv6_udp_vxlan_ipv6_sctp[] = {
619         RTE_FLOW_ITEM_TYPE_ETH,
620         RTE_FLOW_ITEM_TYPE_IPV6,
621         RTE_FLOW_ITEM_TYPE_UDP,
622         RTE_FLOW_ITEM_TYPE_VXLAN,
623         RTE_FLOW_ITEM_TYPE_IPV6,
624         RTE_FLOW_ITEM_TYPE_SCTP,
625         RTE_FLOW_ITEM_TYPE_END,
626 };
627 enum rte_flow_item_type pattern_eth_ipv6_udp_vxlan_ipv6_icmp6[] = {
628         RTE_FLOW_ITEM_TYPE_ETH,
629         RTE_FLOW_ITEM_TYPE_IPV6,
630         RTE_FLOW_ITEM_TYPE_UDP,
631         RTE_FLOW_ITEM_TYPE_VXLAN,
632         RTE_FLOW_ITEM_TYPE_IPV6,
633         RTE_FLOW_ITEM_TYPE_ICMP6,
634         RTE_FLOW_ITEM_TYPE_END,
635 };
636
637 /* IPv6 VXLAN MAC IPv6 */
638 enum rte_flow_item_type pattern_eth_ipv6_udp_vxlan_eth_ipv6[] = {
639         RTE_FLOW_ITEM_TYPE_ETH,
640         RTE_FLOW_ITEM_TYPE_IPV6,
641         RTE_FLOW_ITEM_TYPE_UDP,
642         RTE_FLOW_ITEM_TYPE_VXLAN,
643         RTE_FLOW_ITEM_TYPE_ETH,
644         RTE_FLOW_ITEM_TYPE_IPV6,
645         RTE_FLOW_ITEM_TYPE_END,
646 };
647 enum rte_flow_item_type pattern_eth_ipv6_udp_vxlan_eth_ipv6_tcp[] = {
648         RTE_FLOW_ITEM_TYPE_ETH,
649         RTE_FLOW_ITEM_TYPE_IPV6,
650         RTE_FLOW_ITEM_TYPE_UDP,
651         RTE_FLOW_ITEM_TYPE_VXLAN,
652         RTE_FLOW_ITEM_TYPE_ETH,
653         RTE_FLOW_ITEM_TYPE_IPV6,
654         RTE_FLOW_ITEM_TYPE_TCP,
655         RTE_FLOW_ITEM_TYPE_END,
656 };
657 enum rte_flow_item_type pattern_eth_ipv6_udp_vxlan_eth_ipv6_udp[] = {
658         RTE_FLOW_ITEM_TYPE_ETH,
659         RTE_FLOW_ITEM_TYPE_IPV6,
660         RTE_FLOW_ITEM_TYPE_UDP,
661         RTE_FLOW_ITEM_TYPE_VXLAN,
662         RTE_FLOW_ITEM_TYPE_ETH,
663         RTE_FLOW_ITEM_TYPE_IPV6,
664         RTE_FLOW_ITEM_TYPE_UDP,
665         RTE_FLOW_ITEM_TYPE_END,
666 };
667 enum rte_flow_item_type pattern_eth_ipv6_udp_vxlan_eth_ipv6_sctp[] = {
668         RTE_FLOW_ITEM_TYPE_ETH,
669         RTE_FLOW_ITEM_TYPE_IPV6,
670         RTE_FLOW_ITEM_TYPE_UDP,
671         RTE_FLOW_ITEM_TYPE_VXLAN,
672         RTE_FLOW_ITEM_TYPE_ETH,
673         RTE_FLOW_ITEM_TYPE_IPV6,
674         RTE_FLOW_ITEM_TYPE_SCTP,
675         RTE_FLOW_ITEM_TYPE_END,
676 };
677 enum rte_flow_item_type pattern_eth_ipv6_udp_vxlan_eth_ipv6_icmp6[] = {
678         RTE_FLOW_ITEM_TYPE_ETH,
679         RTE_FLOW_ITEM_TYPE_IPV6,
680         RTE_FLOW_ITEM_TYPE_UDP,
681         RTE_FLOW_ITEM_TYPE_VXLAN,
682         RTE_FLOW_ITEM_TYPE_ETH,
683         RTE_FLOW_ITEM_TYPE_IPV6,
684         RTE_FLOW_ITEM_TYPE_ICMP6,
685         RTE_FLOW_ITEM_TYPE_END,
686 };
687
688 /* IPv4 NVGRE IPv4 */
689 enum rte_flow_item_type pattern_eth_ipv4_nvgre_ipv4[] = {
690         RTE_FLOW_ITEM_TYPE_ETH,
691         RTE_FLOW_ITEM_TYPE_IPV4,
692         RTE_FLOW_ITEM_TYPE_NVGRE,
693         RTE_FLOW_ITEM_TYPE_IPV4,
694         RTE_FLOW_ITEM_TYPE_END,
695 };
696 enum rte_flow_item_type pattern_eth_ipv4_nvgre_ipv4_udp[] = {
697         RTE_FLOW_ITEM_TYPE_ETH,
698         RTE_FLOW_ITEM_TYPE_IPV4,
699         RTE_FLOW_ITEM_TYPE_NVGRE,
700         RTE_FLOW_ITEM_TYPE_IPV4,
701         RTE_FLOW_ITEM_TYPE_UDP,
702         RTE_FLOW_ITEM_TYPE_END,
703 };
704 enum rte_flow_item_type pattern_eth_ipv4_nvgre_ipv4_tcp[] = {
705         RTE_FLOW_ITEM_TYPE_ETH,
706         RTE_FLOW_ITEM_TYPE_IPV4,
707         RTE_FLOW_ITEM_TYPE_NVGRE,
708         RTE_FLOW_ITEM_TYPE_IPV4,
709         RTE_FLOW_ITEM_TYPE_TCP,
710         RTE_FLOW_ITEM_TYPE_END,
711 };
712 enum rte_flow_item_type pattern_eth_ipv4_nvgre_ipv4_sctp[] = {
713         RTE_FLOW_ITEM_TYPE_ETH,
714         RTE_FLOW_ITEM_TYPE_IPV4,
715         RTE_FLOW_ITEM_TYPE_NVGRE,
716         RTE_FLOW_ITEM_TYPE_IPV4,
717         RTE_FLOW_ITEM_TYPE_SCTP,
718         RTE_FLOW_ITEM_TYPE_END,
719 };
720 enum rte_flow_item_type pattern_eth_ipv4_nvgre_ipv4_icmp[] = {
721         RTE_FLOW_ITEM_TYPE_ETH,
722         RTE_FLOW_ITEM_TYPE_IPV4,
723         RTE_FLOW_ITEM_TYPE_NVGRE,
724         RTE_FLOW_ITEM_TYPE_IPV4,
725         RTE_FLOW_ITEM_TYPE_ICMP,
726         RTE_FLOW_ITEM_TYPE_END,
727 };
728
729 /* IPv4 NVGRE MAC IPv4 */
730 enum rte_flow_item_type pattern_eth_ipv4_nvgre_eth_ipv4[] = {
731         RTE_FLOW_ITEM_TYPE_ETH,
732         RTE_FLOW_ITEM_TYPE_IPV4,
733         RTE_FLOW_ITEM_TYPE_NVGRE,
734         RTE_FLOW_ITEM_TYPE_ETH,
735         RTE_FLOW_ITEM_TYPE_IPV4,
736         RTE_FLOW_ITEM_TYPE_END,
737 };
738 enum rte_flow_item_type pattern_eth_ipv4_nvgre_eth_ipv4_udp[] = {
739         RTE_FLOW_ITEM_TYPE_ETH,
740         RTE_FLOW_ITEM_TYPE_IPV4,
741         RTE_FLOW_ITEM_TYPE_NVGRE,
742         RTE_FLOW_ITEM_TYPE_ETH,
743         RTE_FLOW_ITEM_TYPE_IPV4,
744         RTE_FLOW_ITEM_TYPE_UDP,
745         RTE_FLOW_ITEM_TYPE_END,
746 };
747 enum rte_flow_item_type pattern_eth_ipv4_nvgre_eth_ipv4_tcp[] = {
748         RTE_FLOW_ITEM_TYPE_ETH,
749         RTE_FLOW_ITEM_TYPE_IPV4,
750         RTE_FLOW_ITEM_TYPE_NVGRE,
751         RTE_FLOW_ITEM_TYPE_ETH,
752         RTE_FLOW_ITEM_TYPE_IPV4,
753         RTE_FLOW_ITEM_TYPE_TCP,
754         RTE_FLOW_ITEM_TYPE_END,
755 };
756 enum rte_flow_item_type pattern_eth_ipv4_nvgre_eth_ipv4_sctp[] = {
757         RTE_FLOW_ITEM_TYPE_ETH,
758         RTE_FLOW_ITEM_TYPE_IPV4,
759         RTE_FLOW_ITEM_TYPE_NVGRE,
760         RTE_FLOW_ITEM_TYPE_ETH,
761         RTE_FLOW_ITEM_TYPE_IPV4,
762         RTE_FLOW_ITEM_TYPE_SCTP,
763         RTE_FLOW_ITEM_TYPE_END,
764 };
765 enum rte_flow_item_type pattern_eth_ipv4_nvgre_eth_ipv4_icmp[] = {
766         RTE_FLOW_ITEM_TYPE_ETH,
767         RTE_FLOW_ITEM_TYPE_IPV4,
768         RTE_FLOW_ITEM_TYPE_NVGRE,
769         RTE_FLOW_ITEM_TYPE_ETH,
770         RTE_FLOW_ITEM_TYPE_IPV4,
771         RTE_FLOW_ITEM_TYPE_ICMP,
772         RTE_FLOW_ITEM_TYPE_END,
773 };
774
775 /* IPv6 NVGRE IPv4 */
776 enum rte_flow_item_type pattern_eth_ipv6_nvgre_ipv4[] = {
777         RTE_FLOW_ITEM_TYPE_ETH,
778         RTE_FLOW_ITEM_TYPE_IPV6,
779         RTE_FLOW_ITEM_TYPE_NVGRE,
780         RTE_FLOW_ITEM_TYPE_IPV4,
781         RTE_FLOW_ITEM_TYPE_END,
782 };
783 enum rte_flow_item_type pattern_eth_ipv6_nvgre_ipv4_tcp[] = {
784         RTE_FLOW_ITEM_TYPE_ETH,
785         RTE_FLOW_ITEM_TYPE_IPV6,
786         RTE_FLOW_ITEM_TYPE_NVGRE,
787         RTE_FLOW_ITEM_TYPE_IPV4,
788         RTE_FLOW_ITEM_TYPE_TCP,
789         RTE_FLOW_ITEM_TYPE_END,
790 };
791 enum rte_flow_item_type pattern_eth_ipv6_nvgre_ipv4_udp[] = {
792         RTE_FLOW_ITEM_TYPE_ETH,
793         RTE_FLOW_ITEM_TYPE_IPV6,
794         RTE_FLOW_ITEM_TYPE_NVGRE,
795         RTE_FLOW_ITEM_TYPE_IPV4,
796         RTE_FLOW_ITEM_TYPE_UDP,
797         RTE_FLOW_ITEM_TYPE_END,
798 };
799 enum rte_flow_item_type pattern_eth_ipv6_nvgre_ipv4_sctp[] = {
800         RTE_FLOW_ITEM_TYPE_ETH,
801         RTE_FLOW_ITEM_TYPE_IPV6,
802         RTE_FLOW_ITEM_TYPE_NVGRE,
803         RTE_FLOW_ITEM_TYPE_IPV4,
804         RTE_FLOW_ITEM_TYPE_SCTP,
805         RTE_FLOW_ITEM_TYPE_END,
806 };
807 enum rte_flow_item_type pattern_eth_ipv6_nvgre_ipv4_icmp[] = {
808         RTE_FLOW_ITEM_TYPE_ETH,
809         RTE_FLOW_ITEM_TYPE_IPV6,
810         RTE_FLOW_ITEM_TYPE_NVGRE,
811         RTE_FLOW_ITEM_TYPE_IPV4,
812         RTE_FLOW_ITEM_TYPE_ICMP,
813         RTE_FLOW_ITEM_TYPE_END,
814 };
815
816 /* IPv6 NVGRE MAC IPv4 */
817 enum rte_flow_item_type pattern_eth_ipv6_nvgre_eth_ipv4[] = {
818         RTE_FLOW_ITEM_TYPE_ETH,
819         RTE_FLOW_ITEM_TYPE_IPV6,
820         RTE_FLOW_ITEM_TYPE_NVGRE,
821         RTE_FLOW_ITEM_TYPE_ETH,
822         RTE_FLOW_ITEM_TYPE_IPV4,
823         RTE_FLOW_ITEM_TYPE_END,
824 };
825 enum rte_flow_item_type pattern_eth_ipv6_nvgre_eth_ipv4_tcp[] = {
826         RTE_FLOW_ITEM_TYPE_ETH,
827         RTE_FLOW_ITEM_TYPE_IPV6,
828         RTE_FLOW_ITEM_TYPE_NVGRE,
829         RTE_FLOW_ITEM_TYPE_ETH,
830         RTE_FLOW_ITEM_TYPE_IPV4,
831         RTE_FLOW_ITEM_TYPE_TCP,
832         RTE_FLOW_ITEM_TYPE_END,
833 };
834 enum rte_flow_item_type pattern_eth_ipv6_nvgre_eth_ipv4_udp[] = {
835         RTE_FLOW_ITEM_TYPE_ETH,
836         RTE_FLOW_ITEM_TYPE_IPV6,
837         RTE_FLOW_ITEM_TYPE_NVGRE,
838         RTE_FLOW_ITEM_TYPE_ETH,
839         RTE_FLOW_ITEM_TYPE_IPV4,
840         RTE_FLOW_ITEM_TYPE_UDP,
841         RTE_FLOW_ITEM_TYPE_END,
842 };
843 enum rte_flow_item_type pattern_eth_ipv6_nvgre_eth_ipv4_sctp[] = {
844         RTE_FLOW_ITEM_TYPE_ETH,
845         RTE_FLOW_ITEM_TYPE_IPV6,
846         RTE_FLOW_ITEM_TYPE_NVGRE,
847         RTE_FLOW_ITEM_TYPE_ETH,
848         RTE_FLOW_ITEM_TYPE_IPV4,
849         RTE_FLOW_ITEM_TYPE_SCTP,
850         RTE_FLOW_ITEM_TYPE_END,
851 };
852 enum rte_flow_item_type pattern_eth_ipv6_nvgre_eth_ipv4_icmp[] = {
853         RTE_FLOW_ITEM_TYPE_ETH,
854         RTE_FLOW_ITEM_TYPE_IPV6,
855         RTE_FLOW_ITEM_TYPE_NVGRE,
856         RTE_FLOW_ITEM_TYPE_ETH,
857         RTE_FLOW_ITEM_TYPE_IPV4,
858         RTE_FLOW_ITEM_TYPE_ICMP,
859         RTE_FLOW_ITEM_TYPE_END,
860 };
861
862 /* IPv4 NVGRE IPv6 */
863 enum rte_flow_item_type pattern_eth_ipv4_nvgre_ipv6[] = {
864         RTE_FLOW_ITEM_TYPE_ETH,
865         RTE_FLOW_ITEM_TYPE_IPV4,
866         RTE_FLOW_ITEM_TYPE_NVGRE,
867         RTE_FLOW_ITEM_TYPE_IPV6,
868         RTE_FLOW_ITEM_TYPE_END,
869 };
870 enum rte_flow_item_type pattern_eth_ipv4_nvgre_ipv6_udp[] = {
871         RTE_FLOW_ITEM_TYPE_ETH,
872         RTE_FLOW_ITEM_TYPE_IPV4,
873         RTE_FLOW_ITEM_TYPE_NVGRE,
874         RTE_FLOW_ITEM_TYPE_IPV6,
875         RTE_FLOW_ITEM_TYPE_UDP,
876         RTE_FLOW_ITEM_TYPE_END,
877 };
878 enum rte_flow_item_type pattern_eth_ipv4_nvgre_ipv6_tcp[] = {
879         RTE_FLOW_ITEM_TYPE_ETH,
880         RTE_FLOW_ITEM_TYPE_IPV4,
881         RTE_FLOW_ITEM_TYPE_NVGRE,
882         RTE_FLOW_ITEM_TYPE_IPV6,
883         RTE_FLOW_ITEM_TYPE_TCP,
884         RTE_FLOW_ITEM_TYPE_END,
885 };
886 enum rte_flow_item_type pattern_eth_ipv4_nvgre_ipv6_sctp[] = {
887         RTE_FLOW_ITEM_TYPE_ETH,
888         RTE_FLOW_ITEM_TYPE_IPV4,
889         RTE_FLOW_ITEM_TYPE_NVGRE,
890         RTE_FLOW_ITEM_TYPE_IPV6,
891         RTE_FLOW_ITEM_TYPE_SCTP,
892         RTE_FLOW_ITEM_TYPE_END,
893 };
894 enum rte_flow_item_type pattern_eth_ipv4_nvgre_ipv6_icmp6[] = {
895         RTE_FLOW_ITEM_TYPE_ETH,
896         RTE_FLOW_ITEM_TYPE_IPV4,
897         RTE_FLOW_ITEM_TYPE_NVGRE,
898         RTE_FLOW_ITEM_TYPE_IPV6,
899         RTE_FLOW_ITEM_TYPE_ICMP6,
900         RTE_FLOW_ITEM_TYPE_END,
901 };
902
903 /* IPv4 NVGRE MAC IPv6 */
904 enum rte_flow_item_type pattern_eth_ipv4_nvgre_eth_ipv6[] = {
905         RTE_FLOW_ITEM_TYPE_ETH,
906         RTE_FLOW_ITEM_TYPE_IPV4,
907         RTE_FLOW_ITEM_TYPE_NVGRE,
908         RTE_FLOW_ITEM_TYPE_ETH,
909         RTE_FLOW_ITEM_TYPE_IPV6,
910         RTE_FLOW_ITEM_TYPE_END,
911 };
912 enum rte_flow_item_type pattern_eth_ipv4_nvgre_eth_ipv6_udp[] = {
913         RTE_FLOW_ITEM_TYPE_ETH,
914         RTE_FLOW_ITEM_TYPE_IPV4,
915         RTE_FLOW_ITEM_TYPE_NVGRE,
916         RTE_FLOW_ITEM_TYPE_ETH,
917         RTE_FLOW_ITEM_TYPE_IPV6,
918         RTE_FLOW_ITEM_TYPE_UDP,
919         RTE_FLOW_ITEM_TYPE_END,
920 };
921 enum rte_flow_item_type pattern_eth_ipv4_nvgre_eth_ipv6_tcp[] = {
922         RTE_FLOW_ITEM_TYPE_ETH,
923         RTE_FLOW_ITEM_TYPE_IPV4,
924         RTE_FLOW_ITEM_TYPE_NVGRE,
925         RTE_FLOW_ITEM_TYPE_ETH,
926         RTE_FLOW_ITEM_TYPE_IPV6,
927         RTE_FLOW_ITEM_TYPE_TCP,
928         RTE_FLOW_ITEM_TYPE_END,
929 };
930 enum rte_flow_item_type pattern_eth_ipv4_nvgre_eth_ipv6_sctp[] = {
931         RTE_FLOW_ITEM_TYPE_ETH,
932         RTE_FLOW_ITEM_TYPE_IPV4,
933         RTE_FLOW_ITEM_TYPE_NVGRE,
934         RTE_FLOW_ITEM_TYPE_ETH,
935         RTE_FLOW_ITEM_TYPE_IPV6,
936         RTE_FLOW_ITEM_TYPE_SCTP,
937         RTE_FLOW_ITEM_TYPE_END,
938 };
939 enum rte_flow_item_type pattern_eth_ipv4_nvgre_eth_ipv6_icmp6[] = {
940         RTE_FLOW_ITEM_TYPE_ETH,
941         RTE_FLOW_ITEM_TYPE_IPV4,
942         RTE_FLOW_ITEM_TYPE_NVGRE,
943         RTE_FLOW_ITEM_TYPE_ETH,
944         RTE_FLOW_ITEM_TYPE_IPV6,
945         RTE_FLOW_ITEM_TYPE_ICMP6,
946         RTE_FLOW_ITEM_TYPE_END,
947 };
948
949 /* IPv6 NVGRE IPv6 */
950 enum rte_flow_item_type pattern_eth_ipv6_nvgre_ipv6[] = {
951         RTE_FLOW_ITEM_TYPE_ETH,
952         RTE_FLOW_ITEM_TYPE_IPV6,
953         RTE_FLOW_ITEM_TYPE_NVGRE,
954         RTE_FLOW_ITEM_TYPE_IPV6,
955         RTE_FLOW_ITEM_TYPE_END,
956 };
957 enum rte_flow_item_type pattern_eth_ipv6_nvgre_ipv6_tcp[] = {
958         RTE_FLOW_ITEM_TYPE_ETH,
959         RTE_FLOW_ITEM_TYPE_IPV6,
960         RTE_FLOW_ITEM_TYPE_NVGRE,
961         RTE_FLOW_ITEM_TYPE_IPV6,
962         RTE_FLOW_ITEM_TYPE_TCP,
963         RTE_FLOW_ITEM_TYPE_END,
964 };
965 enum rte_flow_item_type pattern_eth_ipv6_nvgre_ipv6_udp[] = {
966         RTE_FLOW_ITEM_TYPE_ETH,
967         RTE_FLOW_ITEM_TYPE_IPV6,
968         RTE_FLOW_ITEM_TYPE_NVGRE,
969         RTE_FLOW_ITEM_TYPE_IPV6,
970         RTE_FLOW_ITEM_TYPE_UDP,
971         RTE_FLOW_ITEM_TYPE_END,
972 };
973 enum rte_flow_item_type pattern_eth_ipv6_nvgre_ipv6_sctp[] = {
974         RTE_FLOW_ITEM_TYPE_ETH,
975         RTE_FLOW_ITEM_TYPE_IPV6,
976         RTE_FLOW_ITEM_TYPE_NVGRE,
977         RTE_FLOW_ITEM_TYPE_IPV6,
978         RTE_FLOW_ITEM_TYPE_SCTP,
979         RTE_FLOW_ITEM_TYPE_END,
980 };
981 enum rte_flow_item_type pattern_eth_ipv6_nvgre_ipv6_icmp6[] = {
982         RTE_FLOW_ITEM_TYPE_ETH,
983         RTE_FLOW_ITEM_TYPE_IPV6,
984         RTE_FLOW_ITEM_TYPE_NVGRE,
985         RTE_FLOW_ITEM_TYPE_IPV6,
986         RTE_FLOW_ITEM_TYPE_ICMP6,
987         RTE_FLOW_ITEM_TYPE_END,
988 };
989
990 /* IPv6 NVGRE MAC IPv6 */
991 enum rte_flow_item_type pattern_eth_ipv6_nvgre_eth_ipv6[] = {
992         RTE_FLOW_ITEM_TYPE_ETH,
993         RTE_FLOW_ITEM_TYPE_IPV6,
994         RTE_FLOW_ITEM_TYPE_NVGRE,
995         RTE_FLOW_ITEM_TYPE_ETH,
996         RTE_FLOW_ITEM_TYPE_IPV6,
997         RTE_FLOW_ITEM_TYPE_END,
998 };
999 enum rte_flow_item_type pattern_eth_ipv6_nvgre_eth_ipv6_tcp[] = {
1000         RTE_FLOW_ITEM_TYPE_ETH,
1001         RTE_FLOW_ITEM_TYPE_IPV6,
1002         RTE_FLOW_ITEM_TYPE_NVGRE,
1003         RTE_FLOW_ITEM_TYPE_ETH,
1004         RTE_FLOW_ITEM_TYPE_IPV6,
1005         RTE_FLOW_ITEM_TYPE_TCP,
1006         RTE_FLOW_ITEM_TYPE_END,
1007 };
1008 enum rte_flow_item_type pattern_eth_ipv6_nvgre_eth_ipv6_udp[] = {
1009         RTE_FLOW_ITEM_TYPE_ETH,
1010         RTE_FLOW_ITEM_TYPE_IPV6,
1011         RTE_FLOW_ITEM_TYPE_NVGRE,
1012         RTE_FLOW_ITEM_TYPE_ETH,
1013         RTE_FLOW_ITEM_TYPE_IPV6,
1014         RTE_FLOW_ITEM_TYPE_UDP,
1015         RTE_FLOW_ITEM_TYPE_END,
1016 };
1017 enum rte_flow_item_type pattern_eth_ipv6_nvgre_eth_ipv6_sctp[] = {
1018         RTE_FLOW_ITEM_TYPE_ETH,
1019         RTE_FLOW_ITEM_TYPE_IPV6,
1020         RTE_FLOW_ITEM_TYPE_NVGRE,
1021         RTE_FLOW_ITEM_TYPE_ETH,
1022         RTE_FLOW_ITEM_TYPE_IPV6,
1023         RTE_FLOW_ITEM_TYPE_SCTP,
1024         RTE_FLOW_ITEM_TYPE_END,
1025 };
1026 enum rte_flow_item_type pattern_eth_ipv6_nvgre_eth_ipv6_icmp6[] = {
1027         RTE_FLOW_ITEM_TYPE_ETH,
1028         RTE_FLOW_ITEM_TYPE_IPV6,
1029         RTE_FLOW_ITEM_TYPE_NVGRE,
1030         RTE_FLOW_ITEM_TYPE_ETH,
1031         RTE_FLOW_ITEM_TYPE_IPV6,
1032         RTE_FLOW_ITEM_TYPE_ICMP6,
1033         RTE_FLOW_ITEM_TYPE_END,
1034 };
1035
1036 /* GTPU */
1037 enum rte_flow_item_type pattern_eth_ipv4_gtpu[] = {
1038         RTE_FLOW_ITEM_TYPE_ETH,
1039         RTE_FLOW_ITEM_TYPE_IPV4,
1040         RTE_FLOW_ITEM_TYPE_UDP,
1041         RTE_FLOW_ITEM_TYPE_GTPU,
1042         RTE_FLOW_ITEM_TYPE_END,
1043 };
1044 enum rte_flow_item_type pattern_eth_ipv4_gtpu_ipv4[] = {
1045         RTE_FLOW_ITEM_TYPE_ETH,
1046         RTE_FLOW_ITEM_TYPE_IPV4,
1047         RTE_FLOW_ITEM_TYPE_UDP,
1048         RTE_FLOW_ITEM_TYPE_GTPU,
1049         RTE_FLOW_ITEM_TYPE_IPV4,
1050         RTE_FLOW_ITEM_TYPE_END,
1051 };
1052 enum rte_flow_item_type pattern_eth_ipv4_gtpu_eh[] = {
1053         RTE_FLOW_ITEM_TYPE_ETH,
1054         RTE_FLOW_ITEM_TYPE_IPV4,
1055         RTE_FLOW_ITEM_TYPE_UDP,
1056         RTE_FLOW_ITEM_TYPE_GTPU,
1057         RTE_FLOW_ITEM_TYPE_GTP_PSC,
1058         RTE_FLOW_ITEM_TYPE_END,
1059 };
1060 enum rte_flow_item_type pattern_eth_ipv4_gtpu_eh_ipv4[] = {
1061         RTE_FLOW_ITEM_TYPE_ETH,
1062         RTE_FLOW_ITEM_TYPE_IPV4,
1063         RTE_FLOW_ITEM_TYPE_UDP,
1064         RTE_FLOW_ITEM_TYPE_GTPU,
1065         RTE_FLOW_ITEM_TYPE_GTP_PSC,
1066         RTE_FLOW_ITEM_TYPE_IPV4,
1067         RTE_FLOW_ITEM_TYPE_END,
1068 };
1069 enum rte_flow_item_type pattern_eth_ipv4_gtpu_eh_ipv4_udp[] = {
1070         RTE_FLOW_ITEM_TYPE_ETH,
1071         RTE_FLOW_ITEM_TYPE_IPV4,
1072         RTE_FLOW_ITEM_TYPE_UDP,
1073         RTE_FLOW_ITEM_TYPE_GTPU,
1074         RTE_FLOW_ITEM_TYPE_GTP_PSC,
1075         RTE_FLOW_ITEM_TYPE_IPV4,
1076         RTE_FLOW_ITEM_TYPE_UDP,
1077         RTE_FLOW_ITEM_TYPE_END,
1078 };
1079 enum rte_flow_item_type pattern_eth_ipv4_gtpu_eh_ipv4_tcp[] = {
1080         RTE_FLOW_ITEM_TYPE_ETH,
1081         RTE_FLOW_ITEM_TYPE_IPV4,
1082         RTE_FLOW_ITEM_TYPE_UDP,
1083         RTE_FLOW_ITEM_TYPE_GTPU,
1084         RTE_FLOW_ITEM_TYPE_GTP_PSC,
1085         RTE_FLOW_ITEM_TYPE_IPV4,
1086         RTE_FLOW_ITEM_TYPE_TCP,
1087         RTE_FLOW_ITEM_TYPE_END,
1088
1089 };
1090 enum rte_flow_item_type pattern_eth_ipv4_gtpu_eh_ipv4_icmp[] = {
1091         RTE_FLOW_ITEM_TYPE_ETH,
1092         RTE_FLOW_ITEM_TYPE_IPV4,
1093         RTE_FLOW_ITEM_TYPE_UDP,
1094         RTE_FLOW_ITEM_TYPE_GTPU,
1095         RTE_FLOW_ITEM_TYPE_GTP_PSC,
1096         RTE_FLOW_ITEM_TYPE_IPV4,
1097         RTE_FLOW_ITEM_TYPE_ICMP,
1098         RTE_FLOW_ITEM_TYPE_END,
1099 };
1100
1101 /* PPPoE */
1102 enum rte_flow_item_type pattern_eth_pppoed[] = {
1103         RTE_FLOW_ITEM_TYPE_ETH,
1104         RTE_FLOW_ITEM_TYPE_PPPOED,
1105         RTE_FLOW_ITEM_TYPE_END,
1106 };
1107 enum rte_flow_item_type pattern_eth_vlan_pppoed[] = {
1108         RTE_FLOW_ITEM_TYPE_ETH,
1109         RTE_FLOW_ITEM_TYPE_VLAN,
1110         RTE_FLOW_ITEM_TYPE_PPPOED,
1111         RTE_FLOW_ITEM_TYPE_END,
1112 };
1113 enum rte_flow_item_type pattern_eth_qinq_pppoed[] = {
1114         RTE_FLOW_ITEM_TYPE_ETH,
1115         RTE_FLOW_ITEM_TYPE_VLAN,
1116         RTE_FLOW_ITEM_TYPE_VLAN,
1117         RTE_FLOW_ITEM_TYPE_PPPOED,
1118         RTE_FLOW_ITEM_TYPE_END,
1119 };
1120 enum rte_flow_item_type pattern_eth_pppoes[] = {
1121         RTE_FLOW_ITEM_TYPE_ETH,
1122         RTE_FLOW_ITEM_TYPE_PPPOES,
1123         RTE_FLOW_ITEM_TYPE_END,
1124 };
1125 enum rte_flow_item_type pattern_eth_vlan_pppoes[] = {
1126         RTE_FLOW_ITEM_TYPE_ETH,
1127         RTE_FLOW_ITEM_TYPE_VLAN,
1128         RTE_FLOW_ITEM_TYPE_PPPOES,
1129         RTE_FLOW_ITEM_TYPE_END,
1130 };
1131 enum rte_flow_item_type pattern_eth_qinq_pppoes[] = {
1132         RTE_FLOW_ITEM_TYPE_ETH,
1133         RTE_FLOW_ITEM_TYPE_VLAN,
1134         RTE_FLOW_ITEM_TYPE_VLAN,
1135         RTE_FLOW_ITEM_TYPE_PPPOES,
1136         RTE_FLOW_ITEM_TYPE_END,
1137 };
1138 enum rte_flow_item_type pattern_eth_pppoes_ipv4[] = {
1139         RTE_FLOW_ITEM_TYPE_ETH,
1140         RTE_FLOW_ITEM_TYPE_PPPOES,
1141         RTE_FLOW_ITEM_TYPE_IPV4,
1142         RTE_FLOW_ITEM_TYPE_END,
1143 };
1144 enum rte_flow_item_type pattern_eth_vlan_pppoes_ipv4[] = {
1145         RTE_FLOW_ITEM_TYPE_ETH,
1146         RTE_FLOW_ITEM_TYPE_VLAN,
1147         RTE_FLOW_ITEM_TYPE_PPPOES,
1148         RTE_FLOW_ITEM_TYPE_IPV4,
1149         RTE_FLOW_ITEM_TYPE_END,
1150 };
1151 enum rte_flow_item_type pattern_eth_qinq_pppoes_ipv4[] = {
1152         RTE_FLOW_ITEM_TYPE_ETH,
1153         RTE_FLOW_ITEM_TYPE_VLAN,
1154         RTE_FLOW_ITEM_TYPE_VLAN,
1155         RTE_FLOW_ITEM_TYPE_PPPOES,
1156         RTE_FLOW_ITEM_TYPE_IPV4,
1157         RTE_FLOW_ITEM_TYPE_END,
1158 };
1159 enum rte_flow_item_type pattern_eth_pppoes_ipv4_udp[] = {
1160         RTE_FLOW_ITEM_TYPE_ETH,
1161         RTE_FLOW_ITEM_TYPE_PPPOES,
1162         RTE_FLOW_ITEM_TYPE_IPV4,
1163         RTE_FLOW_ITEM_TYPE_UDP,
1164         RTE_FLOW_ITEM_TYPE_END,
1165 };
1166 enum rte_flow_item_type pattern_eth_vlan_pppoes_ipv4_udp[] = {
1167         RTE_FLOW_ITEM_TYPE_ETH,
1168         RTE_FLOW_ITEM_TYPE_VLAN,
1169         RTE_FLOW_ITEM_TYPE_PPPOES,
1170         RTE_FLOW_ITEM_TYPE_IPV4,
1171         RTE_FLOW_ITEM_TYPE_UDP,
1172         RTE_FLOW_ITEM_TYPE_END,
1173 };
1174 enum rte_flow_item_type pattern_eth_qinq_pppoes_ipv4_udp[] = {
1175         RTE_FLOW_ITEM_TYPE_ETH,
1176         RTE_FLOW_ITEM_TYPE_VLAN,
1177         RTE_FLOW_ITEM_TYPE_VLAN,
1178         RTE_FLOW_ITEM_TYPE_PPPOES,
1179         RTE_FLOW_ITEM_TYPE_IPV4,
1180         RTE_FLOW_ITEM_TYPE_UDP,
1181         RTE_FLOW_ITEM_TYPE_END,
1182 };
1183 enum rte_flow_item_type pattern_eth_pppoes_ipv4_tcp[] = {
1184         RTE_FLOW_ITEM_TYPE_ETH,
1185         RTE_FLOW_ITEM_TYPE_PPPOES,
1186         RTE_FLOW_ITEM_TYPE_IPV4,
1187         RTE_FLOW_ITEM_TYPE_TCP,
1188         RTE_FLOW_ITEM_TYPE_END,
1189 };
1190 enum rte_flow_item_type pattern_eth_vlan_pppoes_ipv4_tcp[] = {
1191         RTE_FLOW_ITEM_TYPE_ETH,
1192         RTE_FLOW_ITEM_TYPE_VLAN,
1193         RTE_FLOW_ITEM_TYPE_PPPOES,
1194         RTE_FLOW_ITEM_TYPE_IPV4,
1195         RTE_FLOW_ITEM_TYPE_TCP,
1196         RTE_FLOW_ITEM_TYPE_END,
1197 };
1198 enum rte_flow_item_type pattern_eth_qinq_pppoes_ipv4_tcp[] = {
1199         RTE_FLOW_ITEM_TYPE_ETH,
1200         RTE_FLOW_ITEM_TYPE_VLAN,
1201         RTE_FLOW_ITEM_TYPE_VLAN,
1202         RTE_FLOW_ITEM_TYPE_PPPOES,
1203         RTE_FLOW_ITEM_TYPE_IPV4,
1204         RTE_FLOW_ITEM_TYPE_TCP,
1205         RTE_FLOW_ITEM_TYPE_END,
1206 };
1207 enum rte_flow_item_type pattern_eth_pppoes_ipv4_sctp[] = {
1208         RTE_FLOW_ITEM_TYPE_ETH,
1209         RTE_FLOW_ITEM_TYPE_PPPOES,
1210         RTE_FLOW_ITEM_TYPE_IPV4,
1211         RTE_FLOW_ITEM_TYPE_SCTP,
1212         RTE_FLOW_ITEM_TYPE_END,
1213 };
1214 enum rte_flow_item_type pattern_eth_vlan_pppoes_ipv4_sctp[] = {
1215         RTE_FLOW_ITEM_TYPE_ETH,
1216         RTE_FLOW_ITEM_TYPE_VLAN,
1217         RTE_FLOW_ITEM_TYPE_PPPOES,
1218         RTE_FLOW_ITEM_TYPE_IPV4,
1219         RTE_FLOW_ITEM_TYPE_SCTP,
1220         RTE_FLOW_ITEM_TYPE_END,
1221 };
1222 enum rte_flow_item_type pattern_eth_qinq_pppoes_ipv4_sctp[] = {
1223         RTE_FLOW_ITEM_TYPE_ETH,
1224         RTE_FLOW_ITEM_TYPE_VLAN,
1225         RTE_FLOW_ITEM_TYPE_VLAN,
1226         RTE_FLOW_ITEM_TYPE_PPPOES,
1227         RTE_FLOW_ITEM_TYPE_IPV4,
1228         RTE_FLOW_ITEM_TYPE_SCTP,
1229         RTE_FLOW_ITEM_TYPE_END,
1230 };
1231 enum rte_flow_item_type pattern_eth_pppoes_ipv4_icmp[] = {
1232         RTE_FLOW_ITEM_TYPE_ETH,
1233         RTE_FLOW_ITEM_TYPE_PPPOES,
1234         RTE_FLOW_ITEM_TYPE_IPV4,
1235         RTE_FLOW_ITEM_TYPE_ICMP,
1236         RTE_FLOW_ITEM_TYPE_END,
1237 };
1238 enum rte_flow_item_type pattern_eth_vlan_pppoes_ipv4_icmp[] = {
1239         RTE_FLOW_ITEM_TYPE_ETH,
1240         RTE_FLOW_ITEM_TYPE_VLAN,
1241         RTE_FLOW_ITEM_TYPE_PPPOES,
1242         RTE_FLOW_ITEM_TYPE_IPV4,
1243         RTE_FLOW_ITEM_TYPE_ICMP,
1244         RTE_FLOW_ITEM_TYPE_END,
1245 };
1246 enum rte_flow_item_type pattern_eth_qinq_pppoes_ipv4_icmp[] = {
1247         RTE_FLOW_ITEM_TYPE_ETH,
1248         RTE_FLOW_ITEM_TYPE_VLAN,
1249         RTE_FLOW_ITEM_TYPE_VLAN,
1250         RTE_FLOW_ITEM_TYPE_PPPOES,
1251         RTE_FLOW_ITEM_TYPE_IPV4,
1252         RTE_FLOW_ITEM_TYPE_ICMP,
1253         RTE_FLOW_ITEM_TYPE_END,
1254 };
1255 enum rte_flow_item_type pattern_eth_pppoes_ipv6[] = {
1256         RTE_FLOW_ITEM_TYPE_ETH,
1257         RTE_FLOW_ITEM_TYPE_PPPOES,
1258         RTE_FLOW_ITEM_TYPE_IPV6,
1259         RTE_FLOW_ITEM_TYPE_END,
1260 };
1261 enum rte_flow_item_type pattern_eth_vlan_pppoes_ipv6[] = {
1262         RTE_FLOW_ITEM_TYPE_ETH,
1263         RTE_FLOW_ITEM_TYPE_VLAN,
1264         RTE_FLOW_ITEM_TYPE_PPPOES,
1265         RTE_FLOW_ITEM_TYPE_IPV6,
1266         RTE_FLOW_ITEM_TYPE_END,
1267 };
1268 enum rte_flow_item_type pattern_eth_qinq_pppoes_ipv6[] = {
1269         RTE_FLOW_ITEM_TYPE_ETH,
1270         RTE_FLOW_ITEM_TYPE_VLAN,
1271         RTE_FLOW_ITEM_TYPE_VLAN,
1272         RTE_FLOW_ITEM_TYPE_PPPOES,
1273         RTE_FLOW_ITEM_TYPE_IPV6,
1274         RTE_FLOW_ITEM_TYPE_END,
1275 };
1276 enum rte_flow_item_type pattern_eth_pppoes_ipv6_udp[] = {
1277         RTE_FLOW_ITEM_TYPE_ETH,
1278         RTE_FLOW_ITEM_TYPE_PPPOES,
1279         RTE_FLOW_ITEM_TYPE_IPV6,
1280         RTE_FLOW_ITEM_TYPE_UDP,
1281         RTE_FLOW_ITEM_TYPE_END,
1282 };
1283 enum rte_flow_item_type pattern_eth_vlan_pppoes_ipv6_udp[] = {
1284         RTE_FLOW_ITEM_TYPE_ETH,
1285         RTE_FLOW_ITEM_TYPE_VLAN,
1286         RTE_FLOW_ITEM_TYPE_PPPOES,
1287         RTE_FLOW_ITEM_TYPE_IPV6,
1288         RTE_FLOW_ITEM_TYPE_UDP,
1289         RTE_FLOW_ITEM_TYPE_END,
1290 };
1291 enum rte_flow_item_type pattern_eth_qinq_pppoes_ipv6_udp[] = {
1292         RTE_FLOW_ITEM_TYPE_ETH,
1293         RTE_FLOW_ITEM_TYPE_VLAN,
1294         RTE_FLOW_ITEM_TYPE_VLAN,
1295         RTE_FLOW_ITEM_TYPE_PPPOES,
1296         RTE_FLOW_ITEM_TYPE_IPV6,
1297         RTE_FLOW_ITEM_TYPE_UDP,
1298         RTE_FLOW_ITEM_TYPE_END,
1299 };
1300 enum rte_flow_item_type pattern_eth_pppoes_ipv6_tcp[] = {
1301         RTE_FLOW_ITEM_TYPE_ETH,
1302         RTE_FLOW_ITEM_TYPE_PPPOES,
1303         RTE_FLOW_ITEM_TYPE_IPV6,
1304         RTE_FLOW_ITEM_TYPE_TCP,
1305         RTE_FLOW_ITEM_TYPE_END,
1306 };
1307 enum rte_flow_item_type pattern_eth_vlan_pppoes_ipv6_tcp[] = {
1308         RTE_FLOW_ITEM_TYPE_ETH,
1309         RTE_FLOW_ITEM_TYPE_VLAN,
1310         RTE_FLOW_ITEM_TYPE_PPPOES,
1311         RTE_FLOW_ITEM_TYPE_IPV6,
1312         RTE_FLOW_ITEM_TYPE_TCP,
1313         RTE_FLOW_ITEM_TYPE_END,
1314 };
1315 enum rte_flow_item_type pattern_eth_qinq_pppoes_ipv6_tcp[] = {
1316         RTE_FLOW_ITEM_TYPE_ETH,
1317         RTE_FLOW_ITEM_TYPE_VLAN,
1318         RTE_FLOW_ITEM_TYPE_VLAN,
1319         RTE_FLOW_ITEM_TYPE_PPPOES,
1320         RTE_FLOW_ITEM_TYPE_IPV6,
1321         RTE_FLOW_ITEM_TYPE_TCP,
1322         RTE_FLOW_ITEM_TYPE_END,
1323 };
1324 enum rte_flow_item_type pattern_eth_pppoes_ipv6_sctp[] = {
1325         RTE_FLOW_ITEM_TYPE_ETH,
1326         RTE_FLOW_ITEM_TYPE_PPPOES,
1327         RTE_FLOW_ITEM_TYPE_IPV6,
1328         RTE_FLOW_ITEM_TYPE_SCTP,
1329         RTE_FLOW_ITEM_TYPE_END,
1330 };
1331 enum rte_flow_item_type pattern_eth_vlan_pppoes_ipv6_sctp[] = {
1332         RTE_FLOW_ITEM_TYPE_ETH,
1333         RTE_FLOW_ITEM_TYPE_VLAN,
1334         RTE_FLOW_ITEM_TYPE_PPPOES,
1335         RTE_FLOW_ITEM_TYPE_IPV6,
1336         RTE_FLOW_ITEM_TYPE_SCTP,
1337         RTE_FLOW_ITEM_TYPE_END,
1338 };
1339 enum rte_flow_item_type pattern_eth_qinq_pppoes_ipv6_sctp[] = {
1340         RTE_FLOW_ITEM_TYPE_ETH,
1341         RTE_FLOW_ITEM_TYPE_VLAN,
1342         RTE_FLOW_ITEM_TYPE_VLAN,
1343         RTE_FLOW_ITEM_TYPE_PPPOES,
1344         RTE_FLOW_ITEM_TYPE_IPV6,
1345         RTE_FLOW_ITEM_TYPE_SCTP,
1346         RTE_FLOW_ITEM_TYPE_END,
1347 };
1348 enum rte_flow_item_type pattern_eth_pppoes_ipv6_icmp6[] = {
1349         RTE_FLOW_ITEM_TYPE_ETH,
1350         RTE_FLOW_ITEM_TYPE_PPPOES,
1351         RTE_FLOW_ITEM_TYPE_IPV6,
1352         RTE_FLOW_ITEM_TYPE_ICMP6,
1353         RTE_FLOW_ITEM_TYPE_END,
1354 };
1355 enum rte_flow_item_type pattern_eth_vlan_pppoes_ipv6_icmp6[] = {
1356         RTE_FLOW_ITEM_TYPE_ETH,
1357         RTE_FLOW_ITEM_TYPE_VLAN,
1358         RTE_FLOW_ITEM_TYPE_PPPOES,
1359         RTE_FLOW_ITEM_TYPE_IPV6,
1360         RTE_FLOW_ITEM_TYPE_ICMP6,
1361         RTE_FLOW_ITEM_TYPE_END,
1362 };
1363 enum rte_flow_item_type pattern_eth_qinq_pppoes_ipv6_icmp6[] = {
1364         RTE_FLOW_ITEM_TYPE_ETH,
1365         RTE_FLOW_ITEM_TYPE_VLAN,
1366         RTE_FLOW_ITEM_TYPE_VLAN,
1367         RTE_FLOW_ITEM_TYPE_PPPOES,
1368         RTE_FLOW_ITEM_TYPE_IPV6,
1369         RTE_FLOW_ITEM_TYPE_ICMP6,
1370         RTE_FLOW_ITEM_TYPE_END,
1371 };
1372
1373 typedef struct ice_flow_engine * (*parse_engine_t)(struct ice_adapter *ad,
1374                 struct rte_flow *flow,
1375                 struct ice_parser_list *parser_list,
1376                 const struct rte_flow_item pattern[],
1377                 const struct rte_flow_action actions[],
1378                 struct rte_flow_error *error);
1379
1380 void
1381 ice_register_flow_engine(struct ice_flow_engine *engine)
1382 {
1383         TAILQ_INSERT_TAIL(&engine_list, engine, node);
1384 }
1385
1386 int
1387 ice_flow_init(struct ice_adapter *ad)
1388 {
1389         int ret;
1390         struct ice_pf *pf = &ad->pf;
1391         void *temp;
1392         struct ice_flow_engine *engine;
1393
1394         TAILQ_INIT(&pf->flow_list);
1395         TAILQ_INIT(&pf->rss_parser_list);
1396         TAILQ_INIT(&pf->perm_parser_list);
1397         TAILQ_INIT(&pf->dist_parser_list);
1398         rte_spinlock_init(&pf->flow_ops_lock);
1399
1400         TAILQ_FOREACH_SAFE(engine, &engine_list, node, temp) {
1401                 if (engine->init == NULL) {
1402                         PMD_INIT_LOG(ERR, "Invalid engine type (%d)",
1403                                         engine->type);
1404                         return -ENOTSUP;
1405                 }
1406
1407                 ret = engine->init(ad);
1408                 if (ret) {
1409                         PMD_INIT_LOG(ERR, "Failed to initialize engine %d",
1410                                         engine->type);
1411                         return ret;
1412                 }
1413         }
1414         return 0;
1415 }
1416
1417 void
1418 ice_flow_uninit(struct ice_adapter *ad)
1419 {
1420         struct ice_pf *pf = &ad->pf;
1421         struct ice_flow_engine *engine;
1422         struct rte_flow *p_flow;
1423         struct ice_flow_parser_node *p_parser;
1424         void *temp;
1425
1426         TAILQ_FOREACH_SAFE(engine, &engine_list, node, temp) {
1427                 if (engine->uninit)
1428                         engine->uninit(ad);
1429         }
1430
1431         /* Remove all flows */
1432         while ((p_flow = TAILQ_FIRST(&pf->flow_list))) {
1433                 TAILQ_REMOVE(&pf->flow_list, p_flow, node);
1434                 if (p_flow->engine->free)
1435                         p_flow->engine->free(p_flow);
1436                 rte_free(p_flow);
1437         }
1438
1439         /* Cleanup parser list */
1440         while ((p_parser = TAILQ_FIRST(&pf->rss_parser_list))) {
1441                 TAILQ_REMOVE(&pf->rss_parser_list, p_parser, node);
1442                 rte_free(p_parser);
1443         }
1444
1445         while ((p_parser = TAILQ_FIRST(&pf->perm_parser_list))) {
1446                 TAILQ_REMOVE(&pf->perm_parser_list, p_parser, node);
1447                 rte_free(p_parser);
1448         }
1449
1450         while ((p_parser = TAILQ_FIRST(&pf->dist_parser_list))) {
1451                 TAILQ_REMOVE(&pf->dist_parser_list, p_parser, node);
1452                 rte_free(p_parser);
1453         }
1454 }
1455
1456 static struct ice_parser_list *
1457 ice_get_parser_list(struct ice_flow_parser *parser,
1458                 struct ice_adapter *ad)
1459 {
1460         struct ice_parser_list *list;
1461         struct ice_pf *pf = &ad->pf;
1462
1463         switch (parser->stage) {
1464         case ICE_FLOW_STAGE_RSS:
1465                 list = &pf->rss_parser_list;
1466                 break;
1467         case ICE_FLOW_STAGE_PERMISSION:
1468                 list = &pf->perm_parser_list;
1469                 break;
1470         case ICE_FLOW_STAGE_DISTRIBUTOR:
1471                 list = &pf->dist_parser_list;
1472                 break;
1473         default:
1474                 return NULL;
1475         }
1476
1477         return list;
1478 }
1479
1480 int
1481 ice_register_parser(struct ice_flow_parser *parser,
1482                 struct ice_adapter *ad)
1483 {
1484         struct ice_parser_list *list;
1485         struct ice_flow_parser_node *parser_node;
1486
1487         parser_node = rte_zmalloc("ice_parser", sizeof(*parser_node), 0);
1488         if (parser_node == NULL) {
1489                 PMD_DRV_LOG(ERR, "Failed to allocate memory.");
1490                 return -ENOMEM;
1491         }
1492         parser_node->parser = parser;
1493
1494         list = ice_get_parser_list(parser, ad);
1495         if (list == NULL)
1496                 return -EINVAL;
1497
1498         if (ad->devargs.pipe_mode_support) {
1499                 TAILQ_INSERT_TAIL(list, parser_node, node);
1500         } else {
1501                 if (parser->engine->type == ICE_FLOW_ENGINE_SWITCH ||
1502                                 parser->engine->type == ICE_FLOW_ENGINE_HASH)
1503                         TAILQ_INSERT_TAIL(list, parser_node, node);
1504                 else if (parser->engine->type == ICE_FLOW_ENGINE_FDIR)
1505                         TAILQ_INSERT_HEAD(list, parser_node, node);
1506                 else
1507                         return -EINVAL;
1508         }
1509         return 0;
1510 }
1511
1512 void
1513 ice_unregister_parser(struct ice_flow_parser *parser,
1514                 struct ice_adapter *ad)
1515 {
1516         struct ice_parser_list *list;
1517         struct ice_flow_parser_node *p_parser;
1518         void *temp;
1519
1520         list = ice_get_parser_list(parser, ad);
1521         if (list == NULL)
1522                 return;
1523
1524         TAILQ_FOREACH_SAFE(p_parser, list, node, temp) {
1525                 if (p_parser->parser->engine->type == parser->engine->type) {
1526                         TAILQ_REMOVE(list, p_parser, node);
1527                         rte_free(p_parser);
1528                 }
1529         }
1530 }
1531
1532 static int
1533 ice_flow_valid_attr(struct ice_adapter *ad,
1534                 const struct rte_flow_attr *attr,
1535                 int *ice_pipeline_stage,
1536                 struct rte_flow_error *error)
1537 {
1538         /* Must be input direction */
1539         if (!attr->ingress) {
1540                 rte_flow_error_set(error, EINVAL,
1541                                 RTE_FLOW_ERROR_TYPE_ATTR_INGRESS,
1542                                 attr, "Only support ingress.");
1543                 return -rte_errno;
1544         }
1545
1546         /* Not supported */
1547         if (attr->egress) {
1548                 rte_flow_error_set(error, EINVAL,
1549                                 RTE_FLOW_ERROR_TYPE_ATTR_EGRESS,
1550                                 attr, "Not support egress.");
1551                 return -rte_errno;
1552         }
1553
1554         /* Check pipeline mode support to set classification stage */
1555         if (ad->devargs.pipe_mode_support) {
1556                 if (attr->priority == 0)
1557                         *ice_pipeline_stage =
1558                                 ICE_FLOW_CLASSIFY_STAGE_PERMISSION;
1559                 else
1560                         *ice_pipeline_stage =
1561                                 ICE_FLOW_CLASSIFY_STAGE_DISTRIBUTOR;
1562         } else {
1563                 *ice_pipeline_stage =
1564                         ICE_FLOW_CLASSIFY_STAGE_DISTRIBUTOR_ONLY;
1565                 /* Not supported */
1566                 if (attr->priority) {
1567                         rte_flow_error_set(error, EINVAL,
1568                                         RTE_FLOW_ERROR_TYPE_ATTR_PRIORITY,
1569                                         attr, "Not support priority.");
1570                         return -rte_errno;
1571                 }
1572         }
1573
1574         /* Not supported */
1575         if (attr->group) {
1576                 rte_flow_error_set(error, EINVAL,
1577                                 RTE_FLOW_ERROR_TYPE_ATTR_GROUP,
1578                                 attr, "Not support group.");
1579                 return -rte_errno;
1580         }
1581
1582         return 0;
1583 }
1584
1585 /* Find the first VOID or non-VOID item pointer */
1586 static const struct rte_flow_item *
1587 ice_find_first_item(const struct rte_flow_item *item, bool is_void)
1588 {
1589         bool is_find;
1590
1591         while (item->type != RTE_FLOW_ITEM_TYPE_END) {
1592                 if (is_void)
1593                         is_find = item->type == RTE_FLOW_ITEM_TYPE_VOID;
1594                 else
1595                         is_find = item->type != RTE_FLOW_ITEM_TYPE_VOID;
1596                 if (is_find)
1597                         break;
1598                 item++;
1599         }
1600         return item;
1601 }
1602
1603 /* Skip all VOID items of the pattern */
1604 static void
1605 ice_pattern_skip_void_item(struct rte_flow_item *items,
1606                         const struct rte_flow_item *pattern)
1607 {
1608         uint32_t cpy_count = 0;
1609         const struct rte_flow_item *pb = pattern, *pe = pattern;
1610
1611         for (;;) {
1612                 /* Find a non-void item first */
1613                 pb = ice_find_first_item(pb, false);
1614                 if (pb->type == RTE_FLOW_ITEM_TYPE_END) {
1615                         pe = pb;
1616                         break;
1617                 }
1618
1619                 /* Find a void item */
1620                 pe = ice_find_first_item(pb + 1, true);
1621
1622                 cpy_count = pe - pb;
1623                 rte_memcpy(items, pb, sizeof(struct rte_flow_item) * cpy_count);
1624
1625                 items += cpy_count;
1626
1627                 if (pe->type == RTE_FLOW_ITEM_TYPE_END) {
1628                         break;
1629                 }
1630
1631                 pb = pe + 1;
1632         }
1633         /* Copy the END item. */
1634         rte_memcpy(items, pe, sizeof(struct rte_flow_item));
1635 }
1636
1637 /* Check if the pattern matches a supported item type array */
1638 static bool
1639 ice_match_pattern(enum rte_flow_item_type *item_array,
1640                 const struct rte_flow_item *pattern)
1641 {
1642         const struct rte_flow_item *item = pattern;
1643
1644         while ((*item_array == item->type) &&
1645                (*item_array != RTE_FLOW_ITEM_TYPE_END)) {
1646                 item_array++;
1647                 item++;
1648         }
1649
1650         return (*item_array == RTE_FLOW_ITEM_TYPE_END &&
1651                 item->type == RTE_FLOW_ITEM_TYPE_END);
1652 }
1653
1654 struct ice_pattern_match_item *
1655 ice_search_pattern_match_item(const struct rte_flow_item pattern[],
1656                 struct ice_pattern_match_item *array,
1657                 uint32_t array_len,
1658                 struct rte_flow_error *error)
1659 {
1660         uint16_t i = 0;
1661         struct ice_pattern_match_item *pattern_match_item;
1662         /* need free by each filter */
1663         struct rte_flow_item *items; /* used for pattern without VOID items */
1664         uint32_t item_num = 0; /* non-void item number */
1665
1666         /* Get the non-void item number of pattern */
1667         while ((pattern + i)->type != RTE_FLOW_ITEM_TYPE_END) {
1668                 if ((pattern + i)->type != RTE_FLOW_ITEM_TYPE_VOID)
1669                         item_num++;
1670                 i++;
1671         }
1672         item_num++;
1673
1674         items = rte_zmalloc("ice_pattern",
1675                             item_num * sizeof(struct rte_flow_item), 0);
1676         if (!items) {
1677                 rte_flow_error_set(error, ENOMEM, RTE_FLOW_ERROR_TYPE_ITEM_NUM,
1678                                    NULL, "No memory for PMD internal items.");
1679                 return NULL;
1680         }
1681         pattern_match_item = rte_zmalloc("ice_pattern_match_item",
1682                         sizeof(struct ice_pattern_match_item), 0);
1683         if (!pattern_match_item) {
1684                 rte_flow_error_set(error, ENOMEM, RTE_FLOW_ERROR_TYPE_HANDLE,
1685                                 NULL, "Failed to allocate memory.");
1686                 return NULL;
1687         }
1688
1689         ice_pattern_skip_void_item(items, pattern);
1690
1691         for (i = 0; i < array_len; i++)
1692                 if (ice_match_pattern(array[i].pattern_list,
1693                                         items)) {
1694                         pattern_match_item->input_set_mask =
1695                                 array[i].input_set_mask;
1696                         pattern_match_item->pattern_list =
1697                                 array[i].pattern_list;
1698                         pattern_match_item->meta = array[i].meta;
1699                         rte_free(items);
1700                         return pattern_match_item;
1701                 }
1702         rte_flow_error_set(error, EINVAL, RTE_FLOW_ERROR_TYPE_ITEM,
1703                            pattern, "Unsupported pattern");
1704
1705         rte_free(items);
1706         rte_free(pattern_match_item);
1707         return NULL;
1708 }
1709
1710 static struct ice_flow_engine *
1711 ice_parse_engine_create(struct ice_adapter *ad,
1712                 struct rte_flow *flow,
1713                 struct ice_parser_list *parser_list,
1714                 const struct rte_flow_item pattern[],
1715                 const struct rte_flow_action actions[],
1716                 struct rte_flow_error *error)
1717 {
1718         struct ice_flow_engine *engine = NULL;
1719         struct ice_flow_parser_node *parser_node;
1720         void *meta = NULL;
1721         void *temp;
1722
1723         TAILQ_FOREACH_SAFE(parser_node, parser_list, node, temp) {
1724                 int ret;
1725
1726                 if (parser_node->parser->parse_pattern_action(ad,
1727                                 parser_node->parser->array,
1728                                 parser_node->parser->array_len,
1729                                 pattern, actions, &meta, error) < 0)
1730                         continue;
1731
1732                 engine = parser_node->parser->engine;
1733                 RTE_ASSERT(engine->create != NULL);
1734                 ret = engine->create(ad, flow, meta, error);
1735                 if (ret == 0)
1736                         return engine;
1737                 else if (ret == -EEXIST)
1738                         return NULL;
1739         }
1740         return NULL;
1741 }
1742
1743 static struct ice_flow_engine *
1744 ice_parse_engine_validate(struct ice_adapter *ad,
1745                 struct rte_flow *flow __rte_unused,
1746                 struct ice_parser_list *parser_list,
1747                 const struct rte_flow_item pattern[],
1748                 const struct rte_flow_action actions[],
1749                 struct rte_flow_error *error)
1750 {
1751         struct ice_flow_engine *engine = NULL;
1752         struct ice_flow_parser_node *parser_node;
1753         void *temp;
1754
1755         TAILQ_FOREACH_SAFE(parser_node, parser_list, node, temp) {
1756                 if (parser_node->parser->parse_pattern_action(ad,
1757                                 parser_node->parser->array,
1758                                 parser_node->parser->array_len,
1759                                 pattern, actions, NULL, error) < 0)
1760                         continue;
1761
1762                 engine = parser_node->parser->engine;
1763                 break;
1764         }
1765         return engine;
1766 }
1767
1768 static int
1769 ice_flow_process_filter(struct rte_eth_dev *dev,
1770                 struct rte_flow *flow,
1771                 const struct rte_flow_attr *attr,
1772                 const struct rte_flow_item pattern[],
1773                 const struct rte_flow_action actions[],
1774                 struct ice_flow_engine **engine,
1775                 parse_engine_t ice_parse_engine,
1776                 struct rte_flow_error *error)
1777 {
1778         int ret = ICE_ERR_NOT_SUPPORTED;
1779         struct ice_adapter *ad =
1780                 ICE_DEV_PRIVATE_TO_ADAPTER(dev->data->dev_private);
1781         struct ice_pf *pf = ICE_DEV_PRIVATE_TO_PF(dev->data->dev_private);
1782         int ice_pipeline_stage = 0;
1783
1784         if (!pattern) {
1785                 rte_flow_error_set(error, EINVAL, RTE_FLOW_ERROR_TYPE_ITEM_NUM,
1786                                    NULL, "NULL pattern.");
1787                 return -rte_errno;
1788         }
1789
1790         if (!actions) {
1791                 rte_flow_error_set(error, EINVAL,
1792                                    RTE_FLOW_ERROR_TYPE_ACTION_NUM,
1793                                    NULL, "NULL action.");
1794                 return -rte_errno;
1795         }
1796
1797         if (!attr) {
1798                 rte_flow_error_set(error, EINVAL,
1799                                    RTE_FLOW_ERROR_TYPE_ATTR,
1800                                    NULL, "NULL attribute.");
1801                 return -rte_errno;
1802         }
1803
1804         ret = ice_flow_valid_attr(ad, attr, &ice_pipeline_stage, error);
1805         if (ret)
1806                 return ret;
1807
1808         *engine = ice_parse_engine(ad, flow, &pf->rss_parser_list,
1809                         pattern, actions, error);
1810         if (*engine != NULL)
1811                 return 0;
1812
1813         switch (ice_pipeline_stage) {
1814         case ICE_FLOW_CLASSIFY_STAGE_DISTRIBUTOR_ONLY:
1815         case ICE_FLOW_CLASSIFY_STAGE_DISTRIBUTOR:
1816                 *engine = ice_parse_engine(ad, flow, &pf->dist_parser_list,
1817                                 pattern, actions, error);
1818                 break;
1819         case ICE_FLOW_CLASSIFY_STAGE_PERMISSION:
1820                 *engine = ice_parse_engine(ad, flow, &pf->perm_parser_list,
1821                                 pattern, actions, error);
1822                 break;
1823         default:
1824                 return -EINVAL;
1825         }
1826
1827         if (*engine == NULL)
1828                 return -EINVAL;
1829
1830         return 0;
1831 }
1832
1833 static int
1834 ice_flow_validate(struct rte_eth_dev *dev,
1835                 const struct rte_flow_attr *attr,
1836                 const struct rte_flow_item pattern[],
1837                 const struct rte_flow_action actions[],
1838                 struct rte_flow_error *error)
1839 {
1840         struct ice_flow_engine *engine;
1841
1842         return ice_flow_process_filter(dev, NULL, attr, pattern, actions,
1843                         &engine, ice_parse_engine_validate, error);
1844 }
1845
1846 static struct rte_flow *
1847 ice_flow_create(struct rte_eth_dev *dev,
1848                 const struct rte_flow_attr *attr,
1849                 const struct rte_flow_item pattern[],
1850                 const struct rte_flow_action actions[],
1851                 struct rte_flow_error *error)
1852 {
1853         struct ice_pf *pf = ICE_DEV_PRIVATE_TO_PF(dev->data->dev_private);
1854         struct rte_flow *flow = NULL;
1855         int ret;
1856         struct ice_flow_engine *engine = NULL;
1857
1858         flow = rte_zmalloc("ice_flow", sizeof(struct rte_flow), 0);
1859         if (!flow) {
1860                 rte_flow_error_set(error, ENOMEM,
1861                                    RTE_FLOW_ERROR_TYPE_HANDLE, NULL,
1862                                    "Failed to allocate memory");
1863                 return flow;
1864         }
1865
1866         rte_spinlock_lock(&pf->flow_ops_lock);
1867
1868         ret = ice_flow_process_filter(dev, flow, attr, pattern, actions,
1869                         &engine, ice_parse_engine_create, error);
1870         if (ret < 0) {
1871                 PMD_DRV_LOG(ERR, "Failed to create flow");
1872                 rte_free(flow);
1873                 flow = NULL;
1874                 goto out;
1875         }
1876
1877         flow->engine = engine;
1878         TAILQ_INSERT_TAIL(&pf->flow_list, flow, node);
1879         PMD_DRV_LOG(INFO, "Succeeded to create (%d) flow", engine->type);
1880
1881 out:
1882         rte_spinlock_unlock(&pf->flow_ops_lock);
1883         return flow;
1884 }
1885
1886 static int
1887 ice_flow_destroy(struct rte_eth_dev *dev,
1888                 struct rte_flow *flow,
1889                 struct rte_flow_error *error)
1890 {
1891         struct ice_pf *pf = ICE_DEV_PRIVATE_TO_PF(dev->data->dev_private);
1892         struct ice_adapter *ad =
1893                 ICE_DEV_PRIVATE_TO_ADAPTER(dev->data->dev_private);
1894         int ret = 0;
1895
1896         if (!flow || !flow->engine || !flow->engine->destroy) {
1897                 rte_flow_error_set(error, EINVAL,
1898                                 RTE_FLOW_ERROR_TYPE_HANDLE,
1899                                 NULL, "Invalid flow");
1900                 return -rte_errno;
1901         }
1902
1903         rte_spinlock_lock(&pf->flow_ops_lock);
1904
1905         ret = flow->engine->destroy(ad, flow, error);
1906         if (!ret) {
1907                 TAILQ_REMOVE(&pf->flow_list, flow, node);
1908                 rte_free(flow);
1909         } else {
1910                 PMD_DRV_LOG(ERR, "Failed to destroy flow");
1911         }
1912
1913         rte_spinlock_unlock(&pf->flow_ops_lock);
1914
1915         return ret;
1916 }
1917
1918 static int
1919 ice_flow_flush(struct rte_eth_dev *dev,
1920                 struct rte_flow_error *error)
1921 {
1922         struct ice_pf *pf = ICE_DEV_PRIVATE_TO_PF(dev->data->dev_private);
1923         struct rte_flow *p_flow;
1924         void *temp;
1925         int ret = 0;
1926
1927         TAILQ_FOREACH_SAFE(p_flow, &pf->flow_list, node, temp) {
1928                 ret = ice_flow_destroy(dev, p_flow, error);
1929                 if (ret) {
1930                         PMD_DRV_LOG(ERR, "Failed to flush flows");
1931                         return -EINVAL;
1932                 }
1933         }
1934
1935         return ret;
1936 }
1937
1938 static int
1939 ice_flow_query(struct rte_eth_dev *dev,
1940                 struct rte_flow *flow,
1941                 const struct rte_flow_action *actions,
1942                 void *data,
1943                 struct rte_flow_error *error)
1944 {
1945         int ret = -EINVAL;
1946         struct ice_adapter *ad =
1947                 ICE_DEV_PRIVATE_TO_ADAPTER(dev->data->dev_private);
1948         struct rte_flow_query_count *count = data;
1949         struct ice_pf *pf = &ad->pf;
1950
1951         if (!flow || !flow->engine || !flow->engine->query_count) {
1952                 rte_flow_error_set(error, EINVAL,
1953                                 RTE_FLOW_ERROR_TYPE_HANDLE,
1954                                 NULL, "Invalid flow");
1955                 return -rte_errno;
1956         }
1957
1958         rte_spinlock_lock(&pf->flow_ops_lock);
1959
1960         for (; actions->type != RTE_FLOW_ACTION_TYPE_END; actions++) {
1961                 switch (actions->type) {
1962                 case RTE_FLOW_ACTION_TYPE_VOID:
1963                         break;
1964                 case RTE_FLOW_ACTION_TYPE_COUNT:
1965                         ret = flow->engine->query_count(ad, flow, count, error);
1966                         break;
1967                 default:
1968                         return rte_flow_error_set(error, ENOTSUP,
1969                                         RTE_FLOW_ERROR_TYPE_ACTION,
1970                                         actions,
1971                                         "action not supported");
1972                 }
1973         }
1974
1975         rte_spinlock_unlock(&pf->flow_ops_lock);
1976
1977         return ret;
1978 }
1979
1980 int
1981 ice_flow_redirect(struct ice_adapter *ad,
1982                   struct ice_flow_redirect *rd)
1983 {
1984         struct ice_pf *pf = &ad->pf;
1985         struct rte_flow *p_flow;
1986         void *temp;
1987         int ret;
1988
1989         rte_spinlock_lock(&pf->flow_ops_lock);
1990
1991         TAILQ_FOREACH_SAFE(p_flow, &pf->flow_list, node, temp) {
1992                 if (!p_flow->engine->redirect)
1993                         continue;
1994                 ret = p_flow->engine->redirect(ad, p_flow, rd);
1995                 if (ret) {
1996                         PMD_DRV_LOG(ERR, "Failed to redirect flows");
1997                         return ret;
1998                 }
1999         }
2000
2001         rte_spinlock_unlock(&pf->flow_ops_lock);
2002
2003         return 0;
2004 }