netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Joakim Zhang <qiangqing.zhang@nxp.com>
To: Andrew Lunn <andrew@lunn.ch>
Cc: "peppe.cavallaro@st.com" <peppe.cavallaro@st.com>,
	"alexandre.torgue@st.com" <alexandre.torgue@st.com>,
	"joabreu@synopsys.com" <joabreu@synopsys.com>,
	"davem@davemloft.net" <davem@davemloft.net>,
	"kuba@kernel.org" <kuba@kernel.org>,
	"f.fainelli@gmail.com" <f.fainelli@gmail.com>,
	"Jisheng.Zhang@synaptics.com" <Jisheng.Zhang@synaptics.com>,
	"netdev@vger.kernel.org" <netdev@vger.kernel.org>,
	dl-linux-imx <linux-imx@nxp.com>
Subject: RE: [PATCH V3 net] net: stmmac: fix MAC WoL unwork if PHY doesn't support WoL
Date: Thu, 29 Apr 2021 07:09:47 +0000	[thread overview]
Message-ID: <DB8PR04MB6795286E3C03699616C8C5C4E65F9@DB8PR04MB6795.eurprd04.prod.outlook.com> (raw)
In-Reply-To: <YIlUdprPfqa5d2ez@lunn.ch>


> -----Original Message-----
> From: Andrew Lunn <andrew@lunn.ch>
> Sent: 2021年4月28日 20:27
> To: Joakim Zhang <qiangqing.zhang@nxp.com>
> Cc: peppe.cavallaro@st.com; alexandre.torgue@st.com;
> joabreu@synopsys.com; davem@davemloft.net; kuba@kernel.org;
> f.fainelli@gmail.com; Jisheng.Zhang@synaptics.com; netdev@vger.kernel.org;
> dl-linux-imx <linux-imx@nxp.com>
> Subject: Re: [PATCH V3 net] net: stmmac: fix MAC WoL unwork if PHY doesn't
> support WoL
> 
> >  static int stmmac_set_wol(struct net_device *dev, struct
> > ethtool_wolinfo *wol)  {
> >  	struct stmmac_priv *priv = netdev_priv(dev);
> > -	u32 support = WAKE_MAGIC | WAKE_UCAST;
> > +	struct ethtool_wolinfo wol_phy = { .cmd = ETHTOOL_GWOL };
> > +	u32 support = WAKE_MAGIC | WAKE_UCAST | WAKE_MAGICSECURE |
> > +WAKE_BCAST;
> 
> Reverse christmass tree please.
Ok

> >
> > -	if (!device_can_wakeup(priv->device))
> > -		return -EOPNOTSUPP;
> > +	if (wol->wolopts & ~support)
> > +		return -EINVAL;
> 
> Maybe -EOPNOTSUPP would be better.
Ok

> >
> > -	if (!priv->plat->pmt) {
> > +	/* First check if can WoL from PHY */
> > +	phylink_ethtool_get_wol(priv->phylink, &wol_phy);
> 
> This could return an error. In which case, you probably should not trust
> wol_phy.
phylink_ethtool_get_wol() is a void function, there is no return value. I think we can trust wol_phy, if PHY driver does not implement
get_wol(), wol_phy.supported is 0; if PHY driver implement it, then it will fill the wol_phy.supported field. Please point me if I am misunderstanding.

> > +	if (wol->wolopts & wol_phy.supported) {
> 
> This returns true if the PHY supports one or more of the requested WoL
> sources.
>
> >  		int ret = phylink_ethtool_set_wol(priv->phylink, wol);
> 
> and here you request the PHY to enable all the requested WoL sources. If it
> only supports a subset, it is likely to return -EOPNOTSUPP, or -EINVAL, and do
> nothing. So here you only want to enable those sources the PHY actually
> supports. And let the MAC implement the rest.
Yes, you are right! It should be:
	wol->wolopts &= wol_phy.supported;
	ret = phylink_ethtool_set_wol(priv->phylink, wol);

Best Regards,
Joakim Zhang
> 	  Andrew

  parent reply	other threads:[~2021-04-29  7:09 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-04-28  7:41 [PATCH V3 net] net: stmmac: fix MAC WoL unwork if PHY doesn't support WoL Joakim Zhang
2021-04-28 12:26 ` Andrew Lunn
2021-04-28 16:22   ` Florian Fainelli
2021-04-29  7:11     ` Joakim Zhang
2021-04-29  7:09   ` Joakim Zhang [this message]
2021-04-29 21:32     ` Andrew Lunn

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=DB8PR04MB6795286E3C03699616C8C5C4E65F9@DB8PR04MB6795.eurprd04.prod.outlook.com \
    --to=qiangqing.zhang@nxp.com \
    --cc=Jisheng.Zhang@synaptics.com \
    --cc=alexandre.torgue@st.com \
    --cc=andrew@lunn.ch \
    --cc=davem@davemloft.net \
    --cc=f.fainelli@gmail.com \
    --cc=joabreu@synopsys.com \
    --cc=kuba@kernel.org \
    --cc=linux-imx@nxp.com \
    --cc=netdev@vger.kernel.org \
    --cc=peppe.cavallaro@st.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).