@@ -4851,6 +4851,22 @@ static struct ath12k_reg_rule
48514851 return reg_rule_ptr ;
48524852}
48534853
4854+ static u8 ath12k_wmi_ignore_num_extra_rules (struct ath12k_wmi_reg_rule_ext_params * rule ,
4855+ u32 num_reg_rules )
4856+ {
4857+ u8 num_invalid_5ghz_rules = 0 ;
4858+ u32 count , start_freq ;
4859+
4860+ for (count = 0 ; count < num_reg_rules ; count ++ ) {
4861+ start_freq = le32_get_bits (rule [count ].freq_info , REG_RULE_START_FREQ );
4862+
4863+ if (start_freq >= ATH12K_MIN_6G_FREQ )
4864+ num_invalid_5ghz_rules ++ ;
4865+ }
4866+
4867+ return num_invalid_5ghz_rules ;
4868+ }
4869+
48544870static int ath12k_pull_reg_chan_list_ext_update_ev (struct ath12k_base * ab ,
48554871 struct sk_buff * skb ,
48564872 struct ath12k_reg_info * reg_info )
@@ -4861,6 +4877,7 @@ static int ath12k_pull_reg_chan_list_ext_update_ev(struct ath12k_base *ab,
48614877 u32 num_2g_reg_rules , num_5g_reg_rules ;
48624878 u32 num_6g_reg_rules_ap [WMI_REG_CURRENT_MAX_AP_TYPE ];
48634879 u32 num_6g_reg_rules_cl [WMI_REG_CURRENT_MAX_AP_TYPE ][WMI_REG_MAX_CLIENT_TYPE ];
4880+ u8 num_invalid_5ghz_ext_rules ;
48644881 u32 total_reg_rules = 0 ;
48654882 int ret , i , j ;
48664883
@@ -4954,20 +4971,6 @@ static int ath12k_pull_reg_chan_list_ext_update_ev(struct ath12k_base *ab,
49544971
49554972 memcpy (reg_info -> alpha2 , & ev -> alpha2 , REG_ALPHA2_LEN );
49564973
4957- /* FIXME: Currently FW includes 6G reg rule also in 5G rule
4958- * list for country US.
4959- * Having same 6G reg rule in 5G and 6G rules list causes
4960- * intersect check to be true, and same rules will be shown
4961- * multiple times in iw cmd. So added hack below to avoid
4962- * parsing 6G rule from 5G reg rule list, and this can be
4963- * removed later, after FW updates to remove 6G reg rule
4964- * from 5G rules list.
4965- */
4966- if (memcmp (reg_info -> alpha2 , "US" , 2 ) == 0 ) {
4967- reg_info -> num_5g_reg_rules = REG_US_5G_NUM_REG_RULES ;
4968- num_5g_reg_rules = reg_info -> num_5g_reg_rules ;
4969- }
4970-
49714974 reg_info -> dfs_region = le32_to_cpu (ev -> dfs_region );
49724975 reg_info -> phybitmap = le32_to_cpu (ev -> phybitmap );
49734976 reg_info -> num_phy = le32_to_cpu (ev -> num_phy );
@@ -5070,8 +5073,29 @@ static int ath12k_pull_reg_chan_list_ext_update_ev(struct ath12k_base *ab,
50705073 }
50715074 }
50725075
5076+ ext_wmi_reg_rule += num_2g_reg_rules ;
5077+
5078+ /* Firmware might include 6 GHz reg rule in 5 GHz rule list
5079+ * for few countries along with separate 6 GHz rule.
5080+ * Having same 6 GHz reg rule in 5 GHz and 6 GHz rules list
5081+ * causes intersect check to be true, and same rules will be
5082+ * shown multiple times in iw cmd.
5083+ * Hence, avoid parsing 6 GHz rule from 5 GHz reg rule list
5084+ */
5085+ num_invalid_5ghz_ext_rules = ath12k_wmi_ignore_num_extra_rules (ext_wmi_reg_rule ,
5086+ num_5g_reg_rules );
5087+
5088+ if (num_invalid_5ghz_ext_rules ) {
5089+ ath12k_dbg (ab , ATH12K_DBG_WMI ,
5090+ "CC: %s 5 GHz reg rules number %d from fw, %d number of invalid 5 GHz rules" ,
5091+ reg_info -> alpha2 , reg_info -> num_5g_reg_rules ,
5092+ num_invalid_5ghz_ext_rules );
5093+
5094+ num_5g_reg_rules = num_5g_reg_rules - num_invalid_5ghz_ext_rules ;
5095+ reg_info -> num_5g_reg_rules = num_5g_reg_rules ;
5096+ }
5097+
50735098 if (num_5g_reg_rules ) {
5074- ext_wmi_reg_rule += num_2g_reg_rules ;
50755099 reg_info -> reg_rules_5g_ptr =
50765100 create_ext_reg_rules_from_wmi (num_5g_reg_rules ,
50775101 ext_wmi_reg_rule );
@@ -5083,7 +5107,12 @@ static int ath12k_pull_reg_chan_list_ext_update_ev(struct ath12k_base *ab,
50835107 }
50845108 }
50855109
5086- ext_wmi_reg_rule += num_5g_reg_rules ;
5110+ /* We have adjusted the number of 5 GHz reg rules above. But still those
5111+ * many rules needs to be adjusted in ext_wmi_reg_rule.
5112+ *
5113+ * NOTE: num_invalid_5ghz_ext_rules will be 0 for rest other cases.
5114+ */
5115+ ext_wmi_reg_rule += (num_5g_reg_rules + num_invalid_5ghz_ext_rules );
50875116
50885117 for (i = 0 ; i < WMI_REG_CURRENT_MAX_AP_TYPE ; i ++ ) {
50895118 reg_info -> reg_rules_6g_ap_ptr [i ] =
0 commit comments