Date: Sun, 6 Apr 2008 22:51:56 GMT From: Sam Leffler <sam@FreeBSD.org> To: Perforce Change Reviews <perforce@freebsd.org> Subject: PERFORCE change 139481 for review Message-ID: <200804062251.m36MpuSi031756@repoman.freebsd.org>
next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=139481 Change 139481 by sam@sam_ebb on 2008/04/06 22:51:46 Shuffle some more code to make the firmware happy: o configuring the adapter cannot be done on each entry to the SCAN state; we must enable the adapter only once after loading firmware so strip down iwi_config to just setup parameters that are vap-independent and call it from iwi_init o move work that used to be done in iwi_config to iwi_auth_and_assoc where it makes more sense (and we have a vap as parameters like rtsthreshold are vap-specific) o change DISASSOC request issues on RUN->INIT state change to also send a frame to the AP o add debug msg to iwi_ops to see the deferred ops being run o widen the cmd arg to unsigned long so we can pass maxdwell using it instead of having a special sc_maxdwell mechanism o change IWI_* defs to integers instead of bits; can't see a reason why they were as they were and having them small values means we can setup an array of strings to debugging I can now roam between wpa-enabled ap's. Affected files ... .. //depot/projects/vap/sys/dev/iwi/if_iwi.c#19 edit .. //depot/projects/vap/sys/dev/iwi/if_iwivar.h#12 edit Differences ... ==== //depot/projects/vap/sys/dev/iwi/if_iwi.c#19 (text+ko) ==== @@ -180,7 +180,7 @@ static int iwi_load_ucode(struct iwi_softc *, const struct iwi_fw *); static int iwi_load_firmware(struct iwi_softc *, const struct iwi_fw *); static void iwi_release_fw_dma(struct iwi_softc *sc); -static int iwi_config(struct iwi_softc *, struct ieee80211vap *); +static int iwi_config(struct iwi_softc *); static int iwi_get_firmware(struct iwi_softc *, enum ieee80211_opmode); static void iwi_put_firmware(struct iwi_softc *); static int iwi_scanchan(struct iwi_softc *, unsigned long, int); @@ -194,7 +194,7 @@ #endif static void iwi_scan_mindwell(struct ieee80211_scan_state *); static void iwi_ops(void *, int); -static int iwi_queue_cmd(struct iwi_softc *, int, int); +static int iwi_queue_cmd(struct iwi_softc *, int, unsigned long); static int iwi_auth_and_assoc(struct iwi_softc *, struct ieee80211vap *); static int iwi_disassociate(struct iwi_softc *, int quiet); static void iwi_init(void *); @@ -1001,14 +1001,9 @@ */ if (vap->iv_state == IEEE80211_S_RUN && (sc->flags & IWI_FLAG_FW_INITED)) - iwi_queue_cmd(sc, IWI_DISASSOC, 0); + iwi_queue_cmd(sc, IWI_DISASSOC, 1); IWI_UNLOCK(sc); break; - case IEEE80211_S_SCAN: - if (vap->iv_state != IEEE80211_S_INIT) - break; - iwi_queue_cmd(sc, IWI_CONFIG, 0); - return EINPROGRESS; case IEEE80211_S_AUTH: iwi_queue_cmd(sc, IWI_AUTH, arg); return EINPROGRESS; @@ -2575,7 +2570,7 @@ } static int -iwi_config(struct iwi_softc *sc, struct ieee80211vap *vap) +iwi_config(struct iwi_softc *sc) { struct ifnet *ifp = sc->sc_ifp; struct ieee80211com *ic = ifp->if_l2com; @@ -2587,9 +2582,9 @@ IWI_LOCK_ASSERT(sc); - IEEE80211_ADDR_COPY(vap->iv_myaddr, IF_LLADDR(ifp)); - DPRINTF(("Setting MAC address to %6D\n", vap->iv_myaddr, ":")); - error = iwi_cmd(sc, IWI_CMD_SET_MAC_ADDRESS, vap->iv_myaddr, + IEEE80211_ADDR_COPY(ic->ic_myaddr, IF_LLADDR(ifp)); + DPRINTF(("Setting MAC address to %6D\n", ic->ic_myaddr, ":")); + error = iwi_cmd(sc, IWI_CMD_SET_MAC_ADDRESS, ic->ic_myaddr, IEEE80211_ADDR_LEN); if (error != 0) return error; @@ -2599,31 +2594,14 @@ config.silence_threshold = 0x1e; config.antenna = sc->antenna; config.multicast_enabled = 1; - config.answer_pbreq = (vap->iv_opmode == IEEE80211_M_IBSS) ? 1 : 0; + config.answer_pbreq = (ic->ic_opmode == IEEE80211_M_IBSS) ? 1 : 0; config.disable_unicast_decryption = 1; config.disable_multicast_decryption = 1; DPRINTF(("Configuring adapter\n")); error = iwi_cmd(sc, IWI_CMD_SET_CONFIG, &config, sizeof config); if (error != 0) return error; - - error = iwi_setpowermode(sc, vap); - if (error != 0) - return error; - - data = htole32(vap->iv_rtsthreshold); - DPRINTF(("Setting RTS threshold to %u\n", le32toh(data))); - error = iwi_cmd(sc, IWI_CMD_SET_RTS_THRESHOLD, &data, sizeof data); - if (error != 0) - return error; - - data = htole32(vap->iv_fragthreshold); - DPRINTF(("Setting fragmentation threshold to %u\n", le32toh(data))); - error = iwi_cmd(sc, IWI_CMD_SET_FRAG_THRESHOLD, &data, sizeof data); - if (error != 0) - return error; - - if (vap->iv_opmode == IEEE80211_M_IBSS) { + if (ic->ic_opmode == IEEE80211_M_IBSS) { power.mode = IWI_MODE_11B; power.nchan = 11; for (i = 0; i < 11; i++) { @@ -2664,32 +2642,12 @@ if (error != 0) return error; - /* if we have a desired ESSID, set it now */ - if (vap->iv_des_ssid[0].len != 0) { -#ifdef IWI_DEBUG - if (iwi_debug > 0) { - printf("Setting desired ESSID to "); - ieee80211_print_essid(vap->iv_des_ssid[0].ssid, - vap->iv_des_ssid[0].len); - printf("\n"); - } -#endif - error = iwi_cmd(sc, IWI_CMD_SET_ESSID, vap->iv_des_ssid[0].ssid, - vap->iv_des_ssid[0].len); - if (error != 0) - return error; - } - data = htole32(arc4random()); DPRINTF(("Setting initialization vector to %u\n", le32toh(data))); error = iwi_cmd(sc, IWI_CMD_SET_IV, &data, sizeof data); if (error != 0) return error; - error = iwi_setwepkeys(sc, vap); - if (error != 0) - return error; - /* enable adapter */ DPRINTF(("Enabling adapter\n")); return iwi_cmd(sc, IWI_CMD_ENABLE, NULL, 0); @@ -2880,6 +2838,7 @@ struct iwi_associate *assoc = &sc->assoc; struct iwi_rateset rs; uint16_t capinfo; + uint32_t data; int error, mode; IWI_LOCK_ASSERT(sc); @@ -2928,6 +2887,22 @@ if (error != 0) goto done; + error = iwi_setpowermode(sc, vap); + if (error != 0) + goto done; + + data = htole32(vap->iv_rtsthreshold); + DPRINTF(("Setting RTS threshold to %u\n", le32toh(data))); + error = iwi_cmd(sc, IWI_CMD_SET_RTS_THRESHOLD, &data, sizeof data); + if (error != 0) + goto done; + + data = htole32(vap->iv_fragthreshold); + DPRINTF(("Setting fragmentation threshold to %u\n", le32toh(data))); + error = iwi_cmd(sc, IWI_CMD_SET_FRAG_THRESHOLD, &data, sizeof data); + if (error != 0) + goto done; + /* the rate set has already been "negotiated" */ memset(&rs, 0, sizeof rs); rs.mode = mode; @@ -3190,18 +3165,24 @@ } sc->flags |= IWI_FLAG_FW_INITED; + IWI_STATE_END(sc, IWI_FW_LOADING); + + if (iwi_config(sc) != 0) { + device_printf(sc->sc_dev, "unable to enable adapter\n"); + goto fail2; + } + callout_reset(&sc->sc_wdtimer, hz, iwi_watchdog, sc); ifp->if_drv_flags &= ~IFF_DRV_OACTIVE; ifp->if_drv_flags |= IFF_DRV_RUNNING; - IWI_STATE_END(sc, IWI_FW_LOADING); - IWI_UNLOCK(sc); ieee80211_start_all(ic); /* start all vap's */ return; fail: IWI_STATE_END(sc, IWI_FW_LOADING); +fail2: iwi_stop_locked(sc); IWI_UNLOCK(sc); } @@ -3545,23 +3526,35 @@ static void iwi_ops(void *arg0, int npending) { + static const char *opnames[] = { + [IWI_CMD_FREE] = "FREE", + [IWI_SCAN_START] = "SCAN_START", + [IWI_SET_CHANNEL] = "SET_CHANNEL", + [IWI_AUTH] = "AUTH", + [IWI_ASSOC] = "ASSOC", + [IWI_DISASSOC] = "DISASSOC", + [IWI_SCAN_CURCHAN] = "SCAN_CURCHAN", + [IWI_SCAN_ALLCHAN] = "SCAN_ALLCHAN", + [IWI_SET_WME] = "SET_WME", + }; struct iwi_softc *sc = arg0; struct ifnet *ifp = sc->sc_ifp; struct ieee80211com *ic = ifp->if_l2com; struct ieee80211vap *vap = TAILQ_FIRST(&ic->ic_vaps); IWI_LOCK_DECL; - int cmd, arg; + int cmd; + unsigned long arg; again: IWI_CMD_LOCK(sc); cmd = sc->sc_cmd[sc->sc_cmd_cur]; - if (cmd == 0) { + if (cmd == IWI_CMD_FREE) { /* No more commands to process */ IWI_CMD_UNLOCK(sc); return; } - arg = sc->sc_cmd[sc->sc_cmd_cur]; - sc->sc_cmd[sc->sc_cmd_cur] = 0; /* free the slot */ + arg = sc->sc_arg[sc->sc_cmd_cur]; + sc->sc_cmd[sc->sc_cmd_cur] = IWI_CMD_FREE; /* free the slot */ sc->sc_cmd_cur = (sc->sc_cmd_cur + 1) % IWI_CMD_MAXOPS; IWI_CMD_UNLOCK(sc); @@ -3575,17 +3568,8 @@ return; } + DPRINTF(("%s: %s arg %lu\n", __func__, opnames[cmd], arg)); switch (cmd) { - case IWI_CONFIG: - iwi_config(sc, vap); - IWI_UNLOCK(sc); - IEEE80211_LOCK(ic); - IWI_VAP(vap)->iwi_newstate(vap, IEEE80211_S_SCAN, arg); - if (vap->iv_newstate_cb != NULL) - vap->iv_newstate_cb(vap, IEEE80211_S_SCAN, arg); - IEEE80211_UNLOCK(ic); - IWI_LOCK(sc); - break; case IWI_AUTH: case IWI_ASSOC: if (cmd == IWI_AUTH) @@ -3612,7 +3596,7 @@ __func__)); goto done; } - if (iwi_scanchan(sc, sc->sc_maxdwell, cmd)) + if (iwi_scanchan(sc, arg, cmd)) ieee80211_cancel_scan(vap); break; } @@ -3624,7 +3608,7 @@ } static int -iwi_queue_cmd(struct iwi_softc *sc, int cmd, int arg) +iwi_queue_cmd(struct iwi_softc *sc, int cmd, unsigned long arg) { IWI_CMD_LOCK(sc); if (sc->sc_cmd[sc->sc_cmd_next] != 0) { @@ -3666,8 +3650,7 @@ struct ifnet *ifp = vap->iv_ic->ic_ifp; struct iwi_softc *sc = ifp->if_softc; - sc->sc_maxdwell = maxdwell; - iwi_queue_cmd(sc, IWI_SCAN_CURCHAN, 0); + iwi_queue_cmd(sc, IWI_SCAN_CURCHAN, maxdwell); } #if 0 @@ -3677,8 +3660,7 @@ struct ifnet *ifp = ic->ic_ifp; struct iwi_softc *sc = ifp->if_softc; - sc->sc_maxdwell = maxdwell; - iwi_queue_cmd(sc, IWI_SCAN_ALLCHAN, 0); + iwi_queue_cmd(sc, IWI_SCAN_ALLCHAN, maxdwell); } #endif ==== //depot/projects/vap/sys/dev/iwi/if_iwivar.h#12 (text+ko) ==== @@ -220,22 +220,20 @@ int sc_state_timer; /* firmware state timer */ int sc_busy_timer; /* firmware cmd timer */ -#define IWI_SCAN_START (1 << 0) -#define IWI_SET_CHANNEL (1 << 1) -#define IWI_SCAN_END (1 << 2) -#define IWI_CONFIG (1 << 3) -#define IWI_AUTH (1 << 4) -#define IWI_ASSOC (1 << 5) -#define IWI_DISASSOC (1 << 6) -#define IWI_SCAN_CURCHAN (1 << 7) -#define IWI_SCAN_ALLCHAN (1 << 8) -#define IWI_SET_WME (1 << 9) #define IWI_CMD_MAXOPS 10 int sc_cmd[IWI_CMD_MAXOPS]; - int sc_arg[IWI_CMD_MAXOPS]; + unsigned long sc_arg[IWI_CMD_MAXOPS]; int sc_cmd_cur; /* current queued scan task */ int sc_cmd_next; /* last queued scan task */ - unsigned long sc_maxdwell; /* max dwell time for curchan */ +#define IWI_CMD_FREE 0 /* for marking slots unused */ +#define IWI_SCAN_START 1 +#define IWI_SET_CHANNEL 2 +#define IWI_AUTH 3 +#define IWI_ASSOC 4 +#define IWI_DISASSOC 5 +#define IWI_SCAN_CURCHAN 6 +#define IWI_SCAN_ALLCHAN 7 +#define IWI_SET_WME 8 struct iwi_rx_radiotap_header sc_rxtap; int sc_rxtap_len;
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200804062251.m36MpuSi031756>