104
static int wl1271_ap_init_deauth_template(struct wl1271 *wl)
106
struct wl12xx_disconn_template *tmpl;
109
tmpl = kzalloc(sizeof(*tmpl), GFP_KERNEL);
115
tmpl->header.frame_ctl = cpu_to_le16(IEEE80211_FTYPE_MGMT |
116
IEEE80211_STYPE_DEAUTH);
118
ret = wl1271_cmd_template_set(wl, CMD_TEMPL_DEAUTH_AP,
119
tmpl, sizeof(*tmpl), 0,
120
wl1271_tx_min_rate_get(wl));
127
static int wl1271_ap_init_null_template(struct wl1271 *wl)
129
struct ieee80211_hdr_3addr *nullfunc;
132
nullfunc = kzalloc(sizeof(*nullfunc), GFP_KERNEL);
138
nullfunc->frame_control = cpu_to_le16(IEEE80211_FTYPE_DATA |
139
IEEE80211_STYPE_NULLFUNC |
140
IEEE80211_FCTL_FROMDS);
142
/* nullfunc->addr1 is filled by FW */
144
memcpy(nullfunc->addr2, wl->mac_addr, ETH_ALEN);
145
memcpy(nullfunc->addr3, wl->mac_addr, ETH_ALEN);
147
ret = wl1271_cmd_template_set(wl, CMD_TEMPL_NULL_DATA, nullfunc,
148
sizeof(*nullfunc), 0,
149
wl1271_tx_min_rate_get(wl));
156
static int wl1271_ap_init_qos_null_template(struct wl1271 *wl)
158
struct ieee80211_qos_hdr *qosnull;
161
qosnull = kzalloc(sizeof(*qosnull), GFP_KERNEL);
167
qosnull->frame_control = cpu_to_le16(IEEE80211_FTYPE_DATA |
168
IEEE80211_STYPE_QOS_NULLFUNC |
169
IEEE80211_FCTL_FROMDS);
171
/* qosnull->addr1 is filled by FW */
173
memcpy(qosnull->addr2, wl->mac_addr, ETH_ALEN);
174
memcpy(qosnull->addr3, wl->mac_addr, ETH_ALEN);
176
ret = wl1271_cmd_template_set(wl, CMD_TEMPL_QOS_NULL_DATA, qosnull,
178
wl1271_tx_min_rate_get(wl));
185
static int wl1271_ap_init_templates_config(struct wl1271 *wl)
190
* Put very large empty placeholders for all templates. These
191
* reserve memory for later.
193
ret = wl1271_cmd_template_set(wl, CMD_TEMPL_AP_PROBE_RESPONSE, NULL,
195
(struct wl12xx_probe_resp_template),
196
0, WL1271_RATE_AUTOMATIC);
200
ret = wl1271_cmd_template_set(wl, CMD_TEMPL_AP_BEACON, NULL,
202
(struct wl12xx_beacon_template),
203
0, WL1271_RATE_AUTOMATIC);
207
ret = wl1271_cmd_template_set(wl, CMD_TEMPL_DEAUTH_AP, NULL,
209
(struct wl12xx_disconn_template),
210
0, WL1271_RATE_AUTOMATIC);
214
ret = wl1271_cmd_template_set(wl, CMD_TEMPL_NULL_DATA, NULL,
215
sizeof(struct wl12xx_null_data_template),
216
0, WL1271_RATE_AUTOMATIC);
220
ret = wl1271_cmd_template_set(wl, CMD_TEMPL_QOS_NULL_DATA, NULL,
222
(struct wl12xx_qos_null_data_template),
223
0, WL1271_RATE_AUTOMATIC);
121
230
static int wl1271_init_rx_config(struct wl1271 *wl, u32 config, u32 filter)
324
static int wl1271_sta_hw_init(struct wl1271 *wl)
328
if (wl->chip.id != CHIP_ID_1283_PG20) {
329
ret = wl1271_cmd_ext_radio_parms(wl);
335
ret = wl1271_acx_config_ps(wl);
339
ret = wl1271_sta_init_templates_config(wl);
343
ret = wl1271_acx_group_address_tbl(wl, true, NULL, 0);
347
/* Initialize connection monitoring thresholds */
348
ret = wl1271_acx_conn_monit_params(wl, false);
352
/* Beacon filtering */
353
ret = wl1271_init_beacon_filter(wl);
357
/* FM WLAN coexistence */
358
ret = wl1271_acx_fm_coex(wl);
362
/* Beacons and broadcast settings */
363
ret = wl1271_init_beacon_broadcast(wl);
367
/* Configure for ELP power saving */
368
ret = wl1271_acx_sleep_auth(wl, WL1271_PSM_ELP);
372
/* Configure rssi/snr averaging weights */
373
ret = wl1271_acx_rssi_snr_avg_weights(wl);
377
ret = wl1271_acx_sta_rate_policies(wl);
381
ret = wl1271_acx_sta_mem_cfg(wl);
388
static int wl1271_sta_hw_init_post_mem(struct wl1271 *wl)
392
ret = wl1271_cmd_set_sta_default_wep_key(wl, wl->default_key);
394
wl1271_warning("couldn't set default key");
398
/* disable all keep-alive templates */
399
for (i = 0; i < CMD_TEMPL_KLV_IDX_MAX; i++) {
400
ret = wl1271_acx_keep_alive_config(wl, i,
401
ACX_KEEP_ALIVE_TPL_INVALID);
406
/* disable the keep-alive feature */
407
ret = wl1271_acx_keep_alive_mode(wl, false);
414
static int wl1271_ap_hw_init(struct wl1271 *wl)
418
ret = wl1271_ap_init_templates_config(wl);
422
/* Configure for power always on */
423
ret = wl1271_acx_sleep_auth(wl, WL1271_PSM_CAM);
427
ret = wl1271_init_ap_rates(wl);
431
ret = wl1271_acx_max_tx_retry(wl);
435
ret = wl1271_acx_ap_mem_cfg(wl);
442
int wl1271_ap_init_templates(struct wl1271 *wl)
446
ret = wl1271_ap_init_deauth_template(wl);
450
ret = wl1271_ap_init_null_template(wl);
454
ret = wl1271_ap_init_qos_null_template(wl);
459
* when operating as AP we want to receive external beacons for
460
* configuring ERP protection.
462
ret = wl1271_acx_set_ap_beacon_filter(wl, false);
469
static int wl1271_ap_hw_init_post_mem(struct wl1271 *wl)
471
return wl1271_ap_init_templates(wl);
474
int wl1271_init_ap_rates(struct wl1271 *wl)
477
struct conf_tx_rate_class rc;
480
wl1271_debug(DEBUG_AP, "AP basic rate set: 0x%x", wl->basic_rate_set);
482
if (wl->basic_rate_set == 0)
485
rc.enabled_rates = wl->basic_rate_set;
486
rc.long_retry_limit = 10;
487
rc.short_retry_limit = 10;
489
ret = wl1271_acx_ap_rate_policy(wl, &rc, ACX_TX_AP_MODE_MGMT_RATE);
493
/* use the min basic rate for AP broadcast/multicast */
494
rc.enabled_rates = wl1271_tx_min_rate_get(wl);
495
rc.short_retry_limit = 10;
496
rc.long_retry_limit = 10;
498
ret = wl1271_acx_ap_rate_policy(wl, &rc, ACX_TX_AP_MODE_BCST_RATE);
503
* If the basic rates contain OFDM rates, use OFDM only
504
* rates for unicast TX as well. Else use all supported rates.
506
if ((wl->basic_rate_set & CONF_TX_OFDM_RATES))
507
supported_rates = CONF_TX_OFDM_RATES;
509
supported_rates = CONF_TX_AP_ENABLED_RATES;
511
/* configure unicast TX rate classes */
512
for (i = 0; i < wl->conf.tx.ac_conf_count; i++) {
513
rc.enabled_rates = supported_rates;
514
rc.short_retry_limit = 10;
515
rc.long_retry_limit = 10;
517
ret = wl1271_acx_ap_rate_policy(wl, &rc, i);
525
static void wl1271_check_ba_support(struct wl1271 *wl)
527
/* validate FW cose ver x.x.x.50-60.x */
528
if ((wl->chip.fw_ver[3] >= WL12XX_BA_SUPPORT_FW_COST_VER2_START) &&
529
(wl->chip.fw_ver[3] < WL12XX_BA_SUPPORT_FW_COST_VER2_END)) {
530
wl->ba_support = true;
534
wl->ba_support = false;
537
static int wl1271_set_ba_policies(struct wl1271 *wl)
542
/* Reset the BA RX indicators */
543
wl->ba_rx_bitmap = 0;
545
/* validate that FW support BA */
546
wl1271_check_ba_support(wl);
549
/* 802.11n initiator BA session setting */
550
for (tid_index = 0; tid_index < CONF_TX_MAX_TID_COUNT;
552
ret = wl1271_acx_set_ba_session(wl, WLAN_BACK_INITIATOR,
561
int wl1271_chip_specific_init(struct wl1271 *wl)
565
if (wl->chip.id == CHIP_ID_1283_PG20) {
566
u32 host_cfg_bitmap = HOST_IF_CFG_RX_FIFO_ENABLE;
568
if (wl->quirks & WL12XX_QUIRK_BLOCKSIZE_ALIGNMENT)
569
/* Enable SDIO padding */
570
host_cfg_bitmap |= HOST_IF_CFG_TX_PAD_TO_SDIO_BLK;
572
/* Must be before wl1271_acx_init_mem_config() */
573
ret = wl1271_acx_host_if_cfg_bitmap(wl, host_cfg_bitmap);
216
582
int wl1271_hw_init(struct wl1271 *wl)
218
584
struct conf_tx_ac_category *conf_ac;
219
585
struct conf_tx_tid *conf_tid;
222
ret = wl1271_cmd_general_parms(wl);
226
ret = wl1271_cmd_radio_parms(wl);
230
ret = wl1271_cmd_ext_radio_parms(wl);
234
/* Template settings */
235
ret = wl1271_init_templates_config(wl);
587
bool is_ap = (wl->bss_type == BSS_TYPE_AP_BSS);
589
if (wl->chip.id == CHIP_ID_1283_PG20)
590
ret = wl128x_cmd_general_parms(wl);
592
ret = wl1271_cmd_general_parms(wl);
596
if (wl->chip.id == CHIP_ID_1283_PG20)
597
ret = wl128x_cmd_radio_parms(wl);
599
ret = wl1271_cmd_radio_parms(wl);
603
/* Chip-specific init */
604
ret = wl1271_chip_specific_init(wl);
608
/* Mode specific init */
610
ret = wl1271_ap_hw_init(wl);
612
ret = wl1271_sta_hw_init(wl);
617
/* Bluetooth WLAN coexistence */
618
ret = wl1271_init_pta(wl);