public inbox for ath12k@lists.infradead.org
 help / color / mirror / Atom feed
* [PATCH ath-next 0/3] wifi: ath12k: Properly update frequency range
@ 2025-04-08  4:21 Rajat Soni
  2025-04-08  4:21 ` [PATCH ath-next 1/3] wifi: ath12k: Add helper function ath12k_mac_update_freq_range() Rajat Soni
                   ` (3 more replies)
  0 siblings, 4 replies; 11+ messages in thread
From: Rajat Soni @ 2025-04-08  4:21 UTC (permalink / raw)
  To: ath12k; +Cc: linux-wireless, Rajat Soni

This patch series ensures that frequency range is correctly updated
compliance with regulatory rules.

Aditya Kumar Singh (2):
  wifi: ath12k: Fix frequency range in driver
  wifi: ath12k: Update frequency range if reg rules changes

Rajat Soni (1):
  wifi: ath12k: Add helper function ath12k_mac_update_freq_range()

 drivers/net/wireless/ath/ath12k/core.h |  9 ++++
 drivers/net/wireless/ath/ath12k/mac.c  | 49 +++++++++++++++----
 drivers/net/wireless/ath/ath12k/mac.h  |  2 +
 drivers/net/wireless/ath/ath12k/reg.c  | 67 ++++++++++++++++++++++++++
 4 files changed, 118 insertions(+), 9 deletions(-)


base-commit: ac17b1211841c98a9b4c2900ba2a7f457c80cf90
-- 
2.34.1



^ permalink raw reply	[flat|nested] 11+ messages in thread

* [PATCH ath-next 1/3] wifi: ath12k: Add helper function ath12k_mac_update_freq_range()
  2025-04-08  4:21 [PATCH ath-next 0/3] wifi: ath12k: Properly update frequency range Rajat Soni
@ 2025-04-08  4:21 ` Rajat Soni
  2025-04-16  4:04   ` Vasanthakumar Thiagarajan
  2025-04-08  4:21 ` [PATCH ath-next 2/3] wifi: ath12k: Fix frequency range in driver Rajat Soni
                   ` (2 subsequent siblings)
  3 siblings, 1 reply; 11+ messages in thread
From: Rajat Soni @ 2025-04-08  4:21 UTC (permalink / raw)
  To: ath12k; +Cc: linux-wireless, Rajat Soni

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>
---
 drivers/net/wireless/ath/ath12k/mac.c | 22 +++++++++++++++++++---
 drivers/net/wireless/ath/ath12k/mac.h |  2 ++
 2 files changed, 21 insertions(+), 3 deletions(-)

diff --git a/drivers/net/wireless/ath/ath12k/mac.c b/drivers/net/wireless/ath/ath12k/mac.c
index 2b6bdc3d2b11..449aca719ad3 100644
--- a/drivers/net/wireless/ath/ath12k/mac.c
+++ b/drivers/net/wireless/ath/ath12k/mac.c
@@ -10811,6 +10811,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)
@@ -10825,9 +10835,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)
@@ -10885,6 +10892,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) {
@@ -10907,6 +10917,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;
 		}
 
@@ -10936,6 +10949,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);
 		}
 	}
 
diff --git a/drivers/net/wireless/ath/ath12k/mac.h b/drivers/net/wireless/ath/ath12k/mac.h
index 6c5f9d587a60..da37332352fe 100644
--- a/drivers/net/wireless/ath/ath12k/mac.h
+++ b/drivers/net/wireless/ath/ath12k/mac.h
@@ -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
-- 
2.34.1



^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [PATCH ath-next 2/3] wifi: ath12k: Fix frequency range in driver
  2025-04-08  4:21 [PATCH ath-next 0/3] wifi: ath12k: Properly update frequency range Rajat Soni
  2025-04-08  4:21 ` [PATCH ath-next 1/3] wifi: ath12k: Add helper function ath12k_mac_update_freq_range() Rajat Soni
@ 2025-04-08  4:21 ` Rajat Soni
  2025-04-16  4:04   ` Vasanthakumar Thiagarajan
  2025-04-16  4:09   ` Vasanthakumar Thiagarajan
  2025-04-08  4:21 ` [PATCH ath-next 3/3] wifi: ath12k: Update frequency range if reg rules changes Rajat Soni
  2025-04-17 22:57 ` [PATCH ath-next 0/3] wifi: ath12k: Properly update frequency range Jeff Johnson
  3 siblings, 2 replies; 11+ messages in thread
From: Rajat Soni @ 2025-04-08  4:21 UTC (permalink / raw)
  To: ath12k; +Cc: linux-wireless, Aditya Kumar Singh, Rajat Soni

From: Aditya Kumar Singh <aditya.kumar.singh@oss.qualcomm.com>

During the initial WMI exchange, the firmware updates the
hardware-supported start and end frequencies in the
ath12k_wmi_hal_reg_capabilities_ext_arg structure. These frequencies,
being hardware-supported, may not always align with the current
regulatory operating frequencies. When operating as multiple grouped
hardwares under a single wiphy, the driver advertises these values
directly to the upper layer in the per-radio frequency range,
which can be misleading.

Sample output snippet from iw phyX info command -

[..]
Supported wiphy radios:
          * Idx 0:
                  Frequency Range: 2312 MHz - 2732 MHz
		 [..]

          * Idx 1:
                  Frequency Range: 5150 MHz - 5330 MHz
		 [..]
[..]

The frequency range displayed above is incorrect because the driver
directly advertises the hardware-supported values to the upper layer.

The driver is aware of the current operating regulatory rules, and
hence it can use this information to determine the final operating
start and end frequencies.

To resolve this issue, add support to store the start and end
frequencies received during the regulatory update event.
Then, intersect these with the hardware-supported start and
end frequencies, and finally, advertise the intersected values to the
upper layer.

Sample output snippet from iw phyX info command after the fix -

[..]
Supported wiphy radios:
          * Idx 0:
                  Frequency Range: 2402 MHz - 2472 MHz
		 [..]

          * Idx 1:
                  Frequency Range: 5170 MHz - 5330 MHz
		 [..]
[..]

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: Aditya Kumar Singh <aditya.kumar.singh@oss.qualcomm.com>
Co-developed-by: Rajat Soni <quic_rajson@quicinc.com>
Signed-off-by: Rajat Soni <quic_rajson@quicinc.com>
---
 drivers/net/wireless/ath/ath12k/core.h |  9 ++++++
 drivers/net/wireless/ath/ath12k/mac.c  | 39 ++++++++++++++++++--------
 drivers/net/wireless/ath/ath12k/reg.c  | 13 +++++++++
 3 files changed, 49 insertions(+), 12 deletions(-)

diff --git a/drivers/net/wireless/ath/ath12k/core.h b/drivers/net/wireless/ath/ath12k/core.h
index e8d2a0c859f6..8099a5f54e83 100644
--- a/drivers/net/wireless/ath/ath12k/core.h
+++ b/drivers/net/wireless/ath/ath12k/core.h
@@ -880,6 +880,11 @@ struct ath12k_soc_dp_stats {
 	struct ath12k_soc_dp_tx_err_stats tx_err;
 };
 
+struct ath12k_reg_freq {
+	u32 start_freq;
+	u32 end_freq;
+};
+
 struct ath12k_mlo_memory {
 	struct target_mem_chunk chunk[ATH12K_QMI_WLANFW_MAX_NUM_MEM_SEG_V01];
 	int mlo_mem_size;
@@ -1122,6 +1127,10 @@ struct ath12k_base {
 	enum ath12k_firmware_mode fw_mode;
 	struct ath12k_ftm_event_obj ftm_event_obj;
 
+	struct ath12k_reg_freq reg_freq_2ghz;
+	struct ath12k_reg_freq reg_freq_5ghz;
+	struct ath12k_reg_freq reg_freq_6ghz;
+
 	/* must be last */
 	u8 drv_priv[] __aligned(sizeof(void *));
 };
diff --git a/drivers/net/wireless/ath/ath12k/mac.c b/drivers/net/wireless/ath/ath12k/mac.c
index 449aca719ad3..8c971a58fb6f 100644
--- a/drivers/net/wireless/ath/ath12k/mac.c
+++ b/drivers/net/wireless/ath/ath12k/mac.c
@@ -10859,16 +10859,17 @@ static int ath12k_mac_setup_channels_rates(struct ath12k *ar,
 {
 	struct ieee80211_supported_band *band;
 	struct ath12k_wmi_hal_reg_capabilities_ext_arg *reg_cap;
+	struct ath12k_base *ab = ar->ab;
+	u32 phy_id, freq_low, freq_high;
 	struct ath12k_hw *ah = ar->ah;
 	void *channels;
-	u32 phy_id;
 
 	BUILD_BUG_ON((ARRAY_SIZE(ath12k_2ghz_channels) +
 		      ARRAY_SIZE(ath12k_5ghz_channels) +
 		      ARRAY_SIZE(ath12k_6ghz_channels)) !=
 		     ATH12K_NUM_CHANS);
 
-	reg_cap = &ar->ab->hal_reg_cap[ar->pdev_idx];
+	reg_cap = &ab->hal_reg_cap[ar->pdev_idx];
 
 	if (supported_bands & WMI_HOST_WLAN_2GHZ_CAP) {
 		channels = kmemdup(ath12k_2ghz_channels,
@@ -10885,16 +10886,21 @@ static int ath12k_mac_setup_channels_rates(struct ath12k *ar,
 		band->bitrates = ath12k_g_rates;
 		bands[NL80211_BAND_2GHZ] = band;
 
-		if (ar->ab->hw_params->single_pdev_only) {
+		if (ab->hw_params->single_pdev_only) {
 			phy_id = ath12k_get_phy_id(ar, WMI_HOST_WLAN_2GHZ_CAP);
-			reg_cap = &ar->ab->hal_reg_cap[phy_id];
+			reg_cap = &ab->hal_reg_cap[phy_id];
 		}
+
+		freq_low = max(reg_cap->low_2ghz_chan,
+			       ab->reg_freq_2ghz.start_freq);
+		freq_high = min(reg_cap->high_2ghz_chan,
+				ab->reg_freq_2ghz.end_freq);
+
 		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);
+		ath12k_mac_update_freq_range(ar, freq_low, freq_high);
 	}
 
 	if (supported_bands & WMI_HOST_WLAN_5GHZ_CAP) {
@@ -10914,12 +10920,17 @@ static int ath12k_mac_setup_channels_rates(struct ath12k *ar,
 			band->n_bitrates = ath12k_a_rates_size;
 			band->bitrates = ath12k_a_rates;
 			bands[NL80211_BAND_6GHZ] = band;
+
+			freq_low = max(reg_cap->low_5ghz_chan,
+				       ab->reg_freq_6ghz.start_freq);
+			freq_high = min(reg_cap->high_5ghz_chan,
+					ab->reg_freq_6ghz.end_freq);
+
 			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);
+			ath12k_mac_update_freq_range(ar, freq_low, freq_high);
 			ah->use_6ghz_regd = true;
 		}
 
@@ -10941,17 +10952,21 @@ static int ath12k_mac_setup_channels_rates(struct ath12k *ar,
 			band->bitrates = ath12k_a_rates;
 			bands[NL80211_BAND_5GHZ] = band;
 
-			if (ar->ab->hw_params->single_pdev_only) {
+			if (ab->hw_params->single_pdev_only) {
 				phy_id = ath12k_get_phy_id(ar, WMI_HOST_WLAN_5GHZ_CAP);
-				reg_cap = &ar->ab->hal_reg_cap[phy_id];
+				reg_cap = &ab->hal_reg_cap[phy_id];
 			}
 
+			freq_low = max(reg_cap->low_5ghz_chan,
+				       ab->reg_freq_5ghz.start_freq);
+			freq_high = min(reg_cap->high_5ghz_chan,
+					ab->reg_freq_5ghz.end_freq);
+
 			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);
+			ath12k_mac_update_freq_range(ar, freq_low, freq_high);
 		}
 	}
 
diff --git a/drivers/net/wireless/ath/ath12k/reg.c b/drivers/net/wireless/ath/ath12k/reg.c
index 893650f76fb2..e1007b878f91 100644
--- a/drivers/net/wireless/ath/ath12k/reg.c
+++ b/drivers/net/wireless/ath/ath12k/reg.c
@@ -651,6 +651,16 @@ ath12k_reg_update_weather_radar_band(struct ath12k_base *ab,
 	*rule_idx = i;
 }
 
+static void ath12k_reg_update_freq_range(struct ath12k_reg_freq *reg_freq,
+					 struct ath12k_reg_rule *reg_rule)
+{
+	if (reg_freq->start_freq > reg_rule->start_freq)
+		reg_freq->start_freq = reg_rule->start_freq;
+
+	if (reg_freq->end_freq < reg_rule->end_freq)
+		reg_freq->end_freq = reg_rule->end_freq;
+}
+
 struct ieee80211_regdomain *
 ath12k_reg_build_regd(struct ath12k_base *ab,
 		      struct ath12k_reg_info *reg_info, bool intersect)
@@ -704,6 +714,7 @@ ath12k_reg_build_regd(struct ath12k_base *ab,
 			max_bw = min_t(u16, reg_rule->max_bw,
 				       reg_info->max_bw_2g);
 			flags = 0;
+			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)) {
 			reg_rule = reg_info->reg_rules_5g_ptr + j++;
@@ -717,6 +728,7 @@ ath12k_reg_build_regd(struct ath12k_base *ab,
 			 * per other BW rule flags we pass from here
 			 */
 			flags = NL80211_RRF_AUTO_BW;
+			ath12k_reg_update_freq_range(&ab->reg_freq_5ghz, reg_rule);
 		} else if (reg_info->is_ext_reg_event &&
 			   reg_info->num_6g_reg_rules_ap[WMI_REG_INDOOR_AP] &&
 			(k < reg_info->num_6g_reg_rules_ap[WMI_REG_INDOOR_AP])) {
@@ -724,6 +736,7 @@ ath12k_reg_build_regd(struct ath12k_base *ab,
 			max_bw = min_t(u16, reg_rule->max_bw,
 				       reg_info->max_bw_6g_ap[WMI_REG_INDOOR_AP]);
 			flags = NL80211_RRF_AUTO_BW;
+			ath12k_reg_update_freq_range(&ab->reg_freq_6ghz, reg_rule);
 		} else {
 			break;
 		}
-- 
2.34.1



^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [PATCH ath-next 3/3] wifi: ath12k: Update frequency range if reg rules changes
  2025-04-08  4:21 [PATCH ath-next 0/3] wifi: ath12k: Properly update frequency range Rajat Soni
  2025-04-08  4:21 ` [PATCH ath-next 1/3] wifi: ath12k: Add helper function ath12k_mac_update_freq_range() Rajat Soni
  2025-04-08  4:21 ` [PATCH ath-next 2/3] wifi: ath12k: Fix frequency range in driver Rajat Soni
@ 2025-04-08  4:21 ` Rajat Soni
  2025-04-16  4:15   ` Vasanthakumar Thiagarajan
  2025-04-17 22:57 ` [PATCH ath-next 0/3] wifi: ath12k: Properly update frequency range Jeff Johnson
  3 siblings, 1 reply; 11+ messages in thread
From: Rajat Soni @ 2025-04-08  4:21 UTC (permalink / raw)
  To: ath12k; +Cc: linux-wireless, Aditya Kumar Singh, Rajat Soni

From: Aditya Kumar Singh <aditya.kumar.singh@oss.qualcomm.com>

During the hardware register, driver updates the frequency range
during boot-up. However, if new regulatory rules are applied after
boot-up, the frequency range remains based on the older rules.
Since different countries have varying regulatory rules, the
frequency range can differ. Retaining the frequency range based on
outdated rules can be misleading.

Update the frequency range according to the new regulatory rules in
the function ath12k_regd_update().

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: Aditya Kumar Singh <aditya.kumar.singh@oss.qualcomm.com>
Co-developed-by: Rajat Soni <quic_rajson@quicinc.com>
Signed-off-by: Rajat Soni <quic_rajson@quicinc.com>
---
 drivers/net/wireless/ath/ath12k/reg.c | 54 +++++++++++++++++++++++++++
 1 file changed, 54 insertions(+)

diff --git a/drivers/net/wireless/ath/ath12k/reg.c b/drivers/net/wireless/ath/ath12k/reg.c
index e1007b878f91..0fed4e0096cb 100644
--- a/drivers/net/wireless/ath/ath12k/reg.c
+++ b/drivers/net/wireless/ath/ath12k/reg.c
@@ -6,6 +6,7 @@
 #include <linux/rtnetlink.h>
 #include "core.h"
 #include "debug.h"
+#include "mac.h"
 
 /* World regdom to be used in case default regd from fw is unavailable */
 #define ATH12K_2GHZ_CH01_11      REG_RULE(2412 - 10, 2462 + 10, 40, 0, 20, 0)
@@ -246,6 +247,8 @@ static void ath12k_copy_regd(struct ieee80211_regdomain *regd_orig,
 
 int ath12k_regd_update(struct ath12k *ar, bool init)
 {
+	u32 phy_id, freq_low = 0, freq_high = 0, supported_bands, band;
+	struct ath12k_wmi_hal_reg_capabilities_ext_arg *reg_cap;
 	struct ath12k_hw *ah = ath12k_ar_to_ah(ar);
 	struct ieee80211_hw *hw = ah->hw;
 	struct ieee80211_regdomain *regd, *regd_copy = NULL;
@@ -255,6 +258,47 @@ int ath12k_regd_update(struct ath12k *ar, bool init)
 
 	ab = ar->ab;
 
+	supported_bands = ar->pdev->cap.supported_bands;
+	if (supported_bands & WMI_HOST_WLAN_2GHZ_CAP) {
+		band = NL80211_BAND_2GHZ;
+	} else if (supported_bands & WMI_HOST_WLAN_5GHZ_CAP && !ar->supports_6ghz) {
+		band = NL80211_BAND_5GHZ;
+	} else if (supported_bands & WMI_HOST_WLAN_5GHZ_CAP && ar->supports_6ghz) {
+		band = NL80211_BAND_6GHZ;
+	} else {
+		/* This condition is not expected.
+		 */
+		WARN_ON(1);
+		ret = -EINVAL;
+		goto err;
+	}
+
+	reg_cap = &ab->hal_reg_cap[ar->pdev_idx];
+
+	if (ab->hw_params->single_pdev_only && !ar->supports_6ghz) {
+		phy_id = ar->pdev->cap.band[band].phy_id;
+		reg_cap = &ab->hal_reg_cap[phy_id];
+	}
+
+	/* Possible that due to reg change, current limits for supported
+	 * frequency changed. Update that
+	 */
+	if (supported_bands & WMI_HOST_WLAN_2GHZ_CAP) {
+		freq_low = max(reg_cap->low_2ghz_chan, ab->reg_freq_2ghz.start_freq);
+		freq_high = min(reg_cap->high_2ghz_chan, ab->reg_freq_2ghz.end_freq);
+	} else if (supported_bands & WMI_HOST_WLAN_5GHZ_CAP && !ar->supports_6ghz) {
+		freq_low = max(reg_cap->low_5ghz_chan, ab->reg_freq_5ghz.start_freq);
+		freq_high = min(reg_cap->high_5ghz_chan, ab->reg_freq_5ghz.end_freq);
+	} else if (supported_bands & WMI_HOST_WLAN_5GHZ_CAP && ar->supports_6ghz) {
+		freq_low = max(reg_cap->low_5ghz_chan, ab->reg_freq_6ghz.start_freq);
+		freq_high = min(reg_cap->high_5ghz_chan, ab->reg_freq_6ghz.end_freq);
+	}
+
+	ath12k_mac_update_freq_range(ar, freq_low, freq_high);
+
+	ath12k_dbg(ab, ATH12K_DBG_REG, "pdev %u reg updated freq limits %u->%u MHz\n",
+		   ar->pdev->pdev_id, freq_low, freq_high);
+
 	/* If one of the radios within ah has already updated the regd for
 	 * the wiphy, then avoid setting regd again
 	 */
@@ -704,6 +748,16 @@ ath12k_reg_build_regd(struct ath12k_base *ab,
 		   "\r\nCountry %s, CFG Regdomain %s FW Regdomain %d, num_reg_rules %d\n",
 		   alpha2, ath12k_reg_get_regdom_str(tmp_regd->dfs_region),
 		   reg_info->dfs_region, num_rules);
+
+	/* Reset start and end frequency for each band
+	 */
+	ab->reg_freq_5ghz.start_freq = INT_MAX;
+	ab->reg_freq_5ghz.end_freq = 0;
+	ab->reg_freq_2ghz.start_freq = INT_MAX;
+	ab->reg_freq_2ghz.end_freq = 0;
+	ab->reg_freq_6ghz.start_freq = INT_MAX;
+	ab->reg_freq_6ghz.end_freq = 0;
+
 	/* Update reg_rules[] below. Firmware is expected to
 	 * send these rules in order(2G rules first and then 5G)
 	 */
-- 
2.34.1



^ permalink raw reply related	[flat|nested] 11+ messages in thread

* Re: [PATCH ath-next 1/3] wifi: ath12k: Add helper function ath12k_mac_update_freq_range()
  2025-04-08  4:21 ` [PATCH ath-next 1/3] wifi: ath12k: Add helper function ath12k_mac_update_freq_range() Rajat Soni
@ 2025-04-16  4:04   ` Vasanthakumar Thiagarajan
  0 siblings, 0 replies; 11+ messages in thread
From: Vasanthakumar Thiagarajan @ 2025-04-16  4:04 UTC (permalink / raw)
  To: Rajat Soni, ath12k; +Cc: linux-wireless



On 4/8/2025 9:51 AM, Rajat Soni wrote:
> 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>


^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH ath-next 2/3] wifi: ath12k: Fix frequency range in driver
  2025-04-08  4:21 ` [PATCH ath-next 2/3] wifi: ath12k: Fix frequency range in driver Rajat Soni
@ 2025-04-16  4:04   ` Vasanthakumar Thiagarajan
  2025-04-16  4:09   ` Vasanthakumar Thiagarajan
  1 sibling, 0 replies; 11+ messages in thread
From: Vasanthakumar Thiagarajan @ 2025-04-16  4:04 UTC (permalink / raw)
  To: Rajat Soni, ath12k; +Cc: linux-wireless, Aditya Kumar Singh



On 4/8/2025 9:51 AM, Rajat Soni wrote:
> From: Aditya Kumar Singh <aditya.kumar.singh@oss.qualcomm.com>
> 
> During the initial WMI exchange, the firmware updates the
> hardware-supported start and end frequencies in the
> ath12k_wmi_hal_reg_capabilities_ext_arg structure. These frequencies,
> being hardware-supported, may not always align with the current
> regulatory operating frequencies. When operating as multiple grouped
> hardwares under a single wiphy, the driver advertises these values
> directly to the upper layer in the per-radio frequency range,
> which can be misleading.
> 
> Sample output snippet from iw phyX info command -
> 
> [..]
> Supported wiphy radios:
>            * Idx 0:
>                    Frequency Range: 2312 MHz - 2732 MHz
> 		 [..]
> 
>            * Idx 1:
>                    Frequency Range: 5150 MHz - 5330 MHz
> 		 [..]
> [..]
> 
> The frequency range displayed above is incorrect because the driver
> directly advertises the hardware-supported values to the upper layer.
> 
> The driver is aware of the current operating regulatory rules, and
> hence it can use this information to determine the final operating
> start and end frequencies.
> 
> To resolve this issue, add support to store the start and end
> frequencies received during the regulatory update event.
> Then, intersect these with the hardware-supported start and
> end frequencies, and finally, advertise the intersected values to the
> upper layer.
> 
> Sample output snippet from iw phyX info command after the fix -
> 
> [..]
> Supported wiphy radios:
>            * Idx 0:
>                    Frequency Range: 2402 MHz - 2472 MHz
> 		 [..]
> 
>            * Idx 1:
>                    Frequency Range: 5170 MHz - 5330 MHz
> 		 [..]
> [..]
> 
> 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: Aditya Kumar Singh <aditya.kumar.singh@oss.qualcomm.com>
> Co-developed-by: Rajat Soni <quic_rajson@quicinc.com>
> Signed-off-by: Rajat Soni <quic_rajson@quicinc.com>

Reviewed-by: Vasanthakumar Thiagarajan <vasanthakumar.thiagarajan@oss.qualcomm.com>


^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH ath-next 2/3] wifi: ath12k: Fix frequency range in driver
  2025-04-08  4:21 ` [PATCH ath-next 2/3] wifi: ath12k: Fix frequency range in driver Rajat Soni
  2025-04-16  4:04   ` Vasanthakumar Thiagarajan
@ 2025-04-16  4:09   ` Vasanthakumar Thiagarajan
  2025-04-16 14:42     ` Jeff Johnson
  1 sibling, 1 reply; 11+ messages in thread
From: Vasanthakumar Thiagarajan @ 2025-04-16  4:09 UTC (permalink / raw)
  To: Rajat Soni, ath12k; +Cc: linux-wireless, Aditya Kumar Singh



On 4/8/2025 9:51 AM, Rajat Soni wrote:
> From: Aditya Kumar Singh <aditya.kumar.singh@oss.qualcomm.com>
> 
> During the initial WMI exchange, the firmware updates the
> hardware-supported start and end frequencies in the
> ath12k_wmi_hal_reg_capabilities_ext_arg structure. These frequencies,
> being hardware-supported, may not always align with the current
> regulatory operating frequencies. When operating as multiple grouped
> hardwares under a single wiphy, the driver advertises these values
> directly to the upper layer in the per-radio frequency range,
> which can be misleading.
> 
> Sample output snippet from iw phyX info command -
> 
> [..]
> Supported wiphy radios:
>            * Idx 0:
>                    Frequency Range: 2312 MHz - 2732 MHz
> 		 [..]
> 
>            * Idx 1:
>                    Frequency Range: 5150 MHz - 5330 MHz
> 		 [..]
> [..]
> 
> The frequency range displayed above is incorrect because the driver
> directly advertises the hardware-supported values to the upper layer.
> 
> The driver is aware of the current operating regulatory rules, and
> hence it can use this information to determine the final operating
> start and end frequencies.
> 
> To resolve this issue, add support to store the start and end
> frequencies received during the regulatory update event.
> Then, intersect these with the hardware-supported start and
> end frequencies, and finally, advertise the intersected values to the
> upper layer.
> 
> Sample output snippet from iw phyX info command after the fix -
> 
> [..]
> Supported wiphy radios:
>            * Idx 0:
>                    Frequency Range: 2402 MHz - 2472 MHz
> 		 [..]
> 
>            * Idx 1:
>                    Frequency Range: 5170 MHz - 5330 MHz
> 		 [..]
> [..]
> 
> 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: Aditya Kumar Singh <aditya.kumar.singh@oss.qualcomm.com>
> Co-developed-by: Rajat Soni <quic_rajson@quicinc.com>
> Signed-off-by: Rajat Soni <quic_rajson@quicinc.com>
> ---
>   drivers/net/wireless/ath/ath12k/core.h |  9 ++++++
>   drivers/net/wireless/ath/ath12k/mac.c  | 39 ++++++++++++++++++--------
>   drivers/net/wireless/ath/ath12k/reg.c  | 13 +++++++++
>   3 files changed, 49 insertions(+), 12 deletions(-)
> 

You may need to rebase the series

Applying: wifi: ath12k: Add helper function ath12k_mac_update_freq_range()
Applying: wifi: ath12k: Fix frequency range in driver
error: patch failed: drivers/net/wireless/ath/ath12k/core.h:1122
error: drivers/net/wireless/ath/ath12k/core.h: patch does not apply
Patch failed at 0002 wifi: ath12k: Fix frequency range in driver


^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH ath-next 3/3] wifi: ath12k: Update frequency range if reg rules changes
  2025-04-08  4:21 ` [PATCH ath-next 3/3] wifi: ath12k: Update frequency range if reg rules changes Rajat Soni
@ 2025-04-16  4:15   ` Vasanthakumar Thiagarajan
  0 siblings, 0 replies; 11+ messages in thread
From: Vasanthakumar Thiagarajan @ 2025-04-16  4:15 UTC (permalink / raw)
  To: Rajat Soni, ath12k; +Cc: linux-wireless, Aditya Kumar Singh



On 4/8/2025 9:51 AM, Rajat Soni wrote:
> From: Aditya Kumar Singh <aditya.kumar.singh@oss.qualcomm.com>
> 
> During the hardware register, driver updates the frequency range
> during boot-up. However, if new regulatory rules are applied after
> boot-up, the frequency range remains based on the older rules.
> Since different countries have varying regulatory rules, the
> frequency range can differ. Retaining the frequency range based on
> outdated rules can be misleading.
> 
> Update the frequency range according to the new regulatory rules in
> the function ath12k_regd_update().
> 
> 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: Aditya Kumar Singh <aditya.kumar.singh@oss.qualcomm.com>
> Co-developed-by: Rajat Soni <quic_rajson@quicinc.com>
> Signed-off-by: Rajat Soni <quic_rajson@quicinc.com>

Reviewed-by: Vasanthakumar Thiagarajan <vasanthakumar.thiagarajan@oss.qualcomm.com>


^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH ath-next 2/3] wifi: ath12k: Fix frequency range in driver
  2025-04-16  4:09   ` Vasanthakumar Thiagarajan
@ 2025-04-16 14:42     ` Jeff Johnson
  2025-04-16 16:08       ` Vasanthakumar Thiagarajan
  0 siblings, 1 reply; 11+ messages in thread
From: Jeff Johnson @ 2025-04-16 14:42 UTC (permalink / raw)
  To: Vasanthakumar Thiagarajan, Rajat Soni, ath12k
  Cc: linux-wireless, Aditya Kumar Singh

On 4/15/2025 9:09 PM, Vasanthakumar Thiagarajan wrote:
> You may need to rebase the series
> 
> Applying: wifi: ath12k: Add helper function ath12k_mac_update_freq_range()
> Applying: wifi: ath12k: Fix frequency range in driver
> error: patch failed: drivers/net/wireless/ath/ath12k/core.h:1122
> error: drivers/net/wireless/ath/ath12k/core.h: patch does not apply
> Patch failed at 0002 wifi: ath12k: Fix frequency range in driver

It applied to my 'pending' branch with:
b4 am --prep-3way ...
git am -3 ...

/jeff




^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH ath-next 2/3] wifi: ath12k: Fix frequency range in driver
  2025-04-16 14:42     ` Jeff Johnson
@ 2025-04-16 16:08       ` Vasanthakumar Thiagarajan
  0 siblings, 0 replies; 11+ messages in thread
From: Vasanthakumar Thiagarajan @ 2025-04-16 16:08 UTC (permalink / raw)
  To: Jeff Johnson, Vasanthakumar Thiagarajan, Rajat Soni, ath12k
  Cc: linux-wireless, Aditya Kumar Singh



On 4/16/2025 8:12 PM, Jeff Johnson wrote:
> On 4/15/2025 9:09 PM, Vasanthakumar Thiagarajan wrote:
>> You may need to rebase the series
>>
>> Applying: wifi: ath12k: Add helper function ath12k_mac_update_freq_range()
>> Applying: wifi: ath12k: Fix frequency range in driver
>> error: patch failed: drivers/net/wireless/ath/ath12k/core.h:1122
>> error: drivers/net/wireless/ath/ath12k/core.h: patch does not apply
>> Patch failed at 0002 wifi: ath12k: Fix frequency range in driver
> 
> It applied to my 'pending' branch with:
> b4 am --prep-3way ...
> git am -3 ...
> 

Ok. I was trying them on main branch. I'll use pending branch for such checks. Thanks.


^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH ath-next 0/3] wifi: ath12k: Properly update frequency range
  2025-04-08  4:21 [PATCH ath-next 0/3] wifi: ath12k: Properly update frequency range Rajat Soni
                   ` (2 preceding siblings ...)
  2025-04-08  4:21 ` [PATCH ath-next 3/3] wifi: ath12k: Update frequency range if reg rules changes Rajat Soni
@ 2025-04-17 22:57 ` Jeff Johnson
  3 siblings, 0 replies; 11+ messages in thread
From: Jeff Johnson @ 2025-04-17 22:57 UTC (permalink / raw)
  To: ath12k, Rajat Soni; +Cc: linux-wireless


On Tue, 08 Apr 2025 09:51:25 +0530, Rajat Soni wrote:
> This patch series ensures that frequency range is correctly updated
> compliance with regulatory rules.
> 
> Aditya Kumar Singh (2):
>   wifi: ath12k: Fix frequency range in driver
>   wifi: ath12k: Update frequency range if reg rules changes
> 
> [...]

Applied, thanks!

[1/3] wifi: ath12k: Add helper function ath12k_mac_update_freq_range()
      commit: b7544de8a2984e61b95c58c1c6c1e8ce659b1021
[2/3] wifi: ath12k: Fix frequency range in driver
      commit: 657b0c72c4ad688d424560af98e3258b3f875a4d
[3/3] wifi: ath12k: Update frequency range if reg rules changes
      commit: 13324cecbb2c390a11f1fbfe87f3a5e62d6e4591

Best regards,
-- 
Jeff Johnson <jeff.johnson@oss.qualcomm.com>



^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2025-04-17 22:57 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-04-08  4:21 [PATCH ath-next 0/3] wifi: ath12k: Properly update frequency range Rajat Soni
2025-04-08  4:21 ` [PATCH ath-next 1/3] wifi: ath12k: Add helper function ath12k_mac_update_freq_range() Rajat Soni
2025-04-16  4:04   ` Vasanthakumar Thiagarajan
2025-04-08  4:21 ` [PATCH ath-next 2/3] wifi: ath12k: Fix frequency range in driver Rajat Soni
2025-04-16  4:04   ` Vasanthakumar Thiagarajan
2025-04-16  4:09   ` Vasanthakumar Thiagarajan
2025-04-16 14:42     ` Jeff Johnson
2025-04-16 16:08       ` Vasanthakumar Thiagarajan
2025-04-08  4:21 ` [PATCH ath-next 3/3] wifi: ath12k: Update frequency range if reg rules changes Rajat Soni
2025-04-16  4:15   ` Vasanthakumar Thiagarajan
2025-04-17 22:57 ` [PATCH ath-next 0/3] wifi: ath12k: Properly update frequency range Jeff Johnson

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox