Thread (6 messages) 6 messages, 3 authors, 2021-04-29

Re: [PATCH V3 net] net: stmmac: fix MAC WoL unwork if PHY doesn't support WoL

From: Andrew Lunn <andrew@lunn.ch>
Date: 2021-04-28 12:26:53

 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.
 
-	if (!device_can_wakeup(priv->device))
-		return -EOPNOTSUPP;
+	if (wol->wolopts & ~support)
+		return -EINVAL;
Maybe -EOPNOTSUPP would be better.
 
-	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.
+	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.

	  Andrew
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help