// SPDX-License-Identifier: GPL-2.0 /* Copyright(c) 1999 - 2018 Intel Corporation. */ #define pr_fmt(fmt) … #include <linux/module.h> #include <linux/types.h> #include <linux/init.h> #include <linux/pci.h> #include <linux/vmalloc.h> #include <linux/pagemap.h> #include <linux/delay.h> #include <linux/netdevice.h> #include <linux/interrupt.h> #include <linux/tcp.h> #include <linux/ipv6.h> #include <linux/slab.h> #include <net/checksum.h> #include <net/ip6_checksum.h> #include <linux/ethtool.h> #include <linux/if_vlan.h> #include <linux/cpu.h> #include <linux/smp.h> #include <linux/pm_qos.h> #include <linux/pm_runtime.h> #include <linux/prefetch.h> #include <linux/suspend.h> #include "e1000.h" #define CREATE_TRACE_POINTS #include "e1000e_trace.h" char e1000e_driver_name[] = …; #define DEFAULT_MSG_ENABLE … static int debug = …; module_param(debug, int, 0); MODULE_PARM_DESC(…) …; static const struct e1000_info *e1000_info_tbl[] = …; struct e1000_reg_info { … }; static const struct e1000_reg_info e1000_reg_info_tbl[] = …; /** * __ew32_prepare - prepare to write to MAC CSR register on certain parts * @hw: pointer to the HW structure * * When updating the MAC CSR registers, the Manageability Engine (ME) could * be accessing the registers at the same time. Normally, this is handled in * h/w by an arbiter but on some parts there is a bug that acknowledges Host * accesses later than it should which could result in the register to have * an incorrect value. Workaround this by checking the FWSM register which * has bit 24 set while ME is accessing MAC CSR registers, wait if it is set * and try again a number of times. **/ static void __ew32_prepare(struct e1000_hw *hw) { … } void __ew32(struct e1000_hw *hw, unsigned long reg, u32 val) { … } /** * e1000_regdump - register printout routine * @hw: pointer to the HW structure * @reginfo: pointer to the register info table **/ static void e1000_regdump(struct e1000_hw *hw, struct e1000_reg_info *reginfo) { … } static void e1000e_dump_ps_pages(struct e1000_adapter *adapter, struct e1000_buffer *bi) { … } /** * e1000e_dump - Print registers, Tx-ring and Rx-ring * @adapter: board private structure **/ static void e1000e_dump(struct e1000_adapter *adapter) { … } /** * e1000_desc_unused - calculate if we have unused descriptors * @ring: pointer to ring struct to perform calculation on **/ static int e1000_desc_unused(struct e1000_ring *ring) { … } /** * e1000e_systim_to_hwtstamp - convert system time value to hw time stamp * @adapter: board private structure * @hwtstamps: time stamp structure to update * @systim: unsigned 64bit system time value. * * Convert the system time value stored in the RX/TXSTMP registers into a * hwtstamp which can be used by the upper level time stamping functions. * * The 'systim_lock' spinlock is used to protect the consistency of the * system time value. This is needed because reading the 64 bit time * value involves reading two 32 bit registers. The first read latches the * value. **/ static void e1000e_systim_to_hwtstamp(struct e1000_adapter *adapter, struct skb_shared_hwtstamps *hwtstamps, u64 systim) { … } /** * e1000e_rx_hwtstamp - utility function which checks for Rx time stamp * @adapter: board private structure * @status: descriptor extended error and status field * @skb: particular skb to include time stamp * * If the time stamp is valid, convert it into the timecounter ns value * and store that result into the shhwtstamps structure which is passed * up the network stack. **/ static void e1000e_rx_hwtstamp(struct e1000_adapter *adapter, u32 status, struct sk_buff *skb) { … } /** * e1000_receive_skb - helper function to handle Rx indications * @adapter: board private structure * @netdev: pointer to netdev struct * @staterr: descriptor extended error and status field as written by hardware * @vlan: descriptor vlan field as written by hardware (no le/be conversion) * @skb: pointer to sk_buff to be indicated to stack **/ static void e1000_receive_skb(struct e1000_adapter *adapter, struct net_device *netdev, struct sk_buff *skb, u32 staterr, __le16 vlan) { … } /** * e1000_rx_checksum - Receive Checksum Offload * @adapter: board private structure * @status_err: receive descriptor status and error fields * @skb: socket buffer with received data **/ static void e1000_rx_checksum(struct e1000_adapter *adapter, u32 status_err, struct sk_buff *skb) { … } static void e1000e_update_rdt_wa(struct e1000_ring *rx_ring, unsigned int i) { … } static void e1000e_update_tdt_wa(struct e1000_ring *tx_ring, unsigned int i) { … } /** * e1000_alloc_rx_buffers - Replace used receive buffers * @rx_ring: Rx descriptor ring * @cleaned_count: number to reallocate * @gfp: flags for allocation **/ static void e1000_alloc_rx_buffers(struct e1000_ring *rx_ring, int cleaned_count, gfp_t gfp) { … } /** * e1000_alloc_rx_buffers_ps - Replace used receive buffers; packet split * @rx_ring: Rx descriptor ring * @cleaned_count: number to reallocate * @gfp: flags for allocation **/ static void e1000_alloc_rx_buffers_ps(struct e1000_ring *rx_ring, int cleaned_count, gfp_t gfp) { … } /** * e1000_alloc_jumbo_rx_buffers - Replace used jumbo receive buffers * @rx_ring: Rx descriptor ring * @cleaned_count: number of buffers to allocate this pass * @gfp: flags for allocation **/ static void e1000_alloc_jumbo_rx_buffers(struct e1000_ring *rx_ring, int cleaned_count, gfp_t gfp) { … } static inline void e1000_rx_hash(struct net_device *netdev, __le32 rss, struct sk_buff *skb) { … } /** * e1000_clean_rx_irq - Send received data up the network stack * @rx_ring: Rx descriptor ring * @work_done: output parameter for indicating completed work * @work_to_do: how many packets we can clean * * the return value indicates whether actual cleaning was done, there * is no guarantee that everything was cleaned **/ static bool e1000_clean_rx_irq(struct e1000_ring *rx_ring, int *work_done, int work_to_do) { … } static void e1000_put_txbuf(struct e1000_ring *tx_ring, struct e1000_buffer *buffer_info, bool drop) { … } static void e1000_print_hw_hang(struct work_struct *work) { … } /** * e1000e_tx_hwtstamp_work - check for Tx time stamp * @work: pointer to work struct * * This work function polls the TSYNCTXCTL valid bit to determine when a * timestamp has been taken for the current stored skb. The timestamp must * be for this skb because only one such packet is allowed in the queue. */ static void e1000e_tx_hwtstamp_work(struct work_struct *work) { … } /** * e1000_clean_tx_irq - Reclaim resources after transmit completes * @tx_ring: Tx descriptor ring * * the return value indicates whether actual cleaning was done, there * is no guarantee that everything was cleaned **/ static bool e1000_clean_tx_irq(struct e1000_ring *tx_ring) { … } /** * e1000_clean_rx_irq_ps - Send received data up the network stack; packet split * @rx_ring: Rx descriptor ring * @work_done: output parameter for indicating completed work * @work_to_do: how many packets we can clean * * the return value indicates whether actual cleaning was done, there * is no guarantee that everything was cleaned **/ static bool e1000_clean_rx_irq_ps(struct e1000_ring *rx_ring, int *work_done, int work_to_do) { … } static void e1000_consume_page(struct e1000_buffer *bi, struct sk_buff *skb, u16 length) { … } /** * e1000_clean_jumbo_rx_irq - Send received data up the network stack; legacy * @rx_ring: Rx descriptor ring * @work_done: output parameter for indicating completed work * @work_to_do: how many packets we can clean * * the return value indicates whether actual cleaning was done, there * is no guarantee that everything was cleaned **/ static bool e1000_clean_jumbo_rx_irq(struct e1000_ring *rx_ring, int *work_done, int work_to_do) { … } /** * e1000_clean_rx_ring - Free Rx Buffers per Queue * @rx_ring: Rx descriptor ring **/ static void e1000_clean_rx_ring(struct e1000_ring *rx_ring) { … } static void e1000e_downshift_workaround(struct work_struct *work) { … } /** * e1000_intr_msi - Interrupt Handler * @irq: interrupt number * @data: pointer to a network interface device structure **/ static irqreturn_t e1000_intr_msi(int __always_unused irq, void *data) { … } /** * e1000_intr - Interrupt Handler * @irq: interrupt number * @data: pointer to a network interface device structure **/ static irqreturn_t e1000_intr(int __always_unused irq, void *data) { … } static irqreturn_t e1000_msix_other(int __always_unused irq, void *data) { … } static irqreturn_t e1000_intr_msix_tx(int __always_unused irq, void *data) { … } static irqreturn_t e1000_intr_msix_rx(int __always_unused irq, void *data) { … } /** * e1000_configure_msix - Configure MSI-X hardware * @adapter: board private structure * * e1000_configure_msix sets up the hardware to properly * generate MSI-X interrupts. **/ static void e1000_configure_msix(struct e1000_adapter *adapter) { … } void e1000e_reset_interrupt_capability(struct e1000_adapter *adapter) { … } /** * e1000e_set_interrupt_capability - set MSI or MSI-X if supported * @adapter: board private structure * * Attempt to configure interrupts using the best available * capabilities of the hardware and kernel. **/ void e1000e_set_interrupt_capability(struct e1000_adapter *adapter) { … } /** * e1000_request_msix - Initialize MSI-X interrupts * @adapter: board private structure * * e1000_request_msix allocates MSI-X vectors and requests interrupts from the * kernel. **/ static int e1000_request_msix(struct e1000_adapter *adapter) { … } /** * e1000_request_irq - initialize interrupts * @adapter: board private structure * * Attempts to configure interrupts using the best available * capabilities of the hardware and kernel. **/ static int e1000_request_irq(struct e1000_adapter *adapter) { … } static void e1000_free_irq(struct e1000_adapter *adapter) { … } /** * e1000_irq_disable - Mask off interrupt generation on the NIC * @adapter: board private structure **/ static void e1000_irq_disable(struct e1000_adapter *adapter) { … } /** * e1000_irq_enable - Enable default interrupt generation settings * @adapter: board private structure **/ static void e1000_irq_enable(struct e1000_adapter *adapter) { … } /** * e1000e_get_hw_control - get control of the h/w from f/w * @adapter: address of board private structure * * e1000e_get_hw_control sets {CTRL_EXT|SWSM}:DRV_LOAD bit. * For ASF and Pass Through versions of f/w this means that * the driver is loaded. For AMT version (only with 82573) * of the f/w this means that the network i/f is open. **/ void e1000e_get_hw_control(struct e1000_adapter *adapter) { … } /** * e1000e_release_hw_control - release control of the h/w to f/w * @adapter: address of board private structure * * e1000e_release_hw_control resets {CTRL_EXT|SWSM}:DRV_LOAD bit. * For ASF and Pass Through versions of f/w this means that the * driver is no longer loaded. For AMT version (only with 82573) i * of the f/w this means that the network i/f is closed. * **/ void e1000e_release_hw_control(struct e1000_adapter *adapter) { … } /** * e1000_alloc_ring_dma - allocate memory for a ring structure * @adapter: board private structure * @ring: ring struct for which to allocate dma **/ static int e1000_alloc_ring_dma(struct e1000_adapter *adapter, struct e1000_ring *ring) { … } /** * e1000e_setup_tx_resources - allocate Tx resources (Descriptors) * @tx_ring: Tx descriptor ring * * Return 0 on success, negative on failure **/ int e1000e_setup_tx_resources(struct e1000_ring *tx_ring) { … } /** * e1000e_setup_rx_resources - allocate Rx resources (Descriptors) * @rx_ring: Rx descriptor ring * * Returns 0 on success, negative on failure **/ int e1000e_setup_rx_resources(struct e1000_ring *rx_ring) { … } /** * e1000_clean_tx_ring - Free Tx Buffers * @tx_ring: Tx descriptor ring **/ static void e1000_clean_tx_ring(struct e1000_ring *tx_ring) { … } /** * e1000e_free_tx_resources - Free Tx Resources per Queue * @tx_ring: Tx descriptor ring * * Free all transmit software resources **/ void e1000e_free_tx_resources(struct e1000_ring *tx_ring) { … } /** * e1000e_free_rx_resources - Free Rx Resources * @rx_ring: Rx descriptor ring * * Free all receive software resources **/ void e1000e_free_rx_resources(struct e1000_ring *rx_ring) { … } /** * e1000_update_itr - update the dynamic ITR value based on statistics * @itr_setting: current adapter->itr * @packets: the number of packets during this measurement interval * @bytes: the number of bytes during this measurement interval * * Stores a new ITR value based on packets and byte * counts during the last interrupt. The advantage of per interrupt * computation is faster updates and more accurate ITR for the current * traffic pattern. Constants in this function were computed * based on theoretical maximum wire speed and thresholds were set based * on testing data as well as attempting to minimize response time * while increasing bulk throughput. This functionality is controlled * by the InterruptThrottleRate module parameter. **/ static unsigned int e1000_update_itr(u16 itr_setting, int packets, int bytes) { … } static void e1000_set_itr(struct e1000_adapter *adapter) { … } /** * e1000e_write_itr - write the ITR value to the appropriate registers * @adapter: address of board private structure * @itr: new ITR value to program * * e1000e_write_itr determines if the adapter is in MSI-X mode * and, if so, writes the EITR registers with the ITR value. * Otherwise, it writes the ITR value into the ITR register. **/ void e1000e_write_itr(struct e1000_adapter *adapter, u32 itr) { … } /** * e1000_alloc_queues - Allocate memory for all rings * @adapter: board private structure to initialize **/ static int e1000_alloc_queues(struct e1000_adapter *adapter) { … } /** * e1000e_poll - NAPI Rx polling callback * @napi: struct associated with this polling callback * @budget: number of packets driver is allowed to process this poll **/ static int e1000e_poll(struct napi_struct *napi, int budget) { … } static int e1000_vlan_rx_add_vid(struct net_device *netdev, __always_unused __be16 proto, u16 vid) { … } static int e1000_vlan_rx_kill_vid(struct net_device *netdev, __always_unused __be16 proto, u16 vid) { … } /** * e1000e_vlan_filter_disable - helper to disable hw VLAN filtering * @adapter: board private structure to initialize **/ static void e1000e_vlan_filter_disable(struct e1000_adapter *adapter) { … } /** * e1000e_vlan_filter_enable - helper to enable HW VLAN filtering * @adapter: board private structure to initialize **/ static void e1000e_vlan_filter_enable(struct e1000_adapter *adapter) { … } /** * e1000e_vlan_strip_disable - helper to disable HW VLAN stripping * @adapter: board private structure to initialize **/ static void e1000e_vlan_strip_disable(struct e1000_adapter *adapter) { … } /** * e1000e_vlan_strip_enable - helper to enable HW VLAN stripping * @adapter: board private structure to initialize **/ static void e1000e_vlan_strip_enable(struct e1000_adapter *adapter) { … } static void e1000_update_mng_vlan(struct e1000_adapter *adapter) { … } static void e1000_restore_vlan(struct e1000_adapter *adapter) { … } static void e1000_init_manageability_pt(struct e1000_adapter *adapter) { … } /** * e1000_configure_tx - Configure Transmit Unit after Reset * @adapter: board private structure * * Configure the Tx unit of the MAC after a reset. **/ static void e1000_configure_tx(struct e1000_adapter *adapter) { … } #define PAGE_USE_COUNT(S) … /** * e1000_setup_rctl - configure the receive control registers * @adapter: Board private structure **/ static void e1000_setup_rctl(struct e1000_adapter *adapter) { … } /** * e1000_configure_rx - Configure Receive Unit after Reset * @adapter: board private structure * * Configure the Rx unit of the MAC after a reset. **/ static void e1000_configure_rx(struct e1000_adapter *adapter) { … } /** * e1000e_write_mc_addr_list - write multicast addresses to MTA * @netdev: network interface device structure * * Writes multicast address list to the MTA hash table. * Returns: -ENOMEM on failure * 0 on no addresses written * X on writing X addresses to MTA */ static int e1000e_write_mc_addr_list(struct net_device *netdev) { … } /** * e1000e_write_uc_addr_list - write unicast addresses to RAR table * @netdev: network interface device structure * * Writes unicast address list to the RAR table. * Returns: -ENOMEM on failure/insufficient address space * 0 on no addresses written * X on writing X addresses to the RAR table **/ static int e1000e_write_uc_addr_list(struct net_device *netdev) { … } /** * e1000e_set_rx_mode - secondary unicast, Multicast and Promiscuous mode set * @netdev: network interface device structure * * The ndo_set_rx_mode entry point is called whenever the unicast or multicast * address list or the network interface flags are updated. This routine is * responsible for configuring the hardware for proper unicast, multicast, * promiscuous mode, and all-multi behavior. **/ static void e1000e_set_rx_mode(struct net_device *netdev) { … } static void e1000e_setup_rss_hash(struct e1000_adapter *adapter) { … } /** * e1000e_get_base_timinca - get default SYSTIM time increment attributes * @adapter: board private structure * @timinca: pointer to returned time increment attributes * * Get attributes for incrementing the System Time Register SYSTIML/H at * the default base frequency, and set the cyclecounter shift value. **/ s32 e1000e_get_base_timinca(struct e1000_adapter *adapter, u32 *timinca) { … } /** * e1000e_config_hwtstamp - configure the hwtstamp registers and enable/disable * @adapter: board private structure * @config: timestamp configuration * * Outgoing time stamping can be enabled and disabled. Play nice and * disable it when requested, although it shouldn't cause any overhead * when no packet needs it. At most one packet in the queue may be * marked for time stamping, otherwise it would be impossible to tell * for sure to which packet the hardware time stamp belongs. * * Incoming time stamping has to be configured via the hardware filters. * Not all combinations are supported, in particular event type has to be * specified. Matching the kind of event packet is not supported, with the * exception of "all V2 events regardless of level 2 or 4". **/ static int e1000e_config_hwtstamp(struct e1000_adapter *adapter, struct hwtstamp_config *config) { … } /** * e1000_configure - configure the hardware for Rx and Tx * @adapter: private board structure **/ static void e1000_configure(struct e1000_adapter *adapter) { … } /** * e1000e_power_up_phy - restore link in case the phy was powered down * @adapter: address of board private structure * * The phy may be powered down to save power and turn off link when the * driver is unloaded and wake on lan is not enabled (among others) * *** this routine MUST be followed by a call to e1000e_reset *** **/ void e1000e_power_up_phy(struct e1000_adapter *adapter) { … } /** * e1000_power_down_phy - Power down the PHY * @adapter: board private structure * * Power down the PHY so no link is implied when interface is down. * The PHY cannot be powered down if management or WoL is active. */ static void e1000_power_down_phy(struct e1000_adapter *adapter) { … } /** * e1000_flush_tx_ring - remove all descriptors from the tx_ring * @adapter: board private structure * * We want to clear all pending descriptors from the TX ring. * zeroing happens when the HW reads the regs. We assign the ring itself as * the data of the next descriptor. We don't care about the data we are about * to reset the HW. */ static void e1000_flush_tx_ring(struct e1000_adapter *adapter) { … } /** * e1000_flush_rx_ring - remove all descriptors from the rx_ring * @adapter: board private structure * * Mark all descriptors in the RX ring as consumed and disable the rx ring */ static void e1000_flush_rx_ring(struct e1000_adapter *adapter) { … } /** * e1000_flush_desc_rings - remove all descriptors from the descriptor rings * @adapter: board private structure * * In i219, the descriptor rings must be emptied before resetting the HW * or before changing the device state to D3 during runtime (runtime PM). * * Failure to do this will cause the HW to enter a unit hang state which can * only be released by PCI reset on the device * */ static void e1000_flush_desc_rings(struct e1000_adapter *adapter) { … } /** * e1000e_systim_reset - reset the timesync registers after a hardware reset * @adapter: board private structure * * When the MAC is reset, all hardware bits for timesync will be reset to the * default values. This function will restore the settings last in place. * Since the clock SYSTIME registers are reset, we will simply restore the * cyclecounter to the kernel real clock time. **/ static void e1000e_systim_reset(struct e1000_adapter *adapter) { … } /** * e1000e_reset - bring the hardware into a known good state * @adapter: board private structure * * This function boots the hardware and enables some settings that * require a configuration cycle of the hardware - those cannot be * set/changed during runtime. After reset the device needs to be * properly configured for Rx, Tx etc. */ void e1000e_reset(struct e1000_adapter *adapter) { … } /** * e1000e_trigger_lsc - trigger an LSC interrupt * @adapter: board private structure * * Fire a link status change interrupt to start the watchdog. **/ static void e1000e_trigger_lsc(struct e1000_adapter *adapter) { … } void e1000e_up(struct e1000_adapter *adapter) { … } static void e1000e_flush_descriptors(struct e1000_adapter *adapter) { … } static void e1000e_update_stats(struct e1000_adapter *adapter); /** * e1000e_down - quiesce the device and optionally reset the hardware * @adapter: board private structure * @reset: boolean flag to reset the hardware or not */ void e1000e_down(struct e1000_adapter *adapter, bool reset) { … } void e1000e_reinit_locked(struct e1000_adapter *adapter) { … } /** * e1000e_sanitize_systim - sanitize raw cycle counter reads * @hw: pointer to the HW structure * @systim: PHC time value read, sanitized and returned * @sts: structure to hold system time before and after reading SYSTIML, * may be NULL * * Errata for 82574/82583 possible bad bits read from SYSTIMH/L: * check to see that the time is incrementing at a reasonable * rate and is a multiple of incvalue. **/ static u64 e1000e_sanitize_systim(struct e1000_hw *hw, u64 systim, struct ptp_system_timestamp *sts) { … } /** * e1000e_read_systim - read SYSTIM register * @adapter: board private structure * @sts: structure which will contain system time before and after reading * SYSTIML, may be NULL **/ u64 e1000e_read_systim(struct e1000_adapter *adapter, struct ptp_system_timestamp *sts) { … } /** * e1000e_cyclecounter_read - read raw cycle counter (used by time counter) * @cc: cyclecounter structure **/ static u64 e1000e_cyclecounter_read(const struct cyclecounter *cc) { … } /** * e1000_sw_init - Initialize general software structures (struct e1000_adapter) * @adapter: board private structure to initialize * * e1000_sw_init initializes the Adapter private data structure. * Fields are initialized based on PCI device information and * OS network device settings (MTU size). **/ static int e1000_sw_init(struct e1000_adapter *adapter) { … } /** * e1000_intr_msi_test - Interrupt Handler * @irq: interrupt number * @data: pointer to a network interface device structure **/ static irqreturn_t e1000_intr_msi_test(int __always_unused irq, void *data) { … } /** * e1000_test_msi_interrupt - Returns 0 for successful test * @adapter: board private struct * * code flow taken from tg3.c **/ static int e1000_test_msi_interrupt(struct e1000_adapter *adapter) { … } /** * e1000_test_msi - Returns 0 if MSI test succeeds or INTx mode is restored * @adapter: board private struct * * code flow taken from tg3.c, called with e1000 interrupts disabled. **/ static int e1000_test_msi(struct e1000_adapter *adapter) { … } /** * e1000e_open - Called when a network interface is made active * @netdev: network interface device structure * * Returns 0 on success, negative value on failure * * The open entry point is called when a network interface is made * active by the system (IFF_UP). At this point all resources needed * for transmit and receive operations are allocated, the interrupt * handler is registered with the OS, the watchdog timer is started, * and the stack is notified that the interface is ready. **/ int e1000e_open(struct net_device *netdev) { … } /** * e1000e_close - Disables a network interface * @netdev: network interface device structure * * Returns 0, this is not allowed to fail * * The close entry point is called when an interface is de-activated * by the OS. The hardware is still under the drivers control, but * needs to be disabled. A global MAC reset is issued to stop the * hardware, and all transmit and receive resources are freed. **/ int e1000e_close(struct net_device *netdev) { … } /** * e1000_set_mac - Change the Ethernet Address of the NIC * @netdev: network interface device structure * @p: pointer to an address structure * * Returns 0 on success, negative on failure **/ static int e1000_set_mac(struct net_device *netdev, void *p) { … } /** * e1000e_update_phy_task - work thread to update phy * @work: pointer to our work struct * * this worker thread exists because we must acquire a * semaphore to read the phy, which we could msleep while * waiting for it, and we can't msleep in a timer. **/ static void e1000e_update_phy_task(struct work_struct *work) { … } /** * e1000_update_phy_info - timre call-back to update PHY info * @t: pointer to timer_list containing private info adapter * * Need to wait a few seconds after link up to get diagnostic information from * the phy **/ static void e1000_update_phy_info(struct timer_list *t) { … } /** * e1000e_update_phy_stats - Update the PHY statistics counters * @adapter: board private structure * * Read/clear the upper 16-bit PHY registers and read/accumulate lower **/ static void e1000e_update_phy_stats(struct e1000_adapter *adapter) { … } /** * e1000e_update_stats - Update the board statistics counters * @adapter: board private structure **/ static void e1000e_update_stats(struct e1000_adapter *adapter) { … } /** * e1000_phy_read_status - Update the PHY register status snapshot * @adapter: board private structure **/ static void e1000_phy_read_status(struct e1000_adapter *adapter) { … } static void e1000_print_link_info(struct e1000_adapter *adapter) { … } static bool e1000e_has_link(struct e1000_adapter *adapter) { … } static void e1000e_enable_receives(struct e1000_adapter *adapter) { … } static void e1000e_check_82574_phy_workaround(struct e1000_adapter *adapter) { … } /** * e1000_watchdog - Timer Call-back * @t: pointer to timer_list containing private info adapter **/ static void e1000_watchdog(struct timer_list *t) { … } static void e1000_watchdog_task(struct work_struct *work) { … } #define E1000_TX_FLAGS_CSUM … #define E1000_TX_FLAGS_VLAN … #define E1000_TX_FLAGS_TSO … #define E1000_TX_FLAGS_IPV4 … #define E1000_TX_FLAGS_NO_FCS … #define E1000_TX_FLAGS_HWTSTAMP … #define E1000_TX_FLAGS_VLAN_MASK … #define E1000_TX_FLAGS_VLAN_SHIFT … static int e1000_tso(struct e1000_ring *tx_ring, struct sk_buff *skb, __be16 protocol) { … } static bool e1000_tx_csum(struct e1000_ring *tx_ring, struct sk_buff *skb, __be16 protocol) { … } static int e1000_tx_map(struct e1000_ring *tx_ring, struct sk_buff *skb, unsigned int first, unsigned int max_per_txd, unsigned int nr_frags) { … } static void e1000_tx_queue(struct e1000_ring *tx_ring, int tx_flags, int count) { … } #define MINIMUM_DHCP_PACKET_SIZE … static int e1000_transfer_dhcp_info(struct e1000_adapter *adapter, struct sk_buff *skb) { … } static int __e1000_maybe_stop_tx(struct e1000_ring *tx_ring, int size) { … } static int e1000_maybe_stop_tx(struct e1000_ring *tx_ring, int size) { … } static netdev_tx_t e1000_xmit_frame(struct sk_buff *skb, struct net_device *netdev) { … } /** * e1000_tx_timeout - Respond to a Tx Hang * @netdev: network interface device structure * @txqueue: index of the hung queue (unused) **/ static void e1000_tx_timeout(struct net_device *netdev, unsigned int __always_unused txqueue) { … } static void e1000_reset_task(struct work_struct *work) { … } /** * e1000e_get_stats64 - Get System Network Statistics * @netdev: network interface device structure * @stats: rtnl_link_stats64 pointer * * Returns the address of the device statistics structure. **/ void e1000e_get_stats64(struct net_device *netdev, struct rtnl_link_stats64 *stats) { … } /** * e1000_change_mtu - Change the Maximum Transfer Unit * @netdev: network interface device structure * @new_mtu: new value for maximum frame size * * Returns 0 on success, negative on failure **/ static int e1000_change_mtu(struct net_device *netdev, int new_mtu) { … } static int e1000_mii_ioctl(struct net_device *netdev, struct ifreq *ifr, int cmd) { … } /** * e1000e_hwtstamp_set - control hardware time stamping * @netdev: network interface device structure * @ifr: interface request * * Outgoing time stamping can be enabled and disabled. Play nice and * disable it when requested, although it shouldn't cause any overhead * when no packet needs it. At most one packet in the queue may be * marked for time stamping, otherwise it would be impossible to tell * for sure to which packet the hardware time stamp belongs. * * Incoming time stamping has to be configured via the hardware filters. * Not all combinations are supported, in particular event type has to be * specified. Matching the kind of event packet is not supported, with the * exception of "all V2 events regardless of level 2 or 4". **/ static int e1000e_hwtstamp_set(struct net_device *netdev, struct ifreq *ifr) { … } static int e1000e_hwtstamp_get(struct net_device *netdev, struct ifreq *ifr) { … } static int e1000_ioctl(struct net_device *netdev, struct ifreq *ifr, int cmd) { … } static int e1000_init_phy_wakeup(struct e1000_adapter *adapter, u32 wufc) { … } static void e1000e_flush_lpic(struct pci_dev *pdev) { … } /* S0ix implementation */ static void e1000e_s0ix_entry_flow(struct e1000_adapter *adapter) { … } static void e1000e_s0ix_exit_flow(struct e1000_adapter *adapter) { … } static int e1000e_pm_freeze(struct device *dev) { … } static int __e1000_shutdown(struct pci_dev *pdev, bool runtime) { … } /** * __e1000e_disable_aspm - Disable ASPM states * @pdev: pointer to PCI device struct * @state: bit-mask of ASPM states to disable * @locked: indication if this context holds pci_bus_sem locked. * * Some devices *must* have certain ASPM states disabled per hardware errata. **/ static void __e1000e_disable_aspm(struct pci_dev *pdev, u16 state, int locked) { … } /** * e1000e_disable_aspm - Disable ASPM states. * @pdev: pointer to PCI device struct * @state: bit-mask of ASPM states to disable * * This function acquires the pci_bus_sem! * Some devices *must* have certain ASPM states disabled per hardware errata. **/ static void e1000e_disable_aspm(struct pci_dev *pdev, u16 state) { … } /** * e1000e_disable_aspm_locked - Disable ASPM states. * @pdev: pointer to PCI device struct * @state: bit-mask of ASPM states to disable * * This function must be called with pci_bus_sem acquired! * Some devices *must* have certain ASPM states disabled per hardware errata. **/ static void e1000e_disable_aspm_locked(struct pci_dev *pdev, u16 state) { … } static int e1000e_pm_thaw(struct device *dev) { … } static int __e1000_resume(struct pci_dev *pdev) { … } static int e1000e_pm_prepare(struct device *dev) { … } static int e1000e_pm_suspend(struct device *dev) { … } static int e1000e_pm_resume(struct device *dev) { … } static __maybe_unused int e1000e_pm_runtime_idle(struct device *dev) { … } static int e1000e_pm_runtime_resume(struct device *dev) { … } static int e1000e_pm_runtime_suspend(struct device *dev) { … } static void e1000_shutdown(struct pci_dev *pdev) { … } #ifdef CONFIG_NET_POLL_CONTROLLER static irqreturn_t e1000_intr_msix(int __always_unused irq, void *data) { … } /** * e1000_netpoll * @netdev: network interface device structure * * Polling 'interrupt' - used by things like netconsole to send skbs * without having to re-enable interrupts. It's not called while * the interrupt routine is executing. */ static void e1000_netpoll(struct net_device *netdev) { … } #endif /** * e1000_io_error_detected - called when PCI error is detected * @pdev: Pointer to PCI device * @state: The current pci connection state * * This function is called after a PCI bus error affecting * this device has been detected. */ static pci_ers_result_t e1000_io_error_detected(struct pci_dev *pdev, pci_channel_state_t state) { … } /** * e1000_io_slot_reset - called after the pci bus has been reset. * @pdev: Pointer to PCI device * * Restart the card from scratch, as if from a cold-boot. Implementation * resembles the first-half of the e1000e_pm_resume routine. */ static pci_ers_result_t e1000_io_slot_reset(struct pci_dev *pdev) { … } /** * e1000_io_resume - called when traffic can start flowing again. * @pdev: Pointer to PCI device * * This callback is called when the error recovery driver tells us that * its OK to resume normal operation. Implementation resembles the * second-half of the e1000e_pm_resume routine. */ static void e1000_io_resume(struct pci_dev *pdev) { … } static void e1000_print_device_info(struct e1000_adapter *adapter) { … } static void e1000_eeprom_checks(struct e1000_adapter *adapter) { … } static netdev_features_t e1000_fix_features(struct net_device *netdev, netdev_features_t features) { … } static int e1000_set_features(struct net_device *netdev, netdev_features_t features) { … } static const struct net_device_ops e1000e_netdev_ops = …; /** * e1000_probe - Device Initialization Routine * @pdev: PCI device information struct * @ent: entry in e1000_pci_tbl * * Returns 0 on success, negative on failure * * e1000_probe initializes an adapter identified by a pci_dev structure. * The OS initialization, configuring of the adapter private structure, * and a hardware reset occur. **/ static int e1000_probe(struct pci_dev *pdev, const struct pci_device_id *ent) { … } /** * e1000_remove - Device Removal Routine * @pdev: PCI device information struct * * e1000_remove is called by the PCI subsystem to alert the driver * that it should release a PCI device. This could be caused by a * Hot-Plug event, or because the driver is going to be removed from * memory. **/ static void e1000_remove(struct pci_dev *pdev) { … } /* PCI Error Recovery (ERS) */ static const struct pci_error_handlers e1000_err_handler = …; static const struct pci_device_id e1000_pci_tbl[] = …; MODULE_DEVICE_TABLE(pci, e1000_pci_tbl); static const struct dev_pm_ops e1000e_pm_ops = …; /* PCI Device API Driver */ static struct pci_driver e1000_driver = …; /** * e1000_init_module - Driver Registration Routine * * e1000_init_module is the first routine called when the driver is * loaded. All it does is register with the PCI subsystem. **/ static int __init e1000_init_module(void) { … } module_init(…) …; /** * e1000_exit_module - Driver Exit Cleanup Routine * * e1000_exit_module is called just before the driver is removed * from memory. **/ static void __exit e1000_exit_module(void) { … } module_exit(e1000_exit_module); MODULE_DESCRIPTION(…) …; MODULE_LICENSE(…) …; /* netdev.c */