aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/e1000e
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/net/e1000e')
-rw-r--r--drivers/net/e1000e/82571.c332
-rw-r--r--drivers/net/e1000e/Makefile2
-rw-r--r--drivers/net/e1000e/defines.h14
-rw-r--r--drivers/net/e1000e/e1000.h56
-rw-r--r--drivers/net/e1000e/es2lan.c20
-rw-r--r--drivers/net/e1000e/ethtool.c438
-rw-r--r--drivers/net/e1000e/hw.h11
-rw-r--r--drivers/net/e1000e/ich8lan.c168
-rw-r--r--drivers/net/e1000e/lib.c186
-rw-r--r--drivers/net/e1000e/netdev.c932
-rw-r--r--drivers/net/e1000e/param.c10
-rw-r--r--drivers/net/e1000e/phy.c108
12 files changed, 1467 insertions, 810 deletions
diff --git a/drivers/net/e1000e/82571.c b/drivers/net/e1000e/82571.c
index d3d4a57e2450..8295f2192439 100644
--- a/drivers/net/e1000e/82571.c
+++ b/drivers/net/e1000e/82571.c
@@ -1,7 +1,7 @@
1/******************************************************************************* 1/*******************************************************************************
2 2
3 Intel PRO/1000 Linux driver 3 Intel PRO/1000 Linux driver
4 Copyright(c) 1999 - 2010 Intel Corporation. 4 Copyright(c) 1999 - 2011 Intel Corporation.
5 5
6 This program is free software; you can redistribute it and/or modify it 6 This program is free software; you can redistribute it and/or modify it
7 under the terms and conditions of the GNU General Public License, 7 under the terms and conditions of the GNU General Public License,
@@ -52,6 +52,11 @@
52 (ID_LED_DEF1_DEF2)) 52 (ID_LED_DEF1_DEF2))
53 53
54#define E1000_GCR_L1_ACT_WITHOUT_L0S_RX 0x08000000 54#define E1000_GCR_L1_ACT_WITHOUT_L0S_RX 0x08000000
55#define AN_RETRY_COUNT 5 /* Autoneg Retry Count value */
56#define E1000_BASE1000T_STATUS 10
57#define E1000_IDLE_ERROR_COUNT_MASK 0xFF
58#define E1000_RECEIVE_ERROR_COUNTER 21
59#define E1000_RECEIVE_ERROR_MAX 0xFFFF
55 60
56#define E1000_NVM_INIT_CTRL2_MNGM 0x6000 /* Manageability Operation Mode mask */ 61#define E1000_NVM_INIT_CTRL2_MNGM 0x6000 /* Manageability Operation Mode mask */
57 62
@@ -70,6 +75,11 @@ static bool e1000_check_mng_mode_82574(struct e1000_hw *hw);
70static s32 e1000_led_on_82574(struct e1000_hw *hw); 75static s32 e1000_led_on_82574(struct e1000_hw *hw);
71static void e1000_put_hw_semaphore_82571(struct e1000_hw *hw); 76static void e1000_put_hw_semaphore_82571(struct e1000_hw *hw);
72static void e1000_power_down_phy_copper_82571(struct e1000_hw *hw); 77static void e1000_power_down_phy_copper_82571(struct e1000_hw *hw);
78static void e1000_put_hw_semaphore_82573(struct e1000_hw *hw);
79static s32 e1000_get_hw_semaphore_82574(struct e1000_hw *hw);
80static void e1000_put_hw_semaphore_82574(struct e1000_hw *hw);
81static s32 e1000_set_d0_lplu_state_82574(struct e1000_hw *hw, bool active);
82static s32 e1000_set_d3_lplu_state_82574(struct e1000_hw *hw, bool active);
73 83
74/** 84/**
75 * e1000_init_phy_params_82571 - Init PHY func ptrs. 85 * e1000_init_phy_params_82571 - Init PHY func ptrs.
@@ -103,6 +113,10 @@ static s32 e1000_init_phy_params_82571(struct e1000_hw *hw)
103 case e1000_82574: 113 case e1000_82574:
104 case e1000_82583: 114 case e1000_82583:
105 phy->type = e1000_phy_bm; 115 phy->type = e1000_phy_bm;
116 phy->ops.acquire = e1000_get_hw_semaphore_82574;
117 phy->ops.release = e1000_put_hw_semaphore_82574;
118 phy->ops.set_d0_lplu_state = e1000_set_d0_lplu_state_82574;
119 phy->ops.set_d3_lplu_state = e1000_set_d3_lplu_state_82574;
106 break; 120 break;
107 default: 121 default:
108 return -E1000_ERR_PHY; 122 return -E1000_ERR_PHY;
@@ -111,29 +125,36 @@ static s32 e1000_init_phy_params_82571(struct e1000_hw *hw)
111 125
112 /* This can only be done after all function pointers are setup. */ 126 /* This can only be done after all function pointers are setup. */
113 ret_val = e1000_get_phy_id_82571(hw); 127 ret_val = e1000_get_phy_id_82571(hw);
128 if (ret_val) {
129 e_dbg("Error getting PHY ID\n");
130 return ret_val;
131 }
114 132
115 /* Verify phy id */ 133 /* Verify phy id */
116 switch (hw->mac.type) { 134 switch (hw->mac.type) {
117 case e1000_82571: 135 case e1000_82571:
118 case e1000_82572: 136 case e1000_82572:
119 if (phy->id != IGP01E1000_I_PHY_ID) 137 if (phy->id != IGP01E1000_I_PHY_ID)
120 return -E1000_ERR_PHY; 138 ret_val = -E1000_ERR_PHY;
121 break; 139 break;
122 case e1000_82573: 140 case e1000_82573:
123 if (phy->id != M88E1111_I_PHY_ID) 141 if (phy->id != M88E1111_I_PHY_ID)
124 return -E1000_ERR_PHY; 142 ret_val = -E1000_ERR_PHY;
125 break; 143 break;
126 case e1000_82574: 144 case e1000_82574:
127 case e1000_82583: 145 case e1000_82583:
128 if (phy->id != BME1000_E_PHY_ID_R2) 146 if (phy->id != BME1000_E_PHY_ID_R2)
129 return -E1000_ERR_PHY; 147 ret_val = -E1000_ERR_PHY;
130 break; 148 break;
131 default: 149 default:
132 return -E1000_ERR_PHY; 150 ret_val = -E1000_ERR_PHY;
133 break; 151 break;
134 } 152 }
135 153
136 return 0; 154 if (ret_val)
155 e_dbg("PHY ID unknown: type = 0x%08x\n", phy->id);
156
157 return ret_val;
137} 158}
138 159
139/** 160/**
@@ -196,6 +217,17 @@ static s32 e1000_init_nvm_params_82571(struct e1000_hw *hw)
196 break; 217 break;
197 } 218 }
198 219
220 /* Function Pointers */
221 switch (hw->mac.type) {
222 case e1000_82574:
223 case e1000_82583:
224 nvm->ops.acquire = e1000_get_hw_semaphore_82574;
225 nvm->ops.release = e1000_put_hw_semaphore_82574;
226 break;
227 default:
228 break;
229 }
230
199 return 0; 231 return 0;
200} 232}
201 233
@@ -268,6 +300,7 @@ static s32 e1000_init_mac_params_82571(struct e1000_adapter *adapter)
268 func->set_lan_id = e1000_set_lan_id_single_port; 300 func->set_lan_id = e1000_set_lan_id_single_port;
269 func->check_mng_mode = e1000e_check_mng_mode_generic; 301 func->check_mng_mode = e1000e_check_mng_mode_generic;
270 func->led_on = e1000e_led_on_generic; 302 func->led_on = e1000e_led_on_generic;
303 func->blink_led = e1000e_blink_led_generic;
271 304
272 /* FWSM register */ 305 /* FWSM register */
273 mac->has_fwsm = true; 306 mac->has_fwsm = true;
@@ -288,6 +321,7 @@ static s32 e1000_init_mac_params_82571(struct e1000_adapter *adapter)
288 default: 321 default:
289 func->check_mng_mode = e1000e_check_mng_mode_generic; 322 func->check_mng_mode = e1000e_check_mng_mode_generic;
290 func->led_on = e1000e_led_on_generic; 323 func->led_on = e1000e_led_on_generic;
324 func->blink_led = e1000e_blink_led_generic;
291 325
292 /* FWSM register */ 326 /* FWSM register */
293 mac->has_fwsm = true; 327 mac->has_fwsm = true;
@@ -296,7 +330,7 @@ static s32 e1000_init_mac_params_82571(struct e1000_adapter *adapter)
296 330
297 /* 331 /*
298 * Ensure that the inter-port SWSM.SMBI lock bit is clear before 332 * Ensure that the inter-port SWSM.SMBI lock bit is clear before
299 * first NVM or PHY acess. This should be done for single-port 333 * first NVM or PHY access. This should be done for single-port
300 * devices, and for one port only on dual-port devices so that 334 * devices, and for one port only on dual-port devices so that
301 * for those devices we can still use the SMBI lock to synchronize 335 * for those devices we can still use the SMBI lock to synchronize
302 * inter-port accesses to the PHY & NVM. 336 * inter-port accesses to the PHY & NVM.
@@ -399,9 +433,6 @@ static s32 e1000_get_variants_82571(struct e1000_adapter *adapter)
399 case e1000_82573: 433 case e1000_82573:
400 case e1000_82574: 434 case e1000_82574:
401 case e1000_82583: 435 case e1000_82583:
402 /* Disable ASPM L0s due to hardware errata */
403 e1000e_disable_aspm(adapter->pdev, PCIE_LINK_STATE_L0S);
404
405 if (pdev->device == E1000_DEV_ID_82573L) { 436 if (pdev->device == E1000_DEV_ID_82573L) {
406 adapter->flags |= FLAG_HAS_JUMBO_FRAMES; 437 adapter->flags |= FLAG_HAS_JUMBO_FRAMES;
407 adapter->max_hw_frame_size = DEFAULT_JUMBO; 438 adapter->max_hw_frame_size = DEFAULT_JUMBO;
@@ -538,6 +569,146 @@ static void e1000_put_hw_semaphore_82571(struct e1000_hw *hw)
538 swsm &= ~(E1000_SWSM_SMBI | E1000_SWSM_SWESMBI); 569 swsm &= ~(E1000_SWSM_SMBI | E1000_SWSM_SWESMBI);
539 ew32(SWSM, swsm); 570 ew32(SWSM, swsm);
540} 571}
572/**
573 * e1000_get_hw_semaphore_82573 - Acquire hardware semaphore
574 * @hw: pointer to the HW structure
575 *
576 * Acquire the HW semaphore during reset.
577 *
578 **/
579static s32 e1000_get_hw_semaphore_82573(struct e1000_hw *hw)
580{
581 u32 extcnf_ctrl;
582 s32 ret_val = 0;
583 s32 i = 0;
584
585 extcnf_ctrl = er32(EXTCNF_CTRL);
586 extcnf_ctrl |= E1000_EXTCNF_CTRL_MDIO_SW_OWNERSHIP;
587 do {
588 ew32(EXTCNF_CTRL, extcnf_ctrl);
589 extcnf_ctrl = er32(EXTCNF_CTRL);
590
591 if (extcnf_ctrl & E1000_EXTCNF_CTRL_MDIO_SW_OWNERSHIP)
592 break;
593
594 extcnf_ctrl |= E1000_EXTCNF_CTRL_MDIO_SW_OWNERSHIP;
595
596 usleep_range(2000, 4000);
597 i++;
598 } while (i < MDIO_OWNERSHIP_TIMEOUT);
599
600 if (i == MDIO_OWNERSHIP_TIMEOUT) {
601 /* Release semaphores */
602 e1000_put_hw_semaphore_82573(hw);
603 e_dbg("Driver can't access the PHY\n");
604 ret_val = -E1000_ERR_PHY;
605 goto out;
606 }
607
608out:
609 return ret_val;
610}
611
612/**
613 * e1000_put_hw_semaphore_82573 - Release hardware semaphore
614 * @hw: pointer to the HW structure
615 *
616 * Release hardware semaphore used during reset.
617 *
618 **/
619static void e1000_put_hw_semaphore_82573(struct e1000_hw *hw)
620{
621 u32 extcnf_ctrl;
622
623 extcnf_ctrl = er32(EXTCNF_CTRL);
624 extcnf_ctrl &= ~E1000_EXTCNF_CTRL_MDIO_SW_OWNERSHIP;
625 ew32(EXTCNF_CTRL, extcnf_ctrl);
626}
627
628static DEFINE_MUTEX(swflag_mutex);
629
630/**
631 * e1000_get_hw_semaphore_82574 - Acquire hardware semaphore
632 * @hw: pointer to the HW structure
633 *
634 * Acquire the HW semaphore to access the PHY or NVM.
635 *
636 **/
637static s32 e1000_get_hw_semaphore_82574(struct e1000_hw *hw)
638{
639 s32 ret_val;
640
641 mutex_lock(&swflag_mutex);
642 ret_val = e1000_get_hw_semaphore_82573(hw);
643 if (ret_val)
644 mutex_unlock(&swflag_mutex);
645 return ret_val;
646}
647
648/**
649 * e1000_put_hw_semaphore_82574 - Release hardware semaphore
650 * @hw: pointer to the HW structure
651 *
652 * Release hardware semaphore used to access the PHY or NVM
653 *
654 **/
655static void e1000_put_hw_semaphore_82574(struct e1000_hw *hw)
656{
657 e1000_put_hw_semaphore_82573(hw);
658 mutex_unlock(&swflag_mutex);
659}
660
661/**
662 * e1000_set_d0_lplu_state_82574 - Set Low Power Linkup D0 state
663 * @hw: pointer to the HW structure
664 * @active: true to enable LPLU, false to disable
665 *
666 * Sets the LPLU D0 state according to the active flag.
667 * LPLU will not be activated unless the
668 * device autonegotiation advertisement meets standards of
669 * either 10 or 10/100 or 10/100/1000 at all duplexes.
670 * This is a function pointer entry point only called by
671 * PHY setup routines.
672 **/
673static s32 e1000_set_d0_lplu_state_82574(struct e1000_hw *hw, bool active)
674{
675 u16 data = er32(POEMB);
676
677 if (active)
678 data |= E1000_PHY_CTRL_D0A_LPLU;
679 else
680 data &= ~E1000_PHY_CTRL_D0A_LPLU;
681
682 ew32(POEMB, data);
683 return 0;
684}
685
686/**
687 * e1000_set_d3_lplu_state_82574 - Sets low power link up state for D3
688 * @hw: pointer to the HW structure
689 * @active: boolean used to enable/disable lplu
690 *
691 * The low power link up (lplu) state is set to the power management level D3
692 * when active is true, else clear lplu for D3. LPLU
693 * is used during Dx states where the power conservation is most important.
694 * During driver activity, SmartSpeed should be enabled so performance is
695 * maintained.
696 **/
697static s32 e1000_set_d3_lplu_state_82574(struct e1000_hw *hw, bool active)
698{
699 u16 data = er32(POEMB);
700
701 if (!active) {
702 data &= ~E1000_PHY_CTRL_NOND0A_LPLU;
703 } else if ((hw->phy.autoneg_advertised == E1000_ALL_SPEED_DUPLEX) ||
704 (hw->phy.autoneg_advertised == E1000_ALL_NOT_GIG) ||
705 (hw->phy.autoneg_advertised == E1000_ALL_10_SPEED)) {
706 data |= E1000_PHY_CTRL_NOND0A_LPLU;
707 }
708
709 ew32(POEMB, data);
710 return 0;
711}
541 712
542/** 713/**
543 * e1000_acquire_nvm_82571 - Request for access to the EEPROM 714 * e1000_acquire_nvm_82571 - Request for access to the EEPROM
@@ -558,8 +729,6 @@ static s32 e1000_acquire_nvm_82571(struct e1000_hw *hw)
558 729
559 switch (hw->mac.type) { 730 switch (hw->mac.type) {
560 case e1000_82573: 731 case e1000_82573:
561 case e1000_82574:
562 case e1000_82583:
563 break; 732 break;
564 default: 733 default:
565 ret_val = e1000e_acquire_nvm(hw); 734 ret_val = e1000e_acquire_nvm(hw);
@@ -646,7 +815,7 @@ static s32 e1000_update_nvm_checksum_82571(struct e1000_hw *hw)
646 815
647 /* Check for pending operations. */ 816 /* Check for pending operations. */
648 for (i = 0; i < E1000_FLASH_UPDATES; i++) { 817 for (i = 0; i < E1000_FLASH_UPDATES; i++) {
649 msleep(1); 818 usleep_range(1000, 2000);
650 if ((er32(EECD) & E1000_EECD_FLUPD) == 0) 819 if ((er32(EECD) & E1000_EECD_FLUPD) == 0)
651 break; 820 break;
652 } 821 }
@@ -670,7 +839,7 @@ static s32 e1000_update_nvm_checksum_82571(struct e1000_hw *hw)
670 ew32(EECD, eecd); 839 ew32(EECD, eecd);
671 840
672 for (i = 0; i < E1000_FLASH_UPDATES; i++) { 841 for (i = 0; i < E1000_FLASH_UPDATES; i++) {
673 msleep(1); 842 usleep_range(1000, 2000);
674 if ((er32(EECD) & E1000_EECD_FLUPD) == 0) 843 if ((er32(EECD) & E1000_EECD_FLUPD) == 0)
675 break; 844 break;
676 } 845 }
@@ -760,7 +929,7 @@ static s32 e1000_get_cfg_done_82571(struct e1000_hw *hw)
760 if (er32(EEMNGCTL) & 929 if (er32(EEMNGCTL) &
761 E1000_NVM_CFG_DONE_PORT_0) 930 E1000_NVM_CFG_DONE_PORT_0)
762 break; 931 break;
763 msleep(1); 932 usleep_range(1000, 2000);
764 timeout--; 933 timeout--;
765 } 934 }
766 if (!timeout) { 935 if (!timeout) {
@@ -849,9 +1018,8 @@ static s32 e1000_set_d0_lplu_state_82571(struct e1000_hw *hw, bool active)
849 **/ 1018 **/
850static s32 e1000_reset_hw_82571(struct e1000_hw *hw) 1019static s32 e1000_reset_hw_82571(struct e1000_hw *hw)
851{ 1020{
852 u32 ctrl, extcnf_ctrl, ctrl_ext, icr; 1021 u32 ctrl, ctrl_ext;
853 s32 ret_val; 1022 s32 ret_val;
854 u16 i = 0;
855 1023
856 /* 1024 /*
857 * Prevent the PCI-E bus from sticking if there is no TLP connection 1025 * Prevent the PCI-E bus from sticking if there is no TLP connection
@@ -868,7 +1036,7 @@ static s32 e1000_reset_hw_82571(struct e1000_hw *hw)
868 ew32(TCTL, E1000_TCTL_PSP); 1036 ew32(TCTL, E1000_TCTL_PSP);
869 e1e_flush(); 1037 e1e_flush();
870 1038
871 msleep(10); 1039 usleep_range(10000, 20000);
872 1040
873 /* 1041 /*
874 * Must acquire the MDIO ownership before MAC reset. 1042 * Must acquire the MDIO ownership before MAC reset.
@@ -876,33 +1044,33 @@ static s32 e1000_reset_hw_82571(struct e1000_hw *hw)
876 */ 1044 */
877 switch (hw->mac.type) { 1045 switch (hw->mac.type) {
878 case e1000_82573: 1046 case e1000_82573:
1047 ret_val = e1000_get_hw_semaphore_82573(hw);
1048 break;
879 case e1000_82574: 1049 case e1000_82574:
880 case e1000_82583: 1050 case e1000_82583:
881 extcnf_ctrl = er32(EXTCNF_CTRL); 1051 ret_val = e1000_get_hw_semaphore_82574(hw);
882 extcnf_ctrl |= E1000_EXTCNF_CTRL_MDIO_SW_OWNERSHIP;
883
884 do {
885 ew32(EXTCNF_CTRL, extcnf_ctrl);
886 extcnf_ctrl = er32(EXTCNF_CTRL);
887
888 if (extcnf_ctrl & E1000_EXTCNF_CTRL_MDIO_SW_OWNERSHIP)
889 break;
890
891 extcnf_ctrl |= E1000_EXTCNF_CTRL_MDIO_SW_OWNERSHIP;
892
893 msleep(2);
894 i++;
895 } while (i < MDIO_OWNERSHIP_TIMEOUT);
896 break; 1052 break;
897 default: 1053 default:
898 break; 1054 break;
899 } 1055 }
1056 if (ret_val)
1057 e_dbg("Cannot acquire MDIO ownership\n");
900 1058
901 ctrl = er32(CTRL); 1059 ctrl = er32(CTRL);
902 1060
903 e_dbg("Issuing a global reset to MAC\n"); 1061 e_dbg("Issuing a global reset to MAC\n");
904 ew32(CTRL, ctrl | E1000_CTRL_RST); 1062 ew32(CTRL, ctrl | E1000_CTRL_RST);
905 1063
1064 /* Must release MDIO ownership and mutex after MAC reset. */
1065 switch (hw->mac.type) {
1066 case e1000_82574:
1067 case e1000_82583:
1068 e1000_put_hw_semaphore_82574(hw);
1069 break;
1070 default:
1071 break;
1072 }
1073
906 if (hw->nvm.type == e1000_nvm_flash_hw) { 1074 if (hw->nvm.type == e1000_nvm_flash_hw) {
907 udelay(10); 1075 udelay(10);
908 ctrl_ext = er32(CTRL_EXT); 1076 ctrl_ext = er32(CTRL_EXT);
@@ -934,7 +1102,7 @@ static s32 e1000_reset_hw_82571(struct e1000_hw *hw)
934 1102
935 /* Clear any pending interrupt events. */ 1103 /* Clear any pending interrupt events. */
936 ew32(IMC, 0xffffffff); 1104 ew32(IMC, 0xffffffff);
937 icr = er32(ICR); 1105 er32(ICR);
938 1106
939 if (hw->mac.type == e1000_82571) { 1107 if (hw->mac.type == e1000_82571) {
940 /* Install any alternate MAC address into RAR0 */ 1108 /* Install any alternate MAC address into RAR0 */
@@ -1141,7 +1309,7 @@ static void e1000_initialize_hw_bits_82571(struct e1000_hw *hw)
1141 * apply workaround for hardware errata documented in errata 1309 * apply workaround for hardware errata documented in errata
1142 * docs Fixes issue where some error prone or unreliable PCIe 1310 * docs Fixes issue where some error prone or unreliable PCIe
1143 * completions are occurring, particularly with ASPM enabled. 1311 * completions are occurring, particularly with ASPM enabled.
1144 * Without fix, issue can cause tx timeouts. 1312 * Without fix, issue can cause Tx timeouts.
1145 */ 1313 */
1146 reg = er32(GCR2); 1314 reg = er32(GCR2);
1147 reg |= 1; 1315 reg |= 1;
@@ -1243,6 +1411,39 @@ static s32 e1000_led_on_82574(struct e1000_hw *hw)
1243} 1411}
1244 1412
1245/** 1413/**
1414 * e1000_check_phy_82574 - check 82574 phy hung state
1415 * @hw: pointer to the HW structure
1416 *
1417 * Returns whether phy is hung or not
1418 **/
1419bool e1000_check_phy_82574(struct e1000_hw *hw)
1420{
1421 u16 status_1kbt = 0;
1422 u16 receive_errors = 0;
1423 bool phy_hung = false;
1424 s32 ret_val = 0;
1425
1426 /*
1427 * Read PHY Receive Error counter first, if its is max - all F's then
1428 * read the Base1000T status register If both are max then PHY is hung.
1429 */
1430 ret_val = e1e_rphy(hw, E1000_RECEIVE_ERROR_COUNTER, &receive_errors);
1431
1432 if (ret_val)
1433 goto out;
1434 if (receive_errors == E1000_RECEIVE_ERROR_MAX) {
1435 ret_val = e1e_rphy(hw, E1000_BASE1000T_STATUS, &status_1kbt);
1436 if (ret_val)
1437 goto out;
1438 if ((status_1kbt & E1000_IDLE_ERROR_COUNT_MASK) ==
1439 E1000_IDLE_ERROR_COUNT_MASK)
1440 phy_hung = true;
1441 }
1442out:
1443 return phy_hung;
1444}
1445
1446/**
1246 * e1000_setup_link_82571 - Setup flow control and link settings 1447 * e1000_setup_link_82571 - Setup flow control and link settings
1247 * @hw: pointer to the HW structure 1448 * @hw: pointer to the HW structure
1248 * 1449 *
@@ -1365,6 +1566,8 @@ static s32 e1000_check_for_serdes_link_82571(struct e1000_hw *hw)
1365 u32 rxcw; 1566 u32 rxcw;
1366 u32 ctrl; 1567 u32 ctrl;
1367 u32 status; 1568 u32 status;
1569 u32 txcw;
1570 u32 i;
1368 s32 ret_val = 0; 1571 s32 ret_val = 0;
1369 1572
1370 ctrl = er32(CTRL); 1573 ctrl = er32(CTRL);
@@ -1385,8 +1588,10 @@ static s32 e1000_check_for_serdes_link_82571(struct e1000_hw *hw)
1385 e1000_serdes_link_autoneg_progress; 1588 e1000_serdes_link_autoneg_progress;
1386 mac->serdes_has_link = false; 1589 mac->serdes_has_link = false;
1387 e_dbg("AN_UP -> AN_PROG\n"); 1590 e_dbg("AN_UP -> AN_PROG\n");
1591 } else {
1592 mac->serdes_has_link = true;
1388 } 1593 }
1389 break; 1594 break;
1390 1595
1391 case e1000_serdes_link_forced_up: 1596 case e1000_serdes_link_forced_up:
1392 /* 1597 /*
@@ -1394,8 +1599,10 @@ static s32 e1000_check_for_serdes_link_82571(struct e1000_hw *hw)
1394 * auto-negotiation in the TXCW register and disable 1599 * auto-negotiation in the TXCW register and disable
1395 * forced link in the Device Control register in an 1600 * forced link in the Device Control register in an
1396 * attempt to auto-negotiate with our link partner. 1601 * attempt to auto-negotiate with our link partner.
1602 * If the partner code word is null, stop forcing
1603 * and restart auto negotiation.
1397 */ 1604 */
1398 if (rxcw & E1000_RXCW_C) { 1605 if ((rxcw & E1000_RXCW_C) || !(rxcw & E1000_RXCW_CW)) {
1399 /* Enable autoneg, and unforce link up */ 1606 /* Enable autoneg, and unforce link up */
1400 ew32(TXCW, mac->txcw); 1607 ew32(TXCW, mac->txcw);
1401 ew32(CTRL, (ctrl & ~E1000_CTRL_SLU)); 1608 ew32(CTRL, (ctrl & ~E1000_CTRL_SLU));
@@ -1403,6 +1610,8 @@ static s32 e1000_check_for_serdes_link_82571(struct e1000_hw *hw)
1403 e1000_serdes_link_autoneg_progress; 1610 e1000_serdes_link_autoneg_progress;
1404 mac->serdes_has_link = false; 1611 mac->serdes_has_link = false;
1405 e_dbg("FORCED_UP -> AN_PROG\n"); 1612 e_dbg("FORCED_UP -> AN_PROG\n");
1613 } else {
1614 mac->serdes_has_link = true;
1406 } 1615 }
1407 break; 1616 break;
1408 1617
@@ -1458,6 +1667,7 @@ static s32 e1000_check_for_serdes_link_82571(struct e1000_hw *hw)
1458 ew32(CTRL, (ctrl & ~E1000_CTRL_SLU)); 1667 ew32(CTRL, (ctrl & ~E1000_CTRL_SLU));
1459 mac->serdes_link_state = 1668 mac->serdes_link_state =
1460 e1000_serdes_link_autoneg_progress; 1669 e1000_serdes_link_autoneg_progress;
1670 mac->serdes_has_link = false;
1461 e_dbg("DOWN -> AN_PROG\n"); 1671 e_dbg("DOWN -> AN_PROG\n");
1462 break; 1672 break;
1463 } 1673 }
@@ -1468,16 +1678,32 @@ static s32 e1000_check_for_serdes_link_82571(struct e1000_hw *hw)
1468 e_dbg("ANYSTATE -> DOWN\n"); 1678 e_dbg("ANYSTATE -> DOWN\n");
1469 } else { 1679 } else {
1470 /* 1680 /*
1471 * We have sync, and can tolerate one invalid (IV) 1681 * Check several times, if Sync and Config
1472 * codeword before declaring link down, so reread 1682 * both are consistently 1 then simply ignore
1473 * to look again. 1683 * the Invalid bit and restart Autoneg
1474 */ 1684 */
1475 udelay(10); 1685 for (i = 0; i < AN_RETRY_COUNT; i++) {
1476 rxcw = er32(RXCW); 1686 udelay(10);
1477 if (rxcw & E1000_RXCW_IV) { 1687 rxcw = er32(RXCW);
1478 mac->serdes_link_state = e1000_serdes_link_down; 1688 if ((rxcw & E1000_RXCW_IV) &&
1689 !((rxcw & E1000_RXCW_SYNCH) &&
1690 (rxcw & E1000_RXCW_C))) {
1691 mac->serdes_has_link = false;
1692 mac->serdes_link_state =
1693 e1000_serdes_link_down;
1694 e_dbg("ANYSTATE -> DOWN\n");
1695 break;
1696 }
1697 }
1698
1699 if (i == AN_RETRY_COUNT) {
1700 txcw = er32(TXCW);
1701 txcw |= E1000_TXCW_ANE;
1702 ew32(TXCW, txcw);
1703 mac->serdes_link_state =
1704 e1000_serdes_link_autoneg_progress;
1479 mac->serdes_has_link = false; 1705 mac->serdes_has_link = false;
1480 e_dbg("ANYSTATE -> DOWN\n"); 1706 e_dbg("ANYSTATE -> AN_PROG\n");
1481 } 1707 }
1482 } 1708 }
1483 } 1709 }
@@ -1801,7 +2027,8 @@ struct e1000_info e1000_82571_info = {
1801 | FLAG_RESET_OVERWRITES_LAA /* errata */ 2027 | FLAG_RESET_OVERWRITES_LAA /* errata */
1802 | FLAG_TARC_SPEED_MODE_BIT /* errata */ 2028 | FLAG_TARC_SPEED_MODE_BIT /* errata */
1803 | FLAG_APME_CHECK_PORT_B, 2029 | FLAG_APME_CHECK_PORT_B,
1804 .flags2 = FLAG2_DISABLE_ASPM_L1, /* errata 13 */ 2030 .flags2 = FLAG2_DISABLE_ASPM_L1 /* errata 13 */
2031 | FLAG2_DMA_BURST,
1805 .pba = 38, 2032 .pba = 38,
1806 .max_hw_frame_size = DEFAULT_JUMBO, 2033 .max_hw_frame_size = DEFAULT_JUMBO,
1807 .get_variants = e1000_get_variants_82571, 2034 .get_variants = e1000_get_variants_82571,
@@ -1819,7 +2046,8 @@ struct e1000_info e1000_82572_info = {
1819 | FLAG_RX_CSUM_ENABLED 2046 | FLAG_RX_CSUM_ENABLED
1820 | FLAG_HAS_CTRLEXT_ON_LOAD 2047 | FLAG_HAS_CTRLEXT_ON_LOAD
1821 | FLAG_TARC_SPEED_MODE_BIT, /* errata */ 2048 | FLAG_TARC_SPEED_MODE_BIT, /* errata */
1822 .flags2 = FLAG2_DISABLE_ASPM_L1, /* errata 13 */ 2049 .flags2 = FLAG2_DISABLE_ASPM_L1 /* errata 13 */
2050 | FLAG2_DMA_BURST,
1823 .pba = 38, 2051 .pba = 38,
1824 .max_hw_frame_size = DEFAULT_JUMBO, 2052 .max_hw_frame_size = DEFAULT_JUMBO,
1825 .get_variants = e1000_get_variants_82571, 2053 .get_variants = e1000_get_variants_82571,
@@ -1837,7 +2065,8 @@ struct e1000_info e1000_82573_info = {
1837 | FLAG_HAS_SMART_POWER_DOWN 2065 | FLAG_HAS_SMART_POWER_DOWN
1838 | FLAG_HAS_AMT 2066 | FLAG_HAS_AMT
1839 | FLAG_HAS_SWSM_ON_LOAD, 2067 | FLAG_HAS_SWSM_ON_LOAD,
1840 .flags2 = FLAG2_DISABLE_ASPM_L1, 2068 .flags2 = FLAG2_DISABLE_ASPM_L1
2069 | FLAG2_DISABLE_ASPM_L0S,
1841 .pba = 20, 2070 .pba = 20,
1842 .max_hw_frame_size = ETH_FRAME_LEN + ETH_FCS_LEN, 2071 .max_hw_frame_size = ETH_FRAME_LEN + ETH_FCS_LEN,
1843 .get_variants = e1000_get_variants_82571, 2072 .get_variants = e1000_get_variants_82571,
@@ -1857,7 +2086,9 @@ struct e1000_info e1000_82574_info = {
1857 | FLAG_HAS_SMART_POWER_DOWN 2086 | FLAG_HAS_SMART_POWER_DOWN
1858 | FLAG_HAS_AMT 2087 | FLAG_HAS_AMT
1859 | FLAG_HAS_CTRLEXT_ON_LOAD, 2088 | FLAG_HAS_CTRLEXT_ON_LOAD,
1860 .pba = 36, 2089 .flags2 = FLAG2_CHECK_PHY_HANG
2090 | FLAG2_DISABLE_ASPM_L0S,
2091 .pba = 32,
1861 .max_hw_frame_size = DEFAULT_JUMBO, 2092 .max_hw_frame_size = DEFAULT_JUMBO,
1862 .get_variants = e1000_get_variants_82571, 2093 .get_variants = e1000_get_variants_82571,
1863 .mac_ops = &e82571_mac_ops, 2094 .mac_ops = &e82571_mac_ops,
@@ -1874,7 +2105,8 @@ struct e1000_info e1000_82583_info = {
1874 | FLAG_HAS_SMART_POWER_DOWN 2105 | FLAG_HAS_SMART_POWER_DOWN
1875 | FLAG_HAS_AMT 2106 | FLAG_HAS_AMT
1876 | FLAG_HAS_CTRLEXT_ON_LOAD, 2107 | FLAG_HAS_CTRLEXT_ON_LOAD,
1877 .pba = 36, 2108 .flags2 = FLAG2_DISABLE_ASPM_L0S,
2109 .pba = 32,
1878 .max_hw_frame_size = ETH_FRAME_LEN + ETH_FCS_LEN, 2110 .max_hw_frame_size = ETH_FRAME_LEN + ETH_FCS_LEN,
1879 .get_variants = e1000_get_variants_82571, 2111 .get_variants = e1000_get_variants_82571,
1880 .mac_ops = &e82571_mac_ops, 2112 .mac_ops = &e82571_mac_ops,
diff --git a/drivers/net/e1000e/Makefile b/drivers/net/e1000e/Makefile
index 360c91369f35..28519acacd2d 100644
--- a/drivers/net/e1000e/Makefile
+++ b/drivers/net/e1000e/Makefile
@@ -1,7 +1,7 @@
1################################################################################ 1################################################################################
2# 2#
3# Intel PRO/1000 Linux driver 3# Intel PRO/1000 Linux driver
4# Copyright(c) 1999 - 2008 Intel Corporation. 4# Copyright(c) 1999 - 2011 Intel Corporation.
5# 5#
6# This program is free software; you can redistribute it and/or modify it 6# This program is free software; you can redistribute it and/or modify it
7# under the terms and conditions of the GNU General Public License, 7# under the terms and conditions of the GNU General Public License,
diff --git a/drivers/net/e1000e/defines.h b/drivers/net/e1000e/defines.h
index 93b3bedae8d2..c516a7440bec 100644
--- a/drivers/net/e1000e/defines.h
+++ b/drivers/net/e1000e/defines.h
@@ -1,7 +1,7 @@
1/******************************************************************************* 1/*******************************************************************************
2 2
3 Intel PRO/1000 Linux driver 3 Intel PRO/1000 Linux driver
4 Copyright(c) 1999 - 2010 Intel Corporation. 4 Copyright(c) 1999 - 2011 Intel Corporation.
5 5
6 This program is free software; you can redistribute it and/or modify it 6 This program is free software; you can redistribute it and/or modify it
7 under the terms and conditions of the GNU General Public License, 7 under the terms and conditions of the GNU General Public License,
@@ -86,6 +86,7 @@
86#define E1000_CTRL_EXT_IAME 0x08000000 /* Interrupt acknowledge Auto-mask */ 86#define E1000_CTRL_EXT_IAME 0x08000000 /* Interrupt acknowledge Auto-mask */
87#define E1000_CTRL_EXT_INT_TIMER_CLR 0x20000000 /* Clear Interrupt timers after IMS clear */ 87#define E1000_CTRL_EXT_INT_TIMER_CLR 0x20000000 /* Clear Interrupt timers after IMS clear */
88#define E1000_CTRL_EXT_PBA_CLR 0x80000000 /* PBA Clear */ 88#define E1000_CTRL_EXT_PBA_CLR 0x80000000 /* PBA Clear */
89#define E1000_CTRL_EXT_LSECCK 0x00001000
89#define E1000_CTRL_EXT_PHYPDEN 0x00100000 90#define E1000_CTRL_EXT_PHYPDEN 0x00100000
90 91
91/* Receive Descriptor bit definitions */ 92/* Receive Descriptor bit definitions */
@@ -446,7 +447,9 @@
446 447
447/* Transmit Descriptor Control */ 448/* Transmit Descriptor Control */
448#define E1000_TXDCTL_PTHRESH 0x0000003F /* TXDCTL Prefetch Threshold */ 449#define E1000_TXDCTL_PTHRESH 0x0000003F /* TXDCTL Prefetch Threshold */
450#define E1000_TXDCTL_HTHRESH 0x00003F00 /* TXDCTL Host Threshold */
449#define E1000_TXDCTL_WTHRESH 0x003F0000 /* TXDCTL Writeback Threshold */ 451#define E1000_TXDCTL_WTHRESH 0x003F0000 /* TXDCTL Writeback Threshold */
452#define E1000_TXDCTL_GRAN 0x01000000 /* TXDCTL Granularity */
450#define E1000_TXDCTL_FULL_TX_DESC_WB 0x01010000 /* GRAN=1, WTHRESH=1 */ 453#define E1000_TXDCTL_FULL_TX_DESC_WB 0x01010000 /* GRAN=1, WTHRESH=1 */
451#define E1000_TXDCTL_MAX_TX_DESC_PREFETCH 0x0100001F /* GRAN=1, PTHRESH=31 */ 454#define E1000_TXDCTL_MAX_TX_DESC_PREFETCH 0x0100001F /* GRAN=1, PTHRESH=31 */
452/* Enable the counting of desc. still to be processed. */ 455/* Enable the counting of desc. still to be processed. */
@@ -486,6 +489,9 @@
486#define E1000_BLK_PHY_RESET 12 489#define E1000_BLK_PHY_RESET 12
487#define E1000_ERR_SWFW_SYNC 13 490#define E1000_ERR_SWFW_SYNC 13
488#define E1000_NOT_IMPLEMENTED 14 491#define E1000_NOT_IMPLEMENTED 14
492#define E1000_ERR_INVALID_ARGUMENT 16
493#define E1000_ERR_NO_SPACE 17
494#define E1000_ERR_NVM_PBA_SECTION 18
489 495
490/* Loop limit on how long we wait for auto-negotiation to complete */ 496/* Loop limit on how long we wait for auto-negotiation to complete */
491#define FIBER_LINK_UP_LIMIT 50 497#define FIBER_LINK_UP_LIMIT 50
@@ -514,6 +520,7 @@
514#define E1000_TXCW_ANE 0x80000000 /* Auto-neg enable */ 520#define E1000_TXCW_ANE 0x80000000 /* Auto-neg enable */
515 521
516/* Receive Configuration Word */ 522/* Receive Configuration Word */
523#define E1000_RXCW_CW 0x0000ffff /* RxConfigWord mask */
517#define E1000_RXCW_IV 0x08000000 /* Receive config invalid */ 524#define E1000_RXCW_IV 0x08000000 /* Receive config invalid */
518#define E1000_RXCW_C 0x20000000 /* Receive config */ 525#define E1000_RXCW_C 0x20000000 /* Receive config */
519#define E1000_RXCW_SYNCH 0x40000000 /* Receive config synch */ 526#define E1000_RXCW_SYNCH 0x40000000 /* Receive config synch */
@@ -647,13 +654,16 @@
647/* Mask bits for fields in Word 0x03 of the EEPROM */ 654/* Mask bits for fields in Word 0x03 of the EEPROM */
648#define NVM_COMPAT_LOM 0x0800 655#define NVM_COMPAT_LOM 0x0800
649 656
657/* length of string needed to store PBA number */
658#define E1000_PBANUM_LENGTH 11
659
650/* For checksumming, the sum of all words in the NVM should equal 0xBABA. */ 660/* For checksumming, the sum of all words in the NVM should equal 0xBABA. */
651#define NVM_SUM 0xBABA 661#define NVM_SUM 0xBABA
652 662
653/* PBA (printed board assembly) number words */ 663/* PBA (printed board assembly) number words */
654#define NVM_PBA_OFFSET_0 8 664#define NVM_PBA_OFFSET_0 8
655#define NVM_PBA_OFFSET_1 9 665#define NVM_PBA_OFFSET_1 9
656 666#define NVM_PBA_PTR_GUARD 0xFAFA
657#define NVM_WORD_SIZE_BASE_SHIFT 6 667#define NVM_WORD_SIZE_BASE_SHIFT 6
658 668
659/* NVM Commands - SPI */ 669/* NVM Commands - SPI */
diff --git a/drivers/net/e1000e/e1000.h b/drivers/net/e1000e/e1000.h
index f9a31c82f871..9549879e66a0 100644
--- a/drivers/net/e1000e/e1000.h
+++ b/drivers/net/e1000e/e1000.h
@@ -1,7 +1,7 @@
1/******************************************************************************* 1/*******************************************************************************
2 2
3 Intel PRO/1000 Linux driver 3 Intel PRO/1000 Linux driver
4 Copyright(c) 1999 - 2010 Intel Corporation. 4 Copyright(c) 1999 - 2011 Intel Corporation.
5 5
6 This program is free software; you can redistribute it and/or modify it 6 This program is free software; you can redistribute it and/or modify it
7 under the terms and conditions of the GNU General Public License, 7 under the terms and conditions of the GNU General Public License,
@@ -31,6 +31,7 @@
31#ifndef _E1000_H_ 31#ifndef _E1000_H_
32#define _E1000_H_ 32#define _E1000_H_
33 33
34#include <linux/bitops.h>
34#include <linux/types.h> 35#include <linux/types.h>
35#include <linux/timer.h> 36#include <linux/timer.h>
36#include <linux/workqueue.h> 37#include <linux/workqueue.h>
@@ -38,6 +39,8 @@
38#include <linux/netdevice.h> 39#include <linux/netdevice.h>
39#include <linux/pci.h> 40#include <linux/pci.h>
40#include <linux/pci-aspm.h> 41#include <linux/pci-aspm.h>
42#include <linux/crc32.h>
43#include <linux/if_vlan.h>
41 44
42#include "hw.h" 45#include "hw.h"
43 46
@@ -153,6 +156,33 @@ struct e1000_info;
153/* Time to wait before putting the device into D3 if there's no link (in ms). */ 156/* Time to wait before putting the device into D3 if there's no link (in ms). */
154#define LINK_TIMEOUT 100 157#define LINK_TIMEOUT 100
155 158
159#define DEFAULT_RDTR 0
160#define DEFAULT_RADV 8
161#define BURST_RDTR 0x20
162#define BURST_RADV 0x20
163
164/*
165 * in the case of WTHRESH, it appears at least the 82571/2 hardware
166 * writes back 4 descriptors when WTHRESH=5, and 3 descriptors when
167 * WTHRESH=4, and since we want 64 bytes at a time written back, set
168 * it to 5
169 */
170#define E1000_TXDCTL_DMA_BURST_ENABLE \
171 (E1000_TXDCTL_GRAN | /* set descriptor granularity */ \
172 E1000_TXDCTL_COUNT_DESC | \
173 (5 << 16) | /* wthresh must be +1 more than desired */\
174 (1 << 8) | /* hthresh */ \
175 0x1f) /* pthresh */
176
177#define E1000_RXDCTL_DMA_BURST_ENABLE \
178 (0x01000000 | /* set descriptor granularity */ \
179 (4 << 16) | /* set writeback threshold */ \
180 (4 << 8) | /* set prefetch threshold */ \
181 0x20) /* set hthresh */
182
183#define E1000_TIDV_FPD (1 << 31)
184#define E1000_RDTR_FPD (1 << 31)
185
156enum e1000_boards { 186enum e1000_boards {
157 board_82571, 187 board_82571,
158 board_82572, 188 board_82572,
@@ -252,7 +282,7 @@ struct e1000_adapter {
252 282
253 const struct e1000_info *ei; 283 const struct e1000_info *ei;
254 284
255 struct vlan_group *vlgrp; 285 unsigned long active_vlans[BITS_TO_LONGS(VLAN_N_VID)];
256 u32 bd_number; 286 u32 bd_number;
257 u32 rx_buffer_len; 287 u32 rx_buffer_len;
258 u16 mng_vlan_id; 288 u16 mng_vlan_id;
@@ -336,6 +366,7 @@ struct e1000_adapter {
336 /* structs defined in e1000_hw.h */ 366 /* structs defined in e1000_hw.h */
337 struct e1000_hw hw; 367 struct e1000_hw hw;
338 368
369 spinlock_t stats64_lock;
339 struct e1000_hw_stats stats; 370 struct e1000_hw_stats stats;
340 struct e1000_phy_info phy_info; 371 struct e1000_phy_info phy_info;
341 struct e1000_phy_stats phy_stats; 372 struct e1000_phy_stats phy_stats;
@@ -360,16 +391,14 @@ struct e1000_adapter {
360 391
361 bool fc_autoneg; 392 bool fc_autoneg;
362 393
363 unsigned long led_status;
364
365 unsigned int flags; 394 unsigned int flags;
366 unsigned int flags2; 395 unsigned int flags2;
367 struct work_struct downshift_task; 396 struct work_struct downshift_task;
368 struct work_struct update_phy_task; 397 struct work_struct update_phy_task;
369 struct work_struct led_blink_task;
370 struct work_struct print_hang_task; 398 struct work_struct print_hang_task;
371 399
372 bool idle_check; 400 bool idle_check;
401 int phy_hang_count;
373}; 402};
374 403
375struct e1000_info { 404struct e1000_info {
@@ -425,6 +454,10 @@ struct e1000_info {
425#define FLAG2_DISABLE_ASPM_L1 (1 << 3) 454#define FLAG2_DISABLE_ASPM_L1 (1 << 3)
426#define FLAG2_HAS_PHY_STATS (1 << 4) 455#define FLAG2_HAS_PHY_STATS (1 << 4)
427#define FLAG2_HAS_EEE (1 << 5) 456#define FLAG2_HAS_EEE (1 << 5)
457#define FLAG2_DMA_BURST (1 << 6)
458#define FLAG2_DISABLE_ASPM_L0S (1 << 7)
459#define FLAG2_DISABLE_AIM (1 << 8)
460#define FLAG2_CHECK_PHY_HANG (1 << 9)
428 461
429#define E1000_RX_DESC_PS(R, i) \ 462#define E1000_RX_DESC_PS(R, i) \
430 (&(((union e1000_rx_desc_packet_split *)((R).desc))[i])) 463 (&(((union e1000_rx_desc_packet_split *)((R).desc))[i]))
@@ -461,10 +494,13 @@ extern int e1000e_setup_rx_resources(struct e1000_adapter *adapter);
461extern int e1000e_setup_tx_resources(struct e1000_adapter *adapter); 494extern int e1000e_setup_tx_resources(struct e1000_adapter *adapter);
462extern void e1000e_free_rx_resources(struct e1000_adapter *adapter); 495extern void e1000e_free_rx_resources(struct e1000_adapter *adapter);
463extern void e1000e_free_tx_resources(struct e1000_adapter *adapter); 496extern void e1000e_free_tx_resources(struct e1000_adapter *adapter);
464extern void e1000e_update_stats(struct e1000_adapter *adapter); 497extern struct rtnl_link_stats64 *e1000e_get_stats64(struct net_device *netdev,
498 struct rtnl_link_stats64
499 *stats);
465extern void e1000e_set_interrupt_capability(struct e1000_adapter *adapter); 500extern void e1000e_set_interrupt_capability(struct e1000_adapter *adapter);
466extern void e1000e_reset_interrupt_capability(struct e1000_adapter *adapter); 501extern void e1000e_reset_interrupt_capability(struct e1000_adapter *adapter);
467extern void e1000e_disable_aspm(struct pci_dev *pdev, u16 state); 502extern void e1000e_get_hw_control(struct e1000_adapter *adapter);
503extern void e1000e_release_hw_control(struct e1000_adapter *adapter);
468 504
469extern unsigned int copybreak; 505extern unsigned int copybreak;
470 506
@@ -482,7 +518,8 @@ extern struct e1000_info e1000_pch_info;
482extern struct e1000_info e1000_pch2_info; 518extern struct e1000_info e1000_pch2_info;
483extern struct e1000_info e1000_es2_info; 519extern struct e1000_info e1000_es2_info;
484 520
485extern s32 e1000e_read_pba_num(struct e1000_hw *hw, u32 *pba_num); 521extern s32 e1000_read_pba_string_generic(struct e1000_hw *hw, u8 *pba_num,
522 u32 pba_num_size);
486 523
487extern s32 e1000e_commit_phy(struct e1000_hw *hw); 524extern s32 e1000e_commit_phy(struct e1000_hw *hw);
488 525
@@ -534,7 +571,7 @@ extern s32 e1000e_valid_led_default(struct e1000_hw *hw, u16 *data);
534extern void e1000e_config_collision_dist(struct e1000_hw *hw); 571extern void e1000e_config_collision_dist(struct e1000_hw *hw);
535extern s32 e1000e_config_fc_after_link_up(struct e1000_hw *hw); 572extern s32 e1000e_config_fc_after_link_up(struct e1000_hw *hw);
536extern s32 e1000e_force_mac_fc(struct e1000_hw *hw); 573extern s32 e1000e_force_mac_fc(struct e1000_hw *hw);
537extern s32 e1000e_blink_led(struct e1000_hw *hw); 574extern s32 e1000e_blink_led_generic(struct e1000_hw *hw);
538extern void e1000_write_vfta_generic(struct e1000_hw *hw, u32 offset, u32 value); 575extern void e1000_write_vfta_generic(struct e1000_hw *hw, u32 offset, u32 value);
539extern s32 e1000_check_alt_mac_addr_generic(struct e1000_hw *hw); 576extern s32 e1000_check_alt_mac_addr_generic(struct e1000_hw *hw);
540extern void e1000e_reset_adaptive(struct e1000_hw *hw); 577extern void e1000e_reset_adaptive(struct e1000_hw *hw);
@@ -602,6 +639,7 @@ extern s32 e1000_get_phy_info_ife(struct e1000_hw *hw);
602extern s32 e1000_check_polarity_ife(struct e1000_hw *hw); 639extern s32 e1000_check_polarity_ife(struct e1000_hw *hw);
603extern s32 e1000_phy_force_speed_duplex_ife(struct e1000_hw *hw); 640extern s32 e1000_phy_force_speed_duplex_ife(struct e1000_hw *hw);
604extern s32 e1000_check_polarity_igp(struct e1000_hw *hw); 641extern s32 e1000_check_polarity_igp(struct e1000_hw *hw);
642extern bool e1000_check_phy_82574(struct e1000_hw *hw);
605 643
606static inline s32 e1000_phy_hw_reset(struct e1000_hw *hw) 644static inline s32 e1000_phy_hw_reset(struct e1000_hw *hw)
607{ 645{
diff --git a/drivers/net/e1000e/es2lan.c b/drivers/net/e1000e/es2lan.c
index 45aebb4a6fe1..f4bbeb22f51f 100644
--- a/drivers/net/e1000e/es2lan.c
+++ b/drivers/net/e1000e/es2lan.c
@@ -1,7 +1,7 @@
1/******************************************************************************* 1/*******************************************************************************
2 2
3 Intel PRO/1000 Linux driver 3 Intel PRO/1000 Linux driver
4 Copyright(c) 1999 - 2010 Intel Corporation. 4 Copyright(c) 1999 - 2011 Intel Corporation.
5 5
6 This program is free software; you can redistribute it and/or modify it 6 This program is free software; you can redistribute it and/or modify it
7 under the terms and conditions of the GNU General Public License, 7 under the terms and conditions of the GNU General Public License,
@@ -100,8 +100,8 @@
100 * with a lower bound at "index" and the upper bound at 100 * with a lower bound at "index" and the upper bound at
101 * "index + 5". 101 * "index + 5".
102 */ 102 */
103static const u16 e1000_gg82563_cable_length_table[] = 103static const u16 e1000_gg82563_cable_length_table[] = {
104 { 0, 60, 115, 150, 150, 60, 115, 150, 180, 180, 0xFF }; 104 0, 60, 115, 150, 150, 60, 115, 150, 180, 180, 0xFF };
105#define GG82563_CABLE_LENGTH_TABLE_SIZE \ 105#define GG82563_CABLE_LENGTH_TABLE_SIZE \
106 ARRAY_SIZE(e1000_gg82563_cable_length_table) 106 ARRAY_SIZE(e1000_gg82563_cable_length_table)
107 107
@@ -426,8 +426,8 @@ static void e1000_release_swfw_sync_80003es2lan(struct e1000_hw *hw, u16 mask)
426{ 426{
427 u32 swfw_sync; 427 u32 swfw_sync;
428 428
429 while (e1000e_get_hw_semaphore(hw) != 0); 429 while (e1000e_get_hw_semaphore(hw) != 0)
430 /* Empty */ 430 ; /* Empty */
431 431
432 swfw_sync = er32(SW_FW_SYNC); 432 swfw_sync = er32(SW_FW_SYNC);
433 swfw_sync &= ~mask; 433 swfw_sync &= ~mask;
@@ -612,7 +612,7 @@ static s32 e1000_get_cfg_done_80003es2lan(struct e1000_hw *hw)
612 while (timeout) { 612 while (timeout) {
613 if (er32(EEMNGCTL) & mask) 613 if (er32(EEMNGCTL) & mask)
614 break; 614 break;
615 msleep(1); 615 usleep_range(1000, 2000);
616 timeout--; 616 timeout--;
617 } 617 }
618 if (!timeout) { 618 if (!timeout) {
@@ -784,7 +784,7 @@ static s32 e1000_get_link_up_info_80003es2lan(struct e1000_hw *hw, u16 *speed,
784 **/ 784 **/
785static s32 e1000_reset_hw_80003es2lan(struct e1000_hw *hw) 785static s32 e1000_reset_hw_80003es2lan(struct e1000_hw *hw)
786{ 786{
787 u32 ctrl, icr; 787 u32 ctrl;
788 s32 ret_val; 788 s32 ret_val;
789 789
790 /* 790 /*
@@ -802,7 +802,7 @@ static s32 e1000_reset_hw_80003es2lan(struct e1000_hw *hw)
802 ew32(TCTL, E1000_TCTL_PSP); 802 ew32(TCTL, E1000_TCTL_PSP);
803 e1e_flush(); 803 e1e_flush();
804 804
805 msleep(10); 805 usleep_range(10000, 20000);
806 806
807 ctrl = er32(CTRL); 807 ctrl = er32(CTRL);
808 808
@@ -818,7 +818,7 @@ static s32 e1000_reset_hw_80003es2lan(struct e1000_hw *hw)
818 818
819 /* Clear any pending interrupt events. */ 819 /* Clear any pending interrupt events. */
820 ew32(IMC, 0xffffffff); 820 ew32(IMC, 0xffffffff);
821 icr = er32(ICR); 821 er32(ICR);
822 822
823 ret_val = e1000_check_alt_mac_addr_generic(hw); 823 ret_val = e1000_check_alt_mac_addr_generic(hw);
824 824
@@ -1434,6 +1434,7 @@ static void e1000_clear_hw_cntrs_80003es2lan(struct e1000_hw *hw)
1434static struct e1000_mac_operations es2_mac_ops = { 1434static struct e1000_mac_operations es2_mac_ops = {
1435 .read_mac_addr = e1000_read_mac_addr_80003es2lan, 1435 .read_mac_addr = e1000_read_mac_addr_80003es2lan,
1436 .id_led_init = e1000e_id_led_init, 1436 .id_led_init = e1000e_id_led_init,
1437 .blink_led = e1000e_blink_led_generic,
1437 .check_mng_mode = e1000e_check_mng_mode_generic, 1438 .check_mng_mode = e1000e_check_mng_mode_generic,
1438 /* check_for_link dependent on media type */ 1439 /* check_for_link dependent on media type */
1439 .cleanup_led = e1000e_cleanup_led_generic, 1440 .cleanup_led = e1000e_cleanup_led_generic,
@@ -1494,6 +1495,7 @@ struct e1000_info e1000_es2_info = {
1494 | FLAG_APME_CHECK_PORT_B 1495 | FLAG_APME_CHECK_PORT_B
1495 | FLAG_DISABLE_FC_PAUSE_TIME /* errata */ 1496 | FLAG_DISABLE_FC_PAUSE_TIME /* errata */
1496 | FLAG_TIPG_MEDIUM_FOR_80003ESLAN, 1497 | FLAG_TIPG_MEDIUM_FOR_80003ESLAN,
1498 .flags2 = FLAG2_DMA_BURST,
1497 .pba = 38, 1499 .pba = 38,
1498 .max_hw_frame_size = DEFAULT_JUMBO, 1500 .max_hw_frame_size = DEFAULT_JUMBO,
1499 .get_variants = e1000_get_variants_80003es2lan, 1501 .get_variants = e1000_get_variants_80003es2lan,
diff --git a/drivers/net/e1000e/ethtool.c b/drivers/net/e1000e/ethtool.c
index 6355a1b779d3..859d0d3af6c9 100644
--- a/drivers/net/e1000e/ethtool.c
+++ b/drivers/net/e1000e/ethtool.c
@@ -1,7 +1,7 @@
1/******************************************************************************* 1/*******************************************************************************
2 2
3 Intel PRO/1000 Linux driver 3 Intel PRO/1000 Linux driver
4 Copyright(c) 1999 - 2010 Intel Corporation. 4 Copyright(c) 1999 - 2011 Intel Corporation.
5 5
6 This program is free software; you can redistribute it and/or modify it 6 This program is free software; you can redistribute it and/or modify it
7 under the terms and conditions of the GNU General Public License, 7 under the terms and conditions of the GNU General Public License,
@@ -45,63 +45,67 @@ struct e1000_stats {
45 int stat_offset; 45 int stat_offset;
46}; 46};
47 47
48#define E1000_STAT(m) E1000_STATS, \ 48#define E1000_STAT(str, m) { \
49 sizeof(((struct e1000_adapter *)0)->m), \ 49 .stat_string = str, \
50 offsetof(struct e1000_adapter, m) 50 .type = E1000_STATS, \
51#define E1000_NETDEV_STAT(m) NETDEV_STATS, \ 51 .sizeof_stat = sizeof(((struct e1000_adapter *)0)->m), \
52 sizeof(((struct net_device *)0)->m), \ 52 .stat_offset = offsetof(struct e1000_adapter, m) }
53 offsetof(struct net_device, m) 53#define E1000_NETDEV_STAT(str, m) { \
54 .stat_string = str, \
55 .type = NETDEV_STATS, \
56 .sizeof_stat = sizeof(((struct rtnl_link_stats64 *)0)->m), \
57 .stat_offset = offsetof(struct rtnl_link_stats64, m) }
54 58
55static const struct e1000_stats e1000_gstrings_stats[] = { 59static const struct e1000_stats e1000_gstrings_stats[] = {
56 { "rx_packets", E1000_STAT(stats.gprc) }, 60 E1000_STAT("rx_packets", stats.gprc),
57 { "tx_packets", E1000_STAT(stats.gptc) }, 61 E1000_STAT("tx_packets", stats.gptc),
58 { "rx_bytes", E1000_STAT(stats.gorc) }, 62 E1000_STAT("rx_bytes", stats.gorc),
59 { "tx_bytes", E1000_STAT(stats.gotc) }, 63 E1000_STAT("tx_bytes", stats.gotc),
60 { "rx_broadcast", E1000_STAT(stats.bprc) }, 64 E1000_STAT("rx_broadcast", stats.bprc),
61 { "tx_broadcast", E1000_STAT(stats.bptc) }, 65 E1000_STAT("tx_broadcast", stats.bptc),
62 { "rx_multicast", E1000_STAT(stats.mprc) }, 66 E1000_STAT("rx_multicast", stats.mprc),
63 { "tx_multicast", E1000_STAT(stats.mptc) }, 67 E1000_STAT("tx_multicast", stats.mptc),
64 { "rx_errors", E1000_NETDEV_STAT(stats.rx_errors) }, 68 E1000_NETDEV_STAT("rx_errors", rx_errors),
65 { "tx_errors", E1000_NETDEV_STAT(stats.tx_errors) }, 69 E1000_NETDEV_STAT("tx_errors", tx_errors),
66 { "tx_dropped", E1000_NETDEV_STAT(stats.tx_dropped) }, 70 E1000_NETDEV_STAT("tx_dropped", tx_dropped),
67 { "multicast", E1000_STAT(stats.mprc) }, 71 E1000_STAT("multicast", stats.mprc),
68 { "collisions", E1000_STAT(stats.colc) }, 72 E1000_STAT("collisions", stats.colc),
69 { "rx_length_errors", E1000_NETDEV_STAT(stats.rx_length_errors) }, 73 E1000_NETDEV_STAT("rx_length_errors", rx_length_errors),
70 { "rx_over_errors", E1000_NETDEV_STAT(stats.rx_over_errors) }, 74 E1000_NETDEV_STAT("rx_over_errors", rx_over_errors),
71 { "rx_crc_errors", E1000_STAT(stats.crcerrs) }, 75 E1000_STAT("rx_crc_errors", stats.crcerrs),
72 { "rx_frame_errors", E1000_NETDEV_STAT(stats.rx_frame_errors) }, 76 E1000_NETDEV_STAT("rx_frame_errors", rx_frame_errors),
73 { "rx_no_buffer_count", E1000_STAT(stats.rnbc) }, 77 E1000_STAT("rx_no_buffer_count", stats.rnbc),
74 { "rx_missed_errors", E1000_STAT(stats.mpc) }, 78 E1000_STAT("rx_missed_errors", stats.mpc),
75 { "tx_aborted_errors", E1000_STAT(stats.ecol) }, 79 E1000_STAT("tx_aborted_errors", stats.ecol),
76 { "tx_carrier_errors", E1000_STAT(stats.tncrs) }, 80 E1000_STAT("tx_carrier_errors", stats.tncrs),
77 { "tx_fifo_errors", E1000_NETDEV_STAT(stats.tx_fifo_errors) }, 81 E1000_NETDEV_STAT("tx_fifo_errors", tx_fifo_errors),
78 { "tx_heartbeat_errors", E1000_NETDEV_STAT(stats.tx_heartbeat_errors) }, 82 E1000_NETDEV_STAT("tx_heartbeat_errors", tx_heartbeat_errors),
79 { "tx_window_errors", E1000_STAT(stats.latecol) }, 83 E1000_STAT("tx_window_errors", stats.latecol),
80 { "tx_abort_late_coll", E1000_STAT(stats.latecol) }, 84 E1000_STAT("tx_abort_late_coll", stats.latecol),
81 { "tx_deferred_ok", E1000_STAT(stats.dc) }, 85 E1000_STAT("tx_deferred_ok", stats.dc),
82 { "tx_single_coll_ok", E1000_STAT(stats.scc) }, 86 E1000_STAT("tx_single_coll_ok", stats.scc),
83 { "tx_multi_coll_ok", E1000_STAT(stats.mcc) }, 87 E1000_STAT("tx_multi_coll_ok", stats.mcc),
84 { "tx_timeout_count", E1000_STAT(tx_timeout_count) }, 88 E1000_STAT("tx_timeout_count", tx_timeout_count),
85 { "tx_restart_queue", E1000_STAT(restart_queue) }, 89 E1000_STAT("tx_restart_queue", restart_queue),
86 { "rx_long_length_errors", E1000_STAT(stats.roc) }, 90 E1000_STAT("rx_long_length_errors", stats.roc),
87 { "rx_short_length_errors", E1000_STAT(stats.ruc) }, 91 E1000_STAT("rx_short_length_errors", stats.ruc),
88 { "rx_align_errors", E1000_STAT(stats.algnerrc) }, 92 E1000_STAT("rx_align_errors", stats.algnerrc),
89 { "tx_tcp_seg_good", E1000_STAT(stats.tsctc) }, 93 E1000_STAT("tx_tcp_seg_good", stats.tsctc),
90 { "tx_tcp_seg_failed", E1000_STAT(stats.tsctfc) }, 94 E1000_STAT("tx_tcp_seg_failed", stats.tsctfc),
91 { "rx_flow_control_xon", E1000_STAT(stats.xonrxc) }, 95 E1000_STAT("rx_flow_control_xon", stats.xonrxc),
92 { "rx_flow_control_xoff", E1000_STAT(stats.xoffrxc) }, 96 E1000_STAT("rx_flow_control_xoff", stats.xoffrxc),
93 { "tx_flow_control_xon", E1000_STAT(stats.xontxc) }, 97 E1000_STAT("tx_flow_control_xon", stats.xontxc),
94 { "tx_flow_control_xoff", E1000_STAT(stats.xofftxc) }, 98 E1000_STAT("tx_flow_control_xoff", stats.xofftxc),
95 { "rx_long_byte_count", E1000_STAT(stats.gorc) }, 99 E1000_STAT("rx_long_byte_count", stats.gorc),
96 { "rx_csum_offload_good", E1000_STAT(hw_csum_good) }, 100 E1000_STAT("rx_csum_offload_good", hw_csum_good),
97 { "rx_csum_offload_errors", E1000_STAT(hw_csum_err) }, 101 E1000_STAT("rx_csum_offload_errors", hw_csum_err),
98 { "rx_header_split", E1000_STAT(rx_hdr_split) }, 102 E1000_STAT("rx_header_split", rx_hdr_split),
99 { "alloc_rx_buff_failed", E1000_STAT(alloc_rx_buff_failed) }, 103 E1000_STAT("alloc_rx_buff_failed", alloc_rx_buff_failed),
100 { "tx_smbus", E1000_STAT(stats.mgptc) }, 104 E1000_STAT("tx_smbus", stats.mgptc),
101 { "rx_smbus", E1000_STAT(stats.mgprc) }, 105 E1000_STAT("rx_smbus", stats.mgprc),
102 { "dropped_smbus", E1000_STAT(stats.mgpdc) }, 106 E1000_STAT("dropped_smbus", stats.mgpdc),
103 { "rx_dma_failed", E1000_STAT(rx_dma_failed) }, 107 E1000_STAT("rx_dma_failed", rx_dma_failed),
104 { "tx_dma_failed", E1000_STAT(tx_dma_failed) }, 108 E1000_STAT("tx_dma_failed", tx_dma_failed),
105}; 109};
106 110
107#define E1000_GLOBAL_STATS_LEN ARRAY_SIZE(e1000_gstrings_stats) 111#define E1000_GLOBAL_STATS_LEN ARRAY_SIZE(e1000_gstrings_stats)
@@ -118,6 +122,7 @@ static int e1000_get_settings(struct net_device *netdev,
118{ 122{
119 struct e1000_adapter *adapter = netdev_priv(netdev); 123 struct e1000_adapter *adapter = netdev_priv(netdev);
120 struct e1000_hw *hw = &adapter->hw; 124 struct e1000_hw *hw = &adapter->hw;
125 u32 speed;
121 126
122 if (hw->phy.media_type == e1000_media_type_copper) { 127 if (hw->phy.media_type == e1000_media_type_copper) {
123 128
@@ -155,23 +160,23 @@ static int e1000_get_settings(struct net_device *netdev,
155 ecmd->transceiver = XCVR_EXTERNAL; 160 ecmd->transceiver = XCVR_EXTERNAL;
156 } 161 }
157 162
158 ecmd->speed = -1; 163 speed = -1;
159 ecmd->duplex = -1; 164 ecmd->duplex = -1;
160 165
161 if (netif_running(netdev)) { 166 if (netif_running(netdev)) {
162 if (netif_carrier_ok(netdev)) { 167 if (netif_carrier_ok(netdev)) {
163 ecmd->speed = adapter->link_speed; 168 speed = adapter->link_speed;
164 ecmd->duplex = adapter->link_duplex - 1; 169 ecmd->duplex = adapter->link_duplex - 1;
165 } 170 }
166 } else { 171 } else {
167 u32 status = er32(STATUS); 172 u32 status = er32(STATUS);
168 if (status & E1000_STATUS_LU) { 173 if (status & E1000_STATUS_LU) {
169 if (status & E1000_STATUS_SPEED_1000) 174 if (status & E1000_STATUS_SPEED_1000)
170 ecmd->speed = 1000; 175 speed = SPEED_1000;
171 else if (status & E1000_STATUS_SPEED_100) 176 else if (status & E1000_STATUS_SPEED_100)
172 ecmd->speed = 100; 177 speed = SPEED_100;
173 else 178 else
174 ecmd->speed = 10; 179 speed = SPEED_10;
175 180
176 if (status & E1000_STATUS_FD) 181 if (status & E1000_STATUS_FD)
177 ecmd->duplex = DUPLEX_FULL; 182 ecmd->duplex = DUPLEX_FULL;
@@ -180,6 +185,7 @@ static int e1000_get_settings(struct net_device *netdev,
180 } 185 }
181 } 186 }
182 187
188 ethtool_cmd_speed_set(ecmd, speed);
183 ecmd->autoneg = ((hw->phy.media_type == e1000_media_type_fiber) || 189 ecmd->autoneg = ((hw->phy.media_type == e1000_media_type_fiber) ||
184 hw->mac.autoneg) ? AUTONEG_ENABLE : AUTONEG_DISABLE; 190 hw->mac.autoneg) ? AUTONEG_ENABLE : AUTONEG_DISABLE;
185 191
@@ -194,34 +200,25 @@ static int e1000_get_settings(struct net_device *netdev,
194 return 0; 200 return 0;
195} 201}
196 202
197static u32 e1000_get_link(struct net_device *netdev) 203static int e1000_set_spd_dplx(struct e1000_adapter *adapter, u32 spd, u8 dplx)
198{
199 struct e1000_adapter *adapter = netdev_priv(netdev);
200 struct e1000_hw *hw = &adapter->hw;
201
202 /*
203 * Avoid touching hardware registers when possible, otherwise
204 * link negotiation can get messed up when user-level scripts
205 * are rapidly polling the driver to see if link is up.
206 */
207 return netif_running(netdev) ? netif_carrier_ok(netdev) :
208 !!(er32(STATUS) & E1000_STATUS_LU);
209}
210
211static int e1000_set_spd_dplx(struct e1000_adapter *adapter, u16 spddplx)
212{ 204{
213 struct e1000_mac_info *mac = &adapter->hw.mac; 205 struct e1000_mac_info *mac = &adapter->hw.mac;
214 206
215 mac->autoneg = 0; 207 mac->autoneg = 0;
216 208
209 /* Make sure dplx is at most 1 bit and lsb of speed is not set
210 * for the switch() below to work */
211 if ((spd & 1) || (dplx & ~1))
212 goto err_inval;
213
217 /* Fiber NICs only allow 1000 gbps Full duplex */ 214 /* Fiber NICs only allow 1000 gbps Full duplex */
218 if ((adapter->hw.phy.media_type == e1000_media_type_fiber) && 215 if ((adapter->hw.phy.media_type == e1000_media_type_fiber) &&
219 spddplx != (SPEED_1000 + DUPLEX_FULL)) { 216 spd != SPEED_1000 &&
220 e_err("Unsupported Speed/Duplex configuration\n"); 217 dplx != DUPLEX_FULL) {
221 return -EINVAL; 218 goto err_inval;
222 } 219 }
223 220
224 switch (spddplx) { 221 switch (spd + dplx) {
225 case SPEED_10 + DUPLEX_HALF: 222 case SPEED_10 + DUPLEX_HALF:
226 mac->forced_speed_duplex = ADVERTISE_10_HALF; 223 mac->forced_speed_duplex = ADVERTISE_10_HALF;
227 break; 224 break;
@@ -240,10 +237,13 @@ static int e1000_set_spd_dplx(struct e1000_adapter *adapter, u16 spddplx)
240 break; 237 break;
241 case SPEED_1000 + DUPLEX_HALF: /* not supported */ 238 case SPEED_1000 + DUPLEX_HALF: /* not supported */
242 default: 239 default:
243 e_err("Unsupported Speed/Duplex configuration\n"); 240 goto err_inval;
244 return -EINVAL;
245 } 241 }
246 return 0; 242 return 0;
243
244err_inval:
245 e_err("Unsupported Speed/Duplex configuration\n");
246 return -EINVAL;
247} 247}
248 248
249static int e1000_set_settings(struct net_device *netdev, 249static int e1000_set_settings(struct net_device *netdev,
@@ -263,7 +263,7 @@ static int e1000_set_settings(struct net_device *netdev,
263 } 263 }
264 264
265 while (test_and_set_bit(__E1000_RESETTING, &adapter->state)) 265 while (test_and_set_bit(__E1000_RESETTING, &adapter->state))
266 msleep(1); 266 usleep_range(1000, 2000);
267 267
268 if (ecmd->autoneg == AUTONEG_ENABLE) { 268 if (ecmd->autoneg == AUTONEG_ENABLE) {
269 hw->mac.autoneg = 1; 269 hw->mac.autoneg = 1;
@@ -279,7 +279,8 @@ static int e1000_set_settings(struct net_device *netdev,
279 if (adapter->fc_autoneg) 279 if (adapter->fc_autoneg)
280 hw->fc.requested_mode = e1000_fc_default; 280 hw->fc.requested_mode = e1000_fc_default;
281 } else { 281 } else {
282 if (e1000_set_spd_dplx(adapter, ecmd->speed + ecmd->duplex)) { 282 u32 speed = ethtool_cmd_speed(ecmd);
283 if (e1000_set_spd_dplx(adapter, speed, ecmd->duplex)) {
283 clear_bit(__E1000_RESETTING, &adapter->state); 284 clear_bit(__E1000_RESETTING, &adapter->state);
284 return -EINVAL; 285 return -EINVAL;
285 } 286 }
@@ -327,7 +328,7 @@ static int e1000_set_pauseparam(struct net_device *netdev,
327 adapter->fc_autoneg = pause->autoneg; 328 adapter->fc_autoneg = pause->autoneg;
328 329
329 while (test_and_set_bit(__E1000_RESETTING, &adapter->state)) 330 while (test_and_set_bit(__E1000_RESETTING, &adapter->state))
330 msleep(1); 331 usleep_range(1000, 2000);
331 332
332 if (adapter->fc_autoneg == AUTONEG_ENABLE) { 333 if (adapter->fc_autoneg == AUTONEG_ENABLE) {
333 hw->fc.requested_mode = e1000_fc_default; 334 hw->fc.requested_mode = e1000_fc_default;
@@ -368,7 +369,7 @@ out:
368static u32 e1000_get_rx_csum(struct net_device *netdev) 369static u32 e1000_get_rx_csum(struct net_device *netdev)
369{ 370{
370 struct e1000_adapter *adapter = netdev_priv(netdev); 371 struct e1000_adapter *adapter = netdev_priv(netdev);
371 return (adapter->flags & FLAG_RX_CSUM_ENABLED); 372 return adapter->flags & FLAG_RX_CSUM_ENABLED;
372} 373}
373 374
374static int e1000_set_rx_csum(struct net_device *netdev, u32 data) 375static int e1000_set_rx_csum(struct net_device *netdev, u32 data)
@@ -389,7 +390,7 @@ static int e1000_set_rx_csum(struct net_device *netdev, u32 data)
389 390
390static u32 e1000_get_tx_csum(struct net_device *netdev) 391static u32 e1000_get_tx_csum(struct net_device *netdev)
391{ 392{
392 return ((netdev->features & NETIF_F_HW_CSUM) != 0); 393 return (netdev->features & NETIF_F_HW_CSUM) != 0;
393} 394}
394 395
395static int e1000_set_tx_csum(struct net_device *netdev, u32 data) 396static int e1000_set_tx_csum(struct net_device *netdev, u32 data)
@@ -443,13 +444,11 @@ static void e1000_get_regs(struct net_device *netdev,
443 struct e1000_hw *hw = &adapter->hw; 444 struct e1000_hw *hw = &adapter->hw;
444 u32 *regs_buff = p; 445 u32 *regs_buff = p;
445 u16 phy_data; 446 u16 phy_data;
446 u8 revision_id;
447 447
448 memset(p, 0, E1000_REGS_LEN * sizeof(u32)); 448 memset(p, 0, E1000_REGS_LEN * sizeof(u32));
449 449
450 pci_read_config_byte(adapter->pdev, PCI_REVISION_ID, &revision_id); 450 regs->version = (1 << 24) | (adapter->pdev->revision << 16) |
451 451 adapter->pdev->device;
452 regs->version = (1 << 24) | (revision_id << 16) | adapter->pdev->device;
453 452
454 regs_buff[0] = er32(CTRL); 453 regs_buff[0] = er32(CTRL);
455 regs_buff[1] = er32(STATUS); 454 regs_buff[1] = er32(STATUS);
@@ -634,20 +633,24 @@ static void e1000_get_drvinfo(struct net_device *netdev,
634 struct e1000_adapter *adapter = netdev_priv(netdev); 633 struct e1000_adapter *adapter = netdev_priv(netdev);
635 char firmware_version[32]; 634 char firmware_version[32];
636 635
637 strncpy(drvinfo->driver, e1000e_driver_name, 32); 636 strncpy(drvinfo->driver, e1000e_driver_name,
638 strncpy(drvinfo->version, e1000e_driver_version, 32); 637 sizeof(drvinfo->driver) - 1);
638 strncpy(drvinfo->version, e1000e_driver_version,
639 sizeof(drvinfo->version) - 1);
639 640
640 /* 641 /*
641 * EEPROM image version # is reported as firmware version # for 642 * EEPROM image version # is reported as firmware version # for
642 * PCI-E controllers 643 * PCI-E controllers
643 */ 644 */
644 sprintf(firmware_version, "%d.%d-%d", 645 snprintf(firmware_version, sizeof(firmware_version), "%d.%d-%d",
645 (adapter->eeprom_vers & 0xF000) >> 12, 646 (adapter->eeprom_vers & 0xF000) >> 12,
646 (adapter->eeprom_vers & 0x0FF0) >> 4, 647 (adapter->eeprom_vers & 0x0FF0) >> 4,
647 (adapter->eeprom_vers & 0x000F)); 648 (adapter->eeprom_vers & 0x000F));
648 649
649 strncpy(drvinfo->fw_version, firmware_version, 32); 650 strncpy(drvinfo->fw_version, firmware_version,
650 strncpy(drvinfo->bus_info, pci_name(adapter->pdev), 32); 651 sizeof(drvinfo->fw_version) - 1);
652 strncpy(drvinfo->bus_info, pci_name(adapter->pdev),
653 sizeof(drvinfo->bus_info) - 1);
651 drvinfo->regdump_len = e1000_get_regs_len(netdev); 654 drvinfo->regdump_len = e1000_get_regs_len(netdev);
652 drvinfo->eedump_len = e1000_get_eeprom_len(netdev); 655 drvinfo->eedump_len = e1000_get_eeprom_len(netdev);
653} 656}
@@ -681,7 +684,7 @@ static int e1000_set_ringparam(struct net_device *netdev,
681 return -EINVAL; 684 return -EINVAL;
682 685
683 while (test_and_set_bit(__E1000_RESETTING, &adapter->state)) 686 while (test_and_set_bit(__E1000_RESETTING, &adapter->state))
684 msleep(1); 687 usleep_range(1000, 2000);
685 688
686 if (netif_running(adapter->netdev)) 689 if (netif_running(adapter->netdev))
687 e1000e_down(adapter); 690 e1000e_down(adapter);
@@ -690,20 +693,13 @@ static int e1000_set_ringparam(struct net_device *netdev,
690 rx_old = adapter->rx_ring; 693 rx_old = adapter->rx_ring;
691 694
692 err = -ENOMEM; 695 err = -ENOMEM;
693 tx_ring = kzalloc(sizeof(struct e1000_ring), GFP_KERNEL); 696 tx_ring = kmemdup(tx_old, sizeof(struct e1000_ring), GFP_KERNEL);
694 if (!tx_ring) 697 if (!tx_ring)
695 goto err_alloc_tx; 698 goto err_alloc_tx;
696 /*
697 * use a memcpy to save any previously configured
698 * items like napi structs from having to be
699 * reinitialized
700 */
701 memcpy(tx_ring, tx_old, sizeof(struct e1000_ring));
702 699
703 rx_ring = kzalloc(sizeof(struct e1000_ring), GFP_KERNEL); 700 rx_ring = kmemdup(rx_old, sizeof(struct e1000_ring), GFP_KERNEL);
704 if (!rx_ring) 701 if (!rx_ring)
705 goto err_alloc_rx; 702 goto err_alloc_rx;
706 memcpy(rx_ring, rx_old, sizeof(struct e1000_ring));
707 703
708 adapter->tx_ring = tx_ring; 704 adapter->tx_ring = tx_ring;
709 adapter->rx_ring = rx_ring; 705 adapter->rx_ring = rx_ring;
@@ -763,8 +759,8 @@ static bool reg_pattern_test(struct e1000_adapter *adapter, u64 *data,
763 int reg, int offset, u32 mask, u32 write) 759 int reg, int offset, u32 mask, u32 write)
764{ 760{
765 u32 pat, val; 761 u32 pat, val;
766 static const u32 test[] = 762 static const u32 test[] = {
767 {0x5A5A5A5A, 0xA5A5A5A5, 0x00000000, 0xFFFFFFFF}; 763 0x5A5A5A5A, 0xA5A5A5A5, 0x00000000, 0xFFFFFFFF};
768 for (pat = 0; pat < ARRAY_SIZE(test); pat++) { 764 for (pat = 0; pat < ARRAY_SIZE(test); pat++) {
769 E1000_WRITE_REG_ARRAY(&adapter->hw, reg, offset, 765 E1000_WRITE_REG_ARRAY(&adapter->hw, reg, offset,
770 (test[pat] & write)); 766 (test[pat] & write));
@@ -967,7 +963,7 @@ static int e1000_intr_test(struct e1000_adapter *adapter, u64 *data)
967 963
968 /* Disable all the interrupts */ 964 /* Disable all the interrupts */
969 ew32(IMC, 0xFFFFFFFF); 965 ew32(IMC, 0xFFFFFFFF);
970 msleep(10); 966 usleep_range(10000, 20000);
971 967
972 /* Test each interrupt */ 968 /* Test each interrupt */
973 for (i = 0; i < 10; i++) { 969 for (i = 0; i < 10; i++) {
@@ -999,7 +995,7 @@ static int e1000_intr_test(struct e1000_adapter *adapter, u64 *data)
999 adapter->test_icr = 0; 995 adapter->test_icr = 0;
1000 ew32(IMC, mask); 996 ew32(IMC, mask);
1001 ew32(ICS, mask); 997 ew32(ICS, mask);
1002 msleep(10); 998 usleep_range(10000, 20000);
1003 999
1004 if (adapter->test_icr & mask) { 1000 if (adapter->test_icr & mask) {
1005 *data = 3; 1001 *data = 3;
@@ -1017,7 +1013,7 @@ static int e1000_intr_test(struct e1000_adapter *adapter, u64 *data)
1017 adapter->test_icr = 0; 1013 adapter->test_icr = 0;
1018 ew32(IMS, mask); 1014 ew32(IMS, mask);
1019 ew32(ICS, mask); 1015 ew32(ICS, mask);
1020 msleep(10); 1016 usleep_range(10000, 20000);
1021 1017
1022 if (!(adapter->test_icr & mask)) { 1018 if (!(adapter->test_icr & mask)) {
1023 *data = 4; 1019 *data = 4;
@@ -1035,7 +1031,7 @@ static int e1000_intr_test(struct e1000_adapter *adapter, u64 *data)
1035 adapter->test_icr = 0; 1031 adapter->test_icr = 0;
1036 ew32(IMC, ~mask & 0x00007FFF); 1032 ew32(IMC, ~mask & 0x00007FFF);
1037 ew32(ICS, ~mask & 0x00007FFF); 1033 ew32(ICS, ~mask & 0x00007FFF);
1038 msleep(10); 1034 usleep_range(10000, 20000);
1039 1035
1040 if (adapter->test_icr) { 1036 if (adapter->test_icr) {
1041 *data = 5; 1037 *data = 5;
@@ -1046,7 +1042,7 @@ static int e1000_intr_test(struct e1000_adapter *adapter, u64 *data)
1046 1042
1047 /* Disable all the interrupts */ 1043 /* Disable all the interrupts */
1048 ew32(IMC, 0xFFFFFFFF); 1044 ew32(IMC, 0xFFFFFFFF);
1049 msleep(10); 1045 usleep_range(10000, 20000);
1050 1046
1051 /* Unhook test interrupt handler */ 1047 /* Unhook test interrupt handler */
1052 free_irq(irq, netdev); 1048 free_irq(irq, netdev);
@@ -1261,8 +1257,8 @@ static int e1000_integrated_phy_loopback(struct e1000_adapter *adapter)
1261{ 1257{
1262 struct e1000_hw *hw = &adapter->hw; 1258 struct e1000_hw *hw = &adapter->hw;
1263 u32 ctrl_reg = 0; 1259 u32 ctrl_reg = 0;
1264 u32 stat_reg = 0;
1265 u16 phy_reg = 0; 1260 u16 phy_reg = 0;
1261 s32 ret_val = 0;
1266 1262
1267 hw->mac.autoneg = 0; 1263 hw->mac.autoneg = 0;
1268 1264
@@ -1322,7 +1318,13 @@ static int e1000_integrated_phy_loopback(struct e1000_adapter *adapter)
1322 case e1000_phy_82577: 1318 case e1000_phy_82577:
1323 case e1000_phy_82578: 1319 case e1000_phy_82578:
1324 /* Workaround: K1 must be disabled for stable 1Gbps operation */ 1320 /* Workaround: K1 must be disabled for stable 1Gbps operation */
1321 ret_val = hw->phy.ops.acquire(hw);
1322 if (ret_val) {
1323 e_err("Cannot setup 1Gbps loopback.\n");
1324 return ret_val;
1325 }
1325 e1000_configure_k1_ich8lan(hw, false); 1326 e1000_configure_k1_ich8lan(hw, false);
1327 hw->phy.ops.release(hw);
1326 break; 1328 break;
1327 case e1000_phy_82579: 1329 case e1000_phy_82579:
1328 /* Disable PHY energy detect power down */ 1330 /* Disable PHY energy detect power down */
@@ -1362,8 +1364,7 @@ static int e1000_integrated_phy_loopback(struct e1000_adapter *adapter)
1362 * Set the ILOS bit on the fiber Nic if half duplex link is 1364 * Set the ILOS bit on the fiber Nic if half duplex link is
1363 * detected. 1365 * detected.
1364 */ 1366 */
1365 stat_reg = er32(STATUS); 1367 if ((er32(STATUS) & E1000_STATUS_FD) == 0)
1366 if ((stat_reg & E1000_STATUS_FD) == 0)
1367 ctrl_reg |= (E1000_CTRL_ILOS | E1000_CTRL_SLU); 1368 ctrl_reg |= (E1000_CTRL_ILOS | E1000_CTRL_SLU);
1368 } 1369 }
1369 1370
@@ -1416,7 +1417,7 @@ static int e1000_set_82571_fiber_loopback(struct e1000_adapter *adapter)
1416 */ 1417 */
1417#define E1000_SERDES_LB_ON 0x410 1418#define E1000_SERDES_LB_ON 0x410
1418 ew32(SCTL, E1000_SERDES_LB_ON); 1419 ew32(SCTL, E1000_SERDES_LB_ON);
1419 msleep(10); 1420 usleep_range(10000, 20000);
1420 1421
1421 return 0; 1422 return 0;
1422} 1423}
@@ -1511,7 +1512,7 @@ static void e1000_loopback_cleanup(struct e1000_adapter *adapter)
1511 hw->phy.media_type == e1000_media_type_internal_serdes) { 1512 hw->phy.media_type == e1000_media_type_internal_serdes) {
1512#define E1000_SERDES_LB_OFF 0x400 1513#define E1000_SERDES_LB_OFF 0x400
1513 ew32(SCTL, E1000_SERDES_LB_OFF); 1514 ew32(SCTL, E1000_SERDES_LB_OFF);
1514 msleep(10); 1515 usleep_range(10000, 20000);
1515 break; 1516 break;
1516 } 1517 }
1517 /* Fall Through */ 1518 /* Fall Through */
@@ -1676,10 +1677,13 @@ static int e1000_link_test(struct e1000_adapter *adapter, u64 *data)
1676 } else { 1677 } else {
1677 hw->mac.ops.check_for_link(hw); 1678 hw->mac.ops.check_for_link(hw);
1678 if (hw->mac.autoneg) 1679 if (hw->mac.autoneg)
1679 msleep(4000); 1680 /*
1681 * On some Phy/switch combinations, link establishment
1682 * can take a few seconds more than expected.
1683 */
1684 msleep(5000);
1680 1685
1681 if (!(er32(STATUS) & 1686 if (!(er32(STATUS) & E1000_STATUS_LU))
1682 E1000_STATUS_LU))
1683 *data = 1; 1687 *data = 1;
1684 } 1688 }
1685 return *data; 1689 return *data;
@@ -1707,6 +1711,19 @@ static void e1000_diag_test(struct net_device *netdev,
1707 bool if_running = netif_running(netdev); 1711 bool if_running = netif_running(netdev);
1708 1712
1709 set_bit(__E1000_TESTING, &adapter->state); 1713 set_bit(__E1000_TESTING, &adapter->state);
1714
1715 if (!if_running) {
1716 /* Get control of and reset hardware */
1717 if (adapter->flags & FLAG_HAS_AMT)
1718 e1000e_get_hw_control(adapter);
1719
1720 e1000e_power_up_phy(adapter);
1721
1722 adapter->hw.phy.autoneg_wait_to_complete = 1;
1723 e1000e_reset(adapter);
1724 adapter->hw.phy.autoneg_wait_to_complete = 0;
1725 }
1726
1710 if (eth_test->flags == ETH_TEST_FL_OFFLINE) { 1727 if (eth_test->flags == ETH_TEST_FL_OFFLINE) {
1711 /* Offline tests */ 1728 /* Offline tests */
1712 1729
@@ -1717,18 +1734,9 @@ static void e1000_diag_test(struct net_device *netdev,
1717 1734
1718 e_info("offline testing starting\n"); 1735 e_info("offline testing starting\n");
1719 1736
1720 /*
1721 * Link test performed before hardware reset so autoneg doesn't
1722 * interfere with test result
1723 */
1724 if (e1000_link_test(adapter, &data[4]))
1725 eth_test->flags |= ETH_TEST_FL_FAILED;
1726
1727 if (if_running) 1737 if (if_running)
1728 /* indicate we're in test mode */ 1738 /* indicate we're in test mode */
1729 dev_close(netdev); 1739 dev_close(netdev);
1730 else
1731 e1000e_reset(adapter);
1732 1740
1733 if (e1000_reg_test(adapter, &data[0])) 1741 if (e1000_reg_test(adapter, &data[0]))
1734 eth_test->flags |= ETH_TEST_FL_FAILED; 1742 eth_test->flags |= ETH_TEST_FL_FAILED;
@@ -1742,47 +1750,50 @@ static void e1000_diag_test(struct net_device *netdev,
1742 eth_test->flags |= ETH_TEST_FL_FAILED; 1750 eth_test->flags |= ETH_TEST_FL_FAILED;
1743 1751
1744 e1000e_reset(adapter); 1752 e1000e_reset(adapter);
1745 /* make sure the phy is powered up */
1746 e1000e_power_up_phy(adapter);
1747 if (e1000_loopback_test(adapter, &data[3])) 1753 if (e1000_loopback_test(adapter, &data[3]))
1748 eth_test->flags |= ETH_TEST_FL_FAILED; 1754 eth_test->flags |= ETH_TEST_FL_FAILED;
1749 1755
1756 /* force this routine to wait until autoneg complete/timeout */
1757 adapter->hw.phy.autoneg_wait_to_complete = 1;
1758 e1000e_reset(adapter);
1759 adapter->hw.phy.autoneg_wait_to_complete = 0;
1760
1761 if (e1000_link_test(adapter, &data[4]))
1762 eth_test->flags |= ETH_TEST_FL_FAILED;
1763
1750 /* restore speed, duplex, autoneg settings */ 1764 /* restore speed, duplex, autoneg settings */
1751 adapter->hw.phy.autoneg_advertised = autoneg_advertised; 1765 adapter->hw.phy.autoneg_advertised = autoneg_advertised;
1752 adapter->hw.mac.forced_speed_duplex = forced_speed_duplex; 1766 adapter->hw.mac.forced_speed_duplex = forced_speed_duplex;
1753 adapter->hw.mac.autoneg = autoneg; 1767 adapter->hw.mac.autoneg = autoneg;
1754
1755 /* force this routine to wait until autoneg complete/timeout */
1756 adapter->hw.phy.autoneg_wait_to_complete = 1;
1757 e1000e_reset(adapter); 1768 e1000e_reset(adapter);
1758 adapter->hw.phy.autoneg_wait_to_complete = 0;
1759 1769
1760 clear_bit(__E1000_TESTING, &adapter->state); 1770 clear_bit(__E1000_TESTING, &adapter->state);
1761 if (if_running) 1771 if (if_running)
1762 dev_open(netdev); 1772 dev_open(netdev);
1763 } else { 1773 } else {
1764 if (!if_running && (adapter->flags & FLAG_HAS_AMT)) { 1774 /* Online tests */
1765 clear_bit(__E1000_TESTING, &adapter->state);
1766 dev_open(netdev);
1767 set_bit(__E1000_TESTING, &adapter->state);
1768 }
1769 1775
1770 e_info("online testing starting\n"); 1776 e_info("online testing starting\n");
1771 /* Online tests */
1772 if (e1000_link_test(adapter, &data[4]))
1773 eth_test->flags |= ETH_TEST_FL_FAILED;
1774 1777
1775 /* Online tests aren't run; pass by default */ 1778 /* register, eeprom, intr and loopback tests not run online */
1776 data[0] = 0; 1779 data[0] = 0;
1777 data[1] = 0; 1780 data[1] = 0;
1778 data[2] = 0; 1781 data[2] = 0;
1779 data[3] = 0; 1782 data[3] = 0;
1780 1783
1781 if (!if_running && (adapter->flags & FLAG_HAS_AMT)) 1784 if (e1000_link_test(adapter, &data[4]))
1782 dev_close(netdev); 1785 eth_test->flags |= ETH_TEST_FL_FAILED;
1783 1786
1784 clear_bit(__E1000_TESTING, &adapter->state); 1787 clear_bit(__E1000_TESTING, &adapter->state);
1785 } 1788 }
1789
1790 if (!if_running) {
1791 e1000e_reset(adapter);
1792
1793 if (adapter->flags & FLAG_HAS_AMT)
1794 e1000e_release_hw_control(adapter);
1795 }
1796
1786 msleep_interruptible(4 * 1000); 1797 msleep_interruptible(4 * 1000);
1787} 1798}
1788 1799
@@ -1799,8 +1810,7 @@ static void e1000_get_wol(struct net_device *netdev,
1799 return; 1810 return;
1800 1811
1801 wol->supported = WAKE_UCAST | WAKE_MCAST | 1812 wol->supported = WAKE_UCAST | WAKE_MCAST |
1802 WAKE_BCAST | WAKE_MAGIC | 1813 WAKE_BCAST | WAKE_MAGIC | WAKE_PHY;
1803 WAKE_PHY | WAKE_ARP;
1804 1814
1805 /* apply any specific unsupported masks here */ 1815 /* apply any specific unsupported masks here */
1806 if (adapter->flags & FLAG_NO_WAKE_UCAST) { 1816 if (adapter->flags & FLAG_NO_WAKE_UCAST) {
@@ -1821,19 +1831,16 @@ static void e1000_get_wol(struct net_device *netdev,
1821 wol->wolopts |= WAKE_MAGIC; 1831 wol->wolopts |= WAKE_MAGIC;
1822 if (adapter->wol & E1000_WUFC_LNKC) 1832 if (adapter->wol & E1000_WUFC_LNKC)
1823 wol->wolopts |= WAKE_PHY; 1833 wol->wolopts |= WAKE_PHY;
1824 if (adapter->wol & E1000_WUFC_ARP)
1825 wol->wolopts |= WAKE_ARP;
1826} 1834}
1827 1835
1828static int e1000_set_wol(struct net_device *netdev, 1836static int e1000_set_wol(struct net_device *netdev, struct ethtool_wolinfo *wol)
1829 struct ethtool_wolinfo *wol)
1830{ 1837{
1831 struct e1000_adapter *adapter = netdev_priv(netdev); 1838 struct e1000_adapter *adapter = netdev_priv(netdev);
1832 1839
1833 if (!(adapter->flags & FLAG_HAS_WOL) || 1840 if (!(adapter->flags & FLAG_HAS_WOL) ||
1834 !device_can_wakeup(&adapter->pdev->dev) || 1841 !device_can_wakeup(&adapter->pdev->dev) ||
1835 (wol->wolopts & ~(WAKE_UCAST | WAKE_MCAST | WAKE_BCAST | 1842 (wol->wolopts & ~(WAKE_UCAST | WAKE_MCAST | WAKE_BCAST |
1836 WAKE_MAGIC | WAKE_PHY | WAKE_ARP))) 1843 WAKE_MAGIC | WAKE_PHY)))
1837 return -EOPNOTSUPP; 1844 return -EOPNOTSUPP;
1838 1845
1839 /* these settings will always override what we currently have */ 1846 /* these settings will always override what we currently have */
@@ -1849,73 +1856,41 @@ static int e1000_set_wol(struct net_device *netdev,
1849 adapter->wol |= E1000_WUFC_MAG; 1856 adapter->wol |= E1000_WUFC_MAG;
1850 if (wol->wolopts & WAKE_PHY) 1857 if (wol->wolopts & WAKE_PHY)
1851 adapter->wol |= E1000_WUFC_LNKC; 1858 adapter->wol |= E1000_WUFC_LNKC;
1852 if (wol->wolopts & WAKE_ARP)
1853 adapter->wol |= E1000_WUFC_ARP;
1854 1859
1855 device_set_wakeup_enable(&adapter->pdev->dev, adapter->wol); 1860 device_set_wakeup_enable(&adapter->pdev->dev, adapter->wol);
1856 1861
1857 return 0; 1862 return 0;
1858} 1863}
1859 1864
1860/* toggle LED 4 times per second = 2 "blinks" per second */ 1865static int e1000_set_phys_id(struct net_device *netdev,
1861#define E1000_ID_INTERVAL (HZ/4) 1866 enum ethtool_phys_id_state state)
1862
1863/* bit defines for adapter->led_status */
1864#define E1000_LED_ON 0
1865
1866static void e1000e_led_blink_task(struct work_struct *work)
1867{
1868 struct e1000_adapter *adapter = container_of(work,
1869 struct e1000_adapter, led_blink_task);
1870
1871 if (test_and_change_bit(E1000_LED_ON, &adapter->led_status))
1872 adapter->hw.mac.ops.led_off(&adapter->hw);
1873 else
1874 adapter->hw.mac.ops.led_on(&adapter->hw);
1875}
1876
1877static void e1000_led_blink_callback(unsigned long data)
1878{
1879 struct e1000_adapter *adapter = (struct e1000_adapter *) data;
1880
1881 schedule_work(&adapter->led_blink_task);
1882 mod_timer(&adapter->blink_timer, jiffies + E1000_ID_INTERVAL);
1883}
1884
1885static int e1000_phys_id(struct net_device *netdev, u32 data)
1886{ 1867{
1887 struct e1000_adapter *adapter = netdev_priv(netdev); 1868 struct e1000_adapter *adapter = netdev_priv(netdev);
1888 struct e1000_hw *hw = &adapter->hw; 1869 struct e1000_hw *hw = &adapter->hw;
1889 1870
1890 if (!data) 1871 switch (state) {
1891 data = INT_MAX; 1872 case ETHTOOL_ID_ACTIVE:
1873 if (!hw->mac.ops.blink_led)
1874 return 2; /* cycle on/off twice per second */
1892 1875
1893 if ((hw->phy.type == e1000_phy_ife) || 1876 hw->mac.ops.blink_led(hw);
1894 (hw->mac.type == e1000_pchlan) || 1877 break;
1895 (hw->mac.type == e1000_pch2lan) || 1878
1896 (hw->mac.type == e1000_82583) || 1879 case ETHTOOL_ID_INACTIVE:
1897 (hw->mac.type == e1000_82574)) {
1898 INIT_WORK(&adapter->led_blink_task, e1000e_led_blink_task);
1899 if (!adapter->blink_timer.function) {
1900 init_timer(&adapter->blink_timer);
1901 adapter->blink_timer.function =
1902 e1000_led_blink_callback;
1903 adapter->blink_timer.data = (unsigned long) adapter;
1904 }
1905 mod_timer(&adapter->blink_timer, jiffies);
1906 msleep_interruptible(data * 1000);
1907 del_timer_sync(&adapter->blink_timer);
1908 if (hw->phy.type == e1000_phy_ife) 1880 if (hw->phy.type == e1000_phy_ife)
1909 e1e_wphy(hw, IFE_PHY_SPECIAL_CONTROL_LED, 0); 1881 e1e_wphy(hw, IFE_PHY_SPECIAL_CONTROL_LED, 0);
1910 } else { 1882 hw->mac.ops.led_off(hw);
1911 e1000e_blink_led(hw); 1883 hw->mac.ops.cleanup_led(hw);
1912 msleep_interruptible(data * 1000); 1884 break;
1913 }
1914 1885
1915 hw->mac.ops.led_off(hw); 1886 case ETHTOOL_ID_ON:
1916 clear_bit(E1000_LED_ON, &adapter->led_status); 1887 adapter->hw.mac.ops.led_on(&adapter->hw);
1917 hw->mac.ops.cleanup_led(hw); 1888 break;
1918 1889
1890 case ETHTOOL_ID_OFF:
1891 adapter->hw.mac.ops.led_off(&adapter->hw);
1892 break;
1893 }
1919 return 0; 1894 return 0;
1920} 1895}
1921 1896
@@ -1965,8 +1940,15 @@ static int e1000_set_coalesce(struct net_device *netdev,
1965static int e1000_nway_reset(struct net_device *netdev) 1940static int e1000_nway_reset(struct net_device *netdev)
1966{ 1941{
1967 struct e1000_adapter *adapter = netdev_priv(netdev); 1942 struct e1000_adapter *adapter = netdev_priv(netdev);
1968 if (netif_running(netdev)) 1943
1969 e1000e_reinit_locked(adapter); 1944 if (!netif_running(netdev))
1945 return -EAGAIN;
1946
1947 if (!adapter->hw.mac.autoneg)
1948 return -EINVAL;
1949
1950 e1000e_reinit_locked(adapter);
1951
1970 return 0; 1952 return 0;
1971} 1953}
1972 1954
@@ -1975,20 +1957,24 @@ static void e1000_get_ethtool_stats(struct net_device *netdev,
1975 u64 *data) 1957 u64 *data)
1976{ 1958{
1977 struct e1000_adapter *adapter = netdev_priv(netdev); 1959 struct e1000_adapter *adapter = netdev_priv(netdev);
1960 struct rtnl_link_stats64 net_stats;
1978 int i; 1961 int i;
1979 char *p = NULL; 1962 char *p = NULL;
1980 1963
1981 e1000e_update_stats(adapter); 1964 e1000e_get_stats64(netdev, &net_stats);
1982 for (i = 0; i < E1000_GLOBAL_STATS_LEN; i++) { 1965 for (i = 0; i < E1000_GLOBAL_STATS_LEN; i++) {
1983 switch (e1000_gstrings_stats[i].type) { 1966 switch (e1000_gstrings_stats[i].type) {
1984 case NETDEV_STATS: 1967 case NETDEV_STATS:
1985 p = (char *) netdev + 1968 p = (char *) &net_stats +
1986 e1000_gstrings_stats[i].stat_offset; 1969 e1000_gstrings_stats[i].stat_offset;
1987 break; 1970 break;
1988 case E1000_STATS: 1971 case E1000_STATS:
1989 p = (char *) adapter + 1972 p = (char *) adapter +
1990 e1000_gstrings_stats[i].stat_offset; 1973 e1000_gstrings_stats[i].stat_offset;
1991 break; 1974 break;
1975 default:
1976 data[i] = 0;
1977 continue;
1992 } 1978 }
1993 1979
1994 data[i] = (e1000_gstrings_stats[i].sizeof_stat == 1980 data[i] = (e1000_gstrings_stats[i].sizeof_stat ==
@@ -2004,7 +1990,7 @@ static void e1000_get_strings(struct net_device *netdev, u32 stringset,
2004 1990
2005 switch (stringset) { 1991 switch (stringset) {
2006 case ETH_SS_TEST: 1992 case ETH_SS_TEST:
2007 memcpy(data, *e1000_gstrings_test, sizeof(e1000_gstrings_test)); 1993 memcpy(data, e1000_gstrings_test, sizeof(e1000_gstrings_test));
2008 break; 1994 break;
2009 case ETH_SS_STATS: 1995 case ETH_SS_STATS:
2010 for (i = 0; i < E1000_GLOBAL_STATS_LEN; i++) { 1996 for (i = 0; i < E1000_GLOBAL_STATS_LEN; i++) {
@@ -2016,6 +2002,31 @@ static void e1000_get_strings(struct net_device *netdev, u32 stringset,
2016 } 2002 }
2017} 2003}
2018 2004
2005static int e1000e_set_flags(struct net_device *netdev, u32 data)
2006{
2007 struct e1000_adapter *adapter = netdev_priv(netdev);
2008 bool need_reset = false;
2009 int rc;
2010
2011 need_reset = (data & ETH_FLAG_RXVLAN) !=
2012 (netdev->features & NETIF_F_HW_VLAN_RX);
2013
2014 rc = ethtool_op_set_flags(netdev, data, ETH_FLAG_RXVLAN |
2015 ETH_FLAG_TXVLAN);
2016
2017 if (rc)
2018 return rc;
2019
2020 if (need_reset) {
2021 if (netif_running(netdev))
2022 e1000e_reinit_locked(adapter);
2023 else
2024 e1000e_reset(adapter);
2025 }
2026
2027 return 0;
2028}
2029
2019static const struct ethtool_ops e1000_ethtool_ops = { 2030static const struct ethtool_ops e1000_ethtool_ops = {
2020 .get_settings = e1000_get_settings, 2031 .get_settings = e1000_get_settings,
2021 .set_settings = e1000_set_settings, 2032 .set_settings = e1000_set_settings,
@@ -2027,7 +2038,7 @@ static const struct ethtool_ops e1000_ethtool_ops = {
2027 .get_msglevel = e1000_get_msglevel, 2038 .get_msglevel = e1000_get_msglevel,
2028 .set_msglevel = e1000_set_msglevel, 2039 .set_msglevel = e1000_set_msglevel,
2029 .nway_reset = e1000_nway_reset, 2040 .nway_reset = e1000_nway_reset,
2030 .get_link = e1000_get_link, 2041 .get_link = ethtool_op_get_link,
2031 .get_eeprom_len = e1000_get_eeprom_len, 2042 .get_eeprom_len = e1000_get_eeprom_len,
2032 .get_eeprom = e1000_get_eeprom, 2043 .get_eeprom = e1000_get_eeprom,
2033 .set_eeprom = e1000_set_eeprom, 2044 .set_eeprom = e1000_set_eeprom,
@@ -2045,12 +2056,13 @@ static const struct ethtool_ops e1000_ethtool_ops = {
2045 .set_tso = e1000_set_tso, 2056 .set_tso = e1000_set_tso,
2046 .self_test = e1000_diag_test, 2057 .self_test = e1000_diag_test,
2047 .get_strings = e1000_get_strings, 2058 .get_strings = e1000_get_strings,
2048 .phys_id = e1000_phys_id, 2059 .set_phys_id = e1000_set_phys_id,
2049 .get_ethtool_stats = e1000_get_ethtool_stats, 2060 .get_ethtool_stats = e1000_get_ethtool_stats,
2050 .get_sset_count = e1000e_get_sset_count, 2061 .get_sset_count = e1000e_get_sset_count,
2051 .get_coalesce = e1000_get_coalesce, 2062 .get_coalesce = e1000_get_coalesce,
2052 .set_coalesce = e1000_set_coalesce, 2063 .set_coalesce = e1000_set_coalesce,
2053 .get_flags = ethtool_op_get_flags, 2064 .get_flags = ethtool_op_get_flags,
2065 .set_flags = e1000e_set_flags,
2054}; 2066};
2055 2067
2056void e1000e_set_ethtool_ops(struct net_device *netdev) 2068void e1000e_set_ethtool_ops(struct net_device *netdev)
diff --git a/drivers/net/e1000e/hw.h b/drivers/net/e1000e/hw.h
index ba302a5c2c30..6c2fa8327f5c 100644
--- a/drivers/net/e1000e/hw.h
+++ b/drivers/net/e1000e/hw.h
@@ -1,7 +1,7 @@
1/******************************************************************************* 1/*******************************************************************************
2 2
3 Intel PRO/1000 Linux driver 3 Intel PRO/1000 Linux driver
4 Copyright(c) 1999 - 2010 Intel Corporation. 4 Copyright(c) 1999 - 2011 Intel Corporation.
5 5
6 This program is free software; you can redistribute it and/or modify it 6 This program is free software; you can redistribute it and/or modify it
7 under the terms and conditions of the GNU General Public License, 7 under the terms and conditions of the GNU General Public License,
@@ -83,6 +83,7 @@ enum e1e_registers {
83 E1000_EXTCNF_CTRL = 0x00F00, /* Extended Configuration Control */ 83 E1000_EXTCNF_CTRL = 0x00F00, /* Extended Configuration Control */
84 E1000_EXTCNF_SIZE = 0x00F08, /* Extended Configuration Size */ 84 E1000_EXTCNF_SIZE = 0x00F08, /* Extended Configuration Size */
85 E1000_PHY_CTRL = 0x00F10, /* PHY Control Register in CSR */ 85 E1000_PHY_CTRL = 0x00F10, /* PHY Control Register in CSR */
86#define E1000_POEMB E1000_PHY_CTRL /* PHY OEM Bits */
86 E1000_PBA = 0x01000, /* Packet Buffer Allocation - RW */ 87 E1000_PBA = 0x01000, /* Packet Buffer Allocation - RW */
87 E1000_PBS = 0x01008, /* Packet Buffer Size */ 88 E1000_PBS = 0x01008, /* Packet Buffer Size */
88 E1000_EEMNGCTL = 0x01010, /* MNG EEprom Control */ 89 E1000_EEMNGCTL = 0x01010, /* MNG EEprom Control */
@@ -101,7 +102,7 @@ enum e1e_registers {
101 E1000_RDTR = 0x02820, /* Rx Delay Timer - RW */ 102 E1000_RDTR = 0x02820, /* Rx Delay Timer - RW */
102 E1000_RXDCTL_BASE = 0x02828, /* Rx Descriptor Control - RW */ 103 E1000_RXDCTL_BASE = 0x02828, /* Rx Descriptor Control - RW */
103#define E1000_RXDCTL(_n) (E1000_RXDCTL_BASE + (_n << 8)) 104#define E1000_RXDCTL(_n) (E1000_RXDCTL_BASE + (_n << 8))
104 E1000_RADV = 0x0282C, /* RX Interrupt Absolute Delay Timer - RW */ 105 E1000_RADV = 0x0282C, /* Rx Interrupt Absolute Delay Timer - RW */
105 106
106/* Convenience macros 107/* Convenience macros
107 * 108 *
@@ -755,6 +756,7 @@ struct e1000_host_mng_command_info {
755/* Function pointers and static data for the MAC. */ 756/* Function pointers and static data for the MAC. */
756struct e1000_mac_operations { 757struct e1000_mac_operations {
757 s32 (*id_led_init)(struct e1000_hw *); 758 s32 (*id_led_init)(struct e1000_hw *);
759 s32 (*blink_led)(struct e1000_hw *);
758 bool (*check_mng_mode)(struct e1000_hw *); 760 bool (*check_mng_mode)(struct e1000_hw *);
759 s32 (*check_for_link)(struct e1000_hw *); 761 s32 (*check_for_link)(struct e1000_hw *);
760 s32 (*cleanup_led)(struct e1000_hw *); 762 s32 (*cleanup_led)(struct e1000_hw *);
@@ -811,9 +813,8 @@ struct e1000_nvm_operations {
811 813
812struct e1000_mac_info { 814struct e1000_mac_info {
813 struct e1000_mac_operations ops; 815 struct e1000_mac_operations ops;
814 816 u8 addr[ETH_ALEN];
815 u8 addr[6]; 817 u8 perm_addr[ETH_ALEN];
816 u8 perm_addr[6];
817 818
818 enum e1000_mac_type type; 819 enum e1000_mac_type type;
819 820
diff --git a/drivers/net/e1000e/ich8lan.c b/drivers/net/e1000e/ich8lan.c
index 57b5435599ab..3369d1f6a39c 100644
--- a/drivers/net/e1000e/ich8lan.c
+++ b/drivers/net/e1000e/ich8lan.c
@@ -1,7 +1,7 @@
1/******************************************************************************* 1/*******************************************************************************
2 2
3 Intel PRO/1000 Linux driver 3 Intel PRO/1000 Linux driver
4 Copyright(c) 1999 - 2010 Intel Corporation. 4 Copyright(c) 1999 - 2011 Intel Corporation.
5 5
6 This program is free software; you can redistribute it and/or modify it 6 This program is free software; you can redistribute it and/or modify it
7 under the terms and conditions of the GNU General Public License, 7 under the terms and conditions of the GNU General Public License,
@@ -140,6 +140,11 @@
140#define I82579_LPI_CTRL PHY_REG(772, 20) 140#define I82579_LPI_CTRL PHY_REG(772, 20)
141#define I82579_LPI_CTRL_ENABLE_MASK 0x6000 141#define I82579_LPI_CTRL_ENABLE_MASK 0x6000
142 142
143/* EMI Registers */
144#define I82579_EMI_ADDR 0x10
145#define I82579_EMI_DATA 0x11
146#define I82579_LPI_UPDATE_TIMER 0x4805 /* in 40ns units + 40 ns base value */
147
143/* Strapping Option Register - RO */ 148/* Strapping Option Register - RO */
144#define E1000_STRAP 0x0000C 149#define E1000_STRAP 0x0000C
145#define E1000_STRAP_SMBUS_ADDRESS_MASK 0x00FE0000 150#define E1000_STRAP_SMBUS_ADDRESS_MASK 0x00FE0000
@@ -302,9 +307,9 @@ static s32 e1000_init_phy_params_pchlan(struct e1000_hw *hw)
302 * the interconnect to PCIe mode. 307 * the interconnect to PCIe mode.
303 */ 308 */
304 fwsm = er32(FWSM); 309 fwsm = er32(FWSM);
305 if (!(fwsm & E1000_ICH_FWSM_FW_VALID)) { 310 if (!(fwsm & E1000_ICH_FWSM_FW_VALID) && !e1000_check_reset_block(hw)) {
306 ctrl = er32(CTRL); 311 ctrl = er32(CTRL);
307 ctrl |= E1000_CTRL_LANPHYPC_OVERRIDE; 312 ctrl |= E1000_CTRL_LANPHYPC_OVERRIDE;
308 ctrl &= ~E1000_CTRL_LANPHYPC_VALUE; 313 ctrl &= ~E1000_CTRL_LANPHYPC_VALUE;
309 ew32(CTRL, ctrl); 314 ew32(CTRL, ctrl);
310 udelay(10); 315 udelay(10);
@@ -321,7 +326,7 @@ static s32 e1000_init_phy_params_pchlan(struct e1000_hw *hw)
321 } 326 }
322 327
323 /* 328 /*
324 * Reset the PHY before any acccess to it. Doing so, ensures that 329 * Reset the PHY before any access to it. Doing so, ensures that
325 * the PHY is in a known good state before we read/write PHY registers. 330 * the PHY is in a known good state before we read/write PHY registers.
326 * The generic reset is sufficient here, because we haven't determined 331 * The generic reset is sufficient here, because we haven't determined
327 * the PHY type yet. 332 * the PHY type yet.
@@ -331,19 +336,24 @@ static s32 e1000_init_phy_params_pchlan(struct e1000_hw *hw)
331 goto out; 336 goto out;
332 337
333 /* Ungate automatic PHY configuration on non-managed 82579 */ 338 /* Ungate automatic PHY configuration on non-managed 82579 */
334 if ((hw->mac.type == e1000_pch2lan) && 339 if ((hw->mac.type == e1000_pch2lan) &&
335 !(fwsm & E1000_ICH_FWSM_FW_VALID)) { 340 !(fwsm & E1000_ICH_FWSM_FW_VALID)) {
336 msleep(10); 341 usleep_range(10000, 20000);
337 e1000_gate_hw_phy_config_ich8lan(hw, false); 342 e1000_gate_hw_phy_config_ich8lan(hw, false);
338 } 343 }
339 344
340 phy->id = e1000_phy_unknown; 345 phy->id = e1000_phy_unknown;
341 ret_val = e1000e_get_phy_id(hw); 346 switch (hw->mac.type) {
342 if (ret_val) 347 default:
343 goto out; 348 ret_val = e1000e_get_phy_id(hw);
344 if ((phy->id == 0) || (phy->id == PHY_REVISION_MASK)) { 349 if (ret_val)
350 goto out;
351 if ((phy->id != 0) && (phy->id != PHY_REVISION_MASK))
352 break;
353 /* fall-through */
354 case e1000_pch2lan:
345 /* 355 /*
346 * In case the PHY needs to be in mdio slow mode (eg. 82577), 356 * In case the PHY needs to be in mdio slow mode,
347 * set slow mode and try to get the PHY id again. 357 * set slow mode and try to get the PHY id again.
348 */ 358 */
349 ret_val = e1000_set_mdio_slow_mode_hv(hw); 359 ret_val = e1000_set_mdio_slow_mode_hv(hw);
@@ -352,6 +362,7 @@ static s32 e1000_init_phy_params_pchlan(struct e1000_hw *hw)
352 ret_val = e1000e_get_phy_id(hw); 362 ret_val = e1000e_get_phy_id(hw);
353 if (ret_val) 363 if (ret_val)
354 goto out; 364 goto out;
365 break;
355 } 366 }
356 phy->type = e1000e_get_phy_type_from_id(phy->id); 367 phy->type = e1000e_get_phy_type_from_id(phy->id);
357 368
@@ -360,7 +371,7 @@ static s32 e1000_init_phy_params_pchlan(struct e1000_hw *hw)
360 case e1000_phy_82579: 371 case e1000_phy_82579:
361 phy->ops.check_polarity = e1000_check_polarity_82577; 372 phy->ops.check_polarity = e1000_check_polarity_82577;
362 phy->ops.force_speed_duplex = 373 phy->ops.force_speed_duplex =
363 e1000_phy_force_speed_duplex_82577; 374 e1000_phy_force_speed_duplex_82577;
364 phy->ops.get_cable_length = e1000_get_cable_length_82577; 375 phy->ops.get_cable_length = e1000_get_cable_length_82577;
365 phy->ops.get_info = e1000_get_phy_info_82577; 376 phy->ops.get_info = e1000_get_phy_info_82577;
366 phy->ops.commit = e1000e_phy_sw_reset; 377 phy->ops.commit = e1000e_phy_sw_reset;
@@ -416,7 +427,7 @@ static s32 e1000_init_phy_params_ich8lan(struct e1000_hw *hw)
416 phy->id = 0; 427 phy->id = 0;
417 while ((e1000_phy_unknown == e1000e_get_phy_type_from_id(phy->id)) && 428 while ((e1000_phy_unknown == e1000e_get_phy_type_from_id(phy->id)) &&
418 (i++ < 100)) { 429 (i++ < 100)) {
419 msleep(1); 430 usleep_range(1000, 2000);
420 ret_val = e1000e_get_phy_id(hw); 431 ret_val = e1000e_get_phy_id(hw);
421 if (ret_val) 432 if (ret_val)
422 return ret_val; 433 return ret_val;
@@ -553,6 +564,8 @@ static s32 e1000_init_mac_params_ich8lan(struct e1000_adapter *adapter)
553 mac->ops.check_mng_mode = e1000_check_mng_mode_ich8lan; 564 mac->ops.check_mng_mode = e1000_check_mng_mode_ich8lan;
554 /* ID LED init */ 565 /* ID LED init */
555 mac->ops.id_led_init = e1000e_id_led_init; 566 mac->ops.id_led_init = e1000e_id_led_init;
567 /* blink LED */
568 mac->ops.blink_led = e1000e_blink_led_generic;
556 /* setup LED */ 569 /* setup LED */
557 mac->ops.setup_led = e1000e_setup_led_generic; 570 mac->ops.setup_led = e1000e_setup_led_generic;
558 /* cleanup LED */ 571 /* cleanup LED */
@@ -747,9 +760,17 @@ static s32 e1000_get_variants_ich8lan(struct e1000_adapter *adapter)
747 if (rc) 760 if (rc)
748 return rc; 761 return rc;
749 762
750 if (adapter->hw.phy.type == e1000_phy_ife) { 763 /*
764 * Disable Jumbo Frame support on parts with Intel 10/100 PHY or
765 * on parts with MACsec enabled in NVM (reflected in CTRL_EXT).
766 */
767 if ((adapter->hw.phy.type == e1000_phy_ife) ||
768 ((adapter->hw.mac.type >= e1000_pch2lan) &&
769 (!(er32(CTRL_EXT) & E1000_CTRL_EXT_LSECCK)))) {
751 adapter->flags &= ~FLAG_HAS_JUMBO_FRAMES; 770 adapter->flags &= ~FLAG_HAS_JUMBO_FRAMES;
752 adapter->max_hw_frame_size = ETH_FRAME_LEN + ETH_FCS_LEN; 771 adapter->max_hw_frame_size = ETH_FRAME_LEN + ETH_FCS_LEN;
772
773 hw->mac.ops.blink_led = NULL;
753 } 774 }
754 775
755 if ((adapter->hw.mac.type == e1000_ich8lan) && 776 if ((adapter->hw.mac.type == e1000_ich8lan) &&
@@ -1389,22 +1410,6 @@ void e1000_copy_rx_addrs_to_phy_ich8lan(struct e1000_hw *hw)
1389 } 1410 }
1390} 1411}
1391 1412
1392static u32 e1000_calc_rx_da_crc(u8 mac[])
1393{
1394 u32 poly = 0xEDB88320; /* Polynomial for 802.3 CRC calculation */
1395 u32 i, j, mask, crc;
1396
1397 crc = 0xffffffff;
1398 for (i = 0; i < 6; i++) {
1399 crc = crc ^ mac[i];
1400 for (j = 8; j > 0; j--) {
1401 mask = (crc & 1) * (-1);
1402 crc = (crc >> 1) ^ (poly & mask);
1403 }
1404 }
1405 return ~crc;
1406}
1407
1408/** 1413/**
1409 * e1000_lv_jumbo_workaround_ich8lan - required for jumbo frame operation 1414 * e1000_lv_jumbo_workaround_ich8lan - required for jumbo frame operation
1410 * with 82579 PHY 1415 * with 82579 PHY
@@ -1447,8 +1452,7 @@ s32 e1000_lv_jumbo_workaround_ich8lan(struct e1000_hw *hw, bool enable)
1447 mac_addr[4] = (addr_high & 0xFF); 1452 mac_addr[4] = (addr_high & 0xFF);
1448 mac_addr[5] = ((addr_high >> 8) & 0xFF); 1453 mac_addr[5] = ((addr_high >> 8) & 0xFF);
1449 1454
1450 ew32(PCH_RAICC(i), 1455 ew32(PCH_RAICC(i), ~ether_crc_le(ETH_ALEN, mac_addr));
1451 e1000_calc_rx_da_crc(mac_addr));
1452 } 1456 }
1453 1457
1454 /* Write Rx addresses to the PHY */ 1458 /* Write Rx addresses to the PHY */
@@ -1704,7 +1708,7 @@ static s32 e1000_post_phy_reset_ich8lan(struct e1000_hw *hw)
1704 goto out; 1708 goto out;
1705 1709
1706 /* Allow time for h/w to get to quiescent state after reset */ 1710 /* Allow time for h/w to get to quiescent state after reset */
1707 msleep(10); 1711 usleep_range(10000, 20000);
1708 1712
1709 /* Perform any necessary post-reset workarounds */ 1713 /* Perform any necessary post-reset workarounds */
1710 switch (hw->mac.type) { 1714 switch (hw->mac.type) {
@@ -1734,11 +1738,25 @@ static s32 e1000_post_phy_reset_ich8lan(struct e1000_hw *hw)
1734 /* Configure the LCD with the OEM bits in NVM */ 1738 /* Configure the LCD with the OEM bits in NVM */
1735 ret_val = e1000_oem_bits_config_ich8lan(hw, true); 1739 ret_val = e1000_oem_bits_config_ich8lan(hw, true);
1736 1740
1737 /* Ungate automatic PHY configuration on non-managed 82579 */ 1741 if (hw->mac.type == e1000_pch2lan) {
1738 if ((hw->mac.type == e1000_pch2lan) && 1742 /* Ungate automatic PHY configuration on non-managed 82579 */
1739 !(er32(FWSM) & E1000_ICH_FWSM_FW_VALID)) { 1743 if (!(er32(FWSM) & E1000_ICH_FWSM_FW_VALID)) {
1740 msleep(10); 1744 usleep_range(10000, 20000);
1741 e1000_gate_hw_phy_config_ich8lan(hw, false); 1745 e1000_gate_hw_phy_config_ich8lan(hw, false);
1746 }
1747
1748 /* Set EEE LPI Update Timer to 200usec */
1749 ret_val = hw->phy.ops.acquire(hw);
1750 if (ret_val)
1751 goto out;
1752 ret_val = hw->phy.ops.write_reg_locked(hw, I82579_EMI_ADDR,
1753 I82579_LPI_UPDATE_TIMER);
1754 if (ret_val)
1755 goto release;
1756 ret_val = hw->phy.ops.write_reg_locked(hw, I82579_EMI_DATA,
1757 0x1387);
1758release:
1759 hw->phy.ops.release(hw);
1742 } 1760 }
1743 1761
1744out: 1762out:
@@ -2115,7 +2133,6 @@ static s32 e1000_flash_cycle_init_ich8lan(struct e1000_hw *hw)
2115{ 2133{
2116 union ich8_hws_flash_status hsfsts; 2134 union ich8_hws_flash_status hsfsts;
2117 s32 ret_val = -E1000_ERR_NVM; 2135 s32 ret_val = -E1000_ERR_NVM;
2118 s32 i = 0;
2119 2136
2120 hsfsts.regval = er16flash(ICH_FLASH_HSFSTS); 2137 hsfsts.regval = er16flash(ICH_FLASH_HSFSTS);
2121 2138
@@ -2151,6 +2168,8 @@ static s32 e1000_flash_cycle_init_ich8lan(struct e1000_hw *hw)
2151 ew16flash(ICH_FLASH_HSFSTS, hsfsts.regval); 2168 ew16flash(ICH_FLASH_HSFSTS, hsfsts.regval);
2152 ret_val = 0; 2169 ret_val = 0;
2153 } else { 2170 } else {
2171 s32 i = 0;
2172
2154 /* 2173 /*
2155 * Otherwise poll for sometime so the current 2174 * Otherwise poll for sometime so the current
2156 * cycle has a chance to end before giving up. 2175 * cycle has a chance to end before giving up.
@@ -2303,11 +2322,10 @@ static s32 e1000_read_flash_data_ich8lan(struct e1000_hw *hw, u32 offset,
2303 */ 2322 */
2304 if (ret_val == 0) { 2323 if (ret_val == 0) {
2305 flash_data = er32flash(ICH_FLASH_FDATA0); 2324 flash_data = er32flash(ICH_FLASH_FDATA0);
2306 if (size == 1) { 2325 if (size == 1)
2307 *data = (u8)(flash_data & 0x000000FF); 2326 *data = (u8)(flash_data & 0x000000FF);
2308 } else if (size == 2) { 2327 else if (size == 2)
2309 *data = (u16)(flash_data & 0x0000FFFF); 2328 *data = (u16)(flash_data & 0x0000FFFF);
2310 }
2311 break; 2329 break;
2312 } else { 2330 } else {
2313 /* 2331 /*
@@ -2518,7 +2536,7 @@ release:
2518 */ 2536 */
2519 if (!ret_val) { 2537 if (!ret_val) {
2520 e1000e_reload_nvm(hw); 2538 e1000e_reload_nvm(hw);
2521 msleep(10); 2539 usleep_range(10000, 20000);
2522 } 2540 }
2523 2541
2524out: 2542out:
@@ -2972,7 +2990,7 @@ static s32 e1000_reset_hw_ich8lan(struct e1000_hw *hw)
2972{ 2990{
2973 struct e1000_dev_spec_ich8lan *dev_spec = &hw->dev_spec.ich8lan; 2991 struct e1000_dev_spec_ich8lan *dev_spec = &hw->dev_spec.ich8lan;
2974 u16 reg; 2992 u16 reg;
2975 u32 ctrl, icr, kab; 2993 u32 ctrl, kab;
2976 s32 ret_val; 2994 s32 ret_val;
2977 2995
2978 /* 2996 /*
@@ -2995,7 +3013,7 @@ static s32 e1000_reset_hw_ich8lan(struct e1000_hw *hw)
2995 ew32(TCTL, E1000_TCTL_PSP); 3013 ew32(TCTL, E1000_TCTL_PSP);
2996 e1e_flush(); 3014 e1e_flush();
2997 3015
2998 msleep(10); 3016 usleep_range(10000, 20000);
2999 3017
3000 /* Workaround for ICH8 bit corruption issue in FIFO memory */ 3018 /* Workaround for ICH8 bit corruption issue in FIFO memory */
3001 if (hw->mac.type == e1000_ich8lan) { 3019 if (hw->mac.type == e1000_ich8lan) {
@@ -3062,7 +3080,7 @@ static s32 e1000_reset_hw_ich8lan(struct e1000_hw *hw)
3062 ew32(CRC_OFFSET, 0x65656565); 3080 ew32(CRC_OFFSET, 0x65656565);
3063 3081
3064 ew32(IMC, 0xffffffff); 3082 ew32(IMC, 0xffffffff);
3065 icr = er32(ICR); 3083 er32(ICR);
3066 3084
3067 kab = er32(KABGTXD); 3085 kab = er32(KABGTXD);
3068 kab |= E1000_KABGTXD_BGSQLBIAS; 3086 kab |= E1000_KABGTXD_BGSQLBIAS;
@@ -3113,7 +3131,7 @@ static s32 e1000_init_hw_ich8lan(struct e1000_hw *hw)
3113 * Reset the phy after disabling host wakeup to reset the Rx buffer. 3131 * Reset the phy after disabling host wakeup to reset the Rx buffer.
3114 */ 3132 */
3115 if (hw->phy.type == e1000_phy_82578) { 3133 if (hw->phy.type == e1000_phy_82578) {
3116 hw->phy.ops.read_reg(hw, BM_WUC, &i); 3134 e1e_rphy(hw, BM_WUC, &i);
3117 ret_val = e1000_phy_hw_reset_ich8lan(hw); 3135 ret_val = e1000_phy_hw_reset_ich8lan(hw);
3118 if (ret_val) 3136 if (ret_val)
3119 return ret_val; 3137 return ret_val;
@@ -3271,9 +3289,8 @@ static s32 e1000_setup_link_ich8lan(struct e1000_hw *hw)
3271 (hw->phy.type == e1000_phy_82577)) { 3289 (hw->phy.type == e1000_phy_82577)) {
3272 ew32(FCRTV_PCH, hw->fc.refresh_time); 3290 ew32(FCRTV_PCH, hw->fc.refresh_time);
3273 3291
3274 ret_val = hw->phy.ops.write_reg(hw, 3292 ret_val = e1e_wphy(hw, PHY_REG(BM_PORT_CTRL_PAGE, 27),
3275 PHY_REG(BM_PORT_CTRL_PAGE, 27), 3293 hw->fc.pause_time);
3276 hw->fc.pause_time);
3277 if (ret_val) 3294 if (ret_val)
3278 return ret_val; 3295 return ret_val;
3279 } 3296 }
@@ -3337,8 +3354,7 @@ static s32 e1000_setup_copper_link_ich8lan(struct e1000_hw *hw)
3337 return ret_val; 3354 return ret_val;
3338 break; 3355 break;
3339 case e1000_phy_ife: 3356 case e1000_phy_ife:
3340 ret_val = hw->phy.ops.read_reg(hw, IFE_PHY_MDIX_CONTROL, 3357 ret_val = e1e_rphy(hw, IFE_PHY_MDIX_CONTROL, &reg_data);
3341 &reg_data);
3342 if (ret_val) 3358 if (ret_val)
3343 return ret_val; 3359 return ret_val;
3344 3360
@@ -3356,8 +3372,7 @@ static s32 e1000_setup_copper_link_ich8lan(struct e1000_hw *hw)
3356 reg_data |= IFE_PMC_AUTO_MDIX; 3372 reg_data |= IFE_PMC_AUTO_MDIX;
3357 break; 3373 break;
3358 } 3374 }
3359 ret_val = hw->phy.ops.write_reg(hw, IFE_PHY_MDIX_CONTROL, 3375 ret_val = e1e_wphy(hw, IFE_PHY_MDIX_CONTROL, reg_data);
3360 reg_data);
3361 if (ret_val) 3376 if (ret_val)
3362 return ret_val; 3377 return ret_val;
3363 break; 3378 break;
@@ -3591,7 +3606,7 @@ void e1000e_disable_gig_wol_ich8lan(struct e1000_hw *hw)
3591 ew32(PHY_CTRL, phy_ctrl); 3606 ew32(PHY_CTRL, phy_ctrl);
3592 3607
3593 if (hw->mac.type >= e1000_pchlan) { 3608 if (hw->mac.type >= e1000_pchlan) {
3594 e1000_oem_bits_config_ich8lan(hw, true); 3609 e1000_oem_bits_config_ich8lan(hw, false);
3595 ret_val = hw->phy.ops.acquire(hw); 3610 ret_val = hw->phy.ops.acquire(hw);
3596 if (ret_val) 3611 if (ret_val)
3597 return; 3612 return;
@@ -3641,7 +3656,8 @@ static s32 e1000_led_off_ich8lan(struct e1000_hw *hw)
3641{ 3656{
3642 if (hw->phy.type == e1000_phy_ife) 3657 if (hw->phy.type == e1000_phy_ife)
3643 return e1e_wphy(hw, IFE_PHY_SPECIAL_CONTROL_LED, 3658 return e1e_wphy(hw, IFE_PHY_SPECIAL_CONTROL_LED,
3644 (IFE_PSCL_PROBE_MODE | IFE_PSCL_PROBE_LEDS_OFF)); 3659 (IFE_PSCL_PROBE_MODE |
3660 IFE_PSCL_PROBE_LEDS_OFF));
3645 3661
3646 ew32(LEDCTL, hw->mac.ledctl_mode1); 3662 ew32(LEDCTL, hw->mac.ledctl_mode1);
3647 return 0; 3663 return 0;
@@ -3655,8 +3671,7 @@ static s32 e1000_led_off_ich8lan(struct e1000_hw *hw)
3655 **/ 3671 **/
3656static s32 e1000_setup_led_pchlan(struct e1000_hw *hw) 3672static s32 e1000_setup_led_pchlan(struct e1000_hw *hw)
3657{ 3673{
3658 return hw->phy.ops.write_reg(hw, HV_LED_CONFIG, 3674 return e1e_wphy(hw, HV_LED_CONFIG, (u16)hw->mac.ledctl_mode1);
3659 (u16)hw->mac.ledctl_mode1);
3660} 3675}
3661 3676
3662/** 3677/**
@@ -3667,8 +3682,7 @@ static s32 e1000_setup_led_pchlan(struct e1000_hw *hw)
3667 **/ 3682 **/
3668static s32 e1000_cleanup_led_pchlan(struct e1000_hw *hw) 3683static s32 e1000_cleanup_led_pchlan(struct e1000_hw *hw)
3669{ 3684{
3670 return hw->phy.ops.write_reg(hw, HV_LED_CONFIG, 3685 return e1e_wphy(hw, HV_LED_CONFIG, (u16)hw->mac.ledctl_default);
3671 (u16)hw->mac.ledctl_default);
3672} 3686}
3673 3687
3674/** 3688/**
@@ -3699,7 +3713,7 @@ static s32 e1000_led_on_pchlan(struct e1000_hw *hw)
3699 } 3713 }
3700 } 3714 }
3701 3715
3702 return hw->phy.ops.write_reg(hw, HV_LED_CONFIG, data); 3716 return e1e_wphy(hw, HV_LED_CONFIG, data);
3703} 3717}
3704 3718
3705/** 3719/**
@@ -3730,7 +3744,7 @@ static s32 e1000_led_off_pchlan(struct e1000_hw *hw)
3730 } 3744 }
3731 } 3745 }
3732 3746
3733 return hw->phy.ops.write_reg(hw, HV_LED_CONFIG, data); 3747 return e1e_wphy(hw, HV_LED_CONFIG, data);
3734} 3748}
3735 3749
3736/** 3750/**
@@ -3839,20 +3853,20 @@ static void e1000_clear_hw_cntrs_ich8lan(struct e1000_hw *hw)
3839 if ((hw->phy.type == e1000_phy_82578) || 3853 if ((hw->phy.type == e1000_phy_82578) ||
3840 (hw->phy.type == e1000_phy_82579) || 3854 (hw->phy.type == e1000_phy_82579) ||
3841 (hw->phy.type == e1000_phy_82577)) { 3855 (hw->phy.type == e1000_phy_82577)) {
3842 hw->phy.ops.read_reg(hw, HV_SCC_UPPER, &phy_data); 3856 e1e_rphy(hw, HV_SCC_UPPER, &phy_data);
3843 hw->phy.ops.read_reg(hw, HV_SCC_LOWER, &phy_data); 3857 e1e_rphy(hw, HV_SCC_LOWER, &phy_data);
3844 hw->phy.ops.read_reg(hw, HV_ECOL_UPPER, &phy_data); 3858 e1e_rphy(hw, HV_ECOL_UPPER, &phy_data);
3845 hw->phy.ops.read_reg(hw, HV_ECOL_LOWER, &phy_data); 3859 e1e_rphy(hw, HV_ECOL_LOWER, &phy_data);
3846 hw->phy.ops.read_reg(hw, HV_MCC_UPPER, &phy_data); 3860 e1e_rphy(hw, HV_MCC_UPPER, &phy_data);
3847 hw->phy.ops.read_reg(hw, HV_MCC_LOWER, &phy_data); 3861 e1e_rphy(hw, HV_MCC_LOWER, &phy_data);
3848 hw->phy.ops.read_reg(hw, HV_LATECOL_UPPER, &phy_data); 3862 e1e_rphy(hw, HV_LATECOL_UPPER, &phy_data);
3849 hw->phy.ops.read_reg(hw, HV_LATECOL_LOWER, &phy_data); 3863 e1e_rphy(hw, HV_LATECOL_LOWER, &phy_data);
3850 hw->phy.ops.read_reg(hw, HV_COLC_UPPER, &phy_data); 3864 e1e_rphy(hw, HV_COLC_UPPER, &phy_data);
3851 hw->phy.ops.read_reg(hw, HV_COLC_LOWER, &phy_data); 3865 e1e_rphy(hw, HV_COLC_LOWER, &phy_data);
3852 hw->phy.ops.read_reg(hw, HV_DC_UPPER, &phy_data); 3866 e1e_rphy(hw, HV_DC_UPPER, &phy_data);
3853 hw->phy.ops.read_reg(hw, HV_DC_LOWER, &phy_data); 3867 e1e_rphy(hw, HV_DC_LOWER, &phy_data);
3854 hw->phy.ops.read_reg(hw, HV_TNCRS_UPPER, &phy_data); 3868 e1e_rphy(hw, HV_TNCRS_UPPER, &phy_data);
3855 hw->phy.ops.read_reg(hw, HV_TNCRS_LOWER, &phy_data); 3869 e1e_rphy(hw, HV_TNCRS_LOWER, &phy_data);
3856 } 3870 }
3857} 3871}
3858 3872
@@ -3986,7 +4000,7 @@ struct e1000_info e1000_pch2_info = {
3986 | FLAG_APME_IN_WUC, 4000 | FLAG_APME_IN_WUC,
3987 .flags2 = FLAG2_HAS_PHY_STATS 4001 .flags2 = FLAG2_HAS_PHY_STATS
3988 | FLAG2_HAS_EEE, 4002 | FLAG2_HAS_EEE,
3989 .pba = 18, 4003 .pba = 26,
3990 .max_hw_frame_size = DEFAULT_JUMBO, 4004 .max_hw_frame_size = DEFAULT_JUMBO,
3991 .get_variants = e1000_get_variants_ich8lan, 4005 .get_variants = e1000_get_variants_ich8lan,
3992 .mac_ops = &ich8_mac_ops, 4006 .mac_ops = &ich8_mac_ops,
diff --git a/drivers/net/e1000e/lib.c b/drivers/net/e1000e/lib.c
index 0fd4eb5ac5fb..dd8ab05b5590 100644
--- a/drivers/net/e1000e/lib.c
+++ b/drivers/net/e1000e/lib.c
@@ -1,7 +1,7 @@
1/******************************************************************************* 1/*******************************************************************************
2 2
3 Intel PRO/1000 Linux driver 3 Intel PRO/1000 Linux driver
4 Copyright(c) 1999 - 2010 Intel Corporation. 4 Copyright(c) 1999 - 2011 Intel Corporation.
5 5
6 This program is free software; you can redistribute it and/or modify it 6 This program is free software; you can redistribute it and/or modify it
7 under the terms and conditions of the GNU General Public License, 7 under the terms and conditions of the GNU General Public License,
@@ -144,7 +144,7 @@ void e1000_write_vfta_generic(struct e1000_hw *hw, u32 offset, u32 value)
144 * @hw: pointer to the HW structure 144 * @hw: pointer to the HW structure
145 * @rar_count: receive address registers 145 * @rar_count: receive address registers
146 * 146 *
147 * Setups the receive address registers by setting the base receive address 147 * Setup the receive address registers by setting the base receive address
148 * register to the devices MAC address and clearing all the other receive 148 * register to the devices MAC address and clearing all the other receive
149 * address registers to 0. 149 * address registers to 0.
150 **/ 150 **/
@@ -493,9 +493,8 @@ s32 e1000e_check_for_copper_link(struct e1000_hw *hw)
493 * different link partner. 493 * different link partner.
494 */ 494 */
495 ret_val = e1000e_config_fc_after_link_up(hw); 495 ret_val = e1000e_config_fc_after_link_up(hw);
496 if (ret_val) { 496 if (ret_val)
497 e_dbg("Error configuring flow control\n"); 497 e_dbg("Error configuring flow control\n");
498 }
499 498
500 return ret_val; 499 return ret_val;
501} 500}
@@ -534,7 +533,7 @@ s32 e1000e_check_for_fiber_link(struct e1000_hw *hw)
534 mac->autoneg_failed = 1; 533 mac->autoneg_failed = 1;
535 return 0; 534 return 0;
536 } 535 }
537 e_dbg("NOT RXing /C/, disable AutoNeg and force link.\n"); 536 e_dbg("NOT Rx'ing /C/, disable AutoNeg and force link.\n");
538 537
539 /* Disable auto-negotiation in the TXCW register */ 538 /* Disable auto-negotiation in the TXCW register */
540 ew32(TXCW, (mac->txcw & ~E1000_TXCW_ANE)); 539 ew32(TXCW, (mac->txcw & ~E1000_TXCW_ANE));
@@ -557,7 +556,7 @@ s32 e1000e_check_for_fiber_link(struct e1000_hw *hw)
557 * and disable forced link in the Device Control register 556 * and disable forced link in the Device Control register
558 * in an attempt to auto-negotiate with our link partner. 557 * in an attempt to auto-negotiate with our link partner.
559 */ 558 */
560 e_dbg("RXing /C/, enable AutoNeg and stop forcing link.\n"); 559 e_dbg("Rx'ing /C/, enable AutoNeg and stop forcing link.\n");
561 ew32(TXCW, mac->txcw); 560 ew32(TXCW, mac->txcw);
562 ew32(CTRL, (ctrl & ~E1000_CTRL_SLU)); 561 ew32(CTRL, (ctrl & ~E1000_CTRL_SLU));
563 562
@@ -599,7 +598,7 @@ s32 e1000e_check_for_serdes_link(struct e1000_hw *hw)
599 mac->autoneg_failed = 1; 598 mac->autoneg_failed = 1;
600 return 0; 599 return 0;
601 } 600 }
602 e_dbg("NOT RXing /C/, disable AutoNeg and force link.\n"); 601 e_dbg("NOT Rx'ing /C/, disable AutoNeg and force link.\n");
603 602
604 /* Disable auto-negotiation in the TXCW register */ 603 /* Disable auto-negotiation in the TXCW register */
605 ew32(TXCW, (mac->txcw & ~E1000_TXCW_ANE)); 604 ew32(TXCW, (mac->txcw & ~E1000_TXCW_ANE));
@@ -622,7 +621,7 @@ s32 e1000e_check_for_serdes_link(struct e1000_hw *hw)
622 * and disable forced link in the Device Control register 621 * and disable forced link in the Device Control register
623 * in an attempt to auto-negotiate with our link partner. 622 * in an attempt to auto-negotiate with our link partner.
624 */ 623 */
625 e_dbg("RXing /C/, enable AutoNeg and stop forcing link.\n"); 624 e_dbg("Rx'ing /C/, enable AutoNeg and stop forcing link.\n");
626 ew32(TXCW, mac->txcw); 625 ew32(TXCW, mac->txcw);
627 ew32(CTRL, (ctrl & ~E1000_CTRL_SLU)); 626 ew32(CTRL, (ctrl & ~E1000_CTRL_SLU));
628 627
@@ -801,9 +800,9 @@ static s32 e1000_commit_fc_settings_generic(struct e1000_hw *hw)
801 * The possible values of the "fc" parameter are: 800 * The possible values of the "fc" parameter are:
802 * 0: Flow control is completely disabled 801 * 0: Flow control is completely disabled
803 * 1: Rx flow control is enabled (we can receive pause frames, 802 * 1: Rx flow control is enabled (we can receive pause frames,
804 * but not send pause frames). 803 * but not send pause frames).
805 * 2: Tx flow control is enabled (we can send pause frames but we 804 * 2: Tx flow control is enabled (we can send pause frames but we
806 * do not support receiving pause frames). 805 * do not support receiving pause frames).
807 * 3: Both Rx and Tx flow control (symmetric) are enabled. 806 * 3: Both Rx and Tx flow control (symmetric) are enabled.
808 */ 807 */
809 switch (hw->fc.current_mode) { 808 switch (hw->fc.current_mode) {
@@ -869,7 +868,7 @@ static s32 e1000_poll_fiber_serdes_link_generic(struct e1000_hw *hw)
869 * milliseconds even if the other end is doing it in SW). 868 * milliseconds even if the other end is doing it in SW).
870 */ 869 */
871 for (i = 0; i < FIBER_LINK_UP_LIMIT; i++) { 870 for (i = 0; i < FIBER_LINK_UP_LIMIT; i++) {
872 msleep(10); 871 usleep_range(10000, 20000);
873 status = er32(STATUS); 872 status = er32(STATUS);
874 if (status & E1000_STATUS_LU) 873 if (status & E1000_STATUS_LU)
875 break; 874 break;
@@ -931,7 +930,7 @@ s32 e1000e_setup_fiber_serdes_link(struct e1000_hw *hw)
931 930
932 ew32(CTRL, ctrl); 931 ew32(CTRL, ctrl);
933 e1e_flush(); 932 e1e_flush();
934 msleep(1); 933 usleep_range(1000, 2000);
935 934
936 /* 935 /*
937 * For these adapters, the SW definable pin 1 is set when the optics 936 * For these adapters, the SW definable pin 1 is set when the optics
@@ -1032,9 +1031,9 @@ s32 e1000e_force_mac_fc(struct e1000_hw *hw)
1032 * The possible values of the "fc" parameter are: 1031 * The possible values of the "fc" parameter are:
1033 * 0: Flow control is completely disabled 1032 * 0: Flow control is completely disabled
1034 * 1: Rx flow control is enabled (we can receive pause 1033 * 1: Rx flow control is enabled (we can receive pause
1035 * frames but not send pause frames). 1034 * frames but not send pause frames).
1036 * 2: Tx flow control is enabled (we can send pause frames 1035 * 2: Tx flow control is enabled (we can send pause frames
1037 * frames but we do not receive pause frames). 1036 * frames but we do not receive pause frames).
1038 * 3: Both Rx and Tx flow control (symmetric) is enabled. 1037 * 3: Both Rx and Tx flow control (symmetric) is enabled.
1039 * other: No other values should be possible at this point. 1038 * other: No other values should be possible at this point.
1040 */ 1039 */
@@ -1136,7 +1135,8 @@ s32 e1000e_config_fc_after_link_up(struct e1000_hw *hw)
1136 ret_val = e1e_rphy(hw, PHY_AUTONEG_ADV, &mii_nway_adv_reg); 1135 ret_val = e1e_rphy(hw, PHY_AUTONEG_ADV, &mii_nway_adv_reg);
1137 if (ret_val) 1136 if (ret_val)
1138 return ret_val; 1137 return ret_val;
1139 ret_val = e1e_rphy(hw, PHY_LP_ABILITY, &mii_nway_lp_ability_reg); 1138 ret_val =
1139 e1e_rphy(hw, PHY_LP_ABILITY, &mii_nway_lp_ability_reg);
1140 if (ret_val) 1140 if (ret_val)
1141 return ret_val; 1141 return ret_val;
1142 1142
@@ -1181,7 +1181,7 @@ s32 e1000e_config_fc_after_link_up(struct e1000_hw *hw)
1181 * of pause frames. In this case, we had to advertise 1181 * of pause frames. In this case, we had to advertise
1182 * FULL flow control because we could not advertise Rx 1182 * FULL flow control because we could not advertise Rx
1183 * ONLY. Hence, we must now check to see if we need to 1183 * ONLY. Hence, we must now check to see if we need to
1184 * turn OFF the TRANSMISSION of PAUSE frames. 1184 * turn OFF the TRANSMISSION of PAUSE frames.
1185 */ 1185 */
1186 if (hw->fc.requested_mode == e1000_fc_full) { 1186 if (hw->fc.requested_mode == e1000_fc_full) {
1187 hw->fc.current_mode = e1000_fc_full; 1187 hw->fc.current_mode = e1000_fc_full;
@@ -1189,7 +1189,7 @@ s32 e1000e_config_fc_after_link_up(struct e1000_hw *hw)
1189 } else { 1189 } else {
1190 hw->fc.current_mode = e1000_fc_rx_pause; 1190 hw->fc.current_mode = e1000_fc_rx_pause;
1191 e_dbg("Flow Control = " 1191 e_dbg("Flow Control = "
1192 "RX PAUSE frames only.\r\n"); 1192 "Rx PAUSE frames only.\r\n");
1193 } 1193 }
1194 } 1194 }
1195 /* 1195 /*
@@ -1385,7 +1385,7 @@ s32 e1000e_get_auto_rd_done(struct e1000_hw *hw)
1385 while (i < AUTO_READ_DONE_TIMEOUT) { 1385 while (i < AUTO_READ_DONE_TIMEOUT) {
1386 if (er32(EECD) & E1000_EECD_AUTO_RD) 1386 if (er32(EECD) & E1000_EECD_AUTO_RD)
1387 break; 1387 break;
1388 msleep(1); 1388 usleep_range(1000, 2000);
1389 i++; 1389 i++;
1390 } 1390 }
1391 1391
@@ -1496,9 +1496,8 @@ s32 e1000e_setup_led_generic(struct e1000_hw *hw)
1496{ 1496{
1497 u32 ledctl; 1497 u32 ledctl;
1498 1498
1499 if (hw->mac.ops.setup_led != e1000e_setup_led_generic) { 1499 if (hw->mac.ops.setup_led != e1000e_setup_led_generic)
1500 return -E1000_ERR_CONFIG; 1500 return -E1000_ERR_CONFIG;
1501 }
1502 1501
1503 if (hw->phy.media_type == e1000_media_type_fiber) { 1502 if (hw->phy.media_type == e1000_media_type_fiber) {
1504 ledctl = er32(LEDCTL); 1503 ledctl = er32(LEDCTL);
@@ -1531,12 +1530,12 @@ s32 e1000e_cleanup_led_generic(struct e1000_hw *hw)
1531} 1530}
1532 1531
1533/** 1532/**
1534 * e1000e_blink_led - Blink LED 1533 * e1000e_blink_led_generic - Blink LED
1535 * @hw: pointer to the HW structure 1534 * @hw: pointer to the HW structure
1536 * 1535 *
1537 * Blink the LEDs which are set to be on. 1536 * Blink the LEDs which are set to be on.
1538 **/ 1537 **/
1539s32 e1000e_blink_led(struct e1000_hw *hw) 1538s32 e1000e_blink_led_generic(struct e1000_hw *hw)
1540{ 1539{
1541 u32 ledctl_blink = 0; 1540 u32 ledctl_blink = 0;
1542 u32 i; 1541 u32 i;
@@ -1979,15 +1978,15 @@ static s32 e1000_ready_nvm_eeprom(struct e1000_hw *hw)
1979{ 1978{
1980 struct e1000_nvm_info *nvm = &hw->nvm; 1979 struct e1000_nvm_info *nvm = &hw->nvm;
1981 u32 eecd = er32(EECD); 1980 u32 eecd = er32(EECD);
1982 u16 timeout = 0;
1983 u8 spi_stat_reg; 1981 u8 spi_stat_reg;
1984 1982
1985 if (nvm->type == e1000_nvm_eeprom_spi) { 1983 if (nvm->type == e1000_nvm_eeprom_spi) {
1984 u16 timeout = NVM_MAX_RETRY_SPI;
1985
1986 /* Clear SK and CS */ 1986 /* Clear SK and CS */
1987 eecd &= ~(E1000_EECD_CS | E1000_EECD_SK); 1987 eecd &= ~(E1000_EECD_CS | E1000_EECD_SK);
1988 ew32(EECD, eecd); 1988 ew32(EECD, eecd);
1989 udelay(1); 1989 udelay(1);
1990 timeout = NVM_MAX_RETRY_SPI;
1991 1990
1992 /* 1991 /*
1993 * Read "Status Register" repeatedly until the LSB is cleared. 1992 * Read "Status Register" repeatedly until the LSB is cleared.
@@ -2088,8 +2087,6 @@ s32 e1000e_write_nvm_spi(struct e1000_hw *hw, u16 offset, u16 words, u16 *data)
2088 if (ret_val) 2087 if (ret_val)
2089 return ret_val; 2088 return ret_val;
2090 2089
2091 msleep(10);
2092
2093 while (widx < words) { 2090 while (widx < words) {
2094 u8 write_opcode = NVM_WRITE_OPCODE_SPI; 2091 u8 write_opcode = NVM_WRITE_OPCODE_SPI;
2095 2092
@@ -2133,12 +2130,125 @@ s32 e1000e_write_nvm_spi(struct e1000_hw *hw, u16 offset, u16 words, u16 *data)
2133 } 2130 }
2134 } 2131 }
2135 2132
2136 msleep(10); 2133 usleep_range(10000, 20000);
2137 nvm->ops.release(hw); 2134 nvm->ops.release(hw);
2138 return 0; 2135 return 0;
2139} 2136}
2140 2137
2141/** 2138/**
2139 * e1000_read_pba_string_generic - Read device part number
2140 * @hw: pointer to the HW structure
2141 * @pba_num: pointer to device part number
2142 * @pba_num_size: size of part number buffer
2143 *
2144 * Reads the product board assembly (PBA) number from the EEPROM and stores
2145 * the value in pba_num.
2146 **/
2147s32 e1000_read_pba_string_generic(struct e1000_hw *hw, u8 *pba_num,
2148 u32 pba_num_size)
2149{
2150 s32 ret_val;
2151 u16 nvm_data;
2152 u16 pba_ptr;
2153 u16 offset;
2154 u16 length;
2155
2156 if (pba_num == NULL) {
2157 e_dbg("PBA string buffer was null\n");
2158 ret_val = E1000_ERR_INVALID_ARGUMENT;
2159 goto out;
2160 }
2161
2162 ret_val = e1000_read_nvm(hw, NVM_PBA_OFFSET_0, 1, &nvm_data);
2163 if (ret_val) {
2164 e_dbg("NVM Read Error\n");
2165 goto out;
2166 }
2167
2168 ret_val = e1000_read_nvm(hw, NVM_PBA_OFFSET_1, 1, &pba_ptr);
2169 if (ret_val) {
2170 e_dbg("NVM Read Error\n");
2171 goto out;
2172 }
2173
2174 /*
2175 * if nvm_data is not ptr guard the PBA must be in legacy format which
2176 * means pba_ptr is actually our second data word for the PBA number
2177 * and we can decode it into an ascii string
2178 */
2179 if (nvm_data != NVM_PBA_PTR_GUARD) {
2180 e_dbg("NVM PBA number is not stored as string\n");
2181
2182 /* we will need 11 characters to store the PBA */
2183 if (pba_num_size < 11) {
2184 e_dbg("PBA string buffer too small\n");
2185 return E1000_ERR_NO_SPACE;
2186 }
2187
2188 /* extract hex string from data and pba_ptr */
2189 pba_num[0] = (nvm_data >> 12) & 0xF;
2190 pba_num[1] = (nvm_data >> 8) & 0xF;
2191 pba_num[2] = (nvm_data >> 4) & 0xF;
2192 pba_num[3] = nvm_data & 0xF;
2193 pba_num[4] = (pba_ptr >> 12) & 0xF;
2194 pba_num[5] = (pba_ptr >> 8) & 0xF;
2195 pba_num[6] = '-';
2196 pba_num[7] = 0;
2197 pba_num[8] = (pba_ptr >> 4) & 0xF;
2198 pba_num[9] = pba_ptr & 0xF;
2199
2200 /* put a null character on the end of our string */
2201 pba_num[10] = '\0';
2202
2203 /* switch all the data but the '-' to hex char */
2204 for (offset = 0; offset < 10; offset++) {
2205 if (pba_num[offset] < 0xA)
2206 pba_num[offset] += '0';
2207 else if (pba_num[offset] < 0x10)
2208 pba_num[offset] += 'A' - 0xA;
2209 }
2210
2211 goto out;
2212 }
2213
2214 ret_val = e1000_read_nvm(hw, pba_ptr, 1, &length);
2215 if (ret_val) {
2216 e_dbg("NVM Read Error\n");
2217 goto out;
2218 }
2219
2220 if (length == 0xFFFF || length == 0) {
2221 e_dbg("NVM PBA number section invalid length\n");
2222 ret_val = E1000_ERR_NVM_PBA_SECTION;
2223 goto out;
2224 }
2225 /* check if pba_num buffer is big enough */
2226 if (pba_num_size < (((u32)length * 2) - 1)) {
2227 e_dbg("PBA string buffer too small\n");
2228 ret_val = E1000_ERR_NO_SPACE;
2229 goto out;
2230 }
2231
2232 /* trim pba length from start of string */
2233 pba_ptr++;
2234 length--;
2235
2236 for (offset = 0; offset < length; offset++) {
2237 ret_val = e1000_read_nvm(hw, pba_ptr + offset, 1, &nvm_data);
2238 if (ret_val) {
2239 e_dbg("NVM Read Error\n");
2240 goto out;
2241 }
2242 pba_num[offset * 2] = (u8)(nvm_data >> 8);
2243 pba_num[(offset * 2) + 1] = (u8)(nvm_data & 0xFF);
2244 }
2245 pba_num[offset * 2] = '\0';
2246
2247out:
2248 return ret_val;
2249}
2250
2251/**
2142 * e1000_read_mac_addr_generic - Read device MAC address 2252 * e1000_read_mac_addr_generic - Read device MAC address
2143 * @hw: pointer to the HW structure 2253 * @hw: pointer to the HW structure
2144 * 2254 *
@@ -2579,25 +2689,3 @@ bool e1000e_enable_mng_pass_thru(struct e1000_hw *hw)
2579out: 2689out:
2580 return ret_val; 2690 return ret_val;
2581} 2691}
2582
2583s32 e1000e_read_pba_num(struct e1000_hw *hw, u32 *pba_num)
2584{
2585 s32 ret_val;
2586 u16 nvm_data;
2587
2588 ret_val = e1000_read_nvm(hw, NVM_PBA_OFFSET_0, 1, &nvm_data);
2589 if (ret_val) {
2590 e_dbg("NVM Read Error\n");
2591 return ret_val;
2592 }
2593 *pba_num = (u32)(nvm_data << 16);
2594
2595 ret_val = e1000_read_nvm(hw, NVM_PBA_OFFSET_1, 1, &nvm_data);
2596 if (ret_val) {
2597 e_dbg("NVM Read Error\n");
2598 return ret_val;
2599 }
2600 *pba_num |= nvm_data;
2601
2602 return 0;
2603}
diff --git a/drivers/net/e1000e/netdev.c b/drivers/net/e1000e/netdev.c
index e561d15c3eb1..3310c3d477d7 100644
--- a/drivers/net/e1000e/netdev.c
+++ b/drivers/net/e1000e/netdev.c
@@ -1,7 +1,7 @@
1/******************************************************************************* 1/*******************************************************************************
2 2
3 Intel PRO/1000 Linux driver 3 Intel PRO/1000 Linux driver
4 Copyright(c) 1999 - 2010 Intel Corporation. 4 Copyright(c) 1999 - 2011 Intel Corporation.
5 5
6 This program is free software; you can redistribute it and/or modify it 6 This program is free software; you can redistribute it and/or modify it
7 under the terms and conditions of the GNU General Public License, 7 under the terms and conditions of the GNU General Public License,
@@ -49,15 +49,18 @@
49#include <linux/pm_qos_params.h> 49#include <linux/pm_qos_params.h>
50#include <linux/pm_runtime.h> 50#include <linux/pm_runtime.h>
51#include <linux/aer.h> 51#include <linux/aer.h>
52#include <linux/prefetch.h>
52 53
53#include "e1000.h" 54#include "e1000.h"
54 55
55#define DRV_EXTRAVERSION "-k2" 56#define DRV_EXTRAVERSION "-k2"
56 57
57#define DRV_VERSION "1.2.7" DRV_EXTRAVERSION 58#define DRV_VERSION "1.3.10" DRV_EXTRAVERSION
58char e1000e_driver_name[] = "e1000e"; 59char e1000e_driver_name[] = "e1000e";
59const char e1000e_driver_version[] = DRV_VERSION; 60const char e1000e_driver_version[] = DRV_VERSION;
60 61
62static void e1000e_disable_aspm(struct pci_dev *pdev, u16 state);
63
61static const struct e1000_info *e1000_info_tbl[] = { 64static const struct e1000_info *e1000_info_tbl[] = {
62 [board_82571] = &e1000_82571_info, 65 [board_82571] = &e1000_82571_info,
63 [board_82572] = &e1000_82572_info, 66 [board_82572] = &e1000_82572_info,
@@ -77,17 +80,17 @@ struct e1000_reg_info {
77 char *name; 80 char *name;
78}; 81};
79 82
80#define E1000_RDFH 0x02410 /* Rx Data FIFO Head - RW */ 83#define E1000_RDFH 0x02410 /* Rx Data FIFO Head - RW */
81#define E1000_RDFT 0x02418 /* Rx Data FIFO Tail - RW */ 84#define E1000_RDFT 0x02418 /* Rx Data FIFO Tail - RW */
82#define E1000_RDFHS 0x02420 /* Rx Data FIFO Head Saved - RW */ 85#define E1000_RDFHS 0x02420 /* Rx Data FIFO Head Saved - RW */
83#define E1000_RDFTS 0x02428 /* Rx Data FIFO Tail Saved - RW */ 86#define E1000_RDFTS 0x02428 /* Rx Data FIFO Tail Saved - RW */
84#define E1000_RDFPC 0x02430 /* Rx Data FIFO Packet Count - RW */ 87#define E1000_RDFPC 0x02430 /* Rx Data FIFO Packet Count - RW */
85 88
86#define E1000_TDFH 0x03410 /* Tx Data FIFO Head - RW */ 89#define E1000_TDFH 0x03410 /* Tx Data FIFO Head - RW */
87#define E1000_TDFT 0x03418 /* Tx Data FIFO Tail - RW */ 90#define E1000_TDFT 0x03418 /* Tx Data FIFO Tail - RW */
88#define E1000_TDFHS 0x03420 /* Tx Data FIFO Head Saved - RW */ 91#define E1000_TDFHS 0x03420 /* Tx Data FIFO Head Saved - RW */
89#define E1000_TDFTS 0x03428 /* Tx Data FIFO Tail Saved - RW */ 92#define E1000_TDFTS 0x03428 /* Tx Data FIFO Tail Saved - RW */
90#define E1000_TDFPC 0x03430 /* Tx Data FIFO Packet Count - RW */ 93#define E1000_TDFPC 0x03430 /* Tx Data FIFO Packet Count - RW */
91 94
92static const struct e1000_reg_info e1000_reg_info_tbl[] = { 95static const struct e1000_reg_info e1000_reg_info_tbl[] = {
93 96
@@ -99,7 +102,7 @@ static const struct e1000_reg_info e1000_reg_info_tbl[] = {
99 /* Interrupt Registers */ 102 /* Interrupt Registers */
100 {E1000_ICR, "ICR"}, 103 {E1000_ICR, "ICR"},
101 104
102 /* RX Registers */ 105 /* Rx Registers */
103 {E1000_RCTL, "RCTL"}, 106 {E1000_RCTL, "RCTL"},
104 {E1000_RDLEN, "RDLEN"}, 107 {E1000_RDLEN, "RDLEN"},
105 {E1000_RDH, "RDH"}, 108 {E1000_RDH, "RDH"},
@@ -115,7 +118,7 @@ static const struct e1000_reg_info e1000_reg_info_tbl[] = {
115 {E1000_RDFTS, "RDFTS"}, 118 {E1000_RDFTS, "RDFTS"},
116 {E1000_RDFPC, "RDFPC"}, 119 {E1000_RDFPC, "RDFPC"},
117 120
118 /* TX Registers */ 121 /* Tx Registers */
119 {E1000_TCTL, "TCTL"}, 122 {E1000_TCTL, "TCTL"},
120 {E1000_TDBAL, "TDBAL"}, 123 {E1000_TDBAL, "TDBAL"},
121 {E1000_TDBAH, "TDBAH"}, 124 {E1000_TDBAH, "TDBAH"},
@@ -160,7 +163,7 @@ static void e1000_regdump(struct e1000_hw *hw, struct e1000_reg_info *reginfo)
160 break; 163 break;
161 default: 164 default:
162 printk(KERN_INFO "%-15s %08x\n", 165 printk(KERN_INFO "%-15s %08x\n",
163 reginfo->name, __er32(hw, reginfo->ofs)); 166 reginfo->name, __er32(hw, reginfo->ofs));
164 return; 167 return;
165 } 168 }
166 169
@@ -171,9 +174,8 @@ static void e1000_regdump(struct e1000_hw *hw, struct e1000_reg_info *reginfo)
171 printk(KERN_CONT "\n"); 174 printk(KERN_CONT "\n");
172} 175}
173 176
174
175/* 177/*
176 * e1000e_dump - Print registers, tx-ring and rx-ring 178 * e1000e_dump - Print registers, Tx-ring and Rx-ring
177 */ 179 */
178static void e1000e_dump(struct e1000_adapter *adapter) 180static void e1000e_dump(struct e1000_adapter *adapter)
179{ 181{
@@ -182,12 +184,20 @@ static void e1000e_dump(struct e1000_adapter *adapter)
182 struct e1000_reg_info *reginfo; 184 struct e1000_reg_info *reginfo;
183 struct e1000_ring *tx_ring = adapter->tx_ring; 185 struct e1000_ring *tx_ring = adapter->tx_ring;
184 struct e1000_tx_desc *tx_desc; 186 struct e1000_tx_desc *tx_desc;
185 struct my_u0 { u64 a; u64 b; } *u0; 187 struct my_u0 {
188 u64 a;
189 u64 b;
190 } *u0;
186 struct e1000_buffer *buffer_info; 191 struct e1000_buffer *buffer_info;
187 struct e1000_ring *rx_ring = adapter->rx_ring; 192 struct e1000_ring *rx_ring = adapter->rx_ring;
188 union e1000_rx_desc_packet_split *rx_desc_ps; 193 union e1000_rx_desc_packet_split *rx_desc_ps;
189 struct e1000_rx_desc *rx_desc; 194 struct e1000_rx_desc *rx_desc;
190 struct my_u1 { u64 a; u64 b; u64 c; u64 d; } *u1; 195 struct my_u1 {
196 u64 a;
197 u64 b;
198 u64 c;
199 u64 d;
200 } *u1;
191 u32 staterr; 201 u32 staterr;
192 int i = 0; 202 int i = 0;
193 203
@@ -198,12 +208,10 @@ static void e1000e_dump(struct e1000_adapter *adapter)
198 if (netdev) { 208 if (netdev) {
199 dev_info(&adapter->pdev->dev, "Net device Info\n"); 209 dev_info(&adapter->pdev->dev, "Net device Info\n");
200 printk(KERN_INFO "Device Name state " 210 printk(KERN_INFO "Device Name state "
201 "trans_start last_rx\n"); 211 "trans_start last_rx\n");
202 printk(KERN_INFO "%-15s %016lX %016lX %016lX\n", 212 printk(KERN_INFO "%-15s %016lX %016lX %016lX\n",
203 netdev->name, 213 netdev->name, netdev->state, netdev->trans_start,
204 netdev->state, 214 netdev->last_rx);
205 netdev->trans_start,
206 netdev->last_rx);
207 } 215 }
208 216
209 /* Print Registers */ 217 /* Print Registers */
@@ -214,26 +222,26 @@ static void e1000e_dump(struct e1000_adapter *adapter)
214 e1000_regdump(hw, reginfo); 222 e1000_regdump(hw, reginfo);
215 } 223 }
216 224
217 /* Print TX Ring Summary */ 225 /* Print Tx Ring Summary */
218 if (!netdev || !netif_running(netdev)) 226 if (!netdev || !netif_running(netdev))
219 goto exit; 227 goto exit;
220 228
221 dev_info(&adapter->pdev->dev, "TX Rings Summary\n"); 229 dev_info(&adapter->pdev->dev, "Tx Ring Summary\n");
222 printk(KERN_INFO "Queue [NTU] [NTC] [bi(ntc)->dma ]" 230 printk(KERN_INFO "Queue [NTU] [NTC] [bi(ntc)->dma ]"
223 " leng ntw timestamp\n"); 231 " leng ntw timestamp\n");
224 buffer_info = &tx_ring->buffer_info[tx_ring->next_to_clean]; 232 buffer_info = &tx_ring->buffer_info[tx_ring->next_to_clean];
225 printk(KERN_INFO " %5d %5X %5X %016llX %04X %3X %016llX\n", 233 printk(KERN_INFO " %5d %5X %5X %016llX %04X %3X %016llX\n",
226 0, tx_ring->next_to_use, tx_ring->next_to_clean, 234 0, tx_ring->next_to_use, tx_ring->next_to_clean,
227 (unsigned long long)buffer_info->dma, 235 (unsigned long long)buffer_info->dma,
228 buffer_info->length, 236 buffer_info->length,
229 buffer_info->next_to_watch, 237 buffer_info->next_to_watch,
230 (unsigned long long)buffer_info->time_stamp); 238 (unsigned long long)buffer_info->time_stamp);
231 239
232 /* Print TX Rings */ 240 /* Print Tx Ring */
233 if (!netif_msg_tx_done(adapter)) 241 if (!netif_msg_tx_done(adapter))
234 goto rx_ring_summary; 242 goto rx_ring_summary;
235 243
236 dev_info(&adapter->pdev->dev, "TX Rings Dump\n"); 244 dev_info(&adapter->pdev->dev, "Tx Ring Dump\n");
237 245
238 /* Transmit Descriptor Formats - DEXT[29] is 0 (Legacy) or 1 (Extended) 246 /* Transmit Descriptor Formats - DEXT[29] is 0 (Legacy) or 1 (Extended)
239 * 247 *
@@ -263,22 +271,22 @@ static void e1000e_dump(struct e1000_adapter *adapter)
263 * 63 48 47 40 39 36 35 32 31 24 23 20 19 0 271 * 63 48 47 40 39 36 35 32 31 24 23 20 19 0
264 */ 272 */
265 printk(KERN_INFO "Tl[desc] [address 63:0 ] [SpeCssSCmCsLen]" 273 printk(KERN_INFO "Tl[desc] [address 63:0 ] [SpeCssSCmCsLen]"
266 " [bi->dma ] leng ntw timestamp bi->skb " 274 " [bi->dma ] leng ntw timestamp bi->skb "
267 "<-- Legacy format\n"); 275 "<-- Legacy format\n");
268 printk(KERN_INFO "Tc[desc] [Ce CoCsIpceCoS] [MssHlRSCm0Plen]" 276 printk(KERN_INFO "Tc[desc] [Ce CoCsIpceCoS] [MssHlRSCm0Plen]"
269 " [bi->dma ] leng ntw timestamp bi->skb " 277 " [bi->dma ] leng ntw timestamp bi->skb "
270 "<-- Ext Context format\n"); 278 "<-- Ext Context format\n");
271 printk(KERN_INFO "Td[desc] [address 63:0 ] [VlaPoRSCm1Dlen]" 279 printk(KERN_INFO "Td[desc] [address 63:0 ] [VlaPoRSCm1Dlen]"
272 " [bi->dma ] leng ntw timestamp bi->skb " 280 " [bi->dma ] leng ntw timestamp bi->skb "
273 "<-- Ext Data format\n"); 281 "<-- Ext Data format\n");
274 for (i = 0; tx_ring->desc && (i < tx_ring->count); i++) { 282 for (i = 0; tx_ring->desc && (i < tx_ring->count); i++) {
275 tx_desc = E1000_TX_DESC(*tx_ring, i); 283 tx_desc = E1000_TX_DESC(*tx_ring, i);
276 buffer_info = &tx_ring->buffer_info[i]; 284 buffer_info = &tx_ring->buffer_info[i];
277 u0 = (struct my_u0 *)tx_desc; 285 u0 = (struct my_u0 *)tx_desc;
278 printk(KERN_INFO "T%c[0x%03X] %016llX %016llX %016llX " 286 printk(KERN_INFO "T%c[0x%03X] %016llX %016llX %016llX "
279 "%04X %3X %016llX %p", 287 "%04X %3X %016llX %p",
280 (!(le64_to_cpu(u0->b) & (1<<29)) ? 'l' : 288 (!(le64_to_cpu(u0->b) & (1 << 29)) ? 'l' :
281 ((le64_to_cpu(u0->b) & (1<<20)) ? 'd' : 'c')), i, 289 ((le64_to_cpu(u0->b) & (1 << 20)) ? 'd' : 'c')), i,
282 (unsigned long long)le64_to_cpu(u0->a), 290 (unsigned long long)le64_to_cpu(u0->a),
283 (unsigned long long)le64_to_cpu(u0->b), 291 (unsigned long long)le64_to_cpu(u0->b),
284 (unsigned long long)buffer_info->dma, 292 (unsigned long long)buffer_info->dma,
@@ -296,22 +304,22 @@ static void e1000e_dump(struct e1000_adapter *adapter)
296 304
297 if (netif_msg_pktdata(adapter) && buffer_info->dma != 0) 305 if (netif_msg_pktdata(adapter) && buffer_info->dma != 0)
298 print_hex_dump(KERN_INFO, "", DUMP_PREFIX_ADDRESS, 306 print_hex_dump(KERN_INFO, "", DUMP_PREFIX_ADDRESS,
299 16, 1, phys_to_virt(buffer_info->dma), 307 16, 1, phys_to_virt(buffer_info->dma),
300 buffer_info->length, true); 308 buffer_info->length, true);
301 } 309 }
302 310
303 /* Print RX Rings Summary */ 311 /* Print Rx Ring Summary */
304rx_ring_summary: 312rx_ring_summary:
305 dev_info(&adapter->pdev->dev, "RX Rings Summary\n"); 313 dev_info(&adapter->pdev->dev, "Rx Ring Summary\n");
306 printk(KERN_INFO "Queue [NTU] [NTC]\n"); 314 printk(KERN_INFO "Queue [NTU] [NTC]\n");
307 printk(KERN_INFO " %5d %5X %5X\n", 0, 315 printk(KERN_INFO " %5d %5X %5X\n", 0,
308 rx_ring->next_to_use, rx_ring->next_to_clean); 316 rx_ring->next_to_use, rx_ring->next_to_clean);
309 317
310 /* Print RX Rings */ 318 /* Print Rx Ring */
311 if (!netif_msg_rx_status(adapter)) 319 if (!netif_msg_rx_status(adapter))
312 goto exit; 320 goto exit;
313 321
314 dev_info(&adapter->pdev->dev, "RX Rings Dump\n"); 322 dev_info(&adapter->pdev->dev, "Rx Ring Dump\n");
315 switch (adapter->rx_ps_pages) { 323 switch (adapter->rx_ps_pages) {
316 case 1: 324 case 1:
317 case 2: 325 case 2:
@@ -329,7 +337,7 @@ rx_ring_summary:
329 * +-----------------------------------------------------+ 337 * +-----------------------------------------------------+
330 */ 338 */
331 printk(KERN_INFO "R [desc] [buffer 0 63:0 ] " 339 printk(KERN_INFO "R [desc] [buffer 0 63:0 ] "
332 "[buffer 1 63:0 ] " 340 "[buffer 1 63:0 ] "
333 "[buffer 2 63:0 ] [buffer 3 63:0 ] [bi->dma ] " 341 "[buffer 2 63:0 ] [buffer 3 63:0 ] [bi->dma ] "
334 "[bi->skb] <-- Ext Pkt Split format\n"); 342 "[bi->skb] <-- Ext Pkt Split format\n");
335 /* [Extended] Receive Descriptor (Write-Back) Format 343 /* [Extended] Receive Descriptor (Write-Back) Format
@@ -344,7 +352,7 @@ rx_ring_summary:
344 * 63 48 47 32 31 20 19 0 352 * 63 48 47 32 31 20 19 0
345 */ 353 */
346 printk(KERN_INFO "RWB[desc] [ck ipid mrqhsh] " 354 printk(KERN_INFO "RWB[desc] [ck ipid mrqhsh] "
347 "[vl l0 ee es] " 355 "[vl l0 ee es] "
348 "[ l3 l2 l1 hs] [reserved ] ---------------- " 356 "[ l3 l2 l1 hs] [reserved ] ---------------- "
349 "[bi->skb] <-- Ext Rx Write-Back format\n"); 357 "[bi->skb] <-- Ext Rx Write-Back format\n");
350 for (i = 0; i < rx_ring->count; i++) { 358 for (i = 0; i < rx_ring->count; i++) {
@@ -352,26 +360,26 @@ rx_ring_summary:
352 rx_desc_ps = E1000_RX_DESC_PS(*rx_ring, i); 360 rx_desc_ps = E1000_RX_DESC_PS(*rx_ring, i);
353 u1 = (struct my_u1 *)rx_desc_ps; 361 u1 = (struct my_u1 *)rx_desc_ps;
354 staterr = 362 staterr =
355 le32_to_cpu(rx_desc_ps->wb.middle.status_error); 363 le32_to_cpu(rx_desc_ps->wb.middle.status_error);
356 if (staterr & E1000_RXD_STAT_DD) { 364 if (staterr & E1000_RXD_STAT_DD) {
357 /* Descriptor Done */ 365 /* Descriptor Done */
358 printk(KERN_INFO "RWB[0x%03X] %016llX " 366 printk(KERN_INFO "RWB[0x%03X] %016llX "
359 "%016llX %016llX %016llX " 367 "%016llX %016llX %016llX "
360 "---------------- %p", i, 368 "---------------- %p", i,
361 (unsigned long long)le64_to_cpu(u1->a), 369 (unsigned long long)le64_to_cpu(u1->a),
362 (unsigned long long)le64_to_cpu(u1->b), 370 (unsigned long long)le64_to_cpu(u1->b),
363 (unsigned long long)le64_to_cpu(u1->c), 371 (unsigned long long)le64_to_cpu(u1->c),
364 (unsigned long long)le64_to_cpu(u1->d), 372 (unsigned long long)le64_to_cpu(u1->d),
365 buffer_info->skb); 373 buffer_info->skb);
366 } else { 374 } else {
367 printk(KERN_INFO "R [0x%03X] %016llX " 375 printk(KERN_INFO "R [0x%03X] %016llX "
368 "%016llX %016llX %016llX %016llX %p", i, 376 "%016llX %016llX %016llX %016llX %p", i,
369 (unsigned long long)le64_to_cpu(u1->a), 377 (unsigned long long)le64_to_cpu(u1->a),
370 (unsigned long long)le64_to_cpu(u1->b), 378 (unsigned long long)le64_to_cpu(u1->b),
371 (unsigned long long)le64_to_cpu(u1->c), 379 (unsigned long long)le64_to_cpu(u1->c),
372 (unsigned long long)le64_to_cpu(u1->d), 380 (unsigned long long)le64_to_cpu(u1->d),
373 (unsigned long long)buffer_info->dma, 381 (unsigned long long)buffer_info->dma,
374 buffer_info->skb); 382 buffer_info->skb);
375 383
376 if (netif_msg_pktdata(adapter)) 384 if (netif_msg_pktdata(adapter))
377 print_hex_dump(KERN_INFO, "", 385 print_hex_dump(KERN_INFO, "",
@@ -400,18 +408,18 @@ rx_ring_summary:
400 * 63 48 47 40 39 32 31 16 15 0 408 * 63 48 47 40 39 32 31 16 15 0
401 */ 409 */
402 printk(KERN_INFO "Rl[desc] [address 63:0 ] " 410 printk(KERN_INFO "Rl[desc] [address 63:0 ] "
403 "[vl er S cks ln] [bi->dma ] [bi->skb] " 411 "[vl er S cks ln] [bi->dma ] [bi->skb] "
404 "<-- Legacy format\n"); 412 "<-- Legacy format\n");
405 for (i = 0; rx_ring->desc && (i < rx_ring->count); i++) { 413 for (i = 0; rx_ring->desc && (i < rx_ring->count); i++) {
406 rx_desc = E1000_RX_DESC(*rx_ring, i); 414 rx_desc = E1000_RX_DESC(*rx_ring, i);
407 buffer_info = &rx_ring->buffer_info[i]; 415 buffer_info = &rx_ring->buffer_info[i];
408 u0 = (struct my_u0 *)rx_desc; 416 u0 = (struct my_u0 *)rx_desc;
409 printk(KERN_INFO "Rl[0x%03X] %016llX %016llX " 417 printk(KERN_INFO "Rl[0x%03X] %016llX %016llX "
410 "%016llX %p", i, 418 "%016llX %p", i,
411 (unsigned long long)le64_to_cpu(u0->a), 419 (unsigned long long)le64_to_cpu(u0->a),
412 (unsigned long long)le64_to_cpu(u0->b), 420 (unsigned long long)le64_to_cpu(u0->b),
413 (unsigned long long)buffer_info->dma, 421 (unsigned long long)buffer_info->dma,
414 buffer_info->skb); 422 buffer_info->skb);
415 if (i == rx_ring->next_to_use) 423 if (i == rx_ring->next_to_use)
416 printk(KERN_CONT " NTU\n"); 424 printk(KERN_CONT " NTU\n");
417 else if (i == rx_ring->next_to_clean) 425 else if (i == rx_ring->next_to_clean)
@@ -421,9 +429,10 @@ rx_ring_summary:
421 429
422 if (netif_msg_pktdata(adapter)) 430 if (netif_msg_pktdata(adapter))
423 print_hex_dump(KERN_INFO, "", 431 print_hex_dump(KERN_INFO, "",
424 DUMP_PREFIX_ADDRESS, 432 DUMP_PREFIX_ADDRESS,
425 16, 1, phys_to_virt(buffer_info->dma), 433 16, 1,
426 adapter->rx_buffer_len, true); 434 phys_to_virt(buffer_info->dma),
435 adapter->rx_buffer_len, true);
427 } 436 }
428 } 437 }
429 438
@@ -450,21 +459,20 @@ static int e1000_desc_unused(struct e1000_ring *ring)
450 * @skb: pointer to sk_buff to be indicated to stack 459 * @skb: pointer to sk_buff to be indicated to stack
451 **/ 460 **/
452static void e1000_receive_skb(struct e1000_adapter *adapter, 461static void e1000_receive_skb(struct e1000_adapter *adapter,
453 struct net_device *netdev, 462 struct net_device *netdev, struct sk_buff *skb,
454 struct sk_buff *skb,
455 u8 status, __le16 vlan) 463 u8 status, __le16 vlan)
456{ 464{
465 u16 tag = le16_to_cpu(vlan);
457 skb->protocol = eth_type_trans(skb, netdev); 466 skb->protocol = eth_type_trans(skb, netdev);
458 467
459 if (adapter->vlgrp && (status & E1000_RXD_STAT_VP)) 468 if (status & E1000_RXD_STAT_VP)
460 vlan_gro_receive(&adapter->napi, adapter->vlgrp, 469 __vlan_hwaccel_put_tag(skb, tag);
461 le16_to_cpu(vlan), skb); 470
462 else 471 napi_gro_receive(&adapter->napi, skb);
463 napi_gro_receive(&adapter->napi, skb);
464} 472}
465 473
466/** 474/**
467 * e1000_rx_checksum - Receive Checksum Offload for 82543 475 * e1000_rx_checksum - Receive Checksum Offload
468 * @adapter: board private structure 476 * @adapter: board private structure
469 * @status_err: receive descriptor status and error fields 477 * @status_err: receive descriptor status and error fields
470 * @csum: receive descriptor csum field 478 * @csum: receive descriptor csum field
@@ -475,7 +483,8 @@ static void e1000_rx_checksum(struct e1000_adapter *adapter, u32 status_err,
475{ 483{
476 u16 status = (u16)status_err; 484 u16 status = (u16)status_err;
477 u8 errors = (u8)(status_err >> 24); 485 u8 errors = (u8)(status_err >> 24);
478 skb->ip_summed = CHECKSUM_NONE; 486
487 skb_checksum_none_assert(skb);
479 488
480 /* Ignore Checksum bit is set */ 489 /* Ignore Checksum bit is set */
481 if (status & E1000_RXD_STAT_IXSM) 490 if (status & E1000_RXD_STAT_IXSM)
@@ -547,7 +556,7 @@ map_skb:
547 adapter->rx_buffer_len, 556 adapter->rx_buffer_len,
548 DMA_FROM_DEVICE); 557 DMA_FROM_DEVICE);
549 if (dma_mapping_error(&pdev->dev, buffer_info->dma)) { 558 if (dma_mapping_error(&pdev->dev, buffer_info->dma)) {
550 dev_err(&pdev->dev, "RX DMA map failed\n"); 559 dev_err(&pdev->dev, "Rx DMA map failed\n");
551 adapter->rx_dma_failed++; 560 adapter->rx_dma_failed++;
552 break; 561 break;
553 } 562 }
@@ -600,7 +609,8 @@ static void e1000_alloc_rx_buffers_ps(struct e1000_adapter *adapter,
600 ps_page = &buffer_info->ps_pages[j]; 609 ps_page = &buffer_info->ps_pages[j];
601 if (j >= adapter->rx_ps_pages) { 610 if (j >= adapter->rx_ps_pages) {
602 /* all unused desc entries get hw null ptr */ 611 /* all unused desc entries get hw null ptr */
603 rx_desc->read.buffer_addr[j+1] = ~cpu_to_le64(0); 612 rx_desc->read.buffer_addr[j + 1] =
613 ~cpu_to_le64(0);
604 continue; 614 continue;
605 } 615 }
606 if (!ps_page->page) { 616 if (!ps_page->page) {
@@ -616,7 +626,7 @@ static void e1000_alloc_rx_buffers_ps(struct e1000_adapter *adapter,
616 if (dma_mapping_error(&pdev->dev, 626 if (dma_mapping_error(&pdev->dev,
617 ps_page->dma)) { 627 ps_page->dma)) {
618 dev_err(&adapter->pdev->dev, 628 dev_err(&adapter->pdev->dev,
619 "RX DMA page map failed\n"); 629 "Rx DMA page map failed\n");
620 adapter->rx_dma_failed++; 630 adapter->rx_dma_failed++;
621 goto no_buffers; 631 goto no_buffers;
622 } 632 }
@@ -626,8 +636,8 @@ static void e1000_alloc_rx_buffers_ps(struct e1000_adapter *adapter,
626 * didn't change because each write-back 636 * didn't change because each write-back
627 * erases this info. 637 * erases this info.
628 */ 638 */
629 rx_desc->read.buffer_addr[j+1] = 639 rx_desc->read.buffer_addr[j + 1] =
630 cpu_to_le64(ps_page->dma); 640 cpu_to_le64(ps_page->dma);
631 } 641 }
632 642
633 skb = netdev_alloc_skb_ip_align(netdev, 643 skb = netdev_alloc_skb_ip_align(netdev,
@@ -643,7 +653,7 @@ static void e1000_alloc_rx_buffers_ps(struct e1000_adapter *adapter,
643 adapter->rx_ps_bsize0, 653 adapter->rx_ps_bsize0,
644 DMA_FROM_DEVICE); 654 DMA_FROM_DEVICE);
645 if (dma_mapping_error(&pdev->dev, buffer_info->dma)) { 655 if (dma_mapping_error(&pdev->dev, buffer_info->dma)) {
646 dev_err(&pdev->dev, "RX DMA map failed\n"); 656 dev_err(&pdev->dev, "Rx DMA map failed\n");
647 adapter->rx_dma_failed++; 657 adapter->rx_dma_failed++;
648 /* cleanup skb */ 658 /* cleanup skb */
649 dev_kfree_skb_any(skb); 659 dev_kfree_skb_any(skb);
@@ -661,7 +671,7 @@ static void e1000_alloc_rx_buffers_ps(struct e1000_adapter *adapter,
661 * such as IA-64). 671 * such as IA-64).
662 */ 672 */
663 wmb(); 673 wmb();
664 writel(i<<1, adapter->hw.hw_addr + rx_ring->tail); 674 writel(i << 1, adapter->hw.hw_addr + rx_ring->tail);
665 } 675 }
666 676
667 i++; 677 i++;
@@ -893,8 +903,6 @@ next_desc:
893 903
894 adapter->total_rx_bytes += total_rx_bytes; 904 adapter->total_rx_bytes += total_rx_bytes;
895 adapter->total_rx_packets += total_rx_packets; 905 adapter->total_rx_packets += total_rx_packets;
896 netdev->stats.rx_bytes += total_rx_bytes;
897 netdev->stats.rx_packets += total_rx_packets;
898 return cleaned; 906 return cleaned;
899} 907}
900 908
@@ -930,6 +938,9 @@ static void e1000_print_hw_hang(struct work_struct *work)
930 u16 phy_status, phy_1000t_status, phy_ext_status; 938 u16 phy_status, phy_1000t_status, phy_ext_status;
931 u16 pci_status; 939 u16 pci_status;
932 940
941 if (test_bit(__E1000_DOWN, &adapter->state))
942 return;
943
933 e1e_rphy(hw, PHY_STATUS, &phy_status); 944 e1e_rphy(hw, PHY_STATUS, &phy_status);
934 e1e_rphy(hw, PHY_1000T_STATUS, &phy_1000t_status); 945 e1e_rphy(hw, PHY_1000T_STATUS, &phy_1000t_status);
935 e1e_rphy(hw, PHY_EXT_STATUS, &phy_ext_status); 946 e1e_rphy(hw, PHY_EXT_STATUS, &phy_ext_status);
@@ -1050,9 +1061,7 @@ static bool e1000_clean_tx_irq(struct e1000_adapter *adapter)
1050 } 1061 }
1051 adapter->total_tx_bytes += total_tx_bytes; 1062 adapter->total_tx_bytes += total_tx_bytes;
1052 adapter->total_tx_packets += total_tx_packets; 1063 adapter->total_tx_packets += total_tx_packets;
1053 netdev->stats.tx_bytes += total_tx_bytes; 1064 return count < tx_ring->count;
1054 netdev->stats.tx_packets += total_tx_packets;
1055 return (count < tx_ring->count);
1056} 1065}
1057 1066
1058/** 1067/**
@@ -1105,11 +1114,10 @@ static bool e1000_clean_rx_irq_ps(struct e1000_adapter *adapter,
1105 cleaned = 1; 1114 cleaned = 1;
1106 cleaned_count++; 1115 cleaned_count++;
1107 dma_unmap_single(&pdev->dev, buffer_info->dma, 1116 dma_unmap_single(&pdev->dev, buffer_info->dma,
1108 adapter->rx_ps_bsize0, 1117 adapter->rx_ps_bsize0, DMA_FROM_DEVICE);
1109 DMA_FROM_DEVICE);
1110 buffer_info->dma = 0; 1118 buffer_info->dma = 0;
1111 1119
1112 /* see !EOP comment in other rx routine */ 1120 /* see !EOP comment in other Rx routine */
1113 if (!(staterr & E1000_RXD_STAT_EOP)) 1121 if (!(staterr & E1000_RXD_STAT_EOP))
1114 adapter->flags2 |= FLAG2_IS_DISCARDING; 1122 adapter->flags2 |= FLAG2_IS_DISCARDING;
1115 1123
@@ -1239,8 +1247,6 @@ next_desc:
1239 1247
1240 adapter->total_rx_bytes += total_rx_bytes; 1248 adapter->total_rx_bytes += total_rx_bytes;
1241 adapter->total_rx_packets += total_rx_packets; 1249 adapter->total_rx_packets += total_rx_packets;
1242 netdev->stats.rx_bytes += total_rx_bytes;
1243 netdev->stats.rx_packets += total_rx_packets;
1244 return cleaned; 1250 return cleaned;
1245} 1251}
1246 1252
@@ -1319,12 +1325,12 @@ static bool e1000_clean_jumbo_rx_irq(struct e1000_adapter *adapter,
1319 /* an error means any chain goes out the window 1325 /* an error means any chain goes out the window
1320 * too */ 1326 * too */
1321 if (rx_ring->rx_skb_top) 1327 if (rx_ring->rx_skb_top)
1322 dev_kfree_skb(rx_ring->rx_skb_top); 1328 dev_kfree_skb_irq(rx_ring->rx_skb_top);
1323 rx_ring->rx_skb_top = NULL; 1329 rx_ring->rx_skb_top = NULL;
1324 goto next_desc; 1330 goto next_desc;
1325 } 1331 }
1326 1332
1327#define rxtop rx_ring->rx_skb_top 1333#define rxtop (rx_ring->rx_skb_top)
1328 if (!(status & E1000_RXD_STAT_EOP)) { 1334 if (!(status & E1000_RXD_STAT_EOP)) {
1329 /* this descriptor is only the beginning (or middle) */ 1335 /* this descriptor is only the beginning (or middle) */
1330 if (!rxtop) { 1336 if (!rxtop) {
@@ -1392,7 +1398,7 @@ static bool e1000_clean_jumbo_rx_irq(struct e1000_adapter *adapter,
1392 /* eth type trans needs skb->data to point to something */ 1398 /* eth type trans needs skb->data to point to something */
1393 if (!pskb_may_pull(skb, ETH_HLEN)) { 1399 if (!pskb_may_pull(skb, ETH_HLEN)) {
1394 e_err("pskb_may_pull failed.\n"); 1400 e_err("pskb_may_pull failed.\n");
1395 dev_kfree_skb(skb); 1401 dev_kfree_skb_irq(skb);
1396 goto next_desc; 1402 goto next_desc;
1397 } 1403 }
1398 1404
@@ -1420,8 +1426,6 @@ next_desc:
1420 1426
1421 adapter->total_rx_bytes += total_rx_bytes; 1427 adapter->total_rx_bytes += total_rx_bytes;
1422 adapter->total_rx_packets += total_rx_packets; 1428 adapter->total_rx_packets += total_rx_packets;
1423 netdev->stats.rx_bytes += total_rx_bytes;
1424 netdev->stats.rx_packets += total_rx_packets;
1425 return cleaned; 1429 return cleaned;
1426} 1430}
1427 1431
@@ -1500,6 +1504,9 @@ static void e1000e_downshift_workaround(struct work_struct *work)
1500 struct e1000_adapter *adapter = container_of(work, 1504 struct e1000_adapter *adapter = container_of(work,
1501 struct e1000_adapter, downshift_task); 1505 struct e1000_adapter, downshift_task);
1502 1506
1507 if (test_bit(__E1000_DOWN, &adapter->state))
1508 return;
1509
1503 e1000e_gig_downshift_workaround_ich8lan(&adapter->hw); 1510 e1000e_gig_downshift_workaround_ich8lan(&adapter->hw);
1504} 1511}
1505 1512
@@ -1805,9 +1812,8 @@ void e1000e_set_interrupt_capability(struct e1000_adapter *adapter)
1805 err = pci_enable_msix(adapter->pdev, 1812 err = pci_enable_msix(adapter->pdev,
1806 adapter->msix_entries, 1813 adapter->msix_entries,
1807 adapter->num_vectors); 1814 adapter->num_vectors);
1808 if (err == 0) { 1815 if (err == 0)
1809 return; 1816 return;
1810 }
1811 } 1817 }
1812 /* MSI-X failed, so fall through and try MSI */ 1818 /* MSI-X failed, so fall through and try MSI */
1813 e_err("Failed to initialize MSI-X interrupts. " 1819 e_err("Failed to initialize MSI-X interrupts. "
@@ -1846,7 +1852,9 @@ static int e1000_request_msix(struct e1000_adapter *adapter)
1846 int err = 0, vector = 0; 1852 int err = 0, vector = 0;
1847 1853
1848 if (strlen(netdev->name) < (IFNAMSIZ - 5)) 1854 if (strlen(netdev->name) < (IFNAMSIZ - 5))
1849 sprintf(adapter->rx_ring->name, "%s-rx-0", netdev->name); 1855 snprintf(adapter->rx_ring->name,
1856 sizeof(adapter->rx_ring->name) - 1,
1857 "%s-rx-0", netdev->name);
1850 else 1858 else
1851 memcpy(adapter->rx_ring->name, netdev->name, IFNAMSIZ); 1859 memcpy(adapter->rx_ring->name, netdev->name, IFNAMSIZ);
1852 err = request_irq(adapter->msix_entries[vector].vector, 1860 err = request_irq(adapter->msix_entries[vector].vector,
@@ -1859,7 +1867,9 @@ static int e1000_request_msix(struct e1000_adapter *adapter)
1859 vector++; 1867 vector++;
1860 1868
1861 if (strlen(netdev->name) < (IFNAMSIZ - 5)) 1869 if (strlen(netdev->name) < (IFNAMSIZ - 5))
1862 sprintf(adapter->tx_ring->name, "%s-tx-0", netdev->name); 1870 snprintf(adapter->tx_ring->name,
1871 sizeof(adapter->tx_ring->name) - 1,
1872 "%s-tx-0", netdev->name);
1863 else 1873 else
1864 memcpy(adapter->tx_ring->name, netdev->name, IFNAMSIZ); 1874 memcpy(adapter->tx_ring->name, netdev->name, IFNAMSIZ);
1865 err = request_irq(adapter->msix_entries[vector].vector, 1875 err = request_irq(adapter->msix_entries[vector].vector,
@@ -1980,15 +1990,15 @@ static void e1000_irq_enable(struct e1000_adapter *adapter)
1980} 1990}
1981 1991
1982/** 1992/**
1983 * e1000_get_hw_control - get control of the h/w from f/w 1993 * e1000e_get_hw_control - get control of the h/w from f/w
1984 * @adapter: address of board private structure 1994 * @adapter: address of board private structure
1985 * 1995 *
1986 * e1000_get_hw_control sets {CTRL_EXT|SWSM}:DRV_LOAD bit. 1996 * e1000e_get_hw_control sets {CTRL_EXT|SWSM}:DRV_LOAD bit.
1987 * For ASF and Pass Through versions of f/w this means that 1997 * For ASF and Pass Through versions of f/w this means that
1988 * the driver is loaded. For AMT version (only with 82573) 1998 * the driver is loaded. For AMT version (only with 82573)
1989 * of the f/w this means that the network i/f is open. 1999 * of the f/w this means that the network i/f is open.
1990 **/ 2000 **/
1991static void e1000_get_hw_control(struct e1000_adapter *adapter) 2001void e1000e_get_hw_control(struct e1000_adapter *adapter)
1992{ 2002{
1993 struct e1000_hw *hw = &adapter->hw; 2003 struct e1000_hw *hw = &adapter->hw;
1994 u32 ctrl_ext; 2004 u32 ctrl_ext;
@@ -2005,16 +2015,16 @@ static void e1000_get_hw_control(struct e1000_adapter *adapter)
2005} 2015}
2006 2016
2007/** 2017/**
2008 * e1000_release_hw_control - release control of the h/w to f/w 2018 * e1000e_release_hw_control - release control of the h/w to f/w
2009 * @adapter: address of board private structure 2019 * @adapter: address of board private structure
2010 * 2020 *
2011 * e1000_release_hw_control resets {CTRL_EXT|SWSM}:DRV_LOAD bit. 2021 * e1000e_release_hw_control resets {CTRL_EXT|SWSM}:DRV_LOAD bit.
2012 * For ASF and Pass Through versions of f/w this means that the 2022 * For ASF and Pass Through versions of f/w this means that the
2013 * driver is no longer loaded. For AMT version (only with 82573) i 2023 * driver is no longer loaded. For AMT version (only with 82573) i
2014 * of the f/w this means that the network i/f is closed. 2024 * of the f/w this means that the network i/f is closed.
2015 * 2025 *
2016 **/ 2026 **/
2017static void e1000_release_hw_control(struct e1000_adapter *adapter) 2027void e1000e_release_hw_control(struct e1000_adapter *adapter)
2018{ 2028{
2019 struct e1000_hw *hw = &adapter->hw; 2029 struct e1000_hw *hw = &adapter->hw;
2020 u32 ctrl_ext; 2030 u32 ctrl_ext;
@@ -2058,10 +2068,9 @@ int e1000e_setup_tx_resources(struct e1000_adapter *adapter)
2058 int err = -ENOMEM, size; 2068 int err = -ENOMEM, size;
2059 2069
2060 size = sizeof(struct e1000_buffer) * tx_ring->count; 2070 size = sizeof(struct e1000_buffer) * tx_ring->count;
2061 tx_ring->buffer_info = vmalloc(size); 2071 tx_ring->buffer_info = vzalloc(size);
2062 if (!tx_ring->buffer_info) 2072 if (!tx_ring->buffer_info)
2063 goto err; 2073 goto err;
2064 memset(tx_ring->buffer_info, 0, size);
2065 2074
2066 /* round up to nearest 4K */ 2075 /* round up to nearest 4K */
2067 tx_ring->size = tx_ring->count * sizeof(struct e1000_tx_desc); 2076 tx_ring->size = tx_ring->count * sizeof(struct e1000_tx_desc);
@@ -2094,10 +2103,9 @@ int e1000e_setup_rx_resources(struct e1000_adapter *adapter)
2094 int i, size, desc_len, err = -ENOMEM; 2103 int i, size, desc_len, err = -ENOMEM;
2095 2104
2096 size = sizeof(struct e1000_buffer) * rx_ring->count; 2105 size = sizeof(struct e1000_buffer) * rx_ring->count;
2097 rx_ring->buffer_info = vmalloc(size); 2106 rx_ring->buffer_info = vzalloc(size);
2098 if (!rx_ring->buffer_info) 2107 if (!rx_ring->buffer_info)
2099 goto err; 2108 goto err;
2100 memset(rx_ring->buffer_info, 0, size);
2101 2109
2102 for (i = 0; i < rx_ring->count; i++) { 2110 for (i = 0; i < rx_ring->count; i++) {
2103 buffer_info = &rx_ring->buffer_info[i]; 2111 buffer_info = &rx_ring->buffer_info[i];
@@ -2131,7 +2139,7 @@ err_pages:
2131 } 2139 }
2132err: 2140err:
2133 vfree(rx_ring->buffer_info); 2141 vfree(rx_ring->buffer_info);
2134 e_err("Unable to allocate memory for the transmit descriptor ring\n"); 2142 e_err("Unable to allocate memory for the receive descriptor ring\n");
2135 return err; 2143 return err;
2136} 2144}
2137 2145
@@ -2199,9 +2207,8 @@ void e1000e_free_rx_resources(struct e1000_adapter *adapter)
2199 2207
2200 e1000_clean_rx_ring(adapter); 2208 e1000_clean_rx_ring(adapter);
2201 2209
2202 for (i = 0; i < rx_ring->count; i++) { 2210 for (i = 0; i < rx_ring->count; i++)
2203 kfree(rx_ring->buffer_info[i].ps_pages); 2211 kfree(rx_ring->buffer_info[i].ps_pages);
2204 }
2205 2212
2206 vfree(rx_ring->buffer_info); 2213 vfree(rx_ring->buffer_info);
2207 rx_ring->buffer_info = NULL; 2214 rx_ring->buffer_info = NULL;
@@ -2241,20 +2248,18 @@ static unsigned int e1000_update_itr(struct e1000_adapter *adapter,
2241 /* handle TSO and jumbo frames */ 2248 /* handle TSO and jumbo frames */
2242 if (bytes/packets > 8000) 2249 if (bytes/packets > 8000)
2243 retval = bulk_latency; 2250 retval = bulk_latency;
2244 else if ((packets < 5) && (bytes > 512)) { 2251 else if ((packets < 5) && (bytes > 512))
2245 retval = low_latency; 2252 retval = low_latency;
2246 }
2247 break; 2253 break;
2248 case low_latency: /* 50 usec aka 20000 ints/s */ 2254 case low_latency: /* 50 usec aka 20000 ints/s */
2249 if (bytes > 10000) { 2255 if (bytes > 10000) {
2250 /* this if handles the TSO accounting */ 2256 /* this if handles the TSO accounting */
2251 if (bytes/packets > 8000) { 2257 if (bytes/packets > 8000)
2252 retval = bulk_latency; 2258 retval = bulk_latency;
2253 } else if ((packets < 10) || ((bytes/packets) > 1200)) { 2259 else if ((packets < 10) || ((bytes/packets) > 1200))
2254 retval = bulk_latency; 2260 retval = bulk_latency;
2255 } else if ((packets > 35)) { 2261 else if ((packets > 35))
2256 retval = lowest_latency; 2262 retval = lowest_latency;
2257 }
2258 } else if (bytes/packets > 2000) { 2263 } else if (bytes/packets > 2000) {
2259 retval = bulk_latency; 2264 retval = bulk_latency;
2260 } else if (packets <= 2 && bytes < 512) { 2265 } else if (packets <= 2 && bytes < 512) {
@@ -2263,9 +2268,8 @@ static unsigned int e1000_update_itr(struct e1000_adapter *adapter,
2263 break; 2268 break;
2264 case bulk_latency: /* 250 usec aka 4000 ints/s */ 2269 case bulk_latency: /* 250 usec aka 4000 ints/s */
2265 if (bytes > 25000) { 2270 if (bytes > 25000) {
2266 if (packets > 35) { 2271 if (packets > 35)
2267 retval = low_latency; 2272 retval = low_latency;
2268 }
2269 } else if (bytes < 6000) { 2273 } else if (bytes < 6000) {
2270 retval = low_latency; 2274 retval = low_latency;
2271 } 2275 }
@@ -2289,6 +2293,11 @@ static void e1000_set_itr(struct e1000_adapter *adapter)
2289 goto set_itr_now; 2293 goto set_itr_now;
2290 } 2294 }
2291 2295
2296 if (adapter->flags2 & FLAG2_DISABLE_AIM) {
2297 new_itr = 0;
2298 goto set_itr_now;
2299 }
2300
2292 adapter->tx_itr = e1000_update_itr(adapter, 2301 adapter->tx_itr = e1000_update_itr(adapter,
2293 adapter->tx_itr, 2302 adapter->tx_itr,
2294 adapter->total_tx_packets, 2303 adapter->total_tx_packets,
@@ -2337,7 +2346,10 @@ set_itr_now:
2337 if (adapter->msix_entries) 2346 if (adapter->msix_entries)
2338 adapter->rx_ring->set_itr = 1; 2347 adapter->rx_ring->set_itr = 1;
2339 else 2348 else
2340 ew32(ITR, 1000000000 / (new_itr * 256)); 2349 if (new_itr)
2350 ew32(ITR, 1000000000 / (new_itr * 256));
2351 else
2352 ew32(ITR, 0);
2341 } 2353 }
2342} 2354}
2343 2355
@@ -2424,6 +2436,8 @@ static void e1000_vlan_rx_add_vid(struct net_device *netdev, u16 vid)
2424 vfta |= (1 << (vid & 0x1F)); 2436 vfta |= (1 << (vid & 0x1F));
2425 hw->mac.ops.write_vfta(hw, index, vfta); 2437 hw->mac.ops.write_vfta(hw, index, vfta);
2426 } 2438 }
2439
2440 set_bit(vid, adapter->active_vlans);
2427} 2441}
2428 2442
2429static void e1000_vlan_rx_kill_vid(struct net_device *netdev, u16 vid) 2443static void e1000_vlan_rx_kill_vid(struct net_device *netdev, u16 vid)
@@ -2432,18 +2446,11 @@ static void e1000_vlan_rx_kill_vid(struct net_device *netdev, u16 vid)
2432 struct e1000_hw *hw = &adapter->hw; 2446 struct e1000_hw *hw = &adapter->hw;
2433 u32 vfta, index; 2447 u32 vfta, index;
2434 2448
2435 if (!test_bit(__E1000_DOWN, &adapter->state))
2436 e1000_irq_disable(adapter);
2437 vlan_group_set_device(adapter->vlgrp, vid, NULL);
2438
2439 if (!test_bit(__E1000_DOWN, &adapter->state))
2440 e1000_irq_enable(adapter);
2441
2442 if ((adapter->hw.mng_cookie.status & 2449 if ((adapter->hw.mng_cookie.status &
2443 E1000_MNG_DHCP_COOKIE_STATUS_VLAN) && 2450 E1000_MNG_DHCP_COOKIE_STATUS_VLAN) &&
2444 (vid == adapter->mng_vlan_id)) { 2451 (vid == adapter->mng_vlan_id)) {
2445 /* release control to f/w */ 2452 /* release control to f/w */
2446 e1000_release_hw_control(adapter); 2453 e1000e_release_hw_control(adapter);
2447 return; 2454 return;
2448 } 2455 }
2449 2456
@@ -2454,93 +2461,105 @@ static void e1000_vlan_rx_kill_vid(struct net_device *netdev, u16 vid)
2454 vfta &= ~(1 << (vid & 0x1F)); 2461 vfta &= ~(1 << (vid & 0x1F));
2455 hw->mac.ops.write_vfta(hw, index, vfta); 2462 hw->mac.ops.write_vfta(hw, index, vfta);
2456 } 2463 }
2464
2465 clear_bit(vid, adapter->active_vlans);
2457} 2466}
2458 2467
2459static void e1000_update_mng_vlan(struct e1000_adapter *adapter) 2468/**
2469 * e1000e_vlan_filter_disable - helper to disable hw VLAN filtering
2470 * @adapter: board private structure to initialize
2471 **/
2472static void e1000e_vlan_filter_disable(struct e1000_adapter *adapter)
2460{ 2473{
2461 struct net_device *netdev = adapter->netdev; 2474 struct net_device *netdev = adapter->netdev;
2462 u16 vid = adapter->hw.mng_cookie.vlan_id; 2475 struct e1000_hw *hw = &adapter->hw;
2463 u16 old_vid = adapter->mng_vlan_id; 2476 u32 rctl;
2464
2465 if (!adapter->vlgrp)
2466 return;
2467 2477
2468 if (!vlan_group_get_device(adapter->vlgrp, vid)) { 2478 if (adapter->flags & FLAG_HAS_HW_VLAN_FILTER) {
2469 adapter->mng_vlan_id = E1000_MNG_VLAN_NONE; 2479 /* disable VLAN receive filtering */
2470 if (adapter->hw.mng_cookie.status & 2480 rctl = er32(RCTL);
2471 E1000_MNG_DHCP_COOKIE_STATUS_VLAN) { 2481 rctl &= ~(E1000_RCTL_VFE | E1000_RCTL_CFIEN);
2472 e1000_vlan_rx_add_vid(netdev, vid); 2482 ew32(RCTL, rctl);
2473 adapter->mng_vlan_id = vid; 2483
2484 if (adapter->mng_vlan_id != (u16)E1000_MNG_VLAN_NONE) {
2485 e1000_vlan_rx_kill_vid(netdev, adapter->mng_vlan_id);
2486 adapter->mng_vlan_id = E1000_MNG_VLAN_NONE;
2474 } 2487 }
2475
2476 if ((old_vid != (u16)E1000_MNG_VLAN_NONE) &&
2477 (vid != old_vid) &&
2478 !vlan_group_get_device(adapter->vlgrp, old_vid))
2479 e1000_vlan_rx_kill_vid(netdev, old_vid);
2480 } else {
2481 adapter->mng_vlan_id = vid;
2482 } 2488 }
2483} 2489}
2484 2490
2491/**
2492 * e1000e_vlan_filter_enable - helper to enable HW VLAN filtering
2493 * @adapter: board private structure to initialize
2494 **/
2495static void e1000e_vlan_filter_enable(struct e1000_adapter *adapter)
2496{
2497 struct e1000_hw *hw = &adapter->hw;
2498 u32 rctl;
2499
2500 if (adapter->flags & FLAG_HAS_HW_VLAN_FILTER) {
2501 /* enable VLAN receive filtering */
2502 rctl = er32(RCTL);
2503 rctl |= E1000_RCTL_VFE;
2504 rctl &= ~E1000_RCTL_CFIEN;
2505 ew32(RCTL, rctl);
2506 }
2507}
2485 2508
2486static void e1000_vlan_rx_register(struct net_device *netdev, 2509/**
2487 struct vlan_group *grp) 2510 * e1000e_vlan_strip_enable - helper to disable HW VLAN stripping
2511 * @adapter: board private structure to initialize
2512 **/
2513static void e1000e_vlan_strip_disable(struct e1000_adapter *adapter)
2488{ 2514{
2489 struct e1000_adapter *adapter = netdev_priv(netdev);
2490 struct e1000_hw *hw = &adapter->hw; 2515 struct e1000_hw *hw = &adapter->hw;
2491 u32 ctrl, rctl; 2516 u32 ctrl;
2492 2517
2493 if (!test_bit(__E1000_DOWN, &adapter->state)) 2518 /* disable VLAN tag insert/strip */
2494 e1000_irq_disable(adapter); 2519 ctrl = er32(CTRL);
2495 adapter->vlgrp = grp; 2520 ctrl &= ~E1000_CTRL_VME;
2521 ew32(CTRL, ctrl);
2522}
2496 2523
2497 if (grp) { 2524/**
2498 /* enable VLAN tag insert/strip */ 2525 * e1000e_vlan_strip_enable - helper to enable HW VLAN stripping
2499 ctrl = er32(CTRL); 2526 * @adapter: board private structure to initialize
2500 ctrl |= E1000_CTRL_VME; 2527 **/
2501 ew32(CTRL, ctrl); 2528static void e1000e_vlan_strip_enable(struct e1000_adapter *adapter)
2529{
2530 struct e1000_hw *hw = &adapter->hw;
2531 u32 ctrl;
2502 2532
2503 if (adapter->flags & FLAG_HAS_HW_VLAN_FILTER) { 2533 /* enable VLAN tag insert/strip */
2504 /* enable VLAN receive filtering */ 2534 ctrl = er32(CTRL);
2505 rctl = er32(RCTL); 2535 ctrl |= E1000_CTRL_VME;
2506 rctl &= ~E1000_RCTL_CFIEN; 2536 ew32(CTRL, ctrl);
2507 ew32(RCTL, rctl); 2537}
2508 e1000_update_mng_vlan(adapter);
2509 }
2510 } else {
2511 /* disable VLAN tag insert/strip */
2512 ctrl = er32(CTRL);
2513 ctrl &= ~E1000_CTRL_VME;
2514 ew32(CTRL, ctrl);
2515 2538
2516 if (adapter->flags & FLAG_HAS_HW_VLAN_FILTER) { 2539static void e1000_update_mng_vlan(struct e1000_adapter *adapter)
2517 if (adapter->mng_vlan_id != 2540{
2518 (u16)E1000_MNG_VLAN_NONE) { 2541 struct net_device *netdev = adapter->netdev;
2519 e1000_vlan_rx_kill_vid(netdev, 2542 u16 vid = adapter->hw.mng_cookie.vlan_id;
2520 adapter->mng_vlan_id); 2543 u16 old_vid = adapter->mng_vlan_id;
2521 adapter->mng_vlan_id = E1000_MNG_VLAN_NONE; 2544
2522 } 2545 if (adapter->hw.mng_cookie.status &
2523 } 2546 E1000_MNG_DHCP_COOKIE_STATUS_VLAN) {
2547 e1000_vlan_rx_add_vid(netdev, vid);
2548 adapter->mng_vlan_id = vid;
2524 } 2549 }
2525 2550
2526 if (!test_bit(__E1000_DOWN, &adapter->state)) 2551 if ((old_vid != (u16)E1000_MNG_VLAN_NONE) && (vid != old_vid))
2527 e1000_irq_enable(adapter); 2552 e1000_vlan_rx_kill_vid(netdev, old_vid);
2528} 2553}
2529 2554
2530static void e1000_restore_vlan(struct e1000_adapter *adapter) 2555static void e1000_restore_vlan(struct e1000_adapter *adapter)
2531{ 2556{
2532 u16 vid; 2557 u16 vid;
2533 2558
2534 e1000_vlan_rx_register(adapter->netdev, adapter->vlgrp); 2559 e1000_vlan_rx_add_vid(adapter->netdev, 0);
2535 2560
2536 if (!adapter->vlgrp) 2561 for_each_set_bit(vid, adapter->active_vlans, VLAN_N_VID)
2537 return;
2538
2539 for (vid = 0; vid < VLAN_GROUP_ARRAY_LEN; vid++) {
2540 if (!vlan_group_get_device(adapter->vlgrp, vid))
2541 continue;
2542 e1000_vlan_rx_add_vid(adapter->netdev, vid); 2562 e1000_vlan_rx_add_vid(adapter->netdev, vid);
2543 }
2544} 2563}
2545 2564
2546static void e1000_init_manageability_pt(struct e1000_adapter *adapter) 2565static void e1000_init_manageability_pt(struct e1000_adapter *adapter)
@@ -2608,7 +2627,7 @@ static void e1000_init_manageability_pt(struct e1000_adapter *adapter)
2608} 2627}
2609 2628
2610/** 2629/**
2611 * e1000_configure_tx - Configure 8254x Transmit Unit after Reset 2630 * e1000_configure_tx - Configure Transmit Unit after Reset
2612 * @adapter: board private structure 2631 * @adapter: board private structure
2613 * 2632 *
2614 * Configure the Tx unit of the MAC after a reset. 2633 * Configure the Tx unit of the MAC after a reset.
@@ -2649,6 +2668,26 @@ static void e1000_configure_tx(struct e1000_adapter *adapter)
2649 /* Tx irq moderation */ 2668 /* Tx irq moderation */
2650 ew32(TADV, adapter->tx_abs_int_delay); 2669 ew32(TADV, adapter->tx_abs_int_delay);
2651 2670
2671 if (adapter->flags2 & FLAG2_DMA_BURST) {
2672 u32 txdctl = er32(TXDCTL(0));
2673 txdctl &= ~(E1000_TXDCTL_PTHRESH | E1000_TXDCTL_HTHRESH |
2674 E1000_TXDCTL_WTHRESH);
2675 /*
2676 * set up some performance related parameters to encourage the
2677 * hardware to use the bus more efficiently in bursts, depends
2678 * on the tx_int_delay to be enabled,
2679 * wthresh = 5 ==> burst write a cacheline (64 bytes) at a time
2680 * hthresh = 1 ==> prefetch when one or more available
2681 * pthresh = 0x1f ==> prefetch if internal cache 31 or less
2682 * BEWARE: this seems to work but should be considered first if
2683 * there are Tx hangs or other Tx related bugs
2684 */
2685 txdctl |= E1000_TXDCTL_DMA_BURST_ENABLE;
2686 ew32(TXDCTL(0), txdctl);
2687 /* erratum work around: set txdctl the same for both queues */
2688 ew32(TXDCTL(1), txdctl);
2689 }
2690
2652 /* Program the Transmit Control Register */ 2691 /* Program the Transmit Control Register */
2653 tctl = er32(TCTL); 2692 tctl = er32(TCTL);
2654 tctl &= ~E1000_TCTL_CT; 2693 tctl &= ~E1000_TCTL_CT;
@@ -2701,7 +2740,6 @@ static void e1000_setup_rctl(struct e1000_adapter *adapter)
2701{ 2740{
2702 struct e1000_hw *hw = &adapter->hw; 2741 struct e1000_hw *hw = &adapter->hw;
2703 u32 rctl, rfctl; 2742 u32 rctl, rfctl;
2704 u32 psrctl = 0;
2705 u32 pages = 0; 2743 u32 pages = 0;
2706 2744
2707 /* Workaround Si errata on 82579 - configure jumbo frame flow */ 2745 /* Workaround Si errata on 82579 - configure jumbo frame flow */
@@ -2712,6 +2750,9 @@ static void e1000_setup_rctl(struct e1000_adapter *adapter)
2712 ret_val = e1000_lv_jumbo_workaround_ich8lan(hw, true); 2750 ret_val = e1000_lv_jumbo_workaround_ich8lan(hw, true);
2713 else 2751 else
2714 ret_val = e1000_lv_jumbo_workaround_ich8lan(hw, false); 2752 ret_val = e1000_lv_jumbo_workaround_ich8lan(hw, false);
2753
2754 if (ret_val)
2755 e_dbg("failed to enable jumbo frame workaround mode\n");
2715 } 2756 }
2716 2757
2717 /* Program MC offset vector base */ 2758 /* Program MC offset vector base */
@@ -2797,6 +2838,8 @@ static void e1000_setup_rctl(struct e1000_adapter *adapter)
2797 adapter->rx_ps_pages = 0; 2838 adapter->rx_ps_pages = 0;
2798 2839
2799 if (adapter->rx_ps_pages) { 2840 if (adapter->rx_ps_pages) {
2841 u32 psrctl = 0;
2842
2800 /* Configure extra packet-split registers */ 2843 /* Configure extra packet-split registers */
2801 rfctl = er32(RFCTL); 2844 rfctl = er32(RFCTL);
2802 rfctl |= E1000_RFCTL_EXTEN; 2845 rfctl |= E1000_RFCTL_EXTEN;
@@ -2852,7 +2895,7 @@ static void e1000_configure_rx(struct e1000_adapter *adapter)
2852 if (adapter->rx_ps_pages) { 2895 if (adapter->rx_ps_pages) {
2853 /* this is a 32 byte descriptor */ 2896 /* this is a 32 byte descriptor */
2854 rdlen = rx_ring->count * 2897 rdlen = rx_ring->count *
2855 sizeof(union e1000_rx_desc_packet_split); 2898 sizeof(union e1000_rx_desc_packet_split);
2856 adapter->clean_rx = e1000_clean_rx_irq_ps; 2899 adapter->clean_rx = e1000_clean_rx_irq_ps;
2857 adapter->alloc_rx_buf = e1000_alloc_rx_buffers_ps; 2900 adapter->alloc_rx_buf = e1000_alloc_rx_buffers_ps;
2858 } else if (adapter->netdev->mtu > ETH_FRAME_LEN + ETH_FCS_LEN) { 2901 } else if (adapter->netdev->mtu > ETH_FRAME_LEN + ETH_FCS_LEN) {
@@ -2869,14 +2912,37 @@ static void e1000_configure_rx(struct e1000_adapter *adapter)
2869 rctl = er32(RCTL); 2912 rctl = er32(RCTL);
2870 ew32(RCTL, rctl & ~E1000_RCTL_EN); 2913 ew32(RCTL, rctl & ~E1000_RCTL_EN);
2871 e1e_flush(); 2914 e1e_flush();
2872 msleep(10); 2915 usleep_range(10000, 20000);
2916
2917 if (adapter->flags2 & FLAG2_DMA_BURST) {
2918 /*
2919 * set the writeback threshold (only takes effect if the RDTR
2920 * is set). set GRAN=1 and write back up to 0x4 worth, and
2921 * enable prefetching of 0x20 Rx descriptors
2922 * granularity = 01
2923 * wthresh = 04,
2924 * hthresh = 04,
2925 * pthresh = 0x20
2926 */
2927 ew32(RXDCTL(0), E1000_RXDCTL_DMA_BURST_ENABLE);
2928 ew32(RXDCTL(1), E1000_RXDCTL_DMA_BURST_ENABLE);
2929
2930 /*
2931 * override the delay timers for enabling bursting, only if
2932 * the value was not set by the user via module options
2933 */
2934 if (adapter->rx_int_delay == DEFAULT_RDTR)
2935 adapter->rx_int_delay = BURST_RDTR;
2936 if (adapter->rx_abs_int_delay == DEFAULT_RADV)
2937 adapter->rx_abs_int_delay = BURST_RADV;
2938 }
2873 2939
2874 /* set the Receive Delay Timer Register */ 2940 /* set the Receive Delay Timer Register */
2875 ew32(RDTR, adapter->rx_int_delay); 2941 ew32(RDTR, adapter->rx_int_delay);
2876 2942
2877 /* irq moderation */ 2943 /* irq moderation */
2878 ew32(RADV, adapter->rx_abs_int_delay); 2944 ew32(RADV, adapter->rx_abs_int_delay);
2879 if (adapter->itr_setting != 0) 2945 if ((adapter->itr_setting != 0) && (adapter->itr != 0))
2880 ew32(ITR, 1000000000 / (adapter->itr * 256)); 2946 ew32(ITR, 1000000000 / (adapter->itr * 256));
2881 2947
2882 ctrl_ext = er32(CTRL_EXT); 2948 ctrl_ext = er32(CTRL_EXT);
@@ -2921,22 +2987,22 @@ static void e1000_configure_rx(struct e1000_adapter *adapter)
2921 * packet size is equal or larger than the specified value (in 8 byte 2987 * packet size is equal or larger than the specified value (in 8 byte
2922 * units), e.g. using jumbo frames when setting to E1000_ERT_2048 2988 * units), e.g. using jumbo frames when setting to E1000_ERT_2048
2923 */ 2989 */
2924 if (adapter->flags & FLAG_HAS_ERT) { 2990 if ((adapter->flags & FLAG_HAS_ERT) ||
2991 (adapter->hw.mac.type == e1000_pch2lan)) {
2925 if (adapter->netdev->mtu > ETH_DATA_LEN) { 2992 if (adapter->netdev->mtu > ETH_DATA_LEN) {
2926 u32 rxdctl = er32(RXDCTL(0)); 2993 u32 rxdctl = er32(RXDCTL(0));
2927 ew32(RXDCTL(0), rxdctl | 0x3); 2994 ew32(RXDCTL(0), rxdctl | 0x3);
2928 ew32(ERT, E1000_ERT_2048 | (1 << 13)); 2995 if (adapter->flags & FLAG_HAS_ERT)
2996 ew32(ERT, E1000_ERT_2048 | (1 << 13));
2929 /* 2997 /*
2930 * With jumbo frames and early-receive enabled, 2998 * With jumbo frames and early-receive enabled,
2931 * excessive C-state transition latencies result in 2999 * excessive C-state transition latencies result in
2932 * dropped transactions. 3000 * dropped transactions.
2933 */ 3001 */
2934 pm_qos_update_request( 3002 pm_qos_update_request(&adapter->netdev->pm_qos_req, 55);
2935 &adapter->netdev->pm_qos_req, 55);
2936 } else { 3003 } else {
2937 pm_qos_update_request( 3004 pm_qos_update_request(&adapter->netdev->pm_qos_req,
2938 &adapter->netdev->pm_qos_req, 3005 PM_QOS_DEFAULT_VALUE);
2939 PM_QOS_DEFAULT_VALUE);
2940 } 3006 }
2941 } 3007 }
2942 3008
@@ -2975,7 +3041,6 @@ static void e1000_set_multi(struct net_device *netdev)
2975 struct netdev_hw_addr *ha; 3041 struct netdev_hw_addr *ha;
2976 u8 *mta_list; 3042 u8 *mta_list;
2977 u32 rctl; 3043 u32 rctl;
2978 int i;
2979 3044
2980 /* Check for Promiscuous and All Multicast modes */ 3045 /* Check for Promiscuous and All Multicast modes */
2981 3046
@@ -2984,6 +3049,8 @@ static void e1000_set_multi(struct net_device *netdev)
2984 if (netdev->flags & IFF_PROMISC) { 3049 if (netdev->flags & IFF_PROMISC) {
2985 rctl |= (E1000_RCTL_UPE | E1000_RCTL_MPE); 3050 rctl |= (E1000_RCTL_UPE | E1000_RCTL_MPE);
2986 rctl &= ~E1000_RCTL_VFE; 3051 rctl &= ~E1000_RCTL_VFE;
3052 /* Do not hardware filter VLANs in promisc mode */
3053 e1000e_vlan_filter_disable(adapter);
2987 } else { 3054 } else {
2988 if (netdev->flags & IFF_ALLMULTI) { 3055 if (netdev->flags & IFF_ALLMULTI) {
2989 rctl |= E1000_RCTL_MPE; 3056 rctl |= E1000_RCTL_MPE;
@@ -2991,19 +3058,19 @@ static void e1000_set_multi(struct net_device *netdev)
2991 } else { 3058 } else {
2992 rctl &= ~(E1000_RCTL_UPE | E1000_RCTL_MPE); 3059 rctl &= ~(E1000_RCTL_UPE | E1000_RCTL_MPE);
2993 } 3060 }
2994 if (adapter->flags & FLAG_HAS_HW_VLAN_FILTER) 3061 e1000e_vlan_filter_enable(adapter);
2995 rctl |= E1000_RCTL_VFE;
2996 } 3062 }
2997 3063
2998 ew32(RCTL, rctl); 3064 ew32(RCTL, rctl);
2999 3065
3000 if (!netdev_mc_empty(netdev)) { 3066 if (!netdev_mc_empty(netdev)) {
3067 int i = 0;
3068
3001 mta_list = kmalloc(netdev_mc_count(netdev) * 6, GFP_ATOMIC); 3069 mta_list = kmalloc(netdev_mc_count(netdev) * 6, GFP_ATOMIC);
3002 if (!mta_list) 3070 if (!mta_list)
3003 return; 3071 return;
3004 3072
3005 /* prepare a packed array of only addresses. */ 3073 /* prepare a packed array of only addresses. */
3006 i = 0;
3007 netdev_for_each_mc_addr(ha, netdev) 3074 netdev_for_each_mc_addr(ha, netdev)
3008 memcpy(mta_list + (i++ * ETH_ALEN), ha->addr, ETH_ALEN); 3075 memcpy(mta_list + (i++ * ETH_ALEN), ha->addr, ETH_ALEN);
3009 3076
@@ -3016,6 +3083,11 @@ static void e1000_set_multi(struct net_device *netdev)
3016 */ 3083 */
3017 e1000_update_mc_addr_list(hw, NULL, 0); 3084 e1000_update_mc_addr_list(hw, NULL, 0);
3018 } 3085 }
3086
3087 if (netdev->features & NETIF_F_HW_VLAN_RX)
3088 e1000e_vlan_strip_enable(adapter);
3089 else
3090 e1000e_vlan_strip_disable(adapter);
3019} 3091}
3020 3092
3021/** 3093/**
@@ -3102,7 +3174,7 @@ void e1000e_reset(struct e1000_adapter *adapter)
3102 /* lower 16 bits has Rx packet buffer allocation size in KB */ 3174 /* lower 16 bits has Rx packet buffer allocation size in KB */
3103 pba &= 0xffff; 3175 pba &= 0xffff;
3104 /* 3176 /*
3105 * the Tx fifo also stores 16 bytes of information about the tx 3177 * the Tx fifo also stores 16 bytes of information about the Tx
3106 * but don't include ethernet FCS because hardware appends it 3178 * but don't include ethernet FCS because hardware appends it
3107 */ 3179 */
3108 min_tx_space = (adapter->max_frame_size + 3180 min_tx_space = (adapter->max_frame_size +
@@ -3125,7 +3197,7 @@ void e1000e_reset(struct e1000_adapter *adapter)
3125 pba -= min_tx_space - tx_space; 3197 pba -= min_tx_space - tx_space;
3126 3198
3127 /* 3199 /*
3128 * if short on Rx space, Rx wins and must trump tx 3200 * if short on Rx space, Rx wins and must trump Tx
3129 * adjustment or use Early Receive if available 3201 * adjustment or use Early Receive if available
3130 */ 3202 */
3131 if ((pba < min_rx_space) && 3203 if ((pba < min_rx_space) &&
@@ -3137,7 +3209,6 @@ void e1000e_reset(struct e1000_adapter *adapter)
3137 ew32(PBA, pba); 3209 ew32(PBA, pba);
3138 } 3210 }
3139 3211
3140
3141 /* 3212 /*
3142 * flow control settings 3213 * flow control settings
3143 * 3214 *
@@ -3188,9 +3259,35 @@ void e1000e_reset(struct e1000_adapter *adapter)
3188 fc->low_water = 0x05048; 3259 fc->low_water = 0x05048;
3189 fc->pause_time = 0x0650; 3260 fc->pause_time = 0x0650;
3190 fc->refresh_time = 0x0400; 3261 fc->refresh_time = 0x0400;
3262 if (adapter->netdev->mtu > ETH_DATA_LEN) {
3263 pba = 14;
3264 ew32(PBA, pba);
3265 }
3191 break; 3266 break;
3192 } 3267 }
3193 3268
3269 /*
3270 * Disable Adaptive Interrupt Moderation if 2 full packets cannot
3271 * fit in receive buffer and early-receive not supported.
3272 */
3273 if (adapter->itr_setting & 0x3) {
3274 if (((adapter->max_frame_size * 2) > (pba << 10)) &&
3275 !(adapter->flags & FLAG_HAS_ERT)) {
3276 if (!(adapter->flags2 & FLAG2_DISABLE_AIM)) {
3277 dev_info(&adapter->pdev->dev,
3278 "Interrupt Throttle Rate turned off\n");
3279 adapter->flags2 |= FLAG2_DISABLE_AIM;
3280 ew32(ITR, 0);
3281 }
3282 } else if (adapter->flags2 & FLAG2_DISABLE_AIM) {
3283 dev_info(&adapter->pdev->dev,
3284 "Interrupt Throttle Rate turned on\n");
3285 adapter->flags2 &= ~FLAG2_DISABLE_AIM;
3286 adapter->itr = 20000;
3287 ew32(ITR, 1000000000 / (adapter->itr * 256));
3288 }
3289 }
3290
3194 /* Allow time for pending master requests to run */ 3291 /* Allow time for pending master requests to run */
3195 mac->ops.reset_hw(hw); 3292 mac->ops.reset_hw(hw);
3196 3293
@@ -3199,7 +3296,7 @@ void e1000e_reset(struct e1000_adapter *adapter)
3199 * that the network interface is in control 3296 * that the network interface is in control
3200 */ 3297 */
3201 if (adapter->flags & FLAG_HAS_AMT) 3298 if (adapter->flags & FLAG_HAS_AMT)
3202 e1000_get_hw_control(adapter); 3299 e1000e_get_hw_control(adapter);
3203 3300
3204 ew32(WUC, 0); 3301 ew32(WUC, 0);
3205 3302
@@ -3212,6 +3309,13 @@ void e1000e_reset(struct e1000_adapter *adapter)
3212 ew32(VET, ETH_P_8021Q); 3309 ew32(VET, ETH_P_8021Q);
3213 3310
3214 e1000e_reset_adaptive(hw); 3311 e1000e_reset_adaptive(hw);
3312
3313 if (!netif_running(adapter->netdev) &&
3314 !test_bit(__E1000_TESTING, &adapter->state)) {
3315 e1000_power_down_phy(adapter);
3316 return;
3317 }
3318
3215 e1000_get_phy_info(hw); 3319 e1000_get_phy_info(hw);
3216 3320
3217 if ((adapter->flags & FLAG_HAS_SMART_POWER_DOWN) && 3321 if ((adapter->flags & FLAG_HAS_SMART_POWER_DOWN) &&
@@ -3253,6 +3357,23 @@ int e1000e_up(struct e1000_adapter *adapter)
3253 return 0; 3357 return 0;
3254} 3358}
3255 3359
3360static void e1000e_flush_descriptors(struct e1000_adapter *adapter)
3361{
3362 struct e1000_hw *hw = &adapter->hw;
3363
3364 if (!(adapter->flags2 & FLAG2_DMA_BURST))
3365 return;
3366
3367 /* flush pending descriptor writebacks to memory */
3368 ew32(TIDV, adapter->tx_int_delay | E1000_TIDV_FPD);
3369 ew32(RDTR, adapter->rx_int_delay | E1000_RDTR_FPD);
3370
3371 /* execute the writes immediately */
3372 e1e_flush();
3373}
3374
3375static void e1000e_update_stats(struct e1000_adapter *adapter);
3376
3256void e1000e_down(struct e1000_adapter *adapter) 3377void e1000e_down(struct e1000_adapter *adapter)
3257{ 3378{
3258 struct net_device *netdev = adapter->netdev; 3379 struct net_device *netdev = adapter->netdev;
@@ -3278,7 +3399,7 @@ void e1000e_down(struct e1000_adapter *adapter)
3278 ew32(TCTL, tctl); 3399 ew32(TCTL, tctl);
3279 /* flush both disables and wait for them to finish */ 3400 /* flush both disables and wait for them to finish */
3280 e1e_flush(); 3401 e1e_flush();
3281 msleep(10); 3402 usleep_range(10000, 20000);
3282 3403
3283 napi_disable(&adapter->napi); 3404 napi_disable(&adapter->napi);
3284 e1000_irq_disable(adapter); 3405 e1000_irq_disable(adapter);
@@ -3287,11 +3408,19 @@ void e1000e_down(struct e1000_adapter *adapter)
3287 del_timer_sync(&adapter->phy_info_timer); 3408 del_timer_sync(&adapter->phy_info_timer);
3288 3409
3289 netif_carrier_off(netdev); 3410 netif_carrier_off(netdev);
3411
3412 spin_lock(&adapter->stats64_lock);
3413 e1000e_update_stats(adapter);
3414 spin_unlock(&adapter->stats64_lock);
3415
3290 adapter->link_speed = 0; 3416 adapter->link_speed = 0;
3291 adapter->link_duplex = 0; 3417 adapter->link_duplex = 0;
3292 3418
3293 if (!pci_channel_offline(adapter->pdev)) 3419 if (!pci_channel_offline(adapter->pdev))
3294 e1000e_reset(adapter); 3420 e1000e_reset(adapter);
3421
3422 e1000e_flush_descriptors(adapter);
3423
3295 e1000_clean_tx_ring(adapter); 3424 e1000_clean_tx_ring(adapter);
3296 e1000_clean_rx_ring(adapter); 3425 e1000_clean_rx_ring(adapter);
3297 3426
@@ -3305,7 +3434,7 @@ void e1000e_reinit_locked(struct e1000_adapter *adapter)
3305{ 3434{
3306 might_sleep(); 3435 might_sleep();
3307 while (test_and_set_bit(__E1000_RESETTING, &adapter->state)) 3436 while (test_and_set_bit(__E1000_RESETTING, &adapter->state))
3308 msleep(1); 3437 usleep_range(1000, 2000);
3309 e1000e_down(adapter); 3438 e1000e_down(adapter);
3310 e1000e_up(adapter); 3439 e1000e_up(adapter);
3311 clear_bit(__E1000_RESETTING, &adapter->state); 3440 clear_bit(__E1000_RESETTING, &adapter->state);
@@ -3328,6 +3457,8 @@ static int __devinit e1000_sw_init(struct e1000_adapter *adapter)
3328 adapter->max_frame_size = netdev->mtu + ETH_HLEN + ETH_FCS_LEN; 3457 adapter->max_frame_size = netdev->mtu + ETH_HLEN + ETH_FCS_LEN;
3329 adapter->min_frame_size = ETH_ZLEN + ETH_FCS_LEN; 3458 adapter->min_frame_size = ETH_ZLEN + ETH_FCS_LEN;
3330 3459
3460 spin_lock_init(&adapter->stats64_lock);
3461
3331 e1000e_set_interrupt_capability(adapter); 3462 e1000e_set_interrupt_capability(adapter);
3332 3463
3333 if (e1000_alloc_queues(adapter)) 3464 if (e1000_alloc_queues(adapter))
@@ -3411,22 +3542,16 @@ static int e1000_test_msi_interrupt(struct e1000_adapter *adapter)
3411 3542
3412 if (adapter->flags & FLAG_MSI_TEST_FAILED) { 3543 if (adapter->flags & FLAG_MSI_TEST_FAILED) {
3413 adapter->int_mode = E1000E_INT_MODE_LEGACY; 3544 adapter->int_mode = E1000E_INT_MODE_LEGACY;
3414 err = -EIO; 3545 e_info("MSI interrupt test failed, using legacy interrupt.\n");
3415 e_info("MSI interrupt test failed!\n"); 3546 } else
3416 } 3547 e_dbg("MSI interrupt test succeeded!\n");
3417 3548
3418 free_irq(adapter->pdev->irq, netdev); 3549 free_irq(adapter->pdev->irq, netdev);
3419 pci_disable_msi(adapter->pdev); 3550 pci_disable_msi(adapter->pdev);
3420 3551
3421 if (err == -EIO)
3422 goto msi_test_failed;
3423
3424 /* okay so the test worked, restore settings */
3425 e_dbg("MSI interrupt test succeeded!\n");
3426msi_test_failed: 3552msi_test_failed:
3427 e1000e_set_interrupt_capability(adapter); 3553 e1000e_set_interrupt_capability(adapter);
3428 e1000_request_irq(adapter); 3554 return e1000_request_irq(adapter);
3429 return err;
3430} 3555}
3431 3556
3432/** 3557/**
@@ -3458,21 +3583,6 @@ static int e1000_test_msi(struct e1000_adapter *adapter)
3458 pci_write_config_word(adapter->pdev, PCI_COMMAND, pci_cmd); 3583 pci_write_config_word(adapter->pdev, PCI_COMMAND, pci_cmd);
3459 } 3584 }
3460 3585
3461 /* success ! */
3462 if (!err)
3463 return 0;
3464
3465 /* EIO means MSI test failed */
3466 if (err != -EIO)
3467 return err;
3468
3469 /* back to INTx mode */
3470 e_warn("MSI interrupt test failed, using legacy interrupt.\n");
3471
3472 e1000_free_irq(adapter);
3473
3474 err = e1000_request_irq(adapter);
3475
3476 return err; 3586 return err;
3477} 3587}
3478 3588
@@ -3518,7 +3628,7 @@ static int e1000_open(struct net_device *netdev)
3518 * interface is now open and reset the part to a known state. 3628 * interface is now open and reset the part to a known state.
3519 */ 3629 */
3520 if (adapter->flags & FLAG_HAS_AMT) { 3630 if (adapter->flags & FLAG_HAS_AMT) {
3521 e1000_get_hw_control(adapter); 3631 e1000e_get_hw_control(adapter);
3522 e1000e_reset(adapter); 3632 e1000e_reset(adapter);
3523 } 3633 }
3524 3634
@@ -3530,7 +3640,8 @@ static int e1000_open(struct net_device *netdev)
3530 e1000_update_mng_vlan(adapter); 3640 e1000_update_mng_vlan(adapter);
3531 3641
3532 /* DMA latency requirement to workaround early-receive/jumbo issue */ 3642 /* DMA latency requirement to workaround early-receive/jumbo issue */
3533 if (adapter->flags & FLAG_HAS_ERT) 3643 if ((adapter->flags & FLAG_HAS_ERT) ||
3644 (adapter->hw.mac.type == e1000_pch2lan))
3534 pm_qos_add_request(&adapter->netdev->pm_qos_req, 3645 pm_qos_add_request(&adapter->netdev->pm_qos_req,
3535 PM_QOS_CPU_DMA_LATENCY, 3646 PM_QOS_CPU_DMA_LATENCY,
3536 PM_QOS_DEFAULT_VALUE); 3647 PM_QOS_DEFAULT_VALUE);
@@ -3581,7 +3692,7 @@ static int e1000_open(struct net_device *netdev)
3581 return 0; 3692 return 0;
3582 3693
3583err_req_irq: 3694err_req_irq:
3584 e1000_release_hw_control(adapter); 3695 e1000e_release_hw_control(adapter);
3585 e1000_power_down_phy(adapter); 3696 e1000_power_down_phy(adapter);
3586 e1000e_free_rx_resources(adapter); 3697 e1000e_free_rx_resources(adapter);
3587err_setup_rx: 3698err_setup_rx:
@@ -3626,20 +3737,20 @@ static int e1000_close(struct net_device *netdev)
3626 * kill manageability vlan ID if supported, but not if a vlan with 3737 * kill manageability vlan ID if supported, but not if a vlan with
3627 * the same ID is registered on the host OS (let 8021q kill it) 3738 * the same ID is registered on the host OS (let 8021q kill it)
3628 */ 3739 */
3629 if ((adapter->hw.mng_cookie.status & 3740 if (adapter->hw.mng_cookie.status &
3630 E1000_MNG_DHCP_COOKIE_STATUS_VLAN) && 3741 E1000_MNG_DHCP_COOKIE_STATUS_VLAN)
3631 !(adapter->vlgrp &&
3632 vlan_group_get_device(adapter->vlgrp, adapter->mng_vlan_id)))
3633 e1000_vlan_rx_kill_vid(netdev, adapter->mng_vlan_id); 3742 e1000_vlan_rx_kill_vid(netdev, adapter->mng_vlan_id);
3634 3743
3635 /* 3744 /*
3636 * If AMT is enabled, let the firmware know that the network 3745 * If AMT is enabled, let the firmware know that the network
3637 * interface is now closed 3746 * interface is now closed
3638 */ 3747 */
3639 if (adapter->flags & FLAG_HAS_AMT) 3748 if ((adapter->flags & FLAG_HAS_AMT) &&
3640 e1000_release_hw_control(adapter); 3749 !test_bit(__E1000_TESTING, &adapter->state))
3750 e1000e_release_hw_control(adapter);
3641 3751
3642 if (adapter->flags & FLAG_HAS_ERT) 3752 if ((adapter->flags & FLAG_HAS_ERT) ||
3753 (adapter->hw.mac.type == e1000_pch2lan))
3643 pm_qos_remove_request(&adapter->netdev->pm_qos_req); 3754 pm_qos_remove_request(&adapter->netdev->pm_qos_req);
3644 3755
3645 pm_runtime_put_sync(&pdev->dev); 3756 pm_runtime_put_sync(&pdev->dev);
@@ -3698,6 +3809,10 @@ static void e1000e_update_phy_task(struct work_struct *work)
3698{ 3809{
3699 struct e1000_adapter *adapter = container_of(work, 3810 struct e1000_adapter *adapter = container_of(work,
3700 struct e1000_adapter, update_phy_task); 3811 struct e1000_adapter, update_phy_task);
3812
3813 if (test_bit(__E1000_DOWN, &adapter->state))
3814 return;
3815
3701 e1000_get_phy_info(&adapter->hw); 3816 e1000_get_phy_info(&adapter->hw);
3702} 3817}
3703 3818
@@ -3708,6 +3823,10 @@ static void e1000e_update_phy_task(struct work_struct *work)
3708static void e1000_update_phy_info(unsigned long data) 3823static void e1000_update_phy_info(unsigned long data)
3709{ 3824{
3710 struct e1000_adapter *adapter = (struct e1000_adapter *) data; 3825 struct e1000_adapter *adapter = (struct e1000_adapter *) data;
3826
3827 if (test_bit(__E1000_DOWN, &adapter->state))
3828 return;
3829
3711 schedule_work(&adapter->update_phy_task); 3830 schedule_work(&adapter->update_phy_task);
3712} 3831}
3713 3832
@@ -3819,7 +3938,7 @@ release:
3819 * e1000e_update_stats - Update the board statistics counters 3938 * e1000e_update_stats - Update the board statistics counters
3820 * @adapter: board private structure 3939 * @adapter: board private structure
3821 **/ 3940 **/
3822void e1000e_update_stats(struct e1000_adapter *adapter) 3941static void e1000e_update_stats(struct e1000_adapter *adapter)
3823{ 3942{
3824 struct net_device *netdev = adapter->netdev; 3943 struct net_device *netdev = adapter->netdev;
3825 struct e1000_hw *hw = &adapter->hw; 3944 struct e1000_hw *hw = &adapter->hw;
@@ -3931,10 +4050,11 @@ static void e1000_phy_read_status(struct e1000_adapter *adapter)
3931{ 4050{
3932 struct e1000_hw *hw = &adapter->hw; 4051 struct e1000_hw *hw = &adapter->hw;
3933 struct e1000_phy_regs *phy = &adapter->phy_regs; 4052 struct e1000_phy_regs *phy = &adapter->phy_regs;
3934 int ret_val;
3935 4053
3936 if ((er32(STATUS) & E1000_STATUS_LU) && 4054 if ((er32(STATUS) & E1000_STATUS_LU) &&
3937 (adapter->hw.phy.media_type == e1000_media_type_copper)) { 4055 (adapter->hw.phy.media_type == e1000_media_type_copper)) {
4056 int ret_val;
4057
3938 ret_val = e1e_rphy(hw, PHY_CONTROL, &phy->bmcr); 4058 ret_val = e1e_rphy(hw, PHY_CONTROL, &phy->bmcr);
3939 ret_val |= e1e_rphy(hw, PHY_STATUS, &phy->bmsr); 4059 ret_val |= e1e_rphy(hw, PHY_STATUS, &phy->bmsr);
3940 ret_val |= e1e_rphy(hw, PHY_AUTONEG_ADV, &phy->advertise); 4060 ret_val |= e1e_rphy(hw, PHY_AUTONEG_ADV, &phy->advertise);
@@ -3975,11 +4095,11 @@ static void e1000_print_link_info(struct e1000_adapter *adapter)
3975 adapter->netdev->name, 4095 adapter->netdev->name,
3976 adapter->link_speed, 4096 adapter->link_speed,
3977 (adapter->link_duplex == FULL_DUPLEX) ? 4097 (adapter->link_duplex == FULL_DUPLEX) ?
3978 "Full Duplex" : "Half Duplex", 4098 "Full Duplex" : "Half Duplex",
3979 ((ctrl & E1000_CTRL_TFCE) && (ctrl & E1000_CTRL_RFCE)) ? 4099 ((ctrl & E1000_CTRL_TFCE) && (ctrl & E1000_CTRL_RFCE)) ?
3980 "RX/TX" : 4100 "Rx/Tx" :
3981 ((ctrl & E1000_CTRL_RFCE) ? "RX" : 4101 ((ctrl & E1000_CTRL_RFCE) ? "Rx" :
3982 ((ctrl & E1000_CTRL_TFCE) ? "TX" : "None" ))); 4102 ((ctrl & E1000_CTRL_TFCE) ? "Tx" : "None")));
3983} 4103}
3984 4104
3985static bool e1000e_has_link(struct e1000_adapter *adapter) 4105static bool e1000e_has_link(struct e1000_adapter *adapter)
@@ -4037,6 +4157,25 @@ static void e1000e_enable_receives(struct e1000_adapter *adapter)
4037 } 4157 }
4038} 4158}
4039 4159
4160static void e1000e_check_82574_phy_workaround(struct e1000_adapter *adapter)
4161{
4162 struct e1000_hw *hw = &adapter->hw;
4163
4164 /*
4165 * With 82574 controllers, PHY needs to be checked periodically
4166 * for hung state and reset, if two calls return true
4167 */
4168 if (e1000_check_phy_82574(hw))
4169 adapter->phy_hang_count++;
4170 else
4171 adapter->phy_hang_count = 0;
4172
4173 if (adapter->phy_hang_count > 1) {
4174 adapter->phy_hang_count = 0;
4175 schedule_work(&adapter->reset_task);
4176 }
4177}
4178
4040/** 4179/**
4041 * e1000_watchdog - Timer Call-back 4180 * e1000_watchdog - Timer Call-back
4042 * @data: pointer to adapter cast into an unsigned long 4181 * @data: pointer to adapter cast into an unsigned long
@@ -4061,7 +4200,9 @@ static void e1000_watchdog_task(struct work_struct *work)
4061 struct e1000_ring *tx_ring = adapter->tx_ring; 4200 struct e1000_ring *tx_ring = adapter->tx_ring;
4062 struct e1000_hw *hw = &adapter->hw; 4201 struct e1000_hw *hw = &adapter->hw;
4063 u32 link, tctl; 4202 u32 link, tctl;
4064 int tx_pending = 0; 4203
4204 if (test_bit(__E1000_DOWN, &adapter->state))
4205 return;
4065 4206
4066 link = e1000e_has_link(adapter); 4207 link = e1000e_has_link(adapter);
4067 if ((netif_carrier_ok(netdev)) && link) { 4208 if ((netif_carrier_ok(netdev)) && link) {
@@ -4199,6 +4340,7 @@ static void e1000_watchdog_task(struct work_struct *work)
4199 } 4340 }
4200 4341
4201link_up: 4342link_up:
4343 spin_lock(&adapter->stats64_lock);
4202 e1000e_update_stats(adapter); 4344 e1000e_update_stats(adapter);
4203 4345
4204 mac->tx_packet_delta = adapter->stats.tpt - adapter->tpt_old; 4346 mac->tx_packet_delta = adapter->stats.tpt - adapter->tpt_old;
@@ -4210,24 +4352,21 @@ link_up:
4210 adapter->gorc_old = adapter->stats.gorc; 4352 adapter->gorc_old = adapter->stats.gorc;
4211 adapter->gotc = adapter->stats.gotc - adapter->gotc_old; 4353 adapter->gotc = adapter->stats.gotc - adapter->gotc_old;
4212 adapter->gotc_old = adapter->stats.gotc; 4354 adapter->gotc_old = adapter->stats.gotc;
4355 spin_unlock(&adapter->stats64_lock);
4213 4356
4214 e1000e_update_adaptive(&adapter->hw); 4357 e1000e_update_adaptive(&adapter->hw);
4215 4358
4216 if (!netif_carrier_ok(netdev)) { 4359 if (!netif_carrier_ok(netdev) &&
4217 tx_pending = (e1000_desc_unused(tx_ring) + 1 < 4360 (e1000_desc_unused(tx_ring) + 1 < tx_ring->count)) {
4218 tx_ring->count); 4361 /*
4219 if (tx_pending) { 4362 * We've lost link, so the controller stops DMA,
4220 /* 4363 * but we've got queued Tx work that's never going
4221 * We've lost link, so the controller stops DMA, 4364 * to get done, so reset controller to flush Tx.
4222 * but we've got queued Tx work that's never going 4365 * (Do the reset outside of interrupt context).
4223 * to get done, so reset controller to flush Tx. 4366 */
4224 * (Do the reset outside of interrupt context). 4367 schedule_work(&adapter->reset_task);
4225 */ 4368 /* return immediately since reset is imminent */
4226 adapter->tx_timeout_count++; 4369 return;
4227 schedule_work(&adapter->reset_task);
4228 /* return immediately since reset is imminent */
4229 return;
4230 }
4231 } 4370 }
4232 4371
4233 /* Simple mode for Interrupt Throttle Rate (ITR) */ 4372 /* Simple mode for Interrupt Throttle Rate (ITR) */
@@ -4252,6 +4391,9 @@ link_up:
4252 else 4391 else
4253 ew32(ICS, E1000_ICS_RXDMT0); 4392 ew32(ICS, E1000_ICS_RXDMT0);
4254 4393
4394 /* flush pending descriptors to memory before detecting Tx hang */
4395 e1000e_flush_descriptors(adapter);
4396
4255 /* Force detection of hung controller every watchdog period */ 4397 /* Force detection of hung controller every watchdog period */
4256 adapter->detect_tx_hung = 1; 4398 adapter->detect_tx_hung = 1;
4257 4399
@@ -4262,6 +4404,9 @@ link_up:
4262 if (e1000e_get_laa_state_82571(hw)) 4404 if (e1000e_get_laa_state_82571(hw))
4263 e1000e_rar_set(hw, adapter->hw.mac.addr, 0); 4405 e1000e_rar_set(hw, adapter->hw.mac.addr, 0);
4264 4406
4407 if (adapter->flags2 & FLAG2_CHECK_PHY_HANG)
4408 e1000e_check_82574_phy_workaround(adapter);
4409
4265 /* Reset the timer */ 4410 /* Reset the timer */
4266 if (!test_bit(__E1000_DOWN, &adapter->state)) 4411 if (!test_bit(__E1000_DOWN, &adapter->state))
4267 mod_timer(&adapter->watchdog_timer, 4412 mod_timer(&adapter->watchdog_timer,
@@ -4285,13 +4430,13 @@ static int e1000_tso(struct e1000_adapter *adapter,
4285 u32 cmd_length = 0; 4430 u32 cmd_length = 0;
4286 u16 ipcse = 0, tucse, mss; 4431 u16 ipcse = 0, tucse, mss;
4287 u8 ipcss, ipcso, tucss, tucso, hdr_len; 4432 u8 ipcss, ipcso, tucss, tucso, hdr_len;
4288 int err;
4289 4433
4290 if (!skb_is_gso(skb)) 4434 if (!skb_is_gso(skb))
4291 return 0; 4435 return 0;
4292 4436
4293 if (skb_header_cloned(skb)) { 4437 if (skb_header_cloned(skb)) {
4294 err = pskb_expand_head(skb, 0, 0, GFP_ATOMIC); 4438 int err = pskb_expand_head(skb, 0, 0, GFP_ATOMIC);
4439
4295 if (err) 4440 if (err)
4296 return err; 4441 return err;
4297 } 4442 }
@@ -4382,7 +4527,7 @@ static bool e1000_tx_csum(struct e1000_adapter *adapter, struct sk_buff *skb)
4382 break; 4527 break;
4383 } 4528 }
4384 4529
4385 css = skb_transport_offset(skb); 4530 css = skb_checksum_start_offset(skb);
4386 4531
4387 i = tx_ring->next_to_use; 4532 i = tx_ring->next_to_use;
4388 buffer_info = &tx_ring->buffer_info[i]; 4533 buffer_info = &tx_ring->buffer_info[i];
@@ -4433,7 +4578,7 @@ static int e1000_tx_map(struct e1000_adapter *adapter,
4433 buffer_info->next_to_watch = i; 4578 buffer_info->next_to_watch = i;
4434 buffer_info->dma = dma_map_single(&pdev->dev, 4579 buffer_info->dma = dma_map_single(&pdev->dev,
4435 skb->data + offset, 4580 skb->data + offset,
4436 size, DMA_TO_DEVICE); 4581 size, DMA_TO_DEVICE);
4437 buffer_info->mapped_as_page = false; 4582 buffer_info->mapped_as_page = false;
4438 if (dma_mapping_error(&pdev->dev, buffer_info->dma)) 4583 if (dma_mapping_error(&pdev->dev, buffer_info->dma))
4439 goto dma_error; 4584 goto dma_error;
@@ -4480,7 +4625,7 @@ static int e1000_tx_map(struct e1000_adapter *adapter,
4480 } 4625 }
4481 } 4626 }
4482 4627
4483 segs = skb_shinfo(skb)->gso_segs ?: 1; 4628 segs = skb_shinfo(skb)->gso_segs ? : 1;
4484 /* multiply data chunks by size of headers */ 4629 /* multiply data chunks by size of headers */
4485 bytecount = ((segs - 1) * skb_headlen(skb)) + skb->len; 4630 bytecount = ((segs - 1) * skb_headlen(skb)) + skb->len;
4486 4631
@@ -4492,17 +4637,17 @@ static int e1000_tx_map(struct e1000_adapter *adapter,
4492 return count; 4637 return count;
4493 4638
4494dma_error: 4639dma_error:
4495 dev_err(&pdev->dev, "TX DMA map failed\n"); 4640 dev_err(&pdev->dev, "Tx DMA map failed\n");
4496 buffer_info->dma = 0; 4641 buffer_info->dma = 0;
4497 if (count) 4642 if (count)
4498 count--; 4643 count--;
4499 4644
4500 while (count--) { 4645 while (count--) {
4501 if (i==0) 4646 if (i == 0)
4502 i += tx_ring->count; 4647 i += tx_ring->count;
4503 i--; 4648 i--;
4504 buffer_info = &tx_ring->buffer_info[i]; 4649 buffer_info = &tx_ring->buffer_info[i];
4505 e1000_put_txbuf(adapter, buffer_info);; 4650 e1000_put_txbuf(adapter, buffer_info);
4506 } 4651 }
4507 4652
4508 return 0; 4653 return 0;
@@ -4538,7 +4683,7 @@ static void e1000_tx_queue(struct e1000_adapter *adapter,
4538 4683
4539 i = tx_ring->next_to_use; 4684 i = tx_ring->next_to_use;
4540 4685
4541 while (count--) { 4686 do {
4542 buffer_info = &tx_ring->buffer_info[i]; 4687 buffer_info = &tx_ring->buffer_info[i];
4543 tx_desc = E1000_TX_DESC(*tx_ring, i); 4688 tx_desc = E1000_TX_DESC(*tx_ring, i);
4544 tx_desc->buffer_addr = cpu_to_le64(buffer_info->dma); 4689 tx_desc->buffer_addr = cpu_to_le64(buffer_info->dma);
@@ -4549,7 +4694,7 @@ static void e1000_tx_queue(struct e1000_adapter *adapter,
4549 i++; 4694 i++;
4550 if (i == tx_ring->count) 4695 if (i == tx_ring->count)
4551 i = 0; 4696 i = 0;
4552 } 4697 } while (--count > 0);
4553 4698
4554 tx_desc->lower.data |= cpu_to_le32(adapter->txd_cmd); 4699 tx_desc->lower.data |= cpu_to_le32(adapter->txd_cmd);
4555 4700
@@ -4729,7 +4874,7 @@ static netdev_tx_t e1000_xmit_frame(struct sk_buff *skb,
4729 if (e1000_maybe_stop_tx(netdev, count + 2)) 4874 if (e1000_maybe_stop_tx(netdev, count + 2))
4730 return NETDEV_TX_BUSY; 4875 return NETDEV_TX_BUSY;
4731 4876
4732 if (adapter->vlgrp && vlan_tx_tag_present(skb)) { 4877 if (vlan_tx_tag_present(skb)) {
4733 tx_flags |= E1000_TX_FLAGS_VLAN; 4878 tx_flags |= E1000_TX_FLAGS_VLAN;
4734 tx_flags |= (vlan_tx_tag_get(skb) << E1000_TX_FLAGS_VLAN_SHIFT); 4879 tx_flags |= (vlan_tx_tag_get(skb) << E1000_TX_FLAGS_VLAN_SHIFT);
4735 } 4880 }
@@ -4755,7 +4900,7 @@ static netdev_tx_t e1000_xmit_frame(struct sk_buff *skb,
4755 if (skb->protocol == htons(ETH_P_IP)) 4900 if (skb->protocol == htons(ETH_P_IP))
4756 tx_flags |= E1000_TX_FLAGS_IPV4; 4901 tx_flags |= E1000_TX_FLAGS_IPV4;
4757 4902
4758 /* if count is 0 then mapping error has occured */ 4903 /* if count is 0 then mapping error has occurred */
4759 count = e1000_tx_map(adapter, skb, first, max_per_txd, nr_frags, mss); 4904 count = e1000_tx_map(adapter, skb, first, max_per_txd, nr_frags, mss);
4760 if (count) { 4905 if (count) {
4761 e1000_tx_queue(adapter, tx_flags, count); 4906 e1000_tx_queue(adapter, tx_flags, count);
@@ -4789,22 +4934,68 @@ static void e1000_reset_task(struct work_struct *work)
4789 struct e1000_adapter *adapter; 4934 struct e1000_adapter *adapter;
4790 adapter = container_of(work, struct e1000_adapter, reset_task); 4935 adapter = container_of(work, struct e1000_adapter, reset_task);
4791 4936
4792 e1000e_dump(adapter); 4937 /* don't run the task if already down */
4793 e_err("Reset adapter\n"); 4938 if (test_bit(__E1000_DOWN, &adapter->state))
4939 return;
4940
4941 if (!((adapter->flags & FLAG_RX_NEEDS_RESTART) &&
4942 (adapter->flags & FLAG_RX_RESTART_NOW))) {
4943 e1000e_dump(adapter);
4944 e_err("Reset adapter\n");
4945 }
4794 e1000e_reinit_locked(adapter); 4946 e1000e_reinit_locked(adapter);
4795} 4947}
4796 4948
4797/** 4949/**
4798 * e1000_get_stats - Get System Network Statistics 4950 * e1000_get_stats64 - Get System Network Statistics
4799 * @netdev: network interface device structure 4951 * @netdev: network interface device structure
4952 * @stats: rtnl_link_stats64 pointer
4800 * 4953 *
4801 * Returns the address of the device statistics structure. 4954 * Returns the address of the device statistics structure.
4802 * The statistics are actually updated from the timer callback.
4803 **/ 4955 **/
4804static struct net_device_stats *e1000_get_stats(struct net_device *netdev) 4956struct rtnl_link_stats64 *e1000e_get_stats64(struct net_device *netdev,
4957 struct rtnl_link_stats64 *stats)
4805{ 4958{
4806 /* only return the current stats */ 4959 struct e1000_adapter *adapter = netdev_priv(netdev);
4807 return &netdev->stats; 4960
4961 memset(stats, 0, sizeof(struct rtnl_link_stats64));
4962 spin_lock(&adapter->stats64_lock);
4963 e1000e_update_stats(adapter);
4964 /* Fill out the OS statistics structure */
4965 stats->rx_bytes = adapter->stats.gorc;
4966 stats->rx_packets = adapter->stats.gprc;
4967 stats->tx_bytes = adapter->stats.gotc;
4968 stats->tx_packets = adapter->stats.gptc;
4969 stats->multicast = adapter->stats.mprc;
4970 stats->collisions = adapter->stats.colc;
4971
4972 /* Rx Errors */
4973
4974 /*
4975 * RLEC on some newer hardware can be incorrect so build
4976 * our own version based on RUC and ROC
4977 */
4978 stats->rx_errors = adapter->stats.rxerrc +
4979 adapter->stats.crcerrs + adapter->stats.algnerrc +
4980 adapter->stats.ruc + adapter->stats.roc +
4981 adapter->stats.cexterr;
4982 stats->rx_length_errors = adapter->stats.ruc +
4983 adapter->stats.roc;
4984 stats->rx_crc_errors = adapter->stats.crcerrs;
4985 stats->rx_frame_errors = adapter->stats.algnerrc;
4986 stats->rx_missed_errors = adapter->stats.mpc;
4987
4988 /* Tx Errors */
4989 stats->tx_errors = adapter->stats.ecol +
4990 adapter->stats.latecol;
4991 stats->tx_aborted_errors = adapter->stats.ecol;
4992 stats->tx_window_errors = adapter->stats.latecol;
4993 stats->tx_carrier_errors = adapter->stats.tncrs;
4994
4995 /* Tx Dropped needs to be maintained elsewhere */
4996
4997 spin_unlock(&adapter->stats64_lock);
4998 return stats;
4808} 4999}
4809 5000
4810/** 5001/**
@@ -4851,7 +5042,7 @@ static int e1000_change_mtu(struct net_device *netdev, int new_mtu)
4851 } 5042 }
4852 5043
4853 while (test_and_set_bit(__E1000_RESETTING, &adapter->state)) 5044 while (test_and_set_bit(__E1000_RESETTING, &adapter->state))
4854 msleep(1); 5045 usleep_range(1000, 2000);
4855 /* e1000e_down -> e1000e_reset dependent on max_frame_size & mtu */ 5046 /* e1000e_down -> e1000e_reset dependent on max_frame_size & mtu */
4856 adapter->max_frame_size = max_frame; 5047 adapter->max_frame_size = max_frame;
4857 e_info("changing MTU from %d to %d\n", netdev->mtu, new_mtu); 5048 e_info("changing MTU from %d to %d\n", netdev->mtu, new_mtu);
@@ -5120,7 +5311,7 @@ static int __e1000_shutdown(struct pci_dev *pdev, bool *enable_wake,
5120 * Release control of h/w to f/w. If f/w is AMT enabled, this 5311 * Release control of h/w to f/w. If f/w is AMT enabled, this
5121 * would have already happened in close and is redundant. 5312 * would have already happened in close and is redundant.
5122 */ 5313 */
5123 e1000_release_hw_control(adapter); 5314 e1000e_release_hw_control(adapter);
5124 5315
5125 pci_disable_device(pdev); 5316 pci_disable_device(pdev);
5126 5317
@@ -5170,7 +5361,7 @@ static void e1000_complete_shutdown(struct pci_dev *pdev, bool sleep,
5170#ifdef CONFIG_PCIEASPM 5361#ifdef CONFIG_PCIEASPM
5171static void __e1000e_disable_aspm(struct pci_dev *pdev, u16 state) 5362static void __e1000e_disable_aspm(struct pci_dev *pdev, u16 state)
5172{ 5363{
5173 pci_disable_link_state(pdev, state); 5364 pci_disable_link_state_locked(pdev, state);
5174} 5365}
5175#else 5366#else
5176static void __e1000e_disable_aspm(struct pci_dev *pdev, u16 state) 5367static void __e1000e_disable_aspm(struct pci_dev *pdev, u16 state)
@@ -5196,7 +5387,7 @@ static void __e1000e_disable_aspm(struct pci_dev *pdev, u16 state)
5196 pci_write_config_word(pdev->bus->self, pos + PCI_EXP_LNKCTL, reg16); 5387 pci_write_config_word(pdev->bus->self, pos + PCI_EXP_LNKCTL, reg16);
5197} 5388}
5198#endif 5389#endif
5199void e1000e_disable_aspm(struct pci_dev *pdev, u16 state) 5390static void e1000e_disable_aspm(struct pci_dev *pdev, u16 state)
5200{ 5391{
5201 dev_info(&pdev->dev, "Disabling ASPM %s %s\n", 5392 dev_info(&pdev->dev, "Disabling ASPM %s %s\n",
5202 (state & PCIE_LINK_STATE_L0S) ? "L0s" : "", 5393 (state & PCIE_LINK_STATE_L0S) ? "L0s" : "",
@@ -5205,7 +5396,7 @@ void e1000e_disable_aspm(struct pci_dev *pdev, u16 state)
5205 __e1000e_disable_aspm(pdev, state); 5396 __e1000e_disable_aspm(pdev, state);
5206} 5397}
5207 5398
5208#ifdef CONFIG_PM_OPS 5399#ifdef CONFIG_PM
5209static bool e1000e_pm_ready(struct e1000_adapter *adapter) 5400static bool e1000e_pm_ready(struct e1000_adapter *adapter)
5210{ 5401{
5211 return !!adapter->tx_ring->buffer_info; 5402 return !!adapter->tx_ring->buffer_info;
@@ -5216,13 +5407,19 @@ static int __e1000_resume(struct pci_dev *pdev)
5216 struct net_device *netdev = pci_get_drvdata(pdev); 5407 struct net_device *netdev = pci_get_drvdata(pdev);
5217 struct e1000_adapter *adapter = netdev_priv(netdev); 5408 struct e1000_adapter *adapter = netdev_priv(netdev);
5218 struct e1000_hw *hw = &adapter->hw; 5409 struct e1000_hw *hw = &adapter->hw;
5410 u16 aspm_disable_flag = 0;
5219 u32 err; 5411 u32 err;
5220 5412
5413 if (adapter->flags2 & FLAG2_DISABLE_ASPM_L0S)
5414 aspm_disable_flag = PCIE_LINK_STATE_L0S;
5415 if (adapter->flags2 & FLAG2_DISABLE_ASPM_L1)
5416 aspm_disable_flag |= PCIE_LINK_STATE_L1;
5417 if (aspm_disable_flag)
5418 e1000e_disable_aspm(pdev, aspm_disable_flag);
5419
5221 pci_set_power_state(pdev, PCI_D0); 5420 pci_set_power_state(pdev, PCI_D0);
5222 pci_restore_state(pdev); 5421 pci_restore_state(pdev);
5223 pci_save_state(pdev); 5422 pci_save_state(pdev);
5224 if (adapter->flags2 & FLAG2_DISABLE_ASPM_L1)
5225 e1000e_disable_aspm(pdev, PCIE_LINK_STATE_L1);
5226 5423
5227 e1000e_set_interrupt_capability(adapter); 5424 e1000e_set_interrupt_capability(adapter);
5228 if (netif_running(netdev)) { 5425 if (netif_running(netdev)) {
@@ -5277,7 +5474,7 @@ static int __e1000_resume(struct pci_dev *pdev)
5277 * under the control of the driver. 5474 * under the control of the driver.
5278 */ 5475 */
5279 if (!(adapter->flags & FLAG_HAS_AMT)) 5476 if (!(adapter->flags & FLAG_HAS_AMT))
5280 e1000_get_hw_control(adapter); 5477 e1000e_get_hw_control(adapter);
5281 5478
5282 return 0; 5479 return 0;
5283} 5480}
@@ -5356,7 +5553,7 @@ static int e1000_runtime_resume(struct device *dev)
5356 return __e1000_resume(pdev); 5553 return __e1000_resume(pdev);
5357} 5554}
5358#endif /* CONFIG_PM_RUNTIME */ 5555#endif /* CONFIG_PM_RUNTIME */
5359#endif /* CONFIG_PM_OPS */ 5556#endif /* CONFIG_PM */
5360 5557
5361static void e1000_shutdown(struct pci_dev *pdev) 5558static void e1000_shutdown(struct pci_dev *pdev)
5362{ 5559{
@@ -5369,6 +5566,37 @@ static void e1000_shutdown(struct pci_dev *pdev)
5369} 5566}
5370 5567
5371#ifdef CONFIG_NET_POLL_CONTROLLER 5568#ifdef CONFIG_NET_POLL_CONTROLLER
5569
5570static irqreturn_t e1000_intr_msix(int irq, void *data)
5571{
5572 struct net_device *netdev = data;
5573 struct e1000_adapter *adapter = netdev_priv(netdev);
5574
5575 if (adapter->msix_entries) {
5576 int vector, msix_irq;
5577
5578 vector = 0;
5579 msix_irq = adapter->msix_entries[vector].vector;
5580 disable_irq(msix_irq);
5581 e1000_intr_msix_rx(msix_irq, netdev);
5582 enable_irq(msix_irq);
5583
5584 vector++;
5585 msix_irq = adapter->msix_entries[vector].vector;
5586 disable_irq(msix_irq);
5587 e1000_intr_msix_tx(msix_irq, netdev);
5588 enable_irq(msix_irq);
5589
5590 vector++;
5591 msix_irq = adapter->msix_entries[vector].vector;
5592 disable_irq(msix_irq);
5593 e1000_msix_other(msix_irq, netdev);
5594 enable_irq(msix_irq);
5595 }
5596
5597 return IRQ_HANDLED;
5598}
5599
5372/* 5600/*
5373 * Polling 'interrupt' - used by things like netconsole to send skbs 5601 * Polling 'interrupt' - used by things like netconsole to send skbs
5374 * without having to re-enable interrupts. It's not called while 5602 * without having to re-enable interrupts. It's not called while
@@ -5378,10 +5606,21 @@ static void e1000_netpoll(struct net_device *netdev)
5378{ 5606{
5379 struct e1000_adapter *adapter = netdev_priv(netdev); 5607 struct e1000_adapter *adapter = netdev_priv(netdev);
5380 5608
5381 disable_irq(adapter->pdev->irq); 5609 switch (adapter->int_mode) {
5382 e1000_intr(adapter->pdev->irq, netdev); 5610 case E1000E_INT_MODE_MSIX:
5383 5611 e1000_intr_msix(adapter->pdev->irq, netdev);
5384 enable_irq(adapter->pdev->irq); 5612 break;
5613 case E1000E_INT_MODE_MSI:
5614 disable_irq(adapter->pdev->irq);
5615 e1000_intr_msi(adapter->pdev->irq, netdev);
5616 enable_irq(adapter->pdev->irq);
5617 break;
5618 default: /* E1000E_INT_MODE_LEGACY */
5619 disable_irq(adapter->pdev->irq);
5620 e1000_intr(adapter->pdev->irq, netdev);
5621 enable_irq(adapter->pdev->irq);
5622 break;
5623 }
5385} 5624}
5386#endif 5625#endif
5387 5626
@@ -5424,11 +5663,17 @@ static pci_ers_result_t e1000_io_slot_reset(struct pci_dev *pdev)
5424 struct net_device *netdev = pci_get_drvdata(pdev); 5663 struct net_device *netdev = pci_get_drvdata(pdev);
5425 struct e1000_adapter *adapter = netdev_priv(netdev); 5664 struct e1000_adapter *adapter = netdev_priv(netdev);
5426 struct e1000_hw *hw = &adapter->hw; 5665 struct e1000_hw *hw = &adapter->hw;
5666 u16 aspm_disable_flag = 0;
5427 int err; 5667 int err;
5428 pci_ers_result_t result; 5668 pci_ers_result_t result;
5429 5669
5670 if (adapter->flags2 & FLAG2_DISABLE_ASPM_L0S)
5671 aspm_disable_flag = PCIE_LINK_STATE_L0S;
5430 if (adapter->flags2 & FLAG2_DISABLE_ASPM_L1) 5672 if (adapter->flags2 & FLAG2_DISABLE_ASPM_L1)
5431 e1000e_disable_aspm(pdev, PCIE_LINK_STATE_L1); 5673 aspm_disable_flag |= PCIE_LINK_STATE_L1;
5674 if (aspm_disable_flag)
5675 e1000e_disable_aspm(pdev, aspm_disable_flag);
5676
5432 err = pci_enable_device_mem(pdev); 5677 err = pci_enable_device_mem(pdev);
5433 if (err) { 5678 if (err) {
5434 dev_err(&pdev->dev, 5679 dev_err(&pdev->dev,
@@ -5483,7 +5728,7 @@ static void e1000_io_resume(struct pci_dev *pdev)
5483 * under the control of the driver. 5728 * under the control of the driver.
5484 */ 5729 */
5485 if (!(adapter->flags & FLAG_HAS_AMT)) 5730 if (!(adapter->flags & FLAG_HAS_AMT))
5486 e1000_get_hw_control(adapter); 5731 e1000e_get_hw_control(adapter);
5487 5732
5488} 5733}
5489 5734
@@ -5491,10 +5736,11 @@ static void e1000_print_device_info(struct e1000_adapter *adapter)
5491{ 5736{
5492 struct e1000_hw *hw = &adapter->hw; 5737 struct e1000_hw *hw = &adapter->hw;
5493 struct net_device *netdev = adapter->netdev; 5738 struct net_device *netdev = adapter->netdev;
5494 u32 pba_num; 5739 u32 ret_val;
5740 u8 pba_str[E1000_PBANUM_LENGTH];
5495 5741
5496 /* print bus type/speed/width info */ 5742 /* print bus type/speed/width info */
5497 e_info("(PCI Express:2.5GB/s:%s) %pM\n", 5743 e_info("(PCI Express:2.5GT/s:%s) %pM\n",
5498 /* bus width */ 5744 /* bus width */
5499 ((hw->bus.width == e1000_bus_width_pcie_x4) ? "Width x4" : 5745 ((hw->bus.width == e1000_bus_width_pcie_x4) ? "Width x4" :
5500 "Width x1"), 5746 "Width x1"),
@@ -5502,9 +5748,12 @@ static void e1000_print_device_info(struct e1000_adapter *adapter)
5502 netdev->dev_addr); 5748 netdev->dev_addr);
5503 e_info("Intel(R) PRO/%s Network Connection\n", 5749 e_info("Intel(R) PRO/%s Network Connection\n",
5504 (hw->phy.type == e1000_phy_ife) ? "10/100" : "1000"); 5750 (hw->phy.type == e1000_phy_ife) ? "10/100" : "1000");
5505 e1000e_read_pba_num(hw, &pba_num); 5751 ret_val = e1000_read_pba_string_generic(hw, pba_str,
5506 e_info("MAC: %d, PHY: %d, PBA No: %06x-%03x\n", 5752 E1000_PBANUM_LENGTH);
5507 hw->mac.type, hw->phy.type, (pba_num >> 8), (pba_num & 0xff)); 5753 if (ret_val)
5754 strncpy((char *)pba_str, "Unknown", sizeof(pba_str) - 1);
5755 e_info("MAC: %d, PHY: %d, PBA No: %s\n",
5756 hw->mac.type, hw->phy.type, pba_str);
5508} 5757}
5509 5758
5510static void e1000_eeprom_checks(struct e1000_adapter *adapter) 5759static void e1000_eeprom_checks(struct e1000_adapter *adapter)
@@ -5528,7 +5777,7 @@ static const struct net_device_ops e1000e_netdev_ops = {
5528 .ndo_open = e1000_open, 5777 .ndo_open = e1000_open,
5529 .ndo_stop = e1000_close, 5778 .ndo_stop = e1000_close,
5530 .ndo_start_xmit = e1000_xmit_frame, 5779 .ndo_start_xmit = e1000_xmit_frame,
5531 .ndo_get_stats = e1000_get_stats, 5780 .ndo_get_stats64 = e1000e_get_stats64,
5532 .ndo_set_multicast_list = e1000_set_multi, 5781 .ndo_set_multicast_list = e1000_set_multi,
5533 .ndo_set_mac_address = e1000_set_mac, 5782 .ndo_set_mac_address = e1000_set_mac,
5534 .ndo_change_mtu = e1000_change_mtu, 5783 .ndo_change_mtu = e1000_change_mtu,
@@ -5536,7 +5785,6 @@ static const struct net_device_ops e1000e_netdev_ops = {
5536 .ndo_tx_timeout = e1000_tx_timeout, 5785 .ndo_tx_timeout = e1000_tx_timeout,
5537 .ndo_validate_addr = eth_validate_addr, 5786 .ndo_validate_addr = eth_validate_addr,
5538 5787
5539 .ndo_vlan_rx_register = e1000_vlan_rx_register,
5540 .ndo_vlan_rx_add_vid = e1000_vlan_rx_add_vid, 5788 .ndo_vlan_rx_add_vid = e1000_vlan_rx_add_vid,
5541 .ndo_vlan_rx_kill_vid = e1000_vlan_rx_kill_vid, 5789 .ndo_vlan_rx_kill_vid = e1000_vlan_rx_kill_vid,
5542#ifdef CONFIG_NET_POLL_CONTROLLER 5790#ifdef CONFIG_NET_POLL_CONTROLLER
@@ -5566,12 +5814,17 @@ static int __devinit e1000_probe(struct pci_dev *pdev,
5566 resource_size_t flash_start, flash_len; 5814 resource_size_t flash_start, flash_len;
5567 5815
5568 static int cards_found; 5816 static int cards_found;
5817 u16 aspm_disable_flag = 0;
5569 int i, err, pci_using_dac; 5818 int i, err, pci_using_dac;
5570 u16 eeprom_data = 0; 5819 u16 eeprom_data = 0;
5571 u16 eeprom_apme_mask = E1000_EEPROM_APME; 5820 u16 eeprom_apme_mask = E1000_EEPROM_APME;
5572 5821
5822 if (ei->flags2 & FLAG2_DISABLE_ASPM_L0S)
5823 aspm_disable_flag = PCIE_LINK_STATE_L0S;
5573 if (ei->flags2 & FLAG2_DISABLE_ASPM_L1) 5824 if (ei->flags2 & FLAG2_DISABLE_ASPM_L1)
5574 e1000e_disable_aspm(pdev, PCIE_LINK_STATE_L1); 5825 aspm_disable_flag |= PCIE_LINK_STATE_L1;
5826 if (aspm_disable_flag)
5827 e1000e_disable_aspm(pdev, aspm_disable_flag);
5575 5828
5576 err = pci_enable_device_mem(pdev); 5829 err = pci_enable_device_mem(pdev);
5577 if (err) 5830 if (err)
@@ -5712,8 +5965,10 @@ static int __devinit e1000_probe(struct pci_dev *pdev,
5712 netdev->vlan_features |= NETIF_F_HW_CSUM; 5965 netdev->vlan_features |= NETIF_F_HW_CSUM;
5713 netdev->vlan_features |= NETIF_F_SG; 5966 netdev->vlan_features |= NETIF_F_SG;
5714 5967
5715 if (pci_using_dac) 5968 if (pci_using_dac) {
5716 netdev->features |= NETIF_F_HIGHDMA; 5969 netdev->features |= NETIF_F_HIGHDMA;
5970 netdev->vlan_features |= NETIF_F_HIGHDMA;
5971 }
5717 5972
5718 if (e1000e_enable_mng_pass_thru(&adapter->hw)) 5973 if (e1000e_enable_mng_pass_thru(&adapter->hw))
5719 adapter->flags |= FLAG_MNG_PT_ENABLED; 5974 adapter->flags |= FLAG_MNG_PT_ENABLED;
@@ -5754,11 +6009,11 @@ static int __devinit e1000_probe(struct pci_dev *pdev,
5754 } 6009 }
5755 6010
5756 init_timer(&adapter->watchdog_timer); 6011 init_timer(&adapter->watchdog_timer);
5757 adapter->watchdog_timer.function = &e1000_watchdog; 6012 adapter->watchdog_timer.function = e1000_watchdog;
5758 adapter->watchdog_timer.data = (unsigned long) adapter; 6013 adapter->watchdog_timer.data = (unsigned long) adapter;
5759 6014
5760 init_timer(&adapter->phy_info_timer); 6015 init_timer(&adapter->phy_info_timer);
5761 adapter->phy_info_timer.function = &e1000_update_phy_info; 6016 adapter->phy_info_timer.function = e1000_update_phy_info;
5762 adapter->phy_info_timer.data = (unsigned long) adapter; 6017 adapter->phy_info_timer.data = (unsigned long) adapter;
5763 6018
5764 INIT_WORK(&adapter->reset_task, e1000_reset_task); 6019 INIT_WORK(&adapter->reset_task, e1000_reset_task);
@@ -5786,7 +6041,8 @@ static int __devinit e1000_probe(struct pci_dev *pdev,
5786 /* APME bit in EEPROM is mapped to WUC.APME */ 6041 /* APME bit in EEPROM is mapped to WUC.APME */
5787 eeprom_data = er32(WUC); 6042 eeprom_data = er32(WUC);
5788 eeprom_apme_mask = E1000_WUC_APME; 6043 eeprom_apme_mask = E1000_WUC_APME;
5789 if (eeprom_data & E1000_WUC_PHY_WAKE) 6044 if ((hw->mac.type > e1000_ich10lan) &&
6045 (eeprom_data & E1000_WUC_PHY_WAKE))
5790 adapter->flags2 |= FLAG2_HAS_PHY_WAKEUP; 6046 adapter->flags2 |= FLAG2_HAS_PHY_WAKEUP;
5791 } else if (adapter->flags & FLAG_APME_IN_CTRL3) { 6047 } else if (adapter->flags & FLAG_APME_IN_CTRL3) {
5792 if (adapter->flags & FLAG_APME_CHECK_PORT_B && 6048 if (adapter->flags & FLAG_APME_CHECK_PORT_B &&
@@ -5826,9 +6082,9 @@ static int __devinit e1000_probe(struct pci_dev *pdev,
5826 * under the control of the driver. 6082 * under the control of the driver.
5827 */ 6083 */
5828 if (!(adapter->flags & FLAG_HAS_AMT)) 6084 if (!(adapter->flags & FLAG_HAS_AMT))
5829 e1000_get_hw_control(adapter); 6085 e1000e_get_hw_control(adapter);
5830 6086
5831 strcpy(netdev->name, "eth%d"); 6087 strncpy(netdev->name, "eth%d", sizeof(netdev->name) - 1);
5832 err = register_netdev(netdev); 6088 err = register_netdev(netdev);
5833 if (err) 6089 if (err)
5834 goto err_register; 6090 goto err_register;
@@ -5845,12 +6101,11 @@ static int __devinit e1000_probe(struct pci_dev *pdev,
5845 6101
5846err_register: 6102err_register:
5847 if (!(adapter->flags & FLAG_HAS_AMT)) 6103 if (!(adapter->flags & FLAG_HAS_AMT))
5848 e1000_release_hw_control(adapter); 6104 e1000e_release_hw_control(adapter);
5849err_eeprom: 6105err_eeprom:
5850 if (!e1000_check_reset_block(&adapter->hw)) 6106 if (!e1000_check_reset_block(&adapter->hw))
5851 e1000_phy_hw_reset(&adapter->hw); 6107 e1000_phy_hw_reset(&adapter->hw);
5852err_hw_init: 6108err_hw_init:
5853
5854 kfree(adapter->tx_ring); 6109 kfree(adapter->tx_ring);
5855 kfree(adapter->rx_ring); 6110 kfree(adapter->rx_ring);
5856err_sw_init: 6111err_sw_init:
@@ -5886,8 +6141,8 @@ static void __devexit e1000_remove(struct pci_dev *pdev)
5886 bool down = test_bit(__E1000_DOWN, &adapter->state); 6141 bool down = test_bit(__E1000_DOWN, &adapter->state);
5887 6142
5888 /* 6143 /*
5889 * flush_scheduled work may reschedule our watchdog task, so 6144 * The timers may be rescheduled, so explicitly disable them
5890 * explicitly disable watchdog tasks from being rescheduled 6145 * from being rescheduled.
5891 */ 6146 */
5892 if (!down) 6147 if (!down)
5893 set_bit(__E1000_DOWN, &adapter->state); 6148 set_bit(__E1000_DOWN, &adapter->state);
@@ -5899,7 +6154,6 @@ static void __devexit e1000_remove(struct pci_dev *pdev)
5899 cancel_work_sync(&adapter->downshift_task); 6154 cancel_work_sync(&adapter->downshift_task);
5900 cancel_work_sync(&adapter->update_phy_task); 6155 cancel_work_sync(&adapter->update_phy_task);
5901 cancel_work_sync(&adapter->print_hang_task); 6156 cancel_work_sync(&adapter->print_hang_task);
5902 flush_scheduled_work();
5903 6157
5904 if (!(netdev->flags & IFF_UP)) 6158 if (!(netdev->flags & IFF_UP))
5905 e1000_power_down_phy(adapter); 6159 e1000_power_down_phy(adapter);
@@ -5916,7 +6170,7 @@ static void __devexit e1000_remove(struct pci_dev *pdev)
5916 * Release control of h/w to f/w. If f/w is AMT enabled, this 6170 * Release control of h/w to f/w. If f/w is AMT enabled, this
5917 * would have already happened in close and is redundant. 6171 * would have already happened in close and is redundant.
5918 */ 6172 */
5919 e1000_release_hw_control(adapter); 6173 e1000e_release_hw_control(adapter);
5920 6174
5921 e1000e_reset_interrupt_capability(adapter); 6175 e1000e_reset_interrupt_capability(adapter);
5922 kfree(adapter->tx_ring); 6176 kfree(adapter->tx_ring);
@@ -6015,7 +6269,7 @@ static DEFINE_PCI_DEVICE_TABLE(e1000_pci_tbl) = {
6015}; 6269};
6016MODULE_DEVICE_TABLE(pci, e1000_pci_tbl); 6270MODULE_DEVICE_TABLE(pci, e1000_pci_tbl);
6017 6271
6018#ifdef CONFIG_PM_OPS 6272#ifdef CONFIG_PM
6019static const struct dev_pm_ops e1000_pm_ops = { 6273static const struct dev_pm_ops e1000_pm_ops = {
6020 SET_SYSTEM_SLEEP_PM_OPS(e1000_suspend, e1000_resume) 6274 SET_SYSTEM_SLEEP_PM_OPS(e1000_suspend, e1000_resume)
6021 SET_RUNTIME_PM_OPS(e1000_runtime_suspend, 6275 SET_RUNTIME_PM_OPS(e1000_runtime_suspend,
@@ -6029,7 +6283,7 @@ static struct pci_driver e1000_driver = {
6029 .id_table = e1000_pci_tbl, 6283 .id_table = e1000_pci_tbl,
6030 .probe = e1000_probe, 6284 .probe = e1000_probe,
6031 .remove = __devexit_p(e1000_remove), 6285 .remove = __devexit_p(e1000_remove),
6032#ifdef CONFIG_PM_OPS 6286#ifdef CONFIG_PM
6033 .driver.pm = &e1000_pm_ops, 6287 .driver.pm = &e1000_pm_ops,
6034#endif 6288#endif
6035 .shutdown = e1000_shutdown, 6289 .shutdown = e1000_shutdown,
@@ -6047,7 +6301,7 @@ static int __init e1000_init_module(void)
6047 int ret; 6301 int ret;
6048 pr_info("Intel(R) PRO/1000 Network Driver - %s\n", 6302 pr_info("Intel(R) PRO/1000 Network Driver - %s\n",
6049 e1000e_driver_version); 6303 e1000e_driver_version);
6050 pr_info("Copyright (c) 1999 - 2010 Intel Corporation.\n"); 6304 pr_info("Copyright(c) 1999 - 2011 Intel Corporation.\n");
6051 ret = pci_register_driver(&e1000_driver); 6305 ret = pci_register_driver(&e1000_driver);
6052 6306
6053 return ret; 6307 return ret;
diff --git a/drivers/net/e1000e/param.c b/drivers/net/e1000e/param.c
index 34aeec13bb16..4dd9b63273f6 100644
--- a/drivers/net/e1000e/param.c
+++ b/drivers/net/e1000e/param.c
@@ -1,7 +1,7 @@
1/******************************************************************************* 1/*******************************************************************************
2 2
3 Intel PRO/1000 Linux driver 3 Intel PRO/1000 Linux driver
4 Copyright(c) 1999 - 2010 Intel Corporation. 4 Copyright(c) 1999 - 2011 Intel Corporation.
5 5
6 This program is free software; you can redistribute it and/or modify it 6 This program is free software; you can redistribute it and/or modify it
7 under the terms and conditions of the GNU General Public License, 7 under the terms and conditions of the GNU General Public License,
@@ -62,10 +62,9 @@ MODULE_PARM_DESC(copybreak,
62 module_param_array_named(X, X, int, &num_##X, 0); \ 62 module_param_array_named(X, X, int, &num_##X, 0); \
63 MODULE_PARM_DESC(X, desc); 63 MODULE_PARM_DESC(X, desc);
64 64
65
66/* 65/*
67 * Transmit Interrupt Delay in units of 1.024 microseconds 66 * Transmit Interrupt Delay in units of 1.024 microseconds
68 * Tx interrupt delay needs to typically be set to something non zero 67 * Tx interrupt delay needs to typically be set to something non-zero
69 * 68 *
70 * Valid Range: 0-65535 69 * Valid Range: 0-65535
71 */ 70 */
@@ -91,7 +90,6 @@ E1000_PARAM(TxAbsIntDelay, "Transmit Absolute Interrupt Delay");
91 * Valid Range: 0-65535 90 * Valid Range: 0-65535
92 */ 91 */
93E1000_PARAM(RxIntDelay, "Receive Interrupt Delay"); 92E1000_PARAM(RxIntDelay, "Receive Interrupt Delay");
94#define DEFAULT_RDTR 0
95#define MAX_RXDELAY 0xFFFF 93#define MAX_RXDELAY 0xFFFF
96#define MIN_RXDELAY 0 94#define MIN_RXDELAY 0
97 95
@@ -101,7 +99,6 @@ E1000_PARAM(RxIntDelay, "Receive Interrupt Delay");
101 * Valid Range: 0-65535 99 * Valid Range: 0-65535
102 */ 100 */
103E1000_PARAM(RxAbsIntDelay, "Receive Absolute Interrupt Delay"); 101E1000_PARAM(RxAbsIntDelay, "Receive Absolute Interrupt Delay");
104#define DEFAULT_RADV 8
105#define MAX_RXABSDELAY 0xFFFF 102#define MAX_RXABSDELAY 0xFFFF
106#define MIN_RXABSDELAY 0 103#define MIN_RXABSDELAY 0
107 104
@@ -114,6 +111,7 @@ E1000_PARAM(InterruptThrottleRate, "Interrupt Throttling Rate");
114#define DEFAULT_ITR 3 111#define DEFAULT_ITR 3
115#define MAX_ITR 100000 112#define MAX_ITR 100000
116#define MIN_ITR 100 113#define MIN_ITR 100
114
117/* IntMode (Interrupt Mode) 115/* IntMode (Interrupt Mode)
118 * 116 *
119 * Valid Range: 0 - 2 117 * Valid Range: 0 - 2
@@ -423,7 +421,7 @@ void __devinit e1000e_check_options(struct e1000_adapter *adapter)
423 static const struct e1000_option opt = { 421 static const struct e1000_option opt = {
424 .type = enable_option, 422 .type = enable_option,
425 .name = "CRC Stripping", 423 .name = "CRC Stripping",
426 .err = "defaulting to enabled", 424 .err = "defaulting to Enabled",
427 .def = OPTION_ENABLED 425 .def = OPTION_ENABLED
428 }; 426 };
429 427
diff --git a/drivers/net/e1000e/phy.c b/drivers/net/e1000e/phy.c
index 3d3dc0c82355..484774c13c21 100644
--- a/drivers/net/e1000e/phy.c
+++ b/drivers/net/e1000e/phy.c
@@ -1,7 +1,7 @@
1/******************************************************************************* 1/*******************************************************************************
2 2
3 Intel PRO/1000 Linux driver 3 Intel PRO/1000 Linux driver
4 Copyright(c) 1999 - 2010 Intel Corporation. 4 Copyright(c) 1999 - 2011 Intel Corporation.
5 5
6 This program is free software; you can redistribute it and/or modify it 6 This program is free software; you can redistribute it and/or modify it
7 under the terms and conditions of the GNU General Public License, 7 under the terms and conditions of the GNU General Public License,
@@ -42,20 +42,20 @@ static s32 e1000_access_phy_debug_regs_hv(struct e1000_hw *hw, u32 offset,
42 u16 *data, bool read); 42 u16 *data, bool read);
43 43
44/* Cable length tables */ 44/* Cable length tables */
45static const u16 e1000_m88_cable_length_table[] = 45static const u16 e1000_m88_cable_length_table[] = {
46 { 0, 50, 80, 110, 140, 140, E1000_CABLE_LENGTH_UNDEFINED }; 46 0, 50, 80, 110, 140, 140, E1000_CABLE_LENGTH_UNDEFINED };
47#define M88E1000_CABLE_LENGTH_TABLE_SIZE \ 47#define M88E1000_CABLE_LENGTH_TABLE_SIZE \
48 ARRAY_SIZE(e1000_m88_cable_length_table) 48 ARRAY_SIZE(e1000_m88_cable_length_table)
49 49
50static const u16 e1000_igp_2_cable_length_table[] = 50static const u16 e1000_igp_2_cable_length_table[] = {
51 { 0, 0, 0, 0, 0, 0, 0, 0, 3, 5, 8, 11, 13, 16, 18, 21, 0, 0, 0, 3, 51 0, 0, 0, 0, 0, 0, 0, 0, 3, 5, 8, 11, 13, 16, 18, 21, 0, 0, 0, 3,
52 6, 10, 13, 16, 19, 23, 26, 29, 32, 35, 38, 41, 6, 10, 14, 18, 22, 52 6, 10, 13, 16, 19, 23, 26, 29, 32, 35, 38, 41, 6, 10, 14, 18, 22,
53 26, 30, 33, 37, 41, 44, 48, 51, 54, 58, 61, 21, 26, 31, 35, 40, 53 26, 30, 33, 37, 41, 44, 48, 51, 54, 58, 61, 21, 26, 31, 35, 40,
54 44, 49, 53, 57, 61, 65, 68, 72, 75, 79, 82, 40, 45, 51, 56, 61, 54 44, 49, 53, 57, 61, 65, 68, 72, 75, 79, 82, 40, 45, 51, 56, 61,
55 66, 70, 75, 79, 83, 87, 91, 94, 98, 101, 104, 60, 66, 72, 77, 82, 55 66, 70, 75, 79, 83, 87, 91, 94, 98, 101, 104, 60, 66, 72, 77, 82,
56 87, 92, 96, 100, 104, 108, 111, 114, 117, 119, 121, 83, 89, 95, 56 87, 92, 96, 100, 104, 108, 111, 114, 117, 119, 121, 83, 89, 95,
57 100, 105, 109, 113, 116, 119, 122, 124, 104, 109, 114, 118, 121, 57 100, 105, 109, 113, 116, 119, 122, 124, 104, 109, 114, 118, 121,
58 124}; 58 124};
59#define IGP02E1000_CABLE_LENGTH_TABLE_SIZE \ 59#define IGP02E1000_CABLE_LENGTH_TABLE_SIZE \
60 ARRAY_SIZE(e1000_igp_2_cable_length_table) 60 ARRAY_SIZE(e1000_igp_2_cable_length_table)
61 61
@@ -226,6 +226,13 @@ s32 e1000e_read_phy_reg_mdic(struct e1000_hw *hw, u32 offset, u16 *data)
226 } 226 }
227 *data = (u16) mdic; 227 *data = (u16) mdic;
228 228
229 /*
230 * Allow some time after each MDIC transaction to avoid
231 * reading duplicate data in the next MDIC transaction.
232 */
233 if (hw->mac.type == e1000_pch2lan)
234 udelay(100);
235
229 return 0; 236 return 0;
230} 237}
231 238
@@ -279,6 +286,13 @@ s32 e1000e_write_phy_reg_mdic(struct e1000_hw *hw, u32 offset, u16 data)
279 return -E1000_ERR_PHY; 286 return -E1000_ERR_PHY;
280 } 287 }
281 288
289 /*
290 * Allow some time after each MDIC transaction to avoid
291 * reading duplicate data in the next MDIC transaction.
292 */
293 if (hw->mac.type == e1000_pch2lan)
294 udelay(100);
295
282 return 0; 296 return 0;
283} 297}
284 298
@@ -623,12 +637,11 @@ s32 e1000e_write_kmrn_reg_locked(struct e1000_hw *hw, u32 offset, u16 data)
623 **/ 637 **/
624s32 e1000_copper_link_setup_82577(struct e1000_hw *hw) 638s32 e1000_copper_link_setup_82577(struct e1000_hw *hw)
625{ 639{
626 struct e1000_phy_info *phy = &hw->phy;
627 s32 ret_val; 640 s32 ret_val;
628 u16 phy_data; 641 u16 phy_data;
629 642
630 /* Enable CRS on TX. This must be set for half-duplex operation. */ 643 /* Enable CRS on Tx. This must be set for half-duplex operation. */
631 ret_val = phy->ops.read_reg(hw, I82577_CFG_REG, &phy_data); 644 ret_val = e1e_rphy(hw, I82577_CFG_REG, &phy_data);
632 if (ret_val) 645 if (ret_val)
633 goto out; 646 goto out;
634 647
@@ -637,7 +650,7 @@ s32 e1000_copper_link_setup_82577(struct e1000_hw *hw)
637 /* Enable downshift */ 650 /* Enable downshift */
638 phy_data |= I82577_CFG_ENABLE_DOWNSHIFT; 651 phy_data |= I82577_CFG_ENABLE_DOWNSHIFT;
639 652
640 ret_val = phy->ops.write_reg(hw, I82577_CFG_REG, phy_data); 653 ret_val = e1e_wphy(hw, I82577_CFG_REG, phy_data);
641 654
642out: 655out:
643 return ret_val; 656 return ret_val;
@@ -760,16 +773,14 @@ s32 e1000e_copper_link_setup_m88(struct e1000_hw *hw)
760 } 773 }
761 774
762 if (phy->type == e1000_phy_82578) { 775 if (phy->type == e1000_phy_82578) {
763 ret_val = phy->ops.read_reg(hw, M88E1000_EXT_PHY_SPEC_CTRL, 776 ret_val = e1e_rphy(hw, M88E1000_EXT_PHY_SPEC_CTRL, &phy_data);
764 &phy_data);
765 if (ret_val) 777 if (ret_val)
766 return ret_val; 778 return ret_val;
767 779
768 /* 82578 PHY - set the downshift count to 1x. */ 780 /* 82578 PHY - set the downshift count to 1x. */
769 phy_data |= I82578_EPSCR_DOWNSHIFT_ENABLE; 781 phy_data |= I82578_EPSCR_DOWNSHIFT_ENABLE;
770 phy_data &= ~I82578_EPSCR_DOWNSHIFT_COUNTER_MASK; 782 phy_data &= ~I82578_EPSCR_DOWNSHIFT_COUNTER_MASK;
771 ret_val = phy->ops.write_reg(hw, M88E1000_EXT_PHY_SPEC_CTRL, 783 ret_val = e1e_wphy(hw, M88E1000_EXT_PHY_SPEC_CTRL, phy_data);
772 phy_data);
773 if (ret_val) 784 if (ret_val)
774 return ret_val; 785 return ret_val;
775 } 786 }
@@ -1043,9 +1054,8 @@ static s32 e1000_phy_setup_autoneg(struct e1000_hw *hw)
1043 1054
1044 e_dbg("Auto-Neg Advertising %x\n", mii_autoneg_adv_reg); 1055 e_dbg("Auto-Neg Advertising %x\n", mii_autoneg_adv_reg);
1045 1056
1046 if (phy->autoneg_mask & ADVERTISE_1000_FULL) { 1057 if (phy->autoneg_mask & ADVERTISE_1000_FULL)
1047 ret_val = e1e_wphy(hw, PHY_1000T_CTRL, mii_1000t_ctrl_reg); 1058 ret_val = e1e_wphy(hw, PHY_1000T_CTRL, mii_1000t_ctrl_reg);
1048 }
1049 1059
1050 return ret_val; 1060 return ret_val;
1051} 1061}
@@ -1306,9 +1316,8 @@ s32 e1000e_phy_force_speed_duplex_m88(struct e1000_hw *hw)
1306 * We didn't get link. 1316 * We didn't get link.
1307 * Reset the DSP and cross our fingers. 1317 * Reset the DSP and cross our fingers.
1308 */ 1318 */
1309 ret_val = e1e_wphy(hw, 1319 ret_val = e1e_wphy(hw, M88E1000_PHY_PAGE_SELECT,
1310 M88E1000_PHY_PAGE_SELECT, 1320 0x001d);
1311 0x001d);
1312 if (ret_val) 1321 if (ret_val)
1313 return ret_val; 1322 return ret_val;
1314 ret_val = e1000e_phy_reset_dsp(hw); 1323 ret_val = e1000e_phy_reset_dsp(hw);
@@ -1840,11 +1849,12 @@ s32 e1000e_get_cable_length_igp_2(struct e1000_hw *hw)
1840 u16 phy_data, i, agc_value = 0; 1849 u16 phy_data, i, agc_value = 0;
1841 u16 cur_agc_index, max_agc_index = 0; 1850 u16 cur_agc_index, max_agc_index = 0;
1842 u16 min_agc_index = IGP02E1000_CABLE_LENGTH_TABLE_SIZE - 1; 1851 u16 min_agc_index = IGP02E1000_CABLE_LENGTH_TABLE_SIZE - 1;
1843 u16 agc_reg_array[IGP02E1000_PHY_CHANNEL_NUM] = 1852 static const u16 agc_reg_array[IGP02E1000_PHY_CHANNEL_NUM] = {
1844 {IGP02E1000_PHY_AGC_A, 1853 IGP02E1000_PHY_AGC_A,
1845 IGP02E1000_PHY_AGC_B, 1854 IGP02E1000_PHY_AGC_B,
1846 IGP02E1000_PHY_AGC_C, 1855 IGP02E1000_PHY_AGC_C,
1847 IGP02E1000_PHY_AGC_D}; 1856 IGP02E1000_PHY_AGC_D
1857 };
1848 1858
1849 /* Read the AGC registers for all channels */ 1859 /* Read the AGC registers for all channels */
1850 for (i = 0; i < IGP02E1000_PHY_CHANNEL_NUM; i++) { 1860 for (i = 0; i < IGP02E1000_PHY_CHANNEL_NUM; i++) {
@@ -2362,7 +2372,7 @@ s32 e1000e_determine_phy_address(struct e1000_hw *hw)
2362 ret_val = 0; 2372 ret_val = 0;
2363 goto out; 2373 goto out;
2364 } 2374 }
2365 msleep(1); 2375 usleep_range(1000, 2000);
2366 i++; 2376 i++;
2367 } while (i < 10); 2377 } while (i < 10);
2368 } 2378 }
@@ -2399,9 +2409,7 @@ static u32 e1000_get_phy_addr_for_bm_page(u32 page, u32 reg)
2399s32 e1000e_write_phy_reg_bm(struct e1000_hw *hw, u32 offset, u16 data) 2409s32 e1000e_write_phy_reg_bm(struct e1000_hw *hw, u32 offset, u16 data)
2400{ 2410{
2401 s32 ret_val; 2411 s32 ret_val;
2402 u32 page_select = 0;
2403 u32 page = offset >> IGP_PAGE_SHIFT; 2412 u32 page = offset >> IGP_PAGE_SHIFT;
2404 u32 page_shift = 0;
2405 2413
2406 ret_val = hw->phy.ops.acquire(hw); 2414 ret_val = hw->phy.ops.acquire(hw);
2407 if (ret_val) 2415 if (ret_val)
@@ -2417,6 +2425,8 @@ s32 e1000e_write_phy_reg_bm(struct e1000_hw *hw, u32 offset, u16 data)
2417 hw->phy.addr = e1000_get_phy_addr_for_bm_page(page, offset); 2425 hw->phy.addr = e1000_get_phy_addr_for_bm_page(page, offset);
2418 2426
2419 if (offset > MAX_PHY_MULTI_PAGE_REG) { 2427 if (offset > MAX_PHY_MULTI_PAGE_REG) {
2428 u32 page_shift, page_select;
2429
2420 /* 2430 /*
2421 * Page select is register 31 for phy address 1 and 22 for 2431 * Page select is register 31 for phy address 1 and 22 for
2422 * phy address 2 and 3. Page select is shifted only for 2432 * phy address 2 and 3. Page select is shifted only for
@@ -2458,9 +2468,7 @@ out:
2458s32 e1000e_read_phy_reg_bm(struct e1000_hw *hw, u32 offset, u16 *data) 2468s32 e1000e_read_phy_reg_bm(struct e1000_hw *hw, u32 offset, u16 *data)
2459{ 2469{
2460 s32 ret_val; 2470 s32 ret_val;
2461 u32 page_select = 0;
2462 u32 page = offset >> IGP_PAGE_SHIFT; 2471 u32 page = offset >> IGP_PAGE_SHIFT;
2463 u32 page_shift = 0;
2464 2472
2465 ret_val = hw->phy.ops.acquire(hw); 2473 ret_val = hw->phy.ops.acquire(hw);
2466 if (ret_val) 2474 if (ret_val)
@@ -2476,6 +2484,8 @@ s32 e1000e_read_phy_reg_bm(struct e1000_hw *hw, u32 offset, u16 *data)
2476 hw->phy.addr = e1000_get_phy_addr_for_bm_page(page, offset); 2484 hw->phy.addr = e1000_get_phy_addr_for_bm_page(page, offset);
2477 2485
2478 if (offset > MAX_PHY_MULTI_PAGE_REG) { 2486 if (offset > MAX_PHY_MULTI_PAGE_REG) {
2487 u32 page_shift, page_select;
2488
2479 /* 2489 /*
2480 * Page select is register 31 for phy address 1 and 22 for 2490 * Page select is register 31 for phy address 1 and 22 for
2481 * phy address 2 and 3. Page select is shifted only for 2491 * phy address 2 and 3. Page select is shifted only for
@@ -2730,7 +2740,7 @@ void e1000_power_down_phy_copper(struct e1000_hw *hw)
2730 e1e_rphy(hw, PHY_CONTROL, &mii_reg); 2740 e1e_rphy(hw, PHY_CONTROL, &mii_reg);
2731 mii_reg |= MII_CR_POWER_DOWN; 2741 mii_reg |= MII_CR_POWER_DOWN;
2732 e1e_wphy(hw, PHY_CONTROL, mii_reg); 2742 e1e_wphy(hw, PHY_CONTROL, mii_reg);
2733 msleep(1); 2743 usleep_range(1000, 2000);
2734} 2744}
2735 2745
2736/** 2746/**
@@ -2976,7 +2986,7 @@ s32 e1000_write_phy_reg_hv_locked(struct e1000_hw *hw, u32 offset, u16 data)
2976} 2986}
2977 2987
2978/** 2988/**
2979 * e1000_get_phy_addr_for_hv_page - Get PHY adrress based on page 2989 * e1000_get_phy_addr_for_hv_page - Get PHY address based on page
2980 * @page: page to be accessed 2990 * @page: page to be accessed
2981 **/ 2991 **/
2982static u32 e1000_get_phy_addr_for_hv_page(u32 page) 2992static u32 e1000_get_phy_addr_for_hv_page(u32 page)
@@ -3057,12 +3067,12 @@ s32 e1000_link_stall_workaround_hv(struct e1000_hw *hw)
3057 goto out; 3067 goto out;
3058 3068
3059 /* Do not apply workaround if in PHY loopback bit 14 set */ 3069 /* Do not apply workaround if in PHY loopback bit 14 set */
3060 hw->phy.ops.read_reg(hw, PHY_CONTROL, &data); 3070 e1e_rphy(hw, PHY_CONTROL, &data);
3061 if (data & PHY_CONTROL_LB) 3071 if (data & PHY_CONTROL_LB)
3062 goto out; 3072 goto out;
3063 3073
3064 /* check if link is up and at 1Gbps */ 3074 /* check if link is up and at 1Gbps */
3065 ret_val = hw->phy.ops.read_reg(hw, BM_CS_STATUS, &data); 3075 ret_val = e1e_rphy(hw, BM_CS_STATUS, &data);
3066 if (ret_val) 3076 if (ret_val)
3067 goto out; 3077 goto out;
3068 3078
@@ -3078,14 +3088,12 @@ s32 e1000_link_stall_workaround_hv(struct e1000_hw *hw)
3078 mdelay(200); 3088 mdelay(200);
3079 3089
3080 /* flush the packets in the fifo buffer */ 3090 /* flush the packets in the fifo buffer */
3081 ret_val = hw->phy.ops.write_reg(hw, HV_MUX_DATA_CTRL, 3091 ret_val = e1e_wphy(hw, HV_MUX_DATA_CTRL, HV_MUX_DATA_CTRL_GEN_TO_MAC |
3082 HV_MUX_DATA_CTRL_GEN_TO_MAC | 3092 HV_MUX_DATA_CTRL_FORCE_SPEED);
3083 HV_MUX_DATA_CTRL_FORCE_SPEED);
3084 if (ret_val) 3093 if (ret_val)
3085 goto out; 3094 goto out;
3086 3095
3087 ret_val = hw->phy.ops.write_reg(hw, HV_MUX_DATA_CTRL, 3096 ret_val = e1e_wphy(hw, HV_MUX_DATA_CTRL, HV_MUX_DATA_CTRL_GEN_TO_MAC);
3088 HV_MUX_DATA_CTRL_GEN_TO_MAC);
3089 3097
3090out: 3098out:
3091 return ret_val; 3099 return ret_val;
@@ -3105,7 +3113,7 @@ s32 e1000_check_polarity_82577(struct e1000_hw *hw)
3105 s32 ret_val; 3113 s32 ret_val;
3106 u16 data; 3114 u16 data;
3107 3115
3108 ret_val = phy->ops.read_reg(hw, I82577_PHY_STATUS_2, &data); 3116 ret_val = e1e_rphy(hw, I82577_PHY_STATUS_2, &data);
3109 3117
3110 if (!ret_val) 3118 if (!ret_val)
3111 phy->cable_polarity = (data & I82577_PHY_STATUS2_REV_POLARITY) 3119 phy->cable_polarity = (data & I82577_PHY_STATUS2_REV_POLARITY)
@@ -3128,13 +3136,13 @@ s32 e1000_phy_force_speed_duplex_82577(struct e1000_hw *hw)
3128 u16 phy_data; 3136 u16 phy_data;
3129 bool link; 3137 bool link;
3130 3138
3131 ret_val = phy->ops.read_reg(hw, PHY_CONTROL, &phy_data); 3139 ret_val = e1e_rphy(hw, PHY_CONTROL, &phy_data);
3132 if (ret_val) 3140 if (ret_val)
3133 goto out; 3141 goto out;
3134 3142
3135 e1000e_phy_force_speed_duplex_setup(hw, &phy_data); 3143 e1000e_phy_force_speed_duplex_setup(hw, &phy_data);
3136 3144
3137 ret_val = phy->ops.write_reg(hw, PHY_CONTROL, phy_data); 3145 ret_val = e1e_wphy(hw, PHY_CONTROL, phy_data);
3138 if (ret_val) 3146 if (ret_val)
3139 goto out; 3147 goto out;
3140 3148
@@ -3198,7 +3206,7 @@ s32 e1000_get_phy_info_82577(struct e1000_hw *hw)
3198 if (ret_val) 3206 if (ret_val)
3199 goto out; 3207 goto out;
3200 3208
3201 ret_val = phy->ops.read_reg(hw, I82577_PHY_STATUS_2, &data); 3209 ret_val = e1e_rphy(hw, I82577_PHY_STATUS_2, &data);
3202 if (ret_val) 3210 if (ret_val)
3203 goto out; 3211 goto out;
3204 3212
@@ -3210,7 +3218,7 @@ s32 e1000_get_phy_info_82577(struct e1000_hw *hw)
3210 if (ret_val) 3218 if (ret_val)
3211 goto out; 3219 goto out;
3212 3220
3213 ret_val = phy->ops.read_reg(hw, PHY_1000T_STATUS, &data); 3221 ret_val = e1e_rphy(hw, PHY_1000T_STATUS, &data);
3214 if (ret_val) 3222 if (ret_val)
3215 goto out; 3223 goto out;
3216 3224
@@ -3244,7 +3252,7 @@ s32 e1000_get_cable_length_82577(struct e1000_hw *hw)
3244 s32 ret_val; 3252 s32 ret_val;
3245 u16 phy_data, length; 3253 u16 phy_data, length;
3246 3254
3247 ret_val = phy->ops.read_reg(hw, I82577_PHY_DIAG_STATUS, &phy_data); 3255 ret_val = e1e_rphy(hw, I82577_PHY_DIAG_STATUS, &phy_data);
3248 if (ret_val) 3256 if (ret_val)
3249 goto out; 3257 goto out;
3250 3258