From owner-svn-src-user@FreeBSD.ORG  Thu Apr 23 17:19:00 2009
Return-Path: <owner-svn-src-user@FreeBSD.ORG>
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 06A5A106564A;
	Thu, 23 Apr 2009 17:19:00 +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 CF15E8FC1C;
	Thu, 23 Apr 2009 17:18:59 +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 n3NHIx4G094314;
	Thu, 23 Apr 2009 17:18:59 GMT (envelope-from thompsa@svn.freebsd.org)
Received: (from thompsa@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id n3NHIxGY094313;
	Thu, 23 Apr 2009 17:18:59 GMT (envelope-from thompsa@svn.freebsd.org)
Message-Id: <200904231718.n3NHIxGY094313@svn.freebsd.org>
From: Andrew Thompson <thompsa@FreeBSD.org>
Date: Thu, 23 Apr 2009 17:18:59 +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: r191426 - 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 &quot; user&quot;
	src tree" <svn-src-user.freebsd.org>
List-Unsubscribe: <http://lists.freebsd.org/mailman/listinfo/svn-src-user>,
	<mailto:svn-src-user-request@freebsd.org?subject=unsubscribe>
List-Archive: <http://lists.freebsd.org/pipermail/svn-src-user>
List-Post: <mailto:svn-src-user@freebsd.org>
List-Help: <mailto:svn-src-user-request@freebsd.org?subject=help>
List-Subscribe: <http://lists.freebsd.org/mailman/listinfo/svn-src-user>,
	<mailto:svn-src-user-request@freebsd.org?subject=subscribe>
X-List-Received-Date: Thu, 23 Apr 2009 17:19:00 -0000

Author: thompsa
Date: Thu Apr 23 17:18:59 2009
New Revision: 191426
URL: http://svn.freebsd.org/changeset/base/191426

Log:
  Eliminate an unlock for the channel change and add more comments around the
  driver callbacks.

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

Modified: user/thompsa/vaptq/sys/net80211/ieee80211_scan.c
==============================================================================
--- user/thompsa/vaptq/sys/net80211/ieee80211_scan.c	Thu Apr 23 16:56:26 2009	(r191425)
+++ user/thompsa/vaptq/sys/net80211/ieee80211_scan.c	Thu Apr 23 17:18:59 2009	(r191426)
@@ -302,17 +302,6 @@ scan_update_locked(struct ieee80211vap *
 	}
 }
 
-static void
-change_channel(struct ieee80211com *ic,
-	struct ieee80211_channel *chan)
-{
-	ic->ic_curchan = chan;
-	ic->ic_rt = ieee80211_get_ratetable(chan);
-	IEEE80211_UNLOCK(ic);
-	ic->ic_set_channel(ic);
-	IEEE80211_LOCK(ic);
-}
-
 static char
 channel_type(const struct ieee80211_channel *c)
 {
@@ -921,7 +910,15 @@ scan_task(void *arg, int pending)
 		/*
 		 * Potentially change channel and phy mode.
 		 */
-		change_channel(ic, chan);
+		ic->ic_curchan = chan;
+		ic->ic_rt = ieee80211_get_ratetable(chan);
+		IEEE80211_UNLOCK(ic);
+		/*
+		 * Perform the channel change and scan unlocked so the driver
+		 * may sleep. Once set_channel returns the hardware has
+		 * completed the channel change.
+		 */
+		ic->ic_set_channel(ic);
 
 		/*
 		 * Scan curchan.  Drivers for "intelligent hardware"
@@ -929,8 +926,12 @@ scan_task(void *arg, int pending)
 		 * the work.  Otherwise we manage the work outselves;
 		 * sending a probe request (as needed), and arming the
 		 * timeout to switch channels after maxdwell ticks.
+		 *
+		 * scan_curchan should only pause for the time required to
+		 * prepare/initiate the hardware for the scan (if at all), the
+		 * below condvar is used to sleep for the channels dwell time
+		 * and allows it to be signalled for abort.
 		 */
-		IEEE80211_UNLOCK(ic);
 		ic->ic_scan_curchan(ss, maxdwell);
 		IEEE80211_LOCK(ic);