Index: if_iwi.c =================================================================== RCS file: /usr/store/mlaier/fcvs/src/sys/dev/iwi/if_iwi.c,v retrieving revision 1.26 diff -u -r1.26 if_iwi.c --- if_iwi.c 20 Nov 2005 16:02:04 -0000 1.26 +++ if_iwi.c 7 Jan 2006 18:46:16 -0000 @@ -150,6 +150,7 @@ static int iwi_scan(struct iwi_softc *); static int iwi_auth_and_assoc(struct iwi_softc *); static void iwi_init(void *); +static void iwi_init_locked(void *); static void iwi_stop(void *); static int iwi_read_firmware(const char *, caddr_t *, size_t *); static int iwi_sysctl_stats(SYSCTL_HANDLER_ARGS); @@ -881,7 +882,7 @@ } if ((ifp->if_flags & IFF_UP) && (ifp->if_drv_flags & IFF_DRV_RUNNING)) - iwi_init(sc); + iwi_init_locked(sc); IWI_UNLOCK(sc); @@ -1773,7 +1774,7 @@ case SIOCSIFFLAGS: if (ifp->if_flags & IFF_UP) { if (!(ifp->if_drv_flags & IFF_DRV_RUNNING)) - iwi_init(sc); + iwi_init_locked(sc); } else { if (ifp->if_drv_flags & IFF_DRV_RUNNING) iwi_stop(sc); @@ -1788,7 +1789,7 @@ if ((ifp->if_flags & IFF_UP) && (ifp->if_drv_flags & IFF_DRV_RUNNING) && (ic->ic_roaming != IEEE80211_ROAMING_MANUAL)) - iwi_init(sc); + iwi_init_locked(sc); error = 0; } @@ -2255,10 +2256,12 @@ struct ieee80211com *ic = &sc->sc_ic; struct iwi_scan scan; uint8_t *p; - int i, count; + int i, count, do_5ghz_scan = 0; - memset(&scan, 0, sizeof scan); + sc->scan_counter++; + sc->flags |= IWI_FLAG_SCANNING; + bzero(&scan, sizeof(scan)); if (ic->ic_des_esslen != 0) { scan.bdirected = htole16(sc->dwelltime); memset(scan.type, IWI_SCAN_TYPE_BDIRECTED, sizeof scan.type); @@ -2268,25 +2271,40 @@ } p = scan.channels; - count = 0; - for (i = 0; i <= IEEE80211_CHAN_MAX; i++) { - if (IEEE80211_IS_CHAN_5GHZ(&ic->ic_channels[i]) && - isset(ic->ic_chan_active, i)) { - *++p = i; - count++; - } + /* + * If we have .11a capable adapter, and + * - we are in .11a mode, or + * - we are in auto mode and this is an odd numbered scan + * then do a 5GHz scan, otherwise do a 2GHz scan. + */ + if ( ic->ic_sup_rates[IEEE80211_MODE_11A].rs_nrates > 0 ) { + if (( ic->ic_curmode == IEEE80211_MODE_11A ) || + (( ic->ic_curmode == IEEE80211_MODE_AUTO ) && + ( sc->scan_counter & 1))) + do_5ghz_scan = 1; } - *(p - count) = IWI_CHAN_5GHZ | count; - count = 0; - for (i = 0; i <= IEEE80211_CHAN_MAX; i++) { - if (IEEE80211_IS_CHAN_2GHZ(&ic->ic_channels[i]) && - isset(ic->ic_chan_active, i)) { - *++p = i; - count++; + if ( do_5ghz_scan ) { + DPRINTF(("Scanning 5GHz band\n")); + for (i = 0; i <= IEEE80211_CHAN_MAX; i++) { + if (IEEE80211_IS_CHAN_5GHZ(&ic->ic_channels[i]) && + isset(ic->ic_chan_active, i)) { + *++p = i; + count++; + } + } + *(p - count) = IWI_CHAN_5GHZ | count; + } else { + DPRINTF(("Scanning 2GHz band\n")); + for (i = 0; i <= IEEE80211_CHAN_MAX; i++) { + if (IEEE80211_IS_CHAN_2GHZ(&ic->ic_channels[i]) && + isset(ic->ic_chan_active, i)) { + *++p = i; + count++; + } } + *(p - count) = IWI_CHAN_2GHZ | count; } - *(p - count) = IWI_CHAN_2GHZ | count; DPRINTF(("Start scanning\n")); return iwi_cmd(sc, IWI_CMD_SCAN, &scan, sizeof scan, 1); @@ -2418,6 +2436,16 @@ iwi_init(void *priv) { struct iwi_softc *sc = priv; + + IWI_LOCK(sc); + iwi_init_locked(sc); + IWI_UNLOCK(sc); +} + +static void +iwi_init_locked(void *priv) +{ + struct iwi_softc *sc = priv; struct ieee80211com *ic = &sc->sc_ic; struct ifnet *ifp = ic->ic_ifp; struct iwi_rx_data *data; Index: if_iwivar.h =================================================================== RCS file: /usr/store/mlaier/fcvs/src/sys/dev/iwi/if_iwivar.h,v retrieving revision 1.8 diff -u -r1.8 if_iwivar.h --- if_iwivar.h 19 Nov 2005 16:54:55 -0000 1.8 +++ if_iwivar.h 7 Jan 2006 18:46:16 -0000 @@ -118,6 +118,7 @@ struct mtx sc_mtx; struct unrhdr *sc_unr; + uint32_t scan_counter; uint32_t flags; #define IWI_FLAG_FW_INITED (1 << 0) #define IWI_FLAG_SCANNING (1 << 1)