From 154cdb82e33f6e44a7c088642a373745b01ce145 Mon Sep 17 00:00:00 2001 From: Theo Debrouwere Date: Mon, 24 Apr 2023 13:26:32 +0200 Subject: [PATCH] Bugfix: fix active roaming capability. According to the makefile, it should be possible to keep roaming active: Set #bit2 of CONFIG_ROAMING_FLAG, like this: CONFIG_ROAMING_FLAG = 0x7 But, when trying out this option, it appears that active roaming is not working as expected. It only changes if the old AP is expired. This patch fixes this behaviour, but does NOT set BIT2. Reason for failure: The linked_status_chk function runs every 2 seconds. There is an internal roaming flag (need_to_roam) that is set when the current signal is below a threshold AND if it hasn't been set during a predefined time. Setting the flag also updates the last_time_roaming timestamp. If either of these fails, then the flag (need_to_roam) is cleared. This causes a race condition: 1) Threshold is too low + long last_time_roaming -> flag is set + last_time_roaming is updated. 2) Chipset starts scanning / surveying (this takes > 3 sec) 3) Conditions are rechecked: threshold is still to low, but last_time_roaming is now too recent -> flag is cleared. 4) Survey finishes, but since the flag is cleared, roaming will be ignored. The solution in this patch: Once the flag (need_to_roam) has been set, it should only be cleared if the signal strength is above the threshold. It should not be cleared based on the last_time_roaming timestamp. --- core/rtw_mlme_ext.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/core/rtw_mlme_ext.c b/core/rtw_mlme_ext.c index 5fa2000..ebb93e5 100644 --- a/core/rtw_mlme_ext.c +++ b/core/rtw_mlme_ext.c @@ -12799,14 +12799,15 @@ void linked_status_chk(_adapter *padapter, u8 from_timer) #elif defined(CONFIG_LAYER2_ROAMING) if (rtw_chk_roam_flags(padapter, RTW_ROAM_ACTIVE)) { RTW_INFO("signal_strength_data.avg_val = %d\n", precvpriv->signal_strength_data.avg_val); - if ((precvpriv->signal_strength_data.avg_val < pmlmepriv->roam_rssi_threshold) - && (rtw_get_passing_time_ms(pmlmepriv->last_roaming) >= pmlmepriv->roam_scan_int*2000)) { + if (precvpriv->signal_strength_data.avg_val < pmlmepriv->roam_rssi_threshold) { + if (rtw_get_passing_time_ms(pmlmepriv->last_roaming) >= pmlmepriv->roam_scan_int*2000) { #ifdef CONFIG_RTW_80211K - rtw_roam_nb_discover(padapter, _FALSE); + rtw_roam_nb_discover(padapter, _FALSE); #endif - pmlmepriv->need_to_roam = _TRUE; - rtw_drv_scan_by_self(padapter, RTW_AUTO_SCAN_REASON_ROAM); - pmlmepriv->last_roaming = rtw_get_current_time(); + pmlmepriv->need_to_roam = _TRUE; + rtw_drv_scan_by_self(padapter, RTW_AUTO_SCAN_REASON_ROAM); + pmlmepriv->last_roaming = rtw_get_current_time(); + } } else pmlmepriv->need_to_roam = _FALSE; }