Commit | Line | Data |
---|---|---|
00b3ed16 GKH |
1 | /* src/p80211/p80211knetdev.c |
2 | * | |
3 | * Linux Kernel net device interface | |
4 | * | |
5 | * Copyright (C) 1999 AbsoluteValue Systems, Inc. All Rights Reserved. | |
6 | * -------------------------------------------------------------------- | |
7 | * | |
8 | * linux-wlan | |
9 | * | |
10 | * The contents of this file are subject to the Mozilla Public | |
11 | * License Version 1.1 (the "License"); you may not use this file | |
12 | * except in compliance with the License. You may obtain a copy of | |
13 | * the License at http://www.mozilla.org/MPL/ | |
14 | * | |
15 | * Software distributed under the License is distributed on an "AS | |
16 | * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or | |
17 | * implied. See the License for the specific language governing | |
18 | * rights and limitations under the License. | |
19 | * | |
20 | * Alternatively, the contents of this file may be used under the | |
21 | * terms of the GNU Public License version 2 (the "GPL"), in which | |
22 | * case the provisions of the GPL are applicable instead of the | |
23 | * above. If you wish to allow the use of your version of this file | |
24 | * only under the terms of the GPL and not to allow others to use | |
25 | * your version of this file under the MPL, indicate your decision | |
26 | * by deleting the provisions above and replace them with the notice | |
27 | * and other provisions required by the GPL. If you do not delete | |
28 | * the provisions above, a recipient may use your version of this | |
29 | * file under either the MPL or the GPL. | |
30 | * | |
31 | * -------------------------------------------------------------------- | |
32 | * | |
33 | * Inquiries regarding the linux-wlan Open Source project can be | |
34 | * made directly to: | |
35 | * | |
36 | * AbsoluteValue Systems Inc. | |
37 | * info@linux-wlan.com | |
38 | * http://www.linux-wlan.com | |
39 | * | |
40 | * -------------------------------------------------------------------- | |
41 | * | |
42 | * Portions of the development of this software were funded by | |
43 | * Intersil Corporation as part of PRISM(R) chipset product development. | |
44 | * | |
45 | * -------------------------------------------------------------------- | |
46 | * | |
47 | * The functions required for a Linux network device are defined here. | |
48 | * | |
49 | * -------------------------------------------------------------------- | |
50 | */ | |
51 | ||
00b3ed16 | 52 | #include <linux/version.h> |
00b3ed16 GKH |
53 | #include <linux/module.h> |
54 | #include <linux/kernel.h> | |
55 | #include <linux/sched.h> | |
56 | #include <linux/types.h> | |
57 | #include <linux/skbuff.h> | |
58 | #include <linux/slab.h> | |
59 | #include <linux/proc_fs.h> | |
60 | #include <linux/interrupt.h> | |
61 | #include <linux/netdevice.h> | |
62 | #include <linux/kmod.h> | |
63 | #include <linux/if_arp.h> | |
64 | #include <linux/wireless.h> | |
65 | #include <linux/sockios.h> | |
66 | #include <linux/etherdevice.h> | |
28b17a4b | 67 | #include <linux/if_ether.h> |
ae26230b | 68 | #include <linux/byteorder/generic.h> |
b4b3f0da MM |
69 | #include <linux/bitops.h> |
70 | #include <linux/uaccess.h> | |
00b3ed16 GKH |
71 | #include <asm/byteorder.h> |
72 | ||
73 | #ifdef SIOCETHTOOL | |
74 | #include <linux/ethtool.h> | |
75 | #endif | |
76 | ||
00b3ed16 | 77 | #include <net/iw_handler.h> |
00b3ed16 GKH |
78 | #include <net/net_namespace.h> |
79 | ||
80 | /*================================================================*/ | |
81 | /* Project Includes */ | |
82 | ||
00b3ed16 GKH |
83 | #include "p80211types.h" |
84 | #include "p80211hdr.h" | |
85 | #include "p80211conv.h" | |
86 | #include "p80211mgmt.h" | |
87 | #include "p80211msg.h" | |
88 | #include "p80211netdev.h" | |
89 | #include "p80211ioctl.h" | |
90 | #include "p80211req.h" | |
91 | #include "p80211metastruct.h" | |
92 | #include "p80211metadef.h" | |
93 | ||
00b3ed16 GKH |
94 | /* Support functions */ |
95 | static void p80211netdev_rx_bh(unsigned long arg); | |
96 | ||
97 | /* netdevice method functions */ | |
b4b3f0da MM |
98 | static int p80211knetdev_init(netdevice_t *netdev); |
99 | static struct net_device_stats *p80211knetdev_get_stats(netdevice_t *netdev); | |
100 | static int p80211knetdev_open(netdevice_t *netdev); | |
101 | static int p80211knetdev_stop(netdevice_t *netdev); | |
102 | static int p80211knetdev_hard_start_xmit(struct sk_buff *skb, | |
103 | netdevice_t *netdev); | |
00b3ed16 | 104 | static void p80211knetdev_set_multicast_list(netdevice_t *dev); |
b4b3f0da MM |
105 | static int p80211knetdev_do_ioctl(netdevice_t *dev, struct ifreq *ifr, |
106 | int cmd); | |
00b3ed16 GKH |
107 | static int p80211knetdev_set_mac_address(netdevice_t *dev, void *addr); |
108 | static void p80211knetdev_tx_timeout(netdevice_t *netdev); | |
b4b3f0da | 109 | static int p80211_rx_typedrop(wlandevice_t *wlandev, u16 fc); |
00b3ed16 | 110 | |
e02c69b8 SP |
111 | int wlan_watchdog = 5000; |
112 | module_param(wlan_watchdog, int, 0644); | |
113 | MODULE_PARM_DESC(wlan_watchdog, "transmit timeout in milliseconds"); | |
00b3ed16 | 114 | |
e02c69b8 SP |
115 | int wlan_wext_write = 1; |
116 | module_param(wlan_wext_write, int, 0644); | |
117 | MODULE_PARM_DESC(wlan_wext_write, "enable write wireless extensions"); | |
00b3ed16 | 118 | |
00b3ed16 GKH |
119 | /*---------------------------------------------------------------- |
120 | * p80211knetdev_init | |
121 | * | |
122 | * Init method for a Linux netdevice. Called in response to | |
123 | * register_netdev. | |
124 | * | |
125 | * Arguments: | |
126 | * none | |
127 | * | |
128 | * Returns: | |
129 | * nothing | |
130 | ----------------------------------------------------------------*/ | |
b4b3f0da | 131 | static int p80211knetdev_init(netdevice_t *netdev) |
00b3ed16 | 132 | { |
00b3ed16 GKH |
133 | /* Called in response to register_netdev */ |
134 | /* This is usually the probe function, but the probe has */ | |
135 | /* already been done by the MSD and the create_kdev */ | |
136 | /* function. All we do here is return success */ | |
00b3ed16 GKH |
137 | return 0; |
138 | } | |
139 | ||
00b3ed16 GKH |
140 | /*---------------------------------------------------------------- |
141 | * p80211knetdev_get_stats | |
142 | * | |
143 | * Statistics retrieval for linux netdevices. Here we're reporting | |
144 | * the Linux i/f level statistics. Hence, for the primary numbers, | |
145 | * we don't want to report the numbers from the MIB. Eventually, | |
146 | * it might be useful to collect some of the error counters though. | |
147 | * | |
148 | * Arguments: | |
149 | * netdev Linux netdevice | |
150 | * | |
151 | * Returns: | |
152 | * the address of the statistics structure | |
153 | ----------------------------------------------------------------*/ | |
b4b3f0da | 154 | static struct net_device_stats *p80211knetdev_get_stats(netdevice_t *netdev) |
00b3ed16 | 155 | { |
b4b3f0da | 156 | wlandevice_t *wlandev = netdev->ml_priv; |
00b3ed16 GKH |
157 | |
158 | /* TODO: review the MIB stats for items that correspond to | |
b4b3f0da | 159 | linux stats */ |
00b3ed16 | 160 | |
00b3ed16 GKH |
161 | return &(wlandev->linux_stats); |
162 | } | |
163 | ||
00b3ed16 GKH |
164 | /*---------------------------------------------------------------- |
165 | * p80211knetdev_open | |
166 | * | |
167 | * Linux netdevice open method. Following a successful call here, | |
168 | * the device is supposed to be ready for tx and rx. In our | |
169 | * situation that may not be entirely true due to the state of the | |
170 | * MAC below. | |
171 | * | |
172 | * Arguments: | |
173 | * netdev Linux network device structure | |
174 | * | |
175 | * Returns: | |
176 | * zero on success, non-zero otherwise | |
177 | ----------------------------------------------------------------*/ | |
b4b3f0da | 178 | static int p80211knetdev_open(netdevice_t *netdev) |
00b3ed16 | 179 | { |
b4b3f0da MM |
180 | int result = 0; /* success */ |
181 | wlandevice_t *wlandev = netdev->ml_priv; | |
00b3ed16 | 182 | |
00b3ed16 | 183 | /* Check to make sure the MSD is running */ |
b4b3f0da | 184 | if (wlandev->msdstate != WLAN_MSD_RUNNING) |
00b3ed16 | 185 | return -ENODEV; |
00b3ed16 GKH |
186 | |
187 | /* Tell the MSD to open */ | |
b4b3f0da | 188 | if (wlandev->open != NULL) { |
00b3ed16 | 189 | result = wlandev->open(wlandev); |
b4b3f0da | 190 | if (result == 0) { |
cbec30c4 | 191 | netif_start_queue(wlandev->netdev); |
00b3ed16 GKH |
192 | wlandev->state = WLAN_DEVICE_OPEN; |
193 | } | |
194 | } else { | |
195 | result = -EAGAIN; | |
196 | } | |
197 | ||
00b3ed16 GKH |
198 | return result; |
199 | } | |
200 | ||
00b3ed16 GKH |
201 | /*---------------------------------------------------------------- |
202 | * p80211knetdev_stop | |
203 | * | |
204 | * Linux netdevice stop (close) method. Following this call, | |
205 | * no frames should go up or down through this interface. | |
206 | * | |
207 | * Arguments: | |
208 | * netdev Linux network device structure | |
209 | * | |
210 | * Returns: | |
211 | * zero on success, non-zero otherwise | |
212 | ----------------------------------------------------------------*/ | |
b4b3f0da | 213 | static int p80211knetdev_stop(netdevice_t *netdev) |
00b3ed16 | 214 | { |
b4b3f0da MM |
215 | int result = 0; |
216 | wlandevice_t *wlandev = netdev->ml_priv; | |
00b3ed16 | 217 | |
b4b3f0da | 218 | if (wlandev->close != NULL) |
00b3ed16 | 219 | result = wlandev->close(wlandev); |
00b3ed16 | 220 | |
cbec30c4 | 221 | netif_stop_queue(wlandev->netdev); |
00b3ed16 GKH |
222 | wlandev->state = WLAN_DEVICE_CLOSED; |
223 | ||
00b3ed16 GKH |
224 | return result; |
225 | } | |
226 | ||
227 | /*---------------------------------------------------------------- | |
228 | * p80211netdev_rx | |
229 | * | |
230 | * Frame receive function called by the mac specific driver. | |
231 | * | |
232 | * Arguments: | |
233 | * wlandev WLAN network device structure | |
234 | * skb skbuff containing a full 802.11 frame. | |
235 | * Returns: | |
236 | * nothing | |
237 | * Side effects: | |
238 | * | |
239 | ----------------------------------------------------------------*/ | |
b4b3f0da | 240 | void p80211netdev_rx(wlandevice_t *wlandev, struct sk_buff *skb) |
00b3ed16 | 241 | { |
00b3ed16 GKH |
242 | /* Enqueue for post-irq processing */ |
243 | skb_queue_tail(&wlandev->nsd_rxq, skb); | |
244 | ||
245 | tasklet_schedule(&wlandev->rx_bh); | |
246 | ||
00b3ed16 GKH |
247 | return; |
248 | } | |
249 | ||
250 | /*---------------------------------------------------------------- | |
251 | * p80211netdev_rx_bh | |
252 | * | |
253 | * Deferred processing of all received frames. | |
254 | * | |
255 | * Arguments: | |
256 | * wlandev WLAN network device structure | |
257 | * skb skbuff containing a full 802.11 frame. | |
258 | * Returns: | |
259 | * nothing | |
260 | * Side effects: | |
261 | * | |
262 | ----------------------------------------------------------------*/ | |
263 | static void p80211netdev_rx_bh(unsigned long arg) | |
264 | { | |
265 | wlandevice_t *wlandev = (wlandevice_t *) arg; | |
266 | struct sk_buff *skb = NULL; | |
b4b3f0da | 267 | netdevice_t *dev = wlandev->netdev; |
00b3ed16 | 268 | p80211_hdr_a3_t *hdr; |
aaad4303 | 269 | u16 fc; |
00b3ed16 | 270 | |
00b3ed16 | 271 | /* Let's empty our our queue */ |
b4b3f0da | 272 | while ((skb = skb_dequeue(&wlandev->nsd_rxq))) { |
00b3ed16 GKH |
273 | if (wlandev->state == WLAN_DEVICE_OPEN) { |
274 | ||
275 | if (dev->type != ARPHRD_ETHER) { | |
276 | /* RAW frame; we shouldn't convert it */ | |
b4b3f0da | 277 | /* XXX Append the Prism Header here instead. */ |
00b3ed16 GKH |
278 | |
279 | /* set up various data fields */ | |
280 | skb->dev = dev; | |
281 | skb_reset_mac_header(skb); | |
282 | skb->ip_summed = CHECKSUM_NONE; | |
283 | skb->pkt_type = PACKET_OTHERHOST; | |
284 | skb->protocol = htons(ETH_P_80211_RAW); | |
285 | dev->last_rx = jiffies; | |
286 | ||
287 | wlandev->linux_stats.rx_packets++; | |
288 | wlandev->linux_stats.rx_bytes += skb->len; | |
289 | netif_rx_ni(skb); | |
290 | continue; | |
291 | } else { | |
b4b3f0da | 292 | hdr = (p80211_hdr_a3_t *) skb->data; |
ae26230b | 293 | fc = le16_to_cpu(hdr->fc); |
00b3ed16 GKH |
294 | if (p80211_rx_typedrop(wlandev, fc)) { |
295 | dev_kfree_skb(skb); | |
296 | continue; | |
297 | } | |
298 | ||
299 | /* perform mcast filtering */ | |
300 | if (wlandev->netdev->flags & IFF_ALLMULTI) { | |
301 | /* allow my local address through */ | |
b4b3f0da MM |
302 | if (memcmp |
303 | (hdr->a1, wlandev->netdev->dev_addr, | |
304 | ETH_ALEN) != 0) { | |
00b3ed16 GKH |
305 | /* but reject anything else that isn't multicast */ |
306 | if (!(hdr->a1[0] & 0x01)) { | |
307 | dev_kfree_skb(skb); | |
308 | continue; | |
309 | } | |
310 | } | |
311 | } | |
312 | ||
b4b3f0da MM |
313 | if (skb_p80211_to_ether |
314 | (wlandev, wlandev->ethconv, skb) == 0) { | |
00b3ed16 GKH |
315 | skb->dev->last_rx = jiffies; |
316 | wlandev->linux_stats.rx_packets++; | |
b4b3f0da MM |
317 | wlandev->linux_stats.rx_bytes += |
318 | skb->len; | |
00b3ed16 GKH |
319 | netif_rx_ni(skb); |
320 | continue; | |
321 | } | |
b4b3f0da | 322 | pr_debug("p80211_to_ether failed.\n"); |
00b3ed16 GKH |
323 | } |
324 | } | |
325 | dev_kfree_skb(skb); | |
326 | } | |
00b3ed16 GKH |
327 | } |
328 | ||
00b3ed16 GKH |
329 | /*---------------------------------------------------------------- |
330 | * p80211knetdev_hard_start_xmit | |
331 | * | |
332 | * Linux netdevice method for transmitting a frame. | |
333 | * | |
334 | * Arguments: | |
335 | * skb Linux sk_buff containing the frame. | |
336 | * netdev Linux netdevice. | |
337 | * | |
338 | * Side effects: | |
339 | * If the lower layers report that buffers are full. netdev->tbusy | |
340 | * will be set to prevent higher layers from sending more traffic. | |
341 | * | |
342 | * Note: If this function returns non-zero, higher layers retain | |
343 | * ownership of the skb. | |
344 | * | |
345 | * Returns: | |
346 | * zero on success, non-zero on failure. | |
347 | ----------------------------------------------------------------*/ | |
b4b3f0da MM |
348 | static int p80211knetdev_hard_start_xmit(struct sk_buff *skb, |
349 | netdevice_t *netdev) | |
00b3ed16 | 350 | { |
b4b3f0da MM |
351 | int result = 0; |
352 | int txresult = -1; | |
353 | wlandevice_t *wlandev = netdev->ml_priv; | |
354 | p80211_hdr_t p80211_hdr; | |
00b3ed16 GKH |
355 | p80211_metawep_t p80211_wep; |
356 | ||
b4b3f0da | 357 | if (skb == NULL) |
00b3ed16 | 358 | return 0; |
00b3ed16 | 359 | |
b4b3f0da | 360 | if (wlandev->state != WLAN_DEVICE_OPEN) { |
00b3ed16 GKH |
361 | result = 1; |
362 | goto failed; | |
363 | } | |
364 | ||
365 | memset(&p80211_hdr, 0, sizeof(p80211_hdr_t)); | |
366 | memset(&p80211_wep, 0, sizeof(p80211_metawep_t)); | |
367 | ||
b4b3f0da | 368 | if (netif_queue_stopped(netdev)) { |
a7cf7bae | 369 | pr_debug("called when queue stopped.\n"); |
00b3ed16 GKH |
370 | result = 1; |
371 | goto failed; | |
372 | } | |
373 | ||
374 | netif_stop_queue(netdev); | |
375 | ||
00b3ed16 | 376 | /* Check to see that a valid mode is set */ |
b4b3f0da | 377 | switch (wlandev->macmode) { |
00b3ed16 GKH |
378 | case WLAN_MACMODE_IBSS_STA: |
379 | case WLAN_MACMODE_ESS_STA: | |
380 | case WLAN_MACMODE_ESS_AP: | |
381 | break; | |
382 | default: | |
383 | /* Mode isn't set yet, just drop the frame | |
384 | * and return success . | |
385 | * TODO: we need a saner way to handle this | |
386 | */ | |
b4b3f0da | 387 | if (skb->protocol != ETH_P_80211_RAW) { |
cbec30c4 | 388 | netif_start_queue(wlandev->netdev); |
2acbf9de | 389 | printk(KERN_NOTICE |
b4b3f0da | 390 | "Tx attempt prior to association, frame dropped.\n"); |
00b3ed16 GKH |
391 | wlandev->linux_stats.tx_dropped++; |
392 | result = 0; | |
393 | goto failed; | |
394 | } | |
395 | break; | |
396 | } | |
397 | ||
398 | /* Check for raw transmits */ | |
b4b3f0da | 399 | if (skb->protocol == ETH_P_80211_RAW) { |
00b3ed16 GKH |
400 | if (!capable(CAP_NET_ADMIN)) { |
401 | result = 1; | |
402 | goto failed; | |
403 | } | |
404 | /* move the header over */ | |
405 | memcpy(&p80211_hdr, skb->data, sizeof(p80211_hdr_t)); | |
406 | skb_pull(skb, sizeof(p80211_hdr_t)); | |
407 | } else { | |
b4b3f0da MM |
408 | if (skb_ether_to_p80211 |
409 | (wlandev, wlandev->ethconv, skb, &p80211_hdr, | |
410 | &p80211_wep) != 0) { | |
00b3ed16 | 411 | /* convert failed */ |
a7cf7bae | 412 | pr_debug("ether_to_80211(%d) failed.\n", |
b4b3f0da | 413 | wlandev->ethconv); |
00b3ed16 GKH |
414 | result = 1; |
415 | goto failed; | |
416 | } | |
417 | } | |
b4b3f0da | 418 | if (wlandev->txframe == NULL) { |
00b3ed16 GKH |
419 | result = 1; |
420 | goto failed; | |
421 | } | |
422 | ||
423 | netdev->trans_start = jiffies; | |
424 | ||
425 | wlandev->linux_stats.tx_packets++; | |
426 | /* count only the packet payload */ | |
427 | wlandev->linux_stats.tx_bytes += skb->len; | |
428 | ||
429 | txresult = wlandev->txframe(wlandev, skb, &p80211_hdr, &p80211_wep); | |
430 | ||
b4b3f0da | 431 | if (txresult == 0) { |
00b3ed16 GKH |
432 | /* success and more buf */ |
433 | /* avail, re: hw_txdata */ | |
cbec30c4 | 434 | netif_wake_queue(wlandev->netdev); |
5b548140 | 435 | result = NETDEV_TX_OK; |
b4b3f0da | 436 | } else if (txresult == 1) { |
00b3ed16 | 437 | /* success, no more avail */ |
a7cf7bae | 438 | pr_debug("txframe success, no more bufs\n"); |
00b3ed16 GKH |
439 | /* netdev->tbusy = 1; don't set here, irqhdlr */ |
440 | /* may have already cleared it */ | |
5b548140 | 441 | result = NETDEV_TX_OK; |
b4b3f0da | 442 | } else if (txresult == 2) { |
00b3ed16 | 443 | /* alloc failure, drop frame */ |
a7cf7bae | 444 | pr_debug("txframe returned alloc_fail\n"); |
5b548140 | 445 | result = NETDEV_TX_BUSY; |
00b3ed16 GKH |
446 | } else { |
447 | /* buffer full or queue busy, drop frame. */ | |
a7cf7bae | 448 | pr_debug("txframe returned full or busy\n"); |
5b548140 | 449 | result = NETDEV_TX_BUSY; |
00b3ed16 GKH |
450 | } |
451 | ||
b4b3f0da | 452 | failed: |
00b3ed16 GKH |
453 | /* Free up the WEP buffer if it's not the same as the skb */ |
454 | if ((p80211_wep.data) && (p80211_wep.data != skb->data)) | |
455 | kfree(p80211_wep.data); | |
456 | ||
457 | /* we always free the skb here, never in a lower level. */ | |
458 | if (!result) | |
459 | dev_kfree_skb(skb); | |
460 | ||
00b3ed16 GKH |
461 | return result; |
462 | } | |
463 | ||
00b3ed16 GKH |
464 | /*---------------------------------------------------------------- |
465 | * p80211knetdev_set_multicast_list | |
466 | * | |
467 | * Called from higher lavers whenever there's a need to set/clear | |
468 | * promiscuous mode or rewrite the multicast list. | |
469 | * | |
470 | * Arguments: | |
471 | * none | |
472 | * | |
473 | * Returns: | |
474 | * nothing | |
475 | ----------------------------------------------------------------*/ | |
476 | static void p80211knetdev_set_multicast_list(netdevice_t *dev) | |
477 | { | |
b4b3f0da | 478 | wlandevice_t *wlandev = dev->ml_priv; |
00b3ed16 | 479 | |
00b3ed16 GKH |
480 | /* TODO: real multicast support as well */ |
481 | ||
482 | if (wlandev->set_multicast_list) | |
483 | wlandev->set_multicast_list(wlandev, dev); | |
484 | ||
00b3ed16 GKH |
485 | } |
486 | ||
487 | #ifdef SIOCETHTOOL | |
488 | ||
489 | static int p80211netdev_ethtool(wlandevice_t *wlandev, void __user *useraddr) | |
490 | { | |
aaad4303 | 491 | u32 ethcmd; |
00b3ed16 GKH |
492 | struct ethtool_drvinfo info; |
493 | struct ethtool_value edata; | |
494 | ||
495 | memset(&info, 0, sizeof(info)); | |
496 | memset(&edata, 0, sizeof(edata)); | |
497 | ||
498 | if (copy_from_user(ðcmd, useraddr, sizeof(ethcmd))) | |
499 | return -EFAULT; | |
500 | ||
501 | switch (ethcmd) { | |
502 | case ETHTOOL_GDRVINFO: | |
503 | info.cmd = ethcmd; | |
504 | snprintf(info.driver, sizeof(info.driver), "p80211_%s", | |
505 | wlandev->nsdname); | |
506 | snprintf(info.version, sizeof(info.version), "%s", | |
507 | WLAN_RELEASE); | |
508 | ||
00b3ed16 GKH |
509 | if (copy_to_user(useraddr, &info, sizeof(info))) |
510 | return -EFAULT; | |
511 | return 0; | |
512 | #ifdef ETHTOOL_GLINK | |
513 | case ETHTOOL_GLINK: | |
514 | edata.cmd = ethcmd; | |
515 | ||
516 | if (wlandev->linkstatus && | |
517 | (wlandev->macmode != WLAN_MACMODE_NONE)) { | |
518 | edata.data = 1; | |
519 | } else { | |
520 | edata.data = 0; | |
521 | } | |
522 | ||
523 | if (copy_to_user(useraddr, &edata, sizeof(edata))) | |
b4b3f0da | 524 | return -EFAULT; |
00b3ed16 GKH |
525 | return 0; |
526 | } | |
527 | #endif | |
528 | ||
529 | return -EOPNOTSUPP; | |
530 | } | |
531 | ||
532 | #endif | |
533 | ||
534 | /*---------------------------------------------------------------- | |
535 | * p80211knetdev_do_ioctl | |
536 | * | |
537 | * Handle an ioctl call on one of our devices. Everything Linux | |
538 | * ioctl specific is done here. Then we pass the contents of the | |
539 | * ifr->data to the request message handler. | |
540 | * | |
541 | * Arguments: | |
542 | * dev Linux kernel netdevice | |
543 | * ifr Our private ioctl request structure, typed for the | |
544 | * generic struct ifreq so we can use ptr to func | |
545 | * w/o cast. | |
546 | * | |
547 | * Returns: | |
548 | * zero on success, a negative errno on failure. Possible values: | |
549 | * -ENETDOWN Device isn't up. | |
550 | * -EBUSY cmd already in progress | |
551 | * -ETIME p80211 cmd timed out (MSD may have its own timers) | |
552 | * -EFAULT memory fault copying msg from user buffer | |
553 | * -ENOMEM unable to allocate kernel msg buffer | |
554 | * -ENOSYS bad magic, it the cmd really for us? | |
aaad4303 | 555 | * -EintR sleeping on cmd, awakened by signal, cmd cancelled. |
00b3ed16 GKH |
556 | * |
557 | * Call Context: | |
558 | * Process thread (ioctl caller). TODO: SMP support may require | |
559 | * locks. | |
560 | ----------------------------------------------------------------*/ | |
561 | static int p80211knetdev_do_ioctl(netdevice_t *dev, struct ifreq *ifr, int cmd) | |
562 | { | |
b4b3f0da MM |
563 | int result = 0; |
564 | p80211ioctl_req_t *req = (p80211ioctl_req_t *) ifr; | |
565 | wlandevice_t *wlandev = dev->ml_priv; | |
566 | u8 *msgbuf; | |
00b3ed16 | 567 | |
a7cf7bae | 568 | pr_debug("rx'd ioctl, cmd=%d, len=%d\n", cmd, req->len); |
00b3ed16 | 569 | |
cfde7451 RK |
570 | mutex_lock(&wlandev->ioctl_lock); |
571 | ||
00b3ed16 GKH |
572 | #ifdef SIOCETHTOOL |
573 | if (cmd == SIOCETHTOOL) { | |
b4b3f0da MM |
574 | result = |
575 | p80211netdev_ethtool(wlandev, (void __user *)ifr->ifr_data); | |
00b3ed16 GKH |
576 | goto bail; |
577 | } | |
578 | #endif | |
579 | ||
580 | /* Test the magic, assume ifr is good if it's there */ | |
b4b3f0da | 581 | if (req->magic != P80211_IOCTL_MAGIC) { |
00b3ed16 GKH |
582 | result = -ENOSYS; |
583 | goto bail; | |
584 | } | |
585 | ||
b4b3f0da | 586 | if (cmd == P80211_IFTEST) { |
00b3ed16 GKH |
587 | result = 0; |
588 | goto bail; | |
b4b3f0da | 589 | } else if (cmd != P80211_IFREQ) { |
00b3ed16 GKH |
590 | result = -ENOSYS; |
591 | goto bail; | |
592 | } | |
593 | ||
594 | /* Allocate a buf of size req->len */ | |
b4b3f0da MM |
595 | if ((msgbuf = kmalloc(req->len, GFP_KERNEL))) { |
596 | if (copy_from_user(msgbuf, (void __user *)req->data, req->len)) | |
00b3ed16 | 597 | result = -EFAULT; |
b4b3f0da MM |
598 | else |
599 | result = p80211req_dorequest(wlandev, msgbuf); | |
00b3ed16 | 600 | |
b4b3f0da MM |
601 | if (result == 0) { |
602 | if (copy_to_user | |
603 | ((void __user *)req->data, msgbuf, req->len)) { | |
00b3ed16 GKH |
604 | result = -EFAULT; |
605 | } | |
606 | } | |
607 | kfree(msgbuf); | |
608 | } else { | |
609 | result = -ENOMEM; | |
610 | } | |
611 | bail: | |
cfde7451 RK |
612 | mutex_unlock(&wlandev->ioctl_lock); |
613 | ||
b4b3f0da | 614 | return result; /* If allocate,copyfrom or copyto fails, return errno */ |
00b3ed16 GKH |
615 | } |
616 | ||
617 | /*---------------------------------------------------------------- | |
618 | * p80211knetdev_set_mac_address | |
619 | * | |
620 | * Handles the ioctl for changing the MACAddress of a netdevice | |
621 | * | |
622 | * references: linux/netdevice.h and drivers/net/net_init.c | |
623 | * | |
624 | * NOTE: [MSM] We only prevent address changes when the netdev is | |
625 | * up. We don't control anything based on dot11 state. If the | |
626 | * address is changed on a STA that's currently associated, you | |
627 | * will probably lose the ability to send and receive data frames. | |
628 | * Just be aware. Therefore, this should usually only be done | |
629 | * prior to scan/join/auth/assoc. | |
630 | * | |
631 | * Arguments: | |
632 | * dev netdevice struct | |
633 | * addr the new MACAddress (a struct) | |
634 | * | |
635 | * Returns: | |
636 | * zero on success, a negative errno on failure. Possible values: | |
637 | * -EBUSY device is bussy (cmd not possible) | |
638 | * -and errors returned by: p80211req_dorequest(..) | |
639 | * | |
640 | * by: Collin R. Mulliner <collin@mulliner.org> | |
641 | ----------------------------------------------------------------*/ | |
642 | static int p80211knetdev_set_mac_address(netdevice_t *dev, void *addr) | |
643 | { | |
b4b3f0da MM |
644 | struct sockaddr *new_addr = addr; |
645 | p80211msg_dot11req_mibset_t dot11req; | |
646 | p80211item_unk392_t *mibattr; | |
647 | p80211item_pstr6_t *macaddr; | |
648 | p80211item_uint32_t *resultcode; | |
00b3ed16 GKH |
649 | int result = 0; |
650 | ||
00b3ed16 | 651 | /* If we're running, we don't allow MAC address changes */ |
b4b3f0da | 652 | if (netif_running(dev)) |
00b3ed16 | 653 | return -EBUSY; |
00b3ed16 GKH |
654 | |
655 | /* Set up some convenience pointers. */ | |
656 | mibattr = &dot11req.mibattribute; | |
b4b3f0da | 657 | macaddr = (p80211item_pstr6_t *)&mibattr->data; |
00b3ed16 GKH |
658 | resultcode = &dot11req.resultcode; |
659 | ||
660 | /* Set up a dot11req_mibset */ | |
661 | memset(&dot11req, 0, sizeof(p80211msg_dot11req_mibset_t)); | |
662 | dot11req.msgcode = DIDmsg_dot11req_mibset; | |
663 | dot11req.msglen = sizeof(p80211msg_dot11req_mibset_t); | |
664 | memcpy(dot11req.devname, | |
b4b3f0da | 665 | ((wlandevice_t *) dev->ml_priv)->name, WLAN_DEVNAMELEN_MAX - 1); |
00b3ed16 GKH |
666 | |
667 | /* Set up the mibattribute argument */ | |
668 | mibattr->did = DIDmsg_dot11req_mibset_mibattribute; | |
669 | mibattr->status = P80211ENUM_msgitem_status_data_ok; | |
670 | mibattr->len = sizeof(mibattr->data); | |
671 | ||
672 | macaddr->did = DIDmib_dot11mac_dot11OperationTable_dot11MACAddress; | |
673 | macaddr->status = P80211ENUM_msgitem_status_data_ok; | |
674 | macaddr->len = sizeof(macaddr->data); | |
28b17a4b MM |
675 | macaddr->data.len = ETH_ALEN; |
676 | memcpy(&macaddr->data.data, new_addr->sa_data, ETH_ALEN); | |
00b3ed16 GKH |
677 | |
678 | /* Set up the resultcode argument */ | |
679 | resultcode->did = DIDmsg_dot11req_mibset_resultcode; | |
680 | resultcode->status = P80211ENUM_msgitem_status_no_value; | |
681 | resultcode->len = sizeof(resultcode->data); | |
682 | resultcode->data = 0; | |
683 | ||
684 | /* now fire the request */ | |
aaad4303 | 685 | result = p80211req_dorequest(dev->ml_priv, (u8 *)&dot11req); |
00b3ed16 GKH |
686 | |
687 | /* If the request wasn't successful, report an error and don't | |
688 | * change the netdev address | |
689 | */ | |
b4b3f0da | 690 | if (result != 0 || resultcode->data != P80211ENUM_resultcode_success) { |
edbd606c | 691 | printk(KERN_ERR |
b4b3f0da | 692 | "Low-level driver failed dot11req_mibset(dot11MACAddress).\n"); |
00b3ed16 GKH |
693 | result = -EADDRNOTAVAIL; |
694 | } else { | |
695 | /* everything's ok, change the addr in netdev */ | |
696 | memcpy(dev->dev_addr, new_addr->sa_data, dev->addr_len); | |
697 | } | |
698 | ||
00b3ed16 GKH |
699 | return result; |
700 | } | |
701 | ||
702 | static int wlan_change_mtu(netdevice_t *dev, int new_mtu) | |
703 | { | |
b4b3f0da MM |
704 | /* 2312 is max 802.11 payload, 20 is overhead, (ether + llc +snap) |
705 | and another 8 for wep. */ | |
706 | if ((new_mtu < 68) || (new_mtu > (2312 - 20 - 8))) | |
707 | return -EINVAL; | |
00b3ed16 | 708 | |
b4b3f0da | 709 | dev->mtu = new_mtu; |
00b3ed16 | 710 | |
b4b3f0da | 711 | return 0; |
00b3ed16 GKH |
712 | } |
713 | ||
cea96778 AB |
714 | static const struct net_device_ops p80211_netdev_ops = { |
715 | .ndo_init = p80211knetdev_init, | |
716 | .ndo_open = p80211knetdev_open, | |
717 | .ndo_stop = p80211knetdev_stop, | |
718 | .ndo_get_stats = p80211knetdev_get_stats, | |
719 | .ndo_start_xmit = p80211knetdev_hard_start_xmit, | |
720 | .ndo_set_multicast_list = p80211knetdev_set_multicast_list, | |
721 | .ndo_do_ioctl = p80211knetdev_do_ioctl, | |
722 | .ndo_set_mac_address = p80211knetdev_set_mac_address, | |
723 | .ndo_tx_timeout = p80211knetdev_tx_timeout, | |
724 | .ndo_change_mtu = wlan_change_mtu, | |
725 | .ndo_validate_addr = eth_validate_addr, | |
726 | }; | |
727 | ||
00b3ed16 GKH |
728 | /*---------------------------------------------------------------- |
729 | * wlan_setup | |
730 | * | |
731 | * Roughly matches the functionality of ether_setup. Here | |
732 | * we set up any members of the wlandevice structure that are common | |
733 | * to all devices. Additionally, we allocate a linux 'struct device' | |
734 | * and perform the same setup as ether_setup. | |
735 | * | |
736 | * Note: It's important that the caller have setup the wlandev->name | |
737 | * ptr prior to calling this function. | |
738 | * | |
739 | * Arguments: | |
740 | * wlandev ptr to the wlandev structure for the | |
741 | * interface. | |
742 | * Returns: | |
743 | * zero on success, non-zero otherwise. | |
744 | * Call Context: | |
745 | * Should be process thread. We'll assume it might be | |
746 | * interrupt though. When we add support for statically | |
747 | * compiled drivers, this function will be called in the | |
748 | * context of the kernel startup code. | |
749 | ----------------------------------------------------------------*/ | |
750 | int wlan_setup(wlandevice_t *wlandev) | |
751 | { | |
b4b3f0da MM |
752 | int result = 0; |
753 | netdevice_t *dev; | |
00b3ed16 | 754 | |
00b3ed16 GKH |
755 | /* Set up the wlandev */ |
756 | wlandev->state = WLAN_DEVICE_CLOSED; | |
757 | wlandev->ethconv = WLAN_ETHCONV_8021h; | |
758 | wlandev->macmode = WLAN_MACMODE_NONE; | |
759 | ||
760 | /* Set up the rx queue */ | |
761 | skb_queue_head_init(&wlandev->nsd_rxq); | |
762 | tasklet_init(&wlandev->rx_bh, | |
b4b3f0da | 763 | p80211netdev_rx_bh, (unsigned long)wlandev); |
00b3ed16 GKH |
764 | |
765 | /* Allocate and initialize the struct device */ | |
b4b3f0da MM |
766 | dev = alloc_netdev(0, "wlan%d", ether_setup); |
767 | if (dev == NULL) { | |
edbd606c | 768 | printk(KERN_ERR "Failed to alloc netdev.\n"); |
00b3ed16 GKH |
769 | result = 1; |
770 | } else { | |
00b3ed16 | 771 | wlandev->netdev = dev; |
979123d5 | 772 | dev->ml_priv = wlandev; |
cea96778 | 773 | dev->netdev_ops = &p80211_netdev_ops; |
00b3ed16 | 774 | |
cfde7451 RK |
775 | mutex_init(&wlandev->ioctl_lock); |
776 | /* block ioctls until fully initialised. Don't forget to call | |
777 | allow_ioctls at some point!*/ | |
778 | mutex_lock(&wlandev->ioctl_lock); | |
779 | ||
8a1396ef | 780 | #if (WIRELESS_EXT < 21) |
00b3ed16 GKH |
781 | dev->get_wireless_stats = p80211wext_get_wireless_stats; |
782 | #endif | |
00b3ed16 | 783 | dev->wireless_handlers = &p80211wext_handler_def; |
00b3ed16 | 784 | |
00b3ed16 | 785 | netif_stop_queue(dev); |
00b3ed16 GKH |
786 | netif_carrier_off(dev); |
787 | } | |
788 | ||
00b3ed16 GKH |
789 | return result; |
790 | } | |
791 | ||
792 | /*---------------------------------------------------------------- | |
793 | * wlan_unsetup | |
794 | * | |
795 | * This function is paired with the wlan_setup routine. It should | |
796 | * be called after unregister_wlandev. Basically, all it does is | |
797 | * free the 'struct device' that's associated with the wlandev. | |
798 | * We do it here because the 'struct device' isn't allocated | |
799 | * explicitly in the driver code, it's done in wlan_setup. To | |
800 | * do the free in the driver might seem like 'magic'. | |
801 | * | |
802 | * Arguments: | |
803 | * wlandev ptr to the wlandev structure for the | |
804 | * interface. | |
805 | * Returns: | |
806 | * zero on success, non-zero otherwise. | |
807 | * Call Context: | |
808 | * Should be process thread. We'll assume it might be | |
809 | * interrupt though. When we add support for statically | |
810 | * compiled drivers, this function will be called in the | |
811 | * context of the kernel startup code. | |
812 | ----------------------------------------------------------------*/ | |
813 | int wlan_unsetup(wlandevice_t *wlandev) | |
814 | { | |
b4b3f0da | 815 | int result = 0; |
00b3ed16 | 816 | |
00b3ed16 GKH |
817 | tasklet_kill(&wlandev->rx_bh); |
818 | ||
b4b3f0da | 819 | if (wlandev->netdev == NULL) { |
edbd606c | 820 | printk(KERN_ERR "called without wlandev->netdev set.\n"); |
00b3ed16 GKH |
821 | result = 1; |
822 | } else { | |
823 | free_netdev(wlandev->netdev); | |
824 | wlandev->netdev = NULL; | |
825 | } | |
826 | ||
00b3ed16 GKH |
827 | return 0; |
828 | } | |
829 | ||
00b3ed16 GKH |
830 | /*---------------------------------------------------------------- |
831 | * register_wlandev | |
832 | * | |
833 | * Roughly matches the functionality of register_netdev. This function | |
834 | * is called after the driver has successfully probed and set up the | |
835 | * resources for the device. It's now ready to become a named device | |
836 | * in the Linux system. | |
837 | * | |
838 | * First we allocate a name for the device (if not already set), then | |
839 | * we call the Linux function register_netdevice. | |
840 | * | |
841 | * Arguments: | |
842 | * wlandev ptr to the wlandev structure for the | |
843 | * interface. | |
844 | * Returns: | |
845 | * zero on success, non-zero otherwise. | |
846 | * Call Context: | |
847 | * Can be either interrupt or not. | |
848 | ----------------------------------------------------------------*/ | |
849 | int register_wlandev(wlandevice_t *wlandev) | |
850 | { | |
b4b3f0da | 851 | int i = 0; |
00b3ed16 | 852 | |
ee313528 RK |
853 | i = register_netdev(wlandev->netdev); |
854 | if (i) | |
855 | return i; | |
00b3ed16 | 856 | |
00b3ed16 GKH |
857 | return 0; |
858 | } | |
859 | ||
00b3ed16 GKH |
860 | /*---------------------------------------------------------------- |
861 | * unregister_wlandev | |
862 | * | |
863 | * Roughly matches the functionality of unregister_netdev. This | |
864 | * function is called to remove a named device from the system. | |
865 | * | |
866 | * First we tell linux that the device should no longer exist. | |
867 | * Then we remove it from the list of known wlan devices. | |
868 | * | |
869 | * Arguments: | |
870 | * wlandev ptr to the wlandev structure for the | |
871 | * interface. | |
872 | * Returns: | |
873 | * zero on success, non-zero otherwise. | |
874 | * Call Context: | |
875 | * Can be either interrupt or not. | |
876 | ----------------------------------------------------------------*/ | |
877 | int unregister_wlandev(wlandevice_t *wlandev) | |
878 | { | |
879 | struct sk_buff *skb; | |
880 | ||
00b3ed16 GKH |
881 | unregister_netdev(wlandev->netdev); |
882 | ||
883 | /* Now to clean out the rx queue */ | |
b4b3f0da | 884 | while ((skb = skb_dequeue(&wlandev->nsd_rxq))) |
00b3ed16 | 885 | dev_kfree_skb(skb); |
00b3ed16 | 886 | |
00b3ed16 GKH |
887 | return 0; |
888 | } | |
889 | ||
00b3ed16 GKH |
890 | /*---------------------------------------------------------------- |
891 | * p80211netdev_hwremoved | |
892 | * | |
893 | * Hardware removed notification. This function should be called | |
894 | * immediately after an MSD has detected that the underlying hardware | |
895 | * has been yanked out from under us. The primary things we need | |
896 | * to do are: | |
897 | * - Mark the wlandev | |
898 | * - Prevent any further traffic from the knetdev i/f | |
899 | * - Prevent any further requests from mgmt i/f | |
900 | * - If there are any waitq'd mgmt requests or mgmt-frame exchanges, | |
901 | * shut them down. | |
902 | * - Call the MSD hwremoved function. | |
903 | * | |
904 | * The remainder of the cleanup will be handled by unregister(). | |
905 | * Our primary goal here is to prevent as much tickling of the MSD | |
906 | * as possible since the MSD is already in a 'wounded' state. | |
907 | * | |
908 | * TODO: As new features are added, this function should be | |
909 | * updated. | |
910 | * | |
911 | * Arguments: | |
912 | * wlandev WLAN network device structure | |
913 | * Returns: | |
914 | * nothing | |
915 | * Side effects: | |
916 | * | |
917 | * Call context: | |
918 | * Usually interrupt. | |
919 | ----------------------------------------------------------------*/ | |
920 | void p80211netdev_hwremoved(wlandevice_t *wlandev) | |
921 | { | |
00b3ed16 | 922 | wlandev->hwremoved = 1; |
b4b3f0da | 923 | if (wlandev->state == WLAN_DEVICE_OPEN) |
cbec30c4 | 924 | netif_stop_queue(wlandev->netdev); |
00b3ed16 GKH |
925 | |
926 | netif_device_detach(wlandev->netdev); | |
00b3ed16 GKH |
927 | } |
928 | ||
00b3ed16 GKH |
929 | /*---------------------------------------------------------------- |
930 | * p80211_rx_typedrop | |
931 | * | |
932 | * Classifies the frame, increments the appropriate counter, and | |
933 | * returns 0|1|2 indicating whether the driver should handle, ignore, or | |
934 | * drop the frame | |
935 | * | |
936 | * Arguments: | |
937 | * wlandev wlan device structure | |
938 | * fc frame control field | |
939 | * | |
940 | * Returns: | |
941 | * zero if the frame should be handled by the driver, | |
942 | * one if the frame should be ignored | |
943 | * anything else means we drop it. | |
944 | * | |
945 | * Side effects: | |
946 | * | |
947 | * Call context: | |
948 | * interrupt | |
949 | ----------------------------------------------------------------*/ | |
b4b3f0da | 950 | static int p80211_rx_typedrop(wlandevice_t *wlandev, u16 fc) |
00b3ed16 | 951 | { |
b4b3f0da MM |
952 | u16 ftype; |
953 | u16 fstype; | |
954 | int drop = 0; | |
00b3ed16 GKH |
955 | /* Classify frame, increment counter */ |
956 | ftype = WLAN_GET_FC_FTYPE(fc); | |
957 | fstype = WLAN_GET_FC_FSTYPE(fc); | |
958 | #if 0 | |
b4b3f0da | 959 | pr_debug("rx_typedrop : ftype=%d fstype=%d.\n", ftype, fstype); |
00b3ed16 | 960 | #endif |
b4b3f0da | 961 | switch (ftype) { |
00b3ed16 GKH |
962 | case WLAN_FTYPE_MGMT: |
963 | if ((wlandev->netdev->flags & IFF_PROMISC) || | |
b4b3f0da | 964 | (wlandev->netdev->flags & IFF_ALLMULTI)) { |
00b3ed16 GKH |
965 | drop = 1; |
966 | break; | |
967 | } | |
a7cf7bae | 968 | pr_debug("rx'd mgmt:\n"); |
00b3ed16 | 969 | wlandev->rx.mgmt++; |
b4b3f0da | 970 | switch (fstype) { |
00b3ed16 GKH |
971 | case WLAN_FSTYPE_ASSOCREQ: |
972 | /* printk("assocreq"); */ | |
973 | wlandev->rx.assocreq++; | |
974 | break; | |
975 | case WLAN_FSTYPE_ASSOCRESP: | |
976 | /* printk("assocresp"); */ | |
977 | wlandev->rx.assocresp++; | |
978 | break; | |
979 | case WLAN_FSTYPE_REASSOCREQ: | |
980 | /* printk("reassocreq"); */ | |
981 | wlandev->rx.reassocreq++; | |
982 | break; | |
983 | case WLAN_FSTYPE_REASSOCRESP: | |
984 | /* printk("reassocresp"); */ | |
985 | wlandev->rx.reassocresp++; | |
986 | break; | |
987 | case WLAN_FSTYPE_PROBEREQ: | |
988 | /* printk("probereq"); */ | |
989 | wlandev->rx.probereq++; | |
990 | break; | |
991 | case WLAN_FSTYPE_PROBERESP: | |
992 | /* printk("proberesp"); */ | |
993 | wlandev->rx.proberesp++; | |
994 | break; | |
995 | case WLAN_FSTYPE_BEACON: | |
996 | /* printk("beacon"); */ | |
997 | wlandev->rx.beacon++; | |
998 | break; | |
999 | case WLAN_FSTYPE_ATIM: | |
1000 | /* printk("atim"); */ | |
1001 | wlandev->rx.atim++; | |
1002 | break; | |
1003 | case WLAN_FSTYPE_DISASSOC: | |
1004 | /* printk("disassoc"); */ | |
1005 | wlandev->rx.disassoc++; | |
1006 | break; | |
1007 | case WLAN_FSTYPE_AUTHEN: | |
1008 | /* printk("authen"); */ | |
1009 | wlandev->rx.authen++; | |
1010 | break; | |
1011 | case WLAN_FSTYPE_DEAUTHEN: | |
1012 | /* printk("deauthen"); */ | |
1013 | wlandev->rx.deauthen++; | |
1014 | break; | |
1015 | default: | |
1016 | /* printk("unknown"); */ | |
1017 | wlandev->rx.mgmt_unknown++; | |
1018 | break; | |
1019 | } | |
1020 | /* printk("\n"); */ | |
1021 | drop = 2; | |
1022 | break; | |
1023 | ||
1024 | case WLAN_FTYPE_CTL: | |
1025 | if ((wlandev->netdev->flags & IFF_PROMISC) || | |
b4b3f0da | 1026 | (wlandev->netdev->flags & IFF_ALLMULTI)) { |
00b3ed16 GKH |
1027 | drop = 1; |
1028 | break; | |
1029 | } | |
a7cf7bae | 1030 | pr_debug("rx'd ctl:\n"); |
00b3ed16 | 1031 | wlandev->rx.ctl++; |
b4b3f0da | 1032 | switch (fstype) { |
00b3ed16 GKH |
1033 | case WLAN_FSTYPE_PSPOLL: |
1034 | /* printk("pspoll"); */ | |
1035 | wlandev->rx.pspoll++; | |
1036 | break; | |
1037 | case WLAN_FSTYPE_RTS: | |
1038 | /* printk("rts"); */ | |
1039 | wlandev->rx.rts++; | |
1040 | break; | |
1041 | case WLAN_FSTYPE_CTS: | |
1042 | /* printk("cts"); */ | |
1043 | wlandev->rx.cts++; | |
1044 | break; | |
1045 | case WLAN_FSTYPE_ACK: | |
1046 | /* printk("ack"); */ | |
1047 | wlandev->rx.ack++; | |
1048 | break; | |
1049 | case WLAN_FSTYPE_CFEND: | |
1050 | /* printk("cfend"); */ | |
1051 | wlandev->rx.cfend++; | |
1052 | break; | |
1053 | case WLAN_FSTYPE_CFENDCFACK: | |
1054 | /* printk("cfendcfack"); */ | |
1055 | wlandev->rx.cfendcfack++; | |
1056 | break; | |
1057 | default: | |
1058 | /* printk("unknown"); */ | |
1059 | wlandev->rx.ctl_unknown++; | |
1060 | break; | |
1061 | } | |
1062 | /* printk("\n"); */ | |
1063 | drop = 2; | |
1064 | break; | |
1065 | ||
1066 | case WLAN_FTYPE_DATA: | |
1067 | wlandev->rx.data++; | |
b4b3f0da | 1068 | switch (fstype) { |
00b3ed16 GKH |
1069 | case WLAN_FSTYPE_DATAONLY: |
1070 | wlandev->rx.dataonly++; | |
1071 | break; | |
1072 | case WLAN_FSTYPE_DATA_CFACK: | |
1073 | wlandev->rx.data_cfack++; | |
1074 | break; | |
1075 | case WLAN_FSTYPE_DATA_CFPOLL: | |
1076 | wlandev->rx.data_cfpoll++; | |
1077 | break; | |
1078 | case WLAN_FSTYPE_DATA_CFACK_CFPOLL: | |
1079 | wlandev->rx.data__cfack_cfpoll++; | |
1080 | break; | |
1081 | case WLAN_FSTYPE_NULL: | |
a7cf7bae | 1082 | pr_debug("rx'd data:null\n"); |
00b3ed16 GKH |
1083 | wlandev->rx.null++; |
1084 | break; | |
1085 | case WLAN_FSTYPE_CFACK: | |
a7cf7bae | 1086 | pr_debug("rx'd data:cfack\n"); |
00b3ed16 GKH |
1087 | wlandev->rx.cfack++; |
1088 | break; | |
1089 | case WLAN_FSTYPE_CFPOLL: | |
a7cf7bae | 1090 | pr_debug("rx'd data:cfpoll\n"); |
00b3ed16 GKH |
1091 | wlandev->rx.cfpoll++; |
1092 | break; | |
1093 | case WLAN_FSTYPE_CFACK_CFPOLL: | |
a7cf7bae | 1094 | pr_debug("rx'd data:cfack_cfpoll\n"); |
00b3ed16 GKH |
1095 | wlandev->rx.cfack_cfpoll++; |
1096 | break; | |
1097 | default: | |
1098 | /* printk("unknown"); */ | |
1099 | wlandev->rx.data_unknown++; | |
1100 | break; | |
1101 | } | |
1102 | ||
1103 | break; | |
1104 | } | |
1105 | return drop; | |
1106 | } | |
1107 | ||
b4b3f0da | 1108 | static void p80211knetdev_tx_timeout(netdevice_t *netdev) |
00b3ed16 | 1109 | { |
b4b3f0da | 1110 | wlandevice_t *wlandev = netdev->ml_priv; |
00b3ed16 GKH |
1111 | |
1112 | if (wlandev->tx_timeout) { | |
1113 | wlandev->tx_timeout(wlandev); | |
1114 | } else { | |
9b9556ec | 1115 | printk(KERN_WARNING "Implement tx_timeout for %s\n", |
b4b3f0da | 1116 | wlandev->nsdname); |
cbec30c4 | 1117 | netif_wake_queue(wlandev->netdev); |
00b3ed16 | 1118 | } |
00b3ed16 | 1119 | } |
cfde7451 RK |
1120 | |
1121 | void p80211_allow_ioctls(wlandevice_t *wlandev) | |
1122 | { | |
1123 | mutex_unlock(&wlandev->ioctl_lock); | |
1124 | } |