選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

ath_regd.c 16KB

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