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 : filter->input.flow_ext.flex_pit[field_idx] = flex_pit;
2368 : 0 : filter->input.flow_ext.layer_idx = layer_idx;
2369 : 0 : filter->input.flow_ext.raw_id = raw_id;
2370 : 0 : filter->input.flow_ext.is_flex_flow = true;
2371 : 0 : break;
2372 : 0 : case RTE_FLOW_ITEM_TYPE_L2TPV3OIP:
2373 : 0 : l2tpv3oip_spec = item->spec;
2374 : 0 : l2tpv3oip_mask = item->mask;
2375 : :
2376 [ # # ]: 0 : if (!l2tpv3oip_spec || !l2tpv3oip_mask)
2377 : : break;
2378 : :
2379 [ # # ]: 0 : if (l2tpv3oip_mask->session_id != UINT32_MAX) {
2380 : 0 : rte_flow_error_set(error, EINVAL,
2381 : : RTE_FLOW_ERROR_TYPE_ITEM,
2382 : : item,
2383 : : "Invalid L2TPv3 mask");
2384 : 0 : return -rte_errno;
2385 : : }
2386 : :
2387 [ # # ]: 0 : if (l3 == RTE_FLOW_ITEM_TYPE_IPV4) {
2388 : 0 : filter->input.flow.ip4_l2tpv3oip_flow.session_id =
2389 : 0 : l2tpv3oip_spec->session_id;
2390 : 0 : filter->input.flow_ext.oip_type =
2391 : : I40E_FDIR_IPTYPE_IPV4;
2392 [ # # ]: 0 : } else if (l3 == RTE_FLOW_ITEM_TYPE_IPV6) {
2393 : 0 : filter->input.flow.ip6_l2tpv3oip_flow.session_id =
2394 : 0 : l2tpv3oip_spec->session_id;
2395 : 0 : filter->input.flow_ext.oip_type =
2396 : : I40E_FDIR_IPTYPE_IPV6;
2397 : : }
2398 : :
2399 : 0 : filter->input.flow_ext.customized_pctype = true;
2400 : : cus_proto = item_type;
2401 : 0 : break;
2402 : : default:
2403 : : break;
2404 : : }
2405 : : }
2406 : :
2407 : : /* Get customized pctype value */
2408 [ # # ]: 0 : if (filter->input.flow_ext.customized_pctype) {
2409 : 0 : pctype = i40e_flow_fdir_get_pctype_value(pf, cus_proto, filter);
2410 [ # # ]: 0 : if (pctype == I40E_FILTER_PCTYPE_INVALID) {
2411 : 0 : rte_flow_error_set(error, EINVAL,
2412 : : RTE_FLOW_ERROR_TYPE_ITEM,
2413 : : item,
2414 : : "Unsupported pctype");
2415 : 0 : return -rte_errno;
2416 : : }
2417 : : }
2418 : :
2419 : : /* If customized pctype is not used, set fdir configuration.*/
2420 [ # # ]: 0 : if (!filter->input.flow_ext.customized_pctype) {
2421 : : /* Check if the input set is valid */
2422 [ # # ]: 0 : if (i40e_validate_input_set(pctype, RTE_ETH_FILTER_FDIR,
2423 : : input_set) != 0) {
2424 : 0 : rte_flow_error_set(error, EINVAL,
2425 : : RTE_FLOW_ERROR_TYPE_ITEM,
2426 : : item,
2427 : : "Invalid input set");
2428 : 0 : return -rte_errno;
2429 : : }
2430 : :
2431 : 0 : filter->input.flow_ext.input_set = input_set;
2432 : : }
2433 : :
2434 : 0 : filter->input.pctype = pctype;
2435 : :
2436 : 0 : return 0;
2437 : : }
2438 : :
2439 : : /* Parse to get the action info of a FDIR filter.
2440 : : * FDIR action supports QUEUE or (QUEUE + MARK).
2441 : : */
2442 : : static int
2443 : 0 : i40e_flow_parse_fdir_action(struct rte_eth_dev *dev,
2444 : : const struct rte_flow_action *actions,
2445 : : struct rte_flow_error *error,
2446 : : struct i40e_fdir_filter_conf *filter)
2447 : : {
2448 : 0 : struct i40e_pf *pf = I40E_DEV_PRIVATE_TO_PF(dev->data->dev_private);
2449 : : const struct rte_flow_action *act;
2450 : : const struct rte_flow_action_queue *act_q;
2451 : : const struct rte_flow_action_mark *mark_spec = NULL;
2452 : : uint32_t index = 0;
2453 : :
2454 : : /* Check if the first non-void action is QUEUE or DROP or PASSTHRU. */
2455 [ # # ]: 0 : NEXT_ITEM_OF_ACTION(act, actions, index);
2456 [ # # # # : 0 : switch (act->type) {
# ]
2457 : 0 : case RTE_FLOW_ACTION_TYPE_QUEUE:
2458 : 0 : act_q = act->conf;
2459 : 0 : filter->action.rx_queue = act_q->index;
2460 [ # # ]: 0 : if ((!filter->input.flow_ext.is_vf &&
2461 [ # # # # ]: 0 : filter->action.rx_queue >= pf->dev_data->nb_rx_queues) ||
2462 : 0 : (filter->input.flow_ext.is_vf &&
2463 [ # # ]: 0 : filter->action.rx_queue >= pf->vf_nb_qps)) {
2464 : 0 : rte_flow_error_set(error, EINVAL,
2465 : : RTE_FLOW_ERROR_TYPE_ACTION, act,
2466 : : "Invalid queue ID for FDIR.");
2467 : 0 : return -rte_errno;
2468 : : }
2469 : 0 : filter->action.behavior = I40E_FDIR_ACCEPT;
2470 : 0 : break;
2471 : 0 : case RTE_FLOW_ACTION_TYPE_DROP:
2472 : 0 : filter->action.behavior = I40E_FDIR_REJECT;
2473 : 0 : break;
2474 : 0 : case RTE_FLOW_ACTION_TYPE_PASSTHRU:
2475 : 0 : filter->action.behavior = I40E_FDIR_PASSTHRU;
2476 : 0 : break;
2477 : 0 : case RTE_FLOW_ACTION_TYPE_MARK:
2478 : 0 : filter->action.behavior = I40E_FDIR_PASSTHRU;
2479 : 0 : mark_spec = act->conf;
2480 : 0 : filter->action.report_status = I40E_FDIR_REPORT_ID;
2481 : 0 : filter->soft_id = mark_spec->id;
2482 : 0 : break;
2483 : 0 : default:
2484 : 0 : rte_flow_error_set(error, EINVAL,
2485 : : RTE_FLOW_ERROR_TYPE_ACTION, act,
2486 : : "Invalid action.");
2487 : 0 : return -rte_errno;
2488 : : }
2489 : :
2490 : : /* Check if the next non-void item is MARK or FLAG or END. */
2491 : 0 : index++;
2492 [ # # ]: 0 : NEXT_ITEM_OF_ACTION(act, actions, index);
2493 [ # # # # : 0 : switch (act->type) {
# ]
2494 : 0 : case RTE_FLOW_ACTION_TYPE_MARK:
2495 [ # # ]: 0 : if (mark_spec) {
2496 : : /* Double MARK actions requested */
2497 : 0 : rte_flow_error_set(error, EINVAL,
2498 : : RTE_FLOW_ERROR_TYPE_ACTION, act,
2499 : : "Invalid action.");
2500 : 0 : return -rte_errno;
2501 : : }
2502 : 0 : mark_spec = act->conf;
2503 : 0 : filter->action.report_status = I40E_FDIR_REPORT_ID;
2504 : 0 : filter->soft_id = mark_spec->id;
2505 : 0 : break;
2506 : 0 : case RTE_FLOW_ACTION_TYPE_FLAG:
2507 [ # # ]: 0 : if (mark_spec) {
2508 : : /* MARK + FLAG not supported */
2509 : 0 : rte_flow_error_set(error, EINVAL,
2510 : : RTE_FLOW_ERROR_TYPE_ACTION, act,
2511 : : "Invalid action.");
2512 : 0 : return -rte_errno;
2513 : : }
2514 : 0 : filter->action.report_status = I40E_FDIR_NO_REPORT_STATUS;
2515 : 0 : break;
2516 : 0 : case RTE_FLOW_ACTION_TYPE_RSS:
2517 [ # # ]: 0 : if (filter->action.behavior != I40E_FDIR_PASSTHRU) {
2518 : : /* RSS filter won't be next if FDIR did not pass thru */
2519 : 0 : rte_flow_error_set(error, EINVAL,
2520 : : RTE_FLOW_ERROR_TYPE_ACTION, act,
2521 : : "Invalid action.");
2522 : 0 : return -rte_errno;
2523 : : }
2524 : : break;
2525 : : case RTE_FLOW_ACTION_TYPE_END:
2526 : : return 0;
2527 : 0 : default:
2528 : 0 : rte_flow_error_set(error, EINVAL, RTE_FLOW_ERROR_TYPE_ACTION,
2529 : : act, "Invalid action.");
2530 : 0 : return -rte_errno;
2531 : : }
2532 : :
2533 : : /* Check if the next non-void item is END */
2534 : 0 : index++;
2535 [ # # ]: 0 : NEXT_ITEM_OF_ACTION(act, actions, index);
2536 [ # # ]: 0 : if (act->type != RTE_FLOW_ACTION_TYPE_END) {
2537 : 0 : rte_flow_error_set(error, EINVAL,
2538 : : RTE_FLOW_ERROR_TYPE_ACTION,
2539 : : act, "Invalid action.");
2540 : 0 : return -rte_errno;
2541 : : }
2542 : :
2543 : : return 0;
2544 : : }
2545 : :
2546 : : static int
2547 : 0 : i40e_flow_parse_fdir_filter(struct rte_eth_dev *dev,
2548 : : const struct rte_flow_attr *attr,
2549 : : const struct rte_flow_item pattern[],
2550 : : const struct rte_flow_action actions[],
2551 : : struct rte_flow_error *error,
2552 : : union i40e_filter_t *filter)
2553 : : {
2554 : 0 : struct i40e_pf *pf = I40E_DEV_PRIVATE_TO_PF(dev->data->dev_private);
2555 : 0 : struct i40e_fdir_filter_conf *fdir_filter =
2556 : : &filter->fdir_filter;
2557 : : int ret;
2558 : :
2559 : 0 : ret = i40e_flow_parse_fdir_pattern(dev, pattern, error, fdir_filter);
2560 [ # # ]: 0 : if (ret)
2561 : : return ret;
2562 : :
2563 : 0 : ret = i40e_flow_parse_fdir_action(dev, actions, error, fdir_filter);
2564 [ # # ]: 0 : if (ret)
2565 : : return ret;
2566 : :
2567 : 0 : ret = i40e_flow_parse_attr(attr, error);
2568 [ # # ]: 0 : if (ret)
2569 : : return ret;
2570 : :
2571 : 0 : cons_filter_type = RTE_ETH_FILTER_FDIR;
2572 : :
2573 [ # # ]: 0 : if (pf->fdir.fdir_vsi == NULL) {
2574 : : /* Enable fdir when fdir flow is added at first time. */
2575 : 0 : ret = i40e_fdir_setup(pf);
2576 [ # # ]: 0 : if (ret != I40E_SUCCESS) {
2577 : 0 : rte_flow_error_set(error, ENOTSUP,
2578 : : RTE_FLOW_ERROR_TYPE_HANDLE,
2579 : : NULL, "Failed to setup fdir.");
2580 : 0 : return -rte_errno;
2581 : : }
2582 : 0 : ret = i40e_fdir_configure(dev);
2583 [ # # ]: 0 : if (ret < 0) {
2584 : 0 : rte_flow_error_set(error, ENOTSUP,
2585 : : RTE_FLOW_ERROR_TYPE_HANDLE,
2586 : : NULL, "Failed to configure fdir.");
2587 : 0 : goto err;
2588 : : }
2589 : : }
2590 : :
2591 : : /* If create the first fdir rule, enable fdir check for rx queues */
2592 [ # # ]: 0 : if (TAILQ_EMPTY(&pf->fdir.fdir_list))
2593 : 0 : i40e_fdir_rx_proc_enable(dev, 1);
2594 : :
2595 : : return 0;
2596 : : err:
2597 : 0 : i40e_fdir_teardown(pf);
2598 : 0 : return -rte_errno;
2599 : : }
2600 : :
2601 : : /* Parse to get the action info of a tunnel filter
2602 : : * Tunnel action only supports PF, VF and QUEUE.
2603 : : */
2604 : : static int
2605 : 0 : i40e_flow_parse_tunnel_action(struct rte_eth_dev *dev,
2606 : : const struct rte_flow_action *actions,
2607 : : struct rte_flow_error *error,
2608 : : struct i40e_tunnel_filter_conf *filter)
2609 : : {
2610 : 0 : struct i40e_pf *pf = I40E_DEV_PRIVATE_TO_PF(dev->data->dev_private);
2611 : : const struct rte_flow_action *act;
2612 : : const struct rte_flow_action_queue *act_q;
2613 : : const struct rte_flow_action_vf *act_vf;
2614 : : uint32_t index = 0;
2615 : :
2616 : : /* Check if the first non-void action is PF or VF. */
2617 [ # # ]: 0 : NEXT_ITEM_OF_ACTION(act, actions, index);
2618 [ # # ]: 0 : if (act->type != RTE_FLOW_ACTION_TYPE_PF &&
2619 : : act->type != RTE_FLOW_ACTION_TYPE_VF) {
2620 : 0 : rte_flow_error_set(error, EINVAL, RTE_FLOW_ERROR_TYPE_ACTION,
2621 : : act, "Not supported action.");
2622 : 0 : return -rte_errno;
2623 : : }
2624 : :
2625 [ # # ]: 0 : if (act->type == RTE_FLOW_ACTION_TYPE_VF) {
2626 : 0 : act_vf = act->conf;
2627 : 0 : filter->vf_id = act_vf->id;
2628 : 0 : filter->is_to_vf = 1;
2629 [ # # ]: 0 : if (filter->vf_id >= pf->vf_num) {
2630 : 0 : rte_flow_error_set(error, EINVAL,
2631 : : RTE_FLOW_ERROR_TYPE_ACTION,
2632 : : act, "Invalid VF ID for tunnel filter");
2633 : 0 : return -rte_errno;
2634 : : }
2635 : : }
2636 : :
2637 : : /* Check if the next non-void item is QUEUE */
2638 : 0 : index++;
2639 [ # # ]: 0 : NEXT_ITEM_OF_ACTION(act, actions, index);
2640 [ # # ]: 0 : if (act->type == RTE_FLOW_ACTION_TYPE_QUEUE) {
2641 : 0 : act_q = act->conf;
2642 : 0 : filter->queue_id = act_q->index;
2643 [ # # ]: 0 : if ((!filter->is_to_vf) &&
2644 [ # # ]: 0 : (filter->queue_id >= pf->dev_data->nb_rx_queues)) {
2645 : 0 : rte_flow_error_set(error, EINVAL,
2646 : : RTE_FLOW_ERROR_TYPE_ACTION,
2647 : : act, "Invalid queue ID for tunnel filter");
2648 : 0 : return -rte_errno;
2649 [ # # ]: 0 : } else if (filter->is_to_vf &&
2650 [ # # ]: 0 : (filter->queue_id >= pf->vf_nb_qps)) {
2651 : 0 : rte_flow_error_set(error, EINVAL,
2652 : : RTE_FLOW_ERROR_TYPE_ACTION,
2653 : : act, "Invalid queue ID for tunnel filter");
2654 : 0 : return -rte_errno;
2655 : : }
2656 : : }
2657 : :
2658 : : /* Check if the next non-void item is END */
2659 : 0 : index++;
2660 [ # # ]: 0 : NEXT_ITEM_OF_ACTION(act, actions, index);
2661 [ # # ]: 0 : if (act->type != RTE_FLOW_ACTION_TYPE_END) {
2662 : 0 : rte_flow_error_set(error, EINVAL, RTE_FLOW_ERROR_TYPE_ACTION,
2663 : : act, "Not supported action.");
2664 : 0 : return -rte_errno;
2665 : : }
2666 : :
2667 : : return 0;
2668 : : }
2669 : :
2670 : : /* 1. Last in item should be NULL as range is not supported.
2671 : : * 2. Supported filter types: Source port only and Destination port only.
2672 : : * 3. Mask of fields which need to be matched should be
2673 : : * filled with 1.
2674 : : * 4. Mask of fields which needn't to be matched should be
2675 : : * filled with 0.
2676 : : */
2677 : : static int
2678 : 0 : i40e_flow_parse_l4_pattern(const struct rte_flow_item *pattern,
2679 : : struct rte_flow_error *error,
2680 : : struct i40e_tunnel_filter_conf *filter)
2681 : : {
2682 : : const struct rte_flow_item_sctp *sctp_spec, *sctp_mask;
2683 : : const struct rte_flow_item_tcp *tcp_spec, *tcp_mask;
2684 : : const struct rte_flow_item_udp *udp_spec, *udp_mask;
2685 : : const struct rte_flow_item *item = pattern;
2686 : : enum rte_flow_item_type item_type;
2687 : :
2688 [ # # ]: 0 : for (; item->type != RTE_FLOW_ITEM_TYPE_END; item++) {
2689 [ # # ]: 0 : if (item->last) {
2690 : 0 : rte_flow_error_set(error, EINVAL,
2691 : : RTE_FLOW_ERROR_TYPE_ITEM,
2692 : : item,
2693 : : "Not support range");
2694 : 0 : return -rte_errno;
2695 : : }
2696 : : item_type = item->type;
2697 [ # # # # : 0 : switch (item_type) {
# # # ]
2698 : 0 : case RTE_FLOW_ITEM_TYPE_ETH:
2699 [ # # # # ]: 0 : if (item->spec || item->mask) {
2700 : 0 : rte_flow_error_set(error, EINVAL,
2701 : : RTE_FLOW_ERROR_TYPE_ITEM,
2702 : : item,
2703 : : "Invalid ETH item");
2704 : 0 : return -rte_errno;
2705 : : }
2706 : :
2707 : : break;
2708 : 0 : case RTE_FLOW_ITEM_TYPE_IPV4:
2709 : 0 : filter->ip_type = I40E_TUNNEL_IPTYPE_IPV4;
2710 : : /* IPv4 is used to describe protocol,
2711 : : * spec and mask should be NULL.
2712 : : */
2713 [ # # # # ]: 0 : if (item->spec || item->mask) {
2714 : 0 : rte_flow_error_set(error, EINVAL,
2715 : : RTE_FLOW_ERROR_TYPE_ITEM,
2716 : : item,
2717 : : "Invalid IPv4 item");
2718 : 0 : return -rte_errno;
2719 : : }
2720 : :
2721 : : break;
2722 : 0 : case RTE_FLOW_ITEM_TYPE_IPV6:
2723 : 0 : filter->ip_type = I40E_TUNNEL_IPTYPE_IPV6;
2724 : : /* IPv6 is used to describe protocol,
2725 : : * spec and mask should be NULL.
2726 : : */
2727 [ # # # # ]: 0 : if (item->spec || item->mask) {
2728 : 0 : rte_flow_error_set(error, EINVAL,
2729 : : RTE_FLOW_ERROR_TYPE_ITEM,
2730 : : item,
2731 : : "Invalid IPv6 item");
2732 : 0 : return -rte_errno;
2733 : : }
2734 : :
2735 : : break;
2736 : 0 : case RTE_FLOW_ITEM_TYPE_UDP:
2737 : 0 : udp_spec = item->spec;
2738 : 0 : udp_mask = item->mask;
2739 : :
2740 [ # # ]: 0 : if (!udp_spec || !udp_mask) {
2741 : 0 : rte_flow_error_set(error, EINVAL,
2742 : : RTE_FLOW_ERROR_TYPE_ITEM,
2743 : : item,
2744 : : "Invalid udp item");
2745 : 0 : return -rte_errno;
2746 : : }
2747 : :
2748 [ # # ]: 0 : if (udp_spec->hdr.src_port != 0 &&
2749 [ # # ]: 0 : udp_spec->hdr.dst_port != 0) {
2750 : 0 : rte_flow_error_set(error, EINVAL,
2751 : : RTE_FLOW_ERROR_TYPE_ITEM,
2752 : : item,
2753 : : "Invalid udp spec");
2754 : 0 : return -rte_errno;
2755 : : }
2756 : :
2757 [ # # ]: 0 : if (udp_spec->hdr.src_port != 0) {
2758 : 0 : filter->l4_port_type =
2759 : : I40E_L4_PORT_TYPE_SRC;
2760 : 0 : filter->tenant_id =
2761 [ # # ]: 0 : rte_be_to_cpu_32(udp_spec->hdr.src_port);
2762 : : }
2763 : :
2764 [ # # ]: 0 : if (udp_spec->hdr.dst_port != 0) {
2765 : 0 : filter->l4_port_type =
2766 : : I40E_L4_PORT_TYPE_DST;
2767 : 0 : filter->tenant_id =
2768 [ # # ]: 0 : rte_be_to_cpu_32(udp_spec->hdr.dst_port);
2769 : : }
2770 : :
2771 : 0 : filter->tunnel_type = I40E_CLOUD_TYPE_UDP;
2772 : :
2773 : 0 : break;
2774 : 0 : case RTE_FLOW_ITEM_TYPE_TCP:
2775 : 0 : tcp_spec = item->spec;
2776 : 0 : tcp_mask = item->mask;
2777 : :
2778 [ # # ]: 0 : if (!tcp_spec || !tcp_mask) {
2779 : 0 : rte_flow_error_set(error, EINVAL,
2780 : : RTE_FLOW_ERROR_TYPE_ITEM,
2781 : : item,
2782 : : "Invalid tcp item");
2783 : 0 : return -rte_errno;
2784 : : }
2785 : :
2786 [ # # ]: 0 : if (tcp_spec->hdr.src_port != 0 &&
2787 [ # # ]: 0 : tcp_spec->hdr.dst_port != 0) {
2788 : 0 : rte_flow_error_set(error, EINVAL,
2789 : : RTE_FLOW_ERROR_TYPE_ITEM,
2790 : : item,
2791 : : "Invalid tcp spec");
2792 : 0 : return -rte_errno;
2793 : : }
2794 : :
2795 [ # # ]: 0 : if (tcp_spec->hdr.src_port != 0) {
2796 : 0 : filter->l4_port_type =
2797 : : I40E_L4_PORT_TYPE_SRC;
2798 : 0 : filter->tenant_id =
2799 [ # # ]: 0 : rte_be_to_cpu_32(tcp_spec->hdr.src_port);
2800 : : }
2801 : :
2802 [ # # ]: 0 : if (tcp_spec->hdr.dst_port != 0) {
2803 : 0 : filter->l4_port_type =
2804 : : I40E_L4_PORT_TYPE_DST;
2805 : 0 : filter->tenant_id =
2806 [ # # ]: 0 : rte_be_to_cpu_32(tcp_spec->hdr.dst_port);
2807 : : }
2808 : :
2809 : 0 : filter->tunnel_type = I40E_CLOUD_TYPE_TCP;
2810 : :
2811 : 0 : break;
2812 : 0 : case RTE_FLOW_ITEM_TYPE_SCTP:
2813 : 0 : sctp_spec = item->spec;
2814 : 0 : sctp_mask = item->mask;
2815 : :
2816 [ # # ]: 0 : if (!sctp_spec || !sctp_mask) {
2817 : 0 : rte_flow_error_set(error, EINVAL,
2818 : : RTE_FLOW_ERROR_TYPE_ITEM,
2819 : : item,
2820 : : "Invalid sctp item");
2821 : 0 : return -rte_errno;
2822 : : }
2823 : :
2824 [ # # ]: 0 : if (sctp_spec->hdr.src_port != 0 &&
2825 [ # # ]: 0 : sctp_spec->hdr.dst_port != 0) {
2826 : 0 : rte_flow_error_set(error, EINVAL,
2827 : : RTE_FLOW_ERROR_TYPE_ITEM,
2828 : : item,
2829 : : "Invalid sctp spec");
2830 : 0 : return -rte_errno;
2831 : : }
2832 : :
2833 [ # # ]: 0 : if (sctp_spec->hdr.src_port != 0) {
2834 : 0 : filter->l4_port_type =
2835 : : I40E_L4_PORT_TYPE_SRC;
2836 : 0 : filter->tenant_id =
2837 [ # # ]: 0 : rte_be_to_cpu_32(sctp_spec->hdr.src_port);
2838 : : }
2839 : :
2840 [ # # ]: 0 : if (sctp_spec->hdr.dst_port != 0) {
2841 : 0 : filter->l4_port_type =
2842 : : I40E_L4_PORT_TYPE_DST;
2843 : 0 : filter->tenant_id =
2844 [ # # ]: 0 : rte_be_to_cpu_32(sctp_spec->hdr.dst_port);
2845 : : }
2846 : :
2847 : 0 : filter->tunnel_type = I40E_CLOUD_TYPE_SCTP;
2848 : :
2849 : 0 : break;
2850 : : default:
2851 : : break;
2852 : : }
2853 : : }
2854 : :
2855 : : return 0;
2856 : : }
2857 : :
2858 : : static int
2859 : 0 : i40e_flow_parse_l4_cloud_filter(struct rte_eth_dev *dev,
2860 : : const struct rte_flow_attr *attr,
2861 : : const struct rte_flow_item pattern[],
2862 : : const struct rte_flow_action actions[],
2863 : : struct rte_flow_error *error,
2864 : : union i40e_filter_t *filter)
2865 : : {
2866 : 0 : struct i40e_tunnel_filter_conf *tunnel_filter =
2867 : : &filter->consistent_tunnel_filter;
2868 : : int ret;
2869 : :
2870 : 0 : ret = i40e_flow_parse_l4_pattern(pattern, error, tunnel_filter);
2871 [ # # ]: 0 : if (ret)
2872 : : return ret;
2873 : :
2874 : 0 : ret = i40e_flow_parse_tunnel_action(dev, actions, error, tunnel_filter);
2875 [ # # ]: 0 : if (ret)
2876 : : return ret;
2877 : :
2878 : 0 : ret = i40e_flow_parse_attr(attr, error);
2879 [ # # ]: 0 : if (ret)
2880 : : return ret;
2881 : :
2882 : 0 : cons_filter_type = RTE_ETH_FILTER_TUNNEL;
2883 : :
2884 : 0 : return ret;
2885 : : }
2886 : :
2887 : : static uint16_t i40e_supported_tunnel_filter_types[] = {
2888 : : RTE_ETH_TUNNEL_FILTER_IMAC | RTE_ETH_TUNNEL_FILTER_TENID |
2889 : : RTE_ETH_TUNNEL_FILTER_IVLAN,
2890 : : RTE_ETH_TUNNEL_FILTER_IMAC | RTE_ETH_TUNNEL_FILTER_IVLAN,
2891 : : RTE_ETH_TUNNEL_FILTER_IMAC | RTE_ETH_TUNNEL_FILTER_TENID,
2892 : : RTE_ETH_TUNNEL_FILTER_OMAC | RTE_ETH_TUNNEL_FILTER_TENID |
2893 : : RTE_ETH_TUNNEL_FILTER_IMAC,
2894 : : RTE_ETH_TUNNEL_FILTER_IMAC,
2895 : : };
2896 : :
2897 : : static int
2898 : : i40e_check_tunnel_filter_type(uint8_t filter_type)
2899 : : {
2900 : : uint8_t i;
2901 : :
2902 [ # # # # ]: 0 : for (i = 0; i < RTE_DIM(i40e_supported_tunnel_filter_types); i++) {
2903 [ # # # # ]: 0 : if (filter_type == i40e_supported_tunnel_filter_types[i])
2904 : : return 0;
2905 : : }
2906 : :
2907 : : return -1;
2908 : : }
2909 : :
2910 : : /* 1. Last in item should be NULL as range is not supported.
2911 : : * 2. Supported filter types: IMAC_IVLAN_TENID, IMAC_IVLAN,
2912 : : * IMAC_TENID, OMAC_TENID_IMAC and IMAC.
2913 : : * 3. Mask of fields which need to be matched should be
2914 : : * filled with 1.
2915 : : * 4. Mask of fields which needn't to be matched should be
2916 : : * filled with 0.
2917 : : */
2918 : : static int
2919 : 0 : i40e_flow_parse_vxlan_pattern(__rte_unused struct rte_eth_dev *dev,
2920 : : const struct rte_flow_item *pattern,
2921 : : struct rte_flow_error *error,
2922 : : struct i40e_tunnel_filter_conf *filter)
2923 : : {
2924 : : const struct rte_flow_item *item = pattern;
2925 : : const struct rte_flow_item_eth *eth_spec;
2926 : : const struct rte_flow_item_eth *eth_mask;
2927 : : const struct rte_flow_item_vxlan *vxlan_spec;
2928 : : const struct rte_flow_item_vxlan *vxlan_mask;
2929 : : const struct rte_flow_item_vlan *vlan_spec;
2930 : : const struct rte_flow_item_vlan *vlan_mask;
2931 : : uint8_t filter_type = 0;
2932 : : bool is_vni_masked = 0;
2933 : 0 : uint8_t vni_mask[] = {0xFF, 0xFF, 0xFF};
2934 : : enum rte_flow_item_type item_type;
2935 : : bool vxlan_flag = 0;
2936 : 0 : uint32_t tenant_id_be = 0;
2937 : : int ret;
2938 : :
2939 [ # # ]: 0 : for (; item->type != RTE_FLOW_ITEM_TYPE_END; item++) {
2940 [ # # ]: 0 : if (item->last) {
2941 : 0 : rte_flow_error_set(error, EINVAL,
2942 : : RTE_FLOW_ERROR_TYPE_ITEM,
2943 : : item,
2944 : : "Not support range");
2945 : 0 : return -rte_errno;
2946 : : }
2947 : : item_type = item->type;
2948 [ # # # # : 0 : switch (item_type) {
# # # ]
2949 : 0 : case RTE_FLOW_ITEM_TYPE_ETH:
2950 : 0 : eth_spec = item->spec;
2951 : 0 : eth_mask = item->mask;
2952 : :
2953 : : /* Check if ETH item is used for place holder.
2954 : : * If yes, both spec and mask should be NULL.
2955 : : * If no, both spec and mask shouldn't be NULL.
2956 : : */
2957 [ # # ]: 0 : if ((!eth_spec && eth_mask) ||
2958 : : (eth_spec && !eth_mask)) {
2959 : 0 : rte_flow_error_set(error, EINVAL,
2960 : : RTE_FLOW_ERROR_TYPE_ITEM,
2961 : : item,
2962 : : "Invalid ether spec/mask");
2963 : 0 : return -rte_errno;
2964 : : }
2965 : :
2966 [ # # ]: 0 : if (eth_spec && eth_mask) {
2967 : : /* DST address of inner MAC shouldn't be masked.
2968 : : * SRC address of Inner MAC should be masked.
2969 : : */
2970 [ # # # # ]: 0 : if (!rte_is_broadcast_ether_addr(ð_mask->hdr.dst_addr) ||
2971 : 0 : !rte_is_zero_ether_addr(ð_mask->hdr.src_addr) ||
2972 [ # # ]: 0 : eth_mask->hdr.ether_type) {
2973 : 0 : rte_flow_error_set(error, EINVAL,
2974 : : RTE_FLOW_ERROR_TYPE_ITEM,
2975 : : item,
2976 : : "Invalid ether spec/mask");
2977 : 0 : return -rte_errno;
2978 : : }
2979 : :
2980 [ # # ]: 0 : if (!vxlan_flag) {
2981 : 0 : rte_memcpy(&filter->outer_mac,
2982 [ # # ]: 0 : ð_spec->hdr.dst_addr,
2983 : : RTE_ETHER_ADDR_LEN);
2984 : 0 : filter_type |= RTE_ETH_TUNNEL_FILTER_OMAC;
2985 : : } else {
2986 : 0 : rte_memcpy(&filter->inner_mac,
2987 [ # # ]: 0 : ð_spec->hdr.dst_addr,
2988 : : RTE_ETHER_ADDR_LEN);
2989 : 0 : filter_type |= RTE_ETH_TUNNEL_FILTER_IMAC;
2990 : : }
2991 : : }
2992 : : break;
2993 : 0 : case RTE_FLOW_ITEM_TYPE_VLAN:
2994 : 0 : vlan_spec = item->spec;
2995 : 0 : vlan_mask = item->mask;
2996 [ # # ]: 0 : if (!(vlan_spec && vlan_mask) ||
2997 [ # # ]: 0 : vlan_mask->hdr.eth_proto) {
2998 : 0 : rte_flow_error_set(error, EINVAL,
2999 : : RTE_FLOW_ERROR_TYPE_ITEM,
3000 : : item,
3001 : : "Invalid vlan item");
3002 : 0 : return -rte_errno;
3003 : : }
3004 : :
3005 : : if (vlan_spec && vlan_mask) {
3006 [ # # ]: 0 : if (vlan_mask->hdr.vlan_tci ==
3007 : : rte_cpu_to_be_16(I40E_VLAN_TCI_MASK))
3008 : 0 : filter->inner_vlan =
3009 [ # # ]: 0 : rte_be_to_cpu_16(vlan_spec->hdr.vlan_tci) &
3010 : : I40E_VLAN_TCI_MASK;
3011 : 0 : filter_type |= RTE_ETH_TUNNEL_FILTER_IVLAN;
3012 : : }
3013 : : break;
3014 : 0 : case RTE_FLOW_ITEM_TYPE_IPV4:
3015 : 0 : filter->ip_type = I40E_TUNNEL_IPTYPE_IPV4;
3016 : : /* IPv4 is used to describe protocol,
3017 : : * spec and mask should be NULL.
3018 : : */
3019 [ # # # # ]: 0 : if (item->spec || item->mask) {
3020 : 0 : rte_flow_error_set(error, EINVAL,
3021 : : RTE_FLOW_ERROR_TYPE_ITEM,
3022 : : item,
3023 : : "Invalid IPv4 item");
3024 : 0 : return -rte_errno;
3025 : : }
3026 : : break;
3027 : 0 : case RTE_FLOW_ITEM_TYPE_IPV6:
3028 : 0 : filter->ip_type = I40E_TUNNEL_IPTYPE_IPV6;
3029 : : /* IPv6 is used to describe protocol,
3030 : : * spec and mask should be NULL.
3031 : : */
3032 [ # # # # ]: 0 : if (item->spec || item->mask) {
3033 : 0 : rte_flow_error_set(error, EINVAL,
3034 : : RTE_FLOW_ERROR_TYPE_ITEM,
3035 : : item,
3036 : : "Invalid IPv6 item");
3037 : 0 : return -rte_errno;
3038 : : }
3039 : : break;
3040 : 0 : case RTE_FLOW_ITEM_TYPE_UDP:
3041 : : /* UDP is used to describe protocol,
3042 : : * spec and mask should be NULL.
3043 : : */
3044 [ # # # # ]: 0 : if (item->spec || item->mask) {
3045 : 0 : rte_flow_error_set(error, EINVAL,
3046 : : RTE_FLOW_ERROR_TYPE_ITEM,
3047 : : item,
3048 : : "Invalid UDP item");
3049 : 0 : return -rte_errno;
3050 : : }
3051 : : break;
3052 : 0 : case RTE_FLOW_ITEM_TYPE_VXLAN:
3053 : 0 : vxlan_spec = item->spec;
3054 : 0 : vxlan_mask = item->mask;
3055 : : /* Check if VXLAN item is used to describe protocol.
3056 : : * If yes, both spec and mask should be NULL.
3057 : : * If no, both spec and mask shouldn't be NULL.
3058 : : */
3059 [ # # ]: 0 : if ((!vxlan_spec && vxlan_mask) ||
3060 : : (vxlan_spec && !vxlan_mask)) {
3061 : 0 : rte_flow_error_set(error, EINVAL,
3062 : : RTE_FLOW_ERROR_TYPE_ITEM,
3063 : : item,
3064 : : "Invalid VXLAN item");
3065 : 0 : return -rte_errno;
3066 : : }
3067 : :
3068 : : /* Check if VNI is masked. */
3069 [ # # ]: 0 : if (vxlan_spec && vxlan_mask) {
3070 : : is_vni_masked =
3071 : 0 : !!memcmp(vxlan_mask->hdr.vni, vni_mask,
3072 : : RTE_DIM(vni_mask));
3073 [ # # ]: 0 : if (is_vni_masked) {
3074 : 0 : rte_flow_error_set(error, EINVAL,
3075 : : RTE_FLOW_ERROR_TYPE_ITEM,
3076 : : item,
3077 : : "Invalid VNI mask");
3078 : 0 : return -rte_errno;
3079 : : }
3080 : :
3081 : : rte_memcpy(((uint8_t *)&tenant_id_be + 1),
3082 : : vxlan_spec->hdr.vni, 3);
3083 : 0 : filter->tenant_id =
3084 [ # # ]: 0 : rte_be_to_cpu_32(tenant_id_be);
3085 : 0 : filter_type |= RTE_ETH_TUNNEL_FILTER_TENID;
3086 : : }
3087 : :
3088 : : vxlan_flag = 1;
3089 : : break;
3090 : : default:
3091 : : break;
3092 : : }
3093 : : }
3094 : :
3095 : : ret = i40e_check_tunnel_filter_type(filter_type);
3096 [ # # ]: 0 : if (ret < 0) {
3097 : 0 : rte_flow_error_set(error, EINVAL,
3098 : : RTE_FLOW_ERROR_TYPE_ITEM,
3099 : : NULL,
3100 : : "Invalid filter type");
3101 : 0 : return -rte_errno;
3102 : : }
3103 : 0 : filter->filter_type = filter_type;
3104 : :
3105 : 0 : filter->tunnel_type = I40E_TUNNEL_TYPE_VXLAN;
3106 : :
3107 : 0 : return 0;
3108 : : }
3109 : :
3110 : : static int
3111 : 0 : i40e_flow_parse_vxlan_filter(struct rte_eth_dev *dev,
3112 : : const struct rte_flow_attr *attr,
3113 : : const struct rte_flow_item pattern[],
3114 : : const struct rte_flow_action actions[],
3115 : : struct rte_flow_error *error,
3116 : : union i40e_filter_t *filter)
3117 : : {
3118 : 0 : struct i40e_tunnel_filter_conf *tunnel_filter =
3119 : : &filter->consistent_tunnel_filter;
3120 : : int ret;
3121 : :
3122 : 0 : ret = i40e_flow_parse_vxlan_pattern(dev, pattern,
3123 : : error, tunnel_filter);
3124 [ # # ]: 0 : if (ret)
3125 : : return ret;
3126 : :
3127 : 0 : ret = i40e_flow_parse_tunnel_action(dev, actions, error, tunnel_filter);
3128 [ # # ]: 0 : if (ret)
3129 : : return ret;
3130 : :
3131 : 0 : ret = i40e_flow_parse_attr(attr, error);
3132 [ # # ]: 0 : if (ret)
3133 : : return ret;
3134 : :
3135 : 0 : cons_filter_type = RTE_ETH_FILTER_TUNNEL;
3136 : :
3137 : 0 : return ret;
3138 : : }
3139 : :
3140 : : /* 1. Last in item should be NULL as range is not supported.
3141 : : * 2. Supported filter types: IMAC_IVLAN_TENID, IMAC_IVLAN,
3142 : : * IMAC_TENID, OMAC_TENID_IMAC and IMAC.
3143 : : * 3. Mask of fields which need to be matched should be
3144 : : * filled with 1.
3145 : : * 4. Mask of fields which needn't to be matched should be
3146 : : * filled with 0.
3147 : : */
3148 : : static int
3149 : 0 : i40e_flow_parse_nvgre_pattern(__rte_unused struct rte_eth_dev *dev,
3150 : : const struct rte_flow_item *pattern,
3151 : : struct rte_flow_error *error,
3152 : : struct i40e_tunnel_filter_conf *filter)
3153 : : {
3154 : : const struct rte_flow_item *item = pattern;
3155 : : const struct rte_flow_item_eth *eth_spec;
3156 : : const struct rte_flow_item_eth *eth_mask;
3157 : : const struct rte_flow_item_nvgre *nvgre_spec;
3158 : : const struct rte_flow_item_nvgre *nvgre_mask;
3159 : : const struct rte_flow_item_vlan *vlan_spec;
3160 : : const struct rte_flow_item_vlan *vlan_mask;
3161 : : enum rte_flow_item_type item_type;
3162 : : uint8_t filter_type = 0;
3163 : : bool is_tni_masked = 0;
3164 : 0 : uint8_t tni_mask[] = {0xFF, 0xFF, 0xFF};
3165 : : bool nvgre_flag = 0;
3166 : 0 : uint32_t tenant_id_be = 0;
3167 : : int ret;
3168 : :
3169 [ # # ]: 0 : for (; item->type != RTE_FLOW_ITEM_TYPE_END; item++) {
3170 [ # # ]: 0 : if (item->last) {
3171 : 0 : rte_flow_error_set(error, EINVAL,
3172 : : RTE_FLOW_ERROR_TYPE_ITEM,
3173 : : item,
3174 : : "Not support range");
3175 : 0 : return -rte_errno;
3176 : : }
3177 : : item_type = item->type;
3178 [ # # # # : 0 : switch (item_type) {
# # ]
3179 : 0 : case RTE_FLOW_ITEM_TYPE_ETH:
3180 : 0 : eth_spec = item->spec;
3181 : 0 : eth_mask = item->mask;
3182 : :
3183 : : /* Check if ETH item is used for place holder.
3184 : : * If yes, both spec and mask should be NULL.
3185 : : * If no, both spec and mask shouldn't be NULL.
3186 : : */
3187 [ # # ]: 0 : if ((!eth_spec && eth_mask) ||
3188 : : (eth_spec && !eth_mask)) {
3189 : 0 : rte_flow_error_set(error, EINVAL,
3190 : : RTE_FLOW_ERROR_TYPE_ITEM,
3191 : : item,
3192 : : "Invalid ether spec/mask");
3193 : 0 : return -rte_errno;
3194 : : }
3195 : :
3196 [ # # ]: 0 : if (eth_spec && eth_mask) {
3197 : : /* DST address of inner MAC shouldn't be masked.
3198 : : * SRC address of Inner MAC should be masked.
3199 : : */
3200 [ # # # # ]: 0 : if (!rte_is_broadcast_ether_addr(ð_mask->hdr.dst_addr) ||
3201 : 0 : !rte_is_zero_ether_addr(ð_mask->hdr.src_addr) ||
3202 [ # # ]: 0 : eth_mask->hdr.ether_type) {
3203 : 0 : rte_flow_error_set(error, EINVAL,
3204 : : RTE_FLOW_ERROR_TYPE_ITEM,
3205 : : item,
3206 : : "Invalid ether spec/mask");
3207 : 0 : return -rte_errno;
3208 : : }
3209 : :
3210 [ # # ]: 0 : if (!nvgre_flag) {
3211 : 0 : rte_memcpy(&filter->outer_mac,
3212 [ # # ]: 0 : ð_spec->hdr.dst_addr,
3213 : : RTE_ETHER_ADDR_LEN);
3214 : 0 : filter_type |= RTE_ETH_TUNNEL_FILTER_OMAC;
3215 : : } else {
3216 : 0 : rte_memcpy(&filter->inner_mac,
3217 [ # # ]: 0 : ð_spec->hdr.dst_addr,
3218 : : RTE_ETHER_ADDR_LEN);
3219 : 0 : filter_type |= RTE_ETH_TUNNEL_FILTER_IMAC;
3220 : : }
3221 : : }
3222 : :
3223 : : break;
3224 : 0 : case RTE_FLOW_ITEM_TYPE_VLAN:
3225 : 0 : vlan_spec = item->spec;
3226 : 0 : vlan_mask = item->mask;
3227 [ # # ]: 0 : if (!(vlan_spec && vlan_mask) ||
3228 [ # # ]: 0 : vlan_mask->hdr.eth_proto) {
3229 : 0 : rte_flow_error_set(error, EINVAL,
3230 : : RTE_FLOW_ERROR_TYPE_ITEM,
3231 : : item,
3232 : : "Invalid vlan item");
3233 : 0 : return -rte_errno;
3234 : : }
3235 : :
3236 : : if (vlan_spec && vlan_mask) {
3237 [ # # ]: 0 : if (vlan_mask->hdr.vlan_tci ==
3238 : : rte_cpu_to_be_16(I40E_VLAN_TCI_MASK))
3239 : 0 : filter->inner_vlan =
3240 [ # # ]: 0 : rte_be_to_cpu_16(vlan_spec->hdr.vlan_tci) &
3241 : : I40E_VLAN_TCI_MASK;
3242 : 0 : filter_type |= RTE_ETH_TUNNEL_FILTER_IVLAN;
3243 : : }
3244 : : break;
3245 : 0 : case RTE_FLOW_ITEM_TYPE_IPV4:
3246 : 0 : filter->ip_type = I40E_TUNNEL_IPTYPE_IPV4;
3247 : : /* IPv4 is used to describe protocol,
3248 : : * spec and mask should be NULL.
3249 : : */
3250 [ # # # # ]: 0 : if (item->spec || item->mask) {
3251 : 0 : rte_flow_error_set(error, EINVAL,
3252 : : RTE_FLOW_ERROR_TYPE_ITEM,
3253 : : item,
3254 : : "Invalid IPv4 item");
3255 : 0 : return -rte_errno;
3256 : : }
3257 : : break;
3258 : 0 : case RTE_FLOW_ITEM_TYPE_IPV6:
3259 : 0 : filter->ip_type = I40E_TUNNEL_IPTYPE_IPV6;
3260 : : /* IPv6 is used to describe protocol,
3261 : : * spec and mask should be NULL.
3262 : : */
3263 [ # # # # ]: 0 : if (item->spec || item->mask) {
3264 : 0 : rte_flow_error_set(error, EINVAL,
3265 : : RTE_FLOW_ERROR_TYPE_ITEM,
3266 : : item,
3267 : : "Invalid IPv6 item");
3268 : 0 : return -rte_errno;
3269 : : }
3270 : : break;
3271 : 0 : case RTE_FLOW_ITEM_TYPE_NVGRE:
3272 : 0 : nvgre_spec = item->spec;
3273 : 0 : nvgre_mask = item->mask;
3274 : : /* Check if NVGRE item is used to describe protocol.
3275 : : * If yes, both spec and mask should be NULL.
3276 : : * If no, both spec and mask shouldn't be NULL.
3277 : : */
3278 [ # # ]: 0 : if ((!nvgre_spec && nvgre_mask) ||
3279 : : (nvgre_spec && !nvgre_mask)) {
3280 : 0 : rte_flow_error_set(error, EINVAL,
3281 : : RTE_FLOW_ERROR_TYPE_ITEM,
3282 : : item,
3283 : : "Invalid NVGRE item");
3284 : 0 : return -rte_errno;
3285 : : }
3286 : :
3287 [ # # ]: 0 : if (nvgre_spec && nvgre_mask) {
3288 : : is_tni_masked =
3289 : 0 : !!memcmp(nvgre_mask->tni, tni_mask,
3290 : : RTE_DIM(tni_mask));
3291 [ # # ]: 0 : if (is_tni_masked) {
3292 : 0 : rte_flow_error_set(error, EINVAL,
3293 : : RTE_FLOW_ERROR_TYPE_ITEM,
3294 : : item,
3295 : : "Invalid TNI mask");
3296 : 0 : return -rte_errno;
3297 : : }
3298 [ # # ]: 0 : if (nvgre_mask->protocol &&
3299 : : nvgre_mask->protocol != 0xFFFF) {
3300 : 0 : rte_flow_error_set(error, EINVAL,
3301 : : RTE_FLOW_ERROR_TYPE_ITEM,
3302 : : item,
3303 : : "Invalid NVGRE item");
3304 : 0 : return -rte_errno;
3305 : : }
3306 [ # # # # ]: 0 : if (nvgre_mask->c_k_s_rsvd0_ver &&
3307 : : nvgre_mask->c_k_s_rsvd0_ver !=
3308 : : rte_cpu_to_be_16(0xFFFF)) {
3309 : 0 : rte_flow_error_set(error, EINVAL,
3310 : : RTE_FLOW_ERROR_TYPE_ITEM,
3311 : : item,
3312 : : "Invalid NVGRE item");
3313 : 0 : return -rte_errno;
3314 : : }
3315 [ # # ]: 0 : if (nvgre_spec->c_k_s_rsvd0_ver !=
3316 [ # # ]: 0 : rte_cpu_to_be_16(0x2000) &&
3317 : : nvgre_mask->c_k_s_rsvd0_ver) {
3318 : 0 : rte_flow_error_set(error, EINVAL,
3319 : : RTE_FLOW_ERROR_TYPE_ITEM,
3320 : : item,
3321 : : "Invalid NVGRE item");
3322 : 0 : return -rte_errno;
3323 : : }
3324 [ # # ]: 0 : if (nvgre_mask->protocol &&
3325 [ # # ]: 0 : nvgre_spec->protocol !=
3326 : : rte_cpu_to_be_16(0x6558)) {
3327 : 0 : rte_flow_error_set(error, EINVAL,
3328 : : RTE_FLOW_ERROR_TYPE_ITEM,
3329 : : item,
3330 : : "Invalid NVGRE item");
3331 : 0 : return -rte_errno;
3332 : : }
3333 : : rte_memcpy(((uint8_t *)&tenant_id_be + 1),
3334 : : nvgre_spec->tni, 3);
3335 : 0 : filter->tenant_id =
3336 [ # # ]: 0 : rte_be_to_cpu_32(tenant_id_be);
3337 : 0 : filter_type |= RTE_ETH_TUNNEL_FILTER_TENID;
3338 : : }
3339 : :
3340 : : nvgre_flag = 1;
3341 : : break;
3342 : : default:
3343 : : break;
3344 : : }
3345 : : }
3346 : :
3347 : : ret = i40e_check_tunnel_filter_type(filter_type);
3348 [ # # ]: 0 : if (ret < 0) {
3349 : 0 : rte_flow_error_set(error, EINVAL,
3350 : : RTE_FLOW_ERROR_TYPE_ITEM,
3351 : : NULL,
3352 : : "Invalid filter type");
3353 : 0 : return -rte_errno;
3354 : : }
3355 : 0 : filter->filter_type = filter_type;
3356 : :
3357 : 0 : filter->tunnel_type = I40E_TUNNEL_TYPE_NVGRE;
3358 : :
3359 : 0 : return 0;
3360 : : }
3361 : :
3362 : : static int
3363 : 0 : i40e_flow_parse_nvgre_filter(struct rte_eth_dev *dev,
3364 : : const struct rte_flow_attr *attr,
3365 : : const struct rte_flow_item pattern[],
3366 : : const struct rte_flow_action actions[],
3367 : : struct rte_flow_error *error,
3368 : : union i40e_filter_t *filter)
3369 : : {
3370 : 0 : struct i40e_tunnel_filter_conf *tunnel_filter =
3371 : : &filter->consistent_tunnel_filter;
3372 : : int ret;
3373 : :
3374 : 0 : ret = i40e_flow_parse_nvgre_pattern(dev, pattern,
3375 : : error, tunnel_filter);
3376 [ # # ]: 0 : if (ret)
3377 : : return ret;
3378 : :
3379 : 0 : ret = i40e_flow_parse_tunnel_action(dev, actions, error, tunnel_filter);
3380 [ # # ]: 0 : if (ret)
3381 : : return ret;
3382 : :
3383 : 0 : ret = i40e_flow_parse_attr(attr, error);
3384 [ # # ]: 0 : if (ret)
3385 : : return ret;
3386 : :
3387 : 0 : cons_filter_type = RTE_ETH_FILTER_TUNNEL;
3388 : :
3389 : 0 : return ret;
3390 : : }
3391 : :
3392 : : /* 1. Last in item should be NULL as range is not supported.
3393 : : * 2. Supported filter types: MPLS label.
3394 : : * 3. Mask of fields which need to be matched should be
3395 : : * filled with 1.
3396 : : * 4. Mask of fields which needn't to be matched should be
3397 : : * filled with 0.
3398 : : */
3399 : : static int
3400 : 0 : i40e_flow_parse_mpls_pattern(__rte_unused struct rte_eth_dev *dev,
3401 : : const struct rte_flow_item *pattern,
3402 : : struct rte_flow_error *error,
3403 : : struct i40e_tunnel_filter_conf *filter)
3404 : : {
3405 : : const struct rte_flow_item *item = pattern;
3406 : : const struct rte_flow_item_mpls *mpls_spec;
3407 : : const struct rte_flow_item_mpls *mpls_mask;
3408 : : enum rte_flow_item_type item_type;
3409 : : bool is_mplsoudp = 0; /* 1 - MPLSoUDP, 0 - MPLSoGRE */
3410 : 0 : const uint8_t label_mask[3] = {0xFF, 0xFF, 0xF0};
3411 : 0 : uint32_t label_be = 0;
3412 : :
3413 [ # # ]: 0 : for (; item->type != RTE_FLOW_ITEM_TYPE_END; item++) {
3414 [ # # ]: 0 : if (item->last) {
3415 : 0 : rte_flow_error_set(error, EINVAL,
3416 : : RTE_FLOW_ERROR_TYPE_ITEM,
3417 : : item,
3418 : : "Not support range");
3419 : 0 : return -rte_errno;
3420 : : }
3421 : : item_type = item->type;
3422 [ # # # # : 0 : switch (item_type) {
# # # ]
3423 : 0 : case RTE_FLOW_ITEM_TYPE_ETH:
3424 [ # # # # ]: 0 : if (item->spec || item->mask) {
3425 : 0 : rte_flow_error_set(error, EINVAL,
3426 : : RTE_FLOW_ERROR_TYPE_ITEM,
3427 : : item,
3428 : : "Invalid ETH item");
3429 : 0 : return -rte_errno;
3430 : : }
3431 : : break;
3432 : 0 : case RTE_FLOW_ITEM_TYPE_IPV4:
3433 : 0 : filter->ip_type = I40E_TUNNEL_IPTYPE_IPV4;
3434 : : /* IPv4 is used to describe protocol,
3435 : : * spec and mask should be NULL.
3436 : : */
3437 [ # # # # ]: 0 : if (item->spec || item->mask) {
3438 : 0 : rte_flow_error_set(error, EINVAL,
3439 : : RTE_FLOW_ERROR_TYPE_ITEM,
3440 : : item,
3441 : : "Invalid IPv4 item");
3442 : 0 : return -rte_errno;
3443 : : }
3444 : : break;
3445 : 0 : case RTE_FLOW_ITEM_TYPE_IPV6:
3446 : 0 : filter->ip_type = I40E_TUNNEL_IPTYPE_IPV6;
3447 : : /* IPv6 is used to describe protocol,
3448 : : * spec and mask should be NULL.
3449 : : */
3450 [ # # # # ]: 0 : if (item->spec || item->mask) {
3451 : 0 : rte_flow_error_set(error, EINVAL,
3452 : : RTE_FLOW_ERROR_TYPE_ITEM,
3453 : : item,
3454 : : "Invalid IPv6 item");
3455 : 0 : return -rte_errno;
3456 : : }
3457 : : break;
3458 : 0 : case RTE_FLOW_ITEM_TYPE_UDP:
3459 : : /* UDP is used to describe protocol,
3460 : : * spec and mask should be NULL.
3461 : : */
3462 [ # # # # ]: 0 : if (item->spec || item->mask) {
3463 : 0 : rte_flow_error_set(error, EINVAL,
3464 : : RTE_FLOW_ERROR_TYPE_ITEM,
3465 : : item,
3466 : : "Invalid UDP item");
3467 : 0 : return -rte_errno;
3468 : : }
3469 : : is_mplsoudp = 1;
3470 : : break;
3471 : 0 : case RTE_FLOW_ITEM_TYPE_GRE:
3472 : : /* GRE is used to describe protocol,
3473 : : * spec and mask should be NULL.
3474 : : */
3475 [ # # # # ]: 0 : if (item->spec || item->mask) {
3476 : 0 : rte_flow_error_set(error, EINVAL,
3477 : : RTE_FLOW_ERROR_TYPE_ITEM,
3478 : : item,
3479 : : "Invalid GRE item");
3480 : 0 : return -rte_errno;
3481 : : }
3482 : : break;
3483 : 0 : case RTE_FLOW_ITEM_TYPE_MPLS:
3484 : 0 : mpls_spec = item->spec;
3485 : 0 : mpls_mask = item->mask;
3486 : :
3487 [ # # ]: 0 : if (!mpls_spec || !mpls_mask) {
3488 : 0 : rte_flow_error_set(error, EINVAL,
3489 : : RTE_FLOW_ERROR_TYPE_ITEM,
3490 : : item,
3491 : : "Invalid MPLS item");
3492 : 0 : return -rte_errno;
3493 : : }
3494 : :
3495 [ # # ]: 0 : if (memcmp(mpls_mask->label_tc_s, label_mask, 3)) {
3496 : 0 : rte_flow_error_set(error, EINVAL,
3497 : : RTE_FLOW_ERROR_TYPE_ITEM,
3498 : : item,
3499 : : "Invalid MPLS label mask");
3500 : 0 : return -rte_errno;
3501 : : }
3502 : : rte_memcpy(((uint8_t *)&label_be + 1),
3503 : : mpls_spec->label_tc_s, 3);
3504 [ # # ]: 0 : filter->tenant_id = rte_be_to_cpu_32(label_be) >> 4;
3505 : 0 : break;
3506 : : default:
3507 : : break;
3508 : : }
3509 : : }
3510 : :
3511 [ # # ]: 0 : if (is_mplsoudp)
3512 : 0 : filter->tunnel_type = I40E_TUNNEL_TYPE_MPLSoUDP;
3513 : : else
3514 : 0 : filter->tunnel_type = I40E_TUNNEL_TYPE_MPLSoGRE;
3515 : :
3516 : : return 0;
3517 : : }
3518 : :
3519 : : static int
3520 : 0 : i40e_flow_parse_mpls_filter(struct rte_eth_dev *dev,
3521 : : const struct rte_flow_attr *attr,
3522 : : const struct rte_flow_item pattern[],
3523 : : const struct rte_flow_action actions[],
3524 : : struct rte_flow_error *error,
3525 : : union i40e_filter_t *filter)
3526 : : {
3527 : 0 : struct i40e_tunnel_filter_conf *tunnel_filter =
3528 : : &filter->consistent_tunnel_filter;
3529 : : int ret;
3530 : :
3531 : 0 : ret = i40e_flow_parse_mpls_pattern(dev, pattern,
3532 : : error, tunnel_filter);
3533 [ # # ]: 0 : if (ret)
3534 : : return ret;
3535 : :
3536 : 0 : ret = i40e_flow_parse_tunnel_action(dev, actions, error, tunnel_filter);
3537 [ # # ]: 0 : if (ret)
3538 : : return ret;
3539 : :
3540 : 0 : ret = i40e_flow_parse_attr(attr, error);
3541 [ # # ]: 0 : if (ret)
3542 : : return ret;
3543 : :
3544 : 0 : cons_filter_type = RTE_ETH_FILTER_TUNNEL;
3545 : :
3546 : 0 : return ret;
3547 : : }
3548 : :
3549 : : /* 1. Last in item should be NULL as range is not supported.
3550 : : * 2. Supported filter types: GTP TEID.
3551 : : * 3. Mask of fields which need to be matched should be
3552 : : * filled with 1.
3553 : : * 4. Mask of fields which needn't to be matched should be
3554 : : * filled with 0.
3555 : : * 5. GTP profile supports GTPv1 only.
3556 : : * 6. GTP-C response message ('source_port' = 2123) is not supported.
3557 : : */
3558 : : static int
3559 : 0 : i40e_flow_parse_gtp_pattern(struct rte_eth_dev *dev,
3560 : : const struct rte_flow_item *pattern,
3561 : : struct rte_flow_error *error,
3562 : : struct i40e_tunnel_filter_conf *filter)
3563 : : {
3564 : 0 : struct i40e_pf *pf = I40E_DEV_PRIVATE_TO_PF(dev->data->dev_private);
3565 : : const struct rte_flow_item *item = pattern;
3566 : : const struct rte_flow_item_gtp *gtp_spec;
3567 : : const struct rte_flow_item_gtp *gtp_mask;
3568 : : enum rte_flow_item_type item_type;
3569 : :
3570 [ # # ]: 0 : if (!pf->gtp_support) {
3571 : 0 : rte_flow_error_set(error, EINVAL,
3572 : : RTE_FLOW_ERROR_TYPE_ITEM,
3573 : : item,
3574 : : "GTP is not supported by default.");
3575 : 0 : return -rte_errno;
3576 : : }
3577 : :
3578 [ # # ]: 0 : for (; item->type != RTE_FLOW_ITEM_TYPE_END; item++) {
3579 [ # # ]: 0 : if (item->last) {
3580 : 0 : rte_flow_error_set(error, EINVAL,
3581 : : RTE_FLOW_ERROR_TYPE_ITEM,
3582 : : item,
3583 : : "Not support range");
3584 : 0 : return -rte_errno;
3585 : : }
3586 : : item_type = item->type;
3587 [ # # # # : 0 : switch (item_type) {
# ]
3588 : 0 : case RTE_FLOW_ITEM_TYPE_ETH:
3589 [ # # # # ]: 0 : if (item->spec || item->mask) {
3590 : 0 : rte_flow_error_set(error, EINVAL,
3591 : : RTE_FLOW_ERROR_TYPE_ITEM,
3592 : : item,
3593 : : "Invalid ETH item");
3594 : 0 : return -rte_errno;
3595 : : }
3596 : : break;
3597 : 0 : case RTE_FLOW_ITEM_TYPE_IPV4:
3598 : 0 : filter->ip_type = I40E_TUNNEL_IPTYPE_IPV4;
3599 : : /* IPv4 is used to describe protocol,
3600 : : * spec and mask should be NULL.
3601 : : */
3602 [ # # # # ]: 0 : if (item->spec || item->mask) {
3603 : 0 : rte_flow_error_set(error, EINVAL,
3604 : : RTE_FLOW_ERROR_TYPE_ITEM,
3605 : : item,
3606 : : "Invalid IPv4 item");
3607 : 0 : return -rte_errno;
3608 : : }
3609 : : break;
3610 : 0 : case RTE_FLOW_ITEM_TYPE_UDP:
3611 [ # # # # ]: 0 : if (item->spec || item->mask) {
3612 : 0 : rte_flow_error_set(error, EINVAL,
3613 : : RTE_FLOW_ERROR_TYPE_ITEM,
3614 : : item,
3615 : : "Invalid UDP item");
3616 : 0 : return -rte_errno;
3617 : : }
3618 : : break;
3619 : 0 : case RTE_FLOW_ITEM_TYPE_GTPC:
3620 : : case RTE_FLOW_ITEM_TYPE_GTPU:
3621 : 0 : gtp_spec = item->spec;
3622 : 0 : gtp_mask = item->mask;
3623 : :
3624 [ # # ]: 0 : if (!gtp_spec || !gtp_mask) {
3625 : 0 : rte_flow_error_set(error, EINVAL,
3626 : : RTE_FLOW_ERROR_TYPE_ITEM,
3627 : : item,
3628 : : "Invalid GTP item");
3629 : 0 : return -rte_errno;
3630 : : }
3631 : :
3632 : 0 : if (gtp_mask->hdr.gtp_hdr_info ||
3633 [ # # ]: 0 : gtp_mask->hdr.msg_type ||
3634 : 0 : gtp_mask->hdr.plen ||
3635 [ # # ]: 0 : gtp_mask->hdr.teid != UINT32_MAX) {
3636 : 0 : rte_flow_error_set(error, EINVAL,
3637 : : RTE_FLOW_ERROR_TYPE_ITEM,
3638 : : item,
3639 : : "Invalid GTP mask");
3640 : 0 : return -rte_errno;
3641 : : }
3642 : :
3643 [ # # ]: 0 : if (item_type == RTE_FLOW_ITEM_TYPE_GTPC)
3644 : 0 : filter->tunnel_type = I40E_TUNNEL_TYPE_GTPC;
3645 : : else if (item_type == RTE_FLOW_ITEM_TYPE_GTPU)
3646 : 0 : filter->tunnel_type = I40E_TUNNEL_TYPE_GTPU;
3647 : :
3648 [ # # ]: 0 : filter->tenant_id = rte_be_to_cpu_32(gtp_spec->hdr.teid);
3649 : :
3650 : 0 : break;
3651 : : default:
3652 : : break;
3653 : : }
3654 : : }
3655 : :
3656 : : return 0;
3657 : : }
3658 : :
3659 : : static int
3660 : 0 : i40e_flow_parse_gtp_filter(struct rte_eth_dev *dev,
3661 : : const struct rte_flow_attr *attr,
3662 : : const struct rte_flow_item pattern[],
3663 : : const struct rte_flow_action actions[],
3664 : : struct rte_flow_error *error,
3665 : : union i40e_filter_t *filter)
3666 : : {
3667 : 0 : struct i40e_tunnel_filter_conf *tunnel_filter =
3668 : : &filter->consistent_tunnel_filter;
3669 : : int ret;
3670 : :
3671 : 0 : ret = i40e_flow_parse_gtp_pattern(dev, pattern,
3672 : : error, tunnel_filter);
3673 [ # # ]: 0 : if (ret)
3674 : : return ret;
3675 : :
3676 : 0 : ret = i40e_flow_parse_tunnel_action(dev, actions, error, tunnel_filter);
3677 [ # # ]: 0 : if (ret)
3678 : : return ret;
3679 : :
3680 : 0 : ret = i40e_flow_parse_attr(attr, error);
3681 [ # # ]: 0 : if (ret)
3682 : : return ret;
3683 : :
3684 : 0 : cons_filter_type = RTE_ETH_FILTER_TUNNEL;
3685 : :
3686 : 0 : return ret;
3687 : : }
3688 : :
3689 : : /* 1. Last in item should be NULL as range is not supported.
3690 : : * 2. Supported filter types: QINQ.
3691 : : * 3. Mask of fields which need to be matched should be
3692 : : * filled with 1.
3693 : : * 4. Mask of fields which needn't to be matched should be
3694 : : * filled with 0.
3695 : : */
3696 : : static int
3697 : 0 : i40e_flow_parse_qinq_pattern(__rte_unused struct rte_eth_dev *dev,
3698 : : const struct rte_flow_item *pattern,
3699 : : struct rte_flow_error *error,
3700 : : struct i40e_tunnel_filter_conf *filter)
3701 : : {
3702 : : const struct rte_flow_item *item = pattern;
3703 : : const struct rte_flow_item_vlan *vlan_spec = NULL;
3704 : : const struct rte_flow_item_vlan *vlan_mask = NULL;
3705 : : const struct rte_flow_item_vlan *i_vlan_spec = NULL;
3706 : : const struct rte_flow_item_vlan *i_vlan_mask = NULL;
3707 : : const struct rte_flow_item_vlan *o_vlan_spec = NULL;
3708 : : const struct rte_flow_item_vlan *o_vlan_mask = NULL;
3709 : :
3710 : : enum rte_flow_item_type item_type;
3711 : : bool vlan_flag = 0;
3712 : :
3713 [ # # ]: 0 : for (; item->type != RTE_FLOW_ITEM_TYPE_END; item++) {
3714 [ # # ]: 0 : if (item->last) {
3715 : 0 : rte_flow_error_set(error, EINVAL,
3716 : : RTE_FLOW_ERROR_TYPE_ITEM,
3717 : : item,
3718 : : "Not support range");
3719 : 0 : return -rte_errno;
3720 : : }
3721 : : item_type = item->type;
3722 [ # # # ]: 0 : switch (item_type) {
3723 : 0 : case RTE_FLOW_ITEM_TYPE_ETH:
3724 [ # # # # ]: 0 : if (item->spec || item->mask) {
3725 : 0 : rte_flow_error_set(error, EINVAL,
3726 : : RTE_FLOW_ERROR_TYPE_ITEM,
3727 : : item,
3728 : : "Invalid ETH item");
3729 : 0 : return -rte_errno;
3730 : : }
3731 : : break;
3732 : 0 : case RTE_FLOW_ITEM_TYPE_VLAN:
3733 : 0 : vlan_spec = item->spec;
3734 : 0 : vlan_mask = item->mask;
3735 : :
3736 [ # # ]: 0 : if (!(vlan_spec && vlan_mask) ||
3737 [ # # ]: 0 : vlan_mask->hdr.eth_proto) {
3738 : 0 : rte_flow_error_set(error, EINVAL,
3739 : : RTE_FLOW_ERROR_TYPE_ITEM,
3740 : : item,
3741 : : "Invalid vlan item");
3742 : 0 : return -rte_errno;
3743 : : }
3744 : :
3745 [ # # ]: 0 : if (!vlan_flag) {
3746 : : o_vlan_spec = vlan_spec;
3747 : : o_vlan_mask = vlan_mask;
3748 : : vlan_flag = 1;
3749 : : } else {
3750 : : i_vlan_spec = vlan_spec;
3751 : : i_vlan_mask = vlan_mask;
3752 : : vlan_flag = 0;
3753 : : }
3754 : : break;
3755 : :
3756 : : default:
3757 : : break;
3758 : : }
3759 : : }
3760 : :
3761 : : /* Get filter specification */
3762 [ # # ]: 0 : if (o_vlan_mask != NULL && i_vlan_mask != NULL) {
3763 [ # # ]: 0 : filter->outer_vlan = rte_be_to_cpu_16(o_vlan_spec->hdr.vlan_tci);
3764 [ # # ]: 0 : filter->inner_vlan = rte_be_to_cpu_16(i_vlan_spec->hdr.vlan_tci);
3765 : : } else {
3766 : 0 : rte_flow_error_set(error, EINVAL,
3767 : : RTE_FLOW_ERROR_TYPE_ITEM,
3768 : : NULL,
3769 : : "Invalid filter type");
3770 : 0 : return -rte_errno;
3771 : : }
3772 : :
3773 : 0 : filter->tunnel_type = I40E_TUNNEL_TYPE_QINQ;
3774 : 0 : return 0;
3775 : : }
3776 : :
3777 : : static int
3778 : 0 : i40e_flow_parse_qinq_filter(struct rte_eth_dev *dev,
3779 : : const struct rte_flow_attr *attr,
3780 : : const struct rte_flow_item pattern[],
3781 : : const struct rte_flow_action actions[],
3782 : : struct rte_flow_error *error,
3783 : : union i40e_filter_t *filter)
3784 : : {
3785 : 0 : struct i40e_tunnel_filter_conf *tunnel_filter =
3786 : : &filter->consistent_tunnel_filter;
3787 : : int ret;
3788 : :
3789 : 0 : ret = i40e_flow_parse_qinq_pattern(dev, pattern,
3790 : : error, tunnel_filter);
3791 [ # # ]: 0 : if (ret)
3792 : : return ret;
3793 : :
3794 : 0 : ret = i40e_flow_parse_tunnel_action(dev, actions, error, tunnel_filter);
3795 [ # # ]: 0 : if (ret)
3796 : : return ret;
3797 : :
3798 : 0 : ret = i40e_flow_parse_attr(attr, error);
3799 [ # # ]: 0 : if (ret)
3800 : : return ret;
3801 : :
3802 : 0 : cons_filter_type = RTE_ETH_FILTER_TUNNEL;
3803 : :
3804 : 0 : return ret;
3805 : : }
3806 : :
3807 : : static int
3808 : 0 : i40e_flow_validate(struct rte_eth_dev *dev,
3809 : : const struct rte_flow_attr *attr,
3810 : : const struct rte_flow_item pattern[],
3811 : : const struct rte_flow_action actions[],
3812 : : struct rte_flow_error *error)
3813 : : {
3814 : : struct rte_flow_item *items; /* internal pattern w/o VOID items */
3815 : : parse_filter_t parse_filter;
3816 : : uint32_t item_num = 0; /* non-void item number of pattern*/
3817 : 0 : uint32_t i = 0;
3818 : : bool flag = false;
3819 : : int ret = I40E_NOT_SUPPORTED;
3820 : :
3821 [ # # ]: 0 : if (!pattern) {
3822 : 0 : rte_flow_error_set(error, EINVAL, RTE_FLOW_ERROR_TYPE_ITEM_NUM,
3823 : : NULL, "NULL pattern.");
3824 : 0 : return -rte_errno;
3825 : : }
3826 : :
3827 [ # # ]: 0 : if (!actions) {
3828 : 0 : rte_flow_error_set(error, EINVAL,
3829 : : RTE_FLOW_ERROR_TYPE_ACTION_NUM,
3830 : : NULL, "NULL action.");
3831 : 0 : return -rte_errno;
3832 : : }
3833 : :
3834 [ # # ]: 0 : if (!attr) {
3835 : 0 : rte_flow_error_set(error, EINVAL,
3836 : : RTE_FLOW_ERROR_TYPE_ATTR,
3837 : : NULL, "NULL attribute.");
3838 : 0 : return -rte_errno;
3839 : : }
3840 : : memset(&cons_filter, 0, sizeof(cons_filter));
3841 : :
3842 : : /* Get the non-void item of action */
3843 [ # # ]: 0 : while ((actions + i)->type == RTE_FLOW_ACTION_TYPE_VOID)
3844 : 0 : i++;
3845 : :
3846 [ # # ]: 0 : if ((actions + i)->type == RTE_FLOW_ACTION_TYPE_RSS) {
3847 : 0 : ret = i40e_flow_parse_attr(attr, error);
3848 [ # # ]: 0 : if (ret)
3849 : : return ret;
3850 : :
3851 : 0 : cons_filter_type = RTE_ETH_FILTER_HASH;
3852 : 0 : return i40e_hash_parse(dev, pattern, actions + i,
3853 : : &cons_filter.rss_conf, error);
3854 : : }
3855 : :
3856 : 0 : i = 0;
3857 : : /* Get the non-void item number of pattern */
3858 [ # # ]: 0 : while ((pattern + i)->type != RTE_FLOW_ITEM_TYPE_END) {
3859 [ # # ]: 0 : if ((pattern + i)->type != RTE_FLOW_ITEM_TYPE_VOID)
3860 : 0 : item_num++;
3861 : 0 : i++;
3862 : : }
3863 : 0 : item_num++;
3864 : :
3865 [ # # ]: 0 : if (item_num <= ARRAY_SIZE(g_items)) {
3866 : : items = g_items;
3867 : : } else {
3868 : 0 : items = rte_zmalloc("i40e_pattern",
3869 : : item_num * sizeof(struct rte_flow_item), 0);
3870 [ # # ]: 0 : if (!items) {
3871 : 0 : rte_flow_error_set(error, ENOMEM,
3872 : : RTE_FLOW_ERROR_TYPE_ITEM_NUM,
3873 : : NULL,
3874 : : "No memory for PMD internal items.");
3875 : 0 : return -ENOMEM;
3876 : : }
3877 : : }
3878 : :
3879 : 0 : i40e_pattern_skip_void_item(items, pattern);
3880 : :
3881 : 0 : i = 0;
3882 : : do {
3883 : 0 : parse_filter = i40e_find_parse_filter_func(items, &i);
3884 [ # # ]: 0 : if (!parse_filter && !flag) {
3885 : 0 : rte_flow_error_set(error, EINVAL,
3886 : : RTE_FLOW_ERROR_TYPE_ITEM,
3887 : : pattern, "Unsupported pattern");
3888 : :
3889 [ # # ]: 0 : if (items != g_items)
3890 : 0 : rte_free(items);
3891 : 0 : return -rte_errno;
3892 : : }
3893 : :
3894 [ # # ]: 0 : if (parse_filter)
3895 : 0 : ret = parse_filter(dev, attr, items, actions,
3896 : : error, &cons_filter);
3897 : :
3898 : : flag = true;
3899 [ # # # # ]: 0 : } while ((ret < 0) && (i < RTE_DIM(i40e_supported_patterns)));
3900 : :
3901 [ # # ]: 0 : if (items != g_items)
3902 : 0 : rte_free(items);
3903 : :
3904 : : return ret;
3905 : : }
3906 : :
3907 : : static struct rte_flow *
3908 : 0 : i40e_flow_create(struct rte_eth_dev *dev,
3909 : : const struct rte_flow_attr *attr,
3910 : : const struct rte_flow_item pattern[],
3911 : : const struct rte_flow_action actions[],
3912 : : struct rte_flow_error *error)
3913 : : {
3914 : 0 : struct i40e_pf *pf = I40E_DEV_PRIVATE_TO_PF(dev->data->dev_private);
3915 : : struct rte_flow *flow = NULL;
3916 : 0 : struct i40e_fdir_info *fdir_info = &pf->fdir;
3917 : : int ret;
3918 : :
3919 : 0 : ret = i40e_flow_validate(dev, attr, pattern, actions, error);
3920 [ # # ]: 0 : if (ret < 0)
3921 : : return NULL;
3922 : :
3923 [ # # ]: 0 : if (cons_filter_type == RTE_ETH_FILTER_FDIR) {
3924 : 0 : flow = i40e_fdir_entry_pool_get(fdir_info);
3925 [ # # ]: 0 : if (flow == NULL) {
3926 : 0 : rte_flow_error_set(error, ENOBUFS,
3927 : : RTE_FLOW_ERROR_TYPE_HANDLE, NULL,
3928 : : "Fdir space full");
3929 : :
3930 : 0 : return flow;
3931 : : }
3932 : : } else {
3933 : 0 : flow = rte_zmalloc("i40e_flow", sizeof(struct rte_flow), 0);
3934 [ # # ]: 0 : if (!flow) {
3935 : 0 : rte_flow_error_set(error, ENOMEM,
3936 : : RTE_FLOW_ERROR_TYPE_HANDLE, NULL,
3937 : : "Failed to allocate memory");
3938 : 0 : return flow;
3939 : : }
3940 : : }
3941 : :
3942 [ # # # # : 0 : switch (cons_filter_type) {
# ]
3943 : 0 : case RTE_ETH_FILTER_ETHERTYPE:
3944 : 0 : ret = i40e_ethertype_filter_set(pf,
3945 : : &cons_filter.ethertype_filter, 1);
3946 [ # # ]: 0 : if (ret)
3947 : 0 : goto free_flow;
3948 : 0 : flow->rule = TAILQ_LAST(&pf->ethertype.ethertype_list,
3949 : : i40e_ethertype_filter_list);
3950 : 0 : break;
3951 : 0 : case RTE_ETH_FILTER_FDIR:
3952 : 0 : ret = i40e_flow_add_del_fdir_filter(dev,
3953 : : &cons_filter.fdir_filter, 1);
3954 [ # # ]: 0 : if (ret)
3955 : 0 : goto free_flow;
3956 : 0 : flow->rule = TAILQ_LAST(&pf->fdir.fdir_list,
3957 : : i40e_fdir_filter_list);
3958 : 0 : break;
3959 : 0 : case RTE_ETH_FILTER_TUNNEL:
3960 : 0 : ret = i40e_dev_consistent_tunnel_filter_set(pf,
3961 : : &cons_filter.consistent_tunnel_filter, 1);
3962 [ # # ]: 0 : if (ret)
3963 : 0 : goto free_flow;
3964 : 0 : flow->rule = TAILQ_LAST(&pf->tunnel.tunnel_list,
3965 : : i40e_tunnel_filter_list);
3966 : 0 : break;
3967 : 0 : case RTE_ETH_FILTER_HASH:
3968 : 0 : ret = i40e_hash_filter_create(pf, &cons_filter.rss_conf);
3969 [ # # ]: 0 : if (ret)
3970 : 0 : goto free_flow;
3971 : 0 : flow->rule = TAILQ_LAST(&pf->rss_config_list,
3972 : : i40e_rss_conf_list);
3973 : 0 : break;
3974 : 0 : default:
3975 : 0 : goto free_flow;
3976 : : }
3977 : :
3978 : 0 : flow->filter_type = cons_filter_type;
3979 : 0 : TAILQ_INSERT_TAIL(&pf->flow_list, flow, node);
3980 : 0 : return flow;
3981 : :
3982 : 0 : free_flow:
3983 : 0 : rte_flow_error_set(error, -ret,
3984 : : RTE_FLOW_ERROR_TYPE_HANDLE, NULL,
3985 : : "Failed to create flow.");
3986 : :
3987 [ # # ]: 0 : if (cons_filter_type != RTE_ETH_FILTER_FDIR)
3988 : 0 : rte_free(flow);
3989 : : else
3990 : 0 : i40e_fdir_entry_pool_put(fdir_info, flow);
3991 : :
3992 : : return NULL;
3993 : : }
3994 : :
3995 : : static int
3996 : 0 : i40e_flow_destroy(struct rte_eth_dev *dev,
3997 : : struct rte_flow *flow,
3998 : : struct rte_flow_error *error)
3999 : : {
4000 : 0 : struct i40e_pf *pf = I40E_DEV_PRIVATE_TO_PF(dev->data->dev_private);
4001 : 0 : enum rte_filter_type filter_type = flow->filter_type;
4002 : 0 : struct i40e_fdir_info *fdir_info = &pf->fdir;
4003 : : int ret = 0;
4004 : :
4005 [ # # # # : 0 : switch (filter_type) {
# ]
4006 : 0 : case RTE_ETH_FILTER_ETHERTYPE:
4007 : 0 : ret = i40e_flow_destroy_ethertype_filter(pf,
4008 : 0 : (struct i40e_ethertype_filter *)flow->rule);
4009 : 0 : break;
4010 : 0 : case RTE_ETH_FILTER_TUNNEL:
4011 : 0 : ret = i40e_flow_destroy_tunnel_filter(pf,
4012 : 0 : (struct i40e_tunnel_filter *)flow->rule);
4013 : 0 : break;
4014 : 0 : case RTE_ETH_FILTER_FDIR:
4015 : 0 : ret = i40e_flow_add_del_fdir_filter(dev,
4016 : 0 : &((struct i40e_fdir_filter *)flow->rule)->fdir,
4017 : : 0);
4018 : :
4019 : : /* If the last flow is destroyed, disable fdir. */
4020 [ # # # # ]: 0 : if (!ret && TAILQ_EMPTY(&pf->fdir.fdir_list)) {
4021 : 0 : i40e_fdir_rx_proc_enable(dev, 0);
4022 : : }
4023 : : break;
4024 : 0 : case RTE_ETH_FILTER_HASH:
4025 : 0 : ret = i40e_hash_filter_destroy(pf, flow->rule);
4026 : 0 : break;
4027 : 0 : default:
4028 : 0 : PMD_DRV_LOG(WARNING, "Filter type (%d) not supported",
4029 : : filter_type);
4030 : : ret = -EINVAL;
4031 : : break;
4032 : : }
4033 : :
4034 [ # # ]: 0 : if (!ret) {
4035 [ # # ]: 0 : TAILQ_REMOVE(&pf->flow_list, flow, node);
4036 [ # # ]: 0 : if (filter_type == RTE_ETH_FILTER_FDIR)
4037 : 0 : i40e_fdir_entry_pool_put(fdir_info, flow);
4038 : : else
4039 : 0 : rte_free(flow);
4040 : :
4041 : : } else
4042 : 0 : rte_flow_error_set(error, -ret,
4043 : : RTE_FLOW_ERROR_TYPE_HANDLE, NULL,
4044 : : "Failed to destroy flow.");
4045 : :
4046 : 0 : return ret;
4047 : : }
4048 : :
4049 : : static int
4050 : 0 : i40e_flow_destroy_ethertype_filter(struct i40e_pf *pf,
4051 : : struct i40e_ethertype_filter *filter)
4052 : : {
4053 : 0 : struct i40e_hw *hw = I40E_PF_TO_HW(pf);
4054 : 0 : struct i40e_ethertype_rule *ethertype_rule = &pf->ethertype;
4055 : : struct i40e_ethertype_filter *node;
4056 : : struct i40e_control_filter_stats stats;
4057 : : uint16_t flags = 0;
4058 : : int ret = 0;
4059 : :
4060 [ # # ]: 0 : if (!(filter->flags & RTE_ETHTYPE_FLAGS_MAC))
4061 : : flags |= I40E_AQC_ADD_CONTROL_PACKET_FLAGS_IGNORE_MAC;
4062 [ # # ]: 0 : if (filter->flags & RTE_ETHTYPE_FLAGS_DROP)
4063 : 0 : flags |= I40E_AQC_ADD_CONTROL_PACKET_FLAGS_DROP;
4064 : 0 : flags |= I40E_AQC_ADD_CONTROL_PACKET_FLAGS_TO_QUEUE;
4065 : :
4066 : : memset(&stats, 0, sizeof(stats));
4067 : 0 : ret = i40e_aq_add_rem_control_packet_filter(hw,
4068 : 0 : filter->input.mac_addr.addr_bytes,
4069 : 0 : filter->input.ether_type,
4070 : 0 : flags, pf->main_vsi->seid,
4071 : 0 : filter->queue, 0, &stats, NULL);
4072 [ # # ]: 0 : if (ret < 0)
4073 : : return ret;
4074 : :
4075 : 0 : node = i40e_sw_ethertype_filter_lookup(ethertype_rule, &filter->input);
4076 [ # # ]: 0 : if (!node)
4077 : : return -EINVAL;
4078 : :
4079 : 0 : ret = i40e_sw_ethertype_filter_del(pf, &node->input);
4080 : :
4081 : 0 : return ret;
4082 : : }
4083 : :
4084 : : static int
4085 : 0 : i40e_flow_destroy_tunnel_filter(struct i40e_pf *pf,
4086 : : struct i40e_tunnel_filter *filter)
4087 : : {
4088 : 0 : struct i40e_hw *hw = I40E_PF_TO_HW(pf);
4089 : : struct i40e_vsi *vsi;
4090 : : struct i40e_pf_vf *vf;
4091 : : struct i40e_aqc_cloud_filters_element_bb cld_filter;
4092 [ # # ]: 0 : struct i40e_tunnel_rule *tunnel_rule = &pf->tunnel;
4093 : : struct i40e_tunnel_filter *node;
4094 : : bool big_buffer = 0;
4095 : : int ret = 0;
4096 : :
4097 : : memset(&cld_filter, 0, sizeof(cld_filter));
4098 : : rte_ether_addr_copy((struct rte_ether_addr *)&filter->input.outer_mac,
4099 : : (struct rte_ether_addr *)&cld_filter.element.outer_mac);
4100 : : rte_ether_addr_copy((struct rte_ether_addr *)&filter->input.inner_mac,
4101 : : (struct rte_ether_addr *)&cld_filter.element.inner_mac);
4102 : 0 : cld_filter.element.inner_vlan = filter->input.inner_vlan;
4103 : 0 : cld_filter.element.flags = filter->input.flags;
4104 : 0 : cld_filter.element.tenant_id = filter->input.tenant_id;
4105 : 0 : cld_filter.element.queue_number = filter->queue;
4106 : : rte_memcpy(cld_filter.general_fields,
4107 [ # # ]: 0 : filter->input.general_fields,
4108 : : sizeof(cld_filter.general_fields));
4109 : :
4110 [ # # ]: 0 : if (!filter->is_to_vf)
4111 : 0 : vsi = pf->main_vsi;
4112 : : else {
4113 : 0 : vf = &pf->vfs[filter->vf_id];
4114 : 0 : vsi = vf->vsi;
4115 : : }
4116 : :
4117 [ # # ]: 0 : if (((filter->input.flags & I40E_AQC_ADD_CLOUD_FILTER_0X11) ==
4118 [ # # ]: 0 : I40E_AQC_ADD_CLOUD_FILTER_0X11) ||
4119 : : ((filter->input.flags & I40E_AQC_ADD_CLOUD_FILTER_0X12) ==
4120 [ # # ]: 0 : I40E_AQC_ADD_CLOUD_FILTER_0X12) ||
4121 : : ((filter->input.flags & I40E_AQC_ADD_CLOUD_FILTER_0X10) ==
4122 : : I40E_AQC_ADD_CLOUD_FILTER_0X10))
4123 : : big_buffer = 1;
4124 : :
4125 : : if (big_buffer)
4126 : 0 : ret = i40e_aq_rem_cloud_filters_bb(hw, vsi->seid,
4127 : : &cld_filter, 1);
4128 : : else
4129 : 0 : ret = i40e_aq_rem_cloud_filters(hw, vsi->seid,
4130 : : &cld_filter.element, 1);
4131 [ # # ]: 0 : if (ret < 0)
4132 : : return -ENOTSUP;
4133 : :
4134 : 0 : node = i40e_sw_tunnel_filter_lookup(tunnel_rule, &filter->input);
4135 [ # # ]: 0 : if (!node)
4136 : : return -EINVAL;
4137 : :
4138 : 0 : ret = i40e_sw_tunnel_filter_del(pf, &node->input);
4139 : :
4140 : 0 : return ret;
4141 : : }
4142 : :
4143 : : static int
4144 : 0 : i40e_flow_flush(struct rte_eth_dev *dev, struct rte_flow_error *error)
4145 : : {
4146 : 0 : struct i40e_pf *pf = I40E_DEV_PRIVATE_TO_PF(dev->data->dev_private);
4147 : : int ret;
4148 : :
4149 : 0 : ret = i40e_flow_flush_fdir_filter(pf);
4150 [ # # ]: 0 : if (ret) {
4151 : 0 : rte_flow_error_set(error, -ret,
4152 : : RTE_FLOW_ERROR_TYPE_HANDLE, NULL,
4153 : : "Failed to flush FDIR flows.");
4154 : 0 : return -rte_errno;
4155 : : }
4156 : :
4157 : 0 : ret = i40e_flow_flush_ethertype_filter(pf);
4158 [ # # ]: 0 : if (ret) {
4159 : 0 : rte_flow_error_set(error, -ret,
4160 : : RTE_FLOW_ERROR_TYPE_HANDLE, NULL,
4161 : : "Failed to ethertype flush flows.");
4162 : 0 : return -rte_errno;
4163 : : }
4164 : :
4165 : 0 : ret = i40e_flow_flush_tunnel_filter(pf);
4166 [ # # ]: 0 : if (ret) {
4167 : 0 : rte_flow_error_set(error, -ret,
4168 : : RTE_FLOW_ERROR_TYPE_HANDLE, NULL,
4169 : : "Failed to flush tunnel flows.");
4170 : 0 : return -rte_errno;
4171 : : }
4172 : :
4173 : 0 : ret = i40e_hash_filter_flush(pf);
4174 [ # # ]: 0 : if (ret)
4175 : 0 : rte_flow_error_set(error, -ret,
4176 : : RTE_FLOW_ERROR_TYPE_HANDLE, NULL,
4177 : : "Failed to flush RSS flows.");
4178 : : return ret;
4179 : : }
4180 : :
4181 : : static int
4182 : 0 : i40e_flow_flush_fdir_filter(struct i40e_pf *pf)
4183 : : {
4184 : 0 : struct rte_eth_dev *dev = &rte_eth_devices[pf->dev_data->port_id];
4185 : : struct i40e_fdir_info *fdir_info = &pf->fdir;
4186 : : struct i40e_fdir_filter *fdir_filter;
4187 : : enum i40e_filter_pctype pctype;
4188 : : struct rte_flow *flow;
4189 : : void *temp;
4190 : : int ret;
4191 : : uint32_t i = 0;
4192 : :
4193 : 0 : ret = i40e_fdir_flush(dev);
4194 [ # # ]: 0 : if (!ret) {
4195 : : /* Delete FDIR filters in FDIR list. */
4196 [ # # ]: 0 : while ((fdir_filter = TAILQ_FIRST(&fdir_info->fdir_list))) {
4197 : 0 : ret = i40e_sw_fdir_filter_del(pf,
4198 : : &fdir_filter->fdir.input);
4199 [ # # ]: 0 : if (ret < 0)
4200 : 0 : return ret;
4201 : : }
4202 : :
4203 : : /* Delete FDIR flows in flow list. */
4204 [ # # ]: 0 : RTE_TAILQ_FOREACH_SAFE(flow, &pf->flow_list, node, temp) {
4205 [ # # ]: 0 : if (flow->filter_type == RTE_ETH_FILTER_FDIR) {
4206 [ # # ]: 0 : TAILQ_REMOVE(&pf->flow_list, flow, node);
4207 : : }
4208 : : }
4209 : :
4210 : : /* reset bitmap */
4211 : 0 : rte_bitmap_reset(fdir_info->fdir_flow_pool.bitmap);
4212 [ # # ]: 0 : for (i = 0; i < fdir_info->fdir_space_size; i++) {
4213 : 0 : fdir_info->fdir_flow_pool.pool[i].idx = i;
4214 : 0 : rte_bitmap_set(fdir_info->fdir_flow_pool.bitmap, i);
4215 : : }
4216 : :
4217 : 0 : fdir_info->fdir_actual_cnt = 0;
4218 : 0 : fdir_info->fdir_guarantee_free_space =
4219 : 0 : fdir_info->fdir_guarantee_total_space;
4220 : 0 : memset(fdir_info->fdir_filter_array,
4221 : : 0,
4222 : : sizeof(struct i40e_fdir_filter) *
4223 : : I40E_MAX_FDIR_FILTER_NUM);
4224 : :
4225 : 0 : for (pctype = I40E_FILTER_PCTYPE_NONF_IPV4_UDP;
4226 [ # # ]: 0 : pctype <= I40E_FILTER_PCTYPE_L2_PAYLOAD; pctype++) {
4227 : 0 : pf->fdir.flow_count[pctype] = 0;
4228 : 0 : pf->fdir.flex_mask_flag[pctype] = 0;
4229 : : }
4230 : :
4231 [ # # ]: 0 : for (i = 0; i < I40E_MAX_FLXPLD_LAYER; i++)
4232 : 0 : pf->fdir.flex_pit_flag[i] = 0;
4233 : :
4234 : : /* Disable FDIR processing as all FDIR rules are now flushed */
4235 : 0 : i40e_fdir_rx_proc_enable(dev, 0);
4236 : : }
4237 : :
4238 : : return ret;
4239 : : }
4240 : :
4241 : : /* Flush all ethertype filters */
4242 : : static int
4243 : 0 : i40e_flow_flush_ethertype_filter(struct i40e_pf *pf)
4244 : : {
4245 : : struct i40e_ethertype_filter_list
4246 : : *ethertype_list = &pf->ethertype.ethertype_list;
4247 : : struct i40e_ethertype_filter *filter;
4248 : : struct rte_flow *flow;
4249 : : void *temp;
4250 : : int ret = 0;
4251 : :
4252 [ # # ]: 0 : while ((filter = TAILQ_FIRST(ethertype_list))) {
4253 : 0 : ret = i40e_flow_destroy_ethertype_filter(pf, filter);
4254 [ # # ]: 0 : if (ret)
4255 : 0 : return ret;
4256 : : }
4257 : :
4258 : : /* Delete ethertype flows in flow list. */
4259 [ # # ]: 0 : RTE_TAILQ_FOREACH_SAFE(flow, &pf->flow_list, node, temp) {
4260 [ # # ]: 0 : if (flow->filter_type == RTE_ETH_FILTER_ETHERTYPE) {
4261 [ # # ]: 0 : TAILQ_REMOVE(&pf->flow_list, flow, node);
4262 : 0 : rte_free(flow);
4263 : : }
4264 : : }
4265 : :
4266 : : return ret;
4267 : : }
4268 : :
4269 : : /* Flush all tunnel filters */
4270 : : static int
4271 : 0 : i40e_flow_flush_tunnel_filter(struct i40e_pf *pf)
4272 : : {
4273 : : struct i40e_tunnel_filter_list
4274 : : *tunnel_list = &pf->tunnel.tunnel_list;
4275 : : struct i40e_tunnel_filter *filter;
4276 : : struct rte_flow *flow;
4277 : : void *temp;
4278 : : int ret = 0;
4279 : :
4280 [ # # ]: 0 : while ((filter = TAILQ_FIRST(tunnel_list))) {
4281 : 0 : ret = i40e_flow_destroy_tunnel_filter(pf, filter);
4282 [ # # ]: 0 : if (ret)
4283 : 0 : return ret;
4284 : : }
4285 : :
4286 : : /* Delete tunnel flows in flow list. */
4287 [ # # ]: 0 : RTE_TAILQ_FOREACH_SAFE(flow, &pf->flow_list, node, temp) {
4288 [ # # ]: 0 : if (flow->filter_type == RTE_ETH_FILTER_TUNNEL) {
4289 [ # # ]: 0 : TAILQ_REMOVE(&pf->flow_list, flow, node);
4290 : 0 : rte_free(flow);
4291 : : }
4292 : : }
4293 : :
4294 : : return ret;
4295 : : }
4296 : :
4297 : : static int
4298 : 0 : i40e_flow_query(struct rte_eth_dev *dev __rte_unused,
4299 : : struct rte_flow *flow,
4300 : : const struct rte_flow_action *actions,
4301 : : void *data, struct rte_flow_error *error)
4302 : : {
4303 : 0 : struct i40e_rss_filter *rss_rule = (struct i40e_rss_filter *)flow->rule;
4304 : 0 : enum rte_filter_type filter_type = flow->filter_type;
4305 : : struct rte_flow_action_rss *rss_conf = data;
4306 : :
4307 [ # # ]: 0 : if (!rss_rule) {
4308 : 0 : rte_flow_error_set(error, EINVAL,
4309 : : RTE_FLOW_ERROR_TYPE_HANDLE,
4310 : : NULL, "Invalid rule");
4311 : 0 : return -rte_errno;
4312 : : }
4313 : :
4314 [ # # ]: 0 : for (; actions->type != RTE_FLOW_ACTION_TYPE_END; actions++) {
4315 [ # # # ]: 0 : switch (actions->type) {
4316 : : case RTE_FLOW_ACTION_TYPE_VOID:
4317 : : break;
4318 : 0 : case RTE_FLOW_ACTION_TYPE_RSS:
4319 [ # # ]: 0 : if (filter_type != RTE_ETH_FILTER_HASH) {
4320 : 0 : rte_flow_error_set(error, ENOTSUP,
4321 : : RTE_FLOW_ERROR_TYPE_ACTION,
4322 : : actions,
4323 : : "action not supported");
4324 : 0 : return -rte_errno;
4325 : : }
4326 : : rte_memcpy(rss_conf,
4327 [ # # ]: 0 : &rss_rule->rss_filter_info.conf,
4328 : : sizeof(struct rte_flow_action_rss));
4329 : : break;
4330 : 0 : default:
4331 : 0 : return rte_flow_error_set(error, ENOTSUP,
4332 : : RTE_FLOW_ERROR_TYPE_ACTION,
4333 : : actions,
4334 : : "action not supported");
4335 : : }
4336 : : }
4337 : :
4338 : : return 0;
4339 : : }
|