[12/21] net/ixgbe/base: create dedicated func to restart auto nego

Message ID 20200612032410.20864-13-guinanx.sun@intel.com (mailing list archive)
State Superseded, archived
Delegated to: Qi Zhang
Headers
Series update ixgbe base code |

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/Intel-compilation success Compilation OK

Commit Message

Guinan Sun June 12, 2020, 3:24 a.m. UTC
  Code to restart auto negotiation on PHY is already used in two places
and is needed in CORE repo of ixgben. This patch places it in dedicated
function for code clarity and makes it available outside the SHARED repo.

Testing Hints (required if no HSD):
Check if link goes up and traffic works.
Change speed on the uplink.

Signed-off-by: Jakub Chylkowski <jakubx.chylkowski@intel.com>
Signed-off-by: Guinan Sun <guinanx.sun@intel.com>
---
 drivers/net/ixgbe/base/ixgbe_phy.c | 48 ++++++++++++++----------------
 drivers/net/ixgbe/base/ixgbe_phy.h |  1 +
 2 files changed, 23 insertions(+), 26 deletions(-)
  

Comments

Ferruh Yigit June 22, 2020, 11:59 a.m. UTC | #1
On 6/12/2020 4:24 AM, Guinan Sun wrote:
> Code to restart auto negotiation on PHY is already used in two places
> and is needed in CORE repo of ixgben. 

ixgben?

> This patch places it in dedicated
> function for code clarity and makes it available outside the SHARED repo.
> 
> Testing Hints (required if no HSD):

HSD?

> Check if link goes up and traffic works.
> Change speed on the uplink.
> 
> Signed-off-by: Jakub Chylkowski <jakubx.chylkowski@intel.com>
> Signed-off-by: Guinan Sun <guinanx.sun@intel.com>

<...>
  

Patch

diff --git a/drivers/net/ixgbe/base/ixgbe_phy.c b/drivers/net/ixgbe/base/ixgbe_phy.c
index 823cf161e..620154a41 100644
--- a/drivers/net/ixgbe/base/ixgbe_phy.c
+++ b/drivers/net/ixgbe/base/ixgbe_phy.c
@@ -542,6 +542,26 @@  s32 ixgbe_reset_phy_generic(struct ixgbe_hw *hw)
 	return status;
 }
 
+/**
+ * ixgbe_restart_auto_neg - Restart auto negotiation on the PHY
+ * @hw: pointer to hardware structure
+ **/
+void ixgbe_restart_auto_neg(struct ixgbe_hw *hw)
+{
+	u16 autoneg_reg;
+
+	/* Check if PHY reset is blocked by MNG FW */
+	if (ixgbe_check_reset_blocked(hw))
+		return;
+
+	/* Restart PHY auto-negotiation. */
+	hw->phy.ops.read_reg(hw, IXGBE_MDIO_AUTO_NEG_CONTROL,
+				IXGBE_MDIO_AUTO_NEG_DEV_TYPE, &autoneg_reg);
+	autoneg_reg |= IXGBE_MII_RESTART;
+	hw->phy.ops.write_reg(hw, IXGBE_MDIO_AUTO_NEG_CONTROL,
+				IXGBE_MDIO_AUTO_NEG_DEV_TYPE, autoneg_reg);
+}
+
 /**
  * ixgbe_read_phy_mdi - Reads a value from a specified PHY register without
  * the SWFW lock
@@ -826,19 +846,7 @@  s32 ixgbe_setup_phy_link_generic(struct ixgbe_hw *hw)
 			      IXGBE_MDIO_AUTO_NEG_DEV_TYPE,
 			      autoneg_reg);
 
-	/* Blocked by MNG FW so don't reset PHY */
-	if (ixgbe_check_reset_blocked(hw))
-		return status;
-
-	/* Restart PHY auto-negotiation. */
-	hw->phy.ops.read_reg(hw, IXGBE_MDIO_AUTO_NEG_CONTROL,
-			     IXGBE_MDIO_AUTO_NEG_DEV_TYPE, &autoneg_reg);
-
-	autoneg_reg |= IXGBE_MII_RESTART;
-
-	hw->phy.ops.write_reg(hw, IXGBE_MDIO_AUTO_NEG_CONTROL,
-			      IXGBE_MDIO_AUTO_NEG_DEV_TYPE, autoneg_reg);
-
+	ixgbe_restart_auto_neg(hw);
 	return status;
 }
 
@@ -1062,19 +1070,7 @@  s32 ixgbe_setup_phy_link_tnx(struct ixgbe_hw *hw)
 				      autoneg_reg);
 	}
 
-	/* Blocked by MNG FW so don't reset PHY */
-	if (ixgbe_check_reset_blocked(hw))
-		return status;
-
-	/* Restart PHY auto-negotiation. */
-	hw->phy.ops.read_reg(hw, IXGBE_MDIO_AUTO_NEG_CONTROL,
-			     IXGBE_MDIO_AUTO_NEG_DEV_TYPE, &autoneg_reg);
-
-	autoneg_reg |= IXGBE_MII_RESTART;
-
-	hw->phy.ops.write_reg(hw, IXGBE_MDIO_AUTO_NEG_CONTROL,
-			      IXGBE_MDIO_AUTO_NEG_DEV_TYPE, autoneg_reg);
-
+	ixgbe_restart_auto_neg(hw);
 	return status;
 }
 
diff --git a/drivers/net/ixgbe/base/ixgbe_phy.h b/drivers/net/ixgbe/base/ixgbe_phy.h
index a06c3be17..e28c52a7b 100644
--- a/drivers/net/ixgbe/base/ixgbe_phy.h
+++ b/drivers/net/ixgbe/base/ixgbe_phy.h
@@ -133,6 +133,7 @@  enum ixgbe_phy_type ixgbe_get_phy_type_from_id(u32 phy_id);
 s32 ixgbe_get_phy_id(struct ixgbe_hw *hw);
 s32 ixgbe_identify_phy_generic(struct ixgbe_hw *hw);
 s32 ixgbe_reset_phy_generic(struct ixgbe_hw *hw);
+void ixgbe_restart_auto_neg(struct ixgbe_hw *hw);
 s32 ixgbe_read_phy_reg_mdi(struct ixgbe_hw *hw, u32 reg_addr, u32 device_type,
 			   u16 *phy_data);
 s32 ixgbe_write_phy_reg_mdi(struct ixgbe_hw *hw, u32 reg_addr, u32 device_type,