]> xenbits.xensource.com Git - xenclient/kernel.git/commitdiff
imported patch igb-1.3.8.6.patch e1000e-0.4.1.12.patch
authort_jeang <devnull@localhost>
Tue, 6 Jan 2009 12:05:57 +0000 (12:05 +0000)
committert_jeang <devnull@localhost>
Tue, 6 Jan 2009 12:05:57 +0000 (12:05 +0000)
27 files changed:
buildconfigs/conf.linux/igb [new file with mode: 0644]
drivers/net/igb/Makefile
drivers/net/igb/e1000_82575.c
drivers/net/igb/e1000_82575.h
drivers/net/igb/e1000_api.c
drivers/net/igb/e1000_api.h
drivers/net/igb/e1000_defines.h
drivers/net/igb/e1000_hw.h
drivers/net/igb/e1000_mac.c
drivers/net/igb/e1000_mac.h
drivers/net/igb/e1000_manage.c [new file with mode: 0644]
drivers/net/igb/e1000_manage.h [new file with mode: 0644]
drivers/net/igb/e1000_nvm.c
drivers/net/igb/e1000_nvm.h
drivers/net/igb/e1000_osdep.h [new file with mode: 0644]
drivers/net/igb/e1000_phy.c
drivers/net/igb/e1000_phy.h
drivers/net/igb/e1000_regs.h
drivers/net/igb/igb.h
drivers/net/igb/igb_compat.h
drivers/net/igb/igb_ethtool.c
drivers/net/igb/igb_main.c
drivers/net/igb/igb_param.c [new file with mode: 0644]
drivers/net/igb/igb_regtest.h [new file with mode: 0644]
drivers/net/igb/kcompat.c [new file with mode: 0644]
drivers/net/igb/kcompat.h [new file with mode: 0644]
drivers/net/igb/kcompat_ethtool.c [new file with mode: 0644]

diff --git a/buildconfigs/conf.linux/igb b/buildconfigs/conf.linux/igb
new file mode 100644 (file)
index 0000000..1a8ee88
--- /dev/null
@@ -0,0 +1 @@
+CONFIG_IGB=m
index 1927b3fd6f051af7ed37071d5c33c510e5ccaa9e..f6e5b52e6082fd2b8dff7ca1a1da6fa1d2a7935f 100644 (file)
@@ -1,6 +1,6 @@
 ################################################################################
 #
-# Intel 82575 PCI-Express Ethernet Linux driver
+# Intel PRO/1000 Linux driver
 # Copyright(c) 1999 - 2007 Intel Corporation.
 #
 # This program is free software; you can redistribute it and/or modify it
 ################################################################################
 
 #
-# Makefile for the Intel(R) 82575 PCI-Express ethernet driver
+# Makefile for the Intel(R) PRO/1000 ethernet driver
 #
 
 obj-$(CONFIG_IGB) += igb.o
 
-igb-objs := igb_main.o igb_ethtool.o e1000_82575.o \
-           e1000_mac.o e1000_nvm.o e1000_phy.o
+FAMILYC = e1000_82575.c
 
+CFILES = igb_main.c $(FAMILYC) e1000_mac.c e1000_nvm.c e1000_phy.c \
+        e1000_manage.c igb_param.c igb_ethtool.c kcompat.c e1000_api.c
+
+igb-objs := $(CFILES:.c=.o)
+
+EXTRA_CFLAGS += -DDRIVER_IGB
index ceb1bacb691edc27e2385b6d7061646321f4a719..df9c4bdba196d350e43e983d26ae316e4c97a0ee 100644 (file)
@@ -1,7 +1,7 @@
 /*******************************************************************************
 
   Intel(R) Gigabit Ethernet Linux driver
-  Copyright(c) 2007 Intel Corporation.
+  Copyright(c) 2007-2008 Intel Corporation.
 
   This program is free software; you can redistribute it and/or modify it
   under the terms and conditions of the GNU General Public License,
 
 *******************************************************************************/
 
-/* e1000_82575
- * e1000_82576
+/*
+ * 82575EB Gigabit Network Connection
+ * 82575EB Gigabit Backplane Connection
+ * 82575GB Gigabit Network Connection
+ * 82576 Gigabit Network Connection
  */
 
-#include <linux/types.h>
-#include <linux/slab.h>
-
-#include "e1000_mac.h"
-#include "e1000_82575.h"
-
-static s32  igb_get_invariants_82575(struct e1000_hw *);
-static s32  igb_acquire_phy_82575(struct e1000_hw *);
-static void igb_release_phy_82575(struct e1000_hw *);
-static s32  igb_acquire_nvm_82575(struct e1000_hw *);
-static void igb_release_nvm_82575(struct e1000_hw *);
-static s32  igb_check_for_link_82575(struct e1000_hw *);
-static s32  igb_get_cfg_done_82575(struct e1000_hw *);
-static s32  igb_init_hw_82575(struct e1000_hw *);
-static s32  igb_phy_hw_reset_sgmii_82575(struct e1000_hw *);
-static s32  igb_read_phy_reg_sgmii_82575(struct e1000_hw *, u32, u16 *);
-static void igb_rar_set_82575(struct e1000_hw *, u8 *, u32);
-static s32  igb_reset_hw_82575(struct e1000_hw *);
-static s32  igb_set_d0_lplu_state_82575(struct e1000_hw *, bool);
-static s32  igb_setup_copper_link_82575(struct e1000_hw *);
-static s32  igb_setup_fiber_serdes_link_82575(struct e1000_hw *);
-static s32  igb_write_phy_reg_sgmii_82575(struct e1000_hw *, u32, u16);
-static void igb_clear_hw_cntrs_82575(struct e1000_hw *);
-static s32  igb_acquire_swfw_sync_82575(struct e1000_hw *, u16);
-static s32  igb_configure_pcs_link_82575(struct e1000_hw *);
-static s32  igb_get_pcs_speed_and_duplex_82575(struct e1000_hw *, u16 *,
-                                                u16 *);
-static s32  igb_get_phy_id_82575(struct e1000_hw *);
-static void igb_release_swfw_sync_82575(struct e1000_hw *, u16);
-static bool igb_sgmii_active_82575(struct e1000_hw *);
-static s32  igb_reset_init_script_82575(struct e1000_hw *);
-static s32  igb_read_mac_addr_82575(struct e1000_hw *);
-
-
-struct e1000_dev_spec_82575 {
-       bool sgmii_active;
-};
-
-static s32 igb_get_invariants_82575(struct e1000_hw *hw)
+#include "e1000_api.h"
+
+static s32  e1000_init_phy_params_82575(struct e1000_hw *hw);
+static s32  e1000_init_nvm_params_82575(struct e1000_hw *hw);
+static s32  e1000_init_mac_params_82575(struct e1000_hw *hw);
+static s32  e1000_acquire_phy_82575(struct e1000_hw *hw);
+static void e1000_release_phy_82575(struct e1000_hw *hw);
+static s32  e1000_acquire_nvm_82575(struct e1000_hw *hw);
+static void e1000_release_nvm_82575(struct e1000_hw *hw);
+static s32  e1000_check_for_link_82575(struct e1000_hw *hw);
+static s32  e1000_get_cfg_done_82575(struct e1000_hw *hw);
+static s32  e1000_get_link_up_info_82575(struct e1000_hw *hw, u16 *speed,
+                                         u16 *duplex);
+static s32  e1000_init_hw_82575(struct e1000_hw *hw);
+static s32  e1000_phy_hw_reset_sgmii_82575(struct e1000_hw *hw);
+static s32  e1000_read_phy_reg_sgmii_82575(struct e1000_hw *hw, u32 offset,
+                                           u16 *data);
+static s32  e1000_reset_hw_82575(struct e1000_hw *hw);
+static s32  e1000_set_d0_lplu_state_82575(struct e1000_hw *hw,
+                                          bool active);
+static s32  e1000_setup_copper_link_82575(struct e1000_hw *hw);
+static s32  e1000_setup_fiber_serdes_link_82575(struct e1000_hw *hw);
+static s32  e1000_valid_led_default_82575(struct e1000_hw *hw, u16 *data);
+static s32  e1000_write_phy_reg_sgmii_82575(struct e1000_hw *hw,
+                                            u32 offset, u16 data);
+static void e1000_clear_hw_cntrs_82575(struct e1000_hw *hw);
+static s32  e1000_acquire_swfw_sync_82575(struct e1000_hw *hw, u16 mask);
+static s32  e1000_configure_pcs_link_82575(struct e1000_hw *hw);
+static s32  e1000_get_pcs_speed_and_duplex_82575(struct e1000_hw *hw,
+                                                 u16 *speed, u16 *duplex);
+static s32  e1000_get_phy_id_82575(struct e1000_hw *hw);
+static void e1000_release_swfw_sync_82575(struct e1000_hw *hw, u16 mask);
+static bool e1000_sgmii_active_82575(struct e1000_hw *hw);
+static s32  e1000_reset_init_script_82575(struct e1000_hw *hw);
+static s32  e1000_read_mac_addr_82575(struct e1000_hw *hw);
+static void e1000_power_down_phy_copper_82575(struct e1000_hw *hw);
+
+static void e1000_init_rx_addrs_82575(struct e1000_hw *hw, u16 rar_count);
+static void e1000_update_mc_addr_list_82575(struct e1000_hw *hw,
+                                           u8 *mc_addr_list, u32 mc_addr_count,
+                                           u32 rar_used_count, u32 rar_count);
+void e1000_shutdown_fiber_serdes_link_82575(struct e1000_hw *hw);
+
+/**
+ *  e1000_init_phy_params_82575 - Init PHY func ptrs.
+ *  @hw: pointer to the HW structure
+ **/
+static s32 e1000_init_phy_params_82575(struct e1000_hw *hw)
 {
        struct e1000_phy_info *phy = &hw->phy;
-       struct e1000_nvm_info *nvm = &hw->nvm;
-       struct e1000_mac_info *mac = &hw->mac;
-       struct e1000_dev_spec_82575 *dev_spec;
-       u32 eecd;
-       s32 ret_val;
-       u16 size;
-       u32 ctrl_ext = 0;
+       s32 ret_val = E1000_SUCCESS;
 
-       switch (hw->device_id) {
-       case E1000_DEV_ID_82575EB_COPPER:
-       case E1000_DEV_ID_82575EB_FIBER_SERDES:
-       case E1000_DEV_ID_82575GB_QUAD_COPPER:
-               mac->type = e1000_82575;
-               break;
-       default:
-               return -E1000_ERR_MAC_INIT;
-               break;
-       }
+       DEBUGFUNC("e1000_init_phy_params_82575");
 
-       /* MAC initialization */
-       hw->dev_spec_size = sizeof(struct e1000_dev_spec_82575);
+       if (hw->phy.media_type != e1000_media_type_copper) {
+               phy->type = e1000_phy_none;
+               goto out;
+       } else {
+               phy->ops.power_up   = e1000_power_up_phy_copper;
+               phy->ops.power_down = e1000_power_down_phy_copper_82575;
+       }
 
-       /* Device-specific structure allocation */
-       hw->dev_spec = kzalloc(hw->dev_spec_size, GFP_KERNEL);
+       phy->autoneg_mask           = AUTONEG_ADVERTISE_SPEED_DEFAULT;
+       phy->reset_delay_us         = 100;
 
-       if (!hw->dev_spec)
-               return -ENOMEM;
+       phy->ops.acquire            = e1000_acquire_phy_82575;
+       phy->ops.check_reset_block  = e1000_check_reset_block_generic;
+       phy->ops.commit             = e1000_phy_sw_reset_generic;
+       phy->ops.get_cfg_done       = e1000_get_cfg_done_82575;
+       phy->ops.release            = e1000_release_phy_82575;
 
-       dev_spec = (struct e1000_dev_spec_82575 *)hw->dev_spec;
+       if (e1000_sgmii_active_82575(hw)) {
+               phy->ops.reset      = e1000_phy_hw_reset_sgmii_82575;
+               phy->ops.read_reg   = e1000_read_phy_reg_sgmii_82575;
+               phy->ops.write_reg  = e1000_write_phy_reg_sgmii_82575;
+       } else {
+               phy->ops.reset      = e1000_phy_hw_reset_generic;
+               phy->ops.read_reg   = e1000_read_phy_reg_igp;
+               phy->ops.write_reg  = e1000_write_phy_reg_igp;
+       }
 
-       /* Set media type */
-       /*
-        * The 82575 uses bits 22:23 for link mode. The mode can be changed
-        * based on the EEPROM. We cannot rely upon device ID. There
-        * is no distinguishable difference between fiber and internal
-        * SerDes mode on the 82575. There can be an external PHY attached
-        * on the SGMII interface. For this, we'll set sgmii_active to true.
-        */
-       phy->media_type = e1000_media_type_copper;
-       dev_spec->sgmii_active = false;
+       /* Set phy->phy_addr and phy->id. */
+       ret_val = e1000_get_phy_id_82575(hw);
 
-       ctrl_ext = rd32(E1000_CTRL_EXT);
-       if ((ctrl_ext & E1000_CTRL_EXT_LINK_MODE_MASK) ==
-           E1000_CTRL_EXT_LINK_MODE_PCIE_SERDES) {
-               hw->phy.media_type = e1000_media_type_internal_serdes;
-               ctrl_ext |= E1000_CTRL_I2C_ENA;
-       } else if (ctrl_ext & E1000_CTRL_EXT_LINK_MODE_SGMII) {
-               dev_spec->sgmii_active = true;
-               ctrl_ext |= E1000_CTRL_I2C_ENA;
-       } else {
-               ctrl_ext &= ~E1000_CTRL_I2C_ENA;
+       /* Verify phy id and set remaining function pointers */
+       switch (phy->id) {
+       case M88E1111_I_PHY_ID:
+               phy->type                   = e1000_phy_m88;
+               phy->ops.check_polarity     = e1000_check_polarity_m88;
+               phy->ops.get_info           = e1000_get_phy_info_m88;
+               phy->ops.get_cable_length   = e1000_get_cable_length_m88;
+               phy->ops.force_speed_duplex = e1000_phy_force_speed_duplex_m88;
+               break;
+       case IGP03E1000_E_PHY_ID:
+       case IGP04E1000_E_PHY_ID:
+               phy->type                   = e1000_phy_igp_3;
+               phy->ops.check_polarity     = e1000_check_polarity_igp;
+               phy->ops.get_info           = e1000_get_phy_info_igp;
+               phy->ops.get_cable_length   = e1000_get_cable_length_igp_2;
+               phy->ops.force_speed_duplex = e1000_phy_force_speed_duplex_igp;
+               phy->ops.set_d0_lplu_state  = e1000_set_d0_lplu_state_82575;
+               phy->ops.set_d3_lplu_state  = e1000_set_d3_lplu_state_generic;
+               break;
+       default:
+               ret_val = -E1000_ERR_PHY;
+               goto out;
        }
-       wr32(E1000_CTRL_EXT, ctrl_ext);
 
-       /* Set mta register count */
-       mac->mta_reg_count = 128;
-       /* Set rar entry count */
-       mac->rar_entry_count = E1000_RAR_ENTRIES_82575;
-       /* Set if part includes ASF firmware */
-       mac->asf_firmware_present = true;
-       /* Set if manageability features are enabled. */
-       mac->arc_subsystem_valid =
-               (rd32(E1000_FWSM) & E1000_FWSM_MODE_MASK)
-                       ? true : false;
+out:
+       return ret_val;
+}
 
-       /* physical interface link setup */
-       mac->ops.setup_physical_interface =
-               (hw->phy.media_type == e1000_media_type_copper)
-                       ? igb_setup_copper_link_82575
-                       : igb_setup_fiber_serdes_link_82575;
+/**
+ *  e1000_init_nvm_params_82575 - Init NVM func ptrs.
+ *  @hw: pointer to the HW structure
+ **/
+static s32 e1000_init_nvm_params_82575(struct e1000_hw *hw)
+{
+       struct e1000_nvm_info *nvm = &hw->nvm;
+       u32 eecd = E1000_READ_REG(hw, E1000_EECD);
+       u16 size;
 
-       /* NVM initialization */
-       eecd = rd32(E1000_EECD);
+       DEBUGFUNC("e1000_init_nvm_params_82575");
 
        nvm->opcode_bits        = 8;
        nvm->delay_usec         = 1;
@@ -161,95 +173,177 @@ static s32 igb_get_invariants_82575(struct e1000_hw *hw)
                break;
        }
 
-       nvm->type = e1000_nvm_eeprom_spi;
+       nvm->type              = e1000_nvm_eeprom_spi;
 
        size = (u16)((eecd & E1000_EECD_SIZE_EX_MASK) >>
-                    E1000_EECD_SIZE_EX_SHIFT);
+                         E1000_EECD_SIZE_EX_SHIFT);
 
        /*
         * Added to a constant, "size" becomes the left-shift value
         * for setting word_size.
         */
        size += NVM_WORD_SIZE_BASE_SHIFT;
-       nvm->word_size = 1 << size;
 
-       /* setup PHY parameters */
-       if (phy->media_type != e1000_media_type_copper) {
-               phy->type = e1000_phy_none;
-               return 0;
-       }
+       /* EEPROM access above 16k is unsupported */
+       if (size > 14)
+               size = 14;
+       nvm->word_size  = 1 << size;
+
+       /* Function Pointers */
+       nvm->ops.acquire       = e1000_acquire_nvm_82575;
+       nvm->ops.read          = e1000_read_nvm_eerd;
+       nvm->ops.release       = e1000_release_nvm_82575;
+       nvm->ops.update        = e1000_update_nvm_checksum_generic;
+       nvm->ops.valid_led_default = e1000_valid_led_default_82575;
+       nvm->ops.validate      = e1000_validate_nvm_checksum_generic;
+       nvm->ops.write         = e1000_write_nvm_spi;
+
+       return E1000_SUCCESS;
+}
 
-       phy->autoneg_mask        = AUTONEG_ADVERTISE_SPEED_DEFAULT;
-       phy->reset_delay_us      = 100;
+/**
+ *  e1000_init_mac_params_82575 - Init MAC func ptrs.
+ *  @hw: pointer to the HW structure
+ **/
+static s32 e1000_init_mac_params_82575(struct e1000_hw *hw)
+{
+       struct e1000_mac_info *mac = &hw->mac;
+       struct e1000_dev_spec_82575 *dev_spec = &hw->dev_spec._82575;
+       u32 ctrl_ext = 0;
 
-       /* PHY function pointers */
-       if (igb_sgmii_active_82575(hw)) {
-               phy->ops.reset_phy          = igb_phy_hw_reset_sgmii_82575;
-               phy->ops.read_phy_reg       = igb_read_phy_reg_sgmii_82575;
-               phy->ops.write_phy_reg      = igb_write_phy_reg_sgmii_82575;
+       DEBUGFUNC("e1000_init_mac_params_82575");
+
+       /* Set media type */
+        /*
+        * The 82575 uses bits 22:23 for link mode. The mode can be changed
+         * based on the EEPROM. We cannot rely upon device ID. There
+         * is no distinguishable difference between fiber and internal
+         * SerDes mode on the 82575. There can be an external PHY attached
+         * on the SGMII interface. For this, we'll set sgmii_active to true.
+         */
+       hw->phy.media_type = e1000_media_type_copper;
+       dev_spec->sgmii_active = false;
+
+       ctrl_ext = E1000_READ_REG(hw, E1000_CTRL_EXT);
+       if ((ctrl_ext & E1000_CTRL_EXT_LINK_MODE_MASK) ==
+           E1000_CTRL_EXT_LINK_MODE_PCIE_SERDES) {
+               hw->phy.media_type = e1000_media_type_internal_serdes;
+               ctrl_ext |= E1000_CTRL_I2C_ENA;
+       } else if (ctrl_ext & E1000_CTRL_EXT_LINK_MODE_SGMII) {
+               dev_spec->sgmii_active = true;
+               ctrl_ext |= E1000_CTRL_I2C_ENA;
        } else {
-               phy->ops.reset_phy          = igb_phy_hw_reset;
-               phy->ops.read_phy_reg       = igb_read_phy_reg_igp;
-               phy->ops.write_phy_reg      = igb_write_phy_reg_igp;
+               ctrl_ext &= ~E1000_CTRL_I2C_ENA;
        }
+       E1000_WRITE_REG(hw, E1000_CTRL_EXT, ctrl_ext);
 
-       /* Set phy->phy_addr and phy->id. */
-       ret_val = igb_get_phy_id_82575(hw);
-       if (ret_val)
-               return ret_val;
+       /* Set mta register count */
+       mac->mta_reg_count = 128;
+       /* Set rar entry count */
+       mac->rar_entry_count = E1000_RAR_ENTRIES_82575;
+       if (mac->type == e1000_82576)
+               mac->rar_entry_count = E1000_RAR_ENTRIES_82576;
+       /* Set if part includes ASF firmware */
+       mac->asf_firmware_present = true;
+       /* Set if manageability features are enabled. */
+       mac->arc_subsystem_valid =
+               (E1000_READ_REG(hw, E1000_FWSM) & E1000_FWSM_MODE_MASK)
+                       ? true : false;
+
+       /* Function pointers */
+
+       /* bus type/speed/width */
+       mac->ops.get_bus_info = e1000_get_bus_info_pcie_generic;
+       /* reset */
+       mac->ops.reset_hw = e1000_reset_hw_82575;
+       /* hw initialization */
+       mac->ops.init_hw = e1000_init_hw_82575;
+       /* link setup */
+       mac->ops.setup_link = e1000_setup_link_generic;
+       /* physical interface link setup */
+       mac->ops.setup_physical_interface =
+               (hw->phy.media_type == e1000_media_type_copper)
+                       ? e1000_setup_copper_link_82575
+                       : e1000_setup_fiber_serdes_link_82575;
+       /* physical interface shutdown */
+       mac->ops.shutdown_serdes = e1000_shutdown_fiber_serdes_link_82575;
+       /* check for link */
+       mac->ops.check_for_link = e1000_check_for_link_82575;
+       /* receive address register setting */
+       mac->ops.rar_set = e1000_rar_set_generic;
+       /* read mac address */
+       mac->ops.read_mac_addr = e1000_read_mac_addr_82575;
+       /* multicast address update */
+       mac->ops.update_mc_addr_list = e1000_update_mc_addr_list_82575;
+       /* writing VFTA */
+       mac->ops.write_vfta = e1000_write_vfta_generic;
+       /* clearing VFTA */
+       mac->ops.clear_vfta = e1000_clear_vfta_generic;
+       /* setting MTA */
+       mac->ops.mta_set = e1000_mta_set_generic;
+       /* blink LED */
+       mac->ops.blink_led = e1000_blink_led_generic;
+       /* setup LED */
+       mac->ops.setup_led = e1000_setup_led_generic;
+       /* cleanup LED */
+       mac->ops.cleanup_led = e1000_cleanup_led_generic;
+       /* turn on/off LED */
+       mac->ops.led_on = e1000_led_on_generic;
+       mac->ops.led_off = e1000_led_off_generic;
+       /* clear hardware counters */
+       mac->ops.clear_hw_cntrs = e1000_clear_hw_cntrs_82575;
+       /* link info */
+       mac->ops.get_link_up_info = e1000_get_link_up_info_82575;
+
+       return E1000_SUCCESS;
+}
 
-       /* Verify phy id and set remaining function pointers */
-       switch (phy->id) {
-       case M88E1111_I_PHY_ID:
-               phy->type                   = e1000_phy_m88;
-               phy->ops.get_phy_info       = igb_get_phy_info_m88;
-               phy->ops.get_cable_length   = igb_get_cable_length_m88;
-               phy->ops.force_speed_duplex = igb_phy_force_speed_duplex_m88;
-               break;
-       case IGP03E1000_E_PHY_ID:
-               phy->type                   = e1000_phy_igp_3;
-               phy->ops.get_phy_info       = igb_get_phy_info_igp;
-               phy->ops.get_cable_length   = igb_get_cable_length_igp_2;
-               phy->ops.force_speed_duplex = igb_phy_force_speed_duplex_igp;
-               phy->ops.set_d0_lplu_state  = igb_set_d0_lplu_state_82575;
-               phy->ops.set_d3_lplu_state  = igb_set_d3_lplu_state;
-               break;
-       default:
-               return -E1000_ERR_PHY;
-       }
+/**
+ *  e1000_init_function_pointers_82575 - Init func ptrs.
+ *  @hw: pointer to the HW structure
+ *
+ *  Called to initialize all function pointers and parameters.
+ **/
+void e1000_init_function_pointers_82575(struct e1000_hw *hw)
+{
+       DEBUGFUNC("e1000_init_function_pointers_82575");
 
-       return 0;
+       hw->mac.ops.init_params = e1000_init_mac_params_82575;
+       hw->nvm.ops.init_params = e1000_init_nvm_params_82575;
+       hw->phy.ops.init_params = e1000_init_phy_params_82575;
 }
 
 /**
  *  e1000_acquire_phy_82575 - Acquire rights to access PHY
  *  @hw: pointer to the HW structure
  *
- *  Acquire access rights to the correct PHY.  This is a
- *  function pointer entry point called by the api module.
+ *  Acquire access rights to the correct PHY.
  **/
-static s32 igb_acquire_phy_82575(struct e1000_hw *hw)
+static s32 e1000_acquire_phy_82575(struct e1000_hw *hw)
 {
        u16 mask;
 
+       DEBUGFUNC("e1000_acquire_phy_82575");
+
        mask = hw->bus.func ? E1000_SWFW_PHY1_SM : E1000_SWFW_PHY0_SM;
 
-       return igb_acquire_swfw_sync_82575(hw, mask);
+       return e1000_acquire_swfw_sync_82575(hw, mask);
 }
 
 /**
  *  e1000_release_phy_82575 - Release rights to access PHY
  *  @hw: pointer to the HW structure
  *
- *  A wrapper to release access rights to the correct PHY.  This is a
- *  function pointer entry point called by the api module.
+ *  A wrapper to release access rights to the correct PHY.
  **/
-static void igb_release_phy_82575(struct e1000_hw *hw)
+static void e1000_release_phy_82575(struct e1000_hw *hw)
 {
        u16 mask;
 
+       DEBUGFUNC("e1000_release_phy_82575");
+
        mask = hw->bus.func ? E1000_SWFW_PHY1_SM : E1000_SWFW_PHY0_SM;
-       igb_release_swfw_sync_82575(hw, mask);
+       e1000_release_swfw_sync_82575(hw, mask);
 }
 
 /**
@@ -261,14 +355,16 @@ static void igb_release_phy_82575(struct e1000_hw *hw)
  *  Reads the PHY register at offset using the serial gigabit media independent
  *  interface and stores the retrieved information in data.
  **/
-static s32 igb_read_phy_reg_sgmii_82575(struct e1000_hw *hw, u32 offset,
-                                         u16 *data)
+static s32 e1000_read_phy_reg_sgmii_82575(struct e1000_hw *hw, u32 offset,
+                                          u16 *data)
 {
        struct e1000_phy_info *phy = &hw->phy;
        u32 i, i2ccmd = 0;
 
+       DEBUGFUNC("e1000_read_phy_reg_sgmii_82575");
+
        if (offset > E1000_MAX_SGMII_PHY_REG_ADDR) {
-               hw_dbg(hw, "PHY Address %u is out of range\n", offset);
+               DEBUGOUT1("PHY Address %u is out of range\n", offset);
                return -E1000_ERR_PARAM;
        }
 
@@ -278,31 +374,31 @@ static s32 igb_read_phy_reg_sgmii_82575(struct e1000_hw *hw, u32 offset,
         * PHY to retrieve the desired data.
         */
        i2ccmd = ((offset << E1000_I2CCMD_REG_ADDR_SHIFT) |
-                 (phy->addr << E1000_I2CCMD_PHY_ADDR_SHIFT) |
-                 (E1000_I2CCMD_OPCODE_READ));
+                 (phy->addr << E1000_I2CCMD_PHY_ADDR_SHIFT) |
+                 (E1000_I2CCMD_OPCODE_READ));
 
-       wr32(E1000_I2CCMD, i2ccmd);
+       E1000_WRITE_REG(hw, E1000_I2CCMD, i2ccmd);
 
        /* Poll the ready bit to see if the I2C read completed */
        for (i = 0; i < E1000_I2CCMD_PHY_TIMEOUT; i++) {
-               udelay(50);
-               i2ccmd = rd32(E1000_I2CCMD);
+               usec_delay(50);
+               i2ccmd = E1000_READ_REG(hw, E1000_I2CCMD);
                if (i2ccmd & E1000_I2CCMD_READY)
                        break;
        }
        if (!(i2ccmd & E1000_I2CCMD_READY)) {
-               hw_dbg(hw, "I2CCMD Read did not complete\n");
+               DEBUGOUT("I2CCMD Read did not complete\n");
                return -E1000_ERR_PHY;
        }
        if (i2ccmd & E1000_I2CCMD_ERROR) {
-               hw_dbg(hw, "I2CCMD Error bit set\n");
+               DEBUGOUT("I2CCMD Error bit set\n");
                return -E1000_ERR_PHY;
        }
 
        /* Need to byte-swap the 16-bit value. */
        *data = ((i2ccmd >> 8) & 0x00FF) | ((i2ccmd << 8) & 0xFF00);
 
-       return 0;
+       return E1000_SUCCESS;
 }
 
 /**
@@ -314,15 +410,17 @@ static s32 igb_read_phy_reg_sgmii_82575(struct e1000_hw *hw, u32 offset,
  *  Writes the data to PHY register at the offset using the serial gigabit
  *  media independent interface.
  **/
-static s32 igb_write_phy_reg_sgmii_82575(struct e1000_hw *hw, u32 offset,
-                                          u16 data)
+static s32 e1000_write_phy_reg_sgmii_82575(struct e1000_hw *hw, u32 offset,
+                                           u16 data)
 {
        struct e1000_phy_info *phy = &hw->phy;
        u32 i, i2ccmd = 0;
        u16 phy_data_swapped;
 
+       DEBUGFUNC("e1000_write_phy_reg_sgmii_82575");
+
        if (offset > E1000_MAX_SGMII_PHY_REG_ADDR) {
-               hw_dbg(hw, "PHY Address %d is out of range\n", offset);
+               DEBUGOUT1("PHY Address %d is out of range\n", offset);
                return -E1000_ERR_PARAM;
        }
 
@@ -335,44 +433,46 @@ static s32 igb_write_phy_reg_sgmii_82575(struct e1000_hw *hw, u32 offset,
         * PHY to retrieve the desired data.
         */
        i2ccmd = ((offset << E1000_I2CCMD_REG_ADDR_SHIFT) |
-                 (phy->addr << E1000_I2CCMD_PHY_ADDR_SHIFT) |
-                 E1000_I2CCMD_OPCODE_WRITE |
-                 phy_data_swapped);
+                 (phy->addr << E1000_I2CCMD_PHY_ADDR_SHIFT) |
+                 E1000_I2CCMD_OPCODE_WRITE |
+                 phy_data_swapped);
 
-       wr32(E1000_I2CCMD, i2ccmd);
+       E1000_WRITE_REG(hw, E1000_I2CCMD, i2ccmd);
 
        /* Poll the ready bit to see if the I2C read completed */
        for (i = 0; i < E1000_I2CCMD_PHY_TIMEOUT; i++) {
-               udelay(50);
-               i2ccmd = rd32(E1000_I2CCMD);
+               usec_delay(50);
+               i2ccmd = E1000_READ_REG(hw, E1000_I2CCMD);
                if (i2ccmd & E1000_I2CCMD_READY)
                        break;
        }
        if (!(i2ccmd & E1000_I2CCMD_READY)) {
-               hw_dbg(hw, "I2CCMD Write did not complete\n");
+               DEBUGOUT("I2CCMD Write did not complete\n");
                return -E1000_ERR_PHY;
        }
        if (i2ccmd & E1000_I2CCMD_ERROR) {
-               hw_dbg(hw, "I2CCMD Error bit set\n");
+               DEBUGOUT("I2CCMD Error bit set\n");
                return -E1000_ERR_PHY;
        }
 
-       return 0;
+       return E1000_SUCCESS;
 }
 
 /**
- *  e1000_get_phy_id_82575 - Retreive PHY addr and id
+ *  e1000_get_phy_id_82575 - Retrieve PHY addr and id
  *  @hw: pointer to the HW structure
  *
- *  Retreives the PHY address and ID for both PHY's which do and do not use
+ *  Retrieves the PHY address and ID for both PHY's which do and do not use
  *  sgmi interface.
  **/
-static s32 igb_get_phy_id_82575(struct e1000_hw *hw)
+static s32 e1000_get_phy_id_82575(struct e1000_hw *hw)
 {
        struct e1000_phy_info *phy = &hw->phy;
-       s32  ret_val = 0;
+       s32  ret_val = E1000_SUCCESS;
        u16 phy_id;
 
+       DEBUGFUNC("e1000_get_phy_id_82575");
+
        /*
         * For SGMII PHYs, we try the list of possible addresses until
         * we find one that works.  For non-SGMII PHYs
@@ -380,9 +480,9 @@ static s32 igb_get_phy_id_82575(struct e1000_hw *hw)
         * work.  The result of this function should mean phy->phy_addr
         * and phy->id are set correctly.
         */
-       if (!(igb_sgmii_active_82575(hw))) {
+       if (!(e1000_sgmii_active_82575(hw))) {
                phy->addr = 1;
-               ret_val = igb_get_phy_id(hw);
+               ret_val = e1000_get_phy_id(hw);
                goto out;
        }
 
@@ -391,11 +491,11 @@ static s32 igb_get_phy_id_82575(struct e1000_hw *hw)
         * Therefore, we need to test 1-7
         */
        for (phy->addr = 1; phy->addr < 8; phy->addr++) {
-               ret_val = igb_read_phy_reg_sgmii_82575(hw, PHY_ID1, &phy_id);
-               if (ret_val == 0) {
-                       hw_dbg(hw, "Vendor ID 0x%08X read at address %u\n",
-                                 phy_id,
-                                 phy->addr);
+               ret_val = e1000_read_phy_reg_sgmii_82575(hw, PHY_ID1, &phy_id);
+               if (ret_val == E1000_SUCCESS) {
+                       DEBUGOUT2("Vendor ID 0x%08X read at address %u\n",
+                                 phy_id,
+                                 phy->addr);
                        /*
                         * At the time of this writing, The M88 part is
                         * the only supported SGMII PHY product.
@@ -403,8 +503,8 @@ static s32 igb_get_phy_id_82575(struct e1000_hw *hw)
                        if (phy_id == M88_VENDOR)
                                break;
                } else {
-                       hw_dbg(hw, "PHY address %u was unreadable\n",
-                                 phy->addr);
+                       DEBUGOUT1("PHY address %u was unreadable\n",
+                                 phy->addr);
                }
        }
 
@@ -415,7 +515,7 @@ static s32 igb_get_phy_id_82575(struct e1000_hw *hw)
                goto out;
        }
 
-       ret_val = igb_get_phy_id(hw);
+       ret_val = e1000_get_phy_id(hw);
 
 out:
        return ret_val;
@@ -427,26 +527,31 @@ out:
  *
  *  Resets the PHY using the serial gigabit media independent interface.
  **/
-static s32 igb_phy_hw_reset_sgmii_82575(struct e1000_hw *hw)
+static s32 e1000_phy_hw_reset_sgmii_82575(struct e1000_hw *hw)
 {
-       s32 ret_val;
+       s32 ret_val = E1000_SUCCESS;
+
+       DEBUGFUNC("e1000_phy_hw_reset_sgmii_82575");
 
        /*
         * This isn't a true "hard" reset, but is the only reset
         * available to us at this time.
-       */
+        */
+
+       DEBUGOUT("Soft resetting SGMII attached PHY...\n");
 
-       hw_dbg(hw, "Soft resetting SGMII attached PHY...\n");
+       if (!(hw->phy.ops.write_reg))
+               goto out;
 
        /*
         * SFP documentation requires the following to configure the SPF module
         * to work on SGMII.  No further documentation is given.
         */
-       ret_val = hw->phy.ops.write_phy_reg(hw, 0x1B, 0x8084);
+       ret_val = hw->phy.ops.write_reg(hw, 0x1B, 0x8084);
        if (ret_val)
                goto out;
 
-       ret_val = igb_phy_sw_reset(hw);
+       ret_val = hw->phy.ops.commit(hw);
 
 out:
        return ret_val;
@@ -465,40 +570,40 @@ out:
  *  This is a function pointer entry point only called by
  *  PHY setup routines.
  **/
-static s32 igb_set_d0_lplu_state_82575(struct e1000_hw *hw, bool active)
+static s32 e1000_set_d0_lplu_state_82575(struct e1000_hw *hw, bool active)
 {
        struct e1000_phy_info *phy = &hw->phy;
-       s32 ret_val;
+       s32 ret_val = E1000_SUCCESS;
        u16 data;
 
-       ret_val = hw->phy.ops.read_phy_reg(hw, IGP02E1000_PHY_POWER_MGMT,
-                                          &data);
+       DEBUGFUNC("e1000_set_d0_lplu_state_82575");
+
+       if (!(hw->phy.ops.read_reg))
+               goto out;
+
+       ret_val = phy->ops.read_reg(hw, IGP02E1000_PHY_POWER_MGMT, &data);
        if (ret_val)
                goto out;
 
        if (active) {
                data |= IGP02E1000_PM_D0_LPLU;
-               ret_val = hw->phy.ops.write_phy_reg(hw,
-                                             IGP02E1000_PHY_POWER_MGMT,
-                                             data);
+               ret_val = phy->ops.write_reg(hw, IGP02E1000_PHY_POWER_MGMT,
+                                            data);
                if (ret_val)
                        goto out;
 
                /* When LPLU is enabled, we should disable SmartSpeed */
-               ret_val = hw->phy.ops.read_phy_reg(hw,
-                                            IGP01E1000_PHY_PORT_CONFIG,
-                                            &data);
+               ret_val = phy->ops.read_reg(hw, IGP01E1000_PHY_PORT_CONFIG,
+                                           &data);
                data &= ~IGP01E1000_PSCFR_SMART_SPEED;
-               ret_val = hw->phy.ops.write_phy_reg(hw,
-                                             IGP01E1000_PHY_PORT_CONFIG,
-                                             data);
+               ret_val = phy->ops.write_reg(hw, IGP01E1000_PHY_PORT_CONFIG,
+                                            data);
                if (ret_val)
                        goto out;
        } else {
                data &= ~IGP02E1000_PM_D0_LPLU;
-               ret_val = hw->phy.ops.write_phy_reg(hw,
-                                             IGP02E1000_PHY_POWER_MGMT,
-                                             data);
+               ret_val = phy->ops.write_reg(hw, IGP02E1000_PHY_POWER_MGMT,
+                                            data);
                /*
                 * LPLU and SmartSpeed are mutually exclusive.  LPLU is used
                 * during Dx states where the power conservation is most
@@ -506,29 +611,29 @@ static s32 igb_set_d0_lplu_state_82575(struct e1000_hw *hw, bool active)
                 * SmartSpeed, so performance is maintained.
                 */
                if (phy->smart_speed == e1000_smart_speed_on) {
-                       ret_val = hw->phy.ops.read_phy_reg(hw,
-                                                    IGP01E1000_PHY_PORT_CONFIG,
-                                                    &data);
+                       ret_val = phy->ops.read_reg(hw,
+                                                   IGP01E1000_PHY_PORT_CONFIG,
+                                                   &data);
                        if (ret_val)
                                goto out;
 
                        data |= IGP01E1000_PSCFR_SMART_SPEED;
-                       ret_val = hw->phy.ops.write_phy_reg(hw,
-                                                    IGP01E1000_PHY_PORT_CONFIG,
-                                                    data);
+                       ret_val = phy->ops.write_reg(hw,
+                                                    IGP01E1000_PHY_PORT_CONFIG,
+                                                    data);
                        if (ret_val)
                                goto out;
                } else if (phy->smart_speed == e1000_smart_speed_off) {
-                       ret_val = hw->phy.ops.read_phy_reg(hw,
-                                                    IGP01E1000_PHY_PORT_CONFIG,
-                                                    &data);
+                       ret_val = phy->ops.read_reg(hw,
+                                                   IGP01E1000_PHY_PORT_CONFIG,
+                                                   &data);
                        if (ret_val)
                                goto out;
 
                        data &= ~IGP01E1000_PSCFR_SMART_SPEED;
-                       ret_val = hw->phy.ops.write_phy_reg(hw,
-                                                    IGP01E1000_PHY_PORT_CONFIG,
-                                                    data);
+                       ret_val = phy->ops.write_reg(hw,
+                                                    IGP01E1000_PHY_PORT_CONFIG,
+                                                    data);
                        if (ret_val)
                                goto out;
                }
@@ -542,23 +647,25 @@ out:
  *  e1000_acquire_nvm_82575 - Request for access to EEPROM
  *  @hw: pointer to the HW structure
  *
- *  Acquire the necessary semaphores for exclussive access to the EEPROM.
+ *  Acquire the necessary semaphores for exclusive access to the EEPROM.
  *  Set the EEPROM access request bit and wait for EEPROM access grant bit.
  *  Return successful if access grant bit set, else clear the request for
  *  EEPROM access and return -E1000_ERR_NVM (-1).
  **/
-static s32 igb_acquire_nvm_82575(struct e1000_hw *hw)
+static s32 e1000_acquire_nvm_82575(struct e1000_hw *hw)
 {
        s32 ret_val;
 
-       ret_val = igb_acquire_swfw_sync_82575(hw, E1000_SWFW_EEP_SM);
+       DEBUGFUNC("e1000_acquire_nvm_82575");
+
+       ret_val = e1000_acquire_swfw_sync_82575(hw, E1000_SWFW_EEP_SM);
        if (ret_val)
                goto out;
 
-       ret_val = igb_acquire_nvm(hw);
+       ret_val = e1000_acquire_nvm_generic(hw);
 
        if (ret_val)
-               igb_release_swfw_sync_82575(hw, E1000_SWFW_EEP_SM);
+               e1000_release_swfw_sync_82575(hw, E1000_SWFW_EEP_SM);
 
 out:
        return ret_val;
@@ -571,10 +678,12 @@ out:
  *  Stop any current commands to the EEPROM and clear the EEPROM request bit,
  *  then release the semaphores acquired.
  **/
-static void igb_release_nvm_82575(struct e1000_hw *hw)
+static void e1000_release_nvm_82575(struct e1000_hw *hw)
 {
-       igb_release_nvm(hw);
-       igb_release_swfw_sync_82575(hw, E1000_SWFW_EEP_SM);
+       DEBUGFUNC("e1000_release_nvm_82575");
+
+       e1000_release_nvm_generic(hw);
+       e1000_release_swfw_sync_82575(hw, E1000_SWFW_EEP_SM);
 }
 
 /**
@@ -585,21 +694,23 @@ static void igb_release_nvm_82575(struct e1000_hw *hw)
  *  Acquire the SW/FW semaphore to access the PHY or NVM.  The mask
  *  will also specify which port we're acquiring the lock for.
  **/
-static s32 igb_acquire_swfw_sync_82575(struct e1000_hw *hw, u16 mask)
+static s32 e1000_acquire_swfw_sync_82575(struct e1000_hw *hw, u16 mask)
 {
        u32 swfw_sync;
        u32 swmask = mask;
        u32 fwmask = mask << 16;
-       s32 ret_val = 0;
+       s32 ret_val = E1000_SUCCESS;
        s32 i = 0, timeout = 200; /* FIXME: find real value to use here */
 
+       DEBUGFUNC("e1000_acquire_swfw_sync_82575");
+
        while (i < timeout) {
-               if (igb_get_hw_semaphore(hw)) {
+               if (e1000_get_hw_semaphore_generic(hw)) {
                        ret_val = -E1000_ERR_SWFW_SYNC;
                        goto out;
                }
 
-               swfw_sync = rd32(E1000_SW_FW_SYNC);
+               swfw_sync = E1000_READ_REG(hw, E1000_SW_FW_SYNC);
                if (!(swfw_sync & (fwmask | swmask)))
                        break;
 
@@ -607,21 +718,21 @@ static s32 igb_acquire_swfw_sync_82575(struct e1000_hw *hw, u16 mask)
                 * Firmware currently using resource (fwmask)
                 * or other software thread using resource (swmask)
                 */
-               igb_put_hw_semaphore(hw);
-               mdelay(5);
+               e1000_put_hw_semaphore_generic(hw);
+               msec_delay_irq(5);
                i++;
        }
 
        if (i == timeout) {
-               hw_dbg(hw, "Can't access resource, SW_FW_SYNC timeout.\n");
+               DEBUGOUT("Driver can't access resource, SW_FW_SYNC timeout.\n");
                ret_val = -E1000_ERR_SWFW_SYNC;
                goto out;
        }
 
        swfw_sync |= swmask;
-       wr32(E1000_SW_FW_SYNC, swfw_sync);
+       E1000_WRITE_REG(hw, E1000_SW_FW_SYNC, swfw_sync);
 
-       igb_put_hw_semaphore(hw);
+       e1000_put_hw_semaphore_generic(hw);
 
 out:
        return ret_val;
@@ -635,18 +746,20 @@ out:
  *  Release the SW/FW semaphore used to access the PHY or NVM.  The mask
  *  will also specify which port we're releasing the lock for.
  **/
-static void igb_release_swfw_sync_82575(struct e1000_hw *hw, u16 mask)
+static void e1000_release_swfw_sync_82575(struct e1000_hw *hw, u16 mask)
 {
        u32 swfw_sync;
 
-       while (igb_get_hw_semaphore(hw) != 0);
+       DEBUGFUNC("e1000_release_swfw_sync_82575");
+
+       while (e1000_get_hw_semaphore_generic(hw) != E1000_SUCCESS);
        /* Empty */
 
-       swfw_sync = rd32(E1000_SW_FW_SYNC);
+       swfw_sync = E1000_READ_REG(hw, E1000_SW_FW_SYNC);
        swfw_sync &= ~mask;
-       wr32(E1000_SW_FW_SYNC, swfw_sync);
+       E1000_WRITE_REG(hw, E1000_SW_FW_SYNC, swfw_sync);
 
-       igb_put_hw_semaphore(hw);
+       e1000_put_hw_semaphore_generic(hw);
 }
 
 /**
@@ -656,31 +769,64 @@ static void igb_release_swfw_sync_82575(struct e1000_hw *hw, u16 mask)
  *  Read the management control register for the config done bit for
  *  completion status.  NOTE: silicon which is EEPROM-less will fail trying
  *  to read the config done bit, so an error is *ONLY* logged and returns
- *  0.  If we were to return with error, EEPROM-less silicon
+ *  E1000_SUCCESS.  If we were to return with error, EEPROM-less silicon
  *  would not be able to be reset or change link.
  **/
-static s32 igb_get_cfg_done_82575(struct e1000_hw *hw)
+static s32 e1000_get_cfg_done_82575(struct e1000_hw *hw)
 {
        s32 timeout = PHY_CFG_TIMEOUT;
-       s32 ret_val = 0;
+       s32 ret_val = E1000_SUCCESS;
        u32 mask = E1000_NVM_CFG_DONE_PORT_0;
 
+       DEBUGFUNC("e1000_get_cfg_done_82575");
+
        if (hw->bus.func == 1)
                mask = E1000_NVM_CFG_DONE_PORT_1;
 
        while (timeout) {
-               if (rd32(E1000_EEMNGCTL) & mask)
+               if (E1000_READ_REG(hw, E1000_EEMNGCTL) & mask)
                        break;
-               msleep(1);
+               msec_delay(1);
                timeout--;
        }
-       if (!timeout)
-               hw_dbg(hw, "MNG configuration cycle has not completed.\n");
+       if (!timeout) {
+               DEBUGOUT("MNG configuration cycle has not completed.\n");
+       }
 
        /* If EEPROM is not marked present, init the PHY manually */
-       if (((rd32(E1000_EECD) & E1000_EECD_PRES) == 0) &&
-           (hw->phy.type == e1000_phy_igp_3))
-               igb_phy_init_script_igp3(hw);
+       if (((E1000_READ_REG(hw, E1000_EECD) & E1000_EECD_PRES) == 0) &&
+           (hw->phy.type == e1000_phy_igp_3)) {
+               e1000_phy_init_script_igp3(hw);
+       }
+
+       return ret_val;
+}
+
+/**
+ *  e1000_get_link_up_info_82575 - Get link speed/duplex info
+ *  @hw: pointer to the HW structure
+ *  @speed: stores the current speed
+ *  @duplex: stores the current duplex
+ *
+ *  This is a wrapper function, if using the serial gigabit media independent
+ *  interface, use PCS to retrieve the link speed and duplex information.
+ *  Otherwise, use the generic function to get the link speed and duplex info.
+ **/
+static s32 e1000_get_link_up_info_82575(struct e1000_hw *hw, u16 *speed,
+                                        u16 *duplex)
+{
+       s32 ret_val;
+
+       DEBUGFUNC("e1000_get_link_up_info_82575");
+
+       if (hw->phy.media_type != e1000_media_type_copper ||
+           e1000_sgmii_active_82575(hw)) {
+               ret_val = e1000_get_pcs_speed_and_duplex_82575(hw, speed,
+                                                              duplex);
+       } else {
+               ret_val = e1000_get_speed_and_duplex_copper_generic(hw, speed,
+                                                                   duplex);
+       }
 
        return ret_val;
 }
@@ -692,18 +838,20 @@ static s32 igb_get_cfg_done_82575(struct e1000_hw *hw)
  *  If sgmii is enabled, then use the pcs register to determine link, otherwise
  *  use the generic interface for determining link.
  **/
-static s32 igb_check_for_link_82575(struct e1000_hw *hw)
+static s32 e1000_check_for_link_82575(struct e1000_hw *hw)
 {
        s32 ret_val;
        u16 speed, duplex;
 
+       DEBUGFUNC("e1000_check_for_link_82575");
+
        /* SGMII link check is done through the PCS register. */
        if ((hw->phy.media_type != e1000_media_type_copper) ||
-           (igb_sgmii_active_82575(hw)))
-               ret_val = igb_get_pcs_speed_and_duplex_82575(hw, &speed,
-                                                              &duplex);
+           (e1000_sgmii_active_82575(hw)))
+               ret_val = e1000_get_pcs_speed_and_duplex_82575(hw, &speed,
+                                                              &duplex);
        else
-               ret_val = igb_check_for_copper_link(hw);
+               ret_val = e1000_check_for_copper_link_generic(hw);
 
        return ret_val;
 }
@@ -714,15 +862,17 @@ static s32 igb_check_for_link_82575(struct e1000_hw *hw)
  *  @speed: stores the current speed
  *  @duplex: stores the current duplex
  *
- *  Using the physical coding sub-layer (PCS), retreive the current speed and
+ *  Using the physical coding sub-layer (PCS), retrieve the current speed and
  *  duplex, then store the values in the pointers provided.
  **/
-static s32 igb_get_pcs_speed_and_duplex_82575(struct e1000_hw *hw, u16 *speed,
-                                               u16 *duplex)
+static s32 e1000_get_pcs_speed_and_duplex_82575(struct e1000_hw *hw,
+                                                u16 *speed, u16 *duplex)
 {
        struct e1000_mac_info *mac = &hw->mac;
        u32 pcs;
 
+       DEBUGFUNC("e1000_get_pcs_speed_and_duplex_82575");
+
        /* Set up defaults for the return values of this function */
        mac->serdes_has_link = false;
        *speed = 0;
@@ -733,7 +883,7 @@ static s32 igb_get_pcs_speed_and_duplex_82575(struct e1000_hw *hw, u16 *speed,
         * the status register is not accurate. The PCS status register is
         * used instead.
         */
-       pcs = rd32(E1000_PCS_LSTAT);
+       pcs = E1000_READ_REG(hw, E1000_PCS_LSTAT);
 
        /*
         * The link up bit determines when link is up on autoneg. The sync ok
@@ -760,22 +910,144 @@ static s32 igb_get_pcs_speed_and_duplex_82575(struct e1000_hw *hw, u16 *speed,
                }
        }
 
-       return 0;
+       return E1000_SUCCESS;
+}
+
+/**
+ *  e1000_init_rx_addrs_82575 - Initialize receive address's
+ *  @hw: pointer to the HW structure
+ *  @rar_count: receive address registers
+ *
+ *  Setups the receive address registers by setting the base receive address
+ *  register to the devices MAC address and clearing all the other receive
+ *  address registers to 0.
+ **/
+static void e1000_init_rx_addrs_82575(struct e1000_hw *hw, u16 rar_count)
+{
+       u32 i;
+       u8 addr[6] = {0,0,0,0,0,0};
+       /*
+        * This function is essentially the same as that of
+        * e1000_init_rx_addrs_generic. However it also takes care
+        * of the special case where the register offset of the
+        * second set of RARs begins elsewhere. This is implicitly taken care by
+        * function e1000_rar_set_generic.
+        */
+
+       DEBUGFUNC("e1000_init_rx_addrs_82575");
+
+       /* Setup the receive address */
+       DEBUGOUT("Programming MAC Address into RAR[0]\n");
+       hw->mac.ops.rar_set(hw, hw->mac.addr, 0);
+
+       /* Zero out the other (rar_entry_count - 1) receive addresses */
+       DEBUGOUT1("Clearing RAR[1-%u]\n", rar_count-1);
+       for (i = 1; i < rar_count; i++) {
+           hw->mac.ops.rar_set(hw, addr, i);
+       }
+}
+
+/**
+ *  e1000_update_mc_addr_list_82575 - Update Multicast addresses
+ *  @hw: pointer to the HW structure
+ *  @mc_addr_list: array of multicast addresses to program
+ *  @mc_addr_count: number of multicast addresses to program
+ *  @rar_used_count: the first RAR register free to program
+ *  @rar_count: total number of supported Receive Address Registers
+ *
+ *  Updates the Receive Address Registers and Multicast Table Array.
+ *  The caller must have a packed mc_addr_list of multicast addresses.
+ *  The parameter rar_count will usually be hw->mac.rar_entry_count
+ *  unless there are workarounds that change this.
+ **/
+static void e1000_update_mc_addr_list_82575(struct e1000_hw *hw,
+                                     u8 *mc_addr_list, u32 mc_addr_count,
+                                     u32 rar_used_count, u32 rar_count)
+{
+       u32 hash_value;
+       u32 i;
+       u8 addr[6] = {0,0,0,0,0,0};
+       /*
+        * This function is essentially the same as that of 
+        * e1000_update_mc_addr_list_generic. However it also takes care 
+        * of the special case where the register offset of the 
+        * second set of RARs begins elsewhere. This is implicitly taken care by 
+        * function e1000_rar_set_generic.
+        */
+
+       DEBUGFUNC("e1000_update_mc_addr_list_82575");
+
+       /*
+        * Load the first set of multicast addresses into the exact
+        * filters (RAR).  If there are not enough to fill the RAR
+        * array, clear the filters.
+        */
+       for (i = rar_used_count; i < rar_count; i++) {
+               if (mc_addr_count) {
+                       e1000_rar_set_generic(hw, mc_addr_list, i);
+                       mc_addr_count--;
+                       mc_addr_list += ETH_ADDR_LEN;
+               } else {
+                       e1000_rar_set_generic(hw, addr, i);
+               }
+       }
+
+       /* Clear the old settings from the MTA */
+       DEBUGOUT("Clearing MTA\n");
+       for (i = 0; i < hw->mac.mta_reg_count; i++) {
+               E1000_WRITE_REG_ARRAY(hw, E1000_MTA, i, 0);
+               E1000_WRITE_FLUSH(hw);
+       }
+
+       /* Load any remaining multicast addresses into the hash table. */
+       for (; mc_addr_count > 0; mc_addr_count--) {
+               hash_value = e1000_hash_mc_addr(hw, mc_addr_list);
+               DEBUGOUT1("Hash value = 0x%03X\n", hash_value);
+               hw->mac.ops.mta_set(hw, hash_value);
+               mc_addr_list += ETH_ADDR_LEN;
+       }
 }
 
 /**
- *  e1000_rar_set_82575 - Set receive address register
+ *  e1000_shutdown_fiber_serdes_link_82575 - Remove link during power down
  *  @hw: pointer to the HW structure
- *  @addr: pointer to the receive address
- *  @index: receive address array register
  *
- *  Sets the receive address array register at index to the address passed
- *  in by addr.
+ *  In the case of fiber serdes shut down optics and PCS on driver unload
+ *  when management pass thru is not enabled.
  **/
-static void igb_rar_set_82575(struct e1000_hw *hw, u8 *addr, u32 index)
+void e1000_shutdown_fiber_serdes_link_82575(struct e1000_hw *hw)
 {
-       if (index < E1000_RAR_ENTRIES_82575)
-               igb_rar_set(hw, addr, index);
+       u32 reg;
+       u16 eeprom_data = 0;
+
+       if (hw->mac.type != e1000_82576 ||
+          (hw->phy.media_type != e1000_media_type_fiber &&
+           hw->phy.media_type != e1000_media_type_internal_serdes))
+               return;
+
+       if (hw->bus.func == 0)
+               hw->nvm.ops.read(hw, NVM_INIT_CONTROL3_PORT_A, 1, &eeprom_data);
+
+       /*
+        * If APM is not enabled in the EEPROM and management interface is
+        * not enabled, then power down.
+        */
+       if (!(eeprom_data & E1000_NVM_APME_82575) &&
+           !e1000_enable_mng_pass_thru(hw)) {
+               /* Disable PCS to turn off link */
+               reg = E1000_READ_REG(hw, E1000_PCS_CFG0);
+               reg &= ~E1000_PCS_CFG_PCS_EN;
+               E1000_WRITE_REG(hw, E1000_PCS_CFG0, reg);
+
+               /* shutdown the laser */
+               reg = E1000_READ_REG(hw, E1000_CTRL_EXT);
+               reg |= E1000_CTRL_EXT_SDP7_DATA;
+               E1000_WRITE_REG(hw, E1000_CTRL_EXT, reg);
+
+               /* flush the write to verfiy completion */
+               E1000_WRITE_FLUSH(hw);
+               msec_delay(1);
+       }
 
        return;
 }
@@ -784,55 +1056,57 @@ static void igb_rar_set_82575(struct e1000_hw *hw, u8 *addr, u32 index)
  *  e1000_reset_hw_82575 - Reset hardware
  *  @hw: pointer to the HW structure
  *
- *  This resets the hardware into a known state.  This is a
- *  function pointer entry point called by the api module.
+ *  This resets the hardware into a known state.
  **/
-static s32 igb_reset_hw_82575(struct e1000_hw *hw)
+static s32 e1000_reset_hw_82575(struct e1000_hw *hw)
 {
        u32 ctrl, icr;
        s32 ret_val;
 
+       DEBUGFUNC("e1000_reset_hw_82575");
+
        /*
         * Prevent the PCI-E bus from sticking if there is no TLP connection
         * on the last TLP read/write transaction when MAC is reset.
         */
-       ret_val = igb_disable_pcie_master(hw);
-       if (ret_val)
-               hw_dbg(hw, "PCI-E Master disable polling has failed.\n");
+       ret_val = e1000_disable_pcie_master_generic(hw);
+       if (ret_val) {
+               DEBUGOUT("PCI-E Master disable polling has failed.\n");
+       }
 
-       hw_dbg(hw, "Masking off all interrupts\n");
-       wr32(E1000_IMC, 0xffffffff);
+       DEBUGOUT("Masking off all interrupts\n");
+       E1000_WRITE_REG(hw, E1000_IMC, 0xffffffff);
 
-       wr32(E1000_RCTL, 0);
-       wr32(E1000_TCTL, E1000_TCTL_PSP);
-       wrfl();
+       E1000_WRITE_REG(hw, E1000_RCTL, 0);
+       E1000_WRITE_REG(hw, E1000_TCTL, E1000_TCTL_PSP);
+       E1000_WRITE_FLUSH(hw);
 
-       msleep(10);
+       msec_delay(10);
 
-       ctrl = rd32(E1000_CTRL);
+       ctrl = E1000_READ_REG(hw, E1000_CTRL);
 
-       hw_dbg(hw, "Issuing a global reset to MAC\n");
-       wr32(E1000_CTRL, ctrl | E1000_CTRL_RST);
+       DEBUGOUT("Issuing a global reset to MAC\n");
+       E1000_WRITE_REG(hw, E1000_CTRL, ctrl | E1000_CTRL_RST);
 
-       ret_val = igb_get_auto_rd_done(hw);
+       ret_val = e1000_get_auto_rd_done_generic(hw);
        if (ret_val) {
                /*
                 * When auto config read does not complete, do not
                 * return with an error. This can happen in situations
                 * where there is no eeprom and prevents getting link.
                 */
-               hw_dbg(hw, "Auto Read Done did not complete\n");
+               DEBUGOUT("Auto Read Done did not complete\n");
        }
 
        /* If EEPROM is not present, run manual init scripts */
-       if ((rd32(E1000_EECD) & E1000_EECD_PRES) == 0)
-               igb_reset_init_script_82575(hw);
+       if ((E1000_READ_REG(hw, E1000_EECD) & E1000_EECD_PRES) == 0)
+               e1000_reset_init_script_82575(hw);
 
        /* Clear any pending interrupt events. */
-       wr32(E1000_IMC, 0xffffffff);
-       icr = rd32(E1000_ICR);
+       E1000_WRITE_REG(hw, E1000_IMC, 0xffffffff);
+       icr = E1000_READ_REG(hw, E1000_ICR);
 
-       igb_check_alt_mac_addr(hw);
+       e1000_check_alt_mac_addr_generic(hw);
 
        return ret_val;
 }
@@ -843,32 +1117,34 @@ static s32 igb_reset_hw_82575(struct e1000_hw *hw)
  *
  *  This inits the hardware readying it for operation.
  **/
-static s32 igb_init_hw_82575(struct e1000_hw *hw)
+static s32 e1000_init_hw_82575(struct e1000_hw *hw)
 {
        struct e1000_mac_info *mac = &hw->mac;
        s32 ret_val;
        u16 i, rar_count = mac->rar_entry_count;
 
+       DEBUGFUNC("e1000_init_hw_82575");
+
        /* Initialize identification LED */
-       ret_val = igb_id_led_init(hw);
+       ret_val = e1000_id_led_init_generic(hw);
        if (ret_val) {
-               hw_dbg(hw, "Error initializing identification LED\n");
+               DEBUGOUT("Error initializing identification LED\n");
                /* This is not fatal and we should not stop init due to this */
        }
 
        /* Disabling VLAN filtering */
-       hw_dbg(hw, "Initializing the IEEE VLAN\n");
-       igb_clear_vfta(hw);
+       DEBUGOUT("Initializing the IEEE VLAN\n");
+       mac->ops.clear_vfta(hw);
 
        /* Setup the receive address */
-       igb_init_rx_addrs(hw, rar_count);
+       e1000_init_rx_addrs_82575(hw, rar_count);
        /* Zero out the Multicast HASH table */
-       hw_dbg(hw, "Zeroing the MTA\n");
+       DEBUGOUT("Zeroing the MTA\n");
        for (i = 0; i < mac->mta_reg_count; i++)
-               array_wr32(E1000_MTA, i, 0);
+               E1000_WRITE_REG_ARRAY(hw, E1000_MTA, i, 0);
 
        /* Setup link and flow control */
-       ret_val = igb_setup_link(hw);
+       ret_val = mac->ops.setup_link(hw);
 
        /*
         * Clear all of the statistics registers (clear on read).  It is
@@ -876,7 +1152,7 @@ static s32 igb_init_hw_82575(struct e1000_hw *hw)
         * because the symbol error count will increment wildly if there
         * is no link.
         */
-       igb_clear_hw_cntrs_82575(hw);
+       e1000_clear_hw_cntrs_82575(hw);
 
        return ret_val;
 }
@@ -889,28 +1165,30 @@ static s32 igb_init_hw_82575(struct e1000_hw *hw)
  *  for link, once link is established calls to configure collision distance
  *  and flow control are called.
  **/
-static s32 igb_setup_copper_link_82575(struct e1000_hw *hw)
+static s32 e1000_setup_copper_link_82575(struct e1000_hw *hw)
 {
        u32 ctrl, led_ctrl;
        s32  ret_val;
        bool link;
 
-       ctrl = rd32(E1000_CTRL);
+       DEBUGFUNC("e1000_setup_copper_link_82575");
+
+       ctrl = E1000_READ_REG(hw, E1000_CTRL);
        ctrl |= E1000_CTRL_SLU;
        ctrl &= ~(E1000_CTRL_FRCSPD | E1000_CTRL_FRCDPX);
-       wr32(E1000_CTRL, ctrl);
+       E1000_WRITE_REG(hw, E1000_CTRL, ctrl);
 
        switch (hw->phy.type) {
        case e1000_phy_m88:
-               ret_val = igb_copper_link_setup_m88(hw);
+               ret_val = e1000_copper_link_setup_m88(hw);
                break;
        case e1000_phy_igp_3:
-               ret_val = igb_copper_link_setup_igp(hw);
+               ret_val = e1000_copper_link_setup_igp(hw);
                /* Setup activity LED */
-               led_ctrl = rd32(E1000_LEDCTL);
+               led_ctrl = E1000_READ_REG(hw, E1000_LEDCTL);
                led_ctrl &= IGP_ACTIVITY_LED_MASK;
                led_ctrl |= (IGP_ACTIVITY_LED_ENABLE | IGP_LED3_MODE);
-               wr32(E1000_LEDCTL, led_ctrl);
+               E1000_WRITE_REG(hw, E1000_LEDCTL, led_ctrl);
                break;
        default:
                ret_val = -E1000_ERR_PHY;
@@ -925,7 +1203,7 @@ static s32 igb_setup_copper_link_82575(struct e1000_hw *hw)
                 * Setup autoneg and flow control advertisement
                 * and perform autonegotiation.
                 */
-               ret_val = igb_copper_link_autoneg(hw);
+               ret_val = e1000_copper_link_autoneg(hw);
                if (ret_val)
                        goto out;
        } else {
@@ -933,15 +1211,15 @@ static s32 igb_setup_copper_link_82575(struct e1000_hw *hw)
                 * PHY will be set to 10H, 10F, 100H or 100F
                 * depending on user settings.
                 */
-               hw_dbg(hw, "Forcing Speed and Duplex\n");
-               ret_val = igb_phy_force_speed_duplex(hw);
+               DEBUGOUT("Forcing Speed and Duplex\n");
+               ret_val = hw->phy.ops.force_speed_duplex(hw);
                if (ret_val) {
-                       hw_dbg(hw, "Error Forcing Speed and Duplex\n");
+                       DEBUGOUT("Error Forcing Speed and Duplex\n");
                        goto out;
                }
        }
 
-       ret_val = igb_configure_pcs_link_82575(hw);
+       ret_val = e1000_configure_pcs_link_82575(hw);
        if (ret_val)
                goto out;
 
@@ -949,20 +1227,20 @@ static s32 igb_setup_copper_link_82575(struct e1000_hw *hw)
         * Check link status. Wait up to 100 microseconds for link to become
         * valid.
         */
-       ret_val = igb_phy_has_link(hw,
-                                            COPPER_LINK_UP_LIMIT,
-                                            10,
-                                            &link);
+       ret_val = e1000_phy_has_link_generic(hw,
+                                            COPPER_LINK_UP_LIMIT,
+                                            10,
+                                            &link);
        if (ret_val)
                goto out;
 
        if (link) {
-               hw_dbg(hw, "Valid link established!!!\n");
+               DEBUGOUT("Valid link established!!!\n");
                /* Config the MAC and PHY after link is up */
-               igb_config_collision_dist(hw);
-               ret_val = igb_config_fc_after_link_up(hw);
+               e1000_config_collision_dist_generic(hw);
+               ret_val = e1000_config_fc_after_link_up_generic(hw);
        } else {
-               hw_dbg(hw, "Unable to establish link!!!\n");
+               DEBUGOUT("Unable to establish link!!!\n");
        }
 
 out:
@@ -975,31 +1253,40 @@ out:
  *
  *  Configures speed and duplex for fiber and serdes links.
  **/
-static s32 igb_setup_fiber_serdes_link_82575(struct e1000_hw *hw)
+static s32 e1000_setup_fiber_serdes_link_82575(struct e1000_hw *hw)
 {
        u32 reg;
 
+       DEBUGFUNC("e1000_setup_fiber_serdes_link_82575");
+
        /*
         * On the 82575, SerDes loopback mode persists until it is
         * explicitly turned off or a power cycle is performed.  A read to
         * the register does not indicate its status.  Therefore, we ensure
         * loopback mode is disabled during initialization.
         */
-       wr32(E1000_SCTL, E1000_SCTL_DISABLE_SERDES_LOOPBACK);
+       E1000_WRITE_REG(hw, E1000_SCTL, E1000_SCTL_DISABLE_SERDES_LOOPBACK);
 
        /* Force link up, set 1gb, set both sw defined pins */
-       reg = rd32(E1000_CTRL);
+       reg = E1000_READ_REG(hw, E1000_CTRL);
        reg |= E1000_CTRL_SLU |
               E1000_CTRL_SPD_1000 |
               E1000_CTRL_FRCSPD |
               E1000_CTRL_SWDPIN0 |
               E1000_CTRL_SWDPIN1;
-       wr32(E1000_CTRL, reg);
+       E1000_WRITE_REG(hw, E1000_CTRL, reg);
+
+       /* Power on phy for 82576 fiber adapters */
+       if (hw->mac.type == e1000_82576) {
+               reg = E1000_READ_REG(hw, E1000_CTRL_EXT);
+               reg &= ~E1000_CTRL_EXT_SDP7_DATA;
+               E1000_WRITE_REG(hw, E1000_CTRL_EXT, reg);
+       }
 
        /* Set switch control to serdes energy detect */
-       reg = rd32(E1000_CONNSW);
+       reg = E1000_READ_REG(hw, E1000_CONNSW);
        reg |= E1000_CONNSW_ENRGSRC;
-       wr32(E1000_CONNSW, reg);
+       E1000_WRITE_REG(hw, E1000_CONNSW, reg);
 
        /*
         * New SerDes mode allows for forcing speed or autonegotiating speed
@@ -1007,7 +1294,7 @@ static s32 igb_setup_fiber_serdes_link_82575(struct e1000_hw *hw)
         * mode that will be compatible with older link partners and switches.
         * However, both are supported by the hardware and some drivers/tools.
         */
-       reg = rd32(E1000_PCS_LCTL);
+       reg = E1000_READ_REG(hw, E1000_PCS_LCTL);
 
        reg &= ~(E1000_PCS_LCTL_AN_ENABLE | E1000_PCS_LCTL_FLV_LINK_UP |
                E1000_PCS_LCTL_FSD | E1000_PCS_LCTL_FORCE_LINK);
@@ -1018,7 +1305,7 @@ static s32 igb_setup_fiber_serdes_link_82575(struct e1000_hw *hw)
                       E1000_PCS_LCTL_FDV_FULL |      /* SerDes Full duplex */
                       E1000_PCS_LCTL_AN_ENABLE |     /* Enable Autoneg */
                       E1000_PCS_LCTL_AN_RESTART;     /* Restart autoneg */
-               hw_dbg(hw, "Configuring Autoneg; PCS_LCTL = 0x%08X\n", reg);
+               DEBUGOUT1("Configuring Autoneg; PCS_LCTL = 0x%08X\n", reg);
        } else {
                /* Set PCS register for forced speed */
                reg |= E1000_PCS_LCTL_FLV_LINK_UP |   /* Force link up */
@@ -1026,11 +1313,53 @@ static s32 igb_setup_fiber_serdes_link_82575(struct e1000_hw *hw)
                       E1000_PCS_LCTL_FDV_FULL |      /* SerDes Full duplex */
                       E1000_PCS_LCTL_FSD |           /* Force Speed */
                       E1000_PCS_LCTL_FORCE_LINK;     /* Force Link */
-               hw_dbg(hw, "Configuring Forced Link; PCS_LCTL = 0x%08X\n", reg);
+               DEBUGOUT1("Configuring Forced Link; PCS_LCTL = 0x%08X\n", reg);
+       }
+
+       if (hw->mac.type == e1000_82576) {
+               reg |= E1000_PCS_LCTL_FORCE_FCTRL;
+               e1000_force_mac_fc_generic(hw);
        }
-       wr32(E1000_PCS_LCTL, reg);
 
-       return 0;
+       E1000_WRITE_REG(hw, E1000_PCS_LCTL, reg);
+
+       return E1000_SUCCESS;
+}
+
+/**
+ *  e1000_valid_led_default_82575 - Verify a valid default LED config
+ *  @hw: pointer to the HW structure
+ *  @data: pointer to the NVM (EEPROM)
+ *
+ *  Read the EEPROM for the current default LED configuration.  If the
+ *  LED configuration is not valid, set to a valid LED configuration.
+ **/
+static s32 e1000_valid_led_default_82575(struct e1000_hw *hw, u16 *data)
+{
+       s32 ret_val;
+
+       DEBUGFUNC("e1000_valid_led_default_82575");
+
+       ret_val = hw->nvm.ops.read(hw, NVM_ID_LED_SETTINGS, 1, data);
+       if (ret_val) {
+               DEBUGOUT("NVM Read Error\n");
+               goto out;
+       }
+
+       if (*data == ID_LED_RESERVED_0000 || *data == ID_LED_RESERVED_FFFF) {
+               switch(hw->phy.media_type) {
+               case e1000_media_type_fiber:
+               case e1000_media_type_internal_serdes:
+                       *data = ID_LED_DEFAULT_82575_SERDES;
+                       break;
+               case e1000_media_type_copper:
+               default:
+                       *data = ID_LED_DEFAULT;
+                       break;
+               }
+       }
+out:
+       return ret_val;
 }
 
 /**
@@ -1042,17 +1371,19 @@ static s32 igb_setup_fiber_serdes_link_82575(struct e1000_hw *hw)
  *  independent interface (sgmii) is being used.  Configures the link
  *  for auto-negotiation or forces speed/duplex.
  **/
-static s32 igb_configure_pcs_link_82575(struct e1000_hw *hw)
+static s32 e1000_configure_pcs_link_82575(struct e1000_hw *hw)
 {
        struct e1000_mac_info *mac = &hw->mac;
        u32 reg = 0;
 
+       DEBUGFUNC("e1000_configure_pcs_link_82575");
+
        if (hw->phy.media_type != e1000_media_type_copper ||
-           !(igb_sgmii_active_82575(hw)))
+           !(e1000_sgmii_active_82575(hw)))
                goto out;
 
        /* For SGMII, we need to issue a PCS autoneg restart */
-       reg = rd32(E1000_PCS_LCTL);
+       reg = E1000_READ_REG(hw, E1000_PCS_LCTL);
 
        /* AN time out should be disabled for SGMII mode */
        reg &= ~(E1000_PCS_LCTL_AN_TIMEOUT);
@@ -1067,13 +1398,13 @@ static s32 igb_configure_pcs_link_82575(struct e1000_hw *hw)
                 */
                reg |= E1000_PCS_LCTL_AN_RESTART | E1000_PCS_LCTL_AN_ENABLE;
        } else {
-               /* Set PCS regiseter for forced speed */
+               /* Set PCS register for forced speed */
 
                /* Turn off bits for full duplex, speed, and autoneg */
                reg &= ~(E1000_PCS_LCTL_FSV_1000 |
-                        E1000_PCS_LCTL_FSV_100 |
-                        E1000_PCS_LCTL_FDV_FULL |
-                        E1000_PCS_LCTL_AN_ENABLE);
+                        E1000_PCS_LCTL_FSV_100 |
+                        E1000_PCS_LCTL_FDV_FULL |
+                        E1000_PCS_LCTL_AN_ENABLE);
 
                /* Check for duplex first */
                if (mac->forced_speed_duplex & E1000_ALL_FULL_DUPLEX)
@@ -1088,14 +1419,13 @@ static s32 igb_configure_pcs_link_82575(struct e1000_hw *hw)
                       E1000_PCS_LCTL_FORCE_LINK |
                       E1000_PCS_LCTL_FLV_LINK_UP;
 
-               hw_dbg(hw,
-                      "Wrote 0x%08X to PCS_LCTL to configure forced link\n",
-                      reg);
+               DEBUGOUT1("Wrote 0x%08X to PCS_LCTL to configure forced link\n",
+                         reg);
        }
-       wr32(E1000_PCS_LCTL, reg);
+       E1000_WRITE_REG(hw, E1000_PCS_LCTL, reg);
 
 out:
-       return 0;
+       return E1000_SUCCESS;
 }
 
 /**
@@ -1106,22 +1436,16 @@ out:
  *  which can be enabled for use in the embedded applications.  Simply
  *  return the current state of the sgmii interface.
  **/
-static bool igb_sgmii_active_82575(struct e1000_hw *hw)
+static bool e1000_sgmii_active_82575(struct e1000_hw *hw)
 {
-       struct e1000_dev_spec_82575 *dev_spec;
-       bool ret_val;
+       struct e1000_dev_spec_82575 *dev_spec = &hw->dev_spec._82575;
 
-       if (hw->mac.type != e1000_82575) {
-               ret_val = false;
-               goto out;
-       }
-
-       dev_spec = (struct e1000_dev_spec_82575 *)hw->dev_spec;
+       DEBUGFUNC("e1000_sgmii_active_82575");
 
-       ret_val = dev_spec->sgmii_active;
+       if (hw->mac.type != e1000_82575 && hw->mac.type != e1000_82576)
+               return false;
 
-out:
-       return ret_val;
+       return dev_spec->sgmii_active;
 }
 
 /**
@@ -1131,139 +1455,209 @@ out:
  *  Inits recommended HW defaults after a reset when there is no EEPROM
  *  detected. This is only for the 82575.
  **/
-static s32 igb_reset_init_script_82575(struct e1000_hw *hw)
+static s32 e1000_reset_init_script_82575(struct e1000_hw* hw)
 {
+       DEBUGFUNC("e1000_reset_init_script_82575");
+
        if (hw->mac.type == e1000_82575) {
-               hw_dbg(hw, "Running reset init script for 82575\n");
+               DEBUGOUT("Running reset init script for 82575\n");
                /* SerDes configuration via SERDESCTRL */
-               igb_write_8bit_ctrl_reg(hw, E1000_SCTL, 0x00, 0x0C);
-               igb_write_8bit_ctrl_reg(hw, E1000_SCTL, 0x01, 0x78);
-               igb_write_8bit_ctrl_reg(hw, E1000_SCTL, 0x1B, 0x23);
-               igb_write_8bit_ctrl_reg(hw, E1000_SCTL, 0x23, 0x15);
+               e1000_write_8bit_ctrl_reg_generic(hw, E1000_SCTL, 0x00, 0x0C);
+               e1000_write_8bit_ctrl_reg_generic(hw, E1000_SCTL, 0x01, 0x78);
+               e1000_write_8bit_ctrl_reg_generic(hw, E1000_SCTL, 0x1B, 0x23);
+               e1000_write_8bit_ctrl_reg_generic(hw, E1000_SCTL, 0x23, 0x15);
 
                /* CCM configuration via CCMCTL register */
-               igb_write_8bit_ctrl_reg(hw, E1000_CCMCTL, 0x14, 0x00);
-               igb_write_8bit_ctrl_reg(hw, E1000_CCMCTL, 0x10, 0x00);
+               e1000_write_8bit_ctrl_reg_generic(hw, E1000_CCMCTL, 0x14, 0x00);
+               e1000_write_8bit_ctrl_reg_generic(hw, E1000_CCMCTL, 0x10, 0x00);
 
                /* PCIe lanes configuration */
-               igb_write_8bit_ctrl_reg(hw, E1000_GIOCTL, 0x00, 0xEC);
-               igb_write_8bit_ctrl_reg(hw, E1000_GIOCTL, 0x61, 0xDF);
-               igb_write_8bit_ctrl_reg(hw, E1000_GIOCTL, 0x34, 0x05);
-               igb_write_8bit_ctrl_reg(hw, E1000_GIOCTL, 0x2F, 0x81);
+               e1000_write_8bit_ctrl_reg_generic(hw, E1000_GIOCTL, 0x00, 0xEC);
+               e1000_write_8bit_ctrl_reg_generic(hw, E1000_GIOCTL, 0x61, 0xDF);
+               e1000_write_8bit_ctrl_reg_generic(hw, E1000_GIOCTL, 0x34, 0x05);
+               e1000_write_8bit_ctrl_reg_generic(hw, E1000_GIOCTL, 0x2F, 0x81);
 
                /* PCIe PLL Configuration */
-               igb_write_8bit_ctrl_reg(hw, E1000_SCCTL, 0x02, 0x47);
-               igb_write_8bit_ctrl_reg(hw, E1000_SCCTL, 0x14, 0x00);
-               igb_write_8bit_ctrl_reg(hw, E1000_SCCTL, 0x10, 0x00);
+               e1000_write_8bit_ctrl_reg_generic(hw, E1000_SCCTL, 0x02, 0x47);
+               e1000_write_8bit_ctrl_reg_generic(hw, E1000_SCCTL, 0x14, 0x00);
+               e1000_write_8bit_ctrl_reg_generic(hw, E1000_SCCTL, 0x10, 0x00);
        }
 
-       return 0;
+       return E1000_SUCCESS;
 }
 
 /**
  *  e1000_read_mac_addr_82575 - Read device MAC address
  *  @hw: pointer to the HW structure
  **/
-static s32 igb_read_mac_addr_82575(struct e1000_hw *hw)
+static s32 e1000_read_mac_addr_82575(struct e1000_hw *hw)
 {
-       s32 ret_val = 0;
+       s32 ret_val = E1000_SUCCESS;
 
-       if (igb_check_alt_mac_addr(hw))
-               ret_val = igb_read_mac_addr(hw);
+       DEBUGFUNC("e1000_read_mac_addr_82575");
+       if (e1000_check_alt_mac_addr_generic(hw))
+               ret_val = e1000_read_mac_addr_generic(hw);
 
        return ret_val;
 }
 
+/**
+ * e1000_power_down_phy_copper_82575 - Remove link during PHY power down
+ * @hw: pointer to the HW structure
+ *
+ * In the case of a PHY power down to save power, or to turn off link during a
+ * driver unload, or wake on lan is not enabled, remove the link.
+ **/
+static void e1000_power_down_phy_copper_82575(struct e1000_hw *hw)
+{
+       struct e1000_phy_info *phy = &hw->phy;
+       struct e1000_mac_info *mac = &hw->mac;
+
+       if (!(phy->ops.check_reset_block))
+               return;
+
+       /* If the management interface is not enabled, then power down */
+       if (!(mac->ops.check_mng_mode(hw) || phy->ops.check_reset_block(hw)))
+               e1000_power_down_phy_copper(hw);
+
+       return;
+}
+
 /**
  *  e1000_clear_hw_cntrs_82575 - Clear device specific hardware counters
  *  @hw: pointer to the HW structure
  *
  *  Clears the hardware counters by reading the counter registers.
  **/
-static void igb_clear_hw_cntrs_82575(struct e1000_hw *hw)
+static void e1000_clear_hw_cntrs_82575(struct e1000_hw *hw)
 {
-       u32 temp;
-
-       igb_clear_hw_cntrs_base(hw);
-
-       temp = rd32(E1000_PRC64);
-       temp = rd32(E1000_PRC127);
-       temp = rd32(E1000_PRC255);
-       temp = rd32(E1000_PRC511);
-       temp = rd32(E1000_PRC1023);
-       temp = rd32(E1000_PRC1522);
-       temp = rd32(E1000_PTC64);
-       temp = rd32(E1000_PTC127);
-       temp = rd32(E1000_PTC255);
-       temp = rd32(E1000_PTC511);
-       temp = rd32(E1000_PTC1023);
-       temp = rd32(E1000_PTC1522);
-
-       temp = rd32(E1000_ALGNERRC);
-       temp = rd32(E1000_RXERRC);
-       temp = rd32(E1000_TNCRS);
-       temp = rd32(E1000_CEXTERR);
-       temp = rd32(E1000_TSCTC);
-       temp = rd32(E1000_TSCTFC);
-
-       temp = rd32(E1000_MGTPRC);
-       temp = rd32(E1000_MGTPDC);
-       temp = rd32(E1000_MGTPTC);
-
-       temp = rd32(E1000_IAC);
-       temp = rd32(E1000_ICRXOC);
-
-       temp = rd32(E1000_ICRXPTC);
-       temp = rd32(E1000_ICRXATC);
-       temp = rd32(E1000_ICTXPTC);
-       temp = rd32(E1000_ICTXATC);
-       temp = rd32(E1000_ICTXQEC);
-       temp = rd32(E1000_ICTXQMTC);
-       temp = rd32(E1000_ICRXDMTC);
-
-       temp = rd32(E1000_CBTMPC);
-       temp = rd32(E1000_HTDPMC);
-       temp = rd32(E1000_CBRMPC);
-       temp = rd32(E1000_RPTHC);
-       temp = rd32(E1000_HGPTC);
-       temp = rd32(E1000_HTCBDPC);
-       temp = rd32(E1000_HGORCL);
-       temp = rd32(E1000_HGORCH);
-       temp = rd32(E1000_HGOTCL);
-       temp = rd32(E1000_HGOTCH);
-       temp = rd32(E1000_LENERRS);
+       volatile u32 temp;
+
+       DEBUGFUNC("e1000_clear_hw_cntrs_82575");
+
+       e1000_clear_hw_cntrs_base_generic(hw);
+
+       temp = E1000_READ_REG(hw, E1000_PRC64);
+       temp = E1000_READ_REG(hw, E1000_PRC127);
+       temp = E1000_READ_REG(hw, E1000_PRC255);
+       temp = E1000_READ_REG(hw, E1000_PRC511);
+       temp = E1000_READ_REG(hw, E1000_PRC1023);
+       temp = E1000_READ_REG(hw, E1000_PRC1522);
+       temp = E1000_READ_REG(hw, E1000_PTC64);
+       temp = E1000_READ_REG(hw, E1000_PTC127);
+       temp = E1000_READ_REG(hw, E1000_PTC255);
+       temp = E1000_READ_REG(hw, E1000_PTC511);
+       temp = E1000_READ_REG(hw, E1000_PTC1023);
+       temp = E1000_READ_REG(hw, E1000_PTC1522);
+
+       temp = E1000_READ_REG(hw, E1000_ALGNERRC);
+       temp = E1000_READ_REG(hw, E1000_RXERRC);
+       temp = E1000_READ_REG(hw, E1000_TNCRS);
+       temp = E1000_READ_REG(hw, E1000_CEXTERR);
+       temp = E1000_READ_REG(hw, E1000_TSCTC);
+       temp = E1000_READ_REG(hw, E1000_TSCTFC);
+
+       temp = E1000_READ_REG(hw, E1000_MGTPRC);
+       temp = E1000_READ_REG(hw, E1000_MGTPDC);
+       temp = E1000_READ_REG(hw, E1000_MGTPTC);
+
+       temp = E1000_READ_REG(hw, E1000_IAC);
+       temp = E1000_READ_REG(hw, E1000_ICRXOC);
+
+       temp = E1000_READ_REG(hw, E1000_ICRXPTC);
+       temp = E1000_READ_REG(hw, E1000_ICRXATC);
+       temp = E1000_READ_REG(hw, E1000_ICTXPTC);
+       temp = E1000_READ_REG(hw, E1000_ICTXATC);
+       temp = E1000_READ_REG(hw, E1000_ICTXQEC);
+       temp = E1000_READ_REG(hw, E1000_ICTXQMTC);
+       temp = E1000_READ_REG(hw, E1000_ICRXDMTC);
+
+       temp = E1000_READ_REG(hw, E1000_CBTMPC);
+       temp = E1000_READ_REG(hw, E1000_HTDPMC);
+       temp = E1000_READ_REG(hw, E1000_CBRMPC);
+       temp = E1000_READ_REG(hw, E1000_RPTHC);
+       temp = E1000_READ_REG(hw, E1000_HGPTC);
+       temp = E1000_READ_REG(hw, E1000_HTCBDPC);
+       temp = E1000_READ_REG(hw, E1000_HGORCL);
+       temp = E1000_READ_REG(hw, E1000_HGORCH);
+       temp = E1000_READ_REG(hw, E1000_HGOTCL);
+       temp = E1000_READ_REG(hw, E1000_HGOTCH);
+       temp = E1000_READ_REG(hw, E1000_LENERRS);
 
        /* This register should not be read in copper configurations */
        if (hw->phy.media_type == e1000_media_type_internal_serdes)
-               temp = rd32(E1000_SCVPC);
+               temp = E1000_READ_REG(hw, E1000_SCVPC);
 }
+/**
+ *  e1000_rx_fifo_flush_82575 - Clean rx fifo after RX enable
+ *  @hw: pointer to the HW structure
+ *
+ *  After rx enable if managability is enabled then there is likely some
+ *  bad data at the start of the fifo and possibly in the DMA fifo.  This
+ *  function clears the fifos and flushes any packets that came in as rx was
+ *  being enabled.
+ **/
+void e1000_rx_fifo_flush_82575(struct e1000_hw *hw)
+{
+       u32 rctl, rlpml, rxdctl[4], rfctl, temp_rctl, rx_enabled;
+       int i, ms_wait;
+
+       DEBUGFUNC("e1000_rx_fifo_workaround_82575");
+       if (hw->mac.type != e1000_82575 ||
+           !(E1000_READ_REG(hw, E1000_MANC) & E1000_MANC_RCV_TCO_EN))
+               return;
+
+       /* Disable all RX queues */
+       for (i = 0; i < 4; i++) {
+               rxdctl[i] = E1000_READ_REG(hw, E1000_RXDCTL(i));
+               E1000_WRITE_REG(hw, E1000_RXDCTL(i),
+                               rxdctl[i] & ~E1000_RXDCTL_QUEUE_ENABLE);
+       }
+       /* Poll all queues to verify they have shut down */
+       for (ms_wait = 0; ms_wait < 10; ms_wait++) {
+               msec_delay(1);
+               rx_enabled = 0;
+               for (i = 0; i < 4; i++)
+                       rx_enabled |= E1000_READ_REG(hw, E1000_RXDCTL(i));
+               if (!(rx_enabled & E1000_RXDCTL_QUEUE_ENABLE))
+                       break;
+       }
+
+       if (ms_wait == 10)
+               DEBUGOUT("Queue disable timed out after 10ms\n");
+
+       /* Clear RLPML, RCTL.SBP, RFCTL.LEF, and set RCTL.LPE so that all
+        * incoming packets are rejected.  Set enable and wait 2ms so that
+        * any packet that was coming in as RCTL.EN was set is flushed
+        */
+       rfctl = E1000_READ_REG(hw, E1000_RFCTL);
+       E1000_WRITE_REG(hw, E1000_RFCTL, rfctl & ~E1000_RFCTL_LEF);
 
-static struct e1000_mac_operations e1000_mac_ops_82575 = {
-       .reset_hw             = igb_reset_hw_82575,
-       .init_hw              = igb_init_hw_82575,
-       .check_for_link       = igb_check_for_link_82575,
-       .rar_set              = igb_rar_set_82575,
-       .read_mac_addr        = igb_read_mac_addr_82575,
-       .get_speed_and_duplex = igb_get_speed_and_duplex_copper,
-};
-
-static struct e1000_phy_operations e1000_phy_ops_82575 = {
-       .acquire_phy          = igb_acquire_phy_82575,
-       .get_cfg_done         = igb_get_cfg_done_82575,
-       .release_phy          = igb_release_phy_82575,
-};
-
-static struct e1000_nvm_operations e1000_nvm_ops_82575 = {
-       .acquire_nvm          = igb_acquire_nvm_82575,
-       .read_nvm             = igb_read_nvm_eerd,
-       .release_nvm          = igb_release_nvm_82575,
-       .write_nvm            = igb_write_nvm_spi,
-};
-
-const struct e1000_info e1000_82575_info = {
-       .get_invariants = igb_get_invariants_82575,
-       .mac_ops = &e1000_mac_ops_82575,
-       .phy_ops = &e1000_phy_ops_82575,
-       .nvm_ops = &e1000_nvm_ops_82575,
-};
+       rlpml = E1000_READ_REG(hw, E1000_RLPML);
+       E1000_WRITE_REG(hw, E1000_RLPML, 0);
 
+       rctl = E1000_READ_REG(hw, E1000_RCTL);
+       temp_rctl = rctl & ~(E1000_RCTL_EN | E1000_RCTL_SBP);
+       temp_rctl |= E1000_RCTL_LPE;
+
+       E1000_WRITE_REG(hw, E1000_RCTL, temp_rctl);
+       E1000_WRITE_REG(hw, E1000_RCTL, temp_rctl | E1000_RCTL_EN);
+       E1000_WRITE_FLUSH(hw);
+       msec_delay(2);
+
+       /* Enable RX queues that were previously enabled and restore our
+        * previous state
+        */
+       for (i = 0; i < 4; i++)
+               E1000_WRITE_REG(hw, E1000_RXDCTL(i), rxdctl[i]);
+       E1000_WRITE_REG(hw, E1000_RCTL, rctl);
+       E1000_WRITE_FLUSH(hw);
+
+       E1000_WRITE_REG(hw, E1000_RLPML, rlpml);
+       E1000_WRITE_REG(hw, E1000_RFCTL, rfctl);
+
+       /* Flush receive errors generated by workaround */
+       E1000_READ_REG(hw, E1000_ROC);
+       E1000_READ_REG(hw, E1000_RNBC);
+       E1000_READ_REG(hw, E1000_MPC);
+}
index 6604d96bd567618fffff1d01098ad3660e0cf543..ce3236f143bac874ba3ee152246b00eff482f4e0 100644 (file)
@@ -1,7 +1,7 @@
 /*******************************************************************************
 
   Intel(R) Gigabit Ethernet Linux driver
-  Copyright(c) 2007 Intel Corporation.
+  Copyright(c) 2007-2008 Intel Corporation.
 
   This program is free software; you can redistribute it and/or modify it
   under the terms and conditions of the GNU General Public License,
 #ifndef _E1000_82575_H_
 #define _E1000_82575_H_
 
+#define ID_LED_DEFAULT_82575_SERDES ((ID_LED_DEF1_DEF2 << 12) | \
+                                     (ID_LED_DEF1_DEF2 <<  8) | \
+                                     (ID_LED_DEF1_DEF2 <<  4) | \
+                                     (ID_LED_OFF1_ON2))
+/*
+ * Receive Address Register Count
+ * Number of high/low register pairs in the RAR.  The RAR (Receive Address
+ * Registers) holds the directed and multicast addresses that we monitor.
+ * These entries are also used for MAC-based filtering.
+ */
+/*
+ * For 82576, there are an additional set of RARs that begin at an offset
+ * separate from the first set of RARs.
+ */
 #define E1000_RAR_ENTRIES_82575   16
+#define E1000_RAR_ENTRIES_82576   24
+
+struct e1000_adv_data_desc {
+       u64 buffer_addr;    /* Address of the descriptor's data buffer */
+       union {
+               u32 data;
+               struct {
+                       u32 datalen :16; /* Data buffer length */
+                       u32 rsvd    :4;
+                       u32 dtyp    :4;  /* Descriptor type */
+                       u32 dcmd    :8;  /* Descriptor command */
+               } config;
+       } lower;
+       union {
+               u32 data;
+               struct {
+                       u32 status  :4;  /* Descriptor status */
+                       u32 idx     :4;
+                       u32 popts   :6;  /* Packet Options */
+                       u32 paylen  :18; /* Payload length */
+               } options;
+       } upper;
+};
+
+#define E1000_TXD_DTYP_ADV_C    0x2  /* Advanced Context Descriptor */
+#define E1000_TXD_DTYP_ADV_D    0x3  /* Advanced Data Descriptor */
+#define E1000_ADV_TXD_CMD_DEXT  0x20 /* Descriptor extension (0 = legacy) */
+#define E1000_ADV_TUCMD_IPV4    0x2  /* IP Packet Type: 1=IPv4 */
+#define E1000_ADV_TUCMD_IPV6    0x0  /* IP Packet Type: 0=IPv6 */
+#define E1000_ADV_TUCMD_L4T_UDP 0x0  /* L4 Packet TYPE of UDP */
+#define E1000_ADV_TUCMD_L4T_TCP 0x4  /* L4 Packet TYPE of TCP */
+#define E1000_ADV_TUCMD_MKRREQ  0x10 /* Indicates markers are required */
+#define E1000_ADV_DCMD_EOP      0x1  /* End of Packet */
+#define E1000_ADV_DCMD_IFCS     0x2  /* Insert FCS (Ethernet CRC) */
+#define E1000_ADV_DCMD_RS       0x8  /* Report Status */
+#define E1000_ADV_DCMD_VLE      0x40 /* Add VLAN tag */
+#define E1000_ADV_DCMD_TSE      0x80 /* TCP Seg enable */
+/* Extended Device Control */
+#define E1000_CTRL_EXT_NSICR    0x00000001 /* Disable Intr Clear all on read */
+
+struct e1000_adv_context_desc {
+       union {
+               u32 ip_config;
+               struct {
+                       u32 iplen    :9;
+                       u32 maclen   :7;
+                       u32 vlan_tag :16;
+               } fields;
+       } ip_setup;
+       u32 seq_num;
+       union {
+               u64 l4_config;
+               struct {
+                       u32 mkrloc :9;
+                       u32 tucmd  :11;
+                       u32 dtyp   :4;
+                       u32 adv    :8;
+                       u32 rsvd   :4;
+                       u32 idx    :4;
+                       u32 l4len  :8;
+                       u32 mss    :16;
+               } fields;
+       } l4_setup;
+};
 
 /* SRRCTL bit definitions */
 #define E1000_SRRCTL_BSIZEPKT_SHIFT                     10 /* Shift _right_ */
+#define E1000_SRRCTL_BSIZEHDRSIZE_MASK                  0x00000F00
 #define E1000_SRRCTL_BSIZEHDRSIZE_SHIFT                 2  /* Shift _left_ */
+#define E1000_SRRCTL_DESCTYPE_LEGACY                    0x00000000
 #define E1000_SRRCTL_DESCTYPE_ADV_ONEBUF                0x02000000
+#define E1000_SRRCTL_DESCTYPE_HDR_SPLIT                 0x04000000
 #define E1000_SRRCTL_DESCTYPE_HDR_SPLIT_ALWAYS          0x0A000000
+#define E1000_SRRCTL_DESCTYPE_HDR_REPLICATION           0x06000000
+#define E1000_SRRCTL_DESCTYPE_HDR_REPLICATION_LARGE_PKT 0x08000000
+#define E1000_SRRCTL_DESCTYPE_MASK                      0x0E000000
+
+#define E1000_SRRCTL_BSIZEPKT_MASK      0x0000007F
+#define E1000_SRRCTL_BSIZEHDR_MASK      0x00003F00
+
+#define E1000_TX_HEAD_WB_ENABLE   0x1
+#define E1000_TX_SEQNUM_WB_ENABLE 0x2
 
 #define E1000_MRQC_ENABLE_RSS_4Q            0x00000002
+#define E1000_MRQC_ENABLE_VMDQ              0x00000003
 #define E1000_MRQC_RSS_FIELD_IPV4_UDP       0x00400000
 #define E1000_MRQC_RSS_FIELD_IPV6_UDP       0x00800000
 #define E1000_MRQC_RSS_FIELD_IPV6_UDP_EX    0x01000000
 
+#define E1000_VMRCTL_MIRROR_PORT_SHIFT      8
+#define E1000_VMRCTL_MIRROR_DSTPORT_MASK    (7 << E1000_VMRCTL_MIRROR_PORT_SHIFT)
+#define E1000_VMRCTL_POOL_MIRROR_ENABLE     (1 << 0)
+#define E1000_VMRCTL_UPLINK_MIRROR_ENABLE   (1 << 1)
+#define E1000_VMRCTL_DOWNLINK_MIRROR_ENABLE (1 << 2)
+
 #define E1000_EICR_TX_QUEUE ( \
     E1000_EICR_TX_QUEUE0 |    \
     E1000_EICR_TX_QUEUE1 |    \
 #define E1000_EIMS_RX_QUEUE E1000_EICR_RX_QUEUE
 #define E1000_EIMS_TX_QUEUE E1000_EICR_TX_QUEUE
 
-/* Immediate Interrupt RX (A.K.A. Low Latency Interrupt) */
+#define EIMS_ENABLE_MASK ( \
+    E1000_EIMS_RX_QUEUE  | \
+    E1000_EIMS_TX_QUEUE  | \
+    E1000_EIMS_TCP_TIMER | \
+    E1000_EIMS_OTHER)
+
+/* Immediate Interrupt Rx (A.K.A. Low Latency Interrupt) */
+#define E1000_IMIR_PORT_IM_EN     0x00010000  /* TCP port enable */
+#define E1000_IMIR_PORT_BP        0x00020000  /* TCP port check bypass */
+#define E1000_IMIREXT_SIZE_BP     0x00001000  /* Packet size bypass */
+#define E1000_IMIREXT_CTRL_URG    0x00002000  /* Check URG bit in header */
+#define E1000_IMIREXT_CTRL_ACK    0x00004000  /* Check ACK bit in header */
+#define E1000_IMIREXT_CTRL_PSH    0x00008000  /* Check PSH bit in header */
+#define E1000_IMIREXT_CTRL_RST    0x00010000  /* Check RST bit in header */
+#define E1000_IMIREXT_CTRL_SYN    0x00020000  /* Check SYN bit in header */
+#define E1000_IMIREXT_CTRL_FIN    0x00040000  /* Check FIN bit in header */
+#define E1000_IMIREXT_CTRL_BP     0x00080000  /* Bypass check of ctrl bits */
 
 /* Receive Descriptor - Advanced */
 union e1000_adv_rx_desc {
@@ -66,10 +179,13 @@ union e1000_adv_rx_desc {
        } read;
        struct {
                struct {
-                       struct {
-                               u16 pkt_info;   /* RSS type, Packet type */
-                               u16 hdr_info;   /* Split Header,
-                                                * header buffer length */
+                       union {
+                               u32 data;
+                               struct {
+                                       u16 pkt_info; /* RSS type, Packet type */
+                                       u16 hdr_info; /* Split Header,
+                                                      * header buffer length */
+                               } hs_rss;
                        } lo_dword;
                        union {
                                u32 rss;          /* RSS Hash */
@@ -87,12 +203,57 @@ union e1000_adv_rx_desc {
        } wb;  /* writeback */
 };
 
+#define E1000_RXDADV_RSSTYPE_MASK        0x0000F000
+#define E1000_RXDADV_RSSTYPE_SHIFT       12
 #define E1000_RXDADV_HDRBUFLEN_MASK      0x7FE0
 #define E1000_RXDADV_HDRBUFLEN_SHIFT     5
+#define E1000_RXDADV_SPLITHEADER_EN      0x00001000
+#define E1000_RXDADV_SPH                 0x8000
+#define E1000_RXDADV_ERR_HBO             0x00800000
 
 /* RSS Hash results */
+#define E1000_RXDADV_RSSTYPE_NONE        0x00000000
+#define E1000_RXDADV_RSSTYPE_IPV4_TCP    0x00000001
+#define E1000_RXDADV_RSSTYPE_IPV4        0x00000002
+#define E1000_RXDADV_RSSTYPE_IPV6_TCP    0x00000003
+#define E1000_RXDADV_RSSTYPE_IPV6_EX     0x00000004
+#define E1000_RXDADV_RSSTYPE_IPV6        0x00000005
+#define E1000_RXDADV_RSSTYPE_IPV6_TCP_EX 0x00000006
+#define E1000_RXDADV_RSSTYPE_IPV4_UDP    0x00000007
+#define E1000_RXDADV_RSSTYPE_IPV6_UDP    0x00000008
+#define E1000_RXDADV_RSSTYPE_IPV6_UDP_EX 0x00000009
 
 /* RSS Packet Types as indicated in the receive descriptor */
+#define E1000_RXDADV_PKTTYPE_NONE        0x00000000
+#define E1000_RXDADV_PKTTYPE_IPV4        0x00000010 /* IPV4 hdr present */
+#define E1000_RXDADV_PKTTYPE_IPV4_EX     0x00000020 /* IPV4 hdr + extensions */
+#define E1000_RXDADV_PKTTYPE_IPV6        0x00000040 /* IPV6 hdr present */
+#define E1000_RXDADV_PKTTYPE_IPV6_EX     0x00000080 /* IPV6 hdr + extensions */
+#define E1000_RXDADV_PKTTYPE_TCP         0x00000100 /* TCP hdr present */
+#define E1000_RXDADV_PKTTYPE_UDP         0x00000200 /* UDP hdr present */
+#define E1000_RXDADV_PKTTYPE_SCTP        0x00000400 /* SCTP hdr present */
+#define E1000_RXDADV_PKTTYPE_NFS         0x00000800 /* NFS hdr present */
+
+#define E1000_RXDADV_PKTTYPE_IPSEC_ESP   0x00001000 /* IPSec ESP */
+#define E1000_RXDADV_PKTTYPE_IPSEC_AH    0x00002000 /* IPSec AH */
+#define E1000_RXDADV_PKTTYPE_LINKSEC     0x00004000 /* LinkSec Encap */
+#define E1000_RXDADV_PKTTYPE_ETQF        0x00008000 /* PKTTYPE is ETQF index */
+#define E1000_RXDADV_PKTTYPE_ETQF_MASK   0x00000070 /* ETQF has 8 indices */
+#define E1000_RXDADV_PKTTYPE_ETQF_SHIFT  4          /* Right-shift 4 bits */
+
+/* LinkSec results */
+/* Security Processing bit Indication */
+#define E1000_RXDADV_LNKSEC_STATUS_SECP         0x00020000
+#define E1000_RXDADV_LNKSEC_ERROR_BIT_MASK      0x18000000
+#define E1000_RXDADV_LNKSEC_ERROR_NO_SA_MATCH   0x08000000
+#define E1000_RXDADV_LNKSEC_ERROR_REPLAY_ERROR  0x10000000
+#define E1000_RXDADV_LNKSEC_ERROR_BAD_SIG       0x18000000
+
+#define E1000_RXDADV_IPSEC_STATUS_SECP          0x00020000
+#define E1000_RXDADV_IPSEC_ERROR_BIT_MASK       0x18000000
+#define E1000_RXDADV_IPSEC_ERROR_INVALID_PROTOCOL       0x08000000
+#define E1000_RXDADV_IPSEC_ERROR_INVALID_LENGTH         0x10000000
+#define E1000_RXDADV_IPSEC_ERROR_AUTHENTICATION_FAILED  0x18000000
 
 /* Transmit Descriptor - Advanced */
 union e1000_adv_tx_desc {
@@ -111,10 +272,22 @@ union e1000_adv_tx_desc {
 /* Adv Transmit Descriptor Config Masks */
 #define E1000_ADVTXD_DTYP_CTXT    0x00200000 /* Advanced Context Descriptor */
 #define E1000_ADVTXD_DTYP_DATA    0x00300000 /* Advanced Data Descriptor */
+#define E1000_ADVTXD_DCMD_EOP     0x01000000 /* End of Packet */
 #define E1000_ADVTXD_DCMD_IFCS    0x02000000 /* Insert FCS (Ethernet CRC) */
+#define E1000_ADVTXD_DCMD_RS      0x08000000 /* Report Status */
+#define E1000_ADVTXD_DCMD_DDTYP_ISCSI  0x10000000 /* DDP hdr type or iSCSI */
 #define E1000_ADVTXD_DCMD_DEXT    0x20000000 /* Descriptor extension (1=Adv) */
 #define E1000_ADVTXD_DCMD_VLE     0x40000000 /* VLAN pkt enable */
 #define E1000_ADVTXD_DCMD_TSE     0x80000000 /* TCP Seg enable */
+#define E1000_ADVTXD_MAC_LINKSEC  0x00040000 /* Apply LinkSec on packet */
+#define E1000_ADVTXD_MAC_TSTAMP   0x00080000 /* IEEE1588 Timestamp packet */
+#define E1000_ADVTXD_STAT_SN_CRC  0x00000002 /* NXTSEQ/SEED present in WB */
+#define E1000_ADVTXD_IDX_SHIFT    4  /* Adv desc Index shift */
+#define E1000_ADVTXD_POPTS_ISCO_1ST  0x00000000 /* 1st TSO of iSCSI PDU */
+#define E1000_ADVTXD_POPTS_ISCO_MDL  0x00000800 /* Middle TSO of iSCSI PDU */
+#define E1000_ADVTXD_POPTS_ISCO_LAST 0x00001000 /* Last TSO of iSCSI PDU */
+#define E1000_ADVTXD_POPTS_ISCO_FULL 0x00001800 /* 1st&Last TSO-full iSCSI PDU*/
+#define E1000_ADVTXD_POPTS_IPSEC     0x00000400 /* IPSec offload request */
 #define E1000_ADVTXD_PAYLEN_SHIFT    14 /* Adv desc PAYLEN shift */
 
 /* Context descriptors */
@@ -126,25 +299,154 @@ struct e1000_adv_tx_context_desc {
 };
 
 #define E1000_ADVTXD_MACLEN_SHIFT    9  /* Adv ctxt desc mac len shift */
+#define E1000_ADVTXD_VLAN_SHIFT     16  /* Adv ctxt vlan tag shift */
 #define E1000_ADVTXD_TUCMD_IPV4    0x00000400  /* IP Packet Type: 1=IPv4 */
+#define E1000_ADVTXD_TUCMD_IPV6    0x00000000  /* IP Packet Type: 0=IPv6 */
+#define E1000_ADVTXD_TUCMD_L4T_UDP 0x00000000  /* L4 Packet TYPE of UDP */
 #define E1000_ADVTXD_TUCMD_L4T_TCP 0x00000800  /* L4 Packet TYPE of TCP */
+#define E1000_ADVTXD_TUCMD_IPSEC_TYPE_ESP    0x00002000 /* IPSec Type ESP */
 /* IPSec Encrypt Enable for ESP */
+#define E1000_ADVTXD_TUCMD_IPSEC_ENCRYPT_EN  0x00004000
+#define E1000_ADVTXD_TUCMD_MKRREQ  0x00002000 /* Req requires Markers and CRC */
 #define E1000_ADVTXD_L4LEN_SHIFT     8  /* Adv ctxt L4LEN shift */
 #define E1000_ADVTXD_MSS_SHIFT      16  /* Adv ctxt MSS shift */
 /* Adv ctxt IPSec SA IDX mask */
+#define E1000_ADVTXD_IPSEC_SA_INDEX_MASK     0x000000FF
 /* Adv ctxt IPSec ESP len mask */
+#define E1000_ADVTXD_IPSEC_ESP_LEN_MASK      0x000000FF
 
 /* Additional Transmit Descriptor Control definitions */
 #define E1000_TXDCTL_QUEUE_ENABLE  0x02000000 /* Enable specific Tx Queue */
+#define E1000_TXDCTL_SWFLSH        0x04000000 /* Tx Desc. write-back flushing */
 /* Tx Queue Arbitration Priority 0=low, 1=high */
+#define E1000_TXDCTL_PRIORITY      0x08000000
 
 /* Additional Receive Descriptor Control definitions */
 #define E1000_RXDCTL_QUEUE_ENABLE  0x02000000 /* Enable specific Rx Queue */
+#define E1000_RXDCTL_SWFLSH        0x04000000 /* Rx Desc. write-back flushing */
 
 /* Direct Cache Access (DCA) definitions */
+#define E1000_DCA_CTRL_DCA_ENABLE  0x00000000 /* DCA Enable */
+#define E1000_DCA_CTRL_DCA_DISABLE 0x00000001 /* DCA Disable */
+
+#define E1000_DCA_CTRL_DCA_MODE_CB1 0x00 /* DCA Mode CB1 */
+#define E1000_DCA_CTRL_DCA_MODE_CB2 0x02 /* DCA Mode CB2 */
+
+#define E1000_DCA_RXCTRL_CPUID_MASK 0x0000001F /* Rx CPUID Mask */
+#define E1000_DCA_RXCTRL_DESC_DCA_EN (1 << 5) /* DCA Rx Desc enable */
+#define E1000_DCA_RXCTRL_HEAD_DCA_EN (1 << 6) /* DCA Rx Desc header enable */
+#define E1000_DCA_RXCTRL_DATA_DCA_EN (1 << 7) /* DCA Rx Desc payload enable */
+
+#define E1000_DCA_TXCTRL_CPUID_MASK 0x0000001F /* Tx CPUID Mask */
+#define E1000_DCA_TXCTRL_DESC_DCA_EN (1 << 5) /* DCA Tx Desc enable */
+#define E1000_DCA_TXCTRL_TX_WB_RO_EN (1 << 11) /* Tx Desc writeback RO bit */
+
+/* Additional DCA related definitions, note change in position of CPUID */
+#define E1000_DCA_TXCTRL_CPUID_MASK_82576 0xFF000000 /* Tx CPUID Mask */
+#define E1000_DCA_RXCTRL_CPUID_MASK_82576 0xFF000000 /* Rx CPUID Mask */
+#define E1000_DCA_TXCTRL_CPUID_SHIFT 24 /* Tx CPUID now in the last byte */
+#define E1000_DCA_RXCTRL_CPUID_SHIFT 24 /* Rx CPUID now in the last byte */
+
+/* Additional interrupt register bit definitions */
+#define E1000_ICR_LSECPNS       0x00000020          /* PN threshold - server */
+#define E1000_IMS_LSECPNS       E1000_ICR_LSECPNS   /* PN threshold - server */
+#define E1000_ICS_LSECPNS       E1000_ICR_LSECPNS   /* PN threshold - server */
+
+/* ETQF register bit definitions */
+#define E1000_ETQF_FILTER_ENABLE   (1 << 26)
+#define E1000_ETQF_IMM_INT         (1 << 29)
+/*
+ * ETQF filter list: one static filter per filter consumer. This is
+ *                   to avoid filter collisions later. Add new filters
+ *                   here!!
+ *
+ * Current filters:
+ *    EAPOL 802.1x (0x888e): Filter 0
+ */
+#define E1000_ETQF_FILTER_EAPOL          0
+
+#define E1000_NVM_APME_82575          0x0400
+#define MAX_NUM_VFS                   8
+
+#define E1000_DTXSWC_MAC_SPOOF_MASK   0x000000FF /* Per VF MAC spoof control */
+#define E1000_DTXSWC_VLAN_SPOOF_MASK  0x0000FF00 /* Per VF VLAN spoof control */
+#define E1000_DTXSWC_LLE_MASK         0x00FF0000 /* Per VF Local LB enables */
+#define E1000_DTXSWC_VMDQ_LOOPBACK_EN (1 << 31)  /* global VF LB enable */
+
+/* Easy defines for setting default pool, would normally be left a zero */
+#define E1000_VT_CTL_DEFAULT_POOL_SHIFT 7
+#define E1000_VT_CTL_DEFAULT_POOL_MASK  (0x7 << E1000_VT_CTL_DEFAULT_POOL_SHIFT)
+
+/* Other useful VMD_CTL register defines */
+#define E1000_VT_CTL_IGNORE_MAC         (1 << 28)
+#define E1000_VT_CTL_DISABLE_DEF_POOL   (1 << 29)
+#define E1000_VT_CTL_VM_REPL_EN         (1 << 30)
+
+/* Per VM Offload register setup */
+#define E1000_VMOLR_LPE        0x00010000 /* Accept Long packet */
+#define E1000_VMOLR_AUPE       0x01000000 /* Accept untagged packets */
+#define E1000_VMOLR_BAM        0x08000000 /* Accept Broadcast packets */
+#define E1000_VMOLR_MPME       0x10000000 /* Multicast promiscuous mode */
+#define E1000_VMOLR_STRVLAN    0x40000000 /* Vlan stripping enable */
+
+#define E1000_V2PMAILBOX_REQ   0x00000001 /* Request for PF Ready bit */
+#define E1000_V2PMAILBOX_ACK   0x00000002 /* Ack PF message received */
+#define E1000_V2PMAILBOX_VFU   0x00000004 /* VF owns the mailbox buffer */
+#define E1000_V2PMAILBOX_PFU   0x00000008 /* PF owns the mailbox buffer */
+#define E1000_V2PMAILBOX_PFSTS 0x00000010 /* PF wrote a message in the MB */
+#define E1000_V2PMAILBOX_PFACK 0x00000020 /* PF ack the previous VF msg */
+#define E1000_V2PMAILBOX_RSTI  0x00000040 /* PF has reset indication */
+
+#define E1000_P2VMAILBOX_STS   0x00000001 /* Initiate message send to VF */
+#define E1000_P2VMAILBOX_ACK   0x00000002 /* Ack message recv'd from VF */
+#define E1000_P2VMAILBOX_VFU   0x00000004 /* VF owns the mailbox buffer */
+#define E1000_P2VMAILBOX_PFU   0x00000008 /* PF owns the mailbox buffer */
+#define E1000_P2VMAILBOX_RVFU  0x00000010 /* Reset VFU - used when VF stuck */
+
+#define E1000_VFMAILBOX_SIZE   16 /* 16 32 bit words - 64 bytes */
+
+/* If it's a E1000_VF_* msg then it originates in the VF and is sent to the
+ * PF.  The reverse is true if it is E1000_PF_*.
+ * Message ACK's are the value or'd with 0xF0000000
+ */
+#define E1000_VT_MSGTYPE_ACK      0xF0000000  /* Messages below or'd with
+                                               * this are the ACK */
+#define E1000_VT_MSGTYPE_NACK     0xFF000000  /* Messages below or'd with
+                                               * this are the NACK */
+#define E1000_VT_MSGINFO_SHIFT    16
+/* bits 23:16 are used for exra info for certain messages */
+#define E1000_VT_MSGINFO_MASK     (0xFF << E1000_VT_MSGINFO_SHIFT)
+
+#define E1000_VF_MSGTYPE_REQ_MAC  1 /* VF needs to know its MAC */
+#define E1000_VF_MSGTYPE_VFLR     2 /* VF notifies VFLR to PF */
+#define E1000_VF_SET_MULTICAST    3 /* VF requests PF to set MC addr */
+#define E1000_VF_SET_VLAN         4 /* VF requests PF to set VLAN */
+
+/* Add 100h to all PF msgs, leaves room for up to 255 discrete message types
+ * from VF to PF - way more than we'll ever need */
+#define E1000_PF_MSGTYPE_RESET    (1 + 0x100) /* PF notifies global reset
+                                               * imminent to VF */
+#define E1000_PF_MSGTYPE_LSC      (2 + 0x100) /* PF notifies VF of LSC... VF
+                                               * will see extra msg info for
+                                               * status */
 
+#define E1000_PF_MSG_LSCDOWN      (1 << E1000_VT_MSGINFO_SHIFT)
+#define E1000_PF_MSG_LSCUP        (2 << E1000_VT_MSGINFO_SHIFT)
 
+s32  e1000_send_mail_to_pf_vf(struct e1000_hw *hw, u32 *msg,
+                              s16 size);
+s32  e1000_receive_mail_from_pf_vf(struct e1000_hw *hw,
+                                   u32 *msg, s16 size);
+s32  e1000_send_mail_to_vf(struct e1000_hw *hw, u32 *msg,
+                           u32 vf_number, s16 size);
+s32  e1000_receive_mail_from_vf(struct e1000_hw *hw, u32 *msg,
+                                u32 vf_number, s16 size);
+void e1000_vmdq_loopback_enable_vf(struct e1000_hw *hw);
+void e1000_vmdq_loopback_disable_vf(struct e1000_hw *hw);
+void e1000_vmdq_replication_enable_vf(struct e1000_hw *hw, u32 enables);
+void e1000_vmdq_replication_disable_vf(struct e1000_hw *hw);
+bool e1000_check_for_pf_ack_vf(struct e1000_hw *hw);
+bool e1000_check_for_pf_mail_vf(struct e1000_hw *hw, u32*);
 
-#define E1000_DCA_TXCTRL_TX_WB_RO_EN (1 << 11) /* TX Desc writeback RO bit */
 
 #endif
index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..9ee4ee2c00400c58d8d26a7fe3daa61652b5b3c7 100644 (file)
+/*******************************************************************************
+
+  Intel(R) Gigabit Ethernet Linux driver
+  Copyright(c) 2007-2008 Intel Corporation.
+
+  This program is free software; you can redistribute it and/or modify it
+  under the terms and conditions of the GNU General Public License,
+  version 2, as published by the Free Software Foundation.
+
+  This program is distributed in the hope it will be useful, but WITHOUT
+  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+  FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
+  more details.
+
+  You should have received a copy of the GNU General Public License along with
+  this program; if not, write to the Free Software Foundation, Inc.,
+  51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
+
+  The full GNU General Public License is included in this distribution in
+  the file called "COPYING".
+
+  Contact Information:
+  e1000-devel Mailing List <e1000-devel@lists.sourceforge.net>
+  Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
+
+*******************************************************************************/
+
+#include "e1000_api.h"
+
+/**
+ *  e1000_init_mac_params - Initialize MAC function pointers
+ *  @hw: pointer to the HW structure
+ *
+ *  This function initializes the function pointers for the MAC
+ *  set of functions.  Called by drivers or by e1000_setup_init_funcs.
+ **/
+s32 e1000_init_mac_params(struct e1000_hw *hw)
+{
+       s32 ret_val = E1000_SUCCESS;
+
+       if (hw->mac.ops.init_params) {
+               ret_val = hw->mac.ops.init_params(hw);
+               if (ret_val) {
+                       DEBUGOUT("MAC Initialization Error\n");
+                       goto out;
+               }
+       } else {
+               DEBUGOUT("mac.init_mac_params was NULL\n");
+               ret_val = -E1000_ERR_CONFIG;
+       }
+
+out:
+       return ret_val;
+}
+
+/**
+ *  e1000_init_nvm_params - Initialize NVM function pointers
+ *  @hw: pointer to the HW structure
+ *
+ *  This function initializes the function pointers for the NVM
+ *  set of functions.  Called by drivers or by e1000_setup_init_funcs.
+ **/
+s32 e1000_init_nvm_params(struct e1000_hw *hw)
+{
+       s32 ret_val = E1000_SUCCESS;
+
+       if (hw->nvm.ops.init_params) {
+               ret_val = hw->nvm.ops.init_params(hw);
+               if (ret_val) {
+                       DEBUGOUT("NVM Initialization Error\n");
+                       goto out;
+               }
+       } else {
+               DEBUGOUT("nvm.init_nvm_params was NULL\n");
+               ret_val = -E1000_ERR_CONFIG;
+       }
+
+out:
+       return ret_val;
+}
+
+/**
+ *  e1000_init_phy_params - Initialize PHY function pointers
+ *  @hw: pointer to the HW structure
+ *
+ *  This function initializes the function pointers for the PHY
+ *  set of functions.  Called by drivers or by e1000_setup_init_funcs.
+ **/
+s32 e1000_init_phy_params(struct e1000_hw *hw)
+{
+       s32 ret_val = E1000_SUCCESS;
+
+       if (hw->phy.ops.init_params) {
+               ret_val = hw->phy.ops.init_params(hw);
+               if (ret_val) {
+                       DEBUGOUT("PHY Initialization Error\n");
+                       goto out;
+               }
+       } else {
+               DEBUGOUT("phy.init_phy_params was NULL\n");
+               ret_val =  -E1000_ERR_CONFIG;
+       }
+
+out:
+       return ret_val;
+}
+
+/**
+ *  e1000_set_mac_type - Sets MAC type
+ *  @hw: pointer to the HW structure
+ *
+ *  This function sets the mac type of the adapter based on the
+ *  device ID stored in the hw structure.
+ *  MUST BE FIRST FUNCTION CALLED (explicitly or through
+ *  e1000_setup_init_funcs()).
+ **/
+s32 e1000_set_mac_type(struct e1000_hw *hw)
+{
+       struct e1000_mac_info *mac = &hw->mac;
+       s32 ret_val = E1000_SUCCESS;
+
+       DEBUGFUNC("e1000_set_mac_type");
+
+       switch (hw->device_id) {
+       case E1000_DEV_ID_82575EB_COPPER:
+       case E1000_DEV_ID_82575EB_FIBER_SERDES:
+       case E1000_DEV_ID_82575GB_QUAD_COPPER:
+               mac->type = e1000_82575;
+               break;
+       case E1000_DEV_ID_82576:
+       case E1000_DEV_ID_82576_FIBER:
+       case E1000_DEV_ID_82576_SERDES:
+               mac->type = e1000_82576;
+               break;
+       default:
+               /* Should never have loaded on this device */
+               ret_val = -E1000_ERR_MAC_INIT;
+               break;
+       }
+
+       return ret_val;
+}
+
+/**
+ *  e1000_setup_init_funcs - Initializes function pointers
+ *  @hw: pointer to the HW structure
+ *  @init_device: true will initialize the rest of the function pointers
+ *                 getting the device ready for use.  false will only set
+ *                 MAC type and the function pointers for the other init
+ *                 functions.  Passing false will not generate any hardware
+ *                 reads or writes.
+ *
+ *  This function must be called by a driver in order to use the rest
+ *  of the 'shared' code files. Called by drivers only.
+ **/
+s32 e1000_setup_init_funcs(struct e1000_hw *hw, bool init_device)
+{
+       s32 ret_val;
+
+       /* Can't do much good without knowing the MAC type. */
+       ret_val = e1000_set_mac_type(hw);
+       if (ret_val) {
+               DEBUGOUT("ERROR: MAC type could not be set properly.\n");
+               goto out;
+       }
+
+       if (!hw->hw_addr) {
+               DEBUGOUT("ERROR: Registers not mapped\n");
+               ret_val = -E1000_ERR_CONFIG;
+               goto out;
+       }
+
+       /*
+        * Init function pointers to generic implementations. We do this first
+        * allowing a driver module to override it afterward.
+        */
+       e1000_init_mac_ops_generic(hw);
+       e1000_init_nvm_ops_generic(hw);
+
+       /*
+        * Set up the init function pointers. These are functions within the
+        * adapter family file that sets up function pointers for the rest of
+        * the functions in that family.
+        */
+       switch (hw->mac.type) {
+       case e1000_82575:
+       case e1000_82576:
+               e1000_init_function_pointers_82575(hw);
+               break;
+       default:
+               DEBUGOUT("Hardware not supported\n");
+               ret_val = -E1000_ERR_CONFIG;
+               break;
+       }
+
+       /*
+        * Initialize the rest of the function pointers. These require some
+        * register reads/writes in some cases.
+        */
+       if (!(ret_val) && init_device) {
+               ret_val = e1000_init_mac_params(hw);
+               if (ret_val)
+                       goto out;
+
+               ret_val = e1000_init_nvm_params(hw);
+               if (ret_val)
+                       goto out;
+
+               ret_val = e1000_init_phy_params(hw);
+               if (ret_val)
+                       goto out;
+
+       }
+
+out:
+       return ret_val;
+}
+
+/**
+ *  e1000_get_bus_info - Obtain bus information for adapter
+ *  @hw: pointer to the HW structure
+ *
+ *  This will obtain information about the HW bus for which the
+ *  adapter is attached and stores it in the hw structure. This is a
+ *  function pointer entry point called by drivers.
+ **/
+s32 e1000_get_bus_info(struct e1000_hw *hw)
+{
+       if (hw->mac.ops.get_bus_info)
+               return hw->mac.ops.get_bus_info(hw);
+
+       return E1000_SUCCESS;
+}
+
+/**
+ *  e1000_clear_vfta - Clear VLAN filter table
+ *  @hw: pointer to the HW structure
+ *
+ *  This clears the VLAN filter table on the adapter. This is a function
+ *  pointer entry point called by drivers.
+ **/
+void e1000_clear_vfta(struct e1000_hw *hw)
+{
+       if (hw->mac.ops.clear_vfta)
+               hw->mac.ops.clear_vfta(hw);
+}
+
+/**
+ *  e1000_write_vfta - Write value to VLAN filter table
+ *  @hw: pointer to the HW structure
+ *  @offset: the 32-bit offset in which to write the value to.
+ *  @value: the 32-bit value to write at location offset.
+ *
+ *  This writes a 32-bit value to a 32-bit offset in the VLAN filter
+ *  table. This is a function pointer entry point called by drivers.
+ **/
+void e1000_write_vfta(struct e1000_hw *hw, u32 offset, u32 value)
+{
+       if (hw->mac.ops.write_vfta)
+               hw->mac.ops.write_vfta(hw, offset, value);
+}
+
+/**
+ *  e1000_update_mc_addr_list - Update Multicast addresses
+ *  @hw: pointer to the HW structure
+ *  @mc_addr_list: array of multicast addresses to program
+ *  @mc_addr_count: number of multicast addresses to program
+ *  @rar_used_count: the first RAR register free to program
+ *  @rar_count: total number of supported Receive Address Registers
+ *
+ *  Updates the Receive Address Registers and Multicast Table Array.
+ *  The caller must have a packed mc_addr_list of multicast addresses.
+ *  The parameter rar_count will usually be hw->mac.rar_entry_count
+ *  unless there are workarounds that change this.  Currently no func pointer
+ *  exists and all implementations are handled in the generic version of this
+ *  function.
+ **/
+void e1000_update_mc_addr_list(struct e1000_hw *hw, u8 *mc_addr_list,
+                               u32 mc_addr_count, u32 rar_used_count,
+                               u32 rar_count)
+{
+       if (hw->mac.ops.update_mc_addr_list)
+               hw->mac.ops.update_mc_addr_list(hw,
+                                               mc_addr_list,
+                                               mc_addr_count,
+                                               rar_used_count,
+                                               rar_count);
+}
+
+/**
+ *  e1000_force_mac_fc - Force MAC flow control
+ *  @hw: pointer to the HW structure
+ *
+ *  Force the MAC's flow control settings. Currently no func pointer exists
+ *  and all implementations are handled in the generic version of this
+ *  function.
+ **/
+s32 e1000_force_mac_fc(struct e1000_hw *hw)
+{
+       return e1000_force_mac_fc_generic(hw);
+}
+
+/**
+ *  e1000_check_for_link - Check/Store link connection
+ *  @hw: pointer to the HW structure
+ *
+ *  This checks the link condition of the adapter and stores the
+ *  results in the hw->mac structure. This is a function pointer entry
+ *  point called by drivers.
+ **/
+s32 e1000_check_for_link(struct e1000_hw *hw)
+{
+       if (hw->mac.ops.check_for_link)
+               return hw->mac.ops.check_for_link(hw);
+
+       return -E1000_ERR_CONFIG;
+}
+
+/**
+ *  e1000_check_mng_mode - Check management mode
+ *  @hw: pointer to the HW structure
+ *
+ *  This checks if the adapter has manageability enabled.
+ *  This is a function pointer entry point called by drivers.
+ **/
+bool e1000_check_mng_mode(struct e1000_hw *hw)
+{
+       if (hw->mac.ops.check_mng_mode)
+               return hw->mac.ops.check_mng_mode(hw);
+
+       return false;
+}
+
+/**
+ *  e1000_mng_write_dhcp_info - Writes DHCP info to host interface
+ *  @hw: pointer to the HW structure
+ *  @buffer: pointer to the host interface
+ *  @length: size of the buffer
+ *
+ *  Writes the DHCP information to the host interface.
+ **/
+s32 e1000_mng_write_dhcp_info(struct e1000_hw *hw, u8 *buffer, u16 length)
+{
+       return e1000_mng_write_dhcp_info_generic(hw, buffer, length);
+}
+
+/**
+ *  e1000_reset_hw - Reset hardware
+ *  @hw: pointer to the HW structure
+ *
+ *  This resets the hardware into a known state. This is a function pointer
+ *  entry point called by drivers.
+ **/
+s32 e1000_reset_hw(struct e1000_hw *hw)
+{
+       if (hw->mac.ops.reset_hw)
+               return hw->mac.ops.reset_hw(hw);
+
+       return -E1000_ERR_CONFIG;
+}
+
+/**
+ *  e1000_init_hw - Initialize hardware
+ *  @hw: pointer to the HW structure
+ *
+ *  This inits the hardware readying it for operation. This is a function
+ *  pointer entry point called by drivers.
+ **/
+s32 e1000_init_hw(struct e1000_hw *hw)
+{
+       if (hw->mac.ops.init_hw)
+               return hw->mac.ops.init_hw(hw);
+
+       return -E1000_ERR_CONFIG;
+}
+
+/**
+ *  e1000_setup_link - Configures link and flow control
+ *  @hw: pointer to the HW structure
+ *
+ *  This configures link and flow control settings for the adapter. This
+ *  is a function pointer entry point called by drivers. While modules can
+ *  also call this, they probably call their own version of this function.
+ **/
+s32 e1000_setup_link(struct e1000_hw *hw)
+{
+       if (hw->mac.ops.setup_link)
+               return hw->mac.ops.setup_link(hw);
+
+       return -E1000_ERR_CONFIG;
+}
+
+/**
+ *  e1000_get_speed_and_duplex - Returns current speed and duplex
+ *  @hw: pointer to the HW structure
+ *  @speed: pointer to a 16-bit value to store the speed
+ *  @duplex: pointer to a 16-bit value to store the duplex.
+ *
+ *  This returns the speed and duplex of the adapter in the two 'out'
+ *  variables passed in. This is a function pointer entry point called
+ *  by drivers.
+ **/
+s32 e1000_get_speed_and_duplex(struct e1000_hw *hw, u16 *speed, u16 *duplex)
+{
+       if (hw->mac.ops.get_link_up_info)
+               return hw->mac.ops.get_link_up_info(hw, speed, duplex);
+
+       return -E1000_ERR_CONFIG;
+}
+
+/**
+ *  e1000_setup_led - Configures SW controllable LED
+ *  @hw: pointer to the HW structure
+ *
+ *  This prepares the SW controllable LED for use and saves the current state
+ *  of the LED so it can be later restored. This is a function pointer entry
+ *  point called by drivers.
+ **/
+s32 e1000_setup_led(struct e1000_hw *hw)
+{
+       if (hw->mac.ops.setup_led)
+               return hw->mac.ops.setup_led(hw);
+
+       return E1000_SUCCESS;
+}
+
+/**
+ *  e1000_cleanup_led - Restores SW controllable LED
+ *  @hw: pointer to the HW structure
+ *
+ *  This restores the SW controllable LED to the value saved off by
+ *  e1000_setup_led. This is a function pointer entry point called by drivers.
+ **/
+s32 e1000_cleanup_led(struct e1000_hw *hw)
+{
+       if (hw->mac.ops.cleanup_led)
+               return hw->mac.ops.cleanup_led(hw);
+
+       return E1000_SUCCESS;
+}
+
+/**
+ *  e1000_blink_led - Blink SW controllable LED
+ *  @hw: pointer to the HW structure
+ *
+ *  This starts the adapter LED blinking. Request the LED to be setup first
+ *  and cleaned up after. This is a function pointer entry point called by
+ *  drivers.
+ **/
+s32 e1000_blink_led(struct e1000_hw *hw)
+{
+       if (hw->mac.ops.blink_led)
+               return hw->mac.ops.blink_led(hw);
+
+       return E1000_SUCCESS;
+}
+
+/**
+ *  e1000_led_on - Turn on SW controllable LED
+ *  @hw: pointer to the HW structure
+ *
+ *  Turns the SW defined LED on. This is a function pointer entry point
+ *  called by drivers.
+ **/
+s32 e1000_led_on(struct e1000_hw *hw)
+{
+       if (hw->mac.ops.led_on)
+               return hw->mac.ops.led_on(hw);
+
+       return E1000_SUCCESS;
+}
+
+/**
+ *  e1000_led_off - Turn off SW controllable LED
+ *  @hw: pointer to the HW structure
+ *
+ *  Turns the SW defined LED off. This is a function pointer entry point
+ *  called by drivers.
+ **/
+s32 e1000_led_off(struct e1000_hw *hw)
+{
+       if (hw->mac.ops.led_off)
+               return hw->mac.ops.led_off(hw);
+
+       return E1000_SUCCESS;
+}
+
+/**
+ *  e1000_reset_adaptive - Reset adaptive IFS
+ *  @hw: pointer to the HW structure
+ *
+ *  Resets the adaptive IFS. Currently no func pointer exists and all
+ *  implementations are handled in the generic version of this function.
+ **/
+void e1000_reset_adaptive(struct e1000_hw *hw)
+{
+       e1000_reset_adaptive_generic(hw);
+}
+
+/**
+ *  e1000_update_adaptive - Update adaptive IFS
+ *  @hw: pointer to the HW structure
+ *
+ *  Updates adapter IFS. Currently no func pointer exists and all
+ *  implementations are handled in the generic version of this function.
+ **/
+void e1000_update_adaptive(struct e1000_hw *hw)
+{
+       e1000_update_adaptive_generic(hw);
+}
+
+/**
+ *  e1000_disable_pcie_master - Disable PCI-Express master access
+ *  @hw: pointer to the HW structure
+ *
+ *  Disables PCI-Express master access and verifies there are no pending
+ *  requests. Currently no func pointer exists and all implementations are
+ *  handled in the generic version of this function.
+ **/
+s32 e1000_disable_pcie_master(struct e1000_hw *hw)
+{
+       return e1000_disable_pcie_master_generic(hw);
+}
+
+/**
+ *  e1000_config_collision_dist - Configure collision distance
+ *  @hw: pointer to the HW structure
+ *
+ *  Configures the collision distance to the default value and is used
+ *  during link setup.
+ **/
+void e1000_config_collision_dist(struct e1000_hw *hw)
+{
+       if (hw->mac.ops.config_collision_dist)
+               hw->mac.ops.config_collision_dist(hw);
+}
+
+/**
+ *  e1000_rar_set - Sets a receive address register
+ *  @hw: pointer to the HW structure
+ *  @addr: address to set the RAR to
+ *  @index: the RAR to set
+ *
+ *  Sets a Receive Address Register (RAR) to the specified address.
+ **/
+void e1000_rar_set(struct e1000_hw *hw, u8 *addr, u32 index)
+{
+       if (hw->mac.ops.rar_set)
+               hw->mac.ops.rar_set(hw, addr, index);
+}
+
+/**
+ *  e1000_validate_mdi_setting - Ensures valid MDI/MDIX SW state
+ *  @hw: pointer to the HW structure
+ *
+ *  Ensures that the MDI/MDIX SW state is valid.
+ **/
+s32 e1000_validate_mdi_setting(struct e1000_hw *hw)
+{
+       if (hw->mac.ops.validate_mdi_setting)
+               return hw->mac.ops.validate_mdi_setting(hw);
+
+       return E1000_SUCCESS;
+}
+
+/**
+ *  e1000_mta_set - Sets multicast table bit
+ *  @hw: pointer to the HW structure
+ *  @hash_value: Multicast hash value.
+ *
+ *  This sets the bit in the multicast table corresponding to the
+ *  hash value.  This is a function pointer entry point called by drivers.
+ **/
+void e1000_mta_set(struct e1000_hw *hw, u32 hash_value)
+{
+       if (hw->mac.ops.mta_set)
+               hw->mac.ops.mta_set(hw, hash_value);
+}
+
+/**
+ *  e1000_hash_mc_addr - Determines address location in multicast table
+ *  @hw: pointer to the HW structure
+ *  @mc_addr: Multicast address to hash.
+ *
+ *  This hashes an address to determine its location in the multicast
+ *  table. Currently no func pointer exists and all implementations
+ *  are handled in the generic version of this function.
+ **/
+u32 e1000_hash_mc_addr(struct e1000_hw *hw, u8 *mc_addr)
+{
+       return e1000_hash_mc_addr_generic(hw, mc_addr);
+}
+
+/**
+ *  e1000_enable_tx_pkt_filtering - Enable packet filtering on TX
+ *  @hw: pointer to the HW structure
+ *
+ *  Enables packet filtering on transmit packets if manageability is enabled
+ *  and host interface is enabled.
+ *  Currently no func pointer exists and all implementations are handled in the
+ *  generic version of this function.
+ **/
+bool e1000_enable_tx_pkt_filtering(struct e1000_hw *hw)
+{
+       return e1000_enable_tx_pkt_filtering_generic(hw);
+}
+
+/**
+ *  e1000_mng_host_if_write - Writes to the manageability host interface
+ *  @hw: pointer to the HW structure
+ *  @buffer: pointer to the host interface buffer
+ *  @length: size of the buffer
+ *  @offset: location in the buffer to write to
+ *  @sum: sum of the data (not checksum)
+ *
+ *  This function writes the buffer content at the offset given on the host if.
+ *  It also does alignment considerations to do the writes in most efficient
+ *  way.  Also fills up the sum of the buffer in *buffer parameter.
+ **/
+s32 e1000_mng_host_if_write(struct e1000_hw * hw, u8 *buffer, u16 length,
+                            u16 offset, u8 *sum)
+{
+       if (hw->mac.ops.mng_host_if_write)
+               return hw->mac.ops.mng_host_if_write(hw, buffer, length,
+                                                    offset, sum);
+
+       return E1000_NOT_IMPLEMENTED;
+}
+
+/**
+ *  e1000_mng_write_cmd_header - Writes manageability command header
+ *  @hw: pointer to the HW structure
+ *  @hdr: pointer to the host interface command header
+ *
+ *  Writes the command header after does the checksum calculation.
+ **/
+s32 e1000_mng_write_cmd_header(struct e1000_hw *hw,
+                               struct e1000_host_mng_command_header *hdr)
+{
+       if (hw->mac.ops.mng_write_cmd_header)
+               return hw->mac.ops.mng_write_cmd_header(hw, hdr);
+
+       return E1000_NOT_IMPLEMENTED;
+}
+
+/**
+ *  e1000_mng_enable_host_if - Checks host interface is enabled
+ *  @hw: pointer to the HW structure
+ *
+ *  Returns E1000_success upon success, else E1000_ERR_HOST_INTERFACE_COMMAND
+ *
+ *  This function checks whether the HOST IF is enabled for command operation
+ *  and also checks whether the previous command is completed.  It busy waits
+ *  in case of previous command is not completed.
+ **/
+s32 e1000_mng_enable_host_if(struct e1000_hw * hw)
+{
+       if (hw->mac.ops.mng_enable_host_if)
+               return hw->mac.ops.mng_enable_host_if(hw);
+
+       return E1000_NOT_IMPLEMENTED;
+}
+
+/**
+ *  e1000_wait_autoneg - Waits for autonegotiation completion
+ *  @hw: pointer to the HW structure
+ *
+ *  Waits for autoneg to complete. Currently no func pointer exists and all
+ *  implementations are handled in the generic version of this function.
+ **/
+s32 e1000_wait_autoneg(struct e1000_hw *hw)
+{
+       if (hw->mac.ops.wait_autoneg)
+               return hw->mac.ops.wait_autoneg(hw);
+
+       return E1000_SUCCESS;
+}
+
+/**
+ *  e1000_check_reset_block - Verifies PHY can be reset
+ *  @hw: pointer to the HW structure
+ *
+ *  Checks if the PHY is in a state that can be reset or if manageability
+ *  has it tied up. This is a function pointer entry point called by drivers.
+ **/
+s32 e1000_check_reset_block(struct e1000_hw *hw)
+{
+       if (hw->phy.ops.check_reset_block)
+               return hw->phy.ops.check_reset_block(hw);
+
+       return E1000_SUCCESS;
+}
+
+/**
+ *  e1000_read_phy_reg - Reads PHY register
+ *  @hw: pointer to the HW structure
+ *  @offset: the register to read
+ *  @data: the buffer to store the 16-bit read.
+ *
+ *  Reads the PHY register and returns the value in data.
+ *  This is a function pointer entry point called by drivers.
+ **/
+s32 e1000_read_phy_reg(struct e1000_hw *hw, u32 offset, u16 *data)
+{
+       if (hw->phy.ops.read_reg)
+               return hw->phy.ops.read_reg(hw, offset, data);
+
+       return E1000_SUCCESS;
+}
+
+/**
+ *  e1000_write_phy_reg - Writes PHY register
+ *  @hw: pointer to the HW structure
+ *  @offset: the register to write
+ *  @data: the value to write.
+ *
+ *  Writes the PHY register at offset with the value in data.
+ *  This is a function pointer entry point called by drivers.
+ **/
+s32 e1000_write_phy_reg(struct e1000_hw *hw, u32 offset, u16 data)
+{
+       if (hw->phy.ops.write_reg)
+               return hw->phy.ops.write_reg(hw, offset, data);
+
+       return E1000_SUCCESS;
+}
+
+/**
+ *  e1000_release_phy - Generic release PHY
+ *  @hw: pointer to the HW structure
+ *
+ *  Return if silicon family does not require a semaphore when accessing the
+ *  PHY.
+ **/
+void e1000_release_phy(struct e1000_hw *hw)
+{
+       if (hw->phy.ops.release)
+               hw->phy.ops.release(hw);
+}
+
+/**
+ *  e1000_acquire_phy - Generic acquire PHY
+ *  @hw: pointer to the HW structure
+ *
+ *  Return success if silicon family does not require a semaphore when
+ *  accessing the PHY.
+ **/
+s32 e1000_acquire_phy(struct e1000_hw *hw)
+{
+       if (hw->phy.ops.acquire)
+               return hw->phy.ops.acquire(hw);
+
+       return E1000_SUCCESS;
+}
+
+/**
+ *  e1000_read_kmrn_reg - Reads register using Kumeran interface
+ *  @hw: pointer to the HW structure
+ *  @offset: the register to read
+ *  @data: the location to store the 16-bit value read.
+ *
+ *  Reads a register out of the Kumeran interface. Currently no func pointer
+ *  exists and all implementations are handled in the generic version of
+ *  this function.
+ **/
+s32 e1000_read_kmrn_reg(struct e1000_hw *hw, u32 offset, u16 *data)
+{
+       return e1000_read_kmrn_reg_generic(hw, offset, data);
+}
+
+/**
+ *  e1000_write_kmrn_reg - Writes register using Kumeran interface
+ *  @hw: pointer to the HW structure
+ *  @offset: the register to write
+ *  @data: the value to write.
+ *
+ *  Writes a register to the Kumeran interface. Currently no func pointer
+ *  exists and all implementations are handled in the generic version of
+ *  this function.
+ **/
+s32 e1000_write_kmrn_reg(struct e1000_hw *hw, u32 offset, u16 data)
+{
+       return e1000_write_kmrn_reg_generic(hw, offset, data);
+}
+
+/**
+ *  e1000_get_cable_length - Retrieves cable length estimation
+ *  @hw: pointer to the HW structure
+ *
+ *  This function estimates the cable length and stores them in
+ *  hw->phy.min_length and hw->phy.max_length. This is a function pointer
+ *  entry point called by drivers.
+ **/
+s32 e1000_get_cable_length(struct e1000_hw *hw)
+{
+       if (hw->phy.ops.get_cable_length)
+               return hw->phy.ops.get_cable_length(hw);
+
+       return E1000_SUCCESS;
+}
+
+/**
+ *  e1000_get_phy_info - Retrieves PHY information from registers
+ *  @hw: pointer to the HW structure
+ *
+ *  This function gets some information from various PHY registers and
+ *  populates hw->phy values with it. This is a function pointer entry
+ *  point called by drivers.
+ **/
+s32 e1000_get_phy_info(struct e1000_hw *hw)
+{
+       if (hw->phy.ops.get_info)
+               return hw->phy.ops.get_info(hw);
+
+       return E1000_SUCCESS;
+}
+
+/**
+ *  e1000_phy_hw_reset - Hard PHY reset
+ *  @hw: pointer to the HW structure
+ *
+ *  Performs a hard PHY reset. This is a function pointer entry point called
+ *  by drivers.
+ **/
+s32 e1000_phy_hw_reset(struct e1000_hw *hw)
+{
+       if (hw->phy.ops.reset)
+               return hw->phy.ops.reset(hw);
+
+       return E1000_SUCCESS;
+}
+
+/**
+ *  e1000_phy_commit - Soft PHY reset
+ *  @hw: pointer to the HW structure
+ *
+ *  Performs a soft PHY reset on those that apply. This is a function pointer
+ *  entry point called by drivers.
+ **/
+s32 e1000_phy_commit(struct e1000_hw *hw)
+{
+       if (hw->phy.ops.commit)
+               return hw->phy.ops.commit(hw);
+
+       return E1000_SUCCESS;
+}
+
+/**
+ *  e1000_set_d0_lplu_state - Sets low power link up state for D0
+ *  @hw: pointer to the HW structure
+ *  @active: boolean used to enable/disable lplu
+ *
+ *  Success returns 0, Failure returns 1
+ *
+ *  The low power link up (lplu) state is set to the power management level D0
+ *  and SmartSpeed is disabled when active is true, else clear lplu for D0
+ *  and enable Smartspeed.  LPLU and Smartspeed are mutually exclusive.  LPLU
+ *  is used during Dx states where the power conservation is most important.
+ *  During driver activity, SmartSpeed should be enabled so performance is
+ *  maintained.  This is a function pointer entry point called by drivers.
+ **/
+s32 e1000_set_d0_lplu_state(struct e1000_hw *hw, bool active)
+{
+       if (hw->phy.ops.set_d0_lplu_state)
+               return hw->phy.ops.set_d0_lplu_state(hw, active);
+
+       return E1000_SUCCESS;
+}
+
+/**
+ *  e1000_set_d3_lplu_state - Sets low power link up state for D3
+ *  @hw: pointer to the HW structure
+ *  @active: boolean used to enable/disable lplu
+ *
+ *  Success returns 0, Failure returns 1
+ *
+ *  The low power link up (lplu) state is set to the power management level D3
+ *  and SmartSpeed is disabled when active is true, else clear lplu for D3
+ *  and enable Smartspeed.  LPLU and Smartspeed are mutually exclusive.  LPLU
+ *  is used during Dx states where the power conservation is most important.
+ *  During driver activity, SmartSpeed should be enabled so performance is
+ *  maintained.  This is a function pointer entry point called by drivers.
+ **/
+s32 e1000_set_d3_lplu_state(struct e1000_hw *hw, bool active)
+{
+       if (hw->phy.ops.set_d3_lplu_state)
+               return hw->phy.ops.set_d3_lplu_state(hw, active);
+
+       return E1000_SUCCESS;
+}
+
+/**
+ *  e1000_read_mac_addr - Reads MAC address
+ *  @hw: pointer to the HW structure
+ *
+ *  Reads the MAC address out of the adapter and stores it in the HW structure.
+ *  Currently no func pointer exists and all implementations are handled in the
+ *  generic version of this function.
+ **/
+s32 e1000_read_mac_addr(struct e1000_hw *hw)
+{
+       if (hw->mac.ops.read_mac_addr)
+               return hw->mac.ops.read_mac_addr(hw);
+
+       return e1000_read_mac_addr_generic(hw);
+}
+
+/**
+ *  e1000_read_pba_num - Read device part number
+ *  @hw: pointer to the HW structure
+ *  @pba_num: pointer to device part number
+ *
+ *  Reads the product board assembly (PBA) number from the EEPROM and stores
+ *  the value in pba_num.
+ *  Currently no func pointer exists and all implementations are handled in the
+ *  generic version of this function.
+ **/
+s32 e1000_read_pba_num(struct e1000_hw *hw, u32 *pba_num)
+{
+       return e1000_read_pba_num_generic(hw, pba_num);
+}
+
+/**
+ *  e1000_validate_nvm_checksum - Verifies NVM (EEPROM) checksum
+ *  @hw: pointer to the HW structure
+ *
+ *  Validates the NVM checksum is correct. This is a function pointer entry
+ *  point called by drivers.
+ **/
+s32 e1000_validate_nvm_checksum(struct e1000_hw *hw)
+{
+       if (hw->nvm.ops.validate)
+               return hw->nvm.ops.validate(hw);
+
+       return -E1000_ERR_CONFIG;
+}
+
+/**
+ *  e1000_update_nvm_checksum - Updates NVM (EEPROM) checksum
+ *  @hw: pointer to the HW structure
+ *
+ *  Updates the NVM checksum. Currently no func pointer exists and all
+ *  implementations are handled in the generic version of this function.
+ **/
+s32 e1000_update_nvm_checksum(struct e1000_hw *hw)
+{
+       if (hw->nvm.ops.update)
+               return hw->nvm.ops.update(hw);
+
+       return -E1000_ERR_CONFIG;
+}
+
+/**
+ *  e1000_reload_nvm - Reloads EEPROM
+ *  @hw: pointer to the HW structure
+ *
+ *  Reloads the EEPROM by setting the "Reinitialize from EEPROM" bit in the
+ *  extended control register.
+ **/
+void e1000_reload_nvm(struct e1000_hw *hw)
+{
+       if (hw->nvm.ops.reload)
+               hw->nvm.ops.reload(hw);
+}
+
+/**
+ *  e1000_read_nvm - Reads NVM (EEPROM)
+ *  @hw: pointer to the HW structure
+ *  @offset: the word offset to read
+ *  @words: number of 16-bit words to read
+ *  @data: pointer to the properly sized buffer for the data.
+ *
+ *  Reads 16-bit chunks of data from the NVM (EEPROM). This is a function
+ *  pointer entry point called by drivers.
+ **/
+s32 e1000_read_nvm(struct e1000_hw *hw, u16 offset, u16 words, u16 *data)
+{
+       if (hw->nvm.ops.read)
+               return hw->nvm.ops.read(hw, offset, words, data);
+
+       return -E1000_ERR_CONFIG;
+}
+
+/**
+ *  e1000_write_nvm - Writes to NVM (EEPROM)
+ *  @hw: pointer to the HW structure
+ *  @offset: the word offset to read
+ *  @words: number of 16-bit words to write
+ *  @data: pointer to the properly sized buffer for the data.
+ *
+ *  Writes 16-bit chunks of data to the NVM (EEPROM). This is a function
+ *  pointer entry point called by drivers.
+ **/
+s32 e1000_write_nvm(struct e1000_hw *hw, u16 offset, u16 words, u16 *data)
+{
+       if (hw->nvm.ops.write)
+               return hw->nvm.ops.write(hw, offset, words, data);
+
+       return E1000_SUCCESS;
+}
+
+/**
+ *  e1000_write_8bit_ctrl_reg - Writes 8bit Control register
+ *  @hw: pointer to the HW structure
+ *  @reg: 32bit register offset
+ *  @offset: the register to write
+ *  @data: the value to write.
+ *
+ *  Writes the PHY register at offset with the value in data.
+ *  This is a function pointer entry point called by drivers.
+ **/
+s32 e1000_write_8bit_ctrl_reg(struct e1000_hw *hw, u32 reg, u32 offset,
+                              u8 data)
+{
+       return e1000_write_8bit_ctrl_reg_generic(hw, reg, offset, data);
+}
+
+/**
+ * e1000_power_up_phy - Restores link in case of PHY power down
+ * @hw: pointer to the HW structure
+ *
+ * The phy may be powered down to save power, to turn off link when the
+ * driver is unloaded, or wake on lan is not enabled (among others).
+ **/
+void e1000_power_up_phy(struct e1000_hw *hw)
+{
+       if (hw->phy.ops.power_up)
+               hw->phy.ops.power_up(hw);
+
+       e1000_setup_link(hw);
+}
+
+/**
+ * e1000_power_down_phy - Power down PHY
+ * @hw: pointer to the HW structure
+ *
+ * The phy may be powered down to save power, to turn off link when the
+ * driver is unloaded, or wake on lan is not enabled (among others).
+ **/
+void e1000_power_down_phy(struct e1000_hw *hw)
+{
+       if (hw->phy.ops.power_down)
+               hw->phy.ops.power_down(hw);
+}
+
+/**
+ *  e1000_shutdown_fiber_serdes_link - Remove link during power down
+ *  @hw: pointer to the HW structure
+ *
+ *  Shutdown the optics and PCS on driver unload.
+ **/
+void e1000_shutdown_fiber_serdes_link(struct e1000_hw *hw)
+{
+       if (hw->mac.ops.shutdown_serdes)
+               hw->mac.ops.shutdown_serdes(hw);
+}
+
index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..2f8277a703e65d9c58d5562f3dbaf25201331d9e 100644 (file)
@@ -0,0 +1,146 @@
+/*******************************************************************************
+
+  Intel(R) Gigabit Ethernet Linux driver
+  Copyright(c) 2007-2008 Intel Corporation.
+
+  This program is free software; you can redistribute it and/or modify it
+  under the terms and conditions of the GNU General Public License,
+  version 2, as published by the Free Software Foundation.
+
+  This program is distributed in the hope it will be useful, but WITHOUT
+  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+  FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
+  more details.
+
+  You should have received a copy of the GNU General Public License along with
+  this program; if not, write to the Free Software Foundation, Inc.,
+  51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
+
+  The full GNU General Public License is included in this distribution in
+  the file called "COPYING".
+
+  Contact Information:
+  e1000-devel Mailing List <e1000-devel@lists.sourceforge.net>
+  Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
+
+*******************************************************************************/
+
+#ifndef _E1000_API_H_
+#define _E1000_API_H_
+
+#include "e1000_hw.h"
+
+extern void    e1000_init_function_pointers_82575(struct e1000_hw *hw);
+extern void    e1000_rx_fifo_flush_82575(struct e1000_hw *hw);
+extern void    e1000_init_function_pointers_vf(struct e1000_hw *hw);
+extern void    e1000_shutdown_fiber_serdes_link(struct e1000_hw *hw);
+
+s32  e1000_set_mac_type(struct e1000_hw *hw);
+s32  e1000_setup_init_funcs(struct e1000_hw *hw, bool init_device);
+s32  e1000_init_mac_params(struct e1000_hw *hw);
+s32  e1000_init_nvm_params(struct e1000_hw *hw);
+s32  e1000_init_phy_params(struct e1000_hw *hw);
+s32  e1000_get_bus_info(struct e1000_hw *hw);
+void e1000_clear_vfta(struct e1000_hw *hw);
+void e1000_write_vfta(struct e1000_hw *hw, u32 offset, u32 value);
+s32  e1000_force_mac_fc(struct e1000_hw *hw);
+s32  e1000_check_for_link(struct e1000_hw *hw);
+s32  e1000_reset_hw(struct e1000_hw *hw);
+s32  e1000_init_hw(struct e1000_hw *hw);
+s32  e1000_setup_link(struct e1000_hw *hw);
+s32  e1000_get_speed_and_duplex(struct e1000_hw *hw, u16 *speed,
+                                u16 *duplex);
+s32  e1000_disable_pcie_master(struct e1000_hw *hw);
+void e1000_config_collision_dist(struct e1000_hw *hw);
+void e1000_rar_set(struct e1000_hw *hw, u8 *addr, u32 index);
+void e1000_mta_set(struct e1000_hw *hw, u32 hash_value);
+u32  e1000_hash_mc_addr(struct e1000_hw *hw, u8 *mc_addr);
+void e1000_update_mc_addr_list(struct e1000_hw *hw,
+                               u8 *mc_addr_list, u32 mc_addr_count,
+                               u32 rar_used_count, u32 rar_count);
+s32  e1000_setup_led(struct e1000_hw *hw);
+s32  e1000_cleanup_led(struct e1000_hw *hw);
+s32  e1000_check_reset_block(struct e1000_hw *hw);
+s32  e1000_blink_led(struct e1000_hw *hw);
+s32  e1000_led_on(struct e1000_hw *hw);
+s32  e1000_led_off(struct e1000_hw *hw);
+void e1000_reset_adaptive(struct e1000_hw *hw);
+void e1000_update_adaptive(struct e1000_hw *hw);
+s32  e1000_get_cable_length(struct e1000_hw *hw);
+s32  e1000_validate_mdi_setting(struct e1000_hw *hw);
+s32  e1000_read_phy_reg(struct e1000_hw *hw, u32 offset, u16 *data);
+s32  e1000_write_phy_reg(struct e1000_hw *hw, u32 offset, u16 data);
+s32  e1000_write_8bit_ctrl_reg(struct e1000_hw *hw, u32 reg,
+                               u32 offset, u8 data);
+s32  e1000_get_phy_info(struct e1000_hw *hw);
+void e1000_release_phy(struct e1000_hw *hw);
+s32  e1000_acquire_phy(struct e1000_hw *hw);
+s32  e1000_phy_hw_reset(struct e1000_hw *hw);
+s32  e1000_phy_commit(struct e1000_hw *hw);
+void e1000_power_up_phy(struct e1000_hw *hw);
+void e1000_power_down_phy(struct e1000_hw *hw);
+s32  e1000_read_mac_addr(struct e1000_hw *hw);
+s32  e1000_read_pba_num(struct e1000_hw *hw, u32 *part_num);
+void e1000_reload_nvm(struct e1000_hw *hw);
+s32  e1000_update_nvm_checksum(struct e1000_hw *hw);
+s32  e1000_validate_nvm_checksum(struct e1000_hw *hw);
+s32  e1000_read_nvm(struct e1000_hw *hw, u16 offset, u16 words, u16 *data);
+s32  e1000_read_kmrn_reg(struct e1000_hw *hw, u32 offset, u16 *data);
+s32  e1000_write_kmrn_reg(struct e1000_hw *hw, u32 offset, u16 data);
+s32  e1000_write_nvm(struct e1000_hw *hw, u16 offset, u16 words,
+                     u16 *data);
+s32  e1000_wait_autoneg(struct e1000_hw *hw);
+s32  e1000_set_d3_lplu_state(struct e1000_hw *hw, bool active);
+s32  e1000_set_d0_lplu_state(struct e1000_hw *hw, bool active);
+bool e1000_check_mng_mode(struct e1000_hw *hw);
+bool e1000_enable_tx_pkt_filtering(struct e1000_hw *hw);
+s32  e1000_mng_enable_host_if(struct e1000_hw *hw);
+s32  e1000_mng_host_if_write(struct e1000_hw *hw,
+                             u8 *buffer, u16 length, u16 offset, u8 *sum);
+s32  e1000_mng_write_cmd_header(struct e1000_hw *hw,
+                                struct e1000_host_mng_command_header *hdr);
+s32  e1000_mng_write_dhcp_info(struct e1000_hw * hw,
+                                    u8 *buffer, u16 length);
+
+/*
+ * TBI_ACCEPT macro definition:
+ *
+ * This macro requires:
+ *      adapter = a pointer to struct e1000_hw
+ *      status = the 8 bit status field of the Rx descriptor with EOP set
+ *      error = the 8 bit error field of the Rx descriptor with EOP set
+ *      length = the sum of all the length fields of the Rx descriptors that
+ *               make up the current frame
+ *      last_byte = the last byte of the frame DMAed by the hardware
+ *      max_frame_length = the maximum frame length we want to accept.
+ *      min_frame_length = the minimum frame length we want to accept.
+ *
+ * This macro is a conditional that should be used in the interrupt
+ * handler's Rx processing routine when RxErrors have been detected.
+ *
+ * Typical use:
+ *  ...
+ *  if (TBI_ACCEPT) {
+ *      accept_frame = true;
+ *      e1000_tbi_adjust_stats(adapter, MacAddress);
+ *      frame_length--;
+ *  } else {
+ *      accept_frame = false;
+ *  }
+ *  ...
+ */
+
+/* The carrier extension symbol, as received by the NIC. */
+#define CARRIER_EXTENSION   0x0F
+
+#define TBI_ACCEPT(a, status, errors, length, last_byte, min_frame_size, max_frame_size) \
+    (e1000_tbi_sbp_enabled_82543(a) && \
+     (((errors) & E1000_RXD_ERR_FRAME_ERR_MASK) == E1000_RXD_ERR_CE) && \
+     ((last_byte) == CARRIER_EXTENSION) && \
+     (((status) & E1000_RXD_STAT_VP) ? \
+          (((length) > (min_frame_size - VLAN_TAG_SIZE)) && \
+           ((length) <= (max_frame_size + 1))) : \
+          (((length) > min_frame_size) && \
+           ((length) <= (max_frame_size + VLAN_TAG_SIZE + 1)))))
+
+#endif
index 8da9ffedc425ff1c8c250405f35520ab15db7bcd..c9b15ac7b369c1c08d624d8b43994e1cda08829f 100644 (file)
@@ -1,7 +1,7 @@
 /*******************************************************************************
 
   Intel(R) Gigabit Ethernet Linux driver
-  Copyright(c) 2007 Intel Corporation.
+  Copyright(c) 2007-2008 Intel Corporation.
 
   This program is free software; you can redistribute it and/or modify it
   under the terms and conditions of the GNU General Public License,
 
 /* Definitions for power management and wakeup registers */
 /* Wake Up Control */
+#define E1000_WUC_APME       0x00000001 /* APM Enable */
 #define E1000_WUC_PME_EN     0x00000002 /* PME Enable */
+#define E1000_WUC_PME_STATUS 0x00000004 /* PME Status */
+#define E1000_WUC_APMPME     0x00000008 /* Assert PME on APM Wakeup */
+#define E1000_WUC_LSCWE      0x00000010 /* Link Status wake up enable */
+#define E1000_WUC_LSCWO      0x00000020 /* Link Status wake up override */
+#define E1000_WUC_SPM        0x80000000 /* Enable SPM */
+#define E1000_WUC_PHY_WAKE   0x00000100 /* if PHY supports wakeup */
 
 /* Wake Up Filter Control */
 #define E1000_WUFC_LNKC 0x00000001 /* Link Status Change Wakeup Enable */
 #define E1000_WUFC_ARP  0x00000020 /* ARP Request Packet Wakeup Enable */
 #define E1000_WUFC_IPV4 0x00000040 /* Directed IPv4 Packet Wakeup Enable */
 #define E1000_WUFC_IPV6 0x00000080 /* Directed IPv6 Packet Wakeup Enable */
+#define E1000_WUFC_IGNORE_TCO   0x00008000 /* Ignore WakeOn TCO packets */
 #define E1000_WUFC_FLX0 0x00010000 /* Flexible Filter 0 Enable */
 #define E1000_WUFC_FLX1 0x00020000 /* Flexible Filter 1 Enable */
 #define E1000_WUFC_FLX2 0x00040000 /* Flexible Filter 2 Enable */
 #define E1000_WUFC_FLX3 0x00080000 /* Flexible Filter 3 Enable */
-#define E1000_WUFC_FLX_FILTERS 0x000F0000 /* Mask for the 4 flexible filters */
+#define E1000_WUFC_FLX4 0x00100000 /* Flexible Filter 4 Enable */
+#define E1000_WUFC_FLX5 0x00200000 /* Flexible Filter 5 Enable */
+#define E1000_WUFC_ALL_FILTERS  0x000F00FF /* Mask for all wakeup filters */
+#define E1000_WUFC_FLX_OFFSET   16 /* Offset to the Flexible Filters bits */
+#define E1000_WUFC_FLX_FILTERS  0x000F0000 /* Mask for the 4 flexible filters */
+/*
+ * For 82576 to utilize Extended filter masks in addition to
+ * existing (filter) masks
+ */
+#define E1000_WUFC_EXT_FLX_FILTERS      0x00300000 /* Ext. FLX filter mask */
 
 /* Wake Up Status */
+#define E1000_WUS_LNKC         E1000_WUFC_LNKC
+#define E1000_WUS_MAG          E1000_WUFC_MAG
+#define E1000_WUS_EX           E1000_WUFC_EX
+#define E1000_WUS_MC           E1000_WUFC_MC
+#define E1000_WUS_BC           E1000_WUFC_BC
+#define E1000_WUS_ARP          E1000_WUFC_ARP
+#define E1000_WUS_IPV4         E1000_WUFC_IPV4
+#define E1000_WUS_IPV6         E1000_WUFC_IPV6
+#define E1000_WUS_FLX0         E1000_WUFC_FLX0
+#define E1000_WUS_FLX1         E1000_WUFC_FLX1
+#define E1000_WUS_FLX2         E1000_WUFC_FLX2
+#define E1000_WUS_FLX3         E1000_WUFC_FLX3
+#define E1000_WUS_FLX_FILTERS  E1000_WUFC_FLX_FILTERS
 
 /* Wake Up Packet Length */
+#define E1000_WUPL_LENGTH_MASK 0x0FFF   /* Only the lower 12 bits are valid */
 
 /* Four Flexible Filters are supported */
 #define E1000_FLEXIBLE_FILTER_COUNT_MAX 4
+/* Two Extended Flexible Filters are supported (82576) */
+#define E1000_EXT_FLEXIBLE_FILTER_COUNT_MAX     2
+#define E1000_FHFT_LENGTH_OFFSET        0xFC /* Length byte in FHFT */
+#define E1000_FHFT_LENGTH_MASK          0x0FF /* Length in lower byte */
 
 /* Each Flexible Filter is at most 128 (0x80) bytes in length */
 #define E1000_FLEXIBLE_FILTER_SIZE_MAX  128
 
+#define E1000_FFLT_SIZE E1000_FLEXIBLE_FILTER_COUNT_MAX
+#define E1000_FFMT_SIZE E1000_FLEXIBLE_FILTER_SIZE_MAX
+#define E1000_FFVT_SIZE E1000_FLEXIBLE_FILTER_SIZE_MAX
 
 /* Extended Device Control */
+#define E1000_CTRL_EXT_GPI0_EN   0x00000001 /* Maps SDP4 to GPI0 */
 #define E1000_CTRL_EXT_GPI1_EN   0x00000002 /* Maps SDP5 to GPI1 */
-#define E1000_CTRL_EXT_SDP4_DATA 0x00000010 /* Value of SW Defineable Pin 4 */
-#define E1000_CTRL_EXT_SDP5_DATA 0x00000020 /* Value of SW Defineable Pin 5 */
-#define E1000_CTRL_EXT_SDP7_DATA 0x00000080 /* Value of SW Defineable Pin 7 */
+#define E1000_CTRL_EXT_PHYINT_EN E1000_CTRL_EXT_GPI1_EN
+#define E1000_CTRL_EXT_GPI2_EN   0x00000004 /* Maps SDP6 to GPI2 */
+#define E1000_CTRL_EXT_GPI3_EN   0x00000008 /* Maps SDP7 to GPI3 */
+/* Reserved (bits 4,5) in >= 82575 */
+#define E1000_CTRL_EXT_SDP4_DATA 0x00000010 /* Value of SW Definable Pin 4 */
+#define E1000_CTRL_EXT_SDP5_DATA 0x00000020 /* Value of SW Definable Pin 5 */
+#define E1000_CTRL_EXT_PHY_INT   E1000_CTRL_EXT_SDP5_DATA
+#define E1000_CTRL_EXT_SDP6_DATA 0x00000040 /* Value of SW Definable Pin 6 */
+#define E1000_CTRL_EXT_SDP7_DATA 0x00000080 /* Value of SW Definable Pin 7 */
+/* SDP 4/5 (bits 8,9) are reserved in >= 82575 */
 #define E1000_CTRL_EXT_SDP4_DIR  0x00000100 /* Direction of SDP4 0=in 1=out */
+#define E1000_CTRL_EXT_SDP5_DIR  0x00000200 /* Direction of SDP5 0=in 1=out */
+#define E1000_CTRL_EXT_SDP6_DIR  0x00000400 /* Direction of SDP6 0=in 1=out */
+#define E1000_CTRL_EXT_SDP7_DIR  0x00000800 /* Direction of SDP7 0=in 1=out */
+#define E1000_CTRL_EXT_ASDCHK    0x00001000 /* Initiate an ASD sequence */
 #define E1000_CTRL_EXT_EE_RST    0x00002000 /* Reinitialize from EEPROM */
+#define E1000_CTRL_EXT_IPS       0x00004000 /* Invert Power State */
+/* Physical Func Reset Done Indication */
+#define E1000_CTRL_EXT_PFRSTD    0x00004000
+#define E1000_CTRL_EXT_SPD_BYPS  0x00008000 /* Speed Select Bypass */
+#define E1000_CTRL_EXT_RO_DIS    0x00020000 /* Relaxed Ordering disable */
 #define E1000_CTRL_EXT_LINK_MODE_MASK 0x00C00000
+#define E1000_CTRL_EXT_LINK_MODE_GMII 0x00000000
+#define E1000_CTRL_EXT_LINK_MODE_TBI  0x00C00000
+#define E1000_CTRL_EXT_LINK_MODE_KMRN    0x00000000
 #define E1000_CTRL_EXT_LINK_MODE_PCIE_SERDES  0x00C00000
+#define E1000_CTRL_EXT_LINK_MODE_PCIX_SERDES  0x00800000
 #define E1000_CTRL_EXT_LINK_MODE_SGMII   0x00800000
 #define E1000_CTRL_EXT_EIAME          0x01000000
 #define E1000_CTRL_EXT_IRCA           0x00000001
-/* Interrupt delay cancellation */
-/* Driver loaded bit for FW */
-#define E1000_CTRL_EXT_DRV_LOAD       0x10000000
-/* Interrupt acknowledge Auto-mask */
-/* Clear Interrupt timers after IMS clear */
-/* packet buffer parity error detection enabled */
-/* descriptor FIFO parity error detection enable */
+#define E1000_CTRL_EXT_WR_WMARK_MASK  0x03000000
+#define E1000_CTRL_EXT_WR_WMARK_256   0x00000000
+#define E1000_CTRL_EXT_WR_WMARK_320   0x01000000
+#define E1000_CTRL_EXT_WR_WMARK_384   0x02000000
+#define E1000_CTRL_EXT_WR_WMARK_448   0x03000000
+#define E1000_CTRL_EXT_CANC           0x04000000 /* Interrupt delay cancellation */
+#define E1000_CTRL_EXT_DRV_LOAD       0x10000000 /* Driver loaded bit for FW */
+/* IAME enable bit (27) was removed in >= 82575 */
+#define E1000_CTRL_EXT_IAME           0x08000000 /* Interrupt acknowledge Auto-mask */
+#define E1000_CTRL_EXT_INT_TIMER_CLR  0x20000000 /* Clear Interrupt timers after IMS clear */
+#define E1000_CRTL_EXT_PB_PAREN       0x01000000 /* packet buffer parity error detection enabled */
+#define E1000_CTRL_EXT_DF_PAREN       0x02000000 /* descriptor FIFO parity error detection enable */
+#define E1000_CTRL_EXT_GHOST_PAREN    0x40000000
 #define E1000_CTRL_EXT_PBA_CLR        0x80000000 /* PBA Clear */
 #define E1000_I2CCMD_REG_ADDR_SHIFT   16
+#define E1000_I2CCMD_REG_ADDR         0x00FF0000
 #define E1000_I2CCMD_PHY_ADDR_SHIFT   24
+#define E1000_I2CCMD_PHY_ADDR         0x07000000
 #define E1000_I2CCMD_OPCODE_READ      0x08000000
 #define E1000_I2CCMD_OPCODE_WRITE     0x00000000
+#define E1000_I2CCMD_RESET            0x10000000
 #define E1000_I2CCMD_READY            0x20000000
+#define E1000_I2CCMD_INTERRUPT_ENA    0x40000000
 #define E1000_I2CCMD_ERROR            0x80000000
 #define E1000_MAX_SGMII_PHY_REG_ADDR  255
 #define E1000_I2CCMD_PHY_TIMEOUT      200
+#define E1000_IVAR_VALID        0x80
+#define E1000_GPIE_NSICR        0x00000001
+#define E1000_GPIE_MSIX_MODE    0x00000010
+#define E1000_GPIE_EIAME        0x40000000
+#define E1000_GPIE_PBA          0x80000000
 
-/* Receive Decriptor bit definitions */
+/* Receive Descriptor bit definitions */
 #define E1000_RXD_STAT_DD       0x01    /* Descriptor Done */
 #define E1000_RXD_STAT_EOP      0x02    /* End of Packet */
 #define E1000_RXD_STAT_IXSM     0x04    /* Ignore checksum */
 #define E1000_RXD_STAT_VP       0x08    /* IEEE VLAN Packet */
-#define E1000_RXD_STAT_UDPCS    0x10    /* UDP xsum caculated */
+#define E1000_RXD_STAT_UDPCS    0x10    /* UDP xsum calculated */
 #define E1000_RXD_STAT_TCPCS    0x20    /* TCP xsum calculated */
+#define E1000_RXD_STAT_IPCS     0x40    /* IP xsum calculated */
+#define E1000_RXD_STAT_PIF      0x80    /* passed in-exact filter */
+#define E1000_RXD_STAT_CRCV     0x100   /* Speculative CRC Valid */
+#define E1000_RXD_STAT_IPIDV    0x200   /* IP identification valid */
+#define E1000_RXD_STAT_UDPV     0x400   /* Valid UDP checksum */
 #define E1000_RXD_STAT_DYNINT   0x800   /* Pkt caused INT via DYNINT */
+#define E1000_RXD_STAT_ACK      0x8000  /* ACK Packet indication */
 #define E1000_RXD_ERR_CE        0x01    /* CRC Error */
 #define E1000_RXD_ERR_SE        0x02    /* Symbol Error */
 #define E1000_RXD_ERR_SEQ       0x04    /* Sequence Error */
 #define E1000_RXD_ERR_CXE       0x10    /* Carrier Extension Error */
+#define E1000_RXD_ERR_TCPE      0x20    /* TCP/UDP Checksum Error */
+#define E1000_RXD_ERR_IPE       0x40    /* IP Checksum Error */
 #define E1000_RXD_ERR_RXE       0x80    /* Rx Data Error */
 #define E1000_RXD_SPC_VLAN_MASK 0x0FFF  /* VLAN ID is in lower 12 bits */
+#define E1000_RXD_SPC_PRI_MASK  0xE000  /* Priority is in upper 3 bits */
+#define E1000_RXD_SPC_PRI_SHIFT 13
+#define E1000_RXD_SPC_CFI_MASK  0x1000  /* CFI is bit 12 */
+#define E1000_RXD_SPC_CFI_SHIFT 12
 
 #define E1000_RXDEXT_STATERR_CE    0x01000000
 #define E1000_RXDEXT_STATERR_SE    0x02000000
     E1000_RXDEXT_STATERR_CXE |            \
     E1000_RXDEXT_STATERR_RXE)
 
+#define E1000_MRQC_ENABLE_MASK                 0x00000007
+#define E1000_MRQC_ENABLE_RSS_2Q               0x00000001
+#define E1000_MRQC_ENABLE_RSS_INT              0x00000004
+#define E1000_MRQC_RSS_FIELD_MASK              0xFFFF0000
 #define E1000_MRQC_RSS_FIELD_IPV4_TCP          0x00010000
 #define E1000_MRQC_RSS_FIELD_IPV4              0x00020000
 #define E1000_MRQC_RSS_FIELD_IPV6_TCP_EX       0x00040000
+#define E1000_MRQC_RSS_FIELD_IPV6_EX           0x00080000
 #define E1000_MRQC_RSS_FIELD_IPV6              0x00100000
 #define E1000_MRQC_RSS_FIELD_IPV6_TCP          0x00200000
 
+#define E1000_RXDPS_HDRSTAT_HDRSP              0x00008000
+#define E1000_RXDPS_HDRSTAT_HDRLEN_MASK        0x000003FF
 
 /* Management Control */
 #define E1000_MANC_SMBUS_EN      0x00000001 /* SMBus Enabled - RO */
 #define E1000_MANC_ASF_EN        0x00000002 /* ASF Enabled - RO */
+#define E1000_MANC_R_ON_FORCE    0x00000004 /* Reset on Force TCO - RO */
+#define E1000_MANC_RMCP_EN       0x00000100 /* Enable RCMP 026Fh Filtering */
+#define E1000_MANC_0298_EN       0x00000200 /* Enable RCMP 0298h Filtering */
+#define E1000_MANC_IPV4_EN       0x00000400 /* Enable IPv4 */
+#define E1000_MANC_IPV6_EN       0x00000800 /* Enable IPv6 */
+#define E1000_MANC_SNAP_EN       0x00001000 /* Accept LLC/SNAP */
 #define E1000_MANC_ARP_EN        0x00002000 /* Enable ARP Request Filtering */
 /* Enable Neighbor Discovery Filtering */
+#define E1000_MANC_NEIGHBOR_EN   0x00004000
+#define E1000_MANC_ARP_RES_EN    0x00008000 /* Enable ARP response Filtering */
+#define E1000_MANC_TCO_RESET     0x00010000 /* TCO Reset Occurred */
 #define E1000_MANC_RCV_TCO_EN    0x00020000 /* Receive TCO Packets Enabled */
+#define E1000_MANC_REPORT_STATUS 0x00040000 /* Status Reporting Enabled */
+#define E1000_MANC_RCV_ALL       0x00080000 /* Receive All Enabled */
 #define E1000_MANC_BLK_PHY_RST_ON_IDE   0x00040000 /* Block phy resets */
 /* Enable MAC address filtering */
 #define E1000_MANC_EN_MAC_ADDR_FILTER   0x00100000
 /* Enable MNG packets to host memory */
 #define E1000_MANC_EN_MNG2HOST   0x00200000
 /* Enable IP address filtering */
-
+#define E1000_MANC_EN_IP_ADDR_FILTER    0x00400000
+#define E1000_MANC_EN_XSUM_FILTER   0x00800000 /* Enable checksum filtering */
+#define E1000_MANC_BR_EN            0x01000000 /* Enable broadcast filtering */
+#define E1000_MANC_SMB_REQ       0x01000000 /* SMBus Request */
+#define E1000_MANC_SMB_GNT       0x02000000 /* SMBus Grant */
+#define E1000_MANC_SMB_CLK_IN    0x04000000 /* SMBus Clock In */
+#define E1000_MANC_SMB_DATA_IN   0x08000000 /* SMBus Data In */
+#define E1000_MANC_SMB_DATA_OUT  0x10000000 /* SMBus Data Out */
+#define E1000_MANC_SMB_CLK_OUT   0x20000000 /* SMBus Clock Out */
+
+#define E1000_MANC_SMB_DATA_OUT_SHIFT  28 /* SMBus Data Out Shift */
+#define E1000_MANC_SMB_CLK_OUT_SHIFT   29 /* SMBus Clock Out Shift */
 
 /* Receive Control */
+#define E1000_RCTL_RST            0x00000001    /* Software reset */
 #define E1000_RCTL_EN             0x00000002    /* enable */
 #define E1000_RCTL_SBP            0x00000004    /* store bad packet */
 #define E1000_RCTL_UPE            0x00000008    /* unicast promiscuous enable */
 #define E1000_RCTL_LPE            0x00000020    /* long packet enable */
 #define E1000_RCTL_LBM_NO         0x00000000    /* no loopback mode */
 #define E1000_RCTL_LBM_MAC        0x00000040    /* MAC loopback mode */
+#define E1000_RCTL_LBM_SLP        0x00000080    /* serial link loopback mode */
 #define E1000_RCTL_LBM_TCVR       0x000000C0    /* tcvr loopback mode */
+#define E1000_RCTL_DTYP_MASK      0x00000C00    /* Descriptor type mask */
+#define E1000_RCTL_DTYP_PS        0x00000400    /* Packet Split descriptor */
 #define E1000_RCTL_RDMTS_HALF     0x00000000    /* rx desc min threshold size */
+#define E1000_RCTL_RDMTS_QUAT     0x00000100    /* rx desc min threshold size */
+#define E1000_RCTL_RDMTS_EIGTH    0x00000200    /* rx desc min threshold size */
 #define E1000_RCTL_MO_SHIFT       12            /* multicast offset shift */
+#define E1000_RCTL_MO_0           0x00000000    /* multicast offset 11:0 */
+#define E1000_RCTL_MO_1           0x00001000    /* multicast offset 12:1 */
+#define E1000_RCTL_MO_2           0x00002000    /* multicast offset 13:2 */
+#define E1000_RCTL_MO_3           0x00003000    /* multicast offset 15:4 */
+#define E1000_RCTL_MDR            0x00004000    /* multicast desc ring 0 */
 #define E1000_RCTL_BAM            0x00008000    /* broadcast enable */
 /* these buffer sizes are valid if E1000_RCTL_BSEX is 0 */
 #define E1000_RCTL_SZ_2048        0x00000000    /* rx buffer size 2048 */
 #define E1000_RCTL_SZ_4096        0x00030000    /* rx buffer size 4096 */
 #define E1000_RCTL_VFE            0x00040000    /* vlan filter enable */
 #define E1000_RCTL_CFIEN          0x00080000    /* canonical form enable */
+#define E1000_RCTL_CFI            0x00100000    /* canonical form indicator */
+#define E1000_RCTL_DPF            0x00400000    /* discard pause frames */
+#define E1000_RCTL_PMCF           0x00800000    /* pass MAC control frames */
 #define E1000_RCTL_BSEX           0x02000000    /* Buffer size extension */
 #define E1000_RCTL_SECRC          0x04000000    /* Strip Ethernet CRC */
+#define E1000_RCTL_FLXBUF_MASK    0x78000000    /* Flexible buffer size */
+#define E1000_RCTL_FLXBUF_SHIFT   27            /* Flexible buffer shift */
 
 /*
  * Use byte values for the following shift parameters
 #define E1000_SWFW_EEP_SM   0x1
 #define E1000_SWFW_PHY0_SM  0x2
 #define E1000_SWFW_PHY1_SM  0x4
+#define E1000_SWFW_CSR_SM   0x8
 
 /* FACTPS Definitions */
+#define E1000_FACTPS_LFS    0x40000000  /* LAN Function Select */
 /* Device Control */
 #define E1000_CTRL_FD       0x00000001  /* Full duplex.0=half; 1=full */
+#define E1000_CTRL_BEM      0x00000002  /* Endian Mode.0=little,1=big */
+#define E1000_CTRL_PRIOR    0x00000004  /* Priority on PCI. 0=rx,1=fair */
 #define E1000_CTRL_GIO_MASTER_DISABLE 0x00000004 /*Blocks new Master requests */
+#define E1000_CTRL_LRST     0x00000008  /* Link reset. 0=normal,1=reset */
+#define E1000_CTRL_TME      0x00000010  /* Test mode. 0=normal,1=test */
+#define E1000_CTRL_SLE      0x00000020  /* Serial Link on 0=dis,1=en */
 #define E1000_CTRL_ASDE     0x00000020  /* Auto-speed detect enable */
 #define E1000_CTRL_SLU      0x00000040  /* Set link up (Force Link) */
 #define E1000_CTRL_ILOS     0x00000080  /* Invert Loss-Of Signal */
 #define E1000_CTRL_SPD_SEL  0x00000300  /* Speed Select Mask */
+#define E1000_CTRL_SPD_10   0x00000000  /* Force 10Mb */
 #define E1000_CTRL_SPD_100  0x00000100  /* Force 100Mb */
 #define E1000_CTRL_SPD_1000 0x00000200  /* Force 1Gb */
+#define E1000_CTRL_BEM32    0x00000400  /* Big Endian 32 mode */
 #define E1000_CTRL_FRCSPD   0x00000800  /* Force Speed */
 #define E1000_CTRL_FRCDPX   0x00001000  /* Force Duplex */
-/* Defined polarity of Dock/Undock indication in SDP[0] */
-/* Reset both PHY ports, through PHYRST_N pin */
-/* enable link status from external LINK_0 and LINK_1 pins */
+#define E1000_CTRL_D_UD_EN  0x00002000  /* Dock/Undock enable */
+#define E1000_CTRL_D_UD_POLARITY 0x00004000 /* Defined polarity of Dock/Undock indication in SDP[0] */
+#define E1000_CTRL_FORCE_PHY_RESET 0x00008000 /* Reset both PHY ports, through PHYRST_N pin */
+#define E1000_CTRL_EXT_LINK_EN 0x00010000 /* enable link status from external LINK_0 and LINK_1 pins */
 #define E1000_CTRL_SWDPIN0  0x00040000  /* SWDPIN 0 value */
 #define E1000_CTRL_SWDPIN1  0x00080000  /* SWDPIN 1 value */
 #define E1000_CTRL_SWDPIN2  0x00100000  /* SWDPIN 2 value */
 #define E1000_CTRL_SWDPIN3  0x00200000  /* SWDPIN 3 value */
 #define E1000_CTRL_SWDPIO0  0x00400000  /* SWDPIN 0 Input or output */
+#define E1000_CTRL_SWDPIO1  0x00800000  /* SWDPIN 1 input or output */
 #define E1000_CTRL_SWDPIO2  0x01000000  /* SWDPIN 2 input or output */
 #define E1000_CTRL_SWDPIO3  0x02000000  /* SWDPIN 3 input or output */
 #define E1000_CTRL_RST      0x04000000  /* Global reset */
 #define E1000_CTRL_RFCE     0x08000000  /* Receive Flow Control enable */
 #define E1000_CTRL_TFCE     0x10000000  /* Transmit flow control enable */
+#define E1000_CTRL_RTE      0x20000000  /* Routing tag enable */
 #define E1000_CTRL_VME      0x40000000  /* IEEE VLAN mode enable */
 #define E1000_CTRL_PHY_RST  0x80000000  /* PHY Reset */
-/* Initiate an interrupt to manageability engine */
+#define E1000_CTRL_SW2FW_INT 0x02000000  /* Initiate an interrupt to manageability engine */
 #define E1000_CTRL_I2C_ENA  0x02000000  /* I2C enable */
 
-/* Bit definitions for the Management Data IO (MDIO) and Management Data
+/*
+ * Bit definitions for the Management Data IO (MDIO) and Management Data
  * Clock (MDC) pins in the Device Control Register.
  */
+#define E1000_CTRL_PHY_RESET_DIR  E1000_CTRL_SWDPIO0
+#define E1000_CTRL_PHY_RESET      E1000_CTRL_SWDPIN0
+#define E1000_CTRL_MDIO_DIR       E1000_CTRL_SWDPIO2
+#define E1000_CTRL_MDIO           E1000_CTRL_SWDPIN2
+#define E1000_CTRL_MDC_DIR        E1000_CTRL_SWDPIO3
+#define E1000_CTRL_MDC            E1000_CTRL_SWDPIN3
+#define E1000_CTRL_PHY_RESET_DIR4 E1000_CTRL_EXT_SDP4_DIR
+#define E1000_CTRL_PHY_RESET4     E1000_CTRL_EXT_SDP4_DATA
 
 #define E1000_CONNSW_ENRGSRC             0x4
+#define E1000_PCS_CFG_PCS_EN             8
 #define E1000_PCS_LCTL_FLV_LINK_UP       1
+#define E1000_PCS_LCTL_FSV_10            0
 #define E1000_PCS_LCTL_FSV_100           2
 #define E1000_PCS_LCTL_FSV_1000          4
 #define E1000_PCS_LCTL_FDV_FULL          8
 #define E1000_PCS_LCTL_FSD               0x10
 #define E1000_PCS_LCTL_FORCE_LINK        0x20
+#define E1000_PCS_LCTL_LOW_LINK_LATCH    0x40
+#define E1000_PCS_LCTL_FORCE_FCTRL       0x80
 #define E1000_PCS_LCTL_AN_ENABLE         0x10000
 #define E1000_PCS_LCTL_AN_RESTART        0x20000
 #define E1000_PCS_LCTL_AN_TIMEOUT        0x40000
+#define E1000_PCS_LCTL_AN_SGMII_BYPASS   0x80000
+#define E1000_PCS_LCTL_AN_SGMII_TRIGGER  0x100000
+#define E1000_PCS_LCTL_FAST_LINK_TIMER   0x1000000
+#define E1000_PCS_LCTL_LINK_OK_FIX       0x2000000
+#define E1000_PCS_LCTL_CRS_ON_NI         0x4000000
+#define E1000_ENABLE_SERDES_LOOPBACK     0x0410
 
 #define E1000_PCS_LSTS_LINK_OK           1
+#define E1000_PCS_LSTS_SPEED_10          0
 #define E1000_PCS_LSTS_SPEED_100         2
 #define E1000_PCS_LSTS_SPEED_1000        4
 #define E1000_PCS_LSTS_DUPLEX_FULL       8
 #define E1000_PCS_LSTS_SYNK_OK           0x10
+#define E1000_PCS_LSTS_AN_COMPLETE       0x10000
+#define E1000_PCS_LSTS_AN_PAGE_RX        0x20000
+#define E1000_PCS_LSTS_AN_TIMED_OUT      0x40000
+#define E1000_PCS_LSTS_AN_REMOTE_FAULT   0x80000
+#define E1000_PCS_LSTS_AN_ERROR_RWS      0x100000
 
 /* Device Status */
 #define E1000_STATUS_FD         0x00000001      /* Full duplex.0=half,1=full */
 #define E1000_STATUS_LU         0x00000002      /* Link up.0=no,1=link */
 #define E1000_STATUS_FUNC_MASK  0x0000000C      /* PCI Function Mask */
 #define E1000_STATUS_FUNC_SHIFT 2
+#define E1000_STATUS_FUNC_0     0x00000000      /* Function 0 */
 #define E1000_STATUS_FUNC_1     0x00000004      /* Function 1 */
 #define E1000_STATUS_TXOFF      0x00000010      /* transmission paused */
+#define E1000_STATUS_TBIMODE    0x00000020      /* TBI mode */
+#define E1000_STATUS_SPEED_MASK 0x000000C0
+#define E1000_STATUS_SPEED_10   0x00000000      /* Speed 10Mb/s */
 #define E1000_STATUS_SPEED_100  0x00000040      /* Speed 100Mb/s */
 #define E1000_STATUS_SPEED_1000 0x00000080      /* Speed 1000Mb/s */
-/* Change in Dock/Undock state. Clear on write '0'. */
-/* Status of Master requests. */
-#define E1000_STATUS_GIO_MASTER_ENABLE 0x00080000
-/* BMC external code execution disabled */
-
-/* Constants used to intrepret the masked PCI-X bus speed. */
+#define E1000_STATUS_LAN_INIT_DONE 0x00000200   /* Lan Init Completion by NVM */
+#define E1000_STATUS_ASDV       0x00000300      /* Auto speed detect value */
+#define E1000_STATUS_DOCK_CI    0x00000800      /* Change in Dock/Undock state. Clear on write '0'. */
+#define E1000_STATUS_GIO_MASTER_ENABLE 0x00080000 /* Status of Master requests. */
+#define E1000_STATUS_MTXCKOK    0x00000400      /* MTX clock running OK */
+#define E1000_STATUS_PCI66      0x00000800      /* In 66Mhz slot */
+#define E1000_STATUS_BUS64      0x00001000      /* In 64 bit slot */
+#define E1000_STATUS_PCIX_MODE  0x00002000      /* PCI-X mode */
+#define E1000_STATUS_PCIX_SPEED 0x0000C000      /* PCI-X bus speed */
+#define E1000_STATUS_BMC_SKU_0  0x00100000 /* BMC USB redirect disabled */
+#define E1000_STATUS_BMC_SKU_1  0x00200000 /* BMC SRAM disabled */
+#define E1000_STATUS_BMC_SKU_2  0x00400000 /* BMC SDRAM disabled */
+#define E1000_STATUS_BMC_CRYPTO 0x00800000 /* BMC crypto disabled */
+#define E1000_STATUS_BMC_LITE   0x01000000 /* BMC external code execution disabled */
+#define E1000_STATUS_RGMII_ENABLE 0x02000000 /* RGMII disabled */
+#define E1000_STATUS_FUSE_8       0x04000000
+#define E1000_STATUS_FUSE_9       0x08000000
+#define E1000_STATUS_SERDES0_DIS  0x10000000 /* SERDES disabled on port 0 */
+#define E1000_STATUS_SERDES1_DIS  0x20000000 /* SERDES disabled on port 1 */
+
+/* Constants used to interpret the masked PCI-X bus speed. */
+#define E1000_STATUS_PCIX_SPEED_66  0x00000000 /* PCI-X bus speed  50-66 MHz */
+#define E1000_STATUS_PCIX_SPEED_100 0x00004000 /* PCI-X bus speed  66-100 MHz */
+#define E1000_STATUS_PCIX_SPEED_133 0x00008000 /* PCI-X bus speed 100-133 MHz */
 
 #define SPEED_10    10
 #define SPEED_100   100
 #define HALF_DUPLEX 1
 #define FULL_DUPLEX 2
 
+#define PHY_FORCE_TIME   20
 
 #define ADVERTISE_10_HALF                 0x0001
 #define ADVERTISE_10_FULL                 0x0002
 #define ADVERTISE_1000_FULL               0x0020
 
 /* 1000/H is not supported, nor spec-compliant. */
-#define E1000_ALL_SPEED_DUPLEX (ADVERTISE_10_HALF  |  ADVERTISE_10_FULL | \
-                               ADVERTISE_100_HALF |  ADVERTISE_100_FULL | \
-                                                     ADVERTISE_1000_FULL)
-#define E1000_ALL_NOT_GIG      (ADVERTISE_10_HALF  |  ADVERTISE_10_FULL | \
-                               ADVERTISE_100_HALF |  ADVERTISE_100_FULL)
+#define E1000_ALL_SPEED_DUPLEX ( ADVERTISE_10_HALF |   ADVERTISE_10_FULL | \
+                                ADVERTISE_100_HALF |  ADVERTISE_100_FULL | \
+                                                     ADVERTISE_1000_FULL)
+#define E1000_ALL_NOT_GIG      ( ADVERTISE_10_HALF |   ADVERTISE_10_FULL | \
+                                ADVERTISE_100_HALF |  ADVERTISE_100_FULL)
 #define E1000_ALL_100_SPEED    (ADVERTISE_100_HALF |  ADVERTISE_100_FULL)
-#define E1000_ALL_10_SPEED     (ADVERTISE_10_HALF  |  ADVERTISE_10_FULL)
-#define E1000_ALL_FULL_DUPLEX  (ADVERTISE_10_FULL  |  ADVERTISE_100_FULL | \
-                                                     ADVERTISE_1000_FULL)
-#define E1000_ALL_HALF_DUPLEX  (ADVERTISE_10_HALF  |  ADVERTISE_100_HALF)
+#define E1000_ALL_10_SPEED      (ADVERTISE_10_HALF |   ADVERTISE_10_FULL)
+#define E1000_ALL_FULL_DUPLEX   (ADVERTISE_10_FULL |  ADVERTISE_100_FULL | \
+                                                     ADVERTISE_1000_FULL)
+#define E1000_ALL_HALF_DUPLEX   (ADVERTISE_10_HALF |  ADVERTISE_100_HALF)
 
 #define AUTONEG_ADVERTISE_SPEED_DEFAULT   E1000_ALL_SPEED_DUPLEX
 
 /* LED Control */
 #define E1000_LEDCTL_LED0_MODE_MASK       0x0000000F
 #define E1000_LEDCTL_LED0_MODE_SHIFT      0
+#define E1000_LEDCTL_LED0_BLINK_RATE      0x00000020
 #define E1000_LEDCTL_LED0_IVRT            0x00000040
 #define E1000_LEDCTL_LED0_BLINK           0x00000080
-
+#define E1000_LEDCTL_LED1_MODE_MASK       0x00000F00
+#define E1000_LEDCTL_LED1_MODE_SHIFT      8
+#define E1000_LEDCTL_LED1_BLINK_RATE      0x00002000
+#define E1000_LEDCTL_LED1_IVRT            0x00004000
+#define E1000_LEDCTL_LED1_BLINK           0x00008000
+#define E1000_LEDCTL_LED2_MODE_MASK       0x000F0000
+#define E1000_LEDCTL_LED2_MODE_SHIFT      16
+#define E1000_LEDCTL_LED2_BLINK_RATE      0x00200000
+#define E1000_LEDCTL_LED2_IVRT            0x00400000
+#define E1000_LEDCTL_LED2_BLINK           0x00800000
+#define E1000_LEDCTL_LED3_MODE_MASK       0x0F000000
+#define E1000_LEDCTL_LED3_MODE_SHIFT      24
+#define E1000_LEDCTL_LED3_BLINK_RATE      0x20000000
+#define E1000_LEDCTL_LED3_IVRT            0x40000000
+#define E1000_LEDCTL_LED3_BLINK           0x80000000
+
+#define E1000_LEDCTL_MODE_LINK_10_1000  0x0
+#define E1000_LEDCTL_MODE_LINK_100_1000 0x1
+#define E1000_LEDCTL_MODE_LINK_UP       0x2
+#define E1000_LEDCTL_MODE_ACTIVITY      0x3
+#define E1000_LEDCTL_MODE_LINK_ACTIVITY 0x4
+#define E1000_LEDCTL_MODE_LINK_10       0x5
+#define E1000_LEDCTL_MODE_LINK_100      0x6
+#define E1000_LEDCTL_MODE_LINK_1000     0x7
+#define E1000_LEDCTL_MODE_PCIX_MODE     0x8
+#define E1000_LEDCTL_MODE_FULL_DUPLEX   0x9
+#define E1000_LEDCTL_MODE_COLLISION     0xA
+#define E1000_LEDCTL_MODE_BUS_SPEED     0xB
+#define E1000_LEDCTL_MODE_BUS_SIZE      0xC
+#define E1000_LEDCTL_MODE_PAUSED        0xD
 #define E1000_LEDCTL_MODE_LED_ON        0xE
 #define E1000_LEDCTL_MODE_LED_OFF       0xF
 
 /* Transmit Descriptor bit definitions */
+#define E1000_TXD_DTYP_D     0x00100000 /* Data Descriptor */
+#define E1000_TXD_DTYP_C     0x00000000 /* Context Descriptor */
+#define E1000_TXD_POPTS_SHIFT 8         /* POPTS shift */
 #define E1000_TXD_POPTS_IXSM 0x01       /* Insert IP checksum */
 #define E1000_TXD_POPTS_TXSM 0x02       /* Insert TCP/UDP checksum */
 #define E1000_TXD_CMD_EOP    0x01000000 /* End of Packet */
 #define E1000_TXD_CMD_IFCS   0x02000000 /* Insert FCS (Ethernet CRC) */
+#define E1000_TXD_CMD_IC     0x04000000 /* Insert Checksum */
 #define E1000_TXD_CMD_RS     0x08000000 /* Report Status */
+#define E1000_TXD_CMD_RPS    0x10000000 /* Report Packet Sent */
 #define E1000_TXD_CMD_DEXT   0x20000000 /* Descriptor extension (0 = legacy) */
+#define E1000_TXD_CMD_VLE    0x40000000 /* Add VLAN tag */
+#define E1000_TXD_CMD_IDE    0x80000000 /* Enable Tidv register */
+#define E1000_TXD_STAT_DD    0x00000001 /* Descriptor Done */
+#define E1000_TXD_STAT_EC    0x00000002 /* Excess Collisions */
+#define E1000_TXD_STAT_LC    0x00000004 /* Late Collisions */
+#define E1000_TXD_STAT_TU    0x00000008 /* Transmit underrun */
+#define E1000_TXD_CMD_TCP    0x01000000 /* TCP packet */
+#define E1000_TXD_CMD_IP     0x02000000 /* IP packet */
+#define E1000_TXD_CMD_TSE    0x04000000 /* TCP Seg enable */
+#define E1000_TXD_STAT_TC    0x00000004 /* Tx Underrun */
 /* Extended desc bits for Linksec and timesync */
 
 /* Transmit Control */
+#define E1000_TCTL_RST    0x00000001    /* software reset */
 #define E1000_TCTL_EN     0x00000002    /* enable tx */
+#define E1000_TCTL_BCE    0x00000004    /* busy check enable */
 #define E1000_TCTL_PSP    0x00000008    /* pad short packets */
 #define E1000_TCTL_CT     0x00000ff0    /* collision threshold */
 #define E1000_TCTL_COLD   0x003ff000    /* collision distance */
+#define E1000_TCTL_SWXOFF 0x00400000    /* SW Xoff transmission */
+#define E1000_TCTL_PBE    0x00800000    /* Packet Burst Enable */
 #define E1000_TCTL_RTLC   0x01000000    /* Re-transmit on late collision */
+#define E1000_TCTL_NRTU   0x02000000    /* No Re-transmit on underrun */
+#define E1000_TCTL_MULR   0x10000000    /* Multiple request support */
 
 /* Transmit Arbitration Count */
+#define E1000_TARC0_ENABLE     0x00000400   /* Enable Tx Queue 0 */
 
 /* SerDes Control */
 #define E1000_SCTL_DISABLE_SERDES_LOOPBACK 0x0400
 
 /* Receive Checksum Control */
+#define E1000_RXCSUM_PCSS_MASK 0x000000FF   /* Packet Checksum Start */
+#define E1000_RXCSUM_IPOFL     0x00000100   /* IPv4 checksum offload */
 #define E1000_RXCSUM_TUOFL     0x00000200   /* TCP / UDP checksum offload */
+#define E1000_RXCSUM_IPV6OFL   0x00000400   /* IPv6 checksum offload */
+#define E1000_RXCSUM_CRCOFL    0x00000800   /* CRC32 offload enable */
 #define E1000_RXCSUM_IPPCSE    0x00001000   /* IP payload checksum enable */
 #define E1000_RXCSUM_PCSD      0x00002000   /* packet checksum disabled */
 
 /* Header split receive */
+#define E1000_RFCTL_ISCSI_DIS           0x00000001
+#define E1000_RFCTL_ISCSI_DWC_MASK      0x0000003E
+#define E1000_RFCTL_ISCSI_DWC_SHIFT     1
+#define E1000_RFCTL_NFSW_DIS            0x00000040
+#define E1000_RFCTL_NFSR_DIS            0x00000080
+#define E1000_RFCTL_NFS_VER_MASK        0x00000300
+#define E1000_RFCTL_NFS_VER_SHIFT       8
+#define E1000_RFCTL_IPV6_DIS            0x00000400
+#define E1000_RFCTL_IPV6_XSUM_DIS       0x00000800
+#define E1000_RFCTL_ACK_DIS             0x00001000
+#define E1000_RFCTL_ACKD_DIS            0x00002000
+#define E1000_RFCTL_IPFRSP_DIS          0x00004000
+#define E1000_RFCTL_EXTEN               0x00008000
+#define E1000_RFCTL_IPV6_EX_DIS         0x00010000
+#define E1000_RFCTL_NEW_IPV6_EXT_DIS    0x00020000
+#define E1000_RFCTL_LEF                 0x00040000
 
 /* Collision related configuration parameters */
 #define E1000_COLLISION_THRESHOLD       15
 #define E1000_COLLISION_DISTANCE        63
 #define E1000_COLD_SHIFT                12
 
+/* Default values for the transmit IPG register */
+#define DEFAULT_82543_TIPG_IPGT_FIBER  9
+#define DEFAULT_82543_TIPG_IPGT_COPPER 8
+
+#define E1000_TIPG_IPGT_MASK  0x000003FF
+#define E1000_TIPG_IPGR1_MASK 0x000FFC00
+#define E1000_TIPG_IPGR2_MASK 0x3FF00000
+
+#define DEFAULT_82543_TIPG_IPGR1 8
+#define E1000_TIPG_IPGR1_SHIFT  10
+
+#define DEFAULT_82543_TIPG_IPGR2 6
+#define DEFAULT_80003ES2LAN_TIPG_IPGR2 7
+#define E1000_TIPG_IPGR2_SHIFT  20
+
 /* Ethertype field values */
 #define ETHERNET_IEEE_VLAN_TYPE 0x8100  /* 802.3ac packet */
 
+#define ETHERNET_FCS_SIZE       4
 #define MAX_JUMBO_FRAME_SIZE    0x3F00
 
 /* Extended Configuration Control and Size */
+#define E1000_EXTCNF_CTRL_MDIO_SW_OWNERSHIP      0x00000020
+#define E1000_EXTCNF_CTRL_LCD_WRITE_ENABLE       0x00000001
+#define E1000_EXTCNF_CTRL_SWFLAG                 0x00000020
+#define E1000_EXTCNF_SIZE_EXT_PCIE_LENGTH_MASK   0x00FF0000
+#define E1000_EXTCNF_SIZE_EXT_PCIE_LENGTH_SHIFT          16
+#define E1000_EXTCNF_CTRL_EXT_CNF_POINTER_MASK   0x0FFF0000
+#define E1000_EXTCNF_CTRL_EXT_CNF_POINTER_SHIFT          16
+
+#define E1000_PHY_CTRL_SPD_EN             0x00000001
+#define E1000_PHY_CTRL_D0A_LPLU           0x00000002
+#define E1000_PHY_CTRL_NOND0A_LPLU        0x00000004
+#define E1000_PHY_CTRL_NOND0A_GBE_DISABLE 0x00000008
 #define E1000_PHY_CTRL_GBE_DISABLE        0x00000040
 
+#define E1000_KABGTXD_BGSQLBIAS           0x00050000
+
 /* PBA constants */
-#define E1000_PBA_16K 0x0010    /* 16KB, default TX allocation */
+#define E1000_PBA_6K  0x0006   /* 6KB */
+#define E1000_PBA_8K  0x0008    /* 8KB */
+#define E1000_PBA_12K 0x000C    /* 12KB */
+#define E1000_PBA_16K 0x0010    /* 16KB */
+#define E1000_PBA_20K 0x0014
+#define E1000_PBA_22K 0x0016
 #define E1000_PBA_24K 0x0018
+#define E1000_PBA_30K 0x001E
+#define E1000_PBA_32K 0x0020
 #define E1000_PBA_34K 0x0022
+#define E1000_PBA_38K 0x0026
+#define E1000_PBA_40K 0x0028
+#define E1000_PBA_48K 0x0030    /* 48KB */
+#define E1000_PBA_64K 0x0040    /* 64KB */
+
+#define E1000_PBS_16K E1000_PBA_16K
+#define E1000_PBS_24K E1000_PBA_24K
 
 #define IFS_MAX       80
 #define IFS_MIN       40
 /* SW Semaphore Register */
 #define E1000_SWSM_SMBI         0x00000001 /* Driver Semaphore bit */
 #define E1000_SWSM_SWESMBI      0x00000002 /* FW Semaphore bit */
+#define E1000_SWSM_WMNG         0x00000004 /* Wake MNG Clock */
+#define E1000_SWSM_DRV_LOAD     0x00000008 /* Driver Loaded Bit */
 
 /* Interrupt Cause Read */
 #define E1000_ICR_TXDW          0x00000001 /* Transmit desc written back */
 #define E1000_ICR_RXDMT0        0x00000010 /* rx desc min. threshold (0) */
 #define E1000_ICR_RXO           0x00000040 /* rx overrun */
 #define E1000_ICR_RXT0          0x00000080 /* rx timer intr (ring 0) */
+#define E1000_ICR_VMMB          0x00000100 /* VM MB event */
 #define E1000_ICR_MDAC          0x00000200 /* MDIO access complete */
-#define E1000_ICR_RXCFG         0x00000400 /* RX /c/ ordered set */
+#define E1000_ICR_RXCFG         0x00000400 /* Rx /c/ ordered set */
 #define E1000_ICR_GPI_EN0       0x00000800 /* GP Int 0 */
 #define E1000_ICR_GPI_EN1       0x00001000 /* GP Int 1 */
 #define E1000_ICR_GPI_EN2       0x00002000 /* GP Int 2 */
 #define E1000_ICR_ACK           0x00020000 /* Receive Ack frame */
 #define E1000_ICR_MNG           0x00040000 /* Manageability event */
 #define E1000_ICR_DOCK          0x00080000 /* Dock/Undock */
-/* If this bit asserted, the driver should claim the interrupt */
-#define E1000_ICR_INT_ASSERTED  0x80000000
-/* queue 0 Rx descriptor FIFO parity error */
-#define E1000_ICR_RXD_FIFO_PAR0 0x00100000
-/* queue 0 Tx descriptor FIFO parity error */
-#define E1000_ICR_TXD_FIFO_PAR0 0x00200000
-/* host arb read buffer parity error */
-#define E1000_ICR_HOST_ARB_PAR  0x00400000
+#define E1000_ICR_INT_ASSERTED  0x80000000 /* If this bit asserted, the driver should claim the interrupt */
+#define E1000_ICR_RXD_FIFO_PAR0 0x00100000 /* queue 0 Rx descriptor FIFO parity error */
+#define E1000_ICR_TXD_FIFO_PAR0 0x00200000 /* queue 0 Tx descriptor FIFO parity error */
+#define E1000_ICR_HOST_ARB_PAR  0x00400000 /* host arb read buffer parity error */
 #define E1000_ICR_PB_PAR        0x00800000 /* packet buffer parity error */
-/* queue 1 Rx descriptor FIFO parity error */
-#define E1000_ICR_RXD_FIFO_PAR1 0x01000000
-/* queue 1 Tx descriptor FIFO parity error */
-#define E1000_ICR_TXD_FIFO_PAR1 0x02000000
-/* FW changed the status of DISSW bit in the FWSM */
-#define E1000_ICR_DSW           0x00000020
-/* LAN connected device generates an interrupt */
-#define E1000_ICR_PHYINT        0x00001000
-#define E1000_ICR_EPRST         0x00100000 /* ME handware reset occurs */
+#define E1000_ICR_RXD_FIFO_PAR1 0x01000000 /* queue 1 Rx descriptor FIFO parity error */
+#define E1000_ICR_TXD_FIFO_PAR1 0x02000000 /* queue 1 Tx descriptor FIFO parity error */
+#define E1000_ICR_ALL_PARITY    0x03F00000 /* all parity error bits */
+#define E1000_ICR_DSW           0x00000020 /* FW changed the status of DISSW bit in the FWSM */
+#define E1000_ICR_PHYINT        0x00001000 /* LAN connected device generates an interrupt */
+#define E1000_ICR_EPRST         0x00100000 /* ME hardware reset occurs */
 
 /* Extended Interrupt Cause Read */
 #define E1000_EICR_RX_QUEUE0    0x00000001 /* Rx Queue 0 Interrupt */
 #define E1000_EICR_TCP_TIMER    0x40000000 /* TCP Timer */
 #define E1000_EICR_OTHER        0x80000000 /* Interrupt Cause Active */
 /* TCP Timer */
+#define E1000_TCPTIMER_KS       0x00000100 /* KickStart */
+#define E1000_TCPTIMER_COUNT_ENABLE       0x00000200 /* Count Enable */
+#define E1000_TCPTIMER_COUNT_FINISH       0x00000400 /* Count finish */
+#define E1000_TCPTIMER_LOOP     0x00000800 /* Loop */
+
+/*
+ * This defines the bits that are set in the Interrupt Mask
+ * Set/Read Register.  Each bit is documented below:
+ *   o RXDMT0 = Receive Descriptor Minimum Threshold hit (ring 0)
+ *   o RXSEQ  = Receive Sequence Error
+ */
+#define POLL_IMS_ENABLE_MASK ( \
+    E1000_IMS_RXDMT0 |    \
+    E1000_IMS_RXSEQ)
 
 /*
  * This defines the bits that are set in the Interrupt Mask
 
 /* Interrupt Mask Set */
 #define E1000_IMS_TXDW      E1000_ICR_TXDW      /* Transmit desc written back */
+#define E1000_IMS_TXQE      E1000_ICR_TXQE      /* Transmit Queue empty */
 #define E1000_IMS_LSC       E1000_ICR_LSC       /* Link Status Change */
+#define E1000_IMS_VMMB      E1000_ICR_VMMB      /* Mail box activity */
 #define E1000_IMS_RXSEQ     E1000_ICR_RXSEQ     /* rx sequence error */
 #define E1000_IMS_RXDMT0    E1000_ICR_RXDMT0    /* rx desc min. threshold */
+#define E1000_IMS_RXO       E1000_ICR_RXO       /* rx overrun */
 #define E1000_IMS_RXT0      E1000_ICR_RXT0      /* rx timer intr */
-/* queue 0 Rx descriptor FIFO parity error */
-/* queue 0 Tx descriptor FIFO parity error */
-/* host arb read buffer parity error */
-/* packet buffer parity error */
-/* queue 1 Rx descriptor FIFO parity error */
-/* queue 1 Tx descriptor FIFO parity error */
+#define E1000_IMS_MDAC      E1000_ICR_MDAC      /* MDIO access complete */
+#define E1000_IMS_RXCFG     E1000_ICR_RXCFG     /* Rx /c/ ordered set */
+#define E1000_IMS_GPI_EN0   E1000_ICR_GPI_EN0   /* GP Int 0 */
+#define E1000_IMS_GPI_EN1   E1000_ICR_GPI_EN1   /* GP Int 1 */
+#define E1000_IMS_GPI_EN2   E1000_ICR_GPI_EN2   /* GP Int 2 */
+#define E1000_IMS_GPI_EN3   E1000_ICR_GPI_EN3   /* GP Int 3 */
+#define E1000_IMS_TXD_LOW   E1000_ICR_TXD_LOW
+#define E1000_IMS_SRPD      E1000_ICR_SRPD
+#define E1000_IMS_ACK       E1000_ICR_ACK       /* Receive Ack frame */
+#define E1000_IMS_MNG       E1000_ICR_MNG       /* Manageability event */
+#define E1000_IMS_DOCK      E1000_ICR_DOCK      /* Dock/Undock */
+#define E1000_IMS_RXD_FIFO_PAR0 E1000_ICR_RXD_FIFO_PAR0 /* queue 0 Rx descriptor FIFO parity error */
+#define E1000_IMS_TXD_FIFO_PAR0 E1000_ICR_TXD_FIFO_PAR0 /* queue 0 Tx descriptor FIFO parity error */
+#define E1000_IMS_HOST_ARB_PAR  E1000_ICR_HOST_ARB_PAR  /* host arb read buffer parity error */
+#define E1000_IMS_PB_PAR        E1000_ICR_PB_PAR        /* packet buffer parity error */
+#define E1000_IMS_RXD_FIFO_PAR1 E1000_ICR_RXD_FIFO_PAR1 /* queue 1 Rx descriptor FIFO parity error */
+#define E1000_IMS_TXD_FIFO_PAR1 E1000_ICR_TXD_FIFO_PAR1 /* queue 1 Tx descriptor FIFO parity error */
+#define E1000_IMS_DSW       E1000_ICR_DSW
+#define E1000_IMS_PHYINT    E1000_ICR_PHYINT
+#define E1000_IMS_EPRST     E1000_ICR_EPRST
 
 /* Extended Interrupt Mask Set */
+#define E1000_EIMS_RX_QUEUE0    E1000_EICR_RX_QUEUE0 /* Rx Queue 0 Interrupt */
+#define E1000_EIMS_RX_QUEUE1    E1000_EICR_RX_QUEUE1 /* Rx Queue 1 Interrupt */
+#define E1000_EIMS_RX_QUEUE2    E1000_EICR_RX_QUEUE2 /* Rx Queue 2 Interrupt */
+#define E1000_EIMS_RX_QUEUE3    E1000_EICR_RX_QUEUE3 /* Rx Queue 3 Interrupt */
+#define E1000_EIMS_TX_QUEUE0    E1000_EICR_TX_QUEUE0 /* Tx Queue 0 Interrupt */
+#define E1000_EIMS_TX_QUEUE1    E1000_EICR_TX_QUEUE1 /* Tx Queue 1 Interrupt */
+#define E1000_EIMS_TX_QUEUE2    E1000_EICR_TX_QUEUE2 /* Tx Queue 2 Interrupt */
+#define E1000_EIMS_TX_QUEUE3    E1000_EICR_TX_QUEUE3 /* Tx Queue 3 Interrupt */
 #define E1000_EIMS_TCP_TIMER    E1000_EICR_TCP_TIMER /* TCP Timer */
 #define E1000_EIMS_OTHER        E1000_EICR_OTHER   /* Interrupt Cause Active */
 
 /* Interrupt Cause Set */
+#define E1000_ICS_TXDW      E1000_ICR_TXDW      /* Transmit desc written back */
+#define E1000_ICS_TXQE      E1000_ICR_TXQE      /* Transmit Queue empty */
 #define E1000_ICS_LSC       E1000_ICR_LSC       /* Link Status Change */
+#define E1000_ICS_RXSEQ     E1000_ICR_RXSEQ     /* rx sequence error */
 #define E1000_ICS_RXDMT0    E1000_ICR_RXDMT0    /* rx desc min. threshold */
-/* queue 0 Rx descriptor FIFO parity error */
-/* queue 0 Tx descriptor FIFO parity error */
-/* host arb read buffer parity error */
-/* packet buffer parity error */
-/* queue 1 Rx descriptor FIFO parity error */
-/* queue 1 Tx descriptor FIFO parity error */
+#define E1000_ICS_RXO       E1000_ICR_RXO       /* rx overrun */
+#define E1000_ICS_RXT0      E1000_ICR_RXT0      /* rx timer intr */
+#define E1000_ICS_MDAC      E1000_ICR_MDAC      /* MDIO access complete */
+#define E1000_ICS_RXCFG     E1000_ICR_RXCFG     /* Rx /c/ ordered set */
+#define E1000_ICS_GPI_EN0   E1000_ICR_GPI_EN0   /* GP Int 0 */
+#define E1000_ICS_GPI_EN1   E1000_ICR_GPI_EN1   /* GP Int 1 */
+#define E1000_ICS_GPI_EN2   E1000_ICR_GPI_EN2   /* GP Int 2 */
+#define E1000_ICS_GPI_EN3   E1000_ICR_GPI_EN3   /* GP Int 3 */
+#define E1000_ICS_TXD_LOW   E1000_ICR_TXD_LOW
+#define E1000_ICS_SRPD      E1000_ICR_SRPD
+#define E1000_ICS_ACK       E1000_ICR_ACK       /* Receive Ack frame */
+#define E1000_ICS_MNG       E1000_ICR_MNG       /* Manageability event */
+#define E1000_ICS_DOCK      E1000_ICR_DOCK      /* Dock/Undock */
+#define E1000_ICS_RXD_FIFO_PAR0 E1000_ICR_RXD_FIFO_PAR0 /* queue 0 Rx descriptor FIFO parity error */
+#define E1000_ICS_TXD_FIFO_PAR0 E1000_ICR_TXD_FIFO_PAR0 /* queue 0 Tx descriptor FIFO parity error */
+#define E1000_ICS_HOST_ARB_PAR  E1000_ICR_HOST_ARB_PAR  /* host arb read buffer parity error */
+#define E1000_ICS_PB_PAR        E1000_ICR_PB_PAR        /* packet buffer parity error */
+#define E1000_ICS_RXD_FIFO_PAR1 E1000_ICR_RXD_FIFO_PAR1 /* queue 1 Rx descriptor FIFO parity error */
+#define E1000_ICS_TXD_FIFO_PAR1 E1000_ICR_TXD_FIFO_PAR1 /* queue 1 Tx descriptor FIFO parity error */
+#define E1000_ICS_DSW       E1000_ICR_DSW
+#define E1000_ICS_PHYINT    E1000_ICR_PHYINT
+#define E1000_ICS_EPRST     E1000_ICR_EPRST
 
 /* Extended Interrupt Cause Set */
+#define E1000_EICS_RX_QUEUE0    E1000_EICR_RX_QUEUE0 /* Rx Queue 0 Interrupt */
+#define E1000_EICS_RX_QUEUE1    E1000_EICR_RX_QUEUE1 /* Rx Queue 1 Interrupt */
+#define E1000_EICS_RX_QUEUE2    E1000_EICR_RX_QUEUE2 /* Rx Queue 2 Interrupt */
+#define E1000_EICS_RX_QUEUE3    E1000_EICR_RX_QUEUE3 /* Rx Queue 3 Interrupt */
+#define E1000_EICS_TX_QUEUE0    E1000_EICR_TX_QUEUE0 /* Tx Queue 0 Interrupt */
+#define E1000_EICS_TX_QUEUE1    E1000_EICR_TX_QUEUE1 /* Tx Queue 1 Interrupt */
+#define E1000_EICS_TX_QUEUE2    E1000_EICR_TX_QUEUE2 /* Tx Queue 2 Interrupt */
+#define E1000_EICS_TX_QUEUE3    E1000_EICR_TX_QUEUE3 /* Tx Queue 3 Interrupt */
+#define E1000_EICS_TCP_TIMER    E1000_EICR_TCP_TIMER /* TCP Timer */
+#define E1000_EICS_OTHER        E1000_EICR_OTHER   /* Interrupt Cause Active */
 
 /* Transmit Descriptor Control */
+#define E1000_TXDCTL_PTHRESH 0x0000003F /* TXDCTL Prefetch Threshold */
+#define E1000_TXDCTL_HTHRESH 0x00003F00 /* TXDCTL Host Threshold */
+#define E1000_TXDCTL_WTHRESH 0x003F0000 /* TXDCTL Writeback Threshold */
+#define E1000_TXDCTL_GRAN    0x01000000 /* TXDCTL Granularity */
+#define E1000_TXDCTL_LWTHRESH 0xFE000000 /* TXDCTL Low Threshold */
+#define E1000_TXDCTL_FULL_TX_DESC_WB 0x01010000 /* GRAN=1, WTHRESH=1 */
+#define E1000_TXDCTL_MAX_TX_DESC_PREFETCH 0x0100001F /* GRAN=1, PTHRESH=31 */
 /* Enable the counting of descriptors still to be processed. */
+#define E1000_TXDCTL_COUNT_DESC 0x00400000
 
 /* Flow Control Constants */
 #define FLOW_CONTROL_ADDRESS_LOW  0x00C28001
  * (RAR[15]) for our directed address used by controllers with
  * manageability enabled, allowing us room for 15 multicast addresses.
  */
+#define E1000_RAR_ENTRIES     15
 #define E1000_RAH_AV  0x80000000        /* Receive descriptor valid */
 
 /* Error Codes */
+#define E1000_SUCCESS      0
 #define E1000_ERR_NVM      1
 #define E1000_ERR_PHY      2
 #define E1000_ERR_CONFIG   3
 #define E1000_ERR_PARAM    4
 #define E1000_ERR_MAC_INIT 5
+#define E1000_ERR_PHY_TYPE 6
 #define E1000_ERR_RESET   9
 #define E1000_ERR_MASTER_REQUESTS_PENDING 10
 #define E1000_ERR_HOST_INTERFACE_COMMAND 11
 #define E1000_NOT_IMPLEMENTED 14
 
 /* Loop limit on how long we wait for auto-negotiation to complete */
+#define FIBER_LINK_UP_LIMIT               50
 #define COPPER_LINK_UP_LIMIT              10
 #define PHY_AUTO_NEG_LIMIT                45
 #define PHY_FORCE_LIMIT                   20
 /* Number of milliseconds we wait for PHY configuration done after MAC reset */
 #define PHY_CFG_TIMEOUT             100
 /* Number of 2 milliseconds we wait for acquiring MDIO ownership. */
+#define MDIO_OWNERSHIP_TIMEOUT      10
 /* Number of milliseconds for NVM auto read done after MAC reset. */
 #define AUTO_READ_DONE_TIMEOUT      10
 
 /* Flow Control */
+#define E1000_FCRTH_RTH  0x0000FFF8     /* Mask Bits[15:3] for RTH */
+#define E1000_FCRTH_XFCE 0x80000000     /* External Flow Control Enable */
+#define E1000_FCRTL_RTL  0x0000FFF8     /* Mask Bits[15:3] for RTL */
 #define E1000_FCRTL_XONE 0x80000000     /* Enable XON frame transmission */
 
 /* Transmit Configuration Word */
+#define E1000_TXCW_FD         0x00000020        /* TXCW full duplex */
+#define E1000_TXCW_HD         0x00000040        /* TXCW half duplex */
+#define E1000_TXCW_PAUSE      0x00000080        /* TXCW sym pause request */
+#define E1000_TXCW_ASM_DIR    0x00000100        /* TXCW astm pause direction */
+#define E1000_TXCW_PAUSE_MASK 0x00000180        /* TXCW pause request mask */
+#define E1000_TXCW_RF         0x00003000        /* TXCW remote fault */
+#define E1000_TXCW_NP         0x00008000        /* TXCW next page */
+#define E1000_TXCW_CW         0x0000ffff        /* TxConfigWord mask */
+#define E1000_TXCW_TXC        0x40000000        /* Transmit Config control */
 #define E1000_TXCW_ANE        0x80000000        /* Auto-neg enable */
 
 /* Receive Configuration Word */
+#define E1000_RXCW_CW         0x0000ffff        /* RxConfigWord mask */
+#define E1000_RXCW_NC         0x04000000        /* Receive config no carrier */
+#define E1000_RXCW_IV         0x08000000        /* Receive config invalid */
+#define E1000_RXCW_CC         0x10000000        /* Receive config change */
+#define E1000_RXCW_C          0x20000000        /* Receive config */
+#define E1000_RXCW_SYNCH      0x40000000        /* Receive config synch */
+#define E1000_RXCW_ANC        0x80000000        /* Auto-neg complete */
 
 /* PCI Express Control */
 #define E1000_GCR_RXD_NO_SNOOP          0x00000001
 #define E1000_GCR_TXDSCR_NO_SNOOP       0x00000020
 
 #define PCIE_NO_SNOOP_ALL (E1000_GCR_RXD_NO_SNOOP         | \
-                          E1000_GCR_RXDSCW_NO_SNOOP      | \
-                          E1000_GCR_RXDSCR_NO_SNOOP      | \
-                          E1000_GCR_TXD_NO_SNOOP         | \
-                          E1000_GCR_TXDSCW_NO_SNOOP      | \
-                          E1000_GCR_TXDSCR_NO_SNOOP)
+                           E1000_GCR_RXDSCW_NO_SNOOP      | \
+                           E1000_GCR_RXDSCR_NO_SNOOP      | \
+                           E1000_GCR_TXD_NO_SNOOP         | \
+                           E1000_GCR_TXDSCW_NO_SNOOP      | \
+                           E1000_GCR_TXDSCR_NO_SNOOP)
 
 /* PHY Control Register */
+#define MII_CR_SPEED_SELECT_MSB 0x0040  /* bits 6,13: 10=1000, 01=100, 00=10 */
+#define MII_CR_COLL_TEST_ENABLE 0x0080  /* Collision test enable */
 #define MII_CR_FULL_DUPLEX      0x0100  /* FDX =1, half duplex =0 */
 #define MII_CR_RESTART_AUTO_NEG 0x0200  /* Restart auto negotiation */
+#define MII_CR_ISOLATE          0x0400  /* Isolate PHY from MII */
+#define MII_CR_POWER_DOWN       0x0800  /* Power down */
 #define MII_CR_AUTO_NEG_EN      0x1000  /* Auto Neg Enable */
+#define MII_CR_SPEED_SELECT_LSB 0x2000  /* bits 6,13: 10=1000, 01=100, 00=10 */
 #define MII_CR_LOOPBACK         0x4000  /* 0 = normal, 1 = loopback */
 #define MII_CR_RESET            0x8000  /* 0 = normal, 1 = PHY reset */
 #define MII_CR_SPEED_1000       0x0040
 #define MII_CR_SPEED_10         0x0000
 
 /* PHY Status Register */
+#define MII_SR_EXTENDED_CAPS     0x0001 /* Extended register capabilities */
+#define MII_SR_JABBER_DETECT     0x0002 /* Jabber Detected */
 #define MII_SR_LINK_STATUS       0x0004 /* Link Status 1 = link */
+#define MII_SR_AUTONEG_CAPS      0x0008 /* Auto Neg Capable */
+#define MII_SR_REMOTE_FAULT      0x0010 /* Remote Fault Detect */
 #define MII_SR_AUTONEG_COMPLETE  0x0020 /* Auto Neg Complete */
+#define MII_SR_PREAMBLE_SUPPRESS 0x0040 /* Preamble may be suppressed */
+#define MII_SR_EXTENDED_STATUS   0x0100 /* Ext. status info in Reg 0x0F */
+#define MII_SR_100T2_HD_CAPS     0x0200 /* 100T2 Half Duplex Capable */
+#define MII_SR_100T2_FD_CAPS     0x0400 /* 100T2 Full Duplex Capable */
+#define MII_SR_10T_HD_CAPS       0x0800 /* 10T   Half Duplex Capable */
+#define MII_SR_10T_FD_CAPS       0x1000 /* 10T   Full Duplex Capable */
+#define MII_SR_100X_HD_CAPS      0x2000 /* 100X  Half Duplex Capable */
+#define MII_SR_100X_FD_CAPS      0x4000 /* 100X  Full Duplex Capable */
+#define MII_SR_100T4_CAPS        0x8000 /* 100T4 Capable */
 
 /* Autoneg Advertisement Register */
+#define NWAY_AR_SELECTOR_FIELD   0x0001   /* indicates IEEE 802.3 CSMA/CD */
 #define NWAY_AR_10T_HD_CAPS      0x0020   /* 10T   Half Duplex Capable */
 #define NWAY_AR_10T_FD_CAPS      0x0040   /* 10T   Full Duplex Capable */
 #define NWAY_AR_100TX_HD_CAPS    0x0080   /* 100TX Half Duplex Capable */
 #define NWAY_AR_100TX_FD_CAPS    0x0100   /* 100TX Full Duplex Capable */
+#define NWAY_AR_100T4_CAPS       0x0200   /* 100T4 Capable */
 #define NWAY_AR_PAUSE            0x0400   /* Pause operation desired */
 #define NWAY_AR_ASM_DIR          0x0800   /* Asymmetric Pause Direction bit */
+#define NWAY_AR_REMOTE_FAULT     0x2000   /* Remote Fault detected */
+#define NWAY_AR_NEXT_PAGE        0x8000   /* Next Page ability supported */
 
 /* Link Partner Ability Register (Base Page) */
+#define NWAY_LPAR_SELECTOR_FIELD 0x0000 /* LP protocol selector field */
+#define NWAY_LPAR_10T_HD_CAPS    0x0020 /* LP is 10T   Half Duplex Capable */
+#define NWAY_LPAR_10T_FD_CAPS    0x0040 /* LP is 10T   Full Duplex Capable */
+#define NWAY_LPAR_100TX_HD_CAPS  0x0080 /* LP is 100TX Half Duplex Capable */
+#define NWAY_LPAR_100TX_FD_CAPS  0x0100 /* LP is 100TX Full Duplex Capable */
+#define NWAY_LPAR_100T4_CAPS     0x0200 /* LP is 100T4 Capable */
 #define NWAY_LPAR_PAUSE          0x0400 /* LP Pause operation desired */
 #define NWAY_LPAR_ASM_DIR        0x0800 /* LP Asymmetric Pause Direction bit */
+#define NWAY_LPAR_REMOTE_FAULT   0x2000 /* LP has detected Remote Fault */
+#define NWAY_LPAR_ACKNOWLEDGE    0x4000 /* LP has rx'd link code word */
+#define NWAY_LPAR_NEXT_PAGE      0x8000 /* Next Page ability supported */
 
 /* Autoneg Expansion Register */
+#define NWAY_ER_LP_NWAY_CAPS      0x0001 /* LP has Auto Neg Capability */
+#define NWAY_ER_PAGE_RXD          0x0002 /* LP is 10T   Half Duplex Capable */
+#define NWAY_ER_NEXT_PAGE_CAPS    0x0004 /* LP is 10T   Full Duplex Capable */
+#define NWAY_ER_LP_NEXT_PAGE_CAPS 0x0008 /* LP is 100TX Half Duplex Capable */
+#define NWAY_ER_PAR_DETECT_FAULT  0x0010 /* LP is 100TX Full Duplex Capable */
 
 /* 1000BASE-T Control Register */
+#define CR_1000T_ASYM_PAUSE      0x0080 /* Advertise asymmetric pause bit */
 #define CR_1000T_HD_CAPS         0x0100 /* Advertise 1000T HD capability */
 #define CR_1000T_FD_CAPS         0x0200 /* Advertise 1000T FD capability  */
-                                       /* 0=DTE device */
+#define CR_1000T_REPEATER_DTE    0x0400 /* 1=Repeater/switch device port */
+                                        /* 0=DTE device */
 #define CR_1000T_MS_VALUE        0x0800 /* 1=Configure PHY as Master */
-                                       /* 0=Configure PHY as Slave */
+                                        /* 0=Configure PHY as Slave */
 #define CR_1000T_MS_ENABLE       0x1000 /* 1=Master/Slave manual config value */
-                                       /* 0=Automatic Master/Slave config */
+                                        /* 0=Automatic Master/Slave config */
+#define CR_1000T_TEST_MODE_NORMAL 0x0000 /* Normal Operation */
+#define CR_1000T_TEST_MODE_1     0x2000 /* Transmit Waveform test */
+#define CR_1000T_TEST_MODE_2     0x4000 /* Master Transmit Jitter test */
+#define CR_1000T_TEST_MODE_3     0x6000 /* Slave Transmit Jitter test */
+#define CR_1000T_TEST_MODE_4     0x8000 /* Transmitter Distortion test */
 
 /* 1000BASE-T Status Register */
+#define SR_1000T_IDLE_ERROR_CNT   0x00FF /* Num idle errors since last read */
+#define SR_1000T_ASYM_PAUSE_DIR   0x0100 /* LP asymmetric pause direction bit */
+#define SR_1000T_LP_HD_CAPS       0x0400 /* LP is 1000T HD capable */
+#define SR_1000T_LP_FD_CAPS       0x0800 /* LP is 1000T FD capable */
 #define SR_1000T_REMOTE_RX_STATUS 0x1000 /* Remote receiver OK */
 #define SR_1000T_LOCAL_RX_STATUS  0x2000 /* Local receiver OK */
+#define SR_1000T_MS_CONFIG_RES    0x4000 /* 1=Local Tx is Master, 0=Slave */
+#define SR_1000T_MS_CONFIG_FAULT  0x8000 /* Master/Slave config fault */
 
+#define SR_1000T_PHY_EXCESSIVE_IDLE_ERR_COUNT 5
 
 /* PHY 1000 MII Register/Bit Definitions */
 /* PHY Registers defined by IEEE */
 #define PHY_CONTROL      0x00 /* Control Register */
-#define PHY_STATUS       0x01 /* Status Regiser */
+#define PHY_STATUS       0x01 /* Status Register */
 #define PHY_ID1          0x02 /* Phy Id Reg (word 1) */
 #define PHY_ID2          0x03 /* Phy Id Reg (word 2) */
 #define PHY_AUTONEG_ADV  0x04 /* Autoneg Advertisement */
 #define PHY_LP_ABILITY   0x05 /* Link Partner Ability (Base Page) */
+#define PHY_AUTONEG_EXP  0x06 /* Autoneg Expansion Reg */
+#define PHY_NEXT_PAGE_TX 0x07 /* Next Page Tx */
+#define PHY_LP_NEXT_PAGE 0x08 /* Link Partner Next Page */
 #define PHY_1000T_CTRL   0x09 /* 1000Base-T Control Reg */
 #define PHY_1000T_STATUS 0x0A /* 1000Base-T Status Reg */
+#define PHY_EXT_STATUS   0x0F /* Extended Status Reg */
 
 /* NVM Control */
 #define E1000_EECD_SK        0x00000001 /* NVM Clock */
 #define E1000_EECD_CS        0x00000002 /* NVM Chip Select */
 #define E1000_EECD_DI        0x00000004 /* NVM Data In */
 #define E1000_EECD_DO        0x00000008 /* NVM Data Out */
+#define E1000_EECD_FWE_MASK  0x00000030
+#define E1000_EECD_FWE_DIS   0x00000010 /* Disable FLASH writes */
+#define E1000_EECD_FWE_EN    0x00000020 /* Enable FLASH writes */
+#define E1000_EECD_FWE_SHIFT 4
 #define E1000_EECD_REQ       0x00000040 /* NVM Access Request */
 #define E1000_EECD_GNT       0x00000080 /* NVM Access Grant */
 #define E1000_EECD_PRES      0x00000100 /* NVM Present */
+#define E1000_EECD_SIZE      0x00000200 /* NVM Size (0=64 word 1=256 word) */
 /* NVM Addressing bits based on type 0=small, 1=large */
 #define E1000_EECD_ADDR_BITS 0x00000400
+#define E1000_EECD_TYPE      0x00002000 /* NVM Type (1-SPI, 0-Microwire) */
 #define E1000_NVM_GRANT_ATTEMPTS   1000 /* NVM # attempts to gain grant */
 #define E1000_EECD_AUTO_RD          0x00000200  /* NVM Auto Read done */
 #define E1000_EECD_SIZE_EX_MASK     0x00007800  /* NVM Size */
 #define E1000_EECD_SIZE_EX_SHIFT     11
-
-/* Offset to data in NVM read/write registers */
-#define E1000_NVM_RW_REG_DATA   16
+#define E1000_EECD_NVADDS    0x00018000 /* NVM Address Size */
+#define E1000_EECD_SELSHAD   0x00020000 /* Select Shadow RAM */
+#define E1000_EECD_INITSRAM  0x00040000 /* Initialize Shadow RAM */
+#define E1000_EECD_FLUPD     0x00080000 /* Update FLASH */
+#define E1000_EECD_AUPDEN    0x00100000 /* Enable Autonomous FLASH update */
+#define E1000_EECD_SHADV     0x00200000 /* Shadow RAM Data Valid */
+#define E1000_EECD_SEC1VAL   0x00400000 /* Sector One Valid */
+#define E1000_EECD_SECVAL_SHIFT      22
+
+#define E1000_NVM_SWDPIN0   0x0001   /* SWDPIN 0 NVM Value */
+#define E1000_NVM_LED_LOGIC 0x0020   /* Led Logic Word */
+#define E1000_NVM_RW_REG_DATA   16   /* Offset to data in NVM read/write registers */
 #define E1000_NVM_RW_REG_DONE   2    /* Offset to READ/WRITE done bit */
 #define E1000_NVM_RW_REG_START  1    /* Start operation */
 #define E1000_NVM_RW_ADDR_SHIFT 2    /* Shift to the address bits */
+#define E1000_NVM_POLL_WRITE    1    /* Flag for polling for write complete */
 #define E1000_NVM_POLL_READ     0    /* Flag for polling for read complete */
+#define E1000_FLASH_UPDATES  2000
 
 /* NVM Word Offsets */
+#define NVM_COMPAT                 0x0003
 #define NVM_ID_LED_SETTINGS        0x0004
-/* For SERDES output amplitude adjustment. */
+#define NVM_VERSION                0x0005
+#define NVM_SERDES_AMPLITUDE       0x0006 /* For SERDES output amplitude adjustment. */
+#define NVM_PHY_CLASS_WORD         0x0007
+#define NVM_INIT_CONTROL1_REG      0x000A
 #define NVM_INIT_CONTROL2_REG      0x000F
+#define NVM_SWDEF_PINS_CTRL_PORT_1 0x0010
+#define NVM_INIT_CONTROL3_PORT_B   0x0014
+#define NVM_INIT_3GIO_3            0x001A
+#define NVM_SWDEF_PINS_CTRL_PORT_0 0x0020
 #define NVM_INIT_CONTROL3_PORT_A   0x0024
+#define NVM_CFG                    0x0012
+#define NVM_FLASH_VERSION          0x0032
 #define NVM_ALT_MAC_ADDR_PTR       0x0037
 #define NVM_CHECKSUM_REG           0x003F
 
 
 /* Mask bits for fields in Word 0x0f of the NVM */
 #define NVM_WORD0F_PAUSE_MASK       0x3000
+#define NVM_WORD0F_PAUSE            0x1000
 #define NVM_WORD0F_ASM_DIR          0x2000
+#define NVM_WORD0F_ANE              0x0800
+#define NVM_WORD0F_SWPDIO_EXT_MASK  0x00F0
+#define NVM_WORD0F_LPLU             0x0001
 
 /* Mask bits for fields in Word 0x1a of the NVM */
+#define NVM_WORD1A_ASPM_MASK  0x000C
 
 /* For checksumming, the sum of all words in the NVM should equal 0xBABA. */
 #define NVM_SUM                    0xBABA
 
+#define NVM_MAC_ADDR_OFFSET        0
 #define NVM_PBA_OFFSET_0           8
 #define NVM_PBA_OFFSET_1           9
+#define NVM_RESERVED_WORD          0xFFFF
+#define NVM_PHY_CLASS_A            0x8000
+#define NVM_SERDES_AMPLITUDE_MASK  0x000F
+#define NVM_SIZE_MASK              0x1C00
+#define NVM_SIZE_SHIFT             10
 #define NVM_WORD_SIZE_BASE_SHIFT   6
-
-/* NVM Commands - Microwire */
+#define NVM_SWDPIO_EXT_SHIFT       4
 
 /* NVM Commands - SPI */
 #define NVM_MAX_RETRY_SPI          5000 /* Max wait of 5ms, for RDY signal */
+#define NVM_READ_OPCODE_SPI        0x03 /* NVM read opcode */
 #define NVM_WRITE_OPCODE_SPI       0x02 /* NVM write opcode */
 #define NVM_A8_OPCODE_SPI          0x08 /* opcode bit-3 = address bit-8 */
 #define NVM_WREN_OPCODE_SPI        0x06 /* NVM set Write Enable latch */
+#define NVM_WRDI_OPCODE_SPI        0x04 /* NVM reset Write Enable latch */
 #define NVM_RDSR_OPCODE_SPI        0x05 /* NVM read Status register */
+#define NVM_WRSR_OPCODE_SPI        0x01 /* NVM write Status register */
 
 /* SPI NVM Status Register */
 #define NVM_STATUS_RDY_SPI         0x01
+#define NVM_STATUS_WEN_SPI         0x02
+#define NVM_STATUS_BP0_SPI         0x04
+#define NVM_STATUS_BP1_SPI         0x08
+#define NVM_STATUS_WPEN_SPI        0x80
 
 /* Word definitions for ID LED Settings */
 #define ID_LED_RESERVED_0000 0x0000
 #define ID_LED_RESERVED_FFFF 0xFFFF
 #define ID_LED_DEFAULT       ((ID_LED_OFF1_ON2  << 12) | \
-                             (ID_LED_OFF1_OFF2 <<  8) | \
-                             (ID_LED_DEF1_DEF2 <<  4) | \
-                             (ID_LED_DEF1_DEF2))
+                              (ID_LED_OFF1_OFF2 <<  8) | \
+                              (ID_LED_DEF1_DEF2 <<  4) | \
+                              (ID_LED_DEF1_DEF2))
 #define ID_LED_DEF1_DEF2     0x1
 #define ID_LED_DEF1_ON2      0x2
 #define ID_LED_DEF1_OFF2     0x3
 #define PCIE_LINK_WIDTH_MASK         0x3F0
 #define PCIE_LINK_WIDTH_SHIFT        4
 
+#ifndef ETH_ADDR_LEN
+#define ETH_ADDR_LEN                 6
+#endif
+
 #define PHY_REVISION_MASK      0xFFFFFFF0
 #define MAX_PHY_REG_ADDRESS    0x1F  /* 5 bit address bus (0-0x1F) */
 #define MAX_PHY_MULTI_PAGE_REG 0xF
  * I = Integrated
  * E = External
  */
+#define M88E1000_E_PHY_ID    0x01410C50
+#define M88E1000_I_PHY_ID    0x01410C30
+#define M88E1011_I_PHY_ID    0x01410C20
+#define IGP01E1000_I_PHY_ID  0x02A80380
+#define M88E1011_I_REV_4     0x04
 #define M88E1111_I_PHY_ID    0x01410CC0
+#define GG82563_E_PHY_ID     0x01410CA0
 #define IGP03E1000_E_PHY_ID  0x02A80390
+#define IFE_E_PHY_ID         0x02A80330
+#define IFE_PLUS_E_PHY_ID    0x02A80320
+#define IFE_C_E_PHY_ID       0x02A80310
+#define IGP04E1000_E_PHY_ID  0x02A80391
 #define M88_VENDOR           0x0141
 
 /* M88E1000 Specific Registers */
 #define M88E1000_PHY_SPEC_CTRL     0x10  /* PHY Specific Control Register */
 #define M88E1000_PHY_SPEC_STATUS   0x11  /* PHY Specific Status Register */
+#define M88E1000_INT_ENABLE        0x12  /* Interrupt Enable Register */
+#define M88E1000_INT_STATUS        0x13  /* Interrupt Status Register */
 #define M88E1000_EXT_PHY_SPEC_CTRL 0x14  /* Extended PHY Specific Control */
+#define M88E1000_RX_ERR_CNTR       0x15  /* Receive Error Counter */
 
+#define M88E1000_PHY_EXT_CTRL      0x1A  /* PHY extend control register */
 #define M88E1000_PHY_PAGE_SELECT   0x1D  /* Reg 29 for page number setting */
 #define M88E1000_PHY_GEN_CONTROL   0x1E  /* Its meaning depends on reg 29 */
+#define M88E1000_PHY_VCO_REG_BIT8  0x100 /* Bits 8 & 11 are adjusted for */
+#define M88E1000_PHY_VCO_REG_BIT11 0x800    /* improved BER performance */
 
 /* M88E1000 PHY Specific Control Register */
+#define M88E1000_PSCR_JABBER_DISABLE    0x0001 /* 1=Jabber Function disabled */
 #define M88E1000_PSCR_POLARITY_REVERSAL 0x0002 /* 1=Polarity Reversal enabled */
+#define M88E1000_PSCR_SQE_TEST          0x0004 /* 1=SQE Test enabled */
 /* 1=CLK125 low, 0=CLK125 toggling */
+#define M88E1000_PSCR_CLK125_DISABLE    0x0010
 #define M88E1000_PSCR_MDI_MANUAL_MODE  0x0000  /* MDI Crossover Mode bits 6:5 */
-                                              /* Manual MDI configuration */
+                                               /* Manual MDI configuration */
 #define M88E1000_PSCR_MDIX_MANUAL_MODE 0x0020  /* Manual MDIX configuration */
 /* 1000BASE-T: Auto crossover, 100BASE-TX/10BASE-T: MDI Mode */
 #define M88E1000_PSCR_AUTO_X_1000T     0x0040
 /* Auto crossover enabled all speeds */
 #define M88E1000_PSCR_AUTO_X_MODE      0x0060
 /*
- * 1=Enable Extended 10BASE-T distance (Lower 10BASE-T RX Threshold
- * 0=Normal 10BASE-T RX Threshold
+ * 1=Enable Extended 10BASE-T distance (Lower 10BASE-T Rx Threshold
+ * 0=Normal 10BASE-T Rx Threshold
  */
+#define M88E1000_PSCR_EN_10BT_EXT_DIST 0x0080
 /* 1=5-bit interface in 100BASE-TX, 0=MII interface in 100BASE-TX */
+#define M88E1000_PSCR_MII_5BIT_ENABLE      0x0100
+#define M88E1000_PSCR_SCRAMBLER_DISABLE    0x0200 /* 1=Scrambler disable */
+#define M88E1000_PSCR_FORCE_LINK_GOOD      0x0400 /* 1=Force link good */
 #define M88E1000_PSCR_ASSERT_CRS_ON_TX     0x0800 /* 1=Assert CRS on Transmit */
 
 /* M88E1000 PHY Specific Status Register */
+#define M88E1000_PSSR_JABBER             0x0001 /* 1=Jabber */
 #define M88E1000_PSSR_REV_POLARITY       0x0002 /* 1=Polarity reversed */
 #define M88E1000_PSSR_DOWNSHIFT          0x0020 /* 1=Downshifted */
 #define M88E1000_PSSR_MDIX               0x0040 /* 1=MDIX; 0=MDI */
  * 4 = >140M
  */
 #define M88E1000_PSSR_CABLE_LENGTH       0x0380
+#define M88E1000_PSSR_LINK               0x0400 /* 1=Link up, 0=Link down */
+#define M88E1000_PSSR_SPD_DPLX_RESOLVED  0x0800 /* 1=Speed & Duplex resolved */
+#define M88E1000_PSSR_PAGE_RCVD          0x1000 /* 1=Page received */
+#define M88E1000_PSSR_DPLX               0x2000 /* 1=Duplex 0=Half Duplex */
 #define M88E1000_PSSR_SPEED              0xC000 /* Speed, bits 14:15 */
+#define M88E1000_PSSR_10MBS              0x0000 /* 00=10Mbs */
+#define M88E1000_PSSR_100MBS             0x4000 /* 01=100Mbs */
 #define M88E1000_PSSR_1000MBS            0x8000 /* 10=1000Mbs */
 
 #define M88E1000_PSSR_CABLE_LENGTH_SHIFT 7
 
 /* M88E1000 Extended PHY Specific Control Register */
+#define M88E1000_EPSCR_FIBER_LOOPBACK 0x4000 /* 1=Fiber loopback */
 /*
  * 1 = Lost lock detect enabled.
  * Will assert lost lock and bring
  * link down if idle not seen
  * within 1ms in 1000BASE-T
  */
+#define M88E1000_EPSCR_DOWN_NO_IDLE   0x8000
 /*
  * Number of times we will attempt to autonegotiate before downshifting if we
  * are the master
  */
 #define M88E1000_EPSCR_MASTER_DOWNSHIFT_MASK 0x0C00
 #define M88E1000_EPSCR_MASTER_DOWNSHIFT_1X   0x0000
+#define M88E1000_EPSCR_MASTER_DOWNSHIFT_2X   0x0400
+#define M88E1000_EPSCR_MASTER_DOWNSHIFT_3X   0x0800
+#define M88E1000_EPSCR_MASTER_DOWNSHIFT_4X   0x0C00
 /*
  * Number of times we will attempt to autonegotiate before downshifting if we
  * are the slave
  */
 #define M88E1000_EPSCR_SLAVE_DOWNSHIFT_MASK  0x0300
+#define M88E1000_EPSCR_SLAVE_DOWNSHIFT_DIS   0x0000
 #define M88E1000_EPSCR_SLAVE_DOWNSHIFT_1X    0x0100
+#define M88E1000_EPSCR_SLAVE_DOWNSHIFT_2X    0x0200
+#define M88E1000_EPSCR_SLAVE_DOWNSHIFT_3X    0x0300
+#define M88E1000_EPSCR_TX_CLK_2_5     0x0060 /* 2.5 MHz TX_CLK */
 #define M88E1000_EPSCR_TX_CLK_25      0x0070 /* 25  MHz TX_CLK */
+#define M88E1000_EPSCR_TX_CLK_0       0x0000 /* NO  TX_CLK */
 
 /* M88EC018 Rev 2 specific DownShift settings */
 #define M88EC018_EPSCR_DOWNSHIFT_COUNTER_MASK  0x0E00
+#define M88EC018_EPSCR_DOWNSHIFT_COUNTER_1X    0x0000
+#define M88EC018_EPSCR_DOWNSHIFT_COUNTER_2X    0x0200
+#define M88EC018_EPSCR_DOWNSHIFT_COUNTER_3X    0x0400
+#define M88EC018_EPSCR_DOWNSHIFT_COUNTER_4X    0x0600
 #define M88EC018_EPSCR_DOWNSHIFT_COUNTER_5X    0x0800
+#define M88EC018_EPSCR_DOWNSHIFT_COUNTER_6X    0x0A00
+#define M88EC018_EPSCR_DOWNSHIFT_COUNTER_7X    0x0C00
+#define M88EC018_EPSCR_DOWNSHIFT_COUNTER_8X    0x0E00
+
+/*
+ * Bits...
+ * 15-5: page
+ * 4-0: register offset
+ */
+#define GG82563_PAGE_SHIFT        5
+#define GG82563_REG(page, reg)    \
+        (((page) << GG82563_PAGE_SHIFT) | ((reg) & MAX_PHY_REG_ADDRESS))
+#define GG82563_MIN_ALT_REG       30
+
+/* GG82563 Specific Registers */
+#define GG82563_PHY_SPEC_CTRL           \
+        GG82563_REG(0, 16) /* PHY Specific Control */
+#define GG82563_PHY_SPEC_STATUS         \
+        GG82563_REG(0, 17) /* PHY Specific Status */
+#define GG82563_PHY_INT_ENABLE          \
+        GG82563_REG(0, 18) /* Interrupt Enable */
+#define GG82563_PHY_SPEC_STATUS_2       \
+        GG82563_REG(0, 19) /* PHY Specific Status 2 */
+#define GG82563_PHY_RX_ERR_CNTR         \
+        GG82563_REG(0, 21) /* Receive Error Counter */
+#define GG82563_PHY_PAGE_SELECT         \
+        GG82563_REG(0, 22) /* Page Select */
+#define GG82563_PHY_SPEC_CTRL_2         \
+        GG82563_REG(0, 26) /* PHY Specific Control 2 */
+#define GG82563_PHY_PAGE_SELECT_ALT     \
+        GG82563_REG(0, 29) /* Alternate Page Select */
+#define GG82563_PHY_TEST_CLK_CTRL       \
+        GG82563_REG(0, 30) /* Test Clock Control (use reg. 29 to select) */
+
+#define GG82563_PHY_MAC_SPEC_CTRL       \
+        GG82563_REG(2, 21) /* MAC Specific Control Register */
+#define GG82563_PHY_MAC_SPEC_CTRL_2     \
+        GG82563_REG(2, 26) /* MAC Specific Control 2 */
+
+#define GG82563_PHY_DSP_DISTANCE    \
+        GG82563_REG(5, 26) /* DSP Distance */
+
+/* Page 193 - Port Control Registers */
+#define GG82563_PHY_KMRN_MODE_CTRL   \
+        GG82563_REG(193, 16) /* Kumeran Mode Control */
+#define GG82563_PHY_PORT_RESET          \
+        GG82563_REG(193, 17) /* Port Reset */
+#define GG82563_PHY_REVISION_ID         \
+        GG82563_REG(193, 18) /* Revision ID */
+#define GG82563_PHY_DEVICE_ID           \
+        GG82563_REG(193, 19) /* Device ID */
+#define GG82563_PHY_PWR_MGMT_CTRL       \
+        GG82563_REG(193, 20) /* Power Management Control */
+#define GG82563_PHY_RATE_ADAPT_CTRL     \
+        GG82563_REG(193, 25) /* Rate Adaptation Control */
+
+/* Page 194 - KMRN Registers */
+#define GG82563_PHY_KMRN_FIFO_CTRL_STAT \
+        GG82563_REG(194, 16) /* FIFO's Control/Status */
+#define GG82563_PHY_KMRN_CTRL           \
+        GG82563_REG(194, 17) /* Control */
+#define GG82563_PHY_INBAND_CTRL         \
+        GG82563_REG(194, 18) /* Inband Control */
+#define GG82563_PHY_KMRN_DIAGNOSTIC     \
+        GG82563_REG(194, 19) /* Diagnostic */
+#define GG82563_PHY_ACK_TIMEOUTS        \
+        GG82563_REG(194, 20) /* Acknowledge Timeouts */
+#define GG82563_PHY_ADV_ABILITY         \
+        GG82563_REG(194, 21) /* Advertised Ability */
+#define GG82563_PHY_LINK_PARTNER_ADV_ABILITY \
+        GG82563_REG(194, 23) /* Link Partner Advertised Ability */
+#define GG82563_PHY_ADV_NEXT_PAGE       \
+        GG82563_REG(194, 24) /* Advertised Next Page */
+#define GG82563_PHY_LINK_PARTNER_ADV_NEXT_PAGE \
+        GG82563_REG(194, 25) /* Link Partner Advertised Next page */
+#define GG82563_PHY_KMRN_MISC           \
+        GG82563_REG(194, 26) /* Misc. */
 
 /* MDI Control */
+#define E1000_MDIC_DATA_MASK 0x0000FFFF
+#define E1000_MDIC_REG_MASK  0x001F0000
 #define E1000_MDIC_REG_SHIFT 16
+#define E1000_MDIC_PHY_MASK  0x03E00000
 #define E1000_MDIC_PHY_SHIFT 21
 #define E1000_MDIC_OP_WRITE  0x04000000
 #define E1000_MDIC_OP_READ   0x08000000
 #define E1000_MDIC_READY     0x10000000
+#define E1000_MDIC_INT_EN    0x20000000
 #define E1000_MDIC_ERROR     0x40000000
 
 /* SerDes Control */
 #define E1000_GEN_CTL_ADDRESS_SHIFT     8
 #define E1000_GEN_POLL_TIMEOUT          640
 
-#endif
+/* LinkSec register fields */
+#define E1000_LSECTXCAP_SUM_MASK        0x00FF0000
+#define E1000_LSECTXCAP_SUM_SHIFT       16
+#define E1000_LSECRXCAP_SUM_MASK        0x00FF0000
+#define E1000_LSECRXCAP_SUM_SHIFT       16
+
+#define E1000_LSECTXCTRL_EN_MASK        0x00000003
+#define E1000_LSECTXCTRL_DISABLE        0x0
+#define E1000_LSECTXCTRL_AUTH           0x1
+#define E1000_LSECTXCTRL_AUTH_ENCRYPT   0x2
+#define E1000_LSECTXCTRL_AISCI          0x00000020
+#define E1000_LSECTXCTRL_PNTHRSH_MASK   0xFFFFFF00
+#define E1000_LSECTXCTRL_RSV_MASK       0x000000D8
+
+#define E1000_LSECRXCTRL_EN_MASK        0x0000000C
+#define E1000_LSECRXCTRL_EN_SHIFT       2
+#define E1000_LSECRXCTRL_DISABLE        0x0
+#define E1000_LSECRXCTRL_CHECK          0x1
+#define E1000_LSECRXCTRL_STRICT         0x2
+#define E1000_LSECRXCTRL_DROP           0x3
+#define E1000_LSECRXCTRL_PLSH           0x00000040
+#define E1000_LSECRXCTRL_RP             0x00000080
+#define E1000_LSECRXCTRL_RSV_MASK       0xFFFFFF33
+
+#endif /* _E1000_DEFINES_H_ */
index 3be93751be7162f338fd38b1e75c071e00a2668d..90778ff680297ae6925e3857cca66526f3c2cb8e 100644 (file)
@@ -1,7 +1,7 @@
 /*******************************************************************************
 
   Intel(R) Gigabit Ethernet Linux driver
-  Copyright(c) 2007 Intel Corporation.
+  Copyright(c) 2007-2008 Intel Corporation.
 
   This program is free software; you can redistribute it and/or modify it
   under the terms and conditions of the GNU General Public License,
 #ifndef _E1000_HW_H_
 #define _E1000_HW_H_
 
-#include <linux/types.h>
-#include <linux/delay.h>
-#include <linux/io.h>
-
-#include "e1000_mac.h"
+#include "e1000_osdep.h"
 #include "e1000_regs.h"
 #include "e1000_defines.h"
-#include "igb_compat.h"
 
 struct e1000_hw;
 
+#define E1000_DEV_ID_82576                    0x10C9
+#define E1000_DEV_ID_82576_FIBER              0x10E6
+#define E1000_DEV_ID_82576_SERDES             0x10E7
 #define E1000_DEV_ID_82575EB_COPPER           0x10A7
 #define E1000_DEV_ID_82575EB_FIBER_SERDES     0x10A9
 #define E1000_DEV_ID_82575GB_QUAD_COPPER      0x10D6
-
+#define E1000_REVISION_0 0
+#define E1000_REVISION_1 1
 #define E1000_REVISION_2 2
+#define E1000_REVISION_3 3
 #define E1000_REVISION_4 4
 
+#define E1000_FUNC_0     0
 #define E1000_FUNC_1     1
 
 enum e1000_mac_type {
        e1000_undefined = 0,
        e1000_82575,
+       e1000_82576,
        e1000_num_macs  /* List is 1-based, so subtract 1 for true count. */
 };
 
@@ -66,7 +68,6 @@ enum e1000_nvm_type {
        e1000_nvm_unknown = 0,
        e1000_nvm_none,
        e1000_nvm_eeprom_spi,
-       e1000_nvm_eeprom_microwire,
        e1000_nvm_flash_hw,
        e1000_nvm_flash_sw
 };
@@ -75,8 +76,6 @@ enum e1000_nvm_override {
        e1000_nvm_override_none = 0,
        e1000_nvm_override_spi_small,
        e1000_nvm_override_spi_large,
-       e1000_nvm_override_microwire_small,
-       e1000_nvm_override_microwire_large
 };
 
 enum e1000_phy_type {
@@ -88,6 +87,7 @@ enum e1000_phy_type {
        e1000_phy_gg82563,
        e1000_phy_igp_3,
        e1000_phy_ife,
+       e1000_phy_vf,
 };
 
 enum e1000_bus_type {
@@ -141,38 +141,50 @@ enum e1000_fc_type {
        e1000_fc_default = 0xFF
 };
 
+enum e1000_ms_type {
+       e1000_ms_hw_default = 0,
+       e1000_ms_force_master,
+       e1000_ms_force_slave,
+       e1000_ms_auto
+};
+
+enum e1000_smart_speed {
+       e1000_smart_speed_default = 0,
+       e1000_smart_speed_on,
+       e1000_smart_speed_off
+};
 
 /* Receive Descriptor */
 struct e1000_rx_desc {
-       u64 buffer_addr; /* Address of the descriptor's data buffer */
-       u16 length;      /* Length of data DMAed into data buffer */
-       u16 csum;        /* Packet checksum */
-       u8  status;      /* Descriptor status */
-       u8  errors;      /* Descriptor Errors */
-       u16 special;
+       __le64 buffer_addr; /* Address of the descriptor's data buffer */
+       __le16 length;      /* Length of data DMAed into data buffer */
+       __le16 csum;        /* Packet checksum */
+       u8  status;         /* Descriptor status */
+       u8  errors;         /* Descriptor Errors */
+       __le16 special;
 };
 
 /* Receive Descriptor - Extended */
 union e1000_rx_desc_extended {
        struct {
-               u64 buffer_addr;
-               u64 reserved;
+               __le64 buffer_addr;
+               __le64 reserved;
        } read;
        struct {
                struct {
-                       u32 mrq;              /* Multiple Rx Queues */
+                       __le32 mrq;           /* Multiple Rx Queues */
                        union {
-                               u32 rss;            /* RSS Hash */
+                               __le32 rss;         /* RSS Hash */
                                struct {
-                                       u16 ip_id;  /* IP id */
-                                       u16 csum;   /* Packet Checksum */
+                                       __le16 ip_id;  /* IP id */
+                                       __le16 csum;   /* Packet Checksum */
                                } csum_ip;
                        } hi_dword;
                } lower;
                struct {
-                       u32 status_error;     /* ext status/error */
-                       u16 length;
-                       u16 vlan;             /* VLAN tag */
+                       __le32 status_error;  /* ext status/error */
+                       __le16 length;
+                       __le16 vlan;          /* VLAN tag */
                } upper;
        } wb;  /* writeback */
 };
@@ -182,49 +194,49 @@ union e1000_rx_desc_extended {
 union e1000_rx_desc_packet_split {
        struct {
                /* one buffer for protocol header(s), three data buffers */
-               u64 buffer_addr[MAX_PS_BUFFERS];
+               __le64 buffer_addr[MAX_PS_BUFFERS];
        } read;
        struct {
                struct {
-                       u32 mrq;              /* Multiple Rx Queues */
+                       __le32 mrq;           /* Multiple Rx Queues */
                        union {
-                               u32 rss;              /* RSS Hash */
+                               __le32 rss;           /* RSS Hash */
                                struct {
-                                       u16 ip_id;    /* IP id */
-                                       u16 csum;     /* Packet Checksum */
+                                       __le16 ip_id;    /* IP id */
+                                       __le16 csum;     /* Packet Checksum */
                                } csum_ip;
                        } hi_dword;
                } lower;
                struct {
-                       u32 status_error;     /* ext status/error */
-                       u16 length0;          /* length of buffer 0 */
-                       u16 vlan;             /* VLAN tag */
+                       __le32 status_error;  /* ext status/error */
+                       __le16 length0;       /* length of buffer 0 */
+                       __le16 vlan;          /* VLAN tag */
                } middle;
                struct {
-                       u16 header_status;
-                       u16 length[3];        /* length of buffers 1-3 */
+                       __le16 header_status;
+                       __le16 length[3];     /* length of buffers 1-3 */
                } upper;
-               u64 reserved;
+               __le64 reserved;
        } wb; /* writeback */
 };
 
 /* Transmit Descriptor */
 struct e1000_tx_desc {
-       u64 buffer_addr;      /* Address of the descriptor's data buffer */
+       __le64 buffer_addr;   /* Address of the descriptor's data buffer */
        union {
-               u32 data;
+               __le32 data;
                struct {
-                       u16 length;    /* Data buffer length */
-                       u8 cso;        /* Checksum offset */
-                       u8 cmd;        /* Descriptor control */
+                       __le16 length;    /* Data buffer length */
+                       u8 cso;           /* Checksum offset */
+                       u8 cmd;           /* Descriptor control */
                } flags;
        } lower;
        union {
-               u32 data;
+               __le32 data;
                struct {
-                       u8 status;     /* Descriptor status */
-                       u8 css;        /* Checksum start */
-                       u16 special;
+                       u8 status;        /* Descriptor status */
+                       u8 css;           /* Checksum start */
+                       __le16 special;
                } fields;
        } upper;
 };
@@ -232,49 +244,49 @@ struct e1000_tx_desc {
 /* Offload Context Descriptor */
 struct e1000_context_desc {
        union {
-               u32 ip_config;
+               __le32 ip_config;
                struct {
-                       u8 ipcss;      /* IP checksum start */
-                       u8 ipcso;      /* IP checksum offset */
-                       u16 ipcse;     /* IP checksum end */
+                       u8 ipcss;         /* IP checksum start */
+                       u8 ipcso;         /* IP checksum offset */
+                       __le16 ipcse;     /* IP checksum end */
                } ip_fields;
        } lower_setup;
        union {
-               u32 tcp_config;
+               __le32 tcp_config;
                struct {
-                       u8 tucss;      /* TCP checksum start */
-                       u8 tucso;      /* TCP checksum offset */
-                       u16 tucse;     /* TCP checksum end */
+                       u8 tucss;         /* TCP checksum start */
+                       u8 tucso;         /* TCP checksum offset */
+                       __le16 tucse;     /* TCP checksum end */
                } tcp_fields;
        } upper_setup;
-       u32 cmd_and_length;
+       __le32 cmd_and_length;
        union {
-               u32 data;
+               __le32 data;
                struct {
-                       u8 status;     /* Descriptor status */
-                       u8 hdr_len;    /* Header length */
-                       u16 mss;       /* Maximum segment size */
+                       u8 status;        /* Descriptor status */
+                       u8 hdr_len;       /* Header length */
+                       __le16 mss;       /* Maximum segment size */
                } fields;
        } tcp_seg_setup;
 };
 
 /* Offload data descriptor */
 struct e1000_data_desc {
-       u64 buffer_addr;   /* Address of the descriptor's buffer address */
+       __le64 buffer_addr;   /* Address of the descriptor's buffer address */
        union {
-               u32 data;
+               __le32 data;
                struct {
-                       u16 length;    /* Data buffer length */
+                       __le16 length;    /* Data buffer length */
                        u8 typ_len_ext;
                        u8 cmd;
                } flags;
        } lower;
        union {
-               u32 data;
+               __le32 data;
                struct {
-                       u8 status;     /* Descriptor status */
-                       u8 popts;      /* Packet Options */
-                       u16 special;
+                       u8 status;        /* Descriptor status */
+                       u8 popts;         /* Packet Options */
+                       __le16 special;
                } fields;
        } upper;
 };
@@ -406,50 +418,75 @@ struct e1000_host_mng_command_info {
 #include "e1000_mac.h"
 #include "e1000_phy.h"
 #include "e1000_nvm.h"
+#include "e1000_manage.h"
 
 struct e1000_mac_operations {
+       /* Function pointers for the MAC. */
+       s32  (*init_params)(struct e1000_hw *);
+       s32  (*blink_led)(struct e1000_hw *);
        s32  (*check_for_link)(struct e1000_hw *);
+       bool (*check_mng_mode)(struct e1000_hw *hw);
+       s32  (*cleanup_led)(struct e1000_hw *);
+       void (*clear_hw_cntrs)(struct e1000_hw *);
+       void (*clear_vfta)(struct e1000_hw *);
+       s32  (*get_bus_info)(struct e1000_hw *);
+       s32  (*get_link_up_info)(struct e1000_hw *, u16 *, u16 *);
+       s32  (*led_on)(struct e1000_hw *);
+       s32  (*led_off)(struct e1000_hw *);
+       void (*update_mc_addr_list)(struct e1000_hw *, u8 *, u32, u32, u32);
        s32  (*reset_hw)(struct e1000_hw *);
        s32  (*init_hw)(struct e1000_hw *);
+       void (*shutdown_serdes)(struct e1000_hw *);
+       s32  (*setup_link)(struct e1000_hw *);
        s32  (*setup_physical_interface)(struct e1000_hw *);
-       void (*rar_set)(struct e1000_hw *, u8 *, u32);
-       s32  (*read_mac_addr)(struct e1000_hw *);
-       s32  (*get_speed_and_duplex)(struct e1000_hw *, u16 *, u16 *);
+       s32  (*setup_led)(struct e1000_hw *);
+       void (*write_vfta)(struct e1000_hw *, u32, u32);
+       void (*mta_set)(struct e1000_hw *, u32);
+       void (*config_collision_dist)(struct e1000_hw*);
+       void (*rar_set)(struct e1000_hw*, u8*, u32);
+       s32  (*read_mac_addr)(struct e1000_hw*);
+       s32  (*validate_mdi_setting)(struct e1000_hw*);
+       s32  (*mng_host_if_write)(struct e1000_hw*, u8*, u16, u16, u8*);
+       s32  (*mng_write_cmd_header)(struct e1000_hw *hw,
+                      struct e1000_host_mng_command_header*);
+       s32  (*mng_enable_host_if)(struct e1000_hw*);
+       s32  (*wait_autoneg)(struct e1000_hw*);
 };
 
 struct e1000_phy_operations {
-       s32  (*acquire_phy)(struct e1000_hw *);
+       s32  (*init_params)(struct e1000_hw *);
+       s32  (*acquire)(struct e1000_hw *);
+       s32  (*check_polarity)(struct e1000_hw *);
+       s32  (*check_reset_block)(struct e1000_hw *);
+       s32  (*commit)(struct e1000_hw *);
        s32  (*force_speed_duplex)(struct e1000_hw *);
        s32  (*get_cfg_done)(struct e1000_hw *hw);
        s32  (*get_cable_length)(struct e1000_hw *);
-       s32  (*get_phy_info)(struct e1000_hw *);
-       s32  (*read_phy_reg)(struct e1000_hw *, u32, u16 *);
-       void (*release_phy)(struct e1000_hw *);
-       s32  (*reset_phy)(struct e1000_hw *);
+       s32  (*get_info)(struct e1000_hw *);
+       s32  (*read_reg)(struct e1000_hw *, u32, u16 *);
+       void (*release)(struct e1000_hw *);
+       s32  (*reset)(struct e1000_hw *);
        s32  (*set_d0_lplu_state)(struct e1000_hw *, bool);
        s32  (*set_d3_lplu_state)(struct e1000_hw *, bool);
-       s32  (*write_phy_reg)(struct e1000_hw *, u32, u16);
+       s32  (*write_reg)(struct e1000_hw *, u32, u16);
+       void (*power_up)(struct e1000_hw *);
+       void (*power_down)(struct e1000_hw *);
 };
 
 struct e1000_nvm_operations {
-       s32  (*acquire_nvm)(struct e1000_hw *);
-       s32  (*read_nvm)(struct e1000_hw *, u16, u16, u16 *);
-       void (*release_nvm)(struct e1000_hw *);
-       s32  (*write_nvm)(struct e1000_hw *, u16, u16, u16 *);
-};
-
-struct e1000_info {
-       s32 (*get_invariants)(struct e1000_hw *);
-       struct e1000_mac_operations *mac_ops;
-       struct e1000_phy_operations *phy_ops;
-       struct e1000_nvm_operations *nvm_ops;
+       s32  (*init_params)(struct e1000_hw *);
+       s32  (*acquire)(struct e1000_hw *);
+       s32  (*read)(struct e1000_hw *, u16, u16, u16 *);
+       void (*release)(struct e1000_hw *);
+       void (*reload)(struct e1000_hw *);
+       s32  (*update)(struct e1000_hw *);
+       s32  (*valid_led_default)(struct e1000_hw *, u16 *);
+       s32  (*validate)(struct e1000_hw *);
+       s32  (*write)(struct e1000_hw *, u16, u16, u16 *);
 };
 
-extern const struct e1000_info e1000_82575_info;
-
 struct e1000_mac_info {
        struct e1000_mac_operations ops;
-
        u8 addr[6];
        u8 perm_addr[6];
 
@@ -478,19 +515,14 @@ struct e1000_mac_info {
        bool asf_firmware_present;
        bool autoneg;
        bool autoneg_failed;
-       bool disable_av;
-       bool disable_hw_init_bits;
        bool get_link_status;
-       bool ifs_params_forced;
        bool in_ifs_mode;
-       bool report_tx_early;
        bool serdes_has_link;
        bool tx_pkt_filtering;
 };
 
 struct e1000_phy_info {
        struct e1000_phy_operations ops;
-
        enum e1000_phy_type type;
 
        enum e1000_1000t_rx_status local_rx;
@@ -525,7 +557,6 @@ struct e1000_phy_info {
 
 struct e1000_nvm_info {
        struct e1000_nvm_operations ops;
-
        enum e1000_nvm_type type;
        enum e1000_nvm_override override;
 
@@ -544,25 +575,30 @@ struct e1000_bus_info {
        enum e1000_bus_speed speed;
        enum e1000_bus_width width;
 
-       u32 snoop;
-
        u16 func;
        u16 pci_cmd_word;
 };
 
 struct e1000_fc_info {
-       u32 high_water;     /* Flow control high-water mark */
-       u32 low_water;      /* Flow control low-water mark */
-       u16 pause_time;     /* Flow control pause timer */
-       bool send_xon;      /* Flow control send XON */
-       bool strict_ieee;   /* Strict IEEE mode */
+       u32 high_water;          /* Flow control high-water mark */
+       u32 low_water;           /* Flow control low-water mark */
+       u16 pause_time;          /* Flow control pause timer */
+       bool send_xon;           /* Flow control send XON */
+       bool strict_ieee;        /* Strict IEEE mode */
        enum e1000_fc_type type; /* Type of flow control */
        enum e1000_fc_type original_type;
 };
 
+struct e1000_dev_spec_82575 {
+       bool sgmii_active;
+};
+
+struct e1000_dev_spec_vf {
+       u32     vf_number;
+};
+
 struct e1000_hw {
        void *back;
-       void *dev_spec;
 
        u8 __iomem *hw_addr;
        u8 __iomem *flash_address;
@@ -575,7 +611,10 @@ struct e1000_hw {
        struct e1000_bus_info  bus;
        struct e1000_host_mng_dhcp_cookie mng_cookie;
 
-       u32 dev_spec_size;
+       union {
+               struct e1000_dev_spec_82575     _82575;
+               struct e1000_dev_spec_vf        vf;
+       } dev_spec;
 
        u16 device_id;
        u16 subsystem_vendor_id;
@@ -585,16 +624,10 @@ struct e1000_hw {
        u8  revision_id;
 };
 
-#ifdef DEBUG
-extern char *igb_get_hw_dev_name(struct e1000_hw *hw);
-#define hw_dbg(hw, format, arg...) \
-       printk(KERN_DEBUG "%s: " format, igb_get_hw_dev_name(hw), ##arg)
-#else
-static inline int __attribute__ ((format (printf, 2, 3)))
-hw_dbg(struct e1000_hw *hw, const char *format, ...)
-{
-       return 0;
-}
-#endif
+#include "e1000_82575.h"
+
+/* These functions must be implemented by drivers */
+s32  e1000_read_pcie_cap_reg(struct e1000_hw *hw, u32 reg, u16 *value);
+void e1000_read_pci_cfg(struct e1000_hw *hw, u32 reg, u16 *value);
 
 #endif
index 3e84a3f0c1d8c8317b48acd5865800f91e2ef33e..18be7b006ad32dd314c4ada5007087711ad2791f 100644 (file)
@@ -1,7 +1,7 @@
 /*******************************************************************************
 
   Intel(R) Gigabit Ethernet Linux driver
-  Copyright(c) 2007 Intel Corporation.
+  Copyright(c) 2007-2008 Intel Corporation.
 
   This program is free software; you can redistribute it and/or modify it
   under the terms and conditions of the GNU General Public License,
 
 *******************************************************************************/
 
-#include <linux/if_ether.h>
-#include <linux/delay.h>
-#include <linux/pci.h>
-#include <linux/netdevice.h>
+#include "e1000_api.h"
 
-#include "e1000_mac.h"
-
-#include "igb.h"
-
-static s32 igb_set_default_fc(struct e1000_hw *hw);
-static s32 igb_set_fc_watermarks(struct e1000_hw *hw);
-static u32 igb_hash_mc_addr(struct e1000_hw *hw, u8 *mc_addr);
+static s32 e1000_set_default_fc_generic(struct e1000_hw *hw);
+static s32 e1000_commit_fc_settings_generic(struct e1000_hw *hw);
+static s32 e1000_poll_fiber_serdes_link_generic(struct e1000_hw *hw);
+static s32 e1000_validate_mdi_setting_generic(struct e1000_hw *hw);
 
 /**
- *  e1000_remove_device - Free device specific structure
+ *  e1000_init_mac_ops_generic - Initialize MAC function pointers
  *  @hw: pointer to the HW structure
  *
- *  If a device specific structure was allocated, this function will
- *  free it.
+ *  Setups up the function pointers to no-op functions
  **/
-void igb_remove_device(struct e1000_hw *hw)
-{
-       /* Freeing the dev_spec member of e1000_hw structure */
-       kfree(hw->dev_spec);
-}
-
-static void igb_read_pci_cfg(struct e1000_hw *hw, u32 reg, u16 *value)
+void e1000_init_mac_ops_generic(struct e1000_hw *hw)
 {
-       struct igb_adapter *adapter = hw->back;
-
-       pci_read_config_word(adapter->pdev, reg, value);
-}
-
-static s32 igb_read_pcie_cap_reg(struct e1000_hw *hw, u32 reg, u16 *value)
-{
-       struct igb_adapter *adapter = hw->back;
-       u16 cap_offset;
-
-       cap_offset = pci_find_capability(adapter->pdev, PCI_CAP_ID_EXP);
-       if (!cap_offset)
-               return -E1000_ERR_CONFIG;
-
-       pci_read_config_word(adapter->pdev, cap_offset + reg, value);
-
-       return 0;
+       struct e1000_mac_info *mac = &hw->mac;
+       DEBUGFUNC("e1000_init_mac_ops_generic");
+
+       /* General Setup */
+       mac->ops.read_mac_addr = e1000_read_mac_addr_generic;
+       mac->ops.config_collision_dist = e1000_config_collision_dist_generic;
+       /* LINK */
+       mac->ops.wait_autoneg = e1000_wait_autoneg_generic;
+       /* Management */
+       mac->ops.mng_host_if_write = e1000_mng_host_if_write_generic;
+       mac->ops.mng_write_cmd_header = e1000_mng_write_cmd_header_generic;
+       mac->ops.mng_enable_host_if = e1000_mng_enable_host_if_generic;
+       /* VLAN, MC, etc. */
+       mac->ops.rar_set = e1000_rar_set_generic;
+       mac->ops.validate_mdi_setting = e1000_validate_mdi_setting_generic;
 }
 
 /**
- *  e1000_get_bus_info_pcie - Get PCIe bus information
+ *  e1000_get_bus_info_pcie_generic - Get PCIe bus information
  *  @hw: pointer to the HW structure
  *
  *  Determines and stores the system bus information for a particular
  *  network interface.  The following bus information is determined and stored:
  *  bus speed, bus width, type (PCIe), and PCIe function.
  **/
-s32 igb_get_bus_info_pcie(struct e1000_hw *hw)
+s32 e1000_get_bus_info_pcie_generic(struct e1000_hw *hw)
 {
        struct e1000_bus_info *bus = &hw->bus;
        s32 ret_val;
        u32 status;
        u16 pcie_link_status, pci_header_type;
 
+       DEBUGFUNC("e1000_get_bus_info_pcie_generic");
+
        bus->type = e1000_bus_type_pci_express;
        bus->speed = e1000_bus_speed_2500;
 
-       ret_val = igb_read_pcie_cap_reg(hw,
-                                         PCIE_LINK_STATUS,
-                                         &pcie_link_status);
+       ret_val = e1000_read_pcie_cap_reg(hw,
+                                         PCIE_LINK_STATUS,
+                                         &pcie_link_status);
        if (ret_val)
                bus->width = e1000_bus_width_unknown;
        else
                bus->width = (enum e1000_bus_width)((pcie_link_status &
-                                                    PCIE_LINK_WIDTH_MASK) >>
-                                                    PCIE_LINK_WIDTH_SHIFT);
+                                               PCIE_LINK_WIDTH_MASK) >>
+                                              PCIE_LINK_WIDTH_SHIFT);
 
-       igb_read_pci_cfg(hw, PCI_HEADER_TYPE_REGISTER, &pci_header_type);
+       e1000_read_pci_cfg(hw, PCI_HEADER_TYPE_REGISTER, &pci_header_type);
        if (pci_header_type & PCI_HEADER_TYPE_MULTIFUNC) {
-               status = rd32(E1000_STATUS);
+               status = E1000_READ_REG(hw, E1000_STATUS);
                bus->func = (status & E1000_STATUS_FUNC_MASK)
-                           >> E1000_STATUS_FUNC_SHIFT;
+                           >> E1000_STATUS_FUNC_SHIFT;
        } else {
                bus->func = 0;
        }
 
-       return 0;
+       return E1000_SUCCESS;
 }
 
 /**
- *  e1000_clear_vfta - Clear VLAN filter table
+ *  e1000_clear_vfta_generic - Clear VLAN filter table
  *  @hw: pointer to the HW structure
  *
  *  Clears the register array which contains the VLAN filter table by
  *  setting all the values to 0.
  **/
-void igb_clear_vfta(struct e1000_hw *hw)
+void e1000_clear_vfta_generic(struct e1000_hw *hw)
 {
        u32 offset;
 
+       DEBUGFUNC("e1000_clear_vfta_generic");
+
        for (offset = 0; offset < E1000_VLAN_FILTER_TBL_SIZE; offset++) {
-               array_wr32(E1000_VFTA, offset, 0);
-               wrfl();
+               E1000_WRITE_REG_ARRAY(hw, E1000_VFTA, offset, 0);
+               E1000_WRITE_FLUSH(hw);
        }
 }
 
 /**
- *  e1000_write_vfta - Write value to VLAN filter table
+ *  e1000_write_vfta_generic - Write value to VLAN filter table
  *  @hw: pointer to the HW structure
  *  @offset: register offset in VLAN filter table
  *  @value: register value written to VLAN filter table
@@ -138,14 +127,16 @@ void igb_clear_vfta(struct e1000_hw *hw)
  *  Writes value at the given offset in the register array which stores
  *  the VLAN filter table.
  **/
-void igb_write_vfta(struct e1000_hw *hw, u32 offset, u32 value)
+void e1000_write_vfta_generic(struct e1000_hw *hw, u32 offset, u32 value)
 {
-       array_wr32(E1000_VFTA, offset, value);
-       wrfl();
+       DEBUGFUNC("e1000_write_vfta_generic");
+
+       E1000_WRITE_REG_ARRAY(hw, E1000_VFTA, offset, value);
+       E1000_WRITE_FLUSH(hw);
 }
 
 /**
- *  e1000_init_rx_addrs - Initialize receive address's
+ *  e1000_init_rx_addrs_generic - Initialize receive address's
  *  @hw: pointer to the HW structure
  *  @rar_count: receive address registers
  *
@@ -153,47 +144,51 @@ void igb_write_vfta(struct e1000_hw *hw, u32 offset, u32 value)
  *  register to the devices MAC address and clearing all the other receive
  *  address registers to 0.
  **/
-void igb_init_rx_addrs(struct e1000_hw *hw, u16 rar_count)
+void e1000_init_rx_addrs_generic(struct e1000_hw *hw, u16 rar_count)
 {
        u32 i;
 
+       DEBUGFUNC("e1000_init_rx_addrs_generic");
+
        /* Setup the receive address */
-       hw_dbg(hw, "Programming MAC Address into RAR[0]\n");
+       DEBUGOUT("Programming MAC Address into RAR[0]\n");
 
        hw->mac.ops.rar_set(hw, hw->mac.addr, 0);
 
        /* Zero out the other (rar_entry_count - 1) receive addresses */
-       hw_dbg(hw, "Clearing RAR[1-%u]\n", rar_count-1);
+       DEBUGOUT1("Clearing RAR[1-%u]\n", rar_count-1);
        for (i = 1; i < rar_count; i++) {
-               array_wr32(E1000_RA, (i << 1), 0);
-               wrfl();
-               array_wr32(E1000_RA, ((i << 1) + 1), 0);
-               wrfl();
+               E1000_WRITE_REG_ARRAY(hw, E1000_RA, (i << 1), 0);
+               E1000_WRITE_FLUSH(hw);
+               E1000_WRITE_REG_ARRAY(hw, E1000_RA, ((i << 1) + 1), 0);
+               E1000_WRITE_FLUSH(hw);
        }
 }
 
 /**
- *  e1000_check_alt_mac_addr - Check for alternate MAC addr
+ *  e1000_check_alt_mac_addr_generic - Check for alternate MAC addr
  *  @hw: pointer to the HW structure
  *
  *  Checks the nvm for an alternate MAC address.  An alternate MAC address
  *  can be setup by pre-boot software and must be treated like a permanent
  *  address and must override the actual permanent MAC address.  If an
- *  alternate MAC address is fopund it is saved in the hw struct and
- *  prgrammed into RAR0 and the cuntion returns success, otherwise the
- *  fucntion returns an error.
+ *  alternate MAC address is found it is saved in the hw struct and
+ *  programmed into RAR0 and the function returns success, otherwise the
+ *  function returns an error.
  **/
-s32 igb_check_alt_mac_addr(struct e1000_hw *hw)
+s32 e1000_check_alt_mac_addr_generic(struct e1000_hw *hw)
 {
        u32 i;
-       s32 ret_val = 0;
+       s32 ret_val = E1000_SUCCESS;
        u16 offset, nvm_alt_mac_addr_offset, nvm_data;
-       u8 alt_mac_addr[ETH_ALEN];
+       u8 alt_mac_addr[ETH_ADDR_LEN];
+
+       DEBUGFUNC("e1000_check_alt_mac_addr_generic");
 
-       ret_val = hw->nvm.ops.read_nvm(hw, NVM_ALT_MAC_ADDR_PTR, 1,
-                                &nvm_alt_mac_addr_offset);
+       ret_val = hw->nvm.ops.read(hw, NVM_ALT_MAC_ADDR_PTR, 1,
+                                &nvm_alt_mac_addr_offset);
        if (ret_val) {
-               hw_dbg(hw, "NVM Read Error\n");
+               DEBUGOUT("NVM Read Error\n");
                goto out;
        }
 
@@ -203,13 +198,13 @@ s32 igb_check_alt_mac_addr(struct e1000_hw *hw)
        }
 
        if (hw->bus.func == E1000_FUNC_1)
-               nvm_alt_mac_addr_offset += ETH_ALEN/sizeof(u16);
+               nvm_alt_mac_addr_offset += ETH_ADDR_LEN/sizeof(u16);
 
-       for (i = 0; i < ETH_ALEN; i += 2) {
+       for (i = 0; i < ETH_ADDR_LEN; i += 2) {
                offset = nvm_alt_mac_addr_offset + (i >> 1);
-               ret_val = hw->nvm.ops.read_nvm(hw, offset, 1, &nvm_data);
+               ret_val = hw->nvm.ops.read(hw, offset, 1, &nvm_data);
                if (ret_val) {
-                       hw_dbg(hw, "NVM Read Error\n");
+                       DEBUGOUT("NVM Read Error\n");
                        goto out;
                }
 
@@ -223,7 +218,7 @@ s32 igb_check_alt_mac_addr(struct e1000_hw *hw)
                goto out;
        }
 
-       for (i = 0; i < ETH_ALEN; i++)
+       for (i = 0; i < ETH_ADDR_LEN; i++)
                hw->mac.addr[i] = hw->mac.perm_addr[i] = alt_mac_addr[i];
 
        hw->mac.ops.rar_set(hw, hw->mac.perm_addr, 0);
@@ -233,7 +228,7 @@ out:
 }
 
 /**
- *  e1000_rar_set - Set receive address register
+ *  e1000_rar_set_generic - Set receive address register
  *  @hw: pointer to the HW structure
  *  @addr: pointer to the receive address
  *  @index: receive address array register
@@ -241,29 +236,32 @@ out:
  *  Sets the receive address array register at index to the address passed
  *  in by addr.
  **/
-void igb_rar_set(struct e1000_hw *hw, u8 *addr, u32 index)
+void e1000_rar_set_generic(struct e1000_hw *hw, u8 *addr, u32 index)
 {
        u32 rar_low, rar_high;
 
+       DEBUGFUNC("e1000_rar_set_generic");
+
        /*
         * HW expects these in little endian so we reverse the byte order
         * from network order (big endian) to little endian
         */
        rar_low = ((u32) addr[0] |
-                  ((u32) addr[1] << 8) |
-                   ((u32) addr[2] << 16) | ((u32) addr[3] << 24));
+                  ((u32) addr[1] << 8) |
+                  ((u32) addr[2] << 16) | ((u32) addr[3] << 24));
 
        rar_high = ((u32) addr[4] | ((u32) addr[5] << 8));
 
-       if (!hw->mac.disable_av)
+       /* If MAC address zero, no need to set the AV bit */
+       if (rar_low || rar_high)
                rar_high |= E1000_RAH_AV;
 
-       array_wr32(E1000_RA, (index << 1), rar_low);
-       array_wr32(E1000_RA, ((index << 1) + 1), rar_high);
+       E1000_WRITE_REG(hw, E1000_RAL(index), rar_low);
+       E1000_WRITE_REG(hw, E1000_RAH(index), rar_high);
 }
 
 /**
- *  e1000_mta_set - Set multicast filter table address
+ *  e1000_mta_set_generic - Set multicast filter table address
  *  @hw: pointer to the HW structure
  *  @hash_value: determines the MTA register and bit to set
  *
@@ -272,10 +270,11 @@ void igb_rar_set(struct e1000_hw *hw, u8 *addr, u32 index)
  *  current value is read, the new bit is OR'd in and the new value is
  *  written back into the register.
  **/
-static void igb_mta_set(struct e1000_hw *hw, u32 hash_value)
+void e1000_mta_set_generic(struct e1000_hw *hw, u32 hash_value)
 {
        u32 hash_bit, hash_reg, mta;
 
+       DEBUGFUNC("e1000_mta_set_generic");
        /*
         * The MTA is a register array of 32-bit registers. It is
         * treated like an array of (32*mta_reg_count) bits.  We want to
@@ -289,16 +288,16 @@ static void igb_mta_set(struct e1000_hw *hw, u32 hash_value)
        hash_reg = (hash_value >> 5) & (hw->mac.mta_reg_count - 1);
        hash_bit = hash_value & 0x1F;
 
-       mta = array_rd32(E1000_MTA, hash_reg);
+       mta = E1000_READ_REG_ARRAY(hw, E1000_MTA, hash_reg);
 
        mta |= (1 << hash_bit);
 
-       array_wr32(E1000_MTA, hash_reg, mta);
-       wrfl();
+       E1000_WRITE_REG_ARRAY(hw, E1000_MTA, hash_reg, mta);
+       E1000_WRITE_FLUSH(hw);
 }
 
 /**
- *  e1000_update_mc_addr_list - Update Multicast addresses
+ *  e1000_update_mc_addr_list_generic - Update Multicast addresses
  *  @hw: pointer to the HW structure
  *  @mc_addr_list: array of multicast addresses to program
  *  @mc_addr_count: number of multicast addresses to program
@@ -310,13 +309,15 @@ static void igb_mta_set(struct e1000_hw *hw, u32 hash_value)
  *  The parameter rar_count will usually be hw->mac.rar_entry_count
  *  unless there are workarounds that change this.
  **/
-void igb_update_mc_addr_list(struct e1000_hw *hw,
-                              u8 *mc_addr_list, u32 mc_addr_count,
-                              u32 rar_used_count, u32 rar_count)
+void e1000_update_mc_addr_list_generic(struct e1000_hw *hw,
+                                       u8 *mc_addr_list, u32 mc_addr_count,
+                                       u32 rar_used_count, u32 rar_count)
 {
        u32 hash_value;
        u32 i;
 
+       DEBUGFUNC("e1000_update_mc_addr_list_generic");
+
        /*
         * Load the first set of multicast addresses into the exact
         * filters (RAR).  If there are not enough to fill the RAR
@@ -326,45 +327,47 @@ void igb_update_mc_addr_list(struct e1000_hw *hw,
                if (mc_addr_count) {
                        hw->mac.ops.rar_set(hw, mc_addr_list, i);
                        mc_addr_count--;
-                       mc_addr_list += ETH_ALEN;
+                       mc_addr_list += ETH_ADDR_LEN;
                } else {
-                       array_wr32(E1000_RA, i << 1, 0);
-                       wrfl();
-                       array_wr32(E1000_RA, (i << 1) + 1, 0);
-                       wrfl();
+                       E1000_WRITE_REG_ARRAY(hw, E1000_RA, i << 1, 0);
+                       E1000_WRITE_FLUSH(hw);
+                       E1000_WRITE_REG_ARRAY(hw, E1000_RA, (i << 1) + 1, 0);
+                       E1000_WRITE_FLUSH(hw);
                }
        }
 
        /* Clear the old settings from the MTA */
-       hw_dbg(hw, "Clearing MTA\n");
+       DEBUGOUT("Clearing MTA\n");
        for (i = 0; i < hw->mac.mta_reg_count; i++) {
-               array_wr32(E1000_MTA, i, 0);
-               wrfl();
+               E1000_WRITE_REG_ARRAY(hw, E1000_MTA, i, 0);
+               E1000_WRITE_FLUSH(hw);
        }
 
        /* Load any remaining multicast addresses into the hash table. */
        for (; mc_addr_count > 0; mc_addr_count--) {
-               hash_value = igb_hash_mc_addr(hw, mc_addr_list);
-               hw_dbg(hw, "Hash value = 0x%03X\n", hash_value);
-               igb_mta_set(hw, hash_value);
-               mc_addr_list += ETH_ALEN;
+               hash_value = e1000_hash_mc_addr_generic(hw, mc_addr_list);
+               DEBUGOUT1("Hash value = 0x%03X\n", hash_value);
+               hw->mac.ops.mta_set(hw, hash_value);
+               mc_addr_list += ETH_ADDR_LEN;
        }
 }
 
 /**
- *  e1000_hash_mc_addr - Generate a multicast hash value
+ *  e1000_hash_mc_addr_generic - Generate a multicast hash value
  *  @hw: pointer to the HW structure
  *  @mc_addr: pointer to a multicast address
  *
  *  Generates a multicast address hash value which is used to determine
  *  the multicast filter table array address and new table value.  See
- *  igb_mta_set()
+ *  e1000_mta_set_generic()
  **/
-static u32 igb_hash_mc_addr(struct e1000_hw *hw, u8 *mc_addr)
+u32 e1000_hash_mc_addr_generic(struct e1000_hw *hw, u8 *mc_addr)
 {
        u32 hash_value, hash_mask;
        u8 bit_shift = 0;
 
+       DEBUGFUNC("e1000_hash_mc_addr_generic");
+
        /* Register count multiplied by bits per register */
        hash_mask = (hw->mac.mta_reg_count * 32) - 1;
 
@@ -402,89 +405,93 @@ static u32 igb_hash_mc_addr(struct e1000_hw *hw, u8 *mc_addr)
         * case 3: hash_value = ((0x34 >> 0) | (0x56 << 8)) & 0xFFF = 0x634
         */
        switch (hw->mac.mc_filter_type) {
-       default:
-       case 0:
-               break;
-       case 1:
-               bit_shift += 1;
-               break;
-       case 2:
-               bit_shift += 2;
-               break;
-       case 3:
-               bit_shift += 4;
-               break;
+               default:
+               case 0:
+                       break;
+               case 1:
+                       bit_shift += 1;
+                       break;
+               case 2:
+                       bit_shift += 2;
+                       break;
+               case 3:
+                       bit_shift += 4;
+                       break;
        }
 
        hash_value = hash_mask & (((mc_addr[4] >> (8 - bit_shift)) |
-                                 (((u16) mc_addr[5]) << bit_shift)));
+                                 (((u16) mc_addr[5]) << bit_shift)));
 
        return hash_value;
 }
 
 /**
- *  e1000_clear_hw_cntrs_base - Clear base hardware counters
+ *  e1000_clear_hw_cntrs_base_generic - Clear base hardware counters
  *  @hw: pointer to the HW structure
  *
  *  Clears the base hardware counters by reading the counter registers.
  **/
-void igb_clear_hw_cntrs_base(struct e1000_hw *hw)
+void e1000_clear_hw_cntrs_base_generic(struct e1000_hw *hw)
 {
-       u32 temp;
-
-       temp = rd32(E1000_CRCERRS);
-       temp = rd32(E1000_SYMERRS);
-       temp = rd32(E1000_MPC);
-       temp = rd32(E1000_SCC);
-       temp = rd32(E1000_ECOL);
-       temp = rd32(E1000_MCC);
-       temp = rd32(E1000_LATECOL);
-       temp = rd32(E1000_COLC);
-       temp = rd32(E1000_DC);
-       temp = rd32(E1000_SEC);
-       temp = rd32(E1000_RLEC);
-       temp = rd32(E1000_XONRXC);
-       temp = rd32(E1000_XONTXC);
-       temp = rd32(E1000_XOFFRXC);
-       temp = rd32(E1000_XOFFTXC);
-       temp = rd32(E1000_FCRUC);
-       temp = rd32(E1000_GPRC);
-       temp = rd32(E1000_BPRC);
-       temp = rd32(E1000_MPRC);
-       temp = rd32(E1000_GPTC);
-       temp = rd32(E1000_GORCL);
-       temp = rd32(E1000_GORCH);
-       temp = rd32(E1000_GOTCL);
-       temp = rd32(E1000_GOTCH);
-       temp = rd32(E1000_RNBC);
-       temp = rd32(E1000_RUC);
-       temp = rd32(E1000_RFC);
-       temp = rd32(E1000_ROC);
-       temp = rd32(E1000_RJC);
-       temp = rd32(E1000_TORL);
-       temp = rd32(E1000_TORH);
-       temp = rd32(E1000_TOTL);
-       temp = rd32(E1000_TOTH);
-       temp = rd32(E1000_TPR);
-       temp = rd32(E1000_TPT);
-       temp = rd32(E1000_MPTC);
-       temp = rd32(E1000_BPTC);
+       volatile u32 temp;
+
+       DEBUGFUNC("e1000_clear_hw_cntrs_base_generic");
+
+       temp = E1000_READ_REG(hw, E1000_CRCERRS);
+       temp = E1000_READ_REG(hw, E1000_SYMERRS);
+       temp = E1000_READ_REG(hw, E1000_MPC);
+       temp = E1000_READ_REG(hw, E1000_SCC);
+       temp = E1000_READ_REG(hw, E1000_ECOL);
+       temp = E1000_READ_REG(hw, E1000_MCC);
+       temp = E1000_READ_REG(hw, E1000_LATECOL);
+       temp = E1000_READ_REG(hw, E1000_COLC);
+       temp = E1000_READ_REG(hw, E1000_DC);
+       temp = E1000_READ_REG(hw, E1000_SEC);
+       temp = E1000_READ_REG(hw, E1000_RLEC);
+       temp = E1000_READ_REG(hw, E1000_XONRXC);
+       temp = E1000_READ_REG(hw, E1000_XONTXC);
+       temp = E1000_READ_REG(hw, E1000_XOFFRXC);
+       temp = E1000_READ_REG(hw, E1000_XOFFTXC);
+       temp = E1000_READ_REG(hw, E1000_FCRUC);
+       temp = E1000_READ_REG(hw, E1000_GPRC);
+       temp = E1000_READ_REG(hw, E1000_BPRC);
+       temp = E1000_READ_REG(hw, E1000_MPRC);
+       temp = E1000_READ_REG(hw, E1000_GPTC);
+       temp = E1000_READ_REG(hw, E1000_GORCL);
+       temp = E1000_READ_REG(hw, E1000_GORCH);
+       temp = E1000_READ_REG(hw, E1000_GOTCL);
+       temp = E1000_READ_REG(hw, E1000_GOTCH);
+       temp = E1000_READ_REG(hw, E1000_RNBC);
+       temp = E1000_READ_REG(hw, E1000_RUC);
+       temp = E1000_READ_REG(hw, E1000_RFC);
+       temp = E1000_READ_REG(hw, E1000_ROC);
+       temp = E1000_READ_REG(hw, E1000_RJC);
+       temp = E1000_READ_REG(hw, E1000_TORL);
+       temp = E1000_READ_REG(hw, E1000_TORH);
+       temp = E1000_READ_REG(hw, E1000_TOTL);
+       temp = E1000_READ_REG(hw, E1000_TOTH);
+       temp = E1000_READ_REG(hw, E1000_TPR);
+       temp = E1000_READ_REG(hw, E1000_TPT);
+       temp = E1000_READ_REG(hw, E1000_MPTC);
+       temp = E1000_READ_REG(hw, E1000_BPTC);
 }
 
 /**
- *  e1000_check_for_copper_link - Check for link (Copper)
+ *  e1000_check_for_copper_link_generic - Check for link (Copper)
  *  @hw: pointer to the HW structure
  *
  *  Checks to see of the link status of the hardware has changed.  If a
  *  change in link status has been detected, then we read the PHY registers
  *  to get the current speed/duplex if link exists.
  **/
-s32 igb_check_for_copper_link(struct e1000_hw *hw)
+s32 e1000_check_for_copper_link_generic(struct e1000_hw *hw)
 {
        struct e1000_mac_info *mac = &hw->mac;
        s32 ret_val;
        bool link;
 
+       DEBUGFUNC("e1000_check_for_copper_link");
+
        /*
         * We only want to go out to the PHY registers to see if Auto-Neg
         * has completed and/or if our link status has changed.  The
@@ -492,7 +499,7 @@ s32 igb_check_for_copper_link(struct e1000_hw *hw)
         * Change or Rx Sequence Error interrupt.
         */
        if (!mac->get_link_status) {
-               ret_val = 0;
+               ret_val = E1000_SUCCESS;
                goto out;
        }
 
@@ -501,7 +508,7 @@ s32 igb_check_for_copper_link(struct e1000_hw *hw)
         * link.  If so, then we want to get the current speed/duplex
         * of the PHY.
         */
-       ret_val = igb_phy_has_link(hw, 1, 0, &link);
+       ret_val = e1000_phy_has_link_generic(hw, 1, 0, &link);
        if (ret_val)
                goto out;
 
@@ -514,7 +521,7 @@ s32 igb_check_for_copper_link(struct e1000_hw *hw)
         * Check if there was DownShift, must be checked
         * immediately after link-up
         */
-       igb_check_downshift(hw);
+       e1000_check_downshift_generic(hw);
 
        /*
         * If we are forcing speed/duplex, then we simply return since
@@ -530,7 +537,7 @@ s32 igb_check_for_copper_link(struct e1000_hw *hw)
         * of MAC speed/duplex configuration.  So we only need to
         * configure Collision Distance in the MAC.
         */
-       igb_config_collision_dist(hw);
+       e1000_config_collision_dist_generic(hw);
 
        /*
         * Configure Flow Control now that Auto-Neg has completed.
@@ -538,16 +545,199 @@ s32 igb_check_for_copper_link(struct e1000_hw *hw)
         * settings because we may have had to re-autoneg with a
         * different link partner.
         */
-       ret_val = igb_config_fc_after_link_up(hw);
-       if (ret_val)
-               hw_dbg(hw, "Error configuring flow control\n");
+       ret_val = e1000_config_fc_after_link_up_generic(hw);
+       if (ret_val) {
+               DEBUGOUT("Error configuring flow control\n");
+       }
+
+out:
+       return ret_val;
+}
+
+/**
+ *  e1000_check_for_fiber_link_generic - Check for link (Fiber)
+ *  @hw: pointer to the HW structure
+ *
+ *  Checks for link up on the hardware.  If link is not up and we have
+ *  a signal, then we need to force link up.
+ **/
+s32 e1000_check_for_fiber_link_generic(struct e1000_hw *hw)
+{
+       struct e1000_mac_info *mac = &hw->mac;
+       u32 rxcw;
+       u32 ctrl;
+       u32 status;
+       s32 ret_val = E1000_SUCCESS;
+
+       DEBUGFUNC("e1000_check_for_fiber_link_generic");
+
+       ctrl = E1000_READ_REG(hw, E1000_CTRL);
+       status = E1000_READ_REG(hw, E1000_STATUS);
+       rxcw = E1000_READ_REG(hw, E1000_RXCW);
+
+       /*
+        * If we don't have link (auto-negotiation failed or link partner
+        * cannot auto-negotiate), the cable is plugged in (we have signal),
+        * and our link partner is not trying to auto-negotiate with us (we
+        * are receiving idles or data), we need to force link up. We also
+        * need to give auto-negotiation time to complete, in case the cable
+        * was just plugged in. The autoneg_failed flag does this.
+        */
+       /* (ctrl & E1000_CTRL_SWDPIN1) == 1 == have signal */
+       if ((ctrl & E1000_CTRL_SWDPIN1) && (!(status & E1000_STATUS_LU)) &&
+           (!(rxcw & E1000_RXCW_C))) {
+               if (mac->autoneg_failed == 0) {
+                       mac->autoneg_failed = 1;
+                       goto out;
+               }
+               DEBUGOUT("NOT RXing /C/, disable AutoNeg and force link.\n");
+
+               /* Disable auto-negotiation in the TXCW register */
+               E1000_WRITE_REG(hw, E1000_TXCW, (mac->txcw & ~E1000_TXCW_ANE));
+
+               /* Force link-up and also force full-duplex. */
+               ctrl = E1000_READ_REG(hw, E1000_CTRL);
+               ctrl |= (E1000_CTRL_SLU | E1000_CTRL_FD);
+               E1000_WRITE_REG(hw, E1000_CTRL, ctrl);
+
+               /* Configure Flow Control after forcing link up. */
+               ret_val = e1000_config_fc_after_link_up_generic(hw);
+               if (ret_val) {
+                       DEBUGOUT("Error configuring flow control\n");
+                       goto out;
+               }
+       } else if ((ctrl & E1000_CTRL_SLU) && (rxcw & E1000_RXCW_C)) {
+               /*
+                * If we are forcing link and we are receiving /C/ ordered
+                * sets, re-enable auto-negotiation in the TXCW register
+                * and disable forced link in the Device Control register
+                * in an attempt to auto-negotiate with our link partner.
+                */
+               DEBUGOUT("RXing /C/, enable AutoNeg and stop forcing link.\n");
+               E1000_WRITE_REG(hw, E1000_TXCW, mac->txcw);
+               E1000_WRITE_REG(hw, E1000_CTRL, (ctrl & ~E1000_CTRL_SLU));
+
+               mac->serdes_has_link = true;
+       }
+
+out:
+       return ret_val;
+}
+
+/**
+ *  e1000_check_for_serdes_link_generic - Check for link (Serdes)
+ *  @hw: pointer to the HW structure
+ *
+ *  Checks for link up on the hardware.  If link is not up and we have
+ *  a signal, then we need to force link up.
+ **/
+s32 e1000_check_for_serdes_link_generic(struct e1000_hw *hw)
+{
+       struct e1000_mac_info *mac = &hw->mac;
+       u32 rxcw;
+       u32 ctrl;
+       u32 status;
+       s32 ret_val = E1000_SUCCESS;
+
+       DEBUGFUNC("e1000_check_for_serdes_link_generic");
+
+       ctrl = E1000_READ_REG(hw, E1000_CTRL);
+       status = E1000_READ_REG(hw, E1000_STATUS);
+       rxcw = E1000_READ_REG(hw, E1000_RXCW);
+
+       /*
+        * If we don't have link (auto-negotiation failed or link partner
+        * cannot auto-negotiate), and our link partner is not trying to
+        * auto-negotiate with us (we are receiving idles or data),
+        * we need to force link up. We also need to give auto-negotiation
+        * time to complete.
+        */
+       /* (ctrl & E1000_CTRL_SWDPIN1) == 1 == have signal */
+       if ((!(status & E1000_STATUS_LU)) && (!(rxcw & E1000_RXCW_C))) {
+               if (mac->autoneg_failed == 0) {
+                       mac->autoneg_failed = 1;
+                       goto out;
+               }
+               DEBUGOUT("NOT RXing /C/, disable AutoNeg and force link.\n");
+
+               /* Disable auto-negotiation in the TXCW register */
+               E1000_WRITE_REG(hw, E1000_TXCW, (mac->txcw & ~E1000_TXCW_ANE));
+
+               /* Force link-up and also force full-duplex. */
+               ctrl = E1000_READ_REG(hw, E1000_CTRL);
+               ctrl |= (E1000_CTRL_SLU | E1000_CTRL_FD);
+               E1000_WRITE_REG(hw, E1000_CTRL, ctrl);
+
+               /* Configure Flow Control after forcing link up. */
+               ret_val = e1000_config_fc_after_link_up_generic(hw);
+               if (ret_val) {
+                       DEBUGOUT("Error configuring flow control\n");
+                       goto out;
+               }
+       } else if ((ctrl & E1000_CTRL_SLU) && (rxcw & E1000_RXCW_C)) {
+               /*
+                * If we are forcing link and we are receiving /C/ ordered
+                * sets, re-enable auto-negotiation in the TXCW register
+                * and disable forced link in the Device Control register
+                * in an attempt to auto-negotiate with our link partner.
+                */
+               DEBUGOUT("RXing /C/, enable AutoNeg and stop forcing link.\n");
+               E1000_WRITE_REG(hw, E1000_TXCW, mac->txcw);
+               E1000_WRITE_REG(hw, E1000_CTRL, (ctrl & ~E1000_CTRL_SLU));
+
+               mac->serdes_has_link = true;
+       } else if (!(E1000_TXCW_ANE & E1000_READ_REG(hw, E1000_TXCW))) {
+               /*
+                * If we force link for non-auto-negotiation switch, check
+                * link status based on MAC synchronization for internal
+                * serdes media type.
+                */
+               /* SYNCH bit and IV bit are sticky. */
+               usec_delay(10);
+               rxcw = E1000_READ_REG(hw, E1000_RXCW);
+               if (rxcw & E1000_RXCW_SYNCH) {
+                       if (!(rxcw & E1000_RXCW_IV)) {
+                               mac->serdes_has_link = true;
+                               DEBUGOUT("SERDES: Link up - forced.\n");
+                       }
+               } else {
+                       mac->serdes_has_link = false;
+                       DEBUGOUT("SERDES: Link down - force failed.\n");
+               }
+       }
+
+       if (E1000_TXCW_ANE & E1000_READ_REG(hw, E1000_TXCW)) {
+               status = E1000_READ_REG(hw, E1000_STATUS);
+               if (status & E1000_STATUS_LU) {
+                       /* SYNCH bit and IV bit are sticky, so reread rxcw. */
+                       usec_delay(10);
+                       rxcw = E1000_READ_REG(hw, E1000_RXCW);
+                       if (rxcw & E1000_RXCW_SYNCH) {
+                               if (!(rxcw & E1000_RXCW_IV)) {
+                                       mac->serdes_has_link = true;
+                                       DEBUGOUT("SERDES: Link up - autoneg "
+                                          "completed sucessfully.\n");
+                               } else {
+                                       mac->serdes_has_link = false;
+                                       DEBUGOUT("SERDES: Link down - invalid"
+                                          "codewords detected in autoneg.\n");
+                               }
+                       } else {
+                               mac->serdes_has_link = false;
+                               DEBUGOUT("SERDES: Link down - no sync.\n");
+                       }
+               } else {
+                       mac->serdes_has_link = false;
+                       DEBUGOUT("SERDES: Link down - autoneg failed\n");
+               }
+       }
 
 out:
        return ret_val;
 }
 
 /**
- *  e1000_setup_link - Setup flow control and link settings
+ *  e1000_setup_link_generic - Setup flow control and link settings
  *  @hw: pointer to the HW structure
  *
  *  Determines which flow control settings to use, then configures flow
@@ -556,20 +746,29 @@ out:
  *  should be established.  Assumes the hardware has previously been reset
  *  and the transmitter and receiver are not enabled.
  **/
-s32 igb_setup_link(struct e1000_hw *hw)
+s32 e1000_setup_link_generic(struct e1000_hw *hw)
 {
-       s32 ret_val = 0;
+       s32 ret_val = E1000_SUCCESS;
+
+       DEBUGFUNC("e1000_setup_link_generic");
 
        /*
         * In the case of the phy reset being blocked, we already have a link.
         * We do not need to set it up again.
         */
-       if (igb_check_reset_block(hw))
-               goto out;
+       if (hw->phy.ops.check_reset_block)
+               if (hw->phy.ops.check_reset_block(hw))
+                       goto out;
 
-       ret_val = igb_set_default_fc(hw);
-       if (ret_val)
-               goto out;
+       /*
+        * If flow control is set to default, set flow control based on
+        * the EEPROM flow control settings.
+        */
+       if (hw->fc.type == e1000_fc_default) {
+               ret_val = e1000_set_default_fc_generic(hw);
+               if (ret_val)
+                       goto out;
+       }
 
        /*
         * We want to save off the original Flow Control configuration just
@@ -578,7 +777,7 @@ s32 igb_setup_link(struct e1000_hw *hw)
         */
        hw->fc.original_type = hw->fc.type;
 
-       hw_dbg(hw, "After fix-ups FlowControl is now = %x\n", hw->fc.type);
+       DEBUGOUT1("After fix-ups FlowControl is now = %x\n", hw->fc.type);
 
        /* Call the necessary media_type subroutine to configure the link. */
        ret_val = hw->mac.ops.setup_physical_interface(hw);
@@ -591,54 +790,239 @@ s32 igb_setup_link(struct e1000_hw *hw)
         * control is disabled, because it does not hurt anything to
         * initialize these registers.
         */
-       hw_dbg(hw,
-              "Initializing the Flow Control address, type and timer regs\n");
-       wr32(E1000_FCT, FLOW_CONTROL_TYPE);
-       wr32(E1000_FCAH, FLOW_CONTROL_ADDRESS_HIGH);
-       wr32(E1000_FCAL, FLOW_CONTROL_ADDRESS_LOW);
+       DEBUGOUT("Initializing the Flow Control address, type and timer regs\n");
+       E1000_WRITE_REG(hw, E1000_FCT, FLOW_CONTROL_TYPE);
+       E1000_WRITE_REG(hw, E1000_FCAH, FLOW_CONTROL_ADDRESS_HIGH);
+       E1000_WRITE_REG(hw, E1000_FCAL, FLOW_CONTROL_ADDRESS_LOW);
+
+       E1000_WRITE_REG(hw, E1000_FCTTV, hw->fc.pause_time);
+
+       ret_val = e1000_set_fc_watermarks_generic(hw);
+
+out:
+       return ret_val;
+}
+
+/**
+ *  e1000_setup_fiber_serdes_link_generic - Setup link for fiber/serdes
+ *  @hw: pointer to the HW structure
+ *
+ *  Configures collision distance and flow control for fiber and serdes
+ *  links.  Upon successful setup, poll for link.
+ **/
+s32 e1000_setup_fiber_serdes_link_generic(struct e1000_hw *hw)
+{
+       u32 ctrl;
+       s32 ret_val = E1000_SUCCESS;
+
+       DEBUGFUNC("e1000_setup_fiber_serdes_link_generic");
+
+       ctrl = E1000_READ_REG(hw, E1000_CTRL);
+
+       /* Take the link out of reset */
+       ctrl &= ~E1000_CTRL_LRST;
+
+       e1000_config_collision_dist_generic(hw);
+
+       ret_val = e1000_commit_fc_settings_generic(hw);
+       if (ret_val)
+               goto out;
+
+       /*
+        * Since auto-negotiation is enabled, take the link out of reset (the
+        * link will be in reset, because we previously reset the chip). This
+        * will restart auto-negotiation.  If auto-negotiation is successful
+        * then the link-up status bit will be set and the flow control enable
+        * bits (RFCE and TFCE) will be set according to their negotiated value.
+        */
+       DEBUGOUT("Auto-negotiation enabled\n");
 
-       wr32(E1000_FCTTV, hw->fc.pause_time);
+       E1000_WRITE_REG(hw, E1000_CTRL, ctrl);
+       E1000_WRITE_FLUSH(hw);
+       msec_delay(1);
 
-       ret_val = igb_set_fc_watermarks(hw);
+       /*
+        * For these adapters, the SW definable pin 1 is set when the optics
+        * detect a signal.  If we have a signal, then poll for a "Link-Up"
+        * indication.
+        */
+       if (hw->phy.media_type == e1000_media_type_internal_serdes ||
+           (E1000_READ_REG(hw, E1000_CTRL) & E1000_CTRL_SWDPIN1)) {
+               ret_val = e1000_poll_fiber_serdes_link_generic(hw);
+       } else {
+               DEBUGOUT("No signal detected\n");
+       }
 
 out:
        return ret_val;
 }
 
 /**
- *  e1000_config_collision_dist - Configure collision distance
+ *  e1000_config_collision_dist_generic - Configure collision distance
  *  @hw: pointer to the HW structure
  *
  *  Configures the collision distance to the default value and is used
  *  during link setup. Currently no func pointer exists and all
  *  implementations are handled in the generic version of this function.
  **/
-void igb_config_collision_dist(struct e1000_hw *hw)
+void e1000_config_collision_dist_generic(struct e1000_hw *hw)
 {
        u32 tctl;
 
-       tctl = rd32(E1000_TCTL);
+       DEBUGFUNC("e1000_config_collision_dist_generic");
+
+       tctl = E1000_READ_REG(hw, E1000_TCTL);
 
        tctl &= ~E1000_TCTL_COLD;
        tctl |= E1000_COLLISION_DISTANCE << E1000_COLD_SHIFT;
 
-       wr32(E1000_TCTL, tctl);
-       wrfl();
+       E1000_WRITE_REG(hw, E1000_TCTL, tctl);
+       E1000_WRITE_FLUSH(hw);
+}
+
+/**
+ *  e1000_poll_fiber_serdes_link_generic - Poll for link up
+ *  @hw: pointer to the HW structure
+ *
+ *  Polls for link up by reading the status register, if link fails to come
+ *  up with auto-negotiation, then the link is forced if a signal is detected.
+ **/
+s32 e1000_poll_fiber_serdes_link_generic(struct e1000_hw *hw)
+{
+       struct e1000_mac_info *mac = &hw->mac;
+       u32 i, status;
+       s32 ret_val = E1000_SUCCESS;
+
+       DEBUGFUNC("e1000_poll_fiber_serdes_link_generic");
+
+       /*
+        * If we have a signal (the cable is plugged in, or assumed true for
+        * serdes media) then poll for a "Link-Up" indication in the Device
+        * Status Register.  Time-out if a link isn't seen in 500 milliseconds
+        * seconds (Auto-negotiation should complete in less than 500
+        * milliseconds even if the other end is doing it in SW).
+        */
+       for (i = 0; i < FIBER_LINK_UP_LIMIT; i++) {
+               msec_delay(10);
+               status = E1000_READ_REG(hw, E1000_STATUS);
+               if (status & E1000_STATUS_LU)
+                       break;
+       }
+       if (i == FIBER_LINK_UP_LIMIT) {
+               DEBUGOUT("Never got a valid link from auto-neg!!!\n");
+               mac->autoneg_failed = 1;
+               /*
+                * AutoNeg failed to achieve a link, so we'll call
+                * mac->check_for_link. This routine will force the
+                * link up if we detect a signal. This will allow us to
+                * communicate with non-autonegotiating link partners.
+                */
+               ret_val = hw->mac.ops.check_for_link(hw);
+               if (ret_val) {
+                       DEBUGOUT("Error while checking for link\n");
+                       goto out;
+               }
+               mac->autoneg_failed = 0;
+       } else {
+               mac->autoneg_failed = 0;
+               DEBUGOUT("Valid Link Found\n");
+       }
+
+out:
+       return ret_val;
+}
+
+/**
+ *  e1000_commit_fc_settings_generic - Configure flow control
+ *  @hw: pointer to the HW structure
+ *
+ *  Write the flow control settings to the Transmit Config Word Register (TXCW)
+ *  base on the flow control settings in e1000_mac_info.
+ **/
+static s32 e1000_commit_fc_settings_generic(struct e1000_hw *hw)
+{
+       struct e1000_mac_info *mac = &hw->mac;
+       u32 txcw;
+       s32 ret_val = E1000_SUCCESS;
+
+       DEBUGFUNC("e1000_commit_fc_settings_generic");
+
+       /*
+        * Check for a software override of the flow control settings, and
+        * setup the device accordingly.  If auto-negotiation is enabled, then
+        * software will have to set the "PAUSE" bits to the correct value in
+        * the Transmit Config Word Register (TXCW) and re-start auto-
+        * negotiation.  However, if auto-negotiation is disabled, then
+        * software will have to manually configure the two flow control enable
+        * bits in the CTRL register.
+        *
+        * The possible values of the "fc" parameter are:
+        *      0:  Flow control is completely disabled
+        *      1:  Rx flow control is enabled (we can receive pause frames,
+        *          but not send pause frames).
+        *      2:  Tx flow control is enabled (we can send pause frames but we
+        *          do not support receiving pause frames).
+        *      3:  Both Rx and Tx flow control (symmetric) are enabled.
+        */
+       switch (hw->fc.type) {
+       case e1000_fc_none:
+               /* Flow control completely disabled by a software over-ride. */
+               txcw = (E1000_TXCW_ANE | E1000_TXCW_FD);
+               break;
+       case e1000_fc_rx_pause:
+               /*
+                * Rx Flow control is enabled and Tx Flow control is disabled
+                * by a software over-ride. Since there really isn't a way to
+                * advertise that we are capable of Rx Pause ONLY, we will
+                * advertise that we support both symmetric and asymmetric RX
+                * PAUSE.  Later, we will disable the adapter's ability to send
+                * PAUSE frames.
+                */
+               txcw = (E1000_TXCW_ANE | E1000_TXCW_FD | E1000_TXCW_PAUSE_MASK);
+               break;
+       case e1000_fc_tx_pause:
+               /*
+                * Tx Flow control is enabled, and Rx Flow control is disabled,
+                * by a software over-ride.
+                */
+               txcw = (E1000_TXCW_ANE | E1000_TXCW_FD | E1000_TXCW_ASM_DIR);
+               break;
+       case e1000_fc_full:
+               /*
+                * Flow control (both Rx and Tx) is enabled by a software
+                * over-ride.
+                */
+               txcw = (E1000_TXCW_ANE | E1000_TXCW_FD | E1000_TXCW_PAUSE_MASK);
+               break;
+       default:
+               DEBUGOUT("Flow control param set incorrectly\n");
+               ret_val = -E1000_ERR_CONFIG;
+               goto out;
+               break;
+       }
+
+       E1000_WRITE_REG(hw, E1000_TXCW, txcw);
+       mac->txcw = txcw;
+
+out:
+       return ret_val;
 }
 
 /**
- *  e1000_set_fc_watermarks - Set flow control high/low watermarks
+ *  e1000_set_fc_watermarks_generic - Set flow control high/low watermarks
  *  @hw: pointer to the HW structure
  *
  *  Sets the flow control high/low threshold (watermark) registers.  If
  *  flow control XON frame transmission is enabled, then set XON frame
- *  tansmission as well.
+ *  transmission as well.
  **/
-static s32 igb_set_fc_watermarks(struct e1000_hw *hw)
+s32 e1000_set_fc_watermarks_generic(struct e1000_hw *hw)
 {
-       s32 ret_val = 0;
+       s32 ret_val = E1000_SUCCESS;
        u32 fcrtl = 0, fcrth = 0;
 
+       DEBUGFUNC("e1000_set_fc_watermarks_generic");
+
        /*
         * Set the flow control receive threshold registers.  Normally,
         * these registers will be set to a default threshold that may be
@@ -658,24 +1042,26 @@ static s32 igb_set_fc_watermarks(struct e1000_hw *hw)
 
                fcrth = hw->fc.high_water;
        }
-       wr32(E1000_FCRTL, fcrtl);
-       wr32(E1000_FCRTH, fcrth);
+       E1000_WRITE_REG(hw, E1000_FCRTL, fcrtl);
+       E1000_WRITE_REG(hw, E1000_FCRTH, fcrth);
 
        return ret_val;
 }
 
 /**
- *  e1000_set_default_fc - Set flow control default values
+ *  e1000_set_default_fc_generic - Set flow control default values
  *  @hw: pointer to the HW structure
  *
  *  Read the EEPROM for the default values for flow control and store the
  *  values.
  **/
-static s32 igb_set_default_fc(struct e1000_hw *hw)
+static s32 e1000_set_default_fc_generic(struct e1000_hw *hw)
 {
-       s32 ret_val = 0;
+       s32 ret_val = E1000_SUCCESS;
        u16 nvm_data;
 
+       DEBUGFUNC("e1000_set_default_fc_generic");
+
        /*
         * Read and store word 0x0F of the EEPROM. This word contains bits
         * that determine the hardware's default PAUSE (flow control) mode,
@@ -685,11 +1071,10 @@ static s32 igb_set_default_fc(struct e1000_hw *hw)
         * control setting, then the variable hw->fc will
         * be initialized based on a value in the EEPROM.
         */
-       ret_val = hw->nvm.ops.read_nvm(hw, NVM_INIT_CONTROL2_REG, 1,
-                                      &nvm_data);
+       ret_val = hw->nvm.ops.read(hw, NVM_INIT_CONTROL2_REG, 1, &nvm_data);
 
        if (ret_val) {
-               hw_dbg(hw, "NVM Read Error\n");
+               DEBUGOUT("NVM Read Error\n");
                goto out;
        }
 
@@ -706,7 +1091,7 @@ out:
 }
 
 /**
- *  e1000_force_mac_fc - Force the MAC's flow control settings
+ *  e1000_force_mac_fc_generic - Force the MAC's flow control settings
  *  @hw: pointer to the HW structure
  *
  *  Force the MAC's flow control settings.  Sets the TFCE and RFCE bits in the
@@ -715,12 +1100,14 @@ out:
  *  autonegotiation is managed by the PHY rather than the MAC.  Software must
  *  also configure these bits when link is forced on a fiber connection.
  **/
-s32 igb_force_mac_fc(struct e1000_hw *hw)
+s32 e1000_force_mac_fc_generic(struct e1000_hw *hw)
 {
        u32 ctrl;
-       s32 ret_val = 0;
+       s32 ret_val = E1000_SUCCESS;
+
+       DEBUGFUNC("e1000_force_mac_fc_generic");
 
-       ctrl = rd32(E1000_CTRL);
+       ctrl = E1000_READ_REG(hw, E1000_CTRL);
 
        /*
         * Because we didn't get link via the internal auto-negotiation
@@ -737,10 +1124,10 @@ s32 igb_force_mac_fc(struct e1000_hw *hw)
         *          frames but not send pause frames).
         *      2:  Tx flow control is enabled (we can send pause frames
         *          frames but we do not receive pause frames).
-        *      3:  Both Rx and TX flow control (symmetric) is enabled.
+        *      3:  Both Rx and Tx flow control (symmetric) is enabled.
         *  other:  No other values should be possible at this point.
         */
-       hw_dbg(hw, "hw->fc.type = %u\n", hw->fc.type);
+       DEBUGOUT1("hw->fc.type = %u\n", hw->fc.type);
 
        switch (hw->fc.type) {
        case e1000_fc_none:
@@ -758,19 +1145,19 @@ s32 igb_force_mac_fc(struct e1000_hw *hw)
                ctrl |= (E1000_CTRL_TFCE | E1000_CTRL_RFCE);
                break;
        default:
-               hw_dbg(hw, "Flow control param set incorrectly\n");
+               DEBUGOUT("Flow control param set incorrectly\n");
                ret_val = -E1000_ERR_CONFIG;
                goto out;
        }
 
-       wr32(E1000_CTRL, ctrl);
+       E1000_WRITE_REG(hw, E1000_CTRL, ctrl);
 
 out:
        return ret_val;
 }
 
 /**
- *  e1000_config_fc_after_link_up - Configures flow control after link
+ *  e1000_config_fc_after_link_up_generic - Configures flow control after link
  *  @hw: pointer to the HW structure
  *
  *  Checks the status of auto-negotiation after link up to ensure that the
@@ -779,13 +1166,15 @@ out:
  *  and did not fail, then we configure flow control based on our link
  *  partner.
  **/
-s32 igb_config_fc_after_link_up(struct e1000_hw *hw)
+s32 e1000_config_fc_after_link_up_generic(struct e1000_hw *hw)
 {
        struct e1000_mac_info *mac = &hw->mac;
-       s32 ret_val = 0;
+       s32 ret_val = E1000_SUCCESS;
        u16 mii_status_reg, mii_nway_adv_reg, mii_nway_lp_ability_reg;
        u16 speed, duplex;
 
+       DEBUGFUNC("e1000_config_fc_after_link_up_generic");
+
        /*
         * Check for the case where we have fiber media and auto-neg failed
         * so we had to force link.  In this case, we need to force the
@@ -794,14 +1183,14 @@ s32 igb_config_fc_after_link_up(struct e1000_hw *hw)
        if (mac->autoneg_failed) {
                if (hw->phy.media_type == e1000_media_type_fiber ||
                    hw->phy.media_type == e1000_media_type_internal_serdes)
-                       ret_val = igb_force_mac_fc(hw);
+                       ret_val = e1000_force_mac_fc_generic(hw);
        } else {
                if (hw->phy.media_type == e1000_media_type_copper)
-                       ret_val = igb_force_mac_fc(hw);
+                       ret_val = e1000_force_mac_fc_generic(hw);
        }
 
        if (ret_val) {
-               hw_dbg(hw, "Error forcing flow control settings\n");
+               DEBUGOUT("Error forcing flow control settings\n");
                goto out;
        }
 
@@ -817,18 +1206,16 @@ s32 igb_config_fc_after_link_up(struct e1000_hw *hw)
                 * has completed.  We read this twice because this reg has
                 * some "sticky" (latched) bits.
                 */
-               ret_val = hw->phy.ops.read_phy_reg(hw, PHY_STATUS,
-                                                  &mii_status_reg);
+               ret_val = hw->phy.ops.read_reg(hw, PHY_STATUS, &mii_status_reg);
                if (ret_val)
                        goto out;
-               ret_val = hw->phy.ops.read_phy_reg(hw, PHY_STATUS,
-                                                  &mii_status_reg);
+               ret_val = hw->phy.ops.read_reg(hw, PHY_STATUS, &mii_status_reg);
                if (ret_val)
                        goto out;
 
                if (!(mii_status_reg & MII_SR_AUTONEG_COMPLETE)) {
-                       hw_dbg(hw, "Copper PHY and Auto Neg "
-                                "has not completed.\n");
+                       DEBUGOUT("Copper PHY and Auto Neg "
+                                "has not completed.\n");
                        goto out;
                }
 
@@ -839,12 +1226,12 @@ s32 igb_config_fc_after_link_up(struct e1000_hw *hw)
                 * Page Ability Register (Address 5) to determine how
                 * flow control was negotiated.
                 */
-               ret_val = hw->phy.ops.read_phy_reg(hw, PHY_AUTONEG_ADV,
-                                           &mii_nway_adv_reg);
+               ret_val = hw->phy.ops.read_reg(hw, PHY_AUTONEG_ADV,
+                                            &mii_nway_adv_reg);
                if (ret_val)
                        goto out;
-               ret_val = hw->phy.ops.read_phy_reg(hw, PHY_LP_ABILITY,
-                                           &mii_nway_lp_ability_reg);
+               ret_val = hw->phy.ops.read_reg(hw, PHY_LP_ABILITY,
+                                            &mii_nway_lp_ability_reg);
                if (ret_val)
                        goto out;
 
@@ -885,7 +1272,7 @@ s32 igb_config_fc_after_link_up(struct e1000_hw *hw)
                if ((mii_nway_adv_reg & NWAY_AR_PAUSE) &&
                    (mii_nway_lp_ability_reg & NWAY_LPAR_PAUSE)) {
                        /*
-                        * Now we need to check if the user selected RX ONLY
+                        * Now we need to check if the user selected Rx ONLY
                         * of pause frames.  In this case, we had to advertise
                         * FULL flow control because we could not advertise RX
                         * ONLY. Hence, we must now check to see if we need to
@@ -893,11 +1280,11 @@ s32 igb_config_fc_after_link_up(struct e1000_hw *hw)
                         */
                        if (hw->fc.original_type == e1000_fc_full) {
                                hw->fc.type = e1000_fc_full;
-                               hw_dbg(hw, "Flow Control = FULL.\r\n");
+                               DEBUGOUT("Flow Control = FULL.\r\n");
                        } else {
                                hw->fc.type = e1000_fc_rx_pause;
-                               hw_dbg(hw, "Flow Control = "
-                                        "RX PAUSE frames only.\r\n");
+                               DEBUGOUT("Flow Control = "
+                                        "RX PAUSE frames only.\r\n");
                        }
                }
                /*
@@ -909,11 +1296,11 @@ s32 igb_config_fc_after_link_up(struct e1000_hw *hw)
                 *   0   |    1    |   1   |    1    | e1000_fc_tx_pause
                 */
                else if (!(mii_nway_adv_reg & NWAY_AR_PAUSE) &&
-                         (mii_nway_adv_reg & NWAY_AR_ASM_DIR) &&
-                         (mii_nway_lp_ability_reg & NWAY_LPAR_PAUSE) &&
-                         (mii_nway_lp_ability_reg & NWAY_LPAR_ASM_DIR)) {
+                         (mii_nway_adv_reg & NWAY_AR_ASM_DIR) &&
+                         (mii_nway_lp_ability_reg & NWAY_LPAR_PAUSE) &&
+                         (mii_nway_lp_ability_reg & NWAY_LPAR_ASM_DIR)) {
                        hw->fc.type = e1000_fc_tx_pause;
-                       hw_dbg(hw, "Flow Control = TX PAUSE frames only.\r\n");
+                       DEBUGOUT("Flow Control = TX PAUSE frames only.\r\n");
                }
                /*
                 * For transmitting PAUSE frames ONLY.
@@ -924,41 +1311,18 @@ s32 igb_config_fc_after_link_up(struct e1000_hw *hw)
                 *   1   |    1    |   0   |    1    | e1000_fc_rx_pause
                 */
                else if ((mii_nway_adv_reg & NWAY_AR_PAUSE) &&
-                        (mii_nway_adv_reg & NWAY_AR_ASM_DIR) &&
-                        !(mii_nway_lp_ability_reg & NWAY_LPAR_PAUSE) &&
-                        (mii_nway_lp_ability_reg & NWAY_LPAR_ASM_DIR)) {
+                        (mii_nway_adv_reg & NWAY_AR_ASM_DIR) &&
+                        !(mii_nway_lp_ability_reg & NWAY_LPAR_PAUSE) &&
+                        (mii_nway_lp_ability_reg & NWAY_LPAR_ASM_DIR)) {
                        hw->fc.type = e1000_fc_rx_pause;
-                       hw_dbg(hw, "Flow Control = RX PAUSE frames only.\r\n");
-               }
-               /*
-                * Per the IEEE spec, at this point flow control should be
-                * disabled.  However, we want to consider that we could
-                * be connected to a legacy switch that doesn't advertise
-                * desired flow control, but can be forced on the link
-                * partner.  So if we advertised no flow control, that is
-                * what we will resolve to.  If we advertised some kind of
-                * receive capability (Rx Pause Only or Full Flow Control)
-                * and the link partner advertised none, we will configure
-                * ourselves to enable Rx Flow Control only.  We can do
-                * this safely for two reasons:  If the link partner really
-                * didn't want flow control enabled, and we enable Rx, no
-                * harm done since we won't be receiving any PAUSE frames
-                * anyway.  If the intent on the link partner was to have
-                * flow control enabled, then by us enabling RX only, we
-                * can at least receive pause frames and process them.
-                * This is a good idea because in most cases, since we are
-                * predominantly a server NIC, more times than not we will
-                * be asked to delay transmission of packets than asking
-                * our link partner to pause transmission of frames.
-                */
-               else if ((hw->fc.original_type == e1000_fc_none ||
-                         hw->fc.original_type == e1000_fc_tx_pause) ||
-                        hw->fc.strict_ieee) {
-                       hw->fc.type = e1000_fc_none;
-                       hw_dbg(hw, "Flow Control = NONE.\r\n");
+                       DEBUGOUT("Flow Control = RX PAUSE frames only.\r\n");
                } else {
-                       hw->fc.type = e1000_fc_rx_pause;
-                       hw_dbg(hw, "Flow Control = RX PAUSE frames only.\r\n");
+                       /*
+                        * Per the IEEE spec, at this point flow control
+                        * should be disabled.
+                        */
+                       hw->fc.type = e1000_fc_none;
+                       DEBUGOUT("Flow Control = NONE.\r\n");
                }
 
                /*
@@ -966,9 +1330,9 @@ s32 igb_config_fc_after_link_up(struct e1000_hw *hw)
                 * negotiated to HALF DUPLEX, flow control should not be
                 * enabled per IEEE 802.3 spec.
                 */
-               ret_val = hw->mac.ops.get_speed_and_duplex(hw, &speed, &duplex);
+               ret_val = mac->ops.get_link_up_info(hw, &speed, &duplex);
                if (ret_val) {
-                       hw_dbg(hw, "Error getting link speed and duplex\n");
+                       DEBUGOUT("Error getting link speed and duplex\n");
                        goto out;
                }
 
@@ -979,9 +1343,9 @@ s32 igb_config_fc_after_link_up(struct e1000_hw *hw)
                 * Now we call a subroutine to actually force the MAC
                 * controller to use the correct flow control settings.
                 */
-               ret_val = igb_force_mac_fc(hw);
+               ret_val = e1000_force_mac_fc_generic(hw);
                if (ret_val) {
-                       hw_dbg(hw, "Error forcing flow control settings\n");
+                       DEBUGOUT("Error forcing flow control settings\n");
                        goto out;
                }
        }
@@ -991,7 +1355,7 @@ out:
 }
 
 /**
- *  e1000_get_speed_and_duplex_copper - Retreive current speed/duplex
+ *  e1000_get_speed_and_duplex_copper_generic - Retrieve current speed/duplex
  *  @hw: pointer to the HW structure
  *  @speed: stores the current speed
  *  @duplex: stores the current duplex
@@ -999,79 +1363,103 @@ out:
  *  Read the status register for the current speed/duplex and store the current
  *  speed and duplex for copper connections.
  **/
-s32 igb_get_speed_and_duplex_copper(struct e1000_hw *hw, u16 *speed,
-                                     u16 *duplex)
+s32 e1000_get_speed_and_duplex_copper_generic(struct e1000_hw *hw, u16 *speed,
+                                              u16 *duplex)
 {
        u32 status;
 
-       status = rd32(E1000_STATUS);
+       DEBUGFUNC("e1000_get_speed_and_duplex_copper_generic");
+
+       status = E1000_READ_REG(hw, E1000_STATUS);
        if (status & E1000_STATUS_SPEED_1000) {
                *speed = SPEED_1000;
-               hw_dbg(hw, "1000 Mbs, ");
+               DEBUGOUT("1000 Mbs, ");
        } else if (status & E1000_STATUS_SPEED_100) {
                *speed = SPEED_100;
-               hw_dbg(hw, "100 Mbs, ");
+               DEBUGOUT("100 Mbs, ");
        } else {
                *speed = SPEED_10;
-               hw_dbg(hw, "10 Mbs, ");
+               DEBUGOUT("10 Mbs, ");
        }
 
        if (status & E1000_STATUS_FD) {
                *duplex = FULL_DUPLEX;
-               hw_dbg(hw, "Full Duplex\n");
+               DEBUGOUT("Full Duplex\n");
        } else {
                *duplex = HALF_DUPLEX;
-               hw_dbg(hw, "Half Duplex\n");
+               DEBUGOUT("Half Duplex\n");
        }
 
-       return 0;
+       return E1000_SUCCESS;
 }
 
 /**
- *  e1000_get_hw_semaphore - Acquire hardware semaphore
+ *  e1000_get_speed_and_duplex_fiber_generic - Retrieve current speed/duplex
+ *  @hw: pointer to the HW structure
+ *  @speed: stores the current speed
+ *  @duplex: stores the current duplex
+ *
+ *  Sets the speed and duplex to gigabit full duplex (the only possible option)
+ *  for fiber/serdes links.
+ **/
+s32 e1000_get_speed_and_duplex_fiber_serdes_generic(struct e1000_hw *hw,
+                                                    u16 *speed, u16 *duplex)
+{
+       DEBUGFUNC("e1000_get_speed_and_duplex_fiber_serdes_generic");
+
+       *speed = SPEED_1000;
+       *duplex = FULL_DUPLEX;
+
+       return E1000_SUCCESS;
+}
+
+/**
+ *  e1000_get_hw_semaphore_generic - Acquire hardware semaphore
  *  @hw: pointer to the HW structure
  *
  *  Acquire the HW semaphore to access the PHY or NVM
  **/
-s32 igb_get_hw_semaphore(struct e1000_hw *hw)
+s32 e1000_get_hw_semaphore_generic(struct e1000_hw *hw)
 {
        u32 swsm;
-       s32 ret_val = 0;
+       s32 ret_val = E1000_SUCCESS;
        s32 timeout = hw->nvm.word_size + 1;
        s32 i = 0;
 
+       DEBUGFUNC("e1000_get_hw_semaphore_generic");
+
        /* Get the SW semaphore */
        while (i < timeout) {
-               swsm = rd32(E1000_SWSM);
+               swsm = E1000_READ_REG(hw, E1000_SWSM);
                if (!(swsm & E1000_SWSM_SMBI))
                        break;
 
-               udelay(50);
+               usec_delay(50);
                i++;
        }
 
        if (i == timeout) {
-               hw_dbg(hw, "Driver can't access device - SMBI bit is set.\n");
+               DEBUGOUT("Driver can't access device - SMBI bit is set.\n");
                ret_val = -E1000_ERR_NVM;
                goto out;
        }
 
        /* Get the FW semaphore. */
        for (i = 0; i < timeout; i++) {
-               swsm = rd32(E1000_SWSM);
-               wr32(E1000_SWSM, swsm | E1000_SWSM_SWESMBI);
+               swsm = E1000_READ_REG(hw, E1000_SWSM);
+               E1000_WRITE_REG(hw, E1000_SWSM, swsm | E1000_SWSM_SWESMBI);
 
                /* Semaphore acquired if bit latched */
-               if (rd32(E1000_SWSM) & E1000_SWSM_SWESMBI)
+               if (E1000_READ_REG(hw, E1000_SWSM) & E1000_SWSM_SWESMBI)
                        break;
 
-               udelay(50);
+               usec_delay(50);
        }
 
        if (i == timeout) {
                /* Release semaphores */
-               igb_put_hw_semaphore(hw);
-               hw_dbg(hw, "Driver can't access the NVM\n");
+               e1000_put_hw_semaphore_generic(hw);
+               DEBUGOUT("Driver can't access the NVM\n");
                ret_val = -E1000_ERR_NVM;
                goto out;
        }
@@ -1081,43 +1469,46 @@ out:
 }
 
 /**
- *  e1000_put_hw_semaphore - Release hardware semaphore
+ *  e1000_put_hw_semaphore_generic - Release hardware semaphore
  *  @hw: pointer to the HW structure
  *
  *  Release hardware semaphore used to access the PHY or NVM
  **/
-void igb_put_hw_semaphore(struct e1000_hw *hw)
+void e1000_put_hw_semaphore_generic(struct e1000_hw *hw)
 {
        u32 swsm;
 
-       swsm = rd32(E1000_SWSM);
+       DEBUGFUNC("e1000_put_hw_semaphore_generic");
+
+       swsm = E1000_READ_REG(hw, E1000_SWSM);
 
        swsm &= ~(E1000_SWSM_SMBI | E1000_SWSM_SWESMBI);
 
-       wr32(E1000_SWSM, swsm);
+       E1000_WRITE_REG(hw, E1000_SWSM, swsm);
 }
 
 /**
- *  e1000_get_auto_rd_done - Check for auto read completion
+ *  e1000_get_auto_rd_done_generic - Check for auto read completion
  *  @hw: pointer to the HW structure
  *
  *  Check EEPROM for Auto Read done bit.
  **/
-s32 igb_get_auto_rd_done(struct e1000_hw *hw)
+s32 e1000_get_auto_rd_done_generic(struct e1000_hw *hw)
 {
        s32 i = 0;
-       s32 ret_val = 0;
+       s32 ret_val = E1000_SUCCESS;
 
+       DEBUGFUNC("e1000_get_auto_rd_done_generic");
 
        while (i < AUTO_READ_DONE_TIMEOUT) {
-               if (rd32(E1000_EECD) & E1000_EECD_AUTO_RD)
+               if (E1000_READ_REG(hw, E1000_EECD) & E1000_EECD_AUTO_RD)
                        break;
-               msleep(1);
+               msec_delay(1);
                i++;
        }
 
        if (i == AUTO_READ_DONE_TIMEOUT) {
-               hw_dbg(hw, "Auto read by HW from NVM has not completed.\n");
+               DEBUGOUT("Auto read by HW from NVM has not completed.\n");
                ret_val = -E1000_ERR_RESET;
                goto out;
        }
@@ -1127,20 +1518,22 @@ out:
 }
 
 /**
- *  e1000_valid_led_default - Verify a valid default LED config
+ *  e1000_valid_led_default_generic - Verify a valid default LED config
  *  @hw: pointer to the HW structure
  *  @data: pointer to the NVM (EEPROM)
  *
  *  Read the EEPROM for the current default LED configuration.  If the
  *  LED configuration is not valid, set to a valid LED configuration.
  **/
-static s32 igb_valid_led_default(struct e1000_hw *hw, u16 *data)
+s32 e1000_valid_led_default_generic(struct e1000_hw *hw, u16 *data)
 {
        s32 ret_val;
 
-       ret_val = hw->nvm.ops.read_nvm(hw, NVM_ID_LED_SETTINGS, 1, data);
+       DEBUGFUNC("e1000_valid_led_default_generic");
+
+       ret_val = hw->nvm.ops.read(hw, NVM_ID_LED_SETTINGS, 1, data);
        if (ret_val) {
-               hw_dbg(hw, "NVM Read Error\n");
+               DEBUGOUT("NVM Read Error\n");
                goto out;
        }
 
@@ -1152,11 +1545,11 @@ out:
 }
 
 /**
- *  e1000_id_led_init -
+ *  e1000_id_led_init_generic -
  *  @hw: pointer to the HW structure
  *
  **/
-s32 igb_id_led_init(struct e1000_hw *hw)
+s32 e1000_id_led_init_generic(struct e1000_hw * hw)
 {
        struct e1000_mac_info *mac = &hw->mac;
        s32 ret_val;
@@ -1166,11 +1559,13 @@ s32 igb_id_led_init(struct e1000_hw *hw)
        u16 data, i, temp;
        const u16 led_mask = 0x0F;
 
-       ret_val = igb_valid_led_default(hw, &data);
+       DEBUGFUNC("e1000_id_led_init_generic");
+
+       ret_val = hw->nvm.ops.valid_led_default(hw, &data);
        if (ret_val)
                goto out;
 
-       mac->ledctl_default = rd32(E1000_LEDCTL);
+       mac->ledctl_default = E1000_READ_REG(hw, E1000_LEDCTL);
        mac->ledctl_mode1 = mac->ledctl_default;
        mac->ledctl_mode2 = mac->ledctl_default;
 
@@ -1217,29 +1612,79 @@ out:
 }
 
 /**
- *  e1000_cleanup_led - Set LED config to default operation
+ *  e1000_setup_led_generic - Configures SW controllable LED
+ *  @hw: pointer to the HW structure
+ *
+ *  This prepares the SW controllable LED for use and saves the current state
+ *  of the LED so it can be later restored.
+ **/
+s32 e1000_setup_led_generic(struct e1000_hw *hw)
+{
+       u32 ledctl;
+       s32 ret_val = E1000_SUCCESS;
+
+       DEBUGFUNC("e1000_setup_led_generic");
+
+       if (hw->mac.ops.setup_led != e1000_setup_led_generic) {
+               ret_val = -E1000_ERR_CONFIG;
+               goto out;
+       }
+
+       if (hw->phy.media_type == e1000_media_type_fiber) {
+               ledctl = E1000_READ_REG(hw, E1000_LEDCTL);
+               hw->mac.ledctl_default = ledctl;
+               /* Turn off LED0 */
+               ledctl &= ~(E1000_LEDCTL_LED0_IVRT |
+                           E1000_LEDCTL_LED0_BLINK |
+                           E1000_LEDCTL_LED0_MODE_MASK);
+               ledctl |= (E1000_LEDCTL_MODE_LED_OFF <<
+                          E1000_LEDCTL_LED0_MODE_SHIFT);
+               E1000_WRITE_REG(hw, E1000_LEDCTL, ledctl);
+       } else if (hw->phy.media_type == e1000_media_type_copper) {
+               E1000_WRITE_REG(hw, E1000_LEDCTL, hw->mac.ledctl_mode1);
+       }
+
+out:
+       return ret_val;
+}
+
+/**
+ *  e1000_cleanup_led_generic - Set LED config to default operation
  *  @hw: pointer to the HW structure
  *
  *  Remove the current LED configuration and set the LED configuration
  *  to the default value, saved from the EEPROM.
  **/
-s32 igb_cleanup_led(struct e1000_hw *hw)
+s32 e1000_cleanup_led_generic(struct e1000_hw *hw)
 {
-       wr32(E1000_LEDCTL, hw->mac.ledctl_default);
-       return 0;
+       s32 ret_val = E1000_SUCCESS;
+
+       DEBUGFUNC("e1000_cleanup_led_generic");
+
+       if (hw->mac.ops.cleanup_led != e1000_cleanup_led_generic) {
+               ret_val = -E1000_ERR_CONFIG;
+               goto out;
+       }
+
+       E1000_WRITE_REG(hw, E1000_LEDCTL, hw->mac.ledctl_default);
+
+out:
+       return ret_val;
 }
 
 /**
- *  e1000_blink_led - Blink LED
+ *  e1000_blink_led_generic - Blink LED
  *  @hw: pointer to the HW structure
  *
- *  Blink the led's which are set to be on.
+ *  Blink the LEDs which are set to be on.
  **/
-s32 igb_blink_led(struct e1000_hw *hw)
+s32 e1000_blink_led_generic(struct e1000_hw *hw)
 {
        u32 ledctl_blink = 0;
        u32 i;
 
+       DEBUGFUNC("e1000_blink_led_generic");
+
        if (hw->phy.media_type == e1000_media_type_fiber) {
                /* always blink LED0 for PCI-E fiber */
                ledctl_blink = E1000_LEDCTL_LED0_BLINK |
@@ -1254,75 +1699,134 @@ s32 igb_blink_led(struct e1000_hw *hw)
                        if (((hw->mac.ledctl_mode2 >> (i * 8)) & 0xFF) ==
                            E1000_LEDCTL_MODE_LED_ON)
                                ledctl_blink |= (E1000_LEDCTL_LED0_BLINK <<
-                                                (i * 8));
+                                                (i * 8));
        }
 
-       wr32(E1000_LEDCTL, ledctl_blink);
+       E1000_WRITE_REG(hw, E1000_LEDCTL, ledctl_blink);
 
-       return 0;
+       return E1000_SUCCESS;
 }
 
 /**
- *  e1000_led_off - Turn LED off
+ *  e1000_led_on_generic - Turn LED on
+ *  @hw: pointer to the HW structure
+ *
+ *  Turn LED on.
+ **/
+s32 e1000_led_on_generic(struct e1000_hw *hw)
+{
+       u32 ctrl;
+
+       DEBUGFUNC("e1000_led_on_generic");
+
+       switch (hw->phy.media_type) {
+       case e1000_media_type_fiber:
+               ctrl = E1000_READ_REG(hw, E1000_CTRL);
+               ctrl &= ~E1000_CTRL_SWDPIN0;
+               ctrl |= E1000_CTRL_SWDPIO0;
+               E1000_WRITE_REG(hw, E1000_CTRL, ctrl);
+               break;
+       case e1000_media_type_copper:
+               E1000_WRITE_REG(hw, E1000_LEDCTL, hw->mac.ledctl_mode2);
+               break;
+       default:
+               break;
+       }
+
+       return E1000_SUCCESS;
+}
+
+/**
+ *  e1000_led_off_generic - Turn LED off
  *  @hw: pointer to the HW structure
  *
  *  Turn LED off.
  **/
-s32 igb_led_off(struct e1000_hw *hw)
+s32 e1000_led_off_generic(struct e1000_hw *hw)
 {
        u32 ctrl;
 
+       DEBUGFUNC("e1000_led_off_generic");
+
        switch (hw->phy.media_type) {
        case e1000_media_type_fiber:
-               ctrl = rd32(E1000_CTRL);
+               ctrl = E1000_READ_REG(hw, E1000_CTRL);
                ctrl |= E1000_CTRL_SWDPIN0;
                ctrl |= E1000_CTRL_SWDPIO0;
-               wr32(E1000_CTRL, ctrl);
+               E1000_WRITE_REG(hw, E1000_CTRL, ctrl);
                break;
        case e1000_media_type_copper:
-               wr32(E1000_LEDCTL, hw->mac.ledctl_mode1);
+               E1000_WRITE_REG(hw, E1000_LEDCTL, hw->mac.ledctl_mode1);
                break;
        default:
                break;
        }
 
-       return 0;
+       return E1000_SUCCESS;
+}
+
+/**
+ *  e1000_set_pcie_no_snoop_generic - Set PCI-express capabilities
+ *  @hw: pointer to the HW structure
+ *  @no_snoop: bitmap of snoop events
+ *
+ *  Set the PCI-express register to snoop for events enabled in 'no_snoop'.
+ **/
+void e1000_set_pcie_no_snoop_generic(struct e1000_hw *hw, u32 no_snoop)
+{
+       u32 gcr;
+
+       DEBUGFUNC("e1000_set_pcie_no_snoop_generic");
+
+       if (hw->bus.type != e1000_bus_type_pci_express)
+               goto out;
+
+       if (no_snoop) {
+               gcr = E1000_READ_REG(hw, E1000_GCR);
+               gcr &= ~(PCIE_NO_SNOOP_ALL);
+               gcr |= no_snoop;
+               E1000_WRITE_REG(hw, E1000_GCR, gcr);
+       }
+out:
+       return;
 }
 
 /**
- *  e1000_disable_pcie_master - Disables PCI-express master access
+ *  e1000_disable_pcie_master_generic - Disables PCI-express master access
  *  @hw: pointer to the HW structure
  *
- *  Returns 0 (0) if successful, else returns -10
- *  (-E1000_ERR_MASTER_REQUESTS_PENDING) if master disable bit has not casued
+ *  Returns 0 (E1000_SUCCESS) if successful, else returns -10
+ *  (-E1000_ERR_MASTER_REQUESTS_PENDING) if master disable bit has not caused
  *  the master requests to be disabled.
  *
  *  Disables PCI-Express master access and verifies there are no pending
  *  requests.
  **/
-s32 igb_disable_pcie_master(struct e1000_hw *hw)
+s32 e1000_disable_pcie_master_generic(struct e1000_hw *hw)
 {
        u32 ctrl;
        s32 timeout = MASTER_DISABLE_TIMEOUT;
-       s32 ret_val = 0;
+       s32 ret_val = E1000_SUCCESS;
+
+       DEBUGFUNC("e1000_disable_pcie_master_generic");
 
        if (hw->bus.type != e1000_bus_type_pci_express)
                goto out;
 
-       ctrl = rd32(E1000_CTRL);
+       ctrl = E1000_READ_REG(hw, E1000_CTRL);
        ctrl |= E1000_CTRL_GIO_MASTER_DISABLE;
-       wr32(E1000_CTRL, ctrl);
+       E1000_WRITE_REG(hw, E1000_CTRL, ctrl);
 
        while (timeout) {
-               if (!(rd32(E1000_STATUS) &
+               if (!(E1000_READ_REG(hw, E1000_STATUS) &
                      E1000_STATUS_GIO_MASTER_ENABLE))
                        break;
-               udelay(100);
+               usec_delay(100);
                timeout--;
        }
 
        if (!timeout) {
-               hw_dbg(hw, "Master requests are pending.\n");
+               DEBUGOUT("Master requests are pending.\n");
                ret_val = -E1000_ERR_MASTER_REQUESTS_PENDING;
                goto out;
        }
@@ -1332,47 +1836,49 @@ out:
 }
 
 /**
- *  e1000_reset_adaptive - Reset Adaptive Interframe Spacing
+ *  e1000_reset_adaptive_generic - Reset Adaptive Interframe Spacing
  *  @hw: pointer to the HW structure
  *
  *  Reset the Adaptive Interframe Spacing throttle to default values.
  **/
-void igb_reset_adaptive(struct e1000_hw *hw)
+void e1000_reset_adaptive_generic(struct e1000_hw *hw)
 {
        struct e1000_mac_info *mac = &hw->mac;
 
+       DEBUGFUNC("e1000_reset_adaptive_generic");
+
        if (!mac->adaptive_ifs) {
-               hw_dbg(hw, "Not in Adaptive IFS mode!\n");
+               DEBUGOUT("Not in Adaptive IFS mode!\n");
                goto out;
        }
 
-       if (!mac->ifs_params_forced) {
-               mac->current_ifs_val = 0;
-               mac->ifs_min_val = IFS_MIN;
-               mac->ifs_max_val = IFS_MAX;
-               mac->ifs_step_size = IFS_STEP;
-               mac->ifs_ratio = IFS_RATIO;
-       }
+       mac->current_ifs_val = 0;
+       mac->ifs_min_val = IFS_MIN;
+       mac->ifs_max_val = IFS_MAX;
+       mac->ifs_step_size = IFS_STEP;
+       mac->ifs_ratio = IFS_RATIO;
 
        mac->in_ifs_mode = false;
-       wr32(E1000_AIT, 0);
+       E1000_WRITE_REG(hw, E1000_AIT, 0);
 out:
        return;
 }
 
 /**
- *  e1000_update_adaptive - Update Adaptive Interframe Spacing
+ *  e1000_update_adaptive_generic - Update Adaptive Interframe Spacing
  *  @hw: pointer to the HW structure
  *
  *  Update the Adaptive Interframe Spacing Throttle value based on the
  *  time between transmitted packets and time between collisions.
  **/
-void igb_update_adaptive(struct e1000_hw *hw)
+void e1000_update_adaptive_generic(struct e1000_hw *hw)
 {
        struct e1000_mac_info *mac = &hw->mac;
 
+       DEBUGFUNC("e1000_update_adaptive_generic");
+
        if (!mac->adaptive_ifs) {
-               hw_dbg(hw, "Not in Adaptive IFS mode!\n");
+               DEBUGOUT("Not in Adaptive IFS mode!\n");
                goto out;
        }
 
@@ -1385,8 +1891,7 @@ void igb_update_adaptive(struct e1000_hw *hw)
                                else
                                        mac->current_ifs_val +=
                                                mac->ifs_step_size;
-                               wr32(E1000_AIT,
-                                               mac->current_ifs_val);
+                               E1000_WRITE_REG(hw, E1000_AIT, mac->current_ifs_val);
                        }
                }
        } else {
@@ -1394,7 +1899,7 @@ void igb_update_adaptive(struct e1000_hw *hw)
                    (mac->tx_packet_delta <= MIN_NUM_XMITS)) {
                        mac->current_ifs_val = 0;
                        mac->in_ifs_mode = false;
-                       wr32(E1000_AIT, 0);
+                       E1000_WRITE_REG(hw, E1000_AIT, 0);
                }
        }
 out:
@@ -1402,18 +1907,20 @@ out:
 }
 
 /**
- *  e1000_validate_mdi_setting - Verify MDI/MDIx settings
+ *  e1000_validate_mdi_setting_generic - Verify MDI/MDIx settings
  *  @hw: pointer to the HW structure
  *
- *  Verify that when not using auto-negotitation that MDI/MDIx is correctly
+ *  Verify that when not using auto-negotiation that MDI/MDIx is correctly
  *  set, which is forced to MDI mode only.
  **/
-s32 igb_validate_mdi_setting(struct e1000_hw *hw)
+s32 e1000_validate_mdi_setting_generic(struct e1000_hw *hw)
 {
-       s32 ret_val = 0;
+       s32 ret_val = E1000_SUCCESS;
+
+       DEBUGFUNC("e1000_validate_mdi_setting_generic");
 
        if (!hw->mac.autoneg && (hw->phy.mdix == 0 || hw->phy.mdix == 3)) {
-               hw_dbg(hw, "Invalid MDI setting detected\n");
+               DEBUGOUT("Invalid MDI setting detected\n");
                hw->phy.mdix = 1;
                ret_val = -E1000_ERR_CONFIG;
                goto out;
@@ -1424,7 +1931,7 @@ out:
 }
 
 /**
- *  e1000_write_8bit_ctrl_reg - Write a 8bit CTRL register
+ *  e1000_write_8bit_ctrl_reg_generic - Write a 8bit CTRL register
  *  @hw: pointer to the HW structure
  *  @reg: 32bit register offset such as E1000_SCTL
  *  @offset: register offset to write to
@@ -1434,25 +1941,27 @@ out:
  *  and they all have the format address << 8 | data and bit 31 is polled for
  *  completion.
  **/
-s32 igb_write_8bit_ctrl_reg(struct e1000_hw *hw, u32 reg,
-                             u32 offset, u8 data)
+s32 e1000_write_8bit_ctrl_reg_generic(struct e1000_hw *hw, u32 reg,
+                                      u32 offset, u8 data)
 {
        u32 i, regvalue = 0;
-       s32 ret_val = 0;
+       s32 ret_val = E1000_SUCCESS;
+
+       DEBUGFUNC("e1000_write_8bit_ctrl_reg_generic");
 
        /* Set up the address and data */
        regvalue = ((u32)data) | (offset << E1000_GEN_CTL_ADDRESS_SHIFT);
-       wr32(reg, regvalue);
+       E1000_WRITE_REG(hw, reg, regvalue);
 
        /* Poll the ready bit to see if the MDI read completed */
        for (i = 0; i < E1000_GEN_POLL_TIMEOUT; i++) {
-               udelay(5);
-               regvalue = rd32(reg);
+               usec_delay(5);
+               regvalue = E1000_READ_REG(hw, reg);
                if (regvalue & E1000_GEN_CTL_READY)
                        break;
        }
        if (!(regvalue & E1000_GEN_CTL_READY)) {
-               hw_dbg(hw, "Reg %08x did not indicate ready\n", reg);
+               DEBUGOUT1("Reg %08x did not indicate ready\n", reg);
                ret_val = -E1000_ERR_PHY;
                goto out;
        }
@@ -1460,46 +1969,3 @@ s32 igb_write_8bit_ctrl_reg(struct e1000_hw *hw, u32 reg,
 out:
        return ret_val;
 }
-
-/**
- *  e1000_enable_mng_pass_thru - Enable processing of ARP's
- *  @hw: pointer to the HW structure
- *
- *  Verifies the hardware needs to allow ARPs to be processed by the host.
- **/
-bool igb_enable_mng_pass_thru(struct e1000_hw *hw)
-{
-       u32 manc;
-       u32 fwsm, factps;
-       bool ret_val = false;
-
-       if (!hw->mac.asf_firmware_present)
-               goto out;
-
-       manc = rd32(E1000_MANC);
-
-       if (!(manc & E1000_MANC_RCV_TCO_EN) ||
-           !(manc & E1000_MANC_EN_MAC_ADDR_FILTER))
-               goto out;
-
-       if (hw->mac.arc_subsystem_valid) {
-               fwsm = rd32(E1000_FWSM);
-               factps = rd32(E1000_FACTPS);
-
-               if (!(factps & E1000_FACTPS_MNGCG) &&
-                   ((fwsm & E1000_FWSM_MODE_MASK) ==
-                    (e1000_mng_mode_pt << E1000_FWSM_MODE_SHIFT))) {
-                       ret_val = true;
-                       goto out;
-               }
-       } else {
-               if ((manc & E1000_MANC_SMBUS_EN) &&
-                   !(manc & E1000_MANC_ASF_EN)) {
-                       ret_val = true;
-                       goto out;
-               }
-       }
-
-out:
-       return ret_val;
-}
index 326b6592307b4aeee29e7ad22af287f85dc9a1a6..6370376c826d78e8fde95aaecf6442a3d2efaa2b 100644 (file)
@@ -1,7 +1,7 @@
 /*******************************************************************************
 
   Intel(R) Gigabit Ethernet Linux driver
-  Copyright(c) 2007 Intel Corporation.
+  Copyright(c) 2007-2008 Intel Corporation.
 
   This program is free software; you can redistribute it and/or modify it
   under the terms and conditions of the GNU General Public License,
 #ifndef _E1000_MAC_H_
 #define _E1000_MAC_H_
 
-#include "e1000_hw.h"
-
-#include "e1000_phy.h"
-#include "e1000_nvm.h"
-#include "e1000_defines.h"
-
 /*
  * Functions that should not be called directly from drivers but can be used
  * by other files in this 'shared code'
  */
-s32  igb_blink_led(struct e1000_hw *hw);
-s32  igb_check_for_copper_link(struct e1000_hw *hw);
-s32  igb_cleanup_led(struct e1000_hw *hw);
-s32  igb_config_fc_after_link_up(struct e1000_hw *hw);
-s32  igb_disable_pcie_master(struct e1000_hw *hw);
-s32  igb_force_mac_fc(struct e1000_hw *hw);
-s32  igb_get_auto_rd_done(struct e1000_hw *hw);
-s32  igb_get_bus_info_pcie(struct e1000_hw *hw);
-s32  igb_get_hw_semaphore(struct e1000_hw *hw);
-s32  igb_get_speed_and_duplex_copper(struct e1000_hw *hw, u16 *speed,
-                                      u16 *duplex);
-s32  igb_id_led_init(struct e1000_hw *hw);
-s32  igb_led_off(struct e1000_hw *hw);
-void igb_update_mc_addr_list(struct e1000_hw *hw,
-                              u8 *mc_addr_list, u32 mc_addr_count,
-                              u32 rar_used_count, u32 rar_count);
-s32  igb_setup_link(struct e1000_hw *hw);
-s32  igb_validate_mdi_setting(struct e1000_hw *hw);
-s32  igb_write_8bit_ctrl_reg(struct e1000_hw *hw, u32 reg,
-                              u32 offset, u8 data);
-
-void igb_clear_hw_cntrs_base(struct e1000_hw *hw);
-void igb_clear_vfta(struct e1000_hw *hw);
-void igb_config_collision_dist(struct e1000_hw *hw);
-void igb_init_rx_addrs(struct e1000_hw *hw, u16 rar_count);
-void igb_put_hw_semaphore(struct e1000_hw *hw);
-void igb_rar_set(struct e1000_hw *hw, u8 *addr, u32 index);
-s32  igb_check_alt_mac_addr(struct e1000_hw *hw);
-void igb_remove_device(struct e1000_hw *hw);
-void igb_reset_adaptive(struct e1000_hw *hw);
-void igb_update_adaptive(struct e1000_hw *hw);
-void igb_write_vfta(struct e1000_hw *hw, u32 offset, u32 value);
-
-bool igb_enable_mng_pass_thru(struct e1000_hw *hw);
-
-enum e1000_mng_mode {
-       e1000_mng_mode_none = 0,
-       e1000_mng_mode_asf,
-       e1000_mng_mode_pt,
-       e1000_mng_mode_ipmi,
-       e1000_mng_mode_host_if_only
-};
-
-#define E1000_FACTPS_MNGCG    0x20000000
-
-#define E1000_FWSM_MODE_MASK  0xE
-#define E1000_FWSM_MODE_SHIFT 1
-
-#define E1000_MNG_DHCP_COMMAND_TIMEOUT       10
-#define E1000_MNG_DHCP_COOKIE_STATUS_VLAN    0x2
-
-#define E1000_HICR_EN              0x01  /* Enable bit - RO */
-/* Driver sets this bit when done to put command in RAM */
-#define E1000_HICR_C               0x02
-
-extern void e1000_init_function_pointers_82575(struct e1000_hw *hw);
+void e1000_init_mac_ops_generic(struct e1000_hw *hw);
+s32  e1000_blink_led_generic(struct e1000_hw *hw);
+s32  e1000_check_for_copper_link_generic(struct e1000_hw *hw);
+s32  e1000_check_for_fiber_link_generic(struct e1000_hw *hw);
+s32  e1000_check_for_serdes_link_generic(struct e1000_hw *hw);
+s32  e1000_cleanup_led_generic(struct e1000_hw *hw);
+s32  e1000_config_fc_after_link_up_generic(struct e1000_hw *hw);
+s32  e1000_disable_pcie_master_generic(struct e1000_hw *hw);
+s32  e1000_force_mac_fc_generic(struct e1000_hw *hw);
+s32  e1000_get_auto_rd_done_generic(struct e1000_hw *hw);
+s32  e1000_get_bus_info_pcie_generic(struct e1000_hw *hw);
+s32  e1000_get_hw_semaphore_generic(struct e1000_hw *hw);
+s32  e1000_get_speed_and_duplex_copper_generic(struct e1000_hw *hw, u16 *speed,
+                                               u16 *duplex);
+s32  e1000_get_speed_and_duplex_fiber_serdes_generic(struct e1000_hw *hw,
+                                                     u16 *speed, u16 *duplex);
+s32  e1000_id_led_init_generic(struct e1000_hw *hw);
+s32  e1000_led_on_generic(struct e1000_hw *hw);
+s32  e1000_led_off_generic(struct e1000_hw *hw);
+void e1000_update_mc_addr_list_generic(struct e1000_hw *hw,
+                                      u8 *mc_addr_list, u32 mc_addr_count,
+                                      u32 rar_used_count, u32 rar_count);
+s32  e1000_set_fc_watermarks_generic(struct e1000_hw *hw);
+s32  e1000_setup_fiber_serdes_link_generic(struct e1000_hw *hw);
+s32  e1000_setup_led_generic(struct e1000_hw *hw);
+s32  e1000_setup_link_generic(struct e1000_hw *hw);
+s32  e1000_write_8bit_ctrl_reg_generic(struct e1000_hw *hw, u32 reg,
+                                       u32 offset, u8 data);
+
+u32  e1000_hash_mc_addr_generic(struct e1000_hw *hw, u8 *mc_addr);
+
+void e1000_clear_hw_cntrs_base_generic(struct e1000_hw *hw);
+void e1000_clear_vfta_generic(struct e1000_hw *hw);
+void e1000_config_collision_dist_generic(struct e1000_hw *hw);
+void e1000_init_rx_addrs_generic(struct e1000_hw *hw, u16 rar_count);
+void e1000_mta_set_generic(struct e1000_hw *hw, u32 hash_value);
+void e1000_pcix_mmrbc_workaround_generic(struct e1000_hw *hw);
+void e1000_put_hw_semaphore_generic(struct e1000_hw *hw);
+void e1000_rar_set_generic(struct e1000_hw *hw, u8 *addr, u32 index);
+s32  e1000_check_alt_mac_addr_generic(struct e1000_hw *hw);
+void e1000_reset_adaptive_generic(struct e1000_hw *hw);
+void e1000_set_pcie_no_snoop_generic(struct e1000_hw *hw, u32 no_snoop);
+void e1000_update_adaptive_generic(struct e1000_hw *hw);
+void e1000_write_vfta_generic(struct e1000_hw *hw, u32 offset, u32 value);
 
 #endif
diff --git a/drivers/net/igb/e1000_manage.c b/drivers/net/igb/e1000_manage.c
new file mode 100644 (file)
index 0000000..eb44ef5
--- /dev/null
@@ -0,0 +1,382 @@
+/*******************************************************************************
+
+  Intel(R) Gigabit Ethernet Linux driver
+  Copyright(c) 2007-2008 Intel Corporation.
+
+  This program is free software; you can redistribute it and/or modify it
+  under the terms and conditions of the GNU General Public License,
+  version 2, as published by the Free Software Foundation.
+
+  This program is distributed in the hope it will be useful, but WITHOUT
+  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+  FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
+  more details.
+
+  You should have received a copy of the GNU General Public License along with
+  this program; if not, write to the Free Software Foundation, Inc.,
+  51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
+
+  The full GNU General Public License is included in this distribution in
+  the file called "COPYING".
+
+  Contact Information:
+  e1000-devel Mailing List <e1000-devel@lists.sourceforge.net>
+  Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
+
+*******************************************************************************/
+
+#include "e1000_api.h"
+
+static u8 e1000_calculate_checksum(u8 *buffer, u32 length);
+
+/**
+ *  e1000_calculate_checksum - Calculate checksum for buffer
+ *  @buffer: pointer to EEPROM
+ *  @length: size of EEPROM to calculate a checksum for
+ *
+ *  Calculates the checksum for some buffer on a specified length.  The
+ *  checksum calculated is returned.
+ **/
+static u8 e1000_calculate_checksum(u8 *buffer, u32 length)
+{
+       u32 i;
+       u8  sum = 0;
+
+       DEBUGFUNC("e1000_calculate_checksum");
+
+       if (!buffer)
+               return 0;
+
+       for (i = 0; i < length; i++)
+               sum += buffer[i];
+
+       return (u8) (0 - sum);
+}
+
+/**
+ *  e1000_mng_enable_host_if_generic - Checks host interface is enabled
+ *  @hw: pointer to the HW structure
+ *
+ *  Returns E1000_success upon success, else E1000_ERR_HOST_INTERFACE_COMMAND
+ *
+ *  This function checks whether the HOST IF is enabled for command operation
+ *  and also checks whether the previous command is completed.  It busy waits
+ *  in case of previous command is not completed.
+ **/
+s32 e1000_mng_enable_host_if_generic(struct e1000_hw * hw)
+{
+       u32 hicr;
+       s32 ret_val = E1000_SUCCESS;
+       u8  i;
+
+       DEBUGFUNC("e1000_mng_enable_host_if_generic");
+
+       /* Check that the host interface is enabled. */
+       hicr = E1000_READ_REG(hw, E1000_HICR);
+       if ((hicr & E1000_HICR_EN) == 0) {
+               DEBUGOUT("E1000_HOST_EN bit disabled.\n");
+               ret_val = -E1000_ERR_HOST_INTERFACE_COMMAND;
+               goto out;
+       }
+       /* check the previous command is completed */
+       for (i = 0; i < E1000_MNG_DHCP_COMMAND_TIMEOUT; i++) {
+               hicr = E1000_READ_REG(hw, E1000_HICR);
+               if (!(hicr & E1000_HICR_C))
+                       break;
+               msec_delay_irq(1);
+       }
+
+       if (i == E1000_MNG_DHCP_COMMAND_TIMEOUT) {
+               DEBUGOUT("Previous command timeout failed .\n");
+               ret_val = -E1000_ERR_HOST_INTERFACE_COMMAND;
+               goto out;
+       }
+
+out:
+       return ret_val;
+}
+
+/**
+ *  e1000_check_mng_mode_generic - Generic check management mode
+ *  @hw: pointer to the HW structure
+ *
+ *  Reads the firmware semaphore register and returns true (>0) if
+ *  manageability is enabled, else false (0).
+ **/
+bool e1000_check_mng_mode_generic(struct e1000_hw *hw)
+{
+       u32 fwsm;
+
+       DEBUGFUNC("e1000_check_mng_mode_generic");
+
+       fwsm = E1000_READ_REG(hw, E1000_FWSM);
+
+       return (fwsm & E1000_FWSM_MODE_MASK) ==
+               (E1000_MNG_IAMT_MODE << E1000_FWSM_MODE_SHIFT);
+}
+
+/**
+ *  e1000_enable_tx_pkt_filtering_generic - Enable packet filtering on TX
+ *  @hw: pointer to the HW structure
+ *
+ *  Enables packet filtering on transmit packets if manageability is enabled
+ *  and host interface is enabled.
+ **/
+bool e1000_enable_tx_pkt_filtering_generic(struct e1000_hw *hw)
+{
+       struct e1000_host_mng_dhcp_cookie *hdr = &hw->mng_cookie;
+       u32 *buffer = (u32 *)&hw->mng_cookie;
+       u32 offset;
+       s32 ret_val, hdr_csum, csum;
+       u8 i, len;
+       bool tx_filter = true;
+
+       DEBUGFUNC("e1000_enable_tx_pkt_filtering_generic");
+
+       /* No manageability, no filtering */
+       if (!hw->mac.ops.check_mng_mode(hw)) {
+               tx_filter = false;
+               goto out;
+       }
+
+       /*
+        * If we can't read from the host interface for whatever
+        * reason, disable filtering.
+        */
+       ret_val = hw->mac.ops.mng_enable_host_if(hw);
+       if (ret_val != E1000_SUCCESS) {
+               tx_filter = false;
+               goto out;
+       }
+
+       /* Read in the header.  Length and offset are in dwords. */
+       len    = E1000_MNG_DHCP_COOKIE_LENGTH >> 2;
+       offset = E1000_MNG_DHCP_COOKIE_OFFSET >> 2;
+       for (i = 0; i < len; i++) {
+               *(buffer + i) = E1000_READ_REG_ARRAY_DWORD(hw,
+                                                          E1000_HOST_IF,
+                                                          offset + i);
+       }
+       hdr_csum = hdr->checksum;
+       hdr->checksum = 0;
+       csum = e1000_calculate_checksum((u8 *)hdr,
+                                       E1000_MNG_DHCP_COOKIE_LENGTH);
+       /*
+        * If either the checksums or signature don't match, then
+        * the cookie area isn't considered valid, in which case we
+        * take the safe route of assuming Tx filtering is enabled.
+        */
+       if (hdr_csum != csum)
+               goto out;
+       if (hdr->signature != E1000_IAMT_SIGNATURE)
+               goto out;
+
+       /* Cookie area is valid, make the final check for filtering. */
+       if (!(hdr->status & E1000_MNG_DHCP_COOKIE_STATUS_PARSING))
+               tx_filter = false;
+
+out:
+       hw->mac.tx_pkt_filtering = tx_filter;
+       return tx_filter;
+}
+
+/**
+ *  e1000_mng_write_dhcp_info_generic - Writes DHCP info to host interface
+ *  @hw: pointer to the HW structure
+ *  @buffer: pointer to the host interface
+ *  @length: size of the buffer
+ *
+ *  Writes the DHCP information to the host interface.
+ **/
+s32 e1000_mng_write_dhcp_info_generic(struct e1000_hw * hw, u8 *buffer,
+                                      u16 length)
+{
+       struct e1000_host_mng_command_header hdr;
+       s32 ret_val;
+       u32 hicr;
+
+       DEBUGFUNC("e1000_mng_write_dhcp_info_generic");
+
+       hdr.command_id = E1000_MNG_DHCP_TX_PAYLOAD_CMD;
+       hdr.command_length = length;
+       hdr.reserved1 = 0;
+       hdr.reserved2 = 0;
+       hdr.checksum = 0;
+
+       /* Enable the host interface */
+       ret_val = hw->mac.ops.mng_enable_host_if(hw);
+       if (ret_val)
+               goto out;
+
+       /* Populate the host interface with the contents of "buffer". */
+       ret_val = hw->mac.ops.mng_host_if_write(hw, buffer, length,
+                                         sizeof(hdr), &(hdr.checksum));
+       if (ret_val)
+               goto out;
+
+       /* Write the manageability command header */
+       ret_val = hw->mac.ops.mng_write_cmd_header(hw, &hdr);
+       if (ret_val)
+               goto out;
+
+       /* Tell the ARC a new command is pending. */
+       hicr = E1000_READ_REG(hw, E1000_HICR);
+       E1000_WRITE_REG(hw, E1000_HICR, hicr | E1000_HICR_C);
+
+out:
+       return ret_val;
+}
+
+/**
+ *  e1000_mng_write_cmd_header_generic - Writes manageability command header
+ *  @hw: pointer to the HW structure
+ *  @hdr: pointer to the host interface command header
+ *
+ *  Writes the command header after does the checksum calculation.
+ **/
+s32 e1000_mng_write_cmd_header_generic(struct e1000_hw * hw,
+                                    struct e1000_host_mng_command_header * hdr)
+{
+       u16 i, length = sizeof(struct e1000_host_mng_command_header);
+
+       DEBUGFUNC("e1000_mng_write_cmd_header_generic");
+
+       /* Write the whole command header structure with new checksum. */
+
+       hdr->checksum = e1000_calculate_checksum((u8 *)hdr, length);
+
+       length >>= 2;
+       /* Write the relevant command block into the ram area. */
+       for (i = 0; i < length; i++) {
+               E1000_WRITE_REG_ARRAY_DWORD(hw, E1000_HOST_IF, i,
+                                           *((u32 *) hdr + i));
+               E1000_WRITE_FLUSH(hw);
+       }
+
+       return E1000_SUCCESS;
+}
+
+/**
+ *  e1000_mng_host_if_write_generic - Write to the manageability host interface
+ *  @hw: pointer to the HW structure
+ *  @buffer: pointer to the host interface buffer
+ *  @length: size of the buffer
+ *  @offset: location in the buffer to write to
+ *  @sum: sum of the data (not checksum)
+ *
+ *  This function writes the buffer content at the offset given on the host if.
+ *  It also does alignment considerations to do the writes in most efficient
+ *  way.  Also fills up the sum of the buffer in *buffer parameter.
+ **/
+s32 e1000_mng_host_if_write_generic(struct e1000_hw * hw, u8 *buffer,
+                                    u16 length, u16 offset, u8 *sum)
+{
+       u8 *tmp;
+       u8 *bufptr = buffer;
+       u32 data = 0;
+       s32 ret_val = E1000_SUCCESS;
+       u16 remaining, i, j, prev_bytes;
+
+       DEBUGFUNC("e1000_mng_host_if_write_generic");
+
+       /* sum = only sum of the data and it is not checksum */
+
+       if (length == 0 || offset + length > E1000_HI_MAX_MNG_DATA_LENGTH) {
+               ret_val = -E1000_ERR_PARAM;
+               goto out;
+       }
+
+       tmp = (u8 *)&data;
+       prev_bytes = offset & 0x3;
+       offset >>= 2;
+
+       if (prev_bytes) {
+               data = E1000_READ_REG_ARRAY_DWORD(hw, E1000_HOST_IF, offset);
+               for (j = prev_bytes; j < sizeof(u32); j++) {
+                       *(tmp + j) = *bufptr++;
+                       *sum += *(tmp + j);
+               }
+               E1000_WRITE_REG_ARRAY_DWORD(hw, E1000_HOST_IF, offset, data);
+               length -= j - prev_bytes;
+               offset++;
+       }
+
+       remaining = length & 0x3;
+       length -= remaining;
+
+       /* Calculate length in DWORDs */
+       length >>= 2;
+
+       /*
+        * The device driver writes the relevant command block into the
+        * ram area.
+        */
+       for (i = 0; i < length; i++) {
+               for (j = 0; j < sizeof(u32); j++) {
+                       *(tmp + j) = *bufptr++;
+                       *sum += *(tmp + j);
+               }
+
+               E1000_WRITE_REG_ARRAY_DWORD(hw, E1000_HOST_IF, offset + i, data);
+       }
+       if (remaining) {
+               for (j = 0; j < sizeof(u32); j++) {
+                       if (j < remaining)
+                               *(tmp + j) = *bufptr++;
+                       else
+                               *(tmp + j) = 0;
+
+                       *sum += *(tmp + j);
+               }
+               E1000_WRITE_REG_ARRAY_DWORD(hw, E1000_HOST_IF, offset + i, data);
+       }
+
+out:
+       return ret_val;
+}
+
+/**
+ *  e1000_enable_mng_pass_thru - Enable processing of ARP's
+ *  @hw: pointer to the HW structure
+ *
+ *  Verifies the hardware needs to allow ARPs to be processed by the host.
+ **/
+bool e1000_enable_mng_pass_thru(struct e1000_hw *hw)
+{
+       u32 manc;
+       u32 fwsm, factps;
+       bool ret_val = false;
+
+       DEBUGFUNC("e1000_enable_mng_pass_thru");
+
+       if (!hw->mac.asf_firmware_present)
+               goto out;
+
+       manc = E1000_READ_REG(hw, E1000_MANC);
+
+       if (!(manc & E1000_MANC_RCV_TCO_EN) ||
+           !(manc & E1000_MANC_EN_MAC_ADDR_FILTER))
+               goto out;
+
+       if (hw->mac.arc_subsystem_valid) {
+               fwsm = E1000_READ_REG(hw, E1000_FWSM);
+               factps = E1000_READ_REG(hw, E1000_FACTPS);
+
+               if (!(factps & E1000_FACTPS_MNGCG) &&
+                   ((fwsm & E1000_FWSM_MODE_MASK) ==
+                    (e1000_mng_mode_pt << E1000_FWSM_MODE_SHIFT))) {
+                       ret_val = true;
+                       goto out;
+               }
+       } else {
+               if ((manc & E1000_MANC_SMBUS_EN) &&
+                   !(manc & E1000_MANC_ASF_EN)) {
+                       ret_val = true;
+                       goto out;
+               }
+       }
+
+out:
+       return ret_val;
+}
+
diff --git a/drivers/net/igb/e1000_manage.h b/drivers/net/igb/e1000_manage.h
new file mode 100644 (file)
index 0000000..7796202
--- /dev/null
@@ -0,0 +1,81 @@
+/*******************************************************************************
+
+  Intel(R) Gigabit Ethernet Linux driver
+  Copyright(c) 2007-2008 Intel Corporation.
+
+  This program is free software; you can redistribute it and/or modify it
+  under the terms and conditions of the GNU General Public License,
+  version 2, as published by the Free Software Foundation.
+
+  This program is distributed in the hope it will be useful, but WITHOUT
+  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+  FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
+  more details.
+
+  You should have received a copy of the GNU General Public License along with
+  this program; if not, write to the Free Software Foundation, Inc.,
+  51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
+
+  The full GNU General Public License is included in this distribution in
+  the file called "COPYING".
+
+  Contact Information:
+  e1000-devel Mailing List <e1000-devel@lists.sourceforge.net>
+  Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
+
+*******************************************************************************/
+
+#ifndef _E1000_MANAGE_H_
+#define _E1000_MANAGE_H_
+
+bool e1000_check_mng_mode_generic(struct e1000_hw *hw);
+bool e1000_enable_tx_pkt_filtering_generic(struct e1000_hw *hw);
+s32  e1000_mng_enable_host_if_generic(struct e1000_hw *hw);
+s32  e1000_mng_host_if_write_generic(struct e1000_hw *hw, u8 *buffer,
+                                     u16 length, u16 offset, u8 *sum);
+s32  e1000_mng_write_cmd_header_generic(struct e1000_hw *hw,
+                                    struct e1000_host_mng_command_header *hdr);
+s32  e1000_mng_write_dhcp_info_generic(struct e1000_hw *hw,
+                                       u8 *buffer, u16 length);
+bool e1000_enable_mng_pass_thru(struct e1000_hw *hw);
+
+enum e1000_mng_mode {
+       e1000_mng_mode_none = 0,
+       e1000_mng_mode_asf,
+       e1000_mng_mode_pt,
+       e1000_mng_mode_ipmi,
+       e1000_mng_mode_host_if_only
+};
+
+#define E1000_FACTPS_MNGCG    0x20000000
+
+#define E1000_FWSM_MODE_MASK  0xE
+#define E1000_FWSM_MODE_SHIFT 1
+
+#define E1000_MNG_IAMT_MODE                  0x3
+#define E1000_MNG_DHCP_COOKIE_LENGTH         0x10
+#define E1000_MNG_DHCP_COOKIE_OFFSET         0x6F0
+#define E1000_MNG_DHCP_COMMAND_TIMEOUT       10
+#define E1000_MNG_DHCP_TX_PAYLOAD_CMD        64
+#define E1000_MNG_DHCP_COOKIE_STATUS_PARSING 0x1
+#define E1000_MNG_DHCP_COOKIE_STATUS_VLAN    0x2
+
+#define E1000_VFTA_ENTRY_SHIFT               5
+#define E1000_VFTA_ENTRY_MASK                0x7F
+#define E1000_VFTA_ENTRY_BIT_SHIFT_MASK      0x1F
+
+#define E1000_HI_MAX_BLOCK_BYTE_LENGTH       1792 /* Num of bytes in range */
+#define E1000_HI_MAX_BLOCK_DWORD_LENGTH      448 /* Num of dwords in range */
+#define E1000_HI_COMMAND_TIMEOUT             500 /* Process HI command limit */
+
+#define E1000_HICR_EN              0x01  /* Enable bit - RO */
+/* Driver sets this bit when done to put command in RAM */
+#define E1000_HICR_C               0x02
+#define E1000_HICR_SV              0x04  /* Status Validity */
+#define E1000_HICR_FW_RESET_ENABLE 0x40
+#define E1000_HICR_FW_RESET        0x80
+
+/* Intel(R) Active Management Technology signature */
+#define E1000_IAMT_SIGNATURE  0x544D4149
+
+#endif
index 2897106fee923cf0378ee4fc06e076e7ce826bfa..83b78fa50c4db51825e96c2b45ed833424e0d704 100644 (file)
@@ -1,7 +1,7 @@
 /*******************************************************************************
 
   Intel(R) Gigabit Ethernet Linux driver
-  Copyright(c) 2007 Intel Corporation.
+  Copyright(c) 2007-2008 Intel Corporation.
 
   This program is free software; you can redistribute it and/or modify it
   under the terms and conditions of the GNU General Public License,
 
 *******************************************************************************/
 
-#include <linux/if_ether.h>
-#include <linux/delay.h>
+#include "e1000_api.h"
 
-#include "e1000_mac.h"
-#include "e1000_nvm.h"
+static void e1000_stop_nvm(struct e1000_hw *hw);
+static void e1000_reload_nvm_generic(struct e1000_hw *hw);
+
+/**
+ *  e1000_init_nvm_ops_generic - Initialize NVM function pointers
+ *  @hw: pointer to the HW structure
+ *
+ *  Setups up the function pointers to no-op functions
+ **/
+void e1000_init_nvm_ops_generic(struct e1000_hw *hw)
+{
+       struct e1000_nvm_info *nvm = &hw->nvm;
+       DEBUGFUNC("e1000_init_nvm_ops_generic");
+
+       /* Initialize function pointers */
+       nvm->ops.reload = e1000_reload_nvm_generic;
+}
 
 /**
  *  e1000_raise_eec_clk - Raise EEPROM clock
  *
  *  Enable/Raise the EEPROM clock bit.
  **/
-static void igb_raise_eec_clk(struct e1000_hw *hw, u32 *eecd)
+static void e1000_raise_eec_clk(struct e1000_hw *hw, u32 *eecd)
 {
        *eecd = *eecd | E1000_EECD_SK;
-       wr32(E1000_EECD, *eecd);
-       wrfl();
-       udelay(hw->nvm.delay_usec);
+       E1000_WRITE_REG(hw, E1000_EECD, *eecd);
+       E1000_WRITE_FLUSH(hw);
+       usec_delay(hw->nvm.delay_usec);
 }
 
 /**
@@ -53,12 +67,12 @@ static void igb_raise_eec_clk(struct e1000_hw *hw, u32 *eecd)
  *
  *  Clear/Lower the EEPROM clock bit.
  **/
-static void igb_lower_eec_clk(struct e1000_hw *hw, u32 *eecd)
+static void e1000_lower_eec_clk(struct e1000_hw *hw, u32 *eecd)
 {
        *eecd = *eecd & ~E1000_EECD_SK;
-       wr32(E1000_EECD, *eecd);
-       wrfl();
-       udelay(hw->nvm.delay_usec);
+       E1000_WRITE_REG(hw, E1000_EECD, *eecd);
+       E1000_WRITE_FLUSH(hw);
+       usec_delay(hw->nvm.delay_usec);
 }
 
 /**
@@ -71,16 +85,16 @@ static void igb_lower_eec_clk(struct e1000_hw *hw, u32 *eecd)
  *  "data" parameter will be shifted out to the EEPROM one bit at a time.
  *  In order to do this, "data" must be broken down into bits.
  **/
-static void igb_shift_out_eec_bits(struct e1000_hw *hw, u16 data, u16 count)
+static void e1000_shift_out_eec_bits(struct e1000_hw *hw, u16 data, u16 count)
 {
        struct e1000_nvm_info *nvm = &hw->nvm;
-       u32 eecd = rd32(E1000_EECD);
+       u32 eecd = E1000_READ_REG(hw, E1000_EECD);
        u32 mask;
 
+       DEBUGFUNC("e1000_shift_out_eec_bits");
+
        mask = 0x01 << (count - 1);
-       if (nvm->type == e1000_nvm_eeprom_microwire)
-               eecd &= ~E1000_EECD_DO;
-       else if (nvm->type == e1000_nvm_eeprom_spi)
+       if (nvm->type == e1000_nvm_eeprom_spi)
                eecd |= E1000_EECD_DO;
 
        do {
@@ -89,19 +103,19 @@ static void igb_shift_out_eec_bits(struct e1000_hw *hw, u16 data, u16 count)
                if (data & mask)
                        eecd |= E1000_EECD_DI;
 
-               wr32(E1000_EECD, eecd);
-               wrfl();
+               E1000_WRITE_REG(hw, E1000_EECD, eecd);
+               E1000_WRITE_FLUSH(hw);
 
-               udelay(nvm->delay_usec);
+               usec_delay(nvm->delay_usec);
 
-               igb_raise_eec_clk(hw, &eecd);
-               igb_lower_eec_clk(hw, &eecd);
+               e1000_raise_eec_clk(hw, &eecd);
+               e1000_lower_eec_clk(hw, &eecd);
 
                mask >>= 1;
        } while (mask);
 
        eecd &= ~E1000_EECD_DI;
-       wr32(E1000_EECD, eecd);
+       E1000_WRITE_REG(hw, E1000_EECD, eecd);
 }
 
 /**
@@ -115,28 +129,30 @@ static void igb_shift_out_eec_bits(struct e1000_hw *hw, u16 data, u16 count)
  *  "DO" bit.  During this "shifting in" process the data in "DI" bit should
  *  always be clear.
  **/
-static u16 igb_shift_in_eec_bits(struct e1000_hw *hw, u16 count)
+static u16 e1000_shift_in_eec_bits(struct e1000_hw *hw, u16 count)
 {
        u32 eecd;
        u32 i;
        u16 data;
 
-       eecd = rd32(E1000_EECD);
+       DEBUGFUNC("e1000_shift_in_eec_bits");
+
+       eecd = E1000_READ_REG(hw, E1000_EECD);
 
        eecd &= ~(E1000_EECD_DO | E1000_EECD_DI);
        data = 0;
 
        for (i = 0; i < count; i++) {
                data <<= 1;
-               igb_raise_eec_clk(hw, &eecd);
+               e1000_raise_eec_clk(hw, &eecd);
 
-               eecd = rd32(E1000_EECD);
+               eecd = E1000_READ_REG(hw, E1000_EECD);
 
                eecd &= ~E1000_EECD_DI;
                if (eecd & E1000_EECD_DO)
                        data |= 1;
 
-               igb_lower_eec_clk(hw, &eecd);
+               e1000_lower_eec_clk(hw, &eecd);
        }
 
        return data;
@@ -150,59 +166,62 @@ static u16 igb_shift_in_eec_bits(struct e1000_hw *hw, u16 count)
  *  Polls the EEPROM status bit for either read or write completion based
  *  upon the value of 'ee_reg'.
  **/
-static s32 igb_poll_eerd_eewr_done(struct e1000_hw *hw, int ee_reg)
+s32 e1000_poll_eerd_eewr_done(struct e1000_hw *hw, int ee_reg)
 {
        u32 attempts = 100000;
        u32 i, reg = 0;
        s32 ret_val = -E1000_ERR_NVM;
 
+       DEBUGFUNC("e1000_poll_eerd_eewr_done");
+
        for (i = 0; i < attempts; i++) {
                if (ee_reg == E1000_NVM_POLL_READ)
-                       reg = rd32(E1000_EERD);
+                       reg = E1000_READ_REG(hw, E1000_EERD);
                else
-                       reg = rd32(E1000_EEWR);
+                       reg = E1000_READ_REG(hw, E1000_EEWR);
 
                if (reg & E1000_NVM_RW_REG_DONE) {
-                       ret_val = 0;
+                       ret_val = E1000_SUCCESS;
                        break;
                }
 
-               udelay(5);
+               usec_delay(5);
        }
 
        return ret_val;
 }
 
 /**
- *  e1000_acquire_nvm - Generic request for access to EEPROM
+ *  e1000_acquire_nvm_generic - Generic request for access to EEPROM
  *  @hw: pointer to the HW structure
  *
  *  Set the EEPROM access request bit and wait for EEPROM access grant bit.
  *  Return successful if access grant bit set, else clear the request for
  *  EEPROM access and return -E1000_ERR_NVM (-1).
  **/
-s32 igb_acquire_nvm(struct e1000_hw *hw)
+s32 e1000_acquire_nvm_generic(struct e1000_hw *hw)
 {
-       u32 eecd = rd32(E1000_EECD);
+       u32 eecd = E1000_READ_REG(hw, E1000_EECD);
        s32 timeout = E1000_NVM_GRANT_ATTEMPTS;
-       s32 ret_val = 0;
+       s32 ret_val = E1000_SUCCESS;
 
+       DEBUGFUNC("e1000_acquire_nvm_generic");
 
-       wr32(E1000_EECD, eecd | E1000_EECD_REQ);
-       eecd = rd32(E1000_EECD);
+       E1000_WRITE_REG(hw, E1000_EECD, eecd | E1000_EECD_REQ);
+       eecd = E1000_READ_REG(hw, E1000_EECD);
 
        while (timeout) {
                if (eecd & E1000_EECD_GNT)
                        break;
-               udelay(5);
-               eecd = rd32(E1000_EECD);
+               usec_delay(5);
+               eecd = E1000_READ_REG(hw, E1000_EECD);
                timeout--;
        }
 
        if (!timeout) {
                eecd &= ~E1000_EECD_REQ;
-               wr32(E1000_EECD, eecd);
-               hw_dbg(hw, "Could not acquire NVM grant\n");
+               E1000_WRITE_REG(hw, E1000_EECD, eecd);
+               DEBUGOUT("Could not acquire NVM grant\n");
                ret_val = -E1000_ERR_NVM;
        }
 
@@ -215,36 +234,23 @@ s32 igb_acquire_nvm(struct e1000_hw *hw)
  *
  *  Return the EEPROM to a standby state.
  **/
-static void igb_standby_nvm(struct e1000_hw *hw)
+static void e1000_standby_nvm(struct e1000_hw *hw)
 {
        struct e1000_nvm_info *nvm = &hw->nvm;
-       u32 eecd = rd32(E1000_EECD);
-
-       if (nvm->type == e1000_nvm_eeprom_microwire) {
-               eecd &= ~(E1000_EECD_CS | E1000_EECD_SK);
-               wr32(E1000_EECD, eecd);
-               wrfl();
-               udelay(nvm->delay_usec);
-
-               igb_raise_eec_clk(hw, &eecd);
+       u32 eecd = E1000_READ_REG(hw, E1000_EECD);
 
-               /* Select EEPROM */
-               eecd |= E1000_EECD_CS;
-               wr32(E1000_EECD, eecd);
-               wrfl();
-               udelay(nvm->delay_usec);
+       DEBUGFUNC("e1000_standby_nvm");
 
-               igb_lower_eec_clk(hw, &eecd);
-       } else if (nvm->type == e1000_nvm_eeprom_spi) {
+       if (nvm->type == e1000_nvm_eeprom_spi) {
                /* Toggle CS to flush commands */
                eecd |= E1000_EECD_CS;
-               wr32(E1000_EECD, eecd);
-               wrfl();
-               udelay(nvm->delay_usec);
+               E1000_WRITE_REG(hw, E1000_EECD, eecd);
+               E1000_WRITE_FLUSH(hw);
+               usec_delay(nvm->delay_usec);
                eecd &= ~E1000_EECD_CS;
-               wr32(E1000_EECD, eecd);
-               wrfl();
-               udelay(nvm->delay_usec);
+               E1000_WRITE_REG(hw, E1000_EECD, eecd);
+               E1000_WRITE_FLUSH(hw);
+               usec_delay(nvm->delay_usec);
        }
 }
 
@@ -258,35 +264,33 @@ static void e1000_stop_nvm(struct e1000_hw *hw)
 {
        u32 eecd;
 
-       eecd = rd32(E1000_EECD);
+       DEBUGFUNC("e1000_stop_nvm");
+
+       eecd = E1000_READ_REG(hw, E1000_EECD);
        if (hw->nvm.type == e1000_nvm_eeprom_spi) {
                /* Pull CS high */
                eecd |= E1000_EECD_CS;
-               igb_lower_eec_clk(hw, &eecd);
-       } else if (hw->nvm.type == e1000_nvm_eeprom_microwire) {
-               /* CS on Microcwire is active-high */
-               eecd &= ~(E1000_EECD_CS | E1000_EECD_DI);
-               wr32(E1000_EECD, eecd);
-               igb_raise_eec_clk(hw, &eecd);
-               igb_lower_eec_clk(hw, &eecd);
+               e1000_lower_eec_clk(hw, &eecd);
        }
 }
 
 /**
- *  e1000_release_nvm - Release exclusive access to EEPROM
+ *  e1000_release_nvm_generic - Release exclusive access to EEPROM
  *  @hw: pointer to the HW structure
  *
  *  Stop any current commands to the EEPROM and clear the EEPROM request bit.
  **/
-void igb_release_nvm(struct e1000_hw *hw)
+void e1000_release_nvm_generic(struct e1000_hw *hw)
 {
        u32 eecd;
 
+       DEBUGFUNC("e1000_release_nvm_generic");
+
        e1000_stop_nvm(hw);
 
-       eecd = rd32(E1000_EECD);
+       eecd = E1000_READ_REG(hw, E1000_EECD);
        eecd &= ~E1000_EECD_REQ;
-       wr32(E1000_EECD, eecd);
+       E1000_WRITE_REG(hw, E1000_EECD, eecd);
 }
 
 /**
@@ -295,27 +299,21 @@ void igb_release_nvm(struct e1000_hw *hw)
  *
  *  Setups the EEPROM for reading and writing.
  **/
-static s32 igb_ready_nvm_eeprom(struct e1000_hw *hw)
+static s32 e1000_ready_nvm_eeprom(struct e1000_hw *hw)
 {
        struct e1000_nvm_info *nvm = &hw->nvm;
-       u32 eecd = rd32(E1000_EECD);
-       s32 ret_val = 0;
+       u32 eecd = E1000_READ_REG(hw, E1000_EECD);
+       s32 ret_val = E1000_SUCCESS;
        u16 timeout = 0;
        u8 spi_stat_reg;
 
+       DEBUGFUNC("e1000_ready_nvm_eeprom");
 
-       if (nvm->type == e1000_nvm_eeprom_microwire) {
-               /* Clear SK and DI */
-               eecd &= ~(E1000_EECD_DI | E1000_EECD_SK);
-               wr32(E1000_EECD, eecd);
-               /* Set CS */
-               eecd |= E1000_EECD_CS;
-               wr32(E1000_EECD, eecd);
-       } else if (nvm->type == e1000_nvm_eeprom_spi) {
+       if (nvm->type == e1000_nvm_eeprom_spi) {
                /* Clear SK and CS */
                eecd &= ~(E1000_EECD_CS | E1000_EECD_SK);
-               wr32(E1000_EECD, eecd);
-               udelay(1);
+               E1000_WRITE_REG(hw, E1000_EECD, eecd);
+               usec_delay(1);
                timeout = NVM_MAX_RETRY_SPI;
 
                /*
@@ -325,19 +323,19 @@ static s32 igb_ready_nvm_eeprom(struct e1000_hw *hw)
                 * not cleared within 'timeout', then error out.
                 */
                while (timeout) {
-                       igb_shift_out_eec_bits(hw, NVM_RDSR_OPCODE_SPI,
-                                                hw->nvm.opcode_bits);
-                       spi_stat_reg = (u8)igb_shift_in_eec_bits(hw, 8);
+                       e1000_shift_out_eec_bits(hw, NVM_RDSR_OPCODE_SPI,
+                                                hw->nvm.opcode_bits);
+                       spi_stat_reg = (u8)e1000_shift_in_eec_bits(hw, 8);
                        if (!(spi_stat_reg & NVM_STATUS_RDY_SPI))
                                break;
 
-                       udelay(5);
-                       igb_standby_nvm(hw);
+                       usec_delay(5);
+                       e1000_standby_nvm(hw);
                        timeout--;
                }
 
                if (!timeout) {
-                       hw_dbg(hw, "SPI NVM Status error\n");
+                       DEBUGOUT("SPI NVM Status error\n");
                        ret_val = -E1000_ERR_NVM;
                        goto out;
                }
@@ -356,19 +354,21 @@ out:
  *
  *  Reads a 16 bit word from the EEPROM using the EERD register.
  **/
-s32 igb_read_nvm_eerd(struct e1000_hw *hw, u16 offset, u16 words, u16 *data)
+s32 e1000_read_nvm_eerd(struct e1000_hw *hw, u16 offset, u16 words, u16 *data)
 {
        struct e1000_nvm_info *nvm = &hw->nvm;
        u32 i, eerd = 0;
-       s32 ret_val = 0;
+       s32 ret_val = E1000_SUCCESS;
+
+       DEBUGFUNC("e1000_read_nvm_eerd");
 
        /*
         * A check for invalid values:  offset too large, too many words,
-        * and not enough words.
+        * too many words for the offset, and not enough words.
         */
        if ((offset >= nvm->word_size) || (words > (nvm->word_size - offset)) ||
            (words == 0)) {
-               hw_dbg(hw, "nvm parameter(s) out of bounds\n");
+               DEBUGOUT("nvm parameter(s) out of bounds\n");
                ret_val = -E1000_ERR_NVM;
                goto out;
        }
@@ -377,13 +377,13 @@ s32 igb_read_nvm_eerd(struct e1000_hw *hw, u16 offset, u16 words, u16 *data)
                eerd = ((offset+i) << E1000_NVM_RW_ADDR_SHIFT) +
                       E1000_NVM_RW_REG_START;
 
-               wr32(E1000_EERD, eerd);
-               ret_val = igb_poll_eerd_eewr_done(hw, E1000_NVM_POLL_READ);
+               E1000_WRITE_REG(hw, E1000_EERD, eerd);
+               ret_val = e1000_poll_eerd_eewr_done(hw, E1000_NVM_POLL_READ);
                if (ret_val)
                        break;
 
-               data[i] = (rd32(E1000_EERD) >>
-                          E1000_NVM_RW_REG_DATA);
+               data[i] = (E1000_READ_REG(hw, E1000_EERD) >>
+                          E1000_NVM_RW_REG_DATA);
        }
 
 out:
@@ -400,45 +400,45 @@ out:
  *  Writes data to EEPROM at offset using SPI interface.
  *
  *  If e1000_update_nvm_checksum is not called after this function , the
- *  EEPROM will most likley contain an invalid checksum.
+ *  EEPROM will most likely contain an invalid checksum.
  **/
-s32 igb_write_nvm_spi(struct e1000_hw *hw, u16 offset, u16 words, u16 *data)
+s32 e1000_write_nvm_spi(struct e1000_hw *hw, u16 offset, u16 words, u16 *data)
 {
        struct e1000_nvm_info *nvm = &hw->nvm;
        s32 ret_val;
        u16 widx = 0;
 
+       DEBUGFUNC("e1000_write_nvm_spi");
+
        /*
         * A check for invalid values:  offset too large, too many words,
         * and not enough words.
         */
        if ((offset >= nvm->word_size) || (words > (nvm->word_size - offset)) ||
            (words == 0)) {
-               hw_dbg(hw, "nvm parameter(s) out of bounds\n");
+               DEBUGOUT("nvm parameter(s) out of bounds\n");
                ret_val = -E1000_ERR_NVM;
                goto out;
        }
 
-       ret_val = hw->nvm.ops.acquire_nvm(hw);
+       ret_val = nvm->ops.acquire(hw);
        if (ret_val)
                goto out;
 
-       msleep(10);
-
        while (widx < words) {
                u8 write_opcode = NVM_WRITE_OPCODE_SPI;
 
-               ret_val = igb_ready_nvm_eeprom(hw);
+               ret_val = e1000_ready_nvm_eeprom(hw);
                if (ret_val)
                        goto release;
 
-               igb_standby_nvm(hw);
+               e1000_standby_nvm(hw);
 
                /* Send the WRITE ENABLE command (8 bit opcode) */
-               igb_shift_out_eec_bits(hw, NVM_WREN_OPCODE_SPI,
-                                        nvm->opcode_bits);
+               e1000_shift_out_eec_bits(hw, NVM_WREN_OPCODE_SPI,
+                                        nvm->opcode_bits);
 
-               igb_standby_nvm(hw);
+               e1000_standby_nvm(hw);
 
                /*
                 * Some SPI eeproms use the 8th address bit embedded in the
@@ -448,81 +448,85 @@ s32 igb_write_nvm_spi(struct e1000_hw *hw, u16 offset, u16 words, u16 *data)
                        write_opcode |= NVM_A8_OPCODE_SPI;
 
                /* Send the Write command (8-bit opcode + addr) */
-               igb_shift_out_eec_bits(hw, write_opcode, nvm->opcode_bits);
-               igb_shift_out_eec_bits(hw, (u16)((offset + widx) * 2),
-                                        nvm->address_bits);
+               e1000_shift_out_eec_bits(hw, write_opcode, nvm->opcode_bits);
+               e1000_shift_out_eec_bits(hw, (u16)((offset + widx) * 2),
+                                        nvm->address_bits);
 
                /* Loop to allow for up to whole page write of eeprom */
                while (widx < words) {
                        u16 word_out = data[widx];
                        word_out = (word_out >> 8) | (word_out << 8);
-                       igb_shift_out_eec_bits(hw, word_out, 16);
+                       e1000_shift_out_eec_bits(hw, word_out, 16);
                        widx++;
 
                        if ((((offset + widx) * 2) % nvm->page_size) == 0) {
-                               igb_standby_nvm(hw);
+                               e1000_standby_nvm(hw);
                                break;
                        }
                }
        }
 
-       msleep(10);
+       msec_delay(10);
 release:
-       hw->nvm.ops.release_nvm(hw);
+       nvm->ops.release(hw);
 
 out:
        return ret_val;
 }
 
 /**
- *  e1000_read_part_num - Read device part number
+ *  e1000_read_pba_num_generic - Read device part number
  *  @hw: pointer to the HW structure
- *  @part_num: pointer to device part number
+ *  @pba_num: pointer to device part number
  *
  *  Reads the product board assembly (PBA) number from the EEPROM and stores
- *  the value in part_num.
+ *  the value in pba_num.
  **/
-s32 igb_read_part_num(struct e1000_hw *hw, u32 *part_num)
+s32 e1000_read_pba_num_generic(struct e1000_hw *hw, u32 *pba_num)
 {
        s32  ret_val;
        u16 nvm_data;
 
-       ret_val = hw->nvm.ops.read_nvm(hw, NVM_PBA_OFFSET_0, 1, &nvm_data);
+       DEBUGFUNC("e1000_read_pba_num_generic");
+
+       ret_val = hw->nvm.ops.read(hw, NVM_PBA_OFFSET_0, 1, &nvm_data);
        if (ret_val) {
-               hw_dbg(hw, "NVM Read Error\n");
+               DEBUGOUT("NVM Read Error\n");
                goto out;
        }
-       *part_num = (u32)(nvm_data << 16);
+       *pba_num = (u32)(nvm_data << 16);
 
-       ret_val = hw->nvm.ops.read_nvm(hw, NVM_PBA_OFFSET_1, 1, &nvm_data);
+       ret_val = hw->nvm.ops.read(hw, NVM_PBA_OFFSET_1, 1, &nvm_data);
        if (ret_val) {
-               hw_dbg(hw, "NVM Read Error\n");
+               DEBUGOUT("NVM Read Error\n");
                goto out;
        }
-       *part_num |= nvm_data;
+       *pba_num |= nvm_data;
 
 out:
        return ret_val;
 }
 
 /**
- *  e1000_read_mac_addr - Read device MAC address
+ *  e1000_read_mac_addr_generic - Read device MAC address
  *  @hw: pointer to the HW structure
  *
  *  Reads the device MAC address from the EEPROM and stores the value.
  *  Since devices with two ports use the same EEPROM, we increment the
  *  last bit in the MAC address for the second port.
  **/
-s32 igb_read_mac_addr(struct e1000_hw *hw)
+s32 e1000_read_mac_addr_generic(struct e1000_hw *hw)
 {
-       s32  ret_val = 0;
+       s32  ret_val = E1000_SUCCESS;
        u16 offset, nvm_data, i;
 
-       for (i = 0; i < ETH_ALEN; i += 2) {
+       DEBUGFUNC("e1000_read_mac_addr");
+
+       for (i = 0; i < ETH_ADDR_LEN; i += 2) {
                offset = i >> 1;
-               ret_val = hw->nvm.ops.read_nvm(hw, offset, 1, &nvm_data);
+               ret_val = hw->nvm.ops.read(hw, offset, 1, &nvm_data);
                if (ret_val) {
-                       hw_dbg(hw, "NVM Read Error\n");
+                       DEBUGOUT("NVM Read Error\n");
                        goto out;
                }
                hw->mac.perm_addr[i] = (u8)(nvm_data & 0xFF);
@@ -533,7 +537,7 @@ s32 igb_read_mac_addr(struct e1000_hw *hw)
        if (hw->bus.func == E1000_FUNC_1)
                hw->mac.perm_addr[5] ^= 1;
 
-       for (i = 0; i < ETH_ALEN; i++)
+       for (i = 0; i < ETH_ADDR_LEN; i++)
                hw->mac.addr[i] = hw->mac.perm_addr[i];
 
 out:
@@ -541,29 +545,31 @@ out:
 }
 
 /**
- *  e1000_validate_nvm_checksum - Validate EEPROM checksum
+ *  e1000_validate_nvm_checksum_generic - Validate EEPROM checksum
  *  @hw: pointer to the HW structure
  *
  *  Calculates the EEPROM checksum by reading/adding each word of the EEPROM
  *  and then verifies that the sum of the EEPROM is equal to 0xBABA.
  **/
-s32 igb_validate_nvm_checksum(struct e1000_hw *hw)
+s32 e1000_validate_nvm_checksum_generic(struct e1000_hw *hw)
 {
-       s32 ret_val = 0;
+       s32 ret_val = E1000_SUCCESS;
        u16 checksum = 0;
        u16 i, nvm_data;
 
+       DEBUGFUNC("e1000_validate_nvm_checksum_generic");
+
        for (i = 0; i < (NVM_CHECKSUM_REG + 1); i++) {
-               ret_val = hw->nvm.ops.read_nvm(hw, i, 1, &nvm_data);
+               ret_val = hw->nvm.ops.read(hw, i, 1, &nvm_data);
                if (ret_val) {
-                       hw_dbg(hw, "NVM Read Error\n");
+                       DEBUGOUT("NVM Read Error\n");
                        goto out;
                }
                checksum += nvm_data;
        }
 
        if (checksum != (u16) NVM_SUM) {
-               hw_dbg(hw, "NVM Checksum Invalid\n");
+               DEBUGOUT("NVM Checksum Invalid\n");
                ret_val = -E1000_ERR_NVM;
                goto out;
        }
@@ -573,33 +579,56 @@ out:
 }
 
 /**
- *  e1000_update_nvm_checksum - Update EEPROM checksum
+ *  e1000_update_nvm_checksum_generic - Update EEPROM checksum
  *  @hw: pointer to the HW structure
  *
  *  Updates the EEPROM checksum by reading/adding each word of the EEPROM
  *  up to the checksum.  Then calculates the EEPROM checksum and writes the
  *  value to the EEPROM.
  **/
-s32 igb_update_nvm_checksum(struct e1000_hw *hw)
+s32 e1000_update_nvm_checksum_generic(struct e1000_hw *hw)
 {
        s32  ret_val;
        u16 checksum = 0;
        u16 i, nvm_data;
 
+       DEBUGFUNC("e1000_update_nvm_checksum");
+
        for (i = 0; i < NVM_CHECKSUM_REG; i++) {
-               ret_val = hw->nvm.ops.read_nvm(hw, i, 1, &nvm_data);
+               ret_val = hw->nvm.ops.read(hw, i, 1, &nvm_data);
                if (ret_val) {
-                       hw_dbg(hw, "NVM Read Error while updating checksum.\n");
+                       DEBUGOUT("NVM Read Error while updating checksum.\n");
                        goto out;
                }
                checksum += nvm_data;
        }
        checksum = (u16) NVM_SUM - checksum;
-       ret_val = hw->nvm.ops.write_nvm(hw, NVM_CHECKSUM_REG, 1, &checksum);
-       if (ret_val)
-               hw_dbg(hw, "NVM Write Error while updating checksum.\n");
+       ret_val = hw->nvm.ops.write(hw, NVM_CHECKSUM_REG, 1, &checksum);
+       if (ret_val) {
+               DEBUGOUT("NVM Write Error while updating checksum.\n");
+       }
 
 out:
        return ret_val;
 }
 
+/**
+ *  e1000_reload_nvm_generic - Reloads EEPROM
+ *  @hw: pointer to the HW structure
+ *
+ *  Reloads the EEPROM by setting the "Reinitialize from EEPROM" bit in the
+ *  extended control register.
+ **/
+static void e1000_reload_nvm_generic(struct e1000_hw *hw)
+{
+       u32 ctrl_ext;
+
+       DEBUGFUNC("e1000_reload_nvm_generic");
+
+       usec_delay(10);
+       ctrl_ext = E1000_READ_REG(hw, E1000_CTRL_EXT);
+       ctrl_ext |= E1000_CTRL_EXT_EE_RST;
+       E1000_WRITE_REG(hw, E1000_CTRL_EXT, ctrl_ext);
+       E1000_WRITE_FLUSH(hw);
+}
+
index 1041c34dcbe18280be1abee8baca3557a4b8d6a3..97c1a6b56db44fd420e25054d3f6e8bd76cf83cc 100644 (file)
@@ -1,7 +1,7 @@
 /*******************************************************************************
 
   Intel(R) Gigabit Ethernet Linux driver
-  Copyright(c) 2007 Intel Corporation.
+  Copyright(c) 2007-2008 Intel Corporation.
 
   This program is free software; you can redistribute it and/or modify it
   under the terms and conditions of the GNU General Public License,
 #ifndef _E1000_NVM_H_
 #define _E1000_NVM_H_
 
-s32  igb_acquire_nvm(struct e1000_hw *hw);
-void igb_release_nvm(struct e1000_hw *hw);
-s32  igb_read_mac_addr(struct e1000_hw *hw);
-s32  igb_read_part_num(struct e1000_hw *hw, u32 *part_num);
-s32  igb_read_nvm_eerd(struct e1000_hw *hw, u16 offset, u16 words, u16 *data);
-s32  igb_write_nvm_spi(struct e1000_hw *hw, u16 offset, u16 words, u16 *data);
-s32  igb_validate_nvm_checksum(struct e1000_hw *hw);
-s32  igb_update_nvm_checksum(struct e1000_hw *hw);
+void e1000_init_nvm_ops_generic(struct e1000_hw *hw);
+s32  e1000_acquire_nvm_generic(struct e1000_hw *hw);
+
+s32  e1000_poll_eerd_eewr_done(struct e1000_hw *hw, int ee_reg);
+s32  e1000_read_mac_addr_generic(struct e1000_hw *hw);
+s32  e1000_read_pba_num_generic(struct e1000_hw *hw, u32 *pba_num);
+s32  e1000_read_nvm_eerd(struct e1000_hw *hw, u16 offset, u16 words,
+                         u16 *data);
+s32  e1000_valid_led_default_generic(struct e1000_hw *hw, u16 *data);
+s32  e1000_validate_nvm_checksum_generic(struct e1000_hw *hw);
+s32  e1000_write_nvm_eewr(struct e1000_hw *hw, u16 offset,
+                          u16 words, u16 *data);
+s32  e1000_write_nvm_spi(struct e1000_hw *hw, u16 offset, u16 words,
+                         u16 *data);
+s32  e1000_update_nvm_checksum_generic(struct e1000_hw *hw);
+void e1000_release_nvm_generic(struct e1000_hw *hw);
+
+#define E1000_STM_OPCODE  0xDB00
 
 #endif
diff --git a/drivers/net/igb/e1000_osdep.h b/drivers/net/igb/e1000_osdep.h
new file mode 100644 (file)
index 0000000..1856f69
--- /dev/null
@@ -0,0 +1,121 @@
+/*******************************************************************************
+
+  Intel(R) Gigabit Ethernet Linux driver
+  Copyright(c) 2007-2008 Intel Corporation.
+
+  This program is free software; you can redistribute it and/or modify it
+  under the terms and conditions of the GNU General Public License,
+  version 2, as published by the Free Software Foundation.
+
+  This program is distributed in the hope it will be useful, but WITHOUT
+  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+  FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
+  more details.
+
+  You should have received a copy of the GNU General Public License along with
+  this program; if not, write to the Free Software Foundation, Inc.,
+  51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
+
+  The full GNU General Public License is included in this distribution in
+  the file called "COPYING".
+
+  Contact Information:
+  e1000-devel Mailing List <e1000-devel@lists.sourceforge.net>
+  Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
+
+*******************************************************************************/
+
+
+/* glue for the OS independent part of e1000
+ * includes register access macros
+ */
+
+#ifndef _E1000_OSDEP_H_
+#define _E1000_OSDEP_H_
+
+#include <linux/pci.h>
+#include <linux/delay.h>
+#include <linux/interrupt.h>
+#include <linux/if_ether.h>
+#include <linux/sched.h>
+#include "kcompat.h"
+
+#define usec_delay(x) udelay(x)
+#ifndef msec_delay
+#define msec_delay(x)  do { if (in_interrupt()) { \
+                               /* Don't mdelay in interrupt context! */ \
+                               BUG(); \
+                       } else { \
+                               msleep(x); \
+                       } } while (0)
+
+/* Some workarounds require millisecond delays and are run during interrupt
+ * context.  Most notably, when establishing link, the phy may need tweaking
+ * but cannot process phy register reads/writes faster than millisecond
+ * intervals...and we establish link due to a "link status change" interrupt.
+ */
+#define msec_delay_irq(x) mdelay(x)
+#endif
+
+#define PCI_COMMAND_REGISTER   PCI_COMMAND
+#define CMD_MEM_WRT_INVALIDATE PCI_COMMAND_INVALIDATE
+#define ETH_ADDR_LEN           ETH_ALEN
+
+#ifdef __BIG_ENDIAN
+#define E1000_BIG_ENDIAN __BIG_ENDIAN
+#endif
+
+
+#define DEBUGOUT(S)
+#define DEBUGOUT1(S, A...)
+
+#define DEBUGFUNC(F) DEBUGOUT(F "\n")
+#define DEBUGOUT2 DEBUGOUT1
+#define DEBUGOUT3 DEBUGOUT2
+#define DEBUGOUT7 DEBUGOUT3
+
+#define E1000_REGISTER(a, reg) reg
+
+#define E1000_WRITE_REG(a, reg, value) ( \
+    writel((value), ((a)->hw_addr + E1000_REGISTER(a, reg))))
+
+#define E1000_READ_REG(a, reg) (readl((a)->hw_addr + E1000_REGISTER(a, reg)))
+
+#define E1000_WRITE_REG_ARRAY(a, reg, offset, value) ( \
+    writel((value), ((a)->hw_addr + E1000_REGISTER(a, reg) + ((offset) << 2))))
+
+#define E1000_READ_REG_ARRAY(a, reg, offset) ( \
+    readl((a)->hw_addr + E1000_REGISTER(a, reg) + ((offset) << 2)))
+
+#define E1000_READ_REG_ARRAY_DWORD E1000_READ_REG_ARRAY
+#define E1000_WRITE_REG_ARRAY_DWORD E1000_WRITE_REG_ARRAY
+
+#define E1000_WRITE_REG_ARRAY_WORD(a, reg, offset, value) ( \
+    writew((value), ((a)->hw_addr + E1000_REGISTER(a, reg) + ((offset) << 1))))
+
+#define E1000_READ_REG_ARRAY_WORD(a, reg, offset) ( \
+    readw((a)->hw_addr + E1000_REGISTER(a, reg) + ((offset) << 1)))
+
+#define E1000_WRITE_REG_ARRAY_BYTE(a, reg, offset, value) ( \
+    writeb((value), ((a)->hw_addr + E1000_REGISTER(a, reg) + (offset))))
+
+#define E1000_READ_REG_ARRAY_BYTE(a, reg, offset) ( \
+    readb((a)->hw_addr + E1000_REGISTER(a, reg) + (offset)))
+
+#define E1000_WRITE_REG_IO(a, reg, offset) do { \
+    outl(reg, ((a)->io_base));                  \
+    outl(offset, ((a)->io_base + 4));      } while (0)
+
+#define E1000_WRITE_FLUSH(a) E1000_READ_REG(a, E1000_STATUS)
+
+#define E1000_WRITE_FLASH_REG(a, reg, value) ( \
+    writel((value), ((a)->flash_address + reg)))
+
+#define E1000_WRITE_FLASH_REG16(a, reg, value) ( \
+    writew((value), ((a)->flash_address + reg)))
+
+#define E1000_READ_FLASH_REG(a, reg) (readl((a)->flash_address + reg))
+
+#define E1000_READ_FLASH_REG16(a, reg) (readw((a)->flash_address + reg))
+
+#endif /* _E1000_OSDEP_H_ */
index 08a86b107229cde92e30594e45215d5850616e02..36f906f09e83c414469b78f19b32474933ebd7c5 100644 (file)
@@ -1,7 +1,7 @@
 /*******************************************************************************
 
   Intel(R) Gigabit Ethernet Linux driver
-  Copyright(c) 2007 Intel Corporation.
+  Copyright(c) 2007-2008 Intel Corporation.
 
   This program is free software; you can redistribute it and/or modify it
   under the terms and conditions of the GNU General Public License,
 
 *******************************************************************************/
 
-#include <linux/if_ether.h>
-#include <linux/delay.h>
-
-#include "e1000_mac.h"
-#include "e1000_phy.h"
-
-static s32  igb_get_phy_cfg_done(struct e1000_hw *hw);
-static void igb_release_phy(struct e1000_hw *hw);
-static s32  igb_acquire_phy(struct e1000_hw *hw);
-static s32  igb_phy_reset_dsp(struct e1000_hw *hw);
-static s32  igb_phy_setup_autoneg(struct e1000_hw *hw);
-static void igb_phy_force_speed_duplex_setup(struct e1000_hw *hw,
-                                              u16 *phy_ctrl);
-static s32  igb_wait_autoneg(struct e1000_hw *hw);
+#include "e1000_api.h"
 
+static s32 e1000_phy_setup_autoneg(struct e1000_hw *hw);
 /* Cable length tables */
 static const u16 e1000_m88_cable_length_table[] =
        { 0, 50, 80, 110, 140, 140, E1000_CABLE_LENGTH_UNDEFINED };
 #define M88E1000_CABLE_LENGTH_TABLE_SIZE \
-               (sizeof(e1000_m88_cable_length_table) / \
-                sizeof(e1000_m88_cable_length_table[0]))
+                (sizeof(e1000_m88_cable_length_table) / \
+                 sizeof(e1000_m88_cable_length_table[0]))
 
 static const u16 e1000_igp_2_cable_length_table[] =
     { 0, 0, 0, 0, 0, 0, 0, 0, 3, 5, 8, 11, 13, 16, 18, 21,
@@ -57,25 +45,27 @@ static const u16 e1000_igp_2_cable_length_table[] =
       83, 89, 95, 100, 105, 109, 113, 116, 119, 122, 124,
       104, 109, 114, 118, 121, 124};
 #define IGP02E1000_CABLE_LENGTH_TABLE_SIZE \
-               (sizeof(e1000_igp_2_cable_length_table) / \
-                sizeof(e1000_igp_2_cable_length_table[0]))
+                (sizeof(e1000_igp_2_cable_length_table) / \
+                 sizeof(e1000_igp_2_cable_length_table[0]))
 
 /**
- *  e1000_check_reset_block - Check if PHY reset is blocked
+ *  e1000_check_reset_block_generic - Check if PHY reset is blocked
  *  @hw: pointer to the HW structure
  *
  *  Read the PHY management control register and check whether a PHY reset
- *  is blocked.  If a reset is not blocked return 0, otherwise
+ *  is blocked.  If a reset is not blocked return E1000_SUCCESS, otherwise
  *  return E1000_BLK_PHY_RESET (12).
  **/
-s32 igb_check_reset_block(struct e1000_hw *hw)
+s32 e1000_check_reset_block_generic(struct e1000_hw *hw)
 {
        u32 manc;
 
-       manc = rd32(E1000_MANC);
+       DEBUGFUNC("e1000_check_reset_block");
+
+       manc = E1000_READ_REG(hw, E1000_MANC);
 
        return (manc & E1000_MANC_BLK_PHY_RST_ON_IDE) ?
-              E1000_BLK_PHY_RESET : 0;
+              E1000_BLK_PHY_RESET : E1000_SUCCESS;
 }
 
 /**
@@ -85,19 +75,24 @@ s32 igb_check_reset_block(struct e1000_hw *hw)
  *  Reads the PHY registers and stores the PHY ID and possibly the PHY
  *  revision in the hardware structure.
  **/
-s32 igb_get_phy_id(struct e1000_hw *hw)
+s32 e1000_get_phy_id(struct e1000_hw *hw)
 {
        struct e1000_phy_info *phy = &hw->phy;
-       s32 ret_val = 0;
+       s32 ret_val = E1000_SUCCESS;
        u16 phy_id;
 
-       ret_val = hw->phy.ops.read_phy_reg(hw, PHY_ID1, &phy_id);
+       DEBUGFUNC("e1000_get_phy_id");
+
+       if (!(phy->ops.read_reg))
+               goto out;
+
+       ret_val = phy->ops.read_reg(hw, PHY_ID1, &phy_id);
        if (ret_val)
                goto out;
 
        phy->id = (u32)(phy_id << 16);
-       udelay(20);
-       ret_val = hw->phy.ops.read_phy_reg(hw, PHY_ID2, &phy_id);
+       usec_delay(20);
+       ret_val = phy->ops.read_reg(hw, PHY_ID2, &phy_id);
        if (ret_val)
                goto out;
 
@@ -109,20 +104,25 @@ out:
 }
 
 /**
- *  e1000_phy_reset_dsp - Reset PHY DSP
+ *  e1000_phy_reset_dsp_generic - Reset PHY DSP
  *  @hw: pointer to the HW structure
  *
  *  Reset the digital signal processor.
  **/
-static s32 igb_phy_reset_dsp(struct e1000_hw *hw)
+s32 e1000_phy_reset_dsp_generic(struct e1000_hw *hw)
 {
-       s32 ret_val;
+       s32 ret_val = E1000_SUCCESS;
+
+       DEBUGFUNC("e1000_phy_reset_dsp_generic");
 
-       ret_val = hw->phy.ops.write_phy_reg(hw, M88E1000_PHY_GEN_CONTROL, 0xC1);
+       if (!(hw->phy.ops.write_reg))
+               goto out;
+
+       ret_val = hw->phy.ops.write_reg(hw, M88E1000_PHY_GEN_CONTROL, 0xC1);
        if (ret_val)
                goto out;
 
-       ret_val = hw->phy.ops.write_phy_reg(hw, M88E1000_PHY_GEN_CONTROL, 0);
+       ret_val = hw->phy.ops.write_reg(hw, M88E1000_PHY_GEN_CONTROL, 0);
 
 out:
        return ret_val;
@@ -134,20 +134,16 @@ out:
  *  @offset: register offset to be read
  *  @data: pointer to the read data
  *
- *  Reads the MDI control regsiter in the PHY at offset and stores the
+ *  Reads the MDI control register in the PHY at offset and stores the
  *  information read to data.
  **/
-static s32 igb_read_phy_reg_mdic(struct e1000_hw *hw, u32 offset, u16 *data)
+s32 e1000_read_phy_reg_mdic(struct e1000_hw *hw, u32 offset, u16 *data)
 {
        struct e1000_phy_info *phy = &hw->phy;
        u32 i, mdic = 0;
-       s32 ret_val = 0;
+       s32 ret_val = E1000_SUCCESS;
 
-       if (offset > MAX_PHY_REG_ADDRESS) {
-               hw_dbg(hw, "PHY Address %d is out of range\n", offset);
-               ret_val = -E1000_ERR_PARAM;
-               goto out;
-       }
+       DEBUGFUNC("e1000_read_phy_reg_mdic");
 
        /*
         * Set up Op-code, Phy Address, and register offset in the MDI
@@ -155,10 +151,10 @@ static s32 igb_read_phy_reg_mdic(struct e1000_hw *hw, u32 offset, u16 *data)
         * PHY to retrieve the desired data.
         */
        mdic = ((offset << E1000_MDIC_REG_SHIFT) |
-               (phy->addr << E1000_MDIC_PHY_SHIFT) |
-               (E1000_MDIC_OP_READ));
+               (phy->addr << E1000_MDIC_PHY_SHIFT) |
+               (E1000_MDIC_OP_READ));
 
-       wr32(E1000_MDIC, mdic);
+       E1000_WRITE_REG(hw, E1000_MDIC, mdic);
 
        /*
         * Poll the ready bit to see if the MDI read completed
@@ -166,18 +162,18 @@ static s32 igb_read_phy_reg_mdic(struct e1000_hw *hw, u32 offset, u16 *data)
         * the lower time out
         */
        for (i = 0; i < (E1000_GEN_POLL_TIMEOUT * 3); i++) {
-               udelay(50);
-               mdic = rd32(E1000_MDIC);
+               usec_delay(50);
+               mdic = E1000_READ_REG(hw, E1000_MDIC);
                if (mdic & E1000_MDIC_READY)
                        break;
        }
        if (!(mdic & E1000_MDIC_READY)) {
-               hw_dbg(hw, "MDI Read did not complete\n");
+               DEBUGOUT("MDI Read did not complete\n");
                ret_val = -E1000_ERR_PHY;
                goto out;
        }
        if (mdic & E1000_MDIC_ERROR) {
-               hw_dbg(hw, "MDI Error\n");
+               DEBUGOUT("MDI Error\n");
                ret_val = -E1000_ERR_PHY;
                goto out;
        }
@@ -195,17 +191,13 @@ out:
  *
  *  Writes data to MDI control register in the PHY at offset.
  **/
-static s32 igb_write_phy_reg_mdic(struct e1000_hw *hw, u32 offset, u16 data)
+s32 e1000_write_phy_reg_mdic(struct e1000_hw *hw, u32 offset, u16 data)
 {
        struct e1000_phy_info *phy = &hw->phy;
        u32 i, mdic = 0;
-       s32 ret_val = 0;
+       s32 ret_val = E1000_SUCCESS;
 
-       if (offset > MAX_PHY_REG_ADDRESS) {
-               hw_dbg(hw, "PHY Address %d is out of range\n", offset);
-               ret_val = -E1000_ERR_PARAM;
-               goto out;
-       }
+       DEBUGFUNC("e1000_write_phy_reg_mdic");
 
        /*
         * Set up Op-code, Phy Address, and register offset in the MDI
@@ -213,11 +205,11 @@ static s32 igb_write_phy_reg_mdic(struct e1000_hw *hw, u32 offset, u16 data)
         * PHY to retrieve the desired data.
         */
        mdic = (((u32)data) |
-               (offset << E1000_MDIC_REG_SHIFT) |
-               (phy->addr << E1000_MDIC_PHY_SHIFT) |
-               (E1000_MDIC_OP_WRITE));
+               (offset << E1000_MDIC_REG_SHIFT) |
+               (phy->addr << E1000_MDIC_PHY_SHIFT) |
+               (E1000_MDIC_OP_WRITE));
 
-       wr32(E1000_MDIC, mdic);
+       E1000_WRITE_REG(hw, E1000_MDIC, mdic);
 
        /*
         * Poll the ready bit to see if the MDI read completed
@@ -225,18 +217,18 @@ static s32 igb_write_phy_reg_mdic(struct e1000_hw *hw, u32 offset, u16 data)
         * the lower time out
         */
        for (i = 0; i < (E1000_GEN_POLL_TIMEOUT * 3); i++) {
-               udelay(50);
-               mdic = rd32(E1000_MDIC);
+               usec_delay(50);
+               mdic = E1000_READ_REG(hw, E1000_MDIC);
                if (mdic & E1000_MDIC_READY)
                        break;
        }
        if (!(mdic & E1000_MDIC_READY)) {
-               hw_dbg(hw, "MDI Write did not complete\n");
+               DEBUGOUT("MDI Write did not complete\n");
                ret_val = -E1000_ERR_PHY;
                goto out;
        }
        if (mdic & E1000_MDIC_ERROR) {
-               hw_dbg(hw, "MDI Error\n");
+               DEBUGOUT("MDI Error\n");
                ret_val = -E1000_ERR_PHY;
                goto out;
        }
@@ -245,6 +237,69 @@ out:
        return ret_val;
 }
 
+/**
+ *  e1000_read_phy_reg_m88 - Read m88 PHY register
+ *  @hw: pointer to the HW structure
+ *  @offset: register offset to be read
+ *  @data: pointer to the read data
+ *
+ *  Acquires semaphore, if necessary, then reads the PHY register at offset
+ *  and storing the retrieved information in data.  Release any acquired
+ *  semaphores before exiting.
+ **/
+s32 e1000_read_phy_reg_m88(struct e1000_hw *hw, u32 offset, u16 *data)
+{
+       s32 ret_val = E1000_SUCCESS;
+
+       DEBUGFUNC("e1000_read_phy_reg_m88");
+
+       if (!(hw->phy.ops.acquire))
+               goto out;
+
+       ret_val = hw->phy.ops.acquire(hw);
+       if (ret_val)
+               goto out;
+
+       ret_val = e1000_read_phy_reg_mdic(hw, MAX_PHY_REG_ADDRESS & offset,
+                                         data);
+
+       hw->phy.ops.release(hw);
+
+out:
+       return ret_val;
+}
+
+/**
+ *  e1000_write_phy_reg_m88 - Write m88 PHY register
+ *  @hw: pointer to the HW structure
+ *  @offset: register offset to write to
+ *  @data: data to write at register offset
+ *
+ *  Acquires semaphore, if necessary, then writes the data to PHY register
+ *  at the offset.  Release any acquired semaphores before exiting.
+ **/
+s32 e1000_write_phy_reg_m88(struct e1000_hw *hw, u32 offset, u16 data)
+{
+       s32 ret_val = E1000_SUCCESS;
+
+       DEBUGFUNC("e1000_write_phy_reg_m88");
+
+       if (!(hw->phy.ops.acquire))
+               goto out;
+
+       ret_val = hw->phy.ops.acquire(hw);
+       if (ret_val)
+               goto out;
+
+       ret_val = e1000_write_phy_reg_mdic(hw, MAX_PHY_REG_ADDRESS & offset,
+                                          data);
+
+       hw->phy.ops.release(hw);
+
+out:
+       return ret_val;
+}
+
 /**
  *  e1000_read_phy_reg_igp - Read igp PHY register
  *  @hw: pointer to the HW structure
@@ -255,29 +310,33 @@ out:
  *  and storing the retrieved information in data.  Release any acquired
  *  semaphores before exiting.
  **/
-s32 igb_read_phy_reg_igp(struct e1000_hw *hw, u32 offset, u16 *data)
+s32 e1000_read_phy_reg_igp(struct e1000_hw *hw, u32 offset, u16 *data)
 {
-       s32 ret_val;
+       s32 ret_val = E1000_SUCCESS;
+
+       DEBUGFUNC("e1000_read_phy_reg_igp");
+
+       if (!(hw->phy.ops.acquire))
+               goto out;
 
-       ret_val = igb_acquire_phy(hw);
+       ret_val = hw->phy.ops.acquire(hw);
        if (ret_val)
                goto out;
 
        if (offset > MAX_PHY_MULTI_PAGE_REG) {
-               ret_val = igb_write_phy_reg_mdic(hw,
-                                                  IGP01E1000_PHY_PAGE_SELECT,
-                                                  (u16)offset);
+               ret_val = e1000_write_phy_reg_mdic(hw,
+                                                  IGP01E1000_PHY_PAGE_SELECT,
+                                                  (u16)offset);
                if (ret_val) {
-                       igb_release_phy(hw);
+                       hw->phy.ops.release(hw);
                        goto out;
                }
        }
 
-       ret_val = igb_read_phy_reg_mdic(hw,
-                                         MAX_PHY_REG_ADDRESS & offset,
-                                         data);
+       ret_val = e1000_read_phy_reg_mdic(hw, MAX_PHY_REG_ADDRESS & offset,
+                                         data);
 
-       igb_release_phy(hw);
+       hw->phy.ops.release(hw);
 
 out:
        return ret_val;
@@ -292,29 +351,107 @@ out:
  *  Acquires semaphore, if necessary, then writes the data to PHY register
  *  at the offset.  Release any acquired semaphores before exiting.
  **/
-s32 igb_write_phy_reg_igp(struct e1000_hw *hw, u32 offset, u16 data)
+s32 e1000_write_phy_reg_igp(struct e1000_hw *hw, u32 offset, u16 data)
 {
-       s32 ret_val;
+       s32 ret_val = E1000_SUCCESS;
+
+       DEBUGFUNC("e1000_write_phy_reg_igp");
+
+       if (!(hw->phy.ops.acquire))
+               goto out;
 
-       ret_val = igb_acquire_phy(hw);
+       ret_val = hw->phy.ops.acquire(hw);
        if (ret_val)
                goto out;
 
        if (offset > MAX_PHY_MULTI_PAGE_REG) {
-               ret_val = igb_write_phy_reg_mdic(hw,
-                                                  IGP01E1000_PHY_PAGE_SELECT,
-                                                  (u16)offset);
+               ret_val = e1000_write_phy_reg_mdic(hw,
+                                                  IGP01E1000_PHY_PAGE_SELECT,
+                                                  (u16)offset);
                if (ret_val) {
-                       igb_release_phy(hw);
+                       hw->phy.ops.release(hw);
                        goto out;
                }
        }
 
-       ret_val = igb_write_phy_reg_mdic(hw,
-                                          MAX_PHY_REG_ADDRESS & offset,
-                                          data);
+       ret_val = e1000_write_phy_reg_mdic(hw, MAX_PHY_REG_ADDRESS & offset,
+                                          data);
+
+       hw->phy.ops.release(hw);
+
+out:
+       return ret_val;
+}
+
+/**
+ *  e1000_read_kmrn_reg_generic - Read kumeran register
+ *  @hw: pointer to the HW structure
+ *  @offset: register offset to be read
+ *  @data: pointer to the read data
+ *
+ *  Acquires semaphore, if necessary.  Then reads the PHY register at offset
+ *  using the kumeran interface.  The information retrieved is stored in data.
+ *  Release any acquired semaphores before exiting.
+ **/
+s32 e1000_read_kmrn_reg_generic(struct e1000_hw *hw, u32 offset, u16 *data)
+{
+       u32 kmrnctrlsta;
+       s32 ret_val = E1000_SUCCESS;
+
+       DEBUGFUNC("e1000_read_kmrn_reg_generic");
+
+       if (!(hw->phy.ops.acquire))
+               goto out;
+
+       ret_val = hw->phy.ops.acquire(hw);
+       if (ret_val)
+               goto out;
+
+       kmrnctrlsta = ((offset << E1000_KMRNCTRLSTA_OFFSET_SHIFT) &
+                      E1000_KMRNCTRLSTA_OFFSET) | E1000_KMRNCTRLSTA_REN;
+       E1000_WRITE_REG(hw, E1000_KMRNCTRLSTA, kmrnctrlsta);
+
+       usec_delay(2);
 
-       igb_release_phy(hw);
+       kmrnctrlsta = E1000_READ_REG(hw, E1000_KMRNCTRLSTA);
+       *data = (u16)kmrnctrlsta;
+
+       hw->phy.ops.release(hw);
+
+out:
+       return ret_val;
+}
+
+/**
+ *  e1000_write_kmrn_reg_generic - Write kumeran register
+ *  @hw: pointer to the HW structure
+ *  @offset: register offset to write to
+ *  @data: data to write at register offset
+ *
+ *  Acquires semaphore, if necessary.  Then write the data to PHY register
+ *  at the offset using the kumeran interface.  Release any acquired semaphores
+ *  before exiting.
+ **/
+s32 e1000_write_kmrn_reg_generic(struct e1000_hw *hw, u32 offset, u16 data)
+{
+       u32 kmrnctrlsta;
+       s32 ret_val = E1000_SUCCESS;
+
+       DEBUGFUNC("e1000_write_kmrn_reg_generic");
+
+       if (!(hw->phy.ops.acquire))
+               goto out;
+
+       ret_val = hw->phy.ops.acquire(hw);
+       if (ret_val)
+               goto out;
+
+       kmrnctrlsta = ((offset << E1000_KMRNCTRLSTA_OFFSET_SHIFT) &
+                      E1000_KMRNCTRLSTA_OFFSET) | data;
+       E1000_WRITE_REG(hw, E1000_KMRNCTRLSTA, kmrnctrlsta);
+
+       usec_delay(2);
+       hw->phy.ops.release(hw);
 
 out:
        return ret_val;
@@ -327,20 +464,21 @@ out:
  *  Sets up MDI/MDI-X and polarity for m88 PHY's.  If necessary, transmit clock
  *  and downshift values are set also.
  **/
-s32 igb_copper_link_setup_m88(struct e1000_hw *hw)
+s32 e1000_copper_link_setup_m88(struct e1000_hw *hw)
 {
        struct e1000_phy_info *phy = &hw->phy;
        s32 ret_val;
        u16 phy_data;
 
+       DEBUGFUNC("e1000_copper_link_setup_m88");
+
        if (phy->reset_disable) {
-               ret_val = 0;
+               ret_val = E1000_SUCCESS;
                goto out;
        }
 
        /* Enable CRS on TX. This must be set for half-duplex operation. */
-       ret_val = hw->phy.ops.read_phy_reg(hw, M88E1000_PHY_SPEC_CTRL,
-                                          &phy_data);
+       ret_val = phy->ops.read_reg(hw, M88E1000_PHY_SPEC_CTRL, &phy_data);
        if (ret_val)
                goto out;
 
@@ -383,8 +521,7 @@ s32 igb_copper_link_setup_m88(struct e1000_hw *hw)
        if (phy->disable_polarity_correction == 1)
                phy_data |= M88E1000_PSCR_POLARITY_REVERSAL;
 
-       ret_val = hw->phy.ops.write_phy_reg(hw, M88E1000_PHY_SPEC_CTRL,
-                                           phy_data);
+       ret_val = phy->ops.write_reg(hw, M88E1000_PHY_SPEC_CTRL, phy_data);
        if (ret_val)
                goto out;
 
@@ -393,9 +530,8 @@ s32 igb_copper_link_setup_m88(struct e1000_hw *hw)
                 * Force TX_CLK in the Extended PHY Specific Control Register
                 * to 25MHz clock.
                 */
-               ret_val = hw->phy.ops.read_phy_reg(hw,
-                                            M88E1000_EXT_PHY_SPEC_CTRL,
-                                            &phy_data);
+               ret_val = phy->ops.read_reg(hw, M88E1000_EXT_PHY_SPEC_CTRL,
+                                            &phy_data);
                if (ret_val)
                        goto out;
 
@@ -409,21 +545,20 @@ s32 igb_copper_link_setup_m88(struct e1000_hw *hw)
                } else {
                        /* Configure Master and Slave downshift values */
                        phy_data &= ~(M88E1000_EPSCR_MASTER_DOWNSHIFT_MASK |
-                                     M88E1000_EPSCR_SLAVE_DOWNSHIFT_MASK);
+                                    M88E1000_EPSCR_SLAVE_DOWNSHIFT_MASK);
                        phy_data |= (M88E1000_EPSCR_MASTER_DOWNSHIFT_1X |
-                                    M88E1000_EPSCR_SLAVE_DOWNSHIFT_1X);
+                                    M88E1000_EPSCR_SLAVE_DOWNSHIFT_1X);
                }
-               ret_val = hw->phy.ops.write_phy_reg(hw,
-                                            M88E1000_EXT_PHY_SPEC_CTRL,
-                                            phy_data);
+               ret_val = phy->ops.write_reg(hw, M88E1000_EXT_PHY_SPEC_CTRL,
+                                            phy_data);
                if (ret_val)
                        goto out;
        }
 
        /* Commit the changes. */
-       ret_val = igb_phy_sw_reset(hw);
+       ret_val = phy->ops.commit(hw);
        if (ret_val) {
-               hw_dbg(hw, "Error committing the PHY changes\n");
+               DEBUGOUT("Error committing the PHY changes\n");
                goto out;
        }
 
@@ -438,25 +573,30 @@ out:
  *  Sets up LPLU, MDI/MDI-X, polarity, Smartspeed and Master/Slave config for
  *  igp PHY's.
  **/
-s32 igb_copper_link_setup_igp(struct e1000_hw *hw)
+s32 e1000_copper_link_setup_igp(struct e1000_hw *hw)
 {
        struct e1000_phy_info *phy = &hw->phy;
        s32 ret_val;
        u16 data;
 
+       DEBUGFUNC("e1000_copper_link_setup_igp");
+
        if (phy->reset_disable) {
-               ret_val = 0;
+               ret_val = E1000_SUCCESS;
                goto out;
        }
 
-       ret_val = hw->phy.ops.reset_phy(hw);
+       ret_val = hw->phy.ops.reset(hw);
        if (ret_val) {
-               hw_dbg(hw, "Error resetting the PHY.\n");
+               DEBUGOUT("Error resetting the PHY.\n");
                goto out;
        }
 
-       /* Wait 15ms for MAC to configure PHY from NVM settings. */
-       msleep(15);
+       /*
+        * Wait 100ms for MAC to configure PHY from NVM settings, to avoid
+        * timeout issues when LFS is enabled.
+        */
+       msec_delay(100);
 
        /*
         * The NVM settings will configure LPLU in D3 for
@@ -464,22 +604,23 @@ s32 igb_copper_link_setup_igp(struct e1000_hw *hw)
         */
        if (phy->type == e1000_phy_igp) {
                /* disable lplu d3 during driver init */
-               if (hw->phy.ops.set_d3_lplu_state)
-                       ret_val = hw->phy.ops.set_d3_lplu_state(hw, false);
+               ret_val = hw->phy.ops.set_d3_lplu_state(hw, false);
                if (ret_val) {
-                       hw_dbg(hw, "Error Disabling LPLU D3\n");
+                       DEBUGOUT("Error Disabling LPLU D3\n");
                        goto out;
                }
        }
 
        /* disable lplu d0 during driver init */
-       ret_val = hw->phy.ops.set_d0_lplu_state(hw, false);
-       if (ret_val) {
-               hw_dbg(hw, "Error Disabling LPLU D0\n");
-               goto out;
+       if (hw->phy.ops.set_d0_lplu_state) {
+               ret_val = hw->phy.ops.set_d0_lplu_state(hw, false);
+               if (ret_val) {
+                       DEBUGOUT("Error Disabling LPLU D0\n");
+                       goto out;
+               }
        }
        /* Configure mdi-mdix settings */
-       ret_val = hw->phy.ops.read_phy_reg(hw, IGP01E1000_PHY_PORT_CTRL, &data);
+       ret_val = phy->ops.read_reg(hw, IGP01E1000_PHY_PORT_CTRL, &data);
        if (ret_val)
                goto out;
 
@@ -497,7 +638,7 @@ s32 igb_copper_link_setup_igp(struct e1000_hw *hw)
                data |= IGP01E1000_PSCR_AUTO_MDIX;
                break;
        }
-       ret_val = hw->phy.ops.write_phy_reg(hw, IGP01E1000_PHY_PORT_CTRL, data);
+       ret_val = phy->ops.write_reg(hw, IGP01E1000_PHY_PORT_CTRL, data);
        if (ret_val)
                goto out;
 
@@ -510,33 +651,31 @@ s32 igb_copper_link_setup_igp(struct e1000_hw *hw)
                 */
                if (phy->autoneg_advertised == ADVERTISE_1000_FULL) {
                        /* Disable SmartSpeed */
-                       ret_val = hw->phy.ops.read_phy_reg(hw,
-                                                    IGP01E1000_PHY_PORT_CONFIG,
-                                                    &data);
+                       ret_val = phy->ops.read_reg(hw,
+                                                    IGP01E1000_PHY_PORT_CONFIG,
+                                                    &data);
                        if (ret_val)
                                goto out;
 
                        data &= ~IGP01E1000_PSCFR_SMART_SPEED;
-                       ret_val = hw->phy.ops.write_phy_reg(hw,
-                                                    IGP01E1000_PHY_PORT_CONFIG,
-                                                    data);
+                       ret_val = phy->ops.write_reg(hw,
+                                                    IGP01E1000_PHY_PORT_CONFIG,
+                                                    data);
                        if (ret_val)
                                goto out;
 
                        /* Set auto Master/Slave resolution process */
-                       ret_val = hw->phy.ops.read_phy_reg(hw, PHY_1000T_CTRL,
-                                                          &data);
+                       ret_val = phy->ops.read_reg(hw, PHY_1000T_CTRL, &data);
                        if (ret_val)
                                goto out;
 
                        data &= ~CR_1000T_MS_ENABLE;
-                       ret_val = hw->phy.ops.write_phy_reg(hw, PHY_1000T_CTRL,
-                                                           data);
+                       ret_val = phy->ops.write_reg(hw, PHY_1000T_CTRL, data);
                        if (ret_val)
                                goto out;
                }
 
-               ret_val = hw->phy.ops.read_phy_reg(hw, PHY_1000T_CTRL, &data);
+               ret_val = phy->ops.read_reg(hw, PHY_1000T_CTRL, &data);
                if (ret_val)
                        goto out;
 
@@ -560,7 +699,7 @@ s32 igb_copper_link_setup_igp(struct e1000_hw *hw)
                default:
                        break;
                }
-               ret_val = hw->phy.ops.write_phy_reg(hw, PHY_1000T_CTRL, data);
+               ret_val = phy->ops.write_reg(hw, PHY_1000T_CTRL, data);
                if (ret_val)
                        goto out;
        }
@@ -578,12 +717,14 @@ out:
  *  and restart the negotiation process between the link partner.  If
  *  autoneg_wait_to_complete, then wait for autoneg to complete before exiting.
  **/
-s32 igb_copper_link_autoneg(struct e1000_hw *hw)
+s32 e1000_copper_link_autoneg(struct e1000_hw *hw)
 {
        struct e1000_phy_info *phy = &hw->phy;
        s32 ret_val;
        u16 phy_ctrl;
 
+       DEBUGFUNC("e1000_copper_link_autoneg");
+
        /*
         * Perform some bounds checking on the autoneg advertisement
         * parameter.
@@ -597,24 +738,24 @@ s32 igb_copper_link_autoneg(struct e1000_hw *hw)
        if (phy->autoneg_advertised == 0)
                phy->autoneg_advertised = phy->autoneg_mask;
 
-       hw_dbg(hw, "Reconfiguring auto-neg advertisement params\n");
-       ret_val = igb_phy_setup_autoneg(hw);
+       DEBUGOUT("Reconfiguring auto-neg advertisement params\n");
+       ret_val = e1000_phy_setup_autoneg(hw);
        if (ret_val) {
-               hw_dbg(hw, "Error Setting up Auto-Negotiation\n");
+               DEBUGOUT("Error Setting up Auto-Negotiation\n");
                goto out;
        }
-       hw_dbg(hw, "Restarting Auto-Neg\n");
+       DEBUGOUT("Restarting Auto-Neg\n");
 
        /*
         * Restart auto-negotiation by setting the Auto Neg Enable bit and
         * the Auto Neg Restart bit in the PHY control register.
         */
-       ret_val = hw->phy.ops.read_phy_reg(hw, PHY_CONTROL, &phy_ctrl);
+       ret_val = phy->ops.read_reg(hw, PHY_CONTROL, &phy_ctrl);
        if (ret_val)
                goto out;
 
        phy_ctrl |= (MII_CR_AUTO_NEG_EN | MII_CR_RESTART_AUTO_NEG);
-       ret_val = hw->phy.ops.write_phy_reg(hw, PHY_CONTROL, phy_ctrl);
+       ret_val = phy->ops.write_reg(hw, PHY_CONTROL, phy_ctrl);
        if (ret_val)
                goto out;
 
@@ -623,10 +764,10 @@ s32 igb_copper_link_autoneg(struct e1000_hw *hw)
         * check at a later time (for example, callback routine).
         */
        if (phy->autoneg_wait_to_complete) {
-               ret_val = igb_wait_autoneg(hw);
+               ret_val = hw->mac.ops.wait_autoneg(hw);
                if (ret_val) {
-                       hw_dbg(hw, "Error while waiting for "
-                                "autoneg to complete\n");
+                       DEBUGOUT("Error while waiting for "
+                                "autoneg to complete\n");
                        goto out;
                }
        }
@@ -646,26 +787,26 @@ out:
  *  return successful.  Otherwise, setup advertisement and flow control to
  *  the appropriate values for the wanted auto-negotiation.
  **/
-static s32 igb_phy_setup_autoneg(struct e1000_hw *hw)
+static s32 e1000_phy_setup_autoneg(struct e1000_hw *hw)
 {
        struct e1000_phy_info *phy = &hw->phy;
        s32 ret_val;
        u16 mii_autoneg_adv_reg;
        u16 mii_1000t_ctrl_reg = 0;
 
+       DEBUGFUNC("e1000_phy_setup_autoneg");
+
        phy->autoneg_advertised &= phy->autoneg_mask;
 
        /* Read the MII Auto-Neg Advertisement Register (Address 4). */
-       ret_val = hw->phy.ops.read_phy_reg(hw, PHY_AUTONEG_ADV,
-                                          &mii_autoneg_adv_reg);
+       ret_val = phy->ops.read_reg(hw, PHY_AUTONEG_ADV, &mii_autoneg_adv_reg);
        if (ret_val)
                goto out;
 
        if (phy->autoneg_mask & ADVERTISE_1000_FULL) {
                /* Read the MII 1000Base-T Control Register (Address 9). */
-               ret_val = hw->phy.ops.read_phy_reg(hw,
-                                           PHY_1000T_CTRL,
-                                           &mii_1000t_ctrl_reg);
+               ret_val = phy->ops.read_reg(hw, PHY_1000T_CTRL,
+                                           &mii_1000t_ctrl_reg);
                if (ret_val)
                        goto out;
        }
@@ -684,44 +825,44 @@ static s32 igb_phy_setup_autoneg(struct e1000_hw *hw)
         * the  1000Base-T Control Register (Address 9).
         */
        mii_autoneg_adv_reg &= ~(NWAY_AR_100TX_FD_CAPS |
-                                NWAY_AR_100TX_HD_CAPS |
-                                NWAY_AR_10T_FD_CAPS   |
-                                NWAY_AR_10T_HD_CAPS);
+                                NWAY_AR_100TX_HD_CAPS |
+                                NWAY_AR_10T_FD_CAPS   |
+                                NWAY_AR_10T_HD_CAPS);
        mii_1000t_ctrl_reg &= ~(CR_1000T_HD_CAPS | CR_1000T_FD_CAPS);
 
-       hw_dbg(hw, "autoneg_advertised %x\n", phy->autoneg_advertised);
+       DEBUGOUT1("autoneg_advertised %x\n", phy->autoneg_advertised);
 
        /* Do we want to advertise 10 Mb Half Duplex? */
        if (phy->autoneg_advertised & ADVERTISE_10_HALF) {
-               hw_dbg(hw, "Advertise 10mb Half duplex\n");
+               DEBUGOUT("Advertise 10mb Half duplex\n");
                mii_autoneg_adv_reg |= NWAY_AR_10T_HD_CAPS;
        }
 
        /* Do we want to advertise 10 Mb Full Duplex? */
        if (phy->autoneg_advertised & ADVERTISE_10_FULL) {
-               hw_dbg(hw, "Advertise 10mb Full duplex\n");
+               DEBUGOUT("Advertise 10mb Full duplex\n");
                mii_autoneg_adv_reg |= NWAY_AR_10T_FD_CAPS;
        }
 
        /* Do we want to advertise 100 Mb Half Duplex? */
        if (phy->autoneg_advertised & ADVERTISE_100_HALF) {
-               hw_dbg(hw, "Advertise 100mb Half duplex\n");
+               DEBUGOUT("Advertise 100mb Half duplex\n");
                mii_autoneg_adv_reg |= NWAY_AR_100TX_HD_CAPS;
        }
 
        /* Do we want to advertise 100 Mb Full Duplex? */
        if (phy->autoneg_advertised & ADVERTISE_100_FULL) {
-               hw_dbg(hw, "Advertise 100mb Full duplex\n");
+               DEBUGOUT("Advertise 100mb Full duplex\n");
                mii_autoneg_adv_reg |= NWAY_AR_100TX_FD_CAPS;
        }
 
        /* We do not allow the Phy to advertise 1000 Mb Half Duplex */
        if (phy->autoneg_advertised & ADVERTISE_1000_HALF)
-               hw_dbg(hw, "Advertise 1000mb Half duplex request denied!\n");
+               DEBUGOUT("Advertise 1000mb Half duplex request denied!\n");
 
        /* Do we want to advertise 1000 Mb Full Duplex? */
        if (phy->autoneg_advertised & ADVERTISE_1000_FULL) {
-               hw_dbg(hw, "Advertise 1000mb Full duplex\n");
+               DEBUGOUT("Advertise 1000mb Full duplex\n");
                mii_1000t_ctrl_reg |= CR_1000T_FD_CAPS;
        }
 
@@ -739,26 +880,26 @@ static s32 igb_phy_setup_autoneg(struct e1000_hw *hw)
         *          but not send pause frames).
         *      2:  Tx flow control is enabled (we can send pause frames
         *          but we do not support receiving pause frames).
-        *      3:  Both Rx and TX flow control (symmetric) are enabled.
+        *      3:  Both Rx and Tx flow control (symmetric) are enabled.
         *  other:  No software override.  The flow control configuration
         *          in the EEPROM is used.
         */
        switch (hw->fc.type) {
        case e1000_fc_none:
                /*
-                * Flow control (RX & TX) is completely disabled by a
+                * Flow control (Rx & Tx) is completely disabled by a
                 * software over-ride.
                 */
                mii_autoneg_adv_reg &= ~(NWAY_AR_ASM_DIR | NWAY_AR_PAUSE);
                break;
        case e1000_fc_rx_pause:
                /*
-                * RX Flow control is enabled, and TX Flow control is
+                * Rx Flow control is enabled, and Tx Flow control is
                 * disabled, by a software over-ride.
                 *
                 * Since there really isn't a way to advertise that we are
-                * capable of RX Pause ONLY, we will advertise that we
-                * support both symmetric and asymmetric RX PAUSE.  Later
+                * capable of Rx Pause ONLY, we will advertise that we
+                * support both symmetric and asymmetric Rx PAUSE.  Later
                 * (in e1000_config_fc_after_link_up) we will disable the
                 * hw's ability to send PAUSE frames.
                 */
@@ -766,7 +907,7 @@ static s32 igb_phy_setup_autoneg(struct e1000_hw *hw)
                break;
        case e1000_fc_tx_pause:
                /*
-                * TX Flow control is enabled, and RX Flow control is
+                * Tx Flow control is enabled, and Rx Flow control is
                 * disabled, by a software over-ride.
                 */
                mii_autoneg_adv_reg |= NWAY_AR_ASM_DIR;
@@ -774,28 +915,27 @@ static s32 igb_phy_setup_autoneg(struct e1000_hw *hw)
                break;
        case e1000_fc_full:
                /*
-                * Flow control (both RX and TX) is enabled by a software
+                * Flow control (both Rx and Tx) is enabled by a software
                 * over-ride.
                 */
                mii_autoneg_adv_reg |= (NWAY_AR_ASM_DIR | NWAY_AR_PAUSE);
                break;
        default:
-               hw_dbg(hw, "Flow control param set incorrectly\n");
+               DEBUGOUT("Flow control param set incorrectly\n");
                ret_val = -E1000_ERR_CONFIG;
                goto out;
        }
 
-       ret_val = hw->phy.ops.write_phy_reg(hw, PHY_AUTONEG_ADV,
-                                           mii_autoneg_adv_reg);
+       ret_val = phy->ops.write_reg(hw, PHY_AUTONEG_ADV, mii_autoneg_adv_reg);
        if (ret_val)
                goto out;
 
-       hw_dbg(hw, "Auto-Neg Advertising %x\n", mii_autoneg_adv_reg);
+       DEBUGOUT1("Auto-Neg Advertising %x\n", mii_autoneg_adv_reg);
 
        if (phy->autoneg_mask & ADVERTISE_1000_FULL) {
-               ret_val = hw->phy.ops.write_phy_reg(hw,
-                                             PHY_1000T_CTRL,
-                                             mii_1000t_ctrl_reg);
+               ret_val = phy->ops.write_reg(hw,
+                                             PHY_1000T_CTRL,
+                                             mii_1000t_ctrl_reg);
                if (ret_val)
                        goto out;
        }
@@ -804,6 +944,66 @@ out:
        return ret_val;
 }
 
+/**
+ *  e1000_setup_copper_link_generic - Configure copper link settings
+ *  @hw: pointer to the HW structure
+ *
+ *  Calls the appropriate function to configure the link for auto-neg or forced
+ *  speed and duplex.  Then we check for link, once link is established calls
+ *  to configure collision distance and flow control are called.  If link is
+ *  not established, we return -E1000_ERR_PHY (-2).
+ **/
+s32 e1000_setup_copper_link_generic(struct e1000_hw *hw)
+{
+       s32 ret_val;
+       bool link;
+
+       DEBUGFUNC("e1000_setup_copper_link_generic");
+
+       if (hw->mac.autoneg) {
+               /*
+                * Setup autoneg and flow control advertisement and perform
+                * autonegotiation.
+                */
+               ret_val = e1000_copper_link_autoneg(hw);
+               if (ret_val)
+                       goto out;
+       } else {
+               /*
+                * PHY will be set to 10H, 10F, 100H or 100F
+                * depending on user settings.
+                */
+               DEBUGOUT("Forcing Speed and Duplex\n");
+               ret_val = hw->phy.ops.force_speed_duplex(hw);
+               if (ret_val) {
+                       DEBUGOUT("Error Forcing Speed and Duplex\n");
+                       goto out;
+               }
+       }
+
+       /*
+        * Check link status. Wait up to 100 microseconds for link to become
+        * valid.
+        */
+       ret_val = e1000_phy_has_link_generic(hw,
+                                            COPPER_LINK_UP_LIMIT,
+                                            10,
+                                            &link);
+       if (ret_val)
+               goto out;
+
+       if (link) {
+               DEBUGOUT("Valid link established!!!\n");
+               e1000_config_collision_dist_generic(hw);
+               ret_val = e1000_config_fc_after_link_up_generic(hw);
+       } else {
+               DEBUGOUT("Unable to establish link!!!\n");
+       }
+
+out:
+       return ret_val;
+}
+
 /**
  *  e1000_phy_force_speed_duplex_igp - Force speed/duplex for igp PHY
  *  @hw: pointer to the HW structure
@@ -812,20 +1012,22 @@ out:
  *  auto-crossover to force MDI manually.  Waits for link and returns
  *  successful if link up is successful, else -E1000_ERR_PHY (-2).
  **/
-s32 igb_phy_force_speed_duplex_igp(struct e1000_hw *hw)
+s32 e1000_phy_force_speed_duplex_igp(struct e1000_hw *hw)
 {
        struct e1000_phy_info *phy = &hw->phy;
        s32 ret_val;
        u16 phy_data;
        bool link;
 
-       ret_val = hw->phy.ops.read_phy_reg(hw, PHY_CONTROL, &phy_data);
+       DEBUGFUNC("e1000_phy_force_speed_duplex_igp");
+
+       ret_val = phy->ops.read_reg(hw, PHY_CONTROL, &phy_data);
        if (ret_val)
                goto out;
 
-       igb_phy_force_speed_duplex_setup(hw, &phy_data);
+       e1000_phy_force_speed_duplex_setup(hw, &phy_data);
 
-       ret_val = hw->phy.ops.write_phy_reg(hw, PHY_CONTROL, phy_data);
+       ret_val = phy->ops.write_reg(hw, PHY_CONTROL, phy_data);
        if (ret_val)
                goto out;
 
@@ -833,42 +1035,39 @@ s32 igb_phy_force_speed_duplex_igp(struct e1000_hw *hw)
         * Clear Auto-Crossover to force MDI manually.  IGP requires MDI
         * forced whenever speed and duplex are forced.
         */
-       ret_val = hw->phy.ops.read_phy_reg(hw, IGP01E1000_PHY_PORT_CTRL,
-                                          &phy_data);
+       ret_val = phy->ops.read_reg(hw, IGP01E1000_PHY_PORT_CTRL, &phy_data);
        if (ret_val)
                goto out;
 
        phy_data &= ~IGP01E1000_PSCR_AUTO_MDIX;
        phy_data &= ~IGP01E1000_PSCR_FORCE_MDI_MDIX;
 
-       ret_val = hw->phy.ops.write_phy_reg(hw, IGP01E1000_PHY_PORT_CTRL,
-                                           phy_data);
+       ret_val = phy->ops.write_reg(hw, IGP01E1000_PHY_PORT_CTRL, phy_data);
        if (ret_val)
                goto out;
 
-       hw_dbg(hw, "IGP PSCR: %X\n", phy_data);
+       DEBUGOUT1("IGP PSCR: %X\n", phy_data);
 
-       udelay(1);
+       usec_delay(1);
 
        if (phy->autoneg_wait_to_complete) {
-               hw_dbg(hw,
-                      "Waiting for forced speed/duplex link on IGP phy.\n");
+               DEBUGOUT("Waiting for forced speed/duplex link on IGP phy.\n");
 
-               ret_val = igb_phy_has_link(hw,
-                                                    PHY_FORCE_LIMIT,
-                                                    100000,
-                                                    &link);
+               ret_val = e1000_phy_has_link_generic(hw,
+                                                    PHY_FORCE_LIMIT,
+                                                    100000,
+                                                    &link);
                if (ret_val)
                        goto out;
 
                if (!link)
-                       hw_dbg(hw, "Link taking longer than expected.\n");
+                       DEBUGOUT("Link taking longer than expected.\n");
 
                /* Try once more */
-               ret_val = igb_phy_has_link(hw,
-                                                    PHY_FORCE_LIMIT,
-                                                    100000,
-                                                    &link);
+               ret_val = e1000_phy_has_link_generic(hw,
+                                                    PHY_FORCE_LIMIT,
+                                                    100000,
+                                                    &link);
                if (ret_val)
                        goto out;
        }
@@ -884,56 +1083,53 @@ out:
  *  Calls the PHY setup function to force speed and duplex.  Clears the
  *  auto-crossover to force MDI manually.  Resets the PHY to commit the
  *  changes.  If time expires while waiting for link up, we reset the DSP.
- *  After reset, TX_CLK and CRS on TX must be set.  Return successful upon
+ *  After reset, TX_CLK and CRS on Tx must be set.  Return successful upon
  *  successful completion, else return corresponding error code.
  **/
-s32 igb_phy_force_speed_duplex_m88(struct e1000_hw *hw)
+s32 e1000_phy_force_speed_duplex_m88(struct e1000_hw *hw)
 {
        struct e1000_phy_info *phy = &hw->phy;
        s32 ret_val;
        u16 phy_data;
        bool link;
 
+       DEBUGFUNC("e1000_phy_force_speed_duplex_m88");
+
        /*
         * Clear Auto-Crossover to force MDI manually.  M88E1000 requires MDI
         * forced whenever speed and duplex are forced.
         */
-       ret_val = hw->phy.ops.read_phy_reg(hw, M88E1000_PHY_SPEC_CTRL,
-                                          &phy_data);
+       ret_val = phy->ops.read_reg(hw, M88E1000_PHY_SPEC_CTRL, &phy_data);
        if (ret_val)
                goto out;
 
        phy_data &= ~M88E1000_PSCR_AUTO_X_MODE;
-       ret_val = hw->phy.ops.write_phy_reg(hw, M88E1000_PHY_SPEC_CTRL,
-                                           phy_data);
+       ret_val = phy->ops.write_reg(hw, M88E1000_PHY_SPEC_CTRL, phy_data);
        if (ret_val)
                goto out;
 
-       hw_dbg(hw, "M88E1000 PSCR: %X\n", phy_data);
+       DEBUGOUT1("M88E1000 PSCR: %X\n", phy_data);
 
-       ret_val = hw->phy.ops.read_phy_reg(hw, PHY_CONTROL, &phy_data);
+       ret_val = phy->ops.read_reg(hw, PHY_CONTROL, &phy_data);
        if (ret_val)
                goto out;
 
-       igb_phy_force_speed_duplex_setup(hw, &phy_data);
-
-       /* Reset the phy to commit changes. */
-       phy_data |= MII_CR_RESET;
+       e1000_phy_force_speed_duplex_setup(hw, &phy_data);
 
-       ret_val = hw->phy.ops.write_phy_reg(hw, PHY_CONTROL, phy_data);
+       ret_val = phy->ops.write_reg(hw, PHY_CONTROL, phy_data);
        if (ret_val)
                goto out;
 
-       udelay(1);
+       /* Reset the phy to commit changes. */
+       ret_val = hw->phy.ops.commit(hw);
+       if (ret_val)
+               goto out;
 
        if (phy->autoneg_wait_to_complete) {
-               hw_dbg(hw,
-                      "Waiting for forced speed/duplex link on M88 phy.\n");
+               DEBUGOUT("Waiting for forced speed/duplex link on M88 phy.\n");
 
-               ret_val = igb_phy_has_link(hw,
-                                                    PHY_FORCE_LIMIT,
-                                                    100000,
-                                                    &link);
+               ret_val = e1000_phy_has_link_generic(hw, PHY_FORCE_LIMIT,
+                                                    100000, &link);
                if (ret_val)
                        goto out;
 
@@ -942,25 +1138,24 @@ s32 igb_phy_force_speed_duplex_m88(struct e1000_hw *hw)
                         * We didn't get link.
                         * Reset the DSP and cross our fingers.
                         */
-                       ret_val = hw->phy.ops.write_phy_reg(hw,
-                                                     M88E1000_PHY_PAGE_SELECT,
-                                                     0x001d);
+                       ret_val = phy->ops.write_reg(hw,
+                                                     M88E1000_PHY_PAGE_SELECT,
+                                                     0x001d);
                        if (ret_val)
                                goto out;
-                       ret_val = igb_phy_reset_dsp(hw);
+                       ret_val = e1000_phy_reset_dsp_generic(hw);
                        if (ret_val)
                                goto out;
                }
 
                /* Try once more */
-               ret_val = igb_phy_has_link(hw, PHY_FORCE_LIMIT,
-                                            100000, &link);
+               ret_val = e1000_phy_has_link_generic(hw, PHY_FORCE_LIMIT,
+                                                    100000, &link);
                if (ret_val)
                        goto out;
        }
 
-       ret_val = hw->phy.ops.read_phy_reg(hw, M88E1000_EXT_PHY_SPEC_CTRL,
-                                          &phy_data);
+       ret_val = phy->ops.read_reg(hw, M88E1000_EXT_PHY_SPEC_CTRL, &phy_data);
        if (ret_val)
                goto out;
 
@@ -970,8 +1165,7 @@ s32 igb_phy_force_speed_duplex_m88(struct e1000_hw *hw)
         * the reset value of 2.5MHz.
         */
        phy_data |= M88E1000_EPSCR_TX_CLK_25;
-       ret_val = hw->phy.ops.write_phy_reg(hw, M88E1000_EXT_PHY_SPEC_CTRL,
-                                           phy_data);
+       ret_val = phy->ops.write_reg(hw, M88E1000_EXT_PHY_SPEC_CTRL, phy_data);
        if (ret_val)
                goto out;
 
@@ -979,14 +1173,12 @@ s32 igb_phy_force_speed_duplex_m88(struct e1000_hw *hw)
         * In addition, we must re-enable CRS on Tx for both half and full
         * duplex.
         */
-       ret_val = hw->phy.ops.read_phy_reg(hw, M88E1000_PHY_SPEC_CTRL,
-                                          &phy_data);
+       ret_val = phy->ops.read_reg(hw, M88E1000_PHY_SPEC_CTRL, &phy_data);
        if (ret_val)
                goto out;
 
        phy_data |= M88E1000_PSCR_ASSERT_CRS_ON_TX;
-       ret_val = hw->phy.ops.write_phy_reg(hw, M88E1000_PHY_SPEC_CTRL,
-                                           phy_data);
+       ret_val = phy->ops.write_reg(hw, M88E1000_PHY_SPEC_CTRL, phy_data);
 
 out:
        return ret_val;
@@ -1004,17 +1196,18 @@ out:
  *  caller must write to the PHY_CONTROL register for these settings to
  *  take affect.
  **/
-static void igb_phy_force_speed_duplex_setup(struct e1000_hw *hw,
-                                              u16 *phy_ctrl)
+void e1000_phy_force_speed_duplex_setup(struct e1000_hw *hw, u16 *phy_ctrl)
 {
        struct e1000_mac_info *mac = &hw->mac;
        u32 ctrl;
 
+       DEBUGFUNC("e1000_phy_force_speed_duplex_setup");
+
        /* Turn off flow control when forcing speed/duplex */
        hw->fc.type = e1000_fc_none;
 
        /* Force speed/duplex on the mac */
-       ctrl = rd32(E1000_CTRL);
+       ctrl = E1000_READ_REG(hw, E1000_CTRL);
        ctrl |= (E1000_CTRL_FRCSPD | E1000_CTRL_FRCDPX);
        ctrl &= ~E1000_CTRL_SPD_SEL;
 
@@ -1028,11 +1221,11 @@ static void igb_phy_force_speed_duplex_setup(struct e1000_hw *hw,
        if (mac->forced_speed_duplex & E1000_ALL_HALF_DUPLEX) {
                ctrl &= ~E1000_CTRL_FD;
                *phy_ctrl &= ~MII_CR_FULL_DUPLEX;
-               hw_dbg(hw, "Half Duplex\n");
+               DEBUGOUT("Half Duplex\n");
        } else {
                ctrl |= E1000_CTRL_FD;
                *phy_ctrl |= MII_CR_FULL_DUPLEX;
-               hw_dbg(hw, "Full Duplex\n");
+               DEBUGOUT("Full Duplex\n");
        }
 
        /* Forcing 10mb or 100mb? */
@@ -1040,21 +1233,21 @@ static void igb_phy_force_speed_duplex_setup(struct e1000_hw *hw,
                ctrl |= E1000_CTRL_SPD_100;
                *phy_ctrl |= MII_CR_SPEED_100;
                *phy_ctrl &= ~(MII_CR_SPEED_1000 | MII_CR_SPEED_10);
-               hw_dbg(hw, "Forcing 100mb\n");
+               DEBUGOUT("Forcing 100mb\n");
        } else {
                ctrl &= ~(E1000_CTRL_SPD_1000 | E1000_CTRL_SPD_100);
                *phy_ctrl |= MII_CR_SPEED_10;
                *phy_ctrl &= ~(MII_CR_SPEED_1000 | MII_CR_SPEED_100);
-               hw_dbg(hw, "Forcing 10mb\n");
+               DEBUGOUT("Forcing 10mb\n");
        }
 
-       igb_config_collision_dist(hw);
+       e1000_config_collision_dist_generic(hw);
 
-       wr32(E1000_CTRL, ctrl);
+       E1000_WRITE_REG(hw, E1000_CTRL, ctrl);
 }
 
 /**
- *  e1000_set_d3_lplu_state - Sets low power link up state for D3
+ *  e1000_set_d3_lplu_state_generic - Sets low power link up state for D3
  *  @hw: pointer to the HW structure
  *  @active: boolean used to enable/disable lplu
  *
@@ -1067,22 +1260,25 @@ static void igb_phy_force_speed_duplex_setup(struct e1000_hw *hw,
  *  During driver activity, SmartSpeed should be enabled so performance is
  *  maintained.
  **/
-s32 igb_set_d3_lplu_state(struct e1000_hw *hw, bool active)
+s32 e1000_set_d3_lplu_state_generic(struct e1000_hw *hw, bool active)
 {
        struct e1000_phy_info *phy = &hw->phy;
-       s32 ret_val;
+       s32 ret_val = E1000_SUCCESS;
        u16 data;
 
-       ret_val = hw->phy.ops.read_phy_reg(hw, IGP02E1000_PHY_POWER_MGMT,
-                                          &data);
+       DEBUGFUNC("e1000_set_d3_lplu_state_generic");
+
+       if (!(hw->phy.ops.read_reg))
+               goto out;
+
+       ret_val = phy->ops.read_reg(hw, IGP02E1000_PHY_POWER_MGMT, &data);
        if (ret_val)
                goto out;
 
        if (!active) {
                data &= ~IGP02E1000_PM_D3_LPLU;
-               ret_val = hw->phy.ops.write_phy_reg(hw,
-                                            IGP02E1000_PHY_POWER_MGMT,
-                                            data);
+               ret_val = phy->ops.write_reg(hw, IGP02E1000_PHY_POWER_MGMT,
+                                            data);
                if (ret_val)
                        goto out;
                /*
@@ -1092,53 +1288,50 @@ s32 igb_set_d3_lplu_state(struct e1000_hw *hw, bool active)
                 * SmartSpeed, so performance is maintained.
                 */
                if (phy->smart_speed == e1000_smart_speed_on) {
-                       ret_val = hw->phy.ops.read_phy_reg(hw,
-                                                   IGP01E1000_PHY_PORT_CONFIG,
-                                                   &data);
+                       ret_val = phy->ops.read_reg(hw,
+                                                   IGP01E1000_PHY_PORT_CONFIG,
+                                                   &data);
                        if (ret_val)
                                goto out;
 
                        data |= IGP01E1000_PSCFR_SMART_SPEED;
-                       ret_val = hw->phy.ops.write_phy_reg(hw,
-                                                    IGP01E1000_PHY_PORT_CONFIG,
-                                                    data);
+                       ret_val = phy->ops.write_reg(hw,
+                                                    IGP01E1000_PHY_PORT_CONFIG,
+                                                    data);
                        if (ret_val)
                                goto out;
                } else if (phy->smart_speed == e1000_smart_speed_off) {
-                       ret_val = hw->phy.ops.read_phy_reg(hw,
-                                                    IGP01E1000_PHY_PORT_CONFIG,
-                                                    &data);
+                       ret_val = phy->ops.read_reg(hw,
+                                                    IGP01E1000_PHY_PORT_CONFIG,
+                                                    &data);
                        if (ret_val)
                                goto out;
 
                        data &= ~IGP01E1000_PSCFR_SMART_SPEED;
-                       ret_val = hw->phy.ops.write_phy_reg(hw,
-                                                    IGP01E1000_PHY_PORT_CONFIG,
-                                                    data);
+                       ret_val = phy->ops.write_reg(hw,
+                                                    IGP01E1000_PHY_PORT_CONFIG,
+                                                    data);
                        if (ret_val)
                                goto out;
                }
        } else if ((phy->autoneg_advertised == E1000_ALL_SPEED_DUPLEX) ||
-                  (phy->autoneg_advertised == E1000_ALL_NOT_GIG) ||
-                  (phy->autoneg_advertised == E1000_ALL_10_SPEED)) {
+                  (phy->autoneg_advertised == E1000_ALL_NOT_GIG) ||
+                  (phy->autoneg_advertised == E1000_ALL_10_SPEED)) {
                data |= IGP02E1000_PM_D3_LPLU;
-               ret_val = hw->phy.ops.write_phy_reg(hw,
-                                             IGP02E1000_PHY_POWER_MGMT,
-                                             data);
+               ret_val = phy->ops.write_reg(hw, IGP02E1000_PHY_POWER_MGMT,
+                                             data);
                if (ret_val)
                        goto out;
 
                /* When LPLU is enabled, we should disable SmartSpeed */
-               ret_val = hw->phy.ops.read_phy_reg(hw,
-                                            IGP01E1000_PHY_PORT_CONFIG,
-                                            &data);
+               ret_val = phy->ops.read_reg(hw, IGP01E1000_PHY_PORT_CONFIG,
+                                            &data);
                if (ret_val)
                        goto out;
 
                data &= ~IGP01E1000_PSCFR_SMART_SPEED;
-               ret_val = hw->phy.ops.write_phy_reg(hw,
-                                             IGP01E1000_PHY_PORT_CONFIG,
-                                             data);
+               ret_val = phy->ops.write_reg(hw, IGP01E1000_PHY_PORT_CONFIG,
+                                             data);
        }
 
 out:
@@ -1146,19 +1339,21 @@ out:
 }
 
 /**
- *  e1000_check_downshift - Checks whether a downshift in speed occured
+ *  e1000_check_downshift_generic - Checks whether a downshift in speed occurred
  *  @hw: pointer to the HW structure
  *
  *  Success returns 0, Failure returns 1
  *
  *  A downshift is detected by querying the PHY link health.
  **/
-s32 igb_check_downshift(struct e1000_hw *hw)
+s32 e1000_check_downshift_generic(struct e1000_hw *hw)
 {
        struct e1000_phy_info *phy = &hw->phy;
        s32 ret_val;
        u16 phy_data, offset, mask;
 
+       DEBUGFUNC("e1000_check_downshift_generic");
+
        switch (phy->type) {
        case e1000_phy_m88:
        case e1000_phy_gg82563:
@@ -1174,11 +1369,11 @@ s32 igb_check_downshift(struct e1000_hw *hw)
        default:
                /* speed downshift not supported */
                phy->speed_downgraded = false;
-               ret_val = 0;
+               ret_val = E1000_SUCCESS;
                goto out;
        }
 
-       ret_val = hw->phy.ops.read_phy_reg(hw, offset, &phy_data);
+       ret_val = phy->ops.read_reg(hw, offset, &phy_data);
 
        if (!ret_val)
                phy->speed_downgraded = (phy_data & mask) ? true : false;
@@ -1195,18 +1390,20 @@ out:
  *
  *  Polarity is determined based on the PHY specific status register.
  **/
-static s32 igb_check_polarity_m88(struct e1000_hw *hw)
+s32 e1000_check_polarity_m88(struct e1000_hw *hw)
 {
        struct e1000_phy_info *phy = &hw->phy;
        s32 ret_val;
        u16 data;
 
-       ret_val = hw->phy.ops.read_phy_reg(hw, M88E1000_PHY_SPEC_STATUS, &data);
+       DEBUGFUNC("e1000_check_polarity_m88");
+
+       ret_val = phy->ops.read_reg(hw, M88E1000_PHY_SPEC_STATUS, &data);
 
        if (!ret_val)
                phy->cable_polarity = (data & M88E1000_PSSR_REV_POLARITY)
-                                     ? e1000_rev_polarity_reversed
-                                     : e1000_rev_polarity_normal;
+                                     ? e1000_rev_polarity_reversed
+                                     : e1000_rev_polarity_normal;
 
        return ret_val;
 }
@@ -1220,18 +1417,19 @@ static s32 igb_check_polarity_m88(struct e1000_hw *hw)
  *  Polarity is determined based on the PHY port status register, and the
  *  current speed (since there is no polarity at 100Mbps).
  **/
-static s32 igb_check_polarity_igp(struct e1000_hw *hw)
+s32 e1000_check_polarity_igp(struct e1000_hw *hw)
 {
        struct e1000_phy_info *phy = &hw->phy;
        s32 ret_val;
        u16 data, offset, mask;
 
+       DEBUGFUNC("e1000_check_polarity_igp");
+
        /*
         * Polarity is determined based on the speed of
         * our connection.
         */
-       ret_val = hw->phy.ops.read_phy_reg(hw, IGP01E1000_PHY_PORT_STATUS,
-                                          &data);
+       ret_val = phy->ops.read_reg(hw, IGP01E1000_PHY_PORT_STATUS, &data);
        if (ret_val)
                goto out;
 
@@ -1248,40 +1446,45 @@ static s32 igb_check_polarity_igp(struct e1000_hw *hw)
                mask    = IGP01E1000_PSSR_POLARITY_REVERSED;
        }
 
-       ret_val = hw->phy.ops.read_phy_reg(hw, offset, &data);
+       ret_val = phy->ops.read_reg(hw, offset, &data);
 
        if (!ret_val)
                phy->cable_polarity = (data & mask)
-                                     ? e1000_rev_polarity_reversed
-                                     : e1000_rev_polarity_normal;
+                                     ? e1000_rev_polarity_reversed
+                                     : e1000_rev_polarity_normal;
 
 out:
        return ret_val;
 }
 
 /**
- *  e1000_wait_autoneg - Wait for auto-neg compeletion
+ *  e1000_wait_autoneg_generic - Wait for auto-neg completion
  *  @hw: pointer to the HW structure
  *
  *  Waits for auto-negotiation to complete or for the auto-negotiation time
  *  limit to expire, which ever happens first.
  **/
-static s32 igb_wait_autoneg(struct e1000_hw *hw)
+s32 e1000_wait_autoneg_generic(struct e1000_hw *hw)
 {
-       s32 ret_val = 0;
+       s32 ret_val = E1000_SUCCESS;
        u16 i, phy_status;
 
+       DEBUGFUNC("e1000_wait_autoneg_generic");
+
+       if (!(hw->phy.ops.read_reg))
+               return E1000_SUCCESS;
+
        /* Break after autoneg completes or PHY_AUTO_NEG_LIMIT expires. */
        for (i = PHY_AUTO_NEG_LIMIT; i > 0; i--) {
-               ret_val = hw->phy.ops.read_phy_reg(hw, PHY_STATUS, &phy_status);
+               ret_val = hw->phy.ops.read_reg(hw, PHY_STATUS, &phy_status);
                if (ret_val)
                        break;
-               ret_val = hw->phy.ops.read_phy_reg(hw, PHY_STATUS, &phy_status);
+               ret_val = hw->phy.ops.read_reg(hw, PHY_STATUS, &phy_status);
                if (ret_val)
                        break;
                if (phy_status & MII_SR_AUTONEG_COMPLETE)
                        break;
-               msleep(100);
+               msec_delay(100);
        }
 
        /*
@@ -1292,7 +1495,7 @@ static s32 igb_wait_autoneg(struct e1000_hw *hw)
 }
 
 /**
- *  e1000_phy_has_link - Polls PHY for link
+ *  e1000_phy_has_link_generic - Polls PHY for link
  *  @hw: pointer to the HW structure
  *  @iterations: number of times to poll for link
  *  @usec_interval: delay between polling attempts
@@ -1300,30 +1503,35 @@ static s32 igb_wait_autoneg(struct e1000_hw *hw)
  *
  *  Polls the PHY status register for link, 'iterations' number of times.
  **/
-s32 igb_phy_has_link(struct e1000_hw *hw, u32 iterations,
-                              u32 usec_interval, bool *success)
+s32 e1000_phy_has_link_generic(struct e1000_hw *hw, u32 iterations,
+                               u32 usec_interval, bool *success)
 {
-       s32 ret_val = 0;
+       s32 ret_val = E1000_SUCCESS;
        u16 i, phy_status;
 
+       DEBUGFUNC("e1000_phy_has_link_generic");
+
+       if (!(hw->phy.ops.read_reg))
+               return E1000_SUCCESS;
+
        for (i = 0; i < iterations; i++) {
                /*
                 * Some PHYs require the PHY_STATUS register to be read
                 * twice due to the link bit being sticky.  No harm doing
                 * it across the board.
                 */
-               ret_val = hw->phy.ops.read_phy_reg(hw, PHY_STATUS, &phy_status);
+               ret_val = hw->phy.ops.read_reg(hw, PHY_STATUS, &phy_status);
                if (ret_val)
                        break;
-               ret_val = hw->phy.ops.read_phy_reg(hw, PHY_STATUS, &phy_status);
+               ret_val = hw->phy.ops.read_reg(hw, PHY_STATUS, &phy_status);
                if (ret_val)
                        break;
                if (phy_status & MII_SR_LINK_STATUS)
                        break;
                if (usec_interval >= 1000)
-                       mdelay(usec_interval/1000);
+                       msec_delay_irq(usec_interval/1000);
                else
-                       udelay(usec_interval);
+                       usec_delay(usec_interval);
        }
 
        *success = (i < iterations) ? true : false;
@@ -1346,19 +1554,20 @@ s32 igb_phy_has_link(struct e1000_hw *hw, u32 iterations,
  *     3                       110 - 140 meters
  *     4                       > 140 meters
  **/
-s32 igb_get_cable_length_m88(struct e1000_hw *hw)
+s32 e1000_get_cable_length_m88(struct e1000_hw *hw)
 {
        struct e1000_phy_info *phy = &hw->phy;
        s32 ret_val;
        u16 phy_data, index;
 
-       ret_val = hw->phy.ops.read_phy_reg(hw, M88E1000_PHY_SPEC_STATUS,
-                                          &phy_data);
+       DEBUGFUNC("e1000_get_cable_length_m88");
+
+       ret_val = phy->ops.read_reg(hw, M88E1000_PHY_SPEC_STATUS, &phy_data);
        if (ret_val)
                goto out;
 
        index = (phy_data & M88E1000_PSSR_CABLE_LENGTH) >>
-               M88E1000_PSSR_CABLE_LENGTH_SHIFT;
+               M88E1000_PSSR_CABLE_LENGTH_SHIFT;
        phy->min_cable_length = e1000_m88_cable_length_table[index];
        phy->max_cable_length = e1000_m88_cable_length_table[index+1];
 
@@ -1374,39 +1583,40 @@ out:
  *
  *  The automatic gain control (agc) normalizes the amplitude of the
  *  received signal, adjusting for the attenuation produced by the
- *  cable.  By reading the AGC registers, which reperesent the
- *  cobination of course and fine gain value, the value can be put
+ *  cable.  By reading the AGC registers, which represent the
+ *  combination of coarse and fine gain value, the value can be put
  *  into a lookup table to obtain the approximate cable length
  *  for each channel.
  **/
-s32 igb_get_cable_length_igp_2(struct e1000_hw *hw)
+s32 e1000_get_cable_length_igp_2(struct e1000_hw *hw)
 {
        struct e1000_phy_info *phy = &hw->phy;
-       s32 ret_val = 0;
+       s32 ret_val = E1000_SUCCESS;
        u16 phy_data, i, agc_value = 0;
        u16 cur_agc_index, max_agc_index = 0;
        u16 min_agc_index = IGP02E1000_CABLE_LENGTH_TABLE_SIZE - 1;
        u16 agc_reg_array[IGP02E1000_PHY_CHANNEL_NUM] =
-                                                        {IGP02E1000_PHY_AGC_A,
-                                                         IGP02E1000_PHY_AGC_B,
-                                                         IGP02E1000_PHY_AGC_C,
-                                                         IGP02E1000_PHY_AGC_D};
+                                                        {IGP02E1000_PHY_AGC_A,
+                                                         IGP02E1000_PHY_AGC_B,
+                                                         IGP02E1000_PHY_AGC_C,
+                                                         IGP02E1000_PHY_AGC_D};
+
+       DEBUGFUNC("e1000_get_cable_length_igp_2");
 
        /* Read the AGC registers for all channels */
        for (i = 0; i < IGP02E1000_PHY_CHANNEL_NUM; i++) {
-               ret_val = hw->phy.ops.read_phy_reg(hw, agc_reg_array[i],
-                                                  &phy_data);
+               ret_val = phy->ops.read_reg(hw, agc_reg_array[i], &phy_data);
                if (ret_val)
                        goto out;
 
                /*
                 * Getting bits 15:9, which represent the combination of
-                * course and fine gain values.  The result is a number
+                * coarse and fine gain values.  The result is a number
                 * that can be put into the lookup table to obtain the
                 * approximate cable length.
                 */
                cur_agc_index = (phy_data >> IGP02E1000_AGC_LENGTH_SHIFT) &
-                               IGP02E1000_AGC_LENGTH_MASK;
+                               IGP02E1000_AGC_LENGTH_MASK;
 
                /* Array index bound check. */
                if ((cur_agc_index >= IGP02E1000_CABLE_LENGTH_TABLE_SIZE) ||
@@ -1427,12 +1637,12 @@ s32 igb_get_cable_length_igp_2(struct e1000_hw *hw)
        }
 
        agc_value -= (e1000_igp_2_cable_length_table[min_agc_index] +
-                     e1000_igp_2_cable_length_table[max_agc_index]);
+                     e1000_igp_2_cable_length_table[max_agc_index]);
        agc_value /= (IGP02E1000_PHY_CHANNEL_NUM - 2);
 
        /* Calculate cable length with the error range of +/- 10 meters. */
        phy->min_cable_length = ((agc_value - IGP02E1000_AGC_RANGE) > 0) ?
-                                (agc_value - IGP02E1000_AGC_RANGE) : 0;
+                                (agc_value - IGP02E1000_AGC_RANGE) : 0;
        phy->max_cable_length = agc_value + IGP02E1000_AGC_RANGE;
 
        phy->cable_length = (phy->min_cable_length + phy->max_cable_length) / 2;
@@ -1451,44 +1661,43 @@ out:
  *  special status register to determine MDI/MDIx and current speed.  If
  *  speed is 1000, then determine cable length, local and remote receiver.
  **/
-s32 igb_get_phy_info_m88(struct e1000_hw *hw)
+s32 e1000_get_phy_info_m88(struct e1000_hw *hw)
 {
        struct e1000_phy_info *phy = &hw->phy;
        s32  ret_val;
        u16 phy_data;
        bool link;
 
+       DEBUGFUNC("e1000_get_phy_info_m88");
+
        if (hw->phy.media_type != e1000_media_type_copper) {
-               hw_dbg(hw, "Phy info is only valid for copper media\n");
+               DEBUGOUT("Phy info is only valid for copper media\n");
                ret_val = -E1000_ERR_CONFIG;
                goto out;
        }
 
-       ret_val = igb_phy_has_link(hw, 1, 0, &link);
+       ret_val = e1000_phy_has_link_generic(hw, 1, 0, &link);
        if (ret_val)
                goto out;
 
        if (!link) {
-               hw_dbg(hw, "Phy info is only valid if link is up\n");
+               DEBUGOUT("Phy info is only valid if link is up\n");
                ret_val = -E1000_ERR_CONFIG;
                goto out;
        }
 
-       ret_val = hw->phy.ops.read_phy_reg(hw, M88E1000_PHY_SPEC_CTRL,
-                                          &phy_data);
+       ret_val = phy->ops.read_reg(hw, M88E1000_PHY_SPEC_CTRL, &phy_data);
        if (ret_val)
                goto out;
 
        phy->polarity_correction = (phy_data & M88E1000_PSCR_POLARITY_REVERSAL)
-                                  ? true
-                                  : false;
+                                  ? true : false;
 
-       ret_val = igb_check_polarity_m88(hw);
+       ret_val = e1000_check_polarity_m88(hw);
        if (ret_val)
                goto out;
 
-       ret_val = hw->phy.ops.read_phy_reg(hw, M88E1000_PHY_SPEC_STATUS,
-                                          &phy_data);
+       ret_val = phy->ops.read_reg(hw, M88E1000_PHY_SPEC_STATUS, &phy_data);
        if (ret_val)
                goto out;
 
@@ -1499,18 +1708,17 @@ s32 igb_get_phy_info_m88(struct e1000_hw *hw)
                if (ret_val)
                        goto out;
 
-               ret_val = hw->phy.ops.read_phy_reg(hw, PHY_1000T_STATUS,
-                                                  &phy_data);
+               ret_val = phy->ops.read_reg(hw, PHY_1000T_STATUS, &phy_data);
                if (ret_val)
                        goto out;
 
                phy->local_rx = (phy_data & SR_1000T_LOCAL_RX_STATUS)
-                               ? e1000_1000t_rx_status_ok
-                               : e1000_1000t_rx_status_not_ok;
+                               ? e1000_1000t_rx_status_ok
+                               : e1000_1000t_rx_status_not_ok;
 
                phy->remote_rx = (phy_data & SR_1000T_REMOTE_RX_STATUS)
-                                ? e1000_1000t_rx_status_ok
-                                : e1000_1000t_rx_status_not_ok;
+                                ? e1000_1000t_rx_status_ok
+                                : e1000_1000t_rx_status_not_ok;
        } else {
                /* Set values to "undefined" */
                phy->cable_length = E1000_CABLE_LENGTH_UNDEFINED;
@@ -1531,31 +1739,32 @@ out:
  *  PHY port status to determine MDI/MDIx and speed.  Based on the speed,
  *  determine on the cable length, local and remote receiver.
  **/
-s32 igb_get_phy_info_igp(struct e1000_hw *hw)
+s32 e1000_get_phy_info_igp(struct e1000_hw *hw)
 {
        struct e1000_phy_info *phy = &hw->phy;
        s32 ret_val;
        u16 data;
        bool link;
 
-       ret_val = igb_phy_has_link(hw, 1, 0, &link);
+       DEBUGFUNC("e1000_get_phy_info_igp");
+
+       ret_val = e1000_phy_has_link_generic(hw, 1, 0, &link);
        if (ret_val)
                goto out;
 
        if (!link) {
-               hw_dbg(hw, "Phy info is only valid if link is up\n");
+               DEBUGOUT("Phy info is only valid if link is up\n");
                ret_val = -E1000_ERR_CONFIG;
                goto out;
        }
 
        phy->polarity_correction = true;
 
-       ret_val = igb_check_polarity_igp(hw);
+       ret_val = e1000_check_polarity_igp(hw);
        if (ret_val)
                goto out;
 
-       ret_val = hw->phy.ops.read_phy_reg(hw, IGP01E1000_PHY_PORT_STATUS,
-                                          &data);
+       ret_val = phy->ops.read_reg(hw, IGP01E1000_PHY_PORT_STATUS, &data);
        if (ret_val)
                goto out;
 
@@ -1567,18 +1776,17 @@ s32 igb_get_phy_info_igp(struct e1000_hw *hw)
                if (ret_val)
                        goto out;
 
-               ret_val = hw->phy.ops.read_phy_reg(hw, PHY_1000T_STATUS,
-                                                  &data);
+               ret_val = phy->ops.read_reg(hw, PHY_1000T_STATUS, &data);
                if (ret_val)
                        goto out;
 
                phy->local_rx = (data & SR_1000T_LOCAL_RX_STATUS)
-                               ? e1000_1000t_rx_status_ok
-                               : e1000_1000t_rx_status_not_ok;
+                               ? e1000_1000t_rx_status_ok
+                               : e1000_1000t_rx_status_not_ok;
 
                phy->remote_rx = (data & SR_1000T_REMOTE_RX_STATUS)
-                                ? e1000_1000t_rx_status_ok
-                                : e1000_1000t_rx_status_not_ok;
+                                ? e1000_1000t_rx_status_ok
+                                : e1000_1000t_rx_status_not_ok;
        } else {
                phy->cable_length = E1000_CABLE_LENGTH_UNDEFINED;
                phy->local_rx = e1000_1000t_rx_status_undefined;
@@ -1590,134 +1798,97 @@ out:
 }
 
 /**
- *  e1000_phy_sw_reset - PHY software reset
+ *  e1000_phy_sw_reset_generic - PHY software reset
  *  @hw: pointer to the HW structure
  *
  *  Does a software reset of the PHY by reading the PHY control register and
  *  setting/write the control register reset bit to the PHY.
  **/
-s32 igb_phy_sw_reset(struct e1000_hw *hw)
+s32 e1000_phy_sw_reset_generic(struct e1000_hw *hw)
 {
-       s32 ret_val;
+       s32 ret_val = E1000_SUCCESS;
        u16 phy_ctrl;
 
-       ret_val = hw->phy.ops.read_phy_reg(hw, PHY_CONTROL, &phy_ctrl);
+       DEBUGFUNC("e1000_phy_sw_reset_generic");
+
+       if (!(hw->phy.ops.read_reg))
+               goto out;
+
+       ret_val = hw->phy.ops.read_reg(hw, PHY_CONTROL, &phy_ctrl);
        if (ret_val)
                goto out;
 
        phy_ctrl |= MII_CR_RESET;
-       ret_val = hw->phy.ops.write_phy_reg(hw, PHY_CONTROL, phy_ctrl);
+       ret_val = hw->phy.ops.write_reg(hw, PHY_CONTROL, phy_ctrl);
        if (ret_val)
                goto out;
 
-       udelay(1);
+       usec_delay(1);
 
 out:
        return ret_val;
 }
 
 /**
- *  e1000_phy_hw_reset - PHY hardware reset
+ *  e1000_phy_hw_reset_generic - PHY hardware reset
  *  @hw: pointer to the HW structure
  *
  *  Verify the reset block is not blocking us from resetting.  Acquire
  *  semaphore (if necessary) and read/set/write the device control reset
  *  bit in the PHY.  Wait the appropriate delay time for the device to
- *  reset and relase the semaphore (if necessary).
+ *  reset and release the semaphore (if necessary).
  **/
-s32 igb_phy_hw_reset(struct e1000_hw *hw)
+s32 e1000_phy_hw_reset_generic(struct e1000_hw *hw)
 {
        struct e1000_phy_info *phy = &hw->phy;
-       s32  ret_val;
+       s32 ret_val = E1000_SUCCESS;
        u32 ctrl;
 
-       ret_val = igb_check_reset_block(hw);
+       DEBUGFUNC("e1000_phy_hw_reset_generic");
+
+       ret_val = phy->ops.check_reset_block(hw);
        if (ret_val) {
-               ret_val = 0;
+               ret_val = E1000_SUCCESS;
                goto out;
        }
 
-       ret_val = igb_acquire_phy(hw);
+       ret_val = phy->ops.acquire(hw);
        if (ret_val)
                goto out;
 
-       ctrl = rd32(E1000_CTRL);
-       wr32(E1000_CTRL, ctrl | E1000_CTRL_PHY_RST);
-       wrfl();
+       ctrl = E1000_READ_REG(hw, E1000_CTRL);
+       E1000_WRITE_REG(hw, E1000_CTRL, ctrl | E1000_CTRL_PHY_RST);
+       E1000_WRITE_FLUSH(hw);
 
-       udelay(phy->reset_delay_us);
+       usec_delay(phy->reset_delay_us);
 
-       wr32(E1000_CTRL, ctrl);
-       wrfl();
+       E1000_WRITE_REG(hw, E1000_CTRL, ctrl);
+       E1000_WRITE_FLUSH(hw);
 
-       udelay(150);
+       usec_delay(150);
 
-       igb_release_phy(hw);
+       phy->ops.release(hw);
 
-       ret_val = igb_get_phy_cfg_done(hw);
+       ret_val = phy->ops.get_cfg_done(hw);
 
 out:
        return ret_val;
 }
 
-/* Internal function pointers */
-
 /**
- *  e1000_get_phy_cfg_done - Generic PHY configuration done
+ *  e1000_get_cfg_done_generic - Generic configuration done
  *  @hw: pointer to the HW structure
  *
- *  Return success if silicon family did not implement a family specific
- *  get_cfg_done function.
+ *  Generic function to wait 10 milli-seconds for configuration to complete
+ *  and return success.
  **/
-static s32 igb_get_phy_cfg_done(struct e1000_hw *hw)
+s32 e1000_get_cfg_done_generic(struct e1000_hw *hw)
 {
-       if (hw->phy.ops.get_cfg_done)
-               return hw->phy.ops.get_cfg_done(hw);
-
-       return 0;
-}
+       DEBUGFUNC("e1000_get_cfg_done_generic");
 
-/**
- *  e1000_release_phy - Generic release PHY
- *  @hw: pointer to the HW structure
- *
- *  Return if silicon family does not require a semaphore when accessing the
- *  PHY.
- **/
-static void igb_release_phy(struct e1000_hw *hw)
-{
-       if (hw->phy.ops.release_phy)
-               hw->phy.ops.release_phy(hw);
-}
-
-/**
- *  e1000_acquire_phy - Generic acquire PHY
- *  @hw: pointer to the HW structure
- *
- *  Return success if silicon family does not require a semaphore when
- *  accessing the PHY.
- **/
-static s32 igb_acquire_phy(struct e1000_hw *hw)
-{
-       if (hw->phy.ops.acquire_phy)
-               return hw->phy.ops.acquire_phy(hw);
-
-       return 0;
-}
-
-/**
- *  e1000_phy_force_speed_duplex - Generic force PHY speed/duplex
- *  @hw: pointer to the HW structure
- *
- *  When the silicon family has not implemented a forced speed/duplex
- *  function for the PHY, simply return 0.
- **/
-s32 igb_phy_force_speed_duplex(struct e1000_hw *hw)
-{
-       if (hw->phy.ops.force_speed_duplex)
-               return hw->phy.ops.force_speed_duplex(hw);
+       msec_delay_irq(10);
 
-       return 0;
+       return E1000_SUCCESS;
 }
 
 /**
@@ -1726,82 +1897,156 @@ s32 igb_phy_force_speed_duplex(struct e1000_hw *hw)
  *
  *  Initializes a Intel Gigabit PHY3 when an EEPROM is not present.
  **/
-s32 igb_phy_init_script_igp3(struct e1000_hw *hw)
+s32 e1000_phy_init_script_igp3(struct e1000_hw *hw)
 {
-       hw_dbg(hw, "Running IGP 3 PHY init script\n");
+       DEBUGOUT("Running IGP 3 PHY init script\n");
 
        /* PHY init IGP 3 */
        /* Enable rise/fall, 10-mode work in class-A */
-       hw->phy.ops.write_phy_reg(hw, 0x2F5B, 0x9018);
+       hw->phy.ops.write_reg(hw, 0x2F5B, 0x9018);
        /* Remove all caps from Replica path filter */
-       hw->phy.ops.write_phy_reg(hw, 0x2F52, 0x0000);
+       hw->phy.ops.write_reg(hw, 0x2F52, 0x0000);
        /* Bias trimming for ADC, AFE and Driver (Default) */
-       hw->phy.ops.write_phy_reg(hw, 0x2FB1, 0x8B24);
+       hw->phy.ops.write_reg(hw, 0x2FB1, 0x8B24);
        /* Increase Hybrid poly bias */
-       hw->phy.ops.write_phy_reg(hw, 0x2FB2, 0xF8F0);
-       /* Add 4% to TX amplitude in Giga mode */
-       hw->phy.ops.write_phy_reg(hw, 0x2010, 0x10B0);
+       hw->phy.ops.write_reg(hw, 0x2FB2, 0xF8F0);
+       /* Add 4% to Tx amplitude in Gig mode */
+       hw->phy.ops.write_reg(hw, 0x2010, 0x10B0);
        /* Disable trimming (TTT) */
-       hw->phy.ops.write_phy_reg(hw, 0x2011, 0x0000);
+       hw->phy.ops.write_reg(hw, 0x2011, 0x0000);
        /* Poly DC correction to 94.6% + 2% for all channels */
-       hw->phy.ops.write_phy_reg(hw, 0x20DD, 0x249A);
+       hw->phy.ops.write_reg(hw, 0x20DD, 0x249A);
        /* ABS DC correction to 95.9% */
-       hw->phy.ops.write_phy_reg(hw, 0x20DE, 0x00D3);
+       hw->phy.ops.write_reg(hw, 0x20DE, 0x00D3);
        /* BG temp curve trim */
-       hw->phy.ops.write_phy_reg(hw, 0x28B4, 0x04CE);
+       hw->phy.ops.write_reg(hw, 0x28B4, 0x04CE);
        /* Increasing ADC OPAMP stage 1 currents to max */
-       hw->phy.ops.write_phy_reg(hw, 0x2F70, 0x29E4);
+       hw->phy.ops.write_reg(hw, 0x2F70, 0x29E4);
        /* Force 1000 ( required for enabling PHY regs configuration) */
-       hw->phy.ops.write_phy_reg(hw, 0x0000, 0x0140);
+       hw->phy.ops.write_reg(hw, 0x0000, 0x0140);
        /* Set upd_freq to 6 */
-       hw->phy.ops.write_phy_reg(hw, 0x1F30, 0x1606);
+       hw->phy.ops.write_reg(hw, 0x1F30, 0x1606);
        /* Disable NPDFE */
-       hw->phy.ops.write_phy_reg(hw, 0x1F31, 0xB814);
+       hw->phy.ops.write_reg(hw, 0x1F31, 0xB814);
        /* Disable adaptive fixed FFE (Default) */
-       hw->phy.ops.write_phy_reg(hw, 0x1F35, 0x002A);
+       hw->phy.ops.write_reg(hw, 0x1F35, 0x002A);
        /* Enable FFE hysteresis */
-       hw->phy.ops.write_phy_reg(hw, 0x1F3E, 0x0067);
+       hw->phy.ops.write_reg(hw, 0x1F3E, 0x0067);
        /* Fixed FFE for short cable lengths */
-       hw->phy.ops.write_phy_reg(hw, 0x1F54, 0x0065);
+       hw->phy.ops.write_reg(hw, 0x1F54, 0x0065);
        /* Fixed FFE for medium cable lengths */
-       hw->phy.ops.write_phy_reg(hw, 0x1F55, 0x002A);
+       hw->phy.ops.write_reg(hw, 0x1F55, 0x002A);
        /* Fixed FFE for long cable lengths */
-       hw->phy.ops.write_phy_reg(hw, 0x1F56, 0x002A);
+       hw->phy.ops.write_reg(hw, 0x1F56, 0x002A);
        /* Enable Adaptive Clip Threshold */
-       hw->phy.ops.write_phy_reg(hw, 0x1F72, 0x3FB0);
+       hw->phy.ops.write_reg(hw, 0x1F72, 0x3FB0);
        /* AHT reset limit to 1 */
-       hw->phy.ops.write_phy_reg(hw, 0x1F76, 0xC0FF);
+       hw->phy.ops.write_reg(hw, 0x1F76, 0xC0FF);
        /* Set AHT master delay to 127 msec */
-       hw->phy.ops.write_phy_reg(hw, 0x1F77, 0x1DEC);
+       hw->phy.ops.write_reg(hw, 0x1F77, 0x1DEC);
        /* Set scan bits for AHT */
-       hw->phy.ops.write_phy_reg(hw, 0x1F78, 0xF9EF);
+       hw->phy.ops.write_reg(hw, 0x1F78, 0xF9EF);
        /* Set AHT Preset bits */
-       hw->phy.ops.write_phy_reg(hw, 0x1F79, 0x0210);
+       hw->phy.ops.write_reg(hw, 0x1F79, 0x0210);
        /* Change integ_factor of channel A to 3 */
-       hw->phy.ops.write_phy_reg(hw, 0x1895, 0x0003);
+       hw->phy.ops.write_reg(hw, 0x1895, 0x0003);
        /* Change prop_factor of channels BCD to 8 */
-       hw->phy.ops.write_phy_reg(hw, 0x1796, 0x0008);
+       hw->phy.ops.write_reg(hw, 0x1796, 0x0008);
        /* Change cg_icount + enable integbp for channels BCD */
-       hw->phy.ops.write_phy_reg(hw, 0x1798, 0xD008);
+       hw->phy.ops.write_reg(hw, 0x1798, 0xD008);
        /*
         * Change cg_icount + enable integbp + change prop_factor_master
         * to 8 for channel A
         */
-       hw->phy.ops.write_phy_reg(hw, 0x1898, 0xD918);
+       hw->phy.ops.write_reg(hw, 0x1898, 0xD918);
        /* Disable AHT in Slave mode on channel A */
-       hw->phy.ops.write_phy_reg(hw, 0x187A, 0x0800);
+       hw->phy.ops.write_reg(hw, 0x187A, 0x0800);
        /*
         * Enable LPLU and disable AN to 1000 in non-D0a states,
         * Enable SPD+B2B
         */
-       hw->phy.ops.write_phy_reg(hw, 0x0019, 0x008D);
+       hw->phy.ops.write_reg(hw, 0x0019, 0x008D);
        /* Enable restart AN on an1000_dis change */
-       hw->phy.ops.write_phy_reg(hw, 0x001B, 0x2080);
+       hw->phy.ops.write_reg(hw, 0x001B, 0x2080);
        /* Enable wh_fifo read clock in 10/100 modes */
-       hw->phy.ops.write_phy_reg(hw, 0x0014, 0x0045);
+       hw->phy.ops.write_reg(hw, 0x0014, 0x0045);
        /* Restart AN, Speed selection is 1000 */
-       hw->phy.ops.write_phy_reg(hw, 0x0000, 0x1340);
+       hw->phy.ops.write_reg(hw, 0x0000, 0x1340);
 
-       return 0;
+       return E1000_SUCCESS;
 }
 
+/**
+ *  e1000_get_phy_type_from_id - Get PHY type from id
+ *  @phy_id: phy_id read from the phy
+ *
+ *  Returns the phy type from the id.
+ **/
+enum e1000_phy_type e1000_get_phy_type_from_id(u32 phy_id)
+{
+       enum e1000_phy_type phy_type = e1000_phy_unknown;
+
+       switch (phy_id) {
+       case M88E1000_I_PHY_ID:
+       case M88E1000_E_PHY_ID:
+       case M88E1111_I_PHY_ID:
+       case M88E1011_I_PHY_ID:
+               phy_type = e1000_phy_m88;
+               break;
+       case IGP01E1000_I_PHY_ID: /* IGP 1 & 2 share this */
+               phy_type = e1000_phy_igp_2;
+               break;
+       case GG82563_E_PHY_ID:
+               phy_type = e1000_phy_gg82563;
+               break;
+       case IGP03E1000_E_PHY_ID:
+               phy_type = e1000_phy_igp_3;
+               break;
+       case IFE_E_PHY_ID:
+       case IFE_PLUS_E_PHY_ID:
+       case IFE_C_E_PHY_ID:
+               phy_type = e1000_phy_ife;
+               break;
+       default:
+               phy_type = e1000_phy_unknown;
+               break;
+       }
+       return phy_type;
+}
+
+/**
+ * e1000_power_up_phy_copper - Restore copper link in case of PHY power down
+ * @hw: pointer to the HW structure
+ *
+ * In the case of a PHY power down to save power, or to turn off link during a
+ * driver unload, or wake on lan is not enabled, restore the link to previous
+ * settings.
+ **/
+void e1000_power_up_phy_copper(struct e1000_hw *hw)
+{
+       u16 mii_reg = 0;
+
+       /* The PHY will retain its settings across a power down/up cycle */
+       hw->phy.ops.read_reg(hw, PHY_CONTROL, &mii_reg);
+       mii_reg &= ~MII_CR_POWER_DOWN;
+       hw->phy.ops.write_reg(hw, PHY_CONTROL, mii_reg);
+}
+
+/**
+ * e1000_power_down_phy_copper - Restore copper link in case of PHY power down
+ * @hw: pointer to the HW structure
+ *
+ * In the case of a PHY power down to save power, or to turn off link during a
+ * driver unload, or wake on lan is not enabled, restore the link to previous
+ * settings.
+ **/
+void e1000_power_down_phy_copper(struct e1000_hw *hw)
+{
+       u16 mii_reg = 0;
+
+       /* The PHY will retain its settings across a power down/up cycle */
+       hw->phy.ops.read_reg(hw, PHY_CONTROL, &mii_reg);
+       mii_reg |= MII_CR_POWER_DOWN;
+       hw->phy.ops.write_reg(hw, PHY_CONTROL, mii_reg);
+       msec_delay(1);
+}
index 7e75dabf95ac7e14d8ae929ca9b7c0a9f3c7114a..6baf848b5a3af46b98f82734a6e15b8a34f8d45e 100644 (file)
@@ -1,7 +1,7 @@
 /*******************************************************************************
 
   Intel(R) Gigabit Ethernet Linux driver
-  Copyright(c) 2007 Intel Corporation.
+  Copyright(c) 2007-2008 Intel Corporation.
 
   This program is free software; you can redistribute it and/or modify it
   under the terms and conditions of the GNU General Public License,
 #ifndef _E1000_PHY_H_
 #define _E1000_PHY_H_
 
-#include "igb_compat.h"
-
-enum e1000_ms_type {
-       e1000_ms_hw_default = 0,
-       e1000_ms_force_master,
-       e1000_ms_force_slave,
-       e1000_ms_auto
-};
-
-enum e1000_smart_speed {
-       e1000_smart_speed_default = 0,
-       e1000_smart_speed_on,
-       e1000_smart_speed_off
-};
-
-s32  igb_check_downshift(struct e1000_hw *hw);
-s32  igb_check_reset_block(struct e1000_hw *hw);
-s32  igb_copper_link_autoneg(struct e1000_hw *hw);
-s32  igb_phy_force_speed_duplex(struct e1000_hw *hw);
-s32  igb_copper_link_setup_igp(struct e1000_hw *hw);
-s32  igb_copper_link_setup_m88(struct e1000_hw *hw);
-s32  igb_phy_force_speed_duplex_igp(struct e1000_hw *hw);
-s32  igb_phy_force_speed_duplex_m88(struct e1000_hw *hw);
-s32  igb_get_cable_length_m88(struct e1000_hw *hw);
-s32  igb_get_cable_length_igp_2(struct e1000_hw *hw);
-s32  igb_get_phy_id(struct e1000_hw *hw);
-s32  igb_get_phy_info_igp(struct e1000_hw *hw);
-s32  igb_get_phy_info_m88(struct e1000_hw *hw);
-s32  igb_phy_sw_reset(struct e1000_hw *hw);
-s32  igb_phy_hw_reset(struct e1000_hw *hw);
-s32  igb_read_phy_reg_igp(struct e1000_hw *hw, u32 offset, u16 *data);
-s32  igb_set_d3_lplu_state(struct e1000_hw *hw, bool active);
-s32  igb_write_phy_reg_igp(struct e1000_hw *hw, u32 offset, u16 data);
-s32  igb_phy_has_link(struct e1000_hw *hw, u32 iterations,
-                               u32 usec_interval, bool *success);
-s32  igb_phy_init_script_igp3(struct e1000_hw *hw);
+void e1000_init_phy_ops_generic(struct e1000_hw *hw);
+s32  e1000_check_downshift_generic(struct e1000_hw *hw);
+s32  e1000_check_polarity_m88(struct e1000_hw *hw);
+s32  e1000_check_polarity_igp(struct e1000_hw *hw);
+s32  e1000_check_reset_block_generic(struct e1000_hw *hw);
+s32  e1000_copper_link_autoneg(struct e1000_hw *hw);
+s32  e1000_copper_link_setup_igp(struct e1000_hw *hw);
+s32  e1000_copper_link_setup_m88(struct e1000_hw *hw);
+s32  e1000_phy_force_speed_duplex_igp(struct e1000_hw *hw);
+s32  e1000_phy_force_speed_duplex_m88(struct e1000_hw *hw);
+s32  e1000_get_cable_length_m88(struct e1000_hw *hw);
+s32  e1000_get_cable_length_igp_2(struct e1000_hw *hw);
+s32  e1000_get_cfg_done_generic(struct e1000_hw *hw);
+s32  e1000_get_phy_id(struct e1000_hw *hw);
+s32  e1000_get_phy_info_igp(struct e1000_hw *hw);
+s32  e1000_get_phy_info_m88(struct e1000_hw *hw);
+s32  e1000_phy_sw_reset_generic(struct e1000_hw *hw);
+void e1000_phy_force_speed_duplex_setup(struct e1000_hw *hw, u16 *phy_ctrl);
+s32  e1000_phy_hw_reset_generic(struct e1000_hw *hw);
+s32  e1000_phy_reset_dsp_generic(struct e1000_hw *hw);
+s32  e1000_read_kmrn_reg_generic(struct e1000_hw *hw, u32 offset, u16 *data);
+s32  e1000_read_phy_reg_igp(struct e1000_hw *hw, u32 offset, u16 *data);
+s32  e1000_read_phy_reg_m88(struct e1000_hw *hw, u32 offset, u16 *data);
+s32  e1000_set_d3_lplu_state_generic(struct e1000_hw *hw, bool active);
+s32  e1000_setup_copper_link_generic(struct e1000_hw *hw);
+s32  e1000_wait_autoneg_generic(struct e1000_hw *hw);
+s32  e1000_write_kmrn_reg_generic(struct e1000_hw *hw, u32 offset, u16 data);
+s32  e1000_write_phy_reg_igp(struct e1000_hw *hw, u32 offset, u16 data);
+s32  e1000_write_phy_reg_m88(struct e1000_hw *hw, u32 offset, u16 data);
+s32  e1000_phy_reset_dsp(struct e1000_hw *hw);
+s32  e1000_phy_has_link_generic(struct e1000_hw *hw, u32 iterations,
+                                u32 usec_interval, bool *success);
+s32  e1000_phy_init_script_igp3(struct e1000_hw *hw);
+enum e1000_phy_type e1000_get_phy_type_from_id(u32 phy_id);
+void e1000_power_up_phy_copper(struct e1000_hw *hw);
+void e1000_power_down_phy_copper(struct e1000_hw *hw);
+s32 e1000_read_phy_reg_mdic(struct e1000_hw *hw, u32 offset, u16 *data);
+s32 e1000_write_phy_reg_mdic(struct e1000_hw *hw, u32 offset, u16 data);
+
+#define E1000_MAX_PHY_ADDR                4
 
 /* IGP01E1000 Specific Registers */
 #define IGP01E1000_PHY_PORT_CONFIG        0x10 /* Port Config */
 #define IGP01E1000_PHY_PORT_STATUS        0x11 /* Status */
 #define IGP01E1000_PHY_PORT_CTRL          0x12 /* Control */
 #define IGP01E1000_PHY_LINK_HEALTH        0x13 /* PHY Link Health */
+#define IGP01E1000_GMII_FIFO              0x14 /* GMII FIFO */
+#define IGP01E1000_PHY_CHANNEL_QUALITY    0x15 /* PHY Channel Quality */
 #define IGP02E1000_PHY_POWER_MGMT         0x19 /* Power Management */
 #define IGP01E1000_PHY_PAGE_SELECT        0x1F /* Page Select */
+#define BM_PHY_PAGE_SELECT                22   /* Page Select for BM */
+#define IGP_PAGE_SHIFT                    5
+#define PHY_REG_MASK                      0x1F
+
 #define IGP01E1000_PHY_PCS_INIT_REG       0x00B4
 #define IGP01E1000_PHY_POLARITY_MASK      0x0078
+
 #define IGP01E1000_PSCR_AUTO_MDIX         0x1000
 #define IGP01E1000_PSCR_FORCE_MDI_MDIX    0x2000 /* 0=MDI, 1=MDIX */
+
 #define IGP01E1000_PSCFR_SMART_SPEED      0x0080
 
 /* Enable flexible speed on link-up */
+#define IGP01E1000_GMII_FLEX_SPD          0x0010
+#define IGP01E1000_GMII_SPD               0x0020 /* Enable SPD */
+
+#define IGP02E1000_PM_SPD                 0x0001 /* Smart Power Down */
 #define IGP02E1000_PM_D0_LPLU             0x0002 /* For D0a states */
 #define IGP02E1000_PM_D3_LPLU             0x0004 /* For all other states */
+
 #define IGP01E1000_PLHR_SS_DOWNGRADE      0x8000
+
 #define IGP01E1000_PSSR_POLARITY_REVERSED 0x0002
 #define IGP01E1000_PSSR_MDIX              0x0008
 #define IGP01E1000_PSSR_SPEED_MASK        0xC000
 #define IGP01E1000_PSSR_SPEED_1000MBPS    0xC000
+
 #define IGP02E1000_PHY_CHANNEL_NUM        4
 #define IGP02E1000_PHY_AGC_A              0x11B1
 #define IGP02E1000_PHY_AGC_B              0x12B1
 #define IGP02E1000_PHY_AGC_C              0x14B1
 #define IGP02E1000_PHY_AGC_D              0x18B1
+
 #define IGP02E1000_AGC_LENGTH_SHIFT       9   /* Course - 15:13, Fine - 12:9 */
 #define IGP02E1000_AGC_LENGTH_MASK        0x7F
 #define IGP02E1000_AGC_RANGE              15
 
+#define IGP03E1000_PHY_MISC_CTRL          0x1B
+#define IGP03E1000_PHY_MISC_DUPLEX_MANUAL_SET  0x1000 /* Manually Set Duplex */
+
 #define E1000_CABLE_LENGTH_UNDEFINED      0xFF
 
+#define E1000_KMRNCTRLSTA_OFFSET          0x001F0000
+#define E1000_KMRNCTRLSTA_OFFSET_SHIFT    16
+#define E1000_KMRNCTRLSTA_REN             0x00200000
+#define E1000_KMRNCTRLSTA_DIAG_OFFSET     0x3    /* Kumeran Diagnostic */
+#define E1000_KMRNCTRLSTA_DIAG_NELPBK     0x1000 /* Nearend Loopback mode */
+
+#define IFE_PHY_EXTENDED_STATUS_CONTROL 0x10
+#define IFE_PHY_SPECIAL_CONTROL     0x11 /* 100BaseTx PHY Special Control */
+#define IFE_PHY_SPECIAL_CONTROL_LED 0x1B /* PHY Special and LED Control */
+#define IFE_PHY_MDIX_CONTROL        0x1C /* MDI/MDI-X Control */
+
+/* IFE PHY Extended Status Control */
+#define IFE_PESC_POLARITY_REVERSED    0x0100
+
+/* IFE PHY Special Control */
+#define IFE_PSC_AUTO_POLARITY_DISABLE      0x0010
+#define IFE_PSC_FORCE_POLARITY             0x0020
+#define IFE_PSC_DISABLE_DYNAMIC_POWER_DOWN 0x0100
+
+/* IFE PHY Special Control and LED Control */
+#define IFE_PSCL_PROBE_MODE            0x0020
+#define IFE_PSCL_PROBE_LEDS_OFF        0x0006 /* Force LEDs 0 and 2 off */
+#define IFE_PSCL_PROBE_LEDS_ON         0x0007 /* Force LEDs 0 and 2 on */
+
+/* IFE PHY MDIX Control */
+#define IFE_PMC_MDIX_STATUS      0x0020 /* 1=MDI-X, 0=MDI */
+#define IFE_PMC_FORCE_MDIX       0x0040 /* 1=force MDI-X, 0=force MDI */
+#define IFE_PMC_AUTO_MDIX        0x0080 /* 1=enable auto MDI/MDI-X, 0=disable */
+
 #endif
index ff187b73c69e7b53346156f9d40581f92df7e310..353df5d4418f67d411c2b3895a0c6f5812d28892 100644 (file)
@@ -1,7 +1,7 @@
 /*******************************************************************************
 
   Intel(R) Gigabit Ethernet Linux driver
-  Copyright(c) 2007 Intel Corporation.
+  Copyright(c) 2007-2008 Intel Corporation.
 
   This program is free software; you can redistribute it and/or modify it
   under the terms and conditions of the GNU General Public License,
 #define _E1000_REGS_H_
 
 #define E1000_CTRL     0x00000  /* Device Control - RW */
+#define E1000_CTRL_DUP 0x00004  /* Device Control Duplicate (Shadow) - RW */
 #define E1000_STATUS   0x00008  /* Device Status - RO */
 #define E1000_EECD     0x00010  /* EEPROM/Flash Control - RW */
 #define E1000_EERD     0x00014  /* EEPROM Read - RW */
 #define E1000_CTRL_EXT 0x00018  /* Extended Device Control - RW */
+#define E1000_FLA      0x0001C  /* Flash Access - RW */
 #define E1000_MDIC     0x00020  /* MDI Control - RW */
 #define E1000_SCTL     0x00024  /* SerDes Control - RW */
 #define E1000_FCAL     0x00028  /* Flow Control Address Low - RW */
 #define E1000_FCAH     0x0002C  /* Flow Control Address High -RW */
+#define E1000_FEXTNVM  0x00028  /* Future Extended NVM - RW */
 #define E1000_FCT      0x00030  /* Flow Control Type - RW */
 #define E1000_CONNSW   0x00034  /* Copper/Fiber switch control - RW */
 #define E1000_VET      0x00038  /* VLAN Ether Type - RW */
 #define E1000_IMS      0x000D0  /* Interrupt Mask Set - RW */
 #define E1000_IMC      0x000D8  /* Interrupt Mask Clear - WO */
 #define E1000_IAM      0x000E0  /* Interrupt Acknowledge Auto Mask */
-#define E1000_RCTL     0x00100  /* RX Control - RW */
+#define E1000_RCTL     0x00100  /* Rx Control - RW */
 #define E1000_FCTTV    0x00170  /* Flow Control Transmit Timer Value - RW */
-#define E1000_TXCW     0x00178  /* TX Configuration Word - RW */
+#define E1000_TXCW     0x00178  /* Tx Configuration Word - RW */
+#define E1000_RXCW     0x00180  /* Rx Configuration Word - RO */
 #define E1000_EICR     0x01580  /* Ext. Interrupt Cause Read - R/clr */
 #define E1000_EITR(_n) (0x01680 + (0x4 * (_n)))
 #define E1000_EICS     0x01520  /* Ext. Interrupt Cause Set - W0 */
 #define E1000_EIMC     0x01528  /* Ext. Interrupt Mask Clear - WO */
 #define E1000_EIAC     0x0152C  /* Ext. Interrupt Auto Clear - RW */
 #define E1000_EIAM     0x01530  /* Ext. Interrupt Ack Auto Clear Mask - RW */
-#define E1000_TCTL     0x00400  /* TX Control - RW */
-#define E1000_TCTL_EXT 0x00404  /* Extended TX Control - RW */
-#define E1000_TIPG     0x00410  /* TX Inter-packet gap -RW */
+#define E1000_GPIE     0x01514  /* General Purpose Interrupt Enable - RW */
+#define E1000_IVAR0    0x01700  /* Interrupt Vector Allocation (array) - RW */
+#define E1000_IVAR_MISC 0x01740 /* IVAR for "other" causes - RW */
+#define E1000_TCTL     0x00400  /* Tx Control - RW */
+#define E1000_TCTL_EXT 0x00404  /* Extended Tx Control - RW */
+#define E1000_TIPG     0x00410  /* Tx Inter-packet gap -RW */
+#define E1000_TBT      0x00448  /* Tx Burst Timer - RW */
 #define E1000_AIT      0x00458  /* Adaptive Interframe Spacing Throttle - RW */
 #define E1000_LEDCTL   0x00E00  /* LED Control - RW */
+#define E1000_EXTCNF_CTRL  0x00F00  /* Extended Configuration Control */
+#define E1000_EXTCNF_SIZE  0x00F08  /* Extended Configuration Size */
+#define E1000_PHY_CTRL     0x00F10  /* PHY Control Register in CSR */
 #define E1000_PBA      0x01000  /* Packet Buffer Allocation - RW */
 #define E1000_PBS      0x01008  /* Packet Buffer Size */
 #define E1000_EEMNGCTL 0x01010  /* MNG EEprom Control */
+#define E1000_EEARBC   0x01024  /* EEPROM Auto Read Bus Control */
+#define E1000_FLASHT   0x01028  /* FLASH Timer Register */
 #define E1000_EEWR     0x0102C  /* EEPROM Write Register - RW */
+#define E1000_FLSWCTL  0x01030  /* FLASH control register */
+#define E1000_FLSWDATA 0x01034  /* FLASH data register */
+#define E1000_FLSWCNT  0x01038  /* FLASH Access Counter */
+#define E1000_FLOP     0x0103C  /* FLASH Opcode Register */
 #define E1000_I2CCMD   0x01028  /* SFPI2C Command Register - RW */
+#define E1000_I2CPARAMS 0x0102C /* SFPI2C Parameters Register - RW */
+#define E1000_WDSTP    0x01040  /* Watchdog Setup - RW */
+#define E1000_SWDSTS   0x01044  /* SW Device Status - RW */
 #define E1000_FRTIMER  0x01048  /* Free Running Timer - RW */
 #define E1000_TCPTIMER 0x0104C  /* TCP Timer - RW */
+#define E1000_VPDDIAG  0x01060  /* VPD Diagnostic - RO */
+#define E1000_ICR_V2   0x01500  /* Interrupt Cause - new location - RC */
+#define E1000_ICS_V2   0x01504  /* Interrupt Cause Set - new location - WO */
+#define E1000_IMS_V2   0x01508  /* Interrupt Mask Set/Read - new location - RW */
+#define E1000_IMC_V2   0x0150C  /* Interrupt Mask Clear - new location - WO */
+#define E1000_IAM_V2   0x01510  /* Interrupt Ack Auto Mask - new location - RW */
+#define E1000_ERT      0x02008  /* Early Rx Threshold - RW */
 #define E1000_FCRTL    0x02160  /* Flow Control Receive Threshold Low - RW */
 #define E1000_FCRTH    0x02168  /* Flow Control Receive Threshold High - RW */
+#define E1000_PSRCTL   0x02170  /* Packet Split Receive Control - RW */
 #define E1000_RDFPCQ(_n)  (0x02430 + (0x4 * (_n)))
+#define E1000_PBRTH    0x02458  /* PB Rx Arbitration Threshold - RW */
 #define E1000_FCRTV    0x02460  /* Flow Control Refresh Timer Value - RW */
-/* Split and Replication RX Control - RW */
+/* Split and Replication Rx Control - RW */
+#define E1000_RDPUMB   0x025CC  /* DMA Rx Descriptor uC Mailbox - RW */
+#define E1000_RDPUAD   0x025D0  /* DMA Rx Descriptor uC Addr Command - RW */
+#define E1000_RDPUWD   0x025D4  /* DMA Rx Descriptor uC Data Write - RW */
+#define E1000_RDPURD   0x025D8  /* DMA Rx Descriptor uC Data Read - RW */
+#define E1000_RDPUCTL  0x025DC  /* DMA Rx Descriptor uC Control - RW */
+#define E1000_PBDIAG   0x02458  /* Packet Buffer Diagnostic - RW */
+#define E1000_RXPBS    0x02404  /* Rx Packet Buffer Size - RW */
+#define E1000_RXCTL(_n)   (0x0C014 + (0x40 * (_n)))
+#define E1000_RQDPC(_n)   (0x0C030 + (0x40 * (_n)))
+#define E1000_TXCTL(_n)   (0x0E014 + (0x40 * (_n)))
+#define E1000_RDTR     0x02820  /* Rx Delay Timer - RW */
+#define E1000_RADV     0x0282C  /* Rx Interrupt Absolute Delay Timer - RW */
 /*
  * Convenience macros
  *
  * Example usage:
  * E1000_RDBAL_REG(current_rx_queue)
  */
-#define E1000_RDBAL(_n)   ((_n) < 4 ? (0x02800 + ((_n) * 0x100)) \
-                                   : (0x0C000 + ((_n) * 0x40)))
-#define E1000_RDBAH(_n)   ((_n) < 4 ? (0x02804 + ((_n) * 0x100)) \
-                                   : (0x0C004 + ((_n) * 0x40)))
-#define E1000_RDLEN(_n)   ((_n) < 4 ? (0x02808 + ((_n) * 0x100)) \
-                                   : (0x0C008 + ((_n) * 0x40)))
-#define E1000_SRRCTL(_n)  ((_n) < 4 ? (0x0280C + ((_n) * 0x100)) \
-                                   : (0x0C00C + ((_n) * 0x40)))
-#define E1000_RDH(_n)     ((_n) < 4 ? (0x02810 + ((_n) * 0x100)) \
-                                   : (0x0C010 + ((_n) * 0x40)))
-#define E1000_RDT(_n)     ((_n) < 4 ? (0x02818 + ((_n) * 0x100)) \
-                                   : (0x0C018 + ((_n) * 0x40)))
-#define E1000_RXDCTL(_n)  ((_n) < 4 ? (0x02828 + ((_n) * 0x100)) \
-                                   : (0x0C028 + ((_n) * 0x40)))
-#define E1000_TDBAL(_n)   ((_n) < 4 ? (0x03800 + ((_n) * 0x100)) \
-                                   : (0x0E000 + ((_n) * 0x40)))
-#define E1000_TDBAH(_n)   ((_n) < 4 ? (0x03804 + ((_n) * 0x100)) \
-                                   : (0x0E004 + ((_n) * 0x40)))
-#define E1000_TDLEN(_n)   ((_n) < 4 ? (0x03808 + ((_n) * 0x100)) \
-                                   : (0x0E008 + ((_n) * 0x40)))
-#define E1000_TDH(_n)     ((_n) < 4 ? (0x03810 + ((_n) * 0x100)) \
-                                   : (0x0E010 + ((_n) * 0x40)))
-#define E1000_TDT(_n)     ((_n) < 4 ? (0x03818 + ((_n) * 0x100)) \
-                                   : (0x0E018 + ((_n) * 0x40)))
-#define E1000_TXDCTL(_n)  ((_n) < 4 ? (0x03828 + ((_n) * 0x100)) \
-                                   : (0x0E028 + ((_n) * 0x40)))
+#define E1000_RDBAL(_n)   ((_n) < 4 ? (0x02800 + ((_n) * 0x100)) : (0x0C000 + ((_n) * 0x40)))
+#define E1000_RDBAH(_n)   ((_n) < 4 ? (0x02804 + ((_n) * 0x100)) : (0x0C004 + ((_n) * 0x40)))
+#define E1000_RDLEN(_n)   ((_n) < 4 ? (0x02808 + ((_n) * 0x100)) : (0x0C008 + ((_n) * 0x40)))
+#define E1000_SRRCTL(_n)  ((_n) < 4 ? (0x0280C + ((_n) * 0x100)) : (0x0C00C + ((_n) * 0x40)))
+#define E1000_RDH(_n)     ((_n) < 4 ? (0x02810 + ((_n) * 0x100)) : (0x0C010 + ((_n) * 0x40)))
+#define E1000_RDT(_n)     ((_n) < 4 ? (0x02818 + ((_n) * 0x100)) : (0x0C018 + ((_n) * 0x40)))
+#define E1000_RXDCTL(_n)  ((_n) < 4 ? (0x02828 + ((_n) * 0x100)) : (0x0C028 + ((_n) * 0x40)))
+#define E1000_TDBAL(_n)   ((_n) < 4 ? (0x03800 + ((_n) * 0x100)) : (0x0E000 + ((_n) * 0x40)))
+#define E1000_TDBAH(_n)   ((_n) < 4 ? (0x03804 + ((_n) * 0x100)) : (0x0E004 + ((_n) * 0x40)))
+#define E1000_TDLEN(_n)   ((_n) < 4 ? (0x03808 + ((_n) * 0x100)) : (0x0E008 + ((_n) * 0x40)))
+#define E1000_TDH(_n)     ((_n) < 4 ? (0x03810 + ((_n) * 0x100)) : (0x0E010 + ((_n) * 0x40)))
+#define E1000_TDT(_n)     ((_n) < 4 ? (0x03818 + ((_n) * 0x100)) : (0x0E018 + ((_n) * 0x40)))
+#define E1000_TXDCTL(_n)  ((_n) < 4 ? (0x03828 + ((_n) * 0x100)) : (0x0E028 + ((_n) * 0x40)))
 #define E1000_TARC(_n)    (0x03840 + (_n << 8))
 #define E1000_DCA_TXCTRL(_n) (0x03814 + (_n << 8))
 #define E1000_DCA_RXCTRL(_n) (0x02814 + (_n << 8))
-#define E1000_TDWBAL(_n)  ((_n) < 4 ? (0x03838 + ((_n) * 0x100)) \
-                                   : (0x0E038 + ((_n) * 0x40)))
-#define E1000_TDWBAH(_n)  ((_n) < 4 ? (0x0383C + ((_n) * 0x100)) \
-                                   : (0x0E03C + ((_n) * 0x40)))
-#define E1000_TDFH     0x03410  /* TX Data FIFO Head - RW */
-#define E1000_TDFT     0x03418  /* TX Data FIFO Tail - RW */
-#define E1000_TDFHS    0x03420  /* TX Data FIFO Head Saved - RW */
-#define E1000_TDFPC    0x03430  /* TX Data FIFO Packet Count - RW */
-#define E1000_DTXCTL   0x03590  /* DMA TX Control - RW */
+#define E1000_TDWBAL(_n)  ((_n) < 4 ? (0x03838 + ((_n) * 0x100)) : (0x0E038 + ((_n) * 0x40)))
+#define E1000_TDWBAH(_n)  ((_n) < 4 ? (0x0383C + ((_n) * 0x100)) : (0x0E03C + ((_n) * 0x40)))
+#define E1000_RSRPD    0x02C00  /* Rx Small Packet Detect - RW */
+#define E1000_RAID     0x02C08  /* Receive Ack Interrupt Delay - RW */
+#define E1000_TXDMAC   0x03000  /* Tx DMA Control - RW */
+#define E1000_KABGTXD  0x03004  /* AFE Band Gap Transmit Ref Data */
+#define E1000_PSRTYPE(_i)       (0x05480 + ((_i) * 4))
+#define E1000_RAL(_i)  (((_i) <= 15) ? (0x05400 + ((_i) * 8)) : (0x054E0 + ((_i - 16) * 8)))
+#define E1000_RAH(_i)  (((_i) <= 15) ? (0x05404 + ((_i) * 8)) : (0x054E4 + ((_i - 16) * 8)))
+#define E1000_IP4AT_REG(_i)     (0x05840 + ((_i) * 8))
+#define E1000_IP6AT_REG(_i)     (0x05880 + ((_i) * 4))
+#define E1000_WUPM_REG(_i)      (0x05A00 + ((_i) * 4))
+#define E1000_FFMT_REG(_i)      (0x09000 + ((_i) * 8))
+#define E1000_FFVT_REG(_i)      (0x09800 + ((_i) * 8))
+#define E1000_FFLT_REG(_i)      (0x05F00 + ((_i) * 8))
+#define E1000_PBSLAC   0x03100  /* Packet Buffer Slave Access Control */
+#define E1000_PBSLAD(_n)  (0x03110 + (0x4 * (_n)))  /* Packet Buffer DWORD (_n) */
+#define E1000_TXPBS    0x03404  /* Tx Packet Buffer Size - RW */
+#define E1000_TDFH     0x03410  /* Tx Data FIFO Head - RW */
+#define E1000_TDFT     0x03418  /* Tx Data FIFO Tail - RW */
+#define E1000_TDFHS    0x03420  /* Tx Data FIFO Head Saved - RW */
+#define E1000_TDFTS    0x03428  /* Tx Data FIFO Tail Saved - RW */
+#define E1000_TDFPC    0x03430  /* Tx Data FIFO Packet Count - RW */
+#define E1000_TDPUMB   0x0357C  /* DMA Tx Descriptor uC Mail Box - RW */
+#define E1000_TDPUAD   0x03580  /* DMA Tx Descriptor uC Addr Command - RW */
+#define E1000_TDPUWD   0x03584  /* DMA Tx Descriptor uC Data Write - RW */
+#define E1000_TDPURD   0x03588  /* DMA Tx Descriptor uC Data  Read  - RW */
+#define E1000_TDPUCTL  0x0358C  /* DMA Tx Descriptor uC Control - RW */
+#define E1000_DTXCTL   0x03590  /* DMA Tx Control - RW */
+#define E1000_DTXTCPFLGL 0x0359C /* DMA Tx Control flag low - RW */
+#define E1000_DTXTCPFLGH 0x035A0 /* DMA Tx Control flag high - RW */
+#define E1000_DTXMXSZRQ  0x03540 /* DMA Tx Max Total Allow Size Requests - RW */
+#define E1000_TIDV     0x03820  /* Tx Interrupt Delay Value - RW */
+#define E1000_TADV     0x0382C  /* Tx Interrupt Absolute Delay Val - RW */
+#define E1000_TSPMT    0x03830  /* TCP Segmentation PAD & Min Threshold - RW */
 #define E1000_CRCERRS  0x04000  /* CRC Error Count - R/clr */
 #define E1000_ALGNERRC 0x04004  /* Alignment Error Count - R/clr */
 #define E1000_SYMERRS  0x04008  /* Symbol Error Count - R/clr */
 #define E1000_LATECOL  0x04020  /* Late Collision Count - R/clr */
 #define E1000_COLC     0x04028  /* Collision Count - R/clr */
 #define E1000_DC       0x04030  /* Defer Count - R/clr */
-#define E1000_TNCRS    0x04034  /* TX-No CRS - R/clr */
+#define E1000_TNCRS    0x04034  /* Tx-No CRS - R/clr */
 #define E1000_SEC      0x04038  /* Sequence Error Count - R/clr */
 #define E1000_CEXTERR  0x0403C  /* Carrier Extension Error Count - R/clr */
 #define E1000_RLEC     0x04040  /* Receive Length Error Count - R/clr */
-#define E1000_XONRXC   0x04048  /* XON RX Count - R/clr */
-#define E1000_XONTXC   0x0404C  /* XON TX Count - R/clr */
-#define E1000_XOFFRXC  0x04050  /* XOFF RX Count - R/clr */
-#define E1000_XOFFTXC  0x04054  /* XOFF TX Count - R/clr */
-#define E1000_FCRUC    0x04058  /* Flow Control RX Unsupported Count- R/clr */
-#define E1000_PRC64    0x0405C  /* Packets RX (64 bytes) - R/clr */
-#define E1000_PRC127   0x04060  /* Packets RX (65-127 bytes) - R/clr */
-#define E1000_PRC255   0x04064  /* Packets RX (128-255 bytes) - R/clr */
-#define E1000_PRC511   0x04068  /* Packets RX (255-511 bytes) - R/clr */
-#define E1000_PRC1023  0x0406C  /* Packets RX (512-1023 bytes) - R/clr */
-#define E1000_PRC1522  0x04070  /* Packets RX (1024-1522 bytes) - R/clr */
-#define E1000_GPRC     0x04074  /* Good Packets RX Count - R/clr */
-#define E1000_BPRC     0x04078  /* Broadcast Packets RX Count - R/clr */
-#define E1000_MPRC     0x0407C  /* Multicast Packets RX Count - R/clr */
-#define E1000_GPTC     0x04080  /* Good Packets TX Count - R/clr */
-#define E1000_GORCL    0x04088  /* Good Octets RX Count Low - R/clr */
-#define E1000_GORCH    0x0408C  /* Good Octets RX Count High - R/clr */
-#define E1000_GOTCL    0x04090  /* Good Octets TX Count Low - R/clr */
-#define E1000_GOTCH    0x04094  /* Good Octets TX Count High - R/clr */
-#define E1000_RNBC     0x040A0  /* RX No Buffers Count - R/clr */
-#define E1000_RUC      0x040A4  /* RX Undersize Count - R/clr */
-#define E1000_RFC      0x040A8  /* RX Fragment Count - R/clr */
-#define E1000_ROC      0x040AC  /* RX Oversize Count - R/clr */
-#define E1000_RJC      0x040B0  /* RX Jabber Count - R/clr */
-#define E1000_MGTPRC   0x040B4  /* Management Packets RX Count - R/clr */
+#define E1000_XONRXC   0x04048  /* XON Rx Count - R/clr */
+#define E1000_XONTXC   0x0404C  /* XON Tx Count - R/clr */
+#define E1000_XOFFRXC  0x04050  /* XOFF Rx Count - R/clr */
+#define E1000_XOFFTXC  0x04054  /* XOFF Tx Count - R/clr */
+#define E1000_FCRUC    0x04058  /* Flow Control Rx Unsupported Count- R/clr */
+#define E1000_PRC64    0x0405C  /* Packets Rx (64 bytes) - R/clr */
+#define E1000_PRC127   0x04060  /* Packets Rx (65-127 bytes) - R/clr */
+#define E1000_PRC255   0x04064  /* Packets Rx (128-255 bytes) - R/clr */
+#define E1000_PRC511   0x04068  /* Packets Rx (255-511 bytes) - R/clr */
+#define E1000_PRC1023  0x0406C  /* Packets Rx (512-1023 bytes) - R/clr */
+#define E1000_PRC1522  0x04070  /* Packets Rx (1024-1522 bytes) - R/clr */
+#define E1000_GPRC     0x04074  /* Good Packets Rx Count - R/clr */
+#define E1000_BPRC     0x04078  /* Broadcast Packets Rx Count - R/clr */
+#define E1000_MPRC     0x0407C  /* Multicast Packets Rx Count - R/clr */
+#define E1000_GPTC     0x04080  /* Good Packets Tx Count - R/clr */
+#define E1000_GORCL    0x04088  /* Good Octets Rx Count Low - R/clr */
+#define E1000_GORCH    0x0408C  /* Good Octets Rx Count High - R/clr */
+#define E1000_GOTCL    0x04090  /* Good Octets Tx Count Low - R/clr */
+#define E1000_GOTCH    0x04094  /* Good Octets Tx Count High - R/clr */
+#define E1000_RNBC     0x040A0  /* Rx No Buffers Count - R/clr */
+#define E1000_RUC      0x040A4  /* Rx Undersize Count - R/clr */
+#define E1000_RFC      0x040A8  /* Rx Fragment Count - R/clr */
+#define E1000_ROC      0x040AC  /* Rx Oversize Count - R/clr */
+#define E1000_RJC      0x040B0  /* Rx Jabber Count - R/clr */
+#define E1000_MGTPRC   0x040B4  /* Management Packets Rx Count - R/clr */
 #define E1000_MGTPDC   0x040B8  /* Management Packets Dropped Count - R/clr */
-#define E1000_MGTPTC   0x040BC  /* Management Packets TX Count - R/clr */
-#define E1000_TORL     0x040C0  /* Total Octets RX Low - R/clr */
-#define E1000_TORH     0x040C4  /* Total Octets RX High - R/clr */
-#define E1000_TOTL     0x040C8  /* Total Octets TX Low - R/clr */
-#define E1000_TOTH     0x040CC  /* Total Octets TX High - R/clr */
-#define E1000_TPR      0x040D0  /* Total Packets RX - R/clr */
-#define E1000_TPT      0x040D4  /* Total Packets TX - R/clr */
-#define E1000_PTC64    0x040D8  /* Packets TX (64 bytes) - R/clr */
-#define E1000_PTC127   0x040DC  /* Packets TX (65-127 bytes) - R/clr */
-#define E1000_PTC255   0x040E0  /* Packets TX (128-255 bytes) - R/clr */
-#define E1000_PTC511   0x040E4  /* Packets TX (256-511 bytes) - R/clr */
-#define E1000_PTC1023  0x040E8  /* Packets TX (512-1023 bytes) - R/clr */
-#define E1000_PTC1522  0x040EC  /* Packets TX (1024-1522 Bytes) - R/clr */
-#define E1000_MPTC     0x040F0  /* Multicast Packets TX Count - R/clr */
-#define E1000_BPTC     0x040F4  /* Broadcast Packets TX Count - R/clr */
-#define E1000_TSCTC    0x040F8  /* TCP Segmentation Context TX - R/clr */
-#define E1000_TSCTFC   0x040FC  /* TCP Segmentation Context TX Fail - R/clr */
+#define E1000_MGTPTC   0x040BC  /* Management Packets Tx Count - R/clr */
+#define E1000_TORL     0x040C0  /* Total Octets Rx Low - R/clr */
+#define E1000_TORH     0x040C4  /* Total Octets Rx High - R/clr */
+#define E1000_TOTL     0x040C8  /* Total Octets Tx Low - R/clr */
+#define E1000_TOTH     0x040CC  /* Total Octets Tx High - R/clr */
+#define E1000_TPR      0x040D0  /* Total Packets Rx - R/clr */
+#define E1000_TPT      0x040D4  /* Total Packets Tx - R/clr */
+#define E1000_PTC64    0x040D8  /* Packets Tx (64 bytes) - R/clr */
+#define E1000_PTC127   0x040DC  /* Packets Tx (65-127 bytes) - R/clr */
+#define E1000_PTC255   0x040E0  /* Packets Tx (128-255 bytes) - R/clr */
+#define E1000_PTC511   0x040E4  /* Packets Tx (256-511 bytes) - R/clr */
+#define E1000_PTC1023  0x040E8  /* Packets Tx (512-1023 bytes) - R/clr */
+#define E1000_PTC1522  0x040EC  /* Packets Tx (1024-1522 Bytes) - R/clr */
+#define E1000_MPTC     0x040F0  /* Multicast Packets Tx Count - R/clr */
+#define E1000_BPTC     0x040F4  /* Broadcast Packets Tx Count - R/clr */
+#define E1000_TSCTC    0x040F8  /* TCP Segmentation Context Tx - R/clr */
+#define E1000_TSCTFC   0x040FC  /* TCP Segmentation Context Tx Fail - R/clr */
 #define E1000_IAC      0x04100  /* Interrupt Assertion Count */
-/* Interrupt Cause Rx Packet Timer Expire Count */
-#define E1000_ICRXPTC  0x04104
-/* Interrupt Cause Rx Absolute Timer Expire Count */
-#define E1000_ICRXATC  0x04108
-/* Interrupt Cause Tx Packet Timer Expire Count */
-#define E1000_ICTXPTC  0x0410C
-/* Interrupt Cause Tx Absolute Timer Expire Count */
-#define E1000_ICTXATC  0x04110
-/* Interrupt Cause Tx Queue Empty Count */
-#define E1000_ICTXQEC  0x04118
-/* Interrupt Cause Tx Queue Minimum Threshold Count */
-#define E1000_ICTXQMTC 0x0411C
-/* Interrupt Cause Rx Descriptor Minimum Threshold Count */
-#define E1000_ICRXDMTC 0x04120
+#define E1000_ICRXPTC  0x04104  /* Interrupt Cause Rx Packet Timer Expire Count */
+#define E1000_ICRXATC  0x04108  /* Interrupt Cause Rx Absolute Timer Expire Count */
+#define E1000_ICTXPTC  0x0410C  /* Interrupt Cause Tx Packet Timer Expire Count */
+#define E1000_ICTXATC  0x04110  /* Interrupt Cause Tx Absolute Timer Expire Count */
+#define E1000_ICTXQEC  0x04118  /* Interrupt Cause Tx Queue Empty Count */
+#define E1000_ICTXQMTC 0x0411C  /* Interrupt Cause Tx Queue Minimum Threshold Count */
+#define E1000_ICRXDMTC 0x04120  /* Interrupt Cause Rx Descriptor Minimum Threshold Count */
 #define E1000_ICRXOC   0x04124  /* Interrupt Cause Receiver Overrun Count */
+
+#define E1000_LSECTXUT        0x04300  /* LinkSec Tx Untagged Packet Count - OutPktsUntagged */
+#define E1000_LSECTXPKTE      0x04304  /* LinkSec Encrypted Tx Packets Count - OutPktsEncrypted */
+#define E1000_LSECTXPKTP      0x04308  /* LinkSec Protected Tx Packet Count - OutPktsProtected */
+#define E1000_LSECTXOCTE      0x0430C  /* LinkSec Encrypted Tx Octets Count - OutOctetsEncrypted */
+#define E1000_LSECTXOCTP      0x04310  /* LinkSec Protected Tx Octets Count - OutOctetsProtected */
+#define E1000_LSECRXUT        0x04314  /* LinkSec Untagged non-Strict Rx Packet Count - InPktsUntagged/InPktsNoTag */
+#define E1000_LSECRXOCTD      0x0431C  /* LinkSec Rx Octets Decrypted Count - InOctetsDecrypted */
+#define E1000_LSECRXOCTV      0x04320  /* LinkSec Rx Octets Validated - InOctetsValidated */
+#define E1000_LSECRXBAD       0x04324  /* LinkSec Rx Bad Tag - InPktsBadTag */
+#define E1000_LSECRXNOSCI     0x04328  /* LinkSec Rx Packet No SCI Count - InPktsNoSci */
+#define E1000_LSECRXUNSCI     0x0432C  /* LinkSec Rx Packet Unknown SCI Count - InPktsUnknownSci */
+#define E1000_LSECRXUNCH      0x04330  /* LinkSec Rx Unchecked Packets Count - InPktsUnchecked */
+#define E1000_LSECRXDELAY     0x04340  /* LinkSec Rx Delayed Packet Count - InPktsDelayed */
+#define E1000_LSECRXLATE      0x04350  /* LinkSec Rx Late Packets Count - InPktsLate */
+#define E1000_LSECRXOK(_n)    (0x04360 + (0x04 * (_n))) /* LinkSec Rx Packet OK Count - InPktsOk */
+#define E1000_LSECRXINV(_n)   (0x04380 + (0x04 * (_n))) /* LinkSec Rx Invalid Count - InPktsInvalid */
+#define E1000_LSECRXNV(_n)    (0x043A0 + (0x04 * (_n))) /* LinkSec Rx Not Valid Count - InPktsNotValid */
+#define E1000_LSECRXUNSA      0x043C0  /* LinkSec Rx Unused SA Count - InPktsUnusedSa */
+#define E1000_LSECRXNUSA      0x043D0  /* LinkSec Rx Not Using SA Count - InPktsNotUsingSa */
+#define E1000_LSECTXCAP       0x0B000  /* LinkSec Tx Capabilities Register - RO */
+#define E1000_LSECRXCAP       0x0B300  /* LinkSec Rx Capabilities Register - RO */
+#define E1000_LSECTXCTRL      0x0B004  /* LinkSec Tx Control - RW */
+#define E1000_LSECRXCTRL      0x0B304  /* LinkSec Rx Control - RW */
+#define E1000_LSECTXSCL       0x0B008  /* LinkSec Tx SCI Low - RW */
+#define E1000_LSECTXSCH       0x0B00C  /* LinkSec Tx SCI High - RW */
+#define E1000_LSECTXSA        0x0B010  /* LinkSec Tx SA0 - RW */
+#define E1000_LSECTXPN0       0x0B018  /* LinkSec Tx SA PN 0 - RW */
+#define E1000_LSECTXPN1       0x0B01C  /* LinkSec Tx SA PN 1 - RW */
+#define E1000_LSECRXSCL       0x0B3D0  /* LinkSec Rx SCI Low - RW */
+#define E1000_LSECRXSCH       0x0B3E0  /* LinkSec Rx SCI High - RW */
+#define E1000_LSECTXKEY0(_n)  (0x0B020 + (0x04 * (_n))) /* LinkSec Tx 128-bit Key 0 - WO */
+#define E1000_LSECTXKEY1(_n)  (0x0B030 + (0x04 * (_n))) /* LinkSec Tx 128-bit Key 1 - WO */
+#define E1000_LSECRXSA(_n)    (0x0B310 + (0x04 * (_n))) /* LinkSec Rx SAs - RW */
+#define E1000_LSECRXPN(_n)    (0x0B330 + (0x04 * (_n))) /* LinkSec Rx SAs - RW */
+/*
+ * LinkSec Rx Keys  - where _n is the SA no. and _m the 4 dwords of the 128 bit
+ * key - RW.
+ */
+#define E1000_LSECRXKEY(_n, _m) (0x0B350 + (0x10 * (_n)) + (0x04 * (_m)))
+
+#define E1000_SSVPC             0x041A0  /* Switch Security Violation Packet Count */
+#define E1000_IPSCTRL           0xB430   /* IpSec Control Register */
+#define E1000_IPSRXCMD          0x0B408  /* IPSec Rx Command Register - RW */
+#define E1000_IPSRXIDX          0x0B400  /* IPSec Rx Index - RW */
+#define E1000_IPSRXIPADDR(_n)   (0x0B420+ (0x04 * (_n)))  /* IPSec Rx IPv4/v6 Address - RW */
+#define E1000_IPSRXKEY(_n)      (0x0B410 + (0x04 * (_n))) /* IPSec Rx 128-bit Key - RW */
+#define E1000_IPSRXSALT         0x0B404  /* IPSec Rx Salt - RW */
+#define E1000_IPSRXSPI          0x0B40C  /* IPSec Rx SPI - RW */
+#define E1000_IPSTXKEY(_n)      (0x0B460 + (0x04 * (_n))) /* IPSec Tx 128-bit Key - RW */
+#define E1000_IPSTXSALT         0x0B454  /* IPSec Tx Salt - RW */
+#define E1000_IPSTXIDX          0x0B450  /* IPSec Tx SA IDX - RW */
 #define E1000_PCS_CFG0    0x04200  /* PCS Configuration 0 - RW */
 #define E1000_PCS_LCTL    0x04208  /* PCS Link Control - RW */
 #define E1000_PCS_LSTAT   0x0420C  /* PCS Link Status - RO */
-#define E1000_CBTMPC      0x0402C  /* Circuit Breaker TX Packet Count */
+#define E1000_CBTMPC      0x0402C  /* Circuit Breaker Tx Packet Count */
 #define E1000_HTDPMC      0x0403C  /* Host Transmit Discarded Packets */
-#define E1000_CBRMPC      0x040FC  /* Circuit Breaker RX Packet Count */
+#define E1000_CBRDPC      0x04044  /* Circuit Breaker Rx Dropped Count */
+#define E1000_CBRMPC      0x040FC  /* Circuit Breaker Rx Packet Count */
 #define E1000_RPTHC       0x04104  /* Rx Packets To Host */
-#define E1000_HGPTC       0x04118  /* Host Good Packets TX Count */
-#define E1000_HTCBDPC     0x04124  /* Host TX Circuit Breaker Dropped Count */
+#define E1000_HGPTC       0x04118  /* Host Good Packets Tx Count */
+#define E1000_HTCBDPC     0x04124  /* Host Tx Circuit Breaker Dropped Count */
 #define E1000_HGORCL      0x04128  /* Host Good Octets Received Count Low */
 #define E1000_HGORCH      0x0412C  /* Host Good Octets Received Count High */
 #define E1000_HGOTCL      0x04130  /* Host Good Octets Transmit Count Low */
 #define E1000_HGOTCH      0x04134  /* Host Good Octets Transmit Count High */
 #define E1000_LENERRS     0x04138  /* Length Errors Count */
 #define E1000_SCVPC       0x04228  /* SerDes/SGMII Code Violation Pkt Count */
+#define E1000_HRMPC       0x0A018  /* Header Redirection Missed Packet Count */
 #define E1000_PCS_ANADV   0x04218  /* AN advertisement - RW */
 #define E1000_PCS_LPAB    0x0421C  /* Link Partner Ability - RW */
 #define E1000_PCS_NPTX    0x04220  /* AN Next Page Transmit - RW */
 #define E1000_PCS_LPABNP  0x04224  /* Link Partner Ability Next Page - RW */
-#define E1000_RXCSUM   0x05000  /* RX Checksum Control - RW */
-#define E1000_RLPML    0x05004  /* RX Long Packet Max Length */
+#define E1000_1GSTAT_RCV  0x04228  /* 1GSTAT Code Violation Packet Count - RW */
+#define E1000_RXCSUM   0x05000  /* Rx Checksum Control - RW */
+#define E1000_RLPML    0x05004  /* Rx Long Packet Max Length */
 #define E1000_RFCTL    0x05008  /* Receive Filter Control*/
 #define E1000_MTA      0x05200  /* Multicast Table Array - RW Array */
 #define E1000_RA       0x05400  /* Receive Address - RW Array */
+#define E1000_RA2      0x054E0  /* 2nd half of receive address array - RW Array */
 #define E1000_VFTA     0x05600  /* VLAN Filter Table Array - RW Array */
-#define E1000_VMD_CTL  0x0581C  /* VMDq Control - RW */
+#define E1000_VT_CTL   0x0581C  /* VMDq Control - RW */
+#define E1000_VFQA0    0x0B000  /* VLAN Filter Queue Array 0 - RW Array */
+#define E1000_VFQA1    0x0B200  /* VLAN Filter Queue Array 1 - RW Array */
 #define E1000_WUC      0x05800  /* Wakeup Control - RW */
 #define E1000_WUFC     0x05808  /* Wakeup Filter Control - RW */
 #define E1000_WUS      0x05810  /* Wakeup Status - RO */
 #define E1000_MANC     0x05820  /* Management Control - RW */
 #define E1000_IPAV     0x05838  /* IP Address Valid - RW */
+#define E1000_IP4AT    0x05840  /* IPv4 Address Table - RW Array */
+#define E1000_IP6AT    0x05880  /* IPv6 Address Table - RW Array */
 #define E1000_WUPL     0x05900  /* Wakeup Packet Length - RW */
+#define E1000_WUPM     0x05A00  /* Wakeup Packet Memory - RO A */
+#define E1000_PBACL    0x05B68  /* MSIx PBA Clear - Read/Write 1's to clear */
+#define E1000_FFLT     0x05F00  /* Flexible Filter Length Table - RW Array */
 #define E1000_HOST_IF  0x08800  /* Host Interface */
+#define E1000_FFMT     0x09000  /* Flexible Filter Mask Table - RW Array */
+#define E1000_FFVT     0x09800  /* Flexible Filter Value Table - RW Array */
+#define E1000_FHFT(_n)  (0x09000 + (_n * 0x100)) /* Flexible Host Filter Table */
+#define E1000_FHFT_EXT(_n) (0x09A00 + (_n * 0x100)) /* Ext Flexible Host Filter Table */
+
 
+#define E1000_KMRNCTRLSTA 0x00034 /* MAC-PHY interface - RW */
+#define E1000_MDPHYA      0x0003C /* PHY address - RW */
 #define E1000_MANC2H      0x05860 /* Management Control To Host - RW */
 #define E1000_SW_FW_SYNC  0x05B5C /* Software-Firmware Synchronization - RW */
 #define E1000_CCMCTL      0x05B48 /* CCM Control Register */
 #define E1000_GIOCTL      0x05B44 /* GIO Analog Control Register */
 #define E1000_SCCTL       0x05B4C /* PCIc PLL Configuration Register */
+#define E1000_GCR         0x05B00 /* PCI-Ex Control */
+#define E1000_GSCL_1    0x05B10 /* PCI-Ex Statistic Control #1 */
+#define E1000_GSCL_2    0x05B14 /* PCI-Ex Statistic Control #2 */
+#define E1000_GSCL_3    0x05B18 /* PCI-Ex Statistic Control #3 */
+#define E1000_GSCL_4    0x05B1C /* PCI-Ex Statistic Control #4 */
 #define E1000_FACTPS    0x05B30 /* Function Active and Power State to MNG */
 #define E1000_SWSM      0x05B50 /* SW Semaphore */
 #define E1000_FWSM      0x05B54 /* FW Semaphore */
-#define E1000_HICR      0x08F00 /* Host Inteface Control */
+#define E1000_DCA_ID    0x05B70 /* DCA Requester ID Information - RO */
+#define E1000_DCA_CTRL  0x05B74 /* DCA Control - RW */
+#define E1000_FFLT_DBG  0x05F04 /* Debug Register */
+#define E1000_HICR      0x08F00 /* Host Interface Control */
 
 /* RSS registers */
+#define E1000_CPUVEC    0x02C10 /* CPU Vector Register - RW */
 #define E1000_MRQC      0x05818 /* Multiple Receive Control - RW */
 #define E1000_IMIR(_i)      (0x05A80 + ((_i) * 4))  /* Immediate Interrupt */
 #define E1000_IMIREXT(_i)   (0x05AA0 + ((_i) * 4))  /* Immediate Interrupt Ext*/
-#define E1000_IMIRVP    0x05AC0 /* Immediate Interrupt RX VLAN Priority - RW */
-/* MSI-X Allocation Register (_i) - RW */
-#define E1000_MSIXBM(_i)    (0x01600 + ((_i) * 4))
-/* MSI-X Table entry addr low reg 0 - RW */
-#define E1000_MSIXTADD(_i)  (0x0C000 + ((_i) * 0x10))
-/* MSI-X Table entry addr upper reg 0 - RW */
-#define E1000_MSIXTUADD(_i) (0x0C004 + ((_i) * 0x10))
-/* MSI-X Table entry message reg 0 - RW */
-#define E1000_MSIXTMSG(_i)  (0x0C008 + ((_i) * 0x10))
-/* MSI-X Table entry vector ctrl reg 0 - RW */
-#define E1000_MSIXVCTRL(_i) (0x0C00C + ((_i) * 0x10))
-/* Redirection Table - RW Array */
-#define E1000_RETA(_i)  (0x05C00 + ((_i) * 4))
+#define E1000_IMIRVP    0x05AC0 /* Immediate Interrupt Rx VLAN Priority - RW */
+#define E1000_MSIXBM(_i)    (0x01600 + ((_i) * 4)) /* MSI-X Allocation Register (_i) - RW */
+#define E1000_MSIXTADD(_i)  (0x0C000 + ((_i) * 0x10)) /* MSI-X Table entry addr low reg 0 - RW */
+#define E1000_MSIXTUADD(_i) (0x0C004 + ((_i) * 0x10)) /* MSI-X Table entry addr upper reg 0 - RW */
+#define E1000_MSIXTMSG(_i)  (0x0C008 + ((_i) * 0x10)) /* MSI-X Table entry message reg 0 - RW */
+#define E1000_MSIXVCTRL(_i) (0x0C00C + ((_i) * 0x10)) /* MSI-X Table entry vector ctrl reg 0 - RW */
+#define E1000_MSIXPBA    0x0E000 /* MSI-X Pending bit array */
+#define E1000_RETA(_i)  (0x05C00 + ((_i) * 4)) /* Redirection Table - RW Array */
 #define E1000_RSSRK(_i) (0x05C80 + ((_i) * 4)) /* RSS Random Key - RW Array */
+#define E1000_RSSIM     0x05864 /* RSS Interrupt Mask */
+#define E1000_RSSIR     0x05868 /* RSS Interrupt Request */
+/* VT Registers */
+#define E1000_SWPBS     0x03004 /* Switch Packet Buffer Size - RW */
+#define E1000_MBVFICR   0x00C80 /* Mailbox VF Cause - RWC */
+#define E1000_MBVFIMR   0x00C84 /* Mailbox VF int Mask - RW */
+#define E1000_VFLRE     0x00C88 /* VF Register Events - RWC */
+#define E1000_VFRE      0x00C8C /* VF Receive Enables */
+#define E1000_VFTE      0x00C90 /* VF Transmit Enables */
+#define E1000_QDE       0x02408 /* Queue Drop Enable - RW */
+#define E1000_DTXSWC    0x03500 /* DMA Tx Switch Control - RW */
+#define E1000_VLVF      0x05D00 /* VLAN Virtual Machine Filter - RW */
+#define E1000_RPLOLR    0x05AF0 /* Replication Offload - RW */
+#define E1000_UTA       0x0A000 /* Unicast Table Array - RW */
+#define E1000_IOVTCL    0x05BBC /* IOV Control Register */
+#define E1000_VMRCTL    0X05D80 /* Virtual Mirror Rule Control */
+/* These act per VF so an array friendly macro is used */
+#define E1000_V2PMAILBOX(_n)   (0x00C40 + (4 * (_n)))
+#define E1000_P2VMAILBOX(_n)   (0x00C00 + (4 * (_n)))
+#define E1000_VMBMEM(_n)       (0x00800 + (64 * (_n)))
+#define E1000_VFVMBMEM(_n)     (0x00800 + (_n))
+#define E1000_VMOLR(_n)        (0x05AD0 + (4 * (_n)))
 
-#define E1000_REGISTER(a, reg) reg
-
-#define wr32(reg, value) (writel(value, hw->hw_addr + reg))
-#define rd32(reg) (readl(hw->hw_addr + reg))
-#define wrfl() ((void)rd32(E1000_STATUS))
+/* Filtering Registers */
+#define E1000_SAQF(_n)  (0x05980 + (4 * (_n))) /* Source Address Queue Fltr */
+#define E1000_DAQF(_n)  (0x059A0 + (4 * (_n))) /* Dest Address Queue Fltr */
+#define E1000_SPQF(_n)  (0x059C0 + (4 * (_n))) /* Source Port Queue Fltr */
+#define E1000_FTQF(_n)  (0x059E0 + (4 * (_n))) /* 5-tuple Queue Fltr */
+#define E1000_SYNQF(_n) (0x055FC + (4 * (_n))) /* SYN Packet Queue Fltr */
+#define E1000_ETQF(_n)  (0x05CB0 + (4 * (_n))) /* EType Queue Fltr */
 
-#define array_wr32(reg, offset, value) \
-       (writel(value, hw->hw_addr + reg + ((offset) << 2)))
-#define array_rd32(reg, offset) \
-       (readl(hw->hw_addr + reg + ((offset) << 2)))
+#define E1000_RTTDCS            0x3600  /* Reedtown Tx Desc plane control and status */
+#define E1000_RTTPCS            0x3474  /* Reedtown Tx Packet Plane control and status */
+#define E1000_RTRPCS            0x2474  /* Rx packet plane control and status */
+#define E1000_RTRUP2TC          0x05AC4 /* Rx User Priority to Traffic Class */
+#define E1000_RTTUP2TC          0x0418  /* Transmit User Priority to Traffic Class */
+#define E1000_RTTDTCRC(_n)      (0x3610 + ((_n) * 4)) /* Tx Desc plane TC Rate-scheduler config */
+#define E1000_RTTPTCRC(_n)      (0x3480 + ((_n) * 4)) /* Tx Packet plane TC Rate-Scheduler Config */
+#define E1000_RTRPTCRC(_n)      (0x2480 + ((_n) * 4)) /* Rx Packet plane TC Rate-Scheduler Config */
+#define E1000_RTTDTCRS(_n)      (0x3630 + ((_n) * 4)) /* Tx Desc Plane TC Rate-Scheduler Status */
+#define E1000_RTTDTCRM(_n)      (0x3650 + ((_n) * 4)) /* Tx Desc Plane TC Rate-Scheduler MMW */
+#define E1000_RTTPTCRS(_n)      (0x34A0 + ((_n) * 4)) /* Tx Packet plane TC Rate-Scheduler Status */
+#define E1000_RTTPTCRM(_n)      (0x34C0 + ((_n) * 4)) /* Tx Packet plane TC Rate-scheduler MMW */
+#define E1000_RTRPTCRS(_n)      (0x24A0 + ((_n) * 4)) /* Rx Packet plane TC Rate-Scheduler Status */
+#define E1000_RTRPTCRM(_n)      (0x24C0 + ((_n) * 4)) /* Rx Packet plane TC Rate-Scheduler MMW */
+#define E1000_RTTDVMRM(_n)      (0x3670 + ((_n) * 4)) /* Tx Desc plane VM Rate-Scheduler MMW*/
+#define E1000_RTTBCNRM(_n)      (0x3690 + ((_n) * 4)) /* Tx BCN Rate-Scheduler MMW */
+#define E1000_RTTDQSEL          0x3604  /* Tx Desc Plane Queue Select */
+#define E1000_RTTDVMRC          0x3608  /* Tx Desc Plane VM Rate-Scheduler Config */
+#define E1000_RTTDVMRS          0x360C  /* Tx Desc Plane VM Rate-Scheduler Status */
+#define E1000_RTTBCNRC          0x36B0  /* Tx BCN Rate-Scheduler Config */
+#define E1000_RTTBCNRS          0x36B4  /* Tx BCN Rate-Scheduler Status */
+#define E1000_RTTBCNCR          0xB200  /* Tx BCN Control Register */
+#define E1000_RTTBCNTG          0x35A4  /* Tx BCN Tagging */
+#define E1000_RTTBCNCP          0xB208  /* Tx BCN Congestion point */
+#define E1000_RTRBCNCR          0xB20C  /* Rx BCN Control Register */
+#define E1000_RTTBCNRD          0x36B8  /* Tx BCN Rate Drift */
+#define E1000_PFCTOP            0x1080  /* Priority Flow Control Type and Opcode */
+#define E1000_RTTBCNIDX         0xB204  /* Tx BCN Congestion Point */
+#define E1000_RTTBCNACH         0x0B214 /* Tx BCN Control High */
+#define E1000_RTTBCNACL         0x0B210 /* Tx BCN Control Low */
 
 #endif
index 7d5d71135b9fe9255d3e1e7818605ca11d2fc49e..21c469c7b742da97d3d786397db46999be47d507 100644 (file)
@@ -1,7 +1,7 @@
 /*******************************************************************************
 
   Intel(R) Gigabit Ethernet Linux driver
-  Copyright(c) 2007 Intel Corporation.
+  Copyright(c) 2007-2008 Intel Corporation.
 
   This program is free software; you can redistribute it and/or modify it
   under the terms and conditions of the GNU General Public License,
 #ifndef _IGB_H_
 #define _IGB_H_
 
-#include "e1000_mac.h"
-#include "e1000_82575.h"
+#include <linux/pci.h>
+#include <linux/netdevice.h>
+#include <linux/vmalloc.h>
+
+#ifdef SIOCETHTOOL
+#include <linux/ethtool.h>
+#endif
 
 struct igb_adapter;
 
-/* Interrupt defines */
-#define IGB_MAX_TX_CLEAN 72
+#if defined(CONFIG_DCA) || defined(CONFIG_DCA_MODULE)
+#define IGB_DCA
+#endif
+#ifdef IGB_DCA
+#include <linux/dca.h>
+#endif
+
+#ifdef IGB_LRO
+#undef IGB_LRO
+#ifdef NETIF_F_LRO
+#if defined(CONFIG_INET_LRO) || defined(CONFIG_INET_LRO_MODULE)
+#include <linux/inet_lro.h>
+#define MAX_LRO_DESCRIPTORS               8
+#define IGB_LRO
+#endif
+#endif
+#endif /* IGB_LRO */
 
-#define IGB_MIN_DYN_ITR 3000
-#define IGB_MAX_DYN_ITR 96000
-#define IGB_START_ITR 6000
+#include "kcompat.h"
 
-#define IGB_DYN_ITR_PACKET_THRESHOLD 2
-#define IGB_DYN_ITR_LENGTH_LOW 200
-#define IGB_DYN_ITR_LENGTH_HIGH 1000
+#include "e1000_api.h"
+#include "e1000_82575.h"
+
+#define IGB_ERR(args...) printk(KERN_ERR "igb: " args)
+
+#define PFX "igb: "
+#define DPRINTK(nlevel, klevel, fmt, args...) \
+       (void)((NETIF_MSG_##nlevel & adapter->msg_enable) && \
+       printk(KERN_##klevel PFX "%s: %s: " fmt, adapter->netdev->name, \
+               __FUNCTION__ , ## args))
+
+/* Interrupt defines */
+#define IGB_START_ITR                    648 /* ~6000 ints/sec */
 
+/* Interrupt modes, as used by the IntMode paramter */
+#define IGB_INT_MODE_LEGACY                0
+#define IGB_INT_MODE_MSI                   1
+#define IGB_INT_MODE_MSIX_1Q               2
+#define IGB_INT_MODE_MSIX_MQ               3
+
+#define HW_PERF
 /* TX/RX descriptor defines */
 #define IGB_DEFAULT_TXD                  256
 #define IGB_MIN_TXD                       80
@@ -56,12 +91,19 @@ struct igb_adapter;
 #define IGB_MIN_RXD                       80
 #define IGB_MAX_RXD                     4096
 
-#define IGB_DEFAULT_ITR                    3 /* dynamic */
-#define IGB_MAX_ITR_USECS              10000
-#define IGB_MIN_ITR_USECS                 10
+#define IGB_MIN_ITR_USECS                 10 /* 100k irq/sec */
+#define IGB_MAX_ITR_USECS              10000 /* 100  irq/sec */
 
 /* Transmit and receive queues */
-#define IGB_MAX_RX_QUEUES                  1
+#ifndef CONFIG_IGB_SEPARATE_TX_HANDLER
+#define IGB_MAX_RX_QUEUES                  (hw->mac.type > e1000_82575 ? 8 : 4)
+#define IGB_MAX_TX_QUEUES                  (hw->mac.type > e1000_82575 ? 8 : 4)
+#define IGB_ABS_MAX_TX_QUEUES              8
+#else /* CONFIG_IGB_SEPARATE_TX_HANDLER */
+#define IGB_MAX_RX_QUEUES                  4
+#define IGB_MAX_TX_QUEUES                  4
+#define IGB_ABS_MAX_TX_QUEUES              4
+#endif  /* CONFIG_IGB_SEPARATE_TX_HANDLER */
 
 /* RX descriptor control thresholds.
  * PTHRESH - MAC will consider prefetch if it has fewer than this number of
@@ -92,10 +134,14 @@ struct igb_adapter;
 #define IGB_RXBUFFER_16384 16384
 
 /* Packet Buffer allocations */
+#define IGB_PBA_BYTES_SHIFT 0xA
+#define IGB_TX_HEAD_ADDR_SHIFT 7
+#define IGB_PBA_TX_MASK 0xFFFF0000
 
+#define IGB_FC_PAUSE_TIME 0x0680 /* 858 usec */
 
 /* How many Tx Descriptors do we need to call netif_wake_queue ? */
-#define IGB_TX_QUEUE_WAKE      16
+#define IGB_TX_QUEUE_WAKE      32
 /* How many Rx Buffers do we bundle into one write to the hardware ? */
 #define IGB_RX_BUFFER_WRITE    16      /* Must be power of 2 */
 
@@ -120,11 +166,15 @@ struct igb_buffer {
                        unsigned long time_stamp;
                        u32 length;
                };
+
+#ifndef CONFIG_IGB_DISABLE_PACKET_SPLIT
                /* RX */
                struct {
                        struct page *page;
                        u64 page_dma;
+                       unsigned int page_offset;
                };
+#endif
        };
 };
 
@@ -150,31 +200,32 @@ struct igb_ring {
        u16 itr_register;
        u16 cpu;
 
+       int queue_index;
        unsigned int total_bytes;
        unsigned int total_packets;
 
+       char name[IFNAMSIZ + 5];
        union {
                /* TX */
                struct {
-                       spinlock_t tx_clean_lock;
-                       spinlock_t tx_lock;
+                       struct igb_queue_stats tx_stats;
                        bool detect_tx_hung;
                };
                /* RX */
                struct {
-                       /* arrays of page information for packet split */
-                       struct sk_buff *pending_skb;
-                       int pending_skb_page;
-                       int no_itr_adjust;
                        struct igb_queue_stats rx_stats;
-                       struct net_device *netdev;
+                       struct napi_struct napi;
+                       int set_itr;
                        struct igb_ring *buddy;
+#ifdef IGB_LRO
+                       struct net_lro_mgr lro_mgr;
+                       bool lro_used;
+#endif
                };
        };
-
-       char name[IFNAMSIZ + 5];
 };
 
+
 #define IGB_DESC_UNUSED(R) \
        ((((R)->next_to_clean > (R)->next_to_use) ? 0 : (R)->count) + \
        (R)->next_to_clean - (R)->next_to_use - 1)
@@ -189,6 +240,7 @@ struct igb_ring {
 #define E1000_TX_DESC(R, i)            E1000_GET_DESC(R, i, e1000_tx_desc)
 #define E1000_RX_DESC(R, i)            E1000_GET_DESC(R, i, e1000_rx_desc)
 
+#define MAX_MSIX_COUNT 10
 /* board specific private data structure */
 
 struct igb_adapter {
@@ -202,6 +254,7 @@ struct igb_adapter {
        u32 en_mng_pt;
        u16 link_speed;
        u16 link_duplex;
+
        unsigned int total_tx_bytes;
        unsigned int total_tx_packets;
        unsigned int total_rx_bytes;
@@ -211,24 +264,21 @@ struct igb_adapter {
        u32 itr_setting;
        u16 tx_itr;
        u16 rx_itr;
-       int set_itr;
 
        struct work_struct reset_task;
        struct work_struct watchdog_task;
        bool fc_autoneg;
        u8  tx_timeout_factor;
+#ifdef ETHTOOL_PHYS_ID
        struct timer_list blink_timer;
        unsigned long led_status;
+#endif
 
        /* TX */
        struct igb_ring *tx_ring;      /* One per active queue */
        unsigned int restart_queue;
        unsigned long tx_queue_len;
        u32 txd_cmd;
-       u32 gotc;
-       u64 gotc_old;
-       u64 tpt_old;
-       u64 colc_old;
        u32 tx_timeout_count;
 
        /* RX */
@@ -241,12 +291,11 @@ struct igb_adapter {
        u64 rx_hdr_split;
        u32 alloc_rx_buff_failed;
        bool rx_csum;
-       u32 gorc;
-       u64 gorc_old;
        u16 rx_ps_hdr_size;
        u32 max_frame_size;
        u32 min_frame_size;
 
+
        /* OS defined structs */
        struct net_device *netdev;
        struct pci_dev *pdev;
@@ -258,35 +307,57 @@ struct igb_adapter {
        struct e1000_phy_info phy_info;
        struct e1000_phy_stats phy_stats;
 
+#ifdef ETHTOOL_TEST
        u32 test_icr;
        struct igb_ring test_tx_ring;
        struct igb_ring test_rx_ring;
+#endif
+
 
        int msg_enable;
        struct msix_entry *msix_entries;
+       int int_mode;
        u32 eims_enable_mask;
-
-       /* to not mess up cache alignment, always add to the bottom */
+       u32 eims_other;
+       u32 lli_port;
+       u32 lli_size;
+       u64 lli_int;
        unsigned long state;
-       unsigned int msi_enabled;
-
+       unsigned int flags;
        u32 eeprom_wol;
+       u32 *config_space;
+#ifdef HAVE_TX_MQ
+       struct igb_ring *multi_tx_table[IGB_ABS_MAX_TX_QUEUES];
+#endif /* HAVE_TX_MQ */
+#ifdef IGB_LRO
+       unsigned int lro_max_aggr;
+       unsigned int lro_aggregated;
+       unsigned int lro_flushed;
+       unsigned int lro_no_desc;
+#endif
+       unsigned int tx_ring_count;
+       unsigned int rx_ring_count;
 };
 
+
+#define IGB_FLAG_HAS_MSI           (1 << 0)
+#define IGB_FLAG_MSI_ENABLE        (1 << 1)
+#define IGB_FLAG_HAS_DCA           (1 << 2)
+#define IGB_FLAG_DCA_ENABLED       (1 << 3)
+#define IGB_FLAG_LLI_PUSH          (1 << 4)
+#define IGB_FLAG_IN_NETPOLL        (1 << 5)
+#define IGB_FLAG_QUAD_PORT_A       (1 << 6)
+#define IGB_FLAG_NEED_CTX_IDX      (1 << 7)
+
 enum e1000_state_t {
        __IGB_TESTING,
        __IGB_RESETTING,
        __IGB_DOWN
 };
 
-enum igb_boards {
-       board_82575,
-};
-
 extern char igb_driver_name[];
 extern char igb_driver_version[];
 
-extern char *igb_get_hw_dev_name(struct e1000_hw *hw);
 extern int igb_up(struct igb_adapter *);
 extern void igb_down(struct igb_adapter *);
 extern void igb_reinit_locked(struct igb_adapter *);
@@ -294,7 +365,13 @@ extern void igb_reset(struct igb_adapter *);
 extern int igb_set_spd_dplx(struct igb_adapter *, u16);
 extern int igb_setup_tx_resources(struct igb_adapter *, struct igb_ring *);
 extern int igb_setup_rx_resources(struct igb_adapter *, struct igb_ring *);
+extern void igb_free_tx_resources(struct igb_ring *);
+extern void igb_free_rx_resources(struct igb_ring *);
 extern void igb_update_stats(struct igb_adapter *);
 extern void igb_set_ethtool_ops(struct net_device *);
+extern void igb_check_options(struct igb_adapter *);
+#ifdef ETHTOOL_OPS_COMPAT
+extern int ethtool_ioctl(struct ifreq *);
+#endif
 
 #endif /* _IGB_H_ */
index 19bfab2253840135ad0e9d524977652c4cd1b837..fd76a803c0385a602b6ee83a322447e01c1c88ba 100644 (file)
@@ -3,6 +3,8 @@
 
 #include <linux/if_vlan.h>
 
+typedef unsigned int bool;
+
 #define ETH_FCS_LEN               4
 
 static inline struct net_device *vlan_group_get_device(struct vlan_group *vg,
@@ -18,4 +20,3 @@ static inline void vlan_group_set_device(struct vlan_group *vg, int vlan_id,
 }
 
 #endif 
-
index 94ccbbf55ad8fb4a8d15b8335fd3c3c6ae524f79..4cffd80f41a1a60f9302b5819c2f99ada24684cc 100644 (file)
@@ -1,7 +1,7 @@
 /*******************************************************************************
 
   Intel(R) Gigabit Ethernet Linux driver
-  Copyright(c) 2007 Intel Corporation.
+  Copyright(c) 2007-2008 Intel Corporation.
 
   This program is free software; you can redistribute it and/or modify it
   under the terms and conditions of the GNU General Public License,
 
 /* ethtool support for igb */
 
-#include <linux/vmalloc.h>
 #include <linux/netdevice.h>
-#include <linux/pci.h>
-#include <linux/delay.h>
-#include <linux/interrupt.h>
-#include <linux/if_ether.h>
+#include <linux/vmalloc.h>
+
+#ifdef SIOCETHTOOL
 #include <linux/ethtool.h>
 
 #include "igb.h"
+#include "igb_regtest.h"
+#include <linux/if_vlan.h>
 
+#ifdef ETHTOOL_OPS_COMPAT
+#include "kcompat_ethtool.c"
+#endif
+
+#ifdef ETHTOOL_GSTATS
 struct igb_stats {
        char stat_string[ETH_GSTRING_LEN];
        int sizeof_stat;
        int stat_offset;
 };
 
-#define IGB_STAT(m) FIELD_SIZEOF(struct igb_adapter, m), \
+#define IGB_STAT(m) sizeof(((struct igb_adapter *)0)->m), \
                      offsetof(struct igb_adapter, m)
 static const struct igb_stats igb_gstrings_stats[] = {
        { "rx_packets", IGB_STAT(stats.gprc) },
@@ -89,42 +94,50 @@ static const struct igb_stats igb_gstrings_stats[] = {
        { "rx_csum_offload_good", IGB_STAT(hw_csum_good) },
        { "rx_csum_offload_errors", IGB_STAT(hw_csum_err) },
        { "rx_header_split", IGB_STAT(rx_hdr_split) },
+       { "low_latency_interrupt", IGB_STAT(lli_int)},
        { "alloc_rx_buff_failed", IGB_STAT(alloc_rx_buff_failed) },
        { "tx_smbus", IGB_STAT(stats.mgptc) },
        { "rx_smbus", IGB_STAT(stats.mgprc) },
        { "dropped_smbus", IGB_STAT(stats.mgpdc) },
+#ifdef IGB_LRO
+       { "lro_aggregated", IGB_STAT(lro_aggregated) },
+       { "lro_flushed", IGB_STAT(lro_flushed) },
+       { "lro_no_desc", IGB_STAT(lro_no_desc) },
+#endif
 };
 
 #define IGB_QUEUE_STATS_LEN \
-       ((((((struct igb_adapter *)netdev->priv)->num_rx_queues > 1) ? \
-         ((struct igb_adapter *)netdev->priv)->num_rx_queues : 0) + \
-        (((((struct igb_adapter *)netdev->priv)->num_tx_queues > 1) ? \
-         ((struct igb_adapter *)netdev->priv)->num_tx_queues : 0))) * \
+        ((((struct igb_adapter *)netdev->priv)->num_rx_queues + \
+         ((struct igb_adapter *)netdev->priv)->num_tx_queues) * \
        (sizeof(struct igb_queue_stats) / sizeof(u64)))
 #define IGB_GLOBAL_STATS_LEN   \
        sizeof(igb_gstrings_stats) / sizeof(struct igb_stats)
 #define IGB_STATS_LEN (IGB_GLOBAL_STATS_LEN + IGB_QUEUE_STATS_LEN)
+#endif /* ETHTOOL_GSTATS */
+#ifdef ETHTOOL_TEST
 static const char igb_gstrings_test[][ETH_GSTRING_LEN] = {
        "Register test  (offline)", "Eeprom test    (offline)",
        "Interrupt test (offline)", "Loopback test  (offline)",
        "Link test   (on/offline)"
 };
 #define IGB_TEST_LEN sizeof(igb_gstrings_test) / ETH_GSTRING_LEN
+#endif /* ETHTOOL_TEST */
 
 static int igb_get_settings(struct net_device *netdev, struct ethtool_cmd *ecmd)
 {
        struct igb_adapter *adapter = netdev_priv(netdev);
        struct e1000_hw *hw = &adapter->hw;
+       u32 status;
 
        if (hw->phy.media_type == e1000_media_type_copper) {
 
                ecmd->supported = (SUPPORTED_10baseT_Half |
-                                  SUPPORTED_10baseT_Full |
-                                  SUPPORTED_100baseT_Half |
-                                  SUPPORTED_100baseT_Full |
-                                  SUPPORTED_1000baseT_Full|
-                                  SUPPORTED_Autoneg |
-                                  SUPPORTED_TP);
+                                  SUPPORTED_10baseT_Full |
+                                  SUPPORTED_100baseT_Half |
+                                  SUPPORTED_100baseT_Full |
+                                  SUPPORTED_1000baseT_Full|
+                                  SUPPORTED_Autoneg |
+                                  SUPPORTED_TP);
                ecmd->advertising = ADVERTISED_TP;
 
                if (hw->mac.autoneg == 1) {
@@ -149,17 +162,20 @@ static int igb_get_settings(struct net_device *netdev, struct ethtool_cmd *ecmd)
 
        ecmd->transceiver = XCVR_INTERNAL;
 
-       if (rd32(E1000_STATUS) & E1000_STATUS_LU) {
+       status = E1000_READ_REG(hw, E1000_STATUS);
 
-               adapter->hw.mac.ops.get_speed_and_duplex(hw,
-                                       &adapter->link_speed,
-                                       &adapter->link_duplex);
-               ecmd->speed = adapter->link_speed;
+       if (status & E1000_STATUS_LU) {
 
-               /* unfortunately FULL_DUPLEX != DUPLEX_FULL
-                *          and HALF_DUPLEX != DUPLEX_HALF */
+               if ((status & E1000_STATUS_SPEED_1000) ||
+                   hw->phy.media_type != e1000_media_type_copper)
+                       ecmd->speed = SPEED_1000;
+               else if (status & E1000_STATUS_SPEED_100)
+                       ecmd->speed = SPEED_100;
+               else
+                       ecmd->speed = SPEED_10;
 
-               if (adapter->link_duplex == FULL_DUPLEX)
+               if ((status & E1000_STATUS_FD) ||
+                   hw->phy.media_type != e1000_media_type_copper)
                        ecmd->duplex = DUPLEX_FULL;
                else
                        ecmd->duplex = DUPLEX_HALF;
@@ -180,9 +196,9 @@ static int igb_set_settings(struct net_device *netdev, struct ethtool_cmd *ecmd)
 
        /* When SoL/IDER sessions are active, autoneg/speed/duplex
         * cannot be changed */
-       if (igb_check_reset_block(hw)) {
-               dev_err(&adapter->pdev->dev, "Cannot change link "
-                       "characteristics when SoL/IDER is active.\n");
+       if (e1000_check_reset_block(hw)) {
+               DPRINTK(DRV, ERR, "Cannot change link characteristics "
+                       "when SoL/IDER is active.\n");
                return -EINVAL;
        }
 
@@ -193,21 +209,23 @@ static int igb_set_settings(struct net_device *netdev, struct ethtool_cmd *ecmd)
                hw->mac.autoneg = 1;
                if (hw->phy.media_type == e1000_media_type_fiber)
                        hw->phy.autoneg_advertised = ADVERTISED_1000baseT_Full |
-                                                    ADVERTISED_FIBRE |
-                                                    ADVERTISED_Autoneg;
+                                                    ADVERTISED_FIBRE |
+                                                    ADVERTISED_Autoneg;
                else
                        hw->phy.autoneg_advertised = ecmd->advertising |
-                                                    ADVERTISED_TP |
-                                                    ADVERTISED_Autoneg;
+                                                    ADVERTISED_TP |
+                                                    ADVERTISED_Autoneg;
                ecmd->advertising = hw->phy.autoneg_advertised;
-       } else
+               if (adapter->fc_autoneg)
+                       hw->fc.original_type = e1000_fc_default;
+       } else {
                if (igb_set_spd_dplx(adapter, ecmd->speed + ecmd->duplex)) {
                        clear_bit(__IGB_RESETTING, &adapter->state);
                        return -EINVAL;
                }
+       }
 
        /* reset the link */
-
        if (netif_running(adapter->netdev)) {
                igb_down(adapter);
                igb_up(adapter);
@@ -219,7 +237,7 @@ static int igb_set_settings(struct net_device *netdev, struct ethtool_cmd *ecmd)
 }
 
 static void igb_get_pauseparam(struct net_device *netdev,
-                              struct ethtool_pauseparam *pause)
+                               struct ethtool_pauseparam *pause)
 {
        struct igb_adapter *adapter = netdev_priv(netdev);
        struct e1000_hw *hw = &adapter->hw;
@@ -238,7 +256,7 @@ static void igb_get_pauseparam(struct net_device *netdev,
 }
 
 static int igb_set_pauseparam(struct net_device *netdev,
-                             struct ethtool_pauseparam *pause)
+                              struct ethtool_pauseparam *pause)
 {
        struct igb_adapter *adapter = netdev_priv(netdev);
        struct e1000_hw *hw = &adapter->hw;
@@ -260,15 +278,14 @@ static int igb_set_pauseparam(struct net_device *netdev,
 
        hw->fc.original_type = hw->fc.type;
 
-       if (adapter->fc_autoneg == AUTONEG_ENABLE) {
-               if (netif_running(adapter->netdev)) {
-                       igb_down(adapter);
-                       igb_up(adapter);
-               } else
-                       igb_reset(adapter);
-       } else
-               retval = ((hw->phy.media_type == e1000_media_type_fiber) ?
-                         igb_setup_link(hw) : igb_force_mac_fc(hw));
+       /* reset the adapter/link to have settings take effect immediately and
+        * let our link partner know as well */
+       if (netif_running(adapter->netdev)) {
+               igb_down(adapter);
+               igb_up(adapter);
+       } else {
+               igb_reset(adapter);
+       }
 
        clear_bit(__IGB_RESETTING, &adapter->state);
        return retval;
@@ -290,37 +307,63 @@ static int igb_set_rx_csum(struct net_device *netdev, u32 data)
 
 static u32 igb_get_tx_csum(struct net_device *netdev)
 {
-       return (netdev->features & NETIF_F_HW_CSUM) != 0;
+       return (netdev->features & NETIF_F_IP_CSUM) != 0;
 }
 
 static int igb_set_tx_csum(struct net_device *netdev, u32 data)
 {
        if (data)
-               netdev->features |= NETIF_F_HW_CSUM;
+#ifdef NETIF_F_IPV6_CSUM
+               netdev->features |= (NETIF_F_IP_CSUM | NETIF_F_IPV6_CSUM);
        else
-               netdev->features &= ~NETIF_F_HW_CSUM;
+               netdev->features &= ~(NETIF_F_IP_CSUM | NETIF_F_IPV6_CSUM);
+#else
+               netdev->features |= NETIF_F_IP_CSUM;
+       else
+               netdev->features &= ~NETIF_F_IP_CSUM;
+#endif
 
        return 0;
 }
 
+#ifdef NETIF_F_TSO
 static int igb_set_tso(struct net_device *netdev, u32 data)
 {
        struct igb_adapter *adapter = netdev_priv(netdev);
+       int i;
+       struct net_device *v_netdev;
 
-       if (data)
+       if (data) {
                netdev->features |= NETIF_F_TSO;
-       else
-               netdev->features &= ~NETIF_F_TSO;
-
-       if (data)
+#ifdef NETIF_F_TSO6
                netdev->features |= NETIF_F_TSO6;
-       else
+#endif
+       } else {
+               netdev->features &= ~NETIF_F_TSO;
+#ifdef NETIF_F_TSO6
                netdev->features &= ~NETIF_F_TSO6;
+#endif
+               /* disable TSO on all VLANs if they're present */
+               if (!adapter->vlgrp)
+                       goto tso_out;
+               for (i = 0; i < VLAN_GROUP_ARRAY_LEN; i++) {
+                       v_netdev = vlan_group_get_device(adapter->vlgrp, i);
+                       if (!v_netdev)
+                               continue;
+
+                       v_netdev->features &= ~NETIF_F_TSO;
+#ifdef NETIF_F_TSO6
+                       v_netdev->features &= ~NETIF_F_TSO6;
+#endif
+                       vlan_group_set_device(adapter->vlgrp, i, v_netdev);
+               }
+       }
 
-       dev_info(&adapter->pdev->dev, "TSO is %s\n",
-                data ? "Enabled" : "Disabled");
+tso_out:
+       DPRINTK(PROBE, INFO, "TSO is %s\n", data ? "Enabled" : "Disabled");
        return 0;
 }
+#endif /* NETIF_F_TSO */
 
 static u32 igb_get_msglevel(struct net_device *netdev)
 {
@@ -341,7 +384,7 @@ static int igb_get_regs_len(struct net_device *netdev)
 }
 
 static void igb_get_regs(struct net_device *netdev,
-                        struct ethtool_regs *regs, void *p)
+                        struct ethtool_regs *regs, void *p)
 {
        struct igb_adapter *adapter = netdev_priv(netdev);
        struct e1000_hw *hw = &adapter->hw;
@@ -353,74 +396,78 @@ static void igb_get_regs(struct net_device *netdev,
        regs->version = (1 << 24) | (hw->revision_id << 16) | hw->device_id;
 
        /* General Registers */
-       regs_buff[0] = rd32(E1000_CTRL);
-       regs_buff[1] = rd32(E1000_STATUS);
-       regs_buff[2] = rd32(E1000_CTRL_EXT);
-       regs_buff[3] = rd32(E1000_MDIC);
-       regs_buff[4] = rd32(E1000_SCTL);
-       regs_buff[5] = rd32(E1000_CONNSW);
-       regs_buff[6] = rd32(E1000_VET);
-       regs_buff[7] = rd32(E1000_LEDCTL);
-       regs_buff[8] = rd32(E1000_PBA);
-       regs_buff[9] = rd32(E1000_PBS);
-       regs_buff[10] = rd32(E1000_FRTIMER);
-       regs_buff[11] = rd32(E1000_TCPTIMER);
+       regs_buff[0] = E1000_READ_REG(hw, E1000_CTRL);
+       regs_buff[1] = E1000_READ_REG(hw, E1000_STATUS);
+       regs_buff[2] = E1000_READ_REG(hw, E1000_CTRL_EXT);
+       regs_buff[3] = E1000_READ_REG(hw, E1000_MDIC);
+       regs_buff[4] = E1000_READ_REG(hw, E1000_SCTL);
+       regs_buff[5] = E1000_READ_REG(hw, E1000_CONNSW);
+       regs_buff[6] = E1000_READ_REG(hw, E1000_VET);
+       regs_buff[7] = E1000_READ_REG(hw, E1000_LEDCTL);
+       regs_buff[8] = E1000_READ_REG(hw, E1000_PBA);
+       regs_buff[9] = E1000_READ_REG(hw, E1000_PBS);
+       regs_buff[10] = E1000_READ_REG(hw, E1000_FRTIMER);
+       regs_buff[11] = E1000_READ_REG(hw, E1000_TCPTIMER);
 
        /* NVM Register */
-       regs_buff[12] = rd32(E1000_EECD);
+       regs_buff[12] = E1000_READ_REG(hw, E1000_EECD);
 
        /* Interrupt */
-       regs_buff[13] = rd32(E1000_EICR);
-       regs_buff[14] = rd32(E1000_EICS);
-       regs_buff[15] = rd32(E1000_EIMS);
-       regs_buff[16] = rd32(E1000_EIMC);
-       regs_buff[17] = rd32(E1000_EIAC);
-       regs_buff[18] = rd32(E1000_EIAM);
-       regs_buff[19] = rd32(E1000_ICR);
-       regs_buff[20] = rd32(E1000_ICS);
-       regs_buff[21] = rd32(E1000_IMS);
-       regs_buff[22] = rd32(E1000_IMC);
-       regs_buff[23] = rd32(E1000_IAC);
-       regs_buff[24] = rd32(E1000_IAM);
-       regs_buff[25] = rd32(E1000_IMIRVP);
+       /* Reading EICS for EICR because they read the
+        * same but EICS does not clear on read */
+       regs_buff[13] = E1000_READ_REG(hw, E1000_EICS);
+       regs_buff[14] = E1000_READ_REG(hw, E1000_EICS);
+       regs_buff[15] = E1000_READ_REG(hw, E1000_EIMS);
+       regs_buff[16] = E1000_READ_REG(hw, E1000_EIMC);
+       regs_buff[17] = E1000_READ_REG(hw, E1000_EIAC);
+       regs_buff[18] = E1000_READ_REG(hw, E1000_EIAM);
+       /* Reading ICS for ICR because they read the
+        * same but ICS does not clear on read */
+       regs_buff[19] = E1000_READ_REG(hw, E1000_ICS);
+       regs_buff[20] = E1000_READ_REG(hw, E1000_ICS);
+       regs_buff[21] = E1000_READ_REG(hw, E1000_IMS);
+       regs_buff[22] = E1000_READ_REG(hw, E1000_IMC);
+       regs_buff[23] = E1000_READ_REG(hw, E1000_IAC);
+       regs_buff[24] = E1000_READ_REG(hw, E1000_IAM);
+       regs_buff[25] = E1000_READ_REG(hw, E1000_IMIRVP);
 
        /* Flow Control */
-       regs_buff[26] = rd32(E1000_FCAL);
-       regs_buff[27] = rd32(E1000_FCAH);
-       regs_buff[28] = rd32(E1000_FCTTV);
-       regs_buff[29] = rd32(E1000_FCRTL);
-       regs_buff[30] = rd32(E1000_FCRTH);
-       regs_buff[31] = rd32(E1000_FCRTV);
+       regs_buff[26] = E1000_READ_REG(hw, E1000_FCAL);
+       regs_buff[27] = E1000_READ_REG(hw, E1000_FCAH);
+       regs_buff[28] = E1000_READ_REG(hw, E1000_FCTTV);
+       regs_buff[29] = E1000_READ_REG(hw, E1000_FCRTL);
+       regs_buff[30] = E1000_READ_REG(hw, E1000_FCRTH);
+       regs_buff[31] = E1000_READ_REG(hw, E1000_FCRTV);
 
        /* Receive */
-       regs_buff[32] = rd32(E1000_RCTL);
-       regs_buff[33] = rd32(E1000_RXCSUM);
-       regs_buff[34] = rd32(E1000_RLPML);
-       regs_buff[35] = rd32(E1000_RFCTL);
-       regs_buff[36] = rd32(E1000_MRQC);
-       regs_buff[37] = rd32(E1000_VMD_CTL);
+       regs_buff[32] = E1000_READ_REG(hw, E1000_RCTL);
+       regs_buff[33] = E1000_READ_REG(hw, E1000_RXCSUM);
+       regs_buff[34] = E1000_READ_REG(hw, E1000_RLPML);
+       regs_buff[35] = E1000_READ_REG(hw, E1000_RFCTL);
+       regs_buff[36] = E1000_READ_REG(hw, E1000_MRQC);
+       regs_buff[37] = E1000_READ_REG(hw, E1000_VT_CTL);
 
        /* Transmit */
-       regs_buff[38] = rd32(E1000_TCTL);
-       regs_buff[39] = rd32(E1000_TCTL_EXT);
-       regs_buff[40] = rd32(E1000_TIPG);
-       regs_buff[41] = rd32(E1000_DTXCTL);
+       regs_buff[38] = E1000_READ_REG(hw, E1000_TCTL);
+       regs_buff[39] = E1000_READ_REG(hw, E1000_TCTL_EXT);
+       regs_buff[40] = E1000_READ_REG(hw, E1000_TIPG);
+       regs_buff[41] = E1000_READ_REG(hw, E1000_DTXCTL);
 
        /* Wake Up */
-       regs_buff[42] = rd32(E1000_WUC);
-       regs_buff[43] = rd32(E1000_WUFC);
-       regs_buff[44] = rd32(E1000_WUS);
-       regs_buff[45] = rd32(E1000_IPAV);
-       regs_buff[46] = rd32(E1000_WUPL);
+       regs_buff[42] = E1000_READ_REG(hw, E1000_WUC);
+       regs_buff[43] = E1000_READ_REG(hw, E1000_WUFC);
+       regs_buff[44] = E1000_READ_REG(hw, E1000_WUS);
+       regs_buff[45] = E1000_READ_REG(hw, E1000_IPAV);
+       regs_buff[46] = E1000_READ_REG(hw, E1000_WUPL);
 
        /* MAC */
-       regs_buff[47] = rd32(E1000_PCS_CFG0);
-       regs_buff[48] = rd32(E1000_PCS_LCTL);
-       regs_buff[49] = rd32(E1000_PCS_LSTAT);
-       regs_buff[50] = rd32(E1000_PCS_ANADV);
-       regs_buff[51] = rd32(E1000_PCS_LPAB);
-       regs_buff[52] = rd32(E1000_PCS_NPTX);
-       regs_buff[53] = rd32(E1000_PCS_LPABNP);
+       regs_buff[47] = E1000_READ_REG(hw, E1000_PCS_CFG0);
+       regs_buff[48] = E1000_READ_REG(hw, E1000_PCS_LCTL);
+       regs_buff[49] = E1000_READ_REG(hw, E1000_PCS_LSTAT);
+       regs_buff[50] = E1000_READ_REG(hw, E1000_PCS_ANADV);
+       regs_buff[51] = E1000_READ_REG(hw, E1000_PCS_LPAB);
+       regs_buff[52] = E1000_READ_REG(hw, E1000_PCS_NPTX);
+       regs_buff[53] = E1000_READ_REG(hw, E1000_PCS_LPABNP);
 
        /* Statistics */
        regs_buff[54] = adapter->stats.crcerrs;
@@ -485,81 +532,70 @@ static void igb_get_regs(struct net_device *netdev,
        regs_buff[119] = adapter->stats.scvpc;
        regs_buff[120] = adapter->stats.hrmpc;
 
-       /* These should probably be added to e1000_regs.h instead */
-       #define E1000_PSRTYPE_REG(_i) (0x05480 + ((_i) * 4))
-       #define E1000_RAL(_i)         (0x05400 + ((_i) * 8))
-       #define E1000_RAH(_i)         (0x05404 + ((_i) * 8))
-       #define E1000_IP4AT_REG(_i)   (0x05840 + ((_i) * 8))
-       #define E1000_IP6AT_REG(_i)   (0x05880 + ((_i) * 4))
-       #define E1000_WUPM_REG(_i)    (0x05A00 + ((_i) * 4))
-       #define E1000_FFMT_REG(_i)    (0x09000 + ((_i) * 8))
-       #define E1000_FFVT_REG(_i)    (0x09800 + ((_i) * 8))
-       #define E1000_FFLT_REG(_i)    (0x05F00 + ((_i) * 8))
-
        for (i = 0; i < 4; i++)
-               regs_buff[121 + i] = rd32(E1000_SRRCTL(i));
+               regs_buff[121 + i] = E1000_READ_REG(hw, E1000_SRRCTL(i));
        for (i = 0; i < 4; i++)
-               regs_buff[125 + i] = rd32(E1000_PSRTYPE_REG(i));
+               regs_buff[125 + i] = E1000_READ_REG(hw, E1000_PSRTYPE(i));
        for (i = 0; i < 4; i++)
-               regs_buff[129 + i] = rd32(E1000_RDBAL(i));
+               regs_buff[129 + i] = E1000_READ_REG(hw, E1000_RDBAL(i));
        for (i = 0; i < 4; i++)
-               regs_buff[133 + i] = rd32(E1000_RDBAH(i));
+               regs_buff[133 + i] = E1000_READ_REG(hw, E1000_RDBAH(i));
        for (i = 0; i < 4; i++)
-               regs_buff[137 + i] = rd32(E1000_RDLEN(i));
+               regs_buff[137 + i] = E1000_READ_REG(hw, E1000_RDLEN(i));
        for (i = 0; i < 4; i++)
-               regs_buff[141 + i] = rd32(E1000_RDH(i));
+               regs_buff[141 + i] = E1000_READ_REG(hw, E1000_RDH(i));
        for (i = 0; i < 4; i++)
-               regs_buff[145 + i] = rd32(E1000_RDT(i));
+               regs_buff[145 + i] = E1000_READ_REG(hw, E1000_RDT(i));
        for (i = 0; i < 4; i++)
-               regs_buff[149 + i] = rd32(E1000_RXDCTL(i));
+               regs_buff[149 + i] = E1000_READ_REG(hw, E1000_RXDCTL(i));
 
        for (i = 0; i < 10; i++)
-               regs_buff[153 + i] = rd32(E1000_EITR(i));
+               regs_buff[153 + i] = E1000_READ_REG(hw, E1000_EITR(i));
        for (i = 0; i < 8; i++)
-               regs_buff[163 + i] = rd32(E1000_IMIR(i));
+               regs_buff[163 + i] = E1000_READ_REG(hw, E1000_IMIR(i));
        for (i = 0; i < 8; i++)
-               regs_buff[171 + i] = rd32(E1000_IMIREXT(i));
+               regs_buff[171 + i] = E1000_READ_REG(hw, E1000_IMIREXT(i));
        for (i = 0; i < 16; i++)
-               regs_buff[179 + i] = rd32(E1000_RAL(i));
+               regs_buff[179 + i] = E1000_READ_REG(hw, E1000_RAL(i));
        for (i = 0; i < 16; i++)
-               regs_buff[195 + i] = rd32(E1000_RAH(i));
+               regs_buff[195 + i] = E1000_READ_REG(hw, E1000_RAH(i));
 
        for (i = 0; i < 4; i++)
-               regs_buff[211 + i] = rd32(E1000_TDBAL(i));
+               regs_buff[211 + i] = E1000_READ_REG(hw, E1000_TDBAL(i));
        for (i = 0; i < 4; i++)
-               regs_buff[215 + i] = rd32(E1000_TDBAH(i));
+               regs_buff[215 + i] = E1000_READ_REG(hw, E1000_TDBAH(i));
        for (i = 0; i < 4; i++)
-               regs_buff[219 + i] = rd32(E1000_TDLEN(i));
+               regs_buff[219 + i] = E1000_READ_REG(hw, E1000_TDLEN(i));
        for (i = 0; i < 4; i++)
-               regs_buff[223 + i] = rd32(E1000_TDH(i));
+               regs_buff[223 + i] = E1000_READ_REG(hw, E1000_TDH(i));
        for (i = 0; i < 4; i++)
-               regs_buff[227 + i] = rd32(E1000_TDT(i));
+               regs_buff[227 + i] = E1000_READ_REG(hw, E1000_TDT(i));
        for (i = 0; i < 4; i++)
-               regs_buff[231 + i] = rd32(E1000_TXDCTL(i));
+               regs_buff[231 + i] = E1000_READ_REG(hw, E1000_TXDCTL(i));
        for (i = 0; i < 4; i++)
-               regs_buff[235 + i] = rd32(E1000_TDWBAL(i));
+               regs_buff[235 + i] = E1000_READ_REG(hw, E1000_TDWBAL(i));
        for (i = 0; i < 4; i++)
-               regs_buff[239 + i] = rd32(E1000_TDWBAH(i));
+               regs_buff[239 + i] = E1000_READ_REG(hw, E1000_TDWBAH(i));
        for (i = 0; i < 4; i++)
-               regs_buff[243 + i] = rd32(E1000_DCA_TXCTRL(i));
+               regs_buff[243 + i] = E1000_READ_REG(hw, E1000_DCA_TXCTRL(i));
 
        for (i = 0; i < 4; i++)
-               regs_buff[247 + i] = rd32(E1000_IP4AT_REG(i));
+               regs_buff[247 + i] = E1000_READ_REG(hw, E1000_IP4AT_REG(i));
        for (i = 0; i < 4; i++)
-               regs_buff[251 + i] = rd32(E1000_IP6AT_REG(i));
+               regs_buff[251 + i] = E1000_READ_REG(hw, E1000_IP6AT_REG(i));
        for (i = 0; i < 32; i++)
-               regs_buff[255 + i] = rd32(E1000_WUPM_REG(i));
+               regs_buff[255 + i] = E1000_READ_REG(hw, E1000_WUPM_REG(i));
        for (i = 0; i < 128; i++)
-               regs_buff[287 + i] = rd32(E1000_FFMT_REG(i));
+               regs_buff[287 + i] = E1000_READ_REG(hw, E1000_FFMT_REG(i));
        for (i = 0; i < 128; i++)
-               regs_buff[415 + i] = rd32(E1000_FFVT_REG(i));
+               regs_buff[415 + i] = E1000_READ_REG(hw, E1000_FFVT_REG(i));
        for (i = 0; i < 4; i++)
-               regs_buff[543 + i] = rd32(E1000_FFLT_REG(i));
+               regs_buff[543 + i] = E1000_READ_REG(hw, E1000_FFLT_REG(i));
 
-       regs_buff[547] = rd32(E1000_TDFH);
-       regs_buff[548] = rd32(E1000_TDFT);
-       regs_buff[549] = rd32(E1000_TDFHS);
-       regs_buff[550] = rd32(E1000_TDFPC);
+       regs_buff[547] = E1000_READ_REG(hw, E1000_TDFH);
+       regs_buff[548] = E1000_READ_REG(hw, E1000_TDFT);
+       regs_buff[549] = E1000_READ_REG(hw, E1000_TDFHS);
+       regs_buff[550] = E1000_READ_REG(hw, E1000_TDFPC);
 
 }
 
@@ -570,7 +606,7 @@ static int igb_get_eeprom_len(struct net_device *netdev)
 }
 
 static int igb_get_eeprom(struct net_device *netdev,
-                         struct ethtool_eeprom *eeprom, u8 *bytes)
+                          struct ethtool_eeprom *eeprom, u8 *bytes)
 {
        struct igb_adapter *adapter = netdev_priv(netdev);
        struct e1000_hw *hw = &adapter->hw;
@@ -593,13 +629,13 @@ static int igb_get_eeprom(struct net_device *netdev,
                return -ENOMEM;
 
        if (hw->nvm.type == e1000_nvm_eeprom_spi)
-               ret_val = hw->nvm.ops.read_nvm(hw, first_word,
-                                           last_word - first_word + 1,
-                                           eeprom_buff);
+               ret_val = e1000_read_nvm(hw, first_word,
+                                        last_word - first_word + 1,
+                                        eeprom_buff);
        else {
                for (i = 0; i < last_word - first_word + 1; i++) {
-                       ret_val = hw->nvm.ops.read_nvm(hw, first_word + i, 1,
-                                                   &eeprom_buff[i]);
+                       ret_val = e1000_read_nvm(hw, first_word + i, 1,
+                                                     &eeprom_buff[i]);
                        if (ret_val)
                                break;
                }
@@ -617,7 +653,7 @@ static int igb_get_eeprom(struct net_device *netdev,
 }
 
 static int igb_set_eeprom(struct net_device *netdev,
-                         struct ethtool_eeprom *eeprom, u8 *bytes)
+                          struct ethtool_eeprom *eeprom, u8 *bytes)
 {
        struct igb_adapter *adapter = netdev_priv(netdev);
        struct e1000_hw *hw = &adapter->hw;
@@ -645,15 +681,15 @@ static int igb_set_eeprom(struct net_device *netdev,
        if (eeprom->offset & 1) {
                /* need read/modify/write of first changed EEPROM word */
                /* only the second byte of the word is being modified */
-               ret_val = hw->nvm.ops.read_nvm(hw, first_word, 1,
+               ret_val = e1000_read_nvm(hw, first_word, 1,
                                            &eeprom_buff[0]);
                ptr++;
        }
        if (((eeprom->offset + eeprom->len) & 1) && (ret_val == 0)) {
                /* need read/modify/write of last changed EEPROM word */
                /* only the first byte of the word is being modified */
-               ret_val = hw->nvm.ops.read_nvm(hw, last_word, 1,
-                                  &eeprom_buff[last_word - first_word]);
+               ret_val = e1000_read_nvm(hw, last_word, 1,
+                                 &eeprom_buff[last_word - first_word]);
        }
 
        /* Device's eeprom is always little-endian, word addressable */
@@ -665,20 +701,20 @@ static int igb_set_eeprom(struct net_device *netdev,
        for (i = 0; i < last_word - first_word + 1; i++)
                eeprom_buff[i] = cpu_to_le16(eeprom_buff[i]);
 
-       ret_val = hw->nvm.ops.write_nvm(hw, first_word,
-                                    last_word - first_word + 1, eeprom_buff);
+       ret_val = e1000_write_nvm(hw, first_word,
+                                 last_word - first_word + 1, eeprom_buff);
 
        /* Update the checksum over the first part of the EEPROM if needed
         * and flush shadow RAM for 82573 controllers */
        if ((ret_val == 0) && ((first_word <= NVM_CHECKSUM_REG)))
-               igb_update_nvm_checksum(hw);
+               e1000_update_nvm_checksum(hw);
 
        kfree(eeprom_buff);
        return ret_val;
 }
 
 static void igb_get_drvinfo(struct net_device *netdev,
-                           struct ethtool_drvinfo *drvinfo)
+                            struct ethtool_drvinfo *drvinfo)
 {
        struct igb_adapter *adapter = netdev_priv(netdev);
        char firmware_version[32];
@@ -689,7 +725,7 @@ static void igb_get_drvinfo(struct net_device *netdev,
 
        /* EEPROM image version # is reported as firmware version # for
         * 82575 controllers */
-       adapter->hw.nvm.ops.read_nvm(&adapter->hw, 5, 1, &eeprom_data);
+       e1000_read_nvm(&adapter->hw, 5, 1, &eeprom_data);
        sprintf(firmware_version, "%d.%d-%d",
                (eeprom_data & 0xF000) >> 12,
                (eeprom_data & 0x0FF0) >> 4,
@@ -704,7 +740,7 @@ static void igb_get_drvinfo(struct net_device *netdev,
 }
 
 static void igb_get_ringparam(struct net_device *netdev,
-                             struct ethtool_ringparam *ring)
+                              struct ethtool_ringparam *ring)
 {
        struct igb_adapter *adapter = netdev_priv(netdev);
        struct igb_ring *tx_ring = adapter->tx_ring;
@@ -721,15 +757,12 @@ static void igb_get_ringparam(struct net_device *netdev,
 }
 
 static int igb_set_ringparam(struct net_device *netdev,
-                            struct ethtool_ringparam *ring)
+                             struct ethtool_ringparam *ring)
 {
        struct igb_adapter *adapter = netdev_priv(netdev);
-       struct igb_buffer *old_buf;
-       struct igb_buffer *old_rx_buf;
-       void *old_desc;
+       struct igb_ring *temp_ring;
        int i, err;
-       u32 new_rx_count, new_tx_count, old_size;
-       dma_addr_t old_dma;
+       u32 new_rx_count, new_tx_count;
 
        if ((ring->rx_mini_pending) || (ring->rx_jumbo_pending))
                return -EINVAL;
@@ -742,12 +775,19 @@ static int igb_set_ringparam(struct net_device *netdev,
        new_tx_count = min(new_tx_count, (u32)IGB_MAX_TXD);
        new_tx_count = ALIGN(new_tx_count, REQ_TX_DESCRIPTOR_MULTIPLE);
 
-       if ((new_tx_count == adapter->tx_ring->count) &&
-           (new_rx_count == adapter->rx_ring->count)) {
+       if ((new_tx_count == adapter->tx_ring_count) &&
+           (new_rx_count == adapter->rx_ring_count)) {
                /* nothing to do */
                return 0;
        }
 
+       if (adapter->num_tx_queues > adapter->num_rx_queues)
+               temp_ring = vmalloc(adapter->num_tx_queues * sizeof(struct igb_ring));
+       else
+               temp_ring = vmalloc(adapter->num_rx_queues * sizeof(struct igb_ring));
+       if (!temp_ring)
+               return -ENOMEM;
+
        while (test_and_set_bit(__IGB_RESETTING, &adapter->state))
                msleep(1);
 
@@ -759,62 +799,55 @@ static int igb_set_ringparam(struct net_device *netdev,
         * because the ISRs in MSI-X mode get passed pointers
         * to the tx and rx ring structs.
         */
-       if (new_tx_count != adapter->tx_ring->count) {
+       if (new_tx_count != adapter->tx_ring_count) {
+               memcpy(temp_ring, adapter->tx_ring,
+                      adapter->num_tx_queues * sizeof(struct igb_ring));
+
                for (i = 0; i < adapter->num_tx_queues; i++) {
-                       /* Save existing descriptor ring */
-                       old_buf = adapter->tx_ring[i].buffer_info;
-                       old_desc = adapter->tx_ring[i].desc;
-                       old_size = adapter->tx_ring[i].size;
-                       old_dma = adapter->tx_ring[i].dma;
-                       /* Try to allocate a new one */
-                       adapter->tx_ring[i].buffer_info = NULL;
-                       adapter->tx_ring[i].desc = NULL;
-                       adapter->tx_ring[i].count = new_tx_count;
-                       err = igb_setup_tx_resources(adapter,
-                                               &adapter->tx_ring[i]);
+                       temp_ring[i].count = new_tx_count;
+                       err = igb_setup_tx_resources(adapter, &temp_ring[i]);
                        if (err) {
-                               /* Restore the old one so at least
-                                  the adapter still works, even if
-                                  we failed the request */
-                               adapter->tx_ring[i].buffer_info = old_buf;
-                               adapter->tx_ring[i].desc = old_desc;
-                               adapter->tx_ring[i].size = old_size;
-                               adapter->tx_ring[i].dma = old_dma;
+                               while (i) {
+                                       i--;
+                                       igb_free_tx_resources(&temp_ring[i]);
+                               }
                                goto err_setup;
                        }
-                       /* Free the old buffer manually */
-                       vfree(old_buf);
-                       pci_free_consistent(adapter->pdev, old_size,
-                                           old_desc, old_dma);
                }
+
+               for (i = 0; i < adapter->num_tx_queues; i++)
+                       igb_free_tx_resources(&adapter->tx_ring[i]);
+
+               memcpy(adapter->tx_ring, temp_ring,
+                      adapter->num_tx_queues * sizeof(struct igb_ring));
+
+               adapter->tx_ring_count = new_tx_count;
        }
 
        if (new_rx_count != adapter->rx_ring->count) {
-               for (i = 0; i < adapter->num_rx_queues; i++) {
+               memcpy(temp_ring, adapter->rx_ring,
+                      adapter->num_rx_queues * sizeof(struct igb_ring));
 
-                       old_rx_buf = adapter->rx_ring[i].buffer_info;
-                       old_desc = adapter->rx_ring[i].desc;
-                       old_size = adapter->rx_ring[i].size;
-                       old_dma = adapter->rx_ring[i].dma;
-
-                       adapter->rx_ring[i].buffer_info = NULL;
-                       adapter->rx_ring[i].desc = NULL;
-                       adapter->rx_ring[i].dma = 0;
-                       adapter->rx_ring[i].count = new_rx_count;
-                       err = igb_setup_rx_resources(adapter,
-                                                    &adapter->rx_ring[i]);
+               for (i = 0; i < adapter->num_rx_queues; i++) {
+                       temp_ring[i].count = new_rx_count;
+                       err = igb_setup_rx_resources(adapter, &temp_ring[i]);
                        if (err) {
-                               adapter->rx_ring[i].buffer_info = old_rx_buf;
-                               adapter->rx_ring[i].desc = old_desc;
-                               adapter->rx_ring[i].size = old_size;
-                               adapter->rx_ring[i].dma = old_dma;
+                               while (i) {
+                                       i--;
+                                       igb_free_rx_resources(&temp_ring[i]);
+                               }
                                goto err_setup;
                        }
 
-                       vfree(old_rx_buf);
-                       pci_free_consistent(adapter->pdev, old_size, old_desc,
-                                           old_dma);
                }
+
+               for (i = 0; i < adapter->num_rx_queues; i++)
+                       igb_free_rx_resources(&adapter->rx_ring[i]);
+
+               memcpy(adapter->rx_ring, temp_ring,
+                      adapter->num_rx_queues * sizeof(struct igb_ring));
+
+               adapter->rx_ring_count = new_rx_count;
        }
 
        err = 0;
@@ -823,112 +856,60 @@ err_setup:
                igb_up(adapter);
 
        clear_bit(__IGB_RESETTING, &adapter->state);
+       vfree(temp_ring);
        return err;
 }
 
-/* ethtool register test data */
-struct igb_reg_test {
-       u16 reg;
-       u8  array_len;
-       u8  test_type;
-       u32 mask;
-       u32 write;
-};
-
-/* In the hardware, registers are laid out either singly, in arrays
- * spaced 0x100 bytes apart, or in contiguous tables.  We assume
- * most tests take place on arrays or single registers (handled
- * as a single-element array) and special-case the tables.
- * Table tests are always pattern tests.
- *
- * We also make provision for some required setup steps by specifying
- * registers to be written without any read-back testing.
- */
-
-#define PATTERN_TEST   1
-#define SET_READ_TEST  2
-#define WRITE_NO_TEST  3
-#define TABLE32_TEST   4
-#define TABLE64_TEST_LO        5
-#define TABLE64_TEST_HI        6
-
-/* default register test */
-static struct igb_reg_test reg_test_82575[] = {
-       { E1000_FCAL, 1, PATTERN_TEST, 0xFFFFFFFF, 0xFFFFFFFF },
-       { E1000_FCAH, 1, PATTERN_TEST, 0x0000FFFF, 0xFFFFFFFF },
-       { E1000_FCT, 1, PATTERN_TEST, 0x0000FFFF, 0xFFFFFFFF },
-       { E1000_VET, 1, PATTERN_TEST, 0xFFFFFFFF, 0xFFFFFFFF },
-       { E1000_RDBAL(0), 4, PATTERN_TEST, 0xFFFFFF80, 0xFFFFFFFF },
-       { E1000_RDBAH(0), 4, PATTERN_TEST, 0xFFFFFFFF, 0xFFFFFFFF },
-       { E1000_RDLEN(0), 4, PATTERN_TEST, 0x000FFF80, 0x000FFFFF },
-       /* Enable all four RX queues before testing. */
-       { E1000_RXDCTL(0), 4, WRITE_NO_TEST, 0, E1000_RXDCTL_QUEUE_ENABLE },
-       /* RDH is read-only for 82575, only test RDT. */
-       { E1000_RDT(0), 4, PATTERN_TEST, 0x0000FFFF, 0x0000FFFF },
-       { E1000_RXDCTL(0), 4, WRITE_NO_TEST, 0, 0 },
-       { E1000_FCRTH, 1, PATTERN_TEST, 0x0000FFF0, 0x0000FFF0 },
-       { E1000_FCTTV, 1, PATTERN_TEST, 0x0000FFFF, 0x0000FFFF },
-       { E1000_TIPG, 1, PATTERN_TEST, 0x3FFFFFFF, 0x3FFFFFFF },
-       { E1000_TDBAL(0), 4, PATTERN_TEST, 0xFFFFFF80, 0xFFFFFFFF },
-       { E1000_TDBAH(0), 4, PATTERN_TEST, 0xFFFFFFFF, 0xFFFFFFFF },
-       { E1000_TDLEN(0), 4, PATTERN_TEST, 0x000FFF80, 0x000FFFFF },
-       { E1000_RCTL, 1, SET_READ_TEST, 0xFFFFFFFF, 0x00000000 },
-       { E1000_RCTL, 1, SET_READ_TEST, 0x04CFB3FE, 0x003FFFFB },
-       { E1000_RCTL, 1, SET_READ_TEST, 0x04CFB3FE, 0xFFFFFFFF },
-       { E1000_TCTL, 1, SET_READ_TEST, 0xFFFFFFFF, 0x00000000 },
-       { E1000_TXCW, 1, PATTERN_TEST, 0xC000FFFF, 0x0000FFFF },
-       { E1000_RA, 16, TABLE64_TEST_LO, 0xFFFFFFFF, 0xFFFFFFFF },
-       { E1000_RA, 16, TABLE64_TEST_HI, 0x800FFFFF, 0xFFFFFFFF },
-       { E1000_MTA, 128, TABLE32_TEST, 0xFFFFFFFF, 0xFFFFFFFF },
-       { 0, 0, 0, 0 }
-};
-
 static bool reg_pattern_test(struct igb_adapter *adapter, u64 *data,
                             int reg, u32 mask, u32 write)
 {
+       struct e1000_hw *hw = &adapter->hw;
        u32 pat, val;
-       u32 _test[] =
+       static const u32 _test[] =
                {0x5A5A5A5A, 0xA5A5A5A5, 0x00000000, 0xFFFFFFFF};
        for (pat = 0; pat < ARRAY_SIZE(_test); pat++) {
-               writel((_test[pat] & write), (adapter->hw.hw_addr + reg));
-               val = readl(adapter->hw.hw_addr + reg);
+               E1000_WRITE_REG(hw, reg, (_test[pat] & write));
+               val = E1000_READ_REG(hw, reg);
                if (val != (_test[pat] & write & mask)) {
-                       dev_err(&adapter->pdev->dev, "pattern test reg %04X "
-                               "failed: got 0x%08X expected 0x%08X\n",
-                               reg, val, (_test[pat] & write & mask));
-                       *data = reg;
+                       DPRINTK(DRV, ERR, "pattern test reg %04X failed: got "
+                               "0x%08X expected 0x%08X\n",
+                               E1000_REGISTER(hw, reg), val,
+                               (_test[pat] & write & mask));
+                       *data = E1000_REGISTER(hw, reg);
                        return 1;
                }
        }
+
        return 0;
 }
 
 static bool reg_set_and_check(struct igb_adapter *adapter, u64 *data,
                              int reg, u32 mask, u32 write)
 {
+       struct e1000_hw *hw = &adapter->hw;
        u32 val;
-       writel((write & mask), (adapter->hw.hw_addr + reg));
-       val = readl(adapter->hw.hw_addr + reg);
+       E1000_WRITE_REG(hw, reg, write & mask);
+       val = E1000_READ_REG(hw, reg);
        if ((write & mask) != (val & mask)) {
-               dev_err(&adapter->pdev->dev, "set/check reg %04X test failed:"
-                       " got 0x%08X expected 0x%08X\n", reg,
-                       (val & mask), (write & mask));
-               *data = reg;
+               DPRINTK(DRV, ERR, "set/check reg %04X test failed: got 0x%08X "
+                       "expected 0x%08X\n", reg, (val & mask), (write & mask));
+               *data = E1000_REGISTER(hw, reg);
                return 1;
        }
+
        return 0;
 }
 
-#define REG_PATTERN_TEST(reg, mask, write) \
-       do { \
-               if (reg_pattern_test(adapter, data, reg, mask, write)) \
-                       return 1; \
+#define REG_PATTERN_TEST(reg, mask, write)                                     \
+       do {                                                                   \
+               if (reg_pattern_test(adapter, data, reg, mask, write))         \
+                       return 1;                                              \
        } while (0)
 
-#define REG_SET_AND_CHECK(reg, mask, write) \
-       do { \
-               if (reg_set_and_check(adapter, data, reg, mask, write)) \
-                       return 1; \
+#define REG_SET_AND_CHECK(reg, mask, write)                                    \
+       do {                                                                   \
+               if (reg_set_and_check(adapter, data, reg, mask, write))              \
+                       return 1;                                              \
        } while (0)
 
 static int igb_reg_test(struct igb_adapter *adapter, u64 *data)
@@ -939,25 +920,33 @@ static int igb_reg_test(struct igb_adapter *adapter, u64 *data)
        u32 i, toggle;
 
        toggle = 0x7FFFF3FF;
-       test = reg_test_82575;
+
+       switch (adapter->hw.mac.type) {
+       case e1000_82576:
+               test = reg_test_82576;
+               break;
+       default:
+               test = reg_test_82575;
+               break;
+       }
 
        /* Because the status register is such a special case,
         * we handle it separately from the rest of the register
         * tests.  Some bits are read-only, some toggle, and some
         * are writable on newer MACs.
         */
-       before = rd32(E1000_STATUS);
-       value = (rd32(E1000_STATUS) & toggle);
-       wr32(E1000_STATUS, toggle);
-       after = rd32(E1000_STATUS) & toggle;
+       before = E1000_READ_REG(hw, E1000_STATUS);
+       value = (E1000_READ_REG(hw, E1000_STATUS) & toggle);
+       E1000_WRITE_REG(hw, E1000_STATUS, toggle);
+       after = E1000_READ_REG(hw, E1000_STATUS) & toggle;
        if (value != after) {
-               dev_err(&adapter->pdev->dev, "failed STATUS register test "
-                       "got: 0x%08X expected: 0x%08X\n", after, value);
+               DPRINTK(DRV, ERR, "failed STATUS register test got: "
+                       "0x%08X expected: 0x%08X\n", after, value);
                *data = 1;
                return 1;
        }
        /* restore previous status */
-       wr32(E1000_STATUS, before);
+       E1000_WRITE_REG(hw, E1000_STATUS, before);
 
        /* Perform the remainder of the register test, looping through
         * the test table until we either fail or reach the null entry.
@@ -966,19 +955,21 @@ static int igb_reg_test(struct igb_adapter *adapter, u64 *data)
                for (i = 0; i < test->array_len; i++) {
                        switch (test->test_type) {
                        case PATTERN_TEST:
-                               REG_PATTERN_TEST(test->reg + (i * 0x100),
+                               REG_PATTERN_TEST(test->reg +
+                                               (i * test->reg_offset),
                                                test->mask,
                                                test->write);
                                break;
                        case SET_READ_TEST:
-                               REG_SET_AND_CHECK(test->reg + (i * 0x100),
+                               REG_SET_AND_CHECK(test->reg +
+                                               (i * test->reg_offset),
                                                test->mask,
                                                test->write);
                                break;
                        case WRITE_NO_TEST:
                                writel(test->write,
-                                   (adapter->hw.hw_addr + test->reg)
-                                       + (i * 0x100));
+                                      (adapter->hw.hw_addr + test->reg)
+                                       + (i * test->reg_offset));
                                break;
                        case TABLE32_TEST:
                                REG_PATTERN_TEST(test->reg + (i * 4),
@@ -1013,8 +1004,7 @@ static int igb_eeprom_test(struct igb_adapter *adapter, u64 *data)
        *data = 0;
        /* Read and add up the contents of the EEPROM */
        for (i = 0; i < (NVM_CHECKSUM_REG + 1); i++) {
-               if ((adapter->hw.nvm.ops.read_nvm(&adapter->hw, i, 1, &temp))
-                   < 0) {
+               if ((e1000_read_nvm(&adapter->hw, i, 1, &temp)) < 0) {
                        *data = 1;
                        break;
                }
@@ -1028,13 +1018,13 @@ static int igb_eeprom_test(struct igb_adapter *adapter, u64 *data)
        return *data;
 }
 
-static irqreturn_t igb_test_intr(int irq, void *data, struct pt_regs *regs)
+static irqreturn_t igb_test_intr(int irq, void *data)
 {
        struct net_device *netdev = (struct net_device *) data;
        struct igb_adapter *adapter = netdev_priv(netdev);
        struct e1000_hw *hw = &adapter->hw;
 
-       adapter->test_icr |= rd32(E1000_ICR);
+       adapter->test_icr |= E1000_READ_REG(hw, E1000_ICR);
 
        return IRQ_HANDLED;
 }
@@ -1043,7 +1033,7 @@ static int igb_intr_test(struct igb_adapter *adapter, u64 *data)
 {
        struct e1000_hw *hw = &adapter->hw;
        struct net_device *netdev = adapter->netdev;
-       u32 mask, i = 0, shared_int = true;
+       u32 mask, i=0, shared_int = TRUE;
        u32 irq = adapter->pdev->irq;
 
        *data = 0;
@@ -1052,25 +1042,26 @@ static int igb_intr_test(struct igb_adapter *adapter, u64 *data)
        if (adapter->msix_entries) {
                /* NOTE: we don't test MSI-X interrupts here, yet */
                return 0;
-       } else if (adapter->msi_enabled) {
-               shared_int = false;
+       } else if (adapter->flags & IGB_FLAG_HAS_MSI) {
+               shared_int = FALSE;
                if (request_irq(irq, &igb_test_intr, 0, netdev->name, netdev)) {
                        *data = 1;
                        return -1;
                }
        } else if (!request_irq(irq, &igb_test_intr, IRQF_PROBE_SHARED,
-                               netdev->name, netdev)) {
-               shared_int = false;
-       } else if (request_irq(irq, &igb_test_intr, IRQF_SHARED,
-                netdev->name, netdev)) {
+                               netdev->name, netdev)) {
+               shared_int = FALSE;
+       }
+       else if (request_irq(irq, &igb_test_intr, IRQF_SHARED,
+                netdev->name, netdev)) {
                *data = 1;
                return -1;
        }
-       dev_info(&adapter->pdev->dev, "testing %s interrupt\n",
-               (shared_int ? "shared" : "unshared"));
+       DPRINTK(HW, INFO, "testing %s interrupt\n",
+               (shared_int ? "shared" : "unshared"));
 
        /* Disable all the interrupts */
-       wr32(E1000_IMC, 0xFFFFFFFF);
+       E1000_WRITE_REG(hw, E1000_IMC, 0xFFFFFFFF);
        msleep(10);
 
        /* Test each interrupt */
@@ -1086,8 +1077,8 @@ static int igb_intr_test(struct igb_adapter *adapter, u64 *data)
                         * test failed.
                         */
                        adapter->test_icr = 0;
-                       wr32(E1000_IMC, ~mask & 0x00007FFF);
-                       wr32(E1000_ICS, ~mask & 0x00007FFF);
+                       E1000_WRITE_REG(hw, E1000_IMC, ~mask & 0x00007FFF);
+                       E1000_WRITE_REG(hw, E1000_ICS, ~mask & 0x00007FFF);
                        msleep(10);
 
                        if (adapter->test_icr & mask) {
@@ -1103,8 +1094,8 @@ static int igb_intr_test(struct igb_adapter *adapter, u64 *data)
                 * test failed.
                 */
                adapter->test_icr = 0;
-               wr32(E1000_IMS, mask);
-               wr32(E1000_ICS, mask);
+               E1000_WRITE_REG(hw, E1000_IMS, mask);
+               E1000_WRITE_REG(hw, E1000_ICS, mask);
                msleep(10);
 
                if (!(adapter->test_icr & mask)) {
@@ -1120,8 +1111,8 @@ static int igb_intr_test(struct igb_adapter *adapter, u64 *data)
                         * test failed.
                         */
                        adapter->test_icr = 0;
-                       wr32(E1000_IMC, ~mask & 0x00007FFF);
-                       wr32(E1000_ICS, ~mask & 0x00007FFF);
+                       E1000_WRITE_REG(hw, E1000_IMC, ~mask & 0x00007FFF);
+                       E1000_WRITE_REG(hw, E1000_ICS, ~mask & 0x00007FFF);
                        msleep(10);
 
                        if (adapter->test_icr) {
@@ -1132,7 +1123,7 @@ static int igb_intr_test(struct igb_adapter *adapter, u64 *data)
        }
 
        /* Disable all the interrupts */
-       wr32(E1000_IMC, 0xFFFFFFFF);
+       E1000_WRITE_REG(hw, E1000_IMC, 0xFFFFFFFF);
        msleep(10);
 
        /* Unhook test interrupt handler */
@@ -1153,7 +1144,7 @@ static void igb_free_desc_rings(struct igb_adapter *adapter)
                        struct igb_buffer *buf = &(tx_ring->buffer_info[i]);
                        if (buf->dma)
                                pci_unmap_single(pdev, buf->dma, buf->length,
-                                                PCI_DMA_TODEVICE);
+                                                PCI_DMA_TODEVICE);
                        if (buf->skb)
                                dev_kfree_skb(buf->skb);
                }
@@ -1164,8 +1155,8 @@ static void igb_free_desc_rings(struct igb_adapter *adapter)
                        struct igb_buffer *buf = &(rx_ring->buffer_info[i]);
                        if (buf->dma)
                                pci_unmap_single(pdev, buf->dma,
-                                                IGB_RXBUFFER_2048,
-                                                PCI_DMA_FROMDEVICE);
+                                                IGB_RXBUFFER_2048,
+                                                PCI_DMA_FROMDEVICE);
                        if (buf->skb)
                                dev_kfree_skb(buf->skb);
                }
@@ -1173,12 +1164,12 @@ static void igb_free_desc_rings(struct igb_adapter *adapter)
 
        if (tx_ring->desc) {
                pci_free_consistent(pdev, tx_ring->size, tx_ring->desc,
-                                   tx_ring->dma);
+                                   tx_ring->dma);
                tx_ring->desc = NULL;
        }
        if (rx_ring->desc) {
                pci_free_consistent(pdev, rx_ring->size, rx_ring->desc,
-                                   rx_ring->dma);
+                                   rx_ring->dma);
                rx_ring->desc = NULL;
        }
 
@@ -1204,32 +1195,30 @@ static int igb_setup_desc_rings(struct igb_adapter *adapter)
        if (!tx_ring->count)
                tx_ring->count = IGB_DEFAULT_TXD;
 
-       tx_ring->buffer_info = kcalloc(tx_ring->count,
-                                      sizeof(struct igb_buffer),
-                                      GFP_KERNEL);
-       if (!tx_ring->buffer_info) {
+       if (!(tx_ring->buffer_info = kcalloc(tx_ring->count,
+                                            sizeof(struct igb_buffer),
+                                            GFP_KERNEL))) {
                ret_val = 1;
                goto err_nomem;
        }
 
        tx_ring->size = tx_ring->count * sizeof(struct e1000_tx_desc);
        tx_ring->size = ALIGN(tx_ring->size, 4096);
-       tx_ring->desc = pci_alloc_consistent(pdev, tx_ring->size,
-                                            &tx_ring->dma);
-       if (!tx_ring->desc) {
+       if (!(tx_ring->desc = pci_alloc_consistent(pdev, tx_ring->size,
+                                                  &tx_ring->dma))) {
                ret_val = 2;
                goto err_nomem;
        }
        tx_ring->next_to_use = tx_ring->next_to_clean = 0;
 
-       wr32(E1000_TDBAL(0),
+       E1000_WRITE_REG(hw, E1000_TDBAL(0),
                        ((u64) tx_ring->dma & 0x00000000FFFFFFFF));
-       wr32(E1000_TDBAH(0), ((u64) tx_ring->dma >> 32));
-       wr32(E1000_TDLEN(0),
+       E1000_WRITE_REG(hw, E1000_TDBAH(0), ((u64) tx_ring->dma >> 32));
+       E1000_WRITE_REG(hw, E1000_TDLEN(0),
                        tx_ring->count * sizeof(struct e1000_tx_desc));
-       wr32(E1000_TDH(0), 0);
-       wr32(E1000_TDT(0), 0);
-       wr32(E1000_TCTL,
+       E1000_WRITE_REG(hw, E1000_TDH(0), 0);
+       E1000_WRITE_REG(hw, E1000_TDT(0), 0);
+       E1000_WRITE_REG(hw, E1000_TCTL,
                        E1000_TCTL_PSP | E1000_TCTL_EN |
                        E1000_COLLISION_THRESHOLD << E1000_CT_SHIFT |
                        E1000_COLLISION_DISTANCE << E1000_COLD_SHIFT);
@@ -1239,8 +1228,7 @@ static int igb_setup_desc_rings(struct igb_adapter *adapter)
                struct sk_buff *skb;
                unsigned int size = 1024;
 
-               skb = alloc_skb(size, GFP_KERNEL);
-               if (!skb) {
+               if (!(skb = alloc_skb(size, GFP_KERNEL))) {
                        ret_val = 3;
                        goto err_nomem;
                }
@@ -1263,44 +1251,41 @@ static int igb_setup_desc_rings(struct igb_adapter *adapter)
        if (!rx_ring->count)
                rx_ring->count = IGB_DEFAULT_RXD;
 
-       rx_ring->buffer_info = kcalloc(rx_ring->count,
-                                      sizeof(struct igb_buffer),
-                                      GFP_KERNEL);
-       if (!rx_ring->buffer_info) {
+       if (!(rx_ring->buffer_info = kcalloc(rx_ring->count,
+                                            sizeof(struct igb_buffer),
+                                            GFP_KERNEL))) {
                ret_val = 4;
                goto err_nomem;
        }
 
        rx_ring->size = rx_ring->count * sizeof(struct e1000_rx_desc);
-       rx_ring->desc = pci_alloc_consistent(pdev, rx_ring->size,
-                                            &rx_ring->dma);
-       if (!rx_ring->desc) {
+       if (!(rx_ring->desc = pci_alloc_consistent(pdev, rx_ring->size,
+                                                  &rx_ring->dma))) {
                ret_val = 5;
                goto err_nomem;
        }
        rx_ring->next_to_use = rx_ring->next_to_clean = 0;
 
-       rctl = rd32(E1000_RCTL);
-       wr32(E1000_RCTL, rctl & ~E1000_RCTL_EN);
-       wr32(E1000_RDBAL(0),
+       rctl = E1000_READ_REG(hw, E1000_RCTL);
+       E1000_WRITE_REG(hw, E1000_RCTL, rctl & ~E1000_RCTL_EN);
+       E1000_WRITE_REG(hw, E1000_RDBAL(0),
                        ((u64) rx_ring->dma & 0xFFFFFFFF));
-       wr32(E1000_RDBAH(0),
-                       ((u64) rx_ring->dma >> 32));
-       wr32(E1000_RDLEN(0), rx_ring->size);
-       wr32(E1000_RDH(0), 0);
-       wr32(E1000_RDT(0), 0);
+       E1000_WRITE_REG(hw, E1000_RDBAH(0), ((u64) rx_ring->dma >> 32));
+       E1000_WRITE_REG(hw, E1000_RDLEN(0), rx_ring->size);
+       E1000_WRITE_REG(hw, E1000_RDH(0), 0);
+       E1000_WRITE_REG(hw, E1000_RDT(0), 0);
        rctl = E1000_RCTL_EN | E1000_RCTL_BAM | E1000_RCTL_SZ_2048 |
                E1000_RCTL_LBM_NO | E1000_RCTL_RDMTS_HALF |
-               (adapter->hw.mac.mc_filter_type << E1000_RCTL_MO_SHIFT);
-       wr32(E1000_RCTL, rctl);
-       wr32(E1000_SRRCTL(0), 0);
+               (hw->mac.mc_filter_type << E1000_RCTL_MO_SHIFT);
+       E1000_WRITE_REG(hw, E1000_RCTL, rctl);
+       E1000_WRITE_REG(hw, E1000_SRRCTL(0), 0);
 
        for (i = 0; i < rx_ring->count; i++) {
                struct e1000_rx_desc *rx_desc = E1000_RX_DESC(*rx_ring, i);
                struct sk_buff *skb;
 
                skb = alloc_skb(IGB_RXBUFFER_2048 + NET_IP_ALIGN,
-                               GFP_KERNEL);
+                               GFP_KERNEL);
                if (!skb) {
                        ret_val = 6;
                        goto err_nomem;
@@ -1323,13 +1308,11 @@ err_nomem:
 
 static void igb_phy_disable_receiver(struct igb_adapter *adapter)
 {
-       struct e1000_hw *hw = &adapter->hw;
-
        /* Write out to PHY registers 29 and 30 to disable the Receiver. */
-       hw->phy.ops.write_phy_reg(hw, 29, 0x001F);
-       hw->phy.ops.write_phy_reg(hw, 30, 0x8FFC);
-       hw->phy.ops.write_phy_reg(hw, 29, 0x001A);
-       hw->phy.ops.write_phy_reg(hw, 30, 0x8FF0);
+       e1000_write_phy_reg(&adapter->hw, 29, 0x001F);
+       e1000_write_phy_reg(&adapter->hw, 30, 0x8FFC);
+       e1000_write_phy_reg(&adapter->hw, 29, 0x001A);
+       e1000_write_phy_reg(&adapter->hw, 30, 0x8FF0);
 }
 
 static int igb_integrated_phy_loopback(struct igb_adapter *adapter)
@@ -1338,24 +1321,24 @@ static int igb_integrated_phy_loopback(struct igb_adapter *adapter)
        u32 ctrl_reg = 0;
        u32 stat_reg = 0;
 
-       hw->mac.autoneg = false;
+       hw->mac.autoneg = FALSE;
 
        if (hw->phy.type == e1000_phy_m88) {
                /* Auto-MDI/MDIX Off */
-               hw->phy.ops.write_phy_reg(hw, M88E1000_PHY_SPEC_CTRL, 0x0808);
+               e1000_write_phy_reg(hw, M88E1000_PHY_SPEC_CTRL, 0x0808);
                /* reset to update Auto-MDI/MDIX */
-               hw->phy.ops.write_phy_reg(hw, PHY_CONTROL, 0x9140);
+               e1000_write_phy_reg(hw, PHY_CONTROL, 0x9140);
                /* autoneg off */
-               hw->phy.ops.write_phy_reg(hw, PHY_CONTROL, 0x8140);
+               e1000_write_phy_reg(hw, PHY_CONTROL, 0x8140);
        }
 
-       ctrl_reg = rd32(E1000_CTRL);
+       ctrl_reg = E1000_READ_REG(hw, E1000_CTRL);
 
        /* force 1000, set loopback */
-       hw->phy.ops.write_phy_reg(hw, PHY_CONTROL, 0x4140);
+       e1000_write_phy_reg(hw, PHY_CONTROL, 0x4140);
 
        /* Now set up the MAC to the same speed/duplex as the PHY. */
-       ctrl_reg = rd32(E1000_CTRL);
+       ctrl_reg = E1000_READ_REG(hw, E1000_CTRL);
        ctrl_reg &= ~E1000_CTRL_SPD_SEL; /* Clear the speed sel bits */
        ctrl_reg |= (E1000_CTRL_FRCSPD | /* Set the Force Speed Bit */
                     E1000_CTRL_FRCDPX | /* Set the Force Duplex Bit */
@@ -1368,12 +1351,12 @@ static int igb_integrated_phy_loopback(struct igb_adapter *adapter)
        else {
                /* Set the ILOS bit on the fiber Nic if half duplex link is
                 * detected. */
-               stat_reg = rd32(E1000_STATUS);
+               stat_reg = E1000_READ_REG(hw, E1000_STATUS);
                if ((stat_reg & E1000_STATUS_FD) == 0)
                        ctrl_reg |= (E1000_CTRL_ILOS | E1000_CTRL_SLU);
        }
 
-       wr32(E1000_CTRL, ctrl_reg);
+       E1000_WRITE_REG(hw, E1000_CTRL, ctrl_reg);
 
        /* Disable the receiver on the PHY so when a cable is plugged in, the
         * PHY does not begin to autoneg when a cable is reconnected to the NIC.
@@ -1394,13 +1377,40 @@ static int igb_set_phy_loopback(struct igb_adapter *adapter)
 static int igb_setup_loopback_test(struct igb_adapter *adapter)
 {
        struct e1000_hw *hw = &adapter->hw;
-       u32 rctl;
+       u32 reg;
 
        if (hw->phy.media_type == e1000_media_type_fiber ||
            hw->phy.media_type == e1000_media_type_internal_serdes) {
-               rctl = rd32(E1000_RCTL);
-               rctl |= E1000_RCTL_LBM_TCVR;
-               wr32(E1000_RCTL, rctl);
+
+               reg = E1000_READ_REG(hw, E1000_RCTL);
+               reg |= E1000_RCTL_LBM_TCVR;
+               E1000_WRITE_REG(hw, E1000_RCTL, reg);
+
+               E1000_WRITE_REG(hw, E1000_SCTL, E1000_ENABLE_SERDES_LOOPBACK);
+
+               reg = E1000_READ_REG(hw, E1000_CTRL);
+               reg &= ~(E1000_CTRL_RFCE |
+                        E1000_CTRL_TFCE |
+                        E1000_CTRL_LRST);
+               reg |= E1000_CTRL_SLU |
+                      E1000_CTRL_FD;
+               E1000_WRITE_REG(hw, E1000_CTRL, reg);
+
+               /* Unset switch control to serdes energy detect */
+               reg = E1000_READ_REG(hw, E1000_CONNSW);
+               reg &= ~E1000_CONNSW_ENRGSRC;
+               E1000_WRITE_REG(hw, E1000_CONNSW, reg);
+
+               /* Set PCS register for forced speed */
+               reg = E1000_READ_REG(hw, E1000_PCS_LCTL);
+               reg &= ~E1000_PCS_LCTL_AN_ENABLE;     /* Disable Autoneg*/
+               reg |= E1000_PCS_LCTL_FLV_LINK_UP |   /* Force link up */
+                      E1000_PCS_LCTL_FSV_1000 |      /* Force 1000    */
+                      E1000_PCS_LCTL_FDV_FULL |      /* SerDes Full duplex */
+                      E1000_PCS_LCTL_FSD |           /* Force Speed */
+                      E1000_PCS_LCTL_FORCE_LINK;     /* Force Link */
+               E1000_WRITE_REG(hw, E1000_PCS_LCTL, reg);
+
                return 0;
        } else if (hw->phy.media_type == e1000_media_type_copper) {
                return igb_set_phy_loopback(adapter);
@@ -1415,21 +1425,21 @@ static void igb_loopback_cleanup(struct igb_adapter *adapter)
        u32 rctl;
        u16 phy_reg;
 
-       rctl = rd32(E1000_RCTL);
+       rctl = E1000_READ_REG(hw, E1000_RCTL);
        rctl &= ~(E1000_RCTL_LBM_TCVR | E1000_RCTL_LBM_MAC);
-       wr32(E1000_RCTL, rctl);
+       E1000_WRITE_REG(hw, E1000_RCTL, rctl);
 
-       hw->mac.autoneg = true;
-       hw->phy.ops.read_phy_reg(hw, PHY_CONTROL, &phy_reg);
+       hw->mac.autoneg = TRUE;
+       e1000_read_phy_reg(hw, PHY_CONTROL, &phy_reg);
        if (phy_reg & MII_CR_LOOPBACK) {
                phy_reg &= ~MII_CR_LOOPBACK;
-               hw->phy.ops.write_phy_reg(hw, PHY_CONTROL, phy_reg);
-               igb_phy_sw_reset(hw);
+               e1000_write_phy_reg(hw, PHY_CONTROL, phy_reg);
+               e1000_phy_commit(hw);
        }
 }
 
 static void igb_create_lbtest_frame(struct sk_buff *skb,
-                                   unsigned int frame_size)
+                                    unsigned int frame_size)
 {
        memset(skb->data, 0xFF, frame_size);
        frame_size &= ~1;
@@ -1441,10 +1451,12 @@ static void igb_create_lbtest_frame(struct sk_buff *skb,
 static int igb_check_lbtest_frame(struct sk_buff *skb, unsigned int frame_size)
 {
        frame_size &= ~1;
-       if (*(skb->data + 3) == 0xFF)
+       if (*(skb->data + 3) == 0xFF) {
                if ((*(skb->data + frame_size / 2 + 10) == 0xBE) &&
-                  (*(skb->data + frame_size / 2 + 12) == 0xAF))
+                  (*(skb->data + frame_size / 2 + 12) == 0xAF)) {
                        return 0;
+               }
+       }
        return 13;
 }
 
@@ -1454,11 +1466,10 @@ static int igb_run_loopback_test(struct igb_adapter *adapter)
        struct igb_ring *tx_ring = &adapter->test_tx_ring;
        struct igb_ring *rx_ring = &adapter->test_rx_ring;
        struct pci_dev *pdev = adapter->pdev;
-       int i, j, k, l, lc, good_cnt;
-       int ret_val = 0;
+       int i, j, k, l, lc, good_cnt, ret_val=0;
        unsigned long time;
 
-       wr32(E1000_RDT(0), rx_ring->count - 1);
+       E1000_WRITE_REG(hw, E1000_RDT(0), rx_ring->count - 1);
 
        /* Calculate the loop count based on the largest descriptor ring
         * The idea is to wrap the largest ring a number of times using 64
@@ -1474,32 +1485,29 @@ static int igb_run_loopback_test(struct igb_adapter *adapter)
        for (j = 0; j <= lc; j++) { /* loop count loop */
                for (i = 0; i < 64; i++) { /* send the packets */
                        igb_create_lbtest_frame(tx_ring->buffer_info[k].skb,
-                                               1024);
+                                               1024);
                        pci_dma_sync_single_for_device(pdev,
                                tx_ring->buffer_info[k].dma,
                                tx_ring->buffer_info[k].length,
                                PCI_DMA_TODEVICE);
-                       k++;
-                       if (k == tx_ring->count)
-                               k = 0;
+                       if (unlikely(++k == tx_ring->count)) k = 0;
                }
-               wr32(E1000_TDT(0), k);
+               E1000_WRITE_REG(hw, E1000_TDT(0), k);
                msleep(200);
+
                time = jiffies; /* set the start time for the receive */
                good_cnt = 0;
                do { /* receive the sent packets */
                        pci_dma_sync_single_for_cpu(pdev,
-                                       rx_ring->buffer_info[l].dma,
-                                       IGB_RXBUFFER_2048,
-                                       PCI_DMA_FROMDEVICE);
+                                       rx_ring->buffer_info[l].dma,
+                                       IGB_RXBUFFER_2048,
+                                       PCI_DMA_FROMDEVICE);
 
                        ret_val = igb_check_lbtest_frame(
-                                            rx_ring->buffer_info[l].skb, 1024);
+                                            rx_ring->buffer_info[l].skb, 1024);
                        if (!ret_val)
                                good_cnt++;
-                       l++;
-                       if (l == rx_ring->count)
-                               l = 0;
+                       if (unlikely(++l == rx_ring->count)) l = 0;
                        /* time + 20 msecs (200 msecs on 2.4) is more than
                         * enough time to complete the receives, if it's
                         * exceeded, break and error off
@@ -1521,10 +1529,9 @@ static int igb_loopback_test(struct igb_adapter *adapter, u64 *data)
 {
        /* PHY loopback cannot be performed if SoL/IDER
         * sessions are active */
-       if (igb_check_reset_block(&adapter->hw)) {
-               dev_err(&adapter->pdev->dev,
-                       "Cannot do PHY loopback test "
-                       "when SoL/IDER is active.\n");
+       if (e1000_check_reset_block(&adapter->hw)) {
+               DPRINTK(DRV, ERR, "Cannot do PHY loopback test "
+                       "when SoL/IDER is active.\n");
                *data = 0;
                goto out;
        }
@@ -1547,34 +1554,38 @@ static int igb_link_test(struct igb_adapter *adapter, u64 *data)
 {
        struct e1000_hw *hw = &adapter->hw;
        *data = 0;
-       if (hw->phy.media_type == e1000_media_type_internal_serdes) {
+       if (adapter->hw.phy.media_type == e1000_media_type_internal_serdes) {
                int i = 0;
-               hw->mac.serdes_has_link = false;
+               adapter->hw.mac.serdes_has_link = FALSE;
 
                /* On some blade server designs, link establishment
                 * could take as long as 2-3 minutes */
                do {
-                       hw->mac.ops.check_for_link(&adapter->hw);
-                       if (hw->mac.serdes_has_link)
+                       e1000_check_for_link(&adapter->hw);
+                       if (adapter->hw.mac.serdes_has_link)
                                return *data;
                        msleep(20);
                } while (i++ < 3750);
 
                *data = 1;
        } else {
-               hw->mac.ops.check_for_link(&adapter->hw);
-               if (hw->mac.autoneg)
+               e1000_check_for_link(&adapter->hw);
+               if (adapter->hw.mac.autoneg)
                        msleep(4000);
 
-               if (!(rd32(E1000_STATUS) &
-                     E1000_STATUS_LU))
+               if (!(E1000_READ_REG(hw, E1000_STATUS) & E1000_STATUS_LU))
                        *data = 1;
        }
        return *data;
 }
 
+static int igb_diag_test_count(struct net_device *netdev)
+{
+       return IGB_TEST_LEN;
+}
+
 static void igb_diag_test(struct net_device *netdev,
-                         struct ethtool_test *eth_test, u64 *data)
+                          struct ethtool_test *eth_test, u64 *data)
 {
        struct igb_adapter *adapter = netdev_priv(netdev);
        u16 autoneg_advertised;
@@ -1590,7 +1601,7 @@ static void igb_diag_test(struct net_device *netdev,
                forced_speed_duplex = adapter->hw.mac.forced_speed_duplex;
                autoneg = adapter->hw.mac.autoneg;
 
-               dev_info(&adapter->pdev->dev, "offline testing starting\n");
+               DPRINTK(HW, INFO, "offline testing starting\n");
 
                /* Link test performed before hardware reset so autoneg doesn't
                 * interfere with test result */
@@ -1624,15 +1635,15 @@ static void igb_diag_test(struct net_device *netdev,
                adapter->hw.mac.autoneg = autoneg;
 
                /* force this routine to wait until autoneg complete/timeout */
-               adapter->hw.phy.autoneg_wait_to_complete = true;
+               adapter->hw.phy.autoneg_wait_to_complete = TRUE;
                igb_reset(adapter);
-               adapter->hw.phy.autoneg_wait_to_complete = false;
+               adapter->hw.phy.autoneg_wait_to_complete = FALSE;
 
                clear_bit(__IGB_TESTING, &adapter->state);
                if (if_running)
                        dev_open(netdev);
        } else {
-               dev_info(&adapter->pdev->dev, "online testing starting\n");
+               DPRINTK(HW, INFO, "online testing starting\n");
                /* Online tests */
                if (igb_link_test(adapter, &data[4]))
                        eth_test->flags |= ETH_TEST_FL_FAILED;
@@ -1649,7 +1660,7 @@ static void igb_diag_test(struct net_device *netdev,
 }
 
 static int igb_wol_exclusion(struct igb_adapter *adapter,
-                            struct ethtool_wolinfo *wol)
+                             struct ethtool_wolinfo *wol)
 {
        struct e1000_hw *hw = &adapter->hw;
        int retval = 1; /* fail by default */
@@ -1660,8 +1671,10 @@ static int igb_wol_exclusion(struct igb_adapter *adapter,
                wol->supported = 0;
                break;
        case E1000_DEV_ID_82575EB_FIBER_SERDES:
+       case E1000_DEV_ID_82576_FIBER:
+       case E1000_DEV_ID_82576_SERDES:
                /* Wake events not supported on port B */
-               if (rd32(E1000_STATUS) & E1000_STATUS_FUNC_1) {
+               if (E1000_READ_REG(hw, E1000_STATUS) & E1000_STATUS_FUNC_1) {
                        wol->supported = 0;
                        break;
                }
@@ -1672,7 +1685,7 @@ static int igb_wol_exclusion(struct igb_adapter *adapter,
                /* dual port cards only support WoL on port A from now on
                 * unless it was enabled in the eeprom for port B
                 * so exclude FUNC_1 ports from having WoL enabled */
-               if (rd32(E1000_STATUS) & E1000_STATUS_FUNC_1 &&
+               if (E1000_READ_REG(hw, E1000_STATUS) & E1000_STATUS_FUNC_1 &&
                    !adapter->eeprom_wol) {
                        wol->supported = 0;
                        break;
@@ -1689,7 +1702,7 @@ static void igb_get_wol(struct net_device *netdev, struct ethtool_wolinfo *wol)
        struct igb_adapter *adapter = netdev_priv(netdev);
 
        wol->supported = WAKE_UCAST | WAKE_MCAST |
-                        WAKE_BCAST | WAKE_MAGIC;
+                        WAKE_BCAST | WAKE_MAGIC;
        wol->wolopts = 0;
 
        /* this function will set ->supported = 0 and return 1 if wol is not
@@ -1760,12 +1773,12 @@ static int igb_phys_id(struct net_device *netdev, u32 data)
        if (!data || data > (u32)(MAX_SCHEDULE_TIMEOUT / HZ))
                data = (u32)(MAX_SCHEDULE_TIMEOUT / HZ);
 
-       igb_blink_led(hw);
+       e1000_blink_led(hw);
        msleep_interruptible(data * 1000);
 
-       igb_led_off(hw);
+       e1000_led_off(hw);
        clear_bit(IGB_LED_ON, &adapter->led_status);
-       igb_cleanup_led(hw);
+       e1000_cleanup_led(hw);
 
        return 0;
 }
@@ -1774,6 +1787,8 @@ static int igb_set_coalesce(struct net_device *netdev,
                            struct ethtool_coalesce *ec)
 {
        struct igb_adapter *adapter = netdev_priv(netdev);
+       struct e1000_hw *hw = &adapter->hw;
+       int i;
 
        if ((ec->rx_coalesce_usecs > IGB_MAX_ITR_USECS) ||
            ((ec->rx_coalesce_usecs > 3) &&
@@ -1782,13 +1797,17 @@ static int igb_set_coalesce(struct net_device *netdev,
                return -EINVAL;
 
        /* convert to rate of irq's per second */
-       if (ec->rx_coalesce_usecs <= 3)
+       if (ec->rx_coalesce_usecs && ec->rx_coalesce_usecs <= 3) {
+               adapter->itr = IGB_START_ITR;
                adapter->itr_setting = ec->rx_coalesce_usecs;
-       else
-               adapter->itr_setting = (1000000 / ec->rx_coalesce_usecs);
+       } else {
+               adapter->itr = ec->rx_coalesce_usecs << 2;
+               adapter->itr_setting = adapter->itr;
+       }
 
-       if (netif_running(netdev))
-               igb_reinit_locked(adapter);
+       for (i = 0; i < adapter->num_rx_queues; i++)
+               writel(adapter->itr,
+                      hw->hw_addr + adapter->rx_ring[i].itr_register);
 
        return 0;
 }
@@ -1801,12 +1820,11 @@ static int igb_get_coalesce(struct net_device *netdev,
        if (adapter->itr_setting <= 3)
                ec->rx_coalesce_usecs = adapter->itr_setting;
        else
-               ec->rx_coalesce_usecs = 1000000 / adapter->itr_setting;
+               ec->rx_coalesce_usecs = adapter->itr_setting >> 2;
 
        return 0;
 }
 
-
 static int igb_nway_reset(struct net_device *netdev)
 {
        struct igb_adapter *adapter = netdev_priv(netdev);
@@ -1821,20 +1839,40 @@ static int igb_get_stats_count(struct net_device *netdev)
 }
 
 static void igb_get_ethtool_stats(struct net_device *netdev,
-                                 struct ethtool_stats *stats, u64 *data)
+                                  struct ethtool_stats *stats, u64 *data)
 {
        struct igb_adapter *adapter = netdev_priv(netdev);
        u64 *queue_stat;
        int stat_count = sizeof(struct igb_queue_stats) / sizeof(u64);
        int j;
        int i;
+#ifdef IGB_LRO
+       int aggregated = 0, flushed = 0, no_desc = 0;
+
+       for (i = 0; i < adapter->num_rx_queues; i++) {
+               aggregated += adapter->rx_ring[i].lro_mgr.stats.aggregated;
+               flushed += adapter->rx_ring[i].lro_mgr.stats.flushed;
+               no_desc += adapter->rx_ring[i].lro_mgr.stats.no_desc;
+       }
+       adapter->lro_aggregated = aggregated;
+       adapter->lro_flushed = flushed;
+       adapter->lro_no_desc = no_desc;
+#endif
 
        igb_update_stats(adapter);
+
        for (i = 0; i < IGB_GLOBAL_STATS_LEN; i++) {
                char *p = (char *)adapter+igb_gstrings_stats[i].stat_offset;
                data[i] = (igb_gstrings_stats[i].sizeof_stat ==
                        sizeof(u64)) ? *(u64 *)p : *(u32 *)p;
        }
+       for (j = 0; j < adapter->num_tx_queues; j++) {
+               int k;
+               queue_stat = (u64 *)&adapter->tx_ring[j].tx_stats;
+               for (k = 0; k < stat_count; k++)
+                       data[i + k] = queue_stat[k];
+               i += k;
+       }
        for (j = 0; j < adapter->num_rx_queues; j++) {
                int k;
                queue_stat = (u64 *)&adapter->rx_ring[j].rx_stats;
@@ -1903,13 +1941,19 @@ static struct ethtool_ops igb_ethtool_ops = {
        .set_tx_csum            = igb_set_tx_csum,
        .get_sg                 = ethtool_op_get_sg,
        .set_sg                 = ethtool_op_set_sg,
+#ifdef NETIF_F_TSO
        .get_tso                = ethtool_op_get_tso,
        .set_tso                = igb_set_tso,
+#endif
+       .self_test_count        = igb_diag_test_count,
        .self_test              = igb_diag_test,
        .get_strings            = igb_get_strings,
        .phys_id                = igb_phys_id,
        .get_stats_count        = igb_get_stats_count,
        .get_ethtool_stats      = igb_get_ethtool_stats,
+#ifdef ETHTOOL_GPERMADDR
+       .get_perm_addr          = ethtool_op_get_perm_addr,
+#endif
        .get_coalesce           = igb_get_coalesce,
        .set_coalesce           = igb_set_coalesce,
 };
@@ -1918,3 +1962,4 @@ void igb_set_ethtool_ops(struct net_device *netdev)
 {
        SET_ETHTOOL_OPS(netdev, &igb_ethtool_ops);
 }
+#endif /* SIOCETHTOOL */
index 02b9634f4543a00c8289b4a7f456c799d30ea948..f6a2904bb71d51ac2dd57c8f4b736e246e523975 100644 (file)
@@ -1,7 +1,7 @@
 /*******************************************************************************
 
   Intel(R) Gigabit Ethernet Linux driver
-  Copyright(c) 2007 Intel Corporation.
+  Copyright(c) 2007-2008 Intel Corporation.
 
   This program is free software; you can redistribute it and/or modify it
   under the terms and conditions of the GNU General Public License,
 #include <linux/pagemap.h>
 #include <linux/netdevice.h>
 #include <linux/tcp.h>
-#include <linux/ipv6.h>
+#ifdef NETIF_F_TSO
 #include <net/checksum.h>
+#ifdef NETIF_F_TSO6
+#include <linux/ipv6.h>
 #include <net/ip6_checksum.h>
+#endif
+#endif
+#ifdef SIOCGMIIPHY
 #include <linux/mii.h>
+#endif
+#ifdef SIOCETHTOOL
 #include <linux/ethtool.h>
+#endif
 #include <linux/if_vlan.h>
-#include <linux/pci.h>
-#include <linux/delay.h>
-#include <linux/interrupt.h>
-#include <linux/if_ether.h>
 
 #include "igb.h"
 
-#define DRV_VERSION "1.0.8-k2"
+
+#if defined(DEBUG) || defined (DEBUG_DUMP) || defined (DEBUG_ICR) || \
+    defined(DEBUG_ITR)
+#define DRV_DEBUG "_debug"
+#else
+#define DRV_DEBUG
+#endif
+#define DRV_HW_PERF
+
+#define DRV_VERSION "1.3.8.6" DRV_DEBUG DRV_HW_PERF
+
 char igb_driver_name[] = "igb";
 char igb_driver_version[] = DRV_VERSION;
 static const char igb_driver_string[] =
-                               "Intel(R) Gigabit Ethernet Network Driver";
-static const char igb_copyright[] = "Copyright (c) 2007 Intel Corporation.";
-
-
-static const struct e1000_info *igb_info_tbl[] = {
-       [board_82575] = &e1000_82575_info,
-};
+                                "Intel(R) Gigabit Ethernet Network Driver";
+static const char igb_copyright[] = "Copyright (c) 2007-2008 Intel Corporation.";
 
 static struct pci_device_id igb_pci_tbl[] = {
-       { PCI_VDEVICE(INTEL, E1000_DEV_ID_82575EB_COPPER), board_82575 },
-       { PCI_VDEVICE(INTEL, E1000_DEV_ID_82575EB_FIBER_SERDES), board_82575 },
-       { PCI_VDEVICE(INTEL, E1000_DEV_ID_82575GB_QUAD_COPPER), board_82575 },
+       { PCI_VDEVICE(INTEL, E1000_DEV_ID_82576) },
+       { PCI_VDEVICE(INTEL, E1000_DEV_ID_82576_FIBER) },
+       { PCI_VDEVICE(INTEL, E1000_DEV_ID_82576_SERDES) },
+       { PCI_VDEVICE(INTEL, E1000_DEV_ID_82575EB_COPPER) },
+       { PCI_VDEVICE(INTEL, E1000_DEV_ID_82575EB_FIBER_SERDES) },
+       { PCI_VDEVICE(INTEL, E1000_DEV_ID_82575GB_QUAD_COPPER) },
        /* required last entry */
        {0, }
 };
@@ -72,8 +84,6 @@ static int igb_setup_all_tx_resources(struct igb_adapter *);
 static int igb_setup_all_rx_resources(struct igb_adapter *);
 static void igb_free_all_tx_resources(struct igb_adapter *);
 static void igb_free_all_rx_resources(struct igb_adapter *);
-static void igb_free_tx_resources(struct igb_adapter *, struct igb_ring *);
-static void igb_free_rx_resources(struct igb_adapter *, struct igb_ring *);
 void igb_update_stats(struct igb_adapter *);
 static int igb_probe(struct pci_dev *, const struct pci_device_id *);
 static void __devexit igb_remove(struct pci_dev *pdev);
@@ -85,33 +95,41 @@ static void igb_configure_rx(struct igb_adapter *);
 static void igb_setup_rctl(struct igb_adapter *);
 static void igb_clean_all_tx_rings(struct igb_adapter *);
 static void igb_clean_all_rx_rings(struct igb_adapter *);
-static void igb_clean_tx_ring(struct igb_adapter *, struct igb_ring *);
-static void igb_clean_rx_ring(struct igb_adapter *, struct igb_ring *);
+static void igb_clean_tx_ring(struct igb_ring *);
+static void igb_clean_rx_ring(struct igb_ring *);
 static void igb_set_multi(struct net_device *);
 static void igb_update_phy_info(unsigned long);
 static void igb_watchdog(unsigned long);
-static void igb_watchdog_task(struct igb_adapter *);
+static void igb_watchdog_task(struct work_struct *);
 static int igb_xmit_frame_ring_adv(struct sk_buff *, struct net_device *,
-                                 struct igb_ring *);
+                                 struct igb_ring *);
 static int igb_xmit_frame_adv(struct sk_buff *skb, struct net_device *);
-static struct net_device_stats *igb_get_stats(struct net_device *);
+static struct net_device_stats * igb_get_stats(struct net_device *);
 static int igb_change_mtu(struct net_device *, int);
 static int igb_set_mac(struct net_device *, void *);
-static irqreturn_t igb_intr(int irq, void *, struct pt_regs *);
-static irqreturn_t igb_intr_msi(int irq, void *, struct pt_regs *);
-static irqreturn_t igb_msix_other(int irq, void *, struct pt_regs *);
-static irqreturn_t igb_msix_rx(int irq, void *, struct pt_regs *);
-static irqreturn_t igb_msix_tx(int irq, void *, struct pt_regs *);
-static int igb_clean_rx_ring_msix(struct net_device *, int *);
-static bool igb_clean_tx_irq(struct igb_adapter *, struct igb_ring *);
-static int igb_clean(struct net_device *, int *);
-static bool igb_clean_rx_irq_adv(struct igb_adapter *,
-                                struct igb_ring *, int *, int);
-static void igb_alloc_rx_buffers_adv(struct igb_adapter *,
-                                    struct igb_ring *, int);
+static irqreturn_t igb_intr(int irq, void *);
+static irqreturn_t igb_intr_msi(int irq, void *);
+static irqreturn_t igb_msix_other(int irq, void *);
+static irqreturn_t igb_msix_rx(int irq, void *);
+#ifdef CONFIG_IGB_SEPARATE_TX_HANDLER
+static irqreturn_t igb_msix_tx(int irq, void *);
+#endif
+static int igb_clean_rx_ring_msix(struct napi_struct *, int);
+#ifdef IGB_DCA
+static void igb_update_rx_dca(struct igb_ring *);
+static void igb_update_tx_dca(struct igb_ring *);
+static void igb_setup_dca(struct igb_adapter *);
+#endif /* IGB_DCA */
+static bool igb_clean_tx_irq(struct igb_ring *);
+static int igb_poll(struct napi_struct *, int);
+static bool igb_clean_rx_irq_adv(struct igb_ring *, int *, int);
+static void igb_alloc_rx_buffers_adv(struct igb_ring *, int);
+#ifdef IGB_LRO
+static int igb_get_skb_hdr(struct sk_buff *skb, void **, void **, u64 *, void *);
+#endif
 static int igb_ioctl(struct net_device *, struct ifreq *, int cmd);
 static void igb_tx_timeout(struct net_device *);
-static void igb_reset_task(struct igb_adapter *);
+static void igb_reset_task(struct work_struct *);
 static void igb_vlan_rx_register(struct net_device *, struct vlan_group *);
 static void igb_vlan_rx_add_vid(struct net_device *, u16);
 static void igb_vlan_rx_kill_vid(struct net_device *, u16);
@@ -121,15 +139,33 @@ static int igb_suspend(struct pci_dev *, pm_message_t);
 #ifdef CONFIG_PM
 static int igb_resume(struct pci_dev *);
 #endif
+#ifndef USE_REBOOT_NOTIFIER
 static void igb_shutdown(struct pci_dev *);
+#else
+static int igb_notify_reboot(struct notifier_block *, unsigned long, void *);
+static struct notifier_block igb_notifier_reboot = {
+       .notifier_call  = igb_notify_reboot,
+       .next           = NULL,
+       .priority       = 0
+};
+#endif
+#ifdef IGB_DCA
+static int igb_notify_dca(struct notifier_block *, unsigned long, void *);
+static struct notifier_block dca_notifier = {
+       .notifier_call  = igb_notify_dca,
+       .next           = NULL,
+       .priority       = 0
+};
+#endif
 
 #ifdef CONFIG_NET_POLL_CONTROLLER
 /* for netdump / net console */
-static void igb_netpoll(struct net_device *);
+static void igb_netpoll (struct net_device *);
 #endif
 
+#ifdef HAVE_PCI_ERS
 static pci_ers_result_t igb_io_error_detected(struct pci_dev *,
-                    pci_channel_state_t);
+                     pci_channel_state_t);
 static pci_ers_result_t igb_io_slot_reset(struct pci_dev *);
 static void igb_io_resume(struct pci_dev *);
 
@@ -138,6 +174,7 @@ static struct pci_error_handlers igb_err_handler = {
        .slot_reset = igb_io_slot_reset,
        .resume = igb_io_resume,
 };
+#endif
 
 
 static struct pci_driver igb_driver = {
@@ -150,8 +187,12 @@ static struct pci_driver igb_driver = {
        .suspend  = igb_suspend,
        .resume   = igb_resume,
 #endif
+#ifndef USE_REBOOT_NOTIFIER
        .shutdown = igb_shutdown,
+#endif
+#ifdef HAVE_PCI_ERS
        .err_handler = &igb_err_handler
+#endif
 };
 
 MODULE_AUTHOR("Intel Corporation, <e1000-devel@lists.sourceforge.net>");
@@ -159,17 +200,9 @@ MODULE_DESCRIPTION("Intel(R) Gigabit Ethernet Network Driver");
 MODULE_LICENSE("GPL");
 MODULE_VERSION(DRV_VERSION);
 
-#ifdef DEBUG
-/**
- * igb_get_hw_dev_name - return device name string
- * used by hardware layer to print debugging information
- **/
-char *igb_get_hw_dev_name(struct e1000_hw *hw)
-{
-       struct igb_adapter *adapter = hw->back;
-       return adapter->netdev->name;
-}
-#endif
+static int debug = NETIF_MSG_DRV | NETIF_MSG_PROBE;
+module_param(debug, int, 0);
+MODULE_PARM_DESC(debug, "Debug level (0=none, ..., 16=all)");
 
 /**
  * igb_init_module - Driver Registration Routine
@@ -177,15 +210,26 @@ char *igb_get_hw_dev_name(struct e1000_hw *hw)
  * igb_init_module is the first routine called when the driver is
  * loaded. All it does is register with the PCI subsystem.
  **/
+
 static int __init igb_init_module(void)
 {
        int ret;
+
+
        printk(KERN_INFO "%s - version %s\n",
               igb_driver_string, igb_driver_version);
 
        printk(KERN_INFO "%s\n", igb_copyright);
 
        ret = pci_register_driver(&igb_driver);
+#ifdef USE_REBOOT_NOTIFIER
+       if (ret >= 0) {
+               register_reboot_notifier(&igb_notifier_reboot);
+       }
+#endif
+#ifdef IGB_DCA
+       dca_register_notify(&dca_notifier);
+#endif
        return ret;
 }
 
@@ -197,8 +241,15 @@ module_init(igb_init_module);
  * igb_exit_module is called just before the driver is removed
  * from memory.
  **/
+
 static void __exit igb_exit_module(void)
 {
+#ifdef IGB_DCA
+       dca_unregister_notify(&dca_notifier);
+#endif
+#ifdef USE_REBOOT_NOTIFIER
+       unregister_reboot_notifier(&igb_notifier_reboot);
+#endif
        pci_unregister_driver(&igb_driver);
 }
 
@@ -211,58 +262,104 @@ module_exit(igb_exit_module);
  * We allocate one ring per queue at run-time since we don't know the
  * number of queues at compile-time.
  **/
+
 static int igb_alloc_queues(struct igb_adapter *adapter)
 {
        int i;
 
        adapter->tx_ring = kcalloc(adapter->num_tx_queues,
-                                  sizeof(struct igb_ring), GFP_KERNEL);
+                                  sizeof(struct igb_ring), GFP_KERNEL);
        if (!adapter->tx_ring)
-               return -ENOMEM;
+               goto err;
 
        adapter->rx_ring = kcalloc(adapter->num_rx_queues,
-                                  sizeof(struct igb_ring), GFP_KERNEL);
-       if (!adapter->rx_ring) {
-               kfree(adapter->tx_ring);
-               return -ENOMEM;
-       }
+                                  sizeof(struct igb_ring), GFP_KERNEL);
+       if (!adapter->rx_ring)
+               goto err;
 
+       adapter->rx_ring->buddy = adapter->tx_ring;
 
+       for (i = 0; i < adapter->num_tx_queues; i++) {
+               struct igb_ring *ring = &(adapter->tx_ring[i]);
+               ring->count = adapter->tx_ring_count;
+               ring->adapter = adapter;
+               ring->queue_index = i;
+       }
        for (i = 0; i < adapter->num_rx_queues; i++) {
                struct igb_ring *ring = &(adapter->rx_ring[i]);
+               ring->count = adapter->rx_ring_count;
                ring->adapter = adapter;
+               ring->queue_index = i;
                ring->itr_register = E1000_ITR;
-
-               ring->netdev = kzalloc(sizeof(struct net_device), GFP_KERNEL);
-               if (!ring->netdev)
-                       goto err;
-
-               ring->netdev->priv = (void *)ring;
-               ring->netdev->poll = igb_clean;
-               ring->netdev->weight = adapter->netdev->weight /
-                                      adapter->num_rx_queues;
-               dev_hold(ring->netdev);
-               set_bit(__LINK_STATE_START, &ring->netdev->state);
+               /* set a default napi handler for each rx_ring */
+               netif_napi_add(adapter->netdev, &ring->napi, igb_poll, 64);
        }
-        return 0;
+       return E1000_SUCCESS;
 
 err:
-       for (i = 0; i < adapter->num_rx_queues; i++) {
-               struct igb_ring *ring = &(adapter->rx_ring[i]);
-               kfree(ring->netdev);
-       }
+       kfree(adapter->tx_ring);
        kfree(adapter->rx_ring);
+       return -ENOMEM;
+}
+
+static void igb_free_queues(struct igb_adapter *adapter)
+{
+       int i;
+
+       for (i = 0; i < adapter->num_rx_queues; i++)
+               netif_napi_del(&adapter->rx_ring[i].napi);
+
        kfree(adapter->tx_ring);
-return -ENOMEM;
+       kfree(adapter->rx_ring);
+}
+
+static void igb_configure_lli(struct igb_adapter *adapter)
+{
+       struct e1000_hw *hw = &adapter->hw;
+       u16 port;
+
+       /* LLI should only be enabled for MSI-X or MSI interrupts */
+       if (!adapter->msix_entries && !(adapter->flags & IGB_FLAG_HAS_MSI))
+               return;
+
+       if (adapter->lli_port) {
+               /* use filter 0 for port */
+               port = ntohs((u16)adapter->lli_port);
+               E1000_WRITE_REG(hw, E1000_IMIR(0),
+                       (port | E1000_IMIR_PORT_IM_EN));
+               E1000_WRITE_REG(hw, E1000_IMIREXT(0),
+                       (E1000_IMIREXT_SIZE_BP | E1000_IMIREXT_CTRL_BP));
+       }
+
+       if (adapter->flags & IGB_FLAG_LLI_PUSH) {
+               /* use filter 1 for push flag */
+               E1000_WRITE_REG(hw, E1000_IMIR(1),
+                       (E1000_IMIR_PORT_BP | E1000_IMIR_PORT_IM_EN));
+               E1000_WRITE_REG(hw, E1000_IMIREXT(1),
+                       (E1000_IMIREXT_SIZE_BP | E1000_IMIREXT_CTRL_PSH));
+       }
+
+       if (adapter->lli_size) {
+               /* use filter 2 for size */
+               E1000_WRITE_REG(hw, E1000_IMIR(2),
+                       (E1000_IMIR_PORT_BP | E1000_IMIR_PORT_IM_EN));
+               E1000_WRITE_REG(hw, E1000_IMIREXT(2),
+                       (adapter->lli_size | E1000_IMIREXT_CTRL_BP));
+       }
 
 }
 
 #define IGB_N0_QUEUE -1
+
 static void igb_assign_vector(struct igb_adapter *adapter, int rx_queue,
-                             int tx_queue, int msix_vector)
+                              int tx_queue, int msix_vector)
 {
        u32 msixbm = 0;
        struct e1000_hw *hw = &adapter->hw;
+       u32 ivar, index;
+
+       switch (hw->mac.type) {
+       case e1000_82575:
                /* The 82575 assigns vectors using a bitmask, which matches the
                   bitmask for the EICR/EIMS/EIMC registers.  To assign one
                   or more queues to a vector, we write the appropriate bits
@@ -274,9 +371,50 @@ static void igb_assign_vector(struct igb_adapter *adapter, int rx_queue,
                if (tx_queue > IGB_N0_QUEUE) {
                        msixbm |= E1000_EICR_TX_QUEUE0 << tx_queue;
                        adapter->tx_ring[tx_queue].eims_value =
-                                 E1000_EICR_TX_QUEUE0 << tx_queue;
+                                 E1000_EICR_TX_QUEUE0 << tx_queue;
+               }
+               E1000_WRITE_REG_ARRAY(hw, E1000_MSIXBM(0), msix_vector, msixbm);
+               break;
+       case e1000_82576:
+               /* 82576 uses a table-based method for assigning vectors.
+                  Each queue has a single entry in the table to which we write
+                  a vector number along with a "valid" bit.  Sadly, the layout
+                  of the table is somewhat counterintuitive. */
+               if (rx_queue > IGB_N0_QUEUE) {
+                       index = (rx_queue & 0x7);
+                       ivar = E1000_READ_REG_ARRAY(hw, E1000_IVAR0, index);
+                       if (rx_queue < 8) {
+                               /* vector goes into low byte of register */
+                               ivar = ivar & 0xFFFFFF00;
+                               ivar |= msix_vector | E1000_IVAR_VALID;
+                       } else {
+                               /* vector goes into third byte of register */
+                               ivar = ivar & 0xFF00FFFF;
+                               ivar |= (msix_vector | E1000_IVAR_VALID) << 16;
+                       }
+                       adapter->rx_ring[rx_queue].eims_value= 1 << msix_vector;
+                       E1000_WRITE_REG_ARRAY(hw, E1000_IVAR0, index, ivar);
+               }
+               if (tx_queue > IGB_N0_QUEUE) {
+                       index = (tx_queue & 0x7);
+                       ivar = E1000_READ_REG_ARRAY(hw, E1000_IVAR0, index);
+                       if (tx_queue < 8) {
+                               /* vector goes into second byte of register */
+                               ivar = ivar & 0xFFFF00FF;
+                               ivar |= (msix_vector | E1000_IVAR_VALID) << 8;
+                       } else {
+                               /* vector goes into high byte of register */
+                               ivar = ivar & 0x00FFFFFF;
+                               ivar |= (msix_vector | E1000_IVAR_VALID) << 24;
+                       }
+                       adapter->tx_ring[tx_queue].eims_value= 1 << msix_vector;
+                       E1000_WRITE_REG_ARRAY(hw, E1000_IVAR0, index, ivar);
                }
-               array_wr32(E1000_MSIXBM(0), msix_vector, msixbm);
+               break;
+       default:
+               BUG();
+               break;
+       }
 }
 
 /**
@@ -292,13 +430,20 @@ static void igb_configure_msix(struct igb_adapter *adapter)
        struct e1000_hw *hw = &adapter->hw;
 
        adapter->eims_enable_mask = 0;
-
+       if (hw->mac.type == e1000_82576)
+               /* Turn on MSI-X capability first, or our settings
+                * won't stick.  And it will take days to debug. */
+               E1000_WRITE_REG(hw, E1000_GPIE, E1000_GPIE_MSIX_MODE |
+                                  E1000_GPIE_PBA | E1000_GPIE_EIAME |
+                                  E1000_GPIE_NSICR);
+
+#ifdef CONFIG_IGB_SEPARATE_TX_HANDLER
        for (i = 0; i < adapter->num_tx_queues; i++) {
                struct igb_ring *tx_ring = &adapter->tx_ring[i];
                igb_assign_vector(adapter, IGB_N0_QUEUE, i, vector++);
                adapter->eims_enable_mask |= tx_ring->eims_value;
                if (tx_ring->itr_val)
-                       writel(1000000000 / (tx_ring->itr_val * 256),
+                       writel(tx_ring->itr_val,
                               hw->hw_addr + tx_ring->itr_register);
                else
                        writel(1, hw->hw_addr + tx_ring->itr_register);
@@ -306,24 +451,44 @@ static void igb_configure_msix(struct igb_adapter *adapter)
 
        for (i = 0; i < adapter->num_rx_queues; i++) {
                struct igb_ring *rx_ring = &adapter->rx_ring[i];
+               rx_ring->buddy = NULL;
                igb_assign_vector(adapter, i, IGB_N0_QUEUE, vector++);
                adapter->eims_enable_mask |= rx_ring->eims_value;
                if (rx_ring->itr_val)
-                       writel(1000000000 / (rx_ring->itr_val * 256),
+                       writel(rx_ring->itr_val,
+                              hw->hw_addr + rx_ring->itr_register);
+               else
+                       writel(1, hw->hw_addr + rx_ring->itr_register);
+       }
+
+#else
+       for (i = 0; i < adapter->num_rx_queues; i++) {
+               struct igb_ring *rx_ring = &adapter->rx_ring[i];
+               if (i < adapter->num_tx_queues) {
+                       igb_assign_vector(adapter, i, i, vector++);
+                       rx_ring->buddy = &adapter->tx_ring[i];
+                       rx_ring->eims_value |= adapter->tx_ring[i].eims_value;
+               } else {
+                       igb_assign_vector(adapter, i, IGB_N0_QUEUE, vector++);
+               }
+               adapter->eims_enable_mask |= rx_ring->eims_value;
+               if (rx_ring->itr_val)
+                       writel(rx_ring->itr_val,
                               hw->hw_addr + rx_ring->itr_register);
                else
                        writel(1, hw->hw_addr + rx_ring->itr_register);
        }
 
+#endif
 
        /* set vector for other causes, i.e. link changes */
-               array_wr32(E1000_MSIXBM(0), vector++,
-                                     E1000_EIMS_OTHER);
 
-               /* disable IAM for ICR interrupt bits */
-               wr32(E1000_IAM, 0);
+       switch (hw->mac.type) {
+       case e1000_82575:
+               E1000_WRITE_REG_ARRAY(hw, E1000_MSIXBM(0), vector++,
+                                     E1000_EIMS_OTHER);
 
-               tmp = rd32(E1000_CTRL_EXT);
+               tmp = E1000_READ_REG(hw, E1000_CTRL_EXT);
                /* enable MSI-X PBA support*/
                tmp |= E1000_CTRL_EXT_PBA_CLR;
 
@@ -331,10 +496,24 @@ static void igb_configure_msix(struct igb_adapter *adapter)
                tmp |= E1000_CTRL_EXT_EIAME;
                tmp |= E1000_CTRL_EXT_IRCA;
 
-               wr32(E1000_CTRL_EXT, tmp);
+               E1000_WRITE_REG(hw, E1000_CTRL_EXT, tmp);
                adapter->eims_enable_mask |= E1000_EIMS_OTHER;
+               adapter->eims_other = E1000_EIMS_OTHER;
+
+               break;
 
-       wrfl();
+       case e1000_82576:
+               tmp = (vector++ | E1000_IVAR_VALID) << 8;
+               E1000_WRITE_REG(hw, E1000_IVAR_MISC, tmp);
+
+               adapter->eims_enable_mask = (1 << (vector)) - 1;
+               adapter->eims_other = 1 << (vector - 1);
+               break;
+       default:
+               /* do nothing, since nothing else supports MSI-X */
+               break;
+       } /* switch (hw->mac.type) */
+       E1000_WRITE_FLUSH(hw);
 }
 
 /**
@@ -350,42 +529,49 @@ static int igb_request_msix(struct igb_adapter *adapter)
 
        vector = 0;
 
+#ifdef CONFIG_IGB_SEPARATE_TX_HANDLER
        for (i = 0; i < adapter->num_tx_queues; i++) {
                struct igb_ring *ring = &(adapter->tx_ring[i]);
                sprintf(ring->name, "%s-tx%d", netdev->name, i);
                err = request_irq(adapter->msix_entries[vector].vector,
-                                 &igb_msix_tx, 0, ring->name,
-                                 &(adapter->tx_ring[i]));
+                                 &igb_msix_tx, 0, ring->name,
+                                 &(adapter->tx_ring[i]));
                if (err)
                        goto out;
                ring->itr_register = E1000_EITR(0) + (vector << 2);
-               ring->itr_val = adapter->itr;
+               ring->itr_val = 1952; /* ~2000 ints/sec */
                vector++;
        }
+#endif
        for (i = 0; i < adapter->num_rx_queues; i++) {
                struct igb_ring *ring = &(adapter->rx_ring[i]);
                if (strlen(netdev->name) < (IFNAMSIZ - 5))
-                       sprintf(ring->netdev->name, "%s-rx%d", netdev->name, i);
+#ifdef CONFIG_IGB_SEPARATE_TX_HANDLER
+                       sprintf(ring->name, "%s-rx%d", netdev->name, i);
+#else
+                       sprintf(ring->name, "%s-Q%d", netdev->name, i);
+#endif
                else
-                       memcpy(ring->netdev->name, netdev->name, IFNAMSIZ);
+                       memcpy(ring->name, netdev->name, IFNAMSIZ);
                err = request_irq(adapter->msix_entries[vector].vector,
-                                 &igb_msix_rx, 0, ring->netdev->name,
-                                 &(adapter->rx_ring[i]));
+                                 &igb_msix_rx, 0, ring->name,
+                                 &(adapter->rx_ring[i]));
                if (err)
                        goto out;
                ring->itr_register = E1000_EITR(0) + (vector << 2);
                ring->itr_val = adapter->itr;
+               /* overwrite the poll routine for MSIX, we've already done
+                * netif_napi_add */
+               ring->napi.poll = &igb_clean_rx_ring_msix;
                vector++;
        }
 
        err = request_irq(adapter->msix_entries[vector].vector,
-                         &igb_msix_other, 0, netdev->name, netdev);
+                         &igb_msix_other, 0, netdev->name, netdev);
        if (err)
                goto out;
 
-       adapter->netdev->poll = igb_clean_rx_ring_msix;
-       for (i = 0; i < adapter->num_rx_queues; i++)
-               adapter->rx_ring[i].netdev->poll = igb_clean_rx_ring_msix;
+
        igb_configure_msix(adapter);
        return 0;
 out:
@@ -398,8 +584,9 @@ static void igb_reset_interrupt_capability(struct igb_adapter *adapter)
                pci_disable_msix(adapter->pdev);
                kfree(adapter->msix_entries);
                adapter->msix_entries = NULL;
-       } else if (adapter->msi_enabled)
+       } else if (adapter->flags & IGB_FLAG_HAS_MSI)
                pci_disable_msi(adapter->pdev);
+
        return;
 }
 
@@ -415,28 +602,56 @@ static void igb_set_interrupt_capability(struct igb_adapter *adapter)
        int err;
        int numvecs, i;
 
-       numvecs = adapter->num_tx_queues + adapter->num_rx_queues + 1;
-       adapter->msix_entries = kcalloc(numvecs, sizeof(struct msix_entry),
-                                       GFP_KERNEL);
-       if (!adapter->msix_entries)
-               goto msi_only;
 
-       for (i = 0; i < numvecs; i++)
-               adapter->msix_entries[i].entry = i;
-
-       err = pci_enable_msix(adapter->pdev,
-                             adapter->msix_entries,
-                             numvecs);
-       if (err == 0)
-               return;
+       switch (adapter->int_mode) {
+       case IGB_INT_MODE_MSIX_1Q:
+               adapter->num_rx_queues = 1;
+               adapter->num_tx_queues = 1;
+       case IGB_INT_MODE_MSIX_MQ:
+#ifdef CONFIG_IGB_SEPARATE_TX_HANDLER
+               numvecs = adapter->num_tx_queues + adapter->num_rx_queues + 1;
+#else
+               numvecs = adapter->num_rx_queues + 1;
+#endif
+               adapter->msix_entries = kcalloc(numvecs,
+                                               sizeof(struct msix_entry),
+                                               GFP_KERNEL);
+               if (adapter->msix_entries) {
+                       for (i=0; i < numvecs; i++)
+                               adapter->msix_entries[i].entry = i;
+
+                       err = pci_enable_msix(adapter->pdev,
+                                             adapter->msix_entries, numvecs);
+                       if (err == 0)
+                               break;
+               }
+               /* MSI-X failed, so fall through and try MSI */
+               DPRINTK(PROBE, WARNING, "Failed to initialize MSI-X interrupts."
+                       "  Falling back to MSI interrupts.\n");
+               igb_reset_interrupt_capability(adapter);
+       case IGB_INT_MODE_MSI:
+               if (!pci_enable_msi(adapter->pdev))
+                       adapter->flags |= IGB_FLAG_HAS_MSI;
+               else
+                       DPRINTK(PROBE, WARNING, "Failed to initialize MSI "
+                               "interrupts. Falling back to legacy interrupts.\n");
+               /* Fall through */
+       case IGB_INT_MODE_LEGACY:
+               adapter->num_rx_queues = 1;
+               adapter->num_tx_queues = 1;
+               /* Don't do anything; this is system default */
+               break;
+       }
 
-       igb_reset_interrupt_capability(adapter);
+#ifdef HAVE_TX_MQ
+       /* Notify the stack of the (possibly) reduced Tx Queue count. */
+#ifdef CONFIG_NETDEVICES_MULTIQUEUE
+       adapter->netdev->egress_subqueue_count = adapter->num_tx_queues;
+#else
+       adapter->netdev->real_num_tx_queues = adapter->num_tx_queues;
+#endif 
+#endif
 
-       /* If we can't do MSI-X, try MSI */
-msi_only:
-       adapter->num_rx_queues = 1;
-       if (!pci_enable_msi(adapter->pdev))
-               adapter->msi_enabled = 1;
        return;
 }
 
@@ -454,37 +669,48 @@ static int igb_request_irq(struct igb_adapter *adapter)
 
        if (adapter->msix_entries) {
                err = igb_request_msix(adapter);
-               if (!err) {
-                       /* enable IAM, auto-mask,
-                        * DO NOT USE EIAM or IAM in legacy mode */
-                       wr32(E1000_IAM, IMS_ENABLE_MASK);
+               if (!err)
                        goto request_done;
-               }
                /* fall back to MSI */
                igb_reset_interrupt_capability(adapter);
                if (!pci_enable_msi(adapter->pdev))
-                       adapter->msi_enabled = 1;
+                       adapter->flags |= IGB_FLAG_HAS_MSI;
                igb_free_all_tx_resources(adapter);
                igb_free_all_rx_resources(adapter);
                adapter->num_rx_queues = 1;
                igb_alloc_queues(adapter);
+       } else {
+               switch (hw->mac.type) {
+               case e1000_82575:
+                       E1000_WRITE_REG(hw, E1000_MSIXBM(0),
+                                       (E1000_EICR_RX_QUEUE0 |
+                                        E1000_EIMS_OTHER));
+                       break;
+               case e1000_82576:
+                       E1000_WRITE_REG(hw, E1000_IVAR0, E1000_IVAR_VALID);
+                       break;
+               default:
+                       break;
+               }
        }
-       if (adapter->msi_enabled) {
+       if (adapter->flags & IGB_FLAG_HAS_MSI) {
                err = request_irq(adapter->pdev->irq, &igb_intr_msi, 0,
-                                 netdev->name, netdev);
+                                 netdev->name, netdev);
                if (!err)
                        goto request_done;
+
                /* fall back to legacy interrupts */
                igb_reset_interrupt_capability(adapter);
-               adapter->msi_enabled = 0;
+               adapter->flags &= ~IGB_FLAG_HAS_MSI;
        }
 
        err = request_irq(adapter->pdev->irq, &igb_intr, IRQF_SHARED,
-                         netdev->name, netdev);
+                         netdev->name, netdev);
 
-       if (err)
-               dev_err(&adapter->pdev->dev, "Error %d getting interrupt\n",
-                       err);
+       if (err) {
+               DPRINTK(PROBE, ERR, "Error %d getting interrupt\n", err);
+               goto request_done;
+       }
 
 request_done:
        return err;
@@ -497,9 +723,11 @@ static void igb_free_irq(struct igb_adapter *adapter)
        if (adapter->msix_entries) {
                int vector = 0, i;
 
+#ifdef CONFIG_IGB_SEPARATE_TX_HANDLER
                for (i = 0; i < adapter->num_tx_queues; i++)
                        free_irq(adapter->msix_entries[vector++].vector,
                                &(adapter->tx_ring[i]));
+#endif
                for (i = 0; i < adapter->num_rx_queues; i++)
                        free_irq(adapter->msix_entries[vector++].vector,
                                &(adapter->rx_ring[i]));
@@ -515,16 +743,21 @@ static void igb_free_irq(struct igb_adapter *adapter)
  * igb_irq_disable - Mask off interrupt generation on the NIC
  * @adapter: board private structure
  **/
+
 static void igb_irq_disable(struct igb_adapter *adapter)
 {
        struct e1000_hw *hw = &adapter->hw;
 
        if (adapter->msix_entries) {
-               wr32(E1000_EIMC, ~0);
-               wr32(E1000_EIAC, 0);
+               E1000_WRITE_REG(hw, E1000_EIAM, 0);
+               E1000_WRITE_REG(hw, E1000_EIMC, ~0);
+               E1000_WRITE_REG(hw, E1000_EIAC, 0);
        }
-       wr32(E1000_IMC, ~0);
-       wrfl();
+
+       E1000_WRITE_REG(hw, E1000_IAM, 0);
+       E1000_WRITE_REG(hw, E1000_IMC, ~0);
+       E1000_WRITE_FLUSH(hw);
+
        synchronize_irq(adapter->pdev->irq);
 }
 
@@ -532,18 +765,20 @@ static void igb_irq_disable(struct igb_adapter *adapter)
  * igb_irq_enable - Enable default interrupt generation settings
  * @adapter: board private structure
  **/
+
 static void igb_irq_enable(struct igb_adapter *adapter)
 {
        struct e1000_hw *hw = &adapter->hw;
 
        if (adapter->msix_entries) {
-               wr32(E1000_EIMS,
-                               adapter->eims_enable_mask);
-               wr32(E1000_EIAC,
-                               adapter->eims_enable_mask);
-               wr32(E1000_IMS, E1000_IMS_LSC);
-       } else
-       wr32(E1000_IMS, IMS_ENABLE_MASK);
+               E1000_WRITE_REG(hw, E1000_EIAC, adapter->eims_enable_mask);
+               E1000_WRITE_REG(hw, E1000_EIAM, adapter->eims_enable_mask);
+               E1000_WRITE_REG(hw, E1000_EIMS, adapter->eims_enable_mask);
+               E1000_WRITE_REG(hw, E1000_IMS, E1000_IMS_LSC);
+       } else {
+               E1000_WRITE_REG(hw, E1000_IMS, IMS_ENABLE_MASK);
+               E1000_WRITE_REG(hw, E1000_IAM, IMS_ENABLE_MASK);
+       }
 }
 
 static void igb_update_mng_vlan(struct igb_adapter *adapter)
@@ -578,15 +813,16 @@ static void igb_update_mng_vlan(struct igb_adapter *adapter)
  * driver is no longer loaded.
  *
  **/
+
 static void igb_release_hw_control(struct igb_adapter *adapter)
 {
        struct e1000_hw *hw = &adapter->hw;
        u32 ctrl_ext;
 
        /* Let firmware take over control of h/w */
-       ctrl_ext = rd32(E1000_CTRL_EXT);
-       wr32(E1000_CTRL_EXT,
-                       ctrl_ext & ~E1000_CTRL_EXT_DRV_LOAD);
+       ctrl_ext = E1000_READ_REG(hw, E1000_CTRL_EXT);
+       E1000_WRITE_REG(hw, E1000_CTRL_EXT,
+                       ctrl_ext & ~E1000_CTRL_EXT_DRV_LOAD);
 }
 
 
@@ -599,37 +835,16 @@ static void igb_release_hw_control(struct igb_adapter *adapter)
  * the driver is loaded.
  *
  **/
+
 static void igb_get_hw_control(struct igb_adapter *adapter)
 {
        struct e1000_hw *hw = &adapter->hw;
        u32 ctrl_ext;
 
        /* Let firmware know the driver has taken over */
-       ctrl_ext = rd32(E1000_CTRL_EXT);
-       wr32(E1000_CTRL_EXT,
-                       ctrl_ext | E1000_CTRL_EXT_DRV_LOAD);
-}
-
-static void igb_init_manageability(struct igb_adapter *adapter)
-{
-       struct e1000_hw *hw = &adapter->hw;
-
-       if (adapter->en_mng_pt) {
-               u32 manc2h = rd32(E1000_MANC2H);
-               u32 manc = rd32(E1000_MANC);
-
-               /* enable receiving management packets to the host */
-               /* this will probably generate destination unreachable messages
-                * from the host OS, but the packets will be handled on SMBUS */
-               manc |= E1000_MANC_EN_MNG2HOST;
-#define E1000_MNG2HOST_PORT_623 (1 << 5)
-#define E1000_MNG2HOST_PORT_664 (1 << 6)
-               manc2h |= E1000_MNG2HOST_PORT_623;
-               manc2h |= E1000_MNG2HOST_PORT_664;
-               wr32(E1000_MANC2H, manc2h);
-
-               wr32(E1000_MANC, manc);
-       }
+       ctrl_ext = E1000_READ_REG(hw, E1000_CTRL_EXT);
+       E1000_WRITE_REG(hw, E1000_CTRL_EXT,
+                       ctrl_ext | E1000_CTRL_EXT_DRV_LOAD);
 }
 
 /**
@@ -645,20 +860,27 @@ static void igb_configure(struct igb_adapter *adapter)
        igb_set_multi(netdev);
 
        igb_restore_vlan(adapter);
-       igb_init_manageability(adapter);
 
        igb_configure_tx(adapter);
        igb_setup_rctl(adapter);
        igb_configure_rx(adapter);
+
+       e1000_rx_fifo_flush_82575(&adapter->hw);
+#ifdef CONFIG_NETDEVICES_MULTIQUEUE
+       if (adapter->num_tx_queues > 1)
+               netdev->features |= NETIF_F_MULTI_QUEUE;
+       else
+               netdev->features &= ~NETIF_F_MULTI_QUEUE;
+
+#endif
        /* call IGB_DESC_UNUSED which always leaves
         * at least 1 descriptor unused to make sure
         * next_to_use != next_to_clean */
        for (i = 0; i < adapter->num_rx_queues; i++) {
                struct igb_ring *ring = &adapter->rx_ring[i];
-               igb_alloc_rx_buffers_adv(adapter, ring, IGB_DESC_UNUSED(ring));
+               igb_alloc_rx_buffers_adv(ring, IGB_DESC_UNUSED(ring));
        }
 
-
        adapter->tx_queue_len = netdev->tx_queue_len;
 }
 
@@ -671,53 +893,58 @@ static void igb_configure(struct igb_adapter *adapter)
 int igb_up(struct igb_adapter *adapter)
 {
        struct e1000_hw *hw = &adapter->hw;
+       int i;
 
        /* hardware has been reset, we need to reload some things */
        igb_configure(adapter);
 
        clear_bit(__IGB_DOWN, &adapter->state);
 
-       netif_poll_enable(adapter->netdev);
-
-       if (adapter->msix_entries) {
+       for (i = 0; i < adapter->num_rx_queues; i++)
+               napi_enable(&adapter->rx_ring[i].napi);
+       if (adapter->msix_entries)
                igb_configure_msix(adapter);
-       }
+
+       igb_configure_lli(adapter);
 
        /* Clear any pending interrupts. */
-       rd32(E1000_ICR);
+       E1000_READ_REG(hw, E1000_ICR);
        igb_irq_enable(adapter);
 
        /* Fire a link change interrupt to start the watchdog. */
-       wr32(E1000_ICS, E1000_ICS_LSC);
+       E1000_WRITE_REG(hw, E1000_ICS, E1000_ICS_LSC);
        return 0;
 }
 
 void igb_down(struct igb_adapter *adapter)
 {
-       struct e1000_hw *hw = &adapter->hw;
        struct net_device *netdev = adapter->netdev;
+       struct e1000_hw *hw = &adapter->hw;
        u32 tctl, rctl;
+       int i;
 
        /* signal that we're down so the interrupt handler does not
         * reschedule our watchdog timer */
        set_bit(__IGB_DOWN, &adapter->state);
 
        /* disable receives in the hardware */
-       rctl = rd32(E1000_RCTL);
-       wr32(E1000_RCTL, rctl & ~E1000_RCTL_EN);
+       rctl = E1000_READ_REG(hw, E1000_RCTL);
+       E1000_WRITE_REG(hw, E1000_RCTL, rctl & ~E1000_RCTL_EN);
        /* flush and sleep below */
 
-       netif_stop_queue(netdev);
+       netif_tx_stop_all_queues(netdev);
 
        /* disable transmits in the hardware */
-       tctl = rd32(E1000_TCTL);
+       tctl = E1000_READ_REG(hw, E1000_TCTL);
        tctl &= ~E1000_TCTL_EN;
-       wr32(E1000_TCTL, tctl);
+       E1000_WRITE_REG(hw, E1000_TCTL, tctl);
        /* flush both disables and wait for them to finish */
-       wrfl();
+       E1000_WRITE_FLUSH(hw);
        msleep(10);
 
-       netif_poll_disable(netdev);
+       for (i = 0; i < adapter->num_rx_queues; i++)
+               napi_disable(&adapter->rx_ring[i].napi);
+
        igb_irq_disable(adapter);
 
        del_timer_sync(&adapter->watchdog_timer);
@@ -725,10 +952,19 @@ void igb_down(struct igb_adapter *adapter)
 
        netdev->tx_queue_len = adapter->tx_queue_len;
        netif_carrier_off(netdev);
+
+       /* record the stats before reset*/
+       igb_update_stats(adapter);
+
        adapter->link_speed = 0;
        adapter->link_duplex = 0;
 
+#ifdef HAVE_PCI_ERS
+       if (!pci_channel_offline(adapter->pdev))
+               igb_reset(adapter);
+#else
        igb_reset(adapter);
+#endif
        igb_clean_all_tx_rings(adapter);
        igb_clean_all_rx_rings(adapter);
 }
@@ -738,6 +974,7 @@ void igb_reinit_locked(struct igb_adapter *adapter)
        WARN_ON(in_interrupt());
        while (test_and_set_bit(__IGB_RESETTING, &adapter->state))
                msleep(1);
+
        igb_down(adapter);
        igb_up(adapter);
        clear_bit(__IGB_RESETTING, &adapter->state);
@@ -746,18 +983,25 @@ void igb_reinit_locked(struct igb_adapter *adapter)
 void igb_reset(struct igb_adapter *adapter)
 {
        struct e1000_hw *hw = &adapter->hw;
-       struct e1000_fc_info *fc = &adapter->hw.fc;
+       struct e1000_mac_info *mac = &hw->mac;
+       struct e1000_fc_info *fc = &hw->fc;
        u32 pba = 0, tx_space, min_tx_space, min_rx_space;
        u16 hwm;
 
        /* Repartition Pba for greater than 9k mtu
         * To take effect CTRL.RST is required.
         */
-       pba = E1000_PBA_34K;
+       if (mac->type != e1000_82576) {
+               pba = E1000_PBA_34K;
+       }
+       else {
+               pba = E1000_PBA_64K;
+       }
 
-       if (adapter->max_frame_size > ETH_FRAME_LEN + ETH_FCS_LEN) {
+       if ((adapter->max_frame_size > ETH_FRAME_LEN + ETH_FCS_LEN) &&
+           (mac->type < e1000_82576)) {
                /* adjust PBA for jumbo frames */
-               wr32(E1000_PBA, pba);
+               E1000_WRITE_REG(hw, E1000_PBA, pba);
 
                /* To maintain wire speed transmits, the Tx FIFO should be
                 * large enough to accommodate two full transmit packets,
@@ -765,7 +1009,7 @@ void igb_reset(struct igb_adapter *adapter)
                 * the Rx FIFO should be large enough to accommodate at least
                 * one full receive packet and is similarly rounded up and
                 * expressed in KB. */
-               pba = rd32(E1000_PBA);
+               pba = E1000_READ_REG(hw, E1000_PBA);
                /* upper 16 bits has Tx packet buffer allocation size in KB */
                tx_space = pba >> 16;
                /* lower 16 bits has Rx packet buffer allocation size in KB */
@@ -773,8 +1017,8 @@ void igb_reset(struct igb_adapter *adapter)
                /* the tx fifo also stores 16 bytes of information about the tx
                 * but don't include ethernet FCS because hardware appends it */
                min_tx_space = (adapter->max_frame_size +
-                               sizeof(struct e1000_tx_desc) -
-                               ETH_FCS_LEN) * 2;
+                               sizeof(struct e1000_tx_desc) -
+                               ETH_FCS_LEN) * 2;
                min_tx_space = ALIGN(min_tx_space, 1024);
                min_tx_space >>= 10;
                /* software strips receive CRC, so leave room for it */
@@ -794,8 +1038,8 @@ void igb_reset(struct igb_adapter *adapter)
                        if (pba < min_rx_space)
                                pba = min_rx_space;
                }
+               E1000_WRITE_REG(hw, E1000_PBA, pba);
        }
-       wr32(E1000_PBA, pba);
 
        /* flow control settings */
        /* The high water mark must be low enough to fit one full frame
@@ -804,29 +1048,31 @@ void igb_reset(struct igb_adapter *adapter)
         * - 90% of the Rx FIFO size, or
         * - the full Rx FIFO size minus one full frame */
        hwm = min(((pba << 10) * 9 / 10),
-                 ((pba << 10) - adapter->max_frame_size));
+                       ((pba << 10) - 2 * adapter->max_frame_size));
 
-       fc->high_water = hwm & 0xFFF8;  /* 8-byte granularity */
-       fc->low_water = fc->high_water - 8;
+       if (mac->type < e1000_82576) {
+               fc->high_water = hwm & 0xFFF8;  /* 8-byte granularity */
+               fc->low_water = fc->high_water - 8;
+       } else {
+               fc->high_water = hwm & 0xFFF0;  /* 16-byte granularity */
+               fc->low_water = fc->high_water - 16;
+       }
        fc->pause_time = 0xFFFF;
        fc->send_xon = 1;
        fc->type = fc->original_type;
 
        /* Allow time for pending master requests to run */
-       adapter->hw.mac.ops.reset_hw(&adapter->hw);
-       wr32(E1000_WUC, 0);
-
-       if (adapter->hw.mac.ops.init_hw(&adapter->hw))
-               dev_err(&adapter->pdev->dev, "Hardware Error\n");
+       e1000_reset_hw(hw);
+       E1000_WRITE_REG(hw, E1000_WUC, 0);
 
+       if (e1000_init_hw(hw))
+               DPRINTK(PROBE, ERR, "Hardware Error\n");
        igb_update_mng_vlan(adapter);
 
        /* Enable h/w to recognize an 802.1Q VLAN Ethernet packet */
-       wr32(E1000_VET, ETHERNET_IEEE_VLAN_TYPE);
+       E1000_WRITE_REG(hw, E1000_VET, ETHERNET_IEEE_VLAN_TYPE);
 
-       igb_reset_adaptive(&adapter->hw);
-       if (adapter->hw.phy.ops.get_phy_info)
-               adapter->hw.phy.ops.get_phy_info(&adapter->hw);
+       e1000_get_phy_info(hw);
 }
 
 /**
@@ -840,20 +1086,19 @@ void igb_reset(struct igb_adapter *adapter)
  * The OS initialization, configuring of the adapter private structure,
  * and a hardware reset occur.
  **/
+
 static int __devinit igb_probe(struct pci_dev *pdev,
-                              const struct pci_device_id *ent)
+                               const struct pci_device_id *ent)
 {
        struct net_device *netdev;
        struct igb_adapter *adapter;
        struct e1000_hw *hw;
-       const struct e1000_info *ei = igb_info_tbl[ent->driver_data];
-       unsigned long mmio_start, mmio_len;
+       struct pci_dev *us_dev;
+
        static int cards_found = 0;
-       int i, err, pci_using_dac;
-       u16 eeprom_data = 0;
+       int i, err, pci_using_dac, pos;
+       u16 eeprom_data = 0, state = 0;
        u16 eeprom_apme_mask = IGB_EEPROM_APME;
-       u32 part_num;
-
        err = pci_enable_device(pdev);
        if (err)
                return err;
@@ -869,24 +1114,51 @@ static int __devinit igb_probe(struct pci_dev *pdev,
                if (err) {
                        err = pci_set_consistent_dma_mask(pdev, DMA_32BIT_MASK);
                        if (err) {
-                               dev_err(&pdev->dev, "No usable DMA "
-                                       "configuration, aborting\n");
+                               IGB_ERR("No usable DMA configuration, "
+                                       "aborting\n");
                                goto err_dma;
                        }
                }
        }
 
-       err = pci_request_regions(pdev, igb_driver_name);
+       /* 82575 requires that the pci-e link partner disable the L0s state */
+       switch (pdev->device) {
+       case E1000_DEV_ID_82575EB_COPPER:
+       case E1000_DEV_ID_82575EB_FIBER_SERDES:
+       case E1000_DEV_ID_82575GB_QUAD_COPPER:
+               us_dev = pdev->bus->self;
+               pos = pci_find_capability(us_dev, PCI_CAP_ID_EXP);
+               if (pos) {
+                       pci_read_config_word(us_dev, pos + PCI_EXP_LNKCTL, &state);
+                       state &= ~PCIE_LINK_STATE_L0S;
+                       pci_write_config_word(us_dev, pos + PCI_EXP_LNKCTL, state);
+                       printk(KERN_INFO "Disabling ASPM L0s upstream switch "
+                              "port %x:%x.%x\n", us_dev->bus->number,
+                              PCI_SLOT(us_dev->devfn), PCI_FUNC(us_dev->devfn));
+               }
+       default:
+               break;
+       }
+
+       err = pci_request_selected_regions(pdev,
+                                          pci_select_bars(pdev,
+                                                           IORESOURCE_MEM),
+                                          igb_driver_name);
        if (err)
                goto err_pci_reg;
 
        pci_set_master(pdev);
 
        err = -ENOMEM;
+#ifdef HAVE_TX_MQ
+       netdev = alloc_etherdev_mq(sizeof(struct igb_adapter), IGB_ABS_MAX_TX_QUEUES);
+#else
        netdev = alloc_etherdev(sizeof(struct igb_adapter));
+#endif /* HAVE_TX_MQ */
        if (!netdev)
                goto err_alloc_etherdev;
 
+       SET_MODULE_OWNER(netdev);
        SET_NETDEV_DEV(netdev, &pdev->dev);
 
        pci_set_drvdata(pdev, netdev);
@@ -895,14 +1167,17 @@ static int __devinit igb_probe(struct pci_dev *pdev,
        adapter->pdev = pdev;
        hw = &adapter->hw;
        hw->back = adapter;
-       adapter->msg_enable = NETIF_MSG_DRV | NETIF_MSG_PROBE;
-
-       mmio_start = pci_resource_start(pdev, 0);
-       mmio_len = pci_resource_len(pdev, 0);
+       adapter->msg_enable = (1 << debug) - 1;
 
+#ifdef HAVE_PCI_ERS
+       err = pci_save_state(pdev);
+       if (err)
+               goto err_ioremap;
+#endif
        err = -EIO;
-       adapter->hw.hw_addr = ioremap(mmio_start, mmio_len);
-       if (!adapter->hw.hw_addr)
+       hw->hw_addr = ioremap(pci_resource_start(pdev, 0),
+                             pci_resource_len(pdev, 0));
+       if (!hw->hw_addr)
                goto err_ioremap;
 
        netdev->open = &igb_open;
@@ -913,10 +1188,10 @@ static int __devinit igb_probe(struct pci_dev *pdev,
        netdev->change_mtu = &igb_change_mtu;
        netdev->do_ioctl = &igb_ioctl;
        igb_set_ethtool_ops(netdev);
+#ifdef HAVE_TX_TIMEOUT
        netdev->tx_timeout = &igb_tx_timeout;
        netdev->watchdog_timeo = 5 * HZ;
-       netdev->poll = igb_clean;
-       netdev->weight = 64;
+#endif
        netdev->vlan_rx_register = igb_vlan_rx_register;
        netdev->vlan_rx_add_vid = igb_vlan_rx_add_vid;
        netdev->vlan_rx_kill_vid = igb_vlan_rx_kill_vid;
@@ -927,85 +1202,93 @@ static int __devinit igb_probe(struct pci_dev *pdev,
 
        strncpy(netdev->name, pci_name(pdev), sizeof(netdev->name) - 1);
 
-       netdev->mem_start = mmio_start;
-       netdev->mem_end = mmio_start + mmio_len;
-
        adapter->bd_number = cards_found;
 
-       /* PCI config space info */
-       hw->vendor_id = pdev->vendor;
-       hw->device_id = pdev->device;
-       hw->subsystem_vendor_id = pdev->subsystem_vendor;
-       hw->subsystem_device_id = pdev->subsystem_device;
-
-       pci_read_config_byte(pdev, PCI_REVISION_ID, &hw->revision_id);
+       igb_check_options(adapter);
 
        /* setup the private structure */
-       hw->back = adapter;
-       /* Copy the default MAC, PHY and NVM function pointers */
-       memcpy(&hw->mac.ops, ei->mac_ops, sizeof(hw->mac.ops));
-       memcpy(&hw->phy.ops, ei->phy_ops, sizeof(hw->phy.ops));
-       memcpy(&hw->nvm.ops, ei->nvm_ops, sizeof(hw->nvm.ops));
-       /* Initialize skew-specific constants */
-       err = ei->get_invariants(hw);
-       if (err)
-               goto err_hw_init;
-
        err = igb_sw_init(adapter);
        if (err)
                goto err_sw_init;
 
-       igb_get_bus_info_pcie(hw);
+       e1000_get_bus_info(hw);
+
+       /* Set flags */
+       switch (hw->mac.type) {
+               case e1000_82576:
+               /* Fall through */
+               case e1000_82575:
+                       adapter->flags |= IGB_FLAG_HAS_DCA;
+                       adapter->flags |= IGB_FLAG_NEED_CTX_IDX;
+                       break;
+               default:
+                       break;
+       }
 
-       hw->phy.autoneg_wait_to_complete = false;
-       hw->mac.adaptive_ifs = true;
+       hw->phy.autoneg_wait_to_complete = FALSE;
+       hw->mac.adaptive_ifs = FALSE;
 
        /* Copper options */
        if (hw->phy.media_type == e1000_media_type_copper) {
                hw->phy.mdix = AUTO_ALL_MODES;
-               hw->phy.disable_polarity_correction = false;
+               hw->phy.disable_polarity_correction = FALSE;
                hw->phy.ms_type = e1000_ms_hw_default;
        }
 
-       if (igb_check_reset_block(hw))
-               dev_info(&pdev->dev,
-                       "PHY reset is blocked due to SOL/IDER session.\n");
+       if (e1000_check_reset_block(hw))
+               DPRINTK(PROBE, INFO,
+                       "PHY reset is blocked due to SOL/IDER session.\n");
 
        netdev->features = NETIF_F_SG |
-                          NETIF_F_HW_CSUM |
+                          NETIF_F_IP_CSUM |
                           NETIF_F_HW_VLAN_TX |
                           NETIF_F_HW_VLAN_RX |
                           NETIF_F_HW_VLAN_FILTER;
 
+#ifdef NETIF_F_IPV6_CSUM
+       netdev->features |= NETIF_F_IPV6_CSUM;
+#endif
+
+#ifdef NETIF_F_TSO
        netdev->features |= NETIF_F_TSO;
 
+#ifdef NETIF_F_TSO6
        netdev->features |= NETIF_F_TSO6;
+#endif
+#endif /* NETIF_F_TSO */
+
+#ifdef IGB_LRO
+       netdev->features |= NETIF_F_LRO;
+#endif /* IGB_LRO */
+
        if (pci_using_dac)
                netdev->features |= NETIF_F_HIGHDMA;
 
-       netdev->features |= NETIF_F_LLTX;
-       adapter->en_mng_pt = igb_enable_mng_pass_thru(&adapter->hw);
+       adapter->en_mng_pt = e1000_enable_mng_pass_thru(hw);
 
        /* before reading the NVM, reset the controller to put the device in a
         * known good starting state */
-       hw->mac.ops.reset_hw(hw);
+       e1000_reset_hw(hw);
 
        /* make sure the NVM is good */
-       if (igb_validate_nvm_checksum(hw) < 0) {
-               dev_err(&pdev->dev, "The NVM Checksum Is Not Valid\n");
+       if (e1000_validate_nvm_checksum(hw) < 0) {
+               DPRINTK(PROBE, ERR, "The NVM Checksum Is Not Valid\n");
                err = -EIO;
                goto err_eeprom;
        }
 
        /* copy the MAC address out of the NVM */
-       if (hw->mac.ops.read_mac_addr(hw))
-               dev_err(&pdev->dev, "NVM Read Error\n");
-
+       if (e1000_read_mac_addr(hw))
+               DPRINTK(PROBE, ERR, "NVM Read Error\n");
        memcpy(netdev->dev_addr, hw->mac.addr, netdev->addr_len);
+#ifdef ETHTOOL_GPERMADDR
        memcpy(netdev->perm_addr, hw->mac.addr, netdev->addr_len);
 
        if (!is_valid_ether_addr(netdev->perm_addr)) {
-               dev_err(&pdev->dev, "Invalid MAC Address\n");
+#else
+       if (!is_valid_ether_addr(netdev->dev_addr)) {
+#endif
+               DPRINTK(PROBE, ERR, "Invalid MAC Address\n");
                err = -EIO;
                goto err_eeprom;
        }
@@ -1018,18 +1301,10 @@ static int __devinit igb_probe(struct pci_dev *pdev,
        adapter->phy_info_timer.function = &igb_update_phy_info;
        adapter->phy_info_timer.data = (unsigned long) adapter;
 
-       INIT_WORK(&adapter->reset_task,
-                       (void (*)(void *))igb_reset_task, adapter);
-       INIT_WORK(&adapter->watchdog_task,
-                       (void (*)(void *))igb_watchdog_task, adapter);
-       /* Initialize link & ring properties that are user-changeable */
-       adapter->tx_ring->count = 256;
-       for (i = 0; i < adapter->num_tx_queues; i++)
-               adapter->tx_ring[i].count = adapter->tx_ring->count;
-       adapter->rx_ring->count = 256;
-       for (i = 0; i < adapter->num_rx_queues; i++)
-               adapter->rx_ring[i].count = adapter->rx_ring->count;
+       INIT_WORK(&adapter->reset_task, igb_reset_task);
+       INIT_WORK(&adapter->watchdog_task, igb_watchdog_task);
 
+       /* Initialize link properties that are user-changeable */
        adapter->fc_autoneg = true;
        hw->mac.autoneg = true;
        hw->phy.autoneg_advertised = 0x2f;
@@ -1037,10 +1312,7 @@ static int __devinit igb_probe(struct pci_dev *pdev,
        hw->fc.original_type = e1000_fc_default;
        hw->fc.type = e1000_fc_default;
 
-       adapter->itr_setting = 3;
-       adapter->itr = IGB_START_ITR;
-
-       igb_validate_mdi_setting(hw);
+       e1000_validate_mdi_setting(hw);
 
        adapter->rx_csum = 1;
 
@@ -1048,10 +1320,10 @@ static int __devinit igb_probe(struct pci_dev *pdev,
         * enable the ACPI Magic Packet filter
         */
 
-       if (hw->bus.func == 0 ||
-           hw->device_id == E1000_DEV_ID_82575EB_COPPER)
-               hw->nvm.ops.read_nvm(hw, NVM_INIT_CONTROL3_PORT_A, 1,
-                                    &eeprom_data);
+       if (hw->bus.func == 0)
+               e1000_read_nvm(hw, NVM_INIT_CONTROL3_PORT_A, 1, &eeprom_data);
+       else if(hw->bus.func == 1)
+               e1000_read_nvm(hw, NVM_INIT_CONTROL3_PORT_B, 1, &eeprom_data);
 
        if (eeprom_data & eeprom_apme_mask)
                adapter->eeprom_wol |= E1000_WUFC_MAG;
@@ -1064,9 +1336,12 @@ static int __devinit igb_probe(struct pci_dev *pdev,
                adapter->eeprom_wol = 0;
                break;
        case E1000_DEV_ID_82575EB_FIBER_SERDES:
+       case E1000_DEV_ID_82576_FIBER:
+       case E1000_DEV_ID_82576_SERDES:
                /* Wake events only supported on port A for dual fiber
                 * regardless of eeprom setting */
-               if (rd32(E1000_STATUS) & E1000_STATUS_FUNC_1)
+               if (E1000_READ_REG(hw, E1000_STATUS) &
+                   E1000_STATUS_FUNC_1)
                        adapter->eeprom_wol = 0;
                break;
        }
@@ -1083,36 +1358,43 @@ static int __devinit igb_probe(struct pci_dev *pdev,
 
        /* tell the stack to leave us alone until igb_open() is called */
        netif_carrier_off(netdev);
-       netif_stop_queue(netdev);
-       netif_poll_disable(netdev);
+       netif_tx_stop_all_queues(netdev);
 
        strcpy(netdev->name, "eth%d");
        err = register_netdev(netdev);
        if (err)
                goto err_register;
 
-       dev_info(&pdev->dev, "Intel(R) Gigabit Ethernet Network Connection\n");
+#ifdef IGB_DCA
+       if (adapter->flags & IGB_FLAG_HAS_DCA) {
+               if (dca_add_requester(&pdev->dev) == E1000_SUCCESS) {
+                       adapter->flags |= IGB_FLAG_DCA_ENABLED;
+                       DPRINTK(PROBE, INFO, "DCA enabled\n");
+                       /* Always use CB2 mode, difference is masked
+                        * in the CB driver. */
+                       E1000_WRITE_REG(hw, E1000_DCA_CTRL, 2);
+                       igb_setup_dca(adapter);
+               }
+       }
+#endif
+
+       DPRINTK(PROBE, INFO, "Intel(R) Gigabit Ethernet Network Connection\n");
        /* print bus type/speed/width info */
-       dev_info(&pdev->dev,
-                "%s: (PCIe:%s:%s) %02x:%02x:%02x:%02x:%02x:%02x\n",
-                netdev->name,
-                ((hw->bus.speed == e1000_bus_speed_2500)
-                 ? "2.5Gb/s" : "unknown"),
-                ((hw->bus.width == e1000_bus_width_pcie_x4)
-                 ? "Width x4" : (hw->bus.width == e1000_bus_width_pcie_x1)
-                 ? "Width x1" : "unknown"),
-                netdev->dev_addr[0], netdev->dev_addr[1], netdev->dev_addr[2],
-                netdev->dev_addr[3], netdev->dev_addr[4], netdev->dev_addr[5]);
-
-       igb_read_part_num(hw, &part_num);
-       dev_info(&pdev->dev, "%s: PBA No: %06x-%03x\n", netdev->name,
-               (part_num >> 8), (part_num & 0xff));
-
-       dev_info(&pdev->dev,
-               "Using %s interrupts. %d rx queue(s), %d tx queue(s)\n",
-               adapter->msix_entries ? "MSI-X" :
-               adapter->msi_enabled ? "MSI" : "legacy",
-               adapter->num_rx_queues, adapter->num_tx_queues);
+       DPRINTK(PROBE, INFO, "(PCIe:%s:%s) ",
+             ((hw->bus.speed == e1000_bus_speed_2500) ? "2.5Gb/s" : "unknown"),
+             ((hw->bus.width == e1000_bus_width_pcie_x4) ? "Width x4" :
+              (hw->bus.width == e1000_bus_width_pcie_x1) ? "Width x1" :
+               "unknown"));
+
+       for (i = 0; i < 6; i++)
+               printk("%2.2x%c", netdev->dev_addr[i], i == 5 ? '\n' : ':');
+
+       DPRINTK(PROBE, INFO,
+               "Using %s interrupts. %d rx queue(s), %d tx queue(s)\n",
+               adapter->msix_entries ? "MSI-X" :
+               adapter->flags & IGB_FLAG_HAS_MSI ? "MSI" :
+               "legacy",
+               adapter->num_rx_queues, adapter->num_tx_queues);
 
        cards_found++;
        return 0;
@@ -1120,22 +1402,20 @@ static int __devinit igb_probe(struct pci_dev *pdev,
 err_register:
        igb_release_hw_control(adapter);
 err_eeprom:
-       if (!igb_check_reset_block(hw))
-               hw->phy.ops.reset_phy(hw);
+       if (!e1000_check_reset_block(hw))
+               e1000_phy_hw_reset(hw);
 
        if (hw->flash_address)
                iounmap(hw->flash_address);
 
-       igb_remove_device(hw);
-       kfree(adapter->tx_ring);
-       kfree(adapter->rx_ring);
+       igb_free_queues(adapter);
 err_sw_init:
-err_hw_init:
        iounmap(hw->hw_addr);
 err_ioremap:
        free_netdev(netdev);
 err_alloc_etherdev:
-       pci_release_regions(pdev);
+       pci_release_selected_regions(pdev,
+                                    pci_select_bars(pdev, IORESOURCE_MEM));
 err_pci_reg:
 err_dma:
        pci_disable_device(pdev);
@@ -1151,10 +1431,12 @@ err_dma:
  * Hot-Plug event, or because the driver is going to be removed from
  * memory.
  **/
+
 static void __devexit igb_remove(struct pci_dev *pdev)
 {
        struct net_device *netdev = pci_get_drvdata(pdev);
        struct igb_adapter *adapter = netdev_priv(netdev);
+       struct e1000_hw *hw = &adapter->hw;
 
        /* flush_scheduled work may reschedule our watchdog task, so
         * explicitly disable watchdog tasks from being rescheduled  */
@@ -1164,25 +1446,33 @@ static void __devexit igb_remove(struct pci_dev *pdev)
 
        flush_scheduled_work();
 
+#ifdef IGB_DCA
+       if (adapter->flags & IGB_FLAG_DCA_ENABLED) {
+               DPRINTK(PROBE, INFO, "DCA disabled\n");
+               dca_remove_requester(&pdev->dev);
+               adapter->flags &= ~IGB_FLAG_DCA_ENABLED;
+               E1000_WRITE_REG(hw, E1000_DCA_CTRL, 1);
+       }
+#endif
+
        /* Release control of h/w to f/w.  If f/w is AMT enabled, this
         * would have already happened in close and is redundant. */
        igb_release_hw_control(adapter);
 
        unregister_netdev(netdev);
 
-       if (!igb_check_reset_block(&adapter->hw))
-               adapter->hw.phy.ops.reset_phy(&adapter->hw);
+       if (!e1000_check_reset_block(hw))
+               e1000_phy_hw_reset(hw);
 
-       igb_remove_device(&adapter->hw);
        igb_reset_interrupt_capability(adapter);
 
-       kfree(adapter->tx_ring);
-       kfree(adapter->rx_ring);
+       igb_free_queues(adapter);
 
-       iounmap(adapter->hw.hw_addr);
-       if (adapter->hw.flash_address)
+       iounmap(hw->hw_addr);
+       if (hw->flash_address)
                iounmap(adapter->hw.flash_address);
-       pci_release_regions(pdev);
+       pci_release_selected_regions(pdev,
+                                    pci_select_bars(pdev, IORESOURCE_MEM));
 
        free_netdev(netdev);
 
@@ -1197,28 +1487,53 @@ static void __devexit igb_remove(struct pci_dev *pdev)
  * Fields are initialized based on PCI device information and
  * OS network device settings (MTU size).
  **/
+
 static int __devinit igb_sw_init(struct igb_adapter *adapter)
 {
        struct e1000_hw *hw = &adapter->hw;
        struct net_device *netdev = adapter->netdev;
        struct pci_dev *pdev = adapter->pdev;
 
+       /* PCI config space info */
+
+       hw->vendor_id = pdev->vendor;
+       hw->device_id = pdev->device;
+       hw->subsystem_vendor_id = pdev->subsystem_vendor;
+       hw->subsystem_device_id = pdev->subsystem_device;
+
+       pci_read_config_byte(pdev, PCI_REVISION_ID, &hw->revision_id);
+
        pci_read_config_word(pdev, PCI_COMMAND, &hw->bus.pci_cmd_word);
 
+       adapter->tx_ring_count = IGB_DEFAULT_TXD;
+       adapter->rx_ring_count = IGB_DEFAULT_RXD;
        adapter->rx_buffer_len = MAXIMUM_ETHERNET_VLAN_SIZE;
        adapter->rx_ps_hdr_size = 0; /* disable packet split */
        adapter->max_frame_size = netdev->mtu + ETH_HLEN + ETH_FCS_LEN;
        adapter->min_frame_size = ETH_ZLEN + ETH_FCS_LEN;
 
+       /* Initialize the hardware-specific values */
+       if (e1000_setup_init_funcs(hw, TRUE)) {
+               DPRINTK(PROBE, ERR, "Hardware Initialization Failure\n");
+               return -EIO;
+       }
+
        /* Number of supported queues. */
        /* Having more queues than CPUs doesn't make sense. */
+       adapter->num_rx_queues = min((u32)IGB_MAX_RX_QUEUES, (u32)num_online_cpus());
+#ifdef HAVE_TX_MQ
+       adapter->num_tx_queues = min(IGB_MAX_TX_QUEUES, num_online_cpus());
+#else
        adapter->num_tx_queues = 1;
-       adapter->num_rx_queues = min(IGB_MAX_RX_QUEUES, num_online_cpus());
+#endif
+
 
+       /* This call may decrease the number of queues depending on
+        * interrupt mode. */
        igb_set_interrupt_capability(adapter);
 
        if (igb_alloc_queues(adapter)) {
-               dev_err(&pdev->dev, "Unable to allocate memory for queues\n");
+               DPRINTK(PROBE, ERR, "Unable to allocate memory for queues\n");
                return -ENOMEM;
        }
 
@@ -1229,6 +1544,7 @@ static int __devinit igb_sw_init(struct igb_adapter *adapter)
        return 0;
 }
 
+
 /**
  * igb_open - Called when a network interface is made active
  * @netdev: network interface device structure
@@ -1241,11 +1557,13 @@ static int __devinit igb_sw_init(struct igb_adapter *adapter)
  * handler is registered with the OS, the watchdog timer is started,
  * and the stack is notified that the interface is ready.
  **/
+
 static int igb_open(struct net_device *netdev)
 {
        struct igb_adapter *adapter = netdev_priv(netdev);
        struct e1000_hw *hw = &adapter->hw;
        int err;
+       int i;
 
        /* disallow open during test */
        if (test_bit(__IGB_TESTING, &adapter->state))
@@ -1265,8 +1583,9 @@ static int igb_open(struct net_device *netdev)
 
        adapter->mng_vlan_id = IGB_MNG_VLAN_NONE;
        if ((adapter->hw.mng_cookie.status &
-            E1000_MNG_DHCP_COOKIE_STATUS_VLAN))
+            E1000_MNG_DHCP_COOKIE_STATUS_VLAN)) {
                igb_update_mng_vlan(adapter);
+       }
 
        /* before we allocate an interrupt, we must be ready to handle it.
         * Setting DEBUG_SHIRQ in the kernel makes it fire an interrupt
@@ -1281,16 +1600,21 @@ static int igb_open(struct net_device *netdev)
        /* From here on the code is the same as igb_up() */
        clear_bit(__IGB_DOWN, &adapter->state);
 
-       netif_poll_enable(netdev);
+       for (i = 0; i < adapter->num_rx_queues; i++)
+               napi_enable(&adapter->rx_ring[i].napi);
+       igb_configure_lli(adapter);
+
+       /* Clear any pending interrupts. */
+       E1000_READ_REG(hw, E1000_ICR);
 
        igb_irq_enable(adapter);
 
-       /* Clear any pending interrupts. */
-       rd32(E1000_ICR);
+       netif_tx_start_all_queues(netdev);
+
        /* Fire a link status change interrupt to start the watchdog. */
-       wr32(E1000_ICS, E1000_ICS_LSC);
+       E1000_WRITE_REG(hw, E1000_ICS, E1000_ICS_LSC);
 
-       return 0;
+       return E1000_SUCCESS;
 
 err_req_irq:
        igb_release_hw_control(adapter);
@@ -1300,7 +1624,6 @@ err_setup_rx:
        igb_free_all_tx_resources(adapter);
 err_setup_tx:
        igb_reset(adapter);
-
        return err;
 }
 
@@ -1315,6 +1638,7 @@ err_setup_tx:
  * needs to be disabled.  A global MAC reset is issued to stop the
  * hardware, and all transmit and receive resources are freed.
  **/
+
 static int igb_close(struct net_device *netdev)
 {
        struct igb_adapter *adapter = netdev_priv(netdev);
@@ -1347,7 +1671,7 @@ static int igb_close(struct net_device *netdev)
  **/
 
 int igb_setup_tx_resources(struct igb_adapter *adapter,
-                          struct igb_ring *tx_ring)
+                           struct igb_ring *tx_ring)
 {
        struct pci_dev *pdev = adapter->pdev;
        int size;
@@ -1360,11 +1684,11 @@ int igb_setup_tx_resources(struct igb_adapter *adapter,
 
        /* round up to nearest 4K */
        tx_ring->size = tx_ring->count * sizeof(struct e1000_tx_desc)
-                       + sizeof(u32);
+                       + sizeof(u32);
        tx_ring->size = ALIGN(tx_ring->size, 4096);
 
        tx_ring->desc = pci_alloc_consistent(pdev, tx_ring->size,
-                                            &tx_ring->dma);
+                                            &tx_ring->dma);
 
        if (!tx_ring->desc)
                goto err;
@@ -1372,40 +1696,47 @@ int igb_setup_tx_resources(struct igb_adapter *adapter,
        tx_ring->adapter = adapter;
        tx_ring->next_to_use = 0;
        tx_ring->next_to_clean = 0;
-       spin_lock_init(&tx_ring->tx_clean_lock);
-       spin_lock_init(&tx_ring->tx_lock);
        return 0;
 
 err:
        vfree(tx_ring->buffer_info);
-       dev_err(&adapter->pdev->dev,
-               "Unable to allocate memory for the transmit descriptor ring\n");
+       DPRINTK(PROBE, ERR, "Unable to allocate memory for the transmit "
+               "descriptor ring\n");
        return -ENOMEM;
 }
 
 /**
  * igb_setup_all_tx_resources - wrapper to allocate Tx resources
- *                               (Descriptors) for all queues
+ *                               (Descriptors) for all queues
  * @adapter: board private structure
  *
  * Return 0 on success, negative on failure
  **/
+
 static int igb_setup_all_tx_resources(struct igb_adapter *adapter)
 {
        int i, err = 0;
+#ifdef HAVE_TX_MQ
+       int r_idx;
+#endif
 
        for (i = 0; i < adapter->num_tx_queues; i++) {
                err = igb_setup_tx_resources(adapter, &adapter->tx_ring[i]);
                if (err) {
-                       dev_err(&adapter->pdev->dev,
+                       DPRINTK(PROBE, ERR,
                                "Allocation for Tx Queue %u failed\n", i);
                        for (i--; i >= 0; i--)
-                               igb_free_tx_resources(adapter,
-                                                       &adapter->tx_ring[i]);
+                               igb_free_tx_resources(&adapter->tx_ring[i]);
                        break;
                }
        }
 
+#ifdef HAVE_TX_MQ
+       for (i = 0; i < IGB_ABS_MAX_TX_QUEUES; i++) {
+               r_idx = i % adapter->num_tx_queues;
+               adapter->multi_tx_table[i] = &adapter->tx_ring[r_idx];
+       }
+#endif
        return err;
 }
 
@@ -1415,6 +1746,7 @@ static int igb_setup_all_tx_resources(struct igb_adapter *adapter)
  *
  * Configure the Tx unit of the MAC after a reset.
  **/
+
 static void igb_configure_tx(struct igb_adapter *adapter)
 {
        u64 tdba, tdwba;
@@ -1426,48 +1758,46 @@ static void igb_configure_tx(struct igb_adapter *adapter)
        for (i = 0; i < adapter->num_tx_queues; i++) {
                struct igb_ring *ring = &(adapter->tx_ring[i]);
 
-               wr32(E1000_TDLEN(i),
-                               ring->count * sizeof(struct e1000_tx_desc));
+               E1000_WRITE_REG(hw, E1000_TDLEN(i),
+                               ring->count * sizeof(struct e1000_tx_desc));
                tdba = ring->dma;
-               wr32(E1000_TDBAL(i),
-                               tdba & 0x00000000ffffffffULL);
-               wr32(E1000_TDBAH(i), tdba >> 32);
+               E1000_WRITE_REG(hw, E1000_TDBAL(i),
+                               tdba & 0x00000000ffffffffULL);
+               E1000_WRITE_REG(hw, E1000_TDBAH(i), tdba >> 32);
 
                tdwba = ring->dma + ring->count * sizeof(struct e1000_tx_desc);
                tdwba |= 1; /* enable head wb */
-               wr32(E1000_TDWBAL(i),
-                               tdwba & 0x00000000ffffffffULL);
-               wr32(E1000_TDWBAH(i), tdwba >> 32);
+               E1000_WRITE_REG(hw, E1000_TDWBAL(i),
+                               tdwba & 0x00000000ffffffffULL);
+               E1000_WRITE_REG(hw, E1000_TDWBAH(i), tdwba >> 32);
 
                ring->head = E1000_TDH(i);
                ring->tail = E1000_TDT(i);
                writel(0, hw->hw_addr + ring->tail);
                writel(0, hw->hw_addr + ring->head);
-               txdctl = rd32(E1000_TXDCTL(i));
+               txdctl = E1000_READ_REG(hw, E1000_TXDCTL(i));
                txdctl |= E1000_TXDCTL_QUEUE_ENABLE;
-               wr32(E1000_TXDCTL(i), txdctl);
+               E1000_WRITE_REG(hw, E1000_TXDCTL(i), txdctl);
 
-               /* Turn off Relaxed Ordering on head write-backs.  The
-                * writebacks MUST be delivered in order or it will
-                * completely screw up our bookeeping.
+               /* Turn off Relaxed Ordering on head write-backs.  The writebacks
+                * MUST be delivered in order or it will completely screw up
+                * our bookeeping.
                 */
-               txctrl = rd32(E1000_DCA_TXCTRL(i));
+               txctrl = E1000_READ_REG(hw, E1000_DCA_TXCTRL(i));
                txctrl &= ~E1000_DCA_TXCTRL_TX_WB_RO_EN;
-               wr32(E1000_DCA_TXCTRL(i), txctrl);
+               E1000_WRITE_REG(hw, E1000_DCA_TXCTRL(i), txctrl);
        }
 
-
-
        /* Use the default values for the Tx Inter Packet Gap (IPG) timer */
 
        /* Program the Transmit Control Register */
 
-       tctl = rd32(E1000_TCTL);
+       tctl = E1000_READ_REG(hw, E1000_TCTL);
        tctl &= ~E1000_TCTL_CT;
        tctl |= E1000_TCTL_PSP | E1000_TCTL_RTLC |
                (E1000_COLLISION_THRESHOLD << E1000_CT_SHIFT);
 
-       igb_config_collision_dist(hw);
+       e1000_config_collision_dist(hw);
 
        /* Setup Transmit Descriptor Settings for eop descriptor */
        adapter->txd_cmd = E1000_TXD_CMD_EOP | E1000_TXD_CMD_RS;
@@ -1475,7 +1805,7 @@ static void igb_configure_tx(struct igb_adapter *adapter)
        /* Enable transmits */
        tctl |= E1000_TCTL_EN;
 
-       wr32(E1000_TCTL, tctl);
+       E1000_WRITE_REG(hw, E1000_TCTL, tctl);
 }
 
 /**
@@ -1487,11 +1817,19 @@ static void igb_configure_tx(struct igb_adapter *adapter)
  **/
 
 int igb_setup_rx_resources(struct igb_adapter *adapter,
-                          struct igb_ring *rx_ring)
+                           struct igb_ring *rx_ring)
 {
        struct pci_dev *pdev = adapter->pdev;
        int size, desc_len;
 
+#ifdef IGB_LRO
+       size = sizeof(struct net_lro_desc) * MAX_LRO_DESCRIPTORS;
+       rx_ring->lro_mgr.lro_arr = vmalloc(size);
+       if (!rx_ring->lro_mgr.lro_arr)
+               goto err;
+       memset(rx_ring->lro_mgr.lro_arr, 0, size);
+
+#endif /* IGB_LRO */
        size = sizeof(struct igb_buffer) * rx_ring->count;
        rx_ring->buffer_info = vmalloc(size);
        if (!rx_ring->buffer_info)
@@ -1505,37 +1843,37 @@ int igb_setup_rx_resources(struct igb_adapter *adapter,
        rx_ring->size = ALIGN(rx_ring->size, 4096);
 
        rx_ring->desc = pci_alloc_consistent(pdev, rx_ring->size,
-                                            &rx_ring->dma);
+                                            &rx_ring->dma);
 
        if (!rx_ring->desc)
                goto err;
 
        rx_ring->next_to_clean = 0;
        rx_ring->next_to_use = 0;
-       rx_ring->pending_skb = NULL;
 
        rx_ring->adapter = adapter;
-       rx_ring->netdev->priv = rx_ring;
-       rx_ring->netdev->poll = adapter->netdev->poll;
-       rx_ring->netdev->weight = 64;
-       set_bit(__LINK_STATE_START, &rx_ring->netdev->state);
-
        return 0;
 
 err:
+#ifdef IGB_LRO
+       vfree(rx_ring->lro_mgr.lro_arr);
+       rx_ring->lro_mgr.lro_arr = NULL;
+#endif
        vfree(rx_ring->buffer_info);
-       dev_err(&adapter->pdev->dev, "Unable to allocate memory for "
-               "the receive descriptor ring\n");
+       rx_ring->buffer_info = NULL;
+       DPRINTK(PROBE, ERR, "Unable to allocate memory for the receive "
+               "descriptor ring\n");
        return -ENOMEM;
 }
 
 /**
  * igb_setup_all_rx_resources - wrapper to allocate Rx resources
- *                               (Descriptors) for all queues
+ *                               (Descriptors) for all queues
  * @adapter: board private structure
  *
  * Return 0 on success, negative on failure
  **/
+
 static int igb_setup_all_rx_resources(struct igb_adapter *adapter)
 {
        int i, err = 0;
@@ -1543,11 +1881,10 @@ static int igb_setup_all_rx_resources(struct igb_adapter *adapter)
        for (i = 0; i < adapter->num_rx_queues; i++) {
                err = igb_setup_rx_resources(adapter, &adapter->rx_ring[i]);
                if (err) {
-                       dev_err(&adapter->pdev->dev,
+                       DPRINTK(PROBE, ERR,
                                "Allocation for Rx Queue %u failed\n", i);
                        for (i--; i >= 0; i--)
-                               igb_free_rx_resources(adapter,
-                                                       &adapter->rx_ring[i]);
+                               igb_free_rx_resources(&adapter->rx_ring[i]);
                        break;
                }
        }
@@ -1566,18 +1903,20 @@ static void igb_setup_rctl(struct igb_adapter *adapter)
        u32 srrctl = 0;
        int i;
 
-       rctl = rd32(E1000_RCTL);
+       rctl = E1000_READ_REG(hw, E1000_RCTL);
 
        rctl &= ~(3 << E1000_RCTL_MO_SHIFT);
 
        rctl |= E1000_RCTL_EN | E1000_RCTL_BAM |
                E1000_RCTL_LBM_NO | E1000_RCTL_RDMTS_HALF |
-               (adapter->hw.mac.mc_filter_type << E1000_RCTL_MO_SHIFT);
+               (hw->mac.mc_filter_type << E1000_RCTL_MO_SHIFT);
 
-       /* disable the stripping of CRC because it breaks
-        * BMC firmware connected over SMBUS
+       /*
+        * enable stripping of CRC. It's unlikely this will break BMC
+        * redirection as it did with e1000. Newer features require
+        * that the HW strips the CRC.
+        */
        rctl |= E1000_RCTL_SECRC;
-       */
 
        rctl &= ~E1000_RCTL_SBP;
 
@@ -1585,43 +1924,36 @@ static void igb_setup_rctl(struct igb_adapter *adapter)
                rctl &= ~E1000_RCTL_LPE;
        else
                rctl |= E1000_RCTL_LPE;
+
        if (adapter->rx_buffer_len <= IGB_RXBUFFER_2048) {
                /* Setup buffer sizes */
                rctl &= ~E1000_RCTL_SZ_4096;
                rctl |= E1000_RCTL_BSEX;
                switch (adapter->rx_buffer_len) {
-               case IGB_RXBUFFER_256:
-                       rctl |= E1000_RCTL_SZ_256;
-                       rctl &= ~E1000_RCTL_BSEX;
-                       break;
-               case IGB_RXBUFFER_512:
-                       rctl |= E1000_RCTL_SZ_512;
-                       rctl &= ~E1000_RCTL_BSEX;
-                       break;
-               case IGB_RXBUFFER_1024:
-                       rctl |= E1000_RCTL_SZ_1024;
-                       rctl &= ~E1000_RCTL_BSEX;
-                       break;
-               case IGB_RXBUFFER_2048:
-               default:
-                       rctl |= E1000_RCTL_SZ_2048;
-                       rctl &= ~E1000_RCTL_BSEX;
-                       break;
-               case IGB_RXBUFFER_4096:
-                       rctl |= E1000_RCTL_SZ_4096;
-                       break;
-               case IGB_RXBUFFER_8192:
-                       rctl |= E1000_RCTL_SZ_8192;
-                       break;
-               case IGB_RXBUFFER_16384:
-                       rctl |= E1000_RCTL_SZ_16384;
-                       break;
+                       case IGB_RXBUFFER_256:
+                               rctl |= E1000_RCTL_SZ_256;
+                               rctl &= ~E1000_RCTL_BSEX;
+                               break;
+                       case IGB_RXBUFFER_512:
+                               rctl |= E1000_RCTL_SZ_512;
+                               rctl &= ~E1000_RCTL_BSEX;
+                               break;
+                       case IGB_RXBUFFER_1024:
+                               rctl |= E1000_RCTL_SZ_1024;
+                               rctl &= ~E1000_RCTL_BSEX;
+                               break;
+                       case IGB_RXBUFFER_2048:
+                       default:
+                               rctl |= E1000_RCTL_SZ_2048;
+                               rctl &= ~E1000_RCTL_BSEX;
+                               break;
                }
        } else {
                rctl &= ~E1000_RCTL_BSEX;
                srrctl = adapter->rx_buffer_len >> E1000_SRRCTL_BSIZEPKT_SHIFT;
        }
 
+#ifndef CONFIG_IGB_DISABLE_PACKET_SPLIT
        /* 82575 and greater support packet-split where the protocol
         * header is placed in skb->data and the packet data is
         * placed in pages hanging off of skb_shinfo(skb)->nr_frags.
@@ -1633,20 +1965,22 @@ static void igb_setup_rctl(struct igb_adapter *adapter)
         * so only enable packet split for jumbo frames */
        if (rctl & E1000_RCTL_LPE) {
                adapter->rx_ps_hdr_size = IGB_RXBUFFER_128;
-               srrctl = adapter->rx_ps_hdr_size <<
-                        E1000_SRRCTL_BSIZEHDRSIZE_SHIFT;
-               /* buffer size is ALWAYS one page */
-               srrctl |= PAGE_SIZE >> E1000_SRRCTL_BSIZEPKT_SHIFT;
+               srrctl |= adapter->rx_ps_hdr_size <<
+                        E1000_SRRCTL_BSIZEHDRSIZE_SHIFT;
                srrctl |= E1000_SRRCTL_DESCTYPE_HDR_SPLIT_ALWAYS;
        } else {
+#endif /* CONFIG_IGB_DISABLE_PACKET_SPLIT */
                adapter->rx_ps_hdr_size = 0;
                srrctl |= E1000_SRRCTL_DESCTYPE_ADV_ONEBUF;
+#ifndef CONFIG_IGB_DISABLE_PACKET_SPLIT
        }
+#endif /* CONFIG_IGB_DISABLE_PACKET_SPLIT */
 
-       for (i = 0; i < adapter->num_rx_queues; i++)
-               wr32(E1000_SRRCTL(i), srrctl);
+       for (i = 0; i < adapter->num_rx_queues; i++) {
+               E1000_WRITE_REG(hw, E1000_SRRCTL(i), srrctl);
+       }
 
-       wr32(E1000_RCTL, rctl);
+       E1000_WRITE_REG(hw, E1000_RCTL, rctl);
 }
 
 /**
@@ -1655,6 +1989,7 @@ static void igb_setup_rctl(struct igb_adapter *adapter)
  *
  * Configure the Rx unit of the MAC after a reset.
  **/
+
 static void igb_configure_rx(struct igb_adapter *adapter)
 {
        u64 rdba;
@@ -1664,38 +1999,48 @@ static void igb_configure_rx(struct igb_adapter *adapter)
        int i;
 
        /* disable receives while setting up the descriptors */
-       rctl = rd32(E1000_RCTL);
-       wr32(E1000_RCTL, rctl & ~E1000_RCTL_EN);
-       wrfl();
+       rctl = E1000_READ_REG(hw, E1000_RCTL);
+       E1000_WRITE_REG(hw, E1000_RCTL, rctl & ~E1000_RCTL_EN);
+       E1000_WRITE_FLUSH(hw);
        mdelay(10);
 
-       if (adapter->itr_setting > 3)
-               wr32(E1000_ITR,
-                               1000000000 / (adapter->itr * 256));
-
+       if (adapter->itr_setting > 3) {
+               E1000_WRITE_REG(hw, E1000_ITR, adapter->itr);
+       }
        /* Setup the HW Rx Head and Tail Descriptor Pointers and
         * the Base and Length of the Rx Descriptor Ring */
        for (i = 0; i < adapter->num_rx_queues; i++) {
                struct igb_ring *ring = &(adapter->rx_ring[i]);
                rdba = ring->dma;
-               wr32(E1000_RDBAL(i),
-                               rdba & 0x00000000ffffffffULL);
-               wr32(E1000_RDBAH(i), rdba >> 32);
-               wr32(E1000_RDLEN(i),
-                              ring->count * sizeof(union e1000_adv_rx_desc));
+               E1000_WRITE_REG(hw, E1000_RDBAL(i),
+                               rdba & 0x00000000ffffffffULL);
+               E1000_WRITE_REG(hw, E1000_RDBAH(i), rdba >> 32);
+               E1000_WRITE_REG(hw, E1000_RDLEN(i),
+                              ring->count * sizeof(union e1000_adv_rx_desc));
 
                ring->head = E1000_RDH(i);
                ring->tail = E1000_RDT(i);
                writel(0, hw->hw_addr + ring->tail);
                writel(0, hw->hw_addr + ring->head);
 
-               rxdctl = rd32(E1000_RXDCTL(i));
+               rxdctl = E1000_READ_REG(hw, E1000_RXDCTL(i));
                rxdctl |= E1000_RXDCTL_QUEUE_ENABLE;
                rxdctl &= 0xFFF00000;
                rxdctl |= IGB_RX_PTHRESH;
                rxdctl |= IGB_RX_HTHRESH << 8;
                rxdctl |= IGB_RX_WTHRESH << 16;
-               wr32(E1000_RXDCTL(i), rxdctl);
+               E1000_WRITE_REG(hw, E1000_RXDCTL(i), rxdctl);
+#ifdef IGB_LRO
+               /* Intitial LRO Settings */
+               ring->lro_mgr.max_aggr = adapter->lro_max_aggr;
+               ring->lro_mgr.max_desc = MAX_LRO_DESCRIPTORS;
+               ring->lro_mgr.get_skb_header = igb_get_skb_hdr;
+               ring->lro_mgr.features = LRO_F_NAPI | LRO_F_EXTRACT_VLAN_ID;
+               ring->lro_mgr.dev = adapter->netdev;
+               ring->lro_mgr.ip_summed = CHECKSUM_UNNECESSARY;
+               ring->lro_mgr.ip_summed_aggr = CHECKSUM_UNNECESSARY;
+#endif
+
        }
 
        if (adapter->num_rx_queues > 1) {
@@ -1707,65 +2052,65 @@ static void igb_configure_rx(struct igb_adapter *adapter)
                        u8  bytes[4];
                } reta;
 
+               /* ugh, using random bytes here means we'll never put the same
+                * flow in the same rx queue */
                get_random_bytes(&random[0], 40);
 
-               shift = 6;
+               if (hw->mac.type >= e1000_82576)
+                       shift = 0;
+               else
+                       shift = 6;
                for (j = 0; j < (32 * 4); j++) {
                        reta.bytes[j & 3] =
-                               (j % adapter->num_rx_queues) << shift;
-                       if ((j & 3) == 3)
+                               (j % adapter->num_rx_queues) << shift;
+                       if ((j & 3) == 3) {
                                writel(reta.dword,
                                       hw->hw_addr + E1000_RETA(0) + (j & ~3));
+                       }
                }
                mrqc = E1000_MRQC_ENABLE_RSS_4Q;
 
                /* Fill out hash function seeds */
                for (j = 0; j < 10; j++)
-                       array_wr32(E1000_RSSRK(0), j, random[j]);
+                       E1000_WRITE_REG_ARRAY(hw, E1000_RSSRK(0), j, random[j]);
 
                mrqc |= (E1000_MRQC_RSS_FIELD_IPV4 |
                         E1000_MRQC_RSS_FIELD_IPV4_TCP);
                mrqc |= (E1000_MRQC_RSS_FIELD_IPV6 |
                         E1000_MRQC_RSS_FIELD_IPV6_TCP);
-               mrqc |= (E1000_MRQC_RSS_FIELD_IPV4_UDP |
-                        E1000_MRQC_RSS_FIELD_IPV6_UDP);
-               mrqc |= (E1000_MRQC_RSS_FIELD_IPV6_UDP_EX |
-                        E1000_MRQC_RSS_FIELD_IPV6_TCP_EX);
+               mrqc |=E1000_MRQC_RSS_FIELD_IPV4_UDP |
+                       E1000_MRQC_RSS_FIELD_IPV6_UDP);
+               mrqc |=E1000_MRQC_RSS_FIELD_IPV6_UDP_EX |
+                       E1000_MRQC_RSS_FIELD_IPV6_TCP_EX);
 
 
-               wr32(E1000_MRQC, mrqc);
+               E1000_WRITE_REG(hw, E1000_MRQC, mrqc);
 
                /* Multiqueue and raw packet checksumming are mutually
                 * exclusive.  Note that this not the same as TCP/IP
                 * checksumming, which works fine. */
-               rxcsum = rd32(E1000_RXCSUM);
+               rxcsum = E1000_READ_REG(hw, E1000_RXCSUM);
                rxcsum |= E1000_RXCSUM_PCSD;
-               wr32(E1000_RXCSUM, rxcsum);
+               E1000_WRITE_REG(hw, E1000_RXCSUM, rxcsum);
        } else {
                /* Enable Receive Checksum Offload for TCP and UDP */
-               rxcsum = rd32(E1000_RXCSUM);
-               if (adapter->rx_csum) {
-                       rxcsum |= E1000_RXCSUM_TUOFL;
-
-                       /* Enable IPv4 payload checksum for UDP fragments
-                        * Must be used in conjunction with packet-split. */
-                       if (adapter->rx_ps_hdr_size)
-                               rxcsum |= E1000_RXCSUM_IPPCSE;
-               } else {
+               rxcsum = E1000_READ_REG(hw, E1000_RXCSUM);
+               if (adapter->rx_csum)
+                       rxcsum |= E1000_RXCSUM_TUOFL | E1000_RXCSUM_IPPCSE;
+               else
                        rxcsum &= ~E1000_RXCSUM_TUOFL;
                        /* don't need to clear IPPCSE as it defaults to 0 */
-               }
-               wr32(E1000_RXCSUM, rxcsum);
+               E1000_WRITE_REG(hw, E1000_RXCSUM, rxcsum);
        }
 
        if (adapter->vlgrp)
-               wr32(E1000_RLPML,
-                               adapter->max_frame_size + VLAN_TAG_SIZE);
+               E1000_WRITE_REG(hw, E1000_RLPML,
+                               adapter->max_frame_size + VLAN_TAG_SIZE);
        else
-               wr32(E1000_RLPML, adapter->max_frame_size);
+               E1000_WRITE_REG(hw, E1000_RLPML, adapter->max_frame_size);
 
        /* Enable Receives */
-       wr32(E1000_RCTL, rctl);
+       E1000_WRITE_REG(hw, E1000_RCTL, rctl);
 }
 
 /**
@@ -1775,12 +2120,12 @@ static void igb_configure_rx(struct igb_adapter *adapter)
  *
  * Free all transmit software resources
  **/
-static void igb_free_tx_resources(struct igb_adapter *adapter,
-                                 struct igb_ring *tx_ring)
+
+void igb_free_tx_resources(struct igb_ring *tx_ring)
 {
-       struct pci_dev *pdev = adapter->pdev;
+       struct pci_dev *pdev = tx_ring->adapter->pdev;
 
-       igb_clean_tx_ring(adapter, tx_ring);
+       igb_clean_tx_ring(tx_ring);
 
        vfree(tx_ring->buffer_info);
        tx_ring->buffer_info = NULL;
@@ -1796,16 +2141,17 @@ static void igb_free_tx_resources(struct igb_adapter *adapter,
  *
  * Free all transmit software resources
  **/
+
 static void igb_free_all_tx_resources(struct igb_adapter *adapter)
 {
        int i;
 
        for (i = 0; i < adapter->num_tx_queues; i++)
-               igb_free_tx_resources(adapter, &adapter->tx_ring[i]);
+               igb_free_tx_resources(&adapter->tx_ring[i]);
 }
 
 static void igb_unmap_and_free_tx_resource(struct igb_adapter *adapter,
-                                          struct igb_buffer *buffer_info)
+                                           struct igb_buffer *buffer_info)
 {
        if (buffer_info->dma) {
                pci_unmap_page(adapter->pdev,
@@ -1827,9 +2173,10 @@ static void igb_unmap_and_free_tx_resource(struct igb_adapter *adapter,
  * @adapter: board private structure
  * @tx_ring: ring to be cleaned
  **/
-static void igb_clean_tx_ring(struct igb_adapter *adapter,
-                             struct igb_ring *tx_ring)
+
+static void igb_clean_tx_ring(struct igb_ring *tx_ring)
 {
+       struct igb_adapter *adapter = tx_ring->adapter;
        struct igb_buffer *buffer_info;
        unsigned long size;
        unsigned int i;
@@ -1861,12 +2208,13 @@ static void igb_clean_tx_ring(struct igb_adapter *adapter,
  * igb_clean_all_tx_rings - Free Tx Buffers for all queues
  * @adapter: board private structure
  **/
+
 static void igb_clean_all_tx_rings(struct igb_adapter *adapter)
 {
        int i;
 
        for (i = 0; i < adapter->num_tx_queues; i++)
-               igb_clean_tx_ring(adapter, &adapter->tx_ring[i]);
+               igb_clean_tx_ring(&adapter->tx_ring[i]);
 }
 
 /**
@@ -1876,16 +2224,21 @@ static void igb_clean_all_tx_rings(struct igb_adapter *adapter)
  *
  * Free all receive software resources
  **/
-static void igb_free_rx_resources(struct igb_adapter *adapter,
-                                 struct igb_ring *rx_ring)
+
+void igb_free_rx_resources(struct igb_ring *rx_ring)
 {
-       struct pci_dev *pdev = adapter->pdev;
+       struct pci_dev *pdev = rx_ring->adapter->pdev;
 
-       igb_clean_rx_ring(adapter, rx_ring);
+       igb_clean_rx_ring(rx_ring);
 
        vfree(rx_ring->buffer_info);
        rx_ring->buffer_info = NULL;
 
+#ifdef IGB_LRO
+       vfree(rx_ring->lro_mgr.lro_arr);
+       rx_ring->lro_mgr.lro_arr = NULL;
+#endif /* IGB_LRO */
+
        pci_free_consistent(pdev, rx_ring->size, rx_ring->desc, rx_ring->dma);
 
        rx_ring->desc = NULL;
@@ -1897,14 +2250,13 @@ static void igb_free_rx_resources(struct igb_adapter *adapter,
  *
  * Free all receive software resources
  **/
+
 static void igb_free_all_rx_resources(struct igb_adapter *adapter)
 {
        int i;
 
-       for (i = 0; i < adapter->num_rx_queues; i++) {
-               igb_free_rx_resources(adapter, &adapter->rx_ring[i]);
-               dev_put(adapter->rx_ring[i].netdev);
-       }
+       for (i = 0; i < adapter->num_rx_queues; i++)
+               igb_free_rx_resources(&adapter->rx_ring[i]);
 }
 
 /**
@@ -1912,9 +2264,10 @@ static void igb_free_all_rx_resources(struct igb_adapter *adapter)
  * @adapter: board private structure
  * @rx_ring: ring to free buffers from
  **/
-static void igb_clean_rx_ring(struct igb_adapter *adapter,
-                             struct igb_ring *rx_ring)
+
+static void igb_clean_rx_ring(struct igb_ring *rx_ring)
 {
+       struct igb_adapter *adapter = rx_ring->adapter;
        struct igb_buffer *buffer_info;
        struct pci_dev *pdev = adapter->pdev;
        unsigned long size;
@@ -1926,14 +2279,15 @@ static void igb_clean_rx_ring(struct igb_adapter *adapter,
        for (i = 0; i < rx_ring->count; i++) {
                buffer_info = &rx_ring->buffer_info[i];
                if (buffer_info->dma) {
-                       if (adapter->rx_ps_hdr_size)
+                       if (adapter->rx_ps_hdr_size){
                                pci_unmap_single(pdev, buffer_info->dma,
-                                                adapter->rx_ps_hdr_size,
-                                                PCI_DMA_FROMDEVICE);
-                       else
+                                                adapter->rx_ps_hdr_size,
+                                                PCI_DMA_FROMDEVICE);
+                       } else {
                                pci_unmap_single(pdev, buffer_info->dma,
-                                                adapter->rx_buffer_len,
-                                                PCI_DMA_FROMDEVICE);
+                                                adapter->rx_buffer_len,
+                                                PCI_DMA_FROMDEVICE);
+                       }
                        buffer_info->dma = 0;
                }
 
@@ -1941,19 +2295,18 @@ static void igb_clean_rx_ring(struct igb_adapter *adapter,
                        dev_kfree_skb(buffer_info->skb);
                        buffer_info->skb = NULL;
                }
+#ifndef CONFIG_IGB_DISABLE_PACKET_SPLIT
                if (buffer_info->page) {
-                       pci_unmap_page(pdev, buffer_info->page_dma,
-                                      PAGE_SIZE, PCI_DMA_FROMDEVICE);
+                       if (buffer_info->page_dma)
+                               pci_unmap_page(pdev, buffer_info->page_dma,
+                                              PAGE_SIZE / 2,
+                                              PCI_DMA_FROMDEVICE);
                        put_page(buffer_info->page);
                        buffer_info->page = NULL;
                        buffer_info->page_dma = 0;
+                       buffer_info->page_offset = 0;
                }
-       }
-
-       /* there also may be some cached data from a chained receive */
-       if (rx_ring->pending_skb) {
-               dev_kfree_skb(rx_ring->pending_skb);
-               rx_ring->pending_skb = NULL;
+#endif
        }
 
        size = sizeof(struct igb_buffer) * rx_ring->count;
@@ -1973,12 +2326,13 @@ static void igb_clean_rx_ring(struct igb_adapter *adapter,
  * igb_clean_all_rx_rings - Free Rx Buffers for all queues
  * @adapter: board private structure
  **/
+
 static void igb_clean_all_rx_rings(struct igb_adapter *adapter)
 {
        int i;
 
        for (i = 0; i < adapter->num_rx_queues; i++)
-               igb_clean_rx_ring(adapter, &adapter->rx_ring[i]);
+               igb_clean_rx_ring(&adapter->rx_ring[i]);
 }
 
 /**
@@ -1988,18 +2342,20 @@ static void igb_clean_all_rx_rings(struct igb_adapter *adapter)
  *
  * Returns 0 on success, negative on failure
  **/
+
 static int igb_set_mac(struct net_device *netdev, void *p)
 {
        struct igb_adapter *adapter = netdev_priv(netdev);
+       struct e1000_hw *hw = &adapter->hw;
        struct sockaddr *addr = p;
 
        if (!is_valid_ether_addr(addr->sa_data))
                return -EADDRNOTAVAIL;
 
        memcpy(netdev->dev_addr, addr->sa_data, netdev->addr_len);
-       memcpy(adapter->hw.mac.addr, addr->sa_data, netdev->addr_len);
+       memcpy(hw->mac.addr, addr->sa_data, netdev->addr_len);
 
-       adapter->hw.mac.ops.rar_set(&adapter->hw, adapter->hw.mac.addr, 0);
+       e1000_rar_set(hw, hw->mac.addr, 0);
 
        return 0;
 }
@@ -2013,6 +2369,7 @@ static int igb_set_mac(struct net_device *netdev, void *p)
  * responsible for configuring the hardware for proper multicast,
  * promiscuous mode, and all-multi behavior.
  **/
+
 static void igb_set_multi(struct net_device *netdev)
 {
        struct igb_adapter *adapter = netdev_priv(netdev);
@@ -2025,22 +2382,25 @@ static void igb_set_multi(struct net_device *netdev)
 
        /* Check for Promiscuous and All Multicast modes */
 
-       rctl = rd32(E1000_RCTL);
+       rctl = E1000_READ_REG(hw, E1000_RCTL);
 
-       if (netdev->flags & IFF_PROMISC)
+       if (netdev->flags & IFF_PROMISC) {
                rctl |= (E1000_RCTL_UPE | E1000_RCTL_MPE);
-       else if (netdev->flags & IFF_ALLMULTI) {
-               rctl |= E1000_RCTL_MPE;
-               rctl &= ~E1000_RCTL_UPE;
-       } else
-               rctl &= ~(E1000_RCTL_UPE | E1000_RCTL_MPE);
-
-       wr32(E1000_RCTL, rctl);
+               rctl &= ~E1000_RCTL_VFE;
+       } else {
+               if (netdev->flags & IFF_ALLMULTI) {
+                       rctl |= E1000_RCTL_MPE;
+                       rctl &= ~E1000_RCTL_UPE;
+               } else
+                       rctl &= ~(E1000_RCTL_UPE | E1000_RCTL_MPE);
+               rctl |= E1000_RCTL_VFE;
+       }
+       E1000_WRITE_REG(hw, E1000_RCTL, rctl);
 
        if (!netdev->mc_count) {
                /* nothing to program, so clear mc list */
-               igb_update_mc_addr_list(hw, NULL, 0, 1,
-                                         mac->rar_entry_count);
+               e1000_update_mc_addr_list(hw, NULL, 0, 1,
+                                         mac->rar_entry_count);
                return;
        }
 
@@ -2057,17 +2417,58 @@ static void igb_set_multi(struct net_device *netdev)
                memcpy(mta_list + (i*ETH_ALEN), mc_ptr->dmi_addr, ETH_ALEN);
                mc_ptr = mc_ptr->next;
        }
-       igb_update_mc_addr_list(hw, mta_list, i, 1, mac->rar_entry_count);
+       e1000_update_mc_addr_list(hw, mta_list, i, 1, mac->rar_entry_count);
        kfree(mta_list);
 }
 
 /* Need to wait a few seconds after link up to get diagnostic information from
  * the phy */
+
 static void igb_update_phy_info(unsigned long data)
 {
        struct igb_adapter *adapter = (struct igb_adapter *) data;
-       if (adapter->hw.phy.ops.get_phy_info)
-               adapter->hw.phy.ops.get_phy_info(&adapter->hw);
+       e1000_get_phy_info(&adapter->hw);
+}
+
+/**
+ * igb_has_link - check shared code for link and determine up/down
+ * @adapter: pointer to driver private info
+ **/
+static bool igb_has_link(struct igb_adapter *adapter)
+{
+       struct e1000_hw *hw = &adapter->hw;
+       bool link_active = FALSE;
+       s32 ret_val = 0;
+
+       /* get_link_status is set on LSC (link status) interrupt or
+        * rx sequence error interrupt.  get_link_status will stay
+        * false until the e1000_check_for_link establishes link
+        * for copper adapters ONLY
+        */
+       switch (hw->phy.media_type) {
+       case e1000_media_type_copper:
+               if (hw->mac.get_link_status) {
+                       ret_val = e1000_check_for_link(hw);
+                       link_active = !hw->mac.get_link_status;
+               } else {
+                       link_active = TRUE;
+               }
+               break;
+       case e1000_media_type_fiber:
+               ret_val = e1000_check_for_link(hw);
+               link_active = !!(E1000_READ_REG(hw, E1000_STATUS) &
+                                E1000_STATUS_LU);
+               break;
+       case e1000_media_type_internal_serdes:
+               ret_val = e1000_check_for_link(hw);
+               link_active = adapter->hw.mac.serdes_has_link;
+               break;
+       default:
+       case e1000_media_type_unknown:
+               break;
+       }
+
+       return link_active;
 }
 
 /**
@@ -2081,52 +2482,37 @@ static void igb_watchdog(unsigned long data)
        schedule_work(&adapter->watchdog_task);
 }
 
-static void igb_watchdog_task(struct igb_adapter *adapter)
+static void igb_watchdog_task(struct work_struct *work)
 {
+       struct igb_adapter *adapter = container_of(work,
+                                       struct igb_adapter, watchdog_task);
        struct e1000_hw *hw = &adapter->hw;
-       struct net_device *netdev = adapter->netdev;
        struct igb_ring *tx_ring = adapter->tx_ring;
-       struct e1000_mac_info *mac = &adapter->hw.mac;
+       struct net_device *netdev = adapter->netdev;
        u32 link;
-       s32 ret_val;
+       u32 eics = 0;
+       int i;
 
-       if ((netif_carrier_ok(netdev)) &&
-           (rd32(E1000_STATUS) & E1000_STATUS_LU))
+       link = igb_has_link(adapter);
+       if ((netif_carrier_ok(netdev)) && link)
                goto link_up;
 
-       ret_val = hw->mac.ops.check_for_link(&adapter->hw);
-       if ((ret_val == E1000_ERR_PHY) &&
-           (hw->phy.type == e1000_phy_igp_3) &&
-           (rd32(E1000_CTRL) &
-            E1000_PHY_CTRL_GBE_DISABLE))
-               dev_info(&adapter->pdev->dev,
-                        "Gigabit has been disabled, downgrading speed\n");
-
-       if ((hw->phy.media_type == e1000_media_type_internal_serdes) &&
-           !(rd32(E1000_TXCW) & E1000_TXCW_ANE))
-               link = mac->serdes_has_link;
-       else
-               link = rd32(E1000_STATUS) &
-                                     E1000_STATUS_LU;
-
        if (link) {
                if (!netif_carrier_ok(netdev)) {
                        u32 ctrl;
-                       hw->mac.ops.get_speed_and_duplex(&adapter->hw,
-                                                  &adapter->link_speed,
-                                                  &adapter->link_duplex);
-
-                       ctrl = rd32(E1000_CTRL);
-                       dev_info(&adapter->pdev->dev,
-                                "NIC Link is Up %d Mbps %s, "
-                                "Flow Control: %s\n",
-                                adapter->link_speed,
-                                adapter->link_duplex == FULL_DUPLEX ?
-                                "Full Duplex" : "Half Duplex",
-                                ((ctrl & E1000_CTRL_TFCE) && (ctrl &
-                                E1000_CTRL_RFCE)) ? "RX/TX" : ((ctrl &
-                                E1000_CTRL_RFCE) ? "RX" : ((ctrl &
-                                E1000_CTRL_TFCE) ? "TX" : "None")));
+                       e1000_get_speed_and_duplex(hw, &adapter->link_speed,
+                                                  &adapter->link_duplex);
+
+                       ctrl = E1000_READ_REG(hw, E1000_CTRL);
+                       DPRINTK(LINK, INFO, "NIC Link is Up %d Mbps %s, "
+                               "Flow Control: %s\n",
+                               adapter->link_speed,
+                               adapter->link_duplex == FULL_DUPLEX ?
+                               "Full Duplex" : "Half Duplex",
+                               ((ctrl & E1000_CTRL_TFCE) && (ctrl &
+                               E1000_CTRL_RFCE)) ? "RX/TX" : ((ctrl &
+                               E1000_CTRL_RFCE) ? "RX" : ((ctrl &
+                               E1000_CTRL_TFCE) ? "TX" : "None")));
 
                        /* tweak tx_queue_len according to speed/duplex and
                         * adjust the timeout factor */
@@ -2144,40 +2530,21 @@ static void igb_watchdog_task(struct igb_adapter *adapter)
                        }
 
                        netif_carrier_on(netdev);
-                       netif_wake_queue(netdev);
-
-                       if (!test_bit(__IGB_DOWN, &adapter->state))
-                               mod_timer(&adapter->phy_info_timer,
-                                         round_jiffies(jiffies + 2 * HZ));
+                       netif_tx_wake_all_queues(netdev);
                }
        } else {
                if (netif_carrier_ok(netdev)) {
                        adapter->link_speed = 0;
                        adapter->link_duplex = 0;
-                       dev_info(&adapter->pdev->dev, "NIC Link is Down\n");
+                       DPRINTK(LINK, INFO, "NIC Link is Down\n");
                        netif_carrier_off(netdev);
-                       netif_stop_queue(netdev);
-                       if (!test_bit(__IGB_DOWN, &adapter->state))
-                               mod_timer(&adapter->phy_info_timer,
-                                         round_jiffies(jiffies + 2 * HZ));
+                       netif_tx_stop_all_queues(netdev);
                }
        }
 
 link_up:
        igb_update_stats(adapter);
 
-       mac->tx_packet_delta = adapter->stats.tpt - adapter->tpt_old;
-       adapter->tpt_old = adapter->stats.tpt;
-       mac->collision_delta = adapter->stats.colc - adapter->colc_old;
-       adapter->colc_old = adapter->stats.colc;
-
-       adapter->gorc = adapter->stats.gorc - adapter->gorc_old;
-       adapter->gorc_old = adapter->stats.gorc;
-       adapter->gotc = adapter->stats.gotc - adapter->gotc_old;
-       adapter->gotc_old = adapter->stats.gotc;
-
-       igb_update_adaptive(&adapter->hw);
-
        if (!netif_carrier_ok(netdev)) {
                if (IGB_DESC_UNUSED(tx_ring) + 1 < tx_ring->count) {
                        /* We've lost link, so the controller stops DMA,
@@ -2190,15 +2557,21 @@ link_up:
        }
 
        /* Cause software interrupt to ensure rx ring is cleaned */
-       wr32(E1000_ICS, E1000_ICS_RXDMT0);
+       if (adapter->msix_entries) {
+               for (i = 0; i < adapter->num_rx_queues; i++)
+                       eics |= adapter->rx_ring[i].eims_value;
+               E1000_WRITE_REG(hw, E1000_EICS, eics);
+       } else {
+               E1000_WRITE_REG(hw, E1000_ICS, E1000_ICS_RXDMT0);
+       }
 
        /* Force detection of hung controller every watchdog period */
-       tx_ring->detect_tx_hung = true;
+       tx_ring->detect_tx_hung = TRUE;
 
        /* Reset the timer */
        if (!test_bit(__IGB_DOWN, &adapter->state))
                mod_timer(&adapter->watchdog_timer,
-                         round_jiffies(jiffies + 2 * HZ));
+                         round_jiffies(jiffies + 2 * HZ));
 }
 
 enum latency_range {
@@ -2209,37 +2582,66 @@ enum latency_range {
 };
 
 
-static void igb_lower_rx_eitr(struct igb_adapter *adapter,
-                             struct igb_ring *rx_ring)
+/**
+ * igb_update_ring_itr - update the dynamic ITR value based on packet size
+ *
+ *      Stores a new ITR value based on strictly on packet size.  This
+ *      algorithm is less sophisticated than that used in igb_update_itr,
+ *      due to the difficulty of synchronizing statistics across multiple
+ *      receive rings.  The divisors and thresholds used by this fuction
+ *      were determined based on theoretical maximum wire speed and testing
+ *      data, in order to minimize response time while increasing bulk
+ *      throughput.
+ *      This functionality is controlled by the InterruptThrottleRate module
+ *      parameter (see igb_param.c)
+ *      NOTE:  This function is called only when operating in a multiqueue
+ *             receive environment.
+ * @rx_ring: pointer to ring
+ **/
+static void igb_update_ring_itr(struct igb_ring *rx_ring)
 {
-       struct e1000_hw *hw = &adapter->hw;
-       int new_val;
+       int new_val = rx_ring->itr_val;
+       int avg_wire_size = 0;
+       struct igb_adapter *adapter = rx_ring->adapter;
 
-       new_val = rx_ring->itr_val / 2;
-       if (new_val < IGB_MIN_DYN_ITR)
-               new_val = IGB_MIN_DYN_ITR;
+       if (!rx_ring->total_packets)
+               goto clear_counts; /* no packets, so don't do anything */
 
-       if (new_val != rx_ring->itr_val) {
-               rx_ring->itr_val = new_val;
-               wr32(rx_ring->itr_register,
-                               1000000000 / (new_val * 256));
+       /* For non-gigabit speeds, just fix the interrupt rate at 4000
+        * ints/sec - ITR timer value of 120 ticks.
+        */
+       if (adapter->link_speed != SPEED_1000) {
+               new_val = 120;
+               goto set_itr_val;
        }
-}
-
-static void igb_raise_rx_eitr(struct igb_adapter *adapter,
-                             struct igb_ring *rx_ring)
-{
-       struct e1000_hw *hw = &adapter->hw;
-       int new_val;
-
-       new_val = rx_ring->itr_val * 2;
-       if (new_val > IGB_MAX_DYN_ITR)
-               new_val = IGB_MAX_DYN_ITR;
+       avg_wire_size = rx_ring->total_bytes / rx_ring->total_packets;
+       if (rx_ring->buddy && rx_ring->buddy->total_packets)
+               avg_wire_size = max(avg_wire_size,
+                                   (int)(rx_ring->buddy->total_bytes /
+                                         rx_ring->buddy->total_packets));
+       /* Add 24 bytes to size to account for CRC, preamble, and gap */
+       avg_wire_size += 24;
+
+       /* Don't starve jumbo frames */
+       avg_wire_size = min(avg_wire_size, 3000);
+
+       /* Give a little boost to mid-size frames */
+       if ((avg_wire_size > 300) && (avg_wire_size < 1200))
+               new_val = avg_wire_size / 3;
+       else
+               new_val = avg_wire_size / 2;
 
+set_itr_val:
        if (new_val != rx_ring->itr_val) {
                rx_ring->itr_val = new_val;
-               wr32(rx_ring->itr_register,
-                               1000000000 / (new_val * 256));
+               rx_ring->set_itr = 1;
+       }
+clear_counts:
+       rx_ring->total_bytes = 0;
+       rx_ring->total_packets = 0;
+       if (rx_ring->buddy) {
+               rx_ring->buddy->total_bytes = 0;
+               rx_ring->buddy->total_packets = 0;
        }
 }
 
@@ -2262,7 +2664,7 @@ static void igb_raise_rx_eitr(struct igb_adapter *adapter,
  * @bytes: the number of bytes during this measurement interval
  **/
 static unsigned int igb_update_itr(struct igb_adapter *adapter, u16 itr_setting,
-                                  int packets, int bytes)
+                                   int packets, int bytes)
 {
        unsigned int retval = itr_setting;
 
@@ -2274,8 +2676,9 @@ static unsigned int igb_update_itr(struct igb_adapter *adapter, u16 itr_setting,
                /* handle TSO and jumbo frames */
                if (bytes/packets > 8000)
                        retval = bulk_latency;
-               else if ((packets < 5) && (bytes > 512))
+               else if ((packets < 5) && (bytes > 512)) {
                        retval = low_latency;
+               }
                break;
        case low_latency:  /* 50 usec aka 20000 ints/s */
                if (bytes > 10000) {
@@ -2295,9 +2698,10 @@ static unsigned int igb_update_itr(struct igb_adapter *adapter, u16 itr_setting,
                break;
        case bulk_latency: /* 250 usec aka 4000 ints/s */
                if (bytes > 25000) {
-                       if (packets > 35)
+                       if (packets > 35) {
                                retval = low_latency;
-               } else if (bytes < 6000) {
+                       }
+               } else if (bytes < 1500) {
                        retval = low_latency;
                }
                break;
@@ -2307,8 +2711,7 @@ update_itr_done:
        return retval;
 }
 
-static void igb_set_itr(struct igb_adapter *adapter, u16 itr_register,
-                       int rx_only)
+static void igb_set_itr(struct igb_adapter *adapter)
 {
        u16 current_itr;
        u32 new_itr = adapter->itr;
@@ -2321,29 +2724,24 @@ static void igb_set_itr(struct igb_adapter *adapter, u16 itr_register,
        }
 
        adapter->rx_itr = igb_update_itr(adapter,
-                                   adapter->rx_itr,
-                                   adapter->rx_ring->total_packets,
-                                   adapter->rx_ring->total_bytes);
-       /* conservative mode (itr 3) eliminates the lowest_latency setting */
-       if (adapter->itr_setting == 3 && adapter->rx_itr == lowest_latency)
-               adapter->rx_itr = low_latency;
+                                   adapter->rx_itr,
+                                   adapter->rx_ring->total_packets,
+                                   adapter->rx_ring->total_bytes);
 
-       if (!rx_only) {
+       if (adapter->rx_ring->buddy) {
                adapter->tx_itr = igb_update_itr(adapter,
-                                           adapter->tx_itr,
-                                           adapter->tx_ring->total_packets,
-                                           adapter->tx_ring->total_bytes);
-               /* conservative mode (itr 3) eliminates the
-                * lowest_latency setting */
-               if (adapter->itr_setting == 3 &&
-                   adapter->tx_itr == lowest_latency)
-                       adapter->tx_itr = low_latency;
-
+                                           adapter->tx_itr,
+                                           adapter->tx_ring->total_packets,
+                                           adapter->tx_ring->total_bytes);
                current_itr = max(adapter->rx_itr, adapter->tx_itr);
        } else {
                current_itr = adapter->rx_itr;
        }
 
+       /* conservative mode (itr 3) eliminates the lowest_latency setting */
+       if (adapter->itr_setting == 3 && current_itr == lowest_latency)
+               current_itr = low_latency;
+
        switch (current_itr) {
        /* counts and packets in update_itr are dependent on these numbers */
        case lowest_latency:
@@ -2360,13 +2758,20 @@ static void igb_set_itr(struct igb_adapter *adapter, u16 itr_register,
        }
 
 set_itr_now:
+       adapter->rx_ring->total_bytes = 0;
+       adapter->rx_ring->total_packets = 0;
+       if (adapter->rx_ring->buddy) {
+               adapter->rx_ring->buddy->total_bytes = 0;
+               adapter->rx_ring->buddy->total_packets = 0;
+       }
+
        if (new_itr != adapter->itr) {
                /* this attempts to bias the interrupt rate towards Bulk
                 * by adding intermediate steps when interrupt rate is
                 * increasing */
                new_itr = new_itr > adapter->itr ?
-                            min(adapter->itr + (new_itr >> 2), new_itr) :
-                            new_itr;
+                            min(adapter->itr + (new_itr >> 2), new_itr) :
+                            new_itr;
                /* Don't write the value here; it resets the adapter's
                 * internal timer, and causes us to delay far longer than
                 * we should between interrupts.  Instead, we write the ITR
@@ -2374,7 +2779,8 @@ set_itr_now:
                 * ends up being correct.
                 */
                adapter->itr = new_itr;
-               adapter->set_itr = 1;
+               adapter->rx_ring->itr_val = 1000000000 / (new_itr * 256);
+               adapter->rx_ring->set_itr = 1;
        }
 
        return;
@@ -2385,13 +2791,14 @@ set_itr_now:
 #define IGB_TX_FLAGS_VLAN              0x00000002
 #define IGB_TX_FLAGS_TSO               0x00000004
 #define IGB_TX_FLAGS_IPV4              0x00000008
-#define IGB_TX_FLAGS_VLAN_MASK 0xffff0000
-#define IGB_TX_FLAGS_VLAN_SHIFT        16
+#define IGB_TX_FLAGS_VLAN_MASK         0xffff0000
+#define IGB_TX_FLAGS_VLAN_SHIFT                16
 
 static inline int igb_tso_adv(struct igb_adapter *adapter,
-                             struct igb_ring *tx_ring,
-                             struct sk_buff *skb, u32 tx_flags, u8 *hdr_len)
+                              struct igb_ring *tx_ring,
+                              struct sk_buff *skb, u32 tx_flags, u8 *hdr_len)
 {
+#ifdef NETIF_F_TSO
        struct e1000_adv_tx_context_desc *context_desc;
        unsigned int i;
        int err;
@@ -2417,11 +2824,13 @@ static inline int igb_tso_adv(struct igb_adapter *adapter,
                                                         iph->daddr, 0,
                                                         IPPROTO_TCP,
                                                         0);
+#ifdef NETIF_F_TSO6
        } else if (skb_shinfo(skb)->gso_type == SKB_GSO_TCPV6) {
                ipv6_hdr(skb)->payload_len = 0;
                tcp_hdr(skb)->check = ~csum_ipv6_magic(&ipv6_hdr(skb)->saddr,
                                                       &ipv6_hdr(skb)->daddr,
                                                       0, IPPROTO_TCP, 0);
+#endif
        }
 
        i = tx_ring->next_to_use;
@@ -2433,8 +2842,8 @@ static inline int igb_tso_adv(struct igb_adapter *adapter,
                info |= (tx_flags & IGB_TX_FLAGS_VLAN_MASK);
        info |= (skb_network_offset(skb) << E1000_ADVTXD_MACLEN_SHIFT);
        *hdr_len += skb_network_offset(skb);
-       info |= skb_network_header_len(skb);
-       *hdr_len += skb_network_header_len(skb);
+       info |= (skb_transport_header(skb) - skb_network_header(skb));
+       *hdr_len += (skb_transport_header(skb) - skb_network_header(skb));
        context_desc->vlan_macip_lens = cpu_to_le32(info);
 
        /* ADV DTYP TUCMD MKRLOC/ISCSIHEDLEN */
@@ -2450,9 +2859,9 @@ static inline int igb_tso_adv(struct igb_adapter *adapter,
        mss_l4len_idx = (skb_shinfo(skb)->gso_size << E1000_ADVTXD_MSS_SHIFT);
        mss_l4len_idx |= (l4len << E1000_ADVTXD_L4LEN_SHIFT);
 
-       /* Context index must be unique per ring.  Luckily, so is the interrupt
-        * mask value. */
-       mss_l4len_idx |= tx_ring->eims_value >> 4;
+       /* For 82575, context index must be unique per ring. */
+       if (adapter->flags & IGB_FLAG_NEED_CTX_IDX)
+               mss_l4len_idx |= tx_ring->queue_index << 4;
 
        context_desc->mss_l4len_idx = cpu_to_le32(mss_l4len_idx);
        context_desc->seqnum_seed = 0;
@@ -2465,12 +2874,15 @@ static inline int igb_tso_adv(struct igb_adapter *adapter,
 
        tx_ring->next_to_use = i;
 
-       return true;
+       return TRUE;
+#else
+       return FALSE;
+#endif  /* NETIF_F_TSO */
 }
 
 static inline bool igb_tx_csum_adv(struct igb_adapter *adapter,
-                                       struct igb_ring *tx_ring,
-                                       struct sk_buff *skb, u32 tx_flags)
+                                   struct igb_ring *tx_ring,
+                                   struct sk_buff *skb, u32 tx_flags)
 {
        struct e1000_adv_tx_context_desc *context_desc;
        unsigned int i;
@@ -2485,25 +2897,48 @@ static inline bool igb_tx_csum_adv(struct igb_adapter *adapter,
 
                if (tx_flags & IGB_TX_FLAGS_VLAN)
                        info |= (tx_flags & IGB_TX_FLAGS_VLAN_MASK);
+
                info |= (skb_network_offset(skb) << E1000_ADVTXD_MACLEN_SHIFT);
                if (skb->ip_summed == CHECKSUM_PARTIAL)
-                       info |= skb_network_header_len(skb);
+                       info |= (skb_transport_header(skb) -
+                                skb_network_header(skb));
+
 
                context_desc->vlan_macip_lens = cpu_to_le32(info);
 
                tu_cmd |= (E1000_TXD_CMD_DEXT | E1000_ADVTXD_DTYP_CTXT);
 
                if (skb->ip_summed == CHECKSUM_PARTIAL) {
-                       if (skb->protocol == htons(ETH_P_IP))
+                       switch (skb->protocol) {
+                       case __constant_htons(ETH_P_IP):
                                tu_cmd |= E1000_ADVTXD_TUCMD_IPV4;
-                       if (skb->sk && (skb->sk->sk_protocol == IPPROTO_TCP))
-                               tu_cmd |= E1000_ADVTXD_TUCMD_L4T_TCP;
+                               if (ip_hdr(skb)->protocol == IPPROTO_TCP)
+                                       tu_cmd |= E1000_ADVTXD_TUCMD_L4T_TCP;
+                               break;
+#ifdef NETIF_F_IPV6_CSUM
+                       case __constant_htons(ETH_P_IPV6):
+                               /* XXX what about other V6 headers?? */
+                               if (ipv6_hdr(skb)->nexthdr == IPPROTO_TCP)
+                                       tu_cmd |= E1000_ADVTXD_TUCMD_L4T_TCP;
+                               break;
+#endif
+                       default:
+                               if (unlikely(net_ratelimit())) {
+                                       DPRINTK(PROBE, WARNING,
+                                        "partial checksum but proto=%x!\n",
+                                        skb->protocol);
+                               }
+                               break;
+                       }
                }
 
                context_desc->type_tucmd_mlhl = cpu_to_le32(tu_cmd);
                context_desc->seqnum_seed = 0;
-               context_desc->mss_l4len_idx =
-                                         cpu_to_le32(tx_ring->eims_value >> 4);
+               if (adapter->flags & IGB_FLAG_NEED_CTX_IDX)
+                       context_desc->mss_l4len_idx =
+                               cpu_to_le32(tx_ring->queue_index << 4);
+               else
+                       context_desc->mss_l4len_idx = 0;
 
                buffer_info->time_stamp = jiffies;
                buffer_info->dma = 0;
@@ -2513,19 +2948,19 @@ static inline bool igb_tx_csum_adv(struct igb_adapter *adapter,
                        i = 0;
                tx_ring->next_to_use = i;
 
-               return true;
+               return TRUE;
        }
 
 
-       return false;
+       return FALSE;
 }
 
 #define IGB_MAX_TXD_PWR        16
 #define IGB_MAX_DATA_PER_TXD   (1<<IGB_MAX_TXD_PWR)
 
 static inline int igb_tx_map_adv(struct igb_adapter *adapter,
-                                struct igb_ring *tx_ring,
-                                struct sk_buff *skb)
+                                 struct igb_ring *tx_ring,
+                                 struct sk_buff *skb)
 {
        struct igb_buffer *buffer_info;
        unsigned int len = skb_headlen(skb);
@@ -2539,8 +2974,11 @@ static inline int igb_tx_map_adv(struct igb_adapter *adapter,
        buffer_info->length = len;
        /* set time_stamp *before* dma to help avoid a possible race */
        buffer_info->time_stamp = jiffies;
-       buffer_info->dma = pci_map_single(adapter->pdev, skb->data, len,
-                                         PCI_DMA_TODEVICE);
+
+       buffer_info->dma =
+               pci_map_single(adapter->pdev, skb->data, len,
+                                         PCI_DMA_TODEVICE);
+
        count++;
        i++;
        if (i == tx_ring->count)
@@ -2556,11 +2994,12 @@ static inline int igb_tx_map_adv(struct igb_adapter *adapter,
                BUG_ON(len >= IGB_MAX_DATA_PER_TXD);
                buffer_info->length = len;
                buffer_info->time_stamp = jiffies;
-               buffer_info->dma = pci_map_page(adapter->pdev,
-                                               frag->page,
-                                               frag->page_offset,
-                                               len,
-                                               PCI_DMA_TODEVICE);
+               buffer_info->dma =
+                       pci_map_page(adapter->pdev,
+                                               frag->page,
+                                               frag->page_offset,
+                                               len,
+                                               PCI_DMA_TODEVICE);
 
                count++;
                i++;
@@ -2575,9 +3014,9 @@ static inline int igb_tx_map_adv(struct igb_adapter *adapter,
 }
 
 static inline void igb_tx_queue_adv(struct igb_adapter *adapter,
-                                   struct igb_ring *tx_ring,
-                                   int tx_flags, int count, u32 paylen,
-                                   u8 hdr_len)
+                                    struct igb_ring *tx_ring,
+                                    int tx_flags, int count, u32 paylen,
+                                    u8 hdr_len)
 {
        union e1000_adv_tx_desc *tx_desc = NULL;
        struct igb_buffer *buffer_info;
@@ -2585,7 +3024,7 @@ static inline void igb_tx_queue_adv(struct igb_adapter *adapter,
        unsigned int i;
 
        cmd_type_len = (E1000_ADVTXD_DTYP_DATA | E1000_ADVTXD_DCMD_IFCS |
-                       E1000_ADVTXD_DCMD_DEXT);
+                       E1000_ADVTXD_DCMD_DEXT);
 
        if (tx_flags & IGB_TX_FLAGS_VLAN)
                cmd_type_len |= E1000_ADVTXD_DCMD_VLE;
@@ -2604,9 +3043,10 @@ static inline void igb_tx_queue_adv(struct igb_adapter *adapter,
                olinfo_status |= E1000_TXD_POPTS_TXSM << 8;
        }
 
-       if (tx_flags & (IGB_TX_FLAGS_CSUM | IGB_TX_FLAGS_TSO |
-                       IGB_TX_FLAGS_VLAN))
-               olinfo_status |= tx_ring->eims_value >> 4;
+       if ((adapter->flags & IGB_FLAG_NEED_CTX_IDX) &&
+           (tx_flags & (IGB_TX_FLAGS_CSUM |
+                        IGB_TX_FLAGS_TSO | IGB_TX_FLAGS_VLAN)))
+               olinfo_status |= tx_ring->queue_index << 4;
 
        olinfo_status |= ((paylen - hdr_len) << E1000_ADVTXD_PAYLEN_SHIFT);
 
@@ -2638,11 +3078,15 @@ static inline void igb_tx_queue_adv(struct igb_adapter *adapter,
 }
 
 static int __igb_maybe_stop_tx(struct net_device *netdev,
-                              struct igb_ring *tx_ring, int size)
+                               struct igb_ring *tx_ring, int size)
 {
        struct igb_adapter *adapter = netdev_priv(netdev);
 
-       netif_stop_queue(netdev);
+       if (netif_is_multiqueue(netdev))
+               netif_stop_subqueue(netdev, tx_ring->queue_index);
+       else
+               netif_stop_queue(netdev);
+
        /* Herbert's original patch had:
         *  smp_mb__after_netif_stop_queue();
         * but since that doesn't exist yet, just open code it. */
@@ -2654,13 +3098,16 @@ static int __igb_maybe_stop_tx(struct net_device *netdev,
                return -EBUSY;
 
        /* A reprieve! */
-       netif_start_queue(netdev);
+       if (netif_is_multiqueue(netdev))
+               netif_wake_subqueue(netdev, tx_ring->queue_index);
+       else
+               netif_wake_queue(netdev);
        ++adapter->restart_queue;
        return 0;
 }
 
 static int igb_maybe_stop_tx(struct net_device *netdev,
-                            struct igb_ring *tx_ring, int size)
+                             struct igb_ring *tx_ring, int size)
 {
        if (IGB_DESC_UNUSED(tx_ring) >= size)
                return 0;
@@ -2670,13 +3117,12 @@ static int igb_maybe_stop_tx(struct net_device *netdev,
 #define TXD_USE_COUNT(S) (((S) >> (IGB_MAX_TXD_PWR)) + 1)
 
 static int igb_xmit_frame_ring_adv(struct sk_buff *skb,
-                                  struct net_device *netdev,
-                                  struct igb_ring *tx_ring)
+                                   struct net_device *netdev,
+                                   struct igb_ring *tx_ring)
 {
        struct igb_adapter *adapter = netdev_priv(netdev);
        unsigned int tx_flags = 0;
        unsigned int len;
-       unsigned long irq_flags;
        u8 hdr_len = 0;
        int tso = 0;
 
@@ -2692,61 +3138,66 @@ static int igb_xmit_frame_ring_adv(struct sk_buff *skb,
                return NETDEV_TX_OK;
        }
 
-       if (!spin_trylock_irqsave(&tx_ring->tx_lock, irq_flags))
-               /* Collision - tell upper layer to requeue */
-               return NETDEV_TX_LOCKED;
-
        /* need: 1 descriptor per page,
-        *       + 2 desc gap to keep tail from touching head,
-        *       + 1 desc for skb->data,
-        *       + 1 desc for context descriptor,
-        * otherwise try next time */
+         *       + 2 desc gap to keep tail from touching head,
+         *       + 1 desc for skb->data,
+         *       + 1 desc for context descriptor,
+         * otherwise try next time */
        if (igb_maybe_stop_tx(netdev, tx_ring, skb_shinfo(skb)->nr_frags + 4)) {
                /* this is a hard error */
-               spin_unlock_irqrestore(&tx_ring->tx_lock, irq_flags);
                return NETDEV_TX_BUSY;
        }
+       skb_orphan(skb);
 
        if (adapter->vlgrp && vlan_tx_tag_present(skb)) {
                tx_flags |= IGB_TX_FLAGS_VLAN;
                tx_flags |= (vlan_tx_tag_get(skb) << IGB_TX_FLAGS_VLAN_SHIFT);
        }
 
+       if (skb->protocol == htons(ETH_P_IP))
+               tx_flags |= IGB_TX_FLAGS_IPV4;
+
+#ifdef NETIF_F_TSO
        tso = skb_is_gso(skb) ? igb_tso_adv(adapter, tx_ring, skb, tx_flags,
-                                             &hdr_len) : 0;
+                                             &hdr_len) : 0;
+#endif
 
        if (tso < 0) {
                dev_kfree_skb_any(skb);
-               spin_unlock_irqrestore(&tx_ring->tx_lock, irq_flags);
                return NETDEV_TX_OK;
        }
 
-       if (tso)
+       if (tso) {
                tx_flags |= IGB_TX_FLAGS_TSO;
-       else if (igb_tx_csum_adv(adapter, tx_ring, skb, tx_flags))
+       else if (igb_tx_csum_adv(adapter, tx_ring, skb, tx_flags))
                        if (skb->ip_summed == CHECKSUM_PARTIAL)
                                tx_flags |= IGB_TX_FLAGS_CSUM;
 
-       if (skb->protocol == htons(ETH_P_IP))
-               tx_flags |= IGB_TX_FLAGS_IPV4;
-
        igb_tx_queue_adv(adapter, tx_ring, tx_flags,
-                        igb_tx_map_adv(adapter, tx_ring, skb),
-                        skb->len, hdr_len);
+                        igb_tx_map_adv(adapter, tx_ring, skb),
+                        skb->len, hdr_len);
 
        netdev->trans_start = jiffies;
 
        /* Make sure there is space in the ring for the next send. */
        igb_maybe_stop_tx(netdev, tx_ring, MAX_SKB_FRAGS + 4);
 
-       spin_unlock_irqrestore(&tx_ring->tx_lock, irq_flags);
        return NETDEV_TX_OK;
 }
 
 static int igb_xmit_frame_adv(struct sk_buff *skb, struct net_device *netdev)
 {
        struct igb_adapter *adapter = netdev_priv(netdev);
-       struct igb_ring *tx_ring = &adapter->tx_ring[0];
+       struct igb_ring *tx_ring;
+
+#ifdef HAVE_TX_MQ
+       int r_idx = 0;
+       r_idx = skb->queue_mapping & (IGB_ABS_MAX_TX_QUEUES - 1);
+       tx_ring = adapter->multi_tx_table[r_idx];
+#else
+       tx_ring = &adapter->tx_ring[0];
+#endif
+
 
        /* This goes back to the question of how to logically map a tx queue
         * to a flow.  Right now, performance is impacted slightly negatively
@@ -2755,10 +3206,12 @@ static int igb_xmit_frame_adv(struct sk_buff *skb, struct net_device *netdev)
        return (igb_xmit_frame_ring_adv(skb, netdev, tx_ring));
 }
 
+
 /**
  * igb_tx_timeout - Respond to a Tx Hang
  * @netdev: network interface device structure
  **/
+
 static void igb_tx_timeout(struct net_device *netdev)
 {
        struct igb_adapter *adapter = netdev_priv(netdev);
@@ -2767,12 +3220,15 @@ static void igb_tx_timeout(struct net_device *netdev)
        /* Do the reset outside of interrupt context */
        adapter->tx_timeout_count++;
        schedule_work(&adapter->reset_task);
-       wr32(E1000_EICS, adapter->eims_enable_mask &
-               ~(E1000_EIMS_TCP_TIMER | E1000_EIMS_OTHER));
+       E1000_WRITE_REG(hw, E1000_EICS, adapter->eims_enable_mask &
+                       ~(E1000_EIMS_TCP_TIMER | E1000_EIMS_OTHER));
 }
 
-static void igb_reset_task(struct igb_adapter *adapter)
+static void igb_reset_task(struct work_struct *work)
 {
+       struct igb_adapter *adapter;
+       adapter = container_of(work, struct igb_adapter, reset_task);
+
        igb_reinit_locked(adapter);
 }
 
@@ -2783,6 +3239,7 @@ static void igb_reset_task(struct igb_adapter *adapter)
  * Returns the address of the device statistics structure.
  * The statistics are actually updated from the timer callback.
  **/
+
 static struct net_device_stats *
 igb_get_stats(struct net_device *netdev)
 {
@@ -2799,25 +3256,26 @@ igb_get_stats(struct net_device *netdev)
  *
  * Returns 0 on success, negative on failure
  **/
+
 static int igb_change_mtu(struct net_device *netdev, int new_mtu)
 {
        struct igb_adapter *adapter = netdev_priv(netdev);
        int max_frame = new_mtu + ETH_HLEN + ETH_FCS_LEN;
 
-       if ((max_frame < ETH_ZLEN + ETH_FCS_LEN) ||
-           (max_frame > MAX_JUMBO_FRAME_SIZE)) {
-               dev_err(&adapter->pdev->dev, "Invalid MTU setting\n");
+       if ((new_mtu < 68) || (max_frame > MAX_JUMBO_FRAME_SIZE)) {
+               DPRINTK(PROBE, ERR, "Invalid MTU setting\n");
                return -EINVAL;
        }
 
 #define MAX_STD_JUMBO_FRAME_SIZE 9234
        if (max_frame > MAX_STD_JUMBO_FRAME_SIZE) {
-               dev_err(&adapter->pdev->dev, "MTU > 9216 not supported.\n");
+               DPRINTK(PROBE, ERR, "MTU > 9216 not supported.\n");
                return -EINVAL;
        }
 
        while (test_and_set_bit(__IGB_RESETTING, &adapter->state))
                msleep(1);
+
        /* igb_down has a dependency on max_frame_size */
        adapter->max_frame_size = max_frame;
        if (netif_running(netdev))
@@ -2837,15 +3295,28 @@ static int igb_change_mtu(struct net_device *netdev, int new_mtu)
                adapter->rx_buffer_len = IGB_RXBUFFER_1024;
        else if (max_frame <= IGB_RXBUFFER_2048)
                adapter->rx_buffer_len = IGB_RXBUFFER_2048;
+#ifndef CONFIG_IGB_DISABLE_PACKET_SPLIT
        else
+#if (PAGE_SIZE / 2) > IGB_RXBUFFER_16384
+               adapter->rx_buffer_len = IGB_RXBUFFER_16384;
+#else
+               adapter->rx_buffer_len = PAGE_SIZE / 2;
+#endif
+#else
+       else if (max_frame <= IGB_RXBUFFER_4096)
                adapter->rx_buffer_len = IGB_RXBUFFER_4096;
+       else if (max_frame <= IGB_RXBUFFER_8192)
+               adapter->rx_buffer_len = IGB_RXBUFFER_8192;
+       else if (max_frame <= IGB_RXBUFFER_16384)
+               adapter->rx_buffer_len = IGB_RXBUFFER_16384;
+#endif
        /* adjust allocation if LPE protects us, and we aren't using SBP */
        if ((max_frame == ETH_FRAME_LEN + ETH_FCS_LEN) ||
             (max_frame == MAXIMUM_ETHERNET_VLAN_SIZE))
                adapter->rx_buffer_len = MAXIMUM_ETHERNET_VLAN_SIZE;
 
-       dev_info(&adapter->pdev->dev, "changing MTU from %d to %d\n",
-                netdev->mtu, new_mtu);
+       DPRINTK(PROBE, INFO, "changing MTU from %d to %d\n",
+               netdev->mtu, new_mtu);
        netdev->mtu = new_mtu;
 
        if (netif_running(netdev))
@@ -2866,7 +3337,9 @@ static int igb_change_mtu(struct net_device *netdev, int new_mtu)
 void igb_update_stats(struct igb_adapter *adapter)
 {
        struct e1000_hw *hw = &adapter->hw;
+#ifdef HAVE_PCI_ERS
        struct pci_dev *pdev = adapter->pdev;
+#endif
        u16 phy_tmp;
 
 #define PHY_IDLE_ERROR_COUNT_MASK 0x00FF
@@ -2877,81 +3350,79 @@ void igb_update_stats(struct igb_adapter *adapter)
         */
        if (adapter->link_speed == 0)
                return;
-       if (pdev->error_state != pci_channel_io_normal)
+#ifdef HAVE_PCI_ERS
+       if (pci_channel_offline(pdev))
                return;
+#endif
 
-       adapter->stats.crcerrs += rd32(E1000_CRCERRS);
-       adapter->stats.gprc += rd32(E1000_GPRC);
-       adapter->stats.gorc += rd32(E1000_GORCL);
-       rd32(E1000_GORCH); /* clear GORCL */
-       adapter->stats.bprc += rd32(E1000_BPRC);
-       adapter->stats.mprc += rd32(E1000_MPRC);
-       adapter->stats.roc += rd32(E1000_ROC);
-
-       adapter->stats.prc64 += rd32(E1000_PRC64);
-       adapter->stats.prc127 += rd32(E1000_PRC127);
-       adapter->stats.prc255 += rd32(E1000_PRC255);
-       adapter->stats.prc511 += rd32(E1000_PRC511);
-       adapter->stats.prc1023 += rd32(E1000_PRC1023);
-       adapter->stats.prc1522 += rd32(E1000_PRC1522);
-       adapter->stats.symerrs += rd32(E1000_SYMERRS);
-       adapter->stats.sec += rd32(E1000_SEC);
-
-       adapter->stats.mpc += rd32(E1000_MPC);
-       adapter->stats.scc += rd32(E1000_SCC);
-       adapter->stats.ecol += rd32(E1000_ECOL);
-       adapter->stats.mcc += rd32(E1000_MCC);
-       adapter->stats.latecol += rd32(E1000_LATECOL);
-       adapter->stats.dc += rd32(E1000_DC);
-       adapter->stats.rlec += rd32(E1000_RLEC);
-       adapter->stats.xonrxc += rd32(E1000_XONRXC);
-       adapter->stats.xontxc += rd32(E1000_XONTXC);
-       adapter->stats.xoffrxc += rd32(E1000_XOFFRXC);
-       adapter->stats.xofftxc += rd32(E1000_XOFFTXC);
-       adapter->stats.fcruc += rd32(E1000_FCRUC);
-       adapter->stats.gptc += rd32(E1000_GPTC);
-       adapter->stats.gotc += rd32(E1000_GOTCL);
-       rd32(E1000_GOTCH); /* clear GOTCL */
-       adapter->stats.rnbc += rd32(E1000_RNBC);
-       adapter->stats.ruc += rd32(E1000_RUC);
-       adapter->stats.rfc += rd32(E1000_RFC);
-       adapter->stats.rjc += rd32(E1000_RJC);
-       adapter->stats.tor += rd32(E1000_TORH);
-       adapter->stats.tot += rd32(E1000_TOTH);
-       adapter->stats.tpr += rd32(E1000_TPR);
-
-       adapter->stats.ptc64 += rd32(E1000_PTC64);
-       adapter->stats.ptc127 += rd32(E1000_PTC127);
-       adapter->stats.ptc255 += rd32(E1000_PTC255);
-       adapter->stats.ptc511 += rd32(E1000_PTC511);
-       adapter->stats.ptc1023 += rd32(E1000_PTC1023);
-       adapter->stats.ptc1522 += rd32(E1000_PTC1522);
-
-       adapter->stats.mptc += rd32(E1000_MPTC);
-       adapter->stats.bptc += rd32(E1000_BPTC);
-
-       /* used for adaptive IFS */
-
-       hw->mac.tx_packet_delta = rd32(E1000_TPT);
-       adapter->stats.tpt += hw->mac.tx_packet_delta;
-       hw->mac.collision_delta = rd32(E1000_COLC);
-       adapter->stats.colc += hw->mac.collision_delta;
-
-       adapter->stats.algnerrc += rd32(E1000_ALGNERRC);
-       adapter->stats.rxerrc += rd32(E1000_RXERRC);
-       adapter->stats.tncrs += rd32(E1000_TNCRS);
-       adapter->stats.tsctc += rd32(E1000_TSCTC);
-       adapter->stats.tsctfc += rd32(E1000_TSCTFC);
-
-       adapter->stats.iac += rd32(E1000_IAC);
-       adapter->stats.icrxoc += rd32(E1000_ICRXOC);
-       adapter->stats.icrxptc += rd32(E1000_ICRXPTC);
-       adapter->stats.icrxatc += rd32(E1000_ICRXATC);
-       adapter->stats.ictxptc += rd32(E1000_ICTXPTC);
-       adapter->stats.ictxatc += rd32(E1000_ICTXATC);
-       adapter->stats.ictxqec += rd32(E1000_ICTXQEC);
-       adapter->stats.ictxqmtc += rd32(E1000_ICTXQMTC);
-       adapter->stats.icrxdmtc += rd32(E1000_ICRXDMTC);
+       adapter->stats.crcerrs += E1000_READ_REG(hw, E1000_CRCERRS);
+       adapter->stats.gprc += E1000_READ_REG(hw, E1000_GPRC);
+       adapter->stats.gorc += E1000_READ_REG(hw, E1000_GORCL);
+       E1000_READ_REG(hw, E1000_GORCH); /* clear GORCL */
+       adapter->stats.bprc += E1000_READ_REG(hw, E1000_BPRC);
+       adapter->stats.mprc += E1000_READ_REG(hw, E1000_MPRC);
+       adapter->stats.roc += E1000_READ_REG(hw, E1000_ROC);
+
+       adapter->stats.prc64 += E1000_READ_REG(hw, E1000_PRC64);
+       adapter->stats.prc127 += E1000_READ_REG(hw, E1000_PRC127);
+       adapter->stats.prc255 += E1000_READ_REG(hw, E1000_PRC255);
+       adapter->stats.prc511 += E1000_READ_REG(hw, E1000_PRC511);
+       adapter->stats.prc1023 += E1000_READ_REG(hw, E1000_PRC1023);
+       adapter->stats.prc1522 += E1000_READ_REG(hw, E1000_PRC1522);
+       adapter->stats.symerrs += E1000_READ_REG(hw, E1000_SYMERRS);
+       adapter->stats.sec += E1000_READ_REG(hw, E1000_SEC);
+
+       adapter->stats.mpc += E1000_READ_REG(hw, E1000_MPC);
+       adapter->stats.scc += E1000_READ_REG(hw, E1000_SCC);
+       adapter->stats.ecol += E1000_READ_REG(hw, E1000_ECOL);
+       adapter->stats.mcc += E1000_READ_REG(hw, E1000_MCC);
+       adapter->stats.latecol += E1000_READ_REG(hw, E1000_LATECOL);
+       adapter->stats.dc += E1000_READ_REG(hw, E1000_DC);
+       adapter->stats.rlec += E1000_READ_REG(hw, E1000_RLEC);
+       adapter->stats.xonrxc += E1000_READ_REG(hw, E1000_XONRXC);
+       adapter->stats.xontxc += E1000_READ_REG(hw, E1000_XONTXC);
+       adapter->stats.xoffrxc += E1000_READ_REG(hw, E1000_XOFFRXC);
+       adapter->stats.xofftxc += E1000_READ_REG(hw, E1000_XOFFTXC);
+       adapter->stats.fcruc += E1000_READ_REG(hw, E1000_FCRUC);
+       adapter->stats.gptc += E1000_READ_REG(hw, E1000_GPTC);
+       adapter->stats.gotc += E1000_READ_REG(hw, E1000_GOTCL);
+       E1000_READ_REG(hw, E1000_GOTCH); /* clear GOTCL */
+       adapter->stats.rnbc += E1000_READ_REG(hw, E1000_RNBC);
+       adapter->stats.ruc += E1000_READ_REG(hw, E1000_RUC);
+       adapter->stats.rfc += E1000_READ_REG(hw, E1000_RFC);
+       adapter->stats.rjc += E1000_READ_REG(hw, E1000_RJC);
+       adapter->stats.tor += E1000_READ_REG(hw, E1000_TORH);
+       adapter->stats.tot += E1000_READ_REG(hw, E1000_TOTH);
+       adapter->stats.tpr += E1000_READ_REG(hw, E1000_TPR);
+
+       adapter->stats.ptc64 += E1000_READ_REG(hw, E1000_PTC64);
+       adapter->stats.ptc127 += E1000_READ_REG(hw, E1000_PTC127);
+       adapter->stats.ptc255 += E1000_READ_REG(hw, E1000_PTC255);
+       adapter->stats.ptc511 += E1000_READ_REG(hw, E1000_PTC511);
+       adapter->stats.ptc1023 += E1000_READ_REG(hw, E1000_PTC1023);
+       adapter->stats.ptc1522 += E1000_READ_REG(hw, E1000_PTC1522);
+
+       adapter->stats.mptc += E1000_READ_REG(hw, E1000_MPTC);
+       adapter->stats.bptc += E1000_READ_REG(hw, E1000_BPTC);
+
+       adapter->stats.tpt += E1000_READ_REG(hw, E1000_TPT);
+       adapter->stats.colc += E1000_READ_REG(hw, E1000_COLC);
+
+       adapter->stats.algnerrc += E1000_READ_REG(hw, E1000_ALGNERRC);
+       adapter->stats.rxerrc += E1000_READ_REG(hw, E1000_RXERRC);
+       adapter->stats.tncrs += E1000_READ_REG(hw, E1000_TNCRS);
+       adapter->stats.tsctc += E1000_READ_REG(hw, E1000_TSCTC);
+       adapter->stats.tsctfc += E1000_READ_REG(hw, E1000_TSCTFC);
+
+       adapter->stats.iac += E1000_READ_REG(hw, E1000_IAC);
+       adapter->stats.icrxoc += E1000_READ_REG(hw, E1000_ICRXOC);
+       adapter->stats.icrxptc += E1000_READ_REG(hw, E1000_ICRXPTC);
+       adapter->stats.icrxatc += E1000_READ_REG(hw, E1000_ICRXATC);
+       adapter->stats.ictxptc += E1000_READ_REG(hw, E1000_ICTXPTC);
+       adapter->stats.ictxatc += E1000_READ_REG(hw, E1000_ICTXATC);
+       adapter->stats.ictxqec += E1000_READ_REG(hw, E1000_ICTXQEC);
+       adapter->stats.ictxqmtc += E1000_READ_REG(hw, E1000_ICTXQMTC);
+       adapter->stats.icrxdmtc += E1000_READ_REG(hw, E1000_ICRXDMTC);
 
        /* Fill out the OS statistics structure */
        adapter->net_stats.multicast = adapter->stats.mprc;
@@ -2966,14 +3437,14 @@ void igb_update_stats(struct igb_adapter *adapter)
                adapter->stats.ruc + adapter->stats.roc +
                adapter->stats.cexterr;
        adapter->net_stats.rx_length_errors = adapter->stats.ruc +
-                                             adapter->stats.roc;
+                                             adapter->stats.roc;
        adapter->net_stats.rx_crc_errors = adapter->stats.crcerrs;
        adapter->net_stats.rx_frame_errors = adapter->stats.algnerrc;
        adapter->net_stats.rx_missed_errors = adapter->stats.mpc;
 
        /* Tx Errors */
        adapter->net_stats.tx_errors = adapter->stats.ecol +
-                                      adapter->stats.latecol;
+                                      adapter->stats.latecol;
        adapter->net_stats.tx_aborted_errors = adapter->stats.ecol;
        adapter->net_stats.tx_window_errors = adapter->stats.latecol;
        adapter->net_stats.tx_carrier_errors = adapter->stats.tncrs;
@@ -2983,164 +3454,280 @@ void igb_update_stats(struct igb_adapter *adapter)
        /* Phy Stats */
        if (hw->phy.media_type == e1000_media_type_copper) {
                if ((adapter->link_speed == SPEED_1000) &&
-                  (!hw->phy.ops.read_phy_reg(hw, PHY_1000T_STATUS,
-                                             &phy_tmp))) {
+                  (!e1000_read_phy_reg(hw, PHY_1000T_STATUS, &phy_tmp))) {
                        phy_tmp &= PHY_IDLE_ERROR_COUNT_MASK;
                        adapter->phy_stats.idle_errors += phy_tmp;
                }
        }
 
        /* Management Stats */
-       adapter->stats.mgptc += rd32(E1000_MGTPTC);
-       adapter->stats.mgprc += rd32(E1000_MGTPRC);
-       adapter->stats.mgpdc += rd32(E1000_MGTPDC);
+       adapter->stats.mgptc += E1000_READ_REG(hw, E1000_MGTPTC);
+       adapter->stats.mgprc += E1000_READ_REG(hw, E1000_MGTPRC);
+       adapter->stats.mgpdc += E1000_READ_REG(hw, E1000_MGTPDC);
 }
 
-
-static irqreturn_t igb_msix_other(int irq, void *data, struct pt_regs *regs)
+static irqreturn_t igb_msix_other(int irq, void *data)
 {
        struct net_device *netdev = data;
        struct igb_adapter *adapter = netdev_priv(netdev);
        struct e1000_hw *hw = &adapter->hw;
-       u32 eicr;
-       /* disable interrupts from the "other" bit, avoid re-entry */
-       wr32(E1000_EIMC, E1000_EIMS_OTHER);
 
-       eicr = rd32(E1000_EICR);
-
-       if (eicr & E1000_EIMS_OTHER) {
-               u32 icr = rd32(E1000_ICR);
-               /* reading ICR causes bit 31 of EICR to be cleared */
-               if (!(icr & E1000_ICR_LSC))
-                       goto no_link_interrupt;
-               hw->mac.get_link_status = 1;
-               /* guard against interrupt when we're going down */
-               if (!test_bit(__IGB_DOWN, &adapter->state))
-                       mod_timer(&adapter->watchdog_timer, jiffies + 1);
-       }
+       u32 icr = E1000_READ_REG(hw, E1000_ICR);
+       /* reading ICR causes bit 31 of EICR to be cleared */
+       if (!(icr & E1000_ICR_LSC))
+               goto no_link_interrupt;
+       hw->mac.get_link_status = 1;
+       /* guard against interrupt when we're going down */
+       if (!test_bit(__IGB_DOWN, &adapter->state))
+               mod_timer(&adapter->watchdog_timer, jiffies + 1);
 
 no_link_interrupt:
-       wr32(E1000_IMS, E1000_IMS_LSC);
-       wr32(E1000_EIMS, E1000_EIMS_OTHER);
+       E1000_WRITE_REG(hw, E1000_IMS, E1000_IMS_LSC);
+       E1000_WRITE_REG(hw, E1000_EIMS, adapter->eims_other);
 
        return IRQ_HANDLED;
 }
 
-static irqreturn_t igb_msix_tx(int irq, void *data, struct pt_regs *regs)
+
+#ifdef CONFIG_IGB_SEPARATE_TX_HANDLER
+static irqreturn_t igb_msix_tx(int irq, void *data)
 {
        struct igb_ring *tx_ring = data;
        struct igb_adapter *adapter = tx_ring->adapter;
        struct e1000_hw *hw = &adapter->hw;
 
-       if (!tx_ring->itr_val)
-               wr32(E1000_EIMC, tx_ring->eims_value);
-       
+#ifdef IGB_DCA
+       if (adapter->flags & IGB_FLAG_DCA_ENABLED)
+               igb_update_tx_dca(tx_ring);
+#endif
+
        tx_ring->total_bytes = 0;
        tx_ring->total_packets = 0;
-       if (!igb_clean_tx_irq(adapter, tx_ring))
+
+       /* auto mask will automatically reenable the interrupt when we write
+        * EICS */
+       if (!igb_clean_tx_irq(tx_ring))
                /* Ring was not completely cleaned, so fire another interrupt */
-               wr32(E1000_EICS, tx_ring->eims_value);
+               E1000_WRITE_REG(hw, E1000_EICS, tx_ring->eims_value);
+       else
+               E1000_WRITE_REG(hw, E1000_EIMS, tx_ring->eims_value);
 
-       if (!tx_ring->itr_val)
-               wr32(E1000_EIMS, tx_ring->eims_value);
        return IRQ_HANDLED;
 }
+#endif  /* CONFIG_IGB_SEPARATE_TX_HANDLER */
+
+static void igb_write_itr(struct igb_ring *ring)
+{
+       struct e1000_hw *hw = &ring->adapter->hw;
+       if (ring->set_itr) {
+               switch(hw->mac.type) {
+                       case e1000_82576:
+                               E1000_WRITE_REG(hw, ring->itr_register,
+                                               ring->itr_val |
+                                               0x80000000);
+                               break;
+                       default:
+                               E1000_WRITE_REG(hw, ring->itr_register,
+                                               ring->itr_val |
+                                               (ring->itr_val << 16));
+                               break;
+               }
+               ring->set_itr = 0;
+       }
+}
 
-static irqreturn_t igb_msix_rx(int irq, void *data, struct pt_regs *regs)
+static irqreturn_t igb_msix_rx(int irq, void *data)
 {
        struct igb_ring *rx_ring = data;
        struct igb_adapter *adapter = rx_ring->adapter;
-       struct e1000_hw *hw = &adapter->hw;
 
-       if (!rx_ring->itr_val)
-               wr32(E1000_EIMC, rx_ring->eims_value);
+       igb_write_itr(rx_ring);
+       if (netif_rx_schedule_prep(adapter->netdev, &rx_ring->napi)) {
+               __netif_rx_schedule(adapter->netdev, &rx_ring->napi);
 
-       if (netif_rx_schedule_prep(rx_ring->netdev)) {
-               rx_ring->total_bytes = 0;
-               rx_ring->total_packets = 0;
-               rx_ring->no_itr_adjust = 0;
-               __netif_rx_schedule(rx_ring->netdev);
-       } else {
-               if (!rx_ring->no_itr_adjust) {
-                       igb_lower_rx_eitr(adapter, rx_ring);
-                       rx_ring->no_itr_adjust = 1;
-                }
-        }
+#ifdef IGB_DCA
+               if (adapter->flags & IGB_FLAG_DCA_ENABLED)
+                       igb_update_rx_dca(rx_ring);
+#endif
+       }
        return IRQ_HANDLED;
 }
 
+#ifdef IGB_DCA
+static void igb_update_rx_dca(struct igb_ring *rx_ring)
+{
+       u32 dca_rxctrl;
+       struct igb_adapter *adapter = rx_ring->adapter;
+       struct e1000_hw *hw = &adapter->hw;
+       int cpu = get_cpu();
+       int q = rx_ring->queue_index;
+
+       if (rx_ring->cpu != cpu) {
+               dca_rxctrl = E1000_READ_REG(hw, E1000_DCA_RXCTRL(q));
+               if (hw->mac.type == e1000_82576) {
+                       dca_rxctrl &= ~E1000_DCA_RXCTRL_CPUID_MASK_82576;
+                       dca_rxctrl |= dca3_get_tag(&adapter->pdev->dev, cpu) <<
+                                     E1000_DCA_RXCTRL_CPUID_SHIFT;
+               } else {
+                       dca_rxctrl &= ~E1000_DCA_RXCTRL_CPUID_MASK;
+                       dca_rxctrl |= dca3_get_tag(&adapter->pdev->dev, cpu);
+               }
+               dca_rxctrl |= E1000_DCA_RXCTRL_DESC_DCA_EN;
+               dca_rxctrl |= E1000_DCA_RXCTRL_HEAD_DCA_EN;
+               dca_rxctrl |= E1000_DCA_RXCTRL_DATA_DCA_EN;
+               E1000_WRITE_REG(hw, E1000_DCA_RXCTRL(q), dca_rxctrl);
+               rx_ring->cpu = cpu;
+       }
+       put_cpu();
+}
+
+static void igb_update_tx_dca(struct igb_ring *tx_ring)
+{
+       u32 dca_txctrl;
+       struct igb_adapter *adapter = tx_ring->adapter;
+       struct e1000_hw *hw = &adapter->hw;
+       int cpu = get_cpu();
+       int q = tx_ring->queue_index;
+
+       if (tx_ring->cpu != cpu) {
+               dca_txctrl = E1000_READ_REG(hw, E1000_DCA_TXCTRL(q));
+               if (hw->mac.type == e1000_82576) {
+                       dca_txctrl &= ~E1000_DCA_TXCTRL_CPUID_MASK_82576;
+                       dca_txctrl |= dca3_get_tag(&adapter->pdev->dev, cpu) <<
+                                     E1000_DCA_TXCTRL_CPUID_SHIFT;
+               } else {
+                       dca_txctrl &= ~E1000_DCA_TXCTRL_CPUID_MASK;
+                       dca_txctrl |= dca3_get_tag(&adapter->pdev->dev, cpu);
+               }
+               dca_txctrl |= E1000_DCA_TXCTRL_DESC_DCA_EN;
+               E1000_WRITE_REG(hw, E1000_DCA_TXCTRL(q), dca_txctrl);
+               tx_ring->cpu = cpu;
+       }
+       put_cpu();
+}
+
+static void igb_setup_dca(struct igb_adapter *adapter)
+{
+       int i;
+
+       if (!(adapter->flags & IGB_FLAG_DCA_ENABLED))
+               return;
+
+       for (i = 0; i < adapter->num_tx_queues; i++) {
+               adapter->tx_ring[i].cpu = -1;
+               igb_update_tx_dca(&adapter->tx_ring[i]);
+       }
+       for (i = 0; i < adapter->num_rx_queues; i++) {
+               adapter->rx_ring[i].cpu = -1;
+               igb_update_rx_dca(&adapter->rx_ring[i]);
+       }
+}
+
+static int __igb_notify_dca(struct device *dev, void *data)
+{
+       struct net_device *netdev = dev_get_drvdata(dev);
+       struct igb_adapter *adapter = netdev_priv(netdev);
+       struct e1000_hw *hw = &adapter->hw;
+       unsigned long event = *(unsigned long *)data;
+
+       if (!(adapter->flags & IGB_FLAG_HAS_DCA))
+               goto out;
+
+       switch (event) {
+       case DCA_PROVIDER_ADD:
+               /* if we're already enabled, don't do it again */
+               if (adapter->flags & IGB_FLAG_DCA_ENABLED)
+                       break;
+               adapter->flags |= IGB_FLAG_DCA_ENABLED;
+               /* Always use CB2 mode, difference is masked
+                * in the CB driver. */
+               E1000_WRITE_REG(hw, E1000_DCA_CTRL, 2);
+               if (dca_add_requester(dev) == E1000_SUCCESS) {
+                       DPRINTK(PROBE, INFO, "DCA enabled\n");
+                       igb_setup_dca(adapter);
+                       break;
+               }
+               /* Fall Through since DCA is disabled. */
+       case DCA_PROVIDER_REMOVE:
+               if (adapter->flags & IGB_FLAG_DCA_ENABLED) {
+                       /* without this a class_device is left
+                        * hanging around in the sysfs model */
+                       dca_remove_requester(dev);
+                       DPRINTK(PROBE, INFO, "DCA disabled\n");
+                       adapter->flags &= ~IGB_FLAG_DCA_ENABLED;
+                       E1000_WRITE_REG(hw, E1000_DCA_CTRL, 1);
+               }
+               break;
+       }
+
+out:
+       return E1000_SUCCESS;
+}
+
+static int igb_notify_dca(struct notifier_block *nb, unsigned long event,
+                          void *p)
+{
+       int ret_val;
+
+       ret_val = driver_for_each_device(&igb_driver.driver, NULL, &event,
+                                        __igb_notify_dca);
+
+       return ret_val ? NOTIFY_BAD : NOTIFY_DONE;
+}
+#endif /* IGB_DCA */
+
 /**
  * igb_intr_msi - Interrupt Handler
  * @irq: interrupt number
  * @data: pointer to a network interface device structure
  **/
-static irqreturn_t igb_intr_msi(int irq, void *data, struct pt_regs *regs)
+static irqreturn_t igb_intr_msi(int irq, void *data)
 {
        struct net_device *netdev = data;
        struct igb_adapter *adapter = netdev_priv(netdev);
        struct e1000_hw *hw = &adapter->hw;
        /* read ICR disables interrupts using IAM */
-       u32 icr = rd32(E1000_ICR);
+       u32 icr = E1000_READ_REG(hw, E1000_ICR);
 
-       /* Write the ITR value calculated at the end of the
-        * previous interrupt.
-        */
-       if (adapter->set_itr) {
-               wr32(E1000_ITR,
-                       1000000000 / (adapter->itr * 256));
-               adapter->set_itr = 0;
-       }
+       igb_write_itr(adapter->rx_ring);
 
-       /* read ICR disables interrupts using IAM */
        if (icr & (E1000_ICR_RXSEQ | E1000_ICR_LSC)) {
                hw->mac.get_link_status = 1;
                if (!test_bit(__IGB_DOWN, &adapter->state))
                        mod_timer(&adapter->watchdog_timer, jiffies + 1);
        }
 
-       if (netif_rx_schedule_prep(netdev)) {
-               adapter->tx_ring->total_bytes = 0;
-               adapter->tx_ring->total_packets = 0;
-               adapter->rx_ring->total_bytes = 0;
-               adapter->rx_ring->total_packets = 0;
-               __netif_rx_schedule(netdev);
-       }
+       netif_rx_schedule(netdev, &adapter->rx_ring[0].napi);
 
        return IRQ_HANDLED;
 }
 
 /**
- * igb_intr - Interrupt Handler
+ * igb_intr - Legacy Interrupt Handler
  * @irq: interrupt number
  * @data: pointer to a network interface device structure
  **/
-static irqreturn_t igb_intr(int irq, void *data, struct pt_regs *regs)
+
+static irqreturn_t igb_intr(int irq, void *data)
 {
        struct net_device *netdev = data;
        struct igb_adapter *adapter = netdev_priv(netdev);
        struct e1000_hw *hw = &adapter->hw;
        /* Interrupt Auto-Mask...upon reading ICR, interrupts are masked.  No
         * need for the IMC write */
-       u32 icr = rd32(E1000_ICR);
+       u32 icr = E1000_READ_REG(hw, E1000_ICR);
        u32 eicr = 0;
        if (!icr)
                return IRQ_NONE;  /* Not our interrupt */
 
-       /* Write the ITR value calculated at the end of the
-        * previous interrupt.
-        */
-       if (adapter->set_itr) {
-               wr32(E1000_ITR,
-                       1000000000 / (adapter->itr * 256));
-               adapter->set_itr = 0;
-       }
+       igb_write_itr(adapter->rx_ring);
 
        /* IMS will not auto-mask if INT_ASSERTED is not set, and if it is
         * not set, then the adapter didn't send an interrupt */
        if (!(icr & E1000_ICR_INT_ASSERTED))
                return IRQ_NONE;
 
-       eicr = rd32(E1000_EICR);
+       eicr = E1000_READ_REG(hw, E1000_EICR);
 
        if (icr & (E1000_ICR_RXSEQ | E1000_ICR_LSC)) {
                hw->mac.get_link_status = 1;
@@ -3149,167 +3736,164 @@ static irqreturn_t igb_intr(int irq, void *data, struct pt_regs *regs)
                        mod_timer(&adapter->watchdog_timer, jiffies + 1);
        }
 
-       if (netif_rx_schedule_prep(netdev)) {
-               adapter->tx_ring->total_bytes = 0;
-               adapter->rx_ring->total_bytes = 0;
-               adapter->tx_ring->total_packets = 0;
-               adapter->rx_ring->total_packets = 0;
-               __netif_rx_schedule(netdev);
-       }
+       netif_rx_schedule(netdev, &adapter->rx_ring[0].napi);
+
 
        return IRQ_HANDLED;
 }
 
 /**
- * igb_clean - NAPI Rx polling callback
- * @adapter: board private structure
+ * igb_poll - NAPI Rx polling callback
+ * @napi: napi polling structure
+ * @budget: count of how many packets we should handle
  **/
-static int igb_clean(struct net_device *poll_dev, int *budget)
-{
-       struct igb_adapter *adapter;
-       int work_to_do = min(*budget, poll_dev->quota);
-       int tx_clean_complete = 1, work_done = 0;
-       int i;
 
-       /* Must NOT use netdev_priv macro here. */
-       adapter = poll_dev->priv;
-
-       /* Keep link state information with original netdev */
-       if (!netif_carrier_ok(poll_dev))
-               goto quit_polling;
+static int igb_poll(struct napi_struct *napi, int budget)
+{
+       struct igb_ring *rx_ring = container_of(napi, struct igb_ring, napi);
+       struct igb_adapter *adapter = rx_ring->adapter;
+       struct net_device *netdev = adapter->netdev;
+       int tx_clean_complete, work_done = 0;
 
-       /* igb_clean is called per-cpu.  This lock protects tx_ring[i] from
-        * being cleaned by multiple cpus simultaneously.  A failure obtaining
-        * the lock means tx_ring[i] is currently being cleaned anyway. */
-       for (i = 0; i < adapter->num_tx_queues; i++) {
-               if (spin_trylock(&adapter->tx_ring[i].tx_clean_lock)) {
-                       tx_clean_complete &= igb_clean_tx_irq(adapter,
-                                                       &adapter->tx_ring[i]);
-                       spin_unlock(&adapter->tx_ring[i].tx_clean_lock);
-               }
-       }
+       /* this poll routine only supports one tx and one rx queue */
+#ifdef IGB_DCA
+       if (adapter->flags & IGB_FLAG_DCA_ENABLED)
+               igb_update_tx_dca(&adapter->tx_ring[0]);
+#endif
+       tx_clean_complete = igb_clean_tx_irq(&adapter->tx_ring[0]);
 
-       for (i = 0; i < adapter->num_rx_queues; i++) {
-               igb_clean_rx_irq_adv(adapter, &adapter->rx_ring[i], &work_done,
-                                    work_to_do / adapter->num_rx_queues);
-               *budget -= work_done;
-               poll_dev->quota -= work_done;
-       }
+#ifdef IGB_DCA
+       if (adapter->flags & IGB_FLAG_DCA_ENABLED)
+               igb_update_rx_dca(&adapter->rx_ring[0]);
+#endif
+       igb_clean_rx_irq_adv(&adapter->rx_ring[0], &work_done, budget);
 
        /* If no Tx and not enough Rx work done, exit the polling mode */
-       if ((tx_clean_complete && (work_done == 0)) ||
-           !netif_running(poll_dev)) {
-quit_polling:
+       if ((tx_clean_complete && (work_done == 0)) || !netif_running(netdev)) {
+               netif_rx_complete(netdev, napi);
                if (adapter->itr_setting & 3)
-                       igb_set_itr(adapter, E1000_ITR, 0);
-               netif_rx_complete(poll_dev);
+                       igb_set_itr(adapter);
                if (!test_bit(__IGB_DOWN, &adapter->state))
                        igb_irq_enable(adapter);
                return 0;
        }
 
-       return 1;
+       if (!tx_clean_complete)
+               work_done = budget;
+
+       return work_done;
 }
 
-static int igb_clean_rx_ring_msix(struct net_device *netdev, int *budget)
+static int igb_clean_rx_ring_msix(struct napi_struct *napi, int budget)
 {
-       struct igb_ring *rx_ring = netdev->priv;
+       struct igb_ring *rx_ring = container_of(napi, struct igb_ring, napi);
        struct igb_adapter *adapter = rx_ring->adapter;
        struct e1000_hw *hw = &adapter->hw;
-       struct net_device *real_netdev = adapter->netdev;
-       int work_to_do = min(*budget, netdev->quota);
+       struct net_device *netdev = adapter->netdev;
+       int tx_clean_complete = 1;
        int work_done = 0;
 
-       /* Keep link state information with original netdev */
-       if (!netif_carrier_ok(real_netdev))
-               goto quit_polling;
-
-       igb_clean_rx_irq_adv(adapter, rx_ring, &work_done, work_to_do);
+#ifdef IGB_DCA
+       if (adapter->flags & IGB_FLAG_DCA_ENABLED)
+               igb_update_rx_dca(rx_ring);
+#endif
+       igb_clean_rx_irq_adv(rx_ring, &work_done, budget);
 
-       *budget -= work_done;
-       netdev->quota -= work_done;
+       if (rx_ring->buddy) {
+#ifdef IGB_DCA
+               if (adapter->flags & IGB_FLAG_DCA_ENABLED)
+                       igb_update_tx_dca(rx_ring->buddy);
+#endif
+               tx_clean_complete = igb_clean_tx_irq(rx_ring->buddy);
+       }
 
        /* If not enough Rx work done, exit the polling mode */
-       if ((work_done == 0) || !netif_running(real_netdev)) {
-quit_polling:
-               netif_rx_complete(netdev);
-
-               wr32(E1000_EIMS, rx_ring->eims_value);
-               if ((adapter->itr_setting & 3) && !rx_ring->no_itr_adjust &&
-                   (rx_ring->total_packets > IGB_DYN_ITR_PACKET_THRESHOLD)) {
-                       int mean_size = rx_ring->total_bytes /
-                                       rx_ring->total_packets;
-                       if (mean_size < IGB_DYN_ITR_LENGTH_LOW)
-                               igb_raise_rx_eitr(adapter, rx_ring);
-                       else if (mean_size > IGB_DYN_ITR_LENGTH_HIGH)
-                               igb_lower_rx_eitr(adapter, rx_ring);
+       if ((tx_clean_complete && (work_done == 0)) || !netif_running(netdev)) {
+               netif_rx_complete(netdev, napi);
+               if (adapter->itr_setting & 3) {
+                       if (adapter->num_rx_queues == 1)
+                               igb_set_itr(adapter);
+                       else
+                               igb_update_ring_itr(rx_ring);
                }
+               if (!test_bit(__IGB_DOWN, &adapter->state))
+                       E1000_WRITE_REG(hw, E1000_EIMS, rx_ring->eims_value);
+
                return 0;
        }
 
-       return 1;
+       if (!tx_clean_complete)
+               work_done = budget;
+
+       return work_done;
 }
+
+static inline u32 get_head(struct igb_ring *tx_ring)
+{
+       void *end = (struct e1000_tx_desc *)tx_ring->desc + tx_ring->count;
+       return le32_to_cpu(*(volatile __le32 *)end);
+}
+
 /**
  * igb_clean_tx_irq - Reclaim resources after transmit completes
  * @adapter: board private structure
- * returns true if ring is completely cleaned
+ * returns TRUE if ring is completely cleaned
  **/
-static bool igb_clean_tx_irq(struct igb_adapter *adapter,
-                                 struct igb_ring *tx_ring)
+static bool igb_clean_tx_irq(struct igb_ring *tx_ring)
 {
-       struct net_device *netdev = adapter->netdev;
+       struct igb_adapter *adapter = tx_ring->adapter;
        struct e1000_hw *hw = &adapter->hw;
+       struct net_device *netdev = adapter->netdev;
        struct e1000_tx_desc *tx_desc;
        struct igb_buffer *buffer_info;
        struct sk_buff *skb;
        unsigned int i;
        u32 head, oldhead;
        unsigned int count = 0;
-       bool cleaned = false;
-       bool retval = true;
        unsigned int total_bytes = 0, total_packets = 0;
+       bool retval = TRUE;
 
        rmb();
-       head = *(volatile u32 *)((struct e1000_tx_desc *)tx_ring->desc
-                                + tx_ring->count);
-       head = le32_to_cpu(head);
+       head = get_head(tx_ring);
        i = tx_ring->next_to_clean;
        while (1) {
                while (i != head) {
-                       cleaned = true;
                        tx_desc = E1000_TX_DESC(*tx_ring, i);
                        buffer_info = &tx_ring->buffer_info[i];
                        skb = buffer_info->skb;
 
                        if (skb) {
+#ifdef NETIF_F_TSO
                                unsigned int segs, bytecount;
+
                                /* gso_segs is currently only valid for tcp */
                                segs = skb_shinfo(skb)->gso_segs ?: 1;
                                /* multiply data chunks by size of headers */
                                bytecount = ((segs - 1) * skb_headlen(skb)) +
-                                           skb->len;
+                                           skb->len;
                                total_packets += segs;
                                total_bytes += bytecount;
+#else
+                               total_packets++;
+                               total_bytes += skb->len;
+#endif
                        }
 
                        igb_unmap_and_free_tx_resource(adapter, buffer_info);
-                       tx_desc->upper.data = 0;
 
                        i++;
                        if (i == tx_ring->count)
                                i = 0;
 
                        count++;
-                       if (count == IGB_MAX_TX_CLEAN) {
-                               retval = false;
+                       if (count == tx_ring->count) {
+                               retval = FALSE;
                                goto done_cleaning;
                        }
                }
                oldhead = head;
                rmb();
-               head = *(volatile u32 *)((struct e1000_tx_desc *)tx_ring->desc
-                                        + tx_ring->count);
-               head = le32_to_cpu(head);
+               head = get_head(tx_ring);
                if (head == oldhead)
                        goto done_cleaning;
        }  /* while (1) */
@@ -3317,86 +3901,149 @@ static bool igb_clean_tx_irq(struct igb_adapter *adapter,
 done_cleaning:
        tx_ring->next_to_clean = i;
 
-       if (unlikely(cleaned &&
-                    netif_carrier_ok(netdev) &&
-                    IGB_DESC_UNUSED(tx_ring) >= IGB_TX_QUEUE_WAKE)) {
+       if (unlikely(count &&
+                    netif_carrier_ok(netdev) &&
+                    IGB_DESC_UNUSED(tx_ring) >= IGB_TX_QUEUE_WAKE)) {
                /* Make sure that anybody stopping the queue after this
                 * sees the new next_to_clean.
                 */
                smp_mb();
+#ifdef HAVE_TX_MQ
+               if (__netif_subqueue_stopped(netdev, tx_ring->queue_index) &&
+                   !(test_bit(__IGB_DOWN, &adapter->state))) {
+                       netif_wake_subqueue(netdev, tx_ring->queue_index);
+                       ++adapter->restart_queue;
+               }
+#endif
                if (netif_queue_stopped(netdev) &&
                    !(test_bit(__IGB_DOWN, &adapter->state))) {
                        netif_wake_queue(netdev);
                        ++adapter->restart_queue;
                }
        }
-
        if (tx_ring->detect_tx_hung) {
                /* Detect a transmit hang in hardware, this serializes the
                 * check with the clearing of time_stamp and movement of i */
-               tx_ring->detect_tx_hung = false;
+               tx_ring->detect_tx_hung = FALSE;
                if (tx_ring->buffer_info[i].time_stamp &&
                    time_after(jiffies, tx_ring->buffer_info[i].time_stamp +
-                              (adapter->tx_timeout_factor * HZ))
-                   && !(rd32(E1000_STATUS) &
-                        E1000_STATUS_TXOFF)) {
+                              (adapter->tx_timeout_factor * HZ))
+                   && !(E1000_READ_REG(hw, E1000_STATUS) &
+                        E1000_STATUS_TXOFF)) {
 
                        tx_desc = E1000_TX_DESC(*tx_ring, i);
                        /* detected Tx unit hang */
-                       dev_err(&adapter->pdev->dev,
-                               "Detected Tx Unit Hang\n"
-                               "  Tx Queue             <%lu>\n"
-                               "  TDH                  <%x>\n"
-                               "  TDT                  <%x>\n"
-                               "  next_to_use          <%x>\n"
-                               "  next_to_clean        <%x>\n"
-                               "  head (WB)            <%x>\n"
-                               "buffer_info[next_to_clean]\n"
-                               "  time_stamp           <%lx>\n"
-                               "  jiffies              <%lx>\n"
-                               "  desc.status          <%x>\n",
-                               (unsigned long)((tx_ring - adapter->tx_ring) /
+                       DPRINTK(DRV, ERR, "Detected Tx Unit Hang\n"
+                                       "  Tx Queue             <%lu>\n"
+                                       "  TDH                  <%x>\n"
+                                       "  TDT                  <%x>\n"
+                                       "  next_to_use          <%x>\n"
+                                       "  next_to_clean        <%x>\n"
+                                       "  head (WB)            <%x>\n"
+                                       "buffer_info[next_to_clean]\n"
+                                       "  time_stamp           <%lx>\n"
+                                       "  jiffies              <%lx>\n"
+                                       "  desc.status          <%x>\n",
+                               (unsigned long)((tx_ring->queue_index) /
                                        sizeof(struct igb_ring)),
-                               readl(adapter->hw.hw_addr + tx_ring->head),
-                               readl(adapter->hw.hw_addr + tx_ring->tail),
+                               readl(hw->hw_addr + tx_ring->head),
+                               readl(hw->hw_addr + tx_ring->tail),
                                tx_ring->next_to_use,
                                tx_ring->next_to_clean,
                                head,
                                tx_ring->buffer_info[i].time_stamp,
                                jiffies,
                                tx_desc->upper.fields.status);
-                       netif_stop_queue(netdev);
+                       if (netif_is_multiqueue(netdev))
+                               netif_stop_subqueue(netdev,
+                                                   tx_ring->queue_index);
+                       else
+                               netif_stop_queue(netdev);
                }
        }
        tx_ring->total_bytes += total_bytes;
        tx_ring->total_packets += total_packets;
+       tx_ring->tx_stats.packets += total_packets;
+       tx_ring->tx_stats.bytes += total_bytes;
        adapter->net_stats.tx_bytes += total_bytes;
        adapter->net_stats.tx_packets += total_packets;
        return retval;
 }
 
+#ifdef IGB_LRO
+ /**
+ * igb_get_skb_hdr - helper function for LRO header processing
+ * @skb: pointer to sk_buff to be added to LRO packet
+ * @iphdr: pointer to ip header structure
+ * @tcph: pointer to tcp header structure
+ * @hdr_flags: pointer to header flags
+ * @priv: pointer to the receive descriptor for the current sk_buff
+ **/
+static int igb_get_skb_hdr(struct sk_buff *skb, void **iphdr, void **tcph,
+                           u64 *hdr_flags, void *priv)
+{
+       union e1000_adv_rx_desc *rx_desc = priv;
+       u16 pkt_type = rx_desc->wb.lower.lo_dword.hs_rss.pkt_info &
+                      (E1000_RXDADV_PKTTYPE_IPV4 | E1000_RXDADV_PKTTYPE_TCP);
+
+       /* Verify that this is a valid IPv4 TCP packet */
+       if (pkt_type != (E1000_RXDADV_PKTTYPE_IPV4 |
+                         E1000_RXDADV_PKTTYPE_TCP))
+               return -1;
+
+       /* Set network headers */
+       skb_reset_network_header(skb);
+       skb_set_transport_header(skb, ip_hdrlen(skb));
+       *iphdr = ip_hdr(skb);
+       *tcph = tcp_hdr(skb);
+       *hdr_flags = LRO_IPV4 | LRO_TCP;
+
+       return 0;
+
+}
+#endif /* IGB_LRO */
 
 /**
  * igb_receive_skb - helper function to handle rx indications
  * @adapter: board private structure
  * @status: descriptor status field as written by hardware
- * @vlan: descriptor vlan field as written by hardware (no le/be conversion)
+ * @rx_desc: receive descriptor containing vlan and type information.
  * @skb: pointer to sk_buff to be indicated to stack
  **/
-static void igb_receive_skb(struct igb_adapter *adapter, u8 status, u16 vlan,
-                           struct sk_buff *skb)
+static void igb_receive_skb(struct igb_ring *ring, u8 status,
+                            union e1000_adv_rx_desc * rx_desc,
+                            struct sk_buff *skb)
 {
-       if (adapter->vlgrp && (status & E1000_RXD_STAT_VP))
-               vlan_hwaccel_receive_skb(skb, adapter->vlgrp,
-                                        le16_to_cpu(vlan) &
-                                        E1000_RXD_SPC_VLAN_MASK);
-       else
-               netif_receive_skb(skb);
+       struct igb_adapter * adapter = ring->adapter;
+       bool vlan_extracted = (adapter->vlgrp && (status & E1000_RXD_STAT_VP));
+
+#ifdef IGB_LRO
+       if (adapter->netdev->features & NETIF_F_LRO &&
+           skb->ip_summed == CHECKSUM_UNNECESSARY) {
+               if (vlan_extracted)
+                       lro_vlan_hwaccel_receive_skb(&ring->lro_mgr, skb,
+                                                    adapter->vlgrp,
+                                                    le16_to_cpu(rx_desc->wb.upper.vlan),
+                                                    rx_desc);
+               else
+                       lro_receive_skb(&ring->lro_mgr,skb, rx_desc);
+               ring->lro_used = TRUE;
+       } else {
+#endif
+               if (vlan_extracted)
+                       vlan_hwaccel_receive_skb(skb, adapter->vlgrp,
+                                                le16_to_cpu(rx_desc->wb.upper.vlan));
+               else
+
+                       netif_receive_skb(skb);
+#ifdef IGB_LRO
+       }
+#endif
 }
 
 
 static inline void igb_rx_checksum_adv(struct igb_adapter *adapter,
-                                      u32 status_err, struct sk_buff *skb)
+                                       u32 status_err, struct sk_buff *skb)
 {
        skb->ip_summed = CHECKSUM_NONE;
 
@@ -3417,103 +4064,109 @@ static inline void igb_rx_checksum_adv(struct igb_adapter *adapter,
        adapter->hw_csum_good++;
 }
 
-static bool igb_clean_rx_irq_adv(struct igb_adapter *adapter,
-                                     struct igb_ring *rx_ring,
-                                     int *work_done, int budget)
+static bool igb_clean_rx_irq_adv(struct igb_ring *rx_ring,
+                                 int *work_done, int work_to_do)
 {
+       struct igb_adapter *adapter = rx_ring->adapter;
        struct net_device *netdev = adapter->netdev;
        struct pci_dev *pdev = adapter->pdev;
        union e1000_adv_rx_desc *rx_desc , *next_rxd;
        struct igb_buffer *buffer_info , *next_buffer;
        struct sk_buff *skb;
-       unsigned int i, j;
-       u32 length, hlen, staterr;
-       bool cleaned = false;
+       bool cleaned = FALSE;
        int cleaned_count = 0;
        unsigned int total_bytes = 0, total_packets = 0;
+       unsigned int i;
+#ifndef CONFIG_IGB_DISABLE_PACKET_SPLIT
+       u32 length, hlen, staterr;
+#else
+       u32 length, staterr;
+#endif
 
        i = rx_ring->next_to_clean;
        rx_desc = E1000_RX_DESC_ADV(*rx_ring, i);
        staterr = le32_to_cpu(rx_desc->wb.upper.status_error);
 
        while (staterr & E1000_RXD_STAT_DD) {
-               if (*work_done >= budget)
+
+               if (*work_done >= work_to_do)
                        break;
                (*work_done)++;
+
                buffer_info = &rx_ring->buffer_info[i];
 
+#ifndef CONFIG_IGB_DISABLE_PACKET_SPLIT
                /* HW will not DMA in data larger than the given buffer, even
                 * if it parses the (NFS, of course) header to be larger.  In
                 * that case, it fills the header buffer and spills the rest
                 * into the page.
                 */
-               hlen = le16_to_cpu((rx_desc->wb.lower.lo_dword.hdr_info &
-                 E1000_RXDADV_HDRBUFLEN_MASK) >> E1000_RXDADV_HDRBUFLEN_SHIFT);
+               hlen = (le16_to_cpu(rx_desc->wb.lower.lo_dword.hs_rss.hdr_info) &
+                 E1000_RXDADV_HDRBUFLEN_MASK) >> E1000_RXDADV_HDRBUFLEN_SHIFT;
                if (hlen > adapter->rx_ps_hdr_size)
                        hlen = adapter->rx_ps_hdr_size;
 
+#endif /* CONFIG_IGB_DISABLE_PACKET_SPLIT */
+               if (staterr & E1000_RXD_STAT_DYNINT)
+                       adapter->lli_int++;
+
                length = le16_to_cpu(rx_desc->wb.upper.length);
-               cleaned = true;
+               cleaned = TRUE;
                cleaned_count++;
 
-               if (rx_ring->pending_skb != NULL) {
-                       skb = rx_ring->pending_skb;
-                       rx_ring->pending_skb = NULL;
-                       j = rx_ring->pending_skb_page;
-               } else {
-                       skb = buffer_info->skb;
-                       prefetch(skb->data - NET_IP_ALIGN);
-                       buffer_info->skb = NULL;
-                       if (hlen) {
-                               pci_unmap_single(pdev, buffer_info->dma,
-                                                adapter->rx_ps_hdr_size +
-                                                  NET_IP_ALIGN,
-                                                PCI_DMA_FROMDEVICE);
-                               skb_put(skb, hlen);
-                       } else {
-                               pci_unmap_single(pdev, buffer_info->dma,
-                                                adapter->rx_buffer_len +
-                                                  NET_IP_ALIGN,
-                                                PCI_DMA_FROMDEVICE);
-                               skb_put(skb, length);
-                               goto send_up;
-                       }
-                       j = 0;
+#ifdef CONFIG_IGB_DISABLE_PACKET_SPLIT
+               skb = buffer_info->skb;
+               prefetch(skb->data - NET_IP_ALIGN);
+               buffer_info->skb = NULL;
+               pci_unmap_single(pdev, buffer_info->dma,
+                                adapter->rx_buffer_len +
+                                NET_IP_ALIGN,
+                                PCI_DMA_FROMDEVICE);
+               skb_put(skb, length);
+#else
+               skb = buffer_info->skb;
+               prefetch(skb->data - NET_IP_ALIGN);
+               buffer_info->skb = NULL;
+               if (!adapter->rx_ps_hdr_size) {
+                       pci_unmap_single(pdev, buffer_info->dma,
+                                        adapter->rx_buffer_len +
+                                          NET_IP_ALIGN,
+                                        PCI_DMA_FROMDEVICE);
+                       skb_put(skb, length);
+                       goto send_up;
+               }
+
+               if (!skb_shinfo(skb)->nr_frags) {
+                       pci_unmap_single(pdev, buffer_info->dma,
+                                        adapter->rx_ps_hdr_size + NET_IP_ALIGN,
+                                        PCI_DMA_FROMDEVICE);
+                       skb_put(skb, hlen);
                }
 
-               while (length) {
+               if (length) {
                        pci_unmap_page(pdev, buffer_info->page_dma,
-                               PAGE_SIZE, PCI_DMA_FROMDEVICE);
+                                      PAGE_SIZE / 2,
+                                      PCI_DMA_FROMDEVICE);
                        buffer_info->page_dma = 0;
-                       skb_fill_page_desc(skb, j, buffer_info->page,
-                                               0, length);
-                       buffer_info->page = NULL;
+
+                       skb_fill_page_desc(skb, skb_shinfo(skb)->nr_frags++,
+                                          buffer_info->page,
+                                          buffer_info->page_offset,
+                                          length);
+
+                       if ((adapter->rx_buffer_len > (PAGE_SIZE / 2)) ||
+                           (page_count(buffer_info->page) != 1))
+                               buffer_info->page = NULL;
+                       else
+                               get_page(buffer_info->page);
 
                        skb->len += length;
                        skb->data_len += length;
-                       skb->truesize += length;
-                       rx_desc->wb.upper.status_error = 0;
-                       if (staterr & E1000_RXD_STAT_EOP)
-                               break;
 
-                       j++;
-                       cleaned_count++;
-                       i++;
-                       if (i == rx_ring->count)
-                               i = 0;
-
-                       buffer_info = &rx_ring->buffer_info[i];
-                       rx_desc = E1000_RX_DESC_ADV(*rx_ring, i);
-                       staterr = le32_to_cpu(rx_desc->wb.upper.status_error);
-                       length = le16_to_cpu(rx_desc->wb.upper.length);
-                       if (!(staterr & E1000_RXD_STAT_DD)) {
-                               rx_ring->pending_skb = skb;
-                               rx_ring->pending_skb_page = j;
-                               goto out;
-                       }
+                       skb->truesize += length;
                }
 send_up:
-               pskb_trim(skb, skb->len - 4);
+#endif /* CONFIG_IGB_DISABLE_PACKET_SPLIT */
                i++;
                if (i == rx_ring->count)
                        i = 0;
@@ -3521,11 +4174,18 @@ send_up:
                prefetch(next_rxd);
                next_buffer = &rx_ring->buffer_info[i];
 
+               if (!(staterr & E1000_RXD_STAT_EOP)) {
+                       buffer_info->skb = next_buffer->skb;
+                       buffer_info->dma = next_buffer->dma;
+                       next_buffer->skb = skb;
+                       next_buffer->dma = 0;
+                       goto next_desc;
+               }
+
                if (staterr & E1000_RXDEXT_ERR_FRAME_ERR_MASK) {
                        dev_kfree_skb_irq(skb);
                        goto next_desc;
                }
-               rx_ring->no_itr_adjust |= (staterr & E1000_RXD_STAT_DYNINT);
 
                total_bytes += skb->len;
                total_packets++;
@@ -3534,7 +4194,7 @@ send_up:
 
                skb->protocol = eth_type_trans(skb, netdev);
 
-               igb_receive_skb(adapter, staterr, rx_desc->wb.upper.vlan, skb);
+               igb_receive_skb(rx_ring, staterr, rx_desc, skb);
 
                netdev->last_rx = jiffies;
 
@@ -3543,8 +4203,7 @@ next_desc:
 
                /* return some buffers to hardware, one at a time is too slow */
                if (cleaned_count >= IGB_RX_BUFFER_WRITE) {
-                       igb_alloc_rx_buffers_adv(adapter, rx_ring,
-                                                cleaned_count);
+                       igb_alloc_rx_buffers_adv(rx_ring, cleaned_count);
                        cleaned_count = 0;
                }
 
@@ -3554,12 +4213,19 @@ next_desc:
 
                staterr = le32_to_cpu(rx_desc->wb.upper.status_error);
        }
-out:
+
        rx_ring->next_to_clean = i;
        cleaned_count = IGB_DESC_UNUSED(rx_ring);
 
+#ifdef IGB_LRO
+       if (rx_ring->lro_used) {
+               lro_flush_all(&rx_ring->lro_mgr);
+               rx_ring->lro_used = FALSE;
+       }
+#endif
+
        if (cleaned_count)
-               igb_alloc_rx_buffers_adv(adapter, rx_ring, cleaned_count);
+               igb_alloc_rx_buffers_adv(rx_ring, cleaned_count);
 
        rx_ring->total_packets += total_packets;
        rx_ring->total_bytes += total_bytes;
@@ -3575,46 +4241,57 @@ out:
  * igb_alloc_rx_buffers_adv - Replace used receive buffers; packet split
  * @adapter: address of board private structure
  **/
-static void igb_alloc_rx_buffers_adv(struct igb_adapter *adapter,
-                                    struct igb_ring *rx_ring,
-                                    int cleaned_count)
+
+static void igb_alloc_rx_buffers_adv(struct igb_ring *rx_ring,
+                                     int cleaned_count)
 {
+       struct igb_adapter *adapter = rx_ring->adapter;
        struct net_device *netdev = adapter->netdev;
        struct pci_dev *pdev = adapter->pdev;
        union e1000_adv_rx_desc *rx_desc;
        struct igb_buffer *buffer_info;
        struct sk_buff *skb;
        unsigned int i;
+       int bufsz;
 
        i = rx_ring->next_to_use;
        buffer_info = &rx_ring->buffer_info[i];
 
+#ifndef CONFIG_IGB_DISABLE_PACKET_SPLIT
+       if (adapter->rx_ps_hdr_size)
+               bufsz = adapter->rx_ps_hdr_size;
+       else
+               bufsz = adapter->rx_buffer_len;
+       bufsz += NET_IP_ALIGN;
+#else
+       bufsz = adapter->rx_buffer_len + NET_IP_ALIGN;
+#endif /* CONFIG_IGB_DISABLE_PACKET_SPLIT */
+
        while (cleaned_count--) {
                rx_desc = E1000_RX_DESC_ADV(*rx_ring, i);
 
-               if (adapter->rx_ps_hdr_size && !buffer_info->page) {
-                       buffer_info->page = alloc_page(GFP_ATOMIC);
+#ifndef CONFIG_IGB_DISABLE_PACKET_SPLIT
+               if (adapter->rx_ps_hdr_size && !buffer_info->page_dma) {
                        if (!buffer_info->page) {
-                               adapter->alloc_rx_buff_failed++;
-                               goto no_buffers;
+                               buffer_info->page = alloc_page(GFP_ATOMIC);
+                               if (!buffer_info->page) {
+                                       adapter->alloc_rx_buff_failed++;
+                                       goto no_buffers;
+                               }
+                               buffer_info->page_offset = 0;
+                       } else {
+                               buffer_info->page_offset ^= PAGE_SIZE / 2;
                        }
                        buffer_info->page_dma =
-                               pci_map_page(pdev,
-                                            buffer_info->page,
-                                            0, PAGE_SIZE,
-                                            PCI_DMA_FROMDEVICE);
+                               pci_map_page(pdev, buffer_info->page,
+                                            buffer_info->page_offset,
+                                            PAGE_SIZE / 2,
+                                            PCI_DMA_FROMDEVICE);
                }
+#endif /* CONFIG_IGB_DISABLE_PACKET_SPLIT */
 
                if (!buffer_info->skb) {
-                       int bufsz;
-
-                       if (adapter->rx_ps_hdr_size)
-                               bufsz = adapter->rx_ps_hdr_size;
-                       else
-                               bufsz = adapter->rx_buffer_len;
-                       bufsz += NET_IP_ALIGN;
                        skb = netdev_alloc_skb(netdev, bufsz);
-
                        if (!skb) {
                                adapter->alloc_rx_buff_failed++;
                                goto no_buffers;
@@ -3628,17 +4305,20 @@ static void igb_alloc_rx_buffers_adv(struct igb_adapter *adapter,
 
                        buffer_info->skb = skb;
                        buffer_info->dma = pci_map_single(pdev, skb->data,
-                                                         bufsz,
-                                                         PCI_DMA_FROMDEVICE);
-
+                                                         bufsz,
+                                                         PCI_DMA_FROMDEVICE);
                }
                /* Refresh the desc even if buffer_addrs didn't change because
                 * each write-back erases this info. */
+#ifndef CONFIG_IGB_DISABLE_PACKET_SPLIT
                if (adapter->rx_ps_hdr_size) {
                        rx_desc->read.pkt_addr =
                             cpu_to_le64(buffer_info->page_dma);
                        rx_desc->read.hdr_addr = cpu_to_le64(buffer_info->dma);
                } else {
+#else
+               {
+#endif /* CONFIG_IGB_DISABLE_PACKET_SPLIT */
                        rx_desc->read.pkt_addr =
                             cpu_to_le64(buffer_info->dma);
                        rx_desc->read.hdr_addr = 0;
@@ -3667,12 +4347,14 @@ no_buffers:
        }
 }
 
+#ifdef SIOCGMIIPHY
 /**
  * igb_mii_ioctl -
  * @netdev:
  * @ifreq:
  * @cmd:
  **/
+
 static int igb_mii_ioctl(struct net_device *netdev, struct ifreq *ifr, int cmd)
 {
        struct igb_adapter *adapter = netdev_priv(netdev);
@@ -3688,17 +4370,17 @@ static int igb_mii_ioctl(struct net_device *netdev, struct ifreq *ifr, int cmd)
        case SIOCGMIIREG:
                if (!capable(CAP_NET_ADMIN))
                        return -EPERM;
-               if (adapter->hw.phy.ops.read_phy_reg(&adapter->hw,
-                                                    data->reg_num
-                                                    & 0x1F, &data->val_out))
+               if (e1000_read_phy_reg(&adapter->hw, data->reg_num & 0x1F,
+                                  &data->val_out))
                        return -EIO;
                break;
        case SIOCSMIIREG:
        default:
                return -EOPNOTSUPP;
        }
-       return 0;
+       return E1000_SUCCESS;
 }
+#endif
 
 /**
  * igb_ioctl -
@@ -3706,20 +4388,49 @@ static int igb_mii_ioctl(struct net_device *netdev, struct ifreq *ifr, int cmd)
  * @ifreq:
  * @cmd:
  **/
+
 static int igb_ioctl(struct net_device *netdev, struct ifreq *ifr, int cmd)
 {
        switch (cmd) {
+#ifdef SIOCGMIIPHY
        case SIOCGMIIPHY:
        case SIOCGMIIREG:
        case SIOCSMIIREG:
                return igb_mii_ioctl(netdev, ifr, cmd);
+#endif
+#ifdef ETHTOOL_OPS_COMPAT
+       case SIOCETHTOOL:
+               return ethtool_ioctl(ifr);
+#endif
        default:
                return -EOPNOTSUPP;
        }
 }
 
+void e1000_read_pci_cfg(struct e1000_hw *hw, u32 reg, u16 *value)
+{
+       struct igb_adapter *adapter = hw->back;
+
+       pci_read_config_word(adapter->pdev, reg, value);
+}
+
+
+s32 e1000_read_pcie_cap_reg(struct e1000_hw *hw, u32 reg, u16 *value)
+{
+       struct igb_adapter *adapter = hw->back;
+       u16 cap_offset;
+
+       cap_offset = pci_find_capability(adapter->pdev, PCI_CAP_ID_EXP);
+       if (!cap_offset)
+               return -E1000_ERR_CONFIG;
+
+       pci_read_config_word(adapter->pdev, cap_offset + reg, value);
+
+       return E1000_SUCCESS;
+}
+
 static void igb_vlan_rx_register(struct net_device *netdev,
-                                struct vlan_group *grp)
+                                 struct vlan_group *grp)
 {
        struct igb_adapter *adapter = netdev_priv(netdev);
        struct e1000_hw *hw = &adapter->hw;
@@ -3730,34 +4441,29 @@ static void igb_vlan_rx_register(struct net_device *netdev,
 
        if (grp) {
                /* enable VLAN tag insert/strip */
-               ctrl = rd32(E1000_CTRL);
+               ctrl = E1000_READ_REG(hw, E1000_CTRL);
                ctrl |= E1000_CTRL_VME;
-               wr32(E1000_CTRL, ctrl);
+               E1000_WRITE_REG(hw, E1000_CTRL, ctrl);
 
-               /* enable VLAN receive filtering */
-               rctl = rd32(E1000_RCTL);
-               rctl |= E1000_RCTL_VFE;
+               /* Disable CFI check */
+               rctl = E1000_READ_REG(hw, E1000_RCTL);
                rctl &= ~E1000_RCTL_CFIEN;
-               wr32(E1000_RCTL, rctl);
+               E1000_WRITE_REG(hw, E1000_RCTL, rctl);
                igb_update_mng_vlan(adapter);
-               wr32(E1000_RLPML,
-                               adapter->max_frame_size + VLAN_TAG_SIZE);
+               E1000_WRITE_REG(hw, E1000_RLPML,
+                               adapter->max_frame_size + VLAN_TAG_SIZE);
        } else {
                /* disable VLAN tag insert/strip */
-               ctrl = rd32(E1000_CTRL);
+               ctrl = E1000_READ_REG(hw, E1000_CTRL);
                ctrl &= ~E1000_CTRL_VME;
-               wr32(E1000_CTRL, ctrl);
+               E1000_WRITE_REG(hw, E1000_CTRL, ctrl);
 
-               /* disable VLAN filtering */
-               rctl = rd32(E1000_RCTL);
-               rctl &= ~E1000_RCTL_VFE;
-               wr32(E1000_RCTL, rctl);
                if (adapter->mng_vlan_id != (u16)IGB_MNG_VLAN_NONE) {
                        igb_vlan_rx_kill_vid(netdev, adapter->mng_vlan_id);
                        adapter->mng_vlan_id = IGB_MNG_VLAN_NONE;
                }
-               wr32(E1000_RLPML,
-                               adapter->max_frame_size);
+               E1000_WRITE_REG(hw, E1000_RLPML,
+                               adapter->max_frame_size);
        }
 
        if (!test_bit(__IGB_DOWN, &adapter->state))
@@ -3769,16 +4475,23 @@ static void igb_vlan_rx_add_vid(struct net_device *netdev, u16 vid)
        struct igb_adapter *adapter = netdev_priv(netdev);
        struct e1000_hw *hw = &adapter->hw;
        u32 vfta, index;
+       struct net_device *v_netdev;
 
-       if ((adapter->hw.mng_cookie.status &
+       if ((hw->mng_cookie.status &
             E1000_MNG_DHCP_COOKIE_STATUS_VLAN) &&
            (vid == adapter->mng_vlan_id))
                return;
        /* add VID to filter table */
        index = (vid >> 5) & 0x7F;
-       vfta = array_rd32(E1000_VFTA, index);
+       vfta = E1000_READ_REG_ARRAY(hw, E1000_VFTA, index);
        vfta |= (1 << (vid & 0x1F));
-       igb_write_vfta(&adapter->hw, index, vfta);
+       e1000_write_vfta(hw, index, vfta);
+       /* Copy feature flags from netdev to the vlan netdev for this vid.
+        * This allows things like TSO to bubble down to our vlan device.
+        */
+       v_netdev = vlan_group_get_device(adapter->vlgrp, vid);
+       v_netdev->features |= adapter->netdev->features;
+       vlan_group_set_device(adapter->vlgrp, vid, v_netdev);
 }
 
 static void igb_vlan_rx_kill_vid(struct net_device *netdev, u16 vid)
@@ -3803,9 +4516,9 @@ static void igb_vlan_rx_kill_vid(struct net_device *netdev, u16 vid)
 
        /* remove VID from filter table */
        index = (vid >> 5) & 0x7F;
-       vfta = array_rd32(E1000_VFTA, index);
+       vfta = E1000_READ_REG_ARRAY(hw, E1000_VFTA, index);
        vfta &= ~(1 << (vid & 0x1F));
-       igb_write_vfta(&adapter->hw, index, vfta);
+       e1000_write_vfta(hw, index, vfta);
 }
 
 static void igb_restore_vlan(struct igb_adapter *adapter)
@@ -3831,8 +4544,7 @@ int igb_set_spd_dplx(struct igb_adapter *adapter, u16 spddplx)
        /* Fiber NICs only allow 1000 gbps Full duplex */
        if ((adapter->hw.phy.media_type == e1000_media_type_fiber) &&
                spddplx != (SPEED_1000 + DUPLEX_FULL)) {
-               dev_err(&adapter->pdev->dev,
-                       "Unsupported Speed/Duplex configuration\n");
+               DPRINTK(PROBE, ERR, "Unsupported Speed/Duplex configuration\n");
                return -EINVAL;
        }
 
@@ -3855,20 +4567,38 @@ int igb_set_spd_dplx(struct igb_adapter *adapter, u16 spddplx)
                break;
        case SPEED_1000 + DUPLEX_HALF: /* not supported */
        default:
-               dev_err(&adapter->pdev->dev,
-                       "Unsupported Speed/Duplex configuration\n");
+               DPRINTK(PROBE, ERR, "Unsupported Speed/Duplex configuration\n");
                return -EINVAL;
        }
        return 0;
 }
 
+#ifdef USE_REBOOT_NOTIFIER
+/* only want to do this for 2.4 kernels? */
+static int igb_notify_reboot(struct notifier_block *nb, unsigned long event,
+                             void *p)
+{
+       struct pci_dev *pdev = NULL;
+
+       switch (event) {
+       case SYS_DOWN:
+       case SYS_HALT:
+       case SYS_POWER_OFF:
+               while ((pdev = pci_find_device(PCI_ANY_ID, PCI_ANY_ID, pdev))) {
+                       if (pci_dev_driver(pdev) == &igb_driver)
+                               igb_suspend(pdev, PMSG_SUSPEND);
+               }
+       }
+       return NOTIFY_DONE;
+}
+#endif
 
 static int igb_suspend(struct pci_dev *pdev, pm_message_t state)
 {
        struct net_device *netdev = pci_get_drvdata(pdev);
        struct igb_adapter *adapter = netdev_priv(netdev);
        struct e1000_hw *hw = &adapter->hw;
-       u32 ctrl, ctrl_ext, rctl, status;
+       u32 ctrl, rctl, status;
        u32 wufc = adapter->wol;
 #ifdef CONFIG_PM
        int retval = 0;
@@ -3876,11 +4606,12 @@ static int igb_suspend(struct pci_dev *pdev, pm_message_t state)
 
        netif_device_detach(netdev);
 
-       if (netif_running(netdev)) {
-               WARN_ON(test_bit(__IGB_RESETTING, &adapter->state));
-               igb_down(adapter);
-               igb_free_irq(adapter);
-       }
+       if (netif_running(netdev))
+               igb_close(netdev);
+
+       igb_reset_interrupt_capability(adapter);
+
+       igb_free_queues(adapter);
 
 #ifdef CONFIG_PM
        retval = pci_save_state(pdev);
@@ -3888,7 +4619,7 @@ static int igb_suspend(struct pci_dev *pdev, pm_message_t state)
                return retval;
 #endif
 
-       status = rd32(E1000_STATUS);
+       status = E1000_READ_REG(hw, E1000_STATUS);
        if (status & E1000_STATUS_LU)
                wufc &= ~E1000_WUFC_LNKC;
 
@@ -3898,46 +4629,37 @@ static int igb_suspend(struct pci_dev *pdev, pm_message_t state)
 
                /* turn on all-multi mode if wake on multicast is enabled */
                if (wufc & E1000_WUFC_MC) {
-                       rctl = rd32(E1000_RCTL);
+                       rctl = E1000_READ_REG(hw, E1000_RCTL);
                        rctl |= E1000_RCTL_MPE;
-                       wr32(E1000_RCTL, rctl);
+                       E1000_WRITE_REG(hw, E1000_RCTL, rctl);
                }
 
-               ctrl = rd32(E1000_CTRL);
+               ctrl = E1000_READ_REG(hw, E1000_CTRL);
                /* advertise wake from D3Cold */
                #define E1000_CTRL_ADVD3WUC 0x00100000
                /* phy power management enable */
                #define E1000_CTRL_EN_PHY_PWR_MGMT 0x00200000
                ctrl |= E1000_CTRL_ADVD3WUC;
-               wr32(E1000_CTRL, ctrl);
-
-               if (adapter->hw.phy.media_type == e1000_media_type_fiber ||
-                  adapter->hw.phy.media_type ==
-                                       e1000_media_type_internal_serdes) {
-                       /* keep the laser running in D3 */
-                       ctrl_ext = rd32(E1000_CTRL_EXT);
-                       ctrl_ext |= E1000_CTRL_EXT_SDP7_DATA;
-                       wr32(E1000_CTRL_EXT, ctrl_ext);
-               }
+               E1000_WRITE_REG(hw, E1000_CTRL, ctrl);
 
                /* Allow time for pending master requests to run */
-               igb_disable_pcie_master(&adapter->hw);
+               e1000_disable_pcie_master(hw);
 
-               wr32(E1000_WUC, E1000_WUC_PME_EN);
-               wr32(E1000_WUFC, wufc);
-               pci_enable_wake(pdev, PCI_D3hot, 1);
-               pci_enable_wake(pdev, PCI_D3cold, 1);
+               E1000_WRITE_REG(hw, E1000_WUC, E1000_WUC_PME_EN);
+               E1000_WRITE_REG(hw, E1000_WUFC, wufc);
        } else {
-               wr32(E1000_WUC, 0);
-               wr32(E1000_WUFC, 0);
-               pci_enable_wake(pdev, PCI_D3hot, 0);
-               pci_enable_wake(pdev, PCI_D3cold, 0);
+               E1000_WRITE_REG(hw, E1000_WUC, 0);
+               E1000_WRITE_REG(hw, E1000_WUFC, 0);
        }
 
-       /* make sure adapter isn't asleep if manageability is enabled */
-       if (adapter->en_mng_pt) {
+       /* make sure adapter isn't asleep if manageability/wol is enabled */
+       if (wufc || adapter->en_mng_pt) {
                pci_enable_wake(pdev, PCI_D3hot, 1);
                pci_enable_wake(pdev, PCI_D3cold, 1);
+       } else {
+               e1000_shutdown_fiber_serdes_link(hw);
+               pci_enable_wake(pdev, PCI_D3hot, 0);
+               pci_enable_wake(pdev, PCI_D3cold, 0);
        }
 
        /* Release control of h/w to f/w.  If f/w is AMT enabled, this
@@ -3963,8 +4685,8 @@ static int igb_resume(struct pci_dev *pdev)
        pci_restore_state(pdev);
        err = pci_enable_device(pdev);
        if (err) {
-               dev_err(&pdev->dev,
-                       "igb: Cannot enable PCI device from suspend\n");
+               dev_err(&pdev->dev, "igb: Cannot enable PCI device "
+                       "from suspend\n");
                return err;
        }
        pci_set_master(pdev);
@@ -3972,36 +4694,36 @@ static int igb_resume(struct pci_dev *pdev)
        pci_enable_wake(pdev, PCI_D3hot, 0);
        pci_enable_wake(pdev, PCI_D3cold, 0);
 
-       if (netif_running(netdev)) {
-               err = igb_request_irq(adapter);
-               if (err)
-                       return err;
+       igb_set_interrupt_capability(adapter);
+
+       if (igb_alloc_queues(adapter)) {
+               DPRINTK(PROBE, ERR, "Unable to allocate memory for queues\n");
+               return -ENOMEM;
        }
 
        /* e1000_power_up_phy(adapter); */
 
        igb_reset(adapter);
-       wr32(E1000_WUS, ~0);
+       E1000_WRITE_REG(hw, E1000_WUS, ~0);
 
-       igb_init_manageability(adapter);
-
-       if (netif_running(netdev))
-               igb_up(adapter);
+       if (netif_running(netdev)) {
+               err = igb_open(netdev);
+               if (err)
+                       return err;
+       }
 
        netif_device_attach(netdev);
 
-       /* let the f/w know that the h/w is now under the control of the
-        * driver. */
-       igb_get_hw_control(adapter);
-
        return 0;
 }
 #endif
 
+#ifndef USE_REBOOT_NOTIFIER
 static void igb_shutdown(struct pci_dev *pdev)
 {
        igb_suspend(pdev, PMSG_SUSPEND);
 }
+#endif
 
 #ifdef CONFIG_NET_POLL_CONTROLLER
 /*
@@ -4013,20 +4735,28 @@ static void igb_netpoll(struct net_device *netdev)
 {
        struct igb_adapter *adapter = netdev_priv(netdev);
        int i;
-       int work_done = 0, work_to_do = adapter->netdev->weight;
+       int work_done = 0;
 
        igb_irq_disable(adapter);
-       for (i = 0; i < adapter->num_tx_queues; i++)
-               igb_clean_tx_irq(adapter, &adapter->tx_ring[i]);
+       adapter->flags |= IGB_FLAG_IN_NETPOLL;
 
-       for (i = 0; i < adapter->num_rx_queues; i++)
-               igb_clean_rx_irq_adv(adapter, &adapter->rx_ring[i],
-                                    &work_done, work_to_do);
+#ifndef CONFIG_IGB_SEPARATE_TX_HANDLER
+       for (i = 0; i < adapter->num_tx_queues; i++) {
+               igb_clean_tx_irq(&adapter->tx_ring[i]);
+       }
+#endif
 
+       for (i = 0; i < adapter->num_rx_queues; i++) {
+               igb_clean_rx_irq_adv(&adapter->rx_ring[i],
+                                    &work_done,
+                                    adapter->rx_ring[i].napi.weight);
+       }
+       adapter->flags &= ~IGB_FLAG_IN_NETPOLL;
        igb_irq_enable(adapter);
 }
 #endif /* CONFIG_NET_POLL_CONTROLLER */
 
+#ifdef HAVE_PCI_ERS
 /**
  * igb_io_error_detected - called when PCI error is detected
  * @pdev: Pointer to PCI device
@@ -4036,7 +4766,7 @@ static void igb_netpoll(struct net_device *netdev)
  * this device has been detected.
  */
 static pci_ers_result_t igb_io_error_detected(struct pci_dev *pdev,
-                                             pci_channel_state_t state)
+                                              pci_channel_state_t state)
 {
        struct net_device *netdev = pci_get_drvdata(pdev);
        struct igb_adapter *adapter = netdev_priv(netdev);
@@ -4070,12 +4800,13 @@ static pci_ers_result_t igb_io_slot_reset(struct pci_dev *pdev)
                return PCI_ERS_RESULT_DISCONNECT;
        }
        pci_set_master(pdev);
+       pci_restore_state(pdev);
 
        pci_enable_wake(pdev, PCI_D3hot, 0);
        pci_enable_wake(pdev, PCI_D3cold, 0);
 
        igb_reset(adapter);
-       wr32(E1000_WUS, ~0);
+       E1000_WRITE_REG(hw, E1000_WUS, ~0);
 
        return PCI_ERS_RESULT_RECOVERED;
 }
@@ -4093,8 +4824,6 @@ static void igb_io_resume(struct pci_dev *pdev)
        struct net_device *netdev = pci_get_drvdata(pdev);
        struct igb_adapter *adapter = netdev_priv(netdev);
 
-       igb_init_manageability(adapter);
-
        if (netif_running(netdev)) {
                if (igb_up(adapter)) {
                        dev_err(&pdev->dev, "igb_up failed after reset\n");
@@ -4109,5 +4838,7 @@ static void igb_io_resume(struct pci_dev *pdev)
        igb_get_hw_control(adapter);
 
 }
+#endif /* HAVE_PCI_ERS */
+
 
 /* igb_main.c */
diff --git a/drivers/net/igb/igb_param.c b/drivers/net/igb/igb_param.c
new file mode 100644 (file)
index 0000000..0cb9f57
--- /dev/null
@@ -0,0 +1,408 @@
+/*******************************************************************************
+
+  Intel(R) Gigabit Ethernet Linux driver
+  Copyright(c) 2007-2008 Intel Corporation.
+
+  This program is free software; you can redistribute it and/or modify it
+  under the terms and conditions of the GNU General Public License,
+  version 2, as published by the Free Software Foundation.
+
+  This program is distributed in the hope it will be useful, but WITHOUT
+  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+  FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
+  more details.
+
+  You should have received a copy of the GNU General Public License along with
+  this program; if not, write to the Free Software Foundation, Inc.,
+  51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
+
+  The full GNU General Public License is included in this distribution in
+  the file called "COPYING".
+
+  Contact Information:
+  e1000-devel Mailing List <e1000-devel@lists.sourceforge.net>
+  Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
+
+*******************************************************************************/
+
+
+#include <linux/netdevice.h>
+
+#include "igb.h"
+
+/* This is the only thing that needs to be changed to adjust the
+ * maximum number of ports that the driver can manage.
+ */
+
+#define IGB_MAX_NIC 32
+
+#define OPTION_UNSET   -1
+#define OPTION_DISABLED 0
+#define OPTION_ENABLED  1
+
+/* All parameters are treated the same, as an integer array of values.
+ * This macro just reduces the need to repeat the same declaration code
+ * over and over (plus this helps to avoid typo bugs).
+ */
+
+#define IGB_PARAM_INIT { [0 ... IGB_MAX_NIC] = OPTION_UNSET }
+#ifndef module_param_array
+/* Module Parameters are always initialized to -1, so that the driver
+ * can tell the difference between no user specified value or the
+ * user asking for the default value.
+ * The true default values are loaded in when igb_check_options is called.
+ *
+ * This is a GCC extension to ANSI C.
+ * See the item "Labeled Elements in Initializers" in the section
+ * "Extensions to the C Language Family" of the GCC documentation.
+ */
+
+#define IGB_PARAM(X, desc) \
+       static const int __devinitdata X[IGB_MAX_NIC+1] = IGB_PARAM_INIT; \
+       MODULE_PARM(X, "1-" __MODULE_STRING(IGB_MAX_NIC) "i"); \
+       MODULE_PARM_DESC(X, desc);
+#else
+#define IGB_PARAM(X, desc) \
+       static int __devinitdata X[IGB_MAX_NIC+1] = IGB_PARAM_INIT; \
+       static unsigned int num_##X = 0; \
+       module_param_array_named(X, X, int, &num_##X, 0); \
+       MODULE_PARM_DESC(X, desc);
+#endif
+
+/* Interrupt Throttle Rate (interrupts/sec)
+ *
+ * Valid Range: 100-100000 (0=off, 1=dynamic, 3=dynamic conservative)
+ */
+IGB_PARAM(InterruptThrottleRate, "Interrupt Throttling Rate");
+#define DEFAULT_ITR                    3
+#define MAX_ITR                   100000
+#define MIN_ITR                      120
+/* IntMode (Interrupt Mode)
+ *
+ * Valid Range: 0 - 3
+ *
+ * Default Value: 2 (MSI-X single queue)
+ */
+IGB_PARAM(IntMode, "Interrupt Mode");
+#define MAX_INTMODE                    3
+#define MIN_INTMODE                    0
+
+/* LLIPort (Low Latency Interrupt TCP Port)
+ *
+ * Valid Range: 0 - 65535
+ *
+ * Default Value: 0 (disabled)
+ */
+IGB_PARAM(LLIPort, "Low Latency Interrupt TCP Port");
+
+#define DEFAULT_LLIPORT                0
+#define MAX_LLIPORT               0xFFFF
+#define MIN_LLIPORT                    0
+
+/* LLIPush (Low Latency Interrupt on TCP Push flag)
+ *
+ * Valid Range: 0, 1
+ *
+ * Default Value: 0 (disabled)
+ */
+IGB_PARAM(LLIPush, "Low Latency Interrupt on TCP Push flag");
+
+#define DEFAULT_LLIPUSH                0
+#define MAX_LLIPUSH                    1
+#define MIN_LLIPUSH                    0
+
+/* LLISize (Low Latency Interrupt on Packet Size)
+ *
+ * Valid Range: 0 - 1500
+ *
+ * Default Value: 0 (disabled)
+ */
+IGB_PARAM(LLISize, "Low Latency Interrupt on Packet Size");
+
+#define DEFAULT_LLISIZE                0
+#define MAX_LLISIZE                 1500
+#define MIN_LLISIZE                    0
+
+#ifdef IGB_LRO
+/* LROAggr (Large Receive Offload)
+ *
+ * Valid Range: 2 - 44
+ *
+ * Default Value:  32
+ */
+IGB_PARAM(LROAggr, "LRO - Maximum packets to aggregate");
+
+#define DEFAULT_LRO_AGGR              32
+#define MAX_LRO_AGGR                  44
+#define MIN_LRO_AGGR                   2
+#endif
+
+struct igb_option {
+       enum { enable_option, range_option, list_option } type;
+       const char *name;
+       const char *err;
+       int def;
+       union {
+               struct { /* range_option info */
+                       int min;
+                       int max;
+               } r;
+               struct { /* list_option info */
+                       int nr;
+                       struct igb_opt_list { int i; char *str; } *p;
+               } l;
+       } arg;
+};
+
+static int __devinit igb_validate_option(unsigned int *value,
+                                         struct igb_option *opt,
+                                         struct igb_adapter *adapter)
+{
+       if (*value == OPTION_UNSET) {
+               *value = opt->def;
+               return 0;
+       }
+
+       switch (opt->type) {
+       case enable_option:
+               switch (*value) {
+               case OPTION_ENABLED:
+                       DPRINTK(PROBE, INFO, "%s Enabled\n", opt->name);
+                       return 0;
+               case OPTION_DISABLED:
+                       DPRINTK(PROBE, INFO, "%s Disabled\n", opt->name);
+                       return 0;
+               }
+               break;
+       case range_option:
+               if (*value >= opt->arg.r.min && *value <= opt->arg.r.max) {
+                       DPRINTK(PROBE, INFO,
+                                       "%s set to %d\n", opt->name, *value);
+                       return 0;
+               }
+               break;
+       case list_option: {
+               int i;
+               struct igb_opt_list *ent;
+
+               for (i = 0; i < opt->arg.l.nr; i++) {
+                       ent = &opt->arg.l.p[i];
+                       if (*value == ent->i) {
+                               if (ent->str[0] != '\0')
+                                       DPRINTK(PROBE, INFO, "%s\n", ent->str);
+                               return 0;
+                       }
+               }
+       }
+               break;
+       default:
+               BUG();
+       }
+
+       DPRINTK(PROBE, INFO, "Invalid %s value specified (%d) %s\n",
+              opt->name, *value, opt->err);
+       *value = opt->def;
+       return -1;
+}
+
+/**
+ * igb_check_options - Range Checking for Command Line Parameters
+ * @adapter: board private structure
+ *
+ * This routine checks all command line parameters for valid user
+ * input.  If an invalid value is given, or if no user specified
+ * value exists, a default value is used.  The final value is stored
+ * in a variable in the adapter structure.
+ **/
+
+void __devinit igb_check_options(struct igb_adapter *adapter)
+{
+       int bd = adapter->bd_number;
+
+       if (bd >= IGB_MAX_NIC) {
+               DPRINTK(PROBE, NOTICE,
+                      "Warning: no configuration for board #%d\n", bd);
+               DPRINTK(PROBE, NOTICE, "Using defaults for all values\n");
+#ifndef module_param_array
+               bd = IGB_MAX_NIC;
+#endif
+       }
+
+       { /* Interrupt Throttling Rate */
+               struct igb_option opt = {
+                       .type = range_option,
+                       .name = "Interrupt Throttling Rate (ints/sec)",
+                       .err  = "using default of " __MODULE_STRING(DEFAULT_ITR),
+                       .def  = DEFAULT_ITR,
+                       .arg  = { .r = { .min = MIN_ITR,
+                                        .max = MAX_ITR }}
+               };
+
+#ifdef module_param_array
+               if (num_InterruptThrottleRate > bd) {
+#endif
+                       adapter->itr = InterruptThrottleRate[bd];
+                       switch (adapter->itr) {
+                       case 0:
+                               DPRINTK(PROBE, INFO, "%s turned off\n",
+                                       opt.name);
+                               break;
+                       case 1:
+                               DPRINTK(PROBE, INFO, "%s set to dynamic mode\n",
+                                       opt.name);
+                               adapter->itr_setting = adapter->itr;
+                               adapter->itr = IGB_START_ITR;
+                               break;
+                       case 3:
+                               DPRINTK(PROBE, INFO,
+                                       "%s set to dynamic conservative mode\n",
+                                       opt.name);
+                               adapter->itr_setting = adapter->itr;
+                               adapter->itr = IGB_START_ITR;
+                               break;
+                       default:
+                               igb_validate_option(&adapter->itr, &opt,
+                                       adapter);
+                               /* save the setting, because the dynamic bits change itr */
+                               /* in case of invalid user value, default to conservative mode,
+                                * else need to clear the lower two bits because they are
+                                * used as control */
+                               if (adapter->itr == 3) {
+                                       adapter->itr_setting = adapter->itr;
+                                       adapter->itr = IGB_START_ITR;
+                               }
+                               else {
+                                       adapter->itr = 1000000000 / (adapter->itr * 256);
+                                       adapter->itr_setting = adapter->itr & ~3;
+                               }
+                               break;
+                       }
+#ifdef module_param_array
+               } else {
+                       adapter->itr_setting = opt.def;
+                       adapter->itr = 8000;
+               }
+#endif
+       }
+       { /* Interrupt Mode */
+               struct igb_option opt = {
+                       .type = range_option,
+                       .name = "Interrupt Mode",
+                       .err  = "defaulting to 2 (MSI-X single queue)",
+                       .def  = IGB_INT_MODE_MSIX_1Q,
+                       .arg  = { .r = { .min = MIN_INTMODE,
+                                        .max = MAX_INTMODE }}
+               };
+
+#ifdef module_param_array
+               if (num_IntMode > bd) {
+#endif
+                       unsigned int int_mode = IntMode[bd];
+                       igb_validate_option(&int_mode, &opt, adapter);
+                       adapter->int_mode = int_mode;
+#ifdef module_param_array
+               } else {
+                       adapter->int_mode = opt.def;
+               }
+#endif
+       }
+       { /* Low Latency Interrupt TCP Port */
+               struct igb_option opt = {
+                       .type = range_option,
+                       .name = "Low Latency Interrupt TCP Port",
+                       .err  = "using default of " __MODULE_STRING(DEFAULT_LLIPORT),
+                       .def  = DEFAULT_LLIPORT,
+                       .arg  = { .r = { .min = MIN_LLIPORT,
+                                        .max = MAX_LLIPORT }}
+               };
+
+#ifdef module_param_array
+               if (num_LLIPort > bd) {
+#endif
+                       adapter->lli_port = LLIPort[bd];
+                       if (adapter->lli_port) {
+                               igb_validate_option(&adapter->lli_port, &opt,
+                                       adapter);
+                       } else {
+                               DPRINTK(PROBE, INFO, "%s turned off\n",
+                                       opt.name);
+                       }
+#ifdef module_param_array
+               } else {
+                       adapter->lli_port = opt.def;
+               }
+#endif
+       }
+       { /* Low Latency Interrupt on Packet Size */
+               struct igb_option opt = {
+                       .type = range_option,
+                       .name = "Low Latency Interrupt on Packet Size",
+                       .err  = "using default of " __MODULE_STRING(DEFAULT_LLISIZE),
+                       .def  = DEFAULT_LLISIZE,
+                       .arg  = { .r = { .min = MIN_LLISIZE,
+                                        .max = MAX_LLISIZE }}
+               };
+
+#ifdef module_param_array
+               if (num_LLISize > bd) {
+#endif
+                       adapter->lli_size = LLISize[bd];
+                       if (adapter->lli_size) {
+                               igb_validate_option(&adapter->lli_size, &opt,
+                                       adapter);
+                       } else {
+                               DPRINTK(PROBE, INFO, "%s turned off\n",
+                                       opt.name);
+                       }
+#ifdef module_param_array
+               } else {
+                       adapter->lli_size = opt.def;
+               }
+#endif
+       }
+       { /* Low Latency Interrupt on TCP Push flag */
+               struct igb_option opt = {
+                       .type = enable_option,
+                       .name = "Low Latency Interrupt on TCP Push flag",
+                       .err  = "defaulting to Disabled",
+                       .def  = OPTION_DISABLED
+               };
+
+#ifdef module_param_array
+               if (num_LLIPush > bd) {
+#endif
+                       unsigned int lli_push = LLIPush[bd];
+                       igb_validate_option(&lli_push, &opt, adapter);
+                       adapter->flags |= lli_push ? IGB_FLAG_LLI_PUSH : 0;
+#ifdef module_param_array
+               } else {
+                       adapter->flags |= opt.def ? IGB_FLAG_LLI_PUSH : 0;
+               }
+#endif
+       }
+#ifdef IGB_LRO
+       { /* Large Receive Offload - Maximum packets to aggregate */
+               struct igb_option opt = {
+                       .type = range_option,
+                       .name = "LRO - Maximum packets to aggregate",
+                       .err  = "using default of " __MODULE_STRING(DEFAULT_LRO_AGGR),
+                       .def  = DEFAULT_LRO_AGGR,
+                       .arg  = { .r = { .min = MIN_LRO_AGGR,
+                                        .max = MAX_LRO_AGGR }}
+               };
+
+#ifdef module_param_array
+               if (num_LROAggr > bd) {
+#endif
+                       adapter->lro_max_aggr = LROAggr[bd];
+                       igb_validate_option(&adapter->lro_max_aggr, &opt, adapter);
+
+#ifdef module_param_array
+               } else {
+                       adapter->lro_max_aggr = opt.def;
+               }
+#endif
+       }
+#endif /* IGB_LRO */
+}
+
diff --git a/drivers/net/igb/igb_regtest.h b/drivers/net/igb/igb_regtest.h
new file mode 100644 (file)
index 0000000..de0d0ed
--- /dev/null
@@ -0,0 +1,133 @@
+/*******************************************************************************
+
+  Intel(R) Gigabit Ethernet Linux driver
+  Copyright(c) 2007-2008 Intel Corporation.
+
+  This program is free software; you can redistribute it and/or modify it
+  under the terms and conditions of the GNU General Public License,
+  version 2, as published by the Free Software Foundation.
+
+  This program is distributed in the hope it will be useful, but WITHOUT
+  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+  FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
+  more details.
+
+  You should have received a copy of the GNU General Public License along with
+  this program; if not, write to the Free Software Foundation, Inc.,
+  51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
+
+  The full GNU General Public License is included in this distribution in
+  the file called "COPYING".
+
+  Contact Information:
+  e1000-devel Mailing List <e1000-devel@lists.sourceforge.net>
+  Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
+
+*******************************************************************************/
+
+/* ethtool register test data */
+struct igb_reg_test {
+       u16 reg;
+       u16 reg_offset;
+       u16 array_len;
+       u16 test_type;
+       u32 mask;
+       u32 write;
+};
+
+/* In the hardware, registers are laid out either singly, in arrays
+ * spaced 0x100 bytes apart, or in contiguous tables.  We assume
+ * most tests take place on arrays or single registers (handled
+ * as a single-element array) and special-case the tables.
+ * Table tests are always pattern tests.
+ *
+ * We also make provision for some required setup steps by specifying
+ * registers to be written without any read-back testing.
+ */
+
+#define PATTERN_TEST   1
+#define SET_READ_TEST  2
+#define WRITE_NO_TEST  3
+#define TABLE32_TEST   4
+#define TABLE64_TEST_LO        5
+#define TABLE64_TEST_HI        6
+
+/* 82576 reg test */
+static struct igb_reg_test reg_test_82576[] = {
+       { E1000_FCAL,      0x100, 1,  PATTERN_TEST, 0xFFFFFFFF, 0xFFFFFFFF },
+       { E1000_FCAH,      0x100, 1,  PATTERN_TEST, 0x0000FFFF, 0xFFFFFFFF },
+       { E1000_FCT,       0x100, 1,  PATTERN_TEST, 0x0000FFFF, 0xFFFFFFFF },
+       { E1000_VET,       0x100, 1,  PATTERN_TEST, 0xFFFFFFFF, 0xFFFFFFFF },
+       { E1000_RDBAL(0),  0x100, 4, PATTERN_TEST, 0xFFFFFF80, 0xFFFFFFFF },
+       { E1000_RDBAH(0),  0x100, 4, PATTERN_TEST, 0xFFFFFFFF, 0xFFFFFFFF },
+       { E1000_RDLEN(0),  0x100, 4, PATTERN_TEST, 0x000FFFF0, 0x000FFFFF },
+       { E1000_RDBAL(4),  0x40,  8, PATTERN_TEST, 0xFFFFFF80, 0xFFFFFFFF },
+       { E1000_RDBAH(4),  0x40,  8, PATTERN_TEST, 0xFFFFFFFF, 0xFFFFFFFF },
+       { E1000_RDLEN(4),  0x40,  8, PATTERN_TEST, 0x000FFFF0, 0x000FFFFF },
+       /* Enable all four RX queues before testing. */
+       { E1000_RXDCTL(0), 0x100, 1,  WRITE_NO_TEST, 0, E1000_RXDCTL_QUEUE_ENABLE },
+       /* RDH is read-only for 82576, only test RDT. */
+       { E1000_RDT(0),    0x100, 4,  PATTERN_TEST, 0x0000FFFF, 0x0000FFFF },
+       { E1000_RXDCTL(0), 0x100, 4,  WRITE_NO_TEST, 0, 0 },
+       { E1000_FCRTH,     0x100, 1,  PATTERN_TEST, 0x0000FFF0, 0x0000FFF0 },
+       { E1000_FCTTV,     0x100, 1,  PATTERN_TEST, 0x0000FFFF, 0x0000FFFF },
+       { E1000_TIPG,      0x100, 1,  PATTERN_TEST, 0x3FFFFFFF, 0x3FFFFFFF },
+       { E1000_TDBAL(0),  0x100, 4,  PATTERN_TEST, 0xFFFFFF80, 0xFFFFFFFF },
+       { E1000_TDBAH(0),  0x100, 4,  PATTERN_TEST, 0xFFFFFFFF, 0xFFFFFFFF },
+       { E1000_TDLEN(0),  0x100, 4,  PATTERN_TEST, 0x000FFFF0, 0x000FFFFF },
+       { E1000_TDBAL(4),  0x40, 8,  PATTERN_TEST, 0xFFFFFF80, 0xFFFFFFFF },
+       { E1000_TDBAH(4),  0x40, 8,  PATTERN_TEST, 0xFFFFFFFF, 0xFFFFFFFF },
+       { E1000_TDLEN(4),  0x40, 8,  PATTERN_TEST, 0x000FFFF0, 0x000FFFFF },
+       { E1000_RCTL,      0x100, 1,  SET_READ_TEST, 0xFFFFFFFF, 0x00000000 },
+       { E1000_RCTL,      0x100, 1,  SET_READ_TEST, 0x04CFB0FE, 0x003FFFFB },
+       { E1000_RCTL,      0x100, 1,  SET_READ_TEST, 0x04CFB0FE, 0xFFFFFFFF },
+       { E1000_TCTL,      0x100, 1,  SET_READ_TEST, 0xFFFFFFFF, 0x00000000 },
+       { E1000_RA,        0, 16, TABLE64_TEST_LO,
+                                               0xFFFFFFFF, 0xFFFFFFFF },
+       { E1000_RA,        0, 16, TABLE64_TEST_HI,
+                                               0x83FFFFFF, 0xFFFFFFFF },
+       { E1000_RA2,       0, 8, TABLE64_TEST_LO,
+                                               0xFFFFFFFF, 0xFFFFFFFF },
+       { E1000_RA2,       0, 8, TABLE64_TEST_HI,
+                                               0x83FFFFFF, 0xFFFFFFFF },
+       { E1000_MTA,       0, 128,TABLE32_TEST,
+                                               0xFFFFFFFF, 0xFFFFFFFF },
+       { 0, 0, 0, 0 }
+};
+
+
+/* 82575 register test */
+static struct igb_reg_test reg_test_82575[] = {
+       { E1000_FCAL,   0x100,  1, PATTERN_TEST, 0xFFFFFFFF, 0xFFFFFFFF },
+       { E1000_FCAH,   0x100,  1, PATTERN_TEST, 0x0000FFFF, 0xFFFFFFFF },
+       { E1000_FCT,    0x100,  1, PATTERN_TEST, 0x0000FFFF, 0xFFFFFFFF },
+       { E1000_VET,    0x100,  1, PATTERN_TEST, 0xFFFFFFFF, 0xFFFFFFFF },
+       { E1000_RDBAL(0),       0x100,  4, PATTERN_TEST, 0xFFFFFF80, 0xFFFFFFFF },
+       { E1000_RDBAH(0),       0x100,  4, PATTERN_TEST, 0xFFFFFFFF, 0xFFFFFFFF },
+       { E1000_RDLEN(0),       0x100,  4, PATTERN_TEST, 0x000FFF80, 0x000FFFFF },
+       /* Enable all four RX queues before testing. */
+       { E1000_RXDCTL(0),      0x100,  4, WRITE_NO_TEST, 0, E1000_RXDCTL_QUEUE_ENABLE },
+       /* RDH is read-only for 82575, only test RDT. */
+       { E1000_RDT(0), 0x100,  4, PATTERN_TEST, 0x0000FFFF, 0x0000FFFF },
+       { E1000_RXDCTL(0),      0x100,  4, WRITE_NO_TEST, 0, 0 },
+       { E1000_FCRTH,  0x100,  1, PATTERN_TEST, 0x0000FFF0, 0x0000FFF0 },
+       { E1000_FCTTV,  0x100,  1, PATTERN_TEST, 0x0000FFFF, 0x0000FFFF },
+       { E1000_TIPG,   0x100,  1, PATTERN_TEST, 0x3FFFFFFF, 0x3FFFFFFF },
+       { E1000_TDBAL(0),       0x100,  4, PATTERN_TEST, 0xFFFFFF80, 0xFFFFFFFF },
+       { E1000_TDBAH(0),       0x100,  4, PATTERN_TEST, 0xFFFFFFFF, 0xFFFFFFFF },
+       { E1000_TDLEN(0),       0x100,  4, PATTERN_TEST, 0x000FFF80, 0x000FFFFF },
+       { E1000_RCTL,   0x100,  1, SET_READ_TEST, 0xFFFFFFFF, 0x00000000 },
+       { E1000_RCTL,   0x100,  1, SET_READ_TEST, 0x04CFB3FE, 0x003FFFFB },
+       { E1000_RCTL,   0x100,  1, SET_READ_TEST, 0x04CFB3FE, 0xFFFFFFFF },
+       { E1000_TCTL,   0x100,  1, SET_READ_TEST, 0xFFFFFFFF, 0x00000000 },
+       { E1000_TXCW,   0x100,  1, PATTERN_TEST, 0xC000FFFF, 0x0000FFFF },
+       { E1000_RA,     0,      16, TABLE64_TEST_LO,
+                                               0xFFFFFFFF, 0xFFFFFFFF },
+       { E1000_RA,     0,      16, TABLE64_TEST_HI,
+                                               0x800FFFFF, 0xFFFFFFFF },
+       { E1000_MTA,    0,      128, TABLE32_TEST,
+                                               0xFFFFFFFF, 0xFFFFFFFF },
+       { 0, 0, 0, 0 }
+};
+
+
diff --git a/drivers/net/igb/kcompat.c b/drivers/net/igb/kcompat.c
new file mode 100644 (file)
index 0000000..ef28cae
--- /dev/null
@@ -0,0 +1,413 @@
+/*******************************************************************************
+
+  Intel(R) Gigabit Ethernet Linux driver
+  Copyright(c) 2007-2008 Intel Corporation.
+
+  This program is free software; you can redistribute it and/or modify it
+  under the terms and conditions of the GNU General Public License,
+  version 2, as published by the Free Software Foundation.
+
+  This program is distributed in the hope it will be useful, but WITHOUT
+  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+  FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
+  more details.
+
+  You should have received a copy of the GNU General Public License along with
+  this program; if not, write to the Free Software Foundation, Inc.,
+  51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
+
+  The full GNU General Public License is included in this distribution in
+  the file called "COPYING".
+
+  Contact Information:
+  e1000-devel Mailing List <e1000-devel@lists.sourceforge.net>
+  Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
+
+*******************************************************************************/
+
+
+
+
+#include "igb.h"
+
+
+
+#include "kcompat.h"
+
+/*****************************************************************************/
+#if ( LINUX_VERSION_CODE < KERNEL_VERSION(2,4,13) )
+
+/**************************************/
+/* PCI DMA MAPPING */
+
+#if defined(CONFIG_HIGHMEM)
+
+#ifndef PCI_DRAM_OFFSET
+#define PCI_DRAM_OFFSET 0
+#endif
+
+u64
+_kc_pci_map_page(struct pci_dev *dev, struct page *page, unsigned long offset,
+                 size_t size, int direction)
+{
+       return (((u64) (page - mem_map) << PAGE_SHIFT) + offset +
+               PCI_DRAM_OFFSET);
+}
+
+#else /* CONFIG_HIGHMEM */
+
+u64
+_kc_pci_map_page(struct pci_dev *dev, struct page *page, unsigned long offset,
+                 size_t size, int direction)
+{
+       return pci_map_single(dev, (void *)page_address(page) + offset, size,
+                             direction);
+}
+
+#endif /* CONFIG_HIGHMEM */
+
+void
+_kc_pci_unmap_page(struct pci_dev *dev, u64 dma_addr, size_t size,
+                   int direction)
+{
+       return pci_unmap_single(dev, dma_addr, size, direction);
+}
+
+#endif /* 2.4.13 => 2.4.3 */
+
+/*****************************************************************************/
+#if ( LINUX_VERSION_CODE < KERNEL_VERSION(2,4,3) )
+
+/**************************************/
+/* PCI DRIVER API */
+
+int
+_kc_pci_set_dma_mask(struct pci_dev *dev, dma_addr_t mask)
+{
+       if (!pci_dma_supported(dev, mask))
+               return -EIO;
+       dev->dma_mask = mask;
+       return 0;
+}
+
+int
+_kc_pci_request_regions(struct pci_dev *dev, char *res_name)
+{
+       int i;
+
+       for (i = 0; i < 6; i++) {
+               if (pci_resource_len(dev, i) == 0)
+                       continue;
+
+               if (pci_resource_flags(dev, i) & IORESOURCE_IO) {
+                       if (!request_region(pci_resource_start(dev, i), pci_resource_len(dev, i), res_name)) {
+                               pci_release_regions(dev);
+                               return -EBUSY;
+                       }
+               } else if (pci_resource_flags(dev, i) & IORESOURCE_MEM) {
+                       if (!request_mem_region(pci_resource_start(dev, i), pci_resource_len(dev, i), res_name)) {
+                               pci_release_regions(dev);
+                               return -EBUSY;
+                       }
+               }
+       }
+       return 0;
+}
+
+void
+_kc_pci_release_regions(struct pci_dev *dev)
+{
+       int i;
+
+       for (i = 0; i < 6; i++) {
+               if (pci_resource_len(dev, i) == 0)
+                       continue;
+
+               if (pci_resource_flags(dev, i) & IORESOURCE_IO)
+                       release_region(pci_resource_start(dev, i), pci_resource_len(dev, i));
+
+               else if (pci_resource_flags(dev, i) & IORESOURCE_MEM)
+                       release_mem_region(pci_resource_start(dev, i), pci_resource_len(dev, i));
+       }
+}
+
+/**************************************/
+/* NETWORK DRIVER API */
+
+struct net_device *
+_kc_alloc_etherdev(int sizeof_priv)
+{
+       struct net_device *dev;
+       int alloc_size;
+
+       alloc_size = sizeof(*dev) + sizeof_priv + IFNAMSIZ + 31;
+       dev = kmalloc(alloc_size, GFP_KERNEL);
+       if (!dev)
+               return NULL;
+       memset(dev, 0, alloc_size);
+
+       if (sizeof_priv)
+               dev->priv = (void *) (((unsigned long)(dev + 1) + 31) & ~31);
+       dev->name[0] = '\0';
+       ether_setup(dev);
+
+       return dev;
+}
+
+int
+_kc_is_valid_ether_addr(u8 *addr)
+{
+       const char zaddr[6] = { 0, };
+
+       return !(addr[0] & 1) && memcmp(addr, zaddr, 6);
+}
+
+#endif /* 2.4.3 => 2.4.0 */
+
+/*****************************************************************************/
+#if ( LINUX_VERSION_CODE < KERNEL_VERSION(2,4,6) )
+
+int
+_kc_pci_set_power_state(struct pci_dev *dev, int state)
+{
+       return 0;
+}
+
+int
+_kc_pci_enable_wake(struct pci_dev *pdev, u32 state, int enable)
+{
+       return 0;
+}
+
+#endif /* 2.4.6 => 2.4.3 */
+
+/*****************************************************************************/
+#if ( LINUX_VERSION_CODE < KERNEL_VERSION(2,6,0) )
+void _kc_skb_fill_page_desc(struct sk_buff *skb, int i, struct page *page,
+                            int off, int size)
+{
+       skb_frag_t *frag = &skb_shinfo(skb)->frags[i];
+       frag->page = page;
+       frag->page_offset = off;
+       frag->size = size;
+       skb_shinfo(skb)->nr_frags = i + 1;
+}
+
+/*
+ * Original Copyright:
+ * find_next_bit.c: fallback find next bit implementation
+ *
+ * Copyright (C) 2004 Red Hat, Inc. All Rights Reserved.
+ * Written by David Howells (dhowells@redhat.com)
+ */
+
+/**
+ * find_next_bit - find the next set bit in a memory region
+ * @addr: The address to base the search on
+ * @offset: The bitnumber to start searching at
+ * @size: The maximum size to search
+ */
+unsigned long find_next_bit(const unsigned long *addr, unsigned long size,
+                            unsigned long offset)
+{
+       const unsigned long *p = addr + BITOP_WORD(offset);
+       unsigned long result = offset & ~(BITS_PER_LONG-1);
+       unsigned long tmp;
+
+       if (offset >= size)
+               return size;
+       size -= result;
+       offset %= BITS_PER_LONG;
+       if (offset) {
+               tmp = *(p++);
+               tmp &= (~0UL << offset);
+               if (size < BITS_PER_LONG)
+                       goto found_first;
+               if (tmp)
+                       goto found_middle;
+               size -= BITS_PER_LONG;
+               result += BITS_PER_LONG;
+       }
+       while (size & ~(BITS_PER_LONG-1)) {
+               if ((tmp = *(p++)))
+                       goto found_middle;
+               result += BITS_PER_LONG;
+               size -= BITS_PER_LONG;
+       }
+       if (!size)
+               return result;
+       tmp = *p;
+
+found_first:
+       tmp &= (~0UL >> (BITS_PER_LONG - size));
+       if (tmp == 0UL)         /* Are any bits set? */
+               return result + size;   /* Nope. */
+found_middle:
+       return result + ffs(tmp);
+}
+
+#endif /* 2.6.0 => 2.4.6 */
+
+/*****************************************************************************/
+#if ( LINUX_VERSION_CODE < KERNEL_VERSION(2,6,14) )
+void *_kc_kzalloc(size_t size, int flags)
+{
+       void *ret = kmalloc(size, flags);
+       if (ret)
+               memset(ret, 0, size);
+       return ret;
+}
+#endif /* <= 2.6.13 */
+
+/*****************************************************************************/
+#if ( LINUX_VERSION_CODE < KERNEL_VERSION(2,6,18) )
+struct sk_buff *_kc_netdev_alloc_skb(struct net_device *dev,
+                                     unsigned int length)
+{
+       /* 16 == NET_PAD_SKB */
+       struct sk_buff *skb;
+       skb = alloc_skb(length + 16, GFP_ATOMIC);
+       if (likely(skb != NULL)) {
+               skb_reserve(skb, 16);
+               skb->dev = dev;
+       }
+       return skb;
+}
+#endif /* <= 2.6.17 */
+
+/*****************************************************************************/
+#if ( LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19) )
+int _kc_pci_save_state(struct pci_dev *pdev)
+{ 
+       struct net_device *netdev = pci_get_drvdata(pdev);
+       struct adapter_struct *adapter = netdev_priv(netdev);
+       int size = PCI_CONFIG_SPACE_LEN, i;
+       u16 pcie_cap_offset = pci_find_capability(pdev, PCI_CAP_ID_EXP);
+       u16 pcie_link_status;
+
+       if (pcie_cap_offset) {
+               if (!pci_read_config_word(pdev,
+                                         pcie_cap_offset + PCIE_LINK_STATUS,
+                                         &pcie_link_status))
+               size = PCIE_CONFIG_SPACE_LEN;
+       }
+       pci_config_space_ich8lan();
+#ifdef HAVE_PCI_ERS 
+       if (adapter->config_space == NULL)
+#else
+       WARN_ON(adapter->config_space != NULL);
+#endif
+               adapter->config_space = kmalloc(size, GFP_KERNEL);
+       if (!adapter->config_space) {
+               printk(KERN_ERR "Out of memory in pci_save_state\n");
+               return -ENOMEM;
+       }
+       for (i = 0; i < (size / 4); i++)
+               pci_read_config_dword(pdev, i * 4, &adapter->config_space[i]);
+       return 0;
+}
+
+void _kc_pci_restore_state(struct pci_dev * pdev)
+{
+       struct net_device *netdev = pci_get_drvdata(pdev);
+       struct adapter_struct *adapter = netdev_priv(netdev);
+       int size = PCI_CONFIG_SPACE_LEN, i;
+       u16 pcie_cap_offset;
+       u16 pcie_link_status;
+
+       if (adapter->config_space != NULL) {
+               pcie_cap_offset = pci_find_capability(pdev, PCI_CAP_ID_EXP);
+               if (pcie_cap_offset && 
+                   !pci_read_config_word(pdev,
+                                         pcie_cap_offset + PCIE_LINK_STATUS,
+                                         &pcie_link_status))
+                       size = PCIE_CONFIG_SPACE_LEN;
+       
+               pci_config_space_ich8lan();
+               for (i = 0; i < (size / 4); i++)
+               pci_write_config_dword(pdev, i * 4, adapter->config_space[i]);
+#ifndef HAVE_PCI_ERS
+               kfree(adapter->config_space);
+               adapter->config_space = NULL;
+#endif
+       }
+}
+
+#ifdef HAVE_PCI_ERS
+void _kc_free_netdev(struct net_device *netdev)
+{
+       struct adapter_struct *adapter = netdev_priv(netdev);
+
+       if (adapter->config_space != NULL)
+               kfree(adapter->config_space);
+#ifdef CONFIG_SYSFS
+       if (netdev->reg_state == NETREG_UNINITIALIZED) {
+               kfree((char *)netdev - netdev->padded);
+       } else {
+               BUG_ON(netdev->reg_state != NETREG_UNREGISTERED);
+               netdev->reg_state = NETREG_RELEASED;
+               class_device_put(&netdev->class_dev);
+       }
+#else
+       kfree((char *)netdev - netdev->padded);
+#endif
+}
+#endif
+#endif /* <= 2.6.18 */
+
+/*****************************************************************************/
+#if ( LINUX_VERSION_CODE < KERNEL_VERSION(2,6,23) )
+#endif /* < 2.6.23 */
+
+/*****************************************************************************/
+#if ( LINUX_VERSION_CODE < KERNEL_VERSION(2,6,24) )
+#ifdef NAPI
+int __kc_adapter_clean(struct net_device *netdev, int *budget)
+{
+       int work_done;
+       int work_to_do = min(*budget, netdev->quota);
+       /* kcompat.h netif_napi_add puts napi struct in "fake netdev->priv" */
+       struct napi_struct *napi = netdev->priv;
+       work_done = napi->poll(napi, work_to_do);
+       *budget -= work_done;
+       netdev->quota -= work_done;
+       return work_done ? 1 : 0;
+}
+#endif /* NAPI */
+#endif /* <= 2.6.24 */
+
+/*****************************************************************************/
+#if ( LINUX_VERSION_CODE < KERNEL_VERSION(2,6,27) )
+#ifdef HAVE_TX_MQ
+void _kc_netif_tx_stop_all_queues(struct net_device *netdev)
+{
+       struct adapter_struct *adapter = netdev_priv(netdev);
+       int i;
+
+       netif_stop_queue(netdev);
+       if (netif_is_multiqueue(netdev))
+               for (i = 0; i < adapter->num_tx_queues; i++)
+                       netif_stop_subqueue(netdev, i);
+}
+void _kc_netif_tx_wake_all_queues(struct net_device *netdev)
+{
+       struct adapter_struct *adapter = netdev_priv(netdev);
+       int i;
+
+       netif_wake_queue(netdev);
+       if (netif_is_multiqueue(netdev))
+               for (i = 0; i < adapter->num_tx_queues; i++)
+                       netif_wake_subqueue(netdev, i);
+}
+void _kc_netif_tx_start_all_queues(struct net_device *netdev)
+{
+       struct adapter_struct *adapter = netdev_priv(netdev);
+       int i;
+
+       netif_start_queue(netdev);
+       if (netif_is_multiqueue(netdev))
+               for (i = 0; i < adapter->num_tx_queues; i++)
+                       netif_start_subqueue(netdev, i);
+}
+#endif /* HAVE_TX_MQ */
+#endif /* <= 2.6.27 */
diff --git a/drivers/net/igb/kcompat.h b/drivers/net/igb/kcompat.h
new file mode 100644 (file)
index 0000000..32cc976
--- /dev/null
@@ -0,0 +1,1637 @@
+/*******************************************************************************
+
+  Intel(R) Gigabit Ethernet Linux driver
+  Copyright(c) 2007-2008 Intel Corporation.
+
+  This program is free software; you can redistribute it and/or modify it
+  under the terms and conditions of the GNU General Public License,
+  version 2, as published by the Free Software Foundation.
+
+  This program is distributed in the hope it will be useful, but WITHOUT
+  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+  FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
+  more details.
+
+  You should have received a copy of the GNU General Public License along with
+  this program; if not, write to the Free Software Foundation, Inc.,
+  51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
+
+  The full GNU General Public License is included in this distribution in
+  the file called "COPYING".
+
+  Contact Information:
+  e1000-devel Mailing List <e1000-devel@lists.sourceforge.net>
+  Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
+
+*******************************************************************************/
+
+#ifndef _KCOMPAT_H_
+#define _KCOMPAT_H_
+
+#include <linux/version.h>
+#include <linux/init.h>
+#include <linux/types.h>
+#include <linux/errno.h>
+#include <linux/module.h>
+#include <linux/pci.h>
+#include <linux/netdevice.h>
+#include <linux/etherdevice.h>
+#include <linux/skbuff.h>
+#include <linux/ioport.h>
+#include <linux/slab.h>
+#include <linux/list.h>
+#include <linux/delay.h>
+#include <linux/sched.h>
+#include <linux/in.h>
+#include <linux/ip.h>
+#include <linux/udp.h>
+#include <linux/mii.h>
+#include <asm/io.h>
+
+/* NAPI enable/disable flags here */
+
+
+#ifdef _E1000_H_
+#ifdef CONFIG_E1000_NAPI
+#define NAPI
+#endif
+#ifdef E1000_NAPI
+#undef NAPI
+#define NAPI
+#endif
+#ifdef E1000E_NAPI
+#undef NAPI
+#define NAPI
+#endif
+#ifdef E1000_NO_NAPI
+#undef NAPI
+#endif
+#ifdef E1000E_NO_NAPI
+#undef NAPI
+#endif
+#endif
+
+#ifdef _IGB_H_
+#define NAPI
+#endif
+
+
+
+
+
+
+
+#define adapter_struct igb_adapter
+#define NAPI
+
+
+
+/* and finally set defines so that the code sees the changes */
+#ifdef NAPI
+#ifndef CONFIG_E1000_NAPI
+#define CONFIG_E1000_NAPI
+#endif
+#ifndef CONFIG_E1000E_NAPI
+#define CONFIG_E1000E_NAPI
+#endif
+#else
+#undef CONFIG_E1000_NAPI
+#undef CONFIG_E1000E_NAPI
+#undef CONFIG_IXGB_NAPI
+#endif
+
+/* packet split disable/enable */
+#ifdef DISABLE_PACKET_SPLIT
+#undef CONFIG_E1000_DISABLE_PACKET_SPLIT
+#define CONFIG_E1000_DISABLE_PACKET_SPLIT
+#undef CONFIG_IGB_DISABLE_PACKET_SPLIT
+#define CONFIG_IGB_DISABLE_PACKET_SPLIT
+#endif
+
+/* MSI compatibility code for all kernels and drivers */
+#ifdef DISABLE_PCI_MSI
+#undef CONFIG_PCI_MSI
+#endif
+#ifndef CONFIG_PCI_MSI
+#if ( LINUX_VERSION_CODE < KERNEL_VERSION(2,6,8) )
+struct msix_entry {
+       u16 vector; /* kernel uses to write allocated vector */
+       u16 entry;  /* driver uses to specify entry, OS writes */
+};
+#endif
+#define pci_enable_msi(a) -ENOTSUPP
+#define pci_disable_msi(a) do {} while (0)
+#define pci_enable_msix(a, b, c) -ENOTSUPP
+#define pci_disable_msix(a) do {} while (0)
+#define msi_remove_pci_irq_vectors(a) do {} while (0)
+#endif /* CONFIG_PCI_MSI */
+#ifdef DISABLE_PM
+#undef CONFIG_PM
+#endif
+
+#ifdef DISABLE_NET_POLL_CONTROLLER
+#undef CONFIG_NET_POLL_CONTROLLER
+#endif
+
+#ifndef PMSG_SUSPEND
+#define PMSG_SUSPEND 3
+#endif
+
+/* generic boolean compatibility */
+#undef TRUE
+#undef FALSE
+#define TRUE true
+#define FALSE false
+#ifdef GCC_VERSION
+#if ( GCC_VERSION < 3000 )
+#define _Bool char
+#endif
+#endif
+#ifndef bool
+#define bool _Bool
+#define true 1
+#define false 0
+#endif
+
+
+#ifndef module_param
+#define module_param(v,t,p) MODULE_PARM(v, "i");
+#endif
+
+#ifndef DMA_64BIT_MASK
+#define DMA_64BIT_MASK  0xffffffffffffffffULL
+#endif
+
+#ifndef DMA_32BIT_MASK
+#define DMA_32BIT_MASK  0x00000000ffffffffULL
+#endif
+
+#ifndef PCI_CAP_ID_EXP
+#define PCI_CAP_ID_EXP 0x10
+#endif
+
+#ifndef mmiowb
+#ifdef CONFIG_IA64
+#define mmiowb() asm volatile ("mf.a" ::: "memory")
+#else
+#define mmiowb()
+#endif
+#endif
+
+#ifndef IRQ_HANDLED
+#define irqreturn_t void
+#define IRQ_HANDLED
+#define IRQ_NONE
+#endif
+
+#ifndef SET_NETDEV_DEV
+#define SET_NETDEV_DEV(net, pdev)
+#endif
+
+#ifndef HAVE_FREE_NETDEV
+#define free_netdev(x) kfree(x)
+#endif
+
+#ifdef HAVE_POLL_CONTROLLER
+#define CONFIG_NET_POLL_CONTROLLER
+#endif
+
+#ifndef NETDEV_TX_OK
+#define NETDEV_TX_OK 0
+#endif
+
+#ifndef NETDEV_TX_BUSY
+#define NETDEV_TX_BUSY 1
+#endif
+
+#ifndef NETDEV_TX_LOCKED
+#define NETDEV_TX_LOCKED -1
+#endif
+
+#ifndef SKB_DATAREF_SHIFT
+/* if we do not have the infrastructure to detect if skb_header is cloned
+   just return false in all cases */
+#define skb_header_cloned(x) 0
+#endif
+
+#ifndef NETIF_F_GSO
+#define gso_size tso_size
+#define gso_segs tso_segs
+#endif
+
+#ifndef CHECKSUM_PARTIAL
+#define CHECKSUM_PARTIAL CHECKSUM_HW
+#define CHECKSUM_COMPLETE CHECKSUM_HW
+#endif
+
+#ifndef __read_mostly
+#define __read_mostly
+#endif
+
+#ifndef HAVE_NETIF_MSG
+#define HAVE_NETIF_MSG 1
+enum {
+       NETIF_MSG_DRV           = 0x0001,
+       NETIF_MSG_PROBE         = 0x0002,
+       NETIF_MSG_LINK          = 0x0004,
+       NETIF_MSG_TIMER         = 0x0008,
+       NETIF_MSG_IFDOWN        = 0x0010,
+       NETIF_MSG_IFUP          = 0x0020,
+       NETIF_MSG_RX_ERR        = 0x0040,
+       NETIF_MSG_TX_ERR        = 0x0080,
+       NETIF_MSG_TX_QUEUED     = 0x0100,
+       NETIF_MSG_INTR          = 0x0200,
+       NETIF_MSG_TX_DONE       = 0x0400,
+       NETIF_MSG_RX_STATUS     = 0x0800,
+       NETIF_MSG_PKTDATA       = 0x1000,
+       NETIF_MSG_HW            = 0x2000,
+       NETIF_MSG_WOL           = 0x4000,
+};
+
+#else
+#define NETIF_MSG_HW   0x2000
+#define NETIF_MSG_WOL  0x4000
+#endif /* HAVE_NETIF_MSG */
+
+#ifndef MII_RESV1
+#define MII_RESV1              0x17            /* Reserved...          */
+#endif
+
+#ifndef unlikely
+#define unlikely(_x) _x
+#define likely(_x) _x
+#endif
+
+#ifndef WARN_ON
+#define WARN_ON(x)
+#endif
+
+#ifndef PCI_DEVICE
+#define PCI_DEVICE(vend,dev) \
+       .vendor = (vend), .device = (dev), \
+       .subvendor = PCI_ANY_ID, .subdevice = PCI_ANY_ID
+#endif
+
+#ifndef num_online_cpus
+#define num_online_cpus() smp_num_cpus
+#endif
+
+#ifndef _LINUX_RANDOM_H
+#include <linux/random.h>
+#endif
+
+#ifndef DECLARE_BITMAP
+#ifndef BITS_TO_LONGS
+#define BITS_TO_LONGS(bits) (((bits)+BITS_PER_LONG-1)/BITS_PER_LONG)
+#endif
+#define DECLARE_BITMAP(name,bits) long name[BITS_TO_LONGS(bits)]
+#endif
+
+#ifndef VLAN_HLEN
+#define VLAN_HLEN 4
+#endif
+
+#ifndef VLAN_ETH_HLEN
+#define VLAN_ETH_HLEN 18
+#endif
+
+#ifndef VLAN_ETH_FRAME_LEN
+#define VLAN_ETH_FRAME_LEN 1518
+#endif
+
+#ifndef DCA_GET_TAG_TWO_ARGS
+#define dca3_get_tag(a,b) dca_get_tag(b)
+#endif
+
+
+/*****************************************************************************/
+/* Installations with ethtool version without eeprom, adapter id, or statistics
+ * support */
+
+#ifndef ETH_GSTRING_LEN
+#define ETH_GSTRING_LEN 32
+#endif
+
+#ifndef ETHTOOL_GSTATS
+#define ETHTOOL_GSTATS 0x1d
+#undef ethtool_drvinfo
+#define ethtool_drvinfo k_ethtool_drvinfo
+struct k_ethtool_drvinfo {
+       u32 cmd;
+       char driver[32];
+       char version[32];
+       char fw_version[32];
+       char bus_info[32];
+       char reserved1[32];
+       char reserved2[16];
+       u32 n_stats;
+       u32 testinfo_len;
+       u32 eedump_len;
+       u32 regdump_len;
+};
+
+struct ethtool_stats {
+       u32 cmd;
+       u32 n_stats;
+       u64 data[0];
+};
+#endif /* ETHTOOL_GSTATS */
+
+#ifndef ETHTOOL_PHYS_ID
+#define ETHTOOL_PHYS_ID 0x1c
+#endif /* ETHTOOL_PHYS_ID */
+
+#ifndef ETHTOOL_GSTRINGS
+#define ETHTOOL_GSTRINGS 0x1b
+enum ethtool_stringset {
+       ETH_SS_TEST             = 0,
+       ETH_SS_STATS,
+};
+struct ethtool_gstrings {
+       u32 cmd;            /* ETHTOOL_GSTRINGS */
+       u32 string_set;     /* string set id e.c. ETH_SS_TEST, etc*/
+       u32 len;            /* number of strings in the string set */
+       u8 data[0];
+};
+#endif /* ETHTOOL_GSTRINGS */
+
+#ifndef ETHTOOL_TEST
+#define ETHTOOL_TEST 0x1a
+enum ethtool_test_flags {
+       ETH_TEST_FL_OFFLINE     = (1 << 0),
+       ETH_TEST_FL_FAILED      = (1 << 1),
+};
+struct ethtool_test {
+       u32 cmd;
+       u32 flags;
+       u32 reserved;
+       u32 len;
+       u64 data[0];
+};
+#endif /* ETHTOOL_TEST */
+
+#ifndef ETHTOOL_GEEPROM
+#define ETHTOOL_GEEPROM 0xb
+#undef ETHTOOL_GREGS
+struct ethtool_eeprom {
+       u32 cmd;
+       u32 magic;
+       u32 offset;
+       u32 len;
+       u8 data[0];
+};
+
+struct ethtool_value {
+       u32 cmd;
+       u32 data;
+};
+#endif /* ETHTOOL_GEEPROM */
+
+#ifndef ETHTOOL_GLINK
+#define ETHTOOL_GLINK 0xa
+#endif /* ETHTOOL_GLINK */
+
+#ifndef ETHTOOL_GREGS
+#define ETHTOOL_GREGS          0x00000004 /* Get NIC registers */
+#define ethtool_regs _kc_ethtool_regs
+/* for passing big chunks of data */
+struct _kc_ethtool_regs {
+       u32 cmd;
+       u32 version; /* driver-specific, indicates different chips/revs */
+       u32 len; /* bytes */
+       u8 data[0];
+};
+#endif /* ETHTOOL_GREGS */
+
+#ifndef ETHTOOL_GMSGLVL
+#define ETHTOOL_GMSGLVL                0x00000007 /* Get driver message level */
+#endif
+#ifndef ETHTOOL_SMSGLVL
+#define ETHTOOL_SMSGLVL                0x00000008 /* Set driver msg level, priv. */
+#endif
+#ifndef ETHTOOL_NWAY_RST
+#define ETHTOOL_NWAY_RST       0x00000009 /* Restart autonegotiation, priv */
+#endif
+#ifndef ETHTOOL_GLINK
+#define ETHTOOL_GLINK          0x0000000a /* Get link status */
+#endif
+#ifndef ETHTOOL_GEEPROM
+#define ETHTOOL_GEEPROM                0x0000000b /* Get EEPROM data */
+#endif
+#ifndef ETHTOOL_SEEPROM
+#define ETHTOOL_SEEPROM                0x0000000c /* Set EEPROM data */
+#endif
+#ifndef ETHTOOL_GCOALESCE
+#define ETHTOOL_GCOALESCE      0x0000000e /* Get coalesce config */
+/* for configuring coalescing parameters of chip */
+#define ethtool_coalesce _kc_ethtool_coalesce
+struct _kc_ethtool_coalesce {
+       u32     cmd;    /* ETHTOOL_{G,S}COALESCE */
+
+       /* How many usecs to delay an RX interrupt after
+        * a packet arrives.  If 0, only rx_max_coalesced_frames
+        * is used.
+        */
+       u32     rx_coalesce_usecs;
+
+       /* How many packets to delay an RX interrupt after
+        * a packet arrives.  If 0, only rx_coalesce_usecs is
+        * used.  It is illegal to set both usecs and max frames
+        * to zero as this would cause RX interrupts to never be
+        * generated.
+        */
+       u32     rx_max_coalesced_frames;
+
+       /* Same as above two parameters, except that these values
+        * apply while an IRQ is being serviced by the host.  Not
+        * all cards support this feature and the values are ignored
+        * in that case.
+        */
+       u32     rx_coalesce_usecs_irq;
+       u32     rx_max_coalesced_frames_irq;
+
+       /* How many usecs to delay a TX interrupt after
+        * a packet is sent.  If 0, only tx_max_coalesced_frames
+        * is used.
+        */
+       u32     tx_coalesce_usecs;
+
+       /* How many packets to delay a TX interrupt after
+        * a packet is sent.  If 0, only tx_coalesce_usecs is
+        * used.  It is illegal to set both usecs and max frames
+        * to zero as this would cause TX interrupts to never be
+        * generated.
+        */
+       u32     tx_max_coalesced_frames;
+
+       /* Same as above two parameters, except that these values
+        * apply while an IRQ is being serviced by the host.  Not
+        * all cards support this feature and the values are ignored
+        * in that case.
+        */
+       u32     tx_coalesce_usecs_irq;
+       u32     tx_max_coalesced_frames_irq;
+
+       /* How many usecs to delay in-memory statistics
+        * block updates.  Some drivers do not have an in-memory
+        * statistic block, and in such cases this value is ignored.
+        * This value must not be zero.
+        */
+       u32     stats_block_coalesce_usecs;
+
+       /* Adaptive RX/TX coalescing is an algorithm implemented by
+        * some drivers to improve latency under low packet rates and
+        * improve throughput under high packet rates.  Some drivers
+        * only implement one of RX or TX adaptive coalescing.  Anything
+        * not implemented by the driver causes these values to be
+        * silently ignored.
+        */
+       u32     use_adaptive_rx_coalesce;
+       u32     use_adaptive_tx_coalesce;
+
+       /* When the packet rate (measured in packets per second)
+        * is below pkt_rate_low, the {rx,tx}_*_low parameters are
+        * used.
+        */
+       u32     pkt_rate_low;
+       u32     rx_coalesce_usecs_low;
+       u32     rx_max_coalesced_frames_low;
+       u32     tx_coalesce_usecs_low;
+       u32     tx_max_coalesced_frames_low;
+
+       /* When the packet rate is below pkt_rate_high but above
+        * pkt_rate_low (both measured in packets per second) the
+        * normal {rx,tx}_* coalescing parameters are used.
+        */
+
+       /* When the packet rate is (measured in packets per second)
+        * is above pkt_rate_high, the {rx,tx}_*_high parameters are
+        * used.
+        */
+       u32     pkt_rate_high;
+       u32     rx_coalesce_usecs_high;
+       u32     rx_max_coalesced_frames_high;
+       u32     tx_coalesce_usecs_high;
+       u32     tx_max_coalesced_frames_high;
+
+       /* How often to do adaptive coalescing packet rate sampling,
+        * measured in seconds.  Must not be zero.
+        */
+       u32     rate_sample_interval;
+};
+#endif /* ETHTOOL_GCOALESCE */
+
+#ifndef ETHTOOL_SCOALESCE
+#define ETHTOOL_SCOALESCE      0x0000000f /* Set coalesce config. */
+#endif
+#ifndef ETHTOOL_GRINGPARAM
+#define ETHTOOL_GRINGPARAM     0x00000010 /* Get ring parameters */
+/* for configuring RX/TX ring parameters */
+#define ethtool_ringparam _kc_ethtool_ringparam
+struct _kc_ethtool_ringparam {
+       u32     cmd;    /* ETHTOOL_{G,S}RINGPARAM */
+
+       /* Read only attributes.  These indicate the maximum number
+        * of pending RX/TX ring entries the driver will allow the
+        * user to set.
+        */
+       u32     rx_max_pending;
+       u32     rx_mini_max_pending;
+       u32     rx_jumbo_max_pending;
+       u32     tx_max_pending;
+
+       /* Values changeable by the user.  The valid values are
+        * in the range 1 to the "*_max_pending" counterpart above.
+        */
+       u32     rx_pending;
+       u32     rx_mini_pending;
+       u32     rx_jumbo_pending;
+       u32     tx_pending;
+};
+#endif /* ETHTOOL_GRINGPARAM */
+
+#ifndef ETHTOOL_SRINGPARAM
+#define ETHTOOL_SRINGPARAM     0x00000011 /* Set ring parameters, priv. */
+#endif
+#ifndef ETHTOOL_GPAUSEPARAM
+#define ETHTOOL_GPAUSEPARAM    0x00000012 /* Get pause parameters */
+/* for configuring link flow control parameters */
+#define ethtool_pauseparam _kc_ethtool_pauseparam
+struct _kc_ethtool_pauseparam {
+       u32     cmd;    /* ETHTOOL_{G,S}PAUSEPARAM */
+
+       /* If the link is being auto-negotiated (via ethtool_cmd.autoneg
+        * being true) the user may set 'autoneg' here non-zero to have the
+        * pause parameters be auto-negotiated too.  In such a case, the
+        * {rx,tx}_pause values below determine what capabilities are
+        * advertised.
+        *
+        * If 'autoneg' is zero or the link is not being auto-negotiated,
+        * then {rx,tx}_pause force the driver to use/not-use pause
+        * flow control.
+        */
+       u32     autoneg;
+       u32     rx_pause;
+       u32     tx_pause;
+};
+#endif /* ETHTOOL_GPAUSEPARAM */
+
+#ifndef ETHTOOL_SPAUSEPARAM
+#define ETHTOOL_SPAUSEPARAM    0x00000013 /* Set pause parameters. */
+#endif
+#ifndef ETHTOOL_GRXCSUM
+#define ETHTOOL_GRXCSUM                0x00000014 /* Get RX hw csum enable (ethtool_value) */
+#endif
+#ifndef ETHTOOL_SRXCSUM
+#define ETHTOOL_SRXCSUM                0x00000015 /* Set RX hw csum enable (ethtool_value) */
+#endif
+#ifndef ETHTOOL_GTXCSUM
+#define ETHTOOL_GTXCSUM                0x00000016 /* Get TX hw csum enable (ethtool_value) */
+#endif
+#ifndef ETHTOOL_STXCSUM
+#define ETHTOOL_STXCSUM                0x00000017 /* Set TX hw csum enable (ethtool_value) */
+#endif
+#ifndef ETHTOOL_GSG
+#define ETHTOOL_GSG            0x00000018 /* Get scatter-gather enable
+                                           * (ethtool_value) */
+#endif
+#ifndef ETHTOOL_SSG
+#define ETHTOOL_SSG            0x00000019 /* Set scatter-gather enable
+                                           * (ethtool_value). */
+#endif
+#ifndef ETHTOOL_TEST
+#define ETHTOOL_TEST           0x0000001a /* execute NIC self-test, priv. */
+#endif
+#ifndef ETHTOOL_GSTRINGS
+#define ETHTOOL_GSTRINGS       0x0000001b /* get specified string set */
+#endif
+#ifndef ETHTOOL_PHYS_ID
+#define ETHTOOL_PHYS_ID                0x0000001c /* identify the NIC */
+#endif
+#ifndef ETHTOOL_GSTATS
+#define ETHTOOL_GSTATS         0x0000001d /* get NIC-specific statistics */
+#endif
+#ifndef ETHTOOL_GTSO
+#define ETHTOOL_GTSO           0x0000001e /* Get TSO enable (ethtool_value) */
+#endif
+#ifndef ETHTOOL_STSO
+#define ETHTOOL_STSO           0x0000001f /* Set TSO enable (ethtool_value) */
+#endif
+
+#ifndef ETHTOOL_BUSINFO_LEN
+#define ETHTOOL_BUSINFO_LEN    32
+#endif
+
+/*****************************************************************************/
+/* 2.4.3 => 2.4.0 */
+#if ( LINUX_VERSION_CODE < KERNEL_VERSION(2,4,3) )
+
+/**************************************/
+/* PCI DRIVER API */
+
+#ifndef pci_set_dma_mask
+#define pci_set_dma_mask _kc_pci_set_dma_mask
+extern int _kc_pci_set_dma_mask(struct pci_dev *dev, dma_addr_t mask);
+#endif
+
+#ifndef pci_request_regions
+#define pci_request_regions _kc_pci_request_regions
+extern int _kc_pci_request_regions(struct pci_dev *pdev, char *res_name);
+#endif
+
+#ifndef pci_release_regions
+#define pci_release_regions _kc_pci_release_regions
+extern void _kc_pci_release_regions(struct pci_dev *pdev);
+#endif
+
+/**************************************/
+/* NETWORK DRIVER API */
+
+#ifndef alloc_etherdev
+#define alloc_etherdev _kc_alloc_etherdev
+extern struct net_device * _kc_alloc_etherdev(int sizeof_priv);
+#endif
+
+#ifndef is_valid_ether_addr
+#define is_valid_ether_addr _kc_is_valid_ether_addr
+extern int _kc_is_valid_ether_addr(u8 *addr);
+#endif
+
+/**************************************/
+/* MISCELLANEOUS */
+
+#ifndef INIT_TQUEUE
+#define INIT_TQUEUE(_tq, _routine, _data)              \
+       do {                                            \
+               INIT_LIST_HEAD(&(_tq)->list);           \
+               (_tq)->sync = 0;                        \
+               (_tq)->routine = _routine;              \
+               (_tq)->data = _data;                    \
+       } while (0)
+#endif
+
+#endif /* 2.4.3 => 2.4.0 */
+
+/*****************************************************************************/
+#if ( LINUX_VERSION_CODE < KERNEL_VERSION(2,4,5) )
+/* Generic MII registers. */
+#define MII_BMCR            0x00        /* Basic mode control register */
+#define MII_BMSR            0x01        /* Basic mode status register  */
+#define MII_PHYSID1         0x02        /* PHYS ID 1                   */
+#define MII_PHYSID2         0x03        /* PHYS ID 2                   */
+#define MII_ADVERTISE       0x04        /* Advertisement control reg   */
+#define MII_LPA             0x05        /* Link partner ability reg    */
+#define MII_EXPANSION       0x06        /* Expansion register          */
+/* Basic mode control register. */
+#define BMCR_FULLDPLX           0x0100  /* Full duplex                 */
+#define BMCR_ANENABLE           0x1000  /* Enable auto negotiation     */
+/* Basic mode status register. */
+#define BMSR_ERCAP              0x0001  /* Ext-reg capability          */
+#define BMSR_ANEGCAPABLE        0x0008  /* Able to do auto-negotiation */
+#define BMSR_10HALF             0x0800  /* Can do 10mbps, half-duplex  */
+#define BMSR_10FULL             0x1000  /* Can do 10mbps, full-duplex  */
+#define BMSR_100HALF            0x2000  /* Can do 100mbps, half-duplex */
+#define BMSR_100FULL            0x4000  /* Can do 100mbps, full-duplex */
+/* Advertisement control register. */
+#define ADVERTISE_CSMA          0x0001  /* Only selector supported     */
+#define ADVERTISE_10HALF        0x0020  /* Try for 10mbps half-duplex  */
+#define ADVERTISE_10FULL        0x0040  /* Try for 10mbps full-duplex  */
+#define ADVERTISE_100HALF       0x0080  /* Try for 100mbps half-duplex */
+#define ADVERTISE_100FULL       0x0100  /* Try for 100mbps full-duplex */
+#define ADVERTISE_ALL (ADVERTISE_10HALF | ADVERTISE_10FULL | \
+                       ADVERTISE_100HALF | ADVERTISE_100FULL)
+/* Expansion register for auto-negotiation. */
+#define EXPANSION_ENABLENPAGE   0x0004  /* This enables npage words    */
+#endif
+
+/*****************************************************************************/
+/* 2.4.6 => 2.4.3 */
+#if ( LINUX_VERSION_CODE < KERNEL_VERSION(2,4,6) )
+
+#ifndef pci_set_power_state
+#define pci_set_power_state _kc_pci_set_power_state
+extern int _kc_pci_set_power_state(struct pci_dev *dev, int state);
+#endif
+
+#ifndef pci_enable_wake
+#define pci_enable_wake _kc_pci_enable_wake
+extern int _kc_pci_enable_wake(struct pci_dev *pdev, u32 state, int enable);
+#endif
+
+#ifndef pci_disable_device
+#define pci_disable_device _kc_pci_disable_device
+extern void _kc_pci_disable_device(struct pci_dev *pdev);
+#endif
+
+/* PCI PM entry point syntax changed, so don't support suspend/resume */
+#undef CONFIG_PM
+
+#endif /* 2.4.6 => 2.4.3 */
+
+#ifndef HAVE_PCI_SET_MWI
+#define pci_set_mwi(X) pci_write_config_word(X, \
+                              PCI_COMMAND, adapter->hw.bus.pci_cmd_word | \
+                              PCI_COMMAND_INVALIDATE);
+#define pci_clear_mwi(X) pci_write_config_word(X, \
+                              PCI_COMMAND, adapter->hw.bus.pci_cmd_word & \
+                              ~PCI_COMMAND_INVALIDATE);
+#endif
+
+/*****************************************************************************/
+/* 2.4.10 => 2.4.9 */
+#if ( LINUX_VERSION_CODE < KERNEL_VERSION(2,4,10) )
+
+/**************************************/
+/* MODULE API */
+
+#ifndef MODULE_LICENSE
+       #define MODULE_LICENSE(X)
+#endif
+
+/**************************************/
+/* OTHER */
+
+#undef min
+#define min(x,y) ({ \
+       const typeof(x) _x = (x);       \
+       const typeof(y) _y = (y);       \
+       (void) (&_x == &_y);            \
+       _x < _y ? _x : _y; })
+
+#undef max
+#define max(x,y) ({ \
+       const typeof(x) _x = (x);       \
+       const typeof(y) _y = (y);       \
+       (void) (&_x == &_y);            \
+       _x > _y ? _x : _y; })
+
+#ifndef list_for_each_safe
+#define list_for_each_safe(pos, n, head) \
+       for (pos = (head)->next, n = pos->next; pos != (head); \
+               pos = n, n = pos->next)
+#endif
+
+#endif /* 2.4.10 -> 2.4.6 */
+
+
+/*****************************************************************************/
+/* 2.4.13 => 2.4.10 */
+#if ( LINUX_VERSION_CODE < KERNEL_VERSION(2,4,13) )
+
+/**************************************/
+/* PCI DMA MAPPING */
+
+#ifndef virt_to_page
+       #define virt_to_page(v) (mem_map + (virt_to_phys(v) >> PAGE_SHIFT))
+#endif
+
+#ifndef pci_map_page
+#define pci_map_page _kc_pci_map_page
+extern u64 _kc_pci_map_page(struct pci_dev *dev, struct page *page, unsigned long offset, size_t size, int direction);
+#endif
+
+#ifndef pci_unmap_page
+#define pci_unmap_page _kc_pci_unmap_page
+extern void _kc_pci_unmap_page(struct pci_dev *dev, u64 dma_addr, size_t size, int direction);
+#endif
+
+/* pci_set_dma_mask takes dma_addr_t, which is only 32-bits prior to 2.4.13 */
+
+#undef DMA_32BIT_MASK
+#define DMA_32BIT_MASK 0xffffffff
+#undef DMA_64BIT_MASK
+#define DMA_64BIT_MASK 0xffffffff
+
+/**************************************/
+/* OTHER */
+
+#ifndef cpu_relax
+#define cpu_relax()    rep_nop()
+#endif
+
+#endif /* 2.4.13 => 2.4.10 */
+
+/*****************************************************************************/
+/* 2.4.17 => 2.4.12 */
+#if ( LINUX_VERSION_CODE < KERNEL_VERSION(2,4,17) )
+
+#ifndef __devexit_p
+       #define __devexit_p(x) &(x)
+#endif
+
+#endif /* 2.4.17 => 2.4.13 */
+
+/*****************************************************************************/
+/* 2.4.20 => 2.4.19 */
+#if ( LINUX_VERSION_CODE < KERNEL_VERSION(2,4,20) )
+
+/* we won't support NAPI on less than 2.4.20 */
+#ifdef NAPI
+#undef CONFIG_E1000_NAPI
+#undef CONFIG_E1000E_NAPI
+#undef CONFIG_IXGB_NAPI
+#endif
+
+#endif /* 2.4.20 => 2.4.19 */
+/*****************************************************************************/
+/* 2.4.22 => 2.4.17 */
+#if ( LINUX_VERSION_CODE < KERNEL_VERSION(2,4,22) )
+#define pci_name(x)    ((x)->slot_name)
+#endif
+
+/*****************************************************************************/
+/* 2.4.22 => 2.4.17 */
+
+#if ( LINUX_VERSION_CODE < KERNEL_VERSION(2,4,22) )
+#endif
+
+/*****************************************************************************/
+/*****************************************************************************/
+/* 2.4.23 => 2.4.22 */
+#if ( LINUX_VERSION_CODE < KERNEL_VERSION(2,4,23) )
+/*****************************************************************************/
+#ifdef NAPI
+#ifndef netif_poll_disable
+#define netif_poll_disable(x) _kc_netif_poll_disable(x)
+static inline void _kc_netif_poll_disable(struct net_device *netdev)
+{
+       while (test_and_set_bit(__LINK_STATE_RX_SCHED, &netdev->state)) {
+               /* No hurry */
+               current->state = TASK_INTERRUPTIBLE;
+               schedule_timeout(1);
+       }
+}
+#endif
+
+#ifndef netif_poll_enable
+#define netif_poll_enable(x) _kc_netif_poll_enable(x)
+static inline void _kc_netif_poll_enable(struct net_device *netdev)
+{
+       clear_bit(__LINK_STATE_RX_SCHED, &netdev->state);
+}
+#endif
+#endif /* NAPI */
+#ifndef netif_tx_disable
+#define netif_tx_disable(x) _kc_netif_tx_disable(x)
+static inline void _kc_netif_tx_disable(struct net_device *dev)
+{
+       spin_lock_bh(&dev->xmit_lock);
+       netif_stop_queue(dev);
+       spin_unlock_bh(&dev->xmit_lock);
+}
+#endif
+#endif /* 2.4.23 => 2.4.22 */
+
+/*****************************************************************************/
+/* 2.6.4 => 2.6.0 */
+#if ( LINUX_VERSION_CODE < KERNEL_VERSION(2,4,25) || \
+    ( LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0) && \
+      LINUX_VERSION_CODE < KERNEL_VERSION(2,6,4) ) )
+#define ETHTOOL_OPS_COMPAT
+#endif /* 2.6.4 => 2.6.0 */
+
+/*****************************************************************************/
+/* 2.5.71 => 2.4.x */
+#if ( LINUX_VERSION_CODE < KERNEL_VERSION(2,5,71) )
+#include <net/sock.h>
+#define sk_protocol protocol
+
+#define pci_get_device pci_find_device
+#endif /* 2.5.70 => 2.4.x */
+
+/*****************************************************************************/
+/* < 2.4.27 or 2.6.0 <= 2.6.5 */
+#if ( LINUX_VERSION_CODE < KERNEL_VERSION(2,4,27) || \
+    ( LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0) && \
+      LINUX_VERSION_CODE < KERNEL_VERSION(2,6,5) ) )
+
+#ifndef netif_msg_init
+#define netif_msg_init _kc_netif_msg_init
+static inline u32 _kc_netif_msg_init(int debug_value, int default_msg_enable_bits)
+{
+       /* use default */
+       if (debug_value < 0 || debug_value >= (sizeof(u32) * 8))
+               return default_msg_enable_bits;
+       if (debug_value == 0) /* no output */
+               return 0;
+       /* set low N bits */
+       return (1 << debug_value) -1;
+}
+#endif
+
+#endif /* < 2.4.27 or 2.6.0 <= 2.6.5 */
+/*****************************************************************************/
+#if (( LINUX_VERSION_CODE < KERNEL_VERSION(2,4,27) ) || \
+     (( LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0) ) && \
+      ( LINUX_VERSION_CODE < KERNEL_VERSION(2,6,3) )))
+#define netdev_priv(x) x->priv
+#endif
+
+/*****************************************************************************/
+/* <= 2.5.0 */
+#if ( LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0) )
+#undef pci_register_driver
+#define pci_register_driver pci_module_init
+
+#define dev_err(__unused_dev, format, arg...)            \
+       printk(KERN_ERR "%s: " format, pci_name(adapter->pdev) , ## arg)
+#define dev_warn(__unused_dev, format, arg...)            \
+       printk(KERN_WARNING "%s: " format, pci_name(pdev) , ## arg)
+
+/* hlist_* code - double linked lists */
+struct hlist_head {
+       struct hlist_node *first;
+};
+
+struct hlist_node {
+       struct hlist_node *next, **pprev;
+};
+
+static inline void __hlist_del(struct hlist_node *n)
+{
+       struct hlist_node *next = n->next;
+       struct hlist_node **pprev = n->pprev;
+       *pprev = next;
+       if (next)
+       next->pprev = pprev;
+}
+
+static inline void hlist_del(struct hlist_node *n)
+{
+       __hlist_del(n);
+       n->next = NULL;
+       n->pprev = NULL;
+}
+
+static inline void hlist_add_head(struct hlist_node *n, struct hlist_head *h)
+{
+       struct hlist_node *first = h->first;
+       n->next = first;
+       if (first)
+               first->pprev = &n->next;
+       h->first = n;
+       n->pprev = &h->first;
+}
+
+static inline int hlist_empty(const struct hlist_head *h)
+{
+       return !h->first;
+}
+#define HLIST_HEAD_INIT { .first = NULL }
+#define HLIST_HEAD(name) struct hlist_head name = {  .first = NULL }
+#define INIT_HLIST_HEAD(ptr) ((ptr)->first = NULL)
+static inline void INIT_HLIST_NODE(struct hlist_node *h)
+{
+       h->next = NULL;
+       h->pprev = NULL;
+}
+#define hlist_entry(ptr, type, member) container_of(ptr,type,member)
+
+#define hlist_for_each_entry(tpos, pos, head, member)                    \
+       for (pos = (head)->first;                                        \
+            pos && ({ prefetch(pos->next); 1;}) &&                      \
+               ({ tpos = hlist_entry(pos, typeof(*tpos), member); 1;}); \
+            pos = pos->next)
+
+#define hlist_for_each_entry_safe(tpos, pos, n, head, member)            \
+       for (pos = (head)->first;                                        \
+            pos && ({ n = pos->next; 1; }) &&                           \
+               ({ tpos = hlist_entry(pos, typeof(*tpos), member); 1;}); \
+            pos = n)
+
+/* we ignore GFP here */
+#define dma_alloc_coherent(dv, sz, dma, gfp) \
+       pci_alloc_consistent(pdev, (sz), (dma))
+#define dma_free_coherent(dv, sz, addr, dma_addr) \
+       pci_free_consistent(pdev, (sz), (addr), (dma_addr))
+
+#ifndef might_sleep
+#define might_sleep()
+#endif
+
+#ifndef NETREG_REGISTERED
+#define NETREG_REGISTERED 1
+#define reg_state deadbeaf
+#endif
+#endif /* <= 2.5.0 */
+
+/*****************************************************************************/
+/* 2.5.28 => 2.4.23 */
+#if ( LINUX_VERSION_CODE < KERNEL_VERSION(2,5,28) )
+
+static inline void _kc_synchronize_irq(void)
+{
+       synchronize_irq();
+}
+#undef synchronize_irq
+#define synchronize_irq(X) _kc_synchronize_irq()
+
+#include <linux/tqueue.h>
+#define work_struct tq_struct
+#undef INIT_WORK
+#define INIT_WORK(a,b) INIT_TQUEUE(a,(void (*)(void *))b,a)
+#undef container_of
+#define container_of list_entry
+#define schedule_work schedule_task
+#define flush_scheduled_work flush_scheduled_tasks
+#define cancel_work_sync(x) flush_scheduled_work()
+
+#endif /* 2.5.28 => 2.4.17 */
+
+/*****************************************************************************/
+/* 2.6.0 => 2.5.28 */
+#if ( LINUX_VERSION_CODE < KERNEL_VERSION(2,6,0) )
+#define MODULE_INFO(version, _version)
+#ifndef CONFIG_E1000_DISABLE_PACKET_SPLIT
+#define CONFIG_E1000_DISABLE_PACKET_SPLIT 1
+#endif
+#ifndef CONFIG_IGB_DISABLE_PACKET_SPLIT
+#define CONFIG_IGB_DISABLE_PACKET_SPLIT 1
+#endif
+
+#define pci_set_consistent_dma_mask(dev,mask) 1
+
+#undef dev_put
+#define dev_put(dev) __dev_put(dev)
+
+#ifndef skb_fill_page_desc
+#define skb_fill_page_desc _kc_skb_fill_page_desc
+extern void _kc_skb_fill_page_desc(struct sk_buff *skb, int i, struct page *page, int off, int size);
+#endif
+
+#undef ALIGN
+#define ALIGN(x,a) (((x)+(a)-1)&~((a)-1))
+
+#ifndef page_count
+#define page_count(p) atomic_read(&(p)->count)
+#endif
+
+/* find_first_bit and find_next bit are not defined for most
+ * 2.4 kernels (except for the redhat 2.4.21 kernels
+ */
+#include <linux/bitops.h>
+#define BITOP_WORD(nr)          ((nr) / BITS_PER_LONG)
+#undef find_next_bit
+#define find_next_bit _kc_find_next_bit
+extern unsigned long _kc_find_next_bit(const unsigned long *addr,
+                                       unsigned long size,
+                                       unsigned long offset);
+#define find_first_bit(addr, size) find_next_bit((addr), (size), 0)
+
+#endif /* 2.6.0 => 2.5.28 */
+
+/*****************************************************************************/
+/* 2.6.4 => 2.6.0 */
+#if ( LINUX_VERSION_CODE < KERNEL_VERSION(2,6,4) )
+#define MODULE_VERSION(_version) MODULE_INFO(version, _version)
+#endif /* 2.6.4 => 2.6.0 */
+
+/*****************************************************************************/
+/* 2.6.5 => 2.6.0 */
+#if ( LINUX_VERSION_CODE < KERNEL_VERSION(2,6,5) )
+#define pci_dma_sync_single_for_cpu    pci_dma_sync_single
+#define pci_dma_sync_single_for_device pci_dma_sync_single_for_cpu
+#endif /* 2.6.5 => 2.6.0 */
+
+/*****************************************************************************/
+#if ( LINUX_VERSION_CODE < KERNEL_VERSION(2,6,6) )
+/* taken from 2.6 include/linux/bitmap.h */
+#undef bitmap_zero
+#define bitmap_zero _kc_bitmap_zero
+static inline void _kc_bitmap_zero(unsigned long *dst, int nbits)
+{
+        if (nbits <= BITS_PER_LONG)
+                *dst = 0UL;
+        else {
+                int len = BITS_TO_LONGS(nbits) * sizeof(unsigned long);
+                memset(dst, 0, len);
+        }
+}
+#endif /* < 2.6.6 */
+
+/*****************************************************************************/
+#if ( LINUX_VERSION_CODE < KERNEL_VERSION(2,6,7) )
+#undef if_mii
+#define if_mii _kc_if_mii
+static inline struct mii_ioctl_data *_kc_if_mii(struct ifreq *rq)
+{
+       return (struct mii_ioctl_data *) &rq->ifr_ifru;
+}
+#endif /* < 2.6.7 */
+
+/*****************************************************************************/
+#if ( LINUX_VERSION_CODE < KERNEL_VERSION(2,6,8) )
+#define msleep(x)      do { set_current_state(TASK_UNINTERRUPTIBLE); \
+                               schedule_timeout((x * HZ)/1000 + 2); \
+                       } while (0)
+
+#endif /* < 2.6.8 */
+
+/*****************************************************************************/
+#if ( LINUX_VERSION_CODE < KERNEL_VERSION(2,6,9))
+#include <net/dsfield.h>
+#define __iomem
+
+#ifndef kcalloc
+#define kcalloc(n, size, flags) _kc_kzalloc(((n) * (size)), flags)
+extern void *_kc_kzalloc(size_t size, int flags);
+#endif
+#define MSEC_PER_SEC    1000L
+static inline unsigned int _kc_jiffies_to_msecs(const unsigned long j)
+{
+#if HZ <= MSEC_PER_SEC && !(MSEC_PER_SEC % HZ)
+       return (MSEC_PER_SEC / HZ) * j;
+#elif HZ > MSEC_PER_SEC && !(HZ % MSEC_PER_SEC)
+       return (j + (HZ / MSEC_PER_SEC) - 1)/(HZ / MSEC_PER_SEC);
+#else
+       return (j * MSEC_PER_SEC) / HZ;
+#endif
+}
+static inline unsigned long _kc_msecs_to_jiffies(const unsigned int m)
+{
+       if (m > _kc_jiffies_to_msecs(MAX_JIFFY_OFFSET))
+               return MAX_JIFFY_OFFSET;
+#if HZ <= MSEC_PER_SEC && !(MSEC_PER_SEC % HZ)
+       return (m + (MSEC_PER_SEC / HZ) - 1) / (MSEC_PER_SEC / HZ);
+#elif HZ > MSEC_PER_SEC && !(HZ % MSEC_PER_SEC)
+       return m * (HZ / MSEC_PER_SEC);
+#else
+       return (m * HZ + MSEC_PER_SEC - 1) / MSEC_PER_SEC;
+#endif
+}
+
+#define msleep_interruptible _kc_msleep_interruptible
+static inline unsigned long _kc_msleep_interruptible(unsigned int msecs)
+{
+       unsigned long timeout = _kc_msecs_to_jiffies(msecs) + 1;
+
+       while (timeout && !signal_pending(current)) {
+               __set_current_state(TASK_INTERRUPTIBLE);
+               timeout = schedule_timeout(timeout);
+       }
+       return _kc_jiffies_to_msecs(timeout);
+}
+
+/* Basic mode control register. */
+#define BMCR_SPEED1000         0x0040  /* MSB of Speed (1000)         */
+
+#ifndef __le16
+#define __le16 u16
+#endif
+#ifndef __le32
+#define __le32 u32
+#endif
+#ifndef __le64
+#define __le64 u64
+#endif
+#endif /* < 2.6.9 */
+
+/*****************************************************************************/
+#if ( LINUX_VERSION_CODE < KERNEL_VERSION(2,6,10) )
+#ifdef module_param_array_named
+#undef module_param_array_named
+#define module_param_array_named(name, array, type, nump, perm)          \
+       static struct kparam_array __param_arr_##name                    \
+       = { ARRAY_SIZE(array), nump, param_set_##type, param_get_##type, \
+           sizeof(array[0]), array };                                   \
+       module_param_call(name, param_array_set, param_array_get,        \
+                         &__param_arr_##name, perm)
+#endif /* module_param_array_named */
+#endif /* < 2.6.10 */
+
+/*****************************************************************************/
+#if ( LINUX_VERSION_CODE < KERNEL_VERSION(2,6,11) )
+#define PCI_D0      0
+#define PCI_D1      1
+#define PCI_D2      2
+#define PCI_D3hot   3
+#define PCI_D3cold  4
+#define pci_choose_state(pdev,state) state
+#define PMSG_SUSPEND 3
+#define PCI_EXP_LNKCTL 16
+
+#undef NETIF_F_LLTX
+
+#ifndef ARCH_HAS_PREFETCH
+#define prefetch(X)
+#endif
+
+#ifndef NET_IP_ALIGN
+#define NET_IP_ALIGN 2
+#endif
+
+#define KC_USEC_PER_SEC        1000000L
+#define usecs_to_jiffies _kc_usecs_to_jiffies
+static inline unsigned int _kc_jiffies_to_usecs(const unsigned long j)
+{
+#if HZ <= KC_USEC_PER_SEC && !(KC_USEC_PER_SEC % HZ)
+       return (KC_USEC_PER_SEC / HZ) * j;
+#elif HZ > KC_USEC_PER_SEC && !(HZ % KC_USEC_PER_SEC)
+       return (j + (HZ / KC_USEC_PER_SEC) - 1)/(HZ / KC_USEC_PER_SEC);
+#else
+       return (j * KC_USEC_PER_SEC) / HZ;
+#endif
+}
+static inline unsigned long _kc_usecs_to_jiffies(const unsigned int m)
+{
+       if (m > _kc_jiffies_to_usecs(MAX_JIFFY_OFFSET))
+               return MAX_JIFFY_OFFSET;
+#if HZ <= KC_USEC_PER_SEC && !(KC_USEC_PER_SEC % HZ)
+       return (m + (KC_USEC_PER_SEC / HZ) - 1) / (KC_USEC_PER_SEC / HZ);
+#elif HZ > KC_USEC_PER_SEC && !(HZ % KC_USEC_PER_SEC)
+       return m * (HZ / KC_USEC_PER_SEC);
+#else
+       return (m * HZ + KC_USEC_PER_SEC - 1) / KC_USEC_PER_SEC;
+#endif
+}
+#endif /* < 2.6.11 */
+
+/*****************************************************************************/
+#if ( LINUX_VERSION_CODE < KERNEL_VERSION(2,6,12) )
+#include <linux/reboot.h>
+#define USE_REBOOT_NOTIFIER
+
+/* Generic MII registers. */
+#define MII_CTRL1000        0x09        /* 1000BASE-T control          */
+#define MII_STAT1000        0x0a        /* 1000BASE-T status           */
+/* Advertisement control register. */
+#define ADVERTISE_PAUSE_CAP     0x0400  /* Try for pause               */
+#define ADVERTISE_PAUSE_ASYM    0x0800  /* Try for asymmetric pause     */
+/* 1000BASE-T Control register */
+#define ADVERTISE_1000FULL      0x0200  /* Advertise 1000BASE-T full duplex */
+#endif
+
+/*****************************************************************************/
+#if ( LINUX_VERSION_CODE < KERNEL_VERSION(2,6,14) )
+#define pm_message_t u32
+#ifndef kzalloc
+#define kzalloc _kc_kzalloc
+extern void *_kc_kzalloc(size_t size, int flags);
+#endif
+
+/* Generic MII registers. */
+#define MII_ESTATUS        0x0f        /* Extended Status */
+/* Basic mode status register. */
+#define BMSR_ESTATEN           0x0100  /* Extended Status in R15 */
+/* Extended status register. */
+#define ESTATUS_1000_TFULL     0x2000  /* Can do 1000BT Full */
+#define ESTATUS_1000_THALF     0x1000  /* Can do 1000BT Half */
+#endif
+
+/*****************************************************************************/
+#if ( LINUX_VERSION_CODE < KERNEL_VERSION(2,6,16) )
+#undef HAVE_PCI_ERS
+#else /* 2.6.16 and above */
+#undef HAVE_PCI_ERS
+#define HAVE_PCI_ERS
+#endif
+
+/*****************************************************************************/
+#if ( LINUX_VERSION_CODE < KERNEL_VERSION(2,6,18) )
+
+#ifndef IRQF_PROBE_SHARED
+#ifdef SA_PROBEIRQ
+#define IRQF_PROBE_SHARED SA_PROBEIRQ
+#else
+#define IRQF_PROBE_SHARED 0
+#endif
+#endif
+
+#ifndef IRQF_SHARED
+#define IRQF_SHARED SA_SHIRQ
+#endif
+
+#ifndef ARRAY_SIZE
+#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
+#endif
+
+#ifndef netdev_alloc_skb
+#define netdev_alloc_skb _kc_netdev_alloc_skb
+extern struct sk_buff *_kc_netdev_alloc_skb(struct net_device *dev,
+                                            unsigned int length);
+#endif
+
+#ifndef skb_is_gso
+#ifdef NETIF_F_TSO
+#define skb_is_gso _kc_skb_is_gso
+static inline int _kc_skb_is_gso(const struct sk_buff *skb)
+{
+       return skb_shinfo(skb)->gso_size;
+}
+#else
+#define skb_is_gso(a) 0
+#endif
+#endif
+
+#endif /* < 2.6.18 */
+
+/*****************************************************************************/
+#if ( LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19) )
+
+#ifndef DIV_ROUND_UP
+#define DIV_ROUND_UP(n,d) (((n) + (d) - 1) / (d))
+#endif
+
+#if ( LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0) )
+#ifndef RHEL_RELEASE_CODE
+#define RHEL_RELEASE_CODE 0
+#endif
+#ifndef RHEL_RELEASE_VERSION
+#define RHEL_RELEASE_VERSION(a,b) 0
+#endif
+#ifndef AX_RELEASE_CODE
+#define AX_RELEASE_CODE 0
+#endif
+#ifndef AX_RELEASE_VERSION
+#define AX_RELEASE_VERSION(a,b) 0
+#endif
+#if (!(( RHEL_RELEASE_CODE > RHEL_RELEASE_VERSION(4,4) ) && ( RHEL_RELEASE_CODE < RHEL_RELEASE_VERSION(5,0) ) || ( RHEL_RELEASE_CODE > RHEL_RELEASE_VERSION(5,0) ) || (AX_RELEASE_CODE > AX_RELEASE_VERSION(3,0))))
+typedef irqreturn_t (*irq_handler_t)(int, void*, struct pt_regs *);
+#endif
+typedef irqreturn_t (*new_handler_t)(int, void*);
+static inline irqreturn_t _kc_request_irq(unsigned int irq, new_handler_t handler, unsigned long flags, const char *devname, void *dev_id)
+#else /* 2.4.x */
+typedef void (*irq_handler_t)(int, void*, struct pt_regs *);
+typedef void (*new_handler_t)(int, void*);
+static inline int _kc_request_irq(unsigned int irq, new_handler_t handler, unsigned long flags, const char *devname, void *dev_id)
+#endif
+{
+       irq_handler_t new_handler = (irq_handler_t) handler;
+       return request_irq(irq, new_handler, flags, devname, dev_id);
+}
+
+#undef request_irq
+#define request_irq(irq, handler, flags, devname, dev_id) _kc_request_irq((irq), (handler), (flags), (devname), (dev_id))
+
+#define irq_handler_t new_handler_t
+
+/* pci_restore_state and pci_save_state handles MSI/PCIE from 2.6.19 */
+#define PCIE_CONFIG_SPACE_LEN 256
+#define PCI_CONFIG_SPACE_LEN 64
+#define PCIE_LINK_STATUS 0x12
+#define pci_config_space_ich8lan() do {} while (0)
+#undef pci_save_state
+extern int _kc_pci_save_state(struct pci_dev *);
+#define pci_save_state(pdev) _kc_pci_save_state(pdev)
+#undef pci_restore_state
+extern void _kc_pci_restore_state(struct pci_dev *);
+#define pci_restore_state(pdev) _kc_pci_restore_state(pdev)
+#ifdef HAVE_PCI_ERS
+#undef free_netdev
+extern void _kc_free_netdev(struct net_device *);
+#define free_netdev(netdev) _kc_free_netdev(netdev)
+#endif
+
+#endif /* < 2.6.19 */
+/*****************************************************************************/
+#if ( LINUX_VERSION_CODE < KERNEL_VERSION(2,6,20) )
+#if ( LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,28) )
+#undef INIT_WORK
+#define INIT_WORK(_work, _func) \
+do { \
+       INIT_LIST_HEAD(&(_work)->entry); \
+       (_work)->pending = 0; \
+       (_work)->func = (void (*)(void *))_func; \
+       (_work)->data = _work; \
+       init_timer(&(_work)->timer); \
+} while (0)
+#endif
+
+#ifndef PCI_VDEVICE
+#define PCI_VDEVICE(ven, dev)        \
+       PCI_VENDOR_ID_##ven, (dev),  \
+       PCI_ANY_ID, PCI_ANY_ID, 0, 0
+#endif
+
+#ifndef round_jiffies
+#define round_jiffies(x) x
+#endif
+
+#define csum_offset csum
+
+#endif /* < 2.6.20 */
+
+/*****************************************************************************/
+#if ( LINUX_VERSION_CODE < KERNEL_VERSION(2,6,21) )
+#define vlan_group_get_device(vg, id) (vg->vlan_devices[id])
+#define vlan_group_set_device(vg, id, dev) if (vg) vg->vlan_devices[id] = dev;
+#define pci_channel_offline(pdev) (pdev->error_state && \
+       pdev->error_state != pci_channel_io_normal)
+#define pci_request_selected_regions(pdev, bars, name) \
+        pci_request_regions(pdev, name)
+#define pci_release_selected_regions(pdev, bars) pci_release_regions(pdev);
+#endif /* < 2.6.21 */
+
+/*****************************************************************************/
+#if ( LINUX_VERSION_CODE < KERNEL_VERSION(2,6,22) )
+#define tcp_hdr(skb) (skb->h.th)
+#define tcp_hdrlen(skb) (skb->h.th->doff << 2)
+#define skb_transport_offset(skb) (skb->h.raw - skb->data)
+#define skb_transport_header(skb) (skb->h.raw)
+#define ipv6_hdr(skb) (skb->nh.ipv6h)
+#define ip_hdr(skb) (skb->nh.iph)
+#define skb_network_offset(skb) (skb->nh.raw - skb->data)
+#define skb_network_header(skb) (skb->nh.raw)
+#define skb_tail_pointer(skb) skb->tail
+#define skb_copy_to_linear_data_offset(skb, offset, from, len) \
+                                 memcpy(skb->data + offset, from, len)
+#define skb_network_header_len(skb) (skb->h.raw - skb->nh.raw)
+#define pci_register_driver pci_module_init
+#define skb_mac_header(skb) skb->mac.raw
+
+#ifdef NETIF_F_MULTI_QUEUE
+#ifndef alloc_etherdev_mq
+#define alloc_etherdev_mq(_a, _b) alloc_etherdev(_a)
+#endif
+#endif /* NETIF_F_MULTI_QUEUE */
+
+#ifndef ETH_FCS_LEN
+#define ETH_FCS_LEN 4
+#endif
+#define cancel_work_sync(x) flush_scheduled_work()
+#endif /* < 2.6.22 */
+
+/*****************************************************************************/
+#if ( LINUX_VERSION_CODE > KERNEL_VERSION(2,6,22) )
+#undef ETHTOOL_GPERMADDR
+#undef SET_MODULE_OWNER
+#define SET_MODULE_OWNER(dev) do { } while (0)
+#endif /* > 2.6.22 */
+
+/*****************************************************************************/
+#if ( LINUX_VERSION_CODE < KERNEL_VERSION(2,6,24) )
+/* NAPI API changes in 2.6.24 break everything */
+struct napi_struct {
+       /* used to look up the real NAPI polling routine */
+       int (*poll)(struct napi_struct *, int);
+       struct net_device poll_dev;
+       int weight;
+};
+#ifdef NAPI
+extern int __kc_adapter_clean(struct net_device *, int *);
+#if defined(DRIVER_IGB) || defined(DRIVER_IXGBE)
+#define netif_rx_complete(_netdev, napi) netif_rx_complete(&(napi)->poll_dev)
+#define netif_rx_schedule_prep(_netdev, napi) \
+       (netif_running(_netdev) && netif_rx_schedule_prep(&(napi)->poll_dev))
+#define netif_rx_schedule(_netdev, napi) netif_rx_schedule(&(napi)->poll_dev)
+#define __netif_rx_schedule(_netdev, napi) __netif_rx_schedule(&(napi)->poll_dev)
+#define napi_enable(napi) do { \
+       /* abuse if_port as a counter */ \
+       if (!adapter->netdev->if_port) { \
+               netif_poll_enable(adapter->netdev); \
+       } \
+       ++adapter->netdev->if_port; \
+       netif_poll_enable(&(napi)->poll_dev); \
+       } while (0)
+#define napi_disable(_napi) do { \
+       netif_poll_disable(&(_napi)->poll_dev); \
+       --adapter->netdev->if_port; \
+       if (!adapter->netdev->if_port) \
+               netif_poll_disable(adapter->netdev); \
+       } while (0)
+
+#define netif_napi_add(_netdev, _napi, _poll, _weight) \
+       do { \
+               struct napi_struct *__napi = (_napi); \
+               __napi->poll_dev.poll = &(__kc_adapter_clean); \
+               __napi->poll_dev.priv = (_napi); \
+               __napi->poll_dev.weight = (_weight); \
+               dev_hold(&__napi->poll_dev); \
+               set_bit(__LINK_STATE_START, &__napi->poll_dev.state);\
+               _netdev->poll = &(__kc_adapter_clean); \
+               _netdev->weight = (_weight); \
+               __napi->poll = &(_poll); \
+               __napi->weight = (_weight); \
+               set_bit(__LINK_STATE_RX_SCHED, &(_netdev)->state); \
+               set_bit(__LINK_STATE_RX_SCHED, &__napi->poll_dev.state); \
+       } while (0)
+#define netif_napi_del(_napi) \
+       do { \
+               WARN_ON(!test_bit(__LINK_STATE_RX_SCHED, &(_napi)->poll_dev.state)); \
+               dev_put(&(_napi)->poll_dev); \
+               memset(&(_napi)->poll_dev, 0, sizeof(struct napi_struct));\
+       } while (0)
+#else /* DRIVER_IGB || DRIVER_IXGBE */
+#define netif_rx_complete(netdev, napi) netif_rx_complete(netdev)
+#define netif_rx_schedule_prep(netdev, napi) netif_rx_schedule_prep(netdev)
+#define netif_rx_schedule(netdev, napi) netif_rx_schedule(netdev)
+#define __netif_rx_schedule(netdev, napi) __netif_rx_schedule(netdev)
+#define napi_enable(napi) netif_poll_enable(adapter->netdev)
+#define napi_disable(napi) netif_poll_disable(adapter->netdev)
+#define netif_napi_add(_netdev, _napi, _poll, _weight) \
+       do { \
+               struct napi_struct *__napi = (_napi); \
+               _netdev->poll = &(__kc_adapter_clean); \
+               _netdev->weight = (_weight); \
+               __napi->poll = &(_poll); \
+               __napi->weight = (_weight); \
+               netif_poll_disable(_netdev); \
+       } while (0)
+#define netif_napi_del(_a) do {} while (0)
+#endif /* DRIVER_IGB || DRIVER_IXGBE */
+#else /* NAPI */
+#define netif_napi_add(_netdev, _napi, _poll, _weight) \
+       do { \
+               struct napi_struct *__napi = _napi; \
+               _netdev->poll = &(_poll); \
+               _netdev->weight = (_weight); \
+               __napi->poll = &(_poll); \
+               __napi->weight = (_weight); \
+       } while (0)
+#define netif_napi_del(_a) do {} while (0)
+#endif /* NAPI */
+
+#undef dev_get_by_name
+#define dev_get_by_name(_a, _b) dev_get_by_name(_b)
+#define __netif_subqueue_stopped(_a, _b) netif_subqueue_stopped(_a, _b)
+#else
+#define netif_napi_del(_a) do {} while (0)
+#endif /* < 2.6.24 */
+
+/*****************************************************************************/
+#if ( LINUX_VERSION_CODE > KERNEL_VERSION(2,6,24) )
+#include <linux/pm_qos_params.h>
+#endif /* > 2.6.24 */
+
+/*****************************************************************************/
+#if ( LINUX_VERSION_CODE < KERNEL_VERSION(2,6,25) )
+#define PM_QOS_CPU_DMA_LATENCY 1
+
+#if ( LINUX_VERSION_CODE > KERNEL_VERSION(2,6,18) )
+#include <linux/latency.h>
+#define PM_QOS_DEFAULT_VALUE   INFINITE_LATENCY
+#define pm_qos_add_requirement(pm_qos_class, name, value) \
+               set_acceptable_latency(name, value)
+#define pm_qos_remove_requirement(pm_qos_class, name) \
+               remove_acceptable_latency(name)
+#define pm_qos_update_requirement(pm_qos_class, name, value) \
+               modify_acceptable_latency(name, value)
+#else
+#define PM_QOS_DEFAULT_VALUE   -1
+#define pm_qos_add_requirement(pm_qos_class, name, value)
+#define pm_qos_remove_requirement(pm_qos_class, name)
+#define pm_qos_update_requirement(pm_qos_class, name, value) { \
+       if (value != PM_QOS_DEFAULT_VALUE) { \
+               printk(KERN_WARNING "%s: unable to set PM QoS requirement\n", \
+                       pci_name(adapter->pdev)); \
+       } \
+}
+#endif /* > 2.6.18 */
+
+#define pci_enable_device_mem(pdev) pci_enable_device(pdev)
+
+#endif /* < 2.6.25 */
+
+/*****************************************************************************/
+#ifndef PCIE_LINK_STATE_L0S
+#define PCIE_LINK_STATE_L0S 1
+#endif 
+
+/*****************************************************************************/
+#if ( LINUX_VERSION_CODE < KERNEL_VERSION(2,6,27) )
+#ifndef netif_napi_del
+#define netif_napi_del(_a) do {} while (0)
+#ifdef NAPI
+#ifdef CONFIG_NETPOLL
+#undef netif_napi_del
+#define netif_napi_del(_a) list_del(&(_a)->dev_list);
+#endif
+#endif
+#endif /* netif_napi_del */
+#ifndef pci_dma_mapping_error
+#define pci_dma_mapping_error _kc_pci_dma_mapping_error
+static inline int _kc_pci_dma_mapping_error(struct pci_dev *pdev,
+                                            dma_addr_t dma_addr)
+{
+       return dma_addr == 0;
+}
+#endif
+
+#ifdef CONFIG_NETDEVICES_MULTIQUEUE
+#define HAVE_TX_MQ
+#endif
+
+#ifdef HAVE_TX_MQ
+extern void _kc_netif_tx_stop_all_queues(struct net_device *);
+extern void _kc_netif_tx_wake_all_queues(struct net_device *);
+extern void _kc_netif_tx_start_all_queues(struct net_device *);
+#define netif_tx_stop_all_queues(a) _kc_netif_tx_stop_all_queues(a)
+#define netif_tx_wake_all_queues(a) _kc_netif_tx_wake_all_queues(a)
+#define netif_tx_start_all_queues(a) _kc_netif_tx_start_all_queues(a)
+#else /* CONFIG_NETDEVICES_MULTIQUEUE */
+#define netif_tx_stop_all_queues(a) netif_stop_queue(a)
+#define netif_tx_wake_all_queues(a) netif_wake_queue(a)
+#define netif_tx_start_all_queues(a) netif_start_queue(a)
+#endif /* CONFIG_NETDEVICES_MULTIQUEUE */
+#ifndef NETIF_F_MULTI_QUEUE
+#define NETIF_F_MULTI_QUEUE 0
+#define netif_is_multiqueue(a) 0
+#define netif_stop_subqueue(a, b)
+#define netif_wake_subqueue(a, b)
+#define netif_start_subqueue(a, b)
+#endif /* NETIF_F_MULTI_QUEUE */
+#else /* < 2.6.27 */
+#define HAVE_TX_MQ
+#endif /* < 2.6.27 */
+
+#endif /* _KCOMPAT_H_ */
diff --git a/drivers/net/igb/kcompat_ethtool.c b/drivers/net/igb/kcompat_ethtool.c
new file mode 100644 (file)
index 0000000..99abec6
--- /dev/null
@@ -0,0 +1,1168 @@
+/*******************************************************************************
+
+  Intel(R) Gigabit Ethernet Linux driver
+  Copyright(c) 2007-2008 Intel Corporation.
+
+  This program is free software; you can redistribute it and/or modify it
+  under the terms and conditions of the GNU General Public License,
+  version 2, as published by the Free Software Foundation.
+
+  This program is distributed in the hope it will be useful, but WITHOUT
+  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+  FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
+  more details.
+
+  You should have received a copy of the GNU General Public License along with
+  this program; if not, write to the Free Software Foundation, Inc.,
+  51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
+
+  The full GNU General Public License is included in this distribution in
+  the file called "COPYING".
+
+  Contact Information:
+  e1000-devel Mailing List <e1000-devel@lists.sourceforge.net>
+  Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
+
+*******************************************************************************/
+
+/*
+ * net/core/ethtool.c - Ethtool ioctl handler
+ * Copyright (c) 2003 Matthew Wilcox <matthew@wil.cx>
+ *
+ * This file is where we call all the ethtool_ops commands to get
+ * the information ethtool needs.  We fall back to calling do_ioctl()
+ * for drivers which haven't been converted to ethtool_ops yet.
+ *
+ * It's GPL, stupid.
+ *
+ * Modification by sfeldma@pobox.com to work as backward compat
+ * solution for pre-ethtool_ops kernels.
+ *     - copied struct ethtool_ops from ethtool.h
+ *     - defined SET_ETHTOOL_OPS
+ *     - put in some #ifndef NETIF_F_xxx wrappers
+ *     - changes refs to dev->ethtool_ops to ethtool_ops
+ *     - changed dev_ethtool to ethtool_ioctl
+ *      - remove EXPORT_SYMBOL()s
+ *      - added _kc_ prefix in built-in ethtool_op_xxx ops.
+ */
+
+#include <linux/module.h>
+#include <linux/types.h>
+#include <linux/errno.h>
+#include <linux/mii.h>
+#include <linux/ethtool.h>
+#include <linux/netdevice.h>
+#include <asm/uaccess.h>
+
+#include "kcompat.h"
+
+#undef SUPPORTED_10000baseT_Full
+#define SUPPORTED_10000baseT_Full      (1 << 12)
+#undef ADVERTISED_10000baseT_Full
+#define ADVERTISED_10000baseT_Full     (1 << 12)
+#undef SPEED_10000
+#define SPEED_10000            10000
+
+#undef ethtool_ops
+#define ethtool_ops _kc_ethtool_ops
+
+struct _kc_ethtool_ops {
+       int  (*get_settings)(struct net_device *, struct ethtool_cmd *);
+       int  (*set_settings)(struct net_device *, struct ethtool_cmd *);
+       void (*get_drvinfo)(struct net_device *, struct ethtool_drvinfo *);
+       int  (*get_regs_len)(struct net_device *);
+       void (*get_regs)(struct net_device *, struct ethtool_regs *, void *);
+       void (*get_wol)(struct net_device *, struct ethtool_wolinfo *);
+       int  (*set_wol)(struct net_device *, struct ethtool_wolinfo *);
+       u32  (*get_msglevel)(struct net_device *);
+       void (*set_msglevel)(struct net_device *, u32);
+       int  (*nway_reset)(struct net_device *);
+       u32  (*get_link)(struct net_device *);
+       int  (*get_eeprom_len)(struct net_device *);
+       int  (*get_eeprom)(struct net_device *, struct ethtool_eeprom *, u8 *);
+       int  (*set_eeprom)(struct net_device *, struct ethtool_eeprom *, u8 *);
+       int  (*get_coalesce)(struct net_device *, struct ethtool_coalesce *);
+       int  (*set_coalesce)(struct net_device *, struct ethtool_coalesce *);
+       void (*get_ringparam)(struct net_device *, struct ethtool_ringparam *);
+       int  (*set_ringparam)(struct net_device *, struct ethtool_ringparam *);
+       void (*get_pauseparam)(struct net_device *,
+                              struct ethtool_pauseparam*);
+       int  (*set_pauseparam)(struct net_device *,
+                              struct ethtool_pauseparam*);
+       u32  (*get_rx_csum)(struct net_device *);
+       int  (*set_rx_csum)(struct net_device *, u32);
+       u32  (*get_tx_csum)(struct net_device *);
+       int  (*set_tx_csum)(struct net_device *, u32);
+       u32  (*get_sg)(struct net_device *);
+       int  (*set_sg)(struct net_device *, u32);
+       u32  (*get_tso)(struct net_device *);
+       int  (*set_tso)(struct net_device *, u32);
+       int  (*self_test_count)(struct net_device *);
+       void (*self_test)(struct net_device *, struct ethtool_test *, u64 *);
+       void (*get_strings)(struct net_device *, u32 stringset, u8 *);
+       int  (*phys_id)(struct net_device *, u32);
+       int  (*get_stats_count)(struct net_device *);
+       void (*get_ethtool_stats)(struct net_device *, struct ethtool_stats *,
+                                 u64 *);
+} *ethtool_ops = NULL;
+
+#undef SET_ETHTOOL_OPS
+#define SET_ETHTOOL_OPS(netdev, ops) (ethtool_ops = (ops))
+
+/*
+ * Some useful ethtool_ops methods that are device independent. If we find that
+ * all drivers want to do the same thing here, we can turn these into dev_()
+ * function calls.
+ */
+
+#undef ethtool_op_get_link
+#define ethtool_op_get_link _kc_ethtool_op_get_link
+u32 _kc_ethtool_op_get_link(struct net_device *dev)
+{
+       return netif_carrier_ok(dev) ? 1 : 0;
+}
+
+#undef ethtool_op_get_tx_csum
+#define ethtool_op_get_tx_csum _kc_ethtool_op_get_tx_csum
+u32 _kc_ethtool_op_get_tx_csum(struct net_device *dev)
+{
+#ifdef NETIF_F_IP_CSUM
+       return (dev->features & NETIF_F_IP_CSUM) != 0;
+#else
+       return 0;
+#endif
+}
+
+#undef ethtool_op_set_tx_csum
+#define ethtool_op_set_tx_csum _kc_ethtool_op_set_tx_csum
+int _kc_ethtool_op_set_tx_csum(struct net_device *dev, u32 data)
+{
+#ifdef NETIF_F_IP_CSUM
+       if (data)
+#ifdef NETIF_F_IPV6_CSUM
+               dev->features |= (NETIF_F_IP_CSUM | NETIF_F_IPV6_CSUM);
+       else
+               dev->features &= ~(NETIF_F_IP_CSUM | NETIF_F_IPV6_CSUM);
+#else
+               dev->features |= NETIF_F_IP_CSUM;
+       else
+               dev->features &= ~NETIF_F_IP_CSUM;
+#endif
+#endif
+
+       return 0;
+}
+
+#undef ethtool_op_get_sg
+#define ethtool_op_get_sg _kc_ethtool_op_get_sg
+u32 _kc_ethtool_op_get_sg(struct net_device *dev)
+{
+#ifdef NETIF_F_SG
+       return (dev->features & NETIF_F_SG) != 0;
+#else
+       return 0;
+#endif
+}
+
+#undef ethtool_op_set_sg
+#define ethtool_op_set_sg _kc_ethtool_op_set_sg
+int _kc_ethtool_op_set_sg(struct net_device *dev, u32 data)
+{
+#ifdef NETIF_F_SG
+       if (data)
+               dev->features |= NETIF_F_SG;
+       else
+               dev->features &= ~NETIF_F_SG;
+#endif
+
+       return 0;
+}
+
+#undef ethtool_op_get_tso
+#define ethtool_op_get_tso _kc_ethtool_op_get_tso
+u32 _kc_ethtool_op_get_tso(struct net_device *dev)
+{
+#ifdef NETIF_F_TSO
+       return (dev->features & NETIF_F_TSO) != 0;
+#else
+       return 0;
+#endif
+}
+
+#undef ethtool_op_set_tso
+#define ethtool_op_set_tso _kc_ethtool_op_set_tso
+int _kc_ethtool_op_set_tso(struct net_device *dev, u32 data)
+{
+#ifdef NETIF_F_TSO
+       if (data)
+               dev->features |= NETIF_F_TSO;
+       else
+               dev->features &= ~NETIF_F_TSO;
+#endif
+
+       return 0;
+}
+
+/* Handlers for each ethtool command */
+
+static int ethtool_get_settings(struct net_device *dev, void *useraddr)
+{
+       struct ethtool_cmd cmd = { ETHTOOL_GSET };
+       int err;
+
+       if (!ethtool_ops->get_settings)
+               return -EOPNOTSUPP;
+
+       err = ethtool_ops->get_settings(dev, &cmd);
+       if (err < 0)
+               return err;
+
+       if (copy_to_user(useraddr, &cmd, sizeof(cmd)))
+               return -EFAULT;
+       return 0;
+}
+
+static int ethtool_set_settings(struct net_device *dev, void *useraddr)
+{
+       struct ethtool_cmd cmd;
+
+       if (!ethtool_ops->set_settings)
+               return -EOPNOTSUPP;
+
+       if (copy_from_user(&cmd, useraddr, sizeof(cmd)))
+               return -EFAULT;
+
+       return ethtool_ops->set_settings(dev, &cmd);
+}
+
+static int ethtool_get_drvinfo(struct net_device *dev, void *useraddr)
+{
+       struct ethtool_drvinfo info;
+       struct ethtool_ops *ops = ethtool_ops;
+
+       if (!ops->get_drvinfo)
+               return -EOPNOTSUPP;
+
+       memset(&info, 0, sizeof(info));
+       info.cmd = ETHTOOL_GDRVINFO;
+       ops->get_drvinfo(dev, &info);
+
+       if (ops->self_test_count)
+               info.testinfo_len = ops->self_test_count(dev);
+       if (ops->get_stats_count)
+               info.n_stats = ops->get_stats_count(dev);
+       if (ops->get_regs_len)
+               info.regdump_len = ops->get_regs_len(dev);
+       if (ops->get_eeprom_len)
+               info.eedump_len = ops->get_eeprom_len(dev);
+
+       if (copy_to_user(useraddr, &info, sizeof(info)))
+               return -EFAULT;
+       return 0;
+}
+
+static int ethtool_get_regs(struct net_device *dev, char *useraddr)
+{
+       struct ethtool_regs regs;
+       struct ethtool_ops *ops = ethtool_ops;
+       void *regbuf;
+       int reglen, ret;
+
+       if (!ops->get_regs || !ops->get_regs_len)
+               return -EOPNOTSUPP;
+
+       if (copy_from_user(&regs, useraddr, sizeof(regs)))
+               return -EFAULT;
+
+       reglen = ops->get_regs_len(dev);
+       if (regs.len > reglen)
+               regs.len = reglen;
+
+       regbuf = kmalloc(reglen, GFP_USER);
+       if (!regbuf)
+               return -ENOMEM;
+
+       ops->get_regs(dev, &regs, regbuf);
+
+       ret = -EFAULT;
+       if (copy_to_user(useraddr, &regs, sizeof(regs)))
+               goto out;
+       useraddr += offsetof(struct ethtool_regs, data);
+       if (copy_to_user(useraddr, regbuf, reglen))
+               goto out;
+       ret = 0;
+
+out:
+       kfree(regbuf);
+       return ret;
+}
+
+static int ethtool_get_wol(struct net_device *dev, char *useraddr)
+{
+       struct ethtool_wolinfo wol = { ETHTOOL_GWOL };
+
+       if (!ethtool_ops->get_wol)
+               return -EOPNOTSUPP;
+
+       ethtool_ops->get_wol(dev, &wol);
+
+       if (copy_to_user(useraddr, &wol, sizeof(wol)))
+               return -EFAULT;
+       return 0;
+}
+
+static int ethtool_set_wol(struct net_device *dev, char *useraddr)
+{
+       struct ethtool_wolinfo wol;
+
+       if (!ethtool_ops->set_wol)
+               return -EOPNOTSUPP;
+
+       if (copy_from_user(&wol, useraddr, sizeof(wol)))
+               return -EFAULT;
+
+       return ethtool_ops->set_wol(dev, &wol);
+}
+
+static int ethtool_get_msglevel(struct net_device *dev, char *useraddr)
+{
+       struct ethtool_value edata = { ETHTOOL_GMSGLVL };
+
+       if (!ethtool_ops->get_msglevel)
+               return -EOPNOTSUPP;
+
+       edata.data = ethtool_ops->get_msglevel(dev);
+
+       if (copy_to_user(useraddr, &edata, sizeof(edata)))
+               return -EFAULT;
+       return 0;
+}
+
+static int ethtool_set_msglevel(struct net_device *dev, char *useraddr)
+{
+       struct ethtool_value edata;
+
+       if (!ethtool_ops->set_msglevel)
+               return -EOPNOTSUPP;
+
+       if (copy_from_user(&edata, useraddr, sizeof(edata)))
+               return -EFAULT;
+
+       ethtool_ops->set_msglevel(dev, edata.data);
+       return 0;
+}
+
+static int ethtool_nway_reset(struct net_device *dev)
+{
+       if (!ethtool_ops->nway_reset)
+               return -EOPNOTSUPP;
+
+       return ethtool_ops->nway_reset(dev);
+}
+
+static int ethtool_get_link(struct net_device *dev, void *useraddr)
+{
+       struct ethtool_value edata = { ETHTOOL_GLINK };
+
+       if (!ethtool_ops->get_link)
+               return -EOPNOTSUPP;
+
+       edata.data = ethtool_ops->get_link(dev);
+
+       if (copy_to_user(useraddr, &edata, sizeof(edata)))
+               return -EFAULT;
+       return 0;
+}
+
+static int ethtool_get_eeprom(struct net_device *dev, void *useraddr)
+{
+       struct ethtool_eeprom eeprom;
+       struct ethtool_ops *ops = ethtool_ops;
+       u8 *data;
+       int ret;
+
+       if (!ops->get_eeprom || !ops->get_eeprom_len)
+               return -EOPNOTSUPP;
+
+       if (copy_from_user(&eeprom, useraddr, sizeof(eeprom)))
+               return -EFAULT;
+
+       /* Check for wrap and zero */
+       if (eeprom.offset + eeprom.len <= eeprom.offset)
+               return -EINVAL;
+
+       /* Check for exceeding total eeprom len */
+       if (eeprom.offset + eeprom.len > ops->get_eeprom_len(dev))
+               return -EINVAL;
+
+       data = kmalloc(eeprom.len, GFP_USER);
+       if (!data)
+               return -ENOMEM;
+
+       ret = -EFAULT;
+       if (copy_from_user(data, useraddr + sizeof(eeprom), eeprom.len))
+               goto out;
+
+       ret = ops->get_eeprom(dev, &eeprom, data);
+       if (ret)
+               goto out;
+
+       ret = -EFAULT;
+       if (copy_to_user(useraddr, &eeprom, sizeof(eeprom)))
+               goto out;
+       if (copy_to_user(useraddr + sizeof(eeprom), data, eeprom.len))
+               goto out;
+       ret = 0;
+
+out:
+       kfree(data);
+       return ret;
+}
+
+static int ethtool_set_eeprom(struct net_device *dev, void *useraddr)
+{
+       struct ethtool_eeprom eeprom;
+       struct ethtool_ops *ops = ethtool_ops;
+       u8 *data;
+       int ret;
+
+       if (!ops->set_eeprom || !ops->get_eeprom_len)
+               return -EOPNOTSUPP;
+
+       if (copy_from_user(&eeprom, useraddr, sizeof(eeprom)))
+               return -EFAULT;
+
+       /* Check for wrap and zero */
+       if (eeprom.offset + eeprom.len <= eeprom.offset)
+               return -EINVAL;
+
+       /* Check for exceeding total eeprom len */
+       if (eeprom.offset + eeprom.len > ops->get_eeprom_len(dev))
+               return -EINVAL;
+
+       data = kmalloc(eeprom.len, GFP_USER);
+       if (!data)
+               return -ENOMEM;
+
+       ret = -EFAULT;
+       if (copy_from_user(data, useraddr + sizeof(eeprom), eeprom.len))
+               goto out;
+
+       ret = ops->set_eeprom(dev, &eeprom, data);
+       if (ret)
+               goto out;
+
+       if (copy_to_user(useraddr + sizeof(eeprom), data, eeprom.len))
+               ret = -EFAULT;
+
+out:
+       kfree(data);
+       return ret;
+}
+
+static int ethtool_get_coalesce(struct net_device *dev, void *useraddr)
+{
+       struct ethtool_coalesce coalesce = { ETHTOOL_GCOALESCE };
+
+       if (!ethtool_ops->get_coalesce)
+               return -EOPNOTSUPP;
+
+       ethtool_ops->get_coalesce(dev, &coalesce);
+
+       if (copy_to_user(useraddr, &coalesce, sizeof(coalesce)))
+               return -EFAULT;
+       return 0;
+}
+
+static int ethtool_set_coalesce(struct net_device *dev, void *useraddr)
+{
+       struct ethtool_coalesce coalesce;
+
+       if (!ethtool_ops->get_coalesce)
+               return -EOPNOTSUPP;
+
+       if (copy_from_user(&coalesce, useraddr, sizeof(coalesce)))
+               return -EFAULT;
+
+       return ethtool_ops->set_coalesce(dev, &coalesce);
+}
+
+static int ethtool_get_ringparam(struct net_device *dev, void *useraddr)
+{
+       struct ethtool_ringparam ringparam = { ETHTOOL_GRINGPARAM };
+
+       if (!ethtool_ops->get_ringparam)
+               return -EOPNOTSUPP;
+
+       ethtool_ops->get_ringparam(dev, &ringparam);
+
+       if (copy_to_user(useraddr, &ringparam, sizeof(ringparam)))
+               return -EFAULT;
+       return 0;
+}
+
+static int ethtool_set_ringparam(struct net_device *dev, void *useraddr)
+{
+       struct ethtool_ringparam ringparam;
+
+       if (!ethtool_ops->get_ringparam)
+               return -EOPNOTSUPP;
+
+       if (copy_from_user(&ringparam, useraddr, sizeof(ringparam)))
+               return -EFAULT;
+
+       return ethtool_ops->set_ringparam(dev, &ringparam);
+}
+
+static int ethtool_get_pauseparam(struct net_device *dev, void *useraddr)
+{
+       struct ethtool_pauseparam pauseparam = { ETHTOOL_GPAUSEPARAM };
+
+       if (!ethtool_ops->get_pauseparam)
+               return -EOPNOTSUPP;
+
+       ethtool_ops->get_pauseparam(dev, &pauseparam);
+
+       if (copy_to_user(useraddr, &pauseparam, sizeof(pauseparam)))
+               return -EFAULT;
+       return 0;
+}
+
+static int ethtool_set_pauseparam(struct net_device *dev, void *useraddr)
+{
+       struct ethtool_pauseparam pauseparam;
+
+       if (!ethtool_ops->get_pauseparam)
+               return -EOPNOTSUPP;
+
+       if (copy_from_user(&pauseparam, useraddr, sizeof(pauseparam)))
+               return -EFAULT;
+
+       return ethtool_ops->set_pauseparam(dev, &pauseparam);
+}
+
+static int ethtool_get_rx_csum(struct net_device *dev, char *useraddr)
+{
+       struct ethtool_value edata = { ETHTOOL_GRXCSUM };
+
+       if (!ethtool_ops->get_rx_csum)
+               return -EOPNOTSUPP;
+
+       edata.data = ethtool_ops->get_rx_csum(dev);
+
+       if (copy_to_user(useraddr, &edata, sizeof(edata)))
+               return -EFAULT;
+       return 0;
+}
+
+static int ethtool_set_rx_csum(struct net_device *dev, char *useraddr)
+{
+       struct ethtool_value edata;
+
+       if (!ethtool_ops->set_rx_csum)
+               return -EOPNOTSUPP;
+
+       if (copy_from_user(&edata, useraddr, sizeof(edata)))
+               return -EFAULT;
+
+       ethtool_ops->set_rx_csum(dev, edata.data);
+       return 0;
+}
+
+static int ethtool_get_tx_csum(struct net_device *dev, char *useraddr)
+{
+       struct ethtool_value edata = { ETHTOOL_GTXCSUM };
+
+       if (!ethtool_ops->get_tx_csum)
+               return -EOPNOTSUPP;
+
+       edata.data = ethtool_ops->get_tx_csum(dev);
+
+       if (copy_to_user(useraddr, &edata, sizeof(edata)))
+               return -EFAULT;
+       return 0;
+}
+
+static int ethtool_set_tx_csum(struct net_device *dev, char *useraddr)
+{
+       struct ethtool_value edata;
+
+       if (!ethtool_ops->set_tx_csum)
+               return -EOPNOTSUPP;
+
+       if (copy_from_user(&edata, useraddr, sizeof(edata)))
+               return -EFAULT;
+
+       return ethtool_ops->set_tx_csum(dev, edata.data);
+}
+
+static int ethtool_get_sg(struct net_device *dev, char *useraddr)
+{
+       struct ethtool_value edata = { ETHTOOL_GSG };
+
+       if (!ethtool_ops->get_sg)
+               return -EOPNOTSUPP;
+
+       edata.data = ethtool_ops->get_sg(dev);
+
+       if (copy_to_user(useraddr, &edata, sizeof(edata)))
+               return -EFAULT;
+       return 0;
+}
+
+static int ethtool_set_sg(struct net_device *dev, char *useraddr)
+{
+       struct ethtool_value edata;
+
+       if (!ethtool_ops->set_sg)
+               return -EOPNOTSUPP;
+
+       if (copy_from_user(&edata, useraddr, sizeof(edata)))
+               return -EFAULT;
+
+       return ethtool_ops->set_sg(dev, edata.data);
+}
+
+static int ethtool_get_tso(struct net_device *dev, char *useraddr)
+{
+       struct ethtool_value edata = { ETHTOOL_GTSO };
+
+       if (!ethtool_ops->get_tso)
+               return -EOPNOTSUPP;
+
+       edata.data = ethtool_ops->get_tso(dev);
+
+       if (copy_to_user(useraddr, &edata, sizeof(edata)))
+               return -EFAULT;
+       return 0;
+}
+
+static int ethtool_set_tso(struct net_device *dev, char *useraddr)
+{
+       struct ethtool_value edata;
+
+       if (!ethtool_ops->set_tso)
+               return -EOPNOTSUPP;
+
+       if (copy_from_user(&edata, useraddr, sizeof(edata)))
+               return -EFAULT;
+
+       return ethtool_ops->set_tso(dev, edata.data);
+}
+
+static int ethtool_self_test(struct net_device *dev, char *useraddr)
+{
+       struct ethtool_test test;
+       struct ethtool_ops *ops = ethtool_ops;
+       u64 *data;
+       int ret;
+
+       if (!ops->self_test || !ops->self_test_count)
+               return -EOPNOTSUPP;
+
+       if (copy_from_user(&test, useraddr, sizeof(test)))
+               return -EFAULT;
+
+       test.len = ops->self_test_count(dev);
+       data = kmalloc(test.len * sizeof(u64), GFP_USER);
+       if (!data)
+               return -ENOMEM;
+
+       ops->self_test(dev, &test, data);
+
+       ret = -EFAULT;
+       if (copy_to_user(useraddr, &test, sizeof(test)))
+               goto out;
+       useraddr += sizeof(test);
+       if (copy_to_user(useraddr, data, test.len * sizeof(u64)))
+               goto out;
+       ret = 0;
+
+out:
+       kfree(data);
+       return ret;
+}
+
+static int ethtool_get_strings(struct net_device *dev, void *useraddr)
+{
+       struct ethtool_gstrings gstrings;
+       struct ethtool_ops *ops = ethtool_ops;
+       u8 *data;
+       int ret;
+
+       if (!ops->get_strings)
+               return -EOPNOTSUPP;
+
+       if (copy_from_user(&gstrings, useraddr, sizeof(gstrings)))
+               return -EFAULT;
+
+       switch (gstrings.string_set) {
+       case ETH_SS_TEST:
+               if (!ops->self_test_count)
+                       return -EOPNOTSUPP;
+               gstrings.len = ops->self_test_count(dev);
+               break;
+       case ETH_SS_STATS:
+               if (!ops->get_stats_count)
+                       return -EOPNOTSUPP;
+               gstrings.len = ops->get_stats_count(dev);
+               break;
+       default:
+               return -EINVAL;
+       }
+
+       data = kmalloc(gstrings.len * ETH_GSTRING_LEN, GFP_USER);
+       if (!data)
+               return -ENOMEM;
+
+       ops->get_strings(dev, gstrings.string_set, data);
+
+       ret = -EFAULT;
+       if (copy_to_user(useraddr, &gstrings, sizeof(gstrings)))
+               goto out;
+       useraddr += sizeof(gstrings);
+       if (copy_to_user(useraddr, data, gstrings.len * ETH_GSTRING_LEN))
+               goto out;
+       ret = 0;
+
+out:
+       kfree(data);
+       return ret;
+}
+
+static int ethtool_phys_id(struct net_device *dev, void *useraddr)
+{
+       struct ethtool_value id;
+
+       if (!ethtool_ops->phys_id)
+               return -EOPNOTSUPP;
+
+       if (copy_from_user(&id, useraddr, sizeof(id)))
+               return -EFAULT;
+
+       return ethtool_ops->phys_id(dev, id.data);
+}
+
+static int ethtool_get_stats(struct net_device *dev, void *useraddr)
+{
+       struct ethtool_stats stats;
+       struct ethtool_ops *ops = ethtool_ops;
+       u64 *data;
+       int ret;
+
+       if (!ops->get_ethtool_stats || !ops->get_stats_count)
+               return -EOPNOTSUPP;
+
+       if (copy_from_user(&stats, useraddr, sizeof(stats)))
+               return -EFAULT;
+
+       stats.n_stats = ops->get_stats_count(dev);
+       data = kmalloc(stats.n_stats * sizeof(u64), GFP_USER);
+       if (!data)
+               return -ENOMEM;
+
+       ops->get_ethtool_stats(dev, &stats, data);
+
+       ret = -EFAULT;
+       if (copy_to_user(useraddr, &stats, sizeof(stats)))
+               goto out;
+       useraddr += sizeof(stats);
+       if (copy_to_user(useraddr, data, stats.n_stats * sizeof(u64)))
+               goto out;
+       ret = 0;
+
+out:
+       kfree(data);
+       return ret;
+}
+
+/* The main entry point in this file.  Called from net/core/dev.c */
+
+#define ETHTOOL_OPS_COMPAT
+int ethtool_ioctl(struct ifreq *ifr)
+{
+       struct net_device *dev = __dev_get_by_name(ifr->ifr_name);
+       void *useraddr = (void *) ifr->ifr_data;
+       u32 ethcmd;
+
+       /*
+        * XXX: This can be pushed down into the ethtool_* handlers that
+        * need it.  Keep existing behavior for the moment.
+        */
+       if (!capable(CAP_NET_ADMIN))
+               return -EPERM;
+
+       if (!dev || !netif_device_present(dev))
+               return -ENODEV;
+
+       if (copy_from_user(&ethcmd, useraddr, sizeof (ethcmd)))
+               return -EFAULT;
+
+       switch (ethcmd) {
+       case ETHTOOL_GSET:
+               return ethtool_get_settings(dev, useraddr);
+       case ETHTOOL_SSET:
+               return ethtool_set_settings(dev, useraddr);
+       case ETHTOOL_GDRVINFO:
+               return ethtool_get_drvinfo(dev, useraddr);
+       case ETHTOOL_GREGS:
+               return ethtool_get_regs(dev, useraddr);
+       case ETHTOOL_GWOL:
+               return ethtool_get_wol(dev, useraddr);
+       case ETHTOOL_SWOL:
+               return ethtool_set_wol(dev, useraddr);
+       case ETHTOOL_GMSGLVL:
+               return ethtool_get_msglevel(dev, useraddr);
+       case ETHTOOL_SMSGLVL:
+               return ethtool_set_msglevel(dev, useraddr);
+       case ETHTOOL_NWAY_RST:
+               return ethtool_nway_reset(dev);
+       case ETHTOOL_GLINK:
+               return ethtool_get_link(dev, useraddr);
+       case ETHTOOL_GEEPROM:
+               return ethtool_get_eeprom(dev, useraddr);
+       case ETHTOOL_SEEPROM:
+               return ethtool_set_eeprom(dev, useraddr);
+       case ETHTOOL_GCOALESCE:
+               return ethtool_get_coalesce(dev, useraddr);
+       case ETHTOOL_SCOALESCE:
+               return ethtool_set_coalesce(dev, useraddr);
+       case ETHTOOL_GRINGPARAM:
+               return ethtool_get_ringparam(dev, useraddr);
+       case ETHTOOL_SRINGPARAM:
+               return ethtool_set_ringparam(dev, useraddr);
+       case ETHTOOL_GPAUSEPARAM:
+               return ethtool_get_pauseparam(dev, useraddr);
+       case ETHTOOL_SPAUSEPARAM:
+               return ethtool_set_pauseparam(dev, useraddr);
+       case ETHTOOL_GRXCSUM:
+               return ethtool_get_rx_csum(dev, useraddr);
+       case ETHTOOL_SRXCSUM:
+               return ethtool_set_rx_csum(dev, useraddr);
+       case ETHTOOL_GTXCSUM:
+               return ethtool_get_tx_csum(dev, useraddr);
+       case ETHTOOL_STXCSUM:
+               return ethtool_set_tx_csum(dev, useraddr);
+       case ETHTOOL_GSG:
+               return ethtool_get_sg(dev, useraddr);
+       case ETHTOOL_SSG:
+               return ethtool_set_sg(dev, useraddr);
+       case ETHTOOL_GTSO:
+               return ethtool_get_tso(dev, useraddr);
+       case ETHTOOL_STSO:
+               return ethtool_set_tso(dev, useraddr);
+       case ETHTOOL_TEST:
+               return ethtool_self_test(dev, useraddr);
+       case ETHTOOL_GSTRINGS:
+               return ethtool_get_strings(dev, useraddr);
+       case ETHTOOL_PHYS_ID:
+               return ethtool_phys_id(dev, useraddr);
+       case ETHTOOL_GSTATS:
+               return ethtool_get_stats(dev, useraddr);
+       default:
+               return -EOPNOTSUPP;
+       }
+
+       return -EOPNOTSUPP;
+}
+
+#define mii_if_info _kc_mii_if_info
+struct _kc_mii_if_info {
+       int phy_id;
+       int advertising;
+       int phy_id_mask;
+       int reg_num_mask;
+
+       unsigned int full_duplex : 1;   /* is full duplex? */
+       unsigned int force_media : 1;   /* is autoneg. disabled? */
+
+       struct net_device *dev;
+       int (*mdio_read) (struct net_device *dev, int phy_id, int location);
+       void (*mdio_write) (struct net_device *dev, int phy_id, int location, int val);
+};
+
+struct ethtool_cmd;
+struct mii_ioctl_data;
+
+#undef mii_link_ok
+#define mii_link_ok _kc_mii_link_ok
+#undef mii_nway_restart
+#define mii_nway_restart _kc_mii_nway_restart
+#undef mii_ethtool_gset
+#define mii_ethtool_gset _kc_mii_ethtool_gset
+#undef mii_ethtool_sset
+#define mii_ethtool_sset _kc_mii_ethtool_sset
+#undef mii_check_link
+#define mii_check_link _kc_mii_check_link
+#undef generic_mii_ioctl
+#define generic_mii_ioctl _kc_generic_mii_ioctl
+extern int _kc_mii_link_ok (struct mii_if_info *mii);
+extern int _kc_mii_nway_restart (struct mii_if_info *mii);
+extern int _kc_mii_ethtool_gset(struct mii_if_info *mii,
+                                struct ethtool_cmd *ecmd);
+extern int _kc_mii_ethtool_sset(struct mii_if_info *mii,
+                                struct ethtool_cmd *ecmd);
+extern void _kc_mii_check_link (struct mii_if_info *mii);
+extern int _kc_generic_mii_ioctl(struct mii_if_info *mii_if,
+                                 struct mii_ioctl_data *mii_data, int cmd,
+                                 unsigned int *duplex_changed);
+
+
+struct _kc_pci_dev_ext {
+       struct pci_dev *dev;
+       void *pci_drvdata;
+       struct pci_driver *driver;
+};
+
+struct _kc_net_dev_ext {
+       struct net_device *dev;
+       unsigned int carrier;
+};
+
+
+/**************************************/
+/* mii support */
+
+int _kc_mii_ethtool_gset(struct mii_if_info *mii, struct ethtool_cmd *ecmd)
+{
+       struct net_device *dev = mii->dev;
+       u32 advert, bmcr, lpa, nego;
+
+       ecmd->supported =
+           (SUPPORTED_10baseT_Half | SUPPORTED_10baseT_Full |
+            SUPPORTED_100baseT_Half | SUPPORTED_100baseT_Full |
+            SUPPORTED_Autoneg | SUPPORTED_TP | SUPPORTED_MII);
+
+       /* only supports twisted-pair */
+       ecmd->port = PORT_MII;
+
+       /* only supports internal transceiver */
+       ecmd->transceiver = XCVR_INTERNAL;
+
+       /* this isn't fully supported at higher layers */
+       ecmd->phy_address = mii->phy_id;
+
+       ecmd->advertising = ADVERTISED_TP | ADVERTISED_MII;
+       advert = mii->mdio_read(dev, mii->phy_id, MII_ADVERTISE);
+       if (advert & ADVERTISE_10HALF)
+               ecmd->advertising |= ADVERTISED_10baseT_Half;
+       if (advert & ADVERTISE_10FULL)
+               ecmd->advertising |= ADVERTISED_10baseT_Full;
+       if (advert & ADVERTISE_100HALF)
+               ecmd->advertising |= ADVERTISED_100baseT_Half;
+       if (advert & ADVERTISE_100FULL)
+               ecmd->advertising |= ADVERTISED_100baseT_Full;
+
+       bmcr = mii->mdio_read(dev, mii->phy_id, MII_BMCR);
+       lpa = mii->mdio_read(dev, mii->phy_id, MII_LPA);
+       if (bmcr & BMCR_ANENABLE) {
+               ecmd->advertising |= ADVERTISED_Autoneg;
+               ecmd->autoneg = AUTONEG_ENABLE;
+               
+               nego = mii_nway_result(advert & lpa);
+               if (nego == LPA_100FULL || nego == LPA_100HALF)
+                       ecmd->speed = SPEED_100;
+               else
+                       ecmd->speed = SPEED_10;
+               if (nego == LPA_100FULL || nego == LPA_10FULL) {
+                       ecmd->duplex = DUPLEX_FULL;
+                       mii->full_duplex = 1;
+               } else {
+                       ecmd->duplex = DUPLEX_HALF;
+                       mii->full_duplex = 0;
+               }
+       } else {
+               ecmd->autoneg = AUTONEG_DISABLE;
+
+               ecmd->speed = (bmcr & BMCR_SPEED100) ? SPEED_100 : SPEED_10;
+               ecmd->duplex = (bmcr & BMCR_FULLDPLX) ? DUPLEX_FULL : DUPLEX_HALF;
+       }
+
+       /* ignore maxtxpkt, maxrxpkt for now */
+
+       return 0;
+}
+
+int _kc_mii_ethtool_sset(struct mii_if_info *mii, struct ethtool_cmd *ecmd)
+{
+       struct net_device *dev = mii->dev;
+
+       if (ecmd->speed != SPEED_10 && ecmd->speed != SPEED_100)
+               return -EINVAL;
+       if (ecmd->duplex != DUPLEX_HALF && ecmd->duplex != DUPLEX_FULL)
+               return -EINVAL;
+       if (ecmd->port != PORT_MII)
+               return -EINVAL;
+       if (ecmd->transceiver != XCVR_INTERNAL)
+               return -EINVAL;
+       if (ecmd->phy_address != mii->phy_id)
+               return -EINVAL;
+       if (ecmd->autoneg != AUTONEG_DISABLE && ecmd->autoneg != AUTONEG_ENABLE)
+               return -EINVAL;
+                                 
+       /* ignore supported, maxtxpkt, maxrxpkt */
+       
+       if (ecmd->autoneg == AUTONEG_ENABLE) {
+               u32 bmcr, advert, tmp;
+
+               if ((ecmd->advertising & (ADVERTISED_10baseT_Half |
+                                         ADVERTISED_10baseT_Full |
+                                         ADVERTISED_100baseT_Half |
+                                         ADVERTISED_100baseT_Full)) == 0)
+                       return -EINVAL;
+
+               /* advertise only what has been requested */
+               advert = mii->mdio_read(dev, mii->phy_id, MII_ADVERTISE);
+               tmp = advert & ~(ADVERTISE_ALL | ADVERTISE_100BASE4);
+               if (ADVERTISED_10baseT_Half)
+                       tmp |= ADVERTISE_10HALF;
+               if (ADVERTISED_10baseT_Full)
+                       tmp |= ADVERTISE_10FULL;
+               if (ADVERTISED_100baseT_Half)
+                       tmp |= ADVERTISE_100HALF;
+               if (ADVERTISED_100baseT_Full)
+                       tmp |= ADVERTISE_100FULL;
+               if (advert != tmp) {
+                       mii->mdio_write(dev, mii->phy_id, MII_ADVERTISE, tmp);
+                       mii->advertising = tmp;
+               }
+               
+               /* turn on autonegotiation, and force a renegotiate */
+               bmcr = mii->mdio_read(dev, mii->phy_id, MII_BMCR);
+               bmcr |= (BMCR_ANENABLE | BMCR_ANRESTART);
+               mii->mdio_write(dev, mii->phy_id, MII_BMCR, bmcr);
+
+               mii->force_media = 0;
+       } else {
+               u32 bmcr, tmp;
+
+               /* turn off auto negotiation, set speed and duplexity */
+               bmcr = mii->mdio_read(dev, mii->phy_id, MII_BMCR);
+               tmp = bmcr & ~(BMCR_ANENABLE | BMCR_SPEED100 | BMCR_FULLDPLX);
+               if (ecmd->speed == SPEED_100)
+                       tmp |= BMCR_SPEED100;
+               if (ecmd->duplex == DUPLEX_FULL) {
+                       tmp |= BMCR_FULLDPLX;
+                       mii->full_duplex = 1;
+               } else
+                       mii->full_duplex = 0;
+               if (bmcr != tmp)
+                       mii->mdio_write(dev, mii->phy_id, MII_BMCR, tmp);
+
+               mii->force_media = 1;
+       }
+       return 0;
+}
+
+int _kc_mii_link_ok (struct mii_if_info *mii)
+{
+       /* first, a dummy read, needed to latch some MII phys */
+       mii->mdio_read(mii->dev, mii->phy_id, MII_BMSR);
+       if (mii->mdio_read(mii->dev, mii->phy_id, MII_BMSR) & BMSR_LSTATUS)
+               return 1;
+       return 0;
+}
+
+int _kc_mii_nway_restart (struct mii_if_info *mii)
+{
+       int bmcr;
+       int r = -EINVAL;
+
+       /* if autoneg is off, it's an error */
+       bmcr = mii->mdio_read(mii->dev, mii->phy_id, MII_BMCR);
+
+       if (bmcr & BMCR_ANENABLE) {
+               bmcr |= BMCR_ANRESTART;
+               mii->mdio_write(mii->dev, mii->phy_id, MII_BMCR, bmcr);
+               r = 0;
+       }
+
+       return r;
+}
+
+void _kc_mii_check_link (struct mii_if_info *mii)
+{
+       int cur_link = mii_link_ok(mii);
+       int prev_link = netif_carrier_ok(mii->dev);
+
+       if (cur_link && !prev_link)
+               netif_carrier_on(mii->dev);
+       else if (prev_link && !cur_link)
+               netif_carrier_off(mii->dev);
+}
+
+int _kc_generic_mii_ioctl(struct mii_if_info *mii_if,
+                          struct mii_ioctl_data *mii_data, int cmd,
+                          unsigned int *duplex_chg_out)
+{
+       int rc = 0;
+       unsigned int duplex_changed = 0;
+
+       if (duplex_chg_out)
+               *duplex_chg_out = 0;
+
+       mii_data->phy_id &= mii_if->phy_id_mask;
+       mii_data->reg_num &= mii_if->reg_num_mask;
+
+       switch(cmd) {
+       case SIOCDEVPRIVATE:    /* binary compat, remove in 2.5 */
+       case SIOCGMIIPHY:
+               mii_data->phy_id = mii_if->phy_id;
+               /* fall through */
+
+       case SIOCDEVPRIVATE + 1:/* binary compat, remove in 2.5 */
+       case SIOCGMIIREG:
+               mii_data->val_out =
+                       mii_if->mdio_read(mii_if->dev, mii_data->phy_id,
+                                         mii_data->reg_num);
+               break;
+
+       case SIOCDEVPRIVATE + 2:/* binary compat, remove in 2.5 */
+       case SIOCSMIIREG: {
+               u16 val = mii_data->val_in;
+
+               if (!capable(CAP_NET_ADMIN))
+                       return -EPERM;
+
+               if (mii_data->phy_id == mii_if->phy_id) {
+                       switch(mii_data->reg_num) {
+                       case MII_BMCR: {
+                               unsigned int new_duplex = 0;
+                               if (val & (BMCR_RESET|BMCR_ANENABLE))
+                                       mii_if->force_media = 0;
+                               else
+                                       mii_if->force_media = 1;
+                               if (mii_if->force_media &&
+                                   (val & BMCR_FULLDPLX))
+                                       new_duplex = 1;
+                               if (mii_if->full_duplex != new_duplex) {
+                                       duplex_changed = 1;
+                                       mii_if->full_duplex = new_duplex;
+                               }
+                               break;
+                       }
+                       case MII_ADVERTISE:
+                               mii_if->advertising = val;
+                               break;
+                       default:
+                               /* do nothing */
+                               break;
+                       }
+               }
+
+               mii_if->mdio_write(mii_if->dev, mii_data->phy_id,
+                                  mii_data->reg_num, val);
+               break;
+       }
+
+       default:
+               rc = -EOPNOTSUPP;
+               break;
+       }
+
+       if ((rc == 0) && (duplex_chg_out) && (duplex_changed))
+               *duplex_chg_out = 1;
+
+       return rc;
+}
+