net/ixgbe/base: make a debug message simple
[dpdk.git] / drivers / net / ixgbe / base / ixgbe_x550.c
index 2aaed6b..cf72bba 100644 (file)
@@ -450,6 +450,9 @@ STATIC s32 ixgbe_identify_phy_x550em(struct ixgbe_hw *hw)
        case IXGBE_DEV_ID_X550EM_X_KX4:
                hw->phy.type = ixgbe_phy_x550em_kx4;
                break;
+       case IXGBE_DEV_ID_X550EM_X_XFI:
+               hw->phy.type = ixgbe_phy_x550em_xfi;
+               break;
        case IXGBE_DEV_ID_X550EM_X_KR:
        case IXGBE_DEV_ID_X550EM_A_KR:
        case IXGBE_DEV_ID_X550EM_A_KR_L:
@@ -942,6 +945,7 @@ s32 ixgbe_init_ops_X550EM_x(struct ixgbe_hw *hw)
                                      ixgbe_write_i2c_combined_generic_unlocked;
        link->addr = IXGBE_CS4227;
 
+
        return ret_val;
 }
 
@@ -1108,118 +1112,6 @@ s32 ixgbe_init_eeprom_params_X550(struct ixgbe_hw *hw)
        return IXGBE_SUCCESS;
 }
 
-/**
- * ixgbe_enable_eee_x550 - Enable EEE support
- * @hw: pointer to hardware structure
- */
-STATIC s32 ixgbe_enable_eee_x550(struct ixgbe_hw *hw)
-{
-       u32 link_reg;
-       s32 status;
-
-       switch (hw->device_id) {
-       case IXGBE_DEV_ID_X550EM_A_KR:
-       case IXGBE_DEV_ID_X550EM_A_KR_L:
-               status = hw->mac.ops.read_iosf_sb_reg(hw,
-                                       IXGBE_KRM_LINK_CTRL_1(hw->bus.lan_id),
-                                       IXGBE_SB_IOSF_TARGET_KR_PHY, &link_reg);
-               if (status != IXGBE_SUCCESS)
-                       return status;
-
-               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 = hw->mac.ops.write_iosf_sb_reg(hw,
-                                       IXGBE_KRM_LINK_CTRL_1(hw->bus.lan_id),
-                                       IXGBE_SB_IOSF_TARGET_KR_PHY, link_reg);
-               if (status != IXGBE_SUCCESS)
-                       return status;
-               break;
-       default:
-               break;
-       }
-
-       return IXGBE_SUCCESS;
-}
-
-/**
- * ixgbe_disable_eee_x550 - Disable EEE support
- * @hw: pointer to hardware structure
- */
-STATIC s32 ixgbe_disable_eee_x550(struct ixgbe_hw *hw)
-{
-       u32 link_reg;
-       s32 status;
-
-       switch (hw->device_id) {
-       case IXGBE_DEV_ID_X550EM_X_KR:
-       case IXGBE_DEV_ID_X550EM_A_KR:
-       case IXGBE_DEV_ID_X550EM_A_KR_L:
-               status = hw->mac.ops.read_iosf_sb_reg(hw,
-                                       IXGBE_KRM_LINK_CTRL_1(hw->bus.lan_id),
-                                       IXGBE_SB_IOSF_TARGET_KR_PHY, &link_reg);
-               if (status != IXGBE_SUCCESS)
-                       return status;
-
-               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 = hw->mac.ops.write_iosf_sb_reg(hw,
-                                       IXGBE_KRM_LINK_CTRL_1(hw->bus.lan_id),
-                                       IXGBE_SB_IOSF_TARGET_KR_PHY, link_reg);
-               if (status != IXGBE_SUCCESS)
-                       return status;
-               break;
-       default:
-               break;
-       }
-
-       return IXGBE_SUCCESS;
-}
-
-/**
- *  ixgbe_setup_eee_X550 - Enable/disable EEE support
- *  @hw: pointer to the HW structure
- *  @enable_eee: boolean flag to enable EEE
- *
- *  Enable/disable EEE based on enable_eee flag.
- *  Auto-negotiation must be started after BASE-T EEE bits in PHY register 7.3C
- *  are modified.
- *
- **/
-s32 ixgbe_setup_eee_X550(struct ixgbe_hw *hw, bool enable_eee)
-{
-       s32 status;
-       u32 eeer;
-
-       DEBUGFUNC("ixgbe_setup_eee_X550");
-
-       eeer = IXGBE_READ_REG(hw, IXGBE_EEER);
-       /* Enable or disable EEE per flag */
-       if (enable_eee) {
-               eeer |= (IXGBE_EEER_TX_LPI_EN | IXGBE_EEER_RX_LPI_EN);
-
-               status = ixgbe_enable_eee_x550(hw);
-               if (status)
-                       return status;
-       } else {
-               eeer &= ~(IXGBE_EEER_TX_LPI_EN | IXGBE_EEER_RX_LPI_EN);
-
-               status = ixgbe_disable_eee_x550(hw);
-               if (status)
-                       return status;
-       }
-       IXGBE_WRITE_REG(hw, IXGBE_EEER, eeer);
-
-       return IXGBE_SUCCESS;
-}
-
 /**
  * ixgbe_set_source_address_pruning_X550 - Enable/Disbale source address pruning
  * @hw: pointer to hardware structure
@@ -1419,13 +1311,20 @@ s32 ixgbe_get_phy_token(struct ixgbe_hw *hw)
                                              sizeof(token_cmd),
                                              IXGBE_HI_COMMAND_TIMEOUT,
                                              true);
-       if (status)
+       if (status) {
+               DEBUGOUT1("Issuing host interface command failed with Status = %d\n",
+                         status);
                return status;
+       }
        if (token_cmd.hdr.cmd_or_resp.ret_status == FW_PHY_TOKEN_OK)
                return IXGBE_SUCCESS;
-       if (token_cmd.hdr.cmd_or_resp.ret_status != FW_PHY_TOKEN_RETRY)
+       if (token_cmd.hdr.cmd_or_resp.ret_status != FW_PHY_TOKEN_RETRY) {
+               DEBUGOUT1("Host interface command returned 0x%08x , returning IXGBE_ERR_FW_RESP_INVALID\n",
+                         token_cmd.hdr.cmd_or_resp.ret_status);
                return IXGBE_ERR_FW_RESP_INVALID;
+       }
 
+       DEBUGOUT("Returning  IXGBE_ERR_TOKEN_RETRY\n");
        return IXGBE_ERR_TOKEN_RETRY;
 }
 
@@ -1684,6 +1583,7 @@ enum ixgbe_media_type ixgbe_get_media_type_X550em(struct ixgbe_hw *hw)
        switch (hw->device_id) {
        case IXGBE_DEV_ID_X550EM_X_KR:
        case IXGBE_DEV_ID_X550EM_X_KX4:
+       case IXGBE_DEV_ID_X550EM_X_XFI:
        case IXGBE_DEV_ID_X550EM_A_KR:
        case IXGBE_DEV_ID_X550EM_A_KR_L:
                media_type = ixgbe_media_type_backplane;
@@ -2082,6 +1982,7 @@ s32 ixgbe_get_link_capabilities_X550em(struct ixgbe_hw *hw,
                        *speed = IXGBE_LINK_SPEED_10GB_FULL;
        } else {
                switch (hw->phy.type) {
+               case ixgbe_phy_ext_1g_t:
                case ixgbe_phy_sgmii:
                        *speed = IXGBE_LINK_SPEED_1GB_FULL;
                        break;
@@ -2479,6 +2380,10 @@ s32 ixgbe_init_phy_ops_X550em(struct ixgbe_hw *hw)
                /* set up for CS4227 usage */
                hw->phy.phy_semaphore_mask = IXGBE_GSSR_SHARED_I2C_SM;
                break;
+       case IXGBE_DEV_ID_X550EM_X_1G_T:
+               phy->ops.read_reg_mdi = ixgbe_read_phy_reg_mdi_22;
+               phy->ops.write_reg_mdi = ixgbe_write_phy_reg_mdi_22;
+               break;
        default:
                break;
        }
@@ -2506,6 +2411,16 @@ s32 ixgbe_init_phy_ops_X550em(struct ixgbe_hw *hw)
                phy->ops.read_reg = ixgbe_read_phy_reg_x550em;
                phy->ops.write_reg = ixgbe_write_phy_reg_x550em;
                break;
+       case ixgbe_phy_ext_1g_t:
+               /* link is managed by FW */
+               phy->ops.setup_link = NULL;
+               break;
+       case ixgbe_phy_x550em_xfi:
+               /* link is managed by HW */
+               phy->ops.setup_link = NULL;
+               phy->ops.read_reg = ixgbe_read_phy_reg_x550em;
+               phy->ops.write_reg = ixgbe_write_phy_reg_x550em;
+               break;
        case ixgbe_phy_x550em_ext_t:
                /* If internal link mode is XFI, then setup iXFI internal link,
                 * else setup KR now.
@@ -2587,9 +2502,10 @@ s32 ixgbe_reset_hw_X550em(struct ixgbe_hw *hw)
 
        /* Call adapter stop to disable Tx/Rx and clear interrupts */
        status = hw->mac.ops.stop_adapter(hw);
-       if (status != IXGBE_SUCCESS)
+       if (status != IXGBE_SUCCESS) {
+               DEBUGOUT1("Failed to stop adapter, STATUS = %d\n", status);
                return status;
-
+       }
        /* flush pending Tx transactions */
        ixgbe_clear_tx_pending(hw);
 
@@ -2598,14 +2514,23 @@ s32 ixgbe_reset_hw_X550em(struct ixgbe_hw *hw)
        /* PHY ops must be identified and initialized prior to reset */
        status = hw->phy.ops.init(hw);
 
-       if (status == IXGBE_ERR_SFP_NOT_SUPPORTED)
+       if (status)
+               DEBUGOUT1("Failed to initialize PHY ops, STATUS = %d\n",
+                         status);
+
+       if (status == IXGBE_ERR_SFP_NOT_SUPPORTED) {
+               DEBUGOUT("Returning from reset HW due to PHY init failure\n");
                return status;
+       }
 
        /* start the external PHY */
        if (hw->phy.type == ixgbe_phy_x550em_ext_t) {
                status = ixgbe_init_ext_t_x550em(hw);
-               if (status)
+               if (status) {
+                       DEBUGOUT1("Failed to start the external PHY, STATUS = %d\n",
+                                 status);
                        return status;
+               }
        }
 
        /* Setup SFP module if there is one present. */
@@ -2679,6 +2604,9 @@ mac_reset_top:
        if (hw->device_id == IXGBE_DEV_ID_X550EM_X_SFP)
                ixgbe_setup_mux_ctl(hw);
 
+       if (status != IXGBE_SUCCESS)
+               DEBUGOUT1("Reset HW failed, STATUS = %d\n", status);
+
        return status;
 }
 
@@ -2728,12 +2656,11 @@ s32 ixgbe_init_ext_t_x550em(struct ixgbe_hw *hw)
 /**
  *  ixgbe_setup_kr_x550em - Configure the KR PHY.
  *  @hw: pointer to hardware structure
- *
- *  Configures the integrated KR PHY for X550EM_x.
  **/
 s32 ixgbe_setup_kr_x550em(struct ixgbe_hw *hw)
 {
-       if (hw->mac.type != ixgbe_mac_X550EM_x)
+       /* leave link alone for 2.5G */
+       if (hw->phy.autoneg_advertised & IXGBE_LINK_SPEED_2_5GB_FULL)
                return IXGBE_SUCCESS;
 
        return ixgbe_setup_kr_speed_x550em(hw, hw->phy.autoneg_advertised);
@@ -2945,12 +2872,26 @@ s32 ixgbe_setup_mac_link_sfp_x550a(struct ixgbe_hw *hw,
 
                /* Configure CS4227/CS4223 LINE side to proper mode. */
                reg_slice = IXGBE_CS4227_LINE_SPARE24_LSB + slice_offset;
+
+               ret_val = hw->phy.ops.read_reg(hw, reg_slice,
+                                       IXGBE_MDIO_ZERO_DEV_TYPE, &reg_phy_ext);
+
+               if (ret_val != IXGBE_SUCCESS)
+                       return ret_val;
+
+               reg_phy_ext &= ~((IXGBE_CS4227_EDC_MODE_CX1 << 1) |
+                                (IXGBE_CS4227_EDC_MODE_SR << 1));
+
                if (setup_linear)
                        reg_phy_ext = (IXGBE_CS4227_EDC_MODE_CX1 << 1) | 0x1;
                else
                        reg_phy_ext = (IXGBE_CS4227_EDC_MODE_SR << 1) | 0x1;
                ret_val = hw->phy.ops.write_reg(hw, reg_slice,
                                         IXGBE_MDIO_ZERO_DEV_TYPE, reg_phy_ext);
+
+               /* Flush previous write with a read */
+               ret_val = hw->phy.ops.read_reg(hw, reg_slice,
+                                       IXGBE_MDIO_ZERO_DEV_TYPE, &reg_phy_ext);
        }
        return ret_val;
 }
@@ -3766,6 +3707,7 @@ u32 ixgbe_get_supported_physical_layer_X550em(struct ixgbe_hw *hw)
 
        switch (hw->phy.type) {
        case ixgbe_phy_x550em_kr:
+       case ixgbe_phy_x550em_xfi:
                physical_layer = IXGBE_PHYSICAL_LAYER_10GBASE_KR |
                                 IXGBE_PHYSICAL_LAYER_1000BASE_KX;
                break;
@@ -3790,6 +3732,12 @@ u32 ixgbe_get_supported_physical_layer_X550em(struct ixgbe_hw *hw)
                if (hw->phy.speeds_supported & IXGBE_LINK_SPEED_10_FULL)
                        physical_layer |= IXGBE_PHYSICAL_LAYER_10BASE_T;
                break;
+       case ixgbe_phy_sgmii:
+               physical_layer = IXGBE_PHYSICAL_LAYER_1000BASE_KX;
+               break;
+       case ixgbe_phy_ext_1g_t:
+               physical_layer |= IXGBE_PHYSICAL_LAYER_1000BASE_T;
+               break;
        default:
                break;
        }
@@ -4408,21 +4356,34 @@ STATIC s32 ixgbe_acquire_swfw_sync_X550a(struct ixgbe_hw *hw, u32 mask)
                status = IXGBE_SUCCESS;
                if (hmask)
                        status = ixgbe_acquire_swfw_sync_X540(hw, hmask);
-               if (status)
+               if (status) {
+                       DEBUGOUT1("Could not acquire SWFW semaphore, Status = %d\n",
+                                 status);
                        return status;
+               }
                if (!(mask & IXGBE_GSSR_TOKEN_SM))
                        return IXGBE_SUCCESS;
 
                status = ixgbe_get_phy_token(hw);
+               if (status == IXGBE_ERR_TOKEN_RETRY)
+                       DEBUGOUT1("Could not acquire PHY token, Status = %d\n",
+                                 status);
+
                if (status == IXGBE_SUCCESS)
                        return IXGBE_SUCCESS;
 
                if (hmask)
                        ixgbe_release_swfw_sync_X540(hw, hmask);
-               if (status != IXGBE_ERR_TOKEN_RETRY)
+
+               if (status != IXGBE_ERR_TOKEN_RETRY) {
+                       DEBUGOUT1("Unable to retry acquiring the PHY token, Status = %d\n",
+                                 status);
                        return status;
+               }
        }
 
+       DEBUGOUT1("Semaphore acquisition retries failed!: PHY ID = 0x%08X\n",
+                 hw->phy.id);
        return status;
 }