From owner-svn-src-user@FreeBSD.ORG Tue Apr 14 05:09:11 2009 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id F30171065670; Tue, 14 Apr 2009 05:09:10 +0000 (UTC) (envelope-from thompsa@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id E2DD18FC1A; Tue, 14 Apr 2009 05:09:10 +0000 (UTC) (envelope-from thompsa@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n3E599VL095136; Tue, 14 Apr 2009 05:09:09 GMT (envelope-from thompsa@svn.freebsd.org) Received: (from thompsa@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n3E599lm095135; Tue, 14 Apr 2009 05:09:09 GMT (envelope-from thompsa@svn.freebsd.org) Message-Id: <200904140509.n3E599lm095135@svn.freebsd.org> From: Andrew Thompson Date: Tue, 14 Apr 2009 05:09:09 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r191045 - user/thompsa/vaptq/sys/net80211 X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 14 Apr 2009 05:09:11 -0000 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; }