aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/wireless/wl12xx/init.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/net/wireless/wl12xx/init.c')
-rw-r--r--drivers/net/wireless/wl12xx/init.c458
1 files changed, 249 insertions, 209 deletions
diff --git a/drivers/net/wireless/wl12xx/init.c b/drivers/net/wireless/wl12xx/init.c
index 04db64c94e9a..88891cdfdd4a 100644
--- a/drivers/net/wireless/wl12xx/init.c
+++ b/drivers/net/wireless/wl12xx/init.c
@@ -25,6 +25,7 @@
25#include <linux/module.h> 25#include <linux/module.h>
26#include <linux/slab.h> 26#include <linux/slab.h>
27 27
28#include "debug.h"
28#include "init.h" 29#include "init.h"
29#include "wl12xx_80211.h" 30#include "wl12xx_80211.h"
30#include "acx.h" 31#include "acx.h"
@@ -33,7 +34,7 @@
33#include "tx.h" 34#include "tx.h"
34#include "io.h" 35#include "io.h"
35 36
36int wl1271_sta_init_templates_config(struct wl1271 *wl) 37int wl1271_init_templates_config(struct wl1271 *wl)
37{ 38{
38 int ret, i; 39 int ret, i;
39 40
@@ -64,7 +65,7 @@ int wl1271_sta_init_templates_config(struct wl1271 *wl)
64 65
65 ret = wl1271_cmd_template_set(wl, CMD_TEMPL_QOS_NULL_DATA, NULL, 66 ret = wl1271_cmd_template_set(wl, CMD_TEMPL_QOS_NULL_DATA, NULL,
66 sizeof 67 sizeof
67 (struct wl12xx_qos_null_data_template), 68 (struct ieee80211_qos_hdr),
68 0, WL1271_RATE_AUTOMATIC); 69 0, WL1271_RATE_AUTOMATIC);
69 if (ret < 0) 70 if (ret < 0)
70 return ret; 71 return ret;
@@ -88,10 +89,33 @@ int wl1271_sta_init_templates_config(struct wl1271 *wl)
88 if (ret < 0) 89 if (ret < 0)
89 return ret; 90 return ret;
90 91
92 /*
93 * Put very large empty placeholders for all templates. These
94 * reserve memory for later.
95 */
96 ret = wl1271_cmd_template_set(wl, CMD_TEMPL_AP_PROBE_RESPONSE, NULL,
97 WL1271_CMD_TEMPL_MAX_SIZE,
98 0, WL1271_RATE_AUTOMATIC);
99 if (ret < 0)
100 return ret;
101
102 ret = wl1271_cmd_template_set(wl, CMD_TEMPL_AP_BEACON, NULL,
103 WL1271_CMD_TEMPL_MAX_SIZE,
104 0, WL1271_RATE_AUTOMATIC);
105 if (ret < 0)
106 return ret;
107
108 ret = wl1271_cmd_template_set(wl, CMD_TEMPL_DEAUTH_AP, NULL,
109 sizeof
110 (struct wl12xx_disconn_template),
111 0, WL1271_RATE_AUTOMATIC);
112 if (ret < 0)
113 return ret;
114
91 for (i = 0; i < CMD_TEMPL_KLV_IDX_MAX; i++) { 115 for (i = 0; i < CMD_TEMPL_KLV_IDX_MAX; i++) {
92 ret = wl1271_cmd_template_set(wl, CMD_TEMPL_KLV, NULL, 116 ret = wl1271_cmd_template_set(wl, CMD_TEMPL_KLV, NULL,
93 WL1271_CMD_TEMPL_DFLT_SIZE, i, 117 sizeof(struct ieee80211_qos_hdr),
94 WL1271_RATE_AUTOMATIC); 118 i, WL1271_RATE_AUTOMATIC);
95 if (ret < 0) 119 if (ret < 0)
96 return ret; 120 return ret;
97 } 121 }
@@ -99,7 +123,8 @@ int wl1271_sta_init_templates_config(struct wl1271 *wl)
99 return 0; 123 return 0;
100} 124}
101 125
102static int wl1271_ap_init_deauth_template(struct wl1271 *wl) 126static int wl1271_ap_init_deauth_template(struct wl1271 *wl,
127 struct wl12xx_vif *wlvif)
103{ 128{
104 struct wl12xx_disconn_template *tmpl; 129 struct wl12xx_disconn_template *tmpl;
105 int ret; 130 int ret;
@@ -114,7 +139,7 @@ static int wl1271_ap_init_deauth_template(struct wl1271 *wl)
114 tmpl->header.frame_ctl = cpu_to_le16(IEEE80211_FTYPE_MGMT | 139 tmpl->header.frame_ctl = cpu_to_le16(IEEE80211_FTYPE_MGMT |
115 IEEE80211_STYPE_DEAUTH); 140 IEEE80211_STYPE_DEAUTH);
116 141
117 rate = wl1271_tx_min_rate_get(wl, wl->basic_rate_set); 142 rate = wl1271_tx_min_rate_get(wl, wlvif->basic_rate_set);
118 ret = wl1271_cmd_template_set(wl, CMD_TEMPL_DEAUTH_AP, 143 ret = wl1271_cmd_template_set(wl, CMD_TEMPL_DEAUTH_AP,
119 tmpl, sizeof(*tmpl), 0, rate); 144 tmpl, sizeof(*tmpl), 0, rate);
120 145
@@ -123,8 +148,10 @@ out:
123 return ret; 148 return ret;
124} 149}
125 150
126static int wl1271_ap_init_null_template(struct wl1271 *wl) 151static int wl1271_ap_init_null_template(struct wl1271 *wl,
152 struct ieee80211_vif *vif)
127{ 153{
154 struct wl12xx_vif *wlvif = wl12xx_vif_to_data(vif);
128 struct ieee80211_hdr_3addr *nullfunc; 155 struct ieee80211_hdr_3addr *nullfunc;
129 int ret; 156 int ret;
130 u32 rate; 157 u32 rate;
@@ -141,10 +168,10 @@ static int wl1271_ap_init_null_template(struct wl1271 *wl)
141 168
142 /* nullfunc->addr1 is filled by FW */ 169 /* nullfunc->addr1 is filled by FW */
143 170
144 memcpy(nullfunc->addr2, wl->mac_addr, ETH_ALEN); 171 memcpy(nullfunc->addr2, vif->addr, ETH_ALEN);
145 memcpy(nullfunc->addr3, wl->mac_addr, ETH_ALEN); 172 memcpy(nullfunc->addr3, vif->addr, ETH_ALEN);
146 173
147 rate = wl1271_tx_min_rate_get(wl, wl->basic_rate_set); 174 rate = wl1271_tx_min_rate_get(wl, wlvif->basic_rate_set);
148 ret = wl1271_cmd_template_set(wl, CMD_TEMPL_NULL_DATA, nullfunc, 175 ret = wl1271_cmd_template_set(wl, CMD_TEMPL_NULL_DATA, nullfunc,
149 sizeof(*nullfunc), 0, rate); 176 sizeof(*nullfunc), 0, rate);
150 177
@@ -153,8 +180,10 @@ out:
153 return ret; 180 return ret;
154} 181}
155 182
156static int wl1271_ap_init_qos_null_template(struct wl1271 *wl) 183static int wl1271_ap_init_qos_null_template(struct wl1271 *wl,
184 struct ieee80211_vif *vif)
157{ 185{
186 struct wl12xx_vif *wlvif = wl12xx_vif_to_data(vif);
158 struct ieee80211_qos_hdr *qosnull; 187 struct ieee80211_qos_hdr *qosnull;
159 int ret; 188 int ret;
160 u32 rate; 189 u32 rate;
@@ -171,10 +200,10 @@ static int wl1271_ap_init_qos_null_template(struct wl1271 *wl)
171 200
172 /* qosnull->addr1 is filled by FW */ 201 /* qosnull->addr1 is filled by FW */
173 202
174 memcpy(qosnull->addr2, wl->mac_addr, ETH_ALEN); 203 memcpy(qosnull->addr2, vif->addr, ETH_ALEN);
175 memcpy(qosnull->addr3, wl->mac_addr, ETH_ALEN); 204 memcpy(qosnull->addr3, vif->addr, ETH_ALEN);
176 205
177 rate = wl1271_tx_min_rate_get(wl, wl->basic_rate_set); 206 rate = wl1271_tx_min_rate_get(wl, wlvif->basic_rate_set);
178 ret = wl1271_cmd_template_set(wl, CMD_TEMPL_QOS_NULL_DATA, qosnull, 207 ret = wl1271_cmd_template_set(wl, CMD_TEMPL_QOS_NULL_DATA, qosnull,
179 sizeof(*qosnull), 0, rate); 208 sizeof(*qosnull), 0, rate);
180 209
@@ -183,93 +212,59 @@ out:
183 return ret; 212 return ret;
184} 213}
185 214
186static int wl1271_ap_init_templates_config(struct wl1271 *wl) 215static int wl12xx_init_rx_config(struct wl1271 *wl)
187{ 216{
188 int ret; 217 int ret;
189 218
190 /* 219 ret = wl1271_acx_rx_msdu_life_time(wl);
191 * Put very large empty placeholders for all templates. These
192 * reserve memory for later.
193 */
194 ret = wl1271_cmd_template_set(wl, CMD_TEMPL_AP_PROBE_RESPONSE, NULL,
195 WL1271_CMD_TEMPL_MAX_SIZE,
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 WL1271_CMD_TEMPL_MAX_SIZE,
202 0, WL1271_RATE_AUTOMATIC);
203 if (ret < 0)
204 return ret;
205
206 ret = wl1271_cmd_template_set(wl, CMD_TEMPL_DEAUTH_AP, NULL,
207 sizeof
208 (struct wl12xx_disconn_template),
209 0, WL1271_RATE_AUTOMATIC);
210 if (ret < 0)
211 return ret;
212
213 ret = wl1271_cmd_template_set(wl, CMD_TEMPL_NULL_DATA, NULL,
214 sizeof(struct wl12xx_null_data_template),
215 0, WL1271_RATE_AUTOMATIC);
216 if (ret < 0)
217 return ret;
218
219 ret = wl1271_cmd_template_set(wl, CMD_TEMPL_QOS_NULL_DATA, NULL,
220 sizeof
221 (struct wl12xx_qos_null_data_template),
222 0, WL1271_RATE_AUTOMATIC);
223 if (ret < 0) 220 if (ret < 0)
224 return ret; 221 return ret;
225 222
226 return 0; 223 return 0;
227} 224}
228 225
229static int wl12xx_init_rx_config(struct wl1271 *wl) 226int wl1271_init_phy_config(struct wl1271 *wl)
230{ 227{
231 int ret; 228 int ret;
232 229
233 ret = wl1271_acx_rx_msdu_life_time(wl); 230 ret = wl1271_acx_pd_threshold(wl);
234 if (ret < 0) 231 if (ret < 0)
235 return ret; 232 return ret;
236 233
237 return 0; 234 return 0;
238} 235}
239 236
240int wl1271_init_phy_config(struct wl1271 *wl) 237static int wl12xx_init_phy_vif_config(struct wl1271 *wl,
238 struct wl12xx_vif *wlvif)
241{ 239{
242 int ret; 240 int ret;
243 241
244 ret = wl1271_acx_pd_threshold(wl); 242 ret = wl1271_acx_slot(wl, wlvif, DEFAULT_SLOT_TIME);
245 if (ret < 0)
246 return ret;
247
248 ret = wl1271_acx_slot(wl, DEFAULT_SLOT_TIME);
249 if (ret < 0) 243 if (ret < 0)
250 return ret; 244 return ret;
251 245
252 ret = wl1271_acx_service_period_timeout(wl); 246 ret = wl1271_acx_service_period_timeout(wl, wlvif);
253 if (ret < 0) 247 if (ret < 0)
254 return ret; 248 return ret;
255 249
256 ret = wl1271_acx_rts_threshold(wl, wl->hw->wiphy->rts_threshold); 250 ret = wl1271_acx_rts_threshold(wl, wlvif, wl->hw->wiphy->rts_threshold);
257 if (ret < 0) 251 if (ret < 0)
258 return ret; 252 return ret;
259 253
260 return 0; 254 return 0;
261} 255}
262 256
263static int wl1271_init_beacon_filter(struct wl1271 *wl) 257static int wl1271_init_sta_beacon_filter(struct wl1271 *wl,
258 struct wl12xx_vif *wlvif)
264{ 259{
265 int ret; 260 int ret;
266 261
267 /* disable beacon filtering at this stage */ 262 ret = wl1271_acx_beacon_filter_table(wl, wlvif);
268 ret = wl1271_acx_beacon_filter_opt(wl, false);
269 if (ret < 0) 263 if (ret < 0)
270 return ret; 264 return ret;
271 265
272 ret = wl1271_acx_beacon_filter_table(wl); 266 /* enable beacon filtering */
267 ret = wl1271_acx_beacon_filter_opt(wl, wlvif, true);
273 if (ret < 0) 268 if (ret < 0)
274 return ret; 269 return ret;
275 270
@@ -302,11 +297,12 @@ int wl1271_init_energy_detection(struct wl1271 *wl)
302 return 0; 297 return 0;
303} 298}
304 299
305static int wl1271_init_beacon_broadcast(struct wl1271 *wl) 300static int wl1271_init_beacon_broadcast(struct wl1271 *wl,
301 struct wl12xx_vif *wlvif)
306{ 302{
307 int ret; 303 int ret;
308 304
309 ret = wl1271_acx_bcn_dtim_options(wl); 305 ret = wl1271_acx_bcn_dtim_options(wl, wlvif);
310 if (ret < 0) 306 if (ret < 0)
311 return ret; 307 return ret;
312 308
@@ -327,7 +323,8 @@ static int wl12xx_init_fwlog(struct wl1271 *wl)
327 return 0; 323 return 0;
328} 324}
329 325
330static int wl1271_sta_hw_init(struct wl1271 *wl) 326/* generic sta initialization (non vif-specific) */
327static int wl1271_sta_hw_init(struct wl1271 *wl, struct wl12xx_vif *wlvif)
331{ 328{
332 int ret; 329 int ret;
333 330
@@ -338,25 +335,7 @@ static int wl1271_sta_hw_init(struct wl1271 *wl)
338 } 335 }
339 336
340 /* PS config */ 337 /* PS config */
341 ret = wl1271_acx_config_ps(wl); 338 ret = wl12xx_acx_config_ps(wl, wlvif);
342 if (ret < 0)
343 return ret;
344
345 ret = wl1271_sta_init_templates_config(wl);
346 if (ret < 0)
347 return ret;
348
349 ret = wl1271_acx_group_address_tbl(wl, true, NULL, 0);
350 if (ret < 0)
351 return ret;
352
353 /* Initialize connection monitoring thresholds */
354 ret = wl1271_acx_conn_monit_params(wl, false);
355 if (ret < 0)
356 return ret;
357
358 /* Beacon filtering */
359 ret = wl1271_init_beacon_filter(wl);
360 if (ret < 0) 339 if (ret < 0)
361 return ret; 340 return ret;
362 341
@@ -365,103 +344,61 @@ static int wl1271_sta_hw_init(struct wl1271 *wl)
365 if (ret < 0) 344 if (ret < 0)
366 return ret; 345 return ret;
367 346
368 /* Beacons and broadcast settings */ 347 ret = wl1271_acx_sta_rate_policies(wl, wlvif);
369 ret = wl1271_init_beacon_broadcast(wl);
370 if (ret < 0)
371 return ret;
372
373 /* Configure for ELP power saving */
374 ret = wl1271_acx_sleep_auth(wl, WL1271_PSM_ELP);
375 if (ret < 0)
376 return ret;
377
378 /* Configure rssi/snr averaging weights */
379 ret = wl1271_acx_rssi_snr_avg_weights(wl);
380 if (ret < 0)
381 return ret;
382
383 ret = wl1271_acx_sta_rate_policies(wl);
384 if (ret < 0)
385 return ret;
386
387 ret = wl12xx_acx_mem_cfg(wl);
388 if (ret < 0)
389 return ret;
390
391 /* Configure the FW logger */
392 ret = wl12xx_init_fwlog(wl);
393 if (ret < 0) 348 if (ret < 0)
394 return ret; 349 return ret;
395 350
396 return 0; 351 return 0;
397} 352}
398 353
399static int wl1271_sta_hw_init_post_mem(struct wl1271 *wl) 354static int wl1271_sta_hw_init_post_mem(struct wl1271 *wl,
355 struct ieee80211_vif *vif)
400{ 356{
357 struct wl12xx_vif *wlvif = wl12xx_vif_to_data(vif);
401 int ret, i; 358 int ret, i;
402 359
403 /* disable all keep-alive templates */ 360 /* disable all keep-alive templates */
404 for (i = 0; i < CMD_TEMPL_KLV_IDX_MAX; i++) { 361 for (i = 0; i < CMD_TEMPL_KLV_IDX_MAX; i++) {
405 ret = wl1271_acx_keep_alive_config(wl, i, 362 ret = wl1271_acx_keep_alive_config(wl, wlvif, i,
406 ACX_KEEP_ALIVE_TPL_INVALID); 363 ACX_KEEP_ALIVE_TPL_INVALID);
407 if (ret < 0) 364 if (ret < 0)
408 return ret; 365 return ret;
409 } 366 }
410 367
411 /* disable the keep-alive feature */ 368 /* disable the keep-alive feature */
412 ret = wl1271_acx_keep_alive_mode(wl, false); 369 ret = wl1271_acx_keep_alive_mode(wl, wlvif, false);
413 if (ret < 0) 370 if (ret < 0)
414 return ret; 371 return ret;
415 372
416 return 0; 373 return 0;
417} 374}
418 375
419static int wl1271_ap_hw_init(struct wl1271 *wl) 376/* generic ap initialization (non vif-specific) */
377static int wl1271_ap_hw_init(struct wl1271 *wl, struct wl12xx_vif *wlvif)
420{ 378{
421 int ret; 379 int ret;
422 380
423 ret = wl1271_ap_init_templates_config(wl); 381 ret = wl1271_init_ap_rates(wl, wlvif);
424 if (ret < 0)
425 return ret;
426
427 /* Configure for power always on */
428 ret = wl1271_acx_sleep_auth(wl, WL1271_PSM_CAM);
429 if (ret < 0)
430 return ret;
431
432 ret = wl1271_init_ap_rates(wl);
433 if (ret < 0)
434 return ret;
435
436 ret = wl1271_acx_ap_max_tx_retry(wl);
437 if (ret < 0)
438 return ret;
439
440 ret = wl12xx_acx_mem_cfg(wl);
441 if (ret < 0)
442 return ret;
443
444 /* initialize Tx power */
445 ret = wl1271_acx_tx_power(wl, wl->power_level);
446 if (ret < 0) 382 if (ret < 0)
447 return ret; 383 return ret;
448 384
449 return 0; 385 return 0;
450} 386}
451 387
452int wl1271_ap_init_templates(struct wl1271 *wl) 388int wl1271_ap_init_templates(struct wl1271 *wl, struct ieee80211_vif *vif)
453{ 389{
390 struct wl12xx_vif *wlvif = wl12xx_vif_to_data(vif);
454 int ret; 391 int ret;
455 392
456 ret = wl1271_ap_init_deauth_template(wl); 393 ret = wl1271_ap_init_deauth_template(wl, wlvif);
457 if (ret < 0) 394 if (ret < 0)
458 return ret; 395 return ret;
459 396
460 ret = wl1271_ap_init_null_template(wl); 397 ret = wl1271_ap_init_null_template(wl, vif);
461 if (ret < 0) 398 if (ret < 0)
462 return ret; 399 return ret;
463 400
464 ret = wl1271_ap_init_qos_null_template(wl); 401 ret = wl1271_ap_init_qos_null_template(wl, vif);
465 if (ret < 0) 402 if (ret < 0)
466 return ret; 403 return ret;
467 404
@@ -469,43 +406,45 @@ int wl1271_ap_init_templates(struct wl1271 *wl)
469 * when operating as AP we want to receive external beacons for 406 * when operating as AP we want to receive external beacons for
470 * configuring ERP protection. 407 * configuring ERP protection.
471 */ 408 */
472 ret = wl1271_acx_beacon_filter_opt(wl, false); 409 ret = wl1271_acx_beacon_filter_opt(wl, wlvif, false);
473 if (ret < 0) 410 if (ret < 0)
474 return ret; 411 return ret;
475 412
476 return 0; 413 return 0;
477} 414}
478 415
479static int wl1271_ap_hw_init_post_mem(struct wl1271 *wl) 416static int wl1271_ap_hw_init_post_mem(struct wl1271 *wl,
417 struct ieee80211_vif *vif)
480{ 418{
481 return wl1271_ap_init_templates(wl); 419 return wl1271_ap_init_templates(wl, vif);
482} 420}
483 421
484int wl1271_init_ap_rates(struct wl1271 *wl) 422int wl1271_init_ap_rates(struct wl1271 *wl, struct wl12xx_vif *wlvif)
485{ 423{
486 int i, ret; 424 int i, ret;
487 struct conf_tx_rate_class rc; 425 struct conf_tx_rate_class rc;
488 u32 supported_rates; 426 u32 supported_rates;
489 427
490 wl1271_debug(DEBUG_AP, "AP basic rate set: 0x%x", wl->basic_rate_set); 428 wl1271_debug(DEBUG_AP, "AP basic rate set: 0x%x",
429 wlvif->basic_rate_set);
491 430
492 if (wl->basic_rate_set == 0) 431 if (wlvif->basic_rate_set == 0)
493 return -EINVAL; 432 return -EINVAL;
494 433
495 rc.enabled_rates = wl->basic_rate_set; 434 rc.enabled_rates = wlvif->basic_rate_set;
496 rc.long_retry_limit = 10; 435 rc.long_retry_limit = 10;
497 rc.short_retry_limit = 10; 436 rc.short_retry_limit = 10;
498 rc.aflags = 0; 437 rc.aflags = 0;
499 ret = wl1271_acx_ap_rate_policy(wl, &rc, ACX_TX_AP_MODE_MGMT_RATE); 438 ret = wl1271_acx_ap_rate_policy(wl, &rc, wlvif->ap.mgmt_rate_idx);
500 if (ret < 0) 439 if (ret < 0)
501 return ret; 440 return ret;
502 441
503 /* use the min basic rate for AP broadcast/multicast */ 442 /* use the min basic rate for AP broadcast/multicast */
504 rc.enabled_rates = wl1271_tx_min_rate_get(wl, wl->basic_rate_set); 443 rc.enabled_rates = wl1271_tx_min_rate_get(wl, wlvif->basic_rate_set);
505 rc.short_retry_limit = 10; 444 rc.short_retry_limit = 10;
506 rc.long_retry_limit = 10; 445 rc.long_retry_limit = 10;
507 rc.aflags = 0; 446 rc.aflags = 0;
508 ret = wl1271_acx_ap_rate_policy(wl, &rc, ACX_TX_AP_MODE_BCST_RATE); 447 ret = wl1271_acx_ap_rate_policy(wl, &rc, wlvif->ap.bcast_rate_idx);
509 if (ret < 0) 448 if (ret < 0)
510 return ret; 449 return ret;
511 450
@@ -513,7 +452,7 @@ int wl1271_init_ap_rates(struct wl1271 *wl)
513 * If the basic rates contain OFDM rates, use OFDM only 452 * If the basic rates contain OFDM rates, use OFDM only
514 * rates for unicast TX as well. Else use all supported rates. 453 * rates for unicast TX as well. Else use all supported rates.
515 */ 454 */
516 if ((wl->basic_rate_set & CONF_TX_OFDM_RATES)) 455 if ((wlvif->basic_rate_set & CONF_TX_OFDM_RATES))
517 supported_rates = CONF_TX_OFDM_RATES; 456 supported_rates = CONF_TX_OFDM_RATES;
518 else 457 else
519 supported_rates = CONF_TX_AP_ENABLED_RATES; 458 supported_rates = CONF_TX_AP_ENABLED_RATES;
@@ -527,7 +466,8 @@ int wl1271_init_ap_rates(struct wl1271 *wl)
527 rc.short_retry_limit = 10; 466 rc.short_retry_limit = 10;
528 rc.long_retry_limit = 10; 467 rc.long_retry_limit = 10;
529 rc.aflags = 0; 468 rc.aflags = 0;
530 ret = wl1271_acx_ap_rate_policy(wl, &rc, i); 469 ret = wl1271_acx_ap_rate_policy(wl, &rc,
470 wlvif->ap.ucast_rate_idx[i]);
531 if (ret < 0) 471 if (ret < 0)
532 return ret; 472 return ret;
533 } 473 }
@@ -535,24 +475,23 @@ int wl1271_init_ap_rates(struct wl1271 *wl)
535 return 0; 475 return 0;
536} 476}
537 477
538static int wl1271_set_ba_policies(struct wl1271 *wl) 478static int wl1271_set_ba_policies(struct wl1271 *wl, struct wl12xx_vif *wlvif)
539{ 479{
540 /* Reset the BA RX indicators */ 480 /* Reset the BA RX indicators */
541 wl->ba_rx_bitmap = 0; 481 wlvif->ba_allowed = true;
542 wl->ba_allowed = true;
543 wl->ba_rx_session_count = 0; 482 wl->ba_rx_session_count = 0;
544 483
545 /* BA is supported in STA/AP modes */ 484 /* BA is supported in STA/AP modes */
546 if (wl->bss_type != BSS_TYPE_AP_BSS && 485 if (wlvif->bss_type != BSS_TYPE_AP_BSS &&
547 wl->bss_type != BSS_TYPE_STA_BSS) { 486 wlvif->bss_type != BSS_TYPE_STA_BSS) {
548 wl->ba_support = false; 487 wlvif->ba_support = false;
549 return 0; 488 return 0;
550 } 489 }
551 490
552 wl->ba_support = true; 491 wlvif->ba_support = true;
553 492
554 /* 802.11n initiator BA session setting */ 493 /* 802.11n initiator BA session setting */
555 return wl12xx_acx_set_ba_initiator_policy(wl); 494 return wl12xx_acx_set_ba_initiator_policy(wl, wlvif);
556} 495}
557 496
558int wl1271_chip_specific_init(struct wl1271 *wl) 497int wl1271_chip_specific_init(struct wl1271 *wl)
@@ -562,7 +501,7 @@ int wl1271_chip_specific_init(struct wl1271 *wl)
562 if (wl->chip.id == CHIP_ID_1283_PG20) { 501 if (wl->chip.id == CHIP_ID_1283_PG20) {
563 u32 host_cfg_bitmap = HOST_IF_CFG_RX_FIFO_ENABLE; 502 u32 host_cfg_bitmap = HOST_IF_CFG_RX_FIFO_ENABLE;
564 503
565 if (wl->quirks & WL12XX_QUIRK_BLOCKSIZE_ALIGNMENT) 504 if (!(wl->quirks & WL12XX_QUIRK_NO_BLOCKSIZE_ALIGNMENT))
566 /* Enable SDIO padding */ 505 /* Enable SDIO padding */
567 host_cfg_bitmap |= HOST_IF_CFG_TX_PAD_TO_SDIO_BLK; 506 host_cfg_bitmap |= HOST_IF_CFG_TX_PAD_TO_SDIO_BLK;
568 507
@@ -575,13 +514,150 @@ out:
575 return ret; 514 return ret;
576} 515}
577 516
517/* vif-specifc initialization */
518static int wl12xx_init_sta_role(struct wl1271 *wl, struct wl12xx_vif *wlvif)
519{
520 int ret;
578 521
579int wl1271_hw_init(struct wl1271 *wl) 522 ret = wl1271_acx_group_address_tbl(wl, wlvif, true, NULL, 0);
523 if (ret < 0)
524 return ret;
525
526 /* Initialize connection monitoring thresholds */
527 ret = wl1271_acx_conn_monit_params(wl, wlvif, false);
528 if (ret < 0)
529 return ret;
530
531 /* Beacon filtering */
532 ret = wl1271_init_sta_beacon_filter(wl, wlvif);
533 if (ret < 0)
534 return ret;
535
536 /* Beacons and broadcast settings */
537 ret = wl1271_init_beacon_broadcast(wl, wlvif);
538 if (ret < 0)
539 return ret;
540
541 /* Configure rssi/snr averaging weights */
542 ret = wl1271_acx_rssi_snr_avg_weights(wl, wlvif);
543 if (ret < 0)
544 return ret;
545
546 return 0;
547}
548
549/* vif-specific intialization */
550static int wl12xx_init_ap_role(struct wl1271 *wl, struct wl12xx_vif *wlvif)
551{
552 int ret;
553
554 ret = wl1271_acx_ap_max_tx_retry(wl, wlvif);
555 if (ret < 0)
556 return ret;
557
558 /* initialize Tx power */
559 ret = wl1271_acx_tx_power(wl, wlvif, wlvif->power_level);
560 if (ret < 0)
561 return ret;
562
563 return 0;
564}
565
566int wl1271_init_vif_specific(struct wl1271 *wl, struct ieee80211_vif *vif)
580{ 567{
568 struct wl12xx_vif *wlvif = wl12xx_vif_to_data(vif);
581 struct conf_tx_ac_category *conf_ac; 569 struct conf_tx_ac_category *conf_ac;
582 struct conf_tx_tid *conf_tid; 570 struct conf_tx_tid *conf_tid;
571 bool is_ap = (wlvif->bss_type == BSS_TYPE_AP_BSS);
583 int ret, i; 572 int ret, i;
584 bool is_ap = (wl->bss_type == BSS_TYPE_AP_BSS); 573
574 /*
575 * consider all existing roles before configuring psm.
576 * TODO: reconfigure on interface removal.
577 */
578 if (!wl->ap_count) {
579 if (is_ap) {
580 /* Configure for power always on */
581 ret = wl1271_acx_sleep_auth(wl, WL1271_PSM_CAM);
582 if (ret < 0)
583 return ret;
584 } else if (!wl->sta_count) {
585 /* Configure for ELP power saving */
586 ret = wl1271_acx_sleep_auth(wl, WL1271_PSM_ELP);
587 if (ret < 0)
588 return ret;
589 }
590 }
591
592 /* Mode specific init */
593 if (is_ap) {
594 ret = wl1271_ap_hw_init(wl, wlvif);
595 if (ret < 0)
596 return ret;
597
598 ret = wl12xx_init_ap_role(wl, wlvif);
599 if (ret < 0)
600 return ret;
601 } else {
602 ret = wl1271_sta_hw_init(wl, wlvif);
603 if (ret < 0)
604 return ret;
605
606 ret = wl12xx_init_sta_role(wl, wlvif);
607 if (ret < 0)
608 return ret;
609 }
610
611 wl12xx_init_phy_vif_config(wl, wlvif);
612
613 /* Default TID/AC configuration */
614 BUG_ON(wl->conf.tx.tid_conf_count != wl->conf.tx.ac_conf_count);
615 for (i = 0; i < wl->conf.tx.tid_conf_count; i++) {
616 conf_ac = &wl->conf.tx.ac_conf[i];
617 ret = wl1271_acx_ac_cfg(wl, wlvif, conf_ac->ac,
618 conf_ac->cw_min, conf_ac->cw_max,
619 conf_ac->aifsn, conf_ac->tx_op_limit);
620 if (ret < 0)
621 return ret;
622
623 conf_tid = &wl->conf.tx.tid_conf[i];
624 ret = wl1271_acx_tid_cfg(wl, wlvif,
625 conf_tid->queue_id,
626 conf_tid->channel_type,
627 conf_tid->tsid,
628 conf_tid->ps_scheme,
629 conf_tid->ack_policy,
630 conf_tid->apsd_conf[0],
631 conf_tid->apsd_conf[1]);
632 if (ret < 0)
633 return ret;
634 }
635
636 /* Configure HW encryption */
637 ret = wl1271_acx_feature_cfg(wl, wlvif);
638 if (ret < 0)
639 return ret;
640
641 /* Mode specific init - post mem init */
642 if (is_ap)
643 ret = wl1271_ap_hw_init_post_mem(wl, vif);
644 else
645 ret = wl1271_sta_hw_init_post_mem(wl, vif);
646
647 if (ret < 0)
648 return ret;
649
650 /* Configure initiator BA sessions policies */
651 ret = wl1271_set_ba_policies(wl, wlvif);
652 if (ret < 0)
653 return ret;
654
655 return 0;
656}
657
658int wl1271_hw_init(struct wl1271 *wl)
659{
660 int ret;
585 661
586 if (wl->chip.id == CHIP_ID_1283_PG20) 662 if (wl->chip.id == CHIP_ID_1283_PG20)
587 ret = wl128x_cmd_general_parms(wl); 663 ret = wl128x_cmd_general_parms(wl);
@@ -602,12 +678,17 @@ int wl1271_hw_init(struct wl1271 *wl)
602 if (ret < 0) 678 if (ret < 0)
603 return ret; 679 return ret;
604 680
605 /* Mode specific init */ 681 /* Init templates */
606 if (is_ap) 682 ret = wl1271_init_templates_config(wl);
607 ret = wl1271_ap_hw_init(wl); 683 if (ret < 0)
608 else 684 return ret;
609 ret = wl1271_sta_hw_init(wl); 685
686 ret = wl12xx_acx_mem_cfg(wl);
687 if (ret < 0)
688 return ret;
610 689
690 /* Configure the FW logger */
691 ret = wl12xx_init_fwlog(wl);
611 if (ret < 0) 692 if (ret < 0)
612 return ret; 693 return ret;
613 694
@@ -655,61 +736,20 @@ int wl1271_hw_init(struct wl1271 *wl)
655 if (ret < 0) 736 if (ret < 0)
656 goto out_free_memmap; 737 goto out_free_memmap;
657 738
658 /* Default TID/AC configuration */
659 BUG_ON(wl->conf.tx.tid_conf_count != wl->conf.tx.ac_conf_count);
660 for (i = 0; i < wl->conf.tx.tid_conf_count; i++) {
661 conf_ac = &wl->conf.tx.ac_conf[i];
662 ret = wl1271_acx_ac_cfg(wl, conf_ac->ac, conf_ac->cw_min,
663 conf_ac->cw_max, conf_ac->aifsn,
664 conf_ac->tx_op_limit);
665 if (ret < 0)
666 goto out_free_memmap;
667
668 conf_tid = &wl->conf.tx.tid_conf[i];
669 ret = wl1271_acx_tid_cfg(wl, conf_tid->queue_id,
670 conf_tid->channel_type,
671 conf_tid->tsid,
672 conf_tid->ps_scheme,
673 conf_tid->ack_policy,
674 conf_tid->apsd_conf[0],
675 conf_tid->apsd_conf[1]);
676 if (ret < 0)
677 goto out_free_memmap;
678 }
679
680 /* Enable data path */ 739 /* Enable data path */
681 ret = wl1271_cmd_data_path(wl, 1); 740 ret = wl1271_cmd_data_path(wl, 1);
682 if (ret < 0) 741 if (ret < 0)
683 goto out_free_memmap; 742 goto out_free_memmap;
684 743
685 /* Configure HW encryption */
686 ret = wl1271_acx_feature_cfg(wl);
687 if (ret < 0)
688 goto out_free_memmap;
689
690 /* configure PM */ 744 /* configure PM */
691 ret = wl1271_acx_pm_config(wl); 745 ret = wl1271_acx_pm_config(wl);
692 if (ret < 0) 746 if (ret < 0)
693 goto out_free_memmap; 747 goto out_free_memmap;
694 748
695 /* Mode specific init - post mem init */
696 if (is_ap)
697 ret = wl1271_ap_hw_init_post_mem(wl);
698 else
699 ret = wl1271_sta_hw_init_post_mem(wl);
700
701 if (ret < 0)
702 goto out_free_memmap;
703
704 ret = wl12xx_acx_set_rate_mgmt_params(wl); 749 ret = wl12xx_acx_set_rate_mgmt_params(wl);
705 if (ret < 0) 750 if (ret < 0)
706 goto out_free_memmap; 751 goto out_free_memmap;
707 752
708 /* Configure initiator BA sessions policies */
709 ret = wl1271_set_ba_policies(wl);
710 if (ret < 0)
711 goto out_free_memmap;
712
713 /* configure hangover */ 753 /* configure hangover */
714 ret = wl12xx_acx_config_hangover(wl); 754 ret = wl12xx_acx_config_hangover(wl);
715 if (ret < 0) 755 if (ret < 0)