diff mbox series

p2p: get cached scan results on iface creation to avoid scan

Message ID 20221012040202.208576-1-matthewmwang@chromium.org
State Accepted
Headers show
Series p2p: get cached scan results on iface creation to avoid scan | expand

Commit Message

Matthew Wang Oct. 12, 2022, 4:02 a.m. UTC
This allows the p2p client to fast associate if the GO is already in the
scan cache without doing a full scan.

Signed-off-by: Matthew Wang <matthewmwang@chromium.org>
---
 wpa_supplicant/p2p_supplicant.c | 22 ++++++++++++++++++++++
 1 file changed, 22 insertions(+)

Comments

Jouni Malinen Oct. 16, 2022, 5:49 p.m. UTC | #1
On Tue, Oct 11, 2022 at 09:02:02PM -0700, Matthew Wang wrote:
> This allows the p2p client to fast associate if the GO is already in the
> scan cache without doing a full scan.

Thanks, applied.
diff mbox series

Patch

diff --git a/wpa_supplicant/p2p_supplicant.c b/wpa_supplicant/p2p_supplicant.c
index f6252b1aa..27ab710fe 100644
--- a/wpa_supplicant/p2p_supplicant.c
+++ b/wpa_supplicant/p2p_supplicant.c
@@ -6875,6 +6875,8 @@  static int wpas_start_p2p_client(struct wpa_supplicant *wpa_s,
 				 int freq, int force_scan)
 {
 	struct wpa_ssid *ssid;
+	int other_iface_found = 0;
+	struct wpa_supplicant *ifs;
 
 	wpa_s = wpas_p2p_get_group_iface(wpa_s, addr_allocated, 0);
 	if (wpa_s == NULL)
@@ -6919,6 +6921,26 @@  static int wpas_start_p2p_client(struct wpa_supplicant *wpa_s,
 	wpa_s->p2p_go_group_formation_completed = 0;
 	wpa_s->global->p2p_group_formation = wpa_s;
 
+	/*
+	 * Get latest scan results from driver in case cached scan results from
+	 * interfaces on the same wiphy allow us to skip the next scan by fast
+	 * associating. Also update the scan time to the most recent scan result
+	 * fetch time on the same radio so it reflects the actual time the last
+	 * scan result event occurred.
+	 */
+	wpa_supplicant_update_scan_results(wpa_s);
+	dl_list_for_each(ifs, &wpa_s->radio->ifaces, struct wpa_supplicant,
+			 radio_list) {
+		if (ifs == wpa_s)
+			continue;
+		if (!other_iface_found || os_reltime_before(&wpa_s->last_scan,
+							    &ifs->last_scan)) {
+			other_iface_found = 1;
+			wpa_s->last_scan.sec = ifs->last_scan.sec;
+			wpa_s->last_scan.usec = ifs->last_scan.usec;
+		}
+	}
+
 	eloop_cancel_timeout(wpas_p2p_group_formation_timeout, wpa_s->p2pdev,
 			     NULL);
 	eloop_register_timeout(P2P_MAX_INITIAL_CONN_WAIT, 0,