2 * Copyright 2002-2005, Instant802 Networks, Inc.
3 * Copyright 2005-2006, Devicescape Software, Inc.
4 * Copyright 2006-2007 Jiri Benc <jbenc@suse.cz>
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.
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>
23 #include <linux/bitmap.h>
24 #include <net/net_namespace.h>
25 #include <net/cfg80211.h>
27 #include "ieee80211_common.h"
28 #include "ieee80211_i.h"
29 #include "ieee80211_rate.h"
33 #include "ieee80211_led.h"
34 #include "ieee80211_cfg.h"
36 #include "debugfs_netdev.h"
39 * For seeing transmitted packets on monitor interfaces
40 * we have a radiotap header too.
42 struct ieee80211_tx_status_rtap_hdr {
43 struct ieee80211_radiotap_header hdr;
46 } __attribute__ ((packed));
48 /* common interface routines */
50 static int header_parse_80211(struct sk_buff *skb, unsigned char *haddr)
52 memcpy(haddr, skb_mac_header(skb) + 10, ETH_ALEN); /* addr2 */
56 /* master interface */
58 static int ieee80211_master_open(struct net_device *dev)
60 struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr);
61 struct ieee80211_sub_if_data *sdata;
62 int res = -EOPNOTSUPP;
64 read_lock(&local->sub_if_lock);
65 list_for_each_entry(sdata, &local->sub_if_list, list) {
66 if (sdata->dev != dev && netif_running(sdata->dev)) {
71 read_unlock(&local->sub_if_lock);
75 static int ieee80211_master_stop(struct net_device *dev)
77 struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr);
78 struct ieee80211_sub_if_data *sdata;
80 read_lock(&local->sub_if_lock);
81 list_for_each_entry(sdata, &local->sub_if_list, list)
82 if (sdata->dev != dev && netif_running(sdata->dev))
83 dev_close(sdata->dev);
84 read_unlock(&local->sub_if_lock);
89 /* management interface */
92 ieee80211_fill_frame_info(struct ieee80211_local *local,
93 struct ieee80211_frame_info *fi,
94 struct ieee80211_rx_status *status)
98 struct ieee80211_rate *rate;
100 jiffies_to_timespec(jiffies, &ts);
101 fi->hosttime = cpu_to_be64((u64) ts.tv_sec * 1000000 +
103 fi->mactime = cpu_to_be64(status->mactime);
104 switch (status->phymode) {
105 case MODE_IEEE80211A:
106 fi->phytype = htonl(ieee80211_phytype_ofdm_dot11_a);
108 case MODE_IEEE80211B:
109 fi->phytype = htonl(ieee80211_phytype_dsss_dot11_b);
111 case MODE_IEEE80211G:
112 fi->phytype = htonl(ieee80211_phytype_pbcc_dot11_g);
115 fi->phytype = htonl(0xAAAAAAAA);
118 fi->channel = htonl(status->channel);
119 rate = ieee80211_get_rate(local, status->phymode,
122 fi->datarate = htonl(rate->rate);
123 if (rate->flags & IEEE80211_RATE_PREAMBLE2) {
124 if (status->rate == rate->val)
125 fi->preamble = htonl(2); /* long */
126 else if (status->rate == rate->val2)
127 fi->preamble = htonl(1); /* short */
129 fi->preamble = htonl(0);
131 fi->datarate = htonl(0);
132 fi->preamble = htonl(0);
135 fi->antenna = htonl(status->antenna);
136 fi->priority = htonl(0xffffffff); /* no clue */
137 fi->ssi_type = htonl(ieee80211_ssi_raw);
138 fi->ssi_signal = htonl(status->ssi);
139 fi->ssi_noise = 0x00000000;
142 /* clear everything because we really don't know.
143 * the msg_type field isn't present on monitor frames
144 * so we don't know whether it will be present or not,
145 * but it's ok to not clear it since it'll be assigned
147 memset(fi, 0, sizeof(*fi) - sizeof(fi->msg_type));
149 fi->ssi_type = htonl(ieee80211_ssi_none);
151 fi->version = htonl(IEEE80211_FI_VERSION);
152 fi->length = cpu_to_be32(sizeof(*fi) - sizeof(fi->msg_type));
155 /* this routine is actually not just for this, but also
156 * for pushing fake 'management' frames into userspace.
157 * it shall be replaced by a netlink-based system. */
159 ieee80211_rx_mgmt(struct ieee80211_local *local, struct sk_buff *skb,
160 struct ieee80211_rx_status *status, u32 msg_type)
162 struct ieee80211_frame_info *fi;
163 const size_t hlen = sizeof(struct ieee80211_frame_info);
164 struct net_device *dev = local->apdev;
168 if (skb_headroom(skb) < hlen) {
169 I802_DEBUG_INC(local->rx_expand_skb_head);
170 if (pskb_expand_head(skb, hlen, 0, GFP_ATOMIC)) {
176 fi = (struct ieee80211_frame_info *) skb_push(skb, hlen);
178 ieee80211_fill_frame_info(local, fi, status);
179 fi->msg_type = htonl(msg_type);
181 dev->stats.rx_packets++;
182 dev->stats.rx_bytes += skb->len;
184 skb_set_mac_header(skb, 0);
185 skb->ip_summed = CHECKSUM_UNNECESSARY;
186 skb->pkt_type = PACKET_OTHERHOST;
187 skb->protocol = htons(ETH_P_802_2);
188 memset(skb->cb, 0, sizeof(skb->cb));
192 void ieee80211_key_threshold_notify(struct net_device *dev,
193 struct ieee80211_key *key,
194 struct sta_info *sta)
196 struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr);
198 struct ieee80211_msg_key_notification *msg;
200 /* if no one will get it anyway, don't even allocate it.
201 * unlikely because this is only relevant for APs
202 * where the device must be open... */
203 if (unlikely(!local->apdev))
206 skb = dev_alloc_skb(sizeof(struct ieee80211_frame_info) +
207 sizeof(struct ieee80211_msg_key_notification));
211 skb_reserve(skb, sizeof(struct ieee80211_frame_info));
212 msg = (struct ieee80211_msg_key_notification *)
213 skb_put(skb, sizeof(struct ieee80211_msg_key_notification));
214 msg->tx_rx_count = key->tx_rx_count;
215 memcpy(msg->ifname, dev->name, IFNAMSIZ);
217 memcpy(msg->addr, sta->addr, ETH_ALEN);
219 memset(msg->addr, 0xff, ETH_ALEN);
221 key->tx_rx_count = 0;
223 ieee80211_rx_mgmt(local, skb, NULL,
224 ieee80211_msg_key_threshold_notification);
227 static int ieee80211_mgmt_open(struct net_device *dev)
229 struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr);
231 if (!netif_running(local->mdev))
236 static int ieee80211_mgmt_stop(struct net_device *dev)
241 static int ieee80211_change_mtu_apdev(struct net_device *dev, int new_mtu)
243 /* FIX: what would be proper limits for MTU?
244 * This interface uses 802.11 frames. */
245 if (new_mtu < 256 || new_mtu > IEEE80211_MAX_DATA_LEN) {
246 printk(KERN_WARNING "%s: invalid MTU %d\n",
251 #ifdef CONFIG_MAC80211_VERBOSE_DEBUG
252 printk(KERN_DEBUG "%s: setting MTU %d\n", dev->name, new_mtu);
253 #endif /* CONFIG_MAC80211_VERBOSE_DEBUG */
258 void ieee80211_if_mgmt_setup(struct net_device *dev)
261 dev->hard_start_xmit = ieee80211_mgmt_start_xmit;
262 dev->change_mtu = ieee80211_change_mtu_apdev;
263 dev->open = ieee80211_mgmt_open;
264 dev->stop = ieee80211_mgmt_stop;
265 dev->type = ARPHRD_IEEE80211_PRISM;
266 dev->hard_header_parse = header_parse_80211;
267 dev->uninit = ieee80211_if_reinit;
268 dev->destructor = ieee80211_if_free;
271 /* regular interfaces */
273 static int ieee80211_change_mtu(struct net_device *dev, int new_mtu)
275 /* FIX: what would be proper limits for MTU?
276 * This interface uses 802.3 frames. */
277 if (new_mtu < 256 || new_mtu > IEEE80211_MAX_DATA_LEN - 24 - 6) {
278 printk(KERN_WARNING "%s: invalid MTU %d\n",
283 #ifdef CONFIG_MAC80211_VERBOSE_DEBUG
284 printk(KERN_DEBUG "%s: setting MTU %d\n", dev->name, new_mtu);
285 #endif /* CONFIG_MAC80211_VERBOSE_DEBUG */
290 static inline int identical_mac_addr_allowed(int type1, int type2)
292 return (type1 == IEEE80211_IF_TYPE_MNTR ||
293 type2 == IEEE80211_IF_TYPE_MNTR ||
294 (type1 == IEEE80211_IF_TYPE_AP &&
295 type2 == IEEE80211_IF_TYPE_WDS) ||
296 (type1 == IEEE80211_IF_TYPE_WDS &&
297 (type2 == IEEE80211_IF_TYPE_WDS ||
298 type2 == IEEE80211_IF_TYPE_AP)) ||
299 (type1 == IEEE80211_IF_TYPE_AP &&
300 type2 == IEEE80211_IF_TYPE_VLAN) ||
301 (type1 == IEEE80211_IF_TYPE_VLAN &&
302 (type2 == IEEE80211_IF_TYPE_AP ||
303 type2 == IEEE80211_IF_TYPE_VLAN)));
306 /* Check if running monitor interfaces should go to a "soft monitor" mode
307 * and switch them if necessary. */
308 static inline void ieee80211_start_soft_monitor(struct ieee80211_local *local)
310 struct ieee80211_if_init_conf conf;
312 if (local->open_count && local->open_count == local->monitors &&
313 !(local->hw.flags & IEEE80211_HW_MONITOR_DURING_OPER) &&
314 local->ops->remove_interface) {
316 conf.type = IEEE80211_IF_TYPE_MNTR;
317 conf.mac_addr = NULL;
318 local->ops->remove_interface(local_to_hw(local), &conf);
322 /* Check if running monitor interfaces should go to a "hard monitor" mode
323 * and switch them if necessary. */
324 static void ieee80211_start_hard_monitor(struct ieee80211_local *local)
326 struct ieee80211_if_init_conf conf;
328 if (local->open_count && local->open_count == local->monitors &&
329 !(local->hw.flags & IEEE80211_HW_MONITOR_DURING_OPER)) {
331 conf.type = IEEE80211_IF_TYPE_MNTR;
332 conf.mac_addr = NULL;
333 local->ops->add_interface(local_to_hw(local), &conf);
337 static void ieee80211_if_open(struct net_device *dev)
339 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
341 switch (sdata->type) {
342 case IEEE80211_IF_TYPE_STA:
343 case IEEE80211_IF_TYPE_IBSS:
344 sdata->u.sta.flags &= ~IEEE80211_STA_PREV_BSSID_SET;
349 static int ieee80211_open(struct net_device *dev)
351 struct ieee80211_sub_if_data *sdata, *nsdata;
352 struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr);
353 struct ieee80211_if_init_conf conf;
356 sdata = IEEE80211_DEV_TO_SUB_IF(dev);
357 read_lock(&local->sub_if_lock);
358 list_for_each_entry(nsdata, &local->sub_if_list, list) {
359 struct net_device *ndev = nsdata->dev;
361 if (ndev != dev && ndev != local->mdev && netif_running(ndev) &&
362 compare_ether_addr(dev->dev_addr, ndev->dev_addr) == 0 &&
363 !identical_mac_addr_allowed(sdata->type, nsdata->type)) {
364 read_unlock(&local->sub_if_lock);
368 read_unlock(&local->sub_if_lock);
370 if (sdata->type == IEEE80211_IF_TYPE_WDS &&
371 is_zero_ether_addr(sdata->u.wds.remote_addr))
374 if (sdata->type == IEEE80211_IF_TYPE_MNTR && local->open_count &&
375 !(local->hw.flags & IEEE80211_HW_MONITOR_DURING_OPER)) {
376 /* run the interface in a "soft monitor" mode */
379 local->hw.conf.flags |= IEEE80211_CONF_RADIOTAP;
382 ieee80211_if_open(dev);
383 ieee80211_start_soft_monitor(local);
385 conf.if_id = dev->ifindex;
386 conf.type = sdata->type;
387 if (sdata->type == IEEE80211_IF_TYPE_MNTR)
388 conf.mac_addr = NULL;
390 conf.mac_addr = dev->dev_addr;
391 res = local->ops->add_interface(local_to_hw(local), &conf);
393 if (sdata->type == IEEE80211_IF_TYPE_MNTR)
394 ieee80211_start_hard_monitor(local);
398 if (local->open_count == 0) {
400 tasklet_enable(&local->tx_pending_tasklet);
401 tasklet_enable(&local->tasklet);
402 if (local->ops->open)
403 res = local->ops->open(local_to_hw(local));
405 res = dev_open(local->mdev);
407 if (local->ops->stop)
408 local->ops->stop(local_to_hw(local));
410 res = ieee80211_hw_config(local);
411 if (res && local->ops->stop)
412 local->ops->stop(local_to_hw(local));
413 else if (!res && local->apdev)
414 dev_open(local->apdev);
418 if (local->ops->remove_interface)
419 local->ops->remove_interface(local_to_hw(local),
426 if (sdata->type == IEEE80211_IF_TYPE_MNTR) {
428 local->hw.conf.flags |= IEEE80211_CONF_RADIOTAP;
430 ieee80211_if_config(dev);
431 ieee80211_reset_erp_info(dev);
432 ieee80211_enable_keys(sdata);
435 if (sdata->type == IEEE80211_IF_TYPE_STA &&
436 !local->user_space_mlme)
437 netif_carrier_off(dev);
439 netif_carrier_on(dev);
441 netif_start_queue(dev);
445 static void ieee80211_if_shutdown(struct net_device *dev)
447 struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr);
448 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
451 switch (sdata->type) {
452 case IEEE80211_IF_TYPE_STA:
453 case IEEE80211_IF_TYPE_IBSS:
454 sdata->u.sta.state = IEEE80211_DISABLED;
455 del_timer_sync(&sdata->u.sta.timer);
457 * Holding the sub_if_lock for writing here blocks
458 * out the receive path and makes sure it's not
459 * currently processing a packet that may get
460 * added to the queue.
462 write_lock_bh(&local->sub_if_lock);
463 skb_queue_purge(&sdata->u.sta.skb_queue);
464 write_unlock_bh(&local->sub_if_lock);
466 if (!local->ops->hw_scan &&
467 local->scan_dev == sdata->dev) {
468 local->sta_scanning = 0;
469 cancel_delayed_work(&local->scan_work);
471 flush_workqueue(local->hw.workqueue);
476 static int ieee80211_stop(struct net_device *dev)
478 struct ieee80211_sub_if_data *sdata;
479 struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr);
481 sdata = IEEE80211_DEV_TO_SUB_IF(dev);
483 if (sdata->type == IEEE80211_IF_TYPE_MNTR &&
484 local->open_count > 1 &&
485 !(local->hw.flags & IEEE80211_HW_MONITOR_DURING_OPER)) {
486 /* remove "soft monitor" interface */
489 if (!local->monitors)
490 local->hw.conf.flags &= ~IEEE80211_CONF_RADIOTAP;
494 netif_stop_queue(dev);
495 ieee80211_if_shutdown(dev);
497 if (sdata->type == IEEE80211_IF_TYPE_MNTR) {
499 if (!local->monitors)
500 local->hw.conf.flags &= ~IEEE80211_CONF_RADIOTAP;
502 /* disable all keys for as long as this netdev is down */
503 ieee80211_disable_keys(sdata);
507 if (local->open_count == 0) {
508 if (netif_running(local->mdev))
509 dev_close(local->mdev);
511 dev_close(local->apdev);
512 if (local->ops->stop)
513 local->ops->stop(local_to_hw(local));
514 tasklet_disable(&local->tx_pending_tasklet);
515 tasklet_disable(&local->tasklet);
517 if (local->ops->remove_interface) {
518 struct ieee80211_if_init_conf conf;
520 conf.if_id = dev->ifindex;
521 conf.type = sdata->type;
522 conf.mac_addr = dev->dev_addr;
523 local->ops->remove_interface(local_to_hw(local), &conf);
526 ieee80211_start_hard_monitor(local);
531 enum netif_tx_lock_class {
536 static inline void netif_tx_lock_nested(struct net_device *dev, int subclass)
538 spin_lock_nested(&dev->_xmit_lock, subclass);
539 dev->xmit_lock_owner = smp_processor_id();
542 static void ieee80211_set_multicast_list(struct net_device *dev)
544 struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr);
545 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
546 unsigned short flags;
548 netif_tx_lock_nested(local->mdev, TX_LOCK_MASTER);
549 if (((dev->flags & IFF_ALLMULTI) != 0) ^
550 ((sdata->flags & IEEE80211_SDATA_ALLMULTI) != 0)) {
551 if (sdata->flags & IEEE80211_SDATA_ALLMULTI)
552 local->iff_allmultis--;
554 local->iff_allmultis++;
555 sdata->flags ^= IEEE80211_SDATA_ALLMULTI;
557 if (((dev->flags & IFF_PROMISC) != 0) ^
558 ((sdata->flags & IEEE80211_SDATA_PROMISC) != 0)) {
559 if (sdata->flags & IEEE80211_SDATA_PROMISC)
560 local->iff_promiscs--;
562 local->iff_promiscs++;
563 sdata->flags ^= IEEE80211_SDATA_PROMISC;
565 if (dev->mc_count != sdata->mc_count) {
566 local->mc_count = local->mc_count - sdata->mc_count +
568 sdata->mc_count = dev->mc_count;
570 if (local->ops->set_multicast_list) {
571 flags = local->mdev->flags;
572 if (local->iff_allmultis)
573 flags |= IFF_ALLMULTI;
574 if (local->iff_promiscs)
575 flags |= IFF_PROMISC;
576 read_lock(&local->sub_if_lock);
577 local->ops->set_multicast_list(local_to_hw(local), flags,
579 read_unlock(&local->sub_if_lock);
581 netif_tx_unlock(local->mdev);
584 /* Must not be called for mdev and apdev */
585 void ieee80211_if_setup(struct net_device *dev)
588 dev->hard_start_xmit = ieee80211_subif_start_xmit;
589 dev->wireless_handlers = &ieee80211_iw_handler_def;
590 dev->set_multicast_list = ieee80211_set_multicast_list;
591 dev->change_mtu = ieee80211_change_mtu;
592 dev->open = ieee80211_open;
593 dev->stop = ieee80211_stop;
594 dev->uninit = ieee80211_if_reinit;
595 dev->destructor = ieee80211_if_free;
598 /* WDS specialties */
600 int ieee80211_if_update_wds(struct net_device *dev, u8 *remote_addr)
602 struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr);
603 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
604 struct sta_info *sta;
605 DECLARE_MAC_BUF(mac);
607 if (compare_ether_addr(remote_addr, sdata->u.wds.remote_addr) == 0)
610 /* Create STA entry for the new peer */
611 sta = sta_info_add(local, dev, remote_addr, GFP_KERNEL);
616 /* Remove STA entry for the old peer */
617 sta = sta_info_get(local, sdata->u.wds.remote_addr);
622 printk(KERN_DEBUG "%s: could not find STA entry for WDS link "
624 dev->name, print_mac(mac, sdata->u.wds.remote_addr));
627 /* Update WDS link data */
628 memcpy(&sdata->u.wds.remote_addr, remote_addr, ETH_ALEN);
633 /* everything else */
635 static int __ieee80211_if_config(struct net_device *dev,
636 struct sk_buff *beacon,
637 struct ieee80211_tx_control *control)
639 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
640 struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr);
641 struct ieee80211_if_conf conf;
642 static u8 scan_bssid[] = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff };
644 if (!local->ops->config_interface || !netif_running(dev))
647 memset(&conf, 0, sizeof(conf));
648 conf.type = sdata->type;
649 if (sdata->type == IEEE80211_IF_TYPE_STA ||
650 sdata->type == IEEE80211_IF_TYPE_IBSS) {
651 if (local->sta_scanning &&
652 local->scan_dev == dev)
653 conf.bssid = scan_bssid;
655 conf.bssid = sdata->u.sta.bssid;
656 conf.ssid = sdata->u.sta.ssid;
657 conf.ssid_len = sdata->u.sta.ssid_len;
658 conf.generic_elem = sdata->u.sta.extra_ie;
659 conf.generic_elem_len = sdata->u.sta.extra_ie_len;
660 } else if (sdata->type == IEEE80211_IF_TYPE_AP) {
661 conf.ssid = sdata->u.ap.ssid;
662 conf.ssid_len = sdata->u.ap.ssid_len;
663 conf.generic_elem = sdata->u.ap.generic_elem;
664 conf.generic_elem_len = sdata->u.ap.generic_elem_len;
665 conf.beacon = beacon;
666 conf.beacon_control = control;
668 return local->ops->config_interface(local_to_hw(local),
669 dev->ifindex, &conf);
672 int ieee80211_if_config(struct net_device *dev)
674 return __ieee80211_if_config(dev, NULL, NULL);
677 int ieee80211_if_config_beacon(struct net_device *dev)
679 struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr);
680 struct ieee80211_tx_control control;
683 if (!(local->hw.flags & IEEE80211_HW_HOST_GEN_BEACON_TEMPLATE))
685 skb = ieee80211_beacon_get(local_to_hw(local), dev->ifindex, &control);
688 return __ieee80211_if_config(dev, skb, &control);
691 int ieee80211_hw_config(struct ieee80211_local *local)
693 struct ieee80211_hw_mode *mode;
694 struct ieee80211_channel *chan;
697 if (local->sta_scanning) {
698 chan = local->scan_channel;
699 mode = local->scan_hw_mode;
701 chan = local->oper_channel;
702 mode = local->oper_hw_mode;
705 local->hw.conf.channel = chan->chan;
706 local->hw.conf.channel_val = chan->val;
707 if (!local->hw.conf.power_level) {
708 local->hw.conf.power_level = chan->power_level;
710 local->hw.conf.power_level = min(chan->power_level,
711 local->hw.conf.power_level);
713 local->hw.conf.freq = chan->freq;
714 local->hw.conf.phymode = mode->mode;
715 local->hw.conf.antenna_max = chan->antenna_max;
716 local->hw.conf.chan = chan;
717 local->hw.conf.mode = mode;
719 #ifdef CONFIG_MAC80211_VERBOSE_DEBUG
720 printk(KERN_DEBUG "HW CONFIG: channel=%d freq=%d "
721 "phymode=%d\n", local->hw.conf.channel, local->hw.conf.freq,
722 local->hw.conf.phymode);
723 #endif /* CONFIG_MAC80211_VERBOSE_DEBUG */
725 if (local->ops->config)
726 ret = local->ops->config(local_to_hw(local), &local->hw.conf);
731 void ieee80211_erp_info_change_notify(struct net_device *dev, u8 changes)
733 struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr);
734 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
735 if (local->ops->erp_ie_changed)
736 local->ops->erp_ie_changed(local_to_hw(local), changes,
737 !!(sdata->flags & IEEE80211_SDATA_USE_PROTECTION),
738 !(sdata->flags & IEEE80211_SDATA_SHORT_PREAMBLE));
741 void ieee80211_reset_erp_info(struct net_device *dev)
743 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
745 sdata->flags &= ~(IEEE80211_SDATA_USE_PROTECTION |
746 IEEE80211_SDATA_SHORT_PREAMBLE);
747 ieee80211_erp_info_change_notify(dev,
748 IEEE80211_ERP_CHANGE_PROTECTION |
749 IEEE80211_ERP_CHANGE_PREAMBLE);
752 struct dev_mc_list *ieee80211_get_mc_list_item(struct ieee80211_hw *hw,
753 struct dev_mc_list *prev,
756 struct ieee80211_local *local = hw_to_local(hw);
757 struct ieee80211_sub_if_data *sdata = *ptr;
758 struct dev_mc_list *mc;
764 if (!prev || !prev->next) {
766 sdata = list_entry(sdata->list.next,
767 struct ieee80211_sub_if_data, list);
769 sdata = list_entry(local->sub_if_list.next,
770 struct ieee80211_sub_if_data, list);
771 if (&sdata->list != &local->sub_if_list)
772 mc = sdata->dev->mc_list;
781 EXPORT_SYMBOL(ieee80211_get_mc_list_item);
783 void ieee80211_tx_status_irqsafe(struct ieee80211_hw *hw,
785 struct ieee80211_tx_status *status)
787 struct ieee80211_local *local = hw_to_local(hw);
788 struct ieee80211_tx_status *saved;
791 skb->dev = local->mdev;
792 saved = kmalloc(sizeof(struct ieee80211_tx_status), GFP_ATOMIC);
793 if (unlikely(!saved)) {
795 printk(KERN_WARNING "%s: Not enough memory, "
796 "dropping tx status", skb->dev->name);
797 /* should be dev_kfree_skb_irq, but due to this function being
798 * named _irqsafe instead of just _irq we can't be sure that
799 * people won't call it from non-irq contexts */
800 dev_kfree_skb_any(skb);
803 memcpy(saved, status, sizeof(struct ieee80211_tx_status));
804 /* copy pointer to saved status into skb->cb for use by tasklet */
805 memcpy(skb->cb, &saved, sizeof(saved));
807 skb->pkt_type = IEEE80211_TX_STATUS_MSG;
808 skb_queue_tail(status->control.flags & IEEE80211_TXCTL_REQ_TX_STATUS ?
809 &local->skb_queue : &local->skb_queue_unreliable, skb);
810 tmp = skb_queue_len(&local->skb_queue) +
811 skb_queue_len(&local->skb_queue_unreliable);
812 while (tmp > IEEE80211_IRQSAFE_QUEUE_LIMIT &&
813 (skb = skb_dequeue(&local->skb_queue_unreliable))) {
814 memcpy(&saved, skb->cb, sizeof(saved));
816 dev_kfree_skb_irq(skb);
818 I802_DEBUG_INC(local->tx_status_drop);
820 tasklet_schedule(&local->tasklet);
822 EXPORT_SYMBOL(ieee80211_tx_status_irqsafe);
824 static void ieee80211_tasklet_handler(unsigned long data)
826 struct ieee80211_local *local = (struct ieee80211_local *) data;
828 struct ieee80211_rx_status rx_status;
829 struct ieee80211_tx_status *tx_status;
831 while ((skb = skb_dequeue(&local->skb_queue)) ||
832 (skb = skb_dequeue(&local->skb_queue_unreliable))) {
833 switch (skb->pkt_type) {
834 case IEEE80211_RX_MSG:
835 /* status is in skb->cb */
836 memcpy(&rx_status, skb->cb, sizeof(rx_status));
837 /* Clear skb->type in order to not confuse kernel
840 __ieee80211_rx(local_to_hw(local), skb, &rx_status);
842 case IEEE80211_TX_STATUS_MSG:
843 /* get pointer to saved status out of skb->cb */
844 memcpy(&tx_status, skb->cb, sizeof(tx_status));
846 ieee80211_tx_status(local_to_hw(local),
850 default: /* should never get here! */
851 printk(KERN_ERR "%s: Unknown message type (%d)\n",
852 local->mdev->name, skb->pkt_type);
859 /* Remove added headers (e.g., QoS control), encryption header/MIC, etc. to
860 * make a prepared TX frame (one that has been given to hw) to look like brand
861 * new IEEE 802.11 frame that is ready to go through TX processing again.
862 * Also, tx_packet_data in cb is restored from tx_control. */
863 static void ieee80211_remove_tx_extra(struct ieee80211_local *local,
864 struct ieee80211_key *key,
866 struct ieee80211_tx_control *control)
868 int hdrlen, iv_len, mic_len;
869 struct ieee80211_tx_packet_data *pkt_data;
871 pkt_data = (struct ieee80211_tx_packet_data *)skb->cb;
872 pkt_data->ifindex = control->ifindex;
874 if (control->flags & IEEE80211_TXCTL_REQ_TX_STATUS)
875 pkt_data->flags |= IEEE80211_TXPD_REQ_TX_STATUS;
876 if (control->flags & IEEE80211_TXCTL_DO_NOT_ENCRYPT)
877 pkt_data->flags |= IEEE80211_TXPD_DO_NOT_ENCRYPT;
878 if (control->flags & IEEE80211_TXCTL_REQUEUE)
879 pkt_data->flags |= IEEE80211_TXPD_REQUEUE;
880 if (control->type == IEEE80211_IF_TYPE_MGMT)
881 pkt_data->flags |= IEEE80211_TXPD_MGMT_IFACE;
882 pkt_data->queue = control->queue;
884 hdrlen = ieee80211_get_hdrlen_from_skb(skb);
889 switch (key->conf.alg) {
892 mic_len = WEP_ICV_LEN;
895 iv_len = TKIP_IV_LEN;
896 mic_len = TKIP_ICV_LEN;
899 iv_len = CCMP_HDR_LEN;
900 mic_len = CCMP_MIC_LEN;
906 if (skb->len >= mic_len &&
907 !(key->flags & KEY_FLAG_UPLOADED_TO_HARDWARE))
908 skb_trim(skb, skb->len - mic_len);
909 if (skb->len >= iv_len && skb->len > hdrlen) {
910 memmove(skb->data + iv_len, skb->data, hdrlen);
911 skb_pull(skb, iv_len);
916 struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) skb->data;
917 u16 fc = le16_to_cpu(hdr->frame_control);
918 if ((fc & 0x8C) == 0x88) /* QoS Control Field */ {
919 fc &= ~IEEE80211_STYPE_QOS_DATA;
920 hdr->frame_control = cpu_to_le16(fc);
921 memmove(skb->data + 2, skb->data, hdrlen - 2);
927 void ieee80211_tx_status(struct ieee80211_hw *hw, struct sk_buff *skb,
928 struct ieee80211_tx_status *status)
930 struct sk_buff *skb2;
931 struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) skb->data;
932 struct ieee80211_local *local = hw_to_local(hw);
935 struct ieee80211_tx_status_rtap_hdr *rthdr;
936 struct ieee80211_sub_if_data *sdata;
941 "%s: ieee80211_tx_status called with NULL status\n",
947 if (status->excessive_retries) {
948 struct sta_info *sta;
949 sta = sta_info_get(local, hdr->addr1);
951 if (sta->flags & WLAN_STA_PS) {
952 /* The STA is in power save mode, so assume
953 * that this TX packet failed because of that.
955 status->excessive_retries = 0;
956 status->flags |= IEEE80211_TX_STATUS_TX_FILTERED;
962 if (status->flags & IEEE80211_TX_STATUS_TX_FILTERED) {
963 struct sta_info *sta;
964 sta = sta_info_get(local, hdr->addr1);
966 sta->tx_filtered_count++;
968 /* Clear the TX filter mask for this STA when sending
969 * the next packet. If the STA went to power save mode,
970 * this will happen when it is waking up for the next
972 sta->clear_dst_mask = 1;
974 /* TODO: Is the WLAN_STA_PS flag always set here or is
975 * the race between RX and TX status causing some
976 * packets to be filtered out before 80211.o gets an
977 * update for PS status? This seems to be the case, so
978 * no changes are likely to be needed. */
979 if (sta->flags & WLAN_STA_PS &&
980 skb_queue_len(&sta->tx_filtered) <
982 ieee80211_remove_tx_extra(local, sta->key,
985 skb_queue_tail(&sta->tx_filtered, skb);
986 } else if (!(sta->flags & WLAN_STA_PS) &&
987 !(status->control.flags & IEEE80211_TXCTL_REQUEUE)) {
988 /* Software retry the packet once */
989 status->control.flags |= IEEE80211_TXCTL_REQUEUE;
990 ieee80211_remove_tx_extra(local, sta->key,
995 if (net_ratelimit()) {
996 printk(KERN_DEBUG "%s: dropped TX "
997 "filtered frame queue_len=%d "
1002 !!(sta->flags & WLAN_STA_PS),
1011 /* FIXME: STUPID to call this with both local and local->mdev */
1012 rate_control_tx_status(local, local->mdev, skb, status);
1015 ieee80211_led_tx(local, 0);
1018 * Fragments are passed to low-level drivers as separate skbs, so these
1019 * are actually fragments, not frames. Update frame counters only for
1020 * the first fragment of the frame. */
1022 frag = le16_to_cpu(hdr->seq_ctrl) & IEEE80211_SCTL_FRAG;
1023 type = le16_to_cpu(hdr->frame_control) & IEEE80211_FCTL_FTYPE;
1025 if (status->flags & IEEE80211_TX_STATUS_ACK) {
1027 local->dot11TransmittedFrameCount++;
1028 if (is_multicast_ether_addr(hdr->addr1))
1029 local->dot11MulticastTransmittedFrameCount++;
1030 if (status->retry_count > 0)
1031 local->dot11RetryCount++;
1032 if (status->retry_count > 1)
1033 local->dot11MultipleRetryCount++;
1036 /* This counter shall be incremented for an acknowledged MPDU
1037 * with an individual address in the address 1 field or an MPDU
1038 * with a multicast address in the address 1 field of type Data
1040 if (!is_multicast_ether_addr(hdr->addr1) ||
1041 type == IEEE80211_FTYPE_DATA ||
1042 type == IEEE80211_FTYPE_MGMT)
1043 local->dot11TransmittedFragmentCount++;
1046 local->dot11FailedCount++;
1049 msg_type = (status->flags & IEEE80211_TX_STATUS_ACK) ?
1050 ieee80211_msg_tx_callback_ack : ieee80211_msg_tx_callback_fail;
1052 /* this was a transmitted frame, but now we want to reuse it */
1055 if ((status->control.flags & IEEE80211_TXCTL_REQ_TX_STATUS) &&
1057 if (local->monitors) {
1058 skb2 = skb_clone(skb, GFP_ATOMIC);
1065 /* Send frame to hostapd */
1066 ieee80211_rx_mgmt(local, skb2, NULL, msg_type);
1072 if (!local->monitors) {
1077 /* send frame to monitor interfaces now */
1079 if (skb_headroom(skb) < sizeof(*rthdr)) {
1080 printk(KERN_ERR "ieee80211_tx_status: headroom too small\n");
1085 rthdr = (struct ieee80211_tx_status_rtap_hdr*)
1086 skb_push(skb, sizeof(*rthdr));
1088 memset(rthdr, 0, sizeof(*rthdr));
1089 rthdr->hdr.it_len = cpu_to_le16(sizeof(*rthdr));
1090 rthdr->hdr.it_present =
1091 cpu_to_le32((1 << IEEE80211_RADIOTAP_TX_FLAGS) |
1092 (1 << IEEE80211_RADIOTAP_DATA_RETRIES));
1094 if (!(status->flags & IEEE80211_TX_STATUS_ACK) &&
1095 !is_multicast_ether_addr(hdr->addr1))
1096 rthdr->tx_flags |= cpu_to_le16(IEEE80211_RADIOTAP_F_TX_FAIL);
1098 if ((status->control.flags & IEEE80211_TXCTL_USE_RTS_CTS) &&
1099 (status->control.flags & IEEE80211_TXCTL_USE_CTS_PROTECT))
1100 rthdr->tx_flags |= cpu_to_le16(IEEE80211_RADIOTAP_F_TX_CTS);
1101 else if (status->control.flags & IEEE80211_TXCTL_USE_RTS_CTS)
1102 rthdr->tx_flags |= cpu_to_le16(IEEE80211_RADIOTAP_F_TX_RTS);
1104 rthdr->data_retries = status->retry_count;
1106 read_lock(&local->sub_if_lock);
1107 monitors = local->monitors;
1108 list_for_each_entry(sdata, &local->sub_if_list, list) {
1110 * Using the monitors counter is possibly racy, but
1111 * if the value is wrong we simply either clone the skb
1112 * once too much or forget sending it to one monitor iface
1113 * The latter case isn't nice but fixing the race is much
1116 if (!monitors || !skb)
1119 if (sdata->type == IEEE80211_IF_TYPE_MNTR) {
1120 if (!netif_running(sdata->dev))
1124 skb2 = skb_clone(skb, GFP_KERNEL);
1127 skb->dev = sdata->dev;
1128 /* XXX: is this sufficient for BPF? */
1129 skb_set_mac_header(skb, 0);
1130 skb->ip_summed = CHECKSUM_UNNECESSARY;
1131 skb->pkt_type = PACKET_OTHERHOST;
1132 skb->protocol = htons(ETH_P_802_2);
1133 memset(skb->cb, 0, sizeof(skb->cb));
1139 read_unlock(&local->sub_if_lock);
1143 EXPORT_SYMBOL(ieee80211_tx_status);
1145 struct ieee80211_hw *ieee80211_alloc_hw(size_t priv_data_len,
1146 const struct ieee80211_ops *ops)
1148 struct net_device *mdev;
1149 struct ieee80211_local *local;
1150 struct ieee80211_sub_if_data *sdata;
1152 struct wiphy *wiphy;
1154 /* Ensure 32-byte alignment of our private data and hw private data.
1155 * We use the wiphy priv data for both our ieee80211_local and for
1156 * the driver's private data
1158 * In memory it'll be like this:
1160 * +-------------------------+
1162 * +-------------------------+
1163 * | struct ieee80211_local |
1164 * +-------------------------+
1165 * | driver's private data |
1166 * +-------------------------+
1169 priv_size = ((sizeof(struct ieee80211_local) +
1170 NETDEV_ALIGN_CONST) & ~NETDEV_ALIGN_CONST) +
1173 wiphy = wiphy_new(&mac80211_config_ops, priv_size);
1178 wiphy->privid = mac80211_wiphy_privid;
1180 local = wiphy_priv(wiphy);
1181 local->hw.wiphy = wiphy;
1183 local->hw.priv = (char *)local +
1184 ((sizeof(struct ieee80211_local) +
1185 NETDEV_ALIGN_CONST) & ~NETDEV_ALIGN_CONST);
1188 BUG_ON(!ops->config);
1189 BUG_ON(!ops->add_interface);
1192 /* for now, mdev needs sub_if_data :/ */
1193 mdev = alloc_netdev(sizeof(struct ieee80211_sub_if_data),
1194 "wmaster%d", ether_setup);
1200 sdata = IEEE80211_DEV_TO_SUB_IF(mdev);
1201 mdev->ieee80211_ptr = &sdata->wdev;
1202 sdata->wdev.wiphy = wiphy;
1204 local->hw.queues = 1; /* default */
1207 local->rx_pre_handlers = ieee80211_rx_pre_handlers;
1208 local->rx_handlers = ieee80211_rx_handlers;
1209 local->tx_handlers = ieee80211_tx_handlers;
1211 local->bridge_packets = 1;
1213 local->rts_threshold = IEEE80211_MAX_RTS_THRESHOLD;
1214 local->fragmentation_threshold = IEEE80211_MAX_FRAG_THRESHOLD;
1215 local->short_retry_limit = 7;
1216 local->long_retry_limit = 4;
1217 local->hw.conf.radio_enabled = 1;
1219 local->enabled_modes = ~0;
1221 INIT_LIST_HEAD(&local->modes_list);
1223 rwlock_init(&local->sub_if_lock);
1224 INIT_LIST_HEAD(&local->sub_if_list);
1226 INIT_DELAYED_WORK(&local->scan_work, ieee80211_sta_scan_work);
1227 ieee80211_rx_bss_list_init(mdev);
1229 sta_info_init(local);
1231 mdev->hard_start_xmit = ieee80211_master_start_xmit;
1232 mdev->open = ieee80211_master_open;
1233 mdev->stop = ieee80211_master_stop;
1234 mdev->type = ARPHRD_IEEE80211;
1235 mdev->hard_header_parse = header_parse_80211;
1237 sdata->type = IEEE80211_IF_TYPE_AP;
1239 sdata->local = local;
1240 sdata->u.ap.force_unicast_rateidx = -1;
1241 sdata->u.ap.max_ratectrl_rateidx = -1;
1242 ieee80211_if_sdata_init(sdata);
1243 list_add_tail(&sdata->list, &local->sub_if_list);
1245 tasklet_init(&local->tx_pending_tasklet, ieee80211_tx_pending,
1246 (unsigned long)local);
1247 tasklet_disable(&local->tx_pending_tasklet);
1249 tasklet_init(&local->tasklet,
1250 ieee80211_tasklet_handler,
1251 (unsigned long) local);
1252 tasklet_disable(&local->tasklet);
1254 skb_queue_head_init(&local->skb_queue);
1255 skb_queue_head_init(&local->skb_queue_unreliable);
1257 return local_to_hw(local);
1259 EXPORT_SYMBOL(ieee80211_alloc_hw);
1261 int ieee80211_register_hw(struct ieee80211_hw *hw)
1263 struct ieee80211_local *local = hw_to_local(hw);
1267 result = wiphy_register(local->hw.wiphy);
1271 name = wiphy_dev(local->hw.wiphy)->driver->name;
1272 local->hw.workqueue = create_singlethread_workqueue(name);
1273 if (!local->hw.workqueue) {
1275 goto fail_workqueue;
1279 * The hardware needs headroom for sending the frame,
1280 * and we need some headroom for passing the frame to monitor
1281 * interfaces, but never both at the same time.
1283 local->tx_headroom = max_t(unsigned int , local->hw.extra_tx_headroom,
1284 sizeof(struct ieee80211_tx_status_rtap_hdr));
1286 debugfs_hw_add(local);
1288 local->hw.conf.beacon_int = 1000;
1290 local->wstats_flags |= local->hw.max_rssi ?
1291 IW_QUAL_LEVEL_UPDATED : IW_QUAL_LEVEL_INVALID;
1292 local->wstats_flags |= local->hw.max_signal ?
1293 IW_QUAL_QUAL_UPDATED : IW_QUAL_QUAL_INVALID;
1294 local->wstats_flags |= local->hw.max_noise ?
1295 IW_QUAL_NOISE_UPDATED : IW_QUAL_NOISE_INVALID;
1296 if (local->hw.max_rssi < 0 || local->hw.max_noise < 0)
1297 local->wstats_flags |= IW_QUAL_DBM;
1299 result = sta_info_start(local);
1304 result = dev_alloc_name(local->mdev, local->mdev->name);
1308 memcpy(local->mdev->dev_addr, local->hw.wiphy->perm_addr, ETH_ALEN);
1309 SET_NETDEV_DEV(local->mdev, wiphy_dev(local->hw.wiphy));
1311 result = register_netdevice(local->mdev);
1315 ieee80211_debugfs_add_netdev(IEEE80211_DEV_TO_SUB_IF(local->mdev));
1317 result = ieee80211_init_rate_ctrl_alg(local, NULL);
1319 printk(KERN_DEBUG "%s: Failed to initialize rate control "
1320 "algorithm\n", local->mdev->name);
1324 result = ieee80211_wep_init(local);
1327 printk(KERN_DEBUG "%s: Failed to initialize wep\n",
1332 ieee80211_install_qdisc(local->mdev);
1334 /* add one default STA interface */
1335 result = ieee80211_if_add(local->mdev, "wlan%d", NULL,
1336 IEEE80211_IF_TYPE_STA);
1338 printk(KERN_WARNING "%s: Failed to add default virtual iface\n",
1341 local->reg_state = IEEE80211_DEV_REGISTERED;
1344 ieee80211_led_init(local);
1349 rate_control_deinitialize(local);
1351 ieee80211_debugfs_remove_netdev(IEEE80211_DEV_TO_SUB_IF(local->mdev));
1352 unregister_netdevice(local->mdev);
1355 sta_info_stop(local);
1357 debugfs_hw_del(local);
1358 destroy_workqueue(local->hw.workqueue);
1360 wiphy_unregister(local->hw.wiphy);
1363 EXPORT_SYMBOL(ieee80211_register_hw);
1365 int ieee80211_register_hwmode(struct ieee80211_hw *hw,
1366 struct ieee80211_hw_mode *mode)
1368 struct ieee80211_local *local = hw_to_local(hw);
1369 struct ieee80211_rate *rate;
1372 INIT_LIST_HEAD(&mode->list);
1373 list_add_tail(&mode->list, &local->modes_list);
1375 local->hw_modes |= (1 << mode->mode);
1376 for (i = 0; i < mode->num_rates; i++) {
1377 rate = &(mode->rates[i]);
1378 rate->rate_inv = CHAN_UTIL_RATE_LCM / rate->rate;
1380 ieee80211_prepare_rates(local, mode);
1382 if (!local->oper_hw_mode) {
1383 /* Default to this mode */
1384 local->hw.conf.phymode = mode->mode;
1385 local->oper_hw_mode = local->scan_hw_mode = mode;
1386 local->oper_channel = local->scan_channel = &mode->channels[0];
1387 local->hw.conf.mode = local->oper_hw_mode;
1388 local->hw.conf.chan = local->oper_channel;
1391 if (!(hw->flags & IEEE80211_HW_DEFAULT_REG_DOMAIN_CONFIGURED))
1392 ieee80211_set_default_regdomain(mode);
1396 EXPORT_SYMBOL(ieee80211_register_hwmode);
1398 void ieee80211_unregister_hw(struct ieee80211_hw *hw)
1400 struct ieee80211_local *local = hw_to_local(hw);
1401 struct ieee80211_sub_if_data *sdata, *tmp;
1402 struct list_head tmp_list;
1405 tasklet_kill(&local->tx_pending_tasklet);
1406 tasklet_kill(&local->tasklet);
1410 BUG_ON(local->reg_state != IEEE80211_DEV_REGISTERED);
1412 local->reg_state = IEEE80211_DEV_UNREGISTERED;
1414 ieee80211_if_del_mgmt(local);
1416 write_lock_bh(&local->sub_if_lock);
1417 list_replace_init(&local->sub_if_list, &tmp_list);
1418 write_unlock_bh(&local->sub_if_lock);
1420 list_for_each_entry_safe(sdata, tmp, &tmp_list, list)
1421 __ieee80211_if_del(local, sdata);
1425 ieee80211_rx_bss_list_deinit(local->mdev);
1426 ieee80211_clear_tx_pending(local);
1427 sta_info_stop(local);
1428 rate_control_deinitialize(local);
1429 debugfs_hw_del(local);
1431 for (i = 0; i < NUM_IEEE80211_MODES; i++) {
1432 kfree(local->supp_rates[i]);
1433 kfree(local->basic_rates[i]);
1436 if (skb_queue_len(&local->skb_queue)
1437 || skb_queue_len(&local->skb_queue_unreliable))
1438 printk(KERN_WARNING "%s: skb_queue not empty\n",
1440 skb_queue_purge(&local->skb_queue);
1441 skb_queue_purge(&local->skb_queue_unreliable);
1443 destroy_workqueue(local->hw.workqueue);
1444 wiphy_unregister(local->hw.wiphy);
1445 ieee80211_wep_free(local);
1446 ieee80211_led_exit(local);
1448 EXPORT_SYMBOL(ieee80211_unregister_hw);
1450 void ieee80211_free_hw(struct ieee80211_hw *hw)
1452 struct ieee80211_local *local = hw_to_local(hw);
1454 ieee80211_if_free(local->mdev);
1455 wiphy_free(local->hw.wiphy);
1457 EXPORT_SYMBOL(ieee80211_free_hw);
1459 static int __init ieee80211_init(void)
1461 struct sk_buff *skb;
1464 BUILD_BUG_ON(sizeof(struct ieee80211_tx_packet_data) > sizeof(skb->cb));
1466 ret = ieee80211_wme_register();
1468 printk(KERN_DEBUG "ieee80211_init: failed to "
1469 "initialize WME (err=%d)\n", ret);
1473 ieee80211_debugfs_netdev_init();
1474 ieee80211_regdomain_init();
1479 static void __exit ieee80211_exit(void)
1481 ieee80211_wme_unregister();
1482 ieee80211_debugfs_netdev_exit();
1486 subsys_initcall(ieee80211_init);
1487 module_exit(ieee80211_exit);
1489 MODULE_DESCRIPTION("IEEE 802.11 subsystem");
1490 MODULE_LICENSE("GPL");