init.c 17 KB

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