]>
Commit | Line | Data |
---|---|---|
0ac0d6ce CL |
1 | /* |
2 | * mac80211 glue code for mac80211 Prism54 drivers | |
3 | * | |
4 | * Copyright (c) 2006, Michael Wu <flamingice@sourmilk.net> | |
5 | * Copyright (c) 2007-2009, Christian Lamparter <chunkeey@web.de> | |
6 | * Copyright 2008, Johannes Berg <johannes@sipsolutions.net> | |
7 | * | |
8 | * Based on: | |
9 | * - the islsm (softmac prism54) driver, which is: | |
10 | * Copyright 2004-2006 Jean-Baptiste Note <jbnote@gmail.com>, et al. | |
11 | * - stlc45xx driver | |
12 | * Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies). | |
13 | * | |
14 | * This program is free software; you can redistribute it and/or modify | |
15 | * it under the terms of the GNU General Public License version 2 as | |
16 | * published by the Free Software Foundation. | |
17 | */ | |
18 | ||
19 | #include <linux/init.h> | |
20 | #include <linux/firmware.h> | |
21 | #include <linux/etherdevice.h> | |
22 | ||
23 | #include <net/mac80211.h> | |
24 | ||
25 | #include "p54.h" | |
26 | #include "lmac.h" | |
27 | ||
28 | static int modparam_nohwcrypt; | |
29 | module_param_named(nohwcrypt, modparam_nohwcrypt, bool, S_IRUGO); | |
30 | MODULE_PARM_DESC(nohwcrypt, "Disable hardware encryption."); | |
31 | MODULE_AUTHOR("Michael Wu <flamingice@sourmilk.net>"); | |
32 | MODULE_DESCRIPTION("Softmac Prism54 common code"); | |
33 | MODULE_LICENSE("GPL"); | |
34 | MODULE_ALIAS("prism54common"); | |
35 | ||
36 | static void p54_sta_notify(struct ieee80211_hw *dev, struct ieee80211_vif *vif, | |
37 | enum sta_notify_cmd notify_cmd, | |
38 | struct ieee80211_sta *sta) | |
39 | { | |
40 | struct p54_common *priv = dev->priv; | |
41 | switch (notify_cmd) { | |
42 | case STA_NOTIFY_ADD: | |
43 | case STA_NOTIFY_REMOVE: | |
44 | /* | |
45 | * Notify the firmware that we don't want or we don't | |
46 | * need to buffer frames for this station anymore. | |
47 | */ | |
48 | ||
49 | p54_sta_unlock(priv, sta->addr); | |
50 | break; | |
51 | case STA_NOTIFY_AWAKE: | |
52 | /* update the firmware's filter table */ | |
53 | p54_sta_unlock(priv, sta->addr); | |
54 | break; | |
55 | default: | |
56 | break; | |
57 | } | |
58 | } | |
59 | ||
60 | static int p54_set_tim(struct ieee80211_hw *dev, struct ieee80211_sta *sta, | |
61 | bool set) | |
62 | { | |
63 | struct p54_common *priv = dev->priv; | |
64 | ||
65 | return p54_update_beacon_tim(priv, sta->aid, set); | |
66 | } | |
67 | ||
e0f114e8 | 68 | u8 *p54_find_ie(struct sk_buff *skb, u8 ie) |
0ac0d6ce | 69 | { |
0ac0d6ce CL |
70 | struct ieee80211_mgmt *mgmt = (void *)skb->data; |
71 | u8 *pos, *end; | |
72 | ||
73 | if (skb->len <= sizeof(mgmt)) | |
e0f114e8 | 74 | return NULL; |
0ac0d6ce CL |
75 | |
76 | pos = (u8 *)mgmt->u.beacon.variable; | |
77 | end = skb->data + skb->len; | |
78 | while (pos < end) { | |
79 | if (pos + 2 + pos[1] > end) | |
e0f114e8 | 80 | return NULL; |
0ac0d6ce | 81 | |
e0f114e8 CL |
82 | if (pos[0] == ie) |
83 | return pos; | |
0ac0d6ce | 84 | |
e0f114e8 CL |
85 | pos += 2 + pos[1]; |
86 | } | |
87 | return NULL; | |
88 | } | |
0ac0d6ce | 89 | |
e0f114e8 CL |
90 | static int p54_beacon_format_ie_tim(struct sk_buff *skb) |
91 | { | |
92 | /* | |
93 | * the good excuse for this mess is ... the firmware. | |
94 | * The dummy TIM MUST be at the end of the beacon frame, | |
95 | * because it'll be overwritten! | |
96 | */ | |
97 | u8 *tim; | |
98 | u8 dtim_len; | |
99 | u8 dtim_period; | |
100 | u8 *next; | |
0ac0d6ce | 101 | |
e0f114e8 CL |
102 | tim = p54_find_ie(skb, WLAN_EID_TIM); |
103 | if (!tim) | |
104 | return 0; | |
0ac0d6ce | 105 | |
e0f114e8 CL |
106 | dtim_len = tim[1]; |
107 | dtim_period = tim[3]; | |
108 | next = tim + 2 + dtim_len; | |
109 | ||
110 | if (dtim_len < 3) | |
111 | return -EINVAL; | |
112 | ||
113 | memmove(tim, next, skb_tail_pointer(skb) - next); | |
114 | tim = skb_tail_pointer(skb) - (dtim_len + 2); | |
115 | ||
116 | /* add the dummy at the end */ | |
117 | tim[0] = WLAN_EID_TIM; | |
118 | tim[1] = 3; | |
119 | tim[2] = 0; | |
120 | tim[3] = dtim_period; | |
121 | tim[4] = 0; | |
122 | ||
123 | if (dtim_len > 3) | |
124 | skb_trim(skb, skb->len - (dtim_len - 3)); | |
0ac0d6ce | 125 | |
0ac0d6ce CL |
126 | return 0; |
127 | } | |
128 | ||
129 | static int p54_beacon_update(struct p54_common *priv, | |
130 | struct ieee80211_vif *vif) | |
131 | { | |
132 | struct sk_buff *beacon; | |
0ac0d6ce CL |
133 | int ret; |
134 | ||
135 | beacon = ieee80211_beacon_get(priv->hw, vif); | |
136 | if (!beacon) | |
137 | return -ENOMEM; | |
138 | ret = p54_beacon_format_ie_tim(beacon); | |
139 | if (ret) | |
140 | return ret; | |
141 | ||
46df10ae CL |
142 | /* |
143 | * During operation, the firmware takes care of beaconing. | |
144 | * The driver only needs to upload a new beacon template, once | |
145 | * the template was changed by the stack or userspace. | |
146 | * | |
147 | * LMAC API 3.2.2 also specifies that the driver does not need | |
148 | * to cancel the old beacon template by hand, instead the firmware | |
149 | * will release the previous one through the feedback mechanism. | |
150 | */ | |
151 | WARN_ON(p54_tx_80211(priv->hw, beacon)); | |
0ac0d6ce CL |
152 | priv->tsf_high32 = 0; |
153 | priv->tsf_low32 = 0; | |
154 | ||
155 | return 0; | |
156 | } | |
157 | ||
158 | static int p54_start(struct ieee80211_hw *dev) | |
159 | { | |
160 | struct p54_common *priv = dev->priv; | |
161 | int err; | |
162 | ||
163 | mutex_lock(&priv->conf_mutex); | |
164 | err = priv->open(dev); | |
165 | if (err) | |
166 | goto out; | |
167 | P54_SET_QUEUE(priv->qos_params[0], 0x0002, 0x0003, 0x0007, 47); | |
168 | P54_SET_QUEUE(priv->qos_params[1], 0x0002, 0x0007, 0x000f, 94); | |
169 | P54_SET_QUEUE(priv->qos_params[2], 0x0003, 0x000f, 0x03ff, 0); | |
170 | P54_SET_QUEUE(priv->qos_params[3], 0x0007, 0x000f, 0x03ff, 0); | |
171 | err = p54_set_edcf(priv); | |
172 | if (err) | |
173 | goto out; | |
174 | ||
175 | memset(priv->bssid, ~0, ETH_ALEN); | |
176 | priv->mode = NL80211_IFTYPE_MONITOR; | |
177 | err = p54_setup_mac(priv); | |
178 | if (err) { | |
179 | priv->mode = NL80211_IFTYPE_UNSPECIFIED; | |
180 | goto out; | |
181 | } | |
182 | ||
42935eca | 183 | ieee80211_queue_delayed_work(dev, &priv->work, 0); |
0ac0d6ce CL |
184 | |
185 | priv->softled_state = 0; | |
186 | err = p54_set_leds(priv); | |
187 | ||
188 | out: | |
189 | mutex_unlock(&priv->conf_mutex); | |
190 | return err; | |
191 | } | |
192 | ||
193 | static void p54_stop(struct ieee80211_hw *dev) | |
194 | { | |
195 | struct p54_common *priv = dev->priv; | |
196 | int i; | |
197 | ||
198 | mutex_lock(&priv->conf_mutex); | |
199 | priv->mode = NL80211_IFTYPE_UNSPECIFIED; | |
200 | priv->softled_state = 0; | |
201 | p54_set_leds(priv); | |
202 | ||
203 | cancel_delayed_work_sync(&priv->work); | |
204 | ||
205 | priv->stop(dev); | |
206 | skb_queue_purge(&priv->tx_pending); | |
207 | skb_queue_purge(&priv->tx_queue); | |
208 | for (i = 0; i < P54_QUEUE_NUM; i++) { | |
209 | priv->tx_stats[i].count = 0; | |
210 | priv->tx_stats[i].len = 0; | |
211 | } | |
212 | ||
213 | priv->beacon_req_id = cpu_to_le32(0); | |
214 | priv->tsf_high32 = priv->tsf_low32 = 0; | |
215 | mutex_unlock(&priv->conf_mutex); | |
216 | } | |
217 | ||
218 | static int p54_add_interface(struct ieee80211_hw *dev, | |
1ed32e4f | 219 | struct ieee80211_vif *vif) |
0ac0d6ce CL |
220 | { |
221 | struct p54_common *priv = dev->priv; | |
222 | ||
223 | mutex_lock(&priv->conf_mutex); | |
224 | if (priv->mode != NL80211_IFTYPE_MONITOR) { | |
225 | mutex_unlock(&priv->conf_mutex); | |
226 | return -EOPNOTSUPP; | |
227 | } | |
228 | ||
1ed32e4f | 229 | priv->vif = vif; |
0ac0d6ce | 230 | |
1ed32e4f | 231 | switch (vif->type) { |
0ac0d6ce CL |
232 | case NL80211_IFTYPE_STATION: |
233 | case NL80211_IFTYPE_ADHOC: | |
234 | case NL80211_IFTYPE_AP: | |
235 | case NL80211_IFTYPE_MESH_POINT: | |
1ed32e4f | 236 | priv->mode = vif->type; |
0ac0d6ce CL |
237 | break; |
238 | default: | |
239 | mutex_unlock(&priv->conf_mutex); | |
240 | return -EOPNOTSUPP; | |
241 | } | |
242 | ||
1ed32e4f | 243 | memcpy(priv->mac_addr, vif->addr, ETH_ALEN); |
0ac0d6ce CL |
244 | p54_setup_mac(priv); |
245 | mutex_unlock(&priv->conf_mutex); | |
246 | return 0; | |
247 | } | |
248 | ||
249 | static void p54_remove_interface(struct ieee80211_hw *dev, | |
1ed32e4f | 250 | struct ieee80211_vif *vif) |
0ac0d6ce CL |
251 | { |
252 | struct p54_common *priv = dev->priv; | |
253 | ||
254 | mutex_lock(&priv->conf_mutex); | |
255 | priv->vif = NULL; | |
46df10ae CL |
256 | |
257 | /* | |
258 | * LMAC API 3.2.2 states that any active beacon template must be | |
259 | * canceled by the driver before attempting a mode transition. | |
260 | */ | |
261 | if (le32_to_cpu(priv->beacon_req_id) != 0) { | |
0ac0d6ce | 262 | p54_tx_cancel(priv, priv->beacon_req_id); |
46df10ae | 263 | wait_for_completion_interruptible_timeout(&priv->beacon_comp, HZ); |
0ac0d6ce CL |
264 | } |
265 | priv->mode = NL80211_IFTYPE_MONITOR; | |
266 | memset(priv->mac_addr, 0, ETH_ALEN); | |
267 | memset(priv->bssid, 0, ETH_ALEN); | |
268 | p54_setup_mac(priv); | |
269 | mutex_unlock(&priv->conf_mutex); | |
270 | } | |
271 | ||
272 | static int p54_config(struct ieee80211_hw *dev, u32 changed) | |
273 | { | |
274 | int ret = 0; | |
275 | struct p54_common *priv = dev->priv; | |
276 | struct ieee80211_conf *conf = &dev->conf; | |
277 | ||
278 | mutex_lock(&priv->conf_mutex); | |
279 | if (changed & IEEE80211_CONF_CHANGE_POWER) | |
280 | priv->output_power = conf->power_level << 2; | |
281 | if (changed & IEEE80211_CONF_CHANGE_CHANNEL) { | |
282 | ret = p54_scan(priv, P54_SCAN_EXIT, 0); | |
283 | if (ret) | |
284 | goto out; | |
285 | } | |
286 | if (changed & IEEE80211_CONF_CHANGE_PS) { | |
287 | ret = p54_set_ps(priv); | |
288 | if (ret) | |
289 | goto out; | |
290 | } | |
6208f8b2 CL |
291 | if (changed & IEEE80211_CONF_CHANGE_IDLE) { |
292 | ret = p54_setup_mac(priv); | |
293 | if (ret) | |
294 | goto out; | |
295 | } | |
0ac0d6ce CL |
296 | |
297 | out: | |
298 | mutex_unlock(&priv->conf_mutex); | |
299 | return ret; | |
300 | } | |
301 | ||
302 | static void p54_configure_filter(struct ieee80211_hw *dev, | |
303 | unsigned int changed_flags, | |
304 | unsigned int *total_flags, | |
3ac64bee | 305 | u64 multicast) |
0ac0d6ce CL |
306 | { |
307 | struct p54_common *priv = dev->priv; | |
308 | ||
309 | *total_flags &= FIF_PROMISC_IN_BSS | | |
310 | FIF_OTHER_BSS; | |
311 | ||
312 | priv->filter_flags = *total_flags; | |
313 | ||
314 | if (changed_flags & (FIF_PROMISC_IN_BSS | FIF_OTHER_BSS)) | |
315 | p54_setup_mac(priv); | |
316 | } | |
317 | ||
318 | static int p54_conf_tx(struct ieee80211_hw *dev, u16 queue, | |
319 | const struct ieee80211_tx_queue_params *params) | |
320 | { | |
321 | struct p54_common *priv = dev->priv; | |
322 | int ret; | |
323 | ||
324 | mutex_lock(&priv->conf_mutex); | |
718126a7 | 325 | if (queue < dev->queues) { |
0ac0d6ce CL |
326 | P54_SET_QUEUE(priv->qos_params[queue], params->aifs, |
327 | params->cw_min, params->cw_max, params->txop); | |
328 | ret = p54_set_edcf(priv); | |
329 | } else | |
330 | ret = -EINVAL; | |
331 | mutex_unlock(&priv->conf_mutex); | |
332 | return ret; | |
333 | } | |
334 | ||
335 | static void p54_work(struct work_struct *work) | |
336 | { | |
337 | struct p54_common *priv = container_of(work, struct p54_common, | |
338 | work.work); | |
339 | ||
340 | if (unlikely(priv->mode == NL80211_IFTYPE_UNSPECIFIED)) | |
341 | return ; | |
342 | ||
343 | /* | |
344 | * TODO: walk through tx_queue and do the following tasks | |
345 | * 1. initiate bursts. | |
346 | * 2. cancel stuck frames / reset the device if necessary. | |
347 | */ | |
348 | ||
349 | p54_fetch_statistics(priv); | |
350 | } | |
351 | ||
352 | static int p54_get_stats(struct ieee80211_hw *dev, | |
353 | struct ieee80211_low_level_stats *stats) | |
354 | { | |
355 | struct p54_common *priv = dev->priv; | |
356 | ||
357 | memcpy(stats, &priv->stats, sizeof(*stats)); | |
358 | return 0; | |
359 | } | |
360 | ||
0ac0d6ce CL |
361 | static void p54_bss_info_changed(struct ieee80211_hw *dev, |
362 | struct ieee80211_vif *vif, | |
363 | struct ieee80211_bss_conf *info, | |
364 | u32 changed) | |
365 | { | |
366 | struct p54_common *priv = dev->priv; | |
367 | ||
368 | mutex_lock(&priv->conf_mutex); | |
369 | if (changed & BSS_CHANGED_BSSID) { | |
370 | memcpy(priv->bssid, info->bssid, ETH_ALEN); | |
371 | p54_setup_mac(priv); | |
372 | } | |
373 | ||
374 | if (changed & BSS_CHANGED_BEACON) { | |
375 | p54_scan(priv, P54_SCAN_EXIT, 0); | |
376 | p54_setup_mac(priv); | |
377 | p54_beacon_update(priv, vif); | |
378 | p54_set_edcf(priv); | |
379 | } | |
380 | ||
381 | if (changed & (BSS_CHANGED_ERP_SLOT | BSS_CHANGED_BEACON)) { | |
382 | priv->use_short_slot = info->use_short_slot; | |
383 | p54_set_edcf(priv); | |
384 | } | |
385 | if (changed & BSS_CHANGED_BASIC_RATES) { | |
386 | if (dev->conf.channel->band == IEEE80211_BAND_5GHZ) | |
387 | priv->basic_rate_mask = (info->basic_rates << 4); | |
388 | else | |
389 | priv->basic_rate_mask = info->basic_rates; | |
390 | p54_setup_mac(priv); | |
391 | if (priv->fw_var >= 0x500) | |
392 | p54_scan(priv, P54_SCAN_EXIT, 0); | |
393 | } | |
394 | if (changed & BSS_CHANGED_ASSOC) { | |
395 | if (info->assoc) { | |
396 | priv->aid = info->aid; | |
397 | priv->wakeup_timer = info->beacon_int * | |
398 | info->dtim_period * 5; | |
399 | p54_setup_mac(priv); | |
e0f114e8 CL |
400 | } else { |
401 | priv->wakeup_timer = 500; | |
402 | priv->aid = 0; | |
0ac0d6ce CL |
403 | } |
404 | } | |
405 | ||
406 | mutex_unlock(&priv->conf_mutex); | |
407 | } | |
408 | ||
409 | static int p54_set_key(struct ieee80211_hw *dev, enum set_key_cmd cmd, | |
410 | struct ieee80211_vif *vif, struct ieee80211_sta *sta, | |
411 | struct ieee80211_key_conf *key) | |
412 | { | |
413 | struct p54_common *priv = dev->priv; | |
414 | int slot, ret = 0; | |
415 | u8 algo = 0; | |
416 | u8 *addr = NULL; | |
417 | ||
418 | if (modparam_nohwcrypt) | |
419 | return -EOPNOTSUPP; | |
420 | ||
421 | mutex_lock(&priv->conf_mutex); | |
422 | if (cmd == SET_KEY) { | |
423 | switch (key->alg) { | |
424 | case ALG_TKIP: | |
425 | if (!(priv->privacy_caps & (BR_DESC_PRIV_CAP_MICHAEL | | |
426 | BR_DESC_PRIV_CAP_TKIP))) { | |
427 | ret = -EOPNOTSUPP; | |
428 | goto out_unlock; | |
429 | } | |
430 | key->flags |= IEEE80211_KEY_FLAG_GENERATE_IV; | |
431 | algo = P54_CRYPTO_TKIPMICHAEL; | |
432 | break; | |
433 | case ALG_WEP: | |
434 | if (!(priv->privacy_caps & BR_DESC_PRIV_CAP_WEP)) { | |
435 | ret = -EOPNOTSUPP; | |
436 | goto out_unlock; | |
437 | } | |
438 | key->flags |= IEEE80211_KEY_FLAG_GENERATE_IV; | |
439 | algo = P54_CRYPTO_WEP; | |
440 | break; | |
441 | case ALG_CCMP: | |
442 | if (!(priv->privacy_caps & BR_DESC_PRIV_CAP_AESCCMP)) { | |
443 | ret = -EOPNOTSUPP; | |
444 | goto out_unlock; | |
445 | } | |
446 | key->flags |= IEEE80211_KEY_FLAG_GENERATE_IV; | |
447 | algo = P54_CRYPTO_AESCCMP; | |
448 | break; | |
449 | default: | |
450 | ret = -EOPNOTSUPP; | |
451 | goto out_unlock; | |
452 | } | |
453 | slot = bitmap_find_free_region(priv->used_rxkeys, | |
454 | priv->rx_keycache_size, 0); | |
455 | ||
456 | if (slot < 0) { | |
457 | /* | |
458 | * The device supports the choosen algorithm, but the | |
459 | * firmware does not provide enough key slots to store | |
460 | * all of them. | |
461 | * But encryption offload for outgoing frames is always | |
462 | * possible, so we just pretend that the upload was | |
463 | * successful and do the decryption in software. | |
464 | */ | |
465 | ||
466 | /* mark the key as invalid. */ | |
467 | key->hw_key_idx = 0xff; | |
468 | goto out_unlock; | |
469 | } | |
470 | } else { | |
471 | slot = key->hw_key_idx; | |
472 | ||
473 | if (slot == 0xff) { | |
474 | /* This key was not uploaded into the rx key cache. */ | |
475 | ||
476 | goto out_unlock; | |
477 | } | |
478 | ||
479 | bitmap_release_region(priv->used_rxkeys, slot, 0); | |
480 | algo = 0; | |
481 | } | |
482 | ||
483 | if (sta) | |
484 | addr = sta->addr; | |
485 | ||
486 | ret = p54_upload_key(priv, algo, slot, key->keyidx, | |
487 | key->keylen, addr, key->key); | |
488 | if (ret) { | |
489 | bitmap_release_region(priv->used_rxkeys, slot, 0); | |
490 | ret = -EOPNOTSUPP; | |
491 | goto out_unlock; | |
492 | } | |
493 | ||
494 | key->hw_key_idx = slot; | |
495 | ||
496 | out_unlock: | |
497 | mutex_unlock(&priv->conf_mutex); | |
498 | return ret; | |
499 | } | |
500 | ||
501 | static const struct ieee80211_ops p54_ops = { | |
502 | .tx = p54_tx_80211, | |
503 | .start = p54_start, | |
504 | .stop = p54_stop, | |
505 | .add_interface = p54_add_interface, | |
506 | .remove_interface = p54_remove_interface, | |
507 | .set_tim = p54_set_tim, | |
508 | .sta_notify = p54_sta_notify, | |
509 | .set_key = p54_set_key, | |
510 | .config = p54_config, | |
511 | .bss_info_changed = p54_bss_info_changed, | |
512 | .configure_filter = p54_configure_filter, | |
513 | .conf_tx = p54_conf_tx, | |
514 | .get_stats = p54_get_stats, | |
0ac0d6ce CL |
515 | }; |
516 | ||
517 | struct ieee80211_hw *p54_init_common(size_t priv_data_len) | |
518 | { | |
519 | struct ieee80211_hw *dev; | |
520 | struct p54_common *priv; | |
521 | ||
522 | dev = ieee80211_alloc_hw(priv_data_len, &p54_ops); | |
523 | if (!dev) | |
524 | return NULL; | |
525 | ||
526 | priv = dev->priv; | |
527 | priv->hw = dev; | |
528 | priv->mode = NL80211_IFTYPE_UNSPECIFIED; | |
529 | priv->basic_rate_mask = 0x15f; | |
530 | spin_lock_init(&priv->tx_stats_lock); | |
531 | skb_queue_head_init(&priv->tx_queue); | |
532 | skb_queue_head_init(&priv->tx_pending); | |
533 | dev->flags = IEEE80211_HW_RX_INCLUDES_FCS | | |
534 | IEEE80211_HW_SIGNAL_DBM | | |
e0f114e8 CL |
535 | IEEE80211_HW_SUPPORTS_PS | |
536 | IEEE80211_HW_PS_NULLFUNC_STACK | | |
537 | IEEE80211_HW_BEACON_FILTER | | |
0ac0d6ce CL |
538 | IEEE80211_HW_NOISE_DBM; |
539 | ||
540 | dev->wiphy->interface_modes = BIT(NL80211_IFTYPE_STATION) | | |
541 | BIT(NL80211_IFTYPE_ADHOC) | | |
542 | BIT(NL80211_IFTYPE_AP) | | |
543 | BIT(NL80211_IFTYPE_MESH_POINT); | |
544 | ||
545 | dev->channel_change_time = 1000; /* TODO: find actual value */ | |
46df10ae | 546 | priv->beacon_req_id = cpu_to_le32(0); |
0ac0d6ce CL |
547 | priv->tx_stats[P54_QUEUE_BEACON].limit = 1; |
548 | priv->tx_stats[P54_QUEUE_FWSCAN].limit = 1; | |
549 | priv->tx_stats[P54_QUEUE_MGMT].limit = 3; | |
550 | priv->tx_stats[P54_QUEUE_CAB].limit = 3; | |
551 | priv->tx_stats[P54_QUEUE_DATA].limit = 5; | |
552 | dev->queues = 1; | |
553 | priv->noise = -94; | |
554 | /* | |
555 | * We support at most 8 tries no matter which rate they're at, | |
556 | * we cannot support max_rates * max_rate_tries as we set it | |
557 | * here, but setting it correctly to 4/2 or so would limit us | |
558 | * artificially if the RC algorithm wants just two rates, so | |
559 | * let's say 4/7, we'll redistribute it at TX time, see the | |
560 | * comments there. | |
561 | */ | |
562 | dev->max_rates = 4; | |
563 | dev->max_rate_tries = 7; | |
564 | dev->extra_tx_headroom = sizeof(struct p54_hdr) + 4 + | |
565 | sizeof(struct p54_tx_data); | |
566 | ||
c46aaba7 CL |
567 | /* |
568 | * For now, disable PS by default because it affects | |
569 | * link stability significantly. | |
570 | */ | |
5be83de5 | 571 | dev->wiphy->flags &= ~WIPHY_FLAG_PS_ON_BY_DEFAULT; |
c46aaba7 | 572 | |
0ac0d6ce CL |
573 | mutex_init(&priv->conf_mutex); |
574 | mutex_init(&priv->eeprom_mutex); | |
575 | init_completion(&priv->eeprom_comp); | |
46df10ae | 576 | init_completion(&priv->beacon_comp); |
0ac0d6ce CL |
577 | INIT_DELAYED_WORK(&priv->work, p54_work); |
578 | ||
579 | return dev; | |
580 | } | |
581 | EXPORT_SYMBOL_GPL(p54_init_common); | |
582 | ||
583 | int p54_register_common(struct ieee80211_hw *dev, struct device *pdev) | |
584 | { | |
585 | struct p54_common *priv = dev->priv; | |
586 | int err; | |
587 | ||
588 | err = ieee80211_register_hw(dev); | |
589 | if (err) { | |
590 | dev_err(pdev, "Cannot register device (%d).\n", err); | |
591 | return err; | |
592 | } | |
593 | ||
594 | #ifdef CONFIG_P54_LEDS | |
595 | err = p54_init_leds(priv); | |
596 | if (err) | |
597 | return err; | |
598 | #endif /* CONFIG_P54_LEDS */ | |
599 | ||
600 | dev_info(pdev, "is registered as '%s'\n", wiphy_name(dev->wiphy)); | |
601 | return 0; | |
602 | } | |
603 | EXPORT_SYMBOL_GPL(p54_register_common); | |
604 | ||
605 | void p54_free_common(struct ieee80211_hw *dev) | |
606 | { | |
607 | struct p54_common *priv = dev->priv; | |
1a9b6679 CL |
608 | unsigned int i; |
609 | ||
610 | for (i = 0; i < IEEE80211_NUM_BANDS; i++) | |
611 | kfree(priv->band_table[i]); | |
0ac0d6ce CL |
612 | |
613 | kfree(priv->iq_autocal); | |
614 | kfree(priv->output_limit); | |
615 | kfree(priv->curve_data); | |
616 | kfree(priv->used_rxkeys); | |
617 | priv->iq_autocal = NULL; | |
618 | priv->output_limit = NULL; | |
619 | priv->curve_data = NULL; | |
620 | priv->used_rxkeys = NULL; | |
621 | ieee80211_free_hw(dev); | |
622 | } | |
623 | EXPORT_SYMBOL_GPL(p54_free_common); | |
624 | ||
625 | void p54_unregister_common(struct ieee80211_hw *dev) | |
626 | { | |
627 | struct p54_common *priv = dev->priv; | |
628 | ||
629 | #ifdef CONFIG_P54_LEDS | |
630 | p54_unregister_leds(priv); | |
631 | #endif /* CONFIG_P54_LEDS */ | |
632 | ||
633 | ieee80211_unregister_hw(dev); | |
634 | mutex_destroy(&priv->conf_mutex); | |
635 | mutex_destroy(&priv->eeprom_mutex); | |
636 | } | |
637 | EXPORT_SYMBOL_GPL(p54_unregister_common); |