init.c 17 KB

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