1 From 91fa00fa69224aae5afb720c5e68b22e4c4f7333 Mon Sep 17 00:00:00 2001
2 From: Aditya Kumar Singh <quic_adisi@quicinc.com>
3 Date: Wed, 1 Mar 2023 16:20:59 +0200
4 Subject: [PATCH] wifi: ath11k: add support to parse new WMI event for 6 GHz
6 In order to support different power levels of 6 GHz AP and client,
7 new WMI event for regulatory - WMI_REG_CHAN_LIST_CC_EXT_EVENTID is
8 added in firmware. This event provides new parameters required for
9 6 GHz regulatory rules.
11 Add support for parsing 2.4 GHz, 5 GHz and 6 GHz reg rules and other
12 parameters from WMI_REG_CHAN_LIST_CC_EXT_EVENTID.
14 Tested-on: IPQ8074 hw2.0 AHB WLAN.HK.2.7.0.1-01744-QCAHKSWPL_SILICONZ-1
15 Tested-on: QCN9074 hw1.0 PCI WLAN.HK.2.7.0.1-01744-QCAHKSWPL_SILICONZ-1
16 Tested-on: QCN9074 hw1.0 PCI WLAN.HK.2.5.0.1-01100-QCAHKSWPL_SILICONZ-1
18 Signed-off-by: Lavanya Suresh <quic_lavaks@quicinc.com>
19 Signed-off-by: Wen Gong <quic_wgong@quicinc.com>
20 Signed-off-by: Aditya Kumar Singh <quic_adisi@quicinc.com>
21 Signed-off-by: Kalle Valo <quic_kvalo@quicinc.com>
22 Link: https://lore.kernel.org/r/20230110121024.14051-3-quic_adisi@quicinc.com
24 drivers/net/wireless/ath/ath11k/reg.c | 37 ++-
25 drivers/net/wireless/ath/ath11k/wmi.c | 418 +++++++++++++++++++++++++-
26 drivers/net/wireless/ath/ath11k/wmi.h | 163 +++++++++-
27 3 files changed, 584 insertions(+), 34 deletions(-)
29 --- a/drivers/net/wireless/ath/ath11k/reg.c
30 +++ b/drivers/net/wireless/ath/ath11k/reg.c
31 @@ -613,7 +613,7 @@ ath11k_reg_build_regd(struct ath11k_base
33 struct ieee80211_regdomain *tmp_regd, *default_regd, *new_regd = NULL;
34 struct cur_reg_rule *reg_rule;
36 + u8 i = 0, j = 0, k = 0;
40 @@ -621,6 +621,12 @@ ath11k_reg_build_regd(struct ath11k_base
42 num_rules = reg_info->num_5ghz_reg_rules + reg_info->num_2ghz_reg_rules;
44 + /* FIXME: Currently taking reg rules for 6 GHz only from Indoor AP mode list.
45 + * This can be updated after complete 6 GHz regulatory support is added.
47 + if (reg_info->is_ext_reg_event)
48 + num_rules += reg_info->num_6ghz_rules_ap[WMI_REG_INDOOR_AP];
53 @@ -666,6 +672,14 @@ ath11k_reg_build_regd(struct ath11k_base
54 * per other BW rule flags we pass from here
56 flags = NL80211_RRF_AUTO_BW;
57 + } else if (reg_info->is_ext_reg_event &&
58 + reg_info->num_6ghz_rules_ap[WMI_REG_INDOOR_AP] &&
59 + (k < reg_info->num_6ghz_rules_ap[WMI_REG_INDOOR_AP])) {
60 + reg_rule = reg_info->reg_rules_6ghz_ap_ptr[WMI_REG_INDOOR_AP] +
62 + max_bw = min_t(u16, reg_rule->max_bw,
63 + reg_info->max_bw_6ghz_ap[WMI_REG_INDOOR_AP]);
64 + flags = NL80211_RRF_AUTO_BW;
68 @@ -693,12 +707,21 @@ ath11k_reg_build_regd(struct ath11k_base
72 - ath11k_dbg(ab, ATH11K_DBG_REG,
73 - "\t%d. (%d - %d @ %d) (%d, %d) (%d ms) (FLAGS %d)\n",
74 - i + 1, reg_rule->start_freq, reg_rule->end_freq,
75 - max_bw, reg_rule->ant_gain, reg_rule->reg_power,
76 - tmp_regd->reg_rules[i].dfs_cac_ms,
78 + if (reg_info->is_ext_reg_event) {
79 + ath11k_dbg(ab, ATH11K_DBG_REG,
80 + "\t%d. (%d - %d @ %d) (%d, %d) (%d ms) (FLAGS %d) (%d, %d)\n",
81 + i + 1, reg_rule->start_freq, reg_rule->end_freq,
82 + max_bw, reg_rule->ant_gain, reg_rule->reg_power,
83 + tmp_regd->reg_rules[i].dfs_cac_ms, flags,
84 + reg_rule->psd_flag, reg_rule->psd_eirp);
86 + ath11k_dbg(ab, ATH11K_DBG_REG,
87 + "\t%d. (%d - %d @ %d) (%d, %d) (%d ms) (FLAGS %d)\n",
88 + i + 1, reg_rule->start_freq, reg_rule->end_freq,
89 + max_bw, reg_rule->ant_gain, reg_rule->reg_power,
90 + tmp_regd->reg_rules[i].dfs_cac_ms,
95 tmp_regd->n_reg_rules = i;
96 --- a/drivers/net/wireless/ath/ath11k/wmi.c
97 +++ b/drivers/net/wireless/ath/ath11k/wmi.c
98 @@ -105,6 +105,8 @@ static const struct wmi_tlv_policy wmi_t
99 = { .min_len = sizeof(struct wmi_vdev_stopped_event) },
100 [WMI_TAG_REG_CHAN_LIST_CC_EVENT]
101 = { .min_len = sizeof(struct wmi_reg_chan_list_cc_event) },
102 + [WMI_TAG_REG_CHAN_LIST_CC_EXT_EVENT]
103 + = { .min_len = sizeof(struct wmi_reg_chan_list_cc_ext_event) },
104 [WMI_TAG_MGMT_RX_HDR]
105 = { .min_len = sizeof(struct wmi_mgmt_rx_hdr) },
106 [WMI_TAG_MGMT_TX_COMPL_EVENT]
107 @@ -3974,6 +3976,10 @@ ath11k_wmi_copy_resource_config(struct w
108 wmi_cfg->sched_params = tg_cfg->sched_params;
109 wmi_cfg->twt_ap_pdev_count = tg_cfg->twt_ap_pdev_count;
110 wmi_cfg->twt_ap_sta_count = tg_cfg->twt_ap_sta_count;
111 + wmi_cfg->host_service_flags &=
112 + ~(1 << WMI_CFG_HOST_SERVICE_FLAG_REG_CC_EXT);
113 + wmi_cfg->host_service_flags |= (tg_cfg->is_reg_cc_ext_event_supported <<
114 + WMI_CFG_HOST_SERVICE_FLAG_REG_CC_EXT);
117 static int ath11k_init_cmd_send(struct ath11k_pdev_wmi *wmi,
118 @@ -4192,6 +4198,10 @@ int ath11k_wmi_cmd_init(struct ath11k_ba
120 ab->hw_params.hw_ops->wmi_init_config(ab, &config);
122 + if (test_bit(WMI_TLV_SERVICE_REG_CC_EXT_EVENT_SUPPORT,
123 + ab->wmi_ab.svc_map))
124 + config.is_reg_cc_ext_event_supported = 1;
126 memcpy(&wmi_sc->wlan_resource_config, &config, sizeof(config));
128 init_param.res_cfg = &wmi_sc->wlan_resource_config;
129 @@ -4995,18 +5005,11 @@ static int ath11k_pull_reg_chan_list_upd
130 reg_info->phy_id = chan_list_event_hdr->phy_id;
131 reg_info->ctry_code = chan_list_event_hdr->country_id;
132 reg_info->reg_dmn_pair = chan_list_event_hdr->domain_code;
133 - if (chan_list_event_hdr->status_code == WMI_REG_SET_CC_STATUS_PASS)
134 - reg_info->status_code = REG_SET_CC_STATUS_PASS;
135 - else if (chan_list_event_hdr->status_code == WMI_REG_CURRENT_ALPHA2_NOT_FOUND)
136 - reg_info->status_code = REG_CURRENT_ALPHA2_NOT_FOUND;
137 - else if (chan_list_event_hdr->status_code == WMI_REG_INIT_ALPHA2_NOT_FOUND)
138 - reg_info->status_code = REG_INIT_ALPHA2_NOT_FOUND;
139 - else if (chan_list_event_hdr->status_code == WMI_REG_SET_CC_CHANGE_NOT_ALLOWED)
140 - reg_info->status_code = REG_SET_CC_CHANGE_NOT_ALLOWED;
141 - else if (chan_list_event_hdr->status_code == WMI_REG_SET_CC_STATUS_NO_MEMORY)
142 - reg_info->status_code = REG_SET_CC_STATUS_NO_MEMORY;
143 - else if (chan_list_event_hdr->status_code == WMI_REG_SET_CC_STATUS_FAIL)
144 - reg_info->status_code = REG_SET_CC_STATUS_FAIL;
146 + reg_info->status_code =
147 + ath11k_wmi_cc_setting_code_to_reg(chan_list_event_hdr->status_code);
149 + reg_info->is_ext_reg_event = false;
151 reg_info->min_bw_2ghz = chan_list_event_hdr->min_bw_2ghz;
152 reg_info->max_bw_2ghz = chan_list_event_hdr->max_bw_2ghz;
153 @@ -5060,6 +5063,372 @@ static int ath11k_pull_reg_chan_list_upd
157 +static struct cur_reg_rule
158 +*create_ext_reg_rules_from_wmi(u32 num_reg_rules,
159 + struct wmi_regulatory_ext_rule *wmi_reg_rule)
161 + struct cur_reg_rule *reg_rule_ptr;
164 + reg_rule_ptr = kcalloc(num_reg_rules, sizeof(*reg_rule_ptr), GFP_ATOMIC);
169 + for (count = 0; count < num_reg_rules; count++) {
170 + reg_rule_ptr[count].start_freq =
171 + u32_get_bits(wmi_reg_rule[count].freq_info,
172 + REG_RULE_START_FREQ);
173 + reg_rule_ptr[count].end_freq =
174 + u32_get_bits(wmi_reg_rule[count].freq_info,
175 + REG_RULE_END_FREQ);
176 + reg_rule_ptr[count].max_bw =
177 + u32_get_bits(wmi_reg_rule[count].bw_pwr_info,
179 + reg_rule_ptr[count].reg_power =
180 + u32_get_bits(wmi_reg_rule[count].bw_pwr_info,
182 + reg_rule_ptr[count].ant_gain =
183 + u32_get_bits(wmi_reg_rule[count].bw_pwr_info,
184 + REG_RULE_ANT_GAIN);
185 + reg_rule_ptr[count].flags =
186 + u32_get_bits(wmi_reg_rule[count].flag_info,
188 + reg_rule_ptr[count].psd_flag =
189 + u32_get_bits(wmi_reg_rule[count].psd_power_info,
190 + REG_RULE_PSD_INFO);
191 + reg_rule_ptr[count].psd_eirp =
192 + u32_get_bits(wmi_reg_rule[count].psd_power_info,
193 + REG_RULE_PSD_EIRP);
196 + return reg_rule_ptr;
200 +ath11k_invalid_5ghz_reg_ext_rules_from_wmi(u32 num_reg_rules,
201 + const struct wmi_regulatory_ext_rule *rule)
203 + u8 num_invalid_5ghz_rules = 0;
204 + u32 count, start_freq;
206 + for (count = 0; count < num_reg_rules; count++) {
207 + start_freq = u32_get_bits(rule[count].freq_info,
208 + REG_RULE_START_FREQ);
210 + if (start_freq >= ATH11K_MIN_6G_FREQ)
211 + num_invalid_5ghz_rules++;
214 + return num_invalid_5ghz_rules;
217 +static int ath11k_pull_reg_chan_list_ext_update_ev(struct ath11k_base *ab,
218 + struct sk_buff *skb,
219 + struct cur_regulatory_info *reg_info)
222 + const struct wmi_reg_chan_list_cc_ext_event *ext_chan_list_event_hdr;
223 + struct wmi_regulatory_ext_rule *ext_wmi_reg_rule;
224 + u32 num_2ghz_reg_rules, num_5ghz_reg_rules;
225 + u32 num_6ghz_reg_rules_ap[WMI_REG_CURRENT_MAX_AP_TYPE];
226 + u32 num_6ghz_client[WMI_REG_CURRENT_MAX_AP_TYPE][WMI_REG_MAX_CLIENT_TYPE];
227 + u32 total_reg_rules = 0;
228 + int ret, i, j, num_invalid_5ghz_ext_rules = 0;
230 + ath11k_dbg(ab, ATH11K_DBG_WMI, "processing regulatory ext channel list\n");
232 + tb = ath11k_wmi_tlv_parse_alloc(ab, skb->data, skb->len, GFP_ATOMIC);
235 + ath11k_warn(ab, "failed to parse tlv: %d\n", ret);
239 + ext_chan_list_event_hdr = tb[WMI_TAG_REG_CHAN_LIST_CC_EXT_EVENT];
240 + if (!ext_chan_list_event_hdr) {
241 + ath11k_warn(ab, "failed to fetch reg chan list ext update ev\n");
246 + reg_info->num_2ghz_reg_rules =
247 + ext_chan_list_event_hdr->num_2ghz_reg_rules;
248 + reg_info->num_5ghz_reg_rules =
249 + ext_chan_list_event_hdr->num_5ghz_reg_rules;
250 + reg_info->num_6ghz_rules_ap[WMI_REG_INDOOR_AP] =
251 + ext_chan_list_event_hdr->num_6ghz_reg_rules_ap_lpi;
252 + reg_info->num_6ghz_rules_ap[WMI_REG_STANDARD_POWER_AP] =
253 + ext_chan_list_event_hdr->num_6ghz_reg_rules_ap_sp;
254 + reg_info->num_6ghz_rules_ap[WMI_REG_VERY_LOW_POWER_AP] =
255 + ext_chan_list_event_hdr->num_6ghz_reg_rules_ap_vlp;
257 + for (i = 0; i < WMI_REG_MAX_CLIENT_TYPE; i++) {
258 + reg_info->num_6ghz_rules_client[WMI_REG_INDOOR_AP][i] =
259 + ext_chan_list_event_hdr->num_6ghz_reg_rules_client_lpi[i];
260 + reg_info->num_6ghz_rules_client[WMI_REG_STANDARD_POWER_AP][i] =
261 + ext_chan_list_event_hdr->num_6ghz_reg_rules_client_sp[i];
262 + reg_info->num_6ghz_rules_client[WMI_REG_VERY_LOW_POWER_AP][i] =
263 + ext_chan_list_event_hdr->num_6ghz_reg_rules_client_vlp[i];
266 + num_2ghz_reg_rules = reg_info->num_2ghz_reg_rules;
267 + num_5ghz_reg_rules = reg_info->num_5ghz_reg_rules;
269 + total_reg_rules += num_2ghz_reg_rules;
270 + total_reg_rules += num_5ghz_reg_rules;
272 + if ((num_2ghz_reg_rules > MAX_REG_RULES) ||
273 + (num_5ghz_reg_rules > MAX_REG_RULES)) {
274 + ath11k_warn(ab, "Num reg rules for 2.4 GHz/5 GHz exceeds max limit (num_2ghz_reg_rules: %d num_5ghz_reg_rules: %d max_rules: %d)\n",
275 + num_2ghz_reg_rules, num_5ghz_reg_rules, MAX_REG_RULES);
280 + for (i = 0; i < WMI_REG_CURRENT_MAX_AP_TYPE; i++) {
281 + num_6ghz_reg_rules_ap[i] = reg_info->num_6ghz_rules_ap[i];
283 + if (num_6ghz_reg_rules_ap[i] > MAX_6GHZ_REG_RULES) {
284 + ath11k_warn(ab, "Num 6 GHz reg rules for AP mode(%d) exceeds max limit (num_6ghz_reg_rules_ap: %d, max_rules: %d)\n",
285 + i, num_6ghz_reg_rules_ap[i], MAX_6GHZ_REG_RULES);
290 + total_reg_rules += num_6ghz_reg_rules_ap[i];
293 + for (i = 0; i < WMI_REG_MAX_CLIENT_TYPE; i++) {
294 + num_6ghz_client[WMI_REG_INDOOR_AP][i] =
295 + reg_info->num_6ghz_rules_client[WMI_REG_INDOOR_AP][i];
296 + total_reg_rules += num_6ghz_client[WMI_REG_INDOOR_AP][i];
298 + num_6ghz_client[WMI_REG_STANDARD_POWER_AP][i] =
299 + reg_info->num_6ghz_rules_client[WMI_REG_STANDARD_POWER_AP][i];
300 + total_reg_rules += num_6ghz_client[WMI_REG_STANDARD_POWER_AP][i];
302 + num_6ghz_client[WMI_REG_VERY_LOW_POWER_AP][i] =
303 + reg_info->num_6ghz_rules_client[WMI_REG_VERY_LOW_POWER_AP][i];
304 + total_reg_rules += num_6ghz_client[WMI_REG_VERY_LOW_POWER_AP][i];
306 + if ((num_6ghz_client[WMI_REG_INDOOR_AP][i] > MAX_6GHZ_REG_RULES) ||
307 + (num_6ghz_client[WMI_REG_STANDARD_POWER_AP][i] >
308 + MAX_6GHZ_REG_RULES) ||
309 + (num_6ghz_client[WMI_REG_VERY_LOW_POWER_AP][i] >
310 + MAX_6GHZ_REG_RULES)) {
312 + "Num 6 GHz client reg rules exceeds max limit, for client(type: %d)\n",
319 + if (!total_reg_rules) {
320 + ath11k_warn(ab, "No reg rules available\n");
325 + memcpy(reg_info->alpha2, &ext_chan_list_event_hdr->alpha2,
328 + reg_info->dfs_region = ext_chan_list_event_hdr->dfs_region;
329 + reg_info->phybitmap = ext_chan_list_event_hdr->phybitmap;
330 + reg_info->num_phy = ext_chan_list_event_hdr->num_phy;
331 + reg_info->phy_id = ext_chan_list_event_hdr->phy_id;
332 + reg_info->ctry_code = ext_chan_list_event_hdr->country_id;
333 + reg_info->reg_dmn_pair = ext_chan_list_event_hdr->domain_code;
335 + reg_info->status_code =
336 + ath11k_wmi_cc_setting_code_to_reg(ext_chan_list_event_hdr->status_code);
338 + reg_info->is_ext_reg_event = true;
340 + reg_info->min_bw_2ghz = ext_chan_list_event_hdr->min_bw_2ghz;
341 + reg_info->max_bw_2ghz = ext_chan_list_event_hdr->max_bw_2ghz;
342 + reg_info->min_bw_5ghz = ext_chan_list_event_hdr->min_bw_5ghz;
343 + reg_info->max_bw_5ghz = ext_chan_list_event_hdr->max_bw_5ghz;
345 + reg_info->min_bw_6ghz_ap[WMI_REG_INDOOR_AP] =
346 + ext_chan_list_event_hdr->min_bw_6ghz_ap_lpi;
347 + reg_info->max_bw_6ghz_ap[WMI_REG_INDOOR_AP] =
348 + ext_chan_list_event_hdr->max_bw_6ghz_ap_lpi;
349 + reg_info->min_bw_6ghz_ap[WMI_REG_STANDARD_POWER_AP] =
350 + ext_chan_list_event_hdr->min_bw_6ghz_ap_sp;
351 + reg_info->max_bw_6ghz_ap[WMI_REG_STANDARD_POWER_AP] =
352 + ext_chan_list_event_hdr->max_bw_6ghz_ap_sp;
353 + reg_info->min_bw_6ghz_ap[WMI_REG_VERY_LOW_POWER_AP] =
354 + ext_chan_list_event_hdr->min_bw_6ghz_ap_vlp;
355 + reg_info->max_bw_6ghz_ap[WMI_REG_VERY_LOW_POWER_AP] =
356 + ext_chan_list_event_hdr->max_bw_6ghz_ap_vlp;
358 + for (i = 0; i < WMI_REG_MAX_CLIENT_TYPE; i++) {
359 + reg_info->min_bw_6ghz_client[WMI_REG_INDOOR_AP][i] =
360 + ext_chan_list_event_hdr->min_bw_6ghz_client_lpi[i];
361 + reg_info->max_bw_6ghz_client[WMI_REG_INDOOR_AP][i] =
362 + ext_chan_list_event_hdr->max_bw_6ghz_client_lpi[i];
363 + reg_info->min_bw_6ghz_client[WMI_REG_STANDARD_POWER_AP][i] =
364 + ext_chan_list_event_hdr->min_bw_6ghz_client_sp[i];
365 + reg_info->max_bw_6ghz_client[WMI_REG_STANDARD_POWER_AP][i] =
366 + ext_chan_list_event_hdr->max_bw_6ghz_client_sp[i];
367 + reg_info->min_bw_6ghz_client[WMI_REG_VERY_LOW_POWER_AP][i] =
368 + ext_chan_list_event_hdr->min_bw_6ghz_client_vlp[i];
369 + reg_info->max_bw_6ghz_client[WMI_REG_VERY_LOW_POWER_AP][i] =
370 + ext_chan_list_event_hdr->max_bw_6ghz_client_vlp[i];
373 + ath11k_dbg(ab, ATH11K_DBG_WMI,
374 + "%s:cc_ext %s dsf %d BW: min_2ghz %d max_2ghz %d min_5ghz %d max_5ghz %d",
375 + __func__, reg_info->alpha2, reg_info->dfs_region,
376 + reg_info->min_bw_2ghz, reg_info->max_bw_2ghz,
377 + reg_info->min_bw_5ghz, reg_info->max_bw_5ghz);
379 + ath11k_dbg(ab, ATH11K_DBG_WMI,
380 + "num_2ghz_reg_rules %d num_5ghz_reg_rules %d",
381 + num_2ghz_reg_rules, num_5ghz_reg_rules);
383 + ath11k_dbg(ab, ATH11K_DBG_WMI,
384 + "num_6ghz_reg_rules_ap_lpi: %d num_6ghz_reg_rules_ap_sp: %d num_6ghz_reg_rules_ap_vlp: %d",
385 + num_6ghz_reg_rules_ap[WMI_REG_INDOOR_AP],
386 + num_6ghz_reg_rules_ap[WMI_REG_STANDARD_POWER_AP],
387 + num_6ghz_reg_rules_ap[WMI_REG_VERY_LOW_POWER_AP]);
389 + j = WMI_REG_DEFAULT_CLIENT;
390 + ath11k_dbg(ab, ATH11K_DBG_WMI,
391 + "6 GHz Regular client: num_6ghz_reg_rules_lpi: %d num_6ghz_reg_rules_sp: %d num_6ghz_reg_rules_vlp: %d",
392 + num_6ghz_client[WMI_REG_INDOOR_AP][j],
393 + num_6ghz_client[WMI_REG_STANDARD_POWER_AP][j],
394 + num_6ghz_client[WMI_REG_VERY_LOW_POWER_AP][j]);
396 + j = WMI_REG_SUBORDINATE_CLIENT;
397 + ath11k_dbg(ab, ATH11K_DBG_WMI,
398 + "6 GHz Subordinate client: num_6ghz_reg_rules_lpi: %d num_6ghz_reg_rules_sp: %d num_6ghz_reg_rules_vlp: %d",
399 + num_6ghz_client[WMI_REG_INDOOR_AP][j],
400 + num_6ghz_client[WMI_REG_STANDARD_POWER_AP][j],
401 + num_6ghz_client[WMI_REG_VERY_LOW_POWER_AP][j]);
404 + (struct wmi_regulatory_ext_rule *)((u8 *)ext_chan_list_event_hdr
405 + + sizeof(*ext_chan_list_event_hdr)
406 + + sizeof(struct wmi_tlv));
407 + if (num_2ghz_reg_rules) {
408 + reg_info->reg_rules_2ghz_ptr =
409 + create_ext_reg_rules_from_wmi(num_2ghz_reg_rules,
412 + if (!reg_info->reg_rules_2ghz_ptr) {
414 + ath11k_warn(ab, "Unable to Allocate memory for 2 GHz rules\n");
419 + ext_wmi_reg_rule += num_2ghz_reg_rules;
421 + /* Firmware might include 6 GHz reg rule in 5 GHz rule list
422 + * for few countries along with separate 6 GHz rule.
423 + * Having same 6 GHz reg rule in 5 GHz and 6 GHz rules list
424 + * causes intersect check to be true, and same rules will be
425 + * shown multiple times in iw cmd.
426 + * Hence, avoid parsing 6 GHz rule from 5 GHz reg rule list
428 + num_invalid_5ghz_ext_rules =
429 + ath11k_invalid_5ghz_reg_ext_rules_from_wmi(num_5ghz_reg_rules,
432 + if (num_invalid_5ghz_ext_rules) {
433 + ath11k_dbg(ab, ATH11K_DBG_WMI,
434 + "CC: %s 5 GHz reg rules number %d from fw, %d number of invalid 5 GHz rules",
435 + reg_info->alpha2, reg_info->num_5ghz_reg_rules,
436 + num_invalid_5ghz_ext_rules);
438 + num_5ghz_reg_rules = num_5ghz_reg_rules - num_invalid_5ghz_ext_rules;
439 + reg_info->num_5ghz_reg_rules = num_5ghz_reg_rules;
442 + if (num_5ghz_reg_rules) {
443 + reg_info->reg_rules_5ghz_ptr =
444 + create_ext_reg_rules_from_wmi(num_5ghz_reg_rules,
447 + if (!reg_info->reg_rules_5ghz_ptr) {
449 + ath11k_warn(ab, "Unable to Allocate memory for 5 GHz rules\n");
454 + /* We have adjusted the number of 5 GHz reg rules above. But still those
455 + * many rules needs to be adjusted in ext_wmi_reg_rule.
457 + * NOTE: num_invalid_5ghz_ext_rules will be 0 for rest other cases.
459 + ext_wmi_reg_rule += (num_5ghz_reg_rules + num_invalid_5ghz_ext_rules);
461 + for (i = 0; i < WMI_REG_CURRENT_MAX_AP_TYPE; i++) {
462 + reg_info->reg_rules_6ghz_ap_ptr[i] =
463 + create_ext_reg_rules_from_wmi(num_6ghz_reg_rules_ap[i],
466 + if (!reg_info->reg_rules_6ghz_ap_ptr[i]) {
468 + ath11k_warn(ab, "Unable to Allocate memory for 6 GHz AP rules\n");
472 + ext_wmi_reg_rule += num_6ghz_reg_rules_ap[i];
475 + for (j = 0; j < WMI_REG_CURRENT_MAX_AP_TYPE; j++) {
476 + for (i = 0; i < WMI_REG_MAX_CLIENT_TYPE; i++) {
477 + reg_info->reg_rules_6ghz_client_ptr[j][i] =
478 + create_ext_reg_rules_from_wmi(num_6ghz_client[j][i],
481 + if (!reg_info->reg_rules_6ghz_client_ptr[j][i]) {
483 + ath11k_warn(ab, "Unable to Allocate memory for 6 GHz client rules\n");
487 + ext_wmi_reg_rule += num_6ghz_client[j][i];
491 + reg_info->client_type = ext_chan_list_event_hdr->client_type;
492 + reg_info->rnr_tpe_usable = ext_chan_list_event_hdr->rnr_tpe_usable;
493 + reg_info->unspecified_ap_usable =
494 + ext_chan_list_event_hdr->unspecified_ap_usable;
495 + reg_info->domain_code_6ghz_ap[WMI_REG_INDOOR_AP] =
496 + ext_chan_list_event_hdr->domain_code_6ghz_ap_lpi;
497 + reg_info->domain_code_6ghz_ap[WMI_REG_STANDARD_POWER_AP] =
498 + ext_chan_list_event_hdr->domain_code_6ghz_ap_sp;
499 + reg_info->domain_code_6ghz_ap[WMI_REG_VERY_LOW_POWER_AP] =
500 + ext_chan_list_event_hdr->domain_code_6ghz_ap_vlp;
502 + for (i = 0; i < WMI_REG_MAX_CLIENT_TYPE; i++) {
503 + reg_info->domain_code_6ghz_client[WMI_REG_INDOOR_AP][i] =
504 + ext_chan_list_event_hdr->domain_code_6ghz_client_lpi[i];
505 + reg_info->domain_code_6ghz_client[WMI_REG_STANDARD_POWER_AP][i] =
506 + ext_chan_list_event_hdr->domain_code_6ghz_client_sp[i];
507 + reg_info->domain_code_6ghz_client[WMI_REG_VERY_LOW_POWER_AP][i] =
508 + ext_chan_list_event_hdr->domain_code_6ghz_client_vlp[i];
511 + reg_info->domain_code_6ghz_super_id =
512 + ext_chan_list_event_hdr->domain_code_6ghz_super_id;
514 + ath11k_dbg(ab, ATH11K_DBG_WMI, "6 GHz client_type: %d domain_code_6ghz_super_id: %d",
515 + reg_info->client_type, reg_info->domain_code_6ghz_super_id);
517 + ath11k_dbg(ab, ATH11K_DBG_WMI, "processed regulatory ext channel list\n");
523 static int ath11k_pull_peer_del_resp_ev(struct ath11k_base *ab, struct sk_buff *skb,
524 struct wmi_peer_delete_resp_event *peer_del_resp)
526 @@ -6507,12 +6876,14 @@ static bool ath11k_reg_is_world_alpha(ch
530 -static int ath11k_reg_chan_list_event(struct ath11k_base *ab, struct sk_buff *skb)
531 +static int ath11k_reg_chan_list_event(struct ath11k_base *ab,
532 + struct sk_buff *skb,
533 + enum wmi_reg_chan_list_cmd_type id)
535 struct cur_regulatory_info *reg_info = NULL;
536 struct ieee80211_regdomain *regd = NULL;
537 bool intersect = false;
538 - int ret = 0, pdev_idx;
539 + int ret = 0, pdev_idx, i, j;
542 reg_info = kzalloc(sizeof(*reg_info), GFP_ATOMIC);
543 @@ -6521,7 +6892,11 @@ static int ath11k_reg_chan_list_event(st
547 - ret = ath11k_pull_reg_chan_list_update_ev(ab, skb, reg_info);
548 + if (id == WMI_REG_CHAN_LIST_CC_ID)
549 + ret = ath11k_pull_reg_chan_list_update_ev(ab, skb, reg_info);
551 + ret = ath11k_pull_reg_chan_list_ext_update_ev(ab, skb, reg_info);
554 ath11k_warn(ab, "failed to extract regulatory info from received event\n");
556 @@ -6623,6 +6998,14 @@ mem_free:
558 kfree(reg_info->reg_rules_2ghz_ptr);
559 kfree(reg_info->reg_rules_5ghz_ptr);
560 + if (reg_info->is_ext_reg_event) {
561 + for (i = 0; i < WMI_REG_CURRENT_MAX_AP_TYPE; i++)
562 + kfree(reg_info->reg_rules_6ghz_ap_ptr[i]);
564 + for (j = 0; j < WMI_REG_CURRENT_MAX_AP_TYPE; j++)
565 + for (i = 0; i < WMI_REG_MAX_CLIENT_TYPE; i++)
566 + kfree(reg_info->reg_rules_6ghz_client_ptr[j][i]);
571 @@ -8054,7 +8437,10 @@ static void ath11k_wmi_tlv_op_rx(struct
572 ath11k_service_ready_ext2_event(ab, skb);
574 case WMI_REG_CHAN_LIST_CC_EVENTID:
575 - ath11k_reg_chan_list_event(ab, skb);
576 + ath11k_reg_chan_list_event(ab, skb, WMI_REG_CHAN_LIST_CC_ID);
578 + case WMI_REG_CHAN_LIST_CC_EXT_EVENTID:
579 + ath11k_reg_chan_list_event(ab, skb, WMI_REG_CHAN_LIST_CC_EXT_ID);
581 case WMI_READY_EVENTID:
582 ath11k_ready_event(ab, skb);
583 --- a/drivers/net/wireless/ath/ath11k/wmi.h
584 +++ b/drivers/net/wireless/ath/ath11k/wmi.h
585 @@ -797,6 +797,7 @@ enum wmi_tlv_event_id {
586 WMI_RMC_NEW_LEADER_EVENTID = WMI_TLV_CMD(WMI_GRP_RMC),
587 WMI_REG_CHAN_LIST_CC_EVENTID = WMI_TLV_CMD(WMI_GRP_REGULATORY),
588 WMI_11D_NEW_COUNTRY_EVENTID,
589 + WMI_REG_CHAN_LIST_CC_EXT_EVENTID,
590 WMI_NDI_CAP_RSP_EVENTID = WMI_TLV_CMD(WMI_GRP_PROTOTYPE),
591 WMI_NDP_INITIATOR_RSP_EVENTID,
592 WMI_NDP_RESPONDER_RSP_EVENTID,
593 @@ -1865,6 +1866,8 @@ enum wmi_tlv_tag {
594 WMI_TAG_PDEV_SRG_OBSS_BSSID_ENABLE_BITMAP_CMD,
595 WMI_TAG_PDEV_NON_SRG_OBSS_COLOR_ENABLE_BITMAP_CMD,
596 WMI_TAG_PDEV_NON_SRG_OBSS_BSSID_ENABLE_BITMAP_CMD,
597 + WMI_TAG_REGULATORY_RULE_EXT_STRUCT = 0x3A9,
598 + WMI_TAG_REG_CHAN_LIST_CC_EXT_EVENT,
599 WMI_TAG_PDEV_SET_BIOS_SAR_TABLE_CMD = 0x3D8,
600 WMI_TAG_PDEV_SET_BIOS_GEO_TABLE_CMD,
602 @@ -2097,6 +2100,7 @@ enum wmi_tlv_service {
604 /* The second 128 bits */
605 WMI_MAX_EXT_SERVICE = 256,
606 + WMI_TLV_SERVICE_REG_CC_EXT_EVENT_SUPPORT = 281,
607 WMI_TLV_SERVICE_BIOS_SAR_SUPPORT = 326,
609 /* The third 128 bits */
610 @@ -2313,6 +2317,8 @@ struct wmi_init_cmd {
611 #define WMI_RSRC_CFG_FLAG1_BSS_CHANNEL_INFO_64 BIT(5)
612 #define WMI_RSRC_CFG_FLAG1_ACK_RSSI BIT(18)
614 +#define WMI_CFG_HOST_SERVICE_FLAG_REG_CC_EXT 4
616 struct wmi_resource_config {
619 @@ -2372,6 +2378,15 @@ struct wmi_resource_config {
621 u32 twt_ap_pdev_count;
622 u32 twt_ap_sta_count;
624 + u32 num_pkt_filters;
625 + u32 num_max_sta_vdevs;
626 + u32 max_bssid_indicator;
627 + u32 ul_resp_config;
628 + u32 msdu_flow_override_config0;
629 + u32 msdu_flow_override_config1;
631 + u32 host_service_flags;
634 struct wmi_service_ready_event {
635 @@ -2854,6 +2869,8 @@ struct rx_reorder_queue_remove_params {
636 #define REG_RULE_MAX_BW 0x0000ffff
637 #define REG_RULE_REG_PWR 0x00ff0000
638 #define REG_RULE_ANT_GAIN 0xff000000
639 +#define REG_RULE_PSD_INFO BIT(0)
640 +#define REG_RULE_PSD_EIRP 0xff0000
642 #define WMI_VDEV_PARAM_TXBF_SU_TX_BFEE BIT(0)
643 #define WMI_VDEV_PARAM_TXBF_MU_TX_BFEE BIT(1)
644 @@ -4049,6 +4066,7 @@ struct wmi_he_rate_set {
646 #define MAX_REG_RULES 10
647 #define REG_ALPHA2_LEN 2
648 +#define MAX_6GHZ_REG_RULES 5
650 enum wmi_start_event_param {
651 WMI_VDEV_START_RESP_EVENT = 0,
652 @@ -4079,16 +4097,6 @@ enum wmi_vdev_start_resp_status_code {
653 WMI_VDEV_START_RESPONSE_INVALID_REGDOMAIN = 4,
657 -enum cc_setting_code {
658 - REG_SET_CC_STATUS_PASS = 0,
659 - REG_CURRENT_ALPHA2_NOT_FOUND = 1,
660 - REG_INIT_ALPHA2_NOT_FOUND = 2,
661 - REG_SET_CC_CHANGE_NOT_ALLOWED = 3,
662 - REG_SET_CC_STATUS_NO_MEMORY = 4,
663 - REG_SET_CC_STATUS_FAIL = 5,
666 /* Regaulatory Rule Flags Passed by FW */
667 #define REGULATORY_CHAN_DISABLED BIT(0)
668 #define REGULATORY_CHAN_NO_IR BIT(1)
669 @@ -4102,13 +4110,72 @@ enum cc_setting_code {
670 #define REGULATORY_CHAN_NO_20MHZ BIT(11)
671 #define REGULATORY_CHAN_NO_10MHZ BIT(12)
674 +enum wmi_reg_chan_list_cmd_type {
675 + WMI_REG_CHAN_LIST_CC_ID = 0,
676 + WMI_REG_CHAN_LIST_CC_EXT_ID = 1,
679 +enum wmi_reg_cc_setting_code {
680 WMI_REG_SET_CC_STATUS_PASS = 0,
681 WMI_REG_CURRENT_ALPHA2_NOT_FOUND = 1,
682 WMI_REG_INIT_ALPHA2_NOT_FOUND = 2,
683 WMI_REG_SET_CC_CHANGE_NOT_ALLOWED = 3,
684 WMI_REG_SET_CC_STATUS_NO_MEMORY = 4,
685 WMI_REG_SET_CC_STATUS_FAIL = 5,
687 + /* add new setting code above, update in
688 + * @enum cc_setting_code as well.
689 + * Also handle it in ath11k_wmi_cc_setting_code_to_reg()
693 +enum cc_setting_code {
694 + REG_SET_CC_STATUS_PASS = 0,
695 + REG_CURRENT_ALPHA2_NOT_FOUND = 1,
696 + REG_INIT_ALPHA2_NOT_FOUND = 2,
697 + REG_SET_CC_CHANGE_NOT_ALLOWED = 3,
698 + REG_SET_CC_STATUS_NO_MEMORY = 4,
699 + REG_SET_CC_STATUS_FAIL = 5,
701 + /* add new setting code above, update in
702 + * @enum wmi_reg_cc_setting_code as well.
706 +static inline enum cc_setting_code
707 +ath11k_wmi_cc_setting_code_to_reg(enum wmi_reg_cc_setting_code status_code)
709 + switch (status_code) {
710 + case WMI_REG_SET_CC_STATUS_PASS:
711 + return REG_SET_CC_STATUS_PASS;
712 + case WMI_REG_CURRENT_ALPHA2_NOT_FOUND:
713 + return REG_CURRENT_ALPHA2_NOT_FOUND;
714 + case WMI_REG_INIT_ALPHA2_NOT_FOUND:
715 + return REG_INIT_ALPHA2_NOT_FOUND;
716 + case WMI_REG_SET_CC_CHANGE_NOT_ALLOWED:
717 + return REG_SET_CC_CHANGE_NOT_ALLOWED;
718 + case WMI_REG_SET_CC_STATUS_NO_MEMORY:
719 + return REG_SET_CC_STATUS_NO_MEMORY;
720 + case WMI_REG_SET_CC_STATUS_FAIL:
721 + return REG_SET_CC_STATUS_FAIL;
724 + return REG_SET_CC_STATUS_FAIL;
727 +enum wmi_reg_6ghz_ap_type {
728 + WMI_REG_INDOOR_AP = 0,
729 + WMI_REG_STANDARD_POWER_AP = 1,
730 + WMI_REG_VERY_LOW_POWER_AP = 2,
732 + WMI_REG_CURRENT_MAX_AP_TYPE,
733 + WMI_REG_MAX_AP_TYPE = 7,
736 +enum wmi_reg_6ghz_client_type {
737 + WMI_REG_DEFAULT_CLIENT = 0,
738 + WMI_REG_SUBORDINATE_CLIENT = 1,
739 + WMI_REG_MAX_CLIENT_TYPE = 2,
742 struct cur_reg_rule {
743 @@ -4118,6 +4185,8 @@ struct cur_reg_rule {
751 struct cur_regulatory_info {
752 @@ -4137,6 +4206,22 @@ struct cur_regulatory_info {
753 u32 num_5ghz_reg_rules;
754 struct cur_reg_rule *reg_rules_2ghz_ptr;
755 struct cur_reg_rule *reg_rules_5ghz_ptr;
756 + bool is_ext_reg_event;
757 + enum wmi_reg_6ghz_client_type client_type;
758 + bool rnr_tpe_usable;
759 + bool unspecified_ap_usable;
760 + u8 domain_code_6ghz_ap[WMI_REG_CURRENT_MAX_AP_TYPE];
761 + u8 domain_code_6ghz_client[WMI_REG_CURRENT_MAX_AP_TYPE][WMI_REG_MAX_CLIENT_TYPE];
762 + u32 domain_code_6ghz_super_id;
763 + u32 min_bw_6ghz_ap[WMI_REG_CURRENT_MAX_AP_TYPE];
764 + u32 max_bw_6ghz_ap[WMI_REG_CURRENT_MAX_AP_TYPE];
765 + u32 min_bw_6ghz_client[WMI_REG_CURRENT_MAX_AP_TYPE][WMI_REG_MAX_CLIENT_TYPE];
766 + u32 max_bw_6ghz_client[WMI_REG_CURRENT_MAX_AP_TYPE][WMI_REG_MAX_CLIENT_TYPE];
767 + u32 num_6ghz_rules_ap[WMI_REG_CURRENT_MAX_AP_TYPE];
768 + u32 num_6ghz_rules_client[WMI_REG_CURRENT_MAX_AP_TYPE][WMI_REG_MAX_CLIENT_TYPE];
769 + struct cur_reg_rule *reg_rules_6ghz_ap_ptr[WMI_REG_CURRENT_MAX_AP_TYPE];
770 + struct cur_reg_rule *reg_rules_6ghz_client_ptr
771 + [WMI_REG_CURRENT_MAX_AP_TYPE][WMI_REG_MAX_CLIENT_TYPE];
774 struct wmi_reg_chan_list_cc_event {
775 @@ -4163,6 +4248,61 @@ struct wmi_regulatory_rule_struct {
779 +#define WMI_REG_CLIENT_MAX 4
781 +struct wmi_reg_chan_list_cc_ext_event {
794 + u32 num_2ghz_reg_rules;
795 + u32 num_5ghz_reg_rules;
797 + u32 rnr_tpe_usable;
798 + u32 unspecified_ap_usable;
799 + u32 domain_code_6ghz_ap_lpi;
800 + u32 domain_code_6ghz_ap_sp;
801 + u32 domain_code_6ghz_ap_vlp;
802 + u32 domain_code_6ghz_client_lpi[WMI_REG_CLIENT_MAX];
803 + u32 domain_code_6ghz_client_sp[WMI_REG_CLIENT_MAX];
804 + u32 domain_code_6ghz_client_vlp[WMI_REG_CLIENT_MAX];
805 + u32 domain_code_6ghz_super_id;
806 + u32 min_bw_6ghz_ap_sp;
807 + u32 max_bw_6ghz_ap_sp;
808 + u32 min_bw_6ghz_ap_lpi;
809 + u32 max_bw_6ghz_ap_lpi;
810 + u32 min_bw_6ghz_ap_vlp;
811 + u32 max_bw_6ghz_ap_vlp;
812 + u32 min_bw_6ghz_client_sp[WMI_REG_CLIENT_MAX];
813 + u32 max_bw_6ghz_client_sp[WMI_REG_CLIENT_MAX];
814 + u32 min_bw_6ghz_client_lpi[WMI_REG_CLIENT_MAX];
815 + u32 max_bw_6ghz_client_lpi[WMI_REG_CLIENT_MAX];
816 + u32 min_bw_6ghz_client_vlp[WMI_REG_CLIENT_MAX];
817 + u32 max_bw_6ghz_client_vlp[WMI_REG_CLIENT_MAX];
818 + u32 num_6ghz_reg_rules_ap_sp;
819 + u32 num_6ghz_reg_rules_ap_lpi;
820 + u32 num_6ghz_reg_rules_ap_vlp;
821 + u32 num_6ghz_reg_rules_client_sp[WMI_REG_CLIENT_MAX];
822 + u32 num_6ghz_reg_rules_client_lpi[WMI_REG_CLIENT_MAX];
823 + u32 num_6ghz_reg_rules_client_vlp[WMI_REG_CLIENT_MAX];
826 +struct wmi_regulatory_ext_rule {
831 + u32 psd_power_info;
834 struct wmi_vdev_delete_resp_event {
837 @@ -5358,6 +5498,7 @@ struct target_resource_config {
839 u32 twt_ap_pdev_count;
840 u32 twt_ap_sta_count;
841 + u8 is_reg_cc_ext_event_supported;
844 enum wmi_debug_log_param {