From b98919427e885679267ac811eb7e02d7209078b4 Mon Sep 17 00:00:00 2001
From: root <root@cy-blr-au146.india.cypress.com>
Date: Tue, 26 Jul 2022 17:24:49 -0400
Subject: [PATCH 33/49] Add support for beacon loss roaming

---
 wpa_supplicant/bgscan_learn.c  | 19 ++++++++++++++++++-
 wpa_supplicant/bgscan_simple.c | 20 +++++++++++++++++++-
 2 files changed, 37 insertions(+), 2 deletions(-)

diff --git a/wpa_supplicant/bgscan_learn.c b/wpa_supplicant/bgscan_learn.c
index cb732f709..115d2c007 100644
--- a/wpa_supplicant/bgscan_learn.c
+++ b/wpa_supplicant/bgscan_learn.c
@@ -18,6 +18,7 @@
 #include "driver_i.h"
 #include "scan.h"
 #include "bgscan.h"
+#include "bss.h"
 
 struct bgscan_learn_bss {
 	struct dl_list list;
@@ -550,8 +551,24 @@ static int bgscan_learn_notify_scan(void *priv,
 
 static void bgscan_learn_notify_beacon_loss(void *priv)
 {
+	struct bgscan_learn_data *data = priv;
+
 	wpa_printf(MSG_DEBUG, "bgscan learn: beacon loss");
-	/* TODO: speed up background scanning */
+
+	wpa_printf(MSG_DEBUG, "bgscan learn: Flush all prev bss entries");
+	wpa_bss_flush(data->wpa_s);
+
+	wpa_printf(MSG_DEBUG, "bgscan learn: allow reassociation "
+			"to same lost BSS if found");
+	data->wpa_s->reassociate = 1;
+
+	wpa_printf(MSG_DEBUG, "bgscan learn: Start using short "
+		   "bgscan interval");
+	data->scan_interval = data->short_interval;
+
+	wpa_printf(MSG_DEBUG, "bgscan learn: Trigger immediate scan");
+	eloop_cancel_timeout(bgscan_learn_timeout, data, NULL);
+	eloop_register_timeout(0, 0, bgscan_learn_timeout, data, NULL);
 }
 
 
diff --git a/wpa_supplicant/bgscan_simple.c b/wpa_supplicant/bgscan_simple.c
index 41a26df0d..bc99885fb 100644
--- a/wpa_supplicant/bgscan_simple.c
+++ b/wpa_supplicant/bgscan_simple.c
@@ -16,6 +16,7 @@
 #include "driver_i.h"
 #include "scan.h"
 #include "bgscan.h"
+#include "bss.h"
 
 struct bgscan_simple_data {
 	struct wpa_supplicant *wpa_s;
@@ -191,8 +192,25 @@ static int bgscan_simple_notify_scan(void *priv,
 
 static void bgscan_simple_notify_beacon_loss(void *priv)
 {
+	struct bgscan_simple_data *data = priv;
+
 	wpa_printf(MSG_DEBUG, "bgscan simple: beacon loss");
-	/* TODO: speed up background scanning */
+
+	wpa_printf(MSG_DEBUG, "bgscan simple: Flush all prev bss entries");
+	wpa_bss_flush(data->wpa_s);
+
+	wpa_printf(MSG_DEBUG, "bgscan simple: allow reassociation "
+			"to same lost BSS if found");
+	data->wpa_s->reassociate = 1;
+
+	wpa_printf(MSG_DEBUG, "bgscan simple: Start using short "
+		   "bgscan interval");
+	data->scan_interval = data->short_interval;
+
+	wpa_printf(MSG_DEBUG, "bgscan simple: Trigger immediate scan");
+	eloop_cancel_timeout(bgscan_simple_timeout, data, NULL);
+	eloop_register_timeout(0, 0, bgscan_simple_timeout, data,
+			       NULL);
 }
 
 
-- 
2.17.1

