11d.c 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698
  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; region[i] && i < COUNTRY_CODE_LEN; 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 ieeetypes_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 ieeetypes_countryinfofullset*
  258. countryinfo,
  259. u8 band,
  260. struct parsed_region_chan_11d *
  261. parsed_region_chan)
  262. {
  263. u8 nr_subband, nrchan;
  264. u8 lastchan, firstchan;
  265. u8 region;
  266. u8 curchan = 0;
  267. u8 idx = 0; /*chan index in parsed_region_chan */
  268. u8 j, i;
  269. lbs_deb_enter(LBS_DEB_11D);
  270. /*validation Rules:
  271. 1. valid region Code
  272. 2. First Chan increment
  273. 3. channel range no overlap
  274. 4. channel is valid?
  275. 5. channel is supported by region?
  276. 6. Others
  277. */
  278. lbs_deb_hex(LBS_DEB_11D, "countryinfo", (u8 *) countryinfo, 30);
  279. if ((*(countryinfo->countrycode)) == 0
  280. || (countryinfo->len <= COUNTRY_CODE_LEN)) {
  281. /* No region Info or Wrong region info: treat as No 11D info */
  282. goto done;
  283. }
  284. /*Step1: check region_code */
  285. parsed_region_chan->region = region =
  286. lbs_region_2_code(countryinfo->countrycode);
  287. lbs_deb_11d("regioncode=%x\n", (u8) parsed_region_chan->region);
  288. lbs_deb_hex(LBS_DEB_11D, "countrycode", (char *)countryinfo->countrycode,
  289. COUNTRY_CODE_LEN);
  290. parsed_region_chan->band = band;
  291. memcpy(parsed_region_chan->countrycode, countryinfo->countrycode,
  292. COUNTRY_CODE_LEN);
  293. nr_subband = (countryinfo->len - COUNTRY_CODE_LEN) /
  294. sizeof(struct ieeetypes_subbandset);
  295. for (j = 0, lastchan = 0; j < nr_subband; j++) {
  296. if (countryinfo->subband[j].firstchan <= lastchan) {
  297. /*Step2&3. Check First Chan Num increment and no overlap */
  298. lbs_deb_11d("chan %d>%d, overlap\n",
  299. countryinfo->subband[j].firstchan, lastchan);
  300. continue;
  301. }
  302. firstchan = countryinfo->subband[j].firstchan;
  303. nrchan = countryinfo->subband[j].nrchan;
  304. for (i = 0; idx < MAX_NO_OF_CHAN && i < nrchan; i++) {
  305. /*step4: channel is supported? */
  306. if (!lbs_get_chan_11d(firstchan, i, &curchan)) {
  307. /* Chan is not found in UN table */
  308. lbs_deb_11d("chan is not supported: %d \n", i);
  309. break;
  310. }
  311. lastchan = curchan;
  312. if (lbs_region_chan_supported_11d(region, curchan)) {
  313. /*step5: Check if curchan is supported by mrvl in region */
  314. parsed_region_chan->chanpwr[idx].chan = curchan;
  315. parsed_region_chan->chanpwr[idx].pwr =
  316. countryinfo->subband[j].maxtxpwr;
  317. idx++;
  318. } else {
  319. /*not supported and ignore the chan */
  320. lbs_deb_11d(
  321. "i %d, chan %d unsupported in region %x, band %d\n",
  322. i, curchan, region, band);
  323. }
  324. }
  325. /*Step6: Add other checking if any */
  326. }
  327. parsed_region_chan->nr_chan = idx;
  328. lbs_deb_11d("nrchan=%x\n", parsed_region_chan->nr_chan);
  329. lbs_deb_hex(LBS_DEB_11D, "parsed_region_chan", (u8 *) parsed_region_chan,
  330. 2 + COUNTRY_CODE_LEN + sizeof(struct parsed_region_chan_11d) * idx);
  331. done:
  332. lbs_deb_enter(LBS_DEB_11D);
  333. return 0;
  334. }
  335. /**
  336. * @brief This function calculates the scan type for channels
  337. * @param chan chan number
  338. * @param parsed_region_chan pointer to parsed_region_chan_11d
  339. * @return PASSIVE if chan is unknown; ACTIVE if chan is known
  340. */
  341. u8 lbs_get_scan_type_11d(u8 chan,
  342. struct parsed_region_chan_11d * parsed_region_chan)
  343. {
  344. u8 scan_type = CMD_SCAN_TYPE_PASSIVE;
  345. lbs_deb_enter(LBS_DEB_11D);
  346. if (lbs_channel_known_11d(chan, parsed_region_chan)) {
  347. lbs_deb_11d("found, do active scan\n");
  348. scan_type = CMD_SCAN_TYPE_ACTIVE;
  349. } else {
  350. lbs_deb_11d("not found, do passive scan\n");
  351. }
  352. lbs_deb_leave_args(LBS_DEB_11D, "ret scan_type %d", scan_type);
  353. return scan_type;
  354. }
  355. void lbs_init_11d(struct lbs_private *priv)
  356. {
  357. priv->enable11d = 0;
  358. memset(&(priv->parsed_region_chan), 0,
  359. sizeof(struct parsed_region_chan_11d));
  360. return;
  361. }
  362. /**
  363. * @brief This function sets DOMAIN INFO to FW
  364. * @param priv pointer to struct lbs_private
  365. * @return 0; -1
  366. */
  367. static int set_domain_info_11d(struct lbs_private *priv)
  368. {
  369. int ret;
  370. if (!priv->enable11d) {
  371. lbs_deb_11d("dnld domain Info with 11d disabled\n");
  372. return 0;
  373. }
  374. ret = lbs_prepare_and_send_command(priv, CMD_802_11D_DOMAIN_INFO,
  375. CMD_ACT_SET,
  376. CMD_OPTION_WAITFORRSP, 0, NULL);
  377. if (ret)
  378. lbs_deb_11d("fail to dnld domain info\n");
  379. return ret;
  380. }
  381. /**
  382. * @brief This function setups scan channels
  383. * @param priv pointer to struct lbs_private
  384. * @param band band
  385. * @return 0
  386. */
  387. int lbs_set_universaltable(struct lbs_private *priv, u8 band)
  388. {
  389. u16 size = sizeof(struct chan_freq_power);
  390. u16 i = 0;
  391. memset(priv->universal_channel, 0,
  392. sizeof(priv->universal_channel));
  393. priv->universal_channel[i].nrcfp =
  394. sizeof(channel_freq_power_UN_BG) / size;
  395. lbs_deb_11d("BG-band nrcfp %d\n",
  396. priv->universal_channel[i].nrcfp);
  397. priv->universal_channel[i].CFP = channel_freq_power_UN_BG;
  398. priv->universal_channel[i].valid = 1;
  399. priv->universal_channel[i].region = UNIVERSAL_REGION_CODE;
  400. priv->universal_channel[i].band = band;
  401. i++;
  402. return 0;
  403. }
  404. /**
  405. * @brief This function implements command CMD_802_11D_DOMAIN_INFO
  406. * @param priv pointer to struct lbs_private
  407. * @param cmd pointer to cmd buffer
  408. * @param cmdno cmd ID
  409. * @param cmdOption cmd action
  410. * @return 0
  411. */
  412. int lbs_cmd_802_11d_domain_info(struct lbs_private *priv,
  413. struct cmd_ds_command *cmd, u16 cmdno,
  414. u16 cmdoption)
  415. {
  416. struct cmd_ds_802_11d_domain_info *pdomaininfo =
  417. &cmd->params.domaininfo;
  418. struct mrvlietypes_domainparamset *domain = &pdomaininfo->domain;
  419. u8 nr_subband = priv->domainreg.nr_subband;
  420. lbs_deb_enter(LBS_DEB_11D);
  421. lbs_deb_11d("nr_subband=%x\n", nr_subband);
  422. cmd->command = cpu_to_le16(cmdno);
  423. pdomaininfo->action = cpu_to_le16(cmdoption);
  424. if (cmdoption == CMD_ACT_GET) {
  425. cmd->size =
  426. cpu_to_le16(sizeof(pdomaininfo->action) + S_DS_GEN);
  427. lbs_deb_hex(LBS_DEB_11D, "802_11D_DOMAIN_INFO", (u8 *) cmd,
  428. le16_to_cpu(cmd->size));
  429. goto done;
  430. }
  431. domain->header.type = cpu_to_le16(TLV_TYPE_DOMAIN);
  432. memcpy(domain->countrycode, priv->domainreg.countrycode,
  433. sizeof(domain->countrycode));
  434. domain->header.len =
  435. cpu_to_le16(nr_subband * sizeof(struct ieeetypes_subbandset) +
  436. sizeof(domain->countrycode));
  437. if (nr_subband) {
  438. memcpy(domain->subband, priv->domainreg.subband,
  439. nr_subband * sizeof(struct ieeetypes_subbandset));
  440. cmd->size = cpu_to_le16(sizeof(pdomaininfo->action) +
  441. le16_to_cpu(domain->header.len) +
  442. sizeof(struct mrvlietypesheader) +
  443. S_DS_GEN);
  444. } else {
  445. cmd->size =
  446. cpu_to_le16(sizeof(pdomaininfo->action) + S_DS_GEN);
  447. }
  448. lbs_deb_hex(LBS_DEB_11D, "802_11D_DOMAIN_INFO", (u8 *) cmd, le16_to_cpu(cmd->size));
  449. done:
  450. lbs_deb_enter(LBS_DEB_11D);
  451. return 0;
  452. }
  453. /**
  454. * @brief This function parses countryinfo from AP and download country info to FW
  455. * @param priv pointer to struct lbs_private
  456. * @param resp pointer to command response buffer
  457. * @return 0; -1
  458. */
  459. int lbs_ret_802_11d_domain_info(struct cmd_ds_command *resp)
  460. {
  461. struct cmd_ds_802_11d_domain_info *domaininfo = &resp->params.domaininforesp;
  462. struct mrvlietypes_domainparamset *domain = &domaininfo->domain;
  463. u16 action = le16_to_cpu(domaininfo->action);
  464. s16 ret = 0;
  465. u8 nr_subband = 0;
  466. lbs_deb_enter(LBS_DEB_11D);
  467. lbs_deb_hex(LBS_DEB_11D, "domain info resp", (u8 *) resp,
  468. (int)le16_to_cpu(resp->size));
  469. nr_subband = (le16_to_cpu(domain->header.len) - COUNTRY_CODE_LEN) /
  470. sizeof(struct ieeetypes_subbandset);
  471. lbs_deb_11d("domain info resp: nr_subband %d\n", nr_subband);
  472. if (nr_subband > MRVDRV_MAX_SUBBAND_802_11D) {
  473. lbs_deb_11d("Invalid Numrer of Subband returned!!\n");
  474. return -1;
  475. }
  476. switch (action) {
  477. case CMD_ACT_SET: /*Proc Set action */
  478. break;
  479. case CMD_ACT_GET:
  480. break;
  481. default:
  482. lbs_deb_11d("Invalid action:%d\n", domaininfo->action);
  483. ret = -1;
  484. break;
  485. }
  486. lbs_deb_leave_args(LBS_DEB_11D, "ret %d", ret);
  487. return ret;
  488. }
  489. /**
  490. * @brief This function parses countryinfo from AP and download country info to FW
  491. * @param priv pointer to struct lbs_private
  492. * @return 0; -1
  493. */
  494. int lbs_parse_dnld_countryinfo_11d(struct lbs_private *priv,
  495. struct bss_descriptor * bss)
  496. {
  497. int ret;
  498. lbs_deb_enter(LBS_DEB_11D);
  499. if (priv->enable11d) {
  500. memset(&priv->parsed_region_chan, 0,
  501. sizeof(struct parsed_region_chan_11d));
  502. ret = parse_domain_info_11d(&bss->countryinfo, 0,
  503. &priv->parsed_region_chan);
  504. if (ret == -1) {
  505. lbs_deb_11d("error parsing domain_info from AP\n");
  506. goto done;
  507. }
  508. memset(&priv->domainreg, 0,
  509. sizeof(struct lbs_802_11d_domain_reg));
  510. generate_domain_info_11d(&priv->parsed_region_chan,
  511. &priv->domainreg);
  512. ret = set_domain_info_11d(priv);
  513. if (ret) {
  514. lbs_deb_11d("error setting domain info\n");
  515. goto done;
  516. }
  517. }
  518. ret = 0;
  519. done:
  520. lbs_deb_leave_args(LBS_DEB_11D, "ret %d", ret);
  521. return ret;
  522. }
  523. /**
  524. * @brief This function generates 11D info from user specified regioncode and download to FW
  525. * @param priv pointer to struct lbs_private
  526. * @return 0; -1
  527. */
  528. int lbs_create_dnld_countryinfo_11d(struct lbs_private *priv)
  529. {
  530. int ret;
  531. struct region_channel *region_chan;
  532. u8 j;
  533. lbs_deb_enter(LBS_DEB_11D);
  534. lbs_deb_11d("curbssparams.band %d\n", priv->curbssparams.band);
  535. if (priv->enable11d) {
  536. /* update parsed_region_chan_11; dnld domaininf to FW */
  537. for (j = 0; j < ARRAY_SIZE(priv->region_channel); j++) {
  538. region_chan = &priv->region_channel[j];
  539. lbs_deb_11d("%d region_chan->band %d\n", j,
  540. region_chan->band);
  541. if (!region_chan || !region_chan->valid
  542. || !region_chan->CFP)
  543. continue;
  544. if (region_chan->band != priv->curbssparams.band)
  545. continue;
  546. break;
  547. }
  548. if (j >= ARRAY_SIZE(priv->region_channel)) {
  549. lbs_deb_11d("region_chan not found, band %d\n",
  550. priv->curbssparams.band);
  551. ret = -1;
  552. goto done;
  553. }
  554. memset(&priv->parsed_region_chan, 0,
  555. sizeof(struct parsed_region_chan_11d));
  556. lbs_generate_parsed_region_chan_11d(region_chan,
  557. &priv->
  558. parsed_region_chan);
  559. memset(&priv->domainreg, 0,
  560. sizeof(struct lbs_802_11d_domain_reg));
  561. generate_domain_info_11d(&priv->parsed_region_chan,
  562. &priv->domainreg);
  563. ret = set_domain_info_11d(priv);
  564. if (ret) {
  565. lbs_deb_11d("error setting domain info\n");
  566. goto done;
  567. }
  568. }
  569. ret = 0;
  570. done:
  571. lbs_deb_leave_args(LBS_DEB_11D, "ret %d", ret);
  572. return ret;
  573. }