net/ixgbe/base: make a debug message simple
[dpdk.git] / drivers / net / ixgbe / base / ixgbe_x550.c
index c7ccd81..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:
@@ -896,19 +899,18 @@ s32 ixgbe_init_ops_X550EM_a(struct ixgbe_hw *hw)
                break;
        }
 
-       if ((hw->device_id == IXGBE_DEV_ID_X550EM_A_1G_T) ||
-               (hw->device_id == IXGBE_DEV_ID_X550EM_A_1G_T_L)) {
+       switch (hw->device_id) {
+       case IXGBE_DEV_ID_X550EM_A_1G_T:
+       case IXGBE_DEV_ID_X550EM_A_1G_T_L:
                mac->ops.fc_autoneg = ixgbe_fc_autoneg_sgmii_x550em_a;
                mac->ops.setup_fc = ixgbe_fc_autoneg_fw;
-       }
-
-       switch (hw->device_id) {
-       case IXGBE_DEV_ID_X550EM_A_KR:
-       case IXGBE_DEV_ID_X550EM_A_KR_L:
                mac->ops.setup_eee = ixgbe_setup_eee_fw;
+               hw->phy.eee_speeds_supported = IXGBE_LINK_SPEED_100_FULL |
+                                              IXGBE_LINK_SPEED_1GB_FULL;
+               hw->phy.eee_speeds_advertised = hw->phy.eee_speeds_supported;
                break;
        default:
-               mac->ops.setup_eee = NULL;
+               break;
        }
 
        return ret_val;
@@ -943,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;
 }
 
@@ -1109,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
@@ -1420,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;
 }
 
@@ -1685,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;
@@ -2083,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;
@@ -2444,6 +2344,9 @@ s32 ixgbe_init_phy_ops_X550em(struct ixgbe_hw *hw)
 
        DEBUGFUNC("ixgbe_init_phy_ops_X550em");
 
+       hw->mac.ops.set_lan_id(hw);
+       ixgbe_read_mng_if_sel_x550em(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);
@@ -2477,13 +2380,18 @@ 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;
        }
 
        /* Identify the PHY or SFP module */
        ret_val = phy->ops.identify(hw);
-       if (ret_val == IXGBE_ERR_SFP_NOT_SUPPORTED)
+       if (ret_val == IXGBE_ERR_SFP_NOT_SUPPORTED ||
+           ret_val == IXGBE_ERR_PHY_ADDR_INVALID)
                return ret_val;
 
        /* Setup function pointers based on detected hardware */
@@ -2503,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.
@@ -2584,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);
 
@@ -2595,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. */
@@ -2676,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;
 }
 
@@ -2725,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);
@@ -2942,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;
 }
@@ -3763,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;
@@ -3780,7 +3725,19 @@ u32 ixgbe_get_supported_physical_layer_X550em(struct ixgbe_hw *hw)
                        physical_layer |= IXGBE_PHYSICAL_LAYER_1000BASE_T;
                break;
        case ixgbe_phy_fw:
-               physical_layer = IXGBE_PHYSICAL_LAYER_1000BASE_T;
+               if (hw->phy.speeds_supported & IXGBE_LINK_SPEED_1GB_FULL)
+                       physical_layer |= IXGBE_PHYSICAL_LAYER_1000BASE_T;
+               if (hw->phy.speeds_supported & IXGBE_LINK_SPEED_100_FULL)
+                       physical_layer |= IXGBE_PHYSICAL_LAYER_100BASE_TX;
+               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;
        }
@@ -4189,7 +4146,6 @@ void ixgbe_fc_autoneg_sgmii_x550em_a(struct ixgbe_hw *hw)
        u32 info[FW_PHY_ACT_DATA_COUNT] = { 0 };
        ixgbe_link_speed speed;
        bool link_up;
-       u32 fc;
 
        /* AN should have completed when the cable was plugged in.
         * Look for reasons to bail out.  Bail out if:
@@ -4217,21 +4173,8 @@ void ixgbe_fc_autoneg_sgmii_x550em_a(struct ixgbe_hw *hw)
                goto out;
        }
 
-       /* Get the advertized flow control and modify it to indicate
-        * pause and asymmetric pause instead of rx and tx
-        */
-       fc = info[0];
-       if (fc & FW_PHY_ACT_GET_LINK_INFO_FC_RX)
-               fc ^= FW_PHY_ACT_GET_LINK_INFO_FC_TX;
-
-       /* Modify link partner's flow control to indicate pause and
-        * asymmetric pause instead of rx and tx
-        */
-       if (fc & FW_PHY_ACT_GET_LINK_INFO_LP_FC_RX)
-               fc ^= FW_PHY_ACT_GET_LINK_INFO_LP_FC_TX;
-
        /* Negotiate the flow control */
-       status = ixgbe_negotiate_fc(hw, fc, fc,
+       status = ixgbe_negotiate_fc(hw, info[0], info[0],
                                    FW_PHY_ACT_GET_LINK_INFO_FC_RX,
                                    FW_PHY_ACT_GET_LINK_INFO_FC_TX,
                                    FW_PHY_ACT_GET_LINK_INFO_LP_FC_RX,
@@ -4413,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;
 }