32 #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
34 #include <linux/types.h>
35 #include <linux/if_ether.h>
41 static s32 igb_get_invariants_82575(
struct e1000_hw *);
42 static s32 igb_acquire_phy_82575(
struct e1000_hw *);
43 static void igb_release_phy_82575(
struct e1000_hw *);
44 static s32 igb_acquire_nvm_82575(
struct e1000_hw *);
45 static void igb_release_nvm_82575(
struct e1000_hw *);
46 static s32 igb_check_for_link_82575(
struct e1000_hw *);
47 static s32 igb_get_cfg_done_82575(
struct e1000_hw *);
49 static s32 igb_phy_hw_reset_sgmii_82575(
struct e1000_hw *);
55 static s32 igb_set_d0_lplu_state_82575(
struct e1000_hw *,
bool);
56 static s32 igb_set_d0_lplu_state_82580(
struct e1000_hw *,
bool);
57 static s32 igb_set_d3_lplu_state_82580(
struct e1000_hw *,
bool);
58 static s32 igb_setup_copper_link_82575(
struct e1000_hw *);
59 static s32 igb_setup_serdes_link_82575(
struct e1000_hw *);
61 static void igb_clear_hw_cntrs_82575(
struct e1000_hw *);
63 static s32 igb_get_pcs_speed_and_duplex_82575(
struct e1000_hw *,
u16 *,
66 static void igb_release_swfw_sync_82575(
struct e1000_hw *,
u16);
67 static bool igb_sgmii_active_82575(
struct e1000_hw *);
68 static s32 igb_reset_init_script_82575(
struct e1000_hw *);
69 static s32 igb_read_mac_addr_82575(
struct e1000_hw *);
70 static s32 igb_set_pcie_completion_timeout(
struct e1000_hw *
hw);
72 static s32 igb_validate_nvm_checksum_82580(
struct e1000_hw *
hw);
73 static s32 igb_update_nvm_checksum_82580(
struct e1000_hw *
hw);
74 static s32 igb_validate_nvm_checksum_i350(
struct e1000_hw *
hw);
76 static const u16 e1000_82580_rxpbs_table[] =
77 { 36, 72, 144, 1, 2, 4, 8, 16,
79 #define E1000_82580_RXPBS_TABLE_SIZE \
80 (sizeof(e1000_82580_rxpbs_table)/sizeof(u16))
89 static bool igb_sgmii_uses_mdio_82575(
struct e1000_hw *
hw)
92 bool ext_mdio =
false;
94 switch (hw->
mac.type) {
217 mac->
ops.reset_hw = igb_reset_hw_82580;
219 mac->
ops.reset_hw = igb_reset_hw_82575;
225 mac->
ops.acquire_swfw_sync = igb_acquire_swfw_sync_82575;
226 mac->
ops.release_swfw_sync = igb_release_swfw_sync_82575;
241 mac->
ops.setup_physical_interface =
243 ? igb_setup_copper_link_82575
244 : igb_setup_serdes_link_82575;
261 pr_notice(
"The NVM size is not valid, defaulting to 32K\n");
293 switch (hw->
mac.type) {
295 nvm->
ops.validate = igb_validate_nvm_checksum_82580;
296 nvm->
ops.update = igb_update_nvm_checksum_82580;
297 nvm->
ops.acquire = igb_acquire_nvm_82575;
298 nvm->
ops.release = igb_release_nvm_82575;
306 nvm->
ops.validate = igb_validate_nvm_checksum_i350;
307 nvm->
ops.update = igb_update_nvm_checksum_i350;
308 nvm->
ops.acquire = igb_acquire_nvm_82575;
309 nvm->
ops.release = igb_release_nvm_82575;
336 nvm->
ops.acquire = igb_acquire_nvm_82575;
337 nvm->
ops.release = igb_release_nvm_82575;
368 if (igb_sgmii_active_82575(hw)) {
369 phy->
ops.reset = igb_phy_hw_reset_sgmii_82575;
377 igb_reset_mdicnfg_82580(hw);
379 if (igb_sgmii_active_82575(hw) && !igb_sgmii_uses_mdio_82575(hw)) {
380 phy->
ops.read_reg = igb_read_phy_reg_sgmii_82575;
381 phy->
ops.write_reg = igb_write_phy_reg_sgmii_82575;
384 phy->
ops.read_reg = igb_read_phy_reg_82580;
385 phy->
ops.write_reg = igb_write_phy_reg_82580;
399 ret_val = igb_get_phy_id_82575(hw);
418 phy->
ops.get_cable_length =
420 phy->
ops.set_d0_lplu_state =
421 igb_set_d0_lplu_state_82580;
422 phy->
ops.set_d3_lplu_state =
423 igb_set_d3_lplu_state_82580;
432 phy->
ops.set_d0_lplu_state = igb_set_d0_lplu_state_82575;
441 phy->
ops.set_d0_lplu_state = igb_set_d0_lplu_state_82580;
442 phy->
ops.set_d3_lplu_state = igb_set_d3_lplu_state_82580;
449 phy->
ops.set_d0_lplu_state = igb_set_d0_lplu_state_82580;
450 phy->
ops.set_d3_lplu_state = igb_set_d3_lplu_state_82580;
467 static s32 igb_acquire_phy_82575(
struct e1000_hw *hw)
478 return hw->
mac.ops.acquire_swfw_sync(hw, mask);
488 static void igb_release_phy_82575(
struct e1000_hw *hw)
499 hw->
mac.ops.release_swfw_sync(hw, mask);
517 hw_dbg(
"PHY Address %u is out of range\n", offset);
521 ret_val = hw->
phy.ops.acquire(hw);
527 hw->
phy.ops.release(hw);
542 static s32 igb_write_phy_reg_sgmii_82575(
struct e1000_hw *hw,
u32 offset,
549 hw_dbg(
"PHY Address %d is out of range\n", offset);
553 ret_val = hw->
phy.ops.acquire(hw);
559 hw->
phy.ops.release(hw);
572 static s32 igb_get_phy_id_82575(
struct e1000_hw *hw)
587 if (!(igb_sgmii_active_82575(hw))) {
593 if (igb_sgmii_uses_mdio_82575(hw)) {
594 switch (hw->
mac.type) {
629 ret_val = igb_read_phy_reg_sgmii_82575(hw,
PHY_ID1, &phy_id);
631 hw_dbg(
"Vendor ID 0x%08X read at address %u\n",
640 hw_dbg(
"PHY address %u was unreadable\n", phy->
addr);
645 if (phy->
addr == 8) {
666 static s32 igb_phy_hw_reset_sgmii_82575(
struct e1000_hw *hw)
675 hw_dbg(
"Soft resetting SGMII attached PHY...\n");
681 ret_val = hw->
phy.ops.write_reg(hw, 0x1B, 0x8084);
740 ret_val = phy->
ops.read_reg(hw,
746 ret_val = phy->
ops.write_reg(hw,
751 ret_val = phy->
ops.read_reg(hw,
757 ret_val = phy->
ops.write_reg(hw,
781 static s32 igb_set_d0_lplu_state_82580(
struct e1000_hw *hw,
bool active)
826 s32 igb_set_d3_lplu_state_82580(
struct e1000_hw *hw,
bool active)
867 static s32 igb_acquire_nvm_82575(
struct e1000_hw *hw)
891 static void igb_release_nvm_82575(
struct e1000_hw *hw)
905 static s32 igb_acquire_swfw_sync_82575(
struct e1000_hw *hw,
u16 mask)
909 u32 fwmask = mask << 16;
913 while (i < timeout) {
920 if (!(swfw_sync & (fwmask | swmask)))
933 hw_dbg(
"Driver can't access resource, SW_FW_SYNC timeout.\n");
955 static void igb_release_swfw_sync_82575(
struct e1000_hw *hw,
u16 mask)
979 static s32 igb_get_cfg_done_82575(
struct e1000_hw *hw)
985 if (hw->
bus.func == 1)
999 hw_dbg(
"MNG configuration cycle has not completed.\n");
1016 static s32 igb_check_for_link_82575(
struct e1000_hw *hw)
1022 ret_val = igb_get_pcs_speed_and_duplex_82575(hw, &speed,
1029 hw->
mac.get_link_status = !hw->
mac.serdes_has_link;
1047 !igb_sgmii_active_82575(hw))
1074 static s32 igb_get_pcs_speed_and_duplex_82575(
struct e1000_hw *hw,
u16 *speed,
1132 igb_sgmii_active_82575(hw))
1159 static s32 igb_reset_hw_82575(
struct e1000_hw *hw)
1170 hw_dbg(
"PCI-E Master disable polling has failed.\n");
1173 ret_val = igb_set_pcie_completion_timeout(hw);
1175 hw_dbg(
"PCI-E Set completion timeout has failed.\n");
1178 hw_dbg(
"Masking off all interrupts\n");
1189 hw_dbg(
"Issuing a global reset to MAC\n");
1199 hw_dbg(
"Auto Read Done did not complete\n");
1204 igb_reset_init_script_82575(hw);
1231 hw_dbg(
"Error initializing identification LED\n");
1236 hw_dbg(
"Initializing the IEEE VLAN\n");
1246 hw_dbg(
"Zeroing the MTA\n");
1251 hw_dbg(
"Zeroing the UTA\n");
1264 igb_clear_hw_cntrs_82575(hw);
1276 static s32 igb_setup_copper_link_82575(
struct e1000_hw *hw)
1286 ret_val = igb_setup_serdes_link_82575(hw);
1290 if (igb_sgmii_active_82575(hw) && !hw->
phy.reset_disable) {
1294 ret_val = hw->
phy.ops.reset(hw);
1296 hw_dbg(
"Error resetting the PHY.\n");
1300 switch (hw->
phy.type) {
1337 static s32 igb_setup_serdes_link_82575(
struct e1000_hw *hw)
1345 !igb_sgmii_active_82575(hw))
1378 pcs_autoneg = hw->
mac.autoneg;
1380 switch (ctrl_ext & E1000_CTRL_EXT_LINK_MODE_MASK) {
1389 pcs_autoneg =
false;
1400 pcs_autoneg =
false;
1437 hw_dbg(
"Configuring Autoneg:PCS_LCTL=0x%08X\n", reg);
1442 hw_dbg(
"Configuring Forced Link:PCS_LCTL=0x%08X\n", reg);
1447 if (!igb_sgmii_active_82575(hw))
1461 static bool igb_sgmii_active_82575(
struct e1000_hw *hw)
1474 static s32 igb_reset_init_script_82575(
struct e1000_hw *hw)
1477 hw_dbg(
"Running reset init script for 82575\n");
1507 static s32 igb_read_mac_addr_82575(
struct e1000_hw *hw)
1546 static void igb_clear_hw_cntrs_82575(
struct e1000_hw *hw)
1599 igb_sgmii_active_82575(hw))
1622 for (i = 0; i < 4; i++) {
1628 for (ms_wait = 0; ms_wait < 10; ms_wait++) {
1631 for (i = 0; i < 4; i++)
1638 hw_dbg(
"Queue disable timed out after 10ms\n");
1662 for (i = 0; i < 4; i++)
1686 static s32 igb_set_pcie_completion_timeout(
struct e1000_hw *hw)
1739 switch (hw->
mac.type) {
1771 switch (hw->
mac.type) {
1829 ret_val = hw->
phy.ops.acquire(hw);
1835 hw->
phy.ops.release(hw);
1854 ret_val = hw->
phy.ops.acquire(hw);
1860 hw->
phy.ops.release(hw);
1874 static s32 igb_reset_mdicnfg_82580(
struct e1000_hw *hw)
1882 if (!igb_sgmii_active_82575(hw))
1889 hw_dbg(
"NVM Read Error\n");
1910 static s32 igb_reset_hw_82580(
struct e1000_hw *hw)
1930 hw_dbg(
"PCI-E Master disable polling has failed.\n");
1932 hw_dbg(
"Masking off all interrupts\n");
1941 if (global_device_reset &&
1942 hw->
mac.ops.acquire_swfw_sync(hw, swmbsw_mask))
1943 global_device_reset =
false;
1945 if (global_device_reset &&
1955 if (global_device_reset)
1965 hw_dbg(
"Auto Read Done did not complete\n");
1970 igb_reset_init_script_82575(hw);
1979 ret_val = igb_reset_mdicnfg_82580(hw);
1981 hw_dbg(
"Could not reset MDICNFG based on EEPROM\n");
1987 if (global_device_reset)
1988 hw->
mac.ops.release_swfw_sync(hw, swmbsw_mask);
2008 ret_val = e1000_82580_rxpbs_table[
data];
2022 static s32 igb_validate_nvm_checksum_with_offset(
struct e1000_hw *hw,
2030 ret_val = hw->
nvm.ops.read(hw, i, 1, &nvm_data);
2032 hw_dbg(
"NVM Read Error\n");
2039 hw_dbg(
"NVM Checksum Invalid\n");
2058 static s32 igb_update_nvm_checksum_with_offset(
struct e1000_hw *hw,
u16 offset)
2065 ret_val = hw->
nvm.ops.read(hw, i, 1, &nvm_data);
2067 hw_dbg(
"NVM Read Error while updating checksum.\n");
2076 hw_dbg(
"NVM Write Error while updating checksum.\n");
2090 static s32 igb_validate_nvm_checksum_82580(
struct e1000_hw *hw)
2093 u16 eeprom_regions_count = 1;
2099 hw_dbg(
"NVM Read Error\n");
2106 eeprom_regions_count = 4;
2109 for (j = 0; j < eeprom_regions_count; j++) {
2111 ret_val = igb_validate_nvm_checksum_with_offset(hw,
2129 static s32 igb_update_nvm_checksum_82580(
struct e1000_hw *hw)
2137 hw_dbg(
"NVM Read Error while updating checksum"
2138 " compatibility bit.\n");
2142 if ((nvm_data & NVM_COMPATIBILITY_BIT_MASK) == 0) {
2148 hw_dbg(
"NVM Write Error while updating checksum"
2149 " compatibility bit.\n");
2154 for (j = 0; j < 4; j++) {
2156 ret_val = igb_update_nvm_checksum_with_offset(hw, nvm_offset);
2173 static s32 igb_validate_nvm_checksum_i350(
struct e1000_hw *hw)
2179 for (j = 0; j < 4; j++) {
2181 ret_val = igb_validate_nvm_checksum_with_offset(hw,
2199 static s32 igb_update_nvm_checksum_i350(
struct e1000_hw *hw)
2205 for (j = 0; j < 4; j++) {
2207 ret_val = igb_update_nvm_checksum_with_offset(hw, nvm_offset);
2267 .init_hw = igb_init_hw_82575,
2268 .check_for_link = igb_check_for_link_82575,
2270 .read_mac_addr = igb_read_mac_addr_82575,
2275 .acquire = igb_acquire_phy_82575,
2276 .get_cfg_done = igb_get_cfg_done_82575,
2277 .release = igb_release_phy_82575,
2281 .acquire = igb_acquire_nvm_82575,
2283 .release = igb_release_nvm_82575,
2288 .get_invariants = igb_get_invariants_82575,
2289 .mac_ops = &e1000_mac_ops_82575,
2290 .phy_ops = &e1000_phy_ops_82575,
2291 .nvm_ops = &e1000_nvm_ops_82575,