igb: update comments for serdes config and update to handle duplex
authorAlexander Duyck <alexander.h.duyck@intel.com>
Mon, 5 Oct 2009 06:31:47 +0000 (06:31 +0000)
committerDavid S. Miller <davem@davemloft.net>
Tue, 6 Oct 2009 21:59:16 +0000 (14:59 -0700)
This update corrects the driver so that it handles duplex for serdes links
correctly instead of just forcing full duplex always.

Signed-off-by: Alexander Duyck <alexander.h.duyck@intel.com>
Signed-off-by: Jeff Kirsher <jeffrey.t.kirsher@intel.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/igb/e1000_82575.c
drivers/net/igb/e1000_82575.h
drivers/net/igb/e1000_hw.h

index b60daf4..5604b3e 100644 (file)
@@ -706,9 +706,7 @@ static s32 igb_check_for_link_82575(struct e1000_hw *hw)
        s32 ret_val;
        u16 speed, duplex;
 
-       /* SGMII link check is done through the PCS register. */
-       if ((hw->phy.media_type != e1000_media_type_copper) ||
-           (igb_sgmii_active_82575(hw))) {
+       if (hw->phy.media_type != e1000_media_type_copper) {
                ret_val = igb_get_pcs_speed_and_duplex_82575(hw, &speed,
                                                             &duplex);
                /*
@@ -723,6 +721,7 @@ static s32 igb_check_for_link_82575(struct e1000_hw *hw)
 
        return ret_val;
 }
+
 /**
  *  igb_get_pcs_speed_and_duplex_82575 - Retrieve current speed/duplex
  *  @hw: pointer to the HW structure
@@ -788,13 +787,23 @@ static s32 igb_get_pcs_speed_and_duplex_82575(struct e1000_hw *hw, u16 *speed,
 void igb_shutdown_serdes_link_82575(struct e1000_hw *hw)
 {
        u32 reg;
+       u16 eeprom_data = 0;
 
        if (hw->phy.media_type != e1000_media_type_internal_serdes ||
            igb_sgmii_active_82575(hw))
                return;
 
-       /* if the management interface is not enabled, then power down */
-       if (!igb_enable_mng_pass_thru(hw)) {
+       if (hw->bus.func == E1000_FUNC_0)
+               hw->nvm.ops.read(hw, NVM_INIT_CONTROL3_PORT_A, 1, &eeprom_data);
+       else if (hw->bus.func == E1000_FUNC_1)
+               hw->nvm.ops.read(hw, NVM_INIT_CONTROL3_PORT_B, 1, &eeprom_data);
+
+       /*
+        * If APM is not enabled in the EEPROM and management interface is
+        * not enabled, then power down.
+        */
+       if (!(eeprom_data & E1000_NVM_APME_82575) &&
+           !igb_enable_mng_pass_thru(hw)) {
                /* Disable PCS to turn off link */
                reg = rd32(E1000_PCS_CFG0);
                reg &= ~E1000_PCS_CFG_PCS_EN;
@@ -1010,10 +1019,13 @@ out:
 }
 
 /**
- *  igb_setup_serdes_link_82575 - Setup link for fiber/serdes
+ *  igb_setup_serdes_link_82575 - Setup link for serdes
  *  @hw: pointer to the HW structure
  *
- *  Configures speed and duplex for fiber and serdes links.
+ *  Configure the physical coding sub-layer (PCS) link.  The PCS link is
+ *  used on copper connections where the serialized gigabit media independent
+ *  interface (sgmii), or serdes fiber is being used.  Configures the link
+ *  for auto-negotiation or forces speed/duplex.
  **/
 static s32 igb_setup_serdes_link_82575(struct e1000_hw *hw)
 {
@@ -1086,18 +1098,27 @@ static s32 igb_setup_serdes_link_82575(struct e1000_hw *hw)
         */
        if (hw->mac.autoneg || igb_sgmii_active_82575(hw)) {
                /* Set PCS register for autoneg */
-               reg |= E1000_PCS_LCTL_FSV_1000 |      /* Force 1000    */
-                      E1000_PCS_LCTL_FDV_FULL |      /* SerDes Full duplex */
-                      E1000_PCS_LCTL_AN_ENABLE |     /* Enable Autoneg */
-                      E1000_PCS_LCTL_AN_RESTART;     /* Restart autoneg */
+               reg |= E1000_PCS_LCTL_FSV_1000 |  /* Force 1000 */
+                      E1000_PCS_LCTL_FDV_FULL |  /* SerDes Full dplx */
+                      E1000_PCS_LCTL_AN_ENABLE | /* Enable Autoneg */
+                      E1000_PCS_LCTL_AN_RESTART; /* Restart autoneg */
                hw_dbg("Configuring Autoneg; PCS_LCTL = 0x%08X\n", reg);
        } else {
-               /* Set PCS register for forced speed */
-               reg |= E1000_PCS_LCTL_FLV_LINK_UP |   /* Force link up */
-                      E1000_PCS_LCTL_FSV_1000 |      /* Force 1000    */
-                      E1000_PCS_LCTL_FDV_FULL |      /* SerDes Full duplex */
-                      E1000_PCS_LCTL_FSD |           /* Force Speed */
-                      E1000_PCS_LCTL_FORCE_LINK;     /* Force Link */
+               /* Check for duplex first */
+               if (hw->mac.forced_speed_duplex & E1000_ALL_FULL_DUPLEX)
+                       reg |= E1000_PCS_LCTL_FDV_FULL;
+
+               /* No need to check for 1000/full since the spec states that
+                * it requires autoneg to be enabled */
+               /* Now set speed */
+               if (hw->mac.forced_speed_duplex & E1000_ALL_100_SPEED)
+                       reg |= E1000_PCS_LCTL_FSV_100;
+
+               /* Force speed and force link */
+               reg |= E1000_PCS_LCTL_FSD |
+                      E1000_PCS_LCTL_FORCE_LINK |
+                      E1000_PCS_LCTL_FLV_LINK_UP;
+
                hw_dbg("Configuring Forced Link; PCS_LCTL = 0x%08X\n", reg);
        }
 
index ebd146f..7be3a0b 100644 (file)
@@ -167,6 +167,7 @@ struct e1000_adv_tx_context_desc {
 #define E1000_DCA_TXCTRL_CPUID_SHIFT 24 /* Tx CPUID now in the last byte */
 #define E1000_DCA_RXCTRL_CPUID_SHIFT 24 /* Rx CPUID now in the last byte */
 
+#define E1000_NVM_APME_82575          0x0400
 #define MAX_NUM_VFS                   8
 
 #define E1000_DTXSWC_VMDQ_LOOPBACK_EN (1 << 31)  /* global VF LB enable */
index 119869b..b1e0c06 100644 (file)
@@ -50,6 +50,7 @@ struct e1000_hw;
 #define E1000_REVISION_2 2
 #define E1000_REVISION_4 4
 
+#define E1000_FUNC_0     0
 #define E1000_FUNC_1     1
 
 enum e1000_mac_type {