aboutsummaryrefslogtreecommitdiff
path: root/sys/dev/wi/if_wi.c
diff options
context:
space:
mode:
authorAndrew Thompson <thompsa@FreeBSD.org>2009-05-02 15:14:18 +0000
committerAndrew Thompson <thompsa@FreeBSD.org>2009-05-02 15:14:18 +0000
commit5efea30f039c48ddcdddc0d12150b656f4a2e7b8 (patch)
tree46c2c9933cb1753f24ffd7c0096b2ba9074180d2 /sys/dev/wi/if_wi.c
parenta40d9024df6cc7c8d3ca9ebce79a28840f890251 (diff)
Create a taskqueue for each wireless interface which provides a serialised
sleepable context for net80211 driver callbacks. This removes the need for USB and firmware based drivers to roll their own code to defer the chip programming for state changes, scan requests, channel changes and mcast/promisc updates. When a driver callback completes the hardware state is now guaranteed to have been updated and is in sync with net80211 layer. This nukes around 1300 lines of code from the wireless device drivers making them more readable and less race prone. The net80211 layer has been updated as follows - all state/channel changes are serialised on the taskqueue. - ieee80211_new_state() always queues and can now be called from any context - scanning runs from a single taskq function and executes to completion. driver callbacks are synchronous so the channel, phy mode and rx filters are guaranteed to be set in hardware before probe request frames are transmitted. Help and contributions from Sam Leffler. Reviewed by: sam
Notes
Notes: svn path=/head/; revision=191746
Diffstat (limited to 'sys/dev/wi/if_wi.c')
-rw-r--r--sys/dev/wi/if_wi.c72
1 files changed, 13 insertions, 59 deletions
diff --git a/sys/dev/wi/if_wi.c b/sys/dev/wi/if_wi.c
index a4a74e4bf1c8..3dce8471b632 100644
--- a/sys/dev/wi/if_wi.c
+++ b/sys/dev/wi/if_wi.c
@@ -78,7 +78,6 @@ __FBSDID("$FreeBSD$");
#include <sys/random.h>
#include <sys/syslog.h>
#include <sys/sysctl.h>
-#include <sys/taskqueue.h>
#include <machine/bus.h>
#include <machine/resource.h>
@@ -134,10 +133,6 @@ static void wi_rx_intr(struct wi_softc *);
static void wi_tx_intr(struct wi_softc *);
static void wi_tx_ex_intr(struct wi_softc *);
-static void wi_status_connected(void *, int);
-static void wi_status_disconnected(void *, int);
-static void wi_status_oor(void *, int);
-static void wi_status_assoc_failed(void *, int);
static void wi_info_intr(struct wi_softc *);
static int wi_write_txrate(struct wi_softc *, struct ieee80211vap *);
@@ -451,7 +446,6 @@ wi_attach(device_t dev)
}
sc->sc_portnum = WI_DEFAULT_PORT;
- TASK_INIT(&sc->sc_oor_task, 0, wi_status_oor, ic);
ieee80211_ifattach(ic, macaddr);
ic->ic_raw_xmit = wi_raw_xmit;
@@ -574,10 +568,6 @@ wi_vap_create(struct ieee80211com *ic,
break;
}
- TASK_INIT(&wvp->wv_connected_task, 0, wi_status_connected, vap);
- TASK_INIT(&wvp->wv_disconnected_task, 0, wi_status_disconnected, vap);
- TASK_INIT(&wvp->wv_assoc_failed_task, 0, wi_status_assoc_failed, vap);
-
/* complete setup */
ieee80211_vap_attach(vap, ieee80211_media_change, wi_media_status);
ic->ic_opmode = opmode;
@@ -902,7 +892,7 @@ wi_newstate_sta(struct ieee80211vap *vap, enum ieee80211_state nstate, int arg)
* notification we get on association.
*/
vap->iv_state = nstate;
- return EINPROGRESS;
+ return (0);
}
return WI_VAP(vap)->wv_newstate(vap, nstate, arg);
}
@@ -1512,55 +1502,12 @@ wi_tx_intr(struct wi_softc *sc)
}
}
-static void
-wi_status_connected(void *arg, int pending)
-{
- struct ieee80211vap *vap = arg;
- struct ieee80211com *ic = vap->iv_ic;
-
- IEEE80211_LOCK(ic);
- vap->iv_bss->ni_associd = 1 | 0xc000; /* NB: anything will do */
- WI_VAP(vap)->wv_newstate(vap, IEEE80211_S_RUN, 0);
- if (vap->iv_newstate_cb != NULL)
- vap->iv_newstate_cb(vap, IEEE80211_S_RUN, 0);
- IEEE80211_UNLOCK(ic);
-}
-
-static void
-wi_status_disconnected(void *arg, int pending)
-{
- struct ieee80211vap *vap = arg;
-
- if (vap->iv_state == IEEE80211_S_RUN) {
- vap->iv_bss->ni_associd = 0;
- vap->iv_stats.is_rx_deauth++;
- ieee80211_new_state(vap, IEEE80211_S_SCAN, 0);
- }
-}
-
-static void
-wi_status_oor(void *arg, int pending)
-{
- struct ieee80211com *ic = arg;
-
- ieee80211_beacon_miss(ic);
-}
-
-static void
-wi_status_assoc_failed(void *arg, int pending)
-{
- struct ieee80211vap *vap = arg;
-
- ieee80211_new_state(vap, IEEE80211_S_SCAN, IEEE80211_SCAN_FAIL_TIMEOUT);
-}
-
static __noinline void
wi_info_intr(struct wi_softc *sc)
{
struct ifnet *ifp = sc->sc_ifp;
struct ieee80211com *ic = ifp->if_l2com;
struct ieee80211vap *vap = TAILQ_FIRST(&ic->ic_vaps);
- struct wi_vap *wvp = WI_VAP(vap);
int i, fid, len, off;
u_int16_t ltbuf[2];
u_int16_t stat;
@@ -1580,22 +1527,29 @@ wi_info_intr(struct wi_softc *sc)
break;
/* fall thru... */
case WI_INFO_LINK_STAT_AP_CHG:
- taskqueue_enqueue(taskqueue_swi, &wvp->wv_connected_task);
+ IEEE80211_LOCK(ic);
+ vap->iv_bss->ni_associd = 1 | 0xc000; /* NB: anything will do */
+ ieee80211_new_state(vap, IEEE80211_S_RUN, 0);
+ IEEE80211_UNLOCK(ic);
break;
case WI_INFO_LINK_STAT_AP_INR:
break;
case WI_INFO_LINK_STAT_DISCONNECTED:
/* we dropped off the net; e.g. due to deauth/disassoc */
- taskqueue_enqueue(taskqueue_swi, &wvp->wv_disconnected_task);
+ IEEE80211_LOCK(ic);
+ vap->iv_bss->ni_associd = 0;
+ vap->iv_stats.is_rx_deauth++;
+ ieee80211_new_state(vap, IEEE80211_S_SCAN, 0);
+ IEEE80211_UNLOCK(ic);
break;
case WI_INFO_LINK_STAT_AP_OOR:
/* XXX does this need to be per-vap? */
- taskqueue_enqueue(taskqueue_swi, &sc->sc_oor_task);
+ ieee80211_beacon_miss(ic);
break;
case WI_INFO_LINK_STAT_ASSOC_FAILED:
if (vap->iv_opmode == IEEE80211_M_STA)
- taskqueue_enqueue(taskqueue_swi,
- &wvp->wv_assoc_failed_task);
+ ieee80211_new_state(vap, IEEE80211_S_SCAN,
+ IEEE80211_SCAN_FAIL_TIMEOUT);
break;
}
break;