usbnet.c (bf414b369f158bb527f9f29174ada815f961b44c) usbnet.c (38673c8218a6bcaac97b0243089e33617e28f43f)
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

--- 366 unchanged lines hidden (view full) ---

375static int rx_submit (struct usbnet *dev, struct urb *urb, gfp_t flags)
376{
377 struct sk_buff *skb;
378 struct skb_data *entry;
379 int retval = 0;
380 unsigned long lockflags;
381 size_t size = dev->rx_urb_size;
382
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

--- 366 unchanged lines hidden (view full) ---

375static int rx_submit (struct usbnet *dev, struct urb *urb, gfp_t flags)
376{
377 struct sk_buff *skb;
378 struct skb_data *entry;
379 int retval = 0;
380 unsigned long lockflags;
381 size_t size = dev->rx_urb_size;
382
383 /* prevent rx skb allocation when error ratio is high */
384 if (test_bit(EVENT_RX_KILL, &dev->flags)) {
385 usb_free_urb(urb);
386 return -ENOLINK;
387 }
388
389 skb = __netdev_alloc_skb_ip_align(dev->net, size, flags);
390 if (!skb) {
391 netif_dbg(dev, rx_err, dev->net, "no rx skb\n");
392 usbnet_defer_kevent (dev, EVENT_RX_MEMORY);
393 usb_free_urb (urb);
394 return -ENOMEM;
395 }
396

--- 143 unchanged lines hidden (view full) ---

540
541 default:
542 state = rx_cleanup;
543 dev->net->stats.rx_errors++;
544 netif_dbg(dev, rx_err, dev->net, "rx status %d\n", urb_status);
545 break;
546 }
547
383 skb = __netdev_alloc_skb_ip_align(dev->net, size, flags);
384 if (!skb) {
385 netif_dbg(dev, rx_err, dev->net, "no rx skb\n");
386 usbnet_defer_kevent (dev, EVENT_RX_MEMORY);
387 usb_free_urb (urb);
388 return -ENOMEM;
389 }
390

--- 143 unchanged lines hidden (view full) ---

534
535 default:
536 state = rx_cleanup;
537 dev->net->stats.rx_errors++;
538 netif_dbg(dev, rx_err, dev->net, "rx status %d\n", urb_status);
539 break;
540 }
541
548 /* stop rx if packet error rate is high */
549 if (++dev->pkt_cnt > 30) {
550 dev->pkt_cnt = 0;
551 dev->pkt_err = 0;
552 } else {
553 if (state == rx_cleanup)
554 dev->pkt_err++;
555 if (dev->pkt_err > 20)
556 set_bit(EVENT_RX_KILL, &dev->flags);
557 }
558
559 state = defer_bh(dev, skb, &dev->rxq, state);
560
561 if (urb) {
562 if (netif_running (dev->net) &&
563 !test_bit (EVENT_RX_HALT, &dev->flags) &&
564 state != unlink_start) {
565 rx_submit (dev, urb, GFP_ATOMIC);
566 usb_mark_last_busy(dev->udev);

--- 236 unchanged lines hidden (view full) ---

803 dev->net->mtu,
804 (dev->driver_info->flags & FLAG_FRAMING_NC) ? "NetChip" :
805 (dev->driver_info->flags & FLAG_FRAMING_GL) ? "GeneSys" :
806 (dev->driver_info->flags & FLAG_FRAMING_Z) ? "Zaurus" :
807 (dev->driver_info->flags & FLAG_FRAMING_RN) ? "RNDIS" :
808 (dev->driver_info->flags & FLAG_FRAMING_AX) ? "ASIX" :
809 "simple");
810
542 state = defer_bh(dev, skb, &dev->rxq, state);
543
544 if (urb) {
545 if (netif_running (dev->net) &&
546 !test_bit (EVENT_RX_HALT, &dev->flags) &&
547 state != unlink_start) {
548 rx_submit (dev, urb, GFP_ATOMIC);
549 usb_mark_last_busy(dev->udev);

--- 236 unchanged lines hidden (view full) ---

786 dev->net->mtu,
787 (dev->driver_info->flags & FLAG_FRAMING_NC) ? "NetChip" :
788 (dev->driver_info->flags & FLAG_FRAMING_GL) ? "GeneSys" :
789 (dev->driver_info->flags & FLAG_FRAMING_Z) ? "Zaurus" :
790 (dev->driver_info->flags & FLAG_FRAMING_RN) ? "RNDIS" :
791 (dev->driver_info->flags & FLAG_FRAMING_AX) ? "ASIX" :
792 "simple");
793
811 /* reset rx error state */
812 dev->pkt_cnt = 0;
813 dev->pkt_err = 0;
814 clear_bit(EVENT_RX_KILL, &dev->flags);
815
816 // delay posting reads until we're fully open
817 tasklet_schedule (&dev->bh);
818 if (info->manage_power) {
819 retval = info->manage_power(dev, 1);
820 if (retval < 0) {
821 retval = 0;
822 set_bit(EVENT_NO_RUNTIME_PM, &dev->flags);
823 } else {

--- 296 unchanged lines hidden (view full) ---

1120 if (skb)
1121 skb_tx_timestamp(skb);
1122
1123 // some devices want funky USB-level framing, for
1124 // win32 driver (usually) and/or hardware quirks
1125 if (info->tx_fixup) {
1126 skb = info->tx_fixup (dev, skb, GFP_ATOMIC);
1127 if (!skb) {
794 // delay posting reads until we're fully open
795 tasklet_schedule (&dev->bh);
796 if (info->manage_power) {
797 retval = info->manage_power(dev, 1);
798 if (retval < 0) {
799 retval = 0;
800 set_bit(EVENT_NO_RUNTIME_PM, &dev->flags);
801 } else {

--- 296 unchanged lines hidden (view full) ---

1098 if (skb)
1099 skb_tx_timestamp(skb);
1100
1101 // some devices want funky USB-level framing, for
1102 // win32 driver (usually) and/or hardware quirks
1103 if (info->tx_fixup) {
1104 skb = info->tx_fixup (dev, skb, GFP_ATOMIC);
1105 if (!skb) {
1128 /* packet collected; minidriver waiting for more */
1129 if (info->flags & FLAG_MULTI_PACKET)
1106 if (netif_msg_tx_err(dev)) {
1107 netif_dbg(dev, tx_err, dev->net, "can't tx_fixup skb\n");
1108 goto drop;
1109 } else {
1110 /* cdc_ncm collected packet; waits for more */
1130 goto not_drop;
1111 goto not_drop;
1131 netif_dbg(dev, tx_err, dev->net, "can't tx_fixup skb\n");
1132 goto drop;
1112 }
1133 }
1134 }
1135 length = skb->len;
1136
1137 if (!(urb = usb_alloc_urb (0, GFP_ATOMIC))) {
1138 netif_dbg(dev, tx_err, dev->net, "no urb\n");
1139 goto drop;
1140 }

--- 128 unchanged lines hidden (view full) ---

1269 usb_free_urb (entry->urb);
1270 dev_kfree_skb (skb);
1271 continue;
1272 default:
1273 netdev_dbg(dev->net, "bogus skb state %d\n", entry->state);
1274 }
1275 }
1276
1113 }
1114 }
1115 length = skb->len;
1116
1117 if (!(urb = usb_alloc_urb (0, GFP_ATOMIC))) {
1118 netif_dbg(dev, tx_err, dev->net, "no urb\n");
1119 goto drop;
1120 }

--- 128 unchanged lines hidden (view full) ---

1249 usb_free_urb (entry->urb);
1250 dev_kfree_skb (skb);
1251 continue;
1252 default:
1253 netdev_dbg(dev->net, "bogus skb state %d\n", entry->state);
1254 }
1255 }
1256
1277 /* restart RX again after disabling due to high error rate */
1278 clear_bit(EVENT_RX_KILL, &dev->flags);
1279
1280 // waiting for all pending urbs to complete?
1281 if (dev->wait) {
1282 if ((dev->txq.qlen + dev->rxq.qlen + dev->done.qlen) == 0) {
1283 wake_up (dev->wait);
1284 }
1285
1286 // or are we maybe short a few urbs?
1287 } else if (netif_running (dev->net) &&

--- 520 unchanged lines hidden (view full) ---

1808 if (!buf) {
1809 netdev_err(dev->net, "Error allocating buffer"
1810 " in %s!\n", __func__);
1811 goto fail_free;
1812 }
1813 }
1814
1815 req = kmalloc(sizeof(struct usb_ctrlrequest), GFP_ATOMIC);
1257 // waiting for all pending urbs to complete?
1258 if (dev->wait) {
1259 if ((dev->txq.qlen + dev->rxq.qlen + dev->done.qlen) == 0) {
1260 wake_up (dev->wait);
1261 }
1262
1263 // or are we maybe short a few urbs?
1264 } else if (netif_running (dev->net) &&

--- 520 unchanged lines hidden (view full) ---

1785 if (!buf) {
1786 netdev_err(dev->net, "Error allocating buffer"
1787 " in %s!\n", __func__);
1788 goto fail_free;
1789 }
1790 }
1791
1792 req = kmalloc(sizeof(struct usb_ctrlrequest), GFP_ATOMIC);
1816 if (!req) {
1817 netdev_err(dev->net, "Failed to allocate memory for %s\n",
1818 __func__);
1793 if (!req)
1819 goto fail_free_buf;
1794 goto fail_free_buf;
1820 }
1821
1822 req->bRequestType = reqtype;
1823 req->bRequest = cmd;
1824 req->wValue = cpu_to_le16(value);
1825 req->wIndex = cpu_to_le16(index);
1826 req->wLength = cpu_to_le16(size);
1827
1828 usb_fill_control_urb(urb, dev->udev,

--- 44 unchanged lines hidden ---
1795
1796 req->bRequestType = reqtype;
1797 req->bRequest = cmd;
1798 req->wValue = cpu_to_le16(value);
1799 req->wIndex = cpu_to_le16(index);
1800 req->wLength = cpu_to_le16(size);
1801
1802 usb_fill_control_urb(urb, dev->udev,

--- 44 unchanged lines hidden ---