PERFORCE change 112679 for review
Kip Macy
kmacy at FreeBSD.org
Sun Jan 7 23:02:03 PST 2007
http://perforce.freebsd.org/chv.cgi?CH=112679
Change 112679 by kmacy at 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 <net80211/ieee80211_var.h>
#include <net80211/ieee80211_radiotap.h>
+#include <net80211/ieee80211_regdomain.h>
+
#include <netinet/in.h>
#include <netinet/in_systm.h>
@@ -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);
+}
More information about the p4-projects
mailing list