blob: 7106d651f4f9dcdf41115a752951c5fd1f6f738b [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#ifdef CONFIG_MAC80211_MESH
30#include "mesh.h"
31#endif
Jiri Bencf0706e82007-05-05 11:45:53 -070032#include "wep.h"
Jiri Bencf0706e82007-05-05 11:45:53 -070033#include "wme.h"
34#include "aes_ccm.h"
35#include "ieee80211_led.h"
Michael Wue0eb6852007-09-18 17:29:21 -040036#include "cfg.h"
Jiri Bence9f207f2007-05-05 11:46:38 -070037#include "debugfs.h"
38#include "debugfs_netdev.h"
Jiri Bencf0706e82007-05-05 11:45:53 -070039
Ron Rindjunskyd3c990f2007-11-26 16:14:34 +020040#define SUPP_MCS_SET_LEN 16
41
Johannes Bergb306f452007-07-10 19:32:08 +020042/*
43 * For seeing transmitted packets on monitor interfaces
44 * we have a radiotap header too.
45 */
46struct ieee80211_tx_status_rtap_hdr {
47 struct ieee80211_radiotap_header hdr;
48 __le16 tx_flags;
49 u8 data_retries;
50} __attribute__ ((packed));
51
Johannes Bergb2c258f2007-07-27 15:43:23 +020052/* common interface routines */
Jiri Bencf0706e82007-05-05 11:45:53 -070053
Stephen Hemmingerb95cce32007-09-26 22:13:38 -070054static int header_parse_80211(const struct sk_buff *skb, unsigned char *haddr)
Jiri Bencf0706e82007-05-05 11:45:53 -070055{
Johannes Bergb2c258f2007-07-27 15:43:23 +020056 memcpy(haddr, skb_mac_header(skb) + 10, ETH_ALEN); /* addr2 */
57 return ETH_ALEN;
Jiri Bencf0706e82007-05-05 11:45:53 -070058}
59
Johannes Berg4150c572007-09-17 01:29:23 -040060/* must be called under mdev tx lock */
61static void ieee80211_configure_filter(struct ieee80211_local *local)
62{
63 unsigned int changed_flags;
64 unsigned int new_flags = 0;
65
Johannes Berg53918992007-09-26 15:19:47 +020066 if (atomic_read(&local->iff_promiscs))
Johannes Berg4150c572007-09-17 01:29:23 -040067 new_flags |= FIF_PROMISC_IN_BSS;
68
Johannes Berg53918992007-09-26 15:19:47 +020069 if (atomic_read(&local->iff_allmultis))
Johannes Berg4150c572007-09-17 01:29:23 -040070 new_flags |= FIF_ALLMULTI;
71
72 if (local->monitors)
Michael Wu8cc9a732008-01-31 19:48:23 +010073 new_flags |= FIF_BCN_PRBRESP_PROMISC;
74
75 if (local->fif_fcsfail)
76 new_flags |= FIF_FCSFAIL;
77
78 if (local->fif_plcpfail)
79 new_flags |= FIF_PLCPFAIL;
80
81 if (local->fif_control)
82 new_flags |= FIF_CONTROL;
83
84 if (local->fif_other_bss)
85 new_flags |= FIF_OTHER_BSS;
Johannes Berg4150c572007-09-17 01:29:23 -040086
87 changed_flags = local->filter_flags ^ new_flags;
88
89 /* be a bit nasty */
90 new_flags |= (1<<31);
91
92 local->ops->configure_filter(local_to_hw(local),
93 changed_flags, &new_flags,
94 local->mdev->mc_count,
95 local->mdev->mc_list);
96
97 WARN_ON(new_flags & (1<<31));
98
99 local->filter_flags = new_flags & ~(1<<31);
100}
101
Johannes Bergb2c258f2007-07-27 15:43:23 +0200102/* master interface */
Jiri Bencf0706e82007-05-05 11:45:53 -0700103
104static int ieee80211_master_open(struct net_device *dev)
105{
106 struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr);
107 struct ieee80211_sub_if_data *sdata;
108 int res = -EOPNOTSUPP;
109
Johannes Berg79010422007-09-18 17:29:21 -0400110 /* we hold the RTNL here so can safely walk the list */
111 list_for_each_entry(sdata, &local->interfaces, list) {
Jiri Bencf0706e82007-05-05 11:45:53 -0700112 if (sdata->dev != dev && netif_running(sdata->dev)) {
113 res = 0;
114 break;
115 }
116 }
Jiri Bencf0706e82007-05-05 11:45:53 -0700117 return res;
118}
119
120static int ieee80211_master_stop(struct net_device *dev)
121{
122 struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr);
123 struct ieee80211_sub_if_data *sdata;
124
Johannes Berg79010422007-09-18 17:29:21 -0400125 /* we hold the RTNL here so can safely walk the list */
126 list_for_each_entry(sdata, &local->interfaces, list)
Jiri Bencf0706e82007-05-05 11:45:53 -0700127 if (sdata->dev != dev && netif_running(sdata->dev))
128 dev_close(sdata->dev);
Jiri Bencf0706e82007-05-05 11:45:53 -0700129
130 return 0;
131}
132
Johannes Berg4150c572007-09-17 01:29:23 -0400133static void ieee80211_master_set_multicast_list(struct net_device *dev)
134{
135 struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr);
136
137 ieee80211_configure_filter(local);
138}
139
Johannes Bergb2c258f2007-07-27 15:43:23 +0200140/* regular interfaces */
141
142static int ieee80211_change_mtu(struct net_device *dev, int new_mtu)
143{
Luis Carlos Cobof7a92142008-02-23 15:17:18 +0100144 int meshhdrlen;
145 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
146
147 meshhdrlen = (sdata->vif.type == IEEE80211_IF_TYPE_MESH_POINT) ? 5 : 0;
148
Johannes Bergb2c258f2007-07-27 15:43:23 +0200149 /* FIX: what would be proper limits for MTU?
150 * This interface uses 802.3 frames. */
Luis Carlos Cobof7a92142008-02-23 15:17:18 +0100151 if (new_mtu < 256 ||
152 new_mtu > IEEE80211_MAX_DATA_LEN - 24 - 6 - meshhdrlen) {
Johannes Bergb2c258f2007-07-27 15:43:23 +0200153 printk(KERN_WARNING "%s: invalid MTU %d\n",
154 dev->name, new_mtu);
155 return -EINVAL;
156 }
157
158#ifdef CONFIG_MAC80211_VERBOSE_DEBUG
159 printk(KERN_DEBUG "%s: setting MTU %d\n", dev->name, new_mtu);
160#endif /* CONFIG_MAC80211_VERBOSE_DEBUG */
161 dev->mtu = new_mtu;
162 return 0;
163}
164
165static inline int identical_mac_addr_allowed(int type1, int type2)
166{
167 return (type1 == IEEE80211_IF_TYPE_MNTR ||
168 type2 == IEEE80211_IF_TYPE_MNTR ||
169 (type1 == IEEE80211_IF_TYPE_AP &&
170 type2 == IEEE80211_IF_TYPE_WDS) ||
171 (type1 == IEEE80211_IF_TYPE_WDS &&
172 (type2 == IEEE80211_IF_TYPE_WDS ||
173 type2 == IEEE80211_IF_TYPE_AP)) ||
174 (type1 == IEEE80211_IF_TYPE_AP &&
175 type2 == IEEE80211_IF_TYPE_VLAN) ||
176 (type1 == IEEE80211_IF_TYPE_VLAN &&
177 (type2 == IEEE80211_IF_TYPE_AP ||
178 type2 == IEEE80211_IF_TYPE_VLAN)));
179}
180
Johannes Bergb2c258f2007-07-27 15:43:23 +0200181static int ieee80211_open(struct net_device *dev)
182{
183 struct ieee80211_sub_if_data *sdata, *nsdata;
184 struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr);
185 struct ieee80211_if_init_conf conf;
186 int res;
Michael Bueschceffefd2008-02-10 14:16:52 +0100187 bool need_hw_reconfig = 0;
Johannes Bergb2c258f2007-07-27 15:43:23 +0200188
189 sdata = IEEE80211_DEV_TO_SUB_IF(dev);
Johannes Berg0ec3ca42007-09-17 01:29:24 -0400190
Johannes Berg79010422007-09-18 17:29:21 -0400191 /* we hold the RTNL here so can safely walk the list */
192 list_for_each_entry(nsdata, &local->interfaces, list) {
Johannes Bergb2c258f2007-07-27 15:43:23 +0200193 struct net_device *ndev = nsdata->dev;
194
Johannes Berg665e8aa2008-02-21 01:10:07 +0100195 if (ndev != dev && ndev != local->mdev && netif_running(ndev)) {
196 /*
197 * Allow only a single IBSS interface to be up at any
198 * time. This is restricted because beacon distribution
199 * cannot work properly if both are in the same IBSS.
200 *
201 * To remove this restriction we'd have to disallow them
202 * from setting the same SSID on different IBSS interfaces
203 * belonging to the same hardware. Then, however, we're
204 * faced with having to adopt two different TSF timers...
205 */
206 if (sdata->vif.type == IEEE80211_IF_TYPE_IBSS &&
207 nsdata->vif.type == IEEE80211_IF_TYPE_IBSS)
208 return -EBUSY;
209
210 /*
211 * Disallow multiple IBSS/STA mode interfaces.
212 *
213 * This is a technical restriction, it is possible although
214 * most likely not IEEE 802.11 compliant to have multiple
215 * STAs with just a single hardware (the TSF timer will not
216 * be adjusted properly.)
217 *
218 * However, because mac80211 uses the master device's BSS
219 * information for each STA/IBSS interface, doing this will
220 * currently corrupt that BSS information completely, unless,
221 * a not very useful case, both STAs are associated to the
222 * same BSS.
223 *
224 * To remove this restriction, the BSS information needs to
225 * be embedded in the STA/IBSS mode sdata instead of using
226 * the master device's BSS structure.
227 */
228 if ((sdata->vif.type == IEEE80211_IF_TYPE_STA ||
229 sdata->vif.type == IEEE80211_IF_TYPE_IBSS) &&
230 (nsdata->vif.type == IEEE80211_IF_TYPE_STA ||
231 nsdata->vif.type == IEEE80211_IF_TYPE_IBSS))
232 return -EBUSY;
233
234 /*
235 * The remaining checks are only performed for interfaces
236 * with the same MAC address.
237 */
238 if (compare_ether_addr(dev->dev_addr, ndev->dev_addr))
239 continue;
240
Johannes Berg0ec3ca42007-09-17 01:29:24 -0400241 /*
242 * check whether it may have the same address
243 */
Johannes Berg51fb61e2007-12-19 01:31:27 +0100244 if (!identical_mac_addr_allowed(sdata->vif.type,
245 nsdata->vif.type))
Johannes Berg0ec3ca42007-09-17 01:29:24 -0400246 return -ENOTUNIQ;
Johannes Berg0ec3ca42007-09-17 01:29:24 -0400247
248 /*
249 * can only add VLANs to enabled APs
250 */
Johannes Berg51fb61e2007-12-19 01:31:27 +0100251 if (sdata->vif.type == IEEE80211_IF_TYPE_VLAN &&
Johannes Berg665e8aa2008-02-21 01:10:07 +0100252 nsdata->vif.type == IEEE80211_IF_TYPE_AP)
Johannes Berg0ec3ca42007-09-17 01:29:24 -0400253 sdata->u.vlan.ap = nsdata;
Johannes Bergb2c258f2007-07-27 15:43:23 +0200254 }
255 }
Johannes Bergb2c258f2007-07-27 15:43:23 +0200256
Johannes Berg51fb61e2007-12-19 01:31:27 +0100257 switch (sdata->vif.type) {
Johannes Berg0ec3ca42007-09-17 01:29:24 -0400258 case IEEE80211_IF_TYPE_WDS:
259 if (is_zero_ether_addr(sdata->u.wds.remote_addr))
260 return -ENOLINK;
261 break;
262 case IEEE80211_IF_TYPE_VLAN:
263 if (!sdata->u.vlan.ap)
264 return -ENOLINK;
265 break;
Johannes Bergfb1c1cd2007-09-26 15:19:43 +0200266 case IEEE80211_IF_TYPE_AP:
Johannes Bergfb1c1cd2007-09-26 15:19:43 +0200267 case IEEE80211_IF_TYPE_STA:
268 case IEEE80211_IF_TYPE_MNTR:
269 case IEEE80211_IF_TYPE_IBSS:
Johannes Berg6032f932008-02-23 15:17:07 +0100270 case IEEE80211_IF_TYPE_MESH_POINT:
Johannes Bergfb1c1cd2007-09-26 15:19:43 +0200271 /* no special treatment */
272 break;
Johannes Berga2897552007-09-28 14:01:25 +0200273 case IEEE80211_IF_TYPE_INVALID:
274 /* cannot happen */
275 WARN_ON(1);
276 break;
Johannes Berg0ec3ca42007-09-17 01:29:24 -0400277 }
Johannes Bergb2c258f2007-07-27 15:43:23 +0200278
Johannes Bergb2c258f2007-07-27 15:43:23 +0200279 if (local->open_count == 0) {
280 res = 0;
Johannes Berg4150c572007-09-17 01:29:23 -0400281 if (local->ops->start)
282 res = local->ops->start(local_to_hw(local));
283 if (res)
Johannes Bergb2c258f2007-07-27 15:43:23 +0200284 return res;
Michael Bueschceffefd2008-02-10 14:16:52 +0100285 need_hw_reconfig = 1;
Ivo van Doorncdcb0062008-01-07 19:45:24 +0100286 ieee80211_led_radio(local, local->hw.conf.radio_enabled);
Johannes Bergb2c258f2007-07-27 15:43:23 +0200287 }
Johannes Bergb2c258f2007-07-27 15:43:23 +0200288
Johannes Berg51fb61e2007-12-19 01:31:27 +0100289 switch (sdata->vif.type) {
Johannes Berg0ec3ca42007-09-17 01:29:24 -0400290 case IEEE80211_IF_TYPE_VLAN:
291 list_add(&sdata->u.vlan.list, &sdata->u.vlan.ap->u.ap.vlans);
292 /* no need to tell driver */
293 break;
Johannes Berg4150c572007-09-17 01:29:23 -0400294 case IEEE80211_IF_TYPE_MNTR:
Michael Wu3d30d942008-01-31 19:48:27 +0100295 if (sdata->u.mntr_flags & MONITOR_FLAG_COOK_FRAMES) {
296 local->cooked_mntrs++;
297 break;
298 }
299
Johannes Berg4150c572007-09-17 01:29:23 -0400300 /* must be before the call to ieee80211_configure_filter */
Johannes Bergb2c258f2007-07-27 15:43:23 +0200301 local->monitors++;
Michael Wu8cc9a732008-01-31 19:48:23 +0100302 if (local->monitors == 1)
Johannes Berg4150c572007-09-17 01:29:23 -0400303 local->hw.conf.flags |= IEEE80211_CONF_RADIOTAP;
Michael Wu8cc9a732008-01-31 19:48:23 +0100304
305 if (sdata->u.mntr_flags & MONITOR_FLAG_FCSFAIL)
306 local->fif_fcsfail++;
307 if (sdata->u.mntr_flags & MONITOR_FLAG_PLCPFAIL)
308 local->fif_plcpfail++;
309 if (sdata->u.mntr_flags & MONITOR_FLAG_CONTROL)
310 local->fif_control++;
311 if (sdata->u.mntr_flags & MONITOR_FLAG_OTHER_BSS)
312 local->fif_other_bss++;
313
314 netif_tx_lock_bh(local->mdev);
315 ieee80211_configure_filter(local);
316 netif_tx_unlock_bh(local->mdev);
Johannes Berg4150c572007-09-17 01:29:23 -0400317 break;
318 case IEEE80211_IF_TYPE_STA:
319 case IEEE80211_IF_TYPE_IBSS:
320 sdata->u.sta.flags &= ~IEEE80211_STA_PREV_BSSID_SET;
321 /* fall through */
322 default:
Johannes Berg32bfd352007-12-19 01:31:26 +0100323 conf.vif = &sdata->vif;
Johannes Berg51fb61e2007-12-19 01:31:27 +0100324 conf.type = sdata->vif.type;
Johannes Berg4150c572007-09-17 01:29:23 -0400325 conf.mac_addr = dev->dev_addr;
326 res = local->ops->add_interface(local_to_hw(local), &conf);
327 if (res && !local->open_count && local->ops->stop)
328 local->ops->stop(local_to_hw(local));
329 if (res)
330 return res;
331
Johannes Bergb2c258f2007-07-27 15:43:23 +0200332 ieee80211_if_config(dev);
Daniel Draked9430a32007-07-27 15:43:24 +0200333 ieee80211_reset_erp_info(dev);
Johannes Berg11a843b2007-08-28 17:01:55 -0400334 ieee80211_enable_keys(sdata);
Johannes Berg4150c572007-09-17 01:29:23 -0400335
Johannes Berg51fb61e2007-12-19 01:31:27 +0100336 if (sdata->vif.type == IEEE80211_IF_TYPE_STA &&
Johannes Bergddd3d2b2007-09-26 17:53:20 +0200337 !(sdata->flags & IEEE80211_SDATA_USERSPACE_MLME))
Johannes Berg4150c572007-09-17 01:29:23 -0400338 netif_carrier_off(dev);
339 else
340 netif_carrier_on(dev);
Daniel Draked9430a32007-07-27 15:43:24 +0200341 }
Johannes Bergb2c258f2007-07-27 15:43:23 +0200342
Johannes Berg4150c572007-09-17 01:29:23 -0400343 if (local->open_count == 0) {
344 res = dev_open(local->mdev);
345 WARN_ON(res);
Johannes Berg4150c572007-09-17 01:29:23 -0400346 tasklet_enable(&local->tx_pending_tasklet);
347 tasklet_enable(&local->tasklet);
348 }
349
Johannes Bergc1428b32007-11-16 02:54:53 +0100350 /*
351 * set_multicast_list will be invoked by the networking core
352 * which will check whether any increments here were done in
353 * error and sync them down to the hardware as filter flags.
354 */
355 if (sdata->flags & IEEE80211_SDATA_ALLMULTI)
356 atomic_inc(&local->iff_allmultis);
357
358 if (sdata->flags & IEEE80211_SDATA_PROMISC)
359 atomic_inc(&local->iff_promiscs);
360
Johannes Berg4150c572007-09-17 01:29:23 -0400361 local->open_count++;
Michael Bueschceffefd2008-02-10 14:16:52 +0100362 if (need_hw_reconfig)
363 ieee80211_hw_config(local);
Johannes Bergb2c258f2007-07-27 15:43:23 +0200364
365 netif_start_queue(dev);
Johannes Berg4150c572007-09-17 01:29:23 -0400366
Johannes Bergb2c258f2007-07-27 15:43:23 +0200367 return 0;
368}
369
Johannes Berg4150c572007-09-17 01:29:23 -0400370static int ieee80211_stop(struct net_device *dev)
Johannes Bergb2c258f2007-07-27 15:43:23 +0200371{
Johannes Berg4150c572007-09-17 01:29:23 -0400372 struct ieee80211_sub_if_data *sdata;
Johannes Bergb2c258f2007-07-27 15:43:23 +0200373 struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr);
Johannes Berg4150c572007-09-17 01:29:23 -0400374 struct ieee80211_if_init_conf conf;
Ron Rindjunsky07db2182007-12-25 17:00:33 +0200375 struct sta_info *sta;
376 int i;
Johannes Bergb2c258f2007-07-27 15:43:23 +0200377
Johannes Berg4150c572007-09-17 01:29:23 -0400378 sdata = IEEE80211_DEV_TO_SUB_IF(dev);
379
Ron Rindjunsky07db2182007-12-25 17:00:33 +0200380 list_for_each_entry(sta, &local->sta_list, list) {
Ron Rindjunsky5b3d71d2008-01-13 18:21:58 +0200381 if (sta->dev == dev)
382 for (i = 0; i < STA_TID_NUM; i++)
383 ieee80211_sta_stop_rx_ba_session(sta->dev,
384 sta->addr, i,
385 WLAN_BACK_RECIPIENT,
Ron Rindjunsky07db2182007-12-25 17:00:33 +0200386 WLAN_REASON_QSTA_LEAVE_QBSS);
387 }
388
Johannes Berg4150c572007-09-17 01:29:23 -0400389 netif_stop_queue(dev);
390
Johannes Bergc1428b32007-11-16 02:54:53 +0100391 /*
392 * Don't count this interface for promisc/allmulti while it
393 * is down. dev_mc_unsync() will invoke set_multicast_list
394 * on the master interface which will sync these down to the
395 * hardware as filter flags.
396 */
397 if (sdata->flags & IEEE80211_SDATA_ALLMULTI)
398 atomic_dec(&local->iff_allmultis);
399
400 if (sdata->flags & IEEE80211_SDATA_PROMISC)
401 atomic_dec(&local->iff_promiscs);
402
Johannes Berg4150c572007-09-17 01:29:23 -0400403 dev_mc_unsync(local->mdev, dev);
404
Johannes Berg5dfdaf52007-12-19 02:03:33 +0100405 /* APs need special treatment */
Johannes Berg51fb61e2007-12-19 01:31:27 +0100406 if (sdata->vif.type == IEEE80211_IF_TYPE_AP) {
Johannes Berg0ec3ca42007-09-17 01:29:24 -0400407 struct ieee80211_sub_if_data *vlan, *tmp;
Johannes Berg5dfdaf52007-12-19 02:03:33 +0100408 struct beacon_data *old_beacon = sdata->u.ap.beacon;
Johannes Berg0ec3ca42007-09-17 01:29:24 -0400409
Johannes Berg5dfdaf52007-12-19 02:03:33 +0100410 /* remove beacon */
411 rcu_assign_pointer(sdata->u.ap.beacon, NULL);
412 synchronize_rcu();
413 kfree(old_beacon);
414
415 /* down all dependent devices, that is VLANs */
Johannes Berg0ec3ca42007-09-17 01:29:24 -0400416 list_for_each_entry_safe(vlan, tmp, &sdata->u.ap.vlans,
417 u.vlan.list)
418 dev_close(vlan->dev);
419 WARN_ON(!list_empty(&sdata->u.ap.vlans));
420 }
421
Johannes Berg4150c572007-09-17 01:29:23 -0400422 local->open_count--;
423
Johannes Berg51fb61e2007-12-19 01:31:27 +0100424 switch (sdata->vif.type) {
Johannes Berg0ec3ca42007-09-17 01:29:24 -0400425 case IEEE80211_IF_TYPE_VLAN:
426 list_del(&sdata->u.vlan.list);
427 sdata->u.vlan.ap = NULL;
428 /* no need to tell driver */
429 break;
Johannes Berg4150c572007-09-17 01:29:23 -0400430 case IEEE80211_IF_TYPE_MNTR:
Michael Wu3d30d942008-01-31 19:48:27 +0100431 if (sdata->u.mntr_flags & MONITOR_FLAG_COOK_FRAMES) {
432 local->cooked_mntrs--;
433 break;
434 }
435
Johannes Berg4150c572007-09-17 01:29:23 -0400436 local->monitors--;
Michael Wu8cc9a732008-01-31 19:48:23 +0100437 if (local->monitors == 0)
Michael Wu8b393f12007-11-28 01:57:08 -0500438 local->hw.conf.flags &= ~IEEE80211_CONF_RADIOTAP;
Michael Wu8cc9a732008-01-31 19:48:23 +0100439
440 if (sdata->u.mntr_flags & MONITOR_FLAG_FCSFAIL)
441 local->fif_fcsfail--;
442 if (sdata->u.mntr_flags & MONITOR_FLAG_PLCPFAIL)
443 local->fif_plcpfail--;
444 if (sdata->u.mntr_flags & MONITOR_FLAG_CONTROL)
445 local->fif_control--;
446 if (sdata->u.mntr_flags & MONITOR_FLAG_OTHER_BSS)
447 local->fif_other_bss--;
448
449 netif_tx_lock_bh(local->mdev);
450 ieee80211_configure_filter(local);
451 netif_tx_unlock_bh(local->mdev);
Johannes Berg4150c572007-09-17 01:29:23 -0400452 break;
Luis Carlos Cobof7a92142008-02-23 15:17:18 +0100453 case IEEE80211_IF_TYPE_MESH_POINT:
454 sta_info_flush(local, dev);
455 /* fall through */
Johannes Bergb2c258f2007-07-27 15:43:23 +0200456 case IEEE80211_IF_TYPE_STA:
457 case IEEE80211_IF_TYPE_IBSS:
458 sdata->u.sta.state = IEEE80211_DISABLED;
459 del_timer_sync(&sdata->u.sta.timer);
Johannes Berg2a8a9a82007-08-28 17:01:52 -0400460 /*
Johannes Berg79010422007-09-18 17:29:21 -0400461 * When we get here, the interface is marked down.
462 * Call synchronize_rcu() to wait for the RX path
463 * should it be using the interface and enqueuing
464 * frames at this very time on another CPU.
Johannes Berg2a8a9a82007-08-28 17:01:52 -0400465 */
Johannes Berg79010422007-09-18 17:29:21 -0400466 synchronize_rcu();
Johannes Bergb2c258f2007-07-27 15:43:23 +0200467 skb_queue_purge(&sdata->u.sta.skb_queue);
Johannes Berg2a8a9a82007-08-28 17:01:52 -0400468
Zhu Yiece8edd2007-11-22 10:53:21 +0800469 if (local->scan_dev == sdata->dev) {
470 if (!local->ops->hw_scan) {
471 local->sta_sw_scanning = 0;
472 cancel_delayed_work(&local->scan_work);
473 } else
474 local->sta_hw_scanning = 0;
Johannes Bergb2c258f2007-07-27 15:43:23 +0200475 }
Zhu Yiece8edd2007-11-22 10:53:21 +0800476
Johannes Bergb2c258f2007-07-27 15:43:23 +0200477 flush_workqueue(local->hw.workqueue);
Zhu Yia10605e2007-11-22 11:10:22 +0800478
479 sdata->u.sta.flags &= ~IEEE80211_STA_PRIVACY_INVOKED;
480 kfree(sdata->u.sta.extra_ie);
481 sdata->u.sta.extra_ie = NULL;
482 sdata->u.sta.extra_ie_len = 0;
Johannes Berg4150c572007-09-17 01:29:23 -0400483 /* fall through */
484 default:
Johannes Berg32bfd352007-12-19 01:31:26 +0100485 conf.vif = &sdata->vif;
Johannes Berg51fb61e2007-12-19 01:31:27 +0100486 conf.type = sdata->vif.type;
Johannes Bergb2c258f2007-07-27 15:43:23 +0200487 conf.mac_addr = dev->dev_addr;
Johannes Berg4150c572007-09-17 01:29:23 -0400488 /* disable all keys for as long as this netdev is down */
489 ieee80211_disable_keys(sdata);
Johannes Bergb2c258f2007-07-27 15:43:23 +0200490 local->ops->remove_interface(local_to_hw(local), &conf);
491 }
492
Johannes Berg4150c572007-09-17 01:29:23 -0400493 if (local->open_count == 0) {
494 if (netif_running(local->mdev))
495 dev_close(local->mdev);
496
Johannes Berg4150c572007-09-17 01:29:23 -0400497 if (local->ops->stop)
498 local->ops->stop(local_to_hw(local));
499
Ivo van Doorncdcb0062008-01-07 19:45:24 +0100500 ieee80211_led_radio(local, 0);
501
Johannes Berg4150c572007-09-17 01:29:23 -0400502 tasklet_disable(&local->tx_pending_tasklet);
503 tasklet_disable(&local->tasklet);
504 }
Johannes Bergb2c258f2007-07-27 15:43:23 +0200505
506 return 0;
507}
508
Ron Rindjunskyeadc8d92008-01-28 14:07:17 +0200509int ieee80211_start_tx_ba_session(struct ieee80211_hw *hw, u8 *ra, u16 tid)
510{
511 struct ieee80211_local *local = hw_to_local(hw);
512 struct sta_info *sta;
513 struct ieee80211_sub_if_data *sdata;
514 u16 start_seq_num = 0;
515 u8 *state;
516 int ret;
517 DECLARE_MAC_BUF(mac);
518
519 if (tid >= STA_TID_NUM)
520 return -EINVAL;
521
522#ifdef CONFIG_MAC80211_HT_DEBUG
523 printk(KERN_DEBUG "Open BA session requested for %s tid %u\n",
524 print_mac(mac, ra), tid);
525#endif /* CONFIG_MAC80211_HT_DEBUG */
526
527 sta = sta_info_get(local, ra);
528 if (!sta) {
529 printk(KERN_DEBUG "Could not find the station\n");
530 return -ENOENT;
531 }
532
533 spin_lock_bh(&sta->ampdu_mlme.ampdu_tx);
534
535 /* we have tried too many times, receiver does not want A-MPDU */
536 if (sta->ampdu_mlme.tid_tx[tid].addba_req_num > HT_AGG_MAX_RETRIES) {
537 ret = -EBUSY;
538 goto start_ba_exit;
539 }
540
541 state = &sta->ampdu_mlme.tid_tx[tid].state;
542 /* check if the TID is not in aggregation flow already */
543 if (*state != HT_AGG_STATE_IDLE) {
544#ifdef CONFIG_MAC80211_HT_DEBUG
545 printk(KERN_DEBUG "BA request denied - session is not "
546 "idle on tid %u\n", tid);
547#endif /* CONFIG_MAC80211_HT_DEBUG */
548 ret = -EAGAIN;
549 goto start_ba_exit;
550 }
551
552 /* ensure that TX flow won't interrupt us
553 * until the end of the call to requeue function */
554 spin_lock_bh(&local->mdev->queue_lock);
555
556 /* create a new queue for this aggregation */
Ron Rindjunsky9e723492008-01-28 14:07:18 +0200557 ret = ieee80211_ht_agg_queue_add(local, sta, tid);
Ron Rindjunskyeadc8d92008-01-28 14:07:17 +0200558
559 /* case no queue is available to aggregation
560 * don't switch to aggregation */
561 if (ret) {
562#ifdef CONFIG_MAC80211_HT_DEBUG
563 printk(KERN_DEBUG "BA request denied - no queue available for"
564 " tid %d\n", tid);
565#endif /* CONFIG_MAC80211_HT_DEBUG */
566 spin_unlock_bh(&local->mdev->queue_lock);
567 goto start_ba_exit;
568 }
569 sdata = IEEE80211_DEV_TO_SUB_IF(sta->dev);
570
571 /* Ok, the Addba frame hasn't been sent yet, but if the driver calls the
572 * call back right away, it must see that the flow has begun */
573 *state |= HT_ADDBA_REQUESTED_MSK;
574
575 if (local->ops->ampdu_action)
576 ret = local->ops->ampdu_action(hw, IEEE80211_AMPDU_TX_START,
577 ra, tid, &start_seq_num);
578
579 if (ret) {
580 /* No need to requeue the packets in the agg queue, since we
581 * held the tx lock: no packet could be enqueued to the newly
582 * allocated queue */
Ron Rindjunsky9e723492008-01-28 14:07:18 +0200583 ieee80211_ht_agg_queue_remove(local, sta, tid, 0);
Ron Rindjunskyeadc8d92008-01-28 14:07:17 +0200584#ifdef CONFIG_MAC80211_HT_DEBUG
585 printk(KERN_DEBUG "BA request denied - HW or queue unavailable"
586 " for tid %d\n", tid);
587#endif /* CONFIG_MAC80211_HT_DEBUG */
588 spin_unlock_bh(&local->mdev->queue_lock);
589 *state = HT_AGG_STATE_IDLE;
590 goto start_ba_exit;
591 }
592
593 /* Will put all the packets in the new SW queue */
Ron Rindjunsky9e723492008-01-28 14:07:18 +0200594 ieee80211_requeue(local, ieee802_1d_to_ac[tid]);
Ron Rindjunskyeadc8d92008-01-28 14:07:17 +0200595 spin_unlock_bh(&local->mdev->queue_lock);
596
597 /* We have most probably almost emptied the legacy queue */
598 /* ieee80211_wake_queue(local_to_hw(local), ieee802_1d_to_ac[tid]); */
599
600 /* send an addBA request */
601 sta->ampdu_mlme.dialog_token_allocator++;
602 sta->ampdu_mlme.tid_tx[tid].dialog_token =
603 sta->ampdu_mlme.dialog_token_allocator;
604 sta->ampdu_mlme.tid_tx[tid].ssn = start_seq_num;
605
606 ieee80211_send_addba_request(sta->dev, ra, tid,
607 sta->ampdu_mlme.tid_tx[tid].dialog_token,
608 sta->ampdu_mlme.tid_tx[tid].ssn,
609 0x40, 5000);
610
611 /* activate the timer for the recipient's addBA response */
612 sta->ampdu_mlme.tid_tx[tid].addba_resp_timer.expires =
613 jiffies + ADDBA_RESP_INTERVAL;
614 add_timer(&sta->ampdu_mlme.tid_tx[tid].addba_resp_timer);
615 printk(KERN_DEBUG "activated addBA response timer on tid %d\n", tid);
616
617start_ba_exit:
618 spin_unlock_bh(&sta->ampdu_mlme.ampdu_tx);
619 sta_info_put(sta);
620 return ret;
621}
622EXPORT_SYMBOL(ieee80211_start_tx_ba_session);
623
624int ieee80211_stop_tx_ba_session(struct ieee80211_hw *hw,
625 u8 *ra, u16 tid,
626 enum ieee80211_back_parties initiator)
627{
628 struct ieee80211_local *local = hw_to_local(hw);
629 struct sta_info *sta;
630 u8 *state;
631 int ret = 0;
632 DECLARE_MAC_BUF(mac);
633
634 if (tid >= STA_TID_NUM)
635 return -EINVAL;
636
637#ifdef CONFIG_MAC80211_HT_DEBUG
638 printk(KERN_DEBUG "Stop a BA session requested for %s tid %u\n",
639 print_mac(mac, ra), tid);
640#endif /* CONFIG_MAC80211_HT_DEBUG */
641
642 sta = sta_info_get(local, ra);
643 if (!sta)
644 return -ENOENT;
645
646 /* check if the TID is in aggregation */
647 state = &sta->ampdu_mlme.tid_tx[tid].state;
648 spin_lock_bh(&sta->ampdu_mlme.ampdu_tx);
649
650 if (*state != HT_AGG_STATE_OPERATIONAL) {
651#ifdef CONFIG_MAC80211_HT_DEBUG
652 printk(KERN_DEBUG "Try to stop Tx aggregation on"
653 " non active TID\n");
654#endif /* CONFIG_MAC80211_HT_DEBUG */
655 ret = -ENOENT;
656 goto stop_BA_exit;
657 }
658
659 ieee80211_stop_queue(hw, sta->tid_to_tx_q[tid]);
660
661 *state = HT_AGG_STATE_REQ_STOP_BA_MSK |
662 (initiator << HT_AGG_STATE_INITIATOR_SHIFT);
663
664 if (local->ops->ampdu_action)
665 ret = local->ops->ampdu_action(hw, IEEE80211_AMPDU_TX_STOP,
666 ra, tid, NULL);
667
668 /* case HW denied going back to legacy */
669 if (ret) {
670 WARN_ON(ret != -EBUSY);
671 *state = HT_AGG_STATE_OPERATIONAL;
672 ieee80211_wake_queue(hw, sta->tid_to_tx_q[tid]);
673 goto stop_BA_exit;
674 }
675
676stop_BA_exit:
677 spin_unlock_bh(&sta->ampdu_mlme.ampdu_tx);
678 sta_info_put(sta);
679 return ret;
680}
681EXPORT_SYMBOL(ieee80211_stop_tx_ba_session);
682
683void ieee80211_start_tx_ba_cb(struct ieee80211_hw *hw, u8 *ra, u16 tid)
684{
685 struct ieee80211_local *local = hw_to_local(hw);
686 struct sta_info *sta;
687 u8 *state;
688 DECLARE_MAC_BUF(mac);
689
690 if (tid >= STA_TID_NUM) {
691 printk(KERN_DEBUG "Bad TID value: tid = %d (>= %d)\n",
692 tid, STA_TID_NUM);
693 return;
694 }
695
696 sta = sta_info_get(local, ra);
697 if (!sta) {
698 printk(KERN_DEBUG "Could not find station: %s\n",
699 print_mac(mac, ra));
700 return;
701 }
702
703 state = &sta->ampdu_mlme.tid_tx[tid].state;
704 spin_lock_bh(&sta->ampdu_mlme.ampdu_tx);
705
706 if (!(*state & HT_ADDBA_REQUESTED_MSK)) {
707 printk(KERN_DEBUG "addBA was not requested yet, state is %d\n",
708 *state);
709 spin_unlock_bh(&sta->ampdu_mlme.ampdu_tx);
710 sta_info_put(sta);
711 return;
712 }
713
714 WARN_ON_ONCE(*state & HT_ADDBA_DRV_READY_MSK);
715
716 *state |= HT_ADDBA_DRV_READY_MSK;
717
718 if (*state == HT_AGG_STATE_OPERATIONAL) {
719 printk(KERN_DEBUG "Aggregation is on for tid %d \n", tid);
720 ieee80211_wake_queue(hw, sta->tid_to_tx_q[tid]);
721 }
722 spin_unlock_bh(&sta->ampdu_mlme.ampdu_tx);
723 sta_info_put(sta);
724}
725EXPORT_SYMBOL(ieee80211_start_tx_ba_cb);
726
727void ieee80211_stop_tx_ba_cb(struct ieee80211_hw *hw, u8 *ra, u8 tid)
728{
729 struct ieee80211_local *local = hw_to_local(hw);
730 struct sta_info *sta;
731 u8 *state;
732 int agg_queue;
733 DECLARE_MAC_BUF(mac);
734
735 if (tid >= STA_TID_NUM) {
736 printk(KERN_DEBUG "Bad TID value: tid = %d (>= %d)\n",
737 tid, STA_TID_NUM);
738 return;
739 }
740
741 printk(KERN_DEBUG "Stop a BA session requested on DA %s tid %d\n",
742 print_mac(mac, ra), tid);
743
744 sta = sta_info_get(local, ra);
745 if (!sta) {
746 printk(KERN_DEBUG "Could not find station: %s\n",
747 print_mac(mac, ra));
748 return;
749 }
750 state = &sta->ampdu_mlme.tid_tx[tid].state;
751
752 spin_lock_bh(&sta->ampdu_mlme.ampdu_tx);
753 if ((*state & HT_AGG_STATE_REQ_STOP_BA_MSK) == 0) {
754 printk(KERN_DEBUG "unexpected callback to A-MPDU stop\n");
755 sta_info_put(sta);
756 spin_unlock_bh(&sta->ampdu_mlme.ampdu_tx);
757 return;
758 }
759
760 if (*state & HT_AGG_STATE_INITIATOR_MSK)
761 ieee80211_send_delba(sta->dev, ra, tid,
762 WLAN_BACK_INITIATOR, WLAN_REASON_QSTA_NOT_USE);
763
764 agg_queue = sta->tid_to_tx_q[tid];
765
766 /* avoid ordering issues: we are the only one that can modify
767 * the content of the qdiscs */
768 spin_lock_bh(&local->mdev->queue_lock);
769 /* remove the queue for this aggregation */
Ron Rindjunsky9e723492008-01-28 14:07:18 +0200770 ieee80211_ht_agg_queue_remove(local, sta, tid, 1);
Ron Rindjunskyeadc8d92008-01-28 14:07:17 +0200771 spin_unlock_bh(&local->mdev->queue_lock);
772
773 /* we just requeued the all the frames that were in the removed
774 * queue, and since we might miss a softirq we do netif_schedule.
775 * ieee80211_wake_queue is not used here as this queue is not
776 * necessarily stopped */
777 netif_schedule(local->mdev);
778 *state = HT_AGG_STATE_IDLE;
779 sta->ampdu_mlme.tid_tx[tid].addba_req_num = 0;
780 spin_unlock_bh(&sta->ampdu_mlme.ampdu_tx);
781
782 sta_info_put(sta);
783}
784EXPORT_SYMBOL(ieee80211_stop_tx_ba_cb);
785
786void ieee80211_start_tx_ba_cb_irqsafe(struct ieee80211_hw *hw,
787 const u8 *ra, u16 tid)
788{
789 struct ieee80211_local *local = hw_to_local(hw);
790 struct ieee80211_ra_tid *ra_tid;
791 struct sk_buff *skb = dev_alloc_skb(0);
792
793 if (unlikely(!skb)) {
794 if (net_ratelimit())
795 printk(KERN_WARNING "%s: Not enough memory, "
796 "dropping start BA session", skb->dev->name);
797 return;
798 }
799 ra_tid = (struct ieee80211_ra_tid *) &skb->cb;
800 memcpy(&ra_tid->ra, ra, ETH_ALEN);
801 ra_tid->tid = tid;
802
803 skb->pkt_type = IEEE80211_ADDBA_MSG;
804 skb_queue_tail(&local->skb_queue, skb);
805 tasklet_schedule(&local->tasklet);
806}
807EXPORT_SYMBOL(ieee80211_start_tx_ba_cb_irqsafe);
808
809void ieee80211_stop_tx_ba_cb_irqsafe(struct ieee80211_hw *hw,
810 const u8 *ra, u16 tid)
811{
812 struct ieee80211_local *local = hw_to_local(hw);
813 struct ieee80211_ra_tid *ra_tid;
814 struct sk_buff *skb = dev_alloc_skb(0);
815
816 if (unlikely(!skb)) {
817 if (net_ratelimit())
818 printk(KERN_WARNING "%s: Not enough memory, "
819 "dropping stop BA session", skb->dev->name);
820 return;
821 }
822 ra_tid = (struct ieee80211_ra_tid *) &skb->cb;
823 memcpy(&ra_tid->ra, ra, ETH_ALEN);
824 ra_tid->tid = tid;
825
826 skb->pkt_type = IEEE80211_DELBA_MSG;
827 skb_queue_tail(&local->skb_queue, skb);
828 tasklet_schedule(&local->tasklet);
829}
830EXPORT_SYMBOL(ieee80211_stop_tx_ba_cb_irqsafe);
831
Johannes Bergb2c258f2007-07-27 15:43:23 +0200832static void ieee80211_set_multicast_list(struct net_device *dev)
833{
834 struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr);
835 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
Johannes Berg4150c572007-09-17 01:29:23 -0400836 int allmulti, promisc, sdata_allmulti, sdata_promisc;
Johannes Bergb2c258f2007-07-27 15:43:23 +0200837
Johannes Berg4150c572007-09-17 01:29:23 -0400838 allmulti = !!(dev->flags & IFF_ALLMULTI);
839 promisc = !!(dev->flags & IFF_PROMISC);
Johannes Bergb52f2192007-11-16 01:49:11 +0100840 sdata_allmulti = !!(sdata->flags & IEEE80211_SDATA_ALLMULTI);
841 sdata_promisc = !!(sdata->flags & IEEE80211_SDATA_PROMISC);
Johannes Berg4150c572007-09-17 01:29:23 -0400842
843 if (allmulti != sdata_allmulti) {
844 if (dev->flags & IFF_ALLMULTI)
Johannes Berg53918992007-09-26 15:19:47 +0200845 atomic_inc(&local->iff_allmultis);
Johannes Berg4150c572007-09-17 01:29:23 -0400846 else
Johannes Berg53918992007-09-26 15:19:47 +0200847 atomic_dec(&local->iff_allmultis);
Jiri Slaby13262ff2007-08-28 17:01:54 -0400848 sdata->flags ^= IEEE80211_SDATA_ALLMULTI;
Johannes Bergb2c258f2007-07-27 15:43:23 +0200849 }
Johannes Berg4150c572007-09-17 01:29:23 -0400850
851 if (promisc != sdata_promisc) {
852 if (dev->flags & IFF_PROMISC)
Johannes Berg53918992007-09-26 15:19:47 +0200853 atomic_inc(&local->iff_promiscs);
Johannes Berg4150c572007-09-17 01:29:23 -0400854 else
Johannes Berg53918992007-09-26 15:19:47 +0200855 atomic_dec(&local->iff_promiscs);
Jiri Slaby13262ff2007-08-28 17:01:54 -0400856 sdata->flags ^= IEEE80211_SDATA_PROMISC;
Johannes Bergb2c258f2007-07-27 15:43:23 +0200857 }
Johannes Berg4150c572007-09-17 01:29:23 -0400858
859 dev_mc_sync(local->mdev, dev);
Johannes Bergb2c258f2007-07-27 15:43:23 +0200860}
861
Stephen Hemminger3b04ddd2007-10-09 01:40:57 -0700862static const struct header_ops ieee80211_header_ops = {
863 .create = eth_header,
864 .parse = header_parse_80211,
865 .rebuild = eth_rebuild_header,
866 .cache = eth_header_cache,
867 .cache_update = eth_header_cache_update,
868};
869
Johannes Bergf9d540e2007-09-28 14:02:09 +0200870/* Must not be called for mdev */
Johannes Bergb2c258f2007-07-27 15:43:23 +0200871void ieee80211_if_setup(struct net_device *dev)
872{
873 ether_setup(dev);
874 dev->hard_start_xmit = ieee80211_subif_start_xmit;
875 dev->wireless_handlers = &ieee80211_iw_handler_def;
876 dev->set_multicast_list = ieee80211_set_multicast_list;
877 dev->change_mtu = ieee80211_change_mtu;
Johannes Bergb2c258f2007-07-27 15:43:23 +0200878 dev->open = ieee80211_open;
879 dev->stop = ieee80211_stop;
Johannes Bergb2c258f2007-07-27 15:43:23 +0200880 dev->destructor = ieee80211_if_free;
881}
882
883/* WDS specialties */
884
885int ieee80211_if_update_wds(struct net_device *dev, u8 *remote_addr)
886{
887 struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr);
888 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
889 struct sta_info *sta;
Joe Perches0795af52007-10-03 17:59:30 -0700890 DECLARE_MAC_BUF(mac);
Johannes Bergb2c258f2007-07-27 15:43:23 +0200891
892 if (compare_ether_addr(remote_addr, sdata->u.wds.remote_addr) == 0)
893 return 0;
894
895 /* Create STA entry for the new peer */
896 sta = sta_info_add(local, dev, remote_addr, GFP_KERNEL);
Johannes Berg43ba7e92008-02-21 14:09:30 +0100897 if (IS_ERR(sta))
898 return PTR_ERR(sta);
Johannes Berg238814f2008-01-28 17:19:37 +0100899
900 sta->flags |= WLAN_STA_AUTHORIZED;
901
Johannes Bergb2c258f2007-07-27 15:43:23 +0200902 sta_info_put(sta);
903
904 /* Remove STA entry for the old peer */
905 sta = sta_info_get(local, sdata->u.wds.remote_addr);
906 if (sta) {
Michael Wube8755e2007-07-27 15:43:23 +0200907 sta_info_free(sta);
Johannes Bergb2c258f2007-07-27 15:43:23 +0200908 sta_info_put(sta);
Johannes Bergb2c258f2007-07-27 15:43:23 +0200909 } else {
910 printk(KERN_DEBUG "%s: could not find STA entry for WDS link "
Joe Perches0795af52007-10-03 17:59:30 -0700911 "peer %s\n",
912 dev->name, print_mac(mac, sdata->u.wds.remote_addr));
Johannes Bergb2c258f2007-07-27 15:43:23 +0200913 }
914
915 /* Update WDS link data */
916 memcpy(&sdata->u.wds.remote_addr, remote_addr, ETH_ALEN);
917
918 return 0;
919}
920
921/* everything else */
922
Johannes Bergb2c258f2007-07-27 15:43:23 +0200923static int __ieee80211_if_config(struct net_device *dev,
924 struct sk_buff *beacon,
925 struct ieee80211_tx_control *control)
926{
927 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
928 struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr);
929 struct ieee80211_if_conf conf;
Johannes Bergb2c258f2007-07-27 15:43:23 +0200930
931 if (!local->ops->config_interface || !netif_running(dev))
932 return 0;
933
934 memset(&conf, 0, sizeof(conf));
Johannes Berg51fb61e2007-12-19 01:31:27 +0100935 conf.type = sdata->vif.type;
936 if (sdata->vif.type == IEEE80211_IF_TYPE_STA ||
937 sdata->vif.type == IEEE80211_IF_TYPE_IBSS) {
Johannes Berg4150c572007-09-17 01:29:23 -0400938 conf.bssid = sdata->u.sta.bssid;
Johannes Bergb2c258f2007-07-27 15:43:23 +0200939 conf.ssid = sdata->u.sta.ssid;
940 conf.ssid_len = sdata->u.sta.ssid_len;
Luis Carlos Cobof7a92142008-02-23 15:17:18 +0100941#ifdef CONFIG_MAC80211_MESH
942 } else if (sdata->vif.type == IEEE80211_IF_TYPE_MESH_POINT) {
943 conf.beacon = beacon;
944 ieee80211_start_mesh(dev);
945#endif
Johannes Berg51fb61e2007-12-19 01:31:27 +0100946 } else if (sdata->vif.type == IEEE80211_IF_TYPE_AP) {
Johannes Bergb2c258f2007-07-27 15:43:23 +0200947 conf.ssid = sdata->u.ap.ssid;
948 conf.ssid_len = sdata->u.ap.ssid_len;
Johannes Bergb2c258f2007-07-27 15:43:23 +0200949 conf.beacon = beacon;
950 conf.beacon_control = control;
951 }
952 return local->ops->config_interface(local_to_hw(local),
Johannes Berg32bfd352007-12-19 01:31:26 +0100953 &sdata->vif, &conf);
Johannes Bergb2c258f2007-07-27 15:43:23 +0200954}
955
956int ieee80211_if_config(struct net_device *dev)
957{
Luis Carlos Cobof7a92142008-02-23 15:17:18 +0100958 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
959 struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr);
960 if (sdata->vif.type == IEEE80211_IF_TYPE_MESH_POINT &&
961 (local->hw.flags & IEEE80211_HW_HOST_GEN_BEACON_TEMPLATE))
962 return ieee80211_if_config_beacon(dev);
Johannes Bergb2c258f2007-07-27 15:43:23 +0200963 return __ieee80211_if_config(dev, NULL, NULL);
964}
965
966int ieee80211_if_config_beacon(struct net_device *dev)
967{
968 struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr);
969 struct ieee80211_tx_control control;
Johannes Berg32bfd352007-12-19 01:31:26 +0100970 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
Johannes Bergb2c258f2007-07-27 15:43:23 +0200971 struct sk_buff *skb;
972
973 if (!(local->hw.flags & IEEE80211_HW_HOST_GEN_BEACON_TEMPLATE))
974 return 0;
Johannes Berg32bfd352007-12-19 01:31:26 +0100975 skb = ieee80211_beacon_get(local_to_hw(local), &sdata->vif,
976 &control);
Johannes Bergb2c258f2007-07-27 15:43:23 +0200977 if (!skb)
978 return -ENOMEM;
979 return __ieee80211_if_config(dev, skb, &control);
980}
981
982int ieee80211_hw_config(struct ieee80211_local *local)
983{
Johannes Bergb2c258f2007-07-27 15:43:23 +0200984 struct ieee80211_channel *chan;
985 int ret = 0;
986
Johannes Berg8318d782008-01-24 19:38:38 +0100987 if (local->sta_sw_scanning)
Johannes Bergb2c258f2007-07-27 15:43:23 +0200988 chan = local->scan_channel;
Johannes Berg8318d782008-01-24 19:38:38 +0100989 else
Johannes Bergb2c258f2007-07-27 15:43:23 +0200990 chan = local->oper_channel;
Johannes Bergb2c258f2007-07-27 15:43:23 +0200991
Johannes Berg8318d782008-01-24 19:38:38 +0100992 local->hw.conf.channel = chan;
993
994 if (!local->hw.conf.power_level)
995 local->hw.conf.power_level = chan->max_power;
996 else
997 local->hw.conf.power_level = min(chan->max_power,
998 local->hw.conf.power_level);
999
1000 local->hw.conf.max_antenna_gain = chan->max_antenna_gain;
Johannes Bergb2c258f2007-07-27 15:43:23 +02001001
1002#ifdef CONFIG_MAC80211_VERBOSE_DEBUG
Johannes Berg8318d782008-01-24 19:38:38 +01001003 printk(KERN_DEBUG "%s: HW CONFIG: freq=%d\n",
1004 wiphy_name(local->hw.wiphy), chan->center_freq);
1005#endif
Johannes Bergb2c258f2007-07-27 15:43:23 +02001006
Michael Bueschf7c4dae2007-09-24 18:41:49 +02001007 if (local->open_count)
Johannes Bergb2c258f2007-07-27 15:43:23 +02001008 ret = local->ops->config(local_to_hw(local), &local->hw.conf);
1009
1010 return ret;
1011}
1012
Ron Rindjunskyd3c990f2007-11-26 16:14:34 +02001013/**
1014 * ieee80211_hw_config_ht should be used only after legacy configuration
1015 * has been determined, as ht configuration depends upon the hardware's
1016 * HT abilities for a _specific_ band.
1017 */
1018int ieee80211_hw_config_ht(struct ieee80211_local *local, int enable_ht,
1019 struct ieee80211_ht_info *req_ht_cap,
1020 struct ieee80211_ht_bss_info *req_bss_cap)
1021{
1022 struct ieee80211_conf *conf = &local->hw.conf;
Johannes Berg8318d782008-01-24 19:38:38 +01001023 struct ieee80211_supported_band *sband;
Ron Rindjunskyd3c990f2007-11-26 16:14:34 +02001024 int i;
1025
Johannes Berg8318d782008-01-24 19:38:38 +01001026 sband = local->hw.wiphy->bands[conf->channel->band];
1027
Ron Rindjunskyd3c990f2007-11-26 16:14:34 +02001028 /* HT is not supported */
Johannes Berg8318d782008-01-24 19:38:38 +01001029 if (!sband->ht_info.ht_supported) {
Ron Rindjunskyd3c990f2007-11-26 16:14:34 +02001030 conf->flags &= ~IEEE80211_CONF_SUPPORT_HT_MODE;
1031 return -EOPNOTSUPP;
1032 }
1033
1034 /* disable HT */
1035 if (!enable_ht) {
1036 conf->flags &= ~IEEE80211_CONF_SUPPORT_HT_MODE;
1037 } else {
1038 conf->flags |= IEEE80211_CONF_SUPPORT_HT_MODE;
Johannes Berg8318d782008-01-24 19:38:38 +01001039 conf->ht_conf.cap = req_ht_cap->cap & sband->ht_info.cap;
Ron Rindjunskyd3c990f2007-11-26 16:14:34 +02001040 conf->ht_conf.cap &= ~(IEEE80211_HT_CAP_MIMO_PS);
1041 conf->ht_conf.cap |=
Johannes Berg8318d782008-01-24 19:38:38 +01001042 sband->ht_info.cap & IEEE80211_HT_CAP_MIMO_PS;
Ron Rindjunskyd3c990f2007-11-26 16:14:34 +02001043 conf->ht_bss_conf.primary_channel =
1044 req_bss_cap->primary_channel;
1045 conf->ht_bss_conf.bss_cap = req_bss_cap->bss_cap;
1046 conf->ht_bss_conf.bss_op_mode = req_bss_cap->bss_op_mode;
1047 for (i = 0; i < SUPP_MCS_SET_LEN; i++)
1048 conf->ht_conf.supp_mcs_set[i] =
Johannes Berg8318d782008-01-24 19:38:38 +01001049 sband->ht_info.supp_mcs_set[i] &
Ron Rindjunskyd3c990f2007-11-26 16:14:34 +02001050 req_ht_cap->supp_mcs_set[i];
1051
1052 /* In STA mode, this gives us indication
1053 * to the AP's mode of operation */
1054 conf->ht_conf.ht_supported = 1;
1055 conf->ht_conf.ampdu_factor = req_ht_cap->ampdu_factor;
1056 conf->ht_conf.ampdu_density = req_ht_cap->ampdu_density;
1057 }
1058
1059 local->ops->conf_ht(local_to_hw(local), &local->hw.conf);
1060
1061 return 0;
1062}
1063
Johannes Berg471b3ef2007-12-28 14:32:58 +01001064void ieee80211_bss_info_change_notify(struct ieee80211_sub_if_data *sdata,
1065 u32 changed)
Daniel Draked9430a32007-07-27 15:43:24 +02001066{
Johannes Berg471b3ef2007-12-28 14:32:58 +01001067 struct ieee80211_local *local = sdata->local;
1068
1069 if (!changed)
1070 return;
1071
1072 if (local->ops->bss_info_changed)
1073 local->ops->bss_info_changed(local_to_hw(local),
1074 &sdata->vif,
1075 &sdata->bss_conf,
1076 changed);
Daniel Draked9430a32007-07-27 15:43:24 +02001077}
1078
1079void ieee80211_reset_erp_info(struct net_device *dev)
1080{
1081 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
1082
Johannes Berg471b3ef2007-12-28 14:32:58 +01001083 sdata->bss_conf.use_cts_prot = 0;
1084 sdata->bss_conf.use_short_preamble = 0;
1085 ieee80211_bss_info_change_notify(sdata,
1086 BSS_CHANGED_ERP_CTS_PROT |
1087 BSS_CHANGED_ERP_PREAMBLE);
Daniel Draked9430a32007-07-27 15:43:24 +02001088}
1089
Jiri Bencf0706e82007-05-05 11:45:53 -07001090void ieee80211_tx_status_irqsafe(struct ieee80211_hw *hw,
1091 struct sk_buff *skb,
1092 struct ieee80211_tx_status *status)
1093{
1094 struct ieee80211_local *local = hw_to_local(hw);
1095 struct ieee80211_tx_status *saved;
1096 int tmp;
1097
1098 skb->dev = local->mdev;
1099 saved = kmalloc(sizeof(struct ieee80211_tx_status), GFP_ATOMIC);
1100 if (unlikely(!saved)) {
1101 if (net_ratelimit())
1102 printk(KERN_WARNING "%s: Not enough memory, "
1103 "dropping tx status", skb->dev->name);
1104 /* should be dev_kfree_skb_irq, but due to this function being
1105 * named _irqsafe instead of just _irq we can't be sure that
1106 * people won't call it from non-irq contexts */
1107 dev_kfree_skb_any(skb);
1108 return;
1109 }
1110 memcpy(saved, status, sizeof(struct ieee80211_tx_status));
1111 /* copy pointer to saved status into skb->cb for use by tasklet */
1112 memcpy(skb->cb, &saved, sizeof(saved));
1113
1114 skb->pkt_type = IEEE80211_TX_STATUS_MSG;
1115 skb_queue_tail(status->control.flags & IEEE80211_TXCTL_REQ_TX_STATUS ?
1116 &local->skb_queue : &local->skb_queue_unreliable, skb);
1117 tmp = skb_queue_len(&local->skb_queue) +
1118 skb_queue_len(&local->skb_queue_unreliable);
1119 while (tmp > IEEE80211_IRQSAFE_QUEUE_LIMIT &&
1120 (skb = skb_dequeue(&local->skb_queue_unreliable))) {
1121 memcpy(&saved, skb->cb, sizeof(saved));
1122 kfree(saved);
1123 dev_kfree_skb_irq(skb);
1124 tmp--;
1125 I802_DEBUG_INC(local->tx_status_drop);
1126 }
1127 tasklet_schedule(&local->tasklet);
1128}
1129EXPORT_SYMBOL(ieee80211_tx_status_irqsafe);
1130
1131static void ieee80211_tasklet_handler(unsigned long data)
1132{
1133 struct ieee80211_local *local = (struct ieee80211_local *) data;
1134 struct sk_buff *skb;
1135 struct ieee80211_rx_status rx_status;
1136 struct ieee80211_tx_status *tx_status;
Ron Rindjunskyeadc8d92008-01-28 14:07:17 +02001137 struct ieee80211_ra_tid *ra_tid;
Jiri Bencf0706e82007-05-05 11:45:53 -07001138
1139 while ((skb = skb_dequeue(&local->skb_queue)) ||
1140 (skb = skb_dequeue(&local->skb_queue_unreliable))) {
1141 switch (skb->pkt_type) {
1142 case IEEE80211_RX_MSG:
1143 /* status is in skb->cb */
1144 memcpy(&rx_status, skb->cb, sizeof(rx_status));
Johannes Berg51fb61e2007-12-19 01:31:27 +01001145 /* Clear skb->pkt_type in order to not confuse kernel
Jiri Bencf0706e82007-05-05 11:45:53 -07001146 * netstack. */
1147 skb->pkt_type = 0;
1148 __ieee80211_rx(local_to_hw(local), skb, &rx_status);
1149 break;
1150 case IEEE80211_TX_STATUS_MSG:
1151 /* get pointer to saved status out of skb->cb */
1152 memcpy(&tx_status, skb->cb, sizeof(tx_status));
1153 skb->pkt_type = 0;
1154 ieee80211_tx_status(local_to_hw(local),
1155 skb, tx_status);
1156 kfree(tx_status);
1157 break;
Ron Rindjunskyeadc8d92008-01-28 14:07:17 +02001158 case IEEE80211_DELBA_MSG:
1159 ra_tid = (struct ieee80211_ra_tid *) &skb->cb;
1160 ieee80211_stop_tx_ba_cb(local_to_hw(local),
1161 ra_tid->ra, ra_tid->tid);
1162 dev_kfree_skb(skb);
1163 break;
1164 case IEEE80211_ADDBA_MSG:
1165 ra_tid = (struct ieee80211_ra_tid *) &skb->cb;
1166 ieee80211_start_tx_ba_cb(local_to_hw(local),
1167 ra_tid->ra, ra_tid->tid);
1168 dev_kfree_skb(skb);
1169 break ;
Jiri Bencf0706e82007-05-05 11:45:53 -07001170 default: /* should never get here! */
1171 printk(KERN_ERR "%s: Unknown message type (%d)\n",
Johannes Bergdd1cd4c2007-09-18 17:29:20 -04001172 wiphy_name(local->hw.wiphy), skb->pkt_type);
Jiri Bencf0706e82007-05-05 11:45:53 -07001173 dev_kfree_skb(skb);
1174 break;
1175 }
1176 }
1177}
1178
Jiri Bencf0706e82007-05-05 11:45:53 -07001179/* Remove added headers (e.g., QoS control), encryption header/MIC, etc. to
1180 * make a prepared TX frame (one that has been given to hw) to look like brand
1181 * new IEEE 802.11 frame that is ready to go through TX processing again.
1182 * Also, tx_packet_data in cb is restored from tx_control. */
1183static void ieee80211_remove_tx_extra(struct ieee80211_local *local,
1184 struct ieee80211_key *key,
1185 struct sk_buff *skb,
1186 struct ieee80211_tx_control *control)
1187{
1188 int hdrlen, iv_len, mic_len;
1189 struct ieee80211_tx_packet_data *pkt_data;
1190
1191 pkt_data = (struct ieee80211_tx_packet_data *)skb->cb;
Johannes Berg32bfd352007-12-19 01:31:26 +01001192 pkt_data->ifindex = vif_to_sdata(control->vif)->dev->ifindex;
Jiri Slabye8bf9642007-08-28 17:01:54 -04001193 pkt_data->flags = 0;
1194 if (control->flags & IEEE80211_TXCTL_REQ_TX_STATUS)
1195 pkt_data->flags |= IEEE80211_TXPD_REQ_TX_STATUS;
1196 if (control->flags & IEEE80211_TXCTL_DO_NOT_ENCRYPT)
1197 pkt_data->flags |= IEEE80211_TXPD_DO_NOT_ENCRYPT;
1198 if (control->flags & IEEE80211_TXCTL_REQUEUE)
1199 pkt_data->flags |= IEEE80211_TXPD_REQUEUE;
Johannes Berg678f5f712007-12-19 01:31:23 +01001200 if (control->flags & IEEE80211_TXCTL_EAPOL_FRAME)
1201 pkt_data->flags |= IEEE80211_TXPD_EAPOL_FRAME;
Jiri Bencf0706e82007-05-05 11:45:53 -07001202 pkt_data->queue = control->queue;
1203
1204 hdrlen = ieee80211_get_hdrlen_from_skb(skb);
1205
1206 if (!key)
1207 goto no_key;
1208
Johannes Berg8f20fc22007-08-28 17:01:54 -04001209 switch (key->conf.alg) {
Jiri Bencf0706e82007-05-05 11:45:53 -07001210 case ALG_WEP:
1211 iv_len = WEP_IV_LEN;
1212 mic_len = WEP_ICV_LEN;
1213 break;
1214 case ALG_TKIP:
1215 iv_len = TKIP_IV_LEN;
1216 mic_len = TKIP_ICV_LEN;
1217 break;
1218 case ALG_CCMP:
1219 iv_len = CCMP_HDR_LEN;
1220 mic_len = CCMP_MIC_LEN;
1221 break;
1222 default:
1223 goto no_key;
1224 }
1225
Johannes Berg8f20fc22007-08-28 17:01:54 -04001226 if (skb->len >= mic_len &&
Johannes Berg11a843b2007-08-28 17:01:55 -04001227 !(key->flags & KEY_FLAG_UPLOADED_TO_HARDWARE))
Jiri Bencf0706e82007-05-05 11:45:53 -07001228 skb_trim(skb, skb->len - mic_len);
1229 if (skb->len >= iv_len && skb->len > hdrlen) {
1230 memmove(skb->data + iv_len, skb->data, hdrlen);
1231 skb_pull(skb, iv_len);
1232 }
1233
1234no_key:
1235 {
1236 struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) skb->data;
1237 u16 fc = le16_to_cpu(hdr->frame_control);
1238 if ((fc & 0x8C) == 0x88) /* QoS Control Field */ {
1239 fc &= ~IEEE80211_STYPE_QOS_DATA;
1240 hdr->frame_control = cpu_to_le16(fc);
1241 memmove(skb->data + 2, skb->data, hdrlen - 2);
1242 skb_pull(skb, 2);
1243 }
1244 }
1245}
1246
Johannes Bergd46e1442008-02-20 23:59:33 +01001247static void ieee80211_handle_filtered_frame(struct ieee80211_local *local,
1248 struct sta_info *sta,
1249 struct sk_buff *skb,
1250 struct ieee80211_tx_status *status)
1251{
1252 sta->tx_filtered_count++;
1253
1254 /*
1255 * Clear the TX filter mask for this STA when sending the next
1256 * packet. If the STA went to power save mode, this will happen
1257 * happen when it wakes up for the next time.
1258 */
1259 sta->flags |= WLAN_STA_CLEAR_PS_FILT;
1260
1261 /*
1262 * This code races in the following way:
1263 *
1264 * (1) STA sends frame indicating it will go to sleep and does so
1265 * (2) hardware/firmware adds STA to filter list, passes frame up
1266 * (3) hardware/firmware processes TX fifo and suppresses a frame
1267 * (4) we get TX status before having processed the frame and
1268 * knowing that the STA has gone to sleep.
1269 *
1270 * This is actually quite unlikely even when both those events are
1271 * processed from interrupts coming in quickly after one another or
1272 * even at the same time because we queue both TX status events and
1273 * RX frames to be processed by a tasklet and process them in the
1274 * same order that they were received or TX status last. Hence, there
1275 * is no race as long as the frame RX is processed before the next TX
1276 * status, which drivers can ensure, see below.
1277 *
1278 * Note that this can only happen if the hardware or firmware can
1279 * actually add STAs to the filter list, if this is done by the
1280 * driver in response to set_tim() (which will only reduce the race
1281 * this whole filtering tries to solve, not completely solve it)
1282 * this situation cannot happen.
1283 *
1284 * To completely solve this race drivers need to make sure that they
1285 * (a) don't mix the irq-safe/not irq-safe TX status/RX processing
1286 * functions and
1287 * (b) always process RX events before TX status events if ordering
1288 * can be unknown, for example with different interrupt status
1289 * bits.
1290 */
1291 if (sta->flags & WLAN_STA_PS &&
1292 skb_queue_len(&sta->tx_filtered) < STA_MAX_TX_BUFFER) {
1293 ieee80211_remove_tx_extra(local, sta->key, skb,
1294 &status->control);
1295 skb_queue_tail(&sta->tx_filtered, skb);
1296 return;
1297 }
1298
1299 if (!(sta->flags & WLAN_STA_PS) &&
1300 !(status->control.flags & IEEE80211_TXCTL_REQUEUE)) {
1301 /* Software retry the packet once */
1302 status->control.flags |= IEEE80211_TXCTL_REQUEUE;
1303 ieee80211_remove_tx_extra(local, sta->key, skb,
1304 &status->control);
1305 dev_queue_xmit(skb);
1306 return;
1307 }
1308
1309 if (net_ratelimit())
1310 printk(KERN_DEBUG "%s: dropped TX filtered frame, "
1311 "queue_len=%d PS=%d @%lu\n",
1312 wiphy_name(local->hw.wiphy),
1313 skb_queue_len(&sta->tx_filtered),
1314 !!(sta->flags & WLAN_STA_PS), jiffies);
1315 dev_kfree_skb(skb);
1316}
1317
Jiri Bencf0706e82007-05-05 11:45:53 -07001318void ieee80211_tx_status(struct ieee80211_hw *hw, struct sk_buff *skb,
1319 struct ieee80211_tx_status *status)
1320{
1321 struct sk_buff *skb2;
1322 struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) skb->data;
1323 struct ieee80211_local *local = hw_to_local(hw);
1324 u16 frag, type;
Johannes Bergb306f452007-07-10 19:32:08 +02001325 struct ieee80211_tx_status_rtap_hdr *rthdr;
1326 struct ieee80211_sub_if_data *sdata;
Michael Wu3d30d942008-01-31 19:48:27 +01001327 struct net_device *prev_dev = NULL;
Jiri Bencf0706e82007-05-05 11:45:53 -07001328
1329 if (!status) {
1330 printk(KERN_ERR
1331 "%s: ieee80211_tx_status called with NULL status\n",
Johannes Bergdd1cd4c2007-09-18 17:29:20 -04001332 wiphy_name(local->hw.wiphy));
Jiri Bencf0706e82007-05-05 11:45:53 -07001333 dev_kfree_skb(skb);
1334 return;
1335 }
1336
1337 if (status->excessive_retries) {
1338 struct sta_info *sta;
1339 sta = sta_info_get(local, hdr->addr1);
1340 if (sta) {
1341 if (sta->flags & WLAN_STA_PS) {
Johannes Bergd46e1442008-02-20 23:59:33 +01001342 /*
1343 * The STA is in power save mode, so assume
Jiri Bencf0706e82007-05-05 11:45:53 -07001344 * that this TX packet failed because of that.
1345 */
1346 status->excessive_retries = 0;
1347 status->flags |= IEEE80211_TX_STATUS_TX_FILTERED;
Johannes Bergd46e1442008-02-20 23:59:33 +01001348 ieee80211_handle_filtered_frame(local, sta,
1349 skb, status);
1350 sta_info_put(sta);
1351 return;
Jiri Bencf0706e82007-05-05 11:45:53 -07001352 }
1353 sta_info_put(sta);
1354 }
1355 }
1356
1357 if (status->flags & IEEE80211_TX_STATUS_TX_FILTERED) {
1358 struct sta_info *sta;
1359 sta = sta_info_get(local, hdr->addr1);
1360 if (sta) {
Johannes Bergd46e1442008-02-20 23:59:33 +01001361 ieee80211_handle_filtered_frame(local, sta, skb,
1362 status);
Jiri Bencf0706e82007-05-05 11:45:53 -07001363 sta_info_put(sta);
1364 return;
1365 }
Mattias Nissler1abbe492007-12-20 13:50:07 +01001366 } else
1367 rate_control_tx_status(local->mdev, skb, status);
Jiri Bencf0706e82007-05-05 11:45:53 -07001368
1369 ieee80211_led_tx(local, 0);
1370
1371 /* SNMP counters
1372 * Fragments are passed to low-level drivers as separate skbs, so these
1373 * are actually fragments, not frames. Update frame counters only for
1374 * the first fragment of the frame. */
1375
1376 frag = le16_to_cpu(hdr->seq_ctrl) & IEEE80211_SCTL_FRAG;
1377 type = le16_to_cpu(hdr->frame_control) & IEEE80211_FCTL_FTYPE;
1378
1379 if (status->flags & IEEE80211_TX_STATUS_ACK) {
1380 if (frag == 0) {
1381 local->dot11TransmittedFrameCount++;
1382 if (is_multicast_ether_addr(hdr->addr1))
1383 local->dot11MulticastTransmittedFrameCount++;
1384 if (status->retry_count > 0)
1385 local->dot11RetryCount++;
1386 if (status->retry_count > 1)
1387 local->dot11MultipleRetryCount++;
1388 }
1389
1390 /* This counter shall be incremented for an acknowledged MPDU
1391 * with an individual address in the address 1 field or an MPDU
1392 * with a multicast address in the address 1 field of type Data
1393 * or Management. */
1394 if (!is_multicast_ether_addr(hdr->addr1) ||
1395 type == IEEE80211_FTYPE_DATA ||
1396 type == IEEE80211_FTYPE_MGMT)
1397 local->dot11TransmittedFragmentCount++;
1398 } else {
1399 if (frag == 0)
1400 local->dot11FailedCount++;
1401 }
1402
Johannes Bergb306f452007-07-10 19:32:08 +02001403 /* this was a transmitted frame, but now we want to reuse it */
1404 skb_orphan(skb);
1405
Michael Wu3d30d942008-01-31 19:48:27 +01001406 /*
1407 * This is a bit racy but we can avoid a lot of work
1408 * with this test...
1409 */
1410 if (!local->monitors && !local->cooked_mntrs) {
Jiri Bencf0706e82007-05-05 11:45:53 -07001411 dev_kfree_skb(skb);
1412 return;
1413 }
Jiri Bencf0706e82007-05-05 11:45:53 -07001414
Johannes Bergb306f452007-07-10 19:32:08 +02001415 /* send frame to monitor interfaces now */
1416
1417 if (skb_headroom(skb) < sizeof(*rthdr)) {
1418 printk(KERN_ERR "ieee80211_tx_status: headroom too small\n");
1419 dev_kfree_skb(skb);
1420 return;
1421 }
1422
1423 rthdr = (struct ieee80211_tx_status_rtap_hdr*)
1424 skb_push(skb, sizeof(*rthdr));
1425
1426 memset(rthdr, 0, sizeof(*rthdr));
1427 rthdr->hdr.it_len = cpu_to_le16(sizeof(*rthdr));
1428 rthdr->hdr.it_present =
1429 cpu_to_le32((1 << IEEE80211_RADIOTAP_TX_FLAGS) |
1430 (1 << IEEE80211_RADIOTAP_DATA_RETRIES));
1431
1432 if (!(status->flags & IEEE80211_TX_STATUS_ACK) &&
1433 !is_multicast_ether_addr(hdr->addr1))
1434 rthdr->tx_flags |= cpu_to_le16(IEEE80211_RADIOTAP_F_TX_FAIL);
1435
1436 if ((status->control.flags & IEEE80211_TXCTL_USE_RTS_CTS) &&
1437 (status->control.flags & IEEE80211_TXCTL_USE_CTS_PROTECT))
1438 rthdr->tx_flags |= cpu_to_le16(IEEE80211_RADIOTAP_F_TX_CTS);
1439 else if (status->control.flags & IEEE80211_TXCTL_USE_RTS_CTS)
1440 rthdr->tx_flags |= cpu_to_le16(IEEE80211_RADIOTAP_F_TX_RTS);
1441
1442 rthdr->data_retries = status->retry_count;
1443
Michael Wu3d30d942008-01-31 19:48:27 +01001444 /* XXX: is this sufficient for BPF? */
1445 skb_set_mac_header(skb, 0);
1446 skb->ip_summed = CHECKSUM_UNNECESSARY;
1447 skb->pkt_type = PACKET_OTHERHOST;
1448 skb->protocol = htons(ETH_P_802_2);
1449 memset(skb->cb, 0, sizeof(skb->cb));
Johannes Bergb306f452007-07-10 19:32:08 +02001450
Michael Wu3d30d942008-01-31 19:48:27 +01001451 rcu_read_lock();
1452 list_for_each_entry_rcu(sdata, &local->interfaces, list) {
Johannes Berg51fb61e2007-12-19 01:31:27 +01001453 if (sdata->vif.type == IEEE80211_IF_TYPE_MNTR) {
Johannes Bergb306f452007-07-10 19:32:08 +02001454 if (!netif_running(sdata->dev))
1455 continue;
Michael Wu3d30d942008-01-31 19:48:27 +01001456
1457 if (prev_dev) {
Johannes Berg79010422007-09-18 17:29:21 -04001458 skb2 = skb_clone(skb, GFP_ATOMIC);
Michael Wu3d30d942008-01-31 19:48:27 +01001459 if (skb2) {
1460 skb2->dev = prev_dev;
1461 netif_rx(skb2);
1462 }
1463 }
1464
1465 prev_dev = sdata->dev;
Johannes Bergb306f452007-07-10 19:32:08 +02001466 }
1467 }
Michael Wu3d30d942008-01-31 19:48:27 +01001468 if (prev_dev) {
1469 skb->dev = prev_dev;
1470 netif_rx(skb);
1471 skb = NULL;
1472 }
Johannes Berg79010422007-09-18 17:29:21 -04001473 rcu_read_unlock();
Michael Wu3d30d942008-01-31 19:48:27 +01001474 dev_kfree_skb(skb);
Jiri Bencf0706e82007-05-05 11:45:53 -07001475}
1476EXPORT_SYMBOL(ieee80211_tx_status);
1477
Jiri Bencf0706e82007-05-05 11:45:53 -07001478struct ieee80211_hw *ieee80211_alloc_hw(size_t priv_data_len,
1479 const struct ieee80211_ops *ops)
1480{
Jiri Bencf0706e82007-05-05 11:45:53 -07001481 struct ieee80211_local *local;
Jiri Bencf0706e82007-05-05 11:45:53 -07001482 int priv_size;
1483 struct wiphy *wiphy;
1484
1485 /* Ensure 32-byte alignment of our private data and hw private data.
1486 * We use the wiphy priv data for both our ieee80211_local and for
1487 * the driver's private data
1488 *
1489 * In memory it'll be like this:
1490 *
1491 * +-------------------------+
1492 * | struct wiphy |
1493 * +-------------------------+
1494 * | struct ieee80211_local |
1495 * +-------------------------+
1496 * | driver's private data |
1497 * +-------------------------+
1498 *
1499 */
1500 priv_size = ((sizeof(struct ieee80211_local) +
1501 NETDEV_ALIGN_CONST) & ~NETDEV_ALIGN_CONST) +
1502 priv_data_len;
1503
1504 wiphy = wiphy_new(&mac80211_config_ops, priv_size);
1505
1506 if (!wiphy)
1507 return NULL;
1508
1509 wiphy->privid = mac80211_wiphy_privid;
1510
1511 local = wiphy_priv(wiphy);
1512 local->hw.wiphy = wiphy;
1513
1514 local->hw.priv = (char *)local +
1515 ((sizeof(struct ieee80211_local) +
1516 NETDEV_ALIGN_CONST) & ~NETDEV_ALIGN_CONST);
1517
Johannes Berg4480f15c2007-07-10 19:32:10 +02001518 BUG_ON(!ops->tx);
Johannes Berg4150c572007-09-17 01:29:23 -04001519 BUG_ON(!ops->start);
1520 BUG_ON(!ops->stop);
Johannes Berg4480f15c2007-07-10 19:32:10 +02001521 BUG_ON(!ops->config);
1522 BUG_ON(!ops->add_interface);
Johannes Berg4150c572007-09-17 01:29:23 -04001523 BUG_ON(!ops->remove_interface);
1524 BUG_ON(!ops->configure_filter);
Jiri Bencf0706e82007-05-05 11:45:53 -07001525 local->ops = ops;
1526
Jiri Bencf0706e82007-05-05 11:45:53 -07001527 local->hw.queues = 1; /* default */
1528
Jiri Bencf0706e82007-05-05 11:45:53 -07001529 local->bridge_packets = 1;
1530
1531 local->rts_threshold = IEEE80211_MAX_RTS_THRESHOLD;
1532 local->fragmentation_threshold = IEEE80211_MAX_FRAG_THRESHOLD;
1533 local->short_retry_limit = 7;
1534 local->long_retry_limit = 4;
1535 local->hw.conf.radio_enabled = 1;
Jiri Bencf0706e82007-05-05 11:45:53 -07001536
Johannes Berg79010422007-09-18 17:29:21 -04001537 INIT_LIST_HEAD(&local->interfaces);
Jiri Bencf0706e82007-05-05 11:45:53 -07001538
1539 INIT_DELAYED_WORK(&local->scan_work, ieee80211_sta_scan_work);
Jiri Bencf0706e82007-05-05 11:45:53 -07001540
1541 sta_info_init(local);
1542
Jiri Bencf0706e82007-05-05 11:45:53 -07001543 tasklet_init(&local->tx_pending_tasklet, ieee80211_tx_pending,
1544 (unsigned long)local);
1545 tasklet_disable(&local->tx_pending_tasklet);
1546
1547 tasklet_init(&local->tasklet,
1548 ieee80211_tasklet_handler,
1549 (unsigned long) local);
1550 tasklet_disable(&local->tasklet);
1551
1552 skb_queue_head_init(&local->skb_queue);
1553 skb_queue_head_init(&local->skb_queue_unreliable);
1554
1555 return local_to_hw(local);
1556}
1557EXPORT_SYMBOL(ieee80211_alloc_hw);
1558
1559int ieee80211_register_hw(struct ieee80211_hw *hw)
1560{
1561 struct ieee80211_local *local = hw_to_local(hw);
1562 const char *name;
1563 int result;
Johannes Berg8318d782008-01-24 19:38:38 +01001564 enum ieee80211_band band;
Johannes Berg96d51052008-02-08 09:48:13 +01001565 struct net_device *mdev;
1566 struct ieee80211_sub_if_data *sdata;
Johannes Berg8318d782008-01-24 19:38:38 +01001567
1568 /*
1569 * generic code guarantees at least one band,
1570 * set this very early because much code assumes
1571 * that hw.conf.channel is assigned
1572 */
1573 for (band = 0; band < IEEE80211_NUM_BANDS; band++) {
1574 struct ieee80211_supported_band *sband;
1575
1576 sband = local->hw.wiphy->bands[band];
1577 if (sband) {
1578 /* init channel we're on */
1579 local->hw.conf.channel =
1580 local->oper_channel =
1581 local->scan_channel = &sband->channels[0];
1582 break;
1583 }
1584 }
Jiri Bencf0706e82007-05-05 11:45:53 -07001585
1586 result = wiphy_register(local->hw.wiphy);
1587 if (result < 0)
1588 return result;
1589
Johannes Berg96d51052008-02-08 09:48:13 +01001590 /* for now, mdev needs sub_if_data :/ */
1591 mdev = alloc_netdev(sizeof(struct ieee80211_sub_if_data),
1592 "wmaster%d", ether_setup);
1593 if (!mdev)
1594 goto fail_mdev_alloc;
1595
1596 sdata = IEEE80211_DEV_TO_SUB_IF(mdev);
1597 mdev->ieee80211_ptr = &sdata->wdev;
1598 sdata->wdev.wiphy = local->hw.wiphy;
1599
1600 local->mdev = mdev;
1601
1602 ieee80211_rx_bss_list_init(mdev);
1603
1604 mdev->hard_start_xmit = ieee80211_master_start_xmit;
1605 mdev->open = ieee80211_master_open;
1606 mdev->stop = ieee80211_master_stop;
1607 mdev->type = ARPHRD_IEEE80211;
1608 mdev->header_ops = &ieee80211_header_ops;
1609 mdev->set_multicast_list = ieee80211_master_set_multicast_list;
1610
1611 sdata->vif.type = IEEE80211_IF_TYPE_AP;
1612 sdata->dev = mdev;
1613 sdata->local = local;
1614 sdata->u.ap.force_unicast_rateidx = -1;
1615 sdata->u.ap.max_ratectrl_rateidx = -1;
1616 ieee80211_if_sdata_init(sdata);
1617
1618 /* no RCU needed since we're still during init phase */
1619 list_add_tail(&sdata->list, &local->interfaces);
1620
Jiri Bencf0706e82007-05-05 11:45:53 -07001621 name = wiphy_dev(local->hw.wiphy)->driver->name;
1622 local->hw.workqueue = create_singlethread_workqueue(name);
1623 if (!local->hw.workqueue) {
1624 result = -ENOMEM;
1625 goto fail_workqueue;
1626 }
1627
Johannes Bergb306f452007-07-10 19:32:08 +02001628 /*
1629 * The hardware needs headroom for sending the frame,
1630 * and we need some headroom for passing the frame to monitor
1631 * interfaces, but never both at the same time.
1632 */
Jiri Benc33ccad32007-07-18 17:10:44 +02001633 local->tx_headroom = max_t(unsigned int , local->hw.extra_tx_headroom,
1634 sizeof(struct ieee80211_tx_status_rtap_hdr));
Johannes Bergb306f452007-07-10 19:32:08 +02001635
Jiri Bence9f207f2007-05-05 11:46:38 -07001636 debugfs_hw_add(local);
1637
Jiri Bencf0706e82007-05-05 11:45:53 -07001638 local->hw.conf.beacon_int = 1000;
1639
1640 local->wstats_flags |= local->hw.max_rssi ?
1641 IW_QUAL_LEVEL_UPDATED : IW_QUAL_LEVEL_INVALID;
1642 local->wstats_flags |= local->hw.max_signal ?
1643 IW_QUAL_QUAL_UPDATED : IW_QUAL_QUAL_INVALID;
1644 local->wstats_flags |= local->hw.max_noise ?
1645 IW_QUAL_NOISE_UPDATED : IW_QUAL_NOISE_INVALID;
1646 if (local->hw.max_rssi < 0 || local->hw.max_noise < 0)
1647 local->wstats_flags |= IW_QUAL_DBM;
1648
1649 result = sta_info_start(local);
1650 if (result < 0)
1651 goto fail_sta_info;
1652
1653 rtnl_lock();
1654 result = dev_alloc_name(local->mdev, local->mdev->name);
1655 if (result < 0)
1656 goto fail_dev;
1657
1658 memcpy(local->mdev->dev_addr, local->hw.wiphy->perm_addr, ETH_ALEN);
1659 SET_NETDEV_DEV(local->mdev, wiphy_dev(local->hw.wiphy));
1660
1661 result = register_netdevice(local->mdev);
1662 if (result < 0)
1663 goto fail_dev;
1664
Jiri Bence9f207f2007-05-05 11:46:38 -07001665 ieee80211_debugfs_add_netdev(IEEE80211_DEV_TO_SUB_IF(local->mdev));
Johannes Berg5b2812e2007-09-26 14:27:23 +02001666 ieee80211_if_set_type(local->mdev, IEEE80211_IF_TYPE_AP);
Jiri Bence9f207f2007-05-05 11:46:38 -07001667
Johannes Berg830f9032007-10-28 14:51:05 +01001668 result = ieee80211_init_rate_ctrl_alg(local,
1669 hw->rate_control_algorithm);
Jiri Bencf0706e82007-05-05 11:45:53 -07001670 if (result < 0) {
1671 printk(KERN_DEBUG "%s: Failed to initialize rate control "
Johannes Bergdd1cd4c2007-09-18 17:29:20 -04001672 "algorithm\n", wiphy_name(local->hw.wiphy));
Jiri Bencf0706e82007-05-05 11:45:53 -07001673 goto fail_rate;
1674 }
1675
1676 result = ieee80211_wep_init(local);
1677
1678 if (result < 0) {
1679 printk(KERN_DEBUG "%s: Failed to initialize wep\n",
Johannes Bergdd1cd4c2007-09-18 17:29:20 -04001680 wiphy_name(local->hw.wiphy));
Jiri Bencf0706e82007-05-05 11:45:53 -07001681 goto fail_wep;
1682 }
1683
1684 ieee80211_install_qdisc(local->mdev);
1685
1686 /* add one default STA interface */
1687 result = ieee80211_if_add(local->mdev, "wlan%d", NULL,
Luis Carlos Coboee385852008-02-23 15:17:11 +01001688 IEEE80211_IF_TYPE_STA, NULL);
Jiri Bencf0706e82007-05-05 11:45:53 -07001689 if (result)
1690 printk(KERN_WARNING "%s: Failed to add default virtual iface\n",
Johannes Bergdd1cd4c2007-09-18 17:29:20 -04001691 wiphy_name(local->hw.wiphy));
Jiri Bencf0706e82007-05-05 11:45:53 -07001692
1693 local->reg_state = IEEE80211_DEV_REGISTERED;
1694 rtnl_unlock();
1695
1696 ieee80211_led_init(local);
1697
1698 return 0;
1699
1700fail_wep:
1701 rate_control_deinitialize(local);
1702fail_rate:
Jiri Bence9f207f2007-05-05 11:46:38 -07001703 ieee80211_debugfs_remove_netdev(IEEE80211_DEV_TO_SUB_IF(local->mdev));
Jiri Bencf0706e82007-05-05 11:45:53 -07001704 unregister_netdevice(local->mdev);
1705fail_dev:
1706 rtnl_unlock();
1707 sta_info_stop(local);
1708fail_sta_info:
Jiri Bence9f207f2007-05-05 11:46:38 -07001709 debugfs_hw_del(local);
Jiri Bencf0706e82007-05-05 11:45:53 -07001710 destroy_workqueue(local->hw.workqueue);
1711fail_workqueue:
Johannes Berg96d51052008-02-08 09:48:13 +01001712 ieee80211_if_free(local->mdev);
1713 local->mdev = NULL;
1714fail_mdev_alloc:
Jiri Bencf0706e82007-05-05 11:45:53 -07001715 wiphy_unregister(local->hw.wiphy);
1716 return result;
1717}
1718EXPORT_SYMBOL(ieee80211_register_hw);
1719
Jiri Bencf0706e82007-05-05 11:45:53 -07001720void ieee80211_unregister_hw(struct ieee80211_hw *hw)
1721{
1722 struct ieee80211_local *local = hw_to_local(hw);
1723 struct ieee80211_sub_if_data *sdata, *tmp;
Jiri Bencf0706e82007-05-05 11:45:53 -07001724
1725 tasklet_kill(&local->tx_pending_tasklet);
1726 tasklet_kill(&local->tasklet);
1727
1728 rtnl_lock();
1729
1730 BUG_ON(local->reg_state != IEEE80211_DEV_REGISTERED);
1731
1732 local->reg_state = IEEE80211_DEV_UNREGISTERED;
Jiri Bencf0706e82007-05-05 11:45:53 -07001733
Johannes Berg79010422007-09-18 17:29:21 -04001734 /*
1735 * At this point, interface list manipulations are fine
1736 * because the driver cannot be handing us frames any
1737 * more and the tasklet is killed.
1738 */
Johannes Berg5b2812e2007-09-26 14:27:23 +02001739
1740 /*
1741 * First, we remove all non-master interfaces. Do this because they
1742 * may have bss pointer dependency on the master, and when we free
1743 * the master these would be freed as well, breaking our list
1744 * iteration completely.
1745 */
1746 list_for_each_entry_safe(sdata, tmp, &local->interfaces, list) {
1747 if (sdata->dev == local->mdev)
1748 continue;
1749 list_del(&sdata->list);
Jiri Bencf0706e82007-05-05 11:45:53 -07001750 __ieee80211_if_del(local, sdata);
Johannes Berg5b2812e2007-09-26 14:27:23 +02001751 }
1752
1753 /* then, finally, remove the master interface */
1754 __ieee80211_if_del(local, IEEE80211_DEV_TO_SUB_IF(local->mdev));
Jiri Bencf0706e82007-05-05 11:45:53 -07001755
1756 rtnl_unlock();
1757
Jiri Bencf0706e82007-05-05 11:45:53 -07001758 ieee80211_rx_bss_list_deinit(local->mdev);
1759 ieee80211_clear_tx_pending(local);
1760 sta_info_stop(local);
1761 rate_control_deinitialize(local);
Jiri Bence9f207f2007-05-05 11:46:38 -07001762 debugfs_hw_del(local);
Jiri Bencf0706e82007-05-05 11:45:53 -07001763
Jiri Bencf0706e82007-05-05 11:45:53 -07001764 if (skb_queue_len(&local->skb_queue)
1765 || skb_queue_len(&local->skb_queue_unreliable))
1766 printk(KERN_WARNING "%s: skb_queue not empty\n",
Johannes Bergdd1cd4c2007-09-18 17:29:20 -04001767 wiphy_name(local->hw.wiphy));
Jiri Bencf0706e82007-05-05 11:45:53 -07001768 skb_queue_purge(&local->skb_queue);
1769 skb_queue_purge(&local->skb_queue_unreliable);
1770
1771 destroy_workqueue(local->hw.workqueue);
1772 wiphy_unregister(local->hw.wiphy);
1773 ieee80211_wep_free(local);
1774 ieee80211_led_exit(local);
Johannes Berg96d51052008-02-08 09:48:13 +01001775 ieee80211_if_free(local->mdev);
1776 local->mdev = NULL;
Jiri Bencf0706e82007-05-05 11:45:53 -07001777}
1778EXPORT_SYMBOL(ieee80211_unregister_hw);
1779
1780void ieee80211_free_hw(struct ieee80211_hw *hw)
1781{
1782 struct ieee80211_local *local = hw_to_local(hw);
1783
Jiri Bencf0706e82007-05-05 11:45:53 -07001784 wiphy_free(local->hw.wiphy);
1785}
1786EXPORT_SYMBOL(ieee80211_free_hw);
1787
Jiri Bencf0706e82007-05-05 11:45:53 -07001788static int __init ieee80211_init(void)
1789{
1790 struct sk_buff *skb;
1791 int ret;
1792
1793 BUILD_BUG_ON(sizeof(struct ieee80211_tx_packet_data) > sizeof(skb->cb));
1794
Johannes Berg4b475892008-01-02 15:17:03 +01001795 ret = rc80211_simple_init();
Johannes Bergac71c692007-10-28 14:17:44 +01001796 if (ret)
Johannes Berg3eadf5f2008-01-31 19:33:53 +01001797 goto out;
Mattias Nisslerad018372007-12-19 01:25:57 +01001798
Johannes Berg4b475892008-01-02 15:17:03 +01001799 ret = rc80211_pid_init();
Mattias Nisslerad018372007-12-19 01:25:57 +01001800 if (ret)
Johannes Berg3eadf5f2008-01-31 19:33:53 +01001801 goto out_cleanup_simple;
Johannes Bergac71c692007-10-28 14:17:44 +01001802
Jiri Bencf0706e82007-05-05 11:45:53 -07001803 ret = ieee80211_wme_register();
1804 if (ret) {
1805 printk(KERN_DEBUG "ieee80211_init: failed to "
1806 "initialize WME (err=%d)\n", ret);
Johannes Berg3eadf5f2008-01-31 19:33:53 +01001807 goto out_cleanup_pid;
Jiri Bencf0706e82007-05-05 11:45:53 -07001808 }
1809
Jiri Bence9f207f2007-05-05 11:46:38 -07001810 ieee80211_debugfs_netdev_init();
1811
Jiri Bencf0706e82007-05-05 11:45:53 -07001812 return 0;
Mattias Nisslerad018372007-12-19 01:25:57 +01001813
Johannes Berg3eadf5f2008-01-31 19:33:53 +01001814 out_cleanup_pid:
Johannes Berg4b475892008-01-02 15:17:03 +01001815 rc80211_pid_exit();
Johannes Berg3eadf5f2008-01-31 19:33:53 +01001816 out_cleanup_simple:
1817 rc80211_simple_exit();
1818 out:
Mattias Nisslerad018372007-12-19 01:25:57 +01001819 return ret;
Jiri Bencf0706e82007-05-05 11:45:53 -07001820}
1821
Jiri Bencf0706e82007-05-05 11:45:53 -07001822static void __exit ieee80211_exit(void)
1823{
Johannes Berg4b475892008-01-02 15:17:03 +01001824 rc80211_simple_exit();
1825 rc80211_pid_exit();
Johannes Bergac71c692007-10-28 14:17:44 +01001826
Luis Carlos Cobof7a92142008-02-23 15:17:18 +01001827#ifdef CONFIG_MAC80211_MESH
1828 if (mesh_allocated)
1829 ieee80211s_stop();
1830#endif
Jiri Bencf0706e82007-05-05 11:45:53 -07001831 ieee80211_wme_unregister();
Jiri Bence9f207f2007-05-05 11:46:38 -07001832 ieee80211_debugfs_netdev_exit();
Jiri Bencf0706e82007-05-05 11:45:53 -07001833}
1834
1835
Johannes Bergca9938f2007-09-11 12:50:32 +02001836subsys_initcall(ieee80211_init);
Jiri Bencf0706e82007-05-05 11:45:53 -07001837module_exit(ieee80211_exit);
1838
1839MODULE_DESCRIPTION("IEEE 802.11 subsystem");
1840MODULE_LICENSE("GPL");