ixgbe: Avoid needless PHY access on copper phys
authorMark Rustad <mark.d.rustad@intel.com>
Fri, 26 Jun 2015 00:49:57 +0000 (17:49 -0700)
committerJeff Kirsher <jeffrey.t.kirsher@intel.com>
Wed, 2 Sep 2015 00:08:18 +0000 (17:08 -0700)
Avoid a needless PHY access on copper phys to save the 10ms wait
time for each PHY access. A helper function is introduced to
actually do the register access and process the contents.

Signed-off-by: Mark Rustad <mark.d.rustad@intel.com>
Signed-off-by: Jeff Kirsher <jeffrey.t.kirsher@intel.com>
drivers/net/ethernet/intel/ixgbe/ixgbe_phy.c
drivers/net/ethernet/intel/ixgbe/ixgbe_type.h

index 97275dce2a16dbfaa97353902d5cae36fea904eb..597d0b1c23701eadad2c3d9a68448acc7d4c941c 100644 (file)
@@ -730,39 +730,61 @@ s32 ixgbe_setup_phy_link_speed_generic(struct ixgbe_hw *hw,
 }
 
 /**
- * ixgbe_get_copper_link_capabilities_generic - Determines link capabilities
+ * ixgbe_get_copper_speeds_supported - Get copper link speed from phy
  * @hw: pointer to hardware structure
- * @speed: pointer to link speed
- * @autoneg: boolean auto-negotiation value
  *
- * Determines the link capabilities by reading the AUTOC register.
+ * Determines the supported link capabilities by reading the PHY auto
+ * negotiation register.
  */
-s32 ixgbe_get_copper_link_capabilities_generic(struct ixgbe_hw *hw,
-                                              ixgbe_link_speed *speed,
-                                              bool *autoneg)
+static s32 ixgbe_get_copper_speeds_supported(struct ixgbe_hw *hw)
 {
-       s32 status;
        u16 speed_ability;
-
-       *speed = 0;
-       *autoneg = true;
+       s32 status;
 
        status = hw->phy.ops.read_reg(hw, MDIO_SPEED, MDIO_MMD_PMAPMD,
                                      &speed_ability);
+       if (status)
+               return status;
 
-       if (status == 0) {
-               if (speed_ability & MDIO_SPEED_10G)
-                       *speed |= IXGBE_LINK_SPEED_10GB_FULL;
-               if (speed_ability & MDIO_PMA_SPEED_1000)
-                       *speed |= IXGBE_LINK_SPEED_1GB_FULL;
-               if (speed_ability & MDIO_PMA_SPEED_100)
-                       *speed |= IXGBE_LINK_SPEED_100_FULL;
+       if (speed_ability & MDIO_SPEED_10G)
+               hw->phy.speeds_supported |= IXGBE_LINK_SPEED_10GB_FULL;
+       if (speed_ability & MDIO_PMA_SPEED_1000)
+               hw->phy.speeds_supported |= IXGBE_LINK_SPEED_1GB_FULL;
+       if (speed_ability & MDIO_PMA_SPEED_100)
+               hw->phy.speeds_supported |= IXGBE_LINK_SPEED_100_FULL;
+
+       switch (hw->mac.type) {
+       case ixgbe_mac_X550:
+               hw->phy.speeds_supported |= IXGBE_LINK_SPEED_2_5GB_FULL;
+               hw->phy.speeds_supported |= IXGBE_LINK_SPEED_5GB_FULL;
+               break;
+       case ixgbe_mac_X550EM_x:
+               hw->phy.speeds_supported &= ~IXGBE_LINK_SPEED_100_FULL;
+               break;
+       default:
+               break;
        }
 
-       /* Internal PHY does not support 100 Mbps */
-       if (hw->mac.type == ixgbe_mac_X550EM_x)
-               *speed &= ~IXGBE_LINK_SPEED_100_FULL;
+       return 0;
+}
+
+/**
+ * ixgbe_get_copper_link_capabilities_generic - Determines link capabilities
+ * @hw: pointer to hardware structure
+ * @speed: pointer to link speed
+ * @autoneg: boolean auto-negotiation value
+ */
+s32 ixgbe_get_copper_link_capabilities_generic(struct ixgbe_hw *hw,
+                                              ixgbe_link_speed *speed,
+                                              bool *autoneg)
+{
+       s32 status = 0;
+
+       *autoneg = true;
+       if (!hw->phy.speeds_supported)
+               status = ixgbe_get_copper_speeds_supported(hw);
 
+       *speed = hw->phy.speeds_supported;
        return status;
 }
 
index a3eec19c9fdf8010ec76c36c6eb27a01c8db1af5..63689192b149a0d44d1dcf1edcfbe39f6f9d8158 100644 (file)
@@ -3384,6 +3384,7 @@ struct ixgbe_phy_info {
        u32                             phy_semaphore_mask;
        bool                            reset_disable;
        ixgbe_autoneg_advertised        autoneg_advertised;
+       ixgbe_link_speed                speeds_supported;
        enum ixgbe_smart_speed          smart_speed;
        bool                            smart_speed_active;
        bool                            multispeed_fiber;