From 6daee769f4277fe356aee26fa3f0154b0a982b63 Mon Sep 17 00:00:00 2001 From: John Baldwin Date: Mon, 20 Nov 2006 23:30:07 +0000 Subject: [PATCH] Add suspend/resume support. Unlike many other NIC drivers, bfe_init_locked() wasn't sufficient to bring the chip back to life, it also required a call to bfe_chip_reset() during resume. Tested by: Stepan Zastupov +redchrom at gmail+ MFC after: 1 week --- sys/dev/bfe/if_bfe.c | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/sys/dev/bfe/if_bfe.c b/sys/dev/bfe/if_bfe.c index 3aa99ee985da..dc24da9860e1 100644 --- a/sys/dev/bfe/if_bfe.c +++ b/sys/dev/bfe/if_bfe.c @@ -87,6 +87,8 @@ static struct bfe_type bfe_devs[] = { static int bfe_probe (device_t); static int bfe_attach (device_t); static int bfe_detach (device_t); +static int bfe_suspend (device_t); +static int bfe_resume (device_t); static void bfe_release_resources (struct bfe_softc *); static void bfe_intr (void *); static void bfe_start (struct ifnet *); @@ -136,6 +138,8 @@ static device_method_t bfe_methods[] = { DEVMETHOD(device_attach, bfe_attach), DEVMETHOD(device_detach, bfe_detach), DEVMETHOD(device_shutdown, bfe_shutdown), + DEVMETHOD(device_suspend, bfe_suspend), + DEVMETHOD(device_resume, bfe_resume), /* bus interface */ DEVMETHOD(bus_print_child, bus_generic_print_child), @@ -479,6 +483,40 @@ bfe_shutdown(device_t dev) return; } +static int +bfe_suspend(device_t dev) +{ + struct bfe_softc *sc; + + sc = device_get_softc(dev); + BFE_LOCK(sc); + bfe_stop(sc); + BFE_UNLOCK(sc); + + return (0); +} + +static int +bfe_resume(device_t dev) +{ + struct bfe_softc *sc; + struct ifnet *ifp; + + sc = device_get_softc(dev); + ifp = sc->bfe_ifp; + BFE_LOCK(sc); + bfe_chip_reset(sc); + if (ifp->if_flags & IFF_UP) { + bfe_init_locked(sc); + if (ifp->if_drv_flags & IFF_DRV_RUNNING && + !IFQ_DRV_IS_EMPTY(&ifp->if_snd)) + bfe_start_locked(ifp); + } + BFE_UNLOCK(sc); + + return (0); +} + static int bfe_miibus_readreg(device_t dev, int phy, int reg) {