PERFORCE change 120650 for review

Andrew Thompson thompsa at FreeBSD.org
Thu May 31 08:34:06 UTC 2007


http://perforce.freebsd.org/chv.cgi?CH=120650

Change 120650 by thompsa at thompsa_heff on 2007/05/31 08:33:19

	Add support for scanning all channels at once.

Affected files ...

.. //depot/projects/wifi/sys/dev/iwi/if_iwi.c#33 edit

Differences ...

==== //depot/projects/wifi/sys/dev/iwi/if_iwi.c#33 (text+ko) ====

@@ -162,11 +162,12 @@
 static int	iwi_config(struct iwi_softc *);
 static int	iwi_get_firmware(struct iwi_softc *);
 static void	iwi_put_firmware(struct iwi_softc *);
-static int	iwi_scanchan(struct iwi_softc *, unsigned long);
+static int	iwi_scanchan(struct iwi_softc *, unsigned long, int);
 static void	iwi_scan_start(struct ieee80211com *);
 static void	iwi_scan_end(struct ieee80211com *);
 static void	iwi_set_channel(struct ieee80211com *);
 static void	iwi_scan_curchan(struct ieee80211com *, unsigned long maxdwell);
+static void	iwi_scan_allchan(struct ieee80211com *, unsigned long maxdwell);
 static void	iwi_scan_mindwell(struct ieee80211com *);
 static void     iwi_assoc(struct ieee80211com *ic);
 static void	iwi_ops(void *, int);
@@ -1376,9 +1377,12 @@
 	switch (notif->type) {
 	case IWI_NOTIF_TYPE_SCAN_CHANNEL:
 		chan = (struct iwi_notif_scan_channel *)(notif + 1);
-		
+
 		DPRINTFN(3, ("Scan of channel %u complete (%u)\n",
 		    ic->ic_channels[chan->nchan].ic_freq, chan->nchan));
+
+		/* Reset the timer, the scan is still going */
+		sc->sc_scan_timer = 3;
 		break;
 
 	case IWI_NOTIF_TYPE_SCAN_COMPLETE:
@@ -2654,13 +2658,14 @@
  * Scan on ic_curchan according to ic_scan (essid, active/passive, dwell ...)
  */
 static int
-iwi_scanchan(struct iwi_softc *sc, unsigned long maxdwell)
+iwi_scanchan(struct iwi_softc *sc, unsigned long maxdwell, int mode)
 {
 	struct ieee80211com *ic;
 	struct ieee80211_channel *chan;
 	struct ieee80211_scan_state *ss;
 	struct iwi_scan_ext scan;
 	int error = 0;
+	int i, type;
 
 	IWI_LOCK_CHECK(sc);
 	if (sc->flags & IWI_FLAG_SCANNING) {
@@ -2682,25 +2687,37 @@
 	scan.dwell_time[IWI_SCAN_TYPE_BROADCAST] = htole16(maxdwell);
 	scan.dwell_time[IWI_SCAN_TYPE_BDIRECTED] = htole16(maxdwell);
 
-	if (IEEE80211_IS_CHAN_5GHZ(chan))
-		scan.channels[0] = 1 | IWI_CHAN_5GHZ;
-	else
-		scan.channels[0] = 1 | IWI_CHAN_2GHZ;
-	scan.channels[1] = ieee80211_chan2ieee(ic, chan);
 	/* We can only set one essid for a directed scan */
 	if (ss->ss_nssid != 0) {
-		set_scan_type(&scan, 1, IWI_SCAN_TYPE_BDIRECTED);
+		type = IWI_SCAN_TYPE_BDIRECTED;
 		error = iwi_cmd(sc, IWI_CMD_SET_ESSID, ss->ss_ssid[0].ssid,
 		    ss->ss_ssid[0].len);
 		if (error)
 			return (error);
 	} else if ((ss->ss_flags & IEEE80211_SCAN_ACTIVE) &&
 	    (chan->ic_flags & IEEE80211_CHAN_PASSIVE) == 0) {
-		set_scan_type(&scan, 1, IWI_SCAN_TYPE_BROADCAST);
+		type = IWI_SCAN_TYPE_BROADCAST;
 	} else
-		set_scan_type(&scan, 1, IWI_SCAN_TYPE_PASSIVE);
+		type = IWI_SCAN_TYPE_PASSIVE;
+
+	if (mode == IWI_SCAN_ALLCHAN) {
+		for (i = 0; i < ss->ss_last;) {
+			chan = ss->ss_chans[i];
+			scan.channels[++i] = ieee80211_chan2ieee(ic, chan);
+			set_scan_type(&scan, i, type);
+		}
+	} else {
+		/* Scan the current channel only */
+		i = 1;
+		scan.channels[i] = ieee80211_chan2ieee(ic, chan);
+		set_scan_type(&scan, i, type);
+	}
+	if (IEEE80211_IS_CHAN_5GHZ(chan))
+		scan.channels[0] = i | IWI_CHAN_5GHZ;
+	else
+		scan.channels[0] = i | IWI_CHAN_2GHZ;
 
-	DPRINTF(("Scanning on channel %u\n", ieee80211_chan2ieee(ic, chan)));
+	DPRINTF(("Scanning on %d channel(s)\n", i));
 	sc->flags |= IWI_FLAG_SCANNING;
 	sc->sc_scan_timer = 3;
 	sc->sc_ifp->if_timer = 1;
@@ -3443,13 +3460,14 @@
 			iwi_cmd(sc, IWI_CMD_ABORT_SCAN, NULL, 0);
 		break;
 	case IWI_SCAN_CURCHAN:
+	case IWI_SCAN_ALLCHAN:
 		if (!(sc->flags & IWI_FLAG_CHANNEL_SCAN)) {
 			DPRINTF(("%s: ic_scan_curchan while not scanning\n",
 			    __func__));
 			IWI_UNLOCK(sc);
 			return;
 		}
-		if (iwi_scanchan(sc, sc->sc_maxdwell))
+		if (iwi_scanchan(sc, sc->sc_maxdwell, sc->sc_scanop))
 			ieee80211_cancel_scan(ic);
 
 		break;
@@ -3466,7 +3484,6 @@
 
 	sc->sc_scanop = IWI_SCAN_START;
 	taskqueue_enqueue(sc->sc_tq, &sc->sc_opstask);
-	
 }
 
 static void
@@ -3490,6 +3507,17 @@
 }
 
 static void
+iwi_scan_allchan(struct ieee80211com *ic, unsigned long maxdwell)
+{
+	struct ifnet *ifp = ic->ic_ifp;
+	struct iwi_softc *sc = ifp->if_softc;
+
+	sc->sc_scanop = IWI_SCAN_ALLCHAN;
+	sc->sc_maxdwell = maxdwell;
+	taskqueue_enqueue(sc->sc_tq, &sc->sc_opstask);
+}
+
+static void
 iwi_scan_mindwell(struct ieee80211com *ic)
 {
 	/* NB: don't try to abort scan; wait for firmware to finish */


More information about the p4-projects mailing list