net/i40e: parse flow director filter
[dpdk.git] / drivers / net / i40e / i40e_flow.c
1 /*-
2  *   BSD LICENSE
3  *
4  *   Copyright (c) 2016 Intel Corporation. All rights reserved.
5  *
6  *   Redistribution and use in source and binary forms, with or without
7  *   modification, are permitted provided that the following conditions
8  *   are met:
9  *
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
15  *       distribution.
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.
19  *
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.
31  */
32
33 #include <sys/queue.h>
34 #include <stdio.h>
35 #include <errno.h>
36 #include <stdint.h>
37 #include <string.h>
38 #include <unistd.h>
39 #include <stdarg.h>
40
41 #include <rte_ether.h>
42 #include <rte_ethdev.h>
43 #include <rte_log.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>
49
50 #include "i40e_logs.h"
51 #include "base/i40e_type.h"
52 #include "base/i40e_prototype.h"
53 #include "i40e_ethdev.h"
54
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
59 static int i40e_flow_validate(struct rte_eth_dev *dev,
60                               const struct rte_flow_attr *attr,
61                               const struct rte_flow_item pattern[],
62                               const struct rte_flow_action actions[],
63                               struct rte_flow_error *error);
64 static int
65 i40e_flow_parse_ethertype_pattern(struct rte_eth_dev *dev,
66                                   const struct rte_flow_item *pattern,
67                                   struct rte_flow_error *error,
68                                   struct rte_eth_ethertype_filter *filter);
69 static int i40e_flow_parse_ethertype_action(struct rte_eth_dev *dev,
70                                     const struct rte_flow_action *actions,
71                                     struct rte_flow_error *error,
72                                     struct rte_eth_ethertype_filter *filter);
73 static int i40e_flow_parse_fdir_pattern(struct rte_eth_dev *dev,
74                                         const struct rte_flow_item *pattern,
75                                         struct rte_flow_error *error,
76                                         struct rte_eth_fdir_filter *filter);
77 static int i40e_flow_parse_fdir_action(struct rte_eth_dev *dev,
78                                        const struct rte_flow_action *actions,
79                                        struct rte_flow_error *error,
80                                        struct rte_eth_fdir_filter *filter);
81 static int i40e_flow_parse_attr(const struct rte_flow_attr *attr,
82                                 struct rte_flow_error *error);
83 static int i40e_flow_parse_ethertype_filter(struct rte_eth_dev *dev,
84                                     const struct rte_flow_attr *attr,
85                                     const struct rte_flow_item pattern[],
86                                     const struct rte_flow_action actions[],
87                                     struct rte_flow_error *error,
88                                     union i40e_filter_t *filter);
89 static int i40e_flow_parse_fdir_filter(struct rte_eth_dev *dev,
90                                        const struct rte_flow_attr *attr,
91                                        const struct rte_flow_item pattern[],
92                                        const struct rte_flow_action actions[],
93                                        struct rte_flow_error *error,
94                                        union i40e_filter_t *filter);
95
96 const struct rte_flow_ops i40e_flow_ops = {
97         .validate = i40e_flow_validate,
98 };
99
100 union i40e_filter_t cons_filter;
101
102 /* Pattern matched ethertype filter */
103 static enum rte_flow_item_type pattern_ethertype[] = {
104         RTE_FLOW_ITEM_TYPE_ETH,
105         RTE_FLOW_ITEM_TYPE_END,
106 };
107
108 /* Pattern matched flow director filter */
109 static enum rte_flow_item_type pattern_fdir_ipv4[] = {
110         RTE_FLOW_ITEM_TYPE_IPV4,
111         RTE_FLOW_ITEM_TYPE_END,
112 };
113
114 static enum rte_flow_item_type pattern_fdir_ipv4_ext[] = {
115         RTE_FLOW_ITEM_TYPE_ETH,
116         RTE_FLOW_ITEM_TYPE_IPV4,
117         RTE_FLOW_ITEM_TYPE_END,
118 };
119
120 static enum rte_flow_item_type pattern_fdir_ipv4_udp[] = {
121         RTE_FLOW_ITEM_TYPE_IPV4,
122         RTE_FLOW_ITEM_TYPE_UDP,
123         RTE_FLOW_ITEM_TYPE_END,
124 };
125
126 static enum rte_flow_item_type pattern_fdir_ipv4_udp_ext[] = {
127         RTE_FLOW_ITEM_TYPE_ETH,
128         RTE_FLOW_ITEM_TYPE_IPV4,
129         RTE_FLOW_ITEM_TYPE_UDP,
130         RTE_FLOW_ITEM_TYPE_END,
131 };
132
133 static enum rte_flow_item_type pattern_fdir_ipv4_tcp[] = {
134         RTE_FLOW_ITEM_TYPE_IPV4,
135         RTE_FLOW_ITEM_TYPE_TCP,
136         RTE_FLOW_ITEM_TYPE_END,
137 };
138
139 static enum rte_flow_item_type pattern_fdir_ipv4_tcp_ext[] = {
140         RTE_FLOW_ITEM_TYPE_ETH,
141         RTE_FLOW_ITEM_TYPE_IPV4,
142         RTE_FLOW_ITEM_TYPE_TCP,
143         RTE_FLOW_ITEM_TYPE_END,
144 };
145
146 static enum rte_flow_item_type pattern_fdir_ipv4_sctp[] = {
147         RTE_FLOW_ITEM_TYPE_IPV4,
148         RTE_FLOW_ITEM_TYPE_SCTP,
149         RTE_FLOW_ITEM_TYPE_END,
150 };
151
152 static enum rte_flow_item_type pattern_fdir_ipv4_sctp_ext[] = {
153         RTE_FLOW_ITEM_TYPE_ETH,
154         RTE_FLOW_ITEM_TYPE_IPV4,
155         RTE_FLOW_ITEM_TYPE_SCTP,
156         RTE_FLOW_ITEM_TYPE_END,
157 };
158
159 static enum rte_flow_item_type pattern_fdir_ipv6[] = {
160         RTE_FLOW_ITEM_TYPE_IPV6,
161         RTE_FLOW_ITEM_TYPE_END,
162 };
163
164 static enum rte_flow_item_type pattern_fdir_ipv6_ext[] = {
165         RTE_FLOW_ITEM_TYPE_ETH,
166         RTE_FLOW_ITEM_TYPE_IPV6,
167         RTE_FLOW_ITEM_TYPE_END,
168 };
169
170 static enum rte_flow_item_type pattern_fdir_ipv6_udp[] = {
171         RTE_FLOW_ITEM_TYPE_IPV6,
172         RTE_FLOW_ITEM_TYPE_UDP,
173         RTE_FLOW_ITEM_TYPE_END,
174 };
175
176 static enum rte_flow_item_type pattern_fdir_ipv6_udp_ext[] = {
177         RTE_FLOW_ITEM_TYPE_ETH,
178         RTE_FLOW_ITEM_TYPE_IPV6,
179         RTE_FLOW_ITEM_TYPE_UDP,
180         RTE_FLOW_ITEM_TYPE_END,
181 };
182
183 static enum rte_flow_item_type pattern_fdir_ipv6_tcp[] = {
184         RTE_FLOW_ITEM_TYPE_IPV6,
185         RTE_FLOW_ITEM_TYPE_TCP,
186         RTE_FLOW_ITEM_TYPE_END,
187 };
188
189 static enum rte_flow_item_type pattern_fdir_ipv6_tcp_ext[] = {
190         RTE_FLOW_ITEM_TYPE_ETH,
191         RTE_FLOW_ITEM_TYPE_IPV6,
192         RTE_FLOW_ITEM_TYPE_TCP,
193         RTE_FLOW_ITEM_TYPE_END,
194 };
195
196 static enum rte_flow_item_type pattern_fdir_ipv6_sctp[] = {
197         RTE_FLOW_ITEM_TYPE_IPV6,
198         RTE_FLOW_ITEM_TYPE_SCTP,
199         RTE_FLOW_ITEM_TYPE_END,
200 };
201
202 static enum rte_flow_item_type pattern_fdir_ipv6_sctp_ext[] = {
203         RTE_FLOW_ITEM_TYPE_ETH,
204         RTE_FLOW_ITEM_TYPE_IPV6,
205         RTE_FLOW_ITEM_TYPE_SCTP,
206         RTE_FLOW_ITEM_TYPE_END,
207 };
208
209 static struct i40e_valid_pattern i40e_supported_patterns[] = {
210         /* Ethertype */
211         { pattern_ethertype, i40e_flow_parse_ethertype_filter },
212         /* FDIR */
213         { pattern_fdir_ipv4, i40e_flow_parse_fdir_filter },
214         { pattern_fdir_ipv4_ext, i40e_flow_parse_fdir_filter },
215         { pattern_fdir_ipv4_udp, i40e_flow_parse_fdir_filter },
216         { pattern_fdir_ipv4_udp_ext, i40e_flow_parse_fdir_filter },
217         { pattern_fdir_ipv4_tcp, i40e_flow_parse_fdir_filter },
218         { pattern_fdir_ipv4_tcp_ext, i40e_flow_parse_fdir_filter },
219         { pattern_fdir_ipv4_sctp, i40e_flow_parse_fdir_filter },
220         { pattern_fdir_ipv4_sctp_ext, i40e_flow_parse_fdir_filter },
221         { pattern_fdir_ipv6, i40e_flow_parse_fdir_filter },
222         { pattern_fdir_ipv6_ext, i40e_flow_parse_fdir_filter },
223         { pattern_fdir_ipv6_udp, i40e_flow_parse_fdir_filter },
224         { pattern_fdir_ipv6_udp_ext, i40e_flow_parse_fdir_filter },
225         { pattern_fdir_ipv6_tcp, i40e_flow_parse_fdir_filter },
226         { pattern_fdir_ipv6_tcp_ext, i40e_flow_parse_fdir_filter },
227         { pattern_fdir_ipv6_sctp, i40e_flow_parse_fdir_filter },
228         { pattern_fdir_ipv6_sctp_ext, i40e_flow_parse_fdir_filter },
229 };
230
231 #define NEXT_ITEM_OF_ACTION(act, actions, index)                        \
232         do {                                                            \
233                 act = actions + index;                                  \
234                 while (act->type == RTE_FLOW_ACTION_TYPE_VOID) {        \
235                         index++;                                        \
236                         act = actions + index;                          \
237                 }                                                       \
238         } while (0)
239
240 /* Find the first VOID or non-VOID item pointer */
241 static const struct rte_flow_item *
242 i40e_find_first_item(const struct rte_flow_item *item, bool is_void)
243 {
244         bool is_find;
245
246         while (item->type != RTE_FLOW_ITEM_TYPE_END) {
247                 if (is_void)
248                         is_find = item->type == RTE_FLOW_ITEM_TYPE_VOID;
249                 else
250                         is_find = item->type != RTE_FLOW_ITEM_TYPE_VOID;
251                 if (is_find)
252                         break;
253                 item++;
254         }
255         return item;
256 }
257
258 /* Skip all VOID items of the pattern */
259 static void
260 i40e_pattern_skip_void_item(struct rte_flow_item *items,
261                             const struct rte_flow_item *pattern)
262 {
263         uint32_t cpy_count = 0;
264         const struct rte_flow_item *pb = pattern, *pe = pattern;
265
266         for (;;) {
267                 /* Find a non-void item first */
268                 pb = i40e_find_first_item(pb, false);
269                 if (pb->type == RTE_FLOW_ITEM_TYPE_END) {
270                         pe = pb;
271                         break;
272                 }
273
274                 /* Find a void item */
275                 pe = i40e_find_first_item(pb + 1, true);
276
277                 cpy_count = pe - pb;
278                 rte_memcpy(items, pb, sizeof(struct rte_flow_item) * cpy_count);
279
280                 items += cpy_count;
281
282                 if (pe->type == RTE_FLOW_ITEM_TYPE_END) {
283                         pb = pe;
284                         break;
285                 }
286
287                 pb = pe + 1;
288         }
289         /* Copy the END item. */
290         rte_memcpy(items, pe, sizeof(struct rte_flow_item));
291 }
292
293 /* Check if the pattern matches a supported item type array */
294 static bool
295 i40e_match_pattern(enum rte_flow_item_type *item_array,
296                    struct rte_flow_item *pattern)
297 {
298         struct rte_flow_item *item = pattern;
299
300         while ((*item_array == item->type) &&
301                (*item_array != RTE_FLOW_ITEM_TYPE_END)) {
302                 item_array++;
303                 item++;
304         }
305
306         return (*item_array == RTE_FLOW_ITEM_TYPE_END &&
307                 item->type == RTE_FLOW_ITEM_TYPE_END);
308 }
309
310 /* Find if there's parse filter function matched */
311 static parse_filter_t
312 i40e_find_parse_filter_func(struct rte_flow_item *pattern)
313 {
314         parse_filter_t parse_filter = NULL;
315         uint8_t i = 0;
316
317         for (; i < RTE_DIM(i40e_supported_patterns); i++) {
318                 if (i40e_match_pattern(i40e_supported_patterns[i].items,
319                                         pattern)) {
320                         parse_filter = i40e_supported_patterns[i].parse_filter;
321                         break;
322                 }
323         }
324
325         return parse_filter;
326 }
327
328 /* Parse attributes */
329 static int
330 i40e_flow_parse_attr(const struct rte_flow_attr *attr,
331                      struct rte_flow_error *error)
332 {
333         /* Must be input direction */
334         if (!attr->ingress) {
335                 rte_flow_error_set(error, EINVAL,
336                                    RTE_FLOW_ERROR_TYPE_ATTR_INGRESS,
337                                    attr, "Only support ingress.");
338                 return -rte_errno;
339         }
340
341         /* Not supported */
342         if (attr->egress) {
343                 rte_flow_error_set(error, EINVAL,
344                                    RTE_FLOW_ERROR_TYPE_ATTR_EGRESS,
345                                    attr, "Not support egress.");
346                 return -rte_errno;
347         }
348
349         /* Not supported */
350         if (attr->priority) {
351                 rte_flow_error_set(error, EINVAL,
352                                    RTE_FLOW_ERROR_TYPE_ATTR_PRIORITY,
353                                    attr, "Not support priority.");
354                 return -rte_errno;
355         }
356
357         /* Not supported */
358         if (attr->group) {
359                 rte_flow_error_set(error, EINVAL,
360                                    RTE_FLOW_ERROR_TYPE_ATTR_GROUP,
361                                    attr, "Not support group.");
362                 return -rte_errno;
363         }
364
365         return 0;
366 }
367
368 static uint16_t
369 i40e_get_outer_vlan(struct rte_eth_dev *dev)
370 {
371         struct i40e_hw *hw = I40E_DEV_PRIVATE_TO_HW(dev->data->dev_private);
372         int qinq = dev->data->dev_conf.rxmode.hw_vlan_extend;
373         uint64_t reg_r = 0;
374         uint16_t reg_id;
375         uint16_t tpid;
376
377         if (qinq)
378                 reg_id = 2;
379         else
380                 reg_id = 3;
381
382         i40e_aq_debug_read_register(hw, I40E_GL_SWT_L2TAGCTRL(reg_id),
383                                     &reg_r, NULL);
384
385         tpid = (reg_r >> I40E_GL_SWT_L2TAGCTRL_ETHERTYPE_SHIFT) & 0xFFFF;
386
387         return tpid;
388 }
389
390 /* 1. Last in item should be NULL as range is not supported.
391  * 2. Supported filter types: MAC_ETHTYPE and ETHTYPE.
392  * 3. SRC mac_addr mask should be 00:00:00:00:00:00.
393  * 4. DST mac_addr mask should be 00:00:00:00:00:00 or
394  *    FF:FF:FF:FF:FF:FF
395  * 5. Ether_type mask should be 0xFFFF.
396  */
397 static int
398 i40e_flow_parse_ethertype_pattern(struct rte_eth_dev *dev,
399                                   const struct rte_flow_item *pattern,
400                                   struct rte_flow_error *error,
401                                   struct rte_eth_ethertype_filter *filter)
402 {
403         const struct rte_flow_item *item = pattern;
404         const struct rte_flow_item_eth *eth_spec;
405         const struct rte_flow_item_eth *eth_mask;
406         enum rte_flow_item_type item_type;
407         uint16_t outer_tpid;
408
409         outer_tpid = i40e_get_outer_vlan(dev);
410
411         for (; item->type != RTE_FLOW_ITEM_TYPE_END; item++) {
412                 if (item->last) {
413                         rte_flow_error_set(error, EINVAL,
414                                            RTE_FLOW_ERROR_TYPE_ITEM,
415                                            item,
416                                            "Not support range");
417                         return -rte_errno;
418                 }
419                 item_type = item->type;
420                 switch (item_type) {
421                 case RTE_FLOW_ITEM_TYPE_ETH:
422                         eth_spec = (const struct rte_flow_item_eth *)item->spec;
423                         eth_mask = (const struct rte_flow_item_eth *)item->mask;
424                         /* Get the MAC info. */
425                         if (!eth_spec || !eth_mask) {
426                                 rte_flow_error_set(error, EINVAL,
427                                                    RTE_FLOW_ERROR_TYPE_ITEM,
428                                                    item,
429                                                    "NULL ETH spec/mask");
430                                 return -rte_errno;
431                         }
432
433                         /* Mask bits of source MAC address must be full of 0.
434                          * Mask bits of destination MAC address must be full
435                          * of 1 or full of 0.
436                          */
437                         if (!is_zero_ether_addr(&eth_mask->src) ||
438                             (!is_zero_ether_addr(&eth_mask->dst) &&
439                              !is_broadcast_ether_addr(&eth_mask->dst))) {
440                                 rte_flow_error_set(error, EINVAL,
441                                                    RTE_FLOW_ERROR_TYPE_ITEM,
442                                                    item,
443                                                    "Invalid MAC_addr mask");
444                                 return -rte_errno;
445                         }
446
447                         if ((eth_mask->type & UINT16_MAX) != UINT16_MAX) {
448                                 rte_flow_error_set(error, EINVAL,
449                                                    RTE_FLOW_ERROR_TYPE_ITEM,
450                                                    item,
451                                                    "Invalid ethertype mask");
452                                 return -rte_errno;
453                         }
454
455                         /* If mask bits of destination MAC address
456                          * are full of 1, set RTE_ETHTYPE_FLAGS_MAC.
457                          */
458                         if (is_broadcast_ether_addr(&eth_mask->dst)) {
459                                 filter->mac_addr = eth_spec->dst;
460                                 filter->flags |= RTE_ETHTYPE_FLAGS_MAC;
461                         } else {
462                                 filter->flags &= ~RTE_ETHTYPE_FLAGS_MAC;
463                         }
464                         filter->ether_type = rte_be_to_cpu_16(eth_spec->type);
465
466                         if (filter->ether_type == ETHER_TYPE_IPv4 ||
467                             filter->ether_type == ETHER_TYPE_IPv6 ||
468                             filter->ether_type == outer_tpid) {
469                                 rte_flow_error_set(error, EINVAL,
470                                                    RTE_FLOW_ERROR_TYPE_ITEM,
471                                                    item,
472                                                    "Unsupported ether_type in"
473                                                    " control packet filter.");
474                                 return -rte_errno;
475                         }
476                         break;
477                 default:
478                         break;
479                 }
480         }
481
482         return 0;
483 }
484
485 /* Ethertype action only supports QUEUE or DROP. */
486 static int
487 i40e_flow_parse_ethertype_action(struct rte_eth_dev *dev,
488                                  const struct rte_flow_action *actions,
489                                  struct rte_flow_error *error,
490                                  struct rte_eth_ethertype_filter *filter)
491 {
492         struct i40e_pf *pf = I40E_DEV_PRIVATE_TO_PF(dev->data->dev_private);
493         const struct rte_flow_action *act;
494         const struct rte_flow_action_queue *act_q;
495         uint32_t index = 0;
496
497         /* Check if the first non-void action is QUEUE or DROP. */
498         NEXT_ITEM_OF_ACTION(act, actions, index);
499         if (act->type != RTE_FLOW_ACTION_TYPE_QUEUE &&
500             act->type != RTE_FLOW_ACTION_TYPE_DROP) {
501                 rte_flow_error_set(error, EINVAL, RTE_FLOW_ERROR_TYPE_ACTION,
502                                    act, "Not supported action.");
503                 return -rte_errno;
504         }
505
506         if (act->type == RTE_FLOW_ACTION_TYPE_QUEUE) {
507                 act_q = (const struct rte_flow_action_queue *)act->conf;
508                 filter->queue = act_q->index;
509                 if (filter->queue >= pf->dev_data->nb_rx_queues) {
510                         rte_flow_error_set(error, EINVAL,
511                                            RTE_FLOW_ERROR_TYPE_ACTION,
512                                            act, "Invalid queue ID for"
513                                            " ethertype_filter.");
514                         return -rte_errno;
515                 }
516         } else {
517                 filter->flags |= RTE_ETHTYPE_FLAGS_DROP;
518         }
519
520         /* Check if the next non-void item is END */
521         index++;
522         NEXT_ITEM_OF_ACTION(act, actions, index);
523         if (act->type != RTE_FLOW_ACTION_TYPE_END) {
524                 rte_flow_error_set(error, EINVAL, RTE_FLOW_ERROR_TYPE_ACTION,
525                                    act, "Not supported action.");
526                 return -rte_errno;
527         }
528
529         return 0;
530 }
531
532 static int
533 i40e_flow_parse_ethertype_filter(struct rte_eth_dev *dev,
534                                  const struct rte_flow_attr *attr,
535                                  const struct rte_flow_item pattern[],
536                                  const struct rte_flow_action actions[],
537                                  struct rte_flow_error *error,
538                                  union i40e_filter_t *filter)
539 {
540         struct rte_eth_ethertype_filter *ethertype_filter =
541                 &filter->ethertype_filter;
542         int ret;
543
544         ret = i40e_flow_parse_ethertype_pattern(dev, pattern, error,
545                                                 ethertype_filter);
546         if (ret)
547                 return ret;
548
549         ret = i40e_flow_parse_ethertype_action(dev, actions, error,
550                                                ethertype_filter);
551         if (ret)
552                 return ret;
553
554         ret = i40e_flow_parse_attr(attr, error);
555         if (ret)
556                 return ret;
557
558         return ret;
559 }
560
561 /* 1. Last in item should be NULL as range is not supported.
562  * 2. Supported flow type and input set: refer to array
563  *    default_inset_table in i40e_ethdev.c.
564  * 3. Mask of fields which need to be matched should be
565  *    filled with 1.
566  * 4. Mask of fields which needn't to be matched should be
567  *    filled with 0.
568  */
569 static int
570 i40e_flow_parse_fdir_pattern(struct rte_eth_dev *dev,
571                              const struct rte_flow_item *pattern,
572                              struct rte_flow_error *error,
573                              struct rte_eth_fdir_filter *filter)
574 {
575         struct i40e_pf *pf = I40E_DEV_PRIVATE_TO_PF(dev->data->dev_private);
576         const struct rte_flow_item *item = pattern;
577         const struct rte_flow_item_eth *eth_spec, *eth_mask;
578         const struct rte_flow_item_ipv4 *ipv4_spec, *ipv4_mask;
579         const struct rte_flow_item_ipv6 *ipv6_spec, *ipv6_mask;
580         const struct rte_flow_item_tcp *tcp_spec, *tcp_mask;
581         const struct rte_flow_item_udp *udp_spec, *udp_mask;
582         const struct rte_flow_item_sctp *sctp_spec, *sctp_mask;
583         const struct rte_flow_item_vf *vf_spec;
584         uint32_t flow_type = RTE_ETH_FLOW_UNKNOWN;
585         enum i40e_filter_pctype pctype;
586         uint64_t input_set = I40E_INSET_NONE;
587         uint16_t flag_offset;
588         enum rte_flow_item_type item_type;
589         enum rte_flow_item_type l3 = RTE_FLOW_ITEM_TYPE_END;
590         uint32_t j;
591
592         for (; item->type != RTE_FLOW_ITEM_TYPE_END; item++) {
593                 if (item->last) {
594                         rte_flow_error_set(error, EINVAL,
595                                            RTE_FLOW_ERROR_TYPE_ITEM,
596                                            item,
597                                            "Not support range");
598                         return -rte_errno;
599                 }
600                 item_type = item->type;
601                 switch (item_type) {
602                 case RTE_FLOW_ITEM_TYPE_ETH:
603                         eth_spec = (const struct rte_flow_item_eth *)item->spec;
604                         eth_mask = (const struct rte_flow_item_eth *)item->mask;
605                         if (eth_spec || eth_mask) {
606                                 rte_flow_error_set(error, EINVAL,
607                                                    RTE_FLOW_ERROR_TYPE_ITEM,
608                                                    item,
609                                                    "Invalid ETH spec/mask");
610                                 return -rte_errno;
611                         }
612                         break;
613                 case RTE_FLOW_ITEM_TYPE_IPV4:
614                         l3 = RTE_FLOW_ITEM_TYPE_IPV4;
615                         ipv4_spec =
616                                 (const struct rte_flow_item_ipv4 *)item->spec;
617                         ipv4_mask =
618                                 (const struct rte_flow_item_ipv4 *)item->mask;
619                         if (!ipv4_spec || !ipv4_mask) {
620                                 rte_flow_error_set(error, EINVAL,
621                                                    RTE_FLOW_ERROR_TYPE_ITEM,
622                                                    item,
623                                                    "NULL IPv4 spec/mask");
624                                 return -rte_errno;
625                         }
626
627                         /* Check IPv4 mask and update input set */
628                         if (ipv4_mask->hdr.version_ihl ||
629                             ipv4_mask->hdr.total_length ||
630                             ipv4_mask->hdr.packet_id ||
631                             ipv4_mask->hdr.fragment_offset ||
632                             ipv4_mask->hdr.hdr_checksum) {
633                                 rte_flow_error_set(error, EINVAL,
634                                                    RTE_FLOW_ERROR_TYPE_ITEM,
635                                                    item,
636                                                    "Invalid IPv4 mask.");
637                                 return -rte_errno;
638                         }
639
640                         if (ipv4_mask->hdr.src_addr == UINT32_MAX)
641                                 input_set |= I40E_INSET_IPV4_SRC;
642                         if (ipv4_mask->hdr.dst_addr == UINT32_MAX)
643                                 input_set |= I40E_INSET_IPV4_DST;
644                         if (ipv4_mask->hdr.type_of_service == UINT8_MAX)
645                                 input_set |= I40E_INSET_IPV4_TOS;
646                         if (ipv4_mask->hdr.time_to_live == UINT8_MAX)
647                                 input_set |= I40E_INSET_IPV4_TTL;
648                         if (ipv4_mask->hdr.next_proto_id == UINT8_MAX)
649                                 input_set |= I40E_INSET_IPV4_PROTO;
650
651                         /* Get filter info */
652                         flow_type = RTE_ETH_FLOW_NONFRAG_IPV4_OTHER;
653                         /* Check if it is fragment. */
654                         flag_offset =
655                               rte_be_to_cpu_16(ipv4_spec->hdr.fragment_offset);
656                         if (flag_offset & IPV4_HDR_OFFSET_MASK ||
657                             flag_offset & IPV4_HDR_MF_FLAG)
658                                 flow_type = RTE_ETH_FLOW_FRAG_IPV4;
659
660                         /* Get the filter info */
661                         filter->input.flow.ip4_flow.proto =
662                                 ipv4_spec->hdr.next_proto_id;
663                         filter->input.flow.ip4_flow.tos =
664                                 ipv4_spec->hdr.type_of_service;
665                         filter->input.flow.ip4_flow.ttl =
666                                 ipv4_spec->hdr.time_to_live;
667                         filter->input.flow.ip4_flow.src_ip =
668                                 ipv4_spec->hdr.src_addr;
669                         filter->input.flow.ip4_flow.dst_ip =
670                                 ipv4_spec->hdr.dst_addr;
671
672                         break;
673                 case RTE_FLOW_ITEM_TYPE_IPV6:
674                         l3 = RTE_FLOW_ITEM_TYPE_IPV6;
675                         ipv6_spec =
676                                 (const struct rte_flow_item_ipv6 *)item->spec;
677                         ipv6_mask =
678                                 (const struct rte_flow_item_ipv6 *)item->mask;
679                         if (!ipv6_spec || !ipv6_mask) {
680                                 rte_flow_error_set(error, EINVAL,
681                                                    RTE_FLOW_ERROR_TYPE_ITEM,
682                                                    item,
683                                                    "NULL IPv6 spec/mask");
684                                 return -rte_errno;
685                         }
686
687                         /* Check IPv6 mask and update input set */
688                         if (ipv6_mask->hdr.payload_len) {
689                                 rte_flow_error_set(error, EINVAL,
690                                                    RTE_FLOW_ERROR_TYPE_ITEM,
691                                                    item,
692                                                    "Invalid IPv6 mask");
693                                 return -rte_errno;
694                         }
695
696                         /* SCR and DST address of IPv6 shouldn't be masked */
697                         for (j = 0; j < RTE_DIM(ipv6_mask->hdr.src_addr); j++) {
698                                 if (ipv6_mask->hdr.src_addr[j] != UINT8_MAX ||
699                                     ipv6_mask->hdr.dst_addr[j] != UINT8_MAX) {
700                                         rte_flow_error_set(error, EINVAL,
701                                                    RTE_FLOW_ERROR_TYPE_ITEM,
702                                                    item,
703                                                    "Invalid IPv6 mask");
704                                         return -rte_errno;
705                                 }
706                         }
707
708                         input_set |= I40E_INSET_IPV6_SRC;
709                         input_set |= I40E_INSET_IPV6_DST;
710
711                         if ((ipv6_mask->hdr.vtc_flow &
712                              rte_cpu_to_be_16(I40E_IPV6_TC_MASK))
713                             == rte_cpu_to_be_16(I40E_IPV6_TC_MASK))
714                                 input_set |= I40E_INSET_IPV6_TC;
715                         if (ipv6_mask->hdr.proto == UINT8_MAX)
716                                 input_set |= I40E_INSET_IPV6_NEXT_HDR;
717                         if (ipv6_mask->hdr.hop_limits == UINT8_MAX)
718                                 input_set |= I40E_INSET_IPV6_HOP_LIMIT;
719
720                         /* Get filter info */
721                         filter->input.flow.ipv6_flow.tc =
722                                 (uint8_t)(ipv6_spec->hdr.vtc_flow <<
723                                           I40E_IPV4_TC_SHIFT);
724                         filter->input.flow.ipv6_flow.proto =
725                                 ipv6_spec->hdr.proto;
726                         filter->input.flow.ipv6_flow.hop_limits =
727                                 ipv6_spec->hdr.hop_limits;
728
729                         rte_memcpy(filter->input.flow.ipv6_flow.src_ip,
730                                    ipv6_spec->hdr.src_addr, 16);
731                         rte_memcpy(filter->input.flow.ipv6_flow.dst_ip,
732                                    ipv6_spec->hdr.dst_addr, 16);
733
734                         /* Check if it is fragment. */
735                         if (ipv6_spec->hdr.proto == I40E_IPV6_FRAG_HEADER)
736                                 flow_type = RTE_ETH_FLOW_FRAG_IPV6;
737                         else
738                                 flow_type = RTE_ETH_FLOW_NONFRAG_IPV6_OTHER;
739                         break;
740                 case RTE_FLOW_ITEM_TYPE_TCP:
741                         tcp_spec = (const struct rte_flow_item_tcp *)item->spec;
742                         tcp_mask = (const struct rte_flow_item_tcp *)item->mask;
743                         if (!tcp_spec || !tcp_mask) {
744                                 rte_flow_error_set(error, EINVAL,
745                                                    RTE_FLOW_ERROR_TYPE_ITEM,
746                                                    item,
747                                                    "NULL TCP spec/mask");
748                                 return -rte_errno;
749                         }
750
751                         /* Check TCP mask and update input set */
752                         if (tcp_mask->hdr.sent_seq ||
753                             tcp_mask->hdr.recv_ack ||
754                             tcp_mask->hdr.data_off ||
755                             tcp_mask->hdr.tcp_flags ||
756                             tcp_mask->hdr.rx_win ||
757                             tcp_mask->hdr.cksum ||
758                             tcp_mask->hdr.tcp_urp) {
759                                 rte_flow_error_set(error, EINVAL,
760                                                    RTE_FLOW_ERROR_TYPE_ITEM,
761                                                    item,
762                                                    "Invalid TCP mask");
763                                 return -rte_errno;
764                         }
765
766                         if (tcp_mask->hdr.src_port != UINT16_MAX ||
767                             tcp_mask->hdr.dst_port != UINT16_MAX) {
768                                 rte_flow_error_set(error, EINVAL,
769                                                    RTE_FLOW_ERROR_TYPE_ITEM,
770                                                    item,
771                                                    "Invalid TCP mask");
772                                 return -rte_errno;
773                         }
774
775                         input_set |= I40E_INSET_SRC_PORT;
776                         input_set |= I40E_INSET_DST_PORT;
777
778                         /* Get filter info */
779                         if (l3 == RTE_FLOW_ITEM_TYPE_IPV4)
780                                 flow_type = RTE_ETH_FLOW_NONFRAG_IPV4_TCP;
781                         else if (l3 == RTE_FLOW_ITEM_TYPE_IPV6)
782                                 flow_type = RTE_ETH_FLOW_NONFRAG_IPV6_TCP;
783
784                         if (l3 == RTE_FLOW_ITEM_TYPE_IPV4) {
785                                 filter->input.flow.tcp4_flow.src_port =
786                                         tcp_spec->hdr.src_port;
787                                 filter->input.flow.tcp4_flow.dst_port =
788                                         tcp_spec->hdr.dst_port;
789                         } else if (l3 == RTE_FLOW_ITEM_TYPE_IPV6) {
790                                 filter->input.flow.tcp6_flow.src_port =
791                                         tcp_spec->hdr.src_port;
792                                 filter->input.flow.tcp6_flow.dst_port =
793                                         tcp_spec->hdr.dst_port;
794                         }
795                         break;
796                 case RTE_FLOW_ITEM_TYPE_UDP:
797                         udp_spec = (const struct rte_flow_item_udp *)item->spec;
798                         udp_mask = (const struct rte_flow_item_udp *)item->mask;
799                         if (!udp_spec || !udp_mask) {
800                                 rte_flow_error_set(error, EINVAL,
801                                                    RTE_FLOW_ERROR_TYPE_ITEM,
802                                                    item,
803                                                    "NULL UDP spec/mask");
804                                 return -rte_errno;
805                         }
806
807                         /* Check UDP mask and update input set*/
808                         if (udp_mask->hdr.dgram_len ||
809                             udp_mask->hdr.dgram_cksum) {
810                                 rte_flow_error_set(error, EINVAL,
811                                                    RTE_FLOW_ERROR_TYPE_ITEM,
812                                                    item,
813                                                    "Invalid UDP mask");
814                                 return -rte_errno;
815                         }
816
817                         if (udp_mask->hdr.src_port != UINT16_MAX ||
818                             udp_mask->hdr.dst_port != UINT16_MAX) {
819                                 rte_flow_error_set(error, EINVAL,
820                                                    RTE_FLOW_ERROR_TYPE_ITEM,
821                                                    item,
822                                                    "Invalid UDP mask");
823                                 return -rte_errno;
824                         }
825
826                         input_set |= I40E_INSET_SRC_PORT;
827                         input_set |= I40E_INSET_DST_PORT;
828
829                         /* Get filter info */
830                         if (l3 == RTE_FLOW_ITEM_TYPE_IPV4)
831                                 flow_type =
832                                         RTE_ETH_FLOW_NONFRAG_IPV4_UDP;
833                         else if (l3 == RTE_FLOW_ITEM_TYPE_IPV6)
834                                 flow_type =
835                                         RTE_ETH_FLOW_NONFRAG_IPV6_UDP;
836
837                         if (l3 == RTE_FLOW_ITEM_TYPE_IPV4) {
838                                 filter->input.flow.udp4_flow.src_port =
839                                         udp_spec->hdr.src_port;
840                                 filter->input.flow.udp4_flow.dst_port =
841                                         udp_spec->hdr.dst_port;
842                         } else if (l3 == RTE_FLOW_ITEM_TYPE_IPV6) {
843                                 filter->input.flow.udp6_flow.src_port =
844                                         udp_spec->hdr.src_port;
845                                 filter->input.flow.udp6_flow.dst_port =
846                                         udp_spec->hdr.dst_port;
847                         }
848                         break;
849                 case RTE_FLOW_ITEM_TYPE_SCTP:
850                         sctp_spec =
851                                 (const struct rte_flow_item_sctp *)item->spec;
852                         sctp_mask =
853                                 (const struct rte_flow_item_sctp *)item->mask;
854                         if (!sctp_spec || !sctp_mask) {
855                                 rte_flow_error_set(error, EINVAL,
856                                                    RTE_FLOW_ERROR_TYPE_ITEM,
857                                                    item,
858                                                    "NULL SCTP spec/mask");
859                                 return -rte_errno;
860                         }
861
862                         /* Check SCTP mask and update input set */
863                         if (sctp_mask->hdr.cksum) {
864                                 rte_flow_error_set(error, EINVAL,
865                                                    RTE_FLOW_ERROR_TYPE_ITEM,
866                                                    item,
867                                                    "Invalid UDP mask");
868                                 return -rte_errno;
869                         }
870
871                         if (sctp_mask->hdr.src_port != UINT16_MAX ||
872                             sctp_mask->hdr.dst_port != UINT16_MAX ||
873                             sctp_mask->hdr.tag != UINT32_MAX) {
874                                 rte_flow_error_set(error, EINVAL,
875                                                    RTE_FLOW_ERROR_TYPE_ITEM,
876                                                    item,
877                                                    "Invalid UDP mask");
878                                 return -rte_errno;
879                         }
880                         input_set |= I40E_INSET_SRC_PORT;
881                         input_set |= I40E_INSET_DST_PORT;
882                         input_set |= I40E_INSET_SCTP_VT;
883
884                         /* Get filter info */
885                         if (l3 == RTE_FLOW_ITEM_TYPE_IPV4)
886                                 flow_type = RTE_ETH_FLOW_NONFRAG_IPV4_SCTP;
887                         else if (l3 == RTE_FLOW_ITEM_TYPE_IPV6)
888                                 flow_type = RTE_ETH_FLOW_NONFRAG_IPV6_SCTP;
889
890                         if (l3 == RTE_FLOW_ITEM_TYPE_IPV4) {
891                                 filter->input.flow.sctp4_flow.src_port =
892                                         sctp_spec->hdr.src_port;
893                                 filter->input.flow.sctp4_flow.dst_port =
894                                         sctp_spec->hdr.dst_port;
895                                 filter->input.flow.sctp4_flow.verify_tag =
896                                         sctp_spec->hdr.tag;
897                         } else if (l3 == RTE_FLOW_ITEM_TYPE_IPV6) {
898                                 filter->input.flow.sctp6_flow.src_port =
899                                         sctp_spec->hdr.src_port;
900                                 filter->input.flow.sctp6_flow.dst_port =
901                                         sctp_spec->hdr.dst_port;
902                                 filter->input.flow.sctp6_flow.verify_tag =
903                                         sctp_spec->hdr.tag;
904                         }
905                         break;
906                 case RTE_FLOW_ITEM_TYPE_VF:
907                         vf_spec = (const struct rte_flow_item_vf *)item->spec;
908                         filter->input.flow_ext.is_vf = 1;
909                         filter->input.flow_ext.dst_id = vf_spec->id;
910                         if (filter->input.flow_ext.is_vf &&
911                             filter->input.flow_ext.dst_id >= pf->vf_num) {
912                                 rte_flow_error_set(error, EINVAL,
913                                                    RTE_FLOW_ERROR_TYPE_ITEM,
914                                                    item,
915                                                    "Invalid VF ID for FDIR.");
916                                 return -rte_errno;
917                         }
918                         break;
919                 default:
920                         break;
921                 }
922         }
923
924         pctype = i40e_flowtype_to_pctype(flow_type);
925         if (pctype == 0 || pctype > I40E_FILTER_PCTYPE_L2_PAYLOAD) {
926                 rte_flow_error_set(error, EINVAL,
927                                    RTE_FLOW_ERROR_TYPE_ITEM, item,
928                                    "Unsupported flow type");
929                 return -rte_errno;
930         }
931
932         if (input_set != i40e_get_default_input_set(pctype)) {
933                 rte_flow_error_set(error, EINVAL,
934                                    RTE_FLOW_ERROR_TYPE_ITEM, item,
935                                    "Invalid input set.");
936                 return -rte_errno;
937         }
938         filter->input.flow_type = flow_type;
939
940         return 0;
941 }
942
943 /* Parse to get the action info of a FDIR filter.
944  * FDIR action supports QUEUE or (QUEUE + MARK).
945  */
946 static int
947 i40e_flow_parse_fdir_action(struct rte_eth_dev *dev,
948                             const struct rte_flow_action *actions,
949                             struct rte_flow_error *error,
950                             struct rte_eth_fdir_filter *filter)
951 {
952         struct i40e_pf *pf = I40E_DEV_PRIVATE_TO_PF(dev->data->dev_private);
953         const struct rte_flow_action *act;
954         const struct rte_flow_action_queue *act_q;
955         const struct rte_flow_action_mark *mark_spec;
956         uint32_t index = 0;
957
958         /* Check if the first non-void action is QUEUE or DROP. */
959         NEXT_ITEM_OF_ACTION(act, actions, index);
960         if (act->type != RTE_FLOW_ACTION_TYPE_QUEUE &&
961             act->type != RTE_FLOW_ACTION_TYPE_DROP) {
962                 rte_flow_error_set(error, EINVAL, RTE_FLOW_ERROR_TYPE_ACTION,
963                                    act, "Invalid action.");
964                 return -rte_errno;
965         }
966
967         act_q = (const struct rte_flow_action_queue *)act->conf;
968         filter->action.flex_off = 0;
969         if (act->type == RTE_FLOW_ACTION_TYPE_QUEUE)
970                 filter->action.behavior = RTE_ETH_FDIR_ACCEPT;
971         else
972                 filter->action.behavior = RTE_ETH_FDIR_REJECT;
973
974         filter->action.report_status = RTE_ETH_FDIR_REPORT_ID;
975         filter->action.rx_queue = act_q->index;
976
977         if (filter->action.rx_queue >= pf->dev_data->nb_rx_queues) {
978                 rte_flow_error_set(error, EINVAL,
979                                    RTE_FLOW_ERROR_TYPE_ACTION, act,
980                                    "Invalid queue ID for FDIR.");
981                 return -rte_errno;
982         }
983
984         /* Check if the next non-void item is MARK or END. */
985         index++;
986         NEXT_ITEM_OF_ACTION(act, actions, index);
987         if (act->type != RTE_FLOW_ACTION_TYPE_MARK &&
988             act->type != RTE_FLOW_ACTION_TYPE_END) {
989                 rte_flow_error_set(error, EINVAL, RTE_FLOW_ERROR_TYPE_ACTION,
990                                    act, "Invalid action.");
991                 return -rte_errno;
992         }
993
994         if (act->type == RTE_FLOW_ACTION_TYPE_MARK) {
995                 mark_spec = (const struct rte_flow_action_mark *)act->conf;
996                 filter->soft_id = mark_spec->id;
997
998                 /* Check if the next non-void item is END */
999                 index++;
1000                 NEXT_ITEM_OF_ACTION(act, actions, index);
1001                 if (act->type != RTE_FLOW_ACTION_TYPE_END) {
1002                         rte_flow_error_set(error, EINVAL,
1003                                            RTE_FLOW_ERROR_TYPE_ACTION,
1004                                            act, "Invalid action.");
1005                         return -rte_errno;
1006                 }
1007         }
1008
1009         return 0;
1010 }
1011
1012 static int
1013 i40e_flow_parse_fdir_filter(struct rte_eth_dev *dev,
1014                             const struct rte_flow_attr *attr,
1015                             const struct rte_flow_item pattern[],
1016                             const struct rte_flow_action actions[],
1017                             struct rte_flow_error *error,
1018                             union i40e_filter_t *filter)
1019 {
1020         struct rte_eth_fdir_filter *fdir_filter =
1021                 &filter->fdir_filter;
1022         int ret;
1023
1024         ret = i40e_flow_parse_fdir_pattern(dev, pattern, error, fdir_filter);
1025         if (ret)
1026                 return ret;
1027
1028         ret = i40e_flow_parse_fdir_action(dev, actions, error, fdir_filter);
1029         if (ret)
1030                 return ret;
1031
1032         ret = i40e_flow_parse_attr(attr, error);
1033         if (ret)
1034                 return ret;
1035
1036         if (dev->data->dev_conf.fdir_conf.mode !=
1037             RTE_FDIR_MODE_PERFECT) {
1038                 rte_flow_error_set(error, ENOTSUP,
1039                                    RTE_FLOW_ERROR_TYPE_UNSPECIFIED,
1040                                    NULL,
1041                                    "Check the mode in fdir_conf.");
1042                 return -rte_errno;
1043         }
1044
1045         return 0;
1046 }
1047
1048 static int
1049 i40e_flow_validate(struct rte_eth_dev *dev,
1050                    const struct rte_flow_attr *attr,
1051                    const struct rte_flow_item pattern[],
1052                    const struct rte_flow_action actions[],
1053                    struct rte_flow_error *error)
1054 {
1055         struct rte_flow_item *items; /* internal pattern w/o VOID items */
1056         parse_filter_t parse_filter;
1057         uint32_t item_num = 0; /* non-void item number of pattern*/
1058         uint32_t i = 0;
1059         int ret;
1060
1061         if (!pattern) {
1062                 rte_flow_error_set(error, EINVAL, RTE_FLOW_ERROR_TYPE_ITEM_NUM,
1063                                    NULL, "NULL pattern.");
1064                 return -rte_errno;
1065         }
1066
1067         if (!actions) {
1068                 rte_flow_error_set(error, EINVAL,
1069                                    RTE_FLOW_ERROR_TYPE_ACTION_NUM,
1070                                    NULL, "NULL action.");
1071                 return -rte_errno;
1072         }
1073
1074         if (!attr) {
1075                 rte_flow_error_set(error, EINVAL,
1076                                    RTE_FLOW_ERROR_TYPE_ATTR,
1077                                    NULL, "NULL attribute.");
1078                 return -rte_errno;
1079         }
1080
1081         memset(&cons_filter, 0, sizeof(cons_filter));
1082
1083         /* Get the non-void item number of pattern */
1084         while ((pattern + i)->type != RTE_FLOW_ITEM_TYPE_END) {
1085                 if ((pattern + i)->type != RTE_FLOW_ITEM_TYPE_VOID)
1086                         item_num++;
1087                 i++;
1088         }
1089         item_num++;
1090
1091         items = rte_zmalloc("i40e_pattern",
1092                             item_num * sizeof(struct rte_flow_item), 0);
1093         if (!items) {
1094                 rte_flow_error_set(error, ENOMEM, RTE_FLOW_ERROR_TYPE_ITEM_NUM,
1095                                    NULL, "No memory for PMD internal items.");
1096                 return -ENOMEM;
1097         }
1098
1099         i40e_pattern_skip_void_item(items, pattern);
1100
1101         /* Find if there's matched parse filter function */
1102         parse_filter = i40e_find_parse_filter_func(items);
1103         if (!parse_filter) {
1104                 rte_flow_error_set(error, EINVAL,
1105                                    RTE_FLOW_ERROR_TYPE_ITEM,
1106                                    pattern, "Unsupported pattern");
1107                 return -rte_errno;
1108         }
1109
1110         ret = parse_filter(dev, attr, items, actions, error, &cons_filter);
1111
1112         rte_free(items);
1113
1114         return ret;
1115 }