blob: 8e586390a2efd4d17cb12a4bd0cbe46be2ee00ce [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"
29#include "wep.h"
Jiri Bencf0706e82007-05-05 11:45:53 -070030#include "wme.h"
31#include "aes_ccm.h"
32#include "ieee80211_led.h"
Michael Wue0eb6852007-09-18 17:29:21 -040033#include "cfg.h"
Jiri Bence9f207f2007-05-05 11:46:38 -070034#include "debugfs.h"
35#include "debugfs_netdev.h"
Jiri Bencf0706e82007-05-05 11:45:53 -070036
Ron Rindjunskyd3c990f2007-11-26 16:14:34 +020037#define SUPP_MCS_SET_LEN 16
38
Johannes Bergb306f452007-07-10 19:32:08 +020039/*
40 * For seeing transmitted packets on monitor interfaces
41 * we have a radiotap header too.
42 */
43struct ieee80211_tx_status_rtap_hdr {
44 struct ieee80211_radiotap_header hdr;
45 __le16 tx_flags;
46 u8 data_retries;
47} __attribute__ ((packed));
48
Johannes Bergb2c258f2007-07-27 15:43:23 +020049/* common interface routines */
Jiri Bencf0706e82007-05-05 11:45:53 -070050
Stephen Hemmingerb95cce32007-09-26 22:13:38 -070051static int header_parse_80211(const struct sk_buff *skb, unsigned char *haddr)
Jiri Bencf0706e82007-05-05 11:45:53 -070052{
Johannes Bergb2c258f2007-07-27 15:43:23 +020053 memcpy(haddr, skb_mac_header(skb) + 10, ETH_ALEN); /* addr2 */
54 return ETH_ALEN;
Jiri Bencf0706e82007-05-05 11:45:53 -070055}
56
Johannes Berg4150c572007-09-17 01:29:23 -040057/* must be called under mdev tx lock */
58static void ieee80211_configure_filter(struct ieee80211_local *local)
59{
60 unsigned int changed_flags;
61 unsigned int new_flags = 0;
62
Johannes Berg53918992007-09-26 15:19:47 +020063 if (atomic_read(&local->iff_promiscs))
Johannes Berg4150c572007-09-17 01:29:23 -040064 new_flags |= FIF_PROMISC_IN_BSS;
65
Johannes Berg53918992007-09-26 15:19:47 +020066 if (atomic_read(&local->iff_allmultis))
Johannes Berg4150c572007-09-17 01:29:23 -040067 new_flags |= FIF_ALLMULTI;
68
69 if (local->monitors)
70 new_flags |= FIF_CONTROL |
71 FIF_OTHER_BSS |
72 FIF_BCN_PRBRESP_PROMISC;
73
74 changed_flags = local->filter_flags ^ new_flags;
75
76 /* be a bit nasty */
77 new_flags |= (1<<31);
78
79 local->ops->configure_filter(local_to_hw(local),
80 changed_flags, &new_flags,
81 local->mdev->mc_count,
82 local->mdev->mc_list);
83
84 WARN_ON(new_flags & (1<<31));
85
86 local->filter_flags = new_flags & ~(1<<31);
87}
88
Johannes Bergb2c258f2007-07-27 15:43:23 +020089/* master interface */
Jiri Bencf0706e82007-05-05 11:45:53 -070090
91static int ieee80211_master_open(struct net_device *dev)
92{
93 struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr);
94 struct ieee80211_sub_if_data *sdata;
95 int res = -EOPNOTSUPP;
96
Johannes Berg79010422007-09-18 17:29:21 -040097 /* we hold the RTNL here so can safely walk the list */
98 list_for_each_entry(sdata, &local->interfaces, list) {
Jiri Bencf0706e82007-05-05 11:45:53 -070099 if (sdata->dev != dev && netif_running(sdata->dev)) {
100 res = 0;
101 break;
102 }
103 }
Jiri Bencf0706e82007-05-05 11:45:53 -0700104 return res;
105}
106
107static int ieee80211_master_stop(struct net_device *dev)
108{
109 struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr);
110 struct ieee80211_sub_if_data *sdata;
111
Johannes Berg79010422007-09-18 17:29:21 -0400112 /* we hold the RTNL here so can safely walk the list */
113 list_for_each_entry(sdata, &local->interfaces, list)
Jiri Bencf0706e82007-05-05 11:45:53 -0700114 if (sdata->dev != dev && netif_running(sdata->dev))
115 dev_close(sdata->dev);
Jiri Bencf0706e82007-05-05 11:45:53 -0700116
117 return 0;
118}
119
Johannes Berg4150c572007-09-17 01:29:23 -0400120static void ieee80211_master_set_multicast_list(struct net_device *dev)
121{
122 struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr);
123
124 ieee80211_configure_filter(local);
125}
126
Johannes Bergb2c258f2007-07-27 15:43:23 +0200127/* regular interfaces */
128
129static int ieee80211_change_mtu(struct net_device *dev, int new_mtu)
130{
131 /* FIX: what would be proper limits for MTU?
132 * This interface uses 802.3 frames. */
133 if (new_mtu < 256 || new_mtu > IEEE80211_MAX_DATA_LEN - 24 - 6) {
134 printk(KERN_WARNING "%s: invalid MTU %d\n",
135 dev->name, new_mtu);
136 return -EINVAL;
137 }
138
139#ifdef CONFIG_MAC80211_VERBOSE_DEBUG
140 printk(KERN_DEBUG "%s: setting MTU %d\n", dev->name, new_mtu);
141#endif /* CONFIG_MAC80211_VERBOSE_DEBUG */
142 dev->mtu = new_mtu;
143 return 0;
144}
145
146static inline int identical_mac_addr_allowed(int type1, int type2)
147{
148 return (type1 == IEEE80211_IF_TYPE_MNTR ||
149 type2 == IEEE80211_IF_TYPE_MNTR ||
150 (type1 == IEEE80211_IF_TYPE_AP &&
151 type2 == IEEE80211_IF_TYPE_WDS) ||
152 (type1 == IEEE80211_IF_TYPE_WDS &&
153 (type2 == IEEE80211_IF_TYPE_WDS ||
154 type2 == IEEE80211_IF_TYPE_AP)) ||
155 (type1 == IEEE80211_IF_TYPE_AP &&
156 type2 == IEEE80211_IF_TYPE_VLAN) ||
157 (type1 == IEEE80211_IF_TYPE_VLAN &&
158 (type2 == IEEE80211_IF_TYPE_AP ||
159 type2 == IEEE80211_IF_TYPE_VLAN)));
160}
161
Johannes Bergb2c258f2007-07-27 15:43:23 +0200162static int ieee80211_open(struct net_device *dev)
163{
164 struct ieee80211_sub_if_data *sdata, *nsdata;
165 struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr);
166 struct ieee80211_if_init_conf conf;
167 int res;
Michael Bueschceffefd2008-02-10 14:16:52 +0100168 bool need_hw_reconfig = 0;
Johannes Bergb2c258f2007-07-27 15:43:23 +0200169
170 sdata = IEEE80211_DEV_TO_SUB_IF(dev);
Johannes Berg0ec3ca42007-09-17 01:29:24 -0400171
Johannes Berg79010422007-09-18 17:29:21 -0400172 /* we hold the RTNL here so can safely walk the list */
173 list_for_each_entry(nsdata, &local->interfaces, list) {
Johannes Bergb2c258f2007-07-27 15:43:23 +0200174 struct net_device *ndev = nsdata->dev;
175
176 if (ndev != dev && ndev != local->mdev && netif_running(ndev) &&
Johannes Berg0ec3ca42007-09-17 01:29:24 -0400177 compare_ether_addr(dev->dev_addr, ndev->dev_addr) == 0) {
178 /*
179 * check whether it may have the same address
180 */
Johannes Berg51fb61e2007-12-19 01:31:27 +0100181 if (!identical_mac_addr_allowed(sdata->vif.type,
182 nsdata->vif.type))
Johannes Berg0ec3ca42007-09-17 01:29:24 -0400183 return -ENOTUNIQ;
Johannes Berg0ec3ca42007-09-17 01:29:24 -0400184
185 /*
186 * can only add VLANs to enabled APs
187 */
Johannes Berg51fb61e2007-12-19 01:31:27 +0100188 if (sdata->vif.type == IEEE80211_IF_TYPE_VLAN &&
189 nsdata->vif.type == IEEE80211_IF_TYPE_AP &&
Johannes Berg0ec3ca42007-09-17 01:29:24 -0400190 netif_running(nsdata->dev))
191 sdata->u.vlan.ap = nsdata;
Johannes Bergb2c258f2007-07-27 15:43:23 +0200192 }
193 }
Johannes Bergb2c258f2007-07-27 15:43:23 +0200194
Johannes Berg51fb61e2007-12-19 01:31:27 +0100195 switch (sdata->vif.type) {
Johannes Berg0ec3ca42007-09-17 01:29:24 -0400196 case IEEE80211_IF_TYPE_WDS:
197 if (is_zero_ether_addr(sdata->u.wds.remote_addr))
198 return -ENOLINK;
199 break;
200 case IEEE80211_IF_TYPE_VLAN:
201 if (!sdata->u.vlan.ap)
202 return -ENOLINK;
203 break;
Johannes Bergfb1c1cd2007-09-26 15:19:43 +0200204 case IEEE80211_IF_TYPE_AP:
Johannes Bergfb1c1cd2007-09-26 15:19:43 +0200205 case IEEE80211_IF_TYPE_STA:
206 case IEEE80211_IF_TYPE_MNTR:
207 case IEEE80211_IF_TYPE_IBSS:
208 /* no special treatment */
209 break;
Johannes Berga2897552007-09-28 14:01:25 +0200210 case IEEE80211_IF_TYPE_INVALID:
211 /* cannot happen */
212 WARN_ON(1);
213 break;
Johannes Berg0ec3ca42007-09-17 01:29:24 -0400214 }
Johannes Bergb2c258f2007-07-27 15:43:23 +0200215
Johannes Bergb2c258f2007-07-27 15:43:23 +0200216 if (local->open_count == 0) {
217 res = 0;
Johannes Berg4150c572007-09-17 01:29:23 -0400218 if (local->ops->start)
219 res = local->ops->start(local_to_hw(local));
220 if (res)
Johannes Bergb2c258f2007-07-27 15:43:23 +0200221 return res;
Michael Bueschceffefd2008-02-10 14:16:52 +0100222 need_hw_reconfig = 1;
Ivo van Doorncdcb0062008-01-07 19:45:24 +0100223 ieee80211_led_radio(local, local->hw.conf.radio_enabled);
Johannes Bergb2c258f2007-07-27 15:43:23 +0200224 }
Johannes Bergb2c258f2007-07-27 15:43:23 +0200225
Johannes Berg51fb61e2007-12-19 01:31:27 +0100226 switch (sdata->vif.type) {
Johannes Berg0ec3ca42007-09-17 01:29:24 -0400227 case IEEE80211_IF_TYPE_VLAN:
228 list_add(&sdata->u.vlan.list, &sdata->u.vlan.ap->u.ap.vlans);
229 /* no need to tell driver */
230 break;
Johannes Berg4150c572007-09-17 01:29:23 -0400231 case IEEE80211_IF_TYPE_MNTR:
232 /* must be before the call to ieee80211_configure_filter */
Johannes Bergb2c258f2007-07-27 15:43:23 +0200233 local->monitors++;
Johannes Berg4150c572007-09-17 01:29:23 -0400234 if (local->monitors == 1) {
235 netif_tx_lock_bh(local->mdev);
236 ieee80211_configure_filter(local);
237 netif_tx_unlock_bh(local->mdev);
238
239 local->hw.conf.flags |= IEEE80211_CONF_RADIOTAP;
Johannes Berg4150c572007-09-17 01:29:23 -0400240 }
241 break;
242 case IEEE80211_IF_TYPE_STA:
243 case IEEE80211_IF_TYPE_IBSS:
244 sdata->u.sta.flags &= ~IEEE80211_STA_PREV_BSSID_SET;
245 /* fall through */
246 default:
Johannes Berg32bfd352007-12-19 01:31:26 +0100247 conf.vif = &sdata->vif;
Johannes Berg51fb61e2007-12-19 01:31:27 +0100248 conf.type = sdata->vif.type;
Johannes Berg4150c572007-09-17 01:29:23 -0400249 conf.mac_addr = dev->dev_addr;
250 res = local->ops->add_interface(local_to_hw(local), &conf);
251 if (res && !local->open_count && local->ops->stop)
252 local->ops->stop(local_to_hw(local));
253 if (res)
254 return res;
255
Johannes Bergb2c258f2007-07-27 15:43:23 +0200256 ieee80211_if_config(dev);
Daniel Draked9430a32007-07-27 15:43:24 +0200257 ieee80211_reset_erp_info(dev);
Johannes Berg11a843b2007-08-28 17:01:55 -0400258 ieee80211_enable_keys(sdata);
Johannes Berg4150c572007-09-17 01:29:23 -0400259
Johannes Berg51fb61e2007-12-19 01:31:27 +0100260 if (sdata->vif.type == IEEE80211_IF_TYPE_STA &&
Johannes Bergddd3d2b2007-09-26 17:53:20 +0200261 !(sdata->flags & IEEE80211_SDATA_USERSPACE_MLME))
Johannes Berg4150c572007-09-17 01:29:23 -0400262 netif_carrier_off(dev);
263 else
264 netif_carrier_on(dev);
Daniel Draked9430a32007-07-27 15:43:24 +0200265 }
Johannes Bergb2c258f2007-07-27 15:43:23 +0200266
Johannes Berg4150c572007-09-17 01:29:23 -0400267 if (local->open_count == 0) {
268 res = dev_open(local->mdev);
269 WARN_ON(res);
Johannes Berg4150c572007-09-17 01:29:23 -0400270 tasklet_enable(&local->tx_pending_tasklet);
271 tasklet_enable(&local->tasklet);
272 }
273
Johannes Bergc1428b32007-11-16 02:54:53 +0100274 /*
275 * set_multicast_list will be invoked by the networking core
276 * which will check whether any increments here were done in
277 * error and sync them down to the hardware as filter flags.
278 */
279 if (sdata->flags & IEEE80211_SDATA_ALLMULTI)
280 atomic_inc(&local->iff_allmultis);
281
282 if (sdata->flags & IEEE80211_SDATA_PROMISC)
283 atomic_inc(&local->iff_promiscs);
284
Johannes Berg4150c572007-09-17 01:29:23 -0400285 local->open_count++;
Michael Bueschceffefd2008-02-10 14:16:52 +0100286 if (need_hw_reconfig)
287 ieee80211_hw_config(local);
Johannes Bergb2c258f2007-07-27 15:43:23 +0200288
Jan Niehusmann64f851e2008-03-23 20:23:56 +0100289 /*
290 * ieee80211_sta_work is disabled while network interface
291 * is down. Therefore, some configuration changes may not
292 * yet be effective. Trigger execution of ieee80211_sta_work
293 * to fix this.
294 */
295 if(sdata->vif.type == IEEE80211_IF_TYPE_STA ||
296 sdata->vif.type == IEEE80211_IF_TYPE_IBSS) {
297 struct ieee80211_if_sta *ifsta = &sdata->u.sta;
298 queue_work(local->hw.workqueue, &ifsta->work);
299 }
300
Johannes Bergb2c258f2007-07-27 15:43:23 +0200301 netif_start_queue(dev);
Johannes Berg4150c572007-09-17 01:29:23 -0400302
Johannes Bergb2c258f2007-07-27 15:43:23 +0200303 return 0;
304}
305
Johannes Berg4150c572007-09-17 01:29:23 -0400306static int ieee80211_stop(struct net_device *dev)
Johannes Bergb2c258f2007-07-27 15:43:23 +0200307{
Johannes Berg4150c572007-09-17 01:29:23 -0400308 struct ieee80211_sub_if_data *sdata;
Johannes Bergb2c258f2007-07-27 15:43:23 +0200309 struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr);
Johannes Berg4150c572007-09-17 01:29:23 -0400310 struct ieee80211_if_init_conf conf;
Ron Rindjunsky07db2182007-12-25 17:00:33 +0200311 struct sta_info *sta;
312 int i;
Johannes Bergb2c258f2007-07-27 15:43:23 +0200313
Johannes Berg4150c572007-09-17 01:29:23 -0400314 sdata = IEEE80211_DEV_TO_SUB_IF(dev);
315
Ron Rindjunsky07db2182007-12-25 17:00:33 +0200316 list_for_each_entry(sta, &local->sta_list, list) {
Ron Rindjunsky5b3d71d2008-01-13 18:21:58 +0200317 if (sta->dev == dev)
318 for (i = 0; i < STA_TID_NUM; i++)
319 ieee80211_sta_stop_rx_ba_session(sta->dev,
320 sta->addr, i,
321 WLAN_BACK_RECIPIENT,
Ron Rindjunsky07db2182007-12-25 17:00:33 +0200322 WLAN_REASON_QSTA_LEAVE_QBSS);
323 }
324
Johannes Berg4150c572007-09-17 01:29:23 -0400325 netif_stop_queue(dev);
326
Johannes Bergc1428b32007-11-16 02:54:53 +0100327 /*
328 * Don't count this interface for promisc/allmulti while it
329 * is down. dev_mc_unsync() will invoke set_multicast_list
330 * on the master interface which will sync these down to the
331 * hardware as filter flags.
332 */
333 if (sdata->flags & IEEE80211_SDATA_ALLMULTI)
334 atomic_dec(&local->iff_allmultis);
335
336 if (sdata->flags & IEEE80211_SDATA_PROMISC)
337 atomic_dec(&local->iff_promiscs);
338
Johannes Berg4150c572007-09-17 01:29:23 -0400339 dev_mc_unsync(local->mdev, dev);
340
Johannes Berg5dfdaf52007-12-19 02:03:33 +0100341 /* APs need special treatment */
Johannes Berg51fb61e2007-12-19 01:31:27 +0100342 if (sdata->vif.type == IEEE80211_IF_TYPE_AP) {
Johannes Berg0ec3ca42007-09-17 01:29:24 -0400343 struct ieee80211_sub_if_data *vlan, *tmp;
Johannes Berg5dfdaf52007-12-19 02:03:33 +0100344 struct beacon_data *old_beacon = sdata->u.ap.beacon;
Johannes Berg0ec3ca42007-09-17 01:29:24 -0400345
Johannes Berg5dfdaf52007-12-19 02:03:33 +0100346 /* remove beacon */
347 rcu_assign_pointer(sdata->u.ap.beacon, NULL);
348 synchronize_rcu();
349 kfree(old_beacon);
350
351 /* down all dependent devices, that is VLANs */
Johannes Berg0ec3ca42007-09-17 01:29:24 -0400352 list_for_each_entry_safe(vlan, tmp, &sdata->u.ap.vlans,
353 u.vlan.list)
354 dev_close(vlan->dev);
355 WARN_ON(!list_empty(&sdata->u.ap.vlans));
356 }
357
Johannes Berg4150c572007-09-17 01:29:23 -0400358 local->open_count--;
359
Johannes Berg51fb61e2007-12-19 01:31:27 +0100360 switch (sdata->vif.type) {
Johannes Berg0ec3ca42007-09-17 01:29:24 -0400361 case IEEE80211_IF_TYPE_VLAN:
362 list_del(&sdata->u.vlan.list);
363 sdata->u.vlan.ap = NULL;
364 /* no need to tell driver */
365 break;
Johannes Berg4150c572007-09-17 01:29:23 -0400366 case IEEE80211_IF_TYPE_MNTR:
367 local->monitors--;
368 if (local->monitors == 0) {
369 netif_tx_lock_bh(local->mdev);
370 ieee80211_configure_filter(local);
371 netif_tx_unlock_bh(local->mdev);
372
Michael Wu8b393f12007-11-28 01:57:08 -0500373 local->hw.conf.flags &= ~IEEE80211_CONF_RADIOTAP;
Johannes Berg4150c572007-09-17 01:29:23 -0400374 }
375 break;
Johannes Bergb2c258f2007-07-27 15:43:23 +0200376 case IEEE80211_IF_TYPE_STA:
377 case IEEE80211_IF_TYPE_IBSS:
378 sdata->u.sta.state = IEEE80211_DISABLED;
379 del_timer_sync(&sdata->u.sta.timer);
Johannes Berg2a8a9a82007-08-28 17:01:52 -0400380 /*
Johannes Berg79010422007-09-18 17:29:21 -0400381 * When we get here, the interface is marked down.
382 * Call synchronize_rcu() to wait for the RX path
383 * should it be using the interface and enqueuing
384 * frames at this very time on another CPU.
Johannes Berg2a8a9a82007-08-28 17:01:52 -0400385 */
Johannes Berg79010422007-09-18 17:29:21 -0400386 synchronize_rcu();
Johannes Bergb2c258f2007-07-27 15:43:23 +0200387 skb_queue_purge(&sdata->u.sta.skb_queue);
Johannes Berg2a8a9a82007-08-28 17:01:52 -0400388
Zhu Yiece8edd2007-11-22 10:53:21 +0800389 if (local->scan_dev == sdata->dev) {
390 if (!local->ops->hw_scan) {
391 local->sta_sw_scanning = 0;
392 cancel_delayed_work(&local->scan_work);
393 } else
394 local->sta_hw_scanning = 0;
Johannes Bergb2c258f2007-07-27 15:43:23 +0200395 }
Zhu Yiece8edd2007-11-22 10:53:21 +0800396
Johannes Bergb2c258f2007-07-27 15:43:23 +0200397 flush_workqueue(local->hw.workqueue);
Zhu Yia10605e2007-11-22 11:10:22 +0800398
399 sdata->u.sta.flags &= ~IEEE80211_STA_PRIVACY_INVOKED;
400 kfree(sdata->u.sta.extra_ie);
401 sdata->u.sta.extra_ie = NULL;
402 sdata->u.sta.extra_ie_len = 0;
Johannes Berg4150c572007-09-17 01:29:23 -0400403 /* fall through */
404 default:
Johannes Berg32bfd352007-12-19 01:31:26 +0100405 conf.vif = &sdata->vif;
Johannes Berg51fb61e2007-12-19 01:31:27 +0100406 conf.type = sdata->vif.type;
Johannes Bergb2c258f2007-07-27 15:43:23 +0200407 conf.mac_addr = dev->dev_addr;
Johannes Berg4150c572007-09-17 01:29:23 -0400408 /* disable all keys for as long as this netdev is down */
409 ieee80211_disable_keys(sdata);
Johannes Bergb2c258f2007-07-27 15:43:23 +0200410 local->ops->remove_interface(local_to_hw(local), &conf);
411 }
412
Johannes Berg4150c572007-09-17 01:29:23 -0400413 if (local->open_count == 0) {
414 if (netif_running(local->mdev))
415 dev_close(local->mdev);
416
Johannes Berg4150c572007-09-17 01:29:23 -0400417 if (local->ops->stop)
418 local->ops->stop(local_to_hw(local));
419
Ivo van Doorncdcb0062008-01-07 19:45:24 +0100420 ieee80211_led_radio(local, 0);
421
Johannes Berg4150c572007-09-17 01:29:23 -0400422 tasklet_disable(&local->tx_pending_tasklet);
423 tasklet_disable(&local->tasklet);
424 }
Johannes Bergb2c258f2007-07-27 15:43:23 +0200425
426 return 0;
427}
428
Johannes Bergb2c258f2007-07-27 15:43:23 +0200429static void ieee80211_set_multicast_list(struct net_device *dev)
430{
431 struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr);
432 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
Johannes Berg4150c572007-09-17 01:29:23 -0400433 int allmulti, promisc, sdata_allmulti, sdata_promisc;
Johannes Bergb2c258f2007-07-27 15:43:23 +0200434
Johannes Berg4150c572007-09-17 01:29:23 -0400435 allmulti = !!(dev->flags & IFF_ALLMULTI);
436 promisc = !!(dev->flags & IFF_PROMISC);
Johannes Bergb52f2192007-11-16 01:49:11 +0100437 sdata_allmulti = !!(sdata->flags & IEEE80211_SDATA_ALLMULTI);
438 sdata_promisc = !!(sdata->flags & IEEE80211_SDATA_PROMISC);
Johannes Berg4150c572007-09-17 01:29:23 -0400439
440 if (allmulti != sdata_allmulti) {
441 if (dev->flags & IFF_ALLMULTI)
Johannes Berg53918992007-09-26 15:19:47 +0200442 atomic_inc(&local->iff_allmultis);
Johannes Berg4150c572007-09-17 01:29:23 -0400443 else
Johannes Berg53918992007-09-26 15:19:47 +0200444 atomic_dec(&local->iff_allmultis);
Jiri Slaby13262ff2007-08-28 17:01:54 -0400445 sdata->flags ^= IEEE80211_SDATA_ALLMULTI;
Johannes Bergb2c258f2007-07-27 15:43:23 +0200446 }
Johannes Berg4150c572007-09-17 01:29:23 -0400447
448 if (promisc != sdata_promisc) {
449 if (dev->flags & IFF_PROMISC)
Johannes Berg53918992007-09-26 15:19:47 +0200450 atomic_inc(&local->iff_promiscs);
Johannes Berg4150c572007-09-17 01:29:23 -0400451 else
Johannes Berg53918992007-09-26 15:19:47 +0200452 atomic_dec(&local->iff_promiscs);
Jiri Slaby13262ff2007-08-28 17:01:54 -0400453 sdata->flags ^= IEEE80211_SDATA_PROMISC;
Johannes Bergb2c258f2007-07-27 15:43:23 +0200454 }
Johannes Berg4150c572007-09-17 01:29:23 -0400455
456 dev_mc_sync(local->mdev, dev);
Johannes Bergb2c258f2007-07-27 15:43:23 +0200457}
458
Stephen Hemminger3b04ddd2007-10-09 01:40:57 -0700459static const struct header_ops ieee80211_header_ops = {
460 .create = eth_header,
461 .parse = header_parse_80211,
462 .rebuild = eth_rebuild_header,
463 .cache = eth_header_cache,
464 .cache_update = eth_header_cache_update,
465};
466
Johannes Bergf9d540e2007-09-28 14:02:09 +0200467/* Must not be called for mdev */
Johannes Bergb2c258f2007-07-27 15:43:23 +0200468void ieee80211_if_setup(struct net_device *dev)
469{
470 ether_setup(dev);
471 dev->hard_start_xmit = ieee80211_subif_start_xmit;
472 dev->wireless_handlers = &ieee80211_iw_handler_def;
473 dev->set_multicast_list = ieee80211_set_multicast_list;
474 dev->change_mtu = ieee80211_change_mtu;
Johannes Bergb2c258f2007-07-27 15:43:23 +0200475 dev->open = ieee80211_open;
476 dev->stop = ieee80211_stop;
Johannes Bergb2c258f2007-07-27 15:43:23 +0200477 dev->destructor = ieee80211_if_free;
478}
479
480/* WDS specialties */
481
482int ieee80211_if_update_wds(struct net_device *dev, u8 *remote_addr)
483{
484 struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr);
485 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
486 struct sta_info *sta;
Joe Perches0795af52007-10-03 17:59:30 -0700487 DECLARE_MAC_BUF(mac);
Johannes Bergb2c258f2007-07-27 15:43:23 +0200488
489 if (compare_ether_addr(remote_addr, sdata->u.wds.remote_addr) == 0)
490 return 0;
491
492 /* Create STA entry for the new peer */
493 sta = sta_info_add(local, dev, remote_addr, GFP_KERNEL);
494 if (!sta)
495 return -ENOMEM;
496 sta_info_put(sta);
497
498 /* Remove STA entry for the old peer */
499 sta = sta_info_get(local, sdata->u.wds.remote_addr);
500 if (sta) {
Michael Wube8755e2007-07-27 15:43:23 +0200501 sta_info_free(sta);
Johannes Bergb2c258f2007-07-27 15:43:23 +0200502 sta_info_put(sta);
Johannes Bergb2c258f2007-07-27 15:43:23 +0200503 } else {
504 printk(KERN_DEBUG "%s: could not find STA entry for WDS link "
Joe Perches0795af52007-10-03 17:59:30 -0700505 "peer %s\n",
506 dev->name, print_mac(mac, sdata->u.wds.remote_addr));
Johannes Bergb2c258f2007-07-27 15:43:23 +0200507 }
508
509 /* Update WDS link data */
510 memcpy(&sdata->u.wds.remote_addr, remote_addr, ETH_ALEN);
511
512 return 0;
513}
514
515/* everything else */
516
Johannes Bergb2c258f2007-07-27 15:43:23 +0200517static int __ieee80211_if_config(struct net_device *dev,
518 struct sk_buff *beacon,
519 struct ieee80211_tx_control *control)
520{
521 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
522 struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr);
523 struct ieee80211_if_conf conf;
Johannes Bergb2c258f2007-07-27 15:43:23 +0200524
525 if (!local->ops->config_interface || !netif_running(dev))
526 return 0;
527
528 memset(&conf, 0, sizeof(conf));
Johannes Berg51fb61e2007-12-19 01:31:27 +0100529 conf.type = sdata->vif.type;
530 if (sdata->vif.type == IEEE80211_IF_TYPE_STA ||
531 sdata->vif.type == IEEE80211_IF_TYPE_IBSS) {
Johannes Berg4150c572007-09-17 01:29:23 -0400532 conf.bssid = sdata->u.sta.bssid;
Johannes Bergb2c258f2007-07-27 15:43:23 +0200533 conf.ssid = sdata->u.sta.ssid;
534 conf.ssid_len = sdata->u.sta.ssid_len;
Johannes Berg51fb61e2007-12-19 01:31:27 +0100535 } else if (sdata->vif.type == IEEE80211_IF_TYPE_AP) {
Johannes Bergb2c258f2007-07-27 15:43:23 +0200536 conf.ssid = sdata->u.ap.ssid;
537 conf.ssid_len = sdata->u.ap.ssid_len;
Johannes Bergb2c258f2007-07-27 15:43:23 +0200538 conf.beacon = beacon;
539 conf.beacon_control = control;
540 }
541 return local->ops->config_interface(local_to_hw(local),
Johannes Berg32bfd352007-12-19 01:31:26 +0100542 &sdata->vif, &conf);
Johannes Bergb2c258f2007-07-27 15:43:23 +0200543}
544
545int ieee80211_if_config(struct net_device *dev)
546{
547 return __ieee80211_if_config(dev, NULL, NULL);
548}
549
550int ieee80211_if_config_beacon(struct net_device *dev)
551{
552 struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr);
553 struct ieee80211_tx_control control;
Johannes Berg32bfd352007-12-19 01:31:26 +0100554 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
Johannes Bergb2c258f2007-07-27 15:43:23 +0200555 struct sk_buff *skb;
556
557 if (!(local->hw.flags & IEEE80211_HW_HOST_GEN_BEACON_TEMPLATE))
558 return 0;
Johannes Berg32bfd352007-12-19 01:31:26 +0100559 skb = ieee80211_beacon_get(local_to_hw(local), &sdata->vif,
560 &control);
Johannes Bergb2c258f2007-07-27 15:43:23 +0200561 if (!skb)
562 return -ENOMEM;
563 return __ieee80211_if_config(dev, skb, &control);
564}
565
566int ieee80211_hw_config(struct ieee80211_local *local)
567{
568 struct ieee80211_hw_mode *mode;
569 struct ieee80211_channel *chan;
570 int ret = 0;
571
Zhu Yiece8edd2007-11-22 10:53:21 +0800572 if (local->sta_sw_scanning) {
Johannes Bergb2c258f2007-07-27 15:43:23 +0200573 chan = local->scan_channel;
574 mode = local->scan_hw_mode;
575 } else {
576 chan = local->oper_channel;
577 mode = local->oper_hw_mode;
578 }
579
580 local->hw.conf.channel = chan->chan;
581 local->hw.conf.channel_val = chan->val;
Michael Buesch61609bc2007-09-20 22:06:39 +0200582 if (!local->hw.conf.power_level) {
583 local->hw.conf.power_level = chan->power_level;
584 } else {
585 local->hw.conf.power_level = min(chan->power_level,
586 local->hw.conf.power_level);
587 }
Johannes Bergb2c258f2007-07-27 15:43:23 +0200588 local->hw.conf.freq = chan->freq;
589 local->hw.conf.phymode = mode->mode;
590 local->hw.conf.antenna_max = chan->antenna_max;
591 local->hw.conf.chan = chan;
592 local->hw.conf.mode = mode;
593
594#ifdef CONFIG_MAC80211_VERBOSE_DEBUG
595 printk(KERN_DEBUG "HW CONFIG: channel=%d freq=%d "
596 "phymode=%d\n", local->hw.conf.channel, local->hw.conf.freq,
597 local->hw.conf.phymode);
598#endif /* CONFIG_MAC80211_VERBOSE_DEBUG */
599
Michael Bueschf7c4dae2007-09-24 18:41:49 +0200600 if (local->open_count)
Johannes Bergb2c258f2007-07-27 15:43:23 +0200601 ret = local->ops->config(local_to_hw(local), &local->hw.conf);
602
603 return ret;
604}
605
Ron Rindjunskyd3c990f2007-11-26 16:14:34 +0200606/**
607 * ieee80211_hw_config_ht should be used only after legacy configuration
608 * has been determined, as ht configuration depends upon the hardware's
609 * HT abilities for a _specific_ band.
610 */
611int ieee80211_hw_config_ht(struct ieee80211_local *local, int enable_ht,
612 struct ieee80211_ht_info *req_ht_cap,
613 struct ieee80211_ht_bss_info *req_bss_cap)
614{
615 struct ieee80211_conf *conf = &local->hw.conf;
616 struct ieee80211_hw_mode *mode = conf->mode;
617 int i;
618
619 /* HT is not supported */
620 if (!mode->ht_info.ht_supported) {
621 conf->flags &= ~IEEE80211_CONF_SUPPORT_HT_MODE;
622 return -EOPNOTSUPP;
623 }
624
625 /* disable HT */
626 if (!enable_ht) {
627 conf->flags &= ~IEEE80211_CONF_SUPPORT_HT_MODE;
628 } else {
629 conf->flags |= IEEE80211_CONF_SUPPORT_HT_MODE;
630 conf->ht_conf.cap = req_ht_cap->cap & mode->ht_info.cap;
631 conf->ht_conf.cap &= ~(IEEE80211_HT_CAP_MIMO_PS);
632 conf->ht_conf.cap |=
633 mode->ht_info.cap & IEEE80211_HT_CAP_MIMO_PS;
634 conf->ht_bss_conf.primary_channel =
635 req_bss_cap->primary_channel;
636 conf->ht_bss_conf.bss_cap = req_bss_cap->bss_cap;
637 conf->ht_bss_conf.bss_op_mode = req_bss_cap->bss_op_mode;
638 for (i = 0; i < SUPP_MCS_SET_LEN; i++)
639 conf->ht_conf.supp_mcs_set[i] =
640 mode->ht_info.supp_mcs_set[i] &
641 req_ht_cap->supp_mcs_set[i];
642
643 /* In STA mode, this gives us indication
644 * to the AP's mode of operation */
645 conf->ht_conf.ht_supported = 1;
646 conf->ht_conf.ampdu_factor = req_ht_cap->ampdu_factor;
647 conf->ht_conf.ampdu_density = req_ht_cap->ampdu_density;
648 }
649
650 local->ops->conf_ht(local_to_hw(local), &local->hw.conf);
651
652 return 0;
653}
654
Johannes Berg471b3ef2007-12-28 14:32:58 +0100655void ieee80211_bss_info_change_notify(struct ieee80211_sub_if_data *sdata,
656 u32 changed)
Daniel Draked9430a32007-07-27 15:43:24 +0200657{
Johannes Berg471b3ef2007-12-28 14:32:58 +0100658 struct ieee80211_local *local = sdata->local;
659
660 if (!changed)
661 return;
662
663 if (local->ops->bss_info_changed)
664 local->ops->bss_info_changed(local_to_hw(local),
665 &sdata->vif,
666 &sdata->bss_conf,
667 changed);
Daniel Draked9430a32007-07-27 15:43:24 +0200668}
669
670void ieee80211_reset_erp_info(struct net_device *dev)
671{
672 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
673
Johannes Berg471b3ef2007-12-28 14:32:58 +0100674 sdata->bss_conf.use_cts_prot = 0;
675 sdata->bss_conf.use_short_preamble = 0;
676 ieee80211_bss_info_change_notify(sdata,
677 BSS_CHANGED_ERP_CTS_PROT |
678 BSS_CHANGED_ERP_PREAMBLE);
Daniel Draked9430a32007-07-27 15:43:24 +0200679}
680
Jiri Bencf0706e82007-05-05 11:45:53 -0700681void ieee80211_tx_status_irqsafe(struct ieee80211_hw *hw,
682 struct sk_buff *skb,
683 struct ieee80211_tx_status *status)
684{
685 struct ieee80211_local *local = hw_to_local(hw);
686 struct ieee80211_tx_status *saved;
687 int tmp;
688
689 skb->dev = local->mdev;
690 saved = kmalloc(sizeof(struct ieee80211_tx_status), GFP_ATOMIC);
691 if (unlikely(!saved)) {
692 if (net_ratelimit())
693 printk(KERN_WARNING "%s: Not enough memory, "
694 "dropping tx status", skb->dev->name);
695 /* should be dev_kfree_skb_irq, but due to this function being
696 * named _irqsafe instead of just _irq we can't be sure that
697 * people won't call it from non-irq contexts */
698 dev_kfree_skb_any(skb);
699 return;
700 }
701 memcpy(saved, status, sizeof(struct ieee80211_tx_status));
702 /* copy pointer to saved status into skb->cb for use by tasklet */
703 memcpy(skb->cb, &saved, sizeof(saved));
704
705 skb->pkt_type = IEEE80211_TX_STATUS_MSG;
706 skb_queue_tail(status->control.flags & IEEE80211_TXCTL_REQ_TX_STATUS ?
707 &local->skb_queue : &local->skb_queue_unreliable, skb);
708 tmp = skb_queue_len(&local->skb_queue) +
709 skb_queue_len(&local->skb_queue_unreliable);
710 while (tmp > IEEE80211_IRQSAFE_QUEUE_LIMIT &&
711 (skb = skb_dequeue(&local->skb_queue_unreliable))) {
712 memcpy(&saved, skb->cb, sizeof(saved));
713 kfree(saved);
714 dev_kfree_skb_irq(skb);
715 tmp--;
716 I802_DEBUG_INC(local->tx_status_drop);
717 }
718 tasklet_schedule(&local->tasklet);
719}
720EXPORT_SYMBOL(ieee80211_tx_status_irqsafe);
721
722static void ieee80211_tasklet_handler(unsigned long data)
723{
724 struct ieee80211_local *local = (struct ieee80211_local *) data;
725 struct sk_buff *skb;
726 struct ieee80211_rx_status rx_status;
727 struct ieee80211_tx_status *tx_status;
728
729 while ((skb = skb_dequeue(&local->skb_queue)) ||
730 (skb = skb_dequeue(&local->skb_queue_unreliable))) {
731 switch (skb->pkt_type) {
732 case IEEE80211_RX_MSG:
733 /* status is in skb->cb */
734 memcpy(&rx_status, skb->cb, sizeof(rx_status));
Johannes Berg51fb61e2007-12-19 01:31:27 +0100735 /* Clear skb->pkt_type in order to not confuse kernel
Jiri Bencf0706e82007-05-05 11:45:53 -0700736 * netstack. */
737 skb->pkt_type = 0;
738 __ieee80211_rx(local_to_hw(local), skb, &rx_status);
739 break;
740 case IEEE80211_TX_STATUS_MSG:
741 /* get pointer to saved status out of skb->cb */
742 memcpy(&tx_status, skb->cb, sizeof(tx_status));
743 skb->pkt_type = 0;
744 ieee80211_tx_status(local_to_hw(local),
745 skb, tx_status);
746 kfree(tx_status);
747 break;
748 default: /* should never get here! */
749 printk(KERN_ERR "%s: Unknown message type (%d)\n",
Johannes Bergdd1cd4c2007-09-18 17:29:20 -0400750 wiphy_name(local->hw.wiphy), skb->pkt_type);
Jiri Bencf0706e82007-05-05 11:45:53 -0700751 dev_kfree_skb(skb);
752 break;
753 }
754 }
755}
756
Jiri Bencf0706e82007-05-05 11:45:53 -0700757/* Remove added headers (e.g., QoS control), encryption header/MIC, etc. to
758 * make a prepared TX frame (one that has been given to hw) to look like brand
759 * new IEEE 802.11 frame that is ready to go through TX processing again.
760 * Also, tx_packet_data in cb is restored from tx_control. */
761static void ieee80211_remove_tx_extra(struct ieee80211_local *local,
762 struct ieee80211_key *key,
763 struct sk_buff *skb,
764 struct ieee80211_tx_control *control)
765{
766 int hdrlen, iv_len, mic_len;
767 struct ieee80211_tx_packet_data *pkt_data;
768
769 pkt_data = (struct ieee80211_tx_packet_data *)skb->cb;
Johannes Berg32bfd352007-12-19 01:31:26 +0100770 pkt_data->ifindex = vif_to_sdata(control->vif)->dev->ifindex;
Jiri Slabye8bf9642007-08-28 17:01:54 -0400771 pkt_data->flags = 0;
772 if (control->flags & IEEE80211_TXCTL_REQ_TX_STATUS)
773 pkt_data->flags |= IEEE80211_TXPD_REQ_TX_STATUS;
774 if (control->flags & IEEE80211_TXCTL_DO_NOT_ENCRYPT)
775 pkt_data->flags |= IEEE80211_TXPD_DO_NOT_ENCRYPT;
776 if (control->flags & IEEE80211_TXCTL_REQUEUE)
777 pkt_data->flags |= IEEE80211_TXPD_REQUEUE;
Johannes Berg678f5f712007-12-19 01:31:23 +0100778 if (control->flags & IEEE80211_TXCTL_EAPOL_FRAME)
779 pkt_data->flags |= IEEE80211_TXPD_EAPOL_FRAME;
Jiri Bencf0706e82007-05-05 11:45:53 -0700780 pkt_data->queue = control->queue;
781
782 hdrlen = ieee80211_get_hdrlen_from_skb(skb);
783
784 if (!key)
785 goto no_key;
786
Johannes Berg8f20fc22007-08-28 17:01:54 -0400787 switch (key->conf.alg) {
Jiri Bencf0706e82007-05-05 11:45:53 -0700788 case ALG_WEP:
789 iv_len = WEP_IV_LEN;
790 mic_len = WEP_ICV_LEN;
791 break;
792 case ALG_TKIP:
793 iv_len = TKIP_IV_LEN;
794 mic_len = TKIP_ICV_LEN;
795 break;
796 case ALG_CCMP:
797 iv_len = CCMP_HDR_LEN;
798 mic_len = CCMP_MIC_LEN;
799 break;
800 default:
801 goto no_key;
802 }
803
Johannes Berg8f20fc22007-08-28 17:01:54 -0400804 if (skb->len >= mic_len &&
Johannes Berg11a843b2007-08-28 17:01:55 -0400805 !(key->flags & KEY_FLAG_UPLOADED_TO_HARDWARE))
Jiri Bencf0706e82007-05-05 11:45:53 -0700806 skb_trim(skb, skb->len - mic_len);
807 if (skb->len >= iv_len && skb->len > hdrlen) {
808 memmove(skb->data + iv_len, skb->data, hdrlen);
809 skb_pull(skb, iv_len);
810 }
811
812no_key:
813 {
814 struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) skb->data;
815 u16 fc = le16_to_cpu(hdr->frame_control);
816 if ((fc & 0x8C) == 0x88) /* QoS Control Field */ {
817 fc &= ~IEEE80211_STYPE_QOS_DATA;
818 hdr->frame_control = cpu_to_le16(fc);
819 memmove(skb->data + 2, skb->data, hdrlen - 2);
820 skb_pull(skb, 2);
821 }
822 }
823}
824
Jiri Bencf0706e82007-05-05 11:45:53 -0700825void ieee80211_tx_status(struct ieee80211_hw *hw, struct sk_buff *skb,
826 struct ieee80211_tx_status *status)
827{
828 struct sk_buff *skb2;
829 struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) skb->data;
830 struct ieee80211_local *local = hw_to_local(hw);
831 u16 frag, type;
Johannes Bergb306f452007-07-10 19:32:08 +0200832 struct ieee80211_tx_status_rtap_hdr *rthdr;
833 struct ieee80211_sub_if_data *sdata;
834 int monitors;
Jiri Bencf0706e82007-05-05 11:45:53 -0700835
836 if (!status) {
837 printk(KERN_ERR
838 "%s: ieee80211_tx_status called with NULL status\n",
Johannes Bergdd1cd4c2007-09-18 17:29:20 -0400839 wiphy_name(local->hw.wiphy));
Jiri Bencf0706e82007-05-05 11:45:53 -0700840 dev_kfree_skb(skb);
841 return;
842 }
843
844 if (status->excessive_retries) {
845 struct sta_info *sta;
846 sta = sta_info_get(local, hdr->addr1);
847 if (sta) {
848 if (sta->flags & WLAN_STA_PS) {
849 /* The STA is in power save mode, so assume
850 * that this TX packet failed because of that.
851 */
852 status->excessive_retries = 0;
853 status->flags |= IEEE80211_TX_STATUS_TX_FILTERED;
854 }
855 sta_info_put(sta);
856 }
857 }
858
859 if (status->flags & IEEE80211_TX_STATUS_TX_FILTERED) {
860 struct sta_info *sta;
861 sta = sta_info_get(local, hdr->addr1);
862 if (sta) {
863 sta->tx_filtered_count++;
864
865 /* Clear the TX filter mask for this STA when sending
866 * the next packet. If the STA went to power save mode,
867 * this will happen when it is waking up for the next
868 * time. */
869 sta->clear_dst_mask = 1;
870
871 /* TODO: Is the WLAN_STA_PS flag always set here or is
872 * the race between RX and TX status causing some
873 * packets to be filtered out before 80211.o gets an
874 * update for PS status? This seems to be the case, so
875 * no changes are likely to be needed. */
876 if (sta->flags & WLAN_STA_PS &&
877 skb_queue_len(&sta->tx_filtered) <
878 STA_MAX_TX_BUFFER) {
879 ieee80211_remove_tx_extra(local, sta->key,
880 skb,
881 &status->control);
882 skb_queue_tail(&sta->tx_filtered, skb);
883 } else if (!(sta->flags & WLAN_STA_PS) &&
884 !(status->control.flags & IEEE80211_TXCTL_REQUEUE)) {
885 /* Software retry the packet once */
886 status->control.flags |= IEEE80211_TXCTL_REQUEUE;
887 ieee80211_remove_tx_extra(local, sta->key,
888 skb,
889 &status->control);
890 dev_queue_xmit(skb);
891 } else {
892 if (net_ratelimit()) {
893 printk(KERN_DEBUG "%s: dropped TX "
894 "filtered frame queue_len=%d "
895 "PS=%d @%lu\n",
Johannes Bergdd1cd4c2007-09-18 17:29:20 -0400896 wiphy_name(local->hw.wiphy),
Jiri Bencf0706e82007-05-05 11:45:53 -0700897 skb_queue_len(
898 &sta->tx_filtered),
899 !!(sta->flags & WLAN_STA_PS),
900 jiffies);
901 }
902 dev_kfree_skb(skb);
903 }
904 sta_info_put(sta);
905 return;
906 }
Mattias Nissler1abbe492007-12-20 13:50:07 +0100907 } else
908 rate_control_tx_status(local->mdev, skb, status);
Jiri Bencf0706e82007-05-05 11:45:53 -0700909
910 ieee80211_led_tx(local, 0);
911
912 /* SNMP counters
913 * Fragments are passed to low-level drivers as separate skbs, so these
914 * are actually fragments, not frames. Update frame counters only for
915 * the first fragment of the frame. */
916
917 frag = le16_to_cpu(hdr->seq_ctrl) & IEEE80211_SCTL_FRAG;
918 type = le16_to_cpu(hdr->frame_control) & IEEE80211_FCTL_FTYPE;
919
920 if (status->flags & IEEE80211_TX_STATUS_ACK) {
921 if (frag == 0) {
922 local->dot11TransmittedFrameCount++;
923 if (is_multicast_ether_addr(hdr->addr1))
924 local->dot11MulticastTransmittedFrameCount++;
925 if (status->retry_count > 0)
926 local->dot11RetryCount++;
927 if (status->retry_count > 1)
928 local->dot11MultipleRetryCount++;
929 }
930
931 /* This counter shall be incremented for an acknowledged MPDU
932 * with an individual address in the address 1 field or an MPDU
933 * with a multicast address in the address 1 field of type Data
934 * or Management. */
935 if (!is_multicast_ether_addr(hdr->addr1) ||
936 type == IEEE80211_FTYPE_DATA ||
937 type == IEEE80211_FTYPE_MGMT)
938 local->dot11TransmittedFragmentCount++;
939 } else {
940 if (frag == 0)
941 local->dot11FailedCount++;
942 }
943
Johannes Bergb306f452007-07-10 19:32:08 +0200944 /* this was a transmitted frame, but now we want to reuse it */
945 skb_orphan(skb);
946
Johannes Bergb306f452007-07-10 19:32:08 +0200947 if (!local->monitors) {
Jiri Bencf0706e82007-05-05 11:45:53 -0700948 dev_kfree_skb(skb);
949 return;
950 }
Jiri Bencf0706e82007-05-05 11:45:53 -0700951
Johannes Bergb306f452007-07-10 19:32:08 +0200952 /* send frame to monitor interfaces now */
953
954 if (skb_headroom(skb) < sizeof(*rthdr)) {
955 printk(KERN_ERR "ieee80211_tx_status: headroom too small\n");
956 dev_kfree_skb(skb);
957 return;
958 }
959
960 rthdr = (struct ieee80211_tx_status_rtap_hdr*)
961 skb_push(skb, sizeof(*rthdr));
962
963 memset(rthdr, 0, sizeof(*rthdr));
964 rthdr->hdr.it_len = cpu_to_le16(sizeof(*rthdr));
965 rthdr->hdr.it_present =
966 cpu_to_le32((1 << IEEE80211_RADIOTAP_TX_FLAGS) |
967 (1 << IEEE80211_RADIOTAP_DATA_RETRIES));
968
969 if (!(status->flags & IEEE80211_TX_STATUS_ACK) &&
970 !is_multicast_ether_addr(hdr->addr1))
971 rthdr->tx_flags |= cpu_to_le16(IEEE80211_RADIOTAP_F_TX_FAIL);
972
973 if ((status->control.flags & IEEE80211_TXCTL_USE_RTS_CTS) &&
974 (status->control.flags & IEEE80211_TXCTL_USE_CTS_PROTECT))
975 rthdr->tx_flags |= cpu_to_le16(IEEE80211_RADIOTAP_F_TX_CTS);
976 else if (status->control.flags & IEEE80211_TXCTL_USE_RTS_CTS)
977 rthdr->tx_flags |= cpu_to_le16(IEEE80211_RADIOTAP_F_TX_RTS);
978
979 rthdr->data_retries = status->retry_count;
980
Johannes Berg79010422007-09-18 17:29:21 -0400981 rcu_read_lock();
Johannes Bergb306f452007-07-10 19:32:08 +0200982 monitors = local->monitors;
Johannes Berg79010422007-09-18 17:29:21 -0400983 list_for_each_entry_rcu(sdata, &local->interfaces, list) {
Johannes Bergb306f452007-07-10 19:32:08 +0200984 /*
985 * Using the monitors counter is possibly racy, but
986 * if the value is wrong we simply either clone the skb
987 * once too much or forget sending it to one monitor iface
988 * The latter case isn't nice but fixing the race is much
989 * more complicated.
990 */
991 if (!monitors || !skb)
992 goto out;
993
Johannes Berg51fb61e2007-12-19 01:31:27 +0100994 if (sdata->vif.type == IEEE80211_IF_TYPE_MNTR) {
Johannes Bergb306f452007-07-10 19:32:08 +0200995 if (!netif_running(sdata->dev))
996 continue;
997 monitors--;
998 if (monitors)
Johannes Berg79010422007-09-18 17:29:21 -0400999 skb2 = skb_clone(skb, GFP_ATOMIC);
Johannes Bergb306f452007-07-10 19:32:08 +02001000 else
1001 skb2 = NULL;
1002 skb->dev = sdata->dev;
1003 /* XXX: is this sufficient for BPF? */
1004 skb_set_mac_header(skb, 0);
1005 skb->ip_summed = CHECKSUM_UNNECESSARY;
1006 skb->pkt_type = PACKET_OTHERHOST;
1007 skb->protocol = htons(ETH_P_802_2);
1008 memset(skb->cb, 0, sizeof(skb->cb));
1009 netif_rx(skb);
1010 skb = skb2;
Johannes Bergb306f452007-07-10 19:32:08 +02001011 }
1012 }
1013 out:
Johannes Berg79010422007-09-18 17:29:21 -04001014 rcu_read_unlock();
Johannes Bergb306f452007-07-10 19:32:08 +02001015 if (skb)
1016 dev_kfree_skb(skb);
Jiri Bencf0706e82007-05-05 11:45:53 -07001017}
1018EXPORT_SYMBOL(ieee80211_tx_status);
1019
Jiri Bencf0706e82007-05-05 11:45:53 -07001020struct ieee80211_hw *ieee80211_alloc_hw(size_t priv_data_len,
1021 const struct ieee80211_ops *ops)
1022{
1023 struct net_device *mdev;
1024 struct ieee80211_local *local;
1025 struct ieee80211_sub_if_data *sdata;
1026 int priv_size;
1027 struct wiphy *wiphy;
1028
1029 /* Ensure 32-byte alignment of our private data and hw private data.
1030 * We use the wiphy priv data for both our ieee80211_local and for
1031 * the driver's private data
1032 *
1033 * In memory it'll be like this:
1034 *
1035 * +-------------------------+
1036 * | struct wiphy |
1037 * +-------------------------+
1038 * | struct ieee80211_local |
1039 * +-------------------------+
1040 * | driver's private data |
1041 * +-------------------------+
1042 *
1043 */
1044 priv_size = ((sizeof(struct ieee80211_local) +
1045 NETDEV_ALIGN_CONST) & ~NETDEV_ALIGN_CONST) +
1046 priv_data_len;
1047
1048 wiphy = wiphy_new(&mac80211_config_ops, priv_size);
1049
1050 if (!wiphy)
1051 return NULL;
1052
1053 wiphy->privid = mac80211_wiphy_privid;
1054
1055 local = wiphy_priv(wiphy);
1056 local->hw.wiphy = wiphy;
1057
1058 local->hw.priv = (char *)local +
1059 ((sizeof(struct ieee80211_local) +
1060 NETDEV_ALIGN_CONST) & ~NETDEV_ALIGN_CONST);
1061
Johannes Berg4480f15c2007-07-10 19:32:10 +02001062 BUG_ON(!ops->tx);
Johannes Berg4150c572007-09-17 01:29:23 -04001063 BUG_ON(!ops->start);
1064 BUG_ON(!ops->stop);
Johannes Berg4480f15c2007-07-10 19:32:10 +02001065 BUG_ON(!ops->config);
1066 BUG_ON(!ops->add_interface);
Johannes Berg4150c572007-09-17 01:29:23 -04001067 BUG_ON(!ops->remove_interface);
1068 BUG_ON(!ops->configure_filter);
Jiri Bencf0706e82007-05-05 11:45:53 -07001069 local->ops = ops;
1070
1071 /* for now, mdev needs sub_if_data :/ */
1072 mdev = alloc_netdev(sizeof(struct ieee80211_sub_if_data),
1073 "wmaster%d", ether_setup);
1074 if (!mdev) {
1075 wiphy_free(wiphy);
1076 return NULL;
1077 }
1078
1079 sdata = IEEE80211_DEV_TO_SUB_IF(mdev);
1080 mdev->ieee80211_ptr = &sdata->wdev;
1081 sdata->wdev.wiphy = wiphy;
1082
1083 local->hw.queues = 1; /* default */
1084
1085 local->mdev = mdev;
1086 local->rx_pre_handlers = ieee80211_rx_pre_handlers;
1087 local->rx_handlers = ieee80211_rx_handlers;
1088 local->tx_handlers = ieee80211_tx_handlers;
1089
1090 local->bridge_packets = 1;
1091
1092 local->rts_threshold = IEEE80211_MAX_RTS_THRESHOLD;
1093 local->fragmentation_threshold = IEEE80211_MAX_FRAG_THRESHOLD;
1094 local->short_retry_limit = 7;
1095 local->long_retry_limit = 4;
1096 local->hw.conf.radio_enabled = 1;
Jiri Bencf0706e82007-05-05 11:45:53 -07001097
Johannes Bergb708e612007-09-14 11:10:25 -04001098 local->enabled_modes = ~0;
Jiri Bencf0706e82007-05-05 11:45:53 -07001099
1100 INIT_LIST_HEAD(&local->modes_list);
1101
Johannes Berg79010422007-09-18 17:29:21 -04001102 INIT_LIST_HEAD(&local->interfaces);
Jiri Bencf0706e82007-05-05 11:45:53 -07001103
1104 INIT_DELAYED_WORK(&local->scan_work, ieee80211_sta_scan_work);
Jiri Bencf0706e82007-05-05 11:45:53 -07001105 ieee80211_rx_bss_list_init(mdev);
1106
1107 sta_info_init(local);
1108
1109 mdev->hard_start_xmit = ieee80211_master_start_xmit;
1110 mdev->open = ieee80211_master_open;
1111 mdev->stop = ieee80211_master_stop;
1112 mdev->type = ARPHRD_IEEE80211;
Stephen Hemminger3b04ddd2007-10-09 01:40:57 -07001113 mdev->header_ops = &ieee80211_header_ops;
Johannes Berg4150c572007-09-17 01:29:23 -04001114 mdev->set_multicast_list = ieee80211_master_set_multicast_list;
Jiri Bencf0706e82007-05-05 11:45:53 -07001115
Johannes Berg51fb61e2007-12-19 01:31:27 +01001116 sdata->vif.type = IEEE80211_IF_TYPE_AP;
Jiri Bencf0706e82007-05-05 11:45:53 -07001117 sdata->dev = mdev;
1118 sdata->local = local;
1119 sdata->u.ap.force_unicast_rateidx = -1;
1120 sdata->u.ap.max_ratectrl_rateidx = -1;
1121 ieee80211_if_sdata_init(sdata);
Johannes Berg79010422007-09-18 17:29:21 -04001122 /* no RCU needed since we're still during init phase */
1123 list_add_tail(&sdata->list, &local->interfaces);
Jiri Bencf0706e82007-05-05 11:45:53 -07001124
1125 tasklet_init(&local->tx_pending_tasklet, ieee80211_tx_pending,
1126 (unsigned long)local);
1127 tasklet_disable(&local->tx_pending_tasklet);
1128
1129 tasklet_init(&local->tasklet,
1130 ieee80211_tasklet_handler,
1131 (unsigned long) local);
1132 tasklet_disable(&local->tasklet);
1133
1134 skb_queue_head_init(&local->skb_queue);
1135 skb_queue_head_init(&local->skb_queue_unreliable);
1136
1137 return local_to_hw(local);
1138}
1139EXPORT_SYMBOL(ieee80211_alloc_hw);
1140
1141int ieee80211_register_hw(struct ieee80211_hw *hw)
1142{
1143 struct ieee80211_local *local = hw_to_local(hw);
1144 const char *name;
1145 int result;
1146
1147 result = wiphy_register(local->hw.wiphy);
1148 if (result < 0)
1149 return result;
1150
1151 name = wiphy_dev(local->hw.wiphy)->driver->name;
1152 local->hw.workqueue = create_singlethread_workqueue(name);
1153 if (!local->hw.workqueue) {
1154 result = -ENOMEM;
1155 goto fail_workqueue;
1156 }
1157
Johannes Bergb306f452007-07-10 19:32:08 +02001158 /*
1159 * The hardware needs headroom for sending the frame,
1160 * and we need some headroom for passing the frame to monitor
1161 * interfaces, but never both at the same time.
1162 */
Jiri Benc33ccad32007-07-18 17:10:44 +02001163 local->tx_headroom = max_t(unsigned int , local->hw.extra_tx_headroom,
1164 sizeof(struct ieee80211_tx_status_rtap_hdr));
Johannes Bergb306f452007-07-10 19:32:08 +02001165
Jiri Bence9f207f2007-05-05 11:46:38 -07001166 debugfs_hw_add(local);
1167
Jiri Bencf0706e82007-05-05 11:45:53 -07001168 local->hw.conf.beacon_int = 1000;
1169
1170 local->wstats_flags |= local->hw.max_rssi ?
1171 IW_QUAL_LEVEL_UPDATED : IW_QUAL_LEVEL_INVALID;
1172 local->wstats_flags |= local->hw.max_signal ?
1173 IW_QUAL_QUAL_UPDATED : IW_QUAL_QUAL_INVALID;
1174 local->wstats_flags |= local->hw.max_noise ?
1175 IW_QUAL_NOISE_UPDATED : IW_QUAL_NOISE_INVALID;
1176 if (local->hw.max_rssi < 0 || local->hw.max_noise < 0)
1177 local->wstats_flags |= IW_QUAL_DBM;
1178
1179 result = sta_info_start(local);
1180 if (result < 0)
1181 goto fail_sta_info;
1182
1183 rtnl_lock();
1184 result = dev_alloc_name(local->mdev, local->mdev->name);
1185 if (result < 0)
1186 goto fail_dev;
1187
1188 memcpy(local->mdev->dev_addr, local->hw.wiphy->perm_addr, ETH_ALEN);
1189 SET_NETDEV_DEV(local->mdev, wiphy_dev(local->hw.wiphy));
1190
1191 result = register_netdevice(local->mdev);
1192 if (result < 0)
1193 goto fail_dev;
1194
Jiri Bence9f207f2007-05-05 11:46:38 -07001195 ieee80211_debugfs_add_netdev(IEEE80211_DEV_TO_SUB_IF(local->mdev));
Johannes Berg5b2812e2007-09-26 14:27:23 +02001196 ieee80211_if_set_type(local->mdev, IEEE80211_IF_TYPE_AP);
Jiri Bence9f207f2007-05-05 11:46:38 -07001197
Johannes Berg830f9032007-10-28 14:51:05 +01001198 result = ieee80211_init_rate_ctrl_alg(local,
1199 hw->rate_control_algorithm);
Jiri Bencf0706e82007-05-05 11:45:53 -07001200 if (result < 0) {
1201 printk(KERN_DEBUG "%s: Failed to initialize rate control "
Johannes Bergdd1cd4c2007-09-18 17:29:20 -04001202 "algorithm\n", wiphy_name(local->hw.wiphy));
Jiri Bencf0706e82007-05-05 11:45:53 -07001203 goto fail_rate;
1204 }
1205
1206 result = ieee80211_wep_init(local);
1207
1208 if (result < 0) {
1209 printk(KERN_DEBUG "%s: Failed to initialize wep\n",
Johannes Bergdd1cd4c2007-09-18 17:29:20 -04001210 wiphy_name(local->hw.wiphy));
Jiri Bencf0706e82007-05-05 11:45:53 -07001211 goto fail_wep;
1212 }
1213
1214 ieee80211_install_qdisc(local->mdev);
1215
1216 /* add one default STA interface */
1217 result = ieee80211_if_add(local->mdev, "wlan%d", NULL,
1218 IEEE80211_IF_TYPE_STA);
1219 if (result)
1220 printk(KERN_WARNING "%s: Failed to add default virtual iface\n",
Johannes Bergdd1cd4c2007-09-18 17:29:20 -04001221 wiphy_name(local->hw.wiphy));
Jiri Bencf0706e82007-05-05 11:45:53 -07001222
1223 local->reg_state = IEEE80211_DEV_REGISTERED;
1224 rtnl_unlock();
1225
1226 ieee80211_led_init(local);
1227
1228 return 0;
1229
1230fail_wep:
1231 rate_control_deinitialize(local);
1232fail_rate:
Jiri Bence9f207f2007-05-05 11:46:38 -07001233 ieee80211_debugfs_remove_netdev(IEEE80211_DEV_TO_SUB_IF(local->mdev));
Jiri Bencf0706e82007-05-05 11:45:53 -07001234 unregister_netdevice(local->mdev);
1235fail_dev:
1236 rtnl_unlock();
1237 sta_info_stop(local);
1238fail_sta_info:
Jiri Bence9f207f2007-05-05 11:46:38 -07001239 debugfs_hw_del(local);
Jiri Bencf0706e82007-05-05 11:45:53 -07001240 destroy_workqueue(local->hw.workqueue);
1241fail_workqueue:
1242 wiphy_unregister(local->hw.wiphy);
1243 return result;
1244}
1245EXPORT_SYMBOL(ieee80211_register_hw);
1246
1247int ieee80211_register_hwmode(struct ieee80211_hw *hw,
1248 struct ieee80211_hw_mode *mode)
1249{
1250 struct ieee80211_local *local = hw_to_local(hw);
1251 struct ieee80211_rate *rate;
1252 int i;
1253
1254 INIT_LIST_HEAD(&mode->list);
1255 list_add_tail(&mode->list, &local->modes_list);
1256
1257 local->hw_modes |= (1 << mode->mode);
1258 for (i = 0; i < mode->num_rates; i++) {
1259 rate = &(mode->rates[i]);
1260 rate->rate_inv = CHAN_UTIL_RATE_LCM / rate->rate;
1261 }
1262 ieee80211_prepare_rates(local, mode);
1263
1264 if (!local->oper_hw_mode) {
1265 /* Default to this mode */
1266 local->hw.conf.phymode = mode->mode;
1267 local->oper_hw_mode = local->scan_hw_mode = mode;
1268 local->oper_channel = local->scan_channel = &mode->channels[0];
1269 local->hw.conf.mode = local->oper_hw_mode;
1270 local->hw.conf.chan = local->oper_channel;
1271 }
1272
1273 if (!(hw->flags & IEEE80211_HW_DEFAULT_REG_DOMAIN_CONFIGURED))
Daniel Drakefd8bacc2007-06-09 19:07:14 +01001274 ieee80211_set_default_regdomain(mode);
Jiri Bencf0706e82007-05-05 11:45:53 -07001275
1276 return 0;
1277}
1278EXPORT_SYMBOL(ieee80211_register_hwmode);
1279
1280void ieee80211_unregister_hw(struct ieee80211_hw *hw)
1281{
1282 struct ieee80211_local *local = hw_to_local(hw);
1283 struct ieee80211_sub_if_data *sdata, *tmp;
Jiri Bencf0706e82007-05-05 11:45:53 -07001284 int i;
1285
1286 tasklet_kill(&local->tx_pending_tasklet);
1287 tasklet_kill(&local->tasklet);
1288
1289 rtnl_lock();
1290
1291 BUG_ON(local->reg_state != IEEE80211_DEV_REGISTERED);
1292
1293 local->reg_state = IEEE80211_DEV_UNREGISTERED;
Jiri Bencf0706e82007-05-05 11:45:53 -07001294
Johannes Berg79010422007-09-18 17:29:21 -04001295 /*
1296 * At this point, interface list manipulations are fine
1297 * because the driver cannot be handing us frames any
1298 * more and the tasklet is killed.
1299 */
Johannes Berg5b2812e2007-09-26 14:27:23 +02001300
1301 /*
1302 * First, we remove all non-master interfaces. Do this because they
1303 * may have bss pointer dependency on the master, and when we free
1304 * the master these would be freed as well, breaking our list
1305 * iteration completely.
1306 */
1307 list_for_each_entry_safe(sdata, tmp, &local->interfaces, list) {
1308 if (sdata->dev == local->mdev)
1309 continue;
1310 list_del(&sdata->list);
Jiri Bencf0706e82007-05-05 11:45:53 -07001311 __ieee80211_if_del(local, sdata);
Johannes Berg5b2812e2007-09-26 14:27:23 +02001312 }
1313
1314 /* then, finally, remove the master interface */
1315 __ieee80211_if_del(local, IEEE80211_DEV_TO_SUB_IF(local->mdev));
Jiri Bencf0706e82007-05-05 11:45:53 -07001316
1317 rtnl_unlock();
1318
Jiri Bencf0706e82007-05-05 11:45:53 -07001319 ieee80211_rx_bss_list_deinit(local->mdev);
1320 ieee80211_clear_tx_pending(local);
1321 sta_info_stop(local);
1322 rate_control_deinitialize(local);
Jiri Bence9f207f2007-05-05 11:46:38 -07001323 debugfs_hw_del(local);
Jiri Bencf0706e82007-05-05 11:45:53 -07001324
1325 for (i = 0; i < NUM_IEEE80211_MODES; i++) {
1326 kfree(local->supp_rates[i]);
1327 kfree(local->basic_rates[i]);
1328 }
1329
1330 if (skb_queue_len(&local->skb_queue)
1331 || skb_queue_len(&local->skb_queue_unreliable))
1332 printk(KERN_WARNING "%s: skb_queue not empty\n",
Johannes Bergdd1cd4c2007-09-18 17:29:20 -04001333 wiphy_name(local->hw.wiphy));
Jiri Bencf0706e82007-05-05 11:45:53 -07001334 skb_queue_purge(&local->skb_queue);
1335 skb_queue_purge(&local->skb_queue_unreliable);
1336
1337 destroy_workqueue(local->hw.workqueue);
1338 wiphy_unregister(local->hw.wiphy);
1339 ieee80211_wep_free(local);
1340 ieee80211_led_exit(local);
1341}
1342EXPORT_SYMBOL(ieee80211_unregister_hw);
1343
1344void ieee80211_free_hw(struct ieee80211_hw *hw)
1345{
1346 struct ieee80211_local *local = hw_to_local(hw);
1347
1348 ieee80211_if_free(local->mdev);
1349 wiphy_free(local->hw.wiphy);
1350}
1351EXPORT_SYMBOL(ieee80211_free_hw);
1352
Jiri Bencf0706e82007-05-05 11:45:53 -07001353static int __init ieee80211_init(void)
1354{
1355 struct sk_buff *skb;
1356 int ret;
1357
1358 BUILD_BUG_ON(sizeof(struct ieee80211_tx_packet_data) > sizeof(skb->cb));
1359
Johannes Berg4b475892008-01-02 15:17:03 +01001360 ret = rc80211_simple_init();
Johannes Bergac71c692007-10-28 14:17:44 +01001361 if (ret)
Johannes Berg3eadf5f2008-01-31 19:33:53 +01001362 goto out;
Mattias Nisslerad018372007-12-19 01:25:57 +01001363
Johannes Berg4b475892008-01-02 15:17:03 +01001364 ret = rc80211_pid_init();
Mattias Nisslerad018372007-12-19 01:25:57 +01001365 if (ret)
Johannes Berg3eadf5f2008-01-31 19:33:53 +01001366 goto out_cleanup_simple;
Johannes Bergac71c692007-10-28 14:17:44 +01001367
Jiri Bencf0706e82007-05-05 11:45:53 -07001368 ret = ieee80211_wme_register();
1369 if (ret) {
1370 printk(KERN_DEBUG "ieee80211_init: failed to "
1371 "initialize WME (err=%d)\n", ret);
Johannes Berg3eadf5f2008-01-31 19:33:53 +01001372 goto out_cleanup_pid;
Jiri Bencf0706e82007-05-05 11:45:53 -07001373 }
1374
Jiri Bence9f207f2007-05-05 11:46:38 -07001375 ieee80211_debugfs_netdev_init();
Daniel Drakefd8bacc2007-06-09 19:07:14 +01001376 ieee80211_regdomain_init();
Jiri Bence9f207f2007-05-05 11:46:38 -07001377
Jiri Bencf0706e82007-05-05 11:45:53 -07001378 return 0;
Mattias Nisslerad018372007-12-19 01:25:57 +01001379
Johannes Berg3eadf5f2008-01-31 19:33:53 +01001380 out_cleanup_pid:
Johannes Berg4b475892008-01-02 15:17:03 +01001381 rc80211_pid_exit();
Johannes Berg3eadf5f2008-01-31 19:33:53 +01001382 out_cleanup_simple:
1383 rc80211_simple_exit();
1384 out:
Mattias Nisslerad018372007-12-19 01:25:57 +01001385 return ret;
Jiri Bencf0706e82007-05-05 11:45:53 -07001386}
1387
Jiri Bencf0706e82007-05-05 11:45:53 -07001388static void __exit ieee80211_exit(void)
1389{
Johannes Berg4b475892008-01-02 15:17:03 +01001390 rc80211_simple_exit();
1391 rc80211_pid_exit();
Johannes Bergac71c692007-10-28 14:17:44 +01001392
Jiri Bencf0706e82007-05-05 11:45:53 -07001393 ieee80211_wme_unregister();
Jiri Bence9f207f2007-05-05 11:46:38 -07001394 ieee80211_debugfs_netdev_exit();
Jiri Bencf0706e82007-05-05 11:45:53 -07001395}
1396
1397
Johannes Bergca9938f2007-09-11 12:50:32 +02001398subsys_initcall(ieee80211_init);
Jiri Bencf0706e82007-05-05 11:45:53 -07001399module_exit(ieee80211_exit);
1400
1401MODULE_DESCRIPTION("IEEE 802.11 subsystem");
1402MODULE_LICENSE("GPL");