From owner-p4-projects@FreeBSD.ORG Mon Jan 8 07:02:03 2007 Return-Path: X-Original-To: p4-projects@freebsd.org Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id 00E5216A412; Mon, 8 Jan 2007 07:02:03 +0000 (UTC) X-Original-To: perforce@freebsd.org Delivered-To: perforce@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id A7F4D16A403 for ; Mon, 8 Jan 2007 07:02:02 +0000 (UTC) (envelope-from kmacy@freebsd.org) Received: from repoman.freebsd.org (repoman.freebsd.org [69.147.83.41]) by mx1.freebsd.org (Postfix) with ESMTP id 9946713C457 for ; Mon, 8 Jan 2007 07:02:02 +0000 (UTC) (envelope-from kmacy@freebsd.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.13.6/8.13.6) with ESMTP id l08722g9013415 for ; Mon, 8 Jan 2007 07:02:02 GMT (envelope-from kmacy@freebsd.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.13.6/8.13.4/Submit) id l08722VL013412 for perforce@freebsd.org; Mon, 8 Jan 2007 07:02:02 GMT (envelope-from kmacy@freebsd.org) Date: Mon, 8 Jan 2007 07:02:02 GMT Message-Id: <200701080702.l08722VL013412@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to kmacy@freebsd.org using -f From: Kip Macy To: Perforce Change Reviews Cc: Subject: PERFORCE change 112679 for review X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 08 Jan 2007 07:02:03 -0000 http://perforce.freebsd.org/chv.cgi?CH=112679 Change 112679 by kmacy@kmacy_storage:sam_wifi on 2007/01/08 07:01:15 add basic scanning operations Affected files ... .. //depot/projects/wifi/sys/dev/wpi/if_wpi.c#3 edit Differences ... ==== //depot/projects/wifi/sys/dev/wpi/if_wpi.c#3 (text+ko) ==== @@ -63,6 +63,8 @@ #include #include +#include + #include #include @@ -167,6 +169,11 @@ struct wpi_tx_desc *); static void wpi_firmware_mem_free(struct wpi_softc *, char *, bus_dma_tag_t, bus_dmamap_t map); +static void wpi_scan_start(struct ieee80211com *); +static void wpi_scan_end(struct ieee80211com *); +static void wpi_set_channel(struct ieee80211com *); +static void wpi_ops(void *arg, int npending); + static int wpi_probe(device_t); static int wpi_attach(device_t); static int wpi_detach(device_t); @@ -307,7 +314,7 @@ struct wpi_softc *sc = device_get_softc(dev); struct ifnet *ifp; struct ieee80211com *ic = &sc->sc_ic; - int ac, error, i; + int ac, error, bands; sc->sc_dev = dev; @@ -315,6 +322,12 @@ MTX_DEF | MTX_RECURSE); callout_init(&sc->amrr_ch, 0); + sc->sc_tq = taskqueue_create("wpi_taskq", M_NOWAIT | M_ZERO, + taskqueue_thread_enqueue, &sc->sc_tq); + taskqueue_start_threads(&sc->sc_tq, 1, PI_NET, "%s taskq", + device_get_nameunit(dev)); + TASK_INIT(&sc->sc_opstask, 0, wpi_ops, sc); + if (pci_get_powerstate(dev) != PCI_POWERSTATE_D0) { device_printf(dev, "chip is in D%d power mode " "-- setting to D0\n", pci_get_powerstate(dev)); @@ -402,6 +415,11 @@ ic->ic_opmode = IEEE80211_M_STA; /* default to BSS mode */ ic->ic_state = IEEE80211_S_INIT; + ic->ic_scan_start = wpi_scan_start; + ic->ic_scan_end = wpi_scan_end; + ic->ic_set_channel = wpi_set_channel; + + /* set device capabilities */ ic->ic_caps = IEEE80211_C_IBSS | /* IBSS mode support */ @@ -414,38 +432,12 @@ wpi_read_eeprom(sc); - /* set supported .11a rates */ - ic->ic_sup_rates[IEEE80211_MODE_11A] = wpi_rateset_11a; + bands = 0; + setbit(&bands, IEEE80211_MODE_11B); + setbit(&bands, IEEE80211_MODE_11G); + setbit(&bands, IEEE80211_MODE_11A); - /* set supported .11a channels */ - for (i = 36; i <= 64; i += 4) { - ic->ic_channels[i].ic_freq = - ieee80211_ieee2mhz(i, IEEE80211_CHAN_5GHZ); - ic->ic_channels[i].ic_flags = IEEE80211_CHAN_A; - } - for (i = 100; i <= 140; i += 4) { - ic->ic_channels[i].ic_freq = - ieee80211_ieee2mhz(i, IEEE80211_CHAN_5GHZ); - ic->ic_channels[i].ic_flags = IEEE80211_CHAN_A; - } - for (i = 149; i <= 165; i += 4) { - ic->ic_channels[i].ic_freq = - ieee80211_ieee2mhz(i, IEEE80211_CHAN_5GHZ); - ic->ic_channels[i].ic_flags = IEEE80211_CHAN_A; - } - - /* set supported .11b and .11g rates */ - ic->ic_sup_rates[IEEE80211_MODE_11B] = wpi_rateset_11b; - ic->ic_sup_rates[IEEE80211_MODE_11G] = wpi_rateset_11g; - - /* set supported .11b and .11g channels (1 through 14) */ - for (i = 1; i <= 14; i++) { - ic->ic_channels[i].ic_freq = - ieee80211_ieee2mhz(i, IEEE80211_CHAN_2GHZ); - ic->ic_channels[i].ic_flags = - IEEE80211_CHAN_CCK | IEEE80211_CHAN_OFDM | - IEEE80211_CHAN_DYN | IEEE80211_CHAN_2GHZ; - } + ieee80211_init_channels(ic, 0, CTRY_DEFAULT, bands, 0, 1); if_initname(ifp, device_get_name(dev), device_get_unit(dev)); ifp->if_softc = sc; @@ -489,7 +481,6 @@ /* * Hook our interrupt after all initialization is complete. -| INTR_MPSAFE, */ error = bus_setup_intr(dev, sc->irq, INTR_TYPE_NET|INTR_MPSAFE , wpi_intr, sc, &sc->sc_ih); @@ -545,6 +536,8 @@ bus_release_resource(dev, SYS_RES_IRQ, sc->irq_rid, sc->irq); bus_release_resource(dev, SYS_RES_MEMORY, sc->mem_rid, sc->mem); + taskqueue_free(sc->sc_tq); + if_free(ifp); mtx_destroy(&sc->sc_mtx); @@ -2951,3 +2944,52 @@ i--); ni->ni_txrate = i; } + +static void +wpi_scan_start(struct ieee80211com *ic) +{ + struct ifnet *ifp = ic->ic_ifp; + struct wpi_softc *sc = ifp->if_softc; + + printf("start scan\n"); + sc->sc_scanop = WPI_SCAN_START; + taskqueue_enqueue(sc->sc_tq, &sc->sc_opstask); +} + +static void +wpi_scan_end(struct ieee80211com *ic) +{ + /* ??? */ +} + +static void +wpi_set_channel(struct ieee80211com *ic) +{ + /* ??? */ +} + +static void +wpi_ops(void *arg, int npending) +{ + struct wpi_softc *sc = arg; + struct ieee80211com *ic = &sc->sc_ic; + + WPI_LOCK(sc); + while ((ic->ic_state != IEEE80211_S_INIT) && + (sc->sc_flags & WPI_FLAG_BUSY)) { + msleep(sc, &sc->sc_mtx, 0, "wpicmd", hz/10); + } + + if (ic->ic_state == IEEE80211_S_INIT) + goto done; + + switch (sc->sc_scanop) { + + case WPI_SCAN_START: + + wpi_scan(sc, IEEE80211_CHAN_G); + break; + } +done: + WPI_UNLOCK(sc); +}