netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Re: [PATCH net-next] net: phylink: add phylink_speed_(up|down) interface
       [not found] <E1jo2GQ-0005Lr-B4@rmk-PC.armlinux.org.uk>
@ 2020-06-25 23:01 ` David Miller
  0 siblings, 0 replies; 3+ messages in thread
From: David Miller @ 2020-06-25 23:01 UTC (permalink / raw)
  To: rmk+kernel; +Cc: andrew, f.fainelli, hkallweit1, dgcbueu, netdev, kuba

From: Russell King <rmk+kernel@armlinux.org.uk>
Date: Wed, 24 Jun 2020 11:04:18 +0100

> Add an interface for the phy_speed_(up|down) functions when a driver
> makes use of phylink. These pass the call through to phylib when we
> have a normal PHY attached (i.o.w., not a PHY on a SFP module.)
> 
> Signed-off-by: Russell King <rmk+kernel@armlinux.org.uk>

Applied.

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

* Re: [PATCH net-next] net: phylink: add phylink_speed_(up|down) interface
  2020-06-24 10:06 Russell King
@ 2020-06-24 22:20 ` Daniel González Cabanelas
  0 siblings, 0 replies; 3+ messages in thread
From: Daniel González Cabanelas @ 2020-06-24 22:20 UTC (permalink / raw)
  To: Russell King
  Cc: Andrew Lunn, Florian Fainelli, Heiner Kallweit, David S. Miller,
	netdev, Jakub Kicinski

Hi Russell.
I've tested my WoL patch reworked with the phylink_speed_(up|down)
functions on a LS421DE device and it works quite fine.

I'll sent another patch when this one got merged.

Thank you.
Daniel

El mié., 24 jun. 2020 a las 12:06, Russell King
(<rmk+kernel@armlinux.org.uk>) escribió:
>
> Add an interface for the phy_speed_(up|down) functions when a driver
> makes use of phylink. These pass the call through to phylib when we
> have a normal PHY attached (i.o.w., not a PHY on a SFP module.)
>
> Signed-off-by: Russell King <rmk+kernel@armlinux.org.uk>
> ---
> This is to support the work by Daniel González Cabanelas for mvneta WoL,
> but at the present time, this has no users (hence no patch 2). I hope
> mvneta WoL support can be revived soon with the aid of this patch.
> (Resent with Daniel's name fixed.)
>
>  drivers/net/phy/phylink.c | 48 +++++++++++++++++++++++++++++++++++++++
>  include/linux/phylink.h   |  2 ++
>  2 files changed, 50 insertions(+)
>
> diff --git a/drivers/net/phy/phylink.c b/drivers/net/phy/phylink.c
> index 7ce787c227b3..7cda1646bbf7 100644
> --- a/drivers/net/phy/phylink.c
> +++ b/drivers/net/phy/phylink.c
> @@ -1826,6 +1826,54 @@ int phylink_mii_ioctl(struct phylink *pl, struct ifreq *ifr, int cmd)
>  }
>  EXPORT_SYMBOL_GPL(phylink_mii_ioctl);
>
> +/**
> + * phylink_speed_down() - set the non-SFP PHY to lowest speed supported by both
> + *   link partners
> + * @pl: a pointer to a &struct phylink returned from phylink_create()
> + * @sync: perform action synchronously
> + *
> + * If we have a PHY that is not part of a SFP module, then set the speed
> + * as described in the phy_speed_down() function. Please see this function
> + * for a description of the @sync parameter.
> + *
> + * Returns zero if there is no PHY, otherwise as per phy_speed_down().
> + */
> +int phylink_speed_down(struct phylink *pl, bool sync)
> +{
> +       int ret = 0;
> +
> +       ASSERT_RTNL();
> +
> +       if (!pl->sfp_bus && pl->phydev)
> +               ret = phy_speed_down(pl->phydev, sync);
> +
> +       return ret;
> +}
> +EXPORT_SYMBOL_GPL(phylink_speed_down);
> +
> +/**
> + * phylink_speed_up() - restore the advertised speeds prior to the call to
> + *   phylink_speed_down()
> + * @pl: a pointer to a &struct phylink returned from phylink_create()
> + *
> + * If we have a PHY that is not part of a SFP module, then restore the
> + * PHY speeds as per phy_speed_up().
> + *
> + * Returns zero if there is no PHY, otherwise as per phy_speed_up().
> + */
> +int phylink_speed_up(struct phylink *pl)
> +{
> +       int ret = 0;
> +
> +       ASSERT_RTNL();
> +
> +       if (!pl->sfp_bus && pl->phydev)
> +               ret = phy_speed_up(pl->phydev);
> +
> +       return ret;
> +}
> +EXPORT_SYMBOL_GPL(phylink_speed_up);
> +
>  static void phylink_sfp_attach(void *upstream, struct sfp_bus *bus)
>  {
>         struct phylink *pl = upstream;
> diff --git a/include/linux/phylink.h b/include/linux/phylink.h
> index cc5b452a184e..b32b8b45421b 100644
> --- a/include/linux/phylink.h
> +++ b/include/linux/phylink.h
> @@ -392,6 +392,8 @@ int phylink_init_eee(struct phylink *, bool);
>  int phylink_ethtool_get_eee(struct phylink *, struct ethtool_eee *);
>  int phylink_ethtool_set_eee(struct phylink *, struct ethtool_eee *);
>  int phylink_mii_ioctl(struct phylink *, struct ifreq *, int);
> +int phylink_speed_down(struct phylink *pl, bool sync);
> +int phylink_speed_up(struct phylink *pl);
>
>  #define phylink_zero(bm) \
>         bitmap_zero(bm, __ETHTOOL_LINK_MODE_MASK_NBITS)
> --
> 2.20.1
>

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

* [PATCH net-next] net: phylink: add phylink_speed_(up|down) interface
@ 2020-06-24 10:06 Russell King
  2020-06-24 22:20 ` Daniel González Cabanelas
  0 siblings, 1 reply; 3+ messages in thread
From: Russell King @ 2020-06-24 10:06 UTC (permalink / raw)
  To: Andrew Lunn, Florian Fainelli, Heiner Kallweit,
	Daniel González Cabanelas
  Cc: David S. Miller, netdev, Jakub Kicinski

Add an interface for the phy_speed_(up|down) functions when a driver
makes use of phylink. These pass the call through to phylib when we
have a normal PHY attached (i.o.w., not a PHY on a SFP module.)

Signed-off-by: Russell King <rmk+kernel@armlinux.org.uk>
---
This is to support the work by Daniel González Cabanelas for mvneta WoL,
but at the present time, this has no users (hence no patch 2). I hope
mvneta WoL support can be revived soon with the aid of this patch.
(Resent with Daniel's name fixed.)

 drivers/net/phy/phylink.c | 48 +++++++++++++++++++++++++++++++++++++++
 include/linux/phylink.h   |  2 ++
 2 files changed, 50 insertions(+)

diff --git a/drivers/net/phy/phylink.c b/drivers/net/phy/phylink.c
index 7ce787c227b3..7cda1646bbf7 100644
--- a/drivers/net/phy/phylink.c
+++ b/drivers/net/phy/phylink.c
@@ -1826,6 +1826,54 @@ int phylink_mii_ioctl(struct phylink *pl, struct ifreq *ifr, int cmd)
 }
 EXPORT_SYMBOL_GPL(phylink_mii_ioctl);
 
+/**
+ * phylink_speed_down() - set the non-SFP PHY to lowest speed supported by both
+ *   link partners
+ * @pl: a pointer to a &struct phylink returned from phylink_create()
+ * @sync: perform action synchronously
+ *
+ * If we have a PHY that is not part of a SFP module, then set the speed
+ * as described in the phy_speed_down() function. Please see this function
+ * for a description of the @sync parameter.
+ *
+ * Returns zero if there is no PHY, otherwise as per phy_speed_down().
+ */
+int phylink_speed_down(struct phylink *pl, bool sync)
+{
+	int ret = 0;
+
+	ASSERT_RTNL();
+
+	if (!pl->sfp_bus && pl->phydev)
+		ret = phy_speed_down(pl->phydev, sync);
+
+	return ret;
+}
+EXPORT_SYMBOL_GPL(phylink_speed_down);
+
+/**
+ * phylink_speed_up() - restore the advertised speeds prior to the call to
+ *   phylink_speed_down()
+ * @pl: a pointer to a &struct phylink returned from phylink_create()
+ *
+ * If we have a PHY that is not part of a SFP module, then restore the
+ * PHY speeds as per phy_speed_up().
+ *
+ * Returns zero if there is no PHY, otherwise as per phy_speed_up().
+ */
+int phylink_speed_up(struct phylink *pl)
+{
+	int ret = 0;
+
+	ASSERT_RTNL();
+
+	if (!pl->sfp_bus && pl->phydev)
+		ret = phy_speed_up(pl->phydev);
+
+	return ret;
+}
+EXPORT_SYMBOL_GPL(phylink_speed_up);
+
 static void phylink_sfp_attach(void *upstream, struct sfp_bus *bus)
 {
 	struct phylink *pl = upstream;
diff --git a/include/linux/phylink.h b/include/linux/phylink.h
index cc5b452a184e..b32b8b45421b 100644
--- a/include/linux/phylink.h
+++ b/include/linux/phylink.h
@@ -392,6 +392,8 @@ int phylink_init_eee(struct phylink *, bool);
 int phylink_ethtool_get_eee(struct phylink *, struct ethtool_eee *);
 int phylink_ethtool_set_eee(struct phylink *, struct ethtool_eee *);
 int phylink_mii_ioctl(struct phylink *, struct ifreq *, int);
+int phylink_speed_down(struct phylink *pl, bool sync);
+int phylink_speed_up(struct phylink *pl);
 
 #define phylink_zero(bm) \
 	bitmap_zero(bm, __ETHTOOL_LINK_MODE_MASK_NBITS)
-- 
2.20.1


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

end of thread, other threads:[~2020-06-25 23:01 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <E1jo2GQ-0005Lr-B4@rmk-PC.armlinux.org.uk>
2020-06-25 23:01 ` [PATCH net-next] net: phylink: add phylink_speed_(up|down) interface David Miller
2020-06-24 10:06 Russell King
2020-06-24 22:20 ` Daniel González Cabanelas

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).