Merge branch 'topic/core-cleanup' into for-linus
[safe/jmp/linux-2.6] / drivers / net / e1000e / 82571.c
index c5dc1b3..9015555 100644 (file)
@@ -65,9 +65,11 @@ static s32 e1000_fix_nvm_checksum_82571(struct e1000_hw *hw);
 static void e1000_initialize_hw_bits_82571(struct e1000_hw *hw);
 static s32 e1000_setup_link_82571(struct e1000_hw *hw);
 static void e1000_clear_hw_cntrs_82571(struct e1000_hw *hw);
+static void e1000_clear_vfta_82571(struct e1000_hw *hw);
 static bool e1000_check_mng_mode_82574(struct e1000_hw *hw);
 static s32 e1000_led_on_82574(struct e1000_hw *hw);
 static void e1000_put_hw_semaphore_82571(struct e1000_hw *hw);
+static void e1000_power_down_phy_copper_82571(struct e1000_hw *hw);
 
 /**
  *  e1000_init_phy_params_82571 - Init PHY func ptrs.
@@ -87,6 +89,9 @@ static s32 e1000_init_phy_params_82571(struct e1000_hw *hw)
        phy->autoneg_mask                = AUTONEG_ADVERTISE_SPEED_DEFAULT;
        phy->reset_delay_us              = 100;
 
+       phy->ops.power_up                = e1000_power_up_phy_copper;
+       phy->ops.power_down              = e1000_power_down_phy_copper_82571;
+
        switch (hw->mac.type) {
        case e1000_82571:
        case e1000_82572:
@@ -232,6 +237,8 @@ static s32 e1000_init_mac_params_82571(struct e1000_adapter *adapter)
        /* Set if manageability features are enabled. */
        mac->arc_subsystem_valid = (er32(FWSM) & E1000_FWSM_MODE_MASK)
                        ? true : false;
+       /* Adaptive IFS supported */
+       mac->adaptive_ifs = true;
 
        /* check for link */
        switch (hw->phy.media_type) {
@@ -260,8 +267,14 @@ static s32 e1000_init_mac_params_82571(struct e1000_adapter *adapter)
        }
 
        switch (hw->mac.type) {
+       case e1000_82573:
+               func->set_lan_id = e1000_set_lan_id_single_port;
+               func->check_mng_mode = e1000e_check_mng_mode_generic;
+               func->led_on = e1000e_led_on_generic;
+               break;
        case e1000_82574:
        case e1000_82583:
+               func->set_lan_id = e1000_set_lan_id_single_port;
                func->check_mng_mode = e1000_check_mng_mode_82574;
                func->led_on = e1000_led_on_82574;
                break;
@@ -323,7 +336,6 @@ static s32 e1000_get_variants_82571(struct e1000_adapter *adapter)
        struct e1000_hw *hw = &adapter->hw;
        static int global_quad_port_a; /* global port a indication */
        struct pci_dev *pdev = adapter->pdev;
-       u16 eeprom_data = 0;
        int is_port_b = er32(STATUS) & E1000_STATUS_FUNC_1;
        s32 rc;
 
@@ -374,16 +386,15 @@ static s32 e1000_get_variants_82571(struct e1000_adapter *adapter)
                if (pdev->device == E1000_DEV_ID_82571EB_SERDES_QUAD)
                        adapter->flags &= ~FLAG_HAS_WOL;
                break;
-
        case e1000_82573:
+       case e1000_82574:
+       case e1000_82583:
+               /* Disable ASPM L0s due to hardware errata */
+               e1000e_disable_aspm(adapter->pdev, PCIE_LINK_STATE_L0S);
+
                if (pdev->device == E1000_DEV_ID_82573L) {
-                       if (e1000_read_nvm(&adapter->hw, NVM_INIT_3GIO_3, 1,
-                                      &eeprom_data) < 0)
-                               break;
-                       if (!(eeprom_data & NVM_WORD1A_ASPM_MASK)) {
-                               adapter->flags |= FLAG_HAS_JUMBO_FRAMES;
-                               adapter->max_hw_frame_size = DEFAULT_JUMBO;
-                       }
+                       adapter->flags |= FLAG_HAS_JUMBO_FRAMES;
+                       adapter->max_hw_frame_size = DEFAULT_JUMBO;
                }
                break;
        default:
@@ -693,8 +704,7 @@ static s32 e1000_write_nvm_eewr_82571(struct e1000_hw *hw, u16 offset,
                                      u16 words, u16 *data)
 {
        struct e1000_nvm_info *nvm = &hw->nvm;
-       u32 i;
-       u32 eewr = 0;
+       u32 i, eewr = 0;
        s32 ret_val = 0;
 
        /*
@@ -829,10 +839,7 @@ static s32 e1000_set_d0_lplu_state_82571(struct e1000_hw *hw, bool active)
  **/
 static s32 e1000_reset_hw_82571(struct e1000_hw *hw)
 {
-       u32 ctrl;
-       u32 extcnf_ctrl;
-       u32 ctrl_ext;
-       u32 icr;
+       u32 ctrl, extcnf_ctrl, ctrl_ext, icr;
        s32 ret_val;
        u16 i = 0;
 
@@ -919,9 +926,12 @@ static s32 e1000_reset_hw_82571(struct e1000_hw *hw)
        ew32(IMC, 0xffffffff);
        icr = er32(ICR);
 
-       if (hw->mac.type == e1000_82571 &&
-               hw->dev_spec.e82571.alt_mac_addr_is_present)
-                       e1000e_set_laa_state_82571(hw, true);
+       /* Install any alternate MAC address into RAR0 */
+       ret_val = e1000_check_alt_mac_addr_generic(hw);
+       if (ret_val)
+               return ret_val;
+
+       e1000e_set_laa_state_82571(hw, true);
 
        /* Reinitialize the 82571 serdes link state machine */
        if (hw->phy.media_type == e1000_media_type_internal_serdes)
@@ -941,21 +951,19 @@ static s32 e1000_init_hw_82571(struct e1000_hw *hw)
        struct e1000_mac_info *mac = &hw->mac;
        u32 reg_data;
        s32 ret_val;
-       u16 i;
-       u16 rar_count = mac->rar_entry_count;
+       u16 i, rar_count = mac->rar_entry_count;
 
        e1000_initialize_hw_bits_82571(hw);
 
        /* Initialize identification LED */
        ret_val = e1000e_id_led_init(hw);
-       if (ret_val) {
+       if (ret_val)
                e_dbg("Error initializing identification LED\n");
-               return ret_val;
-       }
+               /* This is not fatal and we should not stop init due to this */
 
        /* Disabling VLAN filtering */
        e_dbg("Initializing the IEEE VLAN\n");
-       e1000e_clear_vfta(hw);
+       mac->ops.clear_vfta(hw);
 
        /* Setup the receive address. */
        /*
@@ -1134,13 +1142,13 @@ static void e1000_initialize_hw_bits_82571(struct e1000_hw *hw)
 }
 
 /**
- *  e1000e_clear_vfta - Clear VLAN filter table
+ *  e1000_clear_vfta_82571 - Clear VLAN filter table
  *  @hw: pointer to the HW structure
  *
  *  Clears the register array which contains the VLAN filter table by
  *  setting all the values to 0.
  **/
-void e1000e_clear_vfta(struct e1000_hw *hw)
+static void e1000_clear_vfta_82571(struct e1000_hw *hw)
 {
        u32 offset;
        u32 vfta_value = 0;
@@ -1224,32 +1232,6 @@ static s32 e1000_led_on_82574(struct e1000_hw *hw)
 }
 
 /**
- *  e1000_update_mc_addr_list_82571 - Update Multicast addresses
- *  @hw: pointer to the HW structure
- *  @mc_addr_list: array of multicast addresses to program
- *  @mc_addr_count: number of multicast addresses to program
- *  @rar_used_count: the first RAR register free to program
- *  @rar_count: total number of supported Receive Address Registers
- *
- *  Updates the Receive Address Registers and Multicast Table Array.
- *  The caller must have a packed mc_addr_list of multicast addresses.
- *  The parameter rar_count will usually be hw->mac.rar_entry_count
- *  unless there are workarounds that change this.
- **/
-static void e1000_update_mc_addr_list_82571(struct e1000_hw *hw,
-                                           u8 *mc_addr_list,
-                                           u32 mc_addr_count,
-                                           u32 rar_used_count,
-                                           u32 rar_count)
-{
-       if (e1000e_get_laa_state_82571(hw))
-               rar_count--;
-
-       e1000e_update_mc_addr_list_generic(hw, mc_addr_list, mc_addr_count,
-                                          rar_used_count, rar_count);
-}
-
-/**
  *  e1000_setup_link_82571 - Setup flow control and link settings
  *  @hw: pointer to the HW structure
  *
@@ -1291,7 +1273,6 @@ static s32 e1000_setup_link_82571(struct e1000_hw *hw)
 static s32 e1000_setup_copper_link_82571(struct e1000_hw *hw)
 {
        u32 ctrl;
-       u32 led_ctrl;
        s32 ret_val;
 
        ctrl = er32(CTRL);
@@ -1306,11 +1287,6 @@ static s32 e1000_setup_copper_link_82571(struct e1000_hw *hw)
                break;
        case e1000_phy_igp_2:
                ret_val = e1000e_copper_link_setup_igp(hw);
-               /* Setup activity LED */
-               led_ctrl = er32(LEDCTL);
-               led_ctrl &= IGP_ACTIVITY_LED_MASK;
-               led_ctrl |= (IGP_ACTIVITY_LED_ENABLE | IGP_LED3_MODE);
-               ew32(LEDCTL, led_ctrl);
                break;
        default:
                return -E1000_ERR_PHY;
@@ -1357,8 +1333,20 @@ static s32 e1000_setup_fiber_serdes_link_82571(struct e1000_hw *hw)
  *  e1000_check_for_serdes_link_82571 - Check for link (Serdes)
  *  @hw: pointer to the HW structure
  *
- *  Checks for link up on the hardware.  If link is not up and we have
- *  a signal, then we need to force link up.
+ *  Reports the link state as up or down.
+ *
+ *  If autonegotiation is supported by the link partner, the link state is
+ *  determined by the result of autonegotiation. This is the most likely case.
+ *  If autonegotiation is not supported by the link partner, and the link
+ *  has a valid signal, force the link up.
+ *
+ *  The link state is represented internally here by 4 states:
+ *
+ *  1) down
+ *  2) autoneg_progress
+ *  3) autoneg_complete (the link successfully autonegotiated)
+ *  4) forced_up (the link has been forced up, it did not autonegotiate)
+ *
  **/
 static s32 e1000_check_for_serdes_link_82571(struct e1000_hw *hw)
 {
@@ -1384,6 +1372,7 @@ static s32 e1000_check_for_serdes_link_82571(struct e1000_hw *hw)
                                 */
                                mac->serdes_link_state =
                                    e1000_serdes_link_autoneg_progress;
+                               mac->serdes_has_link = false;
                                e_dbg("AN_UP     -> AN_PROG\n");
                        }
                break;
@@ -1398,57 +1387,64 @@ static s32 e1000_check_for_serdes_link_82571(struct e1000_hw *hw)
                        if (rxcw & E1000_RXCW_C) {
                                /* Enable autoneg, and unforce link up */
                                ew32(TXCW, mac->txcw);
-                               ew32(CTRL,
-                                   (ctrl & ~E1000_CTRL_SLU));
+                               ew32(CTRL, (ctrl & ~E1000_CTRL_SLU));
                                mac->serdes_link_state =
                                    e1000_serdes_link_autoneg_progress;
+                               mac->serdes_has_link = false;
                                e_dbg("FORCED_UP -> AN_PROG\n");
                        }
                        break;
 
                case e1000_serdes_link_autoneg_progress:
-                       /*
-                        * If the LU bit is set in the STATUS register,
-                        * autoneg has completed sucessfully. If not,
-                        * try foring the link because the far end may be
-                        * available but not capable of autonegotiation.
-                        */
-                       if (status & E1000_STATUS_LU)  {
-                               mac->serdes_link_state =
-                                   e1000_serdes_link_autoneg_complete;
-                               e_dbg("AN_PROG   -> AN_UP\n");
+                       if (rxcw & E1000_RXCW_C) {
+                               /*
+                                * We received /C/ ordered sets, meaning the
+                                * link partner has autonegotiated, and we can
+                                * trust the Link Up (LU) status bit.
+                                */
+                               if (status & E1000_STATUS_LU) {
+                                       mac->serdes_link_state =
+                                           e1000_serdes_link_autoneg_complete;
+                                       e_dbg("AN_PROG   -> AN_UP\n");
+                                       mac->serdes_has_link = true;
+                               } else {
+                                       /* Autoneg completed, but failed. */
+                                       mac->serdes_link_state =
+                                           e1000_serdes_link_down;
+                                       e_dbg("AN_PROG   -> DOWN\n");
+                               }
                        } else {
                                /*
-                                * Disable autoneg, force link up and
-                                * full duplex, and change state to forced
+                                * The link partner did not autoneg.
+                                * Force link up and full duplex, and change
+                                * state to forced.
                                 */
-                               ew32(TXCW,
-                                   (mac->txcw & ~E1000_TXCW_ANE));
+                               ew32(TXCW, (mac->txcw & ~E1000_TXCW_ANE));
                                ctrl |= (E1000_CTRL_SLU | E1000_CTRL_FD);
                                ew32(CTRL, ctrl);
 
                                /* Configure Flow Control after link up. */
-                               ret_val =
-                                   e1000e_config_fc_after_link_up(hw);
+                               ret_val = e1000e_config_fc_after_link_up(hw);
                                if (ret_val) {
                                        e_dbg("Error config flow control\n");
                                        break;
                                }
                                mac->serdes_link_state =
                                    e1000_serdes_link_forced_up;
+                               mac->serdes_has_link = true;
                                e_dbg("AN_PROG   -> FORCED_UP\n");
                        }
-                       mac->serdes_has_link = true;
                        break;
 
                case e1000_serdes_link_down:
                default:
-                       /* The link was down but the receiver has now gained
+                       /*
+                        * The link was down but the receiver has now gained
                         * valid sync, so lets see if we can bring the link
-                        * up. */
+                        * up.
+                        */
                        ew32(TXCW, mac->txcw);
-                       ew32(CTRL,
-                           (ctrl & ~E1000_CTRL_SLU));
+                       ew32(CTRL, (ctrl & ~E1000_CTRL_SLU));
                        mac->serdes_link_state =
                            e1000_serdes_link_autoneg_progress;
                        e_dbg("DOWN      -> AN_PROG\n");
@@ -1461,9 +1457,9 @@ static s32 e1000_check_for_serdes_link_82571(struct e1000_hw *hw)
                        e_dbg("ANYSTATE  -> DOWN\n");
                } else {
                        /*
-                        * We have sync, and can tolerate one
-                        * invalid (IV) codeword before declaring
-                        * link down, so reread to look again
+                        * We have sync, and can tolerate one invalid (IV)
+                        * codeword before declaring link down, so reread
+                        * to look again.
                         */
                        udelay(10);
                        rxcw = er32(RXCW);
@@ -1532,7 +1528,7 @@ bool e1000e_get_laa_state_82571(struct e1000_hw *hw)
  *  @hw: pointer to the HW structure
  *  @state: enable/disable locally administered address
  *
- *  Enable/Disable the current locally administers address state.
+ *  Enable/Disable the current locally administered address state.
  **/
 void e1000e_set_laa_state_82571(struct e1000_hw *hw, bool state)
 {
@@ -1606,6 +1602,51 @@ static s32 e1000_fix_nvm_checksum_82571(struct e1000_hw *hw)
 }
 
 /**
+ *  e1000_read_mac_addr_82571 - Read device MAC address
+ *  @hw: pointer to the HW structure
+ **/
+static s32 e1000_read_mac_addr_82571(struct e1000_hw *hw)
+{
+       s32 ret_val = 0;
+
+       /*
+        * If there's an alternate MAC address place it in RAR0
+        * so that it will override the Si installed default perm
+        * address.
+        */
+       ret_val = e1000_check_alt_mac_addr_generic(hw);
+       if (ret_val)
+               goto out;
+
+       ret_val = e1000_read_mac_addr_generic(hw);
+
+out:
+       return ret_val;
+}
+
+/**
+ * e1000_power_down_phy_copper_82571 - Remove link during PHY power down
+ * @hw: pointer to the HW structure
+ *
+ * In the case of a PHY power down to save power, or to turn off link during a
+ * driver unload, or wake on lan is not enabled, remove the link.
+ **/
+static void e1000_power_down_phy_copper_82571(struct e1000_hw *hw)
+{
+       struct e1000_phy_info *phy = &hw->phy;
+       struct e1000_mac_info *mac = &hw->mac;
+
+       if (!(phy->ops.check_reset_block))
+               return;
+
+       /* If the management interface is not enabled, then power down */
+       if (!(mac->ops.check_mng_mode(hw) || phy->ops.check_reset_block(hw)))
+               e1000_power_down_phy_copper(hw);
+
+       return;
+}
+
+/**
  *  e1000_clear_hw_cntrs_82571 - Clear device specific hardware counters
  *  @hw: pointer to the HW structure
  *
@@ -1658,19 +1699,24 @@ static struct e1000_mac_operations e82571_mac_ops = {
        .cleanup_led            = e1000e_cleanup_led_generic,
        .clear_hw_cntrs         = e1000_clear_hw_cntrs_82571,
        .get_bus_info           = e1000e_get_bus_info_pcie,
+       .set_lan_id             = e1000_set_lan_id_multi_port_pcie,
        /* .get_link_up_info: media type dependent */
        /* .led_on: mac type dependent */
        .led_off                = e1000e_led_off_generic,
-       .update_mc_addr_list    = e1000_update_mc_addr_list_82571,
+       .update_mc_addr_list    = e1000e_update_mc_addr_list_generic,
+       .write_vfta             = e1000_write_vfta_generic,
+       .clear_vfta             = e1000_clear_vfta_82571,
        .reset_hw               = e1000_reset_hw_82571,
        .init_hw                = e1000_init_hw_82571,
        .setup_link             = e1000_setup_link_82571,
        /* .setup_physical_interface: media type dependent */
        .setup_led              = e1000e_setup_led_generic,
+       .read_mac_addr          = e1000_read_mac_addr_82571,
 };
 
 static struct e1000_phy_operations e82_phy_ops_igp = {
        .acquire                = e1000_get_hw_semaphore_82571,
+       .check_polarity         = e1000_check_polarity_igp,
        .check_reset_block      = e1000e_check_reset_block_generic,
        .commit                 = NULL,
        .force_speed_duplex     = e1000e_phy_force_speed_duplex_igp,
@@ -1688,6 +1734,7 @@ static struct e1000_phy_operations e82_phy_ops_igp = {
 
 static struct e1000_phy_operations e82_phy_ops_m88 = {
        .acquire                = e1000_get_hw_semaphore_82571,
+       .check_polarity         = e1000_check_polarity_m88,
        .check_reset_block      = e1000e_check_reset_block_generic,
        .commit                 = e1000e_phy_sw_reset,
        .force_speed_duplex     = e1000e_phy_force_speed_duplex_m88,
@@ -1705,6 +1752,7 @@ static struct e1000_phy_operations e82_phy_ops_m88 = {
 
 static struct e1000_phy_operations e82_phy_ops_bm = {
        .acquire                = e1000_get_hw_semaphore_82571,
+       .check_polarity         = e1000_check_polarity_m88,
        .check_reset_block      = e1000e_check_reset_block_generic,
        .commit                 = e1000e_phy_sw_reset,
        .force_speed_duplex     = e1000e_phy_force_speed_duplex_m88,
@@ -1742,6 +1790,7 @@ struct e1000_info e1000_82571_info = {
                                  | FLAG_RESET_OVERWRITES_LAA /* errata */
                                  | FLAG_TARC_SPEED_MODE_BIT /* errata */
                                  | FLAG_APME_CHECK_PORT_B,
+       .flags2                 = FLAG2_DISABLE_ASPM_L1, /* errata 13 */
        .pba                    = 38,
        .max_hw_frame_size      = DEFAULT_JUMBO,
        .get_variants           = e1000_get_variants_82571,
@@ -1759,6 +1808,7 @@ struct e1000_info e1000_82572_info = {
                                  | FLAG_RX_CSUM_ENABLED
                                  | FLAG_HAS_CTRLEXT_ON_LOAD
                                  | FLAG_TARC_SPEED_MODE_BIT, /* errata */
+       .flags2                 = FLAG2_DISABLE_ASPM_L1, /* errata 13 */
        .pba                    = 38,
        .max_hw_frame_size      = DEFAULT_JUMBO,
        .get_variants           = e1000_get_variants_82571,
@@ -1770,13 +1820,11 @@ struct e1000_info e1000_82572_info = {
 struct e1000_info e1000_82573_info = {
        .mac                    = e1000_82573,
        .flags                  = FLAG_HAS_HW_VLAN_FILTER
-                                 | FLAG_HAS_JUMBO_FRAMES
                                  | FLAG_HAS_WOL
                                  | FLAG_APME_IN_CTRL3
                                  | FLAG_RX_CSUM_ENABLED
                                  | FLAG_HAS_SMART_POWER_DOWN
                                  | FLAG_HAS_AMT
-                                 | FLAG_HAS_ERT
                                  | FLAG_HAS_SWSM_ON_LOAD,
        .pba                    = 20,
        .max_hw_frame_size      = ETH_FRAME_LEN + ETH_FCS_LEN,