aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/usb/net/usbnet.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/usb/net/usbnet.c')
-rw-r--r--drivers/usb/net/usbnet.c45
1 files changed, 34 insertions, 11 deletions
diff --git a/drivers/usb/net/usbnet.c b/drivers/usb/net/usbnet.c
index 362d6907c9b..98a522f1e26 100644
--- a/drivers/usb/net/usbnet.c
+++ b/drivers/usb/net/usbnet.c
@@ -33,7 +33,6 @@
33// #define DEBUG // error path messages, extra info 33// #define DEBUG // error path messages, extra info
34// #define VERBOSE // more; success messages 34// #define VERBOSE // more; success messages
35 35
36#include <linux/config.h>
37#include <linux/module.h> 36#include <linux/module.h>
38#include <linux/sched.h> 37#include <linux/sched.h>
39#include <linux/init.h> 38#include <linux/init.h>
@@ -62,8 +61,11 @@
62 * let the USB host controller be busy for 5msec or more before an irq 61 * let the USB host controller be busy for 5msec or more before an irq
63 * is required, under load. Jumbograms change the equation. 62 * is required, under load. Jumbograms change the equation.
64 */ 63 */
65#define RX_QLEN(dev) (((dev)->udev->speed == USB_SPEED_HIGH) ? 60 : 4) 64#define RX_MAX_QUEUE_MEMORY (60 * 1518)
66#define TX_QLEN(dev) (((dev)->udev->speed == USB_SPEED_HIGH) ? 60 : 4) 65#define RX_QLEN(dev) (((dev)->udev->speed == USB_SPEED_HIGH) ? \
66 (RX_MAX_QUEUE_MEMORY/(dev)->rx_urb_size) : 4)
67#define TX_QLEN(dev) (((dev)->udev->speed == USB_SPEED_HIGH) ? \
68 (RX_MAX_QUEUE_MEMORY/(dev)->hard_mtu) : 4)
67 69
68// reawaken network queue this soon after stopping; else watchdog barks 70// reawaken network queue this soon after stopping; else watchdog barks
69#define TX_TIMEOUT_JIFFIES (5*HZ) 71#define TX_TIMEOUT_JIFFIES (5*HZ)
@@ -228,13 +230,23 @@ static int usbnet_change_mtu (struct net_device *net, int new_mtu)
228{ 230{
229 struct usbnet *dev = netdev_priv(net); 231 struct usbnet *dev = netdev_priv(net);
230 int ll_mtu = new_mtu + net->hard_header_len; 232 int ll_mtu = new_mtu + net->hard_header_len;
233 int old_hard_mtu = dev->hard_mtu;
234 int old_rx_urb_size = dev->rx_urb_size;
231 235
232 if (new_mtu <= 0 || ll_mtu > dev->hard_mtu) 236 if (new_mtu <= 0)
233 return -EINVAL; 237 return -EINVAL;
234 // no second zero-length packet read wanted after mtu-sized packets 238 // no second zero-length packet read wanted after mtu-sized packets
235 if ((ll_mtu % dev->maxpacket) == 0) 239 if ((ll_mtu % dev->maxpacket) == 0)
236 return -EDOM; 240 return -EDOM;
237 net->mtu = new_mtu; 241 net->mtu = new_mtu;
242
243 dev->hard_mtu = net->mtu + net->hard_header_len;
244 if (dev->rx_urb_size == old_hard_mtu) {
245 dev->rx_urb_size = dev->hard_mtu;
246 if (dev->rx_urb_size > old_rx_urb_size)
247 usbnet_unlink_rx_urbs(dev);
248 }
249
238 return 0; 250 return 0;
239} 251}
240 252
@@ -413,9 +425,9 @@ static void rx_complete (struct urb *urb, struct pt_regs *regs)
413 // we get controller i/o faults during khubd disconnect() delays. 425 // we get controller i/o faults during khubd disconnect() delays.
414 // throttle down resubmits, to avoid log floods; just temporarily, 426 // throttle down resubmits, to avoid log floods; just temporarily,
415 // so we still recover when the fault isn't a khubd delay. 427 // so we still recover when the fault isn't a khubd delay.
416 case -EPROTO: // ehci 428 case -EPROTO:
417 case -ETIMEDOUT: // ohci 429 case -ETIME:
418 case -EILSEQ: // uhci 430 case -EILSEQ:
419 dev->stats.rx_errors++; 431 dev->stats.rx_errors++;
420 if (!timer_pending (&dev->delay)) { 432 if (!timer_pending (&dev->delay)) {
421 mod_timer (&dev->delay, jiffies + THROTTLE_JIFFIES); 433 mod_timer (&dev->delay, jiffies + THROTTLE_JIFFIES);
@@ -522,6 +534,17 @@ static int unlink_urbs (struct usbnet *dev, struct sk_buff_head *q)
522 return count; 534 return count;
523} 535}
524 536
537// Flush all pending rx urbs
538// minidrivers may need to do this when the MTU changes
539
540void usbnet_unlink_rx_urbs(struct usbnet *dev)
541{
542 if (netif_running(dev->net)) {
543 (void) unlink_urbs (dev, &dev->rxq);
544 tasklet_schedule(&dev->bh);
545 }
546}
547EXPORT_SYMBOL_GPL(usbnet_unlink_rx_urbs);
525 548
526/*-------------------------------------------------------------------------*/ 549/*-------------------------------------------------------------------------*/
527 550
@@ -630,7 +653,7 @@ static int usbnet_open (struct net_device *net)
630 653
631 devinfo (dev, "open: enable queueing " 654 devinfo (dev, "open: enable queueing "
632 "(rx %d, tx %d) mtu %d %s framing", 655 "(rx %d, tx %d) mtu %d %s framing",
633 RX_QLEN (dev), TX_QLEN (dev), dev->net->mtu, 656 (int)RX_QLEN (dev), (int)TX_QLEN (dev), dev->net->mtu,
634 framing); 657 framing);
635 } 658 }
636 659
@@ -798,9 +821,9 @@ static void tx_complete (struct urb *urb, struct pt_regs *regs)
798 821
799 // like rx, tx gets controller i/o faults during khubd delays 822 // like rx, tx gets controller i/o faults during khubd delays
800 // and so it uses the same throttling mechanism. 823 // and so it uses the same throttling mechanism.
801 case -EPROTO: // ehci 824 case -EPROTO:
802 case -ETIMEDOUT: // ohci 825 case -ETIME:
803 case -EILSEQ: // uhci 826 case -EILSEQ:
804 if (!timer_pending (&dev->delay)) { 827 if (!timer_pending (&dev->delay)) {
805 mod_timer (&dev->delay, 828 mod_timer (&dev->delay,
806 jiffies + THROTTLE_JIFFIES); 829 jiffies + THROTTLE_JIFFIES);