From owner-svn-src-stable-7@FreeBSD.ORG Tue Oct 26 17:31:46 2010 Return-Path: Delivered-To: svn-src-stable-7@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id BBE1B106566B; Tue, 26 Oct 2010 17:31:46 +0000 (UTC) (envelope-from bschmidt@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id A9F848FC0A; Tue, 26 Oct 2010 17:31:46 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id o9QHVkbJ057632; Tue, 26 Oct 2010 17:31:46 GMT (envelope-from bschmidt@svn.freebsd.org) Received: (from bschmidt@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id o9QHVk5W057629; Tue, 26 Oct 2010 17:31:46 GMT (envelope-from bschmidt@svn.freebsd.org) Message-Id: <201010261731.o9QHVk5W057629@svn.freebsd.org> From: Bernhard Schmidt Date: Tue, 26 Oct 2010 17:31:46 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-7@freebsd.org X-SVN-Group: stable-7 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r214383 - stable/7/sys/dev/iwi X-BeenThere: svn-src-stable-7@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 7-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 26 Oct 2010 17:31:46 -0000 Author: bschmidt Date: Tue Oct 26 17:31:46 2010 New Revision: 214383 URL: http://svn.freebsd.org/changeset/base/214383 Log: MFC r213729: Fix monitor mode which is implemented by doing a firmware scan. This is a port from stable/6, seems like the code got lost during the background scan changes in r170530. Modified: stable/7/sys/dev/iwi/if_iwi.c stable/7/sys/dev/iwi/if_iwivar.h Directory Properties: stable/7/sys/ (props changed) stable/7/sys/cddl/contrib/opensolaris/ (props changed) stable/7/sys/contrib/dev/acpica/ (props changed) stable/7/sys/contrib/pf/ (props changed) Modified: stable/7/sys/dev/iwi/if_iwi.c ============================================================================== --- stable/7/sys/dev/iwi/if_iwi.c Tue Oct 26 17:30:34 2010 (r214382) +++ stable/7/sys/dev/iwi/if_iwi.c Tue Oct 26 17:31:46 2010 (r214383) @@ -163,6 +163,7 @@ static void iwi_release_fw_dma(struct iw static int iwi_config(struct iwi_softc *); static int iwi_get_firmware(struct iwi_softc *); 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 *); @@ -291,6 +292,7 @@ iwi_attach(device_t dev) TASK_INIT(&sc->sc_restarttask, 0, iwi_restart, sc); TASK_INIT(&sc->sc_opstask, 0, iwi_ops, sc); TASK_INIT(&sc->sc_scanaborttask, 0, iwi_scanabort, sc); + TASK_INIT(&sc->sc_monitortask, 0, iwi_monitor_scan, sc); callout_init_mtx(&sc->sc_wdtimer, &sc->sc_mtx, 0); if (pci_get_powerstate(dev) != PCI_POWERSTATE_D0) { @@ -978,7 +980,8 @@ iwi_newstate(struct ieee80211com *ic, en */ if (ic->ic_state == IEEE80211_S_SCAN) iwi_assoc(ic); - } + } else if (ic->ic_opmode == IEEE80211_M_MONITOR) + taskqueue_enqueue(sc->sc_tq, &sc->sc_monitortask); break; case IEEE80211_S_INIT: /* @@ -1411,6 +1414,18 @@ iwi_notification_intr(struct iwi_softc * 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 (ic->ic_opmode == IEEE80211_M_MONITOR) { + taskqueue_enqueue(sc->sc_tq, &sc->sc_monitortask); + break; + } + if (scan->status == IWI_SCAN_COMPLETED) ieee80211_scan_next(ic); @@ -2595,6 +2610,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) @@ -2717,6 +2737,17 @@ scan_band(const struct ieee80211_channel 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. */ Modified: stable/7/sys/dev/iwi/if_iwivar.h ============================================================================== --- stable/7/sys/dev/iwi/if_iwivar.h Tue Oct 26 17:30:34 2010 (r214382) +++ stable/7/sys/dev/iwi/if_iwivar.h Tue Oct 26 17:31:46 2010 (r214383) @@ -193,6 +193,7 @@ struct iwi_softc { struct task sc_scanaborttask; /* cancel active scan */ struct task sc_restarttask; /* restart adapter processing */ struct task sc_opstask; /* scan / auth processing */ + struct task sc_monitortask; unsigned int sc_softled : 1, /* enable LED gpio status */ sc_ledstate: 1, /* LED on/off state */