Commit | Line | Data |
---|---|---|
f0706e82 JB |
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> | |
f0706e82 | 23 | #include <linux/bitmap.h> |
881d966b | 24 | #include <net/net_namespace.h> |
f0706e82 JB |
25 | #include <net/cfg80211.h> |
26 | ||
27 | #include "ieee80211_common.h" | |
28 | #include "ieee80211_i.h" | |
29 | #include "ieee80211_rate.h" | |
30 | #include "wep.h" | |
f0706e82 JB |
31 | #include "wme.h" |
32 | #include "aes_ccm.h" | |
33 | #include "ieee80211_led.h" | |
34 | #include "ieee80211_cfg.h" | |
e9f207f0 JB |
35 | #include "debugfs.h" |
36 | #include "debugfs_netdev.h" | |
f0706e82 | 37 | |
b306f453 JB |
38 | /* |
39 | * For seeing transmitted packets on monitor interfaces | |
40 | * we have a radiotap header too. | |
41 | */ | |
42 | struct ieee80211_tx_status_rtap_hdr { | |
43 | struct ieee80211_radiotap_header hdr; | |
44 | __le16 tx_flags; | |
45 | u8 data_retries; | |
46 | } __attribute__ ((packed)); | |
47 | ||
b2c258fb | 48 | /* common interface routines */ |
b306f453 | 49 | |
b2c258fb JB |
50 | static int header_parse_80211(struct sk_buff *skb, unsigned char *haddr) |
51 | { | |
52 | memcpy(haddr, skb_mac_header(skb) + 10, ETH_ALEN); /* addr2 */ | |
53 | return ETH_ALEN; | |
54 | } | |
f0706e82 | 55 | |
b2c258fb | 56 | /* master interface */ |
f0706e82 | 57 | |
b2c258fb JB |
58 | static int ieee80211_master_open(struct net_device *dev) |
59 | { | |
60 | struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr); | |
61 | struct ieee80211_sub_if_data *sdata; | |
62 | int res = -EOPNOTSUPP; | |
f0706e82 | 63 | |
b2c258fb JB |
64 | read_lock(&local->sub_if_lock); |
65 | list_for_each_entry(sdata, &local->sub_if_list, list) { | |
66 | if (sdata->dev != dev && netif_running(sdata->dev)) { | |
67 | res = 0; | |
68 | break; | |
69 | } | |
70 | } | |
71 | read_unlock(&local->sub_if_lock); | |
72 | return res; | |
73 | } | |
f0706e82 | 74 | |
b2c258fb | 75 | static int ieee80211_master_stop(struct net_device *dev) |
f0706e82 | 76 | { |
b2c258fb JB |
77 | struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr); |
78 | struct ieee80211_sub_if_data *sdata; | |
f0706e82 | 79 | |
b2c258fb JB |
80 | read_lock(&local->sub_if_lock); |
81 | list_for_each_entry(sdata, &local->sub_if_list, list) | |
82 | if (sdata->dev != dev && netif_running(sdata->dev)) | |
83 | dev_close(sdata->dev); | |
84 | read_unlock(&local->sub_if_lock); | |
f0706e82 | 85 | |
b2c258fb JB |
86 | return 0; |
87 | } | |
f0706e82 | 88 | |
b2c258fb | 89 | /* management interface */ |
f0706e82 | 90 | |
b2c258fb JB |
91 | static void |
92 | ieee80211_fill_frame_info(struct ieee80211_local *local, | |
93 | struct ieee80211_frame_info *fi, | |
94 | struct ieee80211_rx_status *status) | |
95 | { | |
96 | if (status) { | |
97 | struct timespec ts; | |
98 | struct ieee80211_rate *rate; | |
f0706e82 | 99 | |
b2c258fb JB |
100 | jiffies_to_timespec(jiffies, &ts); |
101 | fi->hosttime = cpu_to_be64((u64) ts.tv_sec * 1000000 + | |
102 | ts.tv_nsec / 1000); | |
103 | fi->mactime = cpu_to_be64(status->mactime); | |
104 | switch (status->phymode) { | |
f0706e82 | 105 | case MODE_IEEE80211A: |
b2c258fb | 106 | fi->phytype = htonl(ieee80211_phytype_ofdm_dot11_a); |
f0706e82 JB |
107 | break; |
108 | case MODE_IEEE80211B: | |
b2c258fb | 109 | fi->phytype = htonl(ieee80211_phytype_dsss_dot11_b); |
f0706e82 JB |
110 | break; |
111 | case MODE_IEEE80211G: | |
b2c258fb | 112 | fi->phytype = htonl(ieee80211_phytype_pbcc_dot11_g); |
f0706e82 | 113 | break; |
b2c258fb JB |
114 | default: |
115 | fi->phytype = htonl(0xAAAAAAAA); | |
f0706e82 JB |
116 | break; |
117 | } | |
b2c258fb JB |
118 | fi->channel = htonl(status->channel); |
119 | rate = ieee80211_get_rate(local, status->phymode, | |
120 | status->rate); | |
121 | if (rate) { | |
122 | fi->datarate = htonl(rate->rate); | |
123 | if (rate->flags & IEEE80211_RATE_PREAMBLE2) { | |
124 | if (status->rate == rate->val) | |
125 | fi->preamble = htonl(2); /* long */ | |
126 | else if (status->rate == rate->val2) | |
127 | fi->preamble = htonl(1); /* short */ | |
128 | } else | |
129 | fi->preamble = htonl(0); | |
130 | } else { | |
131 | fi->datarate = htonl(0); | |
132 | fi->preamble = htonl(0); | |
133 | } | |
134 | ||
135 | fi->antenna = htonl(status->antenna); | |
136 | fi->priority = htonl(0xffffffff); /* no clue */ | |
137 | fi->ssi_type = htonl(ieee80211_ssi_raw); | |
138 | fi->ssi_signal = htonl(status->ssi); | |
139 | fi->ssi_noise = 0x00000000; | |
140 | fi->encoding = 0; | |
141 | } else { | |
142 | /* clear everything because we really don't know. | |
143 | * the msg_type field isn't present on monitor frames | |
144 | * so we don't know whether it will be present or not, | |
145 | * but it's ok to not clear it since it'll be assigned | |
146 | * anyway */ | |
147 | memset(fi, 0, sizeof(*fi) - sizeof(fi->msg_type)); | |
148 | ||
149 | fi->ssi_type = htonl(ieee80211_ssi_none); | |
150 | } | |
151 | fi->version = htonl(IEEE80211_FI_VERSION); | |
152 | fi->length = cpu_to_be32(sizeof(*fi) - sizeof(fi->msg_type)); | |
153 | } | |
154 | ||
155 | /* this routine is actually not just for this, but also | |
156 | * for pushing fake 'management' frames into userspace. | |
157 | * it shall be replaced by a netlink-based system. */ | |
158 | void | |
159 | ieee80211_rx_mgmt(struct ieee80211_local *local, struct sk_buff *skb, | |
160 | struct ieee80211_rx_status *status, u32 msg_type) | |
161 | { | |
162 | struct ieee80211_frame_info *fi; | |
163 | const size_t hlen = sizeof(struct ieee80211_frame_info); | |
68aae116 | 164 | struct net_device *dev = local->apdev; |
b2c258fb | 165 | |
68aae116 | 166 | skb->dev = dev; |
b2c258fb JB |
167 | |
168 | if (skb_headroom(skb) < hlen) { | |
169 | I802_DEBUG_INC(local->rx_expand_skb_head); | |
170 | if (pskb_expand_head(skb, hlen, 0, GFP_ATOMIC)) { | |
171 | dev_kfree_skb(skb); | |
172 | return; | |
173 | } | |
f0706e82 | 174 | } |
b2c258fb JB |
175 | |
176 | fi = (struct ieee80211_frame_info *) skb_push(skb, hlen); | |
177 | ||
178 | ieee80211_fill_frame_info(local, fi, status); | |
179 | fi->msg_type = htonl(msg_type); | |
180 | ||
68aae116 SH |
181 | dev->stats.rx_packets++; |
182 | dev->stats.rx_bytes += skb->len; | |
b2c258fb JB |
183 | |
184 | skb_set_mac_header(skb, 0); | |
185 | skb->ip_summed = CHECKSUM_UNNECESSARY; | |
186 | skb->pkt_type = PACKET_OTHERHOST; | |
187 | skb->protocol = htons(ETH_P_802_2); | |
188 | memset(skb->cb, 0, sizeof(skb->cb)); | |
189 | netif_rx(skb); | |
f0706e82 JB |
190 | } |
191 | ||
571ecf67 JB |
192 | void ieee80211_key_threshold_notify(struct net_device *dev, |
193 | struct ieee80211_key *key, | |
194 | struct sta_info *sta) | |
f0706e82 JB |
195 | { |
196 | struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr); | |
197 | struct sk_buff *skb; | |
198 | struct ieee80211_msg_key_notification *msg; | |
199 | ||
200 | /* if no one will get it anyway, don't even allocate it. | |
201 | * unlikely because this is only relevant for APs | |
202 | * where the device must be open... */ | |
203 | if (unlikely(!local->apdev)) | |
204 | return; | |
205 | ||
206 | skb = dev_alloc_skb(sizeof(struct ieee80211_frame_info) + | |
207 | sizeof(struct ieee80211_msg_key_notification)); | |
208 | if (!skb) | |
209 | return; | |
210 | ||
211 | skb_reserve(skb, sizeof(struct ieee80211_frame_info)); | |
212 | msg = (struct ieee80211_msg_key_notification *) | |
213 | skb_put(skb, sizeof(struct ieee80211_msg_key_notification)); | |
214 | msg->tx_rx_count = key->tx_rx_count; | |
215 | memcpy(msg->ifname, dev->name, IFNAMSIZ); | |
216 | if (sta) | |
217 | memcpy(msg->addr, sta->addr, ETH_ALEN); | |
218 | else | |
219 | memset(msg->addr, 0xff, ETH_ALEN); | |
220 | ||
221 | key->tx_rx_count = 0; | |
222 | ||
223 | ieee80211_rx_mgmt(local, skb, NULL, | |
224 | ieee80211_msg_key_threshold_notification); | |
225 | } | |
226 | ||
b2c258fb | 227 | static int ieee80211_mgmt_open(struct net_device *dev) |
f0706e82 | 228 | { |
b2c258fb | 229 | struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr); |
f0706e82 | 230 | |
b2c258fb JB |
231 | if (!netif_running(local->mdev)) |
232 | return -EOPNOTSUPP; | |
233 | return 0; | |
e2ebc74d | 234 | } |
f0706e82 | 235 | |
b2c258fb | 236 | static int ieee80211_mgmt_stop(struct net_device *dev) |
e2ebc74d | 237 | { |
b2c258fb JB |
238 | return 0; |
239 | } | |
f0706e82 | 240 | |
b2c258fb JB |
241 | static int ieee80211_change_mtu_apdev(struct net_device *dev, int new_mtu) |
242 | { | |
243 | /* FIX: what would be proper limits for MTU? | |
244 | * This interface uses 802.11 frames. */ | |
245 | if (new_mtu < 256 || new_mtu > IEEE80211_MAX_DATA_LEN) { | |
246 | printk(KERN_WARNING "%s: invalid MTU %d\n", | |
247 | dev->name, new_mtu); | |
248 | return -EINVAL; | |
f0706e82 | 249 | } |
f0706e82 | 250 | |
b2c258fb JB |
251 | #ifdef CONFIG_MAC80211_VERBOSE_DEBUG |
252 | printk(KERN_DEBUG "%s: setting MTU %d\n", dev->name, new_mtu); | |
253 | #endif /* CONFIG_MAC80211_VERBOSE_DEBUG */ | |
254 | dev->mtu = new_mtu; | |
255 | return 0; | |
e2ebc74d | 256 | } |
f0706e82 | 257 | |
b2c258fb | 258 | void ieee80211_if_mgmt_setup(struct net_device *dev) |
e2ebc74d | 259 | { |
b2c258fb JB |
260 | ether_setup(dev); |
261 | dev->hard_start_xmit = ieee80211_mgmt_start_xmit; | |
262 | dev->change_mtu = ieee80211_change_mtu_apdev; | |
b2c258fb JB |
263 | dev->open = ieee80211_mgmt_open; |
264 | dev->stop = ieee80211_mgmt_stop; | |
265 | dev->type = ARPHRD_IEEE80211_PRISM; | |
266 | dev->hard_header_parse = header_parse_80211; | |
267 | dev->uninit = ieee80211_if_reinit; | |
268 | dev->destructor = ieee80211_if_free; | |
f0706e82 JB |
269 | } |
270 | ||
b2c258fb | 271 | /* regular interfaces */ |
f0706e82 | 272 | |
b2c258fb | 273 | static int ieee80211_change_mtu(struct net_device *dev, int new_mtu) |
f0706e82 | 274 | { |
b2c258fb JB |
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", | |
279 | dev->name, new_mtu); | |
280 | return -EINVAL; | |
281 | } | |
f0706e82 | 282 | |
b2c258fb JB |
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 */ | |
286 | dev->mtu = new_mtu; | |
f0706e82 JB |
287 | return 0; |
288 | } | |
289 | ||
b2c258fb JB |
290 | static inline int identical_mac_addr_allowed(int type1, int type2) |
291 | { | |
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))); | |
304 | } | |
f0706e82 | 305 | |
b2c258fb JB |
306 | /* Check if running monitor interfaces should go to a "soft monitor" mode |
307 | * and switch them if necessary. */ | |
308 | static inline void ieee80211_start_soft_monitor(struct ieee80211_local *local) | |
f0706e82 | 309 | { |
b2c258fb | 310 | struct ieee80211_if_init_conf conf; |
f0706e82 | 311 | |
b2c258fb JB |
312 | if (local->open_count && local->open_count == local->monitors && |
313 | !(local->hw.flags & IEEE80211_HW_MONITOR_DURING_OPER) && | |
314 | local->ops->remove_interface) { | |
315 | conf.if_id = -1; | |
316 | conf.type = IEEE80211_IF_TYPE_MNTR; | |
317 | conf.mac_addr = NULL; | |
318 | local->ops->remove_interface(local_to_hw(local), &conf); | |
f0706e82 | 319 | } |
f0706e82 JB |
320 | } |
321 | ||
b2c258fb JB |
322 | /* Check if running monitor interfaces should go to a "hard monitor" mode |
323 | * and switch them if necessary. */ | |
324 | static void ieee80211_start_hard_monitor(struct ieee80211_local *local) | |
f0706e82 | 325 | { |
b2c258fb | 326 | struct ieee80211_if_init_conf conf; |
f0706e82 | 327 | |
b2c258fb JB |
328 | if (local->open_count && local->open_count == local->monitors && |
329 | !(local->hw.flags & IEEE80211_HW_MONITOR_DURING_OPER)) { | |
330 | conf.if_id = -1; | |
331 | conf.type = IEEE80211_IF_TYPE_MNTR; | |
332 | conf.mac_addr = NULL; | |
333 | local->ops->add_interface(local_to_hw(local), &conf); | |
f0706e82 | 334 | } |
e2ebc74d | 335 | } |
f0706e82 | 336 | |
8a69aa93 DD |
337 | static void ieee80211_if_open(struct net_device *dev) |
338 | { | |
339 | struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev); | |
340 | ||
341 | switch (sdata->type) { | |
342 | case IEEE80211_IF_TYPE_STA: | |
343 | case IEEE80211_IF_TYPE_IBSS: | |
d6f2da5b | 344 | sdata->u.sta.flags &= ~IEEE80211_STA_PREV_BSSID_SET; |
8a69aa93 DD |
345 | break; |
346 | } | |
347 | } | |
348 | ||
b2c258fb | 349 | static int ieee80211_open(struct net_device *dev) |
e2ebc74d | 350 | { |
b2c258fb JB |
351 | struct ieee80211_sub_if_data *sdata, *nsdata; |
352 | struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr); | |
353 | struct ieee80211_if_init_conf conf; | |
354 | int res; | |
f0706e82 | 355 | |
b2c258fb JB |
356 | sdata = IEEE80211_DEV_TO_SUB_IF(dev); |
357 | read_lock(&local->sub_if_lock); | |
358 | list_for_each_entry(nsdata, &local->sub_if_list, list) { | |
359 | struct net_device *ndev = nsdata->dev; | |
e2ebc74d | 360 | |
b2c258fb JB |
361 | if (ndev != dev && ndev != local->mdev && netif_running(ndev) && |
362 | compare_ether_addr(dev->dev_addr, ndev->dev_addr) == 0 && | |
363 | !identical_mac_addr_allowed(sdata->type, nsdata->type)) { | |
364 | read_unlock(&local->sub_if_lock); | |
365 | return -ENOTUNIQ; | |
366 | } | |
367 | } | |
368 | read_unlock(&local->sub_if_lock); | |
f0706e82 | 369 | |
b2c258fb JB |
370 | if (sdata->type == IEEE80211_IF_TYPE_WDS && |
371 | is_zero_ether_addr(sdata->u.wds.remote_addr)) | |
372 | return -ENOLINK; | |
f0706e82 | 373 | |
b2c258fb JB |
374 | if (sdata->type == IEEE80211_IF_TYPE_MNTR && local->open_count && |
375 | !(local->hw.flags & IEEE80211_HW_MONITOR_DURING_OPER)) { | |
376 | /* run the interface in a "soft monitor" mode */ | |
377 | local->monitors++; | |
378 | local->open_count++; | |
379 | local->hw.conf.flags |= IEEE80211_CONF_RADIOTAP; | |
380 | return 0; | |
381 | } | |
8a69aa93 | 382 | ieee80211_if_open(dev); |
b2c258fb | 383 | ieee80211_start_soft_monitor(local); |
f0706e82 | 384 | |
b2c258fb JB |
385 | conf.if_id = dev->ifindex; |
386 | conf.type = sdata->type; | |
1bec3f1a JB |
387 | if (sdata->type == IEEE80211_IF_TYPE_MNTR) |
388 | conf.mac_addr = NULL; | |
389 | else | |
390 | conf.mac_addr = dev->dev_addr; | |
b2c258fb JB |
391 | res = local->ops->add_interface(local_to_hw(local), &conf); |
392 | if (res) { | |
393 | if (sdata->type == IEEE80211_IF_TYPE_MNTR) | |
394 | ieee80211_start_hard_monitor(local); | |
395 | return res; | |
396 | } | |
f0706e82 | 397 | |
b2c258fb JB |
398 | if (local->open_count == 0) { |
399 | res = 0; | |
400 | tasklet_enable(&local->tx_pending_tasklet); | |
401 | tasklet_enable(&local->tasklet); | |
402 | if (local->ops->open) | |
403 | res = local->ops->open(local_to_hw(local)); | |
404 | if (res == 0) { | |
405 | res = dev_open(local->mdev); | |
406 | if (res) { | |
407 | if (local->ops->stop) | |
408 | local->ops->stop(local_to_hw(local)); | |
409 | } else { | |
410 | res = ieee80211_hw_config(local); | |
411 | if (res && local->ops->stop) | |
412 | local->ops->stop(local_to_hw(local)); | |
413 | else if (!res && local->apdev) | |
414 | dev_open(local->apdev); | |
415 | } | |
416 | } | |
417 | if (res) { | |
418 | if (local->ops->remove_interface) | |
419 | local->ops->remove_interface(local_to_hw(local), | |
420 | &conf); | |
421 | return res; | |
422 | } | |
423 | } | |
424 | local->open_count++; | |
f0706e82 | 425 | |
b2c258fb JB |
426 | if (sdata->type == IEEE80211_IF_TYPE_MNTR) { |
427 | local->monitors++; | |
428 | local->hw.conf.flags |= IEEE80211_CONF_RADIOTAP; | |
d9430a32 | 429 | } else { |
b2c258fb | 430 | ieee80211_if_config(dev); |
d9430a32 | 431 | ieee80211_reset_erp_info(dev); |
11a843b7 | 432 | ieee80211_enable_keys(sdata); |
d9430a32 | 433 | } |
f0706e82 | 434 | |
b2c258fb JB |
435 | if (sdata->type == IEEE80211_IF_TYPE_STA && |
436 | !local->user_space_mlme) | |
437 | netif_carrier_off(dev); | |
438 | else | |
439 | netif_carrier_on(dev); | |
f0706e82 | 440 | |
b2c258fb JB |
441 | netif_start_queue(dev); |
442 | return 0; | |
f0706e82 | 443 | } |
f0706e82 | 444 | |
b2c258fb | 445 | static void ieee80211_if_shutdown(struct net_device *dev) |
f0706e82 | 446 | { |
f0706e82 | 447 | struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr); |
b2c258fb | 448 | struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev); |
f0706e82 | 449 | |
b2c258fb JB |
450 | ASSERT_RTNL(); |
451 | switch (sdata->type) { | |
452 | case IEEE80211_IF_TYPE_STA: | |
453 | case IEEE80211_IF_TYPE_IBSS: | |
454 | sdata->u.sta.state = IEEE80211_DISABLED; | |
455 | del_timer_sync(&sdata->u.sta.timer); | |
2a8a9a88 JB |
456 | /* |
457 | * Holding the sub_if_lock for writing here blocks | |
458 | * out the receive path and makes sure it's not | |
459 | * currently processing a packet that may get | |
460 | * added to the queue. | |
461 | */ | |
462 | write_lock_bh(&local->sub_if_lock); | |
b2c258fb | 463 | skb_queue_purge(&sdata->u.sta.skb_queue); |
2a8a9a88 JB |
464 | write_unlock_bh(&local->sub_if_lock); |
465 | ||
b2c258fb JB |
466 | if (!local->ops->hw_scan && |
467 | local->scan_dev == sdata->dev) { | |
468 | local->sta_scanning = 0; | |
469 | cancel_delayed_work(&local->scan_work); | |
470 | } | |
471 | flush_workqueue(local->hw.workqueue); | |
472 | break; | |
f0706e82 | 473 | } |
f0706e82 JB |
474 | } |
475 | ||
b2c258fb | 476 | static int ieee80211_stop(struct net_device *dev) |
f0706e82 | 477 | { |
b2c258fb | 478 | struct ieee80211_sub_if_data *sdata; |
f0706e82 | 479 | struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr); |
f0706e82 | 480 | |
b2c258fb | 481 | sdata = IEEE80211_DEV_TO_SUB_IF(dev); |
f0706e82 | 482 | |
b2c258fb JB |
483 | if (sdata->type == IEEE80211_IF_TYPE_MNTR && |
484 | local->open_count > 1 && | |
485 | !(local->hw.flags & IEEE80211_HW_MONITOR_DURING_OPER)) { | |
486 | /* remove "soft monitor" interface */ | |
487 | local->open_count--; | |
488 | local->monitors--; | |
489 | if (!local->monitors) | |
490 | local->hw.conf.flags &= ~IEEE80211_CONF_RADIOTAP; | |
491 | return 0; | |
f0706e82 JB |
492 | } |
493 | ||
b2c258fb JB |
494 | netif_stop_queue(dev); |
495 | ieee80211_if_shutdown(dev); | |
f0706e82 | 496 | |
b2c258fb JB |
497 | if (sdata->type == IEEE80211_IF_TYPE_MNTR) { |
498 | local->monitors--; | |
499 | if (!local->monitors) | |
500 | local->hw.conf.flags &= ~IEEE80211_CONF_RADIOTAP; | |
11a843b7 JB |
501 | } else { |
502 | /* disable all keys for as long as this netdev is down */ | |
503 | ieee80211_disable_keys(sdata); | |
f0706e82 JB |
504 | } |
505 | ||
b2c258fb JB |
506 | local->open_count--; |
507 | if (local->open_count == 0) { | |
508 | if (netif_running(local->mdev)) | |
509 | dev_close(local->mdev); | |
510 | if (local->apdev) | |
511 | dev_close(local->apdev); | |
512 | if (local->ops->stop) | |
513 | local->ops->stop(local_to_hw(local)); | |
514 | tasklet_disable(&local->tx_pending_tasklet); | |
515 | tasklet_disable(&local->tasklet); | |
516 | } | |
517 | if (local->ops->remove_interface) { | |
518 | struct ieee80211_if_init_conf conf; | |
f0706e82 | 519 | |
b2c258fb JB |
520 | conf.if_id = dev->ifindex; |
521 | conf.type = sdata->type; | |
522 | conf.mac_addr = dev->dev_addr; | |
523 | local->ops->remove_interface(local_to_hw(local), &conf); | |
f0706e82 JB |
524 | } |
525 | ||
b2c258fb JB |
526 | ieee80211_start_hard_monitor(local); |
527 | ||
f0706e82 JB |
528 | return 0; |
529 | } | |
530 | ||
531 | enum netif_tx_lock_class { | |
532 | TX_LOCK_NORMAL, | |
533 | TX_LOCK_MASTER, | |
534 | }; | |
535 | ||
536 | static inline void netif_tx_lock_nested(struct net_device *dev, int subclass) | |
537 | { | |
538 | spin_lock_nested(&dev->_xmit_lock, subclass); | |
539 | dev->xmit_lock_owner = smp_processor_id(); | |
540 | } | |
541 | ||
542 | static void ieee80211_set_multicast_list(struct net_device *dev) | |
543 | { | |
544 | struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr); | |
545 | struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev); | |
546 | unsigned short flags; | |
547 | ||
548 | netif_tx_lock_nested(local->mdev, TX_LOCK_MASTER); | |
13262ffd JS |
549 | if (((dev->flags & IFF_ALLMULTI) != 0) ^ |
550 | ((sdata->flags & IEEE80211_SDATA_ALLMULTI) != 0)) { | |
551 | if (sdata->flags & IEEE80211_SDATA_ALLMULTI) | |
f0706e82 | 552 | local->iff_allmultis--; |
13262ffd | 553 | else |
f0706e82 | 554 | local->iff_allmultis++; |
13262ffd | 555 | sdata->flags ^= IEEE80211_SDATA_ALLMULTI; |
f0706e82 | 556 | } |
13262ffd JS |
557 | if (((dev->flags & IFF_PROMISC) != 0) ^ |
558 | ((sdata->flags & IEEE80211_SDATA_PROMISC) != 0)) { | |
559 | if (sdata->flags & IEEE80211_SDATA_PROMISC) | |
f0706e82 | 560 | local->iff_promiscs--; |
13262ffd | 561 | else |
f0706e82 | 562 | local->iff_promiscs++; |
13262ffd | 563 | sdata->flags ^= IEEE80211_SDATA_PROMISC; |
f0706e82 JB |
564 | } |
565 | if (dev->mc_count != sdata->mc_count) { | |
566 | local->mc_count = local->mc_count - sdata->mc_count + | |
567 | dev->mc_count; | |
568 | sdata->mc_count = dev->mc_count; | |
569 | } | |
570 | if (local->ops->set_multicast_list) { | |
571 | flags = local->mdev->flags; | |
572 | if (local->iff_allmultis) | |
573 | flags |= IFF_ALLMULTI; | |
574 | if (local->iff_promiscs) | |
575 | flags |= IFF_PROMISC; | |
576 | read_lock(&local->sub_if_lock); | |
577 | local->ops->set_multicast_list(local_to_hw(local), flags, | |
578 | local->mc_count); | |
579 | read_unlock(&local->sub_if_lock); | |
580 | } | |
581 | netif_tx_unlock(local->mdev); | |
582 | } | |
583 | ||
b2c258fb JB |
584 | /* Must not be called for mdev and apdev */ |
585 | void ieee80211_if_setup(struct net_device *dev) | |
f0706e82 | 586 | { |
b2c258fb JB |
587 | ether_setup(dev); |
588 | dev->hard_start_xmit = ieee80211_subif_start_xmit; | |
589 | dev->wireless_handlers = &ieee80211_iw_handler_def; | |
590 | dev->set_multicast_list = ieee80211_set_multicast_list; | |
591 | dev->change_mtu = ieee80211_change_mtu; | |
b2c258fb JB |
592 | dev->open = ieee80211_open; |
593 | dev->stop = ieee80211_stop; | |
594 | dev->uninit = ieee80211_if_reinit; | |
595 | dev->destructor = ieee80211_if_free; | |
596 | } | |
f0706e82 | 597 | |
b2c258fb JB |
598 | /* WDS specialties */ |
599 | ||
600 | int ieee80211_if_update_wds(struct net_device *dev, u8 *remote_addr) | |
601 | { | |
602 | struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr); | |
603 | struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev); | |
604 | struct sta_info *sta; | |
605 | ||
606 | if (compare_ether_addr(remote_addr, sdata->u.wds.remote_addr) == 0) | |
607 | return 0; | |
608 | ||
609 | /* Create STA entry for the new peer */ | |
610 | sta = sta_info_add(local, dev, remote_addr, GFP_KERNEL); | |
611 | if (!sta) | |
612 | return -ENOMEM; | |
613 | sta_info_put(sta); | |
614 | ||
615 | /* Remove STA entry for the old peer */ | |
616 | sta = sta_info_get(local, sdata->u.wds.remote_addr); | |
617 | if (sta) { | |
be8755e1 | 618 | sta_info_free(sta); |
b2c258fb | 619 | sta_info_put(sta); |
b2c258fb JB |
620 | } else { |
621 | printk(KERN_DEBUG "%s: could not find STA entry for WDS link " | |
622 | "peer " MAC_FMT "\n", | |
623 | dev->name, MAC_ARG(sdata->u.wds.remote_addr)); | |
624 | } | |
625 | ||
626 | /* Update WDS link data */ | |
627 | memcpy(&sdata->u.wds.remote_addr, remote_addr, ETH_ALEN); | |
628 | ||
629 | return 0; | |
f0706e82 | 630 | } |
f0706e82 | 631 | |
b2c258fb JB |
632 | /* everything else */ |
633 | ||
b2c258fb JB |
634 | static int __ieee80211_if_config(struct net_device *dev, |
635 | struct sk_buff *beacon, | |
636 | struct ieee80211_tx_control *control) | |
637 | { | |
638 | struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev); | |
639 | struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr); | |
640 | struct ieee80211_if_conf conf; | |
641 | static u8 scan_bssid[] = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff }; | |
642 | ||
643 | if (!local->ops->config_interface || !netif_running(dev)) | |
f0706e82 | 644 | return 0; |
f0706e82 | 645 | |
b2c258fb | 646 | memset(&conf, 0, sizeof(conf)); |
4480f15c | 647 | conf.type = sdata->type; |
b2c258fb JB |
648 | if (sdata->type == IEEE80211_IF_TYPE_STA || |
649 | sdata->type == IEEE80211_IF_TYPE_IBSS) { | |
650 | if (local->sta_scanning && | |
651 | local->scan_dev == dev) | |
652 | conf.bssid = scan_bssid; | |
653 | else | |
654 | conf.bssid = sdata->u.sta.bssid; | |
655 | conf.ssid = sdata->u.sta.ssid; | |
656 | conf.ssid_len = sdata->u.sta.ssid_len; | |
657 | conf.generic_elem = sdata->u.sta.extra_ie; | |
658 | conf.generic_elem_len = sdata->u.sta.extra_ie_len; | |
659 | } else if (sdata->type == IEEE80211_IF_TYPE_AP) { | |
660 | conf.ssid = sdata->u.ap.ssid; | |
661 | conf.ssid_len = sdata->u.ap.ssid_len; | |
662 | conf.generic_elem = sdata->u.ap.generic_elem; | |
663 | conf.generic_elem_len = sdata->u.ap.generic_elem_len; | |
664 | conf.beacon = beacon; | |
665 | conf.beacon_control = control; | |
f0706e82 | 666 | } |
b2c258fb JB |
667 | return local->ops->config_interface(local_to_hw(local), |
668 | dev->ifindex, &conf); | |
f0706e82 JB |
669 | } |
670 | ||
b2c258fb JB |
671 | int ieee80211_if_config(struct net_device *dev) |
672 | { | |
673 | return __ieee80211_if_config(dev, NULL, NULL); | |
674 | } | |
f0706e82 | 675 | |
b2c258fb | 676 | int ieee80211_if_config_beacon(struct net_device *dev) |
f0706e82 | 677 | { |
f0706e82 | 678 | struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr); |
b2c258fb JB |
679 | struct ieee80211_tx_control control; |
680 | struct sk_buff *skb; | |
f0706e82 | 681 | |
b2c258fb | 682 | if (!(local->hw.flags & IEEE80211_HW_HOST_GEN_BEACON_TEMPLATE)) |
f0706e82 | 683 | return 0; |
b2c258fb JB |
684 | skb = ieee80211_beacon_get(local_to_hw(local), dev->ifindex, &control); |
685 | if (!skb) | |
686 | return -ENOMEM; | |
687 | return __ieee80211_if_config(dev, skb, &control); | |
688 | } | |
f0706e82 | 689 | |
b2c258fb JB |
690 | int ieee80211_hw_config(struct ieee80211_local *local) |
691 | { | |
692 | struct ieee80211_hw_mode *mode; | |
693 | struct ieee80211_channel *chan; | |
694 | int ret = 0; | |
f0706e82 | 695 | |
b2c258fb JB |
696 | if (local->sta_scanning) { |
697 | chan = local->scan_channel; | |
698 | mode = local->scan_hw_mode; | |
699 | } else { | |
700 | chan = local->oper_channel; | |
701 | mode = local->oper_hw_mode; | |
f0706e82 JB |
702 | } |
703 | ||
b2c258fb JB |
704 | local->hw.conf.channel = chan->chan; |
705 | local->hw.conf.channel_val = chan->val; | |
706 | local->hw.conf.power_level = chan->power_level; | |
707 | local->hw.conf.freq = chan->freq; | |
708 | local->hw.conf.phymode = mode->mode; | |
709 | local->hw.conf.antenna_max = chan->antenna_max; | |
710 | local->hw.conf.chan = chan; | |
711 | local->hw.conf.mode = mode; | |
f0706e82 | 712 | |
b2c258fb JB |
713 | #ifdef CONFIG_MAC80211_VERBOSE_DEBUG |
714 | printk(KERN_DEBUG "HW CONFIG: channel=%d freq=%d " | |
715 | "phymode=%d\n", local->hw.conf.channel, local->hw.conf.freq, | |
716 | local->hw.conf.phymode); | |
717 | #endif /* CONFIG_MAC80211_VERBOSE_DEBUG */ | |
718 | ||
719 | if (local->ops->config) | |
720 | ret = local->ops->config(local_to_hw(local), &local->hw.conf); | |
f0706e82 | 721 | |
b2c258fb JB |
722 | return ret; |
723 | } | |
f0706e82 | 724 | |
d9430a32 DD |
725 | void ieee80211_erp_info_change_notify(struct net_device *dev, u8 changes) |
726 | { | |
727 | struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr); | |
728 | struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev); | |
729 | if (local->ops->erp_ie_changed) | |
730 | local->ops->erp_ie_changed(local_to_hw(local), changes, | |
13262ffd JS |
731 | !!(sdata->flags & IEEE80211_SDATA_USE_PROTECTION), |
732 | !(sdata->flags & IEEE80211_SDATA_SHORT_PREAMBLE)); | |
d9430a32 DD |
733 | } |
734 | ||
735 | void ieee80211_reset_erp_info(struct net_device *dev) | |
736 | { | |
737 | struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev); | |
738 | ||
13262ffd JS |
739 | sdata->flags &= ~(IEEE80211_SDATA_USE_PROTECTION | |
740 | IEEE80211_SDATA_SHORT_PREAMBLE); | |
d9430a32 DD |
741 | ieee80211_erp_info_change_notify(dev, |
742 | IEEE80211_ERP_CHANGE_PROTECTION | | |
743 | IEEE80211_ERP_CHANGE_PREAMBLE); | |
744 | } | |
745 | ||
b2c258fb JB |
746 | struct dev_mc_list *ieee80211_get_mc_list_item(struct ieee80211_hw *hw, |
747 | struct dev_mc_list *prev, | |
748 | void **ptr) | |
f0706e82 | 749 | { |
b2c258fb JB |
750 | struct ieee80211_local *local = hw_to_local(hw); |
751 | struct ieee80211_sub_if_data *sdata = *ptr; | |
752 | struct dev_mc_list *mc; | |
753 | ||
754 | if (!prev) { | |
755 | WARN_ON(sdata); | |
756 | sdata = NULL; | |
757 | } | |
758 | if (!prev || !prev->next) { | |
759 | if (sdata) | |
760 | sdata = list_entry(sdata->list.next, | |
761 | struct ieee80211_sub_if_data, list); | |
762 | else | |
763 | sdata = list_entry(local->sub_if_list.next, | |
764 | struct ieee80211_sub_if_data, list); | |
765 | if (&sdata->list != &local->sub_if_list) | |
766 | mc = sdata->dev->mc_list; | |
767 | else | |
768 | mc = NULL; | |
769 | } else | |
770 | mc = prev->next; | |
771 | ||
772 | *ptr = sdata; | |
773 | return mc; | |
f0706e82 | 774 | } |
b2c258fb | 775 | EXPORT_SYMBOL(ieee80211_get_mc_list_item); |
f0706e82 | 776 | |
f0706e82 JB |
777 | void ieee80211_tx_status_irqsafe(struct ieee80211_hw *hw, |
778 | struct sk_buff *skb, | |
779 | struct ieee80211_tx_status *status) | |
780 | { | |
781 | struct ieee80211_local *local = hw_to_local(hw); | |
782 | struct ieee80211_tx_status *saved; | |
783 | int tmp; | |
784 | ||
785 | skb->dev = local->mdev; | |
786 | saved = kmalloc(sizeof(struct ieee80211_tx_status), GFP_ATOMIC); | |
787 | if (unlikely(!saved)) { | |
788 | if (net_ratelimit()) | |
789 | printk(KERN_WARNING "%s: Not enough memory, " | |
790 | "dropping tx status", skb->dev->name); | |
791 | /* should be dev_kfree_skb_irq, but due to this function being | |
792 | * named _irqsafe instead of just _irq we can't be sure that | |
793 | * people won't call it from non-irq contexts */ | |
794 | dev_kfree_skb_any(skb); | |
795 | return; | |
796 | } | |
797 | memcpy(saved, status, sizeof(struct ieee80211_tx_status)); | |
798 | /* copy pointer to saved status into skb->cb for use by tasklet */ | |
799 | memcpy(skb->cb, &saved, sizeof(saved)); | |
800 | ||
801 | skb->pkt_type = IEEE80211_TX_STATUS_MSG; | |
802 | skb_queue_tail(status->control.flags & IEEE80211_TXCTL_REQ_TX_STATUS ? | |
803 | &local->skb_queue : &local->skb_queue_unreliable, skb); | |
804 | tmp = skb_queue_len(&local->skb_queue) + | |
805 | skb_queue_len(&local->skb_queue_unreliable); | |
806 | while (tmp > IEEE80211_IRQSAFE_QUEUE_LIMIT && | |
807 | (skb = skb_dequeue(&local->skb_queue_unreliable))) { | |
808 | memcpy(&saved, skb->cb, sizeof(saved)); | |
809 | kfree(saved); | |
810 | dev_kfree_skb_irq(skb); | |
811 | tmp--; | |
812 | I802_DEBUG_INC(local->tx_status_drop); | |
813 | } | |
814 | tasklet_schedule(&local->tasklet); | |
815 | } | |
816 | EXPORT_SYMBOL(ieee80211_tx_status_irqsafe); | |
817 | ||
818 | static void ieee80211_tasklet_handler(unsigned long data) | |
819 | { | |
820 | struct ieee80211_local *local = (struct ieee80211_local *) data; | |
821 | struct sk_buff *skb; | |
822 | struct ieee80211_rx_status rx_status; | |
823 | struct ieee80211_tx_status *tx_status; | |
824 | ||
825 | while ((skb = skb_dequeue(&local->skb_queue)) || | |
826 | (skb = skb_dequeue(&local->skb_queue_unreliable))) { | |
827 | switch (skb->pkt_type) { | |
828 | case IEEE80211_RX_MSG: | |
829 | /* status is in skb->cb */ | |
830 | memcpy(&rx_status, skb->cb, sizeof(rx_status)); | |
831 | /* Clear skb->type in order to not confuse kernel | |
832 | * netstack. */ | |
833 | skb->pkt_type = 0; | |
834 | __ieee80211_rx(local_to_hw(local), skb, &rx_status); | |
835 | break; | |
836 | case IEEE80211_TX_STATUS_MSG: | |
837 | /* get pointer to saved status out of skb->cb */ | |
838 | memcpy(&tx_status, skb->cb, sizeof(tx_status)); | |
839 | skb->pkt_type = 0; | |
840 | ieee80211_tx_status(local_to_hw(local), | |
841 | skb, tx_status); | |
842 | kfree(tx_status); | |
843 | break; | |
844 | default: /* should never get here! */ | |
845 | printk(KERN_ERR "%s: Unknown message type (%d)\n", | |
846 | local->mdev->name, skb->pkt_type); | |
847 | dev_kfree_skb(skb); | |
848 | break; | |
849 | } | |
850 | } | |
851 | } | |
852 | ||
f0706e82 JB |
853 | /* Remove added headers (e.g., QoS control), encryption header/MIC, etc. to |
854 | * make a prepared TX frame (one that has been given to hw) to look like brand | |
855 | * new IEEE 802.11 frame that is ready to go through TX processing again. | |
856 | * Also, tx_packet_data in cb is restored from tx_control. */ | |
857 | static void ieee80211_remove_tx_extra(struct ieee80211_local *local, | |
858 | struct ieee80211_key *key, | |
859 | struct sk_buff *skb, | |
860 | struct ieee80211_tx_control *control) | |
861 | { | |
862 | int hdrlen, iv_len, mic_len; | |
863 | struct ieee80211_tx_packet_data *pkt_data; | |
864 | ||
865 | pkt_data = (struct ieee80211_tx_packet_data *)skb->cb; | |
866 | pkt_data->ifindex = control->ifindex; | |
e8bf9649 JS |
867 | pkt_data->flags = 0; |
868 | if (control->flags & IEEE80211_TXCTL_REQ_TX_STATUS) | |
869 | pkt_data->flags |= IEEE80211_TXPD_REQ_TX_STATUS; | |
870 | if (control->flags & IEEE80211_TXCTL_DO_NOT_ENCRYPT) | |
871 | pkt_data->flags |= IEEE80211_TXPD_DO_NOT_ENCRYPT; | |
872 | if (control->flags & IEEE80211_TXCTL_REQUEUE) | |
873 | pkt_data->flags |= IEEE80211_TXPD_REQUEUE; | |
874 | if (control->type == IEEE80211_IF_TYPE_MGMT) | |
875 | pkt_data->flags |= IEEE80211_TXPD_MGMT_IFACE; | |
f0706e82 JB |
876 | pkt_data->queue = control->queue; |
877 | ||
878 | hdrlen = ieee80211_get_hdrlen_from_skb(skb); | |
879 | ||
880 | if (!key) | |
881 | goto no_key; | |
882 | ||
8f20fc24 | 883 | switch (key->conf.alg) { |
f0706e82 JB |
884 | case ALG_WEP: |
885 | iv_len = WEP_IV_LEN; | |
886 | mic_len = WEP_ICV_LEN; | |
887 | break; | |
888 | case ALG_TKIP: | |
889 | iv_len = TKIP_IV_LEN; | |
890 | mic_len = TKIP_ICV_LEN; | |
891 | break; | |
892 | case ALG_CCMP: | |
893 | iv_len = CCMP_HDR_LEN; | |
894 | mic_len = CCMP_MIC_LEN; | |
895 | break; | |
896 | default: | |
897 | goto no_key; | |
898 | } | |
899 | ||
8f20fc24 | 900 | if (skb->len >= mic_len && |
11a843b7 | 901 | !(key->flags & KEY_FLAG_UPLOADED_TO_HARDWARE)) |
f0706e82 JB |
902 | skb_trim(skb, skb->len - mic_len); |
903 | if (skb->len >= iv_len && skb->len > hdrlen) { | |
904 | memmove(skb->data + iv_len, skb->data, hdrlen); | |
905 | skb_pull(skb, iv_len); | |
906 | } | |
907 | ||
908 | no_key: | |
909 | { | |
910 | struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) skb->data; | |
911 | u16 fc = le16_to_cpu(hdr->frame_control); | |
912 | if ((fc & 0x8C) == 0x88) /* QoS Control Field */ { | |
913 | fc &= ~IEEE80211_STYPE_QOS_DATA; | |
914 | hdr->frame_control = cpu_to_le16(fc); | |
915 | memmove(skb->data + 2, skb->data, hdrlen - 2); | |
916 | skb_pull(skb, 2); | |
917 | } | |
918 | } | |
919 | } | |
920 | ||
f0706e82 JB |
921 | void ieee80211_tx_status(struct ieee80211_hw *hw, struct sk_buff *skb, |
922 | struct ieee80211_tx_status *status) | |
923 | { | |
924 | struct sk_buff *skb2; | |
925 | struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) skb->data; | |
926 | struct ieee80211_local *local = hw_to_local(hw); | |
927 | u16 frag, type; | |
928 | u32 msg_type; | |
b306f453 JB |
929 | struct ieee80211_tx_status_rtap_hdr *rthdr; |
930 | struct ieee80211_sub_if_data *sdata; | |
931 | int monitors; | |
f0706e82 JB |
932 | |
933 | if (!status) { | |
934 | printk(KERN_ERR | |
935 | "%s: ieee80211_tx_status called with NULL status\n", | |
936 | local->mdev->name); | |
937 | dev_kfree_skb(skb); | |
938 | return; | |
939 | } | |
940 | ||
941 | if (status->excessive_retries) { | |
942 | struct sta_info *sta; | |
943 | sta = sta_info_get(local, hdr->addr1); | |
944 | if (sta) { | |
945 | if (sta->flags & WLAN_STA_PS) { | |
946 | /* The STA is in power save mode, so assume | |
947 | * that this TX packet failed because of that. | |
948 | */ | |
949 | status->excessive_retries = 0; | |
950 | status->flags |= IEEE80211_TX_STATUS_TX_FILTERED; | |
951 | } | |
952 | sta_info_put(sta); | |
953 | } | |
954 | } | |
955 | ||
956 | if (status->flags & IEEE80211_TX_STATUS_TX_FILTERED) { | |
957 | struct sta_info *sta; | |
958 | sta = sta_info_get(local, hdr->addr1); | |
959 | if (sta) { | |
960 | sta->tx_filtered_count++; | |
961 | ||
962 | /* Clear the TX filter mask for this STA when sending | |
963 | * the next packet. If the STA went to power save mode, | |
964 | * this will happen when it is waking up for the next | |
965 | * time. */ | |
966 | sta->clear_dst_mask = 1; | |
967 | ||
968 | /* TODO: Is the WLAN_STA_PS flag always set here or is | |
969 | * the race between RX and TX status causing some | |
970 | * packets to be filtered out before 80211.o gets an | |
971 | * update for PS status? This seems to be the case, so | |
972 | * no changes are likely to be needed. */ | |
973 | if (sta->flags & WLAN_STA_PS && | |
974 | skb_queue_len(&sta->tx_filtered) < | |
975 | STA_MAX_TX_BUFFER) { | |
976 | ieee80211_remove_tx_extra(local, sta->key, | |
977 | skb, | |
978 | &status->control); | |
979 | skb_queue_tail(&sta->tx_filtered, skb); | |
980 | } else if (!(sta->flags & WLAN_STA_PS) && | |
981 | !(status->control.flags & IEEE80211_TXCTL_REQUEUE)) { | |
982 | /* Software retry the packet once */ | |
983 | status->control.flags |= IEEE80211_TXCTL_REQUEUE; | |
984 | ieee80211_remove_tx_extra(local, sta->key, | |
985 | skb, | |
986 | &status->control); | |
987 | dev_queue_xmit(skb); | |
988 | } else { | |
989 | if (net_ratelimit()) { | |
990 | printk(KERN_DEBUG "%s: dropped TX " | |
991 | "filtered frame queue_len=%d " | |
992 | "PS=%d @%lu\n", | |
993 | local->mdev->name, | |
994 | skb_queue_len( | |
995 | &sta->tx_filtered), | |
996 | !!(sta->flags & WLAN_STA_PS), | |
997 | jiffies); | |
998 | } | |
999 | dev_kfree_skb(skb); | |
1000 | } | |
1001 | sta_info_put(sta); | |
1002 | return; | |
1003 | } | |
1004 | } else { | |
1005 | /* FIXME: STUPID to call this with both local and local->mdev */ | |
1006 | rate_control_tx_status(local, local->mdev, skb, status); | |
1007 | } | |
1008 | ||
1009 | ieee80211_led_tx(local, 0); | |
1010 | ||
1011 | /* SNMP counters | |
1012 | * Fragments are passed to low-level drivers as separate skbs, so these | |
1013 | * are actually fragments, not frames. Update frame counters only for | |
1014 | * the first fragment of the frame. */ | |
1015 | ||
1016 | frag = le16_to_cpu(hdr->seq_ctrl) & IEEE80211_SCTL_FRAG; | |
1017 | type = le16_to_cpu(hdr->frame_control) & IEEE80211_FCTL_FTYPE; | |
1018 | ||
1019 | if (status->flags & IEEE80211_TX_STATUS_ACK) { | |
1020 | if (frag == 0) { | |
1021 | local->dot11TransmittedFrameCount++; | |
1022 | if (is_multicast_ether_addr(hdr->addr1)) | |
1023 | local->dot11MulticastTransmittedFrameCount++; | |
1024 | if (status->retry_count > 0) | |
1025 | local->dot11RetryCount++; | |
1026 | if (status->retry_count > 1) | |
1027 | local->dot11MultipleRetryCount++; | |
1028 | } | |
1029 | ||
1030 | /* This counter shall be incremented for an acknowledged MPDU | |
1031 | * with an individual address in the address 1 field or an MPDU | |
1032 | * with a multicast address in the address 1 field of type Data | |
1033 | * or Management. */ | |
1034 | if (!is_multicast_ether_addr(hdr->addr1) || | |
1035 | type == IEEE80211_FTYPE_DATA || | |
1036 | type == IEEE80211_FTYPE_MGMT) | |
1037 | local->dot11TransmittedFragmentCount++; | |
1038 | } else { | |
1039 | if (frag == 0) | |
1040 | local->dot11FailedCount++; | |
1041 | } | |
1042 | ||
b306f453 JB |
1043 | msg_type = (status->flags & IEEE80211_TX_STATUS_ACK) ? |
1044 | ieee80211_msg_tx_callback_ack : ieee80211_msg_tx_callback_fail; | |
1045 | ||
1046 | /* this was a transmitted frame, but now we want to reuse it */ | |
1047 | skb_orphan(skb); | |
1048 | ||
1049 | if ((status->control.flags & IEEE80211_TXCTL_REQ_TX_STATUS) && | |
1050 | local->apdev) { | |
1051 | if (local->monitors) { | |
1052 | skb2 = skb_clone(skb, GFP_ATOMIC); | |
1053 | } else { | |
1054 | skb2 = skb; | |
1055 | skb = NULL; | |
1056 | } | |
1057 | ||
1058 | if (skb2) | |
1059 | /* Send frame to hostapd */ | |
1060 | ieee80211_rx_mgmt(local, skb2, NULL, msg_type); | |
1061 | ||
1062 | if (!skb) | |
1063 | return; | |
1064 | } | |
1065 | ||
1066 | if (!local->monitors) { | |
f0706e82 JB |
1067 | dev_kfree_skb(skb); |
1068 | return; | |
1069 | } | |
1070 | ||
b306f453 | 1071 | /* send frame to monitor interfaces now */ |
f0706e82 | 1072 | |
b306f453 JB |
1073 | if (skb_headroom(skb) < sizeof(*rthdr)) { |
1074 | printk(KERN_ERR "ieee80211_tx_status: headroom too small\n"); | |
f0706e82 JB |
1075 | dev_kfree_skb(skb); |
1076 | return; | |
1077 | } | |
f0706e82 | 1078 | |
b306f453 JB |
1079 | rthdr = (struct ieee80211_tx_status_rtap_hdr*) |
1080 | skb_push(skb, sizeof(*rthdr)); | |
1081 | ||
1082 | memset(rthdr, 0, sizeof(*rthdr)); | |
1083 | rthdr->hdr.it_len = cpu_to_le16(sizeof(*rthdr)); | |
1084 | rthdr->hdr.it_present = | |
1085 | cpu_to_le32((1 << IEEE80211_RADIOTAP_TX_FLAGS) | | |
1086 | (1 << IEEE80211_RADIOTAP_DATA_RETRIES)); | |
1087 | ||
1088 | if (!(status->flags & IEEE80211_TX_STATUS_ACK) && | |
1089 | !is_multicast_ether_addr(hdr->addr1)) | |
1090 | rthdr->tx_flags |= cpu_to_le16(IEEE80211_RADIOTAP_F_TX_FAIL); | |
1091 | ||
1092 | if ((status->control.flags & IEEE80211_TXCTL_USE_RTS_CTS) && | |
1093 | (status->control.flags & IEEE80211_TXCTL_USE_CTS_PROTECT)) | |
1094 | rthdr->tx_flags |= cpu_to_le16(IEEE80211_RADIOTAP_F_TX_CTS); | |
1095 | else if (status->control.flags & IEEE80211_TXCTL_USE_RTS_CTS) | |
1096 | rthdr->tx_flags |= cpu_to_le16(IEEE80211_RADIOTAP_F_TX_RTS); | |
1097 | ||
1098 | rthdr->data_retries = status->retry_count; | |
1099 | ||
1100 | read_lock(&local->sub_if_lock); | |
1101 | monitors = local->monitors; | |
1102 | list_for_each_entry(sdata, &local->sub_if_list, list) { | |
1103 | /* | |
1104 | * Using the monitors counter is possibly racy, but | |
1105 | * if the value is wrong we simply either clone the skb | |
1106 | * once too much or forget sending it to one monitor iface | |
1107 | * The latter case isn't nice but fixing the race is much | |
1108 | * more complicated. | |
1109 | */ | |
1110 | if (!monitors || !skb) | |
1111 | goto out; | |
1112 | ||
1113 | if (sdata->type == IEEE80211_IF_TYPE_MNTR) { | |
1114 | if (!netif_running(sdata->dev)) | |
1115 | continue; | |
1116 | monitors--; | |
1117 | if (monitors) | |
1118 | skb2 = skb_clone(skb, GFP_KERNEL); | |
1119 | else | |
1120 | skb2 = NULL; | |
1121 | skb->dev = sdata->dev; | |
1122 | /* XXX: is this sufficient for BPF? */ | |
1123 | skb_set_mac_header(skb, 0); | |
1124 | skb->ip_summed = CHECKSUM_UNNECESSARY; | |
1125 | skb->pkt_type = PACKET_OTHERHOST; | |
1126 | skb->protocol = htons(ETH_P_802_2); | |
1127 | memset(skb->cb, 0, sizeof(skb->cb)); | |
1128 | netif_rx(skb); | |
1129 | skb = skb2; | |
b306f453 JB |
1130 | } |
1131 | } | |
1132 | out: | |
1133 | read_unlock(&local->sub_if_lock); | |
1134 | if (skb) | |
1135 | dev_kfree_skb(skb); | |
f0706e82 JB |
1136 | } |
1137 | EXPORT_SYMBOL(ieee80211_tx_status); | |
1138 | ||
f0706e82 JB |
1139 | struct ieee80211_hw *ieee80211_alloc_hw(size_t priv_data_len, |
1140 | const struct ieee80211_ops *ops) | |
1141 | { | |
1142 | struct net_device *mdev; | |
1143 | struct ieee80211_local *local; | |
1144 | struct ieee80211_sub_if_data *sdata; | |
1145 | int priv_size; | |
1146 | struct wiphy *wiphy; | |
1147 | ||
1148 | /* Ensure 32-byte alignment of our private data and hw private data. | |
1149 | * We use the wiphy priv data for both our ieee80211_local and for | |
1150 | * the driver's private data | |
1151 | * | |
1152 | * In memory it'll be like this: | |
1153 | * | |
1154 | * +-------------------------+ | |
1155 | * | struct wiphy | | |
1156 | * +-------------------------+ | |
1157 | * | struct ieee80211_local | | |
1158 | * +-------------------------+ | |
1159 | * | driver's private data | | |
1160 | * +-------------------------+ | |
1161 | * | |
1162 | */ | |
1163 | priv_size = ((sizeof(struct ieee80211_local) + | |
1164 | NETDEV_ALIGN_CONST) & ~NETDEV_ALIGN_CONST) + | |
1165 | priv_data_len; | |
1166 | ||
1167 | wiphy = wiphy_new(&mac80211_config_ops, priv_size); | |
1168 | ||
1169 | if (!wiphy) | |
1170 | return NULL; | |
1171 | ||
1172 | wiphy->privid = mac80211_wiphy_privid; | |
1173 | ||
1174 | local = wiphy_priv(wiphy); | |
1175 | local->hw.wiphy = wiphy; | |
1176 | ||
1177 | local->hw.priv = (char *)local + | |
1178 | ((sizeof(struct ieee80211_local) + | |
1179 | NETDEV_ALIGN_CONST) & ~NETDEV_ALIGN_CONST); | |
1180 | ||
4480f15c JB |
1181 | BUG_ON(!ops->tx); |
1182 | BUG_ON(!ops->config); | |
1183 | BUG_ON(!ops->add_interface); | |
f0706e82 JB |
1184 | local->ops = ops; |
1185 | ||
1186 | /* for now, mdev needs sub_if_data :/ */ | |
1187 | mdev = alloc_netdev(sizeof(struct ieee80211_sub_if_data), | |
1188 | "wmaster%d", ether_setup); | |
1189 | if (!mdev) { | |
1190 | wiphy_free(wiphy); | |
1191 | return NULL; | |
1192 | } | |
1193 | ||
1194 | sdata = IEEE80211_DEV_TO_SUB_IF(mdev); | |
1195 | mdev->ieee80211_ptr = &sdata->wdev; | |
1196 | sdata->wdev.wiphy = wiphy; | |
1197 | ||
1198 | local->hw.queues = 1; /* default */ | |
1199 | ||
1200 | local->mdev = mdev; | |
1201 | local->rx_pre_handlers = ieee80211_rx_pre_handlers; | |
1202 | local->rx_handlers = ieee80211_rx_handlers; | |
1203 | local->tx_handlers = ieee80211_tx_handlers; | |
1204 | ||
1205 | local->bridge_packets = 1; | |
1206 | ||
1207 | local->rts_threshold = IEEE80211_MAX_RTS_THRESHOLD; | |
1208 | local->fragmentation_threshold = IEEE80211_MAX_FRAG_THRESHOLD; | |
1209 | local->short_retry_limit = 7; | |
1210 | local->long_retry_limit = 4; | |
1211 | local->hw.conf.radio_enabled = 1; | |
f0706e82 | 1212 | |
b708e610 | 1213 | local->enabled_modes = ~0; |
f0706e82 JB |
1214 | |
1215 | INIT_LIST_HEAD(&local->modes_list); | |
1216 | ||
1217 | rwlock_init(&local->sub_if_lock); | |
1218 | INIT_LIST_HEAD(&local->sub_if_list); | |
1219 | ||
1220 | INIT_DELAYED_WORK(&local->scan_work, ieee80211_sta_scan_work); | |
f0706e82 JB |
1221 | ieee80211_rx_bss_list_init(mdev); |
1222 | ||
1223 | sta_info_init(local); | |
1224 | ||
1225 | mdev->hard_start_xmit = ieee80211_master_start_xmit; | |
1226 | mdev->open = ieee80211_master_open; | |
1227 | mdev->stop = ieee80211_master_stop; | |
1228 | mdev->type = ARPHRD_IEEE80211; | |
1229 | mdev->hard_header_parse = header_parse_80211; | |
1230 | ||
1231 | sdata->type = IEEE80211_IF_TYPE_AP; | |
1232 | sdata->dev = mdev; | |
1233 | sdata->local = local; | |
1234 | sdata->u.ap.force_unicast_rateidx = -1; | |
1235 | sdata->u.ap.max_ratectrl_rateidx = -1; | |
1236 | ieee80211_if_sdata_init(sdata); | |
1237 | list_add_tail(&sdata->list, &local->sub_if_list); | |
1238 | ||
1239 | tasklet_init(&local->tx_pending_tasklet, ieee80211_tx_pending, | |
1240 | (unsigned long)local); | |
1241 | tasklet_disable(&local->tx_pending_tasklet); | |
1242 | ||
1243 | tasklet_init(&local->tasklet, | |
1244 | ieee80211_tasklet_handler, | |
1245 | (unsigned long) local); | |
1246 | tasklet_disable(&local->tasklet); | |
1247 | ||
1248 | skb_queue_head_init(&local->skb_queue); | |
1249 | skb_queue_head_init(&local->skb_queue_unreliable); | |
1250 | ||
1251 | return local_to_hw(local); | |
1252 | } | |
1253 | EXPORT_SYMBOL(ieee80211_alloc_hw); | |
1254 | ||
1255 | int ieee80211_register_hw(struct ieee80211_hw *hw) | |
1256 | { | |
1257 | struct ieee80211_local *local = hw_to_local(hw); | |
1258 | const char *name; | |
1259 | int result; | |
1260 | ||
1261 | result = wiphy_register(local->hw.wiphy); | |
1262 | if (result < 0) | |
1263 | return result; | |
1264 | ||
1265 | name = wiphy_dev(local->hw.wiphy)->driver->name; | |
1266 | local->hw.workqueue = create_singlethread_workqueue(name); | |
1267 | if (!local->hw.workqueue) { | |
1268 | result = -ENOMEM; | |
1269 | goto fail_workqueue; | |
1270 | } | |
1271 | ||
b306f453 JB |
1272 | /* |
1273 | * The hardware needs headroom for sending the frame, | |
1274 | * and we need some headroom for passing the frame to monitor | |
1275 | * interfaces, but never both at the same time. | |
1276 | */ | |
33ccad35 JB |
1277 | local->tx_headroom = max_t(unsigned int , local->hw.extra_tx_headroom, |
1278 | sizeof(struct ieee80211_tx_status_rtap_hdr)); | |
b306f453 | 1279 | |
e9f207f0 JB |
1280 | debugfs_hw_add(local); |
1281 | ||
f0706e82 JB |
1282 | local->hw.conf.beacon_int = 1000; |
1283 | ||
1284 | local->wstats_flags |= local->hw.max_rssi ? | |
1285 | IW_QUAL_LEVEL_UPDATED : IW_QUAL_LEVEL_INVALID; | |
1286 | local->wstats_flags |= local->hw.max_signal ? | |
1287 | IW_QUAL_QUAL_UPDATED : IW_QUAL_QUAL_INVALID; | |
1288 | local->wstats_flags |= local->hw.max_noise ? | |
1289 | IW_QUAL_NOISE_UPDATED : IW_QUAL_NOISE_INVALID; | |
1290 | if (local->hw.max_rssi < 0 || local->hw.max_noise < 0) | |
1291 | local->wstats_flags |= IW_QUAL_DBM; | |
1292 | ||
1293 | result = sta_info_start(local); | |
1294 | if (result < 0) | |
1295 | goto fail_sta_info; | |
1296 | ||
1297 | rtnl_lock(); | |
1298 | result = dev_alloc_name(local->mdev, local->mdev->name); | |
1299 | if (result < 0) | |
1300 | goto fail_dev; | |
1301 | ||
1302 | memcpy(local->mdev->dev_addr, local->hw.wiphy->perm_addr, ETH_ALEN); | |
1303 | SET_NETDEV_DEV(local->mdev, wiphy_dev(local->hw.wiphy)); | |
1304 | ||
1305 | result = register_netdevice(local->mdev); | |
1306 | if (result < 0) | |
1307 | goto fail_dev; | |
1308 | ||
e9f207f0 JB |
1309 | ieee80211_debugfs_add_netdev(IEEE80211_DEV_TO_SUB_IF(local->mdev)); |
1310 | ||
f0706e82 JB |
1311 | result = ieee80211_init_rate_ctrl_alg(local, NULL); |
1312 | if (result < 0) { | |
1313 | printk(KERN_DEBUG "%s: Failed to initialize rate control " | |
1314 | "algorithm\n", local->mdev->name); | |
1315 | goto fail_rate; | |
1316 | } | |
1317 | ||
1318 | result = ieee80211_wep_init(local); | |
1319 | ||
1320 | if (result < 0) { | |
1321 | printk(KERN_DEBUG "%s: Failed to initialize wep\n", | |
1322 | local->mdev->name); | |
1323 | goto fail_wep; | |
1324 | } | |
1325 | ||
1326 | ieee80211_install_qdisc(local->mdev); | |
1327 | ||
1328 | /* add one default STA interface */ | |
1329 | result = ieee80211_if_add(local->mdev, "wlan%d", NULL, | |
1330 | IEEE80211_IF_TYPE_STA); | |
1331 | if (result) | |
1332 | printk(KERN_WARNING "%s: Failed to add default virtual iface\n", | |
1333 | local->mdev->name); | |
1334 | ||
1335 | local->reg_state = IEEE80211_DEV_REGISTERED; | |
1336 | rtnl_unlock(); | |
1337 | ||
1338 | ieee80211_led_init(local); | |
1339 | ||
1340 | return 0; | |
1341 | ||
1342 | fail_wep: | |
1343 | rate_control_deinitialize(local); | |
1344 | fail_rate: | |
e9f207f0 | 1345 | ieee80211_debugfs_remove_netdev(IEEE80211_DEV_TO_SUB_IF(local->mdev)); |
f0706e82 JB |
1346 | unregister_netdevice(local->mdev); |
1347 | fail_dev: | |
1348 | rtnl_unlock(); | |
1349 | sta_info_stop(local); | |
1350 | fail_sta_info: | |
e9f207f0 | 1351 | debugfs_hw_del(local); |
f0706e82 JB |
1352 | destroy_workqueue(local->hw.workqueue); |
1353 | fail_workqueue: | |
1354 | wiphy_unregister(local->hw.wiphy); | |
1355 | return result; | |
1356 | } | |
1357 | EXPORT_SYMBOL(ieee80211_register_hw); | |
1358 | ||
1359 | int ieee80211_register_hwmode(struct ieee80211_hw *hw, | |
1360 | struct ieee80211_hw_mode *mode) | |
1361 | { | |
1362 | struct ieee80211_local *local = hw_to_local(hw); | |
1363 | struct ieee80211_rate *rate; | |
1364 | int i; | |
1365 | ||
1366 | INIT_LIST_HEAD(&mode->list); | |
1367 | list_add_tail(&mode->list, &local->modes_list); | |
1368 | ||
1369 | local->hw_modes |= (1 << mode->mode); | |
1370 | for (i = 0; i < mode->num_rates; i++) { | |
1371 | rate = &(mode->rates[i]); | |
1372 | rate->rate_inv = CHAN_UTIL_RATE_LCM / rate->rate; | |
1373 | } | |
1374 | ieee80211_prepare_rates(local, mode); | |
1375 | ||
1376 | if (!local->oper_hw_mode) { | |
1377 | /* Default to this mode */ | |
1378 | local->hw.conf.phymode = mode->mode; | |
1379 | local->oper_hw_mode = local->scan_hw_mode = mode; | |
1380 | local->oper_channel = local->scan_channel = &mode->channels[0]; | |
1381 | local->hw.conf.mode = local->oper_hw_mode; | |
1382 | local->hw.conf.chan = local->oper_channel; | |
1383 | } | |
1384 | ||
1385 | if (!(hw->flags & IEEE80211_HW_DEFAULT_REG_DOMAIN_CONFIGURED)) | |
fd8bacc9 | 1386 | ieee80211_set_default_regdomain(mode); |
f0706e82 JB |
1387 | |
1388 | return 0; | |
1389 | } | |
1390 | EXPORT_SYMBOL(ieee80211_register_hwmode); | |
1391 | ||
1392 | void ieee80211_unregister_hw(struct ieee80211_hw *hw) | |
1393 | { | |
1394 | struct ieee80211_local *local = hw_to_local(hw); | |
1395 | struct ieee80211_sub_if_data *sdata, *tmp; | |
1396 | struct list_head tmp_list; | |
1397 | int i; | |
1398 | ||
1399 | tasklet_kill(&local->tx_pending_tasklet); | |
1400 | tasklet_kill(&local->tasklet); | |
1401 | ||
1402 | rtnl_lock(); | |
1403 | ||
1404 | BUG_ON(local->reg_state != IEEE80211_DEV_REGISTERED); | |
1405 | ||
1406 | local->reg_state = IEEE80211_DEV_UNREGISTERED; | |
1407 | if (local->apdev) | |
1408 | ieee80211_if_del_mgmt(local); | |
1409 | ||
1410 | write_lock_bh(&local->sub_if_lock); | |
1411 | list_replace_init(&local->sub_if_list, &tmp_list); | |
1412 | write_unlock_bh(&local->sub_if_lock); | |
1413 | ||
1414 | list_for_each_entry_safe(sdata, tmp, &tmp_list, list) | |
1415 | __ieee80211_if_del(local, sdata); | |
1416 | ||
1417 | rtnl_unlock(); | |
1418 | ||
f0706e82 JB |
1419 | ieee80211_rx_bss_list_deinit(local->mdev); |
1420 | ieee80211_clear_tx_pending(local); | |
1421 | sta_info_stop(local); | |
1422 | rate_control_deinitialize(local); | |
e9f207f0 | 1423 | debugfs_hw_del(local); |
f0706e82 JB |
1424 | |
1425 | for (i = 0; i < NUM_IEEE80211_MODES; i++) { | |
1426 | kfree(local->supp_rates[i]); | |
1427 | kfree(local->basic_rates[i]); | |
1428 | } | |
1429 | ||
1430 | if (skb_queue_len(&local->skb_queue) | |
1431 | || skb_queue_len(&local->skb_queue_unreliable)) | |
1432 | printk(KERN_WARNING "%s: skb_queue not empty\n", | |
1433 | local->mdev->name); | |
1434 | skb_queue_purge(&local->skb_queue); | |
1435 | skb_queue_purge(&local->skb_queue_unreliable); | |
1436 | ||
1437 | destroy_workqueue(local->hw.workqueue); | |
1438 | wiphy_unregister(local->hw.wiphy); | |
1439 | ieee80211_wep_free(local); | |
1440 | ieee80211_led_exit(local); | |
1441 | } | |
1442 | EXPORT_SYMBOL(ieee80211_unregister_hw); | |
1443 | ||
1444 | void ieee80211_free_hw(struct ieee80211_hw *hw) | |
1445 | { | |
1446 | struct ieee80211_local *local = hw_to_local(hw); | |
1447 | ||
1448 | ieee80211_if_free(local->mdev); | |
1449 | wiphy_free(local->hw.wiphy); | |
1450 | } | |
1451 | EXPORT_SYMBOL(ieee80211_free_hw); | |
1452 | ||
f0706e82 JB |
1453 | static int __init ieee80211_init(void) |
1454 | { | |
1455 | struct sk_buff *skb; | |
1456 | int ret; | |
1457 | ||
1458 | BUILD_BUG_ON(sizeof(struct ieee80211_tx_packet_data) > sizeof(skb->cb)); | |
1459 | ||
1460 | ret = ieee80211_wme_register(); | |
1461 | if (ret) { | |
1462 | printk(KERN_DEBUG "ieee80211_init: failed to " | |
1463 | "initialize WME (err=%d)\n", ret); | |
1464 | return ret; | |
1465 | } | |
1466 | ||
e9f207f0 | 1467 | ieee80211_debugfs_netdev_init(); |
fd8bacc9 | 1468 | ieee80211_regdomain_init(); |
e9f207f0 | 1469 | |
f0706e82 JB |
1470 | return 0; |
1471 | } | |
1472 | ||
f0706e82 JB |
1473 | static void __exit ieee80211_exit(void) |
1474 | { | |
1475 | ieee80211_wme_unregister(); | |
e9f207f0 | 1476 | ieee80211_debugfs_netdev_exit(); |
f0706e82 JB |
1477 | } |
1478 | ||
1479 | ||
ca9938fe | 1480 | subsys_initcall(ieee80211_init); |
f0706e82 JB |
1481 | module_exit(ieee80211_exit); |
1482 | ||
1483 | MODULE_DESCRIPTION("IEEE 802.11 subsystem"); | |
1484 | MODULE_LICENSE("GPL"); |