diff options
Diffstat (limited to 'drivers/net/wireless/wl12xx/init.c')
-rw-r--r-- | drivers/net/wireless/wl12xx/init.c | 491 |
1 files changed, 257 insertions, 234 deletions
diff --git a/drivers/net/wireless/wl12xx/init.c b/drivers/net/wireless/wl12xx/init.c index 04db64c94e9a..ca7ee59e4505 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 | ||
36 | int wl1271_sta_init_templates_config(struct wl1271 *wl) | 37 | int 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 | ||
102 | static int wl1271_ap_init_deauth_template(struct wl1271 *wl) | 126 | static 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 | ||
126 | static int wl1271_ap_init_null_template(struct wl1271 *wl) | 151 | static 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 | ||
156 | static int wl1271_ap_init_qos_null_template(struct wl1271 *wl) | 183 | static 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,49 +212,6 @@ out: | |||
183 | return ret; | 212 | return ret; |
184 | } | 213 | } |
185 | 214 | ||
186 | static int wl1271_ap_init_templates_config(struct wl1271 *wl) | ||
187 | { | ||
188 | int ret; | ||
189 | |||
190 | /* | ||
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) | ||
224 | return ret; | ||
225 | |||
226 | return 0; | ||
227 | } | ||
228 | |||
229 | static int wl12xx_init_rx_config(struct wl1271 *wl) | 215 | static int wl12xx_init_rx_config(struct wl1271 *wl) |
230 | { | 216 | { |
231 | int ret; | 217 | int ret; |
@@ -237,39 +223,37 @@ static int wl12xx_init_rx_config(struct wl1271 *wl) | |||
237 | return 0; | 223 | return 0; |
238 | } | 224 | } |
239 | 225 | ||
240 | int wl1271_init_phy_config(struct wl1271 *wl) | 226 | static int wl12xx_init_phy_vif_config(struct wl1271 *wl, |
227 | struct wl12xx_vif *wlvif) | ||
241 | { | 228 | { |
242 | int ret; | 229 | int ret; |
243 | 230 | ||
244 | ret = wl1271_acx_pd_threshold(wl); | 231 | 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) | 232 | if (ret < 0) |
250 | return ret; | 233 | return ret; |
251 | 234 | ||
252 | ret = wl1271_acx_service_period_timeout(wl); | 235 | ret = wl1271_acx_service_period_timeout(wl, wlvif); |
253 | if (ret < 0) | 236 | if (ret < 0) |
254 | return ret; | 237 | return ret; |
255 | 238 | ||
256 | ret = wl1271_acx_rts_threshold(wl, wl->hw->wiphy->rts_threshold); | 239 | ret = wl1271_acx_rts_threshold(wl, wlvif, wl->hw->wiphy->rts_threshold); |
257 | if (ret < 0) | 240 | if (ret < 0) |
258 | return ret; | 241 | return ret; |
259 | 242 | ||
260 | return 0; | 243 | return 0; |
261 | } | 244 | } |
262 | 245 | ||
263 | static int wl1271_init_beacon_filter(struct wl1271 *wl) | 246 | static int wl1271_init_sta_beacon_filter(struct wl1271 *wl, |
247 | struct wl12xx_vif *wlvif) | ||
264 | { | 248 | { |
265 | int ret; | 249 | int ret; |
266 | 250 | ||
267 | /* disable beacon filtering at this stage */ | 251 | ret = wl1271_acx_beacon_filter_table(wl, wlvif); |
268 | ret = wl1271_acx_beacon_filter_opt(wl, false); | ||
269 | if (ret < 0) | 252 | if (ret < 0) |
270 | return ret; | 253 | return ret; |
271 | 254 | ||
272 | ret = wl1271_acx_beacon_filter_table(wl); | 255 | /* enable beacon filtering */ |
256 | ret = wl1271_acx_beacon_filter_opt(wl, wlvif, true); | ||
273 | if (ret < 0) | 257 | if (ret < 0) |
274 | return ret; | 258 | return ret; |
275 | 259 | ||
@@ -302,11 +286,12 @@ int wl1271_init_energy_detection(struct wl1271 *wl) | |||
302 | return 0; | 286 | return 0; |
303 | } | 287 | } |
304 | 288 | ||
305 | static int wl1271_init_beacon_broadcast(struct wl1271 *wl) | 289 | static int wl1271_init_beacon_broadcast(struct wl1271 *wl, |
290 | struct wl12xx_vif *wlvif) | ||
306 | { | 291 | { |
307 | int ret; | 292 | int ret; |
308 | 293 | ||
309 | ret = wl1271_acx_bcn_dtim_options(wl); | 294 | ret = wl1271_acx_bcn_dtim_options(wl, wlvif); |
310 | if (ret < 0) | 295 | if (ret < 0) |
311 | return ret; | 296 | return ret; |
312 | 297 | ||
@@ -327,36 +312,13 @@ static int wl12xx_init_fwlog(struct wl1271 *wl) | |||
327 | return 0; | 312 | return 0; |
328 | } | 313 | } |
329 | 314 | ||
330 | static int wl1271_sta_hw_init(struct wl1271 *wl) | 315 | /* generic sta initialization (non vif-specific) */ |
316 | static int wl1271_sta_hw_init(struct wl1271 *wl, struct wl12xx_vif *wlvif) | ||
331 | { | 317 | { |
332 | int ret; | 318 | int ret; |
333 | 319 | ||
334 | if (wl->chip.id != CHIP_ID_1283_PG20) { | ||
335 | ret = wl1271_cmd_ext_radio_parms(wl); | ||
336 | if (ret < 0) | ||
337 | return ret; | ||
338 | } | ||
339 | |||
340 | /* PS config */ | 320 | /* PS config */ |
341 | ret = wl1271_acx_config_ps(wl); | 321 | 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) | 322 | if (ret < 0) |
361 | return ret; | 323 | return ret; |
362 | 324 | ||
@@ -365,103 +327,61 @@ static int wl1271_sta_hw_init(struct wl1271 *wl) | |||
365 | if (ret < 0) | 327 | if (ret < 0) |
366 | return ret; | 328 | return ret; |
367 | 329 | ||
368 | /* Beacons and broadcast settings */ | 330 | 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) | 331 | if (ret < 0) |
394 | return ret; | 332 | return ret; |
395 | 333 | ||
396 | return 0; | 334 | return 0; |
397 | } | 335 | } |
398 | 336 | ||
399 | static int wl1271_sta_hw_init_post_mem(struct wl1271 *wl) | 337 | static int wl1271_sta_hw_init_post_mem(struct wl1271 *wl, |
338 | struct ieee80211_vif *vif) | ||
400 | { | 339 | { |
340 | struct wl12xx_vif *wlvif = wl12xx_vif_to_data(vif); | ||
401 | int ret, i; | 341 | int ret, i; |
402 | 342 | ||
403 | /* disable all keep-alive templates */ | 343 | /* disable all keep-alive templates */ |
404 | for (i = 0; i < CMD_TEMPL_KLV_IDX_MAX; i++) { | 344 | for (i = 0; i < CMD_TEMPL_KLV_IDX_MAX; i++) { |
405 | ret = wl1271_acx_keep_alive_config(wl, i, | 345 | ret = wl1271_acx_keep_alive_config(wl, wlvif, i, |
406 | ACX_KEEP_ALIVE_TPL_INVALID); | 346 | ACX_KEEP_ALIVE_TPL_INVALID); |
407 | if (ret < 0) | 347 | if (ret < 0) |
408 | return ret; | 348 | return ret; |
409 | } | 349 | } |
410 | 350 | ||
411 | /* disable the keep-alive feature */ | 351 | /* disable the keep-alive feature */ |
412 | ret = wl1271_acx_keep_alive_mode(wl, false); | 352 | ret = wl1271_acx_keep_alive_mode(wl, wlvif, false); |
413 | if (ret < 0) | 353 | if (ret < 0) |
414 | return ret; | 354 | return ret; |
415 | 355 | ||
416 | return 0; | 356 | return 0; |
417 | } | 357 | } |
418 | 358 | ||
419 | static int wl1271_ap_hw_init(struct wl1271 *wl) | 359 | /* generic ap initialization (non vif-specific) */ |
360 | static int wl1271_ap_hw_init(struct wl1271 *wl, struct wl12xx_vif *wlvif) | ||
420 | { | 361 | { |
421 | int ret; | 362 | int ret; |
422 | 363 | ||
423 | ret = wl1271_ap_init_templates_config(wl); | 364 | 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) | 365 | if (ret < 0) |
447 | return ret; | 366 | return ret; |
448 | 367 | ||
449 | return 0; | 368 | return 0; |
450 | } | 369 | } |
451 | 370 | ||
452 | int wl1271_ap_init_templates(struct wl1271 *wl) | 371 | int wl1271_ap_init_templates(struct wl1271 *wl, struct ieee80211_vif *vif) |
453 | { | 372 | { |
373 | struct wl12xx_vif *wlvif = wl12xx_vif_to_data(vif); | ||
454 | int ret; | 374 | int ret; |
455 | 375 | ||
456 | ret = wl1271_ap_init_deauth_template(wl); | 376 | ret = wl1271_ap_init_deauth_template(wl, wlvif); |
457 | if (ret < 0) | 377 | if (ret < 0) |
458 | return ret; | 378 | return ret; |
459 | 379 | ||
460 | ret = wl1271_ap_init_null_template(wl); | 380 | ret = wl1271_ap_init_null_template(wl, vif); |
461 | if (ret < 0) | 381 | if (ret < 0) |
462 | return ret; | 382 | return ret; |
463 | 383 | ||
464 | ret = wl1271_ap_init_qos_null_template(wl); | 384 | ret = wl1271_ap_init_qos_null_template(wl, vif); |
465 | if (ret < 0) | 385 | if (ret < 0) |
466 | return ret; | 386 | return ret; |
467 | 387 | ||
@@ -469,43 +389,45 @@ int wl1271_ap_init_templates(struct wl1271 *wl) | |||
469 | * when operating as AP we want to receive external beacons for | 389 | * when operating as AP we want to receive external beacons for |
470 | * configuring ERP protection. | 390 | * configuring ERP protection. |
471 | */ | 391 | */ |
472 | ret = wl1271_acx_beacon_filter_opt(wl, false); | 392 | ret = wl1271_acx_beacon_filter_opt(wl, wlvif, false); |
473 | if (ret < 0) | 393 | if (ret < 0) |
474 | return ret; | 394 | return ret; |
475 | 395 | ||
476 | return 0; | 396 | return 0; |
477 | } | 397 | } |
478 | 398 | ||
479 | static int wl1271_ap_hw_init_post_mem(struct wl1271 *wl) | 399 | static int wl1271_ap_hw_init_post_mem(struct wl1271 *wl, |
400 | struct ieee80211_vif *vif) | ||
480 | { | 401 | { |
481 | return wl1271_ap_init_templates(wl); | 402 | return wl1271_ap_init_templates(wl, vif); |
482 | } | 403 | } |
483 | 404 | ||
484 | int wl1271_init_ap_rates(struct wl1271 *wl) | 405 | int wl1271_init_ap_rates(struct wl1271 *wl, struct wl12xx_vif *wlvif) |
485 | { | 406 | { |
486 | int i, ret; | 407 | int i, ret; |
487 | struct conf_tx_rate_class rc; | 408 | struct conf_tx_rate_class rc; |
488 | u32 supported_rates; | 409 | u32 supported_rates; |
489 | 410 | ||
490 | wl1271_debug(DEBUG_AP, "AP basic rate set: 0x%x", wl->basic_rate_set); | 411 | wl1271_debug(DEBUG_AP, "AP basic rate set: 0x%x", |
412 | wlvif->basic_rate_set); | ||
491 | 413 | ||
492 | if (wl->basic_rate_set == 0) | 414 | if (wlvif->basic_rate_set == 0) |
493 | return -EINVAL; | 415 | return -EINVAL; |
494 | 416 | ||
495 | rc.enabled_rates = wl->basic_rate_set; | 417 | rc.enabled_rates = wlvif->basic_rate_set; |
496 | rc.long_retry_limit = 10; | 418 | rc.long_retry_limit = 10; |
497 | rc.short_retry_limit = 10; | 419 | rc.short_retry_limit = 10; |
498 | rc.aflags = 0; | 420 | rc.aflags = 0; |
499 | ret = wl1271_acx_ap_rate_policy(wl, &rc, ACX_TX_AP_MODE_MGMT_RATE); | 421 | ret = wl1271_acx_ap_rate_policy(wl, &rc, wlvif->ap.mgmt_rate_idx); |
500 | if (ret < 0) | 422 | if (ret < 0) |
501 | return ret; | 423 | return ret; |
502 | 424 | ||
503 | /* use the min basic rate for AP broadcast/multicast */ | 425 | /* use the min basic rate for AP broadcast/multicast */ |
504 | rc.enabled_rates = wl1271_tx_min_rate_get(wl, wl->basic_rate_set); | 426 | rc.enabled_rates = wl1271_tx_min_rate_get(wl, wlvif->basic_rate_set); |
505 | rc.short_retry_limit = 10; | 427 | rc.short_retry_limit = 10; |
506 | rc.long_retry_limit = 10; | 428 | rc.long_retry_limit = 10; |
507 | rc.aflags = 0; | 429 | rc.aflags = 0; |
508 | ret = wl1271_acx_ap_rate_policy(wl, &rc, ACX_TX_AP_MODE_BCST_RATE); | 430 | ret = wl1271_acx_ap_rate_policy(wl, &rc, wlvif->ap.bcast_rate_idx); |
509 | if (ret < 0) | 431 | if (ret < 0) |
510 | return ret; | 432 | return ret; |
511 | 433 | ||
@@ -513,7 +435,7 @@ int wl1271_init_ap_rates(struct wl1271 *wl) | |||
513 | * If the basic rates contain OFDM rates, use OFDM only | 435 | * If the basic rates contain OFDM rates, use OFDM only |
514 | * rates for unicast TX as well. Else use all supported rates. | 436 | * rates for unicast TX as well. Else use all supported rates. |
515 | */ | 437 | */ |
516 | if ((wl->basic_rate_set & CONF_TX_OFDM_RATES)) | 438 | if ((wlvif->basic_rate_set & CONF_TX_OFDM_RATES)) |
517 | supported_rates = CONF_TX_OFDM_RATES; | 439 | supported_rates = CONF_TX_OFDM_RATES; |
518 | else | 440 | else |
519 | supported_rates = CONF_TX_AP_ENABLED_RATES; | 441 | supported_rates = CONF_TX_AP_ENABLED_RATES; |
@@ -527,7 +449,8 @@ int wl1271_init_ap_rates(struct wl1271 *wl) | |||
527 | rc.short_retry_limit = 10; | 449 | rc.short_retry_limit = 10; |
528 | rc.long_retry_limit = 10; | 450 | rc.long_retry_limit = 10; |
529 | rc.aflags = 0; | 451 | rc.aflags = 0; |
530 | ret = wl1271_acx_ap_rate_policy(wl, &rc, i); | 452 | ret = wl1271_acx_ap_rate_policy(wl, &rc, |
453 | wlvif->ap.ucast_rate_idx[i]); | ||
531 | if (ret < 0) | 454 | if (ret < 0) |
532 | return ret; | 455 | return ret; |
533 | } | 456 | } |
@@ -535,24 +458,23 @@ int wl1271_init_ap_rates(struct wl1271 *wl) | |||
535 | return 0; | 458 | return 0; |
536 | } | 459 | } |
537 | 460 | ||
538 | static int wl1271_set_ba_policies(struct wl1271 *wl) | 461 | static int wl1271_set_ba_policies(struct wl1271 *wl, struct wl12xx_vif *wlvif) |
539 | { | 462 | { |
540 | /* Reset the BA RX indicators */ | 463 | /* Reset the BA RX indicators */ |
541 | wl->ba_rx_bitmap = 0; | 464 | wlvif->ba_allowed = true; |
542 | wl->ba_allowed = true; | ||
543 | wl->ba_rx_session_count = 0; | 465 | wl->ba_rx_session_count = 0; |
544 | 466 | ||
545 | /* BA is supported in STA/AP modes */ | 467 | /* BA is supported in STA/AP modes */ |
546 | if (wl->bss_type != BSS_TYPE_AP_BSS && | 468 | if (wlvif->bss_type != BSS_TYPE_AP_BSS && |
547 | wl->bss_type != BSS_TYPE_STA_BSS) { | 469 | wlvif->bss_type != BSS_TYPE_STA_BSS) { |
548 | wl->ba_support = false; | 470 | wlvif->ba_support = false; |
549 | return 0; | 471 | return 0; |
550 | } | 472 | } |
551 | 473 | ||
552 | wl->ba_support = true; | 474 | wlvif->ba_support = true; |
553 | 475 | ||
554 | /* 802.11n initiator BA session setting */ | 476 | /* 802.11n initiator BA session setting */ |
555 | return wl12xx_acx_set_ba_initiator_policy(wl); | 477 | return wl12xx_acx_set_ba_initiator_policy(wl, wlvif); |
556 | } | 478 | } |
557 | 479 | ||
558 | int wl1271_chip_specific_init(struct wl1271 *wl) | 480 | int wl1271_chip_specific_init(struct wl1271 *wl) |
@@ -562,7 +484,7 @@ int wl1271_chip_specific_init(struct wl1271 *wl) | |||
562 | if (wl->chip.id == CHIP_ID_1283_PG20) { | 484 | if (wl->chip.id == CHIP_ID_1283_PG20) { |
563 | u32 host_cfg_bitmap = HOST_IF_CFG_RX_FIFO_ENABLE; | 485 | u32 host_cfg_bitmap = HOST_IF_CFG_RX_FIFO_ENABLE; |
564 | 486 | ||
565 | if (wl->quirks & WL12XX_QUIRK_BLOCKSIZE_ALIGNMENT) | 487 | if (!(wl->quirks & WL12XX_QUIRK_NO_BLOCKSIZE_ALIGNMENT)) |
566 | /* Enable SDIO padding */ | 488 | /* Enable SDIO padding */ |
567 | host_cfg_bitmap |= HOST_IF_CFG_TX_PAD_TO_SDIO_BLK; | 489 | host_cfg_bitmap |= HOST_IF_CFG_TX_PAD_TO_SDIO_BLK; |
568 | 490 | ||
@@ -575,39 +497,186 @@ out: | |||
575 | return ret; | 497 | return ret; |
576 | } | 498 | } |
577 | 499 | ||
500 | /* vif-specifc initialization */ | ||
501 | static int wl12xx_init_sta_role(struct wl1271 *wl, struct wl12xx_vif *wlvif) | ||
502 | { | ||
503 | int ret; | ||
578 | 504 | ||
579 | int wl1271_hw_init(struct wl1271 *wl) | 505 | ret = wl1271_acx_group_address_tbl(wl, wlvif, true, NULL, 0); |
506 | if (ret < 0) | ||
507 | return ret; | ||
508 | |||
509 | /* Initialize connection monitoring thresholds */ | ||
510 | ret = wl1271_acx_conn_monit_params(wl, wlvif, false); | ||
511 | if (ret < 0) | ||
512 | return ret; | ||
513 | |||
514 | /* Beacon filtering */ | ||
515 | ret = wl1271_init_sta_beacon_filter(wl, wlvif); | ||
516 | if (ret < 0) | ||
517 | return ret; | ||
518 | |||
519 | /* Beacons and broadcast settings */ | ||
520 | ret = wl1271_init_beacon_broadcast(wl, wlvif); | ||
521 | if (ret < 0) | ||
522 | return ret; | ||
523 | |||
524 | /* Configure rssi/snr averaging weights */ | ||
525 | ret = wl1271_acx_rssi_snr_avg_weights(wl, wlvif); | ||
526 | if (ret < 0) | ||
527 | return ret; | ||
528 | |||
529 | return 0; | ||
530 | } | ||
531 | |||
532 | /* vif-specific intialization */ | ||
533 | static int wl12xx_init_ap_role(struct wl1271 *wl, struct wl12xx_vif *wlvif) | ||
580 | { | 534 | { |
535 | int ret; | ||
536 | |||
537 | ret = wl1271_acx_ap_max_tx_retry(wl, wlvif); | ||
538 | if (ret < 0) | ||
539 | return ret; | ||
540 | |||
541 | /* initialize Tx power */ | ||
542 | ret = wl1271_acx_tx_power(wl, wlvif, wlvif->power_level); | ||
543 | if (ret < 0) | ||
544 | return ret; | ||
545 | |||
546 | return 0; | ||
547 | } | ||
548 | |||
549 | int wl1271_init_vif_specific(struct wl1271 *wl, struct ieee80211_vif *vif) | ||
550 | { | ||
551 | struct wl12xx_vif *wlvif = wl12xx_vif_to_data(vif); | ||
581 | struct conf_tx_ac_category *conf_ac; | 552 | struct conf_tx_ac_category *conf_ac; |
582 | struct conf_tx_tid *conf_tid; | 553 | struct conf_tx_tid *conf_tid; |
554 | bool is_ap = (wlvif->bss_type == BSS_TYPE_AP_BSS); | ||
583 | int ret, i; | 555 | int ret, i; |
584 | bool is_ap = (wl->bss_type == BSS_TYPE_AP_BSS); | ||
585 | 556 | ||
586 | if (wl->chip.id == CHIP_ID_1283_PG20) | 557 | /* |
587 | ret = wl128x_cmd_general_parms(wl); | 558 | * consider all existing roles before configuring psm. |
588 | else | 559 | * TODO: reconfigure on interface removal. |
589 | ret = wl1271_cmd_general_parms(wl); | 560 | */ |
561 | if (!wl->ap_count) { | ||
562 | if (is_ap) { | ||
563 | /* Configure for power always on */ | ||
564 | ret = wl1271_acx_sleep_auth(wl, WL1271_PSM_CAM); | ||
565 | if (ret < 0) | ||
566 | return ret; | ||
567 | } else if (!wl->sta_count) { | ||
568 | /* Configure for ELP power saving */ | ||
569 | ret = wl1271_acx_sleep_auth(wl, WL1271_PSM_ELP); | ||
570 | if (ret < 0) | ||
571 | return ret; | ||
572 | } | ||
573 | } | ||
574 | |||
575 | /* Mode specific init */ | ||
576 | if (is_ap) { | ||
577 | ret = wl1271_ap_hw_init(wl, wlvif); | ||
578 | if (ret < 0) | ||
579 | return ret; | ||
580 | |||
581 | ret = wl12xx_init_ap_role(wl, wlvif); | ||
582 | if (ret < 0) | ||
583 | return ret; | ||
584 | } else { | ||
585 | ret = wl1271_sta_hw_init(wl, wlvif); | ||
586 | if (ret < 0) | ||
587 | return ret; | ||
588 | |||
589 | ret = wl12xx_init_sta_role(wl, wlvif); | ||
590 | if (ret < 0) | ||
591 | return ret; | ||
592 | } | ||
593 | |||
594 | wl12xx_init_phy_vif_config(wl, wlvif); | ||
595 | |||
596 | /* Default TID/AC configuration */ | ||
597 | BUG_ON(wl->conf.tx.tid_conf_count != wl->conf.tx.ac_conf_count); | ||
598 | for (i = 0; i < wl->conf.tx.tid_conf_count; i++) { | ||
599 | conf_ac = &wl->conf.tx.ac_conf[i]; | ||
600 | ret = wl1271_acx_ac_cfg(wl, wlvif, conf_ac->ac, | ||
601 | conf_ac->cw_min, conf_ac->cw_max, | ||
602 | conf_ac->aifsn, conf_ac->tx_op_limit); | ||
603 | if (ret < 0) | ||
604 | return ret; | ||
605 | |||
606 | conf_tid = &wl->conf.tx.tid_conf[i]; | ||
607 | ret = wl1271_acx_tid_cfg(wl, wlvif, | ||
608 | conf_tid->queue_id, | ||
609 | conf_tid->channel_type, | ||
610 | conf_tid->tsid, | ||
611 | conf_tid->ps_scheme, | ||
612 | conf_tid->ack_policy, | ||
613 | conf_tid->apsd_conf[0], | ||
614 | conf_tid->apsd_conf[1]); | ||
615 | if (ret < 0) | ||
616 | return ret; | ||
617 | } | ||
618 | |||
619 | /* Configure HW encryption */ | ||
620 | ret = wl1271_acx_feature_cfg(wl, wlvif); | ||
590 | if (ret < 0) | 621 | if (ret < 0) |
591 | return ret; | 622 | return ret; |
592 | 623 | ||
593 | if (wl->chip.id == CHIP_ID_1283_PG20) | 624 | /* Mode specific init - post mem init */ |
594 | ret = wl128x_cmd_radio_parms(wl); | 625 | if (is_ap) |
626 | ret = wl1271_ap_hw_init_post_mem(wl, vif); | ||
595 | else | 627 | else |
596 | ret = wl1271_cmd_radio_parms(wl); | 628 | ret = wl1271_sta_hw_init_post_mem(wl, vif); |
629 | |||
630 | if (ret < 0) | ||
631 | return ret; | ||
632 | |||
633 | /* Configure initiator BA sessions policies */ | ||
634 | ret = wl1271_set_ba_policies(wl, wlvif); | ||
597 | if (ret < 0) | 635 | if (ret < 0) |
598 | return ret; | 636 | return ret; |
599 | 637 | ||
638 | return 0; | ||
639 | } | ||
640 | |||
641 | int wl1271_hw_init(struct wl1271 *wl) | ||
642 | { | ||
643 | int ret; | ||
644 | |||
645 | if (wl->chip.id == CHIP_ID_1283_PG20) { | ||
646 | ret = wl128x_cmd_general_parms(wl); | ||
647 | if (ret < 0) | ||
648 | return ret; | ||
649 | ret = wl128x_cmd_radio_parms(wl); | ||
650 | if (ret < 0) | ||
651 | return ret; | ||
652 | } else { | ||
653 | ret = wl1271_cmd_general_parms(wl); | ||
654 | if (ret < 0) | ||
655 | return ret; | ||
656 | ret = wl1271_cmd_radio_parms(wl); | ||
657 | if (ret < 0) | ||
658 | return ret; | ||
659 | ret = wl1271_cmd_ext_radio_parms(wl); | ||
660 | if (ret < 0) | ||
661 | return ret; | ||
662 | } | ||
663 | |||
600 | /* Chip-specific init */ | 664 | /* Chip-specific init */ |
601 | ret = wl1271_chip_specific_init(wl); | 665 | ret = wl1271_chip_specific_init(wl); |
602 | if (ret < 0) | 666 | if (ret < 0) |
603 | return ret; | 667 | return ret; |
604 | 668 | ||
605 | /* Mode specific init */ | 669 | /* Init templates */ |
606 | if (is_ap) | 670 | ret = wl1271_init_templates_config(wl); |
607 | ret = wl1271_ap_hw_init(wl); | 671 | if (ret < 0) |
608 | else | 672 | return ret; |
609 | ret = wl1271_sta_hw_init(wl); | 673 | |
674 | ret = wl12xx_acx_mem_cfg(wl); | ||
675 | if (ret < 0) | ||
676 | return ret; | ||
610 | 677 | ||
678 | /* Configure the FW logger */ | ||
679 | ret = wl12xx_init_fwlog(wl); | ||
611 | if (ret < 0) | 680 | if (ret < 0) |
612 | return ret; | 681 | return ret; |
613 | 682 | ||
@@ -626,11 +695,6 @@ int wl1271_hw_init(struct wl1271 *wl) | |||
626 | if (ret < 0) | 695 | if (ret < 0) |
627 | goto out_free_memmap; | 696 | goto out_free_memmap; |
628 | 697 | ||
629 | /* PHY layer config */ | ||
630 | ret = wl1271_init_phy_config(wl); | ||
631 | if (ret < 0) | ||
632 | goto out_free_memmap; | ||
633 | |||
634 | ret = wl1271_acx_dco_itrim_params(wl); | 698 | ret = wl1271_acx_dco_itrim_params(wl); |
635 | if (ret < 0) | 699 | if (ret < 0) |
636 | goto out_free_memmap; | 700 | goto out_free_memmap; |
@@ -655,61 +719,20 @@ int wl1271_hw_init(struct wl1271 *wl) | |||
655 | if (ret < 0) | 719 | if (ret < 0) |
656 | goto out_free_memmap; | 720 | goto out_free_memmap; |
657 | 721 | ||
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 */ | 722 | /* Enable data path */ |
681 | ret = wl1271_cmd_data_path(wl, 1); | 723 | ret = wl1271_cmd_data_path(wl, 1); |
682 | if (ret < 0) | 724 | if (ret < 0) |
683 | goto out_free_memmap; | 725 | goto out_free_memmap; |
684 | 726 | ||
685 | /* Configure HW encryption */ | ||
686 | ret = wl1271_acx_feature_cfg(wl); | ||
687 | if (ret < 0) | ||
688 | goto out_free_memmap; | ||
689 | |||
690 | /* configure PM */ | 727 | /* configure PM */ |
691 | ret = wl1271_acx_pm_config(wl); | 728 | ret = wl1271_acx_pm_config(wl); |
692 | if (ret < 0) | 729 | if (ret < 0) |
693 | goto out_free_memmap; | 730 | goto out_free_memmap; |
694 | 731 | ||
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); | 732 | ret = wl12xx_acx_set_rate_mgmt_params(wl); |
705 | if (ret < 0) | 733 | if (ret < 0) |
706 | goto out_free_memmap; | 734 | goto out_free_memmap; |
707 | 735 | ||
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 */ | 736 | /* configure hangover */ |
714 | ret = wl12xx_acx_config_hangover(wl); | 737 | ret = wl12xx_acx_config_hangover(wl); |
715 | if (ret < 0) | 738 | if (ret < 0) |