wifi: iwlwifi: mld: avoid selecting bad links
authorMiri Korenblit <miriam.rachel.korenblit@intel.com>
Sun, 9 Mar 2025 05:36:53 +0000 (07:36 +0200)
committerJohannes Berg <johannes.berg@intel.com>
Tue, 11 Mar 2025 15:29:26 +0000 (16:29 +0100)
Currently, we don't select a link that wasn't heared in the last 5
seconds.
But if the link started to suffer from missed beacons more recent than
that, we might select this link even we really shouldn't,
leading to a disconnection instead of a link switch.

Fix this by checking if a link was heared in the last MLO scan,
if not - don't include it in the link selection.
Since we do an MLO scan on missed beacons, we will not hear that link in
that scan, and won't select it.

Signed-off-by: Miri Korenblit <miriam.rachel.korenblit@intel.com>
Reviewed-by: Emmanuel Grumbach <emmanuel.grumbach@intel.com>
Link: https://patch.msgid.link/20250309073442.8f950497219e.I51306021fe9231a8184e89c23707be47d3c05241@changeid
[replace cast with ULL constant]
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
drivers/net/wireless/intel/iwlwifi/mld/mlo.c
drivers/net/wireless/intel/iwlwifi/mld/scan.c
drivers/net/wireless/intel/iwlwifi/mld/scan.h

index 99ba4018fb247442223a9273eb82eefbebe79413..a5b1d373922a805ea29c960900f1fb3460ed6b2b 100644 (file)
@@ -704,10 +704,9 @@ iwl_mld_set_link_sel_data(struct iwl_mld *mld,
                if (WARN_ON_ONCE(!link_conf))
                        continue;
 
-               /* Ignore any BSS that was not seen in the last 5 seconds */
+               /* Ignore any BSS that was not seen in the last MLO scan */
                if (ktime_before(link_conf->bss->ts_boottime,
-                                ktime_sub_ns(ktime_get_boottime_ns(),
-                                             (u64)5 * NSEC_PER_SEC)))
+                                mld->scan.last_mlo_scan_time))
                        continue;
 
                data[n_data].link_id = link_id;
@@ -819,8 +818,9 @@ static void _iwl_mld_select_links(struct iwl_mld *mld,
        if (!mld_vif->authorized || hweight16(usable_links) <= 1)
                return;
 
-       if (WARN(time_before(mld->scan.last_mlo_scan_jiffies,
-                            jiffies - IWL_MLD_SCAN_EXPIRE_TIME),
+       if (WARN(ktime_before(mld->scan.last_mlo_scan_time,
+                             ktime_sub_ns(ktime_get_boottime_ns(),
+                                          5ULL * NSEC_PER_SEC)),
                "Last MLO scan was too long ago, can't select links\n"))
                return;
 
index 5f4ede92028b444fa3b00fb4a7c340f8f8f1ab92..7ec04318ec2fcf59f3b40562f0089e66e904af87 100644 (file)
@@ -1794,6 +1794,9 @@ static void iwl_mld_int_mlo_scan_start(struct iwl_mld *mld,
        ret = _iwl_mld_single_scan_start(mld, vif, req, &ies,
                                         IWL_MLD_SCAN_INT_MLO);
 
+       if (!ret)
+               mld->scan.last_mlo_scan_time = ktime_get_boottime_ns();
+
        IWL_DEBUG_SCAN(mld, "Internal MLO scan: ret=%d\n", ret);
 }
 
@@ -1922,7 +1925,6 @@ void iwl_mld_handle_scan_complete_notif(struct iwl_mld *mld,
                mld->scan.pass_all_sched_res = SCHED_SCAN_PASS_ALL_STATE_DISABLED;
        } else if (mld->scan.uid_status[uid] == IWL_MLD_SCAN_INT_MLO) {
                IWL_DEBUG_SCAN(mld, "Internal MLO scan completed\n");
-               mld->scan.last_mlo_scan_jiffies = jiffies;
 
                /*
                 * We limit link selection to internal MLO scans as otherwise
index cb589e00231934782f24815d70a1088fbe00210d..3ae940d55065c5d625336011f39e294ee82865d0 100644 (file)
@@ -108,7 +108,8 @@ enum iwl_mld_traffic_load {
  *     in jiffies.
  * @last_start_time_jiffies: stores the last start time in jiffies
  *     (interface up/reset/resume).
- * @last_mlo_scan_jiffies: end time of the last MLO scan in jiffies.
+ * @last_mlo_scan_time: start time of the last MLO scan in nanoseconds since
+ *     boot.
  */
 struct iwl_mld_scan {
        /* Add here fields that need clean up on restart */
@@ -129,7 +130,7 @@ struct iwl_mld_scan {
        void *cmd;
        unsigned long last_6ghz_passive_jiffies;
        unsigned long last_start_time_jiffies;
-       unsigned long last_mlo_scan_jiffies;
+       unsigned long last_mlo_scan_time;
 };
 
 #endif /* __iwl_mld_scan_h__ */