Skip to content

Commit cb797dc

Browse files
Aditya Kumar Singhjfvogel
Aditya Kumar Singh
authored andcommitted
wifi: ath12k: fix handling of 6 GHz rules
commit 64a1ba4072b34af1b76bf15fca5c2075b8cc4d64 upstream. In the US country code, to avoid including 6 GHz rules in the 5 GHz rules list, the number of 5 GHz rules is set to a default constant value of 4 (REG_US_5G_NUM_REG_RULES). However, if there are more than 4 valid 5 GHz rules, the current logic will bypass the legitimate 6 GHz rules. For example, if there are 5 valid 5 GHz rules and 1 valid 6 GHz rule, the current logic will only consider 4 of the 5 GHz rules, treating the last valid rule as a 6 GHz rule. Consequently, the actual 6 GHz rule is never processed, leading to the eventual disabling of 6 GHz channels. To fix this issue, instead of hardcoding the value to 4, use a helper function to determine the number of 6 GHz rules present in the 5 GHz rules list and ignore only those rules. Tested-on: QCN9274 hw2.0 PCI WLAN.WBE.1.3.1-00173-QCAHKSWPL_SILICONZ-1 Cc: [email protected] Fixes: d889913 ("wifi: ath12k: driver for Qualcomm Wi-Fi 7 devices") Signed-off-by: Aditya Kumar Singh <[email protected]> Link: https://patch.msgid.link/20250123-fix_6ghz_rules_handling-v1-1-d734bfa58ff4@oss.qualcomm.com Signed-off-by: Jeff Johnson <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]> (cherry picked from commit 44de00e8bc8f8bf387799c4d2d8f5c4e30377c29) Signed-off-by: Jack Vogel <[email protected]>
1 parent d5ba0c9 commit cb797dc

File tree

2 files changed

+45
-17
lines changed

2 files changed

+45
-17
lines changed

drivers/net/wireless/ath/ath12k/wmi.c

+45-16
Original file line numberDiff line numberDiff line change
@@ -4681,6 +4681,22 @@ static struct ath12k_reg_rule
46814681
return reg_rule_ptr;
46824682
}
46834683

4684+
static u8 ath12k_wmi_ignore_num_extra_rules(struct ath12k_wmi_reg_rule_ext_params *rule,
4685+
u32 num_reg_rules)
4686+
{
4687+
u8 num_invalid_5ghz_rules = 0;
4688+
u32 count, start_freq;
4689+
4690+
for (count = 0; count < num_reg_rules; count++) {
4691+
start_freq = le32_get_bits(rule[count].freq_info, REG_RULE_START_FREQ);
4692+
4693+
if (start_freq >= ATH12K_MIN_6G_FREQ)
4694+
num_invalid_5ghz_rules++;
4695+
}
4696+
4697+
return num_invalid_5ghz_rules;
4698+
}
4699+
46844700
static int ath12k_pull_reg_chan_list_ext_update_ev(struct ath12k_base *ab,
46854701
struct sk_buff *skb,
46864702
struct ath12k_reg_info *reg_info)
@@ -4691,6 +4707,7 @@ static int ath12k_pull_reg_chan_list_ext_update_ev(struct ath12k_base *ab,
46914707
u32 num_2g_reg_rules, num_5g_reg_rules;
46924708
u32 num_6g_reg_rules_ap[WMI_REG_CURRENT_MAX_AP_TYPE];
46934709
u32 num_6g_reg_rules_cl[WMI_REG_CURRENT_MAX_AP_TYPE][WMI_REG_MAX_CLIENT_TYPE];
4710+
u8 num_invalid_5ghz_ext_rules;
46944711
u32 total_reg_rules = 0;
46954712
int ret, i, j;
46964713

@@ -4784,20 +4801,6 @@ static int ath12k_pull_reg_chan_list_ext_update_ev(struct ath12k_base *ab,
47844801

47854802
memcpy(reg_info->alpha2, &ev->alpha2, REG_ALPHA2_LEN);
47864803

4787-
/* FIXME: Currently FW includes 6G reg rule also in 5G rule
4788-
* list for country US.
4789-
* Having same 6G reg rule in 5G and 6G rules list causes
4790-
* intersect check to be true, and same rules will be shown
4791-
* multiple times in iw cmd. So added hack below to avoid
4792-
* parsing 6G rule from 5G reg rule list, and this can be
4793-
* removed later, after FW updates to remove 6G reg rule
4794-
* from 5G rules list.
4795-
*/
4796-
if (memcmp(reg_info->alpha2, "US", 2) == 0) {
4797-
reg_info->num_5g_reg_rules = REG_US_5G_NUM_REG_RULES;
4798-
num_5g_reg_rules = reg_info->num_5g_reg_rules;
4799-
}
4800-
48014804
reg_info->dfs_region = le32_to_cpu(ev->dfs_region);
48024805
reg_info->phybitmap = le32_to_cpu(ev->phybitmap);
48034806
reg_info->num_phy = le32_to_cpu(ev->num_phy);
@@ -4900,8 +4903,29 @@ static int ath12k_pull_reg_chan_list_ext_update_ev(struct ath12k_base *ab,
49004903
}
49014904
}
49024905

4906+
ext_wmi_reg_rule += num_2g_reg_rules;
4907+
4908+
/* Firmware might include 6 GHz reg rule in 5 GHz rule list
4909+
* for few countries along with separate 6 GHz rule.
4910+
* Having same 6 GHz reg rule in 5 GHz and 6 GHz rules list
4911+
* causes intersect check to be true, and same rules will be
4912+
* shown multiple times in iw cmd.
4913+
* Hence, avoid parsing 6 GHz rule from 5 GHz reg rule list
4914+
*/
4915+
num_invalid_5ghz_ext_rules = ath12k_wmi_ignore_num_extra_rules(ext_wmi_reg_rule,
4916+
num_5g_reg_rules);
4917+
4918+
if (num_invalid_5ghz_ext_rules) {
4919+
ath12k_dbg(ab, ATH12K_DBG_WMI,
4920+
"CC: %s 5 GHz reg rules number %d from fw, %d number of invalid 5 GHz rules",
4921+
reg_info->alpha2, reg_info->num_5g_reg_rules,
4922+
num_invalid_5ghz_ext_rules);
4923+
4924+
num_5g_reg_rules = num_5g_reg_rules - num_invalid_5ghz_ext_rules;
4925+
reg_info->num_5g_reg_rules = num_5g_reg_rules;
4926+
}
4927+
49034928
if (num_5g_reg_rules) {
4904-
ext_wmi_reg_rule += num_2g_reg_rules;
49054929
reg_info->reg_rules_5g_ptr =
49064930
create_ext_reg_rules_from_wmi(num_5g_reg_rules,
49074931
ext_wmi_reg_rule);
@@ -4913,7 +4937,12 @@ static int ath12k_pull_reg_chan_list_ext_update_ev(struct ath12k_base *ab,
49134937
}
49144938
}
49154939

4916-
ext_wmi_reg_rule += num_5g_reg_rules;
4940+
/* We have adjusted the number of 5 GHz reg rules above. But still those
4941+
* many rules needs to be adjusted in ext_wmi_reg_rule.
4942+
*
4943+
* NOTE: num_invalid_5ghz_ext_rules will be 0 for rest other cases.
4944+
*/
4945+
ext_wmi_reg_rule += (num_5g_reg_rules + num_invalid_5ghz_ext_rules);
49174946

49184947
for (i = 0; i < WMI_REG_CURRENT_MAX_AP_TYPE; i++) {
49194948
reg_info->reg_rules_6g_ap_ptr[i] =

drivers/net/wireless/ath/ath12k/wmi.h

-1
Original file line numberDiff line numberDiff line change
@@ -3943,7 +3943,6 @@ struct ath12k_wmi_eht_rate_set_params {
39433943
#define MAX_REG_RULES 10
39443944
#define REG_ALPHA2_LEN 2
39453945
#define MAX_6G_REG_RULES 5
3946-
#define REG_US_5G_NUM_REG_RULES 4
39473946

39483947
enum wmi_start_event_param {
39493948
WMI_VDEV_START_RESP_EVENT = 0,

0 commit comments

Comments
 (0)