init.c 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717
  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_DFLT_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_DFLT_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. WL1271_CMD_TEMPL_DFLT_SIZE,
  65. 0, WL1271_RATE_AUTOMATIC);
  66. if (ret < 0)
  67. return ret;
  68. ret = wl1271_cmd_template_set(wl, CMD_TEMPL_BEACON, NULL,
  69. WL1271_CMD_TEMPL_DFLT_SIZE,
  70. 0, WL1271_RATE_AUTOMATIC);
  71. if (ret < 0)
  72. return ret;
  73. ret = wl1271_cmd_template_set(wl, CMD_TEMPL_ARP_RSP, NULL,
  74. sizeof
  75. (struct wl12xx_arp_rsp_template),
  76. 0, WL1271_RATE_AUTOMATIC);
  77. if (ret < 0)
  78. return ret;
  79. for (i = 0; i < CMD_TEMPL_KLV_IDX_MAX; i++) {
  80. ret = wl1271_cmd_template_set(wl, CMD_TEMPL_KLV, NULL,
  81. WL1271_CMD_TEMPL_DFLT_SIZE, i,
  82. WL1271_RATE_AUTOMATIC);
  83. if (ret < 0)
  84. return ret;
  85. }
  86. return 0;
  87. }
  88. static int wl1271_ap_init_deauth_template(struct wl1271 *wl)
  89. {
  90. struct wl12xx_disconn_template *tmpl;
  91. int ret;
  92. tmpl = kzalloc(sizeof(*tmpl), GFP_KERNEL);
  93. if (!tmpl) {
  94. ret = -ENOMEM;
  95. goto out;
  96. }
  97. tmpl->header.frame_ctl = cpu_to_le16(IEEE80211_FTYPE_MGMT |
  98. IEEE80211_STYPE_DEAUTH);
  99. ret = wl1271_cmd_template_set(wl, CMD_TEMPL_DEAUTH_AP,
  100. tmpl, sizeof(*tmpl), 0,
  101. wl1271_tx_min_rate_get(wl));
  102. out:
  103. kfree(tmpl);
  104. return ret;
  105. }
  106. static int wl1271_ap_init_null_template(struct wl1271 *wl)
  107. {
  108. struct ieee80211_hdr_3addr *nullfunc;
  109. int ret;
  110. nullfunc = kzalloc(sizeof(*nullfunc), GFP_KERNEL);
  111. if (!nullfunc) {
  112. ret = -ENOMEM;
  113. goto out;
  114. }
  115. nullfunc->frame_control = cpu_to_le16(IEEE80211_FTYPE_DATA |
  116. IEEE80211_STYPE_NULLFUNC |
  117. IEEE80211_FCTL_FROMDS);
  118. /* nullfunc->addr1 is filled by FW */
  119. memcpy(nullfunc->addr2, wl->mac_addr, ETH_ALEN);
  120. memcpy(nullfunc->addr3, wl->mac_addr, ETH_ALEN);
  121. ret = wl1271_cmd_template_set(wl, CMD_TEMPL_NULL_DATA, nullfunc,
  122. sizeof(*nullfunc), 0,
  123. wl1271_tx_min_rate_get(wl));
  124. out:
  125. kfree(nullfunc);
  126. return ret;
  127. }
  128. static int wl1271_ap_init_qos_null_template(struct wl1271 *wl)
  129. {
  130. struct ieee80211_qos_hdr *qosnull;
  131. int ret;
  132. qosnull = kzalloc(sizeof(*qosnull), GFP_KERNEL);
  133. if (!qosnull) {
  134. ret = -ENOMEM;
  135. goto out;
  136. }
  137. qosnull->frame_control = cpu_to_le16(IEEE80211_FTYPE_DATA |
  138. IEEE80211_STYPE_QOS_NULLFUNC |
  139. IEEE80211_FCTL_FROMDS);
  140. /* qosnull->addr1 is filled by FW */
  141. memcpy(qosnull->addr2, wl->mac_addr, ETH_ALEN);
  142. memcpy(qosnull->addr3, wl->mac_addr, ETH_ALEN);
  143. ret = wl1271_cmd_template_set(wl, CMD_TEMPL_QOS_NULL_DATA, qosnull,
  144. sizeof(*qosnull), 0,
  145. wl1271_tx_min_rate_get(wl));
  146. out:
  147. kfree(qosnull);
  148. return ret;
  149. }
  150. static int wl1271_ap_init_templates_config(struct wl1271 *wl)
  151. {
  152. int ret;
  153. /*
  154. * Put very large empty placeholders for all templates. These
  155. * reserve memory for later.
  156. */
  157. ret = wl1271_cmd_template_set(wl, CMD_TEMPL_AP_PROBE_RESPONSE, NULL,
  158. WL1271_CMD_TEMPL_MAX_SIZE,
  159. 0, WL1271_RATE_AUTOMATIC);
  160. if (ret < 0)
  161. return ret;
  162. ret = wl1271_cmd_template_set(wl, CMD_TEMPL_AP_BEACON, NULL,
  163. WL1271_CMD_TEMPL_MAX_SIZE,
  164. 0, WL1271_RATE_AUTOMATIC);
  165. if (ret < 0)
  166. return ret;
  167. ret = wl1271_cmd_template_set(wl, CMD_TEMPL_DEAUTH_AP, NULL,
  168. sizeof
  169. (struct wl12xx_disconn_template),
  170. 0, WL1271_RATE_AUTOMATIC);
  171. if (ret < 0)
  172. return ret;
  173. ret = wl1271_cmd_template_set(wl, CMD_TEMPL_NULL_DATA, NULL,
  174. sizeof(struct wl12xx_null_data_template),
  175. 0, WL1271_RATE_AUTOMATIC);
  176. if (ret < 0)
  177. return ret;
  178. ret = wl1271_cmd_template_set(wl, CMD_TEMPL_QOS_NULL_DATA, NULL,
  179. sizeof
  180. (struct wl12xx_qos_null_data_template),
  181. 0, WL1271_RATE_AUTOMATIC);
  182. if (ret < 0)
  183. return ret;
  184. return 0;
  185. }
  186. static int wl12xx_init_rx_config(struct wl1271 *wl)
  187. {
  188. int ret;
  189. ret = wl1271_acx_rx_msdu_life_time(wl);
  190. if (ret < 0)
  191. return ret;
  192. return 0;
  193. }
  194. int wl1271_init_phy_config(struct wl1271 *wl)
  195. {
  196. int ret;
  197. ret = wl1271_acx_pd_threshold(wl);
  198. if (ret < 0)
  199. return ret;
  200. ret = wl1271_acx_slot(wl, DEFAULT_SLOT_TIME);
  201. if (ret < 0)
  202. return ret;
  203. ret = wl1271_acx_service_period_timeout(wl);
  204. if (ret < 0)
  205. return ret;
  206. ret = wl1271_acx_rts_threshold(wl, wl->hw->wiphy->rts_threshold);
  207. if (ret < 0)
  208. return ret;
  209. return 0;
  210. }
  211. static int wl1271_init_beacon_filter(struct wl1271 *wl)
  212. {
  213. int ret;
  214. /* disable beacon filtering at this stage */
  215. ret = wl1271_acx_beacon_filter_opt(wl, false);
  216. if (ret < 0)
  217. return ret;
  218. ret = wl1271_acx_beacon_filter_table(wl);
  219. if (ret < 0)
  220. return ret;
  221. return 0;
  222. }
  223. int wl1271_init_pta(struct wl1271 *wl)
  224. {
  225. int ret;
  226. ret = wl12xx_acx_sg_cfg(wl);
  227. if (ret < 0)
  228. return ret;
  229. ret = wl1271_acx_sg_enable(wl, wl->sg_enabled);
  230. if (ret < 0)
  231. return ret;
  232. return 0;
  233. }
  234. int wl1271_init_energy_detection(struct wl1271 *wl)
  235. {
  236. int ret;
  237. ret = wl1271_acx_cca_threshold(wl);
  238. if (ret < 0)
  239. return ret;
  240. return 0;
  241. }
  242. static int wl1271_init_beacon_broadcast(struct wl1271 *wl)
  243. {
  244. int ret;
  245. ret = wl1271_acx_bcn_dtim_options(wl);
  246. if (ret < 0)
  247. return ret;
  248. return 0;
  249. }
  250. static int wl12xx_init_fwlog(struct wl1271 *wl)
  251. {
  252. int ret;
  253. if (wl->quirks & WL12XX_QUIRK_FWLOG_NOT_IMPLEMENTED)
  254. return 0;
  255. ret = wl12xx_cmd_config_fwlog(wl);
  256. if (ret < 0)
  257. return ret;
  258. return 0;
  259. }
  260. static int wl1271_sta_hw_init(struct wl1271 *wl)
  261. {
  262. int ret;
  263. if (wl->chip.id != CHIP_ID_1283_PG20) {
  264. ret = wl1271_cmd_ext_radio_parms(wl);
  265. if (ret < 0)
  266. return ret;
  267. }
  268. /* PS config */
  269. ret = wl1271_acx_config_ps(wl);
  270. if (ret < 0)
  271. return ret;
  272. ret = wl1271_sta_init_templates_config(wl);
  273. if (ret < 0)
  274. return ret;
  275. ret = wl1271_acx_group_address_tbl(wl, true, NULL, 0);
  276. if (ret < 0)
  277. return ret;
  278. /* Initialize connection monitoring thresholds */
  279. ret = wl1271_acx_conn_monit_params(wl, false);
  280. if (ret < 0)
  281. return ret;
  282. /* Beacon filtering */
  283. ret = wl1271_init_beacon_filter(wl);
  284. if (ret < 0)
  285. return ret;
  286. /* FM WLAN coexistence */
  287. ret = wl1271_acx_fm_coex(wl);
  288. if (ret < 0)
  289. return ret;
  290. /* Beacons and broadcast settings */
  291. ret = wl1271_init_beacon_broadcast(wl);
  292. if (ret < 0)
  293. return ret;
  294. /* Configure for ELP power saving */
  295. ret = wl1271_acx_sleep_auth(wl, WL1271_PSM_ELP);
  296. if (ret < 0)
  297. return ret;
  298. /* Configure rssi/snr averaging weights */
  299. ret = wl1271_acx_rssi_snr_avg_weights(wl);
  300. if (ret < 0)
  301. return ret;
  302. ret = wl1271_acx_sta_rate_policies(wl);
  303. if (ret < 0)
  304. return ret;
  305. ret = wl12xx_acx_mem_cfg(wl);
  306. if (ret < 0)
  307. return ret;
  308. /* Configure the FW logger */
  309. ret = wl12xx_init_fwlog(wl);
  310. if (ret < 0)
  311. return ret;
  312. return 0;
  313. }
  314. static int wl1271_sta_hw_init_post_mem(struct wl1271 *wl)
  315. {
  316. int ret, i;
  317. /* disable all keep-alive templates */
  318. for (i = 0; i < CMD_TEMPL_KLV_IDX_MAX; i++) {
  319. ret = wl1271_acx_keep_alive_config(wl, i,
  320. ACX_KEEP_ALIVE_TPL_INVALID);
  321. if (ret < 0)
  322. return ret;
  323. }
  324. /* disable the keep-alive feature */
  325. ret = wl1271_acx_keep_alive_mode(wl, false);
  326. if (ret < 0)
  327. return ret;
  328. return 0;
  329. }
  330. static int wl1271_ap_hw_init(struct wl1271 *wl)
  331. {
  332. int ret;
  333. ret = wl1271_ap_init_templates_config(wl);
  334. if (ret < 0)
  335. return ret;
  336. /* Configure for power always on */
  337. ret = wl1271_acx_sleep_auth(wl, WL1271_PSM_CAM);
  338. if (ret < 0)
  339. return ret;
  340. ret = wl1271_init_ap_rates(wl);
  341. if (ret < 0)
  342. return ret;
  343. ret = wl1271_acx_ap_max_tx_retry(wl);
  344. if (ret < 0)
  345. return ret;
  346. ret = wl12xx_acx_mem_cfg(wl);
  347. if (ret < 0)
  348. return ret;
  349. /* initialize Tx power */
  350. ret = wl1271_acx_tx_power(wl, wl->power_level);
  351. if (ret < 0)
  352. return ret;
  353. return 0;
  354. }
  355. int wl1271_ap_init_templates(struct wl1271 *wl)
  356. {
  357. int ret;
  358. ret = wl1271_ap_init_deauth_template(wl);
  359. if (ret < 0)
  360. return ret;
  361. ret = wl1271_ap_init_null_template(wl);
  362. if (ret < 0)
  363. return ret;
  364. ret = wl1271_ap_init_qos_null_template(wl);
  365. if (ret < 0)
  366. return ret;
  367. /*
  368. * when operating as AP we want to receive external beacons for
  369. * configuring ERP protection.
  370. */
  371. ret = wl1271_acx_beacon_filter_opt(wl, false);
  372. if (ret < 0)
  373. return ret;
  374. return 0;
  375. }
  376. static int wl1271_ap_hw_init_post_mem(struct wl1271 *wl)
  377. {
  378. return wl1271_ap_init_templates(wl);
  379. }
  380. int wl1271_init_ap_rates(struct wl1271 *wl)
  381. {
  382. int i, ret;
  383. struct conf_tx_rate_class rc;
  384. u32 supported_rates;
  385. wl1271_debug(DEBUG_AP, "AP basic rate set: 0x%x", wl->basic_rate_set);
  386. if (wl->basic_rate_set == 0)
  387. return -EINVAL;
  388. rc.enabled_rates = wl->basic_rate_set;
  389. rc.long_retry_limit = 10;
  390. rc.short_retry_limit = 10;
  391. rc.aflags = 0;
  392. ret = wl1271_acx_ap_rate_policy(wl, &rc, ACX_TX_AP_MODE_MGMT_RATE);
  393. if (ret < 0)
  394. return ret;
  395. /* use the min basic rate for AP broadcast/multicast */
  396. rc.enabled_rates = wl1271_tx_min_rate_get(wl);
  397. rc.short_retry_limit = 10;
  398. rc.long_retry_limit = 10;
  399. rc.aflags = 0;
  400. ret = wl1271_acx_ap_rate_policy(wl, &rc, ACX_TX_AP_MODE_BCST_RATE);
  401. if (ret < 0)
  402. return ret;
  403. /*
  404. * If the basic rates contain OFDM rates, use OFDM only
  405. * rates for unicast TX as well. Else use all supported rates.
  406. */
  407. if ((wl->basic_rate_set & CONF_TX_OFDM_RATES))
  408. supported_rates = CONF_TX_OFDM_RATES;
  409. else
  410. supported_rates = CONF_TX_AP_ENABLED_RATES;
  411. /* unconditionally enable HT rates */
  412. supported_rates |= CONF_TX_MCS_RATES;
  413. /* configure unicast TX rate classes */
  414. for (i = 0; i < wl->conf.tx.ac_conf_count; i++) {
  415. rc.enabled_rates = supported_rates;
  416. rc.short_retry_limit = 10;
  417. rc.long_retry_limit = 10;
  418. rc.aflags = 0;
  419. ret = wl1271_acx_ap_rate_policy(wl, &rc, i);
  420. if (ret < 0)
  421. return ret;
  422. }
  423. return 0;
  424. }
  425. static int wl1271_set_ba_policies(struct wl1271 *wl)
  426. {
  427. /* Reset the BA RX indicators */
  428. wl->ba_rx_bitmap = 0;
  429. wl->ba_allowed = true;
  430. wl->ba_rx_session_count = 0;
  431. /* BA is supported in STA/AP modes */
  432. if (wl->bss_type != BSS_TYPE_AP_BSS &&
  433. wl->bss_type != BSS_TYPE_STA_BSS) {
  434. wl->ba_support = false;
  435. return 0;
  436. }
  437. wl->ba_support = true;
  438. /* 802.11n initiator BA session setting */
  439. return wl12xx_acx_set_ba_initiator_policy(wl);
  440. }
  441. int wl1271_chip_specific_init(struct wl1271 *wl)
  442. {
  443. int ret = 0;
  444. if (wl->chip.id == CHIP_ID_1283_PG20) {
  445. u32 host_cfg_bitmap = HOST_IF_CFG_RX_FIFO_ENABLE;
  446. if (wl->quirks & WL12XX_QUIRK_BLOCKSIZE_ALIGNMENT)
  447. /* Enable SDIO padding */
  448. host_cfg_bitmap |= HOST_IF_CFG_TX_PAD_TO_SDIO_BLK;
  449. /* Must be before wl1271_acx_init_mem_config() */
  450. ret = wl1271_acx_host_if_cfg_bitmap(wl, host_cfg_bitmap);
  451. if (ret < 0)
  452. goto out;
  453. }
  454. out:
  455. return ret;
  456. }
  457. int wl1271_hw_init(struct wl1271 *wl)
  458. {
  459. struct conf_tx_ac_category *conf_ac;
  460. struct conf_tx_tid *conf_tid;
  461. int ret, i;
  462. bool is_ap = (wl->bss_type == BSS_TYPE_AP_BSS);
  463. if (wl->chip.id == CHIP_ID_1283_PG20)
  464. ret = wl128x_cmd_general_parms(wl);
  465. else
  466. ret = wl1271_cmd_general_parms(wl);
  467. if (ret < 0)
  468. return ret;
  469. if (wl->chip.id == CHIP_ID_1283_PG20)
  470. ret = wl128x_cmd_radio_parms(wl);
  471. else
  472. ret = wl1271_cmd_radio_parms(wl);
  473. if (ret < 0)
  474. return ret;
  475. /* Chip-specific init */
  476. ret = wl1271_chip_specific_init(wl);
  477. if (ret < 0)
  478. return ret;
  479. /* Mode specific init */
  480. if (is_ap)
  481. ret = wl1271_ap_hw_init(wl);
  482. else
  483. ret = wl1271_sta_hw_init(wl);
  484. if (ret < 0)
  485. return ret;
  486. /* Bluetooth WLAN coexistence */
  487. ret = wl1271_init_pta(wl);
  488. if (ret < 0)
  489. return ret;
  490. /* Default memory configuration */
  491. ret = wl1271_acx_init_mem_config(wl);
  492. if (ret < 0)
  493. return ret;
  494. /* RX config */
  495. ret = wl12xx_init_rx_config(wl);
  496. if (ret < 0)
  497. goto out_free_memmap;
  498. /* PHY layer config */
  499. ret = wl1271_init_phy_config(wl);
  500. if (ret < 0)
  501. goto out_free_memmap;
  502. ret = wl1271_acx_dco_itrim_params(wl);
  503. if (ret < 0)
  504. goto out_free_memmap;
  505. /* Configure TX patch complete interrupt behavior */
  506. ret = wl1271_acx_tx_config_options(wl);
  507. if (ret < 0)
  508. goto out_free_memmap;
  509. /* RX complete interrupt pacing */
  510. ret = wl1271_acx_init_rx_interrupt(wl);
  511. if (ret < 0)
  512. goto out_free_memmap;
  513. /* Energy detection */
  514. ret = wl1271_init_energy_detection(wl);
  515. if (ret < 0)
  516. goto out_free_memmap;
  517. /* Default fragmentation threshold */
  518. ret = wl1271_acx_frag_threshold(wl, wl->hw->wiphy->frag_threshold);
  519. if (ret < 0)
  520. goto out_free_memmap;
  521. /* Default TID/AC configuration */
  522. BUG_ON(wl->conf.tx.tid_conf_count != wl->conf.tx.ac_conf_count);
  523. for (i = 0; i < wl->conf.tx.tid_conf_count; i++) {
  524. conf_ac = &wl->conf.tx.ac_conf[i];
  525. ret = wl1271_acx_ac_cfg(wl, conf_ac->ac, conf_ac->cw_min,
  526. conf_ac->cw_max, conf_ac->aifsn,
  527. conf_ac->tx_op_limit);
  528. if (ret < 0)
  529. goto out_free_memmap;
  530. conf_tid = &wl->conf.tx.tid_conf[i];
  531. ret = wl1271_acx_tid_cfg(wl, conf_tid->queue_id,
  532. conf_tid->channel_type,
  533. conf_tid->tsid,
  534. conf_tid->ps_scheme,
  535. conf_tid->ack_policy,
  536. conf_tid->apsd_conf[0],
  537. conf_tid->apsd_conf[1]);
  538. if (ret < 0)
  539. goto out_free_memmap;
  540. }
  541. /* Enable data path */
  542. ret = wl1271_cmd_data_path(wl, 1);
  543. if (ret < 0)
  544. goto out_free_memmap;
  545. /* Configure HW encryption */
  546. ret = wl1271_acx_feature_cfg(wl);
  547. if (ret < 0)
  548. goto out_free_memmap;
  549. /* configure PM */
  550. ret = wl1271_acx_pm_config(wl);
  551. if (ret < 0)
  552. goto out_free_memmap;
  553. /* Mode specific init - post mem init */
  554. if (is_ap)
  555. ret = wl1271_ap_hw_init_post_mem(wl);
  556. else
  557. ret = wl1271_sta_hw_init_post_mem(wl);
  558. if (ret < 0)
  559. goto out_free_memmap;
  560. ret = wl12xx_acx_set_rate_mgmt_params(wl);
  561. if (ret < 0)
  562. goto out_free_memmap;
  563. /* Configure initiator BA sessions policies */
  564. ret = wl1271_set_ba_policies(wl);
  565. if (ret < 0)
  566. goto out_free_memmap;
  567. return 0;
  568. out_free_memmap:
  569. kfree(wl->target_mem_map);
  570. wl->target_mem_map = NULL;
  571. return ret;
  572. }