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