Searched refs:kaweth (Results 1 - 3 of 3) sorted by relevance

/linux-4.4.14/drivers/net/usb/
H A Dkaweth.c3 * kaweth.c - driver for KL5KUSB101 based USB->Ethernet
106 MODULE_FIRMWARE("kaweth/new_code.bin");
107 MODULE_FIRMWARE("kaweth/new_code_fix.bin");
108 MODULE_FIRMWARE("kaweth/trigger_code.bin");
109 MODULE_FIRMWARE("kaweth/trigger_code_fix.bin");
111 static const char driver_name[] = "kaweth";
255 static int kaweth_control(struct kaweth_device *kaweth, kaweth_control() argument
268 netdev_dbg(kaweth->net, "kaweth_control()\n"); kaweth_control()
271 netdev_dbg(kaweth->net, "in_interrupt()\n"); kaweth_control()
285 retval = kaweth_internal_control_msg(kaweth->dev, kaweth_control()
299 static int kaweth_read_configuration(struct kaweth_device *kaweth) kaweth_read_configuration() argument
303 netdev_dbg(kaweth->net, "Reading kaweth configuration\n"); kaweth_read_configuration()
305 retval = kaweth_control(kaweth, kaweth_read_configuration()
306 usb_rcvctrlpipe(kaweth->dev, 0), kaweth_read_configuration()
311 (void *)&kaweth->configuration, kaweth_read_configuration()
312 sizeof(kaweth->configuration), kaweth_read_configuration()
321 static int kaweth_set_urb_size(struct kaweth_device *kaweth, __u16 urb_size) kaweth_set_urb_size() argument
325 netdev_dbg(kaweth->net, "Setting URB size to %d\n", (unsigned)urb_size); kaweth_set_urb_size()
327 retval = kaweth_control(kaweth, kaweth_set_urb_size()
328 usb_sndctrlpipe(kaweth->dev, 0), kaweth_set_urb_size()
333 (void *)&kaweth->scratch, kaweth_set_urb_size()
343 static int kaweth_set_sofs_wait(struct kaweth_device *kaweth, __u16 sofs_wait) kaweth_set_sofs_wait() argument
347 netdev_dbg(kaweth->net, "Set SOFS wait to %d\n", (unsigned)sofs_wait); kaweth_set_sofs_wait()
349 retval = kaweth_control(kaweth, kaweth_set_sofs_wait()
350 usb_sndctrlpipe(kaweth->dev, 0), kaweth_set_sofs_wait()
355 (void *)&kaweth->scratch, kaweth_set_sofs_wait()
365 static int kaweth_set_receive_filter(struct kaweth_device *kaweth, kaweth_set_receive_filter() argument
370 netdev_dbg(kaweth->net, "Set receive filter to %d\n", kaweth_set_receive_filter()
373 retval = kaweth_control(kaweth, kaweth_set_receive_filter()
374 usb_sndctrlpipe(kaweth->dev, 0), kaweth_set_receive_filter()
379 (void *)&kaweth->scratch, kaweth_set_receive_filter()
389 static int kaweth_download_firmware(struct kaweth_device *kaweth, kaweth_download_firmware() argument
398 ret = request_firmware(&fw, fwname, &kaweth->dev->dev); kaweth_download_firmware()
400 dev_err(&kaweth->intf->dev, "Firmware request failed\n"); kaweth_download_firmware()
405 dev_err(&kaweth->intf->dev, "Firmware too big: %zu\n", kaweth_download_firmware()
411 memcpy(kaweth->firmware_buf, fw->data, fw->size); kaweth_download_firmware()
415 kaweth->firmware_buf[2] = (data_len & 0xFF) - 7; kaweth_download_firmware()
416 kaweth->firmware_buf[3] = data_len >> 8; kaweth_download_firmware()
417 kaweth->firmware_buf[4] = type; kaweth_download_firmware()
418 kaweth->firmware_buf[5] = interrupt; kaweth_download_firmware()
420 netdev_dbg(kaweth->net, "High: %i, Low:%i\n", kaweth->firmware_buf[3], kaweth_download_firmware()
421 kaweth->firmware_buf[2]); kaweth_download_firmware()
423 netdev_dbg(kaweth->net, kaweth_download_firmware()
424 "Downloading firmware at %p to kaweth device at %p\n", kaweth_download_firmware()
425 kaweth->firmware_buf, kaweth); kaweth_download_firmware()
426 netdev_dbg(kaweth->net, "Firmware length: %d\n", data_len); kaweth_download_firmware()
428 return kaweth_control(kaweth, kaweth_download_firmware()
429 usb_sndctrlpipe(kaweth->dev, 0), kaweth_download_firmware()
434 (void *)kaweth->firmware_buf, kaweth_download_firmware()
442 static int kaweth_trigger_firmware(struct kaweth_device *kaweth, kaweth_trigger_firmware() argument
445 kaweth->firmware_buf[0] = 0xB6; kaweth_trigger_firmware()
446 kaweth->firmware_buf[1] = 0xC3; kaweth_trigger_firmware()
447 kaweth->firmware_buf[2] = 0x01; kaweth_trigger_firmware()
448 kaweth->firmware_buf[3] = 0x00; kaweth_trigger_firmware()
449 kaweth->firmware_buf[4] = 0x06; kaweth_trigger_firmware()
450 kaweth->firmware_buf[5] = interrupt; kaweth_trigger_firmware()
451 kaweth->firmware_buf[6] = 0x00; kaweth_trigger_firmware()
452 kaweth->firmware_buf[7] = 0x00; kaweth_trigger_firmware()
454 netdev_dbg(kaweth->net, "Triggering firmware\n"); kaweth_trigger_firmware()
456 return kaweth_control(kaweth, kaweth_trigger_firmware()
457 usb_sndctrlpipe(kaweth->dev, 0), kaweth_trigger_firmware()
462 (void *)kaweth->firmware_buf, kaweth_trigger_firmware()
470 static int kaweth_reset(struct kaweth_device *kaweth) kaweth_reset() argument
474 netdev_dbg(kaweth->net, "kaweth_reset(%p)\n", kaweth); kaweth_reset()
475 result = usb_reset_configuration(kaweth->dev); kaweth_reset()
478 netdev_dbg(kaweth->net, "kaweth_reset() returns %d.\n", result); kaweth_reset()
490 static void kaweth_resubmit_int_urb(struct kaweth_device *kaweth, gfp_t mf) kaweth_resubmit_int_urb() argument
494 status = usb_submit_urb (kaweth->irq_urb, mf); kaweth_resubmit_int_urb()
496 kaweth->suspend_lowmem_ctrl = 1; kaweth_resubmit_int_urb()
497 schedule_delayed_work(&kaweth->lowmem_work, HZ/4); kaweth_resubmit_int_urb()
499 kaweth->suspend_lowmem_ctrl = 0; kaweth_resubmit_int_urb()
503 dev_err(&kaweth->intf->dev, kaweth_resubmit_int_urb()
505 kaweth->dev->bus->bus_name, kaweth_resubmit_int_urb()
506 kaweth->dev->devpath, status); kaweth_resubmit_int_urb()
511 struct kaweth_device *kaweth = u->context; int_callback() local
528 if (kaweth->linkstate != (act_state = ( kaweth->intbuffer[STATE_OFFSET] | STATE_MASK) >> STATE_SHIFT)) { int_callback()
530 netif_carrier_on(kaweth->net); int_callback()
532 netif_carrier_off(kaweth->net); int_callback()
534 kaweth->linkstate = act_state; int_callback()
537 kaweth_resubmit_int_urb(kaweth, GFP_ATOMIC); int_callback()
542 struct kaweth_device *kaweth = kaweth_resubmit_tl() local
545 if (IS_BLOCKED(kaweth->status)) kaweth_resubmit_tl()
548 if (kaweth->suspend_lowmem_rx) kaweth_resubmit_tl()
549 kaweth_resubmit_rx_urb(kaweth, GFP_NOIO); kaweth_resubmit_tl()
551 if (kaweth->suspend_lowmem_ctrl) kaweth_resubmit_tl()
552 kaweth_resubmit_int_urb(kaweth, GFP_NOIO); kaweth_resubmit_tl()
559 static int kaweth_resubmit_rx_urb(struct kaweth_device *kaweth, kaweth_resubmit_rx_urb() argument
564 usb_fill_bulk_urb(kaweth->rx_urb, kaweth_resubmit_rx_urb()
565 kaweth->dev, kaweth_resubmit_rx_urb()
566 usb_rcvbulkpipe(kaweth->dev, 1), kaweth_resubmit_rx_urb()
567 kaweth->rx_buf, kaweth_resubmit_rx_urb()
570 kaweth); kaweth_resubmit_rx_urb()
571 kaweth->rx_urb->transfer_flags |= URB_NO_TRANSFER_DMA_MAP; kaweth_resubmit_rx_urb()
572 kaweth->rx_urb->transfer_dma = kaweth->rxbufferhandle; kaweth_resubmit_rx_urb()
574 if((result = usb_submit_urb(kaweth->rx_urb, mem_flags))) { kaweth_resubmit_rx_urb()
576 kaweth->suspend_lowmem_rx = 1; kaweth_resubmit_rx_urb()
577 schedule_delayed_work(&kaweth->lowmem_work, HZ/4); kaweth_resubmit_rx_urb()
579 dev_err(&kaweth->intf->dev, "resubmitting rx_urb %d failed\n", kaweth_resubmit_rx_urb()
582 kaweth->suspend_lowmem_rx = 0; kaweth_resubmit_rx_urb()
588 static void kaweth_async_set_rx_mode(struct kaweth_device *kaweth);
596 struct kaweth_device *kaweth = urb->context; kaweth_usb_receive() local
597 struct net_device *net = kaweth->net; kaweth_usb_receive()
603 __u16 pkt_len = le16_to_cpup((__le16 *)kaweth->rx_buf); kaweth_usb_receive()
608 kaweth->stats.rx_errors++; kaweth_usb_receive()
609 kaweth->end = 1; kaweth_usb_receive()
610 wake_up(&kaweth->term_wait); kaweth_usb_receive()
616 kaweth->end = 1; kaweth_usb_receive()
617 wake_up(&kaweth->term_wait); kaweth_usb_receive()
623 kaweth->stats.rx_errors++; kaweth_usb_receive()
628 kaweth->stats.rx_errors++; kaweth_usb_receive()
631 spin_lock(&kaweth->device_lock); kaweth_usb_receive()
632 if (IS_BLOCKED(kaweth->status)) { kaweth_usb_receive()
633 spin_unlock(&kaweth->device_lock); kaweth_usb_receive()
636 spin_unlock(&kaweth->device_lock); kaweth_usb_receive()
639 dev_err(&kaweth->intf->dev, kaweth_usb_receive()
642 kaweth_resubmit_rx_urb(kaweth, GFP_ATOMIC); kaweth_usb_receive()
646 if(kaweth->net && (count > 2)) { kaweth_usb_receive()
648 dev_err(&kaweth->intf->dev, kaweth_usb_receive()
651 dev_err(&kaweth->intf->dev, "Packet len & 2047: %x\n", kaweth_usb_receive()
653 dev_err(&kaweth->intf->dev, "Count 2: %x\n", count2); kaweth_usb_receive()
654 kaweth_resubmit_rx_urb(kaweth, GFP_ATOMIC); kaweth_usb_receive()
659 kaweth_resubmit_rx_urb(kaweth, GFP_ATOMIC); kaweth_usb_receive()
665 skb_copy_to_linear_data(skb, kaweth->rx_buf + 2, pkt_len); kaweth_usb_receive()
673 kaweth->stats.rx_packets++; kaweth_usb_receive()
674 kaweth->stats.rx_bytes += pkt_len; kaweth_usb_receive()
677 kaweth_resubmit_rx_urb(kaweth, GFP_ATOMIC); kaweth_usb_receive()
685 struct kaweth_device *kaweth = netdev_priv(net); kaweth_open() local
688 netdev_dbg(kaweth->net, "Opening network device.\n"); kaweth_open()
690 res = usb_autopm_get_interface(kaweth->intf); kaweth_open()
692 dev_err(&kaweth->intf->dev, "Interface cannot be resumed.\n"); kaweth_open()
695 res = kaweth_resubmit_rx_urb(kaweth, GFP_KERNEL); kaweth_open()
700 kaweth->irq_urb, kaweth_open()
701 kaweth->dev, kaweth_open()
702 usb_rcvintpipe(kaweth->dev, 3), kaweth_open()
703 kaweth->intbuffer, kaweth_open()
706 kaweth, kaweth_open()
708 kaweth->irq_urb->transfer_dma = kaweth->intbufferhandle; kaweth_open()
709 kaweth->irq_urb->transfer_flags |= URB_NO_TRANSFER_DMA_MAP; kaweth_open()
711 res = usb_submit_urb(kaweth->irq_urb, GFP_KERNEL); kaweth_open()
713 usb_kill_urb(kaweth->rx_urb); kaweth_open()
716 kaweth->opened = 1; kaweth_open()
720 kaweth_async_set_rx_mode(kaweth); kaweth_open()
724 usb_autopm_put_interface(kaweth->intf); kaweth_open()
731 static void kaweth_kill_urbs(struct kaweth_device *kaweth) kaweth_kill_urbs() argument
733 usb_kill_urb(kaweth->irq_urb); kaweth_kill_urbs()
734 usb_kill_urb(kaweth->rx_urb); kaweth_kill_urbs()
735 usb_kill_urb(kaweth->tx_urb); kaweth_kill_urbs()
737 cancel_delayed_work_sync(&kaweth->lowmem_work); kaweth_kill_urbs()
741 usb_kill_urb(kaweth->irq_urb); kaweth_kill_urbs()
742 usb_kill_urb(kaweth->rx_urb); kaweth_kill_urbs()
750 struct kaweth_device *kaweth = netdev_priv(net); kaweth_close() local
753 kaweth->opened = 0; kaweth_close()
755 kaweth->status |= KAWETH_STATUS_CLOSING; kaweth_close()
757 kaweth_kill_urbs(kaweth); kaweth_close()
759 kaweth->status &= ~KAWETH_STATUS_CLOSING; kaweth_close()
761 usb_autopm_put_interface(kaweth->intf); kaweth_close()
768 struct kaweth_device *kaweth = netdev_priv(dev); kaweth_get_link() local
770 return kaweth->linkstate; kaweth_get_link()
782 struct kaweth_device *kaweth = urb->context; kaweth_usb_transmit_complete() local
783 struct sk_buff *skb = kaweth->tx_skb; kaweth_usb_transmit_complete()
789 kaweth->net->name, status); kaweth_usb_transmit_complete()
791 netif_wake_queue(kaweth->net); kaweth_usb_transmit_complete()
801 struct kaweth_device *kaweth = netdev_priv(net); kaweth_start_xmit() local
806 spin_lock_irq(&kaweth->device_lock); kaweth_start_xmit()
808 kaweth_async_set_rx_mode(kaweth); kaweth_start_xmit()
810 if (IS_BLOCKED(kaweth->status)) { kaweth_start_xmit()
822 kaweth->stats.tx_errors++; kaweth_start_xmit()
824 spin_unlock_irq(&kaweth->device_lock); kaweth_start_xmit()
831 kaweth->tx_skb = skb; kaweth_start_xmit()
833 usb_fill_bulk_urb(kaweth->tx_urb, kaweth_start_xmit()
834 kaweth->dev, kaweth_start_xmit()
835 usb_sndbulkpipe(kaweth->dev, 2), kaweth_start_xmit()
839 kaweth); kaweth_start_xmit()
840 kaweth->end = 0; kaweth_start_xmit()
842 if((res = usb_submit_urb(kaweth->tx_urb, GFP_ATOMIC))) kaweth_start_xmit()
844 dev_warn(&net->dev, "kaweth failed tx_urb %d\n", res); kaweth_start_xmit()
846 kaweth->stats.tx_errors++; kaweth_start_xmit()
853 kaweth->stats.tx_packets++; kaweth_start_xmit()
854 kaweth->stats.tx_bytes += skb->len; kaweth_start_xmit()
857 spin_unlock_irq(&kaweth->device_lock); kaweth_start_xmit()
867 struct kaweth_device *kaweth = netdev_priv(net); kaweth_set_rx_mode() local
884 kaweth->packet_filter_bitmap = packet_filter_bitmap; kaweth_set_rx_mode()
891 static void kaweth_async_set_rx_mode(struct kaweth_device *kaweth) kaweth_async_set_rx_mode() argument
894 __u16 packet_filter_bitmap = kaweth->packet_filter_bitmap; kaweth_async_set_rx_mode()
896 kaweth->packet_filter_bitmap = 0; kaweth_async_set_rx_mode()
903 result = kaweth_control(kaweth, kaweth_async_set_rx_mode()
904 usb_sndctrlpipe(kaweth->dev, 0), kaweth_async_set_rx_mode()
909 (void *)&kaweth->scratch, kaweth_async_set_rx_mode()
914 dev_err(&kaweth->intf->dev, "Failed to set Rx mode: %d\n", kaweth_async_set_rx_mode()
918 netdev_dbg(kaweth->net, "Set Rx mode to %d\n", kaweth_async_set_rx_mode()
928 struct kaweth_device *kaweth = netdev_priv(dev); kaweth_netdev_stats() local
929 return &kaweth->stats; kaweth_netdev_stats()
937 struct kaweth_device *kaweth = netdev_priv(net); kaweth_tx_timeout() local
940 kaweth->stats.tx_errors++; kaweth_tx_timeout()
943 usb_unlink_urb(kaweth->tx_urb); kaweth_tx_timeout()
951 struct kaweth_device *kaweth = usb_get_intfdata(intf); kaweth_suspend() local
955 spin_lock_irqsave(&kaweth->device_lock, flags); kaweth_suspend()
956 kaweth->status |= KAWETH_STATUS_SUSPENDING; kaweth_suspend()
957 spin_unlock_irqrestore(&kaweth->device_lock, flags); kaweth_suspend()
959 kaweth_kill_urbs(kaweth); kaweth_suspend()
968 struct kaweth_device *kaweth = usb_get_intfdata(intf); kaweth_resume() local
972 spin_lock_irqsave(&kaweth->device_lock, flags); kaweth_resume()
973 kaweth->status &= ~KAWETH_STATUS_SUSPENDING; kaweth_resume()
974 spin_unlock_irqrestore(&kaweth->device_lock, flags); kaweth_resume()
976 if (!kaweth->opened) kaweth_resume()
978 kaweth_resubmit_rx_urb(kaweth, GFP_NOIO); kaweth_resume()
979 kaweth_resubmit_int_urb(kaweth, GFP_NOIO); kaweth_resume()
1008 struct kaweth_device *kaweth; kaweth_probe() local
1025 netdev = alloc_etherdev(sizeof(*kaweth)); kaweth_probe()
1029 kaweth = netdev_priv(netdev); kaweth_probe()
1030 kaweth->dev = udev; kaweth_probe()
1031 kaweth->net = netdev; kaweth_probe()
1033 spin_lock_init(&kaweth->device_lock); kaweth_probe()
1034 init_waitqueue_head(&kaweth->term_wait); kaweth_probe()
1038 kaweth_reset(kaweth); kaweth_probe()
1050 kaweth->firmware_buf = (__u8 *)__get_free_page(GFP_KERNEL); kaweth_probe()
1051 if ((result = kaweth_download_firmware(kaweth, kaweth_probe()
1052 "kaweth/new_code.bin", kaweth_probe()
1060 if ((result = kaweth_download_firmware(kaweth, kaweth_probe()
1061 "kaweth/new_code_fix.bin", kaweth_probe()
1069 if ((result = kaweth_download_firmware(kaweth, kaweth_probe()
1070 "kaweth/trigger_code.bin", kaweth_probe()
1079 if ((result = kaweth_download_firmware(kaweth, kaweth_probe()
1080 "kaweth/trigger_code_fix.bin", kaweth_probe()
1088 if ((result = kaweth_trigger_firmware(kaweth, 126)) < 0) { kaweth_probe()
1096 free_page((unsigned long)kaweth->firmware_buf); kaweth_probe()
1101 result = kaweth_read_configuration(kaweth); kaweth_probe()
1108 dev_info(dev, "Statistics collection: %x\n", kaweth->configuration.statistics_mask); kaweth_probe()
1109 dev_info(dev, "Multicast filter limit: %x\n", kaweth->configuration.max_multicast_filters & ((1 << 15) - 1)); kaweth_probe()
1110 dev_info(dev, "MTU: %d\n", le16_to_cpu(kaweth->configuration.segment_size)); kaweth_probe()
1111 dev_info(dev, "Read MAC address %pM\n", kaweth->configuration.hw_addr); kaweth_probe()
1113 if(!memcmp(&kaweth->configuration.hw_addr, kaweth_probe()
1120 if(kaweth_set_urb_size(kaweth, KAWETH_BUF_SIZE) < 0) { kaweth_probe()
1125 if(kaweth_set_sofs_wait(kaweth, KAWETH_SOFS_TO_WAIT) < 0) { kaweth_probe()
1130 result = kaweth_set_receive_filter(kaweth, kaweth_probe()
1142 kaweth->intf = intf; kaweth_probe()
1144 kaweth->tx_urb = usb_alloc_urb(0, GFP_KERNEL); kaweth_probe()
1145 if (!kaweth->tx_urb) kaweth_probe()
1147 kaweth->rx_urb = usb_alloc_urb(0, GFP_KERNEL); kaweth_probe()
1148 if (!kaweth->rx_urb) kaweth_probe()
1150 kaweth->irq_urb = usb_alloc_urb(0, GFP_KERNEL); kaweth_probe()
1151 if (!kaweth->irq_urb) kaweth_probe()
1154 kaweth->intbuffer = usb_alloc_coherent( kaweth->dev, kaweth_probe()
1157 &kaweth->intbufferhandle); kaweth_probe()
1158 if (!kaweth->intbuffer) kaweth_probe()
1160 kaweth->rx_buf = usb_alloc_coherent( kaweth->dev, kaweth_probe()
1163 &kaweth->rxbufferhandle); kaweth_probe()
1164 if (!kaweth->rx_buf) kaweth_probe()
1168 memcpy(netdev->dev_addr, &kaweth->configuration.hw_addr, kaweth_probe()
1169 sizeof(kaweth->configuration.hw_addr)); kaweth_probe()
1173 netdev->mtu = le16_to_cpu(kaweth->configuration.segment_size); kaweth_probe()
1176 /* kaweth is zeroed as part of alloc_netdev */ kaweth_probe()
1177 INIT_DELAYED_WORK(&kaweth->lowmem_work, kaweth_resubmit_tl); kaweth_probe()
1178 usb_set_intfdata(intf, kaweth); kaweth_probe()
1186 dev_info(dev, "kaweth interface created at %s\n", kaweth_probe()
1187 kaweth->net->name); kaweth_probe()
1195 usb_free_coherent(kaweth->dev, KAWETH_BUF_SIZE, (void *)kaweth->rx_buf, kaweth->rxbufferhandle); kaweth_probe()
1197 usb_free_coherent(kaweth->dev, INTBUFFERSIZE, (void *)kaweth->intbuffer, kaweth->intbufferhandle); kaweth_probe()
1199 usb_free_urb(kaweth->irq_urb); kaweth_probe()
1201 usb_free_urb(kaweth->rx_urb); kaweth_probe()
1203 usb_free_urb(kaweth->tx_urb); kaweth_probe()
1215 struct kaweth_device *kaweth = usb_get_intfdata(intf); kaweth_disconnect() local
1221 if (!kaweth) { kaweth_disconnect()
1225 netdev = kaweth->net; kaweth_disconnect()
1227 netdev_dbg(kaweth->net, "Unregistering net device\n"); kaweth_disconnect()
1230 usb_free_urb(kaweth->rx_urb); kaweth_disconnect()
1231 usb_free_urb(kaweth->tx_urb); kaweth_disconnect()
1232 usb_free_urb(kaweth->irq_urb); kaweth_disconnect()
1234 usb_free_coherent(kaweth->dev, KAWETH_BUF_SIZE, (void *)kaweth->rx_buf, kaweth->rxbufferhandle); kaweth_disconnect()
1235 usb_free_coherent(kaweth->dev, INTBUFFERSIZE, (void *)kaweth->intbuffer, kaweth->intbufferhandle); kaweth_disconnect()
H A DMakefile6 obj-$(CONFIG_USB_KAWETH) += kaweth.o
/linux-4.4.14/firmware/
H A DMakefile104 fw-shipped-$(CONFIG_USB_KAWETH) += kaweth/new_code.bin kaweth/trigger_code.bin \
105 kaweth/new_code_fix.bin \
106 kaweth/trigger_code_fix.bin

Completed in 119 milliseconds