svn commit: r191045 - user/thompsa/vaptq/sys/net80211

Andrew Thompson thompsa at FreeBSD.org
Mon Apr 13 22:09:11 PDT 2009


Author: thompsa
Date: Tue Apr 14 05:09:09 2009
New Revision: 191045
URL: http://svn.freebsd.org/changeset/base/191045

Log:
  Call markwaiting() from the taskqueue thread to ensure other vaps are silenced,
  this allows us to remove the forcesync on INIT transitions.

Modified:
  user/thompsa/vaptq/sys/net80211/ieee80211_proto.c

Modified: user/thompsa/vaptq/sys/net80211/ieee80211_proto.c
==============================================================================
--- user/thompsa/vaptq/sys/net80211/ieee80211_proto.c	Tue Apr 14 05:07:17 2009	(r191044)
+++ user/thompsa/vaptq/sys/net80211/ieee80211_proto.c	Tue Apr 14 05:09:09 2009	(r191045)
@@ -1491,7 +1491,7 @@ ieee80211_cac_completeswitch(struct ieee
  * and mark them as waiting for a scan to complete.  These vaps
  * will be brought up when the scan completes and the scanning vap
  * reaches RUN state by wakeupwaiting.
- * XXX if we do this in threads we can use sleep/wakeup.
+ * This is called from the state taskqueue.
  */
 static void
 markwaiting(struct ieee80211vap *vap0)
@@ -1515,6 +1515,7 @@ markwaiting(struct ieee80211vap *vap0)
  * Wakeup all vap's waiting for a scan to complete.  This is the
  * companion to markwaiting (above) and is used to coordinate
  * multiple vaps scanning.
+ * This is called from the state taskqueue.
  */
 static void
 wakeupwaiting(struct ieee80211vap *vap0)
@@ -1566,6 +1567,19 @@ ieee80211_newstate_cb_locked(struct ieee
 	IEEE80211_DPRINTF(vap, IEEE80211_MSG_STATE,
 	    "%s: %s arg %d\n", __func__, ieee80211_state_name[nstate], arg);
 
+	if (nstate == IEEE80211_S_SCAN && ostate != IEEE80211_S_INIT) {
+		/*
+		 * SCAN was forced; e.g. on beacon miss.  Force other running
+		 * vap's to INIT state and mark them as waiting for the scan to
+		 * complete.  This insures they don't interfere with our
+		 * scanning.  Since we are single threaded the vaps can not
+		 * transition again while we are executing.
+		 *
+		 * XXX not always right, assumes ap follows sta
+		 */
+		markwaiting(vap);
+	}
+
 	rc = vap->iv_newstate(vap, nstate, arg);
 	if (rc != 0 || vap->iv_state != nstate) {
 		if (rc == EINPROGRESS)
@@ -1642,10 +1656,17 @@ ieee80211_new_state_locked(struct ieee80
 	struct ieee80211com *ic = vap->iv_ic;
 	struct ieee80211vap *vp;
 	enum ieee80211_state ostate;
-	int forcesync, nrunning, nscanning, rc;
+	int nrunning, nscanning, rc;
 
 	IEEE80211_LOCK_ASSERT(ic);
 
+	/* Warn if the previous state hasn't completed. XXX Queue? */
+	if (vap->iv_state != vap->iv_nstate)
+		IEEE80211_DPRINTF(vap, IEEE80211_MSG_STATE,
+			     "%s: pending %s -> %s transition lost\n", __func__,
+			     ieee80211_state_name[vap->iv_state],
+			     ieee80211_state_name[vap->iv_nstate]);
+
 	nrunning = nscanning = 0;
 	/* XXX can track this state instead of calculating */
 	TAILQ_FOREACH(vp, &ic->ic_vaps, iv_next) {
@@ -1659,7 +1680,6 @@ ieee80211_new_state_locked(struct ieee80
 		}
 	}
 	ostate = vap->iv_state;
-	forcesync = 0;
 	IEEE80211_DPRINTF(vap, IEEE80211_MSG_STATE,
 	    "%s: %s -> %s (nrunning %d nscanning %d)\n", __func__,
 	    ieee80211_state_name[ostate], ieee80211_state_name[nstate],
@@ -1707,16 +1727,6 @@ ieee80211_new_state_locked(struct ieee80
 				}
 #endif
 			}
-		} else {
-			/*
-			 * SCAN was forced; e.g. on beacon miss.  Force
-			 * other running vap's to INIT state and mark
-			 * them as waiting for the scan to complete.  This
-			 * insures they don't interfere with our scanning.
-			 *
-			 * XXX not always right, assumes ap follows sta
-			 */
-			markwaiting(vap);
 		}
 		break;
 	case IEEE80211_S_RUN:
@@ -1759,26 +1769,15 @@ ieee80211_new_state_locked(struct ieee80
 			/* INIT -> INIT. nothing to do */
 			vap->iv_flags_ext &= ~IEEE80211_FEXT_SCANWAIT;
 		}
-		forcesync = 1;
 		/* fall thru... */
 	default:
 		break;
 	}
-	if (forcesync) {
-		/*
-		 * Complete the state transition synchronously, asserting that
-		 * the lock is not dropped.
-		 */
-		WITNESS_NORELEASE(IEEE80211_LOCK_OBJ(ic));
-		rc = ieee80211_newstate_cb_locked(vap, nstate, arg);
-		WITNESS_RELEASEOK(IEEE80211_LOCK_OBJ(ic));
-	} else {
-		/* defer the state change to a thread */
-		vap->iv_nstate = nstate;
-		vap->iv_nstate_arg = arg;
-		taskqueue_enqueue(ic->ic_tq, &vap->iv_nstate_task);
-		return (EINPROGRESS);
-	}
+	/* defer the state change to a thread */
+	vap->iv_nstate = nstate;
+	vap->iv_nstate_arg = arg;
+	taskqueue_enqueue(ic->ic_tq, &vap->iv_nstate_task);
+	return (EINPROGRESS);
 done:
 	return rc;
 }


More information about the svn-src-user mailing list