aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEliad Peller <eliad@wizery.com>2011-10-05 05:55:40 -0400
committerLuciano Coelho <coelho@ti.com>2011-10-07 01:32:32 -0400
commit92c77c734f958474ac73af670834bc32cb833e54 (patch)
tree0bb5c3d1c3fe88624ddb7f3cbbd533eb9cf270e9
parent784f694d0f3ca927361aa0c26de1aa340eb5b275 (diff)
wl12xx: start reworking the init sequence
Split the init sequence into common commands (non role-specific) and role-specific commands. We still need to call the common commands only on add_interface() (rather than on start()) as the fw must get the mac address when uploading the nvs. Future patches will refactor the init sequence further more. Signed-off-by: Eliad Peller <eliad@wizery.com> [fixed a couple of sparse warnings] Signed-off-by: Luciano Coelho <coelho@ti.com>
-rw-r--r--drivers/net/wireless/wl12xx/init.c306
-rw-r--r--drivers/net/wireless/wl12xx/init.h5
-rw-r--r--drivers/net/wireless/wl12xx/main.c8
3 files changed, 171 insertions, 148 deletions
diff --git a/drivers/net/wireless/wl12xx/init.c b/drivers/net/wireless/wl12xx/init.c
index 4692a91ca737..145601dddab0 100644
--- a/drivers/net/wireless/wl12xx/init.c
+++ b/drivers/net/wireless/wl12xx/init.c
@@ -33,7 +33,7 @@
33#include "tx.h" 33#include "tx.h"
34#include "io.h" 34#include "io.h"
35 35
36int wl1271_sta_init_templates_config(struct wl1271 *wl) 36int wl1271_init_templates_config(struct wl1271 *wl)
37{ 37{
38 int ret, i; 38 int ret, i;
39 39
@@ -88,6 +88,29 @@ int wl1271_sta_init_templates_config(struct wl1271 *wl)
88 if (ret < 0) 88 if (ret < 0)
89 return ret; 89 return ret;
90 90
91 /*
92 * Put very large empty placeholders for all templates. These
93 * reserve memory for later.
94 */
95 ret = wl1271_cmd_template_set(wl, CMD_TEMPL_AP_PROBE_RESPONSE, NULL,
96 WL1271_CMD_TEMPL_MAX_SIZE,
97 0, WL1271_RATE_AUTOMATIC);
98 if (ret < 0)
99 return ret;
100
101 ret = wl1271_cmd_template_set(wl, CMD_TEMPL_AP_BEACON, NULL,
102 WL1271_CMD_TEMPL_MAX_SIZE,
103 0, WL1271_RATE_AUTOMATIC);
104 if (ret < 0)
105 return ret;
106
107 ret = wl1271_cmd_template_set(wl, CMD_TEMPL_DEAUTH_AP, NULL,
108 sizeof
109 (struct wl12xx_disconn_template),
110 0, WL1271_RATE_AUTOMATIC);
111 if (ret < 0)
112 return ret;
113
91 for (i = 0; i < CMD_TEMPL_KLV_IDX_MAX; i++) { 114 for (i = 0; i < CMD_TEMPL_KLV_IDX_MAX; i++) {
92 ret = wl1271_cmd_template_set(wl, CMD_TEMPL_KLV, NULL, 115 ret = wl1271_cmd_template_set(wl, CMD_TEMPL_KLV, NULL,
93 WL1271_CMD_TEMPL_DFLT_SIZE, i, 116 WL1271_CMD_TEMPL_DFLT_SIZE, i,
@@ -185,68 +208,32 @@ out:
185 return ret; 208 return ret;
186} 209}
187 210
188static int wl1271_ap_init_templates_config(struct wl1271 *wl) 211static int wl12xx_init_rx_config(struct wl1271 *wl)
189{ 212{
190 int ret; 213 int ret;
191 214
192 /* 215 ret = wl1271_acx_rx_msdu_life_time(wl);
193 * Put very large empty placeholders for all templates. These
194 * reserve memory for later.
195 */
196 ret = wl1271_cmd_template_set(wl, CMD_TEMPL_AP_PROBE_RESPONSE, NULL,
197 WL1271_CMD_TEMPL_MAX_SIZE,
198 0, WL1271_RATE_AUTOMATIC);
199 if (ret < 0)
200 return ret;
201
202 ret = wl1271_cmd_template_set(wl, CMD_TEMPL_AP_BEACON, NULL,
203 WL1271_CMD_TEMPL_MAX_SIZE,
204 0, WL1271_RATE_AUTOMATIC);
205 if (ret < 0)
206 return ret;
207
208 ret = wl1271_cmd_template_set(wl, CMD_TEMPL_DEAUTH_AP, NULL,
209 sizeof
210 (struct wl12xx_disconn_template),
211 0, WL1271_RATE_AUTOMATIC);
212 if (ret < 0)
213 return ret;
214
215 ret = wl1271_cmd_template_set(wl, CMD_TEMPL_NULL_DATA, NULL,
216 sizeof(struct wl12xx_null_data_template),
217 0, WL1271_RATE_AUTOMATIC);
218 if (ret < 0)
219 return ret;
220
221 ret = wl1271_cmd_template_set(wl, CMD_TEMPL_QOS_NULL_DATA, NULL,
222 sizeof
223 (struct wl12xx_qos_null_data_template),
224 0, WL1271_RATE_AUTOMATIC);
225 if (ret < 0) 216 if (ret < 0)
226 return ret; 217 return ret;
227 218
228 return 0; 219 return 0;
229} 220}
230 221
231static int wl12xx_init_rx_config(struct wl1271 *wl) 222int wl1271_init_phy_config(struct wl1271 *wl)
232{ 223{
233 int ret; 224 int ret;
234 225
235 ret = wl1271_acx_rx_msdu_life_time(wl); 226 ret = wl1271_acx_pd_threshold(wl);
236 if (ret < 0) 227 if (ret < 0)
237 return ret; 228 return ret;
238 229
239 return 0; 230 return 0;
240} 231}
241 232
242int wl1271_init_phy_config(struct wl1271 *wl) 233static int wl12xx_init_phy_vif_config(struct wl1271 *wl)
243{ 234{
244 int ret; 235 int ret;
245 236
246 ret = wl1271_acx_pd_threshold(wl);
247 if (ret < 0)
248 return ret;
249
250 ret = wl1271_acx_slot(wl, DEFAULT_SLOT_TIME); 237 ret = wl1271_acx_slot(wl, DEFAULT_SLOT_TIME);
251 if (ret < 0) 238 if (ret < 0)
252 return ret; 239 return ret;
@@ -329,6 +316,7 @@ static int wl12xx_init_fwlog(struct wl1271 *wl)
329 return 0; 316 return 0;
330} 317}
331 318
319/* generic sta initialization (non vif-specific) */
332static int wl1271_sta_hw_init(struct wl1271 *wl) 320static int wl1271_sta_hw_init(struct wl1271 *wl)
333{ 321{
334 int ret; 322 int ret;
@@ -344,57 +332,20 @@ static int wl1271_sta_hw_init(struct wl1271 *wl)
344 if (ret < 0) 332 if (ret < 0)
345 return ret; 333 return ret;
346 334
347 ret = wl1271_sta_init_templates_config(wl);
348 if (ret < 0)
349 return ret;
350
351 ret = wl1271_acx_group_address_tbl(wl, true, NULL, 0);
352 if (ret < 0)
353 return ret;
354
355 /* Initialize connection monitoring thresholds */
356 ret = wl1271_acx_conn_monit_params(wl, false);
357 if (ret < 0)
358 return ret;
359
360 /* Beacon filtering */
361 ret = wl1271_init_beacon_filter(wl);
362 if (ret < 0)
363 return ret;
364
365 /* FM WLAN coexistence */ 335 /* FM WLAN coexistence */
366 ret = wl1271_acx_fm_coex(wl); 336 ret = wl1271_acx_fm_coex(wl);
367 if (ret < 0) 337 if (ret < 0)
368 return ret; 338 return ret;
369 339
370 /* Beacons and broadcast settings */
371 ret = wl1271_init_beacon_broadcast(wl);
372 if (ret < 0)
373 return ret;
374
375 /* Configure for ELP power saving */ 340 /* Configure for ELP power saving */
376 ret = wl1271_acx_sleep_auth(wl, WL1271_PSM_ELP); 341 ret = wl1271_acx_sleep_auth(wl, WL1271_PSM_ELP);
377 if (ret < 0) 342 if (ret < 0)
378 return ret; 343 return ret;
379 344
380 /* Configure rssi/snr averaging weights */
381 ret = wl1271_acx_rssi_snr_avg_weights(wl);
382 if (ret < 0)
383 return ret;
384
385 ret = wl1271_acx_sta_rate_policies(wl); 345 ret = wl1271_acx_sta_rate_policies(wl);
386 if (ret < 0) 346 if (ret < 0)
387 return ret; 347 return ret;
388 348
389 ret = wl12xx_acx_mem_cfg(wl);
390 if (ret < 0)
391 return ret;
392
393 /* Configure the FW logger */
394 ret = wl12xx_init_fwlog(wl);
395 if (ret < 0)
396 return ret;
397
398 return 0; 349 return 0;
399} 350}
400 351
@@ -418,14 +369,11 @@ static int wl1271_sta_hw_init_post_mem(struct wl1271 *wl)
418 return 0; 369 return 0;
419} 370}
420 371
372/* generic ap initialization (non vif-specific) */
421static int wl1271_ap_hw_init(struct wl1271 *wl) 373static int wl1271_ap_hw_init(struct wl1271 *wl)
422{ 374{
423 int ret; 375 int ret;
424 376
425 ret = wl1271_ap_init_templates_config(wl);
426 if (ret < 0)
427 return ret;
428
429 /* Configure for power always on */ 377 /* Configure for power always on */
430 ret = wl1271_acx_sleep_auth(wl, WL1271_PSM_CAM); 378 ret = wl1271_acx_sleep_auth(wl, WL1271_PSM_CAM);
431 if (ret < 0) 379 if (ret < 0)
@@ -435,19 +383,6 @@ static int wl1271_ap_hw_init(struct wl1271 *wl)
435 if (ret < 0) 383 if (ret < 0)
436 return ret; 384 return ret;
437 385
438 ret = wl1271_acx_ap_max_tx_retry(wl);
439 if (ret < 0)
440 return ret;
441
442 ret = wl12xx_acx_mem_cfg(wl);
443 if (ret < 0)
444 return ret;
445
446 /* initialize Tx power */
447 ret = wl1271_acx_tx_power(wl, wl->power_level);
448 if (ret < 0)
449 return ret;
450
451 return 0; 386 return 0;
452} 387}
453 388
@@ -578,14 +513,133 @@ out:
578 return ret; 513 return ret;
579} 514}
580 515
516/* vif-specifc initialization */
517static int wl12xx_init_sta_role(struct wl1271 *wl, struct ieee80211_vif *vif)
518{
519 int ret;
520
521 ret = wl1271_acx_group_address_tbl(wl, true, NULL, 0);
522 if (ret < 0)
523 return ret;
524
525 /* Initialize connection monitoring thresholds */
526 ret = wl1271_acx_conn_monit_params(wl, false);
527 if (ret < 0)
528 return ret;
529
530 /* Beacon filtering */
531 ret = wl1271_init_beacon_filter(wl);
532 if (ret < 0)
533 return ret;
534
535 /* Beacons and broadcast settings */
536 ret = wl1271_init_beacon_broadcast(wl);
537 if (ret < 0)
538 return ret;
581 539
582int wl1271_hw_init(struct wl1271 *wl, struct ieee80211_vif *vif) 540 /* Configure rssi/snr averaging weights */
541 ret = wl1271_acx_rssi_snr_avg_weights(wl);
542 if (ret < 0)
543 return ret;
544
545 return 0;
546}
547
548/* vif-specific intialization */
549static int wl12xx_init_ap_role(struct wl1271 *wl, struct ieee80211_vif *vif)
550{
551 int ret;
552
553 ret = wl1271_acx_ap_max_tx_retry(wl);
554 if (ret < 0)
555 return ret;
556
557 /* initialize Tx power */
558 ret = wl1271_acx_tx_power(wl, wl->power_level);
559 if (ret < 0)
560 return ret;
561
562 return 0;
563}
564
565int wl1271_init_vif_specific(struct wl1271 *wl, struct ieee80211_vif *vif)
583{ 566{
584 struct conf_tx_ac_category *conf_ac; 567 struct conf_tx_ac_category *conf_ac;
585 struct conf_tx_tid *conf_tid; 568 struct conf_tx_tid *conf_tid;
586 int ret, i;
587 bool is_ap = (wl->bss_type == BSS_TYPE_AP_BSS); 569 bool is_ap = (wl->bss_type == BSS_TYPE_AP_BSS);
588 570
571 int ret, i;
572
573 /* Mode specific init */
574 if (is_ap) {
575 ret = wl1271_ap_hw_init(wl);
576 if (ret < 0)
577 return ret;
578
579 ret = wl12xx_init_ap_role(wl, vif);
580 if (ret < 0)
581 return ret;
582 } else {
583 ret = wl1271_sta_hw_init(wl);
584 if (ret < 0)
585 return ret;
586
587 ret = wl12xx_init_sta_role(wl, vif);
588 if (ret < 0)
589 return ret;
590 }
591
592 wl12xx_init_phy_vif_config(wl);
593
594 /* Default TID/AC configuration */
595 BUG_ON(wl->conf.tx.tid_conf_count != wl->conf.tx.ac_conf_count);
596 for (i = 0; i < wl->conf.tx.tid_conf_count; i++) {
597 conf_ac = &wl->conf.tx.ac_conf[i];
598 ret = wl1271_acx_ac_cfg(wl, conf_ac->ac, conf_ac->cw_min,
599 conf_ac->cw_max, conf_ac->aifsn,
600 conf_ac->tx_op_limit);
601 if (ret < 0)
602 return ret;
603
604 conf_tid = &wl->conf.tx.tid_conf[i];
605 ret = wl1271_acx_tid_cfg(wl,
606 conf_tid->queue_id,
607 conf_tid->channel_type,
608 conf_tid->tsid,
609 conf_tid->ps_scheme,
610 conf_tid->ack_policy,
611 conf_tid->apsd_conf[0],
612 conf_tid->apsd_conf[1]);
613 if (ret < 0)
614 return ret;
615 }
616
617 /* Configure HW encryption */
618 ret = wl1271_acx_feature_cfg(wl);
619 if (ret < 0)
620 return ret;
621
622 /* Mode specific init - post mem init */
623 if (is_ap)
624 ret = wl1271_ap_hw_init_post_mem(wl, vif);
625 else
626 ret = wl1271_sta_hw_init_post_mem(wl);
627
628 if (ret < 0)
629 return ret;
630
631 /* Configure initiator BA sessions policies */
632 ret = wl1271_set_ba_policies(wl);
633 if (ret < 0)
634 return ret;
635
636 return 0;
637}
638
639int wl1271_hw_init(struct wl1271 *wl)
640{
641 int ret;
642
589 if (wl->chip.id == CHIP_ID_1283_PG20) 643 if (wl->chip.id == CHIP_ID_1283_PG20)
590 ret = wl128x_cmd_general_parms(wl); 644 ret = wl128x_cmd_general_parms(wl);
591 else 645 else
@@ -605,12 +659,17 @@ int wl1271_hw_init(struct wl1271 *wl, struct ieee80211_vif *vif)
605 if (ret < 0) 659 if (ret < 0)
606 return ret; 660 return ret;
607 661
608 /* Mode specific init */ 662 /* Init templates */
609 if (is_ap) 663 ret = wl1271_init_templates_config(wl);
610 ret = wl1271_ap_hw_init(wl); 664 if (ret < 0)
611 else 665 return ret;
612 ret = wl1271_sta_hw_init(wl);
613 666
667 ret = wl12xx_acx_mem_cfg(wl);
668 if (ret < 0)
669 return ret;
670
671 /* Configure the FW logger */
672 ret = wl12xx_init_fwlog(wl);
614 if (ret < 0) 673 if (ret < 0)
615 return ret; 674 return ret;
616 675
@@ -658,61 +717,20 @@ int wl1271_hw_init(struct wl1271 *wl, struct ieee80211_vif *vif)
658 if (ret < 0) 717 if (ret < 0)
659 goto out_free_memmap; 718 goto out_free_memmap;
660 719
661 /* Default TID/AC configuration */
662 BUG_ON(wl->conf.tx.tid_conf_count != wl->conf.tx.ac_conf_count);
663 for (i = 0; i < wl->conf.tx.tid_conf_count; i++) {
664 conf_ac = &wl->conf.tx.ac_conf[i];
665 ret = wl1271_acx_ac_cfg(wl, conf_ac->ac, conf_ac->cw_min,
666 conf_ac->cw_max, conf_ac->aifsn,
667 conf_ac->tx_op_limit);
668 if (ret < 0)
669 goto out_free_memmap;
670
671 conf_tid = &wl->conf.tx.tid_conf[i];
672 ret = wl1271_acx_tid_cfg(wl, conf_tid->queue_id,
673 conf_tid->channel_type,
674 conf_tid->tsid,
675 conf_tid->ps_scheme,
676 conf_tid->ack_policy,
677 conf_tid->apsd_conf[0],
678 conf_tid->apsd_conf[1]);
679 if (ret < 0)
680 goto out_free_memmap;
681 }
682
683 /* Enable data path */ 720 /* Enable data path */
684 ret = wl1271_cmd_data_path(wl, 1); 721 ret = wl1271_cmd_data_path(wl, 1);
685 if (ret < 0) 722 if (ret < 0)
686 goto out_free_memmap; 723 goto out_free_memmap;
687 724
688 /* Configure HW encryption */
689 ret = wl1271_acx_feature_cfg(wl);
690 if (ret < 0)
691 goto out_free_memmap;
692
693 /* configure PM */ 725 /* configure PM */
694 ret = wl1271_acx_pm_config(wl); 726 ret = wl1271_acx_pm_config(wl);
695 if (ret < 0) 727 if (ret < 0)
696 goto out_free_memmap; 728 goto out_free_memmap;
697 729
698 /* Mode specific init - post mem init */
699 if (is_ap)
700 ret = wl1271_ap_hw_init_post_mem(wl, vif);
701 else
702 ret = wl1271_sta_hw_init_post_mem(wl);
703
704 if (ret < 0)
705 goto out_free_memmap;
706
707 ret = wl12xx_acx_set_rate_mgmt_params(wl); 730 ret = wl12xx_acx_set_rate_mgmt_params(wl);
708 if (ret < 0) 731 if (ret < 0)
709 goto out_free_memmap; 732 goto out_free_memmap;
710 733
711 /* Configure initiator BA sessions policies */
712 ret = wl1271_set_ba_policies(wl);
713 if (ret < 0)
714 goto out_free_memmap;
715
716 /* configure hangover */ 734 /* configure hangover */
717 ret = wl12xx_acx_config_hangover(wl); 735 ret = wl12xx_acx_config_hangover(wl);
718 if (ret < 0) 736 if (ret < 0)
diff --git a/drivers/net/wireless/wl12xx/init.h b/drivers/net/wireless/wl12xx/init.h
index b1f97bcc47c0..64320c0224ca 100644
--- a/drivers/net/wireless/wl12xx/init.h
+++ b/drivers/net/wireless/wl12xx/init.h
@@ -27,12 +27,13 @@
27#include "wl12xx.h" 27#include "wl12xx.h"
28 28
29int wl1271_hw_init_power_auth(struct wl1271 *wl); 29int wl1271_hw_init_power_auth(struct wl1271 *wl);
30int wl1271_sta_init_templates_config(struct wl1271 *wl); 30int wl1271_init_templates_config(struct wl1271 *wl);
31int wl1271_init_phy_config(struct wl1271 *wl); 31int wl1271_init_phy_config(struct wl1271 *wl);
32int wl1271_init_pta(struct wl1271 *wl); 32int wl1271_init_pta(struct wl1271 *wl);
33int wl1271_init_energy_detection(struct wl1271 *wl); 33int wl1271_init_energy_detection(struct wl1271 *wl);
34int wl1271_chip_specific_init(struct wl1271 *wl); 34int wl1271_chip_specific_init(struct wl1271 *wl);
35int wl1271_hw_init(struct wl1271 *wl, struct ieee80211_vif *vif); 35int wl1271_hw_init(struct wl1271 *wl);
36int wl1271_init_vif_specific(struct wl1271 *wl, struct ieee80211_vif *vif);
36int wl1271_init_ap_rates(struct wl1271 *wl); 37int wl1271_init_ap_rates(struct wl1271 *wl);
37int wl1271_ap_init_templates(struct wl1271 *wl, struct ieee80211_vif *vif); 38int wl1271_ap_init_templates(struct wl1271 *wl, struct ieee80211_vif *vif);
38 39
diff --git a/drivers/net/wireless/wl12xx/main.c b/drivers/net/wireless/wl12xx/main.c
index 652471e8c61b..901e43a8334b 100644
--- a/drivers/net/wireless/wl12xx/main.c
+++ b/drivers/net/wireless/wl12xx/main.c
@@ -676,7 +676,7 @@ static int wl1271_plt_init(struct wl1271 *wl)
676 if (ret < 0) 676 if (ret < 0)
677 return ret; 677 return ret;
678 678
679 ret = wl1271_sta_init_templates_config(wl); 679 ret = wl1271_init_templates_config(wl);
680 if (ret < 0) 680 if (ret < 0)
681 return ret; 681 return ret;
682 682
@@ -1919,6 +1919,10 @@ static int wl1271_op_add_interface(struct ieee80211_hw *hw,
1919 if (ret < 0) 1919 if (ret < 0)
1920 goto power_off; 1920 goto power_off;
1921 1921
1922 ret = wl1271_hw_init(wl);
1923 if (ret < 0)
1924 goto irq_disable;
1925
1922 if (wl->bss_type == BSS_TYPE_STA_BSS || 1926 if (wl->bss_type == BSS_TYPE_STA_BSS ||
1923 wl->bss_type == BSS_TYPE_IBSS) { 1927 wl->bss_type == BSS_TYPE_IBSS) {
1924 /* 1928 /*
@@ -1939,7 +1943,7 @@ static int wl1271_op_add_interface(struct ieee80211_hw *hw,
1939 if (ret < 0) 1943 if (ret < 0)
1940 goto irq_disable; 1944 goto irq_disable;
1941 1945
1942 ret = wl1271_hw_init(wl, vif); 1946 ret = wl1271_init_vif_specific(wl, vif);
1943 if (ret < 0) 1947 if (ret < 0)
1944 goto irq_disable; 1948 goto irq_disable;
1945 1949