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 int
1267 : 0 : i40e_get_outer_vlan(struct rte_eth_dev *dev, uint16_t *tpid)
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 : : int ret;
1275 : :
1276 [ # # ]: 0 : if (qinq)
1277 : : reg_id = 2;
1278 : : else
1279 : : reg_id = 3;
1280 : :
1281 : 0 : ret = i40e_aq_debug_read_register(hw, I40E_GL_SWT_L2TAGCTRL(reg_id),
1282 : : ®_r, NULL);
1283 [ # # ]: 0 : if (ret != I40E_SUCCESS) {
1284 : 0 : PMD_DRV_LOG(ERR, "Failed to read from L2 tag ctrl register [%d]", reg_id);
1285 : 0 : return -EIO;
1286 : : }
1287 : :
1288 : 0 : *tpid = (reg_r >> I40E_GL_SWT_L2TAGCTRL_ETHERTYPE_SHIFT) & 0xFFFF;
1289 : :
1290 : 0 : return 0;
1291 : : }
1292 : :
1293 : : /* 1. Last in item should be NULL as range is not supported.
1294 : : * 2. Supported filter types: MAC_ETHTYPE and ETHTYPE.
1295 : : * 3. SRC mac_addr mask should be 00:00:00:00:00:00.
1296 : : * 4. DST mac_addr mask should be 00:00:00:00:00:00 or
1297 : : * FF:FF:FF:FF:FF:FF
1298 : : * 5. Ether_type mask should be 0xFFFF.
1299 : : */
1300 : : static int
1301 : 0 : i40e_flow_parse_ethertype_pattern(struct rte_eth_dev *dev,
1302 : : const struct rte_flow_item *pattern,
1303 : : struct rte_flow_error *error,
1304 : : struct rte_eth_ethertype_filter *filter)
1305 : : {
1306 : : const struct rte_flow_item *item = pattern;
1307 : : const struct rte_flow_item_eth *eth_spec;
1308 : : const struct rte_flow_item_eth *eth_mask;
1309 : : enum rte_flow_item_type item_type;
1310 : : int ret;
1311 : : uint16_t tpid;
1312 : :
1313 [ # # ]: 0 : for (; item->type != RTE_FLOW_ITEM_TYPE_END; item++) {
1314 [ # # ]: 0 : if (item->last) {
1315 : 0 : rte_flow_error_set(error, EINVAL,
1316 : : RTE_FLOW_ERROR_TYPE_ITEM,
1317 : : item,
1318 : : "Not support range");
1319 : 0 : return -rte_errno;
1320 : : }
1321 : : item_type = item->type;
1322 [ # # ]: 0 : switch (item_type) {
1323 : 0 : case RTE_FLOW_ITEM_TYPE_ETH:
1324 : 0 : eth_spec = item->spec;
1325 : 0 : eth_mask = item->mask;
1326 : : /* Get the MAC info. */
1327 [ # # ]: 0 : if (!eth_spec || !eth_mask) {
1328 : 0 : rte_flow_error_set(error, EINVAL,
1329 : : RTE_FLOW_ERROR_TYPE_ITEM,
1330 : : item,
1331 : : "NULL ETH spec/mask");
1332 : 0 : return -rte_errno;
1333 : : }
1334 : :
1335 : : /* Mask bits of source MAC address must be full of 0.
1336 : : * Mask bits of destination MAC address must be full
1337 : : * of 1 or full of 0.
1338 : : */
1339 [ # # # # ]: 0 : if (!rte_is_zero_ether_addr(ð_mask->hdr.src_addr) ||
1340 [ # # ]: 0 : (!rte_is_zero_ether_addr(ð_mask->hdr.dst_addr) &&
1341 : : !rte_is_broadcast_ether_addr(ð_mask->hdr.dst_addr))) {
1342 : 0 : rte_flow_error_set(error, EINVAL,
1343 : : RTE_FLOW_ERROR_TYPE_ITEM,
1344 : : item,
1345 : : "Invalid MAC_addr mask");
1346 : 0 : return -rte_errno;
1347 : : }
1348 : :
1349 [ # # ]: 0 : if ((eth_mask->hdr.ether_type & UINT16_MAX) != UINT16_MAX) {
1350 : 0 : rte_flow_error_set(error, EINVAL,
1351 : : RTE_FLOW_ERROR_TYPE_ITEM,
1352 : : item,
1353 : : "Invalid ethertype mask");
1354 : 0 : return -rte_errno;
1355 : : }
1356 : :
1357 : : /* If mask bits of destination MAC address
1358 : : * are full of 1, set RTE_ETHTYPE_FLAGS_MAC.
1359 : : */
1360 [ # # ]: 0 : if (rte_is_broadcast_ether_addr(ð_mask->hdr.dst_addr)) {
1361 : 0 : filter->mac_addr = eth_spec->hdr.dst_addr;
1362 : 0 : filter->flags |= RTE_ETHTYPE_FLAGS_MAC;
1363 : : } else {
1364 : 0 : filter->flags &= ~RTE_ETHTYPE_FLAGS_MAC;
1365 : : }
1366 [ # # ]: 0 : filter->ether_type = rte_be_to_cpu_16(eth_spec->hdr.ether_type);
1367 : :
1368 [ # # ]: 0 : if (filter->ether_type == RTE_ETHER_TYPE_IPV4 ||
1369 [ # # ]: 0 : filter->ether_type == RTE_ETHER_TYPE_IPV6 ||
1370 : : filter->ether_type == RTE_ETHER_TYPE_LLDP) {
1371 : 0 : rte_flow_error_set(error, EINVAL,
1372 : : RTE_FLOW_ERROR_TYPE_ITEM,
1373 : : item,
1374 : : "Unsupported ether_type in control packet filter.");
1375 : 0 : return -rte_errno;
1376 : : }
1377 : :
1378 : 0 : ret = i40e_get_outer_vlan(dev, &tpid);
1379 [ # # ]: 0 : if (ret != 0) {
1380 : 0 : rte_flow_error_set(error, EIO,
1381 : : RTE_FLOW_ERROR_TYPE_ITEM,
1382 : : item,
1383 : : "Can not get the Ethertype identifying the L2 tag");
1384 : 0 : return -rte_errno;
1385 : : }
1386 [ # # ]: 0 : if (filter->ether_type == tpid) {
1387 : 0 : rte_flow_error_set(error, EINVAL,
1388 : : RTE_FLOW_ERROR_TYPE_ITEM,
1389 : : item,
1390 : : "Unsupported ether_type in"
1391 : : " control packet filter.");
1392 : 0 : return -rte_errno;
1393 : : }
1394 : :
1395 : : break;
1396 : : default:
1397 : : break;
1398 : : }
1399 : : }
1400 : :
1401 : : return 0;
1402 : : }
1403 : :
1404 : : /* Ethertype action only supports QUEUE or DROP. */
1405 : : static int
1406 : 0 : i40e_flow_parse_ethertype_action(struct rte_eth_dev *dev,
1407 : : const struct rte_flow_action *actions,
1408 : : struct rte_flow_error *error,
1409 : : struct rte_eth_ethertype_filter *filter)
1410 : : {
1411 : 0 : struct i40e_pf *pf = I40E_DEV_PRIVATE_TO_PF(dev->data->dev_private);
1412 : : const struct rte_flow_action *act;
1413 : : const struct rte_flow_action_queue *act_q;
1414 : : uint32_t index = 0;
1415 : :
1416 : : /* Check if the first non-void action is QUEUE or DROP. */
1417 [ # # ]: 0 : NEXT_ITEM_OF_ACTION(act, actions, index);
1418 [ # # ]: 0 : if (act->type != RTE_FLOW_ACTION_TYPE_QUEUE &&
1419 : : act->type != RTE_FLOW_ACTION_TYPE_DROP) {
1420 : 0 : rte_flow_error_set(error, EINVAL, RTE_FLOW_ERROR_TYPE_ACTION,
1421 : : act, "Not supported action.");
1422 : 0 : return -rte_errno;
1423 : : }
1424 : :
1425 [ # # ]: 0 : if (act->type == RTE_FLOW_ACTION_TYPE_QUEUE) {
1426 : 0 : act_q = act->conf;
1427 : 0 : filter->queue = act_q->index;
1428 [ # # ]: 0 : if (filter->queue >= pf->dev_data->nb_rx_queues) {
1429 : 0 : rte_flow_error_set(error, EINVAL,
1430 : : RTE_FLOW_ERROR_TYPE_ACTION,
1431 : : act, "Invalid queue ID for"
1432 : : " ethertype_filter.");
1433 : 0 : return -rte_errno;
1434 : : }
1435 : : } else {
1436 : 0 : filter->flags |= RTE_ETHTYPE_FLAGS_DROP;
1437 : : }
1438 : :
1439 : : /* Check if the next non-void item is END */
1440 : 0 : index++;
1441 [ # # ]: 0 : NEXT_ITEM_OF_ACTION(act, actions, index);
1442 [ # # ]: 0 : if (act->type != RTE_FLOW_ACTION_TYPE_END) {
1443 : 0 : rte_flow_error_set(error, EINVAL, RTE_FLOW_ERROR_TYPE_ACTION,
1444 : : act, "Not supported action.");
1445 : 0 : return -rte_errno;
1446 : : }
1447 : :
1448 : : return 0;
1449 : : }
1450 : :
1451 : : static int
1452 : 0 : i40e_flow_parse_ethertype_filter(struct rte_eth_dev *dev,
1453 : : const struct rte_flow_attr *attr,
1454 : : const struct rte_flow_item pattern[],
1455 : : const struct rte_flow_action actions[],
1456 : : struct rte_flow_error *error,
1457 : : union i40e_filter_t *filter)
1458 : : {
1459 : 0 : struct rte_eth_ethertype_filter *ethertype_filter =
1460 : : &filter->ethertype_filter;
1461 : : int ret;
1462 : :
1463 : 0 : ret = i40e_flow_parse_ethertype_pattern(dev, pattern, error,
1464 : : ethertype_filter);
1465 [ # # ]: 0 : if (ret)
1466 : : return ret;
1467 : :
1468 : 0 : ret = i40e_flow_parse_ethertype_action(dev, actions, error,
1469 : : ethertype_filter);
1470 [ # # ]: 0 : if (ret)
1471 : : return ret;
1472 : :
1473 : 0 : ret = i40e_flow_parse_attr(attr, error);
1474 [ # # ]: 0 : if (ret)
1475 : : return ret;
1476 : :
1477 : 0 : cons_filter_type = RTE_ETH_FILTER_ETHERTYPE;
1478 : :
1479 : 0 : return ret;
1480 : : }
1481 : :
1482 : : static int
1483 : 0 : i40e_flow_check_raw_item(const struct rte_flow_item *item,
1484 : : const struct rte_flow_item_raw *raw_spec,
1485 : : struct rte_flow_error *error)
1486 : : {
1487 [ # # ]: 0 : if (!raw_spec->relative) {
1488 : 0 : rte_flow_error_set(error, EINVAL,
1489 : : RTE_FLOW_ERROR_TYPE_ITEM,
1490 : : item,
1491 : : "Relative should be 1.");
1492 : 0 : return -rte_errno;
1493 : : }
1494 : :
1495 [ # # ]: 0 : if (raw_spec->offset % sizeof(uint16_t)) {
1496 : 0 : rte_flow_error_set(error, EINVAL,
1497 : : RTE_FLOW_ERROR_TYPE_ITEM,
1498 : : item,
1499 : : "Offset should be even.");
1500 : 0 : return -rte_errno;
1501 : : }
1502 : :
1503 [ # # # # ]: 0 : if (raw_spec->search || raw_spec->limit) {
1504 : 0 : rte_flow_error_set(error, EINVAL,
1505 : : RTE_FLOW_ERROR_TYPE_ITEM,
1506 : : item,
1507 : : "search or limit is not supported.");
1508 : 0 : return -rte_errno;
1509 : : }
1510 : :
1511 [ # # ]: 0 : if (raw_spec->offset < 0) {
1512 : 0 : rte_flow_error_set(error, EINVAL,
1513 : : RTE_FLOW_ERROR_TYPE_ITEM,
1514 : : item,
1515 : : "Offset should be non-negative.");
1516 : 0 : return -rte_errno;
1517 : : }
1518 : : return 0;
1519 : : }
1520 : :
1521 : :
1522 : : static uint8_t
1523 : 0 : i40e_flow_fdir_get_pctype_value(struct i40e_pf *pf,
1524 : : enum rte_flow_item_type item_type,
1525 : : struct i40e_fdir_filter_conf *filter)
1526 : : {
1527 : : struct i40e_customized_pctype *cus_pctype = NULL;
1528 : :
1529 [ # # # # : 0 : switch (item_type) {
# ]
1530 : 0 : case RTE_FLOW_ITEM_TYPE_GTPC:
1531 : 0 : cus_pctype = i40e_find_customized_pctype(pf,
1532 : : I40E_CUSTOMIZED_GTPC);
1533 : 0 : break;
1534 : 0 : case RTE_FLOW_ITEM_TYPE_GTPU:
1535 [ # # ]: 0 : if (!filter->input.flow_ext.inner_ip)
1536 : 0 : cus_pctype = i40e_find_customized_pctype(pf,
1537 : : I40E_CUSTOMIZED_GTPU);
1538 [ # # ]: 0 : else if (filter->input.flow_ext.iip_type ==
1539 : : I40E_FDIR_IPTYPE_IPV4)
1540 : 0 : cus_pctype = i40e_find_customized_pctype(pf,
1541 : : I40E_CUSTOMIZED_GTPU_IPV4);
1542 [ # # ]: 0 : else if (filter->input.flow_ext.iip_type ==
1543 : : I40E_FDIR_IPTYPE_IPV6)
1544 : 0 : cus_pctype = i40e_find_customized_pctype(pf,
1545 : : I40E_CUSTOMIZED_GTPU_IPV6);
1546 : : break;
1547 : 0 : case RTE_FLOW_ITEM_TYPE_L2TPV3OIP:
1548 [ # # ]: 0 : if (filter->input.flow_ext.oip_type == I40E_FDIR_IPTYPE_IPV4)
1549 : 0 : cus_pctype = i40e_find_customized_pctype(pf,
1550 : : I40E_CUSTOMIZED_IPV4_L2TPV3);
1551 [ # # ]: 0 : else if (filter->input.flow_ext.oip_type ==
1552 : : I40E_FDIR_IPTYPE_IPV6)
1553 : 0 : cus_pctype = i40e_find_customized_pctype(pf,
1554 : : I40E_CUSTOMIZED_IPV6_L2TPV3);
1555 : : break;
1556 : 0 : case RTE_FLOW_ITEM_TYPE_ESP:
1557 [ # # ]: 0 : if (!filter->input.flow_ext.is_udp) {
1558 [ # # ]: 0 : if (filter->input.flow_ext.oip_type ==
1559 : : I40E_FDIR_IPTYPE_IPV4)
1560 : 0 : cus_pctype = i40e_find_customized_pctype(pf,
1561 : : I40E_CUSTOMIZED_ESP_IPV4);
1562 [ # # ]: 0 : else if (filter->input.flow_ext.oip_type ==
1563 : : I40E_FDIR_IPTYPE_IPV6)
1564 : 0 : cus_pctype = i40e_find_customized_pctype(pf,
1565 : : I40E_CUSTOMIZED_ESP_IPV6);
1566 : : } else {
1567 [ # # ]: 0 : if (filter->input.flow_ext.oip_type ==
1568 : : I40E_FDIR_IPTYPE_IPV4)
1569 : 0 : cus_pctype = i40e_find_customized_pctype(pf,
1570 : : I40E_CUSTOMIZED_ESP_IPV4_UDP);
1571 [ # # ]: 0 : else if (filter->input.flow_ext.oip_type ==
1572 : : I40E_FDIR_IPTYPE_IPV6)
1573 : 0 : cus_pctype = i40e_find_customized_pctype(pf,
1574 : : I40E_CUSTOMIZED_ESP_IPV6_UDP);
1575 : 0 : filter->input.flow_ext.is_udp = false;
1576 : : }
1577 : : break;
1578 : 0 : default:
1579 : 0 : PMD_DRV_LOG(ERR, "Unsupported item type");
1580 : : break;
1581 : : }
1582 : :
1583 [ # # # # ]: 0 : if (cus_pctype && cus_pctype->valid)
1584 : 0 : return cus_pctype->pctype;
1585 : :
1586 : : return I40E_FILTER_PCTYPE_INVALID;
1587 : : }
1588 : :
1589 : : static void
1590 : : i40e_flow_set_filter_spi(struct i40e_fdir_filter_conf *filter,
1591 : : const struct rte_flow_item_esp *esp_spec)
1592 : : {
1593 [ # # ]: 0 : if (filter->input.flow_ext.oip_type ==
1594 : : I40E_FDIR_IPTYPE_IPV4) {
1595 [ # # ]: 0 : if (filter->input.flow_ext.is_udp)
1596 : 0 : filter->input.flow.esp_ipv4_udp_flow.spi =
1597 : 0 : esp_spec->hdr.spi;
1598 : : else
1599 : 0 : filter->input.flow.esp_ipv4_flow.spi =
1600 : 0 : esp_spec->hdr.spi;
1601 : : }
1602 [ # # ]: 0 : if (filter->input.flow_ext.oip_type ==
1603 : : I40E_FDIR_IPTYPE_IPV6) {
1604 [ # # ]: 0 : if (filter->input.flow_ext.is_udp)
1605 : 0 : filter->input.flow.esp_ipv6_udp_flow.spi =
1606 : 0 : esp_spec->hdr.spi;
1607 : : else
1608 : 0 : filter->input.flow.esp_ipv6_flow.spi =
1609 : 0 : esp_spec->hdr.spi;
1610 : : }
1611 : : }
1612 : :
1613 : : /* 1. Last in item should be NULL as range is not supported.
1614 : : * 2. Supported patterns: refer to array i40e_supported_patterns.
1615 : : * 3. Default supported flow type and input set: refer to array
1616 : : * valid_fdir_inset_table in i40e_ethdev.c.
1617 : : * 4. Mask of fields which need to be matched should be
1618 : : * filled with 1.
1619 : : * 5. Mask of fields which needn't to be matched should be
1620 : : * filled with 0.
1621 : : * 6. GTP profile supports GTPv1 only.
1622 : : * 7. GTP-C response message ('source_port' = 2123) is not supported.
1623 : : */
1624 : : static int
1625 : 0 : i40e_flow_parse_fdir_pattern(struct rte_eth_dev *dev,
1626 : : const struct rte_flow_item *pattern,
1627 : : struct rte_flow_error *error,
1628 : : struct i40e_fdir_filter_conf *filter)
1629 : : {
1630 : 0 : struct i40e_pf *pf = I40E_DEV_PRIVATE_TO_PF(dev->data->dev_private);
1631 : : const struct rte_flow_item *item = pattern;
1632 : : const struct rte_flow_item_eth *eth_spec, *eth_mask;
1633 : : const struct rte_flow_item_vlan *vlan_spec, *vlan_mask;
1634 : : const struct rte_flow_item_ipv4 *ipv4_spec, *ipv4_last, *ipv4_mask;
1635 : : const struct rte_flow_item_ipv6 *ipv6_spec, *ipv6_mask;
1636 : : const struct rte_flow_item_tcp *tcp_spec, *tcp_mask;
1637 : : const struct rte_flow_item_udp *udp_spec, *udp_mask;
1638 : : const struct rte_flow_item_sctp *sctp_spec, *sctp_mask;
1639 : : const struct rte_flow_item_gtp *gtp_spec, *gtp_mask;
1640 : : const struct rte_flow_item_esp *esp_spec, *esp_mask;
1641 : : const struct rte_flow_item_raw *raw_spec, *raw_mask;
1642 : : const struct rte_flow_item_l2tpv3oip *l2tpv3oip_spec, *l2tpv3oip_mask;
1643 : :
1644 : : uint8_t pctype = 0;
1645 : : uint64_t input_set = I40E_INSET_NONE;
1646 : : enum rte_flow_item_type item_type;
1647 : : enum rte_flow_item_type next_type;
1648 : : enum rte_flow_item_type l3 = RTE_FLOW_ITEM_TYPE_END;
1649 : : enum rte_flow_item_type cus_proto = RTE_FLOW_ITEM_TYPE_END;
1650 : : uint32_t i, j;
1651 : 0 : uint8_t ipv6_addr_mask[16] = {
1652 : : 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
1653 : : 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF };
1654 : : enum i40e_flxpld_layer_idx layer_idx = I40E_FLXPLD_L2_IDX;
1655 : : uint8_t raw_id = 0;
1656 : : int32_t off_arr[I40E_MAX_FLXPLD_FIED];
1657 : : uint16_t len_arr[I40E_MAX_FLXPLD_FIED];
1658 : : struct i40e_fdir_flex_pit flex_pit;
1659 : : uint8_t next_dst_off = 0;
1660 : : uint16_t flex_size;
1661 : : uint16_t ether_type;
1662 : : uint32_t vtc_flow_cpu;
1663 : : bool outer_ip = true;
1664 : : uint8_t field_idx;
1665 : : int ret;
1666 : : uint16_t tpid;
1667 : :
1668 : : memset(off_arr, 0, sizeof(off_arr));
1669 : : memset(len_arr, 0, sizeof(len_arr));
1670 : 0 : filter->input.flow_ext.customized_pctype = false;
1671 [ # # ]: 0 : for (; item->type != RTE_FLOW_ITEM_TYPE_END; item++) {
1672 [ # # # # ]: 0 : if (item->last && item->type != RTE_FLOW_ITEM_TYPE_IPV4) {
1673 : 0 : rte_flow_error_set(error, EINVAL,
1674 : : RTE_FLOW_ERROR_TYPE_ITEM,
1675 : : item,
1676 : : "Not support range");
1677 : 0 : return -rte_errno;
1678 : : }
1679 : : item_type = item->type;
1680 [ # # # # : 0 : switch (item_type) {
# # # # #
# # # ]
1681 : 0 : case RTE_FLOW_ITEM_TYPE_ETH:
1682 : 0 : eth_spec = item->spec;
1683 : 0 : eth_mask = item->mask;
1684 : 0 : next_type = (item + 1)->type;
1685 : :
1686 [ # # ]: 0 : if (next_type == RTE_FLOW_ITEM_TYPE_END &&
1687 [ # # ]: 0 : (!eth_spec || !eth_mask)) {
1688 : 0 : rte_flow_error_set(error, EINVAL,
1689 : : RTE_FLOW_ERROR_TYPE_ITEM,
1690 : : item,
1691 : : "NULL eth spec/mask.");
1692 : 0 : return -rte_errno;
1693 : : }
1694 : :
1695 [ # # ]: 0 : if (eth_spec && eth_mask) {
1696 [ # # # # ]: 0 : if (rte_is_broadcast_ether_addr(ð_mask->hdr.dst_addr) &&
1697 : : rte_is_zero_ether_addr(ð_mask->hdr.src_addr)) {
1698 : 0 : filter->input.flow.l2_flow.dst =
1699 : : eth_spec->hdr.dst_addr;
1700 : 0 : input_set |= I40E_INSET_DMAC;
1701 [ # # # # ]: 0 : } else if (rte_is_zero_ether_addr(ð_mask->hdr.dst_addr) &&
1702 : : rte_is_broadcast_ether_addr(ð_mask->hdr.src_addr)) {
1703 : 0 : filter->input.flow.l2_flow.src =
1704 : : eth_spec->hdr.src_addr;
1705 : 0 : input_set |= I40E_INSET_SMAC;
1706 [ # # # # ]: 0 : } else if (rte_is_broadcast_ether_addr(ð_mask->hdr.dst_addr) &&
1707 : : rte_is_broadcast_ether_addr(ð_mask->hdr.src_addr)) {
1708 : 0 : filter->input.flow.l2_flow.dst =
1709 : : eth_spec->hdr.dst_addr;
1710 : 0 : filter->input.flow.l2_flow.src =
1711 : : eth_spec->hdr.src_addr;
1712 : 0 : input_set |= (I40E_INSET_DMAC | I40E_INSET_SMAC);
1713 [ # # # # ]: 0 : } else if (!rte_is_zero_ether_addr(ð_mask->hdr.src_addr) ||
1714 : : !rte_is_zero_ether_addr(ð_mask->hdr.dst_addr)) {
1715 : 0 : rte_flow_error_set(error, EINVAL,
1716 : : RTE_FLOW_ERROR_TYPE_ITEM,
1717 : : item,
1718 : : "Invalid MAC_addr mask.");
1719 : 0 : return -rte_errno;
1720 : : }
1721 : : }
1722 [ # # # # ]: 0 : if (eth_spec && eth_mask &&
1723 : : next_type == RTE_FLOW_ITEM_TYPE_END) {
1724 [ # # ]: 0 : if (eth_mask->hdr.ether_type != RTE_BE16(0xffff)) {
1725 : 0 : rte_flow_error_set(error, EINVAL,
1726 : : RTE_FLOW_ERROR_TYPE_ITEM,
1727 : : item,
1728 : : "Invalid type mask.");
1729 : 0 : return -rte_errno;
1730 : : }
1731 : :
1732 [ # # ]: 0 : ether_type = rte_be_to_cpu_16(eth_spec->hdr.ether_type);
1733 : :
1734 : 0 : if (ether_type == RTE_ETHER_TYPE_IPV4 ||
1735 [ # # ]: 0 : ether_type == RTE_ETHER_TYPE_IPV6) {
1736 : 0 : rte_flow_error_set(error, EINVAL,
1737 : : RTE_FLOW_ERROR_TYPE_ITEM,
1738 : : item,
1739 : : "Unsupported ether_type.");
1740 : 0 : return -rte_errno;
1741 : : }
1742 : 0 : ret = i40e_get_outer_vlan(dev, &tpid);
1743 [ # # ]: 0 : if (ret != 0) {
1744 : 0 : rte_flow_error_set(error, EIO,
1745 : : RTE_FLOW_ERROR_TYPE_ITEM,
1746 : : item,
1747 : : "Can not get the Ethertype identifying the L2 tag");
1748 : 0 : return -rte_errno;
1749 : : }
1750 [ # # ]: 0 : if (ether_type == tpid) {
1751 : 0 : rte_flow_error_set(error, EINVAL,
1752 : : RTE_FLOW_ERROR_TYPE_ITEM,
1753 : : item,
1754 : : "Unsupported ether_type.");
1755 : 0 : return -rte_errno;
1756 : : }
1757 : :
1758 : 0 : input_set |= I40E_INSET_LAST_ETHER_TYPE;
1759 : 0 : filter->input.flow.l2_flow.ether_type =
1760 : 0 : eth_spec->hdr.ether_type;
1761 : : }
1762 : :
1763 : : pctype = I40E_FILTER_PCTYPE_L2_PAYLOAD;
1764 : : layer_idx = I40E_FLXPLD_L2_IDX;
1765 : :
1766 : : break;
1767 : 0 : case RTE_FLOW_ITEM_TYPE_VLAN:
1768 : 0 : vlan_spec = item->spec;
1769 : 0 : vlan_mask = item->mask;
1770 : :
1771 : : RTE_ASSERT(!(input_set & I40E_INSET_LAST_ETHER_TYPE));
1772 [ # # ]: 0 : if (vlan_spec && vlan_mask) {
1773 [ # # ]: 0 : if (vlan_mask->hdr.vlan_tci !=
1774 [ # # ]: 0 : rte_cpu_to_be_16(I40E_VLAN_TCI_MASK) &&
1775 : : vlan_mask->hdr.vlan_tci !=
1776 [ # # ]: 0 : rte_cpu_to_be_16(I40E_VLAN_PRI_MASK) &&
1777 : : vlan_mask->hdr.vlan_tci !=
1778 [ # # ]: 0 : rte_cpu_to_be_16(I40E_VLAN_CFI_MASK) &&
1779 : : vlan_mask->hdr.vlan_tci !=
1780 : : rte_cpu_to_be_16(I40E_VLAN_VID_MASK)) {
1781 : 0 : rte_flow_error_set(error, EINVAL,
1782 : : RTE_FLOW_ERROR_TYPE_ITEM,
1783 : : item,
1784 : : "Unsupported TCI mask.");
1785 : : }
1786 : 0 : input_set |= I40E_INSET_VLAN_INNER;
1787 : 0 : filter->input.flow_ext.vlan_tci =
1788 : 0 : vlan_spec->hdr.vlan_tci;
1789 : : }
1790 [ # # # # ]: 0 : if (vlan_spec && vlan_mask && vlan_mask->hdr.eth_proto) {
1791 [ # # ]: 0 : if (vlan_mask->hdr.eth_proto != RTE_BE16(0xffff)) {
1792 : 0 : rte_flow_error_set(error, EINVAL,
1793 : : RTE_FLOW_ERROR_TYPE_ITEM,
1794 : : item,
1795 : : "Invalid inner_type"
1796 : : " mask.");
1797 : 0 : return -rte_errno;
1798 : : }
1799 : :
1800 : : ether_type =
1801 [ # # ]: 0 : rte_be_to_cpu_16(vlan_spec->hdr.eth_proto);
1802 : :
1803 : 0 : if (ether_type == RTE_ETHER_TYPE_IPV4 ||
1804 [ # # ]: 0 : ether_type == RTE_ETHER_TYPE_IPV6) {
1805 : 0 : rte_flow_error_set(error, EINVAL,
1806 : : RTE_FLOW_ERROR_TYPE_ITEM,
1807 : : item,
1808 : : "Unsupported inner_type.");
1809 : 0 : return -rte_errno;
1810 : : }
1811 : 0 : ret = i40e_get_outer_vlan(dev, &tpid);
1812 [ # # ]: 0 : if (ret != 0) {
1813 : 0 : rte_flow_error_set(error, EIO,
1814 : : RTE_FLOW_ERROR_TYPE_ITEM,
1815 : : item,
1816 : : "Can not get the Ethertype identifying the L2 tag");
1817 : 0 : return -rte_errno;
1818 : : }
1819 [ # # ]: 0 : if (ether_type == tpid) {
1820 : 0 : rte_flow_error_set(error, EINVAL,
1821 : : RTE_FLOW_ERROR_TYPE_ITEM,
1822 : : item,
1823 : : "Unsupported ether_type.");
1824 : 0 : return -rte_errno;
1825 : : }
1826 : :
1827 : 0 : input_set |= I40E_INSET_LAST_ETHER_TYPE;
1828 : 0 : filter->input.flow.l2_flow.ether_type =
1829 : 0 : vlan_spec->hdr.eth_proto;
1830 : : }
1831 : :
1832 : : pctype = I40E_FILTER_PCTYPE_L2_PAYLOAD;
1833 : : layer_idx = I40E_FLXPLD_L2_IDX;
1834 : :
1835 : : break;
1836 : 0 : case RTE_FLOW_ITEM_TYPE_IPV4:
1837 : : l3 = RTE_FLOW_ITEM_TYPE_IPV4;
1838 : 0 : ipv4_spec = item->spec;
1839 : 0 : ipv4_mask = item->mask;
1840 : : ipv4_last = item->last;
1841 : : pctype = I40E_FILTER_PCTYPE_NONF_IPV4_OTHER;
1842 : : layer_idx = I40E_FLXPLD_L3_IDX;
1843 : :
1844 [ # # ]: 0 : if (ipv4_last) {
1845 [ # # # # ]: 0 : if (!ipv4_spec || !ipv4_mask || !outer_ip) {
1846 : 0 : rte_flow_error_set(error, EINVAL,
1847 : : RTE_FLOW_ERROR_TYPE_ITEM,
1848 : : item,
1849 : : "Not support range");
1850 : 0 : return -rte_errno;
1851 : : }
1852 : : /* Only fragment_offset supports range */
1853 [ # # ]: 0 : if (ipv4_last->hdr.version_ihl ||
1854 : 0 : ipv4_last->hdr.type_of_service ||
1855 [ # # ]: 0 : ipv4_last->hdr.total_length ||
1856 [ # # ]: 0 : ipv4_last->hdr.packet_id ||
1857 [ # # ]: 0 : ipv4_last->hdr.time_to_live ||
1858 : 0 : ipv4_last->hdr.next_proto_id ||
1859 [ # # ]: 0 : ipv4_last->hdr.hdr_checksum ||
1860 [ # # ]: 0 : ipv4_last->hdr.src_addr ||
1861 [ # # ]: 0 : ipv4_last->hdr.dst_addr) {
1862 : 0 : rte_flow_error_set(error, EINVAL,
1863 : : RTE_FLOW_ERROR_TYPE_ITEM,
1864 : : item,
1865 : : "Not support range");
1866 : 0 : return -rte_errno;
1867 : : }
1868 : : }
1869 [ # # # # ]: 0 : if (ipv4_spec && ipv4_mask && outer_ip) {
1870 : : /* Check IPv4 mask and update input set */
1871 [ # # ]: 0 : if (ipv4_mask->hdr.version_ihl ||
1872 [ # # ]: 0 : ipv4_mask->hdr.total_length ||
1873 [ # # ]: 0 : ipv4_mask->hdr.packet_id ||
1874 [ # # ]: 0 : ipv4_mask->hdr.hdr_checksum) {
1875 : 0 : rte_flow_error_set(error, EINVAL,
1876 : : RTE_FLOW_ERROR_TYPE_ITEM,
1877 : : item,
1878 : : "Invalid IPv4 mask.");
1879 : 0 : return -rte_errno;
1880 : : }
1881 : :
1882 [ # # ]: 0 : if (ipv4_mask->hdr.src_addr == UINT32_MAX)
1883 : 0 : input_set |= I40E_INSET_IPV4_SRC;
1884 [ # # ]: 0 : if (ipv4_mask->hdr.dst_addr == UINT32_MAX)
1885 : 0 : input_set |= I40E_INSET_IPV4_DST;
1886 [ # # ]: 0 : if (ipv4_mask->hdr.type_of_service == UINT8_MAX)
1887 : 0 : input_set |= I40E_INSET_IPV4_TOS;
1888 [ # # ]: 0 : if (ipv4_mask->hdr.time_to_live == UINT8_MAX)
1889 : 0 : input_set |= I40E_INSET_IPV4_TTL;
1890 [ # # ]: 0 : if (ipv4_mask->hdr.next_proto_id == UINT8_MAX)
1891 : 0 : input_set |= I40E_INSET_IPV4_PROTO;
1892 : :
1893 : : /* Check if it is fragment. */
1894 : 0 : uint16_t frag_mask =
1895 : : ipv4_mask->hdr.fragment_offset;
1896 : 0 : uint16_t frag_spec =
1897 : : ipv4_spec->hdr.fragment_offset;
1898 : : uint16_t frag_last = 0;
1899 [ # # ]: 0 : if (ipv4_last)
1900 : 0 : frag_last =
1901 : : ipv4_last->hdr.fragment_offset;
1902 [ # # ]: 0 : if (frag_mask) {
1903 [ # # ]: 0 : frag_mask = rte_be_to_cpu_16(frag_mask);
1904 [ # # ]: 0 : frag_spec = rte_be_to_cpu_16(frag_spec);
1905 [ # # ]: 0 : frag_last = rte_be_to_cpu_16(frag_last);
1906 : : /* frag_off mask has to be 0x3fff */
1907 [ # # ]: 0 : if (frag_mask !=
1908 : : (RTE_IPV4_HDR_OFFSET_MASK |
1909 : : RTE_IPV4_HDR_MF_FLAG)) {
1910 : 0 : rte_flow_error_set(error,
1911 : : EINVAL,
1912 : : RTE_FLOW_ERROR_TYPE_ITEM,
1913 : : item,
1914 : : "Invalid IPv4 fragment_offset mask");
1915 : 0 : return -rte_errno;
1916 : : }
1917 : : /*
1918 : : * non-frag rule:
1919 : : * mask=0x3fff,spec=0
1920 : : * frag rule:
1921 : : * mask=0x3fff,spec=0x8,last=0x2000
1922 : : */
1923 : 0 : if (frag_spec ==
1924 : 0 : (1 << RTE_IPV4_HDR_FO_SHIFT) &&
1925 [ # # ]: 0 : frag_last == RTE_IPV4_HDR_MF_FLAG) {
1926 : : pctype =
1927 : : I40E_FILTER_PCTYPE_FRAG_IPV4;
1928 [ # # ]: 0 : } else if (frag_spec || frag_last) {
1929 : 0 : rte_flow_error_set(error,
1930 : : EINVAL,
1931 : : RTE_FLOW_ERROR_TYPE_ITEM,
1932 : : item,
1933 : : "Invalid IPv4 fragment_offset rule");
1934 : 0 : return -rte_errno;
1935 : : }
1936 [ # # ]: 0 : } else if (frag_spec || frag_last) {
1937 : 0 : rte_flow_error_set(error,
1938 : : EINVAL,
1939 : : RTE_FLOW_ERROR_TYPE_ITEM,
1940 : : item,
1941 : : "Invalid fragment_offset");
1942 : 0 : return -rte_errno;
1943 : : }
1944 : :
1945 [ # # ]: 0 : if (input_set & (I40E_INSET_DMAC | I40E_INSET_SMAC)) {
1946 [ # # ]: 0 : if (input_set & (I40E_INSET_IPV4_SRC |
1947 : : I40E_INSET_IPV4_DST | I40E_INSET_IPV4_TOS |
1948 : : I40E_INSET_IPV4_TTL | I40E_INSET_IPV4_PROTO)) {
1949 : 0 : rte_flow_error_set(error, EINVAL,
1950 : : RTE_FLOW_ERROR_TYPE_ITEM,
1951 : : item,
1952 : : "L2 and L3 input set are exclusive.");
1953 : 0 : return -rte_errno;
1954 : : }
1955 : : } else {
1956 : : /* Get the filter info */
1957 : 0 : filter->input.flow.ip4_flow.proto =
1958 : 0 : ipv4_spec->hdr.next_proto_id;
1959 : 0 : filter->input.flow.ip4_flow.tos =
1960 : 0 : ipv4_spec->hdr.type_of_service;
1961 : 0 : filter->input.flow.ip4_flow.ttl =
1962 : 0 : ipv4_spec->hdr.time_to_live;
1963 : 0 : filter->input.flow.ip4_flow.src_ip =
1964 : 0 : ipv4_spec->hdr.src_addr;
1965 : 0 : filter->input.flow.ip4_flow.dst_ip =
1966 : 0 : ipv4_spec->hdr.dst_addr;
1967 : :
1968 : 0 : filter->input.flow_ext.inner_ip = false;
1969 : 0 : filter->input.flow_ext.oip_type =
1970 : : I40E_FDIR_IPTYPE_IPV4;
1971 : : }
1972 [ # # # # ]: 0 : } else if (!ipv4_spec && !ipv4_mask && !outer_ip) {
1973 : 0 : filter->input.flow_ext.inner_ip = true;
1974 : 0 : filter->input.flow_ext.iip_type =
1975 : : I40E_FDIR_IPTYPE_IPV4;
1976 [ # # # # ]: 0 : } else if (!ipv4_spec && !ipv4_mask && outer_ip) {
1977 : 0 : filter->input.flow_ext.inner_ip = false;
1978 : 0 : filter->input.flow_ext.oip_type =
1979 : : I40E_FDIR_IPTYPE_IPV4;
1980 [ # # # # ]: 0 : } else if ((ipv4_spec || ipv4_mask) && !outer_ip) {
1981 : 0 : rte_flow_error_set(error, EINVAL,
1982 : : RTE_FLOW_ERROR_TYPE_ITEM,
1983 : : item,
1984 : : "Invalid inner IPv4 mask.");
1985 : 0 : return -rte_errno;
1986 : : }
1987 : :
1988 : : if (outer_ip)
1989 : : outer_ip = false;
1990 : :
1991 : : break;
1992 : 0 : case RTE_FLOW_ITEM_TYPE_IPV6:
1993 : : l3 = RTE_FLOW_ITEM_TYPE_IPV6;
1994 : 0 : ipv6_spec = item->spec;
1995 : 0 : ipv6_mask = item->mask;
1996 : : pctype = I40E_FILTER_PCTYPE_NONF_IPV6_OTHER;
1997 : : layer_idx = I40E_FLXPLD_L3_IDX;
1998 : :
1999 [ # # # # ]: 0 : if (ipv6_spec && ipv6_mask && outer_ip) {
2000 : : /* Check IPv6 mask and update input set */
2001 [ # # ]: 0 : if (ipv6_mask->hdr.payload_len) {
2002 : 0 : rte_flow_error_set(error, EINVAL,
2003 : : RTE_FLOW_ERROR_TYPE_ITEM,
2004 : : item,
2005 : : "Invalid IPv6 mask");
2006 : 0 : return -rte_errno;
2007 : : }
2008 : :
2009 [ # # ]: 0 : if (!memcmp(&ipv6_mask->hdr.src_addr,
2010 : : ipv6_addr_mask,
2011 : : sizeof(ipv6_mask->hdr.src_addr)))
2012 : 0 : input_set |= I40E_INSET_IPV6_SRC;
2013 [ # # ]: 0 : if (!memcmp(&ipv6_mask->hdr.dst_addr,
2014 : : ipv6_addr_mask,
2015 : : sizeof(ipv6_mask->hdr.dst_addr)))
2016 : 0 : input_set |= I40E_INSET_IPV6_DST;
2017 : :
2018 [ # # ]: 0 : if ((ipv6_mask->hdr.vtc_flow &
2019 : : rte_cpu_to_be_32(I40E_IPV6_TC_MASK))
2020 : : == rte_cpu_to_be_32(I40E_IPV6_TC_MASK))
2021 : 0 : input_set |= I40E_INSET_IPV6_TC;
2022 [ # # ]: 0 : if (ipv6_mask->hdr.proto == UINT8_MAX)
2023 : 0 : input_set |= I40E_INSET_IPV6_NEXT_HDR;
2024 [ # # ]: 0 : if (ipv6_mask->hdr.hop_limits == UINT8_MAX)
2025 : 0 : input_set |= I40E_INSET_IPV6_HOP_LIMIT;
2026 : :
2027 : : /* Get filter info */
2028 : : vtc_flow_cpu =
2029 [ # # ]: 0 : rte_be_to_cpu_32(ipv6_spec->hdr.vtc_flow);
2030 : 0 : filter->input.flow.ipv6_flow.tc =
2031 : 0 : (uint8_t)(vtc_flow_cpu >>
2032 : : I40E_FDIR_IPv6_TC_OFFSET);
2033 : 0 : filter->input.flow.ipv6_flow.proto =
2034 : 0 : ipv6_spec->hdr.proto;
2035 : 0 : filter->input.flow.ipv6_flow.hop_limits =
2036 : 0 : ipv6_spec->hdr.hop_limits;
2037 : :
2038 : 0 : filter->input.flow_ext.inner_ip = false;
2039 : 0 : filter->input.flow_ext.oip_type =
2040 : : I40E_FDIR_IPTYPE_IPV6;
2041 : :
2042 : 0 : rte_memcpy(filter->input.flow.ipv6_flow.src_ip,
2043 [ # # ]: 0 : &ipv6_spec->hdr.src_addr, 16);
2044 : 0 : rte_memcpy(filter->input.flow.ipv6_flow.dst_ip,
2045 [ # # ]: 0 : &ipv6_spec->hdr.dst_addr, 16);
2046 : :
2047 : : /* Check if it is fragment. */
2048 [ # # ]: 0 : if (ipv6_spec->hdr.proto ==
2049 : : I40E_IPV6_FRAG_HEADER)
2050 : : pctype = I40E_FILTER_PCTYPE_FRAG_IPV6;
2051 [ # # # # ]: 0 : } else if (!ipv6_spec && !ipv6_mask && !outer_ip) {
2052 : 0 : filter->input.flow_ext.inner_ip = true;
2053 : 0 : filter->input.flow_ext.iip_type =
2054 : : I40E_FDIR_IPTYPE_IPV6;
2055 [ # # # # ]: 0 : } else if (!ipv6_spec && !ipv6_mask && outer_ip) {
2056 : 0 : filter->input.flow_ext.inner_ip = false;
2057 : 0 : filter->input.flow_ext.oip_type =
2058 : : I40E_FDIR_IPTYPE_IPV6;
2059 [ # # # # ]: 0 : } else if ((ipv6_spec || ipv6_mask) && !outer_ip) {
2060 : 0 : rte_flow_error_set(error, EINVAL,
2061 : : RTE_FLOW_ERROR_TYPE_ITEM,
2062 : : item,
2063 : : "Invalid inner IPv6 mask");
2064 : 0 : return -rte_errno;
2065 : : }
2066 : :
2067 : : if (outer_ip)
2068 : : outer_ip = false;
2069 : : break;
2070 : 0 : case RTE_FLOW_ITEM_TYPE_TCP:
2071 : 0 : tcp_spec = item->spec;
2072 : 0 : tcp_mask = item->mask;
2073 : :
2074 [ # # ]: 0 : if (l3 == RTE_FLOW_ITEM_TYPE_IPV4)
2075 : : pctype =
2076 : : I40E_FILTER_PCTYPE_NONF_IPV4_TCP;
2077 [ # # ]: 0 : else if (l3 == RTE_FLOW_ITEM_TYPE_IPV6)
2078 : : pctype =
2079 : : I40E_FILTER_PCTYPE_NONF_IPV6_TCP;
2080 [ # # ]: 0 : if (tcp_spec && tcp_mask) {
2081 : : /* Check TCP mask and update input set */
2082 [ # # ]: 0 : if (tcp_mask->hdr.sent_seq ||
2083 [ # # ]: 0 : tcp_mask->hdr.recv_ack ||
2084 [ # # ]: 0 : tcp_mask->hdr.data_off ||
2085 [ # # ]: 0 : tcp_mask->hdr.tcp_flags ||
2086 [ # # ]: 0 : tcp_mask->hdr.rx_win ||
2087 [ # # ]: 0 : tcp_mask->hdr.cksum ||
2088 [ # # ]: 0 : tcp_mask->hdr.tcp_urp) {
2089 : 0 : rte_flow_error_set(error, EINVAL,
2090 : : RTE_FLOW_ERROR_TYPE_ITEM,
2091 : : item,
2092 : : "Invalid TCP mask");
2093 : 0 : return -rte_errno;
2094 : : }
2095 : :
2096 [ # # ]: 0 : if (tcp_mask->hdr.src_port == UINT16_MAX)
2097 : 0 : input_set |= I40E_INSET_SRC_PORT;
2098 [ # # ]: 0 : if (tcp_mask->hdr.dst_port == UINT16_MAX)
2099 : 0 : input_set |= I40E_INSET_DST_PORT;
2100 : :
2101 [ # # ]: 0 : if (input_set & (I40E_INSET_DMAC | I40E_INSET_SMAC)) {
2102 [ # # ]: 0 : if (input_set &
2103 : : (I40E_INSET_SRC_PORT | I40E_INSET_DST_PORT)) {
2104 : 0 : rte_flow_error_set(error, EINVAL,
2105 : : RTE_FLOW_ERROR_TYPE_ITEM,
2106 : : item,
2107 : : "L2 and L4 input set are exclusive.");
2108 : 0 : return -rte_errno;
2109 : : }
2110 : : } else {
2111 : : /* Get filter info */
2112 [ # # ]: 0 : if (l3 == RTE_FLOW_ITEM_TYPE_IPV4) {
2113 : 0 : filter->input.flow.tcp4_flow.src_port =
2114 : 0 : tcp_spec->hdr.src_port;
2115 : 0 : filter->input.flow.tcp4_flow.dst_port =
2116 : 0 : tcp_spec->hdr.dst_port;
2117 [ # # ]: 0 : } else if (l3 == RTE_FLOW_ITEM_TYPE_IPV6) {
2118 : 0 : filter->input.flow.tcp6_flow.src_port =
2119 : 0 : tcp_spec->hdr.src_port;
2120 : 0 : filter->input.flow.tcp6_flow.dst_port =
2121 : 0 : tcp_spec->hdr.dst_port;
2122 : : }
2123 : : }
2124 : : }
2125 : :
2126 : : layer_idx = I40E_FLXPLD_L4_IDX;
2127 : :
2128 : : break;
2129 : 0 : case RTE_FLOW_ITEM_TYPE_UDP:
2130 : 0 : udp_spec = item->spec;
2131 : 0 : udp_mask = item->mask;
2132 : :
2133 [ # # ]: 0 : if (l3 == RTE_FLOW_ITEM_TYPE_IPV4)
2134 : : pctype =
2135 : : I40E_FILTER_PCTYPE_NONF_IPV4_UDP;
2136 [ # # ]: 0 : else if (l3 == RTE_FLOW_ITEM_TYPE_IPV6)
2137 : : pctype =
2138 : : I40E_FILTER_PCTYPE_NONF_IPV6_UDP;
2139 : :
2140 [ # # ]: 0 : if (udp_spec && udp_mask) {
2141 : : /* Check UDP mask and update input set*/
2142 [ # # ]: 0 : if (udp_mask->hdr.dgram_len ||
2143 [ # # ]: 0 : udp_mask->hdr.dgram_cksum) {
2144 : 0 : rte_flow_error_set(error, EINVAL,
2145 : : RTE_FLOW_ERROR_TYPE_ITEM,
2146 : : item,
2147 : : "Invalid UDP mask");
2148 : 0 : return -rte_errno;
2149 : : }
2150 : :
2151 [ # # ]: 0 : if (udp_mask->hdr.src_port == UINT16_MAX)
2152 : 0 : input_set |= I40E_INSET_SRC_PORT;
2153 [ # # ]: 0 : if (udp_mask->hdr.dst_port == UINT16_MAX)
2154 : 0 : input_set |= I40E_INSET_DST_PORT;
2155 : :
2156 [ # # ]: 0 : if (input_set & (I40E_INSET_DMAC | I40E_INSET_SMAC)) {
2157 [ # # ]: 0 : if (input_set &
2158 : : (I40E_INSET_SRC_PORT | I40E_INSET_DST_PORT)) {
2159 : 0 : rte_flow_error_set(error, EINVAL,
2160 : : RTE_FLOW_ERROR_TYPE_ITEM,
2161 : : item,
2162 : : "L2 and L4 input set are exclusive.");
2163 : 0 : return -rte_errno;
2164 : : }
2165 : : } else {
2166 : : /* Get filter info */
2167 [ # # ]: 0 : if (l3 == RTE_FLOW_ITEM_TYPE_IPV4) {
2168 : 0 : filter->input.flow.udp4_flow.src_port =
2169 : 0 : udp_spec->hdr.src_port;
2170 : 0 : filter->input.flow.udp4_flow.dst_port =
2171 : 0 : udp_spec->hdr.dst_port;
2172 [ # # ]: 0 : } else if (l3 == RTE_FLOW_ITEM_TYPE_IPV6) {
2173 : 0 : filter->input.flow.udp6_flow.src_port =
2174 : 0 : udp_spec->hdr.src_port;
2175 : 0 : filter->input.flow.udp6_flow.dst_port =
2176 : 0 : udp_spec->hdr.dst_port;
2177 : : }
2178 : : }
2179 : : }
2180 : 0 : filter->input.flow_ext.is_udp = true;
2181 : : layer_idx = I40E_FLXPLD_L4_IDX;
2182 : :
2183 : 0 : break;
2184 : 0 : case RTE_FLOW_ITEM_TYPE_GTPC:
2185 : : case RTE_FLOW_ITEM_TYPE_GTPU:
2186 [ # # ]: 0 : if (!pf->gtp_support) {
2187 : 0 : rte_flow_error_set(error, EINVAL,
2188 : : RTE_FLOW_ERROR_TYPE_ITEM,
2189 : : item,
2190 : : "Unsupported protocol");
2191 : 0 : return -rte_errno;
2192 : : }
2193 : :
2194 : 0 : gtp_spec = item->spec;
2195 : 0 : gtp_mask = item->mask;
2196 : :
2197 [ # # ]: 0 : if (gtp_spec && gtp_mask) {
2198 : 0 : if (gtp_mask->hdr.gtp_hdr_info ||
2199 [ # # ]: 0 : gtp_mask->hdr.msg_type ||
2200 : 0 : gtp_mask->hdr.plen ||
2201 [ # # ]: 0 : gtp_mask->hdr.teid != UINT32_MAX) {
2202 : 0 : rte_flow_error_set(error, EINVAL,
2203 : : RTE_FLOW_ERROR_TYPE_ITEM,
2204 : : item,
2205 : : "Invalid GTP mask");
2206 : 0 : return -rte_errno;
2207 : : }
2208 : :
2209 : 0 : filter->input.flow.gtp_flow.teid =
2210 : 0 : gtp_spec->hdr.teid;
2211 : 0 : filter->input.flow_ext.customized_pctype = true;
2212 : : cus_proto = item_type;
2213 : : }
2214 : : break;
2215 : 0 : case RTE_FLOW_ITEM_TYPE_ESP:
2216 [ # # ]: 0 : if (!pf->esp_support) {
2217 : 0 : rte_flow_error_set(error, EINVAL,
2218 : : RTE_FLOW_ERROR_TYPE_ITEM,
2219 : : item,
2220 : : "Unsupported ESP protocol");
2221 : 0 : return -rte_errno;
2222 : : }
2223 : :
2224 : 0 : esp_spec = item->spec;
2225 : 0 : esp_mask = item->mask;
2226 : :
2227 [ # # ]: 0 : if (!esp_spec || !esp_mask) {
2228 : 0 : rte_flow_error_set(error, EINVAL,
2229 : : RTE_FLOW_ERROR_TYPE_ITEM,
2230 : : item,
2231 : : "Invalid ESP item");
2232 : 0 : return -rte_errno;
2233 : : }
2234 : :
2235 : : if (esp_spec && esp_mask) {
2236 [ # # ]: 0 : if (esp_mask->hdr.spi != UINT32_MAX) {
2237 : 0 : rte_flow_error_set(error, EINVAL,
2238 : : RTE_FLOW_ERROR_TYPE_ITEM,
2239 : : item,
2240 : : "Invalid ESP mask");
2241 : 0 : return -rte_errno;
2242 : : }
2243 : : i40e_flow_set_filter_spi(filter, esp_spec);
2244 : 0 : filter->input.flow_ext.customized_pctype = true;
2245 : : cus_proto = item_type;
2246 : : }
2247 : : break;
2248 : 0 : case RTE_FLOW_ITEM_TYPE_SCTP:
2249 : 0 : sctp_spec = item->spec;
2250 : 0 : sctp_mask = item->mask;
2251 : :
2252 [ # # ]: 0 : if (l3 == RTE_FLOW_ITEM_TYPE_IPV4)
2253 : : pctype =
2254 : : I40E_FILTER_PCTYPE_NONF_IPV4_SCTP;
2255 [ # # ]: 0 : else if (l3 == RTE_FLOW_ITEM_TYPE_IPV6)
2256 : : pctype =
2257 : : I40E_FILTER_PCTYPE_NONF_IPV6_SCTP;
2258 : :
2259 [ # # ]: 0 : if (sctp_spec && sctp_mask) {
2260 : : /* Check SCTP mask and update input set */
2261 [ # # ]: 0 : if (sctp_mask->hdr.cksum) {
2262 : 0 : rte_flow_error_set(error, EINVAL,
2263 : : RTE_FLOW_ERROR_TYPE_ITEM,
2264 : : item,
2265 : : "Invalid UDP mask");
2266 : 0 : return -rte_errno;
2267 : : }
2268 : :
2269 [ # # ]: 0 : if (sctp_mask->hdr.src_port == UINT16_MAX)
2270 : 0 : input_set |= I40E_INSET_SRC_PORT;
2271 [ # # ]: 0 : if (sctp_mask->hdr.dst_port == UINT16_MAX)
2272 : 0 : input_set |= I40E_INSET_DST_PORT;
2273 [ # # ]: 0 : if (sctp_mask->hdr.tag == UINT32_MAX)
2274 : 0 : input_set |= I40E_INSET_SCTP_VT;
2275 : :
2276 : : /* Get filter info */
2277 [ # # ]: 0 : if (l3 == RTE_FLOW_ITEM_TYPE_IPV4) {
2278 : 0 : filter->input.flow.sctp4_flow.src_port =
2279 : 0 : sctp_spec->hdr.src_port;
2280 : 0 : filter->input.flow.sctp4_flow.dst_port =
2281 : 0 : sctp_spec->hdr.dst_port;
2282 : : filter->input.flow.sctp4_flow.verify_tag
2283 : 0 : = sctp_spec->hdr.tag;
2284 [ # # ]: 0 : } else if (l3 == RTE_FLOW_ITEM_TYPE_IPV6) {
2285 : 0 : filter->input.flow.sctp6_flow.src_port =
2286 : 0 : sctp_spec->hdr.src_port;
2287 : 0 : filter->input.flow.sctp6_flow.dst_port =
2288 : 0 : sctp_spec->hdr.dst_port;
2289 : : filter->input.flow.sctp6_flow.verify_tag
2290 : 0 : = sctp_spec->hdr.tag;
2291 : : }
2292 : : }
2293 : :
2294 : : layer_idx = I40E_FLXPLD_L4_IDX;
2295 : :
2296 : : break;
2297 : 0 : case RTE_FLOW_ITEM_TYPE_RAW:
2298 : 0 : raw_spec = item->spec;
2299 : 0 : raw_mask = item->mask;
2300 : :
2301 [ # # ]: 0 : if (!raw_spec || !raw_mask) {
2302 : 0 : rte_flow_error_set(error, EINVAL,
2303 : : RTE_FLOW_ERROR_TYPE_ITEM,
2304 : : item,
2305 : : "NULL RAW spec/mask");
2306 : 0 : return -rte_errno;
2307 : : }
2308 : :
2309 [ # # ]: 0 : if (pf->support_multi_driver) {
2310 : 0 : rte_flow_error_set(error, ENOTSUP,
2311 : : RTE_FLOW_ERROR_TYPE_ITEM,
2312 : : item,
2313 : : "Unsupported flexible payload.");
2314 : 0 : return -rte_errno;
2315 : : }
2316 : :
2317 : 0 : ret = i40e_flow_check_raw_item(item, raw_spec, error);
2318 [ # # ]: 0 : if (ret < 0)
2319 : 0 : return ret;
2320 : :
2321 : 0 : off_arr[raw_id] = raw_spec->offset;
2322 : 0 : len_arr[raw_id] = raw_spec->length;
2323 : :
2324 : : flex_size = 0;
2325 : : memset(&flex_pit, 0, sizeof(struct i40e_fdir_flex_pit));
2326 : 0 : field_idx = layer_idx * I40E_MAX_FLXPLD_FIED + raw_id;
2327 : 0 : flex_pit.size =
2328 : : raw_spec->length / sizeof(uint16_t);
2329 : 0 : flex_pit.dst_offset =
2330 : : next_dst_off / sizeof(uint16_t);
2331 : :
2332 [ # # ]: 0 : for (i = 0; i <= raw_id; i++) {
2333 [ # # ]: 0 : if (i == raw_id)
2334 : 0 : flex_pit.src_offset +=
2335 : 0 : raw_spec->offset /
2336 : : sizeof(uint16_t);
2337 : : else
2338 : 0 : flex_pit.src_offset +=
2339 : 0 : (off_arr[i] + len_arr[i]) /
2340 : : sizeof(uint16_t);
2341 : 0 : flex_size += len_arr[i];
2342 : : }
2343 [ # # ]: 0 : if (((flex_pit.src_offset + flex_pit.size) >=
2344 [ # # ]: 0 : I40E_MAX_FLX_SOURCE_OFF / sizeof(uint16_t)) ||
2345 : : flex_size > I40E_FDIR_MAX_FLEXLEN) {
2346 : 0 : rte_flow_error_set(error, EINVAL,
2347 : : RTE_FLOW_ERROR_TYPE_ITEM,
2348 : : item,
2349 : : "Exceeds maximal payload limit.");
2350 : 0 : return -rte_errno;
2351 : : }
2352 : :
2353 [ # # ]: 0 : for (i = 0; i < raw_spec->length; i++) {
2354 : 0 : j = i + next_dst_off;
2355 [ # # ]: 0 : if (j >= RTE_ETH_FDIR_MAX_FLEXLEN ||
2356 : : j >= I40E_FDIR_MAX_FLEX_LEN)
2357 : : break;
2358 : 0 : filter->input.flow_ext.flexbytes[j] =
2359 : 0 : raw_spec->pattern[i];
2360 : 0 : filter->input.flow_ext.flex_mask[j] =
2361 : 0 : raw_mask->pattern[i];
2362 : : }
2363 : :
2364 : 0 : next_dst_off += raw_spec->length;
2365 : 0 : raw_id++;
2366 : :
2367 : 0 : memcpy(&filter->input.flow_ext.flex_pit[field_idx],
2368 : : &flex_pit, sizeof(struct i40e_fdir_flex_pit));
2369 : 0 : filter->input.flow_ext.layer_idx = layer_idx;
2370 : 0 : filter->input.flow_ext.raw_id = raw_id;
2371 : 0 : filter->input.flow_ext.is_flex_flow = true;
2372 : 0 : break;
2373 : 0 : case RTE_FLOW_ITEM_TYPE_L2TPV3OIP:
2374 : 0 : l2tpv3oip_spec = item->spec;
2375 : 0 : l2tpv3oip_mask = item->mask;
2376 : :
2377 [ # # ]: 0 : if (!l2tpv3oip_spec || !l2tpv3oip_mask)
2378 : : break;
2379 : :
2380 [ # # ]: 0 : if (l2tpv3oip_mask->session_id != UINT32_MAX) {
2381 : 0 : rte_flow_error_set(error, EINVAL,
2382 : : RTE_FLOW_ERROR_TYPE_ITEM,
2383 : : item,
2384 : : "Invalid L2TPv3 mask");
2385 : 0 : return -rte_errno;
2386 : : }
2387 : :
2388 [ # # ]: 0 : if (l3 == RTE_FLOW_ITEM_TYPE_IPV4) {
2389 : 0 : filter->input.flow.ip4_l2tpv3oip_flow.session_id =
2390 : 0 : l2tpv3oip_spec->session_id;
2391 : 0 : filter->input.flow_ext.oip_type =
2392 : : I40E_FDIR_IPTYPE_IPV4;
2393 [ # # ]: 0 : } else if (l3 == RTE_FLOW_ITEM_TYPE_IPV6) {
2394 : 0 : filter->input.flow.ip6_l2tpv3oip_flow.session_id =
2395 : 0 : l2tpv3oip_spec->session_id;
2396 : 0 : filter->input.flow_ext.oip_type =
2397 : : I40E_FDIR_IPTYPE_IPV6;
2398 : : }
2399 : :
2400 : 0 : filter->input.flow_ext.customized_pctype = true;
2401 : : cus_proto = item_type;
2402 : 0 : break;
2403 : : default:
2404 : : break;
2405 : : }
2406 : : }
2407 : :
2408 : : /* Get customized pctype value */
2409 [ # # ]: 0 : if (filter->input.flow_ext.customized_pctype) {
2410 : 0 : pctype = i40e_flow_fdir_get_pctype_value(pf, cus_proto, filter);
2411 [ # # ]: 0 : if (pctype == I40E_FILTER_PCTYPE_INVALID) {
2412 : 0 : rte_flow_error_set(error, EINVAL,
2413 : : RTE_FLOW_ERROR_TYPE_ITEM,
2414 : : item,
2415 : : "Unsupported pctype");
2416 : 0 : return -rte_errno;
2417 : : }
2418 : : }
2419 : :
2420 : : /* If customized pctype is not used, set fdir configuration.*/
2421 [ # # ]: 0 : if (!filter->input.flow_ext.customized_pctype) {
2422 : : /* Check if the input set is valid */
2423 [ # # ]: 0 : if (i40e_validate_input_set(pctype, RTE_ETH_FILTER_FDIR,
2424 : : input_set) != 0) {
2425 : 0 : rte_flow_error_set(error, EINVAL,
2426 : : RTE_FLOW_ERROR_TYPE_ITEM,
2427 : : item,
2428 : : "Invalid input set");
2429 : 0 : return -rte_errno;
2430 : : }
2431 : :
2432 : 0 : filter->input.flow_ext.input_set = input_set;
2433 : : }
2434 : :
2435 : 0 : filter->input.pctype = pctype;
2436 : :
2437 : 0 : return 0;
2438 : : }
2439 : :
2440 : : /* Parse to get the action info of a FDIR filter.
2441 : : * FDIR action supports QUEUE or (QUEUE + MARK).
2442 : : */
2443 : : static int
2444 : 0 : i40e_flow_parse_fdir_action(struct rte_eth_dev *dev,
2445 : : const struct rte_flow_action *actions,
2446 : : struct rte_flow_error *error,
2447 : : struct i40e_fdir_filter_conf *filter)
2448 : : {
2449 : 0 : struct i40e_pf *pf = I40E_DEV_PRIVATE_TO_PF(dev->data->dev_private);
2450 : : const struct rte_flow_action *act;
2451 : : const struct rte_flow_action_queue *act_q;
2452 : : const struct rte_flow_action_mark *mark_spec = NULL;
2453 : : uint32_t index = 0;
2454 : :
2455 : : /* Check if the first non-void action is QUEUE or DROP or PASSTHRU. */
2456 [ # # ]: 0 : NEXT_ITEM_OF_ACTION(act, actions, index);
2457 [ # # # # : 0 : switch (act->type) {
# ]
2458 : 0 : case RTE_FLOW_ACTION_TYPE_QUEUE:
2459 : 0 : act_q = act->conf;
2460 : 0 : filter->action.rx_queue = act_q->index;
2461 [ # # ]: 0 : if ((!filter->input.flow_ext.is_vf &&
2462 [ # # # # ]: 0 : filter->action.rx_queue >= pf->dev_data->nb_rx_queues) ||
2463 : 0 : (filter->input.flow_ext.is_vf &&
2464 [ # # ]: 0 : filter->action.rx_queue >= pf->vf_nb_qps)) {
2465 : 0 : rte_flow_error_set(error, EINVAL,
2466 : : RTE_FLOW_ERROR_TYPE_ACTION, act,
2467 : : "Invalid queue ID for FDIR.");
2468 : 0 : return -rte_errno;
2469 : : }
2470 : 0 : filter->action.behavior = I40E_FDIR_ACCEPT;
2471 : 0 : break;
2472 : 0 : case RTE_FLOW_ACTION_TYPE_DROP:
2473 : 0 : filter->action.behavior = I40E_FDIR_REJECT;
2474 : 0 : break;
2475 : 0 : case RTE_FLOW_ACTION_TYPE_PASSTHRU:
2476 : 0 : filter->action.behavior = I40E_FDIR_PASSTHRU;
2477 : 0 : break;
2478 : 0 : case RTE_FLOW_ACTION_TYPE_MARK:
2479 : 0 : filter->action.behavior = I40E_FDIR_PASSTHRU;
2480 : 0 : mark_spec = act->conf;
2481 : 0 : filter->action.report_status = I40E_FDIR_REPORT_ID;
2482 : 0 : filter->soft_id = mark_spec->id;
2483 : 0 : break;
2484 : 0 : default:
2485 : 0 : rte_flow_error_set(error, EINVAL,
2486 : : RTE_FLOW_ERROR_TYPE_ACTION, act,
2487 : : "Invalid action.");
2488 : 0 : return -rte_errno;
2489 : : }
2490 : :
2491 : : /* Check if the next non-void item is MARK or FLAG or END. */
2492 : 0 : index++;
2493 [ # # ]: 0 : NEXT_ITEM_OF_ACTION(act, actions, index);
2494 [ # # # # : 0 : switch (act->type) {
# ]
2495 : 0 : case RTE_FLOW_ACTION_TYPE_MARK:
2496 [ # # ]: 0 : if (mark_spec) {
2497 : : /* Double MARK actions requested */
2498 : 0 : rte_flow_error_set(error, EINVAL,
2499 : : RTE_FLOW_ERROR_TYPE_ACTION, act,
2500 : : "Invalid action.");
2501 : 0 : return -rte_errno;
2502 : : }
2503 : 0 : mark_spec = act->conf;
2504 : 0 : filter->action.report_status = I40E_FDIR_REPORT_ID;
2505 : 0 : filter->soft_id = mark_spec->id;
2506 : 0 : break;
2507 : 0 : case RTE_FLOW_ACTION_TYPE_FLAG:
2508 [ # # ]: 0 : if (mark_spec) {
2509 : : /* MARK + FLAG not supported */
2510 : 0 : rte_flow_error_set(error, EINVAL,
2511 : : RTE_FLOW_ERROR_TYPE_ACTION, act,
2512 : : "Invalid action.");
2513 : 0 : return -rte_errno;
2514 : : }
2515 : 0 : filter->action.report_status = I40E_FDIR_NO_REPORT_STATUS;
2516 : 0 : break;
2517 : 0 : case RTE_FLOW_ACTION_TYPE_RSS:
2518 [ # # ]: 0 : if (filter->action.behavior != I40E_FDIR_PASSTHRU) {
2519 : : /* RSS filter won't be next if FDIR did not pass thru */
2520 : 0 : rte_flow_error_set(error, EINVAL,
2521 : : RTE_FLOW_ERROR_TYPE_ACTION, act,
2522 : : "Invalid action.");
2523 : 0 : return -rte_errno;
2524 : : }
2525 : : break;
2526 : : case RTE_FLOW_ACTION_TYPE_END:
2527 : : return 0;
2528 : 0 : default:
2529 : 0 : rte_flow_error_set(error, EINVAL, RTE_FLOW_ERROR_TYPE_ACTION,
2530 : : act, "Invalid action.");
2531 : 0 : return -rte_errno;
2532 : : }
2533 : :
2534 : : /* Check if the next non-void item is END */
2535 : 0 : index++;
2536 [ # # ]: 0 : NEXT_ITEM_OF_ACTION(act, actions, index);
2537 [ # # ]: 0 : if (act->type != RTE_FLOW_ACTION_TYPE_END) {
2538 : 0 : rte_flow_error_set(error, EINVAL,
2539 : : RTE_FLOW_ERROR_TYPE_ACTION,
2540 : : act, "Invalid action.");
2541 : 0 : return -rte_errno;
2542 : : }
2543 : :
2544 : : return 0;
2545 : : }
2546 : :
2547 : : static int
2548 : 0 : i40e_flow_parse_fdir_filter(struct rte_eth_dev *dev,
2549 : : const struct rte_flow_attr *attr,
2550 : : const struct rte_flow_item pattern[],
2551 : : const struct rte_flow_action actions[],
2552 : : struct rte_flow_error *error,
2553 : : union i40e_filter_t *filter)
2554 : : {
2555 : 0 : struct i40e_pf *pf = I40E_DEV_PRIVATE_TO_PF(dev->data->dev_private);
2556 : 0 : struct i40e_fdir_filter_conf *fdir_filter =
2557 : : &filter->fdir_filter;
2558 : : int ret;
2559 : :
2560 : 0 : ret = i40e_flow_parse_fdir_pattern(dev, pattern, error, fdir_filter);
2561 [ # # ]: 0 : if (ret)
2562 : : return ret;
2563 : :
2564 : 0 : ret = i40e_flow_parse_fdir_action(dev, actions, error, fdir_filter);
2565 [ # # ]: 0 : if (ret)
2566 : : return ret;
2567 : :
2568 : 0 : ret = i40e_flow_parse_attr(attr, error);
2569 [ # # ]: 0 : if (ret)
2570 : : return ret;
2571 : :
2572 : 0 : cons_filter_type = RTE_ETH_FILTER_FDIR;
2573 : :
2574 [ # # ]: 0 : if (pf->fdir.fdir_vsi == NULL) {
2575 : : /* Enable fdir when fdir flow is added at first time. */
2576 : 0 : ret = i40e_fdir_setup(pf);
2577 [ # # ]: 0 : if (ret != I40E_SUCCESS) {
2578 : 0 : rte_flow_error_set(error, ENOTSUP,
2579 : : RTE_FLOW_ERROR_TYPE_HANDLE,
2580 : : NULL, "Failed to setup fdir.");
2581 : 0 : return -rte_errno;
2582 : : }
2583 : 0 : ret = i40e_fdir_configure(dev);
2584 [ # # ]: 0 : if (ret < 0) {
2585 : 0 : rte_flow_error_set(error, ENOTSUP,
2586 : : RTE_FLOW_ERROR_TYPE_HANDLE,
2587 : : NULL, "Failed to configure fdir.");
2588 : 0 : goto err;
2589 : : }
2590 : : }
2591 : :
2592 : : /* If create the first fdir rule, enable fdir check for rx queues */
2593 [ # # ]: 0 : if (TAILQ_EMPTY(&pf->fdir.fdir_list))
2594 : 0 : i40e_fdir_rx_proc_enable(dev, 1);
2595 : :
2596 : : return 0;
2597 : : err:
2598 : 0 : i40e_fdir_teardown(pf);
2599 : 0 : return -rte_errno;
2600 : : }
2601 : :
2602 : : /* Parse to get the action info of a tunnel filter
2603 : : * Tunnel action only supports PF, VF and QUEUE.
2604 : : */
2605 : : static int
2606 : 0 : i40e_flow_parse_tunnel_action(struct rte_eth_dev *dev,
2607 : : const struct rte_flow_action *actions,
2608 : : struct rte_flow_error *error,
2609 : : struct i40e_tunnel_filter_conf *filter)
2610 : : {
2611 : 0 : struct i40e_pf *pf = I40E_DEV_PRIVATE_TO_PF(dev->data->dev_private);
2612 : : const struct rte_flow_action *act;
2613 : : const struct rte_flow_action_queue *act_q;
2614 : : const struct rte_flow_action_vf *act_vf;
2615 : : uint32_t index = 0;
2616 : :
2617 : : /* Check if the first non-void action is PF or VF. */
2618 [ # # ]: 0 : NEXT_ITEM_OF_ACTION(act, actions, index);
2619 [ # # ]: 0 : if (act->type != RTE_FLOW_ACTION_TYPE_PF &&
2620 : : act->type != RTE_FLOW_ACTION_TYPE_VF) {
2621 : 0 : rte_flow_error_set(error, EINVAL, RTE_FLOW_ERROR_TYPE_ACTION,
2622 : : act, "Not supported action.");
2623 : 0 : return -rte_errno;
2624 : : }
2625 : :
2626 [ # # ]: 0 : if (act->type == RTE_FLOW_ACTION_TYPE_VF) {
2627 : 0 : act_vf = act->conf;
2628 : 0 : filter->vf_id = act_vf->id;
2629 : 0 : filter->is_to_vf = 1;
2630 [ # # ]: 0 : if (filter->vf_id >= pf->vf_num) {
2631 : 0 : rte_flow_error_set(error, EINVAL,
2632 : : RTE_FLOW_ERROR_TYPE_ACTION,
2633 : : act, "Invalid VF ID for tunnel filter");
2634 : 0 : return -rte_errno;
2635 : : }
2636 : : }
2637 : :
2638 : : /* Check if the next non-void item is QUEUE */
2639 : 0 : index++;
2640 [ # # ]: 0 : NEXT_ITEM_OF_ACTION(act, actions, index);
2641 [ # # ]: 0 : if (act->type == RTE_FLOW_ACTION_TYPE_QUEUE) {
2642 : 0 : act_q = act->conf;
2643 : 0 : filter->queue_id = act_q->index;
2644 [ # # ]: 0 : if ((!filter->is_to_vf) &&
2645 [ # # ]: 0 : (filter->queue_id >= pf->dev_data->nb_rx_queues)) {
2646 : 0 : rte_flow_error_set(error, EINVAL,
2647 : : RTE_FLOW_ERROR_TYPE_ACTION,
2648 : : act, "Invalid queue ID for tunnel filter");
2649 : 0 : return -rte_errno;
2650 [ # # ]: 0 : } else if (filter->is_to_vf &&
2651 [ # # ]: 0 : (filter->queue_id >= pf->vf_nb_qps)) {
2652 : 0 : rte_flow_error_set(error, EINVAL,
2653 : : RTE_FLOW_ERROR_TYPE_ACTION,
2654 : : act, "Invalid queue ID for tunnel filter");
2655 : 0 : return -rte_errno;
2656 : : }
2657 : : }
2658 : :
2659 : : /* Check if the next non-void item is END */
2660 : 0 : index++;
2661 [ # # ]: 0 : NEXT_ITEM_OF_ACTION(act, actions, index);
2662 [ # # ]: 0 : if (act->type != RTE_FLOW_ACTION_TYPE_END) {
2663 : 0 : rte_flow_error_set(error, EINVAL, RTE_FLOW_ERROR_TYPE_ACTION,
2664 : : act, "Not supported action.");
2665 : 0 : return -rte_errno;
2666 : : }
2667 : :
2668 : : return 0;
2669 : : }
2670 : :
2671 : : /* 1. Last in item should be NULL as range is not supported.
2672 : : * 2. Supported filter types: Source port only and Destination port only.
2673 : : * 3. Mask of fields which need to be matched should be
2674 : : * filled with 1.
2675 : : * 4. Mask of fields which needn't to be matched should be
2676 : : * filled with 0.
2677 : : */
2678 : : static int
2679 : 0 : i40e_flow_parse_l4_pattern(const struct rte_flow_item *pattern,
2680 : : struct rte_flow_error *error,
2681 : : struct i40e_tunnel_filter_conf *filter)
2682 : : {
2683 : : const struct rte_flow_item_sctp *sctp_spec, *sctp_mask;
2684 : : const struct rte_flow_item_tcp *tcp_spec, *tcp_mask;
2685 : : const struct rte_flow_item_udp *udp_spec, *udp_mask;
2686 : : const struct rte_flow_item *item = pattern;
2687 : : enum rte_flow_item_type item_type;
2688 : :
2689 [ # # ]: 0 : for (; item->type != RTE_FLOW_ITEM_TYPE_END; item++) {
2690 [ # # ]: 0 : if (item->last) {
2691 : 0 : rte_flow_error_set(error, EINVAL,
2692 : : RTE_FLOW_ERROR_TYPE_ITEM,
2693 : : item,
2694 : : "Not support range");
2695 : 0 : return -rte_errno;
2696 : : }
2697 : : item_type = item->type;
2698 [ # # # # : 0 : switch (item_type) {
# # # ]
2699 : 0 : case RTE_FLOW_ITEM_TYPE_ETH:
2700 [ # # # # ]: 0 : if (item->spec || item->mask) {
2701 : 0 : rte_flow_error_set(error, EINVAL,
2702 : : RTE_FLOW_ERROR_TYPE_ITEM,
2703 : : item,
2704 : : "Invalid ETH item");
2705 : 0 : return -rte_errno;
2706 : : }
2707 : :
2708 : : break;
2709 : 0 : case RTE_FLOW_ITEM_TYPE_IPV4:
2710 : 0 : filter->ip_type = I40E_TUNNEL_IPTYPE_IPV4;
2711 : : /* IPv4 is used to describe protocol,
2712 : : * spec and mask should be NULL.
2713 : : */
2714 [ # # # # ]: 0 : if (item->spec || item->mask) {
2715 : 0 : rte_flow_error_set(error, EINVAL,
2716 : : RTE_FLOW_ERROR_TYPE_ITEM,
2717 : : item,
2718 : : "Invalid IPv4 item");
2719 : 0 : return -rte_errno;
2720 : : }
2721 : :
2722 : : break;
2723 : 0 : case RTE_FLOW_ITEM_TYPE_IPV6:
2724 : 0 : filter->ip_type = I40E_TUNNEL_IPTYPE_IPV6;
2725 : : /* IPv6 is used to describe protocol,
2726 : : * spec and mask should be NULL.
2727 : : */
2728 [ # # # # ]: 0 : if (item->spec || item->mask) {
2729 : 0 : rte_flow_error_set(error, EINVAL,
2730 : : RTE_FLOW_ERROR_TYPE_ITEM,
2731 : : item,
2732 : : "Invalid IPv6 item");
2733 : 0 : return -rte_errno;
2734 : : }
2735 : :
2736 : : break;
2737 : 0 : case RTE_FLOW_ITEM_TYPE_UDP:
2738 : 0 : udp_spec = item->spec;
2739 : 0 : udp_mask = item->mask;
2740 : :
2741 [ # # ]: 0 : if (!udp_spec || !udp_mask) {
2742 : 0 : rte_flow_error_set(error, EINVAL,
2743 : : RTE_FLOW_ERROR_TYPE_ITEM,
2744 : : item,
2745 : : "Invalid udp item");
2746 : 0 : return -rte_errno;
2747 : : }
2748 : :
2749 [ # # ]: 0 : if (udp_spec->hdr.src_port != 0 &&
2750 [ # # ]: 0 : udp_spec->hdr.dst_port != 0) {
2751 : 0 : rte_flow_error_set(error, EINVAL,
2752 : : RTE_FLOW_ERROR_TYPE_ITEM,
2753 : : item,
2754 : : "Invalid udp spec");
2755 : 0 : return -rte_errno;
2756 : : }
2757 : :
2758 [ # # ]: 0 : if (udp_spec->hdr.src_port != 0) {
2759 : 0 : filter->l4_port_type =
2760 : : I40E_L4_PORT_TYPE_SRC;
2761 : 0 : filter->tenant_id =
2762 [ # # ]: 0 : rte_be_to_cpu_32(udp_spec->hdr.src_port);
2763 : : }
2764 : :
2765 [ # # ]: 0 : if (udp_spec->hdr.dst_port != 0) {
2766 : 0 : filter->l4_port_type =
2767 : : I40E_L4_PORT_TYPE_DST;
2768 : 0 : filter->tenant_id =
2769 [ # # ]: 0 : rte_be_to_cpu_32(udp_spec->hdr.dst_port);
2770 : : }
2771 : :
2772 : 0 : filter->tunnel_type = I40E_CLOUD_TYPE_UDP;
2773 : :
2774 : 0 : break;
2775 : 0 : case RTE_FLOW_ITEM_TYPE_TCP:
2776 : 0 : tcp_spec = item->spec;
2777 : 0 : tcp_mask = item->mask;
2778 : :
2779 [ # # ]: 0 : if (!tcp_spec || !tcp_mask) {
2780 : 0 : rte_flow_error_set(error, EINVAL,
2781 : : RTE_FLOW_ERROR_TYPE_ITEM,
2782 : : item,
2783 : : "Invalid tcp item");
2784 : 0 : return -rte_errno;
2785 : : }
2786 : :
2787 [ # # ]: 0 : if (tcp_spec->hdr.src_port != 0 &&
2788 [ # # ]: 0 : tcp_spec->hdr.dst_port != 0) {
2789 : 0 : rte_flow_error_set(error, EINVAL,
2790 : : RTE_FLOW_ERROR_TYPE_ITEM,
2791 : : item,
2792 : : "Invalid tcp spec");
2793 : 0 : return -rte_errno;
2794 : : }
2795 : :
2796 [ # # ]: 0 : if (tcp_spec->hdr.src_port != 0) {
2797 : 0 : filter->l4_port_type =
2798 : : I40E_L4_PORT_TYPE_SRC;
2799 : 0 : filter->tenant_id =
2800 [ # # ]: 0 : rte_be_to_cpu_32(tcp_spec->hdr.src_port);
2801 : : }
2802 : :
2803 [ # # ]: 0 : if (tcp_spec->hdr.dst_port != 0) {
2804 : 0 : filter->l4_port_type =
2805 : : I40E_L4_PORT_TYPE_DST;
2806 : 0 : filter->tenant_id =
2807 [ # # ]: 0 : rte_be_to_cpu_32(tcp_spec->hdr.dst_port);
2808 : : }
2809 : :
2810 : 0 : filter->tunnel_type = I40E_CLOUD_TYPE_TCP;
2811 : :
2812 : 0 : break;
2813 : 0 : case RTE_FLOW_ITEM_TYPE_SCTP:
2814 : 0 : sctp_spec = item->spec;
2815 : 0 : sctp_mask = item->mask;
2816 : :
2817 [ # # ]: 0 : if (!sctp_spec || !sctp_mask) {
2818 : 0 : rte_flow_error_set(error, EINVAL,
2819 : : RTE_FLOW_ERROR_TYPE_ITEM,
2820 : : item,
2821 : : "Invalid sctp item");
2822 : 0 : return -rte_errno;
2823 : : }
2824 : :
2825 [ # # ]: 0 : if (sctp_spec->hdr.src_port != 0 &&
2826 [ # # ]: 0 : sctp_spec->hdr.dst_port != 0) {
2827 : 0 : rte_flow_error_set(error, EINVAL,
2828 : : RTE_FLOW_ERROR_TYPE_ITEM,
2829 : : item,
2830 : : "Invalid sctp spec");
2831 : 0 : return -rte_errno;
2832 : : }
2833 : :
2834 [ # # ]: 0 : if (sctp_spec->hdr.src_port != 0) {
2835 : 0 : filter->l4_port_type =
2836 : : I40E_L4_PORT_TYPE_SRC;
2837 : 0 : filter->tenant_id =
2838 [ # # ]: 0 : rte_be_to_cpu_32(sctp_spec->hdr.src_port);
2839 : : }
2840 : :
2841 [ # # ]: 0 : if (sctp_spec->hdr.dst_port != 0) {
2842 : 0 : filter->l4_port_type =
2843 : : I40E_L4_PORT_TYPE_DST;
2844 : 0 : filter->tenant_id =
2845 [ # # ]: 0 : rte_be_to_cpu_32(sctp_spec->hdr.dst_port);
2846 : : }
2847 : :
2848 : 0 : filter->tunnel_type = I40E_CLOUD_TYPE_SCTP;
2849 : :
2850 : 0 : break;
2851 : : default:
2852 : : break;
2853 : : }
2854 : : }
2855 : :
2856 : : return 0;
2857 : : }
2858 : :
2859 : : static int
2860 : 0 : i40e_flow_parse_l4_cloud_filter(struct rte_eth_dev *dev,
2861 : : const struct rte_flow_attr *attr,
2862 : : const struct rte_flow_item pattern[],
2863 : : const struct rte_flow_action actions[],
2864 : : struct rte_flow_error *error,
2865 : : union i40e_filter_t *filter)
2866 : : {
2867 : 0 : struct i40e_tunnel_filter_conf *tunnel_filter =
2868 : : &filter->consistent_tunnel_filter;
2869 : : int ret;
2870 : :
2871 : 0 : ret = i40e_flow_parse_l4_pattern(pattern, error, tunnel_filter);
2872 [ # # ]: 0 : if (ret)
2873 : : return ret;
2874 : :
2875 : 0 : ret = i40e_flow_parse_tunnel_action(dev, actions, error, tunnel_filter);
2876 [ # # ]: 0 : if (ret)
2877 : : return ret;
2878 : :
2879 : 0 : ret = i40e_flow_parse_attr(attr, error);
2880 [ # # ]: 0 : if (ret)
2881 : : return ret;
2882 : :
2883 : 0 : cons_filter_type = RTE_ETH_FILTER_TUNNEL;
2884 : :
2885 : 0 : return ret;
2886 : : }
2887 : :
2888 : : static uint16_t i40e_supported_tunnel_filter_types[] = {
2889 : : RTE_ETH_TUNNEL_FILTER_IMAC | RTE_ETH_TUNNEL_FILTER_TENID |
2890 : : RTE_ETH_TUNNEL_FILTER_IVLAN,
2891 : : RTE_ETH_TUNNEL_FILTER_IMAC | RTE_ETH_TUNNEL_FILTER_IVLAN,
2892 : : RTE_ETH_TUNNEL_FILTER_IMAC | RTE_ETH_TUNNEL_FILTER_TENID,
2893 : : RTE_ETH_TUNNEL_FILTER_OMAC | RTE_ETH_TUNNEL_FILTER_TENID |
2894 : : RTE_ETH_TUNNEL_FILTER_IMAC,
2895 : : RTE_ETH_TUNNEL_FILTER_IMAC,
2896 : : };
2897 : :
2898 : : static int
2899 : : i40e_check_tunnel_filter_type(uint8_t filter_type)
2900 : : {
2901 : : uint8_t i;
2902 : :
2903 [ # # # # ]: 0 : for (i = 0; i < RTE_DIM(i40e_supported_tunnel_filter_types); i++) {
2904 [ # # # # ]: 0 : if (filter_type == i40e_supported_tunnel_filter_types[i])
2905 : : return 0;
2906 : : }
2907 : :
2908 : : return -1;
2909 : : }
2910 : :
2911 : : /* 1. Last in item should be NULL as range is not supported.
2912 : : * 2. Supported filter types: IMAC_IVLAN_TENID, IMAC_IVLAN,
2913 : : * IMAC_TENID, OMAC_TENID_IMAC and IMAC.
2914 : : * 3. Mask of fields which need to be matched should be
2915 : : * filled with 1.
2916 : : * 4. Mask of fields which needn't to be matched should be
2917 : : * filled with 0.
2918 : : */
2919 : : static int
2920 : 0 : i40e_flow_parse_vxlan_pattern(__rte_unused struct rte_eth_dev *dev,
2921 : : const struct rte_flow_item *pattern,
2922 : : struct rte_flow_error *error,
2923 : : struct i40e_tunnel_filter_conf *filter)
2924 : : {
2925 : : const struct rte_flow_item *item = pattern;
2926 : : const struct rte_flow_item_eth *eth_spec;
2927 : : const struct rte_flow_item_eth *eth_mask;
2928 : : const struct rte_flow_item_vxlan *vxlan_spec;
2929 : : const struct rte_flow_item_vxlan *vxlan_mask;
2930 : : const struct rte_flow_item_vlan *vlan_spec;
2931 : : const struct rte_flow_item_vlan *vlan_mask;
2932 : : uint8_t filter_type = 0;
2933 : : bool is_vni_masked = 0;
2934 : 0 : uint8_t vni_mask[] = {0xFF, 0xFF, 0xFF};
2935 : : enum rte_flow_item_type item_type;
2936 : : bool vxlan_flag = 0;
2937 : 0 : uint32_t tenant_id_be = 0;
2938 : : int ret;
2939 : :
2940 [ # # ]: 0 : for (; item->type != RTE_FLOW_ITEM_TYPE_END; item++) {
2941 [ # # ]: 0 : if (item->last) {
2942 : 0 : rte_flow_error_set(error, EINVAL,
2943 : : RTE_FLOW_ERROR_TYPE_ITEM,
2944 : : item,
2945 : : "Not support range");
2946 : 0 : return -rte_errno;
2947 : : }
2948 : : item_type = item->type;
2949 [ # # # # : 0 : switch (item_type) {
# # # ]
2950 : 0 : case RTE_FLOW_ITEM_TYPE_ETH:
2951 : 0 : eth_spec = item->spec;
2952 : 0 : eth_mask = item->mask;
2953 : :
2954 : : /* Check if ETH item is used for place holder.
2955 : : * If yes, both spec and mask should be NULL.
2956 : : * If no, both spec and mask shouldn't be NULL.
2957 : : */
2958 [ # # ]: 0 : if ((!eth_spec && eth_mask) ||
2959 : : (eth_spec && !eth_mask)) {
2960 : 0 : rte_flow_error_set(error, EINVAL,
2961 : : RTE_FLOW_ERROR_TYPE_ITEM,
2962 : : item,
2963 : : "Invalid ether spec/mask");
2964 : 0 : return -rte_errno;
2965 : : }
2966 : :
2967 [ # # ]: 0 : if (eth_spec && eth_mask) {
2968 : : /* DST address of inner MAC shouldn't be masked.
2969 : : * SRC address of Inner MAC should be masked.
2970 : : */
2971 [ # # # # ]: 0 : if (!rte_is_broadcast_ether_addr(ð_mask->hdr.dst_addr) ||
2972 : 0 : !rte_is_zero_ether_addr(ð_mask->hdr.src_addr) ||
2973 [ # # ]: 0 : eth_mask->hdr.ether_type) {
2974 : 0 : rte_flow_error_set(error, EINVAL,
2975 : : RTE_FLOW_ERROR_TYPE_ITEM,
2976 : : item,
2977 : : "Invalid ether spec/mask");
2978 : 0 : return -rte_errno;
2979 : : }
2980 : :
2981 [ # # ]: 0 : if (!vxlan_flag) {
2982 : 0 : rte_memcpy(&filter->outer_mac,
2983 [ # # ]: 0 : ð_spec->hdr.dst_addr,
2984 : : RTE_ETHER_ADDR_LEN);
2985 : 0 : filter_type |= RTE_ETH_TUNNEL_FILTER_OMAC;
2986 : : } else {
2987 : 0 : rte_memcpy(&filter->inner_mac,
2988 [ # # ]: 0 : ð_spec->hdr.dst_addr,
2989 : : RTE_ETHER_ADDR_LEN);
2990 : 0 : filter_type |= RTE_ETH_TUNNEL_FILTER_IMAC;
2991 : : }
2992 : : }
2993 : : break;
2994 : 0 : case RTE_FLOW_ITEM_TYPE_VLAN:
2995 : 0 : vlan_spec = item->spec;
2996 : 0 : vlan_mask = item->mask;
2997 [ # # ]: 0 : if (!(vlan_spec && vlan_mask) ||
2998 [ # # ]: 0 : vlan_mask->hdr.eth_proto) {
2999 : 0 : rte_flow_error_set(error, EINVAL,
3000 : : RTE_FLOW_ERROR_TYPE_ITEM,
3001 : : item,
3002 : : "Invalid vlan item");
3003 : 0 : return -rte_errno;
3004 : : }
3005 : :
3006 : : if (vlan_spec && vlan_mask) {
3007 [ # # ]: 0 : if (vlan_mask->hdr.vlan_tci ==
3008 : : rte_cpu_to_be_16(I40E_VLAN_TCI_MASK))
3009 : 0 : filter->inner_vlan =
3010 [ # # ]: 0 : rte_be_to_cpu_16(vlan_spec->hdr.vlan_tci) &
3011 : : I40E_VLAN_TCI_MASK;
3012 : 0 : filter_type |= RTE_ETH_TUNNEL_FILTER_IVLAN;
3013 : : }
3014 : : break;
3015 : 0 : case RTE_FLOW_ITEM_TYPE_IPV4:
3016 : 0 : filter->ip_type = I40E_TUNNEL_IPTYPE_IPV4;
3017 : : /* IPv4 is used to describe protocol,
3018 : : * spec and mask should be NULL.
3019 : : */
3020 [ # # # # ]: 0 : if (item->spec || item->mask) {
3021 : 0 : rte_flow_error_set(error, EINVAL,
3022 : : RTE_FLOW_ERROR_TYPE_ITEM,
3023 : : item,
3024 : : "Invalid IPv4 item");
3025 : 0 : return -rte_errno;
3026 : : }
3027 : : break;
3028 : 0 : case RTE_FLOW_ITEM_TYPE_IPV6:
3029 : 0 : filter->ip_type = I40E_TUNNEL_IPTYPE_IPV6;
3030 : : /* IPv6 is used to describe protocol,
3031 : : * spec and mask should be NULL.
3032 : : */
3033 [ # # # # ]: 0 : if (item->spec || item->mask) {
3034 : 0 : rte_flow_error_set(error, EINVAL,
3035 : : RTE_FLOW_ERROR_TYPE_ITEM,
3036 : : item,
3037 : : "Invalid IPv6 item");
3038 : 0 : return -rte_errno;
3039 : : }
3040 : : break;
3041 : 0 : case RTE_FLOW_ITEM_TYPE_UDP:
3042 : : /* UDP is used to describe protocol,
3043 : : * spec and mask should be NULL.
3044 : : */
3045 [ # # # # ]: 0 : if (item->spec || item->mask) {
3046 : 0 : rte_flow_error_set(error, EINVAL,
3047 : : RTE_FLOW_ERROR_TYPE_ITEM,
3048 : : item,
3049 : : "Invalid UDP item");
3050 : 0 : return -rte_errno;
3051 : : }
3052 : : break;
3053 : 0 : case RTE_FLOW_ITEM_TYPE_VXLAN:
3054 : 0 : vxlan_spec = item->spec;
3055 : 0 : vxlan_mask = item->mask;
3056 : : /* Check if VXLAN item is used to describe protocol.
3057 : : * If yes, both spec and mask should be NULL.
3058 : : * If no, both spec and mask shouldn't be NULL.
3059 : : */
3060 [ # # ]: 0 : if ((!vxlan_spec && vxlan_mask) ||
3061 : : (vxlan_spec && !vxlan_mask)) {
3062 : 0 : rte_flow_error_set(error, EINVAL,
3063 : : RTE_FLOW_ERROR_TYPE_ITEM,
3064 : : item,
3065 : : "Invalid VXLAN item");
3066 : 0 : return -rte_errno;
3067 : : }
3068 : :
3069 : : /* Check if VNI is masked. */
3070 [ # # ]: 0 : if (vxlan_spec && vxlan_mask) {
3071 : : is_vni_masked =
3072 : 0 : !!memcmp(vxlan_mask->hdr.vni, vni_mask,
3073 : : RTE_DIM(vni_mask));
3074 [ # # ]: 0 : if (is_vni_masked) {
3075 : 0 : rte_flow_error_set(error, EINVAL,
3076 : : RTE_FLOW_ERROR_TYPE_ITEM,
3077 : : item,
3078 : : "Invalid VNI mask");
3079 : 0 : return -rte_errno;
3080 : : }
3081 : :
3082 : : rte_memcpy(((uint8_t *)&tenant_id_be + 1),
3083 : : vxlan_spec->hdr.vni, 3);
3084 : 0 : filter->tenant_id =
3085 [ # # ]: 0 : rte_be_to_cpu_32(tenant_id_be);
3086 : 0 : filter_type |= RTE_ETH_TUNNEL_FILTER_TENID;
3087 : : }
3088 : :
3089 : : vxlan_flag = 1;
3090 : : break;
3091 : : default:
3092 : : break;
3093 : : }
3094 : : }
3095 : :
3096 : : ret = i40e_check_tunnel_filter_type(filter_type);
3097 [ # # ]: 0 : if (ret < 0) {
3098 : 0 : rte_flow_error_set(error, EINVAL,
3099 : : RTE_FLOW_ERROR_TYPE_ITEM,
3100 : : NULL,
3101 : : "Invalid filter type");
3102 : 0 : return -rte_errno;
3103 : : }
3104 : 0 : filter->filter_type = filter_type;
3105 : :
3106 : 0 : filter->tunnel_type = I40E_TUNNEL_TYPE_VXLAN;
3107 : :
3108 : 0 : return 0;
3109 : : }
3110 : :
3111 : : static int
3112 : 0 : i40e_flow_parse_vxlan_filter(struct rte_eth_dev *dev,
3113 : : const struct rte_flow_attr *attr,
3114 : : const struct rte_flow_item pattern[],
3115 : : const struct rte_flow_action actions[],
3116 : : struct rte_flow_error *error,
3117 : : union i40e_filter_t *filter)
3118 : : {
3119 : 0 : struct i40e_tunnel_filter_conf *tunnel_filter =
3120 : : &filter->consistent_tunnel_filter;
3121 : : int ret;
3122 : :
3123 : 0 : ret = i40e_flow_parse_vxlan_pattern(dev, pattern,
3124 : : error, tunnel_filter);
3125 [ # # ]: 0 : if (ret)
3126 : : return ret;
3127 : :
3128 : 0 : ret = i40e_flow_parse_tunnel_action(dev, actions, error, tunnel_filter);
3129 [ # # ]: 0 : if (ret)
3130 : : return ret;
3131 : :
3132 : 0 : ret = i40e_flow_parse_attr(attr, error);
3133 [ # # ]: 0 : if (ret)
3134 : : return ret;
3135 : :
3136 : 0 : cons_filter_type = RTE_ETH_FILTER_TUNNEL;
3137 : :
3138 : 0 : return ret;
3139 : : }
3140 : :
3141 : : /* 1. Last in item should be NULL as range is not supported.
3142 : : * 2. Supported filter types: IMAC_IVLAN_TENID, IMAC_IVLAN,
3143 : : * IMAC_TENID, OMAC_TENID_IMAC and IMAC.
3144 : : * 3. Mask of fields which need to be matched should be
3145 : : * filled with 1.
3146 : : * 4. Mask of fields which needn't to be matched should be
3147 : : * filled with 0.
3148 : : */
3149 : : static int
3150 : 0 : i40e_flow_parse_nvgre_pattern(__rte_unused struct rte_eth_dev *dev,
3151 : : const struct rte_flow_item *pattern,
3152 : : struct rte_flow_error *error,
3153 : : struct i40e_tunnel_filter_conf *filter)
3154 : : {
3155 : : const struct rte_flow_item *item = pattern;
3156 : : const struct rte_flow_item_eth *eth_spec;
3157 : : const struct rte_flow_item_eth *eth_mask;
3158 : : const struct rte_flow_item_nvgre *nvgre_spec;
3159 : : const struct rte_flow_item_nvgre *nvgre_mask;
3160 : : const struct rte_flow_item_vlan *vlan_spec;
3161 : : const struct rte_flow_item_vlan *vlan_mask;
3162 : : enum rte_flow_item_type item_type;
3163 : : uint8_t filter_type = 0;
3164 : : bool is_tni_masked = 0;
3165 : 0 : uint8_t tni_mask[] = {0xFF, 0xFF, 0xFF};
3166 : : bool nvgre_flag = 0;
3167 : 0 : uint32_t tenant_id_be = 0;
3168 : : int ret;
3169 : :
3170 [ # # ]: 0 : for (; item->type != RTE_FLOW_ITEM_TYPE_END; item++) {
3171 [ # # ]: 0 : if (item->last) {
3172 : 0 : rte_flow_error_set(error, EINVAL,
3173 : : RTE_FLOW_ERROR_TYPE_ITEM,
3174 : : item,
3175 : : "Not support range");
3176 : 0 : return -rte_errno;
3177 : : }
3178 : : item_type = item->type;
3179 [ # # # # : 0 : switch (item_type) {
# # ]
3180 : 0 : case RTE_FLOW_ITEM_TYPE_ETH:
3181 : 0 : eth_spec = item->spec;
3182 : 0 : eth_mask = item->mask;
3183 : :
3184 : : /* Check if ETH item is used for place holder.
3185 : : * If yes, both spec and mask should be NULL.
3186 : : * If no, both spec and mask shouldn't be NULL.
3187 : : */
3188 [ # # ]: 0 : if ((!eth_spec && eth_mask) ||
3189 : : (eth_spec && !eth_mask)) {
3190 : 0 : rte_flow_error_set(error, EINVAL,
3191 : : RTE_FLOW_ERROR_TYPE_ITEM,
3192 : : item,
3193 : : "Invalid ether spec/mask");
3194 : 0 : return -rte_errno;
3195 : : }
3196 : :
3197 [ # # ]: 0 : if (eth_spec && eth_mask) {
3198 : : /* DST address of inner MAC shouldn't be masked.
3199 : : * SRC address of Inner MAC should be masked.
3200 : : */
3201 [ # # # # ]: 0 : if (!rte_is_broadcast_ether_addr(ð_mask->hdr.dst_addr) ||
3202 : 0 : !rte_is_zero_ether_addr(ð_mask->hdr.src_addr) ||
3203 [ # # ]: 0 : eth_mask->hdr.ether_type) {
3204 : 0 : rte_flow_error_set(error, EINVAL,
3205 : : RTE_FLOW_ERROR_TYPE_ITEM,
3206 : : item,
3207 : : "Invalid ether spec/mask");
3208 : 0 : return -rte_errno;
3209 : : }
3210 : :
3211 [ # # ]: 0 : if (!nvgre_flag) {
3212 : 0 : rte_memcpy(&filter->outer_mac,
3213 [ # # ]: 0 : ð_spec->hdr.dst_addr,
3214 : : RTE_ETHER_ADDR_LEN);
3215 : 0 : filter_type |= RTE_ETH_TUNNEL_FILTER_OMAC;
3216 : : } else {
3217 : 0 : rte_memcpy(&filter->inner_mac,
3218 [ # # ]: 0 : ð_spec->hdr.dst_addr,
3219 : : RTE_ETHER_ADDR_LEN);
3220 : 0 : filter_type |= RTE_ETH_TUNNEL_FILTER_IMAC;
3221 : : }
3222 : : }
3223 : :
3224 : : break;
3225 : 0 : case RTE_FLOW_ITEM_TYPE_VLAN:
3226 : 0 : vlan_spec = item->spec;
3227 : 0 : vlan_mask = item->mask;
3228 [ # # ]: 0 : if (!(vlan_spec && vlan_mask) ||
3229 [ # # ]: 0 : vlan_mask->hdr.eth_proto) {
3230 : 0 : rte_flow_error_set(error, EINVAL,
3231 : : RTE_FLOW_ERROR_TYPE_ITEM,
3232 : : item,
3233 : : "Invalid vlan item");
3234 : 0 : return -rte_errno;
3235 : : }
3236 : :
3237 : : if (vlan_spec && vlan_mask) {
3238 [ # # ]: 0 : if (vlan_mask->hdr.vlan_tci ==
3239 : : rte_cpu_to_be_16(I40E_VLAN_TCI_MASK))
3240 : 0 : filter->inner_vlan =
3241 [ # # ]: 0 : rte_be_to_cpu_16(vlan_spec->hdr.vlan_tci) &
3242 : : I40E_VLAN_TCI_MASK;
3243 : 0 : filter_type |= RTE_ETH_TUNNEL_FILTER_IVLAN;
3244 : : }
3245 : : break;
3246 : 0 : case RTE_FLOW_ITEM_TYPE_IPV4:
3247 : 0 : filter->ip_type = I40E_TUNNEL_IPTYPE_IPV4;
3248 : : /* IPv4 is used to describe protocol,
3249 : : * spec and mask should be NULL.
3250 : : */
3251 [ # # # # ]: 0 : if (item->spec || item->mask) {
3252 : 0 : rte_flow_error_set(error, EINVAL,
3253 : : RTE_FLOW_ERROR_TYPE_ITEM,
3254 : : item,
3255 : : "Invalid IPv4 item");
3256 : 0 : return -rte_errno;
3257 : : }
3258 : : break;
3259 : 0 : case RTE_FLOW_ITEM_TYPE_IPV6:
3260 : 0 : filter->ip_type = I40E_TUNNEL_IPTYPE_IPV6;
3261 : : /* IPv6 is used to describe protocol,
3262 : : * spec and mask should be NULL.
3263 : : */
3264 [ # # # # ]: 0 : if (item->spec || item->mask) {
3265 : 0 : rte_flow_error_set(error, EINVAL,
3266 : : RTE_FLOW_ERROR_TYPE_ITEM,
3267 : : item,
3268 : : "Invalid IPv6 item");
3269 : 0 : return -rte_errno;
3270 : : }
3271 : : break;
3272 : 0 : case RTE_FLOW_ITEM_TYPE_NVGRE:
3273 : 0 : nvgre_spec = item->spec;
3274 : 0 : nvgre_mask = item->mask;
3275 : : /* Check if NVGRE item is used to describe protocol.
3276 : : * If yes, both spec and mask should be NULL.
3277 : : * If no, both spec and mask shouldn't be NULL.
3278 : : */
3279 [ # # ]: 0 : if ((!nvgre_spec && nvgre_mask) ||
3280 : : (nvgre_spec && !nvgre_mask)) {
3281 : 0 : rte_flow_error_set(error, EINVAL,
3282 : : RTE_FLOW_ERROR_TYPE_ITEM,
3283 : : item,
3284 : : "Invalid NVGRE item");
3285 : 0 : return -rte_errno;
3286 : : }
3287 : :
3288 [ # # ]: 0 : if (nvgre_spec && nvgre_mask) {
3289 : : is_tni_masked =
3290 : 0 : !!memcmp(nvgre_mask->tni, tni_mask,
3291 : : RTE_DIM(tni_mask));
3292 [ # # ]: 0 : if (is_tni_masked) {
3293 : 0 : rte_flow_error_set(error, EINVAL,
3294 : : RTE_FLOW_ERROR_TYPE_ITEM,
3295 : : item,
3296 : : "Invalid TNI mask");
3297 : 0 : return -rte_errno;
3298 : : }
3299 [ # # ]: 0 : if (nvgre_mask->protocol &&
3300 : : nvgre_mask->protocol != 0xFFFF) {
3301 : 0 : rte_flow_error_set(error, EINVAL,
3302 : : RTE_FLOW_ERROR_TYPE_ITEM,
3303 : : item,
3304 : : "Invalid NVGRE item");
3305 : 0 : return -rte_errno;
3306 : : }
3307 [ # # # # ]: 0 : if (nvgre_mask->c_k_s_rsvd0_ver &&
3308 : : nvgre_mask->c_k_s_rsvd0_ver !=
3309 : : rte_cpu_to_be_16(0xFFFF)) {
3310 : 0 : rte_flow_error_set(error, EINVAL,
3311 : : RTE_FLOW_ERROR_TYPE_ITEM,
3312 : : item,
3313 : : "Invalid NVGRE item");
3314 : 0 : return -rte_errno;
3315 : : }
3316 [ # # ]: 0 : if (nvgre_spec->c_k_s_rsvd0_ver !=
3317 [ # # ]: 0 : rte_cpu_to_be_16(0x2000) &&
3318 : : nvgre_mask->c_k_s_rsvd0_ver) {
3319 : 0 : rte_flow_error_set(error, EINVAL,
3320 : : RTE_FLOW_ERROR_TYPE_ITEM,
3321 : : item,
3322 : : "Invalid NVGRE item");
3323 : 0 : return -rte_errno;
3324 : : }
3325 [ # # ]: 0 : if (nvgre_mask->protocol &&
3326 [ # # ]: 0 : nvgre_spec->protocol !=
3327 : : rte_cpu_to_be_16(0x6558)) {
3328 : 0 : rte_flow_error_set(error, EINVAL,
3329 : : RTE_FLOW_ERROR_TYPE_ITEM,
3330 : : item,
3331 : : "Invalid NVGRE item");
3332 : 0 : return -rte_errno;
3333 : : }
3334 : : rte_memcpy(((uint8_t *)&tenant_id_be + 1),
3335 : : nvgre_spec->tni, 3);
3336 : 0 : filter->tenant_id =
3337 [ # # ]: 0 : rte_be_to_cpu_32(tenant_id_be);
3338 : 0 : filter_type |= RTE_ETH_TUNNEL_FILTER_TENID;
3339 : : }
3340 : :
3341 : : nvgre_flag = 1;
3342 : : break;
3343 : : default:
3344 : : break;
3345 : : }
3346 : : }
3347 : :
3348 : : ret = i40e_check_tunnel_filter_type(filter_type);
3349 [ # # ]: 0 : if (ret < 0) {
3350 : 0 : rte_flow_error_set(error, EINVAL,
3351 : : RTE_FLOW_ERROR_TYPE_ITEM,
3352 : : NULL,
3353 : : "Invalid filter type");
3354 : 0 : return -rte_errno;
3355 : : }
3356 : 0 : filter->filter_type = filter_type;
3357 : :
3358 : 0 : filter->tunnel_type = I40E_TUNNEL_TYPE_NVGRE;
3359 : :
3360 : 0 : return 0;
3361 : : }
3362 : :
3363 : : static int
3364 : 0 : i40e_flow_parse_nvgre_filter(struct rte_eth_dev *dev,
3365 : : const struct rte_flow_attr *attr,
3366 : : const struct rte_flow_item pattern[],
3367 : : const struct rte_flow_action actions[],
3368 : : struct rte_flow_error *error,
3369 : : union i40e_filter_t *filter)
3370 : : {
3371 : 0 : struct i40e_tunnel_filter_conf *tunnel_filter =
3372 : : &filter->consistent_tunnel_filter;
3373 : : int ret;
3374 : :
3375 : 0 : ret = i40e_flow_parse_nvgre_pattern(dev, pattern,
3376 : : error, tunnel_filter);
3377 [ # # ]: 0 : if (ret)
3378 : : return ret;
3379 : :
3380 : 0 : ret = i40e_flow_parse_tunnel_action(dev, actions, error, tunnel_filter);
3381 [ # # ]: 0 : if (ret)
3382 : : return ret;
3383 : :
3384 : 0 : ret = i40e_flow_parse_attr(attr, error);
3385 [ # # ]: 0 : if (ret)
3386 : : return ret;
3387 : :
3388 : 0 : cons_filter_type = RTE_ETH_FILTER_TUNNEL;
3389 : :
3390 : 0 : return ret;
3391 : : }
3392 : :
3393 : : /* 1. Last in item should be NULL as range is not supported.
3394 : : * 2. Supported filter types: MPLS label.
3395 : : * 3. Mask of fields which need to be matched should be
3396 : : * filled with 1.
3397 : : * 4. Mask of fields which needn't to be matched should be
3398 : : * filled with 0.
3399 : : */
3400 : : static int
3401 : 0 : i40e_flow_parse_mpls_pattern(__rte_unused struct rte_eth_dev *dev,
3402 : : const struct rte_flow_item *pattern,
3403 : : struct rte_flow_error *error,
3404 : : struct i40e_tunnel_filter_conf *filter)
3405 : : {
3406 : : const struct rte_flow_item *item = pattern;
3407 : : const struct rte_flow_item_mpls *mpls_spec;
3408 : : const struct rte_flow_item_mpls *mpls_mask;
3409 : : enum rte_flow_item_type item_type;
3410 : : bool is_mplsoudp = 0; /* 1 - MPLSoUDP, 0 - MPLSoGRE */
3411 : 0 : const uint8_t label_mask[3] = {0xFF, 0xFF, 0xF0};
3412 : 0 : uint32_t label_be = 0;
3413 : :
3414 [ # # ]: 0 : for (; item->type != RTE_FLOW_ITEM_TYPE_END; item++) {
3415 [ # # ]: 0 : if (item->last) {
3416 : 0 : rte_flow_error_set(error, EINVAL,
3417 : : RTE_FLOW_ERROR_TYPE_ITEM,
3418 : : item,
3419 : : "Not support range");
3420 : 0 : return -rte_errno;
3421 : : }
3422 : : item_type = item->type;
3423 [ # # # # : 0 : switch (item_type) {
# # # ]
3424 : 0 : case RTE_FLOW_ITEM_TYPE_ETH:
3425 [ # # # # ]: 0 : if (item->spec || item->mask) {
3426 : 0 : rte_flow_error_set(error, EINVAL,
3427 : : RTE_FLOW_ERROR_TYPE_ITEM,
3428 : : item,
3429 : : "Invalid ETH item");
3430 : 0 : return -rte_errno;
3431 : : }
3432 : : break;
3433 : 0 : case RTE_FLOW_ITEM_TYPE_IPV4:
3434 : 0 : filter->ip_type = I40E_TUNNEL_IPTYPE_IPV4;
3435 : : /* IPv4 is used to describe protocol,
3436 : : * spec and mask should be NULL.
3437 : : */
3438 [ # # # # ]: 0 : if (item->spec || item->mask) {
3439 : 0 : rte_flow_error_set(error, EINVAL,
3440 : : RTE_FLOW_ERROR_TYPE_ITEM,
3441 : : item,
3442 : : "Invalid IPv4 item");
3443 : 0 : return -rte_errno;
3444 : : }
3445 : : break;
3446 : 0 : case RTE_FLOW_ITEM_TYPE_IPV6:
3447 : 0 : filter->ip_type = I40E_TUNNEL_IPTYPE_IPV6;
3448 : : /* IPv6 is used to describe protocol,
3449 : : * spec and mask should be NULL.
3450 : : */
3451 [ # # # # ]: 0 : if (item->spec || item->mask) {
3452 : 0 : rte_flow_error_set(error, EINVAL,
3453 : : RTE_FLOW_ERROR_TYPE_ITEM,
3454 : : item,
3455 : : "Invalid IPv6 item");
3456 : 0 : return -rte_errno;
3457 : : }
3458 : : break;
3459 : 0 : case RTE_FLOW_ITEM_TYPE_UDP:
3460 : : /* UDP is used to describe protocol,
3461 : : * spec and mask should be NULL.
3462 : : */
3463 [ # # # # ]: 0 : if (item->spec || item->mask) {
3464 : 0 : rte_flow_error_set(error, EINVAL,
3465 : : RTE_FLOW_ERROR_TYPE_ITEM,
3466 : : item,
3467 : : "Invalid UDP item");
3468 : 0 : return -rte_errno;
3469 : : }
3470 : : is_mplsoudp = 1;
3471 : : break;
3472 : 0 : case RTE_FLOW_ITEM_TYPE_GRE:
3473 : : /* GRE is used to describe protocol,
3474 : : * spec and mask should be NULL.
3475 : : */
3476 [ # # # # ]: 0 : if (item->spec || item->mask) {
3477 : 0 : rte_flow_error_set(error, EINVAL,
3478 : : RTE_FLOW_ERROR_TYPE_ITEM,
3479 : : item,
3480 : : "Invalid GRE item");
3481 : 0 : return -rte_errno;
3482 : : }
3483 : : break;
3484 : 0 : case RTE_FLOW_ITEM_TYPE_MPLS:
3485 : 0 : mpls_spec = item->spec;
3486 : 0 : mpls_mask = item->mask;
3487 : :
3488 [ # # ]: 0 : if (!mpls_spec || !mpls_mask) {
3489 : 0 : rte_flow_error_set(error, EINVAL,
3490 : : RTE_FLOW_ERROR_TYPE_ITEM,
3491 : : item,
3492 : : "Invalid MPLS item");
3493 : 0 : return -rte_errno;
3494 : : }
3495 : :
3496 [ # # ]: 0 : if (memcmp(mpls_mask->label_tc_s, label_mask, 3)) {
3497 : 0 : rte_flow_error_set(error, EINVAL,
3498 : : RTE_FLOW_ERROR_TYPE_ITEM,
3499 : : item,
3500 : : "Invalid MPLS label mask");
3501 : 0 : return -rte_errno;
3502 : : }
3503 : : rte_memcpy(((uint8_t *)&label_be + 1),
3504 : : mpls_spec->label_tc_s, 3);
3505 [ # # ]: 0 : filter->tenant_id = rte_be_to_cpu_32(label_be) >> 4;
3506 : 0 : break;
3507 : : default:
3508 : : break;
3509 : : }
3510 : : }
3511 : :
3512 [ # # ]: 0 : if (is_mplsoudp)
3513 : 0 : filter->tunnel_type = I40E_TUNNEL_TYPE_MPLSoUDP;
3514 : : else
3515 : 0 : filter->tunnel_type = I40E_TUNNEL_TYPE_MPLSoGRE;
3516 : :
3517 : : return 0;
3518 : : }
3519 : :
3520 : : static int
3521 : 0 : i40e_flow_parse_mpls_filter(struct rte_eth_dev *dev,
3522 : : const struct rte_flow_attr *attr,
3523 : : const struct rte_flow_item pattern[],
3524 : : const struct rte_flow_action actions[],
3525 : : struct rte_flow_error *error,
3526 : : union i40e_filter_t *filter)
3527 : : {
3528 : 0 : struct i40e_tunnel_filter_conf *tunnel_filter =
3529 : : &filter->consistent_tunnel_filter;
3530 : : int ret;
3531 : :
3532 : 0 : ret = i40e_flow_parse_mpls_pattern(dev, pattern,
3533 : : error, tunnel_filter);
3534 [ # # ]: 0 : if (ret)
3535 : : return ret;
3536 : :
3537 : 0 : ret = i40e_flow_parse_tunnel_action(dev, actions, error, tunnel_filter);
3538 [ # # ]: 0 : if (ret)
3539 : : return ret;
3540 : :
3541 : 0 : ret = i40e_flow_parse_attr(attr, error);
3542 [ # # ]: 0 : if (ret)
3543 : : return ret;
3544 : :
3545 : 0 : cons_filter_type = RTE_ETH_FILTER_TUNNEL;
3546 : :
3547 : 0 : return ret;
3548 : : }
3549 : :
3550 : : /* 1. Last in item should be NULL as range is not supported.
3551 : : * 2. Supported filter types: GTP TEID.
3552 : : * 3. Mask of fields which need to be matched should be
3553 : : * filled with 1.
3554 : : * 4. Mask of fields which needn't to be matched should be
3555 : : * filled with 0.
3556 : : * 5. GTP profile supports GTPv1 only.
3557 : : * 6. GTP-C response message ('source_port' = 2123) is not supported.
3558 : : */
3559 : : static int
3560 : 0 : i40e_flow_parse_gtp_pattern(struct rte_eth_dev *dev,
3561 : : const struct rte_flow_item *pattern,
3562 : : struct rte_flow_error *error,
3563 : : struct i40e_tunnel_filter_conf *filter)
3564 : : {
3565 : 0 : struct i40e_pf *pf = I40E_DEV_PRIVATE_TO_PF(dev->data->dev_private);
3566 : : const struct rte_flow_item *item = pattern;
3567 : : const struct rte_flow_item_gtp *gtp_spec;
3568 : : const struct rte_flow_item_gtp *gtp_mask;
3569 : : enum rte_flow_item_type item_type;
3570 : :
3571 [ # # ]: 0 : if (!pf->gtp_support) {
3572 : 0 : rte_flow_error_set(error, EINVAL,
3573 : : RTE_FLOW_ERROR_TYPE_ITEM,
3574 : : item,
3575 : : "GTP is not supported by default.");
3576 : 0 : return -rte_errno;
3577 : : }
3578 : :
3579 [ # # ]: 0 : for (; item->type != RTE_FLOW_ITEM_TYPE_END; item++) {
3580 [ # # ]: 0 : if (item->last) {
3581 : 0 : rte_flow_error_set(error, EINVAL,
3582 : : RTE_FLOW_ERROR_TYPE_ITEM,
3583 : : item,
3584 : : "Not support range");
3585 : 0 : return -rte_errno;
3586 : : }
3587 : : item_type = item->type;
3588 [ # # # # : 0 : switch (item_type) {
# ]
3589 : 0 : case RTE_FLOW_ITEM_TYPE_ETH:
3590 [ # # # # ]: 0 : if (item->spec || item->mask) {
3591 : 0 : rte_flow_error_set(error, EINVAL,
3592 : : RTE_FLOW_ERROR_TYPE_ITEM,
3593 : : item,
3594 : : "Invalid ETH item");
3595 : 0 : return -rte_errno;
3596 : : }
3597 : : break;
3598 : 0 : case RTE_FLOW_ITEM_TYPE_IPV4:
3599 : 0 : filter->ip_type = I40E_TUNNEL_IPTYPE_IPV4;
3600 : : /* IPv4 is used to describe protocol,
3601 : : * spec and mask should be NULL.
3602 : : */
3603 [ # # # # ]: 0 : if (item->spec || item->mask) {
3604 : 0 : rte_flow_error_set(error, EINVAL,
3605 : : RTE_FLOW_ERROR_TYPE_ITEM,
3606 : : item,
3607 : : "Invalid IPv4 item");
3608 : 0 : return -rte_errno;
3609 : : }
3610 : : break;
3611 : 0 : case RTE_FLOW_ITEM_TYPE_UDP:
3612 [ # # # # ]: 0 : if (item->spec || item->mask) {
3613 : 0 : rte_flow_error_set(error, EINVAL,
3614 : : RTE_FLOW_ERROR_TYPE_ITEM,
3615 : : item,
3616 : : "Invalid UDP item");
3617 : 0 : return -rte_errno;
3618 : : }
3619 : : break;
3620 : 0 : case RTE_FLOW_ITEM_TYPE_GTPC:
3621 : : case RTE_FLOW_ITEM_TYPE_GTPU:
3622 : 0 : gtp_spec = item->spec;
3623 : 0 : gtp_mask = item->mask;
3624 : :
3625 [ # # ]: 0 : if (!gtp_spec || !gtp_mask) {
3626 : 0 : rte_flow_error_set(error, EINVAL,
3627 : : RTE_FLOW_ERROR_TYPE_ITEM,
3628 : : item,
3629 : : "Invalid GTP item");
3630 : 0 : return -rte_errno;
3631 : : }
3632 : :
3633 : 0 : if (gtp_mask->hdr.gtp_hdr_info ||
3634 [ # # ]: 0 : gtp_mask->hdr.msg_type ||
3635 : 0 : gtp_mask->hdr.plen ||
3636 [ # # ]: 0 : gtp_mask->hdr.teid != UINT32_MAX) {
3637 : 0 : rte_flow_error_set(error, EINVAL,
3638 : : RTE_FLOW_ERROR_TYPE_ITEM,
3639 : : item,
3640 : : "Invalid GTP mask");
3641 : 0 : return -rte_errno;
3642 : : }
3643 : :
3644 [ # # ]: 0 : if (item_type == RTE_FLOW_ITEM_TYPE_GTPC)
3645 : 0 : filter->tunnel_type = I40E_TUNNEL_TYPE_GTPC;
3646 : : else if (item_type == RTE_FLOW_ITEM_TYPE_GTPU)
3647 : 0 : filter->tunnel_type = I40E_TUNNEL_TYPE_GTPU;
3648 : :
3649 [ # # ]: 0 : filter->tenant_id = rte_be_to_cpu_32(gtp_spec->hdr.teid);
3650 : :
3651 : 0 : break;
3652 : : default:
3653 : : break;
3654 : : }
3655 : : }
3656 : :
3657 : : return 0;
3658 : : }
3659 : :
3660 : : static int
3661 : 0 : i40e_flow_parse_gtp_filter(struct rte_eth_dev *dev,
3662 : : const struct rte_flow_attr *attr,
3663 : : const struct rte_flow_item pattern[],
3664 : : const struct rte_flow_action actions[],
3665 : : struct rte_flow_error *error,
3666 : : union i40e_filter_t *filter)
3667 : : {
3668 : 0 : struct i40e_tunnel_filter_conf *tunnel_filter =
3669 : : &filter->consistent_tunnel_filter;
3670 : : int ret;
3671 : :
3672 : 0 : ret = i40e_flow_parse_gtp_pattern(dev, pattern,
3673 : : error, tunnel_filter);
3674 [ # # ]: 0 : if (ret)
3675 : : return ret;
3676 : :
3677 : 0 : ret = i40e_flow_parse_tunnel_action(dev, actions, error, tunnel_filter);
3678 [ # # ]: 0 : if (ret)
3679 : : return ret;
3680 : :
3681 : 0 : ret = i40e_flow_parse_attr(attr, error);
3682 [ # # ]: 0 : if (ret)
3683 : : return ret;
3684 : :
3685 : 0 : cons_filter_type = RTE_ETH_FILTER_TUNNEL;
3686 : :
3687 : 0 : return ret;
3688 : : }
3689 : :
3690 : : /* 1. Last in item should be NULL as range is not supported.
3691 : : * 2. Supported filter types: QINQ.
3692 : : * 3. Mask of fields which need to be matched should be
3693 : : * filled with 1.
3694 : : * 4. Mask of fields which needn't to be matched should be
3695 : : * filled with 0.
3696 : : */
3697 : : static int
3698 : 0 : i40e_flow_parse_qinq_pattern(__rte_unused struct rte_eth_dev *dev,
3699 : : const struct rte_flow_item *pattern,
3700 : : struct rte_flow_error *error,
3701 : : struct i40e_tunnel_filter_conf *filter)
3702 : : {
3703 : : const struct rte_flow_item *item = pattern;
3704 : : const struct rte_flow_item_vlan *vlan_spec = NULL;
3705 : : const struct rte_flow_item_vlan *vlan_mask = NULL;
3706 : : const struct rte_flow_item_vlan *i_vlan_spec = NULL;
3707 : : const struct rte_flow_item_vlan *i_vlan_mask = NULL;
3708 : : const struct rte_flow_item_vlan *o_vlan_spec = NULL;
3709 : : const struct rte_flow_item_vlan *o_vlan_mask = NULL;
3710 : :
3711 : : enum rte_flow_item_type item_type;
3712 : : bool vlan_flag = 0;
3713 : :
3714 [ # # ]: 0 : for (; item->type != RTE_FLOW_ITEM_TYPE_END; item++) {
3715 [ # # ]: 0 : if (item->last) {
3716 : 0 : rte_flow_error_set(error, EINVAL,
3717 : : RTE_FLOW_ERROR_TYPE_ITEM,
3718 : : item,
3719 : : "Not support range");
3720 : 0 : return -rte_errno;
3721 : : }
3722 : : item_type = item->type;
3723 [ # # # ]: 0 : switch (item_type) {
3724 : 0 : case RTE_FLOW_ITEM_TYPE_ETH:
3725 [ # # # # ]: 0 : if (item->spec || item->mask) {
3726 : 0 : rte_flow_error_set(error, EINVAL,
3727 : : RTE_FLOW_ERROR_TYPE_ITEM,
3728 : : item,
3729 : : "Invalid ETH item");
3730 : 0 : return -rte_errno;
3731 : : }
3732 : : break;
3733 : 0 : case RTE_FLOW_ITEM_TYPE_VLAN:
3734 : 0 : vlan_spec = item->spec;
3735 : 0 : vlan_mask = item->mask;
3736 : :
3737 [ # # ]: 0 : if (!(vlan_spec && vlan_mask) ||
3738 [ # # ]: 0 : vlan_mask->hdr.eth_proto) {
3739 : 0 : rte_flow_error_set(error, EINVAL,
3740 : : RTE_FLOW_ERROR_TYPE_ITEM,
3741 : : item,
3742 : : "Invalid vlan item");
3743 : 0 : return -rte_errno;
3744 : : }
3745 : :
3746 [ # # ]: 0 : if (!vlan_flag) {
3747 : : o_vlan_spec = vlan_spec;
3748 : : o_vlan_mask = vlan_mask;
3749 : : vlan_flag = 1;
3750 : : } else {
3751 : : i_vlan_spec = vlan_spec;
3752 : : i_vlan_mask = vlan_mask;
3753 : : vlan_flag = 0;
3754 : : }
3755 : : break;
3756 : :
3757 : : default:
3758 : : break;
3759 : : }
3760 : : }
3761 : :
3762 : : /* Get filter specification */
3763 [ # # ]: 0 : if (o_vlan_mask != NULL && i_vlan_mask != NULL) {
3764 [ # # ]: 0 : filter->outer_vlan = rte_be_to_cpu_16(o_vlan_spec->hdr.vlan_tci);
3765 [ # # ]: 0 : filter->inner_vlan = rte_be_to_cpu_16(i_vlan_spec->hdr.vlan_tci);
3766 : : } else {
3767 : 0 : rte_flow_error_set(error, EINVAL,
3768 : : RTE_FLOW_ERROR_TYPE_ITEM,
3769 : : NULL,
3770 : : "Invalid filter type");
3771 : 0 : return -rte_errno;
3772 : : }
3773 : :
3774 : 0 : filter->tunnel_type = I40E_TUNNEL_TYPE_QINQ;
3775 : 0 : return 0;
3776 : : }
3777 : :
3778 : : static int
3779 : 0 : i40e_flow_parse_qinq_filter(struct rte_eth_dev *dev,
3780 : : const struct rte_flow_attr *attr,
3781 : : const struct rte_flow_item pattern[],
3782 : : const struct rte_flow_action actions[],
3783 : : struct rte_flow_error *error,
3784 : : union i40e_filter_t *filter)
3785 : : {
3786 : 0 : struct i40e_tunnel_filter_conf *tunnel_filter =
3787 : : &filter->consistent_tunnel_filter;
3788 : : int ret;
3789 : :
3790 : 0 : ret = i40e_flow_parse_qinq_pattern(dev, pattern,
3791 : : error, tunnel_filter);
3792 [ # # ]: 0 : if (ret)
3793 : : return ret;
3794 : :
3795 : 0 : ret = i40e_flow_parse_tunnel_action(dev, actions, error, tunnel_filter);
3796 [ # # ]: 0 : if (ret)
3797 : : return ret;
3798 : :
3799 : 0 : ret = i40e_flow_parse_attr(attr, error);
3800 [ # # ]: 0 : if (ret)
3801 : : return ret;
3802 : :
3803 : 0 : cons_filter_type = RTE_ETH_FILTER_TUNNEL;
3804 : :
3805 : 0 : return ret;
3806 : : }
3807 : :
3808 : : static int
3809 : 0 : i40e_flow_validate(struct rte_eth_dev *dev,
3810 : : const struct rte_flow_attr *attr,
3811 : : const struct rte_flow_item pattern[],
3812 : : const struct rte_flow_action actions[],
3813 : : struct rte_flow_error *error)
3814 : : {
3815 : : struct rte_flow_item *items; /* internal pattern w/o VOID items */
3816 : : parse_filter_t parse_filter;
3817 : : uint32_t item_num = 0; /* non-void item number of pattern*/
3818 : 0 : uint32_t i = 0;
3819 : : bool flag = false;
3820 : : int ret = I40E_NOT_SUPPORTED;
3821 : :
3822 [ # # ]: 0 : if (!pattern) {
3823 : 0 : rte_flow_error_set(error, EINVAL, RTE_FLOW_ERROR_TYPE_ITEM_NUM,
3824 : : NULL, "NULL pattern.");
3825 : 0 : return -rte_errno;
3826 : : }
3827 : :
3828 [ # # ]: 0 : if (!actions) {
3829 : 0 : rte_flow_error_set(error, EINVAL,
3830 : : RTE_FLOW_ERROR_TYPE_ACTION_NUM,
3831 : : NULL, "NULL action.");
3832 : 0 : return -rte_errno;
3833 : : }
3834 : :
3835 [ # # ]: 0 : if (!attr) {
3836 : 0 : rte_flow_error_set(error, EINVAL,
3837 : : RTE_FLOW_ERROR_TYPE_ATTR,
3838 : : NULL, "NULL attribute.");
3839 : 0 : return -rte_errno;
3840 : : }
3841 : : memset(&cons_filter, 0, sizeof(cons_filter));
3842 : :
3843 : : /* Get the non-void item of action */
3844 [ # # ]: 0 : while ((actions + i)->type == RTE_FLOW_ACTION_TYPE_VOID)
3845 : 0 : i++;
3846 : :
3847 [ # # ]: 0 : if ((actions + i)->type == RTE_FLOW_ACTION_TYPE_RSS) {
3848 : 0 : ret = i40e_flow_parse_attr(attr, error);
3849 [ # # ]: 0 : if (ret)
3850 : : return ret;
3851 : :
3852 : 0 : cons_filter_type = RTE_ETH_FILTER_HASH;
3853 : 0 : return i40e_hash_parse(dev, pattern, actions + i,
3854 : : &cons_filter.rss_conf, error);
3855 : : }
3856 : :
3857 : 0 : i = 0;
3858 : : /* Get the non-void item number of pattern */
3859 [ # # ]: 0 : while ((pattern + i)->type != RTE_FLOW_ITEM_TYPE_END) {
3860 [ # # ]: 0 : if ((pattern + i)->type != RTE_FLOW_ITEM_TYPE_VOID)
3861 : 0 : item_num++;
3862 : 0 : i++;
3863 : : }
3864 : 0 : item_num++;
3865 : :
3866 [ # # ]: 0 : if (item_num <= ARRAY_SIZE(g_items)) {
3867 : : items = g_items;
3868 : : } else {
3869 : 0 : items = rte_zmalloc("i40e_pattern",
3870 : : item_num * sizeof(struct rte_flow_item), 0);
3871 [ # # ]: 0 : if (!items) {
3872 : 0 : rte_flow_error_set(error, ENOMEM,
3873 : : RTE_FLOW_ERROR_TYPE_ITEM_NUM,
3874 : : NULL,
3875 : : "No memory for PMD internal items.");
3876 : 0 : return -ENOMEM;
3877 : : }
3878 : : }
3879 : :
3880 : 0 : i40e_pattern_skip_void_item(items, pattern);
3881 : :
3882 : 0 : i = 0;
3883 : : do {
3884 : 0 : parse_filter = i40e_find_parse_filter_func(items, &i);
3885 [ # # ]: 0 : if (!parse_filter && !flag) {
3886 : 0 : rte_flow_error_set(error, EINVAL,
3887 : : RTE_FLOW_ERROR_TYPE_ITEM,
3888 : : pattern, "Unsupported pattern");
3889 : :
3890 [ # # ]: 0 : if (items != g_items)
3891 : 0 : rte_free(items);
3892 : 0 : return -rte_errno;
3893 : : }
3894 : :
3895 [ # # ]: 0 : if (parse_filter)
3896 : 0 : ret = parse_filter(dev, attr, items, actions,
3897 : : error, &cons_filter);
3898 : :
3899 : : flag = true;
3900 [ # # # # ]: 0 : } while ((ret < 0) && (i < RTE_DIM(i40e_supported_patterns)));
3901 : :
3902 [ # # ]: 0 : if (items != g_items)
3903 : 0 : rte_free(items);
3904 : :
3905 : : return ret;
3906 : : }
3907 : :
3908 : : static struct rte_flow *
3909 : 0 : i40e_flow_create(struct rte_eth_dev *dev,
3910 : : const struct rte_flow_attr *attr,
3911 : : const struct rte_flow_item pattern[],
3912 : : const struct rte_flow_action actions[],
3913 : : struct rte_flow_error *error)
3914 : : {
3915 : 0 : struct i40e_pf *pf = I40E_DEV_PRIVATE_TO_PF(dev->data->dev_private);
3916 : : struct rte_flow *flow = NULL;
3917 : 0 : struct i40e_fdir_info *fdir_info = &pf->fdir;
3918 : : int ret;
3919 : :
3920 : 0 : ret = i40e_flow_validate(dev, attr, pattern, actions, error);
3921 [ # # ]: 0 : if (ret < 0)
3922 : : return NULL;
3923 : :
3924 [ # # ]: 0 : if (cons_filter_type == RTE_ETH_FILTER_FDIR) {
3925 : 0 : flow = i40e_fdir_entry_pool_get(fdir_info);
3926 [ # # ]: 0 : if (flow == NULL) {
3927 : 0 : rte_flow_error_set(error, ENOBUFS,
3928 : : RTE_FLOW_ERROR_TYPE_HANDLE, NULL,
3929 : : "Fdir space full");
3930 : :
3931 : 0 : return flow;
3932 : : }
3933 : : } else {
3934 : 0 : flow = rte_zmalloc("i40e_flow", sizeof(struct rte_flow), 0);
3935 [ # # ]: 0 : if (!flow) {
3936 : 0 : rte_flow_error_set(error, ENOMEM,
3937 : : RTE_FLOW_ERROR_TYPE_HANDLE, NULL,
3938 : : "Failed to allocate memory");
3939 : 0 : return flow;
3940 : : }
3941 : : }
3942 : :
3943 [ # # # # : 0 : switch (cons_filter_type) {
# ]
3944 : 0 : case RTE_ETH_FILTER_ETHERTYPE:
3945 : 0 : ret = i40e_ethertype_filter_set(pf,
3946 : : &cons_filter.ethertype_filter, 1);
3947 [ # # ]: 0 : if (ret)
3948 : 0 : goto free_flow;
3949 : 0 : flow->rule = TAILQ_LAST(&pf->ethertype.ethertype_list,
3950 : : i40e_ethertype_filter_list);
3951 : 0 : break;
3952 : 0 : case RTE_ETH_FILTER_FDIR:
3953 : 0 : ret = i40e_flow_add_del_fdir_filter(dev,
3954 : : &cons_filter.fdir_filter, 1);
3955 [ # # ]: 0 : if (ret)
3956 : 0 : goto free_flow;
3957 : 0 : flow->rule = TAILQ_LAST(&pf->fdir.fdir_list,
3958 : : i40e_fdir_filter_list);
3959 : 0 : break;
3960 : 0 : case RTE_ETH_FILTER_TUNNEL:
3961 : 0 : ret = i40e_dev_consistent_tunnel_filter_set(pf,
3962 : : &cons_filter.consistent_tunnel_filter, 1);
3963 [ # # ]: 0 : if (ret)
3964 : 0 : goto free_flow;
3965 : 0 : flow->rule = TAILQ_LAST(&pf->tunnel.tunnel_list,
3966 : : i40e_tunnel_filter_list);
3967 : 0 : break;
3968 : 0 : case RTE_ETH_FILTER_HASH:
3969 : 0 : ret = i40e_hash_filter_create(pf, &cons_filter.rss_conf);
3970 [ # # ]: 0 : if (ret)
3971 : 0 : goto free_flow;
3972 : 0 : flow->rule = TAILQ_LAST(&pf->rss_config_list,
3973 : : i40e_rss_conf_list);
3974 : 0 : break;
3975 : 0 : default:
3976 : 0 : goto free_flow;
3977 : : }
3978 : :
3979 : 0 : flow->filter_type = cons_filter_type;
3980 : 0 : TAILQ_INSERT_TAIL(&pf->flow_list, flow, node);
3981 : 0 : return flow;
3982 : :
3983 : 0 : free_flow:
3984 : 0 : rte_flow_error_set(error, -ret,
3985 : : RTE_FLOW_ERROR_TYPE_HANDLE, NULL,
3986 : : "Failed to create flow.");
3987 : :
3988 [ # # ]: 0 : if (cons_filter_type != RTE_ETH_FILTER_FDIR)
3989 : 0 : rte_free(flow);
3990 : : else
3991 : 0 : i40e_fdir_entry_pool_put(fdir_info, flow);
3992 : :
3993 : : return NULL;
3994 : : }
3995 : :
3996 : : static int
3997 : 0 : i40e_flow_destroy(struct rte_eth_dev *dev,
3998 : : struct rte_flow *flow,
3999 : : struct rte_flow_error *error)
4000 : : {
4001 : 0 : struct i40e_pf *pf = I40E_DEV_PRIVATE_TO_PF(dev->data->dev_private);
4002 : 0 : enum rte_filter_type filter_type = flow->filter_type;
4003 : 0 : struct i40e_fdir_info *fdir_info = &pf->fdir;
4004 : : int ret = 0;
4005 : :
4006 [ # # # # : 0 : switch (filter_type) {
# ]
4007 : 0 : case RTE_ETH_FILTER_ETHERTYPE:
4008 : 0 : ret = i40e_flow_destroy_ethertype_filter(pf,
4009 : 0 : (struct i40e_ethertype_filter *)flow->rule);
4010 : 0 : break;
4011 : 0 : case RTE_ETH_FILTER_TUNNEL:
4012 : 0 : ret = i40e_flow_destroy_tunnel_filter(pf,
4013 : 0 : (struct i40e_tunnel_filter *)flow->rule);
4014 : 0 : break;
4015 : 0 : case RTE_ETH_FILTER_FDIR:
4016 : 0 : ret = i40e_flow_add_del_fdir_filter(dev,
4017 : 0 : &((struct i40e_fdir_filter *)flow->rule)->fdir,
4018 : : 0);
4019 : :
4020 : : /* If the last flow is destroyed, disable fdir. */
4021 [ # # # # ]: 0 : if (!ret && TAILQ_EMPTY(&pf->fdir.fdir_list)) {
4022 : 0 : i40e_fdir_rx_proc_enable(dev, 0);
4023 : : }
4024 : : break;
4025 : 0 : case RTE_ETH_FILTER_HASH:
4026 : 0 : ret = i40e_hash_filter_destroy(pf, flow->rule);
4027 : 0 : break;
4028 : 0 : default:
4029 : 0 : PMD_DRV_LOG(WARNING, "Filter type (%d) not supported",
4030 : : filter_type);
4031 : : ret = -EINVAL;
4032 : : break;
4033 : : }
4034 : :
4035 [ # # ]: 0 : if (!ret) {
4036 [ # # ]: 0 : TAILQ_REMOVE(&pf->flow_list, flow, node);
4037 [ # # ]: 0 : if (filter_type == RTE_ETH_FILTER_FDIR)
4038 : 0 : i40e_fdir_entry_pool_put(fdir_info, flow);
4039 : : else
4040 : 0 : rte_free(flow);
4041 : :
4042 : : } else
4043 : 0 : rte_flow_error_set(error, -ret,
4044 : : RTE_FLOW_ERROR_TYPE_HANDLE, NULL,
4045 : : "Failed to destroy flow.");
4046 : :
4047 : 0 : return ret;
4048 : : }
4049 : :
4050 : : static int
4051 : 0 : i40e_flow_destroy_ethertype_filter(struct i40e_pf *pf,
4052 : : struct i40e_ethertype_filter *filter)
4053 : : {
4054 : 0 : struct i40e_hw *hw = I40E_PF_TO_HW(pf);
4055 : 0 : struct i40e_ethertype_rule *ethertype_rule = &pf->ethertype;
4056 : : struct i40e_ethertype_filter *node;
4057 : : struct i40e_control_filter_stats stats;
4058 : : uint16_t flags = 0;
4059 : : int ret = 0;
4060 : :
4061 [ # # ]: 0 : if (!(filter->flags & RTE_ETHTYPE_FLAGS_MAC))
4062 : : flags |= I40E_AQC_ADD_CONTROL_PACKET_FLAGS_IGNORE_MAC;
4063 [ # # ]: 0 : if (filter->flags & RTE_ETHTYPE_FLAGS_DROP)
4064 : 0 : flags |= I40E_AQC_ADD_CONTROL_PACKET_FLAGS_DROP;
4065 : 0 : flags |= I40E_AQC_ADD_CONTROL_PACKET_FLAGS_TO_QUEUE;
4066 : :
4067 : : memset(&stats, 0, sizeof(stats));
4068 : 0 : ret = i40e_aq_add_rem_control_packet_filter(hw,
4069 : 0 : filter->input.mac_addr.addr_bytes,
4070 : 0 : filter->input.ether_type,
4071 : 0 : flags, pf->main_vsi->seid,
4072 : 0 : filter->queue, 0, &stats, NULL);
4073 [ # # ]: 0 : if (ret < 0)
4074 : : return ret;
4075 : :
4076 : 0 : node = i40e_sw_ethertype_filter_lookup(ethertype_rule, &filter->input);
4077 [ # # ]: 0 : if (!node)
4078 : : return -EINVAL;
4079 : :
4080 : 0 : ret = i40e_sw_ethertype_filter_del(pf, &node->input);
4081 : :
4082 : 0 : return ret;
4083 : : }
4084 : :
4085 : : static int
4086 : 0 : i40e_flow_destroy_tunnel_filter(struct i40e_pf *pf,
4087 : : struct i40e_tunnel_filter *filter)
4088 : : {
4089 : 0 : struct i40e_hw *hw = I40E_PF_TO_HW(pf);
4090 : : struct i40e_vsi *vsi;
4091 : : struct i40e_pf_vf *vf;
4092 : : struct i40e_aqc_cloud_filters_element_bb cld_filter;
4093 [ # # ]: 0 : struct i40e_tunnel_rule *tunnel_rule = &pf->tunnel;
4094 : : struct i40e_tunnel_filter *node;
4095 : : bool big_buffer = 0;
4096 : : int ret = 0;
4097 : :
4098 : : memset(&cld_filter, 0, sizeof(cld_filter));
4099 : : rte_ether_addr_copy((struct rte_ether_addr *)&filter->input.outer_mac,
4100 : : (struct rte_ether_addr *)&cld_filter.element.outer_mac);
4101 : : rte_ether_addr_copy((struct rte_ether_addr *)&filter->input.inner_mac,
4102 : : (struct rte_ether_addr *)&cld_filter.element.inner_mac);
4103 : 0 : cld_filter.element.inner_vlan = filter->input.inner_vlan;
4104 : 0 : cld_filter.element.flags = filter->input.flags;
4105 : 0 : cld_filter.element.tenant_id = filter->input.tenant_id;
4106 : 0 : cld_filter.element.queue_number = filter->queue;
4107 : : rte_memcpy(cld_filter.general_fields,
4108 [ # # ]: 0 : filter->input.general_fields,
4109 : : sizeof(cld_filter.general_fields));
4110 : :
4111 [ # # ]: 0 : if (!filter->is_to_vf)
4112 : 0 : vsi = pf->main_vsi;
4113 : : else {
4114 : 0 : vf = &pf->vfs[filter->vf_id];
4115 : 0 : vsi = vf->vsi;
4116 : : }
4117 : :
4118 [ # # ]: 0 : if (((filter->input.flags & I40E_AQC_ADD_CLOUD_FILTER_0X11) ==
4119 [ # # ]: 0 : I40E_AQC_ADD_CLOUD_FILTER_0X11) ||
4120 : : ((filter->input.flags & I40E_AQC_ADD_CLOUD_FILTER_0X12) ==
4121 [ # # ]: 0 : I40E_AQC_ADD_CLOUD_FILTER_0X12) ||
4122 : : ((filter->input.flags & I40E_AQC_ADD_CLOUD_FILTER_0X10) ==
4123 : : I40E_AQC_ADD_CLOUD_FILTER_0X10))
4124 : : big_buffer = 1;
4125 : :
4126 : : if (big_buffer)
4127 : 0 : ret = i40e_aq_rem_cloud_filters_bb(hw, vsi->seid,
4128 : : &cld_filter, 1);
4129 : : else
4130 : 0 : ret = i40e_aq_rem_cloud_filters(hw, vsi->seid,
4131 : : &cld_filter.element, 1);
4132 [ # # ]: 0 : if (ret < 0)
4133 : : return -ENOTSUP;
4134 : :
4135 : 0 : node = i40e_sw_tunnel_filter_lookup(tunnel_rule, &filter->input);
4136 [ # # ]: 0 : if (!node)
4137 : : return -EINVAL;
4138 : :
4139 : 0 : ret = i40e_sw_tunnel_filter_del(pf, &node->input);
4140 : :
4141 : 0 : return ret;
4142 : : }
4143 : :
4144 : : static int
4145 : 0 : i40e_flow_flush(struct rte_eth_dev *dev, struct rte_flow_error *error)
4146 : : {
4147 : 0 : struct i40e_pf *pf = I40E_DEV_PRIVATE_TO_PF(dev->data->dev_private);
4148 : : int ret;
4149 : :
4150 : 0 : ret = i40e_flow_flush_fdir_filter(pf);
4151 [ # # ]: 0 : if (ret) {
4152 : 0 : rte_flow_error_set(error, -ret,
4153 : : RTE_FLOW_ERROR_TYPE_HANDLE, NULL,
4154 : : "Failed to flush FDIR flows.");
4155 : 0 : return -rte_errno;
4156 : : }
4157 : :
4158 : 0 : ret = i40e_flow_flush_ethertype_filter(pf);
4159 [ # # ]: 0 : if (ret) {
4160 : 0 : rte_flow_error_set(error, -ret,
4161 : : RTE_FLOW_ERROR_TYPE_HANDLE, NULL,
4162 : : "Failed to ethertype flush flows.");
4163 : 0 : return -rte_errno;
4164 : : }
4165 : :
4166 : 0 : ret = i40e_flow_flush_tunnel_filter(pf);
4167 [ # # ]: 0 : if (ret) {
4168 : 0 : rte_flow_error_set(error, -ret,
4169 : : RTE_FLOW_ERROR_TYPE_HANDLE, NULL,
4170 : : "Failed to flush tunnel flows.");
4171 : 0 : return -rte_errno;
4172 : : }
4173 : :
4174 : 0 : ret = i40e_hash_filter_flush(pf);
4175 [ # # ]: 0 : if (ret)
4176 : 0 : rte_flow_error_set(error, -ret,
4177 : : RTE_FLOW_ERROR_TYPE_HANDLE, NULL,
4178 : : "Failed to flush RSS flows.");
4179 : : return ret;
4180 : : }
4181 : :
4182 : : static int
4183 : 0 : i40e_flow_flush_fdir_filter(struct i40e_pf *pf)
4184 : : {
4185 : 0 : struct rte_eth_dev *dev = &rte_eth_devices[pf->dev_data->port_id];
4186 : : struct i40e_fdir_info *fdir_info = &pf->fdir;
4187 : : struct i40e_fdir_filter *fdir_filter;
4188 : : enum i40e_filter_pctype pctype;
4189 : : struct rte_flow *flow;
4190 : : void *temp;
4191 : : int ret;
4192 : : uint32_t i = 0;
4193 : :
4194 : 0 : ret = i40e_fdir_flush(dev);
4195 [ # # ]: 0 : if (!ret) {
4196 : : /* Delete FDIR filters in FDIR list. */
4197 [ # # ]: 0 : while ((fdir_filter = TAILQ_FIRST(&fdir_info->fdir_list))) {
4198 : 0 : ret = i40e_sw_fdir_filter_del(pf,
4199 : : &fdir_filter->fdir.input);
4200 [ # # ]: 0 : if (ret < 0)
4201 : 0 : return ret;
4202 : : }
4203 : :
4204 : : /* Delete FDIR flows in flow list. */
4205 [ # # ]: 0 : RTE_TAILQ_FOREACH_SAFE(flow, &pf->flow_list, node, temp) {
4206 [ # # ]: 0 : if (flow->filter_type == RTE_ETH_FILTER_FDIR) {
4207 [ # # ]: 0 : TAILQ_REMOVE(&pf->flow_list, flow, node);
4208 : : }
4209 : : }
4210 : :
4211 : : /* reset bitmap */
4212 : 0 : rte_bitmap_reset(fdir_info->fdir_flow_pool.bitmap);
4213 [ # # ]: 0 : for (i = 0; i < fdir_info->fdir_space_size; i++) {
4214 : 0 : fdir_info->fdir_flow_pool.pool[i].idx = i;
4215 : 0 : rte_bitmap_set(fdir_info->fdir_flow_pool.bitmap, i);
4216 : : }
4217 : :
4218 : 0 : fdir_info->fdir_actual_cnt = 0;
4219 : 0 : fdir_info->fdir_guarantee_free_space =
4220 : 0 : fdir_info->fdir_guarantee_total_space;
4221 : 0 : memset(fdir_info->fdir_filter_array,
4222 : : 0,
4223 : : sizeof(struct i40e_fdir_filter) *
4224 : : I40E_MAX_FDIR_FILTER_NUM);
4225 : :
4226 : 0 : for (pctype = I40E_FILTER_PCTYPE_NONF_IPV4_UDP;
4227 [ # # ]: 0 : pctype <= I40E_FILTER_PCTYPE_L2_PAYLOAD; pctype++) {
4228 : 0 : pf->fdir.flow_count[pctype] = 0;
4229 : 0 : pf->fdir.flex_mask_flag[pctype] = 0;
4230 : : }
4231 : :
4232 [ # # ]: 0 : for (i = 0; i < I40E_MAX_FLXPLD_LAYER; i++)
4233 : 0 : pf->fdir.flex_pit_flag[i] = 0;
4234 : :
4235 : : /* Disable FDIR processing as all FDIR rules are now flushed */
4236 : 0 : i40e_fdir_rx_proc_enable(dev, 0);
4237 : : }
4238 : :
4239 : : return ret;
4240 : : }
4241 : :
4242 : : /* Flush all ethertype filters */
4243 : : static int
4244 : 0 : i40e_flow_flush_ethertype_filter(struct i40e_pf *pf)
4245 : : {
4246 : : struct i40e_ethertype_filter_list
4247 : : *ethertype_list = &pf->ethertype.ethertype_list;
4248 : : struct i40e_ethertype_filter *filter;
4249 : : struct rte_flow *flow;
4250 : : void *temp;
4251 : : int ret = 0;
4252 : :
4253 [ # # ]: 0 : while ((filter = TAILQ_FIRST(ethertype_list))) {
4254 : 0 : ret = i40e_flow_destroy_ethertype_filter(pf, filter);
4255 [ # # ]: 0 : if (ret)
4256 : 0 : return ret;
4257 : : }
4258 : :
4259 : : /* Delete ethertype flows in flow list. */
4260 [ # # ]: 0 : RTE_TAILQ_FOREACH_SAFE(flow, &pf->flow_list, node, temp) {
4261 [ # # ]: 0 : if (flow->filter_type == RTE_ETH_FILTER_ETHERTYPE) {
4262 [ # # ]: 0 : TAILQ_REMOVE(&pf->flow_list, flow, node);
4263 : 0 : rte_free(flow);
4264 : : }
4265 : : }
4266 : :
4267 : : return ret;
4268 : : }
4269 : :
4270 : : /* Flush all tunnel filters */
4271 : : static int
4272 : 0 : i40e_flow_flush_tunnel_filter(struct i40e_pf *pf)
4273 : : {
4274 : : struct i40e_tunnel_filter_list
4275 : : *tunnel_list = &pf->tunnel.tunnel_list;
4276 : : struct i40e_tunnel_filter *filter;
4277 : : struct rte_flow *flow;
4278 : : void *temp;
4279 : : int ret = 0;
4280 : :
4281 [ # # ]: 0 : while ((filter = TAILQ_FIRST(tunnel_list))) {
4282 : 0 : ret = i40e_flow_destroy_tunnel_filter(pf, filter);
4283 [ # # ]: 0 : if (ret)
4284 : 0 : return ret;
4285 : : }
4286 : :
4287 : : /* Delete tunnel flows in flow list. */
4288 [ # # ]: 0 : RTE_TAILQ_FOREACH_SAFE(flow, &pf->flow_list, node, temp) {
4289 [ # # ]: 0 : if (flow->filter_type == RTE_ETH_FILTER_TUNNEL) {
4290 [ # # ]: 0 : TAILQ_REMOVE(&pf->flow_list, flow, node);
4291 : 0 : rte_free(flow);
4292 : : }
4293 : : }
4294 : :
4295 : : return ret;
4296 : : }
4297 : :
4298 : : static int
4299 : 0 : i40e_flow_query(struct rte_eth_dev *dev __rte_unused,
4300 : : struct rte_flow *flow,
4301 : : const struct rte_flow_action *actions,
4302 : : void *data, struct rte_flow_error *error)
4303 : : {
4304 : 0 : struct i40e_rss_filter *rss_rule = (struct i40e_rss_filter *)flow->rule;
4305 : 0 : enum rte_filter_type filter_type = flow->filter_type;
4306 : : struct rte_flow_action_rss *rss_conf = data;
4307 : :
4308 [ # # ]: 0 : if (!rss_rule) {
4309 : 0 : rte_flow_error_set(error, EINVAL,
4310 : : RTE_FLOW_ERROR_TYPE_HANDLE,
4311 : : NULL, "Invalid rule");
4312 : 0 : return -rte_errno;
4313 : : }
4314 : :
4315 [ # # ]: 0 : for (; actions->type != RTE_FLOW_ACTION_TYPE_END; actions++) {
4316 [ # # # ]: 0 : switch (actions->type) {
4317 : : case RTE_FLOW_ACTION_TYPE_VOID:
4318 : : break;
4319 : 0 : case RTE_FLOW_ACTION_TYPE_RSS:
4320 [ # # ]: 0 : if (filter_type != RTE_ETH_FILTER_HASH) {
4321 : 0 : rte_flow_error_set(error, ENOTSUP,
4322 : : RTE_FLOW_ERROR_TYPE_ACTION,
4323 : : actions,
4324 : : "action not supported");
4325 : 0 : return -rte_errno;
4326 : : }
4327 : : rte_memcpy(rss_conf,
4328 [ # # ]: 0 : &rss_rule->rss_filter_info.conf,
4329 : : sizeof(struct rte_flow_action_rss));
4330 : : break;
4331 : 0 : default:
4332 : 0 : return rte_flow_error_set(error, ENOTSUP,
4333 : : RTE_FLOW_ERROR_TYPE_ACTION,
4334 : : actions,
4335 : : "action not supported");
4336 : : }
4337 : : }
4338 : :
4339 : : return 0;
4340 : : }
|