blob: b8a513501f02769046046a498537c95ccd22b497 [file] [log] [blame]
Amar Singhale4f28ee2015-10-21 14:36:56 -07001/*
2 * Copyright (c) 2014-2016 The Linux Foundation. All rights reserved.
3 *
4 * Previously licensed under the ISC license by Qualcomm Atheros, Inc.
5 *
6 *
7 * Permission to use, copy, modify, and/or distribute this software for
8 * any purpose with or without fee is hereby granted, provided that the
9 * above copyright notice and this permission notice appear in all
10 * copies.
11 *
12 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
13 * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
14 * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
15 * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
16 * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
17 * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
18 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
19 * PERFORMANCE OF THIS SOFTWARE.
20 */
21
22/*
23 * This file was originally distributed by Qualcomm Atheros, Inc.
24 * under proprietary terms before Copyright ownership was assigned
25 * to the Linux Foundation.
26 */
27
28/**
29 * DOC: wlan_hdd_regulatory.c
30 *
31 * hdd regulatory implementation
32 */
33
34#include "qdf_types.h"
35#include "cds_reg_service.h"
36#include "qdf_trace.h"
37#include "sme_api.h"
38#include "wlan_hdd_main.h"
39#include "cds_regdomain.h"
40#include "cds_regdomain_common.h"
41#include "wlan_hdd_regulatory.h"
42
43#define WORLD_SKU_MASK 0x00F0
44#define WORLD_SKU_PREFIX 0x0060
45#define REG_WAIT_TIME 50
46
47#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 14, 0)) || defined(WITH_BACKPORTS)
48#define IEEE80211_CHAN_PASSIVE_SCAN IEEE80211_CHAN_NO_IR
49#define IEEE80211_CHAN_NO_IBSS IEEE80211_CHAN_NO_IR
50#endif
51
52#define REG_RULE_2412_2462 REG_RULE(2412-10, 2462+10, 40, 0, 20, 0)
53
54#define REG_RULE_2467_2472 REG_RULE(2467-10, 2472+10, 40, 0, 20, \
55 NL80211_RRF_PASSIVE_SCAN)
56
57#define REG_RULE_2484 REG_RULE(2484-10, 2484+10, 40, 0, 20, \
58 NL80211_RRF_PASSIVE_SCAN | NL80211_RRF_NO_OFDM)
59
60#define REG_RULE_5180_5320 REG_RULE(5180-10, 5320+10, 80, 0, 20, \
61 NL80211_RRF_PASSIVE_SCAN | NL80211_RRF_NO_IBSS)
62
63#define REG_RULE_5500_5720 REG_RULE(5500-10, 5720+10, 80, 0, 20, \
64 NL80211_RRF_PASSIVE_SCAN | NL80211_RRF_NO_IBSS)
65
66#define REG_RULE_5745_5925 REG_RULE(5745-10, 5925+10, 80, 0, 20, \
67 NL80211_RRF_PASSIVE_SCAN | NL80211_RRF_NO_IBSS)
68
69static bool init_by_driver;
70static bool init_by_reg_core;
71
72static const struct ieee80211_regdomain
73hdd_world_regrules_60_61_62 = {
74 .n_reg_rules = 6,
75 .alpha2 = "00",
76 .reg_rules = {
77 REG_RULE_2412_2462,
78 REG_RULE_2467_2472,
79 REG_RULE_2484,
80 REG_RULE_5180_5320,
81 REG_RULE_5500_5720,
82 REG_RULE_5745_5925,
83 }
84};
85
86static const struct ieee80211_regdomain
87hdd_world_regrules_63_65 = {
88 .n_reg_rules = 4,
89 .alpha2 = "00",
90 .reg_rules = {
91 REG_RULE_2412_2462,
92 REG_RULE_2467_2472,
93 REG_RULE_5180_5320,
94 REG_RULE_5745_5925,
95 }
96};
97
98static const struct ieee80211_regdomain
99hdd_world_regrules_64 = {
100 .n_reg_rules = 3,
101 .alpha2 = "00",
102 .reg_rules = {
103 REG_RULE_2412_2462,
104 REG_RULE_5180_5320,
105 REG_RULE_5745_5925,
106 }
107};
108
109static const struct ieee80211_regdomain
110hdd_world_regrules_66_69 = {
111 .n_reg_rules = 4,
112 .alpha2 = "00",
113 .reg_rules = {
114 REG_RULE_2412_2462,
115 REG_RULE_5180_5320,
116 REG_RULE_5500_5720,
117 REG_RULE_5745_5925,
118 }
119};
120
121static const struct ieee80211_regdomain
122hdd_world_regrules_67_68_6A_6C = {
123 .n_reg_rules = 5,
124 .alpha2 = "00",
125 .reg_rules = {
126 REG_RULE_2412_2462,
127 REG_RULE_2467_2472,
128 REG_RULE_5180_5320,
129 REG_RULE_5500_5720,
130 REG_RULE_5745_5925,
131 }
132};
133
134/**
135 * hdd_get_world_regrules() - get the appropriate world regrules
136 * @reg: regulatory data
137 *
138 * Return: regulatory rules ptr
139 */
140static const struct ieee80211_regdomain *hdd_get_world_regrules(
141struct regulatory *reg)
142{
143 REG_DMN_PAIR_MAPPING *regpair =
144 (REG_DMN_PAIR_MAPPING *)reg->regpair;
145
146 switch (regpair->regDmnEnum) {
147 case 0x60:
148 case 0x61:
149 case 0x62:
150 return &hdd_world_regrules_60_61_62;
151 case 0x63:
152 case 0x65:
153 return &hdd_world_regrules_63_65;
154 case 0x64:
155 return &hdd_world_regrules_64;
156 case 0x66:
157 case 0x69:
158 return &hdd_world_regrules_66_69;
159 case 0x67:
160 case 0x68:
161 case 0x6A:
162 case 0x6C:
163 return &hdd_world_regrules_67_68_6A_6C;
164 default:
165 hdd_warn("invalid world mode in BDF");
166 return &hdd_world_regrules_60_61_62;
167 }
168}
169
170/**
171 * hdd_is_world_regdomain() - whether world regdomain
172 * @reg_domain: integer regulatory domain
173 *
174 * Return: bool
175 */
176bool hdd_is_world_regdomain(uint32_t reg_domain)
177{
178 uint32_t temp_regd = reg_domain & ~WORLDWIDE_ROAMING_FLAG;
179
180 return ((temp_regd & COUNTRY_ERD_FLAG) != COUNTRY_ERD_FLAG) &&
181 (((temp_regd & WORLD_SKU_MASK) == WORLD_SKU_PREFIX) ||
182 (temp_regd == WORLD));
183}
184
185
186/**
187 * hdd_update_regulatory_info() - update regulatory info
188 * @hdd_ctx: hdd context
189 *
190 * Return: void
191 */
192static void hdd_update_regulatory_info(hdd_context_t *hdd_ctx)
193{
194 uint32_t country_code;
195
196 country_code = cds_get_country_from_alpha2(hdd_ctx->reg.alpha2);
197
198 hdd_ctx->reg.reg_domain = COUNTRY_ERD_FLAG;
199 hdd_ctx->reg.reg_domain |= country_code;
200
201 cds_fill_some_regulatory_info(&hdd_ctx->reg);
202
203}
204
205/**
206 * hdd_regulatory_wiphy_init() - regulatory wiphy init
207 * @hdd_ctx: hdd context
208 * @reg: regulatory data
209 * @wiphy: wiphy structure
210 *
211 * Return: void
212 */
213#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 14, 0)) || defined(WITH_BACKPORTS)
214static void hdd_regulatory_wiphy_init(hdd_context_t *hdd_ctx,
215 struct regulatory *reg,
216 struct wiphy *wiphy)
217{
218 const struct ieee80211_regdomain *reg_rules;
219
220 if (hdd_is_world_regdomain(reg->reg_domain)) {
221 reg_rules = hdd_get_world_regrules(reg);
222 wiphy->regulatory_flags |= REGULATORY_CUSTOM_REG;
223 } else if (hdd_ctx->config->fRegChangeDefCountry) {
224 wiphy->regulatory_flags |= REGULATORY_CUSTOM_REG;
225 reg_rules = &hdd_world_regrules_60_61_62;
226 } else {
227 wiphy->regulatory_flags |= REGULATORY_STRICT_REG;
228 reg_rules = &hdd_world_regrules_60_61_62;
229 }
230
231 /*
232 * save the original driver regulatory flags
233 */
234 hdd_ctx->reg.reg_flags = wiphy->regulatory_flags;
235 wiphy_apply_custom_regulatory(wiphy, reg_rules);
236
237 /*
238 * restore the driver regulatory flags since
239 * wiphy_apply_custom_regulatory may have
240 * changed them
241 */
242 wiphy->regulatory_flags = hdd_ctx->reg.reg_flags;
243
244}
245#else
246static void hdd_regulatory_wiphy_init(hdd_context_t *hdd_ctx,
247 struct regulatory *reg,
248 struct wiphy *wiphy)
249{
250 const struct ieee80211_regdomain *reg_rules;
251
252 if (hdd_is_world_regdomain(reg->reg_domain)) {
253 reg_rules = hdd_get_world_regrules(reg);
254 wiphy->flags |= WIPHY_FLAG_CUSTOM_REGULATORY;
255 } else if (hdd_ctx->config->fRegChangeDefCountry) {
256 wiphy->flags |= WIPHY_FLAG_CUSTOM_REGULATORY;
257 reg_rules = &hdd_world_regrules_60_61_62;
258 } else {
259 wiphy->flags |= WIPHY_FLAG_STRICT_REGULATORY;
260 reg_rules = &hdd_world_regrules_60_61_62;
261 }
262
263 /*
264 * save the original driver regulatory flags
265 */
266 hdd_ctx->reg.reg_flags = wiphy->flags;
267 wiphy_apply_custom_regulatory(wiphy, reg_rules);
268
269 /*
270 * restore the driver regulatory flags since
271 * wiphy_apply_custom_regulatory may have
272 * changed them
273 */
274 wiphy->flags = hdd_ctx->reg.reg_flags;
275
276}
277#endif
278
279/**
Amar Singhale4f28ee2015-10-21 14:36:56 -0700280 * is_wiphy_custom_regulatory() - is custom regulatory defined
281 * @wiphy: wiphy
282 *
283 * Return: int
284 */
285#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 14, 0)) || defined(WITH_BACKPORTS)
286static int is_wiphy_custom_regulatory(struct wiphy *wiphy)
287{
288
289 return wiphy->regulatory_flags & REGULATORY_CUSTOM_REG;
290}
291#else
292static int is_wiphy_custom_regulatory(struct wiphy *wiphy)
293{
294 return wiphy->flags & WIPHY_FLAG_CUSTOM_REGULATORY;
295}
296#endif
297
298
299/**
300 * hdd_modify_wiphy() - modify wiphy
301 * @wiphy: wiphy
302 * @chan: channel structure
303 *
304 * Return: void
305 */
306static void hdd_modify_wiphy(struct wiphy *wiphy,
307 struct ieee80211_channel *chan)
308{
309 const struct ieee80211_reg_rule *reg_rule;
310
311 if (is_wiphy_custom_regulatory(wiphy)) {
312 reg_rule = freq_reg_info(wiphy, MHZ_TO_KHZ(chan->center_freq));
313 if (!IS_ERR(reg_rule)) {
314 chan->flags &= ~IEEE80211_CHAN_DISABLED;
315
316 if (!(reg_rule->flags & NL80211_RRF_DFS)) {
317 hdd_info("%s: remove dfs restriction for %u",
318 __func__, chan->center_freq);
319 chan->flags &= ~IEEE80211_CHAN_RADAR;
320 }
321
322 if (!(reg_rule->flags & NL80211_RRF_PASSIVE_SCAN)) {
323 hdd_info("%s: remove passive restriction for %u",
324 __func__, chan->center_freq);
325 chan->flags &= ~IEEE80211_CHAN_PASSIVE_SCAN;
326 }
327
328 if (!(reg_rule->flags & NL80211_RRF_NO_IBSS)) {
329 hdd_info("%s: remove no ibss restriction for %u",
330 __func__, chan->center_freq);
331 chan->flags &= ~IEEE80211_CHAN_NO_IBSS;
332 }
333
334 chan->max_power =
335 MBM_TO_DBM(reg_rule->power_rule.max_eirp);
336 }
337 }
338}
339
340/**
341 * hdd_process_regulatory_data() - process regulatory data
342 * @hdd_ctx: hdd context
343 * @wiphy: wiphy
344 * @reset: whether to reset channel data
345 *
346 * Return: void
347 */
348static void hdd_process_regulatory_data(hdd_context_t *hdd_ctx,
349 struct wiphy *wiphy,
350 bool reset)
351{
Amar Singhal388b3f02016-02-10 13:37:18 -0800352 int band_num;
353 int chan_num;
354 int chan_enum = 0;
355 struct ieee80211_channel *wiphy_chan;
356 struct regulatory_channel *cds_chan;
Amar Singhale4f28ee2015-10-21 14:36:56 -0700357 uint8_t band_capability;
358
359 band_capability = hdd_ctx->config->nBandCapability;
Amar Singhale4f28ee2015-10-21 14:36:56 -0700360 hdd_ctx->isVHT80Allowed = 0;
361
Amar Singhal388b3f02016-02-10 13:37:18 -0800362 for (band_num = 0; band_num < IEEE80211_NUM_BANDS; band_num++) {
Amar Singhale4f28ee2015-10-21 14:36:56 -0700363
Amar Singhal388b3f02016-02-10 13:37:18 -0800364 if (band_num == IEEE80211_BAND_2GHZ &&
Amar Singhale4f28ee2015-10-21 14:36:56 -0700365 band_capability == eCSR_BAND_5G)
366 continue;
367
Amar Singhal388b3f02016-02-10 13:37:18 -0800368 else if (band_num == IEEE80211_BAND_5GHZ &&
Amar Singhale4f28ee2015-10-21 14:36:56 -0700369 band_capability == eCSR_BAND_24)
370 continue;
371
Amar Singhal388b3f02016-02-10 13:37:18 -0800372 if (wiphy->bands[band_num] == NULL)
Amar Singhale4f28ee2015-10-21 14:36:56 -0700373 continue;
Amar Singhale4f28ee2015-10-21 14:36:56 -0700374
Amar Singhal388b3f02016-02-10 13:37:18 -0800375 for (chan_num = 0;
376 chan_num < wiphy->bands[band_num]->n_channels;
377 chan_num++) {
Amar Singhale4f28ee2015-10-21 14:36:56 -0700378
Amar Singhal388b3f02016-02-10 13:37:18 -0800379 wiphy_chan =
380 &(wiphy->bands[band_num]->channels[chan_num]);
381 cds_chan = &(reg_channels[chan_enum]);
Amar Singhale4f28ee2015-10-21 14:36:56 -0700382
Amar Singhal388b3f02016-02-10 13:37:18 -0800383 chan_enum++;
Amar Singhale4f28ee2015-10-21 14:36:56 -0700384
385 if (!reset)
Amar Singhal388b3f02016-02-10 13:37:18 -0800386 hdd_modify_wiphy(wiphy, wiphy_chan);
Amar Singhale4f28ee2015-10-21 14:36:56 -0700387
Amar Singhal388b3f02016-02-10 13:37:18 -0800388 if (wiphy_chan->flags & IEEE80211_CHAN_DISABLED) {
389 cds_chan->state = CHANNEL_STATE_DISABLE;
390 } else if (wiphy_chan->flags &
Amar Singhale4f28ee2015-10-21 14:36:56 -0700391 (IEEE80211_CHAN_RADAR |
392 IEEE80211_CHAN_PASSIVE_SCAN |
393 IEEE80211_CHAN_INDOOR_ONLY)) {
394
Amar Singhal388b3f02016-02-10 13:37:18 -0800395 if (wiphy_chan->flags &
Amar Singhale4f28ee2015-10-21 14:36:56 -0700396 IEEE80211_CHAN_INDOOR_ONLY)
Amar Singhal388b3f02016-02-10 13:37:18 -0800397 wiphy_chan->flags |=
Amar Singhale4f28ee2015-10-21 14:36:56 -0700398 IEEE80211_CHAN_PASSIVE_SCAN;
Amar Singhal388b3f02016-02-10 13:37:18 -0800399 cds_chan->state = CHANNEL_STATE_DFS;
400 if ((wiphy_chan->flags &
Amar Singhale4f28ee2015-10-21 14:36:56 -0700401 IEEE80211_CHAN_NO_80MHZ) == 0)
402 hdd_ctx->isVHT80Allowed = 1;
403 } else {
Amar Singhal388b3f02016-02-10 13:37:18 -0800404 cds_chan->state = CHANNEL_STATE_ENABLE;
405 if ((wiphy_chan->flags &
Amar Singhale4f28ee2015-10-21 14:36:56 -0700406 IEEE80211_CHAN_NO_80MHZ) == 0)
407 hdd_ctx->isVHT80Allowed = 1;
408 }
Amar Singhal388b3f02016-02-10 13:37:18 -0800409 cds_chan->pwr_limit = wiphy_chan->max_power;
410 cds_chan->flags = wiphy_chan->flags;
Amar Singhale4f28ee2015-10-21 14:36:56 -0700411 }
412 }
413
414 if (0 == (hdd_ctx->reg.eeprom_rd_ext &
415 (1 << WHAL_REG_EXT_FCC_CH_144))) {
Amar Singhal388b3f02016-02-10 13:37:18 -0800416 cds_chan = &(reg_channels[CHAN_ENUM_144]);
417 cds_chan->state = CHANNEL_STATE_DISABLE;
Amar Singhale4f28ee2015-10-21 14:36:56 -0700418 }
Amar Singhale4f28ee2015-10-21 14:36:56 -0700419}
420
421
422/**
423 * hdd_regulatory_init() - regulatory_init
424 * @hdd_ctx: hdd context
425 * @wiphy: wiphy
426 *
427 * Return: int
428 */
429int hdd_regulatory_init(hdd_context_t *hdd_ctx, struct wiphy *wiphy)
430{
431 int ret_val;
432 struct regulatory *reg_info;
433
434 reg_info = &hdd_ctx->reg;
435
436 hdd_regulatory_wiphy_init(hdd_ctx, reg_info, wiphy);
437
438 hdd_process_regulatory_data(hdd_ctx, wiphy, true);
439
440 reg_info->cc_src = SOURCE_DRIVER;
441
442 ret_val = cds_fill_some_regulatory_info(reg_info);
443 if (ret_val) {
444 hdd_err("incorrect BDF regulatory data");
445 return ret_val;
446 }
447
448 cds_put_default_country(reg_info->alpha2);
449
450 init_completion(&hdd_ctx->reg_init);
451
452 cds_fill_and_send_ctl_to_fw(reg_info);
453
454 return 0;
455}
456
457/**
458 * hdd_program_country_code() - process channel information from country code
459 * @hdd_ctx: hddc context
460 *
461 * Return: void
462 */
463void hdd_program_country_code(hdd_context_t *hdd_ctx)
464{
465 struct wiphy *wiphy = hdd_ctx->wiphy;
466 uint8_t *country_alpha2 = hdd_ctx->reg.alpha2;
467
468 if (false == init_by_reg_core) {
469 init_by_driver = true;
470 if (('0' != country_alpha2[0]) ||
471 ('0' != country_alpha2[1])) {
472 INIT_COMPLETION(hdd_ctx->reg_init);
473 regulatory_hint(wiphy, country_alpha2);
474 wait_for_completion_timeout(&hdd_ctx->reg_init,
475 msecs_to_jiffies(REG_WAIT_TIME));
476 }
477 }
478}
479
480
481/**
482 * hdd_set_dfs_region() - set the dfs_region
483 * @dfs_region: the dfs_region to set
484 *
485 * Return: void
486 */
487#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 14, 0)) || defined(WITH_BACKPORTS)
488static void hdd_set_dfs_region(hdd_context_t *hdd_ctx,
489 uint8_t dfs_reg)
490{
491 cds_put_dfs_region(dfs_reg);
492}
493#else
494static void hdd_set_dfs_region(hdd_context_t *hdd_ctx,
495 uint8_t dfs_reg)
496{
497
498 /* remap the ctl code to dfs region code */
499 switch (hdd_ctx->reg.ctl_5g) {
500 case FCC:
501 cds_put_dfs_region(DFS_FCC_DOMAIN);
502 break;
503 case ETSI:
504 cds_put_dfs_region(DFS_ETSI_DOMAIN);
505 break;
506 case MKK:
507 cds_put_dfs_region(DFS_MKK4_DOMAIN);
508 break;
509 default:
510 /* set default dfs_region to FCC */
511 cds_put_dfs_region(DFS_FCC_DOMAIN);
512 break;
513 }
514
515}
516#endif
517
518/**
519 * hdd_restore_custom_reg_settings() - restore custom reg settings
520 * @wiphy: wiphy structure
521 * @country_alpha2: alpha2 of the country
522 * @reset: whether wiphy is reset
523 *
524 * Return: void
525 */
526#if (LINUX_VERSION_CODE > KERNEL_VERSION(3, 14, 0)) || defined(WITH_BACKPORTS)
527static void hdd_restore_custom_reg_settings(struct wiphy *wiphy,
528 uint8_t *country_alpha2,
529 bool *reset)
530{
531}
532#else
533static void hdd_restore_custom_reg_settings(struct wiphy *wiphy,
534 uint8_t *country_alpha2,
535 bool *reset)
536{
537 struct ieee80211_supported_band *sband;
538 enum ieee80211_band band;
539 struct ieee80211_channel *chan;
540 int i;
541
542 if ((country_alpha2[0] == '0') &&
543 (country_alpha2[1] == '0') &&
544 (wiphy->flags & WIPHY_FLAG_CUSTOM_REGULATORY)) {
545
546 for (band = 0; band < IEEE80211_NUM_BANDS; band++) {
547 sband = wiphy->bands[band];
548 if (!sband)
549 continue;
550 for (i = 0; i < sband->n_channels; i++) {
551 chan = &sband->channels[i];
552 chan->flags = chan->orig_flags;
553 chan->max_antenna_gain = chan->orig_mag;
554 chan->max_power = chan->orig_mpwr;
555 }
556 }
557 *reset = true;
558 }
559}
560#endif
561
562
563/**
564 * hdd_restore_reg_flags() - restore regulatory flags
565 * @flags: regulatory flags
566 *
567 * Return: void
568 */
569#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 14, 0)) || defined(WITH_BACKPORTS)
570static void hdd_restore_reg_flags(struct wiphy *wiphy, uint32_t flags)
571{
572 wiphy->regulatory_flags = flags;
573}
574#else
575static void hdd_restore_reg_flags(struct wiphy *wiphy, uint32_t flags)
576{
577 wiphy->flags = flags;
578}
579#endif
580
581
582/**
583 * hdd_reg_notifier() - regulatory notifier
584 * @wiphy: wiphy
585 * @request: regulatory request
586 *
587 * Return: void
588 */
589void hdd_reg_notifier(struct wiphy *wiphy,
590 struct regulatory_request *request)
591{
592 hdd_context_t *hdd_ctx = wiphy_priv(wiphy);
593 eCsrBand band_capability = eCSR_BAND_ALL;
594 bool vht80_allowed;
595 bool reset = false;
596 uint8_t dfs_reg;
597
598 hdd_info("country: %c%c, initiator %d, dfs_region: %d",
599 request->alpha2[0],
600 request->alpha2[1],
601 request->initiator,
602 request->dfs_region);
603
604 if (NULL == hdd_ctx) {
605 hdd_err("invalid hdd_ctx pointer");
606 return;
607 }
608
609 if (cds_is_driver_unloading() || cds_is_driver_recovering()) {
610 hdd_err("%s: unloading or ssr in progress, ignore",
611 __func__);
612 return;
613 }
614
615 sme_get_freq_band(hdd_ctx->hHal, &band_capability);
616
617 /* first check if this callback is in response to the driver callback */
618
619 switch (request->initiator) {
620 case NL80211_REGDOM_SET_BY_DRIVER:
621 case NL80211_REGDOM_SET_BY_CORE:
622 case NL80211_REGDOM_SET_BY_USER:
623
624 if ((false == init_by_driver) &&
625 (false == init_by_reg_core)) {
626
627 if (NL80211_REGDOM_SET_BY_CORE == request->initiator)
628 return;
629 init_by_reg_core = true;
630 }
631
632 if ((NL80211_REGDOM_SET_BY_DRIVER == request->initiator) &&
633 (true == init_by_driver)) {
634
635 /*
636 * restore the driver regulatory flags since
637 * regulatory_hint may have
638 * changed them
639 */
640 hdd_restore_reg_flags(wiphy, hdd_ctx->reg.reg_flags);
641 }
642
643 if (NL80211_REGDOM_SET_BY_CORE == request->initiator) {
644 hdd_ctx->reg.cc_src = SOURCE_CORE;
645 if (is_wiphy_custom_regulatory(wiphy))
646 reset = true;
647 } else if (NL80211_REGDOM_SET_BY_DRIVER == request->initiator)
648 hdd_ctx->reg.cc_src = SOURCE_DRIVER;
649 else {
650 hdd_ctx->reg.cc_src = SOURCE_USERSPACE;
651 hdd_restore_custom_reg_settings(wiphy,
652 request->alpha2,
653 &reset);
654 }
655
656 hdd_ctx->reg.alpha2[0] = request->alpha2[0];
657 hdd_ctx->reg.alpha2[1] = request->alpha2[1];
658
659 hdd_update_regulatory_info(hdd_ctx);
660
661 vht80_allowed = hdd_ctx->isVHT80Allowed;
662
663 hdd_process_regulatory_data(hdd_ctx, wiphy, reset);
664
665 if (hdd_ctx->isVHT80Allowed != vht80_allowed)
666 hdd_checkandupdate_phymode(hdd_ctx);
667
668 if (NL80211_REGDOM_SET_BY_DRIVER == request->initiator)
669 complete(&hdd_ctx->reg_init);
670
671 sme_generic_change_country_code(hdd_ctx->hHal,
672 hdd_ctx->reg.alpha2);
673
674 cds_fill_and_send_ctl_to_fw(&hdd_ctx->reg);
675
676 hdd_set_dfs_region(hdd_ctx, request->dfs_region);
677
678 cds_get_dfs_region(&dfs_reg);
679 cds_set_wma_dfs_region(dfs_reg);
680 break;
681
682 default:
683 break;
684 }
685}