Lines Matching refs:kaweth

253 static int kaweth_control(struct kaweth_device *kaweth,  in kaweth_control()  argument
267 netdev_dbg(kaweth->net, "in_interrupt()\n"); in kaweth_control()
281 retval = kaweth_internal_control_msg(kaweth->dev, in kaweth_control()
295 static int kaweth_read_configuration(struct kaweth_device *kaweth) in kaweth_read_configuration() argument
299 retval = kaweth_control(kaweth, in kaweth_read_configuration()
300 usb_rcvctrlpipe(kaweth->dev, 0), in kaweth_read_configuration()
305 (void *)&kaweth->configuration, in kaweth_read_configuration()
306 sizeof(kaweth->configuration), in kaweth_read_configuration()
315 static int kaweth_set_urb_size(struct kaweth_device *kaweth, __u16 urb_size) in kaweth_set_urb_size() argument
319 netdev_dbg(kaweth->net, "Setting URB size to %d\n", (unsigned)urb_size); in kaweth_set_urb_size()
321 retval = kaweth_control(kaweth, in kaweth_set_urb_size()
322 usb_sndctrlpipe(kaweth->dev, 0), in kaweth_set_urb_size()
327 (void *)&kaweth->scratch, in kaweth_set_urb_size()
337 static int kaweth_set_sofs_wait(struct kaweth_device *kaweth, __u16 sofs_wait) in kaweth_set_sofs_wait() argument
341 netdev_dbg(kaweth->net, "Set SOFS wait to %d\n", (unsigned)sofs_wait); in kaweth_set_sofs_wait()
343 retval = kaweth_control(kaweth, in kaweth_set_sofs_wait()
344 usb_sndctrlpipe(kaweth->dev, 0), in kaweth_set_sofs_wait()
349 (void *)&kaweth->scratch, in kaweth_set_sofs_wait()
359 static int kaweth_set_receive_filter(struct kaweth_device *kaweth, in kaweth_set_receive_filter() argument
364 netdev_dbg(kaweth->net, "Set receive filter to %d\n", in kaweth_set_receive_filter()
367 retval = kaweth_control(kaweth, in kaweth_set_receive_filter()
368 usb_sndctrlpipe(kaweth->dev, 0), in kaweth_set_receive_filter()
373 (void *)&kaweth->scratch, in kaweth_set_receive_filter()
383 static int kaweth_download_firmware(struct kaweth_device *kaweth, in kaweth_download_firmware() argument
392 ret = request_firmware(&fw, fwname, &kaweth->dev->dev); in kaweth_download_firmware()
394 dev_err(&kaweth->intf->dev, "Firmware request failed\n"); in kaweth_download_firmware()
399 dev_err(&kaweth->intf->dev, "Firmware too big: %zu\n", in kaweth_download_firmware()
405 memcpy(kaweth->firmware_buf, fw->data, fw->size); in kaweth_download_firmware()
409 kaweth->firmware_buf[2] = (data_len & 0xFF) - 7; in kaweth_download_firmware()
410 kaweth->firmware_buf[3] = data_len >> 8; in kaweth_download_firmware()
411 kaweth->firmware_buf[4] = type; in kaweth_download_firmware()
412 kaweth->firmware_buf[5] = interrupt; in kaweth_download_firmware()
414 netdev_dbg(kaweth->net, "High: %i, Low:%i\n", kaweth->firmware_buf[3], in kaweth_download_firmware()
415 kaweth->firmware_buf[2]); in kaweth_download_firmware()
417 netdev_dbg(kaweth->net, in kaweth_download_firmware()
419 kaweth->firmware_buf, kaweth); in kaweth_download_firmware()
420 netdev_dbg(kaweth->net, "Firmware length: %d\n", data_len); in kaweth_download_firmware()
422 return kaweth_control(kaweth, in kaweth_download_firmware()
423 usb_sndctrlpipe(kaweth->dev, 0), in kaweth_download_firmware()
428 (void *)kaweth->firmware_buf, in kaweth_download_firmware()
436 static int kaweth_trigger_firmware(struct kaweth_device *kaweth, in kaweth_trigger_firmware() argument
439 kaweth->firmware_buf[0] = 0xB6; in kaweth_trigger_firmware()
440 kaweth->firmware_buf[1] = 0xC3; in kaweth_trigger_firmware()
441 kaweth->firmware_buf[2] = 0x01; in kaweth_trigger_firmware()
442 kaweth->firmware_buf[3] = 0x00; in kaweth_trigger_firmware()
443 kaweth->firmware_buf[4] = 0x06; in kaweth_trigger_firmware()
444 kaweth->firmware_buf[5] = interrupt; in kaweth_trigger_firmware()
445 kaweth->firmware_buf[6] = 0x00; in kaweth_trigger_firmware()
446 kaweth->firmware_buf[7] = 0x00; in kaweth_trigger_firmware()
448 return kaweth_control(kaweth, in kaweth_trigger_firmware()
449 usb_sndctrlpipe(kaweth->dev, 0), in kaweth_trigger_firmware()
454 (void *)kaweth->firmware_buf, in kaweth_trigger_firmware()
462 static int kaweth_reset(struct kaweth_device *kaweth) in kaweth_reset() argument
466 result = usb_reset_configuration(kaweth->dev); in kaweth_reset()
469 netdev_dbg(kaweth->net, "kaweth_reset() returns %d.\n", result); in kaweth_reset()
481 static void kaweth_resubmit_int_urb(struct kaweth_device *kaweth, gfp_t mf) in kaweth_resubmit_int_urb() argument
485 status = usb_submit_urb (kaweth->irq_urb, mf); in kaweth_resubmit_int_urb()
487 kaweth->suspend_lowmem_ctrl = 1; in kaweth_resubmit_int_urb()
488 schedule_delayed_work(&kaweth->lowmem_work, HZ/4); in kaweth_resubmit_int_urb()
490 kaweth->suspend_lowmem_ctrl = 0; in kaweth_resubmit_int_urb()
494 dev_err(&kaweth->intf->dev, in kaweth_resubmit_int_urb()
496 kaweth->dev->bus->bus_name, in kaweth_resubmit_int_urb()
497 kaweth->dev->devpath, status); in kaweth_resubmit_int_urb()
502 struct kaweth_device *kaweth = u->context; in int_callback() local
519 …if (kaweth->linkstate != (act_state = ( kaweth->intbuffer[STATE_OFFSET] | STATE_MASK) >> STATE_SHI… in int_callback()
521 netif_carrier_on(kaweth->net); in int_callback()
523 netif_carrier_off(kaweth->net); in int_callback()
525 kaweth->linkstate = act_state; in int_callback()
528 kaweth_resubmit_int_urb(kaweth, GFP_ATOMIC); in int_callback()
533 struct kaweth_device *kaweth = in kaweth_resubmit_tl() local
536 if (IS_BLOCKED(kaweth->status)) in kaweth_resubmit_tl()
539 if (kaweth->suspend_lowmem_rx) in kaweth_resubmit_tl()
540 kaweth_resubmit_rx_urb(kaweth, GFP_NOIO); in kaweth_resubmit_tl()
542 if (kaweth->suspend_lowmem_ctrl) in kaweth_resubmit_tl()
543 kaweth_resubmit_int_urb(kaweth, GFP_NOIO); in kaweth_resubmit_tl()
550 static int kaweth_resubmit_rx_urb(struct kaweth_device *kaweth, in kaweth_resubmit_rx_urb() argument
555 usb_fill_bulk_urb(kaweth->rx_urb, in kaweth_resubmit_rx_urb()
556 kaweth->dev, in kaweth_resubmit_rx_urb()
557 usb_rcvbulkpipe(kaweth->dev, 1), in kaweth_resubmit_rx_urb()
558 kaweth->rx_buf, in kaweth_resubmit_rx_urb()
561 kaweth); in kaweth_resubmit_rx_urb()
562 kaweth->rx_urb->transfer_flags |= URB_NO_TRANSFER_DMA_MAP; in kaweth_resubmit_rx_urb()
563 kaweth->rx_urb->transfer_dma = kaweth->rxbufferhandle; in kaweth_resubmit_rx_urb()
565 if((result = usb_submit_urb(kaweth->rx_urb, mem_flags))) { in kaweth_resubmit_rx_urb()
567 kaweth->suspend_lowmem_rx = 1; in kaweth_resubmit_rx_urb()
568 schedule_delayed_work(&kaweth->lowmem_work, HZ/4); in kaweth_resubmit_rx_urb()
570 dev_err(&kaweth->intf->dev, "resubmitting rx_urb %d failed\n", in kaweth_resubmit_rx_urb()
573 kaweth->suspend_lowmem_rx = 0; in kaweth_resubmit_rx_urb()
579 static void kaweth_async_set_rx_mode(struct kaweth_device *kaweth);
587 struct kaweth_device *kaweth = urb->context; in kaweth_usb_receive() local
588 struct net_device *net = kaweth->net; in kaweth_usb_receive()
594 __u16 pkt_len = le16_to_cpup((__le16 *)kaweth->rx_buf); in kaweth_usb_receive()
600 kaweth->end = 1; in kaweth_usb_receive()
601 wake_up(&kaweth->term_wait); in kaweth_usb_receive()
607 kaweth->end = 1; in kaweth_usb_receive()
608 wake_up(&kaweth->term_wait); in kaweth_usb_receive()
622 spin_lock_irqsave(&kaweth->device_lock, flags); in kaweth_usb_receive()
623 if (IS_BLOCKED(kaweth->status)) { in kaweth_usb_receive()
624 spin_unlock_irqrestore(&kaweth->device_lock, flags); in kaweth_usb_receive()
627 spin_unlock_irqrestore(&kaweth->device_lock, flags); in kaweth_usb_receive()
630 dev_err(&kaweth->intf->dev, in kaweth_usb_receive()
633 kaweth_resubmit_rx_urb(kaweth, GFP_ATOMIC); in kaweth_usb_receive()
637 if(kaweth->net && (count > 2)) { in kaweth_usb_receive()
639 dev_err(&kaweth->intf->dev, in kaweth_usb_receive()
642 dev_err(&kaweth->intf->dev, "Packet len & 2047: %x\n", in kaweth_usb_receive()
644 dev_err(&kaweth->intf->dev, "Count 2: %x\n", count2); in kaweth_usb_receive()
645 kaweth_resubmit_rx_urb(kaweth, GFP_ATOMIC); in kaweth_usb_receive()
650 kaweth_resubmit_rx_urb(kaweth, GFP_ATOMIC); in kaweth_usb_receive()
656 skb_copy_to_linear_data(skb, kaweth->rx_buf + 2, pkt_len); in kaweth_usb_receive()
668 kaweth_resubmit_rx_urb(kaweth, GFP_ATOMIC); in kaweth_usb_receive()
676 struct kaweth_device *kaweth = netdev_priv(net); in kaweth_open() local
679 res = usb_autopm_get_interface(kaweth->intf); in kaweth_open()
681 dev_err(&kaweth->intf->dev, "Interface cannot be resumed.\n"); in kaweth_open()
684 res = kaweth_resubmit_rx_urb(kaweth, GFP_KERNEL); in kaweth_open()
689 kaweth->irq_urb, in kaweth_open()
690 kaweth->dev, in kaweth_open()
691 usb_rcvintpipe(kaweth->dev, 3), in kaweth_open()
692 kaweth->intbuffer, in kaweth_open()
695 kaweth, in kaweth_open()
697 kaweth->irq_urb->transfer_dma = kaweth->intbufferhandle; in kaweth_open()
698 kaweth->irq_urb->transfer_flags |= URB_NO_TRANSFER_DMA_MAP; in kaweth_open()
700 res = usb_submit_urb(kaweth->irq_urb, GFP_KERNEL); in kaweth_open()
702 usb_kill_urb(kaweth->rx_urb); in kaweth_open()
705 kaweth->opened = 1; in kaweth_open()
709 kaweth_async_set_rx_mode(kaweth); in kaweth_open()
713 usb_autopm_put_interface(kaweth->intf); in kaweth_open()
720 static void kaweth_kill_urbs(struct kaweth_device *kaweth) in kaweth_kill_urbs() argument
722 usb_kill_urb(kaweth->irq_urb); in kaweth_kill_urbs()
723 usb_kill_urb(kaweth->rx_urb); in kaweth_kill_urbs()
724 usb_kill_urb(kaweth->tx_urb); in kaweth_kill_urbs()
726 cancel_delayed_work_sync(&kaweth->lowmem_work); in kaweth_kill_urbs()
730 usb_kill_urb(kaweth->irq_urb); in kaweth_kill_urbs()
731 usb_kill_urb(kaweth->rx_urb); in kaweth_kill_urbs()
739 struct kaweth_device *kaweth = netdev_priv(net); in kaweth_close() local
742 kaweth->opened = 0; in kaweth_close()
744 kaweth->status |= KAWETH_STATUS_CLOSING; in kaweth_close()
746 kaweth_kill_urbs(kaweth); in kaweth_close()
748 kaweth->status &= ~KAWETH_STATUS_CLOSING; in kaweth_close()
750 usb_autopm_put_interface(kaweth->intf); in kaweth_close()
757 struct kaweth_device *kaweth = netdev_priv(dev); in kaweth_get_link() local
759 return kaweth->linkstate; in kaweth_get_link()
771 struct kaweth_device *kaweth = urb->context; in kaweth_usb_transmit_complete() local
772 struct sk_buff *skb = kaweth->tx_skb; in kaweth_usb_transmit_complete()
778 kaweth->net->name, status); in kaweth_usb_transmit_complete()
780 netif_wake_queue(kaweth->net); in kaweth_usb_transmit_complete()
790 struct kaweth_device *kaweth = netdev_priv(net); in kaweth_start_xmit() local
795 spin_lock_irq(&kaweth->device_lock); in kaweth_start_xmit()
797 kaweth_async_set_rx_mode(kaweth); in kaweth_start_xmit()
799 if (IS_BLOCKED(kaweth->status)) { in kaweth_start_xmit()
807 spin_unlock_irq(&kaweth->device_lock); in kaweth_start_xmit()
814 kaweth->tx_skb = skb; in kaweth_start_xmit()
816 usb_fill_bulk_urb(kaweth->tx_urb, in kaweth_start_xmit()
817 kaweth->dev, in kaweth_start_xmit()
818 usb_sndbulkpipe(kaweth->dev, 2), in kaweth_start_xmit()
822 kaweth); in kaweth_start_xmit()
823 kaweth->end = 0; in kaweth_start_xmit()
825 if((res = usb_submit_urb(kaweth->tx_urb, GFP_ATOMIC))) in kaweth_start_xmit()
840 spin_unlock_irq(&kaweth->device_lock); in kaweth_start_xmit()
850 struct kaweth_device *kaweth = netdev_priv(net); in kaweth_set_rx_mode() local
867 kaweth->packet_filter_bitmap = packet_filter_bitmap; in kaweth_set_rx_mode()
874 static void kaweth_async_set_rx_mode(struct kaweth_device *kaweth) in kaweth_async_set_rx_mode() argument
877 __u16 packet_filter_bitmap = kaweth->packet_filter_bitmap; in kaweth_async_set_rx_mode()
879 kaweth->packet_filter_bitmap = 0; in kaweth_async_set_rx_mode()
886 result = kaweth_control(kaweth, in kaweth_async_set_rx_mode()
887 usb_sndctrlpipe(kaweth->dev, 0), in kaweth_async_set_rx_mode()
892 (void *)&kaweth->scratch, in kaweth_async_set_rx_mode()
897 dev_err(&kaweth->intf->dev, "Failed to set Rx mode: %d\n", in kaweth_async_set_rx_mode()
901 netdev_dbg(kaweth->net, "Set Rx mode to %d\n", in kaweth_async_set_rx_mode()
911 struct kaweth_device *kaweth = netdev_priv(net); in kaweth_tx_timeout() local
917 usb_unlink_urb(kaweth->tx_urb); in kaweth_tx_timeout()
925 struct kaweth_device *kaweth = usb_get_intfdata(intf); in kaweth_suspend() local
928 spin_lock_irqsave(&kaweth->device_lock, flags); in kaweth_suspend()
929 kaweth->status |= KAWETH_STATUS_SUSPENDING; in kaweth_suspend()
930 spin_unlock_irqrestore(&kaweth->device_lock, flags); in kaweth_suspend()
932 kaweth_kill_urbs(kaweth); in kaweth_suspend()
941 struct kaweth_device *kaweth = usb_get_intfdata(intf); in kaweth_resume() local
944 spin_lock_irqsave(&kaweth->device_lock, flags); in kaweth_resume()
945 kaweth->status &= ~KAWETH_STATUS_SUSPENDING; in kaweth_resume()
946 spin_unlock_irqrestore(&kaweth->device_lock, flags); in kaweth_resume()
948 if (!kaweth->opened) in kaweth_resume()
950 kaweth_resubmit_rx_urb(kaweth, GFP_NOIO); in kaweth_resume()
951 kaweth_resubmit_int_urb(kaweth, GFP_NOIO); in kaweth_resume()
978 struct kaweth_device *kaweth; in kaweth_probe() local
996 netdev = alloc_etherdev(sizeof(*kaweth)); in kaweth_probe()
1000 kaweth = netdev_priv(netdev); in kaweth_probe()
1001 kaweth->dev = udev; in kaweth_probe()
1002 kaweth->net = netdev; in kaweth_probe()
1003 kaweth->intf = intf; in kaweth_probe()
1005 spin_lock_init(&kaweth->device_lock); in kaweth_probe()
1006 init_waitqueue_head(&kaweth->term_wait); in kaweth_probe()
1010 kaweth_reset(kaweth); in kaweth_probe()
1022 kaweth->firmware_buf = (__u8 *)__get_free_page(GFP_KERNEL); in kaweth_probe()
1023 if (!kaweth->firmware_buf) { in kaweth_probe()
1027 if ((result = kaweth_download_firmware(kaweth, in kaweth_probe()
1036 if ((result = kaweth_download_firmware(kaweth, in kaweth_probe()
1045 if ((result = kaweth_download_firmware(kaweth, in kaweth_probe()
1055 if ((result = kaweth_download_firmware(kaweth, in kaweth_probe()
1064 if ((result = kaweth_trigger_firmware(kaweth, 126)) < 0) { in kaweth_probe()
1072 free_page((unsigned long)kaweth->firmware_buf); in kaweth_probe()
1077 result = kaweth_read_configuration(kaweth); in kaweth_probe()
1084 dev_info(dev, "Statistics collection: %x\n", kaweth->configuration.statistics_mask); in kaweth_probe()
1085 …dev_info(dev, "Multicast filter limit: %x\n", kaweth->configuration.max_multicast_filters & ((1 <<… in kaweth_probe()
1086 dev_info(dev, "MTU: %d\n", le16_to_cpu(kaweth->configuration.segment_size)); in kaweth_probe()
1087 dev_info(dev, "Read MAC address %pM\n", kaweth->configuration.hw_addr); in kaweth_probe()
1089 if(!memcmp(&kaweth->configuration.hw_addr, in kaweth_probe()
1096 if(kaweth_set_urb_size(kaweth, KAWETH_BUF_SIZE) < 0) { in kaweth_probe()
1101 if(kaweth_set_sofs_wait(kaweth, KAWETH_SOFS_TO_WAIT) < 0) { in kaweth_probe()
1106 result = kaweth_set_receive_filter(kaweth, in kaweth_probe()
1118 kaweth->tx_urb = usb_alloc_urb(0, GFP_KERNEL); in kaweth_probe()
1119 if (!kaweth->tx_urb) in kaweth_probe()
1121 kaweth->rx_urb = usb_alloc_urb(0, GFP_KERNEL); in kaweth_probe()
1122 if (!kaweth->rx_urb) in kaweth_probe()
1124 kaweth->irq_urb = usb_alloc_urb(0, GFP_KERNEL); in kaweth_probe()
1125 if (!kaweth->irq_urb) in kaweth_probe()
1128 kaweth->intbuffer = usb_alloc_coherent( kaweth->dev, in kaweth_probe()
1131 &kaweth->intbufferhandle); in kaweth_probe()
1132 if (!kaweth->intbuffer) in kaweth_probe()
1134 kaweth->rx_buf = usb_alloc_coherent( kaweth->dev, in kaweth_probe()
1137 &kaweth->rxbufferhandle); in kaweth_probe()
1138 if (!kaweth->rx_buf) in kaweth_probe()
1142 memcpy(netdev->dev_addr, &kaweth->configuration.hw_addr, in kaweth_probe()
1143 sizeof(kaweth->configuration.hw_addr)); in kaweth_probe()
1147 netdev->mtu = le16_to_cpu(kaweth->configuration.segment_size); in kaweth_probe()
1151 INIT_DELAYED_WORK(&kaweth->lowmem_work, kaweth_resubmit_tl); in kaweth_probe()
1152 usb_set_intfdata(intf, kaweth); in kaweth_probe()
1161 kaweth->net->name); in kaweth_probe()
1167 usb_free_coherent(kaweth->dev, KAWETH_BUF_SIZE, (void *)kaweth->rx_buf, kaweth->rxbufferhandle); in kaweth_probe()
1169 usb_free_coherent(kaweth->dev, INTBUFFERSIZE, (void *)kaweth->intbuffer, kaweth->intbufferhandle); in kaweth_probe()
1171 usb_free_urb(kaweth->irq_urb); in kaweth_probe()
1173 usb_free_urb(kaweth->rx_urb); in kaweth_probe()
1175 usb_free_urb(kaweth->tx_urb); in kaweth_probe()
1187 struct kaweth_device *kaweth = usb_get_intfdata(intf); in kaweth_disconnect() local
1191 if (!kaweth) { in kaweth_disconnect()
1195 netdev = kaweth->net; in kaweth_disconnect()
1197 netdev_dbg(kaweth->net, "Unregistering net device\n"); in kaweth_disconnect()
1200 usb_free_urb(kaweth->rx_urb); in kaweth_disconnect()
1201 usb_free_urb(kaweth->tx_urb); in kaweth_disconnect()
1202 usb_free_urb(kaweth->irq_urb); in kaweth_disconnect()
1204 usb_free_coherent(kaweth->dev, KAWETH_BUF_SIZE, (void *)kaweth->rx_buf, kaweth->rxbufferhandle); in kaweth_disconnect()
1205 usb_free_coherent(kaweth->dev, INTBUFFERSIZE, (void *)kaweth->intbuffer, kaweth->intbufferhandle); in kaweth_disconnect()