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