diff mbox

Improve performance of reassociate operation

Message ID 20140307002308.89E5B1A1F62@zqiu.mtv.corp.google.com
State Superseded
Headers show

Commit Message

Peter Qiu March 6, 2014, 6:06 p.m. UTC
Perform single-channel single-ssid scan instead of full scan
for reassociate operation. This allows the scan result to come
back in much faster time during reassociate. In ath9k, the scan
took around 12 seconds without the fix, and only 0.1 second with
the fix.

Since for reassociate operation the only SSID we care about is
the one we previously connected to, so it should be good idea to
perform single-channel single-ssid scan for reassociate.

Signed-hostap: Peter Qiu <zqiu@chromium.org>
---
 wpa_supplicant/scan.c | 24 ++++++++++++++++++++++++
 1 file changed, 24 insertions(+)

Comments

Holger Schurig March 7, 2014, 12:54 p.m. UTC | #1
I'm against this patch in mainline wpa_supplicant, it seems to be just
for your use case. Also, I think that your problem is already solved:
if you know that you only have one access point, why don't you use
scan_freq?  Excerpt from the demo wpa_supplicant.conf:

# scan_freq: List of frequencies to scan
# Space-separated list of frequencies in MHz to scan when searching for this
# BSS. If the subset of channels used by the network is known, this option can
# be used to optimize scanning to not occur on channels that the network does
# not use. Example: scan_freq=2412 2437 2462


For my usage scenarior (where I have a multitude of APs and might move
around) your patch would make thinks quite bad.
diff mbox

Patch

diff --git a/wpa_supplicant/scan.c b/wpa_supplicant/scan.c
index f7eb537..9926e10 100644
--- a/wpa_supplicant/scan.c
+++ b/wpa_supplicant/scan.c
@@ -665,6 +665,30 @@  static void wpa_supplicant_scan(void *eloop_ctx, void *timeout_ctx)
 		 * wildcard SSID.
 		 */
 		ssid = NULL;
+	} else if (wpa_s->reassociate && wpa_s->current_ssid != NULL) {
+		/*
+		 * Perform single-channel single-SSID scan for reassociate
+		 * operation.
+		 */
+		/* Setup SSID */
+		ssid = wpa_s->current_ssid;
+		wpa_hexdump_ascii(MSG_DEBUG, "Scan SSID",
+		                  ssid->ssid, ssid->ssid_len);
+		params.ssids[0].ssid = ssid->ssid;
+		params.ssids[0].ssid_len = ssid->ssid_len;
+		params.num_ssids = 1;
+
+		/*
+		 * Allocate memory for frequency array, allocate one extra
+		 * slot for the zero-terminator.
+		 */
+		params.freqs = (int *)os_malloc(sizeof(int)*2);
+		if (params.freqs == NULL) {
+		        wpa_dbg(wpa_s, MSG_ERROR, "Memory allocation failed");
+		        return;
+		}
+		params.freqs[0] = wpa_s->assoc_freq;
+		params.freqs[1] = 0;
 	} else {
 		struct wpa_ssid *start = ssid, *tssid;
 		int freqs_set = 0;