Browse Source

P2P: Optimize scan timeouts for group formation

Jouni Malinen 14 years ago
parent
commit
0817de904e
2 changed files with 40 additions and 0 deletions
  1. 10 0
      wpa_supplicant/events.c
  2. 30 0
      wpa_supplicant/scan.c

+ 10 - 0
wpa_supplicant/events.c

@@ -856,6 +856,16 @@ static void wpa_supplicant_event_scan_results(struct wpa_supplicant *wpa_s,
 		} else {
 			int timeout_sec = 5;
 			int timeout_usec = 0;
+#ifdef CONFIG_P2P
+			if (wpa_s->p2p_in_provisioning) {
+				/*
+				 * Use shorter wait during P2P Provisioning
+				 * state to speed up group formation.
+				 */
+				timeout_sec = 0;
+				timeout_usec = 250000;
+			}
+#endif /* CONFIG_P2P */
 			wpa_supplicant_req_new_scan(wpa_s, timeout_sec,
 						    timeout_usec);
 		}

+ 30 - 0
wpa_supplicant/scan.c

@@ -383,6 +383,36 @@ static void wpa_supplicant_scan(void *eloop_ctx, void *timeout_ctx)
 		wpa_printf(MSG_DEBUG, "Starting AP scan for wildcard SSID");
 	}
 
+#ifdef CONFIG_P2P
+	wpa_s->wps->dev.p2p = 1;
+	if (!wps) {
+		wps = 1;
+		req_type = WPS_REQ_ENROLLEE;
+	}
+
+	if (params.freqs == NULL && wpa_s->p2p_in_provisioning &&
+	    wpa_s->go_params) {
+		/* Optimize provisioning state scan based on GO information */
+		if (wpa_s->p2p_in_provisioning < 5 &&
+		    wpa_s->go_params->freq > 0) {
+			wpa_printf(MSG_DEBUG, "P2P: Scan only GO preferred "
+				   "frequency %d MHz",
+				   wpa_s->go_params->freq);
+			params.freqs = os_zalloc(2 * sizeof(int));
+			if (params.freqs)
+				params.freqs[0] = wpa_s->go_params->freq;
+		} else if (wpa_s->go_params->freq_list[0]) {
+			wpa_printf(MSG_DEBUG, "P2P: Scan only common "
+				   "channels");
+			int_array_concat(&params.freqs,
+					 wpa_s->go_params->freq_list);
+			if (params.freqs)
+				int_array_sort_unique(params.freqs);
+		}
+		wpa_s->p2p_in_provisioning++;
+	}
+#endif /* CONFIG_P2P */
+
 #ifdef CONFIG_WPS
 	if (params.freqs == NULL && wpa_s->after_wps && wpa_s->wps_freq) {
 		/*