From 8ffb3b2829773455641d406eada7c9bfaf65b89e Mon Sep 17 00:00:00 2001 From: Mantas Pucka Date: Wed, 16 Apr 2025 16:47:30 +0300 Subject: [PATCH] mac80211: ath12k: fix regdb parsing for 6GHz Add backport patch that fixes ath12k regdomain parsing failure in 6GHz band triggered by the latest regdb/board-2.bin update. Signed-off-by: Mantas Pucka Link: https://github.com/openwrt/openwrt/pull/18512 Signed-off-by: Robert Marko --- ...i-ath12k-fix-handling-of-6-GHz-rules.patch | 140 ++++++++++++++++++ 1 file changed, 140 insertions(+) create mode 100644 package/kernel/mac80211/patches/ath12k/003-wifi-ath12k-fix-handling-of-6-GHz-rules.patch diff --git a/package/kernel/mac80211/patches/ath12k/003-wifi-ath12k-fix-handling-of-6-GHz-rules.patch b/package/kernel/mac80211/patches/ath12k/003-wifi-ath12k-fix-handling-of-6-GHz-rules.patch new file mode 100644 index 00000000000..8df49d38d31 --- /dev/null +++ b/package/kernel/mac80211/patches/ath12k/003-wifi-ath12k-fix-handling-of-6-GHz-rules.patch @@ -0,0 +1,140 @@ +From 64a1ba4072b34af1b76bf15fca5c2075b8cc4d64 Mon Sep 17 00:00:00 2001 +From: Aditya Kumar Singh +Date: Thu, 23 Jan 2025 21:51:38 +0530 +Subject: [PATCH] wifi: ath12k: fix handling of 6 GHz rules + +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: stable@vger.kernel.org +Fixes: d889913205cf ("wifi: ath12k: driver for Qualcomm Wi-Fi 7 devices") +Signed-off-by: Aditya Kumar Singh +Link: https://patch.msgid.link/20250123-fix_6ghz_rules_handling-v1-1-d734bfa58ff4@oss.qualcomm.com +Signed-off-by: Jeff Johnson +--- + drivers/net/wireless/ath/ath12k/wmi.c | 61 ++++++++++++++++++++++++++--------- + drivers/net/wireless/ath/ath12k/wmi.h | 1 - + 2 files changed, 45 insertions(+), 17 deletions(-) + +--- a/drivers/net/wireless/ath/ath12k/wmi.c ++++ b/drivers/net/wireless/ath/ath12k/wmi.c +@@ -4790,6 +4790,22 @@ static struct ath12k_reg_rule + return reg_rule_ptr; + } + ++static u8 ath12k_wmi_ignore_num_extra_rules(struct ath12k_wmi_reg_rule_ext_params *rule, ++ u32 num_reg_rules) ++{ ++ u8 num_invalid_5ghz_rules = 0; ++ u32 count, start_freq; ++ ++ for (count = 0; count < num_reg_rules; count++) { ++ start_freq = le32_get_bits(rule[count].freq_info, REG_RULE_START_FREQ); ++ ++ if (start_freq >= ATH12K_MIN_6G_FREQ) ++ num_invalid_5ghz_rules++; ++ } ++ ++ return num_invalid_5ghz_rules; ++} ++ + static int ath12k_pull_reg_chan_list_ext_update_ev(struct ath12k_base *ab, + struct sk_buff *skb, + struct ath12k_reg_info *reg_info) +@@ -4800,6 +4816,7 @@ static int ath12k_pull_reg_chan_list_ext + u32 num_2g_reg_rules, num_5g_reg_rules; + u32 num_6g_reg_rules_ap[WMI_REG_CURRENT_MAX_AP_TYPE]; + u32 num_6g_reg_rules_cl[WMI_REG_CURRENT_MAX_AP_TYPE][WMI_REG_MAX_CLIENT_TYPE]; ++ u8 num_invalid_5ghz_ext_rules; + u32 total_reg_rules = 0; + int ret, i, j; + +@@ -4893,20 +4910,6 @@ static int ath12k_pull_reg_chan_list_ext + + memcpy(reg_info->alpha2, &ev->alpha2, REG_ALPHA2_LEN); + +- /* FIXME: Currently FW includes 6G reg rule also in 5G rule +- * list for country US. +- * Having same 6G reg rule in 5G and 6G rules list causes +- * intersect check to be true, and same rules will be shown +- * multiple times in iw cmd. So added hack below to avoid +- * parsing 6G rule from 5G reg rule list, and this can be +- * removed later, after FW updates to remove 6G reg rule +- * from 5G rules list. +- */ +- if (memcmp(reg_info->alpha2, "US", 2) == 0) { +- reg_info->num_5g_reg_rules = REG_US_5G_NUM_REG_RULES; +- num_5g_reg_rules = reg_info->num_5g_reg_rules; +- } +- + reg_info->dfs_region = le32_to_cpu(ev->dfs_region); + reg_info->phybitmap = le32_to_cpu(ev->phybitmap); + reg_info->num_phy = le32_to_cpu(ev->num_phy); +@@ -5009,8 +5012,29 @@ static int ath12k_pull_reg_chan_list_ext + } + } + ++ ext_wmi_reg_rule += num_2g_reg_rules; ++ ++ /* Firmware might include 6 GHz reg rule in 5 GHz rule list ++ * for few countries along with separate 6 GHz rule. ++ * Having same 6 GHz reg rule in 5 GHz and 6 GHz rules list ++ * causes intersect check to be true, and same rules will be ++ * shown multiple times in iw cmd. ++ * Hence, avoid parsing 6 GHz rule from 5 GHz reg rule list ++ */ ++ num_invalid_5ghz_ext_rules = ath12k_wmi_ignore_num_extra_rules(ext_wmi_reg_rule, ++ num_5g_reg_rules); ++ ++ if (num_invalid_5ghz_ext_rules) { ++ ath12k_dbg(ab, ATH12K_DBG_WMI, ++ "CC: %s 5 GHz reg rules number %d from fw, %d number of invalid 5 GHz rules", ++ reg_info->alpha2, reg_info->num_5g_reg_rules, ++ num_invalid_5ghz_ext_rules); ++ ++ num_5g_reg_rules = num_5g_reg_rules - num_invalid_5ghz_ext_rules; ++ reg_info->num_5g_reg_rules = num_5g_reg_rules; ++ } ++ + if (num_5g_reg_rules) { +- ext_wmi_reg_rule += num_2g_reg_rules; + reg_info->reg_rules_5g_ptr = + create_ext_reg_rules_from_wmi(num_5g_reg_rules, + ext_wmi_reg_rule); +@@ -5022,7 +5046,12 @@ static int ath12k_pull_reg_chan_list_ext + } + } + +- ext_wmi_reg_rule += num_5g_reg_rules; ++ /* We have adjusted the number of 5 GHz reg rules above. But still those ++ * many rules needs to be adjusted in ext_wmi_reg_rule. ++ * ++ * NOTE: num_invalid_5ghz_ext_rules will be 0 for rest other cases. ++ */ ++ ext_wmi_reg_rule += (num_5g_reg_rules + num_invalid_5ghz_ext_rules); + + for (i = 0; i < WMI_REG_CURRENT_MAX_AP_TYPE; i++) { + reg_info->reg_rules_6g_ap_ptr[i] = +--- a/drivers/net/wireless/ath/ath12k/wmi.h ++++ b/drivers/net/wireless/ath/ath12k/wmi.h +@@ -3965,7 +3965,6 @@ struct ath12k_wmi_eht_rate_set_params { + #define MAX_REG_RULES 10 + #define REG_ALPHA2_LEN 2 + #define MAX_6G_REG_RULES 5 +-#define REG_US_5G_NUM_REG_RULES 4 + + struct wmi_set_current_country_arg { + u8 alpha2[REG_ALPHA2_LEN];