From c932241a1954996c40c29ab699a0f5841bab84dc Mon Sep 17 00:00:00 2001 From: Marcus Glocker Date: Thu, 9 Aug 2007 08:53:23 +0000 Subject: 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. --- sys/dev/pcmcia/if_malo.c | 31 ++++++++++++++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) (limited to 'sys/dev/pcmcia/if_malo.c') 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 @@ -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); } @@ -978,6 +982,31 @@ cmalo_tx_done(struct malo_softc *sc) cmalo_start(ifp); } +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) { -- cgit v1.2.3