diff options
author | Marcus Glocker <mglocker@cvs.openbsd.org> | 2007-08-09 08:53:23 +0000 |
---|---|---|
committer | Marcus Glocker <mglocker@cvs.openbsd.org> | 2007-08-09 08:53:23 +0000 |
commit | c932241a1954996c40c29ab699a0f5841bab84dc (patch) | |
tree | 1027dabbf1b958a0abc210c8b29160aeb8d82b2c | |
parent | 7018f7cbac92f3162dc997d337a9fc4d24d4faaa (diff) |
Add event handler. Events notify us about things like when a
disassociation frame has arrived.
Nice side effect; As we acknowledge the event reason after receiving
a disassociation frame (which happens pretty often by wi(4) hostap) now,
the FW issues an automatic reassociation, and we do not loose network
connectivity anymore.
-rw-r--r-- | sys/dev/pcmcia/if_malo.c | 31 | ||||
-rw-r--r-- | sys/dev/pcmcia/if_maloreg.h | 7 |
2 files changed, 36 insertions, 2 deletions
diff --git a/sys/dev/pcmcia/if_malo.c b/sys/dev/pcmcia/if_malo.c index eb08fe4490f..3c9def435d8 100644 --- a/sys/dev/pcmcia/if_malo.c +++ b/sys/dev/pcmcia/if_malo.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_malo.c,v 1.43 2007/08/07 11:44:44 mglocker Exp $ */ +/* $OpenBSD: if_malo.c,v 1.44 2007/08/09 08:53:22 mglocker Exp $ */ /* * Copyright (c) 2007 Marcus Glocker <mglocker@openbsd.org> @@ -87,6 +87,7 @@ void cmalo_start(struct ifnet *); void cmalo_watchdog(struct ifnet *); int cmalo_tx(struct malo_softc *, struct mbuf *); void cmalo_tx_done(struct malo_softc *); +void cmalo_event(struct malo_softc *); void cmalo_select_network(struct malo_softc *); void cmalo_reflect_network(struct malo_softc *); int cmalo_wep(struct malo_softc *); @@ -797,6 +798,9 @@ cmalo_intr(void *arg) if (intr & MALO_VAL_HOST_INTR_CMD) /* command response */ wakeup(sc); + if (intr & MALO_VAL_HOST_INTR_EVENT) + /* event */ + cmalo_event(sc); return (1); } @@ -979,6 +983,31 @@ cmalo_tx_done(struct malo_softc *sc) } void +cmalo_event(struct malo_softc *sc) +{ + uint16_t event; + + /* read event reason */ + event = MALO_READ_2(sc, MALO_REG_CARD_STATUS); + event &= MALO_VAL_CARD_STATUS_MASK; + event = event >> 8; + + switch (event) { + case MALO_EVENT_DISSASOC: + DPRINTF(1, "%s: got disassociation event (0x%04x)\n", + sc->sc_dev.dv_xname, event); + break; + default: + DPRINTF(1, "%s: got unknown event (0x%04x)\n", + sc->sc_dev.dv_xname, event); + break; + } + + /* clear event */ + MALO_WRITE_2(sc, MALO_REG_CARD_INTR_CAUSE, MALO_VAL_CMD_DL_OVER); +} + +void cmalo_select_network(struct malo_softc *sc) { struct ieee80211com *ic = &sc->sc_ic; diff --git a/sys/dev/pcmcia/if_maloreg.h b/sys/dev/pcmcia/if_maloreg.h index 0ec05cd0d8d..2f359034c86 100644 --- a/sys/dev/pcmcia/if_maloreg.h +++ b/sys/dev/pcmcia/if_maloreg.h @@ -1,4 +1,4 @@ -/* $OpenBSD: if_maloreg.h,v 1.11 2007/08/05 10:05:57 mglocker Exp $ */ +/* $OpenBSD: if_maloreg.h,v 1.12 2007/08/09 08:53:22 mglocker Exp $ */ /* * Copyright (c) 2007 Marcus Glocker <mglocker@openbsd.org> @@ -41,11 +41,13 @@ #define MALO_VAL_TX_DL_OVER 0x01 #define MALO_VAL_RX_DL_OVER 0x02 #define MALO_VAL_CMD_DL_OVER 0x04 +#define MALO_VAL_CARD_STATUS_MASK 0x7f00 /* interrupt reasons */ #define MALO_VAL_HOST_INTR_TX (1 << 0) #define MALO_VAL_HOST_INTR_RX (1 << 1) #define MALO_VAL_HOST_INTR_CMD (1 << 3) +#define MALO_VAL_HOST_INTR_EVENT (1 << 4) /* FW commands */ #define MALO_CMD_RESP 0x8000 @@ -75,3 +77,6 @@ #define MALO_CMD_MACCTRL_RX_ON 0x0001 #define MALO_CMD_MACCTRL_TX_ON 0x0002 #define MALO_CMD_MACCTRL_PROMISC_ON 0x0080 + +/* events */ +#define MALO_EVENT_DISSASOC 0x0009 |