diff mbox series

[5/5] wpa_supplicant: fall back to avg_signal

Message ID 20191206222748.153534-5-matthewmwang@chromium.org
State Accepted
Headers show
Series [1/5] wpa_supplicant: Bump up logging level for roaming decisions | expand

Commit Message

Matthew Wang Dec. 6, 2019, 10:27 p.m. UTC
Some drivers (e.g. Marvell WiFi) don't report avg_beacon_signal, but
it's still useful to poll for the signal again when a roaming decision
needs to be made. Use si.avg_signal when si.avg_beacon_signal is not
available.

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

Comments

Jouni Malinen Jan. 2, 2020, 8:24 a.m. UTC | #1
On Fri, Dec 06, 2019 at 02:27:48PM -0800, Matthew Wang wrote:
> Some drivers (e.g. Marvell WiFi) don't report avg_beacon_signal, but
> it's still useful to poll for the signal again when a roaming decision
> needs to be made. Use si.avg_signal when si.avg_beacon_signal is not
> available.

Thanks, applied with fixes.
diff mbox series

Patch

diff --git a/wpa_supplicant/events.c b/wpa_supplicant/events.c
index cf0aa2b57..c87011297 100644
--- a/wpa_supplicant/events.c
+++ b/wpa_supplicant/events.c
@@ -1667,7 +1667,7 @@  static void wpa_supplicant_rsn_preauth_scan_results(
 
 static int wpas_get_snr_signal_info(const struct wpa_signal_info *si)
 {
-	int noise = IS_5GHZ(si->frequency) ?
+	int noise = IS_5GHZ(frequency) ?
 		DEFAULT_NOISE_FLOOR_5GHZ :
 		DEFAULT_NOISE_FLOOR_2GHZ;
 
@@ -1676,7 +1676,7 @@  static int wpas_get_snr_signal_info(const struct wpa_signal_info *si)
 	 * the current noise measurement (average vs. snapshot),
 	 * so use the default values instead.
 	 */
-	return si->avg_beacon_signal - noise;
+	return avg_signal - noise;
 }
 
 
@@ -1772,10 +1772,10 @@  static int wpa_supplicant_need_to_roam(struct wpa_supplicant *wpa_s,
 	 * get fresh information about our own AP, do that.
 	 */
 	if (!wpa_drv_signal_poll(wpa_s, &si)) {
-		if (si.avg_beacon_signal) {
-			int snr = wpas_get_snr_signal_info(&si);
+		if (si.avg_beacon_signal || si.avg_signal) {
+			cur_level = si.avg_beacon_signal ? si.avg_beacon_signal : si.avg_signal;
+			int snr = wpas_get_snr_signal_info(si.frequency, cur_level);
 
-			cur_level = si.avg_beacon_signal;
 			cur_est = wpas_get_est_throughput_from_bss_snr(wpa_s,
 								       current_bss,
 								       snr);