From: Andy Gospodarek <gospo@redhat.com> Date: Wed, 19 Dec 2007 10:45:38 -0500 Subject: [net] e1000e: update to latest upstream Message-id: 20071219154538.GN28834@gospo.usersys.redhat.com O-Subject: [RHEL5.2 PATCH] e1000e: update to latest upstream Bugzilla: 252003 This is an update to the latest e1000e driver upstream. It pulls all the needed changes from Linus's tree as well as any needed ones from Jeff's netdev-2.6 tree. What's significant about this patch related to RHEL5 is that it includes the following upstream commit that applies to e1000e (not e1000 or igb): commit b3637100199b2679cd2f39d47a0061a3398cd3ca Author: Auke Kok <auke-jan.h.kok@intel.com> Date: Wed Oct 31 15:22:05 2007 -0700 e1000/e1000e: Move PCI-Express device IDs over to e1000e e1000e will from now on support the PCI-Express adapters that previously were supported by e1000. This support means better performance and easier debugging from now on for both the old PCI-X/PCI hardware and PCI-Express adapters. This patch also moves 3 recently merged device IDs over to e1000e that are identical to quad-port versions of already existing dual port versions. With this last bit every former e1000 pci-e device should work now with e1000e. Here is a brief list of which gigabit driver to use with which adapter: e1000: 82540 -> 82547 e1000e: 82571 -> 82573 ich8, ich9 (82562 or 82566) es2lan (80003eslan) igb: (not yet merged, only available from e1000.sf.net) 82575 Signed-off-by: Auke Kok <auke-jan.h.kok@intel.com> Signed-off-by: Jeff Garzik <jeff@garzik.org> I would like to drop support for these adapters from e1000 (I'd settle for dual-support for an update or two), but either way I would like them included in e1000e. This will resolve BZ 252003. Acked-by: Jeff Garzik <jgarzik@redhat.com> Acked-by: Prarit Bhargava <prarit@redhat.com> Acked-by: "John W. Linville" <linville@redhat.com> Acked-by: "David S. Miller" <davem@redhat.com> diff --git a/drivers/net/e1000e/82571.c b/drivers/net/e1000e/82571.c index ddf2303..1de80cc 100644 --- a/drivers/net/e1000e/82571.c +++ b/drivers/net/e1000e/82571.c @@ -37,6 +37,10 @@ * 82573L Gigabit Ethernet Controller */ +#include <linux/netdevice.h> +#include <linux/delay.h> +#include <linux/pci.h> + #include "e1000.h" #define ID_LED_RESERVED_F746 0xF746 @@ -50,7 +54,6 @@ static s32 e1000_get_phy_id_82571(struct e1000_hw *hw); static s32 e1000_setup_copper_link_82571(struct e1000_hw *hw); static s32 e1000_setup_fiber_serdes_link_82571(struct e1000_hw *hw); -static s32 e1000_get_phy_id_82571(struct e1000_hw *hw); static s32 e1000_write_nvm_eewr_82571(struct e1000_hw *hw, u16 offset, u16 words, u16 *data); static s32 e1000_fix_nvm_checksum_82571(struct e1000_hw *hw); @@ -191,6 +194,8 @@ static s32 e1000_init_mac_params_82571(struct e1000_adapter *adapter) break; case E1000_DEV_ID_82571EB_SERDES: case E1000_DEV_ID_82572EI_SERDES: + case E1000_DEV_ID_82571EB_SERDES_DUAL: + case E1000_DEV_ID_82571EB_SERDES_QUAD: hw->media_type = e1000_media_type_internal_serdes; break; default: @@ -210,18 +215,18 @@ static s32 e1000_init_mac_params_82571(struct e1000_adapter *adapter) switch (hw->media_type) { case e1000_media_type_copper: func->setup_physical_interface = e1000_setup_copper_link_82571; - func->check_for_link = e1000_check_for_copper_link; - func->get_link_up_info = e1000_get_speed_and_duplex_copper; + func->check_for_link = e1000e_check_for_copper_link; + func->get_link_up_info = e1000e_get_speed_and_duplex_copper; break; case e1000_media_type_fiber: func->setup_physical_interface = e1000_setup_fiber_serdes_link_82571; - func->check_for_link = e1000_check_for_fiber_link; - func->get_link_up_info = e1000_get_speed_and_duplex_fiber_serdes; + func->check_for_link = e1000e_check_for_fiber_link; + func->get_link_up_info = e1000e_get_speed_and_duplex_fiber_serdes; break; case e1000_media_type_internal_serdes: func->setup_physical_interface = e1000_setup_fiber_serdes_link_82571; - func->check_for_link = e1000_check_for_serdes_link; - func->get_link_up_info = e1000_get_speed_and_duplex_fiber_serdes; + func->check_for_link = e1000e_check_for_serdes_link; + func->get_link_up_info = e1000e_get_speed_and_duplex_fiber_serdes; break; default: return -E1000_ERR_CONFIG; @@ -257,6 +262,7 @@ static s32 e1000_get_invariants_82571(struct e1000_adapter *adapter) case E1000_DEV_ID_82571EB_QUAD_COPPER: case E1000_DEV_ID_82571EB_QUAD_FIBER: case E1000_DEV_ID_82571EB_QUAD_COPPER_LP: + case E1000_DEV_ID_82571PT_QUAD_COPPER: adapter->flags |= FLAG_IS_QUAD_PORT; /* mark the first port */ if (global_quad_port_a == 0) @@ -280,7 +286,10 @@ static s32 e1000_get_invariants_82571(struct e1000_adapter *adapter) adapter->flags &= ~FLAG_HAS_WOL; /* quad ports only support WoL on port A */ if (adapter->flags & FLAG_IS_QUAD_PORT && - (!adapter->flags & FLAG_IS_QUAD_PORT_A)) + (!(adapter->flags & FLAG_IS_QUAD_PORT_A))) + adapter->flags &= ~FLAG_HAS_WOL; + /* Does not support WoL on any port */ + if (pdev->device == E1000_DEV_ID_82571EB_SERDES_QUAD) adapter->flags &= ~FLAG_HAS_WOL; break; @@ -320,7 +329,7 @@ static s32 e1000_get_phy_id_82571(struct e1000_hw *hw) phy->id = IGP01E1000_I_PHY_ID; break; case e1000_82573: - return e1000_get_phy_id(hw); + return e1000e_get_phy_id(hw); break; default: return -E1000_ERR_PHY; @@ -356,7 +365,7 @@ static s32 e1000_get_hw_semaphore_82571(struct e1000_hw *hw) if (i == timeout) { /* Release semaphores */ - e1000_put_hw_semaphore(hw); + e1000e_put_hw_semaphore(hw); hw_dbg(hw, "Driver can't access the NVM\n"); return -E1000_ERR_NVM; } @@ -399,7 +408,7 @@ static s32 e1000_acquire_nvm_82571(struct e1000_hw *hw) return ret_val; if (hw->mac.type != e1000_82573) - ret_val = e1000_acquire_nvm(hw); + ret_val = e1000e_acquire_nvm(hw); if (ret_val) e1000_put_hw_semaphore_82571(hw); @@ -415,7 +424,7 @@ static s32 e1000_acquire_nvm_82571(struct e1000_hw *hw) **/ static void e1000_release_nvm_82571(struct e1000_hw *hw) { - e1000_release_nvm(hw); + e1000e_release_nvm(hw); e1000_put_hw_semaphore_82571(hw); } @@ -428,7 +437,7 @@ static void e1000_release_nvm_82571(struct e1000_hw *hw) * * For non-82573 silicon, write data to EEPROM at offset using SPI interface. * - * If e1000_update_nvm_checksum is not called after this function, the + * If e1000e_update_nvm_checksum is not called after this function, the * EEPROM will most likley contain an invalid checksum. **/ static s32 e1000_write_nvm_82571(struct e1000_hw *hw, u16 offset, u16 words, @@ -442,7 +451,7 @@ static s32 e1000_write_nvm_82571(struct e1000_hw *hw, u16 offset, u16 words, break; case e1000_82571: case e1000_82572: - ret_val = e1000_write_nvm_spi(hw, offset, words, data); + ret_val = e1000e_write_nvm_spi(hw, offset, words, data); break; default: ret_val = -E1000_ERR_NVM; @@ -466,7 +475,7 @@ static s32 e1000_update_nvm_checksum_82571(struct e1000_hw *hw) s32 ret_val; u16 i; - ret_val = e1000_update_nvm_checksum_generic(hw); + ret_val = e1000e_update_nvm_checksum_generic(hw); if (ret_val) return ret_val; @@ -523,7 +532,7 @@ static s32 e1000_validate_nvm_checksum_82571(struct e1000_hw *hw) if (hw->nvm.type == e1000_nvm_flash_hw) e1000_fix_nvm_checksum_82571(hw); - return e1000_validate_nvm_checksum_generic(hw); + return e1000e_validate_nvm_checksum_generic(hw); } /** @@ -537,7 +546,7 @@ static s32 e1000_validate_nvm_checksum_82571(struct e1000_hw *hw) * command has completed before trying to write the next word. After write * poll for completion. * - * If e1000_update_nvm_checksum is not called after this function, the + * If e1000e_update_nvm_checksum is not called after this function, the * EEPROM will most likley contain an invalid checksum. **/ static s32 e1000_write_nvm_eewr_82571(struct e1000_hw *hw, u16 offset, @@ -561,13 +570,13 @@ static s32 e1000_write_nvm_eewr_82571(struct e1000_hw *hw, u16 offset, ((offset+i) << E1000_NVM_RW_ADDR_SHIFT) | E1000_NVM_RW_REG_START; - ret_val = e1000_poll_eerd_eewr_done(hw, E1000_NVM_POLL_WRITE); + ret_val = e1000e_poll_eerd_eewr_done(hw, E1000_NVM_POLL_WRITE); if (ret_val) break; ew32(EEWR, eewr); - ret_val = e1000_poll_eerd_eewr_done(hw, E1000_NVM_POLL_WRITE); + ret_val = e1000e_poll_eerd_eewr_done(hw, E1000_NVM_POLL_WRITE); if (ret_val) break; } @@ -687,7 +696,7 @@ static s32 e1000_reset_hw_82571(struct e1000_hw *hw) /* 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 = e1000_disable_pcie_master(hw); + ret_val = e1000e_disable_pcie_master(hw); if (ret_val) hw_dbg(hw, "PCI-E Master disable polling has failed.\n"); @@ -733,7 +742,7 @@ static s32 e1000_reset_hw_82571(struct e1000_hw *hw) e1e_flush(); } - ret_val = e1000_get_auto_rd_done(hw); + ret_val = e1000e_get_auto_rd_done(hw); if (ret_val) /* We don't want to continue accessing MAC registers. */ return ret_val; @@ -749,6 +758,10 @@ static s32 e1000_reset_hw_82571(struct e1000_hw *hw) ew32(IMC, 0xffffffff); icr = er32(ICR); + if (hw->mac.type == e1000_82571 && + hw->dev_spec.e82571.alt_mac_addr_is_present) + e1000e_set_laa_state_82571(hw, 1); + return 0; } @@ -769,7 +782,7 @@ static s32 e1000_init_hw_82571(struct e1000_hw *hw) e1000_initialize_hw_bits_82571(hw); /* Initialize identification LED */ - ret_val = e1000_id_led_init(hw); + ret_val = e1000e_id_led_init(hw); if (ret_val) { hw_dbg(hw, "Error initializing identification LED\n"); return ret_val; @@ -777,16 +790,16 @@ static s32 e1000_init_hw_82571(struct e1000_hw *hw) /* Disabling VLAN filtering */ hw_dbg(hw, "Initializing the IEEE VLAN\n"); - e1000_clear_vfta(hw); + e1000e_clear_vfta(hw); /* Setup the receive address. */ /* If, however, a locally administered address was assigned to the * 82571, we must reserve a RAR for it to work around an issue where * resetting one port will reload the MAC on the other port. */ - if (e1000_get_laa_state_82571(hw)) + if (e1000e_get_laa_state_82571(hw)) rar_count--; - e1000_init_rx_addrs(hw, rar_count); + e1000e_init_rx_addrs(hw, rar_count); /* Zero out the Multicast HASH table */ hw_dbg(hw, "Zeroing the MTA\n"); @@ -811,7 +824,7 @@ static s32 e1000_init_hw_82571(struct e1000_hw *hw) E1000_TXDCTL_COUNT_DESC; ew32(TXDCTL1, reg_data); } else { - e1000_enable_tx_pkt_filtering(hw); + e1000e_enable_tx_pkt_filtering(hw); reg_data = er32(GCR); reg_data |= E1000_GCR_L1_ACT_WITHOUT_L0S_RX; ew32(GCR, reg_data); @@ -894,13 +907,13 @@ static void e1000_initialize_hw_bits_82571(struct e1000_hw *hw) } /** - * e1000_clear_vfta - Clear VLAN filter table + * e1000e_clear_vfta - 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 e1000_clear_vfta(struct e1000_hw *hw) +void e1000e_clear_vfta(struct e1000_hw *hw) { u32 offset; u32 vfta_value = 0; @@ -952,10 +965,10 @@ static void e1000_mc_addr_list_update_82571(struct e1000_hw *hw, u32 rar_used_count, u32 rar_count) { - if (e1000_get_laa_state_82571(hw)) + if (e1000e_get_laa_state_82571(hw)) rar_count--; - e1000_mc_addr_list_update_generic(hw, mc_addr_list, mc_addr_count, + e1000e_mc_addr_list_update_generic(hw, mc_addr_list, mc_addr_count, rar_used_count, rar_count); } @@ -978,7 +991,7 @@ static s32 e1000_setup_link_82571(struct e1000_hw *hw) if (hw->mac.type == e1000_82573) hw->mac.fc = e1000_fc_full; - return e1000_setup_link(hw); + return e1000e_setup_link(hw); } /** @@ -1002,10 +1015,10 @@ static s32 e1000_setup_copper_link_82571(struct e1000_hw *hw) switch (hw->phy.type) { case e1000_phy_m88: - ret_val = e1000_copper_link_setup_m88(hw); + ret_val = e1000e_copper_link_setup_m88(hw); break; case e1000_phy_igp_2: - ret_val = e1000_copper_link_setup_igp(hw); + ret_val = e1000e_copper_link_setup_igp(hw); /* Setup activity LED */ led_ctrl = er32(LEDCTL); led_ctrl &= IGP_ACTIVITY_LED_MASK; @@ -1020,7 +1033,7 @@ static s32 e1000_setup_copper_link_82571(struct e1000_hw *hw) if (ret_val) return ret_val; - ret_val = e1000_setup_copper_link(hw); + ret_val = e1000e_setup_copper_link(hw); return ret_val; } @@ -1050,7 +1063,7 @@ static s32 e1000_setup_fiber_serdes_link_82571(struct e1000_hw *hw) break; } - return e1000_setup_fiber_serdes_link(hw); + return e1000e_setup_fiber_serdes_link(hw); } /** @@ -1082,12 +1095,12 @@ static s32 e1000_valid_led_default_82571(struct e1000_hw *hw, u16 *data) } /** - * e1000_get_laa_state_82571 - Get locally administered address state + * e1000e_get_laa_state_82571 - Get locally administered address state * @hw: pointer to the HW structure * * Retrieve and return the current locally administed address state. **/ -bool e1000_get_laa_state_82571(struct e1000_hw *hw) +bool e1000e_get_laa_state_82571(struct e1000_hw *hw) { if (hw->mac.type != e1000_82571) return 0; @@ -1096,13 +1109,13 @@ bool e1000_get_laa_state_82571(struct e1000_hw *hw) } /** - * e1000_set_laa_state_82571 - Set locally administered address state + * e1000e_set_laa_state_82571 - Set locally administered address state * @hw: pointer to the HW structure * @state: enable/disable locally administered address * * Enable/Disable the current locally administed address state. **/ -void e1000_set_laa_state_82571(struct e1000_hw *hw, bool state) +void e1000e_set_laa_state_82571(struct e1000_hw *hw, bool state) { if (hw->mac.type != e1000_82571) return; @@ -1117,7 +1130,7 @@ void e1000_set_laa_state_82571(struct e1000_hw *hw, bool state) * incoming packets directed to this port are dropped. * Eventually the LAA will be in RAR[0] and RAR[14]. */ - e1000_rar_set(hw, hw->mac.addr, hw->mac.rar_entry_count - 1); + e1000e_rar_set(hw, hw->mac.addr, hw->mac.rar_entry_count - 1); } /** @@ -1163,7 +1176,7 @@ static s32 e1000_fix_nvm_checksum_82571(struct e1000_hw *hw) ret_val = e1000_write_nvm(hw, 0x23, 1, &data); if (ret_val) return ret_val; - ret_val = e1000_update_nvm_checksum(hw); + ret_val = e1000e_update_nvm_checksum(hw); } } @@ -1180,7 +1193,7 @@ static void e1000_clear_hw_cntrs_82571(struct e1000_hw *hw) { u32 temp; - e1000_clear_hw_cntrs_base(hw); + e1000e_clear_hw_cntrs_base(hw); temp = er32(PRC64); temp = er32(PRC127); @@ -1221,12 +1234,12 @@ static void e1000_clear_hw_cntrs_82571(struct e1000_hw *hw) static struct e1000_mac_operations e82571_mac_ops = { .mng_mode_enab = E1000_MNG_IAMT_MODE << E1000_FWSM_MODE_SHIFT, /* .check_for_link: media type dependent */ - .cleanup_led = e1000_cleanup_led_generic, + .cleanup_led = e1000e_cleanup_led_generic, .clear_hw_cntrs = e1000_clear_hw_cntrs_82571, - .get_bus_info = e1000_get_bus_info_pcie, + .get_bus_info = e1000e_get_bus_info_pcie, /* .get_link_up_info: media type dependent */ - .led_on = e1000_led_on_generic, - .led_off = e1000_led_off_generic, + .led_on = e1000e_led_on_generic, + .led_off = e1000e_led_off_generic, .mc_addr_list_update = e1000_mc_addr_list_update_82571, .reset_hw = e1000_reset_hw_82571, .init_hw = e1000_init_hw_82571, @@ -1236,39 +1249,39 @@ static struct e1000_mac_operations e82571_mac_ops = { static struct e1000_phy_operations e82_phy_ops_igp = { .acquire_phy = e1000_get_hw_semaphore_82571, - .check_reset_block = e1000_check_reset_block_generic, + .check_reset_block = e1000e_check_reset_block_generic, .commit_phy = NULL, - .force_speed_duplex = e1000_phy_force_speed_duplex_igp, + .force_speed_duplex = e1000e_phy_force_speed_duplex_igp, .get_cfg_done = e1000_get_cfg_done_82571, - .get_cable_length = e1000_get_cable_length_igp_2, - .get_phy_info = e1000_get_phy_info_igp, - .read_phy_reg = e1000_read_phy_reg_igp, + .get_cable_length = e1000e_get_cable_length_igp_2, + .get_phy_info = e1000e_get_phy_info_igp, + .read_phy_reg = e1000e_read_phy_reg_igp, .release_phy = e1000_put_hw_semaphore_82571, - .reset_phy = e1000_phy_hw_reset_generic, + .reset_phy = e1000e_phy_hw_reset_generic, .set_d0_lplu_state = e1000_set_d0_lplu_state_82571, - .set_d3_lplu_state = e1000_set_d3_lplu_state, - .write_phy_reg = e1000_write_phy_reg_igp, + .set_d3_lplu_state = e1000e_set_d3_lplu_state, + .write_phy_reg = e1000e_write_phy_reg_igp, }; static struct e1000_phy_operations e82_phy_ops_m88 = { .acquire_phy = e1000_get_hw_semaphore_82571, - .check_reset_block = e1000_check_reset_block_generic, - .commit_phy = e1000_phy_sw_reset, - .force_speed_duplex = e1000_phy_force_speed_duplex_m88, - .get_cfg_done = e1000_get_cfg_done, - .get_cable_length = e1000_get_cable_length_m88, - .get_phy_info = e1000_get_phy_info_m88, - .read_phy_reg = e1000_read_phy_reg_m88, + .check_reset_block = e1000e_check_reset_block_generic, + .commit_phy = e1000e_phy_sw_reset, + .force_speed_duplex = e1000e_phy_force_speed_duplex_m88, + .get_cfg_done = e1000e_get_cfg_done, + .get_cable_length = e1000e_get_cable_length_m88, + .get_phy_info = e1000e_get_phy_info_m88, + .read_phy_reg = e1000e_read_phy_reg_m88, .release_phy = e1000_put_hw_semaphore_82571, - .reset_phy = e1000_phy_hw_reset_generic, + .reset_phy = e1000e_phy_hw_reset_generic, .set_d0_lplu_state = e1000_set_d0_lplu_state_82571, - .set_d3_lplu_state = e1000_set_d3_lplu_state, - .write_phy_reg = e1000_write_phy_reg_m88, + .set_d3_lplu_state = e1000e_set_d3_lplu_state, + .write_phy_reg = e1000e_write_phy_reg_m88, }; static struct e1000_nvm_operations e82571_nvm_ops = { .acquire_nvm = e1000_acquire_nvm_82571, - .read_nvm = e1000_read_nvm_spi, + .read_nvm = e1000e_read_nvm_spi, .release_nvm = e1000_release_nvm_82571, .update_nvm = e1000_update_nvm_checksum_82571, .valid_led_default = e1000_valid_led_default_82571, @@ -1278,7 +1291,7 @@ static struct e1000_nvm_operations e82571_nvm_ops = { static struct e1000_nvm_operations e82573_nvm_ops = { .acquire_nvm = e1000_acquire_nvm_82571, - .read_nvm = e1000_read_nvm_eerd, + .read_nvm = e1000e_read_nvm_eerd, .release_nvm = e1000_release_nvm_82571, .update_nvm = e1000_update_nvm_checksum_82571, .valid_led_default = e1000_valid_led_default_82571, @@ -1336,7 +1349,6 @@ struct e1000_info e1000_82573_info = { | FLAG_HAS_STATS_ICR_ICT | FLAG_HAS_SMART_POWER_DOWN | FLAG_HAS_AMT - | FLAG_HAS_ASPM | FLAG_HAS_ERT | FLAG_HAS_SWSM_ON_LOAD, .pba = 20, diff --git a/drivers/net/e1000e/defines.h b/drivers/net/e1000e/defines.h index ca80fde..f2175ea 100644 --- a/drivers/net/e1000e/defines.h +++ b/drivers/net/e1000e/defines.h @@ -557,6 +557,7 @@ #define NVM_INIT_3GIO_3 0x001A #define NVM_INIT_CONTROL3_PORT_A 0x0024 #define NVM_CFG 0x0012 +#define NVM_ALT_MAC_ADDR_PTR 0x0037 #define NVM_CHECKSUM_REG 0x003F #define E1000_NVM_CFG_DONE_PORT_0 0x40000 /* MNG config cycle done */ @@ -573,9 +574,11 @@ /* For checksumming, the sum of all words in the NVM should equal 0xBABA. */ #define NVM_SUM 0xBABA -#define NVM_WORD_SIZE_BASE_SHIFT 6 +/* PBA (printed board assembly) number words */ +#define NVM_PBA_OFFSET_0 8 +#define NVM_PBA_OFFSET_1 9 -/* NVM Commands - Microwire */ +#define NVM_WORD_SIZE_BASE_SHIFT 6 /* NVM Commands - SPI */ #define NVM_MAX_RETRY_SPI 5000 /* Max wait of 5ms, for RDY signal */ diff --git a/drivers/net/e1000e/e1000.h b/drivers/net/e1000e/e1000.h index a153c42..469430b 100644 --- a/drivers/net/e1000e/e1000.h +++ b/drivers/net/e1000e/e1000.h @@ -31,11 +31,11 @@ #ifndef _E1000_H_ #define _E1000_H_ +#include <linux/types.h> +#include <linux/timer.h> +#include <linux/workqueue.h> +#include <linux/io.h> #include <linux/netdevice.h> -#include <linux/ethtool.h> -#include <linux/pci.h> -#include <linux/delay.h> -#include <asm/io.h> #include "e1000_compat.h" #include "hw.h" @@ -123,7 +123,8 @@ struct e1000_buffer { u16 next_to_watch; }; /* RX */ - struct page *page; + /* arrays of page information for packet split */ + struct e1000_ps_page *ps_pages; }; }; @@ -143,18 +144,7 @@ struct e1000_ring { /* array of buffer information structs */ struct e1000_buffer *buffer_info; - union { - /* for TX */ - struct { - bool last_tx_tso; /* used to mark tso desc. */ - }; - /* for RX */ - struct { - /* arrays of page information for packet split */ - struct e1000_ps_page *ps_pages; - struct sk_buff *rx_skb_top; - }; - }; + struct sk_buff *rx_skb_top; struct e1000_queue_stats stats; }; @@ -221,6 +211,7 @@ struct e1000_adapter { u32 tx_fifo_head; u32 tx_head_addr; u32 tx_fifo_size; + u32 tx_dma_failed; /* * RX @@ -242,6 +233,7 @@ struct e1000_adapter { u64 gorcl_old; u32 gorcl; u32 alloc_rx_buff_failed; + u32 rx_dma_failed; unsigned int rx_ps_pages; u16 rx_ps_bsize0; @@ -295,7 +287,6 @@ struct e1000_info { #define FLAG_HAS_CTRLEXT_ON_LOAD (1 << 5) #define FLAG_HAS_SWSM_ON_LOAD (1 << 6) #define FLAG_HAS_JUMBO_FRAMES (1 << 7) -#define FLAG_HAS_ASPM (1 << 8) #define FLAG_HAS_STATS_ICR_ICT (1 << 9) #define FLAG_HAS_STATS_PTC_PRC (1 << 10) #define FLAG_HAS_SMART_POWER_DOWN (1 << 11) @@ -338,26 +329,26 @@ enum latency_range { latency_invalid = 255 }; -extern char e1000_driver_name[]; -extern const char e1000_driver_version[]; +extern char e1000e_driver_name[]; +extern const char e1000e_driver_version[]; -extern void e1000_check_options(struct e1000_adapter *adapter); -extern void e1000_set_ethtool_ops(struct net_device *netdev); +extern void e1000e_check_options(struct e1000_adapter *adapter); +extern void e1000e_set_ethtool_ops(struct net_device *netdev); -extern int e1000_up(struct e1000_adapter *adapter); -extern void e1000_down(struct e1000_adapter *adapter); -extern void e1000_reinit_locked(struct e1000_adapter *adapter); -extern void e1000_reset(struct e1000_adapter *adapter); -extern void e1000_power_up_phy(struct e1000_adapter *adapter); -extern int e1000_setup_rx_resources(struct e1000_adapter *adapter); -extern int e1000_setup_tx_resources(struct e1000_adapter *adapter); -extern void e1000_free_rx_resources(struct e1000_adapter *adapter); -extern void e1000_free_tx_resources(struct e1000_adapter *adapter); -extern void e1000_update_stats(struct e1000_adapter *adapter); +extern int e1000e_up(struct e1000_adapter *adapter); +extern void e1000e_down(struct e1000_adapter *adapter); +extern void e1000e_reinit_locked(struct e1000_adapter *adapter); +extern void e1000e_reset(struct e1000_adapter *adapter); +extern void e1000e_power_up_phy(struct e1000_adapter *adapter); +extern int e1000e_setup_rx_resources(struct e1000_adapter *adapter); +extern int e1000e_setup_tx_resources(struct e1000_adapter *adapter); +extern void e1000e_free_rx_resources(struct e1000_adapter *adapter); +extern void e1000e_free_tx_resources(struct e1000_adapter *adapter); +extern void e1000e_update_stats(struct e1000_adapter *adapter); extern unsigned int copybreak; -extern char *e1000_get_hw_dev_name(struct e1000_hw *hw); +extern char *e1000e_get_hw_dev_name(struct e1000_hw *hw); extern struct e1000_info e1000_82571_info; extern struct e1000_info e1000_82572_info; @@ -366,79 +357,81 @@ extern struct e1000_info e1000_ich8_info; extern struct e1000_info e1000_ich9_info; extern struct e1000_info e1000_es2_info; -extern s32 e1000_commit_phy(struct e1000_hw *hw); +extern s32 e1000e_read_part_num(struct e1000_hw *hw, u32 *part_num); + +extern s32 e1000e_commit_phy(struct e1000_hw *hw); -extern bool e1000_enable_mng_pass_thru(struct e1000_hw *hw); +extern bool e1000e_enable_mng_pass_thru(struct e1000_hw *hw); -extern bool e1000_get_laa_state_82571(struct e1000_hw *hw); -extern void e1000_set_laa_state_82571(struct e1000_hw *hw, bool state); +extern bool e1000e_get_laa_state_82571(struct e1000_hw *hw); +extern void e1000e_set_laa_state_82571(struct e1000_hw *hw, bool state); -extern void e1000_set_kmrn_lock_loss_workaround_ich8lan(struct e1000_hw *hw, +extern void e1000e_set_kmrn_lock_loss_workaround_ich8lan(struct e1000_hw *hw, bool state); -extern void e1000_igp3_phy_powerdown_workaround_ich8lan(struct e1000_hw *hw); -extern void e1000_gig_downshift_workaround_ich8lan(struct e1000_hw *hw); - -extern s32 e1000_check_for_copper_link(struct e1000_hw *hw); -extern s32 e1000_check_for_fiber_link(struct e1000_hw *hw); -extern s32 e1000_check_for_serdes_link(struct e1000_hw *hw); -extern s32 e1000_cleanup_led_generic(struct e1000_hw *hw); -extern s32 e1000_led_on_generic(struct e1000_hw *hw); -extern s32 e1000_led_off_generic(struct e1000_hw *hw); -extern s32 e1000_get_bus_info_pcie(struct e1000_hw *hw); -extern s32 e1000_get_speed_and_duplex_copper(struct e1000_hw *hw, u16 *speed, u16 *duplex); -extern s32 e1000_get_speed_and_duplex_fiber_serdes(struct e1000_hw *hw, u16 *speed, u16 *duplex); -extern s32 e1000_disable_pcie_master(struct e1000_hw *hw); -extern s32 e1000_get_auto_rd_done(struct e1000_hw *hw); -extern s32 e1000_id_led_init(struct e1000_hw *hw); -extern void e1000_clear_hw_cntrs_base(struct e1000_hw *hw); -extern s32 e1000_setup_fiber_serdes_link(struct e1000_hw *hw); -extern s32 e1000_copper_link_setup_m88(struct e1000_hw *hw); -extern s32 e1000_copper_link_setup_igp(struct e1000_hw *hw); -extern s32 e1000_setup_link(struct e1000_hw *hw); -extern void e1000_clear_vfta(struct e1000_hw *hw); -extern void e1000_init_rx_addrs(struct e1000_hw *hw, u16 rar_count); -extern void e1000_mc_addr_list_update_generic(struct e1000_hw *hw, +extern void e1000e_igp3_phy_powerdown_workaround_ich8lan(struct e1000_hw *hw); +extern void e1000e_gig_downshift_workaround_ich8lan(struct e1000_hw *hw); + +extern s32 e1000e_check_for_copper_link(struct e1000_hw *hw); +extern s32 e1000e_check_for_fiber_link(struct e1000_hw *hw); +extern s32 e1000e_check_for_serdes_link(struct e1000_hw *hw); +extern s32 e1000e_cleanup_led_generic(struct e1000_hw *hw); +extern s32 e1000e_led_on_generic(struct e1000_hw *hw); +extern s32 e1000e_led_off_generic(struct e1000_hw *hw); +extern s32 e1000e_get_bus_info_pcie(struct e1000_hw *hw); +extern s32 e1000e_get_speed_and_duplex_copper(struct e1000_hw *hw, u16 *speed, u16 *duplex); +extern s32 e1000e_get_speed_and_duplex_fiber_serdes(struct e1000_hw *hw, u16 *speed, u16 *duplex); +extern s32 e1000e_disable_pcie_master(struct e1000_hw *hw); +extern s32 e1000e_get_auto_rd_done(struct e1000_hw *hw); +extern s32 e1000e_id_led_init(struct e1000_hw *hw); +extern void e1000e_clear_hw_cntrs_base(struct e1000_hw *hw); +extern s32 e1000e_setup_fiber_serdes_link(struct e1000_hw *hw); +extern s32 e1000e_copper_link_setup_m88(struct e1000_hw *hw); +extern s32 e1000e_copper_link_setup_igp(struct e1000_hw *hw); +extern s32 e1000e_setup_link(struct e1000_hw *hw); +extern void e1000e_clear_vfta(struct e1000_hw *hw); +extern void e1000e_init_rx_addrs(struct e1000_hw *hw, u16 rar_count); +extern void e1000e_mc_addr_list_update_generic(struct e1000_hw *hw, u8 *mc_addr_list, u32 mc_addr_count, u32 rar_used_count, u32 rar_count); -extern void e1000_rar_set(struct e1000_hw *hw, u8 *addr, u32 index); -extern s32 e1000_set_fc_watermarks(struct e1000_hw *hw); -extern void e1000_set_pcie_no_snoop(struct e1000_hw *hw, u32 no_snoop); -extern s32 e1000_get_hw_semaphore(struct e1000_hw *hw); -extern s32 e1000_valid_led_default(struct e1000_hw *hw, u16 *data); -extern void e1000_config_collision_dist(struct e1000_hw *hw); -extern s32 e1000_config_fc_after_link_up(struct e1000_hw *hw); -extern s32 e1000_force_mac_fc(struct e1000_hw *hw); -extern s32 e1000_blink_led(struct e1000_hw *hw); -extern void e1000_write_vfta(struct e1000_hw *hw, u32 offset, u32 value); -extern void e1000_reset_adaptive(struct e1000_hw *hw); -extern void e1000_update_adaptive(struct e1000_hw *hw); - -extern s32 e1000_setup_copper_link(struct e1000_hw *hw); -extern s32 e1000_get_phy_id(struct e1000_hw *hw); -extern void e1000_put_hw_semaphore(struct e1000_hw *hw); -extern s32 e1000_check_reset_block_generic(struct e1000_hw *hw); -extern s32 e1000_phy_force_speed_duplex_igp(struct e1000_hw *hw); -extern s32 e1000_get_cable_length_igp_2(struct e1000_hw *hw); -extern s32 e1000_get_phy_info_igp(struct e1000_hw *hw); -extern s32 e1000_read_phy_reg_igp(struct e1000_hw *hw, u32 offset, u16 *data); -extern s32 e1000_phy_hw_reset_generic(struct e1000_hw *hw); -extern s32 e1000_set_d3_lplu_state(struct e1000_hw *hw, bool active); -extern s32 e1000_write_phy_reg_igp(struct e1000_hw *hw, u32 offset, u16 data); -extern s32 e1000_phy_sw_reset(struct e1000_hw *hw); -extern s32 e1000_phy_force_speed_duplex_m88(struct e1000_hw *hw); -extern s32 e1000_get_cfg_done(struct e1000_hw *hw); -extern s32 e1000_get_cable_length_m88(struct e1000_hw *hw); -extern s32 e1000_get_phy_info_m88(struct e1000_hw *hw); -extern s32 e1000_read_phy_reg_m88(struct e1000_hw *hw, u32 offset, u16 *data); -extern s32 e1000_write_phy_reg_m88(struct e1000_hw *hw, u32 offset, u16 data); -extern enum e1000_phy_type e1000_get_phy_type_from_id(u32 phy_id); -extern void e1000_phy_force_speed_duplex_setup(struct e1000_hw *hw, u16 *phy_ctrl); -extern s32 e1000_write_kmrn_reg(struct e1000_hw *hw, u32 offset, u16 data); -extern s32 e1000_read_kmrn_reg(struct e1000_hw *hw, u32 offset, u16 *data); -extern s32 e1000_phy_has_link_generic(struct e1000_hw *hw, u32 iterations, +extern void e1000e_rar_set(struct e1000_hw *hw, u8 *addr, u32 index); +extern s32 e1000e_set_fc_watermarks(struct e1000_hw *hw); +extern void e1000e_set_pcie_no_snoop(struct e1000_hw *hw, u32 no_snoop); +extern s32 e1000e_get_hw_semaphore(struct e1000_hw *hw); +extern s32 e1000e_valid_led_default(struct e1000_hw *hw, u16 *data); +extern void e1000e_config_collision_dist(struct e1000_hw *hw); +extern s32 e1000e_config_fc_after_link_up(struct e1000_hw *hw); +extern s32 e1000e_force_mac_fc(struct e1000_hw *hw); +extern s32 e1000e_blink_led(struct e1000_hw *hw); +extern void e1000e_write_vfta(struct e1000_hw *hw, u32 offset, u32 value); +extern void e1000e_reset_adaptive(struct e1000_hw *hw); +extern void e1000e_update_adaptive(struct e1000_hw *hw); + +extern s32 e1000e_setup_copper_link(struct e1000_hw *hw); +extern s32 e1000e_get_phy_id(struct e1000_hw *hw); +extern void e1000e_put_hw_semaphore(struct e1000_hw *hw); +extern s32 e1000e_check_reset_block_generic(struct e1000_hw *hw); +extern s32 e1000e_phy_force_speed_duplex_igp(struct e1000_hw *hw); +extern s32 e1000e_get_cable_length_igp_2(struct e1000_hw *hw); +extern s32 e1000e_get_phy_info_igp(struct e1000_hw *hw); +extern s32 e1000e_read_phy_reg_igp(struct e1000_hw *hw, u32 offset, u16 *data); +extern s32 e1000e_phy_hw_reset_generic(struct e1000_hw *hw); +extern s32 e1000e_set_d3_lplu_state(struct e1000_hw *hw, bool active); +extern s32 e1000e_write_phy_reg_igp(struct e1000_hw *hw, u32 offset, u16 data); +extern s32 e1000e_phy_sw_reset(struct e1000_hw *hw); +extern s32 e1000e_phy_force_speed_duplex_m88(struct e1000_hw *hw); +extern s32 e1000e_get_cfg_done(struct e1000_hw *hw); +extern s32 e1000e_get_cable_length_m88(struct e1000_hw *hw); +extern s32 e1000e_get_phy_info_m88(struct e1000_hw *hw); +extern s32 e1000e_read_phy_reg_m88(struct e1000_hw *hw, u32 offset, u16 *data); +extern s32 e1000e_write_phy_reg_m88(struct e1000_hw *hw, u32 offset, u16 data); +extern enum e1000_phy_type e1000e_get_phy_type_from_id(u32 phy_id); +extern void e1000e_phy_force_speed_duplex_setup(struct e1000_hw *hw, u16 *phy_ctrl); +extern s32 e1000e_write_kmrn_reg(struct e1000_hw *hw, u32 offset, u16 data); +extern s32 e1000e_read_kmrn_reg(struct e1000_hw *hw, u32 offset, u16 *data); +extern s32 e1000e_phy_has_link_generic(struct e1000_hw *hw, u32 iterations, u32 usec_interval, bool *success); -extern s32 e1000_phy_reset_dsp(struct e1000_hw *hw); -extern s32 e1000_check_downshift(struct e1000_hw *hw); +extern s32 e1000e_phy_reset_dsp(struct e1000_hw *hw); +extern s32 e1000e_check_downshift(struct e1000_hw *hw); static inline s32 e1000_phy_hw_reset(struct e1000_hw *hw) { @@ -465,23 +458,23 @@ static inline s32 e1000_get_cable_length(struct e1000_hw *hw) return hw->phy.ops.get_cable_length(hw); } -extern s32 e1000_acquire_nvm(struct e1000_hw *hw); -extern s32 e1000_write_nvm_spi(struct e1000_hw *hw, u16 offset, u16 words, u16 *data); -extern s32 e1000_update_nvm_checksum_generic(struct e1000_hw *hw); -extern s32 e1000_poll_eerd_eewr_done(struct e1000_hw *hw, int ee_reg); -extern s32 e1000_read_nvm_spi(struct e1000_hw *hw, u16 offset, u16 words, u16 *data); -extern s32 e1000_read_nvm_eerd(struct e1000_hw *hw, u16 offset, u16 words, u16 *data); -extern s32 e1000_validate_nvm_checksum_generic(struct e1000_hw *hw); -extern void e1000_release_nvm(struct e1000_hw *hw); -extern void e1000_reload_nvm(struct e1000_hw *hw); -extern s32 e1000_read_mac_addr(struct e1000_hw *hw); +extern s32 e1000e_acquire_nvm(struct e1000_hw *hw); +extern s32 e1000e_write_nvm_spi(struct e1000_hw *hw, u16 offset, u16 words, u16 *data); +extern s32 e1000e_update_nvm_checksum_generic(struct e1000_hw *hw); +extern s32 e1000e_poll_eerd_eewr_done(struct e1000_hw *hw, int ee_reg); +extern s32 e1000e_read_nvm_spi(struct e1000_hw *hw, u16 offset, u16 words, u16 *data); +extern s32 e1000e_read_nvm_eerd(struct e1000_hw *hw, u16 offset, u16 words, u16 *data); +extern s32 e1000e_validate_nvm_checksum_generic(struct e1000_hw *hw); +extern void e1000e_release_nvm(struct e1000_hw *hw); +extern void e1000e_reload_nvm(struct e1000_hw *hw); +extern s32 e1000e_read_mac_addr(struct e1000_hw *hw); static inline s32 e1000_validate_nvm_checksum(struct e1000_hw *hw) { return hw->nvm.ops.validate_nvm(hw); } -static inline s32 e1000_update_nvm_checksum(struct e1000_hw *hw) +static inline s32 e1000e_update_nvm_checksum(struct e1000_hw *hw) { return hw->nvm.ops.update_nvm(hw); } @@ -501,9 +494,9 @@ static inline s32 e1000_get_phy_info(struct e1000_hw *hw) return hw->phy.ops.get_phy_info(hw); } -extern bool e1000_check_mng_mode(struct e1000_hw *hw); -extern bool e1000_enable_tx_pkt_filtering(struct e1000_hw *hw); -extern s32 e1000_mng_write_dhcp_info(struct e1000_hw *hw, u8 *buffer, u16 length); +extern bool e1000e_check_mng_mode(struct e1000_hw *hw); +extern bool e1000e_enable_tx_pkt_filtering(struct e1000_hw *hw); +extern s32 e1000e_mng_write_dhcp_info(struct e1000_hw *hw, u8 *buffer, u16 length); static inline u32 __er32(struct e1000_hw *hw, unsigned long reg) { diff --git a/drivers/net/e1000e/es2lan.c b/drivers/net/e1000e/es2lan.c index 5604c50..88657ad 100644 --- a/drivers/net/e1000e/es2lan.c +++ b/drivers/net/e1000e/es2lan.c @@ -31,6 +31,11 @@ * 80003ES2LAN Gigabit Ethernet Controller (Serdes) */ +#include <linux/netdevice.h> +#include <linux/ethtool.h> +#include <linux/delay.h> +#include <linux/pci.h> + #include "e1000.h" #define E1000_KMRNCTRLSTA_OFFSET_FIFO_CTRL 0x00 @@ -124,7 +129,7 @@ static s32 e1000_init_phy_params_80003es2lan(struct e1000_hw *hw) phy->type = e1000_phy_gg82563; /* This can only be done after all function pointers are setup. */ - ret_val = e1000_get_phy_id(hw); + ret_val = e1000e_get_phy_id(hw); /* Verify phy id */ if (phy->id != GG82563_E_PHY_ID) @@ -210,15 +215,15 @@ static s32 e1000_init_mac_params_80003es2lan(struct e1000_adapter *adapter) switch (hw->media_type) { case e1000_media_type_copper: func->setup_physical_interface = e1000_setup_copper_link_80003es2lan; - func->check_for_link = e1000_check_for_copper_link; + func->check_for_link = e1000e_check_for_copper_link; break; case e1000_media_type_fiber: - func->setup_physical_interface = e1000_setup_fiber_serdes_link; - func->check_for_link = e1000_check_for_fiber_link; + func->setup_physical_interface = e1000e_setup_fiber_serdes_link; + func->check_for_link = e1000e_check_for_fiber_link; break; case e1000_media_type_internal_serdes: - func->setup_physical_interface = e1000_setup_fiber_serdes_link; - func->check_for_link = e1000_check_for_serdes_link; + func->setup_physical_interface = e1000e_setup_fiber_serdes_link; + func->check_for_link = e1000e_check_for_serdes_link; break; default: return -E1000_ERR_CONFIG; @@ -294,7 +299,7 @@ static s32 e1000_acquire_nvm_80003es2lan(struct e1000_hw *hw) if (ret_val) return ret_val; - ret_val = e1000_acquire_nvm(hw); + ret_val = e1000e_acquire_nvm(hw); if (ret_val) e1000_release_swfw_sync_80003es2lan(hw, E1000_SWFW_EEP_SM); @@ -311,7 +316,7 @@ static s32 e1000_acquire_nvm_80003es2lan(struct e1000_hw *hw) **/ static void e1000_release_nvm_80003es2lan(struct e1000_hw *hw) { - e1000_release_nvm(hw); + e1000e_release_nvm(hw); e1000_release_swfw_sync_80003es2lan(hw, E1000_SWFW_EEP_SM); } @@ -332,7 +337,7 @@ static s32 e1000_acquire_swfw_sync_80003es2lan(struct e1000_hw *hw, u16 mask) s32 timeout = 200; while (i < timeout) { - if (e1000_get_hw_semaphore(hw)) + if (e1000e_get_hw_semaphore(hw)) return -E1000_ERR_SWFW_SYNC; swfw_sync = er32(SW_FW_SYNC); @@ -341,7 +346,7 @@ static s32 e1000_acquire_swfw_sync_80003es2lan(struct e1000_hw *hw, u16 mask) /* Firmware currently using resource (fwmask) * or other software thread using resource (swmask) */ - e1000_put_hw_semaphore(hw); + e1000e_put_hw_semaphore(hw); mdelay(5); i++; } @@ -355,7 +360,7 @@ static s32 e1000_acquire_swfw_sync_80003es2lan(struct e1000_hw *hw, u16 mask) swfw_sync |= swmask; ew32(SW_FW_SYNC, swfw_sync); - e1000_put_hw_semaphore(hw); + e1000e_put_hw_semaphore(hw); return 0; } @@ -372,14 +377,14 @@ static void e1000_release_swfw_sync_80003es2lan(struct e1000_hw *hw, u16 mask) { u32 swfw_sync; - while (e1000_get_hw_semaphore(hw) != 0); + while (e1000e_get_hw_semaphore(hw) != 0); /* Empty */ swfw_sync = er32(SW_FW_SYNC); swfw_sync &= ~mask; ew32(SW_FW_SYNC, swfw_sync); - e1000_put_hw_semaphore(hw); + e1000e_put_hw_semaphore(hw); } /** @@ -408,7 +413,7 @@ static s32 e1000_read_phy_reg_gg82563_80003es2lan(struct e1000_hw *hw, page_select = GG82563_PHY_PAGE_SELECT_ALT; temp = (u16)((u16)offset >> GG82563_PAGE_SHIFT); - ret_val = e1000_write_phy_reg_m88(hw, page_select, temp); + ret_val = e1000e_write_phy_reg_m88(hw, page_select, temp); if (ret_val) return ret_val; @@ -419,7 +424,7 @@ static s32 e1000_read_phy_reg_gg82563_80003es2lan(struct e1000_hw *hw, udelay(200); /* ...and verify the command was successful. */ - ret_val = e1000_read_phy_reg_m88(hw, page_select, &temp); + ret_val = e1000e_read_phy_reg_m88(hw, page_select, &temp); if (((u16)offset >> GG82563_PAGE_SHIFT) != temp) { ret_val = -E1000_ERR_PHY; @@ -428,7 +433,7 @@ static s32 e1000_read_phy_reg_gg82563_80003es2lan(struct e1000_hw *hw, udelay(200); - ret_val = e1000_read_phy_reg_m88(hw, + ret_val = e1000e_read_phy_reg_m88(hw, MAX_PHY_REG_ADDRESS & offset, data); @@ -463,7 +468,7 @@ static s32 e1000_write_phy_reg_gg82563_80003es2lan(struct e1000_hw *hw, page_select = GG82563_PHY_PAGE_SELECT_ALT; temp = (u16)((u16)offset >> GG82563_PAGE_SHIFT); - ret_val = e1000_write_phy_reg_m88(hw, page_select, temp); + ret_val = e1000e_write_phy_reg_m88(hw, page_select, temp); if (ret_val) return ret_val; @@ -475,14 +480,14 @@ static s32 e1000_write_phy_reg_gg82563_80003es2lan(struct e1000_hw *hw, udelay(200); /* ...and verify the command was successful. */ - ret_val = e1000_read_phy_reg_m88(hw, page_select, &temp); + ret_val = e1000e_read_phy_reg_m88(hw, page_select, &temp); if (((u16)offset >> GG82563_PAGE_SHIFT) != temp) return -E1000_ERR_PHY; udelay(200); - ret_val = e1000_write_phy_reg_m88(hw, + ret_val = e1000e_write_phy_reg_m88(hw, MAX_PHY_REG_ADDRESS & offset, data); @@ -504,7 +509,7 @@ static s32 e1000_write_phy_reg_gg82563_80003es2lan(struct e1000_hw *hw, static s32 e1000_write_nvm_80003es2lan(struct e1000_hw *hw, u16 offset, u16 words, u16 *data) { - return e1000_write_nvm_spi(hw, offset, words, data); + return e1000e_write_nvm_spi(hw, offset, words, data); } /** @@ -567,7 +572,7 @@ static s32 e1000_phy_force_speed_duplex_80003es2lan(struct e1000_hw *hw) if (ret_val) return ret_val; - e1000_phy_force_speed_duplex_setup(hw, &phy_data); + e1000e_phy_force_speed_duplex_setup(hw, &phy_data); /* Reset the phy to commit changes. */ phy_data |= MII_CR_RESET; @@ -582,7 +587,7 @@ static s32 e1000_phy_force_speed_duplex_80003es2lan(struct e1000_hw *hw) hw_dbg(hw, "Waiting for forced speed/duplex link " "on GG82563 phy.\n"); - ret_val = e1000_phy_has_link_generic(hw, PHY_FORCE_LIMIT, + ret_val = e1000e_phy_has_link_generic(hw, PHY_FORCE_LIMIT, 100000, &link); if (ret_val) return ret_val; @@ -591,13 +596,13 @@ static s32 e1000_phy_force_speed_duplex_80003es2lan(struct e1000_hw *hw) /* We didn't get link. * Reset the DSP and cross our fingers. */ - ret_val = e1000_phy_reset_dsp(hw); + ret_val = e1000e_phy_reset_dsp(hw); if (ret_val) return ret_val; } /* Try once more */ - ret_val = e1000_phy_has_link_generic(hw, PHY_FORCE_LIMIT, + ret_val = e1000e_phy_has_link_generic(hw, PHY_FORCE_LIMIT, 100000, &link); if (ret_val) return ret_val; @@ -667,7 +672,7 @@ static s32 e1000_get_link_up_info_80003es2lan(struct e1000_hw *hw, u16 *speed, s32 ret_val; if (hw->media_type == e1000_media_type_copper) { - ret_val = e1000_get_speed_and_duplex_copper(hw, + ret_val = e1000e_get_speed_and_duplex_copper(hw, speed, duplex); if (ret_val) @@ -678,7 +683,7 @@ static s32 e1000_get_link_up_info_80003es2lan(struct e1000_hw *hw, u16 *speed, ret_val = e1000_cfg_kmrn_10_100_80003es2lan(hw, *duplex); } else { - ret_val = e1000_get_speed_and_duplex_fiber_serdes(hw, + ret_val = e1000e_get_speed_and_duplex_fiber_serdes(hw, speed, duplex); } @@ -702,7 +707,7 @@ static s32 e1000_reset_hw_80003es2lan(struct e1000_hw *hw) /* 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 = e1000_disable_pcie_master(hw); + ret_val = e1000e_disable_pcie_master(hw); if (ret_val) hw_dbg(hw, "PCI-E Master disable polling has failed.\n"); @@ -720,7 +725,7 @@ static s32 e1000_reset_hw_80003es2lan(struct e1000_hw *hw) hw_dbg(hw, "Issuing a global reset to MAC\n"); ew32(CTRL, ctrl | E1000_CTRL_RST); - ret_val = e1000_get_auto_rd_done(hw); + ret_val = e1000e_get_auto_rd_done(hw); if (ret_val) /* We don't want to continue accessing MAC registers. */ return ret_val; @@ -749,7 +754,7 @@ static s32 e1000_init_hw_80003es2lan(struct e1000_hw *hw) e1000_initialize_hw_bits_80003es2lan(hw); /* Initialize identification LED */ - ret_val = e1000_id_led_init(hw); + ret_val = e1000e_id_led_init(hw); if (ret_val) { hw_dbg(hw, "Error initializing identification LED\n"); return ret_val; @@ -757,10 +762,10 @@ static s32 e1000_init_hw_80003es2lan(struct e1000_hw *hw) /* Disabling VLAN filtering */ hw_dbg(hw, "Initializing the IEEE VLAN\n"); - e1000_clear_vfta(hw); + e1000e_clear_vfta(hw); /* Setup the receive address. */ - e1000_init_rx_addrs(hw, mac->rar_entry_count); + e1000e_init_rx_addrs(hw, mac->rar_entry_count); /* Zero out the Multicast HASH table */ hw_dbg(hw, "Zeroing the MTA\n"); @@ -768,7 +773,7 @@ static s32 e1000_init_hw_80003es2lan(struct e1000_hw *hw) E1000_WRITE_REG_ARRAY(hw, E1000_MTA, i, 0); /* Setup link and flow control */ - ret_val = e1000_setup_link(hw); + ret_val = e1000e_setup_link(hw); /* Set the transmit descriptor write-back policy */ reg_data = er32(TXDCTL); @@ -917,14 +922,14 @@ static s32 e1000_copper_link_setup_gg82563_80003es2lan(struct e1000_hw *hw) return ret_val; /* SW Reset the PHY so all changes take effect */ - ret_val = e1000_commit_phy(hw); + ret_val = e1000e_commit_phy(hw); if (ret_val) { hw_dbg(hw, "Error Resetting the PHY\n"); return ret_val; } /* Bypass RX and TX FIFO's */ - ret_val = e1000_write_kmrn_reg(hw, + ret_val = e1000e_write_kmrn_reg(hw, E1000_KMRNCTRLSTA_OFFSET_FIFO_CTRL, E1000_KMRNCTRLSTA_FIFO_CTRL_RX_BYPASS | E1000_KMRNCTRLSTA_FIFO_CTRL_TX_BYPASS); @@ -952,7 +957,7 @@ static s32 e1000_copper_link_setup_gg82563_80003es2lan(struct e1000_hw *hw) * firmware will have already initialized them. We only initialize * them if the HW is not in IAMT mode. */ - if (!e1000_check_mng_mode(hw)) { + if (!e1000e_check_mng_mode(hw)) { /* Enable Electrical Idle on the PHY */ data |= GG82563_PMCR_ENABLE_ELECTRICAL_IDLE; ret_val = e1e_wphy(hw, GG82563_PHY_PWR_MGMT_CTRL, data); @@ -1005,23 +1010,23 @@ static s32 e1000_setup_copper_link_80003es2lan(struct e1000_hw *hw) /* Set the mac to wait the maximum time between each * iteration and increase the max iterations when * polling the phy; this fixes erroneous timeouts at 10Mbps. */ - ret_val = e1000_write_kmrn_reg(hw, GG82563_REG(0x34, 4), 0xFFFF); + ret_val = e1000e_write_kmrn_reg(hw, GG82563_REG(0x34, 4), 0xFFFF); if (ret_val) return ret_val; - ret_val = e1000_read_kmrn_reg(hw, GG82563_REG(0x34, 9), ®_data); + ret_val = e1000e_read_kmrn_reg(hw, GG82563_REG(0x34, 9), ®_data); if (ret_val) return ret_val; reg_data |= 0x3F; - ret_val = e1000_write_kmrn_reg(hw, GG82563_REG(0x34, 9), reg_data); + ret_val = e1000e_write_kmrn_reg(hw, GG82563_REG(0x34, 9), reg_data); if (ret_val) return ret_val; - ret_val = e1000_read_kmrn_reg(hw, + ret_val = e1000e_read_kmrn_reg(hw, E1000_KMRNCTRLSTA_OFFSET_INB_CTRL, ®_data); if (ret_val) return ret_val; reg_data |= E1000_KMRNCTRLSTA_INB_CTRL_DIS_PADDING; - ret_val = e1000_write_kmrn_reg(hw, + ret_val = e1000e_write_kmrn_reg(hw, E1000_KMRNCTRLSTA_OFFSET_INB_CTRL, reg_data); if (ret_val) @@ -1031,7 +1036,7 @@ static s32 e1000_setup_copper_link_80003es2lan(struct e1000_hw *hw) if (ret_val) return ret_val; - ret_val = e1000_setup_copper_link(hw); + ret_val = e1000e_setup_copper_link(hw); return 0; } @@ -1051,7 +1056,7 @@ static s32 e1000_cfg_kmrn_10_100_80003es2lan(struct e1000_hw *hw, u16 duplex) u16 reg_data; reg_data = E1000_KMRNCTRLSTA_HD_CTRL_10_100_DEFAULT; - ret_val = e1000_write_kmrn_reg(hw, + ret_val = e1000e_write_kmrn_reg(hw, E1000_KMRNCTRLSTA_OFFSET_HD_CTRL, reg_data); if (ret_val) @@ -1091,7 +1096,7 @@ static s32 e1000_cfg_kmrn_1000_80003es2lan(struct e1000_hw *hw) u32 tipg; reg_data = E1000_KMRNCTRLSTA_HD_CTRL_1000_DEFAULT; - ret_val = e1000_write_kmrn_reg(hw, + ret_val = e1000e_write_kmrn_reg(hw, E1000_KMRNCTRLSTA_OFFSET_HD_CTRL, reg_data); if (ret_val) @@ -1123,7 +1128,7 @@ static void e1000_clear_hw_cntrs_80003es2lan(struct e1000_hw *hw) { u32 temp; - e1000_clear_hw_cntrs_base(hw); + e1000e_clear_hw_cntrs_base(hw); temp = er32(PRC64); temp = er32(PRC127); @@ -1164,42 +1169,42 @@ static void e1000_clear_hw_cntrs_80003es2lan(struct e1000_hw *hw) static struct e1000_mac_operations es2_mac_ops = { .mng_mode_enab = E1000_MNG_IAMT_MODE << E1000_FWSM_MODE_SHIFT, /* check_for_link dependent on media type */ - .cleanup_led = e1000_cleanup_led_generic, + .cleanup_led = e1000e_cleanup_led_generic, .clear_hw_cntrs = e1000_clear_hw_cntrs_80003es2lan, - .get_bus_info = e1000_get_bus_info_pcie, + .get_bus_info = e1000e_get_bus_info_pcie, .get_link_up_info = e1000_get_link_up_info_80003es2lan, - .led_on = e1000_led_on_generic, - .led_off = e1000_led_off_generic, - .mc_addr_list_update = e1000_mc_addr_list_update_generic, + .led_on = e1000e_led_on_generic, + .led_off = e1000e_led_off_generic, + .mc_addr_list_update = e1000e_mc_addr_list_update_generic, .reset_hw = e1000_reset_hw_80003es2lan, .init_hw = e1000_init_hw_80003es2lan, - .setup_link = e1000_setup_link, + .setup_link = e1000e_setup_link, /* setup_physical_interface dependent on media type */ }; static struct e1000_phy_operations es2_phy_ops = { .acquire_phy = e1000_acquire_phy_80003es2lan, - .check_reset_block = e1000_check_reset_block_generic, - .commit_phy = e1000_phy_sw_reset, + .check_reset_block = e1000e_check_reset_block_generic, + .commit_phy = e1000e_phy_sw_reset, .force_speed_duplex = e1000_phy_force_speed_duplex_80003es2lan, .get_cfg_done = e1000_get_cfg_done_80003es2lan, .get_cable_length = e1000_get_cable_length_80003es2lan, - .get_phy_info = e1000_get_phy_info_m88, + .get_phy_info = e1000e_get_phy_info_m88, .read_phy_reg = e1000_read_phy_reg_gg82563_80003es2lan, .release_phy = e1000_release_phy_80003es2lan, - .reset_phy = e1000_phy_hw_reset_generic, + .reset_phy = e1000e_phy_hw_reset_generic, .set_d0_lplu_state = NULL, - .set_d3_lplu_state = e1000_set_d3_lplu_state, + .set_d3_lplu_state = e1000e_set_d3_lplu_state, .write_phy_reg = e1000_write_phy_reg_gg82563_80003es2lan, }; static struct e1000_nvm_operations es2_nvm_ops = { .acquire_nvm = e1000_acquire_nvm_80003es2lan, - .read_nvm = e1000_read_nvm_eerd, + .read_nvm = e1000e_read_nvm_eerd, .release_nvm = e1000_release_nvm_80003es2lan, - .update_nvm = e1000_update_nvm_checksum_generic, - .valid_led_default = e1000_valid_led_default, - .validate_nvm = e1000_validate_nvm_checksum_generic, + .update_nvm = e1000e_update_nvm_checksum_generic, + .valid_led_default = e1000e_valid_led_default, + .validate_nvm = e1000e_validate_nvm_checksum_generic, .write_nvm = e1000_write_nvm_80003es2lan, }; diff --git a/drivers/net/e1000e/ethtool.c b/drivers/net/e1000e/ethtool.c index 9de9dba..fa6ff37 100644 --- a/drivers/net/e1000e/ethtool.c +++ b/drivers/net/e1000e/ethtool.c @@ -29,8 +29,9 @@ /* ethtool support for e1000 */ #include <linux/netdevice.h> - #include <linux/ethtool.h> +#include <linux/pci.h> +#include <linux/delay.h> #include "e1000.h" @@ -90,23 +91,25 @@ static const struct e1000_stats e1000_gstrings_stats[] = { { "tx_smbus", E1000_STAT(stats.mgptc) }, { "rx_smbus", E1000_STAT(stats.mgprc) }, { "dropped_smbus", E1000_STAT(stats.mgpdc) }, + { "rx_dma_failed", E1000_STAT(rx_dma_failed) }, + { "tx_dma_failed", E1000_STAT(tx_dma_failed) }, }; -#define E1000_GLOBAL_STATS_LEN \ - sizeof(e1000_gstrings_stats) / sizeof(struct e1000_stats) +#define E1000_GLOBAL_STATS_LEN ARRAY_SIZE(e1000_gstrings_stats) #define E1000_STATS_LEN (E1000_GLOBAL_STATS_LEN) static const char e1000_gstrings_test[][ETH_GSTRING_LEN] = { "Register test (offline)", "Eeprom test (offline)", "Interrupt test (offline)", "Loopback test (offline)", "Link test (on/offline)" }; -#define E1000_TEST_LEN sizeof(e1000_gstrings_test) / ETH_GSTRING_LEN +#define E1000_TEST_LEN ARRAY_SIZE(e1000_gstrings_test) static int e1000_get_settings(struct net_device *netdev, struct ethtool_cmd *ecmd) { struct e1000_adapter *adapter = netdev_priv(netdev); struct e1000_hw *hw = &adapter->hw; + u32 status; if (hw->media_type == e1000_media_type_copper) { @@ -144,16 +147,16 @@ static int e1000_get_settings(struct net_device *netdev, ecmd->transceiver = XCVR_EXTERNAL; } - if (er32(STATUS) & E1000_STATUS_LU) { - - adapter->hw.mac.ops.get_link_up_info(hw, &adapter->link_speed, - &adapter->link_duplex); - ecmd->speed = adapter->link_speed; - - /* unfortunately FULL_DUPLEX != DUPLEX_FULL - * and HALF_DUPLEX != DUPLEX_HALF */ + status = er32(STATUS); + if (status & E1000_STATUS_LU) { + if (status & E1000_STATUS_SPEED_1000) + ecmd->speed = 1000; + else if (status & E1000_STATUS_SPEED_100) + ecmd->speed = 100; + else + ecmd->speed = 10; - if (adapter->link_duplex == FULL_DUPLEX) + if (status & E1000_STATUS_FD) ecmd->duplex = DUPLEX_FULL; else ecmd->duplex = DUPLEX_HALF; @@ -167,6 +170,16 @@ static int e1000_get_settings(struct net_device *netdev, return 0; } +static u32 e1000_get_link(struct net_device *netdev) +{ + struct e1000_adapter *adapter = netdev_priv(netdev); + struct e1000_hw *hw = &adapter->hw; + u32 status; + + status = er32(STATUS); + return (status & E1000_STATUS_LU); +} + static int e1000_set_spd_dplx(struct e1000_adapter *adapter, u16 spddplx) { struct e1000_mac_info *mac = &adapter->hw.mac; @@ -245,10 +258,10 @@ static int e1000_set_settings(struct net_device *netdev, /* reset the link */ if (netif_running(adapter->netdev)) { - e1000_down(adapter); - e1000_up(adapter); + e1000e_down(adapter); + e1000e_up(adapter); } else { - e1000_reset(adapter); + e1000e_reset(adapter); } clear_bit(__E1000_RESETTING, &adapter->state); @@ -298,15 +311,16 @@ static int e1000_set_pauseparam(struct net_device *netdev, hw->mac.original_fc = hw->mac.fc; if (adapter->fc_autoneg == AUTONEG_ENABLE) { + hw->mac.fc = e1000_fc_default; if (netif_running(adapter->netdev)) { - e1000_down(adapter); - e1000_up(adapter); + e1000e_down(adapter); + e1000e_up(adapter); } else { - e1000_reset(adapter); + e1000e_reset(adapter); } } else { retval = ((hw->media_type == e1000_media_type_fiber) ? - hw->mac.ops.setup_link(hw) : e1000_force_mac_fc(hw)); + hw->mac.ops.setup_link(hw) : e1000e_force_mac_fc(hw)); } clear_bit(__E1000_RESETTING, &adapter->state); @@ -329,9 +343,9 @@ static int e1000_set_rx_csum(struct net_device *netdev, u32 data) adapter->flags &= ~FLAG_RX_CSUM_ENABLED; if (netif_running(netdev)) - e1000_reinit_locked(adapter); + e1000e_reinit_locked(adapter); else - e1000_reset(adapter); + e1000e_reset(adapter); return 0; } @@ -548,7 +562,7 @@ static int e1000_set_eeprom(struct net_device *netdev, * and flush shadow RAM for 82573 controllers */ if ((ret_val == 0) && ((first_word <= NVM_CHECKSUM_REG) || (hw->mac.type == e1000_82573))) - e1000_update_nvm_checksum(hw); + e1000e_update_nvm_checksum(hw); kfree(eeprom_buff); return ret_val; @@ -561,8 +575,8 @@ static void e1000_get_drvinfo(struct net_device *netdev, char firmware_version[32]; u16 eeprom_data; - strncpy(drvinfo->driver, e1000_driver_name, 32); - strncpy(drvinfo->version, e1000_driver_version, 32); + strncpy(drvinfo->driver, e1000e_driver_name, 32); + strncpy(drvinfo->version, e1000e_driver_version, 32); /* EEPROM image version # is reported as firmware version # for * PCI-E controllers */ @@ -574,8 +588,6 @@ static void e1000_get_drvinfo(struct net_device *netdev, strncpy(drvinfo->fw_version, firmware_version, 32); strncpy(drvinfo->bus_info, pci_name(adapter->pdev), 32); - drvinfo->n_stats = E1000_STATS_LEN; - drvinfo->testinfo_len = E1000_TEST_LEN; drvinfo->regdump_len = e1000_get_regs_len(netdev); drvinfo->eedump_len = e1000_get_eeprom_len(netdev); } @@ -612,7 +624,7 @@ static int e1000_set_ringparam(struct net_device *netdev, msleep(1); if (netif_running(adapter->netdev)) - e1000_down(adapter); + e1000e_down(adapter); tx_old = adapter->tx_ring; rx_old = adapter->rx_ring; @@ -639,10 +651,10 @@ static int e1000_set_ringparam(struct net_device *netdev, if (netif_running(adapter->netdev)) { /* Try to get new resources before deleting old */ - err = e1000_setup_rx_resources(adapter); + err = e1000e_setup_rx_resources(adapter); if (err) goto err_setup_rx; - err = e1000_setup_tx_resources(adapter); + err = e1000e_setup_tx_resources(adapter); if (err) goto err_setup_tx; @@ -650,13 +662,13 @@ static int e1000_set_ringparam(struct net_device *netdev, * then restore the new back again */ adapter->rx_ring = rx_old; adapter->tx_ring = tx_old; - e1000_free_rx_resources(adapter); - e1000_free_tx_resources(adapter); + e1000e_free_rx_resources(adapter); + e1000e_free_tx_resources(adapter); kfree(tx_old); kfree(rx_old); adapter->rx_ring = rx_ring; adapter->tx_ring = tx_ring; - err = e1000_up(adapter); + err = e1000e_up(adapter); if (err) goto err_setup; } @@ -664,7 +676,7 @@ static int e1000_set_ringparam(struct net_device *netdev, clear_bit(__E1000_RESETTING, &adapter->state); return 0; err_setup_tx: - e1000_free_rx_resources(adapter); + e1000e_free_rx_resources(adapter); err_setup_rx: adapter->rx_ring = rx_old; adapter->tx_ring = tx_old; @@ -672,47 +684,69 @@ err_setup_rx: err_alloc_rx: kfree(tx_ring); err_alloc_tx: - e1000_up(adapter); + e1000e_up(adapter); err_setup: clear_bit(__E1000_RESETTING, &adapter->state); return err; } -#define REG_PATTERN_TEST(R, M, W) REG_PATTERN_TEST_ARRAY(R, 0, M, W) -#define REG_PATTERN_TEST_ARRAY(reg, offset, mask, writeable) \ -{ \ - u32 _pat; \ - u32 _value; \ - u32 _test[] = {0x5A5A5A5A, 0xA5A5A5A5, 0x00000000, 0xFFFFFFFF}; \ - for (_pat = 0; _pat < ARRAY_SIZE(_test); _pat++) { \ - E1000_WRITE_REG_ARRAY(hw, reg, offset, \ - (_test[_pat] & writeable)); \ - _value = E1000_READ_REG_ARRAY(hw, reg, offset); \ - if (_value != (_test[_pat] & writeable & mask)) { \ - ndev_err(netdev, "pattern test reg %04X " \ - "failed: got 0x%08X expected 0x%08X\n", \ - reg + offset, \ - value, (_test[_pat] & writeable & mask)); \ - *data = reg; \ - return 1; \ - } \ - } \ +int reg_pattern_test_array(struct e1000_adapter *adapter, u64 *data, + int reg, int offset, u32 mask, u32 write) +{ + int i; + u32 read; + static const u32 test[] = + {0x5A5A5A5A, 0xA5A5A5A5, 0x00000000, 0xFFFFFFFF}; + for (i = 0; i < ARRAY_SIZE(test); i++) { + E1000_WRITE_REG_ARRAY(&adapter->hw, reg, offset, + (test[i] & write)); + read = E1000_READ_REG_ARRAY(&adapter->hw, reg, offset); + if (read != (test[i] & write & mask)) { + ndev_err(adapter->netdev, "pattern test reg %04X " + "failed: got 0x%08X expected 0x%08X\n", + reg + offset, + read, (test[i] & write & mask)); + *data = reg; + return 1; + } + } + return 0; } -#define REG_SET_AND_CHECK(R, M, W) \ -{ \ - u32 _value; \ - __ew32(hw, R, W & M); \ - _value = __er32(hw, R); \ - if ((W & M) != (_value & M)) { \ - ndev_err(netdev, "set/check reg %04X test failed: " \ - "got 0x%08X expected 0x%08X\n", R, (_value & M), \ - (W & M)); \ - *data = R; \ - return 1; \ - } \ +static int reg_set_and_check(struct e1000_adapter *adapter, u64 *data, + int reg, u32 mask, u32 write) +{ + u32 read; + __ew32(&adapter->hw, reg, write & mask); + read = __er32(&adapter->hw, reg); + if ((write & mask) != (read & mask)) { + ndev_err(adapter->netdev, "set/check reg %04X test failed: " + "got 0x%08X expected 0x%08X\n", reg, (read & mask), + (write & mask)); + *data = reg; + return 1; + } + return 0; } +#define REG_PATTERN_TEST(R, M, W) \ + do { \ + if (reg_pattern_test_array(adapter, data, R, 0, M, W)) \ + return 1; \ + } while (0) + +#define REG_PATTERN_TEST_ARRAY(R, offset, M, W) \ + do { \ + if (reg_pattern_test_array(adapter, data, R, offset, M, W)) \ + return 1; \ + } while (0) + +#define REG_SET_AND_CHECK(R, M, W) \ + do { \ + if (reg_set_and_check(adapter, data, R, M, W)) \ + return 1; \ + } while (0) + static int e1000_reg_test(struct e1000_adapter *adapter, u64 *data) { struct e1000_hw *hw = &adapter->hw; @@ -783,10 +817,16 @@ static int e1000_reg_test(struct e1000_adapter *adapter, u64 *data) REG_SET_AND_CHECK(E1000_RCTL, before, 0x003FFFFB); REG_SET_AND_CHECK(E1000_TCTL, 0xFFFFFFFF, 0x00000000); - REG_SET_AND_CHECK(E1000_RCTL, 0xFFFFFFFF, 0x01FFFFFF); - REG_PATTERN_TEST(E1000_RDBAL, 0xFFFFF000, 0xFFFFFFFF); - REG_PATTERN_TEST(E1000_TXCW, 0x0000FFFF, 0x0000FFFF); - REG_PATTERN_TEST(E1000_TDBAL, 0xFFFFF000, 0xFFFFFFFF); + REG_SET_AND_CHECK(E1000_RCTL, before, 0xFFFFFFFF); + REG_PATTERN_TEST(E1000_RDBAL, 0xFFFFFFF0, 0xFFFFFFFF); + if ((mac->type != e1000_ich8lan) && + (mac->type != e1000_ich9lan)) + REG_PATTERN_TEST(E1000_TXCW, 0xC000FFFF, 0x0000FFFF); + REG_PATTERN_TEST(E1000_TDBAL, 0xFFFFFFF0, 0xFFFFFFFF); + REG_PATTERN_TEST(E1000_TIDV, 0x0000FFFF, 0x0000FFFF); + for (i = 0; i < mac->rar_entry_count; i++) + REG_PATTERN_TEST_ARRAY(E1000_RA, ((i << 1) + 1), + 0x8003FFFF, 0xFFFFFFFF); for (i = 0; i < mac->mta_reg_count; i++) REG_PATTERN_TEST_ARRAY(E1000_MTA, i, 0xFFFFFFFF, 0xFFFFFFFF); @@ -961,13 +1001,13 @@ static void e1000_free_desc_rings(struct e1000_adapter *adapter) } if (tx_ring->desc) { - pci_free_consistent(pdev, tx_ring->size, tx_ring->desc, - tx_ring->dma); + dma_free_coherent(&pdev->dev, tx_ring->size, tx_ring->desc, + tx_ring->dma); tx_ring->desc = NULL; } if (rx_ring->desc) { - pci_free_consistent(pdev, rx_ring->size, rx_ring->desc, - rx_ring->dma); + dma_free_coherent(&pdev->dev, rx_ring->size, rx_ring->desc, + rx_ring->dma); rx_ring->desc = NULL; } @@ -1003,8 +1043,8 @@ static int e1000_setup_desc_rings(struct e1000_adapter *adapter) 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); + tx_ring->desc = dma_alloc_coherent(&pdev->dev, tx_ring->size, + &tx_ring->dma, GFP_KERNEL); if (!tx_ring->desc) { ret_val = 2; goto err_nomem; @@ -1041,6 +1081,10 @@ static int e1000_setup_desc_rings(struct e1000_adapter *adapter) tx_ring->buffer_info[i].dma = pci_map_single(pdev, skb->data, skb->len, PCI_DMA_TODEVICE); + if (pci_dma_mapping_error(tx_ring->buffer_info[i].dma)) { + ret_val = 4; + goto err_nomem; + } tx_desc->buffer_addr = cpu_to_le64( tx_ring->buffer_info[i].dma); tx_desc->lower.data = cpu_to_le32(skb->len); @@ -1058,16 +1102,16 @@ static int e1000_setup_desc_rings(struct e1000_adapter *adapter) size = rx_ring->count * sizeof(struct e1000_buffer); rx_ring->buffer_info = kmalloc(size, GFP_KERNEL); if (!rx_ring->buffer_info) { - ret_val = 4; + ret_val = 5; goto err_nomem; } memset(rx_ring->buffer_info, 0, size); rx_ring->size = rx_ring->count * sizeof(struct e1000_rx_desc); - rx_ring->desc = pci_alloc_consistent(pdev, rx_ring->size, - &rx_ring->dma); + rx_ring->desc = dma_alloc_coherent(&pdev->dev, rx_ring->size, + &rx_ring->dma, GFP_KERNEL); if (!rx_ring->desc) { - ret_val = 5; + ret_val = 6; goto err_nomem; } memset(rx_ring->desc, 0, rx_ring->size); @@ -1092,7 +1136,7 @@ static int e1000_setup_desc_rings(struct e1000_adapter *adapter) skb = alloc_skb(2048 + NET_IP_ALIGN, GFP_KERNEL); if (!skb) { - ret_val = 6; + ret_val = 7; goto err_nomem; } skb_reserve(skb, NET_IP_ALIGN); @@ -1100,6 +1144,10 @@ static int e1000_setup_desc_rings(struct e1000_adapter *adapter) rx_ring->buffer_info[i].dma = pci_map_single(pdev, skb->data, 2048, PCI_DMA_FROMDEVICE); + if (pci_dma_mapping_error(rx_ring->buffer_info[i].dma)) { + ret_val = 8; + goto err_nomem; + } rx_desc->buffer_addr = cpu_to_le64(rx_ring->buffer_info[i].dma); memset(skb->data, 0x00, skb->len); @@ -1325,7 +1373,7 @@ static void e1000_loopback_cleanup(struct e1000_adapter *adapter) if (phy_reg & MII_CR_LOOPBACK) { phy_reg &= ~MII_CR_LOOPBACK; e1e_wphy(hw, PHY_CONTROL, phy_reg); - e1000_commit_phy(hw); + e1000e_commit_phy(hw); } break; } @@ -1435,11 +1483,11 @@ static int e1000_loopback_test(struct e1000_adapter *adapter, u64 *data) } *data = e1000_setup_desc_rings(adapter); - if (data) + if (*data) goto out; *data = e1000_setup_loopback_test(adapter); - if (data) + if (*data) goto err_loopback; *data = e1000_run_loopback_test(adapter); @@ -1494,7 +1542,7 @@ static void e1000_diag_test(struct net_device *netdev, u16 autoneg_advertised; u8 forced_speed_duplex; u8 autoneg; - bool if_running = netif_running(netdev); + int if_running = netif_running(netdev); set_bit(__E1000_TESTING, &adapter->state); if (eth_test->flags == ETH_TEST_FL_OFFLINE) { @@ -1516,22 +1564,22 @@ static void e1000_diag_test(struct net_device *netdev, /* indicate we're in test mode */ dev_close(netdev); else - e1000_reset(adapter); + e1000e_reset(adapter); if (e1000_reg_test(adapter, &data[0])) eth_test->flags |= ETH_TEST_FL_FAILED; - e1000_reset(adapter); + e1000e_reset(adapter); if (e1000_eeprom_test(adapter, &data[1])) eth_test->flags |= ETH_TEST_FL_FAILED; - e1000_reset(adapter); + e1000e_reset(adapter); if (e1000_intr_test(adapter, &data[2])) eth_test->flags |= ETH_TEST_FL_FAILED; - e1000_reset(adapter); + e1000e_reset(adapter); /* make sure the phy is powered up */ - e1000_power_up_phy(adapter); + e1000e_power_up_phy(adapter); if (e1000_loopback_test(adapter, &data[3])) eth_test->flags |= ETH_TEST_FL_FAILED; @@ -1542,7 +1590,7 @@ static void e1000_diag_test(struct net_device *netdev, /* force this routine to wait until autoneg complete/timeout */ adapter->hw.phy.wait_for_link = 1; - e1000_reset(adapter); + e1000e_reset(adapter); adapter->hw.phy.wait_for_link = 0; clear_bit(__E1000_TESTING, &adapter->state); @@ -1646,8 +1694,8 @@ static int e1000_phys_id(struct net_device *netdev, u32 data) { struct e1000_adapter *adapter = netdev_priv(netdev); - if (!data || data > (u32)(MAX_SCHEDULE_TIMEOUT / HZ)) - data = (u32)(MAX_SCHEDULE_TIMEOUT / HZ); + if (!data) + data = INT_MAX; if (adapter->hw.phy.type == e1000_phy_ife) { if (!adapter->blink_timer.function) { @@ -1662,7 +1710,7 @@ static int e1000_phys_id(struct net_device *netdev, u32 data) e1e_wphy(&adapter->hw, IFE_PHY_SPECIAL_CONTROL_LED, 0); } else { - e1000_blink_led(&adapter->hw); + e1000e_blink_led(&adapter->hw); msleep_interruptible(data * 1000); } @@ -1677,7 +1725,7 @@ static int e1000_nway_reset(struct net_device *netdev) { struct e1000_adapter *adapter = netdev_priv(netdev); if (netif_running(netdev)) - e1000_reinit_locked(adapter); + e1000e_reinit_locked(adapter); return 0; } @@ -1693,7 +1741,7 @@ static void e1000_get_ethtool_stats(struct net_device *netdev, struct e1000_adapter *adapter = netdev_priv(netdev); int i; - e1000_update_stats(adapter); + e1000e_update_stats(adapter); for (i = 0; i < E1000_GLOBAL_STATS_LEN; i++) { char *p = (char *)adapter+e1000_gstrings_stats[i].stat_offset; data[i] = (e1000_gstrings_stats[i].sizeof_stat == @@ -1733,7 +1781,7 @@ static struct ethtool_ops e1000_ethtool_ops = { .get_msglevel = e1000_get_msglevel, .set_msglevel = e1000_set_msglevel, .nway_reset = e1000_nway_reset, - .get_link = ethtool_op_get_link, + .get_link = e1000_get_link, .get_eeprom_len = e1000_get_eeprom_len, .get_eeprom = e1000_get_eeprom, .set_eeprom = e1000_set_eeprom, @@ -1757,7 +1805,7 @@ static struct ethtool_ops e1000_ethtool_ops = { .get_ethtool_stats = e1000_get_ethtool_stats, }; -void e1000_set_ethtool_ops(struct net_device *netdev) +void e1000e_set_ethtool_ops(struct net_device *netdev) { SET_ETHTOOL_OPS(netdev, &e1000_ethtool_ops); } diff --git a/drivers/net/e1000e/hw.h b/drivers/net/e1000e/hw.h index fa3077b..71f93ce 100644 --- a/drivers/net/e1000e/hw.h +++ b/drivers/net/e1000e/hw.h @@ -29,6 +29,8 @@ #ifndef _E1000_HW_H_ #define _E1000_HW_H_ +#include <linux/types.h> + struct e1000_hw; struct e1000_adapter; @@ -301,8 +303,11 @@ enum e1e_registers { #define E1000_DEV_ID_82571EB_FIBER 0x105F #define E1000_DEV_ID_82571EB_SERDES 0x1060 #define E1000_DEV_ID_82571EB_QUAD_COPPER 0x10A4 +#define E1000_DEV_ID_82571PT_QUAD_COPPER 0x10D5 #define E1000_DEV_ID_82571EB_QUAD_FIBER 0x10A5 #define E1000_DEV_ID_82571EB_QUAD_COPPER_LP 0x10BC +#define E1000_DEV_ID_82571EB_SERDES_DUAL 0x10D9 +#define E1000_DEV_ID_82571EB_SERDES_QUAD 0x10DA #define E1000_DEV_ID_82572EI_COPPER 0x107D #define E1000_DEV_ID_82572EI_FIBER 0x107E #define E1000_DEV_ID_82572EI_SERDES 0x107F @@ -700,7 +705,7 @@ struct e1000_phy_operations { s32 (*read_phy_reg)(struct e1000_hw *, u32, u16 *); void (*release_phy)(struct e1000_hw *); s32 (*reset_phy)(struct e1000_hw *); - s32 (*set_d0_lplu_state)(struct e1000_hw *, bool x); + 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); }; @@ -814,6 +819,7 @@ struct e1000_bus_info { struct e1000_dev_spec_82571 { bool laa_is_present; + bool alt_mac_addr_is_present; }; struct e1000_shadow_ram { @@ -850,7 +856,7 @@ struct e1000_hw { #ifdef DEBUG #define hw_dbg(hw, format, arg...) \ - printk(KERN_DEBUG, "%s: " format, e1000_get_hw_dev_name(hw), ##arg); + printk(KERN_DEBUG "%s: " format, e1000e_get_hw_dev_name(hw), ##arg) #else static inline int __attribute__ ((format (printf, 2, 3))) hw_dbg(struct e1000_hw *hw, const char *format, ...) diff --git a/drivers/net/e1000e/ich8lan.c b/drivers/net/e1000e/ich8lan.c index 042abd4..8f8139d 100644 --- a/drivers/net/e1000e/ich8lan.c +++ b/drivers/net/e1000e/ich8lan.c @@ -40,6 +40,11 @@ * 82566MM Gigabit Network Connection */ +#include <linux/netdevice.h> +#include <linux/ethtool.h> +#include <linux/delay.h> +#include <linux/pci.h> + #include "e1000.h" #define ICH_FLASH_GFPREG 0x0000 @@ -194,10 +199,10 @@ static s32 e1000_init_phy_params_ich8lan(struct e1000_hw *hw) phy->reset_delay_us = 100; phy->id = 0; - while ((e1000_phy_unknown == e1000_get_phy_type_from_id(phy->id)) && + while ((e1000_phy_unknown == e1000e_get_phy_type_from_id(phy->id)) && (i++ < 100)) { msleep(1); - ret_val = e1000_get_phy_id(hw); + ret_val = e1000e_get_phy_id(hw); if (ret_val) return ret_val; } @@ -303,7 +308,7 @@ static s32 e1000_init_mac_params_ich8lan(struct e1000_adapter *adapter) /* Enable PCS Lock-loss workaround for ICH8 */ if (mac->type == e1000_ich8lan) - e1000_set_kmrn_lock_loss_workaround_ich8lan(hw, 1); + e1000e_set_kmrn_lock_loss_workaround_ich8lan(hw, 1); return 0; } @@ -415,7 +420,7 @@ static s32 e1000_phy_force_speed_duplex_ich8lan(struct e1000_hw *hw) bool link; if (phy->type != e1000_phy_ife) { - ret_val = e1000_phy_force_speed_duplex_igp(hw); + ret_val = e1000e_phy_force_speed_duplex_igp(hw); return ret_val; } @@ -423,7 +428,7 @@ static s32 e1000_phy_force_speed_duplex_ich8lan(struct e1000_hw *hw) if (ret_val) return ret_val; - e1000_phy_force_speed_duplex_setup(hw, &data); + e1000e_phy_force_speed_duplex_setup(hw, &data); ret_val = e1e_wphy(hw, PHY_CONTROL, data); if (ret_val) @@ -448,7 +453,7 @@ static s32 e1000_phy_force_speed_duplex_ich8lan(struct e1000_hw *hw) if (phy->wait_for_link) { hw_dbg(hw, "Waiting for forced speed/duplex link on IFE phy.\n"); - ret_val = e1000_phy_has_link_generic(hw, + ret_val = e1000e_phy_has_link_generic(hw, PHY_FORCE_LIMIT, 100000, &link); @@ -459,7 +464,7 @@ static s32 e1000_phy_force_speed_duplex_ich8lan(struct e1000_hw *hw) hw_dbg(hw, "Link taking longer than expected.\n"); /* Try once more */ - ret_val = e1000_phy_has_link_generic(hw, + ret_val = e1000e_phy_has_link_generic(hw, PHY_FORCE_LIMIT, 100000, &link); @@ -487,7 +492,7 @@ static s32 e1000_phy_hw_reset_ich8lan(struct e1000_hw *hw) u16 loop = E1000_ICH8_LAN_INIT_TIMEOUT; u16 word_addr, reg_data, reg_addr, phy_page = 0; - ret_val = e1000_phy_hw_reset_generic(hw); + ret_val = e1000e_phy_hw_reset_generic(hw); if (ret_val) return ret_val; @@ -599,7 +604,7 @@ static s32 e1000_get_phy_info_ife_ich8lan(struct e1000_hw *hw) u16 data; bool link; - ret_val = e1000_phy_has_link_generic(hw, 1, 0, &link); + ret_val = e1000e_phy_has_link_generic(hw, 1, 0, &link); if (ret_val) return ret_val; @@ -653,7 +658,7 @@ static s32 e1000_get_phy_info_ich8lan(struct e1000_hw *hw) return e1000_get_phy_info_ife_ich8lan(hw); break; case e1000_phy_igp_3: - return e1000_get_phy_info_igp(hw); + return e1000e_get_phy_info_igp(hw); break; default: break; @@ -730,7 +735,7 @@ static s32 e1000_set_d0_lplu_state_ich8lan(struct e1000_hw *hw, bool active) * any PHY registers */ if ((hw->mac.type == e1000_ich8lan) && (hw->phy.type == e1000_phy_igp_3)) - e1000_gig_downshift_workaround_ich8lan(hw); + e1000e_gig_downshift_workaround_ich8lan(hw); /* When LPLU is enabled, we should disable SmartSpeed */ ret_val = e1e_rphy(hw, IGP01E1000_PHY_PORT_CONFIG, &data); @@ -840,7 +845,7 @@ static s32 e1000_set_d3_lplu_state_ich8lan(struct e1000_hw *hw, bool active) * any PHY registers */ if ((hw->mac.type == e1000_ich8lan) && (hw->phy.type == e1000_phy_igp_3)) - e1000_gig_downshift_workaround_ich8lan(hw); + e1000e_gig_downshift_workaround_ich8lan(hw); /* When LPLU is enabled, we should disable SmartSpeed */ ret_val = e1e_rphy(hw, @@ -1161,7 +1166,7 @@ static s32 e1000_update_nvm_checksum_ich8lan(struct e1000_hw *hw) s32 ret_val; u16 data; - ret_val = e1000_update_nvm_checksum_generic(hw); + ret_val = e1000e_update_nvm_checksum_generic(hw); if (ret_val) return ret_val;; @@ -1270,7 +1275,7 @@ static s32 e1000_update_nvm_checksum_ich8lan(struct e1000_hw *hw) /* Reload the EEPROM, or else modifications will not appear * until after the next adapter reset. */ - e1000_reload_nvm(hw); + e1000e_reload_nvm(hw); msleep(10); return ret_val; @@ -1303,12 +1308,12 @@ static s32 e1000_validate_nvm_checksum_ich8lan(struct e1000_hw *hw) ret_val = e1000_write_nvm(hw, 0x19, 1, &data); if (ret_val) return ret_val; - ret_val = e1000_update_nvm_checksum(hw); + ret_val = e1000e_update_nvm_checksum(hw); if (ret_val) return ret_val; } - return e1000_validate_nvm_checksum_generic(hw); + return e1000e_validate_nvm_checksum_generic(hw); } /** @@ -1578,7 +1583,7 @@ static s32 e1000_get_bus_info_ich8lan(struct e1000_hw *hw) struct e1000_bus_info *bus = &hw->bus; s32 ret_val; - ret_val = e1000_get_bus_info_pcie(hw); + ret_val = e1000e_get_bus_info_pcie(hw); /* ICH devices are "PCI Express"-ish. They have * a configuration space, but do not contain @@ -1606,7 +1611,7 @@ static s32 e1000_reset_hw_ich8lan(struct e1000_hw *hw) /* 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 = e1000_disable_pcie_master(hw); + ret_val = e1000e_disable_pcie_master(hw); if (ret_val) { hw_dbg(hw, "PCI-E Master disable polling has failed.\n"); } @@ -1646,7 +1651,7 @@ static s32 e1000_reset_hw_ich8lan(struct e1000_hw *hw) ew32(CTRL, (ctrl | E1000_CTRL_RST)); msleep(20); - ret_val = e1000_get_auto_rd_done(hw); + ret_val = e1000e_get_auto_rd_done(hw); if (ret_val) { /* * When auto config read does not complete, do not @@ -1688,14 +1693,14 @@ static s32 e1000_init_hw_ich8lan(struct e1000_hw *hw) e1000_initialize_hw_bits_ich8lan(hw); /* Initialize identification LED */ - ret_val = e1000_id_led_init(hw); + ret_val = e1000e_id_led_init(hw); if (ret_val) { hw_dbg(hw, "Error initializing identification LED\n"); return ret_val; } /* Setup the receive address. */ - e1000_init_rx_addrs(hw, mac->rar_entry_count); + e1000e_init_rx_addrs(hw, mac->rar_entry_count); /* Zero out the Multicast HASH table */ hw_dbg(hw, "Zeroing the MTA\n"); @@ -1725,7 +1730,7 @@ static s32 e1000_init_hw_ich8lan(struct e1000_hw *hw) snoop = PCIE_ICH8_SNOOP_ALL; else snoop = (u32) ~(PCIE_NO_SNOOP_ALL); - e1000_set_pcie_no_snoop(hw, snoop); + e1000e_set_pcie_no_snoop(hw, snoop); ctrl_ext = er32(CTRL_EXT); ctrl_ext |= E1000_CTRL_EXT_RO_DIS; @@ -1826,7 +1831,7 @@ static s32 e1000_setup_link_ich8lan(struct e1000_hw *hw) ew32(FCTTV, mac->fc_pause_time); - return e1000_set_fc_watermarks(hw); + return e1000e_set_fc_watermarks(hw); } /** @@ -1851,24 +1856,24 @@ static s32 e1000_setup_copper_link_ich8lan(struct e1000_hw *hw) /* Set the mac to wait the maximum time between each iteration * and increase the max iterations when polling the phy; * this fixes erroneous timeouts at 10Mbps. */ - ret_val = e1000_write_kmrn_reg(hw, GG82563_REG(0x34, 4), 0xFFFF); + ret_val = e1000e_write_kmrn_reg(hw, GG82563_REG(0x34, 4), 0xFFFF); if (ret_val) return ret_val; - ret_val = e1000_read_kmrn_reg(hw, GG82563_REG(0x34, 9), ®_data); + ret_val = e1000e_read_kmrn_reg(hw, GG82563_REG(0x34, 9), ®_data); if (ret_val) return ret_val; reg_data |= 0x3F; - ret_val = e1000_write_kmrn_reg(hw, GG82563_REG(0x34, 9), reg_data); + ret_val = e1000e_write_kmrn_reg(hw, GG82563_REG(0x34, 9), reg_data); if (ret_val) return ret_val; if (hw->phy.type == e1000_phy_igp_3) { - ret_val = e1000_copper_link_setup_igp(hw); + ret_val = e1000e_copper_link_setup_igp(hw); if (ret_val) return ret_val; } - return e1000_setup_copper_link(hw); + return e1000e_setup_copper_link(hw); } /** @@ -1886,7 +1891,7 @@ static s32 e1000_get_link_up_info_ich8lan(struct e1000_hw *hw, u16 *speed, { s32 ret_val; - ret_val = e1000_get_speed_and_duplex_copper(hw, speed, duplex); + ret_val = e1000e_get_speed_and_duplex_copper(hw, speed, duplex); if (ret_val) return ret_val; @@ -1928,7 +1933,7 @@ static s32 e1000_kmrn_lock_loss_workaround_ich8lan(struct e1000_hw *hw) /* Make sure link is up before proceeding. If not just return. * Attempting this while link is negotiating fouled up link * stability */ - ret_val = e1000_phy_has_link_generic(hw, 1, 0, &link); + ret_val = e1000e_phy_has_link_generic(hw, 1, 0, &link); if (!link) return 0; @@ -1958,7 +1963,7 @@ static s32 e1000_kmrn_lock_loss_workaround_ich8lan(struct e1000_hw *hw) /* Call gig speed drop workaround on Giga disable before accessing * any PHY registers */ - e1000_gig_downshift_workaround_ich8lan(hw); + e1000e_gig_downshift_workaround_ich8lan(hw); /* unable to acquire PCS lock */ return -E1000_ERR_PHY; @@ -1972,7 +1977,7 @@ static s32 e1000_kmrn_lock_loss_workaround_ich8lan(struct e1000_hw *hw) * If ICH8, set the current Kumeran workaround state (enabled - TRUE * /disabled - FALSE). **/ -void e1000_set_kmrn_lock_loss_workaround_ich8lan(struct e1000_hw *hw, +void e1000e_set_kmrn_lock_loss_workaround_ich8lan(struct e1000_hw *hw, bool state) { struct e1000_dev_spec_ich8lan *dev_spec = &hw->dev_spec.ich8lan; @@ -1995,7 +2000,7 @@ void e1000_set_kmrn_lock_loss_workaround_ich8lan(struct e1000_hw *hw, * 3) read it back * Continue if successful, else issue LCD reset and repeat **/ -void e1000_igp3_phy_powerdown_workaround_ich8lan(struct e1000_hw *hw) +void e1000e_igp3_phy_powerdown_workaround_ich8lan(struct e1000_hw *hw) { u32 reg; u16 data; @@ -2015,7 +2020,7 @@ void e1000_igp3_phy_powerdown_workaround_ich8lan(struct e1000_hw *hw) /* Call gig speed drop workaround on Giga disable before * accessing any PHY registers */ if (hw->mac.type == e1000_ich8lan) - e1000_gig_downshift_workaround_ich8lan(hw); + e1000e_gig_downshift_workaround_ich8lan(hw); /* Write VR power-down enable */ e1e_rphy(hw, IGP3_VR_CTRL, &data); @@ -2036,7 +2041,7 @@ void e1000_igp3_phy_powerdown_workaround_ich8lan(struct e1000_hw *hw) } /** - * e1000_gig_downshift_workaround_ich8lan - WoL from S5 stops working + * e1000e_gig_downshift_workaround_ich8lan - WoL from S5 stops working * @hw: pointer to the HW structure * * Steps to take when dropping from 1Gb/s (eg. link cable removal (LSC), @@ -2045,7 +2050,7 @@ void e1000_igp3_phy_powerdown_workaround_ich8lan(struct e1000_hw *hw) * 2) Clear Kumeran Near-end loopback * Should only be called for ICH8[m] devices with IGP_3 Phy. **/ -void e1000_gig_downshift_workaround_ich8lan(struct e1000_hw *hw) +void e1000e_gig_downshift_workaround_ich8lan(struct e1000_hw *hw) { s32 ret_val; u16 reg_data; @@ -2054,17 +2059,17 @@ void e1000_gig_downshift_workaround_ich8lan(struct e1000_hw *hw) (hw->phy.type != e1000_phy_igp_3)) return; - ret_val = e1000_read_kmrn_reg(hw, E1000_KMRNCTRLSTA_DIAG_OFFSET, + ret_val = e1000e_read_kmrn_reg(hw, E1000_KMRNCTRLSTA_DIAG_OFFSET, ®_data); if (ret_val) return; reg_data |= E1000_KMRNCTRLSTA_DIAG_NELPBK; - ret_val = e1000_write_kmrn_reg(hw, E1000_KMRNCTRLSTA_DIAG_OFFSET, + ret_val = e1000e_write_kmrn_reg(hw, E1000_KMRNCTRLSTA_DIAG_OFFSET, reg_data); if (ret_val) return; reg_data &= ~E1000_KMRNCTRLSTA_DIAG_NELPBK; - ret_val = e1000_write_kmrn_reg(hw, E1000_KMRNCTRLSTA_DIAG_OFFSET, + ret_val = e1000e_write_kmrn_reg(hw, E1000_KMRNCTRLSTA_DIAG_OFFSET, reg_data); } @@ -2126,7 +2131,7 @@ static void e1000_clear_hw_cntrs_ich8lan(struct e1000_hw *hw) { u32 temp; - e1000_clear_hw_cntrs_base(hw); + e1000e_clear_hw_cntrs_base(hw); temp = er32(ALGNERRC); temp = er32(RXERRC); @@ -2146,14 +2151,14 @@ static void e1000_clear_hw_cntrs_ich8lan(struct e1000_hw *hw) static struct e1000_mac_operations ich8_mac_ops = { .mng_mode_enab = E1000_ICH_MNG_IAMT_MODE << E1000_FWSM_MODE_SHIFT, - .check_for_link = e1000_check_for_copper_link, + .check_for_link = e1000e_check_for_copper_link, .cleanup_led = e1000_cleanup_led_ich8lan, .clear_hw_cntrs = e1000_clear_hw_cntrs_ich8lan, .get_bus_info = e1000_get_bus_info_ich8lan, .get_link_up_info = e1000_get_link_up_info_ich8lan, .led_on = e1000_led_on_ich8lan, .led_off = e1000_led_off_ich8lan, - .mc_addr_list_update = e1000_mc_addr_list_update_generic, + .mc_addr_list_update = e1000e_mc_addr_list_update_generic, .reset_hw = e1000_reset_hw_ich8lan, .init_hw = e1000_init_hw_ich8lan, .setup_link = e1000_setup_link_ich8lan, @@ -2165,15 +2170,15 @@ static struct e1000_phy_operations ich8_phy_ops = { .check_reset_block = e1000_check_reset_block_ich8lan, .commit_phy = NULL, .force_speed_duplex = e1000_phy_force_speed_duplex_ich8lan, - .get_cfg_done = e1000_get_cfg_done, - .get_cable_length = e1000_get_cable_length_igp_2, + .get_cfg_done = e1000e_get_cfg_done, + .get_cable_length = e1000e_get_cable_length_igp_2, .get_phy_info = e1000_get_phy_info_ich8lan, - .read_phy_reg = e1000_read_phy_reg_igp, + .read_phy_reg = e1000e_read_phy_reg_igp, .release_phy = e1000_release_swflag_ich8lan, .reset_phy = e1000_phy_hw_reset_ich8lan, .set_d0_lplu_state = e1000_set_d0_lplu_state_ich8lan, .set_d3_lplu_state = e1000_set_d3_lplu_state_ich8lan, - .write_phy_reg = e1000_write_phy_reg_igp, + .write_phy_reg = e1000e_write_phy_reg_igp, }; static struct e1000_nvm_operations ich8_nvm_ops = { diff --git a/drivers/net/e1000e/lib.c b/drivers/net/e1000e/lib.c index 3bbe63e..16f35fa 100644 --- a/drivers/net/e1000e/lib.c +++ b/drivers/net/e1000e/lib.c @@ -27,6 +27,8 @@ *******************************************************************************/ #include <linux/netdevice.h> +#include <linux/ethtool.h> +#include <linux/delay.h> #include <linux/pci.h> #include "e1000.h" @@ -45,14 +47,14 @@ enum e1000_mng_mode { * Technology signature */ /** - * e1000_get_bus_info_pcie - Get PCIe bus information + * e1000e_get_bus_info_pcie - 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 e1000_get_bus_info_pcie(struct e1000_hw *hw) +s32 e1000e_get_bus_info_pcie(struct e1000_hw *hw) { struct e1000_bus_info *bus = &hw->bus; struct e1000_adapter *adapter = hw->adapter; @@ -85,7 +87,7 @@ s32 e1000_get_bus_info_pcie(struct e1000_hw *hw) } /** - * e1000_write_vfta - Write value to VLAN filter table + * e1000e_write_vfta - 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 @@ -93,14 +95,14 @@ s32 e1000_get_bus_info_pcie(struct e1000_hw *hw) * Writes value at the given offset in the register array which stores * the VLAN filter table. **/ -void e1000_write_vfta(struct e1000_hw *hw, u32 offset, u32 value) +void e1000e_write_vfta(struct e1000_hw *hw, u32 offset, u32 value) { E1000_WRITE_REG_ARRAY(hw, E1000_VFTA, offset, value); e1e_flush(); } /** - * e1000_init_rx_addrs - Initialize receive address's + * e1000e_init_rx_addrs - Initialize receive address's * @hw: pointer to the HW structure * @rar_count: receive address registers * @@ -108,14 +110,14 @@ void e1000_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 e1000_init_rx_addrs(struct e1000_hw *hw, u16 rar_count) +void e1000e_init_rx_addrs(struct e1000_hw *hw, u16 rar_count) { u32 i; /* Setup the receive address */ hw_dbg(hw, "Programming MAC Address into RAR[0]\n"); - e1000_rar_set(hw, hw->mac.addr, 0); + e1000e_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); @@ -128,7 +130,7 @@ void e1000_init_rx_addrs(struct e1000_hw *hw, u16 rar_count) } /** - * e1000_rar_set - Set receive address register + * e1000e_rar_set - Set receive address register * @hw: pointer to the HW structure * @addr: pointer to the receive address * @index: receive address array register @@ -136,7 +138,7 @@ void e1000_init_rx_addrs(struct e1000_hw *hw, u16 rar_count) * Sets the receive address array register at index to the address passed * in by addr. **/ -void e1000_rar_set(struct e1000_hw *hw, u8 *addr, u32 index) +void e1000e_rar_set(struct e1000_hw *hw, u8 *addr, u32 index) { u32 rar_low, rar_high; @@ -258,7 +260,7 @@ static u32 e1000_hash_mc_addr(struct e1000_hw *hw, u8 *mc_addr) } /** - * e1000_mc_addr_list_update_generic - Update Multicast addresses + * e1000e_mc_addr_list_update_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 @@ -270,7 +272,7 @@ static u32 e1000_hash_mc_addr(struct e1000_hw *hw, u8 *mc_addr) * The parameter rar_count will usually be hw->mac.rar_entry_count * unless there are workarounds that change this. **/ -void e1000_mc_addr_list_update_generic(struct e1000_hw *hw, +void e1000e_mc_addr_list_update_generic(struct e1000_hw *hw, u8 *mc_addr_list, u32 mc_addr_count, u32 rar_used_count, u32 rar_count) { @@ -283,7 +285,7 @@ void e1000_mc_addr_list_update_generic(struct e1000_hw *hw, */ for (i = rar_used_count; i < rar_count; i++) { if (mc_addr_count) { - e1000_rar_set(hw, mc_addr_list, i); + e1000e_rar_set(hw, mc_addr_list, i); mc_addr_count--; mc_addr_list += ETH_ALEN; } else { @@ -311,12 +313,12 @@ void e1000_mc_addr_list_update_generic(struct e1000_hw *hw, } /** - * e1000_clear_hw_cntrs_base - Clear base hardware counters + * e1000e_clear_hw_cntrs_base - Clear base hardware counters * @hw: pointer to the HW structure * * Clears the base hardware counters by reading the counter registers. **/ -void e1000_clear_hw_cntrs_base(struct e1000_hw *hw) +void e1000e_clear_hw_cntrs_base(struct e1000_hw *hw) { u32 temp; @@ -360,14 +362,14 @@ void e1000_clear_hw_cntrs_base(struct e1000_hw *hw) } /** - * e1000_check_for_copper_link - Check for link (Copper) + * e1000e_check_for_copper_link - 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 e1000_check_for_copper_link(struct e1000_hw *hw) +s32 e1000e_check_for_copper_link(struct e1000_hw *hw) { struct e1000_mac_info *mac = &hw->mac; s32 ret_val; @@ -385,7 +387,7 @@ s32 e1000_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 = e1000_phy_has_link_generic(hw, 1, 0, &link); + ret_val = e1000e_phy_has_link_generic(hw, 1, 0, &link); if (ret_val) return ret_val; @@ -396,7 +398,7 @@ s32 e1000_check_for_copper_link(struct e1000_hw *hw) /* Check if there was DownShift, must be checked * immediately after link-up */ - e1000_check_downshift(hw); + e1000e_check_downshift(hw); /* If we are forcing speed/duplex, then we simply return since * we have already determined whether we have link or not. @@ -410,14 +412,14 @@ s32 e1000_check_for_copper_link(struct e1000_hw *hw) * of MAC speed/duplex configuration. So we only need to * configure Collision Distance in the MAC. */ - e1000_config_collision_dist(hw); + e1000e_config_collision_dist(hw); /* Configure Flow Control now that Auto-Neg has completed. * First, we need to restore the desired flow control * settings because we may have had to re-autoneg with a * different link partner. */ - ret_val = e1000_config_fc_after_link_up(hw); + ret_val = e1000e_config_fc_after_link_up(hw); if (ret_val) { hw_dbg(hw, "Error configuring flow control\n"); } @@ -426,13 +428,13 @@ s32 e1000_check_for_copper_link(struct e1000_hw *hw) } /** - * e1000_check_for_fiber_link - Check for link (Fiber) + * e1000e_check_for_fiber_link - 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(struct e1000_hw *hw) +s32 e1000e_check_for_fiber_link(struct e1000_hw *hw) { struct e1000_mac_info *mac = &hw->mac; u32 rxcw; @@ -469,7 +471,7 @@ s32 e1000_check_for_fiber_link(struct e1000_hw *hw) ew32(CTRL, ctrl); /* Configure Flow Control after forcing link up. */ - ret_val = e1000_config_fc_after_link_up(hw); + ret_val = e1000e_config_fc_after_link_up(hw); if (ret_val) { hw_dbg(hw, "Error configuring flow control\n"); return ret_val; @@ -491,13 +493,13 @@ s32 e1000_check_for_fiber_link(struct e1000_hw *hw) } /** - * e1000_check_for_serdes_link - Check for link (Serdes) + * e1000e_check_for_serdes_link - 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(struct e1000_hw *hw) +s32 e1000e_check_for_serdes_link(struct e1000_hw *hw) { struct e1000_mac_info *mac = &hw->mac; u32 rxcw; @@ -532,7 +534,7 @@ s32 e1000_check_for_serdes_link(struct e1000_hw *hw) ew32(CTRL, ctrl); /* Configure Flow Control after forcing link up. */ - ret_val = e1000_config_fc_after_link_up(hw); + ret_val = e1000e_config_fc_after_link_up(hw); if (ret_val) { hw_dbg(hw, "Error configuring flow control\n"); return ret_val; @@ -617,7 +619,7 @@ static s32 e1000_set_default_fc_generic(struct e1000_hw *hw) } /** - * e1000_setup_link - Setup flow control and link settings + * e1000e_setup_link - Setup flow control and link settings * @hw: pointer to the HW structure * * Determines which flow control settings to use, then configures flow @@ -626,7 +628,7 @@ static s32 e1000_set_default_fc_generic(struct e1000_hw *hw) * should be established. Assumes the hardware has previously been reset * and the transmitter and receiver are not enabled. **/ -s32 e1000_setup_link(struct e1000_hw *hw) +s32 e1000e_setup_link(struct e1000_hw *hw) { struct e1000_mac_info *mac = &hw->mac; s32 ret_val; @@ -637,9 +639,15 @@ s32 e1000_setup_link(struct e1000_hw *hw) if (e1000_check_reset_block(hw)) return 0; - ret_val = e1000_set_default_fc_generic(hw); - if (ret_val) - return ret_val; + /* + * If flow control is set to default, set flow control based on + * the EEPROM flow control settings. + */ + if (mac->fc == e1000_fc_default) { + ret_val = e1000_set_default_fc_generic(hw); + if (ret_val) + return ret_val; + } /* We want to save off the original Flow Control configuration just * in case we get disconnected and then reconnected into a different @@ -666,7 +674,7 @@ s32 e1000_setup_link(struct e1000_hw *hw) ew32(FCTTV, mac->fc_pause_time); - return e1000_set_fc_watermarks(hw); + return e1000e_set_fc_watermarks(hw); } /** @@ -784,13 +792,13 @@ static s32 e1000_poll_fiber_serdes_link_generic(struct e1000_hw *hw) } /** - * e1000_setup_fiber_serdes_link - Setup link for fiber/serdes + * e1000e_setup_fiber_serdes_link - 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(struct e1000_hw *hw) +s32 e1000e_setup_fiber_serdes_link(struct e1000_hw *hw) { u32 ctrl; s32 ret_val; @@ -800,7 +808,7 @@ s32 e1000_setup_fiber_serdes_link(struct e1000_hw *hw) /* Take the link out of reset */ ctrl &= ~E1000_CTRL_LRST; - e1000_config_collision_dist(hw); + e1000e_config_collision_dist(hw); ret_val = e1000_commit_fc_settings_generic(hw); if (ret_val) @@ -833,14 +841,14 @@ s32 e1000_setup_fiber_serdes_link(struct e1000_hw *hw) } /** - * e1000_config_collision_dist - Configure collision distance + * e1000e_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. Currently no func pointer exists and all * implementations are handled in the generic version of this function. **/ -void e1000_config_collision_dist(struct e1000_hw *hw) +void e1000e_config_collision_dist(struct e1000_hw *hw) { u32 tctl; @@ -854,14 +862,14 @@ void e1000_config_collision_dist(struct e1000_hw *hw) } /** - * e1000_set_fc_watermarks - Set flow control high/low watermarks + * e1000e_set_fc_watermarks - 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. **/ -s32 e1000_set_fc_watermarks(struct e1000_hw *hw) +s32 e1000e_set_fc_watermarks(struct e1000_hw *hw) { struct e1000_mac_info *mac = &hw->mac; u32 fcrtl = 0, fcrth = 0; @@ -888,7 +896,7 @@ s32 e1000_set_fc_watermarks(struct e1000_hw *hw) } /** - * e1000_force_mac_fc - Force the MAC's flow control settings + * e1000e_force_mac_fc - 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 @@ -897,7 +905,7 @@ s32 e1000_set_fc_watermarks(struct e1000_hw *hw) * 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 e1000_force_mac_fc(struct e1000_hw *hw) +s32 e1000e_force_mac_fc(struct e1000_hw *hw) { struct e1000_mac_info *mac = &hw->mac; u32 ctrl; @@ -949,7 +957,7 @@ s32 e1000_force_mac_fc(struct e1000_hw *hw) } /** - * e1000_config_fc_after_link_up - Configures flow control after link + * e1000e_config_fc_after_link_up - Configures flow control after link * @hw: pointer to the HW structure * * Checks the status of auto-negotiation after link up to ensure that the @@ -958,7 +966,7 @@ s32 e1000_force_mac_fc(struct e1000_hw *hw) * and did not fail, then we configure flow control based on our link * partner. **/ -s32 e1000_config_fc_after_link_up(struct e1000_hw *hw) +s32 e1000e_config_fc_after_link_up(struct e1000_hw *hw) { struct e1000_mac_info *mac = &hw->mac; s32 ret_val = 0; @@ -972,10 +980,10 @@ s32 e1000_config_fc_after_link_up(struct e1000_hw *hw) if (mac->autoneg_failed) { if (hw->media_type == e1000_media_type_fiber || hw->media_type == e1000_media_type_internal_serdes) - ret_val = e1000_force_mac_fc(hw); + ret_val = e1000e_force_mac_fc(hw); } else { if (hw->media_type == e1000_media_type_copper) - ret_val = e1000_force_mac_fc(hw); + ret_val = e1000e_force_mac_fc(hw); } if (ret_val) { @@ -1145,7 +1153,7 @@ s32 e1000_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 = e1000_force_mac_fc(hw); + ret_val = e1000e_force_mac_fc(hw); if (ret_val) { hw_dbg(hw, "Error forcing flow control settings\n"); return ret_val; @@ -1156,7 +1164,7 @@ s32 e1000_config_fc_after_link_up(struct e1000_hw *hw) } /** - * e1000_get_speed_and_duplex_copper - Retreive current speed/duplex + * e1000e_get_speed_and_duplex_copper - Retreive current speed/duplex * @hw: pointer to the HW structure * @speed: stores the current speed * @duplex: stores the current duplex @@ -1164,7 +1172,7 @@ s32 e1000_config_fc_after_link_up(struct e1000_hw *hw) * Read the status register for the current speed/duplex and store the current * speed and duplex for copper connections. **/ -s32 e1000_get_speed_and_duplex_copper(struct e1000_hw *hw, u16 *speed, u16 *duplex) +s32 e1000e_get_speed_and_duplex_copper(struct e1000_hw *hw, u16 *speed, u16 *duplex) { u32 status; @@ -1192,7 +1200,7 @@ s32 e1000_get_speed_and_duplex_copper(struct e1000_hw *hw, u16 *speed, u16 *dupl } /** - * e1000_get_speed_and_duplex_fiber_serdes - Retreive current speed/duplex + * e1000e_get_speed_and_duplex_fiber_serdes - Retreive current speed/duplex * @hw: pointer to the HW structure * @speed: stores the current speed * @duplex: stores the current duplex @@ -1200,7 +1208,7 @@ s32 e1000_get_speed_and_duplex_copper(struct e1000_hw *hw, u16 *speed, u16 *dupl * 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(struct e1000_hw *hw, u16 *speed, u16 *duplex) +s32 e1000e_get_speed_and_duplex_fiber_serdes(struct e1000_hw *hw, u16 *speed, u16 *duplex) { *speed = SPEED_1000; *duplex = FULL_DUPLEX; @@ -1209,12 +1217,12 @@ s32 e1000_get_speed_and_duplex_fiber_serdes(struct e1000_hw *hw, u16 *speed, u16 } /** - * e1000_get_hw_semaphore - Acquire hardware semaphore + * e1000e_get_hw_semaphore - Acquire hardware semaphore * @hw: pointer to the HW structure * * Acquire the HW semaphore to access the PHY or NVM **/ -s32 e1000_get_hw_semaphore(struct e1000_hw *hw) +s32 e1000e_get_hw_semaphore(struct e1000_hw *hw) { u32 swsm; s32 timeout = hw->nvm.word_size + 1; @@ -1249,7 +1257,7 @@ s32 e1000_get_hw_semaphore(struct e1000_hw *hw) if (i == timeout) { /* Release semaphores */ - e1000_put_hw_semaphore(hw); + e1000e_put_hw_semaphore(hw); hw_dbg(hw, "Driver can't access the NVM\n"); return -E1000_ERR_NVM; } @@ -1258,12 +1266,12 @@ s32 e1000_get_hw_semaphore(struct e1000_hw *hw) } /** - * e1000_put_hw_semaphore - Release hardware semaphore + * e1000e_put_hw_semaphore - Release hardware semaphore * @hw: pointer to the HW structure * * Release hardware semaphore used to access the PHY or NVM **/ -void e1000_put_hw_semaphore(struct e1000_hw *hw) +void e1000e_put_hw_semaphore(struct e1000_hw *hw) { u32 swsm; @@ -1273,12 +1281,12 @@ void e1000_put_hw_semaphore(struct e1000_hw *hw) } /** - * e1000_get_auto_rd_done - Check for auto read completion + * e1000e_get_auto_rd_done - Check for auto read completion * @hw: pointer to the HW structure * * Check EEPROM for Auto Read done bit. **/ -s32 e1000_get_auto_rd_done(struct e1000_hw *hw) +s32 e1000e_get_auto_rd_done(struct e1000_hw *hw) { s32 i = 0; @@ -1298,14 +1306,14 @@ s32 e1000_get_auto_rd_done(struct e1000_hw *hw) } /** - * e1000_valid_led_default - Verify a valid default LED config + * e1000e_valid_led_default - 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. **/ -s32 e1000_valid_led_default(struct e1000_hw *hw, u16 *data) +s32 e1000e_valid_led_default(struct e1000_hw *hw, u16 *data) { s32 ret_val; @@ -1322,11 +1330,11 @@ s32 e1000_valid_led_default(struct e1000_hw *hw, u16 *data) } /** - * e1000_id_led_init - + * e1000e_id_led_init - * @hw: pointer to the HW structure * **/ -s32 e1000_id_led_init(struct e1000_hw *hw) +s32 e1000e_id_led_init(struct e1000_hw *hw) { struct e1000_mac_info *mac = &hw->mac; s32 ret_val; @@ -1386,25 +1394,25 @@ s32 e1000_id_led_init(struct e1000_hw *hw) } /** - * e1000_cleanup_led_generic - Set LED config to default operation + * e1000e_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 e1000_cleanup_led_generic(struct e1000_hw *hw) +s32 e1000e_cleanup_led_generic(struct e1000_hw *hw) { ew32(LEDCTL, hw->mac.ledctl_default); return 0; } /** - * e1000_blink_led - Blink LED + * e1000e_blink_led - Blink LED * @hw: pointer to the HW structure * * Blink the led's which are set to be on. **/ -s32 e1000_blink_led(struct e1000_hw *hw) +s32 e1000e_blink_led(struct e1000_hw *hw) { u32 ledctl_blink = 0; u32 i; @@ -1430,12 +1438,12 @@ s32 e1000_blink_led(struct e1000_hw *hw) } /** - * e1000_led_on_generic - Turn LED on + * e1000e_led_on_generic - Turn LED on * @hw: pointer to the HW structure * * Turn LED on. **/ -s32 e1000_led_on_generic(struct e1000_hw *hw) +s32 e1000e_led_on_generic(struct e1000_hw *hw) { u32 ctrl; @@ -1457,12 +1465,12 @@ s32 e1000_led_on_generic(struct e1000_hw *hw) } /** - * e1000_led_off_generic - Turn LED off + * e1000e_led_off_generic - Turn LED off * @hw: pointer to the HW structure * * Turn LED off. **/ -s32 e1000_led_off_generic(struct e1000_hw *hw) +s32 e1000e_led_off_generic(struct e1000_hw *hw) { u32 ctrl; @@ -1484,13 +1492,13 @@ s32 e1000_led_off_generic(struct e1000_hw *hw) } /** - * e1000_set_pcie_no_snoop - Set PCI-express capabilities + * e1000e_set_pcie_no_snoop - 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(struct e1000_hw *hw, u32 no_snoop) +void e1000e_set_pcie_no_snoop(struct e1000_hw *hw, u32 no_snoop) { u32 gcr; @@ -1503,7 +1511,7 @@ void e1000_set_pcie_no_snoop(struct e1000_hw *hw, u32 no_snoop) } /** - * e1000_disable_pcie_master - Disables PCI-express master access + * e1000e_disable_pcie_master - Disables PCI-express master access * @hw: pointer to the HW structure * * Returns 0 if successful, else returns -10 @@ -1513,7 +1521,7 @@ void e1000_set_pcie_no_snoop(struct e1000_hw *hw, u32 no_snoop) * Disables PCI-Express master access and verifies there are no pending * requests. **/ -s32 e1000_disable_pcie_master(struct e1000_hw *hw) +s32 e1000e_disable_pcie_master(struct e1000_hw *hw) { u32 ctrl; s32 timeout = MASTER_DISABLE_TIMEOUT; @@ -1539,12 +1547,12 @@ s32 e1000_disable_pcie_master(struct e1000_hw *hw) } /** - * e1000_reset_adaptive - Reset Adaptive Interframe Spacing + * e1000e_reset_adaptive - Reset Adaptive Interframe Spacing * @hw: pointer to the HW structure * * Reset the Adaptive Interframe Spacing throttle to default values. **/ -void e1000_reset_adaptive(struct e1000_hw *hw) +void e1000e_reset_adaptive(struct e1000_hw *hw) { struct e1000_mac_info *mac = &hw->mac; @@ -1559,13 +1567,13 @@ void e1000_reset_adaptive(struct e1000_hw *hw) } /** - * e1000_update_adaptive - Update Adaptive Interframe Spacing + * e1000e_update_adaptive - 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 e1000_update_adaptive(struct e1000_hw *hw) +void e1000e_update_adaptive(struct e1000_hw *hw) { struct e1000_mac_info *mac = &hw->mac; @@ -1702,14 +1710,14 @@ static u16 e1000_shift_in_eec_bits(struct e1000_hw *hw, u16 count) } /** - * e1000_poll_eerd_eewr_done - Poll for EEPROM read/write completion + * e1000e_poll_eerd_eewr_done - Poll for EEPROM read/write completion * @hw: pointer to the HW structure * @ee_reg: EEPROM flag for polling * * Polls the EEPROM status bit for either read or write completion based * upon the value of 'ee_reg'. **/ -s32 e1000_poll_eerd_eewr_done(struct e1000_hw *hw, int ee_reg) +s32 e1000e_poll_eerd_eewr_done(struct e1000_hw *hw, int ee_reg) { u32 attempts = 100000; u32 i, reg = 0; @@ -1730,14 +1738,14 @@ s32 e1000_poll_eerd_eewr_done(struct e1000_hw *hw, int ee_reg) } /** - * e1000_acquire_nvm - Generic request for access to EEPROM + * e1000e_acquire_nvm - 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 e1000_acquire_nvm(struct e1000_hw *hw) +s32 e1000e_acquire_nvm(struct e1000_hw *hw) { u32 eecd = er32(EECD); s32 timeout = E1000_NVM_GRANT_ATTEMPTS; @@ -1806,12 +1814,12 @@ static void e1000_stop_nvm(struct e1000_hw *hw) } /** - * e1000_release_nvm - Release exclusive access to EEPROM + * e1000e_release_nvm - 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 e1000_release_nvm(struct e1000_hw *hw) +void e1000e_release_nvm(struct e1000_hw *hw) { u32 eecd; @@ -1868,7 +1876,7 @@ static s32 e1000_ready_nvm_eeprom(struct e1000_hw *hw) } /** - * e1000_read_nvm_spi - Read EEPROM's using SPI + * e1000e_read_nvm_spi - Read EEPROM's using SPI * @hw: pointer to the HW structure * @offset: offset of word in the EEPROM to read * @words: number of words to read @@ -1876,7 +1884,7 @@ static s32 e1000_ready_nvm_eeprom(struct e1000_hw *hw) * * Reads a 16 bit word from the EEPROM. **/ -s32 e1000_read_nvm_spi(struct e1000_hw *hw, u16 offset, u16 words, u16 *data) +s32 e1000e_read_nvm_spi(struct e1000_hw *hw, u16 offset, u16 words, u16 *data) { struct e1000_nvm_info *nvm = &hw->nvm; u32 i = 0; @@ -1924,7 +1932,7 @@ s32 e1000_read_nvm_spi(struct e1000_hw *hw, u16 offset, u16 words, u16 *data) } /** - * e1000_read_nvm_eerd - Reads EEPROM using EERD register + * e1000e_read_nvm_eerd - Reads EEPROM using EERD register * @hw: pointer to the HW structure * @offset: offset of word in the EEPROM to read * @words: number of words to read @@ -1932,11 +1940,11 @@ s32 e1000_read_nvm_spi(struct e1000_hw *hw, u16 offset, u16 words, u16 *data) * * Reads a 16 bit word from the EEPROM using the EERD register. **/ -s32 e1000_read_nvm_eerd(struct e1000_hw *hw, u16 offset, u16 words, u16 *data) +s32 e1000e_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; + s32 ret_val = 0; /* A check for invalid values: offset too large, too many words, * and not enough words. */ @@ -1951,7 +1959,7 @@ s32 e1000_read_nvm_eerd(struct e1000_hw *hw, u16 offset, u16 words, u16 *data) E1000_NVM_RW_REG_START; ew32(EERD, eerd); - ret_val = e1000_poll_eerd_eewr_done(hw, E1000_NVM_POLL_READ); + ret_val = e1000e_poll_eerd_eewr_done(hw, E1000_NVM_POLL_READ); if (ret_val) break; @@ -1963,7 +1971,7 @@ s32 e1000_read_nvm_eerd(struct e1000_hw *hw, u16 offset, u16 words, u16 *data) } /** - * e1000_write_nvm_spi - Write to EEPROM using SPI + * e1000e_write_nvm_spi - Write to EEPROM using SPI * @hw: pointer to the HW structure * @offset: offset within the EEPROM to be written to * @words: number of words to write @@ -1971,10 +1979,10 @@ s32 e1000_read_nvm_eerd(struct e1000_hw *hw, u16 offset, u16 words, u16 *data) * * Writes data to EEPROM at offset using SPI interface. * - * If e1000_update_nvm_checksum is not called after this function , the + * If e1000e_update_nvm_checksum is not called after this function , the * EEPROM will most likley contain an invalid checksum. **/ -s32 e1000_write_nvm_spi(struct e1000_hw *hw, u16 offset, u16 words, u16 *data) +s32 e1000e_write_nvm_spi(struct e1000_hw *hw, u16 offset, u16 words, u16 *data) { struct e1000_nvm_info *nvm = &hw->nvm; s32 ret_val; @@ -2040,20 +2048,55 @@ s32 e1000_write_nvm_spi(struct e1000_hw *hw, u16 offset, u16 words, u16 *data) } /** - * e1000_read_mac_addr - Read device MAC address + * e1000e_read_mac_addr - 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 e1000_read_mac_addr(struct e1000_hw *hw) +s32 e1000e_read_mac_addr(struct e1000_hw *hw) { s32 ret_val; u16 offset, nvm_data, i; + u16 mac_addr_offset = 0; + + if (hw->mac.type == e1000_82571) { + /* Check 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. */ + ret_val = e1000_read_nvm(hw, NVM_ALT_MAC_ADDR_PTR, 1, + &mac_addr_offset); + if (ret_val) { + hw_dbg(hw, "NVM Read Error\n"); + return ret_val; + } + if (mac_addr_offset == 0xFFFF) + mac_addr_offset = 0; + + if (mac_addr_offset) { + if (hw->bus.func == E1000_FUNC_1) + mac_addr_offset += ETH_ALEN/sizeof(u16); + + /* make sure we have a valid mac address here + * before using it */ + ret_val = e1000_read_nvm(hw, mac_addr_offset, 1, + &nvm_data); + if (ret_val) { + hw_dbg(hw, "NVM Read Error\n"); + return ret_val; + } + if (nvm_data & 0x0001) + mac_addr_offset = 0; + } + + if (mac_addr_offset) + hw->dev_spec.e82571.alt_mac_addr_is_present = 1; + } for (i = 0; i < ETH_ALEN; i += 2) { - offset = i >> 1; + offset = mac_addr_offset + (i >> 1); ret_val = e1000_read_nvm(hw, offset, 1, &nvm_data); if (ret_val) { hw_dbg(hw, "NVM Read Error\n"); @@ -2064,7 +2107,7 @@ s32 e1000_read_mac_addr(struct e1000_hw *hw) } /* Flip last bit of mac address if we're on second port */ - if (hw->bus.func == E1000_FUNC_1) + if (!mac_addr_offset && hw->bus.func == E1000_FUNC_1) hw->mac.perm_addr[5] ^= 1; for (i = 0; i < ETH_ALEN; i++) @@ -2074,13 +2117,13 @@ s32 e1000_read_mac_addr(struct e1000_hw *hw) } /** - * e1000_validate_nvm_checksum_generic - Validate EEPROM checksum + * e1000e_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 e1000_validate_nvm_checksum_generic(struct e1000_hw *hw) +s32 e1000e_validate_nvm_checksum_generic(struct e1000_hw *hw) { s32 ret_val; u16 checksum = 0; @@ -2104,14 +2147,14 @@ s32 e1000_validate_nvm_checksum_generic(struct e1000_hw *hw) } /** - * e1000_update_nvm_checksum_generic - Update EEPROM checksum + * e1000e_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 e1000_update_nvm_checksum_generic(struct e1000_hw *hw) +s32 e1000e_update_nvm_checksum_generic(struct e1000_hw *hw) { s32 ret_val; u16 checksum = 0; @@ -2134,13 +2177,13 @@ s32 e1000_update_nvm_checksum_generic(struct e1000_hw *hw) } /** - * e1000_reload_nvm - Reloads EEPROM + * e1000e_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) +void e1000e_reload_nvm(struct e1000_hw *hw) { u32 ctrl_ext; @@ -2211,13 +2254,13 @@ static s32 e1000_mng_enable_host_if(struct e1000_hw *hw) } /** - * e1000_check_mng_mode - check managament mode + * e1000e_check_mng_mode - check managament 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(struct e1000_hw *hw) +bool e1000e_check_mng_mode(struct e1000_hw *hw) { u32 fwsm = er32(FWSM); @@ -2225,13 +2268,13 @@ bool e1000_check_mng_mode(struct e1000_hw *hw) } /** - * e1000_enable_tx_pkt_filtering - Enable packet filtering on TX + * e1000e_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. **/ -bool e1000_enable_tx_pkt_filtering(struct e1000_hw *hw) +bool e1000e_enable_tx_pkt_filtering(struct e1000_hw *hw) { struct e1000_host_mng_dhcp_cookie *hdr = &hw->mng_cookie; u32 *buffer = (u32 *)&hw->mng_cookie; @@ -2240,7 +2283,7 @@ bool e1000_enable_tx_pkt_filtering(struct e1000_hw *hw) u8 i, len; /* No manageability, no filtering */ - if (!e1000_check_mng_mode(hw)) { + if (!e1000e_check_mng_mode(hw)) { hw->mac.tx_pkt_filtering = 0; return 0; } @@ -2381,14 +2424,14 @@ static s32 e1000_mng_host_if_write(struct e1000_hw *hw, u8 *buffer, } /** - * e1000_mng_write_dhcp_info - Writes DHCP info to host interface + * e1000e_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) +s32 e1000e_mng_write_dhcp_info(struct e1000_hw *hw, u8 *buffer, u16 length) { struct e1000_host_mng_command_header hdr; s32 ret_val; @@ -2424,12 +2467,12 @@ s32 e1000_mng_write_dhcp_info(struct e1000_hw *hw, u8 *buffer, u16 length) } /** - * e1000_enable_mng_pass_thru - Enable processing of ARP's + * e1000e_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) +bool e1000e_enable_mng_pass_thru(struct e1000_hw *hw) { u32 manc; u32 fwsm, factps; @@ -2462,3 +2505,24 @@ bool e1000_enable_mng_pass_thru(struct e1000_hw *hw) return ret_val; } +s32 e1000e_read_part_num(struct e1000_hw *hw, u32 *part_num) +{ + s32 ret_val; + u16 nvm_data; + + ret_val = e1000_read_nvm(hw, NVM_PBA_OFFSET_0, 1, &nvm_data); + if (ret_val) { + hw_dbg(hw, "NVM Read Error\n"); + return ret_val; + } + *part_num = (u32)(nvm_data << 16); + + ret_val = e1000_read_nvm(hw, NVM_PBA_OFFSET_1, 1, &nvm_data); + if (ret_val) { + hw_dbg(hw, "NVM Read Error\n"); + return ret_val; + } + *part_num |= nvm_data; + + return 0; +} diff --git a/drivers/net/e1000e/netdev.c b/drivers/net/e1000e/netdev.c index 4953f61..9914578 100644 --- a/drivers/net/e1000e/netdev.c +++ b/drivers/net/e1000e/netdev.c @@ -29,8 +29,10 @@ #include <linux/module.h> #include <linux/types.h> #include <linux/init.h> +#include <linux/pci.h> #include <linux/vmalloc.h> #include <linux/pagemap.h> +#include <linux/delay.h> #include <linux/netdevice.h> #include <linux/tcp.h> #include <linux/ipv6.h> @@ -45,8 +47,8 @@ #include "e1000.h" #define DRV_VERSION "0.2.0" -char e1000_driver_name[] = "e1000e"; -const char e1000_driver_version[] = DRV_VERSION; +char e1000e_driver_name[] = "e1000e"; +const char e1000e_driver_version[] = DRV_VERSION; static const struct e1000_info *e1000_info_tbl[] = { [board_82571] = &e1000_82571_info, @@ -62,11 +64,9 @@ static const struct e1000_info *e1000_info_tbl[] = { * e1000_get_hw_dev_name - return device name string * used by hardware layer to print debugging information **/ -char *e1000_get_hw_dev_name(struct e1000_hw *hw) +char *e1000e_get_hw_dev_name(struct e1000_hw *hw) { - struct e1000_adapter *adapter = hw->back; - struct net_device *netdev = adapter->netdev; - return netdev->name; + return hw->adapter->netdev->name; } #endif @@ -193,6 +193,11 @@ map_skb: buffer_info->dma = pci_map_single(pdev, skb->data, adapter->rx_buffer_len, PCI_DMA_FROMDEVICE); + if (pci_dma_mapping_error(buffer_info->dma)) { + dev_err(&pdev->dev, "RX DMA map failed\n"); + adapter->rx_dma_failed++; + break; + } rx_desc = E1000_RX_DESC(*rx_ring, i); rx_desc->buffer_addr = cpu_to_le64(buffer_info->dma); @@ -240,30 +245,36 @@ static void e1000_alloc_rx_buffers_ps(struct e1000_adapter *adapter, rx_desc = E1000_RX_DESC_PS(*rx_ring, i); for (j = 0; j < PS_PAGE_BUFFERS; j++) { - ps_page = &rx_ring->ps_pages[(i * PS_PAGE_BUFFERS) - + j]; - if (j < adapter->rx_ps_pages) { + ps_page = &buffer_info->ps_pages[j]; + if (j >= adapter->rx_ps_pages) { + /* all unused desc entries get hw null ptr */ + rx_desc->read.buffer_addr[j+1] = ~0; + continue; + } + if (!ps_page->page) { + ps_page->page = alloc_page(GFP_ATOMIC); if (!ps_page->page) { - ps_page->page = alloc_page(GFP_ATOMIC); - if (!ps_page->page) { - adapter->alloc_rx_buff_failed++; - goto no_buffers; - } - ps_page->dma = pci_map_page(pdev, - ps_page->page, - 0, PAGE_SIZE, - PCI_DMA_FROMDEVICE); + adapter->alloc_rx_buff_failed++; + goto no_buffers; + } + ps_page->dma = pci_map_page(pdev, + ps_page->page, + 0, PAGE_SIZE, + PCI_DMA_FROMDEVICE); + if (pci_dma_mapping_error(ps_page->dma)) { + dev_err(&adapter->pdev->dev, + "RX DMA page map failed\n"); + adapter->rx_dma_failed++; + goto no_buffers; } - /* - * Refresh the desc even if buffer_addrs - * didn't change because each write-back - * erases this info. - */ - rx_desc->read.buffer_addr[j+1] = - cpu_to_le64(ps_page->dma); - } else { - rx_desc->read.buffer_addr[j+1] = ~0; } + /* + * Refresh the desc even if buffer_addrs + * didn't change because each write-back + * erases this info. + */ + rx_desc->read.buffer_addr[j+1] = + cpu_to_le64(ps_page->dma); } skb = netdev_alloc_skb(netdev, @@ -284,6 +295,14 @@ static void e1000_alloc_rx_buffers_ps(struct e1000_adapter *adapter, buffer_info->dma = pci_map_single(pdev, skb->data, adapter->rx_ps_bsize0, PCI_DMA_FROMDEVICE); + if (pci_dma_mapping_error(buffer_info->dma)) { + dev_err(&pdev->dev, "RX DMA map failed\n"); + adapter->rx_dma_failed++; + /* cleanup skb */ + dev_kfree_skb_any(skb); + buffer_info->skb = NULL; + break; + } rx_desc->read.buffer_addr[0] = cpu_to_le64(buffer_info->dma); @@ -314,89 +333,6 @@ no_buffers: } /** - * e1000_alloc_rx_buffers_jumbo - Replace used jumbo receive buffers - * - * @adapter: address of board private structure - * @cleaned_count: number of buffers to allocate this pass - **/ -static void e1000_alloc_rx_buffers_jumbo(struct e1000_adapter *adapter, - int cleaned_count) -{ - struct net_device *netdev = adapter->netdev; - struct pci_dev *pdev = adapter->pdev; - struct e1000_ring *rx_ring = adapter->rx_ring; - struct e1000_rx_desc *rx_desc; - struct e1000_buffer *buffer_info; - struct sk_buff *skb; - unsigned int i; - unsigned int bufsz = 256 - - 16 /*for skb_reserve */ - - NET_IP_ALIGN; - - i = rx_ring->next_to_use; - buffer_info = &rx_ring->buffer_info[i]; - - while (cleaned_count--) { - skb = buffer_info->skb; - if (skb) { - skb_trim(skb, 0); - goto check_page; - } - - skb = netdev_alloc_skb(netdev, bufsz); - if (!skb) { - /* Better luck next round */ - adapter->alloc_rx_buff_failed++; - break; - } - - /* Make buffer alignment 2 beyond a 16 byte boundary - * this will result in a 16 byte aligned IP header after - * the 14 byte MAC header is removed - */ - skb_reserve(skb, NET_IP_ALIGN); - - buffer_info->skb = skb; -check_page: - /* allocate a new page if necessary */ - if (!buffer_info->page) { - buffer_info->page = alloc_page(GFP_ATOMIC); - if (!buffer_info->page) { - adapter->alloc_rx_buff_failed++; - break; - } - } - - if (!buffer_info->dma) - buffer_info->dma = pci_map_page(pdev, - buffer_info->page, 0, - PAGE_SIZE, - PCI_DMA_FROMDEVICE); - - rx_desc = E1000_RX_DESC(*rx_ring, i); - rx_desc->buffer_addr = cpu_to_le64(buffer_info->dma); - - i++; - if (i == rx_ring->count) - i = 0; - buffer_info = &rx_ring->buffer_info[i]; - } - - if (rx_ring->next_to_use != i) { - rx_ring->next_to_use = i; - if (i-- == 0) - i = (rx_ring->count - 1); - - /* Force memory writes to complete before letting h/w - * know there are new descriptors to fetch. (Only - * applicable for weak-ordered memory model archs, - * such as IA-64). */ - wmb(); - writel(i, adapter->hw.hw_addr + rx_ring->tail); - } -} - -/** * e1000_clean_rx_irq - Send received data up the network stack; legacy * @adapter: board private structure * @@ -470,10 +406,6 @@ static bool e1000_clean_rx_irq(struct e1000_adapter *adapter, goto next_desc; } - /* adjust length to remove Ethernet CRC */ - length -= 4; - - /* probably a little skewed due to removing CRC */ total_rx_bytes += length; total_rx_packets++; @@ -526,18 +458,11 @@ next_desc: adapter->total_rx_packets += total_rx_packets; adapter->total_rx_bytes += total_rx_bytes; + adapter->net_stats.rx_packets += total_rx_packets; + adapter->net_stats.rx_bytes += total_rx_bytes; return cleaned; } -static void e1000_consume_page(struct e1000_buffer *bi, struct sk_buff *skb, - u16 length) -{ - bi->page = NULL; - skb->len += length; - skb->data_len += length; - skb->truesize += length; -} - static void e1000_put_txbuf(struct e1000_adapter *adapter, struct e1000_buffer *buffer_info) { @@ -670,174 +595,8 @@ static bool e1000_clean_tx_irq(struct e1000_adapter *adapter) } adapter->total_tx_bytes += total_tx_bytes; adapter->total_tx_packets += total_tx_packets; - return cleaned; -} - -/** - * e1000_clean_rx_irq_jumbo - Send received data up the network stack; legacy - * @adapter: board private structure - * - * the return value indicates whether actual cleaning was done, there - * is no guarantee that everything was cleaned - **/ -static bool e1000_clean_rx_irq_jumbo(struct e1000_adapter *adapter, - int *work_done, int work_to_do) -{ - struct net_device *netdev = adapter->netdev; - struct pci_dev *pdev = adapter->pdev; - struct e1000_ring *rx_ring = adapter->rx_ring; - struct e1000_rx_desc *rx_desc, *next_rxd; - struct e1000_buffer *buffer_info, *next_buffer; - u32 length; - unsigned int i; - int cleaned_count = 0; - bool cleaned = 0; - unsigned int total_rx_bytes = 0, total_rx_packets = 0; - - i = rx_ring->next_to_clean; - rx_desc = E1000_RX_DESC(*rx_ring, i); - buffer_info = &rx_ring->buffer_info[i]; - - while (rx_desc->status & E1000_RXD_STAT_DD) { - struct sk_buff *skb; - u8 status; - - if (*work_done >= work_to_do) - break; - (*work_done)++; - - status = rx_desc->status; - skb = buffer_info->skb; - buffer_info->skb = NULL; - - i++; - if (i == rx_ring->count) - i = 0; - next_rxd = E1000_RX_DESC(*rx_ring, i); - prefetch(next_rxd); - - next_buffer = &rx_ring->buffer_info[i]; - - cleaned = 1; - cleaned_count++; - pci_unmap_page(pdev, - buffer_info->dma, - PAGE_SIZE, - PCI_DMA_FROMDEVICE); - buffer_info->dma = 0; - - length = le16_to_cpu(rx_desc->length); - - /* errors is only valid for DD + EOP descriptors */ - if ((status & E1000_RXD_STAT_EOP) && - (rx_desc->errors & E1000_RXD_ERR_FRAME_ERR_MASK)) { - /* recycle both page and skb */ - buffer_info->skb = skb; - /* an error means any chain goes out the window too */ - if (rx_ring->rx_skb_top) - dev_kfree_skb(rx_ring->rx_skb_top); - rx_ring->rx_skb_top = NULL; - goto next_desc; - } - -#define rxtop rx_ring->rx_skb_top - if (!(status & E1000_RXD_STAT_EOP)) { - /* this descriptor is only the beginning (or middle) */ - if (!rxtop) { - /* this is the beginning of a chain */ - rxtop = skb; - skb_fill_page_desc(rxtop, 0, buffer_info->page, - 0, length); - } else { - /* this is the middle of a chain */ - skb_fill_page_desc(rxtop, - skb_shinfo(rxtop)->nr_frags, - buffer_info->page, 0, - length); - /* re-use the skb, only consumed the page */ - buffer_info->skb = skb; - } - e1000_consume_page(buffer_info, rxtop, length); - goto next_desc; - } else { - if (rxtop) { - /* end of the chain */ - skb_fill_page_desc(rxtop, - skb_shinfo(rxtop)->nr_frags, - buffer_info->page, 0, length); - /* re-use the current skb, we only consumed the - * page */ - buffer_info->skb = skb; - skb = rxtop; - rxtop = NULL; - e1000_consume_page(buffer_info, skb, length); - } else { - /* no chain, got EOP, this buf is the packet - * copybreak to save the put_page/alloc_page */ - if (length <= copybreak && - skb_tailroom(skb) >= length) { - u8 *vaddr; - vaddr = kmap_atomic(buffer_info->page, - KM_SKB_DATA_SOFTIRQ); - memcpy(skb->tail, - vaddr, length); - kunmap_atomic(vaddr, - KM_SKB_DATA_SOFTIRQ); - /* re-use the page, so don't erase - * buffer_info->page */ - skb_put(skb, length); - } else { - skb_fill_page_desc(skb, 0, - buffer_info->page, 0, - length); - e1000_consume_page(buffer_info, skb, - length); - } - } - } - - /* Receive Checksum Offload XXX recompute due to CRC strip? */ - e1000_rx_checksum(adapter, - (u32)(status) | - ((u32)(rx_desc->errors) << 24), - le16_to_cpu(rx_desc->csum), skb); - - pskb_trim(skb, skb->len - 4); - - /* probably a little skewed due to removing CRC */ - total_rx_bytes += skb->len; - total_rx_packets++; - - /* eth type trans needs skb->data to point to something */ - if (!pskb_may_pull(skb, ETH_HLEN)) { - ndev_err(netdev, "__pskb_pull_tail failed.\n"); - dev_kfree_skb(skb); - goto next_desc; - } - - e1000_receive_skb(adapter, netdev, skb,status,rx_desc->special); - -next_desc: - rx_desc->status = 0; - - /* return some buffers to hardware, one at a time is too slow */ - if (cleaned_count >= E1000_RX_BUFFER_WRITE) { - adapter->alloc_rx_buf(adapter, cleaned_count); - cleaned_count = 0; - } - - /* use prefetched values */ - rx_desc = next_rxd; - buffer_info = next_buffer; - } - rx_ring->next_to_clean = i; - - cleaned_count = e1000_desc_unused(rx_ring); - if (cleaned_count) - adapter->alloc_rx_buf(adapter, cleaned_count); - - adapter->total_rx_packets += total_rx_packets; - adapter->total_rx_bytes += total_rx_bytes; + adapter->net_stats.tx_packets += total_tx_packets; + adapter->net_stats.tx_bytes += total_tx_bytes; return cleaned; } @@ -928,7 +687,7 @@ static bool e1000_clean_rx_irq_ps(struct e1000_adapter *adapter, ((length + l1) <= adapter->rx_ps_bsize0)) { u8 *vaddr; - ps_page = &rx_ring->ps_pages[i * PS_PAGE_BUFFERS]; + ps_page = &buffer_info->ps_pages[0]; /* there is no documentation about how to call * kmap_atomic, so we can't hold the mapping @@ -936,12 +695,11 @@ static bool e1000_clean_rx_irq_ps(struct e1000_adapter *adapter, pci_dma_sync_single_for_cpu(pdev, ps_page->dma, PAGE_SIZE, PCI_DMA_FROMDEVICE); vaddr = kmap_atomic(ps_page->page, KM_SKB_DATA_SOFTIRQ); - memcpy(skb->tail, vaddr, l1); + memcpy(skb_tail_pointer(skb), vaddr, l1); kunmap_atomic(vaddr, KM_SKB_DATA_SOFTIRQ); pci_dma_sync_single_for_device(pdev, ps_page->dma, PAGE_SIZE, PCI_DMA_FROMDEVICE); - /* remove the CRC */ - l1 -= 4; + skb_put(skb, l1); goto copydone; } /* if */ @@ -952,7 +710,7 @@ static bool e1000_clean_rx_irq_ps(struct e1000_adapter *adapter, if (!length) break; - ps_page = &rx_ring->ps_pages[(i * PS_PAGE_BUFFERS) + j]; + ps_page = &buffer_info->ps_pages[j]; pci_unmap_page(pdev, ps_page->dma, PAGE_SIZE, PCI_DMA_FROMDEVICE); ps_page->dma = 0; @@ -963,10 +721,6 @@ static bool e1000_clean_rx_irq_ps(struct e1000_adapter *adapter, skb->truesize += length; } - /* strip the ethernet crc, problem is we're using pages now so - * this whole operation can get a little cpu intensive */ - pskb_trim(skb, skb->len - 4); - copydone: total_rx_bytes += skb->len; total_rx_packets++; @@ -1005,6 +759,8 @@ next_desc: adapter->total_rx_packets += total_rx_packets; adapter->total_rx_bytes += total_rx_bytes; + adapter->net_stats.rx_packets += total_rx_packets; + adapter->net_stats.rx_bytes += total_rx_bytes; return cleaned; } @@ -1018,7 +774,6 @@ static void e1000_clean_rx_ring(struct e1000_adapter *adapter) struct e1000_buffer *buffer_info; struct e1000_ps_page *ps_page; struct pci_dev *pdev = adapter->pdev; - unsigned long size; unsigned int i, j; /* Free all the Rx ring sk_buffs */ @@ -1029,9 +784,6 @@ static void e1000_clean_rx_ring(struct e1000_adapter *adapter) pci_unmap_single(pdev, buffer_info->dma, adapter->rx_buffer_len, PCI_DMA_FROMDEVICE); - else if (adapter->clean_rx == e1000_clean_rx_irq_jumbo) - pci_unmap_page(pdev, buffer_info->dma, - PAGE_SIZE, PCI_DMA_FROMDEVICE); else if (adapter->clean_rx == e1000_clean_rx_irq_ps) pci_unmap_single(pdev, buffer_info->dma, adapter->rx_ps_bsize0, @@ -1039,19 +791,13 @@ static void e1000_clean_rx_ring(struct e1000_adapter *adapter) buffer_info->dma = 0; } - if (buffer_info->page) { - put_page(buffer_info->page); - buffer_info->page = NULL; - } - if (buffer_info->skb) { dev_kfree_skb(buffer_info->skb); buffer_info->skb = NULL; } for (j = 0; j < PS_PAGE_BUFFERS; j++) { - ps_page = &rx_ring->ps_pages[(i * PS_PAGE_BUFFERS) - + j]; + ps_page = &buffer_info->ps_pages[j]; if (!ps_page->page) break; pci_unmap_page(pdev, ps_page->dma, PAGE_SIZE, @@ -1068,12 +814,6 @@ static void e1000_clean_rx_ring(struct e1000_adapter *adapter) rx_ring->rx_skb_top = NULL; } - size = sizeof(struct e1000_buffer) * rx_ring->count; - memset(rx_ring->buffer_info, 0, size); - size = sizeof(struct e1000_ps_page) - * (rx_ring->count * PS_PAGE_BUFFERS); - memset(rx_ring->ps_pages, 0, size); - /* Zero out the descriptor ring */ memset(rx_ring->desc, 0, rx_ring->size); @@ -1106,7 +846,7 @@ static irqreturn_t e1000_intr_msi(int irq, void *data) * disconnect (LSC) before accessing any PHY registers */ if ((adapter->flags & FLAG_LSC_GIG_SPEED_DROP) && (!(er32(STATUS) & E1000_STATUS_LU))) - e1000_gig_downshift_workaround_ich8lan(hw); + e1000e_gig_downshift_workaround_ich8lan(hw); /* 80003ES2LAN workaround-- For packet buffer work-around on * link down event; disable receives here in the ISR and reset @@ -1167,7 +907,7 @@ static irqreturn_t e1000_intr(int irq, void *data) * disconnect (LSC) before accessing any PHY registers */ if ((adapter->flags & FLAG_LSC_GIG_SPEED_DROP) && (!(er32(STATUS) & E1000_STATUS_LU))) - e1000_gig_downshift_workaround_ich8lan(hw); + e1000e_gig_downshift_workaround_ich8lan(hw); /* 80003ES2LAN workaround-- * For packet buffer work-around on link down event; @@ -1342,7 +1082,8 @@ static int e1000_alloc_ring_dma(struct e1000_adapter *adapter, { struct pci_dev *pdev = adapter->pdev; - ring->desc = pci_alloc_consistent(pdev, ring->size, &ring->dma); + ring->desc = dma_alloc_coherent(&pdev->dev, ring->size, &ring->dma, + GFP_KERNEL); if (!ring->desc) return -ENOMEM; @@ -1350,12 +1091,12 @@ static int e1000_alloc_ring_dma(struct e1000_adapter *adapter, } /** - * e1000_setup_tx_resources - allocate Tx resources (Descriptors) + * e1000e_setup_tx_resources - allocate Tx resources (Descriptors) * @adapter: board private structure * * Return 0 on success, negative on failure **/ -int e1000_setup_tx_resources(struct e1000_adapter *adapter) +int e1000e_setup_tx_resources(struct e1000_adapter *adapter) { struct e1000_ring *tx_ring = adapter->tx_ring; int err = -ENOMEM, size; @@ -1387,15 +1128,16 @@ err: } /** - * e1000_setup_rx_resources - allocate Rx resources (Descriptors) + * e1000e_setup_rx_resources - allocate Rx resources (Descriptors) * @adapter: board private structure * * Returns 0 on success, negative on failure **/ -int e1000_setup_rx_resources(struct e1000_adapter *adapter) +int e1000e_setup_rx_resources(struct e1000_adapter *adapter) { struct e1000_ring *rx_ring = adapter->rx_ring; - int size, desc_len, err = -ENOMEM; + struct e1000_buffer *buffer_info; + int i, size, desc_len, err = -ENOMEM; size = sizeof(struct e1000_buffer) * rx_ring->count; rx_ring->buffer_info = vmalloc(size); @@ -1403,11 +1145,14 @@ int e1000_setup_rx_resources(struct e1000_adapter *adapter) goto err; memset(rx_ring->buffer_info, 0, size); - rx_ring->ps_pages = kcalloc(rx_ring->count * PS_PAGE_BUFFERS, - sizeof(struct e1000_ps_page), - GFP_KERNEL); - if (!rx_ring->ps_pages) - goto err; + for (i = 0; i < rx_ring->count; i++) { + buffer_info = &rx_ring->buffer_info[i]; + buffer_info->ps_pages = kcalloc(PS_PAGE_BUFFERS, + sizeof(struct e1000_ps_page), + GFP_KERNEL); + if (!buffer_info->ps_pages) + goto err_pages; + } desc_len = sizeof(union e1000_rx_desc_packet_split); @@ -1417,16 +1162,21 @@ int e1000_setup_rx_resources(struct e1000_adapter *adapter) err = e1000_alloc_ring_dma(adapter, rx_ring); if (err) - goto err; + goto err_pages; rx_ring->next_to_clean = 0; rx_ring->next_to_use = 0; rx_ring->rx_skb_top = NULL; return 0; + +err_pages: + for (i = 0; i < rx_ring->count; i++) { + buffer_info = &rx_ring->buffer_info[i]; + kfree(buffer_info->ps_pages); + } err: vfree(rx_ring->buffer_info); - kfree(rx_ring->ps_pages); ndev_err(adapter->netdev, "Unable to allocate memory for the transmit descriptor ring\n"); return err; @@ -1455,19 +1205,18 @@ static void e1000_clean_tx_ring(struct e1000_adapter *adapter) tx_ring->next_to_use = 0; tx_ring->next_to_clean = 0; - tx_ring->last_tx_tso = 0; writel(0, adapter->hw.hw_addr + tx_ring->head); writel(0, adapter->hw.hw_addr + tx_ring->tail); } /** - * e1000_free_tx_resources - Free Tx Resources per Queue + * e1000e_free_tx_resources - Free Tx Resources per Queue * @adapter: board private structure * * Free all transmit software resources **/ -void e1000_free_tx_resources(struct e1000_adapter *adapter) +void e1000e_free_tx_resources(struct e1000_adapter *adapter) { struct pci_dev *pdev = adapter->pdev; struct e1000_ring *tx_ring = adapter->tx_ring; @@ -1477,31 +1226,35 @@ void e1000_free_tx_resources(struct e1000_adapter *adapter) vfree(tx_ring->buffer_info); tx_ring->buffer_info = NULL; - pci_free_consistent(pdev, tx_ring->size, tx_ring->desc, tx_ring->dma); + dma_free_coherent(&pdev->dev, tx_ring->size, tx_ring->desc, + tx_ring->dma); tx_ring->desc = NULL; } /** - * e1000_free_rx_resources - Free Rx Resources + * e1000e_free_rx_resources - Free Rx Resources * @adapter: board private structure * * Free all receive software resources **/ -void e1000_free_rx_resources(struct e1000_adapter *adapter) +void e1000e_free_rx_resources(struct e1000_adapter *adapter) { struct pci_dev *pdev = adapter->pdev; struct e1000_ring *rx_ring = adapter->rx_ring; + int i; e1000_clean_rx_ring(adapter); + for (i = 0; i < rx_ring->count; i++) { + kfree(rx_ring->buffer_info[i].ps_pages); + } + vfree(rx_ring->buffer_info); rx_ring->buffer_info = NULL; - kfree(rx_ring->ps_pages); - rx_ring->ps_pages = NULL; - - pci_free_consistent(pdev, rx_ring->size, rx_ring->desc, rx_ring->dma); + dma_free_coherent(&pdev->dev, rx_ring->size, rx_ring->desc, + rx_ring->dma); rx_ring->desc = NULL; } @@ -1691,7 +1444,7 @@ static void e1000_vlan_rx_add_vid(struct net_device *netdev, u16 vid) index = (vid >> 5) & 0x7F; vfta = E1000_READ_REG_ARRAY(hw, E1000_VFTA, index); vfta |= (1 << (vid & 0x1F)); - e1000_write_vfta(hw, index, vfta); + e1000e_write_vfta(hw, index, vfta); } static void e1000_vlan_rx_kill_vid(struct net_device *netdev, u16 vid) @@ -1716,7 +1469,7 @@ static void e1000_vlan_rx_kill_vid(struct net_device *netdev, u16 vid) index = (vid >> 5) & 0x7F; vfta = E1000_READ_REG_ARRAY(hw, E1000_VFTA, index); vfta &= ~(1 << (vid & 0x1F)); - e1000_write_vfta(hw, index, vfta); + e1000e_write_vfta(hw, index, vfta); } static void e1000_update_mng_vlan(struct e1000_adapter *adapter) @@ -1727,6 +1480,7 @@ static void e1000_update_mng_vlan(struct e1000_adapter *adapter) if (!adapter->vlgrp) return; + if (!vlan_group_get_device(adapter->vlgrp, vid)) { adapter->mng_vlan_id = E1000_MNG_VLAN_NONE; if (adapter->hw.mng_cookie.status & @@ -1901,7 +1655,7 @@ static void e1000_configure_tx(struct e1000_adapter *adapter) ew32(TARC1, tarc); } - e1000_config_collision_dist(hw); + e1000e_config_collision_dist(hw); /* Setup Transmit Descriptor Settings for eop descriptor */ adapter->txd_cmd = E1000_TXD_CMD_EOP | E1000_TXD_CMD_IFCS; @@ -1979,7 +1733,6 @@ static void e1000_setup_rctl(struct e1000_adapter *adapter) break; } -#ifndef CONFIG_E1000_DISABLE_PACKET_SPLIT /* * 82571 and greater support packet-split where the protocol * header is placed in skb->data and the packet data is @@ -1999,7 +1752,7 @@ static void e1000_setup_rctl(struct e1000_adapter *adapter) pages = PAGE_USE_COUNT(adapter->netdev->mtu); if ((pages <= 3) && (PAGE_SIZE <= 16384) && (rctl & E1000_RCTL_LPE)) adapter->rx_ps_pages = pages; -#endif + if (adapter->rx_ps_pages) { /* Configure extra packet-split registers */ rfctl = er32(RFCTL); @@ -2011,9 +1764,11 @@ static void e1000_setup_rctl(struct e1000_adapter *adapter) ew32(RFCTL, rfctl); - /* disable the stripping of CRC because it breaks - * BMC firmware connected over SMBUS */ - rctl |= E1000_RCTL_DTYP_PS /* | E1000_RCTL_SECRC */; + /* Enable Packet split descriptors */ + rctl |= E1000_RCTL_DTYP_PS; + + /* Enable hardware CRC frame stripping */ + rctl |= E1000_RCTL_SECRC; psrctl |= adapter->rx_ps_bsize0 >> E1000_PSRCTL_BSIZE0_SHIFT; @@ -2056,11 +1811,6 @@ static void e1000_configure_rx(struct e1000_adapter *adapter) sizeof(union e1000_rx_desc_packet_split); adapter->clean_rx = e1000_clean_rx_irq_ps; adapter->alloc_rx_buf = e1000_alloc_rx_buffers_ps; - } else if (adapter->netdev->mtu > ETH_FRAME_LEN + VLAN_HLEN + 4) { - rdlen = rx_ring->count * - sizeof(struct e1000_rx_desc); - adapter->clean_rx = e1000_clean_rx_irq_jumbo; - adapter->alloc_rx_buf = e1000_alloc_rx_buffers_jumbo; } else { rdlen = rx_ring->count * sizeof(struct e1000_rx_desc); @@ -2234,14 +1984,14 @@ static void e1000_configure(struct e1000_adapter *adapter) } /** - * e1000_power_up_phy - restore link in case the phy was powered down + * e1000e_power_up_phy - restore link in case the phy was powered down * @adapter: address of board private structure * * The phy may be powered down to save power and turn off link when the * driver is unloaded and wake on lan is not enabled (among others) - * *** this routine MUST be followed by a call to e1000_reset *** + * *** this routine MUST be followed by a call to e1000e_reset *** **/ -void e1000_power_up_phy(struct e1000_adapter *adapter) +void e1000e_power_up_phy(struct e1000_adapter *adapter) { u16 mii_reg = 0; @@ -2277,7 +2027,7 @@ static void e1000_power_down_phy(struct e1000_adapter *adapter) return; /* reset is blocked because of a SoL/IDER session */ - if (e1000_check_mng_mode(hw) || + if (e1000e_check_mng_mode(hw) || e1000_check_reset_block(hw)) return; @@ -2293,20 +2043,23 @@ static void e1000_power_down_phy(struct e1000_adapter *adapter) } /** - * e1000_reset - bring the hardware into a known good state + * e1000e_reset - bring the hardware into a known good state * * This function boots the hardware and enables some settings that * require a configuration cycle of the hardware - those cannot be * set/changed during runtime. After reset the device needs to be * properly configured for rx, tx etc. */ -void e1000_reset(struct e1000_adapter *adapter) +void e1000e_reset(struct e1000_adapter *adapter) { struct e1000_mac_info *mac = &adapter->hw.mac; struct e1000_hw *hw = &adapter->hw; u32 tx_space, min_tx_space, min_rx_space; + u32 pba; u16 hwm; + ew32(PBA, adapter->pba); + if (mac->max_frame_size > ETH_FRAME_LEN + ETH_FCS_LEN ) { /* To maintain wire speed transmits, the Tx FIFO should be * large enough to accommodate two full transmit packets, @@ -2314,11 +2067,11 @@ void e1000_reset(struct e1000_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. */ - adapter->pba = er32(PBA); + pba = er32(PBA); /* upper 16 bits has Tx packet buffer allocation size in KB */ - tx_space = adapter->pba >> 16; + tx_space = pba >> 16; /* lower 16 bits has Rx packet buffer allocation size in KB */ - adapter->pba &= 0xffff; + pba &= 0xffff; /* 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 = (mac->max_frame_size + @@ -2334,20 +2087,21 @@ void e1000_reset(struct e1000_adapter *adapter) /* If current Tx allocation is less than the min Tx FIFO size, * and the min Tx FIFO size is less than the current Rx FIFO * allocation, take space away from current Rx allocation */ - if (tx_space < min_tx_space && - ((min_tx_space - tx_space) < adapter->pba)) { - adapter->pba -= - (min_tx_space - tx_space); + if ((tx_space < min_tx_space) && + ((min_tx_space - tx_space) < pba)) { + pba -= min_tx_space - tx_space; /* if short on rx space, rx wins and must trump tx * adjustment or use Early Receive if available */ - if ((adapter->pba < min_rx_space) && + if ((pba < min_rx_space) && (!(adapter->flags & FLAG_HAS_ERT))) /* ERT enabled in e1000_configure_rx */ - adapter->pba = min_rx_space; + pba = min_rx_space; } + + ew32(PBA, pba); } - ew32(PBA, adapter->pba); /* flow control settings */ /* The high water mark must be low enough to fit one full frame @@ -2385,7 +2139,7 @@ void e1000_reset(struct e1000_adapter *adapter) /* Enable h/w to recognize an 802.1Q VLAN Ethernet packet */ ew32(VET, ETH_P_8021Q); - e1000_reset_adaptive(hw); + e1000e_reset_adaptive(hw); e1000_get_phy_info(hw); if (!(adapter->flags & FLAG_SMART_POWER_DOWN)) { @@ -2401,7 +2155,7 @@ void e1000_reset(struct e1000_adapter *adapter) e1000_release_manageability(adapter); } -int e1000_up(struct e1000_adapter *adapter) +int e1000e_up(struct e1000_adapter *adapter) { struct e1000_hw *hw = &adapter->hw; @@ -2418,7 +2172,7 @@ int e1000_up(struct e1000_adapter *adapter) return 0; } -void e1000_down(struct e1000_adapter *adapter) +void e1000e_down(struct e1000_adapter *adapter) { struct net_device *netdev = adapter->netdev; struct e1000_hw *hw = &adapter->hw; @@ -2454,7 +2208,7 @@ void e1000_down(struct e1000_adapter *adapter) adapter->link_speed = 0; adapter->link_duplex = 0; - e1000_reset(adapter); + e1000e_reset(adapter); e1000_clean_tx_ring(adapter); e1000_clean_rx_ring(adapter); @@ -2464,13 +2218,13 @@ void e1000_down(struct e1000_adapter *adapter) */ } -void e1000_reinit_locked(struct e1000_adapter *adapter) +void e1000e_reinit_locked(struct e1000_adapter *adapter) { might_sleep(); while (test_and_set_bit(__E1000_RESETTING, &adapter->state)) msleep(1); - e1000_down(adapter); - e1000_up(adapter); + e1000e_down(adapter); + e1000e_up(adapter); clear_bit(__E1000_RESETTING, &adapter->state); } @@ -2541,16 +2295,16 @@ static int e1000_open(struct net_device *netdev) return -EBUSY; /* allocate transmit descriptors */ - err = e1000_setup_tx_resources(adapter); + err = e1000e_setup_tx_resources(adapter); if (err) goto err_setup_tx; /* allocate receive descriptors */ - err = e1000_setup_rx_resources(adapter); + err = e1000e_setup_rx_resources(adapter); if (err) goto err_setup_rx; - e1000_power_up_phy(adapter); + e1000e_power_up_phy(adapter); adapter->mng_vlan_id = E1000_MNG_VLAN_NONE; if ((adapter->hw.mng_cookie.status & @@ -2560,7 +2314,7 @@ static int e1000_open(struct net_device *netdev) /* If AMT is enabled, let the firmware know that the network * interface is now open */ if ((adapter->flags & FLAG_HAS_AMT) && - e1000_check_mng_mode(&adapter->hw)) + e1000e_check_mng_mode(&adapter->hw)) e1000_get_hw_control(adapter); /* before we allocate an interrupt, we must be ready to handle it. @@ -2573,7 +2327,7 @@ static int e1000_open(struct net_device *netdev) if (err) goto err_req_irq; - /* From here on the code is the same as e1000_up() */ + /* From here on the code is the same as e1000e_up() */ clear_bit(__E1000_DOWN, &adapter->state); netif_poll_enable(netdev); @@ -2588,11 +2342,11 @@ static int e1000_open(struct net_device *netdev) err_req_irq: e1000_release_hw_control(adapter); e1000_power_down_phy(adapter); - e1000_free_rx_resources(adapter); + e1000e_free_rx_resources(adapter); err_setup_rx: - e1000_free_tx_resources(adapter); + e1000e_free_tx_resources(adapter); err_setup_tx: - e1000_reset(adapter); + e1000e_reset(adapter); return err; } @@ -2613,12 +2367,12 @@ static int e1000_close(struct net_device *netdev) struct e1000_adapter *adapter = netdev_priv(netdev); WARN_ON(test_bit(__E1000_RESETTING, &adapter->state)); - e1000_down(adapter); + e1000e_down(adapter); e1000_power_down_phy(adapter); e1000_free_irq(adapter); - e1000_free_tx_resources(adapter); - e1000_free_rx_resources(adapter); + e1000e_free_tx_resources(adapter); + e1000e_free_rx_resources(adapter); /* kill manageability vlan ID if supported, but not if a vlan with * the same ID is registered on the host OS (let 8021q kill it) */ @@ -2631,7 +2385,7 @@ static int e1000_close(struct net_device *netdev) /* If AMT is enabled, let the firmware know that the network * interface is now closed */ if ((adapter->flags & FLAG_HAS_AMT) && - e1000_check_mng_mode(&adapter->hw)) + e1000e_check_mng_mode(&adapter->hw)) e1000_release_hw_control(adapter); return 0; @@ -2654,11 +2408,11 @@ static int e1000_set_mac(struct net_device *netdev, void *p) memcpy(netdev->dev_addr, addr->sa_data, netdev->addr_len); memcpy(adapter->hw.mac.addr, addr->sa_data, netdev->addr_len); - e1000_rar_set(&adapter->hw, adapter->hw.mac.addr, 0); + e1000e_rar_set(&adapter->hw, adapter->hw.mac.addr, 0); if (adapter->flags & FLAG_RESET_OVERWRITES_LAA) { /* activate the work around */ - e1000_set_laa_state_82571(&adapter->hw, 1); + e1000e_set_laa_state_82571(&adapter->hw, 1); /* Hold a copy of the LAA in RAR[14] This is done so that * between the time RAR[0] gets clobbered and the time it @@ -2666,7 +2420,7 @@ static int e1000_set_mac(struct net_device *netdev, void *p) * of the RARs and no incoming packets directed to this port * are dropped. Eventually the LAA will be in RAR[0] and * RAR[14] */ - e1000_rar_set(&adapter->hw, + e1000e_rar_set(&adapter->hw, adapter->hw.mac.addr, adapter->hw.mac.rar_entry_count - 1); } @@ -2683,10 +2437,10 @@ static void e1000_update_phy_info(unsigned long data) } /** - * e1000_update_stats - Update the board statistics counters + * e1000e_update_stats - Update the board statistics counters * @adapter: board private structure **/ -void e1000_update_stats(struct e1000_adapter *adapter) +void e1000e_update_stats(struct e1000_adapter *adapter) { struct e1000_hw *hw = &adapter->hw; struct pci_dev *pdev = adapter->pdev; @@ -2795,10 +2549,6 @@ void e1000_update_stats(struct e1000_adapter *adapter) } /* Fill out the OS statistics structure */ - adapter->net_stats.rx_packets = adapter->stats.gprc; - adapter->net_stats.tx_packets = adapter->stats.gptc; - adapter->net_stats.rx_bytes = adapter->stats.gorcl; - adapter->net_stats.tx_bytes = adapter->stats.gotcl; adapter->net_stats.multicast = adapter->stats.mprc; adapter->net_stats.collisions = adapter->stats.colc; @@ -2897,7 +2647,7 @@ static void e1000_watchdog_task(struct net_device *netdev) "Gigabit has been disabled, downgrading speed\n"); } - if ((e1000_enable_tx_pkt_filtering(hw)) && + if ((e1000e_enable_tx_pkt_filtering(hw)) && (adapter->mng_vlan_id != adapter->hw.mng_cookie.vlan_id)) e1000_update_mng_vlan(adapter); @@ -2999,7 +2749,7 @@ static void e1000_watchdog_task(struct net_device *netdev) } link_up: - e1000_update_stats(adapter); + e1000e_update_stats(adapter); mac->tx_packet_delta = adapter->stats.tpt - adapter->tpt_old; adapter->tpt_old = adapter->stats.tpt; @@ -3011,7 +2761,7 @@ link_up: adapter->gotcl = adapter->stats.gotcl - adapter->gotcl_old; adapter->gotcl_old = adapter->stats.gotcl; - e1000_update_adaptive(&adapter->hw); + e1000e_update_adaptive(&adapter->hw); if (!netif_carrier_ok(netdev)) { tx_pending = (e1000_desc_unused(tx_ring) + 1 < @@ -3034,8 +2784,8 @@ link_up: /* With 82571 controllers, LAA may be overwritten due to controller * reset from the other port. Set the appropriate LAA in RAR[0] */ - if (e1000_get_laa_state_82571(hw)) - e1000_rar_set(hw, adapter->hw.mac.addr, 0); + if (e1000e_get_laa_state_82571(hw)) + e1000e_rar_set(hw, adapter->hw.mac.addr, 0); /* Reset the timer */ if (!test_bit(__E1000_DOWN, &adapter->state)) @@ -3069,30 +2819,30 @@ static int e1000_tso(struct e1000_adapter *adapter, return err; } - hdr_len = ((skb->h.raw - skb->data) + (skb->h.th->doff << 2)); + hdr_len = skb_transport_offset(skb) + tcp_hdrlen(skb); mss = skb_shinfo(skb)->gso_size; if (skb->protocol == htons(ETH_P_IP)) { - skb->nh.iph->tot_len = 0; - skb->nh.iph->check = 0; - skb->h.th->check = ~csum_tcpudp_magic(skb->nh.iph->saddr, - skb->nh.iph->daddr, 0, - IPPROTO_TCP, - 0); + struct iphdr *iph = ip_hdr(skb); + iph->tot_len = 0; + iph->check = 0; + tcp_hdr(skb)->check = ~csum_tcpudp_magic(iph->saddr, + iph->daddr, 0, + IPPROTO_TCP, + 0); cmd_length = E1000_TXD_CMD_IP; - ipcse = skb->h.raw - skb->data - 1; + ipcse = skb_transport_offset(skb) - 1; } else if (skb_shinfo(skb)->gso_type == SKB_GSO_TCPV6) { - skb->nh.ipv6h->payload_len = 0; - skb->h.th->check = - ~csum_ipv6_magic(&skb->nh.ipv6h->saddr, - &skb->nh.ipv6h->daddr, + 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); ipcse = 0; } - - ipcss = skb->nh.raw - skb->data; - ipcso = (void *)&(skb->nh.iph->check) - (void *)skb->data; - tucss = skb->h.raw - skb->data; - tucso = (void *)&(skb->h.th->check) - (void *)skb->data; + ipcss = skb_network_offset(skb); + ipcso = (void *)&(ip_hdr(skb)->check) - (void *)skb->data; + tucss = skb_transport_offset(skb); + tucso = (void *)&(tcp_hdr(skb)->check) - (void *)skb->data; tucse = 0; cmd_length |= (E1000_TXD_CMD_DEXT | E1000_TXD_CMD_TSE | @@ -3135,7 +2885,7 @@ static bool e1000_tx_csum(struct e1000_adapter *adapter, struct sk_buff *skb) u8 css; if (skb->ip_summed == CHECKSUM_PARTIAL) { - css = skb->h.raw - skb->data; + css = skb_transport_offset(skb); i = tx_ring->next_to_use; buffer_info = &tx_ring->buffer_info[i]; @@ -3181,15 +2931,6 @@ static int e1000_tx_map(struct e1000_adapter *adapter, while (len) { buffer_info = &tx_ring->buffer_info[i]; size = min(len, max_per_txd); - /* Workaround for Controller erratum -- - * descriptor for non-tso packet in a linear SKB that follows a - * tso gets written back prematurely before the data is fully - * DMA'd to the controller */ - if (tx_ring->last_tx_tso && !skb_is_gso(skb)) { - tx_ring->last_tx_tso = 0; - if (!skb->data_len) - size -= 4; - } /* Workaround for premature desc write-backs * in TSO mode. Append 4-byte sentinel desc */ @@ -3204,6 +2945,11 @@ static int e1000_tx_map(struct e1000_adapter *adapter, skb->data + offset, size, PCI_DMA_TODEVICE); + if (pci_dma_mapping_error(buffer_info->dma)) { + dev_err(&adapter->pdev->dev, "TX DMA map failed\n"); + adapter->tx_dma_failed++; + return -1; + } buffer_info->next_to_watch = i; len -= size; @@ -3237,6 +2983,13 @@ static int e1000_tx_map(struct e1000_adapter *adapter, offset, size, PCI_DMA_TODEVICE); + if (pci_dma_mapping_error(buffer_info->dma)) { + dev_err(&adapter->pdev->dev, + "TX DMA page map failed\n"); + adapter->tx_dma_failed++; + return -1; + } + buffer_info->next_to_watch = i; len -= size; @@ -3351,7 +3104,7 @@ static int e1000_transfer_dhcp_info(struct e1000_adapter *adapter, offset = (u8 *)udp + 8 - skb->data; length = skb->len - offset; - return e1000_mng_write_dhcp_info(hw, (u8 *)udp + 8, length); + return e1000e_mng_write_dhcp_info(hw, (u8 *)udp + 8, length); } return 0; @@ -3396,14 +3149,13 @@ static int e1000_xmit_frame(struct sk_buff *skb, struct net_device *netdev) unsigned int max_per_txd = E1000_MAX_PER_TXD; unsigned int max_txd_pwr = E1000_MAX_TXD_PWR; unsigned int tx_flags = 0; - unsigned int len = skb->len; + unsigned int len = skb->len - skb->data_len; unsigned long irq_flags; - unsigned int nr_frags = 0; - unsigned int mss = 0; + unsigned int nr_frags; + unsigned int mss; int count = 0; int tso; unsigned int f; - len -= skb->data_len; if (test_bit(__E1000_DOWN, &adapter->state)) { dev_kfree_skb_any(skb); @@ -3430,8 +3182,8 @@ static int e1000_xmit_frame(struct sk_buff *skb, struct net_device *netdev) /* TSO Workaround for 82571/2/3 Controllers -- if skb->data * points to just header, pull a few bytes of payload from * frags into skb->data */ - hdr_len = ((skb->h.raw - skb->data) + (skb->h.th->doff << 2)); - if (skb->data_len && (hdr_len == (skb->len - skb->data_len))) { + hdr_len = skb_transport_offset(skb) + tcp_hdrlen(skb); + if (skb->data_len && (hdr_len == len)) { unsigned int pull_size; pull_size = min((unsigned int)4, skb->data_len); @@ -3450,10 +3202,6 @@ static int e1000_xmit_frame(struct sk_buff *skb, struct net_device *netdev) count++; count++; - /* Controller Erratum workaround */ - if (!skb->data_len && tx_ring->last_tx_tso && !skb_is_gso(skb)) - count++; - count += TXD_USE_COUNT(len, max_txd_pwr); nr_frags = skb_shinfo(skb)->nr_frags; @@ -3489,12 +3237,10 @@ static int e1000_xmit_frame(struct sk_buff *skb, struct net_device *netdev) return NETDEV_TX_OK; } - if (tso) { - tx_ring->last_tx_tso = 1; + if (tso) tx_flags |= E1000_TX_FLAGS_TSO; - } else if (e1000_tx_csum(adapter, skb)) { + else if (e1000_tx_csum(adapter, skb)) tx_flags |= E1000_TX_FLAGS_CSUM; - } /* Old method was to assume IPv4 packet by default if TSO was enabled. * 82571 hardware supports TSO capabilities for IPv6 as well... @@ -3502,9 +3248,15 @@ static int e1000_xmit_frame(struct sk_buff *skb, struct net_device *netdev) if (skb->protocol == htons(ETH_P_IP)) tx_flags |= E1000_TX_FLAGS_IPV4; - e1000_tx_queue(adapter, tx_flags, - e1000_tx_map(adapter, skb, first, - max_per_txd, nr_frags, mss)); + count = e1000_tx_map(adapter, skb, first, max_per_txd, nr_frags, mss); + if (count < 0) { + /* handle pci_map_single() error in e1000_tx_map */ + dev_kfree_skb_any(skb); + spin_unlock_irqrestore(&adapter->tx_queue_lock, irq_flags); + return NETDEV_TX_OK; + } + + e1000_tx_queue(adapter, tx_flags, count); netdev->trans_start = jiffies; @@ -3532,7 +3284,7 @@ static void e1000_reset_task(struct net_device *netdev) { struct e1000_adapter *adapter = netdev_priv(netdev); - e1000_reinit_locked(adapter); + e1000e_reinit_locked(adapter); } /** @@ -3588,17 +3340,15 @@ static int e1000_change_mtu(struct net_device *netdev, int new_mtu) while (test_and_set_bit(__E1000_RESETTING, &adapter->state)) msleep(1); - /* e1000_down has a dependency on max_frame_size */ + /* e1000e_down has a dependency on max_frame_size */ adapter->hw.mac.max_frame_size = max_frame; if (netif_running(netdev)) - e1000_down(adapter); + e1000e_down(adapter); /* NOTE: netdev_alloc_skb reserves 16 bytes, and typically NET_IP_ALIGN * means we reserve 2 more, this pushes us to allocate from the next * larger slab size. - * i.e. RXBUFFER_2048 --> size-4096 slab - * however with the new *_jumbo* routines, jumbo receives will use - * fragmented skbs */ + * i.e. RXBUFFER_2048 --> size-4096 slab */ if (max_frame <= 256) adapter->rx_buffer_len = 256; @@ -3622,9 +3372,9 @@ static int e1000_change_mtu(struct net_device *netdev, int new_mtu) netdev->mtu = new_mtu; if (netif_running(netdev)) - e1000_up(adapter); + e1000e_up(adapter); else - e1000_reset(adapter); + e1000e_reset(adapter); clear_bit(__E1000_RESETTING, &adapter->state); @@ -3688,7 +3438,7 @@ static int e1000_suspend(struct pci_dev *pdev, pm_message_t state) if (netif_running(netdev)) { WARN_ON(test_bit(__E1000_RESETTING, &adapter->state)); - e1000_down(adapter); + e1000e_down(adapter); e1000_free_irq(adapter); } @@ -3729,7 +3479,7 @@ static int e1000_suspend(struct pci_dev *pdev, pm_message_t state) } /* Allow time for pending master requests to run */ - e1000_disable_pcie_master(&adapter->hw); + e1000e_disable_pcie_master(&adapter->hw); ew32(WUC, E1000_WUC_PME_EN); ew32(WUFC, wufc); @@ -3751,7 +3501,7 @@ static int e1000_suspend(struct pci_dev *pdev, pm_message_t state) } if (adapter->hw.phy.type == e1000_phy_igp_3) - e1000_igp3_phy_powerdown_workaround_ich8lan(&adapter->hw); + e1000e_igp3_phy_powerdown_workaround_ich8lan(&adapter->hw); /* Release control of h/w to f/w. If f/w is AMT enabled, this * would have already happened in close and is redundant. */ @@ -3764,6 +3514,33 @@ static int e1000_suspend(struct pci_dev *pdev, pm_message_t state) return 0; } +static void e1000e_disable_l1aspm(struct pci_dev *pdev) +{ + int pos; + u32 cap; + u16 val; + + /* + * 82573 workaround - disable L1 ASPM on mobile chipsets + * + * L1 ASPM on various mobile (ich7) chipsets do not behave properly + * resulting in lost data or garbage information on the pci-e link + * level. This could result in (false) bad EEPROM checksum errors, + * long ping times (up to 2s) or even a system freeze/hang. + * + * Unfortunately this feature saves about 1W power consumption when + * active. + */ + pos = pci_find_capability(pdev, PCI_CAP_ID_EXP); + pci_read_config_dword(pdev, pos + PCI_EXP_LNKCAP, &cap); + pci_read_config_word(pdev, pos + PCI_EXP_LNKCTL, &val); + if (val & 0x2) { + dev_warn(&pdev->dev, "Disabling L1 ASPM\n"); + val &= ~0x2; + pci_write_config_word(pdev, pos + PCI_EXP_LNKCTL, val); + } +} + #ifdef CONFIG_PM static int e1000_resume(struct pci_dev *pdev) { @@ -3774,6 +3551,7 @@ static int e1000_resume(struct pci_dev *pdev) pci_set_power_state(pdev, PCI_D0); pci_restore_state(pdev); + e1000e_disable_l1aspm(pdev); err = pci_enable_device(pdev); if (err) { dev_err(&pdev->dev, @@ -3792,21 +3570,21 @@ static int e1000_resume(struct pci_dev *pdev) return err; } - e1000_power_up_phy(adapter); - e1000_reset(adapter); + e1000e_power_up_phy(adapter); + e1000e_reset(adapter); ew32(WUS, ~0); e1000_init_manageability(adapter); if (netif_running(netdev)) - e1000_up(adapter); + e1000e_up(adapter); netif_device_attach(netdev); /* If the controller has AMT, do not set DRV_LOAD until the interface * is up. For all other cases, let the f/w know that the h/w is now * under the control of the driver. */ - if (!(adapter->flags & FLAG_HAS_AMT) || !e1000_check_mng_mode(&adapter->hw)) + if (!(adapter->flags & FLAG_HAS_AMT) || !e1000e_check_mng_mode(&adapter->hw)) e1000_get_hw_control(adapter); return 0; @@ -3854,7 +3632,7 @@ static pci_ers_result_t e1000_io_error_detected(struct pci_dev *pdev, netif_device_detach(netdev); if (netif_running(netdev)) - e1000_down(adapter); + e1000e_down(adapter); pci_disable_device(pdev); /* Request a slot slot reset. */ @@ -3874,6 +3652,7 @@ static pci_ers_result_t e1000_io_slot_reset(struct pci_dev *pdev) struct e1000_adapter *adapter = netdev_priv(netdev); struct e1000_hw *hw = &adapter->hw; + e1000e_disable_l1aspm(pdev); if (pci_enable_device(pdev)) { dev_err(&pdev->dev, "Cannot re-enable PCI device after reset.\n"); @@ -3884,7 +3663,7 @@ static pci_ers_result_t e1000_io_slot_reset(struct pci_dev *pdev) pci_enable_wake(pdev, PCI_D3hot, 0); pci_enable_wake(pdev, PCI_D3cold, 0); - e1000_reset(adapter); + e1000e_reset(adapter); ew32(WUS, ~0); return PCI_ERS_RESULT_RECOVERED; @@ -3906,7 +3685,7 @@ static void e1000_io_resume(struct pci_dev *pdev) e1000_init_manageability(adapter); if (netif_running(netdev)) { - if (e1000_up(adapter)) { + if (e1000e_up(adapter)) { dev_err(&pdev->dev, "can't bring device back up after reset\n"); return; @@ -3919,7 +3698,7 @@ static void e1000_io_resume(struct pci_dev *pdev) * is up. For all other cases, let the f/w know that the h/w is now * under the control of the driver. */ if (!(adapter->flags & FLAG_HAS_AMT) || - !e1000_check_mng_mode(&adapter->hw)) + !e1000e_check_mng_mode(&adapter->hw)) e1000_get_hw_control(adapter); } @@ -3928,6 +3707,7 @@ static void e1000_print_device_info(struct e1000_adapter *adapter) { struct e1000_hw *hw = &adapter->hw; struct net_device *netdev = adapter->netdev; + u32 part_num; /* print bus type/speed/width info */ ndev_info(netdev, "(PCI Express:2.5GB/s:%s) " @@ -3942,6 +3722,10 @@ static void e1000_print_device_info(struct e1000_adapter *adapter) ndev_info(netdev, "Intel(R) PRO/%s Network Connection\n", (hw->phy.type == e1000_phy_ife) ? "10/100" : "1000"); + e1000e_read_part_num(hw, &part_num); + ndev_info(netdev, "MAC: %d, PHY: %d, PBA No: %06x-%03x\n", + hw->mac.type, hw->phy.type, + (part_num >> 8), (part_num & 0xff)); } /** @@ -3970,6 +3754,7 @@ static int __devinit e1000_probe(struct pci_dev *pdev, u16 eeprom_data = 0; u16 eeprom_apme_mask = E1000_EEPROM_APME; + e1000e_disable_l1aspm(pdev); err = pci_enable_device(pdev); if (err) return err; @@ -3993,7 +3778,7 @@ static int __devinit e1000_probe(struct pci_dev *pdev, } } - err = pci_request_regions(pdev, e1000_driver_name); + err = pci_request_regions(pdev, e1000e_driver_name); if (err) goto err_pci_reg; @@ -4045,7 +3830,7 @@ static int __devinit e1000_probe(struct pci_dev *pdev, netdev->set_mac_address = &e1000_set_mac; netdev->change_mtu = &e1000_change_mtu; netdev->do_ioctl = &e1000_ioctl; - e1000_set_ethtool_ops(netdev); + e1000e_set_ethtool_ops(netdev); netdev->tx_timeout = &e1000_tx_timeout; netdev->watchdog_timeo = 5 * HZ; netdev->poll = &e1000_clean; @@ -4111,7 +3896,7 @@ static int __devinit e1000_probe(struct pci_dev *pdev, * it. */ netdev->features |= NETIF_F_LLTX; - if (e1000_enable_mng_pass_thru(&adapter->hw)) + if (e1000e_enable_mng_pass_thru(&adapter->hw)) adapter->flags |= FLAG_MNG_PT_ENABLED; /* before reading the NVM, reset the controller to @@ -4133,7 +3918,7 @@ static int __devinit e1000_probe(struct pci_dev *pdev, } /* copy the MAC address out of the NVM */ - if (e1000_read_mac_addr(&adapter->hw)) + if (e1000e_read_mac_addr(&adapter->hw)) ndev_err(netdev, "NVM Read Error while reading MAC address\n"); memcpy(netdev->dev_addr, adapter->hw.mac.addr, netdev->addr_len); @@ -4157,15 +3942,16 @@ static int __devinit e1000_probe(struct pci_dev *pdev, adapter->phy_info_timer.function = &e1000_update_phy_info; adapter->phy_info_timer.data = (unsigned long) adapter; - INIT_WORK(&adapter->reset_task, + INIT_WORK(&adapter->reset_task, (void (*)(void *))e1000_reset_task, netdev); - INIT_WORK(&adapter->watchdog_task, + INIT_WORK(&adapter->watchdog_task, (void (*)(void *))e1000_watchdog_task, netdev); - e1000_check_options(adapter); + e1000e_check_options(adapter); /* Initialize link parameters. User can change them with ethtool */ adapter->hw.mac.autoneg = 1; + adapter->fc_autoneg = 1; adapter->hw.mac.original_fc = e1000_fc_default; adapter->hw.mac.fc = e1000_fc_default; adapter->hw.phy.autoneg_advertised = 0x2f; @@ -4208,19 +3994,18 @@ static int __devinit e1000_probe(struct pci_dev *pdev, adapter->wol = adapter->eeprom_wol; /* reset the hardware with the new settings */ - e1000_reset(adapter); + e1000e_reset(adapter); /* If the controller has AMT, do not set DRV_LOAD until the interface * is up. For all other cases, let the f/w know that the h/w is now * under the control of the driver. */ if (!(adapter->flags & FLAG_HAS_AMT) || - !e1000_check_mng_mode(&adapter->hw)) + !e1000e_check_mng_mode(&adapter->hw)) e1000_get_hw_control(adapter); /* tell the stack to leave us alone until e1000_open() is called */ netif_carrier_off(netdev); netif_stop_queue(netdev); - netif_poll_disable(netdev); strcpy(netdev->name, "eth%d"); err = register_netdev(netdev); @@ -4309,17 +4094,16 @@ static struct pci_error_handlers e1000_err_handler = { .resume = e1000_io_resume, }; -static struct pci_device_id e1000e_pci_tbl[] = { - /* - * Support for 82571/2/3, es2lan and ich8 will be phased in - * stepwise. - +static struct pci_device_id e1000_pci_tbl[] = { { PCI_VDEVICE(INTEL, E1000_DEV_ID_82571EB_COPPER), board_82571 }, { PCI_VDEVICE(INTEL, E1000_DEV_ID_82571EB_FIBER), board_82571 }, { PCI_VDEVICE(INTEL, E1000_DEV_ID_82571EB_QUAD_COPPER), board_82571 }, { PCI_VDEVICE(INTEL, E1000_DEV_ID_82571EB_QUAD_COPPER_LP), board_82571 }, { PCI_VDEVICE(INTEL, E1000_DEV_ID_82571EB_QUAD_FIBER), board_82571 }, { PCI_VDEVICE(INTEL, E1000_DEV_ID_82571EB_SERDES), board_82571 }, + { PCI_VDEVICE(INTEL, E1000_DEV_ID_82571EB_SERDES_DUAL), board_82571 }, + { PCI_VDEVICE(INTEL, E1000_DEV_ID_82571EB_SERDES_QUAD), board_82571 }, + { PCI_VDEVICE(INTEL, E1000_DEV_ID_82571PT_QUAD_COPPER), board_82571 }, { PCI_VDEVICE(INTEL, E1000_DEV_ID_82572EI), board_82572 }, { PCI_VDEVICE(INTEL, E1000_DEV_ID_82572EI_COPPER), board_82572 }, { PCI_VDEVICE(INTEL, E1000_DEV_ID_82572EI_FIBER), board_82572 }, @@ -4342,8 +4126,6 @@ static struct pci_device_id e1000e_pci_tbl[] = { { PCI_VDEVICE(INTEL, E1000_DEV_ID_ICH8_IGP_C), board_ich8lan }, { PCI_VDEVICE(INTEL, E1000_DEV_ID_ICH8_IGP_M), board_ich8lan }, { PCI_VDEVICE(INTEL, E1000_DEV_ID_ICH8_IGP_M_AMT), board_ich8lan }, - */ - { PCI_VDEVICE(INTEL, E1000_DEV_ID_ICH9_IFE), board_ich9lan }, { PCI_VDEVICE(INTEL, E1000_DEV_ID_ICH9_IFE_G), board_ich9lan }, { PCI_VDEVICE(INTEL, E1000_DEV_ID_ICH9_IFE_GT), board_ich9lan }, @@ -4352,12 +4134,12 @@ static struct pci_device_id e1000e_pci_tbl[] = { { } /* terminate list */ }; -MODULE_DEVICE_TABLE(pci, e1000e_pci_tbl); +MODULE_DEVICE_TABLE(pci, e1000_pci_tbl); /* PCI Device API Driver */ static struct pci_driver e1000_driver = { - .name = e1000_driver_name, - .id_table = e1000e_pci_tbl, + .name = e1000e_driver_name, + .id_table = e1000_pci_tbl, .probe = e1000_probe, .remove = __devexit_p(e1000_remove), #ifdef CONFIG_PM @@ -4375,17 +4157,18 @@ static struct pci_driver e1000_driver = { * e1000_init_module is the first routine called when the driver is * loaded. All it does is register with the PCI subsystem. **/ -static int __init e1000e_init_module(void) +static int __init e1000_init_module(void) { int ret; - printk(KERN_INFO "Intel(R) PRO/1000 Network Driver - %s\n", - e1000_driver_version); - printk(KERN_INFO "Copyright (c) 1999-2007 Intel Corporation.\n"); + printk(KERN_INFO "%s: Intel(R) PRO/1000 Network Driver - %s\n", + e1000e_driver_name, e1000e_driver_version); + printk(KERN_INFO "%s: Copyright (c) 1999-2007 Intel Corporation.\n", + e1000e_driver_name); ret = pci_register_driver(&e1000_driver); return ret; } -module_init(e1000e_init_module); +module_init(e1000_init_module); /** * e1000_exit_module - Driver Exit Cleanup Routine @@ -4393,11 +4176,11 @@ module_init(e1000e_init_module); * e1000_exit_module is called just before the driver is removed * from memory. **/ -static void __exit e1000e_exit_module(void) +static void __exit e1000_exit_module(void) { pci_unregister_driver(&e1000_driver); } -module_exit(e1000e_exit_module); +module_exit(e1000_exit_module); MODULE_AUTHOR("Intel Corporation, <linux.nics@intel.com>"); diff --git a/drivers/net/e1000e/param.c b/drivers/net/e1000e/param.c index 9a70d22..df266c3 100644 --- a/drivers/net/e1000e/param.c +++ b/drivers/net/e1000e/param.c @@ -52,10 +52,11 @@ MODULE_PARM_DESC(copybreak, */ #define E1000_PARAM_INIT { [0 ... E1000_MAX_NIC] = OPTION_UNSET } -#define E1000_PARAM(X, desc) \ - static int __devinitdata X[E1000_MAX_NIC+1] = E1000_PARAM_INIT; \ - static int num_##X; \ - module_param_array_named(X, X, int, &num_##X, 0); \ +#define E1000_PARAM(X, desc) \ + static int __devinitdata X[E1000_MAX_NIC+1] \ + = E1000_PARAM_INIT; \ + static unsigned int num_##X; \ + module_param_array_named(X, X, int, &num_##X, 0); \ MODULE_PARM_DESC(X, desc); @@ -124,9 +125,9 @@ E1000_PARAM(KumeranLockLoss, "Enable Kumeran lock loss workaround"); struct e1000_option { enum { enable_option, range_option, list_option } type; - char *name; - char *err; - int def; + const char *name; + const char *err; + int def; union { struct { /* range_option info */ int min; @@ -139,8 +140,8 @@ struct e1000_option { } arg; }; -static int __devinit e1000_validate_option(int *value, - struct e1000_option *opt, +static int __devinit e1000_validate_option(unsigned int *value, + const struct e1000_option *opt, struct e1000_adapter *adapter) { if (*value == OPTION_UNSET) { @@ -192,7 +193,7 @@ static int __devinit e1000_validate_option(int *value, } /** - * e1000_check_options - Range Checking for Command Line Parameters + * e1000e_check_options - Range Checking for Command Line Parameters * @adapter: board private structure * * This routine checks all command line parameters for valid user @@ -200,7 +201,7 @@ static int __devinit e1000_validate_option(int *value, * value exists, a default value is used. The final value is stored * in a variable in the adapter structure. **/ -void __devinit e1000_check_options(struct e1000_adapter *adapter) +void __devinit e1000e_check_options(struct e1000_adapter *adapter) { struct e1000_hw *hw = &adapter->hw; struct net_device *netdev = adapter->netdev; @@ -213,7 +214,7 @@ void __devinit e1000_check_options(struct e1000_adapter *adapter) } { /* Transmit Interrupt Delay */ - struct e1000_option opt = { + const struct e1000_option opt = { .type = range_option, .name = "Transmit Interrupt Delay", .err = "using default of " @@ -232,7 +233,7 @@ void __devinit e1000_check_options(struct e1000_adapter *adapter) } } { /* Transmit Absolute Interrupt Delay */ - struct e1000_option opt = { + const struct e1000_option opt = { .type = range_option, .name = "Transmit Absolute Interrupt Delay", .err = "using default of " @@ -261,13 +262,6 @@ void __devinit e1000_check_options(struct e1000_adapter *adapter) .max = MAX_RXDELAY } } }; - /* modify min and default if 82573 for slow ping w/a, - * a value greater than 8 needs to be set for RDTR */ - if (adapter->flags & FLAG_HAS_ASPM) { - opt.def = 32; - opt.arg.r.min = 8; - } - if (num_RxIntDelay > bd) { adapter->rx_int_delay = RxIntDelay[bd]; e1000_validate_option(&adapter->rx_int_delay, &opt, @@ -277,7 +271,7 @@ void __devinit e1000_check_options(struct e1000_adapter *adapter) } } { /* Receive Absolute Interrupt Delay */ - struct e1000_option opt = { + const struct e1000_option opt = { .type = range_option, .name = "Receive Absolute Interrupt Delay", .err = "using default of " @@ -296,7 +290,7 @@ void __devinit e1000_check_options(struct e1000_adapter *adapter) } } { /* Interrupt Throttling Rate */ - struct e1000_option opt = { + const struct e1000_option opt = { .type = range_option, .name = "Interrupt Throttling Rate (ints/sec)", .err = "using default of " @@ -344,7 +338,7 @@ void __devinit e1000_check_options(struct e1000_adapter *adapter) } } { /* Smart Power Down */ - struct e1000_option opt = { + const struct e1000_option opt = { .type = enable_option, .name = "PHY Smart Power Down", .err = "defaulting to Disabled", @@ -352,7 +346,7 @@ void __devinit e1000_check_options(struct e1000_adapter *adapter) }; if (num_SmartPowerDownEnable > bd) { - int spd = SmartPowerDownEnable[bd]; + unsigned int spd = SmartPowerDownEnable[bd]; e1000_validate_option(&spd, &opt, adapter); if ((adapter->flags & FLAG_HAS_SMART_POWER_DOWN) && spd) @@ -360,7 +354,7 @@ void __devinit e1000_check_options(struct e1000_adapter *adapter) } } { /* Kumeran Lock Loss Workaround */ - struct e1000_option opt = { + const struct e1000_option opt = { .type = enable_option, .name = "Kumeran Lock Loss Workaround", .err = "defaulting to Enabled", @@ -368,14 +362,14 @@ void __devinit e1000_check_options(struct e1000_adapter *adapter) }; if (num_KumeranLockLoss > bd) { - int kmrn_lock_loss = KumeranLockLoss[bd]; + unsigned int kmrn_lock_loss = KumeranLockLoss[bd]; e1000_validate_option(&kmrn_lock_loss, &opt, adapter); if (hw->mac.type == e1000_ich8lan) - e1000_set_kmrn_lock_loss_workaround_ich8lan(hw, + e1000e_set_kmrn_lock_loss_workaround_ich8lan(hw, kmrn_lock_loss); } else { if (hw->mac.type == e1000_ich8lan) - e1000_set_kmrn_lock_loss_workaround_ich8lan(hw, + e1000e_set_kmrn_lock_loss_workaround_ich8lan(hw, opt.def); } } diff --git a/drivers/net/e1000e/phy.c b/drivers/net/e1000e/phy.c index 1ccbad7..fc6fee1 100644 --- a/drivers/net/e1000e/phy.c +++ b/drivers/net/e1000e/phy.c @@ -26,6 +26,8 @@ *******************************************************************************/ +#include <linux/delay.h> + #include "e1000.h" static s32 e1000_get_phy_cfg_done(struct e1000_hw *hw); @@ -47,18 +49,17 @@ static const u16 e1000_igp_2_cable_length_table[] = 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])) + ARRAY_SIZE(e1000_igp_2_cable_length_table) /** - * e1000_check_reset_block_generic - Check if PHY reset is blocked + * e1000e_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 * return E1000_BLK_PHY_RESET (12). **/ -s32 e1000_check_reset_block_generic(struct e1000_hw *hw) +s32 e1000e_check_reset_block_generic(struct e1000_hw *hw) { u32 manc; @@ -69,13 +70,13 @@ s32 e1000_check_reset_block_generic(struct e1000_hw *hw) } /** - * e1000_get_phy_id - Retrieve the PHY ID and revision + * e1000e_get_phy_id - Retrieve the PHY ID and revision * @hw: pointer to the HW structure * * Reads the PHY registers and stores the PHY ID and possibly the PHY * revision in the hardware structure. **/ -s32 e1000_get_phy_id(struct e1000_hw *hw) +s32 e1000e_get_phy_id(struct e1000_hw *hw) { struct e1000_phy_info *phy = &hw->phy; s32 ret_val; @@ -98,12 +99,12 @@ s32 e1000_get_phy_id(struct e1000_hw *hw) } /** - * e1000_phy_reset_dsp - Reset PHY DSP + * e1000e_phy_reset_dsp - Reset PHY DSP * @hw: pointer to the HW structure * * Reset the digital signal processor. **/ -s32 e1000_phy_reset_dsp(struct e1000_hw *hw) +s32 e1000e_phy_reset_dsp(struct e1000_hw *hw) { s32 ret_val; @@ -208,7 +209,7 @@ static s32 e1000_write_phy_reg_mdic(struct e1000_hw *hw, u32 offset, u16 data) } /** - * e1000_read_phy_reg_m88 - Read m88 PHY register + * e1000e_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 @@ -217,7 +218,7 @@ static s32 e1000_write_phy_reg_mdic(struct e1000_hw *hw, u32 offset, u16 data) * 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 e1000e_read_phy_reg_m88(struct e1000_hw *hw, u32 offset, u16 *data) { s32 ret_val; @@ -235,7 +236,7 @@ s32 e1000_read_phy_reg_m88(struct e1000_hw *hw, u32 offset, u16 *data) } /** - * e1000_write_phy_reg_m88 - Write m88 PHY register + * e1000e_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 @@ -243,7 +244,7 @@ s32 e1000_read_phy_reg_m88(struct e1000_hw *hw, u32 offset, u16 *data) * 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 e1000e_write_phy_reg_m88(struct e1000_hw *hw, u32 offset, u16 data) { s32 ret_val; @@ -261,7 +262,7 @@ s32 e1000_write_phy_reg_m88(struct e1000_hw *hw, u32 offset, u16 data) } /** - * e1000_read_phy_reg_igp - Read igp PHY register + * e1000e_read_phy_reg_igp - Read igp PHY register * @hw: pointer to the HW structure * @offset: register offset to be read * @data: pointer to the read data @@ -270,7 +271,7 @@ s32 e1000_write_phy_reg_m88(struct e1000_hw *hw, u32 offset, u16 data) * and storing the retrieved information in data. Release any acquired * semaphores before exiting. **/ -s32 e1000_read_phy_reg_igp(struct e1000_hw *hw, u32 offset, u16 *data) +s32 e1000e_read_phy_reg_igp(struct e1000_hw *hw, u32 offset, u16 *data) { s32 ret_val; @@ -298,7 +299,7 @@ s32 e1000_read_phy_reg_igp(struct e1000_hw *hw, u32 offset, u16 *data) } /** - * e1000_write_phy_reg_igp - Write igp PHY register + * e1000e_write_phy_reg_igp - Write igp PHY register * @hw: pointer to the HW structure * @offset: register offset to write to * @data: data to write at register offset @@ -306,7 +307,7 @@ s32 e1000_read_phy_reg_igp(struct e1000_hw *hw, u32 offset, u16 *data) * 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_igp(struct e1000_hw *hw, u32 offset, u16 data) +s32 e1000e_write_phy_reg_igp(struct e1000_hw *hw, u32 offset, u16 data) { s32 ret_val; @@ -334,7 +335,7 @@ s32 e1000_write_phy_reg_igp(struct e1000_hw *hw, u32 offset, u16 data) } /** - * e1000_read_kmrn_reg - Read kumeran register + * e1000e_read_kmrn_reg - Read kumeran register * @hw: pointer to the HW structure * @offset: register offset to be read * @data: pointer to the read data @@ -343,7 +344,7 @@ s32 e1000_write_phy_reg_igp(struct e1000_hw *hw, u32 offset, u16 data) * using the kumeran interface. The information retrieved is stored in data. * Release any acquired semaphores before exiting. **/ -s32 e1000_read_kmrn_reg(struct e1000_hw *hw, u32 offset, u16 *data) +s32 e1000e_read_kmrn_reg(struct e1000_hw *hw, u32 offset, u16 *data) { u32 kmrnctrlsta; s32 ret_val; @@ -367,7 +368,7 @@ s32 e1000_read_kmrn_reg(struct e1000_hw *hw, u32 offset, u16 *data) } /** - * e1000_write_kmrn_reg - Write kumeran register + * e1000e_write_kmrn_reg - Write kumeran register * @hw: pointer to the HW structure * @offset: register offset to write to * @data: data to write at register offset @@ -376,7 +377,7 @@ s32 e1000_read_kmrn_reg(struct e1000_hw *hw, u32 offset, u16 *data) * at the offset using the kumeran interface. Release any acquired semaphores * before exiting. **/ -s32 e1000_write_kmrn_reg(struct e1000_hw *hw, u32 offset, u16 data) +s32 e1000e_write_kmrn_reg(struct e1000_hw *hw, u32 offset, u16 data) { u32 kmrnctrlsta; s32 ret_val; @@ -396,13 +397,13 @@ s32 e1000_write_kmrn_reg(struct e1000_hw *hw, u32 offset, u16 data) } /** - * e1000_copper_link_setup_m88 - Setup m88 PHY's for copper link + * e1000e_copper_link_setup_m88 - Setup m88 PHY's for copper link * @hw: pointer to the HW structure * * Sets up MDI/MDI-X and polarity for m88 PHY's. If necessary, transmit clock * and downshift values are set also. **/ -s32 e1000_copper_link_setup_m88(struct e1000_hw *hw) +s32 e1000e_copper_link_setup_m88(struct e1000_hw *hw) { struct e1000_phy_info *phy = &hw->phy; s32 ret_val; @@ -482,7 +483,7 @@ s32 e1000_copper_link_setup_m88(struct e1000_hw *hw) } /* Commit the changes. */ - ret_val = e1000_commit_phy(hw); + ret_val = e1000e_commit_phy(hw); if (ret_val) hw_dbg(hw, "Error committing the PHY changes\n"); @@ -490,13 +491,13 @@ s32 e1000_copper_link_setup_m88(struct e1000_hw *hw) } /** - * e1000_copper_link_setup_igp - Setup igp PHY's for copper link + * e1000e_copper_link_setup_igp - Setup igp PHY's for copper link * @hw: pointer to the HW structure * * Sets up LPLU, MDI/MDI-X, polarity, Smartspeed and Master/Slave config for * igp PHY's. **/ -s32 e1000_copper_link_setup_igp(struct e1000_hw *hw) +s32 e1000e_copper_link_setup_igp(struct e1000_hw *hw) { struct e1000_phy_info *phy = &hw->phy; s32 ret_val; @@ -713,7 +714,7 @@ static s32 e1000_phy_setup_autoneg(struct e1000_hw *hw) /* 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 - * (in e1000_config_fc_after_link_up) we will disable the + * (in e1000e_config_fc_after_link_up) we will disable the * hw's ability to send PAUSE frames. */ mii_autoneg_adv_reg |= (NWAY_AR_ASM_DIR | NWAY_AR_PAUSE); @@ -814,7 +815,7 @@ static s32 e1000_copper_link_autoneg(struct e1000_hw *hw) } /** - * e1000_setup_copper_link - Configure copper link settings + * e1000e_setup_copper_link - Configure copper link settings * @hw: pointer to the HW structure * * Calls the appropriate function to configure the link for auto-neg or forced @@ -822,7 +823,7 @@ static s32 e1000_copper_link_autoneg(struct e1000_hw *hw) * 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(struct e1000_hw *hw) +s32 e1000e_setup_copper_link(struct e1000_hw *hw) { s32 ret_val; bool link; @@ -847,7 +848,7 @@ s32 e1000_setup_copper_link(struct e1000_hw *hw) /* Check link status. Wait up to 100 microseconds for link to become * valid. */ - ret_val = e1000_phy_has_link_generic(hw, + ret_val = e1000e_phy_has_link_generic(hw, COPPER_LINK_UP_LIMIT, 10, &link); @@ -856,8 +857,8 @@ s32 e1000_setup_copper_link(struct e1000_hw *hw) if (link) { hw_dbg(hw, "Valid link established!!!\n"); - e1000_config_collision_dist(hw); - ret_val = e1000_config_fc_after_link_up(hw); + e1000e_config_collision_dist(hw); + ret_val = e1000e_config_fc_after_link_up(hw); } else { hw_dbg(hw, "Unable to establish link!!!\n"); } @@ -866,14 +867,14 @@ s32 e1000_setup_copper_link(struct e1000_hw *hw) } /** - * e1000_phy_force_speed_duplex_igp - Force speed/duplex for igp PHY + * e1000e_phy_force_speed_duplex_igp - Force speed/duplex for igp PHY * @hw: pointer to the HW structure * * Calls the PHY setup function to force speed and duplex. Clears the * auto-crossover to force MDI manually. Waits for link and returns * successful if link up is successful, else -E1000_ERR_PHY (-2). **/ -s32 e1000_phy_force_speed_duplex_igp(struct e1000_hw *hw) +s32 e1000e_phy_force_speed_duplex_igp(struct e1000_hw *hw) { struct e1000_phy_info *phy = &hw->phy; s32 ret_val; @@ -884,7 +885,7 @@ s32 e1000_phy_force_speed_duplex_igp(struct e1000_hw *hw) if (ret_val) return ret_val; - e1000_phy_force_speed_duplex_setup(hw, &phy_data); + e1000e_phy_force_speed_duplex_setup(hw, &phy_data); ret_val = e1e_wphy(hw, PHY_CONTROL, phy_data); if (ret_val) @@ -911,7 +912,7 @@ s32 e1000_phy_force_speed_duplex_igp(struct e1000_hw *hw) if (phy->wait_for_link) { hw_dbg(hw, "Waiting for forced speed/duplex link on IGP phy.\n"); - ret_val = e1000_phy_has_link_generic(hw, + ret_val = e1000e_phy_has_link_generic(hw, PHY_FORCE_LIMIT, 100000, &link); @@ -922,7 +923,7 @@ s32 e1000_phy_force_speed_duplex_igp(struct e1000_hw *hw) hw_dbg(hw, "Link taking longer than expected.\n"); /* Try once more */ - ret_val = e1000_phy_has_link_generic(hw, + ret_val = e1000e_phy_has_link_generic(hw, PHY_FORCE_LIMIT, 100000, &link); @@ -934,7 +935,7 @@ s32 e1000_phy_force_speed_duplex_igp(struct e1000_hw *hw) } /** - * e1000_phy_force_speed_duplex_m88 - Force speed/duplex for m88 PHY + * e1000e_phy_force_speed_duplex_m88 - Force speed/duplex for m88 PHY * @hw: pointer to the HW structure * * Calls the PHY setup function to force speed and duplex. Clears the @@ -943,7 +944,7 @@ s32 e1000_phy_force_speed_duplex_igp(struct e1000_hw *hw) * After reset, TX_CLK and CRS on TX must be set. Return successful upon * successful completion, else return corresponding error code. **/ -s32 e1000_phy_force_speed_duplex_m88(struct e1000_hw *hw) +s32 e1000e_phy_force_speed_duplex_m88(struct e1000_hw *hw) { struct e1000_phy_info *phy = &hw->phy; s32 ret_val; @@ -968,7 +969,7 @@ s32 e1000_phy_force_speed_duplex_m88(struct e1000_hw *hw) if (ret_val) return ret_val; - e1000_phy_force_speed_duplex_setup(hw, &phy_data); + e1000e_phy_force_speed_duplex_setup(hw, &phy_data); /* Reset the phy to commit changes. */ phy_data |= MII_CR_RESET; @@ -982,7 +983,7 @@ s32 e1000_phy_force_speed_duplex_m88(struct e1000_hw *hw) if (phy->wait_for_link) { hw_dbg(hw, "Waiting for forced speed/duplex link on M88 phy.\n"); - ret_val = e1000_phy_has_link_generic(hw, PHY_FORCE_LIMIT, + ret_val = e1000e_phy_has_link_generic(hw, PHY_FORCE_LIMIT, 100000, &link); if (ret_val) return ret_val; @@ -994,13 +995,13 @@ s32 e1000_phy_force_speed_duplex_m88(struct e1000_hw *hw) ret_val = e1e_wphy(hw, M88E1000_PHY_PAGE_SELECT, 0x001d); if (ret_val) return ret_val; - ret_val = e1000_phy_reset_dsp(hw); + ret_val = e1000e_phy_reset_dsp(hw); if (ret_val) return ret_val; } /* Try once more */ - ret_val = e1000_phy_has_link_generic(hw, PHY_FORCE_LIMIT, + ret_val = e1000e_phy_has_link_generic(hw, PHY_FORCE_LIMIT, 100000, &link); if (ret_val) return ret_val; @@ -1033,7 +1034,7 @@ s32 e1000_phy_force_speed_duplex_m88(struct e1000_hw *hw) } /** - * e1000_phy_force_speed_duplex_setup - Configure forced PHY speed/duplex + * e1000e_phy_force_speed_duplex_setup - Configure forced PHY speed/duplex * @hw: pointer to the HW structure * @phy_ctrl: pointer to current value of PHY_CONTROL * @@ -1044,7 +1045,7 @@ s32 e1000_phy_force_speed_duplex_m88(struct e1000_hw *hw) * caller must write to the PHY_CONTROL register for these settings to * take affect. **/ -void e1000_phy_force_speed_duplex_setup(struct e1000_hw *hw, u16 *phy_ctrl) +void e1000e_phy_force_speed_duplex_setup(struct e1000_hw *hw, u16 *phy_ctrl) { struct e1000_mac_info *mac = &hw->mac; u32 ctrl; @@ -1087,13 +1088,13 @@ void e1000_phy_force_speed_duplex_setup(struct e1000_hw *hw, u16 *phy_ctrl) hw_dbg(hw, "Forcing 10mb\n"); } - e1000_config_collision_dist(hw); + e1000e_config_collision_dist(hw); ew32(CTRL, ctrl); } /** - * e1000_set_d3_lplu_state - Sets low power link up state for D3 + * e1000e_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 * @@ -1106,7 +1107,7 @@ void e1000_phy_force_speed_duplex_setup(struct e1000_hw *hw, u16 *phy_ctrl) * During driver activity, SmartSpeed should be enabled so performance is * maintained. **/ -s32 e1000_set_d3_lplu_state(struct e1000_hw *hw, bool active) +s32 e1000e_set_d3_lplu_state(struct e1000_hw *hw, bool active) { struct e1000_phy_info *phy = &hw->phy; s32 ret_val; @@ -1171,14 +1172,14 @@ s32 e1000_set_d3_lplu_state(struct e1000_hw *hw, bool active) } /** - * e1000_check_downshift - Checks whether a downshift in speed occured + * e1000e_check_downshift - Checks whether a downshift in speed occured * @hw: pointer to the HW structure * * Success returns 0, Failure returns 1 * * A downshift is detected by querying the PHY link health. **/ -s32 e1000_check_downshift(struct e1000_hw *hw) +s32 e1000e_check_downshift(struct e1000_hw *hw) { struct e1000_phy_info *phy = &hw->phy; s32 ret_val; @@ -1308,7 +1309,7 @@ static s32 e1000_wait_autoneg(struct e1000_hw *hw) } /** - * e1000_phy_has_link_generic - Polls PHY for link + * e1000e_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 @@ -1316,10 +1317,10 @@ static s32 e1000_wait_autoneg(struct e1000_hw *hw) * * Polls the PHY status register for link, 'iterations' number of times. **/ -s32 e1000_phy_has_link_generic(struct e1000_hw *hw, u32 iterations, +s32 e1000e_phy_has_link_generic(struct e1000_hw *hw, u32 iterations, u32 usec_interval, bool *success) { - s32 ret_val; + s32 ret_val = 0; u16 i, phy_status; for (i = 0; i < iterations; i++) { @@ -1347,7 +1348,7 @@ s32 e1000_phy_has_link_generic(struct e1000_hw *hw, u32 iterations, } /** - * e1000_get_cable_length_m88 - Determine cable length for m88 PHY + * e1000e_get_cable_length_m88 - Determine cable length for m88 PHY * @hw: pointer to the HW structure * * Reads the PHY specific status register to retrieve the cable length @@ -1361,7 +1362,7 @@ s32 e1000_phy_has_link_generic(struct e1000_hw *hw, u32 iterations, * 3 110 - 140 meters * 4 > 140 meters **/ -s32 e1000_get_cable_length_m88(struct e1000_hw *hw) +s32 e1000e_get_cable_length_m88(struct e1000_hw *hw) { struct e1000_phy_info *phy = &hw->phy; s32 ret_val; @@ -1382,7 +1383,7 @@ s32 e1000_get_cable_length_m88(struct e1000_hw *hw) } /** - * e1000_get_cable_length_igp_2 - Determine cable length for igp2 PHY + * e1000e_get_cable_length_igp_2 - Determine cable length for igp2 PHY * @hw: pointer to the HW structure * * The automatic gain control (agc) normalizes the amplitude of the @@ -1392,7 +1393,7 @@ s32 e1000_get_cable_length_m88(struct e1000_hw *hw) * into a lookup table to obtain the approximate cable length * for each channel. **/ -s32 e1000_get_cable_length_igp_2(struct e1000_hw *hw) +s32 e1000e_get_cable_length_igp_2(struct e1000_hw *hw) { struct e1000_phy_info *phy = &hw->phy; s32 ret_val; @@ -1449,7 +1450,7 @@ s32 e1000_get_cable_length_igp_2(struct e1000_hw *hw) } /** - * e1000_get_phy_info_m88 - Retrieve PHY information + * e1000e_get_phy_info_m88 - Retrieve PHY information * @hw: pointer to the HW structure * * Valid for only copper links. Read the PHY status register (sticky read) @@ -1458,7 +1459,7 @@ s32 e1000_get_cable_length_igp_2(struct e1000_hw *hw) * special status register to determine MDI/MDIx and current speed. If * speed is 1000, then determine cable length, local and remote receiver. **/ -s32 e1000_get_phy_info_m88(struct e1000_hw *hw) +s32 e1000e_get_phy_info_m88(struct e1000_hw *hw) { struct e1000_phy_info *phy = &hw->phy; s32 ret_val; @@ -1470,7 +1471,7 @@ s32 e1000_get_phy_info_m88(struct e1000_hw *hw) return -E1000_ERR_CONFIG; } - ret_val = e1000_phy_has_link_generic(hw, 1, 0, &link); + ret_val = e1000e_phy_has_link_generic(hw, 1, 0, &link); if (ret_val) return ret_val; @@ -1523,7 +1524,7 @@ s32 e1000_get_phy_info_m88(struct e1000_hw *hw) } /** - * e1000_get_phy_info_igp - Retrieve igp PHY information + * e1000e_get_phy_info_igp - Retrieve igp PHY information * @hw: pointer to the HW structure * * Read PHY status to determine if link is up. If link is up, then @@ -1531,14 +1532,14 @@ s32 e1000_get_phy_info_m88(struct e1000_hw *hw) * PHY port status to determine MDI/MDIx and speed. Based on the speed, * determine on the cable length, local and remote receiver. **/ -s32 e1000_get_phy_info_igp(struct e1000_hw *hw) +s32 e1000e_get_phy_info_igp(struct e1000_hw *hw) { struct e1000_phy_info *phy = &hw->phy; s32 ret_val; u16 data; bool link; - ret_val = e1000_phy_has_link_generic(hw, 1, 0, &link); + ret_val = e1000e_phy_has_link_generic(hw, 1, 0, &link); if (ret_val) return ret_val; @@ -1586,13 +1587,13 @@ s32 e1000_get_phy_info_igp(struct e1000_hw *hw) } /** - * e1000_phy_sw_reset - PHY software reset + * e1000e_phy_sw_reset - 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 e1000_phy_sw_reset(struct e1000_hw *hw) +s32 e1000e_phy_sw_reset(struct e1000_hw *hw) { s32 ret_val; u16 phy_ctrl; @@ -1612,7 +1613,7 @@ s32 e1000_phy_sw_reset(struct e1000_hw *hw) } /** - * e1000_phy_hw_reset_generic - PHY hardware reset + * e1000e_phy_hw_reset_generic - PHY hardware reset * @hw: pointer to the HW structure * * Verify the reset block is not blocking us from resetting. Acquire @@ -1620,7 +1621,7 @@ s32 e1000_phy_sw_reset(struct e1000_hw *hw) * bit in the PHY. Wait the appropriate delay time for the device to * reset and relase the semaphore (if necessary). **/ -s32 e1000_phy_hw_reset_generic(struct e1000_hw *hw) +s32 e1000e_phy_hw_reset_generic(struct e1000_hw *hw) { struct e1000_phy_info *phy = &hw->phy; s32 ret_val; @@ -1651,13 +1652,13 @@ s32 e1000_phy_hw_reset_generic(struct e1000_hw *hw) } /** - * e1000_get_cfg_done - Generic configuration done + * e1000e_get_cfg_done - Generic configuration done * @hw: pointer to the HW structure * * Generic function to wait 10 milli-seconds for configuration to complete * and return success. **/ -s32 e1000_get_cfg_done(struct e1000_hw *hw) +s32 e1000e_get_cfg_done(struct e1000_hw *hw) { mdelay(10); return 0; @@ -1696,12 +1697,12 @@ static s32 e1000_phy_force_speed_duplex(struct e1000_hw *hw) } /** - * e1000_get_phy_type_from_id - Get PHY type from id + * e1000e_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 e1000e_get_phy_type_from_id(u32 phy_id) { enum e1000_phy_type phy_type = e1000_phy_unknown; @@ -1734,13 +1735,13 @@ enum e1000_phy_type e1000_get_phy_type_from_id(u32 phy_id) } /** - * e1000_commit_phy - Soft PHY reset + * e1000e_commit_phy - 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_commit_phy(struct e1000_hw *hw) +s32 e1000e_commit_phy(struct e1000_hw *hw) { if (hw->phy.ops.commit_phy) return hw->phy.ops.commit_phy(hw);