Lines Matching refs:kaweth
237 static int kaweth_read_configuration(struct kaweth_device *kaweth) in kaweth_read_configuration() argument
239 return usb_control_msg(kaweth->dev, usb_rcvctrlpipe(kaweth->dev, 0), in kaweth_read_configuration()
243 &kaweth->configuration, in kaweth_read_configuration()
244 sizeof(kaweth->configuration), in kaweth_read_configuration()
251 static int kaweth_set_urb_size(struct kaweth_device *kaweth, __u16 urb_size) in kaweth_set_urb_size() argument
253 netdev_dbg(kaweth->net, "Setting URB size to %d\n", (unsigned)urb_size); in kaweth_set_urb_size()
255 return usb_control_msg(kaweth->dev, usb_sndctrlpipe(kaweth->dev, 0), in kaweth_set_urb_size()
259 &kaweth->scratch, 0, in kaweth_set_urb_size()
266 static int kaweth_set_sofs_wait(struct kaweth_device *kaweth, __u16 sofs_wait) in kaweth_set_sofs_wait() argument
268 netdev_dbg(kaweth->net, "Set SOFS wait to %d\n", (unsigned)sofs_wait); in kaweth_set_sofs_wait()
270 return usb_control_msg(kaweth->dev, usb_sndctrlpipe(kaweth->dev, 0), in kaweth_set_sofs_wait()
274 &kaweth->scratch, 0, in kaweth_set_sofs_wait()
281 static int kaweth_set_receive_filter(struct kaweth_device *kaweth, in kaweth_set_receive_filter() argument
284 netdev_dbg(kaweth->net, "Set receive filter to %d\n", in kaweth_set_receive_filter()
287 return usb_control_msg(kaweth->dev, usb_sndctrlpipe(kaweth->dev, 0), in kaweth_set_receive_filter()
291 &kaweth->scratch, 0, in kaweth_set_receive_filter()
298 static int kaweth_download_firmware(struct kaweth_device *kaweth, in kaweth_download_firmware() argument
307 ret = request_firmware(&fw, fwname, &kaweth->dev->dev); in kaweth_download_firmware()
309 dev_err(&kaweth->intf->dev, "Firmware request failed\n"); in kaweth_download_firmware()
314 dev_err(&kaweth->intf->dev, "Firmware too big: %zu\n", in kaweth_download_firmware()
320 memcpy(kaweth->firmware_buf, fw->data, fw->size); in kaweth_download_firmware()
324 kaweth->firmware_buf[2] = (data_len & 0xFF) - 7; in kaweth_download_firmware()
325 kaweth->firmware_buf[3] = data_len >> 8; in kaweth_download_firmware()
326 kaweth->firmware_buf[4] = type; in kaweth_download_firmware()
327 kaweth->firmware_buf[5] = interrupt; in kaweth_download_firmware()
329 netdev_dbg(kaweth->net, "High: %i, Low:%i\n", kaweth->firmware_buf[3], in kaweth_download_firmware()
330 kaweth->firmware_buf[2]); in kaweth_download_firmware()
332 netdev_dbg(kaweth->net, in kaweth_download_firmware()
334 kaweth->firmware_buf, kaweth); in kaweth_download_firmware()
335 netdev_dbg(kaweth->net, "Firmware length: %d\n", data_len); in kaweth_download_firmware()
337 return usb_control_msg(kaweth->dev, usb_sndctrlpipe(kaweth->dev, 0), in kaweth_download_firmware()
341 kaweth->firmware_buf, data_len, in kaweth_download_firmware()
348 static int kaweth_trigger_firmware(struct kaweth_device *kaweth, in kaweth_trigger_firmware() argument
351 kaweth->firmware_buf[0] = 0xB6; in kaweth_trigger_firmware()
352 kaweth->firmware_buf[1] = 0xC3; in kaweth_trigger_firmware()
353 kaweth->firmware_buf[2] = 0x01; in kaweth_trigger_firmware()
354 kaweth->firmware_buf[3] = 0x00; in kaweth_trigger_firmware()
355 kaweth->firmware_buf[4] = 0x06; in kaweth_trigger_firmware()
356 kaweth->firmware_buf[5] = interrupt; in kaweth_trigger_firmware()
357 kaweth->firmware_buf[6] = 0x00; in kaweth_trigger_firmware()
358 kaweth->firmware_buf[7] = 0x00; in kaweth_trigger_firmware()
360 return usb_control_msg(kaweth->dev, usb_sndctrlpipe(kaweth->dev, 0), in kaweth_trigger_firmware()
364 (void *)kaweth->firmware_buf, 8, in kaweth_trigger_firmware()
371 static int kaweth_reset(struct kaweth_device *kaweth) in kaweth_reset() argument
375 result = usb_reset_configuration(kaweth->dev); in kaweth_reset()
378 netdev_dbg(kaweth->net, "kaweth_reset() returns %d.\n", result); in kaweth_reset()
390 static void kaweth_resubmit_int_urb(struct kaweth_device *kaweth, gfp_t mf) in kaweth_resubmit_int_urb() argument
394 status = usb_submit_urb (kaweth->irq_urb, mf); in kaweth_resubmit_int_urb()
396 kaweth->suspend_lowmem_ctrl = 1; in kaweth_resubmit_int_urb()
397 schedule_delayed_work(&kaweth->lowmem_work, HZ/4); in kaweth_resubmit_int_urb()
399 kaweth->suspend_lowmem_ctrl = 0; in kaweth_resubmit_int_urb()
403 dev_err(&kaweth->intf->dev, in kaweth_resubmit_int_urb()
405 kaweth->dev->bus->bus_name, in kaweth_resubmit_int_urb()
406 kaweth->dev->devpath, status); in kaweth_resubmit_int_urb()
411 struct kaweth_device *kaweth = u->context; in int_callback() local
428 …if (kaweth->linkstate != (act_state = ( kaweth->intbuffer[STATE_OFFSET] | STATE_MASK) >> STATE_SHI… in int_callback()
430 netif_carrier_on(kaweth->net); in int_callback()
432 netif_carrier_off(kaweth->net); in int_callback()
434 kaweth->linkstate = act_state; in int_callback()
437 kaweth_resubmit_int_urb(kaweth, GFP_ATOMIC); in int_callback()
442 struct kaweth_device *kaweth = in kaweth_resubmit_tl() local
445 if (IS_BLOCKED(kaweth->status)) in kaweth_resubmit_tl()
448 if (kaweth->suspend_lowmem_rx) in kaweth_resubmit_tl()
449 kaweth_resubmit_rx_urb(kaweth, GFP_NOIO); in kaweth_resubmit_tl()
451 if (kaweth->suspend_lowmem_ctrl) in kaweth_resubmit_tl()
452 kaweth_resubmit_int_urb(kaweth, GFP_NOIO); in kaweth_resubmit_tl()
459 static int kaweth_resubmit_rx_urb(struct kaweth_device *kaweth, in kaweth_resubmit_rx_urb() argument
464 usb_fill_bulk_urb(kaweth->rx_urb, in kaweth_resubmit_rx_urb()
465 kaweth->dev, in kaweth_resubmit_rx_urb()
466 usb_rcvbulkpipe(kaweth->dev, 1), in kaweth_resubmit_rx_urb()
467 kaweth->rx_buf, in kaweth_resubmit_rx_urb()
470 kaweth); in kaweth_resubmit_rx_urb()
471 kaweth->rx_urb->transfer_flags |= URB_NO_TRANSFER_DMA_MAP; in kaweth_resubmit_rx_urb()
472 kaweth->rx_urb->transfer_dma = kaweth->rxbufferhandle; in kaweth_resubmit_rx_urb()
474 if((result = usb_submit_urb(kaweth->rx_urb, mem_flags))) { in kaweth_resubmit_rx_urb()
476 kaweth->suspend_lowmem_rx = 1; in kaweth_resubmit_rx_urb()
477 schedule_delayed_work(&kaweth->lowmem_work, HZ/4); in kaweth_resubmit_rx_urb()
479 dev_err(&kaweth->intf->dev, "resubmitting rx_urb %d failed\n", in kaweth_resubmit_rx_urb()
482 kaweth->suspend_lowmem_rx = 0; in kaweth_resubmit_rx_urb()
488 static void kaweth_async_set_rx_mode(struct kaweth_device *kaweth,
497 struct kaweth_device *kaweth = urb->context; in kaweth_usb_receive() local
498 struct net_device *net = kaweth->net; in kaweth_usb_receive()
504 __u16 pkt_len = le16_to_cpup((__le16 *)kaweth->rx_buf); in kaweth_usb_receive()
510 kaweth->end = 1; in kaweth_usb_receive()
511 wake_up(&kaweth->term_wait); in kaweth_usb_receive()
517 kaweth->end = 1; in kaweth_usb_receive()
518 wake_up(&kaweth->term_wait); in kaweth_usb_receive()
532 spin_lock_irqsave(&kaweth->device_lock, flags); in kaweth_usb_receive()
533 if (IS_BLOCKED(kaweth->status)) { in kaweth_usb_receive()
534 spin_unlock_irqrestore(&kaweth->device_lock, flags); in kaweth_usb_receive()
537 spin_unlock_irqrestore(&kaweth->device_lock, flags); in kaweth_usb_receive()
540 dev_err(&kaweth->intf->dev, in kaweth_usb_receive()
543 kaweth_resubmit_rx_urb(kaweth, GFP_ATOMIC); in kaweth_usb_receive()
547 if(kaweth->net && (count > 2)) { in kaweth_usb_receive()
549 dev_err(&kaweth->intf->dev, in kaweth_usb_receive()
552 dev_err(&kaweth->intf->dev, "Packet len & 2047: %x\n", in kaweth_usb_receive()
554 dev_err(&kaweth->intf->dev, "Count 2: %x\n", count2); in kaweth_usb_receive()
555 kaweth_resubmit_rx_urb(kaweth, GFP_ATOMIC); in kaweth_usb_receive()
560 kaweth_resubmit_rx_urb(kaweth, GFP_ATOMIC); in kaweth_usb_receive()
566 skb_copy_to_linear_data(skb, kaweth->rx_buf + 2, pkt_len); in kaweth_usb_receive()
578 kaweth_resubmit_rx_urb(kaweth, GFP_ATOMIC); in kaweth_usb_receive()
586 struct kaweth_device *kaweth = netdev_priv(net); in kaweth_open() local
589 res = usb_autopm_get_interface(kaweth->intf); in kaweth_open()
591 dev_err(&kaweth->intf->dev, "Interface cannot be resumed.\n"); in kaweth_open()
594 res = kaweth_resubmit_rx_urb(kaweth, GFP_KERNEL); in kaweth_open()
599 kaweth->irq_urb, in kaweth_open()
600 kaweth->dev, in kaweth_open()
601 usb_rcvintpipe(kaweth->dev, 3), in kaweth_open()
602 kaweth->intbuffer, in kaweth_open()
605 kaweth, in kaweth_open()
607 kaweth->irq_urb->transfer_dma = kaweth->intbufferhandle; in kaweth_open()
608 kaweth->irq_urb->transfer_flags |= URB_NO_TRANSFER_DMA_MAP; in kaweth_open()
610 res = usb_submit_urb(kaweth->irq_urb, GFP_KERNEL); in kaweth_open()
612 usb_kill_urb(kaweth->rx_urb); in kaweth_open()
615 kaweth->opened = 1; in kaweth_open()
619 kaweth_async_set_rx_mode(kaweth, true); in kaweth_open()
623 usb_autopm_put_interface(kaweth->intf); in kaweth_open()
630 static void kaweth_kill_urbs(struct kaweth_device *kaweth) in kaweth_kill_urbs() argument
632 usb_kill_urb(kaweth->irq_urb); in kaweth_kill_urbs()
633 usb_kill_urb(kaweth->rx_urb); in kaweth_kill_urbs()
634 usb_kill_urb(kaweth->tx_urb); in kaweth_kill_urbs()
636 cancel_delayed_work_sync(&kaweth->lowmem_work); in kaweth_kill_urbs()
640 usb_kill_urb(kaweth->irq_urb); in kaweth_kill_urbs()
641 usb_kill_urb(kaweth->rx_urb); in kaweth_kill_urbs()
649 struct kaweth_device *kaweth = netdev_priv(net); in kaweth_close() local
652 kaweth->opened = 0; in kaweth_close()
654 kaweth->status |= KAWETH_STATUS_CLOSING; in kaweth_close()
656 kaweth_kill_urbs(kaweth); in kaweth_close()
658 kaweth->status &= ~KAWETH_STATUS_CLOSING; in kaweth_close()
660 usb_autopm_put_interface(kaweth->intf); in kaweth_close()
667 struct kaweth_device *kaweth = netdev_priv(dev); in kaweth_get_link() local
669 return kaweth->linkstate; in kaweth_get_link()
681 struct kaweth_device *kaweth = urb->context; in kaweth_usb_transmit_complete() local
682 struct sk_buff *skb = kaweth->tx_skb; in kaweth_usb_transmit_complete()
688 kaweth->net->name, status); in kaweth_usb_transmit_complete()
690 netif_wake_queue(kaweth->net); in kaweth_usb_transmit_complete()
700 struct kaweth_device *kaweth = netdev_priv(net); in kaweth_start_xmit() local
705 spin_lock_irq(&kaweth->device_lock); in kaweth_start_xmit()
707 kaweth_async_set_rx_mode(kaweth, false); in kaweth_start_xmit()
709 if (IS_BLOCKED(kaweth->status)) { in kaweth_start_xmit()
717 spin_unlock_irq(&kaweth->device_lock); in kaweth_start_xmit()
724 kaweth->tx_skb = skb; in kaweth_start_xmit()
726 usb_fill_bulk_urb(kaweth->tx_urb, in kaweth_start_xmit()
727 kaweth->dev, in kaweth_start_xmit()
728 usb_sndbulkpipe(kaweth->dev, 2), in kaweth_start_xmit()
732 kaweth); in kaweth_start_xmit()
733 kaweth->end = 0; in kaweth_start_xmit()
735 if((res = usb_submit_urb(kaweth->tx_urb, GFP_ATOMIC))) in kaweth_start_xmit()
750 spin_unlock_irq(&kaweth->device_lock); in kaweth_start_xmit()
760 struct kaweth_device *kaweth = netdev_priv(net); in kaweth_set_rx_mode() local
777 kaweth->packet_filter_bitmap = packet_filter_bitmap; in kaweth_set_rx_mode()
784 static void kaweth_async_set_rx_mode(struct kaweth_device *kaweth, in kaweth_async_set_rx_mode() argument
788 __u16 packet_filter_bitmap = kaweth->packet_filter_bitmap; in kaweth_async_set_rx_mode()
790 kaweth->packet_filter_bitmap = 0; in kaweth_async_set_rx_mode()
797 ret = usb_control_msg(kaweth->dev, usb_sndctrlpipe(kaweth->dev, 0), in kaweth_async_set_rx_mode()
801 &kaweth->scratch, 0, in kaweth_async_set_rx_mode()
804 dev_err(&kaweth->intf->dev, "Failed to set Rx mode: %d\n", in kaweth_async_set_rx_mode()
807 netdev_dbg(kaweth->net, "Set Rx mode to %d\n", in kaweth_async_set_rx_mode()
816 struct kaweth_device *kaweth = netdev_priv(net); in kaweth_tx_timeout() local
822 usb_unlink_urb(kaweth->tx_urb); in kaweth_tx_timeout()
830 struct kaweth_device *kaweth = usb_get_intfdata(intf); in kaweth_suspend() local
833 spin_lock_irqsave(&kaweth->device_lock, flags); in kaweth_suspend()
834 kaweth->status |= KAWETH_STATUS_SUSPENDING; in kaweth_suspend()
835 spin_unlock_irqrestore(&kaweth->device_lock, flags); in kaweth_suspend()
837 kaweth_kill_urbs(kaweth); in kaweth_suspend()
846 struct kaweth_device *kaweth = usb_get_intfdata(intf); in kaweth_resume() local
849 spin_lock_irqsave(&kaweth->device_lock, flags); in kaweth_resume()
850 kaweth->status &= ~KAWETH_STATUS_SUSPENDING; in kaweth_resume()
851 spin_unlock_irqrestore(&kaweth->device_lock, flags); in kaweth_resume()
853 if (!kaweth->opened) in kaweth_resume()
855 kaweth_resubmit_rx_urb(kaweth, GFP_NOIO); in kaweth_resume()
856 kaweth_resubmit_int_urb(kaweth, GFP_NOIO); in kaweth_resume()
883 struct kaweth_device *kaweth; in kaweth_probe() local
901 netdev = alloc_etherdev(sizeof(*kaweth)); in kaweth_probe()
905 kaweth = netdev_priv(netdev); in kaweth_probe()
906 kaweth->dev = udev; in kaweth_probe()
907 kaweth->net = netdev; in kaweth_probe()
908 kaweth->intf = intf; in kaweth_probe()
910 spin_lock_init(&kaweth->device_lock); in kaweth_probe()
911 init_waitqueue_head(&kaweth->term_wait); in kaweth_probe()
915 kaweth_reset(kaweth); in kaweth_probe()
927 kaweth->firmware_buf = (__u8 *)__get_free_page(GFP_KERNEL); in kaweth_probe()
928 if (!kaweth->firmware_buf) { in kaweth_probe()
932 if ((result = kaweth_download_firmware(kaweth, in kaweth_probe()
941 if ((result = kaweth_download_firmware(kaweth, in kaweth_probe()
950 if ((result = kaweth_download_firmware(kaweth, in kaweth_probe()
960 if ((result = kaweth_download_firmware(kaweth, in kaweth_probe()
969 if ((result = kaweth_trigger_firmware(kaweth, 126)) < 0) { in kaweth_probe()
977 free_page((unsigned long)kaweth->firmware_buf); in kaweth_probe()
982 result = kaweth_read_configuration(kaweth); in kaweth_probe()
989 dev_info(dev, "Statistics collection: %x\n", kaweth->configuration.statistics_mask); in kaweth_probe()
990 …dev_info(dev, "Multicast filter limit: %x\n", kaweth->configuration.max_multicast_filters & ((1 <<… in kaweth_probe()
991 dev_info(dev, "MTU: %d\n", le16_to_cpu(kaweth->configuration.segment_size)); in kaweth_probe()
992 dev_info(dev, "Read MAC address %pM\n", kaweth->configuration.hw_addr); in kaweth_probe()
994 if(!memcmp(&kaweth->configuration.hw_addr, in kaweth_probe()
1001 if(kaweth_set_urb_size(kaweth, KAWETH_BUF_SIZE) < 0) { in kaweth_probe()
1006 if(kaweth_set_sofs_wait(kaweth, KAWETH_SOFS_TO_WAIT) < 0) { in kaweth_probe()
1011 result = kaweth_set_receive_filter(kaweth, in kaweth_probe()
1023 kaweth->tx_urb = usb_alloc_urb(0, GFP_KERNEL); in kaweth_probe()
1024 if (!kaweth->tx_urb) in kaweth_probe()
1026 kaweth->rx_urb = usb_alloc_urb(0, GFP_KERNEL); in kaweth_probe()
1027 if (!kaweth->rx_urb) in kaweth_probe()
1029 kaweth->irq_urb = usb_alloc_urb(0, GFP_KERNEL); in kaweth_probe()
1030 if (!kaweth->irq_urb) in kaweth_probe()
1033 kaweth->intbuffer = usb_alloc_coherent( kaweth->dev, in kaweth_probe()
1036 &kaweth->intbufferhandle); in kaweth_probe()
1037 if (!kaweth->intbuffer) in kaweth_probe()
1039 kaweth->rx_buf = usb_alloc_coherent( kaweth->dev, in kaweth_probe()
1042 &kaweth->rxbufferhandle); in kaweth_probe()
1043 if (!kaweth->rx_buf) in kaweth_probe()
1047 eth_hw_addr_set(netdev, (u8 *)&kaweth->configuration.hw_addr); in kaweth_probe()
1051 netdev->mtu = le16_to_cpu(kaweth->configuration.segment_size); in kaweth_probe()
1055 INIT_DELAYED_WORK(&kaweth->lowmem_work, kaweth_resubmit_tl); in kaweth_probe()
1056 usb_set_intfdata(intf, kaweth); in kaweth_probe()
1065 kaweth->net->name); in kaweth_probe()
1071 usb_free_coherent(kaweth->dev, KAWETH_BUF_SIZE, (void *)kaweth->rx_buf, kaweth->rxbufferhandle); in kaweth_probe()
1073 usb_free_coherent(kaweth->dev, INTBUFFERSIZE, (void *)kaweth->intbuffer, kaweth->intbufferhandle); in kaweth_probe()
1075 usb_free_urb(kaweth->irq_urb); in kaweth_probe()
1077 usb_free_urb(kaweth->rx_urb); in kaweth_probe()
1079 usb_free_urb(kaweth->tx_urb); in kaweth_probe()
1091 struct kaweth_device *kaweth = usb_get_intfdata(intf); in kaweth_disconnect() local
1095 if (!kaweth) { in kaweth_disconnect()
1099 netdev = kaweth->net; in kaweth_disconnect()
1101 netdev_dbg(kaweth->net, "Unregistering net device\n"); in kaweth_disconnect()
1104 usb_free_urb(kaweth->rx_urb); in kaweth_disconnect()
1105 usb_free_urb(kaweth->tx_urb); in kaweth_disconnect()
1106 usb_free_urb(kaweth->irq_urb); in kaweth_disconnect()
1108 usb_free_coherent(kaweth->dev, KAWETH_BUF_SIZE, (void *)kaweth->rx_buf, kaweth->rxbufferhandle); in kaweth_disconnect()
1109 usb_free_coherent(kaweth->dev, INTBUFFERSIZE, (void *)kaweth->intbuffer, kaweth->intbufferhandle); in kaweth_disconnect()