Patchwork Speed up connection time during ASSOC retry

login
register
mail settings
Submitter Jithu Jance
Date May 21, 2012, 6:17 a.m.
Message ID <25A448014331D04F82E3035BCF9620AF06E626@SJEXCHMB09.corp.ad.broadcom.com>
Download mbox | patch
Permalink /patch/160318/
State Superseded
Headers show

Comments

Jithu Jance - May 21, 2012, 6:17 a.m.
In current implementation, authentication timer continues to run even after the
driver has reported ASSOC_REJECT. Then the association is retried on authentication
timeout which is 10secs.

The below patch cancels the authentication timeout on ASSOC_REJECT and initiates an
scan for association. Kindly see whether the patch is fine.


[PATCH] Speed up connection time during ASSOC retry

Avoid waiting for authentication timeout, If driver reports
ASSOC-REJECT

Signed-off-by: Jithu Jance <jithu@broadcom.com>
---
 wpa_supplicant/events.c           |   19 +++++++++++++++++++
 wpa_supplicant/wpa_supplicant.c   |    3 +++
 wpa_supplicant/wpa_supplicant_i.h |    1 +
 3 files changed, 23 insertions(+), 0 deletions(-)

Patch

diff --git a/wpa_supplicant/events.c b/wpa_supplicant/events.c
index 407407a..25c8f90 100644
--- a/wpa_supplicant/events.c
+++ b/wpa_supplicant/events.c
@@ -2238,6 +2238,25 @@  void wpa_supplicant_event(void *ctx, enum wpa_event_type event,
 				data->assoc_reject.status_code);
 		if (wpa_s->drv_flags & WPA_DRIVER_FLAGS_SME)
 			sme_event_assoc_reject(wpa_s, data);
+
+		/* If assoc reject is reported by the driver, then avoid
+		 * waiting for  the authentication timeout. Cancel the
+		 * authentication timeout and retry the assoc.
+		 */
+		if(wpa_s->assoc_retries++ < 3) {
+			wpa_printf(MSG_ERROR, "Retrying assoc "
+			"Iteration:%d", wpa_s->assoc_retries);
+			wpa_supplicant_cancel_auth_timeout(wpa_s);
+
+			/* Clear the states */
+			wpa_sm_notify_disassoc(wpa_s->wpa);
+			wpa_supplicant_disassociate(wpa_s, WLAN_REASON_DEAUTH_LEAVING);
+
+			wpa_s->reassociate = 1;
+			wpa_supplicant_req_scan(wpa_s, 1, 0);
+		} else {
+			wpa_s->assoc_retries = 0;
+		}
 		break;
 	case EVENT_AUTH_TIMED_OUT:
 		if (wpa_s->drv_flags & WPA_DRIVER_FLAGS_SME)
diff --git a/wpa_supplicant/wpa_supplicant.c b/wpa_supplicant/wpa_supplicant.c
index 09b1640..12adb1b 100644
--- a/wpa_supplicant/wpa_supplicant.c
+++ b/wpa_supplicant/wpa_supplicant.c
@@ -585,6 +585,9 @@  void wpa_supplicant_set_state(struct wpa_supplicant *wpa_s,
 		wpa_supplicant_state_txt(wpa_s->wpa_state),
 		wpa_supplicant_state_txt(state));
 
+	if(state == WPA_ASSOCIATED || (state <= WPA_INACTIVE))
+		wpa_s->assoc_retries = 0;
+
 	if (state != WPA_SCANNING)
 		wpa_supplicant_notify_scanning(wpa_s, 0);
 
diff --git a/wpa_supplicant/wpa_supplicant_i.h b/wpa_supplicant/wpa_supplicant_i.h
index 23ffd7d..07837e2 100644
--- a/wpa_supplicant/wpa_supplicant_i.h
+++ b/wpa_supplicant/wpa_supplicant_i.h
@@ -286,6 +286,7 @@  struct wpa_supplicant {
 	struct wpa_bss *current_bss;
 	int ap_ies_from_associnfo;
 	unsigned int assoc_freq;
+	unsigned int assoc_retries;
 
 	/* Selected configuration (based on Beacon/ProbeResp WPA IE) */
 	int pairwise_cipher;