4 * Copyright (c) 2016 Intel Corporation. All rights reserved.
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
10 * * Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * * Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in
14 * the documentation and/or other materials provided with the
16 * * Neither the name of Intel Corporation nor the names of its
17 * contributors may be used to endorse or promote products derived
18 * from this software without specific prior written permission.
20 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
23 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
24 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
25 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
26 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
27 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
28 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
30 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33 #include <sys/queue.h>
41 #include <rte_ether.h>
42 #include <rte_ethdev.h>
44 #include <rte_memzone.h>
45 #include <rte_malloc.h>
46 #include <rte_eth_ctrl.h>
47 #include <rte_tailq.h>
48 #include <rte_flow_driver.h>
50 #include "i40e_logs.h"
51 #include "base/i40e_type.h"
52 #include "base/i40e_prototype.h"
53 #include "i40e_ethdev.h"
55 #define I40E_IPV4_TC_SHIFT 4
56 #define I40E_IPV6_TC_MASK (0x00FF << I40E_IPV4_TC_SHIFT)
57 #define I40E_IPV6_FRAG_HEADER 44
58 #define I40E_TENANT_ARRAY_NUM 3
59 #define I40E_TCI_MASK 0xFFFF
61 static int i40e_flow_validate(struct rte_eth_dev *dev,
62 const struct rte_flow_attr *attr,
63 const struct rte_flow_item pattern[],
64 const struct rte_flow_action actions[],
65 struct rte_flow_error *error);
66 static struct rte_flow *i40e_flow_create(struct rte_eth_dev *dev,
67 const struct rte_flow_attr *attr,
68 const struct rte_flow_item pattern[],
69 const struct rte_flow_action actions[],
70 struct rte_flow_error *error);
71 static int i40e_flow_destroy(struct rte_eth_dev *dev,
72 struct rte_flow *flow,
73 struct rte_flow_error *error);
74 static int i40e_flow_flush(struct rte_eth_dev *dev,
75 struct rte_flow_error *error);
77 i40e_flow_parse_ethertype_pattern(struct rte_eth_dev *dev,
78 const struct rte_flow_item *pattern,
79 struct rte_flow_error *error,
80 struct rte_eth_ethertype_filter *filter);
81 static int i40e_flow_parse_ethertype_action(struct rte_eth_dev *dev,
82 const struct rte_flow_action *actions,
83 struct rte_flow_error *error,
84 struct rte_eth_ethertype_filter *filter);
85 static int i40e_flow_parse_fdir_pattern(struct rte_eth_dev *dev,
86 const struct rte_flow_item *pattern,
87 struct rte_flow_error *error,
88 struct rte_eth_fdir_filter *filter);
89 static int i40e_flow_parse_fdir_action(struct rte_eth_dev *dev,
90 const struct rte_flow_action *actions,
91 struct rte_flow_error *error,
92 struct rte_eth_fdir_filter *filter);
93 static int i40e_flow_parse_tunnel_action(struct rte_eth_dev *dev,
94 const struct rte_flow_action *actions,
95 struct rte_flow_error *error,
96 struct i40e_tunnel_filter_conf *filter);
97 static int i40e_flow_parse_attr(const struct rte_flow_attr *attr,
98 struct rte_flow_error *error);
99 static int i40e_flow_parse_ethertype_filter(struct rte_eth_dev *dev,
100 const struct rte_flow_attr *attr,
101 const struct rte_flow_item pattern[],
102 const struct rte_flow_action actions[],
103 struct rte_flow_error *error,
104 union i40e_filter_t *filter);
105 static int i40e_flow_parse_fdir_filter(struct rte_eth_dev *dev,
106 const struct rte_flow_attr *attr,
107 const struct rte_flow_item pattern[],
108 const struct rte_flow_action actions[],
109 struct rte_flow_error *error,
110 union i40e_filter_t *filter);
111 static int i40e_flow_parse_vxlan_filter(struct rte_eth_dev *dev,
112 const struct rte_flow_attr *attr,
113 const struct rte_flow_item pattern[],
114 const struct rte_flow_action actions[],
115 struct rte_flow_error *error,
116 union i40e_filter_t *filter);
117 static int i40e_flow_parse_mpls_filter(struct rte_eth_dev *dev,
118 const struct rte_flow_attr *attr,
119 const struct rte_flow_item pattern[],
120 const struct rte_flow_action actions[],
121 struct rte_flow_error *error,
122 union i40e_filter_t *filter);
123 static int i40e_flow_destroy_ethertype_filter(struct i40e_pf *pf,
124 struct i40e_ethertype_filter *filter);
125 static int i40e_flow_destroy_tunnel_filter(struct i40e_pf *pf,
126 struct i40e_tunnel_filter *filter);
127 static int i40e_flow_flush_fdir_filter(struct i40e_pf *pf);
128 static int i40e_flow_flush_ethertype_filter(struct i40e_pf *pf);
129 static int i40e_flow_flush_tunnel_filter(struct i40e_pf *pf);
131 const struct rte_flow_ops i40e_flow_ops = {
132 .validate = i40e_flow_validate,
133 .create = i40e_flow_create,
134 .destroy = i40e_flow_destroy,
135 .flush = i40e_flow_flush,
138 union i40e_filter_t cons_filter;
139 enum rte_filter_type cons_filter_type = RTE_ETH_FILTER_NONE;
141 /* Pattern matched ethertype filter */
142 static enum rte_flow_item_type pattern_ethertype[] = {
143 RTE_FLOW_ITEM_TYPE_ETH,
144 RTE_FLOW_ITEM_TYPE_END,
147 /* Pattern matched flow director filter */
148 static enum rte_flow_item_type pattern_fdir_ipv4[] = {
149 RTE_FLOW_ITEM_TYPE_IPV4,
150 RTE_FLOW_ITEM_TYPE_END,
153 static enum rte_flow_item_type pattern_fdir_ipv4_ext[] = {
154 RTE_FLOW_ITEM_TYPE_ETH,
155 RTE_FLOW_ITEM_TYPE_IPV4,
156 RTE_FLOW_ITEM_TYPE_END,
159 static enum rte_flow_item_type pattern_fdir_ipv4_udp[] = {
160 RTE_FLOW_ITEM_TYPE_IPV4,
161 RTE_FLOW_ITEM_TYPE_UDP,
162 RTE_FLOW_ITEM_TYPE_END,
165 static enum rte_flow_item_type pattern_fdir_ipv4_udp_ext[] = {
166 RTE_FLOW_ITEM_TYPE_ETH,
167 RTE_FLOW_ITEM_TYPE_IPV4,
168 RTE_FLOW_ITEM_TYPE_UDP,
169 RTE_FLOW_ITEM_TYPE_END,
172 static enum rte_flow_item_type pattern_fdir_ipv4_tcp[] = {
173 RTE_FLOW_ITEM_TYPE_IPV4,
174 RTE_FLOW_ITEM_TYPE_TCP,
175 RTE_FLOW_ITEM_TYPE_END,
178 static enum rte_flow_item_type pattern_fdir_ipv4_tcp_ext[] = {
179 RTE_FLOW_ITEM_TYPE_ETH,
180 RTE_FLOW_ITEM_TYPE_IPV4,
181 RTE_FLOW_ITEM_TYPE_TCP,
182 RTE_FLOW_ITEM_TYPE_END,
185 static enum rte_flow_item_type pattern_fdir_ipv4_sctp[] = {
186 RTE_FLOW_ITEM_TYPE_IPV4,
187 RTE_FLOW_ITEM_TYPE_SCTP,
188 RTE_FLOW_ITEM_TYPE_END,
191 static enum rte_flow_item_type pattern_fdir_ipv4_sctp_ext[] = {
192 RTE_FLOW_ITEM_TYPE_ETH,
193 RTE_FLOW_ITEM_TYPE_IPV4,
194 RTE_FLOW_ITEM_TYPE_SCTP,
195 RTE_FLOW_ITEM_TYPE_END,
198 static enum rte_flow_item_type pattern_fdir_ipv6[] = {
199 RTE_FLOW_ITEM_TYPE_IPV6,
200 RTE_FLOW_ITEM_TYPE_END,
203 static enum rte_flow_item_type pattern_fdir_ipv6_ext[] = {
204 RTE_FLOW_ITEM_TYPE_ETH,
205 RTE_FLOW_ITEM_TYPE_IPV6,
206 RTE_FLOW_ITEM_TYPE_END,
209 static enum rte_flow_item_type pattern_fdir_ipv6_udp[] = {
210 RTE_FLOW_ITEM_TYPE_IPV6,
211 RTE_FLOW_ITEM_TYPE_UDP,
212 RTE_FLOW_ITEM_TYPE_END,
215 static enum rte_flow_item_type pattern_fdir_ipv6_udp_ext[] = {
216 RTE_FLOW_ITEM_TYPE_ETH,
217 RTE_FLOW_ITEM_TYPE_IPV6,
218 RTE_FLOW_ITEM_TYPE_UDP,
219 RTE_FLOW_ITEM_TYPE_END,
222 static enum rte_flow_item_type pattern_fdir_ipv6_tcp[] = {
223 RTE_FLOW_ITEM_TYPE_IPV6,
224 RTE_FLOW_ITEM_TYPE_TCP,
225 RTE_FLOW_ITEM_TYPE_END,
228 static enum rte_flow_item_type pattern_fdir_ipv6_tcp_ext[] = {
229 RTE_FLOW_ITEM_TYPE_ETH,
230 RTE_FLOW_ITEM_TYPE_IPV6,
231 RTE_FLOW_ITEM_TYPE_TCP,
232 RTE_FLOW_ITEM_TYPE_END,
235 static enum rte_flow_item_type pattern_fdir_ipv6_sctp[] = {
236 RTE_FLOW_ITEM_TYPE_IPV6,
237 RTE_FLOW_ITEM_TYPE_SCTP,
238 RTE_FLOW_ITEM_TYPE_END,
241 static enum rte_flow_item_type pattern_fdir_ipv6_sctp_ext[] = {
242 RTE_FLOW_ITEM_TYPE_ETH,
243 RTE_FLOW_ITEM_TYPE_IPV6,
244 RTE_FLOW_ITEM_TYPE_SCTP,
245 RTE_FLOW_ITEM_TYPE_END,
248 /* Pattern matched tunnel filter */
249 static enum rte_flow_item_type pattern_vxlan_1[] = {
250 RTE_FLOW_ITEM_TYPE_ETH,
251 RTE_FLOW_ITEM_TYPE_IPV4,
252 RTE_FLOW_ITEM_TYPE_UDP,
253 RTE_FLOW_ITEM_TYPE_VXLAN,
254 RTE_FLOW_ITEM_TYPE_ETH,
255 RTE_FLOW_ITEM_TYPE_END,
258 static enum rte_flow_item_type pattern_vxlan_2[] = {
259 RTE_FLOW_ITEM_TYPE_ETH,
260 RTE_FLOW_ITEM_TYPE_IPV6,
261 RTE_FLOW_ITEM_TYPE_UDP,
262 RTE_FLOW_ITEM_TYPE_VXLAN,
263 RTE_FLOW_ITEM_TYPE_ETH,
264 RTE_FLOW_ITEM_TYPE_END,
267 static enum rte_flow_item_type pattern_vxlan_3[] = {
268 RTE_FLOW_ITEM_TYPE_ETH,
269 RTE_FLOW_ITEM_TYPE_IPV4,
270 RTE_FLOW_ITEM_TYPE_UDP,
271 RTE_FLOW_ITEM_TYPE_VXLAN,
272 RTE_FLOW_ITEM_TYPE_ETH,
273 RTE_FLOW_ITEM_TYPE_VLAN,
274 RTE_FLOW_ITEM_TYPE_END,
277 static enum rte_flow_item_type pattern_vxlan_4[] = {
278 RTE_FLOW_ITEM_TYPE_ETH,
279 RTE_FLOW_ITEM_TYPE_IPV6,
280 RTE_FLOW_ITEM_TYPE_UDP,
281 RTE_FLOW_ITEM_TYPE_VXLAN,
282 RTE_FLOW_ITEM_TYPE_ETH,
283 RTE_FLOW_ITEM_TYPE_VLAN,
284 RTE_FLOW_ITEM_TYPE_END,
287 /* Pattern matched MPLS */
288 static enum rte_flow_item_type pattern_mpls_1[] = {
289 RTE_FLOW_ITEM_TYPE_ETH,
290 RTE_FLOW_ITEM_TYPE_IPV4,
291 RTE_FLOW_ITEM_TYPE_UDP,
292 RTE_FLOW_ITEM_TYPE_MPLS,
293 RTE_FLOW_ITEM_TYPE_END,
296 static enum rte_flow_item_type pattern_mpls_2[] = {
297 RTE_FLOW_ITEM_TYPE_ETH,
298 RTE_FLOW_ITEM_TYPE_IPV6,
299 RTE_FLOW_ITEM_TYPE_UDP,
300 RTE_FLOW_ITEM_TYPE_MPLS,
301 RTE_FLOW_ITEM_TYPE_END,
304 static enum rte_flow_item_type pattern_mpls_3[] = {
305 RTE_FLOW_ITEM_TYPE_ETH,
306 RTE_FLOW_ITEM_TYPE_IPV4,
307 RTE_FLOW_ITEM_TYPE_GRE,
308 RTE_FLOW_ITEM_TYPE_MPLS,
309 RTE_FLOW_ITEM_TYPE_END,
312 static enum rte_flow_item_type pattern_mpls_4[] = {
313 RTE_FLOW_ITEM_TYPE_ETH,
314 RTE_FLOW_ITEM_TYPE_IPV6,
315 RTE_FLOW_ITEM_TYPE_GRE,
316 RTE_FLOW_ITEM_TYPE_MPLS,
317 RTE_FLOW_ITEM_TYPE_END,
320 static struct i40e_valid_pattern i40e_supported_patterns[] = {
322 { pattern_ethertype, i40e_flow_parse_ethertype_filter },
324 { pattern_fdir_ipv4, i40e_flow_parse_fdir_filter },
325 { pattern_fdir_ipv4_ext, i40e_flow_parse_fdir_filter },
326 { pattern_fdir_ipv4_udp, i40e_flow_parse_fdir_filter },
327 { pattern_fdir_ipv4_udp_ext, i40e_flow_parse_fdir_filter },
328 { pattern_fdir_ipv4_tcp, i40e_flow_parse_fdir_filter },
329 { pattern_fdir_ipv4_tcp_ext, i40e_flow_parse_fdir_filter },
330 { pattern_fdir_ipv4_sctp, i40e_flow_parse_fdir_filter },
331 { pattern_fdir_ipv4_sctp_ext, i40e_flow_parse_fdir_filter },
332 { pattern_fdir_ipv6, i40e_flow_parse_fdir_filter },
333 { pattern_fdir_ipv6_ext, i40e_flow_parse_fdir_filter },
334 { pattern_fdir_ipv6_udp, i40e_flow_parse_fdir_filter },
335 { pattern_fdir_ipv6_udp_ext, i40e_flow_parse_fdir_filter },
336 { pattern_fdir_ipv6_tcp, i40e_flow_parse_fdir_filter },
337 { pattern_fdir_ipv6_tcp_ext, i40e_flow_parse_fdir_filter },
338 { pattern_fdir_ipv6_sctp, i40e_flow_parse_fdir_filter },
339 { pattern_fdir_ipv6_sctp_ext, i40e_flow_parse_fdir_filter },
341 { pattern_vxlan_1, i40e_flow_parse_vxlan_filter },
342 { pattern_vxlan_2, i40e_flow_parse_vxlan_filter },
343 { pattern_vxlan_3, i40e_flow_parse_vxlan_filter },
344 { pattern_vxlan_4, i40e_flow_parse_vxlan_filter },
345 /* MPLSoUDP & MPLSoGRE */
346 { pattern_mpls_1, i40e_flow_parse_mpls_filter },
347 { pattern_mpls_2, i40e_flow_parse_mpls_filter },
348 { pattern_mpls_3, i40e_flow_parse_mpls_filter },
349 { pattern_mpls_4, i40e_flow_parse_mpls_filter },
352 #define NEXT_ITEM_OF_ACTION(act, actions, index) \
354 act = actions + index; \
355 while (act->type == RTE_FLOW_ACTION_TYPE_VOID) { \
357 act = actions + index; \
361 /* Find the first VOID or non-VOID item pointer */
362 static const struct rte_flow_item *
363 i40e_find_first_item(const struct rte_flow_item *item, bool is_void)
367 while (item->type != RTE_FLOW_ITEM_TYPE_END) {
369 is_find = item->type == RTE_FLOW_ITEM_TYPE_VOID;
371 is_find = item->type != RTE_FLOW_ITEM_TYPE_VOID;
379 /* Skip all VOID items of the pattern */
381 i40e_pattern_skip_void_item(struct rte_flow_item *items,
382 const struct rte_flow_item *pattern)
384 uint32_t cpy_count = 0;
385 const struct rte_flow_item *pb = pattern, *pe = pattern;
388 /* Find a non-void item first */
389 pb = i40e_find_first_item(pb, false);
390 if (pb->type == RTE_FLOW_ITEM_TYPE_END) {
395 /* Find a void item */
396 pe = i40e_find_first_item(pb + 1, true);
399 rte_memcpy(items, pb, sizeof(struct rte_flow_item) * cpy_count);
403 if (pe->type == RTE_FLOW_ITEM_TYPE_END) {
410 /* Copy the END item. */
411 rte_memcpy(items, pe, sizeof(struct rte_flow_item));
414 /* Check if the pattern matches a supported item type array */
416 i40e_match_pattern(enum rte_flow_item_type *item_array,
417 struct rte_flow_item *pattern)
419 struct rte_flow_item *item = pattern;
421 while ((*item_array == item->type) &&
422 (*item_array != RTE_FLOW_ITEM_TYPE_END)) {
427 return (*item_array == RTE_FLOW_ITEM_TYPE_END &&
428 item->type == RTE_FLOW_ITEM_TYPE_END);
431 /* Find if there's parse filter function matched */
432 static parse_filter_t
433 i40e_find_parse_filter_func(struct rte_flow_item *pattern)
435 parse_filter_t parse_filter = NULL;
438 for (; i < RTE_DIM(i40e_supported_patterns); i++) {
439 if (i40e_match_pattern(i40e_supported_patterns[i].items,
441 parse_filter = i40e_supported_patterns[i].parse_filter;
449 /* Parse attributes */
451 i40e_flow_parse_attr(const struct rte_flow_attr *attr,
452 struct rte_flow_error *error)
454 /* Must be input direction */
455 if (!attr->ingress) {
456 rte_flow_error_set(error, EINVAL,
457 RTE_FLOW_ERROR_TYPE_ATTR_INGRESS,
458 attr, "Only support ingress.");
464 rte_flow_error_set(error, EINVAL,
465 RTE_FLOW_ERROR_TYPE_ATTR_EGRESS,
466 attr, "Not support egress.");
471 if (attr->priority) {
472 rte_flow_error_set(error, EINVAL,
473 RTE_FLOW_ERROR_TYPE_ATTR_PRIORITY,
474 attr, "Not support priority.");
480 rte_flow_error_set(error, EINVAL,
481 RTE_FLOW_ERROR_TYPE_ATTR_GROUP,
482 attr, "Not support group.");
490 i40e_get_outer_vlan(struct rte_eth_dev *dev)
492 struct i40e_hw *hw = I40E_DEV_PRIVATE_TO_HW(dev->data->dev_private);
493 int qinq = dev->data->dev_conf.rxmode.hw_vlan_extend;
503 i40e_aq_debug_read_register(hw, I40E_GL_SWT_L2TAGCTRL(reg_id),
506 tpid = (reg_r >> I40E_GL_SWT_L2TAGCTRL_ETHERTYPE_SHIFT) & 0xFFFF;
511 /* 1. Last in item should be NULL as range is not supported.
512 * 2. Supported filter types: MAC_ETHTYPE and ETHTYPE.
513 * 3. SRC mac_addr mask should be 00:00:00:00:00:00.
514 * 4. DST mac_addr mask should be 00:00:00:00:00:00 or
516 * 5. Ether_type mask should be 0xFFFF.
519 i40e_flow_parse_ethertype_pattern(struct rte_eth_dev *dev,
520 const struct rte_flow_item *pattern,
521 struct rte_flow_error *error,
522 struct rte_eth_ethertype_filter *filter)
524 const struct rte_flow_item *item = pattern;
525 const struct rte_flow_item_eth *eth_spec;
526 const struct rte_flow_item_eth *eth_mask;
527 enum rte_flow_item_type item_type;
530 outer_tpid = i40e_get_outer_vlan(dev);
532 for (; item->type != RTE_FLOW_ITEM_TYPE_END; item++) {
534 rte_flow_error_set(error, EINVAL,
535 RTE_FLOW_ERROR_TYPE_ITEM,
537 "Not support range");
540 item_type = item->type;
542 case RTE_FLOW_ITEM_TYPE_ETH:
543 eth_spec = (const struct rte_flow_item_eth *)item->spec;
544 eth_mask = (const struct rte_flow_item_eth *)item->mask;
545 /* Get the MAC info. */
546 if (!eth_spec || !eth_mask) {
547 rte_flow_error_set(error, EINVAL,
548 RTE_FLOW_ERROR_TYPE_ITEM,
550 "NULL ETH spec/mask");
554 /* Mask bits of source MAC address must be full of 0.
555 * Mask bits of destination MAC address must be full
558 if (!is_zero_ether_addr(ð_mask->src) ||
559 (!is_zero_ether_addr(ð_mask->dst) &&
560 !is_broadcast_ether_addr(ð_mask->dst))) {
561 rte_flow_error_set(error, EINVAL,
562 RTE_FLOW_ERROR_TYPE_ITEM,
564 "Invalid MAC_addr mask");
568 if ((eth_mask->type & UINT16_MAX) != UINT16_MAX) {
569 rte_flow_error_set(error, EINVAL,
570 RTE_FLOW_ERROR_TYPE_ITEM,
572 "Invalid ethertype mask");
576 /* If mask bits of destination MAC address
577 * are full of 1, set RTE_ETHTYPE_FLAGS_MAC.
579 if (is_broadcast_ether_addr(ð_mask->dst)) {
580 filter->mac_addr = eth_spec->dst;
581 filter->flags |= RTE_ETHTYPE_FLAGS_MAC;
583 filter->flags &= ~RTE_ETHTYPE_FLAGS_MAC;
585 filter->ether_type = rte_be_to_cpu_16(eth_spec->type);
587 if (filter->ether_type == ETHER_TYPE_IPv4 ||
588 filter->ether_type == ETHER_TYPE_IPv6 ||
589 filter->ether_type == outer_tpid) {
590 rte_flow_error_set(error, EINVAL,
591 RTE_FLOW_ERROR_TYPE_ITEM,
593 "Unsupported ether_type in"
594 " control packet filter.");
606 /* Ethertype action only supports QUEUE or DROP. */
608 i40e_flow_parse_ethertype_action(struct rte_eth_dev *dev,
609 const struct rte_flow_action *actions,
610 struct rte_flow_error *error,
611 struct rte_eth_ethertype_filter *filter)
613 struct i40e_pf *pf = I40E_DEV_PRIVATE_TO_PF(dev->data->dev_private);
614 const struct rte_flow_action *act;
615 const struct rte_flow_action_queue *act_q;
618 /* Check if the first non-void action is QUEUE or DROP. */
619 NEXT_ITEM_OF_ACTION(act, actions, index);
620 if (act->type != RTE_FLOW_ACTION_TYPE_QUEUE &&
621 act->type != RTE_FLOW_ACTION_TYPE_DROP) {
622 rte_flow_error_set(error, EINVAL, RTE_FLOW_ERROR_TYPE_ACTION,
623 act, "Not supported action.");
627 if (act->type == RTE_FLOW_ACTION_TYPE_QUEUE) {
628 act_q = (const struct rte_flow_action_queue *)act->conf;
629 filter->queue = act_q->index;
630 if (filter->queue >= pf->dev_data->nb_rx_queues) {
631 rte_flow_error_set(error, EINVAL,
632 RTE_FLOW_ERROR_TYPE_ACTION,
633 act, "Invalid queue ID for"
634 " ethertype_filter.");
638 filter->flags |= RTE_ETHTYPE_FLAGS_DROP;
641 /* Check if the next non-void item is END */
643 NEXT_ITEM_OF_ACTION(act, actions, index);
644 if (act->type != RTE_FLOW_ACTION_TYPE_END) {
645 rte_flow_error_set(error, EINVAL, RTE_FLOW_ERROR_TYPE_ACTION,
646 act, "Not supported action.");
654 i40e_flow_parse_ethertype_filter(struct rte_eth_dev *dev,
655 const struct rte_flow_attr *attr,
656 const struct rte_flow_item pattern[],
657 const struct rte_flow_action actions[],
658 struct rte_flow_error *error,
659 union i40e_filter_t *filter)
661 struct rte_eth_ethertype_filter *ethertype_filter =
662 &filter->ethertype_filter;
665 ret = i40e_flow_parse_ethertype_pattern(dev, pattern, error,
670 ret = i40e_flow_parse_ethertype_action(dev, actions, error,
675 ret = i40e_flow_parse_attr(attr, error);
679 cons_filter_type = RTE_ETH_FILTER_ETHERTYPE;
684 /* 1. Last in item should be NULL as range is not supported.
685 * 2. Supported flow type and input set: refer to array
686 * default_inset_table in i40e_ethdev.c.
687 * 3. Mask of fields which need to be matched should be
689 * 4. Mask of fields which needn't to be matched should be
693 i40e_flow_parse_fdir_pattern(struct rte_eth_dev *dev,
694 const struct rte_flow_item *pattern,
695 struct rte_flow_error *error,
696 struct rte_eth_fdir_filter *filter)
698 struct i40e_pf *pf = I40E_DEV_PRIVATE_TO_PF(dev->data->dev_private);
699 const struct rte_flow_item *item = pattern;
700 const struct rte_flow_item_eth *eth_spec, *eth_mask;
701 const struct rte_flow_item_ipv4 *ipv4_spec, *ipv4_mask;
702 const struct rte_flow_item_ipv6 *ipv6_spec, *ipv6_mask;
703 const struct rte_flow_item_tcp *tcp_spec, *tcp_mask;
704 const struct rte_flow_item_udp *udp_spec, *udp_mask;
705 const struct rte_flow_item_sctp *sctp_spec, *sctp_mask;
706 const struct rte_flow_item_vf *vf_spec;
707 uint32_t flow_type = RTE_ETH_FLOW_UNKNOWN;
708 enum i40e_filter_pctype pctype;
709 uint64_t input_set = I40E_INSET_NONE;
710 uint16_t flag_offset;
711 enum rte_flow_item_type item_type;
712 enum rte_flow_item_type l3 = RTE_FLOW_ITEM_TYPE_END;
715 for (; item->type != RTE_FLOW_ITEM_TYPE_END; item++) {
717 rte_flow_error_set(error, EINVAL,
718 RTE_FLOW_ERROR_TYPE_ITEM,
720 "Not support range");
723 item_type = item->type;
725 case RTE_FLOW_ITEM_TYPE_ETH:
726 eth_spec = (const struct rte_flow_item_eth *)item->spec;
727 eth_mask = (const struct rte_flow_item_eth *)item->mask;
728 if (eth_spec || eth_mask) {
729 rte_flow_error_set(error, EINVAL,
730 RTE_FLOW_ERROR_TYPE_ITEM,
732 "Invalid ETH spec/mask");
736 case RTE_FLOW_ITEM_TYPE_IPV4:
737 l3 = RTE_FLOW_ITEM_TYPE_IPV4;
739 (const struct rte_flow_item_ipv4 *)item->spec;
741 (const struct rte_flow_item_ipv4 *)item->mask;
742 if (!ipv4_spec || !ipv4_mask) {
743 rte_flow_error_set(error, EINVAL,
744 RTE_FLOW_ERROR_TYPE_ITEM,
746 "NULL IPv4 spec/mask");
750 /* Check IPv4 mask and update input set */
751 if (ipv4_mask->hdr.version_ihl ||
752 ipv4_mask->hdr.total_length ||
753 ipv4_mask->hdr.packet_id ||
754 ipv4_mask->hdr.fragment_offset ||
755 ipv4_mask->hdr.hdr_checksum) {
756 rte_flow_error_set(error, EINVAL,
757 RTE_FLOW_ERROR_TYPE_ITEM,
759 "Invalid IPv4 mask.");
763 if (ipv4_mask->hdr.src_addr == UINT32_MAX)
764 input_set |= I40E_INSET_IPV4_SRC;
765 if (ipv4_mask->hdr.dst_addr == UINT32_MAX)
766 input_set |= I40E_INSET_IPV4_DST;
767 if (ipv4_mask->hdr.type_of_service == UINT8_MAX)
768 input_set |= I40E_INSET_IPV4_TOS;
769 if (ipv4_mask->hdr.time_to_live == UINT8_MAX)
770 input_set |= I40E_INSET_IPV4_TTL;
771 if (ipv4_mask->hdr.next_proto_id == UINT8_MAX)
772 input_set |= I40E_INSET_IPV4_PROTO;
774 /* Get filter info */
775 flow_type = RTE_ETH_FLOW_NONFRAG_IPV4_OTHER;
776 /* Check if it is fragment. */
778 rte_be_to_cpu_16(ipv4_spec->hdr.fragment_offset);
779 if (flag_offset & IPV4_HDR_OFFSET_MASK ||
780 flag_offset & IPV4_HDR_MF_FLAG)
781 flow_type = RTE_ETH_FLOW_FRAG_IPV4;
783 /* Get the filter info */
784 filter->input.flow.ip4_flow.proto =
785 ipv4_spec->hdr.next_proto_id;
786 filter->input.flow.ip4_flow.tos =
787 ipv4_spec->hdr.type_of_service;
788 filter->input.flow.ip4_flow.ttl =
789 ipv4_spec->hdr.time_to_live;
790 filter->input.flow.ip4_flow.src_ip =
791 ipv4_spec->hdr.src_addr;
792 filter->input.flow.ip4_flow.dst_ip =
793 ipv4_spec->hdr.dst_addr;
796 case RTE_FLOW_ITEM_TYPE_IPV6:
797 l3 = RTE_FLOW_ITEM_TYPE_IPV6;
799 (const struct rte_flow_item_ipv6 *)item->spec;
801 (const struct rte_flow_item_ipv6 *)item->mask;
802 if (!ipv6_spec || !ipv6_mask) {
803 rte_flow_error_set(error, EINVAL,
804 RTE_FLOW_ERROR_TYPE_ITEM,
806 "NULL IPv6 spec/mask");
810 /* Check IPv6 mask and update input set */
811 if (ipv6_mask->hdr.payload_len) {
812 rte_flow_error_set(error, EINVAL,
813 RTE_FLOW_ERROR_TYPE_ITEM,
815 "Invalid IPv6 mask");
819 /* SCR and DST address of IPv6 shouldn't be masked */
820 for (j = 0; j < RTE_DIM(ipv6_mask->hdr.src_addr); j++) {
821 if (ipv6_mask->hdr.src_addr[j] != UINT8_MAX ||
822 ipv6_mask->hdr.dst_addr[j] != UINT8_MAX) {
823 rte_flow_error_set(error, EINVAL,
824 RTE_FLOW_ERROR_TYPE_ITEM,
826 "Invalid IPv6 mask");
831 input_set |= I40E_INSET_IPV6_SRC;
832 input_set |= I40E_INSET_IPV6_DST;
834 if ((ipv6_mask->hdr.vtc_flow &
835 rte_cpu_to_be_16(I40E_IPV6_TC_MASK))
836 == rte_cpu_to_be_16(I40E_IPV6_TC_MASK))
837 input_set |= I40E_INSET_IPV6_TC;
838 if (ipv6_mask->hdr.proto == UINT8_MAX)
839 input_set |= I40E_INSET_IPV6_NEXT_HDR;
840 if (ipv6_mask->hdr.hop_limits == UINT8_MAX)
841 input_set |= I40E_INSET_IPV6_HOP_LIMIT;
843 /* Get filter info */
844 filter->input.flow.ipv6_flow.tc =
845 (uint8_t)(ipv6_spec->hdr.vtc_flow <<
847 filter->input.flow.ipv6_flow.proto =
848 ipv6_spec->hdr.proto;
849 filter->input.flow.ipv6_flow.hop_limits =
850 ipv6_spec->hdr.hop_limits;
852 rte_memcpy(filter->input.flow.ipv6_flow.src_ip,
853 ipv6_spec->hdr.src_addr, 16);
854 rte_memcpy(filter->input.flow.ipv6_flow.dst_ip,
855 ipv6_spec->hdr.dst_addr, 16);
857 /* Check if it is fragment. */
858 if (ipv6_spec->hdr.proto == I40E_IPV6_FRAG_HEADER)
859 flow_type = RTE_ETH_FLOW_FRAG_IPV6;
861 flow_type = RTE_ETH_FLOW_NONFRAG_IPV6_OTHER;
863 case RTE_FLOW_ITEM_TYPE_TCP:
864 tcp_spec = (const struct rte_flow_item_tcp *)item->spec;
865 tcp_mask = (const struct rte_flow_item_tcp *)item->mask;
866 if (!tcp_spec || !tcp_mask) {
867 rte_flow_error_set(error, EINVAL,
868 RTE_FLOW_ERROR_TYPE_ITEM,
870 "NULL TCP spec/mask");
874 /* Check TCP mask and update input set */
875 if (tcp_mask->hdr.sent_seq ||
876 tcp_mask->hdr.recv_ack ||
877 tcp_mask->hdr.data_off ||
878 tcp_mask->hdr.tcp_flags ||
879 tcp_mask->hdr.rx_win ||
880 tcp_mask->hdr.cksum ||
881 tcp_mask->hdr.tcp_urp) {
882 rte_flow_error_set(error, EINVAL,
883 RTE_FLOW_ERROR_TYPE_ITEM,
889 if (tcp_mask->hdr.src_port != UINT16_MAX ||
890 tcp_mask->hdr.dst_port != UINT16_MAX) {
891 rte_flow_error_set(error, EINVAL,
892 RTE_FLOW_ERROR_TYPE_ITEM,
898 input_set |= I40E_INSET_SRC_PORT;
899 input_set |= I40E_INSET_DST_PORT;
901 /* Get filter info */
902 if (l3 == RTE_FLOW_ITEM_TYPE_IPV4)
903 flow_type = RTE_ETH_FLOW_NONFRAG_IPV4_TCP;
904 else if (l3 == RTE_FLOW_ITEM_TYPE_IPV6)
905 flow_type = RTE_ETH_FLOW_NONFRAG_IPV6_TCP;
907 if (l3 == RTE_FLOW_ITEM_TYPE_IPV4) {
908 filter->input.flow.tcp4_flow.src_port =
909 tcp_spec->hdr.src_port;
910 filter->input.flow.tcp4_flow.dst_port =
911 tcp_spec->hdr.dst_port;
912 } else if (l3 == RTE_FLOW_ITEM_TYPE_IPV6) {
913 filter->input.flow.tcp6_flow.src_port =
914 tcp_spec->hdr.src_port;
915 filter->input.flow.tcp6_flow.dst_port =
916 tcp_spec->hdr.dst_port;
919 case RTE_FLOW_ITEM_TYPE_UDP:
920 udp_spec = (const struct rte_flow_item_udp *)item->spec;
921 udp_mask = (const struct rte_flow_item_udp *)item->mask;
922 if (!udp_spec || !udp_mask) {
923 rte_flow_error_set(error, EINVAL,
924 RTE_FLOW_ERROR_TYPE_ITEM,
926 "NULL UDP spec/mask");
930 /* Check UDP mask and update input set*/
931 if (udp_mask->hdr.dgram_len ||
932 udp_mask->hdr.dgram_cksum) {
933 rte_flow_error_set(error, EINVAL,
934 RTE_FLOW_ERROR_TYPE_ITEM,
940 if (udp_mask->hdr.src_port != UINT16_MAX ||
941 udp_mask->hdr.dst_port != UINT16_MAX) {
942 rte_flow_error_set(error, EINVAL,
943 RTE_FLOW_ERROR_TYPE_ITEM,
949 input_set |= I40E_INSET_SRC_PORT;
950 input_set |= I40E_INSET_DST_PORT;
952 /* Get filter info */
953 if (l3 == RTE_FLOW_ITEM_TYPE_IPV4)
955 RTE_ETH_FLOW_NONFRAG_IPV4_UDP;
956 else if (l3 == RTE_FLOW_ITEM_TYPE_IPV6)
958 RTE_ETH_FLOW_NONFRAG_IPV6_UDP;
960 if (l3 == RTE_FLOW_ITEM_TYPE_IPV4) {
961 filter->input.flow.udp4_flow.src_port =
962 udp_spec->hdr.src_port;
963 filter->input.flow.udp4_flow.dst_port =
964 udp_spec->hdr.dst_port;
965 } else if (l3 == RTE_FLOW_ITEM_TYPE_IPV6) {
966 filter->input.flow.udp6_flow.src_port =
967 udp_spec->hdr.src_port;
968 filter->input.flow.udp6_flow.dst_port =
969 udp_spec->hdr.dst_port;
972 case RTE_FLOW_ITEM_TYPE_SCTP:
974 (const struct rte_flow_item_sctp *)item->spec;
976 (const struct rte_flow_item_sctp *)item->mask;
977 if (!sctp_spec || !sctp_mask) {
978 rte_flow_error_set(error, EINVAL,
979 RTE_FLOW_ERROR_TYPE_ITEM,
981 "NULL SCTP spec/mask");
985 /* Check SCTP mask and update input set */
986 if (sctp_mask->hdr.cksum) {
987 rte_flow_error_set(error, EINVAL,
988 RTE_FLOW_ERROR_TYPE_ITEM,
994 if (sctp_mask->hdr.src_port != UINT16_MAX ||
995 sctp_mask->hdr.dst_port != UINT16_MAX ||
996 sctp_mask->hdr.tag != UINT32_MAX) {
997 rte_flow_error_set(error, EINVAL,
998 RTE_FLOW_ERROR_TYPE_ITEM,
1000 "Invalid UDP mask");
1003 input_set |= I40E_INSET_SRC_PORT;
1004 input_set |= I40E_INSET_DST_PORT;
1005 input_set |= I40E_INSET_SCTP_VT;
1007 /* Get filter info */
1008 if (l3 == RTE_FLOW_ITEM_TYPE_IPV4)
1009 flow_type = RTE_ETH_FLOW_NONFRAG_IPV4_SCTP;
1010 else if (l3 == RTE_FLOW_ITEM_TYPE_IPV6)
1011 flow_type = RTE_ETH_FLOW_NONFRAG_IPV6_SCTP;
1013 if (l3 == RTE_FLOW_ITEM_TYPE_IPV4) {
1014 filter->input.flow.sctp4_flow.src_port =
1015 sctp_spec->hdr.src_port;
1016 filter->input.flow.sctp4_flow.dst_port =
1017 sctp_spec->hdr.dst_port;
1018 filter->input.flow.sctp4_flow.verify_tag =
1020 } else if (l3 == RTE_FLOW_ITEM_TYPE_IPV6) {
1021 filter->input.flow.sctp6_flow.src_port =
1022 sctp_spec->hdr.src_port;
1023 filter->input.flow.sctp6_flow.dst_port =
1024 sctp_spec->hdr.dst_port;
1025 filter->input.flow.sctp6_flow.verify_tag =
1029 case RTE_FLOW_ITEM_TYPE_VF:
1030 vf_spec = (const struct rte_flow_item_vf *)item->spec;
1031 filter->input.flow_ext.is_vf = 1;
1032 filter->input.flow_ext.dst_id = vf_spec->id;
1033 if (filter->input.flow_ext.is_vf &&
1034 filter->input.flow_ext.dst_id >= pf->vf_num) {
1035 rte_flow_error_set(error, EINVAL,
1036 RTE_FLOW_ERROR_TYPE_ITEM,
1038 "Invalid VF ID for FDIR.");
1047 pctype = i40e_flowtype_to_pctype(flow_type);
1048 if (pctype == 0 || pctype > I40E_FILTER_PCTYPE_L2_PAYLOAD) {
1049 rte_flow_error_set(error, EINVAL,
1050 RTE_FLOW_ERROR_TYPE_ITEM, item,
1051 "Unsupported flow type");
1055 if (input_set != i40e_get_default_input_set(pctype)) {
1056 rte_flow_error_set(error, EINVAL,
1057 RTE_FLOW_ERROR_TYPE_ITEM, item,
1058 "Invalid input set.");
1061 filter->input.flow_type = flow_type;
1066 /* Parse to get the action info of a FDIR filter.
1067 * FDIR action supports QUEUE or (QUEUE + MARK).
1070 i40e_flow_parse_fdir_action(struct rte_eth_dev *dev,
1071 const struct rte_flow_action *actions,
1072 struct rte_flow_error *error,
1073 struct rte_eth_fdir_filter *filter)
1075 struct i40e_pf *pf = I40E_DEV_PRIVATE_TO_PF(dev->data->dev_private);
1076 const struct rte_flow_action *act;
1077 const struct rte_flow_action_queue *act_q;
1078 const struct rte_flow_action_mark *mark_spec;
1081 /* Check if the first non-void action is QUEUE or DROP. */
1082 NEXT_ITEM_OF_ACTION(act, actions, index);
1083 if (act->type != RTE_FLOW_ACTION_TYPE_QUEUE &&
1084 act->type != RTE_FLOW_ACTION_TYPE_DROP) {
1085 rte_flow_error_set(error, EINVAL, RTE_FLOW_ERROR_TYPE_ACTION,
1086 act, "Invalid action.");
1090 act_q = (const struct rte_flow_action_queue *)act->conf;
1091 filter->action.flex_off = 0;
1092 if (act->type == RTE_FLOW_ACTION_TYPE_QUEUE)
1093 filter->action.behavior = RTE_ETH_FDIR_ACCEPT;
1095 filter->action.behavior = RTE_ETH_FDIR_REJECT;
1097 filter->action.report_status = RTE_ETH_FDIR_REPORT_ID;
1098 filter->action.rx_queue = act_q->index;
1100 if (filter->action.rx_queue >= pf->dev_data->nb_rx_queues) {
1101 rte_flow_error_set(error, EINVAL,
1102 RTE_FLOW_ERROR_TYPE_ACTION, act,
1103 "Invalid queue ID for FDIR.");
1107 /* Check if the next non-void item is MARK or END. */
1109 NEXT_ITEM_OF_ACTION(act, actions, index);
1110 if (act->type != RTE_FLOW_ACTION_TYPE_MARK &&
1111 act->type != RTE_FLOW_ACTION_TYPE_END) {
1112 rte_flow_error_set(error, EINVAL, RTE_FLOW_ERROR_TYPE_ACTION,
1113 act, "Invalid action.");
1117 if (act->type == RTE_FLOW_ACTION_TYPE_MARK) {
1118 mark_spec = (const struct rte_flow_action_mark *)act->conf;
1119 filter->soft_id = mark_spec->id;
1121 /* Check if the next non-void item is END */
1123 NEXT_ITEM_OF_ACTION(act, actions, index);
1124 if (act->type != RTE_FLOW_ACTION_TYPE_END) {
1125 rte_flow_error_set(error, EINVAL,
1126 RTE_FLOW_ERROR_TYPE_ACTION,
1127 act, "Invalid action.");
1136 i40e_flow_parse_fdir_filter(struct rte_eth_dev *dev,
1137 const struct rte_flow_attr *attr,
1138 const struct rte_flow_item pattern[],
1139 const struct rte_flow_action actions[],
1140 struct rte_flow_error *error,
1141 union i40e_filter_t *filter)
1143 struct rte_eth_fdir_filter *fdir_filter =
1144 &filter->fdir_filter;
1147 ret = i40e_flow_parse_fdir_pattern(dev, pattern, error, fdir_filter);
1151 ret = i40e_flow_parse_fdir_action(dev, actions, error, fdir_filter);
1155 ret = i40e_flow_parse_attr(attr, error);
1159 cons_filter_type = RTE_ETH_FILTER_FDIR;
1161 if (dev->data->dev_conf.fdir_conf.mode !=
1162 RTE_FDIR_MODE_PERFECT) {
1163 rte_flow_error_set(error, ENOTSUP,
1164 RTE_FLOW_ERROR_TYPE_UNSPECIFIED,
1166 "Check the mode in fdir_conf.");
1173 /* Parse to get the action info of a tunnle filter
1174 * Tunnel action only supports PF, VF and QUEUE.
1177 i40e_flow_parse_tunnel_action(struct rte_eth_dev *dev,
1178 const struct rte_flow_action *actions,
1179 struct rte_flow_error *error,
1180 struct i40e_tunnel_filter_conf *filter)
1182 struct i40e_pf *pf = I40E_DEV_PRIVATE_TO_PF(dev->data->dev_private);
1183 const struct rte_flow_action *act;
1184 const struct rte_flow_action_queue *act_q;
1185 const struct rte_flow_action_vf *act_vf;
1188 /* Check if the first non-void action is PF or VF. */
1189 NEXT_ITEM_OF_ACTION(act, actions, index);
1190 if (act->type != RTE_FLOW_ACTION_TYPE_PF &&
1191 act->type != RTE_FLOW_ACTION_TYPE_VF) {
1192 rte_flow_error_set(error, EINVAL, RTE_FLOW_ERROR_TYPE_ACTION,
1193 act, "Not supported action.");
1197 if (act->type == RTE_FLOW_ACTION_TYPE_VF) {
1198 act_vf = (const struct rte_flow_action_vf *)act->conf;
1199 filter->vf_id = act_vf->id;
1200 filter->is_to_vf = 1;
1201 if (filter->vf_id >= pf->vf_num) {
1202 rte_flow_error_set(error, EINVAL,
1203 RTE_FLOW_ERROR_TYPE_ACTION,
1204 act, "Invalid VF ID for tunnel filter");
1209 /* Check if the next non-void item is QUEUE */
1211 NEXT_ITEM_OF_ACTION(act, actions, index);
1212 if (act->type == RTE_FLOW_ACTION_TYPE_QUEUE) {
1213 act_q = (const struct rte_flow_action_queue *)act->conf;
1214 filter->queue_id = act_q->index;
1215 if (!filter->is_to_vf)
1216 if (filter->queue_id >= pf->dev_data->nb_rx_queues) {
1217 rte_flow_error_set(error, EINVAL,
1218 RTE_FLOW_ERROR_TYPE_ACTION,
1219 act, "Invalid queue ID for tunnel filter");
1224 /* Check if the next non-void item is END */
1226 NEXT_ITEM_OF_ACTION(act, actions, index);
1227 if (act->type != RTE_FLOW_ACTION_TYPE_END) {
1228 rte_flow_error_set(error, EINVAL, RTE_FLOW_ERROR_TYPE_ACTION,
1229 act, "Not supported action.");
1237 i40e_check_tenant_id_mask(const uint8_t *mask)
1242 for (j = 0; j < I40E_TENANT_ARRAY_NUM; j++) {
1243 if (*(mask + j) == UINT8_MAX) {
1244 if (j > 0 && (*(mask + j) != *(mask + j - 1)))
1247 } else if (*(mask + j) == 0) {
1248 if (j > 0 && (*(mask + j) != *(mask + j - 1)))
1259 /* 1. Last in item should be NULL as range is not supported.
1260 * 2. Supported filter types: IMAC_IVLAN_TENID, IMAC_IVLAN,
1261 * IMAC_TENID, OMAC_TENID_IMAC and IMAC.
1262 * 3. Mask of fields which need to be matched should be
1264 * 4. Mask of fields which needn't to be matched should be
1268 i40e_flow_parse_vxlan_pattern(__rte_unused struct rte_eth_dev *dev,
1269 const struct rte_flow_item *pattern,
1270 struct rte_flow_error *error,
1271 struct i40e_tunnel_filter_conf *filter)
1273 const struct rte_flow_item *item = pattern;
1274 const struct rte_flow_item_eth *eth_spec;
1275 const struct rte_flow_item_eth *eth_mask;
1276 const struct rte_flow_item_eth *o_eth_spec = NULL;
1277 const struct rte_flow_item_eth *o_eth_mask = NULL;
1278 const struct rte_flow_item_vxlan *vxlan_spec = NULL;
1279 const struct rte_flow_item_vxlan *vxlan_mask = NULL;
1280 const struct rte_flow_item_eth *i_eth_spec = NULL;
1281 const struct rte_flow_item_eth *i_eth_mask = NULL;
1282 const struct rte_flow_item_vlan *vlan_spec = NULL;
1283 const struct rte_flow_item_vlan *vlan_mask = NULL;
1284 bool is_vni_masked = 0;
1285 enum rte_flow_item_type item_type;
1286 bool vxlan_flag = 0;
1287 uint32_t tenant_id_be = 0;
1289 for (; item->type != RTE_FLOW_ITEM_TYPE_END; item++) {
1291 rte_flow_error_set(error, EINVAL,
1292 RTE_FLOW_ERROR_TYPE_ITEM,
1294 "Not support range");
1297 item_type = item->type;
1298 switch (item_type) {
1299 case RTE_FLOW_ITEM_TYPE_ETH:
1300 eth_spec = (const struct rte_flow_item_eth *)item->spec;
1301 eth_mask = (const struct rte_flow_item_eth *)item->mask;
1302 if ((!eth_spec && eth_mask) ||
1303 (eth_spec && !eth_mask)) {
1304 rte_flow_error_set(error, EINVAL,
1305 RTE_FLOW_ERROR_TYPE_ITEM,
1307 "Invalid ether spec/mask");
1311 if (eth_spec && eth_mask) {
1312 /* DST address of inner MAC shouldn't be masked.
1313 * SRC address of Inner MAC should be masked.
1315 if (!is_broadcast_ether_addr(ð_mask->dst) ||
1316 !is_zero_ether_addr(ð_mask->src) ||
1318 rte_flow_error_set(error, EINVAL,
1319 RTE_FLOW_ERROR_TYPE_ITEM,
1321 "Invalid ether spec/mask");
1326 rte_memcpy(&filter->outer_mac,
1330 rte_memcpy(&filter->inner_mac,
1336 o_eth_spec = eth_spec;
1337 o_eth_mask = eth_mask;
1339 i_eth_spec = eth_spec;
1340 i_eth_mask = eth_mask;
1344 case RTE_FLOW_ITEM_TYPE_VLAN:
1346 (const struct rte_flow_item_vlan *)item->spec;
1348 (const struct rte_flow_item_vlan *)item->mask;
1351 (const struct rte_flow_item_vlan *)item->spec;
1353 (const struct rte_flow_item_vlan *)item->mask;
1354 if (!(vlan_spec && vlan_mask)) {
1355 rte_flow_error_set(error, EINVAL,
1356 RTE_FLOW_ERROR_TYPE_ITEM,
1358 "Invalid vlan item");
1362 if (vlan_spec || vlan_mask)
1363 rte_flow_error_set(error, EINVAL,
1364 RTE_FLOW_ERROR_TYPE_ITEM,
1366 "Invalid vlan item");
1370 case RTE_FLOW_ITEM_TYPE_IPV4:
1371 filter->ip_type = I40E_TUNNEL_IPTYPE_IPV4;
1372 /* IPv4 is used to describe protocol,
1373 * spec and mask should be NULL.
1375 if (item->spec || item->mask) {
1376 rte_flow_error_set(error, EINVAL,
1377 RTE_FLOW_ERROR_TYPE_ITEM,
1379 "Invalid IPv4 item");
1383 case RTE_FLOW_ITEM_TYPE_IPV6:
1384 filter->ip_type = I40E_TUNNEL_IPTYPE_IPV6;
1385 /* IPv6 is used to describe protocol,
1386 * spec and mask should be NULL.
1388 if (item->spec || item->mask) {
1389 rte_flow_error_set(error, EINVAL,
1390 RTE_FLOW_ERROR_TYPE_ITEM,
1392 "Invalid IPv6 item");
1396 case RTE_FLOW_ITEM_TYPE_UDP:
1397 /* UDP is used to describe protocol,
1398 * spec and mask should be NULL.
1400 if (item->spec || item->mask) {
1401 rte_flow_error_set(error, EINVAL,
1402 RTE_FLOW_ERROR_TYPE_ITEM,
1404 "Invalid UDP item");
1408 case RTE_FLOW_ITEM_TYPE_VXLAN:
1410 (const struct rte_flow_item_vxlan *)item->spec;
1412 (const struct rte_flow_item_vxlan *)item->mask;
1413 /* Check if VXLAN item is used to describe protocol.
1414 * If yes, both spec and mask should be NULL.
1415 * If no, either spec or mask shouldn't be NULL.
1417 if ((!vxlan_spec && vxlan_mask) ||
1418 (vxlan_spec && !vxlan_mask)) {
1419 rte_flow_error_set(error, EINVAL,
1420 RTE_FLOW_ERROR_TYPE_ITEM,
1422 "Invalid VXLAN item");
1426 /* Check if VNI is masked. */
1429 i40e_check_tenant_id_mask(vxlan_mask->vni);
1430 if (is_vni_masked < 0) {
1431 rte_flow_error_set(error, EINVAL,
1432 RTE_FLOW_ERROR_TYPE_ITEM,
1434 "Invalid VNI mask");
1445 /* Check specification and mask to get the filter type */
1446 if (vlan_spec && vlan_mask &&
1447 (vlan_mask->tci == rte_cpu_to_be_16(I40E_TCI_MASK))) {
1448 /* If there's inner vlan */
1449 filter->inner_vlan = rte_be_to_cpu_16(vlan_spec->tci)
1451 if (vxlan_spec && vxlan_mask && !is_vni_masked) {
1452 /* If there's vxlan */
1453 rte_memcpy(((uint8_t *)&tenant_id_be + 1),
1454 vxlan_spec->vni, 3);
1455 filter->tenant_id = rte_be_to_cpu_32(tenant_id_be);
1456 if (!o_eth_spec && !o_eth_mask &&
1457 i_eth_spec && i_eth_mask)
1458 filter->filter_type =
1459 RTE_TUNNEL_FILTER_IMAC_IVLAN_TENID;
1461 rte_flow_error_set(error, EINVAL,
1462 RTE_FLOW_ERROR_TYPE_ITEM,
1464 "Invalid filter type");
1467 } else if (!vxlan_spec && !vxlan_mask) {
1468 /* If there's no vxlan */
1469 if (!o_eth_spec && !o_eth_mask &&
1470 i_eth_spec && i_eth_mask)
1471 filter->filter_type =
1472 RTE_TUNNEL_FILTER_IMAC_IVLAN;
1474 rte_flow_error_set(error, EINVAL,
1475 RTE_FLOW_ERROR_TYPE_ITEM,
1477 "Invalid filter type");
1481 rte_flow_error_set(error, EINVAL,
1482 RTE_FLOW_ERROR_TYPE_ITEM,
1484 "Invalid filter type");
1487 } else if ((!vlan_spec && !vlan_mask) ||
1488 (vlan_spec && vlan_mask && vlan_mask->tci == 0x0)) {
1489 /* If there's no inner vlan */
1490 if (vxlan_spec && vxlan_mask && !is_vni_masked) {
1491 /* If there's vxlan */
1492 rte_memcpy(((uint8_t *)&tenant_id_be + 1),
1493 vxlan_spec->vni, 3);
1494 filter->tenant_id = rte_be_to_cpu_32(tenant_id_be);
1495 if (!o_eth_spec && !o_eth_mask &&
1496 i_eth_spec && i_eth_mask)
1497 filter->filter_type =
1498 RTE_TUNNEL_FILTER_IMAC_TENID;
1499 else if (o_eth_spec && o_eth_mask &&
1500 i_eth_spec && i_eth_mask)
1501 filter->filter_type =
1502 RTE_TUNNEL_FILTER_OMAC_TENID_IMAC;
1503 } else if (!vxlan_spec && !vxlan_mask) {
1504 /* If there's no vxlan */
1505 if (!o_eth_spec && !o_eth_mask &&
1506 i_eth_spec && i_eth_mask) {
1507 filter->filter_type = ETH_TUNNEL_FILTER_IMAC;
1509 rte_flow_error_set(error, EINVAL,
1510 RTE_FLOW_ERROR_TYPE_ITEM, NULL,
1511 "Invalid filter type");
1515 rte_flow_error_set(error, EINVAL,
1516 RTE_FLOW_ERROR_TYPE_ITEM, NULL,
1517 "Invalid filter type");
1521 rte_flow_error_set(error, EINVAL,
1522 RTE_FLOW_ERROR_TYPE_ITEM, NULL,
1523 "Not supported by tunnel filter.");
1527 filter->tunnel_type = I40E_TUNNEL_TYPE_VXLAN;
1533 i40e_flow_parse_vxlan_filter(struct rte_eth_dev *dev,
1534 const struct rte_flow_attr *attr,
1535 const struct rte_flow_item pattern[],
1536 const struct rte_flow_action actions[],
1537 struct rte_flow_error *error,
1538 union i40e_filter_t *filter)
1540 struct i40e_tunnel_filter_conf *tunnel_filter =
1541 &filter->consistent_tunnel_filter;
1544 ret = i40e_flow_parse_vxlan_pattern(dev, pattern,
1545 error, tunnel_filter);
1549 ret = i40e_flow_parse_tunnel_action(dev, actions, error, tunnel_filter);
1553 ret = i40e_flow_parse_attr(attr, error);
1557 cons_filter_type = RTE_ETH_FILTER_TUNNEL;
1562 /* 1. Last in item should be NULL as range is not supported.
1563 * 2. Supported filter types: MPLS label.
1564 * 3. Mask of fields which need to be matched should be
1566 * 4. Mask of fields which needn't to be matched should be
1570 i40e_flow_parse_mpls_pattern(__rte_unused struct rte_eth_dev *dev,
1571 const struct rte_flow_item *pattern,
1572 struct rte_flow_error *error,
1573 struct i40e_tunnel_filter_conf *filter)
1575 const struct rte_flow_item *item = pattern;
1576 const struct rte_flow_item_mpls *mpls_spec;
1577 const struct rte_flow_item_mpls *mpls_mask;
1578 enum rte_flow_item_type item_type;
1579 bool is_mplsoudp = 0; /* 1 - MPLSoUDP, 0 - MPLSoGRE */
1580 const uint8_t label_mask[3] = {0xFF, 0xFF, 0xF0};
1581 uint32_t label_be = 0;
1583 for (; item->type != RTE_FLOW_ITEM_TYPE_END; item++) {
1585 rte_flow_error_set(error, EINVAL,
1586 RTE_FLOW_ERROR_TYPE_ITEM,
1588 "Not support range");
1591 item_type = item->type;
1592 switch (item_type) {
1593 case RTE_FLOW_ITEM_TYPE_ETH:
1594 if (item->spec || item->mask) {
1595 rte_flow_error_set(error, EINVAL,
1596 RTE_FLOW_ERROR_TYPE_ITEM,
1598 "Invalid ETH item");
1602 case RTE_FLOW_ITEM_TYPE_IPV4:
1603 filter->ip_type = I40E_TUNNEL_IPTYPE_IPV4;
1604 /* IPv4 is used to describe protocol,
1605 * spec and mask should be NULL.
1607 if (item->spec || item->mask) {
1608 rte_flow_error_set(error, EINVAL,
1609 RTE_FLOW_ERROR_TYPE_ITEM,
1611 "Invalid IPv4 item");
1615 case RTE_FLOW_ITEM_TYPE_IPV6:
1616 filter->ip_type = I40E_TUNNEL_IPTYPE_IPV6;
1617 /* IPv6 is used to describe protocol,
1618 * spec and mask should be NULL.
1620 if (item->spec || item->mask) {
1621 rte_flow_error_set(error, EINVAL,
1622 RTE_FLOW_ERROR_TYPE_ITEM,
1624 "Invalid IPv6 item");
1628 case RTE_FLOW_ITEM_TYPE_UDP:
1629 /* UDP is used to describe protocol,
1630 * spec and mask should be NULL.
1632 if (item->spec || item->mask) {
1633 rte_flow_error_set(error, EINVAL,
1634 RTE_FLOW_ERROR_TYPE_ITEM,
1636 "Invalid UDP item");
1641 case RTE_FLOW_ITEM_TYPE_GRE:
1642 /* GRE is used to describe protocol,
1643 * spec and mask should be NULL.
1645 if (item->spec || item->mask) {
1646 rte_flow_error_set(error, EINVAL,
1647 RTE_FLOW_ERROR_TYPE_ITEM,
1649 "Invalid GRE item");
1653 case RTE_FLOW_ITEM_TYPE_MPLS:
1655 (const struct rte_flow_item_mpls *)item->spec;
1657 (const struct rte_flow_item_mpls *)item->mask;
1659 if (!mpls_spec || !mpls_mask) {
1660 rte_flow_error_set(error, EINVAL,
1661 RTE_FLOW_ERROR_TYPE_ITEM,
1663 "Invalid MPLS item");
1667 if (memcmp(mpls_mask->label_tc_s, label_mask, 3)) {
1668 rte_flow_error_set(error, EINVAL,
1669 RTE_FLOW_ERROR_TYPE_ITEM,
1671 "Invalid MPLS label mask");
1674 rte_memcpy(((uint8_t *)&label_be + 1),
1675 mpls_spec->label_tc_s, 3);
1676 filter->tenant_id = rte_be_to_cpu_32(label_be) >> 4;
1684 filter->tunnel_type = I40E_TUNNEL_TYPE_MPLSoUDP;
1686 filter->tunnel_type = I40E_TUNNEL_TYPE_MPLSoGRE;
1692 i40e_flow_parse_mpls_filter(struct rte_eth_dev *dev,
1693 const struct rte_flow_attr *attr,
1694 const struct rte_flow_item pattern[],
1695 const struct rte_flow_action actions[],
1696 struct rte_flow_error *error,
1697 union i40e_filter_t *filter)
1699 struct i40e_tunnel_filter_conf *tunnel_filter =
1700 &filter->consistent_tunnel_filter;
1703 ret = i40e_flow_parse_mpls_pattern(dev, pattern,
1704 error, tunnel_filter);
1708 ret = i40e_flow_parse_tunnel_action(dev, actions, error, tunnel_filter);
1712 ret = i40e_flow_parse_attr(attr, error);
1716 cons_filter_type = RTE_ETH_FILTER_TUNNEL;
1722 i40e_flow_validate(struct rte_eth_dev *dev,
1723 const struct rte_flow_attr *attr,
1724 const struct rte_flow_item pattern[],
1725 const struct rte_flow_action actions[],
1726 struct rte_flow_error *error)
1728 struct rte_flow_item *items; /* internal pattern w/o VOID items */
1729 parse_filter_t parse_filter;
1730 uint32_t item_num = 0; /* non-void item number of pattern*/
1735 rte_flow_error_set(error, EINVAL, RTE_FLOW_ERROR_TYPE_ITEM_NUM,
1736 NULL, "NULL pattern.");
1741 rte_flow_error_set(error, EINVAL,
1742 RTE_FLOW_ERROR_TYPE_ACTION_NUM,
1743 NULL, "NULL action.");
1748 rte_flow_error_set(error, EINVAL,
1749 RTE_FLOW_ERROR_TYPE_ATTR,
1750 NULL, "NULL attribute.");
1754 memset(&cons_filter, 0, sizeof(cons_filter));
1756 /* Get the non-void item number of pattern */
1757 while ((pattern + i)->type != RTE_FLOW_ITEM_TYPE_END) {
1758 if ((pattern + i)->type != RTE_FLOW_ITEM_TYPE_VOID)
1764 items = rte_zmalloc("i40e_pattern",
1765 item_num * sizeof(struct rte_flow_item), 0);
1767 rte_flow_error_set(error, ENOMEM, RTE_FLOW_ERROR_TYPE_ITEM_NUM,
1768 NULL, "No memory for PMD internal items.");
1772 i40e_pattern_skip_void_item(items, pattern);
1774 /* Find if there's matched parse filter function */
1775 parse_filter = i40e_find_parse_filter_func(items);
1776 if (!parse_filter) {
1777 rte_flow_error_set(error, EINVAL,
1778 RTE_FLOW_ERROR_TYPE_ITEM,
1779 pattern, "Unsupported pattern");
1783 ret = parse_filter(dev, attr, items, actions, error, &cons_filter);
1790 static struct rte_flow *
1791 i40e_flow_create(struct rte_eth_dev *dev,
1792 const struct rte_flow_attr *attr,
1793 const struct rte_flow_item pattern[],
1794 const struct rte_flow_action actions[],
1795 struct rte_flow_error *error)
1797 struct i40e_pf *pf = I40E_DEV_PRIVATE_TO_PF(dev->data->dev_private);
1798 struct rte_flow *flow;
1801 flow = rte_zmalloc("i40e_flow", sizeof(struct rte_flow), 0);
1803 rte_flow_error_set(error, ENOMEM,
1804 RTE_FLOW_ERROR_TYPE_HANDLE, NULL,
1805 "Failed to allocate memory");
1809 ret = i40e_flow_validate(dev, attr, pattern, actions, error);
1813 switch (cons_filter_type) {
1814 case RTE_ETH_FILTER_ETHERTYPE:
1815 ret = i40e_ethertype_filter_set(pf,
1816 &cons_filter.ethertype_filter, 1);
1819 flow->rule = TAILQ_LAST(&pf->ethertype.ethertype_list,
1820 i40e_ethertype_filter_list);
1822 case RTE_ETH_FILTER_FDIR:
1823 ret = i40e_add_del_fdir_filter(dev,
1824 &cons_filter.fdir_filter, 1);
1827 flow->rule = TAILQ_LAST(&pf->fdir.fdir_list,
1828 i40e_fdir_filter_list);
1830 case RTE_ETH_FILTER_TUNNEL:
1831 ret = i40e_dev_consistent_tunnel_filter_set(pf,
1832 &cons_filter.consistent_tunnel_filter, 1);
1835 flow->rule = TAILQ_LAST(&pf->tunnel.tunnel_list,
1836 i40e_tunnel_filter_list);
1842 flow->filter_type = cons_filter_type;
1843 TAILQ_INSERT_TAIL(&pf->flow_list, flow, node);
1847 rte_flow_error_set(error, -ret,
1848 RTE_FLOW_ERROR_TYPE_HANDLE, NULL,
1849 "Failed to create flow.");
1855 i40e_flow_destroy(struct rte_eth_dev *dev,
1856 struct rte_flow *flow,
1857 struct rte_flow_error *error)
1859 struct i40e_pf *pf = I40E_DEV_PRIVATE_TO_PF(dev->data->dev_private);
1860 enum rte_filter_type filter_type = flow->filter_type;
1863 switch (filter_type) {
1864 case RTE_ETH_FILTER_ETHERTYPE:
1865 ret = i40e_flow_destroy_ethertype_filter(pf,
1866 (struct i40e_ethertype_filter *)flow->rule);
1868 case RTE_ETH_FILTER_TUNNEL:
1869 ret = i40e_flow_destroy_tunnel_filter(pf,
1870 (struct i40e_tunnel_filter *)flow->rule);
1872 case RTE_ETH_FILTER_FDIR:
1873 ret = i40e_add_del_fdir_filter(dev,
1874 &((struct i40e_fdir_filter *)flow->rule)->fdir, 0);
1877 PMD_DRV_LOG(WARNING, "Filter type (%d) not supported",
1884 TAILQ_REMOVE(&pf->flow_list, flow, node);
1887 rte_flow_error_set(error, -ret,
1888 RTE_FLOW_ERROR_TYPE_HANDLE, NULL,
1889 "Failed to destroy flow.");
1895 i40e_flow_destroy_ethertype_filter(struct i40e_pf *pf,
1896 struct i40e_ethertype_filter *filter)
1898 struct i40e_hw *hw = I40E_PF_TO_HW(pf);
1899 struct i40e_ethertype_rule *ethertype_rule = &pf->ethertype;
1900 struct i40e_ethertype_filter *node;
1901 struct i40e_control_filter_stats stats;
1905 if (!(filter->flags & RTE_ETHTYPE_FLAGS_MAC))
1906 flags |= I40E_AQC_ADD_CONTROL_PACKET_FLAGS_IGNORE_MAC;
1907 if (filter->flags & RTE_ETHTYPE_FLAGS_DROP)
1908 flags |= I40E_AQC_ADD_CONTROL_PACKET_FLAGS_DROP;
1909 flags |= I40E_AQC_ADD_CONTROL_PACKET_FLAGS_TO_QUEUE;
1911 memset(&stats, 0, sizeof(stats));
1912 ret = i40e_aq_add_rem_control_packet_filter(hw,
1913 filter->input.mac_addr.addr_bytes,
1914 filter->input.ether_type,
1915 flags, pf->main_vsi->seid,
1916 filter->queue, 0, &stats, NULL);
1920 node = i40e_sw_ethertype_filter_lookup(ethertype_rule, &filter->input);
1924 ret = i40e_sw_ethertype_filter_del(pf, &node->input);
1930 i40e_flow_destroy_tunnel_filter(struct i40e_pf *pf,
1931 struct i40e_tunnel_filter *filter)
1933 struct i40e_hw *hw = I40E_PF_TO_HW(pf);
1934 struct i40e_vsi *vsi = pf->main_vsi;
1935 struct i40e_aqc_add_rm_cloud_filt_elem_ext cld_filter;
1936 struct i40e_tunnel_rule *tunnel_rule = &pf->tunnel;
1937 struct i40e_tunnel_filter *node;
1938 bool big_buffer = 0;
1941 memset(&cld_filter, 0, sizeof(cld_filter));
1942 ether_addr_copy((struct ether_addr *)&filter->input.outer_mac,
1943 (struct ether_addr *)&cld_filter.element.outer_mac);
1944 ether_addr_copy((struct ether_addr *)&filter->input.inner_mac,
1945 (struct ether_addr *)&cld_filter.element.inner_mac);
1946 cld_filter.element.inner_vlan = filter->input.inner_vlan;
1947 cld_filter.element.flags = filter->input.flags;
1948 cld_filter.element.tenant_id = filter->input.tenant_id;
1949 cld_filter.element.queue_number = filter->queue;
1950 rte_memcpy(cld_filter.general_fields,
1951 filter->input.general_fields,
1952 sizeof(cld_filter.general_fields));
1954 if (((filter->input.flags & I40E_AQC_ADD_CLOUD_FILTER_TEID_MPLSoUDP) ==
1955 I40E_AQC_ADD_CLOUD_FILTER_TEID_MPLSoUDP) ||
1956 ((filter->input.flags & I40E_AQC_ADD_CLOUD_FILTER_TEID_MPLSoGRE) ==
1957 I40E_AQC_ADD_CLOUD_FILTER_TEID_MPLSoGRE))
1961 ret = i40e_aq_remove_cloud_filters_big_buffer(hw, vsi->seid,
1964 ret = i40e_aq_remove_cloud_filters(hw, vsi->seid,
1965 &cld_filter.element, 1);
1969 node = i40e_sw_tunnel_filter_lookup(tunnel_rule, &filter->input);
1973 ret = i40e_sw_tunnel_filter_del(pf, &node->input);
1979 i40e_flow_flush(struct rte_eth_dev *dev, struct rte_flow_error *error)
1981 struct i40e_pf *pf = I40E_DEV_PRIVATE_TO_PF(dev->data->dev_private);
1984 ret = i40e_flow_flush_fdir_filter(pf);
1986 rte_flow_error_set(error, -ret,
1987 RTE_FLOW_ERROR_TYPE_HANDLE, NULL,
1988 "Failed to flush FDIR flows.");
1992 ret = i40e_flow_flush_ethertype_filter(pf);
1994 rte_flow_error_set(error, -ret,
1995 RTE_FLOW_ERROR_TYPE_HANDLE, NULL,
1996 "Failed to ethertype flush flows.");
2000 ret = i40e_flow_flush_tunnel_filter(pf);
2002 rte_flow_error_set(error, -ret,
2003 RTE_FLOW_ERROR_TYPE_HANDLE, NULL,
2004 "Failed to flush tunnel flows.");
2012 i40e_flow_flush_fdir_filter(struct i40e_pf *pf)
2014 struct rte_eth_dev *dev = pf->adapter->eth_dev;
2015 struct i40e_fdir_info *fdir_info = &pf->fdir;
2016 struct i40e_fdir_filter *fdir_filter;
2017 struct rte_flow *flow;
2021 ret = i40e_fdir_flush(dev);
2023 /* Delete FDIR filters in FDIR list. */
2024 while ((fdir_filter = TAILQ_FIRST(&fdir_info->fdir_list))) {
2025 ret = i40e_sw_fdir_filter_del(pf,
2026 &fdir_filter->fdir.input);
2031 /* Delete FDIR flows in flow list. */
2032 TAILQ_FOREACH_SAFE(flow, &pf->flow_list, node, temp) {
2033 if (flow->filter_type == RTE_ETH_FILTER_FDIR) {
2034 TAILQ_REMOVE(&pf->flow_list, flow, node);
2043 /* Flush all ethertype filters */
2045 i40e_flow_flush_ethertype_filter(struct i40e_pf *pf)
2047 struct i40e_ethertype_filter_list
2048 *ethertype_list = &pf->ethertype.ethertype_list;
2049 struct i40e_ethertype_filter *filter;
2050 struct rte_flow *flow;
2054 while ((filter = TAILQ_FIRST(ethertype_list))) {
2055 ret = i40e_flow_destroy_ethertype_filter(pf, filter);
2060 /* Delete ethertype flows in flow list. */
2061 TAILQ_FOREACH_SAFE(flow, &pf->flow_list, node, temp) {
2062 if (flow->filter_type == RTE_ETH_FILTER_ETHERTYPE) {
2063 TAILQ_REMOVE(&pf->flow_list, flow, node);
2071 /* Flush all tunnel filters */
2073 i40e_flow_flush_tunnel_filter(struct i40e_pf *pf)
2075 struct i40e_tunnel_filter_list
2076 *tunnel_list = &pf->tunnel.tunnel_list;
2077 struct i40e_tunnel_filter *filter;
2078 struct rte_flow *flow;
2082 while ((filter = TAILQ_FIRST(tunnel_list))) {
2083 ret = i40e_flow_destroy_tunnel_filter(pf, filter);
2088 /* Delete tunnel flows in flow list. */
2089 TAILQ_FOREACH_SAFE(flow, &pf->flow_list, node, temp) {
2090 if (flow->filter_type == RTE_ETH_FILTER_TUNNEL) {
2091 TAILQ_REMOVE(&pf->flow_list, flow, node);