Skip to contentSkip to conversation

3c59x: Add ethtool WOL support

PATCH Applied Andrew O. Shadoura 3 participants 3 messages Jul 25, 2010

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 3c59x: Add ethtool WOL support

This patch adds wrappers for ethtool to get or set wake-on-LAN setting without re-inserting the kernel module.

---
Hello.

I've actually tested this patch on a machine with a network card that's idenfied by lsusb as "3c905C-TX/TX-M", and it seems to work.

---

drivers/net/3c59x.c +32 -0
index d75803e..a452dfe 100644
@@ -2909,6 +2909,36 @@ static void vortex_get_drvinfo(struct net_device *dev,
 	}
 }
 
+static void vortex_get_wol(struct net_device *dev, struct ethtool_wolinfo *wol)
+{
+	struct vortex_private *vp = netdev_priv(dev);
+
+	spin_lock_irq(&vp->lock);
+	wol->supported = WAKE_MAGIC;
+
+	wol->wolopts = 0;
+	if (vp->enable_wol)
+		wol->wolopts |= WAKE_MAGIC;
+	spin_unlock_irq(&vp->lock);
+}
+
+static int vortex_set_wol(struct net_device *dev, struct ethtool_wolinfo *wol)
+{
+	struct vortex_private *vp = netdev_priv(dev);
+	if (wol->wolopts & ~WAKE_MAGIC)
+		return -EINVAL;
+
+	spin_lock_irq(&vp->lock);
+	if (wol->wolopts & WAKE_MAGIC)
+		vp->enable_wol = 1;
+	else
+		vp->enable_wol = 0;
+	acpi_set_WOL(dev);
+	spin_unlock_irq(&vp->lock);
+
+	return 0;
+}
+
 static const struct ethtool_ops vortex_ethtool_ops = {
 	.get_drvinfo		= vortex_get_drvinfo,
 	.get_strings            = vortex_get_strings,
@@ -2920,6 +2950,8 @@ static const struct ethtool_ops vortex_ethtool_ops = {
 	.set_settings           = vortex_set_settings,
 	.get_link               = ethtool_op_get_link,
 	.nway_reset             = vortex_nway_reset,
+	.get_wol                = vortex_get_wol,
+	.set_wol                = vortex_set_wol,
 };
 
 #ifdef CONFIG_PCI
Signature · 1 line
WBR, Andrew
#1 lore raw

Hello.

Quoted 3 lines · On Sunday 25 July 2010 05:24:17 Andrew O. Shadoura wrote:

I've actually tested this patch on a machine with a network card that's idenfied by lsusb as "3c905C-TX/TX-M", and it seems to work.

Oops, of course I meant "it's identified by lspci as ...".

Signature · 1 line
WBR, Andrew