mac80211: fix scan band off-by-one error
[deliverable/linux.git] / net / mac80211 / ieee80211.c
CommitLineData
f0706e82
JB
1/*
2 * Copyright 2002-2005, Instant802 Networks, Inc.
3 * Copyright 2005-2006, Devicescape Software, Inc.
4 * Copyright 2006-2007 Jiri Benc <jbenc@suse.cz>
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 as
8 * published by the Free Software Foundation.
9 */
10
11#include <net/mac80211.h>
12#include <net/ieee80211_radiotap.h>
13#include <linux/module.h>
14#include <linux/init.h>
15#include <linux/netdevice.h>
16#include <linux/types.h>
17#include <linux/slab.h>
18#include <linux/skbuff.h>
19#include <linux/etherdevice.h>
20#include <linux/if_arp.h>
21#include <linux/wireless.h>
22#include <linux/rtnetlink.h>
f0706e82 23#include <linux/bitmap.h>
881d966b 24#include <net/net_namespace.h>
f0706e82
JB
25#include <net/cfg80211.h>
26
f0706e82
JB
27#include "ieee80211_i.h"
28#include "ieee80211_rate.h"
29#include "wep.h"
f0706e82
JB
30#include "wme.h"
31#include "aes_ccm.h"
32#include "ieee80211_led.h"
e0eb6859 33#include "cfg.h"
e9f207f0
JB
34#include "debugfs.h"
35#include "debugfs_netdev.h"
f0706e82 36
d3c990fb
RR
37#define SUPP_MCS_SET_LEN 16
38
b306f453
JB
39/*
40 * For seeing transmitted packets on monitor interfaces
41 * we have a radiotap header too.
42 */
43struct ieee80211_tx_status_rtap_hdr {
44 struct ieee80211_radiotap_header hdr;
45 __le16 tx_flags;
46 u8 data_retries;
47} __attribute__ ((packed));
48
b2c258fb 49/* common interface routines */
b306f453 50
b95cce35 51static int header_parse_80211(const struct sk_buff *skb, unsigned char *haddr)
b2c258fb
JB
52{
53 memcpy(haddr, skb_mac_header(skb) + 10, ETH_ALEN); /* addr2 */
54 return ETH_ALEN;
55}
f0706e82 56
4150c572
JB
57/* must be called under mdev tx lock */
58static void ieee80211_configure_filter(struct ieee80211_local *local)
59{
60 unsigned int changed_flags;
61 unsigned int new_flags = 0;
62
53918994 63 if (atomic_read(&local->iff_promiscs))
4150c572
JB
64 new_flags |= FIF_PROMISC_IN_BSS;
65
53918994 66 if (atomic_read(&local->iff_allmultis))
4150c572
JB
67 new_flags |= FIF_ALLMULTI;
68
69 if (local->monitors)
70 new_flags |= FIF_CONTROL |
71 FIF_OTHER_BSS |
72 FIF_BCN_PRBRESP_PROMISC;
73
74 changed_flags = local->filter_flags ^ new_flags;
75
76 /* be a bit nasty */
77 new_flags |= (1<<31);
78
79 local->ops->configure_filter(local_to_hw(local),
80 changed_flags, &new_flags,
81 local->mdev->mc_count,
82 local->mdev->mc_list);
83
84 WARN_ON(new_flags & (1<<31));
85
86 local->filter_flags = new_flags & ~(1<<31);
87}
88
b2c258fb 89/* master interface */
f0706e82 90
b2c258fb
JB
91static int ieee80211_master_open(struct net_device *dev)
92{
93 struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr);
94 struct ieee80211_sub_if_data *sdata;
95 int res = -EOPNOTSUPP;
f0706e82 96
79010420
JB
97 /* we hold the RTNL here so can safely walk the list */
98 list_for_each_entry(sdata, &local->interfaces, list) {
b2c258fb
JB
99 if (sdata->dev != dev && netif_running(sdata->dev)) {
100 res = 0;
101 break;
102 }
103 }
b2c258fb
JB
104 return res;
105}
f0706e82 106
b2c258fb 107static int ieee80211_master_stop(struct net_device *dev)
f0706e82 108{
b2c258fb
JB
109 struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr);
110 struct ieee80211_sub_if_data *sdata;
f0706e82 111
79010420
JB
112 /* we hold the RTNL here so can safely walk the list */
113 list_for_each_entry(sdata, &local->interfaces, list)
b2c258fb
JB
114 if (sdata->dev != dev && netif_running(sdata->dev))
115 dev_close(sdata->dev);
f0706e82 116
b2c258fb
JB
117 return 0;
118}
f0706e82 119
4150c572
JB
120static void ieee80211_master_set_multicast_list(struct net_device *dev)
121{
122 struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr);
123
124 ieee80211_configure_filter(local);
125}
126
b2c258fb 127/* regular interfaces */
f0706e82 128
b2c258fb 129static int ieee80211_change_mtu(struct net_device *dev, int new_mtu)
f0706e82 130{
b2c258fb
JB
131 /* FIX: what would be proper limits for MTU?
132 * This interface uses 802.3 frames. */
133 if (new_mtu < 256 || new_mtu > IEEE80211_MAX_DATA_LEN - 24 - 6) {
134 printk(KERN_WARNING "%s: invalid MTU %d\n",
135 dev->name, new_mtu);
136 return -EINVAL;
137 }
f0706e82 138
b2c258fb
JB
139#ifdef CONFIG_MAC80211_VERBOSE_DEBUG
140 printk(KERN_DEBUG "%s: setting MTU %d\n", dev->name, new_mtu);
141#endif /* CONFIG_MAC80211_VERBOSE_DEBUG */
142 dev->mtu = new_mtu;
f0706e82
JB
143 return 0;
144}
145
b2c258fb
JB
146static inline int identical_mac_addr_allowed(int type1, int type2)
147{
148 return (type1 == IEEE80211_IF_TYPE_MNTR ||
149 type2 == IEEE80211_IF_TYPE_MNTR ||
150 (type1 == IEEE80211_IF_TYPE_AP &&
151 type2 == IEEE80211_IF_TYPE_WDS) ||
152 (type1 == IEEE80211_IF_TYPE_WDS &&
153 (type2 == IEEE80211_IF_TYPE_WDS ||
154 type2 == IEEE80211_IF_TYPE_AP)) ||
155 (type1 == IEEE80211_IF_TYPE_AP &&
156 type2 == IEEE80211_IF_TYPE_VLAN) ||
157 (type1 == IEEE80211_IF_TYPE_VLAN &&
158 (type2 == IEEE80211_IF_TYPE_AP ||
159 type2 == IEEE80211_IF_TYPE_VLAN)));
160}
f0706e82 161
b2c258fb 162static int ieee80211_open(struct net_device *dev)
e2ebc74d 163{
b2c258fb
JB
164 struct ieee80211_sub_if_data *sdata, *nsdata;
165 struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr);
166 struct ieee80211_if_init_conf conf;
167 int res;
ceffefd1 168 bool need_hw_reconfig = 0;
f0706e82 169
b2c258fb 170 sdata = IEEE80211_DEV_TO_SUB_IF(dev);
0ec3ca44 171
79010420
JB
172 /* we hold the RTNL here so can safely walk the list */
173 list_for_each_entry(nsdata, &local->interfaces, list) {
b2c258fb 174 struct net_device *ndev = nsdata->dev;
e2ebc74d 175
b2c258fb 176 if (ndev != dev && ndev != local->mdev && netif_running(ndev) &&
0ec3ca44
JB
177 compare_ether_addr(dev->dev_addr, ndev->dev_addr) == 0) {
178 /*
179 * check whether it may have the same address
180 */
51fb61e7
JB
181 if (!identical_mac_addr_allowed(sdata->vif.type,
182 nsdata->vif.type))
0ec3ca44 183 return -ENOTUNIQ;
0ec3ca44
JB
184
185 /*
186 * can only add VLANs to enabled APs
187 */
51fb61e7
JB
188 if (sdata->vif.type == IEEE80211_IF_TYPE_VLAN &&
189 nsdata->vif.type == IEEE80211_IF_TYPE_AP &&
0ec3ca44
JB
190 netif_running(nsdata->dev))
191 sdata->u.vlan.ap = nsdata;
b2c258fb
JB
192 }
193 }
f0706e82 194
51fb61e7 195 switch (sdata->vif.type) {
0ec3ca44
JB
196 case IEEE80211_IF_TYPE_WDS:
197 if (is_zero_ether_addr(sdata->u.wds.remote_addr))
198 return -ENOLINK;
199 break;
200 case IEEE80211_IF_TYPE_VLAN:
201 if (!sdata->u.vlan.ap)
202 return -ENOLINK;
203 break;
fb1c1cd6 204 case IEEE80211_IF_TYPE_AP:
fb1c1cd6
JB
205 case IEEE80211_IF_TYPE_STA:
206 case IEEE80211_IF_TYPE_MNTR:
207 case IEEE80211_IF_TYPE_IBSS:
208 /* no special treatment */
209 break;
a2897552
JB
210 case IEEE80211_IF_TYPE_INVALID:
211 /* cannot happen */
212 WARN_ON(1);
213 break;
0ec3ca44 214 }
f0706e82 215
b2c258fb
JB
216 if (local->open_count == 0) {
217 res = 0;
4150c572
JB
218 if (local->ops->start)
219 res = local->ops->start(local_to_hw(local));
220 if (res)
b2c258fb 221 return res;
ceffefd1 222 need_hw_reconfig = 1;
cdcb006f 223 ieee80211_led_radio(local, local->hw.conf.radio_enabled);
b2c258fb 224 }
f0706e82 225
51fb61e7 226 switch (sdata->vif.type) {
0ec3ca44
JB
227 case IEEE80211_IF_TYPE_VLAN:
228 list_add(&sdata->u.vlan.list, &sdata->u.vlan.ap->u.ap.vlans);
229 /* no need to tell driver */
230 break;
4150c572
JB
231 case IEEE80211_IF_TYPE_MNTR:
232 /* must be before the call to ieee80211_configure_filter */
b2c258fb 233 local->monitors++;
4150c572
JB
234 if (local->monitors == 1) {
235 netif_tx_lock_bh(local->mdev);
236 ieee80211_configure_filter(local);
237 netif_tx_unlock_bh(local->mdev);
238
239 local->hw.conf.flags |= IEEE80211_CONF_RADIOTAP;
4150c572
JB
240 }
241 break;
242 case IEEE80211_IF_TYPE_STA:
243 case IEEE80211_IF_TYPE_IBSS:
244 sdata->u.sta.flags &= ~IEEE80211_STA_PREV_BSSID_SET;
245 /* fall through */
246 default:
32bfd35d 247 conf.vif = &sdata->vif;
51fb61e7 248 conf.type = sdata->vif.type;
4150c572
JB
249 conf.mac_addr = dev->dev_addr;
250 res = local->ops->add_interface(local_to_hw(local), &conf);
251 if (res && !local->open_count && local->ops->stop)
252 local->ops->stop(local_to_hw(local));
253 if (res)
254 return res;
255
b2c258fb 256 ieee80211_if_config(dev);
d9430a32 257 ieee80211_reset_erp_info(dev);
11a843b7 258 ieee80211_enable_keys(sdata);
4150c572 259
51fb61e7 260 if (sdata->vif.type == IEEE80211_IF_TYPE_STA &&
ddd3d2be 261 !(sdata->flags & IEEE80211_SDATA_USERSPACE_MLME))
4150c572
JB
262 netif_carrier_off(dev);
263 else
264 netif_carrier_on(dev);
d9430a32 265 }
f0706e82 266
4150c572
JB
267 if (local->open_count == 0) {
268 res = dev_open(local->mdev);
269 WARN_ON(res);
4150c572
JB
270 tasklet_enable(&local->tx_pending_tasklet);
271 tasklet_enable(&local->tasklet);
272 }
273
c1428b3f
JB
274 /*
275 * set_multicast_list will be invoked by the networking core
276 * which will check whether any increments here were done in
277 * error and sync them down to the hardware as filter flags.
278 */
279 if (sdata->flags & IEEE80211_SDATA_ALLMULTI)
280 atomic_inc(&local->iff_allmultis);
281
282 if (sdata->flags & IEEE80211_SDATA_PROMISC)
283 atomic_inc(&local->iff_promiscs);
284
4150c572 285 local->open_count++;
ceffefd1
MB
286 if (need_hw_reconfig)
287 ieee80211_hw_config(local);
f0706e82 288
b2c258fb 289 netif_start_queue(dev);
4150c572 290
b2c258fb 291 return 0;
f0706e82 292}
f0706e82 293
4150c572 294static int ieee80211_stop(struct net_device *dev)
f0706e82 295{
4150c572 296 struct ieee80211_sub_if_data *sdata;
f0706e82 297 struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr);
4150c572 298 struct ieee80211_if_init_conf conf;
07db2183
RR
299 struct sta_info *sta;
300 int i;
4150c572
JB
301
302 sdata = IEEE80211_DEV_TO_SUB_IF(dev);
303
07db2183 304 list_for_each_entry(sta, &local->sta_list, list) {
5b3d71d9
RR
305 if (sta->dev == dev)
306 for (i = 0; i < STA_TID_NUM; i++)
307 ieee80211_sta_stop_rx_ba_session(sta->dev,
308 sta->addr, i,
309 WLAN_BACK_RECIPIENT,
07db2183
RR
310 WLAN_REASON_QSTA_LEAVE_QBSS);
311 }
312
4150c572
JB
313 netif_stop_queue(dev);
314
c1428b3f
JB
315 /*
316 * Don't count this interface for promisc/allmulti while it
317 * is down. dev_mc_unsync() will invoke set_multicast_list
318 * on the master interface which will sync these down to the
319 * hardware as filter flags.
320 */
321 if (sdata->flags & IEEE80211_SDATA_ALLMULTI)
322 atomic_dec(&local->iff_allmultis);
323
324 if (sdata->flags & IEEE80211_SDATA_PROMISC)
325 atomic_dec(&local->iff_promiscs);
326
4150c572
JB
327 dev_mc_unsync(local->mdev, dev);
328
5dfdaf58 329 /* APs need special treatment */
51fb61e7 330 if (sdata->vif.type == IEEE80211_IF_TYPE_AP) {
0ec3ca44 331 struct ieee80211_sub_if_data *vlan, *tmp;
5dfdaf58 332 struct beacon_data *old_beacon = sdata->u.ap.beacon;
0ec3ca44 333
5dfdaf58
JB
334 /* remove beacon */
335 rcu_assign_pointer(sdata->u.ap.beacon, NULL);
336 synchronize_rcu();
337 kfree(old_beacon);
338
339 /* down all dependent devices, that is VLANs */
0ec3ca44
JB
340 list_for_each_entry_safe(vlan, tmp, &sdata->u.ap.vlans,
341 u.vlan.list)
342 dev_close(vlan->dev);
343 WARN_ON(!list_empty(&sdata->u.ap.vlans));
344 }
345
4150c572 346 local->open_count--;
f0706e82 347
51fb61e7 348 switch (sdata->vif.type) {
0ec3ca44
JB
349 case IEEE80211_IF_TYPE_VLAN:
350 list_del(&sdata->u.vlan.list);
351 sdata->u.vlan.ap = NULL;
352 /* no need to tell driver */
353 break;
4150c572
JB
354 case IEEE80211_IF_TYPE_MNTR:
355 local->monitors--;
356 if (local->monitors == 0) {
357 netif_tx_lock_bh(local->mdev);
358 ieee80211_configure_filter(local);
359 netif_tx_unlock_bh(local->mdev);
360
8b393f1d 361 local->hw.conf.flags &= ~IEEE80211_CONF_RADIOTAP;
4150c572
JB
362 }
363 break;
b2c258fb
JB
364 case IEEE80211_IF_TYPE_STA:
365 case IEEE80211_IF_TYPE_IBSS:
366 sdata->u.sta.state = IEEE80211_DISABLED;
367 del_timer_sync(&sdata->u.sta.timer);
2a8a9a88 368 /*
79010420
JB
369 * When we get here, the interface is marked down.
370 * Call synchronize_rcu() to wait for the RX path
371 * should it be using the interface and enqueuing
372 * frames at this very time on another CPU.
2a8a9a88 373 */
79010420 374 synchronize_rcu();
b2c258fb 375 skb_queue_purge(&sdata->u.sta.skb_queue);
2a8a9a88 376
ece8eddd
ZY
377 if (local->scan_dev == sdata->dev) {
378 if (!local->ops->hw_scan) {
379 local->sta_sw_scanning = 0;
380 cancel_delayed_work(&local->scan_work);
381 } else
382 local->sta_hw_scanning = 0;
b2c258fb 383 }
ece8eddd 384
b2c258fb 385 flush_workqueue(local->hw.workqueue);
a10605e5
ZY
386
387 sdata->u.sta.flags &= ~IEEE80211_STA_PRIVACY_INVOKED;
388 kfree(sdata->u.sta.extra_ie);
389 sdata->u.sta.extra_ie = NULL;
390 sdata->u.sta.extra_ie_len = 0;
4150c572
JB
391 /* fall through */
392 default:
32bfd35d 393 conf.vif = &sdata->vif;
51fb61e7 394 conf.type = sdata->vif.type;
4150c572 395 conf.mac_addr = dev->dev_addr;
11a843b7
JB
396 /* disable all keys for as long as this netdev is down */
397 ieee80211_disable_keys(sdata);
4150c572 398 local->ops->remove_interface(local_to_hw(local), &conf);
f0706e82
JB
399 }
400
b2c258fb
JB
401 if (local->open_count == 0) {
402 if (netif_running(local->mdev))
403 dev_close(local->mdev);
4150c572 404
b2c258fb
JB
405 if (local->ops->stop)
406 local->ops->stop(local_to_hw(local));
4150c572 407
cdcb006f
ID
408 ieee80211_led_radio(local, 0);
409
b2c258fb
JB
410 tasklet_disable(&local->tx_pending_tasklet);
411 tasklet_disable(&local->tasklet);
412 }
b2c258fb 413
f0706e82
JB
414 return 0;
415}
416
eadc8d9e
RR
417int ieee80211_start_tx_ba_session(struct ieee80211_hw *hw, u8 *ra, u16 tid)
418{
419 struct ieee80211_local *local = hw_to_local(hw);
420 struct sta_info *sta;
421 struct ieee80211_sub_if_data *sdata;
422 u16 start_seq_num = 0;
423 u8 *state;
424 int ret;
425 DECLARE_MAC_BUF(mac);
426
427 if (tid >= STA_TID_NUM)
428 return -EINVAL;
429
430#ifdef CONFIG_MAC80211_HT_DEBUG
431 printk(KERN_DEBUG "Open BA session requested for %s tid %u\n",
432 print_mac(mac, ra), tid);
433#endif /* CONFIG_MAC80211_HT_DEBUG */
434
435 sta = sta_info_get(local, ra);
436 if (!sta) {
437 printk(KERN_DEBUG "Could not find the station\n");
438 return -ENOENT;
439 }
440
441 spin_lock_bh(&sta->ampdu_mlme.ampdu_tx);
442
443 /* we have tried too many times, receiver does not want A-MPDU */
444 if (sta->ampdu_mlme.tid_tx[tid].addba_req_num > HT_AGG_MAX_RETRIES) {
445 ret = -EBUSY;
446 goto start_ba_exit;
447 }
448
449 state = &sta->ampdu_mlme.tid_tx[tid].state;
450 /* check if the TID is not in aggregation flow already */
451 if (*state != HT_AGG_STATE_IDLE) {
452#ifdef CONFIG_MAC80211_HT_DEBUG
453 printk(KERN_DEBUG "BA request denied - session is not "
454 "idle on tid %u\n", tid);
455#endif /* CONFIG_MAC80211_HT_DEBUG */
456 ret = -EAGAIN;
457 goto start_ba_exit;
458 }
459
460 /* ensure that TX flow won't interrupt us
461 * until the end of the call to requeue function */
462 spin_lock_bh(&local->mdev->queue_lock);
463
464 /* create a new queue for this aggregation */
9e723492 465 ret = ieee80211_ht_agg_queue_add(local, sta, tid);
eadc8d9e
RR
466
467 /* case no queue is available to aggregation
468 * don't switch to aggregation */
469 if (ret) {
470#ifdef CONFIG_MAC80211_HT_DEBUG
471 printk(KERN_DEBUG "BA request denied - no queue available for"
472 " tid %d\n", tid);
473#endif /* CONFIG_MAC80211_HT_DEBUG */
474 spin_unlock_bh(&local->mdev->queue_lock);
475 goto start_ba_exit;
476 }
477 sdata = IEEE80211_DEV_TO_SUB_IF(sta->dev);
478
479 /* Ok, the Addba frame hasn't been sent yet, but if the driver calls the
480 * call back right away, it must see that the flow has begun */
481 *state |= HT_ADDBA_REQUESTED_MSK;
482
483 if (local->ops->ampdu_action)
484 ret = local->ops->ampdu_action(hw, IEEE80211_AMPDU_TX_START,
485 ra, tid, &start_seq_num);
486
487 if (ret) {
488 /* No need to requeue the packets in the agg queue, since we
489 * held the tx lock: no packet could be enqueued to the newly
490 * allocated queue */
9e723492 491 ieee80211_ht_agg_queue_remove(local, sta, tid, 0);
eadc8d9e
RR
492#ifdef CONFIG_MAC80211_HT_DEBUG
493 printk(KERN_DEBUG "BA request denied - HW or queue unavailable"
494 " for tid %d\n", tid);
495#endif /* CONFIG_MAC80211_HT_DEBUG */
496 spin_unlock_bh(&local->mdev->queue_lock);
497 *state = HT_AGG_STATE_IDLE;
498 goto start_ba_exit;
499 }
500
501 /* Will put all the packets in the new SW queue */
9e723492 502 ieee80211_requeue(local, ieee802_1d_to_ac[tid]);
eadc8d9e
RR
503 spin_unlock_bh(&local->mdev->queue_lock);
504
505 /* We have most probably almost emptied the legacy queue */
506 /* ieee80211_wake_queue(local_to_hw(local), ieee802_1d_to_ac[tid]); */
507
508 /* send an addBA request */
509 sta->ampdu_mlme.dialog_token_allocator++;
510 sta->ampdu_mlme.tid_tx[tid].dialog_token =
511 sta->ampdu_mlme.dialog_token_allocator;
512 sta->ampdu_mlme.tid_tx[tid].ssn = start_seq_num;
513
514 ieee80211_send_addba_request(sta->dev, ra, tid,
515 sta->ampdu_mlme.tid_tx[tid].dialog_token,
516 sta->ampdu_mlme.tid_tx[tid].ssn,
517 0x40, 5000);
518
519 /* activate the timer for the recipient's addBA response */
520 sta->ampdu_mlme.tid_tx[tid].addba_resp_timer.expires =
521 jiffies + ADDBA_RESP_INTERVAL;
522 add_timer(&sta->ampdu_mlme.tid_tx[tid].addba_resp_timer);
523 printk(KERN_DEBUG "activated addBA response timer on tid %d\n", tid);
524
525start_ba_exit:
526 spin_unlock_bh(&sta->ampdu_mlme.ampdu_tx);
527 sta_info_put(sta);
528 return ret;
529}
530EXPORT_SYMBOL(ieee80211_start_tx_ba_session);
531
532int ieee80211_stop_tx_ba_session(struct ieee80211_hw *hw,
533 u8 *ra, u16 tid,
534 enum ieee80211_back_parties initiator)
535{
536 struct ieee80211_local *local = hw_to_local(hw);
537 struct sta_info *sta;
538 u8 *state;
539 int ret = 0;
540 DECLARE_MAC_BUF(mac);
541
542 if (tid >= STA_TID_NUM)
543 return -EINVAL;
544
545#ifdef CONFIG_MAC80211_HT_DEBUG
546 printk(KERN_DEBUG "Stop a BA session requested for %s tid %u\n",
547 print_mac(mac, ra), tid);
548#endif /* CONFIG_MAC80211_HT_DEBUG */
549
550 sta = sta_info_get(local, ra);
551 if (!sta)
552 return -ENOENT;
553
554 /* check if the TID is in aggregation */
555 state = &sta->ampdu_mlme.tid_tx[tid].state;
556 spin_lock_bh(&sta->ampdu_mlme.ampdu_tx);
557
558 if (*state != HT_AGG_STATE_OPERATIONAL) {
559#ifdef CONFIG_MAC80211_HT_DEBUG
560 printk(KERN_DEBUG "Try to stop Tx aggregation on"
561 " non active TID\n");
562#endif /* CONFIG_MAC80211_HT_DEBUG */
563 ret = -ENOENT;
564 goto stop_BA_exit;
565 }
566
567 ieee80211_stop_queue(hw, sta->tid_to_tx_q[tid]);
568
569 *state = HT_AGG_STATE_REQ_STOP_BA_MSK |
570 (initiator << HT_AGG_STATE_INITIATOR_SHIFT);
571
572 if (local->ops->ampdu_action)
573 ret = local->ops->ampdu_action(hw, IEEE80211_AMPDU_TX_STOP,
574 ra, tid, NULL);
575
576 /* case HW denied going back to legacy */
577 if (ret) {
578 WARN_ON(ret != -EBUSY);
579 *state = HT_AGG_STATE_OPERATIONAL;
580 ieee80211_wake_queue(hw, sta->tid_to_tx_q[tid]);
581 goto stop_BA_exit;
582 }
583
584stop_BA_exit:
585 spin_unlock_bh(&sta->ampdu_mlme.ampdu_tx);
586 sta_info_put(sta);
587 return ret;
588}
589EXPORT_SYMBOL(ieee80211_stop_tx_ba_session);
590
591void ieee80211_start_tx_ba_cb(struct ieee80211_hw *hw, u8 *ra, u16 tid)
592{
593 struct ieee80211_local *local = hw_to_local(hw);
594 struct sta_info *sta;
595 u8 *state;
596 DECLARE_MAC_BUF(mac);
597
598 if (tid >= STA_TID_NUM) {
599 printk(KERN_DEBUG "Bad TID value: tid = %d (>= %d)\n",
600 tid, STA_TID_NUM);
601 return;
602 }
603
604 sta = sta_info_get(local, ra);
605 if (!sta) {
606 printk(KERN_DEBUG "Could not find station: %s\n",
607 print_mac(mac, ra));
608 return;
609 }
610
611 state = &sta->ampdu_mlme.tid_tx[tid].state;
612 spin_lock_bh(&sta->ampdu_mlme.ampdu_tx);
613
614 if (!(*state & HT_ADDBA_REQUESTED_MSK)) {
615 printk(KERN_DEBUG "addBA was not requested yet, state is %d\n",
616 *state);
617 spin_unlock_bh(&sta->ampdu_mlme.ampdu_tx);
618 sta_info_put(sta);
619 return;
620 }
621
622 WARN_ON_ONCE(*state & HT_ADDBA_DRV_READY_MSK);
623
624 *state |= HT_ADDBA_DRV_READY_MSK;
625
626 if (*state == HT_AGG_STATE_OPERATIONAL) {
627 printk(KERN_DEBUG "Aggregation is on for tid %d \n", tid);
628 ieee80211_wake_queue(hw, sta->tid_to_tx_q[tid]);
629 }
630 spin_unlock_bh(&sta->ampdu_mlme.ampdu_tx);
631 sta_info_put(sta);
632}
633EXPORT_SYMBOL(ieee80211_start_tx_ba_cb);
634
635void ieee80211_stop_tx_ba_cb(struct ieee80211_hw *hw, u8 *ra, u8 tid)
636{
637 struct ieee80211_local *local = hw_to_local(hw);
638 struct sta_info *sta;
639 u8 *state;
640 int agg_queue;
641 DECLARE_MAC_BUF(mac);
642
643 if (tid >= STA_TID_NUM) {
644 printk(KERN_DEBUG "Bad TID value: tid = %d (>= %d)\n",
645 tid, STA_TID_NUM);
646 return;
647 }
648
649 printk(KERN_DEBUG "Stop a BA session requested on DA %s tid %d\n",
650 print_mac(mac, ra), tid);
651
652 sta = sta_info_get(local, ra);
653 if (!sta) {
654 printk(KERN_DEBUG "Could not find station: %s\n",
655 print_mac(mac, ra));
656 return;
657 }
658 state = &sta->ampdu_mlme.tid_tx[tid].state;
659
660 spin_lock_bh(&sta->ampdu_mlme.ampdu_tx);
661 if ((*state & HT_AGG_STATE_REQ_STOP_BA_MSK) == 0) {
662 printk(KERN_DEBUG "unexpected callback to A-MPDU stop\n");
663 sta_info_put(sta);
664 spin_unlock_bh(&sta->ampdu_mlme.ampdu_tx);
665 return;
666 }
667
668 if (*state & HT_AGG_STATE_INITIATOR_MSK)
669 ieee80211_send_delba(sta->dev, ra, tid,
670 WLAN_BACK_INITIATOR, WLAN_REASON_QSTA_NOT_USE);
671
672 agg_queue = sta->tid_to_tx_q[tid];
673
674 /* avoid ordering issues: we are the only one that can modify
675 * the content of the qdiscs */
676 spin_lock_bh(&local->mdev->queue_lock);
677 /* remove the queue for this aggregation */
9e723492 678 ieee80211_ht_agg_queue_remove(local, sta, tid, 1);
eadc8d9e
RR
679 spin_unlock_bh(&local->mdev->queue_lock);
680
681 /* we just requeued the all the frames that were in the removed
682 * queue, and since we might miss a softirq we do netif_schedule.
683 * ieee80211_wake_queue is not used here as this queue is not
684 * necessarily stopped */
685 netif_schedule(local->mdev);
686 *state = HT_AGG_STATE_IDLE;
687 sta->ampdu_mlme.tid_tx[tid].addba_req_num = 0;
688 spin_unlock_bh(&sta->ampdu_mlme.ampdu_tx);
689
690 sta_info_put(sta);
691}
692EXPORT_SYMBOL(ieee80211_stop_tx_ba_cb);
693
694void ieee80211_start_tx_ba_cb_irqsafe(struct ieee80211_hw *hw,
695 const u8 *ra, u16 tid)
696{
697 struct ieee80211_local *local = hw_to_local(hw);
698 struct ieee80211_ra_tid *ra_tid;
699 struct sk_buff *skb = dev_alloc_skb(0);
700
701 if (unlikely(!skb)) {
702 if (net_ratelimit())
703 printk(KERN_WARNING "%s: Not enough memory, "
704 "dropping start BA session", skb->dev->name);
705 return;
706 }
707 ra_tid = (struct ieee80211_ra_tid *) &skb->cb;
708 memcpy(&ra_tid->ra, ra, ETH_ALEN);
709 ra_tid->tid = tid;
710
711 skb->pkt_type = IEEE80211_ADDBA_MSG;
712 skb_queue_tail(&local->skb_queue, skb);
713 tasklet_schedule(&local->tasklet);
714}
715EXPORT_SYMBOL(ieee80211_start_tx_ba_cb_irqsafe);
716
717void ieee80211_stop_tx_ba_cb_irqsafe(struct ieee80211_hw *hw,
718 const u8 *ra, u16 tid)
719{
720 struct ieee80211_local *local = hw_to_local(hw);
721 struct ieee80211_ra_tid *ra_tid;
722 struct sk_buff *skb = dev_alloc_skb(0);
723
724 if (unlikely(!skb)) {
725 if (net_ratelimit())
726 printk(KERN_WARNING "%s: Not enough memory, "
727 "dropping stop BA session", skb->dev->name);
728 return;
729 }
730 ra_tid = (struct ieee80211_ra_tid *) &skb->cb;
731 memcpy(&ra_tid->ra, ra, ETH_ALEN);
732 ra_tid->tid = tid;
733
734 skb->pkt_type = IEEE80211_DELBA_MSG;
735 skb_queue_tail(&local->skb_queue, skb);
736 tasklet_schedule(&local->tasklet);
737}
738EXPORT_SYMBOL(ieee80211_stop_tx_ba_cb_irqsafe);
739
f0706e82
JB
740static void ieee80211_set_multicast_list(struct net_device *dev)
741{
742 struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr);
743 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
4150c572 744 int allmulti, promisc, sdata_allmulti, sdata_promisc;
f0706e82 745
4150c572
JB
746 allmulti = !!(dev->flags & IFF_ALLMULTI);
747 promisc = !!(dev->flags & IFF_PROMISC);
b52f2198
JB
748 sdata_allmulti = !!(sdata->flags & IEEE80211_SDATA_ALLMULTI);
749 sdata_promisc = !!(sdata->flags & IEEE80211_SDATA_PROMISC);
4150c572
JB
750
751 if (allmulti != sdata_allmulti) {
752 if (dev->flags & IFF_ALLMULTI)
53918994 753 atomic_inc(&local->iff_allmultis);
4150c572 754 else
53918994 755 atomic_dec(&local->iff_allmultis);
13262ffd 756 sdata->flags ^= IEEE80211_SDATA_ALLMULTI;
f0706e82 757 }
4150c572
JB
758
759 if (promisc != sdata_promisc) {
760 if (dev->flags & IFF_PROMISC)
53918994 761 atomic_inc(&local->iff_promiscs);
4150c572 762 else
53918994 763 atomic_dec(&local->iff_promiscs);
13262ffd 764 sdata->flags ^= IEEE80211_SDATA_PROMISC;
f0706e82 765 }
4150c572
JB
766
767 dev_mc_sync(local->mdev, dev);
f0706e82
JB
768}
769
3b04ddde
SH
770static const struct header_ops ieee80211_header_ops = {
771 .create = eth_header,
772 .parse = header_parse_80211,
773 .rebuild = eth_rebuild_header,
774 .cache = eth_header_cache,
775 .cache_update = eth_header_cache_update,
776};
777
f9d540ee 778/* Must not be called for mdev */
b2c258fb 779void ieee80211_if_setup(struct net_device *dev)
f0706e82 780{
b2c258fb
JB
781 ether_setup(dev);
782 dev->hard_start_xmit = ieee80211_subif_start_xmit;
783 dev->wireless_handlers = &ieee80211_iw_handler_def;
784 dev->set_multicast_list = ieee80211_set_multicast_list;
785 dev->change_mtu = ieee80211_change_mtu;
b2c258fb
JB
786 dev->open = ieee80211_open;
787 dev->stop = ieee80211_stop;
b2c258fb
JB
788 dev->destructor = ieee80211_if_free;
789}
f0706e82 790
b2c258fb
JB
791/* WDS specialties */
792
793int ieee80211_if_update_wds(struct net_device *dev, u8 *remote_addr)
794{
795 struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr);
796 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
797 struct sta_info *sta;
0795af57 798 DECLARE_MAC_BUF(mac);
b2c258fb
JB
799
800 if (compare_ether_addr(remote_addr, sdata->u.wds.remote_addr) == 0)
801 return 0;
802
803 /* Create STA entry for the new peer */
804 sta = sta_info_add(local, dev, remote_addr, GFP_KERNEL);
805 if (!sta)
806 return -ENOMEM;
807 sta_info_put(sta);
808
809 /* Remove STA entry for the old peer */
810 sta = sta_info_get(local, sdata->u.wds.remote_addr);
811 if (sta) {
be8755e1 812 sta_info_free(sta);
b2c258fb 813 sta_info_put(sta);
b2c258fb
JB
814 } else {
815 printk(KERN_DEBUG "%s: could not find STA entry for WDS link "
0795af57
JP
816 "peer %s\n",
817 dev->name, print_mac(mac, sdata->u.wds.remote_addr));
b2c258fb
JB
818 }
819
820 /* Update WDS link data */
821 memcpy(&sdata->u.wds.remote_addr, remote_addr, ETH_ALEN);
822
823 return 0;
f0706e82 824}
f0706e82 825
b2c258fb
JB
826/* everything else */
827
b2c258fb
JB
828static int __ieee80211_if_config(struct net_device *dev,
829 struct sk_buff *beacon,
830 struct ieee80211_tx_control *control)
831{
832 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
833 struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr);
834 struct ieee80211_if_conf conf;
b2c258fb
JB
835
836 if (!local->ops->config_interface || !netif_running(dev))
f0706e82 837 return 0;
f0706e82 838
b2c258fb 839 memset(&conf, 0, sizeof(conf));
51fb61e7
JB
840 conf.type = sdata->vif.type;
841 if (sdata->vif.type == IEEE80211_IF_TYPE_STA ||
842 sdata->vif.type == IEEE80211_IF_TYPE_IBSS) {
4150c572 843 conf.bssid = sdata->u.sta.bssid;
b2c258fb
JB
844 conf.ssid = sdata->u.sta.ssid;
845 conf.ssid_len = sdata->u.sta.ssid_len;
51fb61e7 846 } else if (sdata->vif.type == IEEE80211_IF_TYPE_AP) {
b2c258fb
JB
847 conf.ssid = sdata->u.ap.ssid;
848 conf.ssid_len = sdata->u.ap.ssid_len;
b2c258fb
JB
849 conf.beacon = beacon;
850 conf.beacon_control = control;
f0706e82 851 }
b2c258fb 852 return local->ops->config_interface(local_to_hw(local),
32bfd35d 853 &sdata->vif, &conf);
f0706e82
JB
854}
855
b2c258fb
JB
856int ieee80211_if_config(struct net_device *dev)
857{
858 return __ieee80211_if_config(dev, NULL, NULL);
859}
f0706e82 860
b2c258fb 861int ieee80211_if_config_beacon(struct net_device *dev)
f0706e82 862{
f0706e82 863 struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr);
b2c258fb 864 struct ieee80211_tx_control control;
32bfd35d 865 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
b2c258fb 866 struct sk_buff *skb;
f0706e82 867
b2c258fb 868 if (!(local->hw.flags & IEEE80211_HW_HOST_GEN_BEACON_TEMPLATE))
f0706e82 869 return 0;
32bfd35d
JB
870 skb = ieee80211_beacon_get(local_to_hw(local), &sdata->vif,
871 &control);
b2c258fb
JB
872 if (!skb)
873 return -ENOMEM;
874 return __ieee80211_if_config(dev, skb, &control);
875}
f0706e82 876
b2c258fb
JB
877int ieee80211_hw_config(struct ieee80211_local *local)
878{
b2c258fb
JB
879 struct ieee80211_channel *chan;
880 int ret = 0;
f0706e82 881
8318d78a 882 if (local->sta_sw_scanning)
b2c258fb 883 chan = local->scan_channel;
8318d78a 884 else
b2c258fb 885 chan = local->oper_channel;
f0706e82 886
8318d78a
JB
887 local->hw.conf.channel = chan;
888
889 if (!local->hw.conf.power_level)
890 local->hw.conf.power_level = chan->max_power;
891 else
892 local->hw.conf.power_level = min(chan->max_power,
893 local->hw.conf.power_level);
894
895 local->hw.conf.max_antenna_gain = chan->max_antenna_gain;
f0706e82 896
b2c258fb 897#ifdef CONFIG_MAC80211_VERBOSE_DEBUG
8318d78a
JB
898 printk(KERN_DEBUG "%s: HW CONFIG: freq=%d\n",
899 wiphy_name(local->hw.wiphy), chan->center_freq);
900#endif
b2c258fb 901
f7c4daed 902 if (local->open_count)
b2c258fb 903 ret = local->ops->config(local_to_hw(local), &local->hw.conf);
f0706e82 904
b2c258fb
JB
905 return ret;
906}
f0706e82 907
d3c990fb
RR
908/**
909 * ieee80211_hw_config_ht should be used only after legacy configuration
910 * has been determined, as ht configuration depends upon the hardware's
911 * HT abilities for a _specific_ band.
912 */
913int ieee80211_hw_config_ht(struct ieee80211_local *local, int enable_ht,
914 struct ieee80211_ht_info *req_ht_cap,
915 struct ieee80211_ht_bss_info *req_bss_cap)
916{
917 struct ieee80211_conf *conf = &local->hw.conf;
8318d78a 918 struct ieee80211_supported_band *sband;
d3c990fb
RR
919 int i;
920
8318d78a
JB
921 sband = local->hw.wiphy->bands[conf->channel->band];
922
d3c990fb 923 /* HT is not supported */
8318d78a 924 if (!sband->ht_info.ht_supported) {
d3c990fb
RR
925 conf->flags &= ~IEEE80211_CONF_SUPPORT_HT_MODE;
926 return -EOPNOTSUPP;
927 }
928
929 /* disable HT */
930 if (!enable_ht) {
931 conf->flags &= ~IEEE80211_CONF_SUPPORT_HT_MODE;
932 } else {
933 conf->flags |= IEEE80211_CONF_SUPPORT_HT_MODE;
8318d78a 934 conf->ht_conf.cap = req_ht_cap->cap & sband->ht_info.cap;
d3c990fb
RR
935 conf->ht_conf.cap &= ~(IEEE80211_HT_CAP_MIMO_PS);
936 conf->ht_conf.cap |=
8318d78a 937 sband->ht_info.cap & IEEE80211_HT_CAP_MIMO_PS;
d3c990fb
RR
938 conf->ht_bss_conf.primary_channel =
939 req_bss_cap->primary_channel;
940 conf->ht_bss_conf.bss_cap = req_bss_cap->bss_cap;
941 conf->ht_bss_conf.bss_op_mode = req_bss_cap->bss_op_mode;
942 for (i = 0; i < SUPP_MCS_SET_LEN; i++)
943 conf->ht_conf.supp_mcs_set[i] =
8318d78a 944 sband->ht_info.supp_mcs_set[i] &
d3c990fb
RR
945 req_ht_cap->supp_mcs_set[i];
946
947 /* In STA mode, this gives us indication
948 * to the AP's mode of operation */
949 conf->ht_conf.ht_supported = 1;
950 conf->ht_conf.ampdu_factor = req_ht_cap->ampdu_factor;
951 conf->ht_conf.ampdu_density = req_ht_cap->ampdu_density;
952 }
953
954 local->ops->conf_ht(local_to_hw(local), &local->hw.conf);
955
956 return 0;
957}
958
471b3efd
JB
959void ieee80211_bss_info_change_notify(struct ieee80211_sub_if_data *sdata,
960 u32 changed)
d9430a32 961{
471b3efd
JB
962 struct ieee80211_local *local = sdata->local;
963
964 if (!changed)
965 return;
966
967 if (local->ops->bss_info_changed)
968 local->ops->bss_info_changed(local_to_hw(local),
969 &sdata->vif,
970 &sdata->bss_conf,
971 changed);
d9430a32
DD
972}
973
974void ieee80211_reset_erp_info(struct net_device *dev)
975{
976 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
977
471b3efd
JB
978 sdata->bss_conf.use_cts_prot = 0;
979 sdata->bss_conf.use_short_preamble = 0;
980 ieee80211_bss_info_change_notify(sdata,
981 BSS_CHANGED_ERP_CTS_PROT |
982 BSS_CHANGED_ERP_PREAMBLE);
d9430a32
DD
983}
984
f0706e82
JB
985void ieee80211_tx_status_irqsafe(struct ieee80211_hw *hw,
986 struct sk_buff *skb,
987 struct ieee80211_tx_status *status)
988{
989 struct ieee80211_local *local = hw_to_local(hw);
990 struct ieee80211_tx_status *saved;
991 int tmp;
992
993 skb->dev = local->mdev;
994 saved = kmalloc(sizeof(struct ieee80211_tx_status), GFP_ATOMIC);
995 if (unlikely(!saved)) {
996 if (net_ratelimit())
997 printk(KERN_WARNING "%s: Not enough memory, "
998 "dropping tx status", skb->dev->name);
999 /* should be dev_kfree_skb_irq, but due to this function being
1000 * named _irqsafe instead of just _irq we can't be sure that
1001 * people won't call it from non-irq contexts */
1002 dev_kfree_skb_any(skb);
1003 return;
1004 }
1005 memcpy(saved, status, sizeof(struct ieee80211_tx_status));
1006 /* copy pointer to saved status into skb->cb for use by tasklet */
1007 memcpy(skb->cb, &saved, sizeof(saved));
1008
1009 skb->pkt_type = IEEE80211_TX_STATUS_MSG;
1010 skb_queue_tail(status->control.flags & IEEE80211_TXCTL_REQ_TX_STATUS ?
1011 &local->skb_queue : &local->skb_queue_unreliable, skb);
1012 tmp = skb_queue_len(&local->skb_queue) +
1013 skb_queue_len(&local->skb_queue_unreliable);
1014 while (tmp > IEEE80211_IRQSAFE_QUEUE_LIMIT &&
1015 (skb = skb_dequeue(&local->skb_queue_unreliable))) {
1016 memcpy(&saved, skb->cb, sizeof(saved));
1017 kfree(saved);
1018 dev_kfree_skb_irq(skb);
1019 tmp--;
1020 I802_DEBUG_INC(local->tx_status_drop);
1021 }
1022 tasklet_schedule(&local->tasklet);
1023}
1024EXPORT_SYMBOL(ieee80211_tx_status_irqsafe);
1025
1026static void ieee80211_tasklet_handler(unsigned long data)
1027{
1028 struct ieee80211_local *local = (struct ieee80211_local *) data;
1029 struct sk_buff *skb;
1030 struct ieee80211_rx_status rx_status;
1031 struct ieee80211_tx_status *tx_status;
eadc8d9e 1032 struct ieee80211_ra_tid *ra_tid;
f0706e82
JB
1033
1034 while ((skb = skb_dequeue(&local->skb_queue)) ||
1035 (skb = skb_dequeue(&local->skb_queue_unreliable))) {
1036 switch (skb->pkt_type) {
1037 case IEEE80211_RX_MSG:
1038 /* status is in skb->cb */
1039 memcpy(&rx_status, skb->cb, sizeof(rx_status));
51fb61e7 1040 /* Clear skb->pkt_type in order to not confuse kernel
f0706e82
JB
1041 * netstack. */
1042 skb->pkt_type = 0;
1043 __ieee80211_rx(local_to_hw(local), skb, &rx_status);
1044 break;
1045 case IEEE80211_TX_STATUS_MSG:
1046 /* get pointer to saved status out of skb->cb */
1047 memcpy(&tx_status, skb->cb, sizeof(tx_status));
1048 skb->pkt_type = 0;
1049 ieee80211_tx_status(local_to_hw(local),
1050 skb, tx_status);
1051 kfree(tx_status);
1052 break;
eadc8d9e
RR
1053 case IEEE80211_DELBA_MSG:
1054 ra_tid = (struct ieee80211_ra_tid *) &skb->cb;
1055 ieee80211_stop_tx_ba_cb(local_to_hw(local),
1056 ra_tid->ra, ra_tid->tid);
1057 dev_kfree_skb(skb);
1058 break;
1059 case IEEE80211_ADDBA_MSG:
1060 ra_tid = (struct ieee80211_ra_tid *) &skb->cb;
1061 ieee80211_start_tx_ba_cb(local_to_hw(local),
1062 ra_tid->ra, ra_tid->tid);
1063 dev_kfree_skb(skb);
1064 break ;
f0706e82
JB
1065 default: /* should never get here! */
1066 printk(KERN_ERR "%s: Unknown message type (%d)\n",
dd1cd4c6 1067 wiphy_name(local->hw.wiphy), skb->pkt_type);
f0706e82
JB
1068 dev_kfree_skb(skb);
1069 break;
1070 }
1071 }
1072}
1073
f0706e82
JB
1074/* Remove added headers (e.g., QoS control), encryption header/MIC, etc. to
1075 * make a prepared TX frame (one that has been given to hw) to look like brand
1076 * new IEEE 802.11 frame that is ready to go through TX processing again.
1077 * Also, tx_packet_data in cb is restored from tx_control. */
1078static void ieee80211_remove_tx_extra(struct ieee80211_local *local,
1079 struct ieee80211_key *key,
1080 struct sk_buff *skb,
1081 struct ieee80211_tx_control *control)
1082{
1083 int hdrlen, iv_len, mic_len;
1084 struct ieee80211_tx_packet_data *pkt_data;
1085
1086 pkt_data = (struct ieee80211_tx_packet_data *)skb->cb;
32bfd35d 1087 pkt_data->ifindex = vif_to_sdata(control->vif)->dev->ifindex;
e8bf9649
JS
1088 pkt_data->flags = 0;
1089 if (control->flags & IEEE80211_TXCTL_REQ_TX_STATUS)
1090 pkt_data->flags |= IEEE80211_TXPD_REQ_TX_STATUS;
1091 if (control->flags & IEEE80211_TXCTL_DO_NOT_ENCRYPT)
1092 pkt_data->flags |= IEEE80211_TXPD_DO_NOT_ENCRYPT;
1093 if (control->flags & IEEE80211_TXCTL_REQUEUE)
1094 pkt_data->flags |= IEEE80211_TXPD_REQUEUE;
678f5f71
JB
1095 if (control->flags & IEEE80211_TXCTL_EAPOL_FRAME)
1096 pkt_data->flags |= IEEE80211_TXPD_EAPOL_FRAME;
f0706e82
JB
1097 pkt_data->queue = control->queue;
1098
1099 hdrlen = ieee80211_get_hdrlen_from_skb(skb);
1100
1101 if (!key)
1102 goto no_key;
1103
8f20fc24 1104 switch (key->conf.alg) {
f0706e82
JB
1105 case ALG_WEP:
1106 iv_len = WEP_IV_LEN;
1107 mic_len = WEP_ICV_LEN;
1108 break;
1109 case ALG_TKIP:
1110 iv_len = TKIP_IV_LEN;
1111 mic_len = TKIP_ICV_LEN;
1112 break;
1113 case ALG_CCMP:
1114 iv_len = CCMP_HDR_LEN;
1115 mic_len = CCMP_MIC_LEN;
1116 break;
1117 default:
1118 goto no_key;
1119 }
1120
8f20fc24 1121 if (skb->len >= mic_len &&
11a843b7 1122 !(key->flags & KEY_FLAG_UPLOADED_TO_HARDWARE))
f0706e82
JB
1123 skb_trim(skb, skb->len - mic_len);
1124 if (skb->len >= iv_len && skb->len > hdrlen) {
1125 memmove(skb->data + iv_len, skb->data, hdrlen);
1126 skb_pull(skb, iv_len);
1127 }
1128
1129no_key:
1130 {
1131 struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) skb->data;
1132 u16 fc = le16_to_cpu(hdr->frame_control);
1133 if ((fc & 0x8C) == 0x88) /* QoS Control Field */ {
1134 fc &= ~IEEE80211_STYPE_QOS_DATA;
1135 hdr->frame_control = cpu_to_le16(fc);
1136 memmove(skb->data + 2, skb->data, hdrlen - 2);
1137 skb_pull(skb, 2);
1138 }
1139 }
1140}
1141
f0706e82
JB
1142void ieee80211_tx_status(struct ieee80211_hw *hw, struct sk_buff *skb,
1143 struct ieee80211_tx_status *status)
1144{
1145 struct sk_buff *skb2;
1146 struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) skb->data;
1147 struct ieee80211_local *local = hw_to_local(hw);
1148 u16 frag, type;
b306f453
JB
1149 struct ieee80211_tx_status_rtap_hdr *rthdr;
1150 struct ieee80211_sub_if_data *sdata;
1151 int monitors;
f0706e82
JB
1152
1153 if (!status) {
1154 printk(KERN_ERR
1155 "%s: ieee80211_tx_status called with NULL status\n",
dd1cd4c6 1156 wiphy_name(local->hw.wiphy));
f0706e82
JB
1157 dev_kfree_skb(skb);
1158 return;
1159 }
1160
1161 if (status->excessive_retries) {
1162 struct sta_info *sta;
1163 sta = sta_info_get(local, hdr->addr1);
1164 if (sta) {
1165 if (sta->flags & WLAN_STA_PS) {
1166 /* The STA is in power save mode, so assume
1167 * that this TX packet failed because of that.
1168 */
1169 status->excessive_retries = 0;
1170 status->flags |= IEEE80211_TX_STATUS_TX_FILTERED;
1171 }
1172 sta_info_put(sta);
1173 }
1174 }
1175
1176 if (status->flags & IEEE80211_TX_STATUS_TX_FILTERED) {
1177 struct sta_info *sta;
1178 sta = sta_info_get(local, hdr->addr1);
1179 if (sta) {
1180 sta->tx_filtered_count++;
1181
1182 /* Clear the TX filter mask for this STA when sending
1183 * the next packet. If the STA went to power save mode,
1184 * this will happen when it is waking up for the next
1185 * time. */
1186 sta->clear_dst_mask = 1;
1187
1188 /* TODO: Is the WLAN_STA_PS flag always set here or is
1189 * the race between RX and TX status causing some
1190 * packets to be filtered out before 80211.o gets an
1191 * update for PS status? This seems to be the case, so
1192 * no changes are likely to be needed. */
1193 if (sta->flags & WLAN_STA_PS &&
1194 skb_queue_len(&sta->tx_filtered) <
1195 STA_MAX_TX_BUFFER) {
1196 ieee80211_remove_tx_extra(local, sta->key,
1197 skb,
1198 &status->control);
1199 skb_queue_tail(&sta->tx_filtered, skb);
1200 } else if (!(sta->flags & WLAN_STA_PS) &&
1201 !(status->control.flags & IEEE80211_TXCTL_REQUEUE)) {
1202 /* Software retry the packet once */
1203 status->control.flags |= IEEE80211_TXCTL_REQUEUE;
1204 ieee80211_remove_tx_extra(local, sta->key,
1205 skb,
1206 &status->control);
1207 dev_queue_xmit(skb);
1208 } else {
1209 if (net_ratelimit()) {
1210 printk(KERN_DEBUG "%s: dropped TX "
1211 "filtered frame queue_len=%d "
1212 "PS=%d @%lu\n",
dd1cd4c6 1213 wiphy_name(local->hw.wiphy),
f0706e82
JB
1214 skb_queue_len(
1215 &sta->tx_filtered),
1216 !!(sta->flags & WLAN_STA_PS),
1217 jiffies);
1218 }
1219 dev_kfree_skb(skb);
1220 }
1221 sta_info_put(sta);
1222 return;
1223 }
1abbe498
MN
1224 } else
1225 rate_control_tx_status(local->mdev, skb, status);
f0706e82
JB
1226
1227 ieee80211_led_tx(local, 0);
1228
1229 /* SNMP counters
1230 * Fragments are passed to low-level drivers as separate skbs, so these
1231 * are actually fragments, not frames. Update frame counters only for
1232 * the first fragment of the frame. */
1233
1234 frag = le16_to_cpu(hdr->seq_ctrl) & IEEE80211_SCTL_FRAG;
1235 type = le16_to_cpu(hdr->frame_control) & IEEE80211_FCTL_FTYPE;
1236
1237 if (status->flags & IEEE80211_TX_STATUS_ACK) {
1238 if (frag == 0) {
1239 local->dot11TransmittedFrameCount++;
1240 if (is_multicast_ether_addr(hdr->addr1))
1241 local->dot11MulticastTransmittedFrameCount++;
1242 if (status->retry_count > 0)
1243 local->dot11RetryCount++;
1244 if (status->retry_count > 1)
1245 local->dot11MultipleRetryCount++;
1246 }
1247
1248 /* This counter shall be incremented for an acknowledged MPDU
1249 * with an individual address in the address 1 field or an MPDU
1250 * with a multicast address in the address 1 field of type Data
1251 * or Management. */
1252 if (!is_multicast_ether_addr(hdr->addr1) ||
1253 type == IEEE80211_FTYPE_DATA ||
1254 type == IEEE80211_FTYPE_MGMT)
1255 local->dot11TransmittedFragmentCount++;
1256 } else {
1257 if (frag == 0)
1258 local->dot11FailedCount++;
1259 }
1260
b306f453
JB
1261 /* this was a transmitted frame, but now we want to reuse it */
1262 skb_orphan(skb);
1263
b306f453 1264 if (!local->monitors) {
f0706e82
JB
1265 dev_kfree_skb(skb);
1266 return;
1267 }
1268
b306f453 1269 /* send frame to monitor interfaces now */
f0706e82 1270
b306f453
JB
1271 if (skb_headroom(skb) < sizeof(*rthdr)) {
1272 printk(KERN_ERR "ieee80211_tx_status: headroom too small\n");
f0706e82
JB
1273 dev_kfree_skb(skb);
1274 return;
1275 }
f0706e82 1276
b306f453
JB
1277 rthdr = (struct ieee80211_tx_status_rtap_hdr*)
1278 skb_push(skb, sizeof(*rthdr));
1279
1280 memset(rthdr, 0, sizeof(*rthdr));
1281 rthdr->hdr.it_len = cpu_to_le16(sizeof(*rthdr));
1282 rthdr->hdr.it_present =
1283 cpu_to_le32((1 << IEEE80211_RADIOTAP_TX_FLAGS) |
1284 (1 << IEEE80211_RADIOTAP_DATA_RETRIES));
1285
1286 if (!(status->flags & IEEE80211_TX_STATUS_ACK) &&
1287 !is_multicast_ether_addr(hdr->addr1))
1288 rthdr->tx_flags |= cpu_to_le16(IEEE80211_RADIOTAP_F_TX_FAIL);
1289
1290 if ((status->control.flags & IEEE80211_TXCTL_USE_RTS_CTS) &&
1291 (status->control.flags & IEEE80211_TXCTL_USE_CTS_PROTECT))
1292 rthdr->tx_flags |= cpu_to_le16(IEEE80211_RADIOTAP_F_TX_CTS);
1293 else if (status->control.flags & IEEE80211_TXCTL_USE_RTS_CTS)
1294 rthdr->tx_flags |= cpu_to_le16(IEEE80211_RADIOTAP_F_TX_RTS);
1295
1296 rthdr->data_retries = status->retry_count;
1297
79010420 1298 rcu_read_lock();
b306f453 1299 monitors = local->monitors;
79010420 1300 list_for_each_entry_rcu(sdata, &local->interfaces, list) {
b306f453
JB
1301 /*
1302 * Using the monitors counter is possibly racy, but
1303 * if the value is wrong we simply either clone the skb
1304 * once too much or forget sending it to one monitor iface
1305 * The latter case isn't nice but fixing the race is much
1306 * more complicated.
1307 */
1308 if (!monitors || !skb)
1309 goto out;
1310
51fb61e7 1311 if (sdata->vif.type == IEEE80211_IF_TYPE_MNTR) {
b306f453
JB
1312 if (!netif_running(sdata->dev))
1313 continue;
1314 monitors--;
1315 if (monitors)
79010420 1316 skb2 = skb_clone(skb, GFP_ATOMIC);
b306f453
JB
1317 else
1318 skb2 = NULL;
1319 skb->dev = sdata->dev;
1320 /* XXX: is this sufficient for BPF? */
1321 skb_set_mac_header(skb, 0);
1322 skb->ip_summed = CHECKSUM_UNNECESSARY;
1323 skb->pkt_type = PACKET_OTHERHOST;
1324 skb->protocol = htons(ETH_P_802_2);
1325 memset(skb->cb, 0, sizeof(skb->cb));
1326 netif_rx(skb);
1327 skb = skb2;
b306f453
JB
1328 }
1329 }
1330 out:
79010420 1331 rcu_read_unlock();
b306f453
JB
1332 if (skb)
1333 dev_kfree_skb(skb);
f0706e82
JB
1334}
1335EXPORT_SYMBOL(ieee80211_tx_status);
1336
f0706e82
JB
1337struct ieee80211_hw *ieee80211_alloc_hw(size_t priv_data_len,
1338 const struct ieee80211_ops *ops)
1339{
1340 struct net_device *mdev;
1341 struct ieee80211_local *local;
1342 struct ieee80211_sub_if_data *sdata;
1343 int priv_size;
1344 struct wiphy *wiphy;
1345
1346 /* Ensure 32-byte alignment of our private data and hw private data.
1347 * We use the wiphy priv data for both our ieee80211_local and for
1348 * the driver's private data
1349 *
1350 * In memory it'll be like this:
1351 *
1352 * +-------------------------+
1353 * | struct wiphy |
1354 * +-------------------------+
1355 * | struct ieee80211_local |
1356 * +-------------------------+
1357 * | driver's private data |
1358 * +-------------------------+
1359 *
1360 */
1361 priv_size = ((sizeof(struct ieee80211_local) +
1362 NETDEV_ALIGN_CONST) & ~NETDEV_ALIGN_CONST) +
1363 priv_data_len;
1364
1365 wiphy = wiphy_new(&mac80211_config_ops, priv_size);
1366
1367 if (!wiphy)
1368 return NULL;
1369
1370 wiphy->privid = mac80211_wiphy_privid;
1371
1372 local = wiphy_priv(wiphy);
1373 local->hw.wiphy = wiphy;
1374
1375 local->hw.priv = (char *)local +
1376 ((sizeof(struct ieee80211_local) +
1377 NETDEV_ALIGN_CONST) & ~NETDEV_ALIGN_CONST);
1378
4480f15c 1379 BUG_ON(!ops->tx);
4150c572
JB
1380 BUG_ON(!ops->start);
1381 BUG_ON(!ops->stop);
4480f15c
JB
1382 BUG_ON(!ops->config);
1383 BUG_ON(!ops->add_interface);
4150c572
JB
1384 BUG_ON(!ops->remove_interface);
1385 BUG_ON(!ops->configure_filter);
f0706e82
JB
1386 local->ops = ops;
1387
1388 /* for now, mdev needs sub_if_data :/ */
1389 mdev = alloc_netdev(sizeof(struct ieee80211_sub_if_data),
1390 "wmaster%d", ether_setup);
1391 if (!mdev) {
1392 wiphy_free(wiphy);
1393 return NULL;
1394 }
1395
1396 sdata = IEEE80211_DEV_TO_SUB_IF(mdev);
1397 mdev->ieee80211_ptr = &sdata->wdev;
1398 sdata->wdev.wiphy = wiphy;
1399
1400 local->hw.queues = 1; /* default */
1401
1402 local->mdev = mdev;
f0706e82
JB
1403 local->rx_handlers = ieee80211_rx_handlers;
1404 local->tx_handlers = ieee80211_tx_handlers;
1405
1406 local->bridge_packets = 1;
1407
1408 local->rts_threshold = IEEE80211_MAX_RTS_THRESHOLD;
1409 local->fragmentation_threshold = IEEE80211_MAX_FRAG_THRESHOLD;
1410 local->short_retry_limit = 7;
1411 local->long_retry_limit = 4;
1412 local->hw.conf.radio_enabled = 1;
f0706e82 1413
79010420 1414 INIT_LIST_HEAD(&local->interfaces);
f0706e82
JB
1415
1416 INIT_DELAYED_WORK(&local->scan_work, ieee80211_sta_scan_work);
f0706e82
JB
1417 ieee80211_rx_bss_list_init(mdev);
1418
1419 sta_info_init(local);
1420
1421 mdev->hard_start_xmit = ieee80211_master_start_xmit;
1422 mdev->open = ieee80211_master_open;
1423 mdev->stop = ieee80211_master_stop;
1424 mdev->type = ARPHRD_IEEE80211;
3b04ddde 1425 mdev->header_ops = &ieee80211_header_ops;
4150c572 1426 mdev->set_multicast_list = ieee80211_master_set_multicast_list;
f0706e82 1427
51fb61e7 1428 sdata->vif.type = IEEE80211_IF_TYPE_AP;
f0706e82
JB
1429 sdata->dev = mdev;
1430 sdata->local = local;
1431 sdata->u.ap.force_unicast_rateidx = -1;
1432 sdata->u.ap.max_ratectrl_rateidx = -1;
1433 ieee80211_if_sdata_init(sdata);
79010420
JB
1434 /* no RCU needed since we're still during init phase */
1435 list_add_tail(&sdata->list, &local->interfaces);
f0706e82
JB
1436
1437 tasklet_init(&local->tx_pending_tasklet, ieee80211_tx_pending,
1438 (unsigned long)local);
1439 tasklet_disable(&local->tx_pending_tasklet);
1440
1441 tasklet_init(&local->tasklet,
1442 ieee80211_tasklet_handler,
1443 (unsigned long) local);
1444 tasklet_disable(&local->tasklet);
1445
1446 skb_queue_head_init(&local->skb_queue);
1447 skb_queue_head_init(&local->skb_queue_unreliable);
1448
1449 return local_to_hw(local);
1450}
1451EXPORT_SYMBOL(ieee80211_alloc_hw);
1452
1453int ieee80211_register_hw(struct ieee80211_hw *hw)
1454{
1455 struct ieee80211_local *local = hw_to_local(hw);
1456 const char *name;
1457 int result;
8318d78a
JB
1458 enum ieee80211_band band;
1459
1460 /*
1461 * generic code guarantees at least one band,
1462 * set this very early because much code assumes
1463 * that hw.conf.channel is assigned
1464 */
1465 for (band = 0; band < IEEE80211_NUM_BANDS; band++) {
1466 struct ieee80211_supported_band *sband;
1467
1468 sband = local->hw.wiphy->bands[band];
1469 if (sband) {
1470 /* init channel we're on */
1471 local->hw.conf.channel =
1472 local->oper_channel =
1473 local->scan_channel = &sband->channels[0];
1474 break;
1475 }
1476 }
f0706e82
JB
1477
1478 result = wiphy_register(local->hw.wiphy);
1479 if (result < 0)
1480 return result;
1481
1482 name = wiphy_dev(local->hw.wiphy)->driver->name;
1483 local->hw.workqueue = create_singlethread_workqueue(name);
1484 if (!local->hw.workqueue) {
1485 result = -ENOMEM;
1486 goto fail_workqueue;
1487 }
1488
b306f453
JB
1489 /*
1490 * The hardware needs headroom for sending the frame,
1491 * and we need some headroom for passing the frame to monitor
1492 * interfaces, but never both at the same time.
1493 */
33ccad35
JB
1494 local->tx_headroom = max_t(unsigned int , local->hw.extra_tx_headroom,
1495 sizeof(struct ieee80211_tx_status_rtap_hdr));
b306f453 1496
e9f207f0
JB
1497 debugfs_hw_add(local);
1498
f0706e82
JB
1499 local->hw.conf.beacon_int = 1000;
1500
1501 local->wstats_flags |= local->hw.max_rssi ?
1502 IW_QUAL_LEVEL_UPDATED : IW_QUAL_LEVEL_INVALID;
1503 local->wstats_flags |= local->hw.max_signal ?
1504 IW_QUAL_QUAL_UPDATED : IW_QUAL_QUAL_INVALID;
1505 local->wstats_flags |= local->hw.max_noise ?
1506 IW_QUAL_NOISE_UPDATED : IW_QUAL_NOISE_INVALID;
1507 if (local->hw.max_rssi < 0 || local->hw.max_noise < 0)
1508 local->wstats_flags |= IW_QUAL_DBM;
1509
1510 result = sta_info_start(local);
1511 if (result < 0)
1512 goto fail_sta_info;
1513
1514 rtnl_lock();
1515 result = dev_alloc_name(local->mdev, local->mdev->name);
1516 if (result < 0)
1517 goto fail_dev;
1518
1519 memcpy(local->mdev->dev_addr, local->hw.wiphy->perm_addr, ETH_ALEN);
1520 SET_NETDEV_DEV(local->mdev, wiphy_dev(local->hw.wiphy));
1521
1522 result = register_netdevice(local->mdev);
1523 if (result < 0)
1524 goto fail_dev;
1525
e9f207f0 1526 ieee80211_debugfs_add_netdev(IEEE80211_DEV_TO_SUB_IF(local->mdev));
5b2812e9 1527 ieee80211_if_set_type(local->mdev, IEEE80211_IF_TYPE_AP);
e9f207f0 1528
830f9038
JB
1529 result = ieee80211_init_rate_ctrl_alg(local,
1530 hw->rate_control_algorithm);
f0706e82
JB
1531 if (result < 0) {
1532 printk(KERN_DEBUG "%s: Failed to initialize rate control "
dd1cd4c6 1533 "algorithm\n", wiphy_name(local->hw.wiphy));
f0706e82
JB
1534 goto fail_rate;
1535 }
1536
1537 result = ieee80211_wep_init(local);
1538
1539 if (result < 0) {
1540 printk(KERN_DEBUG "%s: Failed to initialize wep\n",
dd1cd4c6 1541 wiphy_name(local->hw.wiphy));
f0706e82
JB
1542 goto fail_wep;
1543 }
1544
1545 ieee80211_install_qdisc(local->mdev);
1546
1547 /* add one default STA interface */
1548 result = ieee80211_if_add(local->mdev, "wlan%d", NULL,
1549 IEEE80211_IF_TYPE_STA);
1550 if (result)
1551 printk(KERN_WARNING "%s: Failed to add default virtual iface\n",
dd1cd4c6 1552 wiphy_name(local->hw.wiphy));
f0706e82
JB
1553
1554 local->reg_state = IEEE80211_DEV_REGISTERED;
1555 rtnl_unlock();
1556
1557 ieee80211_led_init(local);
1558
1559 return 0;
1560
1561fail_wep:
1562 rate_control_deinitialize(local);
1563fail_rate:
e9f207f0 1564 ieee80211_debugfs_remove_netdev(IEEE80211_DEV_TO_SUB_IF(local->mdev));
f0706e82
JB
1565 unregister_netdevice(local->mdev);
1566fail_dev:
1567 rtnl_unlock();
1568 sta_info_stop(local);
1569fail_sta_info:
e9f207f0 1570 debugfs_hw_del(local);
f0706e82
JB
1571 destroy_workqueue(local->hw.workqueue);
1572fail_workqueue:
1573 wiphy_unregister(local->hw.wiphy);
1574 return result;
1575}
1576EXPORT_SYMBOL(ieee80211_register_hw);
1577
f0706e82
JB
1578void ieee80211_unregister_hw(struct ieee80211_hw *hw)
1579{
1580 struct ieee80211_local *local = hw_to_local(hw);
1581 struct ieee80211_sub_if_data *sdata, *tmp;
f0706e82
JB
1582
1583 tasklet_kill(&local->tx_pending_tasklet);
1584 tasklet_kill(&local->tasklet);
1585
1586 rtnl_lock();
1587
1588 BUG_ON(local->reg_state != IEEE80211_DEV_REGISTERED);
1589
1590 local->reg_state = IEEE80211_DEV_UNREGISTERED;
f0706e82 1591
79010420
JB
1592 /*
1593 * At this point, interface list manipulations are fine
1594 * because the driver cannot be handing us frames any
1595 * more and the tasklet is killed.
1596 */
5b2812e9
JB
1597
1598 /*
1599 * First, we remove all non-master interfaces. Do this because they
1600 * may have bss pointer dependency on the master, and when we free
1601 * the master these would be freed as well, breaking our list
1602 * iteration completely.
1603 */
1604 list_for_each_entry_safe(sdata, tmp, &local->interfaces, list) {
1605 if (sdata->dev == local->mdev)
1606 continue;
1607 list_del(&sdata->list);
f0706e82 1608 __ieee80211_if_del(local, sdata);
5b2812e9
JB
1609 }
1610
1611 /* then, finally, remove the master interface */
1612 __ieee80211_if_del(local, IEEE80211_DEV_TO_SUB_IF(local->mdev));
f0706e82
JB
1613
1614 rtnl_unlock();
1615
f0706e82
JB
1616 ieee80211_rx_bss_list_deinit(local->mdev);
1617 ieee80211_clear_tx_pending(local);
1618 sta_info_stop(local);
1619 rate_control_deinitialize(local);
e9f207f0 1620 debugfs_hw_del(local);
f0706e82 1621
f0706e82
JB
1622 if (skb_queue_len(&local->skb_queue)
1623 || skb_queue_len(&local->skb_queue_unreliable))
1624 printk(KERN_WARNING "%s: skb_queue not empty\n",
dd1cd4c6 1625 wiphy_name(local->hw.wiphy));
f0706e82
JB
1626 skb_queue_purge(&local->skb_queue);
1627 skb_queue_purge(&local->skb_queue_unreliable);
1628
1629 destroy_workqueue(local->hw.workqueue);
1630 wiphy_unregister(local->hw.wiphy);
1631 ieee80211_wep_free(local);
1632 ieee80211_led_exit(local);
1633}
1634EXPORT_SYMBOL(ieee80211_unregister_hw);
1635
1636void ieee80211_free_hw(struct ieee80211_hw *hw)
1637{
1638 struct ieee80211_local *local = hw_to_local(hw);
1639
1640 ieee80211_if_free(local->mdev);
1641 wiphy_free(local->hw.wiphy);
1642}
1643EXPORT_SYMBOL(ieee80211_free_hw);
1644
f0706e82
JB
1645static int __init ieee80211_init(void)
1646{
1647 struct sk_buff *skb;
1648 int ret;
1649
1650 BUILD_BUG_ON(sizeof(struct ieee80211_tx_packet_data) > sizeof(skb->cb));
1651
4b475898 1652 ret = rc80211_simple_init();
ac71c691 1653 if (ret)
3eadf5f4 1654 goto out;
ad018375 1655
4b475898 1656 ret = rc80211_pid_init();
ad018375 1657 if (ret)
3eadf5f4 1658 goto out_cleanup_simple;
ac71c691 1659
f0706e82
JB
1660 ret = ieee80211_wme_register();
1661 if (ret) {
1662 printk(KERN_DEBUG "ieee80211_init: failed to "
1663 "initialize WME (err=%d)\n", ret);
3eadf5f4 1664 goto out_cleanup_pid;
f0706e82
JB
1665 }
1666
e9f207f0
JB
1667 ieee80211_debugfs_netdev_init();
1668
f0706e82 1669 return 0;
ad018375 1670
3eadf5f4 1671 out_cleanup_pid:
4b475898 1672 rc80211_pid_exit();
3eadf5f4
JB
1673 out_cleanup_simple:
1674 rc80211_simple_exit();
1675 out:
ad018375 1676 return ret;
f0706e82
JB
1677}
1678
f0706e82
JB
1679static void __exit ieee80211_exit(void)
1680{
4b475898
JB
1681 rc80211_simple_exit();
1682 rc80211_pid_exit();
ac71c691 1683
f0706e82 1684 ieee80211_wme_unregister();
e9f207f0 1685 ieee80211_debugfs_netdev_exit();
f0706e82
JB
1686}
1687
1688
ca9938fe 1689subsys_initcall(ieee80211_init);
f0706e82
JB
1690module_exit(ieee80211_exit);
1691
1692MODULE_DESCRIPTION("IEEE 802.11 subsystem");
1693MODULE_LICENSE("GPL");
This page took 0.380349 seconds and 5 git commands to generate.