regd.c 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604
  1. /*
  2. * Copyright (c) 2008-2009 Atheros Communications Inc.
  3. *
  4. * Permission to use, copy, modify, and/or distribute this software for any
  5. * purpose with or without fee is hereby granted, provided that the above
  6. * copyright notice and this permission notice appear in all copies.
  7. *
  8. * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
  9. * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
  10. * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
  11. * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
  12. * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
  13. * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
  14. * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  15. */
  16. #include <linux/kernel.h>
  17. #include <net/cfg80211.h>
  18. #include <net/mac80211.h>
  19. #include "regd.h"
  20. #include "regd_common.h"
  21. /*
  22. * This is a set of common rules used by our world regulatory domains.
  23. * We have 12 world regulatory domains. To save space we consolidate
  24. * the regulatory domains in 5 structures by frequency and change
  25. * the flags on our reg_notifier() on a case by case basis.
  26. */
  27. /* Only these channels all allow active scan on all world regulatory domains */
  28. #define ATH9K_2GHZ_CH01_11 REG_RULE(2412-10, 2462+10, 40, 0, 20, 0)
  29. /* We enable active scan on these a case by case basis by regulatory domain */
  30. #define ATH9K_2GHZ_CH12_13 REG_RULE(2467-10, 2472+10, 40, 0, 20,\
  31. NL80211_RRF_PASSIVE_SCAN)
  32. #define ATH9K_2GHZ_CH14 REG_RULE(2484-10, 2484+10, 40, 0, 20,\
  33. NL80211_RRF_PASSIVE_SCAN | NL80211_RRF_NO_OFDM)
  34. /* We allow IBSS on these on a case by case basis by regulatory domain */
  35. #define ATH9K_5GHZ_5150_5350 REG_RULE(5150-10, 5350+10, 40, 0, 30,\
  36. NL80211_RRF_PASSIVE_SCAN | NL80211_RRF_NO_IBSS)
  37. #define ATH9K_5GHZ_5470_5850 REG_RULE(5470-10, 5850+10, 40, 0, 30,\
  38. NL80211_RRF_PASSIVE_SCAN | NL80211_RRF_NO_IBSS)
  39. #define ATH9K_5GHZ_5725_5850 REG_RULE(5725-10, 5850+10, 40, 0, 30,\
  40. NL80211_RRF_PASSIVE_SCAN | NL80211_RRF_NO_IBSS)
  41. #define ATH9K_2GHZ_ALL ATH9K_2GHZ_CH01_11, \
  42. ATH9K_2GHZ_CH12_13, \
  43. ATH9K_2GHZ_CH14
  44. #define ATH9K_5GHZ_ALL ATH9K_5GHZ_5150_5350, \
  45. ATH9K_5GHZ_5470_5850
  46. /* This one skips what we call "mid band" */
  47. #define ATH9K_5GHZ_NO_MIDBAND ATH9K_5GHZ_5150_5350, \
  48. ATH9K_5GHZ_5725_5850
  49. /* Can be used for:
  50. * 0x60, 0x61, 0x62 */
  51. static const struct ieee80211_regdomain ath_world_regdom_60_61_62 = {
  52. .n_reg_rules = 5,
  53. .alpha2 = "99",
  54. .reg_rules = {
  55. ATH9K_2GHZ_ALL,
  56. ATH9K_5GHZ_ALL,
  57. }
  58. };
  59. /* Can be used by 0x63 and 0x65 */
  60. static const struct ieee80211_regdomain ath_world_regdom_63_65 = {
  61. .n_reg_rules = 4,
  62. .alpha2 = "99",
  63. .reg_rules = {
  64. ATH9K_2GHZ_CH01_11,
  65. ATH9K_2GHZ_CH12_13,
  66. ATH9K_5GHZ_NO_MIDBAND,
  67. }
  68. };
  69. /* Can be used by 0x64 only */
  70. static const struct ieee80211_regdomain ath_world_regdom_64 = {
  71. .n_reg_rules = 3,
  72. .alpha2 = "99",
  73. .reg_rules = {
  74. ATH9K_2GHZ_CH01_11,
  75. ATH9K_5GHZ_NO_MIDBAND,
  76. }
  77. };
  78. /* Can be used by 0x66 and 0x69 */
  79. static const struct ieee80211_regdomain ath_world_regdom_66_69 = {
  80. .n_reg_rules = 3,
  81. .alpha2 = "99",
  82. .reg_rules = {
  83. ATH9K_2GHZ_CH01_11,
  84. ATH9K_5GHZ_ALL,
  85. }
  86. };
  87. /* Can be used by 0x67, 0x6A and 0x68 */
  88. static const struct ieee80211_regdomain ath_world_regdom_67_68_6A = {
  89. .n_reg_rules = 4,
  90. .alpha2 = "99",
  91. .reg_rules = {
  92. ATH9K_2GHZ_CH01_11,
  93. ATH9K_2GHZ_CH12_13,
  94. ATH9K_5GHZ_ALL,
  95. }
  96. };
  97. static inline bool is_wwr_sku(u16 regd)
  98. {
  99. return ((regd & COUNTRY_ERD_FLAG) != COUNTRY_ERD_FLAG) &&
  100. (((regd & WORLD_SKU_MASK) == WORLD_SKU_PREFIX) ||
  101. (regd == WORLD));
  102. }
  103. static u16 ath_regd_get_eepromRD(struct ath_regulatory *reg)
  104. {
  105. return reg->current_rd & ~WORLDWIDE_ROAMING_FLAG;
  106. }
  107. bool ath_is_world_regd(struct ath_regulatory *reg)
  108. {
  109. return is_wwr_sku(ath_regd_get_eepromRD(reg));
  110. }
  111. EXPORT_SYMBOL(ath_is_world_regd);
  112. static const struct ieee80211_regdomain *ath_default_world_regdomain(void)
  113. {
  114. /* this is the most restrictive */
  115. return &ath_world_regdom_64;
  116. }
  117. static const struct
  118. ieee80211_regdomain *ath_world_regdomain(struct ath_regulatory *reg)
  119. {
  120. switch (reg->regpair->regDmnEnum) {
  121. case 0x60:
  122. case 0x61:
  123. case 0x62:
  124. return &ath_world_regdom_60_61_62;
  125. case 0x63:
  126. case 0x65:
  127. return &ath_world_regdom_63_65;
  128. case 0x64:
  129. return &ath_world_regdom_64;
  130. case 0x66:
  131. case 0x69:
  132. return &ath_world_regdom_66_69;
  133. case 0x67:
  134. case 0x68:
  135. case 0x6A:
  136. return &ath_world_regdom_67_68_6A;
  137. default:
  138. WARN_ON(1);
  139. return ath_default_world_regdomain();
  140. }
  141. }
  142. bool ath_is_49ghz_allowed(u16 regdomain)
  143. {
  144. /* possibly more */
  145. return regdomain == MKK9_MKKC;
  146. }
  147. EXPORT_SYMBOL(ath_is_49ghz_allowed);
  148. /* Frequency is one where radar detection is required */
  149. static bool ath_is_radar_freq(u16 center_freq)
  150. {
  151. return (center_freq >= 5260 && center_freq <= 5700);
  152. }
  153. /*
  154. * N.B: These exception rules do not apply radar freqs.
  155. *
  156. * - We enable adhoc (or beaconing) if allowed by 11d
  157. * - We enable active scan if the channel is allowed by 11d
  158. * - If no country IE has been processed and a we determine we have
  159. * received a beacon on a channel we can enable active scan and
  160. * adhoc (or beaconing).
  161. */
  162. static void
  163. ath_reg_apply_beaconing_flags(struct wiphy *wiphy,
  164. enum nl80211_reg_initiator initiator)
  165. {
  166. enum ieee80211_band band;
  167. struct ieee80211_supported_band *sband;
  168. const struct ieee80211_reg_rule *reg_rule;
  169. struct ieee80211_channel *ch;
  170. unsigned int i;
  171. u32 bandwidth = 0;
  172. int r;
  173. for (band = 0; band < IEEE80211_NUM_BANDS; band++) {
  174. if (!wiphy->bands[band])
  175. continue;
  176. sband = wiphy->bands[band];
  177. for (i = 0; i < sband->n_channels; i++) {
  178. ch = &sband->channels[i];
  179. if (ath_is_radar_freq(ch->center_freq) ||
  180. (ch->flags & IEEE80211_CHAN_RADAR))
  181. continue;
  182. if (initiator == NL80211_REGDOM_SET_BY_COUNTRY_IE) {
  183. r = freq_reg_info(wiphy,
  184. ch->center_freq,
  185. bandwidth,
  186. &reg_rule);
  187. if (r)
  188. continue;
  189. /*
  190. * If 11d had a rule for this channel ensure
  191. * we enable adhoc/beaconing if it allows us to
  192. * use it. Note that we would have disabled it
  193. * by applying our static world regdomain by
  194. * default during init, prior to calling our
  195. * regulatory_hint().
  196. */
  197. if (!(reg_rule->flags &
  198. NL80211_RRF_NO_IBSS))
  199. ch->flags &=
  200. ~IEEE80211_CHAN_NO_IBSS;
  201. if (!(reg_rule->flags &
  202. NL80211_RRF_PASSIVE_SCAN))
  203. ch->flags &=
  204. ~IEEE80211_CHAN_PASSIVE_SCAN;
  205. } else {
  206. if (ch->beacon_found)
  207. ch->flags &= ~(IEEE80211_CHAN_NO_IBSS |
  208. IEEE80211_CHAN_PASSIVE_SCAN);
  209. }
  210. }
  211. }
  212. }
  213. /* Allows active scan scan on Ch 12 and 13 */
  214. static void
  215. ath_reg_apply_active_scan_flags(struct wiphy *wiphy,
  216. enum nl80211_reg_initiator initiator)
  217. {
  218. struct ieee80211_supported_band *sband;
  219. struct ieee80211_channel *ch;
  220. const struct ieee80211_reg_rule *reg_rule;
  221. u32 bandwidth = 0;
  222. int r;
  223. sband = wiphy->bands[IEEE80211_BAND_2GHZ];
  224. /*
  225. * If no country IE has been received always enable active scan
  226. * on these channels. This is only done for specific regulatory SKUs
  227. */
  228. if (initiator != NL80211_REGDOM_SET_BY_COUNTRY_IE) {
  229. ch = &sband->channels[11]; /* CH 12 */
  230. if (ch->flags & IEEE80211_CHAN_PASSIVE_SCAN)
  231. ch->flags &= ~IEEE80211_CHAN_PASSIVE_SCAN;
  232. ch = &sband->channels[12]; /* CH 13 */
  233. if (ch->flags & IEEE80211_CHAN_PASSIVE_SCAN)
  234. ch->flags &= ~IEEE80211_CHAN_PASSIVE_SCAN;
  235. return;
  236. }
  237. /*
  238. * If a country IE has been recieved check its rule for this
  239. * channel first before enabling active scan. The passive scan
  240. * would have been enforced by the initial processing of our
  241. * custom regulatory domain.
  242. */
  243. ch = &sband->channels[11]; /* CH 12 */
  244. r = freq_reg_info(wiphy, ch->center_freq, bandwidth, &reg_rule);
  245. if (!r) {
  246. if (!(reg_rule->flags & NL80211_RRF_PASSIVE_SCAN))
  247. if (ch->flags & IEEE80211_CHAN_PASSIVE_SCAN)
  248. ch->flags &= ~IEEE80211_CHAN_PASSIVE_SCAN;
  249. }
  250. ch = &sband->channels[12]; /* CH 13 */
  251. r = freq_reg_info(wiphy, ch->center_freq, bandwidth, &reg_rule);
  252. if (!r) {
  253. if (!(reg_rule->flags & NL80211_RRF_PASSIVE_SCAN))
  254. if (ch->flags & IEEE80211_CHAN_PASSIVE_SCAN)
  255. ch->flags &= ~IEEE80211_CHAN_PASSIVE_SCAN;
  256. }
  257. }
  258. /* Always apply Radar/DFS rules on freq range 5260 MHz - 5700 MHz */
  259. static void ath_reg_apply_radar_flags(struct wiphy *wiphy)
  260. {
  261. struct ieee80211_supported_band *sband;
  262. struct ieee80211_channel *ch;
  263. unsigned int i;
  264. if (!wiphy->bands[IEEE80211_BAND_5GHZ])
  265. return;
  266. sband = wiphy->bands[IEEE80211_BAND_5GHZ];
  267. for (i = 0; i < sband->n_channels; i++) {
  268. ch = &sband->channels[i];
  269. if (!ath_is_radar_freq(ch->center_freq))
  270. continue;
  271. /* We always enable radar detection/DFS on this
  272. * frequency range. Additionally we also apply on
  273. * this frequency range:
  274. * - If STA mode does not yet have DFS supports disable
  275. * active scanning
  276. * - If adhoc mode does not support DFS yet then
  277. * disable adhoc in the frequency.
  278. * - If AP mode does not yet support radar detection/DFS
  279. * do not allow AP mode
  280. */
  281. if (!(ch->flags & IEEE80211_CHAN_DISABLED))
  282. ch->flags |= IEEE80211_CHAN_RADAR |
  283. IEEE80211_CHAN_NO_IBSS |
  284. IEEE80211_CHAN_PASSIVE_SCAN;
  285. }
  286. }
  287. static void ath_reg_apply_world_flags(struct wiphy *wiphy,
  288. enum nl80211_reg_initiator initiator,
  289. struct ath_regulatory *reg)
  290. {
  291. switch (reg->regpair->regDmnEnum) {
  292. case 0x60:
  293. case 0x63:
  294. case 0x66:
  295. case 0x67:
  296. ath_reg_apply_beaconing_flags(wiphy, initiator);
  297. break;
  298. case 0x68:
  299. ath_reg_apply_beaconing_flags(wiphy, initiator);
  300. ath_reg_apply_active_scan_flags(wiphy, initiator);
  301. break;
  302. }
  303. }
  304. int ath_reg_notifier_apply(struct wiphy *wiphy,
  305. struct regulatory_request *request,
  306. struct ath_regulatory *reg)
  307. {
  308. /* We always apply this */
  309. ath_reg_apply_radar_flags(wiphy);
  310. /*
  311. * This would happen when we have sent a custom regulatory request
  312. * a world regulatory domain and the scheduler hasn't yet processed
  313. * any pending requests in the queue.
  314. */
  315. if (!request)
  316. return 0;
  317. switch (request->initiator) {
  318. case NL80211_REGDOM_SET_BY_DRIVER:
  319. case NL80211_REGDOM_SET_BY_CORE:
  320. case NL80211_REGDOM_SET_BY_USER:
  321. break;
  322. case NL80211_REGDOM_SET_BY_COUNTRY_IE:
  323. if (ath_is_world_regd(reg))
  324. ath_reg_apply_world_flags(wiphy, request->initiator,
  325. reg);
  326. break;
  327. }
  328. return 0;
  329. }
  330. EXPORT_SYMBOL(ath_reg_notifier_apply);
  331. static bool ath_regd_is_eeprom_valid(struct ath_regulatory *reg)
  332. {
  333. u16 rd = ath_regd_get_eepromRD(reg);
  334. int i;
  335. if (rd & COUNTRY_ERD_FLAG) {
  336. /* EEPROM value is a country code */
  337. u16 cc = rd & ~COUNTRY_ERD_FLAG;
  338. printk(KERN_DEBUG
  339. "ath: EEPROM indicates we should expect "
  340. "a country code\n");
  341. for (i = 0; i < ARRAY_SIZE(allCountries); i++)
  342. if (allCountries[i].countryCode == cc)
  343. return true;
  344. } else {
  345. /* EEPROM value is a regpair value */
  346. if (rd != CTRY_DEFAULT)
  347. printk(KERN_DEBUG "ath: EEPROM indicates we "
  348. "should expect a direct regpair map\n");
  349. for (i = 0; i < ARRAY_SIZE(regDomainPairs); i++)
  350. if (regDomainPairs[i].regDmnEnum == rd)
  351. return true;
  352. }
  353. printk(KERN_DEBUG
  354. "ath: invalid regulatory domain/country code 0x%x\n", rd);
  355. return false;
  356. }
  357. /* EEPROM country code to regpair mapping */
  358. static struct country_code_to_enum_rd*
  359. ath_regd_find_country(u16 countryCode)
  360. {
  361. int i;
  362. for (i = 0; i < ARRAY_SIZE(allCountries); i++) {
  363. if (allCountries[i].countryCode == countryCode)
  364. return &allCountries[i];
  365. }
  366. return NULL;
  367. }
  368. /* EEPROM rd code to regpair mapping */
  369. static struct country_code_to_enum_rd*
  370. ath_regd_find_country_by_rd(int regdmn)
  371. {
  372. int i;
  373. for (i = 0; i < ARRAY_SIZE(allCountries); i++) {
  374. if (allCountries[i].regDmnEnum == regdmn)
  375. return &allCountries[i];
  376. }
  377. return NULL;
  378. }
  379. /* Returns the map of the EEPROM set RD to a country code */
  380. static u16 ath_regd_get_default_country(u16 rd)
  381. {
  382. if (rd & COUNTRY_ERD_FLAG) {
  383. struct country_code_to_enum_rd *country = NULL;
  384. u16 cc = rd & ~COUNTRY_ERD_FLAG;
  385. country = ath_regd_find_country(cc);
  386. if (country != NULL)
  387. return cc;
  388. }
  389. return CTRY_DEFAULT;
  390. }
  391. static struct reg_dmn_pair_mapping*
  392. ath_get_regpair(int regdmn)
  393. {
  394. int i;
  395. if (regdmn == NO_ENUMRD)
  396. return NULL;
  397. for (i = 0; i < ARRAY_SIZE(regDomainPairs); i++) {
  398. if (regDomainPairs[i].regDmnEnum == regdmn)
  399. return &regDomainPairs[i];
  400. }
  401. return NULL;
  402. }
  403. static int
  404. ath_regd_init_wiphy(struct ath_regulatory *reg,
  405. struct wiphy *wiphy,
  406. int (*reg_notifier)(struct wiphy *wiphy,
  407. struct regulatory_request *request))
  408. {
  409. const struct ieee80211_regdomain *regd;
  410. wiphy->reg_notifier = reg_notifier;
  411. wiphy->flags |= WIPHY_FLAG_STRICT_REGULATORY;
  412. if (ath_is_world_regd(reg)) {
  413. /*
  414. * Anything applied here (prior to wiphy registration) gets
  415. * saved on the wiphy orig_* parameters
  416. */
  417. regd = ath_world_regdomain(reg);
  418. wiphy->flags |= WIPHY_FLAG_CUSTOM_REGULATORY;
  419. } else {
  420. /*
  421. * This gets applied in the case of the absense of CRDA,
  422. * it's our own custom world regulatory domain, similar to
  423. * cfg80211's but we enable passive scanning.
  424. */
  425. regd = ath_default_world_regdomain();
  426. }
  427. wiphy_apply_custom_regulatory(wiphy, regd);
  428. ath_reg_apply_radar_flags(wiphy);
  429. ath_reg_apply_world_flags(wiphy, NL80211_REGDOM_SET_BY_DRIVER, reg);
  430. return 0;
  431. }
  432. /*
  433. * Some users have reported their EEPROM programmed with
  434. * 0x8000 set, this is not a supported regulatory domain
  435. * but since we have more than one user with it we need
  436. * a solution for them. We default to 0x64, which is the
  437. * default Atheros world regulatory domain.
  438. */
  439. static void ath_regd_sanitize(struct ath_regulatory *reg)
  440. {
  441. if (reg->current_rd != COUNTRY_ERD_FLAG)
  442. return;
  443. printk(KERN_DEBUG "ath: EEPROM regdomain sanitized\n");
  444. reg->current_rd = 0x64;
  445. }
  446. int
  447. ath_regd_init(struct ath_regulatory *reg,
  448. struct wiphy *wiphy,
  449. int (*reg_notifier)(struct wiphy *wiphy,
  450. struct regulatory_request *request))
  451. {
  452. struct country_code_to_enum_rd *country = NULL;
  453. u16 regdmn;
  454. if (!reg)
  455. return -EINVAL;
  456. ath_regd_sanitize(reg);
  457. printk(KERN_DEBUG "ath: EEPROM regdomain: 0x%0x\n", reg->current_rd);
  458. if (!ath_regd_is_eeprom_valid(reg)) {
  459. printk(KERN_ERR "ath: Invalid EEPROM contents\n");
  460. return -EINVAL;
  461. }
  462. regdmn = ath_regd_get_eepromRD(reg);
  463. reg->country_code = ath_regd_get_default_country(regdmn);
  464. if (reg->country_code == CTRY_DEFAULT &&
  465. regdmn == CTRY_DEFAULT) {
  466. printk(KERN_DEBUG "ath: EEPROM indicates default "
  467. "country code should be used\n");
  468. reg->country_code = CTRY_UNITED_STATES;
  469. }
  470. if (reg->country_code == CTRY_DEFAULT) {
  471. country = NULL;
  472. } else {
  473. printk(KERN_DEBUG "ath: doing EEPROM country->regdmn "
  474. "map search\n");
  475. country = ath_regd_find_country(reg->country_code);
  476. if (country == NULL) {
  477. printk(KERN_DEBUG
  478. "ath: no valid country maps found for "
  479. "country code: 0x%0x\n",
  480. reg->country_code);
  481. return -EINVAL;
  482. } else {
  483. regdmn = country->regDmnEnum;
  484. printk(KERN_DEBUG "ath: country maps to "
  485. "regdmn code: 0x%0x\n",
  486. regdmn);
  487. }
  488. }
  489. reg->regpair = ath_get_regpair(regdmn);
  490. if (!reg->regpair) {
  491. printk(KERN_DEBUG "ath: "
  492. "No regulatory domain pair found, cannot continue\n");
  493. return -EINVAL;
  494. }
  495. if (!country)
  496. country = ath_regd_find_country_by_rd(regdmn);
  497. if (country) {
  498. reg->alpha2[0] = country->isoName[0];
  499. reg->alpha2[1] = country->isoName[1];
  500. } else {
  501. reg->alpha2[0] = '0';
  502. reg->alpha2[1] = '0';
  503. }
  504. printk(KERN_DEBUG "ath: Country alpha2 being used: %c%c\n",
  505. reg->alpha2[0], reg->alpha2[1]);
  506. printk(KERN_DEBUG "ath: Regpair used: 0x%0x\n",
  507. reg->regpair->regDmnEnum);
  508. ath_regd_init_wiphy(reg, wiphy, reg_notifier);
  509. return 0;
  510. }
  511. EXPORT_SYMBOL(ath_regd_init);
  512. u32 ath_regd_get_band_ctl(struct ath_regulatory *reg,
  513. enum ieee80211_band band)
  514. {
  515. if (!reg->regpair ||
  516. (reg->country_code == CTRY_DEFAULT &&
  517. is_wwr_sku(ath_regd_get_eepromRD(reg)))) {
  518. return SD_NO_CTL;
  519. }
  520. switch (band) {
  521. case IEEE80211_BAND_2GHZ:
  522. return reg->regpair->reg_2ghz_ctl;
  523. case IEEE80211_BAND_5GHZ:
  524. return reg->regpair->reg_5ghz_ctl;
  525. default:
  526. return NO_CTL;
  527. }
  528. }
  529. EXPORT_SYMBOL(ath_regd_get_band_ctl);