* [PATCH net v2 0/2] net: phy: fix WoL handling when suspending the PHY @ 2018-09-24 19:58 Heiner Kallweit 2018-09-24 19:58 ` [PATCH net v2 1/2] net: core: add member wol_enabled to struct net_device Heiner Kallweit 2018-09-27 3:04 ` [PATCH net v2 0/2] net: phy: fix WoL handling when suspending the PHY David Miller 0 siblings, 2 replies; 7+ messages in thread From: Heiner Kallweit @ 2018-09-24 19:58 UTC (permalink / raw) To: Andrew Lunn, Florian Fainelli, David Miller, Realtek linux nic maintainers Cc: netdev@vger.kernel.org phy_suspend doesn't always recognize that WoL is enabled and therefore suspends the PHY when it should not. First idea to address the issue was to reuse checks used in mdio_bus_phy_may_suspend which check whether relevant devices are wakeup-enabled. Florian raised some concerns because drivers may enable wakeup even if WoL isn't enabled (e.g. certain USB network drivers). The new approach focuses on reducing the risk to break existing stuff. We add a flag wol_enabled to struct net_device which is set in ethtool_set_wol(). Then this flag is checked in phy_suspend(). This doesn't cover 100% of the cases yet (e.g. if WoL is enabled w/o explicit configuration), but it covers the most relevant cases with very little risk of regressions. v2: - Fix a typo Heiner Kallweit (2): net: core: add member wol_enabled to struct net_device net: phy: fix WoL handling when suspending the PHY drivers/net/phy/phy_device.c | 12 +++++++++--- include/linux/netdevice.h | 3 +++ net/core/ethtool.c | 9 ++++++++- 3 files changed, 20 insertions(+), 4 deletions(-) -- 2.19.0 ^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH net v2 1/2] net: core: add member wol_enabled to struct net_device 2018-09-24 19:58 [PATCH net v2 0/2] net: phy: fix WoL handling when suspending the PHY Heiner Kallweit @ 2018-09-24 19:58 ` Heiner Kallweit 2018-09-24 21:39 ` Florian Fainelli 2018-09-25 8:28 ` Michal Kubecek 2018-09-27 3:04 ` [PATCH net v2 0/2] net: phy: fix WoL handling when suspending the PHY David Miller 1 sibling, 2 replies; 7+ messages in thread From: Heiner Kallweit @ 2018-09-24 19:58 UTC (permalink / raw) To: Andrew Lunn, Florian Fainelli, David Miller, Realtek linux nic maintainers Cc: netdev@vger.kernel.org Add flag wol_enabled to struct net_device indicating whether Wake-on-LAN is enabled. As first user phy_suspend() will use it to decide whether PHY can be suspended or not. Fixes: f1e911d5d0df ("r8169: add basic phylib support") Fixes: e8cfd9d6c772 ("net: phy: call state machine synchronously in phy_stop") Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com> --- include/linux/netdevice.h | 3 +++ net/core/ethtool.c | 9 ++++++++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h index 1cbbf77a6..f5f1f1450 100644 --- a/include/linux/netdevice.h +++ b/include/linux/netdevice.h @@ -1756,6 +1756,8 @@ enum netdev_priv_flags { * switch driver and used to set the phys state of the * switch port. * + * @wol_enabled: Wake-on-LAN is enabled + * * FIXME: cleanup struct net_device such that network protocol info * moves out. */ @@ -2039,6 +2041,7 @@ struct net_device { struct lock_class_key *qdisc_tx_busylock; struct lock_class_key *qdisc_running_key; bool proto_down; + unsigned wol_enabled:1; }; #define to_net_dev(d) container_of(d, struct net_device, dev) diff --git a/net/core/ethtool.c b/net/core/ethtool.c index 9d4e56d97..86f765d42 100644 --- a/net/core/ethtool.c +++ b/net/core/ethtool.c @@ -1395,6 +1395,7 @@ static int ethtool_get_wol(struct net_device *dev, char __user *useraddr) static int ethtool_set_wol(struct net_device *dev, char __user *useraddr) { struct ethtool_wolinfo wol; + int ret; if (!dev->ethtool_ops->set_wol) return -EOPNOTSUPP; @@ -1402,7 +1403,13 @@ static int ethtool_set_wol(struct net_device *dev, char __user *useraddr) if (copy_from_user(&wol, useraddr, sizeof(wol))) return -EFAULT; - return dev->ethtool_ops->set_wol(dev, &wol); + ret = dev->ethtool_ops->set_wol(dev, &wol); + if (ret) + return ret; + + dev->wol_enabled = !!wol.wolopts; + + return 0; } static int ethtool_get_eee(struct net_device *dev, char __user *useraddr) -- 2.19.0 ^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH net v2 1/2] net: core: add member wol_enabled to struct net_device 2018-09-24 19:58 ` [PATCH net v2 1/2] net: core: add member wol_enabled to struct net_device Heiner Kallweit @ 2018-09-24 21:39 ` Florian Fainelli 2018-09-25 8:28 ` Michal Kubecek 1 sibling, 0 replies; 7+ messages in thread From: Florian Fainelli @ 2018-09-24 21:39 UTC (permalink / raw) To: Heiner Kallweit, Andrew Lunn, David Miller, Realtek linux nic maintainers Cc: netdev@vger.kernel.org On 09/24/2018 12:58 PM, Heiner Kallweit wrote: > Add flag wol_enabled to struct net_device indicating whether > Wake-on-LAN is enabled. As first user phy_suspend() will use it to > decide whether PHY can be suspended or not. > > Fixes: f1e911d5d0df ("r8169: add basic phylib support") > Fixes: e8cfd9d6c772 ("net: phy: call state machine synchronously in phy_stop") > Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com> Reviewed-by: Florian Fainelli <f.fainelli@gmail.com> Thanks Heiner! -- Florian ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH net v2 1/2] net: core: add member wol_enabled to struct net_device 2018-09-24 19:58 ` [PATCH net v2 1/2] net: core: add member wol_enabled to struct net_device Heiner Kallweit 2018-09-24 21:39 ` Florian Fainelli @ 2018-09-25 8:28 ` Michal Kubecek 2018-09-25 17:30 ` Heiner Kallweit 1 sibling, 1 reply; 7+ messages in thread From: Michal Kubecek @ 2018-09-25 8:28 UTC (permalink / raw) To: Heiner Kallweit Cc: Andrew Lunn, Florian Fainelli, David Miller, Realtek linux nic maintainers, netdev@vger.kernel.org (I wrote my comment to v1 because I overlooked there is a v2 already; duplicating it here.) On Mon, Sep 24, 2018 at 09:58:59PM +0200, Heiner Kallweit wrote: > Add flag wol_enabled to struct net_device indicating whether > Wake-on-LAN is enabled. As first user phy_suspend() will use it to > decide whether PHY can be suspended or not. > > Fixes: f1e911d5d0df ("r8169: add basic phylib support") > Fixes: e8cfd9d6c772 ("net: phy: call state machine synchronously in phy_stop") > Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com> > --- > include/linux/netdevice.h | 3 +++ > net/core/ethtool.c | 9 ++++++++- > 2 files changed, 11 insertions(+), 1 deletion(-) > > diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h > index 1cbbf77a6..f5f1f1450 100644 > --- a/include/linux/netdevice.h > +++ b/include/linux/netdevice.h > @@ -1756,6 +1756,8 @@ enum netdev_priv_flags { > * switch driver and used to set the phys state of the > * switch port. > * > + * @wol_enabled: Wake-on-LAN is enabled > + * > * FIXME: cleanup struct net_device such that network protocol info > * moves out. > */ > @@ -2039,6 +2041,7 @@ struct net_device { > struct lock_class_key *qdisc_tx_busylock; > struct lock_class_key *qdisc_running_key; > bool proto_down; > + unsigned wol_enabled:1; > }; > #define to_net_dev(d) container_of(d, struct net_device, dev) > As there is no bitfield yet, this would add 4 bytes to struct net_device. How about using a bit in net_device::priv_flags like IFF_RXFH_CONFIGURED in ethtool_set_rxfh_indir() and ethtool_set_rxfh()? Michal Kubecek ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH net v2 1/2] net: core: add member wol_enabled to struct net_device 2018-09-25 8:28 ` Michal Kubecek @ 2018-09-25 17:30 ` Heiner Kallweit 0 siblings, 0 replies; 7+ messages in thread From: Heiner Kallweit @ 2018-09-25 17:30 UTC (permalink / raw) To: Michal Kubecek Cc: Andrew Lunn, Florian Fainelli, David Miller, Realtek linux nic maintainers, netdev@vger.kernel.org On 25.09.2018 10:28, Michal Kubecek wrote: > (I wrote my comment to v1 because I overlooked there is a v2 already; > duplicating it here.) > > On Mon, Sep 24, 2018 at 09:58:59PM +0200, Heiner Kallweit wrote: >> Add flag wol_enabled to struct net_device indicating whether >> Wake-on-LAN is enabled. As first user phy_suspend() will use it to >> decide whether PHY can be suspended or not. >> >> Fixes: f1e911d5d0df ("r8169: add basic phylib support") >> Fixes: e8cfd9d6c772 ("net: phy: call state machine synchronously in phy_stop") >> Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com> >> --- >> include/linux/netdevice.h | 3 +++ >> net/core/ethtool.c | 9 ++++++++- >> 2 files changed, 11 insertions(+), 1 deletion(-) >> >> diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h >> index 1cbbf77a6..f5f1f1450 100644 >> --- a/include/linux/netdevice.h >> +++ b/include/linux/netdevice.h >> @@ -1756,6 +1756,8 @@ enum netdev_priv_flags { >> * switch driver and used to set the phys state of the >> * switch port. >> * >> + * @wol_enabled: Wake-on-LAN is enabled >> + * >> * FIXME: cleanup struct net_device such that network protocol info >> * moves out. >> */ >> @@ -2039,6 +2041,7 @@ struct net_device { >> struct lock_class_key *qdisc_tx_busylock; >> struct lock_class_key *qdisc_running_key; >> bool proto_down; >> + unsigned wol_enabled:1; >> }; >> #define to_net_dev(d) container_of(d, struct net_device, dev) >> > > As there is no bitfield yet, this would add 4 bytes to struct net_device. > How about using a bit in net_device::priv_flags like IFF_RXFH_CONFIGURED > in ethtool_set_rxfh_indir() and ethtool_set_rxfh()? > Indeed alternatively we could add a private flag and the related getter/setter. Regarding the size argument: We have few bool members in struct net_device (uc_promisc, dismantle, needs_free_netdev, proto_down) which most likely can be transparently converted to bitfield members. Then a wol_enabled bitfield member would be no overhead. I don't have a strong preference and would leave it up to David. > Michal Kubecek > Heiner ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH net v2 0/2] net: phy: fix WoL handling when suspending the PHY 2018-09-24 19:58 [PATCH net v2 0/2] net: phy: fix WoL handling when suspending the PHY Heiner Kallweit 2018-09-24 19:58 ` [PATCH net v2 1/2] net: core: add member wol_enabled to struct net_device Heiner Kallweit @ 2018-09-27 3:04 ` David Miller 2018-09-28 19:41 ` Heiner Kallweit 1 sibling, 1 reply; 7+ messages in thread From: David Miller @ 2018-09-27 3:04 UTC (permalink / raw) To: hkallweit1; +Cc: andrew, f.fainelli, nic_swsd, netdev From: Heiner Kallweit <hkallweit1@gmail.com> Date: Mon, 24 Sep 2018 21:58:04 +0200 > phy_suspend doesn't always recognize that WoL is enabled and therefore > suspends the PHY when it should not. First idea to address the issue > was to reuse checks used in mdio_bus_phy_may_suspend which check > whether relevant devices are wakeup-enabled. > Florian raised some concerns because drivers may enable wakeup even if > WoL isn't enabled (e.g. certain USB network drivers). > > The new approach focuses on reducing the risk to break existing stuff. > We add a flag wol_enabled to struct net_device which is set in > ethtool_set_wol(). Then this flag is checked in phy_suspend(). > This doesn't cover 100% of the cases yet (e.g. if WoL is enabled w/o > explicit configuration), but it covers the most relevant cases with > very little risk of regressions. > > v2: > - Fix a typo Series applied, thanks. Please deal with the extra 4 byte size of net_device in net-next. Thanks. ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH net v2 0/2] net: phy: fix WoL handling when suspending the PHY 2018-09-27 3:04 ` [PATCH net v2 0/2] net: phy: fix WoL handling when suspending the PHY David Miller @ 2018-09-28 19:41 ` Heiner Kallweit 0 siblings, 0 replies; 7+ messages in thread From: Heiner Kallweit @ 2018-09-28 19:41 UTC (permalink / raw) To: David Miller; +Cc: andrew, f.fainelli, nic_swsd, netdev On 27.09.2018 05:04, David Miller wrote: > From: Heiner Kallweit <hkallweit1@gmail.com> > Date: Mon, 24 Sep 2018 21:58:04 +0200 > >> phy_suspend doesn't always recognize that WoL is enabled and therefore >> suspends the PHY when it should not. First idea to address the issue >> was to reuse checks used in mdio_bus_phy_may_suspend which check >> whether relevant devices are wakeup-enabled. >> Florian raised some concerns because drivers may enable wakeup even if >> WoL isn't enabled (e.g. certain USB network drivers). >> >> The new approach focuses on reducing the risk to break existing stuff. >> We add a flag wol_enabled to struct net_device which is set in >> ethtool_set_wol(). Then this flag is checked in phy_suspend(). >> This doesn't cover 100% of the cases yet (e.g. if WoL is enabled w/o >> explicit configuration), but it covers the most relevant cases with >> very little risk of regressions. >> >> v2: >> - Fix a typo > > Series applied, thanks. > > Please deal with the extra 4 byte size of net_device in net-next. > Sure. Next week I'm on travel, will do it the week after. > Thanks. > ^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2018-09-29 2:06 UTC | newest] Thread overview: 7+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2018-09-24 19:58 [PATCH net v2 0/2] net: phy: fix WoL handling when suspending the PHY Heiner Kallweit 2018-09-24 19:58 ` [PATCH net v2 1/2] net: core: add member wol_enabled to struct net_device Heiner Kallweit 2018-09-24 21:39 ` Florian Fainelli 2018-09-25 8:28 ` Michal Kubecek 2018-09-25 17:30 ` Heiner Kallweit 2018-09-27 3:04 ` [PATCH net v2 0/2] net: phy: fix WoL handling when suspending the PHY David Miller 2018-09-28 19:41 ` Heiner Kallweit
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).