Date: Mon, 9 Jul 2007 01:39:05 GMT From: Andrew Thompson <thompsa@FreeBSD.org> To: Perforce Change Reviews <perforce@freebsd.org> Subject: PERFORCE change 123165 for review Message-ID: <200707090139.l691d5KA007072@repoman.freebsd.org>
next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=123165 Change 123165 by thompsa@thompsa_heff on 2007/07/09 01:38:17 - mised the *.h files in the last submit - remove debug printf Affected files ... .. //depot/projects/wifi/sys/dev/ipw/if_ipw.c#22 edit .. //depot/projects/wifi/sys/dev/ipw/if_ipwreg.h#4 edit .. //depot/projects/wifi/sys/dev/ipw/if_ipwvar.h#6 edit Differences ... ==== //depot/projects/wifi/sys/dev/ipw/if_ipw.c#22 (text+ko) ==== @@ -339,7 +339,6 @@ val <<= 1; for (i = 1; i < 16; i++) { if (val & (1 << i)) { - printf("adding channel %d\n",i); c = &ic->ic_channels[ic->ic_nchans++]; c->ic_freq = ieee80211_ieee2mhz(i, IEEE80211_CHAN_2GHZ); c->ic_flags = IEEE80211_CHAN_B; ==== //depot/projects/wifi/sys/dev/ipw/if_ipwreg.h#4 (text+ko) ==== ==== //depot/projects/wifi/sys/dev/ipw/if_ipwvar.h#6 (text+ko) ==== @@ -90,21 +90,20 @@ device_t sc_dev; struct mtx sc_mtx; + struct mtx sc_cmdlock; + char sc_cmdname[12]; /* e.g. "ipw0_cmd" */ struct taskqueue *sc_tq; /* private task queue */ #if __FreeBSD_version < 700000 struct proc *sc_tqproc; #endif + struct task sc_opstask; struct task sc_radiontask; /* radio on processing */ struct task sc_radiofftask; /* radio off processing */ - struct task sc_scanstarttask;/* scan start processing */ struct task sc_assoclosttask;/* assoc lost processing */ - struct task sc_assoctask; /* assoc lost processing */ - struct task sc_downtask; /* disassociate processing */ struct task sc_restarttask; /* restart adapter processing */ struct callout sc_wdtimer; /* watchdog timer */ uint32_t flags; -#define IPW_FLAG_FW_LOADING 0x00000001 /* firmware being setup */ #define IPW_FLAG_FW_INITED 0x00000002 /* firmware initialized */ #define IPW_FLAG_SCANNING 0x00000004 /* busy scanning */ #define IPW_FLAG_BUSY 0x00000008 /* busy sending a command */ @@ -112,6 +111,12 @@ #define IPW_FLAG_ENABLED 0x00000020 /* adapter enabled */ #define IPW_FLAG_HAS_RFSWITCH 0x00010000 /* rfkill switch present */ #define IPW_FLAG_HACK 0x00020000 + uint32_t fw_state; +#define IPW_FW_IDLE 0 +#define IPW_FW_LOADING 1 +#define IPW_FW_ASSOCIATING 2 +#define IPW_FW_DISASSOCIATING 3 +#define IPW_FW_SCANNING 4 int irq_rid; int mem_rid; @@ -164,13 +169,22 @@ uint32_t rxcur; int txfree; - int curchan; /* current h/w channel # */ + int chanmask; /* supported channels */ int dwelltime; int sc_tx_timer; int sc_rfkill_timer;/* poll for rfkill change */ int sc_scan_timer; /* scan request timeout */ + int sc_state_timer; +#define IPW_SCAN_START (1 << 0) +#define IPW_SET_CHANNEL (1 << 1) +#define IPW_ASSOC (1 << 2) +#define IPW_DISASSOC (1 << 3) +#define IPW_CMD_MAXOPS 10 + int sc_cmd[IPW_CMD_MAXOPS]; + int sc_cmd_cur; /* current queued scan task */ + int sc_cmd_next; /* last queued scan task */ struct bpf_if *sc_drvbpf; union { @@ -187,3 +201,46 @@ #define sc_txtap sc_txtapu.th int sc_txtap_len; }; + +#define IPW_STATE_BEGIN(_sc, _state) do { \ + KASSERT(_sc->fw_state == IPW_FW_IDLE, \ + ("ipw firmware not idle")); \ + _sc->fw_state = _state; \ + _sc->sc_state_timer = 5; \ + DPRINTF(("enter FW state %d\n", _state)); \ +} while (0) + +#define IPW_STATE_END(_sc, _state) do { \ + if (_sc->fw_state == _state) \ + DPRINTF(("exit FW state %d\n", _state)); \ + else \ + DPRINTF(("expected FW state %d, got %d\n", \ + _state, _sc->fw_state)); \ + _sc->fw_state = IPW_FW_IDLE; \ + wakeup(_sc); \ + _sc->sc_state_timer = 0; \ +} while (0) + +/* + * NB.: This models the only instance of async locking in ipw_init_locked + * and must be kept in sync. + */ +#define IPW_LOCK_DECL int __waslocked = 0 +#define IPW_LOCK(sc) do { \ + if (!(__waslocked = mtx_owned(&(sc)->sc_mtx))) \ + mtx_lock(&sc->sc_mtx); \ +} while (0) +#define IPW_UNLOCK(sc) do { \ + if (!__waslocked) \ + mtx_unlock(&sc->sc_mtx); \ +} while (0) +#define IPW_LOCK_ASSERT(sc) mtx_assert(&(sc)->sc_mtx, MA_OWNED) +#define IPW_CMD_LOCK_INIT(sc) do { \ + snprintf((sc)->sc_cmdname, sizeof((sc)->sc_cmdname), "%s_cmd", \ + device_get_nameunit((sc)->sc_dev)); \ + mtx_init(&(sc)->sc_cmdlock, (sc)->sc_cmdname, NULL, MTX_DEF); \ +} while (0) +#define IPW_CMD_LOCK_DESTROY(sc) mtx_destroy(&(sc)->sc_cmdlock) +#define IPW_CMD_LOCK(sc) mtx_lock(&(sc)->sc_cmdlock) +#define IPW_CMD_UNLOCK(sc) mtx_unlock(&(sc)->sc_cmdlock) +
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200707090139.l691d5KA007072>