diff options
author | 2011-03-13 15:38:50 +0000 | |
---|---|---|
committer | 2011-03-13 15:38:50 +0000 | |
commit | 044fa53697a61a0df6adea14b4bc3fab9266c4f6 (patch) | |
tree | 4ab43c88896ea225a9ec350db4e484afdaf239eb | |
parent | Wake On LAN support for re(4). (diff) | |
download | wireguard-openbsd-044fa53697a61a0df6adea14b4bc3fab9266c4f6.tar.xz wireguard-openbsd-044fa53697a61a0df6adea14b4bc3fab9266c4f6.zip |
Wake On LAN support for vr(4).
ok deraadt
-rw-r--r-- | share/man/man4/vr.4 | 9 | ||||
-rw-r--r-- | sys/dev/pci/if_vr.c | 40 | ||||
-rw-r--r-- | sys/dev/pci/if_vrreg.h | 17 |
3 files changed, 62 insertions, 4 deletions
diff --git a/share/man/man4/vr.4 b/share/man/man4/vr.4 index b1ca5e3355c..24f5582cf91 100644 --- a/share/man/man4/vr.4 +++ b/share/man/man4/vr.4 @@ -1,4 +1,4 @@ -.\" $OpenBSD: vr.4,v 1.22 2009/03/16 22:47:45 sobrado Exp $ +.\" $OpenBSD: vr.4,v 1.23 2011/03/13 15:38:50 stsp Exp $ .\" .\" Copyright (c) 1997, 1998 .\" Bill Paul <wpaul@ctr.columbia.edu>. All rights reserved. @@ -32,7 +32,7 @@ .\" .\" $FreeBSD: vr.4,v 1.3 1999/03/25 00:52:44 wpaul Exp $ .\" -.Dd $Mdocdate: March 16 2009 $ +.Dd $Mdocdate: March 13 2011 $ .Dt VR 4 .Os .Sh NAME @@ -104,6 +104,11 @@ Force half duplex operation. .Pp Note that the 100baseTX media type is only available if supported by the adapter. +.Pp +The +.Nm +driver supports Wake On LAN. +.Pp For more information on configuring this device, see .Xr ifconfig 8 . .Sh DIAGNOSTICS diff --git a/sys/dev/pci/if_vr.c b/sys/dev/pci/if_vr.c index e8ec0e4c093..7703a2a65cb 100644 --- a/sys/dev/pci/if_vr.c +++ b/sys/dev/pci/if_vr.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_vr.c,v 1.107 2011/01/13 11:28:14 kettenis Exp $ */ +/* $OpenBSD: if_vr.c,v 1.108 2011/03/13 15:38:50 stsp Exp $ */ /* * Copyright (c) 1997, 1998 @@ -137,6 +137,9 @@ void vr_reset(struct vr_softc *); int vr_list_rx_init(struct vr_softc *); void vr_fill_rx_ring(struct vr_softc *); int vr_list_tx_init(struct vr_softc *); +#ifndef SMALL_KERNEL +int vr_wol(struct ifnet *, int); +#endif int vr_alloc_mbuf(struct vr_softc *, struct vr_chain_onefrag *); @@ -643,6 +646,13 @@ vr_attach(struct device *parent, struct device *self, void *aux) if (sc->vr_quirks & VR_Q_CSUM) ifp->if_capabilities |= IFCAP_CSUM_IPv4|IFCAP_CSUM_TCPv4| IFCAP_CSUM_UDPv4; +#ifndef SMALL_KERNEL + if (sc->vr_revid >= REV_ID_VT3065_A) { + ifp->if_capabilities |= IFCAP_WOL; + ifp->if_wol = vr_wol; + vr_wol(ifp, 0); + } +#endif /* * Do MII setup. @@ -1529,6 +1539,34 @@ vr_stop(struct vr_softc *sc) sizeof(sc->vr_ldata->vr_tx_list)); } +#ifndef SMALL_KERNEL +int +vr_wol(struct ifnet *ifp, int enable) +{ + struct vr_softc *sc = ifp->if_softc; + + /* Clear WOL configuration */ + CSR_WRITE_1(sc, VR_WOLCRCLR, 0xFF); + + /* Clear event status bits. */ + CSR_WRITE_1(sc, VR_PWRCSRCLR, 0xFF); + + /* Disable PME# assertion upon wake event. */ + VR_CLRBIT(sc, VR_STICKHW, VR_STICKHW_WOL_ENB); + VR_SETBIT(sc, VR_WOLCFGCLR, VR_WOLCFG_PMEOVR); + + if (enable) { + VR_SETBIT(sc, VR_WOLCRSET, VR_WOLCR_MAGIC); + + /* Enable PME# assertion upon wake event. */ + VR_SETBIT(sc, VR_STICKHW, VR_STICKHW_WOL_ENB); + VR_SETBIT(sc, VR_WOLCFGSET, VR_WOLCFG_PMEOVR); + } + + return (0); +} +#endif + int vr_alloc_mbuf(struct vr_softc *sc, struct vr_chain_onefrag *r) { diff --git a/sys/dev/pci/if_vrreg.h b/sys/dev/pci/if_vrreg.h index 13f41ad9883..f4b620f8f38 100644 --- a/sys/dev/pci/if_vrreg.h +++ b/sys/dev/pci/if_vrreg.h @@ -1,4 +1,4 @@ -/* $OpenBSD: if_vrreg.h,v 1.27 2009/06/18 17:48:15 claudio Exp $ */ +/* $OpenBSD: if_vrreg.h,v 1.28 2011/03/13 15:38:50 stsp Exp $ */ /* * Copyright (c) 1997, 1998 @@ -285,6 +285,21 @@ #define VR_STICKHW_WOL_STS 0x08 #define VR_STICKHW_LEGWOL_ENB 0x80 +/* Wake on Lan */ +#define VR_WOLCRSET 0xA0 +#define VR_PWRCFGSET 0xA1 +#define VR_WOLCFGSET 0xA3 +#define VR_WOLCRCLR 0xA4 +#define VR_PWRCFGCLR 0xA5 +#define VR_WOLCFGCLR 0xA7 +#define VR_PWRCSRSET 0xA8 +#define VR_PWRCSRCLR 0xAC +#define VR_WOLCR_UCAST 0x10 +#define VR_WOLCR_MAGIC 0x20 +#define VR_WOLCR_LINKON 0x40 +#define VR_WOLCR_LINKOFF 0x80 +#define VR_WOLCFG_PMEOVR 0x80 + /* * BCR0 register bits. (At least for the VT6102 chip.) */ |