i40e: fix offloading of outer checksum for IPIP tunnel
[dpdk.git] / lib / librte_pmd_e1000 / e1000 / e1000_82575.c
index a6187db..25fa672 100644 (file)
@@ -1,6 +1,6 @@
 /*******************************************************************************
 
-Copyright (c) 2001-2012, Intel Corporation
+Copyright (c) 2001-2014, Intel Corporation
 All rights reserved.
 
 Redistribution and use in source and binary forms, with or without
@@ -51,39 +51,39 @@ STATIC void e1000_release_phy_82575(struct e1000_hw *hw);
 STATIC s32  e1000_acquire_nvm_82575(struct e1000_hw *hw);
 STATIC void e1000_release_nvm_82575(struct e1000_hw *hw);
 STATIC s32  e1000_check_for_link_82575(struct e1000_hw *hw);
+STATIC s32  e1000_check_for_link_media_swap(struct e1000_hw *hw);
 STATIC s32  e1000_get_cfg_done_82575(struct e1000_hw *hw);
 STATIC s32  e1000_get_link_up_info_82575(struct e1000_hw *hw, u16 *speed,
-                                         u16 *duplex);
-STATIC s32  e1000_init_hw_82575(struct e1000_hw *hw);
+                                        u16 *duplex);
 STATIC s32  e1000_phy_hw_reset_sgmii_82575(struct e1000_hw *hw);
 STATIC s32  e1000_read_phy_reg_sgmii_82575(struct e1000_hw *hw, u32 offset,
-                                           u16 *data);
+                                          u16 *data);
 STATIC s32  e1000_reset_hw_82575(struct e1000_hw *hw);
 STATIC s32  e1000_reset_hw_82580(struct e1000_hw *hw);
 STATIC s32  e1000_read_phy_reg_82580(struct e1000_hw *hw,
-                                    u32 offset, u16 *data);
+                                    u32 offset, u16 *data);
 STATIC s32  e1000_write_phy_reg_82580(struct e1000_hw *hw,
-                                     u32 offset, u16 data);
+                                     u32 offset, u16 data);
 STATIC s32  e1000_set_d0_lplu_state_82580(struct e1000_hw *hw,
-                                          bool active);
+                                         bool active);
 STATIC s32  e1000_set_d3_lplu_state_82580(struct e1000_hw *hw,
-                                          bool active);
+                                         bool active);
 STATIC s32  e1000_set_d0_lplu_state_82575(struct e1000_hw *hw,
-                                          bool active);
+                                         bool active);
 STATIC s32  e1000_setup_copper_link_82575(struct e1000_hw *hw);
 STATIC s32  e1000_setup_serdes_link_82575(struct e1000_hw *hw);
 STATIC s32  e1000_get_media_type_82575(struct e1000_hw *hw);
 STATIC s32  e1000_set_sfp_media_type_82575(struct e1000_hw *hw);
 STATIC s32  e1000_valid_led_default_82575(struct e1000_hw *hw, u16 *data);
 STATIC s32  e1000_write_phy_reg_sgmii_82575(struct e1000_hw *hw,
-                                            u32 offset, u16 data);
+                                           u32 offset, u16 data);
 STATIC void e1000_clear_hw_cntrs_82575(struct e1000_hw *hw);
 STATIC s32  e1000_acquire_swfw_sync_82575(struct e1000_hw *hw, u16 mask);
-static s32  e1000_get_pcs_speed_and_duplex_82575(struct e1000_hw *hw,
-                                                 u16 *speed, u16 *duplex);
-static s32  e1000_get_phy_id_82575(struct e1000_hw *hw);
+STATIC s32  e1000_get_pcs_speed_and_duplex_82575(struct e1000_hw *hw,
+                                                u16 *speed, u16 *duplex);
+STATIC s32  e1000_get_phy_id_82575(struct e1000_hw *hw);
 STATIC void e1000_release_swfw_sync_82575(struct e1000_hw *hw, u16 mask);
-static bool e1000_sgmii_active_82575(struct e1000_hw *hw);
+STATIC bool e1000_sgmii_active_82575(struct e1000_hw *hw);
 STATIC s32  e1000_reset_init_script_82575(struct e1000_hw *hw);
 STATIC s32  e1000_read_mac_addr_82575(struct e1000_hw *hw);
 STATIC void e1000_config_collision_dist_82575(struct e1000_hw *hw);
@@ -95,9 +95,9 @@ STATIC s32 e1000_reset_mdicnfg_82580(struct e1000_hw *hw);
 STATIC s32 e1000_validate_nvm_checksum_82580(struct e1000_hw *hw);
 STATIC s32 e1000_update_nvm_checksum_82580(struct e1000_hw *hw);
 STATIC s32 e1000_update_nvm_checksum_with_offset(struct e1000_hw *hw,
-                                               u16 offset);
+                                                u16 offset);
 STATIC s32 e1000_validate_nvm_checksum_with_offset(struct e1000_hw *hw,
-                                               u16 offset);
+                                                  u16 offset);
 STATIC s32 e1000_validate_nvm_checksum_i350(struct e1000_hw *hw);
 STATIC s32 e1000_update_nvm_checksum_i350(struct e1000_hw *hw);
 STATIC void e1000_write_vfta_i350(struct e1000_hw *hw, u32 offset, u32 value);
@@ -115,10 +115,11 @@ STATIC void e1000_lower_i2c_clk(struct e1000_hw *hw, u32 *i2cctl);
 STATIC s32 e1000_set_i2c_data(struct e1000_hw *hw, u32 *i2cctl, bool data);
 STATIC bool e1000_get_i2c_data(u32 *i2cctl);
 
-static const u16 e1000_82580_rxpbs_table[] = {
+STATIC const u16 e1000_82580_rxpbs_table[] = {
        36, 72, 144, 1, 2, 4, 8, 16, 35, 70, 140 };
 #define E1000_82580_RXPBS_TABLE_SIZE \
-       (sizeof(e1000_82580_rxpbs_table)/sizeof(u16))
+       (sizeof(e1000_82580_rxpbs_table) / \
+        sizeof(e1000_82580_rxpbs_table[0]))
 
 
 /**
@@ -143,6 +144,7 @@ STATIC bool e1000_sgmii_uses_mdio_82575(struct e1000_hw *hw)
                break;
        case e1000_82580:
        case e1000_i350:
+       case e1000_i354:
        case e1000_i210:
        case e1000_i211:
                reg = E1000_READ_REG(hw, E1000_MDICNFG);
@@ -177,22 +179,22 @@ STATIC s32 e1000_init_phy_params_82575(struct e1000_hw *hw)
        phy->ops.power_up   = e1000_power_up_phy_copper;
        phy->ops.power_down = e1000_power_down_phy_copper_82575;
 
-       phy->autoneg_mask           = AUTONEG_ADVERTISE_SPEED_DEFAULT;
-       phy->reset_delay_us         = 100;
+       phy->autoneg_mask       = AUTONEG_ADVERTISE_SPEED_DEFAULT;
+       phy->reset_delay_us     = 100;
 
-       phy->ops.acquire            = e1000_acquire_phy_82575;
-       phy->ops.check_reset_block  = e1000_check_reset_block_generic;
-       phy->ops.commit             = e1000_phy_sw_reset_generic;
-       phy->ops.get_cfg_done       = e1000_get_cfg_done_82575;
-       phy->ops.release            = e1000_release_phy_82575;
+       phy->ops.acquire        = e1000_acquire_phy_82575;
+       phy->ops.check_reset_block = e1000_check_reset_block_generic;
+       phy->ops.commit         = e1000_phy_sw_reset_generic;
+       phy->ops.get_cfg_done   = e1000_get_cfg_done_82575;
+       phy->ops.release        = e1000_release_phy_82575;
 
        ctrl_ext = E1000_READ_REG(hw, E1000_CTRL_EXT);
 
        if (e1000_sgmii_active_82575(hw)) {
-               phy->ops.reset      = e1000_phy_hw_reset_sgmii_82575;
+               phy->ops.reset = e1000_phy_hw_reset_sgmii_82575;
                ctrl_ext |= E1000_CTRL_I2C_ENA;
        } else {
-               phy->ops.reset      = e1000_phy_hw_reset_generic;
+               phy->ops.reset = e1000_phy_hw_reset_generic;
                ctrl_ext &= ~E1000_CTRL_I2C_ENA;
        }
 
@@ -200,14 +202,15 @@ STATIC s32 e1000_init_phy_params_82575(struct e1000_hw *hw)
        e1000_reset_mdicnfg_82580(hw);
 
        if (e1000_sgmii_active_82575(hw) && !e1000_sgmii_uses_mdio_82575(hw)) {
-               phy->ops.read_reg   = e1000_read_phy_reg_sgmii_82575;
-               phy->ops.write_reg  = e1000_write_phy_reg_sgmii_82575;
+               phy->ops.read_reg = e1000_read_phy_reg_sgmii_82575;
+               phy->ops.write_reg = e1000_write_phy_reg_sgmii_82575;
        } else {
                switch (hw->mac.type) {
                case e1000_82580:
                case e1000_i350:
-               phy->ops.read_reg   = e1000_read_phy_reg_82580;
-               phy->ops.write_reg  = e1000_write_phy_reg_82580;
+               case e1000_i354:
+                       phy->ops.read_reg = e1000_read_phy_reg_82580;
+                       phy->ops.write_reg = e1000_write_phy_reg_82580;
                        break;
                case e1000_i210:
                case e1000_i211:
@@ -215,9 +218,9 @@ STATIC s32 e1000_init_phy_params_82575(struct e1000_hw *hw)
                        phy->ops.write_reg = e1000_write_phy_reg_gs40g;
                        break;
                default:
-               phy->ops.read_reg   = e1000_read_phy_reg_igp;
-               phy->ops.write_reg  = e1000_write_phy_reg_igp;
-       }
+                       phy->ops.read_reg = e1000_read_phy_reg_igp;
+                       phy->ops.write_reg = e1000_write_phy_reg_igp;
+               }
        }
 
        /* Set phy->phy_addr and phy->id. */
@@ -225,42 +228,76 @@ STATIC s32 e1000_init_phy_params_82575(struct e1000_hw *hw)
 
        /* Verify phy id and set remaining function pointers */
        switch (phy->id) {
+       case M88E1543_E_PHY_ID:
+       case M88E1512_E_PHY_ID:
        case I347AT4_E_PHY_ID:
        case M88E1112_E_PHY_ID:
        case M88E1340M_E_PHY_ID:
        case M88E1111_I_PHY_ID:
-               phy->type                   = e1000_phy_m88;
-               phy->ops.check_polarity     = e1000_check_polarity_m88;
-               phy->ops.get_info           = e1000_get_phy_info_m88;
+               phy->type               = e1000_phy_m88;
+               phy->ops.check_polarity = e1000_check_polarity_m88;
+               phy->ops.get_info       = e1000_get_phy_info_m88;
                if (phy->id == I347AT4_E_PHY_ID ||
                    phy->id == M88E1112_E_PHY_ID ||
                    phy->id == M88E1340M_E_PHY_ID)
                        phy->ops.get_cable_length =
                                         e1000_get_cable_length_m88_gen2;
+               else if (phy->id == M88E1543_E_PHY_ID ||
+                        phy->id == M88E1512_E_PHY_ID)
+                       phy->ops.get_cable_length =
+                                        e1000_get_cable_length_m88_gen2;
                else
                        phy->ops.get_cable_length = e1000_get_cable_length_m88;
                phy->ops.force_speed_duplex = e1000_phy_force_speed_duplex_m88;
+               /* Check if this PHY is confgured for media swap. */
+               if (phy->id == M88E1112_E_PHY_ID) {
+                       u16 data;
+
+                       ret_val = phy->ops.write_reg(hw,
+                                                    E1000_M88E1112_PAGE_ADDR,
+                                                    2);
+                       if (ret_val)
+                               goto out;
+
+                       ret_val = phy->ops.read_reg(hw,
+                                                   E1000_M88E1112_MAC_CTRL_1,
+                                                   &data);
+                       if (ret_val)
+                               goto out;
+
+                       data = (data & E1000_M88E1112_MAC_CTRL_1_MODE_MASK) >>
+                              E1000_M88E1112_MAC_CTRL_1_MODE_SHIFT;
+                       if (data == E1000_M88E1112_AUTO_COPPER_SGMII ||
+                           data == E1000_M88E1112_AUTO_COPPER_BASEX)
+                               hw->mac.ops.check_for_link =
+                                               e1000_check_for_link_media_swap;
+               }
+               if (phy->id == M88E1512_E_PHY_ID) {
+                       ret_val = e1000_initialize_M88E1512_phy(hw);
+                       if (ret_val)
+                               goto out;
+               }
                break;
        case IGP03E1000_E_PHY_ID:
        case IGP04E1000_E_PHY_ID:
-               phy->type                   = e1000_phy_igp_3;
-               phy->ops.check_polarity     = e1000_check_polarity_igp;
-               phy->ops.get_info           = e1000_get_phy_info_igp;
-               phy->ops.get_cable_length   = e1000_get_cable_length_igp_2;
+               phy->type = e1000_phy_igp_3;
+               phy->ops.check_polarity = e1000_check_polarity_igp;
+               phy->ops.get_info = e1000_get_phy_info_igp;
+               phy->ops.get_cable_length = e1000_get_cable_length_igp_2;
                phy->ops.force_speed_duplex = e1000_phy_force_speed_duplex_igp;
-               phy->ops.set_d0_lplu_state  = e1000_set_d0_lplu_state_82575;
-               phy->ops.set_d3_lplu_state  = e1000_set_d3_lplu_state_generic;
+               phy->ops.set_d0_lplu_state = e1000_set_d0_lplu_state_82575;
+               phy->ops.set_d3_lplu_state = e1000_set_d3_lplu_state_generic;
                break;
        case I82580_I_PHY_ID:
        case I350_I_PHY_ID:
-               phy->type                   = e1000_phy_82580;
-               phy->ops.check_polarity     = e1000_check_polarity_82577;
+               phy->type = e1000_phy_82580;
+               phy->ops.check_polarity = e1000_check_polarity_82577;
                phy->ops.force_speed_duplex =
                                         e1000_phy_force_speed_duplex_82577;
-               phy->ops.get_cable_length   = e1000_get_cable_length_82577;
-               phy->ops.get_info           = e1000_get_phy_info_82577;
-               phy->ops.set_d0_lplu_state  = e1000_set_d0_lplu_state_82580;
-               phy->ops.set_d3_lplu_state  = e1000_set_d3_lplu_state_82580;
+               phy->ops.get_cable_length = e1000_get_cable_length_82577;
+               phy->ops.get_info = e1000_get_phy_info_82577;
+               phy->ops.set_d0_lplu_state = e1000_set_d0_lplu_state_82580;
+               phy->ops.set_d3_lplu_state = e1000_set_d3_lplu_state_82580;
                break;
        case I210_I_PHY_ID:
                phy->type               = e1000_phy_i210;
@@ -293,7 +330,7 @@ s32 e1000_init_nvm_params_82575(struct e1000_hw *hw)
        DEBUGFUNC("e1000_init_nvm_params_82575");
 
        size = (u16)((eecd & E1000_EECD_SIZE_EX_MASK) >>
-                    E1000_EECD_SIZE_EX_SHIFT);
+                    E1000_EECD_SIZE_EX_SHIFT);
        /*
         * Added to a constant, "size" becomes the left-shift value
         * for setting word_size.
@@ -308,43 +345,44 @@ s32 e1000_init_nvm_params_82575(struct e1000_hw *hw)
 
        nvm->word_size = 1 << size;
        if (hw->mac.type < e1000_i210) {
-       nvm->opcode_bits        = 8;
-       nvm->delay_usec         = 1;
+               nvm->opcode_bits = 8;
+               nvm->delay_usec = 1;
 
-       switch (nvm->override) {
-       case e1000_nvm_override_spi_large:
-               nvm->page_size    = 32;
-               nvm->address_bits = 16;
-               break;
-       case e1000_nvm_override_spi_small:
-               nvm->page_size    = 8;
-               nvm->address_bits = 8;
-               break;
-       default:
-               nvm->page_size    = eecd & E1000_EECD_ADDR_BITS ? 32 : 8;
+               switch (nvm->override) {
+               case e1000_nvm_override_spi_large:
+                       nvm->page_size = 32;
+                       nvm->address_bits = 16;
+                       break;
+               case e1000_nvm_override_spi_small:
+                       nvm->page_size = 8;
+                       nvm->address_bits = 8;
+                       break;
+               default:
+                       nvm->page_size = eecd & E1000_EECD_ADDR_BITS ? 32 : 8;
                        nvm->address_bits = eecd & E1000_EECD_ADDR_BITS ?
                                            16 : 8;
-               break;
-       }
-       if (nvm->word_size == (1 << 15))
-               nvm->page_size = 128;
+                       break;
+               }
+               if (nvm->word_size == (1 << 15))
+                       nvm->page_size = 128;
 
                nvm->type = e1000_nvm_eeprom_spi;
        } else {
                nvm->type = e1000_nvm_flash_hw;
        }
+
        /* Function Pointers */
-       nvm->ops.acquire    = e1000_acquire_nvm_82575;
-       nvm->ops.release    = e1000_release_nvm_82575;
+       nvm->ops.acquire = e1000_acquire_nvm_82575;
+       nvm->ops.release = e1000_release_nvm_82575;
        if (nvm->word_size < (1 << 15))
-               nvm->ops.read    = e1000_read_nvm_eerd;
+               nvm->ops.read = e1000_read_nvm_eerd;
        else
-               nvm->ops.read    = e1000_read_nvm_spi;
+               nvm->ops.read = e1000_read_nvm_spi;
 
-       nvm->ops.write              = e1000_write_nvm_spi;
-       nvm->ops.validate           = e1000_validate_nvm_checksum_generic;
-       nvm->ops.update             = e1000_update_nvm_checksum_generic;
-       nvm->ops.valid_led_default  = e1000_valid_led_default_82575;
+       nvm->ops.write = e1000_write_nvm_spi;
+       nvm->ops.validate = e1000_validate_nvm_checksum_generic;
+       nvm->ops.update = e1000_update_nvm_checksum_generic;
+       nvm->ops.valid_led_default = e1000_valid_led_default_82575;
 
        /* override generic family function pointers for specific descendants */
        switch (hw->mac.type) {
@@ -353,6 +391,7 @@ s32 e1000_init_nvm_params_82575(struct e1000_hw *hw)
                nvm->ops.update = e1000_update_nvm_checksum_82580;
                break;
        case e1000_i350:
+       case e1000_i354:
                nvm->ops.validate = e1000_validate_nvm_checksum_i350;
                nvm->ops.update = e1000_update_nvm_checksum_i350;
                break;
@@ -386,11 +425,16 @@ STATIC s32 e1000_init_mac_params_82575(struct e1000_hw *hw)
                mac->rar_entry_count = E1000_RAR_ENTRIES_82576;
        if (mac->type == e1000_82580)
                mac->rar_entry_count = E1000_RAR_ENTRIES_82580;
-       if (mac->type == e1000_i350) {
+       if (mac->type == e1000_i350 || mac->type == e1000_i354)
                mac->rar_entry_count = E1000_RAR_ENTRIES_I350;
-               /* Enable EEE default settings for i350 */
+
+       /* Enable EEE default settings for EEE supported devices */
+       if (mac->type >= e1000_i350)
                dev_spec->eee_disable = false;
-       }
+
+       /* Allow a single clear of the SW semaphore on I210 and newer */
+       if (mac->type >= e1000_i210)
+               dev_spec->clear_semaphore_once = true;
 
        /* Set if part includes ASF firmware */
        mac->asf_firmware_present = true;
@@ -410,12 +454,15 @@ STATIC s32 e1000_init_mac_params_82575(struct e1000_hw *hw)
        else
        mac->ops.reset_hw = e1000_reset_hw_82575;
        /* hw initialization */
+       if ((mac->type == e1000_i210) || (mac->type == e1000_i211))
+               mac->ops.init_hw = e1000_init_hw_i210;
+       else
        mac->ops.init_hw = e1000_init_hw_82575;
        /* link setup */
        mac->ops.setup_link = e1000_setup_link_generic;
        /* physical interface link setup */
        mac->ops.setup_physical_interface =
-               (hw->phy.media_type == e1000_media_type_copper)
+               (hw->phy.media_type == e1000_media_type_copper)
                ? e1000_setup_copper_link_82575 : e1000_setup_serdes_link_82575;
        /* physical interface shutdown */
        mac->ops.shutdown_serdes = e1000_shutdown_serdes_link_82575;
@@ -429,16 +476,16 @@ STATIC s32 e1000_init_mac_params_82575(struct e1000_hw *hw)
        mac->ops.config_collision_dist = e1000_config_collision_dist_82575;
        /* multicast address update */
        mac->ops.update_mc_addr_list = e1000_update_mc_addr_list_generic;
-       if (mac->type == e1000_i350) {
+       if (hw->mac.type == e1000_i350 || mac->type == e1000_i354) {
                /* writing VFTA */
                mac->ops.write_vfta = e1000_write_vfta_i350;
                /* clearing VFTA */
                mac->ops.clear_vfta = e1000_clear_vfta_i350;
        } else {
-       /* writing VFTA */
-       mac->ops.write_vfta = e1000_write_vfta_generic;
-       /* clearing VFTA */
-       mac->ops.clear_vfta = e1000_clear_vfta_generic;
+               /* writing VFTA */
+               mac->ops.write_vfta = e1000_write_vfta_generic;
+               /* clearing VFTA */
+               mac->ops.clear_vfta = e1000_clear_vfta_generic;
        }
        if (hw->mac.type >= e1000_82580)
                mac->ops.validate_mdi_setting =
@@ -542,7 +589,7 @@ STATIC void e1000_release_phy_82575(struct e1000_hw *hw)
  *  interface and stores the retrieved information in data.
  **/
 STATIC s32 e1000_read_phy_reg_sgmii_82575(struct e1000_hw *hw, u32 offset,
-                                          u16 *data)
+                                         u16 *data)
 {
        s32 ret_val = -E1000_ERR_PARAM;
 
@@ -575,7 +622,7 @@ out:
  *  media independent interface.
  **/
 STATIC s32 e1000_write_phy_reg_sgmii_82575(struct e1000_hw *hw, u32 offset,
-                                           u16 data)
+                                          u16 data)
 {
        s32 ret_val = -E1000_ERR_PARAM;
 
@@ -615,6 +662,10 @@ STATIC s32 e1000_get_phy_id_82575(struct e1000_hw *hw)
 
        DEBUGFUNC("e1000_get_phy_id_82575");
 
+       /* some i354 devices need an extra read for phy id */
+       if (hw->mac.type == e1000_i354)
+               e1000_get_phy_id(hw);
+
        /*
         * For SGMII PHYs, we try the list of possible addresses until
         * we find one that works.  For non-SGMII PHYs
@@ -638,6 +689,7 @@ STATIC s32 e1000_get_phy_id_82575(struct e1000_hw *hw)
                        break;
                case e1000_82580:
                case e1000_i350:
+               case e1000_i354:
                case e1000_i210:
                case e1000_i211:
                        mdic = E1000_READ_REG(hw, E1000_MDICNFG);
@@ -656,7 +708,7 @@ STATIC s32 e1000_get_phy_id_82575(struct e1000_hw *hw)
        /* Power on sgmii phy if it is disabled */
        ctrl_ext = E1000_READ_REG(hw, E1000_CTRL_EXT);
        E1000_WRITE_REG(hw, E1000_CTRL_EXT,
-                       ctrl_ext & ~E1000_CTRL_EXT_SDP3_DATA);
+                       ctrl_ext & ~E1000_CTRL_EXT_SDP3_DATA);
        E1000_WRITE_FLUSH(hw);
        msec_delay(300);
 
@@ -677,7 +729,7 @@ STATIC s32 e1000_get_phy_id_82575(struct e1000_hw *hw)
                                break;
                } else {
                        DEBUGOUT1("PHY address %u was unreadable\n",
-                                 phy->addr);
+                                 phy->addr);
                }
        }
 
@@ -705,6 +757,7 @@ out:
 STATIC s32 e1000_phy_hw_reset_sgmii_82575(struct e1000_hw *hw)
 {
        s32 ret_val = E1000_SUCCESS;
+       struct e1000_phy_info *phy = &hw->phy;
 
        DEBUGFUNC("e1000_phy_hw_reset_sgmii_82575");
 
@@ -727,7 +780,11 @@ STATIC s32 e1000_phy_hw_reset_sgmii_82575(struct e1000_hw *hw)
                goto out;
 
        ret_val = hw->phy.ops.commit(hw);
+       if (ret_val)
+               goto out;
 
+       if (phy->id == M88E1512_E_PHY_ID)
+               ret_val = e1000_initialize_M88E1512_phy(hw);
 out:
        return ret_val;
 }
@@ -763,22 +820,22 @@ STATIC s32 e1000_set_d0_lplu_state_82575(struct e1000_hw *hw, bool active)
        if (active) {
                data |= IGP02E1000_PM_D0_LPLU;
                ret_val = phy->ops.write_reg(hw, IGP02E1000_PHY_POWER_MGMT,
-                                            data);
+                                            data);
                if (ret_val)
                        goto out;
 
                /* When LPLU is enabled, we should disable SmartSpeed */
                ret_val = phy->ops.read_reg(hw, IGP01E1000_PHY_PORT_CONFIG,
-                                           &data);
+                                           &data);
                data &= ~IGP01E1000_PSCFR_SMART_SPEED;
                ret_val = phy->ops.write_reg(hw, IGP01E1000_PHY_PORT_CONFIG,
-                                            data);
+                                            data);
                if (ret_val)
                        goto out;
        } else {
                data &= ~IGP02E1000_PM_D0_LPLU;
                ret_val = phy->ops.write_reg(hw, IGP02E1000_PHY_POWER_MGMT,
-                                            data);
+                                            data);
                /*
                 * LPLU and SmartSpeed are mutually exclusive.  LPLU is used
                 * during Dx states where the power conservation is most
@@ -787,28 +844,28 @@ STATIC s32 e1000_set_d0_lplu_state_82575(struct e1000_hw *hw, bool active)
                 */
                if (phy->smart_speed == e1000_smart_speed_on) {
                        ret_val = phy->ops.read_reg(hw,
-                                                   IGP01E1000_PHY_PORT_CONFIG,
-                                                   &data);
+                                                   IGP01E1000_PHY_PORT_CONFIG,
+                                                   &data);
                        if (ret_val)
                                goto out;
 
                        data |= IGP01E1000_PSCFR_SMART_SPEED;
                        ret_val = phy->ops.write_reg(hw,
-                                                    IGP01E1000_PHY_PORT_CONFIG,
-                                                    data);
+                                                    IGP01E1000_PHY_PORT_CONFIG,
+                                                    data);
                        if (ret_val)
                                goto out;
                } else if (phy->smart_speed == e1000_smart_speed_off) {
                        ret_val = phy->ops.read_reg(hw,
-                                                   IGP01E1000_PHY_PORT_CONFIG,
-                                                   &data);
+                                                   IGP01E1000_PHY_PORT_CONFIG,
+                                                   &data);
                        if (ret_val)
                                goto out;
 
                        data &= ~IGP01E1000_PSCFR_SMART_SPEED;
                        ret_val = phy->ops.write_reg(hw,
-                                                    IGP01E1000_PHY_PORT_CONFIG,
-                                                    data);
+                                                    IGP01E1000_PHY_PORT_CONFIG,
+                                                    data);
                        if (ret_val)
                                goto out;
                }
@@ -859,7 +916,7 @@ STATIC s32 e1000_set_d0_lplu_state_82580(struct e1000_hw *hw, bool active)
                        data |= E1000_82580_PM_SPD;
                else if (phy->smart_speed == e1000_smart_speed_off)
                        data &= ~E1000_82580_PM_SPD;
-               }
+       }
 
        E1000_WRITE_REG(hw, E1000_82580_PHY_POWER_MGMT, data);
        return ret_val;
@@ -902,8 +959,8 @@ s32 e1000_set_d3_lplu_state_82580(struct e1000_hw *hw, bool active)
                else if (phy->smart_speed == e1000_smart_speed_off)
                        data &= ~E1000_82580_PM_SPD;
        } else if ((phy->autoneg_advertised == E1000_ALL_SPEED_DUPLEX) ||
-                  (phy->autoneg_advertised == E1000_ALL_NOT_GIG) ||
-                  (phy->autoneg_advertised == E1000_ALL_10_SPEED)) {
+                  (phy->autoneg_advertised == E1000_ALL_NOT_GIG) ||
+                  (phy->autoneg_advertised == E1000_ALL_10_SPEED)) {
                data |= E1000_82580_PM_D3_LPLU;
                /* When LPLU is enabled, we should disable SmartSpeed */
                data &= ~E1000_82580_PM_SPD;
@@ -1109,7 +1166,7 @@ STATIC s32 e1000_get_cfg_done_82575(struct e1000_hw *hw)
  *  Otherwise, use the generic function to get the link speed and duplex info.
  **/
 STATIC s32 e1000_get_link_up_info_82575(struct e1000_hw *hw, u16 *speed,
-                                        u16 *duplex)
+                                       u16 *duplex)
 {
        s32 ret_val;
 
@@ -1117,10 +1174,10 @@ STATIC s32 e1000_get_link_up_info_82575(struct e1000_hw *hw, u16 *speed,
 
        if (hw->phy.media_type != e1000_media_type_copper)
                ret_val = e1000_get_pcs_speed_and_duplex_82575(hw, speed,
-                                                              duplex);
+                                                              duplex);
        else
                ret_val = e1000_get_speed_and_duplex_copper_generic(hw, speed,
-                                                                   duplex);
+                                                                   duplex);
 
        return ret_val;
 }
@@ -1141,7 +1198,7 @@ STATIC s32 e1000_check_for_link_82575(struct e1000_hw *hw)
 
        if (hw->phy.media_type != e1000_media_type_copper) {
                ret_val = e1000_get_pcs_speed_and_duplex_82575(hw, &speed,
-                                                              &duplex);
+                                                              &duplex);
                /*
                 * Use this flag to determine if link needs to be checked or
                 * not.  If we have link clear the flag so that we do not
@@ -1165,6 +1222,61 @@ STATIC s32 e1000_check_for_link_82575(struct e1000_hw *hw)
        return ret_val;
 }
 
+/**
+ *  e1000_check_for_link_media_swap - Check which M88E1112 interface linked
+ *  @hw: pointer to the HW structure
+ *
+ *  Poll the M88E1112 interfaces to see which interface achieved link.
+ */
+STATIC s32 e1000_check_for_link_media_swap(struct e1000_hw *hw)
+{
+       struct e1000_phy_info *phy = &hw->phy;
+       s32 ret_val;
+       u16 data;
+       u8 port = 0;
+
+       DEBUGFUNC("e1000_check_for_link_media_swap");
+
+       /* Check the copper medium. */
+       ret_val = phy->ops.write_reg(hw, E1000_M88E1112_PAGE_ADDR, 0);
+       if (ret_val)
+               return ret_val;
+
+       ret_val = phy->ops.read_reg(hw, E1000_M88E1112_STATUS, &data);
+       if (ret_val)
+               return ret_val;
+
+       if (data & E1000_M88E1112_STATUS_LINK)
+               port = E1000_MEDIA_PORT_COPPER;
+
+       /* Check the other medium. */
+       ret_val = phy->ops.write_reg(hw, E1000_M88E1112_PAGE_ADDR, 1);
+       if (ret_val)
+               return ret_val;
+
+       ret_val = phy->ops.read_reg(hw, E1000_M88E1112_STATUS, &data);
+       if (ret_val)
+               return ret_val;
+
+       /* reset page to 0 */
+       ret_val = phy->ops.write_reg(hw, E1000_M88E1112_PAGE_ADDR, 0);
+       if (ret_val)
+               return ret_val;
+
+       if (data & E1000_M88E1112_STATUS_LINK)
+               port = E1000_MEDIA_PORT_OTHER;
+
+       /* Determine if a swap needs to happen. */
+       if (port && (hw->dev_spec._82575.media_port != port)) {
+               hw->dev_spec._82575.media_port = port;
+               hw->dev_spec._82575.media_changed = true;
+       } else {
+               ret_val = e1000_check_for_link_82575(hw);
+       }
+
+       return E1000_SUCCESS;
+}
+
 /**
  *  e1000_power_up_serdes_link_82575 - Power up the serdes link after shutdown
  *  @hw: pointer to the HW structure
@@ -1203,11 +1315,12 @@ STATIC void e1000_power_up_serdes_link_82575(struct e1000_hw *hw)
  *  Using the physical coding sub-layer (PCS), retrieve the current speed and
  *  duplex, then store the values in the pointers provided.
  **/
-static s32 e1000_get_pcs_speed_and_duplex_82575(struct e1000_hw *hw,
-                                                u16 *speed, u16 *duplex)
+STATIC s32 e1000_get_pcs_speed_and_duplex_82575(struct e1000_hw *hw,
+                                               u16 *speed, u16 *duplex)
 {
        struct e1000_mac_info *mac = &hw->mac;
        u32 pcs;
+       u32 status;
 
        DEBUGFUNC("e1000_get_pcs_speed_and_duplex_82575");
 
@@ -1238,11 +1351,23 @@ static s32 e1000_get_pcs_speed_and_duplex_82575(struct e1000_hw *hw,
                else
                        *duplex = HALF_DUPLEX;
 
+               /* Check if it is an I354 2.5Gb backplane connection. */
+               if (mac->type == e1000_i354) {
+                       status = E1000_READ_REG(hw, E1000_STATUS);
+                       if ((status & E1000_STATUS_2P5_SKU) &&
+                           !(status & E1000_STATUS_2P5_SKU_OVER)) {
+                               *speed = SPEED_2500;
+                               *duplex = FULL_DUPLEX;
+                               DEBUGOUT("2500 Mbs, ");
+                               DEBUGOUT("Full Duplex\n");
+                       }
+               }
+
        } else {
                mac->serdes_has_link = false;
                *speed = 0;
                *duplex = 0;
-               }
+       }
 
        return E1000_SUCCESS;
 }
@@ -1353,7 +1478,7 @@ STATIC s32 e1000_reset_hw_82575(struct e1000_hw *hw)
  *
  *  This inits the hardware readying it for operation.
  **/
-STATIC s32 e1000_init_hw_82575(struct e1000_hw *hw)
+s32 e1000_init_hw_82575(struct e1000_hw *hw)
 {
        struct e1000_mac_info *mac = &hw->mac;
        s32 ret_val;
@@ -1413,7 +1538,7 @@ STATIC s32 e1000_init_hw_82575(struct e1000_hw *hw)
 STATIC s32 e1000_setup_copper_link_82575(struct e1000_hw *hw)
 {
        u32 ctrl;
-       s32  ret_val;
+       s32 ret_val;
        u32 phpm_reg;
 
        DEBUGFUNC("e1000_setup_copper_link_82575");
@@ -1423,11 +1548,18 @@ STATIC s32 e1000_setup_copper_link_82575(struct e1000_hw *hw)
        ctrl &= ~(E1000_CTRL_FRCSPD | E1000_CTRL_FRCDPX);
        E1000_WRITE_REG(hw, E1000_CTRL, ctrl);
 
-       /* Clear Go Link Disconnect bit */
-       if (hw->mac.type >= e1000_82580) {
+       /* Clear Go Link Disconnect bit on supported devices */
+       switch (hw->mac.type) {
+       case e1000_82580:
+       case e1000_i350:
+       case e1000_i210:
+       case e1000_i211:
                phpm_reg = E1000_READ_REG(hw, E1000_82580_PHY_POWER_MGMT);
                phpm_reg &= ~E1000_82580_PM_GO_LINKD;
                E1000_WRITE_REG(hw, E1000_82580_PHY_POWER_MGMT, phpm_reg);
+               break;
+       default:
+               break;
        }
 
        ret_val = e1000_setup_serdes_link_82575(hw);
@@ -1447,12 +1579,19 @@ STATIC s32 e1000_setup_copper_link_82575(struct e1000_hw *hw)
        switch (hw->phy.type) {
        case e1000_phy_i210:
        case e1000_phy_m88:
-               if (hw->phy.id == I347AT4_E_PHY_ID ||
-                   hw->phy.id == M88E1112_E_PHY_ID ||
-                   hw->phy.id == M88E1340M_E_PHY_ID)
+               switch (hw->phy.id) {
+               case I347AT4_E_PHY_ID:
+               case M88E1112_E_PHY_ID:
+               case M88E1340M_E_PHY_ID:
+               case M88E1543_E_PHY_ID:
+               case M88E1512_E_PHY_ID:
+               case I210_I_PHY_ID:
                        ret_val = e1000_copper_link_setup_m88_gen2(hw);
-               else
+                       break;
+               default:
                        ret_val = e1000_copper_link_setup_m88(hw);
+                       break;
+               }
                break;
        case e1000_phy_igp_3:
                ret_val = e1000_copper_link_setup_igp(hw);
@@ -1550,7 +1689,7 @@ STATIC s32 e1000_setup_serdes_link_82575(struct e1000_hw *hw)
                 * link either autoneg or be forced to 1000/Full
                 */
                ctrl_reg |= E1000_CTRL_SPD_1000 | E1000_CTRL_FRCSPD |
-                           E1000_CTRL_FD | E1000_CTRL_FRCDPX;
+                           E1000_CTRL_FD | E1000_CTRL_FRCDPX;
 
                /* set speed of 1000/Full if speed/duplex is forced */
                reg |= E1000_PCS_LCTL_FSV_1000 | E1000_PCS_LCTL_FDV_FULL;
@@ -1566,7 +1705,7 @@ STATIC s32 e1000_setup_serdes_link_82575(struct e1000_hw *hw)
         * However, both are supported by the hardware and some drivers/tools.
         */
        reg &= ~(E1000_PCS_LCTL_AN_ENABLE | E1000_PCS_LCTL_FLV_LINK_UP |
-                E1000_PCS_LCTL_FSD | E1000_PCS_LCTL_FORCE_LINK);
+                E1000_PCS_LCTL_FSD | E1000_PCS_LCTL_FORCE_LINK);
 
        if (pcs_autoneg) {
                /* Set PCS register for autoneg */
@@ -1598,7 +1737,7 @@ STATIC s32 e1000_setup_serdes_link_82575(struct e1000_hw *hw)
                DEBUGOUT1("Configuring Autoneg:PCS_LCTL=0x%08X\n", reg);
        } else {
                /* Set PCS register for forced link */
-               reg |= E1000_PCS_LCTL_FSD;        /* Force Speed */
+               reg |= E1000_PCS_LCTL_FSD;      /* Force Speed */
 
                /* Force flow control for forced link */
                reg |= E1000_PCS_LCTL_FORCE_FCTRL;
@@ -1627,140 +1766,70 @@ STATIC s32 e1000_setup_serdes_link_82575(struct e1000_hw *hw)
  **/
 STATIC s32 e1000_get_media_type_82575(struct e1000_hw *hw)
 {
-       u32 lan_id = 0;
-       s32 ret_val = E1000_ERR_CONFIG;
        struct e1000_dev_spec_82575 *dev_spec = &hw->dev_spec._82575;
+       s32 ret_val = E1000_SUCCESS;
        u32 ctrl_ext = 0;
-       u32 current_link_mode = 0;
-       u16 init_ctrl_wd_3 = 0;
-       u8 init_ctrl_wd_3_offset = 0;
-       u8 init_ctrl_wd_3_bit_offset = 0;
+       u32 link_mode = 0;
 
        /* Set internal phy as default */
        dev_spec->sgmii_active = false;
        dev_spec->module_plugged = false;
 
-       /*
-        * Check if NVM access method is attached already.
-        * If it is then Init Control Word #3 is considered
-        * otherwise runtime CSR register content is taken.
-        */
-
        /* Get CSR setting */
        ctrl_ext = E1000_READ_REG(hw, E1000_CTRL_EXT);
 
-       /* Get link mode setting */
-       if ((hw->nvm.ops.read) && (hw->nvm.ops.read != e1000_null_read_nvm)) {
-               /* Take link mode from EEPROM */
-
-               /*
-                * Get LAN port ID to derive its
-                * adequate Init Control Word #3
-                */
-               lan_id = ((E1000_READ_REG(hw, E1000_STATUS) &
-                     E1000_STATUS_LAN_ID_MASK) >> E1000_STATUS_LAN_ID_OFFSET);
-               /*
-                * Derive Init Control Word #3 offset
-                * and mask to pick up link mode setting.
-                */
-               if (hw->mac.type < e1000_82580) {
-                       init_ctrl_wd_3_offset = lan_id ?
-                          NVM_INIT_CONTROL3_PORT_A : NVM_INIT_CONTROL3_PORT_B;
-                       init_ctrl_wd_3_bit_offset = NVM_WORD24_LNK_MODE_OFFSET;
-               } else {
-                       init_ctrl_wd_3_offset =
-                                           NVM_82580_LAN_FUNC_OFFSET(lan_id) +
-                                           NVM_INIT_CONTROL3_PORT_A;
-                       init_ctrl_wd_3_bit_offset =
-                                             NVM_WORD24_82580_LNK_MODE_OFFSET;
-               }
-               /* Read Init Control Word #3*/
-               hw->nvm.ops.read(hw, init_ctrl_wd_3_offset, 1, &init_ctrl_wd_3);
-
-               /*
-                * Align link mode bits to
-                * their CTRL_EXT location.
-                */
-               current_link_mode = init_ctrl_wd_3;
-               current_link_mode <<= (E1000_CTRL_EXT_LINK_MODE_OFFSET -
-                                      init_ctrl_wd_3_bit_offset);
-               current_link_mode &= E1000_CTRL_EXT_LINK_MODE_MASK;
-
-               /*
-                * Switch to CSR for all but internal PHY.
-                */
-               if (current_link_mode != E1000_CTRL_EXT_LINK_MODE_GMII)
-                       /* Take link mode from CSR */
-                       current_link_mode = ctrl_ext &
-                                           E1000_CTRL_EXT_LINK_MODE_MASK;
-       } else {
-               /* Take link mode from CSR */
-               current_link_mode = ctrl_ext & E1000_CTRL_EXT_LINK_MODE_MASK;
-       }
-
-       switch (current_link_mode) {
+       /* extract link mode setting */
+       link_mode = ctrl_ext & E1000_CTRL_EXT_LINK_MODE_MASK;
 
+       switch (link_mode) {
        case E1000_CTRL_EXT_LINK_MODE_1000BASE_KX:
                hw->phy.media_type = e1000_media_type_internal_serdes;
-               current_link_mode = E1000_CTRL_EXT_LINK_MODE_1000BASE_KX;
                break;
        case E1000_CTRL_EXT_LINK_MODE_GMII:
                hw->phy.media_type = e1000_media_type_copper;
-               current_link_mode = E1000_CTRL_EXT_LINK_MODE_GMII;
                break;
        case E1000_CTRL_EXT_LINK_MODE_SGMII:
-       case E1000_CTRL_EXT_LINK_MODE_PCIE_SERDES:
                /* Get phy control interface type set (MDIO vs. I2C)*/
                if (e1000_sgmii_uses_mdio_82575(hw)) {
                        hw->phy.media_type = e1000_media_type_copper;
                        dev_spec->sgmii_active = true;
-                       current_link_mode = E1000_CTRL_EXT_LINK_MODE_SGMII;
-               } else {
-                       ret_val = e1000_set_sfp_media_type_82575(hw);
-                       if (ret_val != E1000_SUCCESS)
-                               goto out;
-                       if (hw->phy.media_type ==
-                               e1000_media_type_internal_serdes) {
-                               /* Keep Link Mode as SGMII for 100BaseFX */
-                               if (!dev_spec->eth_flags.e100_base_fx) {
-                                       current_link_mode =
-                                        E1000_CTRL_EXT_LINK_MODE_PCIE_SERDES;
-                               }
-                       } else if (hw->phy.media_type ==
-                               e1000_media_type_copper) {
-                               current_link_mode =
-                                              E1000_CTRL_EXT_LINK_MODE_SGMII;
+                       break;
+               }
+               /* fall through for I2C based SGMII */
+       case E1000_CTRL_EXT_LINK_MODE_PCIE_SERDES:
+               /* read media type from SFP EEPROM */
+               ret_val = e1000_set_sfp_media_type_82575(hw);
+               if ((ret_val != E1000_SUCCESS) ||
+                   (hw->phy.media_type == e1000_media_type_unknown)) {
+                       /*
+                        * If media type was not identified then return media
+                        * type defined by the CTRL_EXT settings.
+                        */
+                       hw->phy.media_type = e1000_media_type_internal_serdes;
+
+                       if (link_mode == E1000_CTRL_EXT_LINK_MODE_SGMII) {
+                               hw->phy.media_type = e1000_media_type_copper;
+                               dev_spec->sgmii_active = true;
                        }
+
+                       break;
                }
-               break;
-       default:
-               DEBUGOUT("Link mode mask doesn't fit bit field size\n");
-               goto out;
-       }
-       /*
-        * Do not change current link mode setting
-        * if media type is fibre or has not been
-        * recognized.
-        */
-       if ((hw->phy.media_type != e1000_media_type_unknown) &&
-           (hw->phy.media_type != e1000_media_type_fiber)) {
-               /* Update link mode */
+
+               /* do not change link mode for 100BaseFX */
+               if (dev_spec->eth_flags.e100_base_fx)
+                       break;
+
+               /* change current link mode setting */
                ctrl_ext &= ~E1000_CTRL_EXT_LINK_MODE_MASK;
-               E1000_WRITE_REG(hw, E1000_CTRL_EXT, ctrl_ext |
-                               current_link_mode);
-       }
 
-       ret_val = E1000_SUCCESS;
-out:
-       /*
-        * If media type was not identified then return media type
-        * defined by the CTRL_EXT settings.
-        */
-       if (hw->phy.media_type == e1000_media_type_unknown) {
-               if (current_link_mode == E1000_CTRL_EXT_LINK_MODE_SGMII)
-                       hw->phy.media_type = e1000_media_type_copper;
+               if (hw->phy.media_type == e1000_media_type_copper)
+                       ctrl_ext |= E1000_CTRL_EXT_LINK_MODE_SGMII;
                else
-                       hw->phy.media_type = e1000_media_type_internal_serdes;
+                       ctrl_ext |= E1000_CTRL_EXT_LINK_MODE_PCIE_SERDES;
+
+               E1000_WRITE_REG(hw, E1000_CTRL_EXT, ctrl_ext);
+
+               break;
        }
 
        return ret_val;
@@ -1801,15 +1870,14 @@ STATIC s32 e1000_set_sfp_media_type_82575(struct e1000_hw *hw)
        }
        if (ret_val != E1000_SUCCESS)
                goto out;
+
        ret_val = e1000_read_sfp_data_byte(hw,
                        E1000_I2CCMD_SFP_DATA_ADDR(E1000_SFF_ETH_FLAGS_OFFSET),
                        (u8 *)eth_flags);
        if (ret_val != E1000_SUCCESS)
                goto out;
-       /*
-        * Check if there is some SFP
-        * module plugged and powered
-        */
+
+       /* Check if there is some SFP module plugged and powered */
        if ((tranceiver_type == E1000_SFF_IDENTIFIER_SFP) ||
            (tranceiver_type == E1000_SFF_IDENTIFIER_SFF)) {
                dev_spec->module_plugged = true;
@@ -1822,9 +1890,9 @@ STATIC s32 e1000_set_sfp_media_type_82575(struct e1000_hw *hw)
                        dev_spec->sgmii_active = true;
                        hw->phy.media_type = e1000_media_type_copper;
                } else {
-                               hw->phy.media_type = e1000_media_type_unknown;
-                               DEBUGOUT("PHY module has not been recognized\n");
-                               goto out;
+                       hw->phy.media_type = e1000_media_type_unknown;
+                       DEBUGOUT("PHY module has not been recognized\n");
+                       goto out;
                }
        } else {
                hw->phy.media_type = e1000_media_type_unknown;
@@ -1879,7 +1947,7 @@ out:
  *  which can be enabled for use in the embedded applications.  Simply
  *  return the current state of the sgmii interface.
  **/
-static bool e1000_sgmii_active_82575(struct e1000_hw *hw)
+STATIC bool e1000_sgmii_active_82575(struct e1000_hw *hw)
 {
        struct e1000_dev_spec_82575 *dev_spec = &hw->dev_spec._82575;
        return dev_spec->sgmii_active;
@@ -1929,7 +1997,7 @@ STATIC s32 e1000_reset_init_script_82575(struct e1000_hw *hw)
  **/
 STATIC s32 e1000_read_mac_addr_82575(struct e1000_hw *hw)
 {
-       s32 ret_val = E1000_SUCCESS;
+       s32 ret_val;
 
        DEBUGFUNC("e1000_read_mac_addr_82575");
 
@@ -2079,7 +2147,7 @@ void e1000_rx_fifo_flush_82575(struct e1000_hw *hw)
        for (i = 0; i < 4; i++) {
                rxdctl[i] = E1000_READ_REG(hw, E1000_RXDCTL(i));
                E1000_WRITE_REG(hw, E1000_RXDCTL(i),
-                               rxdctl[i] & ~E1000_RXDCTL_QUEUE_ENABLE);
+                               rxdctl[i] & ~E1000_RXDCTL_QUEUE_ENABLE);
        }
        /* Poll all queues to verify they have shut down */
        for (ms_wait = 0; ms_wait < 10; ms_wait++) {
@@ -2165,14 +2233,14 @@ STATIC s32 e1000_set_pcie_completion_timeout(struct e1000_hw *hw)
         * 16ms to 55ms
         */
        ret_val = e1000_read_pcie_cap_reg(hw, PCIE_DEVICE_CONTROL2,
-                                         &pcie_devctl2);
+                                         &pcie_devctl2);
        if (ret_val)
                goto out;
 
        pcie_devctl2 |= PCIE_DEVICE_CONTROL2_16ms;
 
        ret_val = e1000_write_pcie_cap_reg(hw, PCIE_DEVICE_CONTROL2,
-                                          &pcie_devctl2);
+                                          &pcie_devctl2);
 out:
        /* disable completion timeout resend */
        gcr &= ~E1000_GCR_CMPL_TMOUT_RESEND;
@@ -2191,42 +2259,33 @@ out:
  **/
 void e1000_vmdq_set_anti_spoofing_pf(struct e1000_hw *hw, bool enable, int pf)
 {
-       u32 dtxswc;
+       u32 reg_val, reg_offset;
 
        switch (hw->mac.type) {
        case e1000_82576:
-               dtxswc = E1000_READ_REG(hw, E1000_DTXSWC);
-               if (enable) {
-                       dtxswc |= (E1000_DTXSWC_MAC_SPOOF_MASK |
-                                  E1000_DTXSWC_VLAN_SPOOF_MASK);
-                       /* The PF can spoof - it has to in order to
-                        * support emulation mode NICs */
-                       dtxswc ^= (1 << pf | 1 << (pf +
-                                  E1000_DTXSWC_VLAN_SPOOF_SHIFT));
-               } else {
-                       dtxswc &= ~(E1000_DTXSWC_MAC_SPOOF_MASK |
-                                   E1000_DTXSWC_VLAN_SPOOF_MASK);
-               }
-               E1000_WRITE_REG(hw, E1000_DTXSWC, dtxswc);
+               reg_offset = E1000_DTXSWC;
                break;
        case e1000_i350:
-               dtxswc = E1000_READ_REG(hw, E1000_TXSWC);
-               if (enable) {
-                       dtxswc |= (E1000_DTXSWC_MAC_SPOOF_MASK |
-                                  E1000_DTXSWC_VLAN_SPOOF_MASK);
-                       /* The PF can spoof - it has to in order to
-                        * support emulation mode NICs
-                        */
-                       dtxswc ^= (1 << pf | 1 << (pf +
-                                  E1000_DTXSWC_VLAN_SPOOF_SHIFT));
-               } else {
-                       dtxswc &= ~(E1000_DTXSWC_MAC_SPOOF_MASK |
-                                   E1000_DTXSWC_VLAN_SPOOF_MASK);
-               }
-               E1000_WRITE_REG(hw, E1000_TXSWC, dtxswc);
-       default:
+       case e1000_i354:
+               reg_offset = E1000_TXSWC;
                break;
+       default:
+               return;
+       }
+
+       reg_val = E1000_READ_REG(hw, reg_offset);
+       if (enable) {
+               reg_val |= (E1000_DTXSWC_MAC_SPOOF_MASK |
+                            E1000_DTXSWC_VLAN_SPOOF_MASK);
+               /* The PF can spoof - it has to in order to
+                * support emulation mode NICs
+                */
+               reg_val ^= (1 << pf | 1 << (pf + MAX_NUM_VFS));
+       } else {
+               reg_val &= ~(E1000_DTXSWC_MAC_SPOOF_MASK |
+                            E1000_DTXSWC_VLAN_SPOOF_MASK);
        }
+       E1000_WRITE_REG(hw, reg_offset, reg_val);
 }
 
 /**
@@ -2250,6 +2309,7 @@ void e1000_vmdq_set_loopback_pf(struct e1000_hw *hw, bool enable)
                E1000_WRITE_REG(hw, E1000_DTXSWC, dtxswc);
                break;
        case e1000_i350:
+       case e1000_i354:
                dtxswc = E1000_READ_REG(hw, E1000_TXSWC);
                if (enable)
                        dtxswc |= E1000_DTXSWC_VMDQ_LOOPBACK_EN;
@@ -2359,8 +2419,8 @@ STATIC s32 e1000_reset_mdicnfg_82580(struct e1000_hw *hw)
                goto out;
 
        ret_val = hw->nvm.ops.read(hw, NVM_INIT_CONTROL3_PORT_A +
-                                  NVM_82580_LAN_FUNC_OFFSET(hw->bus.func), 1,
-                                  &nvm_data);
+                                  NVM_82580_LAN_FUNC_OFFSET(hw->bus.func), 1,
+                                  &nvm_data);
        if (ret_val) {
                DEBUGOUT("NVM Read Error\n");
                goto out;
@@ -2395,6 +2455,10 @@ STATIC s32 e1000_reset_hw_82580(struct e1000_hw *hw)
 
        hw->dev_spec._82575.global_device_reset = false;
 
+       /* 82580 does not reliably do global_device_reset due to hw errata */
+       if (hw->mac.type == e1000_82580)
+               global_device_reset = false;
+
        /* Get current control state. */
        ctrl = E1000_READ_REG(hw, E1000_CTRL);
 
@@ -2442,10 +2506,6 @@ STATIC s32 e1000_reset_hw_82580(struct e1000_hw *hw)
                DEBUGOUT("Auto Read Done did not complete\n");
        }
 
-       /* If EEPROM is not present, run manual init scripts */
-       if (!(E1000_READ_REG(hw, E1000_EECD) & E1000_EECD_PRES))
-               e1000_reset_init_script_82575(hw);
-
        /* clear global device reset status bit */
        E1000_WRITE_REG(hw, E1000_STATUS, E1000_STAT_DEV_RST_SET);
 
@@ -2551,7 +2611,7 @@ s32 e1000_update_nvm_checksum_with_offset(struct e1000_hw *hw, u16 offset)
        }
        checksum = (u16) NVM_SUM - checksum;
        ret_val = hw->nvm.ops.write(hw, (NVM_CHECKSUM_REG + offset), 1,
-                               &checksum);
+                                   &checksum);
        if (ret_val)
                DEBUGOUT("NVM Write Error while updating checksum.\n");
 
@@ -2569,7 +2629,7 @@ out:
  **/
 STATIC s32 e1000_validate_nvm_checksum_82580(struct e1000_hw *hw)
 {
-       s32 ret_val = E1000_SUCCESS;
+       s32 ret_val;
        u16 eeprom_regions_count = 1;
        u16 j, nvm_data;
        u16 nvm_offset;
@@ -2591,7 +2651,7 @@ STATIC s32 e1000_validate_nvm_checksum_82580(struct e1000_hw *hw)
        for (j = 0; j < eeprom_regions_count; j++) {
                nvm_offset = NVM_82580_LAN_FUNC_OFFSET(j);
                ret_val = e1000_validate_nvm_checksum_with_offset(hw,
-                                                               nvm_offset);
+                                                                 nvm_offset);
                if (ret_val != E1000_SUCCESS)
                        goto out;
        }
@@ -2626,7 +2686,7 @@ STATIC s32 e1000_update_nvm_checksum_82580(struct e1000_hw *hw)
                /* set compatibility bit to validate checksums appropriately */
                nvm_data = nvm_data | NVM_COMPATIBILITY_BIT_MASK;
                ret_val = hw->nvm.ops.write(hw, NVM_COMPATIBILITY_REG_3, 1,
-                                       &nvm_data);
+                                           &nvm_data);
                if (ret_val) {
                        DEBUGOUT("NVM Write Error while updating checksum compatibility bit.\n");
                        goto out;
@@ -2638,7 +2698,7 @@ STATIC s32 e1000_update_nvm_checksum_82580(struct e1000_hw *hw)
                ret_val = e1000_update_nvm_checksum_with_offset(hw, nvm_offset);
                if (ret_val)
                        goto out;
-               }
+       }
 
 out:
        return ret_val;
@@ -2663,7 +2723,7 @@ STATIC s32 e1000_validate_nvm_checksum_i350(struct e1000_hw *hw)
        for (j = 0; j < 4; j++) {
                nvm_offset = NVM_82580_LAN_FUNC_OFFSET(j);
                ret_val = e1000_validate_nvm_checksum_with_offset(hw,
-                                                               nvm_offset);
+                                                                 nvm_offset);
                if (ret_val != E1000_SUCCESS)
                        goto out;
        }
@@ -2699,6 +2759,134 @@ out:
        return ret_val;
 }
 
+/**
+ *  __e1000_access_emi_reg - Read/write EMI register
+ *  @hw: pointer to the HW structure
+ *  @addr: EMI address to program
+ *  @data: pointer to value to read/write from/to the EMI address
+ *  @read: boolean flag to indicate read or write
+ **/
+STATIC s32 __e1000_access_emi_reg(struct e1000_hw *hw, u16 address,
+                                 u16 *data, bool read)
+{
+       s32 ret_val;
+
+       DEBUGFUNC("__e1000_access_emi_reg");
+
+       ret_val = hw->phy.ops.write_reg(hw, E1000_EMIADD, address);
+       if (ret_val)
+               return ret_val;
+
+       if (read)
+               ret_val = hw->phy.ops.read_reg(hw, E1000_EMIDATA, data);
+       else
+               ret_val = hw->phy.ops.write_reg(hw, E1000_EMIDATA, *data);
+
+       return ret_val;
+}
+
+/**
+ *  e1000_read_emi_reg - Read Extended Management Interface register
+ *  @hw: pointer to the HW structure
+ *  @addr: EMI address to program
+ *  @data: value to be read from the EMI address
+ **/
+s32 e1000_read_emi_reg(struct e1000_hw *hw, u16 addr, u16 *data)
+{
+       DEBUGFUNC("e1000_read_emi_reg");
+
+       return __e1000_access_emi_reg(hw, addr, data, true);
+}
+
+/**
+ *  e1000_initialize_M88E1512_phy - Initialize M88E1512 PHY
+ *  @hw: pointer to the HW structure
+ *
+ *  Initialize Marverl 1512 to work correctly with Avoton.
+ **/
+s32 e1000_initialize_M88E1512_phy(struct e1000_hw *hw)
+{
+       struct e1000_phy_info *phy = &hw->phy;
+       s32 ret_val = E1000_SUCCESS;
+
+       DEBUGFUNC("e1000_initialize_M88E1512_phy");
+
+       /* Check if this is correct PHY. */
+       if (phy->id != M88E1512_E_PHY_ID)
+               goto out;
+
+       /* Switch to PHY page 0xFF. */
+       ret_val = phy->ops.write_reg(hw, E1000_M88E1543_PAGE_ADDR, 0x00FF);
+       if (ret_val)
+               goto out;
+
+       ret_val = phy->ops.write_reg(hw, E1000_M88E1512_CFG_REG_2, 0x214B);
+       if (ret_val)
+               goto out;
+
+       ret_val = phy->ops.write_reg(hw, E1000_M88E1512_CFG_REG_1, 0x2144);
+       if (ret_val)
+               goto out;
+
+       ret_val = phy->ops.write_reg(hw, E1000_M88E1512_CFG_REG_2, 0x0C28);
+       if (ret_val)
+               goto out;
+
+       ret_val = phy->ops.write_reg(hw, E1000_M88E1512_CFG_REG_1, 0x2146);
+       if (ret_val)
+               goto out;
+
+       ret_val = phy->ops.write_reg(hw, E1000_M88E1512_CFG_REG_2, 0xB233);
+       if (ret_val)
+               goto out;
+
+       ret_val = phy->ops.write_reg(hw, E1000_M88E1512_CFG_REG_1, 0x214D);
+       if (ret_val)
+               goto out;
+
+       ret_val = phy->ops.write_reg(hw, E1000_M88E1512_CFG_REG_2, 0xCC0C);
+       if (ret_val)
+               goto out;
+
+       ret_val = phy->ops.write_reg(hw, E1000_M88E1512_CFG_REG_1, 0x2159);
+       if (ret_val)
+               goto out;
+
+       /* Switch to PHY page 0xFB. */
+       ret_val = phy->ops.write_reg(hw, E1000_M88E1543_PAGE_ADDR, 0x00FB);
+       if (ret_val)
+               goto out;
+
+       ret_val = phy->ops.write_reg(hw, E1000_M88E1512_CFG_REG_3, 0x000D);
+       if (ret_val)
+               goto out;
+
+       /* Switch to PHY page 0x12. */
+       ret_val = phy->ops.write_reg(hw, E1000_M88E1543_PAGE_ADDR, 0x12);
+       if (ret_val)
+               goto out;
+
+       /* Change mode to SGMII-to-Copper */
+       ret_val = phy->ops.write_reg(hw, E1000_M88E1512_MODE, 0x8001);
+       if (ret_val)
+               goto out;
+
+       /* Return the PHY to page 0. */
+       ret_val = phy->ops.write_reg(hw, E1000_M88E1543_PAGE_ADDR, 0);
+       if (ret_val)
+               goto out;
+
+       ret_val = phy->ops.commit(hw);
+       if (ret_val) {
+               DEBUGOUT("Error committing the PHY changes\n");
+               return ret_val;
+       }
+
+       msec_delay(1000);
+out:
+       return ret_val;
+}
+
 /**
  *  e1000_set_eee_i350 - Enable/disable EEE support
  *  @hw: pointer to the HW structure
@@ -2725,7 +2913,7 @@ s32 e1000_set_eee_i350(struct e1000_hw *hw)
 
                ipcnfg |= (E1000_IPCNFG_EEE_1G_AN | E1000_IPCNFG_EEE_100M_AN);
                eeer |= (E1000_EEER_TX_LPI_EN | E1000_EEER_RX_LPI_EN |
-                        E1000_EEER_LPI_FC);
+                        E1000_EEER_LPI_FC);
 
                /* This bit should not be set in normal operation. */
                if (eee_su & E1000_EEE_SU_LPI_CLK_STP)
@@ -2733,14 +2921,122 @@ s32 e1000_set_eee_i350(struct e1000_hw *hw)
        } else {
                ipcnfg &= ~(E1000_IPCNFG_EEE_1G_AN | E1000_IPCNFG_EEE_100M_AN);
                eeer &= ~(E1000_EEER_TX_LPI_EN | E1000_EEER_RX_LPI_EN |
-                         E1000_EEER_LPI_FC);
+                         E1000_EEER_LPI_FC);
        }
        E1000_WRITE_REG(hw, E1000_IPCNFG, ipcnfg);
        E1000_WRITE_REG(hw, E1000_EEER, eeer);
-                       E1000_READ_REG(hw, E1000_IPCNFG);
-                       E1000_READ_REG(hw, E1000_EEER);
+       E1000_READ_REG(hw, E1000_IPCNFG);
+       E1000_READ_REG(hw, E1000_EEER);
+out:
+
+       return ret_val;
+}
+
+/**
+ *  e1000_set_eee_i354 - Enable/disable EEE support
+ *  @hw: pointer to the HW structure
+ *
+ *  Enable/disable EEE legacy mode based on setting in dev_spec structure.
+ *
+ **/
+s32 e1000_set_eee_i354(struct e1000_hw *hw)
+{
+       struct e1000_phy_info *phy = &hw->phy;
+       s32 ret_val = E1000_SUCCESS;
+       u16 phy_data;
+
+       DEBUGFUNC("e1000_set_eee_i354");
+
+       if ((hw->phy.media_type != e1000_media_type_copper) ||
+           ((phy->id != M88E1543_E_PHY_ID) &&
+           (phy->id != M88E1512_E_PHY_ID)))
+               goto out;
+
+       if (!hw->dev_spec._82575.eee_disable) {
+               /* Switch to PHY page 18. */
+               ret_val = phy->ops.write_reg(hw, E1000_M88E1543_PAGE_ADDR, 18);
+               if (ret_val)
+                       goto out;
+
+               ret_val = phy->ops.read_reg(hw, E1000_M88E1543_EEE_CTRL_1,
+                                           &phy_data);
+               if (ret_val)
+                       goto out;
+
+               phy_data |= E1000_M88E1543_EEE_CTRL_1_MS;
+               ret_val = phy->ops.write_reg(hw, E1000_M88E1543_EEE_CTRL_1,
+                                            phy_data);
+               if (ret_val)
+                       goto out;
+
+               /* Return the PHY to page 0. */
+               ret_val = phy->ops.write_reg(hw, E1000_M88E1543_PAGE_ADDR, 0);
+               if (ret_val)
+                       goto out;
+
+               /* Turn on EEE advertisement. */
+               ret_val = e1000_read_xmdio_reg(hw, E1000_EEE_ADV_ADDR_I354,
+                                              E1000_EEE_ADV_DEV_I354,
+                                              &phy_data);
+               if (ret_val)
+                       goto out;
+
+               phy_data |= E1000_EEE_ADV_100_SUPPORTED |
+                           E1000_EEE_ADV_1000_SUPPORTED;
+               ret_val = e1000_write_xmdio_reg(hw, E1000_EEE_ADV_ADDR_I354,
+                                               E1000_EEE_ADV_DEV_I354,
+                                               phy_data);
+       } else {
+               /* Turn off EEE advertisement. */
+               ret_val = e1000_read_xmdio_reg(hw, E1000_EEE_ADV_ADDR_I354,
+                                              E1000_EEE_ADV_DEV_I354,
+                                              &phy_data);
+               if (ret_val)
+                       goto out;
+
+               phy_data &= ~(E1000_EEE_ADV_100_SUPPORTED |
+                             E1000_EEE_ADV_1000_SUPPORTED);
+               ret_val = e1000_write_xmdio_reg(hw, E1000_EEE_ADV_ADDR_I354,
+                                               E1000_EEE_ADV_DEV_I354,
+                                               phy_data);
+       }
+
 out:
+       return ret_val;
+}
+
+/**
+ *  e1000_get_eee_status_i354 - Get EEE status
+ *  @hw: pointer to the HW structure
+ *  @status: EEE status
+ *
+ *  Get EEE status by guessing based on whether Tx or Rx LPI indications have
+ *  been received.
+ **/
+s32 e1000_get_eee_status_i354(struct e1000_hw *hw, bool *status)
+{
+       struct e1000_phy_info *phy = &hw->phy;
+       s32 ret_val = E1000_SUCCESS;
+       u16 phy_data;
+
+       DEBUGFUNC("e1000_get_eee_status_i354");
+
+       /* Check if EEE is supported on this device. */
+       if ((hw->phy.media_type != e1000_media_type_copper) ||
+           ((phy->id != M88E1543_E_PHY_ID) &&
+           (phy->id != M88E1512_E_PHY_ID)))
+               goto out;
 
+       ret_val = e1000_read_xmdio_reg(hw, E1000_PCS_STATUS_ADDR_I354,
+                                      E1000_PCS_STATUS_DEV_I354,
+                                      &phy_data);
+       if (ret_val)
+               goto out;
+
+       *status = phy_data & (E1000_PCS_STATUS_TX_LPI_RCVD |
+                             E1000_PCS_STATUS_RX_LPI_RCVD) ? true : false;
+
+out:
        return ret_val;
 }