Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 17 Apr 2009 16:15:56 +0000 (UTC)
From:      Andrew Thompson <thompsa@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-user@freebsd.org
Subject:   svn commit: r191208 - in user/thompsa/vaptq/sys/dev: ipw iwi iwn wpi
Message-ID:  <200904171615.n3HGFuji027525@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: thompsa
Date: Fri Apr 17 16:15:56 2009
New Revision: 191208
URL: http://svn.freebsd.org/changeset/base/191208

Log:
  Remove the command op queues now that they are not used during normal
  operation, infrequent tasks such as kicking dead firmware can go on
  taskqueue_swi.

Modified:
  user/thompsa/vaptq/sys/dev/ipw/if_ipw.c
  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/wpi/if_wpi.c
  user/thompsa/vaptq/sys/dev/wpi/if_wpivar.h

Modified: user/thompsa/vaptq/sys/dev/ipw/if_ipw.c
==============================================================================
--- user/thompsa/vaptq/sys/dev/ipw/if_ipw.c	Fri Apr 17 16:07:13 2009	(r191207)
+++ user/thompsa/vaptq/sys/dev/ipw/if_ipw.c	Fri Apr 17 16:15:56 2009	(r191208)
@@ -412,7 +412,7 @@ ipw_detach(device_t dev)
 	ieee80211_ifdetach(ic);
 
 	callout_drain(&sc->sc_wdtimer);
-	taskqueue_drain(taskqueue_fast, &sc->sc_init_task);
+	taskqueue_drain(taskqueue_swi, &sc->sc_init_task);
 
 	ipw_release(sc);
 

Modified: user/thompsa/vaptq/sys/dev/iwi/if_iwi.c
==============================================================================
--- user/thompsa/vaptq/sys/dev/iwi/if_iwi.c	Fri Apr 17 16:07:13 2009	(r191207)
+++ user/thompsa/vaptq/sys/dev/iwi/if_iwi.c	Fri Apr 17 16:15:56 2009	(r191208)
@@ -189,8 +189,6 @@ static void	iwi_scan_end(struct ieee8021
 static void	iwi_set_channel(struct ieee80211com *);
 static void	iwi_scan_curchan(struct ieee80211_scan_state *, unsigned long maxdwell);
 static void	iwi_scan_mindwell(struct ieee80211_scan_state *);
-static void	iwi_ops(void *, int);
-static int	iwi_queue_cmd(struct iwi_softc *, int, unsigned long);
 static int	iwi_auth_and_assoc(struct iwi_softc *, struct ieee80211vap *);
 static int	iwi_disassociate(struct iwi_softc *, int quiet);
 static void	iwi_init_locked(struct iwi_softc *);
@@ -288,23 +286,12 @@ iwi_attach(device_t dev)
 	ic = ifp->if_l2com;
 
 	IWI_LOCK_INIT(sc);
-	IWI_CMD_LOCK_INIT(sc);
 
 	sc->sc_unr = new_unrhdr(1, IWI_MAX_IBSSNODE-1, &sc->sc_mtx);
 
-	sc->sc_tq = taskqueue_create("iwi_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));
-	sc->sc_tq2 = taskqueue_create("iwi_taskq2", M_NOWAIT | M_ZERO,
-		taskqueue_thread_enqueue, &sc->sc_tq2);
-	taskqueue_start_threads(&sc->sc_tq2, 1, PI_NET, "%s taskq2",
-		device_get_nameunit(dev));
-
 	TASK_INIT(&sc->sc_radiontask, 0, iwi_radio_on, sc);
 	TASK_INIT(&sc->sc_radiofftask, 0, iwi_radio_off, sc);
 	TASK_INIT(&sc->sc_restarttask, 0, iwi_restart, sc);
-	TASK_INIT(&sc->sc_opstask, 0, iwi_ops, sc);
 	callout_init_mtx(&sc->sc_wdtimer, &sc->sc_mtx, 0);
 	callout_init_mtx(&sc->sc_rftimer, &sc->sc_mtx, 0);
 
@@ -478,8 +465,9 @@ iwi_detach(device_t dev)
 	ieee80211_ifdetach(ic);
 
 	/* NB: do early to drain any pending tasks */
-	taskqueue_free(sc->sc_tq);
-	taskqueue_free(sc->sc_tq2);
+	taskqueue_drain(taskqueue_swi, &sc->sc_radiontask);
+	taskqueue_drain(taskqueue_swi, &sc->sc_radiofftask);
+	taskqueue_drain(taskqueue_swi, &sc->sc_restarttask);
 
 	iwi_put_firmware(sc);
 	iwi_release_fw_dma(sc);
@@ -1102,6 +1090,7 @@ static int
 iwi_wme_update(struct ieee80211com *ic)
 {
 	struct iwi_softc *sc = ic->ic_ifp->if_softc;
+	struct ieee80211vap *vap = TAILQ_FIRST(&ic->ic_vaps);
 
 	/*
 	 * We may be called to update the WME parameters in
@@ -1111,7 +1100,9 @@ iwi_wme_update(struct ieee80211com *ic)
 	 * will get sent down to the adapter as part of the
 	 * work iwi_auth_and_assoc does.
 	 */
-	return iwi_queue_cmd(sc, IWI_SET_WME, 0);
+	if (vap->iv_state == IEEE80211_S_RUN)
+		(void) iwi_wme_setparams(sc, ic);
+	return (0);
 }
 
 static int
@@ -1559,7 +1550,7 @@ iwi_notification_intr(struct iwi_softc *
 				 * to disassociate and then on completion we'll
 				 * kick the state machine to scan.
 				 */
-				iwi_queue_cmd(sc, IWI_DISASSOC, 1);
+				//iwi_disassociate(sc, 0);
 			}
 		}
 		break;
@@ -1678,7 +1669,7 @@ iwi_intr(void *arg)
 
 	if (r & IWI_INTR_FATAL_ERROR) {
 		device_printf(sc->sc_dev, "firmware error\n");
-		taskqueue_enqueue(sc->sc_tq2, &sc->sc_restarttask);
+		taskqueue_enqueue(taskqueue_swi, &sc->sc_restarttask);
 
 		sc->flags &= ~IWI_FLAG_BUSY;
 		sc->sc_busy_timer = 0;
@@ -1691,7 +1682,7 @@ iwi_intr(void *arg)
 	}
 
 	if (r & IWI_INTR_RADIO_OFF)
-		taskqueue_enqueue(sc->sc_tq, &sc->sc_radiofftask);
+		taskqueue_enqueue(taskqueue_swi, &sc->sc_radiofftask);
 
 	if (r & IWI_INTR_CMD_DONE) {
 		sc->flags &= ~IWI_FLAG_BUSY;
@@ -2011,14 +2002,14 @@ iwi_watchdog(void *arg)
 		if (--sc->sc_tx_timer == 0) {
 			if_printf(ifp, "device timeout\n");
 			ifp->if_oerrors++;
-			taskqueue_enqueue(sc->sc_tq2, &sc->sc_restarttask);
+			taskqueue_enqueue(taskqueue_swi, &sc->sc_restarttask);
 		}
 	}
 	if (sc->sc_state_timer > 0) {
 		if (--sc->sc_state_timer == 0) {
 			if_printf(ifp, "firmware stuck in state %d, resetting\n",
 			    sc->fw_state);
-			taskqueue_enqueue(sc->sc_tq2, &sc->sc_restarttask);
+			taskqueue_enqueue(taskqueue_swi, &sc->sc_restarttask);
 			if (sc->fw_state == IWI_FW_SCANNING) {
 				struct ieee80211com *ic = ifp->if_l2com;
 				ieee80211_cancel_scan(TAILQ_FIRST(&ic->ic_vaps));
@@ -2029,7 +2020,7 @@ iwi_watchdog(void *arg)
 	if (sc->sc_busy_timer > 0) {
 		if (--sc->sc_busy_timer == 0) {
 			if_printf(ifp, "firmware command timeout, resetting\n");
-			taskqueue_enqueue(sc->sc_tq2, &sc->sc_restarttask);
+			taskqueue_enqueue(taskqueue_swi, &sc->sc_restarttask);
 		}
 	}
 	callout_reset(&sc->sc_wdtimer, hz, iwi_watchdog, sc);
@@ -3068,9 +3059,6 @@ iwi_init_locked(struct iwi_softc *sc)
 
 	IWI_STATE_BEGIN(sc, IWI_FW_LOADING);
 
-	taskqueue_unblock(sc->sc_tq);
-	taskqueue_unblock(sc->sc_tq2);
-
 	if (iwi_reset(sc) != 0) {
 		device_printf(sc->sc_dev, "could not reset adapter\n");
 		goto fail;
@@ -3165,8 +3153,6 @@ iwi_stop_locked(void *priv)
 
 	ifp->if_drv_flags &= ~(IFF_DRV_RUNNING | IFF_DRV_OACTIVE);
 
-	taskqueue_block(sc->sc_tq);
-	taskqueue_block(sc->sc_tq2);
 	if (sc->sc_softled) {
 		callout_stop(&sc->sc_ledtimer);
 		sc->sc_blinking = 0;
@@ -3249,7 +3235,7 @@ iwi_rfkill_poll(void *arg)
 	 */
 	if (!iwi_getrfkill(sc)) {
 		taskqueue_unblock(sc->sc_tq);
-		taskqueue_enqueue(sc->sc_tq, &sc->sc_radiontask);
+		taskqueue_enqueue(taskqueue_swi, &sc->sc_radiontask);
 		return;
 	}
 	callout_reset(&sc->sc_rftimer, 2*hz, iwi_rfkill_poll, sc);
@@ -3515,79 +3501,6 @@ iwi_ledattach(struct iwi_softc *sc)
 }
 
 static void
-iwi_ops(void *arg0, int npending)
-{
-	static const char *opnames[] = {
-		[IWI_CMD_FREE]		= "FREE",
-		[IWI_DISASSOC]		= "DISASSOC",
-		[IWI_SET_WME]		= "SET_WME",
-	};
-	struct iwi_softc *sc = arg0;
-	struct ifnet *ifp = sc->sc_ifp;
-	struct ieee80211com *ic = ifp->if_l2com;
-	struct ieee80211vap *vap = TAILQ_FIRST(&ic->ic_vaps);
-	IWI_LOCK_DECL;
-	int cmd;
-	unsigned long arg;
-
-again:
-	IWI_CMD_LOCK(sc);
-	cmd = sc->sc_cmd[sc->sc_cmd_cur];
-	if (cmd == IWI_CMD_FREE) {
-		/* No more commands to process */
-		IWI_CMD_UNLOCK(sc);
-		return;
-	}
-	arg = sc->sc_arg[sc->sc_cmd_cur];
-	sc->sc_cmd[sc->sc_cmd_cur] = IWI_CMD_FREE;	/* free the slot */
-	sc->sc_cmd_cur = (sc->sc_cmd_cur + 1) % IWI_CMD_MAXOPS;
-	IWI_CMD_UNLOCK(sc);
-
-	IWI_LOCK(sc);
-	while  (sc->fw_state != IWI_FW_IDLE || (sc->flags & IWI_FLAG_BUSY)) {
-		msleep(sc, &sc->sc_mtx, 0, "iwicmd", hz/10);
-	}
-
-	if (!(ifp->if_drv_flags & IFF_DRV_RUNNING)) {
-		IWI_UNLOCK(sc);
-		return;
-	}
-
-	DPRINTF(("%s: %s arg %lu\n", __func__, opnames[cmd], arg));
-	switch (cmd) {
-	case IWI_DISASSOC:
-		iwi_disassociate(sc, 0);
-		break;
-	case IWI_SET_WME:
-		if (vap->iv_state == IEEE80211_S_RUN)
-			(void) iwi_wme_setparams(sc, ic);
-		break;
-	}
-	IWI_UNLOCK(sc);
-
-	/* Take another pass */
-	goto again;
-}
-
-static int
-iwi_queue_cmd(struct iwi_softc *sc, int cmd, unsigned long arg)
-{
-	IWI_CMD_LOCK(sc);
-	if (sc->sc_cmd[sc->sc_cmd_next] != 0) {
-		IWI_CMD_UNLOCK(sc);
-		DPRINTF(("%s: command %d dropped\n", __func__, cmd));
-		return (EBUSY);
-	}
-
-	sc->sc_cmd[sc->sc_cmd_next] = cmd;
-	sc->sc_arg[sc->sc_cmd_next] = arg;
-	sc->sc_cmd_next = (sc->sc_cmd_next + 1) % IWI_CMD_MAXOPS;
-	taskqueue_enqueue(sc->sc_tq, &sc->sc_opstask);
-	IWI_CMD_UNLOCK(sc);
-	return (0);
-}
-
-static void
 iwi_scan_start(struct ieee80211com *ic)
 {
 	/* ignore */

Modified: user/thompsa/vaptq/sys/dev/iwi/if_iwivar.h
==============================================================================
--- user/thompsa/vaptq/sys/dev/iwi/if_iwivar.h	Fri Apr 17 16:07:13 2009	(r191207)
+++ user/thompsa/vaptq/sys/dev/iwi/if_iwivar.h	Fri Apr 17 16:15:56 2009	(r191208)
@@ -131,12 +131,8 @@ struct iwi_softc {
 	device_t		sc_dev;
 
 	struct mtx		sc_mtx;
-	struct mtx		sc_cmdlock;
-	char			sc_cmdname[12];	/* e.g. "iwi0_cmd" */
 	uint8_t			sc_mcast[IEEE80211_ADDR_LEN];
 	struct unrhdr		*sc_unr;
-	struct taskqueue	*sc_tq;		/* private task queue */
-	struct taskqueue	*sc_tq2;	/* reset task queue */
 
 	uint32_t		flags;
 #define IWI_FLAG_FW_INITED	(1 << 0)
@@ -196,7 +192,6 @@ struct iwi_softc {
 	struct task		sc_radiontask;	/* radio on processing */
 	struct task		sc_radiofftask;	/* radio off processing */
 	struct task		sc_restarttask;	/* restart adapter processing */
-	struct task		sc_opstask;	/* scan / auth processing */
 
 	unsigned int		sc_softled : 1,	/* enable LED gpio status */
 				sc_ledstate: 1,	/* LED on/off state */
@@ -218,15 +213,6 @@ struct iwi_softc {
 	int			sc_state_timer;	/* firmware state timer */
 	int			sc_busy_timer;	/* firmware cmd timer */
 
-#define	IWI_CMD_MAXOPS		10
-	int			sc_cmd[IWI_CMD_MAXOPS];
-	unsigned long		sc_arg[IWI_CMD_MAXOPS];
-	int			sc_cmd_cur;	/* current queued scan task */
-	int			sc_cmd_next;	/* last queued scan task */
-#define	IWI_CMD_FREE		0		/* for marking slots unused */
-#define	IWI_DISASSOC		1
-#define	IWI_SET_WME		2
-
 	struct iwi_rx_radiotap_header sc_rxtap;
 	int			sc_rxtap_len;
 
@@ -270,11 +256,3 @@ struct iwi_softc {
 	if (!__waslocked)			\
 		mtx_unlock(&(sc)->sc_mtx);	\
 } while (0)
-#define	IWI_CMD_LOCK_INIT(sc) do { \
-	snprintf((sc)->sc_cmdname, sizeof((sc)->sc_cmdname), "%s_cmd", \
-		device_get_nameunit((sc)->sc_dev)); \
-	mtx_init(&(sc)->sc_cmdlock, (sc)->sc_cmdname, NULL, MTX_DEF); \
-} while (0)
-#define	IWI_CMD_LOCK_DESTROY(sc)	mtx_destroy(&(sc)->sc_cmdlock)
-#define	IWI_CMD_LOCK(sc)		mtx_lock(&(sc)->sc_cmdlock)
-#define	IWI_CMD_UNLOCK(sc)		mtx_unlock(&(sc)->sc_cmdlock)

Modified: user/thompsa/vaptq/sys/dev/iwn/if_iwn.c
==============================================================================
--- user/thompsa/vaptq/sys/dev/iwn/if_iwn.c	Fri Apr 17 16:07:13 2009	(r191207)
+++ user/thompsa/vaptq/sys/dev/iwn/if_iwn.c	Fri Apr 17 16:15:56 2009	(r191208)
@@ -182,8 +182,9 @@ static void 	iwn_scan_end(struct ieee802
 static void 	iwn_set_channel(struct ieee80211com *);
 static void 	iwn_scan_curchan(struct ieee80211_scan_state *, unsigned long);
 static void 	iwn_scan_mindwell(struct ieee80211_scan_state *);
-static void 	iwn_ops(void *, int);
-static int 	iwn_queue_cmd( struct iwn_softc *, int, int, int);
+static void	iwn_hwreset(void *, int);
+static void	iwn_radioon(void *, int);
+static void	iwn_radiooff(void *, int);
 static void	iwn_bpfattach(struct iwn_softc *);
 static void	iwn_sysctlattach(struct iwn_softc *);
 
@@ -212,7 +213,6 @@ enum {
 		printf(fmt, __VA_ARGS__);		\
 } while (0)
 
-static const char *iwn_ops_str(int);
 static const char *iwn_intr_str(uint8_t);
 #else
 #define DPRINTF(sc, m, fmt, ...) do { (void) sc; } while (0)
@@ -295,19 +295,10 @@ iwn_attach(device_t dev)
 	}
 
 	IWN_LOCK_INIT(sc);
-	IWN_CMD_LOCK_INIT(sc);
 	callout_init_mtx(&sc->sc_timer_to, &sc->sc_mtx, 0);
-
-        /*
-         * Create the taskqueues used by the driver. Primarily
-         * sc_tq handles most the task
-         */
-        sc->sc_tq = taskqueue_create("iwn_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_ops_task, 0, iwn_ops, sc );
+        TASK_INIT(&sc->sc_reinit_task, 0, iwn_hwreset, sc );
+        TASK_INIT(&sc->sc_radioon_task, 0, iwn_radioon, sc );
+        TASK_INIT(&sc->sc_radiooff_task, 0, iwn_radiooff, sc );
 
 	/*
 	 * Put adapter into a known state.
@@ -473,6 +464,10 @@ iwn_cleanup(device_t dev)
 	struct ieee80211com *ic = ifp->if_l2com;
 	int i;
 
+	taskqueue_drain(taskqueue_swi, &sc->sc_reinit_task);
+	taskqueue_drain(taskqueue_swi, &sc->sc_radioon_task);
+	taskqueue_drain(taskqueue_swi, &sc->sc_radiooff_task);
+
 	if (ifp != NULL) {
 		iwn_stop(sc);
 		callout_drain(&sc->sc_timer_to);
@@ -497,8 +492,6 @@ iwn_cleanup(device_t dev)
 		bus_release_resource(dev, SYS_RES_MEMORY, sc->mem_rid, sc->mem);
 	if (ifp != NULL)
 		if_free(ifp);
-	taskqueue_free(sc->sc_tq);
-	IWN_CMD_LOCK_DESTROY(sc);
 	IWN_LOCK_DESTROY(sc);
 	return 0;
 }
@@ -1807,16 +1800,16 @@ iwn_intr(void *arg)
 		device_printf(sc->sc_dev, "RF switch: radio %s\n",
 		    (tmp & IWN_GPIO_RF_ENABLED) ? "enabled" : "disabled");
 		if (tmp & IWN_GPIO_RF_ENABLED)
-			iwn_queue_cmd(sc, IWN_RADIO_ENABLE, 0, IWN_QUEUE_CLEAR);
+			taskqueue_enqueue(taskqueue_swi, &sc->sc_radioon_task);
 		else
-			iwn_queue_cmd(sc, IWN_RADIO_DISABLE, 0, IWN_QUEUE_CLEAR);
+			taskqueue_enqueue(taskqueue_swi, &sc->sc_radiooff_task);
 	}
 	if (r1 & IWN_CT_REACHED)
 		device_printf(sc->sc_dev, "critical temperature reached!\n");
 	if (r1 & (IWN_SW_ERROR | IWN_HW_ERROR)) {
 		device_printf(sc->sc_dev, "error, INTR=%b STATUS=0x%x\n",
 		    r1, IWN_INTR_BITS, r2);
-		iwn_queue_cmd(sc, IWN_REINIT, 0, IWN_QUEUE_CLEAR);
+		taskqueue_enqueue(taskqueue_swi, &sc->sc_reinit_task);
 		goto done;
 	}
 	if ((r1 & (IWN_RX_INTR | IWN_SW_RX_INTR)) || (r2 & IWN_RX_STATUS_INTR))
@@ -2345,7 +2338,7 @@ iwn_watchdog(struct iwn_softc *sc)
 		struct ifnet *ifp = sc->sc_ifp;
 
 		if_printf(ifp, "device timeout\n");
-		iwn_queue_cmd(sc, IWN_REINIT, 0, IWN_QUEUE_CLEAR);
+		taskqueue_enqueue(taskqueue_swi, &sc->sc_reinit_task);
 	}
 }
 
@@ -4250,9 +4243,6 @@ iwn_stop_locked(struct iwn_softc *sc)
 	IWN_WRITE(sc, IWN_INTR, 0xffffffff);
 	IWN_WRITE(sc, IWN_INTR_STATUS, 0xffffffff);
 
-	/* Clear any commands left in the taskq command buffer */
-	memset(sc->sc_cmd, 0, sizeof(sc->sc_cmd));
-
 	/* reset all Tx rings */
 	for (i = 0; i < IWN_NTXQUEUES; i++)
 		iwn_reset_tx_ring(sc, &sc->txq[i]);
@@ -4364,94 +4354,36 @@ iwn_scan_mindwell(struct ieee80211_scan_
 	/* NB: don't try to abort scan; wait for firmware to finish */
 }
 
-/*
- * Carry out work in the taskq context.
- */
 static void
-iwn_ops(void *arg0, int pending)
+iwn_hwreset(void *arg0, int pending)
 {
 	struct iwn_softc *sc = arg0;
 	struct ifnet *ifp = sc->sc_ifp;
 	struct ieee80211com *ic = ifp->if_l2com;
-	struct ieee80211vap *vap;
-	int cmd, arg;
 
-	for (;;) {
-		IWN_CMD_LOCK(sc);
-		cmd = sc->sc_cmd[sc->sc_cmd_cur];
-		if (cmd == 0) {
-			/* No more commands to process */
-			IWN_CMD_UNLOCK(sc);
-			return;
-		}
-		if ((sc->sc_ifp->if_drv_flags & IFF_DRV_RUNNING) == 0 &&
-		    cmd != IWN_RADIO_ENABLE ) {
-			IWN_CMD_UNLOCK(sc);
-			return;
-		}
-		arg = sc->sc_cmd_arg[sc->sc_cmd_cur];
-		sc->sc_cmd[sc->sc_cmd_cur] = 0;		/* free the slot */
-		sc->sc_cmd_cur = (sc->sc_cmd_cur + 1) % IWN_CMD_MAXOPS;
-		IWN_CMD_UNLOCK(sc);
-
-		IWN_LOCK(sc);		/* NB: sync debug printfs on smp */
-		DPRINTF(sc, IWN_DEBUG_OPS, "%s: %s (cmd 0x%x)\n",
-		    __func__, iwn_ops_str(cmd), cmd);
-
-		vap = TAILQ_FIRST(&ic->ic_vaps);	/* XXX */
-		switch (cmd) {
-		case IWN_REINIT:
-			IWN_UNLOCK(sc);
-			iwn_init(sc);
-			IWN_LOCK(sc);
-			ieee80211_notify_radio(ic, 1);
-			break;
-		case IWN_RADIO_ENABLE:
-			KASSERT(sc->fw_fp != NULL,
-			    ("Fware Not Loaded, can't load from tq"));
-			IWN_UNLOCK(sc);
-			iwn_init(sc);
-			IWN_LOCK(sc);
-			break;
-		case IWN_RADIO_DISABLE:
-			ieee80211_notify_radio(ic, 0);
-			iwn_stop_locked(sc);
-			break;
-		}
-		IWN_UNLOCK(sc);
-	}
+	iwn_init(sc);
+	ieee80211_notify_radio(ic, 1);
 }
 
-/*
- * Queue a command for execution in the taskq thread.
- * This is needed as the net80211 callbacks do not allow
- * sleeping, since we need to sleep to confirm commands have
- * been processed by the firmware, we must defer execution to 
- * a sleep enabled thread.
- */
-static int
-iwn_queue_cmd(struct iwn_softc *sc, int cmd, int arg, int clear)
+static void
+iwn_radioon(void *arg0, int pending)
 {
-	IWN_CMD_LOCK(sc);
-	if (clear) {
-		sc->sc_cmd[0] = cmd;
-		sc->sc_cmd_arg[0] = arg;
-		sc->sc_cmd_cur = 0;
-		sc->sc_cmd_next = 1;
-	} else {
-		if (sc->sc_cmd[sc->sc_cmd_next] != 0) {
-			IWN_CMD_UNLOCK(sc);
-			DPRINTF(sc, IWN_DEBUG_ANY, "%s: command %d dropped\n",
-			    __func__, cmd);
-			return EBUSY;
-		}
-		sc->sc_cmd[sc->sc_cmd_next] = cmd;
-		sc->sc_cmd_arg[sc->sc_cmd_next] = arg;
-		sc->sc_cmd_next = (sc->sc_cmd_next + 1) % IWN_CMD_MAXOPS;
-	}
-	taskqueue_enqueue(sc->sc_tq, &sc->sc_ops_task);
-	IWN_CMD_UNLOCK(sc);
-	return 0;
+	struct iwn_softc *sc = arg0;
+
+	iwn_init(sc);
+}
+
+static void
+iwn_radiooff(void *arg0, int pending)
+{
+	struct iwn_softc *sc = arg0;
+	struct ifnet *ifp = sc->sc_ifp;
+	struct ieee80211com *ic = ifp->if_l2com;
+
+	IWN_LOCK(sc);
+	ieee80211_notify_radio(ic, 0);
+	iwn_stop_locked(sc);
+	IWN_UNLOCK(sc);
 }
 
 static void
@@ -4486,17 +4418,6 @@ iwn_sysctlattach(struct iwn_softc *sc)
 
 #ifdef IWN_DEBUG
 static const char *
-iwn_ops_str(int cmd)
-{
-	switch (cmd) {
-	case IWN_RADIO_ENABLE:	return "RADIO_ENABLE";
-	case IWN_RADIO_DISABLE:	return "RADIO_DISABLE";
-	case IWN_REINIT:	return "REINIT";
-	}
-	return "UNKNOWN COMMAND";
-}
-
-static const char *
 iwn_intr_str(uint8_t cmd)
 {
 	switch (cmd) {

Modified: user/thompsa/vaptq/sys/dev/iwn/if_iwnvar.h
==============================================================================
--- user/thompsa/vaptq/sys/dev/iwn/if_iwnvar.h	Fri Apr 17 16:07:13 2009	(r191207)
+++ user/thompsa/vaptq/sys/dev/iwn/if_iwnvar.h	Fri Apr 17 16:15:56 2009	(r191208)
@@ -180,26 +180,10 @@ struct iwn_softc {
 	void 			*sc_ih;
 	bus_size_t		sc_sz;
 
-        /* command queue related variables */
-#define IWN_RADIO_ENABLE	(1<<0)
-#define IWN_RADIO_DISABLE	(1<<1)
-#define IWN_REINIT		(1<<2)
-#define IWN_CMD_MAXOPS		10
-	/* command queuing request type */
-#define IWN_QUEUE_NORMAL	0
-#define IWN_QUEUE_CLEAR		1
-        int                     sc_cmd[IWN_CMD_MAXOPS];
-        int                     sc_cmd_arg[IWN_CMD_MAXOPS];
-        int                     sc_cmd_cur;    /* current queued task */
-        int                     sc_cmd_next;   /* last queued task */
-        struct mtx              sc_cmdlock;
-
-	/* Task queues used to control the driver */
-	struct taskqueue         *sc_tq; /* Main command task queue */
-
 	/* Tasks used by the driver */
-	struct task             sc_ops_task;	/* deferred ops */
-	struct task		sc_bmiss_task;	/* beacon miss */
+	struct task             sc_reinit_task;
+	struct task		sc_radioon_task;
+	struct task		sc_radiooff_task;
 
 	/* Thermal calibration */
 	int			calib_cnt;
@@ -227,9 +211,3 @@ struct iwn_softc {
 #define IWN_LOCK_ASSERT(_sc)		mtx_assert(&(_sc)->sc_mtx, MA_OWNED)
 #define IWN_UNLOCK(_sc)			mtx_unlock(&(_sc)->sc_mtx)
 #define IWN_LOCK_DESTROY(_sc)		mtx_destroy(&(_sc)->sc_mtx)
-#define IWN_CMD_LOCK_INIT(_sc) \
-	mtx_init(&(_sc)->sc_cmdlock, device_get_nameunit((_sc)->sc_dev), \
-	     NULL, MTX_DEF);
-#define IWN_CMD_LOCK_DESTROY(_sc)	mtx_destroy(&(_sc)->sc_cmdlock)
-#define IWN_CMD_LOCK(_sc)		mtx_lock(&(_sc)->sc_cmdlock)
-#define IWN_CMD_UNLOCK(_sc)		mtx_unlock(&(_sc)->sc_cmdlock)

Modified: user/thompsa/vaptq/sys/dev/wpi/if_wpi.c
==============================================================================
--- user/thompsa/vaptq/sys/dev/wpi/if_wpi.c	Fri Apr 17 16:07:13 2009	(r191207)
+++ user/thompsa/vaptq/sys/dev/wpi/if_wpi.c	Fri Apr 17 16:15:56 2009	(r191208)
@@ -194,9 +194,7 @@ static void	wpi_tx_intr(struct wpi_softc
 static void	wpi_cmd_intr(struct wpi_softc *, struct wpi_rx_desc *);
 static void	wpi_notif_intr(struct wpi_softc *);
 static void	wpi_intr(void *);
-static void	wpi_ops(void *, int);
 static uint8_t	wpi_plcp_signal(int);
-static int	wpi_queue_cmd(struct wpi_softc *, int, int, int);
 static void	wpi_watchdog(void *);
 static int	wpi_tx_data(struct wpi_softc *, struct mbuf *,
 		    struct ieee80211_node *, int);
@@ -229,6 +227,8 @@ static int	wpi_config(struct wpi_softc *
 static void	wpi_stop_master(struct wpi_softc *);
 static int	wpi_power_up(struct wpi_softc *);
 static int	wpi_reset(struct wpi_softc *);
+static void	wpi_hwreset(void *, int);
+static void	wpi_rfreset(void *, int);
 static void	wpi_hw_config(struct wpi_softc *);
 static void	wpi_init(void *);
 static void	wpi_init_locked(struct wpi_softc *, int);
@@ -513,20 +513,11 @@ wpi_attach(device_t dev)
 		}
 	}
 
-	/*
-	 * Create the taskqueues used by the driver. Primarily
-	 * sc_tq handles most the task
-	 */
-	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));
-
 	/* Create the tasks that can be queued */
-	TASK_INIT(&sc->sc_opstask, 0, wpi_ops, sc);
+	TASK_INIT(&sc->sc_restarttask, 0, wpi_hwreset, sc);
+	TASK_INIT(&sc->sc_radiotask, 0, wpi_rfreset, sc);
 
 	WPI_LOCK_INIT(sc);
-	WPI_CMD_LOCK_INIT(sc);
 
 	callout_init_mtx(&sc->calib_to, &sc->sc_mtx, 0);
 	callout_init_mtx(&sc->watchdog_to, &sc->sc_mtx, 0);
@@ -730,6 +721,9 @@ wpi_detach(device_t dev)
 	struct ieee80211com *ic = ifp->if_l2com;
 	int ac;
 
+	taskqueue_drain(taskqueue_swi, &sc->sc_restarttask);
+	taskqueue_drain(taskqueue_swi, &sc->sc_radiotask);
+
 	if (ifp != NULL) {
 		wpi_stop(sc);
 		callout_drain(&sc->watchdog_to);
@@ -767,10 +761,7 @@ wpi_detach(device_t dev)
 	if (ifp != NULL)
 		if_free(ifp);
 
-	taskqueue_free(sc->sc_tq);
-
 	WPI_LOCK_DESTROY(sc);
-	WPI_CMD_LOCK_DESTROY(sc);
 
 	return 0;
 }
@@ -1796,7 +1787,7 @@ wpi_intr(void *arg)
 		device_printf(sc->sc_dev, "fatal firmware error\n");
 		DPRINTFN(6,("(%s)\n", (r & WPI_SW_ERROR) ? "(Software Error)" :
 				"(Hardware Error)"));
-		wpi_queue_cmd(sc, WPI_RESTART, 0, WPI_QUEUE_CLEAR);
+		taskqueue_enqueue(taskqueue_swi, &sc->sc_restarttask);
 		sc->flags &= ~WPI_FLAG_BUSY;
 		WPI_UNLOCK(sc);
 		return;
@@ -3187,12 +3178,6 @@ wpi_stop_locked(struct wpi_softc *sc)
 	WPI_WRITE(sc, WPI_INTR_STATUS, 0xff);
 	WPI_WRITE(sc, WPI_INTR_STATUS, 0x00070000);
 
-	/* Clear any commands left in the command buffer */
-	memset(sc->sc_cmd, 0, sizeof(sc->sc_cmd));
-	memset(sc->sc_cmd_arg, 0, sizeof(sc->sc_cmd_arg));
-	sc->sc_cmd_cur = 0;
-	sc->sc_cmd_next = 0;
-
 	wpi_mem_lock(sc);
 	wpi_mem_write(sc, WPI_MEM_MODE, 0);
 	wpi_mem_unlock(sc);
@@ -3561,6 +3546,7 @@ wpi_set_channel(struct ieee80211com *ic)
 {
 	struct ifnet *ifp = ic->ic_ifp;
 	struct wpi_softc *sc = ifp->if_softc;
+	int error;
 
 	/*
 	 * Only need to set the channel in Monitor mode. AP scanning and auth
@@ -3604,83 +3590,24 @@ wpi_scan_mindwell(struct ieee80211_scan_
 	/* NB: don't try to abort scan; wait for firmware to finish */
 }
 
-/**
- * The ops function is called to perform some actual work.
- * because we can't sleep from any of the ic callbacks, we queue an
- * op task with wpi_queue_cmd and have the taskqueue process that task.
- * The task that gets cued is a op task, which ends up calling this function.
- */
 static void
-wpi_ops(void *arg0, int pending)
+wpi_hwreset(void *arg, int pending)
 {
-	struct wpi_softc *sc = arg0;
-	struct ifnet *ifp = sc->sc_ifp;
-	struct ieee80211com *ic = ifp->if_l2com;
-	int cmd, arg, error;
-	struct ieee80211vap *vap = TAILQ_FIRST(&ic->ic_vaps);
+	struct wpi_softc *sc = arg;
 
-again:
-	WPI_CMD_LOCK(sc);
-	cmd = sc->sc_cmd[sc->sc_cmd_cur];
-	arg = sc->sc_cmd_arg[sc->sc_cmd_cur];
-
-	if (cmd == 0) {
-		/* No more commands to process */
-		WPI_CMD_UNLOCK(sc);
-		return;
-	}
-	sc->sc_cmd[sc->sc_cmd_cur] = 0; /* free the slot */
-	sc->sc_cmd_arg[sc->sc_cmd_cur] = 0; /* free the slot */
-	sc->sc_cmd_cur = (sc->sc_cmd_cur + 1) % WPI_CMD_MAXOPS;
-	WPI_CMD_UNLOCK(sc);
 	WPI_LOCK(sc);
-
-	DPRINTFN(WPI_DEBUG_OPS,("wpi_ops: command: %d\n", cmd));
-
-	switch (cmd) {
-	case WPI_RESTART:
-		wpi_init_locked(sc, 0);
-
-	case WPI_RF_RESTART:
-		wpi_rfkill_resume(sc);
-	}
+	wpi_init_locked(sc, 0);
 	WPI_UNLOCK(sc);
 }
 
-/**
- * queue a command for later execution in a different thread.
- * This is needed as the net80211 callbacks do not allow
- * sleeping, since we need to sleep to confirm commands have
- * been processed by the firmware, we must defer execution to
- * a sleep enabled thread.
- */
-static int
-wpi_queue_cmd(struct wpi_softc *sc, int cmd, int arg, int flush)
+static void
+wpi_rfreset(void *arg, int pending)
 {
-	WPI_CMD_LOCK(sc);
-
-	if (flush) {
-		memset(sc->sc_cmd, 0, sizeof (sc->sc_cmd));
-		memset(sc->sc_cmd_arg, 0, sizeof (sc->sc_cmd_arg));
-		sc->sc_cmd_cur = 0;
-		sc->sc_cmd_next = 0;
-	}
-
-	if (sc->sc_cmd[sc->sc_cmd_next] != 0) {
-		WPI_CMD_UNLOCK(sc);
-		DPRINTF(("%s: command %d dropped\n", __func__, cmd));
-		return (EBUSY);
-	}
-
-	sc->sc_cmd[sc->sc_cmd_next] = cmd;
-	sc->sc_cmd_arg[sc->sc_cmd_next] = arg;
-	sc->sc_cmd_next = (sc->sc_cmd_next + 1) % WPI_CMD_MAXOPS;
-
-	taskqueue_enqueue(sc->sc_tq, &sc->sc_opstask);
-
-	WPI_CMD_UNLOCK(sc);
+	struct wpi_softc *sc = arg;
 
-	return 0;
+	WPI_LOCK(sc);
+	wpi_rfkill_resume(sc);
+	WPI_UNLOCK(sc);
 }
 
 /*
@@ -3725,7 +3652,7 @@ wpi_watchdog(void *arg)
 		}
 
 		device_printf(sc->sc_dev, "Hardware Switch Enabled\n");
-		wpi_queue_cmd(sc, WPI_RF_RESTART, 0, WPI_QUEUE_CLEAR);
+		taskqueue_enqueue(taskqueue_swi, &sc->sc_radiotask);
 		return;
 	}
 
@@ -3733,7 +3660,7 @@ wpi_watchdog(void *arg)
 		if (--sc->sc_tx_timer == 0) {
 			device_printf(sc->sc_dev,"device timeout\n");
 			ifp->if_oerrors++;
-			wpi_queue_cmd(sc, WPI_RESTART, 0, WPI_QUEUE_CLEAR);
+			taskqueue_enqueue(taskqueue_swi, &sc->sc_restarttask);
 		}
 	}
 	if (sc->sc_scan_timer > 0) {
@@ -3743,7 +3670,7 @@ wpi_watchdog(void *arg)
 		if (--sc->sc_scan_timer == 0 && vap != NULL) {
 			device_printf(sc->sc_dev,"scan timeout\n");
 			ieee80211_cancel_scan(vap);
-			wpi_queue_cmd(sc, WPI_RESTART, 0, WPI_QUEUE_CLEAR);
+			taskqueue_enqueue(taskqueue_swi, &sc->sc_restarttask);
 		}
 	}
 

Modified: user/thompsa/vaptq/sys/dev/wpi/if_wpivar.h
==============================================================================
--- user/thompsa/vaptq/sys/dev/wpi/if_wpivar.h	Fri Apr 17 16:07:13 2009	(r191207)
+++ user/thompsa/vaptq/sys/dev/wpi/if_wpivar.h	Fri Apr 17 16:15:56 2009	(r191208)
@@ -144,9 +144,8 @@ struct wpi_softc {
 	 */
 	uint32_t		flags;
 #define WPI_FLAG_HW_RADIO_OFF	(1 << 0)
-#define WPI_FLAG_SCANNING	(1 << 1)
-#define WPI_FLAG_BUSY		(1 << 2)
-#define WPI_FLAG_AUTH		(1 << 3)
+#define WPI_FLAG_BUSY		(1 << 1)
+#define WPI_FLAG_AUTH		(1 << 2)
 
 	/* shared area */
 	struct wpi_dma_info	shared_dma;
@@ -193,29 +192,9 @@ struct wpi_softc {
 	/* firmware DMA transfer */
 	struct wpi_dma_info	fw_dma;
 
-	/* command queue related variables */
-#define WPI_RESTART		(1<<0)
-#define WPI_RF_RESTART		(1<<1)
-#define WPI_CMD_MAXOPS		10
-	/* command queuing request type */
-#define WPI_QUEUE_NORMAL	0
-#define WPI_QUEUE_CLEAR		1
-	int                     sc_cmd[WPI_CMD_MAXOPS];
-	int                     sc_cmd_arg[WPI_CMD_MAXOPS];
-	int                     sc_cmd_cur;    /* current queued scan task */
-	int                     sc_cmd_next;   /* last queued scan task */
-	struct mtx              sc_cmdlock;
-
-	/* Task queues used to control the driver */
-	struct taskqueue	*sc_tq;		/* Main command task queue */
-	struct taskqueue	*sc_tq2;	/* firmware reset task queue */
-
 	/* Tasks used by the driver */
-	struct task		sc_radioontask;	/* enable rf transmitter task*/
-	struct task		sc_radioofftask;/* disable rf transmitter task*/
-	struct task		sc_opstask;	/* operation handling task */
 	struct task		sc_restarttask;	/* reset firmware task */
-	struct task		sc_bmiss_task;	/* beacon miss */
+	struct task		sc_radiotask;	/* reset rf task */
 
        /* Eeprom info */
 	uint8_t			cap;
@@ -232,10 +211,3 @@ struct wpi_softc {
 #define WPI_UNLOCK(_sc)		mtx_unlock(&(_sc)->sc_mtx)
 #define WPI_LOCK_ASSERT(sc)     mtx_assert(&(sc)->sc_mtx, MA_OWNED)
 #define WPI_LOCK_DESTROY(_sc)	mtx_destroy(&(_sc)->sc_mtx)
-
-#define WPI_CMD_LOCK_INIT(_sc)  \
-        mtx_init(&(_sc)->sc_cmdlock, device_get_nameunit((_sc)->sc_dev), \
-	    NULL, MTX_DEF)
-#define WPI_CMD_LOCK_DESTROY(_sc)        mtx_destroy(&(_sc)->sc_cmdlock)
-#define WPI_CMD_LOCK(_sc)                mtx_lock(&(_sc)->sc_cmdlock)
-#define WPI_CMD_UNLOCK(_sc)              mtx_unlock(&(_sc)->sc_cmdlock)



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200904171615.n3HGFuji027525>