From de0abf19baf53432276904fa858a8c28cf881ffb Mon Sep 17 00:00:00 2001 From: Sam Leffler Date: Mon, 10 Dec 2007 02:31:00 +0000 Subject: [PATCH] Wake On Lan (WOL) infrastructure Submitted by: Stefan Sperling Reviewed by: brooks --- sbin/ifconfig/ifconfig.8 | 17 ++++++++++++++++- sbin/ifconfig/ifconfig.c | 10 +++++++++- sys/net/if.h | 8 ++++++-- 3 files changed, 31 insertions(+), 4 deletions(-) diff --git a/sbin/ifconfig/ifconfig.8 b/sbin/ifconfig/ifconfig.8 index 05f0dc19da97..4dfafc1bbc3d 100644 --- a/sbin/ifconfig/ifconfig.8 +++ b/sbin/ifconfig/ifconfig.8 @@ -28,7 +28,7 @@ .\" From: @(#)ifconfig.8 8.3 (Berkeley) 1/5/94 .\" $FreeBSD$ .\" -.Dd October 31, 2007 +.Dd December 8, 2007 .Dt IFCONFIG 8 .Os .Sh NAME @@ -387,6 +387,21 @@ large receive offloading, enable LRO on the interface. If the driver supports .Xr tcp 4 large receive offloading, disable LRO on the interface. +.It Cm wol , wol_ucast , wol_mcast , wol_magic +Enable Wake On Lan (WOL) support, if available. +WOL is a facility whereby a machine in a low power state may be woken +in response to a received packet. +There are three types of packets that may wake a system: +ucast (directed solely to the machine's mac address), +mcast (directed to a broadcast or multicast address), +or +magic (unicast or multicast frames with a ``magic contents''). +Not all devices support WOL, those that do indicate the mechanisms +they support in their capabilities. +.Cm wol +is a synonym for enabling all available WOL mechanisms. +To disable WOL use +.Fl wol . .It Cm vlanmtu , vlanhwtag If the driver offers user-configurable VLAN support, enable reception of extended frames or tag processing in hardware, diff --git a/sbin/ifconfig/ifconfig.c b/sbin/ifconfig/ifconfig.c index 3ea1b31fdf4d..36763967911f 100644 --- a/sbin/ifconfig/ifconfig.c +++ b/sbin/ifconfig/ifconfig.c @@ -746,7 +746,7 @@ setifname(const char *val, int dummy __unused, int s, #define IFCAPBITS \ "\020\1RXCSUM\2TXCSUM\3NETCONS\4VLAN_MTU\5VLAN_HWTAGGING\6JUMBO_MTU\7POLLING" \ -"\10VLAN_HWCSUM\11TSO4\12TSO6\13LRO" +"\10VLAN_HWCSUM\11TSO4\12TSO6\13LRO\14WOL_UCAST\15WOL_MCAST\16WOL_MAGIC" /* * Print the status of the interface. If an address family was @@ -991,6 +991,14 @@ static struct cmd basic_cmds[] = { DEF_CMD("-tso", -IFCAP_TSO, setifcap), DEF_CMD("lro", IFCAP_LRO, setifcap), DEF_CMD("-lro", -IFCAP_LRO, setifcap), + DEF_CMD("wol", IFCAP_WOL, setifcap), + DEF_CMD("-wol", -IFCAP_WOL, setifcap), + DEF_CMD("wol_ucast", IFCAP_WOL_UCAST, setifcap), + DEF_CMD("-wol_ucast", -IFCAP_WOL_UCAST, setifcap), + DEF_CMD("wol_mcast", IFCAP_WOL_MCAST, setifcap), + DEF_CMD("-wol_mcast", -IFCAP_WOL_MCAST, setifcap), + DEF_CMD("wol_magic", IFCAP_WOL_MAGIC, setifcap), + DEF_CMD("-wol_magic", -IFCAP_WOL_MAGIC, setifcap), DEF_CMD("normal", -IFF_LINK0, setifflags), DEF_CMD("compress", IFF_LINK0, setifflags), DEF_CMD("noicmp", IFF_LINK1, setifflags), diff --git a/sys/net/if.h b/sys/net/if.h index a5a0e967604f..c649fca654cd 100644 --- a/sys/net/if.h +++ b/sys/net/if.h @@ -209,9 +209,13 @@ struct if_data { #define IFCAP_TSO4 0x0100 /* can do TCP Segmentation Offload */ #define IFCAP_TSO6 0x0200 /* can do TCP6 Segmentation Offload */ #define IFCAP_LRO 0x0400 /* can do Large Receive Offload */ +#define IFCAP_WOL_UCAST 0x0800 /* wake on any unicast frame */ +#define IFCAP_WOL_MCAST 0x1000 /* wake on any multicast frame */ +#define IFCAP_WOL_MAGIC 0x2000 /* wake on any Magic Packet */ -#define IFCAP_HWCSUM (IFCAP_RXCSUM | IFCAP_TXCSUM) -#define IFCAP_TSO (IFCAP_TSO4 | IFCAP_TSO6) +#define IFCAP_HWCSUM (IFCAP_RXCSUM | IFCAP_TXCSUM) +#define IFCAP_TSO (IFCAP_TSO4 | IFCAP_TSO6) +#define IFCAP_WOL (IFCAP_WOL_UCAST | IFCAP_WOL_MCAST | IFCAP_WOL_MAGIC) #define IFQ_MAXLEN 50 #define IFNET_SLOWHZ 1 /* granularity is 1 second */