Lines Matching refs:dev

110 static int ipheth_rx_submit(struct ipheth_device *dev, gfp_t mem_flags);
165 static void ipheth_kill_urbs(struct ipheth_device *dev) in ipheth_kill_urbs() argument
167 usb_kill_urb(dev->tx_urb); in ipheth_kill_urbs()
168 usb_kill_urb(dev->rx_urb); in ipheth_kill_urbs()
171 static int ipheth_consume_skb(char *buf, int len, struct ipheth_device *dev) in ipheth_consume_skb() argument
177 dev->net->stats.rx_dropped++; in ipheth_consume_skb()
182 skb->dev = dev->net; in ipheth_consume_skb()
183 skb->protocol = eth_type_trans(skb, dev->net); in ipheth_consume_skb()
185 dev->net->stats.rx_packets++; in ipheth_consume_skb()
186 dev->net->stats.rx_bytes += len; in ipheth_consume_skb()
194 struct ipheth_device *dev; in ipheth_rcvbulk_callback_legacy() local
198 dev = urb->context; in ipheth_rcvbulk_callback_legacy()
201 dev->net->stats.rx_length_errors++; in ipheth_rcvbulk_callback_legacy()
207 return ipheth_consume_skb(buf, len, dev); in ipheth_rcvbulk_callback_legacy()
215 struct ipheth_device *dev; in ipheth_rcvbulk_callback_ncm() local
220 dev = urb->context; in ipheth_rcvbulk_callback_ncm()
223 dev->net->stats.rx_length_errors++; in ipheth_rcvbulk_callback_ncm()
230 dev->net->stats.rx_errors++; in ipheth_rcvbulk_callback_ncm()
238 dev->net->stats.rx_errors++; in ipheth_rcvbulk_callback_ncm()
248 dev->net->stats.rx_length_errors++; in ipheth_rcvbulk_callback_ncm()
255 retval = ipheth_consume_skb(buf, len, dev); in ipheth_rcvbulk_callback_ncm()
267 struct ipheth_device *dev; in ipheth_rcvbulk_callback() local
270 dev = urb->context; in ipheth_rcvbulk_callback()
271 if (dev == NULL) in ipheth_rcvbulk_callback()
284 dev_err(&dev->intf->dev, "%s: urb status: %d\n", in ipheth_rcvbulk_callback()
290 dev->net->stats.rx_length_errors++; in ipheth_rcvbulk_callback()
305 retval = dev->rcvbulk_callback(urb); in ipheth_rcvbulk_callback()
307 dev_err(&dev->intf->dev, "%s: callback retval: %d\n", in ipheth_rcvbulk_callback()
313 dev->confirmed_pairing = true; in ipheth_rcvbulk_callback()
314 ipheth_rx_submit(dev, GFP_ATOMIC); in ipheth_rcvbulk_callback()
319 struct ipheth_device *dev; in ipheth_sndbulk_callback() local
322 dev = urb->context; in ipheth_sndbulk_callback()
323 if (dev == NULL) in ipheth_sndbulk_callback()
330 dev_err(&dev->intf->dev, "%s: urb status: %d\n", in ipheth_sndbulk_callback()
334 netif_wake_queue(dev->net); in ipheth_sndbulk_callback()
337 schedule_delayed_work(&dev->carrier_work, 0); in ipheth_sndbulk_callback()
340 static int ipheth_carrier_set(struct ipheth_device *dev) in ipheth_carrier_set() argument
345 if (!dev->confirmed_pairing) in ipheth_carrier_set()
348 udev = dev->udev; in ipheth_carrier_set()
355 dev->ctrl_buf, IPHETH_CTRL_BUF_SIZE, in ipheth_carrier_set()
358 dev_err(&dev->intf->dev, "%s: usb_control_msg: %d\n", in ipheth_carrier_set()
363 if (dev->ctrl_buf[0] == IPHETH_CARRIER_ON) { in ipheth_carrier_set()
364 netif_carrier_on(dev->net); in ipheth_carrier_set()
365 if (dev->tx_urb->status != -EINPROGRESS) in ipheth_carrier_set()
366 netif_wake_queue(dev->net); in ipheth_carrier_set()
368 netif_carrier_off(dev->net); in ipheth_carrier_set()
369 netif_stop_queue(dev->net); in ipheth_carrier_set()
376 struct ipheth_device *dev = container_of(work, struct ipheth_device, in ipheth_carrier_check_work() local
379 ipheth_carrier_set(dev); in ipheth_carrier_check_work()
380 schedule_delayed_work(&dev->carrier_work, IPHETH_CARRIER_CHECK_TIMEOUT); in ipheth_carrier_check_work()
383 static int ipheth_get_macaddr(struct ipheth_device *dev) in ipheth_get_macaddr() argument
385 struct usb_device *udev = dev->udev; in ipheth_get_macaddr()
386 struct net_device *net = dev->net; in ipheth_get_macaddr()
395 dev->ctrl_buf, in ipheth_get_macaddr()
399 dev_err(&dev->intf->dev, "%s: usb_control_msg: %d\n", in ipheth_get_macaddr()
402 dev_err(&dev->intf->dev, in ipheth_get_macaddr()
407 eth_hw_addr_set(net, dev->ctrl_buf); in ipheth_get_macaddr()
414 static int ipheth_enable_ncm(struct ipheth_device *dev) in ipheth_enable_ncm() argument
416 struct usb_device *udev = dev->udev; in ipheth_enable_ncm()
429 dev_info(&dev->intf->dev, "%s: usb_control_msg: %d\n", in ipheth_enable_ncm()
435 static int ipheth_rx_submit(struct ipheth_device *dev, gfp_t mem_flags) in ipheth_rx_submit() argument
437 struct usb_device *udev = dev->udev; in ipheth_rx_submit()
440 usb_fill_bulk_urb(dev->rx_urb, udev, in ipheth_rx_submit()
441 usb_rcvbulkpipe(udev, dev->bulk_in), in ipheth_rx_submit()
442 dev->rx_buf, dev->rx_buf_len, in ipheth_rx_submit()
444 dev); in ipheth_rx_submit()
445 dev->rx_urb->transfer_flags |= URB_NO_TRANSFER_DMA_MAP; in ipheth_rx_submit()
447 retval = usb_submit_urb(dev->rx_urb, mem_flags); in ipheth_rx_submit()
449 dev_err(&dev->intf->dev, "%s: usb_submit_urb: %d\n", in ipheth_rx_submit()
456 struct ipheth_device *dev = netdev_priv(net); in ipheth_open() local
457 struct usb_device *udev = dev->udev; in ipheth_open()
462 retval = ipheth_carrier_set(dev); in ipheth_open()
466 retval = ipheth_rx_submit(dev, GFP_KERNEL); in ipheth_open()
470 schedule_delayed_work(&dev->carrier_work, IPHETH_CARRIER_CHECK_TIMEOUT); in ipheth_open()
476 struct ipheth_device *dev = netdev_priv(net); in ipheth_close() local
479 cancel_delayed_work_sync(&dev->carrier_work); in ipheth_close()
485 struct ipheth_device *dev = netdev_priv(net); in ipheth_tx() local
486 struct usb_device *udev = dev->udev; in ipheth_tx()
492 dev->net->stats.tx_dropped++; in ipheth_tx()
497 memcpy(dev->tx_buf, skb->data, skb->len); in ipheth_tx()
499 usb_fill_bulk_urb(dev->tx_urb, udev, in ipheth_tx()
500 usb_sndbulkpipe(udev, dev->bulk_out), in ipheth_tx()
501 dev->tx_buf, skb->len, in ipheth_tx()
503 dev); in ipheth_tx()
504 dev->tx_urb->transfer_flags |= URB_NO_TRANSFER_DMA_MAP; in ipheth_tx()
507 retval = usb_submit_urb(dev->tx_urb, GFP_ATOMIC); in ipheth_tx()
509 dev_err(&dev->intf->dev, "%s: usb_submit_urb: %d\n", in ipheth_tx()
511 dev->net->stats.tx_errors++; in ipheth_tx()
515 dev->net->stats.tx_packets++; in ipheth_tx()
516 dev->net->stats.tx_bytes += skb->len; in ipheth_tx()
525 struct ipheth_device *dev = netdev_priv(net); in ipheth_tx_timeout() local
527 dev_err(&dev->intf->dev, "%s: TX timeout\n", __func__); in ipheth_tx_timeout()
528 dev->net->stats.tx_errors++; in ipheth_tx_timeout()
529 usb_unlink_urb(dev->tx_urb); in ipheth_tx_timeout()
534 struct ipheth_device *dev = netdev_priv(net); in ipheth_ethtool_op_get_link() local
535 return netif_carrier_ok(dev->net); in ipheth_ethtool_op_get_link()
555 struct ipheth_device *dev; in ipheth_probe() local
568 dev = netdev_priv(netdev); in ipheth_probe()
569 dev->udev = udev; in ipheth_probe()
570 dev->net = netdev; in ipheth_probe()
571 dev->intf = intf; in ipheth_probe()
572 dev->confirmed_pairing = false; in ipheth_probe()
573 dev->rx_buf_len = IPHETH_RX_BUF_SIZE_LEGACY; in ipheth_probe()
574 dev->rcvbulk_callback = ipheth_rcvbulk_callback_legacy; in ipheth_probe()
579 dev_err(&intf->dev, "Unable to find alternate settings interface\n"); in ipheth_probe()
586 dev->bulk_in = endp->bEndpointAddress; in ipheth_probe()
588 dev->bulk_out = endp->bEndpointAddress; in ipheth_probe()
590 if (!(dev->bulk_in && dev->bulk_out)) { in ipheth_probe()
592 dev_err(&intf->dev, "Unable to find endpoints\n"); in ipheth_probe()
596 dev->ctrl_buf = kmalloc(IPHETH_CTRL_BUF_SIZE, GFP_KERNEL); in ipheth_probe()
597 if (dev->ctrl_buf == NULL) { in ipheth_probe()
602 retval = ipheth_get_macaddr(dev); in ipheth_probe()
606 retval = ipheth_enable_ncm(dev); in ipheth_probe()
608 dev->rx_buf_len = IPHETH_RX_BUF_SIZE_NCM; in ipheth_probe()
609 dev->rcvbulk_callback = ipheth_rcvbulk_callback_ncm; in ipheth_probe()
612 INIT_DELAYED_WORK(&dev->carrier_work, ipheth_carrier_check_work); in ipheth_probe()
614 retval = ipheth_alloc_urbs(dev); in ipheth_probe()
616 dev_err(&intf->dev, "error allocating urbs: %d\n", retval); in ipheth_probe()
620 usb_set_intfdata(intf, dev); in ipheth_probe()
622 SET_NETDEV_DEV(netdev, &intf->dev); in ipheth_probe()
627 dev_err(&intf->dev, "error registering netdev: %d\n", retval); in ipheth_probe()
634 dev_info(&intf->dev, "Apple iPhone USB Ethernet device attached\n"); in ipheth_probe()
638 ipheth_free_urbs(dev); in ipheth_probe()
641 kfree(dev->ctrl_buf); in ipheth_probe()
650 struct ipheth_device *dev; in ipheth_disconnect() local
652 dev = usb_get_intfdata(intf); in ipheth_disconnect()
653 if (dev != NULL) { in ipheth_disconnect()
654 unregister_netdev(dev->net); in ipheth_disconnect()
655 ipheth_kill_urbs(dev); in ipheth_disconnect()
656 ipheth_free_urbs(dev); in ipheth_disconnect()
657 kfree(dev->ctrl_buf); in ipheth_disconnect()
658 free_netdev(dev->net); in ipheth_disconnect()
661 dev_info(&intf->dev, "Apple iPhone USB Ethernet now disconnected\n"); in ipheth_disconnect()