blob: 8124cf16259f2d721699de90e85c6c94399fdb24 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
David Brownell090ffa92005-08-31 09:54:50 -07002 * USB Network driver infrastructure
David Brownellf29fc252005-08-31 09:52:31 -07003 * Copyright (C) 2000-2005 by David Brownell
Linus Torvalds1da177e2005-04-16 15:20:36 -07004 * Copyright (C) 2003-2005 David Hollis <dhollis@davehollis.com>
Linus Torvalds1da177e2005-04-16 15:20:36 -07005 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 */
20
21/*
22 * This is a generic "USB networking" framework that works with several
David Brownell090ffa92005-08-31 09:54:50 -070023 * kinds of full and high speed networking devices: host-to-host cables,
24 * smart usb peripherals, and actual Ethernet adapters.
Linus Torvalds1da177e2005-04-16 15:20:36 -070025 *
David Brownell090ffa92005-08-31 09:54:50 -070026 * These devices usually differ in terms of control protocols (if they
27 * even have one!) and sometimes they define new framing to wrap or batch
28 * Ethernet packets. Otherwise, they talk to USB pretty much the same,
29 * so interface (un)binding, endpoint I/O queues, fault handling, and other
30 * issues can usefully be addressed by this framework.
31 */
Linus Torvalds1da177e2005-04-16 15:20:36 -070032
33// #define DEBUG // error path messages, extra info
34// #define VERBOSE // more; success messages
35
Linus Torvalds1da177e2005-04-16 15:20:36 -070036#include <linux/module.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070037#include <linux/init.h>
38#include <linux/netdevice.h>
39#include <linux/etherdevice.h>
Peter Holik03ad0322009-04-18 07:24:17 +000040#include <linux/ctype.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070041#include <linux/ethtool.h>
42#include <linux/workqueue.h>
43#include <linux/mii.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070044#include <linux/usb.h>
Jussi Kivilinna3692e942008-01-26 00:51:45 +020045#include <linux/usb/usbnet.h>
David Brownellf29fc252005-08-31 09:52:31 -070046
47#define DRIVER_VERSION "22-Aug-2005"
Linus Torvalds1da177e2005-04-16 15:20:36 -070048
49
50/*-------------------------------------------------------------------------*/
51
52/*
53 * Nineteen USB 1.1 max size bulk transactions per frame (ms), max.
54 * Several dozen bytes of IPv4 data can fit in two such transactions.
55 * One maximum size Ethernet packet takes twenty four of them.
56 * For high speed, each frame comfortably fits almost 36 max size
57 * Ethernet packets (so queues should be bigger).
David Brownellf29fc252005-08-31 09:52:31 -070058 *
59 * REVISIT qlens should be members of 'struct usbnet'; the goal is to
60 * let the USB host controller be busy for 5msec or more before an irq
61 * is required, under load. Jumbograms change the equation.
Linus Torvalds1da177e2005-04-16 15:20:36 -070062 */
Jamie Paintera99c1942006-07-27 14:17:28 -040063#define RX_MAX_QUEUE_MEMORY (60 * 1518)
64#define RX_QLEN(dev) (((dev)->udev->speed == USB_SPEED_HIGH) ? \
65 (RX_MAX_QUEUE_MEMORY/(dev)->rx_urb_size) : 4)
66#define TX_QLEN(dev) (((dev)->udev->speed == USB_SPEED_HIGH) ? \
67 (RX_MAX_QUEUE_MEMORY/(dev)->hard_mtu) : 4)
Linus Torvalds1da177e2005-04-16 15:20:36 -070068
Linus Torvalds1da177e2005-04-16 15:20:36 -070069// reawaken network queue this soon after stopping; else watchdog barks
70#define TX_TIMEOUT_JIFFIES (5*HZ)
71
72// throttle rx/tx briefly after some faults, so khubd might disconnect()
73// us (it polls at HZ/4 usually) before we report too many false errors.
74#define THROTTLE_JIFFIES (HZ/8)
75
Linus Torvalds1da177e2005-04-16 15:20:36 -070076// between wakeups
77#define UNLINK_TIMEOUT_MS 3
78
79/*-------------------------------------------------------------------------*/
80
81// randomly generated ethernet address
82static u8 node_id [ETH_ALEN];
83
Linus Torvalds1da177e2005-04-16 15:20:36 -070084static const char driver_name [] = "usbnet";
85
86/* use ethtool to change the level for any given device */
87static int msg_level = -1;
88module_param (msg_level, int, 0);
89MODULE_PARM_DESC (msg_level, "Override default message level");
90
Linus Torvalds1da177e2005-04-16 15:20:36 -070091/*-------------------------------------------------------------------------*/
92
Linus Torvalds1da177e2005-04-16 15:20:36 -070093/* handles CDC Ethernet and many other network "bulk data" interfaces */
David Brownell2e55cc72005-08-31 09:53:10 -070094int usbnet_get_endpoints(struct usbnet *dev, struct usb_interface *intf)
Linus Torvalds1da177e2005-04-16 15:20:36 -070095{
96 int tmp;
97 struct usb_host_interface *alt = NULL;
98 struct usb_host_endpoint *in = NULL, *out = NULL;
99 struct usb_host_endpoint *status = NULL;
100
101 for (tmp = 0; tmp < intf->num_altsetting; tmp++) {
102 unsigned ep;
103
104 in = out = status = NULL;
105 alt = intf->altsetting + tmp;
106
107 /* take the first altsetting with in-bulk + out-bulk;
108 * remember any status endpoint, just in case;
109 * ignore other endpoints and altsetttings.
110 */
111 for (ep = 0; ep < alt->desc.bNumEndpoints; ep++) {
112 struct usb_host_endpoint *e;
113 int intr = 0;
114
115 e = alt->endpoint + ep;
116 switch (e->desc.bmAttributes) {
117 case USB_ENDPOINT_XFER_INT:
Luiz Fernando N. Capitulinofc6e2542006-10-26 13:03:01 -0300118 if (!usb_endpoint_dir_in(&e->desc))
Linus Torvalds1da177e2005-04-16 15:20:36 -0700119 continue;
120 intr = 1;
121 /* FALLTHROUGH */
122 case USB_ENDPOINT_XFER_BULK:
123 break;
124 default:
125 continue;
126 }
Luiz Fernando N. Capitulinofc6e2542006-10-26 13:03:01 -0300127 if (usb_endpoint_dir_in(&e->desc)) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700128 if (!intr && !in)
129 in = e;
130 else if (intr && !status)
131 status = e;
132 } else {
133 if (!out)
134 out = e;
135 }
136 }
137 if (in && out)
138 break;
139 }
140 if (!alt || !in || !out)
141 return -EINVAL;
142
143 if (alt->desc.bAlternateSetting != 0
144 || !(dev->driver_info->flags & FLAG_NO_SETINT)) {
145 tmp = usb_set_interface (dev->udev, alt->desc.bInterfaceNumber,
146 alt->desc.bAlternateSetting);
147 if (tmp < 0)
148 return tmp;
149 }
David Brownellcb1cebb2007-02-15 18:52:30 -0800150
Linus Torvalds1da177e2005-04-16 15:20:36 -0700151 dev->in = usb_rcvbulkpipe (dev->udev,
152 in->desc.bEndpointAddress & USB_ENDPOINT_NUMBER_MASK);
153 dev->out = usb_sndbulkpipe (dev->udev,
154 out->desc.bEndpointAddress & USB_ENDPOINT_NUMBER_MASK);
155 dev->status = status;
156 return 0;
157}
David Brownell2e55cc72005-08-31 09:53:10 -0700158EXPORT_SYMBOL_GPL(usbnet_get_endpoints);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700159
Peter Holik03ad0322009-04-18 07:24:17 +0000160static u8 nibble(unsigned char c)
161{
162 if (likely(isdigit(c)))
163 return c - '0';
164 c = toupper(c);
165 if (likely(isxdigit(c)))
166 return 10 + c - 'A';
167 return 0;
168}
169
170int usbnet_get_ethernet_addr(struct usbnet *dev, int iMACAddress)
171{
172 int tmp, i;
173 unsigned char buf [13];
174
175 tmp = usb_string(dev->udev, iMACAddress, buf, sizeof buf);
176 if (tmp != 12) {
177 dev_dbg(&dev->udev->dev,
178 "bad MAC string %d fetch, %d\n", iMACAddress, tmp);
179 if (tmp >= 0)
180 tmp = -EINVAL;
181 return tmp;
182 }
183 for (i = tmp = 0; i < 6; i++, tmp += 2)
184 dev->net->dev_addr [i] =
185 (nibble(buf [tmp]) << 4) + nibble(buf [tmp + 1]);
186 return 0;
187}
188EXPORT_SYMBOL_GPL(usbnet_get_ethernet_addr);
189
David Howells7d12e782006-10-05 14:55:46 +0100190static void intr_complete (struct urb *urb);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700191
192static int init_status (struct usbnet *dev, struct usb_interface *intf)
193{
194 char *buf = NULL;
195 unsigned pipe = 0;
196 unsigned maxp;
197 unsigned period;
198
199 if (!dev->driver_info->status)
200 return 0;
201
202 pipe = usb_rcvintpipe (dev->udev,
203 dev->status->desc.bEndpointAddress
204 & USB_ENDPOINT_NUMBER_MASK);
205 maxp = usb_maxpacket (dev->udev, pipe, 0);
206
207 /* avoid 1 msec chatter: min 8 msec poll rate */
208 period = max ((int) dev->status->desc.bInterval,
209 (dev->udev->speed == USB_SPEED_HIGH) ? 7 : 3);
210
Christoph Lametere94b1762006-12-06 20:33:17 -0800211 buf = kmalloc (maxp, GFP_KERNEL);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700212 if (buf) {
Christoph Lametere94b1762006-12-06 20:33:17 -0800213 dev->interrupt = usb_alloc_urb (0, GFP_KERNEL);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700214 if (!dev->interrupt) {
215 kfree (buf);
216 return -ENOMEM;
217 } else {
218 usb_fill_int_urb(dev->interrupt, dev->udev, pipe,
219 buf, maxp, intr_complete, dev, period);
220 dev_dbg(&intf->dev,
221 "status ep%din, %d bytes period %d\n",
222 usb_pipeendpoint(pipe), maxp, period);
223 }
224 }
David Brownell18ab4582007-05-25 12:31:32 -0700225 return 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700226}
227
David Brownell2e55cc72005-08-31 09:53:10 -0700228/* Passes this packet up the stack, updating its accounting.
229 * Some link protocols batch packets, so their rx_fixup paths
230 * can return clones as well as just modify the original skb.
231 */
232void usbnet_skb_return (struct usbnet *dev, struct sk_buff *skb)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700233{
234 int status;
235
Jussi Kivilinna7834ddb2009-08-11 22:57:16 +0300236 if (test_bit(EVENT_RX_PAUSED, &dev->flags)) {
237 skb_queue_tail(&dev->rxq_pause, skb);
238 return;
239 }
240
Linus Torvalds1da177e2005-04-16 15:20:36 -0700241 skb->protocol = eth_type_trans (skb, dev->net);
Herbert Xu79638372009-06-29 16:53:28 +0000242 dev->net->stats.rx_packets++;
243 dev->net->stats.rx_bytes += skb->len;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700244
245 if (netif_msg_rx_status (dev))
Al Viro5330e922005-04-26 11:26:53 -0700246 devdbg (dev, "< rx, len %zu, type 0x%x",
Linus Torvalds1da177e2005-04-16 15:20:36 -0700247 skb->len + sizeof (struct ethhdr), skb->protocol);
248 memset (skb->cb, 0, sizeof (struct skb_data));
249 status = netif_rx (skb);
250 if (status != NET_RX_SUCCESS && netif_msg_rx_err (dev))
251 devdbg (dev, "netif_rx status %d", status);
252}
David Brownell2e55cc72005-08-31 09:53:10 -0700253EXPORT_SYMBOL_GPL(usbnet_skb_return);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700254
255
Linus Torvalds1da177e2005-04-16 15:20:36 -0700256/*-------------------------------------------------------------------------
257 *
258 * Network Device Driver (peer link to "Host Device", from USB host)
259 *
260 *-------------------------------------------------------------------------*/
261
Stephen Hemminger777baa42009-03-20 19:35:54 +0000262int usbnet_change_mtu (struct net_device *net, int new_mtu)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700263{
264 struct usbnet *dev = netdev_priv(net);
David Brownellf29fc252005-08-31 09:52:31 -0700265 int ll_mtu = new_mtu + net->hard_header_len;
Jamie Paintera99c1942006-07-27 14:17:28 -0400266 int old_hard_mtu = dev->hard_mtu;
267 int old_rx_urb_size = dev->rx_urb_size;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700268
Jamie Paintera99c1942006-07-27 14:17:28 -0400269 if (new_mtu <= 0)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700270 return -EINVAL;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700271 // no second zero-length packet read wanted after mtu-sized packets
David Brownellf29fc252005-08-31 09:52:31 -0700272 if ((ll_mtu % dev->maxpacket) == 0)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700273 return -EDOM;
274 net->mtu = new_mtu;
Jamie Paintera99c1942006-07-27 14:17:28 -0400275
276 dev->hard_mtu = net->mtu + net->hard_header_len;
277 if (dev->rx_urb_size == old_hard_mtu) {
278 dev->rx_urb_size = dev->hard_mtu;
279 if (dev->rx_urb_size > old_rx_urb_size)
280 usbnet_unlink_rx_urbs(dev);
281 }
282
Linus Torvalds1da177e2005-04-16 15:20:36 -0700283 return 0;
284}
Stephen Hemminger777baa42009-03-20 19:35:54 +0000285EXPORT_SYMBOL_GPL(usbnet_change_mtu);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700286
287/*-------------------------------------------------------------------------*/
288
Linus Torvalds1da177e2005-04-16 15:20:36 -0700289/* some LK 2.4 HCDs oopsed if we freed or resubmitted urbs from
290 * completion callbacks. 2.5 should have fixed those bugs...
291 */
292
David S. Miller8728b832005-08-09 19:25:21 -0700293static void defer_bh(struct usbnet *dev, struct sk_buff *skb, struct sk_buff_head *list)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700294{
Linus Torvalds1da177e2005-04-16 15:20:36 -0700295 unsigned long flags;
296
David S. Miller8728b832005-08-09 19:25:21 -0700297 spin_lock_irqsave(&list->lock, flags);
298 __skb_unlink(skb, list);
299 spin_unlock(&list->lock);
300 spin_lock(&dev->done.lock);
301 __skb_queue_tail(&dev->done, skb);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700302 if (dev->done.qlen == 1)
David S. Miller8728b832005-08-09 19:25:21 -0700303 tasklet_schedule(&dev->bh);
304 spin_unlock_irqrestore(&dev->done.lock, flags);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700305}
306
307/* some work can't be done in tasklets, so we use keventd
308 *
309 * NOTE: annoying asymmetry: if it's active, schedule_work() fails,
310 * but tasklet_schedule() doesn't. hope the failure is rare.
311 */
David Brownell2e55cc72005-08-31 09:53:10 -0700312void usbnet_defer_kevent (struct usbnet *dev, int work)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700313{
314 set_bit (work, &dev->flags);
315 if (!schedule_work (&dev->kevent))
316 deverr (dev, "kevent %d may have been dropped", work);
317 else
318 devdbg (dev, "kevent %d scheduled", work);
319}
David Brownell2e55cc72005-08-31 09:53:10 -0700320EXPORT_SYMBOL_GPL(usbnet_defer_kevent);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700321
322/*-------------------------------------------------------------------------*/
323
David Howells7d12e782006-10-05 14:55:46 +0100324static void rx_complete (struct urb *urb);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700325
Al Viro55016f12005-10-21 03:21:58 -0400326static void rx_submit (struct usbnet *dev, struct urb *urb, gfp_t flags)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700327{
328 struct sk_buff *skb;
329 struct skb_data *entry;
330 int retval = 0;
331 unsigned long lockflags;
David Brownell2e55cc72005-08-31 09:53:10 -0700332 size_t size = dev->rx_urb_size;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700333
Linus Torvalds1da177e2005-04-16 15:20:36 -0700334 if ((skb = alloc_skb (size + NET_IP_ALIGN, flags)) == NULL) {
335 if (netif_msg_rx_err (dev))
336 devdbg (dev, "no rx skb");
David Brownell2e55cc72005-08-31 09:53:10 -0700337 usbnet_defer_kevent (dev, EVENT_RX_MEMORY);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700338 usb_free_urb (urb);
339 return;
340 }
341 skb_reserve (skb, NET_IP_ALIGN);
342
343 entry = (struct skb_data *) skb->cb;
344 entry->urb = urb;
345 entry->dev = dev;
346 entry->state = rx_start;
347 entry->length = 0;
348
349 usb_fill_bulk_urb (urb, dev->udev, dev->in,
350 skb->data, size, rx_complete, skb);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700351
352 spin_lock_irqsave (&dev->rxq.lock, lockflags);
353
354 if (netif_running (dev->net)
355 && netif_device_present (dev->net)
356 && !test_bit (EVENT_RX_HALT, &dev->flags)) {
David Brownell18ab4582007-05-25 12:31:32 -0700357 switch (retval = usb_submit_urb (urb, GFP_ATOMIC)) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700358 case -EPIPE:
David Brownell2e55cc72005-08-31 09:53:10 -0700359 usbnet_defer_kevent (dev, EVENT_RX_HALT);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700360 break;
361 case -ENOMEM:
David Brownell2e55cc72005-08-31 09:53:10 -0700362 usbnet_defer_kevent (dev, EVENT_RX_MEMORY);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700363 break;
364 case -ENODEV:
365 if (netif_msg_ifdown (dev))
366 devdbg (dev, "device gone");
367 netif_device_detach (dev->net);
368 break;
369 default:
370 if (netif_msg_rx_err (dev))
371 devdbg (dev, "rx submit, %d", retval);
372 tasklet_schedule (&dev->bh);
373 break;
374 case 0:
375 __skb_queue_tail (&dev->rxq, skb);
376 }
377 } else {
378 if (netif_msg_ifdown (dev))
379 devdbg (dev, "rx: stopped");
380 retval = -ENOLINK;
381 }
382 spin_unlock_irqrestore (&dev->rxq.lock, lockflags);
383 if (retval) {
384 dev_kfree_skb_any (skb);
385 usb_free_urb (urb);
386 }
387}
388
389
390/*-------------------------------------------------------------------------*/
391
392static inline void rx_process (struct usbnet *dev, struct sk_buff *skb)
393{
394 if (dev->driver_info->rx_fixup
395 && !dev->driver_info->rx_fixup (dev, skb))
396 goto error;
397 // else network stack removes extra byte if we forced a short packet
398
399 if (skb->len)
David Brownell2e55cc72005-08-31 09:53:10 -0700400 usbnet_skb_return (dev, skb);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700401 else {
402 if (netif_msg_rx_err (dev))
403 devdbg (dev, "drop");
404error:
Herbert Xu79638372009-06-29 16:53:28 +0000405 dev->net->stats.rx_errors++;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700406 skb_queue_tail (&dev->done, skb);
407 }
408}
409
410/*-------------------------------------------------------------------------*/
411
David Howells7d12e782006-10-05 14:55:46 +0100412static void rx_complete (struct urb *urb)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700413{
414 struct sk_buff *skb = (struct sk_buff *) urb->context;
415 struct skb_data *entry = (struct skb_data *) skb->cb;
416 struct usbnet *dev = entry->dev;
417 int urb_status = urb->status;
418
419 skb_put (skb, urb->actual_length);
420 entry->state = rx_done;
421 entry->urb = NULL;
422
423 switch (urb_status) {
David Brownell18ab4582007-05-25 12:31:32 -0700424 /* success */
425 case 0:
David Brownellf29fc252005-08-31 09:52:31 -0700426 if (skb->len < dev->net->hard_header_len) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700427 entry->state = rx_cleanup;
Herbert Xu79638372009-06-29 16:53:28 +0000428 dev->net->stats.rx_errors++;
429 dev->net->stats.rx_length_errors++;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700430 if (netif_msg_rx_err (dev))
431 devdbg (dev, "rx length %d", skb->len);
432 }
433 break;
434
David Brownell18ab4582007-05-25 12:31:32 -0700435 /* stalls need manual reset. this is rare ... except that
436 * when going through USB 2.0 TTs, unplug appears this way.
Jean Delvare3ac49a12009-06-04 16:20:28 +0200437 * we avoid the highspeed version of the ETIMEDOUT/EILSEQ
David Brownell18ab4582007-05-25 12:31:32 -0700438 * storm, recovering as needed.
439 */
440 case -EPIPE:
Herbert Xu79638372009-06-29 16:53:28 +0000441 dev->net->stats.rx_errors++;
David Brownell2e55cc72005-08-31 09:53:10 -0700442 usbnet_defer_kevent (dev, EVENT_RX_HALT);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700443 // FALLTHROUGH
444
David Brownell18ab4582007-05-25 12:31:32 -0700445 /* software-driven interface shutdown */
446 case -ECONNRESET: /* async unlink */
447 case -ESHUTDOWN: /* hardware gone */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700448 if (netif_msg_ifdown (dev))
449 devdbg (dev, "rx shutdown, code %d", urb_status);
450 goto block;
451
David Brownell18ab4582007-05-25 12:31:32 -0700452 /* we get controller i/o faults during khubd disconnect() delays.
453 * throttle down resubmits, to avoid log floods; just temporarily,
454 * so we still recover when the fault isn't a khubd delay.
455 */
456 case -EPROTO:
457 case -ETIME:
458 case -EILSEQ:
Herbert Xu79638372009-06-29 16:53:28 +0000459 dev->net->stats.rx_errors++;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700460 if (!timer_pending (&dev->delay)) {
461 mod_timer (&dev->delay, jiffies + THROTTLE_JIFFIES);
462 if (netif_msg_link (dev))
463 devdbg (dev, "rx throttle %d", urb_status);
464 }
465block:
466 entry->state = rx_cleanup;
467 entry->urb = urb;
468 urb = NULL;
469 break;
470
David Brownell18ab4582007-05-25 12:31:32 -0700471 /* data overrun ... flush fifo? */
472 case -EOVERFLOW:
Herbert Xu79638372009-06-29 16:53:28 +0000473 dev->net->stats.rx_over_errors++;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700474 // FALLTHROUGH
David Brownellcb1cebb2007-02-15 18:52:30 -0800475
David Brownell18ab4582007-05-25 12:31:32 -0700476 default:
Linus Torvalds1da177e2005-04-16 15:20:36 -0700477 entry->state = rx_cleanup;
Herbert Xu79638372009-06-29 16:53:28 +0000478 dev->net->stats.rx_errors++;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700479 if (netif_msg_rx_err (dev))
480 devdbg (dev, "rx status %d", urb_status);
481 break;
482 }
483
David S. Miller8728b832005-08-09 19:25:21 -0700484 defer_bh(dev, skb, &dev->rxq);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700485
486 if (urb) {
487 if (netif_running (dev->net)
488 && !test_bit (EVENT_RX_HALT, &dev->flags)) {
489 rx_submit (dev, urb, GFP_ATOMIC);
490 return;
491 }
492 usb_free_urb (urb);
493 }
494 if (netif_msg_rx_err (dev))
495 devdbg (dev, "no read resubmitted");
496}
497
David Howells7d12e782006-10-05 14:55:46 +0100498static void intr_complete (struct urb *urb)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700499{
500 struct usbnet *dev = urb->context;
501 int status = urb->status;
502
503 switch (status) {
David Brownell18ab4582007-05-25 12:31:32 -0700504 /* success */
505 case 0:
Linus Torvalds1da177e2005-04-16 15:20:36 -0700506 dev->driver_info->status(dev, urb);
507 break;
508
David Brownell18ab4582007-05-25 12:31:32 -0700509 /* software-driven interface shutdown */
510 case -ENOENT: /* urb killed */
511 case -ESHUTDOWN: /* hardware gone */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700512 if (netif_msg_ifdown (dev))
513 devdbg (dev, "intr shutdown, code %d", status);
514 return;
515
David Brownell18ab4582007-05-25 12:31:32 -0700516 /* NOTE: not throttling like RX/TX, since this endpoint
517 * already polls infrequently
518 */
519 default:
Linus Torvalds1da177e2005-04-16 15:20:36 -0700520 devdbg (dev, "intr status %d", status);
521 break;
522 }
523
524 if (!netif_running (dev->net))
525 return;
526
527 memset(urb->transfer_buffer, 0, urb->transfer_buffer_length);
528 status = usb_submit_urb (urb, GFP_ATOMIC);
529 if (status != 0 && netif_msg_timer (dev))
530 deverr(dev, "intr resubmit --> %d", status);
531}
532
533/*-------------------------------------------------------------------------*/
Jussi Kivilinna7834ddb2009-08-11 22:57:16 +0300534void usbnet_pause_rx(struct usbnet *dev)
535{
536 set_bit(EVENT_RX_PAUSED, &dev->flags);
537
538 if (netif_msg_rx_status(dev))
539 devdbg(dev, "paused rx queue enabled");
540}
541EXPORT_SYMBOL_GPL(usbnet_pause_rx);
542
543void usbnet_resume_rx(struct usbnet *dev)
544{
545 struct sk_buff *skb;
546 int num = 0;
547
548 clear_bit(EVENT_RX_PAUSED, &dev->flags);
549
550 while ((skb = skb_dequeue(&dev->rxq_pause)) != NULL) {
551 usbnet_skb_return(dev, skb);
552 num++;
553 }
554
555 tasklet_schedule(&dev->bh);
556
557 if (netif_msg_rx_status(dev))
558 devdbg(dev, "paused rx queue disabled, %d skbs requeued", num);
559}
560EXPORT_SYMBOL_GPL(usbnet_resume_rx);
561
562void usbnet_purge_paused_rxq(struct usbnet *dev)
563{
564 skb_queue_purge(&dev->rxq_pause);
565}
566EXPORT_SYMBOL_GPL(usbnet_purge_paused_rxq);
567
568/*-------------------------------------------------------------------------*/
Linus Torvalds1da177e2005-04-16 15:20:36 -0700569
570// unlink pending rx/tx; completion handlers do all other cleanup
571
572static int unlink_urbs (struct usbnet *dev, struct sk_buff_head *q)
573{
574 unsigned long flags;
575 struct sk_buff *skb, *skbnext;
576 int count = 0;
577
578 spin_lock_irqsave (&q->lock, flags);
David S. Miller83bfba52008-09-22 20:18:47 -0700579 skb_queue_walk_safe(q, skb, skbnext) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700580 struct skb_data *entry;
581 struct urb *urb;
582 int retval;
583
584 entry = (struct skb_data *) skb->cb;
585 urb = entry->urb;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700586
587 // during some PM-driven resume scenarios,
588 // these (async) unlinks complete immediately
589 retval = usb_unlink_urb (urb);
590 if (retval != -EINPROGRESS && retval != 0)
591 devdbg (dev, "unlink urb err, %d", retval);
592 else
593 count++;
594 }
595 spin_unlock_irqrestore (&q->lock, flags);
596 return count;
597}
598
Jamie Paintera99c1942006-07-27 14:17:28 -0400599// Flush all pending rx urbs
600// minidrivers may need to do this when the MTU changes
601
602void usbnet_unlink_rx_urbs(struct usbnet *dev)
603{
604 if (netif_running(dev->net)) {
605 (void) unlink_urbs (dev, &dev->rxq);
606 tasklet_schedule(&dev->bh);
607 }
608}
609EXPORT_SYMBOL_GPL(usbnet_unlink_rx_urbs);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700610
611/*-------------------------------------------------------------------------*/
612
613// precondition: never called in_interrupt
614
Stephen Hemminger777baa42009-03-20 19:35:54 +0000615int usbnet_stop (struct net_device *net)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700616{
617 struct usbnet *dev = netdev_priv(net);
Jussi Kivilinnaa33e9e72009-06-16 17:17:27 +0300618 struct driver_info *info = dev->driver_info;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700619 int temp;
Jussi Kivilinnaa33e9e72009-06-16 17:17:27 +0300620 int retval;
Peter Zijlstra7259f0d2006-10-29 22:46:36 -0800621 DECLARE_WAIT_QUEUE_HEAD_ONSTACK (unlink_wakeup);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700622 DECLARE_WAITQUEUE (wait, current);
623
624 netif_stop_queue (net);
625
626 if (netif_msg_ifdown (dev))
627 devinfo (dev, "stop stats: rx/tx %ld/%ld, errs %ld/%ld",
Herbert Xu79638372009-06-29 16:53:28 +0000628 net->stats.rx_packets, net->stats.tx_packets,
629 net->stats.rx_errors, net->stats.tx_errors
Linus Torvalds1da177e2005-04-16 15:20:36 -0700630 );
631
Jussi Kivilinnaa33e9e72009-06-16 17:17:27 +0300632 /* allow minidriver to stop correctly (wireless devices to turn off
633 * radio etc) */
634 if (info->stop) {
635 retval = info->stop(dev);
636 if (retval < 0 && netif_msg_ifdown(dev))
637 devinfo(dev,
638 "stop fail (%d) usbnet usb-%s-%s, %s",
639 retval,
640 dev->udev->bus->bus_name, dev->udev->devpath,
641 info->description);
642 }
643
Jussi Kivilinna1487cd52009-07-30 19:41:20 +0300644 if (!(info->flags & FLAG_AVOID_UNLINK_URBS)) {
645 /* ensure there are no more active urbs */
646 add_wait_queue(&unlink_wakeup, &wait);
647 dev->wait = &unlink_wakeup;
648 temp = unlink_urbs(dev, &dev->txq) +
649 unlink_urbs(dev, &dev->rxq);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700650
Jussi Kivilinna1487cd52009-07-30 19:41:20 +0300651 /* maybe wait for deletions to finish. */
652 while (!skb_queue_empty(&dev->rxq)
653 && !skb_queue_empty(&dev->txq)
654 && !skb_queue_empty(&dev->done)) {
655 msleep(UNLINK_TIMEOUT_MS);
656 if (netif_msg_ifdown(dev))
657 devdbg(dev, "waited for %d urb completions",
658 temp);
659 }
660 dev->wait = NULL;
661 remove_wait_queue(&unlink_wakeup, &wait);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700662 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700663
664 usb_kill_urb(dev->interrupt);
665
Jussi Kivilinna7834ddb2009-08-11 22:57:16 +0300666 usbnet_purge_paused_rxq(dev);
667
Linus Torvalds1da177e2005-04-16 15:20:36 -0700668 /* deferred work (task, timer, softirq) must also stop.
669 * can't flush_scheduled_work() until we drop rtnl (later),
670 * else workers could deadlock; so make workers a NOP.
671 */
672 dev->flags = 0;
673 del_timer_sync (&dev->delay);
674 tasklet_kill (&dev->bh);
Oliver Neukuma11a6542007-08-03 13:52:19 +0200675 usb_autopm_put_interface(dev->intf);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700676
677 return 0;
678}
Stephen Hemminger777baa42009-03-20 19:35:54 +0000679EXPORT_SYMBOL_GPL(usbnet_stop);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700680
681/*-------------------------------------------------------------------------*/
682
683// posts reads, and enables write queuing
684
685// precondition: never called in_interrupt
686
Stephen Hemminger777baa42009-03-20 19:35:54 +0000687int usbnet_open (struct net_device *net)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700688{
689 struct usbnet *dev = netdev_priv(net);
Oliver Neukuma11a6542007-08-03 13:52:19 +0200690 int retval;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700691 struct driver_info *info = dev->driver_info;
692
Oliver Neukuma11a6542007-08-03 13:52:19 +0200693 if ((retval = usb_autopm_get_interface(dev->intf)) < 0) {
694 if (netif_msg_ifup (dev))
695 devinfo (dev,
696 "resumption fail (%d) usbnet usb-%s-%s, %s",
697 retval,
698 dev->udev->bus->bus_name, dev->udev->devpath,
699 info->description);
700 goto done_nopm;
701 }
702
Linus Torvalds1da177e2005-04-16 15:20:36 -0700703 // put into "known safe" state
704 if (info->reset && (retval = info->reset (dev)) < 0) {
705 if (netif_msg_ifup (dev))
706 devinfo (dev,
707 "open reset fail (%d) usbnet usb-%s-%s, %s",
708 retval,
709 dev->udev->bus->bus_name, dev->udev->devpath,
710 info->description);
711 goto done;
712 }
713
714 // insist peer be connected
715 if (info->check_connect && (retval = info->check_connect (dev)) < 0) {
716 if (netif_msg_ifup (dev))
717 devdbg (dev, "can't open; %d", retval);
718 goto done;
719 }
720
721 /* start any status interrupt transfer */
722 if (dev->interrupt) {
723 retval = usb_submit_urb (dev->interrupt, GFP_KERNEL);
724 if (retval < 0) {
725 if (netif_msg_ifup (dev))
726 deverr (dev, "intr submit %d", retval);
727 goto done;
728 }
729 }
730
731 netif_start_queue (net);
732 if (netif_msg_ifup (dev)) {
733 char *framing;
734
735 if (dev->driver_info->flags & FLAG_FRAMING_NC)
736 framing = "NetChip";
737 else if (dev->driver_info->flags & FLAG_FRAMING_GL)
738 framing = "GeneSys";
739 else if (dev->driver_info->flags & FLAG_FRAMING_Z)
740 framing = "Zaurus";
741 else if (dev->driver_info->flags & FLAG_FRAMING_RN)
742 framing = "RNDIS";
743 else if (dev->driver_info->flags & FLAG_FRAMING_AX)
744 framing = "ASIX";
745 else
746 framing = "simple";
747
748 devinfo (dev, "open: enable queueing "
749 "(rx %d, tx %d) mtu %d %s framing",
Randy Dunlap25d94e62006-08-07 15:56:40 -0700750 (int)RX_QLEN (dev), (int)TX_QLEN (dev), dev->net->mtu,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700751 framing);
752 }
753
754 // delay posting reads until we're fully open
755 tasklet_schedule (&dev->bh);
Oliver Neukuma11a6542007-08-03 13:52:19 +0200756 return retval;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700757done:
Oliver Neukuma11a6542007-08-03 13:52:19 +0200758 usb_autopm_put_interface(dev->intf);
759done_nopm:
Linus Torvalds1da177e2005-04-16 15:20:36 -0700760 return retval;
761}
Stephen Hemminger777baa42009-03-20 19:35:54 +0000762EXPORT_SYMBOL_GPL(usbnet_open);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700763
764/*-------------------------------------------------------------------------*/
765
David Brownell2e55cc72005-08-31 09:53:10 -0700766/* ethtool methods; minidrivers may need to add some more, but
767 * they'll probably want to use this base set.
768 */
769
Arnd Bergmannc41286f2006-10-09 00:08:01 +0200770int usbnet_get_settings (struct net_device *net, struct ethtool_cmd *cmd)
771{
772 struct usbnet *dev = netdev_priv(net);
773
774 if (!dev->mii.mdio_read)
775 return -EOPNOTSUPP;
776
777 return mii_ethtool_gset(&dev->mii, cmd);
778}
779EXPORT_SYMBOL_GPL(usbnet_get_settings);
780
781int usbnet_set_settings (struct net_device *net, struct ethtool_cmd *cmd)
782{
783 struct usbnet *dev = netdev_priv(net);
784 int retval;
785
786 if (!dev->mii.mdio_write)
787 return -EOPNOTSUPP;
788
789 retval = mii_ethtool_sset(&dev->mii, cmd);
790
791 /* link speed/duplex might have changed */
792 if (dev->driver_info->link_reset)
793 dev->driver_info->link_reset(dev);
794
795 return retval;
796
797}
798EXPORT_SYMBOL_GPL(usbnet_set_settings);
799
Arnd Bergmannc41286f2006-10-09 00:08:01 +0200800u32 usbnet_get_link (struct net_device *net)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700801{
802 struct usbnet *dev = netdev_priv(net);
803
David Brownellf29fc252005-08-31 09:52:31 -0700804 /* If a check_connect is defined, return its result */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700805 if (dev->driver_info->check_connect)
806 return dev->driver_info->check_connect (dev) == 0;
807
Arnd Bergmannc41286f2006-10-09 00:08:01 +0200808 /* if the device has mii operations, use those */
809 if (dev->mii.mdio_read)
810 return mii_link_ok(&dev->mii);
811
Bjørn Mork05ffb3e2009-03-01 20:45:40 -0800812 /* Otherwise, dtrt for drivers calling netif_carrier_{on,off} */
813 return ethtool_op_get_link(net);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700814}
Arnd Bergmannc41286f2006-10-09 00:08:01 +0200815EXPORT_SYMBOL_GPL(usbnet_get_link);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700816
David Brownell18ee91fa2006-11-02 12:29:12 -0800817int usbnet_nway_reset(struct net_device *net)
818{
819 struct usbnet *dev = netdev_priv(net);
820
821 if (!dev->mii.mdio_write)
822 return -EOPNOTSUPP;
823
824 return mii_nway_restart(&dev->mii);
825}
826EXPORT_SYMBOL_GPL(usbnet_nway_reset);
827
David Brownell18ee91fa2006-11-02 12:29:12 -0800828void usbnet_get_drvinfo (struct net_device *net, struct ethtool_drvinfo *info)
829{
830 struct usbnet *dev = netdev_priv(net);
831
David Brownell296c0242007-04-17 16:10:10 -0700832 strncpy (info->driver, dev->driver_name, sizeof info->driver);
David Brownell18ee91fa2006-11-02 12:29:12 -0800833 strncpy (info->version, DRIVER_VERSION, sizeof info->version);
834 strncpy (info->fw_version, dev->driver_info->description,
835 sizeof info->fw_version);
836 usb_make_path (dev->udev, info->bus_info, sizeof info->bus_info);
837}
838EXPORT_SYMBOL_GPL(usbnet_get_drvinfo);
839
David Brownell2e55cc72005-08-31 09:53:10 -0700840u32 usbnet_get_msglevel (struct net_device *net)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700841{
842 struct usbnet *dev = netdev_priv(net);
843
844 return dev->msg_enable;
845}
David Brownell2e55cc72005-08-31 09:53:10 -0700846EXPORT_SYMBOL_GPL(usbnet_get_msglevel);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700847
David Brownell2e55cc72005-08-31 09:53:10 -0700848void usbnet_set_msglevel (struct net_device *net, u32 level)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700849{
850 struct usbnet *dev = netdev_priv(net);
851
852 dev->msg_enable = level;
853}
David Brownell2e55cc72005-08-31 09:53:10 -0700854EXPORT_SYMBOL_GPL(usbnet_set_msglevel);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700855
David Brownell2e55cc72005-08-31 09:53:10 -0700856/* drivers may override default ethtool_ops in their bind() routine */
Stephen Hemminger0fc0b732009-09-02 01:03:33 -0700857static const struct ethtool_ops usbnet_ethtool_ops = {
Arnd Bergmannc41286f2006-10-09 00:08:01 +0200858 .get_settings = usbnet_get_settings,
859 .set_settings = usbnet_set_settings,
David Brownell2e55cc72005-08-31 09:53:10 -0700860 .get_link = usbnet_get_link,
Arnd Bergmannc41286f2006-10-09 00:08:01 +0200861 .nway_reset = usbnet_nway_reset,
David Brownell18ee91fa2006-11-02 12:29:12 -0800862 .get_drvinfo = usbnet_get_drvinfo,
David Brownell2e55cc72005-08-31 09:53:10 -0700863 .get_msglevel = usbnet_get_msglevel,
864 .set_msglevel = usbnet_set_msglevel,
865};
Linus Torvalds1da177e2005-04-16 15:20:36 -0700866
867/*-------------------------------------------------------------------------*/
868
869/* work that cannot be done in interrupt context uses keventd.
870 *
871 * NOTE: with 2.5 we could do more of this using completion callbacks,
872 * especially now that control transfers can be queued.
873 */
874static void
David Howellsc4028952006-11-22 14:57:56 +0000875kevent (struct work_struct *work)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700876{
David Howellsc4028952006-11-22 14:57:56 +0000877 struct usbnet *dev =
878 container_of(work, struct usbnet, kevent);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700879 int status;
880
881 /* usb_clear_halt() needs a thread context */
882 if (test_bit (EVENT_TX_HALT, &dev->flags)) {
883 unlink_urbs (dev, &dev->txq);
884 status = usb_clear_halt (dev->udev, dev->out);
David Brownellf29fc252005-08-31 09:52:31 -0700885 if (status < 0
886 && status != -EPIPE
887 && status != -ESHUTDOWN) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700888 if (netif_msg_tx_err (dev))
889 deverr (dev, "can't clear tx halt, status %d",
890 status);
891 } else {
892 clear_bit (EVENT_TX_HALT, &dev->flags);
David Brownellf29fc252005-08-31 09:52:31 -0700893 if (status != -ESHUTDOWN)
894 netif_wake_queue (dev->net);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700895 }
896 }
897 if (test_bit (EVENT_RX_HALT, &dev->flags)) {
898 unlink_urbs (dev, &dev->rxq);
899 status = usb_clear_halt (dev->udev, dev->in);
David Brownellf29fc252005-08-31 09:52:31 -0700900 if (status < 0
901 && status != -EPIPE
902 && status != -ESHUTDOWN) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700903 if (netif_msg_rx_err (dev))
904 deverr (dev, "can't clear rx halt, status %d",
905 status);
906 } else {
907 clear_bit (EVENT_RX_HALT, &dev->flags);
908 tasklet_schedule (&dev->bh);
909 }
910 }
911
912 /* tasklet could resubmit itself forever if memory is tight */
913 if (test_bit (EVENT_RX_MEMORY, &dev->flags)) {
914 struct urb *urb = NULL;
915
916 if (netif_running (dev->net))
917 urb = usb_alloc_urb (0, GFP_KERNEL);
918 else
919 clear_bit (EVENT_RX_MEMORY, &dev->flags);
920 if (urb != NULL) {
921 clear_bit (EVENT_RX_MEMORY, &dev->flags);
922 rx_submit (dev, urb, GFP_KERNEL);
923 tasklet_schedule (&dev->bh);
924 }
925 }
926
David Hollis7ea13c92005-04-22 15:07:02 -0700927 if (test_bit (EVENT_LINK_RESET, &dev->flags)) {
David Brownellcb1cebb2007-02-15 18:52:30 -0800928 struct driver_info *info = dev->driver_info;
David Hollis7ea13c92005-04-22 15:07:02 -0700929 int retval = 0;
930
931 clear_bit (EVENT_LINK_RESET, &dev->flags);
932 if(info->link_reset && (retval = info->link_reset(dev)) < 0) {
933 devinfo(dev, "link reset failed (%d) usbnet usb-%s-%s, %s",
934 retval,
935 dev->udev->bus->bus_name, dev->udev->devpath,
936 info->description);
937 }
938 }
939
Linus Torvalds1da177e2005-04-16 15:20:36 -0700940 if (dev->flags)
941 devdbg (dev, "kevent done, flags = 0x%lx",
942 dev->flags);
943}
944
945/*-------------------------------------------------------------------------*/
946
David Howells7d12e782006-10-05 14:55:46 +0100947static void tx_complete (struct urb *urb)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700948{
949 struct sk_buff *skb = (struct sk_buff *) urb->context;
950 struct skb_data *entry = (struct skb_data *) skb->cb;
951 struct usbnet *dev = entry->dev;
952
953 if (urb->status == 0) {
Herbert Xu79638372009-06-29 16:53:28 +0000954 dev->net->stats.tx_packets++;
955 dev->net->stats.tx_bytes += entry->length;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700956 } else {
Herbert Xu79638372009-06-29 16:53:28 +0000957 dev->net->stats.tx_errors++;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700958
959 switch (urb->status) {
960 case -EPIPE:
David Brownell2e55cc72005-08-31 09:53:10 -0700961 usbnet_defer_kevent (dev, EVENT_TX_HALT);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700962 break;
963
964 /* software-driven interface shutdown */
965 case -ECONNRESET: // async unlink
966 case -ESHUTDOWN: // hardware gone
967 break;
968
969 // like rx, tx gets controller i/o faults during khubd delays
970 // and so it uses the same throttling mechanism.
Pete Zaitcev38e2bfc2006-09-18 22:49:02 -0700971 case -EPROTO:
972 case -ETIME:
973 case -EILSEQ:
Linus Torvalds1da177e2005-04-16 15:20:36 -0700974 if (!timer_pending (&dev->delay)) {
975 mod_timer (&dev->delay,
976 jiffies + THROTTLE_JIFFIES);
977 if (netif_msg_link (dev))
978 devdbg (dev, "tx throttle %d",
979 urb->status);
980 }
981 netif_stop_queue (dev->net);
982 break;
983 default:
984 if (netif_msg_tx_err (dev))
985 devdbg (dev, "tx err %d", entry->urb->status);
986 break;
987 }
988 }
989
990 urb->dev = NULL;
991 entry->state = tx_done;
David S. Miller8728b832005-08-09 19:25:21 -0700992 defer_bh(dev, skb, &dev->txq);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700993}
994
995/*-------------------------------------------------------------------------*/
996
Stephen Hemminger777baa42009-03-20 19:35:54 +0000997void usbnet_tx_timeout (struct net_device *net)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700998{
999 struct usbnet *dev = netdev_priv(net);
1000
1001 unlink_urbs (dev, &dev->txq);
1002 tasklet_schedule (&dev->bh);
1003
1004 // FIXME: device recovery -- reset?
1005}
Stephen Hemminger777baa42009-03-20 19:35:54 +00001006EXPORT_SYMBOL_GPL(usbnet_tx_timeout);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001007
1008/*-------------------------------------------------------------------------*/
1009
Stephen Hemminger25a79c42009-08-31 19:50:45 +00001010netdev_tx_t usbnet_start_xmit (struct sk_buff *skb,
1011 struct net_device *net)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001012{
1013 struct usbnet *dev = netdev_priv(net);
1014 int length;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001015 struct urb *urb = NULL;
1016 struct skb_data *entry;
1017 struct driver_info *info = dev->driver_info;
1018 unsigned long flags;
Stephen Hemminger25a79c42009-08-31 19:50:45 +00001019 int retval;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001020
1021 // some devices want funky USB-level framing, for
1022 // win32 driver (usually) and/or hardware quirks
1023 if (info->tx_fixup) {
1024 skb = info->tx_fixup (dev, skb, GFP_ATOMIC);
1025 if (!skb) {
1026 if (netif_msg_tx_err (dev))
1027 devdbg (dev, "can't tx_fixup skb");
1028 goto drop;
1029 }
1030 }
1031 length = skb->len;
1032
1033 if (!(urb = usb_alloc_urb (0, GFP_ATOMIC))) {
1034 if (netif_msg_tx_err (dev))
1035 devdbg (dev, "no urb");
1036 goto drop;
1037 }
1038
1039 entry = (struct skb_data *) skb->cb;
1040 entry->urb = urb;
1041 entry->dev = dev;
1042 entry->state = tx_start;
1043 entry->length = length;
1044
Linus Torvalds1da177e2005-04-16 15:20:36 -07001045 usb_fill_bulk_urb (urb, dev->udev, dev->out,
1046 skb->data, skb->len, tx_complete, skb);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001047
1048 /* don't assume the hardware handles USB_ZERO_PACKET
1049 * NOTE: strictly conforming cdc-ether devices should expect
1050 * the ZLP here, but ignore the one-byte packet.
Linus Torvalds1da177e2005-04-16 15:20:36 -07001051 */
Steve Glendinningec475622009-09-22 04:00:27 +00001052 if (!(info->flags & FLAG_SEND_ZLP) && (length % dev->maxpacket) == 0) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001053 urb->transfer_buffer_length++;
Peter Korsgaard3e323f32007-06-27 08:48:15 +02001054 if (skb_tailroom(skb)) {
1055 skb->data[skb->len] = 0;
1056 __skb_put(skb, 1);
1057 }
1058 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07001059
1060 spin_lock_irqsave (&dev->txq.lock, flags);
1061
Linus Torvalds1da177e2005-04-16 15:20:36 -07001062 switch ((retval = usb_submit_urb (urb, GFP_ATOMIC))) {
1063 case -EPIPE:
1064 netif_stop_queue (net);
David Brownell2e55cc72005-08-31 09:53:10 -07001065 usbnet_defer_kevent (dev, EVENT_TX_HALT);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001066 break;
1067 default:
1068 if (netif_msg_tx_err (dev))
1069 devdbg (dev, "tx: submit urb err %d", retval);
1070 break;
1071 case 0:
1072 net->trans_start = jiffies;
1073 __skb_queue_tail (&dev->txq, skb);
1074 if (dev->txq.qlen >= TX_QLEN (dev))
1075 netif_stop_queue (net);
1076 }
1077 spin_unlock_irqrestore (&dev->txq.lock, flags);
1078
1079 if (retval) {
1080 if (netif_msg_tx_err (dev))
1081 devdbg (dev, "drop, code %d", retval);
1082drop:
Herbert Xu79638372009-06-29 16:53:28 +00001083 dev->net->stats.tx_dropped++;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001084 if (skb)
1085 dev_kfree_skb_any (skb);
1086 usb_free_urb (urb);
1087 } else if (netif_msg_tx_queued (dev)) {
1088 devdbg (dev, "> tx, len %d, type 0x%x",
1089 length, skb->protocol);
1090 }
Stephen Hemminger25a79c42009-08-31 19:50:45 +00001091 return NETDEV_TX_OK;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001092}
Stephen Hemminger777baa42009-03-20 19:35:54 +00001093EXPORT_SYMBOL_GPL(usbnet_start_xmit);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001094
1095/*-------------------------------------------------------------------------*/
1096
1097// tasklet (work deferred from completions, in_irq) or timer
1098
1099static void usbnet_bh (unsigned long param)
1100{
1101 struct usbnet *dev = (struct usbnet *) param;
1102 struct sk_buff *skb;
1103 struct skb_data *entry;
1104
1105 while ((skb = skb_dequeue (&dev->done))) {
1106 entry = (struct skb_data *) skb->cb;
1107 switch (entry->state) {
David Brownell18ab4582007-05-25 12:31:32 -07001108 case rx_done:
Linus Torvalds1da177e2005-04-16 15:20:36 -07001109 entry->state = rx_cleanup;
1110 rx_process (dev, skb);
1111 continue;
David Brownell18ab4582007-05-25 12:31:32 -07001112 case tx_done:
1113 case rx_cleanup:
Linus Torvalds1da177e2005-04-16 15:20:36 -07001114 usb_free_urb (entry->urb);
1115 dev_kfree_skb (skb);
1116 continue;
David Brownell18ab4582007-05-25 12:31:32 -07001117 default:
Linus Torvalds1da177e2005-04-16 15:20:36 -07001118 devdbg (dev, "bogus skb state %d", entry->state);
1119 }
1120 }
1121
1122 // waiting for all pending urbs to complete?
1123 if (dev->wait) {
1124 if ((dev->txq.qlen + dev->rxq.qlen + dev->done.qlen) == 0) {
1125 wake_up (dev->wait);
1126 }
1127
1128 // or are we maybe short a few urbs?
1129 } else if (netif_running (dev->net)
1130 && netif_device_present (dev->net)
1131 && !timer_pending (&dev->delay)
1132 && !test_bit (EVENT_RX_HALT, &dev->flags)) {
1133 int temp = dev->rxq.qlen;
1134 int qlen = RX_QLEN (dev);
1135
1136 if (temp < qlen) {
1137 struct urb *urb;
1138 int i;
1139
1140 // don't refill the queue all at once
1141 for (i = 0; i < 10 && dev->rxq.qlen < qlen; i++) {
1142 urb = usb_alloc_urb (0, GFP_ATOMIC);
1143 if (urb != NULL)
1144 rx_submit (dev, urb, GFP_ATOMIC);
1145 }
1146 if (temp != dev->rxq.qlen && netif_msg_link (dev))
1147 devdbg (dev, "rxqlen %d --> %d",
1148 temp, dev->rxq.qlen);
1149 if (dev->rxq.qlen < qlen)
1150 tasklet_schedule (&dev->bh);
1151 }
1152 if (dev->txq.qlen < TX_QLEN (dev))
1153 netif_wake_queue (dev->net);
1154 }
1155}
1156
1157
Linus Torvalds1da177e2005-04-16 15:20:36 -07001158/*-------------------------------------------------------------------------
1159 *
1160 * USB Device Driver support
1161 *
1162 *-------------------------------------------------------------------------*/
David Brownellcb1cebb2007-02-15 18:52:30 -08001163
Linus Torvalds1da177e2005-04-16 15:20:36 -07001164// precondition: never called in_interrupt
1165
David Brownell38bde1d2005-08-31 09:52:45 -07001166void usbnet_disconnect (struct usb_interface *intf)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001167{
1168 struct usbnet *dev;
1169 struct usb_device *xdev;
1170 struct net_device *net;
1171
1172 dev = usb_get_intfdata(intf);
1173 usb_set_intfdata(intf, NULL);
1174 if (!dev)
1175 return;
1176
1177 xdev = interface_to_usbdev (intf);
1178
1179 if (netif_msg_probe (dev))
David Brownell38bde1d2005-08-31 09:52:45 -07001180 devinfo (dev, "unregister '%s' usb-%s-%s, %s",
1181 intf->dev.driver->name,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001182 xdev->bus->bus_name, xdev->devpath,
1183 dev->driver_info->description);
David Brownellcb1cebb2007-02-15 18:52:30 -08001184
Linus Torvalds1da177e2005-04-16 15:20:36 -07001185 net = dev->net;
1186 unregister_netdev (net);
1187
1188 /* we don't hold rtnl here ... */
1189 flush_scheduled_work ();
1190
1191 if (dev->driver_info->unbind)
1192 dev->driver_info->unbind (dev, intf);
1193
1194 free_netdev(net);
1195 usb_put_dev (xdev);
1196}
David Brownell38bde1d2005-08-31 09:52:45 -07001197EXPORT_SYMBOL_GPL(usbnet_disconnect);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001198
Stephen Hemminger777baa42009-03-20 19:35:54 +00001199static const struct net_device_ops usbnet_netdev_ops = {
1200 .ndo_open = usbnet_open,
1201 .ndo_stop = usbnet_stop,
1202 .ndo_start_xmit = usbnet_start_xmit,
1203 .ndo_tx_timeout = usbnet_tx_timeout,
1204 .ndo_change_mtu = usbnet_change_mtu,
1205 .ndo_set_mac_address = eth_mac_addr,
1206 .ndo_validate_addr = eth_validate_addr,
1207};
Linus Torvalds1da177e2005-04-16 15:20:36 -07001208
1209/*-------------------------------------------------------------------------*/
1210
Linus Torvalds1da177e2005-04-16 15:20:36 -07001211// precondition: never called in_interrupt
1212
David Brownell38bde1d2005-08-31 09:52:45 -07001213int
Linus Torvalds1da177e2005-04-16 15:20:36 -07001214usbnet_probe (struct usb_interface *udev, const struct usb_device_id *prod)
1215{
1216 struct usbnet *dev;
David Brownellcb1cebb2007-02-15 18:52:30 -08001217 struct net_device *net;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001218 struct usb_host_interface *interface;
1219 struct driver_info *info;
1220 struct usb_device *xdev;
1221 int status;
David Brownell296c0242007-04-17 16:10:10 -07001222 const char *name;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001223
David Brownell296c0242007-04-17 16:10:10 -07001224 name = udev->dev.driver->name;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001225 info = (struct driver_info *) prod->driver_info;
1226 if (!info) {
David Brownell296c0242007-04-17 16:10:10 -07001227 dev_dbg (&udev->dev, "blacklisted by %s\n", name);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001228 return -ENODEV;
1229 }
1230 xdev = interface_to_usbdev (udev);
1231 interface = udev->cur_altsetting;
1232
1233 usb_get_dev (xdev);
1234
1235 status = -ENOMEM;
1236
1237 // set up our own records
1238 net = alloc_etherdev(sizeof(*dev));
1239 if (!net) {
1240 dbg ("can't kmalloc dev");
1241 goto out;
1242 }
1243
1244 dev = netdev_priv(net);
1245 dev->udev = xdev;
Oliver Neukuma11a6542007-08-03 13:52:19 +02001246 dev->intf = udev;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001247 dev->driver_info = info;
David Brownell296c0242007-04-17 16:10:10 -07001248 dev->driver_name = name;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001249 dev->msg_enable = netif_msg_init (msg_level, NETIF_MSG_DRV
1250 | NETIF_MSG_PROBE | NETIF_MSG_LINK);
1251 skb_queue_head_init (&dev->rxq);
1252 skb_queue_head_init (&dev->txq);
1253 skb_queue_head_init (&dev->done);
Jussi Kivilinna7834ddb2009-08-11 22:57:16 +03001254 skb_queue_head_init(&dev->rxq_pause);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001255 dev->bh.func = usbnet_bh;
1256 dev->bh.data = (unsigned long) dev;
David Howellsc4028952006-11-22 14:57:56 +00001257 INIT_WORK (&dev->kevent, kevent);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001258 dev->delay.function = usbnet_bh;
1259 dev->delay.data = (unsigned long) dev;
1260 init_timer (&dev->delay);
Arnd Bergmanna9fc6332006-10-09 00:08:02 +02001261 mutex_init (&dev->phy_mutex);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001262
Linus Torvalds1da177e2005-04-16 15:20:36 -07001263 dev->net = net;
1264 strcpy (net->name, "usb%d");
1265 memcpy (net->dev_addr, node_id, sizeof node_id);
1266
David Brownell2e55cc72005-08-31 09:53:10 -07001267 /* rx and tx sides can use different message sizes;
1268 * bind() should set rx_urb_size in that case.
1269 */
1270 dev->hard_mtu = net->mtu + net->hard_header_len;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001271#if 0
1272// dma_supported() is deeply broken on almost all architectures
1273 // possible with some EHCI controllers
Yang Hongyang6a355282009-04-06 19:01:13 -07001274 if (dma_supported (&udev->dev, DMA_BIT_MASK(64)))
Linus Torvalds1da177e2005-04-16 15:20:36 -07001275 net->features |= NETIF_F_HIGHDMA;
1276#endif
1277
Stephen Hemminger777baa42009-03-20 19:35:54 +00001278 net->netdev_ops = &usbnet_netdev_ops;
Stephen Hemminger777baa42009-03-20 19:35:54 +00001279 net->watchdog_timeo = TX_TIMEOUT_JIFFIES;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001280 net->ethtool_ops = &usbnet_ethtool_ops;
1281
1282 // allow device-specific bind/init procedures
1283 // NOTE net->name still not usable ...
1284 if (info->bind) {
1285 status = info->bind (dev, udev);
David Brownellcb1cebb2007-02-15 18:52:30 -08001286 if (status < 0)
1287 goto out1;
1288
Linus Torvalds1da177e2005-04-16 15:20:36 -07001289 // heuristic: "usb%d" for links we know are two-host,
1290 // else "eth%d" when there's reasonable doubt. userspace
1291 // can rename the link if it knows better.
1292 if ((dev->driver_info->flags & FLAG_ETHER) != 0
1293 && (net->dev_addr [0] & 0x02) == 0)
1294 strcpy (net->name, "eth%d");
Jussi Kivilinna6e3bbcc2008-01-26 00:51:06 +02001295 /* WLAN devices should always be named "wlan%d" */
1296 if ((dev->driver_info->flags & FLAG_WLAN) != 0)
1297 strcpy(net->name, "wlan%d");
Marcel Holtmanne1e499e2009-10-02 05:15:25 +00001298 /* WWAN devices should always be named "wwan%d" */
1299 if ((dev->driver_info->flags & FLAG_WWAN) != 0)
1300 strcpy(net->name, "wwan%d");
David Brownellf29fc252005-08-31 09:52:31 -07001301
1302 /* maybe the remote can't receive an Ethernet MTU */
1303 if (net->mtu > (dev->hard_mtu - net->hard_header_len))
1304 net->mtu = dev->hard_mtu - net->hard_header_len;
David Brownell2e55cc72005-08-31 09:53:10 -07001305 } else if (!info->in || !info->out)
1306 status = usbnet_get_endpoints (dev, udev);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001307 else {
1308 dev->in = usb_rcvbulkpipe (xdev, info->in);
1309 dev->out = usb_sndbulkpipe (xdev, info->out);
1310 if (!(info->flags & FLAG_NO_SETINT))
1311 status = usb_set_interface (xdev,
1312 interface->desc.bInterfaceNumber,
1313 interface->desc.bAlternateSetting);
1314 else
1315 status = 0;
1316
1317 }
Peter Korsgaard9514bfe2007-07-03 00:46:42 +02001318 if (status >= 0 && dev->status)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001319 status = init_status (dev, udev);
1320 if (status < 0)
David Brownellcb1cebb2007-02-15 18:52:30 -08001321 goto out3;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001322
David Brownell2e55cc72005-08-31 09:53:10 -07001323 if (!dev->rx_urb_size)
1324 dev->rx_urb_size = dev->hard_mtu;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001325 dev->maxpacket = usb_maxpacket (dev->udev, dev->out, 1);
David Brownellcb1cebb2007-02-15 18:52:30 -08001326
Linus Torvalds1da177e2005-04-16 15:20:36 -07001327 SET_NETDEV_DEV(net, &udev->dev);
1328 status = register_netdev (net);
1329 if (status)
1330 goto out3;
1331 if (netif_msg_probe (dev))
Johannes Berge1749612008-10-27 15:59:26 -07001332 devinfo (dev, "register '%s' at usb-%s-%s, %s, %pM",
David Brownell38bde1d2005-08-31 09:52:45 -07001333 udev->dev.driver->name,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001334 xdev->bus->bus_name, xdev->devpath,
1335 dev->driver_info->description,
Johannes Berge1749612008-10-27 15:59:26 -07001336 net->dev_addr);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001337
1338 // ok, it's ready to go.
1339 usb_set_intfdata (udev, dev);
1340
1341 // start as if the link is up
1342 netif_device_attach (net);
1343
1344 return 0;
1345
1346out3:
1347 if (info->unbind)
1348 info->unbind (dev, udev);
1349out1:
1350 free_netdev(net);
1351out:
1352 usb_put_dev(xdev);
1353 return status;
1354}
David Brownell38bde1d2005-08-31 09:52:45 -07001355EXPORT_SYMBOL_GPL(usbnet_probe);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001356
1357/*-------------------------------------------------------------------------*/
1358
Oliver Neukum36433122007-04-30 01:37:44 -07001359/*
1360 * suspend the whole driver as soon as the first interface is suspended
1361 * resume only when the last interface is resumed
David Brownell38bde1d2005-08-31 09:52:45 -07001362 */
Linus Torvalds1da177e2005-04-16 15:20:36 -07001363
David Brownell38bde1d2005-08-31 09:52:45 -07001364int usbnet_suspend (struct usb_interface *intf, pm_message_t message)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001365{
1366 struct usbnet *dev = usb_get_intfdata(intf);
David Brownellcb1cebb2007-02-15 18:52:30 -08001367
Oliver Neukum36433122007-04-30 01:37:44 -07001368 if (!dev->suspend_count++) {
Oliver Neukuma11a6542007-08-03 13:52:19 +02001369 /*
1370 * accelerate emptying of the rx and queues, to avoid
Oliver Neukum36433122007-04-30 01:37:44 -07001371 * having everything error out.
1372 */
1373 netif_device_detach (dev->net);
1374 (void) unlink_urbs (dev, &dev->rxq);
1375 (void) unlink_urbs (dev, &dev->txq);
Oliver Neukuma11a6542007-08-03 13:52:19 +02001376 /*
1377 * reattach so runtime management can use and
1378 * wake the device
1379 */
1380 netif_device_attach (dev->net);
Oliver Neukum36433122007-04-30 01:37:44 -07001381 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07001382 return 0;
1383}
David Brownell38bde1d2005-08-31 09:52:45 -07001384EXPORT_SYMBOL_GPL(usbnet_suspend);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001385
David Brownell38bde1d2005-08-31 09:52:45 -07001386int usbnet_resume (struct usb_interface *intf)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001387{
1388 struct usbnet *dev = usb_get_intfdata(intf);
1389
Oliver Neukuma11a6542007-08-03 13:52:19 +02001390 if (!--dev->suspend_count)
Oliver Neukum36433122007-04-30 01:37:44 -07001391 tasklet_schedule (&dev->bh);
Oliver Neukuma11a6542007-08-03 13:52:19 +02001392
Linus Torvalds1da177e2005-04-16 15:20:36 -07001393 return 0;
1394}
David Brownell38bde1d2005-08-31 09:52:45 -07001395EXPORT_SYMBOL_GPL(usbnet_resume);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001396
Linus Torvalds1da177e2005-04-16 15:20:36 -07001397
1398/*-------------------------------------------------------------------------*/
1399
David Brownellf29fc252005-08-31 09:52:31 -07001400static int __init usbnet_init(void)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001401{
David Brownell090ffa92005-08-31 09:54:50 -07001402 /* compiler should optimize this out */
Alexey Dobriyanf8ac2322006-10-08 16:02:00 +04001403 BUILD_BUG_ON (sizeof (((struct sk_buff *)0)->cb)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001404 < sizeof (struct skb_data));
Linus Torvalds1da177e2005-04-16 15:20:36 -07001405
1406 random_ether_addr(node_id);
David Brownellcb1cebb2007-02-15 18:52:30 -08001407 return 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001408}
David Brownellf29fc252005-08-31 09:52:31 -07001409module_init(usbnet_init);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001410
David Brownellf29fc252005-08-31 09:52:31 -07001411static void __exit usbnet_exit(void)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001412{
Linus Torvalds1da177e2005-04-16 15:20:36 -07001413}
David Brownellf29fc252005-08-31 09:52:31 -07001414module_exit(usbnet_exit);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001415
David Brownellf29fc252005-08-31 09:52:31 -07001416MODULE_AUTHOR("David Brownell");
David Brownell090ffa92005-08-31 09:54:50 -07001417MODULE_DESCRIPTION("USB network driver framework");
David Brownellf29fc252005-08-31 09:52:31 -07001418MODULE_LICENSE("GPL");