]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
wifi: iwlwifi: mld: add chan-load hysteresis for MLO scan triggers
authorAvinash Bhatt <avinash.bhatt@intel.com>
Tue, 12 May 2026 19:34:36 +0000 (22:34 +0300)
committerMiri Korenblit <miriam.rachel.korenblit@intel.com>
Tue, 26 May 2026 12:17:11 +0000 (15:17 +0300)
Introduce a three-level, table-driven hysteresis mechanism for
deciding when to trigger internal MLO scans based on MCLM Chan
Load. Prevents repeated triggers under fluctuating load conditions.

Signed-off-by: Avinash Bhatt <avinash.bhatt@intel.com>
Link: https://patch.msgid.link/20260512222731.2db48151d32d.I8660f0660a95358bda067af806d28bc2fa6f7f76@changeid
Signed-off-by: Miri Korenblit <miriam.rachel.korenblit@intel.com>
drivers/net/wireless/intel/iwlwifi/mld/link.c
drivers/net/wireless/intel/iwlwifi/mld/link.h
drivers/net/wireless/intel/iwlwifi/mld/mlo.c
drivers/net/wireless/intel/iwlwifi/mld/stats.c

index 9e40b334ee1fab544da1bf32a399fc6f04d6868b..a8d146edc4bdb0410d4e8aec036fe8a83c62ed3f 100644 (file)
 #include "fw/api/context.h"
 #include "fw/dbg.h"
 
+/**
+ * struct iwl_mld_link_chan_load_threshold - channel load thresholds
+ * @high_lim: level up transition thresholds, in percentage
+ * @low_lim: level down transition thresholds, in percentage
+ */
+struct iwl_mld_link_chan_load_threshold {
+       u8 high_lim;
+       u8 low_lim;
+};
+
+static const struct iwl_mld_link_chan_load_threshold
+link_chan_load_thresh_tbl[] = {
+       [LINK_CHAN_LOAD_LVL1] = { .high_lim = 45, .low_lim = 40 },
+       [LINK_CHAN_LOAD_LVL2] = { .high_lim = 70, .low_lim = 65 },
+       [LINK_CHAN_LOAD_LVL3] = { .high_lim = 85, .low_lim = 80 },
+};
+
 int iwl_mld_send_link_cmd(struct iwl_mld *mld,
                          struct iwl_link_config_cmd *cmd,
                          enum iwl_ctxt_action action)
@@ -792,6 +809,50 @@ int iwl_mld_get_chan_load_by_others(struct iwl_mld *mld,
        return chan_load;
 }
 
+/* Returns whether internal MLO Scan needs to be triggered */
+bool iwl_mld_chan_load_requires_scan(struct iwl_mld *mld,
+                                    struct ieee80211_bss_conf *link_conf,
+                                    u32 new_chan_load)
+{
+       struct iwl_mld_link *mld_link = iwl_mld_link_from_mac80211(link_conf);
+       enum iwl_mld_link_chan_load_level new_lvl;
+       bool scan_trig = false;
+
+       if (WARN_ON(!mld_link))
+               return false;
+
+       /* For each Level,
+        * First check if high limit threshold crosses
+        * If not then, check if low limit threshold crosses
+        * Set new level based on low limit thresh only if old level
+        * is not lower than level threshold
+        */
+       for (new_lvl = LINK_CHAN_LOAD_LVL_MAX;
+            new_lvl > LINK_CHAN_LOAD_LVL_NONE; new_lvl--) {
+               if (new_chan_load >=
+                   link_chan_load_thresh_tbl[new_lvl].high_lim)
+                       break;
+               if (new_chan_load >=
+                   link_chan_load_thresh_tbl[new_lvl].low_lim &&
+                   mld_link->chan_load_lvl >= new_lvl)
+                       break;
+       }
+
+       /* Trigger scan only for Level Up Transition */
+       if (new_lvl > mld_link->chan_load_lvl)
+               scan_trig = true;
+
+       IWL_DEBUG_EHT(mld,
+                     "Link %d: chan_load=%d%%, old_lvl=%d, new_lvl=%d, scan_trig=%d\n",
+                     link_conf->link_id, new_chan_load,
+                     mld_link->chan_load_lvl, new_lvl, scan_trig);
+
+       /* Update computed new level */
+       mld_link->chan_load_lvl = new_lvl;
+
+       return scan_trig;
+}
+
 static unsigned int
 iwl_mld_get_default_chan_load(struct ieee80211_bss_conf *link_conf)
 {
index 2b3e6b55367f6ae9f2a36ed2f3df853eced9932b..4527f054ce921da44531b6fb55a85bd0b72f93d3 100644 (file)
 #include "mld.h"
 #include "sta.h"
 
+enum iwl_mld_link_chan_load_level {
+       LINK_CHAN_LOAD_LVL_NONE,
+       LINK_CHAN_LOAD_LVL1,
+       LINK_CHAN_LOAD_LVL2,
+       LINK_CHAN_LOAD_LVL3,
+       LINK_CHAN_LOAD_LVL_MAX  = LINK_CHAN_LOAD_LVL3
+};
+
 /**
  * struct iwl_probe_resp_data - data for NoA/CSA updates
  * @rcu_head: used for freeing the data on update
@@ -50,6 +58,8 @@ struct iwl_probe_resp_data {
  * @silent_deactivation: next deactivation needs to be silent.
  * @probe_resp_data: data from FW notification to store NOA related data to be
  *     inserted into probe response.
+ * @chan_load_lvl: current channel load level for a link, computed based on
+ *     channel load by others on a link.
  */
 struct iwl_mld_link {
        struct rcu_head rcu_head;
@@ -63,6 +73,7 @@ struct iwl_mld_link {
                bool he_ru_2mhz_block;
                struct ieee80211_key_conf *tx_igtk;
                struct ieee80211_key_conf __rcu *bigtks[2];
+               enum iwl_mld_link_chan_load_level chan_load_lvl;
        );
        /* And here fields that survive a fw restart */
        struct iwl_mld_int_sta bcast_sta;
@@ -135,6 +146,10 @@ int iwl_mld_get_chan_load_by_others(struct iwl_mld *mld,
                                    struct ieee80211_bss_conf *link_conf,
                                    bool expect_active_link);
 
+bool  iwl_mld_chan_load_requires_scan(struct iwl_mld *mld,
+                                     struct ieee80211_bss_conf *link_conf,
+                                     u32 new_chan_load);
+
 void iwl_mld_handle_beacon_filter_notif(struct iwl_mld *mld,
                                        struct iwl_rx_packet *pkt);
 
index 8227ccb31d604e45fc074d49d867a72bbed423d1..2a3b2c883fc4adbd107676bdabc0147b29bd5cf7 100644 (file)
@@ -1,6 +1,6 @@
 // SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause
 /*
- * Copyright (C) 2024-2025 Intel Corporation
+ * Copyright (C) 2024-2026 Intel Corporation
  */
 #include "mlo.h"
 #include "phy.h"
@@ -1081,8 +1081,13 @@ static void iwl_mld_chan_load_update_iter(void *_data, u8 *mac,
                container_of((const void *)phy, struct ieee80211_chanctx_conf,
                             drv_priv);
        struct iwl_mld *mld = iwl_mld_vif_from_mac80211(vif)->mld;
-       struct ieee80211_bss_conf *prim_link;
+       u32 new_chan_load = phy->avg_channel_load_not_by_us;
+       struct ieee80211_bss_conf *prim_link, *link_conf;
        unsigned int prim_link_id;
+       int link_id;
+
+       if (!ieee80211_vif_is_mld(vif) || hweight16(vif->valid_links) <= 1)
+               return;
 
        prim_link_id = iwl_mld_get_primary_link(vif);
        prim_link = link_conf_dereference_protected(vif, prim_link_id);
@@ -1090,6 +1095,25 @@ static void iwl_mld_chan_load_update_iter(void *_data, u8 *mac,
        if (WARN_ON(!prim_link))
                return;
 
+       /* Evaluate MLO Internal Scan for high chan load beyond thresholds */
+       for_each_vif_active_link(vif, link_conf, link_id) {
+               if (rcu_access_pointer(link_conf->chanctx_conf) != chanctx)
+                       continue;
+
+               if (iwl_mld_chan_load_requires_scan(mld,
+                                                   link_conf,
+                                                   new_chan_load)) {
+                       /* When EMLSR is active, only trigger scan based on
+                        * primary link
+                        */
+                       if (iwl_mld_emlsr_active(vif) && link_conf != prim_link)
+                               continue;
+
+                       iwl_mld_int_mlo_scan(mld, vif);
+                       return;
+               }
+       }
+
        if (chanctx != rcu_access_pointer(prim_link->chanctx_conf))
                return;
 
@@ -1107,7 +1131,6 @@ static void iwl_mld_chan_load_update_iter(void *_data, u8 *mac,
                                           prim_link_id);
        } else {
                u32 old_chan_load = data->prev_chan_load_not_by_us;
-               u32 new_chan_load = phy->avg_channel_load_not_by_us;
                u32 min_thresh = iwl_mld_get_min_chan_load_thresh(chanctx);
 
 #define THRESHOLD_CROSSED(threshold) \
index 6e826797f63732c275ef71d0b8d098f6da9de741..b93e0f8ab5fbcd0573d5213a91cae48f1f70d8a0 100644 (file)
@@ -515,6 +515,10 @@ static void iwl_mld_fill_chanctx_stats(struct ieee80211_hw *hw,
                                                  (old_load >> 1);
        }
 
+       IWL_DEBUG_EHT(phy->mld,
+                     "PHY %d: load_by_us=%u%% load_not_by_us=%u%%\n",
+                     phy->fw_id, phy->channel_load_by_us, new_load);
+
        iwl_mld_emlsr_check_chan_load(hw, phy, old_load);
 }