net/ixgbe/base: support MAC X550em/X557 LED on/off
[dpdk.git] / drivers / net / ixgbe / base / ixgbe_x550.c
index 1fd7ffb..674dc14 100644 (file)
@@ -1311,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;
 }
 
@@ -2373,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;
        }
@@ -2486,14 +2497,16 @@ s32 ixgbe_reset_hw_X550em(struct ixgbe_hw *hw)
        u32 ctrl = 0;
        u32 i;
        bool link_up = false;
+       u32 swfw_mask = hw->phy.phy_semaphore_mask;
 
        DEBUGFUNC("ixgbe_reset_hw_X550em");
 
        /* 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);
 
@@ -2502,14 +2515,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. */
@@ -2540,9 +2562,17 @@ mac_reset_top:
                        ctrl = IXGBE_CTRL_RST;
        }
 
+       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_ERR_SWFW_SYNC;
+       }
+
        ctrl |= IXGBE_READ_REG(hw, IXGBE_CTRL);
        IXGBE_WRITE_REG(hw, IXGBE_CTRL, ctrl);
        IXGBE_WRITE_FLUSH(hw);
+       hw->mac.ops.release_swfw_sync(hw, swfw_mask);
 
        /* Poll for reset bit to self-clear meaning reset is complete */
        for (i = 0; i < 10; i++) {
@@ -2583,6 +2613,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;
 }
 
@@ -2639,6 +2672,9 @@ s32 ixgbe_setup_kr_x550em(struct ixgbe_hw *hw)
        if (hw->phy.autoneg_advertised & IXGBE_LINK_SPEED_2_5GB_FULL)
                return IXGBE_SUCCESS;
 
+       if (ixgbe_check_reset_blocked(hw))
+               return 0;
+
        return ixgbe_setup_kr_speed_x550em(hw, hw->phy.autoneg_advertised);
 }
 
@@ -2670,53 +2706,18 @@ s32 ixgbe_setup_mac_link_sfp_x550em(struct ixgbe_hw *hw,
        if (ret_val != IXGBE_SUCCESS)
                return ret_val;
 
-       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 = hw->link.ops.write_link(hw, hw->link.addr, reg_slice,
-                                                 reg_val);
+       /* Configure internal PHY for KR/KX. */
+       ixgbe_setup_kr_speed_x550em(hw, speed);
 
-               reg_slice = IXGBE_CS4227_LINE_SPARE24_LSB +
-                           (hw->bus.lan_id << 12);
+       /* 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 = hw->link.ops.write_link(hw, hw->link.addr, 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 = hw->link.ops.write_link(hw, hw->link.addr, 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 = hw->link.ops.write_link(hw, hw->link.addr, reg_slice,
-                                                 reg_val);
-
-               /* 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 = hw->link.ops.write_link(hw, hw->link.addr, reg_slice,
-                                                 reg_val);
-       }
+       ret_val = hw->link.ops.write_link(hw, hw->link.addr, reg_slice,
+                                         reg_val);
        return ret_val;
 }
 
@@ -3672,9 +3673,9 @@ s32 ixgbe_update_flash_X550(struct ixgbe_hw *hw)
  *
  *  Determines physical layer capabilities of the current configuration.
  **/
-u32 ixgbe_get_supported_physical_layer_X550em(struct ixgbe_hw *hw)
+u64 ixgbe_get_supported_physical_layer_X550em(struct ixgbe_hw *hw)
 {
-       u32 physical_layer = IXGBE_PHYSICAL_LAYER_UNKNOWN;
+       u64 physical_layer = IXGBE_PHYSICAL_LAYER_UNKNOWN;
        u16 ext_ability = 0;
 
        DEBUGFUNC("ixgbe_get_supported_physical_layer_X550em");
@@ -3683,6 +3684,20 @@ u32 ixgbe_get_supported_physical_layer_X550em(struct ixgbe_hw *hw)
 
        switch (hw->phy.type) {
        case ixgbe_phy_x550em_kr:
+               if (hw->mac.type == ixgbe_mac_X550EM_a) {
+                       if (hw->phy.nw_mng_if_sel &
+                           IXGBE_NW_MNG_IF_SEL_PHY_SPEED_2_5G) {
+                               physical_layer =
+                                       IXGBE_PHYSICAL_LAYER_2500BASE_KX;
+                               break;
+                       } else if (hw->device_id ==
+                                  IXGBE_DEV_ID_X550EM_A_KR_L) {
+                               physical_layer =
+                                       IXGBE_PHYSICAL_LAYER_1000BASE_KX;
+                               break;
+                       }
+               }
+               /* fall through */
        case ixgbe_phy_x550em_xfi:
                physical_layer = IXGBE_PHYSICAL_LAYER_10GBASE_KR |
                                 IXGBE_PHYSICAL_LAYER_1000BASE_KX;
@@ -4013,6 +4028,9 @@ s32 ixgbe_setup_fc_X550em(struct ixgbe_hw *hw)
                /* This device does not fully support AN. */
                hw->fc.disable_fc_autoneg = true;
                break;
+       case IXGBE_DEV_ID_X550EM_X_XFI:
+               hw->fc.disable_fc_autoneg = true;
+               break;
        default:
                break;
        }
@@ -4332,21 +4350,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;
 }
 
@@ -4579,7 +4610,8 @@ s32 ixgbe_led_on_t_X550em(struct ixgbe_hw *hw, u32 led_idx)
        ixgbe_write_phy_reg(hw, IXGBE_X557_LED_PROVISIONING + led_idx,
                            IXGBE_MDIO_VENDOR_SPECIFIC_1_DEV_TYPE, phy_data);
 
-       return IXGBE_SUCCESS;
+       /* Some designs have the LEDs wired to the MAC */
+       return ixgbe_led_on_generic(hw, led_idx);
 }
 
 /**
@@ -4603,7 +4635,8 @@ s32 ixgbe_led_off_t_X550em(struct ixgbe_hw *hw, u32 led_idx)
        ixgbe_write_phy_reg(hw, IXGBE_X557_LED_PROVISIONING + led_idx,
                            IXGBE_MDIO_VENDOR_SPECIFIC_1_DEV_TYPE, phy_data);
 
-       return IXGBE_SUCCESS;
+       /* Some designs have the LEDs wired to the MAC */
+       return ixgbe_led_off_generic(hw, led_idx);
 }
 
 /**