usbnet.c (9c5ef0fbfa0b0be219290b05a39135b957479251) | usbnet.c (18ab458fb7bd5c64bef766090020648266cfa9b6) |
---|---|
1/* 2 * USB Network driver infrastructure 3 * Copyright (C) 2000-2005 by David Brownell 4 * Copyright (C) 2003-2005 David Hollis <dhollis@davehollis.com> 5 * 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 --- 178 unchanged lines hidden (view full) --- 187 } else { 188 usb_fill_int_urb(dev->interrupt, dev->udev, pipe, 189 buf, maxp, intr_complete, dev, period); 190 dev_dbg(&intf->dev, 191 "status ep%din, %d bytes period %d\n", 192 usb_pipeendpoint(pipe), maxp, period); 193 } 194 } | 1/* 2 * USB Network driver infrastructure 3 * Copyright (C) 2000-2005 by David Brownell 4 * Copyright (C) 2003-2005 David Hollis <dhollis@davehollis.com> 5 * 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 --- 178 unchanged lines hidden (view full) --- 187 } else { 188 usb_fill_int_urb(dev->interrupt, dev->udev, pipe, 189 buf, maxp, intr_complete, dev, period); 190 dev_dbg(&intf->dev, 191 "status ep%din, %d bytes period %d\n", 192 usb_pipeendpoint(pipe), maxp, period); 193 } 194 } |
195 return 0; | 195 return 0; |
196} 197 198/* Passes this packet up the stack, updating its accounting. 199 * Some link protocols batch packets, so their rx_fixup paths 200 * can return clones as well as just modify the original skb. 201 */ 202void usbnet_skb_return (struct usbnet *dev, struct sk_buff *skb) 203{ --- 117 unchanged lines hidden (view full) --- 321 usb_fill_bulk_urb (urb, dev->udev, dev->in, 322 skb->data, size, rx_complete, skb); 323 324 spin_lock_irqsave (&dev->rxq.lock, lockflags); 325 326 if (netif_running (dev->net) 327 && netif_device_present (dev->net) 328 && !test_bit (EVENT_RX_HALT, &dev->flags)) { | 196} 197 198/* Passes this packet up the stack, updating its accounting. 199 * Some link protocols batch packets, so their rx_fixup paths 200 * can return clones as well as just modify the original skb. 201 */ 202void usbnet_skb_return (struct usbnet *dev, struct sk_buff *skb) 203{ --- 117 unchanged lines hidden (view full) --- 321 usb_fill_bulk_urb (urb, dev->udev, dev->in, 322 skb->data, size, rx_complete, skb); 323 324 spin_lock_irqsave (&dev->rxq.lock, lockflags); 325 326 if (netif_running (dev->net) 327 && netif_device_present (dev->net) 328 && !test_bit (EVENT_RX_HALT, &dev->flags)) { |
329 switch (retval = usb_submit_urb (urb, GFP_ATOMIC)){ | 329 switch (retval = usb_submit_urb (urb, GFP_ATOMIC)) { |
330 case -EPIPE: 331 usbnet_defer_kevent (dev, EVENT_RX_HALT); 332 break; 333 case -ENOMEM: 334 usbnet_defer_kevent (dev, EVENT_RX_MEMORY); 335 break; 336 case -ENODEV: 337 if (netif_msg_ifdown (dev)) --- 50 unchanged lines hidden (view full) --- 388 struct usbnet *dev = entry->dev; 389 int urb_status = urb->status; 390 391 skb_put (skb, urb->actual_length); 392 entry->state = rx_done; 393 entry->urb = NULL; 394 395 switch (urb_status) { | 330 case -EPIPE: 331 usbnet_defer_kevent (dev, EVENT_RX_HALT); 332 break; 333 case -ENOMEM: 334 usbnet_defer_kevent (dev, EVENT_RX_MEMORY); 335 break; 336 case -ENODEV: 337 if (netif_msg_ifdown (dev)) --- 50 unchanged lines hidden (view full) --- 388 struct usbnet *dev = entry->dev; 389 int urb_status = urb->status; 390 391 skb_put (skb, urb->actual_length); 392 entry->state = rx_done; 393 entry->urb = NULL; 394 395 switch (urb_status) { |
396 // success 397 case 0: | 396 /* success */ 397 case 0: |
398 if (skb->len < dev->net->hard_header_len) { 399 entry->state = rx_cleanup; 400 dev->stats.rx_errors++; 401 dev->stats.rx_length_errors++; 402 if (netif_msg_rx_err (dev)) 403 devdbg (dev, "rx length %d", skb->len); 404 } 405 break; 406 | 398 if (skb->len < dev->net->hard_header_len) { 399 entry->state = rx_cleanup; 400 dev->stats.rx_errors++; 401 dev->stats.rx_length_errors++; 402 if (netif_msg_rx_err (dev)) 403 devdbg (dev, "rx length %d", skb->len); 404 } 405 break; 406 |
407 // stalls need manual reset. this is rare ... except that 408 // when going through USB 2.0 TTs, unplug appears this way. 409 // we avoid the highspeed version of the ETIMEOUT/EILSEQ 410 // storm, recovering as needed. 411 case -EPIPE: | 407 /* stalls need manual reset. this is rare ... except that 408 * when going through USB 2.0 TTs, unplug appears this way. 409 * we avoid the highspeed version of the ETIMEOUT/EILSEQ 410 * storm, recovering as needed. 411 */ 412 case -EPIPE: |
412 dev->stats.rx_errors++; 413 usbnet_defer_kevent (dev, EVENT_RX_HALT); 414 // FALLTHROUGH 415 | 413 dev->stats.rx_errors++; 414 usbnet_defer_kevent (dev, EVENT_RX_HALT); 415 // FALLTHROUGH 416 |
416 // software-driven interface shutdown 417 case -ECONNRESET: // async unlink 418 case -ESHUTDOWN: // hardware gone | 417 /* software-driven interface shutdown */ 418 case -ECONNRESET: /* async unlink */ 419 case -ESHUTDOWN: /* hardware gone */ |
419 if (netif_msg_ifdown (dev)) 420 devdbg (dev, "rx shutdown, code %d", urb_status); 421 goto block; 422 | 420 if (netif_msg_ifdown (dev)) 421 devdbg (dev, "rx shutdown, code %d", urb_status); 422 goto block; 423 |
423 // we get controller i/o faults during khubd disconnect() delays. 424 // throttle down resubmits, to avoid log floods; just temporarily, 425 // so we still recover when the fault isn't a khubd delay. 426 case -EPROTO: 427 case -ETIME: 428 case -EILSEQ: | 424 /* we get controller i/o faults during khubd disconnect() delays. 425 * throttle down resubmits, to avoid log floods; just temporarily, 426 * so we still recover when the fault isn't a khubd delay. 427 */ 428 case -EPROTO: 429 case -ETIME: 430 case -EILSEQ: |
429 dev->stats.rx_errors++; 430 if (!timer_pending (&dev->delay)) { 431 mod_timer (&dev->delay, jiffies + THROTTLE_JIFFIES); 432 if (netif_msg_link (dev)) 433 devdbg (dev, "rx throttle %d", urb_status); 434 } 435block: 436 entry->state = rx_cleanup; 437 entry->urb = urb; 438 urb = NULL; 439 break; 440 | 431 dev->stats.rx_errors++; 432 if (!timer_pending (&dev->delay)) { 433 mod_timer (&dev->delay, jiffies + THROTTLE_JIFFIES); 434 if (netif_msg_link (dev)) 435 devdbg (dev, "rx throttle %d", urb_status); 436 } 437block: 438 entry->state = rx_cleanup; 439 entry->urb = urb; 440 urb = NULL; 441 break; 442 |
441 // data overrun ... flush fifo? 442 case -EOVERFLOW: | 443 /* data overrun ... flush fifo? */ 444 case -EOVERFLOW: |
443 dev->stats.rx_over_errors++; 444 // FALLTHROUGH 445 | 445 dev->stats.rx_over_errors++; 446 // FALLTHROUGH 447 |
446 default: | 448 default: |
447 entry->state = rx_cleanup; 448 dev->stats.rx_errors++; 449 if (netif_msg_rx_err (dev)) 450 devdbg (dev, "rx status %d", urb_status); 451 break; 452 } 453 454 defer_bh(dev, skb, &dev->rxq); --- 11 unchanged lines hidden (view full) --- 466} 467 468static void intr_complete (struct urb *urb) 469{ 470 struct usbnet *dev = urb->context; 471 int status = urb->status; 472 473 switch (status) { | 449 entry->state = rx_cleanup; 450 dev->stats.rx_errors++; 451 if (netif_msg_rx_err (dev)) 452 devdbg (dev, "rx status %d", urb_status); 453 break; 454 } 455 456 defer_bh(dev, skb, &dev->rxq); --- 11 unchanged lines hidden (view full) --- 468} 469 470static void intr_complete (struct urb *urb) 471{ 472 struct usbnet *dev = urb->context; 473 int status = urb->status; 474 475 switch (status) { |
474 /* success */ 475 case 0: | 476 /* success */ 477 case 0: |
476 dev->driver_info->status(dev, urb); 477 break; 478 | 478 dev->driver_info->status(dev, urb); 479 break; 480 |
479 /* software-driven interface shutdown */ 480 case -ENOENT: // urb killed 481 case -ESHUTDOWN: // hardware gone | 481 /* software-driven interface shutdown */ 482 case -ENOENT: /* urb killed */ 483 case -ESHUTDOWN: /* hardware gone */ |
482 if (netif_msg_ifdown (dev)) 483 devdbg (dev, "intr shutdown, code %d", status); 484 return; 485 | 484 if (netif_msg_ifdown (dev)) 485 devdbg (dev, "intr shutdown, code %d", status); 486 return; 487 |
486 /* NOTE: not throttling like RX/TX, since this endpoint 487 * already polls infrequently 488 */ 489 default: | 488 /* NOTE: not throttling like RX/TX, since this endpoint 489 * already polls infrequently 490 */ 491 default: |
490 devdbg (dev, "intr status %d", status); 491 break; 492 } 493 494 if (!netif_running (dev->net)) 495 return; 496 497 memset(urb->transfer_buffer, 0, urb->transfer_buffer_length); --- 66 unchanged lines hidden (view full) --- 564 ); 565 566 // ensure there are no more active urbs 567 add_wait_queue (&unlink_wakeup, &wait); 568 dev->wait = &unlink_wakeup; 569 temp = unlink_urbs (dev, &dev->txq) + unlink_urbs (dev, &dev->rxq); 570 571 // maybe wait for deletions to finish. | 492 devdbg (dev, "intr status %d", status); 493 break; 494 } 495 496 if (!netif_running (dev->net)) 497 return; 498 499 memset(urb->transfer_buffer, 0, urb->transfer_buffer_length); --- 66 unchanged lines hidden (view full) --- 566 ); 567 568 // ensure there are no more active urbs 569 add_wait_queue (&unlink_wakeup, &wait); 570 dev->wait = &unlink_wakeup; 571 temp = unlink_urbs (dev, &dev->txq) + unlink_urbs (dev, &dev->rxq); 572 573 // maybe wait for deletions to finish. |
572 while (!skb_queue_empty(&dev->rxq) && 573 !skb_queue_empty(&dev->txq) && 574 !skb_queue_empty(&dev->done)) { | 574 while (!skb_queue_empty(&dev->rxq) 575 && !skb_queue_empty(&dev->txq) 576 && !skb_queue_empty(&dev->done)) { |
575 msleep(UNLINK_TIMEOUT_MS); 576 if (netif_msg_ifdown (dev)) 577 devdbg (dev, "waited for %d urb completions", temp); 578 } 579 dev->wait = NULL; 580 remove_wait_queue (&unlink_wakeup, &wait); 581 582 usb_kill_urb(dev->interrupt); --- 423 unchanged lines hidden (view full) --- 1006{ 1007 struct usbnet *dev = (struct usbnet *) param; 1008 struct sk_buff *skb; 1009 struct skb_data *entry; 1010 1011 while ((skb = skb_dequeue (&dev->done))) { 1012 entry = (struct skb_data *) skb->cb; 1013 switch (entry->state) { | 577 msleep(UNLINK_TIMEOUT_MS); 578 if (netif_msg_ifdown (dev)) 579 devdbg (dev, "waited for %d urb completions", temp); 580 } 581 dev->wait = NULL; 582 remove_wait_queue (&unlink_wakeup, &wait); 583 584 usb_kill_urb(dev->interrupt); --- 423 unchanged lines hidden (view full) --- 1008{ 1009 struct usbnet *dev = (struct usbnet *) param; 1010 struct sk_buff *skb; 1011 struct skb_data *entry; 1012 1013 while ((skb = skb_dequeue (&dev->done))) { 1014 entry = (struct skb_data *) skb->cb; 1015 switch (entry->state) { |
1014 case rx_done: | 1016 case rx_done: |
1015 entry->state = rx_cleanup; 1016 rx_process (dev, skb); 1017 continue; | 1017 entry->state = rx_cleanup; 1018 rx_process (dev, skb); 1019 continue; |
1018 case tx_done: 1019 case rx_cleanup: | 1020 case tx_done: 1021 case rx_cleanup: |
1020 usb_free_urb (entry->urb); 1021 dev_kfree_skb (skb); 1022 continue; | 1022 usb_free_urb (entry->urb); 1023 dev_kfree_skb (skb); 1024 continue; |
1023 default: | 1025 default: |
1024 devdbg (dev, "bogus skb state %d", entry->state); 1025 } 1026 } 1027 1028 // waiting for all pending urbs to complete? 1029 if (dev->wait) { 1030 if ((dev->txq.qlen + dev->rxq.qlen + dev->done.qlen) == 0) { 1031 wake_up (dev->wait); --- 281 unchanged lines hidden --- | 1026 devdbg (dev, "bogus skb state %d", entry->state); 1027 } 1028 } 1029 1030 // waiting for all pending urbs to complete? 1031 if (dev->wait) { 1032 if ((dev->txq.qlen + dev->rxq.qlen + dev->done.qlen) == 0) { 1033 wake_up (dev->wait); --- 281 unchanged lines hidden --- |