svn commit: r185733 - in user/thompsa/vaptq/sys: dev/if_ndis dev/ipw dev/iwi dev/iwn dev/usb dev/usb2/wlan dev/wi dev/wpi net80211

Andrew Thompson thompsa at FreeBSD.org
Sat Dec 6 21:49:23 PST 2008


Author: thompsa
Date: Sun Dec  7 05:49:22 2008
New Revision: 185733
URL: http://svn.freebsd.org/changeset/base/185733

Log:
  Commit WIP to move net80211 state changes and scanning to threads in order to
  simplify drivers. Once complete drivers will be able to sleep during callbacks
  and not need private taskqueues at all.

Modified:
  user/thompsa/vaptq/sys/dev/if_ndis/if_ndis.c
  user/thompsa/vaptq/sys/dev/if_ndis/if_ndisvar.h
  user/thompsa/vaptq/sys/dev/ipw/if_ipw.c
  user/thompsa/vaptq/sys/dev/ipw/if_ipwvar.h
  user/thompsa/vaptq/sys/dev/iwi/if_iwi.c
  user/thompsa/vaptq/sys/dev/iwi/if_iwivar.h
  user/thompsa/vaptq/sys/dev/iwn/if_iwn.c
  user/thompsa/vaptq/sys/dev/iwn/if_iwnvar.h
  user/thompsa/vaptq/sys/dev/usb/if_rum.c
  user/thompsa/vaptq/sys/dev/usb/if_rumvar.h
  user/thompsa/vaptq/sys/dev/usb/if_upgt.c
  user/thompsa/vaptq/sys/dev/usb/if_upgtvar.h
  user/thompsa/vaptq/sys/dev/usb/if_ural.c
  user/thompsa/vaptq/sys/dev/usb/if_uralvar.h
  user/thompsa/vaptq/sys/dev/usb/if_zyd.c
  user/thompsa/vaptq/sys/dev/usb/if_zydreg.h
  user/thompsa/vaptq/sys/dev/usb2/wlan/if_rum2.c
  user/thompsa/vaptq/sys/dev/usb2/wlan/if_ural2.c
  user/thompsa/vaptq/sys/dev/usb2/wlan/if_zyd2.c
  user/thompsa/vaptq/sys/dev/wi/if_wi.c
  user/thompsa/vaptq/sys/dev/wi/if_wivar.h
  user/thompsa/vaptq/sys/dev/wpi/if_wpi.c
  user/thompsa/vaptq/sys/dev/wpi/if_wpivar.h
  user/thompsa/vaptq/sys/net80211/ieee80211.c
  user/thompsa/vaptq/sys/net80211/ieee80211_proto.c
  user/thompsa/vaptq/sys/net80211/ieee80211_var.h

Modified: user/thompsa/vaptq/sys/dev/if_ndis/if_ndis.c
==============================================================================
--- user/thompsa/vaptq/sys/dev/if_ndis/if_ndis.c	Sun Dec  7 05:46:17 2008	(r185732)
+++ user/thompsa/vaptq/sys/dev/if_ndis/if_ndis.c	Sun Dec  7 05:49:22 2008	(r185733)
@@ -165,8 +165,6 @@ static void ndis_init		(void *);
 static void ndis_stop		(struct ndis_softc *);
 static int ndis_ifmedia_upd	(struct ifnet *);
 static void ndis_ifmedia_sts	(struct ifnet *, struct ifmediareq *);
-static void ndis_auth		(void *, int);
-static void ndis_assoc		(void *, int);
 static int ndis_get_assoc	(struct ndis_softc *, ndis_wlan_bssid_ex **);
 static int ndis_probe_offload	(struct ndis_softc *);
 static int ndis_set_offload	(struct ndis_softc *);
@@ -719,8 +717,6 @@ ndis_attach(dev)
 		taskqueue_start_threads(&sc->ndis_tq, 1, PI_NET, "%s taskq",
 		    device_get_nameunit(dev));
 		TASK_INIT(&sc->ndis_scantask, 0, ndis_scan, sc);
-		TASK_INIT(&sc->ndis_authtask, 0, ndis_auth, sc);
-		TASK_INIT(&sc->ndis_assoctask, 0, ndis_assoc, sc);
 
 		ifp->if_ioctl = ndis_ioctl_80211;
 		ic->ic_ifp = ifp;
@@ -1017,8 +1013,6 @@ ndis_detach(dev)
 
 	if (sc->ndis_80211) {
 		taskqueue_drain(sc->ndis_tq, &sc->ndis_scantask);
-		taskqueue_drain(sc->ndis_tq, &sc->ndis_authtask);
-		taskqueue_drain(sc->ndis_tq, &sc->ndis_assoctask);
 	}
 
 	if (sc->ndis_tickitem != NULL)
@@ -2361,30 +2355,6 @@ ndis_setstate_80211(sc)
 }
 
 static void
-ndis_auth(void *arg, int npending)
-{
-	struct ndis_softc *sc = arg;
-	struct ifnet *ifp = sc->ifp;
-	struct ieee80211com *ic = ifp->if_l2com;
-	struct ieee80211vap *vap = TAILQ_FIRST(&ic->ic_vaps);
-
-	vap->iv_state = IEEE80211_S_AUTH;
-	ndis_auth_and_assoc(sc, vap);
-}
-
-static void
-ndis_assoc(void *arg, int npending)
-{
-	struct ndis_softc *sc = arg;
-	struct ifnet *ifp = sc->ifp;
-	struct ieee80211com *ic = ifp->if_l2com;
-	struct ieee80211vap *vap = TAILQ_FIRST(&ic->ic_vaps);
-
-	vap->iv_state = IEEE80211_S_ASSOC;
-	ndis_auth_and_assoc(sc, vap);
-}
-
-static void
 ndis_auth_and_assoc(sc, vap)
 	struct ndis_softc	*sc;
 	struct ieee80211vap	*vap;
@@ -2598,9 +2568,6 @@ ndis_auth_and_assoc(sc, vap)
 	if (rval)
 		device_printf (sc->ndis_dev, "set ssid failed: %d\n", rval);
 
-	if (vap->iv_state == IEEE80211_S_AUTH)
-		ieee80211_new_state(vap, IEEE80211_S_ASSOC, 0);
-
 	return;
 }
 
@@ -3228,13 +3195,18 @@ ndis_newstate(struct ieee80211vap *vap, 
 		return nvp->newstate(vap, nstate, arg);
 	case IEEE80211_S_ASSOC:
 		if (ostate != IEEE80211_S_AUTH) {
-			taskqueue_enqueue(sc->ndis_tq, &sc->ndis_assoctask);
-			return EINPROGRESS;
+			IEEE80211_UNLOCK(ic);
+			ndis_auth_and_assoc(sc, vap);
+			IEEE80211_LOCK(ic);
 		}
 		break;
 	case IEEE80211_S_AUTH:
-		taskqueue_enqueue(sc->ndis_tq, &sc->ndis_authtask);
-		return EINPROGRESS;
+		IEEE80211_UNLOCK(ic);
+		ndis_auth_and_assoc(sc, vap);
+		if (vap->iv_state == IEEE80211_S_AUTH) /* XXX */
+			ieee80211_new_state(vap, IEEE80211_S_ASSOC, 0);
+		IEEE80211_LOCK(ic);
+		break;
 	default:
 		break;
 	}

Modified: user/thompsa/vaptq/sys/dev/if_ndis/if_ndisvar.h
==============================================================================
--- user/thompsa/vaptq/sys/dev/if_ndis/if_ndisvar.h	Sun Dec  7 05:46:17 2008	(r185732)
+++ user/thompsa/vaptq/sys/dev/if_ndis/if_ndisvar.h	Sun Dec  7 05:49:22 2008	(r185733)
@@ -177,8 +177,6 @@ struct ndis_softc {
 
 	struct taskqueue	*ndis_tq;		/* private task queue */
 	struct task		ndis_scantask;
-	struct task		ndis_authtask;
-	struct task		ndis_assoctask;
 	int			(*ndis_newstate)(struct ieee80211com *,
 				    enum ieee80211_state, int);
 	int			ndis_tx_timer;

Modified: user/thompsa/vaptq/sys/dev/ipw/if_ipw.c
==============================================================================
--- user/thompsa/vaptq/sys/dev/ipw/if_ipw.c	Sun Dec  7 05:46:17 2008	(r185732)
+++ user/thompsa/vaptq/sys/dev/ipw/if_ipw.c	Sun Dec  7 05:49:22 2008	(r185733)
@@ -147,8 +147,8 @@ static int	ipw_reset(struct ipw_softc *)
 static int	ipw_load_ucode(struct ipw_softc *, const char *, int);
 static int	ipw_load_firmware(struct ipw_softc *, const char *, int);
 static int	ipw_config(struct ipw_softc *);
-static void	ipw_assoc_task(void *, int);
-static void	ipw_disassoc_task(void *, int);
+static void	ipw_assoc(struct ieee80211com *, struct ieee80211vap *);
+static void	ipw_disassoc(struct ieee80211com *, struct ieee80211vap *);
 static void	ipw_init_task(void *, int);
 static void	ipw_init(void *);
 static void	ipw_init_locked(struct ipw_softc *);
@@ -511,8 +511,6 @@ ipw_vap_create(struct ieee80211com *ic,
 		return NULL;
 	vap = &ivp->vap;
 
-	TASK_INIT(&ivp->assoc_task, 0, ipw_assoc_task, vap);
-	TASK_INIT(&ivp->disassoc_task, 0, ipw_disassoc_task, vap);
 	TASK_INIT(&ivp->assoc_success_task, 0, ipw_assocsuccess, vap);
 	TASK_INIT(&ivp->assoc_failed_task, 0, ipw_assocfailed, vap);
 	TASK_INIT(&ivp->scandone_task, 0, ipw_scandone, vap);
@@ -894,11 +892,15 @@ ipw_newstate(struct ieee80211vap *vap, e
 	struct ieee80211com *ic = vap->iv_ic;
 	struct ifnet *ifp = ic->ic_ifp;
 	struct ipw_softc *sc = ifp->if_softc;
+	enum ieee80211_state ostate;
 
 	DPRINTF(("%s: %s -> %s flags 0x%x\n", __func__,
 		ieee80211_state_name[vap->iv_state],
 		ieee80211_state_name[nstate], sc->flags));
 
+	ostate = vap->iv_state;
+	IEEE80211_UNLOCK(ic);
+
 	switch (nstate) {
 	case IEEE80211_S_RUN:
 		if (ic->ic_opmode == IEEE80211_M_IBSS) {
@@ -910,39 +912,33 @@ ipw_newstate(struct ieee80211vap *vap, e
 			 * AUTH -> RUN transition and we want to do nothing.
 			 * This is all totally bogus and needs to be redone.
 			 */
-			if (vap->iv_state == IEEE80211_S_SCAN) {
-				taskqueue_enqueue(taskqueue_swi,
-				    &IPW_VAP(vap)->assoc_task);
-				return EINPROGRESS;
-			}
+			if (ostate == IEEE80211_S_SCAN)
+				ipw_assoc(ic, vap);
 		}
 		break;
 
 	case IEEE80211_S_INIT:
 		if (sc->flags & IPW_FLAG_ASSOCIATED)
-			taskqueue_enqueue(taskqueue_swi,
-			    &IPW_VAP(vap)->disassoc_task);
+			ipw_disassoc(ic, vap);
 		break;
 
 	case IEEE80211_S_AUTH:
-		taskqueue_enqueue(taskqueue_swi, &IPW_VAP(vap)->assoc_task);
-		return EINPROGRESS;
+		ipw_assoc(ic, vap);
+		break;
 
 	case IEEE80211_S_ASSOC:
 		/*
 		 * If we are not transitioning from AUTH the resend the
 		 * association request.
 		 */
-		if (vap->iv_state != IEEE80211_S_AUTH) {
-			taskqueue_enqueue(taskqueue_swi,
-			    &IPW_VAP(vap)->assoc_task);
-			return EINPROGRESS;
-		}
+		if (ostate != IEEE80211_S_AUTH)
+			ipw_assoc(ic, vap);
 		break;
 
 	default:
 		break;
 	}
+	IEEE80211_LOCK(ic);
 	return ivp->newstate(vap, nstate, arg);
 }
 
@@ -2263,11 +2259,9 @@ ipw_setchannel(struct ipw_softc *sc, str
 }
 
 static void
-ipw_assoc_task(void *context, int pending)
+ipw_assoc(struct ieee80211com *ic, struct ieee80211vap *vap)
 {
-	struct ieee80211vap *vap = context;
 	struct ifnet *ifp = vap->iv_ic->ic_ifp;
-	struct ieee80211com *ic = ifp->if_l2com;
 	struct ipw_softc *sc = ifp->if_softc;
 	struct ieee80211_node *ni = vap->iv_bss;
 	struct ipw_security security;
@@ -2358,9 +2352,8 @@ done:
 }
 
 static void
-ipw_disassoc_task(void *context, int pending)
+ipw_disassoc(struct ieee80211com *ic, struct ieee80211vap *vap)
 {
-	struct ieee80211vap *vap = context;
 	struct ifnet *ifp = vap->iv_ic->ic_ifp;
 	struct ieee80211_node *ni = vap->iv_bss;
 	struct ipw_softc *sc = ifp->if_softc;

Modified: user/thompsa/vaptq/sys/dev/ipw/if_ipwvar.h
==============================================================================
--- user/thompsa/vaptq/sys/dev/ipw/if_ipwvar.h	Sun Dec  7 05:46:17 2008	(r185732)
+++ user/thompsa/vaptq/sys/dev/ipw/if_ipwvar.h	Sun Dec  7 05:49:22 2008	(r185733)
@@ -78,8 +78,6 @@ struct ipw_tx_radiotap_header {
 
 struct ipw_vap {
 	struct ieee80211vap	vap;
-	struct task		assoc_task;
-	struct task		disassoc_task;
 	struct task		assoc_success_task;
 	struct task		assoc_failed_task;
 	struct task		scandone_task;

Modified: user/thompsa/vaptq/sys/dev/iwi/if_iwi.c
==============================================================================
--- user/thompsa/vaptq/sys/dev/iwi/if_iwi.c	Sun Dec  7 05:46:17 2008	(r185732)
+++ user/thompsa/vaptq/sys/dev/iwi/if_iwi.c	Sun Dec  7 05:49:22 2008	(r185733)
@@ -986,21 +986,21 @@ iwi_newstate(struct ieee80211vap *vap, e
 		ieee80211_state_name[vap->iv_state],
 		ieee80211_state_name[nstate], sc->flags));
 
+	IEEE80211_UNLOCK(ic);
+	IWI_LOCK(sc);
 	switch (nstate) {
 	case IEEE80211_S_INIT:
-		IWI_LOCK(sc);
 		/*
 		 * NB: don't try to do this if iwi_stop_master has
 		 *     shutdown the firmware and disabled interrupts.
 		 */
 		if (vap->iv_state == IEEE80211_S_RUN &&
 		    (sc->flags & IWI_FLAG_FW_INITED))
-			iwi_queue_cmd(sc, IWI_DISASSOC, 1);
-		IWI_UNLOCK(sc);
+			iwi_disassociate(sc, 0);
 		break;
 	case IEEE80211_S_AUTH:
-		iwi_queue_cmd(sc, IWI_AUTH, arg);
-		return EINPROGRESS;
+		iwi_auth_and_assoc(sc, vap);
+		break;
 	case IEEE80211_S_RUN:
 		if (vap->iv_opmode == IEEE80211_M_IBSS &&
 		    vap->iv_state == IEEE80211_S_SCAN) {
@@ -1012,8 +1012,7 @@ iwi_newstate(struct ieee80211vap *vap, e
 			 * AUTH -> RUN transition and we want to do nothing.
 			 * This is all totally bogus and needs to be redone.
 			 */
-			iwi_queue_cmd(sc, IWI_ASSOC, 0);
-			return EINPROGRESS;
+			iwi_auth_and_assoc(sc, vap);
 		}
 		break;
 	case IEEE80211_S_ASSOC:
@@ -1024,11 +1023,13 @@ iwi_newstate(struct ieee80211vap *vap, e
 		 */
 		if (vap->iv_state == IEEE80211_S_AUTH)
 			break;
-		iwi_queue_cmd(sc, IWI_ASSOC, arg);
-		return EINPROGRESS;
+		iwi_auth_and_assoc(sc, vap);
+		break;
 	default:
 		break;
 	}
+	IWI_UNLOCK(sc);
+	IEEE80211_LOCK(ic);
 	return ivp->iwi_newstate(vap, nstate, arg);
 }
 
@@ -3546,8 +3547,6 @@ iwi_ops(void *arg0, int npending)
 		[IWI_CMD_FREE]		= "FREE",
 		[IWI_SCAN_START]	= "SCAN_START",
 		[IWI_SET_CHANNEL]	= "SET_CHANNEL",
-		[IWI_AUTH]		= "AUTH",
-		[IWI_ASSOC]		= "ASSOC",
 		[IWI_DISASSOC]		= "DISASSOC",
 		[IWI_SCAN_CURCHAN]	= "SCAN_CURCHAN",
 		[IWI_SCAN_ALLCHAN]	= "SCAN_ALLCHAN",
@@ -3586,15 +3585,6 @@ again:
 
 	DPRINTF(("%s: %s arg %lu\n", __func__, opnames[cmd], arg));
 	switch (cmd) {
-	case IWI_AUTH:
-	case IWI_ASSOC:
-		if (cmd == IWI_AUTH)
-			vap->iv_state = IEEE80211_S_AUTH;
-		else
-			vap->iv_state = IEEE80211_S_ASSOC;
-		iwi_auth_and_assoc(sc, vap);
-		/* NB: completion done in iwi_notification_intr */
-		break;
 	case IWI_DISASSOC:
 		iwi_disassociate(sc, 0);
 		break;

Modified: user/thompsa/vaptq/sys/dev/iwi/if_iwivar.h
==============================================================================
--- user/thompsa/vaptq/sys/dev/iwi/if_iwivar.h	Sun Dec  7 05:46:17 2008	(r185732)
+++ user/thompsa/vaptq/sys/dev/iwi/if_iwivar.h	Sun Dec  7 05:49:22 2008	(r185733)
@@ -227,12 +227,10 @@ struct iwi_softc {
 #define	IWI_CMD_FREE		0		/* for marking slots unused */
 #define IWI_SCAN_START		1
 #define IWI_SET_CHANNEL	        2
-#define	IWI_AUTH		3
-#define	IWI_ASSOC		4
-#define	IWI_DISASSOC		5
-#define	IWI_SCAN_CURCHAN	6
-#define	IWI_SCAN_ALLCHAN	7
-#define	IWI_SET_WME		8
+#define	IWI_DISASSOC		3
+#define	IWI_SCAN_CURCHAN	4
+#define	IWI_SCAN_ALLCHAN	5
+#define	IWI_SET_WME		6
 
 	struct iwi_rx_radiotap_header sc_rxtap;
 	int			sc_rxtap_len;

Modified: user/thompsa/vaptq/sys/dev/iwn/if_iwn.c
==============================================================================
--- user/thompsa/vaptq/sys/dev/iwn/if_iwn.c	Sun Dec  7 05:46:17 2008	(r185732)
+++ user/thompsa/vaptq/sys/dev/iwn/if_iwn.c	Sun Dec  7 05:49:22 2008	(r185733)
@@ -165,8 +165,8 @@ void		iwn_compute_differential_gain(stru
 void		iwn_tune_sensitivity(struct iwn_softc *,
 		    const struct iwn_rx_stats *);
 int		iwn_send_sensitivity(struct iwn_softc *);
-int		iwn_auth(struct iwn_softc *);
-int		iwn_run(struct iwn_softc *);
+int		iwn_auth(struct iwn_softc *, struct ieee80211vap *);
+int		iwn_run(struct iwn_softc *, struct ieee80211vap *);
 int		iwn_scan(struct iwn_softc *);
 int		iwn_config(struct iwn_softc *);
 void		iwn_post_alive(struct iwn_softc *);
@@ -981,20 +981,13 @@ iwn_newstate(struct ieee80211vap *vap, e
 		ieee80211_state_name[vap->iv_state],
 		ieee80211_state_name[nstate]);
 
+	IEEE80211_UNLOCK(ic);
 	IWN_LOCK(sc);
 	callout_stop(&sc->sc_timer_to);
-	IWN_UNLOCK(sc);
 
-	/*
-	 * Some state transitions require issuing a configure request
-	 * to the adapter.  This must be done in a blocking context
-	 * so we toss control to the task q thread where the state
-	 * change will be finished after the command completes.
-	 */
 	if (nstate == IEEE80211_S_AUTH && vap->iv_state != IEEE80211_S_AUTH) {
 		/* !AUTH -> AUTH requires adapter config */
-		error = iwn_queue_cmd(sc, IWN_AUTH, arg, IWN_QUEUE_NORMAL);
-		return (error != 0 ? error : EINPROGRESS);
+		error = iwn_auth(sc, vap);
 	}
 	if (nstate == IEEE80211_S_RUN && vap->iv_state != IEEE80211_S_RUN) {
 		/*
@@ -1002,8 +995,7 @@ iwn_newstate(struct ieee80211vap *vap, e
 		 * which is done with a firmware cmd.  We also defer
 		 * starting the timers until that work is done.
 		 */
-		error = iwn_queue_cmd(sc, IWN_RUN, arg, IWN_QUEUE_NORMAL);
-		return (error != 0 ? error : EINPROGRESS);
+		error = iwn_run(sc, vap);
 	}
 	if (nstate == IEEE80211_S_RUN) {
 		/*
@@ -1011,6 +1003,8 @@ iwn_newstate(struct ieee80211vap *vap, e
 		 */
 		iwn_calib_reset(sc);
 	}
+	IWN_UNLOCK(sc);
+	IEEE80211_LOCK(ic);
 	return ivp->iv_newstate(vap, nstate, arg);
 }
 
@@ -3456,11 +3450,10 @@ iwn_send_sensitivity(struct iwn_softc *s
 }
 
 int
-iwn_auth(struct iwn_softc *sc)
+iwn_auth(struct iwn_softc *sc, struct ieee80211vap *vap)
 {
 	struct ifnet *ifp = sc->sc_ifp;
 	struct ieee80211com *ic = ifp->if_l2com;
-	struct ieee80211vap *vap = TAILQ_FIRST(&ic->ic_vaps);	/*XXX*/
 	struct ieee80211_node *ni = vap->iv_bss;
 	struct iwn_node_info node;
 	int error;
@@ -3549,12 +3542,11 @@ iwn_auth(struct iwn_softc *sc)
  * Configure the adapter for associated state.
  */
 int
-iwn_run(struct iwn_softc *sc)
+iwn_run(struct iwn_softc *sc, struct ieee80211vap *vap)
 {
 #define	MS(v,x)	(((v) & x) >> x##_S)
 	struct ifnet *ifp = sc->sc_ifp;
 	struct ieee80211com *ic = ifp->if_l2com;
-	struct ieee80211vap *vap = TAILQ_FIRST(&ic->ic_vaps);	/*XXX*/
 	struct ieee80211_node *ni = vap->iv_bss;
 	struct iwn_node_info node;
 	int error, maxrxampdu, ampdudensity;
@@ -4386,7 +4378,6 @@ iwn_ops(void *arg0, int pending)
 	struct ieee80211com *ic = ifp->if_l2com;
 	struct ieee80211vap *vap;
 	int cmd, arg, error;
-	enum ieee80211_state nstate;
 
 	for (;;) {
 		IWN_CMD_LOCK(sc);
@@ -4442,30 +4433,6 @@ iwn_ops(void *arg0, int pending)
 				return;
 			}
 			break;
-		case IWN_AUTH:
-		case IWN_RUN:
-			if (cmd == IWN_AUTH) {
-				error = iwn_auth(sc);
-				nstate = IEEE80211_S_AUTH;
-			} else {
-				error = iwn_run(sc);
-				nstate = IEEE80211_S_RUN;
-			}
-			if (error == 0) {
-				IWN_UNLOCK(sc);
-				IEEE80211_LOCK(ic);
-				IWN_VAP(vap)->iv_newstate(vap, nstate, arg);
-				if (vap->iv_newstate_cb != NULL)
-					vap->iv_newstate_cb(vap, nstate, arg);
-				IEEE80211_UNLOCK(ic);
-				IWN_LOCK(sc);
-			} else {
-				device_printf(sc->sc_dev,
-				    "%s: %s state change failed, error %d\n",
-				    __func__, ieee80211_state_name[nstate],
-				    error);
-			}
-			break;
 		case IWN_REINIT:
 			IWN_UNLOCK(sc);
 			iwn_init(sc);
@@ -4559,9 +4526,7 @@ iwn_ops_str(int cmd)
 	case IWN_SCAN_CURCHAN:	return "SCAN_CURCHAN";
 	case IWN_SCAN_STOP:	return "SCAN_STOP";
 	case IWN_SET_CHAN:	return "SET_CHAN";
-	case IWN_AUTH:		return "AUTH";
 	case IWN_SCAN_NEXT:	return "SCAN_NEXT";
-	case IWN_RUN:		return "RUN";
 	case IWN_RADIO_ENABLE:	return "RADIO_ENABLE";
 	case IWN_RADIO_DISABLE:	return "RADIO_DISABLE";
 	case IWN_REINIT:	return "REINIT";

Modified: user/thompsa/vaptq/sys/dev/iwn/if_iwnvar.h
==============================================================================
--- user/thompsa/vaptq/sys/dev/iwn/if_iwnvar.h	Sun Dec  7 05:46:17 2008	(r185732)
+++ user/thompsa/vaptq/sys/dev/iwn/if_iwnvar.h	Sun Dec  7 05:49:22 2008	(r185733)
@@ -185,12 +185,10 @@ struct iwn_softc {
 #define IWN_SCAN_CURCHAN	(1<<1)
 #define IWN_SCAN_STOP		(1<<2)
 #define IWN_SET_CHAN		(1<<3)
-#define IWN_AUTH		(1<<4)
-#define IWN_SCAN_NEXT		(1<<5)
-#define IWN_RUN			(1<<6)
-#define IWN_RADIO_ENABLE	(1<<7)
-#define IWN_RADIO_DISABLE	(1<<8)
-#define IWN_REINIT		(1<<9)
+#define IWN_SCAN_NEXT		(1<<4)
+#define IWN_RADIO_ENABLE	(1<<5)
+#define IWN_RADIO_DISABLE	(1<<6)
+#define IWN_REINIT		(1<<7)
 #define IWN_CMD_MAXOPS		10
 	/* command queuing request type */
 #define IWN_QUEUE_NORMAL	0

Modified: user/thompsa/vaptq/sys/dev/usb/if_rum.c
==============================================================================
--- user/thompsa/vaptq/sys/dev/usb/if_rum.c	Sun Dec  7 05:46:17 2008	(r185732)
+++ user/thompsa/vaptq/sys/dev/usb/if_rum.c	Sun Dec  7 05:49:22 2008	(r185733)
@@ -140,7 +140,6 @@ static int		rum_alloc_tx_list(struct rum
 static void		rum_free_tx_list(struct rum_softc *);
 static int		rum_alloc_rx_list(struct rum_softc *);
 static void		rum_free_rx_list(struct rum_softc *);
-static void		rum_task(void *);
 static void		rum_scantask(void *);
 static int		rum_newstate(struct ieee80211vap *,
 			    enum ieee80211_state, int);
@@ -448,7 +447,6 @@ rum_attach(device_t self)
 	mtx_init(&sc->sc_mtx, device_get_nameunit(sc->sc_dev), MTX_NETWORK_LOCK,
 	    MTX_DEF | MTX_RECURSE);
 
-	usb_init_task(&sc->sc_task, rum_task, sc);
 	usb_init_task(&sc->sc_scantask, rum_scantask, sc);
 	callout_init(&sc->watchdog_ch, 0);
 
@@ -556,7 +554,6 @@ rum_detach(device_t self)
 	bpfdetach(ifp);
 	ieee80211_ifdetach(ic);
 
-	usb_rem_task(sc->sc_udev, &sc->sc_task);
 	usb_rem_task(sc->sc_udev, &sc->sc_scantask);
 	callout_stop(&sc->watchdog_ch);
 
@@ -751,24 +748,24 @@ rum_free_rx_list(struct rum_softc *sc)
 	}
 }
 
-static void
-rum_task(void *arg)
+static int
+rum_newstate(struct ieee80211vap *vap, enum ieee80211_state nstate, int arg)
 {
-	struct rum_softc *sc = arg;
-	struct ifnet *ifp = sc->sc_ifp;
-	struct ieee80211com *ic = ifp->if_l2com;
-	struct ieee80211vap *vap = TAILQ_FIRST(&ic->ic_vaps);
 	struct rum_vap *rvp = RUM_VAP(vap);
+	struct ieee80211com *ic = vap->iv_ic;
+	struct rum_softc *sc = ic->ic_ifp->if_softc;
 	const struct ieee80211_txparam *tp;
 	enum ieee80211_state ostate;
 	struct ieee80211_node *ni;
 	uint32_t tmp;
 
+	usb_rem_task(sc->sc_udev, &sc->sc_scantask);
+	callout_stop(&rvp->amrr_ch);
 	ostate = vap->iv_state;
 
+	IEEE80211_UNLOCK(ic);
 	RUM_LOCK(sc);
-
-	switch (sc->sc_state) {
+	switch (nstate) {
 	case IEEE80211_S_INIT:
 		if (ostate == IEEE80211_S_RUN) {
 			/* abort TSF synchronization */
@@ -803,38 +800,10 @@ rum_task(void *arg)
 	default:
 		break;
 	}
-
 	RUM_UNLOCK(sc);
-
 	IEEE80211_LOCK(ic);
-	rvp->newstate(vap, sc->sc_state, sc->sc_arg);
-	if (vap->iv_newstate_cb != NULL)
-		vap->iv_newstate_cb(vap, sc->sc_state, sc->sc_arg);
-	IEEE80211_UNLOCK(ic);
-}
-
-static int
-rum_newstate(struct ieee80211vap *vap, enum ieee80211_state nstate, int arg)
-{
-	struct rum_vap *rvp = RUM_VAP(vap);
-	struct ieee80211com *ic = vap->iv_ic;
-	struct rum_softc *sc = ic->ic_ifp->if_softc;
-
-	usb_rem_task(sc->sc_udev, &sc->sc_task);
-	usb_rem_task(sc->sc_udev, &sc->sc_scantask);
-	callout_stop(&rvp->amrr_ch);
-
-	/* do it in a process context */
-	sc->sc_state = nstate;
-	sc->sc_arg = arg;
-
-	if (nstate == IEEE80211_S_INIT) {
-		rvp->newstate(vap, nstate, arg);
-		return 0;
-	} else {
-		usb_add_task(sc->sc_udev, &sc->sc_task, USB_TASKQ_DRIVER);
-		return EINPROGRESS;
-	}
+	rvp->newstate(vap, nstate, arg);
+	return 0;
 }
 
 static void

Modified: user/thompsa/vaptq/sys/dev/usb/if_rumvar.h
==============================================================================
--- user/thompsa/vaptq/sys/dev/usb/if_rumvar.h	Sun Dec  7 05:46:17 2008	(r185732)
+++ user/thompsa/vaptq/sys/dev/usb/if_rumvar.h	Sun Dec  7 05:49:22 2008	(r185733)
@@ -105,10 +105,6 @@ struct rum_softc {
 	usbd_pipe_handle		sc_rx_pipeh;
 	usbd_pipe_handle		sc_tx_pipeh;
 
-	enum ieee80211_state		sc_state;
-	int				sc_arg;
-	struct usb_task			sc_task;
-
 	struct usb_task			sc_scantask;
 	int				sc_scan_action;
 #define RUM_SCAN_START	0

Modified: user/thompsa/vaptq/sys/dev/usb/if_upgt.c
==============================================================================
--- user/thompsa/vaptq/sys/dev/usb/if_upgt.c	Sun Dec  7 05:46:17 2008	(r185732)
+++ user/thompsa/vaptq/sys/dev/usb/if_upgt.c	Sun Dec  7 05:49:22 2008	(r185733)
@@ -167,10 +167,9 @@ static void	upgt_stop(struct upgt_softc 
 static void	upgt_setup_rates(struct ieee80211vap *, struct ieee80211com *);
 static int	upgt_set_macfilter(struct upgt_softc *, uint8_t);
 static int	upgt_newstate(struct ieee80211vap *, enum ieee80211_state, int);
-static void	upgt_task(void *);
 static void	upgt_scantask(void *);
 static void	upgt_set_chan(struct upgt_softc *, struct ieee80211_channel *);
-static void	upgt_set_led(struct upgt_softc *, int);
+static void	upgt_set_led(struct upgt_softc *, int, enum ieee80211_state);
 static void	upgt_set_led_blink(void *);
 static void	upgt_tx_task(void *);
 static int	upgt_get_stats(struct upgt_softc *);
@@ -333,7 +332,6 @@ upgt_attach_hook(device_t dev)
 	    MTX_DEF | MTX_RECURSE);
 	usb_init_task(&sc->sc_mcasttask, upgt_set_multi, sc);
 	usb_init_task(&sc->sc_scantask, upgt_scantask, sc);
-	usb_init_task(&sc->sc_task, upgt_task, sc);
 	usb_init_task(&sc->sc_task_tx, upgt_tx_task, sc);
 	callout_init(&sc->sc_led_ch, 0);
 	callout_init(&sc->sc_watchdog_ch, 0);
@@ -451,6 +449,7 @@ upgt_tx_task(void *arg)
 	struct upgt_softc *sc = arg;
 	struct ifnet *ifp = sc->sc_ifp;
 	struct ieee80211com *ic = ifp->if_l2com;
+	struct ieee80211vap *vap = TAILQ_FIRST(&ic->ic_vaps);
 	struct ieee80211_frame *wh;
 	struct ieee80211_key *k;
 	struct upgt_data *data_tx;
@@ -461,7 +460,7 @@ upgt_tx_task(void *arg)
 	int len, i;
 	usbd_status error;
 
-	upgt_set_led(sc, UPGT_LED_BLINK);
+	upgt_set_led(sc, UPGT_LED_BLINK, vap->iv_state);
 
 	UPGT_LOCK(sc);
 	for (i = 0; i < upgt_txbuf; i++) {
@@ -693,53 +692,7 @@ upgt_stop(struct upgt_softc *sc, int dis
 }
 
 static void
-upgt_task(void *arg)
-{
-	struct upgt_softc *sc = arg;
-	struct ifnet *ifp = sc->sc_ifp;
-	struct ieee80211com *ic = ifp->if_l2com;
-	struct ieee80211vap *vap = TAILQ_FIRST(&ic->ic_vaps);
-	struct upgt_vap *uvp = UPGT_VAP(vap);
-
-	DPRINTF(sc, UPGT_DEBUG_STATE, "%s: %s -> %s\n", __func__,
-	    ieee80211_state_name[vap->iv_state],
-	    ieee80211_state_name[sc->sc_state]);
-	
-	switch (sc->sc_state) {
-	case IEEE80211_S_INIT:
-		/* do not accept any frames if the device is down */
-		UPGT_LOCK(sc);
-		upgt_set_macfilter(sc, sc->sc_state);
-		UPGT_UNLOCK(sc);
-		upgt_set_led(sc, UPGT_LED_OFF);
-		break;
-	case IEEE80211_S_SCAN:
-		upgt_set_chan(sc, ic->ic_curchan);
-		break;
-	case IEEE80211_S_AUTH:
-		upgt_set_chan(sc, ic->ic_curchan);
-		break;
-	case IEEE80211_S_ASSOC:
-		break;
-	case IEEE80211_S_RUN:
-		UPGT_LOCK(sc);
-		upgt_set_macfilter(sc, sc->sc_state);
-		UPGT_UNLOCK(sc);
-		upgt_set_led(sc, UPGT_LED_ON);
-		break;
-	default:
-		break;
-	}
-
-	IEEE80211_LOCK(ic);
-	uvp->newstate(vap, sc->sc_state, sc->sc_arg);
-	if (vap->iv_newstate_cb != NULL)
-		vap->iv_newstate_cb(vap, sc->sc_state, sc->sc_arg);
-	IEEE80211_UNLOCK(ic);
-}
-
-static void
-upgt_set_led(struct upgt_softc *sc, int action)
+upgt_set_led(struct upgt_softc *sc, int action, enum ieee80211_state nstate)
 {
 	struct upgt_data *data_cmd = &sc->cmd_data;
 	struct upgt_lmac_mem *mem;
@@ -781,7 +734,7 @@ upgt_set_led(struct upgt_softc *sc, int 
 		led->action_tmp_dur = 0;
 		break;
 	case UPGT_LED_BLINK:
-		if (sc->sc_state != IEEE80211_S_RUN)
+		if (nstate != IEEE80211_S_RUN)
 			return;
 		if (sc->sc_led_blink)
 			/* previous blink was not finished */
@@ -1311,19 +1264,35 @@ upgt_newstate(struct ieee80211vap *vap, 
 	struct ieee80211com *ic = vap->iv_ic;
 	struct upgt_softc *sc = ic->ic_ifp->if_softc;
 
-	usb_rem_task(sc->sc_udev, &sc->sc_task);
-
-	/* do it in a process context */
-	sc->sc_state = nstate;
-	sc->sc_arg = arg;
-
-	if (nstate == IEEE80211_S_INIT) {
-		uvp->newstate(vap, nstate, arg);
-		return 0;
-	} else {
-		usb_add_task(sc->sc_udev, &sc->sc_task, USB_TASKQ_DRIVER);
-		return EINPROGRESS;
+	IEEE80211_UNLOCK(ic);
+	switch (nstate) {
+	case IEEE80211_S_INIT:
+		/* do not accept any frames if the device is down */
+		UPGT_LOCK(sc);
+		upgt_set_macfilter(sc, nstate);
+		UPGT_UNLOCK(sc);
+		upgt_set_led(sc, UPGT_LED_OFF, nstate);
+		break;
+	case IEEE80211_S_SCAN:
+		upgt_set_chan(sc, ic->ic_curchan);
+		break;
+	case IEEE80211_S_AUTH:
+		upgt_set_chan(sc, ic->ic_curchan);
+		break;
+	case IEEE80211_S_ASSOC:
+		break;
+	case IEEE80211_S_RUN:
+		UPGT_LOCK(sc);
+		upgt_set_macfilter(sc, nstate);
+		UPGT_UNLOCK(sc);
+		upgt_set_led(sc, UPGT_LED_ON, nstate);
+		break;
+	default:
+		break;
 	}
+	IEEE80211_LOCK(ic);
+	uvp->newstate(vap, nstate, arg);
+	return 0;
 }
 
 static void
@@ -2291,7 +2260,6 @@ upgt_detach(device_t dev)
 	mtx_destroy(&sc->sc_mtx);
 	usb_rem_task(sc->sc_udev, &sc->sc_mcasttask);
 	usb_rem_task(sc->sc_udev, &sc->sc_scantask);
-	usb_rem_task(sc->sc_udev, &sc->sc_task);
 	usb_rem_task(sc->sc_udev, &sc->sc_task_tx);
 	callout_stop(&sc->sc_led_ch);
 	callout_stop(&sc->sc_watchdog_ch);

Modified: user/thompsa/vaptq/sys/dev/usb/if_upgtvar.h
==============================================================================
--- user/thompsa/vaptq/sys/dev/usb/if_upgtvar.h	Sun Dec  7 05:46:17 2008	(r185732)
+++ user/thompsa/vaptq/sys/dev/usb/if_upgtvar.h	Sun Dec  7 05:49:22 2008	(r185733)
@@ -409,12 +409,9 @@ struct upgt_softc {
 	int			 sc_debug;
 
 	struct usb_task		 sc_mcasttask;
-	struct usb_task		 sc_task;
 	struct usb_task		 sc_scantask;
 #define UPGT_SET_CHANNEL	 2
 	int			 sc_scan_action;
-	enum ieee80211_state	 sc_state;
-	int			 sc_arg;
 	int			 sc_led_blink;
 	struct callout		 sc_led_ch;
 	uint8_t			 sc_cur_rateset[8];

Modified: user/thompsa/vaptq/sys/dev/usb/if_ural.c
==============================================================================
--- user/thompsa/vaptq/sys/dev/usb/if_ural.c	Sun Dec  7 05:46:17 2008	(r185732)
+++ user/thompsa/vaptq/sys/dev/usb/if_ural.c	Sun Dec  7 05:49:22 2008	(r185733)
@@ -125,7 +125,6 @@ static int		ural_alloc_tx_list(struct ur
 static void		ural_free_tx_list(struct ural_softc *);
 static int		ural_alloc_rx_list(struct ural_softc *);
 static void		ural_free_rx_list(struct ural_softc *);
-static void		ural_task(void *);
 static void		ural_scantask(void *);
 static int		ural_newstate(struct ieee80211vap *,
 			    enum ieee80211_state, int);
@@ -451,7 +450,6 @@ ural_attach(device_t self)
 	mtx_init(&sc->sc_mtx, device_get_nameunit(sc->sc_dev), MTX_NETWORK_LOCK,
 	    MTX_DEF | MTX_RECURSE);
 
-	usb_init_task(&sc->sc_task, ural_task, sc);
 	usb_init_task(&sc->sc_scantask, ural_scantask, sc);
 	callout_init(&sc->watchdog_ch, 0);
 
@@ -539,7 +537,6 @@ ural_detach(device_t self)
 	bpfdetach(ifp);
 	ieee80211_ifdetach(ic);
 
-	usb_rem_task(sc->sc_udev, &sc->sc_task);
 	usb_rem_task(sc->sc_udev, &sc->sc_scantask);
 	callout_stop(&sc->watchdog_ch);
 
@@ -737,22 +734,51 @@ ural_free_rx_list(struct ural_softc *sc)
 }
 
 static void
-ural_task(void *xarg)
+ural_scantask(void *arg)
 {
-	struct ural_softc *sc = xarg;
+	struct ural_softc *sc = arg;
 	struct ifnet *ifp = sc->sc_ifp;
 	struct ieee80211com *ic = ifp->if_l2com;
 	struct ieee80211vap *vap = TAILQ_FIRST(&ic->ic_vaps);
+
+	RAL_LOCK(sc);
+	if (sc->sc_scan_action == URAL_SCAN_START) {
+		/* abort TSF synchronization */
+		ural_write(sc, RAL_TXRX_CSR19, 0);
+		ural_set_bssid(sc, ifp->if_broadcastaddr);
+	} else if (sc->sc_scan_action == URAL_SET_CHANNEL) {
+		mtx_lock(&Giant);
+		ural_set_chan(sc, ic->ic_curchan);
+		mtx_unlock(&Giant);
+	} else {
+		ural_enable_tsf_sync(sc);
+		/* XXX keep local copy */
+		ural_set_bssid(sc, vap->iv_bss->ni_bssid);
+	} 
+	RAL_UNLOCK(sc);
+}
+
+static int
+ural_newstate(struct ieee80211vap *vap, enum ieee80211_state nstate, int arg)
+{
 	struct ural_vap *uvp = URAL_VAP(vap);
-	const struct ieee80211_txparam *tp;
+	struct ieee80211com *ic = vap->iv_ic;
+	struct ural_softc *sc = ic->ic_ifp->if_softc;
 	enum ieee80211_state ostate;
+	const struct ieee80211_txparam *tp;
 	struct ieee80211_node *ni;
 	struct mbuf *m;
 
+	callout_stop(&uvp->amrr_ch);
 	ostate = vap->iv_state;
 
+	DPRINTF(("%s: %s -> %s\n", __func__,
+		ieee80211_state_name[vap->iv_state],
+		ieee80211_state_name[nstate]));
+
+	IEEE80211_UNLOCK(ic);
 	RAL_LOCK(sc);
-	switch (sc->sc_state) {
+	switch (nstate) {
 	case IEEE80211_S_INIT:
 		if (ostate == IEEE80211_S_RUN) {
 			/* abort TSF synchronization */
@@ -779,13 +805,13 @@ ural_task(void *xarg)
 			if (m == NULL) {
 				device_printf(sc->sc_dev,
 				    "could not allocate beacon\n");
-				return;
+				return ENXIO;
 			}
 
 			if (ural_tx_bcn(sc, m, ni) != 0) {
 				device_printf(sc->sc_dev,
 				    "could not send beacon\n");
-				return;
+				return ENXIO;
 			}
 		}
 
@@ -805,62 +831,10 @@ ural_task(void *xarg)
 	default:
 		break;
 	}
-
 	RAL_UNLOCK(sc);
-
 	IEEE80211_LOCK(ic);
-	uvp->newstate(vap, sc->sc_state, sc->sc_arg);
-	if (vap->iv_newstate_cb != NULL)
-		vap->iv_newstate_cb(vap, sc->sc_state, sc->sc_arg);
-	IEEE80211_UNLOCK(ic);
-}
-
-static void
-ural_scantask(void *arg)
-{
-	struct ural_softc *sc = arg;
-	struct ifnet *ifp = sc->sc_ifp;
-	struct ieee80211com *ic = ifp->if_l2com;
-	struct ieee80211vap *vap = TAILQ_FIRST(&ic->ic_vaps);
-
-	RAL_LOCK(sc);
-	if (sc->sc_scan_action == URAL_SCAN_START) {
-		/* abort TSF synchronization */
-		ural_write(sc, RAL_TXRX_CSR19, 0);
-		ural_set_bssid(sc, ifp->if_broadcastaddr);
-	} else if (sc->sc_scan_action == URAL_SET_CHANNEL) {
-		mtx_lock(&Giant);
-		ural_set_chan(sc, ic->ic_curchan);
-		mtx_unlock(&Giant);
-	} else {
-		ural_enable_tsf_sync(sc);
-		/* XXX keep local copy */
-		ural_set_bssid(sc, vap->iv_bss->ni_bssid);
-	} 
-	RAL_UNLOCK(sc);
-}
-
-static int
-ural_newstate(struct ieee80211vap *vap, enum ieee80211_state nstate, int arg)
-{
-	struct ural_vap *uvp = URAL_VAP(vap);
-	struct ieee80211com *ic = vap->iv_ic;
-	struct ural_softc *sc = ic->ic_ifp->if_softc;
-
-	callout_stop(&uvp->amrr_ch);
-
-	/* do it in a process context */
-	sc->sc_state = nstate;
-	sc->sc_arg = arg;
-
-	usb_rem_task(sc->sc_udev, &sc->sc_task);
-	if (nstate == IEEE80211_S_INIT) {
-		uvp->newstate(vap, nstate, arg);
-		return 0;
-	} else {
-		usb_add_task(sc->sc_udev, &sc->sc_task, USB_TASKQ_DRIVER);
-		return EINPROGRESS;
-	}
+	uvp->newstate(vap, nstate, arg);
+	return 0;
 }
 
 #define RAL_RXTX_TURNAROUND	5	/* us */

Modified: user/thompsa/vaptq/sys/dev/usb/if_uralvar.h
==============================================================================
--- user/thompsa/vaptq/sys/dev/usb/if_uralvar.h	Sun Dec  7 05:46:17 2008	(r185732)
+++ user/thompsa/vaptq/sys/dev/usb/if_uralvar.h	Sun Dec  7 05:49:22 2008	(r185733)
@@ -110,10 +110,7 @@ struct ural_softc {
 	usbd_pipe_handle		sc_rx_pipeh;
 	usbd_pipe_handle		sc_tx_pipeh;
 
-	enum ieee80211_state		sc_state;
-	int				sc_arg;
 	int                             sc_scan_action; /* should be an enum */
-	struct usb_task			sc_task;
 	struct usb_task			sc_scantask;
 
 	struct ural_rx_data		rx_data[RAL_RX_LIST_COUNT];

Modified: user/thompsa/vaptq/sys/dev/usb/if_zyd.c
==============================================================================
--- user/thompsa/vaptq/sys/dev/usb/if_zyd.c	Sun Dec  7 05:46:17 2008	(r185732)
+++ user/thompsa/vaptq/sys/dev/usb/if_zyd.c	Sun Dec  7 05:49:22 2008	(r185733)
@@ -202,7 +202,6 @@ static int	zyd_alloc_rx_list(struct zyd_
 static void	zyd_free_rx_list(struct zyd_softc *);
 static struct ieee80211_node *zyd_node_alloc(struct ieee80211vap *,
 			    const uint8_t mac[IEEE80211_ADDR_LEN]);
-static void	zyd_task(void *);
 static int	zyd_newstate(struct ieee80211vap *, enum ieee80211_state, int);
 static int	zyd_cmd(struct zyd_softc *, uint16_t, const void *, int,
 		    void *, int, u_int);
@@ -322,7 +321,6 @@ zyd_attach(device_t dev)
 	    MTX_NETWORK_LOCK, MTX_DEF);
 	usb_init_task(&sc->sc_mcasttask, zyd_set_multi, sc);
 	usb_init_task(&sc->sc_scantask, zyd_scantask, sc);
-	usb_init_task(&sc->sc_task, zyd_task, sc);
 	callout_init(&sc->sc_watchdog_ch, 0);
 	STAILQ_INIT(&sc->sc_rqh);
 
@@ -661,18 +659,24 @@ zyd_node_alloc(struct ieee80211vap *vap 
 	return (zn != NULL) ? (&zn->ni) : (NULL);
 }
 
-static void
-zyd_task(void *arg)
+static int
+zyd_newstate(struct ieee80211vap *vap, enum ieee80211_state nstate, int arg)
 {
-	int error;
-	struct zyd_softc *sc = arg;
-	struct ifnet *ifp = sc->sc_ifp;
-	struct ieee80211com *ic = ifp->if_l2com;
-	struct ieee80211vap *vap = TAILQ_FIRST(&ic->ic_vaps);
-	struct ieee80211_node *ni = vap->iv_bss;
 	struct zyd_vap *zvp = ZYD_VAP(vap);
+	struct ieee80211com *ic = vap->iv_ic;
+	struct zyd_softc *sc = ic->ic_ifp->if_softc;
+	struct ieee80211_node *ni = vap->iv_bss;
+	int error;
 
-	switch (sc->sc_state) {
+	DPRINTF(sc, ZYD_DEBUG_STATE, "%s: %s -> %s\n", __func__,
+	    ieee80211_state_name[vap->iv_state],
+	    ieee80211_state_name[nstate]);
+
+	usb_rem_task(sc->sc_udev, &sc->sc_scantask);
+	callout_stop(&sc->sc_watchdog_ch);
+
+	IEEE80211_UNLOCK(ic);
+	switch (nstate) {
 	case IEEE80211_S_AUTH:
 		zyd_set_chan(sc, ic->ic_curchan);
 		break;
@@ -684,51 +688,20 @@ zyd_task(void *arg)
 		error = zyd_set_led(sc, ZYD_LED1, 1);
 		if (error != 0)
 			goto fail;
-		
+
 		/* make data LED blink upon Tx */
 		zyd_write32_m(sc, sc->sc_fwbase + ZYD_FW_LINK_STATUS, 1);
-		
+
 		IEEE80211_ADDR_COPY(sc->sc_bssid, ni->ni_bssid);

*** DIFF OUTPUT TRUNCATED AT 1000 LINES ***


More information about the svn-src-user mailing list