wl12xx: AP mode - support FW TX inactivity triggers
[linux-2.6.git] / drivers / net / wireless / wl12xx / init.c
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
24 #include <linux/kernel.h>
25 #include <linux/module.h>
26 #include <linux/slab.h>
27
28 #include "init.h"
29 #include "wl12xx_80211.h"
30 #include "acx.h"
31 #include "cmd.h"
32 #include "reg.h"
33 #include "tx.h"
34 #include "io.h"
35
36 int wl1271_sta_init_templates_config(struct wl1271 *wl)
37 {
38         int ret, i;
39
40         /* send empty templates for fw memory reservation */
41         ret = wl1271_cmd_template_set(wl, CMD_TEMPL_CFG_PROBE_REQ_2_4, NULL,
42                                       WL1271_CMD_TEMPL_MAX_SIZE,
43                                       0, WL1271_RATE_AUTOMATIC);
44         if (ret < 0)
45                 return ret;
46
47         ret = wl1271_cmd_template_set(wl, CMD_TEMPL_CFG_PROBE_REQ_5,
48                                       NULL, WL1271_CMD_TEMPL_MAX_SIZE, 0,
49                                       WL1271_RATE_AUTOMATIC);
50         if (ret < 0)
51                 return ret;
52
53         ret = wl1271_cmd_template_set(wl, CMD_TEMPL_NULL_DATA, NULL,
54                                       sizeof(struct wl12xx_null_data_template),
55                                       0, WL1271_RATE_AUTOMATIC);
56         if (ret < 0)
57                 return ret;
58
59         ret = wl1271_cmd_template_set(wl, CMD_TEMPL_PS_POLL, NULL,
60                                       sizeof(struct wl12xx_ps_poll_template),
61                                       0, WL1271_RATE_AUTOMATIC);
62         if (ret < 0)
63                 return ret;
64
65         ret = wl1271_cmd_template_set(wl, CMD_TEMPL_QOS_NULL_DATA, NULL,
66                                       sizeof
67                                       (struct wl12xx_qos_null_data_template),
68                                       0, WL1271_RATE_AUTOMATIC);
69         if (ret < 0)
70                 return ret;
71
72         ret = wl1271_cmd_template_set(wl, CMD_TEMPL_PROBE_RESPONSE, NULL,
73                                       sizeof
74                                       (struct wl12xx_probe_resp_template),
75                                       0, WL1271_RATE_AUTOMATIC);
76         if (ret < 0)
77                 return ret;
78
79         ret = wl1271_cmd_template_set(wl, CMD_TEMPL_BEACON, NULL,
80                                       sizeof
81                                       (struct wl12xx_beacon_template),
82                                       0, WL1271_RATE_AUTOMATIC);
83         if (ret < 0)
84                 return ret;
85
86         ret = wl1271_cmd_template_set(wl, CMD_TEMPL_ARP_RSP, NULL,
87                                       sizeof
88                                       (struct wl12xx_arp_rsp_template),
89                                       0, WL1271_RATE_AUTOMATIC);
90         if (ret < 0)
91                 return ret;
92
93         for (i = 0; i < CMD_TEMPL_KLV_IDX_MAX; i++) {
94                 ret = wl1271_cmd_template_set(wl, CMD_TEMPL_KLV, NULL,
95                                               WL1271_CMD_TEMPL_MAX_SIZE, i,
96                                               WL1271_RATE_AUTOMATIC);
97                 if (ret < 0)
98                         return ret;
99         }
100
101         return 0;
102 }
103
104 static int wl1271_ap_init_deauth_template(struct wl1271 *wl)
105 {
106         struct wl12xx_disconn_template *tmpl;
107         int ret;
108
109         tmpl = kzalloc(sizeof(*tmpl), GFP_KERNEL);
110         if (!tmpl) {
111                 ret = -ENOMEM;
112                 goto out;
113         }
114
115         tmpl->header.frame_ctl = cpu_to_le16(IEEE80211_FTYPE_MGMT |
116                                              IEEE80211_STYPE_DEAUTH);
117
118         ret = wl1271_cmd_template_set(wl, CMD_TEMPL_DEAUTH_AP,
119                                       tmpl, sizeof(*tmpl), 0,
120                                       wl1271_tx_min_rate_get(wl));
121
122 out:
123         kfree(tmpl);
124         return ret;
125 }
126
127 static int wl1271_ap_init_null_template(struct wl1271 *wl)
128 {
129         struct ieee80211_hdr_3addr *nullfunc;
130         int ret;
131
132         nullfunc = kzalloc(sizeof(*nullfunc), GFP_KERNEL);
133         if (!nullfunc) {
134                 ret = -ENOMEM;
135                 goto out;
136         }
137
138         nullfunc->frame_control = cpu_to_le16(IEEE80211_FTYPE_DATA |
139                                               IEEE80211_STYPE_NULLFUNC |
140                                               IEEE80211_FCTL_FROMDS);
141
142         /* nullfunc->addr1 is filled by FW */
143
144         memcpy(nullfunc->addr2, wl->mac_addr, ETH_ALEN);
145         memcpy(nullfunc->addr3, wl->mac_addr, ETH_ALEN);
146
147         ret = wl1271_cmd_template_set(wl, CMD_TEMPL_NULL_DATA, nullfunc,
148                                       sizeof(*nullfunc), 0,
149                                       wl1271_tx_min_rate_get(wl));
150
151 out:
152         kfree(nullfunc);
153         return ret;
154 }
155
156 static int wl1271_ap_init_qos_null_template(struct wl1271 *wl)
157 {
158         struct ieee80211_qos_hdr *qosnull;
159         int ret;
160
161         qosnull = kzalloc(sizeof(*qosnull), GFP_KERNEL);
162         if (!qosnull) {
163                 ret = -ENOMEM;
164                 goto out;
165         }
166
167         qosnull->frame_control = cpu_to_le16(IEEE80211_FTYPE_DATA |
168                                              IEEE80211_STYPE_QOS_NULLFUNC |
169                                              IEEE80211_FCTL_FROMDS);
170
171         /* qosnull->addr1 is filled by FW */
172
173         memcpy(qosnull->addr2, wl->mac_addr, ETH_ALEN);
174         memcpy(qosnull->addr3, wl->mac_addr, ETH_ALEN);
175
176         ret = wl1271_cmd_template_set(wl, CMD_TEMPL_QOS_NULL_DATA, qosnull,
177                                       sizeof(*qosnull), 0,
178                                       wl1271_tx_min_rate_get(wl));
179
180 out:
181         kfree(qosnull);
182         return ret;
183 }
184
185 static int wl1271_ap_init_templates_config(struct wl1271 *wl)
186 {
187         int ret;
188
189         /*
190          * Put very large empty placeholders for all templates. These
191          * reserve memory for later.
192          */
193         ret = wl1271_cmd_template_set(wl, CMD_TEMPL_AP_PROBE_RESPONSE, NULL,
194                                       sizeof
195                                       (struct wl12xx_probe_resp_template),
196                                       0, WL1271_RATE_AUTOMATIC);
197         if (ret < 0)
198                 return ret;
199
200         ret = wl1271_cmd_template_set(wl, CMD_TEMPL_AP_BEACON, NULL,
201                                       sizeof
202                                       (struct wl12xx_beacon_template),
203                                       0, WL1271_RATE_AUTOMATIC);
204         if (ret < 0)
205                 return ret;
206
207         ret = wl1271_cmd_template_set(wl, CMD_TEMPL_DEAUTH_AP, NULL,
208                                       sizeof
209                                       (struct wl12xx_disconn_template),
210                                       0, WL1271_RATE_AUTOMATIC);
211         if (ret < 0)
212                 return ret;
213
214         ret = wl1271_cmd_template_set(wl, CMD_TEMPL_NULL_DATA, NULL,
215                                       sizeof(struct wl12xx_null_data_template),
216                                       0, WL1271_RATE_AUTOMATIC);
217         if (ret < 0)
218                 return ret;
219
220         ret = wl1271_cmd_template_set(wl, CMD_TEMPL_QOS_NULL_DATA, NULL,
221                                       sizeof
222                                       (struct wl12xx_qos_null_data_template),
223                                       0, WL1271_RATE_AUTOMATIC);
224         if (ret < 0)
225                 return ret;
226
227         return 0;
228 }
229
230 static int wl1271_init_rx_config(struct wl1271 *wl, u32 config, u32 filter)
231 {
232         int ret;
233
234         ret = wl1271_acx_rx_msdu_life_time(wl);
235         if (ret < 0)
236                 return ret;
237
238         ret = wl1271_acx_rx_config(wl, config, filter);
239         if (ret < 0)
240                 return ret;
241
242         return 0;
243 }
244
245 int wl1271_init_phy_config(struct wl1271 *wl)
246 {
247         int ret;
248
249         ret = wl1271_acx_pd_threshold(wl);
250         if (ret < 0)
251                 return ret;
252
253         ret = wl1271_acx_slot(wl, DEFAULT_SLOT_TIME);
254         if (ret < 0)
255                 return ret;
256
257         ret = wl1271_acx_service_period_timeout(wl);
258         if (ret < 0)
259                 return ret;
260
261         ret = wl1271_acx_rts_threshold(wl, wl->hw->wiphy->rts_threshold);
262         if (ret < 0)
263                 return ret;
264
265         return 0;
266 }
267
268 static int wl1271_init_beacon_filter(struct wl1271 *wl)
269 {
270         int ret;
271
272         /* disable beacon filtering at this stage */
273         ret = wl1271_acx_beacon_filter_opt(wl, false);
274         if (ret < 0)
275                 return ret;
276
277         ret = wl1271_acx_beacon_filter_table(wl);
278         if (ret < 0)
279                 return ret;
280
281         return 0;
282 }
283
284 int wl1271_init_pta(struct wl1271 *wl)
285 {
286         int ret;
287
288         if (wl->bss_type == BSS_TYPE_AP_BSS)
289                 ret = wl1271_acx_ap_sg_cfg(wl);
290         else
291                 ret = wl1271_acx_sta_sg_cfg(wl);
292         if (ret < 0)
293                 return ret;
294
295         ret = wl1271_acx_sg_enable(wl, wl->sg_enabled);
296         if (ret < 0)
297                 return ret;
298
299         return 0;
300 }
301
302 int wl1271_init_energy_detection(struct wl1271 *wl)
303 {
304         int ret;
305
306         ret = wl1271_acx_cca_threshold(wl);
307         if (ret < 0)
308                 return ret;
309
310         return 0;
311 }
312
313 static int wl1271_init_beacon_broadcast(struct wl1271 *wl)
314 {
315         int ret;
316
317         ret = wl1271_acx_bcn_dtim_options(wl);
318         if (ret < 0)
319                 return ret;
320
321         return 0;
322 }
323
324 static int wl12xx_init_fwlog(struct wl1271 *wl)
325 {
326         int ret;
327
328         if (wl->quirks & WL12XX_QUIRK_FWLOG_NOT_IMPLEMENTED)
329                 return 0;
330
331         ret = wl12xx_cmd_config_fwlog(wl);
332         if (ret < 0)
333                 return ret;
334
335         return 0;
336 }
337
338 static int wl1271_sta_hw_init(struct wl1271 *wl)
339 {
340         int ret;
341
342         if (wl->chip.id != CHIP_ID_1283_PG20) {
343                 ret = wl1271_cmd_ext_radio_parms(wl);
344                 if (ret < 0)
345                         return ret;
346         }
347
348         /* PS config */
349         ret = wl1271_acx_config_ps(wl);
350         if (ret < 0)
351                 return ret;
352
353         ret = wl1271_sta_init_templates_config(wl);
354         if (ret < 0)
355                 return ret;
356
357         ret = wl1271_acx_group_address_tbl(wl, true, NULL, 0);
358         if (ret < 0)
359                 return ret;
360
361         /* Initialize connection monitoring thresholds */
362         ret = wl1271_acx_conn_monit_params(wl, false);
363         if (ret < 0)
364                 return ret;
365
366         /* Beacon filtering */
367         ret = wl1271_init_beacon_filter(wl);
368         if (ret < 0)
369                 return ret;
370
371         /* FM WLAN coexistence */
372         ret = wl1271_acx_fm_coex(wl);
373         if (ret < 0)
374                 return ret;
375
376         /* Beacons and broadcast settings */
377         ret = wl1271_init_beacon_broadcast(wl);
378         if (ret < 0)
379                 return ret;
380
381         /* Configure for ELP power saving */
382         ret = wl1271_acx_sleep_auth(wl, WL1271_PSM_ELP);
383         if (ret < 0)
384                 return ret;
385
386         /* Configure rssi/snr averaging weights */
387         ret = wl1271_acx_rssi_snr_avg_weights(wl);
388         if (ret < 0)
389                 return ret;
390
391         ret = wl1271_acx_sta_rate_policies(wl);
392         if (ret < 0)
393                 return ret;
394
395         ret = wl1271_acx_sta_mem_cfg(wl);
396         if (ret < 0)
397                 return ret;
398
399         /* Configure the FW logger */
400         ret = wl12xx_init_fwlog(wl);
401         if (ret < 0)
402                 return ret;
403
404         return 0;
405 }
406
407 static int wl1271_sta_hw_init_post_mem(struct wl1271 *wl)
408 {
409         int ret, i;
410
411         ret = wl1271_cmd_set_sta_default_wep_key(wl, wl->default_key);
412         if (ret < 0) {
413                 wl1271_warning("couldn't set default key");
414                 return ret;
415         }
416
417         /* disable all keep-alive templates */
418         for (i = 0; i < CMD_TEMPL_KLV_IDX_MAX; i++) {
419                 ret = wl1271_acx_keep_alive_config(wl, i,
420                                                    ACX_KEEP_ALIVE_TPL_INVALID);
421                 if (ret < 0)
422                         return ret;
423         }
424
425         /* disable the keep-alive feature */
426         ret = wl1271_acx_keep_alive_mode(wl, false);
427         if (ret < 0)
428                 return ret;
429
430         return 0;
431 }
432
433 static int wl1271_ap_hw_init(struct wl1271 *wl)
434 {
435         int ret;
436
437         ret = wl1271_ap_init_templates_config(wl);
438         if (ret < 0)
439                 return ret;
440
441         /* Configure for power always on */
442         ret = wl1271_acx_sleep_auth(wl, WL1271_PSM_CAM);
443         if (ret < 0)
444                 return ret;
445
446         ret = wl1271_init_ap_rates(wl);
447         if (ret < 0)
448                 return ret;
449
450         ret = wl1271_acx_ap_max_tx_retry(wl);
451         if (ret < 0)
452                 return ret;
453
454         ret = wl1271_acx_ap_mem_cfg(wl);
455         if (ret < 0)
456                 return ret;
457
458         return 0;
459 }
460
461 int wl1271_ap_init_templates(struct wl1271 *wl)
462 {
463         int ret;
464
465         ret = wl1271_ap_init_deauth_template(wl);
466         if (ret < 0)
467                 return ret;
468
469         ret = wl1271_ap_init_null_template(wl);
470         if (ret < 0)
471                 return ret;
472
473         ret = wl1271_ap_init_qos_null_template(wl);
474         if (ret < 0)
475                 return ret;
476
477         /*
478          * when operating as AP we want to receive external beacons for
479          * configuring ERP protection.
480          */
481         ret = wl1271_acx_set_ap_beacon_filter(wl, false);
482         if (ret < 0)
483                 return ret;
484
485         return 0;
486 }
487
488 static int wl1271_ap_hw_init_post_mem(struct wl1271 *wl)
489 {
490         return wl1271_ap_init_templates(wl);
491 }
492
493 int wl1271_init_ap_rates(struct wl1271 *wl)
494 {
495         int i, ret;
496         struct conf_tx_rate_class rc;
497         u32 supported_rates;
498
499         wl1271_debug(DEBUG_AP, "AP basic rate set: 0x%x", wl->basic_rate_set);
500
501         if (wl->basic_rate_set == 0)
502                 return -EINVAL;
503
504         rc.enabled_rates = wl->basic_rate_set;
505         rc.long_retry_limit = 10;
506         rc.short_retry_limit = 10;
507         rc.aflags = 0;
508         ret = wl1271_acx_ap_rate_policy(wl, &rc, ACX_TX_AP_MODE_MGMT_RATE);
509         if (ret < 0)
510                 return ret;
511
512         /* use the min basic rate for AP broadcast/multicast */
513         rc.enabled_rates = wl1271_tx_min_rate_get(wl);
514         rc.short_retry_limit = 10;
515         rc.long_retry_limit = 10;
516         rc.aflags = 0;
517         ret = wl1271_acx_ap_rate_policy(wl, &rc, ACX_TX_AP_MODE_BCST_RATE);
518         if (ret < 0)
519                 return ret;
520
521         /*
522          * If the basic rates contain OFDM rates, use OFDM only
523          * rates for unicast TX as well. Else use all supported rates.
524          */
525         if ((wl->basic_rate_set & CONF_TX_OFDM_RATES))
526                 supported_rates = CONF_TX_OFDM_RATES;
527         else
528                 supported_rates = CONF_TX_AP_ENABLED_RATES;
529
530         /* configure unicast TX rate classes */
531         for (i = 0; i < wl->conf.tx.ac_conf_count; i++) {
532                 rc.enabled_rates = supported_rates;
533                 rc.short_retry_limit = 10;
534                 rc.long_retry_limit = 10;
535                 rc.aflags = 0;
536                 ret = wl1271_acx_ap_rate_policy(wl, &rc, i);
537                 if (ret < 0)
538                         return ret;
539         }
540
541         return 0;
542 }
543
544 static void wl1271_check_ba_support(struct wl1271 *wl)
545 {
546         /* validate FW cose ver x.x.x.50-60.x */
547         if ((wl->chip.fw_ver[3] >= WL12XX_BA_SUPPORT_FW_COST_VER2_START) &&
548             (wl->chip.fw_ver[3] < WL12XX_BA_SUPPORT_FW_COST_VER2_END)) {
549                 wl->ba_support = true;
550                 return;
551         }
552
553         wl->ba_support = false;
554 }
555
556 static int wl1271_set_ba_policies(struct wl1271 *wl)
557 {
558         u8 tid_index;
559         int ret = 0;
560
561         /* Reset the BA RX indicators */
562         wl->ba_rx_bitmap = 0;
563         wl->ba_allowed = true;
564
565         /* validate that FW support BA */
566         wl1271_check_ba_support(wl);
567
568         if (wl->ba_support)
569                 /* 802.11n initiator BA session setting */
570                 for (tid_index = 0; tid_index < CONF_TX_MAX_TID_COUNT;
571                      ++tid_index) {
572                         ret = wl1271_acx_set_ba_session(wl, WLAN_BACK_INITIATOR,
573                                                         tid_index, true);
574                         if (ret < 0)
575                                 break;
576                 }
577
578         return ret;
579 }
580
581 int wl1271_chip_specific_init(struct wl1271 *wl)
582 {
583         int ret = 0;
584
585         if (wl->chip.id == CHIP_ID_1283_PG20) {
586                 u32 host_cfg_bitmap = HOST_IF_CFG_RX_FIFO_ENABLE;
587
588                 if (wl->quirks & WL12XX_QUIRK_BLOCKSIZE_ALIGNMENT)
589                         /* Enable SDIO padding */
590                         host_cfg_bitmap |= HOST_IF_CFG_TX_PAD_TO_SDIO_BLK;
591
592                 /* Must be before wl1271_acx_init_mem_config() */
593                 ret = wl1271_acx_host_if_cfg_bitmap(wl, host_cfg_bitmap);
594                 if (ret < 0)
595                         goto out;
596         }
597 out:
598         return ret;
599 }
600
601
602 int wl1271_hw_init(struct wl1271 *wl)
603 {
604         struct conf_tx_ac_category *conf_ac;
605         struct conf_tx_tid *conf_tid;
606         int ret, i;
607         bool is_ap = (wl->bss_type == BSS_TYPE_AP_BSS);
608
609         if (wl->chip.id == CHIP_ID_1283_PG20)
610                 ret = wl128x_cmd_general_parms(wl);
611         else
612                 ret = wl1271_cmd_general_parms(wl);
613         if (ret < 0)
614                 return ret;
615
616         if (wl->chip.id == CHIP_ID_1283_PG20)
617                 ret = wl128x_cmd_radio_parms(wl);
618         else
619                 ret = wl1271_cmd_radio_parms(wl);
620         if (ret < 0)
621                 return ret;
622
623         /* Chip-specific init */
624         ret = wl1271_chip_specific_init(wl);
625         if (ret < 0)
626                 return ret;
627
628         /* Mode specific init */
629         if (is_ap)
630                 ret = wl1271_ap_hw_init(wl);
631         else
632                 ret = wl1271_sta_hw_init(wl);
633
634         if (ret < 0)
635                 return ret;
636
637         /* Bluetooth WLAN coexistence */
638         ret = wl1271_init_pta(wl);
639         if (ret < 0)
640                 return ret;
641
642         /* Default memory configuration */
643         ret = wl1271_acx_init_mem_config(wl);
644         if (ret < 0)
645                 return ret;
646
647         /* RX config */
648         ret = wl1271_init_rx_config(wl,
649                                     RX_CFG_PROMISCUOUS | RX_CFG_TSF,
650                                     RX_FILTER_OPTION_DEF);
651         /* RX_CONFIG_OPTION_ANY_DST_ANY_BSS,
652            RX_FILTER_OPTION_FILTER_ALL); */
653         if (ret < 0)
654                 goto out_free_memmap;
655
656         /* PHY layer config */
657         ret = wl1271_init_phy_config(wl);
658         if (ret < 0)
659                 goto out_free_memmap;
660
661         ret = wl1271_acx_dco_itrim_params(wl);
662         if (ret < 0)
663                 goto out_free_memmap;
664
665         /* Configure TX patch complete interrupt behavior */
666         ret = wl1271_acx_tx_config_options(wl);
667         if (ret < 0)
668                 goto out_free_memmap;
669
670         /* RX complete interrupt pacing */
671         ret = wl1271_acx_init_rx_interrupt(wl);
672         if (ret < 0)
673                 goto out_free_memmap;
674
675         /* Energy detection */
676         ret = wl1271_init_energy_detection(wl);
677         if (ret < 0)
678                 goto out_free_memmap;
679
680         /* Default fragmentation threshold */
681         ret = wl1271_acx_frag_threshold(wl, wl->hw->wiphy->frag_threshold);
682         if (ret < 0)
683                 goto out_free_memmap;
684
685         /* Default TID/AC configuration */
686         BUG_ON(wl->conf.tx.tid_conf_count != wl->conf.tx.ac_conf_count);
687         for (i = 0; i < wl->conf.tx.tid_conf_count; i++) {
688                 conf_ac = &wl->conf.tx.ac_conf[i];
689                 ret = wl1271_acx_ac_cfg(wl, conf_ac->ac, conf_ac->cw_min,
690                                         conf_ac->cw_max, conf_ac->aifsn,
691                                         conf_ac->tx_op_limit);
692                 if (ret < 0)
693                         goto out_free_memmap;
694
695                 conf_tid = &wl->conf.tx.tid_conf[i];
696                 ret = wl1271_acx_tid_cfg(wl, conf_tid->queue_id,
697                                          conf_tid->channel_type,
698                                          conf_tid->tsid,
699                                          conf_tid->ps_scheme,
700                                          conf_tid->ack_policy,
701                                          conf_tid->apsd_conf[0],
702                                          conf_tid->apsd_conf[1]);
703                 if (ret < 0)
704                         goto out_free_memmap;
705         }
706
707         /* Enable data path */
708         ret = wl1271_cmd_data_path(wl, 1);
709         if (ret < 0)
710                 goto out_free_memmap;
711
712         /* Configure HW encryption */
713         ret = wl1271_acx_feature_cfg(wl);
714         if (ret < 0)
715                 goto out_free_memmap;
716
717         /* configure PM */
718         ret = wl1271_acx_pm_config(wl);
719         if (ret < 0)
720                 goto out_free_memmap;
721
722         /* Mode specific init - post mem init */
723         if (is_ap)
724                 ret = wl1271_ap_hw_init_post_mem(wl);
725         else
726                 ret = wl1271_sta_hw_init_post_mem(wl);
727
728         if (ret < 0)
729                 goto out_free_memmap;
730
731         /* Configure initiator BA sessions policies */
732         ret = wl1271_set_ba_policies(wl);
733         if (ret < 0)
734                 goto out_free_memmap;
735
736         return 0;
737
738  out_free_memmap:
739         kfree(wl->target_mem_map);
740         wl->target_mem_map = NULL;
741
742         return ret;
743 }