Message ID | 20231013122405.3745475-8-o.rempel@pengutronix.de |
---|---|
State | New |
Headers | show |
Series | net: dsa: microchip: provide Wake on LAN support | expand |
On Fri, Oct 13, 2023 at 02:24:05PM +0200, Oleksij Rempel wrote: > For Wake on Lan we should not reconfigure, reset or power down the > switch on shut down sequence. > > Signed-off-by: Oleksij Rempel <o.rempel@pengutronix.de> > --- > drivers/net/dsa/microchip/ksz9477_i2c.c | 3 +++ > drivers/net/dsa/microchip/ksz_common.c | 18 ++++++++++++++++++ > drivers/net/dsa/microchip/ksz_common.h | 2 ++ > drivers/net/dsa/microchip/ksz_spi.c | 3 +++ > 4 files changed, 26 insertions(+) > > diff --git a/drivers/net/dsa/microchip/ksz9477_i2c.c b/drivers/net/dsa/microchip/ksz9477_i2c.c > index 2710afad4f3a..fe818742051c 100644 > --- a/drivers/net/dsa/microchip/ksz9477_i2c.c > +++ b/drivers/net/dsa/microchip/ksz9477_i2c.c > @@ -66,6 +66,9 @@ static void ksz9477_i2c_shutdown(struct i2c_client *i2c) > if (!dev) > return; > > + if (ksz_wol_is_active(dev)) > + return; > + > if (dev->dev_ops->reset) > dev->dev_ops->reset(dev); The rest of the code used to read: dsa_switch_shutdown(dev->ds); i2c_set_clientdata(i2c, NULL); } and that part is non-optional. Please only skip the dev->dev_ops->reset() call if ksz_wol_is_active(). > static void ksz_set_xmii(struct ksz_device *dev, int port, > phy_interface_t interface) > { > diff --git a/drivers/net/dsa/microchip/ksz_common.h b/drivers/net/dsa/microchip/ksz_common.h > index 80679f38ee12..84b1eed8cd2a 100644 > --- a/drivers/net/dsa/microchip/ksz_common.h > +++ b/drivers/net/dsa/microchip/ksz_common.h > @@ -397,6 +397,8 @@ bool ksz_get_gbit(struct ksz_device *dev, int port); > phy_interface_t ksz_get_xmii(struct ksz_device *dev, int port, bool gbit); > extern const struct ksz_chip_data ksz_switch_chips[]; > > +bool ksz_wol_is_active(struct ksz_device *dev); > + > /* Common register access functions */ > static inline struct regmap *ksz_regmap_8(struct ksz_device *dev) > { > diff --git a/drivers/net/dsa/microchip/ksz_spi.c b/drivers/net/dsa/microchip/ksz_spi.c > index 279338451621..c5d9c3d86ddb 100644 > --- a/drivers/net/dsa/microchip/ksz_spi.c > +++ b/drivers/net/dsa/microchip/ksz_spi.c > @@ -114,6 +114,9 @@ static void ksz_spi_shutdown(struct spi_device *spi) > if (!dev) > return; > > + if (ksz_wol_is_active(dev)) > + return; > + > if (dev->dev_ops->reset) > dev->dev_ops->reset(dev); Same here. Maybe introducing a common ksz_switch_shutdown() would be appropriate.
diff --git a/drivers/net/dsa/microchip/ksz9477_i2c.c b/drivers/net/dsa/microchip/ksz9477_i2c.c index 2710afad4f3a..fe818742051c 100644 --- a/drivers/net/dsa/microchip/ksz9477_i2c.c +++ b/drivers/net/dsa/microchip/ksz9477_i2c.c @@ -66,6 +66,9 @@ static void ksz9477_i2c_shutdown(struct i2c_client *i2c) if (!dev) return; + if (ksz_wol_is_active(dev)) + return; + if (dev->dev_ops->reset) dev->dev_ops->reset(dev); diff --git a/drivers/net/dsa/microchip/ksz_common.c b/drivers/net/dsa/microchip/ksz_common.c index 820edda82cea..c3669b9cc6ce 100644 --- a/drivers/net/dsa/microchip/ksz_common.c +++ b/drivers/net/dsa/microchip/ksz_common.c @@ -2959,6 +2959,24 @@ static int ksz_set_wol(struct dsa_switch *ds, int port, return -EOPNOTSUPP; } +bool ksz_wol_is_active(struct ksz_device *dev) +{ + struct dsa_port *dp; + + if (!dev->wakeup_source) + return false; + + dsa_switch_for_each_user_port(dp, dev->ds) { + struct ethtool_wolinfo wol; + + ksz_get_wol(dev->ds, dp->index, &wol); + if (wol.wolopts) + return true; + } + + return false; +} + static void ksz_set_xmii(struct ksz_device *dev, int port, phy_interface_t interface) { diff --git a/drivers/net/dsa/microchip/ksz_common.h b/drivers/net/dsa/microchip/ksz_common.h index 80679f38ee12..84b1eed8cd2a 100644 --- a/drivers/net/dsa/microchip/ksz_common.h +++ b/drivers/net/dsa/microchip/ksz_common.h @@ -397,6 +397,8 @@ bool ksz_get_gbit(struct ksz_device *dev, int port); phy_interface_t ksz_get_xmii(struct ksz_device *dev, int port, bool gbit); extern const struct ksz_chip_data ksz_switch_chips[]; +bool ksz_wol_is_active(struct ksz_device *dev); + /* Common register access functions */ static inline struct regmap *ksz_regmap_8(struct ksz_device *dev) { diff --git a/drivers/net/dsa/microchip/ksz_spi.c b/drivers/net/dsa/microchip/ksz_spi.c index 279338451621..c5d9c3d86ddb 100644 --- a/drivers/net/dsa/microchip/ksz_spi.c +++ b/drivers/net/dsa/microchip/ksz_spi.c @@ -114,6 +114,9 @@ static void ksz_spi_shutdown(struct spi_device *spi) if (!dev) return; + if (ksz_wol_is_active(dev)) + return; + if (dev->dev_ops->reset) dev->dev_ops->reset(dev);
For Wake on Lan we should not reconfigure, reset or power down the switch on shut down sequence. Signed-off-by: Oleksij Rempel <o.rempel@pengutronix.de> --- drivers/net/dsa/microchip/ksz9477_i2c.c | 3 +++ drivers/net/dsa/microchip/ksz_common.c | 18 ++++++++++++++++++ drivers/net/dsa/microchip/ksz_common.h | 2 ++ drivers/net/dsa/microchip/ksz_spi.c | 3 +++ 4 files changed, 26 insertions(+)