diff options
Diffstat (limited to 'drivers/net/usb/usbnet.c')
-rw-r--r-- | drivers/net/usb/usbnet.c | 449 |
1 files changed, 272 insertions, 177 deletions
diff --git a/drivers/net/usb/usbnet.c b/drivers/net/usb/usbnet.c index ca5ca5ae061d..7177abc78dc6 100644 --- a/drivers/net/usb/usbnet.c +++ b/drivers/net/usb/usbnet.c | |||
@@ -43,6 +43,7 @@ | |||
43 | #include <linux/mii.h> | 43 | #include <linux/mii.h> |
44 | #include <linux/usb.h> | 44 | #include <linux/usb.h> |
45 | #include <linux/usb/usbnet.h> | 45 | #include <linux/usb/usbnet.h> |
46 | #include <linux/slab.h> | ||
46 | 47 | ||
47 | #define DRIVER_VERSION "22-Aug-2005" | 48 | #define DRIVER_VERSION "22-Aug-2005" |
48 | 49 | ||
@@ -140,8 +141,8 @@ int usbnet_get_endpoints(struct usbnet *dev, struct usb_interface *intf) | |||
140 | if (!alt || !in || !out) | 141 | if (!alt || !in || !out) |
141 | return -EINVAL; | 142 | return -EINVAL; |
142 | 143 | ||
143 | if (alt->desc.bAlternateSetting != 0 | 144 | if (alt->desc.bAlternateSetting != 0 || |
144 | || !(dev->driver_info->flags & FLAG_NO_SETINT)) { | 145 | !(dev->driver_info->flags & FLAG_NO_SETINT)) { |
145 | tmp = usb_set_interface (dev->udev, alt->desc.bInterfaceNumber, | 146 | tmp = usb_set_interface (dev->udev, alt->desc.bInterfaceNumber, |
146 | alt->desc.bAlternateSetting); | 147 | alt->desc.bAlternateSetting); |
147 | if (tmp < 0) | 148 | if (tmp < 0) |
@@ -242,13 +243,13 @@ void usbnet_skb_return (struct usbnet *dev, struct sk_buff *skb) | |||
242 | dev->net->stats.rx_packets++; | 243 | dev->net->stats.rx_packets++; |
243 | dev->net->stats.rx_bytes += skb->len; | 244 | dev->net->stats.rx_bytes += skb->len; |
244 | 245 | ||
245 | if (netif_msg_rx_status (dev)) | 246 | netif_dbg(dev, rx_status, dev->net, "< rx, len %zu, type 0x%x\n", |
246 | devdbg (dev, "< rx, len %zu, type 0x%x", | 247 | skb->len + sizeof (struct ethhdr), skb->protocol); |
247 | skb->len + sizeof (struct ethhdr), skb->protocol); | ||
248 | memset (skb->cb, 0, sizeof (struct skb_data)); | 248 | memset (skb->cb, 0, sizeof (struct skb_data)); |
249 | status = netif_rx (skb); | 249 | status = netif_rx (skb); |
250 | if (status != NET_RX_SUCCESS && netif_msg_rx_err (dev)) | 250 | if (status != NET_RX_SUCCESS) |
251 | devdbg (dev, "netif_rx status %d", status); | 251 | netif_dbg(dev, rx_err, dev->net, |
252 | "netif_rx status %d\n", status); | ||
252 | } | 253 | } |
253 | EXPORT_SYMBOL_GPL(usbnet_skb_return); | 254 | EXPORT_SYMBOL_GPL(usbnet_skb_return); |
254 | 255 | ||
@@ -313,9 +314,9 @@ void usbnet_defer_kevent (struct usbnet *dev, int work) | |||
313 | { | 314 | { |
314 | set_bit (work, &dev->flags); | 315 | set_bit (work, &dev->flags); |
315 | if (!schedule_work (&dev->kevent)) | 316 | if (!schedule_work (&dev->kevent)) |
316 | deverr (dev, "kevent %d may have been dropped", work); | 317 | netdev_err(dev->net, "kevent %d may have been dropped\n", work); |
317 | else | 318 | else |
318 | devdbg (dev, "kevent %d scheduled", work); | 319 | netdev_dbg(dev->net, "kevent %d scheduled\n", work); |
319 | } | 320 | } |
320 | EXPORT_SYMBOL_GPL(usbnet_defer_kevent); | 321 | EXPORT_SYMBOL_GPL(usbnet_defer_kevent); |
321 | 322 | ||
@@ -332,8 +333,7 @@ static void rx_submit (struct usbnet *dev, struct urb *urb, gfp_t flags) | |||
332 | size_t size = dev->rx_urb_size; | 333 | size_t size = dev->rx_urb_size; |
333 | 334 | ||
334 | if ((skb = alloc_skb (size + NET_IP_ALIGN, flags)) == NULL) { | 335 | if ((skb = alloc_skb (size + NET_IP_ALIGN, flags)) == NULL) { |
335 | if (netif_msg_rx_err (dev)) | 336 | netif_dbg(dev, rx_err, dev->net, "no rx skb\n"); |
336 | devdbg (dev, "no rx skb"); | ||
337 | usbnet_defer_kevent (dev, EVENT_RX_MEMORY); | 337 | usbnet_defer_kevent (dev, EVENT_RX_MEMORY); |
338 | usb_free_urb (urb); | 338 | usb_free_urb (urb); |
339 | return; | 339 | return; |
@@ -351,9 +351,10 @@ static void rx_submit (struct usbnet *dev, struct urb *urb, gfp_t flags) | |||
351 | 351 | ||
352 | spin_lock_irqsave (&dev->rxq.lock, lockflags); | 352 | spin_lock_irqsave (&dev->rxq.lock, lockflags); |
353 | 353 | ||
354 | if (netif_running (dev->net) | 354 | if (netif_running (dev->net) && |
355 | && netif_device_present (dev->net) | 355 | netif_device_present (dev->net) && |
356 | && !test_bit (EVENT_RX_HALT, &dev->flags)) { | 356 | !test_bit (EVENT_RX_HALT, &dev->flags) && |
357 | !test_bit (EVENT_DEV_ASLEEP, &dev->flags)) { | ||
357 | switch (retval = usb_submit_urb (urb, GFP_ATOMIC)) { | 358 | switch (retval = usb_submit_urb (urb, GFP_ATOMIC)) { |
358 | case -EPIPE: | 359 | case -EPIPE: |
359 | usbnet_defer_kevent (dev, EVENT_RX_HALT); | 360 | usbnet_defer_kevent (dev, EVENT_RX_HALT); |
@@ -362,21 +363,19 @@ static void rx_submit (struct usbnet *dev, struct urb *urb, gfp_t flags) | |||
362 | usbnet_defer_kevent (dev, EVENT_RX_MEMORY); | 363 | usbnet_defer_kevent (dev, EVENT_RX_MEMORY); |
363 | break; | 364 | break; |
364 | case -ENODEV: | 365 | case -ENODEV: |
365 | if (netif_msg_ifdown (dev)) | 366 | netif_dbg(dev, ifdown, dev->net, "device gone\n"); |
366 | devdbg (dev, "device gone"); | ||
367 | netif_device_detach (dev->net); | 367 | netif_device_detach (dev->net); |
368 | break; | 368 | break; |
369 | default: | 369 | default: |
370 | if (netif_msg_rx_err (dev)) | 370 | netif_dbg(dev, rx_err, dev->net, |
371 | devdbg (dev, "rx submit, %d", retval); | 371 | "rx submit, %d\n", retval); |
372 | tasklet_schedule (&dev->bh); | 372 | tasklet_schedule (&dev->bh); |
373 | break; | 373 | break; |
374 | case 0: | 374 | case 0: |
375 | __skb_queue_tail (&dev->rxq, skb); | 375 | __skb_queue_tail (&dev->rxq, skb); |
376 | } | 376 | } |
377 | } else { | 377 | } else { |
378 | if (netif_msg_ifdown (dev)) | 378 | netif_dbg(dev, ifdown, dev->net, "rx: stopped\n"); |
379 | devdbg (dev, "rx: stopped"); | ||
380 | retval = -ENOLINK; | 379 | retval = -ENOLINK; |
381 | } | 380 | } |
382 | spin_unlock_irqrestore (&dev->rxq.lock, lockflags); | 381 | spin_unlock_irqrestore (&dev->rxq.lock, lockflags); |
@@ -391,16 +390,15 @@ static void rx_submit (struct usbnet *dev, struct urb *urb, gfp_t flags) | |||
391 | 390 | ||
392 | static inline void rx_process (struct usbnet *dev, struct sk_buff *skb) | 391 | static inline void rx_process (struct usbnet *dev, struct sk_buff *skb) |
393 | { | 392 | { |
394 | if (dev->driver_info->rx_fixup | 393 | if (dev->driver_info->rx_fixup && |
395 | && !dev->driver_info->rx_fixup (dev, skb)) | 394 | !dev->driver_info->rx_fixup (dev, skb)) |
396 | goto error; | 395 | goto error; |
397 | // else network stack removes extra byte if we forced a short packet | 396 | // else network stack removes extra byte if we forced a short packet |
398 | 397 | ||
399 | if (skb->len) | 398 | if (skb->len) |
400 | usbnet_skb_return (dev, skb); | 399 | usbnet_skb_return (dev, skb); |
401 | else { | 400 | else { |
402 | if (netif_msg_rx_err (dev)) | 401 | netif_dbg(dev, rx_err, dev->net, "drop\n"); |
403 | devdbg (dev, "drop"); | ||
404 | error: | 402 | error: |
405 | dev->net->stats.rx_errors++; | 403 | dev->net->stats.rx_errors++; |
406 | skb_queue_tail (&dev->done, skb); | 404 | skb_queue_tail (&dev->done, skb); |
@@ -427,8 +425,8 @@ static void rx_complete (struct urb *urb) | |||
427 | entry->state = rx_cleanup; | 425 | entry->state = rx_cleanup; |
428 | dev->net->stats.rx_errors++; | 426 | dev->net->stats.rx_errors++; |
429 | dev->net->stats.rx_length_errors++; | 427 | dev->net->stats.rx_length_errors++; |
430 | if (netif_msg_rx_err (dev)) | 428 | netif_dbg(dev, rx_err, dev->net, |
431 | devdbg (dev, "rx length %d", skb->len); | 429 | "rx length %d\n", skb->len); |
432 | } | 430 | } |
433 | break; | 431 | break; |
434 | 432 | ||
@@ -445,8 +443,8 @@ static void rx_complete (struct urb *urb) | |||
445 | /* software-driven interface shutdown */ | 443 | /* software-driven interface shutdown */ |
446 | case -ECONNRESET: /* async unlink */ | 444 | case -ECONNRESET: /* async unlink */ |
447 | case -ESHUTDOWN: /* hardware gone */ | 445 | case -ESHUTDOWN: /* hardware gone */ |
448 | if (netif_msg_ifdown (dev)) | 446 | netif_dbg(dev, ifdown, dev->net, |
449 | devdbg (dev, "rx shutdown, code %d", urb_status); | 447 | "rx shutdown, code %d\n", urb_status); |
450 | goto block; | 448 | goto block; |
451 | 449 | ||
452 | /* we get controller i/o faults during khubd disconnect() delays. | 450 | /* we get controller i/o faults during khubd disconnect() delays. |
@@ -459,8 +457,8 @@ static void rx_complete (struct urb *urb) | |||
459 | dev->net->stats.rx_errors++; | 457 | dev->net->stats.rx_errors++; |
460 | if (!timer_pending (&dev->delay)) { | 458 | if (!timer_pending (&dev->delay)) { |
461 | mod_timer (&dev->delay, jiffies + THROTTLE_JIFFIES); | 459 | mod_timer (&dev->delay, jiffies + THROTTLE_JIFFIES); |
462 | if (netif_msg_link (dev)) | 460 | netif_dbg(dev, link, dev->net, |
463 | devdbg (dev, "rx throttle %d", urb_status); | 461 | "rx throttle %d\n", urb_status); |
464 | } | 462 | } |
465 | block: | 463 | block: |
466 | entry->state = rx_cleanup; | 464 | entry->state = rx_cleanup; |
@@ -476,23 +474,21 @@ block: | |||
476 | default: | 474 | default: |
477 | entry->state = rx_cleanup; | 475 | entry->state = rx_cleanup; |
478 | dev->net->stats.rx_errors++; | 476 | dev->net->stats.rx_errors++; |
479 | if (netif_msg_rx_err (dev)) | 477 | netif_dbg(dev, rx_err, dev->net, "rx status %d\n", urb_status); |
480 | devdbg (dev, "rx status %d", urb_status); | ||
481 | break; | 478 | break; |
482 | } | 479 | } |
483 | 480 | ||
484 | defer_bh(dev, skb, &dev->rxq); | 481 | defer_bh(dev, skb, &dev->rxq); |
485 | 482 | ||
486 | if (urb) { | 483 | if (urb) { |
487 | if (netif_running (dev->net) | 484 | if (netif_running (dev->net) && |
488 | && !test_bit (EVENT_RX_HALT, &dev->flags)) { | 485 | !test_bit (EVENT_RX_HALT, &dev->flags)) { |
489 | rx_submit (dev, urb, GFP_ATOMIC); | 486 | rx_submit (dev, urb, GFP_ATOMIC); |
490 | return; | 487 | return; |
491 | } | 488 | } |
492 | usb_free_urb (urb); | 489 | usb_free_urb (urb); |
493 | } | 490 | } |
494 | if (netif_msg_rx_err (dev)) | 491 | netif_dbg(dev, rx_err, dev->net, "no read resubmitted\n"); |
495 | devdbg (dev, "no read resubmitted"); | ||
496 | } | 492 | } |
497 | 493 | ||
498 | static void intr_complete (struct urb *urb) | 494 | static void intr_complete (struct urb *urb) |
@@ -509,15 +505,15 @@ static void intr_complete (struct urb *urb) | |||
509 | /* software-driven interface shutdown */ | 505 | /* software-driven interface shutdown */ |
510 | case -ENOENT: /* urb killed */ | 506 | case -ENOENT: /* urb killed */ |
511 | case -ESHUTDOWN: /* hardware gone */ | 507 | case -ESHUTDOWN: /* hardware gone */ |
512 | if (netif_msg_ifdown (dev)) | 508 | netif_dbg(dev, ifdown, dev->net, |
513 | devdbg (dev, "intr shutdown, code %d", status); | 509 | "intr shutdown, code %d\n", status); |
514 | return; | 510 | return; |
515 | 511 | ||
516 | /* NOTE: not throttling like RX/TX, since this endpoint | 512 | /* NOTE: not throttling like RX/TX, since this endpoint |
517 | * already polls infrequently | 513 | * already polls infrequently |
518 | */ | 514 | */ |
519 | default: | 515 | default: |
520 | devdbg (dev, "intr status %d", status); | 516 | netdev_dbg(dev->net, "intr status %d\n", status); |
521 | break; | 517 | break; |
522 | } | 518 | } |
523 | 519 | ||
@@ -526,8 +522,9 @@ static void intr_complete (struct urb *urb) | |||
526 | 522 | ||
527 | memset(urb->transfer_buffer, 0, urb->transfer_buffer_length); | 523 | memset(urb->transfer_buffer, 0, urb->transfer_buffer_length); |
528 | status = usb_submit_urb (urb, GFP_ATOMIC); | 524 | status = usb_submit_urb (urb, GFP_ATOMIC); |
529 | if (status != 0 && netif_msg_timer (dev)) | 525 | if (status != 0) |
530 | deverr(dev, "intr resubmit --> %d", status); | 526 | netif_err(dev, timer, dev->net, |
527 | "intr resubmit --> %d\n", status); | ||
531 | } | 528 | } |
532 | 529 | ||
533 | /*-------------------------------------------------------------------------*/ | 530 | /*-------------------------------------------------------------------------*/ |
@@ -535,8 +532,7 @@ void usbnet_pause_rx(struct usbnet *dev) | |||
535 | { | 532 | { |
536 | set_bit(EVENT_RX_PAUSED, &dev->flags); | 533 | set_bit(EVENT_RX_PAUSED, &dev->flags); |
537 | 534 | ||
538 | if (netif_msg_rx_status(dev)) | 535 | netif_dbg(dev, rx_status, dev->net, "paused rx queue enabled\n"); |
539 | devdbg(dev, "paused rx queue enabled"); | ||
540 | } | 536 | } |
541 | EXPORT_SYMBOL_GPL(usbnet_pause_rx); | 537 | EXPORT_SYMBOL_GPL(usbnet_pause_rx); |
542 | 538 | ||
@@ -554,8 +550,8 @@ void usbnet_resume_rx(struct usbnet *dev) | |||
554 | 550 | ||
555 | tasklet_schedule(&dev->bh); | 551 | tasklet_schedule(&dev->bh); |
556 | 552 | ||
557 | if (netif_msg_rx_status(dev)) | 553 | netif_dbg(dev, rx_status, dev->net, |
558 | devdbg(dev, "paused rx queue disabled, %d skbs requeued", num); | 554 | "paused rx queue disabled, %d skbs requeued\n", num); |
559 | } | 555 | } |
560 | EXPORT_SYMBOL_GPL(usbnet_resume_rx); | 556 | EXPORT_SYMBOL_GPL(usbnet_resume_rx); |
561 | 557 | ||
@@ -588,7 +584,7 @@ static int unlink_urbs (struct usbnet *dev, struct sk_buff_head *q) | |||
588 | // these (async) unlinks complete immediately | 584 | // these (async) unlinks complete immediately |
589 | retval = usb_unlink_urb (urb); | 585 | retval = usb_unlink_urb (urb); |
590 | if (retval != -EINPROGRESS && retval != 0) | 586 | if (retval != -EINPROGRESS && retval != 0) |
591 | devdbg (dev, "unlink urb err, %d", retval); | 587 | netdev_dbg(dev->net, "unlink urb err, %d\n", retval); |
592 | else | 588 | else |
593 | count++; | 589 | count++; |
594 | } | 590 | } |
@@ -611,55 +607,60 @@ EXPORT_SYMBOL_GPL(usbnet_unlink_rx_urbs); | |||
611 | /*-------------------------------------------------------------------------*/ | 607 | /*-------------------------------------------------------------------------*/ |
612 | 608 | ||
613 | // precondition: never called in_interrupt | 609 | // precondition: never called in_interrupt |
610 | static void usbnet_terminate_urbs(struct usbnet *dev) | ||
611 | { | ||
612 | DECLARE_WAIT_QUEUE_HEAD_ONSTACK(unlink_wakeup); | ||
613 | DECLARE_WAITQUEUE(wait, current); | ||
614 | int temp; | ||
615 | |||
616 | /* ensure there are no more active urbs */ | ||
617 | add_wait_queue(&unlink_wakeup, &wait); | ||
618 | set_current_state(TASK_UNINTERRUPTIBLE); | ||
619 | dev->wait = &unlink_wakeup; | ||
620 | temp = unlink_urbs(dev, &dev->txq) + | ||
621 | unlink_urbs(dev, &dev->rxq); | ||
622 | |||
623 | /* maybe wait for deletions to finish. */ | ||
624 | while (!skb_queue_empty(&dev->rxq) | ||
625 | && !skb_queue_empty(&dev->txq) | ||
626 | && !skb_queue_empty(&dev->done)) { | ||
627 | schedule_timeout(UNLINK_TIMEOUT_MS); | ||
628 | set_current_state(TASK_UNINTERRUPTIBLE); | ||
629 | netif_dbg(dev, ifdown, dev->net, | ||
630 | "waited for %d urb completions\n", temp); | ||
631 | } | ||
632 | set_current_state(TASK_RUNNING); | ||
633 | dev->wait = NULL; | ||
634 | remove_wait_queue(&unlink_wakeup, &wait); | ||
635 | } | ||
614 | 636 | ||
615 | int usbnet_stop (struct net_device *net) | 637 | int usbnet_stop (struct net_device *net) |
616 | { | 638 | { |
617 | struct usbnet *dev = netdev_priv(net); | 639 | struct usbnet *dev = netdev_priv(net); |
618 | struct driver_info *info = dev->driver_info; | 640 | struct driver_info *info = dev->driver_info; |
619 | int temp; | ||
620 | int retval; | 641 | int retval; |
621 | DECLARE_WAIT_QUEUE_HEAD_ONSTACK (unlink_wakeup); | ||
622 | DECLARE_WAITQUEUE (wait, current); | ||
623 | 642 | ||
624 | netif_stop_queue (net); | 643 | netif_stop_queue (net); |
625 | 644 | ||
626 | if (netif_msg_ifdown (dev)) | 645 | netif_info(dev, ifdown, dev->net, |
627 | devinfo (dev, "stop stats: rx/tx %ld/%ld, errs %ld/%ld", | 646 | "stop stats: rx/tx %ld/%ld, errs %ld/%ld\n", |
628 | net->stats.rx_packets, net->stats.tx_packets, | 647 | net->stats.rx_packets, net->stats.tx_packets, |
629 | net->stats.rx_errors, net->stats.tx_errors | 648 | net->stats.rx_errors, net->stats.tx_errors); |
630 | ); | ||
631 | 649 | ||
632 | /* allow minidriver to stop correctly (wireless devices to turn off | 650 | /* allow minidriver to stop correctly (wireless devices to turn off |
633 | * radio etc) */ | 651 | * radio etc) */ |
634 | if (info->stop) { | 652 | if (info->stop) { |
635 | retval = info->stop(dev); | 653 | retval = info->stop(dev); |
636 | if (retval < 0 && netif_msg_ifdown(dev)) | 654 | if (retval < 0) |
637 | devinfo(dev, | 655 | netif_info(dev, ifdown, dev->net, |
638 | "stop fail (%d) usbnet usb-%s-%s, %s", | 656 | "stop fail (%d) usbnet usb-%s-%s, %s\n", |
639 | retval, | 657 | retval, |
640 | dev->udev->bus->bus_name, dev->udev->devpath, | 658 | dev->udev->bus->bus_name, dev->udev->devpath, |
641 | info->description); | 659 | info->description); |
642 | } | 660 | } |
643 | 661 | ||
644 | if (!(info->flags & FLAG_AVOID_UNLINK_URBS)) { | 662 | if (!(info->flags & FLAG_AVOID_UNLINK_URBS)) |
645 | /* ensure there are no more active urbs */ | 663 | usbnet_terminate_urbs(dev); |
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); | ||
650 | |||
651 | /* 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); | ||
662 | } | ||
663 | 664 | ||
664 | usb_kill_urb(dev->interrupt); | 665 | usb_kill_urb(dev->interrupt); |
665 | 666 | ||
@@ -672,7 +673,10 @@ int usbnet_stop (struct net_device *net) | |||
672 | dev->flags = 0; | 673 | dev->flags = 0; |
673 | del_timer_sync (&dev->delay); | 674 | del_timer_sync (&dev->delay); |
674 | tasklet_kill (&dev->bh); | 675 | tasklet_kill (&dev->bh); |
675 | usb_autopm_put_interface(dev->intf); | 676 | if (info->manage_power) |
677 | info->manage_power(dev, 0); | ||
678 | else | ||
679 | usb_autopm_put_interface(dev->intf); | ||
676 | 680 | ||
677 | return 0; | 681 | return 0; |
678 | } | 682 | } |
@@ -691,30 +695,29 @@ int usbnet_open (struct net_device *net) | |||
691 | struct driver_info *info = dev->driver_info; | 695 | struct driver_info *info = dev->driver_info; |
692 | 696 | ||
693 | if ((retval = usb_autopm_get_interface(dev->intf)) < 0) { | 697 | if ((retval = usb_autopm_get_interface(dev->intf)) < 0) { |
694 | if (netif_msg_ifup (dev)) | 698 | netif_info(dev, ifup, dev->net, |
695 | devinfo (dev, | 699 | "resumption fail (%d) usbnet usb-%s-%s, %s\n", |
696 | "resumption fail (%d) usbnet usb-%s-%s, %s", | 700 | retval, |
697 | retval, | 701 | dev->udev->bus->bus_name, |
698 | dev->udev->bus->bus_name, dev->udev->devpath, | 702 | dev->udev->devpath, |
699 | info->description); | 703 | info->description); |
700 | goto done_nopm; | 704 | goto done_nopm; |
701 | } | 705 | } |
702 | 706 | ||
703 | // put into "known safe" state | 707 | // put into "known safe" state |
704 | if (info->reset && (retval = info->reset (dev)) < 0) { | 708 | if (info->reset && (retval = info->reset (dev)) < 0) { |
705 | if (netif_msg_ifup (dev)) | 709 | netif_info(dev, ifup, dev->net, |
706 | devinfo (dev, | 710 | "open reset fail (%d) usbnet usb-%s-%s, %s\n", |
707 | "open reset fail (%d) usbnet usb-%s-%s, %s", | 711 | retval, |
708 | retval, | 712 | dev->udev->bus->bus_name, |
709 | dev->udev->bus->bus_name, dev->udev->devpath, | 713 | dev->udev->devpath, |
710 | info->description); | 714 | info->description); |
711 | goto done; | 715 | goto done; |
712 | } | 716 | } |
713 | 717 | ||
714 | // insist peer be connected | 718 | // insist peer be connected |
715 | if (info->check_connect && (retval = info->check_connect (dev)) < 0) { | 719 | if (info->check_connect && (retval = info->check_connect (dev)) < 0) { |
716 | if (netif_msg_ifup (dev)) | 720 | netif_dbg(dev, ifup, dev->net, "can't open; %d\n", retval); |
717 | devdbg (dev, "can't open; %d", retval); | ||
718 | goto done; | 721 | goto done; |
719 | } | 722 | } |
720 | 723 | ||
@@ -722,38 +725,34 @@ int usbnet_open (struct net_device *net) | |||
722 | if (dev->interrupt) { | 725 | if (dev->interrupt) { |
723 | retval = usb_submit_urb (dev->interrupt, GFP_KERNEL); | 726 | retval = usb_submit_urb (dev->interrupt, GFP_KERNEL); |
724 | if (retval < 0) { | 727 | if (retval < 0) { |
725 | if (netif_msg_ifup (dev)) | 728 | netif_err(dev, ifup, dev->net, |
726 | deverr (dev, "intr submit %d", retval); | 729 | "intr submit %d\n", retval); |
727 | goto done; | 730 | goto done; |
728 | } | 731 | } |
729 | } | 732 | } |
730 | 733 | ||
731 | netif_start_queue (net); | 734 | netif_start_queue (net); |
732 | if (netif_msg_ifup (dev)) { | 735 | netif_info(dev, ifup, dev->net, |
733 | char *framing; | 736 | "open: enable queueing (rx %d, tx %d) mtu %d %s framing\n", |
734 | 737 | (int)RX_QLEN(dev), (int)TX_QLEN(dev), | |
735 | if (dev->driver_info->flags & FLAG_FRAMING_NC) | 738 | dev->net->mtu, |
736 | framing = "NetChip"; | 739 | (dev->driver_info->flags & FLAG_FRAMING_NC) ? "NetChip" : |
737 | else if (dev->driver_info->flags & FLAG_FRAMING_GL) | 740 | (dev->driver_info->flags & FLAG_FRAMING_GL) ? "GeneSys" : |
738 | framing = "GeneSys"; | 741 | (dev->driver_info->flags & FLAG_FRAMING_Z) ? "Zaurus" : |
739 | else if (dev->driver_info->flags & FLAG_FRAMING_Z) | 742 | (dev->driver_info->flags & FLAG_FRAMING_RN) ? "RNDIS" : |
740 | framing = "Zaurus"; | 743 | (dev->driver_info->flags & FLAG_FRAMING_AX) ? "ASIX" : |
741 | else if (dev->driver_info->flags & FLAG_FRAMING_RN) | 744 | "simple"); |
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", | ||
750 | (int)RX_QLEN (dev), (int)TX_QLEN (dev), dev->net->mtu, | ||
751 | framing); | ||
752 | } | ||
753 | 745 | ||
754 | // delay posting reads until we're fully open | 746 | // delay posting reads until we're fully open |
755 | tasklet_schedule (&dev->bh); | 747 | tasklet_schedule (&dev->bh); |
748 | if (info->manage_power) { | ||
749 | retval = info->manage_power(dev, 1); | ||
750 | if (retval < 0) | ||
751 | goto done; | ||
752 | usb_autopm_put_interface(dev->intf); | ||
753 | } | ||
756 | return retval; | 754 | return retval; |
755 | |||
757 | done: | 756 | done: |
758 | usb_autopm_put_interface(dev->intf); | 757 | usb_autopm_put_interface(dev->intf); |
759 | done_nopm: | 758 | done_nopm: |
@@ -881,13 +880,18 @@ kevent (struct work_struct *work) | |||
881 | /* usb_clear_halt() needs a thread context */ | 880 | /* usb_clear_halt() needs a thread context */ |
882 | if (test_bit (EVENT_TX_HALT, &dev->flags)) { | 881 | if (test_bit (EVENT_TX_HALT, &dev->flags)) { |
883 | unlink_urbs (dev, &dev->txq); | 882 | unlink_urbs (dev, &dev->txq); |
883 | status = usb_autopm_get_interface(dev->intf); | ||
884 | if (status < 0) | ||
885 | goto fail_pipe; | ||
884 | status = usb_clear_halt (dev->udev, dev->out); | 886 | status = usb_clear_halt (dev->udev, dev->out); |
885 | if (status < 0 | 887 | usb_autopm_put_interface(dev->intf); |
886 | && status != -EPIPE | 888 | if (status < 0 && |
887 | && status != -ESHUTDOWN) { | 889 | status != -EPIPE && |
890 | status != -ESHUTDOWN) { | ||
888 | if (netif_msg_tx_err (dev)) | 891 | if (netif_msg_tx_err (dev)) |
889 | deverr (dev, "can't clear tx halt, status %d", | 892 | fail_pipe: |
890 | status); | 893 | netdev_err(dev->net, "can't clear tx halt, status %d\n", |
894 | status); | ||
891 | } else { | 895 | } else { |
892 | clear_bit (EVENT_TX_HALT, &dev->flags); | 896 | clear_bit (EVENT_TX_HALT, &dev->flags); |
893 | if (status != -ESHUTDOWN) | 897 | if (status != -ESHUTDOWN) |
@@ -896,13 +900,18 @@ kevent (struct work_struct *work) | |||
896 | } | 900 | } |
897 | if (test_bit (EVENT_RX_HALT, &dev->flags)) { | 901 | if (test_bit (EVENT_RX_HALT, &dev->flags)) { |
898 | unlink_urbs (dev, &dev->rxq); | 902 | unlink_urbs (dev, &dev->rxq); |
903 | status = usb_autopm_get_interface(dev->intf); | ||
904 | if (status < 0) | ||
905 | goto fail_halt; | ||
899 | status = usb_clear_halt (dev->udev, dev->in); | 906 | status = usb_clear_halt (dev->udev, dev->in); |
900 | if (status < 0 | 907 | usb_autopm_put_interface(dev->intf); |
901 | && status != -EPIPE | 908 | if (status < 0 && |
902 | && status != -ESHUTDOWN) { | 909 | status != -EPIPE && |
910 | status != -ESHUTDOWN) { | ||
903 | if (netif_msg_rx_err (dev)) | 911 | if (netif_msg_rx_err (dev)) |
904 | deverr (dev, "can't clear rx halt, status %d", | 912 | fail_halt: |
905 | status); | 913 | netdev_err(dev->net, "can't clear rx halt, status %d\n", |
914 | status); | ||
906 | } else { | 915 | } else { |
907 | clear_bit (EVENT_RX_HALT, &dev->flags); | 916 | clear_bit (EVENT_RX_HALT, &dev->flags); |
908 | tasklet_schedule (&dev->bh); | 917 | tasklet_schedule (&dev->bh); |
@@ -919,7 +928,12 @@ kevent (struct work_struct *work) | |||
919 | clear_bit (EVENT_RX_MEMORY, &dev->flags); | 928 | clear_bit (EVENT_RX_MEMORY, &dev->flags); |
920 | if (urb != NULL) { | 929 | if (urb != NULL) { |
921 | clear_bit (EVENT_RX_MEMORY, &dev->flags); | 930 | clear_bit (EVENT_RX_MEMORY, &dev->flags); |
931 | status = usb_autopm_get_interface(dev->intf); | ||
932 | if (status < 0) | ||
933 | goto fail_lowmem; | ||
922 | rx_submit (dev, urb, GFP_KERNEL); | 934 | rx_submit (dev, urb, GFP_KERNEL); |
935 | usb_autopm_put_interface(dev->intf); | ||
936 | fail_lowmem: | ||
923 | tasklet_schedule (&dev->bh); | 937 | tasklet_schedule (&dev->bh); |
924 | } | 938 | } |
925 | } | 939 | } |
@@ -929,17 +943,24 @@ kevent (struct work_struct *work) | |||
929 | int retval = 0; | 943 | int retval = 0; |
930 | 944 | ||
931 | clear_bit (EVENT_LINK_RESET, &dev->flags); | 945 | clear_bit (EVENT_LINK_RESET, &dev->flags); |
946 | status = usb_autopm_get_interface(dev->intf); | ||
947 | if (status < 0) | ||
948 | goto skip_reset; | ||
932 | if(info->link_reset && (retval = info->link_reset(dev)) < 0) { | 949 | if(info->link_reset && (retval = info->link_reset(dev)) < 0) { |
933 | devinfo(dev, "link reset failed (%d) usbnet usb-%s-%s, %s", | 950 | usb_autopm_put_interface(dev->intf); |
934 | retval, | 951 | skip_reset: |
935 | dev->udev->bus->bus_name, dev->udev->devpath, | 952 | netdev_info(dev->net, "link reset failed (%d) usbnet usb-%s-%s, %s\n", |
936 | info->description); | 953 | retval, |
954 | dev->udev->bus->bus_name, | ||
955 | dev->udev->devpath, | ||
956 | info->description); | ||
957 | } else { | ||
958 | usb_autopm_put_interface(dev->intf); | ||
937 | } | 959 | } |
938 | } | 960 | } |
939 | 961 | ||
940 | if (dev->flags) | 962 | if (dev->flags) |
941 | devdbg (dev, "kevent done, flags = 0x%lx", | 963 | netdev_dbg(dev->net, "kevent done, flags = 0x%lx\n", dev->flags); |
942 | dev->flags); | ||
943 | } | 964 | } |
944 | 965 | ||
945 | /*-------------------------------------------------------------------------*/ | 966 | /*-------------------------------------------------------------------------*/ |
@@ -971,22 +992,23 @@ static void tx_complete (struct urb *urb) | |||
971 | case -EPROTO: | 992 | case -EPROTO: |
972 | case -ETIME: | 993 | case -ETIME: |
973 | case -EILSEQ: | 994 | case -EILSEQ: |
995 | usb_mark_last_busy(dev->udev); | ||
974 | if (!timer_pending (&dev->delay)) { | 996 | if (!timer_pending (&dev->delay)) { |
975 | mod_timer (&dev->delay, | 997 | mod_timer (&dev->delay, |
976 | jiffies + THROTTLE_JIFFIES); | 998 | jiffies + THROTTLE_JIFFIES); |
977 | if (netif_msg_link (dev)) | 999 | netif_dbg(dev, link, dev->net, |
978 | devdbg (dev, "tx throttle %d", | 1000 | "tx throttle %d\n", urb->status); |
979 | urb->status); | ||
980 | } | 1001 | } |
981 | netif_stop_queue (dev->net); | 1002 | netif_stop_queue (dev->net); |
982 | break; | 1003 | break; |
983 | default: | 1004 | default: |
984 | if (netif_msg_tx_err (dev)) | 1005 | netif_dbg(dev, tx_err, dev->net, |
985 | devdbg (dev, "tx err %d", entry->urb->status); | 1006 | "tx err %d\n", entry->urb->status); |
986 | break; | 1007 | break; |
987 | } | 1008 | } |
988 | } | 1009 | } |
989 | 1010 | ||
1011 | usb_autopm_put_interface_async(dev->intf); | ||
990 | urb->dev = NULL; | 1012 | urb->dev = NULL; |
991 | entry->state = tx_done; | 1013 | entry->state = tx_done; |
992 | defer_bh(dev, skb, &dev->txq); | 1014 | defer_bh(dev, skb, &dev->txq); |
@@ -1023,16 +1045,14 @@ netdev_tx_t usbnet_start_xmit (struct sk_buff *skb, | |||
1023 | if (info->tx_fixup) { | 1045 | if (info->tx_fixup) { |
1024 | skb = info->tx_fixup (dev, skb, GFP_ATOMIC); | 1046 | skb = info->tx_fixup (dev, skb, GFP_ATOMIC); |
1025 | if (!skb) { | 1047 | if (!skb) { |
1026 | if (netif_msg_tx_err (dev)) | 1048 | netif_dbg(dev, tx_err, dev->net, "can't tx_fixup skb\n"); |
1027 | devdbg (dev, "can't tx_fixup skb"); | ||
1028 | goto drop; | 1049 | goto drop; |
1029 | } | 1050 | } |
1030 | } | 1051 | } |
1031 | length = skb->len; | 1052 | length = skb->len; |
1032 | 1053 | ||
1033 | if (!(urb = usb_alloc_urb (0, GFP_ATOMIC))) { | 1054 | if (!(urb = usb_alloc_urb (0, GFP_ATOMIC))) { |
1034 | if (netif_msg_tx_err (dev)) | 1055 | netif_dbg(dev, tx_err, dev->net, "no urb\n"); |
1035 | devdbg (dev, "no urb"); | ||
1036 | goto drop; | 1056 | goto drop; |
1037 | } | 1057 | } |
1038 | 1058 | ||
@@ -1057,16 +1077,36 @@ netdev_tx_t usbnet_start_xmit (struct sk_buff *skb, | |||
1057 | } | 1077 | } |
1058 | } | 1078 | } |
1059 | 1079 | ||
1060 | spin_lock_irqsave (&dev->txq.lock, flags); | 1080 | spin_lock_irqsave(&dev->txq.lock, flags); |
1081 | retval = usb_autopm_get_interface_async(dev->intf); | ||
1082 | if (retval < 0) { | ||
1083 | spin_unlock_irqrestore(&dev->txq.lock, flags); | ||
1084 | goto drop; | ||
1085 | } | ||
1086 | |||
1087 | #ifdef CONFIG_PM | ||
1088 | /* if this triggers the device is still a sleep */ | ||
1089 | if (test_bit(EVENT_DEV_ASLEEP, &dev->flags)) { | ||
1090 | /* transmission will be done in resume */ | ||
1091 | usb_anchor_urb(urb, &dev->deferred); | ||
1092 | /* no use to process more packets */ | ||
1093 | netif_stop_queue(net); | ||
1094 | spin_unlock_irqrestore(&dev->txq.lock, flags); | ||
1095 | netdev_dbg(dev->net, "Delaying transmission for resumption\n"); | ||
1096 | goto deferred; | ||
1097 | } | ||
1098 | #endif | ||
1061 | 1099 | ||
1062 | switch ((retval = usb_submit_urb (urb, GFP_ATOMIC))) { | 1100 | switch ((retval = usb_submit_urb (urb, GFP_ATOMIC))) { |
1063 | case -EPIPE: | 1101 | case -EPIPE: |
1064 | netif_stop_queue (net); | 1102 | netif_stop_queue (net); |
1065 | usbnet_defer_kevent (dev, EVENT_TX_HALT); | 1103 | usbnet_defer_kevent (dev, EVENT_TX_HALT); |
1104 | usb_autopm_put_interface_async(dev->intf); | ||
1066 | break; | 1105 | break; |
1067 | default: | 1106 | default: |
1068 | if (netif_msg_tx_err (dev)) | 1107 | usb_autopm_put_interface_async(dev->intf); |
1069 | devdbg (dev, "tx: submit urb err %d", retval); | 1108 | netif_dbg(dev, tx_err, dev->net, |
1109 | "tx: submit urb err %d\n", retval); | ||
1070 | break; | 1110 | break; |
1071 | case 0: | 1111 | case 0: |
1072 | net->trans_start = jiffies; | 1112 | net->trans_start = jiffies; |
@@ -1077,17 +1117,18 @@ netdev_tx_t usbnet_start_xmit (struct sk_buff *skb, | |||
1077 | spin_unlock_irqrestore (&dev->txq.lock, flags); | 1117 | spin_unlock_irqrestore (&dev->txq.lock, flags); |
1078 | 1118 | ||
1079 | if (retval) { | 1119 | if (retval) { |
1080 | if (netif_msg_tx_err (dev)) | 1120 | netif_dbg(dev, tx_err, dev->net, "drop, code %d\n", retval); |
1081 | devdbg (dev, "drop, code %d", retval); | ||
1082 | drop: | 1121 | drop: |
1083 | dev->net->stats.tx_dropped++; | 1122 | dev->net->stats.tx_dropped++; |
1084 | if (skb) | 1123 | if (skb) |
1085 | dev_kfree_skb_any (skb); | 1124 | dev_kfree_skb_any (skb); |
1086 | usb_free_urb (urb); | 1125 | usb_free_urb (urb); |
1087 | } else if (netif_msg_tx_queued (dev)) { | 1126 | } else |
1088 | devdbg (dev, "> tx, len %d, type 0x%x", | 1127 | netif_dbg(dev, tx_queued, dev->net, |
1089 | length, skb->protocol); | 1128 | "> tx, len %d, type 0x%x\n", length, skb->protocol); |
1090 | } | 1129 | #ifdef CONFIG_PM |
1130 | deferred: | ||
1131 | #endif | ||
1091 | return NETDEV_TX_OK; | 1132 | return NETDEV_TX_OK; |
1092 | } | 1133 | } |
1093 | EXPORT_SYMBOL_GPL(usbnet_start_xmit); | 1134 | EXPORT_SYMBOL_GPL(usbnet_start_xmit); |
@@ -1115,7 +1156,7 @@ static void usbnet_bh (unsigned long param) | |||
1115 | dev_kfree_skb (skb); | 1156 | dev_kfree_skb (skb); |
1116 | continue; | 1157 | continue; |
1117 | default: | 1158 | default: |
1118 | devdbg (dev, "bogus skb state %d", entry->state); | 1159 | netdev_dbg(dev->net, "bogus skb state %d\n", entry->state); |
1119 | } | 1160 | } |
1120 | } | 1161 | } |
1121 | 1162 | ||
@@ -1126,10 +1167,10 @@ static void usbnet_bh (unsigned long param) | |||
1126 | } | 1167 | } |
1127 | 1168 | ||
1128 | // or are we maybe short a few urbs? | 1169 | // or are we maybe short a few urbs? |
1129 | } else if (netif_running (dev->net) | 1170 | } else if (netif_running (dev->net) && |
1130 | && netif_device_present (dev->net) | 1171 | netif_device_present (dev->net) && |
1131 | && !timer_pending (&dev->delay) | 1172 | !timer_pending (&dev->delay) && |
1132 | && !test_bit (EVENT_RX_HALT, &dev->flags)) { | 1173 | !test_bit (EVENT_RX_HALT, &dev->flags)) { |
1133 | int temp = dev->rxq.qlen; | 1174 | int temp = dev->rxq.qlen; |
1134 | int qlen = RX_QLEN (dev); | 1175 | int qlen = RX_QLEN (dev); |
1135 | 1176 | ||
@@ -1143,9 +1184,10 @@ static void usbnet_bh (unsigned long param) | |||
1143 | if (urb != NULL) | 1184 | if (urb != NULL) |
1144 | rx_submit (dev, urb, GFP_ATOMIC); | 1185 | rx_submit (dev, urb, GFP_ATOMIC); |
1145 | } | 1186 | } |
1146 | if (temp != dev->rxq.qlen && netif_msg_link (dev)) | 1187 | if (temp != dev->rxq.qlen) |
1147 | devdbg (dev, "rxqlen %d --> %d", | 1188 | netif_dbg(dev, link, dev->net, |
1148 | temp, dev->rxq.qlen); | 1189 | "rxqlen %d --> %d\n", |
1190 | temp, dev->rxq.qlen); | ||
1149 | if (dev->rxq.qlen < qlen) | 1191 | if (dev->rxq.qlen < qlen) |
1150 | tasklet_schedule (&dev->bh); | 1192 | tasklet_schedule (&dev->bh); |
1151 | } | 1193 | } |
@@ -1176,11 +1218,10 @@ void usbnet_disconnect (struct usb_interface *intf) | |||
1176 | 1218 | ||
1177 | xdev = interface_to_usbdev (intf); | 1219 | xdev = interface_to_usbdev (intf); |
1178 | 1220 | ||
1179 | if (netif_msg_probe (dev)) | 1221 | netif_info(dev, probe, dev->net, "unregister '%s' usb-%s-%s, %s\n", |
1180 | devinfo (dev, "unregister '%s' usb-%s-%s, %s", | 1222 | intf->dev.driver->name, |
1181 | intf->dev.driver->name, | 1223 | xdev->bus->bus_name, xdev->devpath, |
1182 | xdev->bus->bus_name, xdev->devpath, | 1224 | dev->driver_info->description); |
1183 | dev->driver_info->description); | ||
1184 | 1225 | ||
1185 | net = dev->net; | 1226 | net = dev->net; |
1186 | unregister_netdev (net); | 1227 | unregister_netdev (net); |
@@ -1210,6 +1251,14 @@ static const struct net_device_ops usbnet_netdev_ops = { | |||
1210 | 1251 | ||
1211 | // precondition: never called in_interrupt | 1252 | // precondition: never called in_interrupt |
1212 | 1253 | ||
1254 | static struct device_type wlan_type = { | ||
1255 | .name = "wlan", | ||
1256 | }; | ||
1257 | |||
1258 | static struct device_type wwan_type = { | ||
1259 | .name = "wwan", | ||
1260 | }; | ||
1261 | |||
1213 | int | 1262 | int |
1214 | usbnet_probe (struct usb_interface *udev, const struct usb_device_id *prod) | 1263 | usbnet_probe (struct usb_interface *udev, const struct usb_device_id *prod) |
1215 | { | 1264 | { |
@@ -1255,6 +1304,7 @@ usbnet_probe (struct usb_interface *udev, const struct usb_device_id *prod) | |||
1255 | dev->bh.func = usbnet_bh; | 1304 | dev->bh.func = usbnet_bh; |
1256 | dev->bh.data = (unsigned long) dev; | 1305 | dev->bh.data = (unsigned long) dev; |
1257 | INIT_WORK (&dev->kevent, kevent); | 1306 | INIT_WORK (&dev->kevent, kevent); |
1307 | init_usb_anchor(&dev->deferred); | ||
1258 | dev->delay.function = usbnet_bh; | 1308 | dev->delay.function = usbnet_bh; |
1259 | dev->delay.data = (unsigned long) dev; | 1309 | dev->delay.data = (unsigned long) dev; |
1260 | init_timer (&dev->delay); | 1310 | init_timer (&dev->delay); |
@@ -1289,12 +1339,15 @@ usbnet_probe (struct usb_interface *udev, const struct usb_device_id *prod) | |||
1289 | // heuristic: "usb%d" for links we know are two-host, | 1339 | // heuristic: "usb%d" for links we know are two-host, |
1290 | // else "eth%d" when there's reasonable doubt. userspace | 1340 | // else "eth%d" when there's reasonable doubt. userspace |
1291 | // can rename the link if it knows better. | 1341 | // can rename the link if it knows better. |
1292 | if ((dev->driver_info->flags & FLAG_ETHER) != 0 | 1342 | if ((dev->driver_info->flags & FLAG_ETHER) != 0 && |
1293 | && (net->dev_addr [0] & 0x02) == 0) | 1343 | (net->dev_addr [0] & 0x02) == 0) |
1294 | strcpy (net->name, "eth%d"); | 1344 | strcpy (net->name, "eth%d"); |
1295 | /* WLAN devices should always be named "wlan%d" */ | 1345 | /* WLAN devices should always be named "wlan%d" */ |
1296 | if ((dev->driver_info->flags & FLAG_WLAN) != 0) | 1346 | if ((dev->driver_info->flags & FLAG_WLAN) != 0) |
1297 | strcpy(net->name, "wlan%d"); | 1347 | strcpy(net->name, "wlan%d"); |
1348 | /* WWAN devices should always be named "wwan%d" */ | ||
1349 | if ((dev->driver_info->flags & FLAG_WWAN) != 0) | ||
1350 | strcpy(net->name, "wwan%d"); | ||
1298 | 1351 | ||
1299 | /* maybe the remote can't receive an Ethernet MTU */ | 1352 | /* maybe the remote can't receive an Ethernet MTU */ |
1300 | if (net->mtu > (dev->hard_mtu - net->hard_header_len)) | 1353 | if (net->mtu > (dev->hard_mtu - net->hard_header_len)) |
@@ -1322,22 +1375,30 @@ usbnet_probe (struct usb_interface *udev, const struct usb_device_id *prod) | |||
1322 | dev->maxpacket = usb_maxpacket (dev->udev, dev->out, 1); | 1375 | dev->maxpacket = usb_maxpacket (dev->udev, dev->out, 1); |
1323 | 1376 | ||
1324 | SET_NETDEV_DEV(net, &udev->dev); | 1377 | SET_NETDEV_DEV(net, &udev->dev); |
1378 | |||
1379 | if ((dev->driver_info->flags & FLAG_WLAN) != 0) | ||
1380 | SET_NETDEV_DEVTYPE(net, &wlan_type); | ||
1381 | if ((dev->driver_info->flags & FLAG_WWAN) != 0) | ||
1382 | SET_NETDEV_DEVTYPE(net, &wwan_type); | ||
1383 | |||
1325 | status = register_netdev (net); | 1384 | status = register_netdev (net); |
1326 | if (status) | 1385 | if (status) |
1327 | goto out3; | 1386 | goto out3; |
1328 | if (netif_msg_probe (dev)) | 1387 | netif_info(dev, probe, dev->net, |
1329 | devinfo (dev, "register '%s' at usb-%s-%s, %s, %pM", | 1388 | "register '%s' at usb-%s-%s, %s, %pM\n", |
1330 | udev->dev.driver->name, | 1389 | udev->dev.driver->name, |
1331 | xdev->bus->bus_name, xdev->devpath, | 1390 | xdev->bus->bus_name, xdev->devpath, |
1332 | dev->driver_info->description, | 1391 | dev->driver_info->description, |
1333 | net->dev_addr); | 1392 | net->dev_addr); |
1334 | 1393 | ||
1335 | // ok, it's ready to go. | 1394 | // ok, it's ready to go. |
1336 | usb_set_intfdata (udev, dev); | 1395 | usb_set_intfdata (udev, dev); |
1337 | 1396 | ||
1338 | // start as if the link is up | ||
1339 | netif_device_attach (net); | 1397 | netif_device_attach (net); |
1340 | 1398 | ||
1399 | if (dev->driver_info->flags & FLAG_LINK_INTR) | ||
1400 | netif_carrier_off(net); | ||
1401 | |||
1341 | return 0; | 1402 | return 0; |
1342 | 1403 | ||
1343 | out3: | 1404 | out3: |
@@ -1363,13 +1424,23 @@ int usbnet_suspend (struct usb_interface *intf, pm_message_t message) | |||
1363 | struct usbnet *dev = usb_get_intfdata(intf); | 1424 | struct usbnet *dev = usb_get_intfdata(intf); |
1364 | 1425 | ||
1365 | if (!dev->suspend_count++) { | 1426 | if (!dev->suspend_count++) { |
1427 | spin_lock_irq(&dev->txq.lock); | ||
1428 | /* don't autosuspend while transmitting */ | ||
1429 | if (dev->txq.qlen && (message.event & PM_EVENT_AUTO)) { | ||
1430 | spin_unlock_irq(&dev->txq.lock); | ||
1431 | return -EBUSY; | ||
1432 | } else { | ||
1433 | set_bit(EVENT_DEV_ASLEEP, &dev->flags); | ||
1434 | spin_unlock_irq(&dev->txq.lock); | ||
1435 | } | ||
1366 | /* | 1436 | /* |
1367 | * accelerate emptying of the rx and queues, to avoid | 1437 | * accelerate emptying of the rx and queues, to avoid |
1368 | * having everything error out. | 1438 | * having everything error out. |
1369 | */ | 1439 | */ |
1370 | netif_device_detach (dev->net); | 1440 | netif_device_detach (dev->net); |
1371 | (void) unlink_urbs (dev, &dev->rxq); | 1441 | usbnet_terminate_urbs(dev); |
1372 | (void) unlink_urbs (dev, &dev->txq); | 1442 | usb_kill_urb(dev->interrupt); |
1443 | |||
1373 | /* | 1444 | /* |
1374 | * reattach so runtime management can use and | 1445 | * reattach so runtime management can use and |
1375 | * wake the device | 1446 | * wake the device |
@@ -1383,10 +1454,34 @@ EXPORT_SYMBOL_GPL(usbnet_suspend); | |||
1383 | int usbnet_resume (struct usb_interface *intf) | 1454 | int usbnet_resume (struct usb_interface *intf) |
1384 | { | 1455 | { |
1385 | struct usbnet *dev = usb_get_intfdata(intf); | 1456 | struct usbnet *dev = usb_get_intfdata(intf); |
1457 | struct sk_buff *skb; | ||
1458 | struct urb *res; | ||
1459 | int retval; | ||
1460 | |||
1461 | if (!--dev->suspend_count) { | ||
1462 | spin_lock_irq(&dev->txq.lock); | ||
1463 | while ((res = usb_get_from_anchor(&dev->deferred))) { | ||
1464 | |||
1465 | printk(KERN_INFO"%s has delayed data\n", __func__); | ||
1466 | skb = (struct sk_buff *)res->context; | ||
1467 | retval = usb_submit_urb(res, GFP_ATOMIC); | ||
1468 | if (retval < 0) { | ||
1469 | dev_kfree_skb_any(skb); | ||
1470 | usb_free_urb(res); | ||
1471 | usb_autopm_put_interface_async(dev->intf); | ||
1472 | } else { | ||
1473 | dev->net->trans_start = jiffies; | ||
1474 | __skb_queue_tail(&dev->txq, skb); | ||
1475 | } | ||
1476 | } | ||
1386 | 1477 | ||
1387 | if (!--dev->suspend_count) | 1478 | smp_mb(); |
1479 | clear_bit(EVENT_DEV_ASLEEP, &dev->flags); | ||
1480 | spin_unlock_irq(&dev->txq.lock); | ||
1481 | if (!(dev->txq.qlen >= TX_QLEN(dev))) | ||
1482 | netif_start_queue(dev->net); | ||
1388 | tasklet_schedule (&dev->bh); | 1483 | tasklet_schedule (&dev->bh); |
1389 | 1484 | } | |
1390 | return 0; | 1485 | return 0; |
1391 | } | 1486 | } |
1392 | EXPORT_SYMBOL_GPL(usbnet_resume); | 1487 | EXPORT_SYMBOL_GPL(usbnet_resume); |