init.c 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748
  1. /*
  2. * This file is part of wl1271
  3. *
  4. * Copyright (C) 2009 Nokia Corporation
  5. *
  6. * Contact: Luciano Coelho <luciano.coelho@nokia.com>
  7. *
  8. * This program is free software; you can redistribute it and/or
  9. * modify it under the terms of the GNU General Public License
  10. * version 2 as published by the Free Software Foundation.
  11. *
  12. * This program is distributed in the hope that it will be useful, but
  13. * WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  15. * General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU General Public License
  18. * along with this program; if not, write to the Free Software
  19. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
  20. * 02110-1301 USA
  21. *
  22. */
  23. #include <linux/kernel.h>
  24. #include <linux/module.h>
  25. #include <linux/slab.h>
  26. #include "init.h"
  27. #include "wl12xx_80211.h"
  28. #include "acx.h"
  29. #include "cmd.h"
  30. #include "reg.h"
  31. #include "tx.h"
  32. #include "io.h"
  33. int wl1271_sta_init_templates_config(struct wl1271 *wl)
  34. {
  35. int ret, i;
  36. /* send empty templates for fw memory reservation */
  37. ret = wl1271_cmd_template_set(wl, CMD_TEMPL_CFG_PROBE_REQ_2_4, NULL,
  38. WL1271_CMD_TEMPL_MAX_SIZE,
  39. 0, WL1271_RATE_AUTOMATIC);
  40. if (ret < 0)
  41. return ret;
  42. ret = wl1271_cmd_template_set(wl, CMD_TEMPL_CFG_PROBE_REQ_5,
  43. NULL, WL1271_CMD_TEMPL_MAX_SIZE, 0,
  44. WL1271_RATE_AUTOMATIC);
  45. if (ret < 0)
  46. return ret;
  47. ret = wl1271_cmd_template_set(wl, CMD_TEMPL_NULL_DATA, NULL,
  48. sizeof(struct wl12xx_null_data_template),
  49. 0, WL1271_RATE_AUTOMATIC);
  50. if (ret < 0)
  51. return ret;
  52. ret = wl1271_cmd_template_set(wl, CMD_TEMPL_PS_POLL, NULL,
  53. sizeof(struct wl12xx_ps_poll_template),
  54. 0, WL1271_RATE_AUTOMATIC);
  55. if (ret < 0)
  56. return ret;
  57. ret = wl1271_cmd_template_set(wl, CMD_TEMPL_QOS_NULL_DATA, NULL,
  58. sizeof
  59. (struct wl12xx_qos_null_data_template),
  60. 0, WL1271_RATE_AUTOMATIC);
  61. if (ret < 0)
  62. return ret;
  63. ret = wl1271_cmd_template_set(wl, CMD_TEMPL_PROBE_RESPONSE, NULL,
  64. sizeof
  65. (struct wl12xx_probe_resp_template),
  66. 0, WL1271_RATE_AUTOMATIC);
  67. if (ret < 0)
  68. return ret;
  69. ret = wl1271_cmd_template_set(wl, CMD_TEMPL_BEACON, NULL,
  70. sizeof
  71. (struct wl12xx_beacon_template),
  72. 0, WL1271_RATE_AUTOMATIC);
  73. if (ret < 0)
  74. return ret;
  75. ret = wl1271_cmd_template_set(wl, CMD_TEMPL_ARP_RSP, NULL,
  76. sizeof
  77. (struct wl12xx_arp_rsp_template),
  78. 0, WL1271_RATE_AUTOMATIC);
  79. if (ret < 0)
  80. return ret;
  81. for (i = 0; i < CMD_TEMPL_KLV_IDX_MAX; i++) {
  82. ret = wl1271_cmd_template_set(wl, CMD_TEMPL_KLV, NULL,
  83. WL1271_CMD_TEMPL_MAX_SIZE, i,
  84. WL1271_RATE_AUTOMATIC);
  85. if (ret < 0)
  86. return ret;
  87. }
  88. return 0;
  89. }
  90. static int wl1271_ap_init_deauth_template(struct wl1271 *wl)
  91. {
  92. struct wl12xx_disconn_template *tmpl;
  93. int ret;
  94. tmpl = kzalloc(sizeof(*tmpl), GFP_KERNEL);
  95. if (!tmpl) {
  96. ret = -ENOMEM;
  97. goto out;
  98. }
  99. tmpl->header.frame_ctl = cpu_to_le16(IEEE80211_FTYPE_MGMT |
  100. IEEE80211_STYPE_DEAUTH);
  101. ret = wl1271_cmd_template_set(wl, CMD_TEMPL_DEAUTH_AP,
  102. tmpl, sizeof(*tmpl), 0,
  103. wl1271_tx_min_rate_get(wl));
  104. out:
  105. kfree(tmpl);
  106. return ret;
  107. }
  108. static int wl1271_ap_init_null_template(struct wl1271 *wl)
  109. {
  110. struct ieee80211_hdr_3addr *nullfunc;
  111. int ret;
  112. nullfunc = kzalloc(sizeof(*nullfunc), GFP_KERNEL);
  113. if (!nullfunc) {
  114. ret = -ENOMEM;
  115. goto out;
  116. }
  117. nullfunc->frame_control = cpu_to_le16(IEEE80211_FTYPE_DATA |
  118. IEEE80211_STYPE_NULLFUNC |
  119. IEEE80211_FCTL_FROMDS);
  120. /* nullfunc->addr1 is filled by FW */
  121. memcpy(nullfunc->addr2, wl->mac_addr, ETH_ALEN);
  122. memcpy(nullfunc->addr3, wl->mac_addr, ETH_ALEN);
  123. ret = wl1271_cmd_template_set(wl, CMD_TEMPL_NULL_DATA, nullfunc,
  124. sizeof(*nullfunc), 0,
  125. wl1271_tx_min_rate_get(wl));
  126. out:
  127. kfree(nullfunc);
  128. return ret;
  129. }
  130. static int wl1271_ap_init_qos_null_template(struct wl1271 *wl)
  131. {
  132. struct ieee80211_qos_hdr *qosnull;
  133. int ret;
  134. qosnull = kzalloc(sizeof(*qosnull), GFP_KERNEL);
  135. if (!qosnull) {
  136. ret = -ENOMEM;
  137. goto out;
  138. }
  139. qosnull->frame_control = cpu_to_le16(IEEE80211_FTYPE_DATA |
  140. IEEE80211_STYPE_QOS_NULLFUNC |
  141. IEEE80211_FCTL_FROMDS);
  142. /* qosnull->addr1 is filled by FW */
  143. memcpy(qosnull->addr2, wl->mac_addr, ETH_ALEN);
  144. memcpy(qosnull->addr3, wl->mac_addr, ETH_ALEN);
  145. ret = wl1271_cmd_template_set(wl, CMD_TEMPL_QOS_NULL_DATA, qosnull,
  146. sizeof(*qosnull), 0,
  147. wl1271_tx_min_rate_get(wl));
  148. out:
  149. kfree(qosnull);
  150. return ret;
  151. }
  152. static int wl1271_ap_init_templates_config(struct wl1271 *wl)
  153. {
  154. int ret;
  155. /*
  156. * Put very large empty placeholders for all templates. These
  157. * reserve memory for later.
  158. */
  159. ret = wl1271_cmd_template_set(wl, CMD_TEMPL_AP_PROBE_RESPONSE, NULL,
  160. sizeof
  161. (struct wl12xx_probe_resp_template),
  162. 0, WL1271_RATE_AUTOMATIC);
  163. if (ret < 0)
  164. return ret;
  165. ret = wl1271_cmd_template_set(wl, CMD_TEMPL_AP_BEACON, NULL,
  166. sizeof
  167. (struct wl12xx_beacon_template),
  168. 0, WL1271_RATE_AUTOMATIC);
  169. if (ret < 0)
  170. return ret;
  171. ret = wl1271_cmd_template_set(wl, CMD_TEMPL_DEAUTH_AP, NULL,
  172. sizeof
  173. (struct wl12xx_disconn_template),
  174. 0, WL1271_RATE_AUTOMATIC);
  175. if (ret < 0)
  176. return ret;
  177. ret = wl1271_cmd_template_set(wl, CMD_TEMPL_NULL_DATA, NULL,
  178. sizeof(struct wl12xx_null_data_template),
  179. 0, WL1271_RATE_AUTOMATIC);
  180. if (ret < 0)
  181. return ret;
  182. ret = wl1271_cmd_template_set(wl, CMD_TEMPL_QOS_NULL_DATA, NULL,
  183. sizeof
  184. (struct wl12xx_qos_null_data_template),
  185. 0, WL1271_RATE_AUTOMATIC);
  186. if (ret < 0)
  187. return ret;
  188. return 0;
  189. }
  190. static int wl1271_init_rx_config(struct wl1271 *wl, u32 config, u32 filter)
  191. {
  192. int ret;
  193. ret = wl1271_acx_rx_msdu_life_time(wl);
  194. if (ret < 0)
  195. return ret;
  196. ret = wl1271_acx_rx_config(wl, config, filter);
  197. if (ret < 0)
  198. return ret;
  199. return 0;
  200. }
  201. int wl1271_init_phy_config(struct wl1271 *wl)
  202. {
  203. int ret;
  204. ret = wl1271_acx_pd_threshold(wl);
  205. if (ret < 0)
  206. return ret;
  207. ret = wl1271_acx_slot(wl, DEFAULT_SLOT_TIME);
  208. if (ret < 0)
  209. return ret;
  210. ret = wl1271_acx_service_period_timeout(wl);
  211. if (ret < 0)
  212. return ret;
  213. ret = wl1271_acx_rts_threshold(wl, wl->hw->wiphy->rts_threshold);
  214. if (ret < 0)
  215. return ret;
  216. return 0;
  217. }
  218. static int wl1271_init_beacon_filter(struct wl1271 *wl)
  219. {
  220. int ret;
  221. /* disable beacon filtering at this stage */
  222. ret = wl1271_acx_beacon_filter_opt(wl, false);
  223. if (ret < 0)
  224. return ret;
  225. ret = wl1271_acx_beacon_filter_table(wl);
  226. if (ret < 0)
  227. return ret;
  228. return 0;
  229. }
  230. int wl1271_init_pta(struct wl1271 *wl)
  231. {
  232. int ret;
  233. if (wl->bss_type == BSS_TYPE_AP_BSS)
  234. ret = wl1271_acx_ap_sg_cfg(wl);
  235. else
  236. ret = wl1271_acx_sta_sg_cfg(wl);
  237. if (ret < 0)
  238. return ret;
  239. ret = wl1271_acx_sg_enable(wl, wl->sg_enabled);
  240. if (ret < 0)
  241. return ret;
  242. return 0;
  243. }
  244. int wl1271_init_energy_detection(struct wl1271 *wl)
  245. {
  246. int ret;
  247. ret = wl1271_acx_cca_threshold(wl);
  248. if (ret < 0)
  249. return ret;
  250. return 0;
  251. }
  252. static int wl1271_init_beacon_broadcast(struct wl1271 *wl)
  253. {
  254. int ret;
  255. ret = wl1271_acx_bcn_dtim_options(wl);
  256. if (ret < 0)
  257. return ret;
  258. return 0;
  259. }
  260. static int wl12xx_init_fwlog(struct wl1271 *wl)
  261. {
  262. int ret;
  263. if (wl->quirks & WL12XX_QUIRK_FWLOG_NOT_IMPLEMENTED)
  264. return 0;
  265. ret = wl12xx_cmd_config_fwlog(wl);
  266. if (ret < 0)
  267. return ret;
  268. return 0;
  269. }
  270. static int wl1271_sta_hw_init(struct wl1271 *wl)
  271. {
  272. int ret;
  273. if (wl->chip.id != CHIP_ID_1283_PG20) {
  274. ret = wl1271_cmd_ext_radio_parms(wl);
  275. if (ret < 0)
  276. return ret;
  277. }
  278. /* PS config */
  279. ret = wl1271_acx_config_ps(wl);
  280. if (ret < 0)
  281. return ret;
  282. ret = wl1271_sta_init_templates_config(wl);
  283. if (ret < 0)
  284. return ret;
  285. ret = wl1271_acx_group_address_tbl(wl, true, NULL, 0);
  286. if (ret < 0)
  287. return ret;
  288. /* Initialize connection monitoring thresholds */
  289. ret = wl1271_acx_conn_monit_params(wl, false);
  290. if (ret < 0)
  291. return ret;
  292. /* Beacon filtering */
  293. ret = wl1271_init_beacon_filter(wl);
  294. if (ret < 0)
  295. return ret;
  296. /* FM WLAN coexistence */
  297. ret = wl1271_acx_fm_coex(wl);
  298. if (ret < 0)
  299. return ret;
  300. /* Beacons and broadcast settings */
  301. ret = wl1271_init_beacon_broadcast(wl);
  302. if (ret < 0)
  303. return ret;
  304. /* Configure for ELP power saving */
  305. ret = wl1271_acx_sleep_auth(wl, WL1271_PSM_ELP);
  306. if (ret < 0)
  307. return ret;
  308. /* Configure rssi/snr averaging weights */
  309. ret = wl1271_acx_rssi_snr_avg_weights(wl);
  310. if (ret < 0)
  311. return ret;
  312. ret = wl1271_acx_sta_rate_policies(wl);
  313. if (ret < 0)
  314. return ret;
  315. ret = wl1271_acx_sta_mem_cfg(wl);
  316. if (ret < 0)
  317. return ret;
  318. /* Configure the FW logger */
  319. ret = wl12xx_init_fwlog(wl);
  320. if (ret < 0)
  321. return ret;
  322. return 0;
  323. }
  324. static int wl1271_sta_hw_init_post_mem(struct wl1271 *wl)
  325. {
  326. int ret, i;
  327. ret = wl1271_cmd_set_sta_default_wep_key(wl, wl->default_key);
  328. if (ret < 0) {
  329. wl1271_warning("couldn't set default key");
  330. return ret;
  331. }
  332. /* disable all keep-alive templates */
  333. for (i = 0; i < CMD_TEMPL_KLV_IDX_MAX; i++) {
  334. ret = wl1271_acx_keep_alive_config(wl, i,
  335. ACX_KEEP_ALIVE_TPL_INVALID);
  336. if (ret < 0)
  337. return ret;
  338. }
  339. /* disable the keep-alive feature */
  340. ret = wl1271_acx_keep_alive_mode(wl, false);
  341. if (ret < 0)
  342. return ret;
  343. return 0;
  344. }
  345. static int wl1271_ap_hw_init(struct wl1271 *wl)
  346. {
  347. int ret;
  348. ret = wl1271_ap_init_templates_config(wl);
  349. if (ret < 0)
  350. return ret;
  351. /* Configure for power always on */
  352. ret = wl1271_acx_sleep_auth(wl, WL1271_PSM_CAM);
  353. if (ret < 0)
  354. return ret;
  355. ret = wl1271_init_ap_rates(wl);
  356. if (ret < 0)
  357. return ret;
  358. ret = wl1271_acx_ap_max_tx_retry(wl);
  359. if (ret < 0)
  360. return ret;
  361. ret = wl1271_acx_ap_mem_cfg(wl);
  362. if (ret < 0)
  363. return ret;
  364. /* initialize Tx power */
  365. ret = wl1271_acx_tx_power(wl, wl->power_level);
  366. if (ret < 0)
  367. return ret;
  368. return 0;
  369. }
  370. int wl1271_ap_init_templates(struct wl1271 *wl)
  371. {
  372. int ret;
  373. ret = wl1271_ap_init_deauth_template(wl);
  374. if (ret < 0)
  375. return ret;
  376. ret = wl1271_ap_init_null_template(wl);
  377. if (ret < 0)
  378. return ret;
  379. ret = wl1271_ap_init_qos_null_template(wl);
  380. if (ret < 0)
  381. return ret;
  382. /*
  383. * when operating as AP we want to receive external beacons for
  384. * configuring ERP protection.
  385. */
  386. ret = wl1271_acx_set_ap_beacon_filter(wl, false);
  387. if (ret < 0)
  388. return ret;
  389. return 0;
  390. }
  391. static int wl1271_ap_hw_init_post_mem(struct wl1271 *wl)
  392. {
  393. return wl1271_ap_init_templates(wl);
  394. }
  395. int wl1271_init_ap_rates(struct wl1271 *wl)
  396. {
  397. int i, ret;
  398. struct conf_tx_rate_class rc;
  399. u32 supported_rates;
  400. wl1271_debug(DEBUG_AP, "AP basic rate set: 0x%x", wl->basic_rate_set);
  401. if (wl->basic_rate_set == 0)
  402. return -EINVAL;
  403. rc.enabled_rates = wl->basic_rate_set;
  404. rc.long_retry_limit = 10;
  405. rc.short_retry_limit = 10;
  406. rc.aflags = 0;
  407. ret = wl1271_acx_ap_rate_policy(wl, &rc, ACX_TX_AP_MODE_MGMT_RATE);
  408. if (ret < 0)
  409. return ret;
  410. /* use the min basic rate for AP broadcast/multicast */
  411. rc.enabled_rates = wl1271_tx_min_rate_get(wl);
  412. rc.short_retry_limit = 10;
  413. rc.long_retry_limit = 10;
  414. rc.aflags = 0;
  415. ret = wl1271_acx_ap_rate_policy(wl, &rc, ACX_TX_AP_MODE_BCST_RATE);
  416. if (ret < 0)
  417. return ret;
  418. /*
  419. * If the basic rates contain OFDM rates, use OFDM only
  420. * rates for unicast TX as well. Else use all supported rates.
  421. */
  422. if ((wl->basic_rate_set & CONF_TX_OFDM_RATES))
  423. supported_rates = CONF_TX_OFDM_RATES;
  424. else
  425. supported_rates = CONF_TX_AP_ENABLED_RATES;
  426. /* configure unicast TX rate classes */
  427. for (i = 0; i < wl->conf.tx.ac_conf_count; i++) {
  428. rc.enabled_rates = supported_rates;
  429. rc.short_retry_limit = 10;
  430. rc.long_retry_limit = 10;
  431. rc.aflags = 0;
  432. ret = wl1271_acx_ap_rate_policy(wl, &rc, i);
  433. if (ret < 0)
  434. return ret;
  435. }
  436. return 0;
  437. }
  438. static void wl1271_check_ba_support(struct wl1271 *wl)
  439. {
  440. /* validate FW cose ver x.x.x.50-60.x */
  441. if ((wl->chip.fw_ver[3] >= WL12XX_BA_SUPPORT_FW_COST_VER2_START) &&
  442. (wl->chip.fw_ver[3] < WL12XX_BA_SUPPORT_FW_COST_VER2_END)) {
  443. wl->ba_support = true;
  444. return;
  445. }
  446. wl->ba_support = false;
  447. }
  448. static int wl1271_set_ba_policies(struct wl1271 *wl)
  449. {
  450. u8 tid_index;
  451. int ret = 0;
  452. /* Reset the BA RX indicators */
  453. wl->ba_rx_bitmap = 0;
  454. wl->ba_allowed = true;
  455. /* validate that FW support BA */
  456. wl1271_check_ba_support(wl);
  457. if (wl->ba_support)
  458. /* 802.11n initiator BA session setting */
  459. for (tid_index = 0; tid_index < CONF_TX_MAX_TID_COUNT;
  460. ++tid_index) {
  461. ret = wl1271_acx_set_ba_session(wl, WLAN_BACK_INITIATOR,
  462. tid_index, true);
  463. if (ret < 0)
  464. break;
  465. }
  466. return ret;
  467. }
  468. int wl1271_chip_specific_init(struct wl1271 *wl)
  469. {
  470. int ret = 0;
  471. if (wl->chip.id == CHIP_ID_1283_PG20) {
  472. u32 host_cfg_bitmap = HOST_IF_CFG_RX_FIFO_ENABLE;
  473. if (wl->quirks & WL12XX_QUIRK_BLOCKSIZE_ALIGNMENT)
  474. /* Enable SDIO padding */
  475. host_cfg_bitmap |= HOST_IF_CFG_TX_PAD_TO_SDIO_BLK;
  476. /* Must be before wl1271_acx_init_mem_config() */
  477. ret = wl1271_acx_host_if_cfg_bitmap(wl, host_cfg_bitmap);
  478. if (ret < 0)
  479. goto out;
  480. }
  481. out:
  482. return ret;
  483. }
  484. int wl1271_hw_init(struct wl1271 *wl)
  485. {
  486. struct conf_tx_ac_category *conf_ac;
  487. struct conf_tx_tid *conf_tid;
  488. int ret, i;
  489. bool is_ap = (wl->bss_type == BSS_TYPE_AP_BSS);
  490. if (wl->chip.id == CHIP_ID_1283_PG20)
  491. ret = wl128x_cmd_general_parms(wl);
  492. else
  493. ret = wl1271_cmd_general_parms(wl);
  494. if (ret < 0)
  495. return ret;
  496. if (wl->chip.id == CHIP_ID_1283_PG20)
  497. ret = wl128x_cmd_radio_parms(wl);
  498. else
  499. ret = wl1271_cmd_radio_parms(wl);
  500. if (ret < 0)
  501. return ret;
  502. /* Chip-specific init */
  503. ret = wl1271_chip_specific_init(wl);
  504. if (ret < 0)
  505. return ret;
  506. /* Mode specific init */
  507. if (is_ap)
  508. ret = wl1271_ap_hw_init(wl);
  509. else
  510. ret = wl1271_sta_hw_init(wl);
  511. if (ret < 0)
  512. return ret;
  513. /* Bluetooth WLAN coexistence */
  514. ret = wl1271_init_pta(wl);
  515. if (ret < 0)
  516. return ret;
  517. /* Default memory configuration */
  518. ret = wl1271_acx_init_mem_config(wl);
  519. if (ret < 0)
  520. return ret;
  521. /* RX config */
  522. ret = wl1271_init_rx_config(wl,
  523. RX_CFG_PROMISCUOUS | RX_CFG_TSF,
  524. RX_FILTER_OPTION_DEF);
  525. /* RX_CONFIG_OPTION_ANY_DST_ANY_BSS,
  526. RX_FILTER_OPTION_FILTER_ALL); */
  527. if (ret < 0)
  528. goto out_free_memmap;
  529. /* PHY layer config */
  530. ret = wl1271_init_phy_config(wl);
  531. if (ret < 0)
  532. goto out_free_memmap;
  533. ret = wl1271_acx_dco_itrim_params(wl);
  534. if (ret < 0)
  535. goto out_free_memmap;
  536. /* Configure TX patch complete interrupt behavior */
  537. ret = wl1271_acx_tx_config_options(wl);
  538. if (ret < 0)
  539. goto out_free_memmap;
  540. /* RX complete interrupt pacing */
  541. ret = wl1271_acx_init_rx_interrupt(wl);
  542. if (ret < 0)
  543. goto out_free_memmap;
  544. /* Energy detection */
  545. ret = wl1271_init_energy_detection(wl);
  546. if (ret < 0)
  547. goto out_free_memmap;
  548. /* Default fragmentation threshold */
  549. ret = wl1271_acx_frag_threshold(wl, wl->hw->wiphy->frag_threshold);
  550. if (ret < 0)
  551. goto out_free_memmap;
  552. /* Default TID/AC configuration */
  553. BUG_ON(wl->conf.tx.tid_conf_count != wl->conf.tx.ac_conf_count);
  554. for (i = 0; i < wl->conf.tx.tid_conf_count; i++) {
  555. conf_ac = &wl->conf.tx.ac_conf[i];
  556. ret = wl1271_acx_ac_cfg(wl, conf_ac->ac, conf_ac->cw_min,
  557. conf_ac->cw_max, conf_ac->aifsn,
  558. conf_ac->tx_op_limit);
  559. if (ret < 0)
  560. goto out_free_memmap;
  561. conf_tid = &wl->conf.tx.tid_conf[i];
  562. ret = wl1271_acx_tid_cfg(wl, conf_tid->queue_id,
  563. conf_tid->channel_type,
  564. conf_tid->tsid,
  565. conf_tid->ps_scheme,
  566. conf_tid->ack_policy,
  567. conf_tid->apsd_conf[0],
  568. conf_tid->apsd_conf[1]);
  569. if (ret < 0)
  570. goto out_free_memmap;
  571. }
  572. /* Enable data path */
  573. ret = wl1271_cmd_data_path(wl, 1);
  574. if (ret < 0)
  575. goto out_free_memmap;
  576. /* Configure HW encryption */
  577. ret = wl1271_acx_feature_cfg(wl);
  578. if (ret < 0)
  579. goto out_free_memmap;
  580. /* configure PM */
  581. ret = wl1271_acx_pm_config(wl);
  582. if (ret < 0)
  583. goto out_free_memmap;
  584. /* Mode specific init - post mem init */
  585. if (is_ap)
  586. ret = wl1271_ap_hw_init_post_mem(wl);
  587. else
  588. ret = wl1271_sta_hw_init_post_mem(wl);
  589. if (ret < 0)
  590. goto out_free_memmap;
  591. /* Configure initiator BA sessions policies */
  592. ret = wl1271_set_ba_policies(wl);
  593. if (ret < 0)
  594. goto out_free_memmap;
  595. return 0;
  596. out_free_memmap:
  597. kfree(wl->target_mem_map);
  598. wl->target_mem_map = NULL;
  599. return ret;
  600. }