net/i40e: fix Rx packet statistics
[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 <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_frag_ext[] = {
216         RTE_FLOW_ITEM_TYPE_ETH,
217         RTE_FLOW_ITEM_TYPE_IPV6,
218         RTE_FLOW_ITEM_TYPE_IPV6_FRAG_EXT,
219         RTE_FLOW_ITEM_TYPE_END,
220 };
221 enum rte_flow_item_type pattern_eth_vlan_ipv6_frag_ext[] = {
222         RTE_FLOW_ITEM_TYPE_ETH,
223         RTE_FLOW_ITEM_TYPE_VLAN,
224         RTE_FLOW_ITEM_TYPE_IPV6,
225         RTE_FLOW_ITEM_TYPE_IPV6_FRAG_EXT,
226         RTE_FLOW_ITEM_TYPE_END,
227 };
228 enum rte_flow_item_type pattern_eth_qinq_ipv6_frag_ext[] = {
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_IPV6_FRAG_EXT,
234         RTE_FLOW_ITEM_TYPE_END,
235 };
236 enum rte_flow_item_type pattern_eth_ipv6_udp[] = {
237         RTE_FLOW_ITEM_TYPE_ETH,
238         RTE_FLOW_ITEM_TYPE_IPV6,
239         RTE_FLOW_ITEM_TYPE_UDP,
240         RTE_FLOW_ITEM_TYPE_END,
241 };
242 enum rte_flow_item_type pattern_eth_vlan_ipv6_udp[] = {
243         RTE_FLOW_ITEM_TYPE_ETH,
244         RTE_FLOW_ITEM_TYPE_VLAN,
245         RTE_FLOW_ITEM_TYPE_IPV6,
246         RTE_FLOW_ITEM_TYPE_UDP,
247         RTE_FLOW_ITEM_TYPE_END,
248 };
249 enum rte_flow_item_type pattern_eth_qinq_ipv6_udp[] = {
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_UDP,
255         RTE_FLOW_ITEM_TYPE_END,
256 };
257 enum rte_flow_item_type pattern_eth_ipv6_tcp[] = {
258         RTE_FLOW_ITEM_TYPE_ETH,
259         RTE_FLOW_ITEM_TYPE_IPV6,
260         RTE_FLOW_ITEM_TYPE_TCP,
261         RTE_FLOW_ITEM_TYPE_END,
262 };
263 enum rte_flow_item_type pattern_eth_vlan_ipv6_tcp[] = {
264         RTE_FLOW_ITEM_TYPE_ETH,
265         RTE_FLOW_ITEM_TYPE_VLAN,
266         RTE_FLOW_ITEM_TYPE_IPV6,
267         RTE_FLOW_ITEM_TYPE_TCP,
268         RTE_FLOW_ITEM_TYPE_END,
269 };
270 enum rte_flow_item_type pattern_eth_qinq_ipv6_tcp[] = {
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_TCP,
276         RTE_FLOW_ITEM_TYPE_END,
277 };
278 enum rte_flow_item_type pattern_eth_ipv6_sctp[] = {
279         RTE_FLOW_ITEM_TYPE_ETH,
280         RTE_FLOW_ITEM_TYPE_IPV6,
281         RTE_FLOW_ITEM_TYPE_SCTP,
282         RTE_FLOW_ITEM_TYPE_END,
283 };
284 enum rte_flow_item_type pattern_eth_vlan_ipv6_sctp[] = {
285         RTE_FLOW_ITEM_TYPE_ETH,
286         RTE_FLOW_ITEM_TYPE_VLAN,
287         RTE_FLOW_ITEM_TYPE_IPV6,
288         RTE_FLOW_ITEM_TYPE_SCTP,
289         RTE_FLOW_ITEM_TYPE_END,
290 };
291 enum rte_flow_item_type pattern_eth_qinq_ipv6_sctp[] = {
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_SCTP,
297         RTE_FLOW_ITEM_TYPE_END,
298 };
299 enum rte_flow_item_type pattern_eth_ipv6_icmp6[] = {
300         RTE_FLOW_ITEM_TYPE_ETH,
301         RTE_FLOW_ITEM_TYPE_IPV6,
302         RTE_FLOW_ITEM_TYPE_ICMP6,
303         RTE_FLOW_ITEM_TYPE_END,
304 };
305 enum rte_flow_item_type pattern_eth_vlan_ipv6_icmp6[] = {
306         RTE_FLOW_ITEM_TYPE_ETH,
307         RTE_FLOW_ITEM_TYPE_VLAN,
308         RTE_FLOW_ITEM_TYPE_IPV6,
309         RTE_FLOW_ITEM_TYPE_ICMP6,
310         RTE_FLOW_ITEM_TYPE_END,
311 };
312 enum rte_flow_item_type pattern_eth_qinq_ipv6_icmp6[] = {
313         RTE_FLOW_ITEM_TYPE_ETH,
314         RTE_FLOW_ITEM_TYPE_VLAN,
315         RTE_FLOW_ITEM_TYPE_VLAN,
316         RTE_FLOW_ITEM_TYPE_IPV6,
317         RTE_FLOW_ITEM_TYPE_ICMP6,
318         RTE_FLOW_ITEM_TYPE_END,
319 };
320
321 /* IPv4 VXLAN IPv4 */
322 enum rte_flow_item_type pattern_eth_ipv4_udp_vxlan_ipv4[] = {
323         RTE_FLOW_ITEM_TYPE_ETH,
324         RTE_FLOW_ITEM_TYPE_IPV4,
325         RTE_FLOW_ITEM_TYPE_UDP,
326         RTE_FLOW_ITEM_TYPE_VXLAN,
327         RTE_FLOW_ITEM_TYPE_IPV4,
328         RTE_FLOW_ITEM_TYPE_END,
329 };
330 enum rte_flow_item_type pattern_eth_ipv4_udp_vxlan_ipv4_udp[] = {
331         RTE_FLOW_ITEM_TYPE_ETH,
332         RTE_FLOW_ITEM_TYPE_IPV4,
333         RTE_FLOW_ITEM_TYPE_UDP,
334         RTE_FLOW_ITEM_TYPE_VXLAN,
335         RTE_FLOW_ITEM_TYPE_IPV4,
336         RTE_FLOW_ITEM_TYPE_UDP,
337         RTE_FLOW_ITEM_TYPE_END,
338 };
339 enum rte_flow_item_type pattern_eth_ipv4_udp_vxlan_ipv4_tcp[] = {
340         RTE_FLOW_ITEM_TYPE_ETH,
341         RTE_FLOW_ITEM_TYPE_IPV4,
342         RTE_FLOW_ITEM_TYPE_UDP,
343         RTE_FLOW_ITEM_TYPE_VXLAN,
344         RTE_FLOW_ITEM_TYPE_IPV4,
345         RTE_FLOW_ITEM_TYPE_TCP,
346         RTE_FLOW_ITEM_TYPE_END,
347 };
348 enum rte_flow_item_type pattern_eth_ipv4_udp_vxlan_ipv4_sctp[] = {
349         RTE_FLOW_ITEM_TYPE_ETH,
350         RTE_FLOW_ITEM_TYPE_IPV4,
351         RTE_FLOW_ITEM_TYPE_UDP,
352         RTE_FLOW_ITEM_TYPE_VXLAN,
353         RTE_FLOW_ITEM_TYPE_IPV4,
354         RTE_FLOW_ITEM_TYPE_SCTP,
355         RTE_FLOW_ITEM_TYPE_END,
356 };
357 enum rte_flow_item_type pattern_eth_ipv4_udp_vxlan_ipv4_icmp[] = {
358         RTE_FLOW_ITEM_TYPE_ETH,
359         RTE_FLOW_ITEM_TYPE_IPV4,
360         RTE_FLOW_ITEM_TYPE_UDP,
361         RTE_FLOW_ITEM_TYPE_VXLAN,
362         RTE_FLOW_ITEM_TYPE_IPV4,
363         RTE_FLOW_ITEM_TYPE_ICMP,
364         RTE_FLOW_ITEM_TYPE_END,
365 };
366
367 /* IPv4 VXLAN MAC IPv4 */
368 enum rte_flow_item_type pattern_eth_ipv4_udp_vxlan_eth_ipv4[] = {
369         RTE_FLOW_ITEM_TYPE_ETH,
370         RTE_FLOW_ITEM_TYPE_IPV4,
371         RTE_FLOW_ITEM_TYPE_UDP,
372         RTE_FLOW_ITEM_TYPE_VXLAN,
373         RTE_FLOW_ITEM_TYPE_ETH,
374         RTE_FLOW_ITEM_TYPE_IPV4,
375         RTE_FLOW_ITEM_TYPE_END,
376 };
377 enum rte_flow_item_type pattern_eth_ipv4_udp_vxlan_eth_ipv4_udp[] = {
378         RTE_FLOW_ITEM_TYPE_ETH,
379         RTE_FLOW_ITEM_TYPE_IPV4,
380         RTE_FLOW_ITEM_TYPE_UDP,
381         RTE_FLOW_ITEM_TYPE_VXLAN,
382         RTE_FLOW_ITEM_TYPE_ETH,
383         RTE_FLOW_ITEM_TYPE_IPV4,
384         RTE_FLOW_ITEM_TYPE_UDP,
385         RTE_FLOW_ITEM_TYPE_END,
386 };
387 enum rte_flow_item_type pattern_eth_ipv4_udp_vxlan_eth_ipv4_tcp[] = {
388         RTE_FLOW_ITEM_TYPE_ETH,
389         RTE_FLOW_ITEM_TYPE_IPV4,
390         RTE_FLOW_ITEM_TYPE_UDP,
391         RTE_FLOW_ITEM_TYPE_VXLAN,
392         RTE_FLOW_ITEM_TYPE_ETH,
393         RTE_FLOW_ITEM_TYPE_IPV4,
394         RTE_FLOW_ITEM_TYPE_TCP,
395         RTE_FLOW_ITEM_TYPE_END,
396 };
397 enum rte_flow_item_type pattern_eth_ipv4_udp_vxlan_eth_ipv4_sctp[] = {
398         RTE_FLOW_ITEM_TYPE_ETH,
399         RTE_FLOW_ITEM_TYPE_IPV4,
400         RTE_FLOW_ITEM_TYPE_UDP,
401         RTE_FLOW_ITEM_TYPE_VXLAN,
402         RTE_FLOW_ITEM_TYPE_ETH,
403         RTE_FLOW_ITEM_TYPE_IPV4,
404         RTE_FLOW_ITEM_TYPE_SCTP,
405         RTE_FLOW_ITEM_TYPE_END,
406 };
407 enum rte_flow_item_type pattern_eth_ipv4_udp_vxlan_eth_ipv4_icmp[] = {
408         RTE_FLOW_ITEM_TYPE_ETH,
409         RTE_FLOW_ITEM_TYPE_IPV4,
410         RTE_FLOW_ITEM_TYPE_UDP,
411         RTE_FLOW_ITEM_TYPE_VXLAN,
412         RTE_FLOW_ITEM_TYPE_ETH,
413         RTE_FLOW_ITEM_TYPE_IPV4,
414         RTE_FLOW_ITEM_TYPE_ICMP,
415         RTE_FLOW_ITEM_TYPE_END,
416 };
417
418 /* IPv6 VXLAN IPv4 */
419 enum rte_flow_item_type pattern_eth_ipv6_udp_vxlan_ipv4[] = {
420         RTE_FLOW_ITEM_TYPE_ETH,
421         RTE_FLOW_ITEM_TYPE_IPV6,
422         RTE_FLOW_ITEM_TYPE_UDP,
423         RTE_FLOW_ITEM_TYPE_VXLAN,
424         RTE_FLOW_ITEM_TYPE_IPV4,
425         RTE_FLOW_ITEM_TYPE_END,
426 };
427 enum rte_flow_item_type pattern_eth_ipv6_udp_vxlan_ipv4_tcp[] = {
428         RTE_FLOW_ITEM_TYPE_ETH,
429         RTE_FLOW_ITEM_TYPE_IPV6,
430         RTE_FLOW_ITEM_TYPE_UDP,
431         RTE_FLOW_ITEM_TYPE_VXLAN,
432         RTE_FLOW_ITEM_TYPE_IPV4,
433         RTE_FLOW_ITEM_TYPE_TCP,
434         RTE_FLOW_ITEM_TYPE_END,
435 };
436 enum rte_flow_item_type pattern_eth_ipv6_udp_vxlan_ipv4_udp[] = {
437         RTE_FLOW_ITEM_TYPE_ETH,
438         RTE_FLOW_ITEM_TYPE_IPV6,
439         RTE_FLOW_ITEM_TYPE_UDP,
440         RTE_FLOW_ITEM_TYPE_VXLAN,
441         RTE_FLOW_ITEM_TYPE_IPV4,
442         RTE_FLOW_ITEM_TYPE_UDP,
443         RTE_FLOW_ITEM_TYPE_END,
444 };
445 enum rte_flow_item_type pattern_eth_ipv6_udp_vxlan_ipv4_sctp[] = {
446         RTE_FLOW_ITEM_TYPE_ETH,
447         RTE_FLOW_ITEM_TYPE_IPV6,
448         RTE_FLOW_ITEM_TYPE_UDP,
449         RTE_FLOW_ITEM_TYPE_VXLAN,
450         RTE_FLOW_ITEM_TYPE_IPV4,
451         RTE_FLOW_ITEM_TYPE_SCTP,
452         RTE_FLOW_ITEM_TYPE_END,
453 };
454 enum rte_flow_item_type pattern_eth_ipv6_udp_vxlan_ipv4_icmp[] = {
455         RTE_FLOW_ITEM_TYPE_ETH,
456         RTE_FLOW_ITEM_TYPE_IPV6,
457         RTE_FLOW_ITEM_TYPE_UDP,
458         RTE_FLOW_ITEM_TYPE_VXLAN,
459         RTE_FLOW_ITEM_TYPE_IPV4,
460         RTE_FLOW_ITEM_TYPE_ICMP,
461         RTE_FLOW_ITEM_TYPE_END,
462 };
463
464 /* IPv6 VXLAN MAC IPv4 */
465 enum rte_flow_item_type pattern_eth_ipv6_udp_vxlan_eth_ipv4[] = {
466         RTE_FLOW_ITEM_TYPE_ETH,
467         RTE_FLOW_ITEM_TYPE_IPV6,
468         RTE_FLOW_ITEM_TYPE_UDP,
469         RTE_FLOW_ITEM_TYPE_VXLAN,
470         RTE_FLOW_ITEM_TYPE_ETH,
471         RTE_FLOW_ITEM_TYPE_IPV4,
472         RTE_FLOW_ITEM_TYPE_END,
473 };
474 enum rte_flow_item_type pattern_eth_ipv6_udp_vxlan_eth_ipv4_tcp[] = {
475         RTE_FLOW_ITEM_TYPE_ETH,
476         RTE_FLOW_ITEM_TYPE_IPV6,
477         RTE_FLOW_ITEM_TYPE_UDP,
478         RTE_FLOW_ITEM_TYPE_VXLAN,
479         RTE_FLOW_ITEM_TYPE_ETH,
480         RTE_FLOW_ITEM_TYPE_IPV4,
481         RTE_FLOW_ITEM_TYPE_TCP,
482         RTE_FLOW_ITEM_TYPE_END,
483 };
484 enum rte_flow_item_type pattern_eth_ipv6_udp_vxlan_eth_ipv4_udp[] = {
485         RTE_FLOW_ITEM_TYPE_ETH,
486         RTE_FLOW_ITEM_TYPE_IPV6,
487         RTE_FLOW_ITEM_TYPE_UDP,
488         RTE_FLOW_ITEM_TYPE_VXLAN,
489         RTE_FLOW_ITEM_TYPE_ETH,
490         RTE_FLOW_ITEM_TYPE_IPV4,
491         RTE_FLOW_ITEM_TYPE_UDP,
492         RTE_FLOW_ITEM_TYPE_END,
493 };
494 enum rte_flow_item_type pattern_eth_ipv6_udp_vxlan_eth_ipv4_sctp[] = {
495         RTE_FLOW_ITEM_TYPE_ETH,
496         RTE_FLOW_ITEM_TYPE_IPV6,
497         RTE_FLOW_ITEM_TYPE_UDP,
498         RTE_FLOW_ITEM_TYPE_VXLAN,
499         RTE_FLOW_ITEM_TYPE_ETH,
500         RTE_FLOW_ITEM_TYPE_IPV4,
501         RTE_FLOW_ITEM_TYPE_SCTP,
502         RTE_FLOW_ITEM_TYPE_END,
503 };
504 enum rte_flow_item_type pattern_eth_ipv6_udp_vxlan_eth_ipv4_icmp[] = {
505         RTE_FLOW_ITEM_TYPE_ETH,
506         RTE_FLOW_ITEM_TYPE_IPV6,
507         RTE_FLOW_ITEM_TYPE_UDP,
508         RTE_FLOW_ITEM_TYPE_VXLAN,
509         RTE_FLOW_ITEM_TYPE_ETH,
510         RTE_FLOW_ITEM_TYPE_IPV4,
511         RTE_FLOW_ITEM_TYPE_ICMP,
512         RTE_FLOW_ITEM_TYPE_END,
513 };
514
515 /* IPv4 VXLAN IPv6 */
516 enum rte_flow_item_type pattern_eth_ipv4_udp_vxlan_ipv6[] = {
517         RTE_FLOW_ITEM_TYPE_ETH,
518         RTE_FLOW_ITEM_TYPE_IPV4,
519         RTE_FLOW_ITEM_TYPE_UDP,
520         RTE_FLOW_ITEM_TYPE_VXLAN,
521         RTE_FLOW_ITEM_TYPE_IPV6,
522         RTE_FLOW_ITEM_TYPE_END,
523 };
524 enum rte_flow_item_type pattern_eth_ipv4_udp_vxlan_ipv6_udp[] = {
525         RTE_FLOW_ITEM_TYPE_ETH,
526         RTE_FLOW_ITEM_TYPE_IPV4,
527         RTE_FLOW_ITEM_TYPE_UDP,
528         RTE_FLOW_ITEM_TYPE_VXLAN,
529         RTE_FLOW_ITEM_TYPE_IPV6,
530         RTE_FLOW_ITEM_TYPE_UDP,
531         RTE_FLOW_ITEM_TYPE_END,
532 };
533 enum rte_flow_item_type pattern_eth_ipv4_udp_vxlan_ipv6_tcp[] = {
534         RTE_FLOW_ITEM_TYPE_ETH,
535         RTE_FLOW_ITEM_TYPE_IPV4,
536         RTE_FLOW_ITEM_TYPE_UDP,
537         RTE_FLOW_ITEM_TYPE_VXLAN,
538         RTE_FLOW_ITEM_TYPE_IPV6,
539         RTE_FLOW_ITEM_TYPE_TCP,
540         RTE_FLOW_ITEM_TYPE_END,
541 };
542 enum rte_flow_item_type pattern_eth_ipv4_udp_vxlan_ipv6_sctp[] = {
543         RTE_FLOW_ITEM_TYPE_ETH,
544         RTE_FLOW_ITEM_TYPE_IPV4,
545         RTE_FLOW_ITEM_TYPE_UDP,
546         RTE_FLOW_ITEM_TYPE_VXLAN,
547         RTE_FLOW_ITEM_TYPE_IPV6,
548         RTE_FLOW_ITEM_TYPE_SCTP,
549         RTE_FLOW_ITEM_TYPE_END,
550 };
551 enum rte_flow_item_type pattern_eth_ipv4_udp_vxlan_ipv6_icmp6[] = {
552         RTE_FLOW_ITEM_TYPE_ETH,
553         RTE_FLOW_ITEM_TYPE_IPV4,
554         RTE_FLOW_ITEM_TYPE_UDP,
555         RTE_FLOW_ITEM_TYPE_VXLAN,
556         RTE_FLOW_ITEM_TYPE_IPV6,
557         RTE_FLOW_ITEM_TYPE_ICMP6,
558         RTE_FLOW_ITEM_TYPE_END,
559 };
560
561 /* IPv4 VXLAN MAC IPv6 */
562 enum rte_flow_item_type pattern_eth_ipv4_udp_vxlan_eth_ipv6[] = {
563         RTE_FLOW_ITEM_TYPE_ETH,
564         RTE_FLOW_ITEM_TYPE_IPV4,
565         RTE_FLOW_ITEM_TYPE_UDP,
566         RTE_FLOW_ITEM_TYPE_VXLAN,
567         RTE_FLOW_ITEM_TYPE_ETH,
568         RTE_FLOW_ITEM_TYPE_IPV6,
569         RTE_FLOW_ITEM_TYPE_END,
570 };
571 enum rte_flow_item_type pattern_eth_ipv4_udp_vxlan_eth_ipv6_udp[] = {
572         RTE_FLOW_ITEM_TYPE_ETH,
573         RTE_FLOW_ITEM_TYPE_IPV4,
574         RTE_FLOW_ITEM_TYPE_UDP,
575         RTE_FLOW_ITEM_TYPE_VXLAN,
576         RTE_FLOW_ITEM_TYPE_ETH,
577         RTE_FLOW_ITEM_TYPE_IPV6,
578         RTE_FLOW_ITEM_TYPE_UDP,
579         RTE_FLOW_ITEM_TYPE_END,
580 };
581 enum rte_flow_item_type pattern_eth_ipv4_udp_vxlan_eth_ipv6_tcp[] = {
582         RTE_FLOW_ITEM_TYPE_ETH,
583         RTE_FLOW_ITEM_TYPE_IPV4,
584         RTE_FLOW_ITEM_TYPE_UDP,
585         RTE_FLOW_ITEM_TYPE_VXLAN,
586         RTE_FLOW_ITEM_TYPE_ETH,
587         RTE_FLOW_ITEM_TYPE_IPV6,
588         RTE_FLOW_ITEM_TYPE_TCP,
589         RTE_FLOW_ITEM_TYPE_END,
590 };
591 enum rte_flow_item_type pattern_eth_ipv4_udp_vxlan_eth_ipv6_sctp[] = {
592         RTE_FLOW_ITEM_TYPE_ETH,
593         RTE_FLOW_ITEM_TYPE_IPV4,
594         RTE_FLOW_ITEM_TYPE_UDP,
595         RTE_FLOW_ITEM_TYPE_VXLAN,
596         RTE_FLOW_ITEM_TYPE_ETH,
597         RTE_FLOW_ITEM_TYPE_IPV6,
598         RTE_FLOW_ITEM_TYPE_SCTP,
599         RTE_FLOW_ITEM_TYPE_END,
600 };
601 enum rte_flow_item_type pattern_eth_ipv4_udp_vxlan_eth_ipv6_icmp6[] = {
602         RTE_FLOW_ITEM_TYPE_ETH,
603         RTE_FLOW_ITEM_TYPE_IPV4,
604         RTE_FLOW_ITEM_TYPE_UDP,
605         RTE_FLOW_ITEM_TYPE_VXLAN,
606         RTE_FLOW_ITEM_TYPE_ETH,
607         RTE_FLOW_ITEM_TYPE_IPV6,
608         RTE_FLOW_ITEM_TYPE_ICMP6,
609         RTE_FLOW_ITEM_TYPE_END,
610 };
611
612 /* IPv6 VXLAN IPv6 */
613 enum rte_flow_item_type pattern_eth_ipv6_udp_vxlan_ipv6[] = {
614         RTE_FLOW_ITEM_TYPE_ETH,
615         RTE_FLOW_ITEM_TYPE_IPV6,
616         RTE_FLOW_ITEM_TYPE_UDP,
617         RTE_FLOW_ITEM_TYPE_VXLAN,
618         RTE_FLOW_ITEM_TYPE_IPV6,
619         RTE_FLOW_ITEM_TYPE_END,
620 };
621 enum rte_flow_item_type pattern_eth_ipv6_udp_vxlan_ipv6_tcp[] = {
622         RTE_FLOW_ITEM_TYPE_ETH,
623         RTE_FLOW_ITEM_TYPE_IPV6,
624         RTE_FLOW_ITEM_TYPE_UDP,
625         RTE_FLOW_ITEM_TYPE_VXLAN,
626         RTE_FLOW_ITEM_TYPE_IPV6,
627         RTE_FLOW_ITEM_TYPE_TCP,
628         RTE_FLOW_ITEM_TYPE_END,
629 };
630 enum rte_flow_item_type pattern_eth_ipv6_udp_vxlan_ipv6_udp[] = {
631         RTE_FLOW_ITEM_TYPE_ETH,
632         RTE_FLOW_ITEM_TYPE_IPV6,
633         RTE_FLOW_ITEM_TYPE_UDP,
634         RTE_FLOW_ITEM_TYPE_VXLAN,
635         RTE_FLOW_ITEM_TYPE_IPV6,
636         RTE_FLOW_ITEM_TYPE_UDP,
637         RTE_FLOW_ITEM_TYPE_END,
638 };
639 enum rte_flow_item_type pattern_eth_ipv6_udp_vxlan_ipv6_sctp[] = {
640         RTE_FLOW_ITEM_TYPE_ETH,
641         RTE_FLOW_ITEM_TYPE_IPV6,
642         RTE_FLOW_ITEM_TYPE_UDP,
643         RTE_FLOW_ITEM_TYPE_VXLAN,
644         RTE_FLOW_ITEM_TYPE_IPV6,
645         RTE_FLOW_ITEM_TYPE_SCTP,
646         RTE_FLOW_ITEM_TYPE_END,
647 };
648 enum rte_flow_item_type pattern_eth_ipv6_udp_vxlan_ipv6_icmp6[] = {
649         RTE_FLOW_ITEM_TYPE_ETH,
650         RTE_FLOW_ITEM_TYPE_IPV6,
651         RTE_FLOW_ITEM_TYPE_UDP,
652         RTE_FLOW_ITEM_TYPE_VXLAN,
653         RTE_FLOW_ITEM_TYPE_IPV6,
654         RTE_FLOW_ITEM_TYPE_ICMP6,
655         RTE_FLOW_ITEM_TYPE_END,
656 };
657
658 /* IPv6 VXLAN MAC IPv6 */
659 enum rte_flow_item_type pattern_eth_ipv6_udp_vxlan_eth_ipv6[] = {
660         RTE_FLOW_ITEM_TYPE_ETH,
661         RTE_FLOW_ITEM_TYPE_IPV6,
662         RTE_FLOW_ITEM_TYPE_UDP,
663         RTE_FLOW_ITEM_TYPE_VXLAN,
664         RTE_FLOW_ITEM_TYPE_ETH,
665         RTE_FLOW_ITEM_TYPE_IPV6,
666         RTE_FLOW_ITEM_TYPE_END,
667 };
668 enum rte_flow_item_type pattern_eth_ipv6_udp_vxlan_eth_ipv6_tcp[] = {
669         RTE_FLOW_ITEM_TYPE_ETH,
670         RTE_FLOW_ITEM_TYPE_IPV6,
671         RTE_FLOW_ITEM_TYPE_UDP,
672         RTE_FLOW_ITEM_TYPE_VXLAN,
673         RTE_FLOW_ITEM_TYPE_ETH,
674         RTE_FLOW_ITEM_TYPE_IPV6,
675         RTE_FLOW_ITEM_TYPE_TCP,
676         RTE_FLOW_ITEM_TYPE_END,
677 };
678 enum rte_flow_item_type pattern_eth_ipv6_udp_vxlan_eth_ipv6_udp[] = {
679         RTE_FLOW_ITEM_TYPE_ETH,
680         RTE_FLOW_ITEM_TYPE_IPV6,
681         RTE_FLOW_ITEM_TYPE_UDP,
682         RTE_FLOW_ITEM_TYPE_VXLAN,
683         RTE_FLOW_ITEM_TYPE_ETH,
684         RTE_FLOW_ITEM_TYPE_IPV6,
685         RTE_FLOW_ITEM_TYPE_UDP,
686         RTE_FLOW_ITEM_TYPE_END,
687 };
688 enum rte_flow_item_type pattern_eth_ipv6_udp_vxlan_eth_ipv6_sctp[] = {
689         RTE_FLOW_ITEM_TYPE_ETH,
690         RTE_FLOW_ITEM_TYPE_IPV6,
691         RTE_FLOW_ITEM_TYPE_UDP,
692         RTE_FLOW_ITEM_TYPE_VXLAN,
693         RTE_FLOW_ITEM_TYPE_ETH,
694         RTE_FLOW_ITEM_TYPE_IPV6,
695         RTE_FLOW_ITEM_TYPE_SCTP,
696         RTE_FLOW_ITEM_TYPE_END,
697 };
698 enum rte_flow_item_type pattern_eth_ipv6_udp_vxlan_eth_ipv6_icmp6[] = {
699         RTE_FLOW_ITEM_TYPE_ETH,
700         RTE_FLOW_ITEM_TYPE_IPV6,
701         RTE_FLOW_ITEM_TYPE_UDP,
702         RTE_FLOW_ITEM_TYPE_VXLAN,
703         RTE_FLOW_ITEM_TYPE_ETH,
704         RTE_FLOW_ITEM_TYPE_IPV6,
705         RTE_FLOW_ITEM_TYPE_ICMP6,
706         RTE_FLOW_ITEM_TYPE_END,
707 };
708
709 /* IPv4 NVGRE IPv4 */
710 enum rte_flow_item_type pattern_eth_ipv4_nvgre_ipv4[] = {
711         RTE_FLOW_ITEM_TYPE_ETH,
712         RTE_FLOW_ITEM_TYPE_IPV4,
713         RTE_FLOW_ITEM_TYPE_NVGRE,
714         RTE_FLOW_ITEM_TYPE_IPV4,
715         RTE_FLOW_ITEM_TYPE_END,
716 };
717 enum rte_flow_item_type pattern_eth_ipv4_nvgre_ipv4_udp[] = {
718         RTE_FLOW_ITEM_TYPE_ETH,
719         RTE_FLOW_ITEM_TYPE_IPV4,
720         RTE_FLOW_ITEM_TYPE_NVGRE,
721         RTE_FLOW_ITEM_TYPE_IPV4,
722         RTE_FLOW_ITEM_TYPE_UDP,
723         RTE_FLOW_ITEM_TYPE_END,
724 };
725 enum rte_flow_item_type pattern_eth_ipv4_nvgre_ipv4_tcp[] = {
726         RTE_FLOW_ITEM_TYPE_ETH,
727         RTE_FLOW_ITEM_TYPE_IPV4,
728         RTE_FLOW_ITEM_TYPE_NVGRE,
729         RTE_FLOW_ITEM_TYPE_IPV4,
730         RTE_FLOW_ITEM_TYPE_TCP,
731         RTE_FLOW_ITEM_TYPE_END,
732 };
733 enum rte_flow_item_type pattern_eth_ipv4_nvgre_ipv4_sctp[] = {
734         RTE_FLOW_ITEM_TYPE_ETH,
735         RTE_FLOW_ITEM_TYPE_IPV4,
736         RTE_FLOW_ITEM_TYPE_NVGRE,
737         RTE_FLOW_ITEM_TYPE_IPV4,
738         RTE_FLOW_ITEM_TYPE_SCTP,
739         RTE_FLOW_ITEM_TYPE_END,
740 };
741 enum rte_flow_item_type pattern_eth_ipv4_nvgre_ipv4_icmp[] = {
742         RTE_FLOW_ITEM_TYPE_ETH,
743         RTE_FLOW_ITEM_TYPE_IPV4,
744         RTE_FLOW_ITEM_TYPE_NVGRE,
745         RTE_FLOW_ITEM_TYPE_IPV4,
746         RTE_FLOW_ITEM_TYPE_ICMP,
747         RTE_FLOW_ITEM_TYPE_END,
748 };
749
750 /* IPv4 NVGRE MAC IPv4 */
751 enum rte_flow_item_type pattern_eth_ipv4_nvgre_eth_ipv4[] = {
752         RTE_FLOW_ITEM_TYPE_ETH,
753         RTE_FLOW_ITEM_TYPE_IPV4,
754         RTE_FLOW_ITEM_TYPE_NVGRE,
755         RTE_FLOW_ITEM_TYPE_ETH,
756         RTE_FLOW_ITEM_TYPE_IPV4,
757         RTE_FLOW_ITEM_TYPE_END,
758 };
759 enum rte_flow_item_type pattern_eth_ipv4_nvgre_eth_ipv4_udp[] = {
760         RTE_FLOW_ITEM_TYPE_ETH,
761         RTE_FLOW_ITEM_TYPE_IPV4,
762         RTE_FLOW_ITEM_TYPE_NVGRE,
763         RTE_FLOW_ITEM_TYPE_ETH,
764         RTE_FLOW_ITEM_TYPE_IPV4,
765         RTE_FLOW_ITEM_TYPE_UDP,
766         RTE_FLOW_ITEM_TYPE_END,
767 };
768 enum rte_flow_item_type pattern_eth_ipv4_nvgre_eth_ipv4_tcp[] = {
769         RTE_FLOW_ITEM_TYPE_ETH,
770         RTE_FLOW_ITEM_TYPE_IPV4,
771         RTE_FLOW_ITEM_TYPE_NVGRE,
772         RTE_FLOW_ITEM_TYPE_ETH,
773         RTE_FLOW_ITEM_TYPE_IPV4,
774         RTE_FLOW_ITEM_TYPE_TCP,
775         RTE_FLOW_ITEM_TYPE_END,
776 };
777 enum rte_flow_item_type pattern_eth_ipv4_nvgre_eth_ipv4_sctp[] = {
778         RTE_FLOW_ITEM_TYPE_ETH,
779         RTE_FLOW_ITEM_TYPE_IPV4,
780         RTE_FLOW_ITEM_TYPE_NVGRE,
781         RTE_FLOW_ITEM_TYPE_ETH,
782         RTE_FLOW_ITEM_TYPE_IPV4,
783         RTE_FLOW_ITEM_TYPE_SCTP,
784         RTE_FLOW_ITEM_TYPE_END,
785 };
786 enum rte_flow_item_type pattern_eth_ipv4_nvgre_eth_ipv4_icmp[] = {
787         RTE_FLOW_ITEM_TYPE_ETH,
788         RTE_FLOW_ITEM_TYPE_IPV4,
789         RTE_FLOW_ITEM_TYPE_NVGRE,
790         RTE_FLOW_ITEM_TYPE_ETH,
791         RTE_FLOW_ITEM_TYPE_IPV4,
792         RTE_FLOW_ITEM_TYPE_ICMP,
793         RTE_FLOW_ITEM_TYPE_END,
794 };
795
796 /* IPv6 NVGRE IPv4 */
797 enum rte_flow_item_type pattern_eth_ipv6_nvgre_ipv4[] = {
798         RTE_FLOW_ITEM_TYPE_ETH,
799         RTE_FLOW_ITEM_TYPE_IPV6,
800         RTE_FLOW_ITEM_TYPE_NVGRE,
801         RTE_FLOW_ITEM_TYPE_IPV4,
802         RTE_FLOW_ITEM_TYPE_END,
803 };
804 enum rte_flow_item_type pattern_eth_ipv6_nvgre_ipv4_tcp[] = {
805         RTE_FLOW_ITEM_TYPE_ETH,
806         RTE_FLOW_ITEM_TYPE_IPV6,
807         RTE_FLOW_ITEM_TYPE_NVGRE,
808         RTE_FLOW_ITEM_TYPE_IPV4,
809         RTE_FLOW_ITEM_TYPE_TCP,
810         RTE_FLOW_ITEM_TYPE_END,
811 };
812 enum rte_flow_item_type pattern_eth_ipv6_nvgre_ipv4_udp[] = {
813         RTE_FLOW_ITEM_TYPE_ETH,
814         RTE_FLOW_ITEM_TYPE_IPV6,
815         RTE_FLOW_ITEM_TYPE_NVGRE,
816         RTE_FLOW_ITEM_TYPE_IPV4,
817         RTE_FLOW_ITEM_TYPE_UDP,
818         RTE_FLOW_ITEM_TYPE_END,
819 };
820 enum rte_flow_item_type pattern_eth_ipv6_nvgre_ipv4_sctp[] = {
821         RTE_FLOW_ITEM_TYPE_ETH,
822         RTE_FLOW_ITEM_TYPE_IPV6,
823         RTE_FLOW_ITEM_TYPE_NVGRE,
824         RTE_FLOW_ITEM_TYPE_IPV4,
825         RTE_FLOW_ITEM_TYPE_SCTP,
826         RTE_FLOW_ITEM_TYPE_END,
827 };
828 enum rte_flow_item_type pattern_eth_ipv6_nvgre_ipv4_icmp[] = {
829         RTE_FLOW_ITEM_TYPE_ETH,
830         RTE_FLOW_ITEM_TYPE_IPV6,
831         RTE_FLOW_ITEM_TYPE_NVGRE,
832         RTE_FLOW_ITEM_TYPE_IPV4,
833         RTE_FLOW_ITEM_TYPE_ICMP,
834         RTE_FLOW_ITEM_TYPE_END,
835 };
836
837 /* IPv6 NVGRE MAC IPv4 */
838 enum rte_flow_item_type pattern_eth_ipv6_nvgre_eth_ipv4[] = {
839         RTE_FLOW_ITEM_TYPE_ETH,
840         RTE_FLOW_ITEM_TYPE_IPV6,
841         RTE_FLOW_ITEM_TYPE_NVGRE,
842         RTE_FLOW_ITEM_TYPE_ETH,
843         RTE_FLOW_ITEM_TYPE_IPV4,
844         RTE_FLOW_ITEM_TYPE_END,
845 };
846 enum rte_flow_item_type pattern_eth_ipv6_nvgre_eth_ipv4_tcp[] = {
847         RTE_FLOW_ITEM_TYPE_ETH,
848         RTE_FLOW_ITEM_TYPE_IPV6,
849         RTE_FLOW_ITEM_TYPE_NVGRE,
850         RTE_FLOW_ITEM_TYPE_ETH,
851         RTE_FLOW_ITEM_TYPE_IPV4,
852         RTE_FLOW_ITEM_TYPE_TCP,
853         RTE_FLOW_ITEM_TYPE_END,
854 };
855 enum rte_flow_item_type pattern_eth_ipv6_nvgre_eth_ipv4_udp[] = {
856         RTE_FLOW_ITEM_TYPE_ETH,
857         RTE_FLOW_ITEM_TYPE_IPV6,
858         RTE_FLOW_ITEM_TYPE_NVGRE,
859         RTE_FLOW_ITEM_TYPE_ETH,
860         RTE_FLOW_ITEM_TYPE_IPV4,
861         RTE_FLOW_ITEM_TYPE_UDP,
862         RTE_FLOW_ITEM_TYPE_END,
863 };
864 enum rte_flow_item_type pattern_eth_ipv6_nvgre_eth_ipv4_sctp[] = {
865         RTE_FLOW_ITEM_TYPE_ETH,
866         RTE_FLOW_ITEM_TYPE_IPV6,
867         RTE_FLOW_ITEM_TYPE_NVGRE,
868         RTE_FLOW_ITEM_TYPE_ETH,
869         RTE_FLOW_ITEM_TYPE_IPV4,
870         RTE_FLOW_ITEM_TYPE_SCTP,
871         RTE_FLOW_ITEM_TYPE_END,
872 };
873 enum rte_flow_item_type pattern_eth_ipv6_nvgre_eth_ipv4_icmp[] = {
874         RTE_FLOW_ITEM_TYPE_ETH,
875         RTE_FLOW_ITEM_TYPE_IPV6,
876         RTE_FLOW_ITEM_TYPE_NVGRE,
877         RTE_FLOW_ITEM_TYPE_ETH,
878         RTE_FLOW_ITEM_TYPE_IPV4,
879         RTE_FLOW_ITEM_TYPE_ICMP,
880         RTE_FLOW_ITEM_TYPE_END,
881 };
882
883 /* IPv4 NVGRE IPv6 */
884 enum rte_flow_item_type pattern_eth_ipv4_nvgre_ipv6[] = {
885         RTE_FLOW_ITEM_TYPE_ETH,
886         RTE_FLOW_ITEM_TYPE_IPV4,
887         RTE_FLOW_ITEM_TYPE_NVGRE,
888         RTE_FLOW_ITEM_TYPE_IPV6,
889         RTE_FLOW_ITEM_TYPE_END,
890 };
891 enum rte_flow_item_type pattern_eth_ipv4_nvgre_ipv6_udp[] = {
892         RTE_FLOW_ITEM_TYPE_ETH,
893         RTE_FLOW_ITEM_TYPE_IPV4,
894         RTE_FLOW_ITEM_TYPE_NVGRE,
895         RTE_FLOW_ITEM_TYPE_IPV6,
896         RTE_FLOW_ITEM_TYPE_UDP,
897         RTE_FLOW_ITEM_TYPE_END,
898 };
899 enum rte_flow_item_type pattern_eth_ipv4_nvgre_ipv6_tcp[] = {
900         RTE_FLOW_ITEM_TYPE_ETH,
901         RTE_FLOW_ITEM_TYPE_IPV4,
902         RTE_FLOW_ITEM_TYPE_NVGRE,
903         RTE_FLOW_ITEM_TYPE_IPV6,
904         RTE_FLOW_ITEM_TYPE_TCP,
905         RTE_FLOW_ITEM_TYPE_END,
906 };
907 enum rte_flow_item_type pattern_eth_ipv4_nvgre_ipv6_sctp[] = {
908         RTE_FLOW_ITEM_TYPE_ETH,
909         RTE_FLOW_ITEM_TYPE_IPV4,
910         RTE_FLOW_ITEM_TYPE_NVGRE,
911         RTE_FLOW_ITEM_TYPE_IPV6,
912         RTE_FLOW_ITEM_TYPE_SCTP,
913         RTE_FLOW_ITEM_TYPE_END,
914 };
915 enum rte_flow_item_type pattern_eth_ipv4_nvgre_ipv6_icmp6[] = {
916         RTE_FLOW_ITEM_TYPE_ETH,
917         RTE_FLOW_ITEM_TYPE_IPV4,
918         RTE_FLOW_ITEM_TYPE_NVGRE,
919         RTE_FLOW_ITEM_TYPE_IPV6,
920         RTE_FLOW_ITEM_TYPE_ICMP6,
921         RTE_FLOW_ITEM_TYPE_END,
922 };
923
924 /* IPv4 NVGRE MAC IPv6 */
925 enum rte_flow_item_type pattern_eth_ipv4_nvgre_eth_ipv6[] = {
926         RTE_FLOW_ITEM_TYPE_ETH,
927         RTE_FLOW_ITEM_TYPE_IPV4,
928         RTE_FLOW_ITEM_TYPE_NVGRE,
929         RTE_FLOW_ITEM_TYPE_ETH,
930         RTE_FLOW_ITEM_TYPE_IPV6,
931         RTE_FLOW_ITEM_TYPE_END,
932 };
933 enum rte_flow_item_type pattern_eth_ipv4_nvgre_eth_ipv6_udp[] = {
934         RTE_FLOW_ITEM_TYPE_ETH,
935         RTE_FLOW_ITEM_TYPE_IPV4,
936         RTE_FLOW_ITEM_TYPE_NVGRE,
937         RTE_FLOW_ITEM_TYPE_ETH,
938         RTE_FLOW_ITEM_TYPE_IPV6,
939         RTE_FLOW_ITEM_TYPE_UDP,
940         RTE_FLOW_ITEM_TYPE_END,
941 };
942 enum rte_flow_item_type pattern_eth_ipv4_nvgre_eth_ipv6_tcp[] = {
943         RTE_FLOW_ITEM_TYPE_ETH,
944         RTE_FLOW_ITEM_TYPE_IPV4,
945         RTE_FLOW_ITEM_TYPE_NVGRE,
946         RTE_FLOW_ITEM_TYPE_ETH,
947         RTE_FLOW_ITEM_TYPE_IPV6,
948         RTE_FLOW_ITEM_TYPE_TCP,
949         RTE_FLOW_ITEM_TYPE_END,
950 };
951 enum rte_flow_item_type pattern_eth_ipv4_nvgre_eth_ipv6_sctp[] = {
952         RTE_FLOW_ITEM_TYPE_ETH,
953         RTE_FLOW_ITEM_TYPE_IPV4,
954         RTE_FLOW_ITEM_TYPE_NVGRE,
955         RTE_FLOW_ITEM_TYPE_ETH,
956         RTE_FLOW_ITEM_TYPE_IPV6,
957         RTE_FLOW_ITEM_TYPE_SCTP,
958         RTE_FLOW_ITEM_TYPE_END,
959 };
960 enum rte_flow_item_type pattern_eth_ipv4_nvgre_eth_ipv6_icmp6[] = {
961         RTE_FLOW_ITEM_TYPE_ETH,
962         RTE_FLOW_ITEM_TYPE_IPV4,
963         RTE_FLOW_ITEM_TYPE_NVGRE,
964         RTE_FLOW_ITEM_TYPE_ETH,
965         RTE_FLOW_ITEM_TYPE_IPV6,
966         RTE_FLOW_ITEM_TYPE_ICMP6,
967         RTE_FLOW_ITEM_TYPE_END,
968 };
969
970 /* IPv6 NVGRE IPv6 */
971 enum rte_flow_item_type pattern_eth_ipv6_nvgre_ipv6[] = {
972         RTE_FLOW_ITEM_TYPE_ETH,
973         RTE_FLOW_ITEM_TYPE_IPV6,
974         RTE_FLOW_ITEM_TYPE_NVGRE,
975         RTE_FLOW_ITEM_TYPE_IPV6,
976         RTE_FLOW_ITEM_TYPE_END,
977 };
978 enum rte_flow_item_type pattern_eth_ipv6_nvgre_ipv6_tcp[] = {
979         RTE_FLOW_ITEM_TYPE_ETH,
980         RTE_FLOW_ITEM_TYPE_IPV6,
981         RTE_FLOW_ITEM_TYPE_NVGRE,
982         RTE_FLOW_ITEM_TYPE_IPV6,
983         RTE_FLOW_ITEM_TYPE_TCP,
984         RTE_FLOW_ITEM_TYPE_END,
985 };
986 enum rte_flow_item_type pattern_eth_ipv6_nvgre_ipv6_udp[] = {
987         RTE_FLOW_ITEM_TYPE_ETH,
988         RTE_FLOW_ITEM_TYPE_IPV6,
989         RTE_FLOW_ITEM_TYPE_NVGRE,
990         RTE_FLOW_ITEM_TYPE_IPV6,
991         RTE_FLOW_ITEM_TYPE_UDP,
992         RTE_FLOW_ITEM_TYPE_END,
993 };
994 enum rte_flow_item_type pattern_eth_ipv6_nvgre_ipv6_sctp[] = {
995         RTE_FLOW_ITEM_TYPE_ETH,
996         RTE_FLOW_ITEM_TYPE_IPV6,
997         RTE_FLOW_ITEM_TYPE_NVGRE,
998         RTE_FLOW_ITEM_TYPE_IPV6,
999         RTE_FLOW_ITEM_TYPE_SCTP,
1000         RTE_FLOW_ITEM_TYPE_END,
1001 };
1002 enum rte_flow_item_type pattern_eth_ipv6_nvgre_ipv6_icmp6[] = {
1003         RTE_FLOW_ITEM_TYPE_ETH,
1004         RTE_FLOW_ITEM_TYPE_IPV6,
1005         RTE_FLOW_ITEM_TYPE_NVGRE,
1006         RTE_FLOW_ITEM_TYPE_IPV6,
1007         RTE_FLOW_ITEM_TYPE_ICMP6,
1008         RTE_FLOW_ITEM_TYPE_END,
1009 };
1010
1011 /* IPv6 NVGRE MAC IPv6 */
1012 enum rte_flow_item_type pattern_eth_ipv6_nvgre_eth_ipv6[] = {
1013         RTE_FLOW_ITEM_TYPE_ETH,
1014         RTE_FLOW_ITEM_TYPE_IPV6,
1015         RTE_FLOW_ITEM_TYPE_NVGRE,
1016         RTE_FLOW_ITEM_TYPE_ETH,
1017         RTE_FLOW_ITEM_TYPE_IPV6,
1018         RTE_FLOW_ITEM_TYPE_END,
1019 };
1020 enum rte_flow_item_type pattern_eth_ipv6_nvgre_eth_ipv6_tcp[] = {
1021         RTE_FLOW_ITEM_TYPE_ETH,
1022         RTE_FLOW_ITEM_TYPE_IPV6,
1023         RTE_FLOW_ITEM_TYPE_NVGRE,
1024         RTE_FLOW_ITEM_TYPE_ETH,
1025         RTE_FLOW_ITEM_TYPE_IPV6,
1026         RTE_FLOW_ITEM_TYPE_TCP,
1027         RTE_FLOW_ITEM_TYPE_END,
1028 };
1029 enum rte_flow_item_type pattern_eth_ipv6_nvgre_eth_ipv6_udp[] = {
1030         RTE_FLOW_ITEM_TYPE_ETH,
1031         RTE_FLOW_ITEM_TYPE_IPV6,
1032         RTE_FLOW_ITEM_TYPE_NVGRE,
1033         RTE_FLOW_ITEM_TYPE_ETH,
1034         RTE_FLOW_ITEM_TYPE_IPV6,
1035         RTE_FLOW_ITEM_TYPE_UDP,
1036         RTE_FLOW_ITEM_TYPE_END,
1037 };
1038 enum rte_flow_item_type pattern_eth_ipv6_nvgre_eth_ipv6_sctp[] = {
1039         RTE_FLOW_ITEM_TYPE_ETH,
1040         RTE_FLOW_ITEM_TYPE_IPV6,
1041         RTE_FLOW_ITEM_TYPE_NVGRE,
1042         RTE_FLOW_ITEM_TYPE_ETH,
1043         RTE_FLOW_ITEM_TYPE_IPV6,
1044         RTE_FLOW_ITEM_TYPE_SCTP,
1045         RTE_FLOW_ITEM_TYPE_END,
1046 };
1047 enum rte_flow_item_type pattern_eth_ipv6_nvgre_eth_ipv6_icmp6[] = {
1048         RTE_FLOW_ITEM_TYPE_ETH,
1049         RTE_FLOW_ITEM_TYPE_IPV6,
1050         RTE_FLOW_ITEM_TYPE_NVGRE,
1051         RTE_FLOW_ITEM_TYPE_ETH,
1052         RTE_FLOW_ITEM_TYPE_IPV6,
1053         RTE_FLOW_ITEM_TYPE_ICMP6,
1054         RTE_FLOW_ITEM_TYPE_END,
1055 };
1056
1057 /*IPv4 GTPU (EH) */
1058 enum rte_flow_item_type pattern_eth_ipv4_gtpu[] = {
1059         RTE_FLOW_ITEM_TYPE_ETH,
1060         RTE_FLOW_ITEM_TYPE_IPV4,
1061         RTE_FLOW_ITEM_TYPE_UDP,
1062         RTE_FLOW_ITEM_TYPE_GTPU,
1063         RTE_FLOW_ITEM_TYPE_END,
1064 };
1065
1066 enum rte_flow_item_type pattern_eth_ipv4_gtpu_eh[] = {
1067         RTE_FLOW_ITEM_TYPE_ETH,
1068         RTE_FLOW_ITEM_TYPE_IPV4,
1069         RTE_FLOW_ITEM_TYPE_UDP,
1070         RTE_FLOW_ITEM_TYPE_GTPU,
1071         RTE_FLOW_ITEM_TYPE_GTP_PSC,
1072         RTE_FLOW_ITEM_TYPE_END,
1073 };
1074
1075 /*IPv6 GTPU (EH) */
1076 enum rte_flow_item_type pattern_eth_ipv6_gtpu[] = {
1077         RTE_FLOW_ITEM_TYPE_ETH,
1078         RTE_FLOW_ITEM_TYPE_IPV6,
1079         RTE_FLOW_ITEM_TYPE_UDP,
1080         RTE_FLOW_ITEM_TYPE_GTPU,
1081         RTE_FLOW_ITEM_TYPE_END,
1082 };
1083
1084 enum rte_flow_item_type pattern_eth_ipv6_gtpu_eh[] = {
1085         RTE_FLOW_ITEM_TYPE_ETH,
1086         RTE_FLOW_ITEM_TYPE_IPV6,
1087         RTE_FLOW_ITEM_TYPE_UDP,
1088         RTE_FLOW_ITEM_TYPE_GTPU,
1089         RTE_FLOW_ITEM_TYPE_GTP_PSC,
1090         RTE_FLOW_ITEM_TYPE_END,
1091 };
1092
1093 /*IPv4 GTPU IPv4 */
1094 enum rte_flow_item_type pattern_eth_ipv4_gtpu_ipv4[] = {
1095         RTE_FLOW_ITEM_TYPE_ETH,
1096         RTE_FLOW_ITEM_TYPE_IPV4,
1097         RTE_FLOW_ITEM_TYPE_UDP,
1098         RTE_FLOW_ITEM_TYPE_GTPU,
1099         RTE_FLOW_ITEM_TYPE_IPV4,
1100         RTE_FLOW_ITEM_TYPE_END,
1101 };
1102
1103 enum rte_flow_item_type pattern_eth_ipv4_gtpu_ipv4_udp[] = {
1104         RTE_FLOW_ITEM_TYPE_ETH,
1105         RTE_FLOW_ITEM_TYPE_IPV4,
1106         RTE_FLOW_ITEM_TYPE_UDP,
1107         RTE_FLOW_ITEM_TYPE_GTPU,
1108         RTE_FLOW_ITEM_TYPE_IPV4,
1109         RTE_FLOW_ITEM_TYPE_UDP,
1110         RTE_FLOW_ITEM_TYPE_END,
1111 };
1112
1113 enum rte_flow_item_type pattern_eth_ipv4_gtpu_ipv4_tcp[] = {
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_IPV4,
1119         RTE_FLOW_ITEM_TYPE_TCP,
1120         RTE_FLOW_ITEM_TYPE_END,
1121 };
1122
1123 enum rte_flow_item_type pattern_eth_ipv4_gtpu_ipv4_icmp[] = {
1124         RTE_FLOW_ITEM_TYPE_ETH,
1125         RTE_FLOW_ITEM_TYPE_IPV4,
1126         RTE_FLOW_ITEM_TYPE_UDP,
1127         RTE_FLOW_ITEM_TYPE_GTPU,
1128         RTE_FLOW_ITEM_TYPE_IPV4,
1129         RTE_FLOW_ITEM_TYPE_ICMP,
1130         RTE_FLOW_ITEM_TYPE_END,
1131 };
1132
1133 /*IPv4 GTPU IPv6 */
1134 enum rte_flow_item_type pattern_eth_ipv4_gtpu_ipv6[] = {
1135         RTE_FLOW_ITEM_TYPE_ETH,
1136         RTE_FLOW_ITEM_TYPE_IPV4,
1137         RTE_FLOW_ITEM_TYPE_UDP,
1138         RTE_FLOW_ITEM_TYPE_GTPU,
1139         RTE_FLOW_ITEM_TYPE_IPV6,
1140         RTE_FLOW_ITEM_TYPE_END,
1141 };
1142
1143 enum rte_flow_item_type pattern_eth_ipv4_gtpu_ipv6_udp[] = {
1144         RTE_FLOW_ITEM_TYPE_ETH,
1145         RTE_FLOW_ITEM_TYPE_IPV4,
1146         RTE_FLOW_ITEM_TYPE_UDP,
1147         RTE_FLOW_ITEM_TYPE_GTPU,
1148         RTE_FLOW_ITEM_TYPE_IPV6,
1149         RTE_FLOW_ITEM_TYPE_UDP,
1150         RTE_FLOW_ITEM_TYPE_END,
1151 };
1152
1153 enum rte_flow_item_type pattern_eth_ipv4_gtpu_ipv6_tcp[] = {
1154         RTE_FLOW_ITEM_TYPE_ETH,
1155         RTE_FLOW_ITEM_TYPE_IPV4,
1156         RTE_FLOW_ITEM_TYPE_UDP,
1157         RTE_FLOW_ITEM_TYPE_GTPU,
1158         RTE_FLOW_ITEM_TYPE_IPV6,
1159         RTE_FLOW_ITEM_TYPE_TCP,
1160         RTE_FLOW_ITEM_TYPE_END,
1161 };
1162
1163 enum rte_flow_item_type pattern_eth_ipv4_gtpu_ipv6_icmp[] = {
1164         RTE_FLOW_ITEM_TYPE_ETH,
1165         RTE_FLOW_ITEM_TYPE_IPV4,
1166         RTE_FLOW_ITEM_TYPE_UDP,
1167         RTE_FLOW_ITEM_TYPE_GTPU,
1168         RTE_FLOW_ITEM_TYPE_IPV6,
1169         RTE_FLOW_ITEM_TYPE_ICMP,
1170         RTE_FLOW_ITEM_TYPE_END,
1171 };
1172
1173 /*IPv6 GTPU IPv4 */
1174 enum rte_flow_item_type pattern_eth_ipv6_gtpu_ipv4[] = {
1175         RTE_FLOW_ITEM_TYPE_ETH,
1176         RTE_FLOW_ITEM_TYPE_IPV6,
1177         RTE_FLOW_ITEM_TYPE_UDP,
1178         RTE_FLOW_ITEM_TYPE_GTPU,
1179         RTE_FLOW_ITEM_TYPE_IPV4,
1180         RTE_FLOW_ITEM_TYPE_END,
1181 };
1182
1183 enum rte_flow_item_type pattern_eth_ipv6_gtpu_ipv4_udp[] = {
1184         RTE_FLOW_ITEM_TYPE_ETH,
1185         RTE_FLOW_ITEM_TYPE_IPV6,
1186         RTE_FLOW_ITEM_TYPE_UDP,
1187         RTE_FLOW_ITEM_TYPE_GTPU,
1188         RTE_FLOW_ITEM_TYPE_IPV4,
1189         RTE_FLOW_ITEM_TYPE_UDP,
1190         RTE_FLOW_ITEM_TYPE_END,
1191 };
1192
1193 enum rte_flow_item_type pattern_eth_ipv6_gtpu_ipv4_tcp[] = {
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_IPV4,
1199         RTE_FLOW_ITEM_TYPE_TCP,
1200         RTE_FLOW_ITEM_TYPE_END,
1201 };
1202
1203 enum rte_flow_item_type pattern_eth_ipv6_gtpu_ipv4_icmp[] = {
1204         RTE_FLOW_ITEM_TYPE_ETH,
1205         RTE_FLOW_ITEM_TYPE_IPV6,
1206         RTE_FLOW_ITEM_TYPE_UDP,
1207         RTE_FLOW_ITEM_TYPE_GTPU,
1208         RTE_FLOW_ITEM_TYPE_IPV4,
1209         RTE_FLOW_ITEM_TYPE_ICMP,
1210         RTE_FLOW_ITEM_TYPE_END,
1211 };
1212
1213 /*IPv6 GTPU IPv6 */
1214 enum rte_flow_item_type pattern_eth_ipv6_gtpu_ipv6[] = {
1215         RTE_FLOW_ITEM_TYPE_ETH,
1216         RTE_FLOW_ITEM_TYPE_IPV6,
1217         RTE_FLOW_ITEM_TYPE_UDP,
1218         RTE_FLOW_ITEM_TYPE_GTPU,
1219         RTE_FLOW_ITEM_TYPE_IPV6,
1220         RTE_FLOW_ITEM_TYPE_END,
1221 };
1222
1223 enum rte_flow_item_type pattern_eth_ipv6_gtpu_ipv6_udp[] = {
1224         RTE_FLOW_ITEM_TYPE_ETH,
1225         RTE_FLOW_ITEM_TYPE_IPV6,
1226         RTE_FLOW_ITEM_TYPE_UDP,
1227         RTE_FLOW_ITEM_TYPE_GTPU,
1228         RTE_FLOW_ITEM_TYPE_IPV6,
1229         RTE_FLOW_ITEM_TYPE_UDP,
1230         RTE_FLOW_ITEM_TYPE_END,
1231 };
1232
1233 enum rte_flow_item_type pattern_eth_ipv6_gtpu_ipv6_tcp[] = {
1234         RTE_FLOW_ITEM_TYPE_ETH,
1235         RTE_FLOW_ITEM_TYPE_IPV6,
1236         RTE_FLOW_ITEM_TYPE_UDP,
1237         RTE_FLOW_ITEM_TYPE_GTPU,
1238         RTE_FLOW_ITEM_TYPE_IPV6,
1239         RTE_FLOW_ITEM_TYPE_TCP,
1240         RTE_FLOW_ITEM_TYPE_END,
1241 };
1242
1243 enum rte_flow_item_type pattern_eth_ipv6_gtpu_ipv6_icmp[] = {
1244         RTE_FLOW_ITEM_TYPE_ETH,
1245         RTE_FLOW_ITEM_TYPE_IPV6,
1246         RTE_FLOW_ITEM_TYPE_UDP,
1247         RTE_FLOW_ITEM_TYPE_GTPU,
1248         RTE_FLOW_ITEM_TYPE_IPV6,
1249         RTE_FLOW_ITEM_TYPE_ICMP,
1250         RTE_FLOW_ITEM_TYPE_END,
1251 };
1252
1253 /*IPv4 GTPU EH IPv4 */
1254 enum rte_flow_item_type pattern_eth_ipv4_gtpu_eh_ipv4[] = {
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_END,
1262 };
1263
1264 enum rte_flow_item_type pattern_eth_ipv4_gtpu_eh_ipv4_udp[] = {
1265         RTE_FLOW_ITEM_TYPE_ETH,
1266         RTE_FLOW_ITEM_TYPE_IPV4,
1267         RTE_FLOW_ITEM_TYPE_UDP,
1268         RTE_FLOW_ITEM_TYPE_GTPU,
1269         RTE_FLOW_ITEM_TYPE_GTP_PSC,
1270         RTE_FLOW_ITEM_TYPE_IPV4,
1271         RTE_FLOW_ITEM_TYPE_UDP,
1272         RTE_FLOW_ITEM_TYPE_END,
1273 };
1274
1275 enum rte_flow_item_type pattern_eth_ipv4_gtpu_eh_ipv4_tcp[] = {
1276         RTE_FLOW_ITEM_TYPE_ETH,
1277         RTE_FLOW_ITEM_TYPE_IPV4,
1278         RTE_FLOW_ITEM_TYPE_UDP,
1279         RTE_FLOW_ITEM_TYPE_GTPU,
1280         RTE_FLOW_ITEM_TYPE_GTP_PSC,
1281         RTE_FLOW_ITEM_TYPE_IPV4,
1282         RTE_FLOW_ITEM_TYPE_TCP,
1283         RTE_FLOW_ITEM_TYPE_END,
1284 };
1285
1286 enum rte_flow_item_type pattern_eth_ipv4_gtpu_eh_ipv4_icmp[] = {
1287         RTE_FLOW_ITEM_TYPE_ETH,
1288         RTE_FLOW_ITEM_TYPE_IPV4,
1289         RTE_FLOW_ITEM_TYPE_UDP,
1290         RTE_FLOW_ITEM_TYPE_GTPU,
1291         RTE_FLOW_ITEM_TYPE_GTP_PSC,
1292         RTE_FLOW_ITEM_TYPE_IPV4,
1293         RTE_FLOW_ITEM_TYPE_ICMP,
1294         RTE_FLOW_ITEM_TYPE_END,
1295 };
1296
1297 /*IPv4 GTPU EH IPv6 */
1298 enum rte_flow_item_type pattern_eth_ipv4_gtpu_eh_ipv6[] = {
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_END,
1306 };
1307
1308 enum rte_flow_item_type pattern_eth_ipv4_gtpu_eh_ipv6_udp[] = {
1309         RTE_FLOW_ITEM_TYPE_ETH,
1310         RTE_FLOW_ITEM_TYPE_IPV4,
1311         RTE_FLOW_ITEM_TYPE_UDP,
1312         RTE_FLOW_ITEM_TYPE_GTPU,
1313         RTE_FLOW_ITEM_TYPE_GTP_PSC,
1314         RTE_FLOW_ITEM_TYPE_IPV6,
1315         RTE_FLOW_ITEM_TYPE_UDP,
1316         RTE_FLOW_ITEM_TYPE_END,
1317 };
1318
1319 enum rte_flow_item_type pattern_eth_ipv4_gtpu_eh_ipv6_tcp[] = {
1320         RTE_FLOW_ITEM_TYPE_ETH,
1321         RTE_FLOW_ITEM_TYPE_IPV4,
1322         RTE_FLOW_ITEM_TYPE_UDP,
1323         RTE_FLOW_ITEM_TYPE_GTPU,
1324         RTE_FLOW_ITEM_TYPE_GTP_PSC,
1325         RTE_FLOW_ITEM_TYPE_IPV6,
1326         RTE_FLOW_ITEM_TYPE_TCP,
1327         RTE_FLOW_ITEM_TYPE_END,
1328 };
1329
1330 enum rte_flow_item_type pattern_eth_ipv4_gtpu_eh_ipv6_icmp[] = {
1331         RTE_FLOW_ITEM_TYPE_ETH,
1332         RTE_FLOW_ITEM_TYPE_IPV4,
1333         RTE_FLOW_ITEM_TYPE_UDP,
1334         RTE_FLOW_ITEM_TYPE_GTPU,
1335         RTE_FLOW_ITEM_TYPE_GTP_PSC,
1336         RTE_FLOW_ITEM_TYPE_IPV6,
1337         RTE_FLOW_ITEM_TYPE_ICMP,
1338         RTE_FLOW_ITEM_TYPE_END,
1339 };
1340
1341 /*IPv6 GTPU EH IPv4 */
1342 enum rte_flow_item_type pattern_eth_ipv6_gtpu_eh_ipv4[] = {
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_END,
1350 };
1351
1352 enum rte_flow_item_type pattern_eth_ipv6_gtpu_eh_ipv4_udp[] = {
1353         RTE_FLOW_ITEM_TYPE_ETH,
1354         RTE_FLOW_ITEM_TYPE_IPV6,
1355         RTE_FLOW_ITEM_TYPE_UDP,
1356         RTE_FLOW_ITEM_TYPE_GTPU,
1357         RTE_FLOW_ITEM_TYPE_GTP_PSC,
1358         RTE_FLOW_ITEM_TYPE_IPV4,
1359         RTE_FLOW_ITEM_TYPE_UDP,
1360         RTE_FLOW_ITEM_TYPE_END,
1361 };
1362
1363 enum rte_flow_item_type pattern_eth_ipv6_gtpu_eh_ipv4_tcp[] = {
1364         RTE_FLOW_ITEM_TYPE_ETH,
1365         RTE_FLOW_ITEM_TYPE_IPV6,
1366         RTE_FLOW_ITEM_TYPE_UDP,
1367         RTE_FLOW_ITEM_TYPE_GTPU,
1368         RTE_FLOW_ITEM_TYPE_GTP_PSC,
1369         RTE_FLOW_ITEM_TYPE_IPV4,
1370         RTE_FLOW_ITEM_TYPE_TCP,
1371         RTE_FLOW_ITEM_TYPE_END,
1372 };
1373
1374 enum rte_flow_item_type pattern_eth_ipv6_gtpu_eh_ipv4_icmp[] = {
1375         RTE_FLOW_ITEM_TYPE_ETH,
1376         RTE_FLOW_ITEM_TYPE_IPV6,
1377         RTE_FLOW_ITEM_TYPE_UDP,
1378         RTE_FLOW_ITEM_TYPE_GTPU,
1379         RTE_FLOW_ITEM_TYPE_GTP_PSC,
1380         RTE_FLOW_ITEM_TYPE_IPV4,
1381         RTE_FLOW_ITEM_TYPE_ICMP,
1382         RTE_FLOW_ITEM_TYPE_END,
1383 };
1384
1385 /*IPv6 GTPU EH IPv6 */
1386 enum rte_flow_item_type pattern_eth_ipv6_gtpu_eh_ipv6[] = {
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_END,
1394 };
1395
1396 enum rte_flow_item_type pattern_eth_ipv6_gtpu_eh_ipv6_udp[] = {
1397         RTE_FLOW_ITEM_TYPE_ETH,
1398         RTE_FLOW_ITEM_TYPE_IPV6,
1399         RTE_FLOW_ITEM_TYPE_UDP,
1400         RTE_FLOW_ITEM_TYPE_GTPU,
1401         RTE_FLOW_ITEM_TYPE_GTP_PSC,
1402         RTE_FLOW_ITEM_TYPE_IPV6,
1403         RTE_FLOW_ITEM_TYPE_UDP,
1404         RTE_FLOW_ITEM_TYPE_END,
1405 };
1406
1407 enum rte_flow_item_type pattern_eth_ipv6_gtpu_eh_ipv6_tcp[] = {
1408         RTE_FLOW_ITEM_TYPE_ETH,
1409         RTE_FLOW_ITEM_TYPE_IPV6,
1410         RTE_FLOW_ITEM_TYPE_UDP,
1411         RTE_FLOW_ITEM_TYPE_GTPU,
1412         RTE_FLOW_ITEM_TYPE_GTP_PSC,
1413         RTE_FLOW_ITEM_TYPE_IPV6,
1414         RTE_FLOW_ITEM_TYPE_TCP,
1415         RTE_FLOW_ITEM_TYPE_END,
1416 };
1417
1418 enum rte_flow_item_type pattern_eth_ipv6_gtpu_eh_ipv6_icmp[] = {
1419         RTE_FLOW_ITEM_TYPE_ETH,
1420         RTE_FLOW_ITEM_TYPE_IPV6,
1421         RTE_FLOW_ITEM_TYPE_UDP,
1422         RTE_FLOW_ITEM_TYPE_GTPU,
1423         RTE_FLOW_ITEM_TYPE_GTP_PSC,
1424         RTE_FLOW_ITEM_TYPE_IPV6,
1425         RTE_FLOW_ITEM_TYPE_ICMP,
1426         RTE_FLOW_ITEM_TYPE_END,
1427 };
1428
1429 /* PPPoE */
1430 enum rte_flow_item_type pattern_eth_pppoed[] = {
1431         RTE_FLOW_ITEM_TYPE_ETH,
1432         RTE_FLOW_ITEM_TYPE_PPPOED,
1433         RTE_FLOW_ITEM_TYPE_END,
1434 };
1435 enum rte_flow_item_type pattern_eth_vlan_pppoed[] = {
1436         RTE_FLOW_ITEM_TYPE_ETH,
1437         RTE_FLOW_ITEM_TYPE_VLAN,
1438         RTE_FLOW_ITEM_TYPE_PPPOED,
1439         RTE_FLOW_ITEM_TYPE_END,
1440 };
1441 enum rte_flow_item_type pattern_eth_qinq_pppoed[] = {
1442         RTE_FLOW_ITEM_TYPE_ETH,
1443         RTE_FLOW_ITEM_TYPE_VLAN,
1444         RTE_FLOW_ITEM_TYPE_VLAN,
1445         RTE_FLOW_ITEM_TYPE_PPPOED,
1446         RTE_FLOW_ITEM_TYPE_END,
1447 };
1448 enum rte_flow_item_type pattern_eth_pppoes[] = {
1449         RTE_FLOW_ITEM_TYPE_ETH,
1450         RTE_FLOW_ITEM_TYPE_PPPOES,
1451         RTE_FLOW_ITEM_TYPE_END,
1452 };
1453 enum rte_flow_item_type pattern_eth_pppoes_proto[] = {
1454         RTE_FLOW_ITEM_TYPE_ETH,
1455         RTE_FLOW_ITEM_TYPE_PPPOES,
1456         RTE_FLOW_ITEM_TYPE_PPPOE_PROTO_ID,
1457         RTE_FLOW_ITEM_TYPE_END,
1458 };
1459 enum rte_flow_item_type pattern_eth_vlan_pppoes[] = {
1460         RTE_FLOW_ITEM_TYPE_ETH,
1461         RTE_FLOW_ITEM_TYPE_VLAN,
1462         RTE_FLOW_ITEM_TYPE_PPPOES,
1463         RTE_FLOW_ITEM_TYPE_END,
1464 };
1465 enum rte_flow_item_type pattern_eth_vlan_pppoes_proto[] = {
1466         RTE_FLOW_ITEM_TYPE_ETH,
1467         RTE_FLOW_ITEM_TYPE_VLAN,
1468         RTE_FLOW_ITEM_TYPE_PPPOES,
1469         RTE_FLOW_ITEM_TYPE_PPPOE_PROTO_ID,
1470         RTE_FLOW_ITEM_TYPE_END,
1471 };
1472 enum rte_flow_item_type pattern_eth_qinq_pppoes[] = {
1473         RTE_FLOW_ITEM_TYPE_ETH,
1474         RTE_FLOW_ITEM_TYPE_VLAN,
1475         RTE_FLOW_ITEM_TYPE_VLAN,
1476         RTE_FLOW_ITEM_TYPE_PPPOES,
1477         RTE_FLOW_ITEM_TYPE_END,
1478 };
1479 enum rte_flow_item_type pattern_eth_qinq_pppoes_proto[] = {
1480         RTE_FLOW_ITEM_TYPE_ETH,
1481         RTE_FLOW_ITEM_TYPE_VLAN,
1482         RTE_FLOW_ITEM_TYPE_VLAN,
1483         RTE_FLOW_ITEM_TYPE_PPPOES,
1484         RTE_FLOW_ITEM_TYPE_PPPOE_PROTO_ID,
1485         RTE_FLOW_ITEM_TYPE_END,
1486 };
1487 enum rte_flow_item_type pattern_eth_pppoes_ipv4[] = {
1488         RTE_FLOW_ITEM_TYPE_ETH,
1489         RTE_FLOW_ITEM_TYPE_PPPOES,
1490         RTE_FLOW_ITEM_TYPE_IPV4,
1491         RTE_FLOW_ITEM_TYPE_END,
1492 };
1493 enum rte_flow_item_type pattern_eth_vlan_pppoes_ipv4[] = {
1494         RTE_FLOW_ITEM_TYPE_ETH,
1495         RTE_FLOW_ITEM_TYPE_VLAN,
1496         RTE_FLOW_ITEM_TYPE_PPPOES,
1497         RTE_FLOW_ITEM_TYPE_IPV4,
1498         RTE_FLOW_ITEM_TYPE_END,
1499 };
1500 enum rte_flow_item_type pattern_eth_qinq_pppoes_ipv4[] = {
1501         RTE_FLOW_ITEM_TYPE_ETH,
1502         RTE_FLOW_ITEM_TYPE_VLAN,
1503         RTE_FLOW_ITEM_TYPE_VLAN,
1504         RTE_FLOW_ITEM_TYPE_PPPOES,
1505         RTE_FLOW_ITEM_TYPE_IPV4,
1506         RTE_FLOW_ITEM_TYPE_END,
1507 };
1508 enum rte_flow_item_type pattern_eth_pppoes_ipv4_udp[] = {
1509         RTE_FLOW_ITEM_TYPE_ETH,
1510         RTE_FLOW_ITEM_TYPE_PPPOES,
1511         RTE_FLOW_ITEM_TYPE_IPV4,
1512         RTE_FLOW_ITEM_TYPE_UDP,
1513         RTE_FLOW_ITEM_TYPE_END,
1514 };
1515 enum rte_flow_item_type pattern_eth_vlan_pppoes_ipv4_udp[] = {
1516         RTE_FLOW_ITEM_TYPE_ETH,
1517         RTE_FLOW_ITEM_TYPE_VLAN,
1518         RTE_FLOW_ITEM_TYPE_PPPOES,
1519         RTE_FLOW_ITEM_TYPE_IPV4,
1520         RTE_FLOW_ITEM_TYPE_UDP,
1521         RTE_FLOW_ITEM_TYPE_END,
1522 };
1523 enum rte_flow_item_type pattern_eth_qinq_pppoes_ipv4_udp[] = {
1524         RTE_FLOW_ITEM_TYPE_ETH,
1525         RTE_FLOW_ITEM_TYPE_VLAN,
1526         RTE_FLOW_ITEM_TYPE_VLAN,
1527         RTE_FLOW_ITEM_TYPE_PPPOES,
1528         RTE_FLOW_ITEM_TYPE_IPV4,
1529         RTE_FLOW_ITEM_TYPE_UDP,
1530         RTE_FLOW_ITEM_TYPE_END,
1531 };
1532 enum rte_flow_item_type pattern_eth_pppoes_ipv4_tcp[] = {
1533         RTE_FLOW_ITEM_TYPE_ETH,
1534         RTE_FLOW_ITEM_TYPE_PPPOES,
1535         RTE_FLOW_ITEM_TYPE_IPV4,
1536         RTE_FLOW_ITEM_TYPE_TCP,
1537         RTE_FLOW_ITEM_TYPE_END,
1538 };
1539 enum rte_flow_item_type pattern_eth_vlan_pppoes_ipv4_tcp[] = {
1540         RTE_FLOW_ITEM_TYPE_ETH,
1541         RTE_FLOW_ITEM_TYPE_VLAN,
1542         RTE_FLOW_ITEM_TYPE_PPPOES,
1543         RTE_FLOW_ITEM_TYPE_IPV4,
1544         RTE_FLOW_ITEM_TYPE_TCP,
1545         RTE_FLOW_ITEM_TYPE_END,
1546 };
1547 enum rte_flow_item_type pattern_eth_qinq_pppoes_ipv4_tcp[] = {
1548         RTE_FLOW_ITEM_TYPE_ETH,
1549         RTE_FLOW_ITEM_TYPE_VLAN,
1550         RTE_FLOW_ITEM_TYPE_VLAN,
1551         RTE_FLOW_ITEM_TYPE_PPPOES,
1552         RTE_FLOW_ITEM_TYPE_IPV4,
1553         RTE_FLOW_ITEM_TYPE_TCP,
1554         RTE_FLOW_ITEM_TYPE_END,
1555 };
1556 enum rte_flow_item_type pattern_eth_pppoes_ipv4_sctp[] = {
1557         RTE_FLOW_ITEM_TYPE_ETH,
1558         RTE_FLOW_ITEM_TYPE_PPPOES,
1559         RTE_FLOW_ITEM_TYPE_IPV4,
1560         RTE_FLOW_ITEM_TYPE_SCTP,
1561         RTE_FLOW_ITEM_TYPE_END,
1562 };
1563 enum rte_flow_item_type pattern_eth_vlan_pppoes_ipv4_sctp[] = {
1564         RTE_FLOW_ITEM_TYPE_ETH,
1565         RTE_FLOW_ITEM_TYPE_VLAN,
1566         RTE_FLOW_ITEM_TYPE_PPPOES,
1567         RTE_FLOW_ITEM_TYPE_IPV4,
1568         RTE_FLOW_ITEM_TYPE_SCTP,
1569         RTE_FLOW_ITEM_TYPE_END,
1570 };
1571 enum rte_flow_item_type pattern_eth_qinq_pppoes_ipv4_sctp[] = {
1572         RTE_FLOW_ITEM_TYPE_ETH,
1573         RTE_FLOW_ITEM_TYPE_VLAN,
1574         RTE_FLOW_ITEM_TYPE_VLAN,
1575         RTE_FLOW_ITEM_TYPE_PPPOES,
1576         RTE_FLOW_ITEM_TYPE_IPV4,
1577         RTE_FLOW_ITEM_TYPE_SCTP,
1578         RTE_FLOW_ITEM_TYPE_END,
1579 };
1580 enum rte_flow_item_type pattern_eth_pppoes_ipv4_icmp[] = {
1581         RTE_FLOW_ITEM_TYPE_ETH,
1582         RTE_FLOW_ITEM_TYPE_PPPOES,
1583         RTE_FLOW_ITEM_TYPE_IPV4,
1584         RTE_FLOW_ITEM_TYPE_ICMP,
1585         RTE_FLOW_ITEM_TYPE_END,
1586 };
1587 enum rte_flow_item_type pattern_eth_vlan_pppoes_ipv4_icmp[] = {
1588         RTE_FLOW_ITEM_TYPE_ETH,
1589         RTE_FLOW_ITEM_TYPE_VLAN,
1590         RTE_FLOW_ITEM_TYPE_PPPOES,
1591         RTE_FLOW_ITEM_TYPE_IPV4,
1592         RTE_FLOW_ITEM_TYPE_ICMP,
1593         RTE_FLOW_ITEM_TYPE_END,
1594 };
1595 enum rte_flow_item_type pattern_eth_qinq_pppoes_ipv4_icmp[] = {
1596         RTE_FLOW_ITEM_TYPE_ETH,
1597         RTE_FLOW_ITEM_TYPE_VLAN,
1598         RTE_FLOW_ITEM_TYPE_VLAN,
1599         RTE_FLOW_ITEM_TYPE_PPPOES,
1600         RTE_FLOW_ITEM_TYPE_IPV4,
1601         RTE_FLOW_ITEM_TYPE_ICMP,
1602         RTE_FLOW_ITEM_TYPE_END,
1603 };
1604 enum rte_flow_item_type pattern_eth_pppoes_ipv6[] = {
1605         RTE_FLOW_ITEM_TYPE_ETH,
1606         RTE_FLOW_ITEM_TYPE_PPPOES,
1607         RTE_FLOW_ITEM_TYPE_IPV6,
1608         RTE_FLOW_ITEM_TYPE_END,
1609 };
1610 enum rte_flow_item_type pattern_eth_vlan_pppoes_ipv6[] = {
1611         RTE_FLOW_ITEM_TYPE_ETH,
1612         RTE_FLOW_ITEM_TYPE_VLAN,
1613         RTE_FLOW_ITEM_TYPE_PPPOES,
1614         RTE_FLOW_ITEM_TYPE_IPV6,
1615         RTE_FLOW_ITEM_TYPE_END,
1616 };
1617 enum rte_flow_item_type pattern_eth_qinq_pppoes_ipv6[] = {
1618         RTE_FLOW_ITEM_TYPE_ETH,
1619         RTE_FLOW_ITEM_TYPE_VLAN,
1620         RTE_FLOW_ITEM_TYPE_VLAN,
1621         RTE_FLOW_ITEM_TYPE_PPPOES,
1622         RTE_FLOW_ITEM_TYPE_IPV6,
1623         RTE_FLOW_ITEM_TYPE_END,
1624 };
1625 enum rte_flow_item_type pattern_eth_pppoes_ipv6_udp[] = {
1626         RTE_FLOW_ITEM_TYPE_ETH,
1627         RTE_FLOW_ITEM_TYPE_PPPOES,
1628         RTE_FLOW_ITEM_TYPE_IPV6,
1629         RTE_FLOW_ITEM_TYPE_UDP,
1630         RTE_FLOW_ITEM_TYPE_END,
1631 };
1632 enum rte_flow_item_type pattern_eth_vlan_pppoes_ipv6_udp[] = {
1633         RTE_FLOW_ITEM_TYPE_ETH,
1634         RTE_FLOW_ITEM_TYPE_VLAN,
1635         RTE_FLOW_ITEM_TYPE_PPPOES,
1636         RTE_FLOW_ITEM_TYPE_IPV6,
1637         RTE_FLOW_ITEM_TYPE_UDP,
1638         RTE_FLOW_ITEM_TYPE_END,
1639 };
1640 enum rte_flow_item_type pattern_eth_qinq_pppoes_ipv6_udp[] = {
1641         RTE_FLOW_ITEM_TYPE_ETH,
1642         RTE_FLOW_ITEM_TYPE_VLAN,
1643         RTE_FLOW_ITEM_TYPE_VLAN,
1644         RTE_FLOW_ITEM_TYPE_PPPOES,
1645         RTE_FLOW_ITEM_TYPE_IPV6,
1646         RTE_FLOW_ITEM_TYPE_UDP,
1647         RTE_FLOW_ITEM_TYPE_END,
1648 };
1649 enum rte_flow_item_type pattern_eth_pppoes_ipv6_tcp[] = {
1650         RTE_FLOW_ITEM_TYPE_ETH,
1651         RTE_FLOW_ITEM_TYPE_PPPOES,
1652         RTE_FLOW_ITEM_TYPE_IPV6,
1653         RTE_FLOW_ITEM_TYPE_TCP,
1654         RTE_FLOW_ITEM_TYPE_END,
1655 };
1656 enum rte_flow_item_type pattern_eth_vlan_pppoes_ipv6_tcp[] = {
1657         RTE_FLOW_ITEM_TYPE_ETH,
1658         RTE_FLOW_ITEM_TYPE_VLAN,
1659         RTE_FLOW_ITEM_TYPE_PPPOES,
1660         RTE_FLOW_ITEM_TYPE_IPV6,
1661         RTE_FLOW_ITEM_TYPE_TCP,
1662         RTE_FLOW_ITEM_TYPE_END,
1663 };
1664 enum rte_flow_item_type pattern_eth_qinq_pppoes_ipv6_tcp[] = {
1665         RTE_FLOW_ITEM_TYPE_ETH,
1666         RTE_FLOW_ITEM_TYPE_VLAN,
1667         RTE_FLOW_ITEM_TYPE_VLAN,
1668         RTE_FLOW_ITEM_TYPE_PPPOES,
1669         RTE_FLOW_ITEM_TYPE_IPV6,
1670         RTE_FLOW_ITEM_TYPE_TCP,
1671         RTE_FLOW_ITEM_TYPE_END,
1672 };
1673 enum rte_flow_item_type pattern_eth_pppoes_ipv6_sctp[] = {
1674         RTE_FLOW_ITEM_TYPE_ETH,
1675         RTE_FLOW_ITEM_TYPE_PPPOES,
1676         RTE_FLOW_ITEM_TYPE_IPV6,
1677         RTE_FLOW_ITEM_TYPE_SCTP,
1678         RTE_FLOW_ITEM_TYPE_END,
1679 };
1680 enum rte_flow_item_type pattern_eth_vlan_pppoes_ipv6_sctp[] = {
1681         RTE_FLOW_ITEM_TYPE_ETH,
1682         RTE_FLOW_ITEM_TYPE_VLAN,
1683         RTE_FLOW_ITEM_TYPE_PPPOES,
1684         RTE_FLOW_ITEM_TYPE_IPV6,
1685         RTE_FLOW_ITEM_TYPE_SCTP,
1686         RTE_FLOW_ITEM_TYPE_END,
1687 };
1688 enum rte_flow_item_type pattern_eth_qinq_pppoes_ipv6_sctp[] = {
1689         RTE_FLOW_ITEM_TYPE_ETH,
1690         RTE_FLOW_ITEM_TYPE_VLAN,
1691         RTE_FLOW_ITEM_TYPE_VLAN,
1692         RTE_FLOW_ITEM_TYPE_PPPOES,
1693         RTE_FLOW_ITEM_TYPE_IPV6,
1694         RTE_FLOW_ITEM_TYPE_SCTP,
1695         RTE_FLOW_ITEM_TYPE_END,
1696 };
1697 enum rte_flow_item_type pattern_eth_pppoes_ipv6_icmp6[] = {
1698         RTE_FLOW_ITEM_TYPE_ETH,
1699         RTE_FLOW_ITEM_TYPE_PPPOES,
1700         RTE_FLOW_ITEM_TYPE_IPV6,
1701         RTE_FLOW_ITEM_TYPE_ICMP6,
1702         RTE_FLOW_ITEM_TYPE_END,
1703 };
1704 enum rte_flow_item_type pattern_eth_vlan_pppoes_ipv6_icmp6[] = {
1705         RTE_FLOW_ITEM_TYPE_ETH,
1706         RTE_FLOW_ITEM_TYPE_VLAN,
1707         RTE_FLOW_ITEM_TYPE_PPPOES,
1708         RTE_FLOW_ITEM_TYPE_IPV6,
1709         RTE_FLOW_ITEM_TYPE_ICMP6,
1710         RTE_FLOW_ITEM_TYPE_END,
1711 };
1712 enum rte_flow_item_type pattern_eth_qinq_pppoes_ipv6_icmp6[] = {
1713         RTE_FLOW_ITEM_TYPE_ETH,
1714         RTE_FLOW_ITEM_TYPE_VLAN,
1715         RTE_FLOW_ITEM_TYPE_VLAN,
1716         RTE_FLOW_ITEM_TYPE_PPPOES,
1717         RTE_FLOW_ITEM_TYPE_IPV6,
1718         RTE_FLOW_ITEM_TYPE_ICMP6,
1719         RTE_FLOW_ITEM_TYPE_END,
1720 };
1721 enum rte_flow_item_type pattern_eth_ipv4_esp[] = {
1722         RTE_FLOW_ITEM_TYPE_ETH,
1723         RTE_FLOW_ITEM_TYPE_IPV4,
1724         RTE_FLOW_ITEM_TYPE_ESP,
1725         RTE_FLOW_ITEM_TYPE_END,
1726 };
1727 enum rte_flow_item_type pattern_eth_ipv6_esp[] = {
1728         RTE_FLOW_ITEM_TYPE_ETH,
1729         RTE_FLOW_ITEM_TYPE_IPV6,
1730         RTE_FLOW_ITEM_TYPE_ESP,
1731         RTE_FLOW_ITEM_TYPE_END,
1732 };
1733 enum rte_flow_item_type pattern_eth_ipv4_ah[] = {
1734         RTE_FLOW_ITEM_TYPE_ETH,
1735         RTE_FLOW_ITEM_TYPE_IPV4,
1736         RTE_FLOW_ITEM_TYPE_AH,
1737         RTE_FLOW_ITEM_TYPE_END,
1738 };
1739 enum rte_flow_item_type pattern_eth_ipv6_ah[] = {
1740         RTE_FLOW_ITEM_TYPE_ETH,
1741         RTE_FLOW_ITEM_TYPE_IPV6,
1742         RTE_FLOW_ITEM_TYPE_AH,
1743         RTE_FLOW_ITEM_TYPE_END,
1744 };
1745 enum rte_flow_item_type pattern_eth_ipv4_udp_esp[] = {
1746         RTE_FLOW_ITEM_TYPE_ETH,
1747         RTE_FLOW_ITEM_TYPE_IPV4,
1748         RTE_FLOW_ITEM_TYPE_UDP,
1749         RTE_FLOW_ITEM_TYPE_ESP,
1750         RTE_FLOW_ITEM_TYPE_END,
1751 };
1752 enum rte_flow_item_type pattern_eth_ipv6_udp_esp[] = {
1753         RTE_FLOW_ITEM_TYPE_ETH,
1754         RTE_FLOW_ITEM_TYPE_IPV6,
1755         RTE_FLOW_ITEM_TYPE_UDP,
1756         RTE_FLOW_ITEM_TYPE_ESP,
1757         RTE_FLOW_ITEM_TYPE_END,
1758 };
1759 enum rte_flow_item_type pattern_eth_ipv6_udp_ah[] = {
1760         RTE_FLOW_ITEM_TYPE_ETH,
1761         RTE_FLOW_ITEM_TYPE_IPV6,
1762         RTE_FLOW_ITEM_TYPE_UDP,
1763         RTE_FLOW_ITEM_TYPE_AH,
1764         RTE_FLOW_ITEM_TYPE_END,
1765 };
1766 enum rte_flow_item_type pattern_eth_ipv4_l2tp[] = {
1767         RTE_FLOW_ITEM_TYPE_ETH,
1768         RTE_FLOW_ITEM_TYPE_IPV4,
1769         RTE_FLOW_ITEM_TYPE_L2TPV3OIP,
1770         RTE_FLOW_ITEM_TYPE_END,
1771 };
1772 enum rte_flow_item_type pattern_eth_ipv6_l2tp[] = {
1773         RTE_FLOW_ITEM_TYPE_ETH,
1774         RTE_FLOW_ITEM_TYPE_IPV6,
1775         RTE_FLOW_ITEM_TYPE_L2TPV3OIP,
1776         RTE_FLOW_ITEM_TYPE_END,
1777 };
1778 enum rte_flow_item_type pattern_eth_ipv4_pfcp[] = {
1779         RTE_FLOW_ITEM_TYPE_ETH,
1780         RTE_FLOW_ITEM_TYPE_IPV4,
1781         RTE_FLOW_ITEM_TYPE_UDP,
1782         RTE_FLOW_ITEM_TYPE_PFCP,
1783         RTE_FLOW_ITEM_TYPE_END,
1784 };
1785 enum rte_flow_item_type pattern_eth_ipv6_pfcp[] = {
1786         RTE_FLOW_ITEM_TYPE_ETH,
1787         RTE_FLOW_ITEM_TYPE_IPV6,
1788         RTE_FLOW_ITEM_TYPE_UDP,
1789         RTE_FLOW_ITEM_TYPE_PFCP,
1790         RTE_FLOW_ITEM_TYPE_END,
1791 };
1792
1793
1794
1795 typedef struct ice_flow_engine * (*parse_engine_t)(struct ice_adapter *ad,
1796                 struct rte_flow *flow,
1797                 struct ice_parser_list *parser_list,
1798                 uint32_t priority,
1799                 const struct rte_flow_item pattern[],
1800                 const struct rte_flow_action actions[],
1801                 struct rte_flow_error *error);
1802
1803 void
1804 ice_register_flow_engine(struct ice_flow_engine *engine)
1805 {
1806         TAILQ_INSERT_TAIL(&engine_list, engine, node);
1807 }
1808
1809 int
1810 ice_flow_init(struct ice_adapter *ad)
1811 {
1812         int ret;
1813         struct ice_pf *pf = &ad->pf;
1814         void *temp;
1815         struct ice_flow_engine *engine;
1816
1817         TAILQ_INIT(&pf->flow_list);
1818         TAILQ_INIT(&pf->rss_parser_list);
1819         TAILQ_INIT(&pf->perm_parser_list);
1820         TAILQ_INIT(&pf->dist_parser_list);
1821         rte_spinlock_init(&pf->flow_ops_lock);
1822
1823         RTE_TAILQ_FOREACH_SAFE(engine, &engine_list, node, temp) {
1824                 if (engine->init == NULL) {
1825                         PMD_INIT_LOG(ERR, "Invalid engine type (%d)",
1826                                         engine->type);
1827                         return -ENOTSUP;
1828                 }
1829
1830                 ret = engine->init(ad);
1831                 if (ret) {
1832                         PMD_INIT_LOG(ERR, "Failed to initialize engine %d",
1833                                         engine->type);
1834                         return ret;
1835                 }
1836         }
1837         return 0;
1838 }
1839
1840 void
1841 ice_flow_uninit(struct ice_adapter *ad)
1842 {
1843         struct ice_pf *pf = &ad->pf;
1844         struct ice_flow_engine *engine;
1845         struct rte_flow *p_flow;
1846         struct ice_flow_parser_node *p_parser;
1847         void *temp;
1848
1849         RTE_TAILQ_FOREACH_SAFE(engine, &engine_list, node, temp) {
1850                 if (engine->uninit)
1851                         engine->uninit(ad);
1852         }
1853
1854         /* Remove all flows */
1855         while ((p_flow = TAILQ_FIRST(&pf->flow_list))) {
1856                 TAILQ_REMOVE(&pf->flow_list, p_flow, node);
1857                 if (p_flow->engine->free)
1858                         p_flow->engine->free(p_flow);
1859                 rte_free(p_flow);
1860         }
1861
1862         /* Cleanup parser list */
1863         while ((p_parser = TAILQ_FIRST(&pf->rss_parser_list))) {
1864                 TAILQ_REMOVE(&pf->rss_parser_list, p_parser, node);
1865                 rte_free(p_parser);
1866         }
1867
1868         while ((p_parser = TAILQ_FIRST(&pf->perm_parser_list))) {
1869                 TAILQ_REMOVE(&pf->perm_parser_list, p_parser, node);
1870                 rte_free(p_parser);
1871         }
1872
1873         while ((p_parser = TAILQ_FIRST(&pf->dist_parser_list))) {
1874                 TAILQ_REMOVE(&pf->dist_parser_list, p_parser, node);
1875                 rte_free(p_parser);
1876         }
1877 }
1878
1879 static struct ice_parser_list *
1880 ice_get_parser_list(struct ice_flow_parser *parser,
1881                 struct ice_adapter *ad)
1882 {
1883         struct ice_parser_list *list;
1884         struct ice_pf *pf = &ad->pf;
1885
1886         switch (parser->stage) {
1887         case ICE_FLOW_STAGE_RSS:
1888                 list = &pf->rss_parser_list;
1889                 break;
1890         case ICE_FLOW_STAGE_PERMISSION:
1891                 list = &pf->perm_parser_list;
1892                 break;
1893         case ICE_FLOW_STAGE_DISTRIBUTOR:
1894                 list = &pf->dist_parser_list;
1895                 break;
1896         default:
1897                 return NULL;
1898         }
1899
1900         return list;
1901 }
1902
1903 int
1904 ice_register_parser(struct ice_flow_parser *parser,
1905                 struct ice_adapter *ad)
1906 {
1907         struct ice_parser_list *list;
1908         struct ice_flow_parser_node *parser_node;
1909
1910         parser_node = rte_zmalloc("ice_parser", sizeof(*parser_node), 0);
1911         if (parser_node == NULL) {
1912                 PMD_DRV_LOG(ERR, "Failed to allocate memory.");
1913                 return -ENOMEM;
1914         }
1915         parser_node->parser = parser;
1916
1917         list = ice_get_parser_list(parser, ad);
1918         if (list == NULL)
1919                 return -EINVAL;
1920
1921         if (ad->devargs.pipe_mode_support) {
1922                 TAILQ_INSERT_TAIL(list, parser_node, node);
1923         } else {
1924                 if (parser->engine->type == ICE_FLOW_ENGINE_SWITCH ||
1925                                 parser->engine->type == ICE_FLOW_ENGINE_HASH)
1926                         TAILQ_INSERT_HEAD(list, parser_node, node);
1927                 else if (parser->engine->type == ICE_FLOW_ENGINE_FDIR)
1928                         TAILQ_INSERT_TAIL(list, parser_node, node);
1929                 else if (parser->engine->type == ICE_FLOW_ENGINE_ACL)
1930                         TAILQ_INSERT_HEAD(list, parser_node, node);
1931                 else
1932                         return -EINVAL;
1933         }
1934         return 0;
1935 }
1936
1937 void
1938 ice_unregister_parser(struct ice_flow_parser *parser,
1939                 struct ice_adapter *ad)
1940 {
1941         struct ice_parser_list *list;
1942         struct ice_flow_parser_node *p_parser;
1943         void *temp;
1944
1945         list = ice_get_parser_list(parser, ad);
1946         if (list == NULL)
1947                 return;
1948
1949         RTE_TAILQ_FOREACH_SAFE(p_parser, list, node, temp) {
1950                 if (p_parser->parser->engine->type == parser->engine->type) {
1951                         TAILQ_REMOVE(list, p_parser, node);
1952                         rte_free(p_parser);
1953                 }
1954         }
1955 }
1956
1957 static int
1958 ice_flow_valid_attr(struct ice_adapter *ad,
1959                 const struct rte_flow_attr *attr,
1960                 int *ice_pipeline_stage,
1961                 struct rte_flow_error *error)
1962 {
1963         /* Must be input direction */
1964         if (!attr->ingress) {
1965                 rte_flow_error_set(error, EINVAL,
1966                                 RTE_FLOW_ERROR_TYPE_ATTR_INGRESS,
1967                                 attr, "Only support ingress.");
1968                 return -rte_errno;
1969         }
1970
1971         /* Not supported */
1972         if (attr->egress) {
1973                 rte_flow_error_set(error, EINVAL,
1974                                 RTE_FLOW_ERROR_TYPE_ATTR_EGRESS,
1975                                 attr, "Not support egress.");
1976                 return -rte_errno;
1977         }
1978
1979         /* Check pipeline mode support to set classification stage */
1980         if (ad->devargs.pipe_mode_support) {
1981                 if (attr->priority == 0)
1982                         *ice_pipeline_stage =
1983                                 ICE_FLOW_CLASSIFY_STAGE_PERMISSION;
1984                 else
1985                         *ice_pipeline_stage =
1986                                 ICE_FLOW_CLASSIFY_STAGE_DISTRIBUTOR;
1987         } else {
1988                 *ice_pipeline_stage =
1989                         ICE_FLOW_CLASSIFY_STAGE_DISTRIBUTOR_ONLY;
1990                 if (attr->priority > 1) {
1991                         rte_flow_error_set(error, EINVAL,
1992                                         RTE_FLOW_ERROR_TYPE_ATTR_PRIORITY,
1993                                         attr, "Only support priority 0 and 1.");
1994                         return -rte_errno;
1995                 }
1996         }
1997
1998         /* Not supported */
1999         if (attr->group) {
2000                 rte_flow_error_set(error, EINVAL,
2001                                 RTE_FLOW_ERROR_TYPE_ATTR_GROUP,
2002                                 attr, "Not support group.");
2003                 return -rte_errno;
2004         }
2005
2006         return 0;
2007 }
2008
2009 /* Find the first VOID or non-VOID item pointer */
2010 static const struct rte_flow_item *
2011 ice_find_first_item(const struct rte_flow_item *item, bool is_void)
2012 {
2013         bool is_find;
2014
2015         while (item->type != RTE_FLOW_ITEM_TYPE_END) {
2016                 if (is_void)
2017                         is_find = item->type == RTE_FLOW_ITEM_TYPE_VOID;
2018                 else
2019                         is_find = item->type != RTE_FLOW_ITEM_TYPE_VOID;
2020                 if (is_find)
2021                         break;
2022                 item++;
2023         }
2024         return item;
2025 }
2026
2027 /* Skip all VOID items of the pattern */
2028 static void
2029 ice_pattern_skip_void_item(struct rte_flow_item *items,
2030                         const struct rte_flow_item *pattern)
2031 {
2032         uint32_t cpy_count = 0;
2033         const struct rte_flow_item *pb = pattern, *pe = pattern;
2034
2035         for (;;) {
2036                 /* Find a non-void item first */
2037                 pb = ice_find_first_item(pb, false);
2038                 if (pb->type == RTE_FLOW_ITEM_TYPE_END) {
2039                         pe = pb;
2040                         break;
2041                 }
2042
2043                 /* Find a void item */
2044                 pe = ice_find_first_item(pb + 1, true);
2045
2046                 cpy_count = pe - pb;
2047                 rte_memcpy(items, pb, sizeof(struct rte_flow_item) * cpy_count);
2048
2049                 items += cpy_count;
2050
2051                 if (pe->type == RTE_FLOW_ITEM_TYPE_END) {
2052                         break;
2053                 }
2054
2055                 pb = pe + 1;
2056         }
2057         /* Copy the END item. */
2058         rte_memcpy(items, pe, sizeof(struct rte_flow_item));
2059 }
2060
2061 /* Check if the pattern matches a supported item type array */
2062 static bool
2063 ice_match_pattern(enum rte_flow_item_type *item_array,
2064                 const struct rte_flow_item *pattern)
2065 {
2066         const struct rte_flow_item *item = pattern;
2067
2068         while ((*item_array == item->type) &&
2069                (*item_array != RTE_FLOW_ITEM_TYPE_END)) {
2070                 item_array++;
2071                 item++;
2072         }
2073
2074         return (*item_array == RTE_FLOW_ITEM_TYPE_END &&
2075                 item->type == RTE_FLOW_ITEM_TYPE_END);
2076 }
2077
2078 struct ice_ptype_match {
2079         enum rte_flow_item_type *pattern_list;
2080         uint16_t hw_ptype;
2081 };
2082
2083 static struct ice_ptype_match ice_ptype_map[] = {
2084         {pattern_eth_ipv4,                              ICE_PTYPE_IPV4_PAY},
2085         {pattern_eth_ipv4_udp,                          ICE_PTYPE_IPV4_UDP_PAY},
2086         {pattern_eth_ipv4_tcp,                          ICE_PTYPE_IPV4_TCP_PAY},
2087         {pattern_eth_ipv4_sctp,                         ICE_PTYPE_IPV4_SCTP_PAY},
2088         {pattern_eth_ipv4_gtpu,                         ICE_MAC_IPV4_GTPU},
2089         {pattern_eth_ipv4_gtpu_eh,                      ICE_MAC_IPV4_GTPU},
2090         {pattern_eth_ipv4_gtpu_ipv4,                    ICE_MAC_IPV4_GTPU_IPV4_PAY},
2091         {pattern_eth_ipv4_gtpu_ipv4_udp,                ICE_MAC_IPV4_GTPU_IPV4_UDP_PAY},
2092         {pattern_eth_ipv4_gtpu_ipv4_tcp,                ICE_MAC_IPV4_GTPU_IPV4_TCP},
2093         {pattern_eth_ipv4_gtpu_ipv6,                    ICE_MAC_IPV4_GTPU_IPV6_PAY},
2094         {pattern_eth_ipv4_gtpu_ipv6_udp,                ICE_MAC_IPV4_GTPU_IPV6_UDP_PAY},
2095         {pattern_eth_ipv4_gtpu_ipv6_tcp,                ICE_MAC_IPV4_GTPU_IPV6_TCP},
2096         {pattern_eth_ipv4_gtpu_eh_ipv4,                 ICE_MAC_IPV4_GTPU_IPV4_PAY},
2097         {pattern_eth_ipv4_gtpu_eh_ipv4_udp,             ICE_MAC_IPV4_GTPU_IPV4_UDP_PAY},
2098         {pattern_eth_ipv4_gtpu_eh_ipv4_tcp,             ICE_MAC_IPV4_GTPU_IPV4_TCP},
2099         {pattern_eth_ipv4_gtpu_eh_ipv6,                 ICE_MAC_IPV4_GTPU_IPV6_PAY},
2100         {pattern_eth_ipv4_gtpu_eh_ipv6_udp,             ICE_MAC_IPV4_GTPU_IPV6_UDP_PAY},
2101         {pattern_eth_ipv4_gtpu_eh_ipv6_tcp,             ICE_MAC_IPV4_GTPU_IPV6_TCP},
2102         {pattern_eth_ipv4_esp,                          ICE_MAC_IPV4_ESP},
2103         {pattern_eth_ipv4_udp_esp,                      ICE_MAC_IPV4_NAT_T_ESP},
2104         {pattern_eth_ipv4_ah,                           ICE_MAC_IPV4_AH},
2105         {pattern_eth_ipv4_l2tp,                         ICE_MAC_IPV4_L2TPV3},
2106         {pattern_eth_ipv4_pfcp,                         ICE_MAC_IPV4_PFCP_SESSION},
2107         {pattern_eth_ipv6,                              ICE_PTYPE_IPV6_PAY},
2108         {pattern_eth_ipv6_udp,                          ICE_PTYPE_IPV6_UDP_PAY},
2109         {pattern_eth_ipv6_tcp,                          ICE_PTYPE_IPV6_TCP_PAY},
2110         {pattern_eth_ipv6_sctp,                         ICE_PTYPE_IPV6_SCTP_PAY},
2111         {pattern_eth_ipv6_frag_ext,                     ICE_PTYPE_IPV6FRAG_PAY},
2112         {pattern_eth_ipv6_gtpu,                         ICE_MAC_IPV6_GTPU},
2113         {pattern_eth_ipv6_gtpu_eh,                      ICE_MAC_IPV6_GTPU},
2114         {pattern_eth_ipv6_gtpu_ipv4,                    ICE_MAC_IPV6_GTPU_IPV4_PAY},
2115         {pattern_eth_ipv6_gtpu_ipv4_udp,                ICE_MAC_IPV6_GTPU_IPV4_UDP_PAY},
2116         {pattern_eth_ipv6_gtpu_ipv4_tcp,                ICE_MAC_IPV6_GTPU_IPV4_TCP},
2117         {pattern_eth_ipv6_gtpu_ipv6,                    ICE_MAC_IPV6_GTPU_IPV6_PAY},
2118         {pattern_eth_ipv6_gtpu_ipv6_udp,                ICE_MAC_IPV6_GTPU_IPV6_UDP_PAY},
2119         {pattern_eth_ipv6_gtpu_ipv6_tcp,                ICE_MAC_IPV6_GTPU_IPV6_TCP},
2120         {pattern_eth_ipv6_gtpu_eh_ipv4,                 ICE_MAC_IPV6_GTPU_IPV4_PAY},
2121         {pattern_eth_ipv6_gtpu_eh_ipv4_udp,             ICE_MAC_IPV6_GTPU_IPV4_UDP_PAY},
2122         {pattern_eth_ipv6_gtpu_eh_ipv4_tcp,             ICE_MAC_IPV6_GTPU_IPV4_TCP},
2123         {pattern_eth_ipv6_gtpu_eh_ipv6,                 ICE_MAC_IPV6_GTPU_IPV6_PAY},
2124         {pattern_eth_ipv6_gtpu_eh_ipv6_udp,             ICE_MAC_IPV6_GTPU_IPV6_UDP_PAY},
2125         {pattern_eth_ipv6_gtpu_eh_ipv6_tcp,             ICE_MAC_IPV6_GTPU_IPV6_TCP},
2126         {pattern_eth_ipv6_esp,                          ICE_MAC_IPV6_ESP},
2127         {pattern_eth_ipv6_udp_esp,                      ICE_MAC_IPV6_NAT_T_ESP},
2128         {pattern_eth_ipv6_ah,                           ICE_MAC_IPV6_AH},
2129         {pattern_eth_ipv6_l2tp,                         ICE_MAC_IPV6_L2TPV3},
2130         {pattern_eth_ipv6_pfcp,                         ICE_MAC_IPV6_PFCP_SESSION},
2131         {pattern_ethertype,                             ICE_PTYPE_MAC_PAY},
2132         {pattern_ethertype_vlan,                        ICE_PTYPE_MAC_PAY},
2133         {pattern_ethertype_qinq,                        ICE_PTYPE_MAC_PAY},
2134         {pattern_eth_arp,                               ICE_PTYPE_MAC_PAY},
2135         {pattern_eth_vlan_ipv4,                         ICE_PTYPE_IPV4_PAY},
2136         {pattern_eth_qinq_ipv4,                         ICE_PTYPE_IPV4_PAY},
2137         {pattern_eth_qinq_ipv4_udp,                     ICE_PTYPE_IPV4_UDP_PAY},
2138         {pattern_eth_qinq_ipv4_tcp,                     ICE_PTYPE_IPV4_TCP_PAY},
2139         {pattern_eth_vlan_ipv4_udp,                     ICE_PTYPE_IPV4_UDP_PAY},
2140         {pattern_eth_vlan_ipv4_tcp,                     ICE_PTYPE_IPV4_TCP_PAY},
2141         {pattern_eth_vlan_ipv4_sctp,                    ICE_PTYPE_IPV4_SCTP_PAY},
2142         {pattern_eth_vlan_ipv6,                         ICE_PTYPE_IPV6_PAY},
2143         {pattern_eth_qinq_ipv6,                         ICE_PTYPE_IPV6_PAY},
2144         {pattern_eth_qinq_ipv6_udp,                     ICE_PTYPE_IPV6_UDP_PAY},
2145         {pattern_eth_qinq_ipv6_tcp,                     ICE_PTYPE_IPV6_TCP_PAY},
2146         {pattern_eth_vlan_ipv6_udp,                     ICE_PTYPE_IPV6_UDP_PAY},
2147         {pattern_eth_vlan_ipv6_tcp,                     ICE_PTYPE_IPV6_TCP_PAY},
2148         {pattern_eth_vlan_ipv6_sctp,                    ICE_PTYPE_IPV6_SCTP_PAY},
2149         {pattern_eth_pppoes,                            ICE_MAC_PPPOE_PAY},
2150         {pattern_eth_vlan_pppoes,                       ICE_MAC_PPPOE_PAY},
2151         {pattern_eth_qinq_pppoes,                       ICE_MAC_PPPOE_PAY},
2152         {pattern_eth_pppoes_proto,                      ICE_MAC_PPPOE_PAY},
2153         {pattern_eth_vlan_pppoes_proto,                 ICE_MAC_PPPOE_PAY},
2154         {pattern_eth_qinq_pppoes_proto,                 ICE_MAC_PPPOE_PAY},
2155         {pattern_eth_pppoes_ipv4,                       ICE_MAC_PPPOE_IPV4_PAY},
2156         {pattern_eth_pppoes_ipv4_udp,                   ICE_MAC_PPPOE_IPV4_UDP_PAY},
2157         {pattern_eth_pppoes_ipv4_tcp,                   ICE_MAC_PPPOE_IPV4_TCP},
2158         {pattern_eth_vlan_pppoes_ipv4,                  ICE_MAC_PPPOE_IPV4_PAY},
2159         {pattern_eth_qinq_pppoes_ipv4,                  ICE_MAC_PPPOE_IPV4_PAY},
2160         {pattern_eth_vlan_pppoes_ipv4_tcp,              ICE_MAC_PPPOE_IPV4_TCP},
2161         {pattern_eth_vlan_pppoes_ipv4_udp,              ICE_MAC_PPPOE_IPV4_UDP_PAY},
2162         {pattern_eth_pppoes_ipv6,                       ICE_MAC_PPPOE_IPV6_PAY},
2163         {pattern_eth_pppoes_ipv6_udp,                   ICE_MAC_PPPOE_IPV6_UDP_PAY},
2164         {pattern_eth_pppoes_ipv6_tcp,                   ICE_MAC_PPPOE_IPV6_TCP},
2165         {pattern_eth_vlan_pppoes_ipv6,                  ICE_MAC_PPPOE_IPV6_PAY},
2166         {pattern_eth_qinq_pppoes_ipv6,                  ICE_MAC_PPPOE_IPV6_PAY},
2167         {pattern_eth_vlan_pppoes_ipv6_tcp,              ICE_MAC_PPPOE_IPV6_TCP},
2168         {pattern_eth_vlan_pppoes_ipv6_udp,              ICE_MAC_PPPOE_IPV6_UDP_PAY},
2169         {pattern_eth_ipv4_udp_vxlan_ipv4,               ICE_MAC_IPV4_TUN_IPV4_PAY},
2170         {pattern_eth_ipv4_udp_vxlan_ipv4_udp,           ICE_MAC_IPV4_TUN_IPV4_UDP_PAY},
2171         {pattern_eth_ipv4_udp_vxlan_ipv4_tcp,           ICE_MAC_IPV4_TUN_IPV4_TCP},
2172         {pattern_eth_ipv4_udp_vxlan_ipv4_sctp,          ICE_MAC_IPV4_TUN_IPV4_SCTP},
2173         {pattern_eth_ipv4_udp_vxlan_eth_ipv4,           ICE_MAC_IPV4_TUN_IPV4_PAY},
2174         {pattern_eth_ipv4_udp_vxlan_eth_ipv4_udp,       ICE_MAC_IPV4_TUN_IPV4_UDP_PAY},
2175         {pattern_eth_ipv4_udp_vxlan_eth_ipv4_tcp,       ICE_MAC_IPV4_TUN_IPV4_TCP},
2176         {pattern_eth_ipv4_udp_vxlan_eth_ipv4_sctp,      ICE_MAC_IPV4_TUN_IPV4_SCTP},
2177         {pattern_eth_ipv4_nvgre_eth_ipv4,               ICE_MAC_IPV4_TUN_IPV4_PAY},
2178         {pattern_eth_ipv4_nvgre_eth_ipv4_udp,           ICE_MAC_IPV4_TUN_IPV4_UDP_PAY},
2179         {pattern_eth_ipv4_nvgre_eth_ipv4_tcp,           ICE_MAC_IPV4_TUN_IPV4_TCP},
2180         {pattern_empty,                                 0},
2181 };
2182
2183 static bool
2184 ice_pattern_is_supported(__rte_unused struct ice_adapter *ad,
2185                          const struct rte_flow_item *pattern)
2186 {
2187         uint16_t i;
2188
2189         for (i = 0; i < RTE_DIM(ice_ptype_map); i++) {
2190                 if (ice_match_pattern(ice_ptype_map[i].pattern_list,
2191                                       pattern)) {
2192                         return ice_hw_ptype_ena(&ad->hw,
2193                                                 ice_ptype_map[i].hw_ptype);
2194                 }
2195         }
2196
2197         return false;
2198 }
2199
2200 struct ice_pattern_match_item *
2201 ice_search_pattern_match_item(struct ice_adapter *ad,
2202                               const struct rte_flow_item pattern[],
2203                               struct ice_pattern_match_item *array,
2204                               uint32_t array_len,
2205                               struct rte_flow_error *error)
2206 {
2207         struct ice_pattern_match_item *pattern_match_item;
2208         /* need free by each filter */
2209         struct rte_flow_item *items; /* used for pattern without VOID items */
2210         uint32_t item_num = 0; /* non-void item number */
2211         uint16_t i = 0;
2212
2213         /* Get the non-void item number of pattern */
2214         while ((pattern + i)->type != RTE_FLOW_ITEM_TYPE_END) {
2215                 if ((pattern + i)->type != RTE_FLOW_ITEM_TYPE_VOID)
2216                         item_num++;
2217                 i++;
2218         }
2219         item_num++;
2220
2221         items = rte_zmalloc("ice_pattern",
2222                             item_num * sizeof(struct rte_flow_item), 0);
2223         if (!items) {
2224                 rte_flow_error_set(error, ENOMEM, RTE_FLOW_ERROR_TYPE_ITEM_NUM,
2225                                    NULL, "No memory for PMD internal items.");
2226                 return NULL;
2227         }
2228         pattern_match_item = rte_zmalloc("ice_pattern_match_item",
2229                         sizeof(struct ice_pattern_match_item), 0);
2230         if (!pattern_match_item) {
2231                 rte_flow_error_set(error, ENOMEM, RTE_FLOW_ERROR_TYPE_HANDLE,
2232                                 NULL, "Failed to allocate memory.");
2233                 rte_free(items);
2234                 return NULL;
2235         }
2236
2237         ice_pattern_skip_void_item(items, pattern);
2238
2239         if (!ice_pattern_is_supported(ad, pattern))
2240                 goto unsupported;
2241
2242         for (i = 0; i < array_len; i++) {
2243                 if (ice_match_pattern(array[i].pattern_list,
2244                                       items)) {
2245                         pattern_match_item->input_set_mask_o =
2246                                 array[i].input_set_mask_o;
2247                         pattern_match_item->input_set_mask_i =
2248                                 array[i].input_set_mask_i;
2249                         pattern_match_item->pattern_list =
2250                                 array[i].pattern_list;
2251                         pattern_match_item->meta = array[i].meta;
2252                         rte_free(items);
2253                         return pattern_match_item;
2254                 }
2255         }
2256
2257 unsupported:
2258         rte_flow_error_set(error, EINVAL, RTE_FLOW_ERROR_TYPE_ITEM,
2259                            pattern, "Unsupported pattern");
2260         rte_free(items);
2261         rte_free(pattern_match_item);
2262         return NULL;
2263 }
2264
2265 static struct ice_flow_engine *
2266 ice_parse_engine_create(struct ice_adapter *ad,
2267                 struct rte_flow *flow,
2268                 struct ice_parser_list *parser_list,
2269                 uint32_t priority,
2270                 const struct rte_flow_item pattern[],
2271                 const struct rte_flow_action actions[],
2272                 struct rte_flow_error *error)
2273 {
2274         struct ice_flow_engine *engine = NULL;
2275         struct ice_flow_parser_node *parser_node;
2276         void *meta = NULL;
2277         void *temp;
2278
2279         RTE_TAILQ_FOREACH_SAFE(parser_node, parser_list, node, temp) {
2280                 int ret;
2281
2282                 if (parser_node->parser->parse_pattern_action(ad,
2283                                 parser_node->parser->array,
2284                                 parser_node->parser->array_len,
2285                                 pattern, actions, priority, &meta, error) < 0)
2286                         continue;
2287
2288                 engine = parser_node->parser->engine;
2289                 RTE_ASSERT(engine->create != NULL);
2290                 ret = engine->create(ad, flow, meta, error);
2291                 if (ret == 0)
2292                         return engine;
2293                 else if (ret == -EEXIST)
2294                         return NULL;
2295         }
2296         return NULL;
2297 }
2298
2299 static struct ice_flow_engine *
2300 ice_parse_engine_validate(struct ice_adapter *ad,
2301                 struct rte_flow *flow __rte_unused,
2302                 struct ice_parser_list *parser_list,
2303                 uint32_t priority,
2304                 const struct rte_flow_item pattern[],
2305                 const struct rte_flow_action actions[],
2306                 struct rte_flow_error *error)
2307 {
2308         struct ice_flow_engine *engine = NULL;
2309         struct ice_flow_parser_node *parser_node;
2310         void *temp;
2311
2312         RTE_TAILQ_FOREACH_SAFE(parser_node, parser_list, node, temp) {
2313                 if (parser_node->parser->parse_pattern_action(ad,
2314                                 parser_node->parser->array,
2315                                 parser_node->parser->array_len,
2316                                 pattern, actions, priority, NULL, error) < 0)
2317                         continue;
2318
2319                 engine = parser_node->parser->engine;
2320                 break;
2321         }
2322         return engine;
2323 }
2324
2325 static int
2326 ice_flow_process_filter(struct rte_eth_dev *dev,
2327                 struct rte_flow *flow,
2328                 const struct rte_flow_attr *attr,
2329                 const struct rte_flow_item pattern[],
2330                 const struct rte_flow_action actions[],
2331                 struct ice_flow_engine **engine,
2332                 parse_engine_t ice_parse_engine,
2333                 struct rte_flow_error *error)
2334 {
2335         int ret = ICE_ERR_NOT_SUPPORTED;
2336         struct ice_adapter *ad =
2337                 ICE_DEV_PRIVATE_TO_ADAPTER(dev->data->dev_private);
2338         struct ice_pf *pf = ICE_DEV_PRIVATE_TO_PF(dev->data->dev_private);
2339         int ice_pipeline_stage = 0;
2340
2341         if (!pattern) {
2342                 rte_flow_error_set(error, EINVAL, RTE_FLOW_ERROR_TYPE_ITEM_NUM,
2343                                    NULL, "NULL pattern.");
2344                 return -rte_errno;
2345         }
2346
2347         if (!actions || actions->type == RTE_FLOW_ACTION_TYPE_END) {
2348                 rte_flow_error_set(error, EINVAL,
2349                                    RTE_FLOW_ERROR_TYPE_ACTION_NUM,
2350                                    NULL, "NULL action.");
2351                 return -rte_errno;
2352         }
2353
2354         if (!attr) {
2355                 rte_flow_error_set(error, EINVAL,
2356                                    RTE_FLOW_ERROR_TYPE_ATTR,
2357                                    NULL, "NULL attribute.");
2358                 return -rte_errno;
2359         }
2360
2361         ret = ice_flow_valid_attr(ad, attr, &ice_pipeline_stage, error);
2362         if (ret)
2363                 return ret;
2364
2365         *engine = ice_parse_engine(ad, flow, &pf->rss_parser_list,
2366                         attr->priority, pattern, actions, error);
2367         if (*engine != NULL)
2368                 return 0;
2369
2370         switch (ice_pipeline_stage) {
2371         case ICE_FLOW_CLASSIFY_STAGE_DISTRIBUTOR_ONLY:
2372         case ICE_FLOW_CLASSIFY_STAGE_DISTRIBUTOR:
2373                 *engine = ice_parse_engine(ad, flow, &pf->dist_parser_list,
2374                                 attr->priority, pattern, actions, error);
2375                 break;
2376         case ICE_FLOW_CLASSIFY_STAGE_PERMISSION:
2377                 *engine = ice_parse_engine(ad, flow, &pf->perm_parser_list,
2378                                 attr->priority, pattern, actions, error);
2379                 break;
2380         default:
2381                 return -EINVAL;
2382         }
2383
2384         if (*engine == NULL)
2385                 return -EINVAL;
2386
2387         return 0;
2388 }
2389
2390 static int
2391 ice_flow_validate(struct rte_eth_dev *dev,
2392                 const struct rte_flow_attr *attr,
2393                 const struct rte_flow_item pattern[],
2394                 const struct rte_flow_action actions[],
2395                 struct rte_flow_error *error)
2396 {
2397         struct ice_flow_engine *engine;
2398
2399         return ice_flow_process_filter(dev, NULL, attr, pattern, actions,
2400                         &engine, ice_parse_engine_validate, error);
2401 }
2402
2403 static struct rte_flow *
2404 ice_flow_create(struct rte_eth_dev *dev,
2405                 const struct rte_flow_attr *attr,
2406                 const struct rte_flow_item pattern[],
2407                 const struct rte_flow_action actions[],
2408                 struct rte_flow_error *error)
2409 {
2410         struct ice_pf *pf = ICE_DEV_PRIVATE_TO_PF(dev->data->dev_private);
2411         struct rte_flow *flow = NULL;
2412         int ret;
2413         struct ice_flow_engine *engine = NULL;
2414
2415         flow = rte_zmalloc("ice_flow", sizeof(struct rte_flow), 0);
2416         if (!flow) {
2417                 rte_flow_error_set(error, ENOMEM,
2418                                    RTE_FLOW_ERROR_TYPE_HANDLE, NULL,
2419                                    "Failed to allocate memory");
2420                 return flow;
2421         }
2422
2423         rte_spinlock_lock(&pf->flow_ops_lock);
2424
2425         ret = ice_flow_process_filter(dev, flow, attr, pattern, actions,
2426                         &engine, ice_parse_engine_create, error);
2427         if (ret < 0) {
2428                 PMD_DRV_LOG(ERR, "Failed to create flow");
2429                 rte_free(flow);
2430                 flow = NULL;
2431                 goto out;
2432         }
2433
2434         flow->engine = engine;
2435         TAILQ_INSERT_TAIL(&pf->flow_list, flow, node);
2436         PMD_DRV_LOG(INFO, "Succeeded to create (%d) flow", engine->type);
2437
2438 out:
2439         rte_spinlock_unlock(&pf->flow_ops_lock);
2440         return flow;
2441 }
2442
2443 static int
2444 ice_flow_destroy(struct rte_eth_dev *dev,
2445                 struct rte_flow *flow,
2446                 struct rte_flow_error *error)
2447 {
2448         struct ice_pf *pf = ICE_DEV_PRIVATE_TO_PF(dev->data->dev_private);
2449         struct ice_adapter *ad =
2450                 ICE_DEV_PRIVATE_TO_ADAPTER(dev->data->dev_private);
2451         int ret = 0;
2452
2453         if (!flow || !flow->engine || !flow->engine->destroy) {
2454                 rte_flow_error_set(error, EINVAL,
2455                                 RTE_FLOW_ERROR_TYPE_HANDLE,
2456                                 NULL, "Invalid flow");
2457                 return -rte_errno;
2458         }
2459
2460         rte_spinlock_lock(&pf->flow_ops_lock);
2461
2462         ret = flow->engine->destroy(ad, flow, error);
2463         if (!ret) {
2464                 TAILQ_REMOVE(&pf->flow_list, flow, node);
2465                 rte_free(flow);
2466         } else {
2467                 PMD_DRV_LOG(ERR, "Failed to destroy flow");
2468         }
2469
2470         rte_spinlock_unlock(&pf->flow_ops_lock);
2471
2472         return ret;
2473 }
2474
2475 static int
2476 ice_flow_flush(struct rte_eth_dev *dev,
2477                 struct rte_flow_error *error)
2478 {
2479         struct ice_pf *pf = ICE_DEV_PRIVATE_TO_PF(dev->data->dev_private);
2480         struct rte_flow *p_flow;
2481         void *temp;
2482         int ret = 0;
2483
2484         RTE_TAILQ_FOREACH_SAFE(p_flow, &pf->flow_list, node, temp) {
2485                 ret = ice_flow_destroy(dev, p_flow, error);
2486                 if (ret) {
2487                         PMD_DRV_LOG(ERR, "Failed to flush flows");
2488                         return -EINVAL;
2489                 }
2490         }
2491
2492         return ret;
2493 }
2494
2495 static int
2496 ice_flow_query(struct rte_eth_dev *dev,
2497                 struct rte_flow *flow,
2498                 const struct rte_flow_action *actions,
2499                 void *data,
2500                 struct rte_flow_error *error)
2501 {
2502         int ret = -EINVAL;
2503         struct ice_adapter *ad =
2504                 ICE_DEV_PRIVATE_TO_ADAPTER(dev->data->dev_private);
2505         struct rte_flow_query_count *count = data;
2506         struct ice_pf *pf = &ad->pf;
2507
2508         if (!flow || !flow->engine || !flow->engine->query_count) {
2509                 rte_flow_error_set(error, EINVAL,
2510                                 RTE_FLOW_ERROR_TYPE_HANDLE,
2511                                 NULL, "Invalid flow");
2512                 return -rte_errno;
2513         }
2514
2515         rte_spinlock_lock(&pf->flow_ops_lock);
2516
2517         for (; actions->type != RTE_FLOW_ACTION_TYPE_END; actions++) {
2518                 switch (actions->type) {
2519                 case RTE_FLOW_ACTION_TYPE_VOID:
2520                         break;
2521                 case RTE_FLOW_ACTION_TYPE_COUNT:
2522                         ret = flow->engine->query_count(ad, flow, count, error);
2523                         break;
2524                 default:
2525                         ret = rte_flow_error_set(error, ENOTSUP,
2526                                         RTE_FLOW_ERROR_TYPE_ACTION,
2527                                         actions,
2528                                         "action not supported");
2529                         goto out;
2530                 }
2531         }
2532
2533 out:
2534         rte_spinlock_unlock(&pf->flow_ops_lock);
2535         return ret;
2536 }
2537
2538 int
2539 ice_flow_redirect(struct ice_adapter *ad,
2540                   struct ice_flow_redirect *rd)
2541 {
2542         struct ice_pf *pf = &ad->pf;
2543         struct rte_flow *p_flow;
2544         void *temp;
2545         int ret;
2546
2547         rte_spinlock_lock(&pf->flow_ops_lock);
2548
2549         RTE_TAILQ_FOREACH_SAFE(p_flow, &pf->flow_list, node, temp) {
2550                 if (!p_flow->engine->redirect)
2551                         continue;
2552                 ret = p_flow->engine->redirect(ad, p_flow, rd);
2553                 if (ret) {
2554                         PMD_DRV_LOG(ERR, "Failed to redirect flows");
2555                         return ret;
2556                 }
2557         }
2558
2559         rte_spinlock_unlock(&pf->flow_ops_lock);
2560
2561         return 0;
2562 }