linux-wireless.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [RFC 3/3] mac80211: Allow channel time for scans to be modified
@ 2014-01-06  7:52 Jouni Malinen
  0 siblings, 0 replies; only message in thread
From: Jouni Malinen @ 2014-01-06  7:52 UTC (permalink / raw)
  To: Johannes Berg; +Cc: linux-wireless

This uses the MaxChannelTime value, if specified, from the scan request
to control how long the mac80211 sw_scan spends on the channels.

Signed-off-by: Jouni Malinen <j@w1.fi>
---
 net/mac80211/scan.c |   38 +++++++++++++++++++++++++++++---------
 1 file changed, 29 insertions(+), 9 deletions(-)

diff --git a/net/mac80211/scan.c b/net/mac80211/scan.c
index 88c8161..53252a5 100644
--- a/net/mac80211/scan.c
+++ b/net/mac80211/scan.c
@@ -29,6 +29,27 @@
 #define IEEE80211_CHANNEL_TIME (HZ / 33)
 #define IEEE80211_PASSIVE_CHANNEL_TIME (HZ / 9)
 
+static unsigned long ieee80211_scan_active_time(struct ieee80211_local *local)
+{
+	/*
+	 * Note: Could use min_chan_time to speed scans if we supported
+	 * PHY-CCA.indication detection or maybe an emulation of that based on
+	 * frame RX.
+	 */
+	if (!local->scan_req->max_chan_time)
+		return IEEE80211_CHANNEL_TIME;
+	return max_t(unsigned long,
+		     TU_TO_JIFFIES(local->scan_req->max_chan_time), 1);
+}
+
+static unsigned long ieee80211_scan_passive_time(struct ieee80211_local *local)
+{
+	if (!local->scan_req->max_chan_time)
+		return IEEE80211_PASSIVE_CHANNEL_TIME;
+	return max_t(unsigned long,
+		     TU_TO_JIFFIES(local->scan_req->max_chan_time), 1);
+}
+
 void ieee80211_rx_bss_put(struct ieee80211_local *local,
 			  struct ieee80211_bss *bss)
 {
@@ -447,7 +468,7 @@ static void ieee80211_scan_state_send_probe(struct ieee80211_local *local,
 	 * After sending probe requests, wait for probe responses
 	 * on the channel.
 	 */
-	*next_delay = IEEE80211_CHANNEL_TIME;
+	*next_delay = ieee80211_scan_active_time(local);
 	local->next_scan_state = SCAN_DECISION;
 }
 
@@ -489,6 +510,8 @@ static int __ieee80211_start_scan(struct ieee80211_sub_if_data *sdata,
 			req->n_channels * sizeof(req->channels[0]);
 		local->hw_scan_req->ie = ies;
 		local->hw_scan_req->flags = req->flags;
+		local->hw_scan_req->min_chan_time = req->min_chan_time;
+		local->hw_scan_req->max_chan_time = req->max_chan_time;
 
 		local->hw_scan_band = 0;
 
@@ -527,14 +550,11 @@ static int __ieee80211_start_scan(struct ieee80211_sub_if_data *sdata,
 		/* We need to ensure power level is at max for scanning. */
 		ieee80211_hw_config(local, 0);
 
-		if ((req->channels[0]->flags &
-		     IEEE80211_CHAN_NO_IR) ||
-		    !local->scan_req->n_ssids) {
-			next_delay = IEEE80211_PASSIVE_CHANNEL_TIME;
-		} else {
+		if ((req->channels[0]->flags & IEEE80211_CHAN_NO_IR) ||
+		    !local->scan_req->n_ssids)
+			next_delay = ieee80211_scan_passive_time(local);
+		else
 			ieee80211_scan_state_send_probe(local, &next_delay);
-			next_delay = IEEE80211_CHANNEL_TIME;
-		}
 
 		/* Now, just wait a bit and we are all done! */
 		ieee80211_queue_delayed_work(&local->hw, &local->scan_work,
@@ -700,7 +720,7 @@ static void ieee80211_scan_state_set_channel(struct ieee80211_local *local,
 	 */
 	if (chan->flags & IEEE80211_CHAN_NO_IR ||
 	    !local->scan_req->n_ssids) {
-		*next_delay = IEEE80211_PASSIVE_CHANNEL_TIME;
+		*next_delay = ieee80211_scan_passive_time(local);
 		local->next_scan_state = SCAN_DECISION;
 		return;
 	}
-- 
1.7.9.5


-- 
Jouni Malinen                                            PGP id EFC895FA

^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2014-01-06  7:58 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-01-06  7:52 [RFC 3/3] mac80211: Allow channel time for scans to be modified Jouni Malinen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).