regd.c 16 KB

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