[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <ZwOiNQSNJ7CzqbO1@shell.armlinux.org.uk>
Date: Mon, 7 Oct 2024 09:56:21 +0100
From: "Russell King (Oracle)" <linux@...linux.org.uk>
To: Andrew Lunn <andrew@...n.ch>
Cc: Mohammed Anees <pvmohammedanees2003@...il.com>, davem@...emloft.net,
edumazet@...gle.com, f.fainelli@...il.com, kuba@...nel.org,
linux-kernel@...r.kernel.org, netdev@...r.kernel.org,
olteanv@...il.com, pabeni@...hat.com
Subject: Re: [PATCH] net: dsa: Fix conditional handling of Wake-on-Lan
configuration in dsa_user_set_wol
On Sun, Oct 06, 2024 at 09:57:26PM +0200, Andrew Lunn wrote:
> On Sun, Oct 06, 2024 at 09:40:32PM +0530, Mohammed Anees wrote:
> > Considering the insight you've provided, I've written the code below
> >
> > static int dsa_user_set_wol(struct net_device *dev, struct ethtool_wolinfo *w)
> > {
> > struct dsa_port *dp = dsa_user_to_port(dev);
> > struct dsa_switch *ds = dp->ds;
> > int ret;
> >
> > ret = phylink_ethtool_set_wol(dp->pl, w);
> >
> > if (ret != -EOPNOTSUPP)
> > return ret;
> >
> > if (ds->ops->set_wol)
> > ret = ds->ops->set_wol(ds, dp->index, w);
> > if (ret != -EOPNOTSUPP)
> > return ret;
>
> This can be simplified to just:
>
> > if (ds->ops->set_wol)
> > return ds->ops->set_wol(ds, dp->index, w);
> >
> > return -EOPNOTSUPP;
> > }
I don't think the above is correct. While the simplification is, the
overall logic is not.
Let's go back to what Andrew said in his previous reply:
"So userspace could say pumbagsf, with the PHY supporting pmub and the
MAC supporting agsf, and the two need to cooperate."
The above does not do this. Let's go back further:
phylink_ethtool_set_wol(dp->pl, w);
if (ds->ops->set_wol)
ret = ds->ops->set_wol(ds, dp->index, w);
The original code _does_ do this, allowing the PHY and MAC to set
their modes, although the return code is not correct.
I notice V2 of the patch has been posted - in my opinion prematurely
because there's clearly the discussion on the first version has not
reached a conclusion yet.
What I would propose is the following:
int phy_ret, mac_ret;
phy_ret = phylink_ethtool_set_wol(dp->pl, w);
if (phy_ret != 0 && phy_ret != -EOPNOTSUPP)
return phy_ret;
if (ds->ops->set_wol)
mac_ret = ds->ops->set_wol(ds, dp->index, w);
else
mac_ret = -EOPNOTSUPP;
if (mac_ret != 0 && mac_ret != -EOPNOTSUPP)
return mac_ret;
/* Combine the two return codes. If either returned zero,
* then we have been successful.
*/
if (phy_ret == 0 || mac_ret == 0)
return 0;
return -EOPNOTSUPP;
Which I think is the closest one can get to - there is the possibility
for phylink_ethtool_set_wol() to have modified the WoL state, but
ds->ops->set_wol() to fail with an error code, causing this to return
failure, but I don't see that as being avoidable without yet more
complexity.
--
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/
FTTP is here! 80Mbps down 10Mbps up. Decent connectivity at last!
Powered by blists - more mailing lists