11d.c 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696
  1. /**
  2. * This file contains functions for 802.11D.
  3. */
  4. #include <linux/ctype.h>
  5. #include <linux/kernel.h>
  6. #include <linux/wireless.h>
  7. #include "host.h"
  8. #include "decl.h"
  9. #include "11d.h"
  10. #include "dev.h"
  11. #include "wext.h"
  12. #define TX_PWR_DEFAULT 10
  13. static struct region_code_mapping region_code_mapping[] = {
  14. {"US ", 0x10}, /* US FCC */
  15. {"CA ", 0x10}, /* IC Canada */
  16. {"SG ", 0x10}, /* Singapore */
  17. {"EU ", 0x30}, /* ETSI */
  18. {"AU ", 0x30}, /* Australia */
  19. {"KR ", 0x30}, /* Republic Of Korea */
  20. {"ES ", 0x31}, /* Spain */
  21. {"FR ", 0x32}, /* France */
  22. {"JP ", 0x40}, /* Japan */
  23. };
  24. /* Following 2 structure defines the supported channels */
  25. static struct chan_freq_power channel_freq_power_UN_BG[] = {
  26. {1, 2412, TX_PWR_DEFAULT},
  27. {2, 2417, TX_PWR_DEFAULT},
  28. {3, 2422, TX_PWR_DEFAULT},
  29. {4, 2427, TX_PWR_DEFAULT},
  30. {5, 2432, TX_PWR_DEFAULT},
  31. {6, 2437, TX_PWR_DEFAULT},
  32. {7, 2442, TX_PWR_DEFAULT},
  33. {8, 2447, TX_PWR_DEFAULT},
  34. {9, 2452, TX_PWR_DEFAULT},
  35. {10, 2457, TX_PWR_DEFAULT},
  36. {11, 2462, TX_PWR_DEFAULT},
  37. {12, 2467, TX_PWR_DEFAULT},
  38. {13, 2472, TX_PWR_DEFAULT},
  39. {14, 2484, TX_PWR_DEFAULT}
  40. };
  41. static u8 lbs_region_2_code(u8 *region)
  42. {
  43. u8 i;
  44. for (i = 0; i < COUNTRY_CODE_LEN && region[i]; i++)
  45. region[i] = toupper(region[i]);
  46. for (i = 0; i < ARRAY_SIZE(region_code_mapping); i++) {
  47. if (!memcmp(region, region_code_mapping[i].region,
  48. COUNTRY_CODE_LEN))
  49. return (region_code_mapping[i].code);
  50. }
  51. /* default is US */
  52. return (region_code_mapping[0].code);
  53. }
  54. static u8 *lbs_code_2_region(u8 code)
  55. {
  56. u8 i;
  57. for (i = 0; i < ARRAY_SIZE(region_code_mapping); i++) {
  58. if (region_code_mapping[i].code == code)
  59. return (region_code_mapping[i].region);
  60. }
  61. /* default is US */
  62. return (region_code_mapping[0].region);
  63. }
  64. /**
  65. * @brief This function finds the nrchan-th chan after the firstchan
  66. * @param band band
  67. * @param firstchan first channel number
  68. * @param nrchan number of channels
  69. * @return the nrchan-th chan number
  70. */
  71. static u8 lbs_get_chan_11d(u8 firstchan, u8 nrchan, u8 *chan)
  72. /*find the nrchan-th chan after the firstchan*/
  73. {
  74. u8 i;
  75. struct chan_freq_power *cfp;
  76. u8 cfp_no;
  77. cfp = channel_freq_power_UN_BG;
  78. cfp_no = ARRAY_SIZE(channel_freq_power_UN_BG);
  79. for (i = 0; i < cfp_no; i++) {
  80. if ((cfp + i)->channel == firstchan) {
  81. lbs_deb_11d("firstchan found\n");
  82. break;
  83. }
  84. }
  85. if (i < cfp_no) {
  86. /*if beyond the boundary */
  87. if (i + nrchan < cfp_no) {
  88. *chan = (cfp + i + nrchan)->channel;
  89. return 1;
  90. }
  91. }
  92. return 0;
  93. }
  94. /**
  95. * @brief This function Checks if chan txpwr is learned from AP/IBSS
  96. * @param chan chan number
  97. * @param parsed_region_chan pointer to parsed_region_chan_11d
  98. * @return TRUE; FALSE
  99. */
  100. static u8 lbs_channel_known_11d(u8 chan,
  101. struct parsed_region_chan_11d * parsed_region_chan)
  102. {
  103. struct chan_power_11d *chanpwr = parsed_region_chan->chanpwr;
  104. u8 nr_chan = parsed_region_chan->nr_chan;
  105. u8 i = 0;
  106. lbs_deb_hex(LBS_DEB_11D, "parsed_region_chan", (char *)chanpwr,
  107. sizeof(struct chan_power_11d) * nr_chan);
  108. for (i = 0; i < nr_chan; i++) {
  109. if (chan == chanpwr[i].chan) {
  110. lbs_deb_11d("found chan %d\n", chan);
  111. return 1;
  112. }
  113. }
  114. lbs_deb_11d("chan %d not found\n", chan);
  115. return 0;
  116. }
  117. u32 lbs_chan_2_freq(u8 chan)
  118. {
  119. struct chan_freq_power *cf;
  120. u16 i;
  121. u32 freq = 0;
  122. cf = channel_freq_power_UN_BG;
  123. for (i = 0; i < ARRAY_SIZE(channel_freq_power_UN_BG); i++) {
  124. if (chan == cf[i].channel)
  125. freq = cf[i].freq;
  126. }
  127. return freq;
  128. }
  129. static int generate_domain_info_11d(struct parsed_region_chan_11d
  130. *parsed_region_chan,
  131. struct lbs_802_11d_domain_reg *domaininfo)
  132. {
  133. u8 nr_subband = 0;
  134. u8 nr_chan = parsed_region_chan->nr_chan;
  135. u8 nr_parsedchan = 0;
  136. u8 firstchan = 0, nextchan = 0, maxpwr = 0;
  137. u8 i, flag = 0;
  138. memcpy(domaininfo->countrycode, parsed_region_chan->countrycode,
  139. COUNTRY_CODE_LEN);
  140. lbs_deb_11d("nrchan %d\n", nr_chan);
  141. lbs_deb_hex(LBS_DEB_11D, "parsed_region_chan", (char *)parsed_region_chan,
  142. sizeof(struct parsed_region_chan_11d));
  143. for (i = 0; i < nr_chan; i++) {
  144. if (!flag) {
  145. flag = 1;
  146. nextchan = firstchan =
  147. parsed_region_chan->chanpwr[i].chan;
  148. maxpwr = parsed_region_chan->chanpwr[i].pwr;
  149. nr_parsedchan = 1;
  150. continue;
  151. }
  152. if (parsed_region_chan->chanpwr[i].chan == nextchan + 1 &&
  153. parsed_region_chan->chanpwr[i].pwr == maxpwr) {
  154. nextchan++;
  155. nr_parsedchan++;
  156. } else {
  157. domaininfo->subband[nr_subband].firstchan = firstchan;
  158. domaininfo->subband[nr_subband].nrchan =
  159. nr_parsedchan;
  160. domaininfo->subband[nr_subband].maxtxpwr = maxpwr;
  161. nr_subband++;
  162. nextchan = firstchan =
  163. parsed_region_chan->chanpwr[i].chan;
  164. maxpwr = parsed_region_chan->chanpwr[i].pwr;
  165. }
  166. }
  167. if (flag) {
  168. domaininfo->subband[nr_subband].firstchan = firstchan;
  169. domaininfo->subband[nr_subband].nrchan = nr_parsedchan;
  170. domaininfo->subband[nr_subband].maxtxpwr = maxpwr;
  171. nr_subband++;
  172. }
  173. domaininfo->nr_subband = nr_subband;
  174. lbs_deb_11d("nr_subband=%x\n", domaininfo->nr_subband);
  175. lbs_deb_hex(LBS_DEB_11D, "domaininfo", (char *)domaininfo,
  176. COUNTRY_CODE_LEN + 1 +
  177. sizeof(struct ieee_subbandset) * nr_subband);
  178. return 0;
  179. }
  180. /**
  181. * @brief This function generates parsed_region_chan from Domain Info learned from AP/IBSS
  182. * @param region_chan pointer to struct region_channel
  183. * @param *parsed_region_chan pointer to parsed_region_chan_11d
  184. * @return N/A
  185. */
  186. static void lbs_generate_parsed_region_chan_11d(struct region_channel *region_chan,
  187. struct parsed_region_chan_11d *
  188. parsed_region_chan)
  189. {
  190. u8 i;
  191. struct chan_freq_power *cfp;
  192. if (region_chan == NULL) {
  193. lbs_deb_11d("region_chan is NULL\n");
  194. return;
  195. }
  196. cfp = region_chan->CFP;
  197. if (cfp == NULL) {
  198. lbs_deb_11d("cfp is NULL \n");
  199. return;
  200. }
  201. parsed_region_chan->band = region_chan->band;
  202. parsed_region_chan->region = region_chan->region;
  203. memcpy(parsed_region_chan->countrycode,
  204. lbs_code_2_region(region_chan->region), COUNTRY_CODE_LEN);
  205. lbs_deb_11d("region 0x%x, band %d\n", parsed_region_chan->region,
  206. parsed_region_chan->band);
  207. for (i = 0; i < region_chan->nrcfp; i++, cfp++) {
  208. parsed_region_chan->chanpwr[i].chan = cfp->channel;
  209. parsed_region_chan->chanpwr[i].pwr = cfp->maxtxpower;
  210. lbs_deb_11d("chan %d, pwr %d\n",
  211. parsed_region_chan->chanpwr[i].chan,
  212. parsed_region_chan->chanpwr[i].pwr);
  213. }
  214. parsed_region_chan->nr_chan = region_chan->nrcfp;
  215. lbs_deb_11d("nrchan %d\n", parsed_region_chan->nr_chan);
  216. return;
  217. }
  218. /**
  219. * @brief generate parsed_region_chan from Domain Info learned from AP/IBSS
  220. * @param region region ID
  221. * @param band band
  222. * @param chan chan
  223. * @return TRUE;FALSE
  224. */
  225. static u8 lbs_region_chan_supported_11d(u8 region, u8 chan)
  226. {
  227. struct chan_freq_power *cfp;
  228. int cfp_no;
  229. u8 idx;
  230. int ret = 0;
  231. lbs_deb_enter(LBS_DEB_11D);
  232. cfp = lbs_get_region_cfp_table(region, &cfp_no);
  233. if (cfp == NULL)
  234. return 0;
  235. for (idx = 0; idx < cfp_no; idx++) {
  236. if (chan == (cfp + idx)->channel) {
  237. /* If Mrvl Chip Supported? */
  238. if ((cfp + idx)->unsupported) {
  239. ret = 0;
  240. } else {
  241. ret = 1;
  242. }
  243. goto done;
  244. }
  245. }
  246. /*chan is not in the region table */
  247. done:
  248. lbs_deb_leave_args(LBS_DEB_11D, "ret %d", ret);
  249. return ret;
  250. }
  251. /**
  252. * @brief This function checks if chan txpwr is learned from AP/IBSS
  253. * @param chan chan number
  254. * @param parsed_region_chan pointer to parsed_region_chan_11d
  255. * @return 0
  256. */
  257. static int parse_domain_info_11d(struct ieee_ie_country_info_full_set *countryinfo,
  258. u8 band,
  259. struct parsed_region_chan_11d *parsed_region_chan)
  260. {
  261. u8 nr_subband, nrchan;
  262. u8 lastchan, firstchan;
  263. u8 region;
  264. u8 curchan = 0;
  265. u8 idx = 0; /*chan index in parsed_region_chan */
  266. u8 j, i;
  267. lbs_deb_enter(LBS_DEB_11D);
  268. /*validation Rules:
  269. 1. valid region Code
  270. 2. First Chan increment
  271. 3. channel range no overlap
  272. 4. channel is valid?
  273. 5. channel is supported by region?
  274. 6. Others
  275. */
  276. lbs_deb_hex(LBS_DEB_11D, "countryinfo", (u8 *) countryinfo, 30);
  277. if ((*(countryinfo->countrycode)) == 0
  278. || (countryinfo->header.len <= COUNTRY_CODE_LEN)) {
  279. /* No region Info or Wrong region info: treat as No 11D info */
  280. goto done;
  281. }
  282. /*Step1: check region_code */
  283. parsed_region_chan->region = region =
  284. lbs_region_2_code(countryinfo->countrycode);
  285. lbs_deb_11d("regioncode=%x\n", (u8) parsed_region_chan->region);
  286. lbs_deb_hex(LBS_DEB_11D, "countrycode", (char *)countryinfo->countrycode,
  287. COUNTRY_CODE_LEN);
  288. parsed_region_chan->band = band;
  289. memcpy(parsed_region_chan->countrycode, countryinfo->countrycode,
  290. COUNTRY_CODE_LEN);
  291. nr_subband = (countryinfo->header.len - COUNTRY_CODE_LEN) /
  292. sizeof(struct ieee_subbandset);
  293. for (j = 0, lastchan = 0; j < nr_subband; j++) {
  294. if (countryinfo->subband[j].firstchan <= lastchan) {
  295. /*Step2&3. Check First Chan Num increment and no overlap */
  296. lbs_deb_11d("chan %d>%d, overlap\n",
  297. countryinfo->subband[j].firstchan, lastchan);
  298. continue;
  299. }
  300. firstchan = countryinfo->subband[j].firstchan;
  301. nrchan = countryinfo->subband[j].nrchan;
  302. for (i = 0; idx < MAX_NO_OF_CHAN && i < nrchan; i++) {
  303. /*step4: channel is supported? */
  304. if (!lbs_get_chan_11d(firstchan, i, &curchan)) {
  305. /* Chan is not found in UN table */
  306. lbs_deb_11d("chan is not supported: %d \n", i);
  307. break;
  308. }
  309. lastchan = curchan;
  310. if (lbs_region_chan_supported_11d(region, curchan)) {
  311. /*step5: Check if curchan is supported by mrvl in region */
  312. parsed_region_chan->chanpwr[idx].chan = curchan;
  313. parsed_region_chan->chanpwr[idx].pwr =
  314. countryinfo->subband[j].maxtxpwr;
  315. idx++;
  316. } else {
  317. /*not supported and ignore the chan */
  318. lbs_deb_11d(
  319. "i %d, chan %d unsupported in region %x, band %d\n",
  320. i, curchan, region, band);
  321. }
  322. }
  323. /*Step6: Add other checking if any */
  324. }
  325. parsed_region_chan->nr_chan = idx;
  326. lbs_deb_11d("nrchan=%x\n", parsed_region_chan->nr_chan);
  327. lbs_deb_hex(LBS_DEB_11D, "parsed_region_chan", (u8 *) parsed_region_chan,
  328. 2 + COUNTRY_CODE_LEN + sizeof(struct parsed_region_chan_11d) * idx);
  329. done:
  330. lbs_deb_enter(LBS_DEB_11D);
  331. return 0;
  332. }
  333. /**
  334. * @brief This function calculates the scan type for channels
  335. * @param chan chan number
  336. * @param parsed_region_chan pointer to parsed_region_chan_11d
  337. * @return PASSIVE if chan is unknown; ACTIVE if chan is known
  338. */
  339. u8 lbs_get_scan_type_11d(u8 chan,
  340. struct parsed_region_chan_11d * parsed_region_chan)
  341. {
  342. u8 scan_type = CMD_SCAN_TYPE_PASSIVE;
  343. lbs_deb_enter(LBS_DEB_11D);
  344. if (lbs_channel_known_11d(chan, parsed_region_chan)) {
  345. lbs_deb_11d("found, do active scan\n");
  346. scan_type = CMD_SCAN_TYPE_ACTIVE;
  347. } else {
  348. lbs_deb_11d("not found, do passive scan\n");
  349. }
  350. lbs_deb_leave_args(LBS_DEB_11D, "ret scan_type %d", scan_type);
  351. return scan_type;
  352. }
  353. void lbs_init_11d(struct lbs_private *priv)
  354. {
  355. priv->enable11d = 0;
  356. memset(&(priv->parsed_region_chan), 0,
  357. sizeof(struct parsed_region_chan_11d));
  358. return;
  359. }
  360. /**
  361. * @brief This function sets DOMAIN INFO to FW
  362. * @param priv pointer to struct lbs_private
  363. * @return 0; -1
  364. */
  365. static int set_domain_info_11d(struct lbs_private *priv)
  366. {
  367. int ret;
  368. if (!priv->enable11d) {
  369. lbs_deb_11d("dnld domain Info with 11d disabled\n");
  370. return 0;
  371. }
  372. ret = lbs_prepare_and_send_command(priv, CMD_802_11D_DOMAIN_INFO,
  373. CMD_ACT_SET,
  374. CMD_OPTION_WAITFORRSP, 0, NULL);
  375. if (ret)
  376. lbs_deb_11d("fail to dnld domain info\n");
  377. return ret;
  378. }
  379. /**
  380. * @brief This function setups scan channels
  381. * @param priv pointer to struct lbs_private
  382. * @param band band
  383. * @return 0
  384. */
  385. int lbs_set_universaltable(struct lbs_private *priv, u8 band)
  386. {
  387. u16 size = sizeof(struct chan_freq_power);
  388. u16 i = 0;
  389. memset(priv->universal_channel, 0,
  390. sizeof(priv->universal_channel));
  391. priv->universal_channel[i].nrcfp =
  392. sizeof(channel_freq_power_UN_BG) / size;
  393. lbs_deb_11d("BG-band nrcfp %d\n",
  394. priv->universal_channel[i].nrcfp);
  395. priv->universal_channel[i].CFP = channel_freq_power_UN_BG;
  396. priv->universal_channel[i].valid = 1;
  397. priv->universal_channel[i].region = UNIVERSAL_REGION_CODE;
  398. priv->universal_channel[i].band = band;
  399. i++;
  400. return 0;
  401. }
  402. /**
  403. * @brief This function implements command CMD_802_11D_DOMAIN_INFO
  404. * @param priv pointer to struct lbs_private
  405. * @param cmd pointer to cmd buffer
  406. * @param cmdno cmd ID
  407. * @param cmdOption cmd action
  408. * @return 0
  409. */
  410. int lbs_cmd_802_11d_domain_info(struct lbs_private *priv,
  411. struct cmd_ds_command *cmd, u16 cmdno,
  412. u16 cmdoption)
  413. {
  414. struct cmd_ds_802_11d_domain_info *pdomaininfo =
  415. &cmd->params.domaininfo;
  416. struct mrvl_ie_domain_param_set *domain = &pdomaininfo->domain;
  417. u8 nr_subband = priv->domainreg.nr_subband;
  418. lbs_deb_enter(LBS_DEB_11D);
  419. lbs_deb_11d("nr_subband=%x\n", nr_subband);
  420. cmd->command = cpu_to_le16(cmdno);
  421. pdomaininfo->action = cpu_to_le16(cmdoption);
  422. if (cmdoption == CMD_ACT_GET) {
  423. cmd->size =
  424. cpu_to_le16(sizeof(pdomaininfo->action) + S_DS_GEN);
  425. lbs_deb_hex(LBS_DEB_11D, "802_11D_DOMAIN_INFO", (u8 *) cmd,
  426. le16_to_cpu(cmd->size));
  427. goto done;
  428. }
  429. domain->header.type = cpu_to_le16(TLV_TYPE_DOMAIN);
  430. memcpy(domain->countrycode, priv->domainreg.countrycode,
  431. sizeof(domain->countrycode));
  432. domain->header.len =
  433. cpu_to_le16(nr_subband * sizeof(struct ieee_subbandset) +
  434. sizeof(domain->countrycode));
  435. if (nr_subband) {
  436. memcpy(domain->subband, priv->domainreg.subband,
  437. nr_subband * sizeof(struct ieee_subbandset));
  438. cmd->size = cpu_to_le16(sizeof(pdomaininfo->action) +
  439. le16_to_cpu(domain->header.len) +
  440. sizeof(struct mrvl_ie_header) +
  441. S_DS_GEN);
  442. } else {
  443. cmd->size =
  444. cpu_to_le16(sizeof(pdomaininfo->action) + S_DS_GEN);
  445. }
  446. lbs_deb_hex(LBS_DEB_11D, "802_11D_DOMAIN_INFO", (u8 *) cmd, le16_to_cpu(cmd->size));
  447. done:
  448. lbs_deb_enter(LBS_DEB_11D);
  449. return 0;
  450. }
  451. /**
  452. * @brief This function parses countryinfo from AP and download country info to FW
  453. * @param priv pointer to struct lbs_private
  454. * @param resp pointer to command response buffer
  455. * @return 0; -1
  456. */
  457. int lbs_ret_802_11d_domain_info(struct cmd_ds_command *resp)
  458. {
  459. struct cmd_ds_802_11d_domain_info *domaininfo = &resp->params.domaininforesp;
  460. struct mrvl_ie_domain_param_set *domain = &domaininfo->domain;
  461. u16 action = le16_to_cpu(domaininfo->action);
  462. s16 ret = 0;
  463. u8 nr_subband = 0;
  464. lbs_deb_enter(LBS_DEB_11D);
  465. lbs_deb_hex(LBS_DEB_11D, "domain info resp", (u8 *) resp,
  466. (int)le16_to_cpu(resp->size));
  467. nr_subband = (le16_to_cpu(domain->header.len) - COUNTRY_CODE_LEN) /
  468. sizeof(struct ieee_subbandset);
  469. lbs_deb_11d("domain info resp: nr_subband %d\n", nr_subband);
  470. if (nr_subband > MRVDRV_MAX_SUBBAND_802_11D) {
  471. lbs_deb_11d("Invalid Numrer of Subband returned!!\n");
  472. return -1;
  473. }
  474. switch (action) {
  475. case CMD_ACT_SET: /*Proc Set action */
  476. break;
  477. case CMD_ACT_GET:
  478. break;
  479. default:
  480. lbs_deb_11d("Invalid action:%d\n", domaininfo->action);
  481. ret = -1;
  482. break;
  483. }
  484. lbs_deb_leave_args(LBS_DEB_11D, "ret %d", ret);
  485. return ret;
  486. }
  487. /**
  488. * @brief This function parses countryinfo from AP and download country info to FW
  489. * @param priv pointer to struct lbs_private
  490. * @return 0; -1
  491. */
  492. int lbs_parse_dnld_countryinfo_11d(struct lbs_private *priv,
  493. struct bss_descriptor * bss)
  494. {
  495. int ret;
  496. lbs_deb_enter(LBS_DEB_11D);
  497. if (priv->enable11d) {
  498. memset(&priv->parsed_region_chan, 0,
  499. sizeof(struct parsed_region_chan_11d));
  500. ret = parse_domain_info_11d(&bss->countryinfo, 0,
  501. &priv->parsed_region_chan);
  502. if (ret == -1) {
  503. lbs_deb_11d("error parsing domain_info from AP\n");
  504. goto done;
  505. }
  506. memset(&priv->domainreg, 0,
  507. sizeof(struct lbs_802_11d_domain_reg));
  508. generate_domain_info_11d(&priv->parsed_region_chan,
  509. &priv->domainreg);
  510. ret = set_domain_info_11d(priv);
  511. if (ret) {
  512. lbs_deb_11d("error setting domain info\n");
  513. goto done;
  514. }
  515. }
  516. ret = 0;
  517. done:
  518. lbs_deb_leave_args(LBS_DEB_11D, "ret %d", ret);
  519. return ret;
  520. }
  521. /**
  522. * @brief This function generates 11D info from user specified regioncode and download to FW
  523. * @param priv pointer to struct lbs_private
  524. * @return 0; -1
  525. */
  526. int lbs_create_dnld_countryinfo_11d(struct lbs_private *priv)
  527. {
  528. int ret;
  529. struct region_channel *region_chan;
  530. u8 j;
  531. lbs_deb_enter(LBS_DEB_11D);
  532. lbs_deb_11d("curbssparams.band %d\n", priv->curbssparams.band);
  533. if (priv->enable11d) {
  534. /* update parsed_region_chan_11; dnld domaininf to FW */
  535. for (j = 0; j < ARRAY_SIZE(priv->region_channel); j++) {
  536. region_chan = &priv->region_channel[j];
  537. lbs_deb_11d("%d region_chan->band %d\n", j,
  538. region_chan->band);
  539. if (!region_chan || !region_chan->valid
  540. || !region_chan->CFP)
  541. continue;
  542. if (region_chan->band != priv->curbssparams.band)
  543. continue;
  544. break;
  545. }
  546. if (j >= ARRAY_SIZE(priv->region_channel)) {
  547. lbs_deb_11d("region_chan not found, band %d\n",
  548. priv->curbssparams.band);
  549. ret = -1;
  550. goto done;
  551. }
  552. memset(&priv->parsed_region_chan, 0,
  553. sizeof(struct parsed_region_chan_11d));
  554. lbs_generate_parsed_region_chan_11d(region_chan,
  555. &priv->
  556. parsed_region_chan);
  557. memset(&priv->domainreg, 0,
  558. sizeof(struct lbs_802_11d_domain_reg));
  559. generate_domain_info_11d(&priv->parsed_region_chan,
  560. &priv->domainreg);
  561. ret = set_domain_info_11d(priv);
  562. if (ret) {
  563. lbs_deb_11d("error setting domain info\n");
  564. goto done;
  565. }
  566. }
  567. ret = 0;
  568. done:
  569. lbs_deb_leave_args(LBS_DEB_11D, "ret %d", ret);
  570. return ret;
  571. }