11d.c 18 KB

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