init.c 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755
  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 < CMD_TEMPL_KLV_IDX_MAX; 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, i;
  306. /* disable all keep-alive templates */
  307. for (i = 0; i < CMD_TEMPL_KLV_IDX_MAX; i++) {
  308. ret = wl1271_acx_keep_alive_config(wl, wlvif, i,
  309. ACX_KEEP_ALIVE_TPL_INVALID);
  310. if (ret < 0)
  311. return ret;
  312. }
  313. /* disable the keep-alive feature */
  314. ret = wl1271_acx_keep_alive_mode(wl, wlvif, false);
  315. if (ret < 0)
  316. return ret;
  317. return 0;
  318. }
  319. /* generic ap initialization (non vif-specific) */
  320. static int wl1271_ap_hw_init(struct wl1271 *wl, struct wl12xx_vif *wlvif)
  321. {
  322. int ret;
  323. ret = wl1271_init_ap_rates(wl, wlvif);
  324. if (ret < 0)
  325. return ret;
  326. return 0;
  327. }
  328. int wl1271_ap_init_templates(struct wl1271 *wl, struct ieee80211_vif *vif)
  329. {
  330. struct wl12xx_vif *wlvif = wl12xx_vif_to_data(vif);
  331. int ret;
  332. ret = wl1271_ap_init_deauth_template(wl, wlvif);
  333. if (ret < 0)
  334. return ret;
  335. ret = wl1271_ap_init_null_template(wl, vif);
  336. if (ret < 0)
  337. return ret;
  338. ret = wl1271_ap_init_qos_null_template(wl, vif);
  339. if (ret < 0)
  340. return ret;
  341. /*
  342. * when operating as AP we want to receive external beacons for
  343. * configuring ERP protection.
  344. */
  345. ret = wl1271_acx_beacon_filter_opt(wl, wlvif, false);
  346. if (ret < 0)
  347. return ret;
  348. return 0;
  349. }
  350. static int wl1271_ap_hw_init_post_mem(struct wl1271 *wl,
  351. struct ieee80211_vif *vif)
  352. {
  353. return wl1271_ap_init_templates(wl, vif);
  354. }
  355. int wl1271_init_ap_rates(struct wl1271 *wl, struct wl12xx_vif *wlvif)
  356. {
  357. int i, ret;
  358. struct conf_tx_rate_class rc;
  359. u32 supported_rates;
  360. wl1271_debug(DEBUG_AP, "AP basic rate set: 0x%x",
  361. wlvif->basic_rate_set);
  362. if (wlvif->basic_rate_set == 0)
  363. return -EINVAL;
  364. rc.enabled_rates = wlvif->basic_rate_set;
  365. rc.long_retry_limit = 10;
  366. rc.short_retry_limit = 10;
  367. rc.aflags = 0;
  368. ret = wl1271_acx_ap_rate_policy(wl, &rc, wlvif->ap.mgmt_rate_idx);
  369. if (ret < 0)
  370. return ret;
  371. /* use the min basic rate for AP broadcast/multicast */
  372. rc.enabled_rates = wl1271_tx_min_rate_get(wl, wlvif->basic_rate_set);
  373. rc.short_retry_limit = 10;
  374. rc.long_retry_limit = 10;
  375. rc.aflags = 0;
  376. ret = wl1271_acx_ap_rate_policy(wl, &rc, wlvif->ap.bcast_rate_idx);
  377. if (ret < 0)
  378. return ret;
  379. /*
  380. * If the basic rates contain OFDM rates, use OFDM only
  381. * rates for unicast TX as well. Else use all supported rates.
  382. */
  383. if ((wlvif->basic_rate_set & CONF_TX_OFDM_RATES))
  384. supported_rates = CONF_TX_OFDM_RATES;
  385. else
  386. supported_rates = CONF_TX_AP_ENABLED_RATES;
  387. /* unconditionally enable HT rates */
  388. supported_rates |= CONF_TX_MCS_RATES;
  389. /* get extra MIMO or wide-chan rates where the HW supports it */
  390. supported_rates |= wlcore_hw_ap_get_mimo_wide_rate_mask(wl, wlvif);
  391. /* configure unicast TX rate classes */
  392. for (i = 0; i < wl->conf.tx.ac_conf_count; i++) {
  393. rc.enabled_rates = supported_rates;
  394. rc.short_retry_limit = 10;
  395. rc.long_retry_limit = 10;
  396. rc.aflags = 0;
  397. ret = wl1271_acx_ap_rate_policy(wl, &rc,
  398. wlvif->ap.ucast_rate_idx[i]);
  399. if (ret < 0)
  400. return ret;
  401. }
  402. return 0;
  403. }
  404. static int wl1271_set_ba_policies(struct wl1271 *wl, struct wl12xx_vif *wlvif)
  405. {
  406. /* Reset the BA RX indicators */
  407. wlvif->ba_allowed = true;
  408. wl->ba_rx_session_count = 0;
  409. /* BA is supported in STA/AP modes */
  410. if (wlvif->bss_type != BSS_TYPE_AP_BSS &&
  411. wlvif->bss_type != BSS_TYPE_STA_BSS) {
  412. wlvif->ba_support = false;
  413. return 0;
  414. }
  415. wlvif->ba_support = true;
  416. /* 802.11n initiator BA session setting */
  417. return wl12xx_acx_set_ba_initiator_policy(wl, wlvif);
  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. /* consider all existing roles before configuring psm. */
  465. if (wl->ap_count == 0 && is_ap) { /* first AP */
  466. /* Configure for power always on */
  467. ret = wl1271_acx_sleep_auth(wl, WL1271_PSM_CAM);
  468. if (ret < 0)
  469. return ret;
  470. /* first STA, no APs */
  471. } else if (wl->sta_count == 0 && wl->ap_count == 0 && !is_ap) {
  472. u8 sta_auth = wl->conf.conn.sta_sleep_auth;
  473. /* Configure for power according to debugfs */
  474. if (sta_auth != WL1271_PSM_ILLEGAL)
  475. ret = wl1271_acx_sleep_auth(wl, sta_auth);
  476. /* Configure for power always on */
  477. else if (wl->quirks & WLCORE_QUIRK_NO_ELP)
  478. ret = wl1271_acx_sleep_auth(wl, WL1271_PSM_CAM);
  479. /* Configure for ELP power saving */
  480. else
  481. ret = wl1271_acx_sleep_auth(wl, WL1271_PSM_ELP);
  482. if (ret < 0)
  483. return ret;
  484. }
  485. /* Mode specific init */
  486. if (is_ap) {
  487. ret = wl1271_ap_hw_init(wl, wlvif);
  488. if (ret < 0)
  489. return ret;
  490. ret = wl12xx_init_ap_role(wl, wlvif);
  491. if (ret < 0)
  492. return ret;
  493. } else {
  494. ret = wl1271_sta_hw_init(wl, wlvif);
  495. if (ret < 0)
  496. return ret;
  497. ret = wl12xx_init_sta_role(wl, wlvif);
  498. if (ret < 0)
  499. return ret;
  500. }
  501. wl12xx_init_phy_vif_config(wl, wlvif);
  502. /* Default TID/AC configuration */
  503. BUG_ON(wl->conf.tx.tid_conf_count != wl->conf.tx.ac_conf_count);
  504. for (i = 0; i < wl->conf.tx.tid_conf_count; i++) {
  505. conf_ac = &wl->conf.tx.ac_conf[i];
  506. ret = wl1271_acx_ac_cfg(wl, wlvif, conf_ac->ac,
  507. conf_ac->cw_min, conf_ac->cw_max,
  508. conf_ac->aifsn, conf_ac->tx_op_limit);
  509. if (ret < 0)
  510. return ret;
  511. conf_tid = &wl->conf.tx.tid_conf[i];
  512. ret = wl1271_acx_tid_cfg(wl, wlvif,
  513. conf_tid->queue_id,
  514. conf_tid->channel_type,
  515. conf_tid->tsid,
  516. conf_tid->ps_scheme,
  517. conf_tid->ack_policy,
  518. conf_tid->apsd_conf[0],
  519. conf_tid->apsd_conf[1]);
  520. if (ret < 0)
  521. return ret;
  522. }
  523. /* Configure HW encryption */
  524. ret = wl1271_acx_feature_cfg(wl, wlvif);
  525. if (ret < 0)
  526. return ret;
  527. /* Mode specific init - post mem init */
  528. if (is_ap)
  529. ret = wl1271_ap_hw_init_post_mem(wl, vif);
  530. else
  531. ret = wl1271_sta_hw_init_post_mem(wl, vif);
  532. if (ret < 0)
  533. return ret;
  534. /* Configure initiator BA sessions policies */
  535. ret = wl1271_set_ba_policies(wl, wlvif);
  536. if (ret < 0)
  537. return ret;
  538. ret = wlcore_hw_init_vif(wl, wlvif);
  539. if (ret < 0)
  540. return ret;
  541. return 0;
  542. }
  543. int wl1271_hw_init(struct wl1271 *wl)
  544. {
  545. int ret;
  546. /* Chip-specific hw init */
  547. ret = wl->ops->hw_init(wl);
  548. if (ret < 0)
  549. return ret;
  550. /* Init templates */
  551. ret = wl1271_init_templates_config(wl);
  552. if (ret < 0)
  553. return ret;
  554. ret = wl12xx_acx_mem_cfg(wl);
  555. if (ret < 0)
  556. return ret;
  557. /* Configure the FW logger */
  558. ret = wl12xx_init_fwlog(wl);
  559. if (ret < 0)
  560. return ret;
  561. /* Bluetooth WLAN coexistence */
  562. ret = wl1271_init_pta(wl);
  563. if (ret < 0)
  564. return ret;
  565. /* Default memory configuration */
  566. ret = wl1271_acx_init_mem_config(wl);
  567. if (ret < 0)
  568. return ret;
  569. /* RX config */
  570. ret = wl12xx_init_rx_config(wl);
  571. if (ret < 0)
  572. goto out_free_memmap;
  573. ret = wl1271_acx_dco_itrim_params(wl);
  574. if (ret < 0)
  575. goto out_free_memmap;
  576. /* Configure TX patch complete interrupt behavior */
  577. ret = wl1271_acx_tx_config_options(wl);
  578. if (ret < 0)
  579. goto out_free_memmap;
  580. /* RX complete interrupt pacing */
  581. ret = wl1271_acx_init_rx_interrupt(wl);
  582. if (ret < 0)
  583. goto out_free_memmap;
  584. /* Energy detection */
  585. ret = wl1271_init_energy_detection(wl);
  586. if (ret < 0)
  587. goto out_free_memmap;
  588. /* Default fragmentation threshold */
  589. ret = wl1271_acx_frag_threshold(wl, wl->hw->wiphy->frag_threshold);
  590. if (ret < 0)
  591. goto out_free_memmap;
  592. /* Enable data path */
  593. ret = wl1271_cmd_data_path(wl, 1);
  594. if (ret < 0)
  595. goto out_free_memmap;
  596. /* configure PM */
  597. ret = wl1271_acx_pm_config(wl);
  598. if (ret < 0)
  599. goto out_free_memmap;
  600. ret = wl12xx_acx_set_rate_mgmt_params(wl);
  601. if (ret < 0)
  602. goto out_free_memmap;
  603. /* configure hangover */
  604. ret = wl12xx_acx_config_hangover(wl);
  605. if (ret < 0)
  606. goto out_free_memmap;
  607. return 0;
  608. out_free_memmap:
  609. kfree(wl->target_mem_map);
  610. wl->target_mem_map = NULL;
  611. return ret;
  612. }