wifi: ath12k: Add helper function ath12k_mac_update_freq_range()
authorRajat Soni <quic_rajson@quicinc.com>
Tue, 8 Apr 2025 04:21:26 +0000 (09:51 +0530)
committerJeff Johnson <jeff.johnson@oss.qualcomm.com>
Thu, 17 Apr 2025 22:49:33 +0000 (15:49 -0700)
In a subsequent change, the frequency range needs to be updated with
each regulatory update. Since the current function also modifies the
DISABLED flag in the actual channel list, which should always align
with hardware-supported start and end frequencies rather than the
current operating ones, the existing function cannot be called again.
Therefore, the logic for setting the frequency range needs to be
refactored.

To address this, refactor the frequency setting part into a new
helper function, ath12k_mac_update_freq_range(). Since this needs
to be done independently of updating the DISABLED flag, call the new
helper function ath12k_mac_update_freq_range() after updating the
channel list for each band.

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

Signed-off-by: Rajat Soni <quic_rajson@quicinc.com>
Reviewed-by: Vasanthakumar Thiagarajan <vasanthakumar.thiagarajan@oss.qualcomm.com>
Link: https://patch.msgid.link/20250408042128.720263-2-quic_rajson@quicinc.com
Signed-off-by: Jeff Johnson <jeff.johnson@oss.qualcomm.com>
drivers/net/wireless/ath/ath12k/mac.c
drivers/net/wireless/ath/ath12k/mac.h

index dfc8038..660dd4b 100644 (file)
@@ -10865,6 +10865,16 @@ static const struct ieee80211_ops ath12k_ops = {
 #endif
 };
 
+void ath12k_mac_update_freq_range(struct ath12k *ar,
+                                 u32 freq_low, u32 freq_high)
+{
+       if (!(freq_low && freq_high))
+               return;
+
+       ar->freq_range.start_freq = MHZ_TO_KHZ(freq_low);
+       ar->freq_range.end_freq = MHZ_TO_KHZ(freq_high);
+}
+
 static void ath12k_mac_update_ch_list(struct ath12k *ar,
                                      struct ieee80211_supported_band *band,
                                      u32 freq_low, u32 freq_high)
@@ -10879,9 +10889,6 @@ static void ath12k_mac_update_ch_list(struct ath12k *ar,
                    band->channels[i].center_freq > freq_high)
                        band->channels[i].flags |= IEEE80211_CHAN_DISABLED;
        }
-
-       ar->freq_range.start_freq = MHZ_TO_KHZ(freq_low);
-       ar->freq_range.end_freq = MHZ_TO_KHZ(freq_high);
 }
 
 static u32 ath12k_get_phy_id(struct ath12k *ar, u32 band)
@@ -10939,6 +10946,9 @@ static int ath12k_mac_setup_channels_rates(struct ath12k *ar,
                ath12k_mac_update_ch_list(ar, band,
                                          reg_cap->low_2ghz_chan,
                                          reg_cap->high_2ghz_chan);
+
+               ath12k_mac_update_freq_range(ar, reg_cap->low_2ghz_chan,
+                                            reg_cap->high_2ghz_chan);
        }
 
        if (supported_bands & WMI_HOST_WLAN_5GHZ_CAP) {
@@ -10961,6 +10971,9 @@ static int ath12k_mac_setup_channels_rates(struct ath12k *ar,
                        ath12k_mac_update_ch_list(ar, band,
                                                  reg_cap->low_5ghz_chan,
                                                  reg_cap->high_5ghz_chan);
+
+                       ath12k_mac_update_freq_range(ar, reg_cap->low_5ghz_chan,
+                                                    reg_cap->high_5ghz_chan);
                        ah->use_6ghz_regd = true;
                }
 
@@ -10990,6 +11003,9 @@ static int ath12k_mac_setup_channels_rates(struct ath12k *ar,
                        ath12k_mac_update_ch_list(ar, band,
                                                  reg_cap->low_5ghz_chan,
                                                  reg_cap->high_5ghz_chan);
+
+                       ath12k_mac_update_freq_range(ar, reg_cap->low_5ghz_chan,
+                                                    reg_cap->high_5ghz_chan);
                }
        }
 
index 6c5f9d5..da37332 100644 (file)
@@ -126,4 +126,6 @@ struct ath12k *ath12k_get_ar_by_vif(struct ieee80211_hw *hw,
                                    struct ieee80211_vif *vif,
                                    u8 link_id);
 int ath12k_mac_get_fw_stats(struct ath12k *ar, struct ath12k_fw_stats_req_params *param);
+void ath12k_mac_update_freq_range(struct ath12k *ar,
+                                 u32 freq_low, u32 freq_high);
 #endif