blob: 177040218232d4e0a8660276967dfcb6d4a27c6c [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;
168
169 sdata = IEEE80211_DEV_TO_SUB_IF(dev);
Johannes Berg0ec3ca42007-09-17 01:29:24 -0400170
Johannes Berg79010422007-09-18 17:29:21 -0400171 /* we hold the RTNL here so can safely walk the list */
172 list_for_each_entry(nsdata, &local->interfaces, list) {
Johannes Bergb2c258f2007-07-27 15:43:23 +0200173 struct net_device *ndev = nsdata->dev;
174
175 if (ndev != dev && ndev != local->mdev && netif_running(ndev) &&
Johannes Berg0ec3ca42007-09-17 01:29:24 -0400176 compare_ether_addr(dev->dev_addr, ndev->dev_addr) == 0) {
177 /*
178 * check whether it may have the same address
179 */
Johannes Berg51fb61e2007-12-19 01:31:27 +0100180 if (!identical_mac_addr_allowed(sdata->vif.type,
181 nsdata->vif.type))
Johannes Berg0ec3ca42007-09-17 01:29:24 -0400182 return -ENOTUNIQ;
Johannes Berg0ec3ca42007-09-17 01:29:24 -0400183
184 /*
185 * can only add VLANs to enabled APs
186 */
Johannes Berg51fb61e2007-12-19 01:31:27 +0100187 if (sdata->vif.type == IEEE80211_IF_TYPE_VLAN &&
188 nsdata->vif.type == IEEE80211_IF_TYPE_AP &&
Johannes Berg0ec3ca42007-09-17 01:29:24 -0400189 netif_running(nsdata->dev))
190 sdata->u.vlan.ap = nsdata;
Johannes Bergb2c258f2007-07-27 15:43:23 +0200191 }
192 }
Johannes Bergb2c258f2007-07-27 15:43:23 +0200193
Johannes Berg51fb61e2007-12-19 01:31:27 +0100194 switch (sdata->vif.type) {
Johannes Berg0ec3ca42007-09-17 01:29:24 -0400195 case IEEE80211_IF_TYPE_WDS:
196 if (is_zero_ether_addr(sdata->u.wds.remote_addr))
197 return -ENOLINK;
198 break;
199 case IEEE80211_IF_TYPE_VLAN:
200 if (!sdata->u.vlan.ap)
201 return -ENOLINK;
202 break;
Johannes Bergfb1c1cd2007-09-26 15:19:43 +0200203 case IEEE80211_IF_TYPE_AP:
Johannes Bergfb1c1cd2007-09-26 15:19:43 +0200204 case IEEE80211_IF_TYPE_STA:
205 case IEEE80211_IF_TYPE_MNTR:
206 case IEEE80211_IF_TYPE_IBSS:
207 /* no special treatment */
208 break;
Johannes Berga2897552007-09-28 14:01:25 +0200209 case IEEE80211_IF_TYPE_INVALID:
210 /* cannot happen */
211 WARN_ON(1);
212 break;
Johannes Berg0ec3ca42007-09-17 01:29:24 -0400213 }
Johannes Bergb2c258f2007-07-27 15:43:23 +0200214
Johannes Bergb2c258f2007-07-27 15:43:23 +0200215 if (local->open_count == 0) {
216 res = 0;
Johannes Berg4150c572007-09-17 01:29:23 -0400217 if (local->ops->start)
218 res = local->ops->start(local_to_hw(local));
219 if (res)
Johannes Bergb2c258f2007-07-27 15:43:23 +0200220 return res;
Michael Wu8b393f12007-11-28 01:57:08 -0500221 ieee80211_hw_config(local);
Ivo van Doorncdcb0062008-01-07 19:45:24 +0100222 ieee80211_led_radio(local, local->hw.conf.radio_enabled);
Johannes Bergb2c258f2007-07-27 15:43:23 +0200223 }
Johannes Bergb2c258f2007-07-27 15:43:23 +0200224
Johannes Berg51fb61e2007-12-19 01:31:27 +0100225 switch (sdata->vif.type) {
Johannes Berg0ec3ca42007-09-17 01:29:24 -0400226 case IEEE80211_IF_TYPE_VLAN:
227 list_add(&sdata->u.vlan.list, &sdata->u.vlan.ap->u.ap.vlans);
228 /* no need to tell driver */
229 break;
Johannes Berg4150c572007-09-17 01:29:23 -0400230 case IEEE80211_IF_TYPE_MNTR:
231 /* must be before the call to ieee80211_configure_filter */
Johannes Bergb2c258f2007-07-27 15:43:23 +0200232 local->monitors++;
Johannes Berg4150c572007-09-17 01:29:23 -0400233 if (local->monitors == 1) {
234 netif_tx_lock_bh(local->mdev);
235 ieee80211_configure_filter(local);
236 netif_tx_unlock_bh(local->mdev);
237
238 local->hw.conf.flags |= IEEE80211_CONF_RADIOTAP;
Johannes Berg4150c572007-09-17 01:29:23 -0400239 }
240 break;
241 case IEEE80211_IF_TYPE_STA:
242 case IEEE80211_IF_TYPE_IBSS:
243 sdata->u.sta.flags &= ~IEEE80211_STA_PREV_BSSID_SET;
244 /* fall through */
245 default:
Johannes Berg32bfd352007-12-19 01:31:26 +0100246 conf.vif = &sdata->vif;
Johannes Berg51fb61e2007-12-19 01:31:27 +0100247 conf.type = sdata->vif.type;
Johannes Berg4150c572007-09-17 01:29:23 -0400248 conf.mac_addr = dev->dev_addr;
249 res = local->ops->add_interface(local_to_hw(local), &conf);
250 if (res && !local->open_count && local->ops->stop)
251 local->ops->stop(local_to_hw(local));
252 if (res)
253 return res;
254
Johannes Bergb2c258f2007-07-27 15:43:23 +0200255 ieee80211_if_config(dev);
Daniel Draked9430a32007-07-27 15:43:24 +0200256 ieee80211_reset_erp_info(dev);
Johannes Berg11a843b2007-08-28 17:01:55 -0400257 ieee80211_enable_keys(sdata);
Johannes Berg4150c572007-09-17 01:29:23 -0400258
Johannes Berg51fb61e2007-12-19 01:31:27 +0100259 if (sdata->vif.type == IEEE80211_IF_TYPE_STA &&
Johannes Bergddd3d2b2007-09-26 17:53:20 +0200260 !(sdata->flags & IEEE80211_SDATA_USERSPACE_MLME))
Johannes Berg4150c572007-09-17 01:29:23 -0400261 netif_carrier_off(dev);
262 else
263 netif_carrier_on(dev);
Daniel Draked9430a32007-07-27 15:43:24 +0200264 }
Johannes Bergb2c258f2007-07-27 15:43:23 +0200265
Johannes Berg4150c572007-09-17 01:29:23 -0400266 if (local->open_count == 0) {
267 res = dev_open(local->mdev);
268 WARN_ON(res);
Johannes Berg4150c572007-09-17 01:29:23 -0400269 tasklet_enable(&local->tx_pending_tasklet);
270 tasklet_enable(&local->tasklet);
271 }
272
Johannes Bergc1428b32007-11-16 02:54:53 +0100273 /*
274 * set_multicast_list will be invoked by the networking core
275 * which will check whether any increments here were done in
276 * error and sync them down to the hardware as filter flags.
277 */
278 if (sdata->flags & IEEE80211_SDATA_ALLMULTI)
279 atomic_inc(&local->iff_allmultis);
280
281 if (sdata->flags & IEEE80211_SDATA_PROMISC)
282 atomic_inc(&local->iff_promiscs);
283
Johannes Berg4150c572007-09-17 01:29:23 -0400284 local->open_count++;
Johannes Bergb2c258f2007-07-27 15:43:23 +0200285
286 netif_start_queue(dev);
Johannes Berg4150c572007-09-17 01:29:23 -0400287
Johannes Bergb2c258f2007-07-27 15:43:23 +0200288 return 0;
289}
290
Johannes Berg4150c572007-09-17 01:29:23 -0400291static int ieee80211_stop(struct net_device *dev)
Johannes Bergb2c258f2007-07-27 15:43:23 +0200292{
Johannes Berg4150c572007-09-17 01:29:23 -0400293 struct ieee80211_sub_if_data *sdata;
Johannes Bergb2c258f2007-07-27 15:43:23 +0200294 struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr);
Johannes Berg4150c572007-09-17 01:29:23 -0400295 struct ieee80211_if_init_conf conf;
Ron Rindjunsky07db2182007-12-25 17:00:33 +0200296 struct sta_info *sta;
297 int i;
Johannes Bergb2c258f2007-07-27 15:43:23 +0200298
Johannes Berg4150c572007-09-17 01:29:23 -0400299 sdata = IEEE80211_DEV_TO_SUB_IF(dev);
300
Ron Rindjunsky07db2182007-12-25 17:00:33 +0200301 list_for_each_entry(sta, &local->sta_list, list) {
302 for (i = 0; i < STA_TID_NUM; i++)
303 ieee80211_sta_stop_rx_ba_session(sta->dev, sta->addr,
304 i, WLAN_BACK_RECIPIENT,
305 WLAN_REASON_QSTA_LEAVE_QBSS);
306 }
307
Johannes Berg4150c572007-09-17 01:29:23 -0400308 netif_stop_queue(dev);
309
Johannes Bergc1428b32007-11-16 02:54:53 +0100310 /*
311 * Don't count this interface for promisc/allmulti while it
312 * is down. dev_mc_unsync() will invoke set_multicast_list
313 * on the master interface which will sync these down to the
314 * hardware as filter flags.
315 */
316 if (sdata->flags & IEEE80211_SDATA_ALLMULTI)
317 atomic_dec(&local->iff_allmultis);
318
319 if (sdata->flags & IEEE80211_SDATA_PROMISC)
320 atomic_dec(&local->iff_promiscs);
321
Johannes Berg4150c572007-09-17 01:29:23 -0400322 dev_mc_unsync(local->mdev, dev);
323
Johannes Berg5dfdaf52007-12-19 02:03:33 +0100324 /* APs need special treatment */
Johannes Berg51fb61e2007-12-19 01:31:27 +0100325 if (sdata->vif.type == IEEE80211_IF_TYPE_AP) {
Johannes Berg0ec3ca42007-09-17 01:29:24 -0400326 struct ieee80211_sub_if_data *vlan, *tmp;
Johannes Berg5dfdaf52007-12-19 02:03:33 +0100327 struct beacon_data *old_beacon = sdata->u.ap.beacon;
Johannes Berg0ec3ca42007-09-17 01:29:24 -0400328
Johannes Berg5dfdaf52007-12-19 02:03:33 +0100329 /* remove beacon */
330 rcu_assign_pointer(sdata->u.ap.beacon, NULL);
331 synchronize_rcu();
332 kfree(old_beacon);
333
334 /* down all dependent devices, that is VLANs */
Johannes Berg0ec3ca42007-09-17 01:29:24 -0400335 list_for_each_entry_safe(vlan, tmp, &sdata->u.ap.vlans,
336 u.vlan.list)
337 dev_close(vlan->dev);
338 WARN_ON(!list_empty(&sdata->u.ap.vlans));
339 }
340
Johannes Berg4150c572007-09-17 01:29:23 -0400341 local->open_count--;
342
Johannes Berg51fb61e2007-12-19 01:31:27 +0100343 switch (sdata->vif.type) {
Johannes Berg0ec3ca42007-09-17 01:29:24 -0400344 case IEEE80211_IF_TYPE_VLAN:
345 list_del(&sdata->u.vlan.list);
346 sdata->u.vlan.ap = NULL;
347 /* no need to tell driver */
348 break;
Johannes Berg4150c572007-09-17 01:29:23 -0400349 case IEEE80211_IF_TYPE_MNTR:
350 local->monitors--;
351 if (local->monitors == 0) {
352 netif_tx_lock_bh(local->mdev);
353 ieee80211_configure_filter(local);
354 netif_tx_unlock_bh(local->mdev);
355
Michael Wu8b393f12007-11-28 01:57:08 -0500356 local->hw.conf.flags &= ~IEEE80211_CONF_RADIOTAP;
Johannes Berg4150c572007-09-17 01:29:23 -0400357 }
358 break;
Johannes Bergb2c258f2007-07-27 15:43:23 +0200359 case IEEE80211_IF_TYPE_STA:
360 case IEEE80211_IF_TYPE_IBSS:
361 sdata->u.sta.state = IEEE80211_DISABLED;
362 del_timer_sync(&sdata->u.sta.timer);
Johannes Berg2a8a9a82007-08-28 17:01:52 -0400363 /*
Johannes Berg79010422007-09-18 17:29:21 -0400364 * When we get here, the interface is marked down.
365 * Call synchronize_rcu() to wait for the RX path
366 * should it be using the interface and enqueuing
367 * frames at this very time on another CPU.
Johannes Berg2a8a9a82007-08-28 17:01:52 -0400368 */
Johannes Berg79010422007-09-18 17:29:21 -0400369 synchronize_rcu();
Johannes Bergb2c258f2007-07-27 15:43:23 +0200370 skb_queue_purge(&sdata->u.sta.skb_queue);
Johannes Berg2a8a9a82007-08-28 17:01:52 -0400371
Zhu Yiece8edd2007-11-22 10:53:21 +0800372 if (local->scan_dev == sdata->dev) {
373 if (!local->ops->hw_scan) {
374 local->sta_sw_scanning = 0;
375 cancel_delayed_work(&local->scan_work);
376 } else
377 local->sta_hw_scanning = 0;
Johannes Bergb2c258f2007-07-27 15:43:23 +0200378 }
Zhu Yiece8edd2007-11-22 10:53:21 +0800379
Johannes Bergb2c258f2007-07-27 15:43:23 +0200380 flush_workqueue(local->hw.workqueue);
Zhu Yia10605e2007-11-22 11:10:22 +0800381
382 sdata->u.sta.flags &= ~IEEE80211_STA_PRIVACY_INVOKED;
383 kfree(sdata->u.sta.extra_ie);
384 sdata->u.sta.extra_ie = NULL;
385 sdata->u.sta.extra_ie_len = 0;
Johannes Berg4150c572007-09-17 01:29:23 -0400386 /* fall through */
387 default:
Johannes Berg32bfd352007-12-19 01:31:26 +0100388 conf.vif = &sdata->vif;
Johannes Berg51fb61e2007-12-19 01:31:27 +0100389 conf.type = sdata->vif.type;
Johannes Bergb2c258f2007-07-27 15:43:23 +0200390 conf.mac_addr = dev->dev_addr;
Johannes Berg4150c572007-09-17 01:29:23 -0400391 /* disable all keys for as long as this netdev is down */
392 ieee80211_disable_keys(sdata);
Johannes Bergb2c258f2007-07-27 15:43:23 +0200393 local->ops->remove_interface(local_to_hw(local), &conf);
394 }
395
Johannes Berg4150c572007-09-17 01:29:23 -0400396 if (local->open_count == 0) {
397 if (netif_running(local->mdev))
398 dev_close(local->mdev);
399
Johannes Berg4150c572007-09-17 01:29:23 -0400400 if (local->ops->stop)
401 local->ops->stop(local_to_hw(local));
402
Ivo van Doorncdcb0062008-01-07 19:45:24 +0100403 ieee80211_led_radio(local, 0);
404
Johannes Berg4150c572007-09-17 01:29:23 -0400405 tasklet_disable(&local->tx_pending_tasklet);
406 tasklet_disable(&local->tasklet);
407 }
Johannes Bergb2c258f2007-07-27 15:43:23 +0200408
409 return 0;
410}
411
Johannes Bergb2c258f2007-07-27 15:43:23 +0200412static void ieee80211_set_multicast_list(struct net_device *dev)
413{
414 struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr);
415 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
Johannes Berg4150c572007-09-17 01:29:23 -0400416 int allmulti, promisc, sdata_allmulti, sdata_promisc;
Johannes Bergb2c258f2007-07-27 15:43:23 +0200417
Johannes Berg4150c572007-09-17 01:29:23 -0400418 allmulti = !!(dev->flags & IFF_ALLMULTI);
419 promisc = !!(dev->flags & IFF_PROMISC);
Johannes Bergb52f2192007-11-16 01:49:11 +0100420 sdata_allmulti = !!(sdata->flags & IEEE80211_SDATA_ALLMULTI);
421 sdata_promisc = !!(sdata->flags & IEEE80211_SDATA_PROMISC);
Johannes Berg4150c572007-09-17 01:29:23 -0400422
423 if (allmulti != sdata_allmulti) {
424 if (dev->flags & IFF_ALLMULTI)
Johannes Berg53918992007-09-26 15:19:47 +0200425 atomic_inc(&local->iff_allmultis);
Johannes Berg4150c572007-09-17 01:29:23 -0400426 else
Johannes Berg53918992007-09-26 15:19:47 +0200427 atomic_dec(&local->iff_allmultis);
Jiri Slaby13262ff2007-08-28 17:01:54 -0400428 sdata->flags ^= IEEE80211_SDATA_ALLMULTI;
Johannes Bergb2c258f2007-07-27 15:43:23 +0200429 }
Johannes Berg4150c572007-09-17 01:29:23 -0400430
431 if (promisc != sdata_promisc) {
432 if (dev->flags & IFF_PROMISC)
Johannes Berg53918992007-09-26 15:19:47 +0200433 atomic_inc(&local->iff_promiscs);
Johannes Berg4150c572007-09-17 01:29:23 -0400434 else
Johannes Berg53918992007-09-26 15:19:47 +0200435 atomic_dec(&local->iff_promiscs);
Jiri Slaby13262ff2007-08-28 17:01:54 -0400436 sdata->flags ^= IEEE80211_SDATA_PROMISC;
Johannes Bergb2c258f2007-07-27 15:43:23 +0200437 }
Johannes Berg4150c572007-09-17 01:29:23 -0400438
439 dev_mc_sync(local->mdev, dev);
Johannes Bergb2c258f2007-07-27 15:43:23 +0200440}
441
Stephen Hemminger3b04ddd2007-10-09 01:40:57 -0700442static const struct header_ops ieee80211_header_ops = {
443 .create = eth_header,
444 .parse = header_parse_80211,
445 .rebuild = eth_rebuild_header,
446 .cache = eth_header_cache,
447 .cache_update = eth_header_cache_update,
448};
449
Johannes Bergf9d540e2007-09-28 14:02:09 +0200450/* Must not be called for mdev */
Johannes Bergb2c258f2007-07-27 15:43:23 +0200451void ieee80211_if_setup(struct net_device *dev)
452{
453 ether_setup(dev);
454 dev->hard_start_xmit = ieee80211_subif_start_xmit;
455 dev->wireless_handlers = &ieee80211_iw_handler_def;
456 dev->set_multicast_list = ieee80211_set_multicast_list;
457 dev->change_mtu = ieee80211_change_mtu;
Johannes Bergb2c258f2007-07-27 15:43:23 +0200458 dev->open = ieee80211_open;
459 dev->stop = ieee80211_stop;
Johannes Bergb2c258f2007-07-27 15:43:23 +0200460 dev->destructor = ieee80211_if_free;
461}
462
463/* WDS specialties */
464
465int ieee80211_if_update_wds(struct net_device *dev, u8 *remote_addr)
466{
467 struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr);
468 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
469 struct sta_info *sta;
Joe Perches0795af52007-10-03 17:59:30 -0700470 DECLARE_MAC_BUF(mac);
Johannes Bergb2c258f2007-07-27 15:43:23 +0200471
472 if (compare_ether_addr(remote_addr, sdata->u.wds.remote_addr) == 0)
473 return 0;
474
475 /* Create STA entry for the new peer */
476 sta = sta_info_add(local, dev, remote_addr, GFP_KERNEL);
477 if (!sta)
478 return -ENOMEM;
479 sta_info_put(sta);
480
481 /* Remove STA entry for the old peer */
482 sta = sta_info_get(local, sdata->u.wds.remote_addr);
483 if (sta) {
Michael Wube8755e2007-07-27 15:43:23 +0200484 sta_info_free(sta);
Johannes Bergb2c258f2007-07-27 15:43:23 +0200485 sta_info_put(sta);
Johannes Bergb2c258f2007-07-27 15:43:23 +0200486 } else {
487 printk(KERN_DEBUG "%s: could not find STA entry for WDS link "
Joe Perches0795af52007-10-03 17:59:30 -0700488 "peer %s\n",
489 dev->name, print_mac(mac, sdata->u.wds.remote_addr));
Johannes Bergb2c258f2007-07-27 15:43:23 +0200490 }
491
492 /* Update WDS link data */
493 memcpy(&sdata->u.wds.remote_addr, remote_addr, ETH_ALEN);
494
495 return 0;
496}
497
498/* everything else */
499
Johannes Bergb2c258f2007-07-27 15:43:23 +0200500static int __ieee80211_if_config(struct net_device *dev,
501 struct sk_buff *beacon,
502 struct ieee80211_tx_control *control)
503{
504 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
505 struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr);
506 struct ieee80211_if_conf conf;
Johannes Bergb2c258f2007-07-27 15:43:23 +0200507
508 if (!local->ops->config_interface || !netif_running(dev))
509 return 0;
510
511 memset(&conf, 0, sizeof(conf));
Johannes Berg51fb61e2007-12-19 01:31:27 +0100512 conf.type = sdata->vif.type;
513 if (sdata->vif.type == IEEE80211_IF_TYPE_STA ||
514 sdata->vif.type == IEEE80211_IF_TYPE_IBSS) {
Johannes Berg4150c572007-09-17 01:29:23 -0400515 conf.bssid = sdata->u.sta.bssid;
Johannes Bergb2c258f2007-07-27 15:43:23 +0200516 conf.ssid = sdata->u.sta.ssid;
517 conf.ssid_len = sdata->u.sta.ssid_len;
Johannes Berg51fb61e2007-12-19 01:31:27 +0100518 } else if (sdata->vif.type == IEEE80211_IF_TYPE_AP) {
Johannes Bergb2c258f2007-07-27 15:43:23 +0200519 conf.ssid = sdata->u.ap.ssid;
520 conf.ssid_len = sdata->u.ap.ssid_len;
Johannes Bergb2c258f2007-07-27 15:43:23 +0200521 conf.beacon = beacon;
522 conf.beacon_control = control;
523 }
524 return local->ops->config_interface(local_to_hw(local),
Johannes Berg32bfd352007-12-19 01:31:26 +0100525 &sdata->vif, &conf);
Johannes Bergb2c258f2007-07-27 15:43:23 +0200526}
527
528int ieee80211_if_config(struct net_device *dev)
529{
530 return __ieee80211_if_config(dev, NULL, NULL);
531}
532
533int ieee80211_if_config_beacon(struct net_device *dev)
534{
535 struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr);
536 struct ieee80211_tx_control control;
Johannes Berg32bfd352007-12-19 01:31:26 +0100537 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
Johannes Bergb2c258f2007-07-27 15:43:23 +0200538 struct sk_buff *skb;
539
540 if (!(local->hw.flags & IEEE80211_HW_HOST_GEN_BEACON_TEMPLATE))
541 return 0;
Johannes Berg32bfd352007-12-19 01:31:26 +0100542 skb = ieee80211_beacon_get(local_to_hw(local), &sdata->vif,
543 &control);
Johannes Bergb2c258f2007-07-27 15:43:23 +0200544 if (!skb)
545 return -ENOMEM;
546 return __ieee80211_if_config(dev, skb, &control);
547}
548
549int ieee80211_hw_config(struct ieee80211_local *local)
550{
551 struct ieee80211_hw_mode *mode;
552 struct ieee80211_channel *chan;
553 int ret = 0;
554
Zhu Yiece8edd2007-11-22 10:53:21 +0800555 if (local->sta_sw_scanning) {
Johannes Bergb2c258f2007-07-27 15:43:23 +0200556 chan = local->scan_channel;
557 mode = local->scan_hw_mode;
558 } else {
559 chan = local->oper_channel;
560 mode = local->oper_hw_mode;
561 }
562
563 local->hw.conf.channel = chan->chan;
564 local->hw.conf.channel_val = chan->val;
Michael Buesch61609bc2007-09-20 22:06:39 +0200565 if (!local->hw.conf.power_level) {
566 local->hw.conf.power_level = chan->power_level;
567 } else {
568 local->hw.conf.power_level = min(chan->power_level,
569 local->hw.conf.power_level);
570 }
Johannes Bergb2c258f2007-07-27 15:43:23 +0200571 local->hw.conf.freq = chan->freq;
572 local->hw.conf.phymode = mode->mode;
573 local->hw.conf.antenna_max = chan->antenna_max;
574 local->hw.conf.chan = chan;
575 local->hw.conf.mode = mode;
576
577#ifdef CONFIG_MAC80211_VERBOSE_DEBUG
578 printk(KERN_DEBUG "HW CONFIG: channel=%d freq=%d "
579 "phymode=%d\n", local->hw.conf.channel, local->hw.conf.freq,
580 local->hw.conf.phymode);
581#endif /* CONFIG_MAC80211_VERBOSE_DEBUG */
582
Michael Bueschf7c4dae2007-09-24 18:41:49 +0200583 if (local->open_count)
Johannes Bergb2c258f2007-07-27 15:43:23 +0200584 ret = local->ops->config(local_to_hw(local), &local->hw.conf);
585
586 return ret;
587}
588
Ron Rindjunskyd3c990f2007-11-26 16:14:34 +0200589/**
590 * ieee80211_hw_config_ht should be used only after legacy configuration
591 * has been determined, as ht configuration depends upon the hardware's
592 * HT abilities for a _specific_ band.
593 */
594int ieee80211_hw_config_ht(struct ieee80211_local *local, int enable_ht,
595 struct ieee80211_ht_info *req_ht_cap,
596 struct ieee80211_ht_bss_info *req_bss_cap)
597{
598 struct ieee80211_conf *conf = &local->hw.conf;
599 struct ieee80211_hw_mode *mode = conf->mode;
600 int i;
601
602 /* HT is not supported */
603 if (!mode->ht_info.ht_supported) {
604 conf->flags &= ~IEEE80211_CONF_SUPPORT_HT_MODE;
605 return -EOPNOTSUPP;
606 }
607
608 /* disable HT */
609 if (!enable_ht) {
610 conf->flags &= ~IEEE80211_CONF_SUPPORT_HT_MODE;
611 } else {
612 conf->flags |= IEEE80211_CONF_SUPPORT_HT_MODE;
613 conf->ht_conf.cap = req_ht_cap->cap & mode->ht_info.cap;
614 conf->ht_conf.cap &= ~(IEEE80211_HT_CAP_MIMO_PS);
615 conf->ht_conf.cap |=
616 mode->ht_info.cap & IEEE80211_HT_CAP_MIMO_PS;
617 conf->ht_bss_conf.primary_channel =
618 req_bss_cap->primary_channel;
619 conf->ht_bss_conf.bss_cap = req_bss_cap->bss_cap;
620 conf->ht_bss_conf.bss_op_mode = req_bss_cap->bss_op_mode;
621 for (i = 0; i < SUPP_MCS_SET_LEN; i++)
622 conf->ht_conf.supp_mcs_set[i] =
623 mode->ht_info.supp_mcs_set[i] &
624 req_ht_cap->supp_mcs_set[i];
625
626 /* In STA mode, this gives us indication
627 * to the AP's mode of operation */
628 conf->ht_conf.ht_supported = 1;
629 conf->ht_conf.ampdu_factor = req_ht_cap->ampdu_factor;
630 conf->ht_conf.ampdu_density = req_ht_cap->ampdu_density;
631 }
632
633 local->ops->conf_ht(local_to_hw(local), &local->hw.conf);
634
635 return 0;
636}
637
Johannes Berg471b3ef2007-12-28 14:32:58 +0100638void ieee80211_bss_info_change_notify(struct ieee80211_sub_if_data *sdata,
639 u32 changed)
Daniel Draked9430a32007-07-27 15:43:24 +0200640{
Johannes Berg471b3ef2007-12-28 14:32:58 +0100641 struct ieee80211_local *local = sdata->local;
642
643 if (!changed)
644 return;
645
646 if (local->ops->bss_info_changed)
647 local->ops->bss_info_changed(local_to_hw(local),
648 &sdata->vif,
649 &sdata->bss_conf,
650 changed);
Daniel Draked9430a32007-07-27 15:43:24 +0200651}
652
653void ieee80211_reset_erp_info(struct net_device *dev)
654{
655 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
656
Johannes Berg471b3ef2007-12-28 14:32:58 +0100657 sdata->bss_conf.use_cts_prot = 0;
658 sdata->bss_conf.use_short_preamble = 0;
659 ieee80211_bss_info_change_notify(sdata,
660 BSS_CHANGED_ERP_CTS_PROT |
661 BSS_CHANGED_ERP_PREAMBLE);
Daniel Draked9430a32007-07-27 15:43:24 +0200662}
663
Jiri Bencf0706e82007-05-05 11:45:53 -0700664void ieee80211_tx_status_irqsafe(struct ieee80211_hw *hw,
665 struct sk_buff *skb,
666 struct ieee80211_tx_status *status)
667{
668 struct ieee80211_local *local = hw_to_local(hw);
669 struct ieee80211_tx_status *saved;
670 int tmp;
671
672 skb->dev = local->mdev;
673 saved = kmalloc(sizeof(struct ieee80211_tx_status), GFP_ATOMIC);
674 if (unlikely(!saved)) {
675 if (net_ratelimit())
676 printk(KERN_WARNING "%s: Not enough memory, "
677 "dropping tx status", skb->dev->name);
678 /* should be dev_kfree_skb_irq, but due to this function being
679 * named _irqsafe instead of just _irq we can't be sure that
680 * people won't call it from non-irq contexts */
681 dev_kfree_skb_any(skb);
682 return;
683 }
684 memcpy(saved, status, sizeof(struct ieee80211_tx_status));
685 /* copy pointer to saved status into skb->cb for use by tasklet */
686 memcpy(skb->cb, &saved, sizeof(saved));
687
688 skb->pkt_type = IEEE80211_TX_STATUS_MSG;
689 skb_queue_tail(status->control.flags & IEEE80211_TXCTL_REQ_TX_STATUS ?
690 &local->skb_queue : &local->skb_queue_unreliable, skb);
691 tmp = skb_queue_len(&local->skb_queue) +
692 skb_queue_len(&local->skb_queue_unreliable);
693 while (tmp > IEEE80211_IRQSAFE_QUEUE_LIMIT &&
694 (skb = skb_dequeue(&local->skb_queue_unreliable))) {
695 memcpy(&saved, skb->cb, sizeof(saved));
696 kfree(saved);
697 dev_kfree_skb_irq(skb);
698 tmp--;
699 I802_DEBUG_INC(local->tx_status_drop);
700 }
701 tasklet_schedule(&local->tasklet);
702}
703EXPORT_SYMBOL(ieee80211_tx_status_irqsafe);
704
705static void ieee80211_tasklet_handler(unsigned long data)
706{
707 struct ieee80211_local *local = (struct ieee80211_local *) data;
708 struct sk_buff *skb;
709 struct ieee80211_rx_status rx_status;
710 struct ieee80211_tx_status *tx_status;
711
712 while ((skb = skb_dequeue(&local->skb_queue)) ||
713 (skb = skb_dequeue(&local->skb_queue_unreliable))) {
714 switch (skb->pkt_type) {
715 case IEEE80211_RX_MSG:
716 /* status is in skb->cb */
717 memcpy(&rx_status, skb->cb, sizeof(rx_status));
Johannes Berg51fb61e2007-12-19 01:31:27 +0100718 /* Clear skb->pkt_type in order to not confuse kernel
Jiri Bencf0706e82007-05-05 11:45:53 -0700719 * netstack. */
720 skb->pkt_type = 0;
721 __ieee80211_rx(local_to_hw(local), skb, &rx_status);
722 break;
723 case IEEE80211_TX_STATUS_MSG:
724 /* get pointer to saved status out of skb->cb */
725 memcpy(&tx_status, skb->cb, sizeof(tx_status));
726 skb->pkt_type = 0;
727 ieee80211_tx_status(local_to_hw(local),
728 skb, tx_status);
729 kfree(tx_status);
730 break;
731 default: /* should never get here! */
732 printk(KERN_ERR "%s: Unknown message type (%d)\n",
Johannes Bergdd1cd4c2007-09-18 17:29:20 -0400733 wiphy_name(local->hw.wiphy), skb->pkt_type);
Jiri Bencf0706e82007-05-05 11:45:53 -0700734 dev_kfree_skb(skb);
735 break;
736 }
737 }
738}
739
Jiri Bencf0706e82007-05-05 11:45:53 -0700740/* Remove added headers (e.g., QoS control), encryption header/MIC, etc. to
741 * make a prepared TX frame (one that has been given to hw) to look like brand
742 * new IEEE 802.11 frame that is ready to go through TX processing again.
743 * Also, tx_packet_data in cb is restored from tx_control. */
744static void ieee80211_remove_tx_extra(struct ieee80211_local *local,
745 struct ieee80211_key *key,
746 struct sk_buff *skb,
747 struct ieee80211_tx_control *control)
748{
749 int hdrlen, iv_len, mic_len;
750 struct ieee80211_tx_packet_data *pkt_data;
751
752 pkt_data = (struct ieee80211_tx_packet_data *)skb->cb;
Johannes Berg32bfd352007-12-19 01:31:26 +0100753 pkt_data->ifindex = vif_to_sdata(control->vif)->dev->ifindex;
Jiri Slabye8bf9642007-08-28 17:01:54 -0400754 pkt_data->flags = 0;
755 if (control->flags & IEEE80211_TXCTL_REQ_TX_STATUS)
756 pkt_data->flags |= IEEE80211_TXPD_REQ_TX_STATUS;
757 if (control->flags & IEEE80211_TXCTL_DO_NOT_ENCRYPT)
758 pkt_data->flags |= IEEE80211_TXPD_DO_NOT_ENCRYPT;
759 if (control->flags & IEEE80211_TXCTL_REQUEUE)
760 pkt_data->flags |= IEEE80211_TXPD_REQUEUE;
Johannes Berg678f5f712007-12-19 01:31:23 +0100761 if (control->flags & IEEE80211_TXCTL_EAPOL_FRAME)
762 pkt_data->flags |= IEEE80211_TXPD_EAPOL_FRAME;
Jiri Bencf0706e82007-05-05 11:45:53 -0700763 pkt_data->queue = control->queue;
764
765 hdrlen = ieee80211_get_hdrlen_from_skb(skb);
766
767 if (!key)
768 goto no_key;
769
Johannes Berg8f20fc22007-08-28 17:01:54 -0400770 switch (key->conf.alg) {
Jiri Bencf0706e82007-05-05 11:45:53 -0700771 case ALG_WEP:
772 iv_len = WEP_IV_LEN;
773 mic_len = WEP_ICV_LEN;
774 break;
775 case ALG_TKIP:
776 iv_len = TKIP_IV_LEN;
777 mic_len = TKIP_ICV_LEN;
778 break;
779 case ALG_CCMP:
780 iv_len = CCMP_HDR_LEN;
781 mic_len = CCMP_MIC_LEN;
782 break;
783 default:
784 goto no_key;
785 }
786
Johannes Berg8f20fc22007-08-28 17:01:54 -0400787 if (skb->len >= mic_len &&
Johannes Berg11a843b2007-08-28 17:01:55 -0400788 !(key->flags & KEY_FLAG_UPLOADED_TO_HARDWARE))
Jiri Bencf0706e82007-05-05 11:45:53 -0700789 skb_trim(skb, skb->len - mic_len);
790 if (skb->len >= iv_len && skb->len > hdrlen) {
791 memmove(skb->data + iv_len, skb->data, hdrlen);
792 skb_pull(skb, iv_len);
793 }
794
795no_key:
796 {
797 struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) skb->data;
798 u16 fc = le16_to_cpu(hdr->frame_control);
799 if ((fc & 0x8C) == 0x88) /* QoS Control Field */ {
800 fc &= ~IEEE80211_STYPE_QOS_DATA;
801 hdr->frame_control = cpu_to_le16(fc);
802 memmove(skb->data + 2, skb->data, hdrlen - 2);
803 skb_pull(skb, 2);
804 }
805 }
806}
807
Jiri Bencf0706e82007-05-05 11:45:53 -0700808void ieee80211_tx_status(struct ieee80211_hw *hw, struct sk_buff *skb,
809 struct ieee80211_tx_status *status)
810{
811 struct sk_buff *skb2;
812 struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) skb->data;
813 struct ieee80211_local *local = hw_to_local(hw);
814 u16 frag, type;
Johannes Bergb306f452007-07-10 19:32:08 +0200815 struct ieee80211_tx_status_rtap_hdr *rthdr;
816 struct ieee80211_sub_if_data *sdata;
817 int monitors;
Jiri Bencf0706e82007-05-05 11:45:53 -0700818
819 if (!status) {
820 printk(KERN_ERR
821 "%s: ieee80211_tx_status called with NULL status\n",
Johannes Bergdd1cd4c2007-09-18 17:29:20 -0400822 wiphy_name(local->hw.wiphy));
Jiri Bencf0706e82007-05-05 11:45:53 -0700823 dev_kfree_skb(skb);
824 return;
825 }
826
827 if (status->excessive_retries) {
828 struct sta_info *sta;
829 sta = sta_info_get(local, hdr->addr1);
830 if (sta) {
831 if (sta->flags & WLAN_STA_PS) {
832 /* The STA is in power save mode, so assume
833 * that this TX packet failed because of that.
834 */
835 status->excessive_retries = 0;
836 status->flags |= IEEE80211_TX_STATUS_TX_FILTERED;
837 }
838 sta_info_put(sta);
839 }
840 }
841
842 if (status->flags & IEEE80211_TX_STATUS_TX_FILTERED) {
843 struct sta_info *sta;
844 sta = sta_info_get(local, hdr->addr1);
845 if (sta) {
846 sta->tx_filtered_count++;
847
848 /* Clear the TX filter mask for this STA when sending
849 * the next packet. If the STA went to power save mode,
850 * this will happen when it is waking up for the next
851 * time. */
852 sta->clear_dst_mask = 1;
853
854 /* TODO: Is the WLAN_STA_PS flag always set here or is
855 * the race between RX and TX status causing some
856 * packets to be filtered out before 80211.o gets an
857 * update for PS status? This seems to be the case, so
858 * no changes are likely to be needed. */
859 if (sta->flags & WLAN_STA_PS &&
860 skb_queue_len(&sta->tx_filtered) <
861 STA_MAX_TX_BUFFER) {
862 ieee80211_remove_tx_extra(local, sta->key,
863 skb,
864 &status->control);
865 skb_queue_tail(&sta->tx_filtered, skb);
866 } else if (!(sta->flags & WLAN_STA_PS) &&
867 !(status->control.flags & IEEE80211_TXCTL_REQUEUE)) {
868 /* Software retry the packet once */
869 status->control.flags |= IEEE80211_TXCTL_REQUEUE;
870 ieee80211_remove_tx_extra(local, sta->key,
871 skb,
872 &status->control);
873 dev_queue_xmit(skb);
874 } else {
875 if (net_ratelimit()) {
876 printk(KERN_DEBUG "%s: dropped TX "
877 "filtered frame queue_len=%d "
878 "PS=%d @%lu\n",
Johannes Bergdd1cd4c2007-09-18 17:29:20 -0400879 wiphy_name(local->hw.wiphy),
Jiri Bencf0706e82007-05-05 11:45:53 -0700880 skb_queue_len(
881 &sta->tx_filtered),
882 !!(sta->flags & WLAN_STA_PS),
883 jiffies);
884 }
885 dev_kfree_skb(skb);
886 }
887 sta_info_put(sta);
888 return;
889 }
Mattias Nissler1abbe492007-12-20 13:50:07 +0100890 } else
891 rate_control_tx_status(local->mdev, skb, status);
Jiri Bencf0706e82007-05-05 11:45:53 -0700892
893 ieee80211_led_tx(local, 0);
894
895 /* SNMP counters
896 * Fragments are passed to low-level drivers as separate skbs, so these
897 * are actually fragments, not frames. Update frame counters only for
898 * the first fragment of the frame. */
899
900 frag = le16_to_cpu(hdr->seq_ctrl) & IEEE80211_SCTL_FRAG;
901 type = le16_to_cpu(hdr->frame_control) & IEEE80211_FCTL_FTYPE;
902
903 if (status->flags & IEEE80211_TX_STATUS_ACK) {
904 if (frag == 0) {
905 local->dot11TransmittedFrameCount++;
906 if (is_multicast_ether_addr(hdr->addr1))
907 local->dot11MulticastTransmittedFrameCount++;
908 if (status->retry_count > 0)
909 local->dot11RetryCount++;
910 if (status->retry_count > 1)
911 local->dot11MultipleRetryCount++;
912 }
913
914 /* This counter shall be incremented for an acknowledged MPDU
915 * with an individual address in the address 1 field or an MPDU
916 * with a multicast address in the address 1 field of type Data
917 * or Management. */
918 if (!is_multicast_ether_addr(hdr->addr1) ||
919 type == IEEE80211_FTYPE_DATA ||
920 type == IEEE80211_FTYPE_MGMT)
921 local->dot11TransmittedFragmentCount++;
922 } else {
923 if (frag == 0)
924 local->dot11FailedCount++;
925 }
926
Johannes Bergb306f452007-07-10 19:32:08 +0200927 /* this was a transmitted frame, but now we want to reuse it */
928 skb_orphan(skb);
929
Johannes Bergb306f452007-07-10 19:32:08 +0200930 if (!local->monitors) {
Jiri Bencf0706e82007-05-05 11:45:53 -0700931 dev_kfree_skb(skb);
932 return;
933 }
Jiri Bencf0706e82007-05-05 11:45:53 -0700934
Johannes Bergb306f452007-07-10 19:32:08 +0200935 /* send frame to monitor interfaces now */
936
937 if (skb_headroom(skb) < sizeof(*rthdr)) {
938 printk(KERN_ERR "ieee80211_tx_status: headroom too small\n");
939 dev_kfree_skb(skb);
940 return;
941 }
942
943 rthdr = (struct ieee80211_tx_status_rtap_hdr*)
944 skb_push(skb, sizeof(*rthdr));
945
946 memset(rthdr, 0, sizeof(*rthdr));
947 rthdr->hdr.it_len = cpu_to_le16(sizeof(*rthdr));
948 rthdr->hdr.it_present =
949 cpu_to_le32((1 << IEEE80211_RADIOTAP_TX_FLAGS) |
950 (1 << IEEE80211_RADIOTAP_DATA_RETRIES));
951
952 if (!(status->flags & IEEE80211_TX_STATUS_ACK) &&
953 !is_multicast_ether_addr(hdr->addr1))
954 rthdr->tx_flags |= cpu_to_le16(IEEE80211_RADIOTAP_F_TX_FAIL);
955
956 if ((status->control.flags & IEEE80211_TXCTL_USE_RTS_CTS) &&
957 (status->control.flags & IEEE80211_TXCTL_USE_CTS_PROTECT))
958 rthdr->tx_flags |= cpu_to_le16(IEEE80211_RADIOTAP_F_TX_CTS);
959 else if (status->control.flags & IEEE80211_TXCTL_USE_RTS_CTS)
960 rthdr->tx_flags |= cpu_to_le16(IEEE80211_RADIOTAP_F_TX_RTS);
961
962 rthdr->data_retries = status->retry_count;
963
Johannes Berg79010422007-09-18 17:29:21 -0400964 rcu_read_lock();
Johannes Bergb306f452007-07-10 19:32:08 +0200965 monitors = local->monitors;
Johannes Berg79010422007-09-18 17:29:21 -0400966 list_for_each_entry_rcu(sdata, &local->interfaces, list) {
Johannes Bergb306f452007-07-10 19:32:08 +0200967 /*
968 * Using the monitors counter is possibly racy, but
969 * if the value is wrong we simply either clone the skb
970 * once too much or forget sending it to one monitor iface
971 * The latter case isn't nice but fixing the race is much
972 * more complicated.
973 */
974 if (!monitors || !skb)
975 goto out;
976
Johannes Berg51fb61e2007-12-19 01:31:27 +0100977 if (sdata->vif.type == IEEE80211_IF_TYPE_MNTR) {
Johannes Bergb306f452007-07-10 19:32:08 +0200978 if (!netif_running(sdata->dev))
979 continue;
980 monitors--;
981 if (monitors)
Johannes Berg79010422007-09-18 17:29:21 -0400982 skb2 = skb_clone(skb, GFP_ATOMIC);
Johannes Bergb306f452007-07-10 19:32:08 +0200983 else
984 skb2 = NULL;
985 skb->dev = sdata->dev;
986 /* XXX: is this sufficient for BPF? */
987 skb_set_mac_header(skb, 0);
988 skb->ip_summed = CHECKSUM_UNNECESSARY;
989 skb->pkt_type = PACKET_OTHERHOST;
990 skb->protocol = htons(ETH_P_802_2);
991 memset(skb->cb, 0, sizeof(skb->cb));
992 netif_rx(skb);
993 skb = skb2;
Johannes Bergb306f452007-07-10 19:32:08 +0200994 }
995 }
996 out:
Johannes Berg79010422007-09-18 17:29:21 -0400997 rcu_read_unlock();
Johannes Bergb306f452007-07-10 19:32:08 +0200998 if (skb)
999 dev_kfree_skb(skb);
Jiri Bencf0706e82007-05-05 11:45:53 -07001000}
1001EXPORT_SYMBOL(ieee80211_tx_status);
1002
Jiri Bencf0706e82007-05-05 11:45:53 -07001003struct ieee80211_hw *ieee80211_alloc_hw(size_t priv_data_len,
1004 const struct ieee80211_ops *ops)
1005{
1006 struct net_device *mdev;
1007 struct ieee80211_local *local;
1008 struct ieee80211_sub_if_data *sdata;
1009 int priv_size;
1010 struct wiphy *wiphy;
1011
1012 /* Ensure 32-byte alignment of our private data and hw private data.
1013 * We use the wiphy priv data for both our ieee80211_local and for
1014 * the driver's private data
1015 *
1016 * In memory it'll be like this:
1017 *
1018 * +-------------------------+
1019 * | struct wiphy |
1020 * +-------------------------+
1021 * | struct ieee80211_local |
1022 * +-------------------------+
1023 * | driver's private data |
1024 * +-------------------------+
1025 *
1026 */
1027 priv_size = ((sizeof(struct ieee80211_local) +
1028 NETDEV_ALIGN_CONST) & ~NETDEV_ALIGN_CONST) +
1029 priv_data_len;
1030
1031 wiphy = wiphy_new(&mac80211_config_ops, priv_size);
1032
1033 if (!wiphy)
1034 return NULL;
1035
1036 wiphy->privid = mac80211_wiphy_privid;
1037
1038 local = wiphy_priv(wiphy);
1039 local->hw.wiphy = wiphy;
1040
1041 local->hw.priv = (char *)local +
1042 ((sizeof(struct ieee80211_local) +
1043 NETDEV_ALIGN_CONST) & ~NETDEV_ALIGN_CONST);
1044
Johannes Berg4480f15c2007-07-10 19:32:10 +02001045 BUG_ON(!ops->tx);
Johannes Berg4150c572007-09-17 01:29:23 -04001046 BUG_ON(!ops->start);
1047 BUG_ON(!ops->stop);
Johannes Berg4480f15c2007-07-10 19:32:10 +02001048 BUG_ON(!ops->config);
1049 BUG_ON(!ops->add_interface);
Johannes Berg4150c572007-09-17 01:29:23 -04001050 BUG_ON(!ops->remove_interface);
1051 BUG_ON(!ops->configure_filter);
Jiri Bencf0706e82007-05-05 11:45:53 -07001052 local->ops = ops;
1053
1054 /* for now, mdev needs sub_if_data :/ */
1055 mdev = alloc_netdev(sizeof(struct ieee80211_sub_if_data),
1056 "wmaster%d", ether_setup);
1057 if (!mdev) {
1058 wiphy_free(wiphy);
1059 return NULL;
1060 }
1061
1062 sdata = IEEE80211_DEV_TO_SUB_IF(mdev);
1063 mdev->ieee80211_ptr = &sdata->wdev;
1064 sdata->wdev.wiphy = wiphy;
1065
1066 local->hw.queues = 1; /* default */
1067
1068 local->mdev = mdev;
1069 local->rx_pre_handlers = ieee80211_rx_pre_handlers;
1070 local->rx_handlers = ieee80211_rx_handlers;
1071 local->tx_handlers = ieee80211_tx_handlers;
1072
1073 local->bridge_packets = 1;
1074
1075 local->rts_threshold = IEEE80211_MAX_RTS_THRESHOLD;
1076 local->fragmentation_threshold = IEEE80211_MAX_FRAG_THRESHOLD;
1077 local->short_retry_limit = 7;
1078 local->long_retry_limit = 4;
1079 local->hw.conf.radio_enabled = 1;
Jiri Bencf0706e82007-05-05 11:45:53 -07001080
Johannes Bergb708e612007-09-14 11:10:25 -04001081 local->enabled_modes = ~0;
Jiri Bencf0706e82007-05-05 11:45:53 -07001082
1083 INIT_LIST_HEAD(&local->modes_list);
1084
Johannes Berg79010422007-09-18 17:29:21 -04001085 INIT_LIST_HEAD(&local->interfaces);
Jiri Bencf0706e82007-05-05 11:45:53 -07001086
1087 INIT_DELAYED_WORK(&local->scan_work, ieee80211_sta_scan_work);
Jiri Bencf0706e82007-05-05 11:45:53 -07001088 ieee80211_rx_bss_list_init(mdev);
1089
1090 sta_info_init(local);
1091
1092 mdev->hard_start_xmit = ieee80211_master_start_xmit;
1093 mdev->open = ieee80211_master_open;
1094 mdev->stop = ieee80211_master_stop;
1095 mdev->type = ARPHRD_IEEE80211;
Stephen Hemminger3b04ddd2007-10-09 01:40:57 -07001096 mdev->header_ops = &ieee80211_header_ops;
Johannes Berg4150c572007-09-17 01:29:23 -04001097 mdev->set_multicast_list = ieee80211_master_set_multicast_list;
Jiri Bencf0706e82007-05-05 11:45:53 -07001098
Johannes Berg51fb61e2007-12-19 01:31:27 +01001099 sdata->vif.type = IEEE80211_IF_TYPE_AP;
Jiri Bencf0706e82007-05-05 11:45:53 -07001100 sdata->dev = mdev;
1101 sdata->local = local;
1102 sdata->u.ap.force_unicast_rateidx = -1;
1103 sdata->u.ap.max_ratectrl_rateidx = -1;
1104 ieee80211_if_sdata_init(sdata);
Johannes Berg79010422007-09-18 17:29:21 -04001105 /* no RCU needed since we're still during init phase */
1106 list_add_tail(&sdata->list, &local->interfaces);
Jiri Bencf0706e82007-05-05 11:45:53 -07001107
1108 tasklet_init(&local->tx_pending_tasklet, ieee80211_tx_pending,
1109 (unsigned long)local);
1110 tasklet_disable(&local->tx_pending_tasklet);
1111
1112 tasklet_init(&local->tasklet,
1113 ieee80211_tasklet_handler,
1114 (unsigned long) local);
1115 tasklet_disable(&local->tasklet);
1116
1117 skb_queue_head_init(&local->skb_queue);
1118 skb_queue_head_init(&local->skb_queue_unreliable);
1119
1120 return local_to_hw(local);
1121}
1122EXPORT_SYMBOL(ieee80211_alloc_hw);
1123
1124int ieee80211_register_hw(struct ieee80211_hw *hw)
1125{
1126 struct ieee80211_local *local = hw_to_local(hw);
1127 const char *name;
1128 int result;
1129
1130 result = wiphy_register(local->hw.wiphy);
1131 if (result < 0)
1132 return result;
1133
1134 name = wiphy_dev(local->hw.wiphy)->driver->name;
1135 local->hw.workqueue = create_singlethread_workqueue(name);
1136 if (!local->hw.workqueue) {
1137 result = -ENOMEM;
1138 goto fail_workqueue;
1139 }
1140
Johannes Bergb306f452007-07-10 19:32:08 +02001141 /*
1142 * The hardware needs headroom for sending the frame,
1143 * and we need some headroom for passing the frame to monitor
1144 * interfaces, but never both at the same time.
1145 */
Jiri Benc33ccad32007-07-18 17:10:44 +02001146 local->tx_headroom = max_t(unsigned int , local->hw.extra_tx_headroom,
1147 sizeof(struct ieee80211_tx_status_rtap_hdr));
Johannes Bergb306f452007-07-10 19:32:08 +02001148
Jiri Bence9f207f2007-05-05 11:46:38 -07001149 debugfs_hw_add(local);
1150
Jiri Bencf0706e82007-05-05 11:45:53 -07001151 local->hw.conf.beacon_int = 1000;
1152
1153 local->wstats_flags |= local->hw.max_rssi ?
1154 IW_QUAL_LEVEL_UPDATED : IW_QUAL_LEVEL_INVALID;
1155 local->wstats_flags |= local->hw.max_signal ?
1156 IW_QUAL_QUAL_UPDATED : IW_QUAL_QUAL_INVALID;
1157 local->wstats_flags |= local->hw.max_noise ?
1158 IW_QUAL_NOISE_UPDATED : IW_QUAL_NOISE_INVALID;
1159 if (local->hw.max_rssi < 0 || local->hw.max_noise < 0)
1160 local->wstats_flags |= IW_QUAL_DBM;
1161
1162 result = sta_info_start(local);
1163 if (result < 0)
1164 goto fail_sta_info;
1165
1166 rtnl_lock();
1167 result = dev_alloc_name(local->mdev, local->mdev->name);
1168 if (result < 0)
1169 goto fail_dev;
1170
1171 memcpy(local->mdev->dev_addr, local->hw.wiphy->perm_addr, ETH_ALEN);
1172 SET_NETDEV_DEV(local->mdev, wiphy_dev(local->hw.wiphy));
1173
1174 result = register_netdevice(local->mdev);
1175 if (result < 0)
1176 goto fail_dev;
1177
Jiri Bence9f207f2007-05-05 11:46:38 -07001178 ieee80211_debugfs_add_netdev(IEEE80211_DEV_TO_SUB_IF(local->mdev));
Johannes Berg5b2812e2007-09-26 14:27:23 +02001179 ieee80211_if_set_type(local->mdev, IEEE80211_IF_TYPE_AP);
Jiri Bence9f207f2007-05-05 11:46:38 -07001180
Johannes Berg830f9032007-10-28 14:51:05 +01001181 result = ieee80211_init_rate_ctrl_alg(local,
1182 hw->rate_control_algorithm);
Jiri Bencf0706e82007-05-05 11:45:53 -07001183 if (result < 0) {
1184 printk(KERN_DEBUG "%s: Failed to initialize rate control "
Johannes Bergdd1cd4c2007-09-18 17:29:20 -04001185 "algorithm\n", wiphy_name(local->hw.wiphy));
Jiri Bencf0706e82007-05-05 11:45:53 -07001186 goto fail_rate;
1187 }
1188
1189 result = ieee80211_wep_init(local);
1190
1191 if (result < 0) {
1192 printk(KERN_DEBUG "%s: Failed to initialize wep\n",
Johannes Bergdd1cd4c2007-09-18 17:29:20 -04001193 wiphy_name(local->hw.wiphy));
Jiri Bencf0706e82007-05-05 11:45:53 -07001194 goto fail_wep;
1195 }
1196
1197 ieee80211_install_qdisc(local->mdev);
1198
1199 /* add one default STA interface */
1200 result = ieee80211_if_add(local->mdev, "wlan%d", NULL,
1201 IEEE80211_IF_TYPE_STA);
1202 if (result)
1203 printk(KERN_WARNING "%s: Failed to add default virtual iface\n",
Johannes Bergdd1cd4c2007-09-18 17:29:20 -04001204 wiphy_name(local->hw.wiphy));
Jiri Bencf0706e82007-05-05 11:45:53 -07001205
1206 local->reg_state = IEEE80211_DEV_REGISTERED;
1207 rtnl_unlock();
1208
1209 ieee80211_led_init(local);
1210
1211 return 0;
1212
1213fail_wep:
1214 rate_control_deinitialize(local);
1215fail_rate:
Jiri Bence9f207f2007-05-05 11:46:38 -07001216 ieee80211_debugfs_remove_netdev(IEEE80211_DEV_TO_SUB_IF(local->mdev));
Jiri Bencf0706e82007-05-05 11:45:53 -07001217 unregister_netdevice(local->mdev);
1218fail_dev:
1219 rtnl_unlock();
1220 sta_info_stop(local);
1221fail_sta_info:
Jiri Bence9f207f2007-05-05 11:46:38 -07001222 debugfs_hw_del(local);
Jiri Bencf0706e82007-05-05 11:45:53 -07001223 destroy_workqueue(local->hw.workqueue);
1224fail_workqueue:
1225 wiphy_unregister(local->hw.wiphy);
1226 return result;
1227}
1228EXPORT_SYMBOL(ieee80211_register_hw);
1229
1230int ieee80211_register_hwmode(struct ieee80211_hw *hw,
1231 struct ieee80211_hw_mode *mode)
1232{
1233 struct ieee80211_local *local = hw_to_local(hw);
1234 struct ieee80211_rate *rate;
1235 int i;
1236
1237 INIT_LIST_HEAD(&mode->list);
1238 list_add_tail(&mode->list, &local->modes_list);
1239
1240 local->hw_modes |= (1 << mode->mode);
1241 for (i = 0; i < mode->num_rates; i++) {
1242 rate = &(mode->rates[i]);
1243 rate->rate_inv = CHAN_UTIL_RATE_LCM / rate->rate;
1244 }
1245 ieee80211_prepare_rates(local, mode);
1246
1247 if (!local->oper_hw_mode) {
1248 /* Default to this mode */
1249 local->hw.conf.phymode = mode->mode;
1250 local->oper_hw_mode = local->scan_hw_mode = mode;
1251 local->oper_channel = local->scan_channel = &mode->channels[0];
1252 local->hw.conf.mode = local->oper_hw_mode;
1253 local->hw.conf.chan = local->oper_channel;
1254 }
1255
1256 if (!(hw->flags & IEEE80211_HW_DEFAULT_REG_DOMAIN_CONFIGURED))
Daniel Drakefd8bacc2007-06-09 19:07:14 +01001257 ieee80211_set_default_regdomain(mode);
Jiri Bencf0706e82007-05-05 11:45:53 -07001258
1259 return 0;
1260}
1261EXPORT_SYMBOL(ieee80211_register_hwmode);
1262
1263void ieee80211_unregister_hw(struct ieee80211_hw *hw)
1264{
1265 struct ieee80211_local *local = hw_to_local(hw);
1266 struct ieee80211_sub_if_data *sdata, *tmp;
Jiri Bencf0706e82007-05-05 11:45:53 -07001267 int i;
1268
1269 tasklet_kill(&local->tx_pending_tasklet);
1270 tasklet_kill(&local->tasklet);
1271
1272 rtnl_lock();
1273
1274 BUG_ON(local->reg_state != IEEE80211_DEV_REGISTERED);
1275
1276 local->reg_state = IEEE80211_DEV_UNREGISTERED;
Jiri Bencf0706e82007-05-05 11:45:53 -07001277
Johannes Berg79010422007-09-18 17:29:21 -04001278 /*
1279 * At this point, interface list manipulations are fine
1280 * because the driver cannot be handing us frames any
1281 * more and the tasklet is killed.
1282 */
Johannes Berg5b2812e2007-09-26 14:27:23 +02001283
1284 /*
1285 * First, we remove all non-master interfaces. Do this because they
1286 * may have bss pointer dependency on the master, and when we free
1287 * the master these would be freed as well, breaking our list
1288 * iteration completely.
1289 */
1290 list_for_each_entry_safe(sdata, tmp, &local->interfaces, list) {
1291 if (sdata->dev == local->mdev)
1292 continue;
1293 list_del(&sdata->list);
Jiri Bencf0706e82007-05-05 11:45:53 -07001294 __ieee80211_if_del(local, sdata);
Johannes Berg5b2812e2007-09-26 14:27:23 +02001295 }
1296
1297 /* then, finally, remove the master interface */
1298 __ieee80211_if_del(local, IEEE80211_DEV_TO_SUB_IF(local->mdev));
Jiri Bencf0706e82007-05-05 11:45:53 -07001299
1300 rtnl_unlock();
1301
Jiri Bencf0706e82007-05-05 11:45:53 -07001302 ieee80211_rx_bss_list_deinit(local->mdev);
1303 ieee80211_clear_tx_pending(local);
1304 sta_info_stop(local);
1305 rate_control_deinitialize(local);
Jiri Bence9f207f2007-05-05 11:46:38 -07001306 debugfs_hw_del(local);
Jiri Bencf0706e82007-05-05 11:45:53 -07001307
1308 for (i = 0; i < NUM_IEEE80211_MODES; i++) {
1309 kfree(local->supp_rates[i]);
1310 kfree(local->basic_rates[i]);
1311 }
1312
1313 if (skb_queue_len(&local->skb_queue)
1314 || skb_queue_len(&local->skb_queue_unreliable))
1315 printk(KERN_WARNING "%s: skb_queue not empty\n",
Johannes Bergdd1cd4c2007-09-18 17:29:20 -04001316 wiphy_name(local->hw.wiphy));
Jiri Bencf0706e82007-05-05 11:45:53 -07001317 skb_queue_purge(&local->skb_queue);
1318 skb_queue_purge(&local->skb_queue_unreliable);
1319
1320 destroy_workqueue(local->hw.workqueue);
1321 wiphy_unregister(local->hw.wiphy);
1322 ieee80211_wep_free(local);
1323 ieee80211_led_exit(local);
1324}
1325EXPORT_SYMBOL(ieee80211_unregister_hw);
1326
1327void ieee80211_free_hw(struct ieee80211_hw *hw)
1328{
1329 struct ieee80211_local *local = hw_to_local(hw);
1330
1331 ieee80211_if_free(local->mdev);
1332 wiphy_free(local->hw.wiphy);
1333}
1334EXPORT_SYMBOL(ieee80211_free_hw);
1335
Jiri Bencf0706e82007-05-05 11:45:53 -07001336static int __init ieee80211_init(void)
1337{
1338 struct sk_buff *skb;
1339 int ret;
1340
1341 BUILD_BUG_ON(sizeof(struct ieee80211_tx_packet_data) > sizeof(skb->cb));
1342
Johannes Berg4b475892008-01-02 15:17:03 +01001343 ret = rc80211_simple_init();
Johannes Bergac71c692007-10-28 14:17:44 +01001344 if (ret)
Mattias Nisslerad018372007-12-19 01:25:57 +01001345 goto fail;
Mattias Nisslerad018372007-12-19 01:25:57 +01001346
Johannes Berg4b475892008-01-02 15:17:03 +01001347 ret = rc80211_pid_init();
Mattias Nisslerad018372007-12-19 01:25:57 +01001348 if (ret)
Johannes Berg4b475892008-01-02 15:17:03 +01001349 goto fail_simple;
Johannes Bergac71c692007-10-28 14:17:44 +01001350
Jiri Bencf0706e82007-05-05 11:45:53 -07001351 ret = ieee80211_wme_register();
1352 if (ret) {
1353 printk(KERN_DEBUG "ieee80211_init: failed to "
1354 "initialize WME (err=%d)\n", ret);
Johannes Berg4b475892008-01-02 15:17:03 +01001355 goto fail_pid;
Jiri Bencf0706e82007-05-05 11:45:53 -07001356 }
1357
Jiri Bence9f207f2007-05-05 11:46:38 -07001358 ieee80211_debugfs_netdev_init();
Daniel Drakefd8bacc2007-06-09 19:07:14 +01001359 ieee80211_regdomain_init();
Jiri Bence9f207f2007-05-05 11:46:38 -07001360
Jiri Bencf0706e82007-05-05 11:45:53 -07001361 return 0;
Mattias Nisslerad018372007-12-19 01:25:57 +01001362
Johannes Berg4b475892008-01-02 15:17:03 +01001363 fail_pid:
1364 rc80211_simple_exit();
1365 fail_simple:
1366 rc80211_pid_exit();
1367 fail:
Mattias Nisslerad018372007-12-19 01:25:57 +01001368 return ret;
Jiri Bencf0706e82007-05-05 11:45:53 -07001369}
1370
Jiri Bencf0706e82007-05-05 11:45:53 -07001371static void __exit ieee80211_exit(void)
1372{
Johannes Berg4b475892008-01-02 15:17:03 +01001373 rc80211_simple_exit();
1374 rc80211_pid_exit();
Johannes Bergac71c692007-10-28 14:17:44 +01001375
Jiri Bencf0706e82007-05-05 11:45:53 -07001376 ieee80211_wme_unregister();
Jiri Bence9f207f2007-05-05 11:46:38 -07001377 ieee80211_debugfs_netdev_exit();
Jiri Bencf0706e82007-05-05 11:45:53 -07001378}
1379
1380
Johannes Bergca9938f2007-09-11 12:50:32 +02001381subsys_initcall(ieee80211_init);
Jiri Bencf0706e82007-05-05 11:45:53 -07001382module_exit(ieee80211_exit);
1383
1384MODULE_DESCRIPTION("IEEE 802.11 subsystem");
1385MODULE_LICENSE("GPL");