Lines Matching +full:autosuspend +full:- +full:period

1 // SPDX-License-Identifier: GPL-2.0-or-later
4 * Copyright (C) 2000-2005 by David Brownell
5 * Copyright (C) 2003-2005 David Hollis <dhollis@davehollis.com>
10 * kinds of full and high speed networking devices: host-to-host cables,
34 /*-------------------------------------------------------------------------*/
48 #define RX_QLEN(dev) ((dev)->rx_qlen)
49 #define TX_QLEN(dev) ((dev)->tx_qlen)
62 /*-------------------------------------------------------------------------*/
65 static int msg_level = -1;
69 /*-------------------------------------------------------------------------*/
96 for (tmp = 0; tmp < intf->num_altsetting; tmp++) { in usbnet_get_endpoints()
100 alt = intf->altsetting + tmp; in usbnet_get_endpoints()
102 /* take the first altsetting with in-bulk + out-bulk; in usbnet_get_endpoints()
106 for (ep = 0; ep < alt->desc.bNumEndpoints; ep++) { in usbnet_get_endpoints()
110 e = alt->endpoint + ep; in usbnet_get_endpoints()
113 if (!usb_endpoint_maxp(&e->desc)) in usbnet_get_endpoints()
116 switch (e->desc.bmAttributes) { in usbnet_get_endpoints()
118 if (!usb_endpoint_dir_in(&e->desc)) in usbnet_get_endpoints()
127 if (usb_endpoint_dir_in(&e->desc)) { in usbnet_get_endpoints()
141 return -EINVAL; in usbnet_get_endpoints()
143 if (alt->desc.bAlternateSetting != 0 || in usbnet_get_endpoints()
144 !(dev->driver_info->flags & FLAG_NO_SETINT)) { in usbnet_get_endpoints()
145 tmp = usb_set_interface (dev->udev, alt->desc.bInterfaceNumber, in usbnet_get_endpoints()
146 alt->desc.bAlternateSetting); in usbnet_get_endpoints()
151 dev->in = usb_rcvbulkpipe (dev->udev, in usbnet_get_endpoints()
152 in->desc.bEndpointAddress & USB_ENDPOINT_NUMBER_MASK); in usbnet_get_endpoints()
153 dev->out = usb_sndbulkpipe (dev->udev, in usbnet_get_endpoints()
154 out->desc.bEndpointAddress & USB_ENDPOINT_NUMBER_MASK); in usbnet_get_endpoints()
155 dev->status = status; in usbnet_get_endpoints()
163 int tmp = -1, ret; in usbnet_get_ethernet_addr()
166 ret = usb_string(dev->udev, iMACAddress, buf, sizeof buf); in usbnet_get_ethernet_addr()
170 dev_dbg(&dev->udev->dev, in usbnet_get_ethernet_addr()
173 ret = -EINVAL; in usbnet_get_ethernet_addr()
176 eth_hw_addr_set(dev->net, addr); in usbnet_get_ethernet_addr()
183 struct usbnet *dev = urb->context; in intr_complete()
184 int status = urb->status; in intr_complete()
189 dev->driver_info->status(dev, urb); in intr_complete()
192 /* software-driven interface shutdown */ in intr_complete()
193 case -ENOENT: /* urb killed */ in intr_complete()
194 case -ESHUTDOWN: /* hardware gone */ in intr_complete()
195 netif_dbg(dev, ifdown, dev->net, in intr_complete()
203 netdev_dbg(dev->net, "intr status %d\n", status); in intr_complete()
209 netif_err(dev, timer, dev->net, in intr_complete()
210 "intr resubmit --> %d\n", status); in intr_complete()
218 unsigned period; in init_status() local
220 if (!dev->driver_info->status) in init_status()
223 pipe = usb_rcvintpipe (dev->udev, in init_status()
224 dev->status->desc.bEndpointAddress in init_status()
226 maxp = usb_maxpacket(dev->udev, pipe); in init_status()
229 period = max ((int) dev->status->desc.bInterval, in init_status()
230 (dev->udev->speed == USB_SPEED_HIGH) ? 7 : 3); in init_status()
234 dev->interrupt = usb_alloc_urb (0, GFP_KERNEL); in init_status()
235 if (!dev->interrupt) { in init_status()
237 return -ENOMEM; in init_status()
239 usb_fill_int_urb(dev->interrupt, dev->udev, pipe, in init_status()
240 buf, maxp, intr_complete, dev, period); in init_status()
241 dev->interrupt->transfer_flags |= URB_FREE_BUFFER; in init_status()
242 dev_dbg(&intf->dev, in init_status()
243 "status ep%din, %d bytes period %d\n", in init_status()
244 usb_pipeendpoint(pipe), maxp, period); in init_status()
255 WARN_ON_ONCE(dev->interrupt == NULL); in usbnet_status_start()
256 if (dev->interrupt) { in usbnet_status_start()
257 mutex_lock(&dev->interrupt_mutex); in usbnet_status_start()
259 if (++dev->interrupt_count == 1) in usbnet_status_start()
260 ret = usb_submit_urb(dev->interrupt, mem_flags); in usbnet_status_start()
262 dev_dbg(&dev->udev->dev, "incremented interrupt URB count to %d\n", in usbnet_status_start()
263 dev->interrupt_count); in usbnet_status_start()
264 mutex_unlock(&dev->interrupt_mutex); in usbnet_status_start()
275 mutex_lock(&dev->interrupt_mutex); in __usbnet_status_start_force()
276 if (dev->interrupt_count) { in __usbnet_status_start_force()
277 ret = usb_submit_urb(dev->interrupt, mem_flags); in __usbnet_status_start_force()
278 dev_dbg(&dev->udev->dev, in __usbnet_status_start_force()
281 mutex_unlock(&dev->interrupt_mutex); in __usbnet_status_start_force()
288 if (dev->interrupt) { in usbnet_status_stop()
289 mutex_lock(&dev->interrupt_mutex); in usbnet_status_stop()
290 WARN_ON(dev->interrupt_count == 0); in usbnet_status_stop()
292 if (dev->interrupt_count && --dev->interrupt_count == 0) in usbnet_status_stop()
293 usb_kill_urb(dev->interrupt); in usbnet_status_stop()
295 dev_dbg(&dev->udev->dev, in usbnet_status_stop()
297 dev->interrupt_count); in usbnet_status_stop()
298 mutex_unlock(&dev->interrupt_mutex); in usbnet_status_stop()
306 if (dev->interrupt) { in __usbnet_status_stop_force()
307 mutex_lock(&dev->interrupt_mutex); in __usbnet_status_stop_force()
308 usb_kill_urb(dev->interrupt); in __usbnet_status_stop_force()
309 dev_dbg(&dev->udev->dev, "killed interrupt URB for suspend\n"); in __usbnet_status_stop_force()
310 mutex_unlock(&dev->interrupt_mutex); in __usbnet_status_stop_force()
320 struct pcpu_sw_netstats *stats64 = this_cpu_ptr(dev->net->tstats); in usbnet_skb_return()
324 if (test_bit(EVENT_RX_PAUSED, &dev->flags)) { in usbnet_skb_return()
325 skb_queue_tail(&dev->rxq_pause, skb); in usbnet_skb_return()
330 if (skb->protocol == 0) in usbnet_skb_return()
331 skb->protocol = eth_type_trans (skb, dev->net); in usbnet_skb_return()
333 flags = u64_stats_update_begin_irqsave(&stats64->syncp); in usbnet_skb_return()
334 u64_stats_inc(&stats64->rx_packets); in usbnet_skb_return()
335 u64_stats_add(&stats64->rx_bytes, skb->len); in usbnet_skb_return()
336 u64_stats_update_end_irqrestore(&stats64->syncp, flags); in usbnet_skb_return()
338 netif_dbg(dev, rx_status, dev->net, "< rx, len %zu, type 0x%x\n", in usbnet_skb_return()
339 skb->len + sizeof (struct ethhdr), skb->protocol); in usbnet_skb_return()
340 memset (skb->cb, 0, sizeof (struct skb_data)); in usbnet_skb_return()
347 netif_dbg(dev, rx_err, dev->net, in usbnet_skb_return()
355 enum usb_device_speed speed = dev->udev->speed; in usbnet_update_max_qlen()
357 if (!dev->rx_urb_size || !dev->hard_mtu) in usbnet_update_max_qlen()
361 dev->rx_qlen = MAX_QUEUE_MEMORY / dev->rx_urb_size; in usbnet_update_max_qlen()
362 dev->tx_qlen = MAX_QUEUE_MEMORY / dev->hard_mtu; in usbnet_update_max_qlen()
371 dev->rx_qlen = 5 * MAX_QUEUE_MEMORY / dev->rx_urb_size; in usbnet_update_max_qlen()
372 dev->tx_qlen = 5 * MAX_QUEUE_MEMORY / dev->hard_mtu; in usbnet_update_max_qlen()
376 dev->rx_qlen = dev->tx_qlen = 4; in usbnet_update_max_qlen()
382 /*-------------------------------------------------------------------------
386 *-------------------------------------------------------------------------*/
391 int ll_mtu = new_mtu + net->hard_header_len; in usbnet_change_mtu()
392 int old_hard_mtu = dev->hard_mtu; in usbnet_change_mtu()
393 int old_rx_urb_size = dev->rx_urb_size; in usbnet_change_mtu()
395 // no second zero-length packet read wanted after mtu-sized packets in usbnet_change_mtu()
396 if ((ll_mtu % dev->maxpacket) == 0) in usbnet_change_mtu()
397 return -EDOM; in usbnet_change_mtu()
398 WRITE_ONCE(net->mtu, new_mtu); in usbnet_change_mtu()
400 dev->hard_mtu = net->mtu + net->hard_header_len; in usbnet_change_mtu()
401 if (dev->rx_urb_size == old_hard_mtu) { in usbnet_change_mtu()
402 dev->rx_urb_size = dev->hard_mtu; in usbnet_change_mtu()
403 if (dev->rx_urb_size > old_rx_urb_size) { in usbnet_change_mtu()
417 /* The caller must hold list->lock */
421 struct skb_data *entry = (struct skb_data *) newsk->cb; in __usbnet_queue_skb()
424 entry->state = state; in __usbnet_queue_skb()
427 /*-------------------------------------------------------------------------*/
438 struct skb_data *entry = (struct skb_data *) skb->cb; in defer_bh()
440 spin_lock_irqsave(&list->lock, flags); in defer_bh()
441 old_state = entry->state; in defer_bh()
442 entry->state = state; in defer_bh()
445 /* defer_bh() is never called with list == &dev->done. in defer_bh()
447 * dev->done.lock here with list->lock held. in defer_bh()
449 spin_lock_nested(&dev->done.lock, SINGLE_DEPTH_NESTING); in defer_bh()
451 __skb_queue_tail(&dev->done, skb); in defer_bh()
452 if (dev->done.qlen == 1) in defer_bh()
453 tasklet_schedule(&dev->bh); in defer_bh()
454 spin_unlock(&dev->done.lock); in defer_bh()
455 spin_unlock_irqrestore(&list->lock, flags); in defer_bh()
466 set_bit (work, &dev->flags); in usbnet_defer_kevent()
468 if (!schedule_work(&dev->kevent)) in usbnet_defer_kevent()
469 netdev_dbg(dev->net, in usbnet_defer_kevent()
473 netdev_dbg(dev->net, in usbnet_defer_kevent()
479 /*-------------------------------------------------------------------------*/
489 size_t size = dev->rx_urb_size; in rx_submit()
492 if (test_bit(EVENT_RX_KILL, &dev->flags)) { in rx_submit()
494 return -ENOLINK; in rx_submit()
497 if (test_bit(EVENT_NO_IP_ALIGN, &dev->flags)) in rx_submit()
498 skb = __netdev_alloc_skb(dev->net, size, flags); in rx_submit()
500 skb = __netdev_alloc_skb_ip_align(dev->net, size, flags); in rx_submit()
502 netif_dbg(dev, rx_err, dev->net, "no rx skb\n"); in rx_submit()
505 return -ENOMEM; in rx_submit()
508 entry = (struct skb_data *) skb->cb; in rx_submit()
509 entry->urb = urb; in rx_submit()
510 entry->dev = dev; in rx_submit()
511 entry->length = 0; in rx_submit()
513 usb_fill_bulk_urb (urb, dev->udev, dev->in, in rx_submit()
514 skb->data, size, rx_complete, skb); in rx_submit()
516 spin_lock_irqsave (&dev->rxq.lock, lockflags); in rx_submit()
518 if (netif_running (dev->net) && in rx_submit()
519 netif_device_present (dev->net) && in rx_submit()
520 test_bit(EVENT_DEV_OPEN, &dev->flags) && in rx_submit()
521 !test_bit (EVENT_RX_HALT, &dev->flags) && in rx_submit()
522 !test_bit (EVENT_DEV_ASLEEP, &dev->flags)) { in rx_submit()
524 case -EPIPE: in rx_submit()
527 case -ENOMEM: in rx_submit()
530 case -ENODEV: in rx_submit()
531 netif_dbg(dev, ifdown, dev->net, "device gone\n"); in rx_submit()
532 netif_device_detach (dev->net); in rx_submit()
534 case -EHOSTUNREACH: in rx_submit()
535 retval = -ENOLINK; in rx_submit()
538 netif_dbg(dev, rx_err, dev->net, in rx_submit()
540 tasklet_schedule (&dev->bh); in rx_submit()
544 __usbnet_queue_skb(&dev->rxq, skb, rx_start); in rx_submit()
547 netif_dbg(dev, ifdown, dev->net, "rx: stopped\n"); in rx_submit()
548 retval = -ENOLINK; in rx_submit()
550 spin_unlock_irqrestore (&dev->rxq.lock, lockflags); in rx_submit()
559 /*-------------------------------------------------------------------------*/
563 if (dev->driver_info->rx_fixup && in rx_process()
564 !dev->driver_info->rx_fixup (dev, skb)) { in rx_process()
566 if (!(dev->driver_info->flags & FLAG_RX_ASSEMBLE)) in rx_process()
567 dev->net->stats.rx_errors++; in rx_process()
568 return -EPROTO; in rx_process()
573 if (dev->driver_info->flags & FLAG_MULTI_PACKET) in rx_process()
574 return -EALREADY; in rx_process()
576 if (skb->len < ETH_HLEN) { in rx_process()
577 dev->net->stats.rx_errors++; in rx_process()
578 dev->net->stats.rx_length_errors++; in rx_process()
579 netif_dbg(dev, rx_err, dev->net, "rx length %d\n", skb->len); in rx_process()
580 return -EPROTO; in rx_process()
587 /*-------------------------------------------------------------------------*/
591 struct sk_buff *skb = (struct sk_buff *) urb->context; in rx_complete()
592 struct skb_data *entry = (struct skb_data *) skb->cb; in rx_complete()
593 struct usbnet *dev = entry->dev; in rx_complete()
594 int urb_status = urb->status; in rx_complete()
597 skb_put (skb, urb->actual_length); in rx_complete()
599 entry->urb = NULL; in rx_complete()
611 case -EPIPE: in rx_complete()
612 dev->net->stats.rx_errors++; in rx_complete()
616 /* software-driven interface shutdown */ in rx_complete()
617 case -ECONNRESET: /* async unlink */ in rx_complete()
618 case -ESHUTDOWN: /* hardware gone */ in rx_complete()
619 netif_dbg(dev, ifdown, dev->net, in rx_complete()
627 case -EPROTO: in rx_complete()
628 case -ETIME: in rx_complete()
629 case -EILSEQ: in rx_complete()
630 dev->net->stats.rx_errors++; in rx_complete()
631 if (!timer_pending (&dev->delay)) { in rx_complete()
632 mod_timer (&dev->delay, jiffies + THROTTLE_JIFFIES); in rx_complete()
633 netif_dbg(dev, link, dev->net, in rx_complete()
638 entry->urb = urb; in rx_complete()
643 case -EOVERFLOW: in rx_complete()
644 dev->net->stats.rx_over_errors++; in rx_complete()
649 dev->net->stats.rx_errors++; in rx_complete()
650 netif_dbg(dev, rx_err, dev->net, "rx status %d\n", urb_status); in rx_complete()
655 if (++dev->pkt_cnt > 30) { in rx_complete()
656 dev->pkt_cnt = 0; in rx_complete()
657 dev->pkt_err = 0; in rx_complete()
660 dev->pkt_err++; in rx_complete()
661 if (dev->pkt_err > 20) in rx_complete()
662 set_bit(EVENT_RX_KILL, &dev->flags); in rx_complete()
665 state = defer_bh(dev, skb, &dev->rxq, state); in rx_complete()
668 if (netif_running (dev->net) && in rx_complete()
669 !test_bit (EVENT_RX_HALT, &dev->flags) && in rx_complete()
672 usb_mark_last_busy(dev->udev); in rx_complete()
677 netif_dbg(dev, rx_err, dev->net, "no read resubmitted\n"); in rx_complete()
680 /*-------------------------------------------------------------------------*/
683 set_bit(EVENT_RX_PAUSED, &dev->flags); in usbnet_pause_rx()
685 netif_dbg(dev, rx_status, dev->net, "paused rx queue enabled\n"); in usbnet_pause_rx()
694 clear_bit(EVENT_RX_PAUSED, &dev->flags); in usbnet_resume_rx()
696 while ((skb = skb_dequeue(&dev->rxq_pause)) != NULL) { in usbnet_resume_rx()
701 tasklet_schedule(&dev->bh); in usbnet_resume_rx()
703 netif_dbg(dev, rx_status, dev->net, in usbnet_resume_rx()
710 skb_queue_purge(&dev->rxq_pause); in usbnet_purge_paused_rxq()
714 /*-------------------------------------------------------------------------*/
724 spin_lock_irqsave (&q->lock, flags); in unlink_urbs()
731 entry = (struct skb_data *) skb->cb; in unlink_urbs()
732 if (entry->state != unlink_start) in unlink_urbs()
737 entry->state = unlink_start; in unlink_urbs()
738 urb = entry->urb; in unlink_urbs()
743 * use-after-free problem inside usb_unlink_urb since in unlink_urbs()
748 spin_unlock_irqrestore(&q->lock, flags); in unlink_urbs()
749 // during some PM-driven resume scenarios, in unlink_urbs()
752 if (retval != -EINPROGRESS && retval != 0) in unlink_urbs()
753 netdev_dbg(dev->net, "unlink urb err, %d\n", retval); in unlink_urbs()
757 spin_lock_irqsave(&q->lock, flags); in unlink_urbs()
759 spin_unlock_irqrestore (&q->lock, flags); in unlink_urbs()
768 if (netif_running(dev->net)) { in usbnet_unlink_rx_urbs()
769 (void) unlink_urbs (dev, &dev->rxq); in usbnet_unlink_rx_urbs()
770 tasklet_schedule(&dev->bh); in usbnet_unlink_rx_urbs()
775 /*-------------------------------------------------------------------------*/
781 spin_lock_irqsave(&q->lock, flags); in wait_skb_queue_empty()
783 spin_unlock_irqrestore(&q->lock, flags); in wait_skb_queue_empty()
786 spin_lock_irqsave(&q->lock, flags); in wait_skb_queue_empty()
788 spin_unlock_irqrestore(&q->lock, flags); in wait_skb_queue_empty()
798 add_wait_queue(&dev->wait, &wait); in usbnet_terminate_urbs()
800 temp = unlink_urbs(dev, &dev->txq) + in usbnet_terminate_urbs()
801 unlink_urbs(dev, &dev->rxq); in usbnet_terminate_urbs()
804 wait_skb_queue_empty(&dev->rxq); in usbnet_terminate_urbs()
805 wait_skb_queue_empty(&dev->txq); in usbnet_terminate_urbs()
806 wait_skb_queue_empty(&dev->done); in usbnet_terminate_urbs()
807 netif_dbg(dev, ifdown, dev->net, in usbnet_terminate_urbs()
810 remove_wait_queue(&dev->wait, &wait); in usbnet_terminate_urbs()
816 const struct driver_info *info = dev->driver_info; in usbnet_stop()
819 clear_bit(EVENT_DEV_OPEN, &dev->flags); in usbnet_stop()
822 netif_info(dev, ifdown, dev->net, in usbnet_stop()
824 net->stats.rx_packets, net->stats.tx_packets, in usbnet_stop()
825 net->stats.rx_errors, net->stats.tx_errors); in usbnet_stop()
828 pm = usb_autopm_get_interface(dev->intf); in usbnet_stop()
831 if (info->stop) { in usbnet_stop()
832 retval = info->stop(dev); in usbnet_stop()
834 netif_info(dev, ifdown, dev->net, in usbnet_stop()
835 "stop fail (%d) usbnet usb-%s-%s, %s\n", in usbnet_stop()
837 dev->udev->bus->bus_name, dev->udev->devpath, in usbnet_stop()
838 info->description); in usbnet_stop()
841 if (!(info->flags & FLAG_AVOID_UNLINK_URBS)) in usbnet_stop()
848 mpn = !test_and_clear_bit(EVENT_NO_RUNTIME_PM, &dev->flags); in usbnet_stop()
851 dev->flags = 0; in usbnet_stop()
852 del_timer_sync(&dev->delay); in usbnet_stop()
853 tasklet_kill(&dev->bh); in usbnet_stop()
854 cancel_work_sync(&dev->kevent); in usbnet_stop()
860 tasklet_kill(&dev->bh); in usbnet_stop()
861 del_timer_sync(&dev->delay); in usbnet_stop()
862 cancel_work_sync(&dev->kevent); in usbnet_stop()
865 usb_autopm_put_interface(dev->intf); in usbnet_stop()
867 if (info->manage_power && mpn) in usbnet_stop()
868 info->manage_power(dev, 0); in usbnet_stop()
870 usb_autopm_put_interface(dev->intf); in usbnet_stop()
876 /*-------------------------------------------------------------------------*/
886 const struct driver_info *info = dev->driver_info; in usbnet_open()
888 if ((retval = usb_autopm_get_interface(dev->intf)) < 0) { in usbnet_open()
889 netif_info(dev, ifup, dev->net, in usbnet_open()
890 "resumption fail (%d) usbnet usb-%s-%s, %s\n", in usbnet_open()
892 dev->udev->bus->bus_name, in usbnet_open()
893 dev->udev->devpath, in usbnet_open()
894 info->description); in usbnet_open()
899 if (info->reset && (retval = info->reset (dev)) < 0) { in usbnet_open()
900 netif_info(dev, ifup, dev->net, in usbnet_open()
901 "open reset fail (%d) usbnet usb-%s-%s, %s\n", in usbnet_open()
903 dev->udev->bus->bus_name, in usbnet_open()
904 dev->udev->devpath, in usbnet_open()
905 info->description); in usbnet_open()
913 if (info->check_connect && (retval = info->check_connect (dev)) < 0) { in usbnet_open()
914 netif_err(dev, ifup, dev->net, "can't open; %d\n", retval); in usbnet_open()
919 if (dev->interrupt) { in usbnet_open()
922 netif_err(dev, ifup, dev->net, in usbnet_open()
928 set_bit(EVENT_DEV_OPEN, &dev->flags); in usbnet_open()
930 netif_info(dev, ifup, dev->net, in usbnet_open()
933 dev->net->mtu, in usbnet_open()
934 (dev->driver_info->flags & FLAG_FRAMING_NC) ? "NetChip" : in usbnet_open()
935 (dev->driver_info->flags & FLAG_FRAMING_GL) ? "GeneSys" : in usbnet_open()
936 (dev->driver_info->flags & FLAG_FRAMING_Z) ? "Zaurus" : in usbnet_open()
937 (dev->driver_info->flags & FLAG_FRAMING_RN) ? "RNDIS" : in usbnet_open()
938 (dev->driver_info->flags & FLAG_FRAMING_AX) ? "ASIX" : in usbnet_open()
942 dev->pkt_cnt = 0; in usbnet_open()
943 dev->pkt_err = 0; in usbnet_open()
944 clear_bit(EVENT_RX_KILL, &dev->flags); in usbnet_open()
947 tasklet_schedule (&dev->bh); in usbnet_open()
948 if (info->manage_power) { in usbnet_open()
949 retval = info->manage_power(dev, 1); in usbnet_open()
952 set_bit(EVENT_NO_RUNTIME_PM, &dev->flags); in usbnet_open()
954 usb_autopm_put_interface(dev->intf); in usbnet_open()
959 usb_autopm_put_interface(dev->intf); in usbnet_open()
965 /*-------------------------------------------------------------------------*/
979 if (!dev->mii.mdio_read) in usbnet_get_link_ksettings_mii()
980 return -EOPNOTSUPP; in usbnet_get_link_ksettings_mii()
982 mii_ethtool_get_link_ksettings(&dev->mii, cmd); in usbnet_get_link_ksettings_mii()
998 if (dev->rx_speed != SPEED_UNSET) in usbnet_get_link_ksettings_internal()
999 cmd->base.speed = dev->rx_speed / 1000000; in usbnet_get_link_ksettings_internal()
1000 else if (dev->tx_speed != SPEED_UNSET) in usbnet_get_link_ksettings_internal()
1001 cmd->base.speed = dev->tx_speed / 1000000; in usbnet_get_link_ksettings_internal()
1003 cmd->base.speed = SPEED_UNKNOWN; in usbnet_get_link_ksettings_internal()
1015 if (!dev->mii.mdio_write) in usbnet_set_link_ksettings_mii()
1016 return -EOPNOTSUPP; in usbnet_set_link_ksettings_mii()
1018 retval = mii_ethtool_set_link_ksettings(&dev->mii, cmd); in usbnet_set_link_ksettings_mii()
1021 if (dev->driver_info->link_reset) in usbnet_set_link_ksettings_mii()
1022 dev->driver_info->link_reset(dev); in usbnet_set_link_ksettings_mii()
1036 if (dev->driver_info->check_connect) in usbnet_get_link()
1037 return dev->driver_info->check_connect (dev) == 0; in usbnet_get_link()
1040 if (dev->mii.mdio_read) in usbnet_get_link()
1041 return mii_link_ok(&dev->mii); in usbnet_get_link()
1052 if (!dev->mii.mdio_write) in usbnet_nway_reset()
1053 return -EOPNOTSUPP; in usbnet_nway_reset()
1055 return mii_nway_restart(&dev->mii); in usbnet_nway_reset()
1063 strscpy(info->driver, dev->driver_name, sizeof(info->driver)); in usbnet_get_drvinfo()
1064 strscpy(info->fw_version, dev->driver_info->description, in usbnet_get_drvinfo()
1065 sizeof(info->fw_version)); in usbnet_get_drvinfo()
1066 usb_make_path (dev->udev, info->bus_info, sizeof info->bus_info); in usbnet_get_drvinfo()
1074 return dev->msg_enable; in usbnet_get_msglevel()
1082 dev->msg_enable = level; in usbnet_set_msglevel()
1098 /*-------------------------------------------------------------------------*/
1102 if (!test_bit(EVENT_DEV_OPEN, &dev->flags)) in __handle_link_change()
1105 if (!netif_carrier_ok(dev->net)) { in __handle_link_change()
1107 unlink_urbs(dev, &dev->rxq); in __handle_link_change()
1115 tasklet_schedule(&dev->bh); in __handle_link_change()
1121 clear_bit(EVENT_LINK_CHANGE, &dev->flags); in __handle_link_change()
1134 if (dev->driver_info->set_rx_mode) in __handle_set_rx_mode()
1135 (dev->driver_info->set_rx_mode)(dev); in __handle_set_rx_mode()
1137 clear_bit(EVENT_SET_RX_MODE, &dev->flags); in __handle_set_rx_mode()
1153 if (test_bit (EVENT_TX_HALT, &dev->flags)) { in usbnet_deferred_kevent()
1154 unlink_urbs (dev, &dev->txq); in usbnet_deferred_kevent()
1155 status = usb_autopm_get_interface(dev->intf); in usbnet_deferred_kevent()
1158 status = usb_clear_halt (dev->udev, dev->out); in usbnet_deferred_kevent()
1159 usb_autopm_put_interface(dev->intf); in usbnet_deferred_kevent()
1161 status != -EPIPE && in usbnet_deferred_kevent()
1162 status != -ESHUTDOWN) { in usbnet_deferred_kevent()
1165 netdev_err(dev->net, "can't clear tx halt, status %d\n", in usbnet_deferred_kevent()
1168 clear_bit (EVENT_TX_HALT, &dev->flags); in usbnet_deferred_kevent()
1169 if (status != -ESHUTDOWN) in usbnet_deferred_kevent()
1170 netif_wake_queue (dev->net); in usbnet_deferred_kevent()
1173 if (test_bit (EVENT_RX_HALT, &dev->flags)) { in usbnet_deferred_kevent()
1174 unlink_urbs (dev, &dev->rxq); in usbnet_deferred_kevent()
1175 status = usb_autopm_get_interface(dev->intf); in usbnet_deferred_kevent()
1178 status = usb_clear_halt (dev->udev, dev->in); in usbnet_deferred_kevent()
1179 usb_autopm_put_interface(dev->intf); in usbnet_deferred_kevent()
1181 status != -EPIPE && in usbnet_deferred_kevent()
1182 status != -ESHUTDOWN) { in usbnet_deferred_kevent()
1185 netdev_err(dev->net, "can't clear rx halt, status %d\n", in usbnet_deferred_kevent()
1188 clear_bit (EVENT_RX_HALT, &dev->flags); in usbnet_deferred_kevent()
1190 tasklet_schedule(&dev->bh); in usbnet_deferred_kevent()
1195 if (test_bit (EVENT_RX_MEMORY, &dev->flags)) { in usbnet_deferred_kevent()
1199 if (netif_running (dev->net)) in usbnet_deferred_kevent()
1202 clear_bit (EVENT_RX_MEMORY, &dev->flags); in usbnet_deferred_kevent()
1204 clear_bit (EVENT_RX_MEMORY, &dev->flags); in usbnet_deferred_kevent()
1205 status = usb_autopm_get_interface(dev->intf); in usbnet_deferred_kevent()
1210 if (rx_submit (dev, urb, GFP_KERNEL) == -ENOLINK) in usbnet_deferred_kevent()
1212 usb_autopm_put_interface(dev->intf); in usbnet_deferred_kevent()
1216 tasklet_schedule(&dev->bh); in usbnet_deferred_kevent()
1220 if (test_bit (EVENT_LINK_RESET, &dev->flags)) { in usbnet_deferred_kevent()
1221 const struct driver_info *info = dev->driver_info; in usbnet_deferred_kevent()
1224 clear_bit (EVENT_LINK_RESET, &dev->flags); in usbnet_deferred_kevent()
1225 status = usb_autopm_get_interface(dev->intf); in usbnet_deferred_kevent()
1228 if(info->link_reset && (retval = info->link_reset(dev)) < 0) { in usbnet_deferred_kevent()
1229 usb_autopm_put_interface(dev->intf); in usbnet_deferred_kevent()
1231 netdev_info(dev->net, "link reset failed (%d) usbnet usb-%s-%s, %s\n", in usbnet_deferred_kevent()
1233 dev->udev->bus->bus_name, in usbnet_deferred_kevent()
1234 dev->udev->devpath, in usbnet_deferred_kevent()
1235 info->description); in usbnet_deferred_kevent()
1237 usb_autopm_put_interface(dev->intf); in usbnet_deferred_kevent()
1244 if (test_bit (EVENT_LINK_CHANGE, &dev->flags)) in usbnet_deferred_kevent()
1247 if (test_bit (EVENT_SET_RX_MODE, &dev->flags)) in usbnet_deferred_kevent()
1251 if (dev->flags) in usbnet_deferred_kevent()
1252 netdev_dbg(dev->net, "kevent done, flags = 0x%lx\n", dev->flags); in usbnet_deferred_kevent()
1255 /*-------------------------------------------------------------------------*/
1259 struct sk_buff *skb = (struct sk_buff *) urb->context; in tx_complete()
1260 struct skb_data *entry = (struct skb_data *) skb->cb; in tx_complete()
1261 struct usbnet *dev = entry->dev; in tx_complete()
1263 if (urb->status == 0) { in tx_complete()
1264 struct pcpu_sw_netstats *stats64 = this_cpu_ptr(dev->net->tstats); in tx_complete()
1267 flags = u64_stats_update_begin_irqsave(&stats64->syncp); in tx_complete()
1268 u64_stats_add(&stats64->tx_packets, entry->packets); in tx_complete()
1269 u64_stats_add(&stats64->tx_bytes, entry->length); in tx_complete()
1270 u64_stats_update_end_irqrestore(&stats64->syncp, flags); in tx_complete()
1272 dev->net->stats.tx_errors++; in tx_complete()
1274 switch (urb->status) { in tx_complete()
1275 case -EPIPE: in tx_complete()
1279 /* software-driven interface shutdown */ in tx_complete()
1280 case -ECONNRESET: // async unlink in tx_complete()
1281 case -ESHUTDOWN: // hardware gone in tx_complete()
1287 case -EPROTO: in tx_complete()
1288 case -ETIME: in tx_complete()
1289 case -EILSEQ: in tx_complete()
1290 usb_mark_last_busy(dev->udev); in tx_complete()
1291 if (!timer_pending (&dev->delay)) { in tx_complete()
1292 mod_timer (&dev->delay, in tx_complete()
1294 netif_dbg(dev, link, dev->net, in tx_complete()
1295 "tx throttle %d\n", urb->status); in tx_complete()
1297 netif_stop_queue (dev->net); in tx_complete()
1300 netif_dbg(dev, tx_err, dev->net, in tx_complete()
1301 "tx err %d\n", entry->urb->status); in tx_complete()
1306 usb_autopm_put_interface_async(dev->intf); in tx_complete()
1307 (void) defer_bh(dev, skb, &dev->txq, tx_done); in tx_complete()
1310 /*-------------------------------------------------------------------------*/
1316 unlink_urbs (dev, &dev->txq); in usbnet_tx_timeout()
1317 tasklet_schedule (&dev->bh); in usbnet_tx_timeout()
1322 if (dev->driver_info->recover) in usbnet_tx_timeout()
1323 (dev->driver_info->recover)(dev); in usbnet_tx_timeout()
1327 /*-------------------------------------------------------------------------*/
1334 num_sgs = skb_shinfo(skb)->nr_frags + 1; in build_dma_sg()
1339 urb->sg = kmalloc_array(num_sgs + 1, sizeof(struct scatterlist), in build_dma_sg()
1341 if (!urb->sg) in build_dma_sg()
1342 return -ENOMEM; in build_dma_sg()
1344 urb->num_sgs = num_sgs; in build_dma_sg()
1345 sg_init_table(urb->sg, urb->num_sgs + 1); in build_dma_sg()
1347 sg_set_buf(&urb->sg[s++], skb->data, skb_headlen(skb)); in build_dma_sg()
1350 for (i = 0; i < skb_shinfo(skb)->nr_frags; i++) { in build_dma_sg()
1351 skb_frag_t *f = &skb_shinfo(skb)->frags[i]; in build_dma_sg()
1354 sg_set_page(&urb->sg[i + s], skb_frag_page(f), skb_frag_size(f), in build_dma_sg()
1357 urb->transfer_buffer_length = total_len; in build_dma_sg()
1369 const struct driver_info *info = dev->driver_info; in usbnet_start_xmit()
1376 // some devices want funky USB-level framing, for in usbnet_start_xmit()
1378 if (info->tx_fixup) { in usbnet_start_xmit()
1379 skb = info->tx_fixup (dev, skb, GFP_ATOMIC); in usbnet_start_xmit()
1382 if (info->flags & FLAG_MULTI_PACKET) in usbnet_start_xmit()
1384 netif_dbg(dev, tx_err, dev->net, "can't tx_fixup skb\n"); in usbnet_start_xmit()
1390 netif_dbg(dev, tx_err, dev->net, "no urb\n"); in usbnet_start_xmit()
1394 entry = (struct skb_data *) skb->cb; in usbnet_start_xmit()
1395 entry->urb = urb; in usbnet_start_xmit()
1396 entry->dev = dev; in usbnet_start_xmit()
1398 usb_fill_bulk_urb (urb, dev->udev, dev->out, in usbnet_start_xmit()
1399 skb->data, skb->len, tx_complete, skb); in usbnet_start_xmit()
1400 if (dev->can_dma_sg) { in usbnet_start_xmit()
1404 length = urb->transfer_buffer_length; in usbnet_start_xmit()
1407 * NOTE: strictly conforming cdc-ether devices should expect in usbnet_start_xmit()
1408 * the ZLP here, but ignore the one-byte packet. in usbnet_start_xmit()
1413 if (length % dev->maxpacket == 0) { in usbnet_start_xmit()
1414 if (!(info->flags & FLAG_SEND_ZLP)) { in usbnet_start_xmit()
1415 if (!(info->flags & FLAG_MULTI_PACKET)) { in usbnet_start_xmit()
1417 if (skb_tailroom(skb) && !urb->num_sgs) { in usbnet_start_xmit()
1418 skb->data[skb->len] = 0; in usbnet_start_xmit()
1420 } else if (urb->num_sgs) in usbnet_start_xmit()
1421 sg_set_buf(&urb->sg[urb->num_sgs++], in usbnet_start_xmit()
1422 dev->padding_pkt, 1); in usbnet_start_xmit()
1425 urb->transfer_flags |= URB_ZERO_PACKET; in usbnet_start_xmit()
1427 urb->transfer_buffer_length = length; in usbnet_start_xmit()
1429 if (info->flags & FLAG_MULTI_PACKET) { in usbnet_start_xmit()
1434 entry->length += length; in usbnet_start_xmit()
1435 if (WARN_ON_ONCE(entry->length <= 0)) in usbnet_start_xmit()
1436 entry->length = length; in usbnet_start_xmit()
1441 spin_lock_irqsave(&dev->txq.lock, flags); in usbnet_start_xmit()
1442 retval = usb_autopm_get_interface_async(dev->intf); in usbnet_start_xmit()
1444 spin_unlock_irqrestore(&dev->txq.lock, flags); in usbnet_start_xmit()
1448 usb_autopm_put_interface_async(dev->intf); in usbnet_start_xmit()
1449 spin_unlock_irqrestore(&dev->txq.lock, flags); in usbnet_start_xmit()
1455 if (test_bit(EVENT_DEV_ASLEEP, &dev->flags)) { in usbnet_start_xmit()
1457 usb_anchor_urb(urb, &dev->deferred); in usbnet_start_xmit()
1461 spin_unlock_irqrestore(&dev->txq.lock, flags); in usbnet_start_xmit()
1462 netdev_dbg(dev->net, "Delaying transmission for resumption\n"); in usbnet_start_xmit()
1468 case -EPIPE: in usbnet_start_xmit()
1471 usb_autopm_put_interface_async(dev->intf); in usbnet_start_xmit()
1474 usb_autopm_put_interface_async(dev->intf); in usbnet_start_xmit()
1475 netif_dbg(dev, tx_err, dev->net, in usbnet_start_xmit()
1480 __usbnet_queue_skb(&dev->txq, skb, tx_start); in usbnet_start_xmit()
1481 if (dev->txq.qlen >= TX_QLEN (dev)) in usbnet_start_xmit()
1484 spin_unlock_irqrestore (&dev->txq.lock, flags); in usbnet_start_xmit()
1487 netif_dbg(dev, tx_err, dev->net, "drop, code %d\n", retval); in usbnet_start_xmit()
1489 dev->net->stats.tx_dropped++; in usbnet_start_xmit()
1494 kfree(urb->sg); in usbnet_start_xmit()
1498 netif_dbg(dev, tx_queued, dev->net, in usbnet_start_xmit()
1499 "> tx, len %u, type 0x%x\n", length, skb->protocol); in usbnet_start_xmit()
1514 for (i = 0; i < 10 && dev->rxq.qlen < RX_QLEN(dev); i++) { in rx_alloc_submit()
1521 ret = -ENOMEM; in rx_alloc_submit()
1531 struct skb_data *entry = (struct skb_data *)skb->cb; in usb_free_skb()
1533 usb_free_urb(entry->urb); in usb_free_skb()
1537 /*-------------------------------------------------------------------------*/
1547 while ((skb = skb_dequeue (&dev->done))) { in usbnet_bh()
1548 entry = (struct skb_data *) skb->cb; in usbnet_bh()
1549 switch (entry->state) { in usbnet_bh()
1555 kfree(entry->urb->sg); in usbnet_bh()
1561 netdev_dbg(dev->net, "bogus skb state %d\n", entry->state); in usbnet_bh()
1566 clear_bit(EVENT_RX_KILL, &dev->flags); in usbnet_bh()
1571 if (waitqueue_active(&dev->wait)) { in usbnet_bh()
1572 if (dev->txq.qlen + dev->rxq.qlen + dev->done.qlen == 0) in usbnet_bh()
1573 wake_up_all(&dev->wait); in usbnet_bh()
1576 } else if (netif_running (dev->net) && in usbnet_bh()
1577 netif_device_present (dev->net) && in usbnet_bh()
1578 netif_carrier_ok(dev->net) && in usbnet_bh()
1580 !timer_pending(&dev->delay) && in usbnet_bh()
1581 !test_bit(EVENT_RX_PAUSED, &dev->flags) && in usbnet_bh()
1582 !test_bit(EVENT_RX_HALT, &dev->flags)) { in usbnet_bh()
1583 int temp = dev->rxq.qlen; in usbnet_bh()
1586 if (rx_alloc_submit(dev, GFP_ATOMIC) == -ENOLINK) in usbnet_bh()
1588 if (temp != dev->rxq.qlen) in usbnet_bh()
1589 netif_dbg(dev, link, dev->net, in usbnet_bh()
1590 "rxqlen %d --> %d\n", in usbnet_bh()
1591 temp, dev->rxq.qlen); in usbnet_bh()
1592 if (dev->rxq.qlen < RX_QLEN(dev)) in usbnet_bh()
1593 tasklet_schedule (&dev->bh); in usbnet_bh()
1595 if (dev->txq.qlen < TX_QLEN (dev)) in usbnet_bh()
1596 netif_wake_queue (dev->net); in usbnet_bh()
1604 usbnet_bh(&dev->delay); in usbnet_bh_tasklet()
1608 /*-------------------------------------------------------------------------
1612 *-------------------------------------------------------------------------*/
1631 netif_info(dev, probe, dev->net, "unregister '%s' usb-%s-%s, %s\n", in usbnet_disconnect()
1632 intf->dev.driver->name, in usbnet_disconnect()
1633 xdev->bus->bus_name, xdev->devpath, in usbnet_disconnect()
1634 dev->driver_info->description); in usbnet_disconnect()
1636 net = dev->net; in usbnet_disconnect()
1639 while ((urb = usb_get_from_anchor(&dev->deferred))) { in usbnet_disconnect()
1640 dev_kfree_skb(urb->context); in usbnet_disconnect()
1641 kfree(urb->sg); in usbnet_disconnect()
1645 if (dev->driver_info->unbind) in usbnet_disconnect()
1646 dev->driver_info->unbind(dev, intf); in usbnet_disconnect()
1648 usb_kill_urb(dev->interrupt); in usbnet_disconnect()
1649 usb_free_urb(dev->interrupt); in usbnet_disconnect()
1650 kfree(dev->padding_pkt); in usbnet_disconnect()
1667 /*-------------------------------------------------------------------------*/
1689 struct usb_driver *driver = to_usb_driver(udev->dev.driver); in usbnet_probe()
1695 if (!driver->supports_autosuspend) { in usbnet_probe()
1696 driver->supports_autosuspend = 1; in usbnet_probe()
1697 pm_runtime_enable(&udev->dev); in usbnet_probe()
1700 name = udev->dev.driver->name; in usbnet_probe()
1701 info = (const struct driver_info *) prod->driver_info; in usbnet_probe()
1703 dev_dbg (&udev->dev, "blacklisted by %s\n", name); in usbnet_probe()
1704 return -ENODEV; in usbnet_probe()
1707 interface = udev->cur_altsetting; in usbnet_probe()
1709 status = -ENOMEM; in usbnet_probe()
1717 SET_NETDEV_DEV(net, &udev->dev); in usbnet_probe()
1720 dev->udev = xdev; in usbnet_probe()
1721 dev->intf = udev; in usbnet_probe()
1722 dev->driver_info = info; in usbnet_probe()
1723 dev->driver_name = name; in usbnet_probe()
1724 dev->rx_speed = SPEED_UNSET; in usbnet_probe()
1725 dev->tx_speed = SPEED_UNSET; in usbnet_probe()
1727 dev->msg_enable = netif_msg_init (msg_level, NETIF_MSG_DRV in usbnet_probe()
1729 init_waitqueue_head(&dev->wait); in usbnet_probe()
1730 skb_queue_head_init (&dev->rxq); in usbnet_probe()
1731 skb_queue_head_init (&dev->txq); in usbnet_probe()
1732 skb_queue_head_init (&dev->done); in usbnet_probe()
1733 skb_queue_head_init(&dev->rxq_pause); in usbnet_probe()
1734 tasklet_setup(&dev->bh, usbnet_bh_tasklet); in usbnet_probe()
1735 INIT_WORK (&dev->kevent, usbnet_deferred_kevent); in usbnet_probe()
1736 init_usb_anchor(&dev->deferred); in usbnet_probe()
1737 timer_setup(&dev->delay, usbnet_bh, 0); in usbnet_probe()
1738 mutex_init (&dev->phy_mutex); in usbnet_probe()
1739 mutex_init(&dev->interrupt_mutex); in usbnet_probe()
1740 dev->interrupt_count = 0; in usbnet_probe()
1742 dev->net = net; in usbnet_probe()
1743 strscpy(net->name, "usb%d", sizeof(net->name)); in usbnet_probe()
1748 dev->hard_mtu = net->mtu + net->hard_header_len; in usbnet_probe()
1749 net->min_mtu = 0; in usbnet_probe()
1750 net->max_mtu = ETH_MAX_MTU; in usbnet_probe()
1751 net->pcpu_stat_type = NETDEV_PCPU_STAT_TSTATS; in usbnet_probe()
1753 net->netdev_ops = &usbnet_netdev_ops; in usbnet_probe()
1754 net->watchdog_timeo = TX_TIMEOUT_JIFFIES; in usbnet_probe()
1755 net->ethtool_ops = &usbnet_ethtool_ops; in usbnet_probe()
1756 net->pcpu_stat_type = NETDEV_PCPU_STAT_TSTATS; in usbnet_probe()
1758 // allow device-specific bind/init procedures in usbnet_probe()
1759 // NOTE net->name still not usable ... in usbnet_probe()
1760 if (info->bind) { in usbnet_probe()
1761 status = info->bind (dev, udev); in usbnet_probe()
1765 // heuristic: "usb%d" for links we know are two-host, in usbnet_probe()
1768 if ((dev->driver_info->flags & FLAG_ETHER) != 0 && in usbnet_probe()
1769 ((dev->driver_info->flags & FLAG_POINTTOPOINT) == 0 || in usbnet_probe()
1771 !is_zero_ether_addr(net->dev_addr))) in usbnet_probe()
1772 strscpy(net->name, "eth%d", sizeof(net->name)); in usbnet_probe()
1774 if ((dev->driver_info->flags & FLAG_WLAN) != 0) in usbnet_probe()
1775 strscpy(net->name, "wlan%d", sizeof(net->name)); in usbnet_probe()
1777 if ((dev->driver_info->flags & FLAG_WWAN) != 0) in usbnet_probe()
1778 strscpy(net->name, "wwan%d", sizeof(net->name)); in usbnet_probe()
1781 if ((dev->driver_info->flags & FLAG_NOARP) != 0) in usbnet_probe()
1782 net->flags |= IFF_NOARP; in usbnet_probe()
1785 if (net->mtu > (dev->hard_mtu - net->hard_header_len)) in usbnet_probe()
1786 net->mtu = dev->hard_mtu - net->hard_header_len; in usbnet_probe()
1787 } else if (!info->in || !info->out) in usbnet_probe()
1791 info->in + USB_DIR_IN, info->out + USB_DIR_OUT, 0 in usbnet_probe()
1794 dev->in = usb_rcvbulkpipe (xdev, info->in); in usbnet_probe()
1795 dev->out = usb_sndbulkpipe (xdev, info->out); in usbnet_probe()
1796 if (!(info->flags & FLAG_NO_SETINT)) in usbnet_probe()
1798 interface->desc.bInterfaceNumber, in usbnet_probe()
1799 interface->desc.bAlternateSetting); in usbnet_probe()
1804 status = -EINVAL; in usbnet_probe()
1806 if (status >= 0 && dev->status) in usbnet_probe()
1811 if (!dev->rx_urb_size) in usbnet_probe()
1812 dev->rx_urb_size = dev->hard_mtu; in usbnet_probe()
1813 dev->maxpacket = usb_maxpacket(dev->udev, dev->out); in usbnet_probe()
1814 if (dev->maxpacket == 0) { in usbnet_probe()
1816 status = -ENODEV; in usbnet_probe()
1821 if (!is_valid_ether_addr(net->dev_addr)) in usbnet_probe()
1824 if ((dev->driver_info->flags & FLAG_WLAN) != 0) in usbnet_probe()
1826 if ((dev->driver_info->flags & FLAG_WWAN) != 0) in usbnet_probe()
1832 if (dev->can_dma_sg && !(info->flags & FLAG_SEND_ZLP) && in usbnet_probe()
1833 !(info->flags & FLAG_MULTI_PACKET)) { in usbnet_probe()
1834 dev->padding_pkt = kzalloc(1, GFP_KERNEL); in usbnet_probe()
1835 if (!dev->padding_pkt) { in usbnet_probe()
1836 status = -ENOMEM; in usbnet_probe()
1844 netif_info(dev, probe, dev->net, in usbnet_probe()
1845 "register '%s' at usb-%s-%s, %s, %pM\n", in usbnet_probe()
1846 udev->dev.driver->name, in usbnet_probe()
1847 xdev->bus->bus_name, xdev->devpath, in usbnet_probe()
1848 dev->driver_info->description, in usbnet_probe()
1849 net->dev_addr); in usbnet_probe()
1856 if (dev->driver_info->flags & FLAG_LINK_INTR) in usbnet_probe()
1862 kfree(dev->padding_pkt); in usbnet_probe()
1864 usb_free_urb(dev->interrupt); in usbnet_probe()
1866 if (info->unbind) in usbnet_probe()
1867 info->unbind (dev, udev); in usbnet_probe()
1875 cancel_work_sync(&dev->kevent); in usbnet_probe()
1876 del_timer_sync(&dev->delay); in usbnet_probe()
1883 /*-------------------------------------------------------------------------*/
1894 if (!dev->suspend_count++) { in usbnet_suspend()
1895 spin_lock_irq(&dev->txq.lock); in usbnet_suspend()
1896 /* don't autosuspend while transmitting */ in usbnet_suspend()
1897 if (dev->txq.qlen && PMSG_IS_AUTO(message)) { in usbnet_suspend()
1898 dev->suspend_count--; in usbnet_suspend()
1899 spin_unlock_irq(&dev->txq.lock); in usbnet_suspend()
1900 return -EBUSY; in usbnet_suspend()
1902 set_bit(EVENT_DEV_ASLEEP, &dev->flags); in usbnet_suspend()
1903 spin_unlock_irq(&dev->txq.lock); in usbnet_suspend()
1909 netif_device_detach (dev->net); in usbnet_suspend()
1917 netif_device_attach (dev->net); in usbnet_suspend()
1930 if (!--dev->suspend_count) { in usbnet_resume()
1934 spin_lock_irq(&dev->txq.lock); in usbnet_resume()
1935 while ((res = usb_get_from_anchor(&dev->deferred))) { in usbnet_resume()
1937 skb = (struct sk_buff *)res->context; in usbnet_resume()
1941 kfree(res->sg); in usbnet_resume()
1943 usb_autopm_put_interface_async(dev->intf); in usbnet_resume()
1945 netif_trans_update(dev->net); in usbnet_resume()
1946 __skb_queue_tail(&dev->txq, skb); in usbnet_resume()
1951 clear_bit(EVENT_DEV_ASLEEP, &dev->flags); in usbnet_resume()
1952 spin_unlock_irq(&dev->txq.lock); in usbnet_resume()
1954 if (test_bit(EVENT_DEV_OPEN, &dev->flags)) { in usbnet_resume()
1958 if (netif_device_present(dev->net) && in usbnet_resume()
1959 !timer_pending(&dev->delay) && in usbnet_resume()
1960 !test_bit(EVENT_RX_HALT, &dev->flags)) in usbnet_resume()
1963 if (!(dev->txq.qlen >= TX_QLEN(dev))) in usbnet_resume()
1964 netif_tx_wake_all_queues(dev->net); in usbnet_resume()
1965 tasklet_schedule (&dev->bh); in usbnet_resume()
1969 if (test_and_clear_bit(EVENT_DEVICE_REPORT_IDLE, &dev->flags)) in usbnet_resume()
1983 if (!test_and_set_bit(EVENT_DEVICE_REPORT_IDLE, &dev->flags)) { in usbnet_device_suggests_idle()
1984 dev->intf->needs_remote_wakeup = 1; in usbnet_device_suggests_idle()
1985 usb_autopm_put_interface_async(dev->intf); in usbnet_device_suggests_idle()
1995 dev->intf->needs_remote_wakeup = on; in usbnet_manage_power()
2004 netif_carrier_on(dev->net); in usbnet_link_change()
2006 netif_carrier_off(dev->net); in usbnet_link_change()
2015 /*-------------------------------------------------------------------------*/
2020 int err = -ENOMEM; in __usbnet_read_cmd()
2022 netdev_dbg(dev->net, "usbnet_read_cmd cmd=0x%02x reqtype=%02x" in __usbnet_read_cmd()
2032 err = usb_control_msg(dev->udev, usb_rcvctrlpipe(dev->udev, 0), in __usbnet_read_cmd()
2039 netdev_dbg(dev->net, in __usbnet_read_cmd()
2052 int err = -ENOMEM; in __usbnet_write_cmd()
2054 netdev_dbg(dev->net, "usbnet_write_cmd cmd=0x%02x reqtype=%02x" in __usbnet_write_cmd()
2065 err = -EINVAL; in __usbnet_write_cmd()
2070 err = usb_control_msg(dev->udev, usb_sndctrlpipe(dev->udev, 0), in __usbnet_write_cmd()
2088 if (usb_autopm_get_interface(dev->intf) < 0) in usbnet_read_cmd()
2089 return -ENODEV; in usbnet_read_cmd()
2092 usb_autopm_put_interface(dev->intf); in usbnet_read_cmd()
2106 if (usb_autopm_get_interface(dev->intf) < 0) in usbnet_write_cmd()
2107 return -ENODEV; in usbnet_write_cmd()
2110 usb_autopm_put_interface(dev->intf); in usbnet_write_cmd()
2142 struct usb_ctrlrequest *req = (struct usb_ctrlrequest *)urb->context; in usbnet_async_cmd_cb()
2143 int status = urb->status; in usbnet_async_cmd_cb()
2146 dev_dbg(&urb->dev->dev, "%s failed with %d", in usbnet_async_cmd_cb()
2162 int err = -ENOMEM; in usbnet_write_cmd_async()
2165 netdev_dbg(dev->net, "usbnet_write_cmd cmd=0x%02x reqtype=%02x" in usbnet_write_cmd_async()
2176 netdev_err(dev->net, "Error allocating buffer" in usbnet_write_cmd_async()
2186 req->bRequestType = reqtype; in usbnet_write_cmd_async()
2187 req->bRequest = cmd; in usbnet_write_cmd_async()
2188 req->wValue = cpu_to_le16(value); in usbnet_write_cmd_async()
2189 req->wIndex = cpu_to_le16(index); in usbnet_write_cmd_async()
2190 req->wLength = cpu_to_le16(size); in usbnet_write_cmd_async()
2192 usb_fill_control_urb(urb, dev->udev, in usbnet_write_cmd_async()
2193 usb_sndctrlpipe(dev->udev, 0), in usbnet_write_cmd_async()
2196 urb->transfer_flags |= URB_FREE_BUFFER; in usbnet_write_cmd_async()
2200 netdev_err(dev->net, "Error submitting the control" in usbnet_write_cmd_async()
2215 urb->transfer_flags = 0; in usbnet_write_cmd_async()
2223 /*-------------------------------------------------------------------------*/