summaryrefslogtreecommitdiffstats
path: root/sys/dev/iwi/if_iwi.c
diff options
context:
space:
mode:
authorbschmidt <bschmidt@FreeBSD.org>2010-10-12 16:52:13 +0000
committerbschmidt <bschmidt@FreeBSD.org>2010-10-12 16:52:13 +0000
commit465ea6bc32a124d7427fba6851b9ff75874ba1ab (patch)
tree45d0dde16d62e8c2ccab6a4ec9e22e1ed58f0609 /sys/dev/iwi/if_iwi.c
parent7817d1d2590ff0e3480b31e63b08d5c21aceedd2 (diff)
downloadFreeBSD-src-465ea6bc32a124d7427fba6851b9ff75874ba1ab.zip
FreeBSD-src-465ea6bc32a124d7427fba6851b9ff75874ba1ab.tar.gz
Fix monitor mode which is implemented by doing a firmware scan. This
is a port of stable/6, seems like the code got lost during the background scan changes in r170530. Pointed out by: danfe MFC after: 2 weeks
Diffstat (limited to 'sys/dev/iwi/if_iwi.c')
-rw-r--r--sys/dev/iwi/if_iwi.c34
1 files changed, 33 insertions, 1 deletions
diff --git a/sys/dev/iwi/if_iwi.c b/sys/dev/iwi/if_iwi.c
index 4b765ef..f5ba34f 100644
--- a/sys/dev/iwi/if_iwi.c
+++ b/sys/dev/iwi/if_iwi.c
@@ -180,6 +180,7 @@ static void iwi_release_fw_dma(struct iwi_softc *sc);
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 void iwi_monitor_scan(void *, int);
static int iwi_scanchan(struct iwi_softc *, unsigned long, int);
static void iwi_scan_start(struct ieee80211com *);
static void iwi_scan_end(struct ieee80211com *);
@@ -292,6 +293,7 @@ iwi_attach(device_t dev)
TASK_INIT(&sc->sc_restarttask, 0, iwi_restart, sc);
TASK_INIT(&sc->sc_disassoctask, 0, iwi_disassoc, sc);
TASK_INIT(&sc->sc_wmetask, 0, iwi_update_wme, sc);
+ TASK_INIT(&sc->sc_monitortask, 0, iwi_monitor_scan, sc);
callout_init_mtx(&sc->sc_wdtimer, &sc->sc_mtx, 0);
callout_init_mtx(&sc->sc_rftimer, &sc->sc_mtx, 0);
@@ -460,6 +462,7 @@ iwi_detach(device_t dev)
ieee80211_draintask(ic, &sc->sc_radiofftask);
ieee80211_draintask(ic, &sc->sc_restarttask);
ieee80211_draintask(ic, &sc->sc_disassoctask);
+ ieee80211_draintask(ic, &sc->sc_monitortask);
iwi_stop(sc);
@@ -988,7 +991,8 @@ iwi_newstate(struct ieee80211vap *vap, enum ieee80211_state nstate, int arg)
* This is all totally bogus and needs to be redone.
*/
iwi_auth_and_assoc(sc, vap);
- }
+ } else if (vap->iv_opmode == IEEE80211_M_MONITOR)
+ ieee80211_runtask(ic, &sc->sc_monitortask);
break;
case IEEE80211_S_ASSOC:
/*
@@ -1407,6 +1411,18 @@ iwi_notification_intr(struct iwi_softc *sc, struct iwi_notif *notif)
IWI_STATE_END(sc, IWI_FW_SCANNING);
+ /*
+ * Monitor mode works by doing a passive scan to set
+ * the channel and enable rx. Because we don't want
+ * to abort a scan lest the firmware crash we scan
+ * for a short period of time and automatically restart
+ * the scan when notified the sweep has completed.
+ */
+ if (vap->iv_opmode == IEEE80211_M_MONITOR) {
+ ieee80211_runtask(ic, &sc->sc_monitortask);
+ break;
+ }
+
if (scan->status == IWI_SCAN_COMPLETED) {
/* NB: don't need to defer, net80211 does it for us */
ieee80211_scan_next(vap);
@@ -2557,6 +2573,11 @@ iwi_config(struct iwi_softc *sc)
config.answer_pbreq = (ic->ic_opmode == IEEE80211_M_IBSS) ? 1 : 0;
config.disable_unicast_decryption = 1;
config.disable_multicast_decryption = 1;
+ if (ic->ic_opmode == IEEE80211_M_MONITOR) {
+ config.allow_invalid_frames = 1;
+ config.allow_beacon_and_probe_resp = 1;
+ config.allow_mgt = 1;
+ }
DPRINTF(("Configuring adapter\n"));
error = iwi_cmd(sc, IWI_CMD_SET_CONFIG, &config, sizeof config);
if (error != 0)
@@ -2642,6 +2663,17 @@ scan_band(const struct ieee80211_channel *c)
return IEEE80211_IS_CHAN_5GHZ(c) ? IWI_CHAN_5GHZ : IWI_CHAN_2GHZ;
}
+static void
+iwi_monitor_scan(void *arg, int npending)
+{
+ struct iwi_softc *sc = arg;
+ IWI_LOCK_DECL;
+
+ IWI_LOCK(sc);
+ (void) iwi_scanchan(sc, 2000, 0);
+ IWI_UNLOCK(sc);
+}
+
/*
* Start a scan on the current channel or all channels.
*/
OpenPOWER on IntegriCloud