aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPJ Waskiewicz <peter.p.waskiewicz.jr@intel.com>2009-04-09 18:28:33 -0400
committerDavid S. Miller <davem@davemloft.net>2009-04-11 05:48:01 -0400
commit1eb99d5ac44e2a9ac0b2856c579ba4d7cc349ada (patch)
treecc2609d6b53ff31586d2fdbb04c960213fbf118c
parent553b449784e27bb7244c41aa27397d29f213e5a3 (diff)
ixgbe: Update the usage of orig_autoc to be more consistent
The orig_autoc variable tracks the original setting of the autonegotiate state prior to trying a new speed. The usage is inconsistent and not very maintainable. This patch updates the usage to make it more consistent. Signed-off-by: Peter P Waskiewicz Jr <peter.p.waskiewicz.jr@intel.com> Signed-off-by: Jeff Kirsher <jeffrey.t.kirsher@intel.com> Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r--drivers/net/ixgbe/ixgbe_82598.c15
-rw-r--r--drivers/net/ixgbe/ixgbe_82599.c37
2 files changed, 39 insertions, 13 deletions
diff --git a/drivers/net/ixgbe/ixgbe_82598.c b/drivers/net/ixgbe/ixgbe_82598.c
index a8151f25a4d0..361c9d1d0117 100644
--- a/drivers/net/ixgbe/ixgbe_82598.c
+++ b/drivers/net/ixgbe/ixgbe_82598.c
@@ -165,12 +165,19 @@ static s32 ixgbe_get_link_capabilities_82598(struct ixgbe_hw *hw,
165 bool *autoneg) 165 bool *autoneg)
166{ 166{
167 s32 status = 0; 167 s32 status = 0;
168 u32 autoc = 0;
168 169
169 /* 170 /*
170 * Determine link capabilities based on the stored value of AUTOC, 171 * Determine link capabilities based on the stored value of AUTOC,
171 * which represents EEPROM defaults. 172 * which represents EEPROM defaults. If AUTOC value has not been
173 * stored, use the current register value.
172 */ 174 */
173 switch (hw->mac.orig_autoc & IXGBE_AUTOC_LMS_MASK) { 175 if (hw->mac.orig_link_settings_stored)
176 autoc = hw->mac.orig_autoc;
177 else
178 autoc = IXGBE_READ_REG(hw, IXGBE_AUTOC);
179
180 switch (autoc & IXGBE_AUTOC_LMS_MASK) {
174 case IXGBE_AUTOC_LMS_1G_LINK_NO_AN: 181 case IXGBE_AUTOC_LMS_1G_LINK_NO_AN:
175 *speed = IXGBE_LINK_SPEED_1GB_FULL; 182 *speed = IXGBE_LINK_SPEED_1GB_FULL;
176 *autoneg = false; 183 *autoneg = false;
@@ -189,9 +196,9 @@ static s32 ixgbe_get_link_capabilities_82598(struct ixgbe_hw *hw,
189 case IXGBE_AUTOC_LMS_KX4_AN: 196 case IXGBE_AUTOC_LMS_KX4_AN:
190 case IXGBE_AUTOC_LMS_KX4_AN_1G_AN: 197 case IXGBE_AUTOC_LMS_KX4_AN_1G_AN:
191 *speed = IXGBE_LINK_SPEED_UNKNOWN; 198 *speed = IXGBE_LINK_SPEED_UNKNOWN;
192 if (hw->mac.orig_autoc & IXGBE_AUTOC_KX4_SUPP) 199 if (autoc & IXGBE_AUTOC_KX4_SUPP)
193 *speed |= IXGBE_LINK_SPEED_10GB_FULL; 200 *speed |= IXGBE_LINK_SPEED_10GB_FULL;
194 if (hw->mac.orig_autoc & IXGBE_AUTOC_KX_SUPP) 201 if (autoc & IXGBE_AUTOC_KX_SUPP)
195 *speed |= IXGBE_LINK_SPEED_1GB_FULL; 202 *speed |= IXGBE_LINK_SPEED_1GB_FULL;
196 *autoneg = true; 203 *autoneg = true;
197 break; 204 break;
diff --git a/drivers/net/ixgbe/ixgbe_82599.c b/drivers/net/ixgbe/ixgbe_82599.c
index 72a0d27a19af..50b399c1e87f 100644
--- a/drivers/net/ixgbe/ixgbe_82599.c
+++ b/drivers/net/ixgbe/ixgbe_82599.c
@@ -221,8 +221,19 @@ s32 ixgbe_get_link_capabilities_82599(struct ixgbe_hw *hw,
221 bool *negotiation) 221 bool *negotiation)
222{ 222{
223 s32 status = 0; 223 s32 status = 0;
224 u32 autoc = 0;
224 225
225 switch (hw->mac.orig_autoc & IXGBE_AUTOC_LMS_MASK) { 226 /*
227 * Determine link capabilities based on the stored value of AUTOC,
228 * which represents EEPROM defaults. If AUTOC value has not been
229 * stored, use the current register value.
230 */
231 if (hw->mac.orig_link_settings_stored)
232 autoc = hw->mac.orig_autoc;
233 else
234 autoc = IXGBE_READ_REG(hw, IXGBE_AUTOC);
235
236 switch (autoc & IXGBE_AUTOC_LMS_MASK) {
226 case IXGBE_AUTOC_LMS_1G_LINK_NO_AN: 237 case IXGBE_AUTOC_LMS_1G_LINK_NO_AN:
227 *speed = IXGBE_LINK_SPEED_1GB_FULL; 238 *speed = IXGBE_LINK_SPEED_1GB_FULL;
228 *negotiation = false; 239 *negotiation = false;
@@ -246,22 +257,22 @@ s32 ixgbe_get_link_capabilities_82599(struct ixgbe_hw *hw,
246 case IXGBE_AUTOC_LMS_KX4_KX_KR: 257 case IXGBE_AUTOC_LMS_KX4_KX_KR:
247 case IXGBE_AUTOC_LMS_KX4_KX_KR_1G_AN: 258 case IXGBE_AUTOC_LMS_KX4_KX_KR_1G_AN:
248 *speed = IXGBE_LINK_SPEED_UNKNOWN; 259 *speed = IXGBE_LINK_SPEED_UNKNOWN;
249 if (hw->mac.orig_autoc & IXGBE_AUTOC_KR_SUPP) 260 if (autoc & IXGBE_AUTOC_KR_SUPP)
250 *speed |= IXGBE_LINK_SPEED_10GB_FULL; 261 *speed |= IXGBE_LINK_SPEED_10GB_FULL;
251 if (hw->mac.orig_autoc & IXGBE_AUTOC_KX4_SUPP) 262 if (autoc & IXGBE_AUTOC_KX4_SUPP)
252 *speed |= IXGBE_LINK_SPEED_10GB_FULL; 263 *speed |= IXGBE_LINK_SPEED_10GB_FULL;
253 if (hw->mac.orig_autoc & IXGBE_AUTOC_KX_SUPP) 264 if (autoc & IXGBE_AUTOC_KX_SUPP)
254 *speed |= IXGBE_LINK_SPEED_1GB_FULL; 265 *speed |= IXGBE_LINK_SPEED_1GB_FULL;
255 *negotiation = true; 266 *negotiation = true;
256 break; 267 break;
257 268
258 case IXGBE_AUTOC_LMS_KX4_KX_KR_SGMII: 269 case IXGBE_AUTOC_LMS_KX4_KX_KR_SGMII:
259 *speed = IXGBE_LINK_SPEED_100_FULL; 270 *speed = IXGBE_LINK_SPEED_100_FULL;
260 if (hw->mac.orig_autoc & IXGBE_AUTOC_KR_SUPP) 271 if (autoc & IXGBE_AUTOC_KR_SUPP)
261 *speed |= IXGBE_LINK_SPEED_10GB_FULL; 272 *speed |= IXGBE_LINK_SPEED_10GB_FULL;
262 if (hw->mac.orig_autoc & IXGBE_AUTOC_KX4_SUPP) 273 if (autoc & IXGBE_AUTOC_KX4_SUPP)
263 *speed |= IXGBE_LINK_SPEED_10GB_FULL; 274 *speed |= IXGBE_LINK_SPEED_10GB_FULL;
264 if (hw->mac.orig_autoc & IXGBE_AUTOC_KX_SUPP) 275 if (autoc & IXGBE_AUTOC_KX_SUPP)
265 *speed |= IXGBE_LINK_SPEED_1GB_FULL; 276 *speed |= IXGBE_LINK_SPEED_1GB_FULL;
266 *negotiation = true; 277 *negotiation = true;
267 break; 278 break;
@@ -572,6 +583,7 @@ s32 ixgbe_setup_mac_link_speed_82599(struct ixgbe_hw *hw,
572 s32 status = 0; 583 s32 status = 0;
573 u32 autoc = IXGBE_READ_REG(hw, IXGBE_AUTOC); 584 u32 autoc = IXGBE_READ_REG(hw, IXGBE_AUTOC);
574 u32 autoc2 = IXGBE_READ_REG(hw, IXGBE_AUTOC2); 585 u32 autoc2 = IXGBE_READ_REG(hw, IXGBE_AUTOC2);
586 u32 orig_autoc = 0;
575 u32 link_mode = autoc & IXGBE_AUTOC_LMS_MASK; 587 u32 link_mode = autoc & IXGBE_AUTOC_LMS_MASK;
576 u32 pma_pmd_1g = autoc & IXGBE_AUTOC_1G_PMA_PMD_MASK; 588 u32 pma_pmd_1g = autoc & IXGBE_AUTOC_1G_PMA_PMD_MASK;
577 u32 pma_pmd_10g_serial = autoc2 & IXGBE_AUTOC2_10G_SERIAL_PMA_PMD_MASK; 589 u32 pma_pmd_10g_serial = autoc2 & IXGBE_AUTOC2_10G_SERIAL_PMA_PMD_MASK;
@@ -583,6 +595,13 @@ s32 ixgbe_setup_mac_link_speed_82599(struct ixgbe_hw *hw,
583 hw->mac.ops.get_link_capabilities(hw, &link_capabilities, &autoneg); 595 hw->mac.ops.get_link_capabilities(hw, &link_capabilities, &autoneg);
584 speed &= link_capabilities; 596 speed &= link_capabilities;
585 597
598 /* Use stored value (EEPROM defaults) of AUTOC to find KR/KX4 support*/
599 if (hw->mac.orig_link_settings_stored)
600 orig_autoc = hw->mac.orig_autoc;
601 else
602 orig_autoc = autoc;
603
604
586 if (speed == IXGBE_LINK_SPEED_UNKNOWN) { 605 if (speed == IXGBE_LINK_SPEED_UNKNOWN) {
587 status = IXGBE_ERR_LINK_SETUP; 606 status = IXGBE_ERR_LINK_SETUP;
588 } else if (link_mode == IXGBE_AUTOC_LMS_KX4_KX_KR || 607 } else if (link_mode == IXGBE_AUTOC_LMS_KX4_KX_KR ||
@@ -591,9 +610,9 @@ s32 ixgbe_setup_mac_link_speed_82599(struct ixgbe_hw *hw,
591 /* Set KX4/KX/KR support according to speed requested */ 610 /* Set KX4/KX/KR support according to speed requested */
592 autoc &= ~(IXGBE_AUTOC_KX4_KX_SUPP_MASK | IXGBE_AUTOC_KR_SUPP); 611 autoc &= ~(IXGBE_AUTOC_KX4_KX_SUPP_MASK | IXGBE_AUTOC_KR_SUPP);
593 if (speed & IXGBE_LINK_SPEED_10GB_FULL) 612 if (speed & IXGBE_LINK_SPEED_10GB_FULL)
594 if (hw->mac.orig_autoc & IXGBE_AUTOC_KX4_SUPP) 613 if (orig_autoc & IXGBE_AUTOC_KX4_SUPP)
595 autoc |= IXGBE_AUTOC_KX4_SUPP; 614 autoc |= IXGBE_AUTOC_KX4_SUPP;
596 if (hw->mac.orig_autoc & IXGBE_AUTOC_KR_SUPP) 615 if (orig_autoc & IXGBE_AUTOC_KR_SUPP)
597 autoc |= IXGBE_AUTOC_KR_SUPP; 616 autoc |= IXGBE_AUTOC_KR_SUPP;
598 if (speed & IXGBE_LINK_SPEED_1GB_FULL) 617 if (speed & IXGBE_LINK_SPEED_1GB_FULL)
599 autoc |= IXGBE_AUTOC_KX_SUPP; 618 autoc |= IXGBE_AUTOC_KX_SUPP;