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"
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(const struct sk_buff
*skb
, unsigned char *haddr
)
52 memcpy(haddr
, skb_mac_header(skb
) + 10, ETH_ALEN
); /* addr2 */
56 /* must be called under mdev tx lock */
57 static void ieee80211_configure_filter(struct ieee80211_local
*local
)
59 unsigned int changed_flags
;
60 unsigned int new_flags
= 0;
62 if (local
->iff_promiscs
)
63 new_flags
|= FIF_PROMISC_IN_BSS
;
65 if (local
->iff_allmultis
)
66 new_flags
|= FIF_ALLMULTI
;
69 new_flags
|= FIF_CONTROL
|
71 FIF_BCN_PRBRESP_PROMISC
;
73 changed_flags
= local
->filter_flags
^ new_flags
;
78 local
->ops
->configure_filter(local_to_hw(local
),
79 changed_flags
, &new_flags
,
80 local
->mdev
->mc_count
,
81 local
->mdev
->mc_list
);
83 WARN_ON(new_flags
& (1<<31));
85 local
->filter_flags
= new_flags
& ~(1<<31);
88 /* master interface */
90 static int ieee80211_master_open(struct net_device
*dev
)
92 struct ieee80211_local
*local
= wdev_priv(dev
->ieee80211_ptr
);
93 struct ieee80211_sub_if_data
*sdata
;
94 int res
= -EOPNOTSUPP
;
96 /* we hold the RTNL here so can safely walk the list */
97 list_for_each_entry(sdata
, &local
->interfaces
, list
) {
98 if (sdata
->dev
!= dev
&& netif_running(sdata
->dev
)) {
106 static int ieee80211_master_stop(struct net_device
*dev
)
108 struct ieee80211_local
*local
= wdev_priv(dev
->ieee80211_ptr
);
109 struct ieee80211_sub_if_data
*sdata
;
111 /* we hold the RTNL here so can safely walk the list */
112 list_for_each_entry(sdata
, &local
->interfaces
, list
)
113 if (sdata
->dev
!= dev
&& netif_running(sdata
->dev
))
114 dev_close(sdata
->dev
);
119 static void ieee80211_master_set_multicast_list(struct net_device
*dev
)
121 struct ieee80211_local
*local
= wdev_priv(dev
->ieee80211_ptr
);
123 ieee80211_configure_filter(local
);
126 /* management interface */
129 ieee80211_fill_frame_info(struct ieee80211_local
*local
,
130 struct ieee80211_frame_info
*fi
,
131 struct ieee80211_rx_status
*status
)
135 struct ieee80211_rate
*rate
;
137 jiffies_to_timespec(jiffies
, &ts
);
138 fi
->hosttime
= cpu_to_be64((u64
) ts
.tv_sec
* 1000000 +
140 fi
->mactime
= cpu_to_be64(status
->mactime
);
141 switch (status
->phymode
) {
142 case MODE_IEEE80211A
:
143 fi
->phytype
= htonl(ieee80211_phytype_ofdm_dot11_a
);
145 case MODE_IEEE80211B
:
146 fi
->phytype
= htonl(ieee80211_phytype_dsss_dot11_b
);
148 case MODE_IEEE80211G
:
149 fi
->phytype
= htonl(ieee80211_phytype_pbcc_dot11_g
);
152 fi
->phytype
= htonl(0xAAAAAAAA);
155 fi
->channel
= htonl(status
->channel
);
156 rate
= ieee80211_get_rate(local
, status
->phymode
,
159 fi
->datarate
= htonl(rate
->rate
);
160 if (rate
->flags
& IEEE80211_RATE_PREAMBLE2
) {
161 if (status
->rate
== rate
->val
)
162 fi
->preamble
= htonl(2); /* long */
163 else if (status
->rate
== rate
->val2
)
164 fi
->preamble
= htonl(1); /* short */
166 fi
->preamble
= htonl(0);
168 fi
->datarate
= htonl(0);
169 fi
->preamble
= htonl(0);
172 fi
->antenna
= htonl(status
->antenna
);
173 fi
->priority
= htonl(0xffffffff); /* no clue */
174 fi
->ssi_type
= htonl(ieee80211_ssi_raw
);
175 fi
->ssi_signal
= htonl(status
->ssi
);
176 fi
->ssi_noise
= 0x00000000;
179 /* clear everything because we really don't know.
180 * the msg_type field isn't present on monitor frames
181 * so we don't know whether it will be present or not,
182 * but it's ok to not clear it since it'll be assigned
184 memset(fi
, 0, sizeof(*fi
) - sizeof(fi
->msg_type
));
186 fi
->ssi_type
= htonl(ieee80211_ssi_none
);
188 fi
->version
= htonl(IEEE80211_FI_VERSION
);
189 fi
->length
= cpu_to_be32(sizeof(*fi
) - sizeof(fi
->msg_type
));
192 /* this routine is actually not just for this, but also
193 * for pushing fake 'management' frames into userspace.
194 * it shall be replaced by a netlink-based system. */
196 ieee80211_rx_mgmt(struct ieee80211_local
*local
, struct sk_buff
*skb
,
197 struct ieee80211_rx_status
*status
, u32 msg_type
)
199 struct ieee80211_frame_info
*fi
;
200 const size_t hlen
= sizeof(struct ieee80211_frame_info
);
201 struct net_device
*dev
= local
->apdev
;
205 if (skb_headroom(skb
) < hlen
) {
206 I802_DEBUG_INC(local
->rx_expand_skb_head
);
207 if (pskb_expand_head(skb
, hlen
, 0, GFP_ATOMIC
)) {
213 fi
= (struct ieee80211_frame_info
*) skb_push(skb
, hlen
);
215 ieee80211_fill_frame_info(local
, fi
, status
);
216 fi
->msg_type
= htonl(msg_type
);
218 dev
->stats
.rx_packets
++;
219 dev
->stats
.rx_bytes
+= skb
->len
;
221 skb_set_mac_header(skb
, 0);
222 skb
->ip_summed
= CHECKSUM_UNNECESSARY
;
223 skb
->pkt_type
= PACKET_OTHERHOST
;
224 skb
->protocol
= htons(ETH_P_802_2
);
225 memset(skb
->cb
, 0, sizeof(skb
->cb
));
229 static int ieee80211_mgmt_open(struct net_device
*dev
)
231 struct ieee80211_local
*local
= wdev_priv(dev
->ieee80211_ptr
);
233 if (!netif_running(local
->mdev
))
238 static int ieee80211_mgmt_stop(struct net_device
*dev
)
243 static int ieee80211_change_mtu_apdev(struct net_device
*dev
, int new_mtu
)
245 /* FIX: what would be proper limits for MTU?
246 * This interface uses 802.11 frames. */
247 if (new_mtu
< 256 || new_mtu
> IEEE80211_MAX_DATA_LEN
) {
248 printk(KERN_WARNING
"%s: invalid MTU %d\n",
253 #ifdef CONFIG_MAC80211_VERBOSE_DEBUG
254 printk(KERN_DEBUG
"%s: setting MTU %d\n", dev
->name
, new_mtu
);
255 #endif /* CONFIG_MAC80211_VERBOSE_DEBUG */
260 void ieee80211_if_mgmt_setup(struct net_device
*dev
)
263 dev
->hard_start_xmit
= ieee80211_mgmt_start_xmit
;
264 dev
->change_mtu
= ieee80211_change_mtu_apdev
;
265 dev
->open
= ieee80211_mgmt_open
;
266 dev
->stop
= ieee80211_mgmt_stop
;
267 dev
->type
= ARPHRD_IEEE80211_PRISM
;
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 static int ieee80211_open(struct net_device
*dev
)
308 struct ieee80211_sub_if_data
*sdata
, *nsdata
;
309 struct ieee80211_local
*local
= wdev_priv(dev
->ieee80211_ptr
);
310 struct ieee80211_if_init_conf conf
;
313 sdata
= IEEE80211_DEV_TO_SUB_IF(dev
);
315 /* we hold the RTNL here so can safely walk the list */
316 list_for_each_entry(nsdata
, &local
->interfaces
, list
) {
317 struct net_device
*ndev
= nsdata
->dev
;
319 if (ndev
!= dev
&& ndev
!= local
->mdev
&& netif_running(ndev
) &&
320 compare_ether_addr(dev
->dev_addr
, ndev
->dev_addr
) == 0) {
322 * check whether it may have the same address
324 if (!identical_mac_addr_allowed(sdata
->type
,
329 * can only add VLANs to enabled APs
331 if (sdata
->type
== IEEE80211_IF_TYPE_VLAN
&&
332 nsdata
->type
== IEEE80211_IF_TYPE_AP
&&
333 netif_running(nsdata
->dev
))
334 sdata
->u
.vlan
.ap
= nsdata
;
338 switch (sdata
->type
) {
339 case IEEE80211_IF_TYPE_WDS
:
340 if (is_zero_ether_addr(sdata
->u
.wds
.remote_addr
))
343 case IEEE80211_IF_TYPE_VLAN
:
344 if (!sdata
->u
.vlan
.ap
)
349 if (local
->open_count
== 0) {
351 if (local
->ops
->start
)
352 res
= local
->ops
->start(local_to_hw(local
));
357 switch (sdata
->type
) {
358 case IEEE80211_IF_TYPE_VLAN
:
359 list_add(&sdata
->u
.vlan
.list
, &sdata
->u
.vlan
.ap
->u
.ap
.vlans
);
360 /* no need to tell driver */
362 case IEEE80211_IF_TYPE_MNTR
:
363 /* must be before the call to ieee80211_configure_filter */
365 if (local
->monitors
== 1) {
366 netif_tx_lock_bh(local
->mdev
);
367 ieee80211_configure_filter(local
);
368 netif_tx_unlock_bh(local
->mdev
);
370 local
->hw
.conf
.flags
|= IEEE80211_CONF_RADIOTAP
;
371 ieee80211_hw_config(local
);
374 case IEEE80211_IF_TYPE_STA
:
375 case IEEE80211_IF_TYPE_IBSS
:
376 sdata
->u
.sta
.flags
&= ~IEEE80211_STA_PREV_BSSID_SET
;
379 conf
.if_id
= dev
->ifindex
;
380 conf
.type
= sdata
->type
;
381 conf
.mac_addr
= dev
->dev_addr
;
382 res
= local
->ops
->add_interface(local_to_hw(local
), &conf
);
383 if (res
&& !local
->open_count
&& local
->ops
->stop
)
384 local
->ops
->stop(local_to_hw(local
));
388 ieee80211_if_config(dev
);
389 ieee80211_reset_erp_info(dev
);
390 ieee80211_enable_keys(sdata
);
392 if (sdata
->type
== IEEE80211_IF_TYPE_STA
&&
393 !local
->user_space_mlme
)
394 netif_carrier_off(dev
);
396 netif_carrier_on(dev
);
399 if (local
->open_count
== 0) {
400 res
= dev_open(local
->mdev
);
403 res
= dev_open(local
->apdev
);
406 tasklet_enable(&local
->tx_pending_tasklet
);
407 tasklet_enable(&local
->tasklet
);
412 netif_start_queue(dev
);
417 static int ieee80211_stop(struct net_device
*dev
)
419 struct ieee80211_sub_if_data
*sdata
;
420 struct ieee80211_local
*local
= wdev_priv(dev
->ieee80211_ptr
);
421 struct ieee80211_if_init_conf conf
;
423 sdata
= IEEE80211_DEV_TO_SUB_IF(dev
);
425 netif_stop_queue(dev
);
427 dev_mc_unsync(local
->mdev
, dev
);
429 /* down all dependent devices, that is VLANs */
430 if (sdata
->type
== IEEE80211_IF_TYPE_AP
) {
431 struct ieee80211_sub_if_data
*vlan
, *tmp
;
433 list_for_each_entry_safe(vlan
, tmp
, &sdata
->u
.ap
.vlans
,
435 dev_close(vlan
->dev
);
436 WARN_ON(!list_empty(&sdata
->u
.ap
.vlans
));
441 switch (sdata
->type
) {
442 case IEEE80211_IF_TYPE_VLAN
:
443 list_del(&sdata
->u
.vlan
.list
);
444 sdata
->u
.vlan
.ap
= NULL
;
445 /* no need to tell driver */
447 case IEEE80211_IF_TYPE_MNTR
:
449 if (local
->monitors
== 0) {
450 netif_tx_lock_bh(local
->mdev
);
451 ieee80211_configure_filter(local
);
452 netif_tx_unlock_bh(local
->mdev
);
454 local
->hw
.conf
.flags
|= IEEE80211_CONF_RADIOTAP
;
455 ieee80211_hw_config(local
);
458 case IEEE80211_IF_TYPE_STA
:
459 case IEEE80211_IF_TYPE_IBSS
:
460 sdata
->u
.sta
.state
= IEEE80211_DISABLED
;
461 del_timer_sync(&sdata
->u
.sta
.timer
);
463 * When we get here, the interface is marked down.
464 * Call synchronize_rcu() to wait for the RX path
465 * should it be using the interface and enqueuing
466 * frames at this very time on another CPU.
469 skb_queue_purge(&sdata
->u
.sta
.skb_queue
);
471 if (!local
->ops
->hw_scan
&&
472 local
->scan_dev
== sdata
->dev
) {
473 local
->sta_scanning
= 0;
474 cancel_delayed_work(&local
->scan_work
);
476 flush_workqueue(local
->hw
.workqueue
);
479 conf
.if_id
= dev
->ifindex
;
480 conf
.type
= sdata
->type
;
481 conf
.mac_addr
= dev
->dev_addr
;
482 /* disable all keys for as long as this netdev is down */
483 ieee80211_disable_keys(sdata
);
484 local
->ops
->remove_interface(local_to_hw(local
), &conf
);
487 if (local
->open_count
== 0) {
488 if (netif_running(local
->mdev
))
489 dev_close(local
->mdev
);
492 dev_close(local
->apdev
);
494 if (local
->ops
->stop
)
495 local
->ops
->stop(local_to_hw(local
));
497 tasklet_disable(&local
->tx_pending_tasklet
);
498 tasklet_disable(&local
->tasklet
);
504 static void ieee80211_set_multicast_list(struct net_device
*dev
)
506 struct ieee80211_local
*local
= wdev_priv(dev
->ieee80211_ptr
);
507 struct ieee80211_sub_if_data
*sdata
= IEEE80211_DEV_TO_SUB_IF(dev
);
508 int allmulti
, promisc
, sdata_allmulti
, sdata_promisc
;
510 allmulti
= !!(dev
->flags
& IFF_ALLMULTI
);
511 promisc
= !!(dev
->flags
& IFF_PROMISC
);
512 sdata_allmulti
= sdata
->flags
& IEEE80211_SDATA_ALLMULTI
;
513 sdata_promisc
= sdata
->flags
& IEEE80211_SDATA_PROMISC
;
515 if (allmulti
!= sdata_allmulti
) {
516 if (dev
->flags
& IFF_ALLMULTI
)
517 local
->iff_allmultis
++;
519 local
->iff_allmultis
--;
520 sdata
->flags
^= IEEE80211_SDATA_ALLMULTI
;
523 if (promisc
!= sdata_promisc
) {
524 if (dev
->flags
& IFF_PROMISC
)
525 local
->iff_promiscs
++;
527 local
->iff_promiscs
--;
528 sdata
->flags
^= IEEE80211_SDATA_PROMISC
;
531 dev_mc_sync(local
->mdev
, dev
);
534 static const struct header_ops ieee80211_header_ops
= {
535 .create
= eth_header
,
536 .parse
= header_parse_80211
,
537 .rebuild
= eth_rebuild_header
,
538 .cache
= eth_header_cache
,
539 .cache_update
= eth_header_cache_update
,
542 /* Must not be called for mdev and apdev */
543 void ieee80211_if_setup(struct net_device
*dev
)
546 dev
->header_ops
= &ieee80211_header_ops
;
547 dev
->hard_start_xmit
= ieee80211_subif_start_xmit
;
548 dev
->wireless_handlers
= &ieee80211_iw_handler_def
;
549 dev
->set_multicast_list
= ieee80211_set_multicast_list
;
550 dev
->change_mtu
= ieee80211_change_mtu
;
551 dev
->open
= ieee80211_open
;
552 dev
->stop
= ieee80211_stop
;
553 dev
->destructor
= ieee80211_if_free
;
556 /* WDS specialties */
558 int ieee80211_if_update_wds(struct net_device
*dev
, u8
*remote_addr
)
560 struct ieee80211_local
*local
= wdev_priv(dev
->ieee80211_ptr
);
561 struct ieee80211_sub_if_data
*sdata
= IEEE80211_DEV_TO_SUB_IF(dev
);
562 struct sta_info
*sta
;
563 DECLARE_MAC_BUF(mac
);
565 if (compare_ether_addr(remote_addr
, sdata
->u
.wds
.remote_addr
) == 0)
568 /* Create STA entry for the new peer */
569 sta
= sta_info_add(local
, dev
, remote_addr
, GFP_KERNEL
);
574 /* Remove STA entry for the old peer */
575 sta
= sta_info_get(local
, sdata
->u
.wds
.remote_addr
);
580 printk(KERN_DEBUG
"%s: could not find STA entry for WDS link "
582 dev
->name
, print_mac(mac
, sdata
->u
.wds
.remote_addr
));
585 /* Update WDS link data */
586 memcpy(&sdata
->u
.wds
.remote_addr
, remote_addr
, ETH_ALEN
);
591 /* everything else */
593 static int __ieee80211_if_config(struct net_device
*dev
,
594 struct sk_buff
*beacon
,
595 struct ieee80211_tx_control
*control
)
597 struct ieee80211_sub_if_data
*sdata
= IEEE80211_DEV_TO_SUB_IF(dev
);
598 struct ieee80211_local
*local
= wdev_priv(dev
->ieee80211_ptr
);
599 struct ieee80211_if_conf conf
;
601 if (!local
->ops
->config_interface
|| !netif_running(dev
))
604 memset(&conf
, 0, sizeof(conf
));
605 conf
.type
= sdata
->type
;
606 if (sdata
->type
== IEEE80211_IF_TYPE_STA
||
607 sdata
->type
== IEEE80211_IF_TYPE_IBSS
) {
608 conf
.bssid
= sdata
->u
.sta
.bssid
;
609 conf
.ssid
= sdata
->u
.sta
.ssid
;
610 conf
.ssid_len
= sdata
->u
.sta
.ssid_len
;
611 conf
.generic_elem
= sdata
->u
.sta
.extra_ie
;
612 conf
.generic_elem_len
= sdata
->u
.sta
.extra_ie_len
;
613 } else if (sdata
->type
== IEEE80211_IF_TYPE_AP
) {
614 conf
.ssid
= sdata
->u
.ap
.ssid
;
615 conf
.ssid_len
= sdata
->u
.ap
.ssid_len
;
616 conf
.generic_elem
= sdata
->u
.ap
.generic_elem
;
617 conf
.generic_elem_len
= sdata
->u
.ap
.generic_elem_len
;
618 conf
.beacon
= beacon
;
619 conf
.beacon_control
= control
;
621 return local
->ops
->config_interface(local_to_hw(local
),
622 dev
->ifindex
, &conf
);
625 int ieee80211_if_config(struct net_device
*dev
)
627 return __ieee80211_if_config(dev
, NULL
, NULL
);
630 int ieee80211_if_config_beacon(struct net_device
*dev
)
632 struct ieee80211_local
*local
= wdev_priv(dev
->ieee80211_ptr
);
633 struct ieee80211_tx_control control
;
636 if (!(local
->hw
.flags
& IEEE80211_HW_HOST_GEN_BEACON_TEMPLATE
))
638 skb
= ieee80211_beacon_get(local_to_hw(local
), dev
->ifindex
, &control
);
641 return __ieee80211_if_config(dev
, skb
, &control
);
644 int ieee80211_hw_config(struct ieee80211_local
*local
)
646 struct ieee80211_hw_mode
*mode
;
647 struct ieee80211_channel
*chan
;
650 if (local
->sta_scanning
) {
651 chan
= local
->scan_channel
;
652 mode
= local
->scan_hw_mode
;
654 chan
= local
->oper_channel
;
655 mode
= local
->oper_hw_mode
;
658 local
->hw
.conf
.channel
= chan
->chan
;
659 local
->hw
.conf
.channel_val
= chan
->val
;
660 if (!local
->hw
.conf
.power_level
) {
661 local
->hw
.conf
.power_level
= chan
->power_level
;
663 local
->hw
.conf
.power_level
= min(chan
->power_level
,
664 local
->hw
.conf
.power_level
);
666 local
->hw
.conf
.freq
= chan
->freq
;
667 local
->hw
.conf
.phymode
= mode
->mode
;
668 local
->hw
.conf
.antenna_max
= chan
->antenna_max
;
669 local
->hw
.conf
.chan
= chan
;
670 local
->hw
.conf
.mode
= mode
;
672 #ifdef CONFIG_MAC80211_VERBOSE_DEBUG
673 printk(KERN_DEBUG
"HW CONFIG: channel=%d freq=%d "
674 "phymode=%d\n", local
->hw
.conf
.channel
, local
->hw
.conf
.freq
,
675 local
->hw
.conf
.phymode
);
676 #endif /* CONFIG_MAC80211_VERBOSE_DEBUG */
678 if (local
->ops
->config
)
679 ret
= local
->ops
->config(local_to_hw(local
), &local
->hw
.conf
);
684 void ieee80211_erp_info_change_notify(struct net_device
*dev
, u8 changes
)
686 struct ieee80211_local
*local
= wdev_priv(dev
->ieee80211_ptr
);
687 struct ieee80211_sub_if_data
*sdata
= IEEE80211_DEV_TO_SUB_IF(dev
);
688 if (local
->ops
->erp_ie_changed
)
689 local
->ops
->erp_ie_changed(local_to_hw(local
), changes
,
690 !!(sdata
->flags
& IEEE80211_SDATA_USE_PROTECTION
),
691 !(sdata
->flags
& IEEE80211_SDATA_SHORT_PREAMBLE
));
694 void ieee80211_reset_erp_info(struct net_device
*dev
)
696 struct ieee80211_sub_if_data
*sdata
= IEEE80211_DEV_TO_SUB_IF(dev
);
698 sdata
->flags
&= ~(IEEE80211_SDATA_USE_PROTECTION
|
699 IEEE80211_SDATA_SHORT_PREAMBLE
);
700 ieee80211_erp_info_change_notify(dev
,
701 IEEE80211_ERP_CHANGE_PROTECTION
|
702 IEEE80211_ERP_CHANGE_PREAMBLE
);
705 void ieee80211_tx_status_irqsafe(struct ieee80211_hw
*hw
,
707 struct ieee80211_tx_status
*status
)
709 struct ieee80211_local
*local
= hw_to_local(hw
);
710 struct ieee80211_tx_status
*saved
;
713 skb
->dev
= local
->mdev
;
714 saved
= kmalloc(sizeof(struct ieee80211_tx_status
), GFP_ATOMIC
);
715 if (unlikely(!saved
)) {
717 printk(KERN_WARNING
"%s: Not enough memory, "
718 "dropping tx status", skb
->dev
->name
);
719 /* should be dev_kfree_skb_irq, but due to this function being
720 * named _irqsafe instead of just _irq we can't be sure that
721 * people won't call it from non-irq contexts */
722 dev_kfree_skb_any(skb
);
725 memcpy(saved
, status
, sizeof(struct ieee80211_tx_status
));
726 /* copy pointer to saved status into skb->cb for use by tasklet */
727 memcpy(skb
->cb
, &saved
, sizeof(saved
));
729 skb
->pkt_type
= IEEE80211_TX_STATUS_MSG
;
730 skb_queue_tail(status
->control
.flags
& IEEE80211_TXCTL_REQ_TX_STATUS
?
731 &local
->skb_queue
: &local
->skb_queue_unreliable
, skb
);
732 tmp
= skb_queue_len(&local
->skb_queue
) +
733 skb_queue_len(&local
->skb_queue_unreliable
);
734 while (tmp
> IEEE80211_IRQSAFE_QUEUE_LIMIT
&&
735 (skb
= skb_dequeue(&local
->skb_queue_unreliable
))) {
736 memcpy(&saved
, skb
->cb
, sizeof(saved
));
738 dev_kfree_skb_irq(skb
);
740 I802_DEBUG_INC(local
->tx_status_drop
);
742 tasklet_schedule(&local
->tasklet
);
744 EXPORT_SYMBOL(ieee80211_tx_status_irqsafe
);
746 static void ieee80211_tasklet_handler(unsigned long data
)
748 struct ieee80211_local
*local
= (struct ieee80211_local
*) data
;
750 struct ieee80211_rx_status rx_status
;
751 struct ieee80211_tx_status
*tx_status
;
753 while ((skb
= skb_dequeue(&local
->skb_queue
)) ||
754 (skb
= skb_dequeue(&local
->skb_queue_unreliable
))) {
755 switch (skb
->pkt_type
) {
756 case IEEE80211_RX_MSG
:
757 /* status is in skb->cb */
758 memcpy(&rx_status
, skb
->cb
, sizeof(rx_status
));
759 /* Clear skb->type in order to not confuse kernel
762 __ieee80211_rx(local_to_hw(local
), skb
, &rx_status
);
764 case IEEE80211_TX_STATUS_MSG
:
765 /* get pointer to saved status out of skb->cb */
766 memcpy(&tx_status
, skb
->cb
, sizeof(tx_status
));
768 ieee80211_tx_status(local_to_hw(local
),
772 default: /* should never get here! */
773 printk(KERN_ERR
"%s: Unknown message type (%d)\n",
774 wiphy_name(local
->hw
.wiphy
), skb
->pkt_type
);
781 /* Remove added headers (e.g., QoS control), encryption header/MIC, etc. to
782 * make a prepared TX frame (one that has been given to hw) to look like brand
783 * new IEEE 802.11 frame that is ready to go through TX processing again.
784 * Also, tx_packet_data in cb is restored from tx_control. */
785 static void ieee80211_remove_tx_extra(struct ieee80211_local
*local
,
786 struct ieee80211_key
*key
,
788 struct ieee80211_tx_control
*control
)
790 int hdrlen
, iv_len
, mic_len
;
791 struct ieee80211_tx_packet_data
*pkt_data
;
793 pkt_data
= (struct ieee80211_tx_packet_data
*)skb
->cb
;
794 pkt_data
->ifindex
= control
->ifindex
;
796 if (control
->flags
& IEEE80211_TXCTL_REQ_TX_STATUS
)
797 pkt_data
->flags
|= IEEE80211_TXPD_REQ_TX_STATUS
;
798 if (control
->flags
& IEEE80211_TXCTL_DO_NOT_ENCRYPT
)
799 pkt_data
->flags
|= IEEE80211_TXPD_DO_NOT_ENCRYPT
;
800 if (control
->flags
& IEEE80211_TXCTL_REQUEUE
)
801 pkt_data
->flags
|= IEEE80211_TXPD_REQUEUE
;
802 if (control
->type
== IEEE80211_IF_TYPE_MGMT
)
803 pkt_data
->flags
|= IEEE80211_TXPD_MGMT_IFACE
;
804 pkt_data
->queue
= control
->queue
;
806 hdrlen
= ieee80211_get_hdrlen_from_skb(skb
);
811 switch (key
->conf
.alg
) {
814 mic_len
= WEP_ICV_LEN
;
817 iv_len
= TKIP_IV_LEN
;
818 mic_len
= TKIP_ICV_LEN
;
821 iv_len
= CCMP_HDR_LEN
;
822 mic_len
= CCMP_MIC_LEN
;
828 if (skb
->len
>= mic_len
&&
829 !(key
->flags
& KEY_FLAG_UPLOADED_TO_HARDWARE
))
830 skb_trim(skb
, skb
->len
- mic_len
);
831 if (skb
->len
>= iv_len
&& skb
->len
> hdrlen
) {
832 memmove(skb
->data
+ iv_len
, skb
->data
, hdrlen
);
833 skb_pull(skb
, iv_len
);
838 struct ieee80211_hdr
*hdr
= (struct ieee80211_hdr
*) skb
->data
;
839 u16 fc
= le16_to_cpu(hdr
->frame_control
);
840 if ((fc
& 0x8C) == 0x88) /* QoS Control Field */ {
841 fc
&= ~IEEE80211_STYPE_QOS_DATA
;
842 hdr
->frame_control
= cpu_to_le16(fc
);
843 memmove(skb
->data
+ 2, skb
->data
, hdrlen
- 2);
849 void ieee80211_tx_status(struct ieee80211_hw
*hw
, struct sk_buff
*skb
,
850 struct ieee80211_tx_status
*status
)
852 struct sk_buff
*skb2
;
853 struct ieee80211_hdr
*hdr
= (struct ieee80211_hdr
*) skb
->data
;
854 struct ieee80211_local
*local
= hw_to_local(hw
);
857 struct ieee80211_tx_status_rtap_hdr
*rthdr
;
858 struct ieee80211_sub_if_data
*sdata
;
863 "%s: ieee80211_tx_status called with NULL status\n",
864 wiphy_name(local
->hw
.wiphy
));
869 if (status
->excessive_retries
) {
870 struct sta_info
*sta
;
871 sta
= sta_info_get(local
, hdr
->addr1
);
873 if (sta
->flags
& WLAN_STA_PS
) {
874 /* The STA is in power save mode, so assume
875 * that this TX packet failed because of that.
877 status
->excessive_retries
= 0;
878 status
->flags
|= IEEE80211_TX_STATUS_TX_FILTERED
;
884 if (status
->flags
& IEEE80211_TX_STATUS_TX_FILTERED
) {
885 struct sta_info
*sta
;
886 sta
= sta_info_get(local
, hdr
->addr1
);
888 sta
->tx_filtered_count
++;
890 /* Clear the TX filter mask for this STA when sending
891 * the next packet. If the STA went to power save mode,
892 * this will happen when it is waking up for the next
894 sta
->clear_dst_mask
= 1;
896 /* TODO: Is the WLAN_STA_PS flag always set here or is
897 * the race between RX and TX status causing some
898 * packets to be filtered out before 80211.o gets an
899 * update for PS status? This seems to be the case, so
900 * no changes are likely to be needed. */
901 if (sta
->flags
& WLAN_STA_PS
&&
902 skb_queue_len(&sta
->tx_filtered
) <
904 ieee80211_remove_tx_extra(local
, sta
->key
,
907 skb_queue_tail(&sta
->tx_filtered
, skb
);
908 } else if (!(sta
->flags
& WLAN_STA_PS
) &&
909 !(status
->control
.flags
& IEEE80211_TXCTL_REQUEUE
)) {
910 /* Software retry the packet once */
911 status
->control
.flags
|= IEEE80211_TXCTL_REQUEUE
;
912 ieee80211_remove_tx_extra(local
, sta
->key
,
917 if (net_ratelimit()) {
918 printk(KERN_DEBUG
"%s: dropped TX "
919 "filtered frame queue_len=%d "
921 wiphy_name(local
->hw
.wiphy
),
924 !!(sta
->flags
& WLAN_STA_PS
),
933 /* FIXME: STUPID to call this with both local and local->mdev */
934 rate_control_tx_status(local
, local
->mdev
, skb
, status
);
937 ieee80211_led_tx(local
, 0);
940 * Fragments are passed to low-level drivers as separate skbs, so these
941 * are actually fragments, not frames. Update frame counters only for
942 * the first fragment of the frame. */
944 frag
= le16_to_cpu(hdr
->seq_ctrl
) & IEEE80211_SCTL_FRAG
;
945 type
= le16_to_cpu(hdr
->frame_control
) & IEEE80211_FCTL_FTYPE
;
947 if (status
->flags
& IEEE80211_TX_STATUS_ACK
) {
949 local
->dot11TransmittedFrameCount
++;
950 if (is_multicast_ether_addr(hdr
->addr1
))
951 local
->dot11MulticastTransmittedFrameCount
++;
952 if (status
->retry_count
> 0)
953 local
->dot11RetryCount
++;
954 if (status
->retry_count
> 1)
955 local
->dot11MultipleRetryCount
++;
958 /* This counter shall be incremented for an acknowledged MPDU
959 * with an individual address in the address 1 field or an MPDU
960 * with a multicast address in the address 1 field of type Data
962 if (!is_multicast_ether_addr(hdr
->addr1
) ||
963 type
== IEEE80211_FTYPE_DATA
||
964 type
== IEEE80211_FTYPE_MGMT
)
965 local
->dot11TransmittedFragmentCount
++;
968 local
->dot11FailedCount
++;
971 msg_type
= (status
->flags
& IEEE80211_TX_STATUS_ACK
) ?
972 ieee80211_msg_tx_callback_ack
: ieee80211_msg_tx_callback_fail
;
974 /* this was a transmitted frame, but now we want to reuse it */
977 if ((status
->control
.flags
& IEEE80211_TXCTL_REQ_TX_STATUS
) &&
979 if (local
->monitors
) {
980 skb2
= skb_clone(skb
, GFP_ATOMIC
);
987 /* Send frame to hostapd */
988 ieee80211_rx_mgmt(local
, skb2
, NULL
, msg_type
);
994 if (!local
->monitors
) {
999 /* send frame to monitor interfaces now */
1001 if (skb_headroom(skb
) < sizeof(*rthdr
)) {
1002 printk(KERN_ERR
"ieee80211_tx_status: headroom too small\n");
1007 rthdr
= (struct ieee80211_tx_status_rtap_hdr
*)
1008 skb_push(skb
, sizeof(*rthdr
));
1010 memset(rthdr
, 0, sizeof(*rthdr
));
1011 rthdr
->hdr
.it_len
= cpu_to_le16(sizeof(*rthdr
));
1012 rthdr
->hdr
.it_present
=
1013 cpu_to_le32((1 << IEEE80211_RADIOTAP_TX_FLAGS
) |
1014 (1 << IEEE80211_RADIOTAP_DATA_RETRIES
));
1016 if (!(status
->flags
& IEEE80211_TX_STATUS_ACK
) &&
1017 !is_multicast_ether_addr(hdr
->addr1
))
1018 rthdr
->tx_flags
|= cpu_to_le16(IEEE80211_RADIOTAP_F_TX_FAIL
);
1020 if ((status
->control
.flags
& IEEE80211_TXCTL_USE_RTS_CTS
) &&
1021 (status
->control
.flags
& IEEE80211_TXCTL_USE_CTS_PROTECT
))
1022 rthdr
->tx_flags
|= cpu_to_le16(IEEE80211_RADIOTAP_F_TX_CTS
);
1023 else if (status
->control
.flags
& IEEE80211_TXCTL_USE_RTS_CTS
)
1024 rthdr
->tx_flags
|= cpu_to_le16(IEEE80211_RADIOTAP_F_TX_RTS
);
1026 rthdr
->data_retries
= status
->retry_count
;
1029 monitors
= local
->monitors
;
1030 list_for_each_entry_rcu(sdata
, &local
->interfaces
, list
) {
1032 * Using the monitors counter is possibly racy, but
1033 * if the value is wrong we simply either clone the skb
1034 * once too much or forget sending it to one monitor iface
1035 * The latter case isn't nice but fixing the race is much
1038 if (!monitors
|| !skb
)
1041 if (sdata
->type
== IEEE80211_IF_TYPE_MNTR
) {
1042 if (!netif_running(sdata
->dev
))
1046 skb2
= skb_clone(skb
, GFP_ATOMIC
);
1049 skb
->dev
= sdata
->dev
;
1050 /* XXX: is this sufficient for BPF? */
1051 skb_set_mac_header(skb
, 0);
1052 skb
->ip_summed
= CHECKSUM_UNNECESSARY
;
1053 skb
->pkt_type
= PACKET_OTHERHOST
;
1054 skb
->protocol
= htons(ETH_P_802_2
);
1055 memset(skb
->cb
, 0, sizeof(skb
->cb
));
1065 EXPORT_SYMBOL(ieee80211_tx_status
);
1067 struct ieee80211_hw
*ieee80211_alloc_hw(size_t priv_data_len
,
1068 const struct ieee80211_ops
*ops
)
1070 struct net_device
*mdev
;
1071 struct ieee80211_local
*local
;
1072 struct ieee80211_sub_if_data
*sdata
;
1074 struct wiphy
*wiphy
;
1076 /* Ensure 32-byte alignment of our private data and hw private data.
1077 * We use the wiphy priv data for both our ieee80211_local and for
1078 * the driver's private data
1080 * In memory it'll be like this:
1082 * +-------------------------+
1084 * +-------------------------+
1085 * | struct ieee80211_local |
1086 * +-------------------------+
1087 * | driver's private data |
1088 * +-------------------------+
1091 priv_size
= ((sizeof(struct ieee80211_local
) +
1092 NETDEV_ALIGN_CONST
) & ~NETDEV_ALIGN_CONST
) +
1095 wiphy
= wiphy_new(&mac80211_config_ops
, priv_size
);
1100 wiphy
->privid
= mac80211_wiphy_privid
;
1102 local
= wiphy_priv(wiphy
);
1103 local
->hw
.wiphy
= wiphy
;
1105 local
->hw
.priv
= (char *)local
+
1106 ((sizeof(struct ieee80211_local
) +
1107 NETDEV_ALIGN_CONST
) & ~NETDEV_ALIGN_CONST
);
1110 BUG_ON(!ops
->start
);
1112 BUG_ON(!ops
->config
);
1113 BUG_ON(!ops
->add_interface
);
1114 BUG_ON(!ops
->remove_interface
);
1115 BUG_ON(!ops
->configure_filter
);
1118 /* for now, mdev needs sub_if_data :/ */
1119 mdev
= alloc_netdev(sizeof(struct ieee80211_sub_if_data
),
1120 "wmaster%d", ether_setup
);
1126 sdata
= IEEE80211_DEV_TO_SUB_IF(mdev
);
1127 mdev
->ieee80211_ptr
= &sdata
->wdev
;
1128 sdata
->wdev
.wiphy
= wiphy
;
1130 local
->hw
.queues
= 1; /* default */
1133 local
->rx_pre_handlers
= ieee80211_rx_pre_handlers
;
1134 local
->rx_handlers
= ieee80211_rx_handlers
;
1135 local
->tx_handlers
= ieee80211_tx_handlers
;
1137 local
->bridge_packets
= 1;
1139 local
->rts_threshold
= IEEE80211_MAX_RTS_THRESHOLD
;
1140 local
->fragmentation_threshold
= IEEE80211_MAX_FRAG_THRESHOLD
;
1141 local
->short_retry_limit
= 7;
1142 local
->long_retry_limit
= 4;
1143 local
->hw
.conf
.radio_enabled
= 1;
1145 local
->enabled_modes
= ~0;
1147 INIT_LIST_HEAD(&local
->modes_list
);
1149 INIT_LIST_HEAD(&local
->interfaces
);
1151 INIT_DELAYED_WORK(&local
->scan_work
, ieee80211_sta_scan_work
);
1152 ieee80211_rx_bss_list_init(mdev
);
1154 sta_info_init(local
);
1156 mdev
->hard_start_xmit
= ieee80211_master_start_xmit
;
1157 mdev
->open
= ieee80211_master_open
;
1158 mdev
->stop
= ieee80211_master_stop
;
1159 mdev
->type
= ARPHRD_IEEE80211
;
1160 mdev
->header_ops
= &ieee80211_header_ops
;
1161 mdev
->set_multicast_list
= ieee80211_master_set_multicast_list
;
1163 sdata
->type
= IEEE80211_IF_TYPE_AP
;
1165 sdata
->local
= local
;
1166 sdata
->u
.ap
.force_unicast_rateidx
= -1;
1167 sdata
->u
.ap
.max_ratectrl_rateidx
= -1;
1168 ieee80211_if_sdata_init(sdata
);
1169 /* no RCU needed since we're still during init phase */
1170 list_add_tail(&sdata
->list
, &local
->interfaces
);
1172 tasklet_init(&local
->tx_pending_tasklet
, ieee80211_tx_pending
,
1173 (unsigned long)local
);
1174 tasklet_disable(&local
->tx_pending_tasklet
);
1176 tasklet_init(&local
->tasklet
,
1177 ieee80211_tasklet_handler
,
1178 (unsigned long) local
);
1179 tasklet_disable(&local
->tasklet
);
1181 skb_queue_head_init(&local
->skb_queue
);
1182 skb_queue_head_init(&local
->skb_queue_unreliable
);
1184 return local_to_hw(local
);
1186 EXPORT_SYMBOL(ieee80211_alloc_hw
);
1188 int ieee80211_register_hw(struct ieee80211_hw
*hw
)
1190 struct ieee80211_local
*local
= hw_to_local(hw
);
1194 result
= wiphy_register(local
->hw
.wiphy
);
1198 name
= wiphy_dev(local
->hw
.wiphy
)->driver
->name
;
1199 local
->hw
.workqueue
= create_singlethread_workqueue(name
);
1200 if (!local
->hw
.workqueue
) {
1202 goto fail_workqueue
;
1206 * The hardware needs headroom for sending the frame,
1207 * and we need some headroom for passing the frame to monitor
1208 * interfaces, but never both at the same time.
1210 local
->tx_headroom
= max_t(unsigned int , local
->hw
.extra_tx_headroom
,
1211 sizeof(struct ieee80211_tx_status_rtap_hdr
));
1213 debugfs_hw_add(local
);
1215 local
->hw
.conf
.beacon_int
= 1000;
1217 local
->wstats_flags
|= local
->hw
.max_rssi
?
1218 IW_QUAL_LEVEL_UPDATED
: IW_QUAL_LEVEL_INVALID
;
1219 local
->wstats_flags
|= local
->hw
.max_signal
?
1220 IW_QUAL_QUAL_UPDATED
: IW_QUAL_QUAL_INVALID
;
1221 local
->wstats_flags
|= local
->hw
.max_noise
?
1222 IW_QUAL_NOISE_UPDATED
: IW_QUAL_NOISE_INVALID
;
1223 if (local
->hw
.max_rssi
< 0 || local
->hw
.max_noise
< 0)
1224 local
->wstats_flags
|= IW_QUAL_DBM
;
1226 result
= sta_info_start(local
);
1231 result
= dev_alloc_name(local
->mdev
, local
->mdev
->name
);
1235 memcpy(local
->mdev
->dev_addr
, local
->hw
.wiphy
->perm_addr
, ETH_ALEN
);
1236 SET_NETDEV_DEV(local
->mdev
, wiphy_dev(local
->hw
.wiphy
));
1238 result
= register_netdevice(local
->mdev
);
1242 ieee80211_debugfs_add_netdev(IEEE80211_DEV_TO_SUB_IF(local
->mdev
));
1243 ieee80211_if_set_type(local
->mdev
, IEEE80211_IF_TYPE_AP
);
1245 result
= ieee80211_init_rate_ctrl_alg(local
, NULL
);
1247 printk(KERN_DEBUG
"%s: Failed to initialize rate control "
1248 "algorithm\n", wiphy_name(local
->hw
.wiphy
));
1252 result
= ieee80211_wep_init(local
);
1255 printk(KERN_DEBUG
"%s: Failed to initialize wep\n",
1256 wiphy_name(local
->hw
.wiphy
));
1260 ieee80211_install_qdisc(local
->mdev
);
1262 /* add one default STA interface */
1263 result
= ieee80211_if_add(local
->mdev
, "wlan%d", NULL
,
1264 IEEE80211_IF_TYPE_STA
);
1266 printk(KERN_WARNING
"%s: Failed to add default virtual iface\n",
1267 wiphy_name(local
->hw
.wiphy
));
1269 local
->reg_state
= IEEE80211_DEV_REGISTERED
;
1272 ieee80211_led_init(local
);
1277 rate_control_deinitialize(local
);
1279 ieee80211_debugfs_remove_netdev(IEEE80211_DEV_TO_SUB_IF(local
->mdev
));
1280 unregister_netdevice(local
->mdev
);
1283 sta_info_stop(local
);
1285 debugfs_hw_del(local
);
1286 destroy_workqueue(local
->hw
.workqueue
);
1288 wiphy_unregister(local
->hw
.wiphy
);
1291 EXPORT_SYMBOL(ieee80211_register_hw
);
1293 int ieee80211_register_hwmode(struct ieee80211_hw
*hw
,
1294 struct ieee80211_hw_mode
*mode
)
1296 struct ieee80211_local
*local
= hw_to_local(hw
);
1297 struct ieee80211_rate
*rate
;
1300 INIT_LIST_HEAD(&mode
->list
);
1301 list_add_tail(&mode
->list
, &local
->modes_list
);
1303 local
->hw_modes
|= (1 << mode
->mode
);
1304 for (i
= 0; i
< mode
->num_rates
; i
++) {
1305 rate
= &(mode
->rates
[i
]);
1306 rate
->rate_inv
= CHAN_UTIL_RATE_LCM
/ rate
->rate
;
1308 ieee80211_prepare_rates(local
, mode
);
1310 if (!local
->oper_hw_mode
) {
1311 /* Default to this mode */
1312 local
->hw
.conf
.phymode
= mode
->mode
;
1313 local
->oper_hw_mode
= local
->scan_hw_mode
= mode
;
1314 local
->oper_channel
= local
->scan_channel
= &mode
->channels
[0];
1315 local
->hw
.conf
.mode
= local
->oper_hw_mode
;
1316 local
->hw
.conf
.chan
= local
->oper_channel
;
1319 if (!(hw
->flags
& IEEE80211_HW_DEFAULT_REG_DOMAIN_CONFIGURED
))
1320 ieee80211_set_default_regdomain(mode
);
1324 EXPORT_SYMBOL(ieee80211_register_hwmode
);
1326 void ieee80211_unregister_hw(struct ieee80211_hw
*hw
)
1328 struct ieee80211_local
*local
= hw_to_local(hw
);
1329 struct ieee80211_sub_if_data
*sdata
, *tmp
;
1332 tasklet_kill(&local
->tx_pending_tasklet
);
1333 tasklet_kill(&local
->tasklet
);
1337 BUG_ON(local
->reg_state
!= IEEE80211_DEV_REGISTERED
);
1339 local
->reg_state
= IEEE80211_DEV_UNREGISTERED
;
1341 ieee80211_if_del_mgmt(local
);
1344 * At this point, interface list manipulations are fine
1345 * because the driver cannot be handing us frames any
1346 * more and the tasklet is killed.
1350 * First, we remove all non-master interfaces. Do this because they
1351 * may have bss pointer dependency on the master, and when we free
1352 * the master these would be freed as well, breaking our list
1353 * iteration completely.
1355 list_for_each_entry_safe(sdata
, tmp
, &local
->interfaces
, list
) {
1356 if (sdata
->dev
== local
->mdev
)
1358 list_del(&sdata
->list
);
1359 __ieee80211_if_del(local
, sdata
);
1362 /* then, finally, remove the master interface */
1363 __ieee80211_if_del(local
, IEEE80211_DEV_TO_SUB_IF(local
->mdev
));
1367 ieee80211_rx_bss_list_deinit(local
->mdev
);
1368 ieee80211_clear_tx_pending(local
);
1369 sta_info_stop(local
);
1370 rate_control_deinitialize(local
);
1371 debugfs_hw_del(local
);
1373 for (i
= 0; i
< NUM_IEEE80211_MODES
; i
++) {
1374 kfree(local
->supp_rates
[i
]);
1375 kfree(local
->basic_rates
[i
]);
1378 if (skb_queue_len(&local
->skb_queue
)
1379 || skb_queue_len(&local
->skb_queue_unreliable
))
1380 printk(KERN_WARNING
"%s: skb_queue not empty\n",
1381 wiphy_name(local
->hw
.wiphy
));
1382 skb_queue_purge(&local
->skb_queue
);
1383 skb_queue_purge(&local
->skb_queue_unreliable
);
1385 destroy_workqueue(local
->hw
.workqueue
);
1386 wiphy_unregister(local
->hw
.wiphy
);
1387 ieee80211_wep_free(local
);
1388 ieee80211_led_exit(local
);
1390 EXPORT_SYMBOL(ieee80211_unregister_hw
);
1392 void ieee80211_free_hw(struct ieee80211_hw
*hw
)
1394 struct ieee80211_local
*local
= hw_to_local(hw
);
1396 ieee80211_if_free(local
->mdev
);
1397 wiphy_free(local
->hw
.wiphy
);
1399 EXPORT_SYMBOL(ieee80211_free_hw
);
1401 static int __init
ieee80211_init(void)
1403 struct sk_buff
*skb
;
1406 BUILD_BUG_ON(sizeof(struct ieee80211_tx_packet_data
) > sizeof(skb
->cb
));
1408 ret
= ieee80211_wme_register();
1410 printk(KERN_DEBUG
"ieee80211_init: failed to "
1411 "initialize WME (err=%d)\n", ret
);
1415 ieee80211_debugfs_netdev_init();
1416 ieee80211_regdomain_init();
1421 static void __exit
ieee80211_exit(void)
1423 ieee80211_wme_unregister();
1424 ieee80211_debugfs_netdev_exit();
1428 subsys_initcall(ieee80211_init
);
1429 module_exit(ieee80211_exit
);
1431 MODULE_DESCRIPTION("IEEE 802.11 subsystem");
1432 MODULE_LICENSE("GPL");