net/i40e: fix Rx packet statistics
[dpdk.git] / drivers / net / iavf / iavf_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 "iavf.h"
19 #include "iavf_generic_flow.h"
20
21 static struct iavf_engine_list engine_list =
22                 TAILQ_HEAD_INITIALIZER(engine_list);
23
24 static int iavf_flow_validate(struct rte_eth_dev *dev,
25                 const struct rte_flow_attr *attr,
26                 const struct rte_flow_item pattern[],
27                 const struct rte_flow_action actions[],
28                 struct rte_flow_error *error);
29 static struct rte_flow *iavf_flow_create(struct rte_eth_dev *dev,
30                 const struct rte_flow_attr *attr,
31                 const struct rte_flow_item pattern[],
32                 const struct rte_flow_action actions[],
33                 struct rte_flow_error *error);
34 static int iavf_flow_destroy(struct rte_eth_dev *dev,
35                 struct rte_flow *flow,
36                 struct rte_flow_error *error);
37 static int iavf_flow_query(struct rte_eth_dev *dev,
38                 struct rte_flow *flow,
39                 const struct rte_flow_action *actions,
40                 void *data,
41                 struct rte_flow_error *error);
42
43 const struct rte_flow_ops iavf_flow_ops = {
44         .validate = iavf_flow_validate,
45         .create = iavf_flow_create,
46         .destroy = iavf_flow_destroy,
47         .flush = iavf_flow_flush,
48         .query = iavf_flow_query,
49 };
50
51 /* empty */
52 enum rte_flow_item_type iavf_pattern_empty[] = {
53         RTE_FLOW_ITEM_TYPE_END,
54 };
55
56 /* L2 */
57 enum rte_flow_item_type iavf_pattern_ethertype[] = {
58         RTE_FLOW_ITEM_TYPE_ETH,
59         RTE_FLOW_ITEM_TYPE_END,
60 };
61
62 enum rte_flow_item_type iavf_pattern_ethertype_vlan[] = {
63         RTE_FLOW_ITEM_TYPE_ETH,
64         RTE_FLOW_ITEM_TYPE_VLAN,
65         RTE_FLOW_ITEM_TYPE_END,
66 };
67
68 enum rte_flow_item_type iavf_pattern_ethertype_qinq[] = {
69         RTE_FLOW_ITEM_TYPE_ETH,
70         RTE_FLOW_ITEM_TYPE_VLAN,
71         RTE_FLOW_ITEM_TYPE_VLAN,
72         RTE_FLOW_ITEM_TYPE_END,
73 };
74
75 /* ARP */
76 enum rte_flow_item_type iavf_pattern_eth_arp[] = {
77         RTE_FLOW_ITEM_TYPE_ETH,
78         RTE_FLOW_ITEM_TYPE_ARP_ETH_IPV4,
79         RTE_FLOW_ITEM_TYPE_END,
80 };
81
82 /* non-tunnel IPv4 */
83 enum rte_flow_item_type iavf_pattern_eth_ipv4[] = {
84         RTE_FLOW_ITEM_TYPE_ETH,
85         RTE_FLOW_ITEM_TYPE_IPV4,
86         RTE_FLOW_ITEM_TYPE_END,
87 };
88
89 enum rte_flow_item_type iavf_pattern_eth_vlan_ipv4[] = {
90         RTE_FLOW_ITEM_TYPE_ETH,
91         RTE_FLOW_ITEM_TYPE_VLAN,
92         RTE_FLOW_ITEM_TYPE_IPV4,
93         RTE_FLOW_ITEM_TYPE_END,
94 };
95
96 enum rte_flow_item_type iavf_pattern_eth_qinq_ipv4[] = {
97         RTE_FLOW_ITEM_TYPE_ETH,
98         RTE_FLOW_ITEM_TYPE_VLAN,
99         RTE_FLOW_ITEM_TYPE_VLAN,
100         RTE_FLOW_ITEM_TYPE_IPV4,
101         RTE_FLOW_ITEM_TYPE_END,
102 };
103
104 enum rte_flow_item_type iavf_pattern_eth_ipv4_udp[] = {
105         RTE_FLOW_ITEM_TYPE_ETH,
106         RTE_FLOW_ITEM_TYPE_IPV4,
107         RTE_FLOW_ITEM_TYPE_UDP,
108         RTE_FLOW_ITEM_TYPE_END,
109 };
110
111 enum rte_flow_item_type iavf_pattern_eth_vlan_ipv4_udp[] = {
112         RTE_FLOW_ITEM_TYPE_ETH,
113         RTE_FLOW_ITEM_TYPE_VLAN,
114         RTE_FLOW_ITEM_TYPE_IPV4,
115         RTE_FLOW_ITEM_TYPE_UDP,
116         RTE_FLOW_ITEM_TYPE_END,
117 };
118
119 enum rte_flow_item_type iavf_pattern_eth_qinq_ipv4_udp[] = {
120         RTE_FLOW_ITEM_TYPE_ETH,
121         RTE_FLOW_ITEM_TYPE_VLAN,
122         RTE_FLOW_ITEM_TYPE_VLAN,
123         RTE_FLOW_ITEM_TYPE_IPV4,
124         RTE_FLOW_ITEM_TYPE_UDP,
125         RTE_FLOW_ITEM_TYPE_END,
126 };
127
128 enum rte_flow_item_type iavf_pattern_eth_ipv4_tcp[] = {
129         RTE_FLOW_ITEM_TYPE_ETH,
130         RTE_FLOW_ITEM_TYPE_IPV4,
131         RTE_FLOW_ITEM_TYPE_TCP,
132         RTE_FLOW_ITEM_TYPE_END,
133 };
134
135 enum rte_flow_item_type iavf_pattern_eth_vlan_ipv4_tcp[] = {
136         RTE_FLOW_ITEM_TYPE_ETH,
137         RTE_FLOW_ITEM_TYPE_VLAN,
138         RTE_FLOW_ITEM_TYPE_IPV4,
139         RTE_FLOW_ITEM_TYPE_TCP,
140         RTE_FLOW_ITEM_TYPE_END,
141 };
142
143 enum rte_flow_item_type iavf_pattern_eth_qinq_ipv4_tcp[] = {
144         RTE_FLOW_ITEM_TYPE_ETH,
145         RTE_FLOW_ITEM_TYPE_VLAN,
146         RTE_FLOW_ITEM_TYPE_VLAN,
147         RTE_FLOW_ITEM_TYPE_IPV4,
148         RTE_FLOW_ITEM_TYPE_TCP,
149         RTE_FLOW_ITEM_TYPE_END,
150 };
151
152 enum rte_flow_item_type iavf_pattern_eth_ipv4_sctp[] = {
153         RTE_FLOW_ITEM_TYPE_ETH,
154         RTE_FLOW_ITEM_TYPE_IPV4,
155         RTE_FLOW_ITEM_TYPE_SCTP,
156         RTE_FLOW_ITEM_TYPE_END,
157 };
158
159 enum rte_flow_item_type iavf_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
167 enum rte_flow_item_type iavf_pattern_eth_qinq_ipv4_sctp[] = {
168         RTE_FLOW_ITEM_TYPE_ETH,
169         RTE_FLOW_ITEM_TYPE_VLAN,
170         RTE_FLOW_ITEM_TYPE_VLAN,
171         RTE_FLOW_ITEM_TYPE_IPV4,
172         RTE_FLOW_ITEM_TYPE_SCTP,
173         RTE_FLOW_ITEM_TYPE_END,
174 };
175
176 enum rte_flow_item_type iavf_pattern_eth_ipv4_icmp[] = {
177         RTE_FLOW_ITEM_TYPE_ETH,
178         RTE_FLOW_ITEM_TYPE_IPV4,
179         RTE_FLOW_ITEM_TYPE_ICMP,
180         RTE_FLOW_ITEM_TYPE_END,
181 };
182
183 enum rte_flow_item_type iavf_pattern_eth_vlan_ipv4_icmp[] = {
184         RTE_FLOW_ITEM_TYPE_ETH,
185         RTE_FLOW_ITEM_TYPE_VLAN,
186         RTE_FLOW_ITEM_TYPE_IPV4,
187         RTE_FLOW_ITEM_TYPE_ICMP,
188         RTE_FLOW_ITEM_TYPE_END,
189 };
190
191 enum rte_flow_item_type iavf_pattern_eth_qinq_ipv4_icmp[] = {
192         RTE_FLOW_ITEM_TYPE_ETH,
193         RTE_FLOW_ITEM_TYPE_VLAN,
194         RTE_FLOW_ITEM_TYPE_VLAN,
195         RTE_FLOW_ITEM_TYPE_IPV4,
196         RTE_FLOW_ITEM_TYPE_ICMP,
197         RTE_FLOW_ITEM_TYPE_END,
198 };
199
200 /* non-tunnel IPv6 */
201 enum rte_flow_item_type iavf_pattern_eth_ipv6[] = {
202         RTE_FLOW_ITEM_TYPE_ETH,
203         RTE_FLOW_ITEM_TYPE_IPV6,
204         RTE_FLOW_ITEM_TYPE_END,
205 };
206
207 enum rte_flow_item_type iavf_pattern_eth_vlan_ipv6[] = {
208         RTE_FLOW_ITEM_TYPE_ETH,
209         RTE_FLOW_ITEM_TYPE_VLAN,
210         RTE_FLOW_ITEM_TYPE_IPV6,
211         RTE_FLOW_ITEM_TYPE_END,
212 };
213
214 enum rte_flow_item_type iavf_pattern_eth_qinq_ipv6[] = {
215         RTE_FLOW_ITEM_TYPE_ETH,
216         RTE_FLOW_ITEM_TYPE_VLAN,
217         RTE_FLOW_ITEM_TYPE_VLAN,
218         RTE_FLOW_ITEM_TYPE_IPV6,
219         RTE_FLOW_ITEM_TYPE_END,
220 };
221
222 enum rte_flow_item_type iavf_pattern_eth_ipv6_frag_ext[] = {
223         RTE_FLOW_ITEM_TYPE_ETH,
224         RTE_FLOW_ITEM_TYPE_IPV6,
225         RTE_FLOW_ITEM_TYPE_IPV6_FRAG_EXT,
226         RTE_FLOW_ITEM_TYPE_END,
227 };
228
229 enum rte_flow_item_type iavf_pattern_eth_vlan_ipv6_frag_ext[] = {
230         RTE_FLOW_ITEM_TYPE_ETH,
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
237 enum rte_flow_item_type iavf_pattern_eth_qinq_ipv6_frag_ext[] = {
238         RTE_FLOW_ITEM_TYPE_ETH,
239         RTE_FLOW_ITEM_TYPE_VLAN,
240         RTE_FLOW_ITEM_TYPE_VLAN,
241         RTE_FLOW_ITEM_TYPE_IPV6,
242         RTE_FLOW_ITEM_TYPE_IPV6_FRAG_EXT,
243         RTE_FLOW_ITEM_TYPE_END,
244 };
245
246 enum rte_flow_item_type iavf_pattern_eth_ipv6_udp[] = {
247         RTE_FLOW_ITEM_TYPE_ETH,
248         RTE_FLOW_ITEM_TYPE_IPV6,
249         RTE_FLOW_ITEM_TYPE_UDP,
250         RTE_FLOW_ITEM_TYPE_END,
251 };
252
253 enum rte_flow_item_type iavf_pattern_eth_vlan_ipv6_udp[] = {
254         RTE_FLOW_ITEM_TYPE_ETH,
255         RTE_FLOW_ITEM_TYPE_VLAN,
256         RTE_FLOW_ITEM_TYPE_IPV6,
257         RTE_FLOW_ITEM_TYPE_UDP,
258         RTE_FLOW_ITEM_TYPE_END,
259 };
260
261 enum rte_flow_item_type iavf_pattern_eth_qinq_ipv6_udp[] = {
262         RTE_FLOW_ITEM_TYPE_ETH,
263         RTE_FLOW_ITEM_TYPE_VLAN,
264         RTE_FLOW_ITEM_TYPE_VLAN,
265         RTE_FLOW_ITEM_TYPE_IPV6,
266         RTE_FLOW_ITEM_TYPE_UDP,
267         RTE_FLOW_ITEM_TYPE_END,
268 };
269
270 enum rte_flow_item_type iavf_pattern_eth_ipv6_tcp[] = {
271         RTE_FLOW_ITEM_TYPE_ETH,
272         RTE_FLOW_ITEM_TYPE_IPV6,
273         RTE_FLOW_ITEM_TYPE_TCP,
274         RTE_FLOW_ITEM_TYPE_END,
275 };
276
277 enum rte_flow_item_type iavf_pattern_eth_vlan_ipv6_tcp[] = {
278         RTE_FLOW_ITEM_TYPE_ETH,
279         RTE_FLOW_ITEM_TYPE_VLAN,
280         RTE_FLOW_ITEM_TYPE_IPV6,
281         RTE_FLOW_ITEM_TYPE_TCP,
282         RTE_FLOW_ITEM_TYPE_END,
283 };
284
285 enum rte_flow_item_type iavf_pattern_eth_qinq_ipv6_tcp[] = {
286         RTE_FLOW_ITEM_TYPE_ETH,
287         RTE_FLOW_ITEM_TYPE_VLAN,
288         RTE_FLOW_ITEM_TYPE_VLAN,
289         RTE_FLOW_ITEM_TYPE_IPV6,
290         RTE_FLOW_ITEM_TYPE_TCP,
291         RTE_FLOW_ITEM_TYPE_END,
292 };
293
294 enum rte_flow_item_type iavf_pattern_eth_ipv6_sctp[] = {
295         RTE_FLOW_ITEM_TYPE_ETH,
296         RTE_FLOW_ITEM_TYPE_IPV6,
297         RTE_FLOW_ITEM_TYPE_SCTP,
298         RTE_FLOW_ITEM_TYPE_END,
299 };
300
301 enum rte_flow_item_type iavf_pattern_eth_vlan_ipv6_sctp[] = {
302         RTE_FLOW_ITEM_TYPE_ETH,
303         RTE_FLOW_ITEM_TYPE_VLAN,
304         RTE_FLOW_ITEM_TYPE_IPV6,
305         RTE_FLOW_ITEM_TYPE_SCTP,
306         RTE_FLOW_ITEM_TYPE_END,
307 };
308
309 enum rte_flow_item_type iavf_pattern_eth_qinq_ipv6_sctp[] = {
310         RTE_FLOW_ITEM_TYPE_ETH,
311         RTE_FLOW_ITEM_TYPE_VLAN,
312         RTE_FLOW_ITEM_TYPE_VLAN,
313         RTE_FLOW_ITEM_TYPE_IPV6,
314         RTE_FLOW_ITEM_TYPE_SCTP,
315         RTE_FLOW_ITEM_TYPE_END,
316 };
317
318 enum rte_flow_item_type iavf_pattern_eth_ipv6_icmp6[] = {
319         RTE_FLOW_ITEM_TYPE_ETH,
320         RTE_FLOW_ITEM_TYPE_IPV6,
321         RTE_FLOW_ITEM_TYPE_ICMP6,
322         RTE_FLOW_ITEM_TYPE_END,
323 };
324
325 enum rte_flow_item_type iavf_pattern_eth_vlan_ipv6_icmp6[] = {
326         RTE_FLOW_ITEM_TYPE_ETH,
327         RTE_FLOW_ITEM_TYPE_VLAN,
328         RTE_FLOW_ITEM_TYPE_IPV6,
329         RTE_FLOW_ITEM_TYPE_ICMP6,
330         RTE_FLOW_ITEM_TYPE_END,
331 };
332
333 enum rte_flow_item_type iavf_pattern_eth_qinq_ipv6_icmp6[] = {
334         RTE_FLOW_ITEM_TYPE_ETH,
335         RTE_FLOW_ITEM_TYPE_VLAN,
336         RTE_FLOW_ITEM_TYPE_VLAN,
337         RTE_FLOW_ITEM_TYPE_IPV6,
338         RTE_FLOW_ITEM_TYPE_ICMP6,
339         RTE_FLOW_ITEM_TYPE_END,
340 };
341
342 /* IPv4 GTPC */
343 enum rte_flow_item_type iavf_pattern_eth_ipv4_gtpc[] = {
344         RTE_FLOW_ITEM_TYPE_ETH,
345         RTE_FLOW_ITEM_TYPE_IPV4,
346         RTE_FLOW_ITEM_TYPE_UDP,
347         RTE_FLOW_ITEM_TYPE_GTPC,
348         RTE_FLOW_ITEM_TYPE_END,
349 };
350
351 /* IPV4 GTPU (EH) */
352 enum rte_flow_item_type iavf_pattern_eth_ipv4_gtpu[] = {
353         RTE_FLOW_ITEM_TYPE_ETH,
354         RTE_FLOW_ITEM_TYPE_IPV4,
355         RTE_FLOW_ITEM_TYPE_UDP,
356         RTE_FLOW_ITEM_TYPE_GTPU,
357         RTE_FLOW_ITEM_TYPE_END,
358 };
359
360 enum rte_flow_item_type iavf_pattern_eth_ipv4_gtpu_eh[] = {
361         RTE_FLOW_ITEM_TYPE_ETH,
362         RTE_FLOW_ITEM_TYPE_IPV4,
363         RTE_FLOW_ITEM_TYPE_UDP,
364         RTE_FLOW_ITEM_TYPE_GTPU,
365         RTE_FLOW_ITEM_TYPE_GTP_PSC,
366         RTE_FLOW_ITEM_TYPE_END,
367 };
368
369 /* IPv6 GTPC */
370 enum rte_flow_item_type iavf_pattern_eth_ipv6_gtpc[] = {
371         RTE_FLOW_ITEM_TYPE_ETH,
372         RTE_FLOW_ITEM_TYPE_IPV6,
373         RTE_FLOW_ITEM_TYPE_UDP,
374         RTE_FLOW_ITEM_TYPE_GTPC,
375         RTE_FLOW_ITEM_TYPE_END,
376 };
377
378 /* IPV6 GTPU (EH) */
379 enum rte_flow_item_type iavf_pattern_eth_ipv6_gtpu[] = {
380         RTE_FLOW_ITEM_TYPE_ETH,
381         RTE_FLOW_ITEM_TYPE_IPV6,
382         RTE_FLOW_ITEM_TYPE_UDP,
383         RTE_FLOW_ITEM_TYPE_GTPU,
384         RTE_FLOW_ITEM_TYPE_END,
385 };
386
387 enum rte_flow_item_type iavf_pattern_eth_ipv6_gtpu_eh[] = {
388         RTE_FLOW_ITEM_TYPE_ETH,
389         RTE_FLOW_ITEM_TYPE_IPV6,
390         RTE_FLOW_ITEM_TYPE_UDP,
391         RTE_FLOW_ITEM_TYPE_GTPU,
392         RTE_FLOW_ITEM_TYPE_GTP_PSC,
393         RTE_FLOW_ITEM_TYPE_END,
394 };
395
396 /* IPV4 GTPU IPv4 */
397 enum rte_flow_item_type iavf_pattern_eth_ipv4_gtpu_ipv4[] = {
398         RTE_FLOW_ITEM_TYPE_ETH,
399         RTE_FLOW_ITEM_TYPE_IPV4,
400         RTE_FLOW_ITEM_TYPE_UDP,
401         RTE_FLOW_ITEM_TYPE_GTPU,
402         RTE_FLOW_ITEM_TYPE_IPV4,
403         RTE_FLOW_ITEM_TYPE_END,
404 };
405
406 enum rte_flow_item_type iavf_pattern_eth_ipv4_gtpu_ipv4_udp[] = {
407         RTE_FLOW_ITEM_TYPE_ETH,
408         RTE_FLOW_ITEM_TYPE_IPV4,
409         RTE_FLOW_ITEM_TYPE_UDP,
410         RTE_FLOW_ITEM_TYPE_GTPU,
411         RTE_FLOW_ITEM_TYPE_IPV4,
412         RTE_FLOW_ITEM_TYPE_UDP,
413         RTE_FLOW_ITEM_TYPE_END,
414 };
415
416 enum rte_flow_item_type iavf_pattern_eth_ipv4_gtpu_ipv4_tcp[] = {
417         RTE_FLOW_ITEM_TYPE_ETH,
418         RTE_FLOW_ITEM_TYPE_IPV4,
419         RTE_FLOW_ITEM_TYPE_UDP,
420         RTE_FLOW_ITEM_TYPE_GTPU,
421         RTE_FLOW_ITEM_TYPE_IPV4,
422         RTE_FLOW_ITEM_TYPE_TCP,
423         RTE_FLOW_ITEM_TYPE_END,
424 };
425
426 enum rte_flow_item_type iavf_pattern_eth_ipv4_gtpu_ipv4_icmp[] = {
427         RTE_FLOW_ITEM_TYPE_ETH,
428         RTE_FLOW_ITEM_TYPE_IPV4,
429         RTE_FLOW_ITEM_TYPE_UDP,
430         RTE_FLOW_ITEM_TYPE_GTPU,
431         RTE_FLOW_ITEM_TYPE_IPV4,
432         RTE_FLOW_ITEM_TYPE_ICMP,
433         RTE_FLOW_ITEM_TYPE_END,
434 };
435
436 enum rte_flow_item_type iavf_pattern_eth_ipv4_gre_ipv4_gtpu[] = {
437         RTE_FLOW_ITEM_TYPE_ETH,
438         RTE_FLOW_ITEM_TYPE_IPV4,
439         RTE_FLOW_ITEM_TYPE_GRE,
440         RTE_FLOW_ITEM_TYPE_IPV4,
441         RTE_FLOW_ITEM_TYPE_UDP,
442         RTE_FLOW_ITEM_TYPE_GTPU,
443         RTE_FLOW_ITEM_TYPE_END,
444 };
445
446 /* IPV4 GRE IPv4 UDP GTPU IPv4*/
447 enum rte_flow_item_type iavf_pattern_eth_ipv4_gre_ipv4_gtpu_ipv4[] = {
448         RTE_FLOW_ITEM_TYPE_ETH,
449         RTE_FLOW_ITEM_TYPE_IPV4,
450         RTE_FLOW_ITEM_TYPE_GRE,
451         RTE_FLOW_ITEM_TYPE_IPV4,
452         RTE_FLOW_ITEM_TYPE_UDP,
453         RTE_FLOW_ITEM_TYPE_GTPU,
454         RTE_FLOW_ITEM_TYPE_IPV4,
455         RTE_FLOW_ITEM_TYPE_END,
456 };
457
458 enum rte_flow_item_type iavf_pattern_eth_ipv4_gre_ipv4_gtpu_ipv4_udp[] = {
459         RTE_FLOW_ITEM_TYPE_ETH,
460         RTE_FLOW_ITEM_TYPE_IPV4,
461         RTE_FLOW_ITEM_TYPE_GRE,
462         RTE_FLOW_ITEM_TYPE_IPV4,
463         RTE_FLOW_ITEM_TYPE_UDP,
464         RTE_FLOW_ITEM_TYPE_GTPU,
465         RTE_FLOW_ITEM_TYPE_IPV4,
466         RTE_FLOW_ITEM_TYPE_UDP,
467         RTE_FLOW_ITEM_TYPE_END,
468 };
469
470 enum rte_flow_item_type iavf_pattern_eth_ipv4_gre_ipv4_gtpu_ipv4_tcp[] = {
471         RTE_FLOW_ITEM_TYPE_ETH,
472         RTE_FLOW_ITEM_TYPE_IPV4,
473         RTE_FLOW_ITEM_TYPE_GRE,
474         RTE_FLOW_ITEM_TYPE_IPV4,
475         RTE_FLOW_ITEM_TYPE_UDP,
476         RTE_FLOW_ITEM_TYPE_GTPU,
477         RTE_FLOW_ITEM_TYPE_IPV4,
478         RTE_FLOW_ITEM_TYPE_TCP,
479         RTE_FLOW_ITEM_TYPE_END,
480 };
481
482 /* IPV4 GRE IPv4 UDP GTPU IPv6*/
483 enum rte_flow_item_type iavf_pattern_eth_ipv4_gre_ipv4_gtpu_ipv6[] = {
484         RTE_FLOW_ITEM_TYPE_ETH,
485         RTE_FLOW_ITEM_TYPE_IPV4,
486         RTE_FLOW_ITEM_TYPE_GRE,
487         RTE_FLOW_ITEM_TYPE_IPV4,
488         RTE_FLOW_ITEM_TYPE_UDP,
489         RTE_FLOW_ITEM_TYPE_GTPU,
490         RTE_FLOW_ITEM_TYPE_IPV6,
491         RTE_FLOW_ITEM_TYPE_END,
492 };
493
494 enum rte_flow_item_type iavf_pattern_eth_ipv4_gre_ipv4_gtpu_ipv6_udp[] = {
495         RTE_FLOW_ITEM_TYPE_ETH,
496         RTE_FLOW_ITEM_TYPE_IPV4,
497         RTE_FLOW_ITEM_TYPE_GRE,
498         RTE_FLOW_ITEM_TYPE_IPV4,
499         RTE_FLOW_ITEM_TYPE_UDP,
500         RTE_FLOW_ITEM_TYPE_GTPU,
501         RTE_FLOW_ITEM_TYPE_IPV6,
502         RTE_FLOW_ITEM_TYPE_UDP,
503         RTE_FLOW_ITEM_TYPE_END,
504 };
505
506 enum rte_flow_item_type iavf_pattern_eth_ipv4_gre_ipv4_gtpu_ipv6_tcp[] = {
507         RTE_FLOW_ITEM_TYPE_ETH,
508         RTE_FLOW_ITEM_TYPE_IPV4,
509         RTE_FLOW_ITEM_TYPE_GRE,
510         RTE_FLOW_ITEM_TYPE_IPV4,
511         RTE_FLOW_ITEM_TYPE_UDP,
512         RTE_FLOW_ITEM_TYPE_GTPU,
513         RTE_FLOW_ITEM_TYPE_IPV6,
514         RTE_FLOW_ITEM_TYPE_TCP,
515         RTE_FLOW_ITEM_TYPE_END,
516 };
517
518 enum rte_flow_item_type iavf_pattern_eth_ipv4_gre_ipv6_gtpu[] = {
519         RTE_FLOW_ITEM_TYPE_ETH,
520         RTE_FLOW_ITEM_TYPE_IPV4,
521         RTE_FLOW_ITEM_TYPE_GRE,
522         RTE_FLOW_ITEM_TYPE_IPV6,
523         RTE_FLOW_ITEM_TYPE_UDP,
524         RTE_FLOW_ITEM_TYPE_GTPU,
525         RTE_FLOW_ITEM_TYPE_END,
526 };
527
528 /* IPV4 GRE IPv6 UDP GTPU IPv4*/
529 enum rte_flow_item_type iavf_pattern_eth_ipv4_gre_ipv6_gtpu_ipv4[] = {
530         RTE_FLOW_ITEM_TYPE_ETH,
531         RTE_FLOW_ITEM_TYPE_IPV4,
532         RTE_FLOW_ITEM_TYPE_GRE,
533         RTE_FLOW_ITEM_TYPE_IPV6,
534         RTE_FLOW_ITEM_TYPE_UDP,
535         RTE_FLOW_ITEM_TYPE_GTPU,
536         RTE_FLOW_ITEM_TYPE_IPV4,
537         RTE_FLOW_ITEM_TYPE_END,
538 };
539
540 enum rte_flow_item_type iavf_pattern_eth_ipv4_gre_ipv6_gtpu_ipv4_udp[] = {
541         RTE_FLOW_ITEM_TYPE_ETH,
542         RTE_FLOW_ITEM_TYPE_IPV4,
543         RTE_FLOW_ITEM_TYPE_GRE,
544         RTE_FLOW_ITEM_TYPE_IPV6,
545         RTE_FLOW_ITEM_TYPE_UDP,
546         RTE_FLOW_ITEM_TYPE_GTPU,
547         RTE_FLOW_ITEM_TYPE_IPV4,
548         RTE_FLOW_ITEM_TYPE_UDP,
549         RTE_FLOW_ITEM_TYPE_END,
550 };
551
552 enum rte_flow_item_type iavf_pattern_eth_ipv4_gre_ipv6_gtpu_ipv4_tcp[] = {
553         RTE_FLOW_ITEM_TYPE_ETH,
554         RTE_FLOW_ITEM_TYPE_IPV4,
555         RTE_FLOW_ITEM_TYPE_GRE,
556         RTE_FLOW_ITEM_TYPE_IPV6,
557         RTE_FLOW_ITEM_TYPE_UDP,
558         RTE_FLOW_ITEM_TYPE_GTPU,
559         RTE_FLOW_ITEM_TYPE_IPV4,
560         RTE_FLOW_ITEM_TYPE_TCP,
561         RTE_FLOW_ITEM_TYPE_END,
562 };
563
564 /* IPV4 GRE IPv6 UDP GTPU IPv6*/
565 enum rte_flow_item_type iavf_pattern_eth_ipv4_gre_ipv6_gtpu_ipv6[] = {
566         RTE_FLOW_ITEM_TYPE_ETH,
567         RTE_FLOW_ITEM_TYPE_IPV4,
568         RTE_FLOW_ITEM_TYPE_GRE,
569         RTE_FLOW_ITEM_TYPE_IPV6,
570         RTE_FLOW_ITEM_TYPE_UDP,
571         RTE_FLOW_ITEM_TYPE_GTPU,
572         RTE_FLOW_ITEM_TYPE_IPV6,
573         RTE_FLOW_ITEM_TYPE_END,
574 };
575
576 enum rte_flow_item_type iavf_pattern_eth_ipv4_gre_ipv6_gtpu_ipv6_udp[] = {
577         RTE_FLOW_ITEM_TYPE_ETH,
578         RTE_FLOW_ITEM_TYPE_IPV4,
579         RTE_FLOW_ITEM_TYPE_GRE,
580         RTE_FLOW_ITEM_TYPE_IPV6,
581         RTE_FLOW_ITEM_TYPE_UDP,
582         RTE_FLOW_ITEM_TYPE_GTPU,
583         RTE_FLOW_ITEM_TYPE_IPV6,
584         RTE_FLOW_ITEM_TYPE_UDP,
585         RTE_FLOW_ITEM_TYPE_END,
586 };
587
588 enum rte_flow_item_type iavf_pattern_eth_ipv4_gre_ipv6_gtpu_ipv6_tcp[] = {
589         RTE_FLOW_ITEM_TYPE_ETH,
590         RTE_FLOW_ITEM_TYPE_IPV4,
591         RTE_FLOW_ITEM_TYPE_GRE,
592         RTE_FLOW_ITEM_TYPE_IPV6,
593         RTE_FLOW_ITEM_TYPE_UDP,
594         RTE_FLOW_ITEM_TYPE_GTPU,
595         RTE_FLOW_ITEM_TYPE_IPV6,
596         RTE_FLOW_ITEM_TYPE_TCP,
597         RTE_FLOW_ITEM_TYPE_END,
598 };
599
600 enum rte_flow_item_type iavf_pattern_eth_ipv6_gre_ipv4_gtpu[] = {
601         RTE_FLOW_ITEM_TYPE_ETH,
602         RTE_FLOW_ITEM_TYPE_IPV6,
603         RTE_FLOW_ITEM_TYPE_GRE,
604         RTE_FLOW_ITEM_TYPE_IPV4,
605         RTE_FLOW_ITEM_TYPE_UDP,
606         RTE_FLOW_ITEM_TYPE_GTPU,
607         RTE_FLOW_ITEM_TYPE_END,
608 };
609
610 /* IPV6 GRE IPv4 UDP GTPU IPv4*/
611 enum rte_flow_item_type iavf_pattern_eth_ipv6_gre_ipv4_gtpu_ipv4[] = {
612         RTE_FLOW_ITEM_TYPE_ETH,
613         RTE_FLOW_ITEM_TYPE_IPV6,
614         RTE_FLOW_ITEM_TYPE_GRE,
615         RTE_FLOW_ITEM_TYPE_IPV4,
616         RTE_FLOW_ITEM_TYPE_UDP,
617         RTE_FLOW_ITEM_TYPE_GTPU,
618         RTE_FLOW_ITEM_TYPE_IPV4,
619         RTE_FLOW_ITEM_TYPE_END,
620 };
621
622 enum rte_flow_item_type iavf_pattern_eth_ipv6_gre_ipv4_gtpu_ipv4_udp[] = {
623         RTE_FLOW_ITEM_TYPE_ETH,
624         RTE_FLOW_ITEM_TYPE_IPV6,
625         RTE_FLOW_ITEM_TYPE_GRE,
626         RTE_FLOW_ITEM_TYPE_IPV4,
627         RTE_FLOW_ITEM_TYPE_UDP,
628         RTE_FLOW_ITEM_TYPE_GTPU,
629         RTE_FLOW_ITEM_TYPE_IPV4,
630         RTE_FLOW_ITEM_TYPE_UDP,
631         RTE_FLOW_ITEM_TYPE_END,
632 };
633
634 enum rte_flow_item_type iavf_pattern_eth_ipv6_gre_ipv4_gtpu_ipv4_tcp[] = {
635         RTE_FLOW_ITEM_TYPE_ETH,
636         RTE_FLOW_ITEM_TYPE_IPV6,
637         RTE_FLOW_ITEM_TYPE_GRE,
638         RTE_FLOW_ITEM_TYPE_IPV4,
639         RTE_FLOW_ITEM_TYPE_UDP,
640         RTE_FLOW_ITEM_TYPE_GTPU,
641         RTE_FLOW_ITEM_TYPE_IPV4,
642         RTE_FLOW_ITEM_TYPE_TCP,
643         RTE_FLOW_ITEM_TYPE_END,
644 };
645
646 /* IPV4 GRE IPv4 UDP GTPU IPv6*/
647 enum rte_flow_item_type iavf_pattern_eth_ipv6_gre_ipv4_gtpu_ipv6[] = {
648         RTE_FLOW_ITEM_TYPE_ETH,
649         RTE_FLOW_ITEM_TYPE_IPV6,
650         RTE_FLOW_ITEM_TYPE_GRE,
651         RTE_FLOW_ITEM_TYPE_IPV4,
652         RTE_FLOW_ITEM_TYPE_UDP,
653         RTE_FLOW_ITEM_TYPE_GTPU,
654         RTE_FLOW_ITEM_TYPE_IPV6,
655         RTE_FLOW_ITEM_TYPE_END,
656 };
657
658 enum rte_flow_item_type iavf_pattern_eth_ipv6_gre_ipv4_gtpu_ipv6_udp[] = {
659         RTE_FLOW_ITEM_TYPE_ETH,
660         RTE_FLOW_ITEM_TYPE_IPV6,
661         RTE_FLOW_ITEM_TYPE_GRE,
662         RTE_FLOW_ITEM_TYPE_IPV4,
663         RTE_FLOW_ITEM_TYPE_UDP,
664         RTE_FLOW_ITEM_TYPE_GTPU,
665         RTE_FLOW_ITEM_TYPE_IPV6,
666         RTE_FLOW_ITEM_TYPE_UDP,
667         RTE_FLOW_ITEM_TYPE_END,
668 };
669
670 enum rte_flow_item_type iavf_pattern_eth_ipv6_gre_ipv4_gtpu_ipv6_tcp[] = {
671         RTE_FLOW_ITEM_TYPE_ETH,
672         RTE_FLOW_ITEM_TYPE_IPV6,
673         RTE_FLOW_ITEM_TYPE_GRE,
674         RTE_FLOW_ITEM_TYPE_IPV4,
675         RTE_FLOW_ITEM_TYPE_UDP,
676         RTE_FLOW_ITEM_TYPE_GTPU,
677         RTE_FLOW_ITEM_TYPE_IPV6,
678         RTE_FLOW_ITEM_TYPE_TCP,
679         RTE_FLOW_ITEM_TYPE_END,
680 };
681
682 enum rte_flow_item_type iavf_pattern_eth_ipv6_gre_ipv6_gtpu[] = {
683         RTE_FLOW_ITEM_TYPE_ETH,
684         RTE_FLOW_ITEM_TYPE_IPV6,
685         RTE_FLOW_ITEM_TYPE_GRE,
686         RTE_FLOW_ITEM_TYPE_IPV6,
687         RTE_FLOW_ITEM_TYPE_UDP,
688         RTE_FLOW_ITEM_TYPE_GTPU,
689         RTE_FLOW_ITEM_TYPE_END,
690 };
691
692 /* IPV6 GRE IPv6 UDP GTPU IPv4*/
693 enum rte_flow_item_type iavf_pattern_eth_ipv6_gre_ipv6_gtpu_ipv4[] = {
694         RTE_FLOW_ITEM_TYPE_ETH,
695         RTE_FLOW_ITEM_TYPE_IPV6,
696         RTE_FLOW_ITEM_TYPE_GRE,
697         RTE_FLOW_ITEM_TYPE_IPV6,
698         RTE_FLOW_ITEM_TYPE_UDP,
699         RTE_FLOW_ITEM_TYPE_GTPU,
700         RTE_FLOW_ITEM_TYPE_IPV4,
701         RTE_FLOW_ITEM_TYPE_END,
702 };
703
704 enum rte_flow_item_type iavf_pattern_eth_ipv6_gre_ipv6_gtpu_ipv4_udp[] = {
705         RTE_FLOW_ITEM_TYPE_ETH,
706         RTE_FLOW_ITEM_TYPE_IPV6,
707         RTE_FLOW_ITEM_TYPE_GRE,
708         RTE_FLOW_ITEM_TYPE_IPV6,
709         RTE_FLOW_ITEM_TYPE_UDP,
710         RTE_FLOW_ITEM_TYPE_GTPU,
711         RTE_FLOW_ITEM_TYPE_IPV4,
712         RTE_FLOW_ITEM_TYPE_UDP,
713         RTE_FLOW_ITEM_TYPE_END,
714 };
715
716 enum rte_flow_item_type iavf_pattern_eth_ipv6_gre_ipv6_gtpu_ipv4_tcp[] = {
717         RTE_FLOW_ITEM_TYPE_ETH,
718         RTE_FLOW_ITEM_TYPE_IPV6,
719         RTE_FLOW_ITEM_TYPE_GRE,
720         RTE_FLOW_ITEM_TYPE_IPV6,
721         RTE_FLOW_ITEM_TYPE_UDP,
722         RTE_FLOW_ITEM_TYPE_GTPU,
723         RTE_FLOW_ITEM_TYPE_IPV4,
724         RTE_FLOW_ITEM_TYPE_TCP,
725         RTE_FLOW_ITEM_TYPE_END,
726 };
727
728 /* IPV6 GRE IPv6 UDP GTPU IPv6*/
729 enum rte_flow_item_type iavf_pattern_eth_ipv6_gre_ipv6_gtpu_ipv6[] = {
730         RTE_FLOW_ITEM_TYPE_ETH,
731         RTE_FLOW_ITEM_TYPE_IPV6,
732         RTE_FLOW_ITEM_TYPE_GRE,
733         RTE_FLOW_ITEM_TYPE_IPV6,
734         RTE_FLOW_ITEM_TYPE_UDP,
735         RTE_FLOW_ITEM_TYPE_GTPU,
736         RTE_FLOW_ITEM_TYPE_IPV6,
737         RTE_FLOW_ITEM_TYPE_END,
738 };
739
740 enum rte_flow_item_type iavf_pattern_eth_ipv6_gre_ipv6_gtpu_ipv6_udp[] = {
741         RTE_FLOW_ITEM_TYPE_ETH,
742         RTE_FLOW_ITEM_TYPE_IPV6,
743         RTE_FLOW_ITEM_TYPE_GRE,
744         RTE_FLOW_ITEM_TYPE_IPV6,
745         RTE_FLOW_ITEM_TYPE_UDP,
746         RTE_FLOW_ITEM_TYPE_GTPU,
747         RTE_FLOW_ITEM_TYPE_IPV6,
748         RTE_FLOW_ITEM_TYPE_UDP,
749         RTE_FLOW_ITEM_TYPE_END,
750 };
751
752 enum rte_flow_item_type iavf_pattern_eth_ipv6_gre_ipv6_gtpu_ipv6_tcp[] = {
753         RTE_FLOW_ITEM_TYPE_ETH,
754         RTE_FLOW_ITEM_TYPE_IPV6,
755         RTE_FLOW_ITEM_TYPE_GRE,
756         RTE_FLOW_ITEM_TYPE_IPV6,
757         RTE_FLOW_ITEM_TYPE_UDP,
758         RTE_FLOW_ITEM_TYPE_GTPU,
759         RTE_FLOW_ITEM_TYPE_IPV6,
760         RTE_FLOW_ITEM_TYPE_TCP,
761         RTE_FLOW_ITEM_TYPE_END,
762 };
763
764 enum rte_flow_item_type iavf_pattern_eth_ipv4_gre_ipv4_gtpu_eh[] = {
765         RTE_FLOW_ITEM_TYPE_ETH,
766         RTE_FLOW_ITEM_TYPE_IPV4,
767         RTE_FLOW_ITEM_TYPE_GRE,
768         RTE_FLOW_ITEM_TYPE_IPV4,
769         RTE_FLOW_ITEM_TYPE_UDP,
770         RTE_FLOW_ITEM_TYPE_GTPU,
771         RTE_FLOW_ITEM_TYPE_GTP_PSC,
772         RTE_FLOW_ITEM_TYPE_END,
773 };
774
775 /* IPV4 GRE IPv4 UDP GTPU EH IPv4*/
776 enum rte_flow_item_type iavf_pattern_eth_ipv4_gre_ipv4_gtpu_eh_ipv4[] = {
777         RTE_FLOW_ITEM_TYPE_ETH,
778         RTE_FLOW_ITEM_TYPE_IPV4,
779         RTE_FLOW_ITEM_TYPE_GRE,
780         RTE_FLOW_ITEM_TYPE_IPV4,
781         RTE_FLOW_ITEM_TYPE_UDP,
782         RTE_FLOW_ITEM_TYPE_GTPU,
783         RTE_FLOW_ITEM_TYPE_GTP_PSC,
784         RTE_FLOW_ITEM_TYPE_IPV4,
785         RTE_FLOW_ITEM_TYPE_END,
786 };
787
788 enum rte_flow_item_type iavf_pattern_eth_ipv4_gre_ipv4_gtpu_eh_ipv4_udp[] = {
789         RTE_FLOW_ITEM_TYPE_ETH,
790         RTE_FLOW_ITEM_TYPE_IPV4,
791         RTE_FLOW_ITEM_TYPE_GRE,
792         RTE_FLOW_ITEM_TYPE_IPV4,
793         RTE_FLOW_ITEM_TYPE_UDP,
794         RTE_FLOW_ITEM_TYPE_GTPU,
795         RTE_FLOW_ITEM_TYPE_GTP_PSC,
796         RTE_FLOW_ITEM_TYPE_IPV4,
797         RTE_FLOW_ITEM_TYPE_UDP,
798         RTE_FLOW_ITEM_TYPE_END,
799 };
800
801 enum rte_flow_item_type iavf_pattern_eth_ipv4_gre_ipv4_gtpu_eh_ipv4_tcp[] = {
802         RTE_FLOW_ITEM_TYPE_ETH,
803         RTE_FLOW_ITEM_TYPE_IPV4,
804         RTE_FLOW_ITEM_TYPE_GRE,
805         RTE_FLOW_ITEM_TYPE_IPV4,
806         RTE_FLOW_ITEM_TYPE_UDP,
807         RTE_FLOW_ITEM_TYPE_GTPU,
808         RTE_FLOW_ITEM_TYPE_GTP_PSC,
809         RTE_FLOW_ITEM_TYPE_IPV4,
810         RTE_FLOW_ITEM_TYPE_TCP,
811         RTE_FLOW_ITEM_TYPE_END,
812 };
813
814 /* IPV4 GRE IPv4 UDP GTPU IPv6*/
815 enum rte_flow_item_type iavf_pattern_eth_ipv4_gre_ipv4_gtpu_eh_ipv6[] = {
816         RTE_FLOW_ITEM_TYPE_ETH,
817         RTE_FLOW_ITEM_TYPE_IPV4,
818         RTE_FLOW_ITEM_TYPE_GRE,
819         RTE_FLOW_ITEM_TYPE_IPV4,
820         RTE_FLOW_ITEM_TYPE_UDP,
821         RTE_FLOW_ITEM_TYPE_GTPU,
822         RTE_FLOW_ITEM_TYPE_GTP_PSC,
823         RTE_FLOW_ITEM_TYPE_IPV6,
824         RTE_FLOW_ITEM_TYPE_END,
825 };
826
827 enum rte_flow_item_type iavf_pattern_eth_ipv4_gre_ipv4_gtpu_eh_ipv6_udp[] = {
828         RTE_FLOW_ITEM_TYPE_ETH,
829         RTE_FLOW_ITEM_TYPE_IPV4,
830         RTE_FLOW_ITEM_TYPE_GRE,
831         RTE_FLOW_ITEM_TYPE_IPV4,
832         RTE_FLOW_ITEM_TYPE_UDP,
833         RTE_FLOW_ITEM_TYPE_GTPU,
834         RTE_FLOW_ITEM_TYPE_GTP_PSC,
835         RTE_FLOW_ITEM_TYPE_IPV6,
836         RTE_FLOW_ITEM_TYPE_UDP,
837         RTE_FLOW_ITEM_TYPE_END,
838 };
839
840 enum rte_flow_item_type iavf_pattern_eth_ipv4_gre_ipv4_gtpu_eh_ipv6_tcp[] = {
841         RTE_FLOW_ITEM_TYPE_ETH,
842         RTE_FLOW_ITEM_TYPE_IPV4,
843         RTE_FLOW_ITEM_TYPE_GRE,
844         RTE_FLOW_ITEM_TYPE_IPV4,
845         RTE_FLOW_ITEM_TYPE_UDP,
846         RTE_FLOW_ITEM_TYPE_GTPU,
847         RTE_FLOW_ITEM_TYPE_GTP_PSC,
848         RTE_FLOW_ITEM_TYPE_IPV6,
849         RTE_FLOW_ITEM_TYPE_TCP,
850         RTE_FLOW_ITEM_TYPE_END,
851 };
852
853 enum rte_flow_item_type iavf_pattern_eth_ipv4_gre_ipv6_gtpu_eh[] = {
854         RTE_FLOW_ITEM_TYPE_ETH,
855         RTE_FLOW_ITEM_TYPE_IPV4,
856         RTE_FLOW_ITEM_TYPE_GRE,
857         RTE_FLOW_ITEM_TYPE_IPV6,
858         RTE_FLOW_ITEM_TYPE_UDP,
859         RTE_FLOW_ITEM_TYPE_GTPU,
860         RTE_FLOW_ITEM_TYPE_GTP_PSC,
861         RTE_FLOW_ITEM_TYPE_END,
862 };
863
864 /* IPV4 GRE IPv6 UDP GTPU EH IPv4*/
865 enum rte_flow_item_type iavf_pattern_eth_ipv4_gre_ipv6_gtpu_eh_ipv4[] = {
866         RTE_FLOW_ITEM_TYPE_ETH,
867         RTE_FLOW_ITEM_TYPE_IPV4,
868         RTE_FLOW_ITEM_TYPE_GRE,
869         RTE_FLOW_ITEM_TYPE_IPV6,
870         RTE_FLOW_ITEM_TYPE_UDP,
871         RTE_FLOW_ITEM_TYPE_GTPU,
872         RTE_FLOW_ITEM_TYPE_GTP_PSC,
873         RTE_FLOW_ITEM_TYPE_IPV4,
874         RTE_FLOW_ITEM_TYPE_END,
875 };
876
877 enum rte_flow_item_type iavf_pattern_eth_ipv4_gre_ipv6_gtpu_eh_ipv4_udp[] = {
878         RTE_FLOW_ITEM_TYPE_ETH,
879         RTE_FLOW_ITEM_TYPE_IPV4,
880         RTE_FLOW_ITEM_TYPE_GRE,
881         RTE_FLOW_ITEM_TYPE_IPV6,
882         RTE_FLOW_ITEM_TYPE_UDP,
883         RTE_FLOW_ITEM_TYPE_GTPU,
884         RTE_FLOW_ITEM_TYPE_GTP_PSC,
885         RTE_FLOW_ITEM_TYPE_IPV4,
886         RTE_FLOW_ITEM_TYPE_UDP,
887         RTE_FLOW_ITEM_TYPE_END,
888 };
889
890 enum rte_flow_item_type iavf_pattern_eth_ipv4_gre_ipv6_gtpu_eh_ipv4_tcp[] = {
891         RTE_FLOW_ITEM_TYPE_ETH,
892         RTE_FLOW_ITEM_TYPE_IPV4,
893         RTE_FLOW_ITEM_TYPE_GRE,
894         RTE_FLOW_ITEM_TYPE_IPV6,
895         RTE_FLOW_ITEM_TYPE_UDP,
896         RTE_FLOW_ITEM_TYPE_GTPU,
897         RTE_FLOW_ITEM_TYPE_GTP_PSC,
898         RTE_FLOW_ITEM_TYPE_IPV4,
899         RTE_FLOW_ITEM_TYPE_TCP,
900         RTE_FLOW_ITEM_TYPE_END,
901 };
902
903 /* IPV4 GRE IPv6 UDP GTPU EH IPv6*/
904 enum rte_flow_item_type iavf_pattern_eth_ipv4_gre_ipv6_gtpu_eh_ipv6[] = {
905         RTE_FLOW_ITEM_TYPE_ETH,
906         RTE_FLOW_ITEM_TYPE_IPV4,
907         RTE_FLOW_ITEM_TYPE_GRE,
908         RTE_FLOW_ITEM_TYPE_IPV6,
909         RTE_FLOW_ITEM_TYPE_UDP,
910         RTE_FLOW_ITEM_TYPE_GTPU,
911         RTE_FLOW_ITEM_TYPE_GTP_PSC,
912         RTE_FLOW_ITEM_TYPE_IPV6,
913         RTE_FLOW_ITEM_TYPE_END,
914 };
915
916 enum rte_flow_item_type iavf_pattern_eth_ipv4_gre_ipv6_gtpu_eh_ipv6_udp[] = {
917         RTE_FLOW_ITEM_TYPE_ETH,
918         RTE_FLOW_ITEM_TYPE_IPV4,
919         RTE_FLOW_ITEM_TYPE_GRE,
920         RTE_FLOW_ITEM_TYPE_IPV6,
921         RTE_FLOW_ITEM_TYPE_UDP,
922         RTE_FLOW_ITEM_TYPE_GTPU,
923         RTE_FLOW_ITEM_TYPE_GTP_PSC,
924         RTE_FLOW_ITEM_TYPE_IPV6,
925         RTE_FLOW_ITEM_TYPE_UDP,
926         RTE_FLOW_ITEM_TYPE_END,
927 };
928
929 enum rte_flow_item_type iavf_pattern_eth_ipv4_gre_ipv6_gtpu_eh_ipv6_tcp[] = {
930         RTE_FLOW_ITEM_TYPE_ETH,
931         RTE_FLOW_ITEM_TYPE_IPV4,
932         RTE_FLOW_ITEM_TYPE_GRE,
933         RTE_FLOW_ITEM_TYPE_IPV6,
934         RTE_FLOW_ITEM_TYPE_UDP,
935         RTE_FLOW_ITEM_TYPE_GTPU,
936         RTE_FLOW_ITEM_TYPE_GTP_PSC,
937         RTE_FLOW_ITEM_TYPE_IPV6,
938         RTE_FLOW_ITEM_TYPE_TCP,
939         RTE_FLOW_ITEM_TYPE_END,
940 };
941
942 enum rte_flow_item_type iavf_pattern_eth_ipv6_gre_ipv4_gtpu_eh[] = {
943         RTE_FLOW_ITEM_TYPE_ETH,
944         RTE_FLOW_ITEM_TYPE_IPV6,
945         RTE_FLOW_ITEM_TYPE_GRE,
946         RTE_FLOW_ITEM_TYPE_IPV4,
947         RTE_FLOW_ITEM_TYPE_UDP,
948         RTE_FLOW_ITEM_TYPE_GTPU,
949         RTE_FLOW_ITEM_TYPE_GTP_PSC,
950         RTE_FLOW_ITEM_TYPE_END,
951 };
952
953 /* IPV6 GRE IPv4 UDP GTPU EH IPv4*/
954 enum rte_flow_item_type iavf_pattern_eth_ipv6_gre_ipv4_gtpu_eh_ipv4[] = {
955         RTE_FLOW_ITEM_TYPE_ETH,
956         RTE_FLOW_ITEM_TYPE_IPV6,
957         RTE_FLOW_ITEM_TYPE_GRE,
958         RTE_FLOW_ITEM_TYPE_IPV4,
959         RTE_FLOW_ITEM_TYPE_UDP,
960         RTE_FLOW_ITEM_TYPE_GTPU,
961         RTE_FLOW_ITEM_TYPE_GTP_PSC,
962         RTE_FLOW_ITEM_TYPE_IPV4,
963         RTE_FLOW_ITEM_TYPE_END,
964 };
965
966 enum rte_flow_item_type iavf_pattern_eth_ipv6_gre_ipv4_gtpu_eh_ipv4_udp[] = {
967         RTE_FLOW_ITEM_TYPE_ETH,
968         RTE_FLOW_ITEM_TYPE_IPV6,
969         RTE_FLOW_ITEM_TYPE_GRE,
970         RTE_FLOW_ITEM_TYPE_IPV4,
971         RTE_FLOW_ITEM_TYPE_UDP,
972         RTE_FLOW_ITEM_TYPE_GTPU,
973         RTE_FLOW_ITEM_TYPE_GTP_PSC,
974         RTE_FLOW_ITEM_TYPE_IPV4,
975         RTE_FLOW_ITEM_TYPE_UDP,
976         RTE_FLOW_ITEM_TYPE_END,
977 };
978
979 enum rte_flow_item_type iavf_pattern_eth_ipv6_gre_ipv4_gtpu_eh_ipv4_tcp[] = {
980         RTE_FLOW_ITEM_TYPE_ETH,
981         RTE_FLOW_ITEM_TYPE_IPV6,
982         RTE_FLOW_ITEM_TYPE_GRE,
983         RTE_FLOW_ITEM_TYPE_IPV4,
984         RTE_FLOW_ITEM_TYPE_UDP,
985         RTE_FLOW_ITEM_TYPE_GTPU,
986         RTE_FLOW_ITEM_TYPE_GTP_PSC,
987         RTE_FLOW_ITEM_TYPE_IPV4,
988         RTE_FLOW_ITEM_TYPE_TCP,
989         RTE_FLOW_ITEM_TYPE_END,
990 };
991
992 /* IPV4 GRE IPv4 UDP GTPU EH IPv6*/
993 enum rte_flow_item_type iavf_pattern_eth_ipv6_gre_ipv4_gtpu_eh_ipv6[] = {
994         RTE_FLOW_ITEM_TYPE_ETH,
995         RTE_FLOW_ITEM_TYPE_IPV6,
996         RTE_FLOW_ITEM_TYPE_GRE,
997         RTE_FLOW_ITEM_TYPE_IPV4,
998         RTE_FLOW_ITEM_TYPE_UDP,
999         RTE_FLOW_ITEM_TYPE_GTPU,
1000         RTE_FLOW_ITEM_TYPE_GTP_PSC,
1001         RTE_FLOW_ITEM_TYPE_IPV6,
1002         RTE_FLOW_ITEM_TYPE_END,
1003 };
1004
1005 enum rte_flow_item_type iavf_pattern_eth_ipv6_gre_ipv4_gtpu_eh_ipv6_udp[] = {
1006         RTE_FLOW_ITEM_TYPE_ETH,
1007         RTE_FLOW_ITEM_TYPE_IPV6,
1008         RTE_FLOW_ITEM_TYPE_GRE,
1009         RTE_FLOW_ITEM_TYPE_IPV4,
1010         RTE_FLOW_ITEM_TYPE_UDP,
1011         RTE_FLOW_ITEM_TYPE_GTPU,
1012         RTE_FLOW_ITEM_TYPE_GTP_PSC,
1013         RTE_FLOW_ITEM_TYPE_IPV6,
1014         RTE_FLOW_ITEM_TYPE_UDP,
1015         RTE_FLOW_ITEM_TYPE_END,
1016 };
1017
1018 enum rte_flow_item_type iavf_pattern_eth_ipv6_gre_ipv4_gtpu_eh_ipv6_tcp[] = {
1019         RTE_FLOW_ITEM_TYPE_ETH,
1020         RTE_FLOW_ITEM_TYPE_IPV6,
1021         RTE_FLOW_ITEM_TYPE_GRE,
1022         RTE_FLOW_ITEM_TYPE_IPV4,
1023         RTE_FLOW_ITEM_TYPE_UDP,
1024         RTE_FLOW_ITEM_TYPE_GTPU,
1025         RTE_FLOW_ITEM_TYPE_GTP_PSC,
1026         RTE_FLOW_ITEM_TYPE_IPV6,
1027         RTE_FLOW_ITEM_TYPE_TCP,
1028         RTE_FLOW_ITEM_TYPE_END,
1029 };
1030
1031 enum rte_flow_item_type iavf_pattern_eth_ipv6_gre_ipv6_gtpu_eh[] = {
1032         RTE_FLOW_ITEM_TYPE_ETH,
1033         RTE_FLOW_ITEM_TYPE_IPV6,
1034         RTE_FLOW_ITEM_TYPE_GRE,
1035         RTE_FLOW_ITEM_TYPE_IPV6,
1036         RTE_FLOW_ITEM_TYPE_UDP,
1037         RTE_FLOW_ITEM_TYPE_GTPU,
1038         RTE_FLOW_ITEM_TYPE_GTP_PSC,
1039         RTE_FLOW_ITEM_TYPE_END,
1040 };
1041
1042 /* IPV6 GRE IPv6 UDP GTPU EH IPv4*/
1043 enum rte_flow_item_type iavf_pattern_eth_ipv6_gre_ipv6_gtpu_eh_ipv4[] = {
1044         RTE_FLOW_ITEM_TYPE_ETH,
1045         RTE_FLOW_ITEM_TYPE_IPV6,
1046         RTE_FLOW_ITEM_TYPE_GRE,
1047         RTE_FLOW_ITEM_TYPE_IPV6,
1048         RTE_FLOW_ITEM_TYPE_UDP,
1049         RTE_FLOW_ITEM_TYPE_GTPU,
1050         RTE_FLOW_ITEM_TYPE_GTP_PSC,
1051         RTE_FLOW_ITEM_TYPE_IPV4,
1052         RTE_FLOW_ITEM_TYPE_END,
1053 };
1054
1055 enum rte_flow_item_type iavf_pattern_eth_ipv6_gre_ipv6_gtpu_eh_ipv4_udp[] = {
1056         RTE_FLOW_ITEM_TYPE_ETH,
1057         RTE_FLOW_ITEM_TYPE_IPV6,
1058         RTE_FLOW_ITEM_TYPE_GRE,
1059         RTE_FLOW_ITEM_TYPE_IPV6,
1060         RTE_FLOW_ITEM_TYPE_UDP,
1061         RTE_FLOW_ITEM_TYPE_GTPU,
1062         RTE_FLOW_ITEM_TYPE_GTP_PSC,
1063         RTE_FLOW_ITEM_TYPE_IPV4,
1064         RTE_FLOW_ITEM_TYPE_UDP,
1065         RTE_FLOW_ITEM_TYPE_END,
1066 };
1067
1068 enum rte_flow_item_type iavf_pattern_eth_ipv6_gre_ipv6_gtpu_eh_ipv4_tcp[] = {
1069         RTE_FLOW_ITEM_TYPE_ETH,
1070         RTE_FLOW_ITEM_TYPE_IPV6,
1071         RTE_FLOW_ITEM_TYPE_GRE,
1072         RTE_FLOW_ITEM_TYPE_IPV6,
1073         RTE_FLOW_ITEM_TYPE_UDP,
1074         RTE_FLOW_ITEM_TYPE_GTPU,
1075         RTE_FLOW_ITEM_TYPE_GTP_PSC,
1076         RTE_FLOW_ITEM_TYPE_IPV4,
1077         RTE_FLOW_ITEM_TYPE_TCP,
1078         RTE_FLOW_ITEM_TYPE_END,
1079 };
1080
1081 /* IPV6 GRE IPv6 UDP GTPU EH IPv6*/
1082 enum rte_flow_item_type iavf_pattern_eth_ipv6_gre_ipv6_gtpu_eh_ipv6[] = {
1083         RTE_FLOW_ITEM_TYPE_ETH,
1084         RTE_FLOW_ITEM_TYPE_IPV6,
1085         RTE_FLOW_ITEM_TYPE_GRE,
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_IPV6,
1091         RTE_FLOW_ITEM_TYPE_END,
1092 };
1093
1094 enum rte_flow_item_type iavf_pattern_eth_ipv6_gre_ipv6_gtpu_eh_ipv6_udp[] = {
1095         RTE_FLOW_ITEM_TYPE_ETH,
1096         RTE_FLOW_ITEM_TYPE_IPV6,
1097         RTE_FLOW_ITEM_TYPE_GRE,
1098         RTE_FLOW_ITEM_TYPE_IPV6,
1099         RTE_FLOW_ITEM_TYPE_UDP,
1100         RTE_FLOW_ITEM_TYPE_GTPU,
1101         RTE_FLOW_ITEM_TYPE_GTP_PSC,
1102         RTE_FLOW_ITEM_TYPE_IPV6,
1103         RTE_FLOW_ITEM_TYPE_UDP,
1104         RTE_FLOW_ITEM_TYPE_END,
1105 };
1106
1107 enum rte_flow_item_type iavf_pattern_eth_ipv6_gre_ipv6_gtpu_eh_ipv6_tcp[] = {
1108         RTE_FLOW_ITEM_TYPE_ETH,
1109         RTE_FLOW_ITEM_TYPE_IPV6,
1110         RTE_FLOW_ITEM_TYPE_GRE,
1111         RTE_FLOW_ITEM_TYPE_IPV6,
1112         RTE_FLOW_ITEM_TYPE_UDP,
1113         RTE_FLOW_ITEM_TYPE_GTPU,
1114         RTE_FLOW_ITEM_TYPE_GTP_PSC,
1115         RTE_FLOW_ITEM_TYPE_IPV6,
1116         RTE_FLOW_ITEM_TYPE_TCP,
1117         RTE_FLOW_ITEM_TYPE_END,
1118 };
1119
1120 /* IPV4 GTPU IPv6 */
1121 enum rte_flow_item_type iavf_pattern_eth_ipv4_gtpu_ipv6[] = {
1122         RTE_FLOW_ITEM_TYPE_ETH,
1123         RTE_FLOW_ITEM_TYPE_IPV4,
1124         RTE_FLOW_ITEM_TYPE_UDP,
1125         RTE_FLOW_ITEM_TYPE_GTPU,
1126         RTE_FLOW_ITEM_TYPE_IPV6,
1127         RTE_FLOW_ITEM_TYPE_END,
1128 };
1129
1130 enum rte_flow_item_type iavf_pattern_eth_ipv4_gtpu_ipv6_udp[] = {
1131         RTE_FLOW_ITEM_TYPE_ETH,
1132         RTE_FLOW_ITEM_TYPE_IPV4,
1133         RTE_FLOW_ITEM_TYPE_UDP,
1134         RTE_FLOW_ITEM_TYPE_GTPU,
1135         RTE_FLOW_ITEM_TYPE_IPV6,
1136         RTE_FLOW_ITEM_TYPE_UDP,
1137         RTE_FLOW_ITEM_TYPE_END,
1138 };
1139
1140 enum rte_flow_item_type iavf_pattern_eth_ipv4_gtpu_ipv6_tcp[] = {
1141         RTE_FLOW_ITEM_TYPE_ETH,
1142         RTE_FLOW_ITEM_TYPE_IPV4,
1143         RTE_FLOW_ITEM_TYPE_UDP,
1144         RTE_FLOW_ITEM_TYPE_GTPU,
1145         RTE_FLOW_ITEM_TYPE_IPV6,
1146         RTE_FLOW_ITEM_TYPE_TCP,
1147         RTE_FLOW_ITEM_TYPE_END,
1148 };
1149
1150 enum rte_flow_item_type iavf_pattern_eth_ipv4_gtpu_ipv6_icmp[] = {
1151         RTE_FLOW_ITEM_TYPE_ETH,
1152         RTE_FLOW_ITEM_TYPE_IPV4,
1153         RTE_FLOW_ITEM_TYPE_UDP,
1154         RTE_FLOW_ITEM_TYPE_GTPU,
1155         RTE_FLOW_ITEM_TYPE_IPV6,
1156         RTE_FLOW_ITEM_TYPE_ICMP,
1157         RTE_FLOW_ITEM_TYPE_END,
1158 };
1159
1160 /* IPV6 GTPU IPv4 */
1161 enum rte_flow_item_type iavf_pattern_eth_ipv6_gtpu_ipv4[] = {
1162         RTE_FLOW_ITEM_TYPE_ETH,
1163         RTE_FLOW_ITEM_TYPE_IPV6,
1164         RTE_FLOW_ITEM_TYPE_UDP,
1165         RTE_FLOW_ITEM_TYPE_GTPU,
1166         RTE_FLOW_ITEM_TYPE_IPV4,
1167         RTE_FLOW_ITEM_TYPE_END,
1168 };
1169
1170 enum rte_flow_item_type iavf_pattern_eth_ipv6_gtpu_ipv4_udp[] = {
1171         RTE_FLOW_ITEM_TYPE_ETH,
1172         RTE_FLOW_ITEM_TYPE_IPV6,
1173         RTE_FLOW_ITEM_TYPE_UDP,
1174         RTE_FLOW_ITEM_TYPE_GTPU,
1175         RTE_FLOW_ITEM_TYPE_IPV4,
1176         RTE_FLOW_ITEM_TYPE_UDP,
1177         RTE_FLOW_ITEM_TYPE_END,
1178 };
1179
1180 enum rte_flow_item_type iavf_pattern_eth_ipv6_gtpu_ipv4_tcp[] = {
1181         RTE_FLOW_ITEM_TYPE_ETH,
1182         RTE_FLOW_ITEM_TYPE_IPV6,
1183         RTE_FLOW_ITEM_TYPE_UDP,
1184         RTE_FLOW_ITEM_TYPE_GTPU,
1185         RTE_FLOW_ITEM_TYPE_IPV4,
1186         RTE_FLOW_ITEM_TYPE_TCP,
1187         RTE_FLOW_ITEM_TYPE_END,
1188 };
1189
1190 enum rte_flow_item_type iavf_pattern_eth_ipv6_gtpu_ipv4_icmp[] = {
1191         RTE_FLOW_ITEM_TYPE_ETH,
1192         RTE_FLOW_ITEM_TYPE_IPV6,
1193         RTE_FLOW_ITEM_TYPE_UDP,
1194         RTE_FLOW_ITEM_TYPE_GTPU,
1195         RTE_FLOW_ITEM_TYPE_IPV4,
1196         RTE_FLOW_ITEM_TYPE_ICMP,
1197         RTE_FLOW_ITEM_TYPE_END,
1198 };
1199
1200 /* IPV6 GTPU IPv6 */
1201 enum rte_flow_item_type iavf_pattern_eth_ipv6_gtpu_ipv6[] = {
1202         RTE_FLOW_ITEM_TYPE_ETH,
1203         RTE_FLOW_ITEM_TYPE_IPV6,
1204         RTE_FLOW_ITEM_TYPE_UDP,
1205         RTE_FLOW_ITEM_TYPE_GTPU,
1206         RTE_FLOW_ITEM_TYPE_IPV6,
1207         RTE_FLOW_ITEM_TYPE_END,
1208 };
1209
1210 enum rte_flow_item_type iavf_pattern_eth_ipv6_gtpu_ipv6_udp[] = {
1211         RTE_FLOW_ITEM_TYPE_ETH,
1212         RTE_FLOW_ITEM_TYPE_IPV6,
1213         RTE_FLOW_ITEM_TYPE_UDP,
1214         RTE_FLOW_ITEM_TYPE_GTPU,
1215         RTE_FLOW_ITEM_TYPE_IPV6,
1216         RTE_FLOW_ITEM_TYPE_UDP,
1217         RTE_FLOW_ITEM_TYPE_END,
1218 };
1219
1220 enum rte_flow_item_type iavf_pattern_eth_ipv6_gtpu_ipv6_tcp[] = {
1221         RTE_FLOW_ITEM_TYPE_ETH,
1222         RTE_FLOW_ITEM_TYPE_IPV6,
1223         RTE_FLOW_ITEM_TYPE_UDP,
1224         RTE_FLOW_ITEM_TYPE_GTPU,
1225         RTE_FLOW_ITEM_TYPE_IPV6,
1226         RTE_FLOW_ITEM_TYPE_TCP,
1227         RTE_FLOW_ITEM_TYPE_END,
1228 };
1229
1230 enum rte_flow_item_type iavf_pattern_eth_ipv6_gtpu_ipv6_icmp[] = {
1231         RTE_FLOW_ITEM_TYPE_ETH,
1232         RTE_FLOW_ITEM_TYPE_IPV6,
1233         RTE_FLOW_ITEM_TYPE_UDP,
1234         RTE_FLOW_ITEM_TYPE_GTPU,
1235         RTE_FLOW_ITEM_TYPE_IPV6,
1236         RTE_FLOW_ITEM_TYPE_ICMP,
1237         RTE_FLOW_ITEM_TYPE_END,
1238 };
1239
1240 /* IPV4 GTPU EH IPv4 */
1241 enum rte_flow_item_type iavf_pattern_eth_ipv4_gtpu_eh_ipv4[] = {
1242         RTE_FLOW_ITEM_TYPE_ETH,
1243         RTE_FLOW_ITEM_TYPE_IPV4,
1244         RTE_FLOW_ITEM_TYPE_UDP,
1245         RTE_FLOW_ITEM_TYPE_GTPU,
1246         RTE_FLOW_ITEM_TYPE_GTP_PSC,
1247         RTE_FLOW_ITEM_TYPE_IPV4,
1248         RTE_FLOW_ITEM_TYPE_END,
1249 };
1250
1251 enum rte_flow_item_type iavf_pattern_eth_ipv4_gtpu_eh_ipv4_udp[] = {
1252         RTE_FLOW_ITEM_TYPE_ETH,
1253         RTE_FLOW_ITEM_TYPE_IPV4,
1254         RTE_FLOW_ITEM_TYPE_UDP,
1255         RTE_FLOW_ITEM_TYPE_GTPU,
1256         RTE_FLOW_ITEM_TYPE_GTP_PSC,
1257         RTE_FLOW_ITEM_TYPE_IPV4,
1258         RTE_FLOW_ITEM_TYPE_UDP,
1259         RTE_FLOW_ITEM_TYPE_END,
1260 };
1261
1262 enum rte_flow_item_type iavf_pattern_eth_ipv4_gtpu_eh_ipv4_tcp[] = {
1263         RTE_FLOW_ITEM_TYPE_ETH,
1264         RTE_FLOW_ITEM_TYPE_IPV4,
1265         RTE_FLOW_ITEM_TYPE_UDP,
1266         RTE_FLOW_ITEM_TYPE_GTPU,
1267         RTE_FLOW_ITEM_TYPE_GTP_PSC,
1268         RTE_FLOW_ITEM_TYPE_IPV4,
1269         RTE_FLOW_ITEM_TYPE_TCP,
1270         RTE_FLOW_ITEM_TYPE_END,
1271 };
1272
1273 enum rte_flow_item_type iavf_pattern_eth_ipv4_gtpu_eh_ipv4_icmp[] = {
1274         RTE_FLOW_ITEM_TYPE_ETH,
1275         RTE_FLOW_ITEM_TYPE_IPV4,
1276         RTE_FLOW_ITEM_TYPE_UDP,
1277         RTE_FLOW_ITEM_TYPE_GTPU,
1278         RTE_FLOW_ITEM_TYPE_GTP_PSC,
1279         RTE_FLOW_ITEM_TYPE_IPV4,
1280         RTE_FLOW_ITEM_TYPE_ICMP,
1281         RTE_FLOW_ITEM_TYPE_END,
1282 };
1283
1284 /* IPV4 GTPU EH IPv6 */
1285 enum rte_flow_item_type iavf_pattern_eth_ipv4_gtpu_eh_ipv6[] = {
1286         RTE_FLOW_ITEM_TYPE_ETH,
1287         RTE_FLOW_ITEM_TYPE_IPV4,
1288         RTE_FLOW_ITEM_TYPE_UDP,
1289         RTE_FLOW_ITEM_TYPE_GTPU,
1290         RTE_FLOW_ITEM_TYPE_GTP_PSC,
1291         RTE_FLOW_ITEM_TYPE_IPV6,
1292         RTE_FLOW_ITEM_TYPE_END,
1293 };
1294
1295 enum rte_flow_item_type iavf_pattern_eth_ipv4_gtpu_eh_ipv6_udp[] = {
1296         RTE_FLOW_ITEM_TYPE_ETH,
1297         RTE_FLOW_ITEM_TYPE_IPV4,
1298         RTE_FLOW_ITEM_TYPE_UDP,
1299         RTE_FLOW_ITEM_TYPE_GTPU,
1300         RTE_FLOW_ITEM_TYPE_GTP_PSC,
1301         RTE_FLOW_ITEM_TYPE_IPV6,
1302         RTE_FLOW_ITEM_TYPE_UDP,
1303         RTE_FLOW_ITEM_TYPE_END,
1304 };
1305
1306 enum rte_flow_item_type iavf_pattern_eth_ipv4_gtpu_eh_ipv6_tcp[] = {
1307         RTE_FLOW_ITEM_TYPE_ETH,
1308         RTE_FLOW_ITEM_TYPE_IPV4,
1309         RTE_FLOW_ITEM_TYPE_UDP,
1310         RTE_FLOW_ITEM_TYPE_GTPU,
1311         RTE_FLOW_ITEM_TYPE_GTP_PSC,
1312         RTE_FLOW_ITEM_TYPE_IPV6,
1313         RTE_FLOW_ITEM_TYPE_TCP,
1314         RTE_FLOW_ITEM_TYPE_END,
1315 };
1316
1317 enum rte_flow_item_type iavf_pattern_eth_ipv4_gtpu_eh_ipv6_icmp[] = {
1318         RTE_FLOW_ITEM_TYPE_ETH,
1319         RTE_FLOW_ITEM_TYPE_IPV4,
1320         RTE_FLOW_ITEM_TYPE_UDP,
1321         RTE_FLOW_ITEM_TYPE_GTPU,
1322         RTE_FLOW_ITEM_TYPE_GTP_PSC,
1323         RTE_FLOW_ITEM_TYPE_IPV6,
1324         RTE_FLOW_ITEM_TYPE_ICMP,
1325         RTE_FLOW_ITEM_TYPE_END,
1326 };
1327
1328 /* IPV6 GTPU EH IPv4 */
1329 enum rte_flow_item_type iavf_pattern_eth_ipv6_gtpu_eh_ipv4[] = {
1330         RTE_FLOW_ITEM_TYPE_ETH,
1331         RTE_FLOW_ITEM_TYPE_IPV6,
1332         RTE_FLOW_ITEM_TYPE_UDP,
1333         RTE_FLOW_ITEM_TYPE_GTPU,
1334         RTE_FLOW_ITEM_TYPE_GTP_PSC,
1335         RTE_FLOW_ITEM_TYPE_IPV4,
1336         RTE_FLOW_ITEM_TYPE_END,
1337 };
1338
1339 enum rte_flow_item_type iavf_pattern_eth_ipv6_gtpu_eh_ipv4_udp[] = {
1340         RTE_FLOW_ITEM_TYPE_ETH,
1341         RTE_FLOW_ITEM_TYPE_IPV6,
1342         RTE_FLOW_ITEM_TYPE_UDP,
1343         RTE_FLOW_ITEM_TYPE_GTPU,
1344         RTE_FLOW_ITEM_TYPE_GTP_PSC,
1345         RTE_FLOW_ITEM_TYPE_IPV4,
1346         RTE_FLOW_ITEM_TYPE_UDP,
1347         RTE_FLOW_ITEM_TYPE_END,
1348 };
1349
1350 enum rte_flow_item_type iavf_pattern_eth_ipv6_gtpu_eh_ipv4_tcp[] = {
1351         RTE_FLOW_ITEM_TYPE_ETH,
1352         RTE_FLOW_ITEM_TYPE_IPV6,
1353         RTE_FLOW_ITEM_TYPE_UDP,
1354         RTE_FLOW_ITEM_TYPE_GTPU,
1355         RTE_FLOW_ITEM_TYPE_GTP_PSC,
1356         RTE_FLOW_ITEM_TYPE_IPV4,
1357         RTE_FLOW_ITEM_TYPE_TCP,
1358         RTE_FLOW_ITEM_TYPE_END,
1359 };
1360
1361 enum rte_flow_item_type iavf_pattern_eth_ipv6_gtpu_eh_ipv4_icmp[] = {
1362         RTE_FLOW_ITEM_TYPE_ETH,
1363         RTE_FLOW_ITEM_TYPE_IPV6,
1364         RTE_FLOW_ITEM_TYPE_UDP,
1365         RTE_FLOW_ITEM_TYPE_GTPU,
1366         RTE_FLOW_ITEM_TYPE_GTP_PSC,
1367         RTE_FLOW_ITEM_TYPE_IPV4,
1368         RTE_FLOW_ITEM_TYPE_ICMP,
1369         RTE_FLOW_ITEM_TYPE_END,
1370 };
1371
1372 /* IPV6 GTPU EH IPv6 */
1373 enum rte_flow_item_type iavf_pattern_eth_ipv6_gtpu_eh_ipv6[] = {
1374         RTE_FLOW_ITEM_TYPE_ETH,
1375         RTE_FLOW_ITEM_TYPE_IPV6,
1376         RTE_FLOW_ITEM_TYPE_UDP,
1377         RTE_FLOW_ITEM_TYPE_GTPU,
1378         RTE_FLOW_ITEM_TYPE_GTP_PSC,
1379         RTE_FLOW_ITEM_TYPE_IPV6,
1380         RTE_FLOW_ITEM_TYPE_END,
1381 };
1382
1383 enum rte_flow_item_type iavf_pattern_eth_ipv6_gtpu_eh_ipv6_udp[] = {
1384         RTE_FLOW_ITEM_TYPE_ETH,
1385         RTE_FLOW_ITEM_TYPE_IPV6,
1386         RTE_FLOW_ITEM_TYPE_UDP,
1387         RTE_FLOW_ITEM_TYPE_GTPU,
1388         RTE_FLOW_ITEM_TYPE_GTP_PSC,
1389         RTE_FLOW_ITEM_TYPE_IPV6,
1390         RTE_FLOW_ITEM_TYPE_UDP,
1391         RTE_FLOW_ITEM_TYPE_END,
1392 };
1393
1394 enum rte_flow_item_type iavf_pattern_eth_ipv6_gtpu_eh_ipv6_tcp[] = {
1395         RTE_FLOW_ITEM_TYPE_ETH,
1396         RTE_FLOW_ITEM_TYPE_IPV6,
1397         RTE_FLOW_ITEM_TYPE_UDP,
1398         RTE_FLOW_ITEM_TYPE_GTPU,
1399         RTE_FLOW_ITEM_TYPE_GTP_PSC,
1400         RTE_FLOW_ITEM_TYPE_IPV6,
1401         RTE_FLOW_ITEM_TYPE_TCP,
1402         RTE_FLOW_ITEM_TYPE_END,
1403 };
1404
1405 enum rte_flow_item_type iavf_pattern_eth_ipv6_gtpu_eh_ipv6_icmp[] = {
1406         RTE_FLOW_ITEM_TYPE_ETH,
1407         RTE_FLOW_ITEM_TYPE_IPV6,
1408         RTE_FLOW_ITEM_TYPE_UDP,
1409         RTE_FLOW_ITEM_TYPE_GTPU,
1410         RTE_FLOW_ITEM_TYPE_GTP_PSC,
1411         RTE_FLOW_ITEM_TYPE_IPV6,
1412         RTE_FLOW_ITEM_TYPE_ICMP,
1413         RTE_FLOW_ITEM_TYPE_END,
1414 };
1415
1416 /* ESP */
1417 enum rte_flow_item_type iavf_pattern_eth_ipv4_esp[] = {
1418         RTE_FLOW_ITEM_TYPE_ETH,
1419         RTE_FLOW_ITEM_TYPE_IPV4,
1420         RTE_FLOW_ITEM_TYPE_ESP,
1421         RTE_FLOW_ITEM_TYPE_END,
1422 };
1423
1424 enum rte_flow_item_type iavf_pattern_eth_ipv4_udp_esp[] = {
1425         RTE_FLOW_ITEM_TYPE_ETH,
1426         RTE_FLOW_ITEM_TYPE_IPV4,
1427         RTE_FLOW_ITEM_TYPE_UDP,
1428         RTE_FLOW_ITEM_TYPE_ESP,
1429         RTE_FLOW_ITEM_TYPE_END,
1430 };
1431
1432 enum rte_flow_item_type iavf_pattern_eth_ipv6_esp[] = {
1433         RTE_FLOW_ITEM_TYPE_ETH,
1434         RTE_FLOW_ITEM_TYPE_IPV6,
1435         RTE_FLOW_ITEM_TYPE_ESP,
1436         RTE_FLOW_ITEM_TYPE_END,
1437 };
1438
1439 enum rte_flow_item_type iavf_pattern_eth_ipv6_udp_esp[] = {
1440         RTE_FLOW_ITEM_TYPE_ETH,
1441         RTE_FLOW_ITEM_TYPE_IPV6,
1442         RTE_FLOW_ITEM_TYPE_UDP,
1443         RTE_FLOW_ITEM_TYPE_ESP,
1444         RTE_FLOW_ITEM_TYPE_END,
1445 };
1446
1447 /* AH */
1448 enum rte_flow_item_type iavf_pattern_eth_ipv4_ah[] = {
1449         RTE_FLOW_ITEM_TYPE_ETH,
1450         RTE_FLOW_ITEM_TYPE_IPV4,
1451         RTE_FLOW_ITEM_TYPE_AH,
1452         RTE_FLOW_ITEM_TYPE_END,
1453 };
1454
1455 enum rte_flow_item_type iavf_pattern_eth_ipv6_ah[] = {
1456         RTE_FLOW_ITEM_TYPE_ETH,
1457         RTE_FLOW_ITEM_TYPE_IPV6,
1458         RTE_FLOW_ITEM_TYPE_AH,
1459         RTE_FLOW_ITEM_TYPE_END,
1460 };
1461
1462 /* L2TPV3 */
1463 enum rte_flow_item_type iavf_pattern_eth_ipv4_l2tpv3[] = {
1464         RTE_FLOW_ITEM_TYPE_ETH,
1465         RTE_FLOW_ITEM_TYPE_IPV4,
1466         RTE_FLOW_ITEM_TYPE_L2TPV3OIP,
1467         RTE_FLOW_ITEM_TYPE_END,
1468 };
1469
1470 enum rte_flow_item_type iavf_pattern_eth_ipv6_l2tpv3[] = {
1471         RTE_FLOW_ITEM_TYPE_ETH,
1472         RTE_FLOW_ITEM_TYPE_IPV6,
1473         RTE_FLOW_ITEM_TYPE_L2TPV3OIP,
1474         RTE_FLOW_ITEM_TYPE_END,
1475 };
1476
1477 /* PFCP */
1478 enum rte_flow_item_type iavf_pattern_eth_ipv4_pfcp[] = {
1479         RTE_FLOW_ITEM_TYPE_ETH,
1480         RTE_FLOW_ITEM_TYPE_IPV4,
1481         RTE_FLOW_ITEM_TYPE_UDP,
1482         RTE_FLOW_ITEM_TYPE_PFCP,
1483         RTE_FLOW_ITEM_TYPE_END,
1484 };
1485
1486 enum rte_flow_item_type iavf_pattern_eth_ipv6_pfcp[] = {
1487         RTE_FLOW_ITEM_TYPE_ETH,
1488         RTE_FLOW_ITEM_TYPE_IPV6,
1489         RTE_FLOW_ITEM_TYPE_UDP,
1490         RTE_FLOW_ITEM_TYPE_PFCP,
1491         RTE_FLOW_ITEM_TYPE_END,
1492 };
1493
1494 /* ECPRI */
1495 enum rte_flow_item_type iavf_pattern_eth_ecpri[] = {
1496         RTE_FLOW_ITEM_TYPE_ETH,
1497         RTE_FLOW_ITEM_TYPE_ECPRI,
1498         RTE_FLOW_ITEM_TYPE_END,
1499 };
1500
1501 enum rte_flow_item_type iavf_pattern_eth_ipv4_ecpri[] = {
1502         RTE_FLOW_ITEM_TYPE_ETH,
1503         RTE_FLOW_ITEM_TYPE_IPV4,
1504         RTE_FLOW_ITEM_TYPE_UDP,
1505         RTE_FLOW_ITEM_TYPE_ECPRI,
1506         RTE_FLOW_ITEM_TYPE_END,
1507 };
1508
1509 /* GRE */
1510 enum rte_flow_item_type iavf_pattern_eth_ipv4_gre_ipv4[] = {
1511         RTE_FLOW_ITEM_TYPE_ETH,
1512         RTE_FLOW_ITEM_TYPE_IPV4,
1513         RTE_FLOW_ITEM_TYPE_GRE,
1514         RTE_FLOW_ITEM_TYPE_IPV4,
1515         RTE_FLOW_ITEM_TYPE_END,
1516 };
1517
1518 enum rte_flow_item_type iavf_pattern_eth_ipv4_gre_ipv6[] = {
1519         RTE_FLOW_ITEM_TYPE_ETH,
1520         RTE_FLOW_ITEM_TYPE_IPV4,
1521         RTE_FLOW_ITEM_TYPE_GRE,
1522         RTE_FLOW_ITEM_TYPE_IPV6,
1523         RTE_FLOW_ITEM_TYPE_END,
1524 };
1525
1526 enum rte_flow_item_type iavf_pattern_eth_ipv6_gre_ipv4[] = {
1527         RTE_FLOW_ITEM_TYPE_ETH,
1528         RTE_FLOW_ITEM_TYPE_IPV6,
1529         RTE_FLOW_ITEM_TYPE_GRE,
1530         RTE_FLOW_ITEM_TYPE_IPV4,
1531         RTE_FLOW_ITEM_TYPE_END,
1532 };
1533
1534 enum rte_flow_item_type iavf_pattern_eth_ipv6_gre_ipv6[] = {
1535         RTE_FLOW_ITEM_TYPE_ETH,
1536         RTE_FLOW_ITEM_TYPE_IPV6,
1537         RTE_FLOW_ITEM_TYPE_GRE,
1538         RTE_FLOW_ITEM_TYPE_IPV6,
1539         RTE_FLOW_ITEM_TYPE_END,
1540 };
1541
1542 enum rte_flow_item_type iavf_pattern_eth_ipv4_gre_ipv4_tcp[] = {
1543         RTE_FLOW_ITEM_TYPE_ETH,
1544         RTE_FLOW_ITEM_TYPE_IPV4,
1545         RTE_FLOW_ITEM_TYPE_GRE,
1546         RTE_FLOW_ITEM_TYPE_IPV4,
1547         RTE_FLOW_ITEM_TYPE_TCP,
1548         RTE_FLOW_ITEM_TYPE_END,
1549 };
1550
1551 enum rte_flow_item_type iavf_pattern_eth_ipv4_gre_ipv4_udp[] = {
1552         RTE_FLOW_ITEM_TYPE_ETH,
1553         RTE_FLOW_ITEM_TYPE_IPV4,
1554         RTE_FLOW_ITEM_TYPE_GRE,
1555         RTE_FLOW_ITEM_TYPE_IPV4,
1556         RTE_FLOW_ITEM_TYPE_UDP,
1557         RTE_FLOW_ITEM_TYPE_END,
1558 };
1559
1560 enum rte_flow_item_type iavf_pattern_eth_ipv4_gre_ipv6_tcp[] = {
1561         RTE_FLOW_ITEM_TYPE_ETH,
1562         RTE_FLOW_ITEM_TYPE_IPV4,
1563         RTE_FLOW_ITEM_TYPE_GRE,
1564         RTE_FLOW_ITEM_TYPE_IPV6,
1565         RTE_FLOW_ITEM_TYPE_TCP,
1566         RTE_FLOW_ITEM_TYPE_END,
1567 };
1568
1569 enum rte_flow_item_type iavf_pattern_eth_ipv4_gre_ipv6_udp[] = {
1570         RTE_FLOW_ITEM_TYPE_ETH,
1571         RTE_FLOW_ITEM_TYPE_IPV4,
1572         RTE_FLOW_ITEM_TYPE_GRE,
1573         RTE_FLOW_ITEM_TYPE_IPV6,
1574         RTE_FLOW_ITEM_TYPE_UDP,
1575         RTE_FLOW_ITEM_TYPE_END,
1576 };
1577
1578 enum rte_flow_item_type iavf_pattern_eth_ipv6_gre_ipv4_tcp[] = {
1579         RTE_FLOW_ITEM_TYPE_ETH,
1580         RTE_FLOW_ITEM_TYPE_IPV6,
1581         RTE_FLOW_ITEM_TYPE_GRE,
1582         RTE_FLOW_ITEM_TYPE_IPV4,
1583         RTE_FLOW_ITEM_TYPE_TCP,
1584         RTE_FLOW_ITEM_TYPE_END,
1585 };
1586
1587 enum rte_flow_item_type iavf_pattern_eth_ipv6_gre_ipv4_udp[] = {
1588         RTE_FLOW_ITEM_TYPE_ETH,
1589         RTE_FLOW_ITEM_TYPE_IPV6,
1590         RTE_FLOW_ITEM_TYPE_GRE,
1591         RTE_FLOW_ITEM_TYPE_IPV4,
1592         RTE_FLOW_ITEM_TYPE_UDP,
1593         RTE_FLOW_ITEM_TYPE_END,
1594 };
1595
1596 enum rte_flow_item_type iavf_pattern_eth_ipv6_gre_ipv6_tcp[] = {
1597         RTE_FLOW_ITEM_TYPE_ETH,
1598         RTE_FLOW_ITEM_TYPE_IPV6,
1599         RTE_FLOW_ITEM_TYPE_GRE,
1600         RTE_FLOW_ITEM_TYPE_IPV6,
1601         RTE_FLOW_ITEM_TYPE_TCP,
1602         RTE_FLOW_ITEM_TYPE_END,
1603 };
1604
1605 enum rte_flow_item_type iavf_pattern_eth_ipv6_gre_ipv6_udp[] = {
1606         RTE_FLOW_ITEM_TYPE_ETH,
1607         RTE_FLOW_ITEM_TYPE_IPV6,
1608         RTE_FLOW_ITEM_TYPE_GRE,
1609         RTE_FLOW_ITEM_TYPE_IPV6,
1610         RTE_FLOW_ITEM_TYPE_UDP,
1611         RTE_FLOW_ITEM_TYPE_END,
1612 };
1613
1614 typedef struct iavf_flow_engine * (*parse_engine_t)(struct iavf_adapter *ad,
1615                 struct rte_flow *flow,
1616                 struct iavf_parser_list *parser_list,
1617                 const struct rte_flow_item pattern[],
1618                 const struct rte_flow_action actions[],
1619                 struct rte_flow_error *error);
1620
1621 void
1622 iavf_register_flow_engine(struct iavf_flow_engine *engine)
1623 {
1624         TAILQ_INSERT_TAIL(&engine_list, engine, node);
1625 }
1626
1627 int
1628 iavf_flow_init(struct iavf_adapter *ad)
1629 {
1630         int ret;
1631         struct iavf_info *vf = IAVF_DEV_PRIVATE_TO_VF(ad);
1632         void *temp;
1633         struct iavf_flow_engine *engine;
1634
1635         TAILQ_INIT(&vf->flow_list);
1636         TAILQ_INIT(&vf->rss_parser_list);
1637         TAILQ_INIT(&vf->dist_parser_list);
1638         rte_spinlock_init(&vf->flow_ops_lock);
1639
1640         RTE_TAILQ_FOREACH_SAFE(engine, &engine_list, node, temp) {
1641                 if (engine->init == NULL) {
1642                         PMD_INIT_LOG(ERR, "Invalid engine type (%d)",
1643                                      engine->type);
1644                         return -ENOTSUP;
1645                 }
1646
1647                 ret = engine->init(ad);
1648                 if (ret && ret != -ENOTSUP) {
1649                         PMD_INIT_LOG(ERR, "Failed to initialize engine %d",
1650                                      engine->type);
1651                         return ret;
1652                 }
1653         }
1654         return 0;
1655 }
1656
1657 void
1658 iavf_flow_uninit(struct iavf_adapter *ad)
1659 {
1660         struct iavf_info *vf = IAVF_DEV_PRIVATE_TO_VF(ad);
1661         struct iavf_flow_engine *engine;
1662         struct rte_flow *p_flow;
1663         struct iavf_flow_parser_node *p_parser;
1664         void *temp;
1665
1666         RTE_TAILQ_FOREACH_SAFE(engine, &engine_list, node, temp) {
1667                 if (engine->uninit)
1668                         engine->uninit(ad);
1669         }
1670
1671         /* Remove all flows */
1672         while ((p_flow = TAILQ_FIRST(&vf->flow_list))) {
1673                 TAILQ_REMOVE(&vf->flow_list, p_flow, node);
1674                 if (p_flow->engine->free)
1675                         p_flow->engine->free(p_flow);
1676                 rte_free(p_flow);
1677         }
1678
1679         /* Cleanup parser list */
1680         while ((p_parser = TAILQ_FIRST(&vf->rss_parser_list))) {
1681                 TAILQ_REMOVE(&vf->rss_parser_list, p_parser, node);
1682                 rte_free(p_parser);
1683         }
1684
1685         while ((p_parser = TAILQ_FIRST(&vf->dist_parser_list))) {
1686                 TAILQ_REMOVE(&vf->dist_parser_list, p_parser, node);
1687                 rte_free(p_parser);
1688         }
1689 }
1690
1691 int
1692 iavf_register_parser(struct iavf_flow_parser *parser,
1693                      struct iavf_adapter *ad)
1694 {
1695         struct iavf_parser_list *list = NULL;
1696         struct iavf_flow_parser_node *parser_node;
1697         struct iavf_info *vf = IAVF_DEV_PRIVATE_TO_VF(ad);
1698
1699         parser_node = rte_zmalloc("iavf_parser", sizeof(*parser_node), 0);
1700         if (parser_node == NULL) {
1701                 PMD_DRV_LOG(ERR, "Failed to allocate memory.");
1702                 return -ENOMEM;
1703         }
1704         parser_node->parser = parser;
1705
1706         if (parser->engine->type == IAVF_FLOW_ENGINE_HASH) {
1707                 list = &vf->rss_parser_list;
1708                 TAILQ_INSERT_TAIL(list, parser_node, node);
1709         } else if (parser->engine->type == IAVF_FLOW_ENGINE_FDIR) {
1710                 list = &vf->dist_parser_list;
1711                 TAILQ_INSERT_HEAD(list, parser_node, node);
1712         } else {
1713                 return -EINVAL;
1714         }
1715
1716         return 0;
1717 }
1718
1719 void
1720 iavf_unregister_parser(struct iavf_flow_parser *parser,
1721                        struct iavf_adapter *ad)
1722 {
1723         struct iavf_parser_list *list = NULL;
1724         struct iavf_flow_parser_node *p_parser;
1725         struct iavf_info *vf = IAVF_DEV_PRIVATE_TO_VF(ad);
1726         void *temp;
1727
1728         if (parser->engine->type == IAVF_FLOW_ENGINE_HASH)
1729                 list = &vf->rss_parser_list;
1730         else if (parser->engine->type == IAVF_FLOW_ENGINE_FDIR)
1731                 list = &vf->dist_parser_list;
1732
1733         if (list == NULL)
1734                 return;
1735
1736         RTE_TAILQ_FOREACH_SAFE(p_parser, list, node, temp) {
1737                 if (p_parser->parser->engine->type == parser->engine->type) {
1738                         TAILQ_REMOVE(list, p_parser, node);
1739                         rte_free(p_parser);
1740                 }
1741         }
1742 }
1743
1744 static int
1745 iavf_flow_valid_attr(const struct rte_flow_attr *attr,
1746                      struct rte_flow_error *error)
1747 {
1748         /* Must be input direction */
1749         if (!attr->ingress) {
1750                 rte_flow_error_set(error, EINVAL,
1751                                 RTE_FLOW_ERROR_TYPE_ATTR_INGRESS,
1752                                 attr, "Only support ingress.");
1753                 return -rte_errno;
1754         }
1755
1756         /* Not supported */
1757         if (attr->egress) {
1758                 rte_flow_error_set(error, EINVAL,
1759                                 RTE_FLOW_ERROR_TYPE_ATTR_EGRESS,
1760                                 attr, "Not support egress.");
1761                 return -rte_errno;
1762         }
1763
1764         /* Not supported */
1765         if (attr->priority) {
1766                 rte_flow_error_set(error, EINVAL,
1767                                 RTE_FLOW_ERROR_TYPE_ATTR_PRIORITY,
1768                                 attr, "Not support priority.");
1769                 return -rte_errno;
1770         }
1771
1772         /* Not supported */
1773         if (attr->group) {
1774                 rte_flow_error_set(error, EINVAL,
1775                                 RTE_FLOW_ERROR_TYPE_ATTR_GROUP,
1776                                 attr, "Not support group.");
1777                 return -rte_errno;
1778         }
1779
1780         return 0;
1781 }
1782
1783 /* Find the first VOID or non-VOID item pointer */
1784 static const struct rte_flow_item *
1785 iavf_find_first_item(const struct rte_flow_item *item, bool is_void)
1786 {
1787         bool is_find;
1788
1789         while (item->type != RTE_FLOW_ITEM_TYPE_END) {
1790                 if (is_void)
1791                         is_find = item->type == RTE_FLOW_ITEM_TYPE_VOID;
1792                 else
1793                         is_find = item->type != RTE_FLOW_ITEM_TYPE_VOID;
1794                 if (is_find)
1795                         break;
1796                 item++;
1797         }
1798         return item;
1799 }
1800
1801 /* Skip all VOID items of the pattern */
1802 static void
1803 iavf_pattern_skip_void_item(struct rte_flow_item *items,
1804                         const struct rte_flow_item *pattern)
1805 {
1806         uint32_t cpy_count = 0;
1807         const struct rte_flow_item *pb = pattern, *pe = pattern;
1808
1809         for (;;) {
1810                 /* Find a non-void item first */
1811                 pb = iavf_find_first_item(pb, false);
1812                 if (pb->type == RTE_FLOW_ITEM_TYPE_END) {
1813                         pe = pb;
1814                         break;
1815                 }
1816
1817                 /* Find a void item */
1818                 pe = iavf_find_first_item(pb + 1, true);
1819
1820                 cpy_count = pe - pb;
1821                 rte_memcpy(items, pb, sizeof(struct rte_flow_item) * cpy_count);
1822
1823                 items += cpy_count;
1824
1825                 if (pe->type == RTE_FLOW_ITEM_TYPE_END)
1826                         break;
1827
1828                 pb = pe + 1;
1829         }
1830         /* Copy the END item. */
1831         rte_memcpy(items, pe, sizeof(struct rte_flow_item));
1832 }
1833
1834 /* Check if the pattern matches a supported item type array */
1835 static bool
1836 iavf_match_pattern(enum rte_flow_item_type *item_array,
1837                    const struct rte_flow_item *pattern)
1838 {
1839         const struct rte_flow_item *item = pattern;
1840
1841         while ((*item_array == item->type) &&
1842                (*item_array != RTE_FLOW_ITEM_TYPE_END)) {
1843                 item_array++;
1844                 item++;
1845         }
1846
1847         return (*item_array == RTE_FLOW_ITEM_TYPE_END &&
1848                 item->type == RTE_FLOW_ITEM_TYPE_END);
1849 }
1850
1851 struct iavf_pattern_match_item *
1852 iavf_search_pattern_match_item(const struct rte_flow_item pattern[],
1853                 struct iavf_pattern_match_item *array,
1854                 uint32_t array_len,
1855                 struct rte_flow_error *error)
1856 {
1857         uint16_t i = 0;
1858         struct iavf_pattern_match_item *pattern_match_item;
1859         /* need free by each filter */
1860         struct rte_flow_item *items; /* used for pattern without VOID items */
1861         uint32_t item_num = 0; /* non-void item number */
1862
1863         /* Get the non-void item number of pattern */
1864         while ((pattern + i)->type != RTE_FLOW_ITEM_TYPE_END) {
1865                 if ((pattern + i)->type != RTE_FLOW_ITEM_TYPE_VOID)
1866                         item_num++;
1867                 i++;
1868         }
1869         item_num++;
1870
1871         items = rte_zmalloc("iavf_pattern",
1872                             item_num * sizeof(struct rte_flow_item), 0);
1873         if (!items) {
1874                 rte_flow_error_set(error, ENOMEM, RTE_FLOW_ERROR_TYPE_ITEM_NUM,
1875                                    NULL, "No memory for PMD internal items.");
1876                 return NULL;
1877         }
1878         pattern_match_item = rte_zmalloc("iavf_pattern_match_item",
1879                                 sizeof(struct iavf_pattern_match_item), 0);
1880         if (!pattern_match_item) {
1881                 rte_flow_error_set(error, ENOMEM, RTE_FLOW_ERROR_TYPE_HANDLE,
1882                                    NULL, "Failed to allocate memory.");
1883                 return NULL;
1884         }
1885
1886         iavf_pattern_skip_void_item(items, pattern);
1887
1888         for (i = 0; i < array_len; i++)
1889                 if (iavf_match_pattern(array[i].pattern_list,
1890                                        items)) {
1891                         pattern_match_item->input_set_mask =
1892                                 array[i].input_set_mask;
1893                         pattern_match_item->pattern_list =
1894                                 array[i].pattern_list;
1895                         pattern_match_item->meta = array[i].meta;
1896                         rte_free(items);
1897                         return pattern_match_item;
1898                 }
1899         rte_flow_error_set(error, EINVAL, RTE_FLOW_ERROR_TYPE_ITEM,
1900                            pattern, "Unsupported pattern");
1901
1902         rte_free(items);
1903         rte_free(pattern_match_item);
1904         return NULL;
1905 }
1906
1907 static struct iavf_flow_engine *
1908 iavf_parse_engine_create(struct iavf_adapter *ad,
1909                 struct rte_flow *flow,
1910                 struct iavf_parser_list *parser_list,
1911                 const struct rte_flow_item pattern[],
1912                 const struct rte_flow_action actions[],
1913                 struct rte_flow_error *error)
1914 {
1915         struct iavf_flow_engine *engine = NULL;
1916         struct iavf_flow_parser_node *parser_node;
1917         void *temp;
1918         void *meta = NULL;
1919
1920         RTE_TAILQ_FOREACH_SAFE(parser_node, parser_list, node, temp) {
1921                 if (parser_node->parser->parse_pattern_action(ad,
1922                                 parser_node->parser->array,
1923                                 parser_node->parser->array_len,
1924                                 pattern, actions, &meta, error) < 0)
1925                         continue;
1926
1927                 engine = parser_node->parser->engine;
1928
1929                 RTE_ASSERT(engine->create != NULL);
1930                 if (!(engine->create(ad, flow, meta, error)))
1931                         return engine;
1932         }
1933         return NULL;
1934 }
1935
1936 static struct iavf_flow_engine *
1937 iavf_parse_engine_validate(struct iavf_adapter *ad,
1938                 struct rte_flow *flow,
1939                 struct iavf_parser_list *parser_list,
1940                 const struct rte_flow_item pattern[],
1941                 const struct rte_flow_action actions[],
1942                 struct rte_flow_error *error)
1943 {
1944         struct iavf_flow_engine *engine = NULL;
1945         struct iavf_flow_parser_node *parser_node;
1946         void *temp;
1947         void *meta = NULL;
1948
1949         RTE_TAILQ_FOREACH_SAFE(parser_node, parser_list, node, temp) {
1950                 if (parser_node->parser->parse_pattern_action(ad,
1951                                 parser_node->parser->array,
1952                                 parser_node->parser->array_len,
1953                                 pattern, actions, &meta,  error) < 0)
1954                         continue;
1955
1956                 engine = parser_node->parser->engine;
1957                 if (engine->validation == NULL) {
1958                         rte_flow_error_set(error, EINVAL,
1959                                 RTE_FLOW_ERROR_TYPE_HANDLE,
1960                                 NULL, "Validation not support");
1961                         continue;
1962                 }
1963
1964                 if (engine->validation(ad, flow, meta, error)) {
1965                         rte_flow_error_set(error, EINVAL,
1966                                 RTE_FLOW_ERROR_TYPE_HANDLE,
1967                                 NULL, "Validation failed");
1968                         break;
1969                 }
1970         }
1971         return engine;
1972 }
1973
1974
1975 static int
1976 iavf_flow_process_filter(struct rte_eth_dev *dev,
1977                 struct rte_flow *flow,
1978                 const struct rte_flow_attr *attr,
1979                 const struct rte_flow_item pattern[],
1980                 const struct rte_flow_action actions[],
1981                 struct iavf_flow_engine **engine,
1982                 parse_engine_t iavf_parse_engine,
1983                 struct rte_flow_error *error)
1984 {
1985         int ret = IAVF_ERR_CONFIG;
1986         struct iavf_adapter *ad =
1987                 IAVF_DEV_PRIVATE_TO_ADAPTER(dev->data->dev_private);
1988         struct iavf_info *vf = IAVF_DEV_PRIVATE_TO_VF(ad);
1989
1990         if (!pattern) {
1991                 rte_flow_error_set(error, EINVAL, RTE_FLOW_ERROR_TYPE_ITEM_NUM,
1992                                    NULL, "NULL pattern.");
1993                 return -rte_errno;
1994         }
1995
1996         if (!actions) {
1997                 rte_flow_error_set(error, EINVAL,
1998                                    RTE_FLOW_ERROR_TYPE_ACTION_NUM,
1999                                    NULL, "NULL action.");
2000                 return -rte_errno;
2001         }
2002
2003         if (!attr) {
2004                 rte_flow_error_set(error, EINVAL,
2005                                    RTE_FLOW_ERROR_TYPE_ATTR,
2006                                    NULL, "NULL attribute.");
2007                 return -rte_errno;
2008         }
2009
2010         ret = iavf_flow_valid_attr(attr, error);
2011         if (ret)
2012                 return ret;
2013
2014         *engine = iavf_parse_engine(ad, flow, &vf->rss_parser_list, pattern,
2015                                     actions, error);
2016         if (*engine)
2017                 return 0;
2018
2019         *engine = iavf_parse_engine(ad, flow, &vf->dist_parser_list, pattern,
2020                                     actions, error);
2021
2022         if (!*engine) {
2023                 rte_flow_error_set(error, EINVAL,
2024                                    RTE_FLOW_ERROR_TYPE_HANDLE, NULL,
2025                                    "Failed to create parser engine.");
2026                 return -rte_errno;
2027         }
2028
2029         return 0;
2030 }
2031
2032 static int
2033 iavf_flow_validate(struct rte_eth_dev *dev,
2034                 const struct rte_flow_attr *attr,
2035                 const struct rte_flow_item pattern[],
2036                 const struct rte_flow_action actions[],
2037                 struct rte_flow_error *error)
2038 {
2039         struct iavf_flow_engine *engine;
2040
2041         return iavf_flow_process_filter(dev, NULL, attr, pattern, actions,
2042                         &engine, iavf_parse_engine_validate, error);
2043 }
2044
2045 static struct rte_flow *
2046 iavf_flow_create(struct rte_eth_dev *dev,
2047                  const struct rte_flow_attr *attr,
2048                  const struct rte_flow_item pattern[],
2049                  const struct rte_flow_action actions[],
2050                  struct rte_flow_error *error)
2051 {
2052         struct iavf_adapter *ad =
2053                 IAVF_DEV_PRIVATE_TO_ADAPTER(dev->data->dev_private);
2054         struct iavf_info *vf = IAVF_DEV_PRIVATE_TO_VF(ad);
2055         struct iavf_flow_engine *engine = NULL;
2056         struct rte_flow *flow = NULL;
2057         int ret;
2058
2059         flow = rte_zmalloc("iavf_flow", sizeof(struct rte_flow), 0);
2060         if (!flow) {
2061                 rte_flow_error_set(error, ENOMEM,
2062                                    RTE_FLOW_ERROR_TYPE_HANDLE, NULL,
2063                                    "Failed to allocate memory");
2064                 return flow;
2065         }
2066
2067         ret = iavf_flow_process_filter(dev, flow, attr, pattern, actions,
2068                         &engine, iavf_parse_engine_create, error);
2069         if (ret < 0) {
2070                 PMD_DRV_LOG(ERR, "Failed to create flow");
2071                 rte_free(flow);
2072                 flow = NULL;
2073                 goto free_flow;
2074         }
2075
2076         flow->engine = engine;
2077         TAILQ_INSERT_TAIL(&vf->flow_list, flow, node);
2078         PMD_DRV_LOG(INFO, "Succeeded to create (%d) flow", engine->type);
2079
2080 free_flow:
2081         rte_spinlock_unlock(&vf->flow_ops_lock);
2082         return flow;
2083 }
2084
2085 static bool
2086 iavf_flow_is_valid(struct rte_flow *flow)
2087 {
2088         struct iavf_flow_engine *engine;
2089         void *temp;
2090
2091         if (flow && flow->engine) {
2092                 RTE_TAILQ_FOREACH_SAFE(engine, &engine_list, node, temp) {
2093                         if (engine == flow->engine)
2094                                 return true;
2095                 }
2096         }
2097
2098         return false;
2099 }
2100
2101 static int
2102 iavf_flow_destroy(struct rte_eth_dev *dev,
2103                   struct rte_flow *flow,
2104                   struct rte_flow_error *error)
2105 {
2106         struct iavf_adapter *ad =
2107                 IAVF_DEV_PRIVATE_TO_ADAPTER(dev->data->dev_private);
2108         struct iavf_info *vf = IAVF_DEV_PRIVATE_TO_VF(ad);
2109         int ret = 0;
2110
2111         if (!iavf_flow_is_valid(flow) || !flow->engine->destroy) {
2112                 rte_flow_error_set(error, EINVAL,
2113                                    RTE_FLOW_ERROR_TYPE_HANDLE,
2114                                    NULL, "Invalid flow destroy");
2115                 return -rte_errno;
2116         }
2117
2118         rte_spinlock_lock(&vf->flow_ops_lock);
2119
2120         ret = flow->engine->destroy(ad, flow, error);
2121
2122         if (!ret) {
2123                 TAILQ_REMOVE(&vf->flow_list, flow, node);
2124                 rte_free(flow);
2125         } else {
2126                 PMD_DRV_LOG(ERR, "Failed to destroy flow");
2127         }
2128
2129         rte_spinlock_unlock(&vf->flow_ops_lock);
2130
2131         return ret;
2132 }
2133
2134 int
2135 iavf_flow_flush(struct rte_eth_dev *dev,
2136                 struct rte_flow_error *error)
2137 {
2138         struct iavf_adapter *ad =
2139                 IAVF_DEV_PRIVATE_TO_ADAPTER(dev->data->dev_private);
2140         struct iavf_info *vf = IAVF_DEV_PRIVATE_TO_VF(ad);
2141         struct rte_flow *p_flow;
2142         void *temp;
2143         int ret = 0;
2144
2145         RTE_TAILQ_FOREACH_SAFE(p_flow, &vf->flow_list, node, temp) {
2146                 ret = iavf_flow_destroy(dev, p_flow, error);
2147                 if (ret) {
2148                         PMD_DRV_LOG(ERR, "Failed to flush flows");
2149                         return -EINVAL;
2150                 }
2151         }
2152
2153         return ret;
2154 }
2155
2156 static int
2157 iavf_flow_query(struct rte_eth_dev *dev,
2158                 struct rte_flow *flow,
2159                 const struct rte_flow_action *actions,
2160                 void *data,
2161                 struct rte_flow_error *error)
2162 {
2163         int ret = -EINVAL;
2164         struct iavf_adapter *ad =
2165                 IAVF_DEV_PRIVATE_TO_ADAPTER(dev->data->dev_private);
2166         struct rte_flow_query_count *count = data;
2167
2168         if (!iavf_flow_is_valid(flow) || !flow->engine->query_count) {
2169                 rte_flow_error_set(error, EINVAL,
2170                                    RTE_FLOW_ERROR_TYPE_HANDLE,
2171                                    NULL, "Invalid flow query");
2172                 return -rte_errno;
2173         }
2174
2175         for (; actions->type != RTE_FLOW_ACTION_TYPE_END; actions++) {
2176                 switch (actions->type) {
2177                 case RTE_FLOW_ACTION_TYPE_VOID:
2178                         break;
2179                 case RTE_FLOW_ACTION_TYPE_COUNT:
2180                         ret = flow->engine->query_count(ad, flow, count, error);
2181                         break;
2182                 default:
2183                         return rte_flow_error_set(error, ENOTSUP,
2184                                         RTE_FLOW_ERROR_TYPE_ACTION,
2185                                         actions,
2186                                         "action not supported");
2187                 }
2188         }
2189         return ret;
2190 }
2191