LCOV - code coverage report
Current view: top level - drivers/net/txgbe - txgbe_flow.c (source / functions) Hit Total Coverage
Test: Code coverage Lines: 0 1086 0.0 %
Date: 2024-12-01 18:57:19 Functions: 0 18 0.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 0 953 0.0 %

           Branch data     Line data    Source code
       1                 :            : /* SPDX-License-Identifier: BSD-3-Clause
       2                 :            :  * Copyright(c) 2015-2020 Beijing WangXun Technology Co., Ltd.
       3                 :            :  * Copyright(c) 2010-2017 Intel Corporation
       4                 :            :  */
       5                 :            : 
       6                 :            : #include <sys/queue.h>
       7                 :            : #include <bus_pci_driver.h>
       8                 :            : #include <rte_malloc.h>
       9                 :            : #include <rte_flow.h>
      10                 :            : #include <rte_flow_driver.h>
      11                 :            : 
      12                 :            : #include "txgbe_ethdev.h"
      13                 :            : 
      14                 :            : #define TXGBE_MIN_N_TUPLE_PRIO 1
      15                 :            : #define TXGBE_MAX_N_TUPLE_PRIO 7
      16                 :            : #define TXGBE_MAX_FLX_SOURCE_OFF 62
      17                 :            : 
      18                 :            : /* ntuple filter list structure */
      19                 :            : struct txgbe_ntuple_filter_ele {
      20                 :            :         TAILQ_ENTRY(txgbe_ntuple_filter_ele) entries;
      21                 :            :         struct rte_eth_ntuple_filter filter_info;
      22                 :            : };
      23                 :            : /* ethertype filter list structure */
      24                 :            : struct txgbe_ethertype_filter_ele {
      25                 :            :         TAILQ_ENTRY(txgbe_ethertype_filter_ele) entries;
      26                 :            :         struct rte_eth_ethertype_filter filter_info;
      27                 :            : };
      28                 :            : /* syn filter list structure */
      29                 :            : struct txgbe_eth_syn_filter_ele {
      30                 :            :         TAILQ_ENTRY(txgbe_eth_syn_filter_ele) entries;
      31                 :            :         struct rte_eth_syn_filter filter_info;
      32                 :            : };
      33                 :            : /* fdir filter list structure */
      34                 :            : struct txgbe_fdir_rule_ele {
      35                 :            :         TAILQ_ENTRY(txgbe_fdir_rule_ele) entries;
      36                 :            :         struct txgbe_fdir_rule filter_info;
      37                 :            : };
      38                 :            : /* l2_tunnel filter list structure */
      39                 :            : struct txgbe_eth_l2_tunnel_conf_ele {
      40                 :            :         TAILQ_ENTRY(txgbe_eth_l2_tunnel_conf_ele) entries;
      41                 :            :         struct txgbe_l2_tunnel_conf filter_info;
      42                 :            : };
      43                 :            : /* rss filter list structure */
      44                 :            : struct txgbe_rss_conf_ele {
      45                 :            :         TAILQ_ENTRY(txgbe_rss_conf_ele) entries;
      46                 :            :         struct txgbe_rte_flow_rss_conf filter_info;
      47                 :            : };
      48                 :            : /* txgbe_flow memory list structure */
      49                 :            : struct txgbe_flow_mem {
      50                 :            :         TAILQ_ENTRY(txgbe_flow_mem) entries;
      51                 :            :         struct rte_flow *flow;
      52                 :            : };
      53                 :            : 
      54                 :            : TAILQ_HEAD(txgbe_ntuple_filter_list, txgbe_ntuple_filter_ele);
      55                 :            : TAILQ_HEAD(txgbe_ethertype_filter_list, txgbe_ethertype_filter_ele);
      56                 :            : TAILQ_HEAD(txgbe_syn_filter_list, txgbe_eth_syn_filter_ele);
      57                 :            : TAILQ_HEAD(txgbe_fdir_rule_filter_list, txgbe_fdir_rule_ele);
      58                 :            : TAILQ_HEAD(txgbe_l2_tunnel_filter_list, txgbe_eth_l2_tunnel_conf_ele);
      59                 :            : TAILQ_HEAD(txgbe_rss_filter_list, txgbe_rss_conf_ele);
      60                 :            : TAILQ_HEAD(txgbe_flow_mem_list, txgbe_flow_mem);
      61                 :            : 
      62                 :            : static struct txgbe_ntuple_filter_list filter_ntuple_list;
      63                 :            : static struct txgbe_ethertype_filter_list filter_ethertype_list;
      64                 :            : static struct txgbe_syn_filter_list filter_syn_list;
      65                 :            : static struct txgbe_fdir_rule_filter_list filter_fdir_list;
      66                 :            : static struct txgbe_l2_tunnel_filter_list filter_l2_tunnel_list;
      67                 :            : static struct txgbe_rss_filter_list filter_rss_list;
      68                 :            : static struct txgbe_flow_mem_list txgbe_flow_list;
      69                 :            : 
      70                 :            : /**
      71                 :            :  * Endless loop will never happen with below assumption
      72                 :            :  * 1. there is at least one no-void item(END)
      73                 :            :  * 2. cur is before END.
      74                 :            :  */
      75                 :            : static inline
      76                 :            : const struct rte_flow_item *next_no_void_pattern(
      77                 :            :                 const struct rte_flow_item pattern[],
      78                 :            :                 const struct rte_flow_item *cur)
      79                 :            : {
      80                 :            :         const struct rte_flow_item *next =
      81                 :          0 :                 cur ? cur + 1 : &pattern[0];
      82                 :            :         while (1) {
      83   [ #  #  #  #  :          0 :                 if (next->type != RTE_FLOW_ITEM_TYPE_VOID)
          #  #  #  #  #  
          #  #  #  #  #  
          #  #  #  #  #  
          #  #  #  #  #  
          #  #  #  #  #  
          #  #  #  #  #  
          #  #  #  #  #  
          #  #  #  #  #  
          #  #  #  #  #  
          #  #  #  #  #  
          #  #  #  #  #  
          #  #  #  #  #  
          #  #  #  #  #  
             #  #  #  #  
                      # ]
      84                 :            :                         return next;
      85                 :          0 :                 next++;
      86                 :            :         }
      87                 :            : }
      88                 :            : 
      89                 :            : static inline
      90                 :            : const struct rte_flow_action *next_no_void_action(
      91                 :            :                 const struct rte_flow_action actions[],
      92                 :            :                 const struct rte_flow_action *cur)
      93                 :            : {
      94                 :            :         const struct rte_flow_action *next =
      95                 :          0 :                 cur ? cur + 1 : &actions[0];
      96                 :            :         while (1) {
      97   [ #  #  #  #  :          0 :                 if (next->type != RTE_FLOW_ACTION_TYPE_VOID)
          #  #  #  #  #  
          #  #  #  #  #  
          #  #  #  #  #  
          #  #  #  #  #  
          #  #  #  #  #  
                      # ]
      98                 :            :                         return next;
      99                 :          0 :                 next++;
     100                 :            :         }
     101                 :            : }
     102                 :            : 
     103                 :            : /**
     104                 :            :  * Please aware there's an assumption for all the parsers.
     105                 :            :  * rte_flow_item is using big endian, rte_flow_attr and
     106                 :            :  * rte_flow_action are using CPU order.
     107                 :            :  * Because the pattern is used to describe the packets,
     108                 :            :  * normally the packets should use network order.
     109                 :            :  */
     110                 :            : 
     111                 :            : /**
     112                 :            :  * Parse the rule to see if it is a n-tuple rule.
     113                 :            :  * And get the n-tuple filter info BTW.
     114                 :            :  * pattern:
     115                 :            :  * The first not void item can be ETH or IPV4.
     116                 :            :  * The second not void item must be IPV4 if the first one is ETH.
     117                 :            :  * The third not void item must be UDP or TCP.
     118                 :            :  * The next not void item must be END.
     119                 :            :  * action:
     120                 :            :  * The first not void action should be QUEUE.
     121                 :            :  * The next not void action should be END.
     122                 :            :  * pattern example:
     123                 :            :  * ITEM         Spec                    Mask
     124                 :            :  * ETH          NULL                    NULL
     125                 :            :  * IPV4         src_addr 192.168.1.20   0xFFFFFFFF
     126                 :            :  *              dst_addr 192.167.3.50   0xFFFFFFFF
     127                 :            :  *              next_proto_id   17      0xFF
     128                 :            :  * UDP/TCP/     src_port        80      0xFFFF
     129                 :            :  * SCTP         dst_port        80      0xFFFF
     130                 :            :  * END
     131                 :            :  * other members in mask and spec should set to 0x00.
     132                 :            :  * item->last should be NULL.
     133                 :            :  *
     134                 :            :  * Special case for flow action type RTE_FLOW_ACTION_TYPE_SECURITY.
     135                 :            :  *
     136                 :            :  */
     137                 :            : static int
     138                 :          0 : cons_parse_ntuple_filter(const struct rte_flow_attr *attr,
     139                 :            :                          const struct rte_flow_item pattern[],
     140                 :            :                          const struct rte_flow_action actions[],
     141                 :            :                          struct rte_eth_ntuple_filter *filter,
     142                 :            :                          struct rte_flow_error *error)
     143                 :            : {
     144                 :            :         const struct rte_flow_item *item;
     145                 :            :         const struct rte_flow_action *act;
     146                 :            :         const struct rte_flow_item_ipv4 *ipv4_spec;
     147                 :            :         const struct rte_flow_item_ipv4 *ipv4_mask;
     148                 :            :         const struct rte_flow_item_tcp *tcp_spec;
     149                 :            :         const struct rte_flow_item_tcp *tcp_mask;
     150                 :            :         const struct rte_flow_item_udp *udp_spec;
     151                 :            :         const struct rte_flow_item_udp *udp_mask;
     152                 :            :         const struct rte_flow_item_sctp *sctp_spec;
     153                 :            :         const struct rte_flow_item_sctp *sctp_mask;
     154                 :            :         const struct rte_flow_item_eth *eth_spec;
     155                 :            :         const struct rte_flow_item_eth *eth_mask;
     156                 :            :         const struct rte_flow_item_vlan *vlan_spec;
     157                 :            :         const struct rte_flow_item_vlan *vlan_mask;
     158                 :            :         struct rte_flow_item_eth eth_null;
     159                 :            :         struct rte_flow_item_vlan vlan_null;
     160                 :            : 
     161         [ #  # ]:          0 :         if (!pattern) {
     162                 :          0 :                 rte_flow_error_set(error,
     163                 :            :                         EINVAL, RTE_FLOW_ERROR_TYPE_ITEM_NUM,
     164                 :            :                         NULL, "NULL pattern.");
     165                 :          0 :                 return -rte_errno;
     166                 :            :         }
     167                 :            : 
     168         [ #  # ]:          0 :         if (!actions) {
     169                 :          0 :                 rte_flow_error_set(error, EINVAL,
     170                 :            :                                    RTE_FLOW_ERROR_TYPE_ACTION_NUM,
     171                 :            :                                    NULL, "NULL action.");
     172                 :          0 :                 return -rte_errno;
     173                 :            :         }
     174         [ #  # ]:          0 :         if (!attr) {
     175                 :          0 :                 rte_flow_error_set(error, EINVAL,
     176                 :            :                                    RTE_FLOW_ERROR_TYPE_ATTR,
     177                 :            :                                    NULL, "NULL attribute.");
     178                 :          0 :                 return -rte_errno;
     179                 :            :         }
     180                 :            : 
     181                 :            :         memset(&eth_null, 0, sizeof(struct rte_flow_item_eth));
     182                 :            :         memset(&vlan_null, 0, sizeof(struct rte_flow_item_vlan));
     183                 :            : 
     184                 :            : #ifdef RTE_LIB_SECURITY
     185                 :            :         /**
     186                 :            :          *  Special case for flow action type RTE_FLOW_ACTION_TYPE_SECURITY
     187                 :            :          */
     188                 :            :         act = next_no_void_action(actions, NULL);
     189         [ #  # ]:          0 :         if (act->type == RTE_FLOW_ACTION_TYPE_SECURITY) {
     190                 :          0 :                 const void *conf = act->conf;
     191                 :            :                 /* check if the next not void item is END */
     192                 :            :                 act = next_no_void_action(actions, act);
     193         [ #  # ]:          0 :                 if (act->type != RTE_FLOW_ACTION_TYPE_END) {
     194                 :            :                         memset(filter, 0, sizeof(struct rte_eth_ntuple_filter));
     195                 :          0 :                         rte_flow_error_set(error, EINVAL,
     196                 :            :                                 RTE_FLOW_ERROR_TYPE_ACTION,
     197                 :            :                                 act, "Not supported action.");
     198                 :          0 :                         return -rte_errno;
     199                 :            :                 }
     200                 :            : 
     201                 :            :                 /* get the IP pattern*/
     202                 :            :                 item = next_no_void_pattern(pattern, NULL);
     203         [ #  # ]:          0 :                 while (item->type != RTE_FLOW_ITEM_TYPE_IPV4 &&
     204                 :            :                                 item->type != RTE_FLOW_ITEM_TYPE_IPV6) {
     205   [ #  #  #  # ]:          0 :                         if (item->last ||
     206                 :            :                                         item->type == RTE_FLOW_ITEM_TYPE_END) {
     207                 :          0 :                                 rte_flow_error_set(error, EINVAL,
     208                 :            :                                         RTE_FLOW_ERROR_TYPE_ITEM,
     209                 :            :                                         item, "IP pattern missing.");
     210                 :          0 :                                 return -rte_errno;
     211                 :            :                         }
     212                 :            :                         item = next_no_void_pattern(pattern, item);
     213                 :            :                 }
     214                 :            : 
     215                 :          0 :                 filter->proto = IPPROTO_ESP;
     216                 :          0 :                 return txgbe_crypto_add_ingress_sa_from_flow(conf, item->spec,
     217                 :            :                                         item->type == RTE_FLOW_ITEM_TYPE_IPV6);
     218                 :            :         }
     219                 :            : #endif
     220                 :            : 
     221                 :            :         /* the first not void item can be MAC or IPv4 */
     222                 :            :         item = next_no_void_pattern(pattern, NULL);
     223                 :            : 
     224         [ #  # ]:          0 :         if (item->type != RTE_FLOW_ITEM_TYPE_ETH &&
     225                 :            :             item->type != RTE_FLOW_ITEM_TYPE_IPV4) {
     226                 :          0 :                 rte_flow_error_set(error, EINVAL,
     227                 :            :                         RTE_FLOW_ERROR_TYPE_ITEM,
     228                 :            :                         item, "Not supported by ntuple filter");
     229                 :          0 :                 return -rte_errno;
     230                 :            :         }
     231                 :            :         /* Skip Ethernet */
     232         [ #  # ]:          0 :         if (item->type == RTE_FLOW_ITEM_TYPE_ETH) {
     233                 :          0 :                 eth_spec = item->spec;
     234                 :          0 :                 eth_mask = item->mask;
     235                 :            :                 /*Not supported last point for range*/
     236         [ #  # ]:          0 :                 if (item->last) {
     237                 :          0 :                         rte_flow_error_set(error,
     238                 :            :                           EINVAL,
     239                 :            :                           RTE_FLOW_ERROR_TYPE_UNSPECIFIED,
     240                 :            :                           item, "Not supported last point for range");
     241                 :          0 :                         return -rte_errno;
     242                 :            :                 }
     243                 :            :                 /* if the first item is MAC, the content should be NULL */
     244   [ #  #  #  # ]:          0 :                 if ((item->spec && memcmp(eth_spec, &eth_null,
     245         [ #  # ]:          0 :                                           sizeof(struct rte_flow_item_eth))) ||
     246         [ #  # ]:          0 :                     (item->mask && memcmp(eth_mask, &eth_null,
     247                 :            :                                           sizeof(struct rte_flow_item_eth)))) {
     248                 :          0 :                         rte_flow_error_set(error, EINVAL,
     249                 :            :                                 RTE_FLOW_ERROR_TYPE_ITEM,
     250                 :            :                                 item, "Not supported by ntuple filter");
     251                 :          0 :                         return -rte_errno;
     252                 :            :                 }
     253                 :            :                 /* check if the next not void item is IPv4 or Vlan */
     254                 :            :                 item = next_no_void_pattern(pattern, item);
     255         [ #  # ]:          0 :                 if (item->type != RTE_FLOW_ITEM_TYPE_IPV4 &&
     256                 :            :                         item->type != RTE_FLOW_ITEM_TYPE_VLAN) {
     257                 :          0 :                         rte_flow_error_set(error,
     258                 :            :                                 EINVAL, RTE_FLOW_ERROR_TYPE_ITEM,
     259                 :            :                                 item, "Not supported by ntuple filter");
     260                 :          0 :                         return -rte_errno;
     261                 :            :                 }
     262                 :            :         }
     263                 :            : 
     264         [ #  # ]:          0 :         if (item->type == RTE_FLOW_ITEM_TYPE_VLAN) {
     265                 :          0 :                 vlan_spec = item->spec;
     266                 :          0 :                 vlan_mask = item->mask;
     267                 :            :                 /*Not supported last point for range*/
     268         [ #  # ]:          0 :                 if (item->last) {
     269                 :          0 :                         rte_flow_error_set(error,
     270                 :            :                                 EINVAL, RTE_FLOW_ERROR_TYPE_UNSPECIFIED,
     271                 :            :                                 item, "Not supported last point for range");
     272                 :          0 :                         return -rte_errno;
     273                 :            :                 }
     274                 :            :                 /* the content should be NULL */
     275   [ #  #  #  # ]:          0 :                 if ((item->spec && memcmp(vlan_spec, &vlan_null,
     276         [ #  # ]:          0 :                                           sizeof(struct rte_flow_item_vlan))) ||
     277         [ #  # ]:          0 :                     (item->mask && memcmp(vlan_mask, &vlan_null,
     278                 :            :                                           sizeof(struct rte_flow_item_vlan)))) {
     279                 :          0 :                         rte_flow_error_set(error, EINVAL,
     280                 :            :                                 RTE_FLOW_ERROR_TYPE_ITEM,
     281                 :            :                                 item, "Not supported by ntuple filter");
     282                 :          0 :                         return -rte_errno;
     283                 :            :                 }
     284                 :            :                 /* check if the next not void item is IPv4 */
     285                 :            :                 item = next_no_void_pattern(pattern, item);
     286         [ #  # ]:          0 :                 if (item->type != RTE_FLOW_ITEM_TYPE_IPV4) {
     287                 :          0 :                         rte_flow_error_set(error,
     288                 :            :                           EINVAL, RTE_FLOW_ERROR_TYPE_ITEM,
     289                 :            :                           item, "Not supported by ntuple filter");
     290                 :          0 :                         return -rte_errno;
     291                 :            :                 }
     292                 :            :         }
     293                 :            : 
     294         [ #  # ]:          0 :         if (item->mask) {
     295                 :            :                 /* get the IPv4 info */
     296         [ #  # ]:          0 :                 if (!item->spec || !item->mask) {
     297                 :          0 :                         rte_flow_error_set(error, EINVAL,
     298                 :            :                                 RTE_FLOW_ERROR_TYPE_ITEM,
     299                 :            :                                 item, "Invalid ntuple mask");
     300                 :          0 :                         return -rte_errno;
     301                 :            :                 }
     302                 :            :                 /*Not supported last point for range*/
     303         [ #  # ]:          0 :                 if (item->last) {
     304                 :          0 :                         rte_flow_error_set(error, EINVAL,
     305                 :            :                                 RTE_FLOW_ERROR_TYPE_UNSPECIFIED,
     306                 :            :                                 item, "Not supported last point for range");
     307                 :          0 :                         return -rte_errno;
     308                 :            :                 }
     309                 :            : 
     310                 :            :                 ipv4_mask = item->mask;
     311                 :            :                 /**
     312                 :            :                  * Only support src & dst addresses, protocol,
     313                 :            :                  * others should be masked.
     314                 :            :                  */
     315         [ #  # ]:          0 :                 if (ipv4_mask->hdr.version_ihl ||
     316                 :          0 :                     ipv4_mask->hdr.type_of_service ||
     317         [ #  # ]:          0 :                     ipv4_mask->hdr.total_length ||
     318         [ #  # ]:          0 :                     ipv4_mask->hdr.packet_id ||
     319         [ #  # ]:          0 :                     ipv4_mask->hdr.fragment_offset ||
     320         [ #  # ]:          0 :                     ipv4_mask->hdr.time_to_live ||
     321         [ #  # ]:          0 :                     ipv4_mask->hdr.hdr_checksum) {
     322                 :          0 :                         rte_flow_error_set(error,
     323                 :            :                                 EINVAL, RTE_FLOW_ERROR_TYPE_ITEM,
     324                 :            :                                 item, "Not supported by ntuple filter");
     325                 :          0 :                         return -rte_errno;
     326                 :            :                 }
     327         [ #  # ]:          0 :                 if ((ipv4_mask->hdr.src_addr != 0 &&
     328                 :          0 :                         ipv4_mask->hdr.src_addr != UINT32_MAX) ||
     329         [ #  # ]:          0 :                         (ipv4_mask->hdr.dst_addr != 0 &&
     330                 :          0 :                         ipv4_mask->hdr.dst_addr != UINT32_MAX) ||
     331         [ #  # ]:          0 :                         (ipv4_mask->hdr.next_proto_id != UINT8_MAX &&
     332                 :            :                         ipv4_mask->hdr.next_proto_id != 0)) {
     333                 :          0 :                         rte_flow_error_set(error,
     334                 :            :                                 EINVAL, RTE_FLOW_ERROR_TYPE_ITEM,
     335                 :            :                                 item, "Not supported by ntuple filter");
     336                 :          0 :                         return -rte_errno;
     337                 :            :                 }
     338                 :            : 
     339                 :          0 :                 filter->dst_ip_mask = ipv4_mask->hdr.dst_addr;
     340                 :          0 :                 filter->src_ip_mask = ipv4_mask->hdr.src_addr;
     341                 :          0 :                 filter->proto_mask  = ipv4_mask->hdr.next_proto_id;
     342                 :            : 
     343                 :            :                 ipv4_spec = item->spec;
     344                 :          0 :                 filter->dst_ip = ipv4_spec->hdr.dst_addr;
     345                 :          0 :                 filter->src_ip = ipv4_spec->hdr.src_addr;
     346                 :          0 :                 filter->proto  = ipv4_spec->hdr.next_proto_id;
     347                 :            :         }
     348                 :            : 
     349                 :            :         /* check if the next not void item is TCP or UDP */
     350                 :            :         item = next_no_void_pattern(pattern, item);
     351                 :          0 :         if (item->type != RTE_FLOW_ITEM_TYPE_TCP &&
     352                 :            :             item->type != RTE_FLOW_ITEM_TYPE_UDP &&
     353         [ #  # ]:          0 :             item->type != RTE_FLOW_ITEM_TYPE_SCTP &&
     354                 :            :             item->type != RTE_FLOW_ITEM_TYPE_END) {
     355                 :            :                 memset(filter, 0, sizeof(struct rte_eth_ntuple_filter));
     356                 :          0 :                 rte_flow_error_set(error, EINVAL,
     357                 :            :                         RTE_FLOW_ERROR_TYPE_ITEM,
     358                 :            :                         item, "Not supported by ntuple filter");
     359                 :          0 :                 return -rte_errno;
     360                 :            :         }
     361                 :            : 
     362         [ #  # ]:          0 :         if (item->type != RTE_FLOW_ITEM_TYPE_END &&
     363   [ #  #  #  # ]:          0 :                 (!item->spec && !item->mask)) {
     364                 :          0 :                 goto action;
     365                 :            :         }
     366                 :            : 
     367                 :            :         /* get the TCP/UDP/SCTP info */
     368         [ #  # ]:          0 :         if (item->type != RTE_FLOW_ITEM_TYPE_END &&
     369   [ #  #  #  # ]:          0 :                 (!item->spec || !item->mask)) {
     370                 :            :                 memset(filter, 0, sizeof(struct rte_eth_ntuple_filter));
     371                 :          0 :                 rte_flow_error_set(error, EINVAL,
     372                 :            :                         RTE_FLOW_ERROR_TYPE_ITEM,
     373                 :            :                         item, "Invalid ntuple mask");
     374                 :          0 :                 return -rte_errno;
     375                 :            :         }
     376                 :            : 
     377                 :            :         /*Not supported last point for range*/
     378         [ #  # ]:          0 :         if (item->last) {
     379                 :            :                 memset(filter, 0, sizeof(struct rte_eth_ntuple_filter));
     380                 :          0 :                 rte_flow_error_set(error, EINVAL,
     381                 :            :                         RTE_FLOW_ERROR_TYPE_UNSPECIFIED,
     382                 :            :                         item, "Not supported last point for range");
     383                 :          0 :                 return -rte_errno;
     384                 :            :         }
     385                 :            : 
     386         [ #  # ]:          0 :         if (item->type == RTE_FLOW_ITEM_TYPE_TCP) {
     387                 :          0 :                 tcp_mask = item->mask;
     388                 :            : 
     389                 :            :                 /**
     390                 :            :                  * Only support src & dst ports, tcp flags,
     391                 :            :                  * others should be masked.
     392                 :            :                  */
     393         [ #  # ]:          0 :                 if (tcp_mask->hdr.sent_seq ||
     394         [ #  # ]:          0 :                     tcp_mask->hdr.recv_ack ||
     395         [ #  # ]:          0 :                     tcp_mask->hdr.data_off ||
     396         [ #  # ]:          0 :                     tcp_mask->hdr.rx_win ||
     397         [ #  # ]:          0 :                     tcp_mask->hdr.cksum ||
     398         [ #  # ]:          0 :                     tcp_mask->hdr.tcp_urp) {
     399                 :            :                         memset(filter, 0,
     400                 :            :                                 sizeof(struct rte_eth_ntuple_filter));
     401                 :          0 :                         rte_flow_error_set(error, EINVAL,
     402                 :            :                                 RTE_FLOW_ERROR_TYPE_ITEM,
     403                 :            :                                 item, "Not supported by ntuple filter");
     404                 :          0 :                         return -rte_errno;
     405                 :            :                 }
     406         [ #  # ]:          0 :                 if ((tcp_mask->hdr.src_port != 0 &&
     407                 :          0 :                         tcp_mask->hdr.src_port != UINT16_MAX) ||
     408         [ #  # ]:          0 :                         (tcp_mask->hdr.dst_port != 0 &&
     409                 :            :                         tcp_mask->hdr.dst_port != UINT16_MAX)) {
     410                 :          0 :                         rte_flow_error_set(error,
     411                 :            :                                 EINVAL, RTE_FLOW_ERROR_TYPE_ITEM,
     412                 :            :                                 item, "Not supported by ntuple filter");
     413                 :          0 :                         return -rte_errno;
     414                 :            :                 }
     415                 :            : 
     416                 :          0 :                 filter->dst_port_mask  = tcp_mask->hdr.dst_port;
     417                 :          0 :                 filter->src_port_mask  = tcp_mask->hdr.src_port;
     418         [ #  # ]:          0 :                 if (tcp_mask->hdr.tcp_flags == 0xFF) {
     419                 :          0 :                         filter->flags |= RTE_NTUPLE_FLAGS_TCP_FLAG;
     420         [ #  # ]:          0 :                 } else if (!tcp_mask->hdr.tcp_flags) {
     421                 :          0 :                         filter->flags &= ~RTE_NTUPLE_FLAGS_TCP_FLAG;
     422                 :            :                 } else {
     423                 :            :                         memset(filter, 0, sizeof(struct rte_eth_ntuple_filter));
     424                 :          0 :                         rte_flow_error_set(error, EINVAL,
     425                 :            :                                 RTE_FLOW_ERROR_TYPE_ITEM,
     426                 :            :                                 item, "Not supported by ntuple filter");
     427                 :          0 :                         return -rte_errno;
     428                 :            :                 }
     429                 :            : 
     430                 :          0 :                 tcp_spec = item->spec;
     431                 :          0 :                 filter->dst_port  = tcp_spec->hdr.dst_port;
     432                 :          0 :                 filter->src_port  = tcp_spec->hdr.src_port;
     433                 :          0 :                 filter->tcp_flags = tcp_spec->hdr.tcp_flags;
     434         [ #  # ]:          0 :         } else if (item->type == RTE_FLOW_ITEM_TYPE_UDP) {
     435                 :          0 :                 udp_mask = item->mask;
     436                 :            : 
     437                 :            :                 /**
     438                 :            :                  * Only support src & dst ports,
     439                 :            :                  * others should be masked.
     440                 :            :                  */
     441         [ #  # ]:          0 :                 if (udp_mask->hdr.dgram_len ||
     442         [ #  # ]:          0 :                     udp_mask->hdr.dgram_cksum) {
     443                 :            :                         memset(filter, 0,
     444                 :            :                                 sizeof(struct rte_eth_ntuple_filter));
     445                 :          0 :                         rte_flow_error_set(error, EINVAL,
     446                 :            :                                 RTE_FLOW_ERROR_TYPE_ITEM,
     447                 :            :                                 item, "Not supported by ntuple filter");
     448                 :          0 :                         return -rte_errno;
     449                 :            :                 }
     450         [ #  # ]:          0 :                 if ((udp_mask->hdr.src_port != 0 &&
     451                 :          0 :                         udp_mask->hdr.src_port != UINT16_MAX) ||
     452         [ #  # ]:          0 :                         (udp_mask->hdr.dst_port != 0 &&
     453                 :            :                         udp_mask->hdr.dst_port != UINT16_MAX)) {
     454                 :          0 :                         rte_flow_error_set(error,
     455                 :            :                                 EINVAL, RTE_FLOW_ERROR_TYPE_ITEM,
     456                 :            :                                 item, "Not supported by ntuple filter");
     457                 :          0 :                         return -rte_errno;
     458                 :            :                 }
     459                 :            : 
     460                 :          0 :                 filter->dst_port_mask = udp_mask->hdr.dst_port;
     461                 :          0 :                 filter->src_port_mask = udp_mask->hdr.src_port;
     462                 :            : 
     463                 :          0 :                 udp_spec = item->spec;
     464                 :          0 :                 filter->dst_port = udp_spec->hdr.dst_port;
     465                 :          0 :                 filter->src_port = udp_spec->hdr.src_port;
     466         [ #  # ]:          0 :         } else if (item->type == RTE_FLOW_ITEM_TYPE_SCTP) {
     467                 :          0 :                 sctp_mask = item->mask;
     468                 :            : 
     469                 :            :                 /**
     470                 :            :                  * Only support src & dst ports,
     471                 :            :                  * others should be masked.
     472                 :            :                  */
     473         [ #  # ]:          0 :                 if (sctp_mask->hdr.tag ||
     474         [ #  # ]:          0 :                     sctp_mask->hdr.cksum) {
     475                 :            :                         memset(filter, 0,
     476                 :            :                                 sizeof(struct rte_eth_ntuple_filter));
     477                 :          0 :                         rte_flow_error_set(error, EINVAL,
     478                 :            :                                 RTE_FLOW_ERROR_TYPE_ITEM,
     479                 :            :                                 item, "Not supported by ntuple filter");
     480                 :          0 :                         return -rte_errno;
     481                 :            :                 }
     482                 :            : 
     483                 :          0 :                 filter->dst_port_mask = sctp_mask->hdr.dst_port;
     484                 :          0 :                 filter->src_port_mask = sctp_mask->hdr.src_port;
     485                 :            : 
     486                 :          0 :                 sctp_spec = item->spec;
     487                 :          0 :                 filter->dst_port = sctp_spec->hdr.dst_port;
     488                 :          0 :                 filter->src_port = sctp_spec->hdr.src_port;
     489                 :            :         } else {
     490                 :          0 :                 goto action;
     491                 :            :         }
     492                 :            : 
     493                 :            :         /* check if the next not void item is END */
     494                 :            :         item = next_no_void_pattern(pattern, item);
     495         [ #  # ]:          0 :         if (item->type != RTE_FLOW_ITEM_TYPE_END) {
     496                 :            :                 memset(filter, 0, sizeof(struct rte_eth_ntuple_filter));
     497                 :          0 :                 rte_flow_error_set(error, EINVAL,
     498                 :            :                         RTE_FLOW_ERROR_TYPE_ITEM,
     499                 :            :                         item, "Not supported by ntuple filter");
     500                 :          0 :                 return -rte_errno;
     501                 :            :         }
     502                 :            : 
     503                 :          0 : action:
     504                 :            : 
     505                 :            :         /**
     506                 :            :          * n-tuple only supports forwarding,
     507                 :            :          * check if the first not void action is QUEUE.
     508                 :            :          */
     509                 :            :         act = next_no_void_action(actions, NULL);
     510         [ #  # ]:          0 :         if (act->type != RTE_FLOW_ACTION_TYPE_QUEUE) {
     511                 :            :                 memset(filter, 0, sizeof(struct rte_eth_ntuple_filter));
     512                 :          0 :                 rte_flow_error_set(error, EINVAL,
     513                 :            :                         RTE_FLOW_ERROR_TYPE_ACTION,
     514                 :            :                         act, "Not supported action.");
     515                 :          0 :                 return -rte_errno;
     516                 :            :         }
     517                 :          0 :         filter->queue =
     518                 :          0 :                 ((const struct rte_flow_action_queue *)act->conf)->index;
     519                 :            : 
     520                 :            :         /* check if the next not void item is END */
     521                 :            :         act = next_no_void_action(actions, act);
     522         [ #  # ]:          0 :         if (act->type != RTE_FLOW_ACTION_TYPE_END) {
     523                 :            :                 memset(filter, 0, sizeof(struct rte_eth_ntuple_filter));
     524                 :          0 :                 rte_flow_error_set(error, EINVAL,
     525                 :            :                         RTE_FLOW_ERROR_TYPE_ACTION,
     526                 :            :                         act, "Not supported action.");
     527                 :          0 :                 return -rte_errno;
     528                 :            :         }
     529                 :            : 
     530                 :            :         /* parse attr */
     531                 :            :         /* must be input direction */
     532         [ #  # ]:          0 :         if (!attr->ingress) {
     533                 :            :                 memset(filter, 0, sizeof(struct rte_eth_ntuple_filter));
     534                 :          0 :                 rte_flow_error_set(error, EINVAL,
     535                 :            :                                    RTE_FLOW_ERROR_TYPE_ATTR_INGRESS,
     536                 :            :                                    attr, "Only support ingress.");
     537                 :          0 :                 return -rte_errno;
     538                 :            :         }
     539                 :            : 
     540                 :            :         /* not supported */
     541         [ #  # ]:          0 :         if (attr->egress) {
     542                 :            :                 memset(filter, 0, sizeof(struct rte_eth_ntuple_filter));
     543                 :          0 :                 rte_flow_error_set(error, EINVAL,
     544                 :            :                                    RTE_FLOW_ERROR_TYPE_ATTR_EGRESS,
     545                 :            :                                    attr, "Not support egress.");
     546                 :          0 :                 return -rte_errno;
     547                 :            :         }
     548                 :            : 
     549                 :            :         /* not supported */
     550         [ #  # ]:          0 :         if (attr->transfer) {
     551                 :            :                 memset(filter, 0, sizeof(struct rte_eth_ntuple_filter));
     552                 :          0 :                 rte_flow_error_set(error, EINVAL,
     553                 :            :                                    RTE_FLOW_ERROR_TYPE_ATTR_TRANSFER,
     554                 :            :                                    attr, "No support for transfer.");
     555                 :          0 :                 return -rte_errno;
     556                 :            :         }
     557                 :            : 
     558         [ #  # ]:          0 :         if (attr->priority > 0xFFFF) {
     559                 :            :                 memset(filter, 0, sizeof(struct rte_eth_ntuple_filter));
     560                 :          0 :                 rte_flow_error_set(error, EINVAL,
     561                 :            :                                    RTE_FLOW_ERROR_TYPE_ATTR_PRIORITY,
     562                 :            :                                    attr, "Error priority.");
     563                 :          0 :                 return -rte_errno;
     564                 :            :         }
     565                 :          0 :         filter->priority = (uint16_t)attr->priority;
     566         [ #  # ]:          0 :         if (attr->priority < TXGBE_MIN_N_TUPLE_PRIO ||
     567                 :            :                 attr->priority > TXGBE_MAX_N_TUPLE_PRIO)
     568                 :          0 :                 filter->priority = 1;
     569                 :            : 
     570                 :            :         return 0;
     571                 :            : }
     572                 :            : 
     573                 :            : /* a specific function for txgbe because the flags is specific */
     574                 :            : static int
     575                 :          0 : txgbe_parse_ntuple_filter(struct rte_eth_dev *dev,
     576                 :            :                           const struct rte_flow_attr *attr,
     577                 :            :                           const struct rte_flow_item pattern[],
     578                 :            :                           const struct rte_flow_action actions[],
     579                 :            :                           struct rte_eth_ntuple_filter *filter,
     580                 :            :                           struct rte_flow_error *error)
     581                 :            : {
     582                 :            :         int ret;
     583                 :            : 
     584                 :          0 :         ret = cons_parse_ntuple_filter(attr, pattern, actions, filter, error);
     585                 :            : 
     586         [ #  # ]:          0 :         if (ret)
     587                 :            :                 return ret;
     588                 :            : 
     589                 :            : #ifdef RTE_LIB_SECURITY
     590                 :            :         /* ESP flow not really a flow */
     591         [ #  # ]:          0 :         if (filter->proto == IPPROTO_ESP)
     592                 :            :                 return 0;
     593                 :            : #endif
     594                 :            : 
     595                 :            :         /* txgbe doesn't support tcp flags */
     596         [ #  # ]:          0 :         if (filter->flags & RTE_NTUPLE_FLAGS_TCP_FLAG) {
     597                 :            :                 memset(filter, 0, sizeof(struct rte_eth_ntuple_filter));
     598                 :          0 :                 rte_flow_error_set(error, EINVAL,
     599                 :            :                                    RTE_FLOW_ERROR_TYPE_ITEM,
     600                 :            :                                    NULL, "Not supported by ntuple filter");
     601                 :          0 :                 return -rte_errno;
     602                 :            :         }
     603                 :            : 
     604                 :            :         /* txgbe doesn't support many priorities */
     605         [ #  # ]:          0 :         if (filter->priority < TXGBE_MIN_N_TUPLE_PRIO ||
     606                 :            :             filter->priority > TXGBE_MAX_N_TUPLE_PRIO) {
     607                 :            :                 memset(filter, 0, sizeof(struct rte_eth_ntuple_filter));
     608                 :          0 :                 rte_flow_error_set(error, EINVAL,
     609                 :            :                         RTE_FLOW_ERROR_TYPE_ITEM,
     610                 :            :                         NULL, "Priority not supported by ntuple filter");
     611                 :          0 :                 return -rte_errno;
     612                 :            :         }
     613                 :            : 
     614         [ #  # ]:          0 :         if (filter->queue >= dev->data->nb_rx_queues) {
     615                 :            :                 memset(filter, 0, sizeof(struct rte_eth_ntuple_filter));
     616                 :          0 :                 rte_flow_error_set(error, EINVAL,
     617                 :            :                                    RTE_FLOW_ERROR_TYPE_ITEM,
     618                 :            :                                    NULL, "Not supported by ntuple filter");
     619                 :          0 :                 return -rte_errno;
     620                 :            :         }
     621                 :            : 
     622                 :            :         /* fixed value for txgbe */
     623                 :          0 :         filter->flags = RTE_5TUPLE_FLAGS;
     624                 :          0 :         return 0;
     625                 :            : }
     626                 :            : 
     627                 :            : /**
     628                 :            :  * Parse the rule to see if it is a ethertype rule.
     629                 :            :  * And get the ethertype filter info BTW.
     630                 :            :  * pattern:
     631                 :            :  * The first not void item can be ETH.
     632                 :            :  * The next not void item must be END.
     633                 :            :  * action:
     634                 :            :  * The first not void action should be QUEUE.
     635                 :            :  * The next not void action should be END.
     636                 :            :  * pattern example:
     637                 :            :  * ITEM         Spec                    Mask
     638                 :            :  * ETH          type    0x0807          0xFFFF
     639                 :            :  * END
     640                 :            :  * other members in mask and spec should set to 0x00.
     641                 :            :  * item->last should be NULL.
     642                 :            :  */
     643                 :            : static int
     644                 :          0 : cons_parse_ethertype_filter(const struct rte_flow_attr *attr,
     645                 :            :                             const struct rte_flow_item *pattern,
     646                 :            :                             const struct rte_flow_action *actions,
     647                 :            :                             struct rte_eth_ethertype_filter *filter,
     648                 :            :                             struct rte_flow_error *error)
     649                 :            : {
     650                 :            :         const struct rte_flow_item *item;
     651                 :            :         const struct rte_flow_action *act;
     652                 :            :         const struct rte_flow_item_eth *eth_spec;
     653                 :            :         const struct rte_flow_item_eth *eth_mask;
     654                 :            :         const struct rte_flow_action_queue *act_q;
     655                 :            : 
     656         [ #  # ]:          0 :         if (!pattern) {
     657                 :          0 :                 rte_flow_error_set(error, EINVAL,
     658                 :            :                                 RTE_FLOW_ERROR_TYPE_ITEM_NUM,
     659                 :            :                                 NULL, "NULL pattern.");
     660                 :          0 :                 return -rte_errno;
     661                 :            :         }
     662                 :            : 
     663         [ #  # ]:          0 :         if (!actions) {
     664                 :          0 :                 rte_flow_error_set(error, EINVAL,
     665                 :            :                                 RTE_FLOW_ERROR_TYPE_ACTION_NUM,
     666                 :            :                                 NULL, "NULL action.");
     667                 :          0 :                 return -rte_errno;
     668                 :            :         }
     669                 :            : 
     670         [ #  # ]:          0 :         if (!attr) {
     671                 :          0 :                 rte_flow_error_set(error, EINVAL,
     672                 :            :                                    RTE_FLOW_ERROR_TYPE_ATTR,
     673                 :            :                                    NULL, "NULL attribute.");
     674                 :          0 :                 return -rte_errno;
     675                 :            :         }
     676                 :            : 
     677                 :            :         item = next_no_void_pattern(pattern, NULL);
     678                 :            :         /* The first non-void item should be MAC. */
     679         [ #  # ]:          0 :         if (item->type != RTE_FLOW_ITEM_TYPE_ETH) {
     680                 :          0 :                 rte_flow_error_set(error, EINVAL,
     681                 :            :                         RTE_FLOW_ERROR_TYPE_ITEM,
     682                 :            :                         item, "Not supported by ethertype filter");
     683                 :          0 :                 return -rte_errno;
     684                 :            :         }
     685                 :            : 
     686                 :            :         /*Not supported last point for range*/
     687         [ #  # ]:          0 :         if (item->last) {
     688                 :          0 :                 rte_flow_error_set(error, EINVAL,
     689                 :            :                         RTE_FLOW_ERROR_TYPE_UNSPECIFIED,
     690                 :            :                         item, "Not supported last point for range");
     691                 :          0 :                 return -rte_errno;
     692                 :            :         }
     693                 :            : 
     694                 :            :         /* Get the MAC info. */
     695   [ #  #  #  # ]:          0 :         if (!item->spec || !item->mask) {
     696                 :          0 :                 rte_flow_error_set(error, EINVAL,
     697                 :            :                                 RTE_FLOW_ERROR_TYPE_ITEM,
     698                 :            :                                 item, "Not supported by ethertype filter");
     699                 :          0 :                 return -rte_errno;
     700                 :            :         }
     701                 :            : 
     702                 :            :         eth_spec = item->spec;
     703                 :            :         eth_mask = item->mask;
     704                 :            : 
     705                 :            :         /* Mask bits of source MAC address must be full of 0.
     706                 :            :          * Mask bits of destination MAC address must be full
     707                 :            :          * of 1 or full of 0.
     708                 :            :          */
     709   [ #  #  #  # ]:          0 :         if (!rte_is_zero_ether_addr(&eth_mask->hdr.src_addr) ||
     710         [ #  # ]:          0 :             (!rte_is_zero_ether_addr(&eth_mask->hdr.dst_addr) &&
     711                 :            :              !rte_is_broadcast_ether_addr(&eth_mask->hdr.dst_addr))) {
     712                 :          0 :                 rte_flow_error_set(error, EINVAL,
     713                 :            :                                 RTE_FLOW_ERROR_TYPE_ITEM,
     714                 :            :                                 item, "Invalid ether address mask");
     715                 :          0 :                 return -rte_errno;
     716                 :            :         }
     717                 :            : 
     718         [ #  # ]:          0 :         if ((eth_mask->hdr.ether_type & UINT16_MAX) != UINT16_MAX) {
     719                 :          0 :                 rte_flow_error_set(error, EINVAL,
     720                 :            :                                 RTE_FLOW_ERROR_TYPE_ITEM,
     721                 :            :                                 item, "Invalid ethertype mask");
     722                 :          0 :                 return -rte_errno;
     723                 :            :         }
     724                 :            : 
     725                 :            :         /* If mask bits of destination MAC address
     726                 :            :          * are full of 1, set RTE_ETHTYPE_FLAGS_MAC.
     727                 :            :          */
     728         [ #  # ]:          0 :         if (rte_is_broadcast_ether_addr(&eth_mask->hdr.dst_addr)) {
     729                 :          0 :                 filter->mac_addr = eth_spec->hdr.dst_addr;
     730                 :          0 :                 filter->flags |= RTE_ETHTYPE_FLAGS_MAC;
     731                 :            :         } else {
     732                 :          0 :                 filter->flags &= ~RTE_ETHTYPE_FLAGS_MAC;
     733                 :            :         }
     734         [ #  # ]:          0 :         filter->ether_type = rte_be_to_cpu_16(eth_spec->hdr.ether_type);
     735                 :            : 
     736                 :            :         /* Check if the next non-void item is END. */
     737                 :            :         item = next_no_void_pattern(pattern, item);
     738         [ #  # ]:          0 :         if (item->type != RTE_FLOW_ITEM_TYPE_END) {
     739                 :          0 :                 rte_flow_error_set(error, EINVAL,
     740                 :            :                                 RTE_FLOW_ERROR_TYPE_ITEM,
     741                 :            :                                 item, "Not supported by ethertype filter.");
     742                 :          0 :                 return -rte_errno;
     743                 :            :         }
     744                 :            : 
     745                 :            :         /* Parse action */
     746                 :            : 
     747                 :            :         act = next_no_void_action(actions, NULL);
     748         [ #  # ]:          0 :         if (act->type != RTE_FLOW_ACTION_TYPE_QUEUE &&
     749                 :            :             act->type != RTE_FLOW_ACTION_TYPE_DROP) {
     750                 :          0 :                 rte_flow_error_set(error, EINVAL,
     751                 :            :                                 RTE_FLOW_ERROR_TYPE_ACTION,
     752                 :            :                                 act, "Not supported action.");
     753                 :          0 :                 return -rte_errno;
     754                 :            :         }
     755                 :            : 
     756         [ #  # ]:          0 :         if (act->type == RTE_FLOW_ACTION_TYPE_QUEUE) {
     757                 :          0 :                 act_q = (const struct rte_flow_action_queue *)act->conf;
     758                 :          0 :                 filter->queue = act_q->index;
     759                 :            :         } else {
     760                 :          0 :                 filter->flags |= RTE_ETHTYPE_FLAGS_DROP;
     761                 :            :         }
     762                 :            : 
     763                 :            :         /* Check if the next non-void item is END */
     764                 :            :         act = next_no_void_action(actions, act);
     765         [ #  # ]:          0 :         if (act->type != RTE_FLOW_ACTION_TYPE_END) {
     766                 :          0 :                 rte_flow_error_set(error, EINVAL,
     767                 :            :                                 RTE_FLOW_ERROR_TYPE_ACTION,
     768                 :            :                                 act, "Not supported action.");
     769                 :          0 :                 return -rte_errno;
     770                 :            :         }
     771                 :            : 
     772                 :            :         /* Parse attr */
     773                 :            :         /* Must be input direction */
     774         [ #  # ]:          0 :         if (!attr->ingress) {
     775                 :          0 :                 rte_flow_error_set(error, EINVAL,
     776                 :            :                                 RTE_FLOW_ERROR_TYPE_ATTR_INGRESS,
     777                 :            :                                 attr, "Only support ingress.");
     778                 :          0 :                 return -rte_errno;
     779                 :            :         }
     780                 :            : 
     781                 :            :         /* Not supported */
     782         [ #  # ]:          0 :         if (attr->egress) {
     783                 :          0 :                 rte_flow_error_set(error, EINVAL,
     784                 :            :                                 RTE_FLOW_ERROR_TYPE_ATTR_EGRESS,
     785                 :            :                                 attr, "Not support egress.");
     786                 :          0 :                 return -rte_errno;
     787                 :            :         }
     788                 :            : 
     789                 :            :         /* Not supported */
     790         [ #  # ]:          0 :         if (attr->transfer) {
     791                 :          0 :                 rte_flow_error_set(error, EINVAL,
     792                 :            :                                 RTE_FLOW_ERROR_TYPE_ATTR_TRANSFER,
     793                 :            :                                 attr, "No support for transfer.");
     794                 :          0 :                 return -rte_errno;
     795                 :            :         }
     796                 :            : 
     797                 :            :         /* Not supported */
     798         [ #  # ]:          0 :         if (attr->priority) {
     799                 :          0 :                 rte_flow_error_set(error, EINVAL,
     800                 :            :                                 RTE_FLOW_ERROR_TYPE_ATTR_PRIORITY,
     801                 :            :                                 attr, "Not support priority.");
     802                 :          0 :                 return -rte_errno;
     803                 :            :         }
     804                 :            : 
     805                 :            :         /* Not supported */
     806         [ #  # ]:          0 :         if (attr->group) {
     807                 :          0 :                 rte_flow_error_set(error, EINVAL,
     808                 :            :                                 RTE_FLOW_ERROR_TYPE_ATTR_GROUP,
     809                 :            :                                 attr, "Not support group.");
     810                 :          0 :                 return -rte_errno;
     811                 :            :         }
     812                 :            : 
     813                 :            :         return 0;
     814                 :            : }
     815                 :            : 
     816                 :            : static int
     817                 :          0 : txgbe_parse_ethertype_filter(struct rte_eth_dev *dev,
     818                 :            :                              const struct rte_flow_attr *attr,
     819                 :            :                              const struct rte_flow_item pattern[],
     820                 :            :                              const struct rte_flow_action actions[],
     821                 :            :                              struct rte_eth_ethertype_filter *filter,
     822                 :            :                              struct rte_flow_error *error)
     823                 :            : {
     824                 :            :         int ret;
     825                 :            : 
     826                 :          0 :         ret = cons_parse_ethertype_filter(attr, pattern,
     827                 :            :                                         actions, filter, error);
     828                 :            : 
     829         [ #  # ]:          0 :         if (ret)
     830                 :            :                 return ret;
     831                 :            : 
     832         [ #  # ]:          0 :         if (filter->queue >= dev->data->nb_rx_queues) {
     833                 :            :                 memset(filter, 0, sizeof(struct rte_eth_ethertype_filter));
     834                 :          0 :                 rte_flow_error_set(error, EINVAL,
     835                 :            :                         RTE_FLOW_ERROR_TYPE_ITEM,
     836                 :            :                         NULL, "queue index much too big");
     837                 :          0 :                 return -rte_errno;
     838                 :            :         }
     839                 :            : 
     840         [ #  # ]:          0 :         if (filter->ether_type == RTE_ETHER_TYPE_IPV4 ||
     841                 :            :                 filter->ether_type == RTE_ETHER_TYPE_IPV6) {
     842                 :            :                 memset(filter, 0, sizeof(struct rte_eth_ethertype_filter));
     843                 :          0 :                 rte_flow_error_set(error, EINVAL,
     844                 :            :                         RTE_FLOW_ERROR_TYPE_ITEM,
     845                 :            :                         NULL, "IPv4/IPv6 not supported by ethertype filter");
     846                 :          0 :                 return -rte_errno;
     847                 :            :         }
     848                 :            : 
     849         [ #  # ]:          0 :         if (filter->flags & RTE_ETHTYPE_FLAGS_MAC) {
     850                 :            :                 memset(filter, 0, sizeof(struct rte_eth_ethertype_filter));
     851                 :          0 :                 rte_flow_error_set(error, EINVAL,
     852                 :            :                         RTE_FLOW_ERROR_TYPE_ITEM,
     853                 :            :                         NULL, "mac compare is unsupported");
     854                 :          0 :                 return -rte_errno;
     855                 :            :         }
     856                 :            : 
     857         [ #  # ]:          0 :         if (filter->flags & RTE_ETHTYPE_FLAGS_DROP) {
     858                 :            :                 memset(filter, 0, sizeof(struct rte_eth_ethertype_filter));
     859                 :          0 :                 rte_flow_error_set(error, EINVAL,
     860                 :            :                         RTE_FLOW_ERROR_TYPE_ITEM,
     861                 :            :                         NULL, "drop option is unsupported");
     862                 :          0 :                 return -rte_errno;
     863                 :            :         }
     864                 :            : 
     865                 :            :         return 0;
     866                 :            : }
     867                 :            : 
     868                 :            : /**
     869                 :            :  * Parse the rule to see if it is a TCP SYN rule.
     870                 :            :  * And get the TCP SYN filter info BTW.
     871                 :            :  * pattern:
     872                 :            :  * The first not void item must be ETH.
     873                 :            :  * The second not void item must be IPV4 or IPV6.
     874                 :            :  * The third not void item must be TCP.
     875                 :            :  * The next not void item must be END.
     876                 :            :  * action:
     877                 :            :  * The first not void action should be QUEUE.
     878                 :            :  * The next not void action should be END.
     879                 :            :  * pattern example:
     880                 :            :  * ITEM         Spec                    Mask
     881                 :            :  * ETH          NULL                    NULL
     882                 :            :  * IPV4/IPV6    NULL                    NULL
     883                 :            :  * TCP          tcp_flags       0x02    0xFF
     884                 :            :  * END
     885                 :            :  * other members in mask and spec should set to 0x00.
     886                 :            :  * item->last should be NULL.
     887                 :            :  */
     888                 :            : static int
     889                 :          0 : cons_parse_syn_filter(const struct rte_flow_attr *attr,
     890                 :            :                                 const struct rte_flow_item pattern[],
     891                 :            :                                 const struct rte_flow_action actions[],
     892                 :            :                                 struct rte_eth_syn_filter *filter,
     893                 :            :                                 struct rte_flow_error *error)
     894                 :            : {
     895                 :            :         const struct rte_flow_item *item;
     896                 :            :         const struct rte_flow_action *act;
     897                 :            :         const struct rte_flow_item_tcp *tcp_spec;
     898                 :            :         const struct rte_flow_item_tcp *tcp_mask;
     899                 :            :         const struct rte_flow_action_queue *act_q;
     900                 :            : 
     901         [ #  # ]:          0 :         if (!pattern) {
     902                 :          0 :                 rte_flow_error_set(error, EINVAL,
     903                 :            :                                 RTE_FLOW_ERROR_TYPE_ITEM_NUM,
     904                 :            :                                 NULL, "NULL pattern.");
     905                 :          0 :                 return -rte_errno;
     906                 :            :         }
     907                 :            : 
     908         [ #  # ]:          0 :         if (!actions) {
     909                 :          0 :                 rte_flow_error_set(error, EINVAL,
     910                 :            :                                 RTE_FLOW_ERROR_TYPE_ACTION_NUM,
     911                 :            :                                 NULL, "NULL action.");
     912                 :          0 :                 return -rte_errno;
     913                 :            :         }
     914                 :            : 
     915         [ #  # ]:          0 :         if (!attr) {
     916                 :          0 :                 rte_flow_error_set(error, EINVAL,
     917                 :            :                                    RTE_FLOW_ERROR_TYPE_ATTR,
     918                 :            :                                    NULL, "NULL attribute.");
     919                 :          0 :                 return -rte_errno;
     920                 :            :         }
     921                 :            : 
     922                 :            : 
     923                 :            :         /* the first not void item should be MAC or IPv4 or IPv6 or TCP */
     924                 :            :         item = next_no_void_pattern(pattern, NULL);
     925         [ #  # ]:          0 :         if (item->type != RTE_FLOW_ITEM_TYPE_ETH &&
     926         [ #  # ]:          0 :             item->type != RTE_FLOW_ITEM_TYPE_IPV4 &&
     927         [ #  # ]:          0 :             item->type != RTE_FLOW_ITEM_TYPE_IPV6 &&
     928                 :            :             item->type != RTE_FLOW_ITEM_TYPE_TCP) {
     929                 :          0 :                 rte_flow_error_set(error, EINVAL,
     930                 :            :                                 RTE_FLOW_ERROR_TYPE_ITEM,
     931                 :            :                                 item, "Not supported by syn filter");
     932                 :          0 :                 return -rte_errno;
     933                 :            :         }
     934                 :            :                 /*Not supported last point for range*/
     935         [ #  # ]:          0 :         if (item->last) {
     936                 :          0 :                 rte_flow_error_set(error, EINVAL,
     937                 :            :                         RTE_FLOW_ERROR_TYPE_UNSPECIFIED,
     938                 :            :                         item, "Not supported last point for range");
     939                 :          0 :                 return -rte_errno;
     940                 :            :         }
     941                 :            : 
     942                 :            :         /* Skip Ethernet */
     943         [ #  # ]:          0 :         if (item->type == RTE_FLOW_ITEM_TYPE_ETH) {
     944                 :            :                 /* if the item is MAC, the content should be NULL */
     945   [ #  #  #  # ]:          0 :                 if (item->spec || item->mask) {
     946                 :          0 :                         rte_flow_error_set(error, EINVAL,
     947                 :            :                                 RTE_FLOW_ERROR_TYPE_ITEM,
     948                 :            :                                 item, "Invalid SYN address mask");
     949                 :          0 :                         return -rte_errno;
     950                 :            :                 }
     951                 :            : 
     952                 :            :                 /* check if the next not void item is IPv4 or IPv6 */
     953                 :            :                 item = next_no_void_pattern(pattern, item);
     954         [ #  # ]:          0 :                 if (item->type != RTE_FLOW_ITEM_TYPE_IPV4 &&
     955                 :            :                     item->type != RTE_FLOW_ITEM_TYPE_IPV6) {
     956                 :          0 :                         rte_flow_error_set(error, EINVAL,
     957                 :            :                                 RTE_FLOW_ERROR_TYPE_ITEM,
     958                 :            :                                 item, "Not supported by syn filter");
     959                 :          0 :                         return -rte_errno;
     960                 :            :                 }
     961                 :            :         }
     962                 :            : 
     963                 :            :         /* Skip IP */
     964         [ #  # ]:          0 :         if (item->type == RTE_FLOW_ITEM_TYPE_IPV4 ||
     965                 :            :             item->type == RTE_FLOW_ITEM_TYPE_IPV6) {
     966                 :            :                 /* if the item is IP, the content should be NULL */
     967   [ #  #  #  # ]:          0 :                 if (item->spec || item->mask) {
     968                 :          0 :                         rte_flow_error_set(error, EINVAL,
     969                 :            :                                 RTE_FLOW_ERROR_TYPE_ITEM,
     970                 :            :                                 item, "Invalid SYN mask");
     971                 :          0 :                         return -rte_errno;
     972                 :            :                 }
     973                 :            : 
     974                 :            :                 /* check if the next not void item is TCP */
     975                 :            :                 item = next_no_void_pattern(pattern, item);
     976         [ #  # ]:          0 :                 if (item->type != RTE_FLOW_ITEM_TYPE_TCP) {
     977                 :          0 :                         rte_flow_error_set(error, EINVAL,
     978                 :            :                                 RTE_FLOW_ERROR_TYPE_ITEM,
     979                 :            :                                 item, "Not supported by syn filter");
     980                 :          0 :                         return -rte_errno;
     981                 :            :                 }
     982                 :            :         }
     983                 :            : 
     984                 :            :         /* Get the TCP info. Only support SYN. */
     985   [ #  #  #  # ]:          0 :         if (!item->spec || !item->mask) {
     986                 :          0 :                 rte_flow_error_set(error, EINVAL,
     987                 :            :                                 RTE_FLOW_ERROR_TYPE_ITEM,
     988                 :            :                                 item, "Invalid SYN mask");
     989                 :          0 :                 return -rte_errno;
     990                 :            :         }
     991                 :            :         /*Not supported last point for range*/
     992         [ #  # ]:          0 :         if (item->last) {
     993                 :          0 :                 rte_flow_error_set(error, EINVAL,
     994                 :            :                         RTE_FLOW_ERROR_TYPE_UNSPECIFIED,
     995                 :            :                         item, "Not supported last point for range");
     996                 :          0 :                 return -rte_errno;
     997                 :            :         }
     998                 :            : 
     999                 :            :         tcp_spec = item->spec;
    1000                 :            :         tcp_mask = item->mask;
    1001         [ #  # ]:          0 :         if (!(tcp_spec->hdr.tcp_flags & RTE_TCP_SYN_FLAG) ||
    1002         [ #  # ]:          0 :             tcp_mask->hdr.src_port ||
    1003         [ #  # ]:          0 :             tcp_mask->hdr.dst_port ||
    1004         [ #  # ]:          0 :             tcp_mask->hdr.sent_seq ||
    1005         [ #  # ]:          0 :             tcp_mask->hdr.recv_ack ||
    1006         [ #  # ]:          0 :             tcp_mask->hdr.data_off ||
    1007         [ #  # ]:          0 :             tcp_mask->hdr.tcp_flags != RTE_TCP_SYN_FLAG ||
    1008         [ #  # ]:          0 :             tcp_mask->hdr.rx_win ||
    1009         [ #  # ]:          0 :             tcp_mask->hdr.cksum ||
    1010         [ #  # ]:          0 :             tcp_mask->hdr.tcp_urp) {
    1011                 :            :                 memset(filter, 0, sizeof(struct rte_eth_syn_filter));
    1012                 :          0 :                 rte_flow_error_set(error, EINVAL,
    1013                 :            :                                 RTE_FLOW_ERROR_TYPE_ITEM,
    1014                 :            :                                 item, "Not supported by syn filter");
    1015                 :          0 :                 return -rte_errno;
    1016                 :            :         }
    1017                 :            : 
    1018                 :            :         /* check if the next not void item is END */
    1019                 :            :         item = next_no_void_pattern(pattern, item);
    1020         [ #  # ]:          0 :         if (item->type != RTE_FLOW_ITEM_TYPE_END) {
    1021                 :            :                 memset(filter, 0, sizeof(struct rte_eth_syn_filter));
    1022                 :          0 :                 rte_flow_error_set(error, EINVAL,
    1023                 :            :                                 RTE_FLOW_ERROR_TYPE_ITEM,
    1024                 :            :                                 item, "Not supported by syn filter");
    1025                 :          0 :                 return -rte_errno;
    1026                 :            :         }
    1027                 :            : 
    1028                 :            :         /* check if the first not void action is QUEUE. */
    1029                 :            :         act = next_no_void_action(actions, NULL);
    1030         [ #  # ]:          0 :         if (act->type != RTE_FLOW_ACTION_TYPE_QUEUE) {
    1031                 :            :                 memset(filter, 0, sizeof(struct rte_eth_syn_filter));
    1032                 :          0 :                 rte_flow_error_set(error, EINVAL,
    1033                 :            :                                 RTE_FLOW_ERROR_TYPE_ACTION,
    1034                 :            :                                 act, "Not supported action.");
    1035                 :          0 :                 return -rte_errno;
    1036                 :            :         }
    1037                 :            : 
    1038                 :          0 :         act_q = (const struct rte_flow_action_queue *)act->conf;
    1039                 :          0 :         filter->queue = act_q->index;
    1040         [ #  # ]:          0 :         if (filter->queue >= TXGBE_MAX_RX_QUEUE_NUM) {
    1041                 :            :                 memset(filter, 0, sizeof(struct rte_eth_syn_filter));
    1042                 :          0 :                 rte_flow_error_set(error, EINVAL,
    1043                 :            :                                 RTE_FLOW_ERROR_TYPE_ACTION,
    1044                 :            :                                 act, "Not supported action.");
    1045                 :          0 :                 return -rte_errno;
    1046                 :            :         }
    1047                 :            : 
    1048                 :            :         /* check if the next not void item is END */
    1049                 :            :         act = next_no_void_action(actions, act);
    1050         [ #  # ]:          0 :         if (act->type != RTE_FLOW_ACTION_TYPE_END) {
    1051                 :            :                 memset(filter, 0, sizeof(struct rte_eth_syn_filter));
    1052                 :          0 :                 rte_flow_error_set(error, EINVAL,
    1053                 :            :                                 RTE_FLOW_ERROR_TYPE_ACTION,
    1054                 :            :                                 act, "Not supported action.");
    1055                 :          0 :                 return -rte_errno;
    1056                 :            :         }
    1057                 :            : 
    1058                 :            :         /* parse attr */
    1059                 :            :         /* must be input direction */
    1060         [ #  # ]:          0 :         if (!attr->ingress) {
    1061                 :            :                 memset(filter, 0, sizeof(struct rte_eth_syn_filter));
    1062                 :          0 :                 rte_flow_error_set(error, EINVAL,
    1063                 :            :                         RTE_FLOW_ERROR_TYPE_ATTR_INGRESS,
    1064                 :            :                         attr, "Only support ingress.");
    1065                 :          0 :                 return -rte_errno;
    1066                 :            :         }
    1067                 :            : 
    1068                 :            :         /* not supported */
    1069         [ #  # ]:          0 :         if (attr->egress) {
    1070                 :            :                 memset(filter, 0, sizeof(struct rte_eth_syn_filter));
    1071                 :          0 :                 rte_flow_error_set(error, EINVAL,
    1072                 :            :                         RTE_FLOW_ERROR_TYPE_ATTR_EGRESS,
    1073                 :            :                         attr, "Not support egress.");
    1074                 :          0 :                 return -rte_errno;
    1075                 :            :         }
    1076                 :            : 
    1077                 :            :         /* not supported */
    1078         [ #  # ]:          0 :         if (attr->transfer) {
    1079                 :            :                 memset(filter, 0, sizeof(struct rte_eth_syn_filter));
    1080                 :          0 :                 rte_flow_error_set(error, EINVAL,
    1081                 :            :                         RTE_FLOW_ERROR_TYPE_ATTR_TRANSFER,
    1082                 :            :                         attr, "No support for transfer.");
    1083                 :          0 :                 return -rte_errno;
    1084                 :            :         }
    1085                 :            : 
    1086                 :            :         /* Support 2 priorities, the lowest or highest. */
    1087         [ #  # ]:          0 :         if (!attr->priority) {
    1088                 :          0 :                 filter->hig_pri = 0;
    1089         [ #  # ]:          0 :         } else if (attr->priority == (uint32_t)~0U) {
    1090                 :          0 :                 filter->hig_pri = 1;
    1091                 :            :         } else {
    1092                 :            :                 memset(filter, 0, sizeof(struct rte_eth_syn_filter));
    1093                 :          0 :                 rte_flow_error_set(error, EINVAL,
    1094                 :            :                         RTE_FLOW_ERROR_TYPE_ATTR_PRIORITY,
    1095                 :            :                         attr, "Not support priority.");
    1096                 :          0 :                 return -rte_errno;
    1097                 :            :         }
    1098                 :            : 
    1099                 :            :         return 0;
    1100                 :            : }
    1101                 :            : 
    1102                 :            : static int
    1103                 :            : txgbe_parse_syn_filter(struct rte_eth_dev *dev,
    1104                 :            :                              const struct rte_flow_attr *attr,
    1105                 :            :                              const struct rte_flow_item pattern[],
    1106                 :            :                              const struct rte_flow_action actions[],
    1107                 :            :                              struct rte_eth_syn_filter *filter,
    1108                 :            :                              struct rte_flow_error *error)
    1109                 :            : {
    1110                 :            :         int ret;
    1111                 :            : 
    1112                 :          0 :         ret = cons_parse_syn_filter(attr, pattern,
    1113                 :            :                                         actions, filter, error);
    1114                 :            : 
    1115   [ #  #  #  # ]:          0 :         if (filter->queue >= dev->data->nb_rx_queues)
    1116                 :          0 :                 return -rte_errno;
    1117                 :            : 
    1118   [ #  #  #  # ]:          0 :         if (ret)
    1119                 :            :                 return ret;
    1120                 :            : 
    1121                 :            :         return 0;
    1122                 :            : }
    1123                 :            : 
    1124                 :            : /**
    1125                 :            :  * Parse the rule to see if it is a L2 tunnel rule.
    1126                 :            :  * And get the L2 tunnel filter info BTW.
    1127                 :            :  * Only support E-tag now.
    1128                 :            :  * pattern:
    1129                 :            :  * The first not void item can be E_TAG.
    1130                 :            :  * The next not void item must be END.
    1131                 :            :  * action:
    1132                 :            :  * The first not void action should be VF or PF.
    1133                 :            :  * The next not void action should be END.
    1134                 :            :  * pattern example:
    1135                 :            :  * ITEM         Spec                    Mask
    1136                 :            :  * E_TAG        grp             0x1     0x3
    1137                 :            :                 e_cid_base      0x309   0xFFF
    1138                 :            :  * END
    1139                 :            :  * other members in mask and spec should set to 0x00.
    1140                 :            :  * item->last should be NULL.
    1141                 :            :  */
    1142                 :            : static int
    1143                 :          0 : cons_parse_l2_tn_filter(struct rte_eth_dev *dev,
    1144                 :            :                         const struct rte_flow_attr *attr,
    1145                 :            :                         const struct rte_flow_item pattern[],
    1146                 :            :                         const struct rte_flow_action actions[],
    1147                 :            :                         struct txgbe_l2_tunnel_conf *filter,
    1148                 :            :                         struct rte_flow_error *error)
    1149                 :            : {
    1150                 :            :         const struct rte_flow_item *item;
    1151                 :            :         const struct rte_flow_item_e_tag *e_tag_spec;
    1152                 :            :         const struct rte_flow_item_e_tag *e_tag_mask;
    1153                 :            :         const struct rte_flow_action *act;
    1154                 :            :         const struct rte_flow_action_vf *act_vf;
    1155                 :          0 :         struct rte_pci_device *pci_dev = RTE_ETH_DEV_TO_PCI(dev);
    1156                 :            : 
    1157         [ #  # ]:          0 :         if (!pattern) {
    1158                 :          0 :                 rte_flow_error_set(error, EINVAL,
    1159                 :            :                         RTE_FLOW_ERROR_TYPE_ITEM_NUM,
    1160                 :            :                         NULL, "NULL pattern.");
    1161                 :          0 :                 return -rte_errno;
    1162                 :            :         }
    1163                 :            : 
    1164         [ #  # ]:          0 :         if (!actions) {
    1165                 :          0 :                 rte_flow_error_set(error, EINVAL,
    1166                 :            :                                    RTE_FLOW_ERROR_TYPE_ACTION_NUM,
    1167                 :            :                                    NULL, "NULL action.");
    1168                 :          0 :                 return -rte_errno;
    1169                 :            :         }
    1170                 :            : 
    1171         [ #  # ]:          0 :         if (!attr) {
    1172                 :          0 :                 rte_flow_error_set(error, EINVAL,
    1173                 :            :                                    RTE_FLOW_ERROR_TYPE_ATTR,
    1174                 :            :                                    NULL, "NULL attribute.");
    1175                 :          0 :                 return -rte_errno;
    1176                 :            :         }
    1177                 :            : 
    1178                 :            :         /* The first not void item should be e-tag. */
    1179                 :            :         item = next_no_void_pattern(pattern, NULL);
    1180         [ #  # ]:          0 :         if (item->type != RTE_FLOW_ITEM_TYPE_E_TAG) {
    1181                 :            :                 memset(filter, 0, sizeof(struct txgbe_l2_tunnel_conf));
    1182                 :          0 :                 rte_flow_error_set(error, EINVAL,
    1183                 :            :                         RTE_FLOW_ERROR_TYPE_ITEM,
    1184                 :            :                         item, "Not supported by L2 tunnel filter");
    1185                 :          0 :                 return -rte_errno;
    1186                 :            :         }
    1187                 :            : 
    1188   [ #  #  #  # ]:          0 :         if (!item->spec || !item->mask) {
    1189                 :            :                 memset(filter, 0, sizeof(struct txgbe_l2_tunnel_conf));
    1190                 :          0 :                 rte_flow_error_set(error, EINVAL, RTE_FLOW_ERROR_TYPE_ITEM,
    1191                 :            :                         item, "Not supported by L2 tunnel filter");
    1192                 :          0 :                 return -rte_errno;
    1193                 :            :         }
    1194                 :            : 
    1195                 :            :         /*Not supported last point for range*/
    1196         [ #  # ]:          0 :         if (item->last) {
    1197                 :          0 :                 rte_flow_error_set(error, EINVAL,
    1198                 :            :                         RTE_FLOW_ERROR_TYPE_UNSPECIFIED,
    1199                 :            :                         item, "Not supported last point for range");
    1200                 :          0 :                 return -rte_errno;
    1201                 :            :         }
    1202                 :            : 
    1203                 :            :         e_tag_spec = item->spec;
    1204                 :            :         e_tag_mask = item->mask;
    1205                 :            : 
    1206                 :            :         /* Only care about GRP and E cid base. */
    1207         [ #  # ]:          0 :         if (e_tag_mask->epcp_edei_in_ecid_b ||
    1208         [ #  # ]:          0 :             e_tag_mask->in_ecid_e ||
    1209                 :          0 :             e_tag_mask->ecid_e ||
    1210         [ #  # ]:          0 :             e_tag_mask->rsvd_grp_ecid_b != rte_cpu_to_be_16(0x3FFF)) {
    1211                 :            :                 memset(filter, 0, sizeof(struct txgbe_l2_tunnel_conf));
    1212                 :          0 :                 rte_flow_error_set(error, EINVAL,
    1213                 :            :                         RTE_FLOW_ERROR_TYPE_ITEM,
    1214                 :            :                         item, "Not supported by L2 tunnel filter");
    1215                 :          0 :                 return -rte_errno;
    1216                 :            :         }
    1217                 :            : 
    1218                 :          0 :         filter->l2_tunnel_type = RTE_ETH_L2_TUNNEL_TYPE_E_TAG;
    1219                 :            :         /**
    1220                 :            :          * grp and e_cid_base are bit fields and only use 14 bits.
    1221                 :            :          * e-tag id is taken as little endian by HW.
    1222                 :            :          */
    1223         [ #  # ]:          0 :         filter->tunnel_id = rte_be_to_cpu_16(e_tag_spec->rsvd_grp_ecid_b);
    1224                 :            : 
    1225                 :            :         /* check if the next not void item is END */
    1226                 :            :         item = next_no_void_pattern(pattern, item);
    1227         [ #  # ]:          0 :         if (item->type != RTE_FLOW_ITEM_TYPE_END) {
    1228                 :            :                 memset(filter, 0, sizeof(struct txgbe_l2_tunnel_conf));
    1229                 :          0 :                 rte_flow_error_set(error, EINVAL,
    1230                 :            :                         RTE_FLOW_ERROR_TYPE_ITEM,
    1231                 :            :                         item, "Not supported by L2 tunnel filter");
    1232                 :          0 :                 return -rte_errno;
    1233                 :            :         }
    1234                 :            : 
    1235                 :            :         /* parse attr */
    1236                 :            :         /* must be input direction */
    1237         [ #  # ]:          0 :         if (!attr->ingress) {
    1238                 :            :                 memset(filter, 0, sizeof(struct txgbe_l2_tunnel_conf));
    1239                 :          0 :                 rte_flow_error_set(error, EINVAL,
    1240                 :            :                         RTE_FLOW_ERROR_TYPE_ATTR_INGRESS,
    1241                 :            :                         attr, "Only support ingress.");
    1242                 :          0 :                 return -rte_errno;
    1243                 :            :         }
    1244                 :            : 
    1245                 :            :         /* not supported */
    1246         [ #  # ]:          0 :         if (attr->egress) {
    1247                 :            :                 memset(filter, 0, sizeof(struct txgbe_l2_tunnel_conf));
    1248                 :          0 :                 rte_flow_error_set(error, EINVAL,
    1249                 :            :                         RTE_FLOW_ERROR_TYPE_ATTR_EGRESS,
    1250                 :            :                         attr, "Not support egress.");
    1251                 :          0 :                 return -rte_errno;
    1252                 :            :         }
    1253                 :            : 
    1254                 :            :         /* not supported */
    1255         [ #  # ]:          0 :         if (attr->transfer) {
    1256                 :            :                 memset(filter, 0, sizeof(struct txgbe_l2_tunnel_conf));
    1257                 :          0 :                 rte_flow_error_set(error, EINVAL,
    1258                 :            :                         RTE_FLOW_ERROR_TYPE_ATTR_TRANSFER,
    1259                 :            :                         attr, "No support for transfer.");
    1260                 :          0 :                 return -rte_errno;
    1261                 :            :         }
    1262                 :            : 
    1263                 :            :         /* not supported */
    1264         [ #  # ]:          0 :         if (attr->priority) {
    1265                 :            :                 memset(filter, 0, sizeof(struct txgbe_l2_tunnel_conf));
    1266                 :          0 :                 rte_flow_error_set(error, EINVAL,
    1267                 :            :                         RTE_FLOW_ERROR_TYPE_ATTR_PRIORITY,
    1268                 :            :                         attr, "Not support priority.");
    1269                 :          0 :                 return -rte_errno;
    1270                 :            :         }
    1271                 :            : 
    1272                 :            :         /* check if the first not void action is VF or PF. */
    1273                 :            :         act = next_no_void_action(actions, NULL);
    1274         [ #  # ]:          0 :         if (act->type != RTE_FLOW_ACTION_TYPE_VF &&
    1275                 :            :                         act->type != RTE_FLOW_ACTION_TYPE_PF) {
    1276                 :            :                 memset(filter, 0, sizeof(struct txgbe_l2_tunnel_conf));
    1277                 :          0 :                 rte_flow_error_set(error, EINVAL,
    1278                 :            :                         RTE_FLOW_ERROR_TYPE_ACTION,
    1279                 :            :                         act, "Not supported action.");
    1280                 :          0 :                 return -rte_errno;
    1281                 :            :         }
    1282                 :            : 
    1283         [ #  # ]:          0 :         if (act->type == RTE_FLOW_ACTION_TYPE_VF) {
    1284                 :          0 :                 act_vf = (const struct rte_flow_action_vf *)act->conf;
    1285                 :          0 :                 filter->pool = act_vf->id;
    1286                 :            :         } else {
    1287                 :          0 :                 filter->pool = pci_dev->max_vfs;
    1288                 :            :         }
    1289                 :            : 
    1290                 :            :         /* check if the next not void item is END */
    1291                 :            :         act = next_no_void_action(actions, act);
    1292         [ #  # ]:          0 :         if (act->type != RTE_FLOW_ACTION_TYPE_END) {
    1293                 :            :                 memset(filter, 0, sizeof(struct txgbe_l2_tunnel_conf));
    1294                 :          0 :                 rte_flow_error_set(error, EINVAL,
    1295                 :            :                         RTE_FLOW_ERROR_TYPE_ACTION,
    1296                 :            :                         act, "Not supported action.");
    1297                 :          0 :                 return -rte_errno;
    1298                 :            :         }
    1299                 :            : 
    1300                 :            :         return 0;
    1301                 :            : }
    1302                 :            : 
    1303                 :            : static int
    1304                 :            : txgbe_parse_l2_tn_filter(struct rte_eth_dev *dev,
    1305                 :            :                         const struct rte_flow_attr *attr,
    1306                 :            :                         const struct rte_flow_item pattern[],
    1307                 :            :                         const struct rte_flow_action actions[],
    1308                 :            :                         struct txgbe_l2_tunnel_conf *l2_tn_filter,
    1309                 :            :                         struct rte_flow_error *error)
    1310                 :            : {
    1311                 :            :         int ret = 0;
    1312                 :          0 :         struct rte_pci_device *pci_dev = RTE_ETH_DEV_TO_PCI(dev);
    1313                 :            :         uint16_t vf_num;
    1314                 :            : 
    1315                 :          0 :         ret = cons_parse_l2_tn_filter(dev, attr, pattern,
    1316                 :            :                                 actions, l2_tn_filter, error);
    1317                 :            : 
    1318                 :          0 :         vf_num = pci_dev->max_vfs;
    1319                 :            : 
    1320   [ #  #  #  # ]:          0 :         if (l2_tn_filter->pool > vf_num)
    1321                 :          0 :                 return -rte_errno;
    1322                 :            : 
    1323                 :            :         return ret;
    1324                 :            : }
    1325                 :            : 
    1326                 :            : /* Parse to get the attr and action info of flow director rule. */
    1327                 :            : static int
    1328                 :          0 : txgbe_parse_fdir_act_attr(const struct rte_flow_attr *attr,
    1329                 :            :                           const struct rte_flow_action actions[],
    1330                 :            :                           struct txgbe_fdir_rule *rule,
    1331                 :            :                           struct rte_flow_error *error)
    1332                 :            : {
    1333                 :            :         const struct rte_flow_action *act;
    1334                 :            :         const struct rte_flow_action_queue *act_q;
    1335                 :            :         const struct rte_flow_action_mark *mark;
    1336                 :            : 
    1337                 :            :         /* parse attr */
    1338                 :            :         /* must be input direction */
    1339         [ #  # ]:          0 :         if (!attr->ingress) {
    1340                 :            :                 memset(rule, 0, sizeof(struct txgbe_fdir_rule));
    1341                 :          0 :                 rte_flow_error_set(error, EINVAL,
    1342                 :            :                         RTE_FLOW_ERROR_TYPE_ATTR_INGRESS,
    1343                 :            :                         attr, "Only support ingress.");
    1344                 :          0 :                 return -rte_errno;
    1345                 :            :         }
    1346                 :            : 
    1347                 :            :         /* not supported */
    1348         [ #  # ]:          0 :         if (attr->egress) {
    1349                 :            :                 memset(rule, 0, sizeof(struct txgbe_fdir_rule));
    1350                 :          0 :                 rte_flow_error_set(error, EINVAL,
    1351                 :            :                         RTE_FLOW_ERROR_TYPE_ATTR_EGRESS,
    1352                 :            :                         attr, "Not support egress.");
    1353                 :          0 :                 return -rte_errno;
    1354                 :            :         }
    1355                 :            : 
    1356                 :            :         /* not supported */
    1357         [ #  # ]:          0 :         if (attr->transfer) {
    1358                 :            :                 memset(rule, 0, sizeof(struct txgbe_fdir_rule));
    1359                 :          0 :                 rte_flow_error_set(error, EINVAL,
    1360                 :            :                         RTE_FLOW_ERROR_TYPE_ATTR_TRANSFER,
    1361                 :            :                         attr, "No support for transfer.");
    1362                 :          0 :                 return -rte_errno;
    1363                 :            :         }
    1364                 :            : 
    1365                 :            :         /* not supported */
    1366         [ #  # ]:          0 :         if (attr->priority) {
    1367                 :            :                 memset(rule, 0, sizeof(struct txgbe_fdir_rule));
    1368                 :          0 :                 rte_flow_error_set(error, EINVAL,
    1369                 :            :                         RTE_FLOW_ERROR_TYPE_ATTR_PRIORITY,
    1370                 :            :                         attr, "Not support priority.");
    1371                 :          0 :                 return -rte_errno;
    1372                 :            :         }
    1373                 :            : 
    1374                 :            :         /* check if the first not void action is QUEUE or DROP. */
    1375                 :            :         act = next_no_void_action(actions, NULL);
    1376         [ #  # ]:          0 :         if (act->type != RTE_FLOW_ACTION_TYPE_QUEUE &&
    1377                 :            :             act->type != RTE_FLOW_ACTION_TYPE_DROP) {
    1378                 :            :                 memset(rule, 0, sizeof(struct txgbe_fdir_rule));
    1379                 :          0 :                 rte_flow_error_set(error, EINVAL,
    1380                 :            :                         RTE_FLOW_ERROR_TYPE_ACTION,
    1381                 :            :                         act, "Not supported action.");
    1382                 :          0 :                 return -rte_errno;
    1383                 :            :         }
    1384                 :            : 
    1385         [ #  # ]:          0 :         if (act->type == RTE_FLOW_ACTION_TYPE_QUEUE) {
    1386                 :          0 :                 act_q = (const struct rte_flow_action_queue *)act->conf;
    1387                 :          0 :                 rule->queue = act_q->index;
    1388                 :            :         } else { /* drop */
    1389                 :            :                 /* signature mode does not support drop action. */
    1390         [ #  # ]:          0 :                 if (rule->mode == RTE_FDIR_MODE_SIGNATURE) {
    1391                 :            :                         memset(rule, 0, sizeof(struct txgbe_fdir_rule));
    1392                 :          0 :                         rte_flow_error_set(error, EINVAL,
    1393                 :            :                                 RTE_FLOW_ERROR_TYPE_ACTION,
    1394                 :            :                                 act, "Not supported action.");
    1395                 :          0 :                         return -rte_errno;
    1396                 :            :                 }
    1397                 :          0 :                 rule->fdirflags = TXGBE_FDIRPICMD_DROP;
    1398                 :            :         }
    1399                 :            : 
    1400                 :            :         /* check if the next not void item is MARK */
    1401                 :            :         act = next_no_void_action(actions, act);
    1402         [ #  # ]:          0 :         if (act->type != RTE_FLOW_ACTION_TYPE_MARK &&
    1403                 :            :                 act->type != RTE_FLOW_ACTION_TYPE_END) {
    1404                 :            :                 memset(rule, 0, sizeof(struct txgbe_fdir_rule));
    1405                 :          0 :                 rte_flow_error_set(error, EINVAL,
    1406                 :            :                         RTE_FLOW_ERROR_TYPE_ACTION,
    1407                 :            :                         act, "Not supported action.");
    1408                 :          0 :                 return -rte_errno;
    1409                 :            :         }
    1410                 :            : 
    1411                 :          0 :         rule->soft_id = 0;
    1412                 :            : 
    1413         [ #  # ]:          0 :         if (act->type == RTE_FLOW_ACTION_TYPE_MARK) {
    1414                 :          0 :                 mark = (const struct rte_flow_action_mark *)act->conf;
    1415                 :          0 :                 rule->soft_id = mark->id;
    1416                 :            :                 act = next_no_void_action(actions, act);
    1417                 :            :         }
    1418                 :            : 
    1419                 :            :         /* check if the next not void item is END */
    1420         [ #  # ]:          0 :         if (act->type != RTE_FLOW_ACTION_TYPE_END) {
    1421                 :            :                 memset(rule, 0, sizeof(struct txgbe_fdir_rule));
    1422                 :          0 :                 rte_flow_error_set(error, EINVAL,
    1423                 :            :                         RTE_FLOW_ERROR_TYPE_ACTION,
    1424                 :            :                         act, "Not supported action.");
    1425                 :          0 :                 return -rte_errno;
    1426                 :            :         }
    1427                 :            : 
    1428                 :            :         return 0;
    1429                 :            : }
    1430                 :            : 
    1431                 :            : /* search next no void pattern and skip fuzzy */
    1432                 :            : static inline
    1433                 :            : const struct rte_flow_item *next_no_fuzzy_pattern(
    1434                 :            :                 const struct rte_flow_item pattern[],
    1435                 :            :                 const struct rte_flow_item *cur)
    1436                 :            : {
    1437                 :            :         const struct rte_flow_item *next =
    1438                 :            :                 next_no_void_pattern(pattern, cur);
    1439                 :            :         while (1) {
    1440   [ #  #  #  #  :          0 :                 if (next->type != RTE_FLOW_ITEM_TYPE_FUZZY)
          #  #  #  #  #  
          #  #  #  #  #  
                   #  # ]
    1441                 :            :                         return next;
    1442                 :            :                 next = next_no_void_pattern(pattern, next);
    1443                 :            :         }
    1444                 :            : }
    1445                 :            : 
    1446                 :          0 : static inline uint8_t signature_match(const struct rte_flow_item pattern[])
    1447                 :            : {
    1448                 :            :         const struct rte_flow_item_fuzzy *spec, *last, *mask;
    1449                 :            :         const struct rte_flow_item *item;
    1450                 :            :         uint32_t sh, lh, mh;
    1451                 :            :         int i = 0;
    1452                 :            : 
    1453                 :            :         while (1) {
    1454                 :          0 :                 item = pattern + i;
    1455         [ #  # ]:          0 :                 if (item->type == RTE_FLOW_ITEM_TYPE_END)
    1456                 :            :                         break;
    1457                 :            : 
    1458         [ #  # ]:          0 :                 if (item->type == RTE_FLOW_ITEM_TYPE_FUZZY) {
    1459                 :          0 :                         spec = item->spec;
    1460                 :          0 :                         last = item->last;
    1461                 :          0 :                         mask = item->mask;
    1462                 :            : 
    1463         [ #  # ]:          0 :                         if (!spec || !mask)
    1464                 :            :                                 return 0;
    1465                 :            : 
    1466                 :          0 :                         sh = spec->thresh;
    1467                 :            : 
    1468         [ #  # ]:          0 :                         if (!last)
    1469                 :            :                                 lh = sh;
    1470                 :            :                         else
    1471                 :          0 :                                 lh = last->thresh;
    1472                 :            : 
    1473                 :          0 :                         mh = mask->thresh;
    1474                 :          0 :                         sh = sh & mh;
    1475                 :          0 :                         lh = lh & mh;
    1476                 :            : 
    1477         [ #  # ]:          0 :                         if (!sh || sh > lh)
    1478                 :            :                                 return 0;
    1479                 :            : 
    1480                 :          0 :                         return 1;
    1481                 :            :                 }
    1482                 :            : 
    1483                 :          0 :                 i++;
    1484                 :            :         }
    1485                 :            : 
    1486                 :            :         return 0;
    1487                 :            : }
    1488                 :            : 
    1489                 :            : /**
    1490                 :            :  * Parse the rule to see if it is a IP or MAC VLAN flow director rule.
    1491                 :            :  * And get the flow director filter info BTW.
    1492                 :            :  * UDP/TCP/SCTP PATTERN:
    1493                 :            :  * The first not void item can be ETH or IPV4 or IPV6
    1494                 :            :  * The second not void item must be IPV4 or IPV6 if the first one is ETH.
    1495                 :            :  * The next not void item could be UDP or TCP or SCTP (optional)
    1496                 :            :  * The next not void item could be RAW (for flexbyte, optional)
    1497                 :            :  * The next not void item must be END.
    1498                 :            :  * A Fuzzy Match pattern can appear at any place before END.
    1499                 :            :  * Fuzzy Match is optional for IPV4 but is required for IPV6
    1500                 :            :  * MAC VLAN PATTERN:
    1501                 :            :  * The first not void item must be ETH.
    1502                 :            :  * The second not void item must be MAC VLAN.
    1503                 :            :  * The next not void item must be END.
    1504                 :            :  * ACTION:
    1505                 :            :  * The first not void action should be QUEUE or DROP.
    1506                 :            :  * The second not void optional action should be MARK,
    1507                 :            :  * mark_id is a uint32_t number.
    1508                 :            :  * The next not void action should be END.
    1509                 :            :  * UDP/TCP/SCTP pattern example:
    1510                 :            :  * ITEM         Spec                    Mask
    1511                 :            :  * ETH          NULL                    NULL
    1512                 :            :  * IPV4         src_addr 192.168.1.20   0xFFFFFFFF
    1513                 :            :  *              dst_addr 192.167.3.50   0xFFFFFFFF
    1514                 :            :  * UDP/TCP/SCTP src_port        80      0xFFFF
    1515                 :            :  *              dst_port        80      0xFFFF
    1516                 :            :  * FLEX relative        0       0x1
    1517                 :            :  *              search          0       0x1
    1518                 :            :  *              reserved        0       0
    1519                 :            :  *              offset          12      0xFFFFFFFF
    1520                 :            :  *              limit           0       0xFFFF
    1521                 :            :  *              length          2       0xFFFF
    1522                 :            :  *              pattern[0]      0x86    0xFF
    1523                 :            :  *              pattern[1]      0xDD    0xFF
    1524                 :            :  * END
    1525                 :            :  * MAC VLAN pattern example:
    1526                 :            :  * ITEM         Spec                    Mask
    1527                 :            :  * ETH          dst_addr
    1528                 :            :                 {0xAC, 0x7B, 0xA1,      {0xFF, 0xFF, 0xFF,
    1529                 :            :                 0x2C, 0x6D, 0x36}       0xFF, 0xFF, 0xFF}
    1530                 :            :  * MAC VLAN     tci     0x2016          0xEFFF
    1531                 :            :  * END
    1532                 :            :  * Other members in mask and spec should set to 0x00.
    1533                 :            :  * Item->last should be NULL.
    1534                 :            :  */
    1535                 :            : static int
    1536                 :          0 : txgbe_parse_fdir_filter_normal(struct rte_eth_dev *dev __rte_unused,
    1537                 :            :                                const struct rte_flow_attr *attr,
    1538                 :            :                                const struct rte_flow_item pattern[],
    1539                 :            :                                const struct rte_flow_action actions[],
    1540                 :            :                                struct txgbe_fdir_rule *rule,
    1541                 :            :                                struct rte_flow_error *error)
    1542                 :            : {
    1543                 :            :         const struct rte_flow_item *item;
    1544                 :            :         const struct rte_flow_item_eth *eth_mask;
    1545                 :            :         const struct rte_flow_item_ipv4 *ipv4_spec;
    1546                 :            :         const struct rte_flow_item_ipv4 *ipv4_mask;
    1547                 :            :         const struct rte_flow_item_ipv6 *ipv6_spec;
    1548                 :            :         const struct rte_flow_item_ipv6 *ipv6_mask;
    1549                 :            :         const struct rte_flow_item_tcp *tcp_spec;
    1550                 :            :         const struct rte_flow_item_tcp *tcp_mask;
    1551                 :            :         const struct rte_flow_item_udp *udp_spec;
    1552                 :            :         const struct rte_flow_item_udp *udp_mask;
    1553                 :            :         const struct rte_flow_item_sctp *sctp_spec;
    1554                 :            :         const struct rte_flow_item_sctp *sctp_mask;
    1555                 :            :         const struct rte_flow_item_raw *raw_mask;
    1556                 :            :         const struct rte_flow_item_raw *raw_spec;
    1557                 :            :         u32 ptype = 0;
    1558                 :            :         uint8_t j;
    1559                 :            : 
    1560         [ #  # ]:          0 :         if (!pattern) {
    1561                 :          0 :                 rte_flow_error_set(error, EINVAL,
    1562                 :            :                         RTE_FLOW_ERROR_TYPE_ITEM_NUM,
    1563                 :            :                         NULL, "NULL pattern.");
    1564                 :          0 :                 return -rte_errno;
    1565                 :            :         }
    1566                 :            : 
    1567         [ #  # ]:          0 :         if (!actions) {
    1568                 :          0 :                 rte_flow_error_set(error, EINVAL,
    1569                 :            :                                    RTE_FLOW_ERROR_TYPE_ACTION_NUM,
    1570                 :            :                                    NULL, "NULL action.");
    1571                 :          0 :                 return -rte_errno;
    1572                 :            :         }
    1573                 :            : 
    1574         [ #  # ]:          0 :         if (!attr) {
    1575                 :          0 :                 rte_flow_error_set(error, EINVAL,
    1576                 :            :                                    RTE_FLOW_ERROR_TYPE_ATTR,
    1577                 :            :                                    NULL, "NULL attribute.");
    1578                 :          0 :                 return -rte_errno;
    1579                 :            :         }
    1580                 :            : 
    1581                 :            :         /**
    1582                 :            :          * Some fields may not be provided. Set spec to 0 and mask to default
    1583                 :            :          * value. So, we need not do anything for the not provided fields later.
    1584                 :            :          */
    1585                 :            :         memset(rule, 0, sizeof(struct txgbe_fdir_rule));
    1586                 :            :         memset(&rule->mask, 0, sizeof(struct txgbe_hw_fdir_mask));
    1587                 :            : 
    1588                 :            :         /**
    1589                 :            :          * The first not void item should be
    1590                 :            :          * MAC or IPv4 or TCP or UDP or SCTP.
    1591                 :            :          */
    1592                 :            :         item = next_no_fuzzy_pattern(pattern, NULL);
    1593         [ #  # ]:          0 :         if (item->type != RTE_FLOW_ITEM_TYPE_ETH &&
    1594         [ #  # ]:          0 :             item->type != RTE_FLOW_ITEM_TYPE_IPV4 &&
    1595         [ #  # ]:          0 :             item->type != RTE_FLOW_ITEM_TYPE_IPV6 &&
    1596         [ #  # ]:          0 :             item->type != RTE_FLOW_ITEM_TYPE_TCP &&
    1597         [ #  # ]:          0 :             item->type != RTE_FLOW_ITEM_TYPE_UDP &&
    1598                 :            :             item->type != RTE_FLOW_ITEM_TYPE_SCTP) {
    1599                 :            :                 memset(rule, 0, sizeof(struct txgbe_fdir_rule));
    1600                 :          0 :                 rte_flow_error_set(error, EINVAL,
    1601                 :            :                         RTE_FLOW_ERROR_TYPE_ITEM,
    1602                 :            :                         item, "Not supported by fdir filter");
    1603                 :          0 :                 return -rte_errno;
    1604                 :            :         }
    1605                 :            : 
    1606         [ #  # ]:          0 :         if (signature_match(pattern))
    1607                 :          0 :                 rule->mode = RTE_FDIR_MODE_SIGNATURE;
    1608                 :            :         else
    1609                 :          0 :                 rule->mode = RTE_FDIR_MODE_PERFECT;
    1610                 :            : 
    1611                 :            :         /*Not supported last point for range*/
    1612         [ #  # ]:          0 :         if (item->last) {
    1613                 :          0 :                 rte_flow_error_set(error, EINVAL,
    1614                 :            :                         RTE_FLOW_ERROR_TYPE_UNSPECIFIED,
    1615                 :            :                         item, "Not supported last point for range");
    1616                 :          0 :                 return -rte_errno;
    1617                 :            :         }
    1618                 :            : 
    1619                 :            :         /* Get the MAC info. */
    1620         [ #  # ]:          0 :         if (item->type == RTE_FLOW_ITEM_TYPE_ETH) {
    1621                 :            :                 /**
    1622                 :            :                  * Only support vlan and dst MAC address,
    1623                 :            :                  * others should be masked.
    1624                 :            :                  */
    1625   [ #  #  #  # ]:          0 :                 if (item->spec && !item->mask) {
    1626                 :            :                         memset(rule, 0, sizeof(struct txgbe_fdir_rule));
    1627                 :          0 :                         rte_flow_error_set(error, EINVAL,
    1628                 :            :                                 RTE_FLOW_ERROR_TYPE_ITEM,
    1629                 :            :                                 item, "Not supported by fdir filter");
    1630                 :          0 :                         return -rte_errno;
    1631                 :            :                 }
    1632                 :            : 
    1633         [ #  # ]:          0 :                 if (item->mask) {
    1634                 :          0 :                         rule->b_mask = TRUE;
    1635                 :            :                         eth_mask = item->mask;
    1636                 :            : 
    1637                 :            :                         /* Ether type should be masked. */
    1638         [ #  # ]:          0 :                         if (eth_mask->hdr.ether_type ||
    1639         [ #  # ]:          0 :                             rule->mode == RTE_FDIR_MODE_SIGNATURE) {
    1640                 :            :                                 memset(rule, 0, sizeof(struct txgbe_fdir_rule));
    1641                 :          0 :                                 rte_flow_error_set(error, EINVAL,
    1642                 :            :                                         RTE_FLOW_ERROR_TYPE_ITEM,
    1643                 :            :                                         item, "Not supported by fdir filter");
    1644                 :          0 :                                 return -rte_errno;
    1645                 :            :                         }
    1646                 :            : 
    1647                 :            :                         /* If ethernet has meaning, it means MAC VLAN mode. */
    1648                 :          0 :                         rule->mode = RTE_FDIR_MODE_PERFECT_MAC_VLAN;
    1649                 :            : 
    1650                 :            :                         /**
    1651                 :            :                          * src MAC address must be masked,
    1652                 :            :                          * and don't support dst MAC address mask.
    1653                 :            :                          */
    1654         [ #  # ]:          0 :                         for (j = 0; j < RTE_ETHER_ADDR_LEN; j++) {
    1655         [ #  # ]:          0 :                                 if (eth_mask->hdr.src_addr.addr_bytes[j] ||
    1656         [ #  # ]:          0 :                                         eth_mask->hdr.dst_addr.addr_bytes[j] != 0xFF) {
    1657                 :            :                                         memset(rule, 0,
    1658                 :            :                                         sizeof(struct txgbe_fdir_rule));
    1659                 :          0 :                                         rte_flow_error_set(error, EINVAL,
    1660                 :            :                                         RTE_FLOW_ERROR_TYPE_ITEM,
    1661                 :            :                                         item, "Not supported by fdir filter");
    1662                 :          0 :                                         return -rte_errno;
    1663                 :            :                                 }
    1664                 :            :                         }
    1665                 :            : 
    1666                 :            :                         /* When no VLAN, considered as full mask. */
    1667                 :          0 :                         rule->mask.vlan_tci_mask = rte_cpu_to_be_16(0xEFFF);
    1668                 :            :                 }
    1669                 :            :                 /*** If both spec and mask are item,
    1670                 :            :                  * it means don't care about ETH.
    1671                 :            :                  * Do nothing.
    1672                 :            :                  */
    1673                 :            : 
    1674                 :            :                 /**
    1675                 :            :                  * Check if the next not void item is vlan or ipv4.
    1676                 :            :                  * IPv6 is not supported.
    1677                 :            :                  */
    1678                 :            :                 item = next_no_fuzzy_pattern(pattern, item);
    1679         [ #  # ]:          0 :                 if (rule->mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN) {
    1680         [ #  # ]:          0 :                         if (item->type != RTE_FLOW_ITEM_TYPE_VLAN) {
    1681                 :            :                                 memset(rule, 0, sizeof(struct txgbe_fdir_rule));
    1682                 :          0 :                                 rte_flow_error_set(error, EINVAL,
    1683                 :            :                                         RTE_FLOW_ERROR_TYPE_ITEM,
    1684                 :            :                                         item, "Not supported by fdir filter");
    1685                 :          0 :                                 return -rte_errno;
    1686                 :            :                         }
    1687                 :            :                 } else {
    1688         [ #  # ]:          0 :                         if (item->type != RTE_FLOW_ITEM_TYPE_IPV4 &&
    1689                 :            :                                         item->type != RTE_FLOW_ITEM_TYPE_VLAN) {
    1690                 :            :                                 memset(rule, 0, sizeof(struct txgbe_fdir_rule));
    1691                 :          0 :                                 rte_flow_error_set(error, EINVAL,
    1692                 :            :                                         RTE_FLOW_ERROR_TYPE_ITEM,
    1693                 :            :                                         item, "Not supported by fdir filter");
    1694                 :          0 :                                 return -rte_errno;
    1695                 :            :                         }
    1696                 :            :                 }
    1697                 :            :         }
    1698                 :            : 
    1699                 :            :         /* Get the IPV4 info. */
    1700         [ #  # ]:          0 :         if (item->type == RTE_FLOW_ITEM_TYPE_IPV4) {
    1701                 :            :                 /**
    1702                 :            :                  * Set the flow type even if there's no content
    1703                 :            :                  * as we must have a flow type.
    1704                 :            :                  */
    1705                 :            :                 rule->input.flow_type = TXGBE_ATR_FLOW_TYPE_IPV4;
    1706                 :          0 :                 ptype = txgbe_ptype_table[TXGBE_PT_IPV4];
    1707                 :            :                 /*Not supported last point for range*/
    1708         [ #  # ]:          0 :                 if (item->last) {
    1709                 :          0 :                         rte_flow_error_set(error, EINVAL,
    1710                 :            :                                 RTE_FLOW_ERROR_TYPE_UNSPECIFIED,
    1711                 :            :                                 item, "Not supported last point for range");
    1712                 :          0 :                         return -rte_errno;
    1713                 :            :                 }
    1714                 :            :                 /**
    1715                 :            :                  * Only care about src & dst addresses,
    1716                 :            :                  * others should be masked.
    1717                 :            :                  */
    1718         [ #  # ]:          0 :                 if (!item->mask) {
    1719                 :            :                         memset(rule, 0, sizeof(struct txgbe_fdir_rule));
    1720                 :          0 :                         rte_flow_error_set(error, EINVAL,
    1721                 :            :                                 RTE_FLOW_ERROR_TYPE_ITEM,
    1722                 :            :                                 item, "Not supported by fdir filter");
    1723                 :          0 :                         return -rte_errno;
    1724                 :            :                 }
    1725                 :          0 :                 rule->b_mask = TRUE;
    1726                 :            :                 ipv4_mask = item->mask;
    1727         [ #  # ]:          0 :                 if (ipv4_mask->hdr.version_ihl ||
    1728                 :          0 :                     ipv4_mask->hdr.type_of_service ||
    1729         [ #  # ]:          0 :                     ipv4_mask->hdr.total_length ||
    1730         [ #  # ]:          0 :                     ipv4_mask->hdr.packet_id ||
    1731         [ #  # ]:          0 :                     ipv4_mask->hdr.fragment_offset ||
    1732         [ #  # ]:          0 :                     ipv4_mask->hdr.time_to_live ||
    1733                 :          0 :                     ipv4_mask->hdr.next_proto_id ||
    1734         [ #  # ]:          0 :                     ipv4_mask->hdr.hdr_checksum) {
    1735                 :            :                         memset(rule, 0, sizeof(struct txgbe_fdir_rule));
    1736                 :          0 :                         rte_flow_error_set(error, EINVAL,
    1737                 :            :                                 RTE_FLOW_ERROR_TYPE_ITEM,
    1738                 :            :                                 item, "Not supported by fdir filter");
    1739                 :          0 :                         return -rte_errno;
    1740                 :            :                 }
    1741                 :          0 :                 rule->mask.dst_ipv4_mask = ipv4_mask->hdr.dst_addr;
    1742                 :          0 :                 rule->mask.src_ipv4_mask = ipv4_mask->hdr.src_addr;
    1743                 :            : 
    1744         [ #  # ]:          0 :                 if (item->spec) {
    1745                 :          0 :                         rule->b_spec = TRUE;
    1746                 :            :                         ipv4_spec = item->spec;
    1747                 :          0 :                         rule->input.dst_ip[0] =
    1748                 :          0 :                                 ipv4_spec->hdr.dst_addr;
    1749                 :          0 :                         rule->input.src_ip[0] =
    1750                 :          0 :                                 ipv4_spec->hdr.src_addr;
    1751                 :            :                 }
    1752                 :            : 
    1753                 :            :                 /**
    1754                 :            :                  * Check if the next not void item is
    1755                 :            :                  * TCP or UDP or SCTP or END.
    1756                 :            :                  */
    1757                 :            :                 item = next_no_fuzzy_pattern(pattern, item);
    1758                 :          0 :                 if (item->type != RTE_FLOW_ITEM_TYPE_TCP &&
    1759                 :            :                     item->type != RTE_FLOW_ITEM_TYPE_UDP &&
    1760         [ #  # ]:          0 :                     item->type != RTE_FLOW_ITEM_TYPE_SCTP &&
    1761         [ #  # ]:          0 :                     item->type != RTE_FLOW_ITEM_TYPE_END &&
    1762                 :            :                     item->type != RTE_FLOW_ITEM_TYPE_RAW) {
    1763                 :            :                         memset(rule, 0, sizeof(struct txgbe_fdir_rule));
    1764                 :          0 :                         rte_flow_error_set(error, EINVAL,
    1765                 :            :                                 RTE_FLOW_ERROR_TYPE_ITEM,
    1766                 :            :                                 item, "Not supported by fdir filter");
    1767                 :          0 :                         return -rte_errno;
    1768                 :            :                 }
    1769                 :            :         }
    1770                 :            : 
    1771                 :            :         /* Get the IPV6 info. */
    1772         [ #  # ]:          0 :         if (item->type == RTE_FLOW_ITEM_TYPE_IPV6) {
    1773                 :            :                 /**
    1774                 :            :                  * Set the flow type even if there's no content
    1775                 :            :                  * as we must have a flow type.
    1776                 :            :                  */
    1777                 :          0 :                 rule->input.flow_type = TXGBE_ATR_FLOW_TYPE_IPV6;
    1778                 :          0 :                 ptype = txgbe_ptype_table[TXGBE_PT_IPV6];
    1779                 :            : 
    1780                 :            :                 /**
    1781                 :            :                  * 1. must signature match
    1782                 :            :                  * 2. not support last
    1783                 :            :                  * 3. mask must not null
    1784                 :            :                  */
    1785         [ #  # ]:          0 :                 if (rule->mode != RTE_FDIR_MODE_SIGNATURE ||
    1786         [ #  # ]:          0 :                     item->last ||
    1787         [ #  # ]:          0 :                     !item->mask) {
    1788                 :            :                         memset(rule, 0, sizeof(struct txgbe_fdir_rule));
    1789                 :          0 :                         rte_flow_error_set(error, EINVAL,
    1790                 :            :                                 RTE_FLOW_ERROR_TYPE_UNSPECIFIED,
    1791                 :            :                                 item, "Not supported last point for range");
    1792                 :          0 :                         return -rte_errno;
    1793                 :            :                 }
    1794                 :            : 
    1795                 :          0 :                 rule->b_mask = TRUE;
    1796                 :            :                 ipv6_mask = item->mask;
    1797         [ #  # ]:          0 :                 if (ipv6_mask->hdr.vtc_flow ||
    1798                 :            :                     ipv6_mask->hdr.payload_len ||
    1799         [ #  # ]:          0 :                     ipv6_mask->hdr.proto ||
    1800                 :            :                     ipv6_mask->hdr.hop_limits) {
    1801                 :            :                         memset(rule, 0, sizeof(struct txgbe_fdir_rule));
    1802                 :          0 :                         rte_flow_error_set(error, EINVAL,
    1803                 :            :                                 RTE_FLOW_ERROR_TYPE_ITEM,
    1804                 :            :                                 item, "Not supported by fdir filter");
    1805                 :          0 :                         return -rte_errno;
    1806                 :            :                 }
    1807                 :            : 
    1808                 :            :                 /* check src addr mask */
    1809         [ #  # ]:          0 :                 for (j = 0; j < 16; j++) {
    1810         [ #  # ]:          0 :                         if (ipv6_mask->hdr.src_addr.a[j] == UINT8_MAX) {
    1811                 :          0 :                                 rule->mask.src_ipv6_mask |= 1 << j;
    1812         [ #  # ]:          0 :                         } else if (ipv6_mask->hdr.src_addr.a[j] != 0) {
    1813                 :            :                                 memset(rule, 0, sizeof(struct txgbe_fdir_rule));
    1814                 :          0 :                                 rte_flow_error_set(error, EINVAL,
    1815                 :            :                                         RTE_FLOW_ERROR_TYPE_ITEM,
    1816                 :            :                                         item, "Not supported by fdir filter");
    1817                 :          0 :                                 return -rte_errno;
    1818                 :            :                         }
    1819                 :            :                 }
    1820                 :            : 
    1821                 :            :                 /* check dst addr mask */
    1822         [ #  # ]:          0 :                 for (j = 0; j < 16; j++) {
    1823         [ #  # ]:          0 :                         if (ipv6_mask->hdr.dst_addr.a[j] == UINT8_MAX) {
    1824                 :          0 :                                 rule->mask.dst_ipv6_mask |= 1 << j;
    1825         [ #  # ]:          0 :                         } else if (ipv6_mask->hdr.dst_addr.a[j] != 0) {
    1826                 :            :                                 memset(rule, 0, sizeof(struct txgbe_fdir_rule));
    1827                 :          0 :                                 rte_flow_error_set(error, EINVAL,
    1828                 :            :                                         RTE_FLOW_ERROR_TYPE_ITEM,
    1829                 :            :                                         item, "Not supported by fdir filter");
    1830                 :          0 :                                 return -rte_errno;
    1831                 :            :                         }
    1832                 :            :                 }
    1833                 :            : 
    1834         [ #  # ]:          0 :                 if (item->spec) {
    1835                 :          0 :                         rule->b_spec = TRUE;
    1836                 :            :                         ipv6_spec = item->spec;
    1837                 :          0 :                         rte_memcpy(rule->input.src_ip,
    1838         [ #  # ]:          0 :                                    &ipv6_spec->hdr.src_addr, 16);
    1839                 :          0 :                         rte_memcpy(rule->input.dst_ip,
    1840         [ #  # ]:          0 :                                    &ipv6_spec->hdr.dst_addr, 16);
    1841                 :            :                 }
    1842                 :            : 
    1843                 :            :                 /**
    1844                 :            :                  * Check if the next not void item is
    1845                 :            :                  * TCP or UDP or SCTP or END.
    1846                 :            :                  */
    1847                 :            :                 item = next_no_fuzzy_pattern(pattern, item);
    1848                 :          0 :                 if (item->type != RTE_FLOW_ITEM_TYPE_TCP &&
    1849                 :            :                     item->type != RTE_FLOW_ITEM_TYPE_UDP &&
    1850         [ #  # ]:          0 :                     item->type != RTE_FLOW_ITEM_TYPE_SCTP &&
    1851         [ #  # ]:          0 :                     item->type != RTE_FLOW_ITEM_TYPE_END &&
    1852                 :            :                     item->type != RTE_FLOW_ITEM_TYPE_RAW) {
    1853                 :            :                         memset(rule, 0, sizeof(struct txgbe_fdir_rule));
    1854                 :          0 :                         rte_flow_error_set(error, EINVAL,
    1855                 :            :                                 RTE_FLOW_ERROR_TYPE_ITEM,
    1856                 :            :                                 item, "Not supported by fdir filter");
    1857                 :          0 :                         return -rte_errno;
    1858                 :            :                 }
    1859                 :            :         }
    1860                 :            : 
    1861                 :            :         /* Get the TCP info. */
    1862         [ #  # ]:          0 :         if (item->type == RTE_FLOW_ITEM_TYPE_TCP) {
    1863                 :            :                 /**
    1864                 :            :                  * Set the flow type even if there's no content
    1865                 :            :                  * as we must have a flow type.
    1866                 :            :                  */
    1867                 :          0 :                 rule->input.flow_type |= TXGBE_ATR_L4TYPE_TCP;
    1868         [ #  # ]:          0 :                 if (rule->input.flow_type & TXGBE_ATR_FLOW_TYPE_IPV6)
    1869                 :          0 :                         ptype = txgbe_ptype_table[TXGBE_PT_IPV6_TCP];
    1870                 :            :                 else
    1871                 :          0 :                         ptype = txgbe_ptype_table[TXGBE_PT_IPV4_TCP];
    1872                 :            :                 /*Not supported last point for range*/
    1873         [ #  # ]:          0 :                 if (item->last) {
    1874                 :          0 :                         rte_flow_error_set(error, EINVAL,
    1875                 :            :                                 RTE_FLOW_ERROR_TYPE_UNSPECIFIED,
    1876                 :            :                                 item, "Not supported last point for range");
    1877                 :          0 :                         return -rte_errno;
    1878                 :            :                 }
    1879                 :            :                 /**
    1880                 :            :                  * Only care about src & dst ports,
    1881                 :            :                  * others should be masked.
    1882                 :            :                  */
    1883         [ #  # ]:          0 :                 if (!item->mask) {
    1884                 :            :                         memset(rule, 0, sizeof(struct txgbe_fdir_rule));
    1885                 :          0 :                         rte_flow_error_set(error, EINVAL,
    1886                 :            :                                 RTE_FLOW_ERROR_TYPE_ITEM,
    1887                 :            :                                 item, "Not supported by fdir filter");
    1888                 :          0 :                         return -rte_errno;
    1889                 :            :                 }
    1890                 :          0 :                 rule->b_mask = TRUE;
    1891                 :            :                 tcp_mask = item->mask;
    1892         [ #  # ]:          0 :                 if (tcp_mask->hdr.sent_seq ||
    1893         [ #  # ]:          0 :                     tcp_mask->hdr.recv_ack ||
    1894         [ #  # ]:          0 :                     tcp_mask->hdr.data_off ||
    1895         [ #  # ]:          0 :                     tcp_mask->hdr.tcp_flags ||
    1896         [ #  # ]:          0 :                     tcp_mask->hdr.rx_win ||
    1897         [ #  # ]:          0 :                     tcp_mask->hdr.cksum ||
    1898         [ #  # ]:          0 :                     tcp_mask->hdr.tcp_urp) {
    1899                 :            :                         memset(rule, 0, sizeof(struct txgbe_fdir_rule));
    1900                 :          0 :                         rte_flow_error_set(error, EINVAL,
    1901                 :            :                                 RTE_FLOW_ERROR_TYPE_ITEM,
    1902                 :            :                                 item, "Not supported by fdir filter");
    1903                 :          0 :                         return -rte_errno;
    1904                 :            :                 }
    1905                 :          0 :                 rule->mask.src_port_mask = tcp_mask->hdr.src_port;
    1906                 :          0 :                 rule->mask.dst_port_mask = tcp_mask->hdr.dst_port;
    1907                 :            : 
    1908         [ #  # ]:          0 :                 if (item->spec) {
    1909                 :          0 :                         rule->b_spec = TRUE;
    1910                 :            :                         tcp_spec = item->spec;
    1911                 :          0 :                         rule->input.src_port =
    1912                 :          0 :                                 tcp_spec->hdr.src_port;
    1913                 :          0 :                         rule->input.dst_port =
    1914                 :          0 :                                 tcp_spec->hdr.dst_port;
    1915                 :            :                 }
    1916                 :            : 
    1917                 :            :                 item = next_no_fuzzy_pattern(pattern, item);
    1918         [ #  # ]:          0 :                 if (item->type != RTE_FLOW_ITEM_TYPE_RAW &&
    1919                 :            :                     item->type != RTE_FLOW_ITEM_TYPE_END) {
    1920                 :            :                         memset(rule, 0, sizeof(struct txgbe_fdir_rule));
    1921                 :          0 :                         rte_flow_error_set(error, EINVAL,
    1922                 :            :                                 RTE_FLOW_ERROR_TYPE_ITEM,
    1923                 :            :                                 item, "Not supported by fdir filter");
    1924                 :          0 :                         return -rte_errno;
    1925                 :            :                 }
    1926                 :            :         }
    1927                 :            : 
    1928                 :            :         /* Get the UDP info */
    1929         [ #  # ]:          0 :         if (item->type == RTE_FLOW_ITEM_TYPE_UDP) {
    1930                 :            :                 /**
    1931                 :            :                  * Set the flow type even if there's no content
    1932                 :            :                  * as we must have a flow type.
    1933                 :            :                  */
    1934                 :          0 :                 rule->input.flow_type |= TXGBE_ATR_L4TYPE_UDP;
    1935         [ #  # ]:          0 :                 if (rule->input.flow_type & TXGBE_ATR_FLOW_TYPE_IPV6)
    1936                 :          0 :                         ptype = txgbe_ptype_table[TXGBE_PT_IPV6_UDP];
    1937                 :            :                 else
    1938                 :          0 :                         ptype = txgbe_ptype_table[TXGBE_PT_IPV4_UDP];
    1939                 :            :                 /*Not supported last point for range*/
    1940         [ #  # ]:          0 :                 if (item->last) {
    1941                 :          0 :                         rte_flow_error_set(error, EINVAL,
    1942                 :            :                                 RTE_FLOW_ERROR_TYPE_UNSPECIFIED,
    1943                 :            :                                 item, "Not supported last point for range");
    1944                 :          0 :                         return -rte_errno;
    1945                 :            :                 }
    1946                 :            :                 /**
    1947                 :            :                  * Only care about src & dst ports,
    1948                 :            :                  * others should be masked.
    1949                 :            :                  */
    1950         [ #  # ]:          0 :                 if (!item->mask) {
    1951                 :            :                         memset(rule, 0, sizeof(struct txgbe_fdir_rule));
    1952                 :          0 :                         rte_flow_error_set(error, EINVAL,
    1953                 :            :                                 RTE_FLOW_ERROR_TYPE_ITEM,
    1954                 :            :                                 item, "Not supported by fdir filter");
    1955                 :          0 :                         return -rte_errno;
    1956                 :            :                 }
    1957                 :          0 :                 rule->b_mask = TRUE;
    1958                 :            :                 udp_mask = item->mask;
    1959         [ #  # ]:          0 :                 if (udp_mask->hdr.dgram_len ||
    1960         [ #  # ]:          0 :                     udp_mask->hdr.dgram_cksum) {
    1961                 :            :                         memset(rule, 0, sizeof(struct txgbe_fdir_rule));
    1962                 :          0 :                         rte_flow_error_set(error, EINVAL,
    1963                 :            :                                 RTE_FLOW_ERROR_TYPE_ITEM,
    1964                 :            :                                 item, "Not supported by fdir filter");
    1965                 :          0 :                         return -rte_errno;
    1966                 :            :                 }
    1967                 :          0 :                 rule->mask.src_port_mask = udp_mask->hdr.src_port;
    1968                 :          0 :                 rule->mask.dst_port_mask = udp_mask->hdr.dst_port;
    1969                 :            : 
    1970         [ #  # ]:          0 :                 if (item->spec) {
    1971                 :          0 :                         rule->b_spec = TRUE;
    1972                 :            :                         udp_spec = item->spec;
    1973                 :          0 :                         rule->input.src_port =
    1974                 :          0 :                                 udp_spec->hdr.src_port;
    1975                 :          0 :                         rule->input.dst_port =
    1976                 :          0 :                                 udp_spec->hdr.dst_port;
    1977                 :            :                 }
    1978                 :            : 
    1979                 :            :                 item = next_no_fuzzy_pattern(pattern, item);
    1980         [ #  # ]:          0 :                 if (item->type != RTE_FLOW_ITEM_TYPE_RAW &&
    1981                 :            :                     item->type != RTE_FLOW_ITEM_TYPE_END) {
    1982                 :            :                         memset(rule, 0, sizeof(struct txgbe_fdir_rule));
    1983                 :          0 :                         rte_flow_error_set(error, EINVAL,
    1984                 :            :                                 RTE_FLOW_ERROR_TYPE_ITEM,
    1985                 :            :                                 item, "Not supported by fdir filter");
    1986                 :          0 :                         return -rte_errno;
    1987                 :            :                 }
    1988                 :            :         }
    1989                 :            : 
    1990                 :            :         /* Get the SCTP info */
    1991         [ #  # ]:          0 :         if (item->type == RTE_FLOW_ITEM_TYPE_SCTP) {
    1992                 :            :                 /**
    1993                 :            :                  * Set the flow type even if there's no content
    1994                 :            :                  * as we must have a flow type.
    1995                 :            :                  */
    1996                 :          0 :                 rule->input.flow_type |= TXGBE_ATR_L4TYPE_SCTP;
    1997         [ #  # ]:          0 :                 if (rule->input.flow_type & TXGBE_ATR_FLOW_TYPE_IPV6)
    1998                 :          0 :                         ptype = txgbe_ptype_table[TXGBE_PT_IPV6_SCTP];
    1999                 :            :                 else
    2000                 :          0 :                         ptype = txgbe_ptype_table[TXGBE_PT_IPV4_SCTP];
    2001                 :            :                 /*Not supported last point for range*/
    2002         [ #  # ]:          0 :                 if (item->last) {
    2003                 :          0 :                         rte_flow_error_set(error, EINVAL,
    2004                 :            :                                 RTE_FLOW_ERROR_TYPE_UNSPECIFIED,
    2005                 :            :                                 item, "Not supported last point for range");
    2006                 :          0 :                         return -rte_errno;
    2007                 :            :                 }
    2008                 :            : 
    2009                 :            :                 /**
    2010                 :            :                  * Only care about src & dst ports,
    2011                 :            :                  * others should be masked.
    2012                 :            :                  */
    2013         [ #  # ]:          0 :                 if (!item->mask) {
    2014                 :            :                         memset(rule, 0, sizeof(struct txgbe_fdir_rule));
    2015                 :          0 :                         rte_flow_error_set(error, EINVAL,
    2016                 :            :                                 RTE_FLOW_ERROR_TYPE_ITEM,
    2017                 :            :                                 item, "Not supported by fdir filter");
    2018                 :          0 :                         return -rte_errno;
    2019                 :            :                 }
    2020                 :          0 :                 rule->b_mask = TRUE;
    2021                 :            :                 sctp_mask = item->mask;
    2022         [ #  # ]:          0 :                 if (sctp_mask->hdr.tag ||
    2023         [ #  # ]:          0 :                         sctp_mask->hdr.cksum) {
    2024                 :            :                         memset(rule, 0, sizeof(struct txgbe_fdir_rule));
    2025                 :          0 :                         rte_flow_error_set(error, EINVAL,
    2026                 :            :                                 RTE_FLOW_ERROR_TYPE_ITEM,
    2027                 :            :                                 item, "Not supported by fdir filter");
    2028                 :          0 :                         return -rte_errno;
    2029                 :            :                 }
    2030                 :          0 :                 rule->mask.src_port_mask = sctp_mask->hdr.src_port;
    2031                 :          0 :                 rule->mask.dst_port_mask = sctp_mask->hdr.dst_port;
    2032                 :            : 
    2033         [ #  # ]:          0 :                 if (item->spec) {
    2034                 :          0 :                         rule->b_spec = TRUE;
    2035                 :            :                         sctp_spec = item->spec;
    2036                 :          0 :                         rule->input.src_port =
    2037                 :          0 :                                 sctp_spec->hdr.src_port;
    2038                 :          0 :                         rule->input.dst_port =
    2039                 :          0 :                                 sctp_spec->hdr.dst_port;
    2040                 :            :                 }
    2041                 :            :                 /* others even sctp port is not supported */
    2042                 :            :                 sctp_mask = item->mask;
    2043         [ #  # ]:          0 :                 if (sctp_mask &&
    2044         [ #  # ]:          0 :                         (sctp_mask->hdr.src_port ||
    2045                 :            :                          sctp_mask->hdr.dst_port ||
    2046                 :            :                          sctp_mask->hdr.tag ||
    2047                 :            :                          sctp_mask->hdr.cksum)) {
    2048                 :            :                         memset(rule, 0, sizeof(struct txgbe_fdir_rule));
    2049                 :          0 :                         rte_flow_error_set(error, EINVAL,
    2050                 :            :                                 RTE_FLOW_ERROR_TYPE_ITEM,
    2051                 :            :                                 item, "Not supported by fdir filter");
    2052                 :          0 :                         return -rte_errno;
    2053                 :            :                 }
    2054                 :            : 
    2055                 :            :                 item = next_no_fuzzy_pattern(pattern, item);
    2056         [ #  # ]:          0 :                 if (item->type != RTE_FLOW_ITEM_TYPE_RAW &&
    2057                 :            :                         item->type != RTE_FLOW_ITEM_TYPE_END) {
    2058                 :            :                         memset(rule, 0, sizeof(struct txgbe_fdir_rule));
    2059                 :          0 :                         rte_flow_error_set(error, EINVAL,
    2060                 :            :                                 RTE_FLOW_ERROR_TYPE_ITEM,
    2061                 :            :                                 item, "Not supported by fdir filter");
    2062                 :          0 :                         return -rte_errno;
    2063                 :            :                 }
    2064                 :            :         }
    2065                 :            : 
    2066                 :            :         /* Get the flex byte info */
    2067         [ #  # ]:          0 :         if (item->type == RTE_FLOW_ITEM_TYPE_RAW) {
    2068                 :            :                 /* Not supported last point for range*/
    2069         [ #  # ]:          0 :                 if (item->last) {
    2070                 :          0 :                         rte_flow_error_set(error, EINVAL,
    2071                 :            :                                 RTE_FLOW_ERROR_TYPE_UNSPECIFIED,
    2072                 :            :                                 item, "Not supported last point for range");
    2073                 :          0 :                         return -rte_errno;
    2074                 :            :                 }
    2075                 :            :                 /* mask should not be null */
    2076   [ #  #  #  # ]:          0 :                 if (!item->mask || !item->spec) {
    2077                 :            :                         memset(rule, 0, sizeof(struct txgbe_fdir_rule));
    2078                 :          0 :                         rte_flow_error_set(error, EINVAL,
    2079                 :            :                                 RTE_FLOW_ERROR_TYPE_ITEM,
    2080                 :            :                                 item, "Not supported by fdir filter");
    2081                 :          0 :                         return -rte_errno;
    2082                 :            :                 }
    2083                 :            : 
    2084                 :            :                 raw_mask = item->mask;
    2085                 :            : 
    2086                 :            :                 /* check mask */
    2087                 :          0 :                 if (raw_mask->relative != 0x1 ||
    2088                 :            :                     raw_mask->search != 0x1 ||
    2089         [ #  # ]:          0 :                     raw_mask->reserved != 0x0 ||
    2090                 :            :                     (uint32_t)raw_mask->offset != 0xffffffff ||
    2091         [ #  # ]:          0 :                     raw_mask->limit != 0xffff ||
    2092                 :            :                     raw_mask->length != 0xffff) {
    2093                 :            :                         memset(rule, 0, sizeof(struct txgbe_fdir_rule));
    2094                 :          0 :                         rte_flow_error_set(error, EINVAL,
    2095                 :            :                                 RTE_FLOW_ERROR_TYPE_ITEM,
    2096                 :            :                                 item, "Not supported by fdir filter");
    2097                 :          0 :                         return -rte_errno;
    2098                 :            :                 }
    2099                 :            : 
    2100                 :            :                 raw_spec = item->spec;
    2101                 :            : 
    2102                 :            :                 /* check spec */
    2103                 :          0 :                 if (raw_spec->relative != 0 ||
    2104         [ #  # ]:          0 :                     raw_spec->search != 0 ||
    2105                 :          0 :                     raw_spec->reserved != 0 ||
    2106   [ #  #  #  # ]:          0 :                     raw_spec->offset > TXGBE_MAX_FLX_SOURCE_OFF ||
    2107                 :            :                     raw_spec->offset % 2 ||
    2108         [ #  # ]:          0 :                     raw_spec->limit != 0 ||
    2109                 :          0 :                     raw_spec->length != 2 ||
    2110                 :            :                     /* pattern can't be 0xffff */
    2111         [ #  # ]:          0 :                     (raw_spec->pattern[0] == 0xff &&
    2112         [ #  # ]:          0 :                      raw_spec->pattern[1] == 0xff)) {
    2113                 :            :                         memset(rule, 0, sizeof(struct txgbe_fdir_rule));
    2114                 :          0 :                         rte_flow_error_set(error, EINVAL,
    2115                 :            :                                 RTE_FLOW_ERROR_TYPE_ITEM,
    2116                 :            :                                 item, "Not supported by fdir filter");
    2117                 :          0 :                         return -rte_errno;
    2118                 :            :                 }
    2119                 :            : 
    2120                 :            :                 /* check pattern mask */
    2121         [ #  # ]:          0 :                 if (raw_mask->pattern[0] != 0xff ||
    2122         [ #  # ]:          0 :                     raw_mask->pattern[1] != 0xff) {
    2123                 :            :                         memset(rule, 0, sizeof(struct txgbe_fdir_rule));
    2124                 :          0 :                         rte_flow_error_set(error, EINVAL,
    2125                 :            :                                 RTE_FLOW_ERROR_TYPE_ITEM,
    2126                 :            :                                 item, "Not supported by fdir filter");
    2127                 :          0 :                         return -rte_errno;
    2128                 :            :                 }
    2129                 :            : 
    2130                 :          0 :                 rule->mask.flex_bytes_mask = 0xffff;
    2131                 :          0 :                 rule->input.flex_bytes =
    2132                 :          0 :                         (((uint16_t)raw_spec->pattern[1]) << 8) |
    2133                 :          0 :                         raw_spec->pattern[0];
    2134                 :          0 :                 rule->flex_bytes_offset = raw_spec->offset;
    2135                 :            :         }
    2136                 :            : 
    2137         [ #  # ]:          0 :         if (item->type != RTE_FLOW_ITEM_TYPE_END) {
    2138                 :            :                 /* check if the next not void item is END */
    2139                 :            :                 item = next_no_fuzzy_pattern(pattern, item);
    2140         [ #  # ]:          0 :                 if (item->type != RTE_FLOW_ITEM_TYPE_END) {
    2141                 :            :                         memset(rule, 0, sizeof(struct txgbe_fdir_rule));
    2142                 :          0 :                         rte_flow_error_set(error, EINVAL,
    2143                 :            :                                 RTE_FLOW_ERROR_TYPE_ITEM,
    2144                 :            :                                 item, "Not supported by fdir filter");
    2145                 :          0 :                         return -rte_errno;
    2146                 :            :                 }
    2147                 :            :         }
    2148                 :            : 
    2149                 :          0 :         rule->input.pkt_type = cpu_to_be16(txgbe_encode_ptype(ptype));
    2150                 :            : 
    2151         [ #  # ]:          0 :         if (rule->input.flow_type & TXGBE_ATR_FLOW_TYPE_IPV6) {
    2152         [ #  # ]:          0 :                 if (rule->input.flow_type & TXGBE_ATR_L4TYPE_MASK)
    2153                 :            :                         rule->input.pkt_type &= 0xFFFF;
    2154                 :            :                 else
    2155                 :          0 :                         rule->input.pkt_type &= 0xF8FF;
    2156                 :            : 
    2157                 :          0 :                 rule->input.flow_type &= TXGBE_ATR_L3TYPE_MASK |
    2158                 :            :                                         TXGBE_ATR_L4TYPE_MASK;
    2159                 :            :         }
    2160                 :            : 
    2161                 :          0 :         return txgbe_parse_fdir_act_attr(attr, actions, rule, error);
    2162                 :            : }
    2163                 :            : 
    2164                 :            : /**
    2165                 :            :  * Parse the rule to see if it is a VxLAN or NVGRE flow director rule.
    2166                 :            :  * And get the flow director filter info BTW.
    2167                 :            :  * VxLAN PATTERN:
    2168                 :            :  * The first not void item must be ETH.
    2169                 :            :  * The second not void item must be IPV4/ IPV6.
    2170                 :            :  * The third not void item must be NVGRE.
    2171                 :            :  * The next not void item must be END.
    2172                 :            :  * NVGRE PATTERN:
    2173                 :            :  * The first not void item must be ETH.
    2174                 :            :  * The second not void item must be IPV4/ IPV6.
    2175                 :            :  * The third not void item must be NVGRE.
    2176                 :            :  * The next not void item must be END.
    2177                 :            :  * ACTION:
    2178                 :            :  * The first not void action should be QUEUE or DROP.
    2179                 :            :  * The second not void optional action should be MARK,
    2180                 :            :  * mark_id is a uint32_t number.
    2181                 :            :  * The next not void action should be END.
    2182                 :            :  * VxLAN pattern example:
    2183                 :            :  * ITEM         Spec                    Mask
    2184                 :            :  * ETH          NULL                    NULL
    2185                 :            :  * IPV4/IPV6    NULL                    NULL
    2186                 :            :  * UDP          NULL                    NULL
    2187                 :            :  * VxLAN        vni{0x00, 0x32, 0x54}   {0xFF, 0xFF, 0xFF}
    2188                 :            :  * MAC VLAN     tci     0x2016          0xEFFF
    2189                 :            :  * END
    2190                 :            :  * NEGRV pattern example:
    2191                 :            :  * ITEM         Spec                    Mask
    2192                 :            :  * ETH          NULL                    NULL
    2193                 :            :  * IPV4/IPV6    NULL                    NULL
    2194                 :            :  * NVGRE        protocol        0x6558  0xFFFF
    2195                 :            :  *              tni{0x00, 0x32, 0x54}   {0xFF, 0xFF, 0xFF}
    2196                 :            :  * MAC VLAN     tci     0x2016          0xEFFF
    2197                 :            :  * END
    2198                 :            :  * other members in mask and spec should set to 0x00.
    2199                 :            :  * item->last should be NULL.
    2200                 :            :  */
    2201                 :            : static int
    2202                 :          0 : txgbe_parse_fdir_filter_tunnel(const struct rte_flow_attr *attr,
    2203                 :            :                                const struct rte_flow_item pattern[],
    2204                 :            :                                const struct rte_flow_action actions[],
    2205                 :            :                                struct txgbe_fdir_rule *rule,
    2206                 :            :                                struct rte_flow_error *error)
    2207                 :            : {
    2208                 :            :         const struct rte_flow_item *item;
    2209                 :            :         const struct rte_flow_item_eth *eth_mask;
    2210                 :            :         uint32_t j;
    2211                 :            : 
    2212         [ #  # ]:          0 :         if (!pattern) {
    2213                 :          0 :                 rte_flow_error_set(error, EINVAL,
    2214                 :            :                         RTE_FLOW_ERROR_TYPE_ITEM_NUM,
    2215                 :            :                                    NULL, "NULL pattern.");
    2216                 :          0 :                 return -rte_errno;
    2217                 :            :         }
    2218                 :            : 
    2219         [ #  # ]:          0 :         if (!actions) {
    2220                 :          0 :                 rte_flow_error_set(error, EINVAL,
    2221                 :            :                                    RTE_FLOW_ERROR_TYPE_ACTION_NUM,
    2222                 :            :                                    NULL, "NULL action.");
    2223                 :          0 :                 return -rte_errno;
    2224                 :            :         }
    2225                 :            : 
    2226         [ #  # ]:          0 :         if (!attr) {
    2227                 :          0 :                 rte_flow_error_set(error, EINVAL,
    2228                 :            :                                    RTE_FLOW_ERROR_TYPE_ATTR,
    2229                 :            :                                    NULL, "NULL attribute.");
    2230                 :          0 :                 return -rte_errno;
    2231                 :            :         }
    2232                 :            : 
    2233                 :            :         /**
    2234                 :            :          * Some fields may not be provided. Set spec to 0 and mask to default
    2235                 :            :          * value. So, we need not do anything for the not provided fields later.
    2236                 :            :          */
    2237                 :            :         memset(rule, 0, sizeof(struct txgbe_fdir_rule));
    2238                 :          0 :         memset(&rule->mask, 0xFF, sizeof(struct txgbe_hw_fdir_mask));
    2239                 :          0 :         rule->mask.vlan_tci_mask = 0;
    2240                 :            : 
    2241                 :            :         /**
    2242                 :            :          * The first not void item should be
    2243                 :            :          * MAC or IPv4 or IPv6 or UDP or VxLAN.
    2244                 :            :          */
    2245                 :            :         item = next_no_void_pattern(pattern, NULL);
    2246         [ #  # ]:          0 :         if (item->type != RTE_FLOW_ITEM_TYPE_ETH &&
    2247                 :            :             item->type != RTE_FLOW_ITEM_TYPE_IPV4 &&
    2248                 :            :             item->type != RTE_FLOW_ITEM_TYPE_IPV6 &&
    2249                 :            :             item->type != RTE_FLOW_ITEM_TYPE_UDP &&
    2250                 :            :             item->type != RTE_FLOW_ITEM_TYPE_VXLAN &&
    2251                 :            :             item->type != RTE_FLOW_ITEM_TYPE_NVGRE) {
    2252                 :            :                 memset(rule, 0, sizeof(struct txgbe_fdir_rule));
    2253                 :          0 :                 rte_flow_error_set(error, EINVAL,
    2254                 :            :                         RTE_FLOW_ERROR_TYPE_ITEM,
    2255                 :            :                         item, "Not supported by fdir filter");
    2256                 :          0 :                 return -rte_errno;
    2257                 :            :         }
    2258                 :            : 
    2259                 :          0 :         rule->mode = RTE_FDIR_MODE_PERFECT_TUNNEL;
    2260                 :            : 
    2261                 :            :         /* Skip MAC. */
    2262         [ #  # ]:          0 :         if (item->type == RTE_FLOW_ITEM_TYPE_ETH) {
    2263                 :            :                 /* Only used to describe the protocol stack. */
    2264   [ #  #  #  # ]:          0 :                 if (item->spec || item->mask) {
    2265                 :            :                         memset(rule, 0, sizeof(struct txgbe_fdir_rule));
    2266                 :          0 :                         rte_flow_error_set(error, EINVAL,
    2267                 :            :                                 RTE_FLOW_ERROR_TYPE_ITEM,
    2268                 :            :                                 item, "Not supported by fdir filter");
    2269                 :          0 :                         return -rte_errno;
    2270                 :            :                 }
    2271                 :            :                 /* Not supported last point for range*/
    2272         [ #  # ]:          0 :                 if (item->last) {
    2273                 :          0 :                         rte_flow_error_set(error, EINVAL,
    2274                 :            :                                 RTE_FLOW_ERROR_TYPE_UNSPECIFIED,
    2275                 :            :                                 item, "Not supported last point for range");
    2276                 :          0 :                         return -rte_errno;
    2277                 :            :                 }
    2278                 :            : 
    2279                 :            :                 /* Check if the next not void item is IPv4 or IPv6. */
    2280                 :            :                 item = next_no_void_pattern(pattern, item);
    2281         [ #  # ]:          0 :                 if (item->type != RTE_FLOW_ITEM_TYPE_IPV4 &&
    2282                 :            :                     item->type != RTE_FLOW_ITEM_TYPE_IPV6) {
    2283                 :            :                         memset(rule, 0, sizeof(struct txgbe_fdir_rule));
    2284                 :          0 :                         rte_flow_error_set(error, EINVAL,
    2285                 :            :                                 RTE_FLOW_ERROR_TYPE_ITEM,
    2286                 :            :                                 item, "Not supported by fdir filter");
    2287                 :          0 :                         return -rte_errno;
    2288                 :            :                 }
    2289                 :            :         }
    2290                 :            : 
    2291                 :            :         /* Skip IP. */
    2292         [ #  # ]:          0 :         if (item->type == RTE_FLOW_ITEM_TYPE_IPV4 ||
    2293                 :            :             item->type == RTE_FLOW_ITEM_TYPE_IPV6) {
    2294                 :            :                 /* Only used to describe the protocol stack. */
    2295   [ #  #  #  # ]:          0 :                 if (item->spec || item->mask) {
    2296                 :            :                         memset(rule, 0, sizeof(struct txgbe_fdir_rule));
    2297                 :          0 :                         rte_flow_error_set(error, EINVAL,
    2298                 :            :                                 RTE_FLOW_ERROR_TYPE_ITEM,
    2299                 :            :                                 item, "Not supported by fdir filter");
    2300                 :          0 :                         return -rte_errno;
    2301                 :            :                 }
    2302                 :            :                 /*Not supported last point for range*/
    2303         [ #  # ]:          0 :                 if (item->last) {
    2304                 :          0 :                         rte_flow_error_set(error, EINVAL,
    2305                 :            :                                 RTE_FLOW_ERROR_TYPE_UNSPECIFIED,
    2306                 :            :                                 item, "Not supported last point for range");
    2307                 :          0 :                         return -rte_errno;
    2308                 :            :                 }
    2309                 :            : 
    2310                 :            :                 /* Check if the next not void item is UDP or NVGRE. */
    2311                 :            :                 item = next_no_void_pattern(pattern, item);
    2312         [ #  # ]:          0 :                 if (item->type != RTE_FLOW_ITEM_TYPE_UDP &&
    2313                 :            :                     item->type != RTE_FLOW_ITEM_TYPE_NVGRE) {
    2314                 :            :                         memset(rule, 0, sizeof(struct txgbe_fdir_rule));
    2315                 :          0 :                         rte_flow_error_set(error, EINVAL,
    2316                 :            :                                 RTE_FLOW_ERROR_TYPE_ITEM,
    2317                 :            :                                 item, "Not supported by fdir filter");
    2318                 :          0 :                         return -rte_errno;
    2319                 :            :                 }
    2320                 :            :         }
    2321                 :            : 
    2322                 :            :         /* Skip UDP. */
    2323         [ #  # ]:          0 :         if (item->type == RTE_FLOW_ITEM_TYPE_UDP) {
    2324                 :            :                 /* Only used to describe the protocol stack. */
    2325   [ #  #  #  # ]:          0 :                 if (item->spec || item->mask) {
    2326                 :            :                         memset(rule, 0, sizeof(struct txgbe_fdir_rule));
    2327                 :          0 :                         rte_flow_error_set(error, EINVAL,
    2328                 :            :                                 RTE_FLOW_ERROR_TYPE_ITEM,
    2329                 :            :                                 item, "Not supported by fdir filter");
    2330                 :          0 :                         return -rte_errno;
    2331                 :            :                 }
    2332                 :            :                 /*Not supported last point for range*/
    2333         [ #  # ]:          0 :                 if (item->last) {
    2334                 :          0 :                         rte_flow_error_set(error, EINVAL,
    2335                 :            :                                 RTE_FLOW_ERROR_TYPE_UNSPECIFIED,
    2336                 :            :                                 item, "Not supported last point for range");
    2337                 :          0 :                         return -rte_errno;
    2338                 :            :                 }
    2339                 :            : 
    2340                 :            :                 /* Check if the next not void item is VxLAN. */
    2341                 :            :                 item = next_no_void_pattern(pattern, item);
    2342         [ #  # ]:          0 :                 if (item->type != RTE_FLOW_ITEM_TYPE_VXLAN) {
    2343                 :            :                         memset(rule, 0, sizeof(struct txgbe_fdir_rule));
    2344                 :          0 :                         rte_flow_error_set(error, EINVAL,
    2345                 :            :                                 RTE_FLOW_ERROR_TYPE_ITEM,
    2346                 :            :                                 item, "Not supported by fdir filter");
    2347                 :          0 :                         return -rte_errno;
    2348                 :            :                 }
    2349                 :            :         }
    2350                 :            : 
    2351                 :            :         /* check if the next not void item is MAC */
    2352                 :            :         item = next_no_void_pattern(pattern, item);
    2353         [ #  # ]:          0 :         if (item->type != RTE_FLOW_ITEM_TYPE_ETH) {
    2354                 :            :                 memset(rule, 0, sizeof(struct txgbe_fdir_rule));
    2355                 :          0 :                 rte_flow_error_set(error, EINVAL,
    2356                 :            :                         RTE_FLOW_ERROR_TYPE_ITEM,
    2357                 :            :                         item, "Not supported by fdir filter");
    2358                 :          0 :                 return -rte_errno;
    2359                 :            :         }
    2360                 :            : 
    2361                 :            :         /**
    2362                 :            :          * Only support vlan and dst MAC address,
    2363                 :            :          * others should be masked.
    2364                 :            :          */
    2365                 :            : 
    2366         [ #  # ]:          0 :         if (!item->mask) {
    2367                 :            :                 memset(rule, 0, sizeof(struct txgbe_fdir_rule));
    2368                 :          0 :                 rte_flow_error_set(error, EINVAL,
    2369                 :            :                         RTE_FLOW_ERROR_TYPE_ITEM,
    2370                 :            :                         item, "Not supported by fdir filter");
    2371                 :          0 :                 return -rte_errno;
    2372                 :            :         }
    2373                 :            :         /*Not supported last point for range*/
    2374         [ #  # ]:          0 :         if (item->last) {
    2375                 :          0 :                 rte_flow_error_set(error, EINVAL,
    2376                 :            :                         RTE_FLOW_ERROR_TYPE_UNSPECIFIED,
    2377                 :            :                         item, "Not supported last point for range");
    2378                 :          0 :                 return -rte_errno;
    2379                 :            :         }
    2380                 :          0 :         rule->b_mask = TRUE;
    2381                 :            :         eth_mask = item->mask;
    2382                 :            : 
    2383                 :            :         /* Ether type should be masked. */
    2384         [ #  # ]:          0 :         if (eth_mask->hdr.ether_type) {
    2385                 :            :                 memset(rule, 0, sizeof(struct txgbe_fdir_rule));
    2386                 :          0 :                 rte_flow_error_set(error, EINVAL,
    2387                 :            :                         RTE_FLOW_ERROR_TYPE_ITEM,
    2388                 :            :                         item, "Not supported by fdir filter");
    2389                 :          0 :                 return -rte_errno;
    2390                 :            :         }
    2391                 :            : 
    2392                 :            :         /* src MAC address should be masked. */
    2393         [ #  # ]:          0 :         for (j = 0; j < RTE_ETHER_ADDR_LEN; j++) {
    2394         [ #  # ]:          0 :                 if (eth_mask->hdr.src_addr.addr_bytes[j]) {
    2395                 :            :                         memset(rule, 0,
    2396                 :            :                                sizeof(struct txgbe_fdir_rule));
    2397                 :          0 :                         rte_flow_error_set(error, EINVAL,
    2398                 :            :                                 RTE_FLOW_ERROR_TYPE_ITEM,
    2399                 :            :                                 item, "Not supported by fdir filter");
    2400                 :          0 :                         return -rte_errno;
    2401                 :            :                 }
    2402                 :            :         }
    2403                 :          0 :         rule->mask.mac_addr_byte_mask = 0;
    2404         [ #  # ]:          0 :         for (j = 0; j < ETH_ADDR_LEN; j++) {
    2405                 :            :                 /* It's a per byte mask. */
    2406         [ #  # ]:          0 :                 if (eth_mask->hdr.dst_addr.addr_bytes[j] == 0xFF) {
    2407                 :          0 :                         rule->mask.mac_addr_byte_mask |= 0x1 << j;
    2408         [ #  # ]:          0 :                 } else if (eth_mask->hdr.dst_addr.addr_bytes[j]) {
    2409                 :            :                         memset(rule, 0, sizeof(struct txgbe_fdir_rule));
    2410                 :          0 :                         rte_flow_error_set(error, EINVAL,
    2411                 :            :                                 RTE_FLOW_ERROR_TYPE_ITEM,
    2412                 :            :                                 item, "Not supported by fdir filter");
    2413                 :          0 :                         return -rte_errno;
    2414                 :            :                 }
    2415                 :            :         }
    2416                 :            : 
    2417                 :            :         /* When no vlan, considered as full mask. */
    2418                 :          0 :         rule->mask.vlan_tci_mask = rte_cpu_to_be_16(0xEFFF);
    2419                 :            : 
    2420                 :            :         /**
    2421                 :            :          * Check if the next not void item is vlan or ipv4.
    2422                 :            :          * IPv6 is not supported.
    2423                 :            :          */
    2424                 :            :         item = next_no_void_pattern(pattern, item);
    2425         [ #  # ]:          0 :         if (item->type != RTE_FLOW_ITEM_TYPE_VLAN &&
    2426                 :            :                 item->type != RTE_FLOW_ITEM_TYPE_IPV4) {
    2427                 :            :                 memset(rule, 0, sizeof(struct txgbe_fdir_rule));
    2428                 :          0 :                 rte_flow_error_set(error, EINVAL,
    2429                 :            :                         RTE_FLOW_ERROR_TYPE_ITEM,
    2430                 :            :                         item, "Not supported by fdir filter");
    2431                 :          0 :                 return -rte_errno;
    2432                 :            :         }
    2433                 :            :         /*Not supported last point for range*/
    2434         [ #  # ]:          0 :         if (item->last) {
    2435                 :          0 :                 rte_flow_error_set(error, EINVAL,
    2436                 :            :                         RTE_FLOW_ERROR_TYPE_UNSPECIFIED,
    2437                 :            :                         item, "Not supported last point for range");
    2438                 :          0 :                 return -rte_errno;
    2439                 :            :         }
    2440                 :            : 
    2441                 :            :         /**
    2442                 :            :          * If the tags is 0, it means don't care about the VLAN.
    2443                 :            :          * Do nothing.
    2444                 :            :          */
    2445                 :            : 
    2446                 :          0 :         return txgbe_parse_fdir_act_attr(attr, actions, rule, error);
    2447                 :            : }
    2448                 :            : 
    2449                 :            : static int
    2450                 :          0 : txgbe_parse_fdir_filter(struct rte_eth_dev *dev,
    2451                 :            :                         const struct rte_flow_attr *attr,
    2452                 :            :                         const struct rte_flow_item pattern[],
    2453                 :            :                         const struct rte_flow_action actions[],
    2454                 :            :                         struct txgbe_fdir_rule *rule,
    2455                 :            :                         struct rte_flow_error *error)
    2456                 :            : {
    2457                 :            :         int ret;
    2458                 :          0 :         struct txgbe_hw *hw = TXGBE_DEV_HW(dev);
    2459                 :            :         struct rte_eth_fdir_conf *fdir_conf = TXGBE_DEV_FDIR_CONF(dev);
    2460                 :            : 
    2461                 :          0 :         ret = txgbe_parse_fdir_filter_normal(dev, attr, pattern,
    2462                 :            :                                         actions, rule, error);
    2463         [ #  # ]:          0 :         if (!ret)
    2464                 :          0 :                 goto step_next;
    2465                 :            : 
    2466                 :          0 :         ret = txgbe_parse_fdir_filter_tunnel(attr, pattern,
    2467                 :            :                                         actions, rule, error);
    2468         [ #  # ]:          0 :         if (ret)
    2469                 :            :                 return ret;
    2470                 :            : 
    2471                 :          0 : step_next:
    2472                 :            : 
    2473         [ #  # ]:          0 :         if (hw->mac.type == txgbe_mac_raptor &&
    2474         [ #  # ]:          0 :                 rule->fdirflags == TXGBE_FDIRPICMD_DROP &&
    2475         [ #  # ]:          0 :                 (rule->input.src_port != 0 || rule->input.dst_port != 0))
    2476                 :            :                 return -ENOTSUP;
    2477                 :            : 
    2478         [ #  # ]:          0 :         if (fdir_conf->mode == RTE_FDIR_MODE_NONE) {
    2479                 :          0 :                 fdir_conf->mode = rule->mode;
    2480                 :          0 :                 ret = txgbe_fdir_configure(dev);
    2481         [ #  # ]:          0 :                 if (ret) {
    2482                 :          0 :                         fdir_conf->mode = RTE_FDIR_MODE_NONE;
    2483                 :          0 :                         return ret;
    2484                 :            :                 }
    2485         [ #  # ]:          0 :         } else if (fdir_conf->mode != rule->mode) {
    2486                 :            :                 return -ENOTSUP;
    2487                 :            :         }
    2488                 :            : 
    2489         [ #  # ]:          0 :         if (rule->queue >= dev->data->nb_rx_queues)
    2490                 :          0 :                 return -ENOTSUP;
    2491                 :            : 
    2492                 :            :         return ret;
    2493                 :            : }
    2494                 :            : 
    2495                 :            : static int
    2496                 :          0 : txgbe_parse_rss_filter(struct rte_eth_dev *dev,
    2497                 :            :                         const struct rte_flow_attr *attr,
    2498                 :            :                         const struct rte_flow_action actions[],
    2499                 :            :                         struct txgbe_rte_flow_rss_conf *rss_conf,
    2500                 :            :                         struct rte_flow_error *error)
    2501                 :            : {
    2502                 :            :         const struct rte_flow_action *act;
    2503                 :            :         const struct rte_flow_action_rss *rss;
    2504                 :            :         uint16_t n;
    2505                 :            : 
    2506                 :            :         /**
    2507                 :            :          * rss only supports forwarding,
    2508                 :            :          * check if the first not void action is RSS.
    2509                 :            :          */
    2510                 :            :         act = next_no_void_action(actions, NULL);
    2511         [ #  # ]:          0 :         if (act->type != RTE_FLOW_ACTION_TYPE_RSS) {
    2512                 :            :                 memset(rss_conf, 0, sizeof(struct txgbe_rte_flow_rss_conf));
    2513                 :          0 :                 rte_flow_error_set(error, EINVAL,
    2514                 :            :                         RTE_FLOW_ERROR_TYPE_ACTION,
    2515                 :            :                         act, "Not supported action.");
    2516                 :          0 :                 return -rte_errno;
    2517                 :            :         }
    2518                 :            : 
    2519                 :          0 :         rss = (const struct rte_flow_action_rss *)act->conf;
    2520                 :            : 
    2521   [ #  #  #  # ]:          0 :         if (!rss || !rss->queue_num) {
    2522                 :          0 :                 rte_flow_error_set(error, EINVAL,
    2523                 :            :                                 RTE_FLOW_ERROR_TYPE_ACTION,
    2524                 :            :                                 act,
    2525                 :            :                            "no valid queues");
    2526                 :          0 :                 return -rte_errno;
    2527                 :            :         }
    2528                 :            : 
    2529         [ #  # ]:          0 :         for (n = 0; n < rss->queue_num; n++) {
    2530         [ #  # ]:          0 :                 if (rss->queue[n] >= dev->data->nb_rx_queues) {
    2531                 :          0 :                         rte_flow_error_set(error, EINVAL,
    2532                 :            :                                    RTE_FLOW_ERROR_TYPE_ACTION,
    2533                 :            :                                    act,
    2534                 :            :                                    "queue id > max number of queues");
    2535                 :          0 :                         return -rte_errno;
    2536                 :            :                 }
    2537                 :            :         }
    2538                 :            : 
    2539         [ #  # ]:          0 :         if (rss->func != RTE_ETH_HASH_FUNCTION_DEFAULT)
    2540                 :          0 :                 return rte_flow_error_set
    2541                 :            :                         (error, ENOTSUP, RTE_FLOW_ERROR_TYPE_ACTION, act,
    2542                 :            :                          "non-default RSS hash functions are not supported");
    2543         [ #  # ]:          0 :         if (rss->level)
    2544                 :          0 :                 return rte_flow_error_set
    2545                 :            :                         (error, ENOTSUP, RTE_FLOW_ERROR_TYPE_ACTION, act,
    2546                 :            :                          "a nonzero RSS encapsulation level is not supported");
    2547         [ #  # ]:          0 :         if (rss->key_len && rss->key_len != RTE_DIM(rss_conf->key))
    2548                 :          0 :                 return rte_flow_error_set
    2549                 :            :                         (error, ENOTSUP, RTE_FLOW_ERROR_TYPE_ACTION, act,
    2550                 :            :                          "RSS hash key must be exactly 40 bytes");
    2551         [ #  # ]:          0 :         if (rss->queue_num > RTE_DIM(rss_conf->queue))
    2552                 :          0 :                 return rte_flow_error_set
    2553                 :            :                         (error, ENOTSUP, RTE_FLOW_ERROR_TYPE_ACTION, act,
    2554                 :            :                          "too many queues for RSS context");
    2555         [ #  # ]:          0 :         if (txgbe_rss_conf_init(rss_conf, rss))
    2556                 :          0 :                 return rte_flow_error_set
    2557                 :            :                         (error, EINVAL, RTE_FLOW_ERROR_TYPE_ACTION, act,
    2558                 :            :                          "RSS context initialization failure");
    2559                 :            : 
    2560                 :            :         /* check if the next not void item is END */
    2561                 :            :         act = next_no_void_action(actions, act);
    2562         [ #  # ]:          0 :         if (act->type != RTE_FLOW_ACTION_TYPE_END) {
    2563                 :            :                 memset(rss_conf, 0, sizeof(struct txgbe_rte_flow_rss_conf));
    2564                 :          0 :                 rte_flow_error_set(error, EINVAL,
    2565                 :            :                         RTE_FLOW_ERROR_TYPE_ACTION,
    2566                 :            :                         act, "Not supported action.");
    2567                 :          0 :                 return -rte_errno;
    2568                 :            :         }
    2569                 :            : 
    2570                 :            :         /* parse attr */
    2571                 :            :         /* must be input direction */
    2572         [ #  # ]:          0 :         if (!attr->ingress) {
    2573                 :            :                 memset(rss_conf, 0, sizeof(struct txgbe_rte_flow_rss_conf));
    2574                 :          0 :                 rte_flow_error_set(error, EINVAL,
    2575                 :            :                                    RTE_FLOW_ERROR_TYPE_ATTR_INGRESS,
    2576                 :            :                                    attr, "Only support ingress.");
    2577                 :          0 :                 return -rte_errno;
    2578                 :            :         }
    2579                 :            : 
    2580                 :            :         /* not supported */
    2581         [ #  # ]:          0 :         if (attr->egress) {
    2582                 :            :                 memset(rss_conf, 0, sizeof(struct txgbe_rte_flow_rss_conf));
    2583                 :          0 :                 rte_flow_error_set(error, EINVAL,
    2584                 :            :                                    RTE_FLOW_ERROR_TYPE_ATTR_EGRESS,
    2585                 :            :                                    attr, "Not support egress.");
    2586                 :          0 :                 return -rte_errno;
    2587                 :            :         }
    2588                 :            : 
    2589                 :            :         /* not supported */
    2590         [ #  # ]:          0 :         if (attr->transfer) {
    2591                 :            :                 memset(rss_conf, 0, sizeof(struct txgbe_rte_flow_rss_conf));
    2592                 :          0 :                 rte_flow_error_set(error, EINVAL,
    2593                 :            :                                    RTE_FLOW_ERROR_TYPE_ATTR_TRANSFER,
    2594                 :            :                                    attr, "No support for transfer.");
    2595                 :          0 :                 return -rte_errno;
    2596                 :            :         }
    2597                 :            : 
    2598         [ #  # ]:          0 :         if (attr->priority > 0xFFFF) {
    2599                 :            :                 memset(rss_conf, 0, sizeof(struct txgbe_rte_flow_rss_conf));
    2600                 :          0 :                 rte_flow_error_set(error, EINVAL,
    2601                 :            :                                    RTE_FLOW_ERROR_TYPE_ATTR_PRIORITY,
    2602                 :            :                                    attr, "Error priority.");
    2603                 :          0 :                 return -rte_errno;
    2604                 :            :         }
    2605                 :            : 
    2606                 :            :         return 0;
    2607                 :            : }
    2608                 :            : 
    2609                 :            : /* remove the rss filter */
    2610                 :            : static void
    2611                 :            : txgbe_clear_rss_filter(struct rte_eth_dev *dev)
    2612                 :            : {
    2613                 :          0 :         struct txgbe_filter_info *filter_info = TXGBE_DEV_FILTER(dev);
    2614                 :            : 
    2615         [ #  # ]:          0 :         if (filter_info->rss_info.conf.queue_num)
    2616                 :          0 :                 txgbe_config_rss_filter(dev, &filter_info->rss_info, FALSE);
    2617                 :            : }
    2618                 :            : 
    2619                 :            : void
    2620                 :          0 : txgbe_filterlist_init(void)
    2621                 :            : {
    2622                 :          0 :         TAILQ_INIT(&filter_ntuple_list);
    2623                 :          0 :         TAILQ_INIT(&filter_ethertype_list);
    2624                 :          0 :         TAILQ_INIT(&filter_syn_list);
    2625                 :          0 :         TAILQ_INIT(&filter_fdir_list);
    2626                 :          0 :         TAILQ_INIT(&filter_l2_tunnel_list);
    2627                 :          0 :         TAILQ_INIT(&filter_rss_list);
    2628                 :          0 :         TAILQ_INIT(&txgbe_flow_list);
    2629                 :          0 : }
    2630                 :            : 
    2631                 :            : void
    2632                 :          0 : txgbe_filterlist_flush(void)
    2633                 :            : {
    2634                 :            :         struct txgbe_ntuple_filter_ele *ntuple_filter_ptr;
    2635                 :            :         struct txgbe_ethertype_filter_ele *ethertype_filter_ptr;
    2636                 :            :         struct txgbe_eth_syn_filter_ele *syn_filter_ptr;
    2637                 :            :         struct txgbe_eth_l2_tunnel_conf_ele *l2_tn_filter_ptr;
    2638                 :            :         struct txgbe_fdir_rule_ele *fdir_rule_ptr;
    2639                 :            :         struct txgbe_flow_mem *txgbe_flow_mem_ptr;
    2640                 :            :         struct txgbe_rss_conf_ele *rss_filter_ptr;
    2641                 :            : 
    2642         [ #  # ]:          0 :         while ((ntuple_filter_ptr = TAILQ_FIRST(&filter_ntuple_list))) {
    2643         [ #  # ]:          0 :                 TAILQ_REMOVE(&filter_ntuple_list,
    2644                 :            :                                  ntuple_filter_ptr,
    2645                 :            :                                  entries);
    2646                 :          0 :                 rte_free(ntuple_filter_ptr);
    2647                 :            :         }
    2648                 :            : 
    2649         [ #  # ]:          0 :         while ((ethertype_filter_ptr = TAILQ_FIRST(&filter_ethertype_list))) {
    2650         [ #  # ]:          0 :                 TAILQ_REMOVE(&filter_ethertype_list,
    2651                 :            :                                  ethertype_filter_ptr,
    2652                 :            :                                  entries);
    2653                 :          0 :                 rte_free(ethertype_filter_ptr);
    2654                 :            :         }
    2655                 :            : 
    2656         [ #  # ]:          0 :         while ((syn_filter_ptr = TAILQ_FIRST(&filter_syn_list))) {
    2657         [ #  # ]:          0 :                 TAILQ_REMOVE(&filter_syn_list,
    2658                 :            :                                  syn_filter_ptr,
    2659                 :            :                                  entries);
    2660                 :          0 :                 rte_free(syn_filter_ptr);
    2661                 :            :         }
    2662                 :            : 
    2663         [ #  # ]:          0 :         while ((l2_tn_filter_ptr = TAILQ_FIRST(&filter_l2_tunnel_list))) {
    2664         [ #  # ]:          0 :                 TAILQ_REMOVE(&filter_l2_tunnel_list,
    2665                 :            :                                  l2_tn_filter_ptr,
    2666                 :            :                                  entries);
    2667                 :          0 :                 rte_free(l2_tn_filter_ptr);
    2668                 :            :         }
    2669                 :            : 
    2670         [ #  # ]:          0 :         while ((fdir_rule_ptr = TAILQ_FIRST(&filter_fdir_list))) {
    2671         [ #  # ]:          0 :                 TAILQ_REMOVE(&filter_fdir_list,
    2672                 :            :                                  fdir_rule_ptr,
    2673                 :            :                                  entries);
    2674                 :          0 :                 rte_free(fdir_rule_ptr);
    2675                 :            :         }
    2676                 :            : 
    2677         [ #  # ]:          0 :         while ((rss_filter_ptr = TAILQ_FIRST(&filter_rss_list))) {
    2678         [ #  # ]:          0 :                 TAILQ_REMOVE(&filter_rss_list,
    2679                 :            :                                  rss_filter_ptr,
    2680                 :            :                                  entries);
    2681                 :          0 :                 rte_free(rss_filter_ptr);
    2682                 :            :         }
    2683                 :            : 
    2684         [ #  # ]:          0 :         while ((txgbe_flow_mem_ptr = TAILQ_FIRST(&txgbe_flow_list))) {
    2685         [ #  # ]:          0 :                 TAILQ_REMOVE(&txgbe_flow_list,
    2686                 :            :                                  txgbe_flow_mem_ptr,
    2687                 :            :                                  entries);
    2688                 :          0 :                 rte_free(txgbe_flow_mem_ptr->flow);
    2689                 :          0 :                 rte_free(txgbe_flow_mem_ptr);
    2690                 :            :         }
    2691                 :          0 : }
    2692                 :            : 
    2693                 :            : /**
    2694                 :            :  * Create or destroy a flow rule.
    2695                 :            :  * Theorically one rule can match more than one filters.
    2696                 :            :  * We will let it use the filter which it hit first.
    2697                 :            :  * So, the sequence matters.
    2698                 :            :  */
    2699                 :            : static struct rte_flow *
    2700                 :          0 : txgbe_flow_create(struct rte_eth_dev *dev,
    2701                 :            :                   const struct rte_flow_attr *attr,
    2702                 :            :                   const struct rte_flow_item pattern[],
    2703                 :            :                   const struct rte_flow_action actions[],
    2704                 :            :                   struct rte_flow_error *error)
    2705                 :            : {
    2706                 :            :         int ret;
    2707                 :            :         struct rte_eth_ntuple_filter ntuple_filter;
    2708                 :            :         struct rte_eth_ethertype_filter ethertype_filter;
    2709                 :            :         struct rte_eth_syn_filter syn_filter;
    2710                 :            :         struct txgbe_fdir_rule fdir_rule;
    2711                 :            :         struct txgbe_l2_tunnel_conf l2_tn_filter;
    2712                 :          0 :         struct txgbe_hw_fdir_info *fdir_info = TXGBE_DEV_FDIR(dev);
    2713                 :            :         struct txgbe_rte_flow_rss_conf rss_conf;
    2714                 :            :         struct rte_flow *flow = NULL;
    2715                 :            :         struct txgbe_ntuple_filter_ele *ntuple_filter_ptr;
    2716                 :            :         struct txgbe_ethertype_filter_ele *ethertype_filter_ptr;
    2717                 :            :         struct txgbe_eth_syn_filter_ele *syn_filter_ptr;
    2718                 :            :         struct txgbe_eth_l2_tunnel_conf_ele *l2_tn_filter_ptr;
    2719                 :            :         struct txgbe_fdir_rule_ele *fdir_rule_ptr;
    2720                 :            :         struct txgbe_rss_conf_ele *rss_filter_ptr;
    2721                 :            :         struct txgbe_flow_mem *txgbe_flow_mem_ptr;
    2722                 :            :         uint8_t first_mask = FALSE;
    2723                 :            : 
    2724                 :          0 :         flow = rte_zmalloc("txgbe_rte_flow", sizeof(struct rte_flow), 0);
    2725         [ #  # ]:          0 :         if (!flow) {
    2726                 :          0 :                 PMD_DRV_LOG(ERR, "failed to allocate memory");
    2727                 :          0 :                 return (struct rte_flow *)flow;
    2728                 :            :         }
    2729                 :          0 :         txgbe_flow_mem_ptr = rte_zmalloc("txgbe_flow_mem",
    2730                 :            :                         sizeof(struct txgbe_flow_mem), 0);
    2731         [ #  # ]:          0 :         if (!txgbe_flow_mem_ptr) {
    2732                 :          0 :                 PMD_DRV_LOG(ERR, "failed to allocate memory");
    2733                 :          0 :                 rte_free(flow);
    2734                 :          0 :                 return NULL;
    2735                 :            :         }
    2736                 :          0 :         txgbe_flow_mem_ptr->flow = flow;
    2737                 :          0 :         TAILQ_INSERT_TAIL(&txgbe_flow_list,
    2738                 :            :                                 txgbe_flow_mem_ptr, entries);
    2739                 :            : 
    2740                 :            :         memset(&ntuple_filter, 0, sizeof(struct rte_eth_ntuple_filter));
    2741                 :          0 :         ret = txgbe_parse_ntuple_filter(dev, attr, pattern,
    2742                 :            :                         actions, &ntuple_filter, error);
    2743                 :            : 
    2744                 :            : #ifdef RTE_LIB_SECURITY
    2745                 :            :         /* ESP flow not really a flow*/
    2746         [ #  # ]:          0 :         if (ntuple_filter.proto == IPPROTO_ESP)
    2747                 :            :                 return flow;
    2748                 :            : #endif
    2749                 :            : 
    2750         [ #  # ]:          0 :         if (!ret) {
    2751                 :          0 :                 ret = txgbe_add_del_ntuple_filter(dev, &ntuple_filter, TRUE);
    2752         [ #  # ]:          0 :                 if (!ret) {
    2753                 :          0 :                         ntuple_filter_ptr = rte_zmalloc("txgbe_ntuple_filter",
    2754                 :            :                                 sizeof(struct txgbe_ntuple_filter_ele), 0);
    2755         [ #  # ]:          0 :                         if (!ntuple_filter_ptr) {
    2756                 :          0 :                                 PMD_DRV_LOG(ERR, "failed to allocate memory");
    2757                 :          0 :                                 goto out;
    2758                 :            :                         }
    2759         [ #  # ]:          0 :                         rte_memcpy(&ntuple_filter_ptr->filter_info,
    2760                 :            :                                 &ntuple_filter,
    2761                 :            :                                 sizeof(struct rte_eth_ntuple_filter));
    2762                 :          0 :                         TAILQ_INSERT_TAIL(&filter_ntuple_list,
    2763                 :            :                                 ntuple_filter_ptr, entries);
    2764                 :          0 :                         flow->rule = ntuple_filter_ptr;
    2765                 :          0 :                         flow->filter_type = RTE_ETH_FILTER_NTUPLE;
    2766                 :          0 :                         return flow;
    2767                 :            :                 }
    2768                 :          0 :                 goto out;
    2769                 :            :         }
    2770                 :            : 
    2771                 :            :         memset(&ethertype_filter, 0, sizeof(struct rte_eth_ethertype_filter));
    2772                 :          0 :         ret = txgbe_parse_ethertype_filter(dev, attr, pattern,
    2773                 :            :                                 actions, &ethertype_filter, error);
    2774         [ #  # ]:          0 :         if (!ret) {
    2775                 :          0 :                 ret = txgbe_add_del_ethertype_filter(dev,
    2776                 :            :                                 &ethertype_filter, TRUE);
    2777         [ #  # ]:          0 :                 if (!ret) {
    2778                 :            :                         ethertype_filter_ptr =
    2779                 :          0 :                                 rte_zmalloc("txgbe_ethertype_filter",
    2780                 :            :                                 sizeof(struct txgbe_ethertype_filter_ele), 0);
    2781         [ #  # ]:          0 :                         if (!ethertype_filter_ptr) {
    2782                 :          0 :                                 PMD_DRV_LOG(ERR, "failed to allocate memory");
    2783                 :          0 :                                 goto out;
    2784                 :            :                         }
    2785         [ #  # ]:          0 :                         rte_memcpy(&ethertype_filter_ptr->filter_info,
    2786                 :            :                                 &ethertype_filter,
    2787                 :            :                                 sizeof(struct rte_eth_ethertype_filter));
    2788                 :          0 :                         TAILQ_INSERT_TAIL(&filter_ethertype_list,
    2789                 :            :                                 ethertype_filter_ptr, entries);
    2790                 :          0 :                         flow->rule = ethertype_filter_ptr;
    2791                 :          0 :                         flow->filter_type = RTE_ETH_FILTER_ETHERTYPE;
    2792                 :          0 :                         return flow;
    2793                 :            :                 }
    2794                 :          0 :                 goto out;
    2795                 :            :         }
    2796                 :            : 
    2797                 :            :         memset(&syn_filter, 0, sizeof(struct rte_eth_syn_filter));
    2798                 :            :         ret = txgbe_parse_syn_filter(dev, attr, pattern,
    2799                 :            :                                 actions, &syn_filter, error);
    2800         [ #  # ]:          0 :         if (!ret) {
    2801                 :          0 :                 ret = txgbe_syn_filter_set(dev, &syn_filter, TRUE);
    2802         [ #  # ]:          0 :                 if (!ret) {
    2803                 :          0 :                         syn_filter_ptr = rte_zmalloc("txgbe_syn_filter",
    2804                 :            :                                 sizeof(struct txgbe_eth_syn_filter_ele), 0);
    2805         [ #  # ]:          0 :                         if (!syn_filter_ptr) {
    2806                 :          0 :                                 PMD_DRV_LOG(ERR, "failed to allocate memory");
    2807                 :          0 :                                 goto out;
    2808                 :            :                         }
    2809         [ #  # ]:          0 :                         rte_memcpy(&syn_filter_ptr->filter_info,
    2810                 :            :                                 &syn_filter,
    2811                 :            :                                 sizeof(struct rte_eth_syn_filter));
    2812                 :          0 :                         TAILQ_INSERT_TAIL(&filter_syn_list,
    2813                 :            :                                 syn_filter_ptr,
    2814                 :            :                                 entries);
    2815                 :          0 :                         flow->rule = syn_filter_ptr;
    2816                 :          0 :                         flow->filter_type = RTE_ETH_FILTER_SYN;
    2817                 :          0 :                         return flow;
    2818                 :            :                 }
    2819                 :          0 :                 goto out;
    2820                 :            :         }
    2821                 :            : 
    2822                 :            :         memset(&fdir_rule, 0, sizeof(struct txgbe_fdir_rule));
    2823                 :          0 :         ret = txgbe_parse_fdir_filter(dev, attr, pattern,
    2824                 :            :                                 actions, &fdir_rule, error);
    2825         [ #  # ]:          0 :         if (!ret) {
    2826                 :            :                 /* A mask cannot be deleted. */
    2827         [ #  # ]:          0 :                 if (fdir_rule.b_mask) {
    2828         [ #  # ]:          0 :                         if (!fdir_info->mask_added) {
    2829                 :            :                                 /* It's the first time the mask is set. */
    2830         [ #  # ]:          0 :                                 rte_memcpy(&fdir_info->mask,
    2831                 :            :                                         &fdir_rule.mask,
    2832                 :            :                                         sizeof(struct txgbe_hw_fdir_mask));
    2833                 :          0 :                                 fdir_info->flex_bytes_offset =
    2834                 :          0 :                                         fdir_rule.flex_bytes_offset;
    2835                 :            : 
    2836         [ #  # ]:          0 :                                 if (fdir_rule.mask.flex_bytes_mask)
    2837                 :          0 :                                         txgbe_fdir_set_flexbytes_offset(dev,
    2838                 :            :                                                 fdir_rule.flex_bytes_offset);
    2839                 :            : 
    2840                 :          0 :                                 ret = txgbe_fdir_set_input_mask(dev);
    2841         [ #  # ]:          0 :                                 if (ret)
    2842                 :          0 :                                         goto out;
    2843                 :            : 
    2844                 :          0 :                                 fdir_info->mask_added = TRUE;
    2845                 :            :                                 first_mask = TRUE;
    2846                 :            :                         } else {
    2847                 :            :                                 /**
    2848                 :            :                                  * Only support one global mask,
    2849                 :            :                                  * all the masks should be the same.
    2850                 :            :                                  */
    2851                 :          0 :                                 ret = memcmp(&fdir_info->mask,
    2852                 :            :                                         &fdir_rule.mask,
    2853                 :            :                                         sizeof(struct txgbe_hw_fdir_mask));
    2854         [ #  # ]:          0 :                                 if (ret) {
    2855                 :          0 :                                         PMD_DRV_LOG(ERR, "only support one global mask");
    2856                 :          0 :                                         goto out;
    2857                 :            :                                 }
    2858                 :            : 
    2859                 :          0 :                                 if (fdir_info->flex_bytes_offset !=
    2860         [ #  # ]:          0 :                                                 fdir_rule.flex_bytes_offset)
    2861                 :          0 :                                         goto out;
    2862                 :            :                         }
    2863                 :            :                 }
    2864                 :            : 
    2865         [ #  # ]:          0 :                 if (fdir_rule.b_spec) {
    2866                 :          0 :                         ret = txgbe_fdir_filter_program(dev, &fdir_rule,
    2867                 :            :                                         FALSE, FALSE);
    2868         [ #  # ]:          0 :                         if (!ret) {
    2869                 :          0 :                                 fdir_rule_ptr = rte_zmalloc("txgbe_fdir_filter",
    2870                 :            :                                         sizeof(struct txgbe_fdir_rule_ele), 0);
    2871         [ #  # ]:          0 :                                 if (!fdir_rule_ptr) {
    2872                 :          0 :                                         PMD_DRV_LOG(ERR,
    2873                 :            :                                                 "failed to allocate memory");
    2874                 :          0 :                                         goto out;
    2875                 :            :                                 }
    2876         [ #  # ]:          0 :                                 rte_memcpy(&fdir_rule_ptr->filter_info,
    2877                 :            :                                         &fdir_rule,
    2878                 :            :                                         sizeof(struct txgbe_fdir_rule));
    2879                 :          0 :                                 TAILQ_INSERT_TAIL(&filter_fdir_list,
    2880                 :            :                                         fdir_rule_ptr, entries);
    2881                 :          0 :                                 flow->rule = fdir_rule_ptr;
    2882                 :          0 :                                 flow->filter_type = RTE_ETH_FILTER_FDIR;
    2883                 :            : 
    2884                 :          0 :                                 return flow;
    2885                 :            :                         }
    2886                 :            : 
    2887                 :            :                         if (ret) {
    2888                 :            :                                 /**
    2889                 :            :                                  * clean the mask_added flag if fail to
    2890                 :            :                                  * program
    2891                 :            :                                  **/
    2892         [ #  # ]:          0 :                                 if (first_mask)
    2893                 :          0 :                                         fdir_info->mask_added = FALSE;
    2894                 :          0 :                                 goto out;
    2895                 :            :                         }
    2896                 :            :                 }
    2897                 :            : 
    2898                 :          0 :                 goto out;
    2899                 :            :         }
    2900                 :            : 
    2901                 :            :         memset(&l2_tn_filter, 0, sizeof(struct txgbe_l2_tunnel_conf));
    2902                 :            :         ret = txgbe_parse_l2_tn_filter(dev, attr, pattern,
    2903                 :            :                                         actions, &l2_tn_filter, error);
    2904         [ #  # ]:          0 :         if (!ret) {
    2905                 :          0 :                 ret = txgbe_dev_l2_tunnel_filter_add(dev, &l2_tn_filter, FALSE);
    2906         [ #  # ]:          0 :                 if (!ret) {
    2907                 :          0 :                         l2_tn_filter_ptr = rte_zmalloc("txgbe_l2_tn_filter",
    2908                 :            :                                 sizeof(struct txgbe_eth_l2_tunnel_conf_ele), 0);
    2909         [ #  # ]:          0 :                         if (!l2_tn_filter_ptr) {
    2910                 :          0 :                                 PMD_DRV_LOG(ERR, "failed to allocate memory");
    2911                 :          0 :                                 goto out;
    2912                 :            :                         }
    2913         [ #  # ]:          0 :                         rte_memcpy(&l2_tn_filter_ptr->filter_info,
    2914                 :            :                                 &l2_tn_filter,
    2915                 :            :                                 sizeof(struct txgbe_l2_tunnel_conf));
    2916                 :          0 :                         TAILQ_INSERT_TAIL(&filter_l2_tunnel_list,
    2917                 :            :                                 l2_tn_filter_ptr, entries);
    2918                 :          0 :                         flow->rule = l2_tn_filter_ptr;
    2919                 :          0 :                         flow->filter_type = RTE_ETH_FILTER_L2_TUNNEL;
    2920                 :          0 :                         return flow;
    2921                 :            :                 }
    2922                 :            :         }
    2923                 :            : 
    2924                 :            :         memset(&rss_conf, 0, sizeof(struct txgbe_rte_flow_rss_conf));
    2925                 :          0 :         ret = txgbe_parse_rss_filter(dev, attr,
    2926                 :            :                                         actions, &rss_conf, error);
    2927         [ #  # ]:          0 :         if (!ret) {
    2928                 :          0 :                 ret = txgbe_config_rss_filter(dev, &rss_conf, TRUE);
    2929         [ #  # ]:          0 :                 if (!ret) {
    2930                 :          0 :                         rss_filter_ptr = rte_zmalloc("txgbe_rss_filter",
    2931                 :            :                                 sizeof(struct txgbe_rss_conf_ele), 0);
    2932         [ #  # ]:          0 :                         if (!rss_filter_ptr) {
    2933                 :          0 :                                 PMD_DRV_LOG(ERR, "failed to allocate memory");
    2934                 :          0 :                                 goto out;
    2935                 :            :                         }
    2936                 :          0 :                         txgbe_rss_conf_init(&rss_filter_ptr->filter_info,
    2937                 :            :                                             &rss_conf.conf);
    2938                 :          0 :                         TAILQ_INSERT_TAIL(&filter_rss_list,
    2939                 :            :                                 rss_filter_ptr, entries);
    2940                 :          0 :                         flow->rule = rss_filter_ptr;
    2941                 :          0 :                         flow->filter_type = RTE_ETH_FILTER_HASH;
    2942                 :          0 :                         return flow;
    2943                 :            :                 }
    2944                 :            :         }
    2945                 :            : 
    2946                 :          0 : out:
    2947         [ #  # ]:          0 :         TAILQ_REMOVE(&txgbe_flow_list,
    2948                 :            :                 txgbe_flow_mem_ptr, entries);
    2949                 :          0 :         rte_flow_error_set(error, -ret,
    2950                 :            :                            RTE_FLOW_ERROR_TYPE_HANDLE, NULL,
    2951                 :            :                            "Failed to create flow.");
    2952                 :          0 :         rte_free(txgbe_flow_mem_ptr);
    2953                 :          0 :         rte_free(flow);
    2954                 :          0 :         return NULL;
    2955                 :            : }
    2956                 :            : 
    2957                 :            : /**
    2958                 :            :  * Check if the flow rule is supported by txgbe.
    2959                 :            :  * It only checks the format. Don't guarantee the rule can be programmed into
    2960                 :            :  * the HW. Because there can be no enough room for the rule.
    2961                 :            :  */
    2962                 :            : static int
    2963                 :          0 : txgbe_flow_validate(struct rte_eth_dev *dev,
    2964                 :            :                 const struct rte_flow_attr *attr,
    2965                 :            :                 const struct rte_flow_item pattern[],
    2966                 :            :                 const struct rte_flow_action actions[],
    2967                 :            :                 struct rte_flow_error *error)
    2968                 :            : {
    2969                 :            :         struct rte_eth_ntuple_filter ntuple_filter;
    2970                 :            :         struct rte_eth_ethertype_filter ethertype_filter;
    2971                 :            :         struct rte_eth_syn_filter syn_filter;
    2972                 :            :         struct txgbe_l2_tunnel_conf l2_tn_filter;
    2973                 :            :         struct txgbe_fdir_rule fdir_rule;
    2974                 :            :         struct txgbe_rte_flow_rss_conf rss_conf;
    2975                 :            :         int ret = 0;
    2976                 :            : 
    2977                 :            :         memset(&ntuple_filter, 0, sizeof(struct rte_eth_ntuple_filter));
    2978                 :          0 :         ret = txgbe_parse_ntuple_filter(dev, attr, pattern,
    2979                 :            :                                 actions, &ntuple_filter, error);
    2980         [ #  # ]:          0 :         if (!ret)
    2981                 :            :                 return 0;
    2982                 :            : 
    2983                 :            :         memset(&ethertype_filter, 0, sizeof(struct rte_eth_ethertype_filter));
    2984                 :          0 :         ret = txgbe_parse_ethertype_filter(dev, attr, pattern,
    2985                 :            :                                 actions, &ethertype_filter, error);
    2986         [ #  # ]:          0 :         if (!ret)
    2987                 :            :                 return 0;
    2988                 :            : 
    2989                 :            :         memset(&syn_filter, 0, sizeof(struct rte_eth_syn_filter));
    2990                 :            :         ret = txgbe_parse_syn_filter(dev, attr, pattern,
    2991                 :            :                                 actions, &syn_filter, error);
    2992         [ #  # ]:          0 :         if (!ret)
    2993                 :            :                 return 0;
    2994                 :            : 
    2995                 :            :         memset(&fdir_rule, 0, sizeof(struct txgbe_fdir_rule));
    2996                 :          0 :         ret = txgbe_parse_fdir_filter(dev, attr, pattern,
    2997                 :            :                                 actions, &fdir_rule, error);
    2998         [ #  # ]:          0 :         if (!ret)
    2999                 :            :                 return 0;
    3000                 :            : 
    3001                 :            :         memset(&l2_tn_filter, 0, sizeof(struct txgbe_l2_tunnel_conf));
    3002                 :            :         ret = txgbe_parse_l2_tn_filter(dev, attr, pattern,
    3003                 :            :                                 actions, &l2_tn_filter, error);
    3004         [ #  # ]:          0 :         if (!ret)
    3005                 :            :                 return 0;
    3006                 :            : 
    3007                 :            :         memset(&rss_conf, 0, sizeof(struct txgbe_rte_flow_rss_conf));
    3008                 :          0 :         ret = txgbe_parse_rss_filter(dev, attr,
    3009                 :            :                                         actions, &rss_conf, error);
    3010                 :            : 
    3011                 :          0 :         return ret;
    3012                 :            : }
    3013                 :            : 
    3014                 :            : /* Destroy a flow rule on txgbe. */
    3015                 :            : static int
    3016                 :          0 : txgbe_flow_destroy(struct rte_eth_dev *dev,
    3017                 :            :                 struct rte_flow *flow,
    3018                 :            :                 struct rte_flow_error *error)
    3019                 :            : {
    3020                 :            :         int ret = 0;
    3021                 :            :         struct rte_flow *pmd_flow = flow;
    3022                 :          0 :         enum rte_filter_type filter_type = pmd_flow->filter_type;
    3023                 :            :         struct rte_eth_ntuple_filter ntuple_filter;
    3024                 :            :         struct rte_eth_ethertype_filter ethertype_filter;
    3025                 :            :         struct rte_eth_syn_filter syn_filter;
    3026                 :            :         struct txgbe_fdir_rule fdir_rule;
    3027                 :            :         struct txgbe_l2_tunnel_conf l2_tn_filter;
    3028                 :            :         struct txgbe_ntuple_filter_ele *ntuple_filter_ptr;
    3029                 :            :         struct txgbe_ethertype_filter_ele *ethertype_filter_ptr;
    3030                 :            :         struct txgbe_eth_syn_filter_ele *syn_filter_ptr;
    3031                 :            :         struct txgbe_eth_l2_tunnel_conf_ele *l2_tn_filter_ptr;
    3032                 :            :         struct txgbe_fdir_rule_ele *fdir_rule_ptr;
    3033                 :            :         struct txgbe_flow_mem *txgbe_flow_mem_ptr;
    3034                 :          0 :         struct txgbe_hw_fdir_info *fdir_info = TXGBE_DEV_FDIR(dev);
    3035                 :            :         struct txgbe_rss_conf_ele *rss_filter_ptr;
    3036                 :            : 
    3037   [ #  #  #  #  :          0 :         switch (filter_type) {
                #  #  # ]
    3038                 :          0 :         case RTE_ETH_FILTER_NTUPLE:
    3039                 :          0 :                 ntuple_filter_ptr = (struct txgbe_ntuple_filter_ele *)
    3040                 :            :                                         pmd_flow->rule;
    3041                 :            :                 rte_memcpy(&ntuple_filter,
    3042         [ #  # ]:          0 :                         &ntuple_filter_ptr->filter_info,
    3043                 :            :                         sizeof(struct rte_eth_ntuple_filter));
    3044                 :          0 :                 ret = txgbe_add_del_ntuple_filter(dev, &ntuple_filter, FALSE);
    3045         [ #  # ]:          0 :                 if (!ret) {
    3046         [ #  # ]:          0 :                         TAILQ_REMOVE(&filter_ntuple_list,
    3047                 :            :                         ntuple_filter_ptr, entries);
    3048                 :          0 :                         rte_free(ntuple_filter_ptr);
    3049                 :            :                 }
    3050                 :            :                 break;
    3051                 :          0 :         case RTE_ETH_FILTER_ETHERTYPE:
    3052                 :          0 :                 ethertype_filter_ptr = (struct txgbe_ethertype_filter_ele *)
    3053                 :            :                                         pmd_flow->rule;
    3054                 :            :                 rte_memcpy(&ethertype_filter,
    3055         [ #  # ]:          0 :                         &ethertype_filter_ptr->filter_info,
    3056                 :            :                         sizeof(struct rte_eth_ethertype_filter));
    3057                 :          0 :                 ret = txgbe_add_del_ethertype_filter(dev,
    3058                 :            :                                 &ethertype_filter, FALSE);
    3059         [ #  # ]:          0 :                 if (!ret) {
    3060         [ #  # ]:          0 :                         TAILQ_REMOVE(&filter_ethertype_list,
    3061                 :            :                                 ethertype_filter_ptr, entries);
    3062                 :          0 :                         rte_free(ethertype_filter_ptr);
    3063                 :            :                 }
    3064                 :            :                 break;
    3065                 :          0 :         case RTE_ETH_FILTER_SYN:
    3066                 :          0 :                 syn_filter_ptr = (struct txgbe_eth_syn_filter_ele *)
    3067                 :            :                                 pmd_flow->rule;
    3068                 :            :                 rte_memcpy(&syn_filter,
    3069         [ #  # ]:          0 :                         &syn_filter_ptr->filter_info,
    3070                 :            :                         sizeof(struct rte_eth_syn_filter));
    3071                 :          0 :                 ret = txgbe_syn_filter_set(dev, &syn_filter, FALSE);
    3072         [ #  # ]:          0 :                 if (!ret) {
    3073         [ #  # ]:          0 :                         TAILQ_REMOVE(&filter_syn_list,
    3074                 :            :                                 syn_filter_ptr, entries);
    3075                 :          0 :                         rte_free(syn_filter_ptr);
    3076                 :            :                 }
    3077                 :            :                 break;
    3078                 :          0 :         case RTE_ETH_FILTER_FDIR:
    3079                 :          0 :                 fdir_rule_ptr = (struct txgbe_fdir_rule_ele *)pmd_flow->rule;
    3080                 :            :                 rte_memcpy(&fdir_rule,
    3081         [ #  # ]:          0 :                         &fdir_rule_ptr->filter_info,
    3082                 :            :                         sizeof(struct txgbe_fdir_rule));
    3083                 :          0 :                 ret = txgbe_fdir_filter_program(dev, &fdir_rule, TRUE, FALSE);
    3084         [ #  # ]:          0 :                 if (!ret) {
    3085         [ #  # ]:          0 :                         TAILQ_REMOVE(&filter_fdir_list,
    3086                 :            :                                 fdir_rule_ptr, entries);
    3087                 :          0 :                         rte_free(fdir_rule_ptr);
    3088         [ #  # ]:          0 :                         if (TAILQ_EMPTY(&filter_fdir_list))
    3089                 :          0 :                                 fdir_info->mask_added = false;
    3090                 :            :                 }
    3091                 :            :                 break;
    3092                 :          0 :         case RTE_ETH_FILTER_L2_TUNNEL:
    3093                 :          0 :                 l2_tn_filter_ptr = (struct txgbe_eth_l2_tunnel_conf_ele *)
    3094                 :            :                                 pmd_flow->rule;
    3095         [ #  # ]:          0 :                 rte_memcpy(&l2_tn_filter, &l2_tn_filter_ptr->filter_info,
    3096                 :            :                         sizeof(struct txgbe_l2_tunnel_conf));
    3097                 :          0 :                 ret = txgbe_dev_l2_tunnel_filter_del(dev, &l2_tn_filter);
    3098         [ #  # ]:          0 :                 if (!ret) {
    3099         [ #  # ]:          0 :                         TAILQ_REMOVE(&filter_l2_tunnel_list,
    3100                 :            :                                 l2_tn_filter_ptr, entries);
    3101                 :          0 :                         rte_free(l2_tn_filter_ptr);
    3102                 :            :                 }
    3103                 :            :                 break;
    3104                 :          0 :         case RTE_ETH_FILTER_HASH:
    3105                 :          0 :                 rss_filter_ptr = (struct txgbe_rss_conf_ele *)
    3106                 :            :                                 pmd_flow->rule;
    3107                 :          0 :                 ret = txgbe_config_rss_filter(dev,
    3108                 :            :                                         &rss_filter_ptr->filter_info, FALSE);
    3109         [ #  # ]:          0 :                 if (!ret) {
    3110         [ #  # ]:          0 :                         TAILQ_REMOVE(&filter_rss_list,
    3111                 :            :                                 rss_filter_ptr, entries);
    3112                 :          0 :                         rte_free(rss_filter_ptr);
    3113                 :            :                 }
    3114                 :            :                 break;
    3115                 :          0 :         default:
    3116                 :          0 :                 PMD_DRV_LOG(WARNING, "Filter type (%d) not supported",
    3117                 :            :                             filter_type);
    3118                 :            :                 ret = -EINVAL;
    3119                 :            :                 break;
    3120                 :            :         }
    3121                 :            : 
    3122         [ #  # ]:          0 :         if (ret) {
    3123                 :          0 :                 rte_flow_error_set(error, EINVAL,
    3124                 :            :                                 RTE_FLOW_ERROR_TYPE_HANDLE,
    3125                 :            :                                 NULL, "Failed to destroy flow");
    3126                 :          0 :                 return ret;
    3127                 :            :         }
    3128                 :            : 
    3129         [ #  # ]:          0 :         TAILQ_FOREACH(txgbe_flow_mem_ptr, &txgbe_flow_list, entries) {
    3130         [ #  # ]:          0 :                 if (txgbe_flow_mem_ptr->flow == pmd_flow) {
    3131         [ #  # ]:          0 :                         TAILQ_REMOVE(&txgbe_flow_list,
    3132                 :            :                                 txgbe_flow_mem_ptr, entries);
    3133                 :          0 :                         rte_free(txgbe_flow_mem_ptr);
    3134                 :            :                 }
    3135                 :            :         }
    3136                 :          0 :         rte_free(flow);
    3137                 :            : 
    3138                 :          0 :         return ret;
    3139                 :            : }
    3140                 :            : 
    3141                 :            : /*  Destroy all flow rules associated with a port on txgbe. */
    3142                 :            : static int
    3143                 :          0 : txgbe_flow_flush(struct rte_eth_dev *dev,
    3144                 :            :                 struct rte_flow_error *error)
    3145                 :            : {
    3146                 :            :         int ret = 0;
    3147                 :            : 
    3148                 :          0 :         txgbe_clear_all_ntuple_filter(dev);
    3149                 :          0 :         txgbe_clear_all_ethertype_filter(dev);
    3150                 :          0 :         txgbe_clear_syn_filter(dev);
    3151                 :            : 
    3152                 :          0 :         ret = txgbe_clear_all_fdir_filter(dev);
    3153         [ #  # ]:          0 :         if (ret < 0) {
    3154                 :          0 :                 rte_flow_error_set(error, EINVAL, RTE_FLOW_ERROR_TYPE_HANDLE,
    3155                 :            :                                         NULL, "Failed to flush rule");
    3156                 :          0 :                 return ret;
    3157                 :            :         }
    3158                 :            : 
    3159                 :          0 :         ret = txgbe_clear_all_l2_tn_filter(dev);
    3160         [ #  # ]:          0 :         if (ret < 0) {
    3161                 :          0 :                 rte_flow_error_set(error, EINVAL, RTE_FLOW_ERROR_TYPE_HANDLE,
    3162                 :            :                                         NULL, "Failed to flush rule");
    3163                 :          0 :                 return ret;
    3164                 :            :         }
    3165                 :            : 
    3166                 :            :         txgbe_clear_rss_filter(dev);
    3167                 :            : 
    3168                 :          0 :         txgbe_filterlist_flush();
    3169                 :            : 
    3170                 :          0 :         return 0;
    3171                 :            : }
    3172                 :            : 
    3173                 :            : const struct rte_flow_ops txgbe_flow_ops = {
    3174                 :            :         .validate = txgbe_flow_validate,
    3175                 :            :         .create = txgbe_flow_create,
    3176                 :            :         .destroy = txgbe_flow_destroy,
    3177                 :            :         .flush = txgbe_flow_flush,
    3178                 :            : };

Generated by: LCOV version 1.14