[PATCH] driver_nl80211: use low-priority scan for OBSS scan

Johannes Berg johannes at sipsolutions.net
Wed Jun 4 05:21:40 EDT 2014


From: Johannes Berg <johannes.berg at intel.com>

Some drivers may support low-priority scans, if they do then
use that for OBSS scanning.

Signed-off-by: Johannes Berg <johannes.berg at intel.com>
---
 src/drivers/driver.h         | 12 ++++++++++--
 src/drivers/driver_nl80211.c | 17 +++++++++++++++--
 wpa_supplicant/scan.c        |  1 +
 wpa_supplicant/sme.c         |  1 +
 4 files changed, 27 insertions(+), 4 deletions(-)

diff --git a/src/drivers/driver.h b/src/drivers/driver.h
index 6e47b862b742..33f53af32c5a 100644
--- a/src/drivers/driver.h
+++ b/src/drivers/driver.h
@@ -351,7 +351,7 @@ struct wpa_driver_scan_params {
 	 * Mbps from the support rates element(s) in the Probe Request frames
 	 * and not to transmit the frames at any of those rates.
 	 */
-	u8 p2p_probe;
+	unsigned int p2p_probe:1;
 
 	/**
 	 * only_new_results - Request driver to report only new results
@@ -360,7 +360,15 @@ struct wpa_driver_scan_params {
 	 * been detected after this scan request has been started, i.e., to
 	 * flush old cached BSS entries.
 	 */
-	int only_new_results;
+	unsigned int only_new_results:1;
+
+	/**
+	 * low_priority - Requests driver to use a lower scan priority
+	 *
+	 * This is used to request the driver to use a lower scan priority
+	 * if it supports such a thing.
+	 */
+	unsigned int low_priority:1;
 
 	/*
 	 * NOTE: Whenever adding new parameters here, please make sure
diff --git a/src/drivers/driver_nl80211.c b/src/drivers/driver_nl80211.c
index 756865387746..41ff1e21ab0a 100644
--- a/src/drivers/driver_nl80211.c
+++ b/src/drivers/driver_nl80211.c
@@ -307,6 +307,7 @@ struct wpa_driver_nl80211_data {
 	unsigned int test_use_roc_tx:1;
 	unsigned int ignore_deauth_event:1;
 	unsigned int dfs_vendor_cmd_avail:1;
+	unsigned int have_low_prio_scan:1;
 
 	u64 remain_on_chan_cookie;
 	u64 send_action_cookie;
@@ -3411,6 +3412,7 @@ struct wiphy_info_data {
 	unsigned int p2p_concurrent:1;
 	unsigned int channel_switch_supported:1;
 	unsigned int set_qos_map_supported:1;
+	unsigned int have_low_prio_scan:1;
 };
 
 
@@ -3689,6 +3691,9 @@ static void wiphy_info_feature_flags(struct wiphy_info_data *info,
 
 	if (flags & NL80211_FEATURE_AP_MODE_CHAN_WIDTH_CHANGE)
 		capa->flags |= WPA_DRIVER_FLAGS_HT_2040_COEX;
+
+	if (flags & NL80211_FEATURE_LOW_PRIORITY_SCAN)
+		info->have_low_prio_scan = 1;
 }
 
 
@@ -3981,6 +3986,7 @@ static int wpa_driver_nl80211_capa(struct wpa_driver_nl80211_data *drv)
 	drv->data_tx_status = info.data_tx_status;
 	if (info.set_qos_map_supported)
 		drv->capa.flags |= WPA_DRIVER_FLAGS_QOS_MAPPING;
+	drv->have_low_prio_scan = info.have_low_prio_scan;
 
 	/*
 	 * If poll command and tx status are supported, mac80211 is new enough
@@ -4949,6 +4955,7 @@ nl80211_scan_common(struct wpa_driver_nl80211_data *drv, u8 cmd,
 {
 	struct nl_msg *msg;
 	size_t i;
+	u32 scan_flags = 0;
 
 	msg = nlmsg_alloc();
 	if (!msg)
@@ -5007,10 +5014,16 @@ nl80211_scan_common(struct wpa_driver_nl80211_data *drv, u8 cmd,
 
 	if (params->only_new_results) {
 		wpa_printf(MSG_DEBUG, "nl80211: Add NL80211_SCAN_FLAG_FLUSH");
-		NLA_PUT_U32(msg, NL80211_ATTR_SCAN_FLAGS,
-			    NL80211_SCAN_FLAG_FLUSH);
+		scan_flags |= NL80211_SCAN_FLAG_FLUSH;
+	}
+
+	if (params->low_priority && drv->have_low_prio_scan) {
+		wpa_printf(MSG_DEBUG, "nl80211: Add NL80211_SCAN_FLAG_LOW_PRIORITY");
+		scan_flags |= NL80211_SCAN_FLAG_LOW_PRIORITY;
 	}
 
+	NLA_PUT_U32(msg, NL80211_ATTR_SCAN_FLAGS, scan_flags);
+
 	return msg;
 
 fail:
diff --git a/wpa_supplicant/scan.c b/wpa_supplicant/scan.c
index 4d96e82cdfad..6c1889d3c593 100644
--- a/wpa_supplicant/scan.c
+++ b/wpa_supplicant/scan.c
@@ -1859,6 +1859,7 @@ wpa_scan_clone_params(const struct wpa_driver_scan_params *src)
 	params->filter_rssi = src->filter_rssi;
 	params->p2p_probe = src->p2p_probe;
 	params->only_new_results = src->only_new_results;
+	params->low_priority = src->low_priority;
 
 	return params;
 
diff --git a/wpa_supplicant/sme.c b/wpa_supplicant/sme.c
index 9b6667a62b7b..bc357998385d 100644
--- a/wpa_supplicant/sme.c
+++ b/wpa_supplicant/sme.c
@@ -1166,6 +1166,7 @@ static void sme_obss_scan_timeout(void *eloop_ctx, void *timeout_ctx)
 
 	os_memset(&params, 0, sizeof(params));
 	wpa_setband_scan_freqs_list(wpa_s, HOSTAPD_MODE_IEEE80211G, &params);
+	params.low_priority = 1;
 	wpa_printf(MSG_DEBUG, "SME OBSS: Request an OBSS scan");
 
 	if (wpa_supplicant_trigger_scan(wpa_s, &params))
-- 
2.0.0.rc0



More information about the HostAP mailing list