From: <nicolas.ferre@microchip.com> To: <linux-arm-kernel@lists.infradead.org>, <netdev@vger.kernel.org>, "Claudiu Beznea" <claudiu.beznea@microchip.com>, <harini.katakam@xilinx.com> Cc: <linux-kernel@vger.kernel.org>, "David S. Miller" <davem@davemloft.net>, Alexandre Belloni <alexandre.belloni@bootlin.com>, <pthombar@cadence.com>, <sergio.prado@e-labworks.com>, <antoine.tenart@bootlin.com>, <f.fainelli@gmail.com>, <linux@armlinux.org.uk>, <andrew@lunn.ch>, <michal.simek@xilinx.com>, Nicolas Ferre <nicolas.ferre@microchip.com>, "Rafal Ozieblo" <rafalo@cadence.com> Subject: [PATCH 3/5] net: macb: fix macb_get/set_wol() when moving to phylink Date: Thu, 16 Apr 2020 19:44:30 +0200 [thread overview] Message-ID: <897ab8f112d0b82f807e83c6f9e7425d1321fa09.1587058078.git.nicolas.ferre@microchip.com> (raw) In-Reply-To: <cover.1587058078.git.nicolas.ferre@microchip.com> From: Nicolas Ferre <nicolas.ferre@microchip.com> Keep previous function goals and integrate phylink actions to them. phylink_ethtool_get_wol() is not enough to figure out if Ethernet driver supports Wake-on-Lan. Initialization of "supported" and "wolopts" members is done in phylink function, no need to keep them in calling function. phylink_ethtool_set_wol() return value is not enough to determine if WoL is enabled for the calling Ethernet driver. Call if first but don't rely on its return value as most of simple PHY drivers don't implement a set_wol() function. Fixes: 7897b071ac3b ("net: macb: convert to phylink") Cc: Claudiu Beznea <claudiu.beznea@microchip.com> Cc: Harini Katakam <harini.katakam@xilinx.com> Cc: Rafal Ozieblo <rafalo@cadence.com> Cc: Antoine Tenart <antoine.tenart@bootlin.com> Signed-off-by: Nicolas Ferre <nicolas.ferre@microchip.com> --- drivers/net/ethernet/cadence/macb_main.c | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/drivers/net/ethernet/cadence/macb_main.c b/drivers/net/ethernet/cadence/macb_main.c index 629660d9f17e..b17a33c60cd4 100644 --- a/drivers/net/ethernet/cadence/macb_main.c +++ b/drivers/net/ethernet/cadence/macb_main.c @@ -2813,21 +2813,23 @@ static void macb_get_wol(struct net_device *netdev, struct ethtool_wolinfo *wol) { struct macb *bp = netdev_priv(netdev); - wol->supported = 0; - wol->wolopts = 0; - - if (bp->wol & MACB_WOL_HAS_MAGIC_PACKET) + if (bp->wol & MACB_WOL_HAS_MAGIC_PACKET) { phylink_ethtool_get_wol(bp->phylink, wol); + wol->supported |= WAKE_MAGIC; + + if (bp->wol & MACB_WOL_ENABLED) + wol->wolopts |= WAKE_MAGIC; + } } static int macb_set_wol(struct net_device *netdev, struct ethtool_wolinfo *wol) { struct macb *bp = netdev_priv(netdev); - int ret; - ret = phylink_ethtool_set_wol(bp->phylink, wol); - if (!ret) - return 0; + /* Pass the order to phylink layer. + * Don't test return value as set_wol() is often not supported. + */ + phylink_ethtool_set_wol(bp->phylink, wol); if (!(bp->wol & MACB_WOL_HAS_MAGIC_PACKET) || (wol->wolopts & ~WAKE_MAGIC)) -- 2.20.1
WARNING: multiple messages have this Message-ID (diff)
From: <nicolas.ferre@microchip.com> To: <linux-arm-kernel@lists.infradead.org>, <netdev@vger.kernel.org>, "Claudiu Beznea" <claudiu.beznea@microchip.com>, <harini.katakam@xilinx.com> Cc: andrew@lunn.ch, Alexandre Belloni <alexandre.belloni@bootlin.com>, f.fainelli@gmail.com, sergio.prado@e-labworks.com, pthombar@cadence.com, antoine.tenart@bootlin.com, michal.simek@xilinx.com, linux-kernel@vger.kernel.org, linux@armlinux.org.uk, Rafal Ozieblo <rafalo@cadence.com>, "David S. Miller" <davem@davemloft.net> Subject: [PATCH 3/5] net: macb: fix macb_get/set_wol() when moving to phylink Date: Thu, 16 Apr 2020 19:44:30 +0200 [thread overview] Message-ID: <897ab8f112d0b82f807e83c6f9e7425d1321fa09.1587058078.git.nicolas.ferre@microchip.com> (raw) In-Reply-To: <cover.1587058078.git.nicolas.ferre@microchip.com> From: Nicolas Ferre <nicolas.ferre@microchip.com> Keep previous function goals and integrate phylink actions to them. phylink_ethtool_get_wol() is not enough to figure out if Ethernet driver supports Wake-on-Lan. Initialization of "supported" and "wolopts" members is done in phylink function, no need to keep them in calling function. phylink_ethtool_set_wol() return value is not enough to determine if WoL is enabled for the calling Ethernet driver. Call if first but don't rely on its return value as most of simple PHY drivers don't implement a set_wol() function. Fixes: 7897b071ac3b ("net: macb: convert to phylink") Cc: Claudiu Beznea <claudiu.beznea@microchip.com> Cc: Harini Katakam <harini.katakam@xilinx.com> Cc: Rafal Ozieblo <rafalo@cadence.com> Cc: Antoine Tenart <antoine.tenart@bootlin.com> Signed-off-by: Nicolas Ferre <nicolas.ferre@microchip.com> --- drivers/net/ethernet/cadence/macb_main.c | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/drivers/net/ethernet/cadence/macb_main.c b/drivers/net/ethernet/cadence/macb_main.c index 629660d9f17e..b17a33c60cd4 100644 --- a/drivers/net/ethernet/cadence/macb_main.c +++ b/drivers/net/ethernet/cadence/macb_main.c @@ -2813,21 +2813,23 @@ static void macb_get_wol(struct net_device *netdev, struct ethtool_wolinfo *wol) { struct macb *bp = netdev_priv(netdev); - wol->supported = 0; - wol->wolopts = 0; - - if (bp->wol & MACB_WOL_HAS_MAGIC_PACKET) + if (bp->wol & MACB_WOL_HAS_MAGIC_PACKET) { phylink_ethtool_get_wol(bp->phylink, wol); + wol->supported |= WAKE_MAGIC; + + if (bp->wol & MACB_WOL_ENABLED) + wol->wolopts |= WAKE_MAGIC; + } } static int macb_set_wol(struct net_device *netdev, struct ethtool_wolinfo *wol) { struct macb *bp = netdev_priv(netdev); - int ret; - ret = phylink_ethtool_set_wol(bp->phylink, wol); - if (!ret) - return 0; + /* Pass the order to phylink layer. + * Don't test return value as set_wol() is often not supported. + */ + phylink_ethtool_set_wol(bp->phylink, wol); if (!(bp->wol & MACB_WOL_HAS_MAGIC_PACKET) || (wol->wolopts & ~WAKE_MAGIC)) -- 2.20.1 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
next prev parent reply other threads:[~2020-04-16 17:45 UTC|newest] Thread overview: 34+ messages / expand[flat|nested] mbox.gz Atom feed top 2020-04-16 17:44 [PATCH 0/5] net: macb: Wake-on-Lan magic packet fixes and GEM handling nicolas.ferre 2020-04-16 17:44 ` nicolas.ferre 2020-04-16 17:44 ` [PATCH 1/5] net: macb: fix wakeup test in runtime suspend/resume routines nicolas.ferre 2020-04-16 17:44 ` nicolas.ferre 2020-04-16 18:26 ` Harini Katakam 2020-04-16 18:26 ` Harini Katakam 2020-04-17 12:33 ` Nicolas Ferre 2020-04-17 12:33 ` Nicolas Ferre 2020-04-16 19:21 ` Florian Fainelli 2020-04-16 19:21 ` Florian Fainelli 2020-04-16 17:44 ` [PATCH 2/5] net: macb: mark device wake capable when "magic-packet" property present nicolas.ferre 2020-04-16 17:44 ` nicolas.ferre 2020-04-16 19:21 ` Florian Fainelli 2020-04-16 19:21 ` Florian Fainelli 2020-04-16 17:44 ` nicolas.ferre [this message] 2020-04-16 17:44 ` [PATCH 3/5] net: macb: fix macb_get/set_wol() when moving to phylink nicolas.ferre 2020-04-16 19:22 ` Florian Fainelli 2020-04-16 19:22 ` Florian Fainelli 2020-04-16 17:44 ` [PATCH 4/5] net: macb: WoL support for GEM type of Ethernet controller nicolas.ferre 2020-04-16 17:44 ` nicolas.ferre 2020-04-16 19:25 ` Florian Fainelli 2020-04-16 19:25 ` Florian Fainelli 2020-04-17 12:57 ` Nicolas Ferre 2020-04-17 12:57 ` Nicolas Ferre 2020-04-17 17:14 ` Nicolas Ferre 2020-04-17 17:14 ` Nicolas Ferre 2020-04-21 8:21 ` Nicolas.Ferre 2020-04-21 8:21 ` Nicolas.Ferre 2020-04-21 8:37 ` Harini Katakam 2020-04-21 8:37 ` Harini Katakam 2020-04-16 17:44 ` [PATCH 5/5] net: macb: Add WoL interrupt support for MACB " nicolas.ferre 2020-04-16 17:44 ` nicolas.ferre 2020-04-16 19:26 ` Florian Fainelli 2020-04-16 19:26 ` Florian Fainelli
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=897ab8f112d0b82f807e83c6f9e7425d1321fa09.1587058078.git.nicolas.ferre@microchip.com \ --to=nicolas.ferre@microchip.com \ --cc=alexandre.belloni@bootlin.com \ --cc=andrew@lunn.ch \ --cc=antoine.tenart@bootlin.com \ --cc=claudiu.beznea@microchip.com \ --cc=davem@davemloft.net \ --cc=f.fainelli@gmail.com \ --cc=harini.katakam@xilinx.com \ --cc=linux-arm-kernel@lists.infradead.org \ --cc=linux-kernel@vger.kernel.org \ --cc=linux@armlinux.org.uk \ --cc=michal.simek@xilinx.com \ --cc=netdev@vger.kernel.org \ --cc=pthombar@cadence.com \ --cc=rafalo@cadence.com \ --cc=sergio.prado@e-labworks.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: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.