net/ixgbe/base: clean up X557 link status check
authorWei Dai <wei.dai@intel.com>
Wed, 21 Dec 2016 09:47:49 +0000 (17:47 +0800)
committerFerruh Yigit <ferruh.yigit@intel.com>
Tue, 17 Jan 2017 18:40:51 +0000 (19:40 +0100)
This patch cleans up the code and clarifies the comment around
the X557 PHY link status check in ixgbe_check_link_t_x550em().

Signed-off-by: Wei Dai <wei.dai@intel.com>
drivers/net/ixgbe/base/ixgbe_x550.c

index f5143f9..69aa9d5 100644 (file)
@@ -4660,7 +4660,7 @@ s32 ixgbe_check_link_t_X550em(struct ixgbe_hw *hw, ixgbe_link_speed *speed,
                              bool *link_up, bool link_up_wait_to_complete)
 {
        u32 status;
-       u16 autoneg_status;
+       u16 i, autoneg_status = 0;
 
        if (hw->mac.ops.get_media_type(hw) != ixgbe_media_type_copper)
                return IXGBE_ERR_CONFIG;
@@ -4673,21 +4673,18 @@ s32 ixgbe_check_link_t_X550em(struct ixgbe_hw *hw, ixgbe_link_speed *speed,
                return status;
 
        /* MAC link is up, so check external PHY link.
-        * Read this twice back to back to indicate current status.
+        * X557 PHY. Link status is latching low, and can only be used to detect
+        * link drop, and not the current status of the link without performing
+        * back-to-back reads.
         */
-       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);
+       for (i = 0; i < 2; i++) {
+               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;
+               if (status != IXGBE_SUCCESS)
+                       return status;
+       }
 
        /* If external PHY link is not up, then indicate link not up */
        if (!(autoneg_status & IXGBE_MDIO_AUTO_NEG_LINK_STATUS))