]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
wifi: iwlwifi: defer MLO scan after link activation
authorJohannes Berg <johannes.berg@intel.com>
Wed, 11 Jun 2025 19:26:28 +0000 (22:26 +0300)
committerMiri Korenblit <miriam.rachel.korenblit@intel.com>
Wed, 25 Jun 2025 07:57:32 +0000 (10:57 +0300)
Doing a scan right after link activation can be less reliable
than at other times, as the firmware is still busy trying to
catch beacons from the just activated link, etc. In case a new
MLO scan request comes in, defer it for a few seconds after a
link activation.

Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Signed-off-by: Miri Korenblit <miriam.rachel.korenblit@intel.com>
Link: https://patch.msgid.link/20250611222325.09548e958a9e.I24dbfd425da260f3ae6fa5a48fe25bd4ab6fcf99@changeid
drivers/net/wireless/intel/iwlwifi/mld/iface.c
drivers/net/wireless/intel/iwlwifi/mld/iface.h
drivers/net/wireless/intel/iwlwifi/mld/link.c
drivers/net/wireless/intel/iwlwifi/mld/scan.c

index 235b55e0fe5940af3f4400b27993ab38825f4ef3..38993d65c052a8736e36a08b8a0095567467c5cd 100644 (file)
@@ -55,6 +55,8 @@ void iwl_mld_cleanup_vif(void *data, u8 *mac, struct ieee80211_vif *vif)
 
        ieee80211_iter_keys(mld->hw, vif, iwl_mld_cleanup_keys_iter, NULL);
 
+       wiphy_delayed_work_cancel(mld->wiphy, &mld_vif->mlo_scan_start_wk);
+
        CLEANUP_STRUCT(mld_vif);
 }
 
@@ -385,6 +387,17 @@ int iwl_mld_mac_fw_action(struct iwl_mld *mld, struct ieee80211_vif *vif,
        return iwl_mld_send_mac_cmd(mld, &cmd);
 }
 
+static void iwl_mld_mlo_scan_start_wk(struct wiphy *wiphy,
+                                     struct wiphy_work *wk)
+{
+       struct iwl_mld_vif *mld_vif = container_of(wk, struct iwl_mld_vif,
+                                                  mlo_scan_start_wk.work);
+       struct ieee80211_hw *hw = wiphy_to_ieee80211_hw(wiphy);
+       struct iwl_mld *mld = IWL_MAC80211_GET_MLD(hw);
+
+       iwl_mld_int_mlo_scan(mld, iwl_mld_vif_to_mac80211(mld_vif));
+}
+
 IWL_MLD_ALLOC_FN(vif, vif)
 
 /* Constructor function for struct iwl_mld_vif */
@@ -412,6 +425,8 @@ iwl_mld_init_vif(struct iwl_mld *mld, struct ieee80211_vif *vif)
                                        iwl_mld_emlsr_prevent_done_wk);
                wiphy_delayed_work_init(&mld_vif->emlsr.tmp_non_bss_done_wk,
                                        iwl_mld_emlsr_tmp_non_bss_done_wk);
+               wiphy_delayed_work_init(&mld_vif->mlo_scan_start_wk,
+                                       iwl_mld_mlo_scan_start_wk);
        }
        iwl_mld_init_internal_sta(&mld_vif->aux_sta);
 
index 49e2ce65557d6e5dde2df82ae0ca7b7ede09820f..874e9ef9e79856ae72c8069c0680a616218e9b2a 100644 (file)
@@ -133,6 +133,8 @@ struct iwl_mld_emlsr {
  * @low_latency_causes: bit flags, indicating the causes for low-latency,
  *     see @iwl_mld_low_latency_cause.
  * @ps_disabled: indicates that PS is disabled for this interface
+ * @last_link_activation_time: last time a link was activated, for
+ *     deferring MLO scans (to make them more reliable)
  * @mld: pointer to the mld structure.
  * @deflink: default link data, for use in non-MLO,
  * @link: reference to link data for each valid link, for use in MLO.
@@ -144,6 +146,7 @@ struct iwl_mld_emlsr {
  * @roc_activity: the id of the roc_activity running. Relevant for STA and
  *     p2p device only. Set to %ROC_NUM_ACTIVITIES when not in use.
  * @aux_sta: station used for remain on channel. Used in P2P device.
+ * @mlo_scan_start_wk: worker to start a deferred MLO scan
  */
 struct iwl_mld_vif {
        /* Add here fields that need clean up on restart */
@@ -161,6 +164,7 @@ struct iwl_mld_vif {
 #endif
                u8 low_latency_causes;
                bool ps_disabled;
+               time64_t last_link_activation_time;
        );
        /* And here fields that survive a fw restart */
        struct iwl_mld *mld;
@@ -179,6 +183,8 @@ struct iwl_mld_vif {
 #endif
        enum iwl_roc_activity roc_activity;
        struct iwl_mld_int_sta aux_sta;
+
+       struct wiphy_delayed_work mlo_scan_start_wk;
 };
 
 static inline struct iwl_mld_vif *
@@ -187,6 +193,12 @@ iwl_mld_vif_from_mac80211(struct ieee80211_vif *vif)
        return (void *)vif->drv_priv;
 }
 
+static inline struct ieee80211_vif *
+iwl_mld_vif_to_mac80211(struct iwl_mld_vif *mld_vif)
+{
+       return container_of((void *)mld_vif, struct ieee80211_vif, drv_priv);
+}
+
 #define iwl_mld_link_dereference_check(mld_vif, link_id)               \
        rcu_dereference_check((mld_vif)->link[link_id],                 \
                              lockdep_is_held(&mld_vif->mld->wiphy->mtx))
index d0f56189ad3fd0504a71c5b041e0f1914094b61b..c65ac6ecbd1d1d2d9081b39c3dc675c792bb42c0 100644 (file)
@@ -404,6 +404,7 @@ int iwl_mld_activate_link(struct iwl_mld *mld,
                          struct ieee80211_bss_conf *link)
 {
        struct iwl_mld_link *mld_link = iwl_mld_link_from_mac80211(link);
+       struct iwl_mld_vif *mld_vif = iwl_mld_vif_from_mac80211(mld_link->vif);
        int ret;
 
        lockdep_assert_wiphy(mld->wiphy);
@@ -418,6 +419,9 @@ int iwl_mld_activate_link(struct iwl_mld *mld,
                                        LINK_CONTEXT_MODIFY_ACTIVE);
        if (ret)
                mld_link->active = false;
+       else
+               mld_vif->last_link_activation_time =
+                       ktime_get_boottime_seconds();
 
        return ret;
 }
index 55d54bf29eae6985cfe1ab55fff2edd2df0627b0..cf3063e6ec53cd973eb8237c38960f9f64a5b173 100644 (file)
@@ -1800,9 +1800,12 @@ static void iwl_mld_int_mlo_scan_start(struct iwl_mld *mld,
        IWL_DEBUG_SCAN(mld, "Internal MLO scan: ret=%d\n", ret);
 }
 
+#define IWL_MLD_MLO_SCAN_BLOCKOUT_TIME         5 /* seconds */
+
 void iwl_mld_int_mlo_scan(struct iwl_mld *mld, struct ieee80211_vif *vif)
 {
        struct ieee80211_channel *channels[IEEE80211_MLD_MAX_NUM_LINKS];
+       struct iwl_mld_vif *mld_vif = iwl_mld_vif_from_mac80211(vif);
        unsigned long usable_links = ieee80211_vif_usable_links(vif);
        size_t n_channels = 0;
        u8 link_id;
@@ -1818,6 +1821,15 @@ void iwl_mld_int_mlo_scan(struct iwl_mld *mld, struct ieee80211_vif *vif)
                return;
        }
 
+       if (mld_vif->last_link_activation_time > ktime_get_boottime_seconds() -
+                                                IWL_MLD_MLO_SCAN_BLOCKOUT_TIME) {
+               /* timing doesn't matter much, so use the blockout time */
+               wiphy_delayed_work_queue(mld->wiphy,
+                                        &mld_vif->mlo_scan_start_wk,
+                                        IWL_MLD_MLO_SCAN_BLOCKOUT_TIME);
+               return;
+       }
+
        for_each_set_bit(link_id, &usable_links, IEEE80211_MLD_MAX_NUM_LINKS) {
                struct ieee80211_bss_conf *link_conf =
                        link_conf_dereference_check(vif, link_id);