wifi: iwlwifi: mld: skip unknown FW channel load values
authorJohannes Berg <johannes.berg@intel.com>
Thu, 24 Apr 2025 12:38:24 +0000 (15:38 +0300)
committerJohannes Berg <johannes.berg@intel.com>
Fri, 25 Apr 2025 09:26:33 +0000 (11:26 +0200)
The firmware statistics were previously reporting bogus/old
channel load values if the device hadn't been active on a
given channel; it'll report an unknown value now for those
statistics affected (channel_load and channel_load_not_by_us.)
Handle that by simply skipping the value, the averaging would
result in the exact same value as before.

Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Signed-off-by: Miri Korenblit <miriam.rachel.korenblit@intel.com>
Link: https://patch.msgid.link/20250424153620.db5410318642.I4d2981f68b915ad335bb02c926e9289c2a60ea6c@changeid
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
drivers/net/wireless/intel/iwlwifi/fw/api/stats.h
drivers/net/wireless/intel/iwlwifi/mld/stats.c

index 0a9f14fb04bef5aabc4d8a3799552cacac2ba68c..00713a9918792879637d4c2a2f96d9df5c210ce9 100644 (file)
@@ -1,6 +1,6 @@
 /* SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause */
 /*
- * Copyright (C) 2012-2014, 2018, 2020 - 2021, 2023 - 2024 Intel Corporation
+ * Copyright (C) 2012-2014, 2018, 2020-2021, 2023-2025 Intel Corporation
  * Copyright (C) 2013-2015 Intel Mobile Communications GmbH
  * Copyright (C) 2016-2017 Intel Deutschland GmbH
  */
@@ -584,6 +584,9 @@ struct iwl_stats_ntfy_per_phy {
        __le32 last_tx_ch_width_indx;
 } __packed; /* STATISTICS_NTFY_PER_PHY_API_S_VER_1 */
 
+/* unknown channel load (due to not being active on channel) */
+#define IWL_STATS_UNKNOWN_CHANNEL_LOAD 0xffffffff
+
 /**
  * struct iwl_stats_ntfy_per_sta
  *
index 0715bbc31031962f9cf56d8c7f385330bc66422c..360a6bfbbfb24d034bb52d44e46ea1bc5f016ed1 100644 (file)
@@ -467,12 +467,18 @@ static void iwl_mld_fill_chanctx_stats(struct ieee80211_hw *hw,
 
        old_load = phy->avg_channel_load_not_by_us;
        new_load = le32_to_cpu(per_phy[phy->fw_id].channel_load_not_by_us);
-       if (IWL_FW_CHECK(phy->mld, new_load > 100, "Invalid channel load %u\n",
-                        new_load))
+
+       if (IWL_FW_CHECK(phy->mld,
+                        new_load != IWL_STATS_UNKNOWN_CHANNEL_LOAD &&
+                               new_load > 100,
+                        "Invalid channel load %u\n", new_load))
                return;
 
-       /* give a weight of 0.5 for the old value */
-       phy->avg_channel_load_not_by_us = (new_load >> 1) + (old_load >> 1);
+       if (new_load != IWL_STATS_UNKNOWN_CHANNEL_LOAD) {
+               /* update giving a weight of 0.5 for the old value */
+               phy->avg_channel_load_not_by_us = (new_load >> 1) +
+                                                 (old_load >> 1);
+       }
 
        iwl_mld_emlsr_check_chan_load(hw, phy, old_load);
 }