Branch data Line data Source code
1 : : /* SPDX-License-Identifier: BSD-3-Clause
2 : : * Copyright(c) 2016-2017 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_debug.h>
14 : : #include <rte_ether.h>
15 : : #include <ethdev_driver.h>
16 : : #include <rte_log.h>
17 : : #include <rte_malloc.h>
18 : : #include <rte_tailq.h>
19 : : #include <rte_flow_driver.h>
20 : : #include <rte_bitmap.h>
21 : :
22 : : #include "i40e_logs.h"
23 : : #include "base/i40e_type.h"
24 : : #include "base/i40e_prototype.h"
25 : : #include "i40e_ethdev.h"
26 : : #include "i40e_hash.h"
27 : :
28 : : #define I40E_IPV6_TC_MASK (0xFF << I40E_FDIR_IPv6_TC_OFFSET)
29 : : #define I40E_IPV6_FRAG_HEADER 44
30 : : #define I40E_TENANT_ARRAY_NUM 3
31 : : #define I40E_VLAN_TCI_MASK 0xFFFF
32 : : #define I40E_VLAN_PRI_MASK 0xE000
33 : : #define I40E_VLAN_CFI_MASK 0x1000
34 : : #define I40E_VLAN_VID_MASK 0x0FFF
35 : :
36 : : static int i40e_flow_validate(struct rte_eth_dev *dev,
37 : : const struct rte_flow_attr *attr,
38 : : const struct rte_flow_item pattern[],
39 : : const struct rte_flow_action actions[],
40 : : struct rte_flow_error *error);
41 : : static struct rte_flow *i40e_flow_create(struct rte_eth_dev *dev,
42 : : const struct rte_flow_attr *attr,
43 : : const struct rte_flow_item pattern[],
44 : : const struct rte_flow_action actions[],
45 : : struct rte_flow_error *error);
46 : : static int i40e_flow_destroy(struct rte_eth_dev *dev,
47 : : struct rte_flow *flow,
48 : : struct rte_flow_error *error);
49 : : static int i40e_flow_flush(struct rte_eth_dev *dev,
50 : : struct rte_flow_error *error);
51 : : static int i40e_flow_query(struct rte_eth_dev *dev,
52 : : struct rte_flow *flow,
53 : : const struct rte_flow_action *actions,
54 : : void *data, struct rte_flow_error *error);
55 : : static int
56 : : i40e_flow_parse_ethertype_pattern(struct rte_eth_dev *dev,
57 : : const struct rte_flow_item *pattern,
58 : : struct rte_flow_error *error,
59 : : struct rte_eth_ethertype_filter *filter);
60 : : static int i40e_flow_parse_ethertype_action(struct rte_eth_dev *dev,
61 : : const struct rte_flow_action *actions,
62 : : struct rte_flow_error *error,
63 : : struct rte_eth_ethertype_filter *filter);
64 : : static int i40e_flow_parse_fdir_pattern(struct rte_eth_dev *dev,
65 : : const struct rte_flow_item *pattern,
66 : : struct rte_flow_error *error,
67 : : struct i40e_fdir_filter_conf *filter);
68 : : static int i40e_flow_parse_fdir_action(struct rte_eth_dev *dev,
69 : : const struct rte_flow_action *actions,
70 : : struct rte_flow_error *error,
71 : : struct i40e_fdir_filter_conf *filter);
72 : : static int i40e_flow_parse_tunnel_action(struct rte_eth_dev *dev,
73 : : const struct rte_flow_action *actions,
74 : : struct rte_flow_error *error,
75 : : struct i40e_tunnel_filter_conf *filter);
76 : : static int i40e_flow_parse_attr(const struct rte_flow_attr *attr,
77 : : struct rte_flow_error *error);
78 : : static int i40e_flow_parse_ethertype_filter(struct rte_eth_dev *dev,
79 : : const struct rte_flow_attr *attr,
80 : : const struct rte_flow_item pattern[],
81 : : const struct rte_flow_action actions[],
82 : : struct rte_flow_error *error,
83 : : union i40e_filter_t *filter);
84 : : static int i40e_flow_parse_fdir_filter(struct rte_eth_dev *dev,
85 : : const struct rte_flow_attr *attr,
86 : : const struct rte_flow_item pattern[],
87 : : const struct rte_flow_action actions[],
88 : : struct rte_flow_error *error,
89 : : union i40e_filter_t *filter);
90 : : static int i40e_flow_parse_vxlan_filter(struct rte_eth_dev *dev,
91 : : const struct rte_flow_attr *attr,
92 : : const struct rte_flow_item pattern[],
93 : : const struct rte_flow_action actions[],
94 : : struct rte_flow_error *error,
95 : : union i40e_filter_t *filter);
96 : : static int i40e_flow_parse_nvgre_filter(struct rte_eth_dev *dev,
97 : : const struct rte_flow_attr *attr,
98 : : const struct rte_flow_item pattern[],
99 : : const struct rte_flow_action actions[],
100 : : struct rte_flow_error *error,
101 : : union i40e_filter_t *filter);
102 : : static int i40e_flow_parse_mpls_filter(struct rte_eth_dev *dev,
103 : : const struct rte_flow_attr *attr,
104 : : const struct rte_flow_item pattern[],
105 : : const struct rte_flow_action actions[],
106 : : struct rte_flow_error *error,
107 : : union i40e_filter_t *filter);
108 : : static int i40e_flow_parse_gtp_filter(struct rte_eth_dev *dev,
109 : : const struct rte_flow_attr *attr,
110 : : const struct rte_flow_item pattern[],
111 : : const struct rte_flow_action actions[],
112 : : struct rte_flow_error *error,
113 : : union i40e_filter_t *filter);
114 : : static int i40e_flow_destroy_ethertype_filter(struct i40e_pf *pf,
115 : : struct i40e_ethertype_filter *filter);
116 : : static int i40e_flow_destroy_tunnel_filter(struct i40e_pf *pf,
117 : : struct i40e_tunnel_filter *filter);
118 : : static int i40e_flow_flush_fdir_filter(struct i40e_pf *pf);
119 : : static int i40e_flow_flush_ethertype_filter(struct i40e_pf *pf);
120 : : static int i40e_flow_flush_tunnel_filter(struct i40e_pf *pf);
121 : : static int
122 : : i40e_flow_parse_qinq_filter(struct rte_eth_dev *dev,
123 : : const struct rte_flow_attr *attr,
124 : : const struct rte_flow_item pattern[],
125 : : const struct rte_flow_action actions[],
126 : : struct rte_flow_error *error,
127 : : union i40e_filter_t *filter);
128 : : static int
129 : : i40e_flow_parse_qinq_pattern(struct rte_eth_dev *dev,
130 : : const struct rte_flow_item *pattern,
131 : : struct rte_flow_error *error,
132 : : struct i40e_tunnel_filter_conf *filter);
133 : :
134 : : static int i40e_flow_parse_l4_cloud_filter(struct rte_eth_dev *dev,
135 : : const struct rte_flow_attr *attr,
136 : : const struct rte_flow_item pattern[],
137 : : const struct rte_flow_action actions[],
138 : : struct rte_flow_error *error,
139 : : union i40e_filter_t *filter);
140 : : const struct rte_flow_ops i40e_flow_ops = {
141 : : .validate = i40e_flow_validate,
142 : : .create = i40e_flow_create,
143 : : .destroy = i40e_flow_destroy,
144 : : .flush = i40e_flow_flush,
145 : : .query = i40e_flow_query,
146 : : };
147 : :
148 : : static union i40e_filter_t cons_filter;
149 : : static enum rte_filter_type cons_filter_type = RTE_ETH_FILTER_NONE;
150 : : /* internal pattern w/o VOID items */
151 : : struct rte_flow_item g_items[32];
152 : :
153 : : /* Pattern matched ethertype filter */
154 : : static enum rte_flow_item_type pattern_ethertype[] = {
155 : : RTE_FLOW_ITEM_TYPE_ETH,
156 : : RTE_FLOW_ITEM_TYPE_END,
157 : : };
158 : :
159 : : /* Pattern matched flow director filter */
160 : : static enum rte_flow_item_type pattern_fdir_ipv4[] = {
161 : : RTE_FLOW_ITEM_TYPE_ETH,
162 : : RTE_FLOW_ITEM_TYPE_IPV4,
163 : : RTE_FLOW_ITEM_TYPE_END,
164 : : };
165 : :
166 : : static enum rte_flow_item_type pattern_fdir_ipv4_udp[] = {
167 : : RTE_FLOW_ITEM_TYPE_ETH,
168 : : RTE_FLOW_ITEM_TYPE_IPV4,
169 : : RTE_FLOW_ITEM_TYPE_UDP,
170 : : RTE_FLOW_ITEM_TYPE_END,
171 : : };
172 : :
173 : : static enum rte_flow_item_type pattern_fdir_ipv4_tcp[] = {
174 : : RTE_FLOW_ITEM_TYPE_ETH,
175 : : RTE_FLOW_ITEM_TYPE_IPV4,
176 : : RTE_FLOW_ITEM_TYPE_TCP,
177 : : RTE_FLOW_ITEM_TYPE_END,
178 : : };
179 : :
180 : : static enum rte_flow_item_type pattern_fdir_ipv4_sctp[] = {
181 : : RTE_FLOW_ITEM_TYPE_ETH,
182 : : RTE_FLOW_ITEM_TYPE_IPV4,
183 : : RTE_FLOW_ITEM_TYPE_SCTP,
184 : : RTE_FLOW_ITEM_TYPE_END,
185 : : };
186 : :
187 : : static enum rte_flow_item_type pattern_fdir_ipv4_gtpc[] = {
188 : : RTE_FLOW_ITEM_TYPE_ETH,
189 : : RTE_FLOW_ITEM_TYPE_IPV4,
190 : : RTE_FLOW_ITEM_TYPE_UDP,
191 : : RTE_FLOW_ITEM_TYPE_GTPC,
192 : : RTE_FLOW_ITEM_TYPE_END,
193 : : };
194 : :
195 : : static enum rte_flow_item_type pattern_fdir_ipv4_gtpu[] = {
196 : : RTE_FLOW_ITEM_TYPE_ETH,
197 : : RTE_FLOW_ITEM_TYPE_IPV4,
198 : : RTE_FLOW_ITEM_TYPE_UDP,
199 : : RTE_FLOW_ITEM_TYPE_GTPU,
200 : : RTE_FLOW_ITEM_TYPE_END,
201 : : };
202 : :
203 : : static enum rte_flow_item_type pattern_fdir_ipv4_gtpu_ipv4[] = {
204 : : RTE_FLOW_ITEM_TYPE_ETH,
205 : : RTE_FLOW_ITEM_TYPE_IPV4,
206 : : RTE_FLOW_ITEM_TYPE_UDP,
207 : : RTE_FLOW_ITEM_TYPE_GTPU,
208 : : RTE_FLOW_ITEM_TYPE_IPV4,
209 : : RTE_FLOW_ITEM_TYPE_END,
210 : : };
211 : :
212 : : static enum rte_flow_item_type pattern_fdir_ipv4_gtpu_ipv6[] = {
213 : : RTE_FLOW_ITEM_TYPE_ETH,
214 : : RTE_FLOW_ITEM_TYPE_IPV4,
215 : : RTE_FLOW_ITEM_TYPE_UDP,
216 : : RTE_FLOW_ITEM_TYPE_GTPU,
217 : : RTE_FLOW_ITEM_TYPE_IPV6,
218 : : RTE_FLOW_ITEM_TYPE_END,
219 : : };
220 : :
221 : : static enum rte_flow_item_type pattern_fdir_ipv6[] = {
222 : : RTE_FLOW_ITEM_TYPE_ETH,
223 : : RTE_FLOW_ITEM_TYPE_IPV6,
224 : : RTE_FLOW_ITEM_TYPE_END,
225 : : };
226 : :
227 : : static enum rte_flow_item_type pattern_fdir_ipv6_udp[] = {
228 : : RTE_FLOW_ITEM_TYPE_ETH,
229 : : RTE_FLOW_ITEM_TYPE_IPV6,
230 : : RTE_FLOW_ITEM_TYPE_UDP,
231 : : RTE_FLOW_ITEM_TYPE_END,
232 : : };
233 : :
234 : : static enum rte_flow_item_type pattern_fdir_ipv6_tcp[] = {
235 : : RTE_FLOW_ITEM_TYPE_ETH,
236 : : RTE_FLOW_ITEM_TYPE_IPV6,
237 : : RTE_FLOW_ITEM_TYPE_TCP,
238 : : RTE_FLOW_ITEM_TYPE_END,
239 : : };
240 : :
241 : : static enum rte_flow_item_type pattern_fdir_ipv6_sctp[] = {
242 : : RTE_FLOW_ITEM_TYPE_ETH,
243 : : RTE_FLOW_ITEM_TYPE_IPV6,
244 : : RTE_FLOW_ITEM_TYPE_SCTP,
245 : : RTE_FLOW_ITEM_TYPE_END,
246 : : };
247 : :
248 : : static enum rte_flow_item_type pattern_fdir_ipv6_gtpc[] = {
249 : : RTE_FLOW_ITEM_TYPE_ETH,
250 : : RTE_FLOW_ITEM_TYPE_IPV6,
251 : : RTE_FLOW_ITEM_TYPE_UDP,
252 : : RTE_FLOW_ITEM_TYPE_GTPC,
253 : : RTE_FLOW_ITEM_TYPE_END,
254 : : };
255 : :
256 : : static enum rte_flow_item_type pattern_fdir_ipv6_gtpu[] = {
257 : : RTE_FLOW_ITEM_TYPE_ETH,
258 : : RTE_FLOW_ITEM_TYPE_IPV6,
259 : : RTE_FLOW_ITEM_TYPE_UDP,
260 : : RTE_FLOW_ITEM_TYPE_GTPU,
261 : : RTE_FLOW_ITEM_TYPE_END,
262 : : };
263 : :
264 : : static enum rte_flow_item_type pattern_fdir_ipv6_gtpu_ipv4[] = {
265 : : RTE_FLOW_ITEM_TYPE_ETH,
266 : : RTE_FLOW_ITEM_TYPE_IPV6,
267 : : RTE_FLOW_ITEM_TYPE_UDP,
268 : : RTE_FLOW_ITEM_TYPE_GTPU,
269 : : RTE_FLOW_ITEM_TYPE_IPV4,
270 : : RTE_FLOW_ITEM_TYPE_END,
271 : : };
272 : :
273 : : static enum rte_flow_item_type pattern_fdir_ipv6_gtpu_ipv6[] = {
274 : : RTE_FLOW_ITEM_TYPE_ETH,
275 : : RTE_FLOW_ITEM_TYPE_IPV6,
276 : : RTE_FLOW_ITEM_TYPE_UDP,
277 : : RTE_FLOW_ITEM_TYPE_GTPU,
278 : : RTE_FLOW_ITEM_TYPE_IPV6,
279 : : RTE_FLOW_ITEM_TYPE_END,
280 : : };
281 : :
282 : : static enum rte_flow_item_type pattern_fdir_ethertype_raw_1[] = {
283 : : RTE_FLOW_ITEM_TYPE_ETH,
284 : : RTE_FLOW_ITEM_TYPE_RAW,
285 : : RTE_FLOW_ITEM_TYPE_END,
286 : : };
287 : :
288 : : static enum rte_flow_item_type pattern_fdir_ethertype_raw_2[] = {
289 : : RTE_FLOW_ITEM_TYPE_ETH,
290 : : RTE_FLOW_ITEM_TYPE_RAW,
291 : : RTE_FLOW_ITEM_TYPE_RAW,
292 : : RTE_FLOW_ITEM_TYPE_END,
293 : : };
294 : :
295 : : static enum rte_flow_item_type pattern_fdir_ethertype_raw_3[] = {
296 : : RTE_FLOW_ITEM_TYPE_ETH,
297 : : RTE_FLOW_ITEM_TYPE_RAW,
298 : : RTE_FLOW_ITEM_TYPE_RAW,
299 : : RTE_FLOW_ITEM_TYPE_RAW,
300 : : RTE_FLOW_ITEM_TYPE_END,
301 : : };
302 : :
303 : : static enum rte_flow_item_type pattern_fdir_ipv4_raw_1[] = {
304 : : RTE_FLOW_ITEM_TYPE_ETH,
305 : : RTE_FLOW_ITEM_TYPE_IPV4,
306 : : RTE_FLOW_ITEM_TYPE_RAW,
307 : : RTE_FLOW_ITEM_TYPE_END,
308 : : };
309 : :
310 : : static enum rte_flow_item_type pattern_fdir_ipv4_raw_2[] = {
311 : : RTE_FLOW_ITEM_TYPE_ETH,
312 : : RTE_FLOW_ITEM_TYPE_IPV4,
313 : : RTE_FLOW_ITEM_TYPE_RAW,
314 : : RTE_FLOW_ITEM_TYPE_RAW,
315 : : RTE_FLOW_ITEM_TYPE_END,
316 : : };
317 : :
318 : : static enum rte_flow_item_type pattern_fdir_ipv4_raw_3[] = {
319 : : RTE_FLOW_ITEM_TYPE_ETH,
320 : : RTE_FLOW_ITEM_TYPE_IPV4,
321 : : RTE_FLOW_ITEM_TYPE_RAW,
322 : : RTE_FLOW_ITEM_TYPE_RAW,
323 : : RTE_FLOW_ITEM_TYPE_RAW,
324 : : RTE_FLOW_ITEM_TYPE_END,
325 : : };
326 : :
327 : : static enum rte_flow_item_type pattern_fdir_ipv4_udp_raw_1[] = {
328 : : RTE_FLOW_ITEM_TYPE_ETH,
329 : : RTE_FLOW_ITEM_TYPE_IPV4,
330 : : RTE_FLOW_ITEM_TYPE_UDP,
331 : : RTE_FLOW_ITEM_TYPE_RAW,
332 : : RTE_FLOW_ITEM_TYPE_END,
333 : : };
334 : :
335 : : static enum rte_flow_item_type pattern_fdir_ipv4_udp_raw_2[] = {
336 : : RTE_FLOW_ITEM_TYPE_ETH,
337 : : RTE_FLOW_ITEM_TYPE_IPV4,
338 : : RTE_FLOW_ITEM_TYPE_UDP,
339 : : RTE_FLOW_ITEM_TYPE_RAW,
340 : : RTE_FLOW_ITEM_TYPE_RAW,
341 : : RTE_FLOW_ITEM_TYPE_END,
342 : : };
343 : :
344 : : static enum rte_flow_item_type pattern_fdir_ipv4_udp_raw_3[] = {
345 : : RTE_FLOW_ITEM_TYPE_ETH,
346 : : RTE_FLOW_ITEM_TYPE_IPV4,
347 : : RTE_FLOW_ITEM_TYPE_UDP,
348 : : RTE_FLOW_ITEM_TYPE_RAW,
349 : : RTE_FLOW_ITEM_TYPE_RAW,
350 : : RTE_FLOW_ITEM_TYPE_RAW,
351 : : RTE_FLOW_ITEM_TYPE_END,
352 : : };
353 : :
354 : : static enum rte_flow_item_type pattern_fdir_ipv4_tcp_raw_1[] = {
355 : : RTE_FLOW_ITEM_TYPE_ETH,
356 : : RTE_FLOW_ITEM_TYPE_IPV4,
357 : : RTE_FLOW_ITEM_TYPE_TCP,
358 : : RTE_FLOW_ITEM_TYPE_RAW,
359 : : RTE_FLOW_ITEM_TYPE_END,
360 : : };
361 : :
362 : : static enum rte_flow_item_type pattern_fdir_ipv4_tcp_raw_2[] = {
363 : : RTE_FLOW_ITEM_TYPE_ETH,
364 : : RTE_FLOW_ITEM_TYPE_IPV4,
365 : : RTE_FLOW_ITEM_TYPE_TCP,
366 : : RTE_FLOW_ITEM_TYPE_RAW,
367 : : RTE_FLOW_ITEM_TYPE_RAW,
368 : : RTE_FLOW_ITEM_TYPE_END,
369 : : };
370 : :
371 : : static enum rte_flow_item_type pattern_fdir_ipv4_tcp_raw_3[] = {
372 : : RTE_FLOW_ITEM_TYPE_ETH,
373 : : RTE_FLOW_ITEM_TYPE_IPV4,
374 : : RTE_FLOW_ITEM_TYPE_TCP,
375 : : RTE_FLOW_ITEM_TYPE_RAW,
376 : : RTE_FLOW_ITEM_TYPE_RAW,
377 : : RTE_FLOW_ITEM_TYPE_RAW,
378 : : RTE_FLOW_ITEM_TYPE_END,
379 : : };
380 : :
381 : : static enum rte_flow_item_type pattern_fdir_ipv4_sctp_raw_1[] = {
382 : : RTE_FLOW_ITEM_TYPE_ETH,
383 : : RTE_FLOW_ITEM_TYPE_IPV4,
384 : : RTE_FLOW_ITEM_TYPE_SCTP,
385 : : RTE_FLOW_ITEM_TYPE_RAW,
386 : : RTE_FLOW_ITEM_TYPE_END,
387 : : };
388 : :
389 : : static enum rte_flow_item_type pattern_fdir_ipv4_sctp_raw_2[] = {
390 : : RTE_FLOW_ITEM_TYPE_ETH,
391 : : RTE_FLOW_ITEM_TYPE_IPV4,
392 : : RTE_FLOW_ITEM_TYPE_SCTP,
393 : : RTE_FLOW_ITEM_TYPE_RAW,
394 : : RTE_FLOW_ITEM_TYPE_RAW,
395 : : RTE_FLOW_ITEM_TYPE_END,
396 : : };
397 : :
398 : : static enum rte_flow_item_type pattern_fdir_ipv4_sctp_raw_3[] = {
399 : : RTE_FLOW_ITEM_TYPE_ETH,
400 : : RTE_FLOW_ITEM_TYPE_IPV4,
401 : : RTE_FLOW_ITEM_TYPE_SCTP,
402 : : RTE_FLOW_ITEM_TYPE_RAW,
403 : : RTE_FLOW_ITEM_TYPE_RAW,
404 : : RTE_FLOW_ITEM_TYPE_RAW,
405 : : RTE_FLOW_ITEM_TYPE_END,
406 : : };
407 : :
408 : : static enum rte_flow_item_type pattern_fdir_ipv6_raw_1[] = {
409 : : RTE_FLOW_ITEM_TYPE_ETH,
410 : : RTE_FLOW_ITEM_TYPE_IPV6,
411 : : RTE_FLOW_ITEM_TYPE_RAW,
412 : : RTE_FLOW_ITEM_TYPE_END,
413 : : };
414 : :
415 : : static enum rte_flow_item_type pattern_fdir_ipv6_raw_2[] = {
416 : : RTE_FLOW_ITEM_TYPE_ETH,
417 : : RTE_FLOW_ITEM_TYPE_IPV6,
418 : : RTE_FLOW_ITEM_TYPE_RAW,
419 : : RTE_FLOW_ITEM_TYPE_RAW,
420 : : RTE_FLOW_ITEM_TYPE_END,
421 : : };
422 : :
423 : : static enum rte_flow_item_type pattern_fdir_ipv6_raw_3[] = {
424 : : RTE_FLOW_ITEM_TYPE_ETH,
425 : : RTE_FLOW_ITEM_TYPE_IPV6,
426 : : RTE_FLOW_ITEM_TYPE_RAW,
427 : : RTE_FLOW_ITEM_TYPE_RAW,
428 : : RTE_FLOW_ITEM_TYPE_RAW,
429 : : RTE_FLOW_ITEM_TYPE_END,
430 : : };
431 : :
432 : : static enum rte_flow_item_type pattern_fdir_ipv6_udp_raw_1[] = {
433 : : RTE_FLOW_ITEM_TYPE_ETH,
434 : : RTE_FLOW_ITEM_TYPE_IPV6,
435 : : RTE_FLOW_ITEM_TYPE_UDP,
436 : : RTE_FLOW_ITEM_TYPE_RAW,
437 : : RTE_FLOW_ITEM_TYPE_END,
438 : : };
439 : :
440 : : static enum rte_flow_item_type pattern_fdir_ipv6_udp_raw_2[] = {
441 : : RTE_FLOW_ITEM_TYPE_ETH,
442 : : RTE_FLOW_ITEM_TYPE_IPV6,
443 : : RTE_FLOW_ITEM_TYPE_UDP,
444 : : RTE_FLOW_ITEM_TYPE_RAW,
445 : : RTE_FLOW_ITEM_TYPE_RAW,
446 : : RTE_FLOW_ITEM_TYPE_END,
447 : : };
448 : :
449 : : static enum rte_flow_item_type pattern_fdir_ipv6_udp_raw_3[] = {
450 : : RTE_FLOW_ITEM_TYPE_ETH,
451 : : RTE_FLOW_ITEM_TYPE_IPV6,
452 : : RTE_FLOW_ITEM_TYPE_UDP,
453 : : RTE_FLOW_ITEM_TYPE_RAW,
454 : : RTE_FLOW_ITEM_TYPE_RAW,
455 : : RTE_FLOW_ITEM_TYPE_RAW,
456 : : RTE_FLOW_ITEM_TYPE_END,
457 : : };
458 : :
459 : : static enum rte_flow_item_type pattern_fdir_ipv6_tcp_raw_1[] = {
460 : : RTE_FLOW_ITEM_TYPE_ETH,
461 : : RTE_FLOW_ITEM_TYPE_IPV6,
462 : : RTE_FLOW_ITEM_TYPE_TCP,
463 : : RTE_FLOW_ITEM_TYPE_RAW,
464 : : RTE_FLOW_ITEM_TYPE_END,
465 : : };
466 : :
467 : : static enum rte_flow_item_type pattern_fdir_ipv6_tcp_raw_2[] = {
468 : : RTE_FLOW_ITEM_TYPE_ETH,
469 : : RTE_FLOW_ITEM_TYPE_IPV6,
470 : : RTE_FLOW_ITEM_TYPE_TCP,
471 : : RTE_FLOW_ITEM_TYPE_RAW,
472 : : RTE_FLOW_ITEM_TYPE_RAW,
473 : : RTE_FLOW_ITEM_TYPE_END,
474 : : };
475 : :
476 : : static enum rte_flow_item_type pattern_fdir_ipv6_tcp_raw_3[] = {
477 : : RTE_FLOW_ITEM_TYPE_ETH,
478 : : RTE_FLOW_ITEM_TYPE_IPV6,
479 : : RTE_FLOW_ITEM_TYPE_TCP,
480 : : RTE_FLOW_ITEM_TYPE_RAW,
481 : : RTE_FLOW_ITEM_TYPE_RAW,
482 : : RTE_FLOW_ITEM_TYPE_RAW,
483 : : RTE_FLOW_ITEM_TYPE_END,
484 : : };
485 : :
486 : : static enum rte_flow_item_type pattern_fdir_ipv6_sctp_raw_1[] = {
487 : : RTE_FLOW_ITEM_TYPE_ETH,
488 : : RTE_FLOW_ITEM_TYPE_IPV6,
489 : : RTE_FLOW_ITEM_TYPE_SCTP,
490 : : RTE_FLOW_ITEM_TYPE_RAW,
491 : : RTE_FLOW_ITEM_TYPE_END,
492 : : };
493 : :
494 : : static enum rte_flow_item_type pattern_fdir_ipv6_sctp_raw_2[] = {
495 : : RTE_FLOW_ITEM_TYPE_ETH,
496 : : RTE_FLOW_ITEM_TYPE_IPV6,
497 : : RTE_FLOW_ITEM_TYPE_SCTP,
498 : : RTE_FLOW_ITEM_TYPE_RAW,
499 : : RTE_FLOW_ITEM_TYPE_RAW,
500 : : RTE_FLOW_ITEM_TYPE_END,
501 : : };
502 : :
503 : : static enum rte_flow_item_type pattern_fdir_ipv6_sctp_raw_3[] = {
504 : : RTE_FLOW_ITEM_TYPE_ETH,
505 : : RTE_FLOW_ITEM_TYPE_IPV6,
506 : : RTE_FLOW_ITEM_TYPE_SCTP,
507 : : RTE_FLOW_ITEM_TYPE_RAW,
508 : : RTE_FLOW_ITEM_TYPE_RAW,
509 : : RTE_FLOW_ITEM_TYPE_RAW,
510 : : RTE_FLOW_ITEM_TYPE_END,
511 : : };
512 : :
513 : : static enum rte_flow_item_type pattern_fdir_ethertype_vlan[] = {
514 : : RTE_FLOW_ITEM_TYPE_ETH,
515 : : RTE_FLOW_ITEM_TYPE_VLAN,
516 : : RTE_FLOW_ITEM_TYPE_END,
517 : : };
518 : :
519 : : static enum rte_flow_item_type pattern_fdir_vlan_ipv4[] = {
520 : : RTE_FLOW_ITEM_TYPE_ETH,
521 : : RTE_FLOW_ITEM_TYPE_VLAN,
522 : : RTE_FLOW_ITEM_TYPE_IPV4,
523 : : RTE_FLOW_ITEM_TYPE_END,
524 : : };
525 : :
526 : : static enum rte_flow_item_type pattern_fdir_vlan_ipv4_udp[] = {
527 : : RTE_FLOW_ITEM_TYPE_ETH,
528 : : RTE_FLOW_ITEM_TYPE_VLAN,
529 : : RTE_FLOW_ITEM_TYPE_IPV4,
530 : : RTE_FLOW_ITEM_TYPE_UDP,
531 : : RTE_FLOW_ITEM_TYPE_END,
532 : : };
533 : :
534 : : static enum rte_flow_item_type pattern_fdir_vlan_ipv4_tcp[] = {
535 : : RTE_FLOW_ITEM_TYPE_ETH,
536 : : RTE_FLOW_ITEM_TYPE_VLAN,
537 : : RTE_FLOW_ITEM_TYPE_IPV4,
538 : : RTE_FLOW_ITEM_TYPE_TCP,
539 : : RTE_FLOW_ITEM_TYPE_END,
540 : : };
541 : :
542 : : static enum rte_flow_item_type pattern_fdir_vlan_ipv4_sctp[] = {
543 : : RTE_FLOW_ITEM_TYPE_ETH,
544 : : RTE_FLOW_ITEM_TYPE_VLAN,
545 : : RTE_FLOW_ITEM_TYPE_IPV4,
546 : : RTE_FLOW_ITEM_TYPE_SCTP,
547 : : RTE_FLOW_ITEM_TYPE_END,
548 : : };
549 : :
550 : : static enum rte_flow_item_type pattern_fdir_vlan_ipv6[] = {
551 : : RTE_FLOW_ITEM_TYPE_ETH,
552 : : RTE_FLOW_ITEM_TYPE_VLAN,
553 : : RTE_FLOW_ITEM_TYPE_IPV6,
554 : : RTE_FLOW_ITEM_TYPE_END,
555 : : };
556 : :
557 : : static enum rte_flow_item_type pattern_fdir_vlan_ipv6_udp[] = {
558 : : RTE_FLOW_ITEM_TYPE_ETH,
559 : : RTE_FLOW_ITEM_TYPE_VLAN,
560 : : RTE_FLOW_ITEM_TYPE_IPV6,
561 : : RTE_FLOW_ITEM_TYPE_UDP,
562 : : RTE_FLOW_ITEM_TYPE_END,
563 : : };
564 : :
565 : : static enum rte_flow_item_type pattern_fdir_vlan_ipv6_tcp[] = {
566 : : RTE_FLOW_ITEM_TYPE_ETH,
567 : : RTE_FLOW_ITEM_TYPE_VLAN,
568 : : RTE_FLOW_ITEM_TYPE_IPV6,
569 : : RTE_FLOW_ITEM_TYPE_TCP,
570 : : RTE_FLOW_ITEM_TYPE_END,
571 : : };
572 : :
573 : : static enum rte_flow_item_type pattern_fdir_vlan_ipv6_sctp[] = {
574 : : RTE_FLOW_ITEM_TYPE_ETH,
575 : : RTE_FLOW_ITEM_TYPE_VLAN,
576 : : RTE_FLOW_ITEM_TYPE_IPV6,
577 : : RTE_FLOW_ITEM_TYPE_SCTP,
578 : : RTE_FLOW_ITEM_TYPE_END,
579 : : };
580 : :
581 : : static enum rte_flow_item_type pattern_fdir_ethertype_vlan_raw_1[] = {
582 : : RTE_FLOW_ITEM_TYPE_ETH,
583 : : RTE_FLOW_ITEM_TYPE_VLAN,
584 : : RTE_FLOW_ITEM_TYPE_RAW,
585 : : RTE_FLOW_ITEM_TYPE_END,
586 : : };
587 : :
588 : : static enum rte_flow_item_type pattern_fdir_ethertype_vlan_raw_2[] = {
589 : : RTE_FLOW_ITEM_TYPE_ETH,
590 : : RTE_FLOW_ITEM_TYPE_VLAN,
591 : : RTE_FLOW_ITEM_TYPE_RAW,
592 : : RTE_FLOW_ITEM_TYPE_RAW,
593 : : RTE_FLOW_ITEM_TYPE_END,
594 : : };
595 : :
596 : : static enum rte_flow_item_type pattern_fdir_ethertype_vlan_raw_3[] = {
597 : : RTE_FLOW_ITEM_TYPE_ETH,
598 : : RTE_FLOW_ITEM_TYPE_VLAN,
599 : : RTE_FLOW_ITEM_TYPE_RAW,
600 : : RTE_FLOW_ITEM_TYPE_RAW,
601 : : RTE_FLOW_ITEM_TYPE_RAW,
602 : : RTE_FLOW_ITEM_TYPE_END,
603 : : };
604 : :
605 : : static enum rte_flow_item_type pattern_fdir_vlan_ipv4_raw_1[] = {
606 : : RTE_FLOW_ITEM_TYPE_ETH,
607 : : RTE_FLOW_ITEM_TYPE_VLAN,
608 : : RTE_FLOW_ITEM_TYPE_IPV4,
609 : : RTE_FLOW_ITEM_TYPE_RAW,
610 : : RTE_FLOW_ITEM_TYPE_END,
611 : : };
612 : :
613 : : static enum rte_flow_item_type pattern_fdir_vlan_ipv4_raw_2[] = {
614 : : RTE_FLOW_ITEM_TYPE_ETH,
615 : : RTE_FLOW_ITEM_TYPE_VLAN,
616 : : RTE_FLOW_ITEM_TYPE_IPV4,
617 : : RTE_FLOW_ITEM_TYPE_RAW,
618 : : RTE_FLOW_ITEM_TYPE_RAW,
619 : : RTE_FLOW_ITEM_TYPE_END,
620 : : };
621 : :
622 : : static enum rte_flow_item_type pattern_fdir_vlan_ipv4_raw_3[] = {
623 : : RTE_FLOW_ITEM_TYPE_ETH,
624 : : RTE_FLOW_ITEM_TYPE_VLAN,
625 : : RTE_FLOW_ITEM_TYPE_IPV4,
626 : : RTE_FLOW_ITEM_TYPE_RAW,
627 : : RTE_FLOW_ITEM_TYPE_RAW,
628 : : RTE_FLOW_ITEM_TYPE_RAW,
629 : : RTE_FLOW_ITEM_TYPE_END,
630 : : };
631 : :
632 : : static enum rte_flow_item_type pattern_fdir_vlan_ipv4_udp_raw_1[] = {
633 : : RTE_FLOW_ITEM_TYPE_ETH,
634 : : RTE_FLOW_ITEM_TYPE_VLAN,
635 : : RTE_FLOW_ITEM_TYPE_IPV4,
636 : : RTE_FLOW_ITEM_TYPE_UDP,
637 : : RTE_FLOW_ITEM_TYPE_RAW,
638 : : RTE_FLOW_ITEM_TYPE_END,
639 : : };
640 : :
641 : : static enum rte_flow_item_type pattern_fdir_vlan_ipv4_udp_raw_2[] = {
642 : : RTE_FLOW_ITEM_TYPE_ETH,
643 : : RTE_FLOW_ITEM_TYPE_VLAN,
644 : : RTE_FLOW_ITEM_TYPE_IPV4,
645 : : RTE_FLOW_ITEM_TYPE_UDP,
646 : : RTE_FLOW_ITEM_TYPE_RAW,
647 : : RTE_FLOW_ITEM_TYPE_RAW,
648 : : RTE_FLOW_ITEM_TYPE_END,
649 : : };
650 : :
651 : : static enum rte_flow_item_type pattern_fdir_vlan_ipv4_udp_raw_3[] = {
652 : : RTE_FLOW_ITEM_TYPE_ETH,
653 : : RTE_FLOW_ITEM_TYPE_VLAN,
654 : : RTE_FLOW_ITEM_TYPE_IPV4,
655 : : RTE_FLOW_ITEM_TYPE_UDP,
656 : : RTE_FLOW_ITEM_TYPE_RAW,
657 : : RTE_FLOW_ITEM_TYPE_RAW,
658 : : RTE_FLOW_ITEM_TYPE_RAW,
659 : : RTE_FLOW_ITEM_TYPE_END,
660 : : };
661 : :
662 : : static enum rte_flow_item_type pattern_fdir_vlan_ipv4_tcp_raw_1[] = {
663 : : RTE_FLOW_ITEM_TYPE_ETH,
664 : : RTE_FLOW_ITEM_TYPE_VLAN,
665 : : RTE_FLOW_ITEM_TYPE_IPV4,
666 : : RTE_FLOW_ITEM_TYPE_TCP,
667 : : RTE_FLOW_ITEM_TYPE_RAW,
668 : : RTE_FLOW_ITEM_TYPE_END,
669 : : };
670 : :
671 : : static enum rte_flow_item_type pattern_fdir_vlan_ipv4_tcp_raw_2[] = {
672 : : RTE_FLOW_ITEM_TYPE_ETH,
673 : : RTE_FLOW_ITEM_TYPE_VLAN,
674 : : RTE_FLOW_ITEM_TYPE_IPV4,
675 : : RTE_FLOW_ITEM_TYPE_TCP,
676 : : RTE_FLOW_ITEM_TYPE_RAW,
677 : : RTE_FLOW_ITEM_TYPE_RAW,
678 : : RTE_FLOW_ITEM_TYPE_END,
679 : : };
680 : :
681 : : static enum rte_flow_item_type pattern_fdir_vlan_ipv4_tcp_raw_3[] = {
682 : : RTE_FLOW_ITEM_TYPE_ETH,
683 : : RTE_FLOW_ITEM_TYPE_VLAN,
684 : : RTE_FLOW_ITEM_TYPE_IPV4,
685 : : RTE_FLOW_ITEM_TYPE_TCP,
686 : : RTE_FLOW_ITEM_TYPE_RAW,
687 : : RTE_FLOW_ITEM_TYPE_RAW,
688 : : RTE_FLOW_ITEM_TYPE_RAW,
689 : : RTE_FLOW_ITEM_TYPE_END,
690 : : };
691 : :
692 : : static enum rte_flow_item_type pattern_fdir_vlan_ipv4_sctp_raw_1[] = {
693 : : RTE_FLOW_ITEM_TYPE_ETH,
694 : : RTE_FLOW_ITEM_TYPE_VLAN,
695 : : RTE_FLOW_ITEM_TYPE_IPV4,
696 : : RTE_FLOW_ITEM_TYPE_SCTP,
697 : : RTE_FLOW_ITEM_TYPE_RAW,
698 : : RTE_FLOW_ITEM_TYPE_END,
699 : : };
700 : :
701 : : static enum rte_flow_item_type pattern_fdir_vlan_ipv4_sctp_raw_2[] = {
702 : : RTE_FLOW_ITEM_TYPE_ETH,
703 : : RTE_FLOW_ITEM_TYPE_VLAN,
704 : : RTE_FLOW_ITEM_TYPE_IPV4,
705 : : RTE_FLOW_ITEM_TYPE_SCTP,
706 : : RTE_FLOW_ITEM_TYPE_RAW,
707 : : RTE_FLOW_ITEM_TYPE_RAW,
708 : : RTE_FLOW_ITEM_TYPE_END,
709 : : };
710 : :
711 : : static enum rte_flow_item_type pattern_fdir_vlan_ipv4_sctp_raw_3[] = {
712 : : RTE_FLOW_ITEM_TYPE_ETH,
713 : : RTE_FLOW_ITEM_TYPE_VLAN,
714 : : RTE_FLOW_ITEM_TYPE_IPV4,
715 : : RTE_FLOW_ITEM_TYPE_SCTP,
716 : : RTE_FLOW_ITEM_TYPE_RAW,
717 : : RTE_FLOW_ITEM_TYPE_RAW,
718 : : RTE_FLOW_ITEM_TYPE_RAW,
719 : : RTE_FLOW_ITEM_TYPE_END,
720 : : };
721 : :
722 : : static enum rte_flow_item_type pattern_fdir_vlan_ipv6_raw_1[] = {
723 : : RTE_FLOW_ITEM_TYPE_ETH,
724 : : RTE_FLOW_ITEM_TYPE_VLAN,
725 : : RTE_FLOW_ITEM_TYPE_IPV6,
726 : : RTE_FLOW_ITEM_TYPE_RAW,
727 : : RTE_FLOW_ITEM_TYPE_END,
728 : : };
729 : :
730 : : static enum rte_flow_item_type pattern_fdir_vlan_ipv6_raw_2[] = {
731 : : RTE_FLOW_ITEM_TYPE_ETH,
732 : : RTE_FLOW_ITEM_TYPE_VLAN,
733 : : RTE_FLOW_ITEM_TYPE_IPV6,
734 : : RTE_FLOW_ITEM_TYPE_RAW,
735 : : RTE_FLOW_ITEM_TYPE_RAW,
736 : : RTE_FLOW_ITEM_TYPE_END,
737 : : };
738 : :
739 : : static enum rte_flow_item_type pattern_fdir_vlan_ipv6_raw_3[] = {
740 : : RTE_FLOW_ITEM_TYPE_ETH,
741 : : RTE_FLOW_ITEM_TYPE_VLAN,
742 : : RTE_FLOW_ITEM_TYPE_IPV6,
743 : : RTE_FLOW_ITEM_TYPE_RAW,
744 : : RTE_FLOW_ITEM_TYPE_RAW,
745 : : RTE_FLOW_ITEM_TYPE_RAW,
746 : : RTE_FLOW_ITEM_TYPE_END,
747 : : };
748 : :
749 : : static enum rte_flow_item_type pattern_fdir_vlan_ipv6_udp_raw_1[] = {
750 : : RTE_FLOW_ITEM_TYPE_ETH,
751 : : RTE_FLOW_ITEM_TYPE_VLAN,
752 : : RTE_FLOW_ITEM_TYPE_IPV6,
753 : : RTE_FLOW_ITEM_TYPE_UDP,
754 : : RTE_FLOW_ITEM_TYPE_RAW,
755 : : RTE_FLOW_ITEM_TYPE_END,
756 : : };
757 : :
758 : : static enum rte_flow_item_type pattern_fdir_vlan_ipv6_udp_raw_2[] = {
759 : : RTE_FLOW_ITEM_TYPE_ETH,
760 : : RTE_FLOW_ITEM_TYPE_VLAN,
761 : : RTE_FLOW_ITEM_TYPE_IPV6,
762 : : RTE_FLOW_ITEM_TYPE_UDP,
763 : : RTE_FLOW_ITEM_TYPE_RAW,
764 : : RTE_FLOW_ITEM_TYPE_RAW,
765 : : RTE_FLOW_ITEM_TYPE_END,
766 : : };
767 : :
768 : : static enum rte_flow_item_type pattern_fdir_vlan_ipv6_udp_raw_3[] = {
769 : : RTE_FLOW_ITEM_TYPE_ETH,
770 : : RTE_FLOW_ITEM_TYPE_VLAN,
771 : : RTE_FLOW_ITEM_TYPE_IPV6,
772 : : RTE_FLOW_ITEM_TYPE_UDP,
773 : : RTE_FLOW_ITEM_TYPE_RAW,
774 : : RTE_FLOW_ITEM_TYPE_RAW,
775 : : RTE_FLOW_ITEM_TYPE_RAW,
776 : : RTE_FLOW_ITEM_TYPE_END,
777 : : };
778 : :
779 : : static enum rte_flow_item_type pattern_fdir_vlan_ipv6_tcp_raw_1[] = {
780 : : RTE_FLOW_ITEM_TYPE_ETH,
781 : : RTE_FLOW_ITEM_TYPE_VLAN,
782 : : RTE_FLOW_ITEM_TYPE_IPV6,
783 : : RTE_FLOW_ITEM_TYPE_TCP,
784 : : RTE_FLOW_ITEM_TYPE_RAW,
785 : : RTE_FLOW_ITEM_TYPE_END,
786 : : };
787 : :
788 : : static enum rte_flow_item_type pattern_fdir_vlan_ipv6_tcp_raw_2[] = {
789 : : RTE_FLOW_ITEM_TYPE_ETH,
790 : : RTE_FLOW_ITEM_TYPE_VLAN,
791 : : RTE_FLOW_ITEM_TYPE_IPV6,
792 : : RTE_FLOW_ITEM_TYPE_TCP,
793 : : RTE_FLOW_ITEM_TYPE_RAW,
794 : : RTE_FLOW_ITEM_TYPE_RAW,
795 : : RTE_FLOW_ITEM_TYPE_END,
796 : : };
797 : :
798 : : static enum rte_flow_item_type pattern_fdir_vlan_ipv6_tcp_raw_3[] = {
799 : : RTE_FLOW_ITEM_TYPE_ETH,
800 : : RTE_FLOW_ITEM_TYPE_VLAN,
801 : : RTE_FLOW_ITEM_TYPE_IPV6,
802 : : RTE_FLOW_ITEM_TYPE_TCP,
803 : : RTE_FLOW_ITEM_TYPE_RAW,
804 : : RTE_FLOW_ITEM_TYPE_RAW,
805 : : RTE_FLOW_ITEM_TYPE_RAW,
806 : : RTE_FLOW_ITEM_TYPE_END,
807 : : };
808 : :
809 : : static enum rte_flow_item_type pattern_fdir_vlan_ipv6_sctp_raw_1[] = {
810 : : RTE_FLOW_ITEM_TYPE_ETH,
811 : : RTE_FLOW_ITEM_TYPE_VLAN,
812 : : RTE_FLOW_ITEM_TYPE_IPV6,
813 : : RTE_FLOW_ITEM_TYPE_SCTP,
814 : : RTE_FLOW_ITEM_TYPE_RAW,
815 : : RTE_FLOW_ITEM_TYPE_END,
816 : : };
817 : :
818 : : static enum rte_flow_item_type pattern_fdir_vlan_ipv6_sctp_raw_2[] = {
819 : : RTE_FLOW_ITEM_TYPE_ETH,
820 : : RTE_FLOW_ITEM_TYPE_VLAN,
821 : : RTE_FLOW_ITEM_TYPE_IPV6,
822 : : RTE_FLOW_ITEM_TYPE_SCTP,
823 : : RTE_FLOW_ITEM_TYPE_RAW,
824 : : RTE_FLOW_ITEM_TYPE_RAW,
825 : : RTE_FLOW_ITEM_TYPE_END,
826 : : };
827 : :
828 : : static enum rte_flow_item_type pattern_fdir_vlan_ipv6_sctp_raw_3[] = {
829 : : RTE_FLOW_ITEM_TYPE_ETH,
830 : : RTE_FLOW_ITEM_TYPE_VLAN,
831 : : RTE_FLOW_ITEM_TYPE_IPV6,
832 : : RTE_FLOW_ITEM_TYPE_SCTP,
833 : : RTE_FLOW_ITEM_TYPE_RAW,
834 : : RTE_FLOW_ITEM_TYPE_RAW,
835 : : RTE_FLOW_ITEM_TYPE_RAW,
836 : : RTE_FLOW_ITEM_TYPE_END,
837 : : };
838 : :
839 : : /* Pattern matched tunnel filter */
840 : : static enum rte_flow_item_type pattern_vxlan_1[] = {
841 : : RTE_FLOW_ITEM_TYPE_ETH,
842 : : RTE_FLOW_ITEM_TYPE_IPV4,
843 : : RTE_FLOW_ITEM_TYPE_UDP,
844 : : RTE_FLOW_ITEM_TYPE_VXLAN,
845 : : RTE_FLOW_ITEM_TYPE_ETH,
846 : : RTE_FLOW_ITEM_TYPE_END,
847 : : };
848 : :
849 : : static enum rte_flow_item_type pattern_vxlan_2[] = {
850 : : RTE_FLOW_ITEM_TYPE_ETH,
851 : : RTE_FLOW_ITEM_TYPE_IPV6,
852 : : RTE_FLOW_ITEM_TYPE_UDP,
853 : : RTE_FLOW_ITEM_TYPE_VXLAN,
854 : : RTE_FLOW_ITEM_TYPE_ETH,
855 : : RTE_FLOW_ITEM_TYPE_END,
856 : : };
857 : :
858 : : static enum rte_flow_item_type pattern_vxlan_3[] = {
859 : : RTE_FLOW_ITEM_TYPE_ETH,
860 : : RTE_FLOW_ITEM_TYPE_IPV4,
861 : : RTE_FLOW_ITEM_TYPE_UDP,
862 : : RTE_FLOW_ITEM_TYPE_VXLAN,
863 : : RTE_FLOW_ITEM_TYPE_ETH,
864 : : RTE_FLOW_ITEM_TYPE_VLAN,
865 : : RTE_FLOW_ITEM_TYPE_END,
866 : : };
867 : :
868 : : static enum rte_flow_item_type pattern_vxlan_4[] = {
869 : : RTE_FLOW_ITEM_TYPE_ETH,
870 : : RTE_FLOW_ITEM_TYPE_IPV6,
871 : : RTE_FLOW_ITEM_TYPE_UDP,
872 : : RTE_FLOW_ITEM_TYPE_VXLAN,
873 : : RTE_FLOW_ITEM_TYPE_ETH,
874 : : RTE_FLOW_ITEM_TYPE_VLAN,
875 : : RTE_FLOW_ITEM_TYPE_END,
876 : : };
877 : :
878 : : static enum rte_flow_item_type pattern_nvgre_1[] = {
879 : : RTE_FLOW_ITEM_TYPE_ETH,
880 : : RTE_FLOW_ITEM_TYPE_IPV4,
881 : : RTE_FLOW_ITEM_TYPE_NVGRE,
882 : : RTE_FLOW_ITEM_TYPE_ETH,
883 : : RTE_FLOW_ITEM_TYPE_END,
884 : : };
885 : :
886 : : static enum rte_flow_item_type pattern_nvgre_2[] = {
887 : : RTE_FLOW_ITEM_TYPE_ETH,
888 : : RTE_FLOW_ITEM_TYPE_IPV6,
889 : : RTE_FLOW_ITEM_TYPE_NVGRE,
890 : : RTE_FLOW_ITEM_TYPE_ETH,
891 : : RTE_FLOW_ITEM_TYPE_END,
892 : : };
893 : :
894 : : static enum rte_flow_item_type pattern_nvgre_3[] = {
895 : : RTE_FLOW_ITEM_TYPE_ETH,
896 : : RTE_FLOW_ITEM_TYPE_IPV4,
897 : : RTE_FLOW_ITEM_TYPE_NVGRE,
898 : : RTE_FLOW_ITEM_TYPE_ETH,
899 : : RTE_FLOW_ITEM_TYPE_VLAN,
900 : : RTE_FLOW_ITEM_TYPE_END,
901 : : };
902 : :
903 : : static enum rte_flow_item_type pattern_nvgre_4[] = {
904 : : RTE_FLOW_ITEM_TYPE_ETH,
905 : : RTE_FLOW_ITEM_TYPE_IPV6,
906 : : RTE_FLOW_ITEM_TYPE_NVGRE,
907 : : RTE_FLOW_ITEM_TYPE_ETH,
908 : : RTE_FLOW_ITEM_TYPE_VLAN,
909 : : RTE_FLOW_ITEM_TYPE_END,
910 : : };
911 : :
912 : : static enum rte_flow_item_type pattern_mpls_1[] = {
913 : : RTE_FLOW_ITEM_TYPE_ETH,
914 : : RTE_FLOW_ITEM_TYPE_IPV4,
915 : : RTE_FLOW_ITEM_TYPE_UDP,
916 : : RTE_FLOW_ITEM_TYPE_MPLS,
917 : : RTE_FLOW_ITEM_TYPE_END,
918 : : };
919 : :
920 : : static enum rte_flow_item_type pattern_mpls_2[] = {
921 : : RTE_FLOW_ITEM_TYPE_ETH,
922 : : RTE_FLOW_ITEM_TYPE_IPV6,
923 : : RTE_FLOW_ITEM_TYPE_UDP,
924 : : RTE_FLOW_ITEM_TYPE_MPLS,
925 : : RTE_FLOW_ITEM_TYPE_END,
926 : : };
927 : :
928 : : static enum rte_flow_item_type pattern_mpls_3[] = {
929 : : RTE_FLOW_ITEM_TYPE_ETH,
930 : : RTE_FLOW_ITEM_TYPE_IPV4,
931 : : RTE_FLOW_ITEM_TYPE_GRE,
932 : : RTE_FLOW_ITEM_TYPE_MPLS,
933 : : RTE_FLOW_ITEM_TYPE_END,
934 : : };
935 : :
936 : : static enum rte_flow_item_type pattern_mpls_4[] = {
937 : : RTE_FLOW_ITEM_TYPE_ETH,
938 : : RTE_FLOW_ITEM_TYPE_IPV6,
939 : : RTE_FLOW_ITEM_TYPE_GRE,
940 : : RTE_FLOW_ITEM_TYPE_MPLS,
941 : : RTE_FLOW_ITEM_TYPE_END,
942 : : };
943 : :
944 : : static enum rte_flow_item_type pattern_qinq_1[] = {
945 : : RTE_FLOW_ITEM_TYPE_ETH,
946 : : RTE_FLOW_ITEM_TYPE_VLAN,
947 : : RTE_FLOW_ITEM_TYPE_VLAN,
948 : : RTE_FLOW_ITEM_TYPE_END,
949 : : };
950 : :
951 : : static enum rte_flow_item_type pattern_fdir_ipv4_l2tpv3oip[] = {
952 : : RTE_FLOW_ITEM_TYPE_ETH,
953 : : RTE_FLOW_ITEM_TYPE_IPV4,
954 : : RTE_FLOW_ITEM_TYPE_L2TPV3OIP,
955 : : RTE_FLOW_ITEM_TYPE_END,
956 : : };
957 : :
958 : : static enum rte_flow_item_type pattern_fdir_ipv6_l2tpv3oip[] = {
959 : : RTE_FLOW_ITEM_TYPE_ETH,
960 : : RTE_FLOW_ITEM_TYPE_IPV6,
961 : : RTE_FLOW_ITEM_TYPE_L2TPV3OIP,
962 : : RTE_FLOW_ITEM_TYPE_END,
963 : : };
964 : :
965 : : static enum rte_flow_item_type pattern_fdir_ipv4_esp[] = {
966 : : RTE_FLOW_ITEM_TYPE_ETH,
967 : : RTE_FLOW_ITEM_TYPE_IPV4,
968 : : RTE_FLOW_ITEM_TYPE_ESP,
969 : : RTE_FLOW_ITEM_TYPE_END,
970 : : };
971 : :
972 : : static enum rte_flow_item_type pattern_fdir_ipv6_esp[] = {
973 : : RTE_FLOW_ITEM_TYPE_ETH,
974 : : RTE_FLOW_ITEM_TYPE_IPV6,
975 : : RTE_FLOW_ITEM_TYPE_ESP,
976 : : RTE_FLOW_ITEM_TYPE_END,
977 : : };
978 : :
979 : : static enum rte_flow_item_type pattern_fdir_ipv4_udp_esp[] = {
980 : : RTE_FLOW_ITEM_TYPE_ETH,
981 : : RTE_FLOW_ITEM_TYPE_IPV4,
982 : : RTE_FLOW_ITEM_TYPE_UDP,
983 : : RTE_FLOW_ITEM_TYPE_ESP,
984 : : RTE_FLOW_ITEM_TYPE_END,
985 : : };
986 : :
987 : : static enum rte_flow_item_type pattern_fdir_ipv6_udp_esp[] = {
988 : : RTE_FLOW_ITEM_TYPE_ETH,
989 : : RTE_FLOW_ITEM_TYPE_IPV6,
990 : : RTE_FLOW_ITEM_TYPE_UDP,
991 : : RTE_FLOW_ITEM_TYPE_ESP,
992 : : RTE_FLOW_ITEM_TYPE_END,
993 : : };
994 : :
995 : : static struct i40e_valid_pattern i40e_supported_patterns[] = {
996 : : /* Ethertype */
997 : : { pattern_ethertype, i40e_flow_parse_ethertype_filter },
998 : : /* FDIR - support default flow type without flexible payload*/
999 : : { pattern_ethertype, i40e_flow_parse_fdir_filter },
1000 : : { pattern_fdir_ipv4, i40e_flow_parse_fdir_filter },
1001 : : { pattern_fdir_ipv4_udp, i40e_flow_parse_fdir_filter },
1002 : : { pattern_fdir_ipv4_tcp, i40e_flow_parse_fdir_filter },
1003 : : { pattern_fdir_ipv4_sctp, i40e_flow_parse_fdir_filter },
1004 : : { pattern_fdir_ipv4_gtpc, i40e_flow_parse_fdir_filter },
1005 : : { pattern_fdir_ipv4_gtpu, i40e_flow_parse_fdir_filter },
1006 : : { pattern_fdir_ipv4_gtpu_ipv4, i40e_flow_parse_fdir_filter },
1007 : : { pattern_fdir_ipv4_gtpu_ipv6, i40e_flow_parse_fdir_filter },
1008 : : { pattern_fdir_ipv4_esp, i40e_flow_parse_fdir_filter },
1009 : : { pattern_fdir_ipv4_udp_esp, i40e_flow_parse_fdir_filter },
1010 : : { pattern_fdir_ipv6, i40e_flow_parse_fdir_filter },
1011 : : { pattern_fdir_ipv6_udp, i40e_flow_parse_fdir_filter },
1012 : : { pattern_fdir_ipv6_tcp, i40e_flow_parse_fdir_filter },
1013 : : { pattern_fdir_ipv6_sctp, i40e_flow_parse_fdir_filter },
1014 : : { pattern_fdir_ipv6_gtpc, i40e_flow_parse_fdir_filter },
1015 : : { pattern_fdir_ipv6_gtpu, i40e_flow_parse_fdir_filter },
1016 : : { pattern_fdir_ipv6_gtpu_ipv4, i40e_flow_parse_fdir_filter },
1017 : : { pattern_fdir_ipv6_gtpu_ipv6, i40e_flow_parse_fdir_filter },
1018 : : { pattern_fdir_ipv6_esp, i40e_flow_parse_fdir_filter },
1019 : : { pattern_fdir_ipv6_udp_esp, i40e_flow_parse_fdir_filter },
1020 : : /* FDIR - support default flow type with flexible payload */
1021 : : { pattern_fdir_ethertype_raw_1, i40e_flow_parse_fdir_filter },
1022 : : { pattern_fdir_ethertype_raw_2, i40e_flow_parse_fdir_filter },
1023 : : { pattern_fdir_ethertype_raw_3, i40e_flow_parse_fdir_filter },
1024 : : { pattern_fdir_ipv4_raw_1, i40e_flow_parse_fdir_filter },
1025 : : { pattern_fdir_ipv4_raw_2, i40e_flow_parse_fdir_filter },
1026 : : { pattern_fdir_ipv4_raw_3, i40e_flow_parse_fdir_filter },
1027 : : { pattern_fdir_ipv4_udp_raw_1, i40e_flow_parse_fdir_filter },
1028 : : { pattern_fdir_ipv4_udp_raw_2, i40e_flow_parse_fdir_filter },
1029 : : { pattern_fdir_ipv4_udp_raw_3, i40e_flow_parse_fdir_filter },
1030 : : { pattern_fdir_ipv4_tcp_raw_1, i40e_flow_parse_fdir_filter },
1031 : : { pattern_fdir_ipv4_tcp_raw_2, i40e_flow_parse_fdir_filter },
1032 : : { pattern_fdir_ipv4_tcp_raw_3, i40e_flow_parse_fdir_filter },
1033 : : { pattern_fdir_ipv4_sctp_raw_1, i40e_flow_parse_fdir_filter },
1034 : : { pattern_fdir_ipv4_sctp_raw_2, i40e_flow_parse_fdir_filter },
1035 : : { pattern_fdir_ipv4_sctp_raw_3, i40e_flow_parse_fdir_filter },
1036 : : { pattern_fdir_ipv6_raw_1, i40e_flow_parse_fdir_filter },
1037 : : { pattern_fdir_ipv6_raw_2, i40e_flow_parse_fdir_filter },
1038 : : { pattern_fdir_ipv6_raw_3, i40e_flow_parse_fdir_filter },
1039 : : { pattern_fdir_ipv6_udp_raw_1, i40e_flow_parse_fdir_filter },
1040 : : { pattern_fdir_ipv6_udp_raw_2, i40e_flow_parse_fdir_filter },
1041 : : { pattern_fdir_ipv6_udp_raw_3, i40e_flow_parse_fdir_filter },
1042 : : { pattern_fdir_ipv6_tcp_raw_1, i40e_flow_parse_fdir_filter },
1043 : : { pattern_fdir_ipv6_tcp_raw_2, i40e_flow_parse_fdir_filter },
1044 : : { pattern_fdir_ipv6_tcp_raw_3, i40e_flow_parse_fdir_filter },
1045 : : { pattern_fdir_ipv6_sctp_raw_1, i40e_flow_parse_fdir_filter },
1046 : : { pattern_fdir_ipv6_sctp_raw_2, i40e_flow_parse_fdir_filter },
1047 : : { pattern_fdir_ipv6_sctp_raw_3, i40e_flow_parse_fdir_filter },
1048 : : /* FDIR - support single vlan input set */
1049 : : { pattern_fdir_ethertype_vlan, i40e_flow_parse_fdir_filter },
1050 : : { pattern_fdir_vlan_ipv4, i40e_flow_parse_fdir_filter },
1051 : : { pattern_fdir_vlan_ipv4_udp, i40e_flow_parse_fdir_filter },
1052 : : { pattern_fdir_vlan_ipv4_tcp, i40e_flow_parse_fdir_filter },
1053 : : { pattern_fdir_vlan_ipv4_sctp, i40e_flow_parse_fdir_filter },
1054 : : { pattern_fdir_vlan_ipv6, i40e_flow_parse_fdir_filter },
1055 : : { pattern_fdir_vlan_ipv6_udp, i40e_flow_parse_fdir_filter },
1056 : : { pattern_fdir_vlan_ipv6_tcp, i40e_flow_parse_fdir_filter },
1057 : : { pattern_fdir_vlan_ipv6_sctp, i40e_flow_parse_fdir_filter },
1058 : : { pattern_fdir_ethertype_vlan_raw_1, i40e_flow_parse_fdir_filter },
1059 : : { pattern_fdir_ethertype_vlan_raw_2, i40e_flow_parse_fdir_filter },
1060 : : { pattern_fdir_ethertype_vlan_raw_3, i40e_flow_parse_fdir_filter },
1061 : : { pattern_fdir_vlan_ipv4_raw_1, i40e_flow_parse_fdir_filter },
1062 : : { pattern_fdir_vlan_ipv4_raw_2, i40e_flow_parse_fdir_filter },
1063 : : { pattern_fdir_vlan_ipv4_raw_3, i40e_flow_parse_fdir_filter },
1064 : : { pattern_fdir_vlan_ipv4_udp_raw_1, i40e_flow_parse_fdir_filter },
1065 : : { pattern_fdir_vlan_ipv4_udp_raw_2, i40e_flow_parse_fdir_filter },
1066 : : { pattern_fdir_vlan_ipv4_udp_raw_3, i40e_flow_parse_fdir_filter },
1067 : : { pattern_fdir_vlan_ipv4_tcp_raw_1, i40e_flow_parse_fdir_filter },
1068 : : { pattern_fdir_vlan_ipv4_tcp_raw_2, i40e_flow_parse_fdir_filter },
1069 : : { pattern_fdir_vlan_ipv4_tcp_raw_3, i40e_flow_parse_fdir_filter },
1070 : : { pattern_fdir_vlan_ipv4_sctp_raw_1, i40e_flow_parse_fdir_filter },
1071 : : { pattern_fdir_vlan_ipv4_sctp_raw_2, i40e_flow_parse_fdir_filter },
1072 : : { pattern_fdir_vlan_ipv4_sctp_raw_3, i40e_flow_parse_fdir_filter },
1073 : : { pattern_fdir_vlan_ipv6_raw_1, i40e_flow_parse_fdir_filter },
1074 : : { pattern_fdir_vlan_ipv6_raw_2, i40e_flow_parse_fdir_filter },
1075 : : { pattern_fdir_vlan_ipv6_raw_3, i40e_flow_parse_fdir_filter },
1076 : : { pattern_fdir_vlan_ipv6_udp_raw_1, i40e_flow_parse_fdir_filter },
1077 : : { pattern_fdir_vlan_ipv6_udp_raw_2, i40e_flow_parse_fdir_filter },
1078 : : { pattern_fdir_vlan_ipv6_udp_raw_3, i40e_flow_parse_fdir_filter },
1079 : : { pattern_fdir_vlan_ipv6_tcp_raw_1, i40e_flow_parse_fdir_filter },
1080 : : { pattern_fdir_vlan_ipv6_tcp_raw_2, i40e_flow_parse_fdir_filter },
1081 : : { pattern_fdir_vlan_ipv6_tcp_raw_3, i40e_flow_parse_fdir_filter },
1082 : : { pattern_fdir_vlan_ipv6_sctp_raw_1, i40e_flow_parse_fdir_filter },
1083 : : { pattern_fdir_vlan_ipv6_sctp_raw_2, i40e_flow_parse_fdir_filter },
1084 : : { pattern_fdir_vlan_ipv6_sctp_raw_3, i40e_flow_parse_fdir_filter },
1085 : : /* VXLAN */
1086 : : { pattern_vxlan_1, i40e_flow_parse_vxlan_filter },
1087 : : { pattern_vxlan_2, i40e_flow_parse_vxlan_filter },
1088 : : { pattern_vxlan_3, i40e_flow_parse_vxlan_filter },
1089 : : { pattern_vxlan_4, i40e_flow_parse_vxlan_filter },
1090 : : /* NVGRE */
1091 : : { pattern_nvgre_1, i40e_flow_parse_nvgre_filter },
1092 : : { pattern_nvgre_2, i40e_flow_parse_nvgre_filter },
1093 : : { pattern_nvgre_3, i40e_flow_parse_nvgre_filter },
1094 : : { pattern_nvgre_4, i40e_flow_parse_nvgre_filter },
1095 : : /* MPLSoUDP & MPLSoGRE */
1096 : : { pattern_mpls_1, i40e_flow_parse_mpls_filter },
1097 : : { pattern_mpls_2, i40e_flow_parse_mpls_filter },
1098 : : { pattern_mpls_3, i40e_flow_parse_mpls_filter },
1099 : : { pattern_mpls_4, i40e_flow_parse_mpls_filter },
1100 : : /* GTP-C & GTP-U */
1101 : : { pattern_fdir_ipv4_gtpc, i40e_flow_parse_gtp_filter },
1102 : : { pattern_fdir_ipv4_gtpu, i40e_flow_parse_gtp_filter },
1103 : : { pattern_fdir_ipv6_gtpc, i40e_flow_parse_gtp_filter },
1104 : : { pattern_fdir_ipv6_gtpu, i40e_flow_parse_gtp_filter },
1105 : : /* QINQ */
1106 : : { pattern_qinq_1, i40e_flow_parse_qinq_filter },
1107 : : /* L2TPv3 over IP */
1108 : : { pattern_fdir_ipv4_l2tpv3oip, i40e_flow_parse_fdir_filter },
1109 : : { pattern_fdir_ipv6_l2tpv3oip, i40e_flow_parse_fdir_filter },
1110 : : /* L4 over port */
1111 : : { pattern_fdir_ipv4_udp, i40e_flow_parse_l4_cloud_filter },
1112 : : { pattern_fdir_ipv4_tcp, i40e_flow_parse_l4_cloud_filter },
1113 : : { pattern_fdir_ipv4_sctp, i40e_flow_parse_l4_cloud_filter },
1114 : : { pattern_fdir_ipv6_udp, i40e_flow_parse_l4_cloud_filter },
1115 : : { pattern_fdir_ipv6_tcp, i40e_flow_parse_l4_cloud_filter },
1116 : : { pattern_fdir_ipv6_sctp, i40e_flow_parse_l4_cloud_filter },
1117 : : };
1118 : :
1119 : : #define NEXT_ITEM_OF_ACTION(act, actions, index) \
1120 : : do { \
1121 : : act = actions + index; \
1122 : : while (act->type == RTE_FLOW_ACTION_TYPE_VOID) { \
1123 : : index++; \
1124 : : act = actions + index; \
1125 : : } \
1126 : : } while (0)
1127 : :
1128 : : /* Find the first VOID or non-VOID item pointer */
1129 : : static const struct rte_flow_item *
1130 : : i40e_find_first_item(const struct rte_flow_item *item, bool is_void)
1131 : : {
1132 : : bool is_find;
1133 : :
1134 [ # # # # ]: 0 : while (item->type != RTE_FLOW_ITEM_TYPE_END) {
1135 : : if (is_void)
1136 : : is_find = item->type == RTE_FLOW_ITEM_TYPE_VOID;
1137 : : else
1138 : : is_find = item->type != RTE_FLOW_ITEM_TYPE_VOID;
1139 [ # # # # ]: 0 : if (is_find)
1140 : : break;
1141 : 0 : item++;
1142 : : }
1143 : : return item;
1144 : : }
1145 : :
1146 : : /* Skip all VOID items of the pattern */
1147 : : static void
1148 : 0 : i40e_pattern_skip_void_item(struct rte_flow_item *items,
1149 : : const struct rte_flow_item *pattern)
1150 : : {
1151 : : uint32_t cpy_count = 0;
1152 : : const struct rte_flow_item *pb = pattern, *pe = pattern;
1153 : :
1154 : : for (;;) {
1155 : : /* Find a non-void item first */
1156 : 0 : pb = i40e_find_first_item(pb, false);
1157 [ # # ]: 0 : if (pb->type == RTE_FLOW_ITEM_TYPE_END) {
1158 : : pe = pb;
1159 : : break;
1160 : : }
1161 : :
1162 : : /* Find a void item */
1163 : 0 : pe = i40e_find_first_item(pb + 1, true);
1164 : :
1165 : 0 : cpy_count = pe - pb;
1166 [ # # ]: 0 : rte_memcpy(items, pb, sizeof(struct rte_flow_item) * cpy_count);
1167 : :
1168 : 0 : items += cpy_count;
1169 : :
1170 [ # # ]: 0 : if (pe->type == RTE_FLOW_ITEM_TYPE_END) {
1171 : : pb = pe;
1172 : : break;
1173 : : }
1174 : :
1175 : 0 : pb = pe + 1;
1176 : : }
1177 : : /* Copy the END item. */
1178 : : rte_memcpy(items, pe, sizeof(struct rte_flow_item));
1179 : 0 : }
1180 : :
1181 : : /* Check if the pattern matches a supported item type array */
1182 : : static bool
1183 : : i40e_match_pattern(enum rte_flow_item_type *item_array,
1184 : : struct rte_flow_item *pattern)
1185 : : {
1186 : : struct rte_flow_item *item = pattern;
1187 : :
1188 [ # # # # ]: 0 : while ((*item_array == item->type) &&
1189 : : (*item_array != RTE_FLOW_ITEM_TYPE_END)) {
1190 : 0 : item_array++;
1191 : 0 : item++;
1192 : : }
1193 : :
1194 [ # # # # ]: 0 : return (*item_array == RTE_FLOW_ITEM_TYPE_END &&
1195 : : item->type == RTE_FLOW_ITEM_TYPE_END);
1196 : : }
1197 : :
1198 : : /* Find if there's parse filter function matched */
1199 : : static parse_filter_t
1200 : 0 : i40e_find_parse_filter_func(struct rte_flow_item *pattern, uint32_t *idx)
1201 : : {
1202 : : parse_filter_t parse_filter = NULL;
1203 : 0 : uint8_t i = *idx;
1204 : :
1205 [ # # ]: 0 : for (; i < RTE_DIM(i40e_supported_patterns); i++) {
1206 [ # # ]: 0 : if (i40e_match_pattern(i40e_supported_patterns[i].items,
1207 : : pattern)) {
1208 : 0 : parse_filter = i40e_supported_patterns[i].parse_filter;
1209 : 0 : break;
1210 : : }
1211 : : }
1212 : :
1213 : 0 : *idx = ++i;
1214 : :
1215 : 0 : return parse_filter;
1216 : : }
1217 : :
1218 : : /* Parse attributes */
1219 : : static int
1220 : 0 : i40e_flow_parse_attr(const struct rte_flow_attr *attr,
1221 : : struct rte_flow_error *error)
1222 : : {
1223 : : /* Must be input direction */
1224 [ # # ]: 0 : if (!attr->ingress) {
1225 : 0 : rte_flow_error_set(error, EINVAL,
1226 : : RTE_FLOW_ERROR_TYPE_ATTR_INGRESS,
1227 : : attr, "Only support ingress.");
1228 : 0 : return -rte_errno;
1229 : : }
1230 : :
1231 : : /* Not supported */
1232 [ # # ]: 0 : if (attr->egress) {
1233 : 0 : rte_flow_error_set(error, EINVAL,
1234 : : RTE_FLOW_ERROR_TYPE_ATTR_EGRESS,
1235 : : attr, "Not support egress.");
1236 : 0 : return -rte_errno;
1237 : : }
1238 : :
1239 : : /* Not supported */
1240 [ # # ]: 0 : if (attr->transfer) {
1241 : 0 : rte_flow_error_set(error, EINVAL,
1242 : : RTE_FLOW_ERROR_TYPE_ATTR_TRANSFER,
1243 : : attr, "Not support transfer.");
1244 : 0 : return -rte_errno;
1245 : : }
1246 : :
1247 : : /* Not supported */
1248 [ # # ]: 0 : if (attr->priority) {
1249 : 0 : rte_flow_error_set(error, EINVAL,
1250 : : RTE_FLOW_ERROR_TYPE_ATTR_PRIORITY,
1251 : : attr, "Not support priority.");
1252 : 0 : return -rte_errno;
1253 : : }
1254 : :
1255 : : /* Not supported */
1256 [ # # ]: 0 : if (attr->group) {
1257 : 0 : rte_flow_error_set(error, EINVAL,
1258 : : RTE_FLOW_ERROR_TYPE_ATTR_GROUP,
1259 : : attr, "Not support group.");
1260 : 0 : return -rte_errno;
1261 : : }
1262 : :
1263 : : return 0;
1264 : : }
1265 : :
1266 : : static uint16_t
1267 : 0 : i40e_get_outer_vlan(struct rte_eth_dev *dev)
1268 : : {
1269 : 0 : struct i40e_hw *hw = I40E_DEV_PRIVATE_TO_HW(dev->data->dev_private);
1270 : 0 : int qinq = dev->data->dev_conf.rxmode.offloads &
1271 : : RTE_ETH_RX_OFFLOAD_VLAN_EXTEND;
1272 : 0 : uint64_t reg_r = 0;
1273 : : uint16_t reg_id;
1274 : : uint16_t tpid;
1275 : :
1276 [ # # ]: 0 : if (qinq)
1277 : : reg_id = 2;
1278 : : else
1279 : : reg_id = 3;
1280 : :
1281 : 0 : i40e_aq_debug_read_register(hw, I40E_GL_SWT_L2TAGCTRL(reg_id),
1282 : : ®_r, NULL);
1283 : :
1284 : 0 : tpid = (reg_r >> I40E_GL_SWT_L2TAGCTRL_ETHERTYPE_SHIFT) & 0xFFFF;
1285 : :
1286 : 0 : return tpid;
1287 : : }
1288 : :
1289 : : /* 1. Last in item should be NULL as range is not supported.
1290 : : * 2. Supported filter types: MAC_ETHTYPE and ETHTYPE.
1291 : : * 3. SRC mac_addr mask should be 00:00:00:00:00:00.
1292 : : * 4. DST mac_addr mask should be 00:00:00:00:00:00 or
1293 : : * FF:FF:FF:FF:FF:FF
1294 : : * 5. Ether_type mask should be 0xFFFF.
1295 : : */
1296 : : static int
1297 : 0 : i40e_flow_parse_ethertype_pattern(struct rte_eth_dev *dev,
1298 : : const struct rte_flow_item *pattern,
1299 : : struct rte_flow_error *error,
1300 : : struct rte_eth_ethertype_filter *filter)
1301 : : {
1302 : : const struct rte_flow_item *item = pattern;
1303 : : const struct rte_flow_item_eth *eth_spec;
1304 : : const struct rte_flow_item_eth *eth_mask;
1305 : : enum rte_flow_item_type item_type;
1306 : :
1307 [ # # ]: 0 : for (; item->type != RTE_FLOW_ITEM_TYPE_END; item++) {
1308 [ # # ]: 0 : if (item->last) {
1309 : 0 : rte_flow_error_set(error, EINVAL,
1310 : : RTE_FLOW_ERROR_TYPE_ITEM,
1311 : : item,
1312 : : "Not support range");
1313 : 0 : return -rte_errno;
1314 : : }
1315 : : item_type = item->type;
1316 [ # # ]: 0 : switch (item_type) {
1317 : 0 : case RTE_FLOW_ITEM_TYPE_ETH:
1318 : 0 : eth_spec = item->spec;
1319 : 0 : eth_mask = item->mask;
1320 : : /* Get the MAC info. */
1321 [ # # ]: 0 : if (!eth_spec || !eth_mask) {
1322 : 0 : rte_flow_error_set(error, EINVAL,
1323 : : RTE_FLOW_ERROR_TYPE_ITEM,
1324 : : item,
1325 : : "NULL ETH spec/mask");
1326 : 0 : return -rte_errno;
1327 : : }
1328 : :
1329 : : /* Mask bits of source MAC address must be full of 0.
1330 : : * Mask bits of destination MAC address must be full
1331 : : * of 1 or full of 0.
1332 : : */
1333 [ # # # # ]: 0 : if (!rte_is_zero_ether_addr(ð_mask->hdr.src_addr) ||
1334 [ # # ]: 0 : (!rte_is_zero_ether_addr(ð_mask->hdr.dst_addr) &&
1335 : : !rte_is_broadcast_ether_addr(ð_mask->hdr.dst_addr))) {
1336 : 0 : rte_flow_error_set(error, EINVAL,
1337 : : RTE_FLOW_ERROR_TYPE_ITEM,
1338 : : item,
1339 : : "Invalid MAC_addr mask");
1340 : 0 : return -rte_errno;
1341 : : }
1342 : :
1343 [ # # ]: 0 : if ((eth_mask->hdr.ether_type & UINT16_MAX) != UINT16_MAX) {
1344 : 0 : rte_flow_error_set(error, EINVAL,
1345 : : RTE_FLOW_ERROR_TYPE_ITEM,
1346 : : item,
1347 : : "Invalid ethertype mask");
1348 : 0 : return -rte_errno;
1349 : : }
1350 : :
1351 : : /* If mask bits of destination MAC address
1352 : : * are full of 1, set RTE_ETHTYPE_FLAGS_MAC.
1353 : : */
1354 [ # # ]: 0 : if (rte_is_broadcast_ether_addr(ð_mask->hdr.dst_addr)) {
1355 : 0 : filter->mac_addr = eth_spec->hdr.dst_addr;
1356 : 0 : filter->flags |= RTE_ETHTYPE_FLAGS_MAC;
1357 : : } else {
1358 : 0 : filter->flags &= ~RTE_ETHTYPE_FLAGS_MAC;
1359 : : }
1360 [ # # ]: 0 : filter->ether_type = rte_be_to_cpu_16(eth_spec->hdr.ether_type);
1361 : :
1362 [ # # ]: 0 : if (filter->ether_type == RTE_ETHER_TYPE_IPV4 ||
1363 [ # # ]: 0 : filter->ether_type == RTE_ETHER_TYPE_IPV6 ||
1364 [ # # ]: 0 : filter->ether_type == RTE_ETHER_TYPE_LLDP ||
1365 : 0 : filter->ether_type == i40e_get_outer_vlan(dev)) {
1366 : 0 : rte_flow_error_set(error, EINVAL,
1367 : : RTE_FLOW_ERROR_TYPE_ITEM,
1368 : : item,
1369 : : "Unsupported ether_type in"
1370 : : " control packet filter.");
1371 : 0 : return -rte_errno;
1372 : : }
1373 : : break;
1374 : : default:
1375 : : break;
1376 : : }
1377 : : }
1378 : :
1379 : : return 0;
1380 : : }
1381 : :
1382 : : /* Ethertype action only supports QUEUE or DROP. */
1383 : : static int
1384 : 0 : i40e_flow_parse_ethertype_action(struct rte_eth_dev *dev,
1385 : : const struct rte_flow_action *actions,
1386 : : struct rte_flow_error *error,
1387 : : struct rte_eth_ethertype_filter *filter)
1388 : : {
1389 : 0 : struct i40e_pf *pf = I40E_DEV_PRIVATE_TO_PF(dev->data->dev_private);
1390 : : const struct rte_flow_action *act;
1391 : : const struct rte_flow_action_queue *act_q;
1392 : : uint32_t index = 0;
1393 : :
1394 : : /* Check if the first non-void action is QUEUE or DROP. */
1395 [ # # ]: 0 : NEXT_ITEM_OF_ACTION(act, actions, index);
1396 [ # # ]: 0 : if (act->type != RTE_FLOW_ACTION_TYPE_QUEUE &&
1397 : : act->type != RTE_FLOW_ACTION_TYPE_DROP) {
1398 : 0 : rte_flow_error_set(error, EINVAL, RTE_FLOW_ERROR_TYPE_ACTION,
1399 : : act, "Not supported action.");
1400 : 0 : return -rte_errno;
1401 : : }
1402 : :
1403 [ # # ]: 0 : if (act->type == RTE_FLOW_ACTION_TYPE_QUEUE) {
1404 : 0 : act_q = act->conf;
1405 : 0 : filter->queue = act_q->index;
1406 [ # # ]: 0 : if (filter->queue >= pf->dev_data->nb_rx_queues) {
1407 : 0 : rte_flow_error_set(error, EINVAL,
1408 : : RTE_FLOW_ERROR_TYPE_ACTION,
1409 : : act, "Invalid queue ID for"
1410 : : " ethertype_filter.");
1411 : 0 : return -rte_errno;
1412 : : }
1413 : : } else {
1414 : 0 : filter->flags |= RTE_ETHTYPE_FLAGS_DROP;
1415 : : }
1416 : :
1417 : : /* Check if the next non-void item is END */
1418 : 0 : index++;
1419 [ # # ]: 0 : NEXT_ITEM_OF_ACTION(act, actions, index);
1420 [ # # ]: 0 : if (act->type != RTE_FLOW_ACTION_TYPE_END) {
1421 : 0 : rte_flow_error_set(error, EINVAL, RTE_FLOW_ERROR_TYPE_ACTION,
1422 : : act, "Not supported action.");
1423 : 0 : return -rte_errno;
1424 : : }
1425 : :
1426 : : return 0;
1427 : : }
1428 : :
1429 : : static int
1430 : 0 : i40e_flow_parse_ethertype_filter(struct rte_eth_dev *dev,
1431 : : const struct rte_flow_attr *attr,
1432 : : const struct rte_flow_item pattern[],
1433 : : const struct rte_flow_action actions[],
1434 : : struct rte_flow_error *error,
1435 : : union i40e_filter_t *filter)
1436 : : {
1437 : 0 : struct rte_eth_ethertype_filter *ethertype_filter =
1438 : : &filter->ethertype_filter;
1439 : : int ret;
1440 : :
1441 : 0 : ret = i40e_flow_parse_ethertype_pattern(dev, pattern, error,
1442 : : ethertype_filter);
1443 [ # # ]: 0 : if (ret)
1444 : : return ret;
1445 : :
1446 : 0 : ret = i40e_flow_parse_ethertype_action(dev, actions, error,
1447 : : ethertype_filter);
1448 [ # # ]: 0 : if (ret)
1449 : : return ret;
1450 : :
1451 : 0 : ret = i40e_flow_parse_attr(attr, error);
1452 [ # # ]: 0 : if (ret)
1453 : : return ret;
1454 : :
1455 : 0 : cons_filter_type = RTE_ETH_FILTER_ETHERTYPE;
1456 : :
1457 : 0 : return ret;
1458 : : }
1459 : :
1460 : : static int
1461 : 0 : i40e_flow_check_raw_item(const struct rte_flow_item *item,
1462 : : const struct rte_flow_item_raw *raw_spec,
1463 : : struct rte_flow_error *error)
1464 : : {
1465 [ # # ]: 0 : if (!raw_spec->relative) {
1466 : 0 : rte_flow_error_set(error, EINVAL,
1467 : : RTE_FLOW_ERROR_TYPE_ITEM,
1468 : : item,
1469 : : "Relative should be 1.");
1470 : 0 : return -rte_errno;
1471 : : }
1472 : :
1473 [ # # ]: 0 : if (raw_spec->offset % sizeof(uint16_t)) {
1474 : 0 : rte_flow_error_set(error, EINVAL,
1475 : : RTE_FLOW_ERROR_TYPE_ITEM,
1476 : : item,
1477 : : "Offset should be even.");
1478 : 0 : return -rte_errno;
1479 : : }
1480 : :
1481 [ # # # # ]: 0 : if (raw_spec->search || raw_spec->limit) {
1482 : 0 : rte_flow_error_set(error, EINVAL,
1483 : : RTE_FLOW_ERROR_TYPE_ITEM,
1484 : : item,
1485 : : "search or limit is not supported.");
1486 : 0 : return -rte_errno;
1487 : : }
1488 : :
1489 [ # # ]: 0 : if (raw_spec->offset < 0) {
1490 : 0 : rte_flow_error_set(error, EINVAL,
1491 : : RTE_FLOW_ERROR_TYPE_ITEM,
1492 : : item,
1493 : : "Offset should be non-negative.");
1494 : 0 : return -rte_errno;
1495 : : }
1496 : : return 0;
1497 : : }
1498 : :
1499 : :
1500 : : static uint8_t
1501 : 0 : i40e_flow_fdir_get_pctype_value(struct i40e_pf *pf,
1502 : : enum rte_flow_item_type item_type,
1503 : : struct i40e_fdir_filter_conf *filter)
1504 : : {
1505 : : struct i40e_customized_pctype *cus_pctype = NULL;
1506 : :
1507 [ # # # # : 0 : switch (item_type) {
# ]
1508 : 0 : case RTE_FLOW_ITEM_TYPE_GTPC:
1509 : 0 : cus_pctype = i40e_find_customized_pctype(pf,
1510 : : I40E_CUSTOMIZED_GTPC);
1511 : 0 : break;
1512 : 0 : case RTE_FLOW_ITEM_TYPE_GTPU:
1513 [ # # ]: 0 : if (!filter->input.flow_ext.inner_ip)
1514 : 0 : cus_pctype = i40e_find_customized_pctype(pf,
1515 : : I40E_CUSTOMIZED_GTPU);
1516 [ # # ]: 0 : else if (filter->input.flow_ext.iip_type ==
1517 : : I40E_FDIR_IPTYPE_IPV4)
1518 : 0 : cus_pctype = i40e_find_customized_pctype(pf,
1519 : : I40E_CUSTOMIZED_GTPU_IPV4);
1520 [ # # ]: 0 : else if (filter->input.flow_ext.iip_type ==
1521 : : I40E_FDIR_IPTYPE_IPV6)
1522 : 0 : cus_pctype = i40e_find_customized_pctype(pf,
1523 : : I40E_CUSTOMIZED_GTPU_IPV6);
1524 : : break;
1525 : 0 : case RTE_FLOW_ITEM_TYPE_L2TPV3OIP:
1526 [ # # ]: 0 : if (filter->input.flow_ext.oip_type == I40E_FDIR_IPTYPE_IPV4)
1527 : 0 : cus_pctype = i40e_find_customized_pctype(pf,
1528 : : I40E_CUSTOMIZED_IPV4_L2TPV3);
1529 [ # # ]: 0 : else if (filter->input.flow_ext.oip_type ==
1530 : : I40E_FDIR_IPTYPE_IPV6)
1531 : 0 : cus_pctype = i40e_find_customized_pctype(pf,
1532 : : I40E_CUSTOMIZED_IPV6_L2TPV3);
1533 : : break;
1534 : 0 : case RTE_FLOW_ITEM_TYPE_ESP:
1535 [ # # ]: 0 : if (!filter->input.flow_ext.is_udp) {
1536 [ # # ]: 0 : if (filter->input.flow_ext.oip_type ==
1537 : : I40E_FDIR_IPTYPE_IPV4)
1538 : 0 : cus_pctype = i40e_find_customized_pctype(pf,
1539 : : I40E_CUSTOMIZED_ESP_IPV4);
1540 [ # # ]: 0 : else if (filter->input.flow_ext.oip_type ==
1541 : : I40E_FDIR_IPTYPE_IPV6)
1542 : 0 : cus_pctype = i40e_find_customized_pctype(pf,
1543 : : I40E_CUSTOMIZED_ESP_IPV6);
1544 : : } else {
1545 [ # # ]: 0 : if (filter->input.flow_ext.oip_type ==
1546 : : I40E_FDIR_IPTYPE_IPV4)
1547 : 0 : cus_pctype = i40e_find_customized_pctype(pf,
1548 : : I40E_CUSTOMIZED_ESP_IPV4_UDP);
1549 [ # # ]: 0 : else if (filter->input.flow_ext.oip_type ==
1550 : : I40E_FDIR_IPTYPE_IPV6)
1551 : 0 : cus_pctype = i40e_find_customized_pctype(pf,
1552 : : I40E_CUSTOMIZED_ESP_IPV6_UDP);
1553 : 0 : filter->input.flow_ext.is_udp = false;
1554 : : }
1555 : : break;
1556 : 0 : default:
1557 : 0 : PMD_DRV_LOG(ERR, "Unsupported item type");
1558 : : break;
1559 : : }
1560 : :
1561 [ # # # # ]: 0 : if (cus_pctype && cus_pctype->valid)
1562 : 0 : return cus_pctype->pctype;
1563 : :
1564 : : return I40E_FILTER_PCTYPE_INVALID;
1565 : : }
1566 : :
1567 : : static void
1568 : : i40e_flow_set_filter_spi(struct i40e_fdir_filter_conf *filter,
1569 : : const struct rte_flow_item_esp *esp_spec)
1570 : : {
1571 [ # # ]: 0 : if (filter->input.flow_ext.oip_type ==
1572 : : I40E_FDIR_IPTYPE_IPV4) {
1573 [ # # ]: 0 : if (filter->input.flow_ext.is_udp)
1574 : 0 : filter->input.flow.esp_ipv4_udp_flow.spi =
1575 : 0 : esp_spec->hdr.spi;
1576 : : else
1577 : 0 : filter->input.flow.esp_ipv4_flow.spi =
1578 : 0 : esp_spec->hdr.spi;
1579 : : }
1580 [ # # ]: 0 : if (filter->input.flow_ext.oip_type ==
1581 : : I40E_FDIR_IPTYPE_IPV6) {
1582 [ # # ]: 0 : if (filter->input.flow_ext.is_udp)
1583 : 0 : filter->input.flow.esp_ipv6_udp_flow.spi =
1584 : 0 : esp_spec->hdr.spi;
1585 : : else
1586 : 0 : filter->input.flow.esp_ipv6_flow.spi =
1587 : 0 : esp_spec->hdr.spi;
1588 : : }
1589 : : }
1590 : :
1591 : : /* 1. Last in item should be NULL as range is not supported.
1592 : : * 2. Supported patterns: refer to array i40e_supported_patterns.
1593 : : * 3. Default supported flow type and input set: refer to array
1594 : : * valid_fdir_inset_table in i40e_ethdev.c.
1595 : : * 4. Mask of fields which need to be matched should be
1596 : : * filled with 1.
1597 : : * 5. Mask of fields which needn't to be matched should be
1598 : : * filled with 0.
1599 : : * 6. GTP profile supports GTPv1 only.
1600 : : * 7. GTP-C response message ('source_port' = 2123) is not supported.
1601 : : */
1602 : : static int
1603 : 0 : i40e_flow_parse_fdir_pattern(struct rte_eth_dev *dev,
1604 : : const struct rte_flow_item *pattern,
1605 : : struct rte_flow_error *error,
1606 : : struct i40e_fdir_filter_conf *filter)
1607 : : {
1608 : 0 : struct i40e_pf *pf = I40E_DEV_PRIVATE_TO_PF(dev->data->dev_private);
1609 : : const struct rte_flow_item *item = pattern;
1610 : : const struct rte_flow_item_eth *eth_spec, *eth_mask;
1611 : : const struct rte_flow_item_vlan *vlan_spec, *vlan_mask;
1612 : : const struct rte_flow_item_ipv4 *ipv4_spec, *ipv4_last, *ipv4_mask;
1613 : : const struct rte_flow_item_ipv6 *ipv6_spec, *ipv6_mask;
1614 : : const struct rte_flow_item_tcp *tcp_spec, *tcp_mask;
1615 : : const struct rte_flow_item_udp *udp_spec, *udp_mask;
1616 : : const struct rte_flow_item_sctp *sctp_spec, *sctp_mask;
1617 : : const struct rte_flow_item_gtp *gtp_spec, *gtp_mask;
1618 : : const struct rte_flow_item_esp *esp_spec, *esp_mask;
1619 : : const struct rte_flow_item_raw *raw_spec, *raw_mask;
1620 : : const struct rte_flow_item_l2tpv3oip *l2tpv3oip_spec, *l2tpv3oip_mask;
1621 : :
1622 : : uint8_t pctype = 0;
1623 : : uint64_t input_set = I40E_INSET_NONE;
1624 : : enum rte_flow_item_type item_type;
1625 : : enum rte_flow_item_type next_type;
1626 : : enum rte_flow_item_type l3 = RTE_FLOW_ITEM_TYPE_END;
1627 : : enum rte_flow_item_type cus_proto = RTE_FLOW_ITEM_TYPE_END;
1628 : : uint32_t i, j;
1629 : 0 : uint8_t ipv6_addr_mask[16] = {
1630 : : 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
1631 : : 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF };
1632 : : enum i40e_flxpld_layer_idx layer_idx = I40E_FLXPLD_L2_IDX;
1633 : : uint8_t raw_id = 0;
1634 : : int32_t off_arr[I40E_MAX_FLXPLD_FIED];
1635 : : uint16_t len_arr[I40E_MAX_FLXPLD_FIED];
1636 : : struct i40e_fdir_flex_pit flex_pit;
1637 : : uint8_t next_dst_off = 0;
1638 : : uint16_t flex_size;
1639 : : uint16_t ether_type;
1640 : : uint32_t vtc_flow_cpu;
1641 : : bool outer_ip = true;
1642 : : uint8_t field_idx;
1643 : : int ret;
1644 : :
1645 : : memset(off_arr, 0, sizeof(off_arr));
1646 : : memset(len_arr, 0, sizeof(len_arr));
1647 : 0 : filter->input.flow_ext.customized_pctype = false;
1648 [ # # ]: 0 : for (; item->type != RTE_FLOW_ITEM_TYPE_END; item++) {
1649 [ # # # # ]: 0 : if (item->last && item->type != RTE_FLOW_ITEM_TYPE_IPV4) {
1650 : 0 : rte_flow_error_set(error, EINVAL,
1651 : : RTE_FLOW_ERROR_TYPE_ITEM,
1652 : : item,
1653 : : "Not support range");
1654 : 0 : return -rte_errno;
1655 : : }
1656 : : item_type = item->type;
1657 [ # # # # : 0 : switch (item_type) {
# # # # #
# # # ]
1658 : 0 : case RTE_FLOW_ITEM_TYPE_ETH:
1659 : 0 : eth_spec = item->spec;
1660 : 0 : eth_mask = item->mask;
1661 : 0 : next_type = (item + 1)->type;
1662 : :
1663 [ # # ]: 0 : if (next_type == RTE_FLOW_ITEM_TYPE_END &&
1664 [ # # ]: 0 : (!eth_spec || !eth_mask)) {
1665 : 0 : rte_flow_error_set(error, EINVAL,
1666 : : RTE_FLOW_ERROR_TYPE_ITEM,
1667 : : item,
1668 : : "NULL eth spec/mask.");
1669 : 0 : return -rte_errno;
1670 : : }
1671 : :
1672 [ # # ]: 0 : if (eth_spec && eth_mask) {
1673 [ # # # # ]: 0 : if (rte_is_broadcast_ether_addr(ð_mask->hdr.dst_addr) &&
1674 : : rte_is_zero_ether_addr(ð_mask->hdr.src_addr)) {
1675 : 0 : filter->input.flow.l2_flow.dst =
1676 : : eth_spec->hdr.dst_addr;
1677 : 0 : input_set |= I40E_INSET_DMAC;
1678 [ # # # # ]: 0 : } else if (rte_is_zero_ether_addr(ð_mask->hdr.dst_addr) &&
1679 : : rte_is_broadcast_ether_addr(ð_mask->hdr.src_addr)) {
1680 : 0 : filter->input.flow.l2_flow.src =
1681 : : eth_spec->hdr.src_addr;
1682 : 0 : input_set |= I40E_INSET_SMAC;
1683 [ # # # # ]: 0 : } else if (rte_is_broadcast_ether_addr(ð_mask->hdr.dst_addr) &&
1684 : : rte_is_broadcast_ether_addr(ð_mask->hdr.src_addr)) {
1685 : 0 : filter->input.flow.l2_flow.dst =
1686 : : eth_spec->hdr.dst_addr;
1687 : 0 : filter->input.flow.l2_flow.src =
1688 : : eth_spec->hdr.src_addr;
1689 : 0 : input_set |= (I40E_INSET_DMAC | I40E_INSET_SMAC);
1690 [ # # # # ]: 0 : } else if (!rte_is_zero_ether_addr(ð_mask->hdr.src_addr) ||
1691 : : !rte_is_zero_ether_addr(ð_mask->hdr.dst_addr)) {
1692 : 0 : rte_flow_error_set(error, EINVAL,
1693 : : RTE_FLOW_ERROR_TYPE_ITEM,
1694 : : item,
1695 : : "Invalid MAC_addr mask.");
1696 : 0 : return -rte_errno;
1697 : : }
1698 : : }
1699 [ # # # # ]: 0 : if (eth_spec && eth_mask &&
1700 : : next_type == RTE_FLOW_ITEM_TYPE_END) {
1701 [ # # ]: 0 : if (eth_mask->hdr.ether_type != RTE_BE16(0xffff)) {
1702 : 0 : rte_flow_error_set(error, EINVAL,
1703 : : RTE_FLOW_ERROR_TYPE_ITEM,
1704 : : item,
1705 : : "Invalid type mask.");
1706 : 0 : return -rte_errno;
1707 : : }
1708 : :
1709 [ # # ]: 0 : ether_type = rte_be_to_cpu_16(eth_spec->hdr.ether_type);
1710 : :
1711 : 0 : if (ether_type == RTE_ETHER_TYPE_IPV4 ||
1712 [ # # # # ]: 0 : ether_type == RTE_ETHER_TYPE_IPV6 ||
1713 : 0 : ether_type == i40e_get_outer_vlan(dev)) {
1714 : 0 : rte_flow_error_set(error, EINVAL,
1715 : : RTE_FLOW_ERROR_TYPE_ITEM,
1716 : : item,
1717 : : "Unsupported ether_type.");
1718 : 0 : return -rte_errno;
1719 : : }
1720 : 0 : input_set |= I40E_INSET_LAST_ETHER_TYPE;
1721 : 0 : filter->input.flow.l2_flow.ether_type =
1722 : 0 : eth_spec->hdr.ether_type;
1723 : : }
1724 : :
1725 : : pctype = I40E_FILTER_PCTYPE_L2_PAYLOAD;
1726 : : layer_idx = I40E_FLXPLD_L2_IDX;
1727 : :
1728 : : break;
1729 : 0 : case RTE_FLOW_ITEM_TYPE_VLAN:
1730 : 0 : vlan_spec = item->spec;
1731 : 0 : vlan_mask = item->mask;
1732 : :
1733 : : RTE_ASSERT(!(input_set & I40E_INSET_LAST_ETHER_TYPE));
1734 [ # # ]: 0 : if (vlan_spec && vlan_mask) {
1735 [ # # ]: 0 : if (vlan_mask->hdr.vlan_tci !=
1736 [ # # ]: 0 : rte_cpu_to_be_16(I40E_VLAN_TCI_MASK) &&
1737 : : vlan_mask->hdr.vlan_tci !=
1738 [ # # ]: 0 : rte_cpu_to_be_16(I40E_VLAN_PRI_MASK) &&
1739 : : vlan_mask->hdr.vlan_tci !=
1740 [ # # ]: 0 : rte_cpu_to_be_16(I40E_VLAN_CFI_MASK) &&
1741 : : vlan_mask->hdr.vlan_tci !=
1742 : : rte_cpu_to_be_16(I40E_VLAN_VID_MASK)) {
1743 : 0 : rte_flow_error_set(error, EINVAL,
1744 : : RTE_FLOW_ERROR_TYPE_ITEM,
1745 : : item,
1746 : : "Unsupported TCI mask.");
1747 : : }
1748 : 0 : input_set |= I40E_INSET_VLAN_INNER;
1749 : 0 : filter->input.flow_ext.vlan_tci =
1750 : 0 : vlan_spec->hdr.vlan_tci;
1751 : : }
1752 [ # # # # ]: 0 : if (vlan_spec && vlan_mask && vlan_mask->hdr.eth_proto) {
1753 [ # # ]: 0 : if (vlan_mask->hdr.eth_proto != RTE_BE16(0xffff)) {
1754 : 0 : rte_flow_error_set(error, EINVAL,
1755 : : RTE_FLOW_ERROR_TYPE_ITEM,
1756 : : item,
1757 : : "Invalid inner_type"
1758 : : " mask.");
1759 : 0 : return -rte_errno;
1760 : : }
1761 : :
1762 : : ether_type =
1763 [ # # ]: 0 : rte_be_to_cpu_16(vlan_spec->hdr.eth_proto);
1764 : :
1765 : 0 : if (ether_type == RTE_ETHER_TYPE_IPV4 ||
1766 [ # # # # ]: 0 : ether_type == RTE_ETHER_TYPE_IPV6 ||
1767 : 0 : ether_type == i40e_get_outer_vlan(dev)) {
1768 : 0 : rte_flow_error_set(error, EINVAL,
1769 : : RTE_FLOW_ERROR_TYPE_ITEM,
1770 : : item,
1771 : : "Unsupported inner_type.");
1772 : 0 : return -rte_errno;
1773 : : }
1774 : 0 : input_set |= I40E_INSET_LAST_ETHER_TYPE;
1775 : 0 : filter->input.flow.l2_flow.ether_type =
1776 : 0 : vlan_spec->hdr.eth_proto;
1777 : : }
1778 : :
1779 : : pctype = I40E_FILTER_PCTYPE_L2_PAYLOAD;
1780 : : layer_idx = I40E_FLXPLD_L2_IDX;
1781 : :
1782 : : break;
1783 : 0 : case RTE_FLOW_ITEM_TYPE_IPV4:
1784 : : l3 = RTE_FLOW_ITEM_TYPE_IPV4;
1785 : 0 : ipv4_spec = item->spec;
1786 : 0 : ipv4_mask = item->mask;
1787 : : ipv4_last = item->last;
1788 : : pctype = I40E_FILTER_PCTYPE_NONF_IPV4_OTHER;
1789 : : layer_idx = I40E_FLXPLD_L3_IDX;
1790 : :
1791 [ # # ]: 0 : if (ipv4_last) {
1792 [ # # # # ]: 0 : if (!ipv4_spec || !ipv4_mask || !outer_ip) {
1793 : 0 : rte_flow_error_set(error, EINVAL,
1794 : : RTE_FLOW_ERROR_TYPE_ITEM,
1795 : : item,
1796 : : "Not support range");
1797 : 0 : return -rte_errno;
1798 : : }
1799 : : /* Only fragment_offset supports range */
1800 [ # # ]: 0 : if (ipv4_last->hdr.version_ihl ||
1801 [ # # ]: 0 : ipv4_last->hdr.type_of_service ||
1802 [ # # ]: 0 : ipv4_last->hdr.total_length ||
1803 [ # # ]: 0 : ipv4_last->hdr.packet_id ||
1804 [ # # ]: 0 : ipv4_last->hdr.time_to_live ||
1805 [ # # ]: 0 : ipv4_last->hdr.next_proto_id ||
1806 [ # # ]: 0 : ipv4_last->hdr.hdr_checksum ||
1807 [ # # ]: 0 : ipv4_last->hdr.src_addr ||
1808 [ # # ]: 0 : ipv4_last->hdr.dst_addr) {
1809 : 0 : rte_flow_error_set(error, EINVAL,
1810 : : RTE_FLOW_ERROR_TYPE_ITEM,
1811 : : item,
1812 : : "Not support range");
1813 : 0 : return -rte_errno;
1814 : : }
1815 : : }
1816 [ # # # # ]: 0 : if (ipv4_spec && ipv4_mask && outer_ip) {
1817 : : /* Check IPv4 mask and update input set */
1818 [ # # ]: 0 : if (ipv4_mask->hdr.version_ihl ||
1819 [ # # ]: 0 : ipv4_mask->hdr.total_length ||
1820 [ # # ]: 0 : ipv4_mask->hdr.packet_id ||
1821 [ # # ]: 0 : ipv4_mask->hdr.hdr_checksum) {
1822 : 0 : rte_flow_error_set(error, EINVAL,
1823 : : RTE_FLOW_ERROR_TYPE_ITEM,
1824 : : item,
1825 : : "Invalid IPv4 mask.");
1826 : 0 : return -rte_errno;
1827 : : }
1828 : :
1829 [ # # ]: 0 : if (ipv4_mask->hdr.src_addr == UINT32_MAX)
1830 : 0 : input_set |= I40E_INSET_IPV4_SRC;
1831 [ # # ]: 0 : if (ipv4_mask->hdr.dst_addr == UINT32_MAX)
1832 : 0 : input_set |= I40E_INSET_IPV4_DST;
1833 [ # # ]: 0 : if (ipv4_mask->hdr.type_of_service == UINT8_MAX)
1834 : 0 : input_set |= I40E_INSET_IPV4_TOS;
1835 [ # # ]: 0 : if (ipv4_mask->hdr.time_to_live == UINT8_MAX)
1836 : 0 : input_set |= I40E_INSET_IPV4_TTL;
1837 [ # # ]: 0 : if (ipv4_mask->hdr.next_proto_id == UINT8_MAX)
1838 : 0 : input_set |= I40E_INSET_IPV4_PROTO;
1839 : :
1840 : : /* Check if it is fragment. */
1841 : 0 : uint16_t frag_mask =
1842 : : ipv4_mask->hdr.fragment_offset;
1843 : 0 : uint16_t frag_spec =
1844 : : ipv4_spec->hdr.fragment_offset;
1845 : : uint16_t frag_last = 0;
1846 [ # # ]: 0 : if (ipv4_last)
1847 : 0 : frag_last =
1848 : : ipv4_last->hdr.fragment_offset;
1849 [ # # ]: 0 : if (frag_mask) {
1850 [ # # ]: 0 : frag_mask = rte_be_to_cpu_16(frag_mask);
1851 [ # # ]: 0 : frag_spec = rte_be_to_cpu_16(frag_spec);
1852 [ # # ]: 0 : frag_last = rte_be_to_cpu_16(frag_last);
1853 : : /* frag_off mask has to be 0x3fff */
1854 [ # # ]: 0 : if (frag_mask !=
1855 : : (RTE_IPV4_HDR_OFFSET_MASK |
1856 : : RTE_IPV4_HDR_MF_FLAG)) {
1857 : 0 : rte_flow_error_set(error,
1858 : : EINVAL,
1859 : : RTE_FLOW_ERROR_TYPE_ITEM,
1860 : : item,
1861 : : "Invalid IPv4 fragment_offset mask");
1862 : 0 : return -rte_errno;
1863 : : }
1864 : : /*
1865 : : * non-frag rule:
1866 : : * mask=0x3fff,spec=0
1867 : : * frag rule:
1868 : : * mask=0x3fff,spec=0x8,last=0x2000
1869 : : */
1870 : 0 : if (frag_spec ==
1871 : 0 : (1 << RTE_IPV4_HDR_FO_SHIFT) &&
1872 [ # # ]: 0 : frag_last == RTE_IPV4_HDR_MF_FLAG) {
1873 : : pctype =
1874 : : I40E_FILTER_PCTYPE_FRAG_IPV4;
1875 [ # # ]: 0 : } else if (frag_spec || frag_last) {
1876 : 0 : rte_flow_error_set(error,
1877 : : EINVAL,
1878 : : RTE_FLOW_ERROR_TYPE_ITEM,
1879 : : item,
1880 : : "Invalid IPv4 fragment_offset rule");
1881 : 0 : return -rte_errno;
1882 : : }
1883 [ # # ]: 0 : } else if (frag_spec || frag_last) {
1884 : 0 : rte_flow_error_set(error,
1885 : : EINVAL,
1886 : : RTE_FLOW_ERROR_TYPE_ITEM,
1887 : : item,
1888 : : "Invalid fragment_offset");
1889 : 0 : return -rte_errno;
1890 : : }
1891 : :
1892 [ # # ]: 0 : if (input_set & (I40E_INSET_DMAC | I40E_INSET_SMAC)) {
1893 [ # # ]: 0 : if (input_set & (I40E_INSET_IPV4_SRC |
1894 : : I40E_INSET_IPV4_DST | I40E_INSET_IPV4_TOS |
1895 : : I40E_INSET_IPV4_TTL | I40E_INSET_IPV4_PROTO)) {
1896 : 0 : rte_flow_error_set(error, EINVAL,
1897 : : RTE_FLOW_ERROR_TYPE_ITEM,
1898 : : item,
1899 : : "L2 and L3 input set are exclusive.");
1900 : 0 : return -rte_errno;
1901 : : }
1902 : : } else {
1903 : : /* Get the filter info */
1904 : 0 : filter->input.flow.ip4_flow.proto =
1905 : 0 : ipv4_spec->hdr.next_proto_id;
1906 : 0 : filter->input.flow.ip4_flow.tos =
1907 : 0 : ipv4_spec->hdr.type_of_service;
1908 : 0 : filter->input.flow.ip4_flow.ttl =
1909 : 0 : ipv4_spec->hdr.time_to_live;
1910 : 0 : filter->input.flow.ip4_flow.src_ip =
1911 : 0 : ipv4_spec->hdr.src_addr;
1912 : 0 : filter->input.flow.ip4_flow.dst_ip =
1913 : 0 : ipv4_spec->hdr.dst_addr;
1914 : :
1915 : 0 : filter->input.flow_ext.inner_ip = false;
1916 : 0 : filter->input.flow_ext.oip_type =
1917 : : I40E_FDIR_IPTYPE_IPV4;
1918 : : }
1919 [ # # # # ]: 0 : } else if (!ipv4_spec && !ipv4_mask && !outer_ip) {
1920 : 0 : filter->input.flow_ext.inner_ip = true;
1921 : 0 : filter->input.flow_ext.iip_type =
1922 : : I40E_FDIR_IPTYPE_IPV4;
1923 [ # # # # ]: 0 : } else if (!ipv4_spec && !ipv4_mask && outer_ip) {
1924 : 0 : filter->input.flow_ext.inner_ip = false;
1925 : 0 : filter->input.flow_ext.oip_type =
1926 : : I40E_FDIR_IPTYPE_IPV4;
1927 [ # # # # ]: 0 : } else if ((ipv4_spec || ipv4_mask) && !outer_ip) {
1928 : 0 : rte_flow_error_set(error, EINVAL,
1929 : : RTE_FLOW_ERROR_TYPE_ITEM,
1930 : : item,
1931 : : "Invalid inner IPv4 mask.");
1932 : 0 : return -rte_errno;
1933 : : }
1934 : :
1935 : : if (outer_ip)
1936 : : outer_ip = false;
1937 : :
1938 : : break;
1939 : 0 : case RTE_FLOW_ITEM_TYPE_IPV6:
1940 : : l3 = RTE_FLOW_ITEM_TYPE_IPV6;
1941 : 0 : ipv6_spec = item->spec;
1942 : 0 : ipv6_mask = item->mask;
1943 : : pctype = I40E_FILTER_PCTYPE_NONF_IPV6_OTHER;
1944 : : layer_idx = I40E_FLXPLD_L3_IDX;
1945 : :
1946 [ # # # # ]: 0 : if (ipv6_spec && ipv6_mask && outer_ip) {
1947 : : /* Check IPv6 mask and update input set */
1948 [ # # ]: 0 : if (ipv6_mask->hdr.payload_len) {
1949 : 0 : rte_flow_error_set(error, EINVAL,
1950 : : RTE_FLOW_ERROR_TYPE_ITEM,
1951 : : item,
1952 : : "Invalid IPv6 mask");
1953 : 0 : return -rte_errno;
1954 : : }
1955 : :
1956 [ # # ]: 0 : if (!memcmp(ipv6_mask->hdr.src_addr,
1957 : : ipv6_addr_mask,
1958 : : RTE_DIM(ipv6_mask->hdr.src_addr)))
1959 : 0 : input_set |= I40E_INSET_IPV6_SRC;
1960 [ # # ]: 0 : if (!memcmp(ipv6_mask->hdr.dst_addr,
1961 : : ipv6_addr_mask,
1962 : : RTE_DIM(ipv6_mask->hdr.dst_addr)))
1963 : 0 : input_set |= I40E_INSET_IPV6_DST;
1964 : :
1965 [ # # ]: 0 : if ((ipv6_mask->hdr.vtc_flow &
1966 : : rte_cpu_to_be_32(I40E_IPV6_TC_MASK))
1967 : : == rte_cpu_to_be_32(I40E_IPV6_TC_MASK))
1968 : 0 : input_set |= I40E_INSET_IPV6_TC;
1969 [ # # ]: 0 : if (ipv6_mask->hdr.proto == UINT8_MAX)
1970 : 0 : input_set |= I40E_INSET_IPV6_NEXT_HDR;
1971 [ # # ]: 0 : if (ipv6_mask->hdr.hop_limits == UINT8_MAX)
1972 : 0 : input_set |= I40E_INSET_IPV6_HOP_LIMIT;
1973 : :
1974 : : /* Get filter info */
1975 : : vtc_flow_cpu =
1976 [ # # ]: 0 : rte_be_to_cpu_32(ipv6_spec->hdr.vtc_flow);
1977 : 0 : filter->input.flow.ipv6_flow.tc =
1978 : 0 : (uint8_t)(vtc_flow_cpu >>
1979 : : I40E_FDIR_IPv6_TC_OFFSET);
1980 : 0 : filter->input.flow.ipv6_flow.proto =
1981 : 0 : ipv6_spec->hdr.proto;
1982 : 0 : filter->input.flow.ipv6_flow.hop_limits =
1983 : 0 : ipv6_spec->hdr.hop_limits;
1984 : :
1985 : 0 : filter->input.flow_ext.inner_ip = false;
1986 : 0 : filter->input.flow_ext.oip_type =
1987 : : I40E_FDIR_IPTYPE_IPV6;
1988 : :
1989 : 0 : rte_memcpy(filter->input.flow.ipv6_flow.src_ip,
1990 [ # # ]: 0 : ipv6_spec->hdr.src_addr, 16);
1991 : 0 : rte_memcpy(filter->input.flow.ipv6_flow.dst_ip,
1992 [ # # ]: 0 : ipv6_spec->hdr.dst_addr, 16);
1993 : :
1994 : : /* Check if it is fragment. */
1995 [ # # ]: 0 : if (ipv6_spec->hdr.proto ==
1996 : : I40E_IPV6_FRAG_HEADER)
1997 : : pctype = I40E_FILTER_PCTYPE_FRAG_IPV6;
1998 [ # # # # ]: 0 : } else if (!ipv6_spec && !ipv6_mask && !outer_ip) {
1999 : 0 : filter->input.flow_ext.inner_ip = true;
2000 : 0 : filter->input.flow_ext.iip_type =
2001 : : I40E_FDIR_IPTYPE_IPV6;
2002 [ # # # # ]: 0 : } else if (!ipv6_spec && !ipv6_mask && outer_ip) {
2003 : 0 : filter->input.flow_ext.inner_ip = false;
2004 : 0 : filter->input.flow_ext.oip_type =
2005 : : I40E_FDIR_IPTYPE_IPV6;
2006 [ # # # # ]: 0 : } else if ((ipv6_spec || ipv6_mask) && !outer_ip) {
2007 : 0 : rte_flow_error_set(error, EINVAL,
2008 : : RTE_FLOW_ERROR_TYPE_ITEM,
2009 : : item,
2010 : : "Invalid inner IPv6 mask");
2011 : 0 : return -rte_errno;
2012 : : }
2013 : :
2014 : : if (outer_ip)
2015 : : outer_ip = false;
2016 : : break;
2017 : 0 : case RTE_FLOW_ITEM_TYPE_TCP:
2018 : 0 : tcp_spec = item->spec;
2019 : 0 : tcp_mask = item->mask;
2020 : :
2021 [ # # ]: 0 : if (l3 == RTE_FLOW_ITEM_TYPE_IPV4)
2022 : : pctype =
2023 : : I40E_FILTER_PCTYPE_NONF_IPV4_TCP;
2024 [ # # ]: 0 : else if (l3 == RTE_FLOW_ITEM_TYPE_IPV6)
2025 : : pctype =
2026 : : I40E_FILTER_PCTYPE_NONF_IPV6_TCP;
2027 [ # # ]: 0 : if (tcp_spec && tcp_mask) {
2028 : : /* Check TCP mask and update input set */
2029 [ # # ]: 0 : if (tcp_mask->hdr.sent_seq ||
2030 [ # # ]: 0 : tcp_mask->hdr.recv_ack ||
2031 [ # # ]: 0 : tcp_mask->hdr.data_off ||
2032 [ # # ]: 0 : tcp_mask->hdr.tcp_flags ||
2033 [ # # ]: 0 : tcp_mask->hdr.rx_win ||
2034 [ # # ]: 0 : tcp_mask->hdr.cksum ||
2035 [ # # ]: 0 : tcp_mask->hdr.tcp_urp) {
2036 : 0 : rte_flow_error_set(error, EINVAL,
2037 : : RTE_FLOW_ERROR_TYPE_ITEM,
2038 : : item,
2039 : : "Invalid TCP mask");
2040 : 0 : return -rte_errno;
2041 : : }
2042 : :
2043 [ # # ]: 0 : if (tcp_mask->hdr.src_port == UINT16_MAX)
2044 : 0 : input_set |= I40E_INSET_SRC_PORT;
2045 [ # # ]: 0 : if (tcp_mask->hdr.dst_port == UINT16_MAX)
2046 : 0 : input_set |= I40E_INSET_DST_PORT;
2047 : :
2048 [ # # ]: 0 : if (input_set & (I40E_INSET_DMAC | I40E_INSET_SMAC)) {
2049 [ # # ]: 0 : if (input_set &
2050 : : (I40E_INSET_SRC_PORT | I40E_INSET_DST_PORT)) {
2051 : 0 : rte_flow_error_set(error, EINVAL,
2052 : : RTE_FLOW_ERROR_TYPE_ITEM,
2053 : : item,
2054 : : "L2 and L4 input set are exclusive.");
2055 : 0 : return -rte_errno;
2056 : : }
2057 : : } else {
2058 : : /* Get filter info */
2059 [ # # ]: 0 : if (l3 == RTE_FLOW_ITEM_TYPE_IPV4) {
2060 : 0 : filter->input.flow.tcp4_flow.src_port =
2061 : 0 : tcp_spec->hdr.src_port;
2062 : 0 : filter->input.flow.tcp4_flow.dst_port =
2063 : 0 : tcp_spec->hdr.dst_port;
2064 [ # # ]: 0 : } else if (l3 == RTE_FLOW_ITEM_TYPE_IPV6) {
2065 : 0 : filter->input.flow.tcp6_flow.src_port =
2066 : 0 : tcp_spec->hdr.src_port;
2067 : 0 : filter->input.flow.tcp6_flow.dst_port =
2068 : 0 : tcp_spec->hdr.dst_port;
2069 : : }
2070 : : }
2071 : : }
2072 : :
2073 : : layer_idx = I40E_FLXPLD_L4_IDX;
2074 : :
2075 : : break;
2076 : 0 : case RTE_FLOW_ITEM_TYPE_UDP:
2077 : 0 : udp_spec = item->spec;
2078 : 0 : udp_mask = item->mask;
2079 : :
2080 [ # # ]: 0 : if (l3 == RTE_FLOW_ITEM_TYPE_IPV4)
2081 : : pctype =
2082 : : I40E_FILTER_PCTYPE_NONF_IPV4_UDP;
2083 [ # # ]: 0 : else if (l3 == RTE_FLOW_ITEM_TYPE_IPV6)
2084 : : pctype =
2085 : : I40E_FILTER_PCTYPE_NONF_IPV6_UDP;
2086 : :
2087 [ # # ]: 0 : if (udp_spec && udp_mask) {
2088 : : /* Check UDP mask and update input set*/
2089 [ # # ]: 0 : if (udp_mask->hdr.dgram_len ||
2090 [ # # ]: 0 : udp_mask->hdr.dgram_cksum) {
2091 : 0 : rte_flow_error_set(error, EINVAL,
2092 : : RTE_FLOW_ERROR_TYPE_ITEM,
2093 : : item,
2094 : : "Invalid UDP mask");
2095 : 0 : return -rte_errno;
2096 : : }
2097 : :
2098 [ # # ]: 0 : if (udp_mask->hdr.src_port == UINT16_MAX)
2099 : 0 : input_set |= I40E_INSET_SRC_PORT;
2100 [ # # ]: 0 : if (udp_mask->hdr.dst_port == UINT16_MAX)
2101 : 0 : input_set |= I40E_INSET_DST_PORT;
2102 : :
2103 [ # # ]: 0 : if (input_set & (I40E_INSET_DMAC | I40E_INSET_SMAC)) {
2104 [ # # ]: 0 : if (input_set &
2105 : : (I40E_INSET_SRC_PORT | I40E_INSET_DST_PORT)) {
2106 : 0 : rte_flow_error_set(error, EINVAL,
2107 : : RTE_FLOW_ERROR_TYPE_ITEM,
2108 : : item,
2109 : : "L2 and L4 input set are exclusive.");
2110 : 0 : return -rte_errno;
2111 : : }
2112 : : } else {
2113 : : /* Get filter info */
2114 [ # # ]: 0 : if (l3 == RTE_FLOW_ITEM_TYPE_IPV4) {
2115 : 0 : filter->input.flow.udp4_flow.src_port =
2116 : 0 : udp_spec->hdr.src_port;
2117 : 0 : filter->input.flow.udp4_flow.dst_port =
2118 : 0 : udp_spec->hdr.dst_port;
2119 [ # # ]: 0 : } else if (l3 == RTE_FLOW_ITEM_TYPE_IPV6) {
2120 : 0 : filter->input.flow.udp6_flow.src_port =
2121 : 0 : udp_spec->hdr.src_port;
2122 : 0 : filter->input.flow.udp6_flow.dst_port =
2123 : 0 : udp_spec->hdr.dst_port;
2124 : : }
2125 : : }
2126 : : }
2127 : 0 : filter->input.flow_ext.is_udp = true;
2128 : : layer_idx = I40E_FLXPLD_L4_IDX;
2129 : :
2130 : 0 : break;
2131 : 0 : case RTE_FLOW_ITEM_TYPE_GTPC:
2132 : : case RTE_FLOW_ITEM_TYPE_GTPU:
2133 [ # # ]: 0 : if (!pf->gtp_support) {
2134 : 0 : rte_flow_error_set(error, EINVAL,
2135 : : RTE_FLOW_ERROR_TYPE_ITEM,
2136 : : item,
2137 : : "Unsupported protocol");
2138 : 0 : return -rte_errno;
2139 : : }
2140 : :
2141 : 0 : gtp_spec = item->spec;
2142 : 0 : gtp_mask = item->mask;
2143 : :
2144 [ # # ]: 0 : if (gtp_spec && gtp_mask) {
2145 : 0 : if (gtp_mask->hdr.gtp_hdr_info ||
2146 [ # # ]: 0 : gtp_mask->hdr.msg_type ||
2147 : 0 : gtp_mask->hdr.plen ||
2148 [ # # ]: 0 : gtp_mask->hdr.teid != UINT32_MAX) {
2149 : 0 : rte_flow_error_set(error, EINVAL,
2150 : : RTE_FLOW_ERROR_TYPE_ITEM,
2151 : : item,
2152 : : "Invalid GTP mask");
2153 : 0 : return -rte_errno;
2154 : : }
2155 : :
2156 : 0 : filter->input.flow.gtp_flow.teid =
2157 : 0 : gtp_spec->hdr.teid;
2158 : 0 : filter->input.flow_ext.customized_pctype = true;
2159 : : cus_proto = item_type;
2160 : : }
2161 : : break;
2162 : 0 : case RTE_FLOW_ITEM_TYPE_ESP:
2163 [ # # ]: 0 : if (!pf->esp_support) {
2164 : 0 : rte_flow_error_set(error, EINVAL,
2165 : : RTE_FLOW_ERROR_TYPE_ITEM,
2166 : : item,
2167 : : "Unsupported ESP protocol");
2168 : 0 : return -rte_errno;
2169 : : }
2170 : :
2171 : 0 : esp_spec = item->spec;
2172 : 0 : esp_mask = item->mask;
2173 : :
2174 [ # # ]: 0 : if (!esp_spec || !esp_mask) {
2175 : 0 : rte_flow_error_set(error, EINVAL,
2176 : : RTE_FLOW_ERROR_TYPE_ITEM,
2177 : : item,
2178 : : "Invalid ESP item");
2179 : 0 : return -rte_errno;
2180 : : }
2181 : :
2182 : : if (esp_spec && esp_mask) {
2183 [ # # ]: 0 : if (esp_mask->hdr.spi != UINT32_MAX) {
2184 : 0 : rte_flow_error_set(error, EINVAL,
2185 : : RTE_FLOW_ERROR_TYPE_ITEM,
2186 : : item,
2187 : : "Invalid ESP mask");
2188 : 0 : return -rte_errno;
2189 : : }
2190 : : i40e_flow_set_filter_spi(filter, esp_spec);
2191 : 0 : filter->input.flow_ext.customized_pctype = true;
2192 : : cus_proto = item_type;
2193 : : }
2194 : : break;
2195 : 0 : case RTE_FLOW_ITEM_TYPE_SCTP:
2196 : 0 : sctp_spec = item->spec;
2197 : 0 : sctp_mask = item->mask;
2198 : :
2199 [ # # ]: 0 : if (l3 == RTE_FLOW_ITEM_TYPE_IPV4)
2200 : : pctype =
2201 : : I40E_FILTER_PCTYPE_NONF_IPV4_SCTP;
2202 [ # # ]: 0 : else if (l3 == RTE_FLOW_ITEM_TYPE_IPV6)
2203 : : pctype =
2204 : : I40E_FILTER_PCTYPE_NONF_IPV6_SCTP;
2205 : :
2206 [ # # ]: 0 : if (sctp_spec && sctp_mask) {
2207 : : /* Check SCTP mask and update input set */
2208 [ # # ]: 0 : if (sctp_mask->hdr.cksum) {
2209 : 0 : rte_flow_error_set(error, EINVAL,
2210 : : RTE_FLOW_ERROR_TYPE_ITEM,
2211 : : item,
2212 : : "Invalid UDP mask");
2213 : 0 : return -rte_errno;
2214 : : }
2215 : :
2216 [ # # ]: 0 : if (sctp_mask->hdr.src_port == UINT16_MAX)
2217 : 0 : input_set |= I40E_INSET_SRC_PORT;
2218 [ # # ]: 0 : if (sctp_mask->hdr.dst_port == UINT16_MAX)
2219 : 0 : input_set |= I40E_INSET_DST_PORT;
2220 [ # # ]: 0 : if (sctp_mask->hdr.tag == UINT32_MAX)
2221 : 0 : input_set |= I40E_INSET_SCTP_VT;
2222 : :
2223 : : /* Get filter info */
2224 [ # # ]: 0 : if (l3 == RTE_FLOW_ITEM_TYPE_IPV4) {
2225 : 0 : filter->input.flow.sctp4_flow.src_port =
2226 : 0 : sctp_spec->hdr.src_port;
2227 : 0 : filter->input.flow.sctp4_flow.dst_port =
2228 : 0 : sctp_spec->hdr.dst_port;
2229 : : filter->input.flow.sctp4_flow.verify_tag
2230 : 0 : = sctp_spec->hdr.tag;
2231 [ # # ]: 0 : } else if (l3 == RTE_FLOW_ITEM_TYPE_IPV6) {
2232 : 0 : filter->input.flow.sctp6_flow.src_port =
2233 : 0 : sctp_spec->hdr.src_port;
2234 : 0 : filter->input.flow.sctp6_flow.dst_port =
2235 : 0 : sctp_spec->hdr.dst_port;
2236 : : filter->input.flow.sctp6_flow.verify_tag
2237 : 0 : = sctp_spec->hdr.tag;
2238 : : }
2239 : : }
2240 : :
2241 : : layer_idx = I40E_FLXPLD_L4_IDX;
2242 : :
2243 : : break;
2244 : 0 : case RTE_FLOW_ITEM_TYPE_RAW:
2245 : 0 : raw_spec = item->spec;
2246 : 0 : raw_mask = item->mask;
2247 : :
2248 [ # # ]: 0 : if (!raw_spec || !raw_mask) {
2249 : 0 : rte_flow_error_set(error, EINVAL,
2250 : : RTE_FLOW_ERROR_TYPE_ITEM,
2251 : : item,
2252 : : "NULL RAW spec/mask");
2253 : 0 : return -rte_errno;
2254 : : }
2255 : :
2256 [ # # ]: 0 : if (pf->support_multi_driver) {
2257 : 0 : rte_flow_error_set(error, ENOTSUP,
2258 : : RTE_FLOW_ERROR_TYPE_ITEM,
2259 : : item,
2260 : : "Unsupported flexible payload.");
2261 : 0 : return -rte_errno;
2262 : : }
2263 : :
2264 : 0 : ret = i40e_flow_check_raw_item(item, raw_spec, error);
2265 [ # # ]: 0 : if (ret < 0)
2266 : 0 : return ret;
2267 : :
2268 : 0 : off_arr[raw_id] = raw_spec->offset;
2269 : 0 : len_arr[raw_id] = raw_spec->length;
2270 : :
2271 : : flex_size = 0;
2272 : : memset(&flex_pit, 0, sizeof(struct i40e_fdir_flex_pit));
2273 : 0 : field_idx = layer_idx * I40E_MAX_FLXPLD_FIED + raw_id;
2274 : 0 : flex_pit.size =
2275 : : raw_spec->length / sizeof(uint16_t);
2276 : 0 : flex_pit.dst_offset =
2277 : : next_dst_off / sizeof(uint16_t);
2278 : :
2279 [ # # ]: 0 : for (i = 0; i <= raw_id; i++) {
2280 [ # # ]: 0 : if (i == raw_id)
2281 : 0 : flex_pit.src_offset +=
2282 : 0 : raw_spec->offset /
2283 : : sizeof(uint16_t);
2284 : : else
2285 : 0 : flex_pit.src_offset +=
2286 : 0 : (off_arr[i] + len_arr[i]) /
2287 : : sizeof(uint16_t);
2288 : 0 : flex_size += len_arr[i];
2289 : : }
2290 [ # # ]: 0 : if (((flex_pit.src_offset + flex_pit.size) >=
2291 [ # # ]: 0 : I40E_MAX_FLX_SOURCE_OFF / sizeof(uint16_t)) ||
2292 : : flex_size > I40E_FDIR_MAX_FLEXLEN) {
2293 : 0 : rte_flow_error_set(error, EINVAL,
2294 : : RTE_FLOW_ERROR_TYPE_ITEM,
2295 : : item,
2296 : : "Exceeds maximal payload limit.");
2297 : 0 : return -rte_errno;
2298 : : }
2299 : :
2300 [ # # ]: 0 : for (i = 0; i < raw_spec->length; i++) {
2301 : 0 : j = i + next_dst_off;
2302 [ # # ]: 0 : if (j >= RTE_ETH_FDIR_MAX_FLEXLEN ||
2303 : : j >= I40E_FDIR_MAX_FLEX_LEN)
2304 : : break;
2305 : 0 : filter->input.flow_ext.flexbytes[j] =
2306 : 0 : raw_spec->pattern[i];
2307 : 0 : filter->input.flow_ext.flex_mask[j] =
2308 : 0 : raw_mask->pattern[i];
2309 : : }
2310 : :
2311 : 0 : next_dst_off += raw_spec->length;
2312 : 0 : raw_id++;
2313 : :
2314 : 0 : memcpy(&filter->input.flow_ext.flex_pit[field_idx],
2315 : : &flex_pit, sizeof(struct i40e_fdir_flex_pit));
2316 : 0 : filter->input.flow_ext.layer_idx = layer_idx;
2317 : 0 : filter->input.flow_ext.raw_id = raw_id;
2318 : 0 : filter->input.flow_ext.is_flex_flow = true;
2319 : 0 : break;
2320 : 0 : case RTE_FLOW_ITEM_TYPE_L2TPV3OIP:
2321 : 0 : l2tpv3oip_spec = item->spec;
2322 : 0 : l2tpv3oip_mask = item->mask;
2323 : :
2324 [ # # ]: 0 : if (!l2tpv3oip_spec || !l2tpv3oip_mask)
2325 : : break;
2326 : :
2327 [ # # ]: 0 : if (l2tpv3oip_mask->session_id != UINT32_MAX) {
2328 : 0 : rte_flow_error_set(error, EINVAL,
2329 : : RTE_FLOW_ERROR_TYPE_ITEM,
2330 : : item,
2331 : : "Invalid L2TPv3 mask");
2332 : 0 : return -rte_errno;
2333 : : }
2334 : :
2335 [ # # ]: 0 : if (l3 == RTE_FLOW_ITEM_TYPE_IPV4) {
2336 : 0 : filter->input.flow.ip4_l2tpv3oip_flow.session_id =
2337 : 0 : l2tpv3oip_spec->session_id;
2338 : 0 : filter->input.flow_ext.oip_type =
2339 : : I40E_FDIR_IPTYPE_IPV4;
2340 [ # # ]: 0 : } else if (l3 == RTE_FLOW_ITEM_TYPE_IPV6) {
2341 : 0 : filter->input.flow.ip6_l2tpv3oip_flow.session_id =
2342 : 0 : l2tpv3oip_spec->session_id;
2343 : 0 : filter->input.flow_ext.oip_type =
2344 : : I40E_FDIR_IPTYPE_IPV6;
2345 : : }
2346 : :
2347 : 0 : filter->input.flow_ext.customized_pctype = true;
2348 : : cus_proto = item_type;
2349 : 0 : break;
2350 : : default:
2351 : : break;
2352 : : }
2353 : : }
2354 : :
2355 : : /* Get customized pctype value */
2356 [ # # ]: 0 : if (filter->input.flow_ext.customized_pctype) {
2357 : 0 : pctype = i40e_flow_fdir_get_pctype_value(pf, cus_proto, filter);
2358 [ # # ]: 0 : if (pctype == I40E_FILTER_PCTYPE_INVALID) {
2359 : 0 : rte_flow_error_set(error, EINVAL,
2360 : : RTE_FLOW_ERROR_TYPE_ITEM,
2361 : : item,
2362 : : "Unsupported pctype");
2363 : 0 : return -rte_errno;
2364 : : }
2365 : : }
2366 : :
2367 : : /* If customized pctype is not used, set fdir configuration.*/
2368 [ # # ]: 0 : if (!filter->input.flow_ext.customized_pctype) {
2369 : : /* Check if the input set is valid */
2370 [ # # ]: 0 : if (i40e_validate_input_set(pctype, RTE_ETH_FILTER_FDIR,
2371 : : input_set) != 0) {
2372 : 0 : rte_flow_error_set(error, EINVAL,
2373 : : RTE_FLOW_ERROR_TYPE_ITEM,
2374 : : item,
2375 : : "Invalid input set");
2376 : 0 : return -rte_errno;
2377 : : }
2378 : :
2379 : 0 : filter->input.flow_ext.input_set = input_set;
2380 : : }
2381 : :
2382 : 0 : filter->input.pctype = pctype;
2383 : :
2384 : 0 : return 0;
2385 : : }
2386 : :
2387 : : /* Parse to get the action info of a FDIR filter.
2388 : : * FDIR action supports QUEUE or (QUEUE + MARK).
2389 : : */
2390 : : static int
2391 : 0 : i40e_flow_parse_fdir_action(struct rte_eth_dev *dev,
2392 : : const struct rte_flow_action *actions,
2393 : : struct rte_flow_error *error,
2394 : : struct i40e_fdir_filter_conf *filter)
2395 : : {
2396 : 0 : struct i40e_pf *pf = I40E_DEV_PRIVATE_TO_PF(dev->data->dev_private);
2397 : : const struct rte_flow_action *act;
2398 : : const struct rte_flow_action_queue *act_q;
2399 : : const struct rte_flow_action_mark *mark_spec = NULL;
2400 : : uint32_t index = 0;
2401 : :
2402 : : /* Check if the first non-void action is QUEUE or DROP or PASSTHRU. */
2403 [ # # ]: 0 : NEXT_ITEM_OF_ACTION(act, actions, index);
2404 [ # # # # : 0 : switch (act->type) {
# ]
2405 : 0 : case RTE_FLOW_ACTION_TYPE_QUEUE:
2406 : 0 : act_q = act->conf;
2407 : 0 : filter->action.rx_queue = act_q->index;
2408 [ # # ]: 0 : if ((!filter->input.flow_ext.is_vf &&
2409 [ # # # # ]: 0 : filter->action.rx_queue >= pf->dev_data->nb_rx_queues) ||
2410 : 0 : (filter->input.flow_ext.is_vf &&
2411 [ # # ]: 0 : filter->action.rx_queue >= pf->vf_nb_qps)) {
2412 : 0 : rte_flow_error_set(error, EINVAL,
2413 : : RTE_FLOW_ERROR_TYPE_ACTION, act,
2414 : : "Invalid queue ID for FDIR.");
2415 : 0 : return -rte_errno;
2416 : : }
2417 : 0 : filter->action.behavior = I40E_FDIR_ACCEPT;
2418 : 0 : break;
2419 : 0 : case RTE_FLOW_ACTION_TYPE_DROP:
2420 : 0 : filter->action.behavior = I40E_FDIR_REJECT;
2421 : 0 : break;
2422 : 0 : case RTE_FLOW_ACTION_TYPE_PASSTHRU:
2423 : 0 : filter->action.behavior = I40E_FDIR_PASSTHRU;
2424 : 0 : break;
2425 : 0 : case RTE_FLOW_ACTION_TYPE_MARK:
2426 : 0 : filter->action.behavior = I40E_FDIR_PASSTHRU;
2427 : 0 : mark_spec = act->conf;
2428 : 0 : filter->action.report_status = I40E_FDIR_REPORT_ID;
2429 : 0 : filter->soft_id = mark_spec->id;
2430 : 0 : break;
2431 : 0 : default:
2432 : 0 : rte_flow_error_set(error, EINVAL,
2433 : : RTE_FLOW_ERROR_TYPE_ACTION, act,
2434 : : "Invalid action.");
2435 : 0 : return -rte_errno;
2436 : : }
2437 : :
2438 : : /* Check if the next non-void item is MARK or FLAG or END. */
2439 : 0 : index++;
2440 [ # # ]: 0 : NEXT_ITEM_OF_ACTION(act, actions, index);
2441 [ # # # # : 0 : switch (act->type) {
# ]
2442 : 0 : case RTE_FLOW_ACTION_TYPE_MARK:
2443 [ # # ]: 0 : if (mark_spec) {
2444 : : /* Double MARK actions requested */
2445 : 0 : rte_flow_error_set(error, EINVAL,
2446 : : RTE_FLOW_ERROR_TYPE_ACTION, act,
2447 : : "Invalid action.");
2448 : 0 : return -rte_errno;
2449 : : }
2450 : 0 : mark_spec = act->conf;
2451 : 0 : filter->action.report_status = I40E_FDIR_REPORT_ID;
2452 : 0 : filter->soft_id = mark_spec->id;
2453 : 0 : break;
2454 : 0 : case RTE_FLOW_ACTION_TYPE_FLAG:
2455 [ # # ]: 0 : if (mark_spec) {
2456 : : /* MARK + FLAG not supported */
2457 : 0 : rte_flow_error_set(error, EINVAL,
2458 : : RTE_FLOW_ERROR_TYPE_ACTION, act,
2459 : : "Invalid action.");
2460 : 0 : return -rte_errno;
2461 : : }
2462 : 0 : filter->action.report_status = I40E_FDIR_NO_REPORT_STATUS;
2463 : 0 : break;
2464 : 0 : case RTE_FLOW_ACTION_TYPE_RSS:
2465 [ # # ]: 0 : if (filter->action.behavior != I40E_FDIR_PASSTHRU) {
2466 : : /* RSS filter won't be next if FDIR did not pass thru */
2467 : 0 : rte_flow_error_set(error, EINVAL,
2468 : : RTE_FLOW_ERROR_TYPE_ACTION, act,
2469 : : "Invalid action.");
2470 : 0 : return -rte_errno;
2471 : : }
2472 : : break;
2473 : : case RTE_FLOW_ACTION_TYPE_END:
2474 : : return 0;
2475 : 0 : default:
2476 : 0 : rte_flow_error_set(error, EINVAL, RTE_FLOW_ERROR_TYPE_ACTION,
2477 : : act, "Invalid action.");
2478 : 0 : return -rte_errno;
2479 : : }
2480 : :
2481 : : /* Check if the next non-void item is END */
2482 : 0 : index++;
2483 [ # # ]: 0 : NEXT_ITEM_OF_ACTION(act, actions, index);
2484 [ # # ]: 0 : if (act->type != RTE_FLOW_ACTION_TYPE_END) {
2485 : 0 : rte_flow_error_set(error, EINVAL,
2486 : : RTE_FLOW_ERROR_TYPE_ACTION,
2487 : : act, "Invalid action.");
2488 : 0 : return -rte_errno;
2489 : : }
2490 : :
2491 : : return 0;
2492 : : }
2493 : :
2494 : : static int
2495 : 0 : i40e_flow_parse_fdir_filter(struct rte_eth_dev *dev,
2496 : : const struct rte_flow_attr *attr,
2497 : : const struct rte_flow_item pattern[],
2498 : : const struct rte_flow_action actions[],
2499 : : struct rte_flow_error *error,
2500 : : union i40e_filter_t *filter)
2501 : : {
2502 : 0 : struct i40e_pf *pf = I40E_DEV_PRIVATE_TO_PF(dev->data->dev_private);
2503 : 0 : struct i40e_fdir_filter_conf *fdir_filter =
2504 : : &filter->fdir_filter;
2505 : : int ret;
2506 : :
2507 : 0 : ret = i40e_flow_parse_fdir_pattern(dev, pattern, error, fdir_filter);
2508 [ # # ]: 0 : if (ret)
2509 : : return ret;
2510 : :
2511 : 0 : ret = i40e_flow_parse_fdir_action(dev, actions, error, fdir_filter);
2512 [ # # ]: 0 : if (ret)
2513 : : return ret;
2514 : :
2515 : 0 : ret = i40e_flow_parse_attr(attr, error);
2516 [ # # ]: 0 : if (ret)
2517 : : return ret;
2518 : :
2519 : 0 : cons_filter_type = RTE_ETH_FILTER_FDIR;
2520 : :
2521 [ # # ]: 0 : if (pf->fdir.fdir_vsi == NULL) {
2522 : : /* Enable fdir when fdir flow is added at first time. */
2523 : 0 : ret = i40e_fdir_setup(pf);
2524 [ # # ]: 0 : if (ret != I40E_SUCCESS) {
2525 : 0 : rte_flow_error_set(error, ENOTSUP,
2526 : : RTE_FLOW_ERROR_TYPE_HANDLE,
2527 : : NULL, "Failed to setup fdir.");
2528 : 0 : return -rte_errno;
2529 : : }
2530 : 0 : ret = i40e_fdir_configure(dev);
2531 [ # # ]: 0 : if (ret < 0) {
2532 : 0 : rte_flow_error_set(error, ENOTSUP,
2533 : : RTE_FLOW_ERROR_TYPE_HANDLE,
2534 : : NULL, "Failed to configure fdir.");
2535 : 0 : goto err;
2536 : : }
2537 : : }
2538 : :
2539 : : /* If create the first fdir rule, enable fdir check for rx queues */
2540 [ # # ]: 0 : if (TAILQ_EMPTY(&pf->fdir.fdir_list))
2541 : 0 : i40e_fdir_rx_proc_enable(dev, 1);
2542 : :
2543 : : return 0;
2544 : : err:
2545 : 0 : i40e_fdir_teardown(pf);
2546 : 0 : return -rte_errno;
2547 : : }
2548 : :
2549 : : /* Parse to get the action info of a tunnel filter
2550 : : * Tunnel action only supports PF, VF and QUEUE.
2551 : : */
2552 : : static int
2553 : 0 : i40e_flow_parse_tunnel_action(struct rte_eth_dev *dev,
2554 : : const struct rte_flow_action *actions,
2555 : : struct rte_flow_error *error,
2556 : : struct i40e_tunnel_filter_conf *filter)
2557 : : {
2558 : 0 : struct i40e_pf *pf = I40E_DEV_PRIVATE_TO_PF(dev->data->dev_private);
2559 : : const struct rte_flow_action *act;
2560 : : const struct rte_flow_action_queue *act_q;
2561 : : const struct rte_flow_action_vf *act_vf;
2562 : : uint32_t index = 0;
2563 : :
2564 : : /* Check if the first non-void action is PF or VF. */
2565 [ # # ]: 0 : NEXT_ITEM_OF_ACTION(act, actions, index);
2566 [ # # ]: 0 : if (act->type != RTE_FLOW_ACTION_TYPE_PF &&
2567 : : act->type != RTE_FLOW_ACTION_TYPE_VF) {
2568 : 0 : rte_flow_error_set(error, EINVAL, RTE_FLOW_ERROR_TYPE_ACTION,
2569 : : act, "Not supported action.");
2570 : 0 : return -rte_errno;
2571 : : }
2572 : :
2573 [ # # ]: 0 : if (act->type == RTE_FLOW_ACTION_TYPE_VF) {
2574 : 0 : act_vf = act->conf;
2575 : 0 : filter->vf_id = act_vf->id;
2576 : 0 : filter->is_to_vf = 1;
2577 [ # # ]: 0 : if (filter->vf_id >= pf->vf_num) {
2578 : 0 : rte_flow_error_set(error, EINVAL,
2579 : : RTE_FLOW_ERROR_TYPE_ACTION,
2580 : : act, "Invalid VF ID for tunnel filter");
2581 : 0 : return -rte_errno;
2582 : : }
2583 : : }
2584 : :
2585 : : /* Check if the next non-void item is QUEUE */
2586 : 0 : index++;
2587 [ # # ]: 0 : NEXT_ITEM_OF_ACTION(act, actions, index);
2588 [ # # ]: 0 : if (act->type == RTE_FLOW_ACTION_TYPE_QUEUE) {
2589 : 0 : act_q = act->conf;
2590 : 0 : filter->queue_id = act_q->index;
2591 [ # # ]: 0 : if ((!filter->is_to_vf) &&
2592 [ # # ]: 0 : (filter->queue_id >= pf->dev_data->nb_rx_queues)) {
2593 : 0 : rte_flow_error_set(error, EINVAL,
2594 : : RTE_FLOW_ERROR_TYPE_ACTION,
2595 : : act, "Invalid queue ID for tunnel filter");
2596 : 0 : return -rte_errno;
2597 [ # # ]: 0 : } else if (filter->is_to_vf &&
2598 [ # # ]: 0 : (filter->queue_id >= pf->vf_nb_qps)) {
2599 : 0 : rte_flow_error_set(error, EINVAL,
2600 : : RTE_FLOW_ERROR_TYPE_ACTION,
2601 : : act, "Invalid queue ID for tunnel filter");
2602 : 0 : return -rte_errno;
2603 : : }
2604 : : }
2605 : :
2606 : : /* Check if the next non-void item is END */
2607 : 0 : index++;
2608 [ # # ]: 0 : NEXT_ITEM_OF_ACTION(act, actions, index);
2609 [ # # ]: 0 : if (act->type != RTE_FLOW_ACTION_TYPE_END) {
2610 : 0 : rte_flow_error_set(error, EINVAL, RTE_FLOW_ERROR_TYPE_ACTION,
2611 : : act, "Not supported action.");
2612 : 0 : return -rte_errno;
2613 : : }
2614 : :
2615 : : return 0;
2616 : : }
2617 : :
2618 : : /* 1. Last in item should be NULL as range is not supported.
2619 : : * 2. Supported filter types: Source port only and Destination port only.
2620 : : * 3. Mask of fields which need to be matched should be
2621 : : * filled with 1.
2622 : : * 4. Mask of fields which needn't to be matched should be
2623 : : * filled with 0.
2624 : : */
2625 : : static int
2626 : 0 : i40e_flow_parse_l4_pattern(const struct rte_flow_item *pattern,
2627 : : struct rte_flow_error *error,
2628 : : struct i40e_tunnel_filter_conf *filter)
2629 : : {
2630 : : const struct rte_flow_item_sctp *sctp_spec, *sctp_mask;
2631 : : const struct rte_flow_item_tcp *tcp_spec, *tcp_mask;
2632 : : const struct rte_flow_item_udp *udp_spec, *udp_mask;
2633 : : const struct rte_flow_item *item = pattern;
2634 : : enum rte_flow_item_type item_type;
2635 : :
2636 [ # # ]: 0 : for (; item->type != RTE_FLOW_ITEM_TYPE_END; item++) {
2637 [ # # ]: 0 : if (item->last) {
2638 : 0 : rte_flow_error_set(error, EINVAL,
2639 : : RTE_FLOW_ERROR_TYPE_ITEM,
2640 : : item,
2641 : : "Not support range");
2642 : 0 : return -rte_errno;
2643 : : }
2644 : : item_type = item->type;
2645 [ # # # # : 0 : switch (item_type) {
# # # ]
2646 : 0 : case RTE_FLOW_ITEM_TYPE_ETH:
2647 [ # # # # ]: 0 : if (item->spec || item->mask) {
2648 : 0 : rte_flow_error_set(error, EINVAL,
2649 : : RTE_FLOW_ERROR_TYPE_ITEM,
2650 : : item,
2651 : : "Invalid ETH item");
2652 : 0 : return -rte_errno;
2653 : : }
2654 : :
2655 : : break;
2656 : 0 : case RTE_FLOW_ITEM_TYPE_IPV4:
2657 : 0 : filter->ip_type = I40E_TUNNEL_IPTYPE_IPV4;
2658 : : /* IPv4 is used to describe protocol,
2659 : : * spec and mask should be NULL.
2660 : : */
2661 [ # # # # ]: 0 : if (item->spec || item->mask) {
2662 : 0 : rte_flow_error_set(error, EINVAL,
2663 : : RTE_FLOW_ERROR_TYPE_ITEM,
2664 : : item,
2665 : : "Invalid IPv4 item");
2666 : 0 : return -rte_errno;
2667 : : }
2668 : :
2669 : : break;
2670 : 0 : case RTE_FLOW_ITEM_TYPE_IPV6:
2671 : 0 : filter->ip_type = I40E_TUNNEL_IPTYPE_IPV6;
2672 : : /* IPv6 is used to describe protocol,
2673 : : * spec and mask should be NULL.
2674 : : */
2675 [ # # # # ]: 0 : if (item->spec || item->mask) {
2676 : 0 : rte_flow_error_set(error, EINVAL,
2677 : : RTE_FLOW_ERROR_TYPE_ITEM,
2678 : : item,
2679 : : "Invalid IPv6 item");
2680 : 0 : return -rte_errno;
2681 : : }
2682 : :
2683 : : break;
2684 : 0 : case RTE_FLOW_ITEM_TYPE_UDP:
2685 : 0 : udp_spec = item->spec;
2686 : 0 : udp_mask = item->mask;
2687 : :
2688 [ # # ]: 0 : if (!udp_spec || !udp_mask) {
2689 : 0 : rte_flow_error_set(error, EINVAL,
2690 : : RTE_FLOW_ERROR_TYPE_ITEM,
2691 : : item,
2692 : : "Invalid udp item");
2693 : 0 : return -rte_errno;
2694 : : }
2695 : :
2696 [ # # ]: 0 : if (udp_spec->hdr.src_port != 0 &&
2697 [ # # ]: 0 : udp_spec->hdr.dst_port != 0) {
2698 : 0 : rte_flow_error_set(error, EINVAL,
2699 : : RTE_FLOW_ERROR_TYPE_ITEM,
2700 : : item,
2701 : : "Invalid udp spec");
2702 : 0 : return -rte_errno;
2703 : : }
2704 : :
2705 [ # # ]: 0 : if (udp_spec->hdr.src_port != 0) {
2706 : 0 : filter->l4_port_type =
2707 : : I40E_L4_PORT_TYPE_SRC;
2708 : 0 : filter->tenant_id =
2709 [ # # ]: 0 : rte_be_to_cpu_32(udp_spec->hdr.src_port);
2710 : : }
2711 : :
2712 [ # # ]: 0 : if (udp_spec->hdr.dst_port != 0) {
2713 : 0 : filter->l4_port_type =
2714 : : I40E_L4_PORT_TYPE_DST;
2715 : 0 : filter->tenant_id =
2716 [ # # ]: 0 : rte_be_to_cpu_32(udp_spec->hdr.dst_port);
2717 : : }
2718 : :
2719 : 0 : filter->tunnel_type = I40E_CLOUD_TYPE_UDP;
2720 : :
2721 : 0 : break;
2722 : 0 : case RTE_FLOW_ITEM_TYPE_TCP:
2723 : 0 : tcp_spec = item->spec;
2724 : 0 : tcp_mask = item->mask;
2725 : :
2726 [ # # ]: 0 : if (!tcp_spec || !tcp_mask) {
2727 : 0 : rte_flow_error_set(error, EINVAL,
2728 : : RTE_FLOW_ERROR_TYPE_ITEM,
2729 : : item,
2730 : : "Invalid tcp item");
2731 : 0 : return -rte_errno;
2732 : : }
2733 : :
2734 [ # # ]: 0 : if (tcp_spec->hdr.src_port != 0 &&
2735 [ # # ]: 0 : tcp_spec->hdr.dst_port != 0) {
2736 : 0 : rte_flow_error_set(error, EINVAL,
2737 : : RTE_FLOW_ERROR_TYPE_ITEM,
2738 : : item,
2739 : : "Invalid tcp spec");
2740 : 0 : return -rte_errno;
2741 : : }
2742 : :
2743 [ # # ]: 0 : if (tcp_spec->hdr.src_port != 0) {
2744 : 0 : filter->l4_port_type =
2745 : : I40E_L4_PORT_TYPE_SRC;
2746 : 0 : filter->tenant_id =
2747 [ # # ]: 0 : rte_be_to_cpu_32(tcp_spec->hdr.src_port);
2748 : : }
2749 : :
2750 [ # # ]: 0 : if (tcp_spec->hdr.dst_port != 0) {
2751 : 0 : filter->l4_port_type =
2752 : : I40E_L4_PORT_TYPE_DST;
2753 : 0 : filter->tenant_id =
2754 [ # # ]: 0 : rte_be_to_cpu_32(tcp_spec->hdr.dst_port);
2755 : : }
2756 : :
2757 : 0 : filter->tunnel_type = I40E_CLOUD_TYPE_TCP;
2758 : :
2759 : 0 : break;
2760 : 0 : case RTE_FLOW_ITEM_TYPE_SCTP:
2761 : 0 : sctp_spec = item->spec;
2762 : 0 : sctp_mask = item->mask;
2763 : :
2764 [ # # ]: 0 : if (!sctp_spec || !sctp_mask) {
2765 : 0 : rte_flow_error_set(error, EINVAL,
2766 : : RTE_FLOW_ERROR_TYPE_ITEM,
2767 : : item,
2768 : : "Invalid sctp item");
2769 : 0 : return -rte_errno;
2770 : : }
2771 : :
2772 [ # # ]: 0 : if (sctp_spec->hdr.src_port != 0 &&
2773 [ # # ]: 0 : sctp_spec->hdr.dst_port != 0) {
2774 : 0 : rte_flow_error_set(error, EINVAL,
2775 : : RTE_FLOW_ERROR_TYPE_ITEM,
2776 : : item,
2777 : : "Invalid sctp spec");
2778 : 0 : return -rte_errno;
2779 : : }
2780 : :
2781 [ # # ]: 0 : if (sctp_spec->hdr.src_port != 0) {
2782 : 0 : filter->l4_port_type =
2783 : : I40E_L4_PORT_TYPE_SRC;
2784 : 0 : filter->tenant_id =
2785 [ # # ]: 0 : rte_be_to_cpu_32(sctp_spec->hdr.src_port);
2786 : : }
2787 : :
2788 [ # # ]: 0 : if (sctp_spec->hdr.dst_port != 0) {
2789 : 0 : filter->l4_port_type =
2790 : : I40E_L4_PORT_TYPE_DST;
2791 : 0 : filter->tenant_id =
2792 [ # # ]: 0 : rte_be_to_cpu_32(sctp_spec->hdr.dst_port);
2793 : : }
2794 : :
2795 : 0 : filter->tunnel_type = I40E_CLOUD_TYPE_SCTP;
2796 : :
2797 : 0 : break;
2798 : : default:
2799 : : break;
2800 : : }
2801 : : }
2802 : :
2803 : : return 0;
2804 : : }
2805 : :
2806 : : static int
2807 : 0 : i40e_flow_parse_l4_cloud_filter(struct rte_eth_dev *dev,
2808 : : const struct rte_flow_attr *attr,
2809 : : const struct rte_flow_item pattern[],
2810 : : const struct rte_flow_action actions[],
2811 : : struct rte_flow_error *error,
2812 : : union i40e_filter_t *filter)
2813 : : {
2814 : 0 : struct i40e_tunnel_filter_conf *tunnel_filter =
2815 : : &filter->consistent_tunnel_filter;
2816 : : int ret;
2817 : :
2818 : 0 : ret = i40e_flow_parse_l4_pattern(pattern, error, tunnel_filter);
2819 [ # # ]: 0 : if (ret)
2820 : : return ret;
2821 : :
2822 : 0 : ret = i40e_flow_parse_tunnel_action(dev, actions, error, tunnel_filter);
2823 [ # # ]: 0 : if (ret)
2824 : : return ret;
2825 : :
2826 : 0 : ret = i40e_flow_parse_attr(attr, error);
2827 [ # # ]: 0 : if (ret)
2828 : : return ret;
2829 : :
2830 : 0 : cons_filter_type = RTE_ETH_FILTER_TUNNEL;
2831 : :
2832 : 0 : return ret;
2833 : : }
2834 : :
2835 : : static uint16_t i40e_supported_tunnel_filter_types[] = {
2836 : : RTE_ETH_TUNNEL_FILTER_IMAC | RTE_ETH_TUNNEL_FILTER_TENID |
2837 : : RTE_ETH_TUNNEL_FILTER_IVLAN,
2838 : : RTE_ETH_TUNNEL_FILTER_IMAC | RTE_ETH_TUNNEL_FILTER_IVLAN,
2839 : : RTE_ETH_TUNNEL_FILTER_IMAC | RTE_ETH_TUNNEL_FILTER_TENID,
2840 : : RTE_ETH_TUNNEL_FILTER_OMAC | RTE_ETH_TUNNEL_FILTER_TENID |
2841 : : RTE_ETH_TUNNEL_FILTER_IMAC,
2842 : : RTE_ETH_TUNNEL_FILTER_IMAC,
2843 : : };
2844 : :
2845 : : static int
2846 : : i40e_check_tunnel_filter_type(uint8_t filter_type)
2847 : : {
2848 : : uint8_t i;
2849 : :
2850 [ # # # # ]: 0 : for (i = 0; i < RTE_DIM(i40e_supported_tunnel_filter_types); i++) {
2851 [ # # # # ]: 0 : if (filter_type == i40e_supported_tunnel_filter_types[i])
2852 : : return 0;
2853 : : }
2854 : :
2855 : : return -1;
2856 : : }
2857 : :
2858 : : /* 1. Last in item should be NULL as range is not supported.
2859 : : * 2. Supported filter types: IMAC_IVLAN_TENID, IMAC_IVLAN,
2860 : : * IMAC_TENID, OMAC_TENID_IMAC and IMAC.
2861 : : * 3. Mask of fields which need to be matched should be
2862 : : * filled with 1.
2863 : : * 4. Mask of fields which needn't to be matched should be
2864 : : * filled with 0.
2865 : : */
2866 : : static int
2867 : 0 : i40e_flow_parse_vxlan_pattern(__rte_unused struct rte_eth_dev *dev,
2868 : : const struct rte_flow_item *pattern,
2869 : : struct rte_flow_error *error,
2870 : : struct i40e_tunnel_filter_conf *filter)
2871 : : {
2872 : : const struct rte_flow_item *item = pattern;
2873 : : const struct rte_flow_item_eth *eth_spec;
2874 : : const struct rte_flow_item_eth *eth_mask;
2875 : : const struct rte_flow_item_vxlan *vxlan_spec;
2876 : : const struct rte_flow_item_vxlan *vxlan_mask;
2877 : : const struct rte_flow_item_vlan *vlan_spec;
2878 : : const struct rte_flow_item_vlan *vlan_mask;
2879 : : uint8_t filter_type = 0;
2880 : : bool is_vni_masked = 0;
2881 : 0 : uint8_t vni_mask[] = {0xFF, 0xFF, 0xFF};
2882 : : enum rte_flow_item_type item_type;
2883 : : bool vxlan_flag = 0;
2884 : 0 : uint32_t tenant_id_be = 0;
2885 : : int ret;
2886 : :
2887 [ # # ]: 0 : for (; item->type != RTE_FLOW_ITEM_TYPE_END; item++) {
2888 [ # # ]: 0 : if (item->last) {
2889 : 0 : rte_flow_error_set(error, EINVAL,
2890 : : RTE_FLOW_ERROR_TYPE_ITEM,
2891 : : item,
2892 : : "Not support range");
2893 : 0 : return -rte_errno;
2894 : : }
2895 : : item_type = item->type;
2896 [ # # # # : 0 : switch (item_type) {
# # # ]
2897 : 0 : case RTE_FLOW_ITEM_TYPE_ETH:
2898 : 0 : eth_spec = item->spec;
2899 : 0 : eth_mask = item->mask;
2900 : :
2901 : : /* Check if ETH item is used for place holder.
2902 : : * If yes, both spec and mask should be NULL.
2903 : : * If no, both spec and mask shouldn't be NULL.
2904 : : */
2905 [ # # ]: 0 : if ((!eth_spec && eth_mask) ||
2906 : : (eth_spec && !eth_mask)) {
2907 : 0 : rte_flow_error_set(error, EINVAL,
2908 : : RTE_FLOW_ERROR_TYPE_ITEM,
2909 : : item,
2910 : : "Invalid ether spec/mask");
2911 : 0 : return -rte_errno;
2912 : : }
2913 : :
2914 [ # # ]: 0 : if (eth_spec && eth_mask) {
2915 : : /* DST address of inner MAC shouldn't be masked.
2916 : : * SRC address of Inner MAC should be masked.
2917 : : */
2918 [ # # # # ]: 0 : if (!rte_is_broadcast_ether_addr(ð_mask->hdr.dst_addr) ||
2919 : 0 : !rte_is_zero_ether_addr(ð_mask->hdr.src_addr) ||
2920 [ # # ]: 0 : eth_mask->hdr.ether_type) {
2921 : 0 : rte_flow_error_set(error, EINVAL,
2922 : : RTE_FLOW_ERROR_TYPE_ITEM,
2923 : : item,
2924 : : "Invalid ether spec/mask");
2925 : 0 : return -rte_errno;
2926 : : }
2927 : :
2928 [ # # ]: 0 : if (!vxlan_flag) {
2929 : 0 : rte_memcpy(&filter->outer_mac,
2930 [ # # ]: 0 : ð_spec->hdr.dst_addr,
2931 : : RTE_ETHER_ADDR_LEN);
2932 : 0 : filter_type |= RTE_ETH_TUNNEL_FILTER_OMAC;
2933 : : } else {
2934 : 0 : rte_memcpy(&filter->inner_mac,
2935 [ # # ]: 0 : ð_spec->hdr.dst_addr,
2936 : : RTE_ETHER_ADDR_LEN);
2937 : 0 : filter_type |= RTE_ETH_TUNNEL_FILTER_IMAC;
2938 : : }
2939 : : }
2940 : : break;
2941 : 0 : case RTE_FLOW_ITEM_TYPE_VLAN:
2942 : 0 : vlan_spec = item->spec;
2943 : 0 : vlan_mask = item->mask;
2944 [ # # ]: 0 : if (!(vlan_spec && vlan_mask) ||
2945 [ # # ]: 0 : vlan_mask->hdr.eth_proto) {
2946 : 0 : rte_flow_error_set(error, EINVAL,
2947 : : RTE_FLOW_ERROR_TYPE_ITEM,
2948 : : item,
2949 : : "Invalid vlan item");
2950 : 0 : return -rte_errno;
2951 : : }
2952 : :
2953 : : if (vlan_spec && vlan_mask) {
2954 [ # # ]: 0 : if (vlan_mask->hdr.vlan_tci ==
2955 : : rte_cpu_to_be_16(I40E_VLAN_TCI_MASK))
2956 : 0 : filter->inner_vlan =
2957 [ # # ]: 0 : rte_be_to_cpu_16(vlan_spec->hdr.vlan_tci) &
2958 : : I40E_VLAN_TCI_MASK;
2959 : 0 : filter_type |= RTE_ETH_TUNNEL_FILTER_IVLAN;
2960 : : }
2961 : : break;
2962 : 0 : case RTE_FLOW_ITEM_TYPE_IPV4:
2963 : 0 : filter->ip_type = I40E_TUNNEL_IPTYPE_IPV4;
2964 : : /* IPv4 is used to describe protocol,
2965 : : * spec and mask should be NULL.
2966 : : */
2967 [ # # # # ]: 0 : if (item->spec || item->mask) {
2968 : 0 : rte_flow_error_set(error, EINVAL,
2969 : : RTE_FLOW_ERROR_TYPE_ITEM,
2970 : : item,
2971 : : "Invalid IPv4 item");
2972 : 0 : return -rte_errno;
2973 : : }
2974 : : break;
2975 : 0 : case RTE_FLOW_ITEM_TYPE_IPV6:
2976 : 0 : filter->ip_type = I40E_TUNNEL_IPTYPE_IPV6;
2977 : : /* IPv6 is used to describe protocol,
2978 : : * spec and mask should be NULL.
2979 : : */
2980 [ # # # # ]: 0 : if (item->spec || item->mask) {
2981 : 0 : rte_flow_error_set(error, EINVAL,
2982 : : RTE_FLOW_ERROR_TYPE_ITEM,
2983 : : item,
2984 : : "Invalid IPv6 item");
2985 : 0 : return -rte_errno;
2986 : : }
2987 : : break;
2988 : 0 : case RTE_FLOW_ITEM_TYPE_UDP:
2989 : : /* UDP is used to describe protocol,
2990 : : * spec and mask should be NULL.
2991 : : */
2992 [ # # # # ]: 0 : if (item->spec || item->mask) {
2993 : 0 : rte_flow_error_set(error, EINVAL,
2994 : : RTE_FLOW_ERROR_TYPE_ITEM,
2995 : : item,
2996 : : "Invalid UDP item");
2997 : 0 : return -rte_errno;
2998 : : }
2999 : : break;
3000 : 0 : case RTE_FLOW_ITEM_TYPE_VXLAN:
3001 : 0 : vxlan_spec = item->spec;
3002 : 0 : vxlan_mask = item->mask;
3003 : : /* Check if VXLAN item is used to describe protocol.
3004 : : * If yes, both spec and mask should be NULL.
3005 : : * If no, both spec and mask shouldn't be NULL.
3006 : : */
3007 [ # # ]: 0 : if ((!vxlan_spec && vxlan_mask) ||
3008 : : (vxlan_spec && !vxlan_mask)) {
3009 : 0 : rte_flow_error_set(error, EINVAL,
3010 : : RTE_FLOW_ERROR_TYPE_ITEM,
3011 : : item,
3012 : : "Invalid VXLAN item");
3013 : 0 : return -rte_errno;
3014 : : }
3015 : :
3016 : : /* Check if VNI is masked. */
3017 [ # # ]: 0 : if (vxlan_spec && vxlan_mask) {
3018 : : is_vni_masked =
3019 : 0 : !!memcmp(vxlan_mask->hdr.vni, vni_mask,
3020 : : RTE_DIM(vni_mask));
3021 [ # # ]: 0 : if (is_vni_masked) {
3022 : 0 : rte_flow_error_set(error, EINVAL,
3023 : : RTE_FLOW_ERROR_TYPE_ITEM,
3024 : : item,
3025 : : "Invalid VNI mask");
3026 : 0 : return -rte_errno;
3027 : : }
3028 : :
3029 : : rte_memcpy(((uint8_t *)&tenant_id_be + 1),
3030 : : vxlan_spec->hdr.vni, 3);
3031 : 0 : filter->tenant_id =
3032 [ # # ]: 0 : rte_be_to_cpu_32(tenant_id_be);
3033 : 0 : filter_type |= RTE_ETH_TUNNEL_FILTER_TENID;
3034 : : }
3035 : :
3036 : : vxlan_flag = 1;
3037 : : break;
3038 : : default:
3039 : : break;
3040 : : }
3041 : : }
3042 : :
3043 : : ret = i40e_check_tunnel_filter_type(filter_type);
3044 [ # # ]: 0 : if (ret < 0) {
3045 : 0 : rte_flow_error_set(error, EINVAL,
3046 : : RTE_FLOW_ERROR_TYPE_ITEM,
3047 : : NULL,
3048 : : "Invalid filter type");
3049 : 0 : return -rte_errno;
3050 : : }
3051 : 0 : filter->filter_type = filter_type;
3052 : :
3053 : 0 : filter->tunnel_type = I40E_TUNNEL_TYPE_VXLAN;
3054 : :
3055 : 0 : return 0;
3056 : : }
3057 : :
3058 : : static int
3059 : 0 : i40e_flow_parse_vxlan_filter(struct rte_eth_dev *dev,
3060 : : const struct rte_flow_attr *attr,
3061 : : const struct rte_flow_item pattern[],
3062 : : const struct rte_flow_action actions[],
3063 : : struct rte_flow_error *error,
3064 : : union i40e_filter_t *filter)
3065 : : {
3066 : 0 : struct i40e_tunnel_filter_conf *tunnel_filter =
3067 : : &filter->consistent_tunnel_filter;
3068 : : int ret;
3069 : :
3070 : 0 : ret = i40e_flow_parse_vxlan_pattern(dev, pattern,
3071 : : error, tunnel_filter);
3072 [ # # ]: 0 : if (ret)
3073 : : return ret;
3074 : :
3075 : 0 : ret = i40e_flow_parse_tunnel_action(dev, actions, error, tunnel_filter);
3076 [ # # ]: 0 : if (ret)
3077 : : return ret;
3078 : :
3079 : 0 : ret = i40e_flow_parse_attr(attr, error);
3080 [ # # ]: 0 : if (ret)
3081 : : return ret;
3082 : :
3083 : 0 : cons_filter_type = RTE_ETH_FILTER_TUNNEL;
3084 : :
3085 : 0 : return ret;
3086 : : }
3087 : :
3088 : : /* 1. Last in item should be NULL as range is not supported.
3089 : : * 2. Supported filter types: IMAC_IVLAN_TENID, IMAC_IVLAN,
3090 : : * IMAC_TENID, OMAC_TENID_IMAC and IMAC.
3091 : : * 3. Mask of fields which need to be matched should be
3092 : : * filled with 1.
3093 : : * 4. Mask of fields which needn't to be matched should be
3094 : : * filled with 0.
3095 : : */
3096 : : static int
3097 : 0 : i40e_flow_parse_nvgre_pattern(__rte_unused struct rte_eth_dev *dev,
3098 : : const struct rte_flow_item *pattern,
3099 : : struct rte_flow_error *error,
3100 : : struct i40e_tunnel_filter_conf *filter)
3101 : : {
3102 : : const struct rte_flow_item *item = pattern;
3103 : : const struct rte_flow_item_eth *eth_spec;
3104 : : const struct rte_flow_item_eth *eth_mask;
3105 : : const struct rte_flow_item_nvgre *nvgre_spec;
3106 : : const struct rte_flow_item_nvgre *nvgre_mask;
3107 : : const struct rte_flow_item_vlan *vlan_spec;
3108 : : const struct rte_flow_item_vlan *vlan_mask;
3109 : : enum rte_flow_item_type item_type;
3110 : : uint8_t filter_type = 0;
3111 : : bool is_tni_masked = 0;
3112 : 0 : uint8_t tni_mask[] = {0xFF, 0xFF, 0xFF};
3113 : : bool nvgre_flag = 0;
3114 : 0 : uint32_t tenant_id_be = 0;
3115 : : int ret;
3116 : :
3117 [ # # ]: 0 : for (; item->type != RTE_FLOW_ITEM_TYPE_END; item++) {
3118 [ # # ]: 0 : if (item->last) {
3119 : 0 : rte_flow_error_set(error, EINVAL,
3120 : : RTE_FLOW_ERROR_TYPE_ITEM,
3121 : : item,
3122 : : "Not support range");
3123 : 0 : return -rte_errno;
3124 : : }
3125 : : item_type = item->type;
3126 [ # # # # : 0 : switch (item_type) {
# # ]
3127 : 0 : case RTE_FLOW_ITEM_TYPE_ETH:
3128 : 0 : eth_spec = item->spec;
3129 : 0 : eth_mask = item->mask;
3130 : :
3131 : : /* Check if ETH item is used for place holder.
3132 : : * If yes, both spec and mask should be NULL.
3133 : : * If no, both spec and mask shouldn't be NULL.
3134 : : */
3135 [ # # ]: 0 : if ((!eth_spec && eth_mask) ||
3136 : : (eth_spec && !eth_mask)) {
3137 : 0 : rte_flow_error_set(error, EINVAL,
3138 : : RTE_FLOW_ERROR_TYPE_ITEM,
3139 : : item,
3140 : : "Invalid ether spec/mask");
3141 : 0 : return -rte_errno;
3142 : : }
3143 : :
3144 [ # # ]: 0 : if (eth_spec && eth_mask) {
3145 : : /* DST address of inner MAC shouldn't be masked.
3146 : : * SRC address of Inner MAC should be masked.
3147 : : */
3148 [ # # # # ]: 0 : if (!rte_is_broadcast_ether_addr(ð_mask->hdr.dst_addr) ||
3149 : 0 : !rte_is_zero_ether_addr(ð_mask->hdr.src_addr) ||
3150 [ # # ]: 0 : eth_mask->hdr.ether_type) {
3151 : 0 : rte_flow_error_set(error, EINVAL,
3152 : : RTE_FLOW_ERROR_TYPE_ITEM,
3153 : : item,
3154 : : "Invalid ether spec/mask");
3155 : 0 : return -rte_errno;
3156 : : }
3157 : :
3158 [ # # ]: 0 : if (!nvgre_flag) {
3159 : 0 : rte_memcpy(&filter->outer_mac,
3160 [ # # ]: 0 : ð_spec->hdr.dst_addr,
3161 : : RTE_ETHER_ADDR_LEN);
3162 : 0 : filter_type |= RTE_ETH_TUNNEL_FILTER_OMAC;
3163 : : } else {
3164 : 0 : rte_memcpy(&filter->inner_mac,
3165 [ # # ]: 0 : ð_spec->hdr.dst_addr,
3166 : : RTE_ETHER_ADDR_LEN);
3167 : 0 : filter_type |= RTE_ETH_TUNNEL_FILTER_IMAC;
3168 : : }
3169 : : }
3170 : :
3171 : : break;
3172 : 0 : case RTE_FLOW_ITEM_TYPE_VLAN:
3173 : 0 : vlan_spec = item->spec;
3174 : 0 : vlan_mask = item->mask;
3175 [ # # ]: 0 : if (!(vlan_spec && vlan_mask) ||
3176 [ # # ]: 0 : vlan_mask->hdr.eth_proto) {
3177 : 0 : rte_flow_error_set(error, EINVAL,
3178 : : RTE_FLOW_ERROR_TYPE_ITEM,
3179 : : item,
3180 : : "Invalid vlan item");
3181 : 0 : return -rte_errno;
3182 : : }
3183 : :
3184 : : if (vlan_spec && vlan_mask) {
3185 [ # # ]: 0 : if (vlan_mask->hdr.vlan_tci ==
3186 : : rte_cpu_to_be_16(I40E_VLAN_TCI_MASK))
3187 : 0 : filter->inner_vlan =
3188 [ # # ]: 0 : rte_be_to_cpu_16(vlan_spec->hdr.vlan_tci) &
3189 : : I40E_VLAN_TCI_MASK;
3190 : 0 : filter_type |= RTE_ETH_TUNNEL_FILTER_IVLAN;
3191 : : }
3192 : : break;
3193 : 0 : case RTE_FLOW_ITEM_TYPE_IPV4:
3194 : 0 : filter->ip_type = I40E_TUNNEL_IPTYPE_IPV4;
3195 : : /* IPv4 is used to describe protocol,
3196 : : * spec and mask should be NULL.
3197 : : */
3198 [ # # # # ]: 0 : if (item->spec || item->mask) {
3199 : 0 : rte_flow_error_set(error, EINVAL,
3200 : : RTE_FLOW_ERROR_TYPE_ITEM,
3201 : : item,
3202 : : "Invalid IPv4 item");
3203 : 0 : return -rte_errno;
3204 : : }
3205 : : break;
3206 : 0 : case RTE_FLOW_ITEM_TYPE_IPV6:
3207 : 0 : filter->ip_type = I40E_TUNNEL_IPTYPE_IPV6;
3208 : : /* IPv6 is used to describe protocol,
3209 : : * spec and mask should be NULL.
3210 : : */
3211 [ # # # # ]: 0 : if (item->spec || item->mask) {
3212 : 0 : rte_flow_error_set(error, EINVAL,
3213 : : RTE_FLOW_ERROR_TYPE_ITEM,
3214 : : item,
3215 : : "Invalid IPv6 item");
3216 : 0 : return -rte_errno;
3217 : : }
3218 : : break;
3219 : 0 : case RTE_FLOW_ITEM_TYPE_NVGRE:
3220 : 0 : nvgre_spec = item->spec;
3221 : 0 : nvgre_mask = item->mask;
3222 : : /* Check if NVGRE item is used to describe protocol.
3223 : : * If yes, both spec and mask should be NULL.
3224 : : * If no, both spec and mask shouldn't be NULL.
3225 : : */
3226 [ # # ]: 0 : if ((!nvgre_spec && nvgre_mask) ||
3227 : : (nvgre_spec && !nvgre_mask)) {
3228 : 0 : rte_flow_error_set(error, EINVAL,
3229 : : RTE_FLOW_ERROR_TYPE_ITEM,
3230 : : item,
3231 : : "Invalid NVGRE item");
3232 : 0 : return -rte_errno;
3233 : : }
3234 : :
3235 [ # # ]: 0 : if (nvgre_spec && nvgre_mask) {
3236 : : is_tni_masked =
3237 : 0 : !!memcmp(nvgre_mask->tni, tni_mask,
3238 : : RTE_DIM(tni_mask));
3239 [ # # ]: 0 : if (is_tni_masked) {
3240 : 0 : rte_flow_error_set(error, EINVAL,
3241 : : RTE_FLOW_ERROR_TYPE_ITEM,
3242 : : item,
3243 : : "Invalid TNI mask");
3244 : 0 : return -rte_errno;
3245 : : }
3246 [ # # ]: 0 : if (nvgre_mask->protocol &&
3247 : : nvgre_mask->protocol != 0xFFFF) {
3248 : 0 : rte_flow_error_set(error, EINVAL,
3249 : : RTE_FLOW_ERROR_TYPE_ITEM,
3250 : : item,
3251 : : "Invalid NVGRE item");
3252 : 0 : return -rte_errno;
3253 : : }
3254 [ # # # # ]: 0 : if (nvgre_mask->c_k_s_rsvd0_ver &&
3255 : : nvgre_mask->c_k_s_rsvd0_ver !=
3256 : : rte_cpu_to_be_16(0xFFFF)) {
3257 : 0 : rte_flow_error_set(error, EINVAL,
3258 : : RTE_FLOW_ERROR_TYPE_ITEM,
3259 : : item,
3260 : : "Invalid NVGRE item");
3261 : 0 : return -rte_errno;
3262 : : }
3263 [ # # ]: 0 : if (nvgre_spec->c_k_s_rsvd0_ver !=
3264 [ # # ]: 0 : rte_cpu_to_be_16(0x2000) &&
3265 : : nvgre_mask->c_k_s_rsvd0_ver) {
3266 : 0 : rte_flow_error_set(error, EINVAL,
3267 : : RTE_FLOW_ERROR_TYPE_ITEM,
3268 : : item,
3269 : : "Invalid NVGRE item");
3270 : 0 : return -rte_errno;
3271 : : }
3272 [ # # ]: 0 : if (nvgre_mask->protocol &&
3273 [ # # ]: 0 : nvgre_spec->protocol !=
3274 : : rte_cpu_to_be_16(0x6558)) {
3275 : 0 : rte_flow_error_set(error, EINVAL,
3276 : : RTE_FLOW_ERROR_TYPE_ITEM,
3277 : : item,
3278 : : "Invalid NVGRE item");
3279 : 0 : return -rte_errno;
3280 : : }
3281 : : rte_memcpy(((uint8_t *)&tenant_id_be + 1),
3282 : : nvgre_spec->tni, 3);
3283 : 0 : filter->tenant_id =
3284 [ # # ]: 0 : rte_be_to_cpu_32(tenant_id_be);
3285 : 0 : filter_type |= RTE_ETH_TUNNEL_FILTER_TENID;
3286 : : }
3287 : :
3288 : : nvgre_flag = 1;
3289 : : break;
3290 : : default:
3291 : : break;
3292 : : }
3293 : : }
3294 : :
3295 : : ret = i40e_check_tunnel_filter_type(filter_type);
3296 [ # # ]: 0 : if (ret < 0) {
3297 : 0 : rte_flow_error_set(error, EINVAL,
3298 : : RTE_FLOW_ERROR_TYPE_ITEM,
3299 : : NULL,
3300 : : "Invalid filter type");
3301 : 0 : return -rte_errno;
3302 : : }
3303 : 0 : filter->filter_type = filter_type;
3304 : :
3305 : 0 : filter->tunnel_type = I40E_TUNNEL_TYPE_NVGRE;
3306 : :
3307 : 0 : return 0;
3308 : : }
3309 : :
3310 : : static int
3311 : 0 : i40e_flow_parse_nvgre_filter(struct rte_eth_dev *dev,
3312 : : const struct rte_flow_attr *attr,
3313 : : const struct rte_flow_item pattern[],
3314 : : const struct rte_flow_action actions[],
3315 : : struct rte_flow_error *error,
3316 : : union i40e_filter_t *filter)
3317 : : {
3318 : 0 : struct i40e_tunnel_filter_conf *tunnel_filter =
3319 : : &filter->consistent_tunnel_filter;
3320 : : int ret;
3321 : :
3322 : 0 : ret = i40e_flow_parse_nvgre_pattern(dev, pattern,
3323 : : error, tunnel_filter);
3324 [ # # ]: 0 : if (ret)
3325 : : return ret;
3326 : :
3327 : 0 : ret = i40e_flow_parse_tunnel_action(dev, actions, error, tunnel_filter);
3328 [ # # ]: 0 : if (ret)
3329 : : return ret;
3330 : :
3331 : 0 : ret = i40e_flow_parse_attr(attr, error);
3332 [ # # ]: 0 : if (ret)
3333 : : return ret;
3334 : :
3335 : 0 : cons_filter_type = RTE_ETH_FILTER_TUNNEL;
3336 : :
3337 : 0 : return ret;
3338 : : }
3339 : :
3340 : : /* 1. Last in item should be NULL as range is not supported.
3341 : : * 2. Supported filter types: MPLS label.
3342 : : * 3. Mask of fields which need to be matched should be
3343 : : * filled with 1.
3344 : : * 4. Mask of fields which needn't to be matched should be
3345 : : * filled with 0.
3346 : : */
3347 : : static int
3348 : 0 : i40e_flow_parse_mpls_pattern(__rte_unused struct rte_eth_dev *dev,
3349 : : const struct rte_flow_item *pattern,
3350 : : struct rte_flow_error *error,
3351 : : struct i40e_tunnel_filter_conf *filter)
3352 : : {
3353 : : const struct rte_flow_item *item = pattern;
3354 : : const struct rte_flow_item_mpls *mpls_spec;
3355 : : const struct rte_flow_item_mpls *mpls_mask;
3356 : : enum rte_flow_item_type item_type;
3357 : : bool is_mplsoudp = 0; /* 1 - MPLSoUDP, 0 - MPLSoGRE */
3358 : 0 : const uint8_t label_mask[3] = {0xFF, 0xFF, 0xF0};
3359 : 0 : uint32_t label_be = 0;
3360 : :
3361 [ # # ]: 0 : for (; item->type != RTE_FLOW_ITEM_TYPE_END; item++) {
3362 [ # # ]: 0 : if (item->last) {
3363 : 0 : rte_flow_error_set(error, EINVAL,
3364 : : RTE_FLOW_ERROR_TYPE_ITEM,
3365 : : item,
3366 : : "Not support range");
3367 : 0 : return -rte_errno;
3368 : : }
3369 : : item_type = item->type;
3370 [ # # # # : 0 : switch (item_type) {
# # # ]
3371 : 0 : case RTE_FLOW_ITEM_TYPE_ETH:
3372 [ # # # # ]: 0 : if (item->spec || item->mask) {
3373 : 0 : rte_flow_error_set(error, EINVAL,
3374 : : RTE_FLOW_ERROR_TYPE_ITEM,
3375 : : item,
3376 : : "Invalid ETH item");
3377 : 0 : return -rte_errno;
3378 : : }
3379 : : break;
3380 : 0 : case RTE_FLOW_ITEM_TYPE_IPV4:
3381 : 0 : filter->ip_type = I40E_TUNNEL_IPTYPE_IPV4;
3382 : : /* IPv4 is used to describe protocol,
3383 : : * spec and mask should be NULL.
3384 : : */
3385 [ # # # # ]: 0 : if (item->spec || item->mask) {
3386 : 0 : rte_flow_error_set(error, EINVAL,
3387 : : RTE_FLOW_ERROR_TYPE_ITEM,
3388 : : item,
3389 : : "Invalid IPv4 item");
3390 : 0 : return -rte_errno;
3391 : : }
3392 : : break;
3393 : 0 : case RTE_FLOW_ITEM_TYPE_IPV6:
3394 : 0 : filter->ip_type = I40E_TUNNEL_IPTYPE_IPV6;
3395 : : /* IPv6 is used to describe protocol,
3396 : : * spec and mask should be NULL.
3397 : : */
3398 [ # # # # ]: 0 : if (item->spec || item->mask) {
3399 : 0 : rte_flow_error_set(error, EINVAL,
3400 : : RTE_FLOW_ERROR_TYPE_ITEM,
3401 : : item,
3402 : : "Invalid IPv6 item");
3403 : 0 : return -rte_errno;
3404 : : }
3405 : : break;
3406 : 0 : case RTE_FLOW_ITEM_TYPE_UDP:
3407 : : /* UDP is used to describe protocol,
3408 : : * spec and mask should be NULL.
3409 : : */
3410 [ # # # # ]: 0 : if (item->spec || item->mask) {
3411 : 0 : rte_flow_error_set(error, EINVAL,
3412 : : RTE_FLOW_ERROR_TYPE_ITEM,
3413 : : item,
3414 : : "Invalid UDP item");
3415 : 0 : return -rte_errno;
3416 : : }
3417 : : is_mplsoudp = 1;
3418 : : break;
3419 : 0 : case RTE_FLOW_ITEM_TYPE_GRE:
3420 : : /* GRE is used to describe protocol,
3421 : : * spec and mask should be NULL.
3422 : : */
3423 [ # # # # ]: 0 : if (item->spec || item->mask) {
3424 : 0 : rte_flow_error_set(error, EINVAL,
3425 : : RTE_FLOW_ERROR_TYPE_ITEM,
3426 : : item,
3427 : : "Invalid GRE item");
3428 : 0 : return -rte_errno;
3429 : : }
3430 : : break;
3431 : 0 : case RTE_FLOW_ITEM_TYPE_MPLS:
3432 : 0 : mpls_spec = item->spec;
3433 : 0 : mpls_mask = item->mask;
3434 : :
3435 [ # # ]: 0 : if (!mpls_spec || !mpls_mask) {
3436 : 0 : rte_flow_error_set(error, EINVAL,
3437 : : RTE_FLOW_ERROR_TYPE_ITEM,
3438 : : item,
3439 : : "Invalid MPLS item");
3440 : 0 : return -rte_errno;
3441 : : }
3442 : :
3443 [ # # ]: 0 : if (memcmp(mpls_mask->label_tc_s, label_mask, 3)) {
3444 : 0 : rte_flow_error_set(error, EINVAL,
3445 : : RTE_FLOW_ERROR_TYPE_ITEM,
3446 : : item,
3447 : : "Invalid MPLS label mask");
3448 : 0 : return -rte_errno;
3449 : : }
3450 : : rte_memcpy(((uint8_t *)&label_be + 1),
3451 : : mpls_spec->label_tc_s, 3);
3452 [ # # ]: 0 : filter->tenant_id = rte_be_to_cpu_32(label_be) >> 4;
3453 : 0 : break;
3454 : : default:
3455 : : break;
3456 : : }
3457 : : }
3458 : :
3459 [ # # ]: 0 : if (is_mplsoudp)
3460 : 0 : filter->tunnel_type = I40E_TUNNEL_TYPE_MPLSoUDP;
3461 : : else
3462 : 0 : filter->tunnel_type = I40E_TUNNEL_TYPE_MPLSoGRE;
3463 : :
3464 : : return 0;
3465 : : }
3466 : :
3467 : : static int
3468 : 0 : i40e_flow_parse_mpls_filter(struct rte_eth_dev *dev,
3469 : : const struct rte_flow_attr *attr,
3470 : : const struct rte_flow_item pattern[],
3471 : : const struct rte_flow_action actions[],
3472 : : struct rte_flow_error *error,
3473 : : union i40e_filter_t *filter)
3474 : : {
3475 : 0 : struct i40e_tunnel_filter_conf *tunnel_filter =
3476 : : &filter->consistent_tunnel_filter;
3477 : : int ret;
3478 : :
3479 : 0 : ret = i40e_flow_parse_mpls_pattern(dev, pattern,
3480 : : error, tunnel_filter);
3481 [ # # ]: 0 : if (ret)
3482 : : return ret;
3483 : :
3484 : 0 : ret = i40e_flow_parse_tunnel_action(dev, actions, error, tunnel_filter);
3485 [ # # ]: 0 : if (ret)
3486 : : return ret;
3487 : :
3488 : 0 : ret = i40e_flow_parse_attr(attr, error);
3489 [ # # ]: 0 : if (ret)
3490 : : return ret;
3491 : :
3492 : 0 : cons_filter_type = RTE_ETH_FILTER_TUNNEL;
3493 : :
3494 : 0 : return ret;
3495 : : }
3496 : :
3497 : : /* 1. Last in item should be NULL as range is not supported.
3498 : : * 2. Supported filter types: GTP TEID.
3499 : : * 3. Mask of fields which need to be matched should be
3500 : : * filled with 1.
3501 : : * 4. Mask of fields which needn't to be matched should be
3502 : : * filled with 0.
3503 : : * 5. GTP profile supports GTPv1 only.
3504 : : * 6. GTP-C response message ('source_port' = 2123) is not supported.
3505 : : */
3506 : : static int
3507 : 0 : i40e_flow_parse_gtp_pattern(struct rte_eth_dev *dev,
3508 : : const struct rte_flow_item *pattern,
3509 : : struct rte_flow_error *error,
3510 : : struct i40e_tunnel_filter_conf *filter)
3511 : : {
3512 : 0 : struct i40e_pf *pf = I40E_DEV_PRIVATE_TO_PF(dev->data->dev_private);
3513 : : const struct rte_flow_item *item = pattern;
3514 : : const struct rte_flow_item_gtp *gtp_spec;
3515 : : const struct rte_flow_item_gtp *gtp_mask;
3516 : : enum rte_flow_item_type item_type;
3517 : :
3518 [ # # ]: 0 : if (!pf->gtp_support) {
3519 : 0 : rte_flow_error_set(error, EINVAL,
3520 : : RTE_FLOW_ERROR_TYPE_ITEM,
3521 : : item,
3522 : : "GTP is not supported by default.");
3523 : 0 : return -rte_errno;
3524 : : }
3525 : :
3526 [ # # ]: 0 : for (; item->type != RTE_FLOW_ITEM_TYPE_END; item++) {
3527 [ # # ]: 0 : if (item->last) {
3528 : 0 : rte_flow_error_set(error, EINVAL,
3529 : : RTE_FLOW_ERROR_TYPE_ITEM,
3530 : : item,
3531 : : "Not support range");
3532 : 0 : return -rte_errno;
3533 : : }
3534 : : item_type = item->type;
3535 [ # # # # : 0 : switch (item_type) {
# ]
3536 : 0 : case RTE_FLOW_ITEM_TYPE_ETH:
3537 [ # # # # ]: 0 : if (item->spec || item->mask) {
3538 : 0 : rte_flow_error_set(error, EINVAL,
3539 : : RTE_FLOW_ERROR_TYPE_ITEM,
3540 : : item,
3541 : : "Invalid ETH item");
3542 : 0 : return -rte_errno;
3543 : : }
3544 : : break;
3545 : 0 : case RTE_FLOW_ITEM_TYPE_IPV4:
3546 : 0 : filter->ip_type = I40E_TUNNEL_IPTYPE_IPV4;
3547 : : /* IPv4 is used to describe protocol,
3548 : : * spec and mask should be NULL.
3549 : : */
3550 [ # # # # ]: 0 : if (item->spec || item->mask) {
3551 : 0 : rte_flow_error_set(error, EINVAL,
3552 : : RTE_FLOW_ERROR_TYPE_ITEM,
3553 : : item,
3554 : : "Invalid IPv4 item");
3555 : 0 : return -rte_errno;
3556 : : }
3557 : : break;
3558 : 0 : case RTE_FLOW_ITEM_TYPE_UDP:
3559 [ # # # # ]: 0 : if (item->spec || item->mask) {
3560 : 0 : rte_flow_error_set(error, EINVAL,
3561 : : RTE_FLOW_ERROR_TYPE_ITEM,
3562 : : item,
3563 : : "Invalid UDP item");
3564 : 0 : return -rte_errno;
3565 : : }
3566 : : break;
3567 : 0 : case RTE_FLOW_ITEM_TYPE_GTPC:
3568 : : case RTE_FLOW_ITEM_TYPE_GTPU:
3569 : 0 : gtp_spec = item->spec;
3570 : 0 : gtp_mask = item->mask;
3571 : :
3572 [ # # ]: 0 : if (!gtp_spec || !gtp_mask) {
3573 : 0 : rte_flow_error_set(error, EINVAL,
3574 : : RTE_FLOW_ERROR_TYPE_ITEM,
3575 : : item,
3576 : : "Invalid GTP item");
3577 : 0 : return -rte_errno;
3578 : : }
3579 : :
3580 : 0 : if (gtp_mask->hdr.gtp_hdr_info ||
3581 [ # # ]: 0 : gtp_mask->hdr.msg_type ||
3582 : 0 : gtp_mask->hdr.plen ||
3583 [ # # ]: 0 : gtp_mask->hdr.teid != UINT32_MAX) {
3584 : 0 : rte_flow_error_set(error, EINVAL,
3585 : : RTE_FLOW_ERROR_TYPE_ITEM,
3586 : : item,
3587 : : "Invalid GTP mask");
3588 : 0 : return -rte_errno;
3589 : : }
3590 : :
3591 [ # # ]: 0 : if (item_type == RTE_FLOW_ITEM_TYPE_GTPC)
3592 : 0 : filter->tunnel_type = I40E_TUNNEL_TYPE_GTPC;
3593 : : else if (item_type == RTE_FLOW_ITEM_TYPE_GTPU)
3594 : 0 : filter->tunnel_type = I40E_TUNNEL_TYPE_GTPU;
3595 : :
3596 [ # # ]: 0 : filter->tenant_id = rte_be_to_cpu_32(gtp_spec->hdr.teid);
3597 : :
3598 : 0 : break;
3599 : : default:
3600 : : break;
3601 : : }
3602 : : }
3603 : :
3604 : : return 0;
3605 : : }
3606 : :
3607 : : static int
3608 : 0 : i40e_flow_parse_gtp_filter(struct rte_eth_dev *dev,
3609 : : const struct rte_flow_attr *attr,
3610 : : const struct rte_flow_item pattern[],
3611 : : const struct rte_flow_action actions[],
3612 : : struct rte_flow_error *error,
3613 : : union i40e_filter_t *filter)
3614 : : {
3615 : 0 : struct i40e_tunnel_filter_conf *tunnel_filter =
3616 : : &filter->consistent_tunnel_filter;
3617 : : int ret;
3618 : :
3619 : 0 : ret = i40e_flow_parse_gtp_pattern(dev, pattern,
3620 : : error, tunnel_filter);
3621 [ # # ]: 0 : if (ret)
3622 : : return ret;
3623 : :
3624 : 0 : ret = i40e_flow_parse_tunnel_action(dev, actions, error, tunnel_filter);
3625 [ # # ]: 0 : if (ret)
3626 : : return ret;
3627 : :
3628 : 0 : ret = i40e_flow_parse_attr(attr, error);
3629 [ # # ]: 0 : if (ret)
3630 : : return ret;
3631 : :
3632 : 0 : cons_filter_type = RTE_ETH_FILTER_TUNNEL;
3633 : :
3634 : 0 : return ret;
3635 : : }
3636 : :
3637 : : /* 1. Last in item should be NULL as range is not supported.
3638 : : * 2. Supported filter types: QINQ.
3639 : : * 3. Mask of fields which need to be matched should be
3640 : : * filled with 1.
3641 : : * 4. Mask of fields which needn't to be matched should be
3642 : : * filled with 0.
3643 : : */
3644 : : static int
3645 : 0 : i40e_flow_parse_qinq_pattern(__rte_unused struct rte_eth_dev *dev,
3646 : : const struct rte_flow_item *pattern,
3647 : : struct rte_flow_error *error,
3648 : : struct i40e_tunnel_filter_conf *filter)
3649 : : {
3650 : : const struct rte_flow_item *item = pattern;
3651 : : const struct rte_flow_item_vlan *vlan_spec = NULL;
3652 : : const struct rte_flow_item_vlan *vlan_mask = NULL;
3653 : : const struct rte_flow_item_vlan *i_vlan_spec = NULL;
3654 : : const struct rte_flow_item_vlan *i_vlan_mask = NULL;
3655 : : const struct rte_flow_item_vlan *o_vlan_spec = NULL;
3656 : : const struct rte_flow_item_vlan *o_vlan_mask = NULL;
3657 : :
3658 : : enum rte_flow_item_type item_type;
3659 : : bool vlan_flag = 0;
3660 : :
3661 [ # # ]: 0 : for (; item->type != RTE_FLOW_ITEM_TYPE_END; item++) {
3662 [ # # ]: 0 : if (item->last) {
3663 : 0 : rte_flow_error_set(error, EINVAL,
3664 : : RTE_FLOW_ERROR_TYPE_ITEM,
3665 : : item,
3666 : : "Not support range");
3667 : 0 : return -rte_errno;
3668 : : }
3669 : : item_type = item->type;
3670 [ # # # ]: 0 : switch (item_type) {
3671 : 0 : case RTE_FLOW_ITEM_TYPE_ETH:
3672 [ # # # # ]: 0 : if (item->spec || item->mask) {
3673 : 0 : rte_flow_error_set(error, EINVAL,
3674 : : RTE_FLOW_ERROR_TYPE_ITEM,
3675 : : item,
3676 : : "Invalid ETH item");
3677 : 0 : return -rte_errno;
3678 : : }
3679 : : break;
3680 : 0 : case RTE_FLOW_ITEM_TYPE_VLAN:
3681 : 0 : vlan_spec = item->spec;
3682 : 0 : vlan_mask = item->mask;
3683 : :
3684 [ # # ]: 0 : if (!(vlan_spec && vlan_mask) ||
3685 [ # # ]: 0 : vlan_mask->hdr.eth_proto) {
3686 : 0 : rte_flow_error_set(error, EINVAL,
3687 : : RTE_FLOW_ERROR_TYPE_ITEM,
3688 : : item,
3689 : : "Invalid vlan item");
3690 : 0 : return -rte_errno;
3691 : : }
3692 : :
3693 [ # # ]: 0 : if (!vlan_flag) {
3694 : : o_vlan_spec = vlan_spec;
3695 : : o_vlan_mask = vlan_mask;
3696 : : vlan_flag = 1;
3697 : : } else {
3698 : : i_vlan_spec = vlan_spec;
3699 : : i_vlan_mask = vlan_mask;
3700 : : vlan_flag = 0;
3701 : : }
3702 : : break;
3703 : :
3704 : : default:
3705 : : break;
3706 : : }
3707 : : }
3708 : :
3709 : : /* Get filter specification */
3710 [ # # ]: 0 : if (o_vlan_mask != NULL && i_vlan_mask != NULL) {
3711 [ # # ]: 0 : filter->outer_vlan = rte_be_to_cpu_16(o_vlan_spec->hdr.vlan_tci);
3712 [ # # ]: 0 : filter->inner_vlan = rte_be_to_cpu_16(i_vlan_spec->hdr.vlan_tci);
3713 : : } else {
3714 : 0 : rte_flow_error_set(error, EINVAL,
3715 : : RTE_FLOW_ERROR_TYPE_ITEM,
3716 : : NULL,
3717 : : "Invalid filter type");
3718 : 0 : return -rte_errno;
3719 : : }
3720 : :
3721 : 0 : filter->tunnel_type = I40E_TUNNEL_TYPE_QINQ;
3722 : 0 : return 0;
3723 : : }
3724 : :
3725 : : static int
3726 : 0 : i40e_flow_parse_qinq_filter(struct rte_eth_dev *dev,
3727 : : const struct rte_flow_attr *attr,
3728 : : const struct rte_flow_item pattern[],
3729 : : const struct rte_flow_action actions[],
3730 : : struct rte_flow_error *error,
3731 : : union i40e_filter_t *filter)
3732 : : {
3733 : 0 : struct i40e_tunnel_filter_conf *tunnel_filter =
3734 : : &filter->consistent_tunnel_filter;
3735 : : int ret;
3736 : :
3737 : 0 : ret = i40e_flow_parse_qinq_pattern(dev, pattern,
3738 : : error, tunnel_filter);
3739 [ # # ]: 0 : if (ret)
3740 : : return ret;
3741 : :
3742 : 0 : ret = i40e_flow_parse_tunnel_action(dev, actions, error, tunnel_filter);
3743 [ # # ]: 0 : if (ret)
3744 : : return ret;
3745 : :
3746 : 0 : ret = i40e_flow_parse_attr(attr, error);
3747 [ # # ]: 0 : if (ret)
3748 : : return ret;
3749 : :
3750 : 0 : cons_filter_type = RTE_ETH_FILTER_TUNNEL;
3751 : :
3752 : 0 : return ret;
3753 : : }
3754 : :
3755 : : static int
3756 : 0 : i40e_flow_validate(struct rte_eth_dev *dev,
3757 : : const struct rte_flow_attr *attr,
3758 : : const struct rte_flow_item pattern[],
3759 : : const struct rte_flow_action actions[],
3760 : : struct rte_flow_error *error)
3761 : : {
3762 : : struct rte_flow_item *items; /* internal pattern w/o VOID items */
3763 : : parse_filter_t parse_filter;
3764 : : uint32_t item_num = 0; /* non-void item number of pattern*/
3765 : 0 : uint32_t i = 0;
3766 : : bool flag = false;
3767 : : int ret = I40E_NOT_SUPPORTED;
3768 : :
3769 [ # # ]: 0 : if (!pattern) {
3770 : 0 : rte_flow_error_set(error, EINVAL, RTE_FLOW_ERROR_TYPE_ITEM_NUM,
3771 : : NULL, "NULL pattern.");
3772 : 0 : return -rte_errno;
3773 : : }
3774 : :
3775 [ # # ]: 0 : if (!actions) {
3776 : 0 : rte_flow_error_set(error, EINVAL,
3777 : : RTE_FLOW_ERROR_TYPE_ACTION_NUM,
3778 : : NULL, "NULL action.");
3779 : 0 : return -rte_errno;
3780 : : }
3781 : :
3782 [ # # ]: 0 : if (!attr) {
3783 : 0 : rte_flow_error_set(error, EINVAL,
3784 : : RTE_FLOW_ERROR_TYPE_ATTR,
3785 : : NULL, "NULL attribute.");
3786 : 0 : return -rte_errno;
3787 : : }
3788 : : memset(&cons_filter, 0, sizeof(cons_filter));
3789 : :
3790 : : /* Get the non-void item of action */
3791 [ # # ]: 0 : while ((actions + i)->type == RTE_FLOW_ACTION_TYPE_VOID)
3792 : 0 : i++;
3793 : :
3794 [ # # ]: 0 : if ((actions + i)->type == RTE_FLOW_ACTION_TYPE_RSS) {
3795 : 0 : ret = i40e_flow_parse_attr(attr, error);
3796 [ # # ]: 0 : if (ret)
3797 : : return ret;
3798 : :
3799 : 0 : cons_filter_type = RTE_ETH_FILTER_HASH;
3800 : 0 : return i40e_hash_parse(dev, pattern, actions + i,
3801 : : &cons_filter.rss_conf, error);
3802 : : }
3803 : :
3804 : 0 : i = 0;
3805 : : /* Get the non-void item number of pattern */
3806 [ # # ]: 0 : while ((pattern + i)->type != RTE_FLOW_ITEM_TYPE_END) {
3807 [ # # ]: 0 : if ((pattern + i)->type != RTE_FLOW_ITEM_TYPE_VOID)
3808 : 0 : item_num++;
3809 : 0 : i++;
3810 : : }
3811 : 0 : item_num++;
3812 : :
3813 [ # # ]: 0 : if (item_num <= ARRAY_SIZE(g_items)) {
3814 : : items = g_items;
3815 : : } else {
3816 : 0 : items = rte_zmalloc("i40e_pattern",
3817 : : item_num * sizeof(struct rte_flow_item), 0);
3818 [ # # ]: 0 : if (!items) {
3819 : 0 : rte_flow_error_set(error, ENOMEM,
3820 : : RTE_FLOW_ERROR_TYPE_ITEM_NUM,
3821 : : NULL,
3822 : : "No memory for PMD internal items.");
3823 : 0 : return -ENOMEM;
3824 : : }
3825 : : }
3826 : :
3827 : 0 : i40e_pattern_skip_void_item(items, pattern);
3828 : :
3829 : 0 : i = 0;
3830 : : do {
3831 : 0 : parse_filter = i40e_find_parse_filter_func(items, &i);
3832 [ # # ]: 0 : if (!parse_filter && !flag) {
3833 : 0 : rte_flow_error_set(error, EINVAL,
3834 : : RTE_FLOW_ERROR_TYPE_ITEM,
3835 : : pattern, "Unsupported pattern");
3836 : :
3837 [ # # ]: 0 : if (items != g_items)
3838 : 0 : rte_free(items);
3839 : 0 : return -rte_errno;
3840 : : }
3841 : :
3842 [ # # ]: 0 : if (parse_filter)
3843 : 0 : ret = parse_filter(dev, attr, items, actions,
3844 : : error, &cons_filter);
3845 : :
3846 : : flag = true;
3847 [ # # # # ]: 0 : } while ((ret < 0) && (i < RTE_DIM(i40e_supported_patterns)));
3848 : :
3849 [ # # ]: 0 : if (items != g_items)
3850 : 0 : rte_free(items);
3851 : :
3852 : : return ret;
3853 : : }
3854 : :
3855 : : static struct rte_flow *
3856 : 0 : i40e_flow_create(struct rte_eth_dev *dev,
3857 : : const struct rte_flow_attr *attr,
3858 : : const struct rte_flow_item pattern[],
3859 : : const struct rte_flow_action actions[],
3860 : : struct rte_flow_error *error)
3861 : : {
3862 : 0 : struct i40e_pf *pf = I40E_DEV_PRIVATE_TO_PF(dev->data->dev_private);
3863 : : struct rte_flow *flow = NULL;
3864 : 0 : struct i40e_fdir_info *fdir_info = &pf->fdir;
3865 : : int ret;
3866 : :
3867 : 0 : ret = i40e_flow_validate(dev, attr, pattern, actions, error);
3868 [ # # ]: 0 : if (ret < 0)
3869 : : return NULL;
3870 : :
3871 [ # # ]: 0 : if (cons_filter_type == RTE_ETH_FILTER_FDIR) {
3872 : 0 : flow = i40e_fdir_entry_pool_get(fdir_info);
3873 [ # # ]: 0 : if (flow == NULL) {
3874 : 0 : rte_flow_error_set(error, ENOBUFS,
3875 : : RTE_FLOW_ERROR_TYPE_HANDLE, NULL,
3876 : : "Fdir space full");
3877 : :
3878 : 0 : return flow;
3879 : : }
3880 : : } else {
3881 : 0 : flow = rte_zmalloc("i40e_flow", sizeof(struct rte_flow), 0);
3882 [ # # ]: 0 : if (!flow) {
3883 : 0 : rte_flow_error_set(error, ENOMEM,
3884 : : RTE_FLOW_ERROR_TYPE_HANDLE, NULL,
3885 : : "Failed to allocate memory");
3886 : 0 : return flow;
3887 : : }
3888 : : }
3889 : :
3890 [ # # # # : 0 : switch (cons_filter_type) {
# ]
3891 : 0 : case RTE_ETH_FILTER_ETHERTYPE:
3892 : 0 : ret = i40e_ethertype_filter_set(pf,
3893 : : &cons_filter.ethertype_filter, 1);
3894 [ # # ]: 0 : if (ret)
3895 : 0 : goto free_flow;
3896 : 0 : flow->rule = TAILQ_LAST(&pf->ethertype.ethertype_list,
3897 : : i40e_ethertype_filter_list);
3898 : 0 : break;
3899 : 0 : case RTE_ETH_FILTER_FDIR:
3900 : 0 : ret = i40e_flow_add_del_fdir_filter(dev,
3901 : : &cons_filter.fdir_filter, 1);
3902 [ # # ]: 0 : if (ret)
3903 : 0 : goto free_flow;
3904 : 0 : flow->rule = TAILQ_LAST(&pf->fdir.fdir_list,
3905 : : i40e_fdir_filter_list);
3906 : 0 : break;
3907 : 0 : case RTE_ETH_FILTER_TUNNEL:
3908 : 0 : ret = i40e_dev_consistent_tunnel_filter_set(pf,
3909 : : &cons_filter.consistent_tunnel_filter, 1);
3910 [ # # ]: 0 : if (ret)
3911 : 0 : goto free_flow;
3912 : 0 : flow->rule = TAILQ_LAST(&pf->tunnel.tunnel_list,
3913 : : i40e_tunnel_filter_list);
3914 : 0 : break;
3915 : 0 : case RTE_ETH_FILTER_HASH:
3916 : 0 : ret = i40e_hash_filter_create(pf, &cons_filter.rss_conf);
3917 [ # # ]: 0 : if (ret)
3918 : 0 : goto free_flow;
3919 : 0 : flow->rule = TAILQ_LAST(&pf->rss_config_list,
3920 : : i40e_rss_conf_list);
3921 : 0 : break;
3922 : 0 : default:
3923 : 0 : goto free_flow;
3924 : : }
3925 : :
3926 : 0 : flow->filter_type = cons_filter_type;
3927 : 0 : TAILQ_INSERT_TAIL(&pf->flow_list, flow, node);
3928 : 0 : return flow;
3929 : :
3930 : 0 : free_flow:
3931 : 0 : rte_flow_error_set(error, -ret,
3932 : : RTE_FLOW_ERROR_TYPE_HANDLE, NULL,
3933 : : "Failed to create flow.");
3934 : :
3935 [ # # ]: 0 : if (cons_filter_type != RTE_ETH_FILTER_FDIR)
3936 : 0 : rte_free(flow);
3937 : : else
3938 : 0 : i40e_fdir_entry_pool_put(fdir_info, flow);
3939 : :
3940 : : return NULL;
3941 : : }
3942 : :
3943 : : static int
3944 : 0 : i40e_flow_destroy(struct rte_eth_dev *dev,
3945 : : struct rte_flow *flow,
3946 : : struct rte_flow_error *error)
3947 : : {
3948 : 0 : struct i40e_pf *pf = I40E_DEV_PRIVATE_TO_PF(dev->data->dev_private);
3949 : 0 : enum rte_filter_type filter_type = flow->filter_type;
3950 : 0 : struct i40e_fdir_info *fdir_info = &pf->fdir;
3951 : : int ret = 0;
3952 : :
3953 [ # # # # : 0 : switch (filter_type) {
# ]
3954 : 0 : case RTE_ETH_FILTER_ETHERTYPE:
3955 : 0 : ret = i40e_flow_destroy_ethertype_filter(pf,
3956 : 0 : (struct i40e_ethertype_filter *)flow->rule);
3957 : 0 : break;
3958 : 0 : case RTE_ETH_FILTER_TUNNEL:
3959 : 0 : ret = i40e_flow_destroy_tunnel_filter(pf,
3960 : 0 : (struct i40e_tunnel_filter *)flow->rule);
3961 : 0 : break;
3962 : 0 : case RTE_ETH_FILTER_FDIR:
3963 : 0 : ret = i40e_flow_add_del_fdir_filter(dev,
3964 : 0 : &((struct i40e_fdir_filter *)flow->rule)->fdir,
3965 : : 0);
3966 : :
3967 : : /* If the last flow is destroyed, disable fdir. */
3968 [ # # # # ]: 0 : if (!ret && TAILQ_EMPTY(&pf->fdir.fdir_list)) {
3969 : 0 : i40e_fdir_rx_proc_enable(dev, 0);
3970 : : }
3971 : : break;
3972 : 0 : case RTE_ETH_FILTER_HASH:
3973 : 0 : ret = i40e_hash_filter_destroy(pf, flow->rule);
3974 : 0 : break;
3975 : 0 : default:
3976 : 0 : PMD_DRV_LOG(WARNING, "Filter type (%d) not supported",
3977 : : filter_type);
3978 : : ret = -EINVAL;
3979 : : break;
3980 : : }
3981 : :
3982 [ # # ]: 0 : if (!ret) {
3983 [ # # ]: 0 : TAILQ_REMOVE(&pf->flow_list, flow, node);
3984 [ # # ]: 0 : if (filter_type == RTE_ETH_FILTER_FDIR)
3985 : 0 : i40e_fdir_entry_pool_put(fdir_info, flow);
3986 : : else
3987 : 0 : rte_free(flow);
3988 : :
3989 : : } else
3990 : 0 : rte_flow_error_set(error, -ret,
3991 : : RTE_FLOW_ERROR_TYPE_HANDLE, NULL,
3992 : : "Failed to destroy flow.");
3993 : :
3994 : 0 : return ret;
3995 : : }
3996 : :
3997 : : static int
3998 : 0 : i40e_flow_destroy_ethertype_filter(struct i40e_pf *pf,
3999 : : struct i40e_ethertype_filter *filter)
4000 : : {
4001 : 0 : struct i40e_hw *hw = I40E_PF_TO_HW(pf);
4002 : 0 : struct i40e_ethertype_rule *ethertype_rule = &pf->ethertype;
4003 : : struct i40e_ethertype_filter *node;
4004 : : struct i40e_control_filter_stats stats;
4005 : : uint16_t flags = 0;
4006 : : int ret = 0;
4007 : :
4008 [ # # ]: 0 : if (!(filter->flags & RTE_ETHTYPE_FLAGS_MAC))
4009 : : flags |= I40E_AQC_ADD_CONTROL_PACKET_FLAGS_IGNORE_MAC;
4010 [ # # ]: 0 : if (filter->flags & RTE_ETHTYPE_FLAGS_DROP)
4011 : 0 : flags |= I40E_AQC_ADD_CONTROL_PACKET_FLAGS_DROP;
4012 : 0 : flags |= I40E_AQC_ADD_CONTROL_PACKET_FLAGS_TO_QUEUE;
4013 : :
4014 : : memset(&stats, 0, sizeof(stats));
4015 : 0 : ret = i40e_aq_add_rem_control_packet_filter(hw,
4016 : 0 : filter->input.mac_addr.addr_bytes,
4017 : 0 : filter->input.ether_type,
4018 : 0 : flags, pf->main_vsi->seid,
4019 : 0 : filter->queue, 0, &stats, NULL);
4020 [ # # ]: 0 : if (ret < 0)
4021 : : return ret;
4022 : :
4023 : 0 : node = i40e_sw_ethertype_filter_lookup(ethertype_rule, &filter->input);
4024 [ # # ]: 0 : if (!node)
4025 : : return -EINVAL;
4026 : :
4027 : 0 : ret = i40e_sw_ethertype_filter_del(pf, &node->input);
4028 : :
4029 : 0 : return ret;
4030 : : }
4031 : :
4032 : : static int
4033 : 0 : i40e_flow_destroy_tunnel_filter(struct i40e_pf *pf,
4034 : : struct i40e_tunnel_filter *filter)
4035 : : {
4036 : 0 : struct i40e_hw *hw = I40E_PF_TO_HW(pf);
4037 : : struct i40e_vsi *vsi;
4038 : : struct i40e_pf_vf *vf;
4039 : : struct i40e_aqc_cloud_filters_element_bb cld_filter;
4040 [ # # ]: 0 : struct i40e_tunnel_rule *tunnel_rule = &pf->tunnel;
4041 : : struct i40e_tunnel_filter *node;
4042 : : bool big_buffer = 0;
4043 : : int ret = 0;
4044 : :
4045 : : memset(&cld_filter, 0, sizeof(cld_filter));
4046 : : rte_ether_addr_copy((struct rte_ether_addr *)&filter->input.outer_mac,
4047 : : (struct rte_ether_addr *)&cld_filter.element.outer_mac);
4048 : : rte_ether_addr_copy((struct rte_ether_addr *)&filter->input.inner_mac,
4049 : : (struct rte_ether_addr *)&cld_filter.element.inner_mac);
4050 : 0 : cld_filter.element.inner_vlan = filter->input.inner_vlan;
4051 : 0 : cld_filter.element.flags = filter->input.flags;
4052 : 0 : cld_filter.element.tenant_id = filter->input.tenant_id;
4053 : 0 : cld_filter.element.queue_number = filter->queue;
4054 : : rte_memcpy(cld_filter.general_fields,
4055 [ # # ]: 0 : filter->input.general_fields,
4056 : : sizeof(cld_filter.general_fields));
4057 : :
4058 [ # # ]: 0 : if (!filter->is_to_vf)
4059 : 0 : vsi = pf->main_vsi;
4060 : : else {
4061 : 0 : vf = &pf->vfs[filter->vf_id];
4062 : 0 : vsi = vf->vsi;
4063 : : }
4064 : :
4065 [ # # ]: 0 : if (((filter->input.flags & I40E_AQC_ADD_CLOUD_FILTER_0X11) ==
4066 [ # # ]: 0 : I40E_AQC_ADD_CLOUD_FILTER_0X11) ||
4067 : : ((filter->input.flags & I40E_AQC_ADD_CLOUD_FILTER_0X12) ==
4068 [ # # ]: 0 : I40E_AQC_ADD_CLOUD_FILTER_0X12) ||
4069 : : ((filter->input.flags & I40E_AQC_ADD_CLOUD_FILTER_0X10) ==
4070 : : I40E_AQC_ADD_CLOUD_FILTER_0X10))
4071 : : big_buffer = 1;
4072 : :
4073 : : if (big_buffer)
4074 : 0 : ret = i40e_aq_rem_cloud_filters_bb(hw, vsi->seid,
4075 : : &cld_filter, 1);
4076 : : else
4077 : 0 : ret = i40e_aq_rem_cloud_filters(hw, vsi->seid,
4078 : : &cld_filter.element, 1);
4079 [ # # ]: 0 : if (ret < 0)
4080 : : return -ENOTSUP;
4081 : :
4082 : 0 : node = i40e_sw_tunnel_filter_lookup(tunnel_rule, &filter->input);
4083 [ # # ]: 0 : if (!node)
4084 : : return -EINVAL;
4085 : :
4086 : 0 : ret = i40e_sw_tunnel_filter_del(pf, &node->input);
4087 : :
4088 : 0 : return ret;
4089 : : }
4090 : :
4091 : : static int
4092 : 0 : i40e_flow_flush(struct rte_eth_dev *dev, struct rte_flow_error *error)
4093 : : {
4094 : 0 : struct i40e_pf *pf = I40E_DEV_PRIVATE_TO_PF(dev->data->dev_private);
4095 : : int ret;
4096 : :
4097 : 0 : ret = i40e_flow_flush_fdir_filter(pf);
4098 [ # # ]: 0 : if (ret) {
4099 : 0 : rte_flow_error_set(error, -ret,
4100 : : RTE_FLOW_ERROR_TYPE_HANDLE, NULL,
4101 : : "Failed to flush FDIR flows.");
4102 : 0 : return -rte_errno;
4103 : : }
4104 : :
4105 : 0 : ret = i40e_flow_flush_ethertype_filter(pf);
4106 [ # # ]: 0 : if (ret) {
4107 : 0 : rte_flow_error_set(error, -ret,
4108 : : RTE_FLOW_ERROR_TYPE_HANDLE, NULL,
4109 : : "Failed to ethertype flush flows.");
4110 : 0 : return -rte_errno;
4111 : : }
4112 : :
4113 : 0 : ret = i40e_flow_flush_tunnel_filter(pf);
4114 [ # # ]: 0 : if (ret) {
4115 : 0 : rte_flow_error_set(error, -ret,
4116 : : RTE_FLOW_ERROR_TYPE_HANDLE, NULL,
4117 : : "Failed to flush tunnel flows.");
4118 : 0 : return -rte_errno;
4119 : : }
4120 : :
4121 : 0 : ret = i40e_hash_filter_flush(pf);
4122 [ # # ]: 0 : if (ret)
4123 : 0 : rte_flow_error_set(error, -ret,
4124 : : RTE_FLOW_ERROR_TYPE_HANDLE, NULL,
4125 : : "Failed to flush RSS flows.");
4126 : : return ret;
4127 : : }
4128 : :
4129 : : static int
4130 : 0 : i40e_flow_flush_fdir_filter(struct i40e_pf *pf)
4131 : : {
4132 : 0 : struct rte_eth_dev *dev = &rte_eth_devices[pf->dev_data->port_id];
4133 : : struct i40e_fdir_info *fdir_info = &pf->fdir;
4134 : : struct i40e_fdir_filter *fdir_filter;
4135 : : enum i40e_filter_pctype pctype;
4136 : : struct rte_flow *flow;
4137 : : void *temp;
4138 : : int ret;
4139 : : uint32_t i = 0;
4140 : :
4141 : 0 : ret = i40e_fdir_flush(dev);
4142 [ # # ]: 0 : if (!ret) {
4143 : : /* Delete FDIR filters in FDIR list. */
4144 [ # # ]: 0 : while ((fdir_filter = TAILQ_FIRST(&fdir_info->fdir_list))) {
4145 : 0 : ret = i40e_sw_fdir_filter_del(pf,
4146 : : &fdir_filter->fdir.input);
4147 [ # # ]: 0 : if (ret < 0)
4148 : 0 : return ret;
4149 : : }
4150 : :
4151 : : /* Delete FDIR flows in flow list. */
4152 [ # # ]: 0 : RTE_TAILQ_FOREACH_SAFE(flow, &pf->flow_list, node, temp) {
4153 [ # # ]: 0 : if (flow->filter_type == RTE_ETH_FILTER_FDIR) {
4154 [ # # ]: 0 : TAILQ_REMOVE(&pf->flow_list, flow, node);
4155 : : }
4156 : : }
4157 : :
4158 : : /* reset bitmap */
4159 : 0 : rte_bitmap_reset(fdir_info->fdir_flow_pool.bitmap);
4160 [ # # ]: 0 : for (i = 0; i < fdir_info->fdir_space_size; i++) {
4161 : 0 : fdir_info->fdir_flow_pool.pool[i].idx = i;
4162 : 0 : rte_bitmap_set(fdir_info->fdir_flow_pool.bitmap, i);
4163 : : }
4164 : :
4165 : 0 : fdir_info->fdir_actual_cnt = 0;
4166 : 0 : fdir_info->fdir_guarantee_free_space =
4167 : 0 : fdir_info->fdir_guarantee_total_space;
4168 : 0 : memset(fdir_info->fdir_filter_array,
4169 : : 0,
4170 : : sizeof(struct i40e_fdir_filter) *
4171 : : I40E_MAX_FDIR_FILTER_NUM);
4172 : :
4173 : 0 : for (pctype = I40E_FILTER_PCTYPE_NONF_IPV4_UDP;
4174 [ # # ]: 0 : pctype <= I40E_FILTER_PCTYPE_L2_PAYLOAD; pctype++) {
4175 : 0 : pf->fdir.flow_count[pctype] = 0;
4176 : 0 : pf->fdir.flex_mask_flag[pctype] = 0;
4177 : : }
4178 : :
4179 [ # # ]: 0 : for (i = 0; i < I40E_MAX_FLXPLD_LAYER; i++)
4180 : 0 : pf->fdir.flex_pit_flag[i] = 0;
4181 : :
4182 : : /* Disable FDIR processing as all FDIR rules are now flushed */
4183 : 0 : i40e_fdir_rx_proc_enable(dev, 0);
4184 : : }
4185 : :
4186 : : return ret;
4187 : : }
4188 : :
4189 : : /* Flush all ethertype filters */
4190 : : static int
4191 : 0 : i40e_flow_flush_ethertype_filter(struct i40e_pf *pf)
4192 : : {
4193 : : struct i40e_ethertype_filter_list
4194 : : *ethertype_list = &pf->ethertype.ethertype_list;
4195 : : struct i40e_ethertype_filter *filter;
4196 : : struct rte_flow *flow;
4197 : : void *temp;
4198 : : int ret = 0;
4199 : :
4200 [ # # ]: 0 : while ((filter = TAILQ_FIRST(ethertype_list))) {
4201 : 0 : ret = i40e_flow_destroy_ethertype_filter(pf, filter);
4202 [ # # ]: 0 : if (ret)
4203 : 0 : return ret;
4204 : : }
4205 : :
4206 : : /* Delete ethertype flows in flow list. */
4207 [ # # ]: 0 : RTE_TAILQ_FOREACH_SAFE(flow, &pf->flow_list, node, temp) {
4208 [ # # ]: 0 : if (flow->filter_type == RTE_ETH_FILTER_ETHERTYPE) {
4209 [ # # ]: 0 : TAILQ_REMOVE(&pf->flow_list, flow, node);
4210 : 0 : rte_free(flow);
4211 : : }
4212 : : }
4213 : :
4214 : : return ret;
4215 : : }
4216 : :
4217 : : /* Flush all tunnel filters */
4218 : : static int
4219 : 0 : i40e_flow_flush_tunnel_filter(struct i40e_pf *pf)
4220 : : {
4221 : : struct i40e_tunnel_filter_list
4222 : : *tunnel_list = &pf->tunnel.tunnel_list;
4223 : : struct i40e_tunnel_filter *filter;
4224 : : struct rte_flow *flow;
4225 : : void *temp;
4226 : : int ret = 0;
4227 : :
4228 [ # # ]: 0 : while ((filter = TAILQ_FIRST(tunnel_list))) {
4229 : 0 : ret = i40e_flow_destroy_tunnel_filter(pf, filter);
4230 [ # # ]: 0 : if (ret)
4231 : 0 : return ret;
4232 : : }
4233 : :
4234 : : /* Delete tunnel flows in flow list. */
4235 [ # # ]: 0 : RTE_TAILQ_FOREACH_SAFE(flow, &pf->flow_list, node, temp) {
4236 [ # # ]: 0 : if (flow->filter_type == RTE_ETH_FILTER_TUNNEL) {
4237 [ # # ]: 0 : TAILQ_REMOVE(&pf->flow_list, flow, node);
4238 : 0 : rte_free(flow);
4239 : : }
4240 : : }
4241 : :
4242 : : return ret;
4243 : : }
4244 : :
4245 : : static int
4246 : 0 : i40e_flow_query(struct rte_eth_dev *dev __rte_unused,
4247 : : struct rte_flow *flow,
4248 : : const struct rte_flow_action *actions,
4249 : : void *data, struct rte_flow_error *error)
4250 : : {
4251 : 0 : struct i40e_rss_filter *rss_rule = (struct i40e_rss_filter *)flow->rule;
4252 : 0 : enum rte_filter_type filter_type = flow->filter_type;
4253 : : struct rte_flow_action_rss *rss_conf = data;
4254 : :
4255 [ # # ]: 0 : if (!rss_rule) {
4256 : 0 : rte_flow_error_set(error, EINVAL,
4257 : : RTE_FLOW_ERROR_TYPE_HANDLE,
4258 : : NULL, "Invalid rule");
4259 : 0 : return -rte_errno;
4260 : : }
4261 : :
4262 [ # # ]: 0 : for (; actions->type != RTE_FLOW_ACTION_TYPE_END; actions++) {
4263 [ # # # ]: 0 : switch (actions->type) {
4264 : : case RTE_FLOW_ACTION_TYPE_VOID:
4265 : : break;
4266 : 0 : case RTE_FLOW_ACTION_TYPE_RSS:
4267 [ # # ]: 0 : if (filter_type != RTE_ETH_FILTER_HASH) {
4268 : 0 : rte_flow_error_set(error, ENOTSUP,
4269 : : RTE_FLOW_ERROR_TYPE_ACTION,
4270 : : actions,
4271 : : "action not supported");
4272 : 0 : return -rte_errno;
4273 : : }
4274 : : rte_memcpy(rss_conf,
4275 [ # # ]: 0 : &rss_rule->rss_filter_info.conf,
4276 : : sizeof(struct rte_flow_action_rss));
4277 : : break;
4278 : 0 : default:
4279 : 0 : return rte_flow_error_set(error, ENOTSUP,
4280 : : RTE_FLOW_ERROR_TYPE_ACTION,
4281 : : actions,
4282 : : "action not supported");
4283 : : }
4284 : : }
4285 : :
4286 : : return 0;
4287 : : }
|