From c4a973882a0a60e654fce9e6f76a5fe3f2d17172 Mon Sep 17 00:00:00 2001 From: deraadt Date: Fri, 6 Aug 2010 14:11:42 +0000 Subject: [PATCH] ca_activate for suspend/resume; tested by andrew@afresh1.com --- sys/dev/ic/fxp.c | 4 +--- sys/dev/ic/fxpvar.h | 4 +++- sys/dev/pci/if_fxp_pci.c | 26 ++++++++++++++++++++++++-- 3 files changed, 28 insertions(+), 6 deletions(-) diff --git a/sys/dev/ic/fxp.c b/sys/dev/ic/fxp.c index 1ebf6772268..76e5c073d88 100644 --- a/sys/dev/ic/fxp.c +++ b/sys/dev/ic/fxp.c @@ -1,4 +1,4 @@ -/* $OpenBSD: fxp.c,v 1.101 2010/05/19 15:27:35 oga Exp $ */ +/* $OpenBSD: fxp.c,v 1.102 2010/08/06 14:11:42 deraadt Exp $ */ /* $NetBSD: if_fxp.c,v 1.2 1997/06/05 02:01:55 thorpej Exp $ */ /* @@ -147,9 +147,7 @@ void fxp_mediastatus(struct ifnet *, struct ifmediareq *); void fxp_scb_wait(struct fxp_softc *); void fxp_start(struct ifnet *); int fxp_ioctl(struct ifnet *, u_long, caddr_t); -void fxp_init(void *); void fxp_load_ucode(struct fxp_softc *); -void fxp_stop(struct fxp_softc *, int, int); void fxp_watchdog(struct ifnet *); int fxp_add_rfabuf(struct fxp_softc *, struct mbuf *); int fxp_mdi_read(struct device *, int, int); diff --git a/sys/dev/ic/fxpvar.h b/sys/dev/ic/fxpvar.h index 594764d618d..66ddb3ca3f1 100644 --- a/sys/dev/ic/fxpvar.h +++ b/sys/dev/ic/fxpvar.h @@ -1,4 +1,4 @@ -/* $OpenBSD: fxpvar.h,v 1.31 2009/10/15 17:54:54 deraadt Exp $ */ +/* $OpenBSD: fxpvar.h,v 1.32 2010/08/06 14:11:43 deraadt Exp $ */ /* $NetBSD: if_fxpvar.h,v 1.1 1997/06/05 02:01:58 thorpej Exp $ */ /* @@ -157,6 +157,8 @@ struct fxp_softc { extern int fxp_intr(void *); extern int fxp_attach(struct fxp_softc *, const char *); void fxp_detach(struct fxp_softc *); +void fxp_init(void *); +void fxp_stop(struct fxp_softc *, int, int); #define FXP_RXMAP_GET(sc) ((sc)->sc_rxmaps[(sc)->sc_rxfree++]) #define FXP_RXMAP_PUT(sc,map) ((sc)->sc_rxmaps[--(sc)->sc_rxfree] = (map)) diff --git a/sys/dev/pci/if_fxp_pci.c b/sys/dev/pci/if_fxp_pci.c index 9166c3a4656..6afc8ca4062 100644 --- a/sys/dev/pci/if_fxp_pci.c +++ b/sys/dev/pci/if_fxp_pci.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_fxp_pci.c,v 1.52 2009/10/15 17:54:56 deraadt Exp $ */ +/* $OpenBSD: if_fxp_pci.c,v 1.53 2010/08/06 14:11:48 deraadt Exp $ */ /* * Copyright (c) 1995, David Greenman @@ -81,6 +81,7 @@ int fxp_pci_match(struct device *, void *, void *); void fxp_pci_attach(struct device *, struct device *, void *); int fxp_pci_detach(struct device *, int); +int fxp_pci_activate(struct device *, int); struct fxp_pci_softc { struct fxp_softc psc_softc; @@ -90,7 +91,7 @@ struct fxp_pci_softc { struct cfattach fxp_pci_ca = { sizeof(struct fxp_pci_softc), fxp_pci_match, fxp_pci_attach, - fxp_pci_detach + fxp_pci_detach, fxp_pci_activate }; const struct pci_matchid fxp_pci_devices[] = { @@ -276,3 +277,24 @@ fxp_pci_detach(struct device *self, int flags) return (0); } + +int +fxp_pci_activate(struct device *self, int act) +{ + struct fxp_softc *sc = (struct fxp_softc *)self; + struct ifnet *ifp = &sc->sc_arpcom.ac_if; + + switch (act) { + case DVACT_SUSPEND: + if (ifp->if_flags & IFF_RUNNING) + fxp_stop(sc, 1, 1); + config_activate_children(self, act); + break; + case DVACT_RESUME: + config_activate_children(self, act); + if (ifp->if_flags & IFF_UP) + fxp_init(ifp); + break; + } + return (0); +} -- 2.20.1