LCOV - code coverage report
Current view: top level - drivers/net/intel/e1000 - em_ethdev.c (source / functions) Hit Total Coverage
Test: Code coverage Lines: 1 635 0.2 %
Date: 2025-04-03 19:37:06 Functions: 1 40 2.5 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 0 222 0.0 %

           Branch data     Line data    Source code
       1                 :            : /* SPDX-License-Identifier: BSD-3-Clause
       2                 :            :  * Copyright(c) 2010-2016 Intel Corporation
       3                 :            :  */
       4                 :            : 
       5                 :            : #include <sys/queue.h>
       6                 :            : #include <stdio.h>
       7                 :            : #include <errno.h>
       8                 :            : #include <stdint.h>
       9                 :            : #include <stdarg.h>
      10                 :            : 
      11                 :            : #include <rte_common.h>
      12                 :            : #include <rte_interrupts.h>
      13                 :            : #include <rte_byteorder.h>
      14                 :            : #include <rte_debug.h>
      15                 :            : #include <rte_pci.h>
      16                 :            : #include <bus_pci_driver.h>
      17                 :            : #include <rte_ether.h>
      18                 :            : #include <ethdev_driver.h>
      19                 :            : #include <ethdev_pci.h>
      20                 :            : #include <rte_memory.h>
      21                 :            : #include <rte_eal.h>
      22                 :            : #include <rte_malloc.h>
      23                 :            : #include <dev_driver.h>
      24                 :            : 
      25                 :            : #include "e1000_logs.h"
      26                 :            : #include "base/e1000_api.h"
      27                 :            : #include "e1000_ethdev.h"
      28                 :            : 
      29                 :            : #define EM_EIAC                 0x000DC
      30                 :            : 
      31                 :            : #define PMD_ROUNDUP(x,y)        (((x) + (y) - 1)/(y) * (y))
      32                 :            : 
      33                 :            : 
      34                 :            : static int eth_em_configure(struct rte_eth_dev *dev);
      35                 :            : static int eth_em_start(struct rte_eth_dev *dev);
      36                 :            : static int eth_em_stop(struct rte_eth_dev *dev);
      37                 :            : static int eth_em_close(struct rte_eth_dev *dev);
      38                 :            : static int eth_em_promiscuous_enable(struct rte_eth_dev *dev);
      39                 :            : static int eth_em_promiscuous_disable(struct rte_eth_dev *dev);
      40                 :            : static int eth_em_allmulticast_enable(struct rte_eth_dev *dev);
      41                 :            : static int eth_em_allmulticast_disable(struct rte_eth_dev *dev);
      42                 :            : static int eth_em_link_update(struct rte_eth_dev *dev,
      43                 :            :                                 int wait_to_complete);
      44                 :            : static int eth_em_stats_get(struct rte_eth_dev *dev,
      45                 :            :                                 struct rte_eth_stats *rte_stats);
      46                 :            : static int eth_em_stats_reset(struct rte_eth_dev *dev);
      47                 :            : static int eth_em_infos_get(struct rte_eth_dev *dev,
      48                 :            :                                 struct rte_eth_dev_info *dev_info);
      49                 :            : static int eth_em_flow_ctrl_get(struct rte_eth_dev *dev,
      50                 :            :                                 struct rte_eth_fc_conf *fc_conf);
      51                 :            : static int eth_em_flow_ctrl_set(struct rte_eth_dev *dev,
      52                 :            :                                 struct rte_eth_fc_conf *fc_conf);
      53                 :            : static int eth_em_interrupt_setup(struct rte_eth_dev *dev);
      54                 :            : static int eth_em_rxq_interrupt_setup(struct rte_eth_dev *dev);
      55                 :            : static int eth_em_interrupt_get_status(struct rte_eth_dev *dev);
      56                 :            : static int eth_em_interrupt_action(struct rte_eth_dev *dev,
      57                 :            :                                    struct rte_intr_handle *handle);
      58                 :            : static void eth_em_interrupt_handler(void *param);
      59                 :            : 
      60                 :            : static int em_hw_init(struct e1000_hw *hw);
      61                 :            : static int em_hardware_init(struct e1000_hw *hw);
      62                 :            : static void em_hw_control_acquire(struct e1000_hw *hw);
      63                 :            : static void em_hw_control_release(struct e1000_hw *hw);
      64                 :            : static void em_init_manageability(struct e1000_hw *hw);
      65                 :            : static void em_release_manageability(struct e1000_hw *hw);
      66                 :            : 
      67                 :            : static int eth_em_mtu_set(struct rte_eth_dev *dev, uint16_t mtu);
      68                 :            : 
      69                 :            : static int eth_em_vlan_filter_set(struct rte_eth_dev *dev,
      70                 :            :                 uint16_t vlan_id, int on);
      71                 :            : static int eth_em_vlan_offload_set(struct rte_eth_dev *dev, int mask);
      72                 :            : static void em_vlan_hw_filter_enable(struct rte_eth_dev *dev);
      73                 :            : static void em_vlan_hw_filter_disable(struct rte_eth_dev *dev);
      74                 :            : static void em_vlan_hw_strip_enable(struct rte_eth_dev *dev);
      75                 :            : static void em_vlan_hw_strip_disable(struct rte_eth_dev *dev);
      76                 :            : 
      77                 :            : /*
      78                 :            : static void eth_em_vlan_filter_set(struct rte_eth_dev *dev,
      79                 :            :                                         uint16_t vlan_id, int on);
      80                 :            : */
      81                 :            : 
      82                 :            : static int eth_em_rx_queue_intr_enable(struct rte_eth_dev *dev, uint16_t queue_id);
      83                 :            : static int eth_em_rx_queue_intr_disable(struct rte_eth_dev *dev, uint16_t queue_id);
      84                 :            : static void em_lsc_intr_disable(struct e1000_hw *hw);
      85                 :            : static void em_rxq_intr_enable(struct e1000_hw *hw);
      86                 :            : static void em_rxq_intr_disable(struct e1000_hw *hw);
      87                 :            : 
      88                 :            : static int eth_em_led_on(struct rte_eth_dev *dev);
      89                 :            : static int eth_em_led_off(struct rte_eth_dev *dev);
      90                 :            : 
      91                 :            : static int em_get_rx_buffer_size(struct e1000_hw *hw);
      92                 :            : static int eth_em_rar_set(struct rte_eth_dev *dev,
      93                 :            :                         struct rte_ether_addr *mac_addr,
      94                 :            :                         uint32_t index, uint32_t pool);
      95                 :            : static void eth_em_rar_clear(struct rte_eth_dev *dev, uint32_t index);
      96                 :            : static int eth_em_default_mac_addr_set(struct rte_eth_dev *dev,
      97                 :            :                                          struct rte_ether_addr *addr);
      98                 :            : 
      99                 :            : static int eth_em_set_mc_addr_list(struct rte_eth_dev *dev,
     100                 :            :                                    struct rte_ether_addr *mc_addr_set,
     101                 :            :                                    uint32_t nb_mc_addr);
     102                 :            : 
     103                 :            : #define EM_FC_PAUSE_TIME 0x0680
     104                 :            : #define EM_LINK_UPDATE_CHECK_TIMEOUT  90  /* 9s */
     105                 :            : #define EM_LINK_UPDATE_CHECK_INTERVAL 100 /* ms */
     106                 :            : 
     107                 :            : static enum e1000_fc_mode em_fc_setting = e1000_fc_full;
     108                 :            : 
     109                 :            : /*
     110                 :            :  * The set of PCI devices this driver supports
     111                 :            :  */
     112                 :            : static const struct rte_pci_id pci_id_em_map[] = {
     113                 :            :         { RTE_PCI_DEVICE(E1000_INTEL_VENDOR_ID, E1000_DEV_ID_82540EM) },
     114                 :            :         { RTE_PCI_DEVICE(E1000_INTEL_VENDOR_ID, E1000_DEV_ID_82545EM_COPPER) },
     115                 :            :         { RTE_PCI_DEVICE(E1000_INTEL_VENDOR_ID, E1000_DEV_ID_82545EM_FIBER) },
     116                 :            :         { RTE_PCI_DEVICE(E1000_INTEL_VENDOR_ID, E1000_DEV_ID_82546EB_COPPER) },
     117                 :            :         { RTE_PCI_DEVICE(E1000_INTEL_VENDOR_ID, E1000_DEV_ID_82546EB_FIBER) },
     118                 :            :         { RTE_PCI_DEVICE(E1000_INTEL_VENDOR_ID, E1000_DEV_ID_82546EB_QUAD_COPPER) },
     119                 :            :         { RTE_PCI_DEVICE(E1000_INTEL_VENDOR_ID, E1000_DEV_ID_82571EB_COPPER) },
     120                 :            :         { RTE_PCI_DEVICE(E1000_INTEL_VENDOR_ID, E1000_DEV_ID_82571EB_FIBER) },
     121                 :            :         { RTE_PCI_DEVICE(E1000_INTEL_VENDOR_ID, E1000_DEV_ID_82571EB_SERDES) },
     122                 :            :         { RTE_PCI_DEVICE(E1000_INTEL_VENDOR_ID, E1000_DEV_ID_82571EB_SERDES_DUAL) },
     123                 :            :         { RTE_PCI_DEVICE(E1000_INTEL_VENDOR_ID, E1000_DEV_ID_82571EB_SERDES_QUAD) },
     124                 :            :         { RTE_PCI_DEVICE(E1000_INTEL_VENDOR_ID, E1000_DEV_ID_82571EB_QUAD_COPPER) },
     125                 :            :         { RTE_PCI_DEVICE(E1000_INTEL_VENDOR_ID, E1000_DEV_ID_82571PT_QUAD_COPPER) },
     126                 :            :         { RTE_PCI_DEVICE(E1000_INTEL_VENDOR_ID, E1000_DEV_ID_82571EB_QUAD_FIBER) },
     127                 :            :         { RTE_PCI_DEVICE(E1000_INTEL_VENDOR_ID, E1000_DEV_ID_82571EB_QUAD_COPPER_LP) },
     128                 :            :         { RTE_PCI_DEVICE(E1000_INTEL_VENDOR_ID, E1000_DEV_ID_82572EI_COPPER) },
     129                 :            :         { RTE_PCI_DEVICE(E1000_INTEL_VENDOR_ID, E1000_DEV_ID_82572EI_FIBER) },
     130                 :            :         { RTE_PCI_DEVICE(E1000_INTEL_VENDOR_ID, E1000_DEV_ID_82572EI_SERDES) },
     131                 :            :         { RTE_PCI_DEVICE(E1000_INTEL_VENDOR_ID, E1000_DEV_ID_82572EI) },
     132                 :            :         { RTE_PCI_DEVICE(E1000_INTEL_VENDOR_ID, E1000_DEV_ID_82573L) },
     133                 :            :         { RTE_PCI_DEVICE(E1000_INTEL_VENDOR_ID, E1000_DEV_ID_82574L) },
     134                 :            :         { RTE_PCI_DEVICE(E1000_INTEL_VENDOR_ID, E1000_DEV_ID_82574LA) },
     135                 :            :         { RTE_PCI_DEVICE(E1000_INTEL_VENDOR_ID, E1000_DEV_ID_82583V) },
     136                 :            :         { RTE_PCI_DEVICE(E1000_INTEL_VENDOR_ID, E1000_DEV_ID_PCH2_LV_LM) },
     137                 :            :         { RTE_PCI_DEVICE(E1000_INTEL_VENDOR_ID, E1000_DEV_ID_PCH_LPT_I217_LM) },
     138                 :            :         { RTE_PCI_DEVICE(E1000_INTEL_VENDOR_ID, E1000_DEV_ID_PCH_LPT_I217_V) },
     139                 :            :         { RTE_PCI_DEVICE(E1000_INTEL_VENDOR_ID, E1000_DEV_ID_PCH_LPTLP_I218_LM) },
     140                 :            :         { RTE_PCI_DEVICE(E1000_INTEL_VENDOR_ID, E1000_DEV_ID_PCH_LPTLP_I218_V) },
     141                 :            :         { RTE_PCI_DEVICE(E1000_INTEL_VENDOR_ID, E1000_DEV_ID_PCH_I218_LM2) },
     142                 :            :         { RTE_PCI_DEVICE(E1000_INTEL_VENDOR_ID, E1000_DEV_ID_PCH_I218_V2) },
     143                 :            :         { RTE_PCI_DEVICE(E1000_INTEL_VENDOR_ID, E1000_DEV_ID_PCH_I218_LM3) },
     144                 :            :         { RTE_PCI_DEVICE(E1000_INTEL_VENDOR_ID, E1000_DEV_ID_PCH_I218_V3) },
     145                 :            :         { RTE_PCI_DEVICE(E1000_INTEL_VENDOR_ID, E1000_DEV_ID_PCH_SPT_I219_LM) },
     146                 :            :         { RTE_PCI_DEVICE(E1000_INTEL_VENDOR_ID, E1000_DEV_ID_PCH_SPT_I219_V) },
     147                 :            :         { RTE_PCI_DEVICE(E1000_INTEL_VENDOR_ID, E1000_DEV_ID_PCH_SPT_I219_LM2) },
     148                 :            :         { RTE_PCI_DEVICE(E1000_INTEL_VENDOR_ID, E1000_DEV_ID_PCH_SPT_I219_V2) },
     149                 :            :         { RTE_PCI_DEVICE(E1000_INTEL_VENDOR_ID, E1000_DEV_ID_PCH_LBG_I219_LM3) },
     150                 :            :         { RTE_PCI_DEVICE(E1000_INTEL_VENDOR_ID, E1000_DEV_ID_PCH_SPT_I219_LM4) },
     151                 :            :         { RTE_PCI_DEVICE(E1000_INTEL_VENDOR_ID, E1000_DEV_ID_PCH_SPT_I219_V4) },
     152                 :            :         { RTE_PCI_DEVICE(E1000_INTEL_VENDOR_ID, E1000_DEV_ID_PCH_SPT_I219_LM5) },
     153                 :            :         { RTE_PCI_DEVICE(E1000_INTEL_VENDOR_ID, E1000_DEV_ID_PCH_SPT_I219_V5) },
     154                 :            :         { RTE_PCI_DEVICE(E1000_INTEL_VENDOR_ID, E1000_DEV_ID_PCH_CNP_I219_LM6) },
     155                 :            :         { RTE_PCI_DEVICE(E1000_INTEL_VENDOR_ID, E1000_DEV_ID_PCH_CNP_I219_V6) },
     156                 :            :         { RTE_PCI_DEVICE(E1000_INTEL_VENDOR_ID, E1000_DEV_ID_PCH_CNP_I219_LM7) },
     157                 :            :         { RTE_PCI_DEVICE(E1000_INTEL_VENDOR_ID, E1000_DEV_ID_PCH_CNP_I219_V7) },
     158                 :            :         { RTE_PCI_DEVICE(E1000_INTEL_VENDOR_ID, E1000_DEV_ID_PCH_ICP_I219_LM8) },
     159                 :            :         { RTE_PCI_DEVICE(E1000_INTEL_VENDOR_ID, E1000_DEV_ID_PCH_ICP_I219_V8) },
     160                 :            :         { RTE_PCI_DEVICE(E1000_INTEL_VENDOR_ID, E1000_DEV_ID_PCH_ICP_I219_LM9) },
     161                 :            :         { RTE_PCI_DEVICE(E1000_INTEL_VENDOR_ID, E1000_DEV_ID_PCH_ICP_I219_V9) },
     162                 :            :         { RTE_PCI_DEVICE(E1000_INTEL_VENDOR_ID, E1000_DEV_ID_PCH_CMP_I219_LM10) },
     163                 :            :         { RTE_PCI_DEVICE(E1000_INTEL_VENDOR_ID, E1000_DEV_ID_PCH_CMP_I219_V10) },
     164                 :            :         { RTE_PCI_DEVICE(E1000_INTEL_VENDOR_ID, E1000_DEV_ID_PCH_CMP_I219_LM11) },
     165                 :            :         { RTE_PCI_DEVICE(E1000_INTEL_VENDOR_ID, E1000_DEV_ID_PCH_CMP_I219_V11) },
     166                 :            :         { RTE_PCI_DEVICE(E1000_INTEL_VENDOR_ID, E1000_DEV_ID_PCH_CMP_I219_LM12) },
     167                 :            :         { RTE_PCI_DEVICE(E1000_INTEL_VENDOR_ID, E1000_DEV_ID_PCH_CMP_I219_V12) },
     168                 :            :         { RTE_PCI_DEVICE(E1000_INTEL_VENDOR_ID, E1000_DEV_ID_PCH_TGP_I219_LM13) },
     169                 :            :         { RTE_PCI_DEVICE(E1000_INTEL_VENDOR_ID, E1000_DEV_ID_PCH_TGP_I219_V13) },
     170                 :            :         { RTE_PCI_DEVICE(E1000_INTEL_VENDOR_ID, E1000_DEV_ID_PCH_TGP_I219_LM14) },
     171                 :            :         { RTE_PCI_DEVICE(E1000_INTEL_VENDOR_ID, E1000_DEV_ID_PCH_TGP_I219_V14) },
     172                 :            :         { RTE_PCI_DEVICE(E1000_INTEL_VENDOR_ID, E1000_DEV_ID_PCH_TGP_I219_LM15) },
     173                 :            :         { RTE_PCI_DEVICE(E1000_INTEL_VENDOR_ID, E1000_DEV_ID_PCH_TGP_I219_V15) },
     174                 :            :         { RTE_PCI_DEVICE(E1000_INTEL_VENDOR_ID, E1000_DEV_ID_PCH_ADL_I219_LM16) },
     175                 :            :         { RTE_PCI_DEVICE(E1000_INTEL_VENDOR_ID, E1000_DEV_ID_PCH_ADL_I219_V16) },
     176                 :            :         { RTE_PCI_DEVICE(E1000_INTEL_VENDOR_ID, E1000_DEV_ID_PCH_ADL_I219_LM17) },
     177                 :            :         { RTE_PCI_DEVICE(E1000_INTEL_VENDOR_ID, E1000_DEV_ID_PCH_ADL_I219_V17) },
     178                 :            :         { RTE_PCI_DEVICE(E1000_INTEL_VENDOR_ID, E1000_DEV_ID_PCH_MTP_I219_LM18) },
     179                 :            :         { RTE_PCI_DEVICE(E1000_INTEL_VENDOR_ID, E1000_DEV_ID_PCH_MTP_I219_V18) },
     180                 :            :         { RTE_PCI_DEVICE(E1000_INTEL_VENDOR_ID, E1000_DEV_ID_PCH_MTP_I219_LM19) },
     181                 :            :         { RTE_PCI_DEVICE(E1000_INTEL_VENDOR_ID, E1000_DEV_ID_PCH_MTP_I219_V19) },
     182                 :            :         { RTE_PCI_DEVICE(E1000_INTEL_VENDOR_ID, E1000_DEV_ID_PCH_LNL_I219_LM20) },
     183                 :            :         { RTE_PCI_DEVICE(E1000_INTEL_VENDOR_ID, E1000_DEV_ID_PCH_LNL_I219_V20) },
     184                 :            :         { RTE_PCI_DEVICE(E1000_INTEL_VENDOR_ID, E1000_DEV_ID_PCH_RPL_I219_LM22) },
     185                 :            :         { RTE_PCI_DEVICE(E1000_INTEL_VENDOR_ID, E1000_DEV_ID_PCH_RPL_I219_V22) },
     186                 :            :         { RTE_PCI_DEVICE(E1000_INTEL_VENDOR_ID, E1000_DEV_ID_PCH_RPL_I219_LM23) },
     187                 :            :         { RTE_PCI_DEVICE(E1000_INTEL_VENDOR_ID, E1000_DEV_ID_PCH_RPL_I219_V23) },
     188                 :            :         { RTE_PCI_DEVICE(E1000_INTEL_VENDOR_ID, E1000_DEV_ID_PCH_ARL_I219_LM24) },
     189                 :            :         { RTE_PCI_DEVICE(E1000_INTEL_VENDOR_ID, E1000_DEV_ID_PCH_ARL_I219_V24) },
     190                 :            :         { .vendor_id = 0, /* sentinel */ },
     191                 :            : };
     192                 :            : 
     193                 :            : static const struct eth_dev_ops eth_em_ops = {
     194                 :            :         .dev_configure        = eth_em_configure,
     195                 :            :         .dev_start            = eth_em_start,
     196                 :            :         .dev_stop             = eth_em_stop,
     197                 :            :         .dev_close            = eth_em_close,
     198                 :            :         .promiscuous_enable   = eth_em_promiscuous_enable,
     199                 :            :         .promiscuous_disable  = eth_em_promiscuous_disable,
     200                 :            :         .allmulticast_enable  = eth_em_allmulticast_enable,
     201                 :            :         .allmulticast_disable = eth_em_allmulticast_disable,
     202                 :            :         .link_update          = eth_em_link_update,
     203                 :            :         .stats_get            = eth_em_stats_get,
     204                 :            :         .stats_reset          = eth_em_stats_reset,
     205                 :            :         .dev_infos_get        = eth_em_infos_get,
     206                 :            :         .mtu_set              = eth_em_mtu_set,
     207                 :            :         .vlan_filter_set      = eth_em_vlan_filter_set,
     208                 :            :         .vlan_offload_set     = eth_em_vlan_offload_set,
     209                 :            :         .rx_queue_setup       = eth_em_rx_queue_setup,
     210                 :            :         .rx_queue_release     = eth_em_rx_queue_release,
     211                 :            :         .tx_queue_setup       = eth_em_tx_queue_setup,
     212                 :            :         .tx_queue_release     = eth_em_tx_queue_release,
     213                 :            :         .rx_queue_intr_enable = eth_em_rx_queue_intr_enable,
     214                 :            :         .rx_queue_intr_disable = eth_em_rx_queue_intr_disable,
     215                 :            :         .dev_led_on           = eth_em_led_on,
     216                 :            :         .dev_led_off          = eth_em_led_off,
     217                 :            :         .flow_ctrl_get        = eth_em_flow_ctrl_get,
     218                 :            :         .flow_ctrl_set        = eth_em_flow_ctrl_set,
     219                 :            :         .mac_addr_set         = eth_em_default_mac_addr_set,
     220                 :            :         .mac_addr_add         = eth_em_rar_set,
     221                 :            :         .mac_addr_remove      = eth_em_rar_clear,
     222                 :            :         .set_mc_addr_list     = eth_em_set_mc_addr_list,
     223                 :            :         .rxq_info_get         = em_rxq_info_get,
     224                 :            :         .txq_info_get         = em_txq_info_get,
     225                 :            : };
     226                 :            : 
     227                 :            : 
     228                 :            : /**
     229                 :            :  *  eth_em_dev_is_ich8 - Check for ICH8 device
     230                 :            :  *  @hw: pointer to the HW structure
     231                 :            :  *
     232                 :            :  *  return TRUE for ICH8, otherwise FALSE
     233                 :            :  **/
     234                 :            : static bool
     235                 :          0 : eth_em_dev_is_ich8(struct e1000_hw *hw)
     236                 :            : {
     237                 :          0 :         DEBUGFUNC("eth_em_dev_is_ich8");
     238                 :            : 
     239         [ #  # ]:          0 :         switch (hw->device_id) {
     240                 :            :         case E1000_DEV_ID_PCH2_LV_LM:
     241                 :            :         case E1000_DEV_ID_PCH_LPT_I217_LM:
     242                 :            :         case E1000_DEV_ID_PCH_LPT_I217_V:
     243                 :            :         case E1000_DEV_ID_PCH_LPTLP_I218_LM:
     244                 :            :         case E1000_DEV_ID_PCH_LPTLP_I218_V:
     245                 :            :         case E1000_DEV_ID_PCH_I218_V2:
     246                 :            :         case E1000_DEV_ID_PCH_I218_LM2:
     247                 :            :         case E1000_DEV_ID_PCH_I218_V3:
     248                 :            :         case E1000_DEV_ID_PCH_I218_LM3:
     249                 :            :         case E1000_DEV_ID_PCH_SPT_I219_LM:
     250                 :            :         case E1000_DEV_ID_PCH_SPT_I219_V:
     251                 :            :         case E1000_DEV_ID_PCH_SPT_I219_LM2:
     252                 :            :         case E1000_DEV_ID_PCH_SPT_I219_V2:
     253                 :            :         case E1000_DEV_ID_PCH_LBG_I219_LM3:
     254                 :            :         case E1000_DEV_ID_PCH_SPT_I219_LM4:
     255                 :            :         case E1000_DEV_ID_PCH_SPT_I219_V4:
     256                 :            :         case E1000_DEV_ID_PCH_SPT_I219_LM5:
     257                 :            :         case E1000_DEV_ID_PCH_SPT_I219_V5:
     258                 :            :         case E1000_DEV_ID_PCH_CNP_I219_LM6:
     259                 :            :         case E1000_DEV_ID_PCH_CNP_I219_V6:
     260                 :            :         case E1000_DEV_ID_PCH_CNP_I219_LM7:
     261                 :            :         case E1000_DEV_ID_PCH_CNP_I219_V7:
     262                 :            :         case E1000_DEV_ID_PCH_RPL_I219_LM22:
     263                 :            :         case E1000_DEV_ID_PCH_RPL_I219_V22:
     264                 :            :         case E1000_DEV_ID_PCH_RPL_I219_LM23:
     265                 :            :         case E1000_DEV_ID_PCH_RPL_I219_V23:
     266                 :            : 
     267                 :            :                 return 1;
     268                 :          0 :         default:
     269                 :          0 :                 return 0;
     270                 :            :         }
     271                 :            : }
     272                 :            : 
     273                 :            : static int
     274                 :          0 : eth_em_dev_init(struct rte_eth_dev *eth_dev)
     275                 :            : {
     276                 :          0 :         struct rte_pci_device *pci_dev = RTE_ETH_DEV_TO_PCI(eth_dev);
     277                 :          0 :         struct rte_intr_handle *intr_handle = pci_dev->intr_handle;
     278                 :          0 :         struct e1000_adapter *adapter =
     279                 :          0 :                 E1000_DEV_PRIVATE(eth_dev->data->dev_private);
     280                 :          0 :         struct e1000_hw *hw =
     281                 :            :                 E1000_DEV_PRIVATE_TO_HW(eth_dev->data->dev_private);
     282                 :          0 :         struct e1000_vfta * shadow_vfta =
     283                 :            :                 E1000_DEV_PRIVATE_TO_VFTA(eth_dev->data->dev_private);
     284                 :            : 
     285                 :          0 :         eth_dev->dev_ops = &eth_em_ops;
     286                 :          0 :         eth_dev->rx_queue_count = eth_em_rx_queue_count;
     287                 :          0 :         eth_dev->rx_descriptor_status = eth_em_rx_descriptor_status;
     288                 :          0 :         eth_dev->tx_descriptor_status = eth_em_tx_descriptor_status;
     289                 :          0 :         eth_dev->rx_pkt_burst = (eth_rx_burst_t)&eth_em_recv_pkts;
     290                 :          0 :         eth_dev->tx_pkt_burst = (eth_tx_burst_t)&eth_em_xmit_pkts;
     291                 :          0 :         eth_dev->tx_pkt_prepare = (eth_tx_prep_t)&eth_em_prep_pkts;
     292                 :            : 
     293                 :            :         /* for secondary processes, we don't initialise any further as primary
     294                 :            :          * has already done this work. Only check we don't need a different
     295                 :            :          * RX function */
     296         [ #  # ]:          0 :         if (rte_eal_process_type() != RTE_PROC_PRIMARY){
     297         [ #  # ]:          0 :                 if (eth_dev->data->scattered_rx)
     298                 :          0 :                         eth_dev->rx_pkt_burst =
     299                 :            :                                 (eth_rx_burst_t)&eth_em_recv_scattered_pkts;
     300                 :          0 :                 return 0;
     301                 :            :         }
     302                 :            : 
     303                 :          0 :         rte_eth_copy_pci_info(eth_dev, pci_dev);
     304                 :            : 
     305                 :          0 :         hw->hw_addr = (void *)pci_dev->mem_resource[0].addr;
     306                 :          0 :         hw->device_id = pci_dev->id.device_id;
     307                 :          0 :         adapter->stopped = 0;
     308                 :            : 
     309                 :            :         /* For ICH8 support we'll need to map the flash memory BAR */
     310         [ #  # ]:          0 :         if (eth_em_dev_is_ich8(hw))
     311                 :          0 :                 hw->flash_address = (void *)pci_dev->mem_resource[1].addr;
     312                 :            : 
     313   [ #  #  #  # ]:          0 :         if (e1000_setup_init_funcs(hw, TRUE) != E1000_SUCCESS ||
     314                 :          0 :                         em_hw_init(hw) != 0) {
     315                 :          0 :                 PMD_INIT_LOG(ERR, "port_id %d vendorID=0x%x deviceID=0x%x: "
     316                 :            :                         "failed to init HW",
     317                 :            :                         eth_dev->data->port_id, pci_dev->id.vendor_id,
     318                 :            :                         pci_dev->id.device_id);
     319                 :          0 :                 return -ENODEV;
     320                 :            :         }
     321                 :            : 
     322                 :            :         /* Allocate memory for storing MAC addresses */
     323                 :          0 :         eth_dev->data->mac_addrs = rte_zmalloc("e1000", RTE_ETHER_ADDR_LEN *
     324                 :          0 :                         hw->mac.rar_entry_count, 0);
     325         [ #  # ]:          0 :         if (eth_dev->data->mac_addrs == NULL) {
     326                 :          0 :                 PMD_INIT_LOG(ERR, "Failed to allocate %d bytes needed to "
     327                 :            :                         "store MAC addresses",
     328                 :            :                         RTE_ETHER_ADDR_LEN * hw->mac.rar_entry_count);
     329                 :          0 :                 return -ENOMEM;
     330                 :            :         }
     331                 :            : 
     332                 :            :         /* Copy the permanent MAC address */
     333                 :            :         rte_ether_addr_copy((struct rte_ether_addr *)hw->mac.addr,
     334                 :            :                 eth_dev->data->mac_addrs);
     335                 :            : 
     336                 :            :         /* initialize the vfta */
     337                 :            :         memset(shadow_vfta, 0, sizeof(*shadow_vfta));
     338                 :            : 
     339                 :          0 :         PMD_INIT_LOG(DEBUG, "port_id %d vendorID=0x%x deviceID=0x%x",
     340                 :            :                      eth_dev->data->port_id, pci_dev->id.vendor_id,
     341                 :            :                      pci_dev->id.device_id);
     342                 :            : 
     343                 :          0 :         rte_intr_callback_register(intr_handle,
     344                 :            :                                    eth_em_interrupt_handler, eth_dev);
     345                 :            : 
     346                 :          0 :         return 0;
     347                 :            : }
     348                 :            : 
     349                 :            : static int
     350                 :          0 : eth_em_dev_uninit(struct rte_eth_dev *eth_dev)
     351                 :            : {
     352                 :          0 :         PMD_INIT_FUNC_TRACE();
     353                 :            : 
     354         [ #  # ]:          0 :         if (rte_eal_process_type() != RTE_PROC_PRIMARY)
     355                 :            :                 return 0;
     356                 :            : 
     357                 :          0 :         eth_em_close(eth_dev);
     358                 :            : 
     359                 :          0 :         return 0;
     360                 :            : }
     361                 :            : 
     362                 :          0 : static int eth_em_pci_probe(struct rte_pci_driver *pci_drv __rte_unused,
     363                 :            :         struct rte_pci_device *pci_dev)
     364                 :            : {
     365                 :          0 :         return rte_eth_dev_pci_generic_probe(pci_dev,
     366                 :            :                 sizeof(struct e1000_adapter), eth_em_dev_init);
     367                 :            : }
     368                 :            : 
     369                 :          0 : static int eth_em_pci_remove(struct rte_pci_device *pci_dev)
     370                 :            : {
     371                 :          0 :         return rte_eth_dev_pci_generic_remove(pci_dev, eth_em_dev_uninit);
     372                 :            : }
     373                 :            : 
     374                 :            : static struct rte_pci_driver rte_em_pmd = {
     375                 :            :         .id_table = pci_id_em_map,
     376                 :            :         .drv_flags = RTE_PCI_DRV_NEED_MAPPING | RTE_PCI_DRV_INTR_LSC,
     377                 :            :         .probe = eth_em_pci_probe,
     378                 :            :         .remove = eth_em_pci_remove,
     379                 :            : };
     380                 :            : 
     381                 :            : static int
     382                 :          0 : em_hw_init(struct e1000_hw *hw)
     383                 :            : {
     384                 :            :         int diag;
     385                 :            : 
     386                 :          0 :         diag = hw->mac.ops.init_params(hw);
     387         [ #  # ]:          0 :         if (diag != 0) {
     388                 :          0 :                 PMD_INIT_LOG(ERR, "MAC Initialization Error");
     389                 :          0 :                 return diag;
     390                 :            :         }
     391                 :          0 :         diag = hw->nvm.ops.init_params(hw);
     392         [ #  # ]:          0 :         if (diag != 0) {
     393                 :          0 :                 PMD_INIT_LOG(ERR, "NVM Initialization Error");
     394                 :          0 :                 return diag;
     395                 :            :         }
     396                 :          0 :         diag = hw->phy.ops.init_params(hw);
     397         [ #  # ]:          0 :         if (diag != 0) {
     398                 :          0 :                 PMD_INIT_LOG(ERR, "PHY Initialization Error");
     399                 :          0 :                 return diag;
     400                 :            :         }
     401                 :          0 :         (void) e1000_get_bus_info(hw);
     402                 :            : 
     403                 :          0 :         hw->mac.autoneg = 1;
     404                 :          0 :         hw->phy.autoneg_wait_to_complete = 0;
     405                 :          0 :         hw->phy.autoneg_advertised = E1000_ALL_SPEED_DUPLEX;
     406                 :            : 
     407                 :          0 :         e1000_init_script_state_82541(hw, TRUE);
     408                 :          0 :         e1000_set_tbi_compatibility_82543(hw, TRUE);
     409                 :            : 
     410                 :            :         /* Copper options */
     411         [ #  # ]:          0 :         if (hw->phy.media_type == e1000_media_type_copper) {
     412                 :          0 :                 hw->phy.mdix = 0; /* AUTO_ALL_MODES */
     413                 :          0 :                 hw->phy.disable_polarity_correction = 0;
     414                 :          0 :                 hw->phy.ms_type = e1000_ms_hw_default;
     415                 :            :         }
     416                 :            : 
     417                 :            :         /*
     418                 :            :          * Start from a known state, this is important in reading the nvm
     419                 :            :          * and mac from that.
     420                 :            :          */
     421                 :          0 :         e1000_reset_hw(hw);
     422                 :            : 
     423                 :            :         /* Make sure we have a good EEPROM before we read from it */
     424         [ #  # ]:          0 :         if (e1000_validate_nvm_checksum(hw) < 0) {
     425                 :            :                 /*
     426                 :            :                  * Some PCI-E parts fail the first check due to
     427                 :            :                  * the link being in sleep state, call it again,
     428                 :            :                  * if it fails a second time its a real issue.
     429                 :            :                  */
     430                 :          0 :                 diag = e1000_validate_nvm_checksum(hw);
     431         [ #  # ]:          0 :                 if (diag < 0) {
     432                 :          0 :                         PMD_INIT_LOG(ERR, "EEPROM checksum invalid");
     433                 :          0 :                         goto error;
     434                 :            :                 }
     435                 :            :         }
     436                 :            : 
     437                 :            :         /* Read the permanent MAC address out of the EEPROM */
     438                 :          0 :         diag = e1000_read_mac_addr(hw);
     439         [ #  # ]:          0 :         if (diag != 0) {
     440                 :          0 :                 PMD_INIT_LOG(ERR, "EEPROM error while reading MAC address");
     441                 :          0 :                 goto error;
     442                 :            :         }
     443                 :            : 
     444                 :            :         /* Now initialize the hardware */
     445                 :          0 :         diag = em_hardware_init(hw);
     446         [ #  # ]:          0 :         if (diag != 0) {
     447                 :          0 :                 PMD_INIT_LOG(ERR, "Hardware initialization failed");
     448                 :          0 :                 goto error;
     449                 :            :         }
     450                 :            : 
     451                 :          0 :         hw->mac.get_link_status = 1;
     452                 :            : 
     453                 :            :         /* Indicate SOL/IDER usage */
     454                 :          0 :         diag = e1000_check_reset_block(hw);
     455         [ #  # ]:          0 :         if (diag < 0) {
     456                 :          0 :                 PMD_INIT_LOG(ERR, "PHY reset is blocked due to "
     457                 :            :                         "SOL/IDER session");
     458                 :            :         }
     459                 :            :         return 0;
     460                 :            : 
     461                 :          0 : error:
     462                 :            :         em_hw_control_release(hw);
     463                 :            :         return diag;
     464                 :            : }
     465                 :            : 
     466                 :            : static int
     467                 :          0 : eth_em_configure(struct rte_eth_dev *dev)
     468                 :            : {
     469                 :            :         struct e1000_interrupt *intr =
     470                 :          0 :                 E1000_DEV_PRIVATE_TO_INTR(dev->data->dev_private);
     471                 :            : 
     472                 :          0 :         PMD_INIT_FUNC_TRACE();
     473                 :          0 :         intr->flags |= E1000_FLAG_NEED_LINK_UPDATE;
     474                 :            : 
     475                 :          0 :         PMD_INIT_FUNC_TRACE();
     476                 :            : 
     477                 :          0 :         return 0;
     478                 :            : }
     479                 :            : 
     480                 :            : static void
     481                 :            : em_set_pba(struct e1000_hw *hw)
     482                 :            : {
     483                 :            :         uint32_t pba;
     484                 :            : 
     485                 :            :         /*
     486                 :            :          * Packet Buffer Allocation (PBA)
     487                 :            :          * Writing PBA sets the receive portion of the buffer
     488                 :            :          * the remainder is used for the transmit buffer.
     489                 :            :          * Devices before the 82547 had a Packet Buffer of 64K.
     490                 :            :          * After the 82547 the buffer was reduced to 40K.
     491                 :            :          */
     492         [ #  # ]:          0 :         switch (hw->mac.type) {
     493                 :            :                 case e1000_82547:
     494                 :            :                 case e1000_82547_rev_2:
     495                 :            :                 /* 82547: Total Packet Buffer is 40K */
     496                 :            :                         pba = E1000_PBA_22K; /* 22K for Rx, 18K for Tx */
     497                 :            :                         break;
     498                 :            :                 case e1000_82571:
     499                 :            :                 case e1000_82572:
     500                 :            :                 case e1000_80003es2lan:
     501                 :            :                         pba = E1000_PBA_32K; /* 32K for Rx, 16K for Tx */
     502                 :            :                         break;
     503                 :            :                 case e1000_82573: /* 82573: Total Packet Buffer is 32K */
     504                 :            :                         pba = E1000_PBA_12K; /* 12K for Rx, 20K for Tx */
     505                 :            :                         break;
     506                 :            :                 case e1000_82574:
     507                 :            :                 case e1000_82583:
     508                 :            :                         pba = E1000_PBA_20K; /* 20K for Rx, 20K for Tx */
     509                 :            :                         break;
     510                 :            :                 case e1000_ich8lan:
     511                 :            :                         pba = E1000_PBA_8K;
     512                 :            :                         break;
     513                 :            :                 case e1000_ich9lan:
     514                 :            :                 case e1000_ich10lan:
     515                 :            :                         pba = E1000_PBA_10K;
     516                 :            :                         break;
     517                 :            :                 case e1000_pchlan:
     518                 :            :                 case e1000_pch2lan:
     519                 :            :                 case e1000_pch_lpt:
     520                 :            :                 case e1000_pch_spt:
     521                 :            :                 case e1000_pch_cnp:
     522                 :            :                 case e1000_pch_adp:
     523                 :            :                 case e1000_pch_tgp:
     524                 :            :                 case e1000_pch_mtp:
     525                 :            :                 case e1000_pch_ptp:
     526                 :            :                         pba = E1000_PBA_26K;
     527                 :            :                         break;
     528                 :            :                 default:
     529                 :            :                         pba = E1000_PBA_40K; /* 40K for Rx, 24K for Tx */
     530                 :            :         }
     531                 :            : 
     532                 :          0 :         E1000_WRITE_REG(hw, E1000_PBA, pba);
     533                 :            : }
     534                 :            : 
     535                 :            : static void
     536                 :          0 : eth_em_rxtx_control(struct rte_eth_dev *dev,
     537                 :            :                     bool enable)
     538                 :            : {
     539                 :            :         struct e1000_hw *hw =
     540                 :          0 :                 E1000_DEV_PRIVATE_TO_HW(dev->data->dev_private);
     541                 :            :         uint32_t tctl, rctl;
     542                 :            : 
     543                 :          0 :         tctl = E1000_READ_REG(hw, E1000_TCTL);
     544                 :          0 :         rctl = E1000_READ_REG(hw, E1000_RCTL);
     545         [ #  # ]:          0 :         if (enable) {
     546                 :            :                 /* enable Tx/Rx */
     547                 :          0 :                 tctl |= E1000_TCTL_EN;
     548                 :          0 :                 rctl |= E1000_RCTL_EN;
     549                 :            :         } else {
     550                 :            :                 /* disable Tx/Rx */
     551                 :          0 :                 tctl &= ~E1000_TCTL_EN;
     552                 :          0 :                 rctl &= ~E1000_RCTL_EN;
     553                 :            :         }
     554                 :          0 :         E1000_WRITE_REG(hw, E1000_TCTL, tctl);
     555                 :          0 :         E1000_WRITE_REG(hw, E1000_RCTL, rctl);
     556                 :          0 :         E1000_WRITE_FLUSH(hw);
     557                 :          0 : }
     558                 :            : 
     559                 :            : static int
     560                 :          0 : eth_em_start(struct rte_eth_dev *dev)
     561                 :            : {
     562                 :          0 :         struct e1000_adapter *adapter =
     563                 :          0 :                 E1000_DEV_PRIVATE(dev->data->dev_private);
     564                 :          0 :         struct e1000_hw *hw =
     565                 :            :                 E1000_DEV_PRIVATE_TO_HW(dev->data->dev_private);
     566                 :          0 :         struct rte_pci_device *pci_dev = RTE_ETH_DEV_TO_PCI(dev);
     567                 :          0 :         struct rte_intr_handle *intr_handle = pci_dev->intr_handle;
     568                 :            :         int ret, mask;
     569                 :            :         uint32_t intr_vector = 0;
     570                 :            :         uint32_t *speeds;
     571                 :            :         int num_speeds;
     572                 :            :         bool autoneg;
     573                 :            : 
     574                 :          0 :         PMD_INIT_FUNC_TRACE();
     575                 :            : 
     576                 :            :         /*
     577                 :            :          * This function calls into the base driver, which in turn will use
     578                 :            :          * function pointers, which are not guaranteed to be valid in secondary
     579                 :            :          * processes, so avoid using this function in secondary processes.
     580                 :            :          */
     581         [ #  # ]:          0 :         if (rte_eal_process_type() != RTE_PROC_PRIMARY)
     582                 :            :                 return -E_RTE_SECONDARY;
     583                 :            : 
     584                 :          0 :         ret = eth_em_stop(dev);
     585         [ #  # ]:          0 :         if (ret != 0)
     586                 :            :                 return ret;
     587                 :            : 
     588                 :          0 :         e1000_power_up_phy(hw);
     589                 :            : 
     590                 :            :         /* Set default PBA value */
     591                 :            :         em_set_pba(hw);
     592                 :            : 
     593                 :            :         /* Put the address into the Receive Address Array */
     594                 :          0 :         e1000_rar_set(hw, hw->mac.addr, 0);
     595                 :            : 
     596                 :            :         /*
     597                 :            :          * With the 82571 adapter, RAR[0] may be overwritten
     598                 :            :          * when the other port is reset, we make a duplicate
     599                 :            :          * in RAR[14] for that eventuality, this assures
     600                 :            :          * the interface continues to function.
     601                 :            :          */
     602         [ #  # ]:          0 :         if (hw->mac.type == e1000_82571) {
     603                 :          0 :                 e1000_set_laa_state_82571(hw, TRUE);
     604                 :          0 :                 e1000_rar_set(hw, hw->mac.addr, E1000_RAR_ENTRIES - 1);
     605                 :            :         }
     606                 :            : 
     607                 :            :         /* Initialize the hardware */
     608         [ #  # ]:          0 :         if (em_hardware_init(hw)) {
     609                 :          0 :                 PMD_INIT_LOG(ERR, "Unable to initialize the hardware");
     610                 :          0 :                 return -EIO;
     611                 :            :         }
     612                 :            : 
     613                 :          0 :         E1000_WRITE_REG(hw, E1000_VET, RTE_ETHER_TYPE_VLAN);
     614                 :            : 
     615                 :            :         /* Configure for OS presence */
     616                 :          0 :         em_init_manageability(hw);
     617                 :            : 
     618         [ #  # ]:          0 :         if (dev->data->dev_conf.intr_conf.rxq != 0) {
     619                 :          0 :                 intr_vector = dev->data->nb_rx_queues;
     620         [ #  # ]:          0 :                 if (rte_intr_efd_enable(intr_handle, intr_vector))
     621                 :            :                         return -1;
     622                 :            :         }
     623                 :            : 
     624         [ #  # ]:          0 :         if (rte_intr_dp_is_en(intr_handle)) {
     625         [ #  # ]:          0 :                 if (rte_intr_vec_list_alloc(intr_handle, "intr_vec",
     626                 :          0 :                                                    dev->data->nb_rx_queues)) {
     627                 :          0 :                         PMD_INIT_LOG(ERR, "Failed to allocate %d rx_queues"
     628                 :            :                                      " intr_vec", dev->data->nb_rx_queues);
     629                 :          0 :                         return -ENOMEM;
     630                 :            :                 }
     631                 :            : 
     632                 :            :                 /* enable rx interrupt */
     633                 :            :                 em_rxq_intr_enable(hw);
     634                 :            :         }
     635                 :            : 
     636                 :          0 :         eth_em_tx_init(dev);
     637                 :            : 
     638                 :          0 :         ret = eth_em_rx_init(dev);
     639         [ #  # ]:          0 :         if (ret) {
     640                 :          0 :                 PMD_INIT_LOG(ERR, "Unable to initialize RX hardware");
     641                 :          0 :                 em_dev_clear_queues(dev);
     642                 :          0 :                 return ret;
     643                 :            :         }
     644                 :            : 
     645                 :          0 :         e1000_clear_hw_cntrs_base_generic(hw);
     646                 :            : 
     647                 :            :         mask = RTE_ETH_VLAN_STRIP_MASK | RTE_ETH_VLAN_FILTER_MASK |
     648                 :            :                         RTE_ETH_VLAN_EXTEND_MASK;
     649                 :          0 :         ret = eth_em_vlan_offload_set(dev, mask);
     650         [ #  # ]:          0 :         if (ret) {
     651                 :          0 :                 PMD_INIT_LOG(ERR, "Unable to update vlan offload");
     652                 :          0 :                 em_dev_clear_queues(dev);
     653                 :          0 :                 return ret;
     654                 :            :         }
     655                 :            : 
     656                 :            :         /* Set Interrupt Throttling Rate to maximum allowed value. */
     657                 :          0 :         E1000_WRITE_REG(hw, E1000_ITR, UINT16_MAX);
     658                 :            : 
     659                 :            :         /* Setup link speed and duplex */
     660                 :          0 :         speeds = &dev->data->dev_conf.link_speeds;
     661         [ #  # ]:          0 :         if (*speeds == RTE_ETH_LINK_SPEED_AUTONEG) {
     662                 :          0 :                 hw->phy.autoneg_advertised = E1000_ALL_SPEED_DUPLEX;
     663                 :          0 :                 hw->mac.autoneg = 1;
     664                 :            :         } else {
     665                 :            :                 num_speeds = 0;
     666                 :          0 :                 autoneg = (*speeds & RTE_ETH_LINK_SPEED_FIXED) == 0;
     667                 :            : 
     668                 :            :                 /* Reset */
     669                 :          0 :                 hw->phy.autoneg_advertised = 0;
     670                 :            : 
     671         [ #  # ]:          0 :                 if (*speeds & ~(RTE_ETH_LINK_SPEED_10M_HD | RTE_ETH_LINK_SPEED_10M |
     672                 :            :                                 RTE_ETH_LINK_SPEED_100M_HD | RTE_ETH_LINK_SPEED_100M |
     673                 :            :                                 RTE_ETH_LINK_SPEED_1G | RTE_ETH_LINK_SPEED_FIXED)) {
     674                 :            :                         num_speeds = -1;
     675                 :          0 :                         goto error_invalid_config;
     676                 :            :                 }
     677         [ #  # ]:          0 :                 if (*speeds & RTE_ETH_LINK_SPEED_10M_HD) {
     678                 :          0 :                         hw->phy.autoneg_advertised |= ADVERTISE_10_HALF;
     679                 :            :                         num_speeds++;
     680                 :            :                 }
     681         [ #  # ]:          0 :                 if (*speeds & RTE_ETH_LINK_SPEED_10M) {
     682                 :          0 :                         hw->phy.autoneg_advertised |= ADVERTISE_10_FULL;
     683                 :          0 :                         num_speeds++;
     684                 :            :                 }
     685         [ #  # ]:          0 :                 if (*speeds & RTE_ETH_LINK_SPEED_100M_HD) {
     686                 :          0 :                         hw->phy.autoneg_advertised |= ADVERTISE_100_HALF;
     687                 :          0 :                         num_speeds++;
     688                 :            :                 }
     689         [ #  # ]:          0 :                 if (*speeds & RTE_ETH_LINK_SPEED_100M) {
     690                 :          0 :                         hw->phy.autoneg_advertised |= ADVERTISE_100_FULL;
     691                 :          0 :                         num_speeds++;
     692                 :            :                 }
     693         [ #  # ]:          0 :                 if (*speeds & RTE_ETH_LINK_SPEED_1G) {
     694                 :          0 :                         hw->phy.autoneg_advertised |= ADVERTISE_1000_FULL;
     695                 :          0 :                         num_speeds++;
     696                 :            :                 }
     697   [ #  #  #  # ]:          0 :                 if (num_speeds == 0 || (!autoneg && (num_speeds > 1)))
     698                 :          0 :                         goto error_invalid_config;
     699                 :            : 
     700                 :            :                 /* Set/reset the mac.autoneg based on the link speed,
     701                 :            :                  * fixed or not
     702                 :            :                  */
     703         [ #  # ]:          0 :                 if (!autoneg) {
     704                 :          0 :                         hw->mac.autoneg = 0;
     705                 :          0 :                         hw->mac.forced_speed_duplex =
     706                 :          0 :                                         hw->phy.autoneg_advertised;
     707                 :            :                 } else {
     708                 :          0 :                         hw->mac.autoneg = 1;
     709                 :            :                 }
     710                 :            :         }
     711                 :            : 
     712                 :          0 :         e1000_setup_link(hw);
     713                 :            : 
     714         [ #  # ]:          0 :         if (rte_intr_allow_others(intr_handle)) {
     715                 :            :                 /* check if lsc interrupt is enabled */
     716         [ #  # ]:          0 :                 if (dev->data->dev_conf.intr_conf.lsc != 0) {
     717                 :            :                         ret = eth_em_interrupt_setup(dev);
     718                 :            :                         if (ret) {
     719                 :            :                                 PMD_INIT_LOG(ERR, "Unable to setup interrupts");
     720                 :            :                                 em_dev_clear_queues(dev);
     721                 :            :                                 return ret;
     722                 :            :                         }
     723                 :            :                 }
     724                 :            :         } else {
     725                 :          0 :                 rte_intr_callback_unregister(intr_handle,
     726                 :            :                                                 eth_em_interrupt_handler,
     727                 :            :                                                 (void *)dev);
     728         [ #  # ]:          0 :                 if (dev->data->dev_conf.intr_conf.lsc != 0)
     729                 :          0 :                         PMD_INIT_LOG(INFO, "lsc won't enable because of"
     730                 :            :                                      " no intr multiplexn");
     731                 :            :         }
     732                 :            :         /* check if rxq interrupt is enabled */
     733         [ #  # ]:          0 :         if (dev->data->dev_conf.intr_conf.rxq != 0)
     734                 :            :                 eth_em_rxq_interrupt_setup(dev);
     735                 :            : 
     736                 :          0 :         rte_intr_enable(intr_handle);
     737                 :            : 
     738                 :          0 :         adapter->stopped = 0;
     739                 :            : 
     740                 :          0 :         eth_em_rxtx_control(dev, true);
     741                 :          0 :         eth_em_link_update(dev, 0);
     742                 :            : 
     743                 :          0 :         PMD_INIT_LOG(DEBUG, "<<");
     744                 :            : 
     745                 :          0 :         return 0;
     746                 :            : 
     747                 :          0 : error_invalid_config:
     748                 :          0 :         PMD_INIT_LOG(ERR, "Invalid advertised speeds (%u) for port %u",
     749                 :            :                      dev->data->dev_conf.link_speeds, dev->data->port_id);
     750                 :          0 :         em_dev_clear_queues(dev);
     751                 :          0 :         return -EINVAL;
     752                 :            : }
     753                 :            : 
     754                 :            : /*********************************************************************
     755                 :            :  *
     756                 :            :  *  This routine disables all traffic on the adapter by issuing a
     757                 :            :  *  global reset on the MAC.
     758                 :            :  *
     759                 :            :  **********************************************************************/
     760                 :            : static int
     761                 :          0 : eth_em_stop(struct rte_eth_dev *dev)
     762                 :            : {
     763                 :            :         struct rte_eth_link link;
     764                 :          0 :         struct e1000_hw *hw = E1000_DEV_PRIVATE_TO_HW(dev->data->dev_private);
     765                 :          0 :         struct rte_pci_device *pci_dev = RTE_ETH_DEV_TO_PCI(dev);
     766                 :          0 :         struct rte_intr_handle *intr_handle = pci_dev->intr_handle;
     767                 :            : 
     768                 :            :         /*
     769                 :            :          * This function calls into the base driver, which in turn will use
     770                 :            :          * function pointers, which are not guaranteed to be valid in secondary
     771                 :            :          * processes, so avoid using this function in secondary processes.
     772                 :            :          */
     773         [ #  # ]:          0 :         if (rte_eal_process_type() != RTE_PROC_PRIMARY)
     774                 :            :                 return -E_RTE_SECONDARY;
     775                 :            : 
     776                 :          0 :         dev->data->dev_started = 0;
     777                 :            : 
     778                 :          0 :         eth_em_rxtx_control(dev, false);
     779                 :            :         em_rxq_intr_disable(hw);
     780                 :            :         em_lsc_intr_disable(hw);
     781                 :            : 
     782                 :          0 :         e1000_reset_hw(hw);
     783                 :            : 
     784                 :            :         /* Flush desc rings for i219 */
     785         [ #  # ]:          0 :         if (hw->mac.type == e1000_pch_spt || hw->mac.type == e1000_pch_cnp)
     786                 :          0 :                 em_flush_desc_rings(dev);
     787                 :            : 
     788         [ #  # ]:          0 :         if (hw->mac.type >= e1000_82544)
     789                 :          0 :                 E1000_WRITE_REG(hw, E1000_WUC, 0);
     790                 :            : 
     791                 :            :         /* Power down the phy. Needed to make the link go down */
     792                 :          0 :         e1000_power_down_phy(hw);
     793                 :            : 
     794                 :          0 :         em_dev_clear_queues(dev);
     795                 :            : 
     796                 :            :         /* clear the recorded link status */
     797                 :            :         memset(&link, 0, sizeof(link));
     798                 :          0 :         rte_eth_linkstatus_set(dev, &link);
     799                 :            : 
     800         [ #  # ]:          0 :         if (!rte_intr_allow_others(intr_handle))
     801                 :            :                 /* resume to the default handler */
     802                 :          0 :                 rte_intr_callback_register(intr_handle,
     803                 :            :                                            eth_em_interrupt_handler,
     804                 :            :                                            (void *)dev);
     805                 :            : 
     806                 :            :         /* Clean datapath event and queue/vec mapping */
     807                 :          0 :         rte_intr_efd_disable(intr_handle);
     808                 :          0 :         rte_intr_vec_list_free(intr_handle);
     809                 :            : 
     810                 :          0 :         return 0;
     811                 :            : }
     812                 :            : 
     813                 :            : static int
     814                 :          0 : eth_em_close(struct rte_eth_dev *dev)
     815                 :            : {
     816                 :          0 :         struct e1000_hw *hw = E1000_DEV_PRIVATE_TO_HW(dev->data->dev_private);
     817                 :            :         struct e1000_adapter *adapter =
     818                 :            :                 E1000_DEV_PRIVATE(dev->data->dev_private);
     819                 :          0 :         struct rte_pci_device *pci_dev = RTE_ETH_DEV_TO_PCI(dev);
     820                 :          0 :         struct rte_intr_handle *intr_handle = pci_dev->intr_handle;
     821                 :            :         int ret;
     822                 :            : 
     823         [ #  # ]:          0 :         if (rte_eal_process_type() != RTE_PROC_PRIMARY)
     824                 :            :                 return 0;
     825                 :            : 
     826                 :          0 :         ret = eth_em_stop(dev);
     827                 :          0 :         adapter->stopped = 1;
     828                 :          0 :         em_dev_free_queues(dev);
     829                 :          0 :         e1000_phy_hw_reset(hw);
     830                 :          0 :         em_release_manageability(hw);
     831                 :            :         em_hw_control_release(hw);
     832                 :            : 
     833                 :            :         /* disable uio intr before callback unregister */
     834                 :          0 :         rte_intr_disable(intr_handle);
     835                 :          0 :         rte_intr_callback_unregister(intr_handle,
     836                 :            :                                      eth_em_interrupt_handler, dev);
     837                 :            : 
     838                 :          0 :         return ret;
     839                 :            : }
     840                 :            : 
     841                 :            : static int
     842                 :            : em_get_rx_buffer_size(struct e1000_hw *hw)
     843                 :            : {
     844                 :            :         uint32_t rx_buf_size;
     845                 :            : 
     846                 :          0 :         rx_buf_size = ((E1000_READ_REG(hw, E1000_PBA) & UINT16_MAX) << 10);
     847                 :            :         return rx_buf_size;
     848                 :            : }
     849                 :            : 
     850                 :            : /*********************************************************************
     851                 :            :  *
     852                 :            :  *  Initialize the hardware
     853                 :            :  *
     854                 :            :  **********************************************************************/
     855                 :            : static int
     856                 :          0 : em_hardware_init(struct e1000_hw *hw)
     857                 :            : {
     858                 :            :         uint32_t rx_buf_size;
     859                 :            :         int diag;
     860                 :            : 
     861                 :            :         /* Issue a global reset */
     862                 :          0 :         e1000_reset_hw(hw);
     863                 :            : 
     864                 :            :         /* Let the firmware know the OS is in control */
     865                 :            :         em_hw_control_acquire(hw);
     866                 :            : 
     867                 :            :         /*
     868                 :            :          * These parameters control the automatic generation (Tx) and
     869                 :            :          * response (Rx) to Ethernet PAUSE frames.
     870                 :            :          * - High water mark should allow for at least two standard size (1518)
     871                 :            :          *   frames to be received after sending an XOFF.
     872                 :            :          * - Low water mark works best when it is very near the high water mark.
     873                 :            :          *   This allows the receiver to restart by sending XON when it has
     874                 :            :          *   drained a bit. Here we use an arbitrary value of 1500 which will
     875                 :            :          *   restart after one full frame is pulled from the buffer. There
     876                 :            :          *   could be several smaller frames in the buffer and if so they will
     877                 :            :          *   not trigger the XON until their total number reduces the buffer
     878                 :            :          *   by 1500.
     879                 :            :          * - The pause time is fairly large at 1000 x 512ns = 512 usec.
     880                 :            :          */
     881                 :            :         rx_buf_size = em_get_rx_buffer_size(hw);
     882                 :            : 
     883                 :          0 :         hw->fc.high_water = rx_buf_size -
     884                 :            :                 PMD_ROUNDUP(RTE_ETHER_MAX_LEN * 2, 1024);
     885                 :          0 :         hw->fc.low_water = hw->fc.high_water - 1500;
     886                 :            : 
     887         [ #  # ]:          0 :         if (hw->mac.type == e1000_80003es2lan)
     888                 :          0 :                 hw->fc.pause_time = UINT16_MAX;
     889                 :            :         else
     890                 :          0 :                 hw->fc.pause_time = EM_FC_PAUSE_TIME;
     891                 :            : 
     892                 :          0 :         hw->fc.send_xon = 1;
     893                 :            : 
     894                 :            :         /* Set Flow control, use the tunable location if sane */
     895         [ #  # ]:          0 :         if (em_fc_setting <= e1000_fc_full)
     896                 :          0 :                 hw->fc.requested_mode = em_fc_setting;
     897                 :            :         else
     898                 :          0 :                 hw->fc.requested_mode = e1000_fc_none;
     899                 :            : 
     900                 :            :         /* Workaround: no TX flow ctrl for PCH */
     901         [ #  # ]:          0 :         if (hw->mac.type == e1000_pchlan)
     902                 :          0 :                 hw->fc.requested_mode = e1000_fc_rx_pause;
     903                 :            : 
     904                 :            :         /* Override - settings for PCH2LAN, ya its magic :) */
     905         [ #  # ]:          0 :         if (hw->mac.type == e1000_pch2lan) {
     906                 :          0 :                 hw->fc.high_water = 0x5C20;
     907                 :          0 :                 hw->fc.low_water = 0x5048;
     908                 :          0 :                 hw->fc.pause_time = 0x0650;
     909                 :          0 :                 hw->fc.refresh_time = 0x0400;
     910                 :          0 :         } else if (hw->mac.type == e1000_pch_lpt ||
     911                 :            :                    hw->mac.type == e1000_pch_spt ||
     912                 :            :                    hw->mac.type == e1000_pch_cnp ||
     913         [ #  # ]:          0 :                    hw->mac.type == e1000_pch_adp ||
     914         [ #  # ]:          0 :                    hw->mac.type == e1000_pch_tgp ||
     915         [ #  # ]:          0 :                    hw->mac.type == e1000_pch_mtp ||
     916                 :            :                    hw->mac.type == e1000_pch_ptp) {
     917                 :          0 :                 hw->fc.requested_mode = e1000_fc_full;
     918                 :            :         }
     919                 :            : 
     920                 :          0 :         diag = e1000_init_hw(hw);
     921         [ #  # ]:          0 :         if (diag < 0)
     922                 :            :                 return diag;
     923                 :          0 :         e1000_check_for_link(hw);
     924                 :          0 :         return 0;
     925                 :            : }
     926                 :            : 
     927                 :            : /* This function is based on em_update_stats_counters() in e1000/if_em.c */
     928                 :            : static int
     929                 :          0 : eth_em_stats_get(struct rte_eth_dev *dev, struct rte_eth_stats *rte_stats)
     930                 :            : {
     931                 :          0 :         struct e1000_hw *hw = E1000_DEV_PRIVATE_TO_HW(dev->data->dev_private);
     932                 :            :         struct e1000_hw_stats *stats =
     933                 :            :                         E1000_DEV_PRIVATE_TO_STATS(dev->data->dev_private);
     934                 :            :         int pause_frames;
     935                 :            : 
     936         [ #  # ]:          0 :         if(hw->phy.media_type == e1000_media_type_copper ||
     937         [ #  # ]:          0 :                         (E1000_READ_REG(hw, E1000_STATUS) & E1000_STATUS_LU)) {
     938                 :          0 :                 stats->symerrs += E1000_READ_REG(hw,E1000_SYMERRS);
     939                 :          0 :                 stats->sec += E1000_READ_REG(hw, E1000_SEC);
     940                 :            :         }
     941                 :            : 
     942                 :          0 :         stats->crcerrs += E1000_READ_REG(hw, E1000_CRCERRS);
     943                 :          0 :         stats->mpc += E1000_READ_REG(hw, E1000_MPC);
     944                 :          0 :         stats->scc += E1000_READ_REG(hw, E1000_SCC);
     945                 :          0 :         stats->ecol += E1000_READ_REG(hw, E1000_ECOL);
     946                 :            : 
     947                 :          0 :         stats->mcc += E1000_READ_REG(hw, E1000_MCC);
     948                 :          0 :         stats->latecol += E1000_READ_REG(hw, E1000_LATECOL);
     949                 :          0 :         stats->colc += E1000_READ_REG(hw, E1000_COLC);
     950                 :          0 :         stats->dc += E1000_READ_REG(hw, E1000_DC);
     951                 :          0 :         stats->rlec += E1000_READ_REG(hw, E1000_RLEC);
     952                 :          0 :         stats->xonrxc += E1000_READ_REG(hw, E1000_XONRXC);
     953                 :          0 :         stats->xontxc += E1000_READ_REG(hw, E1000_XONTXC);
     954                 :            : 
     955                 :            :         /*
     956                 :            :          * For watchdog management we need to know if we have been
     957                 :            :          * paused during the last interval, so capture that here.
     958                 :            :          */
     959                 :          0 :         pause_frames = E1000_READ_REG(hw, E1000_XOFFRXC);
     960                 :          0 :         stats->xoffrxc += pause_frames;
     961                 :          0 :         stats->xofftxc += E1000_READ_REG(hw, E1000_XOFFTXC);
     962                 :          0 :         stats->fcruc += E1000_READ_REG(hw, E1000_FCRUC);
     963                 :          0 :         stats->prc64 += E1000_READ_REG(hw, E1000_PRC64);
     964                 :          0 :         stats->prc127 += E1000_READ_REG(hw, E1000_PRC127);
     965                 :          0 :         stats->prc255 += E1000_READ_REG(hw, E1000_PRC255);
     966                 :          0 :         stats->prc511 += E1000_READ_REG(hw, E1000_PRC511);
     967                 :          0 :         stats->prc1023 += E1000_READ_REG(hw, E1000_PRC1023);
     968                 :          0 :         stats->prc1522 += E1000_READ_REG(hw, E1000_PRC1522);
     969                 :          0 :         stats->gprc += E1000_READ_REG(hw, E1000_GPRC);
     970                 :          0 :         stats->bprc += E1000_READ_REG(hw, E1000_BPRC);
     971                 :          0 :         stats->mprc += E1000_READ_REG(hw, E1000_MPRC);
     972                 :          0 :         stats->gptc += E1000_READ_REG(hw, E1000_GPTC);
     973                 :            : 
     974                 :            :         /*
     975                 :            :          * For the 64-bit byte counters the low dword must be read first.
     976                 :            :          * Both registers clear on the read of the high dword.
     977                 :            :          */
     978                 :            : 
     979                 :          0 :         stats->gorc += E1000_READ_REG(hw, E1000_GORCL);
     980                 :          0 :         stats->gorc += ((uint64_t)E1000_READ_REG(hw, E1000_GORCH) << 32);
     981                 :          0 :         stats->gotc += E1000_READ_REG(hw, E1000_GOTCL);
     982                 :          0 :         stats->gotc += ((uint64_t)E1000_READ_REG(hw, E1000_GOTCH) << 32);
     983                 :            : 
     984                 :          0 :         stats->rnbc += E1000_READ_REG(hw, E1000_RNBC);
     985                 :          0 :         stats->ruc += E1000_READ_REG(hw, E1000_RUC);
     986                 :          0 :         stats->rfc += E1000_READ_REG(hw, E1000_RFC);
     987                 :          0 :         stats->roc += E1000_READ_REG(hw, E1000_ROC);
     988                 :          0 :         stats->rjc += E1000_READ_REG(hw, E1000_RJC);
     989                 :            : 
     990                 :          0 :         stats->tor += E1000_READ_REG(hw, E1000_TORH);
     991                 :          0 :         stats->tot += E1000_READ_REG(hw, E1000_TOTH);
     992                 :            : 
     993                 :          0 :         stats->tpr += E1000_READ_REG(hw, E1000_TPR);
     994                 :          0 :         stats->tpt += E1000_READ_REG(hw, E1000_TPT);
     995                 :          0 :         stats->ptc64 += E1000_READ_REG(hw, E1000_PTC64);
     996                 :          0 :         stats->ptc127 += E1000_READ_REG(hw, E1000_PTC127);
     997                 :          0 :         stats->ptc255 += E1000_READ_REG(hw, E1000_PTC255);
     998                 :          0 :         stats->ptc511 += E1000_READ_REG(hw, E1000_PTC511);
     999                 :          0 :         stats->ptc1023 += E1000_READ_REG(hw, E1000_PTC1023);
    1000                 :          0 :         stats->ptc1522 += E1000_READ_REG(hw, E1000_PTC1522);
    1001                 :          0 :         stats->mptc += E1000_READ_REG(hw, E1000_MPTC);
    1002                 :          0 :         stats->bptc += E1000_READ_REG(hw, E1000_BPTC);
    1003                 :            : 
    1004                 :            :         /* Interrupt Counts */
    1005                 :            : 
    1006         [ #  # ]:          0 :         if (hw->mac.type >= e1000_82571) {
    1007                 :          0 :                 stats->iac += E1000_READ_REG(hw, E1000_IAC);
    1008                 :          0 :                 stats->icrxptc += E1000_READ_REG(hw, E1000_ICRXPTC);
    1009                 :          0 :                 stats->icrxatc += E1000_READ_REG(hw, E1000_ICRXATC);
    1010                 :          0 :                 stats->ictxptc += E1000_READ_REG(hw, E1000_ICTXPTC);
    1011                 :          0 :                 stats->ictxatc += E1000_READ_REG(hw, E1000_ICTXATC);
    1012                 :          0 :                 stats->ictxqec += E1000_READ_REG(hw, E1000_ICTXQEC);
    1013                 :          0 :                 stats->ictxqmtc += E1000_READ_REG(hw, E1000_ICTXQMTC);
    1014                 :          0 :                 stats->icrxdmtc += E1000_READ_REG(hw, E1000_ICRXDMTC);
    1015                 :          0 :                 stats->icrxoc += E1000_READ_REG(hw, E1000_ICRXOC);
    1016                 :            :         }
    1017                 :            : 
    1018         [ #  # ]:          0 :         if (hw->mac.type >= e1000_82543) {
    1019                 :          0 :                 stats->algnerrc += E1000_READ_REG(hw, E1000_ALGNERRC);
    1020                 :          0 :                 stats->rxerrc += E1000_READ_REG(hw, E1000_RXERRC);
    1021                 :          0 :                 stats->tncrs += E1000_READ_REG(hw, E1000_TNCRS);
    1022                 :          0 :                 stats->cexterr += E1000_READ_REG(hw, E1000_CEXTERR);
    1023                 :          0 :                 stats->tsctc += E1000_READ_REG(hw, E1000_TSCTC);
    1024                 :          0 :                 stats->tsctfc += E1000_READ_REG(hw, E1000_TSCTFC);
    1025                 :            :         }
    1026                 :            : 
    1027         [ #  # ]:          0 :         if (rte_stats == NULL)
    1028                 :            :                 return -EINVAL;
    1029                 :            : 
    1030                 :            :         /* Rx Errors */
    1031                 :          0 :         rte_stats->imissed = stats->mpc;
    1032                 :          0 :         rte_stats->ierrors = stats->crcerrs + stats->rlec +
    1033                 :          0 :                              stats->rxerrc + stats->algnerrc + stats->cexterr;
    1034                 :            : 
    1035                 :            :         /* Tx Errors */
    1036                 :          0 :         rte_stats->oerrors = stats->ecol + stats->latecol;
    1037                 :            : 
    1038                 :          0 :         rte_stats->ipackets = stats->gprc;
    1039                 :          0 :         rte_stats->opackets = stats->gptc;
    1040                 :          0 :         rte_stats->ibytes   = stats->gorc;
    1041                 :          0 :         rte_stats->obytes   = stats->gotc;
    1042                 :          0 :         return 0;
    1043                 :            : }
    1044                 :            : 
    1045                 :            : static int
    1046                 :          0 : eth_em_stats_reset(struct rte_eth_dev *dev)
    1047                 :            : {
    1048                 :          0 :         struct e1000_hw_stats *hw_stats =
    1049                 :          0 :                         E1000_DEV_PRIVATE_TO_STATS(dev->data->dev_private);
    1050                 :            : 
    1051                 :            :         /* HW registers are cleared on read */
    1052                 :          0 :         eth_em_stats_get(dev, NULL);
    1053                 :            : 
    1054                 :            :         /* Reset software totals */
    1055                 :            :         memset(hw_stats, 0, sizeof(*hw_stats));
    1056                 :            : 
    1057                 :          0 :         return 0;
    1058                 :            : }
    1059                 :            : 
    1060                 :            : static int
    1061                 :          0 : eth_em_rx_queue_intr_enable(struct rte_eth_dev *dev, __rte_unused uint16_t queue_id)
    1062                 :            : {
    1063                 :          0 :         struct e1000_hw *hw = E1000_DEV_PRIVATE_TO_HW(dev->data->dev_private);
    1064                 :          0 :         struct rte_pci_device *pci_dev = RTE_ETH_DEV_TO_PCI(dev);
    1065                 :          0 :         struct rte_intr_handle *intr_handle = pci_dev->intr_handle;
    1066                 :            : 
    1067                 :            :         /* device interrupts are only subscribed to in primary processes */
    1068         [ #  # ]:          0 :         if (rte_eal_process_type() != RTE_PROC_PRIMARY)
    1069                 :            :                 return -E_RTE_SECONDARY;
    1070                 :            : 
    1071                 :            :         em_rxq_intr_enable(hw);
    1072                 :          0 :         rte_intr_ack(intr_handle);
    1073                 :            : 
    1074                 :          0 :         return 0;
    1075                 :            : }
    1076                 :            : 
    1077                 :            : static int
    1078                 :          0 : eth_em_rx_queue_intr_disable(struct rte_eth_dev *dev, __rte_unused uint16_t queue_id)
    1079                 :            : {
    1080                 :          0 :         struct e1000_hw *hw = E1000_DEV_PRIVATE_TO_HW(dev->data->dev_private);
    1081                 :            : 
    1082                 :            :         /* device interrupts are only subscribed to in primary processes */
    1083         [ #  # ]:          0 :         if (rte_eal_process_type() != RTE_PROC_PRIMARY)
    1084                 :            :                 return -E_RTE_SECONDARY;
    1085                 :            : 
    1086                 :            :         em_rxq_intr_disable(hw);
    1087                 :            : 
    1088                 :          0 :         return 0;
    1089                 :            : }
    1090                 :            : 
    1091                 :            : uint32_t
    1092                 :          0 : em_get_max_pktlen(struct rte_eth_dev *dev)
    1093                 :            : {
    1094                 :          0 :         struct e1000_hw *hw = E1000_DEV_PRIVATE_TO_HW(dev->data->dev_private);
    1095                 :            : 
    1096   [ #  #  #  # ]:          0 :         switch (hw->mac.type) {
    1097                 :            :         case e1000_82571:
    1098                 :            :         case e1000_82572:
    1099                 :            :         case e1000_ich9lan:
    1100                 :            :         case e1000_ich10lan:
    1101                 :            :         case e1000_pch2lan:
    1102                 :            :         case e1000_pch_lpt:
    1103                 :            :         case e1000_pch_spt:
    1104                 :            :         case e1000_pch_cnp:
    1105                 :            :         case e1000_pch_adp:
    1106                 :            :         case e1000_pch_tgp:
    1107                 :            :         case e1000_pch_mtp:
    1108                 :            :         case e1000_pch_ptp:
    1109                 :            :         case e1000_82574:
    1110                 :            :         case e1000_80003es2lan: /* 9K Jumbo Frame size */
    1111                 :            :         case e1000_82583:
    1112                 :            :                 return 0x2412;
    1113                 :          0 :         case e1000_pchlan:
    1114                 :          0 :                 return 0x1000;
    1115                 :            :         /* Adapters that do not support jumbo frames */
    1116                 :          0 :         case e1000_ich8lan:
    1117                 :          0 :                 return RTE_ETHER_MAX_LEN;
    1118                 :          0 :         default:
    1119                 :          0 :                 return MAX_JUMBO_FRAME_SIZE;
    1120                 :            :         }
    1121                 :            : }
    1122                 :            : 
    1123                 :            : static int
    1124                 :          0 : eth_em_infos_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info)
    1125                 :            : {
    1126                 :          0 :         struct e1000_hw *hw = E1000_DEV_PRIVATE_TO_HW(dev->data->dev_private);
    1127                 :            : 
    1128                 :          0 :         dev_info->min_rx_bufsize = 256; /* See BSIZE field of RCTL register. */
    1129                 :          0 :         dev_info->max_rx_pktlen = em_get_max_pktlen(dev);
    1130                 :          0 :         dev_info->max_mac_addrs = hw->mac.rar_entry_count;
    1131                 :            : 
    1132                 :            :         /*
    1133                 :            :          * Starting with 631xESB hw supports 2 TX/RX queues per port.
    1134                 :            :          * Unfortunately, all these nics have just one TX context.
    1135                 :            :          * So we have few choices for TX:
    1136                 :            :          * - Use just one TX queue.
    1137                 :            :          * - Allow cksum offload only for one TX queue.
    1138                 :            :          * - Don't allow TX cksum offload at all.
    1139                 :            :          * For now, option #1 was chosen.
    1140                 :            :          * To use second RX queue we have to use extended RX descriptor
    1141                 :            :          * (Multiple Receive Queues are mutually exclusive with UDP
    1142                 :            :          * fragmentation and are not supported when a legacy receive
    1143                 :            :          * descriptor format is used).
    1144                 :            :          * Which means separate RX routines - as legacy nics (82540, 82545)
    1145                 :            :          * don't support extended RXD.
    1146                 :            :          * To avoid it we support just one RX queue for now (no RSS).
    1147                 :            :          */
    1148                 :            : 
    1149                 :          0 :         dev_info->max_rx_queues = 2;
    1150                 :          0 :         dev_info->max_tx_queues = 2;
    1151                 :            : 
    1152                 :          0 :         dev_info->rx_queue_offload_capa = em_get_rx_queue_offloads_capa();
    1153                 :          0 :         dev_info->rx_offload_capa = em_get_rx_port_offloads_capa() |
    1154                 :          0 :                                     dev_info->rx_queue_offload_capa;
    1155                 :          0 :         dev_info->tx_queue_offload_capa = em_get_tx_queue_offloads_capa(dev);
    1156                 :          0 :         dev_info->tx_offload_capa = em_get_tx_port_offloads_capa(dev) |
    1157                 :          0 :                                     dev_info->tx_queue_offload_capa;
    1158                 :            : 
    1159                 :          0 :         dev_info->rx_desc_lim = (struct rte_eth_desc_lim) {
    1160                 :            :                 .nb_max = E1000_MAX_RING_DESC,
    1161                 :            :                 .nb_min = E1000_MIN_RING_DESC,
    1162                 :            :                 .nb_align = EM_RXD_ALIGN,
    1163                 :            :         };
    1164                 :            : 
    1165                 :          0 :         dev_info->tx_desc_lim = (struct rte_eth_desc_lim) {
    1166                 :            :                 .nb_max = E1000_MAX_RING_DESC,
    1167                 :            :                 .nb_min = E1000_MIN_RING_DESC,
    1168                 :            :                 .nb_align = EM_TXD_ALIGN,
    1169                 :            :                 .nb_seg_max = EM_TX_MAX_SEG,
    1170                 :            :                 .nb_mtu_seg_max = EM_TX_MAX_MTU_SEG,
    1171                 :            :         };
    1172                 :            : 
    1173                 :          0 :         dev_info->speed_capa = RTE_ETH_LINK_SPEED_10M_HD | RTE_ETH_LINK_SPEED_10M |
    1174                 :            :                         RTE_ETH_LINK_SPEED_100M_HD | RTE_ETH_LINK_SPEED_100M |
    1175                 :            :                         RTE_ETH_LINK_SPEED_1G;
    1176                 :            : 
    1177                 :          0 :         dev_info->dev_capa &= ~RTE_ETH_DEV_CAPA_FLOW_RULE_KEEP;
    1178                 :            : 
    1179                 :            :         /* Preferred queue parameters */
    1180                 :          0 :         dev_info->default_rxportconf.nb_queues = 1;
    1181                 :          0 :         dev_info->default_txportconf.nb_queues = 1;
    1182                 :          0 :         dev_info->default_txportconf.ring_size = 256;
    1183                 :          0 :         dev_info->default_rxportconf.ring_size = 256;
    1184                 :            : 
    1185                 :          0 :         return 0;
    1186                 :            : }
    1187                 :            : 
    1188                 :            : /* return 0 means link status changed, -1 means not changed */
    1189                 :            : static int
    1190                 :          0 : eth_em_link_update(struct rte_eth_dev *dev, int wait_to_complete)
    1191                 :            : {
    1192                 :          0 :         struct e1000_hw *hw =
    1193                 :          0 :                 E1000_DEV_PRIVATE_TO_HW(dev->data->dev_private);
    1194                 :            :         struct rte_eth_link link;
    1195                 :            :         int link_up, count;
    1196                 :            : 
    1197         [ #  # ]:          0 :         if (rte_eal_process_type() != RTE_PROC_PRIMARY)
    1198                 :            :                 return -1;
    1199                 :            : 
    1200                 :            :         link_up = 0;
    1201                 :          0 :         hw->mac.get_link_status = 1;
    1202                 :            : 
    1203                 :            :         /* possible wait-to-complete in up to 9 seconds */
    1204         [ #  # ]:          0 :         for (count = 0; count < EM_LINK_UPDATE_CHECK_TIMEOUT; count ++) {
    1205                 :            :                 /* Read the real link status */
    1206   [ #  #  #  # ]:          0 :                 switch (hw->phy.media_type) {
    1207                 :          0 :                 case e1000_media_type_copper:
    1208                 :            :                         /* Do the work to read phy */
    1209                 :          0 :                         e1000_check_for_link(hw);
    1210                 :          0 :                         link_up = !hw->mac.get_link_status;
    1211                 :          0 :                         break;
    1212                 :            : 
    1213                 :          0 :                 case e1000_media_type_fiber:
    1214                 :          0 :                         e1000_check_for_link(hw);
    1215                 :          0 :                         link_up = (E1000_READ_REG(hw, E1000_STATUS) &
    1216                 :            :                                         E1000_STATUS_LU);
    1217                 :          0 :                         break;
    1218                 :            : 
    1219                 :          0 :                 case e1000_media_type_internal_serdes:
    1220                 :          0 :                         e1000_check_for_link(hw);
    1221                 :          0 :                         link_up = hw->mac.serdes_has_link;
    1222                 :          0 :                         break;
    1223                 :            : 
    1224                 :            :                 default:
    1225                 :            :                         break;
    1226                 :            :                 }
    1227         [ #  # ]:          0 :                 if (link_up || wait_to_complete == 0)
    1228                 :            :                         break;
    1229                 :            :                 rte_delay_ms(EM_LINK_UPDATE_CHECK_INTERVAL);
    1230                 :            :         }
    1231                 :            :         memset(&link, 0, sizeof(link));
    1232                 :            : 
    1233                 :            :         /* Now we check if a transition has happened */
    1234         [ #  # ]:          0 :         if (link_up) {
    1235                 :            :                 uint16_t duplex, speed;
    1236                 :          0 :                 hw->mac.ops.get_link_up_info(hw, &speed, &duplex);
    1237                 :          0 :                 link.link_duplex = (duplex == FULL_DUPLEX) ?
    1238                 :          0 :                                 RTE_ETH_LINK_FULL_DUPLEX :
    1239                 :            :                                 RTE_ETH_LINK_HALF_DUPLEX;
    1240                 :          0 :                 link.link_speed = speed;
    1241                 :          0 :                 link.link_status = RTE_ETH_LINK_UP;
    1242                 :          0 :                 link.link_autoneg = !(dev->data->dev_conf.link_speeds &
    1243                 :            :                                 RTE_ETH_LINK_SPEED_FIXED);
    1244                 :            :         } else {
    1245                 :            :                 link.link_speed = RTE_ETH_SPEED_NUM_NONE;
    1246                 :            :                 link.link_duplex = RTE_ETH_LINK_HALF_DUPLEX;
    1247                 :            :                 link.link_status = RTE_ETH_LINK_DOWN;
    1248                 :            :                 link.link_autoneg = RTE_ETH_LINK_FIXED;
    1249                 :            :         }
    1250                 :            : 
    1251                 :            :         return rte_eth_linkstatus_set(dev, &link);
    1252                 :            : }
    1253                 :            : 
    1254                 :            : /*
    1255                 :            :  * em_hw_control_acquire sets {CTRL_EXT|FWSM}:DRV_LOAD bit.
    1256                 :            :  * For ASF and Pass Through versions of f/w this means
    1257                 :            :  * that the driver is loaded. For AMT version type f/w
    1258                 :            :  * this means that the network i/f is open.
    1259                 :            :  */
    1260                 :            : static void
    1261                 :            : em_hw_control_acquire(struct e1000_hw *hw)
    1262                 :            : {
    1263                 :            :         uint32_t ctrl_ext, swsm;
    1264                 :            : 
    1265                 :            :         /* Let firmware know the driver has taken over */
    1266         [ #  # ]:          0 :         if (hw->mac.type == e1000_82573) {
    1267                 :          0 :                 swsm = E1000_READ_REG(hw, E1000_SWSM);
    1268                 :          0 :                 E1000_WRITE_REG(hw, E1000_SWSM, swsm | E1000_SWSM_DRV_LOAD);
    1269                 :            : 
    1270                 :            :         } else {
    1271                 :          0 :                 ctrl_ext = E1000_READ_REG(hw, E1000_CTRL_EXT);
    1272                 :          0 :                 E1000_WRITE_REG(hw, E1000_CTRL_EXT,
    1273                 :            :                         ctrl_ext | E1000_CTRL_EXT_DRV_LOAD);
    1274                 :            :         }
    1275                 :            : }
    1276                 :            : 
    1277                 :            : /*
    1278                 :            :  * em_hw_control_release resets {CTRL_EXTT|FWSM}:DRV_LOAD bit.
    1279                 :            :  * For ASF and Pass Through versions of f/w this means that the
    1280                 :            :  * driver is no longer loaded. For AMT versions of the
    1281                 :            :  * f/w this means that the network i/f is closed.
    1282                 :            :  */
    1283                 :            : static void
    1284                 :            : em_hw_control_release(struct e1000_hw *hw)
    1285                 :            : {
    1286                 :            :         uint32_t ctrl_ext, swsm;
    1287                 :            : 
    1288                 :            :         /* Let firmware taken over control of h/w */
    1289   [ #  #  #  # ]:          0 :         if (hw->mac.type == e1000_82573) {
    1290                 :          0 :                 swsm = E1000_READ_REG(hw, E1000_SWSM);
    1291                 :          0 :                 E1000_WRITE_REG(hw, E1000_SWSM, swsm & ~E1000_SWSM_DRV_LOAD);
    1292                 :            :         } else {
    1293                 :          0 :                 ctrl_ext = E1000_READ_REG(hw, E1000_CTRL_EXT);
    1294                 :          0 :                 E1000_WRITE_REG(hw, E1000_CTRL_EXT,
    1295                 :            :                         ctrl_ext & ~E1000_CTRL_EXT_DRV_LOAD);
    1296                 :            :         }
    1297                 :            : }
    1298                 :            : 
    1299                 :            : /*
    1300                 :            :  * Bit of a misnomer, what this really means is
    1301                 :            :  * to enable OS management of the system... aka
    1302                 :            :  * to disable special hardware management features.
    1303                 :            :  */
    1304                 :            : static void
    1305                 :          0 : em_init_manageability(struct e1000_hw *hw)
    1306                 :            : {
    1307         [ #  # ]:          0 :         if (e1000_enable_mng_pass_thru(hw)) {
    1308                 :          0 :                 uint32_t manc2h = E1000_READ_REG(hw, E1000_MANC2H);
    1309                 :          0 :                 uint32_t manc = E1000_READ_REG(hw, E1000_MANC);
    1310                 :            : 
    1311                 :            :                 /* disable hardware interception of ARP */
    1312                 :          0 :                 manc &= ~(E1000_MANC_ARP_EN);
    1313                 :            : 
    1314                 :            :                 /* enable receiving management packets to the host */
    1315                 :          0 :                 manc |= E1000_MANC_EN_MNG2HOST;
    1316                 :            :                 manc2h |= 1 << 5;  /* Mng Port 623 */
    1317                 :          0 :                 manc2h |= 1 << 6;  /* Mng Port 664 */
    1318                 :          0 :                 E1000_WRITE_REG(hw, E1000_MANC2H, manc2h);
    1319                 :          0 :                 E1000_WRITE_REG(hw, E1000_MANC, manc);
    1320                 :            :         }
    1321                 :          0 : }
    1322                 :            : 
    1323                 :            : /*
    1324                 :            :  * Give control back to hardware management
    1325                 :            :  * controller if there is one.
    1326                 :            :  */
    1327                 :            : static void
    1328                 :          0 : em_release_manageability(struct e1000_hw *hw)
    1329                 :            : {
    1330                 :            :         uint32_t manc;
    1331                 :            : 
    1332         [ #  # ]:          0 :         if (e1000_enable_mng_pass_thru(hw)) {
    1333                 :          0 :                 manc = E1000_READ_REG(hw, E1000_MANC);
    1334                 :            : 
    1335                 :            :                 /* re-enable hardware interception of ARP */
    1336                 :            :                 manc |= E1000_MANC_ARP_EN;
    1337                 :          0 :                 manc &= ~E1000_MANC_EN_MNG2HOST;
    1338                 :            : 
    1339                 :          0 :                 E1000_WRITE_REG(hw, E1000_MANC, manc);
    1340                 :            :         }
    1341                 :          0 : }
    1342                 :            : 
    1343                 :            : static int
    1344                 :          0 : eth_em_promiscuous_enable(struct rte_eth_dev *dev)
    1345                 :            : {
    1346                 :            :         struct e1000_hw *hw =
    1347                 :          0 :                 E1000_DEV_PRIVATE_TO_HW(dev->data->dev_private);
    1348                 :            :         uint32_t rctl;
    1349                 :            : 
    1350                 :          0 :         rctl = E1000_READ_REG(hw, E1000_RCTL);
    1351                 :          0 :         rctl |= (E1000_RCTL_UPE | E1000_RCTL_MPE);
    1352                 :          0 :         E1000_WRITE_REG(hw, E1000_RCTL, rctl);
    1353                 :            : 
    1354                 :          0 :         return 0;
    1355                 :            : }
    1356                 :            : 
    1357                 :            : static int
    1358                 :          0 : eth_em_promiscuous_disable(struct rte_eth_dev *dev)
    1359                 :            : {
    1360                 :            :         struct e1000_hw *hw =
    1361                 :          0 :                 E1000_DEV_PRIVATE_TO_HW(dev->data->dev_private);
    1362                 :            :         uint32_t rctl;
    1363                 :            : 
    1364                 :          0 :         rctl = E1000_READ_REG(hw, E1000_RCTL);
    1365                 :          0 :         rctl &= ~(E1000_RCTL_UPE | E1000_RCTL_SBP);
    1366         [ #  # ]:          0 :         if (dev->data->all_multicast == 1)
    1367                 :          0 :                 rctl |= E1000_RCTL_MPE;
    1368                 :            :         else
    1369                 :          0 :                 rctl &= (~E1000_RCTL_MPE);
    1370                 :          0 :         E1000_WRITE_REG(hw, E1000_RCTL, rctl);
    1371                 :            : 
    1372                 :          0 :         return 0;
    1373                 :            : }
    1374                 :            : 
    1375                 :            : static int
    1376                 :          0 : eth_em_allmulticast_enable(struct rte_eth_dev *dev)
    1377                 :            : {
    1378                 :            :         struct e1000_hw *hw =
    1379                 :          0 :                 E1000_DEV_PRIVATE_TO_HW(dev->data->dev_private);
    1380                 :            :         uint32_t rctl;
    1381                 :            : 
    1382                 :          0 :         rctl = E1000_READ_REG(hw, E1000_RCTL);
    1383                 :          0 :         rctl |= E1000_RCTL_MPE;
    1384                 :          0 :         E1000_WRITE_REG(hw, E1000_RCTL, rctl);
    1385                 :            : 
    1386                 :          0 :         return 0;
    1387                 :            : }
    1388                 :            : 
    1389                 :            : static int
    1390                 :          0 : eth_em_allmulticast_disable(struct rte_eth_dev *dev)
    1391                 :            : {
    1392                 :            :         struct e1000_hw *hw =
    1393                 :          0 :                 E1000_DEV_PRIVATE_TO_HW(dev->data->dev_private);
    1394                 :            :         uint32_t rctl;
    1395                 :            : 
    1396         [ #  # ]:          0 :         if (dev->data->promiscuous == 1)
    1397                 :            :                 return 0; /* must remain in all_multicast mode */
    1398                 :          0 :         rctl = E1000_READ_REG(hw, E1000_RCTL);
    1399                 :          0 :         rctl &= (~E1000_RCTL_MPE);
    1400                 :          0 :         E1000_WRITE_REG(hw, E1000_RCTL, rctl);
    1401                 :            : 
    1402                 :          0 :         return 0;
    1403                 :            : }
    1404                 :            : 
    1405                 :            : static int
    1406                 :          0 : eth_em_vlan_filter_set(struct rte_eth_dev *dev, uint16_t vlan_id, int on)
    1407                 :            : {
    1408                 :            :         struct e1000_hw *hw =
    1409                 :          0 :                 E1000_DEV_PRIVATE_TO_HW(dev->data->dev_private);
    1410                 :            :         struct e1000_vfta * shadow_vfta =
    1411                 :            :                 E1000_DEV_PRIVATE_TO_VFTA(dev->data->dev_private);
    1412                 :            :         uint32_t vfta;
    1413                 :            :         uint32_t vid_idx;
    1414                 :            :         uint32_t vid_bit;
    1415                 :            : 
    1416                 :          0 :         vid_idx = (uint32_t) ((vlan_id >> E1000_VFTA_ENTRY_SHIFT) &
    1417                 :            :                               E1000_VFTA_ENTRY_MASK);
    1418                 :          0 :         vid_bit = (uint32_t) (1 << (vlan_id & E1000_VFTA_ENTRY_BIT_SHIFT_MASK));
    1419                 :          0 :         vfta = E1000_READ_REG_ARRAY(hw, E1000_VFTA, vid_idx);
    1420         [ #  # ]:          0 :         if (on)
    1421                 :          0 :                 vfta |= vid_bit;
    1422                 :            :         else
    1423                 :          0 :                 vfta &= ~vid_bit;
    1424                 :          0 :         E1000_WRITE_REG_ARRAY(hw, E1000_VFTA, vid_idx, vfta);
    1425                 :            : 
    1426                 :            :         /* update local VFTA copy */
    1427                 :          0 :         shadow_vfta->vfta[vid_idx] = vfta;
    1428                 :            : 
    1429                 :          0 :         return 0;
    1430                 :            : }
    1431                 :            : 
    1432                 :            : static void
    1433                 :            : em_vlan_hw_filter_disable(struct rte_eth_dev *dev)
    1434                 :            : {
    1435                 :            :         struct e1000_hw *hw =
    1436                 :          0 :                 E1000_DEV_PRIVATE_TO_HW(dev->data->dev_private);
    1437                 :            :         uint32_t reg;
    1438                 :            : 
    1439                 :            :         /* Filter Table Disable */
    1440                 :          0 :         reg = E1000_READ_REG(hw, E1000_RCTL);
    1441                 :            :         reg &= ~E1000_RCTL_CFIEN;
    1442                 :          0 :         reg &= ~E1000_RCTL_VFE;
    1443                 :          0 :         E1000_WRITE_REG(hw, E1000_RCTL, reg);
    1444                 :          0 : }
    1445                 :            : 
    1446                 :            : static void
    1447                 :          0 : em_vlan_hw_filter_enable(struct rte_eth_dev *dev)
    1448                 :            : {
    1449                 :            :         struct e1000_hw *hw =
    1450                 :          0 :                 E1000_DEV_PRIVATE_TO_HW(dev->data->dev_private);
    1451                 :            :         struct e1000_vfta * shadow_vfta =
    1452                 :            :                 E1000_DEV_PRIVATE_TO_VFTA(dev->data->dev_private);
    1453                 :            :         uint32_t reg;
    1454                 :            :         int i;
    1455                 :            : 
    1456                 :            :         /* Filter Table Enable, CFI not used for packet acceptance */
    1457                 :          0 :         reg = E1000_READ_REG(hw, E1000_RCTL);
    1458                 :          0 :         reg &= ~E1000_RCTL_CFIEN;
    1459                 :          0 :         reg |= E1000_RCTL_VFE;
    1460                 :          0 :         E1000_WRITE_REG(hw, E1000_RCTL, reg);
    1461                 :            : 
    1462                 :            :         /* restore vfta from local copy */
    1463         [ #  # ]:          0 :         for (i = 0; i < IGB_VFTA_SIZE; i++)
    1464                 :          0 :                 E1000_WRITE_REG_ARRAY(hw, E1000_VFTA, i, shadow_vfta->vfta[i]);
    1465                 :          0 : }
    1466                 :            : 
    1467                 :            : static void
    1468                 :            : em_vlan_hw_strip_disable(struct rte_eth_dev *dev)
    1469                 :            : {
    1470                 :            :         struct e1000_hw *hw =
    1471                 :          0 :                 E1000_DEV_PRIVATE_TO_HW(dev->data->dev_private);
    1472                 :            :         uint32_t reg;
    1473                 :            : 
    1474                 :            :         /* VLAN Mode Disable */
    1475                 :          0 :         reg = E1000_READ_REG(hw, E1000_CTRL);
    1476                 :          0 :         reg &= ~E1000_CTRL_VME;
    1477                 :          0 :         E1000_WRITE_REG(hw, E1000_CTRL, reg);
    1478                 :            : 
    1479                 :          0 : }
    1480                 :            : 
    1481                 :            : static void
    1482                 :            : em_vlan_hw_strip_enable(struct rte_eth_dev *dev)
    1483                 :            : {
    1484                 :            :         struct e1000_hw *hw =
    1485                 :          0 :                 E1000_DEV_PRIVATE_TO_HW(dev->data->dev_private);
    1486                 :            :         uint32_t reg;
    1487                 :            : 
    1488                 :            :         /* VLAN Mode Enable */
    1489                 :          0 :         reg = E1000_READ_REG(hw, E1000_CTRL);
    1490                 :          0 :         reg |= E1000_CTRL_VME;
    1491                 :          0 :         E1000_WRITE_REG(hw, E1000_CTRL, reg);
    1492                 :          0 : }
    1493                 :            : 
    1494                 :            : static int
    1495                 :          0 : eth_em_vlan_offload_set(struct rte_eth_dev *dev, int mask)
    1496                 :            : {
    1497                 :            :         struct rte_eth_rxmode *rxmode;
    1498                 :            : 
    1499                 :          0 :         rxmode = &dev->data->dev_conf.rxmode;
    1500         [ #  # ]:          0 :         if (mask & RTE_ETH_VLAN_STRIP_MASK) {
    1501         [ #  # ]:          0 :                 if (rxmode->offloads & RTE_ETH_RX_OFFLOAD_VLAN_STRIP)
    1502                 :            :                         em_vlan_hw_strip_enable(dev);
    1503                 :            :                 else
    1504                 :            :                         em_vlan_hw_strip_disable(dev);
    1505                 :            :         }
    1506                 :            : 
    1507         [ #  # ]:          0 :         if (mask & RTE_ETH_VLAN_FILTER_MASK) {
    1508         [ #  # ]:          0 :                 if (rxmode->offloads & RTE_ETH_RX_OFFLOAD_VLAN_FILTER)
    1509                 :          0 :                         em_vlan_hw_filter_enable(dev);
    1510                 :            :                 else
    1511                 :            :                         em_vlan_hw_filter_disable(dev);
    1512                 :            :         }
    1513                 :            : 
    1514                 :          0 :         return 0;
    1515                 :            : }
    1516                 :            : 
    1517                 :            : /*
    1518                 :            :  * It enables the interrupt mask and then enable the interrupt.
    1519                 :            :  *
    1520                 :            :  * @param dev
    1521                 :            :  *  Pointer to struct rte_eth_dev.
    1522                 :            :  *
    1523                 :            :  * @return
    1524                 :            :  *  - On success, zero.
    1525                 :            :  *  - On failure, a negative value.
    1526                 :            :  */
    1527                 :            : static int
    1528                 :            : eth_em_interrupt_setup(struct rte_eth_dev *dev)
    1529                 :            : {
    1530                 :            :         uint32_t regval;
    1531                 :            :         struct e1000_hw *hw =
    1532                 :          0 :                 E1000_DEV_PRIVATE_TO_HW(dev->data->dev_private);
    1533                 :            : 
    1534                 :            :         /* clear interrupt */
    1535                 :          0 :         E1000_READ_REG(hw, E1000_ICR);
    1536                 :          0 :         regval = E1000_READ_REG(hw, E1000_IMS);
    1537                 :          0 :         E1000_WRITE_REG(hw, E1000_IMS,
    1538                 :            :                         regval | E1000_ICR_LSC | E1000_ICR_OTHER);
    1539                 :            :         return 0;
    1540                 :            : }
    1541                 :            : 
    1542                 :            : /*
    1543                 :            :  * It clears the interrupt causes and enables the interrupt.
    1544                 :            :  * It will be called once only during nic initialized.
    1545                 :            :  *
    1546                 :            :  * @param dev
    1547                 :            :  *  Pointer to struct rte_eth_dev.
    1548                 :            :  *
    1549                 :            :  * @return
    1550                 :            :  *  - On success, zero.
    1551                 :            :  *  - On failure, a negative value.
    1552                 :            :  */
    1553                 :            : static int
    1554                 :            : eth_em_rxq_interrupt_setup(struct rte_eth_dev *dev)
    1555                 :            : {
    1556                 :            :         struct e1000_hw *hw =
    1557                 :          0 :         E1000_DEV_PRIVATE_TO_HW(dev->data->dev_private);
    1558                 :            : 
    1559                 :          0 :         E1000_READ_REG(hw, E1000_ICR);
    1560                 :            :         em_rxq_intr_enable(hw);
    1561                 :          0 :         return 0;
    1562                 :            : }
    1563                 :            : 
    1564                 :            : /*
    1565                 :            :  * It enable receive packet interrupt.
    1566                 :            :  * @param hw
    1567                 :            :  * Pointer to struct e1000_hw
    1568                 :            :  *
    1569                 :            :  * @return
    1570                 :            :  */
    1571                 :            : static void
    1572                 :            : em_rxq_intr_enable(struct e1000_hw *hw)
    1573                 :            : {
    1574                 :          0 :         E1000_WRITE_REG(hw, E1000_IMS, E1000_IMS_RXT0);
    1575                 :          0 :         E1000_WRITE_FLUSH(hw);
    1576                 :          0 : }
    1577                 :            : 
    1578                 :            : /*
    1579                 :            :  * It disabled lsc interrupt.
    1580                 :            :  * @param hw
    1581                 :            :  * Pointer to struct e1000_hw
    1582                 :            :  *
    1583                 :            :  * @return
    1584                 :            :  */
    1585                 :            : static void
    1586                 :            : em_lsc_intr_disable(struct e1000_hw *hw)
    1587                 :            : {
    1588                 :          0 :         E1000_WRITE_REG(hw, E1000_IMC, E1000_IMS_LSC | E1000_IMS_OTHER);
    1589                 :          0 :         E1000_WRITE_FLUSH(hw);
    1590                 :            : }
    1591                 :            : 
    1592                 :            : /*
    1593                 :            :  * It disabled receive packet interrupt.
    1594                 :            :  * @param hw
    1595                 :            :  * Pointer to struct e1000_hw
    1596                 :            :  *
    1597                 :            :  * @return
    1598                 :            :  */
    1599                 :            : static void
    1600                 :            : em_rxq_intr_disable(struct e1000_hw *hw)
    1601                 :            : {
    1602                 :          0 :         E1000_READ_REG(hw, E1000_ICR);
    1603                 :          0 :         E1000_WRITE_REG(hw, E1000_IMC, E1000_IMS_RXT0);
    1604                 :          0 :         E1000_WRITE_FLUSH(hw);
    1605                 :            : }
    1606                 :            : 
    1607                 :            : /*
    1608                 :            :  * It reads ICR and gets interrupt causes, check it and set a bit flag
    1609                 :            :  * to update link status.
    1610                 :            :  *
    1611                 :            :  * @param dev
    1612                 :            :  *  Pointer to struct rte_eth_dev.
    1613                 :            :  *
    1614                 :            :  * @return
    1615                 :            :  *  - On success, zero.
    1616                 :            :  *  - On failure, a negative value.
    1617                 :            :  */
    1618                 :            : static int
    1619                 :            : eth_em_interrupt_get_status(struct rte_eth_dev *dev)
    1620                 :            : {
    1621                 :            :         uint32_t icr;
    1622                 :            :         struct e1000_hw *hw =
    1623                 :          0 :                 E1000_DEV_PRIVATE_TO_HW(dev->data->dev_private);
    1624                 :            :         struct e1000_interrupt *intr =
    1625                 :            :                 E1000_DEV_PRIVATE_TO_INTR(dev->data->dev_private);
    1626                 :            : 
    1627                 :            :         /* read-on-clear nic registers here */
    1628                 :          0 :         icr = E1000_READ_REG(hw, E1000_ICR);
    1629         [ #  # ]:          0 :         if (icr & E1000_ICR_LSC) {
    1630                 :          0 :                 intr->flags |= E1000_FLAG_NEED_LINK_UPDATE;
    1631                 :            :         }
    1632                 :            : 
    1633                 :            :         return 0;
    1634                 :            : }
    1635                 :            : 
    1636                 :            : /*
    1637                 :            :  * It executes link_update after knowing an interrupt is present.
    1638                 :            :  *
    1639                 :            :  * @param dev
    1640                 :            :  *  Pointer to struct rte_eth_dev.
    1641                 :            :  *
    1642                 :            :  * @return
    1643                 :            :  *  - On success, zero.
    1644                 :            :  *  - On failure, a negative value.
    1645                 :            :  */
    1646                 :            : static int
    1647                 :          0 : eth_em_interrupt_action(struct rte_eth_dev *dev,
    1648                 :            :                         struct rte_intr_handle *intr_handle)
    1649                 :            : {
    1650                 :          0 :         struct rte_pci_device *pci_dev = RTE_ETH_DEV_TO_PCI(dev);
    1651                 :            :         struct e1000_hw *hw =
    1652                 :          0 :                 E1000_DEV_PRIVATE_TO_HW(dev->data->dev_private);
    1653                 :            :         struct e1000_interrupt *intr =
    1654                 :            :                 E1000_DEV_PRIVATE_TO_INTR(dev->data->dev_private);
    1655                 :            :         struct rte_eth_link link;
    1656                 :            :         int ret;
    1657                 :            : 
    1658         [ #  # ]:          0 :         if (!(intr->flags & E1000_FLAG_NEED_LINK_UPDATE))
    1659                 :            :                 return -1;
    1660                 :            : 
    1661                 :          0 :         intr->flags &= ~E1000_FLAG_NEED_LINK_UPDATE;
    1662                 :          0 :         rte_intr_ack(intr_handle);
    1663                 :            : 
    1664                 :            :         /* set get_link_status to check register later */
    1665                 :          0 :         hw->mac.get_link_status = 1;
    1666                 :          0 :         ret = eth_em_link_update(dev, 0);
    1667                 :            : 
    1668                 :            :         /* check if link has changed */
    1669         [ #  # ]:          0 :         if (ret < 0)
    1670                 :            :                 return 0;
    1671                 :            : 
    1672                 :          0 :         rte_eth_linkstatus_get(dev, &link);
    1673                 :            : 
    1674         [ #  # ]:          0 :         if (link.link_status) {
    1675         [ #  # ]:          0 :                 PMD_INIT_LOG(INFO, " Port %d: Link Up - speed %u Mbps - %s",
    1676                 :            :                              dev->data->port_id, link.link_speed,
    1677                 :            :                              link.link_duplex == RTE_ETH_LINK_FULL_DUPLEX ?
    1678                 :            :                              "full-duplex" : "half-duplex");
    1679                 :            :         } else {
    1680                 :          0 :                 PMD_INIT_LOG(INFO, " Port %d: Link Down", dev->data->port_id);
    1681                 :            :         }
    1682                 :          0 :         PMD_INIT_LOG(DEBUG, "PCI Address: " PCI_PRI_FMT,
    1683                 :            :                      pci_dev->addr.domain, pci_dev->addr.bus,
    1684                 :            :                      pci_dev->addr.devid, pci_dev->addr.function);
    1685                 :            : 
    1686                 :          0 :         return 0;
    1687                 :            : }
    1688                 :            : 
    1689                 :            : /**
    1690                 :            :  * Interrupt handler which shall be registered at first.
    1691                 :            :  *
    1692                 :            :  * @param handle
    1693                 :            :  *  Pointer to interrupt handle.
    1694                 :            :  * @param param
    1695                 :            :  *  The address of parameter (struct rte_eth_dev *) registered before.
    1696                 :            :  *
    1697                 :            :  * @return
    1698                 :            :  *  void
    1699                 :            :  */
    1700                 :            : static void
    1701                 :          0 : eth_em_interrupt_handler(void *param)
    1702                 :            : {
    1703                 :            :         struct rte_eth_dev *dev = (struct rte_eth_dev *)param;
    1704                 :            : 
    1705                 :            :         eth_em_interrupt_get_status(dev);
    1706                 :          0 :         eth_em_interrupt_action(dev, dev->intr_handle);
    1707                 :          0 :         rte_eth_dev_callback_process(dev, RTE_ETH_EVENT_INTR_LSC, NULL);
    1708                 :          0 : }
    1709                 :            : 
    1710                 :            : static int
    1711                 :          0 : eth_em_led_on(struct rte_eth_dev *dev)
    1712                 :            : {
    1713                 :            :         struct e1000_hw *hw;
    1714                 :            : 
    1715                 :            :         /*
    1716                 :            :          * This function calls into the base driver, which in turn will use
    1717                 :            :          * function pointers, which are not guaranteed to be valid in secondary
    1718                 :            :          * processes, so avoid using this function in secondary processes.
    1719                 :            :          */
    1720         [ #  # ]:          0 :         if (rte_eal_process_type() != RTE_PROC_PRIMARY)
    1721                 :            :                 return -E_RTE_SECONDARY;
    1722                 :            : 
    1723                 :          0 :         hw = E1000_DEV_PRIVATE_TO_HW(dev->data->dev_private);
    1724         [ #  # ]:          0 :         return e1000_led_on(hw) == E1000_SUCCESS ? 0 : -ENOTSUP;
    1725                 :            : }
    1726                 :            : 
    1727                 :            : static int
    1728                 :          0 : eth_em_led_off(struct rte_eth_dev *dev)
    1729                 :            : {
    1730                 :            :         struct e1000_hw *hw;
    1731                 :            : 
    1732                 :            :         /*
    1733                 :            :          * This function calls into the base driver, which in turn will use
    1734                 :            :          * function pointers, which are not guaranteed to be valid in secondary
    1735                 :            :          * processes, so avoid using this function in secondary processes.
    1736                 :            :          */
    1737         [ #  # ]:          0 :         if (rte_eal_process_type() != RTE_PROC_PRIMARY)
    1738                 :            :                 return -E_RTE_SECONDARY;
    1739                 :            : 
    1740                 :          0 :         hw = E1000_DEV_PRIVATE_TO_HW(dev->data->dev_private);
    1741         [ #  # ]:          0 :         return e1000_led_off(hw) == E1000_SUCCESS ? 0 : -ENOTSUP;
    1742                 :            : }
    1743                 :            : 
    1744                 :            : static int
    1745                 :          0 : eth_em_flow_ctrl_get(struct rte_eth_dev *dev, struct rte_eth_fc_conf *fc_conf)
    1746                 :            : {
    1747                 :            :         struct e1000_hw *hw;
    1748                 :            :         uint32_t ctrl;
    1749                 :            :         int tx_pause;
    1750                 :            :         int rx_pause;
    1751                 :            : 
    1752                 :          0 :         hw = E1000_DEV_PRIVATE_TO_HW(dev->data->dev_private);
    1753                 :          0 :         fc_conf->pause_time = hw->fc.pause_time;
    1754                 :          0 :         fc_conf->high_water = hw->fc.high_water;
    1755                 :          0 :         fc_conf->low_water = hw->fc.low_water;
    1756                 :          0 :         fc_conf->send_xon = hw->fc.send_xon;
    1757                 :          0 :         fc_conf->autoneg = hw->mac.autoneg;
    1758                 :            : 
    1759                 :            :         /*
    1760                 :            :          * Return rx_pause and tx_pause status according to actual setting of
    1761                 :            :          * the TFCE and RFCE bits in the CTRL register.
    1762                 :            :          */
    1763                 :          0 :         ctrl = E1000_READ_REG(hw, E1000_CTRL);
    1764         [ #  # ]:          0 :         if (ctrl & E1000_CTRL_TFCE)
    1765                 :            :                 tx_pause = 1;
    1766                 :            :         else
    1767                 :            :                 tx_pause = 0;
    1768                 :            : 
    1769         [ #  # ]:          0 :         if (ctrl & E1000_CTRL_RFCE)
    1770                 :            :                 rx_pause = 1;
    1771                 :            :         else
    1772                 :            :                 rx_pause = 0;
    1773                 :            : 
    1774         [ #  # ]:          0 :         if (rx_pause && tx_pause)
    1775                 :          0 :                 fc_conf->mode = RTE_ETH_FC_FULL;
    1776         [ #  # ]:          0 :         else if (rx_pause)
    1777                 :          0 :                 fc_conf->mode = RTE_ETH_FC_RX_PAUSE;
    1778         [ #  # ]:          0 :         else if (tx_pause)
    1779                 :          0 :                 fc_conf->mode = RTE_ETH_FC_TX_PAUSE;
    1780                 :            :         else
    1781                 :          0 :                 fc_conf->mode = RTE_ETH_FC_NONE;
    1782                 :            : 
    1783                 :          0 :         return 0;
    1784                 :            : }
    1785                 :            : 
    1786                 :            : static int
    1787                 :          0 : eth_em_flow_ctrl_set(struct rte_eth_dev *dev, struct rte_eth_fc_conf *fc_conf)
    1788                 :            : {
    1789                 :            :         struct e1000_hw *hw;
    1790                 :            :         int err;
    1791                 :          0 :         enum e1000_fc_mode rte_fcmode_2_e1000_fcmode[] = {
    1792                 :            :                 e1000_fc_none,
    1793                 :            :                 e1000_fc_rx_pause,
    1794                 :            :                 e1000_fc_tx_pause,
    1795                 :            :                 e1000_fc_full
    1796                 :            :         };
    1797                 :            :         uint32_t rx_buf_size;
    1798                 :            :         uint32_t max_high_water;
    1799                 :            :         uint32_t rctl;
    1800                 :            : 
    1801                 :            :         /*
    1802                 :            :          * This function calls into the base driver, which in turn will use
    1803                 :            :          * function pointers, which are not guaranteed to be valid in secondary
    1804                 :            :          * processes, so avoid using this function in secondary processes.
    1805                 :            :          */
    1806         [ #  # ]:          0 :         if (rte_eal_process_type() != RTE_PROC_PRIMARY)
    1807                 :            :                 return -E_RTE_SECONDARY;
    1808                 :            : 
    1809                 :          0 :         hw = E1000_DEV_PRIVATE_TO_HW(dev->data->dev_private);
    1810         [ #  # ]:          0 :         if (fc_conf->autoneg != hw->mac.autoneg)
    1811                 :            :                 return -ENOTSUP;
    1812                 :            :         rx_buf_size = em_get_rx_buffer_size(hw);
    1813                 :          0 :         PMD_INIT_LOG(DEBUG, "Rx packet buffer size = 0x%x", rx_buf_size);
    1814                 :            : 
    1815                 :            :         /* At least reserve one Ethernet frame for watermark */
    1816                 :          0 :         max_high_water = rx_buf_size - RTE_ETHER_MAX_LEN;
    1817         [ #  # ]:          0 :         if ((fc_conf->high_water > max_high_water) ||
    1818         [ #  # ]:          0 :             (fc_conf->high_water < fc_conf->low_water)) {
    1819                 :          0 :                 PMD_INIT_LOG(ERR, "e1000 incorrect high/low water value");
    1820                 :          0 :                 PMD_INIT_LOG(ERR, "high water must <= 0x%x", max_high_water);
    1821                 :          0 :                 return -EINVAL;
    1822                 :            :         }
    1823                 :            : 
    1824                 :          0 :         hw->fc.requested_mode = rte_fcmode_2_e1000_fcmode[fc_conf->mode];
    1825                 :          0 :         hw->fc.pause_time     = fc_conf->pause_time;
    1826                 :          0 :         hw->fc.high_water     = fc_conf->high_water;
    1827                 :          0 :         hw->fc.low_water      = fc_conf->low_water;
    1828                 :          0 :         hw->fc.send_xon            = fc_conf->send_xon;
    1829                 :            : 
    1830                 :          0 :         err = e1000_setup_link_generic(hw);
    1831         [ #  # ]:          0 :         if (err == E1000_SUCCESS) {
    1832                 :            : 
    1833                 :            :                 /* check if we want to forward MAC frames - driver doesn't have native
    1834                 :            :                  * capability to do that, so we'll write the registers ourselves */
    1835                 :            : 
    1836                 :          0 :                 rctl = E1000_READ_REG(hw, E1000_RCTL);
    1837                 :            : 
    1838                 :            :                 /* set or clear MFLCN.PMCF bit depending on configuration */
    1839         [ #  # ]:          0 :                 if (fc_conf->mac_ctrl_frame_fwd != 0)
    1840                 :          0 :                         rctl |= E1000_RCTL_PMCF;
    1841                 :            :                 else
    1842                 :          0 :                         rctl &= ~E1000_RCTL_PMCF;
    1843                 :            : 
    1844                 :          0 :                 E1000_WRITE_REG(hw, E1000_RCTL, rctl);
    1845                 :          0 :                 E1000_WRITE_FLUSH(hw);
    1846                 :            : 
    1847                 :          0 :                 return 0;
    1848                 :            :         }
    1849                 :            : 
    1850                 :          0 :         PMD_INIT_LOG(ERR, "e1000_setup_link_generic = 0x%x", err);
    1851                 :          0 :         return -EIO;
    1852                 :            : }
    1853                 :            : 
    1854                 :            : static int
    1855                 :          0 : eth_em_rar_set(struct rte_eth_dev *dev, struct rte_ether_addr *mac_addr,
    1856                 :            :                 uint32_t index, __rte_unused uint32_t pool)
    1857                 :            : {
    1858                 :          0 :         struct e1000_hw *hw = E1000_DEV_PRIVATE_TO_HW(dev->data->dev_private);
    1859                 :            : 
    1860                 :            :         /*
    1861                 :            :          * This function calls into the base driver, which in turn will use
    1862                 :            :          * function pointers, which are not guaranteed to be valid in secondary
    1863                 :            :          * processes, so avoid using this function in secondary processes.
    1864                 :            :          */
    1865         [ #  # ]:          0 :         if (rte_eal_process_type() != RTE_PROC_PRIMARY)
    1866                 :            :                 return -E_RTE_SECONDARY;
    1867                 :            : 
    1868                 :          0 :         return e1000_rar_set(hw, mac_addr->addr_bytes, index);
    1869                 :            : }
    1870                 :            : 
    1871                 :            : static void
    1872                 :          0 : eth_em_rar_clear(struct rte_eth_dev *dev, uint32_t index)
    1873                 :            : {
    1874                 :            :         uint8_t addr[RTE_ETHER_ADDR_LEN];
    1875                 :          0 :         struct e1000_hw *hw = E1000_DEV_PRIVATE_TO_HW(dev->data->dev_private);
    1876                 :            : 
    1877                 :            :         /*
    1878                 :            :          * This function calls into the base driver, which in turn will use
    1879                 :            :          * function pointers, which are not guaranteed to be valid in secondary
    1880                 :            :          * processes, so avoid using this function in secondary processes.
    1881                 :            :          */
    1882         [ #  # ]:          0 :         if (rte_eal_process_type() != RTE_PROC_PRIMARY)
    1883                 :          0 :                 return;
    1884                 :            : 
    1885                 :            :         memset(addr, 0, sizeof(addr));
    1886                 :            : 
    1887                 :          0 :         e1000_rar_set(hw, addr, index);
    1888                 :            : }
    1889                 :            : 
    1890                 :            : static int
    1891                 :          0 : eth_em_default_mac_addr_set(struct rte_eth_dev *dev,
    1892                 :            :                             struct rte_ether_addr *addr)
    1893                 :            : {
    1894                 :            :         /*
    1895                 :            :          * This function calls into the base driver, which in turn will use
    1896                 :            :          * function pointers, which are not guaranteed to be valid in secondary
    1897                 :            :          * processes, so avoid using this function in secondary processes.
    1898                 :            :          */
    1899         [ #  # ]:          0 :         if (rte_eal_process_type() != RTE_PROC_PRIMARY)
    1900                 :            :                 return -E_RTE_SECONDARY;
    1901                 :            : 
    1902                 :          0 :         eth_em_rar_clear(dev, 0);
    1903                 :            : 
    1904                 :          0 :         return eth_em_rar_set(dev, (void *)addr, 0, 0);
    1905                 :            : }
    1906                 :            : 
    1907                 :            : static int
    1908                 :          0 : eth_em_mtu_set(struct rte_eth_dev *dev, uint16_t mtu)
    1909                 :            : {
    1910                 :            :         struct e1000_hw *hw;
    1911                 :            :         uint32_t frame_size;
    1912                 :            :         uint32_t rctl;
    1913                 :            : 
    1914                 :          0 :         frame_size = mtu + E1000_ETH_OVERHEAD;
    1915                 :            : 
    1916                 :            :         /*
    1917                 :            :          * If device is started, refuse mtu that requires the support of
    1918                 :            :          * scattered packets when this feature has not been enabled before.
    1919                 :            :          */
    1920         [ #  # ]:          0 :         if (dev->data->dev_started && !dev->data->scattered_rx &&
    1921         [ #  # ]:          0 :             frame_size > dev->data->min_rx_buf_size - RTE_PKTMBUF_HEADROOM) {
    1922                 :          0 :                 PMD_INIT_LOG(ERR, "Stop port first.");
    1923                 :          0 :                 return -EINVAL;
    1924                 :            :         }
    1925                 :            : 
    1926                 :          0 :         hw = E1000_DEV_PRIVATE_TO_HW(dev->data->dev_private);
    1927                 :          0 :         rctl = E1000_READ_REG(hw, E1000_RCTL);
    1928                 :            : 
    1929                 :            :         /* switch to jumbo mode if needed */
    1930         [ #  # ]:          0 :         if (mtu > RTE_ETHER_MTU)
    1931                 :          0 :                 rctl |= E1000_RCTL_LPE;
    1932                 :            :         else
    1933                 :          0 :                 rctl &= ~E1000_RCTL_LPE;
    1934                 :          0 :         E1000_WRITE_REG(hw, E1000_RCTL, rctl);
    1935                 :            : 
    1936                 :          0 :         return 0;
    1937                 :            : }
    1938                 :            : 
    1939                 :            : static int
    1940                 :          0 : eth_em_set_mc_addr_list(struct rte_eth_dev *dev,
    1941                 :            :                         struct rte_ether_addr *mc_addr_set,
    1942                 :            :                         uint32_t nb_mc_addr)
    1943                 :            : {
    1944                 :            :         struct e1000_hw *hw;
    1945                 :            : 
    1946                 :            :         /*
    1947                 :            :          * This function calls into the base driver, which in turn will use
    1948                 :            :          * function pointers, which are not guaranteed to be valid in secondary
    1949                 :            :          * processes, so avoid using this function in secondary processes.
    1950                 :            :          */
    1951         [ #  # ]:          0 :         if (rte_eal_process_type() != RTE_PROC_PRIMARY)
    1952                 :            :                 return -E_RTE_SECONDARY;
    1953                 :            : 
    1954                 :          0 :         hw = E1000_DEV_PRIVATE_TO_HW(dev->data->dev_private);
    1955                 :          0 :         e1000_update_mc_addr_list(hw, (u8 *)mc_addr_set, nb_mc_addr);
    1956                 :          0 :         return 0;
    1957                 :            : }
    1958                 :            : 
    1959                 :        252 : RTE_PMD_REGISTER_PCI(net_e1000_em, rte_em_pmd);
    1960                 :            : RTE_PMD_REGISTER_PCI_TABLE(net_e1000_em, pci_id_em_map);
    1961                 :            : RTE_PMD_REGISTER_KMOD_DEP(net_e1000_em, "* igb_uio | uio_pci_generic | vfio-pci");

Generated by: LCOV version 1.14