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.rus...@intel.com>
---
This patch should apply to version 4.1.1 of the ixgbe driver on Source
Forge. This is only provided for testing purposes.
---
 src/ixgbe_phy.c  |   67 +++++++++++++++++++++++++++++++++++-------------------
 src/ixgbe_type.h |    1 +
 2 files changed, 45 insertions(+), 23 deletions(-)

diff --git a/src/ixgbe_phy.c b/src/ixgbe_phy.c
index 102dd53f6230..c45f5df5a355 100644
--- a/src/ixgbe_phy.c
+++ b/src/ixgbe_phy.c
@@ -946,6 +946,46 @@ s32 ixgbe_setup_phy_link_speed_generic(struct ixgbe_hw *hw,
 }
 
 /**
+ * ixgbe_get_copper_speeds_supported - Get copper link speeds from phy
+ * @hw: pointer to hardware structure
+ *
+ * Determines the supported link capabilities by reading the PHY auto
+ * negotiation register.
+ **/
+static s32 ixgbe_get_copper_speeds_supported(struct ixgbe_hw *hw)
+{
+       s32 status;
+       u16 speed_ability;
+
+       status = hw->phy.ops.read_reg(hw, IXGBE_MDIO_PHY_SPEED_ABILITY,
+                                     IXGBE_MDIO_PMA_PMD_DEV_TYPE,
+                                     &speed_ability);
+       if (status)
+               return status;
+
+       if (speed_ability & IXGBE_MDIO_PHY_SPEED_10G)
+               hw->phy.speeds_supported |= IXGBE_LINK_SPEED_10GB_FULL;
+       if (speed_ability & IXGBE_MDIO_PHY_SPEED_1G)
+               hw->phy.speeds_supported |= IXGBE_LINK_SPEED_1GB_FULL;
+       if (speed_ability & IXGBE_MDIO_PHY_SPEED_100M)
+               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;
+       }
+
+       return status;
+}
+
+/**
  *  ixgbe_get_copper_link_capabilities_generic - Determines link capabilities
  *  @hw: pointer to hardware structure
  *  @speed: pointer to link speed
@@ -958,36 +998,17 @@ s32 ixgbe_get_copper_link_capabilities_generic(struct 
ixgbe_hw *hw,
                                               ixgbe_link_speed *speed,
                                               bool *autoneg)
 {
-       s32 status;
-       u16 speed_ability;
+       s32 status = IXGBE_SUCCESS;
 
        DEBUGFUNC("ixgbe_get_copper_link_capabilities_generic");
 
-       *speed = 0;
        *autoneg = true;
 
-       status = hw->phy.ops.read_reg(hw, IXGBE_MDIO_PHY_SPEED_ABILITY,
-                                     IXGBE_MDIO_PMA_PMD_DEV_TYPE,
-                                     &speed_ability);
-
-       if (status == IXGBE_SUCCESS) {
-               if (speed_ability & IXGBE_MDIO_PHY_SPEED_10G)
-                       *speed |= IXGBE_LINK_SPEED_10GB_FULL;
-               if (speed_ability & IXGBE_MDIO_PHY_SPEED_1G)
-                       *speed |= IXGBE_LINK_SPEED_1GB_FULL;
-               if (speed_ability & IXGBE_MDIO_PHY_SPEED_100M)
-                       *speed |= IXGBE_LINK_SPEED_100_FULL;
-       }
-
-       /* Internal PHY does not support 100 Mbps */
-       if (hw->mac.type == ixgbe_mac_X550EM_x)
-               *speed &= ~IXGBE_LINK_SPEED_100_FULL;
+       if (!hw->phy.speeds_supported)
+               status = ixgbe_get_copper_speeds_supported(hw);
 
-       if (hw->mac.type == ixgbe_mac_X550) {
-               *speed |= IXGBE_LINK_SPEED_2_5GB_FULL;
-               *speed |= IXGBE_LINK_SPEED_5GB_FULL;
-       }
 
+       *speed = hw->phy.speeds_supported;
        return status;
 }
 
diff --git a/src/ixgbe_type.h b/src/ixgbe_type.h
index ccab5a7b0107..3e7ef98ac68a 100644
--- a/src/ixgbe_type.h
+++ b/src/ixgbe_type.h
@@ -3693,6 +3693,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;
>From 1234567890abcdef Mon Sep 17 00:00:00 2001
From: Mark D Rustad <mark.d.rus...@intel.com>
Date: 2015-06-23 14:18:49 -0700
Subject: [TEST PATCH] ixgbe: Avoid needless phy access on copper phys

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.rus...@intel.com>
--- 
 src/ixgbe_phy.c  |   67 +++++++++++++++++++++++++++++++++++-------------------
 src/ixgbe_type.h |    1 +
 2 files changed, 45 insertions(+), 23 deletions(-)

diff --git a/src/ixgbe_phy.c b/src/ixgbe_phy.c
index 102dd53f6230..c45f5df5a355 100644
--- a/src/ixgbe_phy.c
+++ b/src/ixgbe_phy.c
@@ -946,6 +946,46 @@ s32 ixgbe_setup_phy_link_speed_generic(struct ixgbe_hw *hw,
 }
 
 /**
+ * ixgbe_get_copper_speeds_supported - Get copper link speeds from phy
+ * @hw: pointer to hardware structure
+ *
+ * Determines the supported link capabilities by reading the PHY auto
+ * negotiation register.
+ **/
+static s32 ixgbe_get_copper_speeds_supported(struct ixgbe_hw *hw)
+{
+       s32 status;
+       u16 speed_ability;
+
+       status = hw->phy.ops.read_reg(hw, IXGBE_MDIO_PHY_SPEED_ABILITY,
+                                     IXGBE_MDIO_PMA_PMD_DEV_TYPE,
+                                     &speed_ability);
+       if (status)
+               return status;
+
+       if (speed_ability & IXGBE_MDIO_PHY_SPEED_10G)
+               hw->phy.speeds_supported |= IXGBE_LINK_SPEED_10GB_FULL;
+       if (speed_ability & IXGBE_MDIO_PHY_SPEED_1G)
+               hw->phy.speeds_supported |= IXGBE_LINK_SPEED_1GB_FULL;
+       if (speed_ability & IXGBE_MDIO_PHY_SPEED_100M)
+               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;
+       }
+
+       return status;
+}
+
+/**
  *  ixgbe_get_copper_link_capabilities_generic - Determines link capabilities
  *  @hw: pointer to hardware structure
  *  @speed: pointer to link speed
@@ -958,36 +998,17 @@ s32 ixgbe_get_copper_link_capabilities_generic(struct 
ixgbe_hw *hw,
                                               ixgbe_link_speed *speed,
                                               bool *autoneg)
 {
-       s32 status;
-       u16 speed_ability;
+       s32 status = IXGBE_SUCCESS;
 
        DEBUGFUNC("ixgbe_get_copper_link_capabilities_generic");
 
-       *speed = 0;
        *autoneg = true;
 
-       status = hw->phy.ops.read_reg(hw, IXGBE_MDIO_PHY_SPEED_ABILITY,
-                                     IXGBE_MDIO_PMA_PMD_DEV_TYPE,
-                                     &speed_ability);
-
-       if (status == IXGBE_SUCCESS) {
-               if (speed_ability & IXGBE_MDIO_PHY_SPEED_10G)
-                       *speed |= IXGBE_LINK_SPEED_10GB_FULL;
-               if (speed_ability & IXGBE_MDIO_PHY_SPEED_1G)
-                       *speed |= IXGBE_LINK_SPEED_1GB_FULL;
-               if (speed_ability & IXGBE_MDIO_PHY_SPEED_100M)
-                       *speed |= IXGBE_LINK_SPEED_100_FULL;
-       }
-
-       /* Internal PHY does not support 100 Mbps */
-       if (hw->mac.type == ixgbe_mac_X550EM_x)
-               *speed &= ~IXGBE_LINK_SPEED_100_FULL;
+       if (!hw->phy.speeds_supported)
+               status = ixgbe_get_copper_speeds_supported(hw);
 
-       if (hw->mac.type == ixgbe_mac_X550) {
-               *speed |= IXGBE_LINK_SPEED_2_5GB_FULL;
-               *speed |= IXGBE_LINK_SPEED_5GB_FULL;
-       }
 
+       *speed = hw->phy.speeds_supported;
        return status;
 }
 
diff --git a/src/ixgbe_type.h b/src/ixgbe_type.h
index ccab5a7b0107..3e7ef98ac68a 100644
--- a/src/ixgbe_type.h
+++ b/src/ixgbe_type.h
@@ -3693,6 +3693,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;
------------------------------------------------------------------------------
Monitor 25 network devices or servers for free with OpManager!
OpManager is web-based network management software that monitors 
network devices and physical & virtual servers, alerts via email & sms 
for fault. Monitor 25 devices for free with no restriction. Download now
http://ad.doubleclick.net/ddm/clk/292181274;119417398;o
_______________________________________________
E1000-devel mailing list
E1000-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/e1000-devel
To learn more about Intel&#174; Ethernet, visit 
http://communities.intel.com/community/wired

Reply via email to