blob: 727af295c9693ce8fefa0bcc916da9a64cd24bb4 [file] [log] [blame]
Jiri Bencf0706e82007-05-05 11:45:53 -07001/*
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>
Jiri Bencf0706e82007-05-05 11:45:53 -070023#include <linux/bitmap.h>
Eric W. Biederman881d9662007-09-17 11:56:21 -070024#include <net/net_namespace.h>
Jiri Bencf0706e82007-05-05 11:45:53 -070025#include <net/cfg80211.h>
26
Jiri Bencf0706e82007-05-05 11:45:53 -070027#include "ieee80211_i.h"
28#include "ieee80211_rate.h"
Luis Carlos Cobof7a92142008-02-23 15:17:18 +010029#include "mesh.h"
Jiri Bencf0706e82007-05-05 11:45:53 -070030#include "wep.h"
Jiri Bencf0706e82007-05-05 11:45:53 -070031#include "wme.h"
32#include "aes_ccm.h"
33#include "ieee80211_led.h"
Michael Wue0eb6852007-09-18 17:29:21 -040034#include "cfg.h"
Jiri Bence9f207f2007-05-05 11:46:38 -070035#include "debugfs.h"
36#include "debugfs_netdev.h"
Jiri Bencf0706e82007-05-05 11:45:53 -070037
Ron Rindjunskyd3c990f2007-11-26 16:14:34 +020038#define SUPP_MCS_SET_LEN 16
39
Johannes Bergb306f452007-07-10 19:32:08 +020040/*
41 * For seeing transmitted packets on monitor interfaces
42 * we have a radiotap header too.
43 */
44struct ieee80211_tx_status_rtap_hdr {
45 struct ieee80211_radiotap_header hdr;
46 __le16 tx_flags;
47 u8 data_retries;
48} __attribute__ ((packed));
49
Johannes Bergb2c258f2007-07-27 15:43:23 +020050/* common interface routines */
Jiri Bencf0706e82007-05-05 11:45:53 -070051
Stephen Hemmingerb95cce32007-09-26 22:13:38 -070052static int header_parse_80211(const struct sk_buff *skb, unsigned char *haddr)
Jiri Bencf0706e82007-05-05 11:45:53 -070053{
Johannes Bergb2c258f2007-07-27 15:43:23 +020054 memcpy(haddr, skb_mac_header(skb) + 10, ETH_ALEN); /* addr2 */
55 return ETH_ALEN;
Jiri Bencf0706e82007-05-05 11:45:53 -070056}
57
Johannes Berg4150c572007-09-17 01:29:23 -040058/* must be called under mdev tx lock */
59static void ieee80211_configure_filter(struct ieee80211_local *local)
60{
61 unsigned int changed_flags;
62 unsigned int new_flags = 0;
63
Johannes Berg53918992007-09-26 15:19:47 +020064 if (atomic_read(&local->iff_promiscs))
Johannes Berg4150c572007-09-17 01:29:23 -040065 new_flags |= FIF_PROMISC_IN_BSS;
66
Johannes Berg53918992007-09-26 15:19:47 +020067 if (atomic_read(&local->iff_allmultis))
Johannes Berg4150c572007-09-17 01:29:23 -040068 new_flags |= FIF_ALLMULTI;
69
70 if (local->monitors)
Michael Wu8cc9a732008-01-31 19:48:23 +010071 new_flags |= FIF_BCN_PRBRESP_PROMISC;
72
73 if (local->fif_fcsfail)
74 new_flags |= FIF_FCSFAIL;
75
76 if (local->fif_plcpfail)
77 new_flags |= FIF_PLCPFAIL;
78
79 if (local->fif_control)
80 new_flags |= FIF_CONTROL;
81
82 if (local->fif_other_bss)
83 new_flags |= FIF_OTHER_BSS;
Johannes Berg4150c572007-09-17 01:29:23 -040084
85 changed_flags = local->filter_flags ^ new_flags;
86
87 /* be a bit nasty */
88 new_flags |= (1<<31);
89
90 local->ops->configure_filter(local_to_hw(local),
91 changed_flags, &new_flags,
92 local->mdev->mc_count,
93 local->mdev->mc_list);
94
95 WARN_ON(new_flags & (1<<31));
96
97 local->filter_flags = new_flags & ~(1<<31);
98}
99
Johannes Bergb2c258f2007-07-27 15:43:23 +0200100/* master interface */
Jiri Bencf0706e82007-05-05 11:45:53 -0700101
102static int ieee80211_master_open(struct net_device *dev)
103{
104 struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr);
105 struct ieee80211_sub_if_data *sdata;
106 int res = -EOPNOTSUPP;
107
Johannes Berg79010422007-09-18 17:29:21 -0400108 /* we hold the RTNL here so can safely walk the list */
109 list_for_each_entry(sdata, &local->interfaces, list) {
Jiri Bencf0706e82007-05-05 11:45:53 -0700110 if (sdata->dev != dev && netif_running(sdata->dev)) {
111 res = 0;
112 break;
113 }
114 }
Jiri Bencf0706e82007-05-05 11:45:53 -0700115 return res;
116}
117
118static int ieee80211_master_stop(struct net_device *dev)
119{
120 struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr);
121 struct ieee80211_sub_if_data *sdata;
122
Johannes Berg79010422007-09-18 17:29:21 -0400123 /* we hold the RTNL here so can safely walk the list */
124 list_for_each_entry(sdata, &local->interfaces, list)
Jiri Bencf0706e82007-05-05 11:45:53 -0700125 if (sdata->dev != dev && netif_running(sdata->dev))
126 dev_close(sdata->dev);
Jiri Bencf0706e82007-05-05 11:45:53 -0700127
128 return 0;
129}
130
Johannes Berg4150c572007-09-17 01:29:23 -0400131static void ieee80211_master_set_multicast_list(struct net_device *dev)
132{
133 struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr);
134
135 ieee80211_configure_filter(local);
136}
137
Johannes Bergb2c258f2007-07-27 15:43:23 +0200138/* regular interfaces */
139
140static int ieee80211_change_mtu(struct net_device *dev, int new_mtu)
141{
Luis Carlos Cobof7a92142008-02-23 15:17:18 +0100142 int meshhdrlen;
143 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
144
145 meshhdrlen = (sdata->vif.type == IEEE80211_IF_TYPE_MESH_POINT) ? 5 : 0;
146
Johannes Bergb2c258f2007-07-27 15:43:23 +0200147 /* FIX: what would be proper limits for MTU?
148 * This interface uses 802.3 frames. */
Luis Carlos Cobof7a92142008-02-23 15:17:18 +0100149 if (new_mtu < 256 ||
150 new_mtu > IEEE80211_MAX_DATA_LEN - 24 - 6 - meshhdrlen) {
Johannes Bergb2c258f2007-07-27 15:43:23 +0200151 printk(KERN_WARNING "%s: invalid MTU %d\n",
152 dev->name, new_mtu);
153 return -EINVAL;
154 }
155
156#ifdef CONFIG_MAC80211_VERBOSE_DEBUG
157 printk(KERN_DEBUG "%s: setting MTU %d\n", dev->name, new_mtu);
158#endif /* CONFIG_MAC80211_VERBOSE_DEBUG */
159 dev->mtu = new_mtu;
160 return 0;
161}
162
163static inline int identical_mac_addr_allowed(int type1, int type2)
164{
165 return (type1 == IEEE80211_IF_TYPE_MNTR ||
166 type2 == IEEE80211_IF_TYPE_MNTR ||
167 (type1 == IEEE80211_IF_TYPE_AP &&
168 type2 == IEEE80211_IF_TYPE_WDS) ||
169 (type1 == IEEE80211_IF_TYPE_WDS &&
170 (type2 == IEEE80211_IF_TYPE_WDS ||
171 type2 == IEEE80211_IF_TYPE_AP)) ||
172 (type1 == IEEE80211_IF_TYPE_AP &&
173 type2 == IEEE80211_IF_TYPE_VLAN) ||
174 (type1 == IEEE80211_IF_TYPE_VLAN &&
175 (type2 == IEEE80211_IF_TYPE_AP ||
176 type2 == IEEE80211_IF_TYPE_VLAN)));
177}
178
Johannes Bergb2c258f2007-07-27 15:43:23 +0200179static int ieee80211_open(struct net_device *dev)
180{
181 struct ieee80211_sub_if_data *sdata, *nsdata;
182 struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr);
183 struct ieee80211_if_init_conf conf;
184 int res;
Michael Bueschceffefd2008-02-10 14:16:52 +0100185 bool need_hw_reconfig = 0;
Johannes Bergb2c258f2007-07-27 15:43:23 +0200186
187 sdata = IEEE80211_DEV_TO_SUB_IF(dev);
Johannes Berg0ec3ca42007-09-17 01:29:24 -0400188
Johannes Berg79010422007-09-18 17:29:21 -0400189 /* we hold the RTNL here so can safely walk the list */
190 list_for_each_entry(nsdata, &local->interfaces, list) {
Johannes Bergb2c258f2007-07-27 15:43:23 +0200191 struct net_device *ndev = nsdata->dev;
192
Johannes Berg665e8aa2008-02-21 01:10:07 +0100193 if (ndev != dev && ndev != local->mdev && netif_running(ndev)) {
194 /*
195 * Allow only a single IBSS interface to be up at any
196 * time. This is restricted because beacon distribution
197 * cannot work properly if both are in the same IBSS.
198 *
199 * To remove this restriction we'd have to disallow them
200 * from setting the same SSID on different IBSS interfaces
201 * belonging to the same hardware. Then, however, we're
202 * faced with having to adopt two different TSF timers...
203 */
204 if (sdata->vif.type == IEEE80211_IF_TYPE_IBSS &&
205 nsdata->vif.type == IEEE80211_IF_TYPE_IBSS)
206 return -EBUSY;
207
208 /*
209 * Disallow multiple IBSS/STA mode interfaces.
210 *
211 * This is a technical restriction, it is possible although
212 * most likely not IEEE 802.11 compliant to have multiple
213 * STAs with just a single hardware (the TSF timer will not
214 * be adjusted properly.)
215 *
216 * However, because mac80211 uses the master device's BSS
217 * information for each STA/IBSS interface, doing this will
218 * currently corrupt that BSS information completely, unless,
219 * a not very useful case, both STAs are associated to the
220 * same BSS.
221 *
222 * To remove this restriction, the BSS information needs to
223 * be embedded in the STA/IBSS mode sdata instead of using
224 * the master device's BSS structure.
225 */
226 if ((sdata->vif.type == IEEE80211_IF_TYPE_STA ||
227 sdata->vif.type == IEEE80211_IF_TYPE_IBSS) &&
228 (nsdata->vif.type == IEEE80211_IF_TYPE_STA ||
229 nsdata->vif.type == IEEE80211_IF_TYPE_IBSS))
230 return -EBUSY;
231
232 /*
233 * The remaining checks are only performed for interfaces
234 * with the same MAC address.
235 */
236 if (compare_ether_addr(dev->dev_addr, ndev->dev_addr))
237 continue;
238
Johannes Berg0ec3ca42007-09-17 01:29:24 -0400239 /*
240 * check whether it may have the same address
241 */
Johannes Berg51fb61e2007-12-19 01:31:27 +0100242 if (!identical_mac_addr_allowed(sdata->vif.type,
243 nsdata->vif.type))
Johannes Berg0ec3ca42007-09-17 01:29:24 -0400244 return -ENOTUNIQ;
Johannes Berg0ec3ca42007-09-17 01:29:24 -0400245
246 /*
247 * can only add VLANs to enabled APs
248 */
Johannes Berg51fb61e2007-12-19 01:31:27 +0100249 if (sdata->vif.type == IEEE80211_IF_TYPE_VLAN &&
Johannes Berg665e8aa2008-02-21 01:10:07 +0100250 nsdata->vif.type == IEEE80211_IF_TYPE_AP)
Johannes Berg0ec3ca42007-09-17 01:29:24 -0400251 sdata->u.vlan.ap = nsdata;
Johannes Bergb2c258f2007-07-27 15:43:23 +0200252 }
253 }
Johannes Bergb2c258f2007-07-27 15:43:23 +0200254
Johannes Berg51fb61e2007-12-19 01:31:27 +0100255 switch (sdata->vif.type) {
Johannes Berg0ec3ca42007-09-17 01:29:24 -0400256 case IEEE80211_IF_TYPE_WDS:
257 if (is_zero_ether_addr(sdata->u.wds.remote_addr))
258 return -ENOLINK;
259 break;
260 case IEEE80211_IF_TYPE_VLAN:
261 if (!sdata->u.vlan.ap)
262 return -ENOLINK;
263 break;
Johannes Bergfb1c1cd2007-09-26 15:19:43 +0200264 case IEEE80211_IF_TYPE_AP:
Johannes Bergfb1c1cd2007-09-26 15:19:43 +0200265 case IEEE80211_IF_TYPE_STA:
266 case IEEE80211_IF_TYPE_MNTR:
267 case IEEE80211_IF_TYPE_IBSS:
Johannes Berg6032f932008-02-23 15:17:07 +0100268 case IEEE80211_IF_TYPE_MESH_POINT:
Johannes Bergfb1c1cd2007-09-26 15:19:43 +0200269 /* no special treatment */
270 break;
Johannes Berga2897552007-09-28 14:01:25 +0200271 case IEEE80211_IF_TYPE_INVALID:
272 /* cannot happen */
273 WARN_ON(1);
274 break;
Johannes Berg0ec3ca42007-09-17 01:29:24 -0400275 }
Johannes Bergb2c258f2007-07-27 15:43:23 +0200276
Johannes Bergb2c258f2007-07-27 15:43:23 +0200277 if (local->open_count == 0) {
278 res = 0;
Johannes Berg4150c572007-09-17 01:29:23 -0400279 if (local->ops->start)
280 res = local->ops->start(local_to_hw(local));
281 if (res)
Johannes Bergb2c258f2007-07-27 15:43:23 +0200282 return res;
Michael Bueschceffefd2008-02-10 14:16:52 +0100283 need_hw_reconfig = 1;
Ivo van Doorncdcb0062008-01-07 19:45:24 +0100284 ieee80211_led_radio(local, local->hw.conf.radio_enabled);
Johannes Bergb2c258f2007-07-27 15:43:23 +0200285 }
Johannes Bergb2c258f2007-07-27 15:43:23 +0200286
Johannes Berg51fb61e2007-12-19 01:31:27 +0100287 switch (sdata->vif.type) {
Johannes Berg0ec3ca42007-09-17 01:29:24 -0400288 case IEEE80211_IF_TYPE_VLAN:
289 list_add(&sdata->u.vlan.list, &sdata->u.vlan.ap->u.ap.vlans);
290 /* no need to tell driver */
291 break;
Johannes Berg4150c572007-09-17 01:29:23 -0400292 case IEEE80211_IF_TYPE_MNTR:
Michael Wu3d30d942008-01-31 19:48:27 +0100293 if (sdata->u.mntr_flags & MONITOR_FLAG_COOK_FRAMES) {
294 local->cooked_mntrs++;
295 break;
296 }
297
Johannes Berg4150c572007-09-17 01:29:23 -0400298 /* must be before the call to ieee80211_configure_filter */
Johannes Bergb2c258f2007-07-27 15:43:23 +0200299 local->monitors++;
Michael Wu8cc9a732008-01-31 19:48:23 +0100300 if (local->monitors == 1)
Johannes Berg4150c572007-09-17 01:29:23 -0400301 local->hw.conf.flags |= IEEE80211_CONF_RADIOTAP;
Michael Wu8cc9a732008-01-31 19:48:23 +0100302
303 if (sdata->u.mntr_flags & MONITOR_FLAG_FCSFAIL)
304 local->fif_fcsfail++;
305 if (sdata->u.mntr_flags & MONITOR_FLAG_PLCPFAIL)
306 local->fif_plcpfail++;
307 if (sdata->u.mntr_flags & MONITOR_FLAG_CONTROL)
308 local->fif_control++;
309 if (sdata->u.mntr_flags & MONITOR_FLAG_OTHER_BSS)
310 local->fif_other_bss++;
311
312 netif_tx_lock_bh(local->mdev);
313 ieee80211_configure_filter(local);
314 netif_tx_unlock_bh(local->mdev);
Johannes Berg4150c572007-09-17 01:29:23 -0400315 break;
316 case IEEE80211_IF_TYPE_STA:
317 case IEEE80211_IF_TYPE_IBSS:
318 sdata->u.sta.flags &= ~IEEE80211_STA_PREV_BSSID_SET;
319 /* fall through */
320 default:
Johannes Berg32bfd352007-12-19 01:31:26 +0100321 conf.vif = &sdata->vif;
Johannes Berg51fb61e2007-12-19 01:31:27 +0100322 conf.type = sdata->vif.type;
Johannes Berg4150c572007-09-17 01:29:23 -0400323 conf.mac_addr = dev->dev_addr;
324 res = local->ops->add_interface(local_to_hw(local), &conf);
325 if (res && !local->open_count && local->ops->stop)
326 local->ops->stop(local_to_hw(local));
327 if (res)
328 return res;
329
Johannes Bergb2c258f2007-07-27 15:43:23 +0200330 ieee80211_if_config(dev);
Daniel Draked9430a32007-07-27 15:43:24 +0200331 ieee80211_reset_erp_info(dev);
Johannes Berg11a843b2007-08-28 17:01:55 -0400332 ieee80211_enable_keys(sdata);
Johannes Berg4150c572007-09-17 01:29:23 -0400333
Johannes Berg51fb61e2007-12-19 01:31:27 +0100334 if (sdata->vif.type == IEEE80211_IF_TYPE_STA &&
Johannes Bergddd3d2b2007-09-26 17:53:20 +0200335 !(sdata->flags & IEEE80211_SDATA_USERSPACE_MLME))
Johannes Berg4150c572007-09-17 01:29:23 -0400336 netif_carrier_off(dev);
337 else
338 netif_carrier_on(dev);
Daniel Draked9430a32007-07-27 15:43:24 +0200339 }
Johannes Bergb2c258f2007-07-27 15:43:23 +0200340
Johannes Berg4150c572007-09-17 01:29:23 -0400341 if (local->open_count == 0) {
342 res = dev_open(local->mdev);
343 WARN_ON(res);
Johannes Berg4150c572007-09-17 01:29:23 -0400344 tasklet_enable(&local->tx_pending_tasklet);
345 tasklet_enable(&local->tasklet);
346 }
347
Johannes Bergc1428b32007-11-16 02:54:53 +0100348 /*
349 * set_multicast_list will be invoked by the networking core
350 * which will check whether any increments here were done in
351 * error and sync them down to the hardware as filter flags.
352 */
353 if (sdata->flags & IEEE80211_SDATA_ALLMULTI)
354 atomic_inc(&local->iff_allmultis);
355
356 if (sdata->flags & IEEE80211_SDATA_PROMISC)
357 atomic_inc(&local->iff_promiscs);
358
Johannes Berg4150c572007-09-17 01:29:23 -0400359 local->open_count++;
Michael Bueschceffefd2008-02-10 14:16:52 +0100360 if (need_hw_reconfig)
361 ieee80211_hw_config(local);
Johannes Bergb2c258f2007-07-27 15:43:23 +0200362
363 netif_start_queue(dev);
Johannes Berg4150c572007-09-17 01:29:23 -0400364
Johannes Bergb2c258f2007-07-27 15:43:23 +0200365 return 0;
366}
367
Johannes Berg4150c572007-09-17 01:29:23 -0400368static int ieee80211_stop(struct net_device *dev)
Johannes Bergb2c258f2007-07-27 15:43:23 +0200369{
Johannes Berg4150c572007-09-17 01:29:23 -0400370 struct ieee80211_sub_if_data *sdata;
Johannes Bergb2c258f2007-07-27 15:43:23 +0200371 struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr);
Johannes Berg4150c572007-09-17 01:29:23 -0400372 struct ieee80211_if_init_conf conf;
Ron Rindjunsky07db2182007-12-25 17:00:33 +0200373 struct sta_info *sta;
374 int i;
Johannes Bergb2c258f2007-07-27 15:43:23 +0200375
Johannes Berg4150c572007-09-17 01:29:23 -0400376 sdata = IEEE80211_DEV_TO_SUB_IF(dev);
377
Ron Rindjunsky07db2182007-12-25 17:00:33 +0200378 list_for_each_entry(sta, &local->sta_list, list) {
Ron Rindjunsky5b3d71d2008-01-13 18:21:58 +0200379 if (sta->dev == dev)
380 for (i = 0; i < STA_TID_NUM; i++)
381 ieee80211_sta_stop_rx_ba_session(sta->dev,
382 sta->addr, i,
383 WLAN_BACK_RECIPIENT,
Ron Rindjunsky07db2182007-12-25 17:00:33 +0200384 WLAN_REASON_QSTA_LEAVE_QBSS);
385 }
386
Johannes Berg4150c572007-09-17 01:29:23 -0400387 netif_stop_queue(dev);
388
Johannes Bergc1428b32007-11-16 02:54:53 +0100389 /*
390 * Don't count this interface for promisc/allmulti while it
391 * is down. dev_mc_unsync() will invoke set_multicast_list
392 * on the master interface which will sync these down to the
393 * hardware as filter flags.
394 */
395 if (sdata->flags & IEEE80211_SDATA_ALLMULTI)
396 atomic_dec(&local->iff_allmultis);
397
398 if (sdata->flags & IEEE80211_SDATA_PROMISC)
399 atomic_dec(&local->iff_promiscs);
400
Johannes Berg4150c572007-09-17 01:29:23 -0400401 dev_mc_unsync(local->mdev, dev);
402
Johannes Berg5dfdaf52007-12-19 02:03:33 +0100403 /* APs need special treatment */
Johannes Berg51fb61e2007-12-19 01:31:27 +0100404 if (sdata->vif.type == IEEE80211_IF_TYPE_AP) {
Johannes Berg0ec3ca42007-09-17 01:29:24 -0400405 struct ieee80211_sub_if_data *vlan, *tmp;
Johannes Berg5dfdaf52007-12-19 02:03:33 +0100406 struct beacon_data *old_beacon = sdata->u.ap.beacon;
Johannes Berg0ec3ca42007-09-17 01:29:24 -0400407
Johannes Berg5dfdaf52007-12-19 02:03:33 +0100408 /* remove beacon */
409 rcu_assign_pointer(sdata->u.ap.beacon, NULL);
410 synchronize_rcu();
411 kfree(old_beacon);
412
413 /* down all dependent devices, that is VLANs */
Johannes Berg0ec3ca42007-09-17 01:29:24 -0400414 list_for_each_entry_safe(vlan, tmp, &sdata->u.ap.vlans,
415 u.vlan.list)
416 dev_close(vlan->dev);
417 WARN_ON(!list_empty(&sdata->u.ap.vlans));
418 }
419
Johannes Berg4150c572007-09-17 01:29:23 -0400420 local->open_count--;
421
Johannes Berg51fb61e2007-12-19 01:31:27 +0100422 switch (sdata->vif.type) {
Johannes Berg0ec3ca42007-09-17 01:29:24 -0400423 case IEEE80211_IF_TYPE_VLAN:
424 list_del(&sdata->u.vlan.list);
425 sdata->u.vlan.ap = NULL;
426 /* no need to tell driver */
427 break;
Johannes Berg4150c572007-09-17 01:29:23 -0400428 case IEEE80211_IF_TYPE_MNTR:
Michael Wu3d30d942008-01-31 19:48:27 +0100429 if (sdata->u.mntr_flags & MONITOR_FLAG_COOK_FRAMES) {
430 local->cooked_mntrs--;
431 break;
432 }
433
Johannes Berg4150c572007-09-17 01:29:23 -0400434 local->monitors--;
Michael Wu8cc9a732008-01-31 19:48:23 +0100435 if (local->monitors == 0)
Michael Wu8b393f12007-11-28 01:57:08 -0500436 local->hw.conf.flags &= ~IEEE80211_CONF_RADIOTAP;
Michael Wu8cc9a732008-01-31 19:48:23 +0100437
438 if (sdata->u.mntr_flags & MONITOR_FLAG_FCSFAIL)
439 local->fif_fcsfail--;
440 if (sdata->u.mntr_flags & MONITOR_FLAG_PLCPFAIL)
441 local->fif_plcpfail--;
442 if (sdata->u.mntr_flags & MONITOR_FLAG_CONTROL)
443 local->fif_control--;
444 if (sdata->u.mntr_flags & MONITOR_FLAG_OTHER_BSS)
445 local->fif_other_bss--;
446
447 netif_tx_lock_bh(local->mdev);
448 ieee80211_configure_filter(local);
449 netif_tx_unlock_bh(local->mdev);
Johannes Berg4150c572007-09-17 01:29:23 -0400450 break;
Luis Carlos Cobof7a92142008-02-23 15:17:18 +0100451 case IEEE80211_IF_TYPE_MESH_POINT:
452 sta_info_flush(local, dev);
453 /* fall through */
Johannes Bergb2c258f2007-07-27 15:43:23 +0200454 case IEEE80211_IF_TYPE_STA:
455 case IEEE80211_IF_TYPE_IBSS:
456 sdata->u.sta.state = IEEE80211_DISABLED;
457 del_timer_sync(&sdata->u.sta.timer);
Johannes Berg2a8a9a82007-08-28 17:01:52 -0400458 /*
Johannes Berg79010422007-09-18 17:29:21 -0400459 * When we get here, the interface is marked down.
460 * Call synchronize_rcu() to wait for the RX path
461 * should it be using the interface and enqueuing
462 * frames at this very time on another CPU.
Johannes Berg2a8a9a82007-08-28 17:01:52 -0400463 */
Johannes Berg79010422007-09-18 17:29:21 -0400464 synchronize_rcu();
Johannes Bergb2c258f2007-07-27 15:43:23 +0200465 skb_queue_purge(&sdata->u.sta.skb_queue);
Johannes Berg2a8a9a82007-08-28 17:01:52 -0400466
Zhu Yiece8edd2007-11-22 10:53:21 +0800467 if (local->scan_dev == sdata->dev) {
468 if (!local->ops->hw_scan) {
469 local->sta_sw_scanning = 0;
470 cancel_delayed_work(&local->scan_work);
471 } else
472 local->sta_hw_scanning = 0;
Johannes Bergb2c258f2007-07-27 15:43:23 +0200473 }
Zhu Yiece8edd2007-11-22 10:53:21 +0800474
Johannes Bergb2c258f2007-07-27 15:43:23 +0200475 flush_workqueue(local->hw.workqueue);
Zhu Yia10605e2007-11-22 11:10:22 +0800476
477 sdata->u.sta.flags &= ~IEEE80211_STA_PRIVACY_INVOKED;
478 kfree(sdata->u.sta.extra_ie);
479 sdata->u.sta.extra_ie = NULL;
480 sdata->u.sta.extra_ie_len = 0;
Johannes Berg4150c572007-09-17 01:29:23 -0400481 /* fall through */
482 default:
Johannes Berg32bfd352007-12-19 01:31:26 +0100483 conf.vif = &sdata->vif;
Johannes Berg51fb61e2007-12-19 01:31:27 +0100484 conf.type = sdata->vif.type;
Johannes Bergb2c258f2007-07-27 15:43:23 +0200485 conf.mac_addr = dev->dev_addr;
Johannes Berg4150c572007-09-17 01:29:23 -0400486 /* disable all keys for as long as this netdev is down */
487 ieee80211_disable_keys(sdata);
Johannes Bergb2c258f2007-07-27 15:43:23 +0200488 local->ops->remove_interface(local_to_hw(local), &conf);
489 }
490
Johannes Berg4150c572007-09-17 01:29:23 -0400491 if (local->open_count == 0) {
492 if (netif_running(local->mdev))
493 dev_close(local->mdev);
494
Johannes Berg4150c572007-09-17 01:29:23 -0400495 if (local->ops->stop)
496 local->ops->stop(local_to_hw(local));
497
Ivo van Doorncdcb0062008-01-07 19:45:24 +0100498 ieee80211_led_radio(local, 0);
499
Johannes Berg4150c572007-09-17 01:29:23 -0400500 tasklet_disable(&local->tx_pending_tasklet);
501 tasklet_disable(&local->tasklet);
502 }
Johannes Bergb2c258f2007-07-27 15:43:23 +0200503
504 return 0;
505}
506
Ron Rindjunskyeadc8d92008-01-28 14:07:17 +0200507int ieee80211_start_tx_ba_session(struct ieee80211_hw *hw, u8 *ra, u16 tid)
508{
509 struct ieee80211_local *local = hw_to_local(hw);
510 struct sta_info *sta;
511 struct ieee80211_sub_if_data *sdata;
512 u16 start_seq_num = 0;
513 u8 *state;
514 int ret;
515 DECLARE_MAC_BUF(mac);
516
517 if (tid >= STA_TID_NUM)
518 return -EINVAL;
519
520#ifdef CONFIG_MAC80211_HT_DEBUG
521 printk(KERN_DEBUG "Open BA session requested for %s tid %u\n",
522 print_mac(mac, ra), tid);
523#endif /* CONFIG_MAC80211_HT_DEBUG */
524
525 sta = sta_info_get(local, ra);
526 if (!sta) {
527 printk(KERN_DEBUG "Could not find the station\n");
528 return -ENOENT;
529 }
530
531 spin_lock_bh(&sta->ampdu_mlme.ampdu_tx);
532
533 /* we have tried too many times, receiver does not want A-MPDU */
534 if (sta->ampdu_mlme.tid_tx[tid].addba_req_num > HT_AGG_MAX_RETRIES) {
535 ret = -EBUSY;
536 goto start_ba_exit;
537 }
538
539 state = &sta->ampdu_mlme.tid_tx[tid].state;
540 /* check if the TID is not in aggregation flow already */
541 if (*state != HT_AGG_STATE_IDLE) {
542#ifdef CONFIG_MAC80211_HT_DEBUG
543 printk(KERN_DEBUG "BA request denied - session is not "
544 "idle on tid %u\n", tid);
545#endif /* CONFIG_MAC80211_HT_DEBUG */
546 ret = -EAGAIN;
547 goto start_ba_exit;
548 }
549
550 /* ensure that TX flow won't interrupt us
551 * until the end of the call to requeue function */
552 spin_lock_bh(&local->mdev->queue_lock);
553
554 /* create a new queue for this aggregation */
Ron Rindjunsky9e723492008-01-28 14:07:18 +0200555 ret = ieee80211_ht_agg_queue_add(local, sta, tid);
Ron Rindjunskyeadc8d92008-01-28 14:07:17 +0200556
557 /* case no queue is available to aggregation
558 * don't switch to aggregation */
559 if (ret) {
560#ifdef CONFIG_MAC80211_HT_DEBUG
561 printk(KERN_DEBUG "BA request denied - no queue available for"
562 " tid %d\n", tid);
563#endif /* CONFIG_MAC80211_HT_DEBUG */
564 spin_unlock_bh(&local->mdev->queue_lock);
565 goto start_ba_exit;
566 }
567 sdata = IEEE80211_DEV_TO_SUB_IF(sta->dev);
568
569 /* Ok, the Addba frame hasn't been sent yet, but if the driver calls the
570 * call back right away, it must see that the flow has begun */
571 *state |= HT_ADDBA_REQUESTED_MSK;
572
573 if (local->ops->ampdu_action)
574 ret = local->ops->ampdu_action(hw, IEEE80211_AMPDU_TX_START,
575 ra, tid, &start_seq_num);
576
577 if (ret) {
578 /* No need to requeue the packets in the agg queue, since we
579 * held the tx lock: no packet could be enqueued to the newly
580 * allocated queue */
Ron Rindjunsky9e723492008-01-28 14:07:18 +0200581 ieee80211_ht_agg_queue_remove(local, sta, tid, 0);
Ron Rindjunskyeadc8d92008-01-28 14:07:17 +0200582#ifdef CONFIG_MAC80211_HT_DEBUG
583 printk(KERN_DEBUG "BA request denied - HW or queue unavailable"
584 " for tid %d\n", tid);
585#endif /* CONFIG_MAC80211_HT_DEBUG */
586 spin_unlock_bh(&local->mdev->queue_lock);
587 *state = HT_AGG_STATE_IDLE;
588 goto start_ba_exit;
589 }
590
591 /* Will put all the packets in the new SW queue */
Ron Rindjunsky9e723492008-01-28 14:07:18 +0200592 ieee80211_requeue(local, ieee802_1d_to_ac[tid]);
Ron Rindjunskyeadc8d92008-01-28 14:07:17 +0200593 spin_unlock_bh(&local->mdev->queue_lock);
594
595 /* We have most probably almost emptied the legacy queue */
596 /* ieee80211_wake_queue(local_to_hw(local), ieee802_1d_to_ac[tid]); */
597
598 /* send an addBA request */
599 sta->ampdu_mlme.dialog_token_allocator++;
600 sta->ampdu_mlme.tid_tx[tid].dialog_token =
601 sta->ampdu_mlme.dialog_token_allocator;
602 sta->ampdu_mlme.tid_tx[tid].ssn = start_seq_num;
603
604 ieee80211_send_addba_request(sta->dev, ra, tid,
605 sta->ampdu_mlme.tid_tx[tid].dialog_token,
606 sta->ampdu_mlme.tid_tx[tid].ssn,
607 0x40, 5000);
608
609 /* activate the timer for the recipient's addBA response */
610 sta->ampdu_mlme.tid_tx[tid].addba_resp_timer.expires =
611 jiffies + ADDBA_RESP_INTERVAL;
612 add_timer(&sta->ampdu_mlme.tid_tx[tid].addba_resp_timer);
613 printk(KERN_DEBUG "activated addBA response timer on tid %d\n", tid);
614
615start_ba_exit:
616 spin_unlock_bh(&sta->ampdu_mlme.ampdu_tx);
617 sta_info_put(sta);
618 return ret;
619}
620EXPORT_SYMBOL(ieee80211_start_tx_ba_session);
621
622int ieee80211_stop_tx_ba_session(struct ieee80211_hw *hw,
623 u8 *ra, u16 tid,
624 enum ieee80211_back_parties initiator)
625{
626 struct ieee80211_local *local = hw_to_local(hw);
627 struct sta_info *sta;
628 u8 *state;
629 int ret = 0;
630 DECLARE_MAC_BUF(mac);
631
632 if (tid >= STA_TID_NUM)
633 return -EINVAL;
634
635#ifdef CONFIG_MAC80211_HT_DEBUG
636 printk(KERN_DEBUG "Stop a BA session requested for %s tid %u\n",
637 print_mac(mac, ra), tid);
638#endif /* CONFIG_MAC80211_HT_DEBUG */
639
640 sta = sta_info_get(local, ra);
641 if (!sta)
642 return -ENOENT;
643
644 /* check if the TID is in aggregation */
645 state = &sta->ampdu_mlme.tid_tx[tid].state;
646 spin_lock_bh(&sta->ampdu_mlme.ampdu_tx);
647
648 if (*state != HT_AGG_STATE_OPERATIONAL) {
649#ifdef CONFIG_MAC80211_HT_DEBUG
650 printk(KERN_DEBUG "Try to stop Tx aggregation on"
651 " non active TID\n");
652#endif /* CONFIG_MAC80211_HT_DEBUG */
653 ret = -ENOENT;
654 goto stop_BA_exit;
655 }
656
657 ieee80211_stop_queue(hw, sta->tid_to_tx_q[tid]);
658
659 *state = HT_AGG_STATE_REQ_STOP_BA_MSK |
660 (initiator << HT_AGG_STATE_INITIATOR_SHIFT);
661
662 if (local->ops->ampdu_action)
663 ret = local->ops->ampdu_action(hw, IEEE80211_AMPDU_TX_STOP,
664 ra, tid, NULL);
665
666 /* case HW denied going back to legacy */
667 if (ret) {
668 WARN_ON(ret != -EBUSY);
669 *state = HT_AGG_STATE_OPERATIONAL;
670 ieee80211_wake_queue(hw, sta->tid_to_tx_q[tid]);
671 goto stop_BA_exit;
672 }
673
674stop_BA_exit:
675 spin_unlock_bh(&sta->ampdu_mlme.ampdu_tx);
676 sta_info_put(sta);
677 return ret;
678}
679EXPORT_SYMBOL(ieee80211_stop_tx_ba_session);
680
681void ieee80211_start_tx_ba_cb(struct ieee80211_hw *hw, u8 *ra, u16 tid)
682{
683 struct ieee80211_local *local = hw_to_local(hw);
684 struct sta_info *sta;
685 u8 *state;
686 DECLARE_MAC_BUF(mac);
687
688 if (tid >= STA_TID_NUM) {
689 printk(KERN_DEBUG "Bad TID value: tid = %d (>= %d)\n",
690 tid, STA_TID_NUM);
691 return;
692 }
693
694 sta = sta_info_get(local, ra);
695 if (!sta) {
696 printk(KERN_DEBUG "Could not find station: %s\n",
697 print_mac(mac, ra));
698 return;
699 }
700
701 state = &sta->ampdu_mlme.tid_tx[tid].state;
702 spin_lock_bh(&sta->ampdu_mlme.ampdu_tx);
703
704 if (!(*state & HT_ADDBA_REQUESTED_MSK)) {
705 printk(KERN_DEBUG "addBA was not requested yet, state is %d\n",
706 *state);
707 spin_unlock_bh(&sta->ampdu_mlme.ampdu_tx);
708 sta_info_put(sta);
709 return;
710 }
711
712 WARN_ON_ONCE(*state & HT_ADDBA_DRV_READY_MSK);
713
714 *state |= HT_ADDBA_DRV_READY_MSK;
715
716 if (*state == HT_AGG_STATE_OPERATIONAL) {
717 printk(KERN_DEBUG "Aggregation is on for tid %d \n", tid);
718 ieee80211_wake_queue(hw, sta->tid_to_tx_q[tid]);
719 }
720 spin_unlock_bh(&sta->ampdu_mlme.ampdu_tx);
721 sta_info_put(sta);
722}
723EXPORT_SYMBOL(ieee80211_start_tx_ba_cb);
724
725void ieee80211_stop_tx_ba_cb(struct ieee80211_hw *hw, u8 *ra, u8 tid)
726{
727 struct ieee80211_local *local = hw_to_local(hw);
728 struct sta_info *sta;
729 u8 *state;
730 int agg_queue;
731 DECLARE_MAC_BUF(mac);
732
733 if (tid >= STA_TID_NUM) {
734 printk(KERN_DEBUG "Bad TID value: tid = %d (>= %d)\n",
735 tid, STA_TID_NUM);
736 return;
737 }
738
739 printk(KERN_DEBUG "Stop a BA session requested on DA %s tid %d\n",
740 print_mac(mac, ra), tid);
741
742 sta = sta_info_get(local, ra);
743 if (!sta) {
744 printk(KERN_DEBUG "Could not find station: %s\n",
745 print_mac(mac, ra));
746 return;
747 }
748 state = &sta->ampdu_mlme.tid_tx[tid].state;
749
750 spin_lock_bh(&sta->ampdu_mlme.ampdu_tx);
751 if ((*state & HT_AGG_STATE_REQ_STOP_BA_MSK) == 0) {
752 printk(KERN_DEBUG "unexpected callback to A-MPDU stop\n");
753 sta_info_put(sta);
754 spin_unlock_bh(&sta->ampdu_mlme.ampdu_tx);
755 return;
756 }
757
758 if (*state & HT_AGG_STATE_INITIATOR_MSK)
759 ieee80211_send_delba(sta->dev, ra, tid,
760 WLAN_BACK_INITIATOR, WLAN_REASON_QSTA_NOT_USE);
761
762 agg_queue = sta->tid_to_tx_q[tid];
763
764 /* avoid ordering issues: we are the only one that can modify
765 * the content of the qdiscs */
766 spin_lock_bh(&local->mdev->queue_lock);
767 /* remove the queue for this aggregation */
Ron Rindjunsky9e723492008-01-28 14:07:18 +0200768 ieee80211_ht_agg_queue_remove(local, sta, tid, 1);
Ron Rindjunskyeadc8d92008-01-28 14:07:17 +0200769 spin_unlock_bh(&local->mdev->queue_lock);
770
771 /* we just requeued the all the frames that were in the removed
772 * queue, and since we might miss a softirq we do netif_schedule.
773 * ieee80211_wake_queue is not used here as this queue is not
774 * necessarily stopped */
775 netif_schedule(local->mdev);
776 *state = HT_AGG_STATE_IDLE;
777 sta->ampdu_mlme.tid_tx[tid].addba_req_num = 0;
778 spin_unlock_bh(&sta->ampdu_mlme.ampdu_tx);
779
780 sta_info_put(sta);
781}
782EXPORT_SYMBOL(ieee80211_stop_tx_ba_cb);
783
784void ieee80211_start_tx_ba_cb_irqsafe(struct ieee80211_hw *hw,
785 const u8 *ra, u16 tid)
786{
787 struct ieee80211_local *local = hw_to_local(hw);
788 struct ieee80211_ra_tid *ra_tid;
789 struct sk_buff *skb = dev_alloc_skb(0);
790
791 if (unlikely(!skb)) {
792 if (net_ratelimit())
793 printk(KERN_WARNING "%s: Not enough memory, "
794 "dropping start BA session", skb->dev->name);
795 return;
796 }
797 ra_tid = (struct ieee80211_ra_tid *) &skb->cb;
798 memcpy(&ra_tid->ra, ra, ETH_ALEN);
799 ra_tid->tid = tid;
800
801 skb->pkt_type = IEEE80211_ADDBA_MSG;
802 skb_queue_tail(&local->skb_queue, skb);
803 tasklet_schedule(&local->tasklet);
804}
805EXPORT_SYMBOL(ieee80211_start_tx_ba_cb_irqsafe);
806
807void ieee80211_stop_tx_ba_cb_irqsafe(struct ieee80211_hw *hw,
808 const u8 *ra, u16 tid)
809{
810 struct ieee80211_local *local = hw_to_local(hw);
811 struct ieee80211_ra_tid *ra_tid;
812 struct sk_buff *skb = dev_alloc_skb(0);
813
814 if (unlikely(!skb)) {
815 if (net_ratelimit())
816 printk(KERN_WARNING "%s: Not enough memory, "
817 "dropping stop BA session", skb->dev->name);
818 return;
819 }
820 ra_tid = (struct ieee80211_ra_tid *) &skb->cb;
821 memcpy(&ra_tid->ra, ra, ETH_ALEN);
822 ra_tid->tid = tid;
823
824 skb->pkt_type = IEEE80211_DELBA_MSG;
825 skb_queue_tail(&local->skb_queue, skb);
826 tasklet_schedule(&local->tasklet);
827}
828EXPORT_SYMBOL(ieee80211_stop_tx_ba_cb_irqsafe);
829
Johannes Bergb2c258f2007-07-27 15:43:23 +0200830static void ieee80211_set_multicast_list(struct net_device *dev)
831{
832 struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr);
833 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
Johannes Berg4150c572007-09-17 01:29:23 -0400834 int allmulti, promisc, sdata_allmulti, sdata_promisc;
Johannes Bergb2c258f2007-07-27 15:43:23 +0200835
Johannes Berg4150c572007-09-17 01:29:23 -0400836 allmulti = !!(dev->flags & IFF_ALLMULTI);
837 promisc = !!(dev->flags & IFF_PROMISC);
Johannes Bergb52f2192007-11-16 01:49:11 +0100838 sdata_allmulti = !!(sdata->flags & IEEE80211_SDATA_ALLMULTI);
839 sdata_promisc = !!(sdata->flags & IEEE80211_SDATA_PROMISC);
Johannes Berg4150c572007-09-17 01:29:23 -0400840
841 if (allmulti != sdata_allmulti) {
842 if (dev->flags & IFF_ALLMULTI)
Johannes Berg53918992007-09-26 15:19:47 +0200843 atomic_inc(&local->iff_allmultis);
Johannes Berg4150c572007-09-17 01:29:23 -0400844 else
Johannes Berg53918992007-09-26 15:19:47 +0200845 atomic_dec(&local->iff_allmultis);
Jiri Slaby13262ff2007-08-28 17:01:54 -0400846 sdata->flags ^= IEEE80211_SDATA_ALLMULTI;
Johannes Bergb2c258f2007-07-27 15:43:23 +0200847 }
Johannes Berg4150c572007-09-17 01:29:23 -0400848
849 if (promisc != sdata_promisc) {
850 if (dev->flags & IFF_PROMISC)
Johannes Berg53918992007-09-26 15:19:47 +0200851 atomic_inc(&local->iff_promiscs);
Johannes Berg4150c572007-09-17 01:29:23 -0400852 else
Johannes Berg53918992007-09-26 15:19:47 +0200853 atomic_dec(&local->iff_promiscs);
Jiri Slaby13262ff2007-08-28 17:01:54 -0400854 sdata->flags ^= IEEE80211_SDATA_PROMISC;
Johannes Bergb2c258f2007-07-27 15:43:23 +0200855 }
Johannes Berg4150c572007-09-17 01:29:23 -0400856
857 dev_mc_sync(local->mdev, dev);
Johannes Bergb2c258f2007-07-27 15:43:23 +0200858}
859
Stephen Hemminger3b04ddd2007-10-09 01:40:57 -0700860static const struct header_ops ieee80211_header_ops = {
861 .create = eth_header,
862 .parse = header_parse_80211,
863 .rebuild = eth_rebuild_header,
864 .cache = eth_header_cache,
865 .cache_update = eth_header_cache_update,
866};
867
Johannes Bergf9d540e2007-09-28 14:02:09 +0200868/* Must not be called for mdev */
Johannes Bergb2c258f2007-07-27 15:43:23 +0200869void ieee80211_if_setup(struct net_device *dev)
870{
871 ether_setup(dev);
872 dev->hard_start_xmit = ieee80211_subif_start_xmit;
873 dev->wireless_handlers = &ieee80211_iw_handler_def;
874 dev->set_multicast_list = ieee80211_set_multicast_list;
875 dev->change_mtu = ieee80211_change_mtu;
Johannes Bergb2c258f2007-07-27 15:43:23 +0200876 dev->open = ieee80211_open;
877 dev->stop = ieee80211_stop;
Johannes Bergb2c258f2007-07-27 15:43:23 +0200878 dev->destructor = ieee80211_if_free;
879}
880
881/* WDS specialties */
882
883int ieee80211_if_update_wds(struct net_device *dev, u8 *remote_addr)
884{
885 struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr);
886 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
887 struct sta_info *sta;
Joe Perches0795af52007-10-03 17:59:30 -0700888 DECLARE_MAC_BUF(mac);
Johannes Bergb2c258f2007-07-27 15:43:23 +0200889
890 if (compare_ether_addr(remote_addr, sdata->u.wds.remote_addr) == 0)
891 return 0;
892
893 /* Create STA entry for the new peer */
894 sta = sta_info_add(local, dev, remote_addr, GFP_KERNEL);
Johannes Berg43ba7e92008-02-21 14:09:30 +0100895 if (IS_ERR(sta))
896 return PTR_ERR(sta);
Johannes Berg238814f2008-01-28 17:19:37 +0100897
898 sta->flags |= WLAN_STA_AUTHORIZED;
899
Johannes Bergb2c258f2007-07-27 15:43:23 +0200900 sta_info_put(sta);
901
902 /* Remove STA entry for the old peer */
903 sta = sta_info_get(local, sdata->u.wds.remote_addr);
904 if (sta) {
Michael Wube8755e2007-07-27 15:43:23 +0200905 sta_info_free(sta);
Johannes Bergb2c258f2007-07-27 15:43:23 +0200906 sta_info_put(sta);
Johannes Bergb2c258f2007-07-27 15:43:23 +0200907 } else {
908 printk(KERN_DEBUG "%s: could not find STA entry for WDS link "
Joe Perches0795af52007-10-03 17:59:30 -0700909 "peer %s\n",
910 dev->name, print_mac(mac, sdata->u.wds.remote_addr));
Johannes Bergb2c258f2007-07-27 15:43:23 +0200911 }
912
913 /* Update WDS link data */
914 memcpy(&sdata->u.wds.remote_addr, remote_addr, ETH_ALEN);
915
916 return 0;
917}
918
919/* everything else */
920
Johannes Bergb2c258f2007-07-27 15:43:23 +0200921static int __ieee80211_if_config(struct net_device *dev,
922 struct sk_buff *beacon,
923 struct ieee80211_tx_control *control)
924{
925 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
926 struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr);
927 struct ieee80211_if_conf conf;
Johannes Bergb2c258f2007-07-27 15:43:23 +0200928
929 if (!local->ops->config_interface || !netif_running(dev))
930 return 0;
931
932 memset(&conf, 0, sizeof(conf));
Johannes Berg51fb61e2007-12-19 01:31:27 +0100933 conf.type = sdata->vif.type;
934 if (sdata->vif.type == IEEE80211_IF_TYPE_STA ||
935 sdata->vif.type == IEEE80211_IF_TYPE_IBSS) {
Johannes Berg4150c572007-09-17 01:29:23 -0400936 conf.bssid = sdata->u.sta.bssid;
Johannes Bergb2c258f2007-07-27 15:43:23 +0200937 conf.ssid = sdata->u.sta.ssid;
938 conf.ssid_len = sdata->u.sta.ssid_len;
Johannes Berg902acc72008-02-23 15:17:19 +0100939 } else if (ieee80211_vif_is_mesh(&sdata->vif)) {
Luis Carlos Cobof7a92142008-02-23 15:17:18 +0100940 conf.beacon = beacon;
941 ieee80211_start_mesh(dev);
Johannes Berg51fb61e2007-12-19 01:31:27 +0100942 } else if (sdata->vif.type == IEEE80211_IF_TYPE_AP) {
Johannes Bergb2c258f2007-07-27 15:43:23 +0200943 conf.ssid = sdata->u.ap.ssid;
944 conf.ssid_len = sdata->u.ap.ssid_len;
Johannes Bergb2c258f2007-07-27 15:43:23 +0200945 conf.beacon = beacon;
946 conf.beacon_control = control;
947 }
948 return local->ops->config_interface(local_to_hw(local),
Johannes Berg32bfd352007-12-19 01:31:26 +0100949 &sdata->vif, &conf);
Johannes Bergb2c258f2007-07-27 15:43:23 +0200950}
951
952int ieee80211_if_config(struct net_device *dev)
953{
Luis Carlos Cobof7a92142008-02-23 15:17:18 +0100954 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
955 struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr);
956 if (sdata->vif.type == IEEE80211_IF_TYPE_MESH_POINT &&
957 (local->hw.flags & IEEE80211_HW_HOST_GEN_BEACON_TEMPLATE))
958 return ieee80211_if_config_beacon(dev);
Johannes Bergb2c258f2007-07-27 15:43:23 +0200959 return __ieee80211_if_config(dev, NULL, NULL);
960}
961
962int ieee80211_if_config_beacon(struct net_device *dev)
963{
964 struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr);
965 struct ieee80211_tx_control control;
Johannes Berg32bfd352007-12-19 01:31:26 +0100966 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
Johannes Bergb2c258f2007-07-27 15:43:23 +0200967 struct sk_buff *skb;
968
969 if (!(local->hw.flags & IEEE80211_HW_HOST_GEN_BEACON_TEMPLATE))
970 return 0;
Johannes Berg32bfd352007-12-19 01:31:26 +0100971 skb = ieee80211_beacon_get(local_to_hw(local), &sdata->vif,
972 &control);
Johannes Bergb2c258f2007-07-27 15:43:23 +0200973 if (!skb)
974 return -ENOMEM;
975 return __ieee80211_if_config(dev, skb, &control);
976}
977
978int ieee80211_hw_config(struct ieee80211_local *local)
979{
Johannes Bergb2c258f2007-07-27 15:43:23 +0200980 struct ieee80211_channel *chan;
981 int ret = 0;
982
Johannes Berg8318d782008-01-24 19:38:38 +0100983 if (local->sta_sw_scanning)
Johannes Bergb2c258f2007-07-27 15:43:23 +0200984 chan = local->scan_channel;
Johannes Berg8318d782008-01-24 19:38:38 +0100985 else
Johannes Bergb2c258f2007-07-27 15:43:23 +0200986 chan = local->oper_channel;
Johannes Bergb2c258f2007-07-27 15:43:23 +0200987
Johannes Berg8318d782008-01-24 19:38:38 +0100988 local->hw.conf.channel = chan;
989
990 if (!local->hw.conf.power_level)
991 local->hw.conf.power_level = chan->max_power;
992 else
993 local->hw.conf.power_level = min(chan->max_power,
994 local->hw.conf.power_level);
995
996 local->hw.conf.max_antenna_gain = chan->max_antenna_gain;
Johannes Bergb2c258f2007-07-27 15:43:23 +0200997
998#ifdef CONFIG_MAC80211_VERBOSE_DEBUG
Johannes Berg8318d782008-01-24 19:38:38 +0100999 printk(KERN_DEBUG "%s: HW CONFIG: freq=%d\n",
1000 wiphy_name(local->hw.wiphy), chan->center_freq);
1001#endif
Johannes Bergb2c258f2007-07-27 15:43:23 +02001002
Michael Bueschf7c4dae2007-09-24 18:41:49 +02001003 if (local->open_count)
Johannes Bergb2c258f2007-07-27 15:43:23 +02001004 ret = local->ops->config(local_to_hw(local), &local->hw.conf);
1005
1006 return ret;
1007}
1008
Ron Rindjunskyd3c990f2007-11-26 16:14:34 +02001009/**
1010 * ieee80211_hw_config_ht should be used only after legacy configuration
1011 * has been determined, as ht configuration depends upon the hardware's
1012 * HT abilities for a _specific_ band.
1013 */
1014int ieee80211_hw_config_ht(struct ieee80211_local *local, int enable_ht,
1015 struct ieee80211_ht_info *req_ht_cap,
1016 struct ieee80211_ht_bss_info *req_bss_cap)
1017{
1018 struct ieee80211_conf *conf = &local->hw.conf;
Johannes Berg8318d782008-01-24 19:38:38 +01001019 struct ieee80211_supported_band *sband;
Ron Rindjunskyd3c990f2007-11-26 16:14:34 +02001020 int i;
1021
Johannes Berg8318d782008-01-24 19:38:38 +01001022 sband = local->hw.wiphy->bands[conf->channel->band];
1023
Ron Rindjunskyd3c990f2007-11-26 16:14:34 +02001024 /* HT is not supported */
Johannes Berg8318d782008-01-24 19:38:38 +01001025 if (!sband->ht_info.ht_supported) {
Ron Rindjunskyd3c990f2007-11-26 16:14:34 +02001026 conf->flags &= ~IEEE80211_CONF_SUPPORT_HT_MODE;
1027 return -EOPNOTSUPP;
1028 }
1029
1030 /* disable HT */
1031 if (!enable_ht) {
1032 conf->flags &= ~IEEE80211_CONF_SUPPORT_HT_MODE;
1033 } else {
1034 conf->flags |= IEEE80211_CONF_SUPPORT_HT_MODE;
Johannes Berg8318d782008-01-24 19:38:38 +01001035 conf->ht_conf.cap = req_ht_cap->cap & sband->ht_info.cap;
Ron Rindjunskyd3c990f2007-11-26 16:14:34 +02001036 conf->ht_conf.cap &= ~(IEEE80211_HT_CAP_MIMO_PS);
1037 conf->ht_conf.cap |=
Johannes Berg8318d782008-01-24 19:38:38 +01001038 sband->ht_info.cap & IEEE80211_HT_CAP_MIMO_PS;
Ron Rindjunskyd3c990f2007-11-26 16:14:34 +02001039 conf->ht_bss_conf.primary_channel =
1040 req_bss_cap->primary_channel;
1041 conf->ht_bss_conf.bss_cap = req_bss_cap->bss_cap;
1042 conf->ht_bss_conf.bss_op_mode = req_bss_cap->bss_op_mode;
1043 for (i = 0; i < SUPP_MCS_SET_LEN; i++)
1044 conf->ht_conf.supp_mcs_set[i] =
Johannes Berg8318d782008-01-24 19:38:38 +01001045 sband->ht_info.supp_mcs_set[i] &
Ron Rindjunskyd3c990f2007-11-26 16:14:34 +02001046 req_ht_cap->supp_mcs_set[i];
1047
1048 /* In STA mode, this gives us indication
1049 * to the AP's mode of operation */
1050 conf->ht_conf.ht_supported = 1;
1051 conf->ht_conf.ampdu_factor = req_ht_cap->ampdu_factor;
1052 conf->ht_conf.ampdu_density = req_ht_cap->ampdu_density;
1053 }
1054
1055 local->ops->conf_ht(local_to_hw(local), &local->hw.conf);
1056
1057 return 0;
1058}
1059
Johannes Berg471b3ef2007-12-28 14:32:58 +01001060void ieee80211_bss_info_change_notify(struct ieee80211_sub_if_data *sdata,
1061 u32 changed)
Daniel Draked9430a32007-07-27 15:43:24 +02001062{
Johannes Berg471b3ef2007-12-28 14:32:58 +01001063 struct ieee80211_local *local = sdata->local;
1064
1065 if (!changed)
1066 return;
1067
1068 if (local->ops->bss_info_changed)
1069 local->ops->bss_info_changed(local_to_hw(local),
1070 &sdata->vif,
1071 &sdata->bss_conf,
1072 changed);
Daniel Draked9430a32007-07-27 15:43:24 +02001073}
1074
1075void ieee80211_reset_erp_info(struct net_device *dev)
1076{
1077 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
1078
Johannes Berg471b3ef2007-12-28 14:32:58 +01001079 sdata->bss_conf.use_cts_prot = 0;
1080 sdata->bss_conf.use_short_preamble = 0;
1081 ieee80211_bss_info_change_notify(sdata,
1082 BSS_CHANGED_ERP_CTS_PROT |
1083 BSS_CHANGED_ERP_PREAMBLE);
Daniel Draked9430a32007-07-27 15:43:24 +02001084}
1085
Jiri Bencf0706e82007-05-05 11:45:53 -07001086void ieee80211_tx_status_irqsafe(struct ieee80211_hw *hw,
1087 struct sk_buff *skb,
1088 struct ieee80211_tx_status *status)
1089{
1090 struct ieee80211_local *local = hw_to_local(hw);
1091 struct ieee80211_tx_status *saved;
1092 int tmp;
1093
1094 skb->dev = local->mdev;
1095 saved = kmalloc(sizeof(struct ieee80211_tx_status), GFP_ATOMIC);
1096 if (unlikely(!saved)) {
1097 if (net_ratelimit())
1098 printk(KERN_WARNING "%s: Not enough memory, "
1099 "dropping tx status", skb->dev->name);
1100 /* should be dev_kfree_skb_irq, but due to this function being
1101 * named _irqsafe instead of just _irq we can't be sure that
1102 * people won't call it from non-irq contexts */
1103 dev_kfree_skb_any(skb);
1104 return;
1105 }
1106 memcpy(saved, status, sizeof(struct ieee80211_tx_status));
1107 /* copy pointer to saved status into skb->cb for use by tasklet */
1108 memcpy(skb->cb, &saved, sizeof(saved));
1109
1110 skb->pkt_type = IEEE80211_TX_STATUS_MSG;
1111 skb_queue_tail(status->control.flags & IEEE80211_TXCTL_REQ_TX_STATUS ?
1112 &local->skb_queue : &local->skb_queue_unreliable, skb);
1113 tmp = skb_queue_len(&local->skb_queue) +
1114 skb_queue_len(&local->skb_queue_unreliable);
1115 while (tmp > IEEE80211_IRQSAFE_QUEUE_LIMIT &&
1116 (skb = skb_dequeue(&local->skb_queue_unreliable))) {
1117 memcpy(&saved, skb->cb, sizeof(saved));
1118 kfree(saved);
1119 dev_kfree_skb_irq(skb);
1120 tmp--;
1121 I802_DEBUG_INC(local->tx_status_drop);
1122 }
1123 tasklet_schedule(&local->tasklet);
1124}
1125EXPORT_SYMBOL(ieee80211_tx_status_irqsafe);
1126
1127static void ieee80211_tasklet_handler(unsigned long data)
1128{
1129 struct ieee80211_local *local = (struct ieee80211_local *) data;
1130 struct sk_buff *skb;
1131 struct ieee80211_rx_status rx_status;
1132 struct ieee80211_tx_status *tx_status;
Ron Rindjunskyeadc8d92008-01-28 14:07:17 +02001133 struct ieee80211_ra_tid *ra_tid;
Jiri Bencf0706e82007-05-05 11:45:53 -07001134
1135 while ((skb = skb_dequeue(&local->skb_queue)) ||
1136 (skb = skb_dequeue(&local->skb_queue_unreliable))) {
1137 switch (skb->pkt_type) {
1138 case IEEE80211_RX_MSG:
1139 /* status is in skb->cb */
1140 memcpy(&rx_status, skb->cb, sizeof(rx_status));
Johannes Berg51fb61e2007-12-19 01:31:27 +01001141 /* Clear skb->pkt_type in order to not confuse kernel
Jiri Bencf0706e82007-05-05 11:45:53 -07001142 * netstack. */
1143 skb->pkt_type = 0;
1144 __ieee80211_rx(local_to_hw(local), skb, &rx_status);
1145 break;
1146 case IEEE80211_TX_STATUS_MSG:
1147 /* get pointer to saved status out of skb->cb */
1148 memcpy(&tx_status, skb->cb, sizeof(tx_status));
1149 skb->pkt_type = 0;
1150 ieee80211_tx_status(local_to_hw(local),
1151 skb, tx_status);
1152 kfree(tx_status);
1153 break;
Ron Rindjunskyeadc8d92008-01-28 14:07:17 +02001154 case IEEE80211_DELBA_MSG:
1155 ra_tid = (struct ieee80211_ra_tid *) &skb->cb;
1156 ieee80211_stop_tx_ba_cb(local_to_hw(local),
1157 ra_tid->ra, ra_tid->tid);
1158 dev_kfree_skb(skb);
1159 break;
1160 case IEEE80211_ADDBA_MSG:
1161 ra_tid = (struct ieee80211_ra_tid *) &skb->cb;
1162 ieee80211_start_tx_ba_cb(local_to_hw(local),
1163 ra_tid->ra, ra_tid->tid);
1164 dev_kfree_skb(skb);
1165 break ;
Jiri Bencf0706e82007-05-05 11:45:53 -07001166 default: /* should never get here! */
1167 printk(KERN_ERR "%s: Unknown message type (%d)\n",
Johannes Bergdd1cd4c2007-09-18 17:29:20 -04001168 wiphy_name(local->hw.wiphy), skb->pkt_type);
Jiri Bencf0706e82007-05-05 11:45:53 -07001169 dev_kfree_skb(skb);
1170 break;
1171 }
1172 }
1173}
1174
Jiri Bencf0706e82007-05-05 11:45:53 -07001175/* Remove added headers (e.g., QoS control), encryption header/MIC, etc. to
1176 * make a prepared TX frame (one that has been given to hw) to look like brand
1177 * new IEEE 802.11 frame that is ready to go through TX processing again.
1178 * Also, tx_packet_data in cb is restored from tx_control. */
1179static void ieee80211_remove_tx_extra(struct ieee80211_local *local,
1180 struct ieee80211_key *key,
1181 struct sk_buff *skb,
1182 struct ieee80211_tx_control *control)
1183{
1184 int hdrlen, iv_len, mic_len;
1185 struct ieee80211_tx_packet_data *pkt_data;
1186
1187 pkt_data = (struct ieee80211_tx_packet_data *)skb->cb;
Johannes Berg32bfd352007-12-19 01:31:26 +01001188 pkt_data->ifindex = vif_to_sdata(control->vif)->dev->ifindex;
Jiri Slabye8bf9642007-08-28 17:01:54 -04001189 pkt_data->flags = 0;
1190 if (control->flags & IEEE80211_TXCTL_REQ_TX_STATUS)
1191 pkt_data->flags |= IEEE80211_TXPD_REQ_TX_STATUS;
1192 if (control->flags & IEEE80211_TXCTL_DO_NOT_ENCRYPT)
1193 pkt_data->flags |= IEEE80211_TXPD_DO_NOT_ENCRYPT;
1194 if (control->flags & IEEE80211_TXCTL_REQUEUE)
1195 pkt_data->flags |= IEEE80211_TXPD_REQUEUE;
Johannes Berg678f5f712007-12-19 01:31:23 +01001196 if (control->flags & IEEE80211_TXCTL_EAPOL_FRAME)
1197 pkt_data->flags |= IEEE80211_TXPD_EAPOL_FRAME;
Jiri Bencf0706e82007-05-05 11:45:53 -07001198 pkt_data->queue = control->queue;
1199
1200 hdrlen = ieee80211_get_hdrlen_from_skb(skb);
1201
1202 if (!key)
1203 goto no_key;
1204
Johannes Berg8f20fc22007-08-28 17:01:54 -04001205 switch (key->conf.alg) {
Jiri Bencf0706e82007-05-05 11:45:53 -07001206 case ALG_WEP:
1207 iv_len = WEP_IV_LEN;
1208 mic_len = WEP_ICV_LEN;
1209 break;
1210 case ALG_TKIP:
1211 iv_len = TKIP_IV_LEN;
1212 mic_len = TKIP_ICV_LEN;
1213 break;
1214 case ALG_CCMP:
1215 iv_len = CCMP_HDR_LEN;
1216 mic_len = CCMP_MIC_LEN;
1217 break;
1218 default:
1219 goto no_key;
1220 }
1221
Johannes Berg8f20fc22007-08-28 17:01:54 -04001222 if (skb->len >= mic_len &&
Johannes Berg11a843b2007-08-28 17:01:55 -04001223 !(key->flags & KEY_FLAG_UPLOADED_TO_HARDWARE))
Jiri Bencf0706e82007-05-05 11:45:53 -07001224 skb_trim(skb, skb->len - mic_len);
1225 if (skb->len >= iv_len && skb->len > hdrlen) {
1226 memmove(skb->data + iv_len, skb->data, hdrlen);
1227 skb_pull(skb, iv_len);
1228 }
1229
1230no_key:
1231 {
1232 struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) skb->data;
1233 u16 fc = le16_to_cpu(hdr->frame_control);
1234 if ((fc & 0x8C) == 0x88) /* QoS Control Field */ {
1235 fc &= ~IEEE80211_STYPE_QOS_DATA;
1236 hdr->frame_control = cpu_to_le16(fc);
1237 memmove(skb->data + 2, skb->data, hdrlen - 2);
1238 skb_pull(skb, 2);
1239 }
1240 }
1241}
1242
Johannes Bergd46e1442008-02-20 23:59:33 +01001243static void ieee80211_handle_filtered_frame(struct ieee80211_local *local,
1244 struct sta_info *sta,
1245 struct sk_buff *skb,
1246 struct ieee80211_tx_status *status)
1247{
1248 sta->tx_filtered_count++;
1249
1250 /*
1251 * Clear the TX filter mask for this STA when sending the next
1252 * packet. If the STA went to power save mode, this will happen
1253 * happen when it wakes up for the next time.
1254 */
1255 sta->flags |= WLAN_STA_CLEAR_PS_FILT;
1256
1257 /*
1258 * This code races in the following way:
1259 *
1260 * (1) STA sends frame indicating it will go to sleep and does so
1261 * (2) hardware/firmware adds STA to filter list, passes frame up
1262 * (3) hardware/firmware processes TX fifo and suppresses a frame
1263 * (4) we get TX status before having processed the frame and
1264 * knowing that the STA has gone to sleep.
1265 *
1266 * This is actually quite unlikely even when both those events are
1267 * processed from interrupts coming in quickly after one another or
1268 * even at the same time because we queue both TX status events and
1269 * RX frames to be processed by a tasklet and process them in the
1270 * same order that they were received or TX status last. Hence, there
1271 * is no race as long as the frame RX is processed before the next TX
1272 * status, which drivers can ensure, see below.
1273 *
1274 * Note that this can only happen if the hardware or firmware can
1275 * actually add STAs to the filter list, if this is done by the
1276 * driver in response to set_tim() (which will only reduce the race
1277 * this whole filtering tries to solve, not completely solve it)
1278 * this situation cannot happen.
1279 *
1280 * To completely solve this race drivers need to make sure that they
1281 * (a) don't mix the irq-safe/not irq-safe TX status/RX processing
1282 * functions and
1283 * (b) always process RX events before TX status events if ordering
1284 * can be unknown, for example with different interrupt status
1285 * bits.
1286 */
1287 if (sta->flags & WLAN_STA_PS &&
1288 skb_queue_len(&sta->tx_filtered) < STA_MAX_TX_BUFFER) {
1289 ieee80211_remove_tx_extra(local, sta->key, skb,
1290 &status->control);
1291 skb_queue_tail(&sta->tx_filtered, skb);
1292 return;
1293 }
1294
1295 if (!(sta->flags & WLAN_STA_PS) &&
1296 !(status->control.flags & IEEE80211_TXCTL_REQUEUE)) {
1297 /* Software retry the packet once */
1298 status->control.flags |= IEEE80211_TXCTL_REQUEUE;
1299 ieee80211_remove_tx_extra(local, sta->key, skb,
1300 &status->control);
1301 dev_queue_xmit(skb);
1302 return;
1303 }
1304
1305 if (net_ratelimit())
1306 printk(KERN_DEBUG "%s: dropped TX filtered frame, "
1307 "queue_len=%d PS=%d @%lu\n",
1308 wiphy_name(local->hw.wiphy),
1309 skb_queue_len(&sta->tx_filtered),
1310 !!(sta->flags & WLAN_STA_PS), jiffies);
1311 dev_kfree_skb(skb);
1312}
1313
Jiri Bencf0706e82007-05-05 11:45:53 -07001314void ieee80211_tx_status(struct ieee80211_hw *hw, struct sk_buff *skb,
1315 struct ieee80211_tx_status *status)
1316{
1317 struct sk_buff *skb2;
1318 struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) skb->data;
1319 struct ieee80211_local *local = hw_to_local(hw);
1320 u16 frag, type;
Johannes Bergb306f452007-07-10 19:32:08 +02001321 struct ieee80211_tx_status_rtap_hdr *rthdr;
1322 struct ieee80211_sub_if_data *sdata;
Michael Wu3d30d942008-01-31 19:48:27 +01001323 struct net_device *prev_dev = NULL;
Jiri Bencf0706e82007-05-05 11:45:53 -07001324
1325 if (!status) {
1326 printk(KERN_ERR
1327 "%s: ieee80211_tx_status called with NULL status\n",
Johannes Bergdd1cd4c2007-09-18 17:29:20 -04001328 wiphy_name(local->hw.wiphy));
Jiri Bencf0706e82007-05-05 11:45:53 -07001329 dev_kfree_skb(skb);
1330 return;
1331 }
1332
1333 if (status->excessive_retries) {
1334 struct sta_info *sta;
1335 sta = sta_info_get(local, hdr->addr1);
1336 if (sta) {
1337 if (sta->flags & WLAN_STA_PS) {
Johannes Bergd46e1442008-02-20 23:59:33 +01001338 /*
1339 * The STA is in power save mode, so assume
Jiri Bencf0706e82007-05-05 11:45:53 -07001340 * that this TX packet failed because of that.
1341 */
1342 status->excessive_retries = 0;
1343 status->flags |= IEEE80211_TX_STATUS_TX_FILTERED;
Johannes Bergd46e1442008-02-20 23:59:33 +01001344 ieee80211_handle_filtered_frame(local, sta,
1345 skb, status);
1346 sta_info_put(sta);
1347 return;
Jiri Bencf0706e82007-05-05 11:45:53 -07001348 }
1349 sta_info_put(sta);
1350 }
1351 }
1352
1353 if (status->flags & IEEE80211_TX_STATUS_TX_FILTERED) {
1354 struct sta_info *sta;
1355 sta = sta_info_get(local, hdr->addr1);
1356 if (sta) {
Johannes Bergd46e1442008-02-20 23:59:33 +01001357 ieee80211_handle_filtered_frame(local, sta, skb,
1358 status);
Jiri Bencf0706e82007-05-05 11:45:53 -07001359 sta_info_put(sta);
1360 return;
1361 }
Mattias Nissler1abbe492007-12-20 13:50:07 +01001362 } else
1363 rate_control_tx_status(local->mdev, skb, status);
Jiri Bencf0706e82007-05-05 11:45:53 -07001364
1365 ieee80211_led_tx(local, 0);
1366
1367 /* SNMP counters
1368 * Fragments are passed to low-level drivers as separate skbs, so these
1369 * are actually fragments, not frames. Update frame counters only for
1370 * the first fragment of the frame. */
1371
1372 frag = le16_to_cpu(hdr->seq_ctrl) & IEEE80211_SCTL_FRAG;
1373 type = le16_to_cpu(hdr->frame_control) & IEEE80211_FCTL_FTYPE;
1374
1375 if (status->flags & IEEE80211_TX_STATUS_ACK) {
1376 if (frag == 0) {
1377 local->dot11TransmittedFrameCount++;
1378 if (is_multicast_ether_addr(hdr->addr1))
1379 local->dot11MulticastTransmittedFrameCount++;
1380 if (status->retry_count > 0)
1381 local->dot11RetryCount++;
1382 if (status->retry_count > 1)
1383 local->dot11MultipleRetryCount++;
1384 }
1385
1386 /* This counter shall be incremented for an acknowledged MPDU
1387 * with an individual address in the address 1 field or an MPDU
1388 * with a multicast address in the address 1 field of type Data
1389 * or Management. */
1390 if (!is_multicast_ether_addr(hdr->addr1) ||
1391 type == IEEE80211_FTYPE_DATA ||
1392 type == IEEE80211_FTYPE_MGMT)
1393 local->dot11TransmittedFragmentCount++;
1394 } else {
1395 if (frag == 0)
1396 local->dot11FailedCount++;
1397 }
1398
Johannes Bergb306f452007-07-10 19:32:08 +02001399 /* this was a transmitted frame, but now we want to reuse it */
1400 skb_orphan(skb);
1401
Michael Wu3d30d942008-01-31 19:48:27 +01001402 /*
1403 * This is a bit racy but we can avoid a lot of work
1404 * with this test...
1405 */
1406 if (!local->monitors && !local->cooked_mntrs) {
Jiri Bencf0706e82007-05-05 11:45:53 -07001407 dev_kfree_skb(skb);
1408 return;
1409 }
Jiri Bencf0706e82007-05-05 11:45:53 -07001410
Johannes Bergb306f452007-07-10 19:32:08 +02001411 /* send frame to monitor interfaces now */
1412
1413 if (skb_headroom(skb) < sizeof(*rthdr)) {
1414 printk(KERN_ERR "ieee80211_tx_status: headroom too small\n");
1415 dev_kfree_skb(skb);
1416 return;
1417 }
1418
1419 rthdr = (struct ieee80211_tx_status_rtap_hdr*)
1420 skb_push(skb, sizeof(*rthdr));
1421
1422 memset(rthdr, 0, sizeof(*rthdr));
1423 rthdr->hdr.it_len = cpu_to_le16(sizeof(*rthdr));
1424 rthdr->hdr.it_present =
1425 cpu_to_le32((1 << IEEE80211_RADIOTAP_TX_FLAGS) |
1426 (1 << IEEE80211_RADIOTAP_DATA_RETRIES));
1427
1428 if (!(status->flags & IEEE80211_TX_STATUS_ACK) &&
1429 !is_multicast_ether_addr(hdr->addr1))
1430 rthdr->tx_flags |= cpu_to_le16(IEEE80211_RADIOTAP_F_TX_FAIL);
1431
1432 if ((status->control.flags & IEEE80211_TXCTL_USE_RTS_CTS) &&
1433 (status->control.flags & IEEE80211_TXCTL_USE_CTS_PROTECT))
1434 rthdr->tx_flags |= cpu_to_le16(IEEE80211_RADIOTAP_F_TX_CTS);
1435 else if (status->control.flags & IEEE80211_TXCTL_USE_RTS_CTS)
1436 rthdr->tx_flags |= cpu_to_le16(IEEE80211_RADIOTAP_F_TX_RTS);
1437
1438 rthdr->data_retries = status->retry_count;
1439
Michael Wu3d30d942008-01-31 19:48:27 +01001440 /* XXX: is this sufficient for BPF? */
1441 skb_set_mac_header(skb, 0);
1442 skb->ip_summed = CHECKSUM_UNNECESSARY;
1443 skb->pkt_type = PACKET_OTHERHOST;
1444 skb->protocol = htons(ETH_P_802_2);
1445 memset(skb->cb, 0, sizeof(skb->cb));
Johannes Bergb306f452007-07-10 19:32:08 +02001446
Michael Wu3d30d942008-01-31 19:48:27 +01001447 rcu_read_lock();
1448 list_for_each_entry_rcu(sdata, &local->interfaces, list) {
Johannes Berg51fb61e2007-12-19 01:31:27 +01001449 if (sdata->vif.type == IEEE80211_IF_TYPE_MNTR) {
Johannes Bergb306f452007-07-10 19:32:08 +02001450 if (!netif_running(sdata->dev))
1451 continue;
Michael Wu3d30d942008-01-31 19:48:27 +01001452
1453 if (prev_dev) {
Johannes Berg79010422007-09-18 17:29:21 -04001454 skb2 = skb_clone(skb, GFP_ATOMIC);
Michael Wu3d30d942008-01-31 19:48:27 +01001455 if (skb2) {
1456 skb2->dev = prev_dev;
1457 netif_rx(skb2);
1458 }
1459 }
1460
1461 prev_dev = sdata->dev;
Johannes Bergb306f452007-07-10 19:32:08 +02001462 }
1463 }
Michael Wu3d30d942008-01-31 19:48:27 +01001464 if (prev_dev) {
1465 skb->dev = prev_dev;
1466 netif_rx(skb);
1467 skb = NULL;
1468 }
Johannes Berg79010422007-09-18 17:29:21 -04001469 rcu_read_unlock();
Michael Wu3d30d942008-01-31 19:48:27 +01001470 dev_kfree_skb(skb);
Jiri Bencf0706e82007-05-05 11:45:53 -07001471}
1472EXPORT_SYMBOL(ieee80211_tx_status);
1473
Jiri Bencf0706e82007-05-05 11:45:53 -07001474struct ieee80211_hw *ieee80211_alloc_hw(size_t priv_data_len,
1475 const struct ieee80211_ops *ops)
1476{
Jiri Bencf0706e82007-05-05 11:45:53 -07001477 struct ieee80211_local *local;
Jiri Bencf0706e82007-05-05 11:45:53 -07001478 int priv_size;
1479 struct wiphy *wiphy;
1480
1481 /* Ensure 32-byte alignment of our private data and hw private data.
1482 * We use the wiphy priv data for both our ieee80211_local and for
1483 * the driver's private data
1484 *
1485 * In memory it'll be like this:
1486 *
1487 * +-------------------------+
1488 * | struct wiphy |
1489 * +-------------------------+
1490 * | struct ieee80211_local |
1491 * +-------------------------+
1492 * | driver's private data |
1493 * +-------------------------+
1494 *
1495 */
1496 priv_size = ((sizeof(struct ieee80211_local) +
1497 NETDEV_ALIGN_CONST) & ~NETDEV_ALIGN_CONST) +
1498 priv_data_len;
1499
1500 wiphy = wiphy_new(&mac80211_config_ops, priv_size);
1501
1502 if (!wiphy)
1503 return NULL;
1504
1505 wiphy->privid = mac80211_wiphy_privid;
1506
1507 local = wiphy_priv(wiphy);
1508 local->hw.wiphy = wiphy;
1509
1510 local->hw.priv = (char *)local +
1511 ((sizeof(struct ieee80211_local) +
1512 NETDEV_ALIGN_CONST) & ~NETDEV_ALIGN_CONST);
1513
Johannes Berg4480f15c2007-07-10 19:32:10 +02001514 BUG_ON(!ops->tx);
Johannes Berg4150c572007-09-17 01:29:23 -04001515 BUG_ON(!ops->start);
1516 BUG_ON(!ops->stop);
Johannes Berg4480f15c2007-07-10 19:32:10 +02001517 BUG_ON(!ops->config);
1518 BUG_ON(!ops->add_interface);
Johannes Berg4150c572007-09-17 01:29:23 -04001519 BUG_ON(!ops->remove_interface);
1520 BUG_ON(!ops->configure_filter);
Jiri Bencf0706e82007-05-05 11:45:53 -07001521 local->ops = ops;
1522
Jiri Bencf0706e82007-05-05 11:45:53 -07001523 local->hw.queues = 1; /* default */
1524
Jiri Bencf0706e82007-05-05 11:45:53 -07001525 local->bridge_packets = 1;
1526
1527 local->rts_threshold = IEEE80211_MAX_RTS_THRESHOLD;
1528 local->fragmentation_threshold = IEEE80211_MAX_FRAG_THRESHOLD;
1529 local->short_retry_limit = 7;
1530 local->long_retry_limit = 4;
1531 local->hw.conf.radio_enabled = 1;
Jiri Bencf0706e82007-05-05 11:45:53 -07001532
Johannes Berg79010422007-09-18 17:29:21 -04001533 INIT_LIST_HEAD(&local->interfaces);
Jiri Bencf0706e82007-05-05 11:45:53 -07001534
1535 INIT_DELAYED_WORK(&local->scan_work, ieee80211_sta_scan_work);
Jiri Bencf0706e82007-05-05 11:45:53 -07001536
1537 sta_info_init(local);
1538
Jiri Bencf0706e82007-05-05 11:45:53 -07001539 tasklet_init(&local->tx_pending_tasklet, ieee80211_tx_pending,
1540 (unsigned long)local);
1541 tasklet_disable(&local->tx_pending_tasklet);
1542
1543 tasklet_init(&local->tasklet,
1544 ieee80211_tasklet_handler,
1545 (unsigned long) local);
1546 tasklet_disable(&local->tasklet);
1547
1548 skb_queue_head_init(&local->skb_queue);
1549 skb_queue_head_init(&local->skb_queue_unreliable);
1550
1551 return local_to_hw(local);
1552}
1553EXPORT_SYMBOL(ieee80211_alloc_hw);
1554
1555int ieee80211_register_hw(struct ieee80211_hw *hw)
1556{
1557 struct ieee80211_local *local = hw_to_local(hw);
1558 const char *name;
1559 int result;
Johannes Berg8318d782008-01-24 19:38:38 +01001560 enum ieee80211_band band;
Johannes Berg96d51052008-02-08 09:48:13 +01001561 struct net_device *mdev;
1562 struct ieee80211_sub_if_data *sdata;
Johannes Berg8318d782008-01-24 19:38:38 +01001563
1564 /*
1565 * generic code guarantees at least one band,
1566 * set this very early because much code assumes
1567 * that hw.conf.channel is assigned
1568 */
1569 for (band = 0; band < IEEE80211_NUM_BANDS; band++) {
1570 struct ieee80211_supported_band *sband;
1571
1572 sband = local->hw.wiphy->bands[band];
1573 if (sband) {
1574 /* init channel we're on */
1575 local->hw.conf.channel =
1576 local->oper_channel =
1577 local->scan_channel = &sband->channels[0];
1578 break;
1579 }
1580 }
Jiri Bencf0706e82007-05-05 11:45:53 -07001581
1582 result = wiphy_register(local->hw.wiphy);
1583 if (result < 0)
1584 return result;
1585
Johannes Berg96d51052008-02-08 09:48:13 +01001586 /* for now, mdev needs sub_if_data :/ */
1587 mdev = alloc_netdev(sizeof(struct ieee80211_sub_if_data),
1588 "wmaster%d", ether_setup);
1589 if (!mdev)
1590 goto fail_mdev_alloc;
1591
1592 sdata = IEEE80211_DEV_TO_SUB_IF(mdev);
1593 mdev->ieee80211_ptr = &sdata->wdev;
1594 sdata->wdev.wiphy = local->hw.wiphy;
1595
1596 local->mdev = mdev;
1597
1598 ieee80211_rx_bss_list_init(mdev);
1599
1600 mdev->hard_start_xmit = ieee80211_master_start_xmit;
1601 mdev->open = ieee80211_master_open;
1602 mdev->stop = ieee80211_master_stop;
1603 mdev->type = ARPHRD_IEEE80211;
1604 mdev->header_ops = &ieee80211_header_ops;
1605 mdev->set_multicast_list = ieee80211_master_set_multicast_list;
1606
1607 sdata->vif.type = IEEE80211_IF_TYPE_AP;
1608 sdata->dev = mdev;
1609 sdata->local = local;
1610 sdata->u.ap.force_unicast_rateidx = -1;
1611 sdata->u.ap.max_ratectrl_rateidx = -1;
1612 ieee80211_if_sdata_init(sdata);
1613
1614 /* no RCU needed since we're still during init phase */
1615 list_add_tail(&sdata->list, &local->interfaces);
1616
Jiri Bencf0706e82007-05-05 11:45:53 -07001617 name = wiphy_dev(local->hw.wiphy)->driver->name;
1618 local->hw.workqueue = create_singlethread_workqueue(name);
1619 if (!local->hw.workqueue) {
1620 result = -ENOMEM;
1621 goto fail_workqueue;
1622 }
1623
Johannes Bergb306f452007-07-10 19:32:08 +02001624 /*
1625 * The hardware needs headroom for sending the frame,
1626 * and we need some headroom for passing the frame to monitor
1627 * interfaces, but never both at the same time.
1628 */
Jiri Benc33ccad32007-07-18 17:10:44 +02001629 local->tx_headroom = max_t(unsigned int , local->hw.extra_tx_headroom,
1630 sizeof(struct ieee80211_tx_status_rtap_hdr));
Johannes Bergb306f452007-07-10 19:32:08 +02001631
Jiri Bence9f207f2007-05-05 11:46:38 -07001632 debugfs_hw_add(local);
1633
Jiri Bencf0706e82007-05-05 11:45:53 -07001634 local->hw.conf.beacon_int = 1000;
1635
1636 local->wstats_flags |= local->hw.max_rssi ?
1637 IW_QUAL_LEVEL_UPDATED : IW_QUAL_LEVEL_INVALID;
1638 local->wstats_flags |= local->hw.max_signal ?
1639 IW_QUAL_QUAL_UPDATED : IW_QUAL_QUAL_INVALID;
1640 local->wstats_flags |= local->hw.max_noise ?
1641 IW_QUAL_NOISE_UPDATED : IW_QUAL_NOISE_INVALID;
1642 if (local->hw.max_rssi < 0 || local->hw.max_noise < 0)
1643 local->wstats_flags |= IW_QUAL_DBM;
1644
1645 result = sta_info_start(local);
1646 if (result < 0)
1647 goto fail_sta_info;
1648
1649 rtnl_lock();
1650 result = dev_alloc_name(local->mdev, local->mdev->name);
1651 if (result < 0)
1652 goto fail_dev;
1653
1654 memcpy(local->mdev->dev_addr, local->hw.wiphy->perm_addr, ETH_ALEN);
1655 SET_NETDEV_DEV(local->mdev, wiphy_dev(local->hw.wiphy));
1656
1657 result = register_netdevice(local->mdev);
1658 if (result < 0)
1659 goto fail_dev;
1660
Jiri Bence9f207f2007-05-05 11:46:38 -07001661 ieee80211_debugfs_add_netdev(IEEE80211_DEV_TO_SUB_IF(local->mdev));
Johannes Berg5b2812e2007-09-26 14:27:23 +02001662 ieee80211_if_set_type(local->mdev, IEEE80211_IF_TYPE_AP);
Jiri Bence9f207f2007-05-05 11:46:38 -07001663
Johannes Berg830f9032007-10-28 14:51:05 +01001664 result = ieee80211_init_rate_ctrl_alg(local,
1665 hw->rate_control_algorithm);
Jiri Bencf0706e82007-05-05 11:45:53 -07001666 if (result < 0) {
1667 printk(KERN_DEBUG "%s: Failed to initialize rate control "
Johannes Bergdd1cd4c2007-09-18 17:29:20 -04001668 "algorithm\n", wiphy_name(local->hw.wiphy));
Jiri Bencf0706e82007-05-05 11:45:53 -07001669 goto fail_rate;
1670 }
1671
1672 result = ieee80211_wep_init(local);
1673
1674 if (result < 0) {
1675 printk(KERN_DEBUG "%s: Failed to initialize wep\n",
Johannes Bergdd1cd4c2007-09-18 17:29:20 -04001676 wiphy_name(local->hw.wiphy));
Jiri Bencf0706e82007-05-05 11:45:53 -07001677 goto fail_wep;
1678 }
1679
1680 ieee80211_install_qdisc(local->mdev);
1681
1682 /* add one default STA interface */
1683 result = ieee80211_if_add(local->mdev, "wlan%d", NULL,
Luis Carlos Coboee385852008-02-23 15:17:11 +01001684 IEEE80211_IF_TYPE_STA, NULL);
Jiri Bencf0706e82007-05-05 11:45:53 -07001685 if (result)
1686 printk(KERN_WARNING "%s: Failed to add default virtual iface\n",
Johannes Bergdd1cd4c2007-09-18 17:29:20 -04001687 wiphy_name(local->hw.wiphy));
Jiri Bencf0706e82007-05-05 11:45:53 -07001688
1689 local->reg_state = IEEE80211_DEV_REGISTERED;
1690 rtnl_unlock();
1691
1692 ieee80211_led_init(local);
1693
1694 return 0;
1695
1696fail_wep:
1697 rate_control_deinitialize(local);
1698fail_rate:
Jiri Bence9f207f2007-05-05 11:46:38 -07001699 ieee80211_debugfs_remove_netdev(IEEE80211_DEV_TO_SUB_IF(local->mdev));
Jiri Bencf0706e82007-05-05 11:45:53 -07001700 unregister_netdevice(local->mdev);
1701fail_dev:
1702 rtnl_unlock();
1703 sta_info_stop(local);
1704fail_sta_info:
Jiri Bence9f207f2007-05-05 11:46:38 -07001705 debugfs_hw_del(local);
Jiri Bencf0706e82007-05-05 11:45:53 -07001706 destroy_workqueue(local->hw.workqueue);
1707fail_workqueue:
Johannes Berg96d51052008-02-08 09:48:13 +01001708 ieee80211_if_free(local->mdev);
1709 local->mdev = NULL;
1710fail_mdev_alloc:
Jiri Bencf0706e82007-05-05 11:45:53 -07001711 wiphy_unregister(local->hw.wiphy);
1712 return result;
1713}
1714EXPORT_SYMBOL(ieee80211_register_hw);
1715
Jiri Bencf0706e82007-05-05 11:45:53 -07001716void ieee80211_unregister_hw(struct ieee80211_hw *hw)
1717{
1718 struct ieee80211_local *local = hw_to_local(hw);
1719 struct ieee80211_sub_if_data *sdata, *tmp;
Jiri Bencf0706e82007-05-05 11:45:53 -07001720
1721 tasklet_kill(&local->tx_pending_tasklet);
1722 tasklet_kill(&local->tasklet);
1723
1724 rtnl_lock();
1725
1726 BUG_ON(local->reg_state != IEEE80211_DEV_REGISTERED);
1727
1728 local->reg_state = IEEE80211_DEV_UNREGISTERED;
Jiri Bencf0706e82007-05-05 11:45:53 -07001729
Johannes Berg79010422007-09-18 17:29:21 -04001730 /*
1731 * At this point, interface list manipulations are fine
1732 * because the driver cannot be handing us frames any
1733 * more and the tasklet is killed.
1734 */
Johannes Berg5b2812e2007-09-26 14:27:23 +02001735
1736 /*
1737 * First, we remove all non-master interfaces. Do this because they
1738 * may have bss pointer dependency on the master, and when we free
1739 * the master these would be freed as well, breaking our list
1740 * iteration completely.
1741 */
1742 list_for_each_entry_safe(sdata, tmp, &local->interfaces, list) {
1743 if (sdata->dev == local->mdev)
1744 continue;
1745 list_del(&sdata->list);
Jiri Bencf0706e82007-05-05 11:45:53 -07001746 __ieee80211_if_del(local, sdata);
Johannes Berg5b2812e2007-09-26 14:27:23 +02001747 }
1748
1749 /* then, finally, remove the master interface */
1750 __ieee80211_if_del(local, IEEE80211_DEV_TO_SUB_IF(local->mdev));
Jiri Bencf0706e82007-05-05 11:45:53 -07001751
1752 rtnl_unlock();
1753
Jiri Bencf0706e82007-05-05 11:45:53 -07001754 ieee80211_rx_bss_list_deinit(local->mdev);
1755 ieee80211_clear_tx_pending(local);
1756 sta_info_stop(local);
1757 rate_control_deinitialize(local);
Jiri Bence9f207f2007-05-05 11:46:38 -07001758 debugfs_hw_del(local);
Jiri Bencf0706e82007-05-05 11:45:53 -07001759
Jiri Bencf0706e82007-05-05 11:45:53 -07001760 if (skb_queue_len(&local->skb_queue)
1761 || skb_queue_len(&local->skb_queue_unreliable))
1762 printk(KERN_WARNING "%s: skb_queue not empty\n",
Johannes Bergdd1cd4c2007-09-18 17:29:20 -04001763 wiphy_name(local->hw.wiphy));
Jiri Bencf0706e82007-05-05 11:45:53 -07001764 skb_queue_purge(&local->skb_queue);
1765 skb_queue_purge(&local->skb_queue_unreliable);
1766
1767 destroy_workqueue(local->hw.workqueue);
1768 wiphy_unregister(local->hw.wiphy);
1769 ieee80211_wep_free(local);
1770 ieee80211_led_exit(local);
Johannes Berg96d51052008-02-08 09:48:13 +01001771 ieee80211_if_free(local->mdev);
1772 local->mdev = NULL;
Jiri Bencf0706e82007-05-05 11:45:53 -07001773}
1774EXPORT_SYMBOL(ieee80211_unregister_hw);
1775
1776void ieee80211_free_hw(struct ieee80211_hw *hw)
1777{
1778 struct ieee80211_local *local = hw_to_local(hw);
1779
Jiri Bencf0706e82007-05-05 11:45:53 -07001780 wiphy_free(local->hw.wiphy);
1781}
1782EXPORT_SYMBOL(ieee80211_free_hw);
1783
Jiri Bencf0706e82007-05-05 11:45:53 -07001784static int __init ieee80211_init(void)
1785{
1786 struct sk_buff *skb;
1787 int ret;
1788
1789 BUILD_BUG_ON(sizeof(struct ieee80211_tx_packet_data) > sizeof(skb->cb));
1790
Johannes Berg4b475892008-01-02 15:17:03 +01001791 ret = rc80211_simple_init();
Johannes Bergac71c692007-10-28 14:17:44 +01001792 if (ret)
Johannes Berg3eadf5f2008-01-31 19:33:53 +01001793 goto out;
Mattias Nisslerad018372007-12-19 01:25:57 +01001794
Johannes Berg4b475892008-01-02 15:17:03 +01001795 ret = rc80211_pid_init();
Mattias Nisslerad018372007-12-19 01:25:57 +01001796 if (ret)
Johannes Berg3eadf5f2008-01-31 19:33:53 +01001797 goto out_cleanup_simple;
Johannes Bergac71c692007-10-28 14:17:44 +01001798
Jiri Bencf0706e82007-05-05 11:45:53 -07001799 ret = ieee80211_wme_register();
1800 if (ret) {
1801 printk(KERN_DEBUG "ieee80211_init: failed to "
1802 "initialize WME (err=%d)\n", ret);
Johannes Berg3eadf5f2008-01-31 19:33:53 +01001803 goto out_cleanup_pid;
Jiri Bencf0706e82007-05-05 11:45:53 -07001804 }
1805
Jiri Bence9f207f2007-05-05 11:46:38 -07001806 ieee80211_debugfs_netdev_init();
1807
Jiri Bencf0706e82007-05-05 11:45:53 -07001808 return 0;
Mattias Nisslerad018372007-12-19 01:25:57 +01001809
Johannes Berg3eadf5f2008-01-31 19:33:53 +01001810 out_cleanup_pid:
Johannes Berg4b475892008-01-02 15:17:03 +01001811 rc80211_pid_exit();
Johannes Berg3eadf5f2008-01-31 19:33:53 +01001812 out_cleanup_simple:
1813 rc80211_simple_exit();
1814 out:
Mattias Nisslerad018372007-12-19 01:25:57 +01001815 return ret;
Jiri Bencf0706e82007-05-05 11:45:53 -07001816}
1817
Jiri Bencf0706e82007-05-05 11:45:53 -07001818static void __exit ieee80211_exit(void)
1819{
Johannes Berg4b475892008-01-02 15:17:03 +01001820 rc80211_simple_exit();
1821 rc80211_pid_exit();
Johannes Bergac71c692007-10-28 14:17:44 +01001822
Luis Carlos Cobof7a92142008-02-23 15:17:18 +01001823 if (mesh_allocated)
1824 ieee80211s_stop();
Johannes Berg902acc72008-02-23 15:17:19 +01001825
Jiri Bencf0706e82007-05-05 11:45:53 -07001826 ieee80211_wme_unregister();
Jiri Bence9f207f2007-05-05 11:46:38 -07001827 ieee80211_debugfs_netdev_exit();
Jiri Bencf0706e82007-05-05 11:45:53 -07001828}
1829
1830
Johannes Bergca9938f2007-09-11 12:50:32 +02001831subsys_initcall(ieee80211_init);
Jiri Bencf0706e82007-05-05 11:45:53 -07001832module_exit(ieee80211_exit);
1833
1834MODULE_DESCRIPTION("IEEE 802.11 subsystem");
1835MODULE_LICENSE("GPL");