LCOV - code coverage report
Current view: top level - drivers/net/i40e - i40e_flow.c (source / functions) Hit Total Coverage
Test: Code coverage Lines: 0 1298 0.0 %
Date: 2024-01-22 16:13:49 Functions: 0 35 0.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 0 989 0.0 %

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

Generated by: LCOV version 1.14