]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
P2P: Delay P2P scan when an external scan is in progress
authorPurushottam Kushwaha <pkushwah@codeaurora.org>
Tue, 8 Dec 2020 10:53:56 +0000 (16:23 +0530)
committerJouni Malinen <j@w1.fi>
Mon, 21 Dec 2020 21:22:51 +0000 (23:22 +0200)
When an external scan is in progress on the same radio, delay the P2P
search operation based on configuration parameter p2p_search_delay. The
"search_delay" configuration done through p2p_find always takes
precedence over this delay value set due to an external scan trigger.

Signed-off-by: Jouni Malinen <jouni@codeaurora.org>
src/p2p/p2p.c
src/p2p/p2p.h
wpa_supplicant/p2p_supplicant.c

index 6b92a6d23ebcb71e34942c827116b7a459d40b58..74b7b52ae05c37371e20a0c694e8dbcee3d11c93 100644 (file)
@@ -3510,12 +3510,17 @@ int p2p_scan_res_handler(struct p2p_data *p2p, const u8 *bssid, int freq,
 }
 
 
-void p2p_scan_res_handled(struct p2p_data *p2p)
+void p2p_scan_res_handled(struct p2p_data *p2p, unsigned int delay)
 {
        if (!p2p->p2p_scan_running) {
                p2p_dbg(p2p, "p2p_scan was not running, but scan results received");
        }
        p2p->p2p_scan_running = 0;
+
+       /* Use this delay only when p2p_find doesn't set it */
+       if (!p2p->search_delay)
+               p2p->search_delay = delay;
+
        eloop_cancel_timeout(p2p_scan_timeout, p2p, NULL);
 
        if (p2p_run_after_scan(p2p))
index ed8beab19acf21cc5149bf673c9a9e93e496c680..762bd40bea8b536c42296b5fb5135b9fd7594d62 100644 (file)
@@ -1625,6 +1625,7 @@ int p2p_scan_res_handler(struct p2p_data *p2p, const u8 *bssid, int freq,
 /**
  * p2p_scan_res_handled - Indicate end of scan results
  * @p2p: P2P module context from p2p_init()
+ * @delay: Search delay for next scan in ms
  *
  * This function is called to indicate that all P2P scan results from a scan
  * have been reported with zero or more calls to p2p_scan_res_handler(). This
@@ -1632,7 +1633,7 @@ int p2p_scan_res_handler(struct p2p_data *p2p, const u8 *bssid, int freq,
  * struct p2p_config::p2p_scan() call if none of the p2p_scan_res_handler()
  * calls stopped iteration.
  */
-void p2p_scan_res_handled(struct p2p_data *p2p);
+void p2p_scan_res_handled(struct p2p_data *p2p, unsigned int delay);
 
 enum p2p_send_action_result {
        P2P_SEND_ACTION_SUCCESS /* Frame was send and acknowledged */,
index 8c8a834dac85d597fec59423dd373fcb988fd963..7d6e2dac80f686eab967236df9c26350430d4422 100644 (file)
@@ -242,6 +242,22 @@ static void wpas_p2p_set_own_freq_preference(struct wpa_supplicant *wpa_s,
 }
 
 
+static void wpas_p2p_scan_res_handled(struct wpa_supplicant *wpa_s)
+{
+       unsigned int delay = wpas_p2p_search_delay(wpa_s);
+
+       /* In case of concurrent P2P and external scans, delay P2P search. */
+       if (wpa_s->radio->external_scan_running) {
+               delay = wpa_s->conf->p2p_search_delay;
+               wpa_printf(MSG_DEBUG,
+                          "P2P: Delay next P2P search by %d ms to let externally triggered scan complete",
+                          delay);
+       }
+
+       p2p_scan_res_handled(wpa_s->global->p2p, delay);
+}
+
+
 static void wpas_p2p_scan_res_handler(struct wpa_supplicant *wpa_s,
                                      struct wpa_scan_results *scan_res)
 {
@@ -287,7 +303,7 @@ static void wpas_p2p_scan_res_handler(struct wpa_supplicant *wpa_s,
                        break;
        }
 
-       p2p_scan_res_handled(wpa_s->global->p2p);
+       wpas_p2p_scan_res_handled(wpa_s);
 }
 
 
@@ -305,7 +321,7 @@ static void wpas_p2p_scan_res_fail_handler(struct wpa_supplicant *wpa_s)
 
        wpa_dbg(wpa_s, MSG_DEBUG,
                "P2P: Failed to get scan results - try to continue");
-       p2p_scan_res_handled(wpa_s->global->p2p);
+       wpas_p2p_scan_res_handled(wpa_s);
 }
 
 
@@ -7089,7 +7105,7 @@ static void wpas_p2p_scan_res_ignore_search(struct wpa_supplicant *wpa_s,
         * Indicate that results have been processed so that the P2P module can
         * continue pending tasks.
         */
-       p2p_scan_res_handled(wpa_s->global->p2p);
+       wpas_p2p_scan_res_handled(wpa_s);
 }