Initial import from the website's tarball, on the 18th of october 2004
[islsm.git] / usb_netdev.c
blob0dff4a0d7d35bcf64a159292d5d56aa2b7306a5c
1 /*
2 * Prism54 USB driver
3 */
5 #include <linux/config.h>
6 #include <linux/kernel.h>
7 #include <linux/errno.h>
8 #include <linux/init.h>
9 #include <linux/slab.h>
10 #include <linux/module.h>
11 #include <linux/smp_lock.h>
12 #include <linux/completion.h>
13 #include <linux/netdevice.h>
14 #include <linux/etherdevice.h>
15 #include <linux/wireless.h>
16 #include <asm/uaccess.h>
17 #include <linux/usb.h>
19 #include "prism54_usb.h"
20 #include "isl_38xx.h"
21 #include "ioctl.h"
23 const char dummy_mac[ETH_ALEN] = {0x00, 0x3d, 0xb4, 0x00, 0x00, 0x00};
25 static int p54u_open(struct net_device *netdev)
27 struct p54u *p54u = netdev_priv(netdev);
28 struct usb_device *usbdev = p54u->usbdev;
30 p54u_info("sem down\n");
31 down (&p54u->disconnect_sem);
32 p54u_info("sem down done\n");
35 if(!p54u->running)
37 p54u_info("Not running on open, booting\n");
38 if(p54u_boot(netdev)) {
39 p54u_err("Failed to boot device.\n");
40 goto do_err;
44 netif_start_queue(netdev);
45 p54u_info("sem up\n");
46 up(&p54u->disconnect_sem);
47 p54u_info("sem up done\n");
48 return 0;
50 do_err:
51 p54u_err("Failed to open device.\n");
52 p54u_shutdown(netdev);
53 p54u_info("sem up\n");
54 up(&p54u->disconnect_sem);
55 p54u_info("sem up done\n");
56 return -EIO;
59 static int p54u_close(struct net_device *netdev)
61 struct p54u *p54u = netdev_priv(netdev);
62 struct usb_device *usbdev = p54u->usbdev;
64 netif_stop_queue(netdev);
66 if(!load_fw)
68 p54u_info("Close with firmware unload\n");
69 if (p54u->running)
71 p54u_info("Running on close,shutting down\n");
72 if (p54u_shutdown(netdev))
74 p54u_info("Shutdown failed\n");
75 return -EIO;
80 return 0;
83 static void p54u_tx_timeout(struct net_device *netdev)
85 struct p54u *p54u = netdev_priv(netdev);
86 struct usb_device *usbdev = p54u->usbdev;
88 return;
91 static int p54u_transmit(struct sk_buff *skb, struct net_device *netdev)
93 struct p54u *p54u = netdev_priv(netdev);
94 struct usb_device *usbdev = p54u->usbdev;
96 p54u_info("xmit\n");
97 netdev->trans_start = jiffies;
98 /* do the submit urb stuff */
99 dev_kfree_skb(skb);
101 return 0;
104 static struct net_device_stats *
105 p54u_statistics(struct net_device *netdev)
107 struct p54u *p54u = netdev_priv(netdev);
109 return &p54u->statistics;
112 static int
113 p54u_ioctl(struct net_device *ndev, struct ifreq *rq, int cmd)
115 return -EOPNOTSUPP;
118 int p54u_setup_net(struct net_device *netdev)
120 struct p54u *p54u = netdev_priv(netdev);
121 struct usb_device *usbdev = p54u->usbdev;
123 /* initialize the function pointers */
124 netdev->open = &p54u_open;
125 netdev->stop = &p54u_close;
126 netdev->get_stats = &p54u_statistics;
127 netdev->get_wireless_stats = &p54u_wireless_stats;
128 netdev->do_ioctl = &p54u_ioctl;
129 netdev->wireless_handlers = (struct iw_handler_def *) &p54u_handler_def;
131 netdev->hard_start_xmit = &p54u_transmit;
132 netdev->addr_len = ETH_ALEN;
133 // netdev->set_mac_address = &prism54_set_mac_address;
135 netdev->watchdog_timeo = P54U_TX_TIMEOUT;
136 netdev->tx_timeout = &p54u_tx_timeout;
138 return 0;