Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 1 | /* |
| 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 Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 23 | #include <linux/bitmap.h> |
Eric W. Biederman | 881d966 | 2007-09-17 11:56:21 -0700 | [diff] [blame] | 24 | #include <net/net_namespace.h> |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 25 | #include <net/cfg80211.h> |
| 26 | |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 27 | #include "ieee80211_i.h" |
| 28 | #include "ieee80211_rate.h" |
| 29 | #include "wep.h" |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 30 | #include "wme.h" |
| 31 | #include "aes_ccm.h" |
| 32 | #include "ieee80211_led.h" |
Michael Wu | e0eb685 | 2007-09-18 17:29:21 -0400 | [diff] [blame] | 33 | #include "cfg.h" |
Jiri Benc | e9f207f | 2007-05-05 11:46:38 -0700 | [diff] [blame] | 34 | #include "debugfs.h" |
| 35 | #include "debugfs_netdev.h" |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 36 | |
Ron Rindjunsky | d3c990f | 2007-11-26 16:14:34 +0200 | [diff] [blame] | 37 | #define SUPP_MCS_SET_LEN 16 |
| 38 | |
Johannes Berg | b306f45 | 2007-07-10 19:32:08 +0200 | [diff] [blame] | 39 | /* |
| 40 | * For seeing transmitted packets on monitor interfaces |
| 41 | * we have a radiotap header too. |
| 42 | */ |
| 43 | struct ieee80211_tx_status_rtap_hdr { |
| 44 | struct ieee80211_radiotap_header hdr; |
| 45 | __le16 tx_flags; |
| 46 | u8 data_retries; |
| 47 | } __attribute__ ((packed)); |
| 48 | |
Johannes Berg | b2c258f | 2007-07-27 15:43:23 +0200 | [diff] [blame] | 49 | /* common interface routines */ |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 50 | |
Stephen Hemminger | b95cce3 | 2007-09-26 22:13:38 -0700 | [diff] [blame] | 51 | static int header_parse_80211(const struct sk_buff *skb, unsigned char *haddr) |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 52 | { |
Johannes Berg | b2c258f | 2007-07-27 15:43:23 +0200 | [diff] [blame] | 53 | memcpy(haddr, skb_mac_header(skb) + 10, ETH_ALEN); /* addr2 */ |
| 54 | return ETH_ALEN; |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 55 | } |
| 56 | |
Johannes Berg | 4150c57 | 2007-09-17 01:29:23 -0400 | [diff] [blame] | 57 | /* must be called under mdev tx lock */ |
| 58 | static void ieee80211_configure_filter(struct ieee80211_local *local) |
| 59 | { |
| 60 | unsigned int changed_flags; |
| 61 | unsigned int new_flags = 0; |
| 62 | |
Johannes Berg | 5391899 | 2007-09-26 15:19:47 +0200 | [diff] [blame] | 63 | if (atomic_read(&local->iff_promiscs)) |
Johannes Berg | 4150c57 | 2007-09-17 01:29:23 -0400 | [diff] [blame] | 64 | new_flags |= FIF_PROMISC_IN_BSS; |
| 65 | |
Johannes Berg | 5391899 | 2007-09-26 15:19:47 +0200 | [diff] [blame] | 66 | if (atomic_read(&local->iff_allmultis)) |
Johannes Berg | 4150c57 | 2007-09-17 01:29:23 -0400 | [diff] [blame] | 67 | 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 Berg | b2c258f | 2007-07-27 15:43:23 +0200 | [diff] [blame] | 89 | /* master interface */ |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 90 | |
| 91 | static 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 Berg | 7901042 | 2007-09-18 17:29:21 -0400 | [diff] [blame] | 97 | /* we hold the RTNL here so can safely walk the list */ |
| 98 | list_for_each_entry(sdata, &local->interfaces, list) { |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 99 | if (sdata->dev != dev && netif_running(sdata->dev)) { |
| 100 | res = 0; |
| 101 | break; |
| 102 | } |
| 103 | } |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 104 | return res; |
| 105 | } |
| 106 | |
| 107 | static 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 Berg | 7901042 | 2007-09-18 17:29:21 -0400 | [diff] [blame] | 112 | /* we hold the RTNL here so can safely walk the list */ |
| 113 | list_for_each_entry(sdata, &local->interfaces, list) |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 114 | if (sdata->dev != dev && netif_running(sdata->dev)) |
| 115 | dev_close(sdata->dev); |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 116 | |
| 117 | return 0; |
| 118 | } |
| 119 | |
Johannes Berg | 4150c57 | 2007-09-17 01:29:23 -0400 | [diff] [blame] | 120 | static 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 Berg | b2c258f | 2007-07-27 15:43:23 +0200 | [diff] [blame] | 127 | /* regular interfaces */ |
| 128 | |
| 129 | static 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 | |
| 146 | static 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 Berg | b2c258f | 2007-07-27 15:43:23 +0200 | [diff] [blame] | 162 | static int ieee80211_open(struct net_device *dev) |
| 163 | { |
| 164 | struct ieee80211_sub_if_data *sdata, *nsdata; |
| 165 | struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr); |
| 166 | struct ieee80211_if_init_conf conf; |
| 167 | int res; |
Michael Buesch | ceffefd | 2008-02-10 14:16:52 +0100 | [diff] [blame^] | 168 | bool need_hw_reconfig = 0; |
Johannes Berg | b2c258f | 2007-07-27 15:43:23 +0200 | [diff] [blame] | 169 | |
| 170 | sdata = IEEE80211_DEV_TO_SUB_IF(dev); |
Johannes Berg | 0ec3ca44 | 2007-09-17 01:29:24 -0400 | [diff] [blame] | 171 | |
Johannes Berg | 7901042 | 2007-09-18 17:29:21 -0400 | [diff] [blame] | 172 | /* we hold the RTNL here so can safely walk the list */ |
| 173 | list_for_each_entry(nsdata, &local->interfaces, list) { |
Johannes Berg | b2c258f | 2007-07-27 15:43:23 +0200 | [diff] [blame] | 174 | struct net_device *ndev = nsdata->dev; |
| 175 | |
| 176 | if (ndev != dev && ndev != local->mdev && netif_running(ndev) && |
Johannes Berg | 0ec3ca44 | 2007-09-17 01:29:24 -0400 | [diff] [blame] | 177 | compare_ether_addr(dev->dev_addr, ndev->dev_addr) == 0) { |
| 178 | /* |
| 179 | * check whether it may have the same address |
| 180 | */ |
Johannes Berg | 51fb61e | 2007-12-19 01:31:27 +0100 | [diff] [blame] | 181 | if (!identical_mac_addr_allowed(sdata->vif.type, |
| 182 | nsdata->vif.type)) |
Johannes Berg | 0ec3ca44 | 2007-09-17 01:29:24 -0400 | [diff] [blame] | 183 | return -ENOTUNIQ; |
Johannes Berg | 0ec3ca44 | 2007-09-17 01:29:24 -0400 | [diff] [blame] | 184 | |
| 185 | /* |
| 186 | * can only add VLANs to enabled APs |
| 187 | */ |
Johannes Berg | 51fb61e | 2007-12-19 01:31:27 +0100 | [diff] [blame] | 188 | if (sdata->vif.type == IEEE80211_IF_TYPE_VLAN && |
| 189 | nsdata->vif.type == IEEE80211_IF_TYPE_AP && |
Johannes Berg | 0ec3ca44 | 2007-09-17 01:29:24 -0400 | [diff] [blame] | 190 | netif_running(nsdata->dev)) |
| 191 | sdata->u.vlan.ap = nsdata; |
Johannes Berg | b2c258f | 2007-07-27 15:43:23 +0200 | [diff] [blame] | 192 | } |
| 193 | } |
Johannes Berg | b2c258f | 2007-07-27 15:43:23 +0200 | [diff] [blame] | 194 | |
Johannes Berg | 51fb61e | 2007-12-19 01:31:27 +0100 | [diff] [blame] | 195 | switch (sdata->vif.type) { |
Johannes Berg | 0ec3ca44 | 2007-09-17 01:29:24 -0400 | [diff] [blame] | 196 | case IEEE80211_IF_TYPE_WDS: |
| 197 | if (is_zero_ether_addr(sdata->u.wds.remote_addr)) |
| 198 | return -ENOLINK; |
| 199 | break; |
| 200 | case IEEE80211_IF_TYPE_VLAN: |
| 201 | if (!sdata->u.vlan.ap) |
| 202 | return -ENOLINK; |
| 203 | break; |
Johannes Berg | fb1c1cd | 2007-09-26 15:19:43 +0200 | [diff] [blame] | 204 | case IEEE80211_IF_TYPE_AP: |
Johannes Berg | fb1c1cd | 2007-09-26 15:19:43 +0200 | [diff] [blame] | 205 | case IEEE80211_IF_TYPE_STA: |
| 206 | case IEEE80211_IF_TYPE_MNTR: |
| 207 | case IEEE80211_IF_TYPE_IBSS: |
| 208 | /* no special treatment */ |
| 209 | break; |
Johannes Berg | a289755 | 2007-09-28 14:01:25 +0200 | [diff] [blame] | 210 | case IEEE80211_IF_TYPE_INVALID: |
| 211 | /* cannot happen */ |
| 212 | WARN_ON(1); |
| 213 | break; |
Johannes Berg | 0ec3ca44 | 2007-09-17 01:29:24 -0400 | [diff] [blame] | 214 | } |
Johannes Berg | b2c258f | 2007-07-27 15:43:23 +0200 | [diff] [blame] | 215 | |
Johannes Berg | b2c258f | 2007-07-27 15:43:23 +0200 | [diff] [blame] | 216 | if (local->open_count == 0) { |
| 217 | res = 0; |
Johannes Berg | 4150c57 | 2007-09-17 01:29:23 -0400 | [diff] [blame] | 218 | if (local->ops->start) |
| 219 | res = local->ops->start(local_to_hw(local)); |
| 220 | if (res) |
Johannes Berg | b2c258f | 2007-07-27 15:43:23 +0200 | [diff] [blame] | 221 | return res; |
Michael Buesch | ceffefd | 2008-02-10 14:16:52 +0100 | [diff] [blame^] | 222 | need_hw_reconfig = 1; |
Ivo van Doorn | cdcb006 | 2008-01-07 19:45:24 +0100 | [diff] [blame] | 223 | ieee80211_led_radio(local, local->hw.conf.radio_enabled); |
Johannes Berg | b2c258f | 2007-07-27 15:43:23 +0200 | [diff] [blame] | 224 | } |
Johannes Berg | b2c258f | 2007-07-27 15:43:23 +0200 | [diff] [blame] | 225 | |
Johannes Berg | 51fb61e | 2007-12-19 01:31:27 +0100 | [diff] [blame] | 226 | switch (sdata->vif.type) { |
Johannes Berg | 0ec3ca44 | 2007-09-17 01:29:24 -0400 | [diff] [blame] | 227 | case IEEE80211_IF_TYPE_VLAN: |
| 228 | list_add(&sdata->u.vlan.list, &sdata->u.vlan.ap->u.ap.vlans); |
| 229 | /* no need to tell driver */ |
| 230 | break; |
Johannes Berg | 4150c57 | 2007-09-17 01:29:23 -0400 | [diff] [blame] | 231 | case IEEE80211_IF_TYPE_MNTR: |
| 232 | /* must be before the call to ieee80211_configure_filter */ |
Johannes Berg | b2c258f | 2007-07-27 15:43:23 +0200 | [diff] [blame] | 233 | local->monitors++; |
Johannes Berg | 4150c57 | 2007-09-17 01:29:23 -0400 | [diff] [blame] | 234 | if (local->monitors == 1) { |
| 235 | netif_tx_lock_bh(local->mdev); |
| 236 | ieee80211_configure_filter(local); |
| 237 | netif_tx_unlock_bh(local->mdev); |
| 238 | |
| 239 | local->hw.conf.flags |= IEEE80211_CONF_RADIOTAP; |
Johannes Berg | 4150c57 | 2007-09-17 01:29:23 -0400 | [diff] [blame] | 240 | } |
| 241 | break; |
| 242 | case IEEE80211_IF_TYPE_STA: |
| 243 | case IEEE80211_IF_TYPE_IBSS: |
| 244 | sdata->u.sta.flags &= ~IEEE80211_STA_PREV_BSSID_SET; |
| 245 | /* fall through */ |
| 246 | default: |
Johannes Berg | 32bfd35 | 2007-12-19 01:31:26 +0100 | [diff] [blame] | 247 | conf.vif = &sdata->vif; |
Johannes Berg | 51fb61e | 2007-12-19 01:31:27 +0100 | [diff] [blame] | 248 | conf.type = sdata->vif.type; |
Johannes Berg | 4150c57 | 2007-09-17 01:29:23 -0400 | [diff] [blame] | 249 | conf.mac_addr = dev->dev_addr; |
| 250 | res = local->ops->add_interface(local_to_hw(local), &conf); |
| 251 | if (res && !local->open_count && local->ops->stop) |
| 252 | local->ops->stop(local_to_hw(local)); |
| 253 | if (res) |
| 254 | return res; |
| 255 | |
Johannes Berg | b2c258f | 2007-07-27 15:43:23 +0200 | [diff] [blame] | 256 | ieee80211_if_config(dev); |
Daniel Drake | d9430a3 | 2007-07-27 15:43:24 +0200 | [diff] [blame] | 257 | ieee80211_reset_erp_info(dev); |
Johannes Berg | 11a843b | 2007-08-28 17:01:55 -0400 | [diff] [blame] | 258 | ieee80211_enable_keys(sdata); |
Johannes Berg | 4150c57 | 2007-09-17 01:29:23 -0400 | [diff] [blame] | 259 | |
Johannes Berg | 51fb61e | 2007-12-19 01:31:27 +0100 | [diff] [blame] | 260 | if (sdata->vif.type == IEEE80211_IF_TYPE_STA && |
Johannes Berg | ddd3d2b | 2007-09-26 17:53:20 +0200 | [diff] [blame] | 261 | !(sdata->flags & IEEE80211_SDATA_USERSPACE_MLME)) |
Johannes Berg | 4150c57 | 2007-09-17 01:29:23 -0400 | [diff] [blame] | 262 | netif_carrier_off(dev); |
| 263 | else |
| 264 | netif_carrier_on(dev); |
Daniel Drake | d9430a3 | 2007-07-27 15:43:24 +0200 | [diff] [blame] | 265 | } |
Johannes Berg | b2c258f | 2007-07-27 15:43:23 +0200 | [diff] [blame] | 266 | |
Johannes Berg | 4150c57 | 2007-09-17 01:29:23 -0400 | [diff] [blame] | 267 | if (local->open_count == 0) { |
| 268 | res = dev_open(local->mdev); |
| 269 | WARN_ON(res); |
Johannes Berg | 4150c57 | 2007-09-17 01:29:23 -0400 | [diff] [blame] | 270 | tasklet_enable(&local->tx_pending_tasklet); |
| 271 | tasklet_enable(&local->tasklet); |
| 272 | } |
| 273 | |
Johannes Berg | c1428b3 | 2007-11-16 02:54:53 +0100 | [diff] [blame] | 274 | /* |
| 275 | * set_multicast_list will be invoked by the networking core |
| 276 | * which will check whether any increments here were done in |
| 277 | * error and sync them down to the hardware as filter flags. |
| 278 | */ |
| 279 | if (sdata->flags & IEEE80211_SDATA_ALLMULTI) |
| 280 | atomic_inc(&local->iff_allmultis); |
| 281 | |
| 282 | if (sdata->flags & IEEE80211_SDATA_PROMISC) |
| 283 | atomic_inc(&local->iff_promiscs); |
| 284 | |
Johannes Berg | 4150c57 | 2007-09-17 01:29:23 -0400 | [diff] [blame] | 285 | local->open_count++; |
Michael Buesch | ceffefd | 2008-02-10 14:16:52 +0100 | [diff] [blame^] | 286 | if (need_hw_reconfig) |
| 287 | ieee80211_hw_config(local); |
Johannes Berg | b2c258f | 2007-07-27 15:43:23 +0200 | [diff] [blame] | 288 | |
| 289 | netif_start_queue(dev); |
Johannes Berg | 4150c57 | 2007-09-17 01:29:23 -0400 | [diff] [blame] | 290 | |
Johannes Berg | b2c258f | 2007-07-27 15:43:23 +0200 | [diff] [blame] | 291 | return 0; |
| 292 | } |
| 293 | |
Johannes Berg | 4150c57 | 2007-09-17 01:29:23 -0400 | [diff] [blame] | 294 | static int ieee80211_stop(struct net_device *dev) |
Johannes Berg | b2c258f | 2007-07-27 15:43:23 +0200 | [diff] [blame] | 295 | { |
Johannes Berg | 4150c57 | 2007-09-17 01:29:23 -0400 | [diff] [blame] | 296 | struct ieee80211_sub_if_data *sdata; |
Johannes Berg | b2c258f | 2007-07-27 15:43:23 +0200 | [diff] [blame] | 297 | struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr); |
Johannes Berg | 4150c57 | 2007-09-17 01:29:23 -0400 | [diff] [blame] | 298 | struct ieee80211_if_init_conf conf; |
Ron Rindjunsky | 07db218 | 2007-12-25 17:00:33 +0200 | [diff] [blame] | 299 | struct sta_info *sta; |
| 300 | int i; |
Johannes Berg | b2c258f | 2007-07-27 15:43:23 +0200 | [diff] [blame] | 301 | |
Johannes Berg | 4150c57 | 2007-09-17 01:29:23 -0400 | [diff] [blame] | 302 | sdata = IEEE80211_DEV_TO_SUB_IF(dev); |
| 303 | |
Ron Rindjunsky | 07db218 | 2007-12-25 17:00:33 +0200 | [diff] [blame] | 304 | list_for_each_entry(sta, &local->sta_list, list) { |
Ron Rindjunsky | 5b3d71d | 2008-01-13 18:21:58 +0200 | [diff] [blame] | 305 | if (sta->dev == dev) |
| 306 | for (i = 0; i < STA_TID_NUM; i++) |
| 307 | ieee80211_sta_stop_rx_ba_session(sta->dev, |
| 308 | sta->addr, i, |
| 309 | WLAN_BACK_RECIPIENT, |
Ron Rindjunsky | 07db218 | 2007-12-25 17:00:33 +0200 | [diff] [blame] | 310 | WLAN_REASON_QSTA_LEAVE_QBSS); |
| 311 | } |
| 312 | |
Johannes Berg | 4150c57 | 2007-09-17 01:29:23 -0400 | [diff] [blame] | 313 | netif_stop_queue(dev); |
| 314 | |
Johannes Berg | c1428b3 | 2007-11-16 02:54:53 +0100 | [diff] [blame] | 315 | /* |
| 316 | * Don't count this interface for promisc/allmulti while it |
| 317 | * is down. dev_mc_unsync() will invoke set_multicast_list |
| 318 | * on the master interface which will sync these down to the |
| 319 | * hardware as filter flags. |
| 320 | */ |
| 321 | if (sdata->flags & IEEE80211_SDATA_ALLMULTI) |
| 322 | atomic_dec(&local->iff_allmultis); |
| 323 | |
| 324 | if (sdata->flags & IEEE80211_SDATA_PROMISC) |
| 325 | atomic_dec(&local->iff_promiscs); |
| 326 | |
Johannes Berg | 4150c57 | 2007-09-17 01:29:23 -0400 | [diff] [blame] | 327 | dev_mc_unsync(local->mdev, dev); |
| 328 | |
Johannes Berg | 5dfdaf5 | 2007-12-19 02:03:33 +0100 | [diff] [blame] | 329 | /* APs need special treatment */ |
Johannes Berg | 51fb61e | 2007-12-19 01:31:27 +0100 | [diff] [blame] | 330 | if (sdata->vif.type == IEEE80211_IF_TYPE_AP) { |
Johannes Berg | 0ec3ca44 | 2007-09-17 01:29:24 -0400 | [diff] [blame] | 331 | struct ieee80211_sub_if_data *vlan, *tmp; |
Johannes Berg | 5dfdaf5 | 2007-12-19 02:03:33 +0100 | [diff] [blame] | 332 | struct beacon_data *old_beacon = sdata->u.ap.beacon; |
Johannes Berg | 0ec3ca44 | 2007-09-17 01:29:24 -0400 | [diff] [blame] | 333 | |
Johannes Berg | 5dfdaf5 | 2007-12-19 02:03:33 +0100 | [diff] [blame] | 334 | /* remove beacon */ |
| 335 | rcu_assign_pointer(sdata->u.ap.beacon, NULL); |
| 336 | synchronize_rcu(); |
| 337 | kfree(old_beacon); |
| 338 | |
| 339 | /* down all dependent devices, that is VLANs */ |
Johannes Berg | 0ec3ca44 | 2007-09-17 01:29:24 -0400 | [diff] [blame] | 340 | list_for_each_entry_safe(vlan, tmp, &sdata->u.ap.vlans, |
| 341 | u.vlan.list) |
| 342 | dev_close(vlan->dev); |
| 343 | WARN_ON(!list_empty(&sdata->u.ap.vlans)); |
| 344 | } |
| 345 | |
Johannes Berg | 4150c57 | 2007-09-17 01:29:23 -0400 | [diff] [blame] | 346 | local->open_count--; |
| 347 | |
Johannes Berg | 51fb61e | 2007-12-19 01:31:27 +0100 | [diff] [blame] | 348 | switch (sdata->vif.type) { |
Johannes Berg | 0ec3ca44 | 2007-09-17 01:29:24 -0400 | [diff] [blame] | 349 | case IEEE80211_IF_TYPE_VLAN: |
| 350 | list_del(&sdata->u.vlan.list); |
| 351 | sdata->u.vlan.ap = NULL; |
| 352 | /* no need to tell driver */ |
| 353 | break; |
Johannes Berg | 4150c57 | 2007-09-17 01:29:23 -0400 | [diff] [blame] | 354 | case IEEE80211_IF_TYPE_MNTR: |
| 355 | local->monitors--; |
| 356 | if (local->monitors == 0) { |
| 357 | netif_tx_lock_bh(local->mdev); |
| 358 | ieee80211_configure_filter(local); |
| 359 | netif_tx_unlock_bh(local->mdev); |
| 360 | |
Michael Wu | 8b393f1 | 2007-11-28 01:57:08 -0500 | [diff] [blame] | 361 | local->hw.conf.flags &= ~IEEE80211_CONF_RADIOTAP; |
Johannes Berg | 4150c57 | 2007-09-17 01:29:23 -0400 | [diff] [blame] | 362 | } |
| 363 | break; |
Johannes Berg | b2c258f | 2007-07-27 15:43:23 +0200 | [diff] [blame] | 364 | case IEEE80211_IF_TYPE_STA: |
| 365 | case IEEE80211_IF_TYPE_IBSS: |
| 366 | sdata->u.sta.state = IEEE80211_DISABLED; |
| 367 | del_timer_sync(&sdata->u.sta.timer); |
Johannes Berg | 2a8a9a8 | 2007-08-28 17:01:52 -0400 | [diff] [blame] | 368 | /* |
Johannes Berg | 7901042 | 2007-09-18 17:29:21 -0400 | [diff] [blame] | 369 | * When we get here, the interface is marked down. |
| 370 | * Call synchronize_rcu() to wait for the RX path |
| 371 | * should it be using the interface and enqueuing |
| 372 | * frames at this very time on another CPU. |
Johannes Berg | 2a8a9a8 | 2007-08-28 17:01:52 -0400 | [diff] [blame] | 373 | */ |
Johannes Berg | 7901042 | 2007-09-18 17:29:21 -0400 | [diff] [blame] | 374 | synchronize_rcu(); |
Johannes Berg | b2c258f | 2007-07-27 15:43:23 +0200 | [diff] [blame] | 375 | skb_queue_purge(&sdata->u.sta.skb_queue); |
Johannes Berg | 2a8a9a8 | 2007-08-28 17:01:52 -0400 | [diff] [blame] | 376 | |
Zhu Yi | ece8edd | 2007-11-22 10:53:21 +0800 | [diff] [blame] | 377 | if (local->scan_dev == sdata->dev) { |
| 378 | if (!local->ops->hw_scan) { |
| 379 | local->sta_sw_scanning = 0; |
| 380 | cancel_delayed_work(&local->scan_work); |
| 381 | } else |
| 382 | local->sta_hw_scanning = 0; |
Johannes Berg | b2c258f | 2007-07-27 15:43:23 +0200 | [diff] [blame] | 383 | } |
Zhu Yi | ece8edd | 2007-11-22 10:53:21 +0800 | [diff] [blame] | 384 | |
Johannes Berg | b2c258f | 2007-07-27 15:43:23 +0200 | [diff] [blame] | 385 | flush_workqueue(local->hw.workqueue); |
Zhu Yi | a10605e | 2007-11-22 11:10:22 +0800 | [diff] [blame] | 386 | |
| 387 | sdata->u.sta.flags &= ~IEEE80211_STA_PRIVACY_INVOKED; |
| 388 | kfree(sdata->u.sta.extra_ie); |
| 389 | sdata->u.sta.extra_ie = NULL; |
| 390 | sdata->u.sta.extra_ie_len = 0; |
Johannes Berg | 4150c57 | 2007-09-17 01:29:23 -0400 | [diff] [blame] | 391 | /* fall through */ |
| 392 | default: |
Johannes Berg | 32bfd35 | 2007-12-19 01:31:26 +0100 | [diff] [blame] | 393 | conf.vif = &sdata->vif; |
Johannes Berg | 51fb61e | 2007-12-19 01:31:27 +0100 | [diff] [blame] | 394 | conf.type = sdata->vif.type; |
Johannes Berg | b2c258f | 2007-07-27 15:43:23 +0200 | [diff] [blame] | 395 | conf.mac_addr = dev->dev_addr; |
Johannes Berg | 4150c57 | 2007-09-17 01:29:23 -0400 | [diff] [blame] | 396 | /* disable all keys for as long as this netdev is down */ |
| 397 | ieee80211_disable_keys(sdata); |
Johannes Berg | b2c258f | 2007-07-27 15:43:23 +0200 | [diff] [blame] | 398 | local->ops->remove_interface(local_to_hw(local), &conf); |
| 399 | } |
| 400 | |
Johannes Berg | 4150c57 | 2007-09-17 01:29:23 -0400 | [diff] [blame] | 401 | if (local->open_count == 0) { |
| 402 | if (netif_running(local->mdev)) |
| 403 | dev_close(local->mdev); |
| 404 | |
Johannes Berg | 4150c57 | 2007-09-17 01:29:23 -0400 | [diff] [blame] | 405 | if (local->ops->stop) |
| 406 | local->ops->stop(local_to_hw(local)); |
| 407 | |
Ivo van Doorn | cdcb006 | 2008-01-07 19:45:24 +0100 | [diff] [blame] | 408 | ieee80211_led_radio(local, 0); |
| 409 | |
Johannes Berg | 4150c57 | 2007-09-17 01:29:23 -0400 | [diff] [blame] | 410 | tasklet_disable(&local->tx_pending_tasklet); |
| 411 | tasklet_disable(&local->tasklet); |
| 412 | } |
Johannes Berg | b2c258f | 2007-07-27 15:43:23 +0200 | [diff] [blame] | 413 | |
| 414 | return 0; |
| 415 | } |
| 416 | |
Johannes Berg | b2c258f | 2007-07-27 15:43:23 +0200 | [diff] [blame] | 417 | static void ieee80211_set_multicast_list(struct net_device *dev) |
| 418 | { |
| 419 | struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr); |
| 420 | struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev); |
Johannes Berg | 4150c57 | 2007-09-17 01:29:23 -0400 | [diff] [blame] | 421 | int allmulti, promisc, sdata_allmulti, sdata_promisc; |
Johannes Berg | b2c258f | 2007-07-27 15:43:23 +0200 | [diff] [blame] | 422 | |
Johannes Berg | 4150c57 | 2007-09-17 01:29:23 -0400 | [diff] [blame] | 423 | allmulti = !!(dev->flags & IFF_ALLMULTI); |
| 424 | promisc = !!(dev->flags & IFF_PROMISC); |
Johannes Berg | b52f219 | 2007-11-16 01:49:11 +0100 | [diff] [blame] | 425 | sdata_allmulti = !!(sdata->flags & IEEE80211_SDATA_ALLMULTI); |
| 426 | sdata_promisc = !!(sdata->flags & IEEE80211_SDATA_PROMISC); |
Johannes Berg | 4150c57 | 2007-09-17 01:29:23 -0400 | [diff] [blame] | 427 | |
| 428 | if (allmulti != sdata_allmulti) { |
| 429 | if (dev->flags & IFF_ALLMULTI) |
Johannes Berg | 5391899 | 2007-09-26 15:19:47 +0200 | [diff] [blame] | 430 | atomic_inc(&local->iff_allmultis); |
Johannes Berg | 4150c57 | 2007-09-17 01:29:23 -0400 | [diff] [blame] | 431 | else |
Johannes Berg | 5391899 | 2007-09-26 15:19:47 +0200 | [diff] [blame] | 432 | atomic_dec(&local->iff_allmultis); |
Jiri Slaby | 13262ff | 2007-08-28 17:01:54 -0400 | [diff] [blame] | 433 | sdata->flags ^= IEEE80211_SDATA_ALLMULTI; |
Johannes Berg | b2c258f | 2007-07-27 15:43:23 +0200 | [diff] [blame] | 434 | } |
Johannes Berg | 4150c57 | 2007-09-17 01:29:23 -0400 | [diff] [blame] | 435 | |
| 436 | if (promisc != sdata_promisc) { |
| 437 | if (dev->flags & IFF_PROMISC) |
Johannes Berg | 5391899 | 2007-09-26 15:19:47 +0200 | [diff] [blame] | 438 | atomic_inc(&local->iff_promiscs); |
Johannes Berg | 4150c57 | 2007-09-17 01:29:23 -0400 | [diff] [blame] | 439 | else |
Johannes Berg | 5391899 | 2007-09-26 15:19:47 +0200 | [diff] [blame] | 440 | atomic_dec(&local->iff_promiscs); |
Jiri Slaby | 13262ff | 2007-08-28 17:01:54 -0400 | [diff] [blame] | 441 | sdata->flags ^= IEEE80211_SDATA_PROMISC; |
Johannes Berg | b2c258f | 2007-07-27 15:43:23 +0200 | [diff] [blame] | 442 | } |
Johannes Berg | 4150c57 | 2007-09-17 01:29:23 -0400 | [diff] [blame] | 443 | |
| 444 | dev_mc_sync(local->mdev, dev); |
Johannes Berg | b2c258f | 2007-07-27 15:43:23 +0200 | [diff] [blame] | 445 | } |
| 446 | |
Stephen Hemminger | 3b04ddd | 2007-10-09 01:40:57 -0700 | [diff] [blame] | 447 | static const struct header_ops ieee80211_header_ops = { |
| 448 | .create = eth_header, |
| 449 | .parse = header_parse_80211, |
| 450 | .rebuild = eth_rebuild_header, |
| 451 | .cache = eth_header_cache, |
| 452 | .cache_update = eth_header_cache_update, |
| 453 | }; |
| 454 | |
Johannes Berg | f9d540e | 2007-09-28 14:02:09 +0200 | [diff] [blame] | 455 | /* Must not be called for mdev */ |
Johannes Berg | b2c258f | 2007-07-27 15:43:23 +0200 | [diff] [blame] | 456 | void ieee80211_if_setup(struct net_device *dev) |
| 457 | { |
| 458 | ether_setup(dev); |
| 459 | dev->hard_start_xmit = ieee80211_subif_start_xmit; |
| 460 | dev->wireless_handlers = &ieee80211_iw_handler_def; |
| 461 | dev->set_multicast_list = ieee80211_set_multicast_list; |
| 462 | dev->change_mtu = ieee80211_change_mtu; |
Johannes Berg | b2c258f | 2007-07-27 15:43:23 +0200 | [diff] [blame] | 463 | dev->open = ieee80211_open; |
| 464 | dev->stop = ieee80211_stop; |
Johannes Berg | b2c258f | 2007-07-27 15:43:23 +0200 | [diff] [blame] | 465 | dev->destructor = ieee80211_if_free; |
| 466 | } |
| 467 | |
| 468 | /* WDS specialties */ |
| 469 | |
| 470 | int ieee80211_if_update_wds(struct net_device *dev, u8 *remote_addr) |
| 471 | { |
| 472 | struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr); |
| 473 | struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev); |
| 474 | struct sta_info *sta; |
Joe Perches | 0795af5 | 2007-10-03 17:59:30 -0700 | [diff] [blame] | 475 | DECLARE_MAC_BUF(mac); |
Johannes Berg | b2c258f | 2007-07-27 15:43:23 +0200 | [diff] [blame] | 476 | |
| 477 | if (compare_ether_addr(remote_addr, sdata->u.wds.remote_addr) == 0) |
| 478 | return 0; |
| 479 | |
| 480 | /* Create STA entry for the new peer */ |
| 481 | sta = sta_info_add(local, dev, remote_addr, GFP_KERNEL); |
| 482 | if (!sta) |
| 483 | return -ENOMEM; |
| 484 | sta_info_put(sta); |
| 485 | |
| 486 | /* Remove STA entry for the old peer */ |
| 487 | sta = sta_info_get(local, sdata->u.wds.remote_addr); |
| 488 | if (sta) { |
Michael Wu | be8755e | 2007-07-27 15:43:23 +0200 | [diff] [blame] | 489 | sta_info_free(sta); |
Johannes Berg | b2c258f | 2007-07-27 15:43:23 +0200 | [diff] [blame] | 490 | sta_info_put(sta); |
Johannes Berg | b2c258f | 2007-07-27 15:43:23 +0200 | [diff] [blame] | 491 | } else { |
| 492 | printk(KERN_DEBUG "%s: could not find STA entry for WDS link " |
Joe Perches | 0795af5 | 2007-10-03 17:59:30 -0700 | [diff] [blame] | 493 | "peer %s\n", |
| 494 | dev->name, print_mac(mac, sdata->u.wds.remote_addr)); |
Johannes Berg | b2c258f | 2007-07-27 15:43:23 +0200 | [diff] [blame] | 495 | } |
| 496 | |
| 497 | /* Update WDS link data */ |
| 498 | memcpy(&sdata->u.wds.remote_addr, remote_addr, ETH_ALEN); |
| 499 | |
| 500 | return 0; |
| 501 | } |
| 502 | |
| 503 | /* everything else */ |
| 504 | |
Johannes Berg | b2c258f | 2007-07-27 15:43:23 +0200 | [diff] [blame] | 505 | static int __ieee80211_if_config(struct net_device *dev, |
| 506 | struct sk_buff *beacon, |
| 507 | struct ieee80211_tx_control *control) |
| 508 | { |
| 509 | struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev); |
| 510 | struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr); |
| 511 | struct ieee80211_if_conf conf; |
Johannes Berg | b2c258f | 2007-07-27 15:43:23 +0200 | [diff] [blame] | 512 | |
| 513 | if (!local->ops->config_interface || !netif_running(dev)) |
| 514 | return 0; |
| 515 | |
| 516 | memset(&conf, 0, sizeof(conf)); |
Johannes Berg | 51fb61e | 2007-12-19 01:31:27 +0100 | [diff] [blame] | 517 | conf.type = sdata->vif.type; |
| 518 | if (sdata->vif.type == IEEE80211_IF_TYPE_STA || |
| 519 | sdata->vif.type == IEEE80211_IF_TYPE_IBSS) { |
Johannes Berg | 4150c57 | 2007-09-17 01:29:23 -0400 | [diff] [blame] | 520 | conf.bssid = sdata->u.sta.bssid; |
Johannes Berg | b2c258f | 2007-07-27 15:43:23 +0200 | [diff] [blame] | 521 | conf.ssid = sdata->u.sta.ssid; |
| 522 | conf.ssid_len = sdata->u.sta.ssid_len; |
Johannes Berg | 51fb61e | 2007-12-19 01:31:27 +0100 | [diff] [blame] | 523 | } else if (sdata->vif.type == IEEE80211_IF_TYPE_AP) { |
Johannes Berg | b2c258f | 2007-07-27 15:43:23 +0200 | [diff] [blame] | 524 | conf.ssid = sdata->u.ap.ssid; |
| 525 | conf.ssid_len = sdata->u.ap.ssid_len; |
Johannes Berg | b2c258f | 2007-07-27 15:43:23 +0200 | [diff] [blame] | 526 | conf.beacon = beacon; |
| 527 | conf.beacon_control = control; |
| 528 | } |
| 529 | return local->ops->config_interface(local_to_hw(local), |
Johannes Berg | 32bfd35 | 2007-12-19 01:31:26 +0100 | [diff] [blame] | 530 | &sdata->vif, &conf); |
Johannes Berg | b2c258f | 2007-07-27 15:43:23 +0200 | [diff] [blame] | 531 | } |
| 532 | |
| 533 | int ieee80211_if_config(struct net_device *dev) |
| 534 | { |
| 535 | return __ieee80211_if_config(dev, NULL, NULL); |
| 536 | } |
| 537 | |
| 538 | int ieee80211_if_config_beacon(struct net_device *dev) |
| 539 | { |
| 540 | struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr); |
| 541 | struct ieee80211_tx_control control; |
Johannes Berg | 32bfd35 | 2007-12-19 01:31:26 +0100 | [diff] [blame] | 542 | struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev); |
Johannes Berg | b2c258f | 2007-07-27 15:43:23 +0200 | [diff] [blame] | 543 | struct sk_buff *skb; |
| 544 | |
| 545 | if (!(local->hw.flags & IEEE80211_HW_HOST_GEN_BEACON_TEMPLATE)) |
| 546 | return 0; |
Johannes Berg | 32bfd35 | 2007-12-19 01:31:26 +0100 | [diff] [blame] | 547 | skb = ieee80211_beacon_get(local_to_hw(local), &sdata->vif, |
| 548 | &control); |
Johannes Berg | b2c258f | 2007-07-27 15:43:23 +0200 | [diff] [blame] | 549 | if (!skb) |
| 550 | return -ENOMEM; |
| 551 | return __ieee80211_if_config(dev, skb, &control); |
| 552 | } |
| 553 | |
| 554 | int ieee80211_hw_config(struct ieee80211_local *local) |
| 555 | { |
| 556 | struct ieee80211_hw_mode *mode; |
| 557 | struct ieee80211_channel *chan; |
| 558 | int ret = 0; |
| 559 | |
Zhu Yi | ece8edd | 2007-11-22 10:53:21 +0800 | [diff] [blame] | 560 | if (local->sta_sw_scanning) { |
Johannes Berg | b2c258f | 2007-07-27 15:43:23 +0200 | [diff] [blame] | 561 | chan = local->scan_channel; |
| 562 | mode = local->scan_hw_mode; |
| 563 | } else { |
| 564 | chan = local->oper_channel; |
| 565 | mode = local->oper_hw_mode; |
| 566 | } |
| 567 | |
| 568 | local->hw.conf.channel = chan->chan; |
| 569 | local->hw.conf.channel_val = chan->val; |
Michael Buesch | 61609bc | 2007-09-20 22:06:39 +0200 | [diff] [blame] | 570 | if (!local->hw.conf.power_level) { |
| 571 | local->hw.conf.power_level = chan->power_level; |
| 572 | } else { |
| 573 | local->hw.conf.power_level = min(chan->power_level, |
| 574 | local->hw.conf.power_level); |
| 575 | } |
Johannes Berg | b2c258f | 2007-07-27 15:43:23 +0200 | [diff] [blame] | 576 | local->hw.conf.freq = chan->freq; |
| 577 | local->hw.conf.phymode = mode->mode; |
| 578 | local->hw.conf.antenna_max = chan->antenna_max; |
| 579 | local->hw.conf.chan = chan; |
| 580 | local->hw.conf.mode = mode; |
| 581 | |
| 582 | #ifdef CONFIG_MAC80211_VERBOSE_DEBUG |
| 583 | printk(KERN_DEBUG "HW CONFIG: channel=%d freq=%d " |
| 584 | "phymode=%d\n", local->hw.conf.channel, local->hw.conf.freq, |
| 585 | local->hw.conf.phymode); |
| 586 | #endif /* CONFIG_MAC80211_VERBOSE_DEBUG */ |
| 587 | |
Michael Buesch | f7c4dae | 2007-09-24 18:41:49 +0200 | [diff] [blame] | 588 | if (local->open_count) |
Johannes Berg | b2c258f | 2007-07-27 15:43:23 +0200 | [diff] [blame] | 589 | ret = local->ops->config(local_to_hw(local), &local->hw.conf); |
| 590 | |
| 591 | return ret; |
| 592 | } |
| 593 | |
Ron Rindjunsky | d3c990f | 2007-11-26 16:14:34 +0200 | [diff] [blame] | 594 | /** |
| 595 | * ieee80211_hw_config_ht should be used only after legacy configuration |
| 596 | * has been determined, as ht configuration depends upon the hardware's |
| 597 | * HT abilities for a _specific_ band. |
| 598 | */ |
| 599 | int ieee80211_hw_config_ht(struct ieee80211_local *local, int enable_ht, |
| 600 | struct ieee80211_ht_info *req_ht_cap, |
| 601 | struct ieee80211_ht_bss_info *req_bss_cap) |
| 602 | { |
| 603 | struct ieee80211_conf *conf = &local->hw.conf; |
| 604 | struct ieee80211_hw_mode *mode = conf->mode; |
| 605 | int i; |
| 606 | |
| 607 | /* HT is not supported */ |
| 608 | if (!mode->ht_info.ht_supported) { |
| 609 | conf->flags &= ~IEEE80211_CONF_SUPPORT_HT_MODE; |
| 610 | return -EOPNOTSUPP; |
| 611 | } |
| 612 | |
| 613 | /* disable HT */ |
| 614 | if (!enable_ht) { |
| 615 | conf->flags &= ~IEEE80211_CONF_SUPPORT_HT_MODE; |
| 616 | } else { |
| 617 | conf->flags |= IEEE80211_CONF_SUPPORT_HT_MODE; |
| 618 | conf->ht_conf.cap = req_ht_cap->cap & mode->ht_info.cap; |
| 619 | conf->ht_conf.cap &= ~(IEEE80211_HT_CAP_MIMO_PS); |
| 620 | conf->ht_conf.cap |= |
| 621 | mode->ht_info.cap & IEEE80211_HT_CAP_MIMO_PS; |
| 622 | conf->ht_bss_conf.primary_channel = |
| 623 | req_bss_cap->primary_channel; |
| 624 | conf->ht_bss_conf.bss_cap = req_bss_cap->bss_cap; |
| 625 | conf->ht_bss_conf.bss_op_mode = req_bss_cap->bss_op_mode; |
| 626 | for (i = 0; i < SUPP_MCS_SET_LEN; i++) |
| 627 | conf->ht_conf.supp_mcs_set[i] = |
| 628 | mode->ht_info.supp_mcs_set[i] & |
| 629 | req_ht_cap->supp_mcs_set[i]; |
| 630 | |
| 631 | /* In STA mode, this gives us indication |
| 632 | * to the AP's mode of operation */ |
| 633 | conf->ht_conf.ht_supported = 1; |
| 634 | conf->ht_conf.ampdu_factor = req_ht_cap->ampdu_factor; |
| 635 | conf->ht_conf.ampdu_density = req_ht_cap->ampdu_density; |
| 636 | } |
| 637 | |
| 638 | local->ops->conf_ht(local_to_hw(local), &local->hw.conf); |
| 639 | |
| 640 | return 0; |
| 641 | } |
| 642 | |
Johannes Berg | 471b3ef | 2007-12-28 14:32:58 +0100 | [diff] [blame] | 643 | void ieee80211_bss_info_change_notify(struct ieee80211_sub_if_data *sdata, |
| 644 | u32 changed) |
Daniel Drake | d9430a3 | 2007-07-27 15:43:24 +0200 | [diff] [blame] | 645 | { |
Johannes Berg | 471b3ef | 2007-12-28 14:32:58 +0100 | [diff] [blame] | 646 | struct ieee80211_local *local = sdata->local; |
| 647 | |
| 648 | if (!changed) |
| 649 | return; |
| 650 | |
| 651 | if (local->ops->bss_info_changed) |
| 652 | local->ops->bss_info_changed(local_to_hw(local), |
| 653 | &sdata->vif, |
| 654 | &sdata->bss_conf, |
| 655 | changed); |
Daniel Drake | d9430a3 | 2007-07-27 15:43:24 +0200 | [diff] [blame] | 656 | } |
| 657 | |
| 658 | void ieee80211_reset_erp_info(struct net_device *dev) |
| 659 | { |
| 660 | struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev); |
| 661 | |
Johannes Berg | 471b3ef | 2007-12-28 14:32:58 +0100 | [diff] [blame] | 662 | sdata->bss_conf.use_cts_prot = 0; |
| 663 | sdata->bss_conf.use_short_preamble = 0; |
| 664 | ieee80211_bss_info_change_notify(sdata, |
| 665 | BSS_CHANGED_ERP_CTS_PROT | |
| 666 | BSS_CHANGED_ERP_PREAMBLE); |
Daniel Drake | d9430a3 | 2007-07-27 15:43:24 +0200 | [diff] [blame] | 667 | } |
| 668 | |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 669 | void ieee80211_tx_status_irqsafe(struct ieee80211_hw *hw, |
| 670 | struct sk_buff *skb, |
| 671 | struct ieee80211_tx_status *status) |
| 672 | { |
| 673 | struct ieee80211_local *local = hw_to_local(hw); |
| 674 | struct ieee80211_tx_status *saved; |
| 675 | int tmp; |
| 676 | |
| 677 | skb->dev = local->mdev; |
| 678 | saved = kmalloc(sizeof(struct ieee80211_tx_status), GFP_ATOMIC); |
| 679 | if (unlikely(!saved)) { |
| 680 | if (net_ratelimit()) |
| 681 | printk(KERN_WARNING "%s: Not enough memory, " |
| 682 | "dropping tx status", skb->dev->name); |
| 683 | /* should be dev_kfree_skb_irq, but due to this function being |
| 684 | * named _irqsafe instead of just _irq we can't be sure that |
| 685 | * people won't call it from non-irq contexts */ |
| 686 | dev_kfree_skb_any(skb); |
| 687 | return; |
| 688 | } |
| 689 | memcpy(saved, status, sizeof(struct ieee80211_tx_status)); |
| 690 | /* copy pointer to saved status into skb->cb for use by tasklet */ |
| 691 | memcpy(skb->cb, &saved, sizeof(saved)); |
| 692 | |
| 693 | skb->pkt_type = IEEE80211_TX_STATUS_MSG; |
| 694 | skb_queue_tail(status->control.flags & IEEE80211_TXCTL_REQ_TX_STATUS ? |
| 695 | &local->skb_queue : &local->skb_queue_unreliable, skb); |
| 696 | tmp = skb_queue_len(&local->skb_queue) + |
| 697 | skb_queue_len(&local->skb_queue_unreliable); |
| 698 | while (tmp > IEEE80211_IRQSAFE_QUEUE_LIMIT && |
| 699 | (skb = skb_dequeue(&local->skb_queue_unreliable))) { |
| 700 | memcpy(&saved, skb->cb, sizeof(saved)); |
| 701 | kfree(saved); |
| 702 | dev_kfree_skb_irq(skb); |
| 703 | tmp--; |
| 704 | I802_DEBUG_INC(local->tx_status_drop); |
| 705 | } |
| 706 | tasklet_schedule(&local->tasklet); |
| 707 | } |
| 708 | EXPORT_SYMBOL(ieee80211_tx_status_irqsafe); |
| 709 | |
| 710 | static void ieee80211_tasklet_handler(unsigned long data) |
| 711 | { |
| 712 | struct ieee80211_local *local = (struct ieee80211_local *) data; |
| 713 | struct sk_buff *skb; |
| 714 | struct ieee80211_rx_status rx_status; |
| 715 | struct ieee80211_tx_status *tx_status; |
| 716 | |
| 717 | while ((skb = skb_dequeue(&local->skb_queue)) || |
| 718 | (skb = skb_dequeue(&local->skb_queue_unreliable))) { |
| 719 | switch (skb->pkt_type) { |
| 720 | case IEEE80211_RX_MSG: |
| 721 | /* status is in skb->cb */ |
| 722 | memcpy(&rx_status, skb->cb, sizeof(rx_status)); |
Johannes Berg | 51fb61e | 2007-12-19 01:31:27 +0100 | [diff] [blame] | 723 | /* Clear skb->pkt_type in order to not confuse kernel |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 724 | * netstack. */ |
| 725 | skb->pkt_type = 0; |
| 726 | __ieee80211_rx(local_to_hw(local), skb, &rx_status); |
| 727 | break; |
| 728 | case IEEE80211_TX_STATUS_MSG: |
| 729 | /* get pointer to saved status out of skb->cb */ |
| 730 | memcpy(&tx_status, skb->cb, sizeof(tx_status)); |
| 731 | skb->pkt_type = 0; |
| 732 | ieee80211_tx_status(local_to_hw(local), |
| 733 | skb, tx_status); |
| 734 | kfree(tx_status); |
| 735 | break; |
| 736 | default: /* should never get here! */ |
| 737 | printk(KERN_ERR "%s: Unknown message type (%d)\n", |
Johannes Berg | dd1cd4c | 2007-09-18 17:29:20 -0400 | [diff] [blame] | 738 | wiphy_name(local->hw.wiphy), skb->pkt_type); |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 739 | dev_kfree_skb(skb); |
| 740 | break; |
| 741 | } |
| 742 | } |
| 743 | } |
| 744 | |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 745 | /* Remove added headers (e.g., QoS control), encryption header/MIC, etc. to |
| 746 | * make a prepared TX frame (one that has been given to hw) to look like brand |
| 747 | * new IEEE 802.11 frame that is ready to go through TX processing again. |
| 748 | * Also, tx_packet_data in cb is restored from tx_control. */ |
| 749 | static void ieee80211_remove_tx_extra(struct ieee80211_local *local, |
| 750 | struct ieee80211_key *key, |
| 751 | struct sk_buff *skb, |
| 752 | struct ieee80211_tx_control *control) |
| 753 | { |
| 754 | int hdrlen, iv_len, mic_len; |
| 755 | struct ieee80211_tx_packet_data *pkt_data; |
| 756 | |
| 757 | pkt_data = (struct ieee80211_tx_packet_data *)skb->cb; |
Johannes Berg | 32bfd35 | 2007-12-19 01:31:26 +0100 | [diff] [blame] | 758 | pkt_data->ifindex = vif_to_sdata(control->vif)->dev->ifindex; |
Jiri Slaby | e8bf964 | 2007-08-28 17:01:54 -0400 | [diff] [blame] | 759 | pkt_data->flags = 0; |
| 760 | if (control->flags & IEEE80211_TXCTL_REQ_TX_STATUS) |
| 761 | pkt_data->flags |= IEEE80211_TXPD_REQ_TX_STATUS; |
| 762 | if (control->flags & IEEE80211_TXCTL_DO_NOT_ENCRYPT) |
| 763 | pkt_data->flags |= IEEE80211_TXPD_DO_NOT_ENCRYPT; |
| 764 | if (control->flags & IEEE80211_TXCTL_REQUEUE) |
| 765 | pkt_data->flags |= IEEE80211_TXPD_REQUEUE; |
Johannes Berg | 678f5f71 | 2007-12-19 01:31:23 +0100 | [diff] [blame] | 766 | if (control->flags & IEEE80211_TXCTL_EAPOL_FRAME) |
| 767 | pkt_data->flags |= IEEE80211_TXPD_EAPOL_FRAME; |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 768 | pkt_data->queue = control->queue; |
| 769 | |
| 770 | hdrlen = ieee80211_get_hdrlen_from_skb(skb); |
| 771 | |
| 772 | if (!key) |
| 773 | goto no_key; |
| 774 | |
Johannes Berg | 8f20fc2 | 2007-08-28 17:01:54 -0400 | [diff] [blame] | 775 | switch (key->conf.alg) { |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 776 | case ALG_WEP: |
| 777 | iv_len = WEP_IV_LEN; |
| 778 | mic_len = WEP_ICV_LEN; |
| 779 | break; |
| 780 | case ALG_TKIP: |
| 781 | iv_len = TKIP_IV_LEN; |
| 782 | mic_len = TKIP_ICV_LEN; |
| 783 | break; |
| 784 | case ALG_CCMP: |
| 785 | iv_len = CCMP_HDR_LEN; |
| 786 | mic_len = CCMP_MIC_LEN; |
| 787 | break; |
| 788 | default: |
| 789 | goto no_key; |
| 790 | } |
| 791 | |
Johannes Berg | 8f20fc2 | 2007-08-28 17:01:54 -0400 | [diff] [blame] | 792 | if (skb->len >= mic_len && |
Johannes Berg | 11a843b | 2007-08-28 17:01:55 -0400 | [diff] [blame] | 793 | !(key->flags & KEY_FLAG_UPLOADED_TO_HARDWARE)) |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 794 | skb_trim(skb, skb->len - mic_len); |
| 795 | if (skb->len >= iv_len && skb->len > hdrlen) { |
| 796 | memmove(skb->data + iv_len, skb->data, hdrlen); |
| 797 | skb_pull(skb, iv_len); |
| 798 | } |
| 799 | |
| 800 | no_key: |
| 801 | { |
| 802 | struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) skb->data; |
| 803 | u16 fc = le16_to_cpu(hdr->frame_control); |
| 804 | if ((fc & 0x8C) == 0x88) /* QoS Control Field */ { |
| 805 | fc &= ~IEEE80211_STYPE_QOS_DATA; |
| 806 | hdr->frame_control = cpu_to_le16(fc); |
| 807 | memmove(skb->data + 2, skb->data, hdrlen - 2); |
| 808 | skb_pull(skb, 2); |
| 809 | } |
| 810 | } |
| 811 | } |
| 812 | |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 813 | void ieee80211_tx_status(struct ieee80211_hw *hw, struct sk_buff *skb, |
| 814 | struct ieee80211_tx_status *status) |
| 815 | { |
| 816 | struct sk_buff *skb2; |
| 817 | struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) skb->data; |
| 818 | struct ieee80211_local *local = hw_to_local(hw); |
| 819 | u16 frag, type; |
Johannes Berg | b306f45 | 2007-07-10 19:32:08 +0200 | [diff] [blame] | 820 | struct ieee80211_tx_status_rtap_hdr *rthdr; |
| 821 | struct ieee80211_sub_if_data *sdata; |
| 822 | int monitors; |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 823 | |
| 824 | if (!status) { |
| 825 | printk(KERN_ERR |
| 826 | "%s: ieee80211_tx_status called with NULL status\n", |
Johannes Berg | dd1cd4c | 2007-09-18 17:29:20 -0400 | [diff] [blame] | 827 | wiphy_name(local->hw.wiphy)); |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 828 | dev_kfree_skb(skb); |
| 829 | return; |
| 830 | } |
| 831 | |
| 832 | if (status->excessive_retries) { |
| 833 | struct sta_info *sta; |
| 834 | sta = sta_info_get(local, hdr->addr1); |
| 835 | if (sta) { |
| 836 | if (sta->flags & WLAN_STA_PS) { |
| 837 | /* The STA is in power save mode, so assume |
| 838 | * that this TX packet failed because of that. |
| 839 | */ |
| 840 | status->excessive_retries = 0; |
| 841 | status->flags |= IEEE80211_TX_STATUS_TX_FILTERED; |
| 842 | } |
| 843 | sta_info_put(sta); |
| 844 | } |
| 845 | } |
| 846 | |
| 847 | if (status->flags & IEEE80211_TX_STATUS_TX_FILTERED) { |
| 848 | struct sta_info *sta; |
| 849 | sta = sta_info_get(local, hdr->addr1); |
| 850 | if (sta) { |
| 851 | sta->tx_filtered_count++; |
| 852 | |
| 853 | /* Clear the TX filter mask for this STA when sending |
| 854 | * the next packet. If the STA went to power save mode, |
| 855 | * this will happen when it is waking up for the next |
| 856 | * time. */ |
| 857 | sta->clear_dst_mask = 1; |
| 858 | |
| 859 | /* TODO: Is the WLAN_STA_PS flag always set here or is |
| 860 | * the race between RX and TX status causing some |
| 861 | * packets to be filtered out before 80211.o gets an |
| 862 | * update for PS status? This seems to be the case, so |
| 863 | * no changes are likely to be needed. */ |
| 864 | if (sta->flags & WLAN_STA_PS && |
| 865 | skb_queue_len(&sta->tx_filtered) < |
| 866 | STA_MAX_TX_BUFFER) { |
| 867 | ieee80211_remove_tx_extra(local, sta->key, |
| 868 | skb, |
| 869 | &status->control); |
| 870 | skb_queue_tail(&sta->tx_filtered, skb); |
| 871 | } else if (!(sta->flags & WLAN_STA_PS) && |
| 872 | !(status->control.flags & IEEE80211_TXCTL_REQUEUE)) { |
| 873 | /* Software retry the packet once */ |
| 874 | status->control.flags |= IEEE80211_TXCTL_REQUEUE; |
| 875 | ieee80211_remove_tx_extra(local, sta->key, |
| 876 | skb, |
| 877 | &status->control); |
| 878 | dev_queue_xmit(skb); |
| 879 | } else { |
| 880 | if (net_ratelimit()) { |
| 881 | printk(KERN_DEBUG "%s: dropped TX " |
| 882 | "filtered frame queue_len=%d " |
| 883 | "PS=%d @%lu\n", |
Johannes Berg | dd1cd4c | 2007-09-18 17:29:20 -0400 | [diff] [blame] | 884 | wiphy_name(local->hw.wiphy), |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 885 | skb_queue_len( |
| 886 | &sta->tx_filtered), |
| 887 | !!(sta->flags & WLAN_STA_PS), |
| 888 | jiffies); |
| 889 | } |
| 890 | dev_kfree_skb(skb); |
| 891 | } |
| 892 | sta_info_put(sta); |
| 893 | return; |
| 894 | } |
Mattias Nissler | 1abbe49 | 2007-12-20 13:50:07 +0100 | [diff] [blame] | 895 | } else |
| 896 | rate_control_tx_status(local->mdev, skb, status); |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 897 | |
| 898 | ieee80211_led_tx(local, 0); |
| 899 | |
| 900 | /* SNMP counters |
| 901 | * Fragments are passed to low-level drivers as separate skbs, so these |
| 902 | * are actually fragments, not frames. Update frame counters only for |
| 903 | * the first fragment of the frame. */ |
| 904 | |
| 905 | frag = le16_to_cpu(hdr->seq_ctrl) & IEEE80211_SCTL_FRAG; |
| 906 | type = le16_to_cpu(hdr->frame_control) & IEEE80211_FCTL_FTYPE; |
| 907 | |
| 908 | if (status->flags & IEEE80211_TX_STATUS_ACK) { |
| 909 | if (frag == 0) { |
| 910 | local->dot11TransmittedFrameCount++; |
| 911 | if (is_multicast_ether_addr(hdr->addr1)) |
| 912 | local->dot11MulticastTransmittedFrameCount++; |
| 913 | if (status->retry_count > 0) |
| 914 | local->dot11RetryCount++; |
| 915 | if (status->retry_count > 1) |
| 916 | local->dot11MultipleRetryCount++; |
| 917 | } |
| 918 | |
| 919 | /* This counter shall be incremented for an acknowledged MPDU |
| 920 | * with an individual address in the address 1 field or an MPDU |
| 921 | * with a multicast address in the address 1 field of type Data |
| 922 | * or Management. */ |
| 923 | if (!is_multicast_ether_addr(hdr->addr1) || |
| 924 | type == IEEE80211_FTYPE_DATA || |
| 925 | type == IEEE80211_FTYPE_MGMT) |
| 926 | local->dot11TransmittedFragmentCount++; |
| 927 | } else { |
| 928 | if (frag == 0) |
| 929 | local->dot11FailedCount++; |
| 930 | } |
| 931 | |
Johannes Berg | b306f45 | 2007-07-10 19:32:08 +0200 | [diff] [blame] | 932 | /* this was a transmitted frame, but now we want to reuse it */ |
| 933 | skb_orphan(skb); |
| 934 | |
Johannes Berg | b306f45 | 2007-07-10 19:32:08 +0200 | [diff] [blame] | 935 | if (!local->monitors) { |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 936 | dev_kfree_skb(skb); |
| 937 | return; |
| 938 | } |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 939 | |
Johannes Berg | b306f45 | 2007-07-10 19:32:08 +0200 | [diff] [blame] | 940 | /* send frame to monitor interfaces now */ |
| 941 | |
| 942 | if (skb_headroom(skb) < sizeof(*rthdr)) { |
| 943 | printk(KERN_ERR "ieee80211_tx_status: headroom too small\n"); |
| 944 | dev_kfree_skb(skb); |
| 945 | return; |
| 946 | } |
| 947 | |
| 948 | rthdr = (struct ieee80211_tx_status_rtap_hdr*) |
| 949 | skb_push(skb, sizeof(*rthdr)); |
| 950 | |
| 951 | memset(rthdr, 0, sizeof(*rthdr)); |
| 952 | rthdr->hdr.it_len = cpu_to_le16(sizeof(*rthdr)); |
| 953 | rthdr->hdr.it_present = |
| 954 | cpu_to_le32((1 << IEEE80211_RADIOTAP_TX_FLAGS) | |
| 955 | (1 << IEEE80211_RADIOTAP_DATA_RETRIES)); |
| 956 | |
| 957 | if (!(status->flags & IEEE80211_TX_STATUS_ACK) && |
| 958 | !is_multicast_ether_addr(hdr->addr1)) |
| 959 | rthdr->tx_flags |= cpu_to_le16(IEEE80211_RADIOTAP_F_TX_FAIL); |
| 960 | |
| 961 | if ((status->control.flags & IEEE80211_TXCTL_USE_RTS_CTS) && |
| 962 | (status->control.flags & IEEE80211_TXCTL_USE_CTS_PROTECT)) |
| 963 | rthdr->tx_flags |= cpu_to_le16(IEEE80211_RADIOTAP_F_TX_CTS); |
| 964 | else if (status->control.flags & IEEE80211_TXCTL_USE_RTS_CTS) |
| 965 | rthdr->tx_flags |= cpu_to_le16(IEEE80211_RADIOTAP_F_TX_RTS); |
| 966 | |
| 967 | rthdr->data_retries = status->retry_count; |
| 968 | |
Johannes Berg | 7901042 | 2007-09-18 17:29:21 -0400 | [diff] [blame] | 969 | rcu_read_lock(); |
Johannes Berg | b306f45 | 2007-07-10 19:32:08 +0200 | [diff] [blame] | 970 | monitors = local->monitors; |
Johannes Berg | 7901042 | 2007-09-18 17:29:21 -0400 | [diff] [blame] | 971 | list_for_each_entry_rcu(sdata, &local->interfaces, list) { |
Johannes Berg | b306f45 | 2007-07-10 19:32:08 +0200 | [diff] [blame] | 972 | /* |
| 973 | * Using the monitors counter is possibly racy, but |
| 974 | * if the value is wrong we simply either clone the skb |
| 975 | * once too much or forget sending it to one monitor iface |
| 976 | * The latter case isn't nice but fixing the race is much |
| 977 | * more complicated. |
| 978 | */ |
| 979 | if (!monitors || !skb) |
| 980 | goto out; |
| 981 | |
Johannes Berg | 51fb61e | 2007-12-19 01:31:27 +0100 | [diff] [blame] | 982 | if (sdata->vif.type == IEEE80211_IF_TYPE_MNTR) { |
Johannes Berg | b306f45 | 2007-07-10 19:32:08 +0200 | [diff] [blame] | 983 | if (!netif_running(sdata->dev)) |
| 984 | continue; |
| 985 | monitors--; |
| 986 | if (monitors) |
Johannes Berg | 7901042 | 2007-09-18 17:29:21 -0400 | [diff] [blame] | 987 | skb2 = skb_clone(skb, GFP_ATOMIC); |
Johannes Berg | b306f45 | 2007-07-10 19:32:08 +0200 | [diff] [blame] | 988 | else |
| 989 | skb2 = NULL; |
| 990 | skb->dev = sdata->dev; |
| 991 | /* XXX: is this sufficient for BPF? */ |
| 992 | skb_set_mac_header(skb, 0); |
| 993 | skb->ip_summed = CHECKSUM_UNNECESSARY; |
| 994 | skb->pkt_type = PACKET_OTHERHOST; |
| 995 | skb->protocol = htons(ETH_P_802_2); |
| 996 | memset(skb->cb, 0, sizeof(skb->cb)); |
| 997 | netif_rx(skb); |
| 998 | skb = skb2; |
Johannes Berg | b306f45 | 2007-07-10 19:32:08 +0200 | [diff] [blame] | 999 | } |
| 1000 | } |
| 1001 | out: |
Johannes Berg | 7901042 | 2007-09-18 17:29:21 -0400 | [diff] [blame] | 1002 | rcu_read_unlock(); |
Johannes Berg | b306f45 | 2007-07-10 19:32:08 +0200 | [diff] [blame] | 1003 | if (skb) |
| 1004 | dev_kfree_skb(skb); |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 1005 | } |
| 1006 | EXPORT_SYMBOL(ieee80211_tx_status); |
| 1007 | |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 1008 | struct ieee80211_hw *ieee80211_alloc_hw(size_t priv_data_len, |
| 1009 | const struct ieee80211_ops *ops) |
| 1010 | { |
| 1011 | struct net_device *mdev; |
| 1012 | struct ieee80211_local *local; |
| 1013 | struct ieee80211_sub_if_data *sdata; |
| 1014 | int priv_size; |
| 1015 | struct wiphy *wiphy; |
| 1016 | |
| 1017 | /* Ensure 32-byte alignment of our private data and hw private data. |
| 1018 | * We use the wiphy priv data for both our ieee80211_local and for |
| 1019 | * the driver's private data |
| 1020 | * |
| 1021 | * In memory it'll be like this: |
| 1022 | * |
| 1023 | * +-------------------------+ |
| 1024 | * | struct wiphy | |
| 1025 | * +-------------------------+ |
| 1026 | * | struct ieee80211_local | |
| 1027 | * +-------------------------+ |
| 1028 | * | driver's private data | |
| 1029 | * +-------------------------+ |
| 1030 | * |
| 1031 | */ |
| 1032 | priv_size = ((sizeof(struct ieee80211_local) + |
| 1033 | NETDEV_ALIGN_CONST) & ~NETDEV_ALIGN_CONST) + |
| 1034 | priv_data_len; |
| 1035 | |
| 1036 | wiphy = wiphy_new(&mac80211_config_ops, priv_size); |
| 1037 | |
| 1038 | if (!wiphy) |
| 1039 | return NULL; |
| 1040 | |
| 1041 | wiphy->privid = mac80211_wiphy_privid; |
| 1042 | |
| 1043 | local = wiphy_priv(wiphy); |
| 1044 | local->hw.wiphy = wiphy; |
| 1045 | |
| 1046 | local->hw.priv = (char *)local + |
| 1047 | ((sizeof(struct ieee80211_local) + |
| 1048 | NETDEV_ALIGN_CONST) & ~NETDEV_ALIGN_CONST); |
| 1049 | |
Johannes Berg | 4480f15c | 2007-07-10 19:32:10 +0200 | [diff] [blame] | 1050 | BUG_ON(!ops->tx); |
Johannes Berg | 4150c57 | 2007-09-17 01:29:23 -0400 | [diff] [blame] | 1051 | BUG_ON(!ops->start); |
| 1052 | BUG_ON(!ops->stop); |
Johannes Berg | 4480f15c | 2007-07-10 19:32:10 +0200 | [diff] [blame] | 1053 | BUG_ON(!ops->config); |
| 1054 | BUG_ON(!ops->add_interface); |
Johannes Berg | 4150c57 | 2007-09-17 01:29:23 -0400 | [diff] [blame] | 1055 | BUG_ON(!ops->remove_interface); |
| 1056 | BUG_ON(!ops->configure_filter); |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 1057 | local->ops = ops; |
| 1058 | |
| 1059 | /* for now, mdev needs sub_if_data :/ */ |
| 1060 | mdev = alloc_netdev(sizeof(struct ieee80211_sub_if_data), |
| 1061 | "wmaster%d", ether_setup); |
| 1062 | if (!mdev) { |
| 1063 | wiphy_free(wiphy); |
| 1064 | return NULL; |
| 1065 | } |
| 1066 | |
| 1067 | sdata = IEEE80211_DEV_TO_SUB_IF(mdev); |
| 1068 | mdev->ieee80211_ptr = &sdata->wdev; |
| 1069 | sdata->wdev.wiphy = wiphy; |
| 1070 | |
| 1071 | local->hw.queues = 1; /* default */ |
| 1072 | |
| 1073 | local->mdev = mdev; |
| 1074 | local->rx_pre_handlers = ieee80211_rx_pre_handlers; |
| 1075 | local->rx_handlers = ieee80211_rx_handlers; |
| 1076 | local->tx_handlers = ieee80211_tx_handlers; |
| 1077 | |
| 1078 | local->bridge_packets = 1; |
| 1079 | |
| 1080 | local->rts_threshold = IEEE80211_MAX_RTS_THRESHOLD; |
| 1081 | local->fragmentation_threshold = IEEE80211_MAX_FRAG_THRESHOLD; |
| 1082 | local->short_retry_limit = 7; |
| 1083 | local->long_retry_limit = 4; |
| 1084 | local->hw.conf.radio_enabled = 1; |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 1085 | |
Johannes Berg | b708e61 | 2007-09-14 11:10:25 -0400 | [diff] [blame] | 1086 | local->enabled_modes = ~0; |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 1087 | |
| 1088 | INIT_LIST_HEAD(&local->modes_list); |
| 1089 | |
Johannes Berg | 7901042 | 2007-09-18 17:29:21 -0400 | [diff] [blame] | 1090 | INIT_LIST_HEAD(&local->interfaces); |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 1091 | |
| 1092 | INIT_DELAYED_WORK(&local->scan_work, ieee80211_sta_scan_work); |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 1093 | ieee80211_rx_bss_list_init(mdev); |
| 1094 | |
| 1095 | sta_info_init(local); |
| 1096 | |
| 1097 | mdev->hard_start_xmit = ieee80211_master_start_xmit; |
| 1098 | mdev->open = ieee80211_master_open; |
| 1099 | mdev->stop = ieee80211_master_stop; |
| 1100 | mdev->type = ARPHRD_IEEE80211; |
Stephen Hemminger | 3b04ddd | 2007-10-09 01:40:57 -0700 | [diff] [blame] | 1101 | mdev->header_ops = &ieee80211_header_ops; |
Johannes Berg | 4150c57 | 2007-09-17 01:29:23 -0400 | [diff] [blame] | 1102 | mdev->set_multicast_list = ieee80211_master_set_multicast_list; |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 1103 | |
Johannes Berg | 51fb61e | 2007-12-19 01:31:27 +0100 | [diff] [blame] | 1104 | sdata->vif.type = IEEE80211_IF_TYPE_AP; |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 1105 | sdata->dev = mdev; |
| 1106 | sdata->local = local; |
| 1107 | sdata->u.ap.force_unicast_rateidx = -1; |
| 1108 | sdata->u.ap.max_ratectrl_rateidx = -1; |
| 1109 | ieee80211_if_sdata_init(sdata); |
Johannes Berg | 7901042 | 2007-09-18 17:29:21 -0400 | [diff] [blame] | 1110 | /* no RCU needed since we're still during init phase */ |
| 1111 | list_add_tail(&sdata->list, &local->interfaces); |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 1112 | |
| 1113 | tasklet_init(&local->tx_pending_tasklet, ieee80211_tx_pending, |
| 1114 | (unsigned long)local); |
| 1115 | tasklet_disable(&local->tx_pending_tasklet); |
| 1116 | |
| 1117 | tasklet_init(&local->tasklet, |
| 1118 | ieee80211_tasklet_handler, |
| 1119 | (unsigned long) local); |
| 1120 | tasklet_disable(&local->tasklet); |
| 1121 | |
| 1122 | skb_queue_head_init(&local->skb_queue); |
| 1123 | skb_queue_head_init(&local->skb_queue_unreliable); |
| 1124 | |
| 1125 | return local_to_hw(local); |
| 1126 | } |
| 1127 | EXPORT_SYMBOL(ieee80211_alloc_hw); |
| 1128 | |
| 1129 | int ieee80211_register_hw(struct ieee80211_hw *hw) |
| 1130 | { |
| 1131 | struct ieee80211_local *local = hw_to_local(hw); |
| 1132 | const char *name; |
| 1133 | int result; |
| 1134 | |
| 1135 | result = wiphy_register(local->hw.wiphy); |
| 1136 | if (result < 0) |
| 1137 | return result; |
| 1138 | |
| 1139 | name = wiphy_dev(local->hw.wiphy)->driver->name; |
| 1140 | local->hw.workqueue = create_singlethread_workqueue(name); |
| 1141 | if (!local->hw.workqueue) { |
| 1142 | result = -ENOMEM; |
| 1143 | goto fail_workqueue; |
| 1144 | } |
| 1145 | |
Johannes Berg | b306f45 | 2007-07-10 19:32:08 +0200 | [diff] [blame] | 1146 | /* |
| 1147 | * The hardware needs headroom for sending the frame, |
| 1148 | * and we need some headroom for passing the frame to monitor |
| 1149 | * interfaces, but never both at the same time. |
| 1150 | */ |
Jiri Benc | 33ccad3 | 2007-07-18 17:10:44 +0200 | [diff] [blame] | 1151 | local->tx_headroom = max_t(unsigned int , local->hw.extra_tx_headroom, |
| 1152 | sizeof(struct ieee80211_tx_status_rtap_hdr)); |
Johannes Berg | b306f45 | 2007-07-10 19:32:08 +0200 | [diff] [blame] | 1153 | |
Jiri Benc | e9f207f | 2007-05-05 11:46:38 -0700 | [diff] [blame] | 1154 | debugfs_hw_add(local); |
| 1155 | |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 1156 | local->hw.conf.beacon_int = 1000; |
| 1157 | |
| 1158 | local->wstats_flags |= local->hw.max_rssi ? |
| 1159 | IW_QUAL_LEVEL_UPDATED : IW_QUAL_LEVEL_INVALID; |
| 1160 | local->wstats_flags |= local->hw.max_signal ? |
| 1161 | IW_QUAL_QUAL_UPDATED : IW_QUAL_QUAL_INVALID; |
| 1162 | local->wstats_flags |= local->hw.max_noise ? |
| 1163 | IW_QUAL_NOISE_UPDATED : IW_QUAL_NOISE_INVALID; |
| 1164 | if (local->hw.max_rssi < 0 || local->hw.max_noise < 0) |
| 1165 | local->wstats_flags |= IW_QUAL_DBM; |
| 1166 | |
| 1167 | result = sta_info_start(local); |
| 1168 | if (result < 0) |
| 1169 | goto fail_sta_info; |
| 1170 | |
| 1171 | rtnl_lock(); |
| 1172 | result = dev_alloc_name(local->mdev, local->mdev->name); |
| 1173 | if (result < 0) |
| 1174 | goto fail_dev; |
| 1175 | |
| 1176 | memcpy(local->mdev->dev_addr, local->hw.wiphy->perm_addr, ETH_ALEN); |
| 1177 | SET_NETDEV_DEV(local->mdev, wiphy_dev(local->hw.wiphy)); |
| 1178 | |
| 1179 | result = register_netdevice(local->mdev); |
| 1180 | if (result < 0) |
| 1181 | goto fail_dev; |
| 1182 | |
Jiri Benc | e9f207f | 2007-05-05 11:46:38 -0700 | [diff] [blame] | 1183 | ieee80211_debugfs_add_netdev(IEEE80211_DEV_TO_SUB_IF(local->mdev)); |
Johannes Berg | 5b2812e | 2007-09-26 14:27:23 +0200 | [diff] [blame] | 1184 | ieee80211_if_set_type(local->mdev, IEEE80211_IF_TYPE_AP); |
Jiri Benc | e9f207f | 2007-05-05 11:46:38 -0700 | [diff] [blame] | 1185 | |
Johannes Berg | 830f903 | 2007-10-28 14:51:05 +0100 | [diff] [blame] | 1186 | result = ieee80211_init_rate_ctrl_alg(local, |
| 1187 | hw->rate_control_algorithm); |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 1188 | if (result < 0) { |
| 1189 | printk(KERN_DEBUG "%s: Failed to initialize rate control " |
Johannes Berg | dd1cd4c | 2007-09-18 17:29:20 -0400 | [diff] [blame] | 1190 | "algorithm\n", wiphy_name(local->hw.wiphy)); |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 1191 | goto fail_rate; |
| 1192 | } |
| 1193 | |
| 1194 | result = ieee80211_wep_init(local); |
| 1195 | |
| 1196 | if (result < 0) { |
| 1197 | printk(KERN_DEBUG "%s: Failed to initialize wep\n", |
Johannes Berg | dd1cd4c | 2007-09-18 17:29:20 -0400 | [diff] [blame] | 1198 | wiphy_name(local->hw.wiphy)); |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 1199 | goto fail_wep; |
| 1200 | } |
| 1201 | |
| 1202 | ieee80211_install_qdisc(local->mdev); |
| 1203 | |
| 1204 | /* add one default STA interface */ |
| 1205 | result = ieee80211_if_add(local->mdev, "wlan%d", NULL, |
| 1206 | IEEE80211_IF_TYPE_STA); |
| 1207 | if (result) |
| 1208 | printk(KERN_WARNING "%s: Failed to add default virtual iface\n", |
Johannes Berg | dd1cd4c | 2007-09-18 17:29:20 -0400 | [diff] [blame] | 1209 | wiphy_name(local->hw.wiphy)); |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 1210 | |
| 1211 | local->reg_state = IEEE80211_DEV_REGISTERED; |
| 1212 | rtnl_unlock(); |
| 1213 | |
| 1214 | ieee80211_led_init(local); |
| 1215 | |
| 1216 | return 0; |
| 1217 | |
| 1218 | fail_wep: |
| 1219 | rate_control_deinitialize(local); |
| 1220 | fail_rate: |
Jiri Benc | e9f207f | 2007-05-05 11:46:38 -0700 | [diff] [blame] | 1221 | ieee80211_debugfs_remove_netdev(IEEE80211_DEV_TO_SUB_IF(local->mdev)); |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 1222 | unregister_netdevice(local->mdev); |
| 1223 | fail_dev: |
| 1224 | rtnl_unlock(); |
| 1225 | sta_info_stop(local); |
| 1226 | fail_sta_info: |
Jiri Benc | e9f207f | 2007-05-05 11:46:38 -0700 | [diff] [blame] | 1227 | debugfs_hw_del(local); |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 1228 | destroy_workqueue(local->hw.workqueue); |
| 1229 | fail_workqueue: |
| 1230 | wiphy_unregister(local->hw.wiphy); |
| 1231 | return result; |
| 1232 | } |
| 1233 | EXPORT_SYMBOL(ieee80211_register_hw); |
| 1234 | |
| 1235 | int ieee80211_register_hwmode(struct ieee80211_hw *hw, |
| 1236 | struct ieee80211_hw_mode *mode) |
| 1237 | { |
| 1238 | struct ieee80211_local *local = hw_to_local(hw); |
| 1239 | struct ieee80211_rate *rate; |
| 1240 | int i; |
| 1241 | |
| 1242 | INIT_LIST_HEAD(&mode->list); |
| 1243 | list_add_tail(&mode->list, &local->modes_list); |
| 1244 | |
| 1245 | local->hw_modes |= (1 << mode->mode); |
| 1246 | for (i = 0; i < mode->num_rates; i++) { |
| 1247 | rate = &(mode->rates[i]); |
| 1248 | rate->rate_inv = CHAN_UTIL_RATE_LCM / rate->rate; |
| 1249 | } |
| 1250 | ieee80211_prepare_rates(local, mode); |
| 1251 | |
| 1252 | if (!local->oper_hw_mode) { |
| 1253 | /* Default to this mode */ |
| 1254 | local->hw.conf.phymode = mode->mode; |
| 1255 | local->oper_hw_mode = local->scan_hw_mode = mode; |
| 1256 | local->oper_channel = local->scan_channel = &mode->channels[0]; |
| 1257 | local->hw.conf.mode = local->oper_hw_mode; |
| 1258 | local->hw.conf.chan = local->oper_channel; |
| 1259 | } |
| 1260 | |
| 1261 | if (!(hw->flags & IEEE80211_HW_DEFAULT_REG_DOMAIN_CONFIGURED)) |
Daniel Drake | fd8bacc | 2007-06-09 19:07:14 +0100 | [diff] [blame] | 1262 | ieee80211_set_default_regdomain(mode); |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 1263 | |
| 1264 | return 0; |
| 1265 | } |
| 1266 | EXPORT_SYMBOL(ieee80211_register_hwmode); |
| 1267 | |
| 1268 | void ieee80211_unregister_hw(struct ieee80211_hw *hw) |
| 1269 | { |
| 1270 | struct ieee80211_local *local = hw_to_local(hw); |
| 1271 | struct ieee80211_sub_if_data *sdata, *tmp; |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 1272 | int i; |
| 1273 | |
| 1274 | tasklet_kill(&local->tx_pending_tasklet); |
| 1275 | tasklet_kill(&local->tasklet); |
| 1276 | |
| 1277 | rtnl_lock(); |
| 1278 | |
| 1279 | BUG_ON(local->reg_state != IEEE80211_DEV_REGISTERED); |
| 1280 | |
| 1281 | local->reg_state = IEEE80211_DEV_UNREGISTERED; |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 1282 | |
Johannes Berg | 7901042 | 2007-09-18 17:29:21 -0400 | [diff] [blame] | 1283 | /* |
| 1284 | * At this point, interface list manipulations are fine |
| 1285 | * because the driver cannot be handing us frames any |
| 1286 | * more and the tasklet is killed. |
| 1287 | */ |
Johannes Berg | 5b2812e | 2007-09-26 14:27:23 +0200 | [diff] [blame] | 1288 | |
| 1289 | /* |
| 1290 | * First, we remove all non-master interfaces. Do this because they |
| 1291 | * may have bss pointer dependency on the master, and when we free |
| 1292 | * the master these would be freed as well, breaking our list |
| 1293 | * iteration completely. |
| 1294 | */ |
| 1295 | list_for_each_entry_safe(sdata, tmp, &local->interfaces, list) { |
| 1296 | if (sdata->dev == local->mdev) |
| 1297 | continue; |
| 1298 | list_del(&sdata->list); |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 1299 | __ieee80211_if_del(local, sdata); |
Johannes Berg | 5b2812e | 2007-09-26 14:27:23 +0200 | [diff] [blame] | 1300 | } |
| 1301 | |
| 1302 | /* then, finally, remove the master interface */ |
| 1303 | __ieee80211_if_del(local, IEEE80211_DEV_TO_SUB_IF(local->mdev)); |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 1304 | |
| 1305 | rtnl_unlock(); |
| 1306 | |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 1307 | ieee80211_rx_bss_list_deinit(local->mdev); |
| 1308 | ieee80211_clear_tx_pending(local); |
| 1309 | sta_info_stop(local); |
| 1310 | rate_control_deinitialize(local); |
Jiri Benc | e9f207f | 2007-05-05 11:46:38 -0700 | [diff] [blame] | 1311 | debugfs_hw_del(local); |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 1312 | |
| 1313 | for (i = 0; i < NUM_IEEE80211_MODES; i++) { |
| 1314 | kfree(local->supp_rates[i]); |
| 1315 | kfree(local->basic_rates[i]); |
| 1316 | } |
| 1317 | |
| 1318 | if (skb_queue_len(&local->skb_queue) |
| 1319 | || skb_queue_len(&local->skb_queue_unreliable)) |
| 1320 | printk(KERN_WARNING "%s: skb_queue not empty\n", |
Johannes Berg | dd1cd4c | 2007-09-18 17:29:20 -0400 | [diff] [blame] | 1321 | wiphy_name(local->hw.wiphy)); |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 1322 | skb_queue_purge(&local->skb_queue); |
| 1323 | skb_queue_purge(&local->skb_queue_unreliable); |
| 1324 | |
| 1325 | destroy_workqueue(local->hw.workqueue); |
| 1326 | wiphy_unregister(local->hw.wiphy); |
| 1327 | ieee80211_wep_free(local); |
| 1328 | ieee80211_led_exit(local); |
| 1329 | } |
| 1330 | EXPORT_SYMBOL(ieee80211_unregister_hw); |
| 1331 | |
| 1332 | void ieee80211_free_hw(struct ieee80211_hw *hw) |
| 1333 | { |
| 1334 | struct ieee80211_local *local = hw_to_local(hw); |
| 1335 | |
| 1336 | ieee80211_if_free(local->mdev); |
| 1337 | wiphy_free(local->hw.wiphy); |
| 1338 | } |
| 1339 | EXPORT_SYMBOL(ieee80211_free_hw); |
| 1340 | |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 1341 | static int __init ieee80211_init(void) |
| 1342 | { |
| 1343 | struct sk_buff *skb; |
| 1344 | int ret; |
| 1345 | |
| 1346 | BUILD_BUG_ON(sizeof(struct ieee80211_tx_packet_data) > sizeof(skb->cb)); |
| 1347 | |
Johannes Berg | 4b47589 | 2008-01-02 15:17:03 +0100 | [diff] [blame] | 1348 | ret = rc80211_simple_init(); |
Johannes Berg | ac71c69 | 2007-10-28 14:17:44 +0100 | [diff] [blame] | 1349 | if (ret) |
Johannes Berg | 3eadf5f | 2008-01-31 19:33:53 +0100 | [diff] [blame] | 1350 | goto out; |
Mattias Nissler | ad01837 | 2007-12-19 01:25:57 +0100 | [diff] [blame] | 1351 | |
Johannes Berg | 4b47589 | 2008-01-02 15:17:03 +0100 | [diff] [blame] | 1352 | ret = rc80211_pid_init(); |
Mattias Nissler | ad01837 | 2007-12-19 01:25:57 +0100 | [diff] [blame] | 1353 | if (ret) |
Johannes Berg | 3eadf5f | 2008-01-31 19:33:53 +0100 | [diff] [blame] | 1354 | goto out_cleanup_simple; |
Johannes Berg | ac71c69 | 2007-10-28 14:17:44 +0100 | [diff] [blame] | 1355 | |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 1356 | ret = ieee80211_wme_register(); |
| 1357 | if (ret) { |
| 1358 | printk(KERN_DEBUG "ieee80211_init: failed to " |
| 1359 | "initialize WME (err=%d)\n", ret); |
Johannes Berg | 3eadf5f | 2008-01-31 19:33:53 +0100 | [diff] [blame] | 1360 | goto out_cleanup_pid; |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 1361 | } |
| 1362 | |
Jiri Benc | e9f207f | 2007-05-05 11:46:38 -0700 | [diff] [blame] | 1363 | ieee80211_debugfs_netdev_init(); |
Daniel Drake | fd8bacc | 2007-06-09 19:07:14 +0100 | [diff] [blame] | 1364 | ieee80211_regdomain_init(); |
Jiri Benc | e9f207f | 2007-05-05 11:46:38 -0700 | [diff] [blame] | 1365 | |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 1366 | return 0; |
Mattias Nissler | ad01837 | 2007-12-19 01:25:57 +0100 | [diff] [blame] | 1367 | |
Johannes Berg | 3eadf5f | 2008-01-31 19:33:53 +0100 | [diff] [blame] | 1368 | out_cleanup_pid: |
Johannes Berg | 4b47589 | 2008-01-02 15:17:03 +0100 | [diff] [blame] | 1369 | rc80211_pid_exit(); |
Johannes Berg | 3eadf5f | 2008-01-31 19:33:53 +0100 | [diff] [blame] | 1370 | out_cleanup_simple: |
| 1371 | rc80211_simple_exit(); |
| 1372 | out: |
Mattias Nissler | ad01837 | 2007-12-19 01:25:57 +0100 | [diff] [blame] | 1373 | return ret; |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 1374 | } |
| 1375 | |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 1376 | static void __exit ieee80211_exit(void) |
| 1377 | { |
Johannes Berg | 4b47589 | 2008-01-02 15:17:03 +0100 | [diff] [blame] | 1378 | rc80211_simple_exit(); |
| 1379 | rc80211_pid_exit(); |
Johannes Berg | ac71c69 | 2007-10-28 14:17:44 +0100 | [diff] [blame] | 1380 | |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 1381 | ieee80211_wme_unregister(); |
Jiri Benc | e9f207f | 2007-05-05 11:46:38 -0700 | [diff] [blame] | 1382 | ieee80211_debugfs_netdev_exit(); |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 1383 | } |
| 1384 | |
| 1385 | |
Johannes Berg | ca9938f | 2007-09-11 12:50:32 +0200 | [diff] [blame] | 1386 | subsys_initcall(ieee80211_init); |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 1387 | module_exit(ieee80211_exit); |
| 1388 | |
| 1389 | MODULE_DESCRIPTION("IEEE 802.11 subsystem"); |
| 1390 | MODULE_LICENSE("GPL"); |