common/sfc_efx/base: implement Tx control path for Riverhead
[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 /*IPv4 GTPU (EH) */
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
1045 enum rte_flow_item_type pattern_eth_ipv4_gtpu_eh[] = {
1046         RTE_FLOW_ITEM_TYPE_ETH,
1047         RTE_FLOW_ITEM_TYPE_IPV4,
1048         RTE_FLOW_ITEM_TYPE_UDP,
1049         RTE_FLOW_ITEM_TYPE_GTPU,
1050         RTE_FLOW_ITEM_TYPE_GTP_PSC,
1051         RTE_FLOW_ITEM_TYPE_END,
1052 };
1053
1054 /*IPv6 GTPU (EH) */
1055 enum rte_flow_item_type pattern_eth_ipv6_gtpu[] = {
1056         RTE_FLOW_ITEM_TYPE_ETH,
1057         RTE_FLOW_ITEM_TYPE_IPV6,
1058         RTE_FLOW_ITEM_TYPE_UDP,
1059         RTE_FLOW_ITEM_TYPE_GTPU,
1060         RTE_FLOW_ITEM_TYPE_END,
1061 };
1062
1063 enum rte_flow_item_type pattern_eth_ipv6_gtpu_eh[] = {
1064         RTE_FLOW_ITEM_TYPE_ETH,
1065         RTE_FLOW_ITEM_TYPE_IPV6,
1066         RTE_FLOW_ITEM_TYPE_UDP,
1067         RTE_FLOW_ITEM_TYPE_GTPU,
1068         RTE_FLOW_ITEM_TYPE_GTP_PSC,
1069         RTE_FLOW_ITEM_TYPE_END,
1070 };
1071
1072 /*IPv4 GTPU IPv4 */
1073 enum rte_flow_item_type pattern_eth_ipv4_gtpu_ipv4[] = {
1074         RTE_FLOW_ITEM_TYPE_ETH,
1075         RTE_FLOW_ITEM_TYPE_IPV4,
1076         RTE_FLOW_ITEM_TYPE_UDP,
1077         RTE_FLOW_ITEM_TYPE_GTPU,
1078         RTE_FLOW_ITEM_TYPE_IPV4,
1079         RTE_FLOW_ITEM_TYPE_END,
1080 };
1081
1082 enum rte_flow_item_type pattern_eth_ipv4_gtpu_ipv4_udp[] = {
1083         RTE_FLOW_ITEM_TYPE_ETH,
1084         RTE_FLOW_ITEM_TYPE_IPV4,
1085         RTE_FLOW_ITEM_TYPE_UDP,
1086         RTE_FLOW_ITEM_TYPE_GTPU,
1087         RTE_FLOW_ITEM_TYPE_IPV4,
1088         RTE_FLOW_ITEM_TYPE_UDP,
1089         RTE_FLOW_ITEM_TYPE_END,
1090 };
1091
1092 enum rte_flow_item_type pattern_eth_ipv4_gtpu_ipv4_tcp[] = {
1093         RTE_FLOW_ITEM_TYPE_ETH,
1094         RTE_FLOW_ITEM_TYPE_IPV4,
1095         RTE_FLOW_ITEM_TYPE_UDP,
1096         RTE_FLOW_ITEM_TYPE_GTPU,
1097         RTE_FLOW_ITEM_TYPE_IPV4,
1098         RTE_FLOW_ITEM_TYPE_TCP,
1099         RTE_FLOW_ITEM_TYPE_END,
1100 };
1101
1102 enum rte_flow_item_type pattern_eth_ipv4_gtpu_ipv4_icmp[] = {
1103         RTE_FLOW_ITEM_TYPE_ETH,
1104         RTE_FLOW_ITEM_TYPE_IPV4,
1105         RTE_FLOW_ITEM_TYPE_UDP,
1106         RTE_FLOW_ITEM_TYPE_GTPU,
1107         RTE_FLOW_ITEM_TYPE_IPV4,
1108         RTE_FLOW_ITEM_TYPE_ICMP,
1109         RTE_FLOW_ITEM_TYPE_END,
1110 };
1111
1112 /*IPv4 GTPU IPv6 */
1113 enum rte_flow_item_type pattern_eth_ipv4_gtpu_ipv6[] = {
1114         RTE_FLOW_ITEM_TYPE_ETH,
1115         RTE_FLOW_ITEM_TYPE_IPV4,
1116         RTE_FLOW_ITEM_TYPE_UDP,
1117         RTE_FLOW_ITEM_TYPE_GTPU,
1118         RTE_FLOW_ITEM_TYPE_IPV6,
1119         RTE_FLOW_ITEM_TYPE_END,
1120 };
1121
1122 enum rte_flow_item_type pattern_eth_ipv4_gtpu_ipv6_udp[] = {
1123         RTE_FLOW_ITEM_TYPE_ETH,
1124         RTE_FLOW_ITEM_TYPE_IPV4,
1125         RTE_FLOW_ITEM_TYPE_UDP,
1126         RTE_FLOW_ITEM_TYPE_GTPU,
1127         RTE_FLOW_ITEM_TYPE_IPV6,
1128         RTE_FLOW_ITEM_TYPE_UDP,
1129         RTE_FLOW_ITEM_TYPE_END,
1130 };
1131
1132 enum rte_flow_item_type pattern_eth_ipv4_gtpu_ipv6_tcp[] = {
1133         RTE_FLOW_ITEM_TYPE_ETH,
1134         RTE_FLOW_ITEM_TYPE_IPV4,
1135         RTE_FLOW_ITEM_TYPE_UDP,
1136         RTE_FLOW_ITEM_TYPE_GTPU,
1137         RTE_FLOW_ITEM_TYPE_IPV6,
1138         RTE_FLOW_ITEM_TYPE_TCP,
1139         RTE_FLOW_ITEM_TYPE_END,
1140 };
1141
1142 enum rte_flow_item_type pattern_eth_ipv4_gtpu_ipv6_icmp[] = {
1143         RTE_FLOW_ITEM_TYPE_ETH,
1144         RTE_FLOW_ITEM_TYPE_IPV4,
1145         RTE_FLOW_ITEM_TYPE_UDP,
1146         RTE_FLOW_ITEM_TYPE_GTPU,
1147         RTE_FLOW_ITEM_TYPE_IPV6,
1148         RTE_FLOW_ITEM_TYPE_ICMP,
1149         RTE_FLOW_ITEM_TYPE_END,
1150 };
1151
1152 /*IPv6 GTPU IPv4 */
1153 enum rte_flow_item_type pattern_eth_ipv6_gtpu_ipv4[] = {
1154         RTE_FLOW_ITEM_TYPE_ETH,
1155         RTE_FLOW_ITEM_TYPE_IPV6,
1156         RTE_FLOW_ITEM_TYPE_UDP,
1157         RTE_FLOW_ITEM_TYPE_GTPU,
1158         RTE_FLOW_ITEM_TYPE_IPV4,
1159         RTE_FLOW_ITEM_TYPE_END,
1160 };
1161
1162 enum rte_flow_item_type pattern_eth_ipv6_gtpu_ipv4_udp[] = {
1163         RTE_FLOW_ITEM_TYPE_ETH,
1164         RTE_FLOW_ITEM_TYPE_IPV6,
1165         RTE_FLOW_ITEM_TYPE_UDP,
1166         RTE_FLOW_ITEM_TYPE_GTPU,
1167         RTE_FLOW_ITEM_TYPE_IPV4,
1168         RTE_FLOW_ITEM_TYPE_UDP,
1169         RTE_FLOW_ITEM_TYPE_END,
1170 };
1171
1172 enum rte_flow_item_type pattern_eth_ipv6_gtpu_ipv4_tcp[] = {
1173         RTE_FLOW_ITEM_TYPE_ETH,
1174         RTE_FLOW_ITEM_TYPE_IPV6,
1175         RTE_FLOW_ITEM_TYPE_UDP,
1176         RTE_FLOW_ITEM_TYPE_GTPU,
1177         RTE_FLOW_ITEM_TYPE_IPV4,
1178         RTE_FLOW_ITEM_TYPE_TCP,
1179         RTE_FLOW_ITEM_TYPE_END,
1180 };
1181
1182 enum rte_flow_item_type pattern_eth_ipv6_gtpu_ipv4_icmp[] = {
1183         RTE_FLOW_ITEM_TYPE_ETH,
1184         RTE_FLOW_ITEM_TYPE_IPV6,
1185         RTE_FLOW_ITEM_TYPE_UDP,
1186         RTE_FLOW_ITEM_TYPE_GTPU,
1187         RTE_FLOW_ITEM_TYPE_IPV4,
1188         RTE_FLOW_ITEM_TYPE_ICMP,
1189         RTE_FLOW_ITEM_TYPE_END,
1190 };
1191
1192 /*IPv6 GTPU IPv6 */
1193 enum rte_flow_item_type pattern_eth_ipv6_gtpu_ipv6[] = {
1194         RTE_FLOW_ITEM_TYPE_ETH,
1195         RTE_FLOW_ITEM_TYPE_IPV6,
1196         RTE_FLOW_ITEM_TYPE_UDP,
1197         RTE_FLOW_ITEM_TYPE_GTPU,
1198         RTE_FLOW_ITEM_TYPE_IPV6,
1199         RTE_FLOW_ITEM_TYPE_END,
1200 };
1201
1202 enum rte_flow_item_type pattern_eth_ipv6_gtpu_ipv6_udp[] = {
1203         RTE_FLOW_ITEM_TYPE_ETH,
1204         RTE_FLOW_ITEM_TYPE_IPV6,
1205         RTE_FLOW_ITEM_TYPE_UDP,
1206         RTE_FLOW_ITEM_TYPE_GTPU,
1207         RTE_FLOW_ITEM_TYPE_IPV6,
1208         RTE_FLOW_ITEM_TYPE_UDP,
1209         RTE_FLOW_ITEM_TYPE_END,
1210 };
1211
1212 enum rte_flow_item_type pattern_eth_ipv6_gtpu_ipv6_tcp[] = {
1213         RTE_FLOW_ITEM_TYPE_ETH,
1214         RTE_FLOW_ITEM_TYPE_IPV6,
1215         RTE_FLOW_ITEM_TYPE_UDP,
1216         RTE_FLOW_ITEM_TYPE_GTPU,
1217         RTE_FLOW_ITEM_TYPE_IPV6,
1218         RTE_FLOW_ITEM_TYPE_TCP,
1219         RTE_FLOW_ITEM_TYPE_END,
1220 };
1221
1222 enum rte_flow_item_type pattern_eth_ipv6_gtpu_ipv6_icmp[] = {
1223         RTE_FLOW_ITEM_TYPE_ETH,
1224         RTE_FLOW_ITEM_TYPE_IPV6,
1225         RTE_FLOW_ITEM_TYPE_UDP,
1226         RTE_FLOW_ITEM_TYPE_GTPU,
1227         RTE_FLOW_ITEM_TYPE_IPV6,
1228         RTE_FLOW_ITEM_TYPE_ICMP,
1229         RTE_FLOW_ITEM_TYPE_END,
1230 };
1231
1232 /*IPv4 GTPU EH IPv4 */
1233 enum rte_flow_item_type pattern_eth_ipv4_gtpu_eh_ipv4[] = {
1234         RTE_FLOW_ITEM_TYPE_ETH,
1235         RTE_FLOW_ITEM_TYPE_IPV4,
1236         RTE_FLOW_ITEM_TYPE_UDP,
1237         RTE_FLOW_ITEM_TYPE_GTPU,
1238         RTE_FLOW_ITEM_TYPE_GTP_PSC,
1239         RTE_FLOW_ITEM_TYPE_IPV4,
1240         RTE_FLOW_ITEM_TYPE_END,
1241 };
1242
1243 enum rte_flow_item_type pattern_eth_ipv4_gtpu_eh_ipv4_udp[] = {
1244         RTE_FLOW_ITEM_TYPE_ETH,
1245         RTE_FLOW_ITEM_TYPE_IPV4,
1246         RTE_FLOW_ITEM_TYPE_UDP,
1247         RTE_FLOW_ITEM_TYPE_GTPU,
1248         RTE_FLOW_ITEM_TYPE_GTP_PSC,
1249         RTE_FLOW_ITEM_TYPE_IPV4,
1250         RTE_FLOW_ITEM_TYPE_UDP,
1251         RTE_FLOW_ITEM_TYPE_END,
1252 };
1253
1254 enum rte_flow_item_type pattern_eth_ipv4_gtpu_eh_ipv4_tcp[] = {
1255         RTE_FLOW_ITEM_TYPE_ETH,
1256         RTE_FLOW_ITEM_TYPE_IPV4,
1257         RTE_FLOW_ITEM_TYPE_UDP,
1258         RTE_FLOW_ITEM_TYPE_GTPU,
1259         RTE_FLOW_ITEM_TYPE_GTP_PSC,
1260         RTE_FLOW_ITEM_TYPE_IPV4,
1261         RTE_FLOW_ITEM_TYPE_TCP,
1262         RTE_FLOW_ITEM_TYPE_END,
1263 };
1264
1265 enum rte_flow_item_type pattern_eth_ipv4_gtpu_eh_ipv4_icmp[] = {
1266         RTE_FLOW_ITEM_TYPE_ETH,
1267         RTE_FLOW_ITEM_TYPE_IPV4,
1268         RTE_FLOW_ITEM_TYPE_UDP,
1269         RTE_FLOW_ITEM_TYPE_GTPU,
1270         RTE_FLOW_ITEM_TYPE_GTP_PSC,
1271         RTE_FLOW_ITEM_TYPE_IPV4,
1272         RTE_FLOW_ITEM_TYPE_ICMP,
1273         RTE_FLOW_ITEM_TYPE_END,
1274 };
1275
1276 /*IPv4 GTPU EH IPv6 */
1277 enum rte_flow_item_type pattern_eth_ipv4_gtpu_eh_ipv6[] = {
1278         RTE_FLOW_ITEM_TYPE_ETH,
1279         RTE_FLOW_ITEM_TYPE_IPV4,
1280         RTE_FLOW_ITEM_TYPE_UDP,
1281         RTE_FLOW_ITEM_TYPE_GTPU,
1282         RTE_FLOW_ITEM_TYPE_GTP_PSC,
1283         RTE_FLOW_ITEM_TYPE_IPV6,
1284         RTE_FLOW_ITEM_TYPE_END,
1285 };
1286
1287 enum rte_flow_item_type pattern_eth_ipv4_gtpu_eh_ipv6_udp[] = {
1288         RTE_FLOW_ITEM_TYPE_ETH,
1289         RTE_FLOW_ITEM_TYPE_IPV4,
1290         RTE_FLOW_ITEM_TYPE_UDP,
1291         RTE_FLOW_ITEM_TYPE_GTPU,
1292         RTE_FLOW_ITEM_TYPE_GTP_PSC,
1293         RTE_FLOW_ITEM_TYPE_IPV6,
1294         RTE_FLOW_ITEM_TYPE_UDP,
1295         RTE_FLOW_ITEM_TYPE_END,
1296 };
1297
1298 enum rte_flow_item_type pattern_eth_ipv4_gtpu_eh_ipv6_tcp[] = {
1299         RTE_FLOW_ITEM_TYPE_ETH,
1300         RTE_FLOW_ITEM_TYPE_IPV4,
1301         RTE_FLOW_ITEM_TYPE_UDP,
1302         RTE_FLOW_ITEM_TYPE_GTPU,
1303         RTE_FLOW_ITEM_TYPE_GTP_PSC,
1304         RTE_FLOW_ITEM_TYPE_IPV6,
1305         RTE_FLOW_ITEM_TYPE_TCP,
1306         RTE_FLOW_ITEM_TYPE_END,
1307 };
1308
1309 enum rte_flow_item_type pattern_eth_ipv4_gtpu_eh_ipv6_icmp[] = {
1310         RTE_FLOW_ITEM_TYPE_ETH,
1311         RTE_FLOW_ITEM_TYPE_IPV4,
1312         RTE_FLOW_ITEM_TYPE_UDP,
1313         RTE_FLOW_ITEM_TYPE_GTPU,
1314         RTE_FLOW_ITEM_TYPE_GTP_PSC,
1315         RTE_FLOW_ITEM_TYPE_IPV6,
1316         RTE_FLOW_ITEM_TYPE_ICMP,
1317         RTE_FLOW_ITEM_TYPE_END,
1318 };
1319
1320 /*IPv6 GTPU EH IPv4 */
1321 enum rte_flow_item_type pattern_eth_ipv6_gtpu_eh_ipv4[] = {
1322         RTE_FLOW_ITEM_TYPE_ETH,
1323         RTE_FLOW_ITEM_TYPE_IPV6,
1324         RTE_FLOW_ITEM_TYPE_UDP,
1325         RTE_FLOW_ITEM_TYPE_GTPU,
1326         RTE_FLOW_ITEM_TYPE_GTP_PSC,
1327         RTE_FLOW_ITEM_TYPE_IPV4,
1328         RTE_FLOW_ITEM_TYPE_END,
1329 };
1330
1331 enum rte_flow_item_type pattern_eth_ipv6_gtpu_eh_ipv4_udp[] = {
1332         RTE_FLOW_ITEM_TYPE_ETH,
1333         RTE_FLOW_ITEM_TYPE_IPV6,
1334         RTE_FLOW_ITEM_TYPE_UDP,
1335         RTE_FLOW_ITEM_TYPE_GTPU,
1336         RTE_FLOW_ITEM_TYPE_GTP_PSC,
1337         RTE_FLOW_ITEM_TYPE_IPV4,
1338         RTE_FLOW_ITEM_TYPE_UDP,
1339         RTE_FLOW_ITEM_TYPE_END,
1340 };
1341
1342 enum rte_flow_item_type pattern_eth_ipv6_gtpu_eh_ipv4_tcp[] = {
1343         RTE_FLOW_ITEM_TYPE_ETH,
1344         RTE_FLOW_ITEM_TYPE_IPV6,
1345         RTE_FLOW_ITEM_TYPE_UDP,
1346         RTE_FLOW_ITEM_TYPE_GTPU,
1347         RTE_FLOW_ITEM_TYPE_GTP_PSC,
1348         RTE_FLOW_ITEM_TYPE_IPV4,
1349         RTE_FLOW_ITEM_TYPE_TCP,
1350         RTE_FLOW_ITEM_TYPE_END,
1351 };
1352
1353 enum rte_flow_item_type pattern_eth_ipv6_gtpu_eh_ipv4_icmp[] = {
1354         RTE_FLOW_ITEM_TYPE_ETH,
1355         RTE_FLOW_ITEM_TYPE_IPV6,
1356         RTE_FLOW_ITEM_TYPE_UDP,
1357         RTE_FLOW_ITEM_TYPE_GTPU,
1358         RTE_FLOW_ITEM_TYPE_GTP_PSC,
1359         RTE_FLOW_ITEM_TYPE_IPV4,
1360         RTE_FLOW_ITEM_TYPE_ICMP,
1361         RTE_FLOW_ITEM_TYPE_END,
1362 };
1363
1364 /*IPv6 GTPU EH IPv6 */
1365 enum rte_flow_item_type pattern_eth_ipv6_gtpu_eh_ipv6[] = {
1366         RTE_FLOW_ITEM_TYPE_ETH,
1367         RTE_FLOW_ITEM_TYPE_IPV6,
1368         RTE_FLOW_ITEM_TYPE_UDP,
1369         RTE_FLOW_ITEM_TYPE_GTPU,
1370         RTE_FLOW_ITEM_TYPE_GTP_PSC,
1371         RTE_FLOW_ITEM_TYPE_IPV6,
1372         RTE_FLOW_ITEM_TYPE_END,
1373 };
1374
1375 enum rte_flow_item_type pattern_eth_ipv6_gtpu_eh_ipv6_udp[] = {
1376         RTE_FLOW_ITEM_TYPE_ETH,
1377         RTE_FLOW_ITEM_TYPE_IPV6,
1378         RTE_FLOW_ITEM_TYPE_UDP,
1379         RTE_FLOW_ITEM_TYPE_GTPU,
1380         RTE_FLOW_ITEM_TYPE_GTP_PSC,
1381         RTE_FLOW_ITEM_TYPE_IPV6,
1382         RTE_FLOW_ITEM_TYPE_UDP,
1383         RTE_FLOW_ITEM_TYPE_END,
1384 };
1385
1386 enum rte_flow_item_type pattern_eth_ipv6_gtpu_eh_ipv6_tcp[] = {
1387         RTE_FLOW_ITEM_TYPE_ETH,
1388         RTE_FLOW_ITEM_TYPE_IPV6,
1389         RTE_FLOW_ITEM_TYPE_UDP,
1390         RTE_FLOW_ITEM_TYPE_GTPU,
1391         RTE_FLOW_ITEM_TYPE_GTP_PSC,
1392         RTE_FLOW_ITEM_TYPE_IPV6,
1393         RTE_FLOW_ITEM_TYPE_TCP,
1394         RTE_FLOW_ITEM_TYPE_END,
1395 };
1396
1397 enum rte_flow_item_type pattern_eth_ipv6_gtpu_eh_ipv6_icmp[] = {
1398         RTE_FLOW_ITEM_TYPE_ETH,
1399         RTE_FLOW_ITEM_TYPE_IPV6,
1400         RTE_FLOW_ITEM_TYPE_UDP,
1401         RTE_FLOW_ITEM_TYPE_GTPU,
1402         RTE_FLOW_ITEM_TYPE_GTP_PSC,
1403         RTE_FLOW_ITEM_TYPE_IPV6,
1404         RTE_FLOW_ITEM_TYPE_ICMP,
1405         RTE_FLOW_ITEM_TYPE_END,
1406 };
1407
1408 /* PPPoE */
1409 enum rte_flow_item_type pattern_eth_pppoed[] = {
1410         RTE_FLOW_ITEM_TYPE_ETH,
1411         RTE_FLOW_ITEM_TYPE_PPPOED,
1412         RTE_FLOW_ITEM_TYPE_END,
1413 };
1414 enum rte_flow_item_type pattern_eth_vlan_pppoed[] = {
1415         RTE_FLOW_ITEM_TYPE_ETH,
1416         RTE_FLOW_ITEM_TYPE_VLAN,
1417         RTE_FLOW_ITEM_TYPE_PPPOED,
1418         RTE_FLOW_ITEM_TYPE_END,
1419 };
1420 enum rte_flow_item_type pattern_eth_qinq_pppoed[] = {
1421         RTE_FLOW_ITEM_TYPE_ETH,
1422         RTE_FLOW_ITEM_TYPE_VLAN,
1423         RTE_FLOW_ITEM_TYPE_VLAN,
1424         RTE_FLOW_ITEM_TYPE_PPPOED,
1425         RTE_FLOW_ITEM_TYPE_END,
1426 };
1427 enum rte_flow_item_type pattern_eth_pppoes[] = {
1428         RTE_FLOW_ITEM_TYPE_ETH,
1429         RTE_FLOW_ITEM_TYPE_PPPOES,
1430         RTE_FLOW_ITEM_TYPE_END,
1431 };
1432 enum rte_flow_item_type pattern_eth_pppoes_proto[] = {
1433         RTE_FLOW_ITEM_TYPE_ETH,
1434         RTE_FLOW_ITEM_TYPE_PPPOES,
1435         RTE_FLOW_ITEM_TYPE_PPPOE_PROTO_ID,
1436         RTE_FLOW_ITEM_TYPE_END,
1437 };
1438 enum rte_flow_item_type pattern_eth_vlan_pppoes[] = {
1439         RTE_FLOW_ITEM_TYPE_ETH,
1440         RTE_FLOW_ITEM_TYPE_VLAN,
1441         RTE_FLOW_ITEM_TYPE_PPPOES,
1442         RTE_FLOW_ITEM_TYPE_END,
1443 };
1444 enum rte_flow_item_type pattern_eth_vlan_pppoes_proto[] = {
1445         RTE_FLOW_ITEM_TYPE_ETH,
1446         RTE_FLOW_ITEM_TYPE_VLAN,
1447         RTE_FLOW_ITEM_TYPE_PPPOES,
1448         RTE_FLOW_ITEM_TYPE_PPPOE_PROTO_ID,
1449         RTE_FLOW_ITEM_TYPE_END,
1450 };
1451 enum rte_flow_item_type pattern_eth_qinq_pppoes[] = {
1452         RTE_FLOW_ITEM_TYPE_ETH,
1453         RTE_FLOW_ITEM_TYPE_VLAN,
1454         RTE_FLOW_ITEM_TYPE_VLAN,
1455         RTE_FLOW_ITEM_TYPE_PPPOES,
1456         RTE_FLOW_ITEM_TYPE_END,
1457 };
1458 enum rte_flow_item_type pattern_eth_pppoes_ipv4[] = {
1459         RTE_FLOW_ITEM_TYPE_ETH,
1460         RTE_FLOW_ITEM_TYPE_PPPOES,
1461         RTE_FLOW_ITEM_TYPE_IPV4,
1462         RTE_FLOW_ITEM_TYPE_END,
1463 };
1464 enum rte_flow_item_type pattern_eth_vlan_pppoes_ipv4[] = {
1465         RTE_FLOW_ITEM_TYPE_ETH,
1466         RTE_FLOW_ITEM_TYPE_VLAN,
1467         RTE_FLOW_ITEM_TYPE_PPPOES,
1468         RTE_FLOW_ITEM_TYPE_IPV4,
1469         RTE_FLOW_ITEM_TYPE_END,
1470 };
1471 enum rte_flow_item_type pattern_eth_qinq_pppoes_ipv4[] = {
1472         RTE_FLOW_ITEM_TYPE_ETH,
1473         RTE_FLOW_ITEM_TYPE_VLAN,
1474         RTE_FLOW_ITEM_TYPE_VLAN,
1475         RTE_FLOW_ITEM_TYPE_PPPOES,
1476         RTE_FLOW_ITEM_TYPE_IPV4,
1477         RTE_FLOW_ITEM_TYPE_END,
1478 };
1479 enum rte_flow_item_type pattern_eth_pppoes_ipv4_udp[] = {
1480         RTE_FLOW_ITEM_TYPE_ETH,
1481         RTE_FLOW_ITEM_TYPE_PPPOES,
1482         RTE_FLOW_ITEM_TYPE_IPV4,
1483         RTE_FLOW_ITEM_TYPE_UDP,
1484         RTE_FLOW_ITEM_TYPE_END,
1485 };
1486 enum rte_flow_item_type pattern_eth_vlan_pppoes_ipv4_udp[] = {
1487         RTE_FLOW_ITEM_TYPE_ETH,
1488         RTE_FLOW_ITEM_TYPE_VLAN,
1489         RTE_FLOW_ITEM_TYPE_PPPOES,
1490         RTE_FLOW_ITEM_TYPE_IPV4,
1491         RTE_FLOW_ITEM_TYPE_UDP,
1492         RTE_FLOW_ITEM_TYPE_END,
1493 };
1494 enum rte_flow_item_type pattern_eth_qinq_pppoes_ipv4_udp[] = {
1495         RTE_FLOW_ITEM_TYPE_ETH,
1496         RTE_FLOW_ITEM_TYPE_VLAN,
1497         RTE_FLOW_ITEM_TYPE_VLAN,
1498         RTE_FLOW_ITEM_TYPE_PPPOES,
1499         RTE_FLOW_ITEM_TYPE_IPV4,
1500         RTE_FLOW_ITEM_TYPE_UDP,
1501         RTE_FLOW_ITEM_TYPE_END,
1502 };
1503 enum rte_flow_item_type pattern_eth_pppoes_ipv4_tcp[] = {
1504         RTE_FLOW_ITEM_TYPE_ETH,
1505         RTE_FLOW_ITEM_TYPE_PPPOES,
1506         RTE_FLOW_ITEM_TYPE_IPV4,
1507         RTE_FLOW_ITEM_TYPE_TCP,
1508         RTE_FLOW_ITEM_TYPE_END,
1509 };
1510 enum rte_flow_item_type pattern_eth_vlan_pppoes_ipv4_tcp[] = {
1511         RTE_FLOW_ITEM_TYPE_ETH,
1512         RTE_FLOW_ITEM_TYPE_VLAN,
1513         RTE_FLOW_ITEM_TYPE_PPPOES,
1514         RTE_FLOW_ITEM_TYPE_IPV4,
1515         RTE_FLOW_ITEM_TYPE_TCP,
1516         RTE_FLOW_ITEM_TYPE_END,
1517 };
1518 enum rte_flow_item_type pattern_eth_qinq_pppoes_ipv4_tcp[] = {
1519         RTE_FLOW_ITEM_TYPE_ETH,
1520         RTE_FLOW_ITEM_TYPE_VLAN,
1521         RTE_FLOW_ITEM_TYPE_VLAN,
1522         RTE_FLOW_ITEM_TYPE_PPPOES,
1523         RTE_FLOW_ITEM_TYPE_IPV4,
1524         RTE_FLOW_ITEM_TYPE_TCP,
1525         RTE_FLOW_ITEM_TYPE_END,
1526 };
1527 enum rte_flow_item_type pattern_eth_pppoes_ipv4_sctp[] = {
1528         RTE_FLOW_ITEM_TYPE_ETH,
1529         RTE_FLOW_ITEM_TYPE_PPPOES,
1530         RTE_FLOW_ITEM_TYPE_IPV4,
1531         RTE_FLOW_ITEM_TYPE_SCTP,
1532         RTE_FLOW_ITEM_TYPE_END,
1533 };
1534 enum rte_flow_item_type pattern_eth_vlan_pppoes_ipv4_sctp[] = {
1535         RTE_FLOW_ITEM_TYPE_ETH,
1536         RTE_FLOW_ITEM_TYPE_VLAN,
1537         RTE_FLOW_ITEM_TYPE_PPPOES,
1538         RTE_FLOW_ITEM_TYPE_IPV4,
1539         RTE_FLOW_ITEM_TYPE_SCTP,
1540         RTE_FLOW_ITEM_TYPE_END,
1541 };
1542 enum rte_flow_item_type pattern_eth_qinq_pppoes_ipv4_sctp[] = {
1543         RTE_FLOW_ITEM_TYPE_ETH,
1544         RTE_FLOW_ITEM_TYPE_VLAN,
1545         RTE_FLOW_ITEM_TYPE_VLAN,
1546         RTE_FLOW_ITEM_TYPE_PPPOES,
1547         RTE_FLOW_ITEM_TYPE_IPV4,
1548         RTE_FLOW_ITEM_TYPE_SCTP,
1549         RTE_FLOW_ITEM_TYPE_END,
1550 };
1551 enum rte_flow_item_type pattern_eth_pppoes_ipv4_icmp[] = {
1552         RTE_FLOW_ITEM_TYPE_ETH,
1553         RTE_FLOW_ITEM_TYPE_PPPOES,
1554         RTE_FLOW_ITEM_TYPE_IPV4,
1555         RTE_FLOW_ITEM_TYPE_ICMP,
1556         RTE_FLOW_ITEM_TYPE_END,
1557 };
1558 enum rte_flow_item_type pattern_eth_vlan_pppoes_ipv4_icmp[] = {
1559         RTE_FLOW_ITEM_TYPE_ETH,
1560         RTE_FLOW_ITEM_TYPE_VLAN,
1561         RTE_FLOW_ITEM_TYPE_PPPOES,
1562         RTE_FLOW_ITEM_TYPE_IPV4,
1563         RTE_FLOW_ITEM_TYPE_ICMP,
1564         RTE_FLOW_ITEM_TYPE_END,
1565 };
1566 enum rte_flow_item_type pattern_eth_qinq_pppoes_ipv4_icmp[] = {
1567         RTE_FLOW_ITEM_TYPE_ETH,
1568         RTE_FLOW_ITEM_TYPE_VLAN,
1569         RTE_FLOW_ITEM_TYPE_VLAN,
1570         RTE_FLOW_ITEM_TYPE_PPPOES,
1571         RTE_FLOW_ITEM_TYPE_IPV4,
1572         RTE_FLOW_ITEM_TYPE_ICMP,
1573         RTE_FLOW_ITEM_TYPE_END,
1574 };
1575 enum rte_flow_item_type pattern_eth_pppoes_ipv6[] = {
1576         RTE_FLOW_ITEM_TYPE_ETH,
1577         RTE_FLOW_ITEM_TYPE_PPPOES,
1578         RTE_FLOW_ITEM_TYPE_IPV6,
1579         RTE_FLOW_ITEM_TYPE_END,
1580 };
1581 enum rte_flow_item_type pattern_eth_vlan_pppoes_ipv6[] = {
1582         RTE_FLOW_ITEM_TYPE_ETH,
1583         RTE_FLOW_ITEM_TYPE_VLAN,
1584         RTE_FLOW_ITEM_TYPE_PPPOES,
1585         RTE_FLOW_ITEM_TYPE_IPV6,
1586         RTE_FLOW_ITEM_TYPE_END,
1587 };
1588 enum rte_flow_item_type pattern_eth_qinq_pppoes_ipv6[] = {
1589         RTE_FLOW_ITEM_TYPE_ETH,
1590         RTE_FLOW_ITEM_TYPE_VLAN,
1591         RTE_FLOW_ITEM_TYPE_VLAN,
1592         RTE_FLOW_ITEM_TYPE_PPPOES,
1593         RTE_FLOW_ITEM_TYPE_IPV6,
1594         RTE_FLOW_ITEM_TYPE_END,
1595 };
1596 enum rte_flow_item_type pattern_eth_pppoes_ipv6_udp[] = {
1597         RTE_FLOW_ITEM_TYPE_ETH,
1598         RTE_FLOW_ITEM_TYPE_PPPOES,
1599         RTE_FLOW_ITEM_TYPE_IPV6,
1600         RTE_FLOW_ITEM_TYPE_UDP,
1601         RTE_FLOW_ITEM_TYPE_END,
1602 };
1603 enum rte_flow_item_type pattern_eth_vlan_pppoes_ipv6_udp[] = {
1604         RTE_FLOW_ITEM_TYPE_ETH,
1605         RTE_FLOW_ITEM_TYPE_VLAN,
1606         RTE_FLOW_ITEM_TYPE_PPPOES,
1607         RTE_FLOW_ITEM_TYPE_IPV6,
1608         RTE_FLOW_ITEM_TYPE_UDP,
1609         RTE_FLOW_ITEM_TYPE_END,
1610 };
1611 enum rte_flow_item_type pattern_eth_qinq_pppoes_ipv6_udp[] = {
1612         RTE_FLOW_ITEM_TYPE_ETH,
1613         RTE_FLOW_ITEM_TYPE_VLAN,
1614         RTE_FLOW_ITEM_TYPE_VLAN,
1615         RTE_FLOW_ITEM_TYPE_PPPOES,
1616         RTE_FLOW_ITEM_TYPE_IPV6,
1617         RTE_FLOW_ITEM_TYPE_UDP,
1618         RTE_FLOW_ITEM_TYPE_END,
1619 };
1620 enum rte_flow_item_type pattern_eth_pppoes_ipv6_tcp[] = {
1621         RTE_FLOW_ITEM_TYPE_ETH,
1622         RTE_FLOW_ITEM_TYPE_PPPOES,
1623         RTE_FLOW_ITEM_TYPE_IPV6,
1624         RTE_FLOW_ITEM_TYPE_TCP,
1625         RTE_FLOW_ITEM_TYPE_END,
1626 };
1627 enum rte_flow_item_type pattern_eth_vlan_pppoes_ipv6_tcp[] = {
1628         RTE_FLOW_ITEM_TYPE_ETH,
1629         RTE_FLOW_ITEM_TYPE_VLAN,
1630         RTE_FLOW_ITEM_TYPE_PPPOES,
1631         RTE_FLOW_ITEM_TYPE_IPV6,
1632         RTE_FLOW_ITEM_TYPE_TCP,
1633         RTE_FLOW_ITEM_TYPE_END,
1634 };
1635 enum rte_flow_item_type pattern_eth_qinq_pppoes_ipv6_tcp[] = {
1636         RTE_FLOW_ITEM_TYPE_ETH,
1637         RTE_FLOW_ITEM_TYPE_VLAN,
1638         RTE_FLOW_ITEM_TYPE_VLAN,
1639         RTE_FLOW_ITEM_TYPE_PPPOES,
1640         RTE_FLOW_ITEM_TYPE_IPV6,
1641         RTE_FLOW_ITEM_TYPE_TCP,
1642         RTE_FLOW_ITEM_TYPE_END,
1643 };
1644 enum rte_flow_item_type pattern_eth_pppoes_ipv6_sctp[] = {
1645         RTE_FLOW_ITEM_TYPE_ETH,
1646         RTE_FLOW_ITEM_TYPE_PPPOES,
1647         RTE_FLOW_ITEM_TYPE_IPV6,
1648         RTE_FLOW_ITEM_TYPE_SCTP,
1649         RTE_FLOW_ITEM_TYPE_END,
1650 };
1651 enum rte_flow_item_type pattern_eth_vlan_pppoes_ipv6_sctp[] = {
1652         RTE_FLOW_ITEM_TYPE_ETH,
1653         RTE_FLOW_ITEM_TYPE_VLAN,
1654         RTE_FLOW_ITEM_TYPE_PPPOES,
1655         RTE_FLOW_ITEM_TYPE_IPV6,
1656         RTE_FLOW_ITEM_TYPE_SCTP,
1657         RTE_FLOW_ITEM_TYPE_END,
1658 };
1659 enum rte_flow_item_type pattern_eth_qinq_pppoes_ipv6_sctp[] = {
1660         RTE_FLOW_ITEM_TYPE_ETH,
1661         RTE_FLOW_ITEM_TYPE_VLAN,
1662         RTE_FLOW_ITEM_TYPE_VLAN,
1663         RTE_FLOW_ITEM_TYPE_PPPOES,
1664         RTE_FLOW_ITEM_TYPE_IPV6,
1665         RTE_FLOW_ITEM_TYPE_SCTP,
1666         RTE_FLOW_ITEM_TYPE_END,
1667 };
1668 enum rte_flow_item_type pattern_eth_pppoes_ipv6_icmp6[] = {
1669         RTE_FLOW_ITEM_TYPE_ETH,
1670         RTE_FLOW_ITEM_TYPE_PPPOES,
1671         RTE_FLOW_ITEM_TYPE_IPV6,
1672         RTE_FLOW_ITEM_TYPE_ICMP6,
1673         RTE_FLOW_ITEM_TYPE_END,
1674 };
1675 enum rte_flow_item_type pattern_eth_vlan_pppoes_ipv6_icmp6[] = {
1676         RTE_FLOW_ITEM_TYPE_ETH,
1677         RTE_FLOW_ITEM_TYPE_VLAN,
1678         RTE_FLOW_ITEM_TYPE_PPPOES,
1679         RTE_FLOW_ITEM_TYPE_IPV6,
1680         RTE_FLOW_ITEM_TYPE_ICMP6,
1681         RTE_FLOW_ITEM_TYPE_END,
1682 };
1683 enum rte_flow_item_type pattern_eth_qinq_pppoes_ipv6_icmp6[] = {
1684         RTE_FLOW_ITEM_TYPE_ETH,
1685         RTE_FLOW_ITEM_TYPE_VLAN,
1686         RTE_FLOW_ITEM_TYPE_VLAN,
1687         RTE_FLOW_ITEM_TYPE_PPPOES,
1688         RTE_FLOW_ITEM_TYPE_IPV6,
1689         RTE_FLOW_ITEM_TYPE_ICMP6,
1690         RTE_FLOW_ITEM_TYPE_END,
1691 };
1692 enum rte_flow_item_type pattern_eth_ipv4_esp[] = {
1693         RTE_FLOW_ITEM_TYPE_ETH,
1694         RTE_FLOW_ITEM_TYPE_IPV4,
1695         RTE_FLOW_ITEM_TYPE_ESP,
1696         RTE_FLOW_ITEM_TYPE_END,
1697 };
1698 enum rte_flow_item_type pattern_eth_ipv6_esp[] = {
1699         RTE_FLOW_ITEM_TYPE_ETH,
1700         RTE_FLOW_ITEM_TYPE_IPV6,
1701         RTE_FLOW_ITEM_TYPE_ESP,
1702         RTE_FLOW_ITEM_TYPE_END,
1703 };
1704 enum rte_flow_item_type pattern_eth_ipv4_ah[] = {
1705         RTE_FLOW_ITEM_TYPE_ETH,
1706         RTE_FLOW_ITEM_TYPE_IPV4,
1707         RTE_FLOW_ITEM_TYPE_AH,
1708         RTE_FLOW_ITEM_TYPE_END,
1709 };
1710 enum rte_flow_item_type pattern_eth_ipv6_ah[] = {
1711         RTE_FLOW_ITEM_TYPE_ETH,
1712         RTE_FLOW_ITEM_TYPE_IPV6,
1713         RTE_FLOW_ITEM_TYPE_AH,
1714         RTE_FLOW_ITEM_TYPE_END,
1715 };
1716 enum rte_flow_item_type pattern_eth_ipv4_udp_esp[] = {
1717         RTE_FLOW_ITEM_TYPE_ETH,
1718         RTE_FLOW_ITEM_TYPE_IPV4,
1719         RTE_FLOW_ITEM_TYPE_UDP,
1720         RTE_FLOW_ITEM_TYPE_ESP,
1721         RTE_FLOW_ITEM_TYPE_END,
1722 };
1723 enum rte_flow_item_type pattern_eth_ipv6_udp_esp[] = {
1724         RTE_FLOW_ITEM_TYPE_ETH,
1725         RTE_FLOW_ITEM_TYPE_IPV6,
1726         RTE_FLOW_ITEM_TYPE_UDP,
1727         RTE_FLOW_ITEM_TYPE_ESP,
1728         RTE_FLOW_ITEM_TYPE_END,
1729 };
1730 enum rte_flow_item_type pattern_eth_ipv6_udp_ah[] = {
1731         RTE_FLOW_ITEM_TYPE_ETH,
1732         RTE_FLOW_ITEM_TYPE_IPV6,
1733         RTE_FLOW_ITEM_TYPE_UDP,
1734         RTE_FLOW_ITEM_TYPE_AH,
1735         RTE_FLOW_ITEM_TYPE_END,
1736 };
1737 enum rte_flow_item_type pattern_eth_ipv4_l2tp[] = {
1738         RTE_FLOW_ITEM_TYPE_ETH,
1739         RTE_FLOW_ITEM_TYPE_IPV4,
1740         RTE_FLOW_ITEM_TYPE_L2TPV3OIP,
1741         RTE_FLOW_ITEM_TYPE_END,
1742 };
1743 enum rte_flow_item_type pattern_eth_ipv6_l2tp[] = {
1744         RTE_FLOW_ITEM_TYPE_ETH,
1745         RTE_FLOW_ITEM_TYPE_IPV6,
1746         RTE_FLOW_ITEM_TYPE_L2TPV3OIP,
1747         RTE_FLOW_ITEM_TYPE_END,
1748 };
1749 enum rte_flow_item_type pattern_eth_ipv4_pfcp[] = {
1750         RTE_FLOW_ITEM_TYPE_ETH,
1751         RTE_FLOW_ITEM_TYPE_IPV4,
1752         RTE_FLOW_ITEM_TYPE_UDP,
1753         RTE_FLOW_ITEM_TYPE_PFCP,
1754         RTE_FLOW_ITEM_TYPE_END,
1755 };
1756 enum rte_flow_item_type pattern_eth_ipv6_pfcp[] = {
1757         RTE_FLOW_ITEM_TYPE_ETH,
1758         RTE_FLOW_ITEM_TYPE_IPV6,
1759         RTE_FLOW_ITEM_TYPE_UDP,
1760         RTE_FLOW_ITEM_TYPE_PFCP,
1761         RTE_FLOW_ITEM_TYPE_END,
1762 };
1763
1764
1765
1766 typedef struct ice_flow_engine * (*parse_engine_t)(struct ice_adapter *ad,
1767                 struct rte_flow *flow,
1768                 struct ice_parser_list *parser_list,
1769                 const struct rte_flow_item pattern[],
1770                 const struct rte_flow_action actions[],
1771                 struct rte_flow_error *error);
1772
1773 void
1774 ice_register_flow_engine(struct ice_flow_engine *engine)
1775 {
1776         TAILQ_INSERT_TAIL(&engine_list, engine, node);
1777 }
1778
1779 int
1780 ice_flow_init(struct ice_adapter *ad)
1781 {
1782         int ret;
1783         struct ice_pf *pf = &ad->pf;
1784         void *temp;
1785         struct ice_flow_engine *engine;
1786
1787         TAILQ_INIT(&pf->flow_list);
1788         TAILQ_INIT(&pf->rss_parser_list);
1789         TAILQ_INIT(&pf->perm_parser_list);
1790         TAILQ_INIT(&pf->dist_parser_list);
1791         rte_spinlock_init(&pf->flow_ops_lock);
1792
1793         TAILQ_FOREACH_SAFE(engine, &engine_list, node, temp) {
1794                 if (engine->init == NULL) {
1795                         PMD_INIT_LOG(ERR, "Invalid engine type (%d)",
1796                                         engine->type);
1797                         return -ENOTSUP;
1798                 }
1799
1800                 ret = engine->init(ad);
1801                 if (ret) {
1802                         PMD_INIT_LOG(ERR, "Failed to initialize engine %d",
1803                                         engine->type);
1804                         return ret;
1805                 }
1806         }
1807         return 0;
1808 }
1809
1810 void
1811 ice_flow_uninit(struct ice_adapter *ad)
1812 {
1813         struct ice_pf *pf = &ad->pf;
1814         struct ice_flow_engine *engine;
1815         struct rte_flow *p_flow;
1816         struct ice_flow_parser_node *p_parser;
1817         void *temp;
1818
1819         TAILQ_FOREACH_SAFE(engine, &engine_list, node, temp) {
1820                 if (engine->uninit)
1821                         engine->uninit(ad);
1822         }
1823
1824         /* Remove all flows */
1825         while ((p_flow = TAILQ_FIRST(&pf->flow_list))) {
1826                 TAILQ_REMOVE(&pf->flow_list, p_flow, node);
1827                 if (p_flow->engine->free)
1828                         p_flow->engine->free(p_flow);
1829                 rte_free(p_flow);
1830         }
1831
1832         /* Cleanup parser list */
1833         while ((p_parser = TAILQ_FIRST(&pf->rss_parser_list))) {
1834                 TAILQ_REMOVE(&pf->rss_parser_list, p_parser, node);
1835                 rte_free(p_parser);
1836         }
1837
1838         while ((p_parser = TAILQ_FIRST(&pf->perm_parser_list))) {
1839                 TAILQ_REMOVE(&pf->perm_parser_list, p_parser, node);
1840                 rte_free(p_parser);
1841         }
1842
1843         while ((p_parser = TAILQ_FIRST(&pf->dist_parser_list))) {
1844                 TAILQ_REMOVE(&pf->dist_parser_list, p_parser, node);
1845                 rte_free(p_parser);
1846         }
1847 }
1848
1849 static struct ice_parser_list *
1850 ice_get_parser_list(struct ice_flow_parser *parser,
1851                 struct ice_adapter *ad)
1852 {
1853         struct ice_parser_list *list;
1854         struct ice_pf *pf = &ad->pf;
1855
1856         switch (parser->stage) {
1857         case ICE_FLOW_STAGE_RSS:
1858                 list = &pf->rss_parser_list;
1859                 break;
1860         case ICE_FLOW_STAGE_PERMISSION:
1861                 list = &pf->perm_parser_list;
1862                 break;
1863         case ICE_FLOW_STAGE_DISTRIBUTOR:
1864                 list = &pf->dist_parser_list;
1865                 break;
1866         default:
1867                 return NULL;
1868         }
1869
1870         return list;
1871 }
1872
1873 int
1874 ice_register_parser(struct ice_flow_parser *parser,
1875                 struct ice_adapter *ad)
1876 {
1877         struct ice_parser_list *list;
1878         struct ice_flow_parser_node *parser_node;
1879
1880         parser_node = rte_zmalloc("ice_parser", sizeof(*parser_node), 0);
1881         if (parser_node == NULL) {
1882                 PMD_DRV_LOG(ERR, "Failed to allocate memory.");
1883                 return -ENOMEM;
1884         }
1885         parser_node->parser = parser;
1886
1887         list = ice_get_parser_list(parser, ad);
1888         if (list == NULL)
1889                 return -EINVAL;
1890
1891         if (ad->devargs.pipe_mode_support) {
1892                 TAILQ_INSERT_TAIL(list, parser_node, node);
1893         } else {
1894                 if (parser->engine->type == ICE_FLOW_ENGINE_SWITCH ||
1895                                 parser->engine->type == ICE_FLOW_ENGINE_HASH)
1896                         TAILQ_INSERT_TAIL(list, parser_node, node);
1897                 else if (parser->engine->type == ICE_FLOW_ENGINE_FDIR)
1898                         TAILQ_INSERT_HEAD(list, parser_node, node);
1899                 else
1900                         return -EINVAL;
1901         }
1902         return 0;
1903 }
1904
1905 void
1906 ice_unregister_parser(struct ice_flow_parser *parser,
1907                 struct ice_adapter *ad)
1908 {
1909         struct ice_parser_list *list;
1910         struct ice_flow_parser_node *p_parser;
1911         void *temp;
1912
1913         list = ice_get_parser_list(parser, ad);
1914         if (list == NULL)
1915                 return;
1916
1917         TAILQ_FOREACH_SAFE(p_parser, list, node, temp) {
1918                 if (p_parser->parser->engine->type == parser->engine->type) {
1919                         TAILQ_REMOVE(list, p_parser, node);
1920                         rte_free(p_parser);
1921                 }
1922         }
1923 }
1924
1925 static int
1926 ice_flow_valid_attr(struct ice_adapter *ad,
1927                 const struct rte_flow_attr *attr,
1928                 int *ice_pipeline_stage,
1929                 struct rte_flow_error *error)
1930 {
1931         /* Must be input direction */
1932         if (!attr->ingress) {
1933                 rte_flow_error_set(error, EINVAL,
1934                                 RTE_FLOW_ERROR_TYPE_ATTR_INGRESS,
1935                                 attr, "Only support ingress.");
1936                 return -rte_errno;
1937         }
1938
1939         /* Not supported */
1940         if (attr->egress) {
1941                 rte_flow_error_set(error, EINVAL,
1942                                 RTE_FLOW_ERROR_TYPE_ATTR_EGRESS,
1943                                 attr, "Not support egress.");
1944                 return -rte_errno;
1945         }
1946
1947         /* Check pipeline mode support to set classification stage */
1948         if (ad->devargs.pipe_mode_support) {
1949                 if (attr->priority == 0)
1950                         *ice_pipeline_stage =
1951                                 ICE_FLOW_CLASSIFY_STAGE_PERMISSION;
1952                 else
1953                         *ice_pipeline_stage =
1954                                 ICE_FLOW_CLASSIFY_STAGE_DISTRIBUTOR;
1955         } else {
1956                 *ice_pipeline_stage =
1957                         ICE_FLOW_CLASSIFY_STAGE_DISTRIBUTOR_ONLY;
1958                 /* Not supported */
1959                 if (attr->priority) {
1960                         rte_flow_error_set(error, EINVAL,
1961                                         RTE_FLOW_ERROR_TYPE_ATTR_PRIORITY,
1962                                         attr, "Not support priority.");
1963                         return -rte_errno;
1964                 }
1965         }
1966
1967         /* Not supported */
1968         if (attr->group) {
1969                 rte_flow_error_set(error, EINVAL,
1970                                 RTE_FLOW_ERROR_TYPE_ATTR_GROUP,
1971                                 attr, "Not support group.");
1972                 return -rte_errno;
1973         }
1974
1975         return 0;
1976 }
1977
1978 /* Find the first VOID or non-VOID item pointer */
1979 static const struct rte_flow_item *
1980 ice_find_first_item(const struct rte_flow_item *item, bool is_void)
1981 {
1982         bool is_find;
1983
1984         while (item->type != RTE_FLOW_ITEM_TYPE_END) {
1985                 if (is_void)
1986                         is_find = item->type == RTE_FLOW_ITEM_TYPE_VOID;
1987                 else
1988                         is_find = item->type != RTE_FLOW_ITEM_TYPE_VOID;
1989                 if (is_find)
1990                         break;
1991                 item++;
1992         }
1993         return item;
1994 }
1995
1996 /* Skip all VOID items of the pattern */
1997 static void
1998 ice_pattern_skip_void_item(struct rte_flow_item *items,
1999                         const struct rte_flow_item *pattern)
2000 {
2001         uint32_t cpy_count = 0;
2002         const struct rte_flow_item *pb = pattern, *pe = pattern;
2003
2004         for (;;) {
2005                 /* Find a non-void item first */
2006                 pb = ice_find_first_item(pb, false);
2007                 if (pb->type == RTE_FLOW_ITEM_TYPE_END) {
2008                         pe = pb;
2009                         break;
2010                 }
2011
2012                 /* Find a void item */
2013                 pe = ice_find_first_item(pb + 1, true);
2014
2015                 cpy_count = pe - pb;
2016                 rte_memcpy(items, pb, sizeof(struct rte_flow_item) * cpy_count);
2017
2018                 items += cpy_count;
2019
2020                 if (pe->type == RTE_FLOW_ITEM_TYPE_END) {
2021                         break;
2022                 }
2023
2024                 pb = pe + 1;
2025         }
2026         /* Copy the END item. */
2027         rte_memcpy(items, pe, sizeof(struct rte_flow_item));
2028 }
2029
2030 /* Check if the pattern matches a supported item type array */
2031 static bool
2032 ice_match_pattern(enum rte_flow_item_type *item_array,
2033                 const struct rte_flow_item *pattern)
2034 {
2035         const struct rte_flow_item *item = pattern;
2036
2037         while ((*item_array == item->type) &&
2038                (*item_array != RTE_FLOW_ITEM_TYPE_END)) {
2039                 item_array++;
2040                 item++;
2041         }
2042
2043         return (*item_array == RTE_FLOW_ITEM_TYPE_END &&
2044                 item->type == RTE_FLOW_ITEM_TYPE_END);
2045 }
2046
2047 struct ice_pattern_match_item *
2048 ice_search_pattern_match_item(const struct rte_flow_item pattern[],
2049                 struct ice_pattern_match_item *array,
2050                 uint32_t array_len,
2051                 struct rte_flow_error *error)
2052 {
2053         uint16_t i = 0;
2054         struct ice_pattern_match_item *pattern_match_item;
2055         /* need free by each filter */
2056         struct rte_flow_item *items; /* used for pattern without VOID items */
2057         uint32_t item_num = 0; /* non-void item number */
2058
2059         /* Get the non-void item number of pattern */
2060         while ((pattern + i)->type != RTE_FLOW_ITEM_TYPE_END) {
2061                 if ((pattern + i)->type != RTE_FLOW_ITEM_TYPE_VOID)
2062                         item_num++;
2063                 i++;
2064         }
2065         item_num++;
2066
2067         items = rte_zmalloc("ice_pattern",
2068                             item_num * sizeof(struct rte_flow_item), 0);
2069         if (!items) {
2070                 rte_flow_error_set(error, ENOMEM, RTE_FLOW_ERROR_TYPE_ITEM_NUM,
2071                                    NULL, "No memory for PMD internal items.");
2072                 return NULL;
2073         }
2074         pattern_match_item = rte_zmalloc("ice_pattern_match_item",
2075                         sizeof(struct ice_pattern_match_item), 0);
2076         if (!pattern_match_item) {
2077                 rte_flow_error_set(error, ENOMEM, RTE_FLOW_ERROR_TYPE_HANDLE,
2078                                 NULL, "Failed to allocate memory.");
2079                 return NULL;
2080         }
2081
2082         ice_pattern_skip_void_item(items, pattern);
2083
2084         for (i = 0; i < array_len; i++)
2085                 if (ice_match_pattern(array[i].pattern_list,
2086                                         items)) {
2087                         pattern_match_item->input_set_mask =
2088                                 array[i].input_set_mask;
2089                         pattern_match_item->pattern_list =
2090                                 array[i].pattern_list;
2091                         pattern_match_item->meta = array[i].meta;
2092                         rte_free(items);
2093                         return pattern_match_item;
2094                 }
2095         rte_flow_error_set(error, EINVAL, RTE_FLOW_ERROR_TYPE_ITEM,
2096                            pattern, "Unsupported pattern");
2097
2098         rte_free(items);
2099         rte_free(pattern_match_item);
2100         return NULL;
2101 }
2102
2103 static struct ice_flow_engine *
2104 ice_parse_engine_create(struct ice_adapter *ad,
2105                 struct rte_flow *flow,
2106                 struct ice_parser_list *parser_list,
2107                 const struct rte_flow_item pattern[],
2108                 const struct rte_flow_action actions[],
2109                 struct rte_flow_error *error)
2110 {
2111         struct ice_flow_engine *engine = NULL;
2112         struct ice_flow_parser_node *parser_node;
2113         void *meta = NULL;
2114         void *temp;
2115
2116         TAILQ_FOREACH_SAFE(parser_node, parser_list, node, temp) {
2117                 int ret;
2118
2119                 if (parser_node->parser->parse_pattern_action(ad,
2120                                 parser_node->parser->array,
2121                                 parser_node->parser->array_len,
2122                                 pattern, actions, &meta, error) < 0)
2123                         continue;
2124
2125                 engine = parser_node->parser->engine;
2126                 RTE_ASSERT(engine->create != NULL);
2127                 ret = engine->create(ad, flow, meta, error);
2128                 if (ret == 0)
2129                         return engine;
2130                 else if (ret == -EEXIST)
2131                         return NULL;
2132         }
2133         return NULL;
2134 }
2135
2136 static struct ice_flow_engine *
2137 ice_parse_engine_validate(struct ice_adapter *ad,
2138                 struct rte_flow *flow __rte_unused,
2139                 struct ice_parser_list *parser_list,
2140                 const struct rte_flow_item pattern[],
2141                 const struct rte_flow_action actions[],
2142                 struct rte_flow_error *error)
2143 {
2144         struct ice_flow_engine *engine = NULL;
2145         struct ice_flow_parser_node *parser_node;
2146         void *temp;
2147
2148         TAILQ_FOREACH_SAFE(parser_node, parser_list, node, temp) {
2149                 if (parser_node->parser->parse_pattern_action(ad,
2150                                 parser_node->parser->array,
2151                                 parser_node->parser->array_len,
2152                                 pattern, actions, NULL, error) < 0)
2153                         continue;
2154
2155                 engine = parser_node->parser->engine;
2156                 break;
2157         }
2158         return engine;
2159 }
2160
2161 static int
2162 ice_flow_process_filter(struct rte_eth_dev *dev,
2163                 struct rte_flow *flow,
2164                 const struct rte_flow_attr *attr,
2165                 const struct rte_flow_item pattern[],
2166                 const struct rte_flow_action actions[],
2167                 struct ice_flow_engine **engine,
2168                 parse_engine_t ice_parse_engine,
2169                 struct rte_flow_error *error)
2170 {
2171         int ret = ICE_ERR_NOT_SUPPORTED;
2172         struct ice_adapter *ad =
2173                 ICE_DEV_PRIVATE_TO_ADAPTER(dev->data->dev_private);
2174         struct ice_pf *pf = ICE_DEV_PRIVATE_TO_PF(dev->data->dev_private);
2175         int ice_pipeline_stage = 0;
2176
2177         if (!pattern) {
2178                 rte_flow_error_set(error, EINVAL, RTE_FLOW_ERROR_TYPE_ITEM_NUM,
2179                                    NULL, "NULL pattern.");
2180                 return -rte_errno;
2181         }
2182
2183         if (!actions || actions->type == RTE_FLOW_ACTION_TYPE_END) {
2184                 rte_flow_error_set(error, EINVAL,
2185                                    RTE_FLOW_ERROR_TYPE_ACTION_NUM,
2186                                    NULL, "NULL action.");
2187                 return -rte_errno;
2188         }
2189
2190         if (!attr) {
2191                 rte_flow_error_set(error, EINVAL,
2192                                    RTE_FLOW_ERROR_TYPE_ATTR,
2193                                    NULL, "NULL attribute.");
2194                 return -rte_errno;
2195         }
2196
2197         ret = ice_flow_valid_attr(ad, attr, &ice_pipeline_stage, error);
2198         if (ret)
2199                 return ret;
2200
2201         *engine = ice_parse_engine(ad, flow, &pf->rss_parser_list,
2202                         pattern, actions, error);
2203         if (*engine != NULL)
2204                 return 0;
2205
2206         switch (ice_pipeline_stage) {
2207         case ICE_FLOW_CLASSIFY_STAGE_DISTRIBUTOR_ONLY:
2208         case ICE_FLOW_CLASSIFY_STAGE_DISTRIBUTOR:
2209                 *engine = ice_parse_engine(ad, flow, &pf->dist_parser_list,
2210                                 pattern, actions, error);
2211                 break;
2212         case ICE_FLOW_CLASSIFY_STAGE_PERMISSION:
2213                 *engine = ice_parse_engine(ad, flow, &pf->perm_parser_list,
2214                                 pattern, actions, error);
2215                 break;
2216         default:
2217                 return -EINVAL;
2218         }
2219
2220         if (*engine == NULL)
2221                 return -EINVAL;
2222
2223         return 0;
2224 }
2225
2226 static int
2227 ice_flow_validate(struct rte_eth_dev *dev,
2228                 const struct rte_flow_attr *attr,
2229                 const struct rte_flow_item pattern[],
2230                 const struct rte_flow_action actions[],
2231                 struct rte_flow_error *error)
2232 {
2233         struct ice_flow_engine *engine;
2234
2235         return ice_flow_process_filter(dev, NULL, attr, pattern, actions,
2236                         &engine, ice_parse_engine_validate, error);
2237 }
2238
2239 static struct rte_flow *
2240 ice_flow_create(struct rte_eth_dev *dev,
2241                 const struct rte_flow_attr *attr,
2242                 const struct rte_flow_item pattern[],
2243                 const struct rte_flow_action actions[],
2244                 struct rte_flow_error *error)
2245 {
2246         struct ice_pf *pf = ICE_DEV_PRIVATE_TO_PF(dev->data->dev_private);
2247         struct rte_flow *flow = NULL;
2248         int ret;
2249         struct ice_flow_engine *engine = NULL;
2250
2251         flow = rte_zmalloc("ice_flow", sizeof(struct rte_flow), 0);
2252         if (!flow) {
2253                 rte_flow_error_set(error, ENOMEM,
2254                                    RTE_FLOW_ERROR_TYPE_HANDLE, NULL,
2255                                    "Failed to allocate memory");
2256                 return flow;
2257         }
2258
2259         rte_spinlock_lock(&pf->flow_ops_lock);
2260
2261         ret = ice_flow_process_filter(dev, flow, attr, pattern, actions,
2262                         &engine, ice_parse_engine_create, error);
2263         if (ret < 0) {
2264                 PMD_DRV_LOG(ERR, "Failed to create flow");
2265                 rte_free(flow);
2266                 flow = NULL;
2267                 goto out;
2268         }
2269
2270         flow->engine = engine;
2271         TAILQ_INSERT_TAIL(&pf->flow_list, flow, node);
2272         PMD_DRV_LOG(INFO, "Succeeded to create (%d) flow", engine->type);
2273
2274 out:
2275         rte_spinlock_unlock(&pf->flow_ops_lock);
2276         return flow;
2277 }
2278
2279 static int
2280 ice_flow_destroy(struct rte_eth_dev *dev,
2281                 struct rte_flow *flow,
2282                 struct rte_flow_error *error)
2283 {
2284         struct ice_pf *pf = ICE_DEV_PRIVATE_TO_PF(dev->data->dev_private);
2285         struct ice_adapter *ad =
2286                 ICE_DEV_PRIVATE_TO_ADAPTER(dev->data->dev_private);
2287         int ret = 0;
2288
2289         if (!flow || !flow->engine || !flow->engine->destroy) {
2290                 rte_flow_error_set(error, EINVAL,
2291                                 RTE_FLOW_ERROR_TYPE_HANDLE,
2292                                 NULL, "Invalid flow");
2293                 return -rte_errno;
2294         }
2295
2296         rte_spinlock_lock(&pf->flow_ops_lock);
2297
2298         ret = flow->engine->destroy(ad, flow, error);
2299         if (!ret) {
2300                 TAILQ_REMOVE(&pf->flow_list, flow, node);
2301                 rte_free(flow);
2302         } else {
2303                 PMD_DRV_LOG(ERR, "Failed to destroy flow");
2304         }
2305
2306         rte_spinlock_unlock(&pf->flow_ops_lock);
2307
2308         return ret;
2309 }
2310
2311 static int
2312 ice_flow_flush(struct rte_eth_dev *dev,
2313                 struct rte_flow_error *error)
2314 {
2315         struct ice_pf *pf = ICE_DEV_PRIVATE_TO_PF(dev->data->dev_private);
2316         struct rte_flow *p_flow;
2317         void *temp;
2318         int ret = 0;
2319
2320         TAILQ_FOREACH_SAFE(p_flow, &pf->flow_list, node, temp) {
2321                 ret = ice_flow_destroy(dev, p_flow, error);
2322                 if (ret) {
2323                         PMD_DRV_LOG(ERR, "Failed to flush flows");
2324                         return -EINVAL;
2325                 }
2326         }
2327
2328         return ret;
2329 }
2330
2331 static int
2332 ice_flow_query(struct rte_eth_dev *dev,
2333                 struct rte_flow *flow,
2334                 const struct rte_flow_action *actions,
2335                 void *data,
2336                 struct rte_flow_error *error)
2337 {
2338         int ret = -EINVAL;
2339         struct ice_adapter *ad =
2340                 ICE_DEV_PRIVATE_TO_ADAPTER(dev->data->dev_private);
2341         struct rte_flow_query_count *count = data;
2342         struct ice_pf *pf = &ad->pf;
2343
2344         if (!flow || !flow->engine || !flow->engine->query_count) {
2345                 rte_flow_error_set(error, EINVAL,
2346                                 RTE_FLOW_ERROR_TYPE_HANDLE,
2347                                 NULL, "Invalid flow");
2348                 return -rte_errno;
2349         }
2350
2351         rte_spinlock_lock(&pf->flow_ops_lock);
2352
2353         for (; actions->type != RTE_FLOW_ACTION_TYPE_END; actions++) {
2354                 switch (actions->type) {
2355                 case RTE_FLOW_ACTION_TYPE_VOID:
2356                         break;
2357                 case RTE_FLOW_ACTION_TYPE_COUNT:
2358                         ret = flow->engine->query_count(ad, flow, count, error);
2359                         break;
2360                 default:
2361                         return rte_flow_error_set(error, ENOTSUP,
2362                                         RTE_FLOW_ERROR_TYPE_ACTION,
2363                                         actions,
2364                                         "action not supported");
2365                 }
2366         }
2367
2368         rte_spinlock_unlock(&pf->flow_ops_lock);
2369
2370         return ret;
2371 }
2372
2373 int
2374 ice_flow_redirect(struct ice_adapter *ad,
2375                   struct ice_flow_redirect *rd)
2376 {
2377         struct ice_pf *pf = &ad->pf;
2378         struct rte_flow *p_flow;
2379         void *temp;
2380         int ret;
2381
2382         rte_spinlock_lock(&pf->flow_ops_lock);
2383
2384         TAILQ_FOREACH_SAFE(p_flow, &pf->flow_list, node, temp) {
2385                 if (!p_flow->engine->redirect)
2386                         continue;
2387                 ret = p_flow->engine->redirect(ad, p_flow, rd);
2388                 if (ret) {
2389                         PMD_DRV_LOG(ERR, "Failed to redirect flows");
2390                         return ret;
2391                 }
2392         }
2393
2394         rte_spinlock_unlock(&pf->flow_ops_lock);
2395
2396         return 0;
2397 }