netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net-next 0/4] net: phy: improve generic clause 45 aneg configuration
@ 2019-02-18 20:18 Heiner Kallweit
  2019-02-18 20:26 ` [PATCH net-next 1/4] net: phy: export genphy_config_eee_advert Heiner Kallweit
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: Heiner Kallweit @ 2019-02-18 20:18 UTC (permalink / raw)
  To: Andrew Lunn, Florian Fainelli, David Miller; +Cc: netdev

Improve generic clause 45 aneg configuration.

Heiner Kallweit (4):
  net: phy: export genphy_config_eee_advert
  net: phy: use genphy_config_eee_advert in genphy_c45_an_config_aneg
  net: phy: add genphy_c45_check_and_restart_aneg
  net: phy: marvell10g: use genphy_c45_check_and_restart_aneg in
    mv3310_config_aneg

 drivers/net/phy/marvell10g.c | 15 +--------------
 drivers/net/phy/phy-c45.c    | 34 +++++++++++++++++++++++++++++++++-
 drivers/net/phy/phy_device.c |  3 ++-
 include/linux/phy.h          |  2 ++
 4 files changed, 38 insertions(+), 16 deletions(-)

-- 
2.20.1


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH net-next 1/4] net: phy: export genphy_config_eee_advert
  2019-02-18 20:18 [PATCH net-next 0/4] net: phy: improve generic clause 45 aneg configuration Heiner Kallweit
@ 2019-02-18 20:26 ` Heiner Kallweit
  2019-02-18 20:27 ` [PATCH net-next 2/4] net: phy: use genphy_config_eee_advert in genphy_c45_an_config_aneg Heiner Kallweit
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: Heiner Kallweit @ 2019-02-18 20:26 UTC (permalink / raw)
  To: Andrew Lunn, Florian Fainelli, David Miller, Russell King - ARM Linux
  Cc: netdev

We want to use this function in phy-c45.c too, therefore export it.

Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
---
 drivers/net/phy/phy_device.c | 3 ++-
 include/linux/phy.h          | 1 +
 2 files changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/net/phy/phy_device.c b/drivers/net/phy/phy_device.c
index 4bb3b6c28..49fdd1ee7 100644
--- a/drivers/net/phy/phy_device.c
+++ b/drivers/net/phy/phy_device.c
@@ -1575,7 +1575,7 @@ static int genphy_config_advert(struct phy_device *phydev)
  *   efficent ethernet modes. Returns 0 if the PHY's advertisement hasn't
  *   changed, and 1 if it has changed.
  */
-static int genphy_config_eee_advert(struct phy_device *phydev)
+int genphy_config_eee_advert(struct phy_device *phydev)
 {
 	int err;
 
@@ -1588,6 +1588,7 @@ static int genphy_config_eee_advert(struct phy_device *phydev)
 	/* If the call failed, we assume that EEE is not supported */
 	return err < 0 ? 0 : err;
 }
+EXPORT_SYMBOL(genphy_config_eee_advert);
 
 /**
  * genphy_setup_forced - configures/forces speed/duplex from @phydev
diff --git a/include/linux/phy.h b/include/linux/phy.h
index 3db507e68..761131de4 100644
--- a/include/linux/phy.h
+++ b/include/linux/phy.h
@@ -1077,6 +1077,7 @@ void phy_attached_info(struct phy_device *phydev);
 int genphy_config_init(struct phy_device *phydev);
 int genphy_setup_forced(struct phy_device *phydev);
 int genphy_restart_aneg(struct phy_device *phydev);
+int genphy_config_eee_advert(struct phy_device *phydev);
 int genphy_config_aneg(struct phy_device *phydev);
 int genphy_aneg_done(struct phy_device *phydev);
 int genphy_update_link(struct phy_device *phydev);
-- 
2.20.1




^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH net-next 2/4] net: phy: use genphy_config_eee_advert in genphy_c45_an_config_aneg
  2019-02-18 20:18 [PATCH net-next 0/4] net: phy: improve generic clause 45 aneg configuration Heiner Kallweit
  2019-02-18 20:26 ` [PATCH net-next 1/4] net: phy: export genphy_config_eee_advert Heiner Kallweit
@ 2019-02-18 20:27 ` Heiner Kallweit
  2019-02-18 20:27 ` [PATCH net-next 3/4] net: phy: add genphy_c45_check_and_restart_aneg Heiner Kallweit
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: Heiner Kallweit @ 2019-02-18 20:27 UTC (permalink / raw)
  To: Andrew Lunn, Florian Fainelli, David Miller, Russell King - ARM Linux
  Cc: netdev

Like in genphy_config_aneg() for clause 22 PHY's, we should keep modes
from being advertised that are known to be broken with EEE.

Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
---
 drivers/net/phy/phy-c45.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/net/phy/phy-c45.c b/drivers/net/phy/phy-c45.c
index 16636d49b..2f5721430 100644
--- a/drivers/net/phy/phy-c45.c
+++ b/drivers/net/phy/phy-c45.c
@@ -89,12 +89,14 @@ EXPORT_SYMBOL_GPL(genphy_c45_pma_setup_forced);
  */
 int genphy_c45_an_config_aneg(struct phy_device *phydev)
 {
-	int changed = 0, ret;
+	int changed, ret;
 	u32 adv;
 
 	linkmode_and(phydev->advertising, phydev->advertising,
 		     phydev->supported);
 
+	changed = genphy_config_eee_advert(phydev);
+
 	adv = linkmode_adv_to_mii_adv_t(phydev->advertising);
 
 	ret = phy_modify_mmd(phydev, MDIO_MMD_AN, MDIO_AN_ADVERTISE,
-- 
2.20.1




^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH net-next 3/4] net: phy: add genphy_c45_check_and_restart_aneg
  2019-02-18 20:18 [PATCH net-next 0/4] net: phy: improve generic clause 45 aneg configuration Heiner Kallweit
  2019-02-18 20:26 ` [PATCH net-next 1/4] net: phy: export genphy_config_eee_advert Heiner Kallweit
  2019-02-18 20:27 ` [PATCH net-next 2/4] net: phy: use genphy_config_eee_advert in genphy_c45_an_config_aneg Heiner Kallweit
@ 2019-02-18 20:27 ` Heiner Kallweit
  2019-02-18 20:27 ` [PATCH net-next 4/4] net: phy: marvell10g: use genphy_c45_check_and_restart_aneg in mv3310_config_aneg Heiner Kallweit
  2019-02-21 21:03 ` [PATCH net-next 0/4] net: phy: improve generic clause 45 aneg configuration David Miller
  4 siblings, 0 replies; 6+ messages in thread
From: Heiner Kallweit @ 2019-02-18 20:27 UTC (permalink / raw)
  To: Andrew Lunn, Florian Fainelli, David Miller, Russell King - ARM Linux
  Cc: netdev

This function will be used by config_aneg callback implementations of
PHY drivers and allows to reduce boilerplate code.

Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
---
 drivers/net/phy/phy-c45.c | 30 ++++++++++++++++++++++++++++++
 include/linux/phy.h       |  1 +
 2 files changed, 31 insertions(+)

diff --git a/drivers/net/phy/phy-c45.c b/drivers/net/phy/phy-c45.c
index 2f5721430..fc3173cc0 100644
--- a/drivers/net/phy/phy-c45.c
+++ b/drivers/net/phy/phy-c45.c
@@ -156,6 +156,36 @@ int genphy_c45_restart_aneg(struct phy_device *phydev)
 }
 EXPORT_SYMBOL_GPL(genphy_c45_restart_aneg);
 
+/**
+ * genphy_c45_check_and_restart_aneg - Enable and restart auto-negotiation
+ * @phydev: target phy_device struct
+ * @restart: whether aneg restart is requested
+ *
+ * This assumes that the auto-negotiation MMD is present.
+ *
+ * Check, and restart auto-negotiation if needed.
+ */
+int genphy_c45_check_and_restart_aneg(struct phy_device *phydev, bool restart)
+{
+	int ret = 0;
+
+	if (!restart) {
+		/* Configure and restart aneg if it wasn't set before */
+		ret = phy_read_mmd(phydev, MDIO_MMD_AN, MDIO_CTRL1);
+		if (ret < 0)
+			return ret;
+
+		if (!(ret & MDIO_AN_CTRL1_ENABLE))
+			restart = true;
+	}
+
+	if (restart)
+		ret = genphy_c45_restart_aneg(phydev);
+
+	return ret;
+}
+EXPORT_SYMBOL_GPL(genphy_c45_check_and_restart_aneg);
+
 /**
  * genphy_c45_aneg_done - return auto-negotiation complete status
  * @phydev: target phy_device struct
diff --git a/include/linux/phy.h b/include/linux/phy.h
index 761131de4..8e9fc5764 100644
--- a/include/linux/phy.h
+++ b/include/linux/phy.h
@@ -1097,6 +1097,7 @@ int genphy_write_mmd_unsupported(struct phy_device *phdev, int devnum,
 
 /* Clause 45 PHY */
 int genphy_c45_restart_aneg(struct phy_device *phydev);
+int genphy_c45_check_and_restart_aneg(struct phy_device *phydev, bool restart);
 int genphy_c45_aneg_done(struct phy_device *phydev);
 int genphy_c45_read_link(struct phy_device *phydev);
 int genphy_c45_read_lpa(struct phy_device *phydev);
-- 
2.20.1




^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH net-next 4/4] net: phy: marvell10g: use genphy_c45_check_and_restart_aneg in mv3310_config_aneg
  2019-02-18 20:18 [PATCH net-next 0/4] net: phy: improve generic clause 45 aneg configuration Heiner Kallweit
                   ` (2 preceding siblings ...)
  2019-02-18 20:27 ` [PATCH net-next 3/4] net: phy: add genphy_c45_check_and_restart_aneg Heiner Kallweit
@ 2019-02-18 20:27 ` Heiner Kallweit
  2019-02-21 21:03 ` [PATCH net-next 0/4] net: phy: improve generic clause 45 aneg configuration David Miller
  4 siblings, 0 replies; 6+ messages in thread
From: Heiner Kallweit @ 2019-02-18 20:27 UTC (permalink / raw)
  To: Andrew Lunn, Florian Fainelli, David Miller, Russell King - ARM Linux
  Cc: netdev

Use new function genphy_c45_check_and_restart_aneg() to reduce
boilerplate code.

Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
---
 drivers/net/phy/marvell10g.c | 15 +--------------
 1 file changed, 1 insertion(+), 14 deletions(-)

diff --git a/drivers/net/phy/marvell10g.c b/drivers/net/phy/marvell10g.c
index 67066127b..8cbf35964 100644
--- a/drivers/net/phy/marvell10g.c
+++ b/drivers/net/phy/marvell10g.c
@@ -291,20 +291,7 @@ static int mv3310_config_aneg(struct phy_device *phydev)
 	if (ret > 0)
 		changed = true;
 
-	if (!changed) {
-		/* Configure and restart aneg if it wasn't set before */
-		ret = phy_read_mmd(phydev, MDIO_MMD_AN, MDIO_CTRL1);
-		if (ret < 0)
-			return ret;
-
-		if (!(ret & MDIO_AN_CTRL1_ENABLE))
-			changed = 1;
-	}
-
-	if (changed)
-		ret = genphy_c45_restart_aneg(phydev);
-
-	return ret;
+	return genphy_c45_check_and_restart_aneg(phydev, changed);
 }
 
 static int mv3310_aneg_done(struct phy_device *phydev)
-- 
2.20.1



^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH net-next 0/4] net: phy: improve generic clause 45 aneg configuration
  2019-02-18 20:18 [PATCH net-next 0/4] net: phy: improve generic clause 45 aneg configuration Heiner Kallweit
                   ` (3 preceding siblings ...)
  2019-02-18 20:27 ` [PATCH net-next 4/4] net: phy: marvell10g: use genphy_c45_check_and_restart_aneg in mv3310_config_aneg Heiner Kallweit
@ 2019-02-21 21:03 ` David Miller
  4 siblings, 0 replies; 6+ messages in thread
From: David Miller @ 2019-02-21 21:03 UTC (permalink / raw)
  To: hkallweit1; +Cc: andrew, f.fainelli, netdev

From: Heiner Kallweit <hkallweit1@gmail.com>
Date: Mon, 18 Feb 2019 21:18:35 +0100

> Improve generic clause 45 aneg configuration.

Series applied, thank you.

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2019-02-21 21:03 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-02-18 20:18 [PATCH net-next 0/4] net: phy: improve generic clause 45 aneg configuration Heiner Kallweit
2019-02-18 20:26 ` [PATCH net-next 1/4] net: phy: export genphy_config_eee_advert Heiner Kallweit
2019-02-18 20:27 ` [PATCH net-next 2/4] net: phy: use genphy_config_eee_advert in genphy_c45_an_config_aneg Heiner Kallweit
2019-02-18 20:27 ` [PATCH net-next 3/4] net: phy: add genphy_c45_check_and_restart_aneg Heiner Kallweit
2019-02-18 20:27 ` [PATCH net-next 4/4] net: phy: marvell10g: use genphy_c45_check_and_restart_aneg in mv3310_config_aneg Heiner Kallweit
2019-02-21 21:03 ` [PATCH net-next 0/4] net: phy: improve generic clause 45 aneg configuration David Miller

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).