]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
wifi: ath12k: update unsupported bandwidth flags in reg rules
authorHarshitha Prem <quic_hprem@quicinc.com>
Tue, 1 Jul 2025 13:59:02 +0000 (19:29 +0530)
committerJeff Johnson <jeff.johnson@oss.qualcomm.com>
Thu, 10 Jul 2025 14:29:44 +0000 (07:29 -0700)
The maximum bandwidth an interface can operate in is defined by the
configured country. However, currently, it is able to operate in
bandwidths greater than the allowed bandwidth. For example,
the Central African Republic (CF) supports a maximum bandwidth of 40 MHz
in both the 2 GHz and 5 GHz bands, but an interface is still able to
operate in bandwidths higher than 40 MHz. This issue arises because the
regulatory rules in the regd are not updated with these restrictions
received from firmware on the maximum bandwidth.

Hence, update the regulatory rules with unsupported bandwidth flags based
on the maximum bandwidth to ensure compliance with country-specific
regulations.

Tested-on: QCN9274 hw2.0 PCI WLAN.WBE.1.4.1-00199-QCAHKSWPL_SILICONZ-1
Tested-on: WCN7850 hw2.0 PCI WLAN.HMT.1.1.c5-00284-QCAHMTSWPL_V1.0_V2.0_SILICONZ-3

Fixes: d889913205cf ("wifi: ath12k: driver for Qualcomm Wi-Fi 7 devices")
Signed-off-by: Harshitha Prem <quic_hprem@quicinc.com>
Signed-off-by: Amith A <quic_amitajit@quicinc.com>
Reviewed-by: Vasanthakumar Thiagarajan <vasanthakumar.thiagarajan@oss.qualcomm.com>
Link: https://patch.msgid.link/20250701135902.722851-1-quic_amitajit@quicinc.com
Signed-off-by: Jeff Johnson <jeff.johnson@oss.qualcomm.com>
drivers/net/wireless/ath/ath12k/reg.c

index 96254d6fc6757c2901294aa5a33cc4d8793fcdf7..7898f6981e5a8f2af5667d0943109cb17646ed84 100644 (file)
@@ -426,6 +426,29 @@ ath12k_map_fw_dfs_region(enum ath12k_dfs_region dfs_region)
        }
 }
 
+static u32 ath12k_get_bw_reg_flags(u16 max_bw)
+{
+       switch (max_bw) {
+       case 20:
+               return NL80211_RRF_NO_HT40 |
+                       NL80211_RRF_NO_80MHZ |
+                       NL80211_RRF_NO_160MHZ |
+                       NL80211_RRF_NO_320MHZ;
+       case 40:
+               return NL80211_RRF_NO_80MHZ |
+                       NL80211_RRF_NO_160MHZ |
+                       NL80211_RRF_NO_320MHZ;
+       case 80:
+               return NL80211_RRF_NO_160MHZ |
+                       NL80211_RRF_NO_320MHZ;
+       case 160:
+               return NL80211_RRF_NO_320MHZ;
+       case 320:
+       default:
+               return 0;
+       }
+}
+
 static u32 ath12k_map_fw_reg_flags(u16 reg_flags)
 {
        u32 flags = 0;
@@ -704,7 +727,7 @@ ath12k_reg_build_regd(struct ath12k_base *ab,
                        reg_rule = reg_info->reg_rules_2g_ptr + i;
                        max_bw = min_t(u16, reg_rule->max_bw,
                                       reg_info->max_bw_2g);
-                       flags = 0;
+                       flags = ath12k_get_bw_reg_flags(reg_info->max_bw_2g);
                        ath12k_reg_update_freq_range(&ab->reg_freq_2ghz, reg_rule);
                } else if (reg_info->num_5g_reg_rules &&
                           (j < reg_info->num_5g_reg_rules)) {
@@ -718,13 +741,15 @@ ath12k_reg_build_regd(struct ath12k_base *ab,
                         * BW correction if required and applies flags as
                         * per other BW rule flags we pass from here
                         */
-                       flags = NL80211_RRF_AUTO_BW;
+                       flags = NL80211_RRF_AUTO_BW |
+                               ath12k_get_bw_reg_flags(reg_info->max_bw_5g);
                        ath12k_reg_update_freq_range(&ab->reg_freq_5ghz, reg_rule);
                } else if (reg_info->is_ext_reg_event && reg_6ghz_number &&
                           (k < reg_6ghz_number)) {
                        reg_rule = reg_rule_6ghz + k++;
                        max_bw = min_t(u16, reg_rule->max_bw, max_bw_6ghz);
-                       flags = NL80211_RRF_AUTO_BW;
+                       flags = NL80211_RRF_AUTO_BW |
+                               ath12k_get_bw_reg_flags(max_bw_6ghz);
                        if (reg_rule->psd_flag)
                                flags |= NL80211_RRF_PSD;
                        ath12k_reg_update_freq_range(&ab->reg_freq_6ghz, reg_rule);