Patchwork [RFC,v2,3/4] nl80211: Add suport for chan_time scan parameter

login
register
mail settings
Submitter Michal Kazior
Date July 29, 2013, 9:19 a.m.
Message ID <1375089554-5885-4-git-send-email-michal.kazior@tieto.com>
Download mbox | patch
Permalink /patch/262703/
State Superseded
Headers show

Comments

Michal Kazior - July 29, 2013, 9:19 a.m.
This can be useful for future Automatic Channel
Selection.

Signed-off-by: Michal Kazior <michal.kazior@tieto.com>
---
 src/drivers/driver.h         |    7 +++++++
 src/drivers/driver_nl80211.c |   17 ++++++++++++++++-
 src/drivers/nl80211_copy.h   |    2 ++
 3 files changed, 25 insertions(+), 1 deletion(-)

Patch

diff --git a/src/drivers/driver.h b/src/drivers/driver.h
index 661f427..34da469 100644
--- a/src/drivers/driver.h
+++ b/src/drivers/driver.h
@@ -318,6 +318,13 @@  struct wpa_driver_scan_params {
 	 * and not to transmit the frames at any of those rates.
 	 */
 	u8 p2p_probe;
+
+	/**
+	 * chan_time - How many msecs driver should stay on each channel
+	 *
+	 * This is intended for either long passive scans or ACS.
+	 */
+	u32 chan_time;
 };
 
 /**
diff --git a/src/drivers/driver_nl80211.c b/src/drivers/driver_nl80211.c
index 034fe26..d56629e 100644
--- a/src/drivers/driver_nl80211.c
+++ b/src/drivers/driver_nl80211.c
@@ -4256,6 +4256,10 @@  nl80211_scan_common(struct wpa_driver_nl80211_data *drv, u8 cmd,
 		nla_nest_end(msg, freqs);
 	}
 
+	if (params->chan_time)
+		nla_put_u32(msg, NL80211_ATTR_SCAN_CHAN_TIME,
+			    params->chan_time);
+
 	os_free(drv->filter_ssids);
 	drv->filter_ssids = params->filter_ssids;
 	params->filter_ssids = NULL;
@@ -4280,7 +4284,7 @@  static int wpa_driver_nl80211_scan(struct i802_bss *bss,
 				   struct wpa_driver_scan_params *params)
 {
 	struct wpa_driver_nl80211_data *drv = bss->drv;
-	int ret = -1, timeout;
+	int ret = -1, timeout, n_freqs = 0, *freq;
 	struct nl_msg *msg = NULL;
 
 	wpa_dbg(drv->ctx, MSG_DEBUG, "nl80211: scan request");
@@ -4354,6 +4358,17 @@  static int wpa_driver_nl80211_scan(struct i802_bss *bss,
 		 */
 		timeout = 30;
 	}
+
+	if (params->chan_time && params->freqs) {
+		for (freq = params->freqs; *freq; freq++)
+			n_freqs++;
+
+		/* Give it twice the time each frequency is visited for
+		 * to provide enough grace period for channel
+		 * switching, etc. Also round up. */
+		timeout = ((params->chan_time * n_freqs) * 2 + 1) / 1000;
+	}
+
 	wpa_printf(MSG_DEBUG, "Scan requested (ret=%d) - scan timeout %d "
 		   "seconds", ret, timeout);
 	eloop_cancel_timeout(wpa_driver_nl80211_scan_timeout, drv, drv->ctx);
diff --git a/src/drivers/nl80211_copy.h b/src/drivers/nl80211_copy.h
index 32b060e..10e28e9 100644
--- a/src/drivers/nl80211_copy.h
+++ b/src/drivers/nl80211_copy.h
@@ -1736,6 +1736,8 @@  enum nl80211_attrs {
 
 	NL80211_ATTR_PEER_AID,
 
+	NL80211_ATTR_SCAN_CHAN_TIME,
+
 	/* add attributes here, update the policy in nl80211.c */
 
 	__NL80211_ATTR_AFTER_LAST,