1 /* src/p80211/p80211knetdev.c
3 * Linux Kernel net device interface
5 * Copyright (C) 1999 AbsoluteValue Systems, Inc. All Rights Reserved.
6 * --------------------------------------------------------------------
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/
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.
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.
31 * --------------------------------------------------------------------
33 * Inquiries regarding the linux-wlan Open Source project can be
36 * AbsoluteValue Systems Inc.
38 * http://www.linux-wlan.com
40 * --------------------------------------------------------------------
42 * Portions of the development of this software were funded by
43 * Intersil Corporation as part of PRISM(R) chipset product development.
45 * --------------------------------------------------------------------
47 * The functions required for a Linux network device are defined here.
49 * --------------------------------------------------------------------
52 #include <linux/version.h>
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>
67 #include <linux/if_ether.h>
68 #include <linux/byteorder/generic.h>
69 #include <linux/bitops.h>
70 #include <linux/uaccess.h>
71 #include <asm/byteorder.h>
74 #include <linux/ethtool.h>
77 #include <net/iw_handler.h>
78 #include <net/net_namespace.h>
80 /*================================================================*/
81 /* Project Includes */
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"
94 /* Support functions */
95 static void p80211netdev_rx_bh(unsigned long arg);
97 /* netdevice method functions */
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);
104 static void p80211knetdev_set_multicast_list(netdevice_t *dev);
105 static int p80211knetdev_do_ioctl(netdevice_t *dev, struct ifreq *ifr,
107 static int p80211knetdev_set_mac_address(netdevice_t *dev, void *addr);
108 static void p80211knetdev_tx_timeout(netdevice_t *netdev);
109 static int p80211_rx_typedrop(wlandevice_t *wlandev, u16 fc);
111 int wlan_watchdog = 5000;
112 module_param(wlan_watchdog, int, 0644);
113 MODULE_PARM_DESC(wlan_watchdog, "transmit timeout in milliseconds");
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");
119 /*----------------------------------------------------------------
122 * Init method for a Linux netdevice. Called in response to
130 ----------------------------------------------------------------*/
131 static int p80211knetdev_init(netdevice_t *netdev)
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 */
140 /*----------------------------------------------------------------
141 * p80211knetdev_get_stats
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.
149 * netdev Linux netdevice
152 * the address of the statistics structure
153 ----------------------------------------------------------------*/
154 static struct net_device_stats *p80211knetdev_get_stats(netdevice_t *netdev)
156 wlandevice_t *wlandev = netdev->ml_priv;
158 /* TODO: review the MIB stats for items that correspond to
161 return &(wlandev->linux_stats);
164 /*----------------------------------------------------------------
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
173 * netdev Linux network device structure
176 * zero on success, non-zero otherwise
177 ----------------------------------------------------------------*/
178 static int p80211knetdev_open(netdevice_t *netdev)
180 int result = 0; /* success */
181 wlandevice_t *wlandev = netdev->ml_priv;
183 /* Check to make sure the MSD is running */
184 if (wlandev->msdstate != WLAN_MSD_RUNNING)
187 /* Tell the MSD to open */
188 if (wlandev->open != NULL) {
189 result = wlandev->open(wlandev);
191 netif_start_queue(wlandev->netdev);
192 wlandev->state = WLAN_DEVICE_OPEN;
201 /*----------------------------------------------------------------
204 * Linux netdevice stop (close) method. Following this call,
205 * no frames should go up or down through this interface.
208 * netdev Linux network device structure
211 * zero on success, non-zero otherwise
212 ----------------------------------------------------------------*/
213 static int p80211knetdev_stop(netdevice_t *netdev)
216 wlandevice_t *wlandev = netdev->ml_priv;
218 if (wlandev->close != NULL)
219 result = wlandev->close(wlandev);
221 netif_stop_queue(wlandev->netdev);
222 wlandev->state = WLAN_DEVICE_CLOSED;
227 /*----------------------------------------------------------------
230 * Frame receive function called by the mac specific driver.
233 * wlandev WLAN network device structure
234 * skb skbuff containing a full 802.11 frame.
239 ----------------------------------------------------------------*/
240 void p80211netdev_rx(wlandevice_t *wlandev, struct sk_buff *skb)
242 /* Enqueue for post-irq processing */
243 skb_queue_tail(&wlandev->nsd_rxq, skb);
245 tasklet_schedule(&wlandev->rx_bh);
250 /*----------------------------------------------------------------
253 * Deferred processing of all received frames.
256 * wlandev WLAN network device structure
257 * skb skbuff containing a full 802.11 frame.
262 ----------------------------------------------------------------*/
263 static void p80211netdev_rx_bh(unsigned long arg)
265 wlandevice_t *wlandev = (wlandevice_t *) arg;
266 struct sk_buff *skb = NULL;
267 netdevice_t *dev = wlandev->netdev;
268 p80211_hdr_a3_t *hdr;
271 /* Let's empty our our queue */
272 while ((skb = skb_dequeue(&wlandev->nsd_rxq))) {
273 if (wlandev->state == WLAN_DEVICE_OPEN) {
275 if (dev->type != ARPHRD_ETHER) {
276 /* RAW frame; we shouldn't convert it */
277 /* XXX Append the Prism Header here instead. */
279 /* set up various data fields */
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;
287 wlandev->linux_stats.rx_packets++;
288 wlandev->linux_stats.rx_bytes += skb->len;
292 hdr = (p80211_hdr_a3_t *) skb->data;
293 fc = le16_to_cpu(hdr->fc);
294 if (p80211_rx_typedrop(wlandev, fc)) {
299 /* perform mcast filtering */
300 if (wlandev->netdev->flags & IFF_ALLMULTI) {
301 /* allow my local address through */
303 (hdr->a1, wlandev->netdev->dev_addr,
305 /* but reject anything else that isn't multicast */
306 if (!(hdr->a1[0] & 0x01)) {
313 if (skb_p80211_to_ether
314 (wlandev, wlandev->ethconv, skb) == 0) {
315 skb->dev->last_rx = jiffies;
316 wlandev->linux_stats.rx_packets++;
317 wlandev->linux_stats.rx_bytes +=
322 pr_debug("p80211_to_ether failed.\n");
329 /*----------------------------------------------------------------
330 * p80211knetdev_hard_start_xmit
332 * Linux netdevice method for transmitting a frame.
335 * skb Linux sk_buff containing the frame.
336 * netdev Linux netdevice.
339 * If the lower layers report that buffers are full. netdev->tbusy
340 * will be set to prevent higher layers from sending more traffic.
342 * Note: If this function returns non-zero, higher layers retain
343 * ownership of the skb.
346 * zero on success, non-zero on failure.
347 ----------------------------------------------------------------*/
348 static int p80211knetdev_hard_start_xmit(struct sk_buff *skb,
353 wlandevice_t *wlandev = netdev->ml_priv;
354 p80211_hdr_t p80211_hdr;
355 p80211_metawep_t p80211_wep;
360 if (wlandev->state != WLAN_DEVICE_OPEN) {
365 memset(&p80211_hdr, 0, sizeof(p80211_hdr_t));
366 memset(&p80211_wep, 0, sizeof(p80211_metawep_t));
368 if (netif_queue_stopped(netdev)) {
369 pr_debug("called when queue stopped.\n");
374 netif_stop_queue(netdev);
376 /* Check to see that a valid mode is set */
377 switch (wlandev->macmode) {
378 case WLAN_MACMODE_IBSS_STA:
379 case WLAN_MACMODE_ESS_STA:
380 case WLAN_MACMODE_ESS_AP:
383 /* Mode isn't set yet, just drop the frame
384 * and return success .
385 * TODO: we need a saner way to handle this
387 if (skb->protocol != ETH_P_80211_RAW) {
388 netif_start_queue(wlandev->netdev);
390 "Tx attempt prior to association, frame dropped.\n");
391 wlandev->linux_stats.tx_dropped++;
398 /* Check for raw transmits */
399 if (skb->protocol == ETH_P_80211_RAW) {
400 if (!capable(CAP_NET_ADMIN)) {
404 /* move the header over */
405 memcpy(&p80211_hdr, skb->data, sizeof(p80211_hdr_t));
406 skb_pull(skb, sizeof(p80211_hdr_t));
408 if (skb_ether_to_p80211
409 (wlandev, wlandev->ethconv, skb, &p80211_hdr,
412 pr_debug("ether_to_80211(%d) failed.\n",
418 if (wlandev->txframe == NULL) {
423 netdev->trans_start = jiffies;
425 wlandev->linux_stats.tx_packets++;
426 /* count only the packet payload */
427 wlandev->linux_stats.tx_bytes += skb->len;
429 txresult = wlandev->txframe(wlandev, skb, &p80211_hdr, &p80211_wep);
432 /* success and more buf */
433 /* avail, re: hw_txdata */
434 netif_wake_queue(wlandev->netdev);
436 } else if (txresult == 1) {
437 /* success, no more avail */
438 pr_debug("txframe success, no more bufs\n");
439 /* netdev->tbusy = 1; don't set here, irqhdlr */
440 /* may have already cleared it */
442 } else if (txresult == 2) {
443 /* alloc failure, drop frame */
444 pr_debug("txframe returned alloc_fail\n");
447 /* buffer full or queue busy, drop frame. */
448 pr_debug("txframe returned full or busy\n");
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);
457 /* we always free the skb here, never in a lower level. */
464 /*----------------------------------------------------------------
465 * p80211knetdev_set_multicast_list
467 * Called from higher lavers whenever there's a need to set/clear
468 * promiscuous mode or rewrite the multicast list.
475 ----------------------------------------------------------------*/
476 static void p80211knetdev_set_multicast_list(netdevice_t *dev)
478 wlandevice_t *wlandev = dev->ml_priv;
480 /* TODO: real multicast support as well */
482 if (wlandev->set_multicast_list)
483 wlandev->set_multicast_list(wlandev, dev);
489 static int p80211netdev_ethtool(wlandevice_t *wlandev, void __user *useraddr)
492 struct ethtool_drvinfo info;
493 struct ethtool_value edata;
495 memset(&info, 0, sizeof(info));
496 memset(&edata, 0, sizeof(edata));
498 if (copy_from_user(ðcmd, useraddr, sizeof(ethcmd)))
502 case ETHTOOL_GDRVINFO:
504 snprintf(info.driver, sizeof(info.driver), "p80211_%s",
506 snprintf(info.version, sizeof(info.version), "%s",
509 if (copy_to_user(useraddr, &info, sizeof(info)))
516 if (wlandev->linkstatus &&
517 (wlandev->macmode != WLAN_MACMODE_NONE)) {
523 if (copy_to_user(useraddr, &edata, sizeof(edata)))
534 /*----------------------------------------------------------------
535 * p80211knetdev_do_ioctl
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.
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
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?
555 * -EintR sleeping on cmd, awakened by signal, cmd cancelled.
558 * Process thread (ioctl caller). TODO: SMP support may require
560 ----------------------------------------------------------------*/
561 static int p80211knetdev_do_ioctl(netdevice_t *dev, struct ifreq *ifr, int cmd)
564 p80211ioctl_req_t *req = (p80211ioctl_req_t *) ifr;
565 wlandevice_t *wlandev = dev->ml_priv;
568 pr_debug("rx'd ioctl, cmd=%d, len=%d\n", cmd, req->len);
570 mutex_lock(&wlandev->ioctl_lock);
573 if (cmd == SIOCETHTOOL) {
575 p80211netdev_ethtool(wlandev, (void __user *)ifr->ifr_data);
580 /* Test the magic, assume ifr is good if it's there */
581 if (req->magic != P80211_IOCTL_MAGIC) {
586 if (cmd == P80211_IFTEST) {
589 } else if (cmd != P80211_IFREQ) {
594 /* Allocate a buf of size req->len */
595 if ((msgbuf = kmalloc(req->len, GFP_KERNEL))) {
596 if (copy_from_user(msgbuf, (void __user *)req->data, req->len))
599 result = p80211req_dorequest(wlandev, msgbuf);
603 ((void __user *)req->data, msgbuf, req->len)) {
612 mutex_unlock(&wlandev->ioctl_lock);
614 return result; /* If allocate,copyfrom or copyto fails, return errno */
617 /*----------------------------------------------------------------
618 * p80211knetdev_set_mac_address
620 * Handles the ioctl for changing the MACAddress of a netdevice
622 * references: linux/netdevice.h and drivers/net/net_init.c
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.
632 * dev netdevice struct
633 * addr the new MACAddress (a struct)
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(..)
640 * by: Collin R. Mulliner <collin@mulliner.org>
641 ----------------------------------------------------------------*/
642 static int p80211knetdev_set_mac_address(netdevice_t *dev, void *addr)
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;
651 /* If we're running, we don't allow MAC address changes */
652 if (netif_running(dev))
655 /* Set up some convenience pointers. */
656 mibattr = &dot11req.mibattribute;
657 macaddr = (p80211item_pstr6_t *)&mibattr->data;
658 resultcode = &dot11req.resultcode;
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,
665 ((wlandevice_t *) dev->ml_priv)->name, WLAN_DEVNAMELEN_MAX - 1);
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);
672 macaddr->did = DIDmib_dot11mac_dot11OperationTable_dot11MACAddress;
673 macaddr->status = P80211ENUM_msgitem_status_data_ok;
674 macaddr->len = sizeof(macaddr->data);
675 macaddr->data.len = ETH_ALEN;
676 memcpy(&macaddr->data.data, new_addr->sa_data, ETH_ALEN);
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;
684 /* now fire the request */
685 result = p80211req_dorequest(dev->ml_priv, (u8 *)&dot11req);
687 /* If the request wasn't successful, report an error and don't
688 * change the netdev address
690 if (result != 0 || resultcode->data != P80211ENUM_resultcode_success) {
692 "Low-level driver failed dot11req_mibset(dot11MACAddress).\n");
693 result = -EADDRNOTAVAIL;
695 /* everything's ok, change the addr in netdev */
696 memcpy(dev->dev_addr, new_addr->sa_data, dev->addr_len);
702 static int wlan_change_mtu(netdevice_t *dev, int new_mtu)
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)))
714 /*----------------------------------------------------------------
717 * Roughly matches the functionality of ether_setup. Here
718 * we set up any members of the wlandevice structure that are common
719 * to all devices. Additionally, we allocate a linux 'struct device'
720 * and perform the same setup as ether_setup.
722 * Note: It's important that the caller have setup the wlandev->name
723 * ptr prior to calling this function.
726 * wlandev ptr to the wlandev structure for the
729 * zero on success, non-zero otherwise.
731 * Should be process thread. We'll assume it might be
732 * interrupt though. When we add support for statically
733 * compiled drivers, this function will be called in the
734 * context of the kernel startup code.
735 ----------------------------------------------------------------*/
736 int wlan_setup(wlandevice_t *wlandev)
741 /* Set up the wlandev */
742 wlandev->state = WLAN_DEVICE_CLOSED;
743 wlandev->ethconv = WLAN_ETHCONV_8021h;
744 wlandev->macmode = WLAN_MACMODE_NONE;
746 /* Set up the rx queue */
747 skb_queue_head_init(&wlandev->nsd_rxq);
748 tasklet_init(&wlandev->rx_bh,
749 p80211netdev_rx_bh, (unsigned long)wlandev);
751 /* Allocate and initialize the struct device */
752 dev = alloc_netdev(0, "wlan%d", ether_setup);
754 printk(KERN_ERR "Failed to alloc netdev.\n");
757 wlandev->netdev = dev;
758 dev->ml_priv = wlandev;
759 dev->hard_start_xmit = p80211knetdev_hard_start_xmit;
760 dev->get_stats = p80211knetdev_get_stats;
761 dev->init = p80211knetdev_init;
762 dev->open = p80211knetdev_open;
763 dev->stop = p80211knetdev_stop;
765 mutex_init(&wlandev->ioctl_lock);
766 /* block ioctls until fully initialised. Don't forget to call
767 allow_ioctls at some point!*/
768 mutex_lock(&wlandev->ioctl_lock);
770 #if (WIRELESS_EXT < 21)
771 dev->get_wireless_stats = p80211wext_get_wireless_stats;
773 dev->wireless_handlers = &p80211wext_handler_def;
775 netif_stop_queue(dev);
776 netif_carrier_off(dev);
782 /*----------------------------------------------------------------
785 * This function is paired with the wlan_setup routine. It should
786 * be called after unregister_wlandev. Basically, all it does is
787 * free the 'struct device' that's associated with the wlandev.
788 * We do it here because the 'struct device' isn't allocated
789 * explicitly in the driver code, it's done in wlan_setup. To
790 * do the free in the driver might seem like 'magic'.
793 * wlandev ptr to the wlandev structure for the
796 * zero on success, non-zero otherwise.
798 * Should be process thread. We'll assume it might be
799 * interrupt though. When we add support for statically
800 * compiled drivers, this function will be called in the
801 * context of the kernel startup code.
802 ----------------------------------------------------------------*/
803 int wlan_unsetup(wlandevice_t *wlandev)
807 tasklet_kill(&wlandev->rx_bh);
809 if (wlandev->netdev == NULL) {
810 printk(KERN_ERR "called without wlandev->netdev set.\n");
813 free_netdev(wlandev->netdev);
814 wlandev->netdev = NULL;
820 /*----------------------------------------------------------------
823 * Roughly matches the functionality of register_netdev. This function
824 * is called after the driver has successfully probed and set up the
825 * resources for the device. It's now ready to become a named device
826 * in the Linux system.
828 * First we allocate a name for the device (if not already set), then
829 * we call the Linux function register_netdevice.
832 * wlandev ptr to the wlandev structure for the
835 * zero on success, non-zero otherwise.
837 * Can be either interrupt or not.
838 ----------------------------------------------------------------*/
839 int register_wlandev(wlandevice_t *wlandev)
843 i = register_netdev(wlandev->netdev);
850 /*----------------------------------------------------------------
853 * Roughly matches the functionality of unregister_netdev. This
854 * function is called to remove a named device from the system.
856 * First we tell linux that the device should no longer exist.
857 * Then we remove it from the list of known wlan devices.
860 * wlandev ptr to the wlandev structure for the
863 * zero on success, non-zero otherwise.
865 * Can be either interrupt or not.
866 ----------------------------------------------------------------*/
867 int unregister_wlandev(wlandevice_t *wlandev)
871 unregister_netdev(wlandev->netdev);
873 /* Now to clean out the rx queue */
874 while ((skb = skb_dequeue(&wlandev->nsd_rxq)))
880 /*----------------------------------------------------------------
881 * p80211netdev_hwremoved
883 * Hardware removed notification. This function should be called
884 * immediately after an MSD has detected that the underlying hardware
885 * has been yanked out from under us. The primary things we need
888 * - Prevent any further traffic from the knetdev i/f
889 * - Prevent any further requests from mgmt i/f
890 * - If there are any waitq'd mgmt requests or mgmt-frame exchanges,
892 * - Call the MSD hwremoved function.
894 * The remainder of the cleanup will be handled by unregister().
895 * Our primary goal here is to prevent as much tickling of the MSD
896 * as possible since the MSD is already in a 'wounded' state.
898 * TODO: As new features are added, this function should be
902 * wlandev WLAN network device structure
909 ----------------------------------------------------------------*/
910 void p80211netdev_hwremoved(wlandevice_t *wlandev)
912 wlandev->hwremoved = 1;
913 if (wlandev->state == WLAN_DEVICE_OPEN)
914 netif_stop_queue(wlandev->netdev);
916 netif_device_detach(wlandev->netdev);
919 /*----------------------------------------------------------------
922 * Classifies the frame, increments the appropriate counter, and
923 * returns 0|1|2 indicating whether the driver should handle, ignore, or
927 * wlandev wlan device structure
928 * fc frame control field
931 * zero if the frame should be handled by the driver,
932 * one if the frame should be ignored
933 * anything else means we drop it.
939 ----------------------------------------------------------------*/
940 static int p80211_rx_typedrop(wlandevice_t *wlandev, u16 fc)
945 /* Classify frame, increment counter */
946 ftype = WLAN_GET_FC_FTYPE(fc);
947 fstype = WLAN_GET_FC_FSTYPE(fc);
949 pr_debug("rx_typedrop : ftype=%d fstype=%d.\n", ftype, fstype);
952 case WLAN_FTYPE_MGMT:
953 if ((wlandev->netdev->flags & IFF_PROMISC) ||
954 (wlandev->netdev->flags & IFF_ALLMULTI)) {
958 pr_debug("rx'd mgmt:\n");
961 case WLAN_FSTYPE_ASSOCREQ:
962 /* printk("assocreq"); */
963 wlandev->rx.assocreq++;
965 case WLAN_FSTYPE_ASSOCRESP:
966 /* printk("assocresp"); */
967 wlandev->rx.assocresp++;
969 case WLAN_FSTYPE_REASSOCREQ:
970 /* printk("reassocreq"); */
971 wlandev->rx.reassocreq++;
973 case WLAN_FSTYPE_REASSOCRESP:
974 /* printk("reassocresp"); */
975 wlandev->rx.reassocresp++;
977 case WLAN_FSTYPE_PROBEREQ:
978 /* printk("probereq"); */
979 wlandev->rx.probereq++;
981 case WLAN_FSTYPE_PROBERESP:
982 /* printk("proberesp"); */
983 wlandev->rx.proberesp++;
985 case WLAN_FSTYPE_BEACON:
986 /* printk("beacon"); */
987 wlandev->rx.beacon++;
989 case WLAN_FSTYPE_ATIM:
990 /* printk("atim"); */
993 case WLAN_FSTYPE_DISASSOC:
994 /* printk("disassoc"); */
995 wlandev->rx.disassoc++;
997 case WLAN_FSTYPE_AUTHEN:
998 /* printk("authen"); */
999 wlandev->rx.authen++;
1001 case WLAN_FSTYPE_DEAUTHEN:
1002 /* printk("deauthen"); */
1003 wlandev->rx.deauthen++;
1006 /* printk("unknown"); */
1007 wlandev->rx.mgmt_unknown++;
1014 case WLAN_FTYPE_CTL:
1015 if ((wlandev->netdev->flags & IFF_PROMISC) ||
1016 (wlandev->netdev->flags & IFF_ALLMULTI)) {
1020 pr_debug("rx'd ctl:\n");
1023 case WLAN_FSTYPE_PSPOLL:
1024 /* printk("pspoll"); */
1025 wlandev->rx.pspoll++;
1027 case WLAN_FSTYPE_RTS:
1028 /* printk("rts"); */
1031 case WLAN_FSTYPE_CTS:
1032 /* printk("cts"); */
1035 case WLAN_FSTYPE_ACK:
1036 /* printk("ack"); */
1039 case WLAN_FSTYPE_CFEND:
1040 /* printk("cfend"); */
1041 wlandev->rx.cfend++;
1043 case WLAN_FSTYPE_CFENDCFACK:
1044 /* printk("cfendcfack"); */
1045 wlandev->rx.cfendcfack++;
1048 /* printk("unknown"); */
1049 wlandev->rx.ctl_unknown++;
1056 case WLAN_FTYPE_DATA:
1059 case WLAN_FSTYPE_DATAONLY:
1060 wlandev->rx.dataonly++;
1062 case WLAN_FSTYPE_DATA_CFACK:
1063 wlandev->rx.data_cfack++;
1065 case WLAN_FSTYPE_DATA_CFPOLL:
1066 wlandev->rx.data_cfpoll++;
1068 case WLAN_FSTYPE_DATA_CFACK_CFPOLL:
1069 wlandev->rx.data__cfack_cfpoll++;
1071 case WLAN_FSTYPE_NULL:
1072 pr_debug("rx'd data:null\n");
1075 case WLAN_FSTYPE_CFACK:
1076 pr_debug("rx'd data:cfack\n");
1077 wlandev->rx.cfack++;
1079 case WLAN_FSTYPE_CFPOLL:
1080 pr_debug("rx'd data:cfpoll\n");
1081 wlandev->rx.cfpoll++;
1083 case WLAN_FSTYPE_CFACK_CFPOLL:
1084 pr_debug("rx'd data:cfack_cfpoll\n");
1085 wlandev->rx.cfack_cfpoll++;
1088 /* printk("unknown"); */
1089 wlandev->rx.data_unknown++;
1098 static void p80211knetdev_tx_timeout(netdevice_t *netdev)
1100 wlandevice_t *wlandev = netdev->ml_priv;
1102 if (wlandev->tx_timeout) {
1103 wlandev->tx_timeout(wlandev);
1105 printk(KERN_WARNING "Implement tx_timeout for %s\n",
1107 netif_wake_queue(wlandev->netdev);
1111 void p80211_allow_ioctls(wlandevice_t *wlandev)
1113 mutex_unlock(&wlandev->ioctl_lock);