linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/2] drivers/net/forcedeth: add support for WAKE_PHY
@ 2016-03-10 14:58 Karol Herbst
  2016-03-10 14:58 ` [PATCH 1/2] net/forcedeth: refactor wol support to make it easier to add more wol modes Karol Herbst
  2016-03-10 14:58 ` [PATCH 2/2] net/forcedeth: add wol p support Karol Herbst
  0 siblings, 2 replies; 5+ messages in thread
From: Karol Herbst @ 2016-03-10 14:58 UTC (permalink / raw)
  To: linux-kernel; +Cc: David S . Miller, netdev, Karol Herbst

From: Karol Herbst <nouveau@karolherbst.de>

I want to use my mac mini as a local server, but put it to sleep automatically
therefore wol p, and because wol g is a mess if you want to wakeup the target
machine automagically :)

Karol Herbst (2):
  net/forcedeth: refactor wol support to make it easier adding more
    modes
  net/forcedeth: add wol p support

 drivers/net/ethernet/nvidia/forcedeth.c | 37 ++++++++++++++++++++-------------
 1 file changed, 23 insertions(+), 14 deletions(-)

-- 
2.7.2

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH 1/2] net/forcedeth: refactor wol support to make it easier to add more wol modes
  2016-03-10 14:58 [PATCH 0/2] drivers/net/forcedeth: add support for WAKE_PHY Karol Herbst
@ 2016-03-10 14:58 ` Karol Herbst
  2016-03-14  2:14   ` David Miller
  2016-03-10 14:58 ` [PATCH 2/2] net/forcedeth: add wol p support Karol Herbst
  1 sibling, 1 reply; 5+ messages in thread
From: Karol Herbst @ 2016-03-10 14:58 UTC (permalink / raw)
  To: linux-kernel; +Cc: David S . Miller, netdev

Signed-off-by: Karol Herbst <git@karolherbst.de>
---
 drivers/net/ethernet/nvidia/forcedeth.c | 28 +++++++++++++++-------------
 1 file changed, 15 insertions(+), 13 deletions(-)

diff --git a/drivers/net/ethernet/nvidia/forcedeth.c b/drivers/net/ethernet/nvidia/forcedeth.c
index 75e88f4..bdce33b 100644
--- a/drivers/net/ethernet/nvidia/forcedeth.c
+++ b/drivers/net/ethernet/nvidia/forcedeth.c
@@ -290,7 +290,7 @@ enum {
 #define NVREG_WAKEUPFLAGS_ACCEPT_MAGPAT		0x01
 #define NVREG_WAKEUPFLAGS_ACCEPT_WAKEUPPAT	0x02
 #define NVREG_WAKEUPFLAGS_ACCEPT_LINKCHANGE	0x04
-#define NVREG_WAKEUPFLAGS_ENABLE	0x1111
+#define NVREG_WAKEUPFLAGS_ENABLE_G	0x01111
 
 	NvRegMgmtUnitGetVersion = 0x204,
 #define NVREG_MGMTUNITGETVERSION	0x01
@@ -764,6 +764,7 @@ struct fe_priv {
 	int fixed_mode;
 	int phyaddr;
 	int wolenabled;
+	u32 wol_flags;
 	unsigned int phy_oui;
 	unsigned int phy_model;
 	unsigned int phy_rev;
@@ -4218,8 +4219,9 @@ static void nv_get_wol(struct net_device *dev, struct ethtool_wolinfo *wolinfo)
 	wolinfo->supported = WAKE_MAGIC;
 
 	spin_lock_irq(&np->lock);
-	if (np->wolenabled)
-		wolinfo->wolopts = WAKE_MAGIC;
+	wolinfo->wolopts = 0;
+	if (np->wolenabled & WAKE_MAGIC)
+		wolinfo->wolopts |= WAKE_MAGIC;
 	spin_unlock_irq(&np->lock);
 }
 
@@ -4227,20 +4229,19 @@ static int nv_set_wol(struct net_device *dev, struct ethtool_wolinfo *wolinfo)
 {
 	struct fe_priv *np = netdev_priv(dev);
 	u8 __iomem *base = get_hwbase(dev);
-	u32 flags = 0;
 
-	if (wolinfo->wolopts == 0) {
-		np->wolenabled = 0;
-	} else if (wolinfo->wolopts & WAKE_MAGIC) {
-		np->wolenabled = 1;
-		flags = NVREG_WAKEUPFLAGS_ENABLE;
+	np->wolenabled = 0;
+	np->wol_flags = 0;
+	if (wolinfo->wolopts & WAKE_MAGIC) {
+		np->wolenabled |= WAKE_MAGIC;
+		np->wol_flags |= NVREG_WAKEUPFLAGS_ENABLE_G;
 	}
 	if (netif_running(dev)) {
 		spin_lock_irq(&np->lock);
-		writel(flags, base + NvRegWakeUpFlags);
+		writel(np->wol_flags, base + NvRegWakeUpFlags);
 		spin_unlock_irq(&np->lock);
 	}
-	device_set_wakeup_enable(&np->pci_dev->dev, np->wolenabled);
+	device_set_wakeup_enable(&np->pci_dev->dev, np->wolenabled != 0);
 	return 0;
 }
 
@@ -5445,7 +5446,7 @@ static int nv_open(struct net_device *dev)
 	writel(NVREG_MIISPEED_BIT8|NVREG_MIIDELAY, base + NvRegMIISpeed);
 	writel(NVREG_MII_LINKCHANGE, base + NvRegMIIMask);
 	if (np->wolenabled)
-		writel(NVREG_WAKEUPFLAGS_ENABLE , base + NvRegWakeUpFlags);
+		writel(np->wol_flags, base + NvRegWakeUpFlags);
 
 	i = readl(base + NvRegPowerState);
 	if ((i & NVREG_POWERSTATE_POWEREDUP) == 0)
@@ -5833,6 +5834,7 @@ static int nv_probe(struct pci_dev *pci_dev, const struct pci_device_id *id)
 	/* disable WOL */
 	writel(0, base + NvRegWakeUpFlags);
 	np->wolenabled = 0;
+	np->wol_flags = 0;
 	device_set_wakeup_enable(&pci_dev->dev, false);
 
 	if (id->driver_data & DEV_HAS_POWER_CNTRL) {
@@ -6175,7 +6177,7 @@ static void nv_shutdown(struct pci_dev *pdev)
 	 * only put the device into D3 if we really go for poweroff.
 	 */
 	if (system_state == SYSTEM_POWER_OFF) {
-		pci_wake_from_d3(pdev, np->wolenabled);
+		pci_wake_from_d3(pdev, np->wolenabled != 0);
 		pci_set_power_state(pdev, PCI_D3hot);
 	}
 }
-- 
2.7.2

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH 2/2] net/forcedeth: add wol p support
  2016-03-10 14:58 [PATCH 0/2] drivers/net/forcedeth: add support for WAKE_PHY Karol Herbst
  2016-03-10 14:58 ` [PATCH 1/2] net/forcedeth: refactor wol support to make it easier to add more wol modes Karol Herbst
@ 2016-03-10 14:58 ` Karol Herbst
  2016-03-10 16:13   ` Karol Herbst
  1 sibling, 1 reply; 5+ messages in thread
From: Karol Herbst @ 2016-03-10 14:58 UTC (permalink / raw)
  To: linux-kernel; +Cc: David S . Miller, netdev, Karol Herbst

REd on my mac mini. No idea if that also works on other ethernet cards
supported by forcedeth, but I doubt anybody cares at all, otherwise somebody
else would have REd it already.

Signed-off-by: Karol Herbst <nouveau@karolherbst.de>
---
 drivers/net/ethernet/nvidia/forcedeth.c | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/nvidia/forcedeth.c b/drivers/net/ethernet/nvidia/forcedeth.c
index bdce33b..8e4e894 100644
--- a/drivers/net/ethernet/nvidia/forcedeth.c
+++ b/drivers/net/ethernet/nvidia/forcedeth.c
@@ -291,6 +291,7 @@ enum {
 #define NVREG_WAKEUPFLAGS_ACCEPT_WAKEUPPAT	0x02
 #define NVREG_WAKEUPFLAGS_ACCEPT_LINKCHANGE	0x04
 #define NVREG_WAKEUPFLAGS_ENABLE_G	0x01111
+#define NVREG_WAKEUPFLAGS_ENABLE_P	0x12000
 
 	NvRegMgmtUnitGetVersion = 0x204,
 #define NVREG_MGMTUNITGETVERSION	0x01
@@ -4216,12 +4217,14 @@ static void nv_get_drvinfo(struct net_device *dev, struct ethtool_drvinfo *info)
 static void nv_get_wol(struct net_device *dev, struct ethtool_wolinfo *wolinfo)
 {
 	struct fe_priv *np = netdev_priv(dev);
-	wolinfo->supported = WAKE_MAGIC;
+	wolinfo->supported = WAKE_MAGIC | WAKE_PHY;
 
 	spin_lock_irq(&np->lock);
 	wolinfo->wolopts = 0;
 	if (np->wolenabled & WAKE_MAGIC)
 		wolinfo->wolopts |= WAKE_MAGIC;
+	if (np->wolenabled & WAKE_PHY)
+		wolinfo->wolopts |= WAKE_PHY;
 	spin_unlock_irq(&np->lock);
 }
 
@@ -4236,6 +4239,10 @@ static int nv_set_wol(struct net_device *dev, struct ethtool_wolinfo *wolinfo)
 		np->wolenabled |= WAKE_MAGIC;
 		np->wol_flags |= NVREG_WAKEUPFLAGS_ENABLE_G;
 	}
+	if (wolinfo->wolopts & WAKE_PHY) {
+		np->wolenabled |= WAKE_PHY;
+		np->wol_flags |= NVREG_WAKEUPFLAGS_ENABLE_P;
+	}
 	if (netif_running(dev)) {
 		spin_lock_irq(&np->lock);
 		writel(np->wol_flags, base + NvRegWakeUpFlags);
-- 
2.7.2

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH 2/2] net/forcedeth: add wol p support
  2016-03-10 14:58 ` [PATCH 2/2] net/forcedeth: add wol p support Karol Herbst
@ 2016-03-10 16:13   ` Karol Herbst
  0 siblings, 0 replies; 5+ messages in thread
From: Karol Herbst @ 2016-03-10 16:13 UTC (permalink / raw)
  To: linux-kernel; +Cc: netdev, David S . Miller

one note though:

I am not _really_ sure it is the right flag. I've contacted somebody at nvidia
and asked for documentation regarding this mmio reg.

I still get some random wakeups and I don't know where they are comming from.

> Karol Herbst <git@karolherbst.de> hat am 10. März 2016 um 15:58 geschrieben:
> 
> 
> REd on my mac mini. No idea if that also works on other ethernet cards
> supported by forcedeth, but I doubt anybody cares at all, otherwise somebody
> else would have REd it already.
> 
> Signed-off-by: Karol Herbst <nouveau@karolherbst.de>
> ---
>  drivers/net/ethernet/nvidia/forcedeth.c | 9 ++++++++-
>  1 file changed, 8 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/net/ethernet/nvidia/forcedeth.c
> b/drivers/net/ethernet/nvidia/forcedeth.c
> index bdce33b..8e4e894 100644
> --- a/drivers/net/ethernet/nvidia/forcedeth.c
> +++ b/drivers/net/ethernet/nvidia/forcedeth.c
> @@ -291,6 +291,7 @@ enum {
>  #define NVREG_WAKEUPFLAGS_ACCEPT_WAKEUPPAT	0x02
>  #define NVREG_WAKEUPFLAGS_ACCEPT_LINKCHANGE	0x04
>  #define NVREG_WAKEUPFLAGS_ENABLE_G	0x01111
> +#define NVREG_WAKEUPFLAGS_ENABLE_P	0x12000
>  
>  	NvRegMgmtUnitGetVersion = 0x204,
>  #define NVREG_MGMTUNITGETVERSION	0x01
> @@ -4216,12 +4217,14 @@ static void nv_get_drvinfo(struct net_device *dev,
> struct ethtool_drvinfo *info)
>  static void nv_get_wol(struct net_device *dev, struct ethtool_wolinfo
> *wolinfo)
>  {
>  	struct fe_priv *np = netdev_priv(dev);
> -	wolinfo->supported = WAKE_MAGIC;
> +	wolinfo->supported = WAKE_MAGIC | WAKE_PHY;
>  
>  	spin_lock_irq(&np->lock);
>  	wolinfo->wolopts = 0;
>  	if (np->wolenabled & WAKE_MAGIC)
>  		wolinfo->wolopts |= WAKE_MAGIC;
> +	if (np->wolenabled & WAKE_PHY)
> +		wolinfo->wolopts |= WAKE_PHY;
>  	spin_unlock_irq(&np->lock);
>  }
>  
> @@ -4236,6 +4239,10 @@ static int nv_set_wol(struct net_device *dev, struct
> ethtool_wolinfo *wolinfo)
>  		np->wolenabled |= WAKE_MAGIC;
>  		np->wol_flags |= NVREG_WAKEUPFLAGS_ENABLE_G;
>  	}
> +	if (wolinfo->wolopts & WAKE_PHY) {
> +		np->wolenabled |= WAKE_PHY;
> +		np->wol_flags |= NVREG_WAKEUPFLAGS_ENABLE_P;
> +	}
>  	if (netif_running(dev)) {
>  		spin_lock_irq(&np->lock);
>  		writel(np->wol_flags, base + NvRegWakeUpFlags);
> -- 
> 2.7.2
>

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH 1/2] net/forcedeth: refactor wol support to make it easier to add more wol modes
  2016-03-10 14:58 ` [PATCH 1/2] net/forcedeth: refactor wol support to make it easier to add more wol modes Karol Herbst
@ 2016-03-14  2:14   ` David Miller
  0 siblings, 0 replies; 5+ messages in thread
From: David Miller @ 2016-03-14  2:14 UTC (permalink / raw)
  To: git; +Cc: linux-kernel, netdev

From: Karol Herbst <git@karolherbst.de>
Date: Thu, 10 Mar 2016 15:58:03 +0100

> @@ -4218,8 +4219,9 @@ static void nv_get_wol(struct net_device *dev, struct ethtool_wolinfo *wolinfo)
>  	wolinfo->supported = WAKE_MAGIC;
>  
>  	spin_lock_irq(&np->lock);
> -	if (np->wolenabled)
> -		wolinfo->wolopts = WAKE_MAGIC;
> +	wolinfo->wolopts = 0;
> +	if (np->wolenabled & WAKE_MAGIC)
> +		wolinfo->wolopts |= WAKE_MAGIC;
>  	spin_unlock_irq(&np->lock);
>  }
>  

When I see a change like this I can see you don't understand the
contract that exists between the ethtool core layer and your
driver.

The command info struct, in this case 'wolinfo' passed to you is
zero'd out, always.

Therefore the part of the change explicitly clearing out
wolinfo->wolopts is completely unnecessary and needs to be removed.

Thanks.

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2016-03-14  2:14 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-03-10 14:58 [PATCH 0/2] drivers/net/forcedeth: add support for WAKE_PHY Karol Herbst
2016-03-10 14:58 ` [PATCH 1/2] net/forcedeth: refactor wol support to make it easier to add more wol modes Karol Herbst
2016-03-14  2:14   ` David Miller
2016-03-10 14:58 ` [PATCH 2/2] net/forcedeth: add wol p support Karol Herbst
2016-03-10 16:13   ` Karol Herbst

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).