ixgbe/base: support KR mode for X550 link
[dpdk.git] / drivers / net / ixgbe / base / ixgbe_x550.c
index d9d8ab3..6514a0f 100644 (file)
@@ -38,6 +38,7 @@ POSSIBILITY OF SUCH DAMAGE.
 #include "ixgbe_common.h"
 #include "ixgbe_phy.h"
 
+STATIC s32 ixgbe_setup_ixfi_x550em(struct ixgbe_hw *hw, ixgbe_link_speed *speed);
 
 /**
  *  ixgbe_init_ops_X550 - Inits func ptrs and MAC type
@@ -79,6 +80,10 @@ s32 ixgbe_init_ops_X550(struct ixgbe_hw *hw)
        mac->ops.mdd_event = ixgbe_mdd_event_X550;
        mac->ops.restore_mdd_vf = ixgbe_restore_mdd_vf_X550;
        mac->ops.disable_rx = ixgbe_disable_rx_x550;
+       if (hw->device_id == IXGBE_DEV_ID_X550EM_X_10G_T) {
+               hw->mac.ops.led_on = ixgbe_led_on_t_X550em;
+               hw->mac.ops.led_off = ixgbe_led_off_t_X550em;
+       }
        return ret_val;
 }
 
@@ -108,42 +113,6 @@ STATIC s32 ixgbe_write_cs4227(struct ixgbe_hw *hw, u16 reg, u16 value)
        return ixgbe_write_i2c_combined_unlocked(hw, IXGBE_CS4227, reg, value);
 }
 
-/**
- * ixgbe_get_cs4227_status - Return CS4227 status
- * @hw: pointer to hardware structure
- *
- * Returns error if CS4227 not successfully initialized
- **/
-STATIC s32 ixgbe_get_cs4227_status(struct ixgbe_hw *hw)
-{
-       s32 status;
-       u16 value = 0;
-       u8 retry;
-
-       for (retry = 0; retry < IXGBE_CS4227_RETRIES; ++retry) {
-               status = ixgbe_read_cs4227(hw, IXGBE_CS4227_GLOBAL_ID_LSB,
-                                          &value);
-               if (status != IXGBE_SUCCESS)
-                       return status;
-               if (value == IXGBE_CS4227_GLOBAL_ID_VALUE)
-                       break;
-               msec_delay(IXGBE_CS4227_CHECK_DELAY);
-       }
-       if (value != IXGBE_CS4227_GLOBAL_ID_VALUE)
-               return IXGBE_ERR_PHY;
-
-       status = ixgbe_write_cs4227(hw, IXGBE_CS4227_SCRATCH,
-                                   IXGBE_CS4227_SCRATCH_VALUE);
-       if (status != IXGBE_SUCCESS)
-               return status;
-       status = ixgbe_read_cs4227(hw, IXGBE_CS4227_SCRATCH, &value);
-       if (status != IXGBE_SUCCESS)
-               return status;
-       if (value != IXGBE_CS4227_SCRATCH_VALUE)
-               return IXGBE_ERR_PHY;
-       return IXGBE_SUCCESS;
-}
-
 /**
  * ixgbe_read_pe - Read register from port expander
  * @hw: pointer to hardware structure
@@ -186,13 +155,17 @@ STATIC s32 ixgbe_write_pe(struct ixgbe_hw *hw, u8 reg, u8 value)
  * ixgbe_reset_cs4227 - Reset CS4227 using port expander
  * @hw: pointer to hardware structure
  *
+ * This function assumes that the caller has acquired the proper semaphore.
  * Returns error code
  **/
 STATIC s32 ixgbe_reset_cs4227(struct ixgbe_hw *hw)
 {
        s32 status;
+       u32 retry;
+       u16 value;
        u8 reg;
 
+       /* Trigger hard reset. */
        status = ixgbe_read_pe(hw, IXGBE_PE_OUTPUT, &reg);
        if (status != IXGBE_SUCCESS)
                return status;
@@ -227,7 +200,29 @@ STATIC s32 ixgbe_reset_cs4227(struct ixgbe_hw *hw)
        if (status != IXGBE_SUCCESS)
                return status;
 
+       /* Wait for the reset to complete. */
        msec_delay(IXGBE_CS4227_RESET_DELAY);
+       for (retry = 0; retry < IXGBE_CS4227_RETRIES; retry++) {
+               status = ixgbe_read_cs4227(hw, IXGBE_CS4227_EFUSE_STATUS,
+                                          &value);
+               if (status == IXGBE_SUCCESS &&
+                   value == IXGBE_CS4227_EEPROM_LOAD_OK)
+                       break;
+               msec_delay(IXGBE_CS4227_CHECK_DELAY);
+       }
+       if (retry == IXGBE_CS4227_RETRIES) {
+               ERROR_REPORT1(IXGBE_ERROR_INVALID_STATE,
+                       "CS4227 reset did not complete.");
+               return IXGBE_ERR_PHY;
+       }
+
+       status = ixgbe_read_cs4227(hw, IXGBE_CS4227_EEPROM_STATUS, &value);
+       if (status != IXGBE_SUCCESS ||
+           !(value & IXGBE_CS4227_EEPROM_LOAD_OK)) {
+               ERROR_REPORT1(IXGBE_ERROR_INVALID_STATE,
+                       "CS4227 EEPROM did not load successfully.");
+               return IXGBE_ERR_PHY;
+       }
 
        return IXGBE_SUCCESS;
 }
@@ -238,29 +233,75 @@ STATIC s32 ixgbe_reset_cs4227(struct ixgbe_hw *hw)
  **/
 STATIC void ixgbe_check_cs4227(struct ixgbe_hw *hw)
 {
+       s32 status = IXGBE_SUCCESS;
        u32 swfw_mask = hw->phy.phy_semaphore_mask;
-       s32 status;
+       u16 value = 0;
        u8 retry;
 
        for (retry = 0; retry < IXGBE_CS4227_RETRIES; retry++) {
                status = hw->mac.ops.acquire_swfw_sync(hw, swfw_mask);
                if (status != IXGBE_SUCCESS) {
                        ERROR_REPORT2(IXGBE_ERROR_CAUTION,
-                                     "semaphore failed with %d\n", status);
-                       return;
+                               "semaphore failed with %d", status);
+                       msec_delay(IXGBE_CS4227_CHECK_DELAY);
+                       continue;
                }
-               status = ixgbe_get_cs4227_status(hw);
-               if (status == IXGBE_SUCCESS) {
-                       hw->mac.ops.release_swfw_sync(hw, swfw_mask);
-                       msec_delay(hw->eeprom.semaphore_delay);
+
+               /* Get status of reset flow. */
+               status = ixgbe_read_cs4227(hw, IXGBE_CS4227_SCRATCH, &value);
+
+               if (status == IXGBE_SUCCESS &&
+                   value == IXGBE_CS4227_RESET_COMPLETE)
+                       goto out;
+
+               if (status != IXGBE_SUCCESS ||
+                   value != IXGBE_CS4227_RESET_PENDING)
+                       break;
+
+               /* Reset is pending. Wait and check again. */
+               hw->mac.ops.release_swfw_sync(hw, swfw_mask);
+               msec_delay(IXGBE_CS4227_CHECK_DELAY);
+       }
+
+       /* If still pending, assume other instance failed. */
+       if (retry == IXGBE_CS4227_RETRIES) {
+               status = hw->mac.ops.acquire_swfw_sync(hw, swfw_mask);
+               if (status != IXGBE_SUCCESS) {
+                       ERROR_REPORT2(IXGBE_ERROR_CAUTION,
+                                     "semaphore failed with %d", status);
                        return;
                }
-               ixgbe_reset_cs4227(hw);
-               hw->mac.ops.release_swfw_sync(hw, swfw_mask);
-               msec_delay(hw->eeprom.semaphore_delay);
        }
-       ERROR_REPORT2(IXGBE_ERROR_CAUTION,
-                     "Unable to initialize CS4227, err=%d\n", status);
+
+       /* Reset the CS4227. */
+       status = ixgbe_reset_cs4227(hw);
+       if (status != IXGBE_SUCCESS) {
+               ERROR_REPORT2(IXGBE_ERROR_INVALID_STATE,
+                       "CS4227 reset failed: %d", status);
+               goto out;
+       }
+
+       /* Reset takes so long, temporarily release semaphore in case the
+        * other driver instance is waiting for the reset indication.
+        */
+       ixgbe_write_cs4227(hw, IXGBE_CS4227_SCRATCH,
+                          IXGBE_CS4227_RESET_PENDING);
+       hw->mac.ops.release_swfw_sync(hw, swfw_mask);
+       msec_delay(10);
+       status = hw->mac.ops.acquire_swfw_sync(hw, swfw_mask);
+       if (status != IXGBE_SUCCESS) {
+               ERROR_REPORT2(IXGBE_ERROR_CAUTION,
+                       "semaphore failed with %d", status);
+               return;
+       }
+
+       /* Record completion for next time. */
+       status = ixgbe_write_cs4227(hw, IXGBE_CS4227_SCRATCH,
+               IXGBE_CS4227_RESET_COMPLETE);
+
+out:
+       hw->mac.ops.release_swfw_sync(hw, swfw_mask);
+       msec_delay(hw->eeprom.semaphore_delay);
 }
 
 /**
@@ -373,8 +414,13 @@ s32 ixgbe_init_ops_X550EM(struct ixgbe_hw *hw)
        hw->bus.type = ixgbe_bus_type_internal;
        mac->ops.get_bus_info = ixgbe_get_bus_info_X550em;
 
-       mac->ops.read_iosf_sb_reg = ixgbe_read_iosf_sb_reg_x550;
-       mac->ops.write_iosf_sb_reg = ixgbe_write_iosf_sb_reg_x550;
+       if (hw->mac.type == ixgbe_mac_X550EM_x) {
+               mac->ops.read_iosf_sb_reg = ixgbe_read_iosf_sb_reg_x550;
+               mac->ops.write_iosf_sb_reg = ixgbe_write_iosf_sb_reg_x550;
+               mac->ops.acquire_swfw_sync = ixgbe_acquire_swfw_sync_X550em;
+               mac->ops.release_swfw_sync = ixgbe_release_swfw_sync_X550em;
+       }
+
        mac->ops.get_media_type = ixgbe_get_media_type_X550em;
        mac->ops.setup_sfp = ixgbe_setup_sfp_modules_X550em;
        mac->ops.get_link_capabilities = ixgbe_get_link_capabilities_X550em;
@@ -387,8 +433,6 @@ s32 ixgbe_init_ops_X550EM(struct ixgbe_hw *hw)
        else
                mac->ops.setup_fc = ixgbe_setup_fc_X550em;
 
-       mac->ops.acquire_swfw_sync = ixgbe_acquire_swfw_sync_X550em;
-       mac->ops.release_swfw_sync = ixgbe_release_swfw_sync_X550em;
 
        if (hw->device_id != IXGBE_DEV_ID_X550EM_X_KR)
                mac->ops.setup_eee = NULL;
@@ -591,6 +635,7 @@ s32 ixgbe_setup_eee_X550(struct ixgbe_hw *hw, bool enable_eee)
        u16 autoneg_eee_reg;
        u32 link_reg;
        s32 status;
+       u32 fuse;
 
        DEBUGFUNC("ixgbe_setup_eee_X550");
 
@@ -611,6 +656,11 @@ s32 ixgbe_setup_eee_X550(struct ixgbe_hw *hw, bool enable_eee)
                        hw->phy.ops.write_reg(hw, IXGBE_MDIO_AUTO_NEG_EEE_ADVT,
                                IXGBE_MDIO_AUTO_NEG_DEV_TYPE, autoneg_eee_reg);
                } else if (hw->device_id == IXGBE_DEV_ID_X550EM_X_KR) {
+                       /* Not supported on first revision. */
+                       fuse = IXGBE_READ_REG(hw, IXGBE_FUSES0_GROUP(0));
+                       if (!(fuse & IXGBE_FUSES0_REV1))
+                               return IXGBE_SUCCESS;
+
                        status = ixgbe_read_iosf_sb_reg_x550(hw,
                                IXGBE_KRM_LINK_CTRL_1(hw->bus.lan_id),
                                IXGBE_SB_IOSF_TARGET_KR_PHY, &link_reg);
@@ -620,6 +670,9 @@ s32 ixgbe_setup_eee_X550(struct ixgbe_hw *hw, bool enable_eee)
                        link_reg |= IXGBE_KRM_LINK_CTRL_1_TETH_EEE_CAP_KR |
                                    IXGBE_KRM_LINK_CTRL_1_TETH_EEE_CAP_KX;
 
+                       /* Don't advertise FEC capability when EEE enabled. */
+                       link_reg &= ~IXGBE_KRM_LINK_CTRL_1_TETH_AN_CAP_FEC;
+
                        status = ixgbe_write_iosf_sb_reg_x550(hw,
                                IXGBE_KRM_LINK_CTRL_1(hw->bus.lan_id),
                                IXGBE_SB_IOSF_TARGET_KR_PHY, link_reg);
@@ -650,6 +703,9 @@ s32 ixgbe_setup_eee_X550(struct ixgbe_hw *hw, bool enable_eee)
                        link_reg &= ~(IXGBE_KRM_LINK_CTRL_1_TETH_EEE_CAP_KR |
                                IXGBE_KRM_LINK_CTRL_1_TETH_EEE_CAP_KX);
 
+                       /* Advertise FEC capability when EEE is disabled. */
+                       link_reg |= IXGBE_KRM_LINK_CTRL_1_TETH_AN_CAP_FEC;
+
                        status = ixgbe_write_iosf_sb_reg_x550(hw,
                                IXGBE_KRM_LINK_CTRL_1(hw->bus.lan_id),
                                IXGBE_SB_IOSF_TARGET_KR_PHY, link_reg);
@@ -714,6 +770,39 @@ void ixgbe_set_ethertype_anti_spoofing_X550(struct ixgbe_hw *hw,
        IXGBE_WRITE_REG(hw, IXGBE_PFVFSPOOF(vf_target_reg), pfvfspoof);
 }
 
+/**
+ * ixgbe_iosf_wait - Wait for IOSF command completion
+ * @hw: pointer to hardware structure
+ * @ctrl: pointer to location to receive final IOSF control value
+ *
+ * Returns failing status on timeout
+ *
+ * Note: ctrl can be NULL if the IOSF control register value is not needed
+ **/
+STATIC s32 ixgbe_iosf_wait(struct ixgbe_hw *hw, u32 *ctrl)
+{
+       u32 i, command = 0;
+
+       /* Check every 10 usec to see if the address cycle completed.
+        * The SB IOSF BUSY bit will clear when the operation is
+        * complete
+        */
+       for (i = 0; i < IXGBE_MDIO_COMMAND_TIMEOUT; i++) {
+               command = IXGBE_READ_REG(hw, IXGBE_SB_IOSF_INDIRECT_CTRL);
+               if ((command & IXGBE_SB_IOSF_CTRL_BUSY) == 0)
+                       break;
+               usec_delay(10);
+       }
+       if (ctrl)
+               *ctrl = command;
+       if (i == IXGBE_MDIO_COMMAND_TIMEOUT) {
+               ERROR_REPORT1(IXGBE_ERROR_POLLING, "Wait timed out\n");
+               return IXGBE_ERR_PHY;
+       }
+
+       return IXGBE_SUCCESS;
+}
+
 /**
  *  ixgbe_write_iosf_sb_reg_x550 - Writes a value to specified register of the IOSF
  *  device
@@ -725,7 +814,17 @@ void ixgbe_set_ethertype_anti_spoofing_X550(struct ixgbe_hw *hw,
 s32 ixgbe_write_iosf_sb_reg_x550(struct ixgbe_hw *hw, u32 reg_addr,
                            u32 device_type, u32 data)
 {
-       u32 i, command, error;
+       u32 gssr = IXGBE_GSSR_PHY1_SM | IXGBE_GSSR_PHY0_SM;
+       u32 command, error;
+       s32 ret;
+
+       ret = ixgbe_acquire_swfw_semaphore(hw, gssr);
+       if (ret != IXGBE_SUCCESS)
+               return ret;
+
+       ret = ixgbe_iosf_wait(hw, NULL);
+       if (ret != IXGBE_SUCCESS)
+               goto out;
 
        command = ((reg_addr << IXGBE_SB_IOSF_CTRL_ADDR_SHIFT) |
                   (device_type << IXGBE_SB_IOSF_CTRL_TARGET_SELECT_SHIFT));
@@ -735,33 +834,20 @@ s32 ixgbe_write_iosf_sb_reg_x550(struct ixgbe_hw *hw, u32 reg_addr,
 
        /* Write IOSF data register */
        IXGBE_WRITE_REG(hw, IXGBE_SB_IOSF_INDIRECT_DATA, data);
-       /*
-        * Check every 10 usec to see if the address cycle completed.
-        * The SB IOSF BUSY bit will clear when the operation is
-        * complete
-        */
-       for (i = 0; i < IXGBE_MDIO_COMMAND_TIMEOUT; i++) {
-               usec_delay(10);
 
-               command = IXGBE_READ_REG(hw, IXGBE_SB_IOSF_INDIRECT_CTRL);
-               if ((command & IXGBE_SB_IOSF_CTRL_BUSY) == 0)
-                       break;
-       }
+       ret = ixgbe_iosf_wait(hw, &command);
 
        if ((command & IXGBE_SB_IOSF_CTRL_RESP_STAT_MASK) != 0) {
                error = (command & IXGBE_SB_IOSF_CTRL_CMPL_ERR_MASK) >>
                         IXGBE_SB_IOSF_CTRL_CMPL_ERR_SHIFT;
                ERROR_REPORT2(IXGBE_ERROR_POLLING,
                              "Failed to write, error %x\n", error);
-               return IXGBE_ERR_PHY;
-       }
-
-       if (i == IXGBE_MDIO_COMMAND_TIMEOUT) {
-               ERROR_REPORT1(IXGBE_ERROR_POLLING, "Write timed out\n");
-               return IXGBE_ERR_PHY;
+               ret = IXGBE_ERR_PHY;
        }
 
-       return IXGBE_SUCCESS;
+out:
+       ixgbe_release_swfw_semaphore(hw, gssr);
+       return ret;
 }
 
 /**
@@ -775,7 +861,17 @@ s32 ixgbe_write_iosf_sb_reg_x550(struct ixgbe_hw *hw, u32 reg_addr,
 s32 ixgbe_read_iosf_sb_reg_x550(struct ixgbe_hw *hw, u32 reg_addr,
                           u32 device_type, u32 *data)
 {
-       u32 i, command, error;
+       u32 gssr = IXGBE_GSSR_PHY1_SM | IXGBE_GSSR_PHY0_SM;
+       u32 command, error;
+       s32 ret;
+
+       ret = ixgbe_acquire_swfw_semaphore(hw, gssr);
+       if (ret != IXGBE_SUCCESS)
+               return ret;
+
+       ret = ixgbe_iosf_wait(hw, NULL);
+       if (ret != IXGBE_SUCCESS)
+               goto out;
 
        command = ((reg_addr << IXGBE_SB_IOSF_CTRL_ADDR_SHIFT) |
                   (device_type << IXGBE_SB_IOSF_CTRL_TARGET_SELECT_SHIFT));
@@ -783,35 +879,22 @@ s32 ixgbe_read_iosf_sb_reg_x550(struct ixgbe_hw *hw, u32 reg_addr,
        /* Write IOSF control register */
        IXGBE_WRITE_REG(hw, IXGBE_SB_IOSF_INDIRECT_CTRL, command);
 
-       /*
-        * Check every 10 usec to see if the address cycle completed.
-        * The SB IOSF BUSY bit will clear when the operation is
-        * complete
-        */
-       for (i = 0; i < IXGBE_MDIO_COMMAND_TIMEOUT; i++) {
-               usec_delay(10);
-
-               command = IXGBE_READ_REG(hw, IXGBE_SB_IOSF_INDIRECT_CTRL);
-               if ((command & IXGBE_SB_IOSF_CTRL_BUSY) == 0)
-                       break;
-       }
+       ret = ixgbe_iosf_wait(hw, &command);
 
        if ((command & IXGBE_SB_IOSF_CTRL_RESP_STAT_MASK) != 0) {
                error = (command & IXGBE_SB_IOSF_CTRL_CMPL_ERR_MASK) >>
                         IXGBE_SB_IOSF_CTRL_CMPL_ERR_SHIFT;
                ERROR_REPORT2(IXGBE_ERROR_POLLING,
                                "Failed to read, error %x\n", error);
-               return IXGBE_ERR_PHY;
-       }
-
-       if (i == IXGBE_MDIO_COMMAND_TIMEOUT) {
-               ERROR_REPORT1(IXGBE_ERROR_POLLING, "Read timed out\n");
-               return IXGBE_ERR_PHY;
+               ret = IXGBE_ERR_PHY;
        }
 
-       *data = IXGBE_READ_REG(hw, IXGBE_SB_IOSF_INDIRECT_DATA);
+       if (ret == IXGBE_SUCCESS)
+               *data = IXGBE_READ_REG(hw, IXGBE_SB_IOSF_INDIRECT_DATA);
 
-       return IXGBE_SUCCESS;
+out:
+       ixgbe_release_swfw_semaphore(hw, gssr);
+       return ret;
 }
 
 /**
@@ -990,13 +1073,82 @@ enum ixgbe_media_type ixgbe_get_media_type_X550em(struct ixgbe_hw *hw)
 }
 
 /**
- *  ixgbe_setup_sfp_modules_X550em - Setup SFP module
+ *  ixgbe_supported_sfp_modules_X550em - Check if SFP module type is supported
+ *  @hw: pointer to hardware structure
+ *  @linear: true if SFP module is linear
+ */
+STATIC s32 ixgbe_supported_sfp_modules_X550em(struct ixgbe_hw *hw, bool *linear)
+{
+       DEBUGFUNC("ixgbe_supported_sfp_modules_X550em");
+
+       switch (hw->phy.sfp_type) {
+       case ixgbe_sfp_type_not_present:
+               return IXGBE_ERR_SFP_NOT_PRESENT;
+       case ixgbe_sfp_type_da_cu_core0:
+       case ixgbe_sfp_type_da_cu_core1:
+               *linear = true;
+               break;
+       case ixgbe_sfp_type_srlr_core0:
+       case ixgbe_sfp_type_srlr_core1:
+       case ixgbe_sfp_type_da_act_lmt_core0:
+       case ixgbe_sfp_type_da_act_lmt_core1:
+       case ixgbe_sfp_type_1g_sx_core0:
+       case ixgbe_sfp_type_1g_sx_core1:
+       case ixgbe_sfp_type_1g_lx_core0:
+       case ixgbe_sfp_type_1g_lx_core1:
+               *linear = false;
+               break;
+       case ixgbe_sfp_type_unknown:
+       case ixgbe_sfp_type_1g_cu_core0:
+       case ixgbe_sfp_type_1g_cu_core1:
+       default:
+               return IXGBE_ERR_SFP_NOT_SUPPORTED;
+       }
+
+       return IXGBE_SUCCESS;
+}
+
+/**
+ *  ixgbe_identify_sfp_module_X550em - Identifies SFP modules
+ *  @hw: pointer to hardware structure
+ *
+ *  Searches for and identifies the SFP module and assigns appropriate PHY type.
+ **/
+s32 ixgbe_identify_sfp_module_X550em(struct ixgbe_hw *hw)
+{
+       s32 status;
+       bool linear;
+
+       DEBUGFUNC("ixgbe_identify_sfp_module_X550em");
+
+       status = ixgbe_identify_module_generic(hw);
+
+       if (status != IXGBE_SUCCESS)
+               return status;
+
+       /* Check if SFP module is supported */
+       status = ixgbe_supported_sfp_modules_X550em(hw, &linear);
+
+       return status;
+}
+
+/**
+ *  ixgbe_setup_sfp_modules_X550em - Setup MAC link ops
  *  @hw: pointer to hardware structure
  */
 s32 ixgbe_setup_sfp_modules_X550em(struct ixgbe_hw *hw)
 {
+       s32 status;
+       bool linear;
+
        DEBUGFUNC("ixgbe_setup_sfp_modules_X550em");
 
+       /* Check if SFP module is supported */
+       status = ixgbe_supported_sfp_modules_X550em(hw, &linear);
+
+       if (status != IXGBE_SUCCESS)
+               return status;
+
        ixgbe_init_mac_link_ops_X550em(hw);
        hw->phy.ops.reset = NULL;
 
@@ -1124,8 +1276,11 @@ STATIC s32 ixgbe_get_lasi_ext_t_x550em(struct ixgbe_hw *hw, bool *lsc)
                return status;
 
        /* If high temperature failure, then return over temp error and exit */
-       if (reg & IXGBE_MDIO_GLOBAL_ALM_1_HI_TMP_FAIL)
+       if (reg & IXGBE_MDIO_GLOBAL_ALM_1_HI_TMP_FAIL) {
+               /* power down the PHY in case the PHY FW didn't already */
+               ixgbe_set_copper_phy_power(hw, false);
                return IXGBE_ERR_OVERTEMP;
+       }
 
        /* Vendor alarm 2 triggered */
        status = hw->phy.ops.read_reg(hw, IXGBE_MDIO_GLOBAL_CHIP_STD_INT_FLAG,
@@ -1234,6 +1389,46 @@ STATIC s32 ixgbe_enable_lasi_ext_t_x550em(struct ixgbe_hw *hw)
        return status;
 }
 
+/**
+ *  ixgbe_setup_kr_speed_x550em - Configure the KR PHY for link speed.
+ *  @hw: pointer to hardware structure
+ *  @speed: link speed
+ *
+ *  Configures the integrated KR PHY.
+ **/
+STATIC s32 ixgbe_setup_kr_speed_x550em(struct ixgbe_hw *hw,
+                                      ixgbe_link_speed speed)
+{
+       s32 status;
+       u32 reg_val;
+
+       status = ixgbe_read_iosf_sb_reg_x550(hw,
+               IXGBE_KRM_LINK_CTRL_1(hw->bus.lan_id),
+               IXGBE_SB_IOSF_TARGET_KR_PHY, &reg_val);
+       if (status)
+               return status;
+
+       reg_val |= IXGBE_KRM_LINK_CTRL_1_TETH_AN_ENABLE;
+       reg_val &= ~(IXGBE_KRM_LINK_CTRL_1_TETH_AN_CAP_KR |
+                    IXGBE_KRM_LINK_CTRL_1_TETH_AN_CAP_KX);
+
+       /* Advertise 10G support. */
+       if (speed & IXGBE_LINK_SPEED_10GB_FULL)
+               reg_val |= IXGBE_KRM_LINK_CTRL_1_TETH_AN_CAP_KR;
+
+       /* Advertise 1G support. */
+       if (speed & IXGBE_LINK_SPEED_1GB_FULL)
+               reg_val |= IXGBE_KRM_LINK_CTRL_1_TETH_AN_CAP_KX;
+
+       /* Restart auto-negotiation. */
+       reg_val |= IXGBE_KRM_LINK_CTRL_1_TETH_AN_RESTART;
+       status = ixgbe_write_iosf_sb_reg_x550(hw,
+               IXGBE_KRM_LINK_CTRL_1(hw->bus.lan_id),
+               IXGBE_SB_IOSF_TARGET_KR_PHY, reg_val);
+
+       return status;
+}
+
 /**
  *  ixgbe_init_phy_ops_X550em - PHY/SFP specific init
  *  @hw: pointer to hardware structure
@@ -1245,6 +1440,7 @@ STATIC s32 ixgbe_enable_lasi_ext_t_x550em(struct ixgbe_hw *hw)
 s32 ixgbe_init_phy_ops_X550em(struct ixgbe_hw *hw)
 {
        struct ixgbe_phy_info *phy = &hw->phy;
+       ixgbe_link_speed speed;
        s32 ret_val;
 
        DEBUGFUNC("ixgbe_init_phy_ops_X550em");
@@ -1254,6 +1450,12 @@ s32 ixgbe_init_phy_ops_X550em(struct ixgbe_hw *hw)
        if (hw->mac.ops.get_media_type(hw) == ixgbe_media_type_fiber) {
                phy->phy_semaphore_mask = IXGBE_GSSR_SHARED_I2C_SM;
                ixgbe_setup_mux_ctl(hw);
+
+               /* Save NW management interface connected on board. This is used
+                * to determine internal PHY mode.
+                */
+               phy->nw_mng_if_sel = IXGBE_READ_REG(hw, IXGBE_NW_MNG_IF_SEL);
+               phy->ops.identify_sfp = ixgbe_identify_sfp_module_X550em;
        }
 
        /* Identify the PHY or SFP module */
@@ -1269,7 +1471,7 @@ s32 ixgbe_init_phy_ops_X550em(struct ixgbe_hw *hw)
        /* Set functions pointers based on phy type */
        switch (hw->phy.type) {
        case ixgbe_phy_x550em_kx4:
-               phy->ops.setup_link = ixgbe_setup_kx4_x550em;
+               phy->ops.setup_link = NULL;
                phy->ops.read_reg = ixgbe_read_phy_reg_x550em;
                phy->ops.write_reg = ixgbe_write_phy_reg_x550em;
                break;
@@ -1279,9 +1481,28 @@ s32 ixgbe_init_phy_ops_X550em(struct ixgbe_hw *hw)
                phy->ops.write_reg = ixgbe_write_phy_reg_x550em;
                break;
        case ixgbe_phy_x550em_ext_t:
-               phy->ops.setup_internal_link =
-                                        ixgbe_setup_internal_phy_t_x550em;
-               phy->ops.enter_lplu = ixgbe_enter_lplu_t_x550em;
+               /* Save NW management interface connected on board. This is used
+                * to determine internal PHY mode
+                */
+               phy->nw_mng_if_sel = IXGBE_READ_REG(hw, IXGBE_NW_MNG_IF_SEL);
+
+               /* If internal link mode is XFI, then setup iXFI internal link,
+                * else setup KR now.
+                */
+               if (!(phy->nw_mng_if_sel & IXGBE_NW_MNG_IF_SEL_INT_PHY_MODE)) {
+                       phy->ops.setup_internal_link =
+                                             ixgbe_setup_internal_phy_t_x550em;
+               } else {
+                       speed = IXGBE_LINK_SPEED_10GB_FULL |
+                               IXGBE_LINK_SPEED_1GB_FULL;
+                       ret_val = ixgbe_setup_kr_speed_x550em(hw, speed);
+               }
+
+               /* setup SW LPLU only for first revision */
+               if (!(IXGBE_FUSES0_REV1 & IXGBE_READ_REG(hw,
+                                                      IXGBE_FUSES0_GROUP(0))))
+                       phy->ops.enter_lplu = ixgbe_enter_lplu_t_x550em;
+
                phy->ops.handle_lasi = ixgbe_handle_lasi_ext_t_x550em;
                phy->ops.reset = ixgbe_reset_phy_t_X550em;
                break;
@@ -1305,6 +1526,7 @@ s32 ixgbe_reset_hw_X550em(struct ixgbe_hw *hw)
        s32 status;
        u32 ctrl = 0;
        u32 i;
+       u32 hlreg0;
        bool link_up = false;
 
        DEBUGFUNC("ixgbe_reset_hw_X550em");
@@ -1396,6 +1618,12 @@ mac_reset_top:
        hw->mac.num_rar_entries = 128;
        hw->mac.ops.init_rx_addrs(hw);
 
+       if (hw->device_id == IXGBE_DEV_ID_X550EM_X_10G_T) {
+               /* Config MDIO clock speed. */
+               hlreg0 = IXGBE_READ_REG(hw, IXGBE_HLREG0);
+               hlreg0 &= ~IXGBE_HLREG0_MDCSPD;
+               IXGBE_WRITE_REG(hw, IXGBE_HLREG0, hlreg0);
+       }
 
        if (hw->device_id == IXGBE_DEV_ID_X550EM_X_SFP)
                ixgbe_setup_mux_ctl(hw);
@@ -1454,73 +1682,85 @@ s32 ixgbe_init_ext_t_x550em(struct ixgbe_hw *hw)
  **/
 s32 ixgbe_setup_kr_x550em(struct ixgbe_hw *hw)
 {
-       s32 status;
-       u32 reg_val;
-
-       status = ixgbe_read_iosf_sb_reg_x550(hw,
-               IXGBE_KRM_LINK_CTRL_1(hw->bus.lan_id),
-               IXGBE_SB_IOSF_TARGET_KR_PHY, &reg_val);
-       if (status)
-               return status;
-
-       reg_val |= IXGBE_KRM_LINK_CTRL_1_TETH_AN_ENABLE;
-       reg_val &= ~(IXGBE_KRM_LINK_CTRL_1_TETH_AN_FEC_REQ |
-                    IXGBE_KRM_LINK_CTRL_1_TETH_AN_CAP_FEC);
-       reg_val &= ~(IXGBE_KRM_LINK_CTRL_1_TETH_AN_CAP_KR |
-                    IXGBE_KRM_LINK_CTRL_1_TETH_AN_CAP_KX);
-
-       /* Advertise 10G support. */
-       if (hw->phy.autoneg_advertised & IXGBE_LINK_SPEED_10GB_FULL)
-               reg_val |= IXGBE_KRM_LINK_CTRL_1_TETH_AN_CAP_KR;
-
-       /* Advertise 1G support. */
-       if (hw->phy.autoneg_advertised & IXGBE_LINK_SPEED_1GB_FULL)
-               reg_val |= IXGBE_KRM_LINK_CTRL_1_TETH_AN_CAP_KX;
-
-       /* Restart auto-negotiation. */
-       reg_val |= IXGBE_KRM_LINK_CTRL_1_TETH_AN_RESTART;
-       status = ixgbe_write_iosf_sb_reg_x550(hw,
-               IXGBE_KRM_LINK_CTRL_1(hw->bus.lan_id),
-               IXGBE_SB_IOSF_TARGET_KR_PHY, reg_val);
-
-       return status;
+       return ixgbe_setup_kr_speed_x550em(hw, hw->phy.autoneg_advertised);
 }
 
 /**
- *  ixgbe_setup_kx4_x550em - Configure the KX4 PHY.
+ *  ixgbe_setup_mac_link_sfp_x550em - Setup internal/external the PHY for SFP
  *  @hw: pointer to hardware structure
  *
- *  Configures the integrated KX4 PHY.
+ *  Configure the external PHY and the integrated KR PHY for SFP support.
  **/
-s32 ixgbe_setup_kx4_x550em(struct ixgbe_hw *hw)
+s32 ixgbe_setup_mac_link_sfp_x550em(struct ixgbe_hw *hw,
+                                   ixgbe_link_speed speed,
+                                   bool autoneg_wait_to_complete)
 {
-       s32 status;
-       u32 reg_val;
-
-       status = ixgbe_read_iosf_sb_reg_x550(hw, IXGBE_KX4_LINK_CNTL_1,
-               IXGBE_SB_IOSF_TARGET_KX4_PCS0 + hw->bus.lan_id, &reg_val);
-       if (status)
-               return status;
+       s32 ret_val;
+       u16 reg_slice, reg_val;
+       bool setup_linear = false;
+       UNREFERENCED_1PARAMETER(autoneg_wait_to_complete);
 
-       reg_val &= ~(IXGBE_KX4_LINK_CNTL_1_TETH_AN_CAP_KX4 |
-                       IXGBE_KX4_LINK_CNTL_1_TETH_AN_CAP_KX);
+       /* Check if SFP module is supported and linear */
+       ret_val = ixgbe_supported_sfp_modules_X550em(hw, &setup_linear);
 
-       reg_val |= IXGBE_KX4_LINK_CNTL_1_TETH_AN_ENABLE;
+       /* If no SFP module present, then return success. Return success since
+        * there is no reason to configure CS4227 and SFP not present error is
+        * not excepted in the setup MAC link flow.
+        */
+       if (ret_val == IXGBE_ERR_SFP_NOT_PRESENT)
+               return IXGBE_SUCCESS;
 
-       /* Advertise 10G support. */
-       if (hw->phy.autoneg_advertised & IXGBE_LINK_SPEED_10GB_FULL)
-               reg_val |= IXGBE_KX4_LINK_CNTL_1_TETH_AN_CAP_KX4;
+       if (ret_val != IXGBE_SUCCESS)
+               return ret_val;
 
-       /* Advertise 1G support. */
-       if (hw->phy.autoneg_advertised & IXGBE_LINK_SPEED_1GB_FULL)
-               reg_val |= IXGBE_KX4_LINK_CNTL_1_TETH_AN_CAP_KX;
+       if (!(hw->phy.nw_mng_if_sel & IXGBE_NW_MNG_IF_SEL_INT_PHY_MODE)) {
+               /* Configure CS4227 LINE side to 10G SR. */
+               reg_slice = IXGBE_CS4227_LINE_SPARE22_MSB +
+                           (hw->bus.lan_id << 12);
+               reg_val = IXGBE_CS4227_SPEED_10G;
+               ret_val = ixgbe_write_i2c_combined(hw, IXGBE_CS4227, reg_slice,
+                                                  reg_val);
 
-       /* Restart auto-negotiation. */
-       reg_val |= IXGBE_KX4_LINK_CNTL_1_TETH_AN_RESTART;
-       status = ixgbe_write_iosf_sb_reg_x550(hw, IXGBE_KX4_LINK_CNTL_1,
-               IXGBE_SB_IOSF_TARGET_KX4_PCS0 + hw->bus.lan_id, reg_val);
+               reg_slice = IXGBE_CS4227_LINE_SPARE24_LSB +
+                           (hw->bus.lan_id << 12);
+               reg_val = (IXGBE_CS4227_EDC_MODE_SR << 1) | 0x1;
+               ret_val = ixgbe_write_i2c_combined(hw, IXGBE_CS4227, reg_slice,
+                                                  reg_val);
+
+               /* Configure CS4227 for HOST connection rate then type. */
+               reg_slice = IXGBE_CS4227_HOST_SPARE22_MSB +
+                           (hw->bus.lan_id << 12);
+               reg_val = (speed & IXGBE_LINK_SPEED_10GB_FULL) ?
+               IXGBE_CS4227_SPEED_10G : IXGBE_CS4227_SPEED_1G;
+               ret_val = ixgbe_write_i2c_combined(hw, IXGBE_CS4227, reg_slice,
+                                                  reg_val);
+
+               reg_slice = IXGBE_CS4227_HOST_SPARE24_LSB +
+                           (hw->bus.lan_id << 12);
+               if (setup_linear)
+                       reg_val = (IXGBE_CS4227_EDC_MODE_CX1 << 1) | 0x1;
+               else
+                       reg_val = (IXGBE_CS4227_EDC_MODE_SR << 1) | 0x1;
+               ret_val = ixgbe_write_i2c_combined(hw, IXGBE_CS4227, reg_slice,
+                                                  reg_val);
 
-       return status;
+               /* Setup XFI internal link. */
+               ret_val = ixgbe_setup_ixfi_x550em(hw, &speed);
+       } else {
+               /* Configure internal PHY for KR/KX. */
+               ixgbe_setup_kr_speed_x550em(hw, speed);
+
+               /* Configure CS4227 LINE side to proper mode. */
+               reg_slice = IXGBE_CS4227_LINE_SPARE24_LSB +
+                           (hw->bus.lan_id << 12);
+               if (setup_linear)
+                       reg_val = (IXGBE_CS4227_EDC_MODE_CX1 << 1) | 0x1;
+               else
+                       reg_val = (IXGBE_CS4227_EDC_MODE_SR << 1) | 0x1;
+               ret_val = ixgbe_write_i2c_combined(hw, IXGBE_CS4227, reg_slice,
+                                                  reg_val);
+       }
+       return ret_val;
 }
 
 /**
@@ -1637,75 +1877,35 @@ STATIC s32 ixgbe_setup_ixfi_x550em(struct ixgbe_hw *hw, ixgbe_link_speed *speed)
 }
 
 /**
- *  ixgbe_setup_mac_link_sfp_x550em - Configure the KR PHY for SFP.
- *  @hw: pointer to hardware structure
+ * ixgbe_ext_phy_t_x550em_get_link - Get ext phy link status
+ * @hw: address of hardware structure
+ * @link_up: address of boolean to indicate link status
  *
- *  Configures the integrated KR PHY for SFP support.
- **/
-s32 ixgbe_setup_mac_link_sfp_x550em(struct ixgbe_hw *hw,
-                                   ixgbe_link_speed speed,
-                                   bool autoneg_wait_to_complete)
+ * Returns error code if unable to get link status.
+ */
+STATIC s32 ixgbe_ext_phy_t_x550em_get_link(struct ixgbe_hw *hw, bool *link_up)
 {
-       s32 ret_val;
-       u16 reg_slice, reg_val;
-       bool setup_linear = false;
-       UNREFERENCED_1PARAMETER(autoneg_wait_to_complete);
+       u32 ret;
+       u16 autoneg_status;
 
-       /* Configure the external PHY. */
-       switch (hw->phy.sfp_type) {
-       case ixgbe_sfp_type_da_cu_core0:
-       case ixgbe_sfp_type_da_cu_core1:
-               setup_linear = true;
-               break;
-       case ixgbe_sfp_type_srlr_core0:
-       case ixgbe_sfp_type_srlr_core1:
-       case ixgbe_sfp_type_da_act_lmt_core0:
-       case ixgbe_sfp_type_da_act_lmt_core1:
-       case ixgbe_sfp_type_1g_sx_core0:
-       case ixgbe_sfp_type_1g_sx_core1:
-#ifdef SUPPORT_1000BASE_LX
-       case ixgbe_sfp_type_1g_lx_core0:
-       case ixgbe_sfp_type_1g_lx_core1:
-#endif /* SUPPORT_1000BASE_LX */
-               setup_linear = false;
-               break;
-       default:
-               return IXGBE_ERR_SFP_NOT_SUPPORTED;
-       }
+       *link_up = false;
 
-       /* Configure CS4227 for connection rate. */
-       reg_slice = IXGBE_CS4227_LINE_SPARE22_MSB + (hw->bus.lan_id << 12);
-       reg_val = (speed & IXGBE_LINK_SPEED_10GB_FULL) ? 0 : 0x8000;
-       ret_val = ixgbe_write_i2c_combined(hw, IXGBE_CS4227, reg_slice,
-                                          reg_val);
+       /* read this twice back to back to indicate current status */
+       ret = hw->phy.ops.read_reg(hw, IXGBE_MDIO_AUTO_NEG_STATUS,
+                                  IXGBE_MDIO_AUTO_NEG_DEV_TYPE,
+                                  &autoneg_status);
+       if (ret != IXGBE_SUCCESS)
+               return ret;
 
-       /* Configure CS4227 for connection type. */
-       reg_slice = IXGBE_CS4227_LINE_SPARE24_LSB + (hw->bus.lan_id << 12);
-       if (setup_linear)
-               reg_val = (IXGBE_CS4227_EDC_MODE_CX1 << 1) | 0x1;
-       else
-               reg_val = (IXGBE_CS4227_EDC_MODE_SR << 1) | 0x1;
-       ret_val = ixgbe_write_i2c_combined(hw, IXGBE_CS4227, reg_slice,
-                                          reg_val);
-
-       reg_slice = IXGBE_CS4227_HOST_SPARE22_MSB + (hw->bus.lan_id << 12);
-       reg_val = (speed & IXGBE_LINK_SPEED_10GB_FULL) ? 0 : 0x8000;
-       ret_val = ixgbe_write_i2c_combined(hw, IXGBE_CS4227, reg_slice,
-                                          reg_val);
-
-       /* Configure CS4227 for connection type. */
-       reg_slice = IXGBE_CS4227_HOST_SPARE24_LSB + (hw->bus.lan_id << 12);
-       if (setup_linear)
-               reg_val = (IXGBE_CS4227_EDC_MODE_CX1 << 1) | 0x1;
-       else
-               reg_val = (IXGBE_CS4227_EDC_MODE_SR << 1) | 0x1;
-       ret_val = ixgbe_write_i2c_combined(hw, IXGBE_CS4227, reg_slice,
-                                          reg_val);
+       ret = hw->phy.ops.read_reg(hw, IXGBE_MDIO_AUTO_NEG_STATUS,
+                                  IXGBE_MDIO_AUTO_NEG_DEV_TYPE,
+                                  &autoneg_status);
+       if (ret != IXGBE_SUCCESS)
+               return ret;
 
-       /* Configure the internal PHY. */
-       ret_val = ixgbe_setup_ixfi_x550em(hw, &speed);
+       *link_up = !!(autoneg_status & IXGBE_MDIO_AUTO_NEG_LINK_STATUS);
 
-       return ret_val;
+       return IXGBE_SUCCESS;
 }
 
 /**
@@ -1722,33 +1922,34 @@ s32 ixgbe_setup_mac_link_sfp_x550em(struct ixgbe_hw *hw,
  */
 s32 ixgbe_setup_internal_phy_t_x550em(struct ixgbe_hw *hw)
 {
-       u32 status;
-       u16 autoneg_status, speed;
        ixgbe_link_speed force_speed;
+       bool link_up;
+       u32 status;
+       u16 speed;
 
        if (hw->mac.ops.get_media_type(hw) != ixgbe_media_type_copper)
                return IXGBE_ERR_CONFIG;
 
-       /* read this twice back to back to indicate current status */
-       status = hw->phy.ops.read_reg(hw, IXGBE_MDIO_AUTO_NEG_STATUS,
-                                     IXGBE_MDIO_AUTO_NEG_DEV_TYPE,
-                                     &autoneg_status);
-       if (status != IXGBE_SUCCESS)
-               return status;
-
-       status = hw->phy.ops.read_reg(hw, IXGBE_MDIO_AUTO_NEG_STATUS,
-                                     IXGBE_MDIO_AUTO_NEG_DEV_TYPE,
-                                     &autoneg_status);
+       /* If link is not up, then there is no setup necessary so return  */
+       status = ixgbe_ext_phy_t_x550em_get_link(hw, &link_up);
        if (status != IXGBE_SUCCESS)
                return status;
 
-       /* If link is not up, then there is no setup necessary so return  */
-       if (!(autoneg_status & IXGBE_MDIO_AUTO_NEG_LINK_STATUS))
+       if (!link_up)
                return IXGBE_SUCCESS;
 
        status = hw->phy.ops.read_reg(hw, IXGBE_MDIO_AUTO_NEG_VENDOR_STAT,
                                      IXGBE_MDIO_AUTO_NEG_DEV_TYPE,
                                      &speed);
+       if (status != IXGBE_SUCCESS)
+               return status;
+
+       /* If link is not still up, then no setup is necessary so return */
+       status = ixgbe_ext_phy_t_x550em_get_link(hw, &link_up);
+       if (status != IXGBE_SUCCESS)
+               return status;
+       if (!link_up)
+               return IXGBE_SUCCESS;
 
        /* clear everything but the speed and duplex bits */
        speed &= IXGBE_MDIO_AUTO_NEG_VENDOR_STATUS_MASK;
@@ -2473,19 +2674,21 @@ void ixgbe_disable_rx_x550(struct ixgbe_hw *hw)
  **/
 s32 ixgbe_enter_lplu_t_x550em(struct ixgbe_hw *hw)
 {
-       u16 autoneg_status, an_10g_cntl_reg, autoneg_reg, speed;
+       u16 an_10g_cntl_reg, autoneg_reg, speed;
        s32 status;
        ixgbe_link_speed lcd_speed;
        u32 save_autoneg;
+       bool link_up;
+
+       /* SW LPLU not required on later HW revisions. */
+       if (IXGBE_FUSES0_REV1 & IXGBE_READ_REG(hw, IXGBE_FUSES0_GROUP(0)))
+               return IXGBE_SUCCESS;
 
        /* If blocked by MNG FW, then don't restart AN */
        if (ixgbe_check_reset_blocked(hw))
                return IXGBE_SUCCESS;
 
-       status = hw->phy.ops.read_reg(hw, IXGBE_MDIO_AUTO_NEG_STATUS,
-                                     IXGBE_MDIO_AUTO_NEG_DEV_TYPE,
-                                     &autoneg_status);
-
+       status = ixgbe_ext_phy_t_x550em_get_link(hw, &link_up);
        if (status != IXGBE_SUCCESS)
                return status;
 
@@ -2497,8 +2700,7 @@ s32 ixgbe_enter_lplu_t_x550em(struct ixgbe_hw *hw)
        /* If link is down, LPLU disabled in NVM, WoL disabled, or manageability
         * disabled, then force link down by entering low power mode.
         */
-       if (!(autoneg_status & IXGBE_MDIO_AUTO_NEG_LINK_STATUS) ||
-           !(hw->eeprom.ctrl_word_3 & NVM_INIT_CTRL_3_LPLU) ||
+       if (!link_up || !(hw->eeprom.ctrl_word_3 & NVM_INIT_CTRL_3_LPLU) ||
            !(hw->wol_enabled || ixgbe_mng_present(hw)))
                return ixgbe_set_copper_phy_power(hw, FALSE);
 
@@ -2519,6 +2721,11 @@ s32 ixgbe_enter_lplu_t_x550em(struct ixgbe_hw *hw)
        if (status != IXGBE_SUCCESS)
                return status;
 
+       /* If no link now, speed is invalid so take link down */
+       status = ixgbe_ext_phy_t_x550em_get_link(hw, &link_up);
+       if (status != IXGBE_SUCCESS)
+               return ixgbe_set_copper_phy_power(hw, false);
+
        /* clear everything but the speed bits */
        speed &= IXGBE_MDIO_AUTO_NEG_VEN_STAT_SPEED_MASK;
 
@@ -2532,7 +2739,7 @@ s32 ixgbe_enter_lplu_t_x550em(struct ixgbe_hw *hw)
        /* Clear AN completed indication */
        status = hw->phy.ops.read_reg(hw, IXGBE_MDIO_AUTO_NEG_VENDOR_TX_ALARM,
                                      IXGBE_MDIO_AUTO_NEG_DEV_TYPE,
-                                     &autoneg_status);
+                                     &autoneg_reg);
 
        if (status != IXGBE_SUCCESS)
                return status;
@@ -2658,7 +2865,7 @@ s32 ixgbe_setup_fc_X550em(struct ixgbe_hw *hw)
                goto out;
        }
 
-       if (hw->phy.media_type == ixgbe_media_type_backplane) {
+       if (hw->device_id == IXGBE_DEV_ID_X550EM_X_KR) {
                ret_val = ixgbe_read_iosf_sb_reg_x550(hw,
                        IXGBE_KRM_AN_CNTL_1(hw->bus.lan_id),
                        IXGBE_SB_IOSF_TARGET_KR_PHY, &reg_val);
@@ -2674,9 +2881,8 @@ s32 ixgbe_setup_fc_X550em(struct ixgbe_hw *hw)
                        IXGBE_KRM_AN_CNTL_1(hw->bus.lan_id),
                        IXGBE_SB_IOSF_TARGET_KR_PHY, reg_val);
 
-               /* Not all devices fully support AN. */
-               if (hw->device_id == IXGBE_DEV_ID_X550EM_X_KR)
-                       hw->fc.disable_fc_autoneg = true;
+               /* This device does not fully support AN. */
+               hw->fc.disable_fc_autoneg = true;
        }
 
 out:
@@ -2765,7 +2971,7 @@ s32 ixgbe_handle_lasi_ext_t_x550em(struct ixgbe_hw *hw)
                return status;
 
        if (lsc)
-               return ixgbe_setup_internal_phy_t_x550em(hw);
+               return ixgbe_setup_internal_phy(hw);
 
        return IXGBE_SUCCESS;
 }
@@ -2798,10 +3004,13 @@ s32 ixgbe_setup_mac_link_t_X550em(struct ixgbe_hw *hw,
        else
                force_speed = IXGBE_LINK_SPEED_1GB_FULL;
 
-       status = ixgbe_setup_ixfi_x550em(hw, &force_speed);
+       /* If internal link mode is XFI, then setup XFI internal link. */
+       if (!(hw->phy.nw_mng_if_sel & IXGBE_NW_MNG_IF_SEL_INT_PHY_MODE)) {
+               status = ixgbe_setup_ixfi_x550em(hw, &force_speed);
 
-       if (status != IXGBE_SUCCESS)
-               return status;
+               if (status != IXGBE_SUCCESS)
+                       return status;
+       }
 
        return hw->phy.ops.setup_link_speed(hw, speed, autoneg_wait_to_complete);
 }
@@ -2871,3 +3080,51 @@ s32 ixgbe_reset_phy_t_X550em(struct ixgbe_hw *hw)
        /* Configure Link Status Alarm and Temperature Threshold interrupts */
        return ixgbe_enable_lasi_ext_t_x550em(hw);
 }
+
+/**
+ *  ixgbe_led_on_t_X550em - Turns on the software controllable LEDs.
+ *  @hw: pointer to hardware structure
+ *  @led_idx: led number to turn on
+ **/
+s32 ixgbe_led_on_t_X550em(struct ixgbe_hw *hw, u32 led_idx)
+{
+       u16 phy_data;
+
+       DEBUGFUNC("ixgbe_led_on_t_X550em");
+
+       if (led_idx >= IXGBE_X557_MAX_LED_INDEX)
+               return IXGBE_ERR_PARAM;
+
+       /* To turn on the LED, set mode to ON. */
+       ixgbe_read_phy_reg(hw, IXGBE_X557_LED_PROVISIONING + led_idx,
+                          IXGBE_MDIO_VENDOR_SPECIFIC_1_DEV_TYPE, &phy_data);
+       phy_data |= IXGBE_X557_LED_MANUAL_SET_MASK;
+       ixgbe_write_phy_reg(hw, IXGBE_X557_LED_PROVISIONING + led_idx,
+                           IXGBE_MDIO_VENDOR_SPECIFIC_1_DEV_TYPE, phy_data);
+
+       return IXGBE_SUCCESS;
+}
+
+/**
+ *  ixgbe_led_off_t_X550em - Turns off the software controllable LEDs.
+ *  @hw: pointer to hardware structure
+ *  @led_idx: led number to turn off
+ **/
+s32 ixgbe_led_off_t_X550em(struct ixgbe_hw *hw, u32 led_idx)
+{
+       u16 phy_data;
+
+       DEBUGFUNC("ixgbe_led_off_t_X550em");
+
+       if (led_idx >= IXGBE_X557_MAX_LED_INDEX)
+               return IXGBE_ERR_PARAM;
+
+       /* To turn on the LED, set mode to ON. */
+       ixgbe_read_phy_reg(hw, IXGBE_X557_LED_PROVISIONING + led_idx,
+                          IXGBE_MDIO_VENDOR_SPECIFIC_1_DEV_TYPE, &phy_data);
+       phy_data &= ~IXGBE_X557_LED_MANUAL_SET_MASK;
+       ixgbe_write_phy_reg(hw, IXGBE_X557_LED_PROVISIONING + led_idx,
+                           IXGBE_MDIO_VENDOR_SPECIFIC_1_DEV_TYPE, phy_data);
+
+       return IXGBE_SUCCESS;
+}