init.c 17 KB

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