summaryrefslogtreecommitdiff
path: root/sys/dev
diff options
context:
space:
mode:
authoronoe <onoe@NetBSD.org>2001-06-28 10:40:04 +0000
committeronoe <onoe@NetBSD.org>2001-06-28 10:40:04 +0000
commite7e0a9984c6f049fa7318bc37b1216a5fdcda4e8 (patch)
treed0fae19b8823acb556e982bca7147b2948e73087 /sys/dev
parent950ec87b20e99003fae076e501b5dc2b5dbc5e2d (diff)
Do not re-enable the driver after resume if the interface is marked down.
Change the first argument of awi_init/awi_stop from struct awi_softc to struct ifnet to match the definition if_init/if_stop, though we don't use ether_ioctl() yet.
Diffstat (limited to 'sys/dev')
-rw-r--r--sys/dev/ic/awi.c80
-rw-r--r--sys/dev/ic/awi_wep.c6
-rw-r--r--sys/dev/ic/awi_wicfg.c6
-rw-r--r--sys/dev/ic/awivar.h6
4 files changed, 48 insertions, 50 deletions
diff --git a/sys/dev/ic/awi.c b/sys/dev/ic/awi.c
index b305a04b844..70cb419e4e4 100644
--- a/sys/dev/ic/awi.c
+++ b/sys/dev/ic/awi.c
@@ -1,4 +1,4 @@
-/* $NetBSD: awi.c,v 1.34 2001/06/26 08:41:19 onoe Exp $ */
+/* $NetBSD: awi.c,v 1.35 2001/06/28 10:40:04 onoe Exp $ */
/*-
* Copyright (c) 1999 The NetBSD Foundation, Inc.
@@ -298,6 +298,8 @@ awi_attach(sc)
ifp->if_flags |= IFF_NOTRAILERS;
#endif
#ifdef __NetBSD__
+ ifp->if_init = awi_init;
+ ifp->if_stop = awi_stop;
memcpy(ifp->if_xname, sc->sc_dev.dv_xname, IFNAMSIZ);
#endif
#ifdef __FreeBSD__
@@ -365,7 +367,7 @@ awi_detach(sc)
s = splnet();
sc->sc_invalid = 1;
- awi_stop(sc);
+ awi_stop(ifp, 1);
while (sc->sc_sleep_cnt > 0) {
wakeup(sc);
(void)tsleep(sc, PWAIT, "awidet", 1);
@@ -377,11 +379,6 @@ awi_detach(sc)
#endif
ether_ifdetach(ifp);
if_detach(ifp);
- if (sc->sc_enabled) {
- if (sc->sc_disable)
- (*sc->sc_disable)(sc);
- sc->sc_enabled = 0;
- }
splx(s);
return 0;
}
@@ -416,6 +413,7 @@ awi_power(sc, why)
struct awi_softc *sc;
int why;
{
+ struct ifnet *ifp = sc->sc_ifp;
int s;
int ocansleep;
@@ -425,16 +423,11 @@ awi_power(sc, why)
switch (why) {
case PWR_SUSPEND:
case PWR_STANDBY:
- if (sc->sc_enabled) {
- awi_stop(sc);
- if (sc->sc_disable)
- (*sc->sc_disable)(sc);
- }
+ awi_stop(ifp, 1);
break;
case PWR_RESUME:
- if (sc->sc_enabled) {
- sc->sc_enabled = 0;
- awi_init(sc);
+ if (ifp->if_flags & IFF_UP) {
+ awi_init(ifp);
(void)awi_intr(sc);
}
break;
@@ -480,16 +473,13 @@ awi_ioctl(ifp, cmd, data)
/* FALLTHROUGH */
case SIOCSIFFLAGS:
sc->sc_format_llc = !(ifp->if_flags & IFF_LINK0);
- if (!(ifp->if_flags & IFF_UP)) {
- if (sc->sc_enabled) {
- awi_stop(sc);
- if (sc->sc_disable)
- (*sc->sc_disable)(sc);
- sc->sc_enabled = 0;
- }
- break;
- }
- error = awi_init(sc);
+ if (ifp->if_flags & IFF_UP) {
+ /* Do not reset if already associated */
+ if (!(ifp->if_flags & IFF_RUNNING))
+ awi_stop(ifp, 0);
+ error = awi_init(ifp);
+ } else if (sc->sc_enabled)
+ awi_stop(ifp, 1);
break;
case SIOCADDMULTI:
@@ -506,7 +496,7 @@ awi_ioctl(ifp, cmd, data)
*/
if (error == ENETRESET) {
if (sc->sc_enabled)
- error = awi_init(sc);
+ error = awi_init(ifp);
else
error = 0;
}
@@ -535,8 +525,8 @@ awi_ioctl(ifp, cmd, data)
memcpy(&sc->sc_mib_mac.aDesired_ESS_ID[2], nwid.i_nwid,
nwid.i_len);
if (sc->sc_enabled) {
- awi_stop(sc);
- error = awi_init(sc);
+ awi_stop(ifp, 0); /* force rescan */
+ error = awi_init(ifp);
}
break;
case SIOCG80211NWID:
@@ -548,6 +538,10 @@ awi_ioctl(ifp, cmd, data)
break;
case SIOCS80211NWKEY:
error = awi_wep_setnwkey(sc, (struct ieee80211_nwkey *)data);
+ if (error == 0 && sc->sc_enabled) {
+ awi_stop(ifp, 0); /* force rescan */
+ error = awi_init(ifp);
+ }
break;
case SIOCG80211NWKEY:
error = awi_wep_getnwkey(sc, (struct ieee80211_nwkey *)data);
@@ -680,8 +674,8 @@ awi_media_change(ifp)
sc->sc_mib_local.Network_Mode = 1;
}
if (sc->sc_enabled) {
- awi_stop(sc);
- error = awi_init(sc);
+ awi_stop(ifp, 0); /* force rescan */
+ error = awi_init(ifp);
}
return error;
}
@@ -758,12 +752,12 @@ awi_intr(arg)
}
int
-awi_init(sc)
- struct awi_softc *sc;
+awi_init(ifp)
+ struct ifnet *ifp;
{
+ struct awi_softc *sc = ifp->if_softc;
int error, ostatus;
int n;
- struct ifnet *ifp = sc->sc_ifp;
#ifdef __FreeBSD__
struct ifmultiaddr *ifma;
#else
@@ -822,8 +816,10 @@ awi_init(sc)
(*sc->sc_enable)(sc);
sc->sc_status = AWI_ST_INIT;
error = awi_init_hw(sc);
- if (error)
+ if (error) {
+ awi_stop(ifp, 1);
return error;
+ }
}
ostatus = sc->sc_status;
sc->sc_status = AWI_ST_INIT;
@@ -832,7 +828,7 @@ awi_init(sc)
(error = awi_mib(sc, AWI_CMD_SET_MIB, AWI_MIB_MAC)) != 0 ||
(error = awi_mib(sc, AWI_CMD_SET_MIB, AWI_MIB_MGT)) != 0 ||
(error = awi_mib(sc, AWI_CMD_SET_MIB, AWI_MIB_PHY)) != 0) {
- awi_stop(sc);
+ awi_stop(ifp, 1);
return error;
}
if (ifp->if_flags & IFF_RUNNING)
@@ -849,14 +845,15 @@ awi_init(sc)
}
void
-awi_stop(sc)
- struct awi_softc *sc;
+awi_stop(ifp, disable)
+ struct ifnet *ifp;
+ int disable;
{
- struct ifnet *ifp = sc->sc_ifp;
+ struct awi_softc *sc = ifp->if_softc;
struct awi_bss *bp;
sc->sc_status = AWI_ST_INIT;
- if (!sc->sc_invalid) {
+ if (sc->sc_enabled && !sc->sc_invalid) {
(void)awi_cmd_wait(sc);
if (sc->sc_mib_local.Network_Mode &&
sc->sc_status > AWI_ST_AUTH)
@@ -872,6 +869,11 @@ awi_stop(sc)
TAILQ_REMOVE(&sc->sc_scan, bp, list);
free(bp, M_DEVBUF);
}
+ if (sc->sc_enabled && disable) {
+ if (sc->sc_disable)
+ (*sc->sc_disable)(sc);
+ sc->sc_enabled = 0;
+ }
}
static void
diff --git a/sys/dev/ic/awi_wep.c b/sys/dev/ic/awi_wep.c
index eb5a684a10c..7582ab2166b 100644
--- a/sys/dev/ic/awi_wep.c
+++ b/sys/dev/ic/awi_wep.c
@@ -1,4 +1,4 @@
-/* $NetBSD: awi_wep.c,v 1.7 2001/06/25 12:11:59 onoe Exp $ */
+/* $NetBSD: awi_wep.c,v 1.8 2001/06/28 10:40:04 onoe Exp $ */
/*
* Copyright (c) 2000 The NetBSD Foundation, Inc.
@@ -164,10 +164,6 @@ awi_wep_setnwkey(sc, nwkey)
if (error == 0) {
sc->sc_wep_defkid = nwkey->i_defkid - 1;
error = awi_wep_setalgo(sc, nwkey->i_wepon);
- if (error == 0 && sc->sc_enabled) {
- awi_stop(sc);
- error = awi_init(sc);
- }
}
return error;
}
diff --git a/sys/dev/ic/awi_wicfg.c b/sys/dev/ic/awi_wicfg.c
index 375e0b58285..535c65ea9f7 100644
--- a/sys/dev/ic/awi_wicfg.c
+++ b/sys/dev/ic/awi_wicfg.c
@@ -1,4 +1,4 @@
-/* $NetBSD: awi_wicfg.c,v 1.6 2001/06/25 04:43:33 onoe Exp $ */
+/* $NetBSD: awi_wicfg.c,v 1.7 2001/06/28 10:40:04 onoe Exp $ */
/*
* Copyright (c) 2000 The NetBSD Foundation, Inc.
@@ -648,8 +648,8 @@ awi_cfgset(ifp, cmd, data)
}
if (error == ENETRESET) {
if (sc->sc_enabled) {
- awi_stop(sc);
- error = awi_init(sc);
+ awi_stop(ifp, 0);
+ error = awi_init(ifp);
} else
error = 0;
}
diff --git a/sys/dev/ic/awivar.h b/sys/dev/ic/awivar.h
index 3e68e82fb74..14f0ae1be8b 100644
--- a/sys/dev/ic/awivar.h
+++ b/sys/dev/ic/awivar.h
@@ -1,4 +1,4 @@
-/* $NetBSD: awivar.h,v 1.13 2001/01/18 20:28:17 jdolecek Exp $ */
+/* $NetBSD: awivar.h,v 1.14 2001/06/28 10:40:04 onoe Exp $ */
/*-
* Copyright (c) 1999 The NetBSD Foundation, Inc.
@@ -201,14 +201,14 @@ struct awi_softc
int awi_attach __P((struct awi_softc *));
int awi_intr __P((void *));
void awi_reset __P((struct awi_softc *));
+int awi_init __P((struct ifnet *));
+void awi_stop __P((struct ifnet *, int));
#ifdef __NetBSD__
int awi_activate __P((struct device *, enum devact));
int awi_detach __P((struct awi_softc *));
void awi_power __P((struct awi_softc *, int));
#endif
-void awi_stop __P((struct awi_softc *sc));
-int awi_init __P((struct awi_softc *sc));
int awi_init_region __P((struct awi_softc *));
int awi_wicfg __P((struct ifnet *, u_long, caddr_t));