From 0817de904e7fd2ad383379d7c2787c5cac86f1bd Mon Sep 17 00:00:00 2001 From: Jouni Malinen Date: Sun, 18 Jul 2010 14:30:25 -0700 Subject: [PATCH] P2P: Optimize scan timeouts for group formation --- wpa_supplicant/events.c | 10 ++++++++++ wpa_supplicant/scan.c | 30 ++++++++++++++++++++++++++++++ 2 files changed, 40 insertions(+) diff --git a/wpa_supplicant/events.c b/wpa_supplicant/events.c index 880794afb..167e6338d 100644 --- a/wpa_supplicant/events.c +++ b/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); } diff --git a/wpa_supplicant/scan.c b/wpa_supplicant/scan.c index d74174e0f..fc677da87 100644 --- a/wpa_supplicant/scan.c +++ b/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(¶ms.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) { /*