aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/ethernet
diff options
context:
space:
mode:
authorAlexander Duyck <alexander.h.duyck@intel.com>2011-07-15 03:29:44 -0400
committerJeff Kirsher <jeffrey.t.kirsher@intel.com>2011-09-16 00:26:16 -0400
commit8132b54e46259cfc6579ba11c5e3efffda64110b (patch)
tree10126b998408f47db9b4ea8815536fa6a28bc9ef /drivers/net/ethernet
parentb88c6de20c5edf797bc526cbfe0e8979c63768b9 (diff)
ixgbe: cleanup reset paths
The reset paths are overly complicated and are either missing steps or contain extra unnecessary steps such as reading MAC address twice. This change is meant to help clean up the reset paths an get things functioning correctly. Signed-off-by: Alexander Duyck <alexander.h.duyck@intel.com> Tested-by: Phil Schmitt <phillip.j.schmitt@intel.com> Signed-off-by: Jeff Kirsher <jeffrey.t.kirsher@intel.com>
Diffstat (limited to 'drivers/net/ethernet')
-rw-r--r--drivers/net/ethernet/intel/ixgbe/ixgbe_82598.c13
-rw-r--r--drivers/net/ethernet/intel/ixgbe/ixgbe_82599.c40
-rw-r--r--drivers/net/ethernet/intel/ixgbe/ixgbe_type.h1
-rw-r--r--drivers/net/ethernet/intel/ixgbe/ixgbe_x540.c72
4 files changed, 43 insertions, 83 deletions
diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_82598.c b/drivers/net/ethernet/intel/ixgbe/ixgbe_82598.c
index 0d4e38264492..22504f2db25e 100644
--- a/drivers/net/ethernet/intel/ixgbe/ixgbe_82598.c
+++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_82598.c
@@ -820,8 +820,8 @@ mac_reset_top:
820 * Issue global reset to the MAC. This needs to be a SW reset. 820 * Issue global reset to the MAC. This needs to be a SW reset.
821 * If link reset is used, it might reset the MAC when mng is using it 821 * If link reset is used, it might reset the MAC when mng is using it
822 */ 822 */
823 ctrl = IXGBE_READ_REG(hw, IXGBE_CTRL); 823 ctrl = IXGBE_READ_REG(hw, IXGBE_CTRL) | IXGBE_CTRL_RST;
824 IXGBE_WRITE_REG(hw, IXGBE_CTRL, (ctrl | IXGBE_CTRL_RST)); 824 IXGBE_WRITE_REG(hw, IXGBE_CTRL, ctrl);
825 IXGBE_WRITE_FLUSH(hw); 825 IXGBE_WRITE_FLUSH(hw);
826 826
827 /* Poll for reset bit to self-clear indicating reset is complete */ 827 /* Poll for reset bit to self-clear indicating reset is complete */
@@ -836,21 +836,18 @@ mac_reset_top:
836 hw_dbg(hw, "Reset polling failed to complete.\n"); 836 hw_dbg(hw, "Reset polling failed to complete.\n");
837 } 837 }
838 838
839 msleep(50);
840
839 /* 841 /*
840 * Double resets are required for recovery from certain error 842 * Double resets are required for recovery from certain error
841 * conditions. Between resets, it is necessary to stall to allow time 843 * conditions. Between resets, it is necessary to stall to allow time
842 * for any pending HW events to complete. We use 1usec since that is 844 * for any pending HW events to complete.
843 * what is needed for ixgbe_disable_pcie_master(). The second reset
844 * then clears out any effects of those events.
845 */ 845 */
846 if (hw->mac.flags & IXGBE_FLAGS_DOUBLE_RESET_REQUIRED) { 846 if (hw->mac.flags & IXGBE_FLAGS_DOUBLE_RESET_REQUIRED) {
847 hw->mac.flags &= ~IXGBE_FLAGS_DOUBLE_RESET_REQUIRED; 847 hw->mac.flags &= ~IXGBE_FLAGS_DOUBLE_RESET_REQUIRED;
848 udelay(1);
849 goto mac_reset_top; 848 goto mac_reset_top;
850 } 849 }
851 850
852 msleep(50);
853
854 gheccr = IXGBE_READ_REG(hw, IXGBE_GHECCR); 851 gheccr = IXGBE_READ_REG(hw, IXGBE_GHECCR);
855 gheccr &= ~((1 << 21) | (1 << 18) | (1 << 9) | (1 << 6)); 852 gheccr &= ~((1 << 21) | (1 << 18) | (1 << 9) | (1 << 6));
856 IXGBE_WRITE_REG(hw, IXGBE_GHECCR, gheccr); 853 IXGBE_WRITE_REG(hw, IXGBE_GHECCR, gheccr);
diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_82599.c b/drivers/net/ethernet/intel/ixgbe/ixgbe_82599.c
index f193fc2f28fb..a5ff4358357c 100644
--- a/drivers/net/ethernet/intel/ixgbe/ixgbe_82599.c
+++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_82599.c
@@ -904,11 +904,10 @@ static s32 ixgbe_setup_copper_link_82599(struct ixgbe_hw *hw,
904 **/ 904 **/
905static s32 ixgbe_reset_hw_82599(struct ixgbe_hw *hw) 905static s32 ixgbe_reset_hw_82599(struct ixgbe_hw *hw)
906{ 906{
907 s32 status = 0; 907 ixgbe_link_speed link_speed;
908 u32 ctrl; 908 s32 status;
909 u32 i; 909 u32 ctrl, i, autoc, autoc2;
910 u32 autoc; 910 bool link_up = false;
911 u32 autoc2;
912 911
913 /* Call adapter stop to disable tx/rx and clear interrupts */ 912 /* Call adapter stop to disable tx/rx and clear interrupts */
914 hw->mac.ops.stop_adapter(hw); 913 hw->mac.ops.stop_adapter(hw);
@@ -942,40 +941,47 @@ static s32 ixgbe_reset_hw_82599(struct ixgbe_hw *hw)
942 941
943mac_reset_top: 942mac_reset_top:
944 /* 943 /*
945 * Issue global reset to the MAC. This needs to be a SW reset. 944 * Issue global reset to the MAC. Needs to be SW reset if link is up.
946 * If link reset is used, it might reset the MAC when mng is using it 945 * If link reset is used when link is up, it might reset the PHY when
946 * mng is using it. If link is down or the flag to force full link
947 * reset is set, then perform link reset.
947 */ 948 */
948 ctrl = IXGBE_READ_REG(hw, IXGBE_CTRL); 949 ctrl = IXGBE_CTRL_LNK_RST;
949 IXGBE_WRITE_REG(hw, IXGBE_CTRL, (ctrl | IXGBE_CTRL_RST)); 950 if (!hw->force_full_reset) {
951 hw->mac.ops.check_link(hw, &link_speed, &link_up, false);
952 if (link_up)
953 ctrl = IXGBE_CTRL_RST;
954 }
955
956 ctrl |= IXGBE_READ_REG(hw, IXGBE_CTRL);
957 IXGBE_WRITE_REG(hw, IXGBE_CTRL, ctrl);
950 IXGBE_WRITE_FLUSH(hw); 958 IXGBE_WRITE_FLUSH(hw);
951 959
952 /* Poll for reset bit to self-clear indicating reset is complete */ 960 /* Poll for reset bit to self-clear indicating reset is complete */
953 for (i = 0; i < 10; i++) { 961 for (i = 0; i < 10; i++) {
954 udelay(1); 962 udelay(1);
955 ctrl = IXGBE_READ_REG(hw, IXGBE_CTRL); 963 ctrl = IXGBE_READ_REG(hw, IXGBE_CTRL);
956 if (!(ctrl & IXGBE_CTRL_RST)) 964 if (!(ctrl & IXGBE_CTRL_RST_MASK))
957 break; 965 break;
958 } 966 }
959 if (ctrl & IXGBE_CTRL_RST) { 967
968 if (ctrl & IXGBE_CTRL_RST_MASK) {
960 status = IXGBE_ERR_RESET_FAILED; 969 status = IXGBE_ERR_RESET_FAILED;
961 hw_dbg(hw, "Reset polling failed to complete.\n"); 970 hw_dbg(hw, "Reset polling failed to complete.\n");
962 } 971 }
963 972
973 msleep(50);
974
964 /* 975 /*
965 * Double resets are required for recovery from certain error 976 * Double resets are required for recovery from certain error
966 * conditions. Between resets, it is necessary to stall to allow time 977 * conditions. Between resets, it is necessary to stall to allow time
967 * for any pending HW events to complete. We use 1usec since that is 978 * for any pending HW events to complete.
968 * what is needed for ixgbe_disable_pcie_master(). The second reset
969 * then clears out any effects of those events.
970 */ 979 */
971 if (hw->mac.flags & IXGBE_FLAGS_DOUBLE_RESET_REQUIRED) { 980 if (hw->mac.flags & IXGBE_FLAGS_DOUBLE_RESET_REQUIRED) {
972 hw->mac.flags &= ~IXGBE_FLAGS_DOUBLE_RESET_REQUIRED; 981 hw->mac.flags &= ~IXGBE_FLAGS_DOUBLE_RESET_REQUIRED;
973 udelay(1);
974 goto mac_reset_top; 982 goto mac_reset_top;
975 } 983 }
976 984
977 msleep(50);
978
979 /* 985 /*
980 * Store the original AUTOC/AUTOC2 values if they have not been 986 * Store the original AUTOC/AUTOC2 values if they have not been
981 * stored off yet. Otherwise restore the stored original 987 * stored off yet. Otherwise restore the stored original
diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_type.h b/drivers/net/ethernet/intel/ixgbe/ixgbe_type.h
index 9f618ee7d333..a9f8839bffb9 100644
--- a/drivers/net/ethernet/intel/ixgbe/ixgbe_type.h
+++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_type.h
@@ -982,6 +982,7 @@
982#define IXGBE_CTRL_GIO_DIS 0x00000004 /* Global IO Master Disable bit */ 982#define IXGBE_CTRL_GIO_DIS 0x00000004 /* Global IO Master Disable bit */
983#define IXGBE_CTRL_LNK_RST 0x00000008 /* Link Reset. Resets everything. */ 983#define IXGBE_CTRL_LNK_RST 0x00000008 /* Link Reset. Resets everything. */
984#define IXGBE_CTRL_RST 0x04000000 /* Reset (SW) */ 984#define IXGBE_CTRL_RST 0x04000000 /* Reset (SW) */
985#define IXGBE_CTRL_RST_MASK (IXGBE_CTRL_LNK_RST | IXGBE_CTRL_RST)
985 986
986/* FACTPS */ 987/* FACTPS */
987#define IXGBE_FACTPS_LFS 0x40000000 /* LAN Function Select */ 988#define IXGBE_FACTPS_LFS 0x40000000 /* LAN Function Select */
diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_x540.c b/drivers/net/ethernet/intel/ixgbe/ixgbe_x540.c
index 2696c78e9f46..bbfe8c40a784 100644
--- a/drivers/net/ethernet/intel/ixgbe/ixgbe_x540.c
+++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_x540.c
@@ -94,13 +94,8 @@ static s32 ixgbe_setup_mac_link_X540(struct ixgbe_hw *hw,
94static s32 ixgbe_reset_hw_X540(struct ixgbe_hw *hw) 94static s32 ixgbe_reset_hw_X540(struct ixgbe_hw *hw)
95{ 95{
96 ixgbe_link_speed link_speed; 96 ixgbe_link_speed link_speed;
97 s32 status = 0; 97 s32 status;
98 u32 ctrl; 98 u32 ctrl, i;
99 u32 ctrl_ext;
100 u32 reset_bit;
101 u32 i;
102 u32 autoc;
103 u32 autoc2;
104 bool link_up = false; 99 bool link_up = false;
105 100
106 /* Call adapter stop to disable tx/rx and clear interrupts */ 101 /* Call adapter stop to disable tx/rx and clear interrupts */
@@ -119,53 +114,42 @@ mac_reset_top:
119 * mng is using it. If link is down or the flag to force full link 114 * mng is using it. If link is down or the flag to force full link
120 * reset is set, then perform link reset. 115 * reset is set, then perform link reset.
121 */ 116 */
122 if (hw->force_full_reset) { 117 ctrl = IXGBE_CTRL_LNK_RST;
123 reset_bit = IXGBE_CTRL_LNK_RST; 118 if (!hw->force_full_reset) {
124 } else {
125 hw->mac.ops.check_link(hw, &link_speed, &link_up, false); 119 hw->mac.ops.check_link(hw, &link_speed, &link_up, false);
126 if (!link_up) 120 if (link_up)
127 reset_bit = IXGBE_CTRL_LNK_RST; 121 ctrl = IXGBE_CTRL_RST;
128 else
129 reset_bit = IXGBE_CTRL_RST;
130 } 122 }
131 123
132 ctrl = IXGBE_READ_REG(hw, IXGBE_CTRL); 124 ctrl |= IXGBE_READ_REG(hw, IXGBE_CTRL);
133 IXGBE_WRITE_REG(hw, IXGBE_CTRL, (ctrl | reset_bit)); 125 IXGBE_WRITE_REG(hw, IXGBE_CTRL, ctrl);
134 IXGBE_WRITE_FLUSH(hw); 126 IXGBE_WRITE_FLUSH(hw);
135 127
136 /* Poll for reset bit to self-clear indicating reset is complete */ 128 /* Poll for reset bit to self-clear indicating reset is complete */
137 for (i = 0; i < 10; i++) { 129 for (i = 0; i < 10; i++) {
138 udelay(1); 130 udelay(1);
139 ctrl = IXGBE_READ_REG(hw, IXGBE_CTRL); 131 ctrl = IXGBE_READ_REG(hw, IXGBE_CTRL);
140 if (!(ctrl & reset_bit)) 132 if (!(ctrl & IXGBE_CTRL_RST_MASK))
141 break; 133 break;
142 } 134 }
143 if (ctrl & reset_bit) { 135
136 if (ctrl & IXGBE_CTRL_RST_MASK) {
144 status = IXGBE_ERR_RESET_FAILED; 137 status = IXGBE_ERR_RESET_FAILED;
145 hw_dbg(hw, "Reset polling failed to complete.\n"); 138 hw_dbg(hw, "Reset polling failed to complete.\n");
146 } 139 }
147 140
141 msleep(50);
142
148 /* 143 /*
149 * Double resets are required for recovery from certain error 144 * Double resets are required for recovery from certain error
150 * conditions. Between resets, it is necessary to stall to allow time 145 * conditions. Between resets, it is necessary to stall to allow time
151 * for any pending HW events to complete. We use 1usec since that is 146 * for any pending HW events to complete.
152 * what is needed for ixgbe_disable_pcie_master(). The second reset
153 * then clears out any effects of those events.
154 */ 147 */
155 if (hw->mac.flags & IXGBE_FLAGS_DOUBLE_RESET_REQUIRED) { 148 if (hw->mac.flags & IXGBE_FLAGS_DOUBLE_RESET_REQUIRED) {
156 hw->mac.flags &= ~IXGBE_FLAGS_DOUBLE_RESET_REQUIRED; 149 hw->mac.flags &= ~IXGBE_FLAGS_DOUBLE_RESET_REQUIRED;
157 udelay(1);
158 goto mac_reset_top; 150 goto mac_reset_top;
159 } 151 }
160 152
161 /* Clear PF Reset Done bit so PF/VF Mail Ops can work */
162 ctrl_ext = IXGBE_READ_REG(hw, IXGBE_CTRL_EXT);
163 ctrl_ext |= IXGBE_CTRL_EXT_PFRSTD;
164 IXGBE_WRITE_REG(hw, IXGBE_CTRL_EXT, ctrl_ext);
165 IXGBE_WRITE_FLUSH(hw);
166
167 msleep(50);
168
169 /* Set the Rx packet buffer size. */ 153 /* Set the Rx packet buffer size. */
170 IXGBE_WRITE_REG(hw, IXGBE_RXPBSIZE(0), 384 << IXGBE_RXPBSIZE_SHIFT); 154 IXGBE_WRITE_REG(hw, IXGBE_RXPBSIZE(0), 384 << IXGBE_RXPBSIZE_SHIFT);
171 155
@@ -173,31 +157,6 @@ mac_reset_top:
173 hw->mac.ops.get_mac_addr(hw, hw->mac.perm_addr); 157 hw->mac.ops.get_mac_addr(hw, hw->mac.perm_addr);
174 158
175 /* 159 /*
176 * Store the original AUTOC/AUTOC2 values if they have not been
177 * stored off yet. Otherwise restore the stored original
178 * values since the reset operation sets back to defaults.
179 */
180 autoc = IXGBE_READ_REG(hw, IXGBE_AUTOC);
181 autoc2 = IXGBE_READ_REG(hw, IXGBE_AUTOC2);
182 if (hw->mac.orig_link_settings_stored == false) {
183 hw->mac.orig_autoc = autoc;
184 hw->mac.orig_autoc2 = autoc2;
185 hw->mac.orig_link_settings_stored = true;
186 } else {
187 if (autoc != hw->mac.orig_autoc)
188 IXGBE_WRITE_REG(hw, IXGBE_AUTOC, (hw->mac.orig_autoc |
189 IXGBE_AUTOC_AN_RESTART));
190
191 if ((autoc2 & IXGBE_AUTOC2_UPPER_MASK) !=
192 (hw->mac.orig_autoc2 & IXGBE_AUTOC2_UPPER_MASK)) {
193 autoc2 &= ~IXGBE_AUTOC2_UPPER_MASK;
194 autoc2 |= (hw->mac.orig_autoc2 &
195 IXGBE_AUTOC2_UPPER_MASK);
196 IXGBE_WRITE_REG(hw, IXGBE_AUTOC2, autoc2);
197 }
198 }
199
200 /*
201 * Store MAC address from RAR0, clear receive address registers, and 160 * Store MAC address from RAR0, clear receive address registers, and
202 * clear the multicast table. Also reset num_rar_entries to 128, 161 * clear the multicast table. Also reset num_rar_entries to 128,
203 * since we modify this value when programming the SAN MAC address. 162 * since we modify this value when programming the SAN MAC address.
@@ -205,9 +164,6 @@ mac_reset_top:
205 hw->mac.num_rar_entries = IXGBE_X540_MAX_TX_QUEUES; 164 hw->mac.num_rar_entries = IXGBE_X540_MAX_TX_QUEUES;
206 hw->mac.ops.init_rx_addrs(hw); 165 hw->mac.ops.init_rx_addrs(hw);
207 166
208 /* Store the permanent mac address */
209 hw->mac.ops.get_mac_addr(hw, hw->mac.perm_addr);
210
211 /* Store the permanent SAN mac address */ 167 /* Store the permanent SAN mac address */
212 hw->mac.ops.get_san_mac_addr(hw, hw->mac.san_addr); 168 hw->mac.ops.get_san_mac_addr(hw, hw->mac.san_addr);
213 169