diff options
author | Paul Mackerras <paulus@samba.org> | 2006-12-03 23:59:07 -0500 |
---|---|---|
committer | Paul Mackerras <paulus@samba.org> | 2006-12-03 23:59:07 -0500 |
commit | 79acbb3ff2d8095b692e1502b9eb2ccec348de26 (patch) | |
tree | 6ab773e5a8f9de2cd6443362b21d0d6fffe3b35e /drivers/usb/net | |
parent | 19a79859e168640f8e16d7b216d211c1c52b687a (diff) | |
parent | 2b5f6dcce5bf94b9b119e9ed8d537098ec61c3d2 (diff) |
Merge branch 'linux-2.6' into for-linus
Diffstat (limited to 'drivers/usb/net')
-rw-r--r-- | drivers/usb/net/Kconfig | 16 | ||||
-rw-r--r-- | drivers/usb/net/Makefile | 1 | ||||
-rw-r--r-- | drivers/usb/net/asix.c | 54 | ||||
-rw-r--r-- | drivers/usb/net/catc.c | 12 | ||||
-rw-r--r-- | drivers/usb/net/cdc_ether.c | 5 | ||||
-rw-r--r-- | drivers/usb/net/kaweth.c | 204 | ||||
-rw-r--r-- | drivers/usb/net/mcs7830.c | 534 | ||||
-rw-r--r-- | drivers/usb/net/net1080.c | 4 | ||||
-rw-r--r-- | drivers/usb/net/pegasus.c | 1 | ||||
-rw-r--r-- | drivers/usb/net/usbnet.c | 85 | ||||
-rw-r--r-- | drivers/usb/net/usbnet.h | 5 |
11 files changed, 780 insertions, 141 deletions
diff --git a/drivers/usb/net/Kconfig b/drivers/usb/net/Kconfig index 054059632a21..e081836014ac 100644 --- a/drivers/usb/net/Kconfig +++ b/drivers/usb/net/Kconfig | |||
@@ -92,8 +92,13 @@ config USB_RTL8150 | |||
92 | To compile this driver as a module, choose M here: the | 92 | To compile this driver as a module, choose M here: the |
93 | module will be called rtl8150. | 93 | module will be called rtl8150. |
94 | 94 | ||
95 | config USB_USBNET_MII | ||
96 | tristate | ||
97 | default n | ||
98 | |||
95 | config USB_USBNET | 99 | config USB_USBNET |
96 | tristate "Multi-purpose USB Networking Framework" | 100 | tristate "Multi-purpose USB Networking Framework" |
101 | select MII if USBNET_MII != n | ||
97 | ---help--- | 102 | ---help--- |
98 | This driver supports several kinds of network links over USB, | 103 | This driver supports several kinds of network links over USB, |
99 | with "minidrivers" built around a common network driver core | 104 | with "minidrivers" built around a common network driver core |
@@ -129,7 +134,7 @@ config USB_NET_AX8817X | |||
129 | tristate "ASIX AX88xxx Based USB 2.0 Ethernet Adapters" | 134 | tristate "ASIX AX88xxx Based USB 2.0 Ethernet Adapters" |
130 | depends on USB_USBNET && NET_ETHERNET | 135 | depends on USB_USBNET && NET_ETHERNET |
131 | select CRC32 | 136 | select CRC32 |
132 | select MII | 137 | select USB_USBNET_MII |
133 | default y | 138 | default y |
134 | help | 139 | help |
135 | This option adds support for ASIX AX88xxx based USB 2.0 | 140 | This option adds support for ASIX AX88xxx based USB 2.0 |
@@ -207,6 +212,15 @@ config USB_NET_PLUSB | |||
207 | Choose this option if you're using a host-to-host cable | 212 | Choose this option if you're using a host-to-host cable |
208 | with one of these chips. | 213 | with one of these chips. |
209 | 214 | ||
215 | config USB_NET_MCS7830 | ||
216 | tristate "MosChip MCS7830 based Ethernet adapters" | ||
217 | depends on USB_USBNET | ||
218 | select USB_USBNET_MII | ||
219 | help | ||
220 | Choose this option if you're using a 10/100 Ethernet USB2 | ||
221 | adapter based on the MosChip 7830 controller. This includes | ||
222 | adapters marketed under the DeLOCK brand. | ||
223 | |||
210 | config USB_NET_RNDIS_HOST | 224 | config USB_NET_RNDIS_HOST |
211 | tristate "Host for RNDIS devices (EXPERIMENTAL)" | 225 | tristate "Host for RNDIS devices (EXPERIMENTAL)" |
212 | depends on USB_USBNET && EXPERIMENTAL | 226 | depends on USB_USBNET && EXPERIMENTAL |
diff --git a/drivers/usb/net/Makefile b/drivers/usb/net/Makefile index 160f19dbdf12..7b51964de171 100644 --- a/drivers/usb/net/Makefile +++ b/drivers/usb/net/Makefile | |||
@@ -14,6 +14,7 @@ obj-$(CONFIG_USB_NET_PLUSB) += plusb.o | |||
14 | obj-$(CONFIG_USB_NET_RNDIS_HOST) += rndis_host.o | 14 | obj-$(CONFIG_USB_NET_RNDIS_HOST) += rndis_host.o |
15 | obj-$(CONFIG_USB_NET_CDC_SUBSET) += cdc_subset.o | 15 | obj-$(CONFIG_USB_NET_CDC_SUBSET) += cdc_subset.o |
16 | obj-$(CONFIG_USB_NET_ZAURUS) += zaurus.o | 16 | obj-$(CONFIG_USB_NET_ZAURUS) += zaurus.o |
17 | obj-$(CONFIG_USB_NET_MCS7830) += mcs7830.o | ||
17 | obj-$(CONFIG_USB_USBNET) += usbnet.o | 18 | obj-$(CONFIG_USB_USBNET) += usbnet.o |
18 | 19 | ||
19 | ifeq ($(CONFIG_USB_DEBUG),y) | 20 | ifeq ($(CONFIG_USB_DEBUG),y) |
diff --git a/drivers/usb/net/asix.c b/drivers/usb/net/asix.c index c73dd224aa76..95e682e2c9d6 100644 --- a/drivers/usb/net/asix.c +++ b/drivers/usb/net/asix.c | |||
@@ -249,9 +249,9 @@ asix_write_cmd_async(struct usbnet *dev, u8 cmd, u16 value, u16 index, | |||
249 | 249 | ||
250 | req->bRequestType = USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_DEVICE; | 250 | req->bRequestType = USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_DEVICE; |
251 | req->bRequest = cmd; | 251 | req->bRequest = cmd; |
252 | req->wValue = value; | 252 | req->wValue = cpu_to_le16(value); |
253 | req->wIndex = index; | 253 | req->wIndex = cpu_to_le16(index); |
254 | req->wLength = size; | 254 | req->wLength = cpu_to_le16(size); |
255 | 255 | ||
256 | usb_fill_control_urb(urb, dev->udev, | 256 | usb_fill_control_urb(urb, dev->udev, |
257 | usb_sndctrlpipe(dev->udev, 0), | 257 | usb_sndctrlpipe(dev->udev, 0), |
@@ -569,10 +569,12 @@ static int asix_mdio_read(struct net_device *netdev, int phy_id, int loc) | |||
569 | struct usbnet *dev = netdev_priv(netdev); | 569 | struct usbnet *dev = netdev_priv(netdev); |
570 | u16 res; | 570 | u16 res; |
571 | 571 | ||
572 | mutex_lock(&dev->phy_mutex); | ||
572 | asix_set_sw_mii(dev); | 573 | asix_set_sw_mii(dev); |
573 | asix_read_cmd(dev, AX_CMD_READ_MII_REG, phy_id, | 574 | asix_read_cmd(dev, AX_CMD_READ_MII_REG, phy_id, |
574 | (__u16)loc, 2, (u16 *)&res); | 575 | (__u16)loc, 2, (u16 *)&res); |
575 | asix_set_hw_mii(dev); | 576 | asix_set_hw_mii(dev); |
577 | mutex_unlock(&dev->phy_mutex); | ||
576 | 578 | ||
577 | devdbg(dev, "asix_mdio_read() phy_id=0x%02x, loc=0x%02x, returns=0x%04x", phy_id, loc, le16_to_cpu(res & 0xffff)); | 579 | devdbg(dev, "asix_mdio_read() phy_id=0x%02x, loc=0x%02x, returns=0x%04x", phy_id, loc, le16_to_cpu(res & 0xffff)); |
578 | 580 | ||
@@ -586,10 +588,12 @@ asix_mdio_write(struct net_device *netdev, int phy_id, int loc, int val) | |||
586 | u16 res = cpu_to_le16(val); | 588 | u16 res = cpu_to_le16(val); |
587 | 589 | ||
588 | devdbg(dev, "asix_mdio_write() phy_id=0x%02x, loc=0x%02x, val=0x%04x", phy_id, loc, val); | 590 | devdbg(dev, "asix_mdio_write() phy_id=0x%02x, loc=0x%02x, val=0x%04x", phy_id, loc, val); |
591 | mutex_lock(&dev->phy_mutex); | ||
589 | asix_set_sw_mii(dev); | 592 | asix_set_sw_mii(dev); |
590 | asix_write_cmd(dev, AX_CMD_WRITE_MII_REG, phy_id, | 593 | asix_write_cmd(dev, AX_CMD_WRITE_MII_REG, phy_id, |
591 | (__u16)loc, 2, (u16 *)&res); | 594 | (__u16)loc, 2, (u16 *)&res); |
592 | asix_set_hw_mii(dev); | 595 | asix_set_hw_mii(dev); |
596 | mutex_unlock(&dev->phy_mutex); | ||
593 | } | 597 | } |
594 | 598 | ||
595 | /* Get the PHY Identifier from the PHYSID1 & PHYSID2 MII registers */ | 599 | /* Get the PHY Identifier from the PHYSID1 & PHYSID2 MII registers */ |
@@ -700,32 +704,6 @@ static void asix_get_drvinfo (struct net_device *net, | |||
700 | info->eedump_len = data->eeprom_len; | 704 | info->eedump_len = data->eeprom_len; |
701 | } | 705 | } |
702 | 706 | ||
703 | static int asix_get_settings(struct net_device *net, struct ethtool_cmd *cmd) | ||
704 | { | ||
705 | struct usbnet *dev = netdev_priv(net); | ||
706 | |||
707 | return mii_ethtool_gset(&dev->mii,cmd); | ||
708 | } | ||
709 | |||
710 | static int asix_set_settings(struct net_device *net, struct ethtool_cmd *cmd) | ||
711 | { | ||
712 | struct usbnet *dev = netdev_priv(net); | ||
713 | int res = mii_ethtool_sset(&dev->mii,cmd); | ||
714 | |||
715 | /* link speed/duplex might have changed */ | ||
716 | if (dev->driver_info->link_reset) | ||
717 | dev->driver_info->link_reset(dev); | ||
718 | |||
719 | return res; | ||
720 | } | ||
721 | |||
722 | static int asix_nway_reset(struct net_device *net) | ||
723 | { | ||
724 | struct usbnet *dev = netdev_priv(net); | ||
725 | |||
726 | return mii_nway_restart(&dev->mii); | ||
727 | } | ||
728 | |||
729 | static u32 asix_get_link(struct net_device *net) | 707 | static u32 asix_get_link(struct net_device *net) |
730 | { | 708 | { |
731 | struct usbnet *dev = netdev_priv(net); | 709 | struct usbnet *dev = netdev_priv(net); |
@@ -746,15 +724,15 @@ static int asix_ioctl (struct net_device *net, struct ifreq *rq, int cmd) | |||
746 | static struct ethtool_ops ax88172_ethtool_ops = { | 724 | static struct ethtool_ops ax88172_ethtool_ops = { |
747 | .get_drvinfo = asix_get_drvinfo, | 725 | .get_drvinfo = asix_get_drvinfo, |
748 | .get_link = asix_get_link, | 726 | .get_link = asix_get_link, |
749 | .nway_reset = asix_nway_reset, | ||
750 | .get_msglevel = usbnet_get_msglevel, | 727 | .get_msglevel = usbnet_get_msglevel, |
751 | .set_msglevel = usbnet_set_msglevel, | 728 | .set_msglevel = usbnet_set_msglevel, |
752 | .get_wol = asix_get_wol, | 729 | .get_wol = asix_get_wol, |
753 | .set_wol = asix_set_wol, | 730 | .set_wol = asix_set_wol, |
754 | .get_eeprom_len = asix_get_eeprom_len, | 731 | .get_eeprom_len = asix_get_eeprom_len, |
755 | .get_eeprom = asix_get_eeprom, | 732 | .get_eeprom = asix_get_eeprom, |
756 | .get_settings = asix_get_settings, | 733 | .get_settings = usbnet_get_settings, |
757 | .set_settings = asix_set_settings, | 734 | .set_settings = usbnet_set_settings, |
735 | .nway_reset = usbnet_nway_reset, | ||
758 | }; | 736 | }; |
759 | 737 | ||
760 | static void ax88172_set_multicast(struct net_device *net) | 738 | static void ax88172_set_multicast(struct net_device *net) |
@@ -885,15 +863,15 @@ out1: | |||
885 | static struct ethtool_ops ax88772_ethtool_ops = { | 863 | static struct ethtool_ops ax88772_ethtool_ops = { |
886 | .get_drvinfo = asix_get_drvinfo, | 864 | .get_drvinfo = asix_get_drvinfo, |
887 | .get_link = asix_get_link, | 865 | .get_link = asix_get_link, |
888 | .nway_reset = asix_nway_reset, | ||
889 | .get_msglevel = usbnet_get_msglevel, | 866 | .get_msglevel = usbnet_get_msglevel, |
890 | .set_msglevel = usbnet_set_msglevel, | 867 | .set_msglevel = usbnet_set_msglevel, |
891 | .get_wol = asix_get_wol, | 868 | .get_wol = asix_get_wol, |
892 | .set_wol = asix_set_wol, | 869 | .set_wol = asix_set_wol, |
893 | .get_eeprom_len = asix_get_eeprom_len, | 870 | .get_eeprom_len = asix_get_eeprom_len, |
894 | .get_eeprom = asix_get_eeprom, | 871 | .get_eeprom = asix_get_eeprom, |
895 | .get_settings = asix_get_settings, | 872 | .get_settings = usbnet_get_settings, |
896 | .set_settings = asix_set_settings, | 873 | .set_settings = usbnet_set_settings, |
874 | .nway_reset = usbnet_nway_reset, | ||
897 | }; | 875 | }; |
898 | 876 | ||
899 | static int ax88772_link_reset(struct usbnet *dev) | 877 | static int ax88772_link_reset(struct usbnet *dev) |
@@ -1046,15 +1024,15 @@ out1: | |||
1046 | static struct ethtool_ops ax88178_ethtool_ops = { | 1024 | static struct ethtool_ops ax88178_ethtool_ops = { |
1047 | .get_drvinfo = asix_get_drvinfo, | 1025 | .get_drvinfo = asix_get_drvinfo, |
1048 | .get_link = asix_get_link, | 1026 | .get_link = asix_get_link, |
1049 | .nway_reset = asix_nway_reset, | ||
1050 | .get_msglevel = usbnet_get_msglevel, | 1027 | .get_msglevel = usbnet_get_msglevel, |
1051 | .set_msglevel = usbnet_set_msglevel, | 1028 | .set_msglevel = usbnet_set_msglevel, |
1052 | .get_wol = asix_get_wol, | 1029 | .get_wol = asix_get_wol, |
1053 | .set_wol = asix_set_wol, | 1030 | .set_wol = asix_set_wol, |
1054 | .get_eeprom_len = asix_get_eeprom_len, | 1031 | .get_eeprom_len = asix_get_eeprom_len, |
1055 | .get_eeprom = asix_get_eeprom, | 1032 | .get_eeprom = asix_get_eeprom, |
1056 | .get_settings = asix_get_settings, | 1033 | .get_settings = usbnet_get_settings, |
1057 | .set_settings = asix_set_settings, | 1034 | .set_settings = usbnet_set_settings, |
1035 | .nway_reset = usbnet_nway_reset, | ||
1058 | }; | 1036 | }; |
1059 | 1037 | ||
1060 | static int marvell_phy_init(struct usbnet *dev) | 1038 | static int marvell_phy_init(struct usbnet *dev) |
diff --git a/drivers/usb/net/catc.c b/drivers/usb/net/catc.c index f740325abac4..907b820a5faf 100644 --- a/drivers/usb/net/catc.c +++ b/drivers/usb/net/catc.c | |||
@@ -786,14 +786,10 @@ static int catc_probe(struct usb_interface *intf, const struct usb_device_id *id | |||
786 | if ((!catc->ctrl_urb) || (!catc->tx_urb) || | 786 | if ((!catc->ctrl_urb) || (!catc->tx_urb) || |
787 | (!catc->rx_urb) || (!catc->irq_urb)) { | 787 | (!catc->rx_urb) || (!catc->irq_urb)) { |
788 | err("No free urbs available."); | 788 | err("No free urbs available."); |
789 | if (catc->ctrl_urb) | 789 | usb_free_urb(catc->ctrl_urb); |
790 | usb_free_urb(catc->ctrl_urb); | 790 | usb_free_urb(catc->tx_urb); |
791 | if (catc->tx_urb) | 791 | usb_free_urb(catc->rx_urb); |
792 | usb_free_urb(catc->tx_urb); | 792 | usb_free_urb(catc->irq_urb); |
793 | if (catc->rx_urb) | ||
794 | usb_free_urb(catc->rx_urb); | ||
795 | if (catc->irq_urb) | ||
796 | usb_free_urb(catc->irq_urb); | ||
797 | free_netdev(netdev); | 793 | free_netdev(netdev); |
798 | return -ENOMEM; | 794 | return -ENOMEM; |
799 | } | 795 | } |
diff --git a/drivers/usb/net/cdc_ether.c b/drivers/usb/net/cdc_ether.c index 82ce0358d9a3..44a91547146e 100644 --- a/drivers/usb/net/cdc_ether.c +++ b/drivers/usb/net/cdc_ether.c | |||
@@ -200,8 +200,7 @@ next_desc: | |||
200 | 200 | ||
201 | dev->status = &info->control->cur_altsetting->endpoint [0]; | 201 | dev->status = &info->control->cur_altsetting->endpoint [0]; |
202 | desc = &dev->status->desc; | 202 | desc = &dev->status->desc; |
203 | if (desc->bmAttributes != USB_ENDPOINT_XFER_INT | 203 | if (!usb_endpoint_is_int_in(desc) |
204 | || !(desc->bEndpointAddress & USB_DIR_IN) | ||
205 | || (le16_to_cpu(desc->wMaxPacketSize) | 204 | || (le16_to_cpu(desc->wMaxPacketSize) |
206 | < sizeof(struct usb_cdc_notification)) | 205 | < sizeof(struct usb_cdc_notification)) |
207 | || !desc->bInterval) { | 206 | || !desc->bInterval) { |
@@ -498,7 +497,7 @@ static struct usb_driver cdc_driver = { | |||
498 | 497 | ||
499 | static int __init cdc_init(void) | 498 | static int __init cdc_init(void) |
500 | { | 499 | { |
501 | BUG_ON((sizeof(((struct usbnet *)0)->data) | 500 | BUILD_BUG_ON((sizeof(((struct usbnet *)0)->data) |
502 | < sizeof(struct cdc_state))); | 501 | < sizeof(struct cdc_state))); |
503 | 502 | ||
504 | return usb_register(&cdc_driver); | 503 | return usb_register(&cdc_driver); |
diff --git a/drivers/usb/net/kaweth.c b/drivers/usb/net/kaweth.c index 957d4ad316f9..7c906a43e497 100644 --- a/drivers/usb/net/kaweth.c +++ b/drivers/usb/net/kaweth.c | |||
@@ -65,16 +65,6 @@ | |||
65 | 65 | ||
66 | #undef DEBUG | 66 | #undef DEBUG |
67 | 67 | ||
68 | #ifdef DEBUG | ||
69 | #define kaweth_dbg(format, arg...) printk(KERN_DEBUG __FILE__ ": " format "\n" ,##arg) | ||
70 | #else | ||
71 | #define kaweth_dbg(format, arg...) do {} while (0) | ||
72 | #endif | ||
73 | #define kaweth_err(format, arg...) printk(KERN_ERR __FILE__ ": " format "\n" ,##arg) | ||
74 | #define kaweth_info(format, arg...) printk(KERN_INFO __FILE__ ": " format "\n" , ##arg) | ||
75 | #define kaweth_warn(format, arg...) printk(KERN_WARNING __FILE__ ": " format "\n" , ##arg) | ||
76 | |||
77 | |||
78 | #include "kawethfw.h" | 68 | #include "kawethfw.h" |
79 | 69 | ||
80 | #define KAWETH_MTU 1514 | 70 | #define KAWETH_MTU 1514 |
@@ -86,6 +76,9 @@ | |||
86 | 76 | ||
87 | #define KAWETH_STATUS_BROKEN 0x0000001 | 77 | #define KAWETH_STATUS_BROKEN 0x0000001 |
88 | #define KAWETH_STATUS_CLOSING 0x0000002 | 78 | #define KAWETH_STATUS_CLOSING 0x0000002 |
79 | #define KAWETH_STATUS_SUSPENDING 0x0000004 | ||
80 | |||
81 | #define KAWETH_STATUS_BLOCKED (KAWETH_STATUS_CLOSING | KAWETH_STATUS_SUSPENDING) | ||
89 | 82 | ||
90 | #define KAWETH_PACKET_FILTER_PROMISCUOUS 0x01 | 83 | #define KAWETH_PACKET_FILTER_PROMISCUOUS 0x01 |
91 | #define KAWETH_PACKET_FILTER_ALL_MULTICAST 0x02 | 84 | #define KAWETH_PACKET_FILTER_ALL_MULTICAST 0x02 |
@@ -112,6 +105,8 @@ | |||
112 | #define STATE_MASK 0x40 | 105 | #define STATE_MASK 0x40 |
113 | #define STATE_SHIFT 5 | 106 | #define STATE_SHIFT 5 |
114 | 107 | ||
108 | #define IS_BLOCKED(s) (s & KAWETH_STATUS_BLOCKED) | ||
109 | |||
115 | 110 | ||
116 | MODULE_AUTHOR("Michael Zappe <zapman@interlan.net>, Stephane Alnet <stephane@u-picardie.fr>, Brad Hards <bhards@bigpond.net.au> and Oliver Neukum <oliver@neukum.org>"); | 111 | MODULE_AUTHOR("Michael Zappe <zapman@interlan.net>, Stephane Alnet <stephane@u-picardie.fr>, Brad Hards <bhards@bigpond.net.au> and Oliver Neukum <oliver@neukum.org>"); |
117 | MODULE_DESCRIPTION("KL5USB101 USB Ethernet driver"); | 112 | MODULE_DESCRIPTION("KL5USB101 USB Ethernet driver"); |
@@ -128,6 +123,8 @@ static int kaweth_internal_control_msg(struct usb_device *usb_dev, | |||
128 | unsigned int pipe, | 123 | unsigned int pipe, |
129 | struct usb_ctrlrequest *cmd, void *data, | 124 | struct usb_ctrlrequest *cmd, void *data, |
130 | int len, int timeout); | 125 | int len, int timeout); |
126 | static int kaweth_suspend(struct usb_interface *intf, pm_message_t message); | ||
127 | static int kaweth_resume(struct usb_interface *intf); | ||
131 | 128 | ||
132 | /**************************************************************** | 129 | /**************************************************************** |
133 | * usb_device_id | 130 | * usb_device_id |
@@ -179,6 +176,8 @@ static struct usb_driver kaweth_driver = { | |||
179 | .name = driver_name, | 176 | .name = driver_name, |
180 | .probe = kaweth_probe, | 177 | .probe = kaweth_probe, |
181 | .disconnect = kaweth_disconnect, | 178 | .disconnect = kaweth_disconnect, |
179 | .suspend = kaweth_suspend, | ||
180 | .resume = kaweth_resume, | ||
182 | .id_table = usb_klsi_table, | 181 | .id_table = usb_klsi_table, |
183 | }; | 182 | }; |
184 | 183 | ||
@@ -222,6 +221,7 @@ struct kaweth_device | |||
222 | int suspend_lowmem_rx; | 221 | int suspend_lowmem_rx; |
223 | int suspend_lowmem_ctrl; | 222 | int suspend_lowmem_ctrl; |
224 | int linkstate; | 223 | int linkstate; |
224 | int opened; | ||
225 | struct work_struct lowmem_work; | 225 | struct work_struct lowmem_work; |
226 | 226 | ||
227 | struct usb_device *dev; | 227 | struct usb_device *dev; |
@@ -265,17 +265,17 @@ static int kaweth_control(struct kaweth_device *kaweth, | |||
265 | { | 265 | { |
266 | struct usb_ctrlrequest *dr; | 266 | struct usb_ctrlrequest *dr; |
267 | 267 | ||
268 | kaweth_dbg("kaweth_control()"); | 268 | dbg("kaweth_control()"); |
269 | 269 | ||
270 | if(in_interrupt()) { | 270 | if(in_interrupt()) { |
271 | kaweth_dbg("in_interrupt()"); | 271 | dbg("in_interrupt()"); |
272 | return -EBUSY; | 272 | return -EBUSY; |
273 | } | 273 | } |
274 | 274 | ||
275 | dr = kmalloc(sizeof(struct usb_ctrlrequest), GFP_ATOMIC); | 275 | dr = kmalloc(sizeof(struct usb_ctrlrequest), GFP_ATOMIC); |
276 | 276 | ||
277 | if (!dr) { | 277 | if (!dr) { |
278 | kaweth_dbg("kmalloc() failed"); | 278 | dbg("kmalloc() failed"); |
279 | return -ENOMEM; | 279 | return -ENOMEM; |
280 | } | 280 | } |
281 | 281 | ||
@@ -300,7 +300,7 @@ static int kaweth_read_configuration(struct kaweth_device *kaweth) | |||
300 | { | 300 | { |
301 | int retval; | 301 | int retval; |
302 | 302 | ||
303 | kaweth_dbg("Reading kaweth configuration"); | 303 | dbg("Reading kaweth configuration"); |
304 | 304 | ||
305 | retval = kaweth_control(kaweth, | 305 | retval = kaweth_control(kaweth, |
306 | usb_rcvctrlpipe(kaweth->dev, 0), | 306 | usb_rcvctrlpipe(kaweth->dev, 0), |
@@ -322,7 +322,7 @@ static int kaweth_set_urb_size(struct kaweth_device *kaweth, __u16 urb_size) | |||
322 | { | 322 | { |
323 | int retval; | 323 | int retval; |
324 | 324 | ||
325 | kaweth_dbg("Setting URB size to %d", (unsigned)urb_size); | 325 | dbg("Setting URB size to %d", (unsigned)urb_size); |
326 | 326 | ||
327 | retval = kaweth_control(kaweth, | 327 | retval = kaweth_control(kaweth, |
328 | usb_sndctrlpipe(kaweth->dev, 0), | 328 | usb_sndctrlpipe(kaweth->dev, 0), |
@@ -344,7 +344,7 @@ static int kaweth_set_sofs_wait(struct kaweth_device *kaweth, __u16 sofs_wait) | |||
344 | { | 344 | { |
345 | int retval; | 345 | int retval; |
346 | 346 | ||
347 | kaweth_dbg("Set SOFS wait to %d", (unsigned)sofs_wait); | 347 | dbg("Set SOFS wait to %d", (unsigned)sofs_wait); |
348 | 348 | ||
349 | retval = kaweth_control(kaweth, | 349 | retval = kaweth_control(kaweth, |
350 | usb_sndctrlpipe(kaweth->dev, 0), | 350 | usb_sndctrlpipe(kaweth->dev, 0), |
@@ -367,7 +367,7 @@ static int kaweth_set_receive_filter(struct kaweth_device *kaweth, | |||
367 | { | 367 | { |
368 | int retval; | 368 | int retval; |
369 | 369 | ||
370 | kaweth_dbg("Set receive filter to %d", (unsigned)receive_filter); | 370 | dbg("Set receive filter to %d", (unsigned)receive_filter); |
371 | 371 | ||
372 | retval = kaweth_control(kaweth, | 372 | retval = kaweth_control(kaweth, |
373 | usb_sndctrlpipe(kaweth->dev, 0), | 373 | usb_sndctrlpipe(kaweth->dev, 0), |
@@ -392,7 +392,7 @@ static int kaweth_download_firmware(struct kaweth_device *kaweth, | |||
392 | __u8 type) | 392 | __u8 type) |
393 | { | 393 | { |
394 | if(data_len > KAWETH_FIRMWARE_BUF_SIZE) { | 394 | if(data_len > KAWETH_FIRMWARE_BUF_SIZE) { |
395 | kaweth_err("Firmware too big: %d", data_len); | 395 | err("Firmware too big: %d", data_len); |
396 | return -ENOSPC; | 396 | return -ENOSPC; |
397 | } | 397 | } |
398 | 398 | ||
@@ -403,13 +403,13 @@ static int kaweth_download_firmware(struct kaweth_device *kaweth, | |||
403 | kaweth->firmware_buf[4] = type; | 403 | kaweth->firmware_buf[4] = type; |
404 | kaweth->firmware_buf[5] = interrupt; | 404 | kaweth->firmware_buf[5] = interrupt; |
405 | 405 | ||
406 | kaweth_dbg("High: %i, Low:%i", kaweth->firmware_buf[3], | 406 | dbg("High: %i, Low:%i", kaweth->firmware_buf[3], |
407 | kaweth->firmware_buf[2]); | 407 | kaweth->firmware_buf[2]); |
408 | 408 | ||
409 | kaweth_dbg("Downloading firmware at %p to kaweth device at %p", | 409 | dbg("Downloading firmware at %p to kaweth device at %p", |
410 | data, | 410 | data, |
411 | kaweth); | 411 | kaweth); |
412 | kaweth_dbg("Firmware length: %d", data_len); | 412 | dbg("Firmware length: %d", data_len); |
413 | 413 | ||
414 | return kaweth_control(kaweth, | 414 | return kaweth_control(kaweth, |
415 | usb_sndctrlpipe(kaweth->dev, 0), | 415 | usb_sndctrlpipe(kaweth->dev, 0), |
@@ -437,7 +437,7 @@ static int kaweth_trigger_firmware(struct kaweth_device *kaweth, | |||
437 | kaweth->firmware_buf[6] = 0x00; | 437 | kaweth->firmware_buf[6] = 0x00; |
438 | kaweth->firmware_buf[7] = 0x00; | 438 | kaweth->firmware_buf[7] = 0x00; |
439 | 439 | ||
440 | kaweth_dbg("Triggering firmware"); | 440 | dbg("Triggering firmware"); |
441 | 441 | ||
442 | return kaweth_control(kaweth, | 442 | return kaweth_control(kaweth, |
443 | usb_sndctrlpipe(kaweth->dev, 0), | 443 | usb_sndctrlpipe(kaweth->dev, 0), |
@@ -457,7 +457,7 @@ static int kaweth_reset(struct kaweth_device *kaweth) | |||
457 | { | 457 | { |
458 | int result; | 458 | int result; |
459 | 459 | ||
460 | kaweth_dbg("kaweth_reset(%p)", kaweth); | 460 | dbg("kaweth_reset(%p)", kaweth); |
461 | result = kaweth_control(kaweth, | 461 | result = kaweth_control(kaweth, |
462 | usb_sndctrlpipe(kaweth->dev, 0), | 462 | usb_sndctrlpipe(kaweth->dev, 0), |
463 | USB_REQ_SET_CONFIGURATION, | 463 | USB_REQ_SET_CONFIGURATION, |
@@ -470,7 +470,7 @@ static int kaweth_reset(struct kaweth_device *kaweth) | |||
470 | 470 | ||
471 | mdelay(10); | 471 | mdelay(10); |
472 | 472 | ||
473 | kaweth_dbg("kaweth_reset() returns %d.",result); | 473 | dbg("kaweth_reset() returns %d.",result); |
474 | 474 | ||
475 | return result; | 475 | return result; |
476 | } | 476 | } |
@@ -534,7 +534,7 @@ static void kaweth_resubmit_tl(void *d) | |||
534 | { | 534 | { |
535 | struct kaweth_device *kaweth = (struct kaweth_device *)d; | 535 | struct kaweth_device *kaweth = (struct kaweth_device *)d; |
536 | 536 | ||
537 | if (kaweth->status | KAWETH_STATUS_CLOSING) | 537 | if (IS_BLOCKED(kaweth->status)) |
538 | return; | 538 | return; |
539 | 539 | ||
540 | if (kaweth->suspend_lowmem_rx) | 540 | if (kaweth->suspend_lowmem_rx) |
@@ -568,7 +568,7 @@ static int kaweth_resubmit_rx_urb(struct kaweth_device *kaweth, | |||
568 | kaweth->suspend_lowmem_rx = 1; | 568 | kaweth->suspend_lowmem_rx = 1; |
569 | schedule_delayed_work(&kaweth->lowmem_work, HZ/4); | 569 | schedule_delayed_work(&kaweth->lowmem_work, HZ/4); |
570 | } | 570 | } |
571 | kaweth_err("resubmitting rx_urb %d failed", result); | 571 | err("resubmitting rx_urb %d failed", result); |
572 | } else { | 572 | } else { |
573 | kaweth->suspend_lowmem_rx = 0; | 573 | kaweth->suspend_lowmem_rx = 0; |
574 | } | 574 | } |
@@ -601,11 +601,15 @@ static void kaweth_usb_receive(struct urb *urb) | |||
601 | return; | 601 | return; |
602 | } | 602 | } |
603 | 603 | ||
604 | if (kaweth->status & KAWETH_STATUS_CLOSING) | 604 | spin_lock(&kaweth->device_lock); |
605 | if (IS_BLOCKED(kaweth->status)) { | ||
606 | spin_unlock(&kaweth->device_lock); | ||
605 | return; | 607 | return; |
608 | } | ||
609 | spin_unlock(&kaweth->device_lock); | ||
606 | 610 | ||
607 | if(urb->status && urb->status != -EREMOTEIO && count != 1) { | 611 | if(urb->status && urb->status != -EREMOTEIO && count != 1) { |
608 | kaweth_err("%s RX status: %d count: %d packet_len: %d", | 612 | err("%s RX status: %d count: %d packet_len: %d", |
609 | net->name, | 613 | net->name, |
610 | urb->status, | 614 | urb->status, |
611 | count, | 615 | count, |
@@ -616,9 +620,9 @@ static void kaweth_usb_receive(struct urb *urb) | |||
616 | 620 | ||
617 | if(kaweth->net && (count > 2)) { | 621 | if(kaweth->net && (count > 2)) { |
618 | if(pkt_len > (count - 2)) { | 622 | if(pkt_len > (count - 2)) { |
619 | kaweth_err("Packet length too long for USB frame (pkt_len: %x, count: %x)",pkt_len, count); | 623 | err("Packet length too long for USB frame (pkt_len: %x, count: %x)",pkt_len, count); |
620 | kaweth_err("Packet len & 2047: %x", pkt_len & 2047); | 624 | err("Packet len & 2047: %x", pkt_len & 2047); |
621 | kaweth_err("Count 2: %x", count2); | 625 | err("Count 2: %x", count2); |
622 | kaweth_resubmit_rx_urb(kaweth, GFP_ATOMIC); | 626 | kaweth_resubmit_rx_urb(kaweth, GFP_ATOMIC); |
623 | return; | 627 | return; |
624 | } | 628 | } |
@@ -655,7 +659,7 @@ static int kaweth_open(struct net_device *net) | |||
655 | struct kaweth_device *kaweth = netdev_priv(net); | 659 | struct kaweth_device *kaweth = netdev_priv(net); |
656 | int res; | 660 | int res; |
657 | 661 | ||
658 | kaweth_dbg("Opening network device."); | 662 | dbg("Opening network device."); |
659 | 663 | ||
660 | res = kaweth_resubmit_rx_urb(kaweth, GFP_KERNEL); | 664 | res = kaweth_resubmit_rx_urb(kaweth, GFP_KERNEL); |
661 | if (res) | 665 | if (res) |
@@ -678,6 +682,7 @@ static int kaweth_open(struct net_device *net) | |||
678 | usb_kill_urb(kaweth->rx_urb); | 682 | usb_kill_urb(kaweth->rx_urb); |
679 | return -EIO; | 683 | return -EIO; |
680 | } | 684 | } |
685 | kaweth->opened = 1; | ||
681 | 686 | ||
682 | netif_start_queue(net); | 687 | netif_start_queue(net); |
683 | 688 | ||
@@ -688,14 +693,8 @@ static int kaweth_open(struct net_device *net) | |||
688 | /**************************************************************** | 693 | /**************************************************************** |
689 | * kaweth_close | 694 | * kaweth_close |
690 | ****************************************************************/ | 695 | ****************************************************************/ |
691 | static int kaweth_close(struct net_device *net) | 696 | static void kaweth_kill_urbs(struct kaweth_device *kaweth) |
692 | { | 697 | { |
693 | struct kaweth_device *kaweth = netdev_priv(net); | ||
694 | |||
695 | netif_stop_queue(net); | ||
696 | |||
697 | kaweth->status |= KAWETH_STATUS_CLOSING; | ||
698 | |||
699 | usb_kill_urb(kaweth->irq_urb); | 698 | usb_kill_urb(kaweth->irq_urb); |
700 | usb_kill_urb(kaweth->rx_urb); | 699 | usb_kill_urb(kaweth->rx_urb); |
701 | usb_kill_urb(kaweth->tx_urb); | 700 | usb_kill_urb(kaweth->tx_urb); |
@@ -706,6 +705,21 @@ static int kaweth_close(struct net_device *net) | |||
706 | we hit them again */ | 705 | we hit them again */ |
707 | usb_kill_urb(kaweth->irq_urb); | 706 | usb_kill_urb(kaweth->irq_urb); |
708 | usb_kill_urb(kaweth->rx_urb); | 707 | usb_kill_urb(kaweth->rx_urb); |
708 | } | ||
709 | |||
710 | /**************************************************************** | ||
711 | * kaweth_close | ||
712 | ****************************************************************/ | ||
713 | static int kaweth_close(struct net_device *net) | ||
714 | { | ||
715 | struct kaweth_device *kaweth = netdev_priv(net); | ||
716 | |||
717 | netif_stop_queue(net); | ||
718 | kaweth->opened = 0; | ||
719 | |||
720 | kaweth->status |= KAWETH_STATUS_CLOSING; | ||
721 | |||
722 | kaweth_kill_urbs(kaweth); | ||
709 | 723 | ||
710 | kaweth->status &= ~KAWETH_STATUS_CLOSING; | 724 | kaweth->status &= ~KAWETH_STATUS_CLOSING; |
711 | 725 | ||
@@ -732,7 +746,7 @@ static void kaweth_usb_transmit_complete(struct urb *urb) | |||
732 | 746 | ||
733 | if (unlikely(urb->status != 0)) | 747 | if (unlikely(urb->status != 0)) |
734 | if (urb->status != -ENOENT) | 748 | if (urb->status != -ENOENT) |
735 | kaweth_dbg("%s: TX status %d.", kaweth->net->name, urb->status); | 749 | dbg("%s: TX status %d.", kaweth->net->name, urb->status); |
736 | 750 | ||
737 | netif_wake_queue(kaweth->net); | 751 | netif_wake_queue(kaweth->net); |
738 | dev_kfree_skb_irq(skb); | 752 | dev_kfree_skb_irq(skb); |
@@ -752,6 +766,9 @@ static int kaweth_start_xmit(struct sk_buff *skb, struct net_device *net) | |||
752 | 766 | ||
753 | kaweth_async_set_rx_mode(kaweth); | 767 | kaweth_async_set_rx_mode(kaweth); |
754 | netif_stop_queue(net); | 768 | netif_stop_queue(net); |
769 | if (IS_BLOCKED(kaweth->status)) { | ||
770 | goto skip; | ||
771 | } | ||
755 | 772 | ||
756 | /* We now decide whether we can put our special header into the sk_buff */ | 773 | /* We now decide whether we can put our special header into the sk_buff */ |
757 | if (skb_cloned(skb) || skb_headroom(skb) < 2) { | 774 | if (skb_cloned(skb) || skb_headroom(skb) < 2) { |
@@ -783,7 +800,8 @@ static int kaweth_start_xmit(struct sk_buff *skb, struct net_device *net) | |||
783 | 800 | ||
784 | if((res = usb_submit_urb(kaweth->tx_urb, GFP_ATOMIC))) | 801 | if((res = usb_submit_urb(kaweth->tx_urb, GFP_ATOMIC))) |
785 | { | 802 | { |
786 | kaweth_warn("kaweth failed tx_urb %d", res); | 803 | warn("kaweth failed tx_urb %d", res); |
804 | skip: | ||
787 | kaweth->stats.tx_errors++; | 805 | kaweth->stats.tx_errors++; |
788 | 806 | ||
789 | netif_start_queue(net); | 807 | netif_start_queue(net); |
@@ -812,7 +830,7 @@ static void kaweth_set_rx_mode(struct net_device *net) | |||
812 | KAWETH_PACKET_FILTER_BROADCAST | | 830 | KAWETH_PACKET_FILTER_BROADCAST | |
813 | KAWETH_PACKET_FILTER_MULTICAST; | 831 | KAWETH_PACKET_FILTER_MULTICAST; |
814 | 832 | ||
815 | kaweth_dbg("Setting Rx mode to %d", packet_filter_bitmap); | 833 | dbg("Setting Rx mode to %d", packet_filter_bitmap); |
816 | 834 | ||
817 | netif_stop_queue(net); | 835 | netif_stop_queue(net); |
818 | 836 | ||
@@ -850,10 +868,10 @@ static void kaweth_async_set_rx_mode(struct kaweth_device *kaweth) | |||
850 | KAWETH_CONTROL_TIMEOUT); | 868 | KAWETH_CONTROL_TIMEOUT); |
851 | 869 | ||
852 | if(result < 0) { | 870 | if(result < 0) { |
853 | kaweth_err("Failed to set Rx mode: %d", result); | 871 | err("Failed to set Rx mode: %d", result); |
854 | } | 872 | } |
855 | else { | 873 | else { |
856 | kaweth_dbg("Set Rx mode to %d", packet_filter_bitmap); | 874 | dbg("Set Rx mode to %d", packet_filter_bitmap); |
857 | } | 875 | } |
858 | } | 876 | } |
859 | } | 877 | } |
@@ -874,7 +892,7 @@ static void kaweth_tx_timeout(struct net_device *net) | |||
874 | { | 892 | { |
875 | struct kaweth_device *kaweth = netdev_priv(net); | 893 | struct kaweth_device *kaweth = netdev_priv(net); |
876 | 894 | ||
877 | kaweth_warn("%s: Tx timed out. Resetting.", net->name); | 895 | warn("%s: Tx timed out. Resetting.", net->name); |
878 | kaweth->stats.tx_errors++; | 896 | kaweth->stats.tx_errors++; |
879 | net->trans_start = jiffies; | 897 | net->trans_start = jiffies; |
880 | 898 | ||
@@ -882,6 +900,42 @@ static void kaweth_tx_timeout(struct net_device *net) | |||
882 | } | 900 | } |
883 | 901 | ||
884 | /**************************************************************** | 902 | /**************************************************************** |
903 | * kaweth_suspend | ||
904 | ****************************************************************/ | ||
905 | static int kaweth_suspend(struct usb_interface *intf, pm_message_t message) | ||
906 | { | ||
907 | struct kaweth_device *kaweth = usb_get_intfdata(intf); | ||
908 | unsigned long flags; | ||
909 | |||
910 | spin_lock_irqsave(&kaweth->device_lock, flags); | ||
911 | kaweth->status |= KAWETH_STATUS_SUSPENDING; | ||
912 | spin_unlock_irqrestore(&kaweth->device_lock, flags); | ||
913 | |||
914 | kaweth_kill_urbs(kaweth); | ||
915 | return 0; | ||
916 | } | ||
917 | |||
918 | /**************************************************************** | ||
919 | * kaweth_resume | ||
920 | ****************************************************************/ | ||
921 | static int kaweth_resume(struct usb_interface *intf) | ||
922 | { | ||
923 | struct kaweth_device *kaweth = usb_get_intfdata(intf); | ||
924 | unsigned long flags; | ||
925 | |||
926 | spin_lock_irqsave(&kaweth->device_lock, flags); | ||
927 | kaweth->status &= ~KAWETH_STATUS_SUSPENDING; | ||
928 | spin_unlock_irqrestore(&kaweth->device_lock, flags); | ||
929 | |||
930 | if (!kaweth->opened) | ||
931 | return 0; | ||
932 | kaweth_resubmit_rx_urb(kaweth, GFP_NOIO); | ||
933 | kaweth_resubmit_int_urb(kaweth, GFP_NOIO); | ||
934 | |||
935 | return 0; | ||
936 | } | ||
937 | |||
938 | /**************************************************************** | ||
885 | * kaweth_probe | 939 | * kaweth_probe |
886 | ****************************************************************/ | 940 | ****************************************************************/ |
887 | static int kaweth_probe( | 941 | static int kaweth_probe( |
@@ -895,15 +949,15 @@ static int kaweth_probe( | |||
895 | const eth_addr_t bcast_addr = { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF }; | 949 | const eth_addr_t bcast_addr = { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF }; |
896 | int result = 0; | 950 | int result = 0; |
897 | 951 | ||
898 | kaweth_dbg("Kawasaki Device Probe (Device number:%d): 0x%4.4x:0x%4.4x:0x%4.4x", | 952 | dbg("Kawasaki Device Probe (Device number:%d): 0x%4.4x:0x%4.4x:0x%4.4x", |
899 | dev->devnum, | 953 | dev->devnum, |
900 | le16_to_cpu(dev->descriptor.idVendor), | 954 | le16_to_cpu(dev->descriptor.idVendor), |
901 | le16_to_cpu(dev->descriptor.idProduct), | 955 | le16_to_cpu(dev->descriptor.idProduct), |
902 | le16_to_cpu(dev->descriptor.bcdDevice)); | 956 | le16_to_cpu(dev->descriptor.bcdDevice)); |
903 | 957 | ||
904 | kaweth_dbg("Device at %p", dev); | 958 | dbg("Device at %p", dev); |
905 | 959 | ||
906 | kaweth_dbg("Descriptor length: %x type: %x", | 960 | dbg("Descriptor length: %x type: %x", |
907 | (int)dev->descriptor.bLength, | 961 | (int)dev->descriptor.bLength, |
908 | (int)dev->descriptor.bDescriptorType); | 962 | (int)dev->descriptor.bDescriptorType); |
909 | 963 | ||
@@ -918,7 +972,7 @@ static int kaweth_probe( | |||
918 | spin_lock_init(&kaweth->device_lock); | 972 | spin_lock_init(&kaweth->device_lock); |
919 | init_waitqueue_head(&kaweth->term_wait); | 973 | init_waitqueue_head(&kaweth->term_wait); |
920 | 974 | ||
921 | kaweth_dbg("Resetting."); | 975 | dbg("Resetting."); |
922 | 976 | ||
923 | kaweth_reset(kaweth); | 977 | kaweth_reset(kaweth); |
924 | 978 | ||
@@ -928,17 +982,17 @@ static int kaweth_probe( | |||
928 | */ | 982 | */ |
929 | 983 | ||
930 | if (le16_to_cpu(dev->descriptor.bcdDevice) >> 8) { | 984 | if (le16_to_cpu(dev->descriptor.bcdDevice) >> 8) { |
931 | kaweth_info("Firmware present in device."); | 985 | info("Firmware present in device."); |
932 | } else { | 986 | } else { |
933 | /* Download the firmware */ | 987 | /* Download the firmware */ |
934 | kaweth_info("Downloading firmware..."); | 988 | info("Downloading firmware..."); |
935 | kaweth->firmware_buf = (__u8 *)__get_free_page(GFP_KERNEL); | 989 | kaweth->firmware_buf = (__u8 *)__get_free_page(GFP_KERNEL); |
936 | if ((result = kaweth_download_firmware(kaweth, | 990 | if ((result = kaweth_download_firmware(kaweth, |
937 | kaweth_new_code, | 991 | kaweth_new_code, |
938 | len_kaweth_new_code, | 992 | len_kaweth_new_code, |
939 | 100, | 993 | 100, |
940 | 2)) < 0) { | 994 | 2)) < 0) { |
941 | kaweth_err("Error downloading firmware (%d)", result); | 995 | err("Error downloading firmware (%d)", result); |
942 | goto err_fw; | 996 | goto err_fw; |
943 | } | 997 | } |
944 | 998 | ||
@@ -947,7 +1001,7 @@ static int kaweth_probe( | |||
947 | len_kaweth_new_code_fix, | 1001 | len_kaweth_new_code_fix, |
948 | 100, | 1002 | 100, |
949 | 3)) < 0) { | 1003 | 3)) < 0) { |
950 | kaweth_err("Error downloading firmware fix (%d)", result); | 1004 | err("Error downloading firmware fix (%d)", result); |
951 | goto err_fw; | 1005 | goto err_fw; |
952 | } | 1006 | } |
953 | 1007 | ||
@@ -956,7 +1010,7 @@ static int kaweth_probe( | |||
956 | len_kaweth_trigger_code, | 1010 | len_kaweth_trigger_code, |
957 | 126, | 1011 | 126, |
958 | 2)) < 0) { | 1012 | 2)) < 0) { |
959 | kaweth_err("Error downloading trigger code (%d)", result); | 1013 | err("Error downloading trigger code (%d)", result); |
960 | goto err_fw; | 1014 | goto err_fw; |
961 | 1015 | ||
962 | } | 1016 | } |
@@ -966,18 +1020,18 @@ static int kaweth_probe( | |||
966 | len_kaweth_trigger_code_fix, | 1020 | len_kaweth_trigger_code_fix, |
967 | 126, | 1021 | 126, |
968 | 3)) < 0) { | 1022 | 3)) < 0) { |
969 | kaweth_err("Error downloading trigger code fix (%d)", result); | 1023 | err("Error downloading trigger code fix (%d)", result); |
970 | goto err_fw; | 1024 | goto err_fw; |
971 | } | 1025 | } |
972 | 1026 | ||
973 | 1027 | ||
974 | if ((result = kaweth_trigger_firmware(kaweth, 126)) < 0) { | 1028 | if ((result = kaweth_trigger_firmware(kaweth, 126)) < 0) { |
975 | kaweth_err("Error triggering firmware (%d)", result); | 1029 | err("Error triggering firmware (%d)", result); |
976 | goto err_fw; | 1030 | goto err_fw; |
977 | } | 1031 | } |
978 | 1032 | ||
979 | /* Device will now disappear for a moment... */ | 1033 | /* Device will now disappear for a moment... */ |
980 | kaweth_info("Firmware loaded. I'll be back..."); | 1034 | info("Firmware loaded. I'll be back..."); |
981 | err_fw: | 1035 | err_fw: |
982 | free_page((unsigned long)kaweth->firmware_buf); | 1036 | free_page((unsigned long)kaweth->firmware_buf); |
983 | free_netdev(netdev); | 1037 | free_netdev(netdev); |
@@ -987,14 +1041,14 @@ err_fw: | |||
987 | result = kaweth_read_configuration(kaweth); | 1041 | result = kaweth_read_configuration(kaweth); |
988 | 1042 | ||
989 | if(result < 0) { | 1043 | if(result < 0) { |
990 | kaweth_err("Error reading configuration (%d), no net device created", result); | 1044 | err("Error reading configuration (%d), no net device created", result); |
991 | goto err_free_netdev; | 1045 | goto err_free_netdev; |
992 | } | 1046 | } |
993 | 1047 | ||
994 | kaweth_info("Statistics collection: %x", kaweth->configuration.statistics_mask); | 1048 | info("Statistics collection: %x", kaweth->configuration.statistics_mask); |
995 | kaweth_info("Multicast filter limit: %x", kaweth->configuration.max_multicast_filters & ((1 << 15) - 1)); | 1049 | info("Multicast filter limit: %x", kaweth->configuration.max_multicast_filters & ((1 << 15) - 1)); |
996 | kaweth_info("MTU: %d", le16_to_cpu(kaweth->configuration.segment_size)); | 1050 | info("MTU: %d", le16_to_cpu(kaweth->configuration.segment_size)); |
997 | kaweth_info("Read MAC address %2.2x:%2.2x:%2.2x:%2.2x:%2.2x:%2.2x", | 1051 | info("Read MAC address %2.2x:%2.2x:%2.2x:%2.2x:%2.2x:%2.2x", |
998 | (int)kaweth->configuration.hw_addr[0], | 1052 | (int)kaweth->configuration.hw_addr[0], |
999 | (int)kaweth->configuration.hw_addr[1], | 1053 | (int)kaweth->configuration.hw_addr[1], |
1000 | (int)kaweth->configuration.hw_addr[2], | 1054 | (int)kaweth->configuration.hw_addr[2], |
@@ -1005,17 +1059,17 @@ err_fw: | |||
1005 | if(!memcmp(&kaweth->configuration.hw_addr, | 1059 | if(!memcmp(&kaweth->configuration.hw_addr, |
1006 | &bcast_addr, | 1060 | &bcast_addr, |
1007 | sizeof(bcast_addr))) { | 1061 | sizeof(bcast_addr))) { |
1008 | kaweth_err("Firmware not functioning properly, no net device created"); | 1062 | err("Firmware not functioning properly, no net device created"); |
1009 | goto err_free_netdev; | 1063 | goto err_free_netdev; |
1010 | } | 1064 | } |
1011 | 1065 | ||
1012 | if(kaweth_set_urb_size(kaweth, KAWETH_BUF_SIZE) < 0) { | 1066 | if(kaweth_set_urb_size(kaweth, KAWETH_BUF_SIZE) < 0) { |
1013 | kaweth_dbg("Error setting URB size"); | 1067 | dbg("Error setting URB size"); |
1014 | goto err_free_netdev; | 1068 | goto err_free_netdev; |
1015 | } | 1069 | } |
1016 | 1070 | ||
1017 | if(kaweth_set_sofs_wait(kaweth, KAWETH_SOFS_TO_WAIT) < 0) { | 1071 | if(kaweth_set_sofs_wait(kaweth, KAWETH_SOFS_TO_WAIT) < 0) { |
1018 | kaweth_err("Error setting SOFS wait"); | 1072 | err("Error setting SOFS wait"); |
1019 | goto err_free_netdev; | 1073 | goto err_free_netdev; |
1020 | } | 1074 | } |
1021 | 1075 | ||
@@ -1025,11 +1079,11 @@ err_fw: | |||
1025 | KAWETH_PACKET_FILTER_MULTICAST); | 1079 | KAWETH_PACKET_FILTER_MULTICAST); |
1026 | 1080 | ||
1027 | if(result < 0) { | 1081 | if(result < 0) { |
1028 | kaweth_err("Error setting receive filter"); | 1082 | err("Error setting receive filter"); |
1029 | goto err_free_netdev; | 1083 | goto err_free_netdev; |
1030 | } | 1084 | } |
1031 | 1085 | ||
1032 | kaweth_dbg("Initializing net device."); | 1086 | dbg("Initializing net device."); |
1033 | 1087 | ||
1034 | kaweth->tx_urb = usb_alloc_urb(0, GFP_KERNEL); | 1088 | kaweth->tx_urb = usb_alloc_urb(0, GFP_KERNEL); |
1035 | if (!kaweth->tx_urb) | 1089 | if (!kaweth->tx_urb) |
@@ -1086,13 +1140,13 @@ err_fw: | |||
1086 | 1140 | ||
1087 | SET_NETDEV_DEV(netdev, &intf->dev); | 1141 | SET_NETDEV_DEV(netdev, &intf->dev); |
1088 | if (register_netdev(netdev) != 0) { | 1142 | if (register_netdev(netdev) != 0) { |
1089 | kaweth_err("Error registering netdev."); | 1143 | err("Error registering netdev."); |
1090 | goto err_intfdata; | 1144 | goto err_intfdata; |
1091 | } | 1145 | } |
1092 | 1146 | ||
1093 | kaweth_info("kaweth interface created at %s", kaweth->net->name); | 1147 | info("kaweth interface created at %s", kaweth->net->name); |
1094 | 1148 | ||
1095 | kaweth_dbg("Kaweth probe returning."); | 1149 | dbg("Kaweth probe returning."); |
1096 | 1150 | ||
1097 | return 0; | 1151 | return 0; |
1098 | 1152 | ||
@@ -1121,16 +1175,16 @@ static void kaweth_disconnect(struct usb_interface *intf) | |||
1121 | struct kaweth_device *kaweth = usb_get_intfdata(intf); | 1175 | struct kaweth_device *kaweth = usb_get_intfdata(intf); |
1122 | struct net_device *netdev; | 1176 | struct net_device *netdev; |
1123 | 1177 | ||
1124 | kaweth_info("Unregistering"); | 1178 | info("Unregistering"); |
1125 | 1179 | ||
1126 | usb_set_intfdata(intf, NULL); | 1180 | usb_set_intfdata(intf, NULL); |
1127 | if (!kaweth) { | 1181 | if (!kaweth) { |
1128 | kaweth_warn("unregistering non-existant device"); | 1182 | warn("unregistering non-existant device"); |
1129 | return; | 1183 | return; |
1130 | } | 1184 | } |
1131 | netdev = kaweth->net; | 1185 | netdev = kaweth->net; |
1132 | 1186 | ||
1133 | kaweth_dbg("Unregistering net device"); | 1187 | dbg("Unregistering net device"); |
1134 | unregister_netdev(netdev); | 1188 | unregister_netdev(netdev); |
1135 | 1189 | ||
1136 | usb_free_urb(kaweth->rx_urb); | 1190 | usb_free_urb(kaweth->rx_urb); |
@@ -1185,7 +1239,7 @@ static int usb_start_wait_urb(struct urb *urb, int timeout, int* actual_length) | |||
1185 | 1239 | ||
1186 | if (!wait_event_timeout(awd.wqh, awd.done, timeout)) { | 1240 | if (!wait_event_timeout(awd.wqh, awd.done, timeout)) { |
1187 | // timeout | 1241 | // timeout |
1188 | kaweth_warn("usb_control/bulk_msg: timeout"); | 1242 | warn("usb_control/bulk_msg: timeout"); |
1189 | usb_kill_urb(urb); // remove urb safely | 1243 | usb_kill_urb(urb); // remove urb safely |
1190 | status = -ETIMEDOUT; | 1244 | status = -ETIMEDOUT; |
1191 | } | 1245 | } |
@@ -1234,7 +1288,7 @@ static int kaweth_internal_control_msg(struct usb_device *usb_dev, | |||
1234 | ****************************************************************/ | 1288 | ****************************************************************/ |
1235 | static int __init kaweth_init(void) | 1289 | static int __init kaweth_init(void) |
1236 | { | 1290 | { |
1237 | kaweth_dbg("Driver loading"); | 1291 | dbg("Driver loading"); |
1238 | return usb_register(&kaweth_driver); | 1292 | return usb_register(&kaweth_driver); |
1239 | } | 1293 | } |
1240 | 1294 | ||
diff --git a/drivers/usb/net/mcs7830.c b/drivers/usb/net/mcs7830.c new file mode 100644 index 000000000000..6240b978fe3d --- /dev/null +++ b/drivers/usb/net/mcs7830.c | |||
@@ -0,0 +1,534 @@ | |||
1 | /* | ||
2 | * MosChips MCS7830 based USB 2.0 Ethernet Devices | ||
3 | * | ||
4 | * based on usbnet.c, asix.c and the vendor provided mcs7830 driver | ||
5 | * | ||
6 | * Copyright (C) 2006 Arnd Bergmann <arnd@arndb.de> | ||
7 | * Copyright (C) 2003-2005 David Hollis <dhollis@davehollis.com> | ||
8 | * Copyright (C) 2005 Phil Chang <pchang23@sbcglobal.net> | ||
9 | * Copyright (c) 2002-2003 TiVo Inc. | ||
10 | * | ||
11 | * This program is free software; you can redistribute it and/or modify | ||
12 | * it under the terms of the GNU General Public License as published by | ||
13 | * the Free Software Foundation; either version 2 of the License, or | ||
14 | * (at your option) any later version. | ||
15 | * | ||
16 | * This program is distributed in the hope that it will be useful, | ||
17 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
18 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
19 | * GNU General Public License for more details. | ||
20 | * | ||
21 | * You should have received a copy of the GNU General Public License | ||
22 | * along with this program; if not, write to the Free Software | ||
23 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | ||
24 | */ | ||
25 | |||
26 | #include <linux/crc32.h> | ||
27 | #include <linux/etherdevice.h> | ||
28 | #include <linux/ethtool.h> | ||
29 | #include <linux/init.h> | ||
30 | #include <linux/mii.h> | ||
31 | #include <linux/module.h> | ||
32 | #include <linux/netdevice.h> | ||
33 | #include <linux/usb.h> | ||
34 | |||
35 | #include "usbnet.h" | ||
36 | |||
37 | /* requests */ | ||
38 | #define MCS7830_RD_BMREQ (USB_DIR_IN | USB_TYPE_VENDOR | \ | ||
39 | USB_RECIP_DEVICE) | ||
40 | #define MCS7830_WR_BMREQ (USB_DIR_OUT | USB_TYPE_VENDOR | \ | ||
41 | USB_RECIP_DEVICE) | ||
42 | #define MCS7830_RD_BREQ 0x0E | ||
43 | #define MCS7830_WR_BREQ 0x0D | ||
44 | |||
45 | #define MCS7830_CTRL_TIMEOUT 1000 | ||
46 | #define MCS7830_MAX_MCAST 64 | ||
47 | |||
48 | #define MCS7830_VENDOR_ID 0x9710 | ||
49 | #define MCS7830_PRODUCT_ID 0x7830 | ||
50 | |||
51 | #define MCS7830_MII_ADVERTISE (ADVERTISE_PAUSE_CAP | ADVERTISE_100FULL | \ | ||
52 | ADVERTISE_100HALF | ADVERTISE_10FULL | \ | ||
53 | ADVERTISE_10HALF | ADVERTISE_CSMA) | ||
54 | |||
55 | /* HIF_REG_XX coressponding index value */ | ||
56 | enum { | ||
57 | HIF_REG_MULTICAST_HASH = 0x00, | ||
58 | HIF_REG_PACKET_GAP1 = 0x08, | ||
59 | HIF_REG_PACKET_GAP2 = 0x09, | ||
60 | HIF_REG_PHY_DATA = 0x0a, | ||
61 | HIF_REG_PHY_CMD1 = 0x0c, | ||
62 | HIF_REG_PHY_CMD1_READ = 0x40, | ||
63 | HIF_REG_PHY_CMD1_WRITE = 0x20, | ||
64 | HIF_REG_PHY_CMD1_PHYADDR = 0x01, | ||
65 | HIF_REG_PHY_CMD2 = 0x0d, | ||
66 | HIF_REG_PHY_CMD2_PEND_FLAG_BIT = 0x80, | ||
67 | HIF_REG_PHY_CMD2_READY_FLAG_BIT = 0x40, | ||
68 | HIF_REG_CONFIG = 0x0e, | ||
69 | HIF_REG_CONFIG_CFG = 0x80, | ||
70 | HIF_REG_CONFIG_SPEED100 = 0x40, | ||
71 | HIF_REG_CONFIG_FULLDUPLEX_ENABLE = 0x20, | ||
72 | HIF_REG_CONFIG_RXENABLE = 0x10, | ||
73 | HIF_REG_CONFIG_TXENABLE = 0x08, | ||
74 | HIF_REG_CONFIG_SLEEPMODE = 0x04, | ||
75 | HIF_REG_CONFIG_ALLMULTICAST = 0x02, | ||
76 | HIF_REG_CONFIG_PROMISCIOUS = 0x01, | ||
77 | HIF_REG_ETHERNET_ADDR = 0x0f, | ||
78 | HIF_REG_22 = 0x15, | ||
79 | HIF_REG_PAUSE_THRESHOLD = 0x16, | ||
80 | HIF_REG_PAUSE_THRESHOLD_DEFAULT = 0, | ||
81 | }; | ||
82 | |||
83 | struct mcs7830_data { | ||
84 | u8 multi_filter[8]; | ||
85 | u8 config; | ||
86 | }; | ||
87 | |||
88 | static const char driver_name[] = "MOSCHIP usb-ethernet driver"; | ||
89 | |||
90 | static int mcs7830_get_reg(struct usbnet *dev, u16 index, u16 size, void *data) | ||
91 | { | ||
92 | struct usb_device *xdev = dev->udev; | ||
93 | int ret; | ||
94 | |||
95 | ret = usb_control_msg(xdev, usb_rcvctrlpipe(xdev, 0), MCS7830_RD_BREQ, | ||
96 | MCS7830_RD_BMREQ, 0x0000, index, data, | ||
97 | size, msecs_to_jiffies(MCS7830_CTRL_TIMEOUT)); | ||
98 | return ret; | ||
99 | } | ||
100 | |||
101 | static int mcs7830_set_reg(struct usbnet *dev, u16 index, u16 size, void *data) | ||
102 | { | ||
103 | struct usb_device *xdev = dev->udev; | ||
104 | int ret; | ||
105 | |||
106 | ret = usb_control_msg(xdev, usb_sndctrlpipe(xdev, 0), MCS7830_WR_BREQ, | ||
107 | MCS7830_WR_BMREQ, 0x0000, index, data, | ||
108 | size, msecs_to_jiffies(MCS7830_CTRL_TIMEOUT)); | ||
109 | return ret; | ||
110 | } | ||
111 | |||
112 | static void mcs7830_async_cmd_callback(struct urb *urb) | ||
113 | { | ||
114 | struct usb_ctrlrequest *req = (struct usb_ctrlrequest *)urb->context; | ||
115 | |||
116 | if (urb->status < 0) | ||
117 | printk(KERN_DEBUG "mcs7830_async_cmd_callback() failed with %d", | ||
118 | urb->status); | ||
119 | |||
120 | kfree(req); | ||
121 | usb_free_urb(urb); | ||
122 | } | ||
123 | |||
124 | static void mcs7830_set_reg_async(struct usbnet *dev, u16 index, u16 size, void *data) | ||
125 | { | ||
126 | struct usb_ctrlrequest *req; | ||
127 | int ret; | ||
128 | struct urb *urb; | ||
129 | |||
130 | urb = usb_alloc_urb(0, GFP_ATOMIC); | ||
131 | if (!urb) { | ||
132 | dev_dbg(&dev->udev->dev, "Error allocating URB " | ||
133 | "in write_cmd_async!"); | ||
134 | return; | ||
135 | } | ||
136 | |||
137 | req = kmalloc(sizeof *req, GFP_ATOMIC); | ||
138 | if (!req) { | ||
139 | dev_err(&dev->udev->dev, "Failed to allocate memory for " | ||
140 | "control request"); | ||
141 | goto out; | ||
142 | } | ||
143 | req->bRequestType = MCS7830_WR_BMREQ; | ||
144 | req->bRequest = MCS7830_WR_BREQ; | ||
145 | req->wValue = 0; | ||
146 | req->wIndex = cpu_to_le16(index); | ||
147 | req->wLength = cpu_to_le16(size); | ||
148 | |||
149 | usb_fill_control_urb(urb, dev->udev, | ||
150 | usb_sndctrlpipe(dev->udev, 0), | ||
151 | (void *)req, data, size, | ||
152 | mcs7830_async_cmd_callback, req); | ||
153 | |||
154 | ret = usb_submit_urb(urb, GFP_ATOMIC); | ||
155 | if (ret < 0) { | ||
156 | dev_err(&dev->udev->dev, "Error submitting the control " | ||
157 | "message: ret=%d", ret); | ||
158 | goto out; | ||
159 | } | ||
160 | return; | ||
161 | out: | ||
162 | kfree(req); | ||
163 | usb_free_urb(urb); | ||
164 | } | ||
165 | |||
166 | static int mcs7830_get_address(struct usbnet *dev) | ||
167 | { | ||
168 | int ret; | ||
169 | ret = mcs7830_get_reg(dev, HIF_REG_ETHERNET_ADDR, ETH_ALEN, | ||
170 | dev->net->dev_addr); | ||
171 | if (ret < 0) | ||
172 | return ret; | ||
173 | return 0; | ||
174 | } | ||
175 | |||
176 | static int mcs7830_read_phy(struct usbnet *dev, u8 index) | ||
177 | { | ||
178 | int ret; | ||
179 | int i; | ||
180 | __le16 val; | ||
181 | |||
182 | u8 cmd[2] = { | ||
183 | HIF_REG_PHY_CMD1_READ | HIF_REG_PHY_CMD1_PHYADDR, | ||
184 | HIF_REG_PHY_CMD2_PEND_FLAG_BIT | index, | ||
185 | }; | ||
186 | |||
187 | mutex_lock(&dev->phy_mutex); | ||
188 | /* write the MII command */ | ||
189 | ret = mcs7830_set_reg(dev, HIF_REG_PHY_CMD1, 2, cmd); | ||
190 | if (ret < 0) | ||
191 | goto out; | ||
192 | |||
193 | /* wait for the data to become valid, should be within < 1ms */ | ||
194 | for (i = 0; i < 10; i++) { | ||
195 | ret = mcs7830_get_reg(dev, HIF_REG_PHY_CMD1, 2, cmd); | ||
196 | if ((ret < 0) || (cmd[1] & HIF_REG_PHY_CMD2_READY_FLAG_BIT)) | ||
197 | break; | ||
198 | ret = -EIO; | ||
199 | msleep(1); | ||
200 | } | ||
201 | if (ret < 0) | ||
202 | goto out; | ||
203 | |||
204 | /* read actual register contents */ | ||
205 | ret = mcs7830_get_reg(dev, HIF_REG_PHY_DATA, 2, &val); | ||
206 | if (ret < 0) | ||
207 | goto out; | ||
208 | ret = le16_to_cpu(val); | ||
209 | dev_dbg(&dev->udev->dev, "read PHY reg %02x: %04x (%d tries)\n", | ||
210 | index, val, i); | ||
211 | out: | ||
212 | mutex_unlock(&dev->phy_mutex); | ||
213 | return ret; | ||
214 | } | ||
215 | |||
216 | static int mcs7830_write_phy(struct usbnet *dev, u8 index, u16 val) | ||
217 | { | ||
218 | int ret; | ||
219 | int i; | ||
220 | __le16 le_val; | ||
221 | |||
222 | u8 cmd[2] = { | ||
223 | HIF_REG_PHY_CMD1_WRITE | HIF_REG_PHY_CMD1_PHYADDR, | ||
224 | HIF_REG_PHY_CMD2_PEND_FLAG_BIT | (index & 0x1F), | ||
225 | }; | ||
226 | |||
227 | mutex_lock(&dev->phy_mutex); | ||
228 | |||
229 | /* write the new register contents */ | ||
230 | le_val = cpu_to_le16(val); | ||
231 | ret = mcs7830_set_reg(dev, HIF_REG_PHY_DATA, 2, &le_val); | ||
232 | if (ret < 0) | ||
233 | goto out; | ||
234 | |||
235 | /* write the MII command */ | ||
236 | ret = mcs7830_set_reg(dev, HIF_REG_PHY_CMD1, 2, cmd); | ||
237 | if (ret < 0) | ||
238 | goto out; | ||
239 | |||
240 | /* wait for the command to be accepted by the PHY */ | ||
241 | for (i = 0; i < 10; i++) { | ||
242 | ret = mcs7830_get_reg(dev, HIF_REG_PHY_CMD1, 2, cmd); | ||
243 | if ((ret < 0) || (cmd[1] & HIF_REG_PHY_CMD2_READY_FLAG_BIT)) | ||
244 | break; | ||
245 | ret = -EIO; | ||
246 | msleep(1); | ||
247 | } | ||
248 | if (ret < 0) | ||
249 | goto out; | ||
250 | |||
251 | ret = 0; | ||
252 | dev_dbg(&dev->udev->dev, "write PHY reg %02x: %04x (%d tries)\n", | ||
253 | index, val, i); | ||
254 | out: | ||
255 | mutex_unlock(&dev->phy_mutex); | ||
256 | return ret; | ||
257 | } | ||
258 | |||
259 | /* | ||
260 | * This algorithm comes from the original mcs7830 version 1.4 driver, | ||
261 | * not sure if it is needed. | ||
262 | */ | ||
263 | static int mcs7830_set_autoneg(struct usbnet *dev, int ptrUserPhyMode) | ||
264 | { | ||
265 | int ret; | ||
266 | /* Enable all media types */ | ||
267 | ret = mcs7830_write_phy(dev, MII_ADVERTISE, MCS7830_MII_ADVERTISE); | ||
268 | |||
269 | /* First reset BMCR */ | ||
270 | if (!ret) | ||
271 | ret = mcs7830_write_phy(dev, MII_BMCR, 0x0000); | ||
272 | /* Enable Auto Neg */ | ||
273 | if (!ret) | ||
274 | ret = mcs7830_write_phy(dev, MII_BMCR, BMCR_ANENABLE); | ||
275 | /* Restart Auto Neg (Keep the Enable Auto Neg Bit Set) */ | ||
276 | if (!ret) | ||
277 | ret = mcs7830_write_phy(dev, MII_BMCR, | ||
278 | BMCR_ANENABLE | BMCR_ANRESTART ); | ||
279 | return ret < 0 ? : 0; | ||
280 | } | ||
281 | |||
282 | |||
283 | /* | ||
284 | * if we can read register 22, the chip revision is C or higher | ||
285 | */ | ||
286 | static int mcs7830_get_rev(struct usbnet *dev) | ||
287 | { | ||
288 | u8 dummy[2]; | ||
289 | int ret; | ||
290 | ret = mcs7830_get_reg(dev, HIF_REG_22, 2, dummy); | ||
291 | if (ret > 0) | ||
292 | return 2; /* Rev C or later */ | ||
293 | return 1; /* earlier revision */ | ||
294 | } | ||
295 | |||
296 | /* | ||
297 | * On rev. C we need to set the pause threshold | ||
298 | */ | ||
299 | static void mcs7830_rev_C_fixup(struct usbnet *dev) | ||
300 | { | ||
301 | u8 pause_threshold = HIF_REG_PAUSE_THRESHOLD_DEFAULT; | ||
302 | int retry; | ||
303 | |||
304 | for (retry = 0; retry < 2; retry++) { | ||
305 | if (mcs7830_get_rev(dev) == 2) { | ||
306 | dev_info(&dev->udev->dev, "applying rev.C fixup\n"); | ||
307 | mcs7830_set_reg(dev, HIF_REG_PAUSE_THRESHOLD, | ||
308 | 1, &pause_threshold); | ||
309 | } | ||
310 | msleep(1); | ||
311 | } | ||
312 | } | ||
313 | |||
314 | static int mcs7830_init_dev(struct usbnet *dev) | ||
315 | { | ||
316 | int ret; | ||
317 | int retry; | ||
318 | |||
319 | /* Read MAC address from EEPROM */ | ||
320 | ret = -EINVAL; | ||
321 | for (retry = 0; retry < 5 && ret; retry++) | ||
322 | ret = mcs7830_get_address(dev); | ||
323 | if (ret) { | ||
324 | dev_warn(&dev->udev->dev, "Cannot read MAC address\n"); | ||
325 | goto out; | ||
326 | } | ||
327 | |||
328 | /* Set up PHY */ | ||
329 | ret = mcs7830_set_autoneg(dev, 0); | ||
330 | if (ret) { | ||
331 | dev_info(&dev->udev->dev, "Cannot set autoneg\n"); | ||
332 | goto out; | ||
333 | } | ||
334 | |||
335 | mcs7830_rev_C_fixup(dev); | ||
336 | ret = 0; | ||
337 | out: | ||
338 | return ret; | ||
339 | } | ||
340 | |||
341 | static int mcs7830_mdio_read(struct net_device *netdev, int phy_id, | ||
342 | int location) | ||
343 | { | ||
344 | struct usbnet *dev = netdev->priv; | ||
345 | return mcs7830_read_phy(dev, location); | ||
346 | } | ||
347 | |||
348 | static void mcs7830_mdio_write(struct net_device *netdev, int phy_id, | ||
349 | int location, int val) | ||
350 | { | ||
351 | struct usbnet *dev = netdev->priv; | ||
352 | mcs7830_write_phy(dev, location, val); | ||
353 | } | ||
354 | |||
355 | static int mcs7830_ioctl(struct net_device *net, struct ifreq *rq, int cmd) | ||
356 | { | ||
357 | struct usbnet *dev = netdev_priv(net); | ||
358 | return generic_mii_ioctl(&dev->mii, if_mii(rq), cmd, NULL); | ||
359 | } | ||
360 | |||
361 | /* credits go to asix_set_multicast */ | ||
362 | static void mcs7830_set_multicast(struct net_device *net) | ||
363 | { | ||
364 | struct usbnet *dev = netdev_priv(net); | ||
365 | struct mcs7830_data *data = (struct mcs7830_data *)&dev->data; | ||
366 | |||
367 | data->config = HIF_REG_CONFIG_TXENABLE; | ||
368 | |||
369 | /* this should not be needed, but it doesn't work otherwise */ | ||
370 | data->config |= HIF_REG_CONFIG_ALLMULTICAST; | ||
371 | |||
372 | if (net->flags & IFF_PROMISC) { | ||
373 | data->config |= HIF_REG_CONFIG_PROMISCIOUS; | ||
374 | } else if (net->flags & IFF_ALLMULTI | ||
375 | || net->mc_count > MCS7830_MAX_MCAST) { | ||
376 | data->config |= HIF_REG_CONFIG_ALLMULTICAST; | ||
377 | } else if (net->mc_count == 0) { | ||
378 | /* just broadcast and directed */ | ||
379 | } else { | ||
380 | /* We use the 20 byte dev->data | ||
381 | * for our 8 byte filter buffer | ||
382 | * to avoid allocating memory that | ||
383 | * is tricky to free later */ | ||
384 | struct dev_mc_list *mc_list = net->mc_list; | ||
385 | u32 crc_bits; | ||
386 | int i; | ||
387 | |||
388 | memset(data->multi_filter, 0, sizeof data->multi_filter); | ||
389 | |||
390 | /* Build the multicast hash filter. */ | ||
391 | for (i = 0; i < net->mc_count; i++) { | ||
392 | crc_bits = ether_crc(ETH_ALEN, mc_list->dmi_addr) >> 26; | ||
393 | data->multi_filter[crc_bits >> 3] |= 1 << (crc_bits & 7); | ||
394 | mc_list = mc_list->next; | ||
395 | } | ||
396 | |||
397 | mcs7830_set_reg_async(dev, HIF_REG_MULTICAST_HASH, | ||
398 | sizeof data->multi_filter, | ||
399 | data->multi_filter); | ||
400 | } | ||
401 | |||
402 | mcs7830_set_reg_async(dev, HIF_REG_CONFIG, 1, &data->config); | ||
403 | } | ||
404 | |||
405 | static int mcs7830_get_regs_len(struct net_device *net) | ||
406 | { | ||
407 | struct usbnet *dev = netdev_priv(net); | ||
408 | |||
409 | switch (mcs7830_get_rev(dev)) { | ||
410 | case 1: | ||
411 | return 21; | ||
412 | case 2: | ||
413 | return 32; | ||
414 | } | ||
415 | return 0; | ||
416 | } | ||
417 | |||
418 | static void mcs7830_get_drvinfo(struct net_device *net, struct ethtool_drvinfo *drvinfo) | ||
419 | { | ||
420 | usbnet_get_drvinfo(net, drvinfo); | ||
421 | drvinfo->regdump_len = mcs7830_get_regs_len(net); | ||
422 | } | ||
423 | |||
424 | static void mcs7830_get_regs(struct net_device *net, struct ethtool_regs *regs, void *data) | ||
425 | { | ||
426 | struct usbnet *dev = netdev_priv(net); | ||
427 | |||
428 | regs->version = mcs7830_get_rev(dev); | ||
429 | mcs7830_get_reg(dev, 0, regs->len, data); | ||
430 | } | ||
431 | |||
432 | static struct ethtool_ops mcs7830_ethtool_ops = { | ||
433 | .get_drvinfo = mcs7830_get_drvinfo, | ||
434 | .get_regs_len = mcs7830_get_regs_len, | ||
435 | .get_regs = mcs7830_get_regs, | ||
436 | |||
437 | /* common usbnet calls */ | ||
438 | .get_link = usbnet_get_link, | ||
439 | .get_msglevel = usbnet_get_msglevel, | ||
440 | .set_msglevel = usbnet_set_msglevel, | ||
441 | .get_settings = usbnet_get_settings, | ||
442 | .set_settings = usbnet_set_settings, | ||
443 | .nway_reset = usbnet_nway_reset, | ||
444 | }; | ||
445 | |||
446 | static int mcs7830_bind(struct usbnet *dev, struct usb_interface *udev) | ||
447 | { | ||
448 | struct net_device *net = dev->net; | ||
449 | int ret; | ||
450 | |||
451 | ret = mcs7830_init_dev(dev); | ||
452 | if (ret) | ||
453 | goto out; | ||
454 | |||
455 | net->do_ioctl = mcs7830_ioctl; | ||
456 | net->ethtool_ops = &mcs7830_ethtool_ops; | ||
457 | net->set_multicast_list = mcs7830_set_multicast; | ||
458 | mcs7830_set_multicast(net); | ||
459 | |||
460 | /* reserve space for the status byte on rx */ | ||
461 | dev->rx_urb_size = ETH_FRAME_LEN + 1; | ||
462 | |||
463 | dev->mii.mdio_read = mcs7830_mdio_read; | ||
464 | dev->mii.mdio_write = mcs7830_mdio_write; | ||
465 | dev->mii.dev = net; | ||
466 | dev->mii.phy_id_mask = 0x3f; | ||
467 | dev->mii.reg_num_mask = 0x1f; | ||
468 | dev->mii.phy_id = *((u8 *) net->dev_addr + 1); | ||
469 | |||
470 | ret = usbnet_get_endpoints(dev, udev); | ||
471 | out: | ||
472 | return ret; | ||
473 | } | ||
474 | |||
475 | /* The chip always appends a status bytes that we need to strip */ | ||
476 | static int mcs7830_rx_fixup(struct usbnet *dev, struct sk_buff *skb) | ||
477 | { | ||
478 | u8 status; | ||
479 | |||
480 | if (skb->len == 0) { | ||
481 | dev_err(&dev->udev->dev, "unexpected empty rx frame\n"); | ||
482 | return 0; | ||
483 | } | ||
484 | |||
485 | skb_trim(skb, skb->len - 1); | ||
486 | status = skb->data[skb->len]; | ||
487 | |||
488 | if (status != 0x20) | ||
489 | dev_dbg(&dev->udev->dev, "rx fixup status %x\n", status); | ||
490 | |||
491 | return skb->len > 0; | ||
492 | } | ||
493 | |||
494 | static const struct driver_info moschip_info = { | ||
495 | .description = "MOSCHIP 7830 usb-NET adapter", | ||
496 | .bind = mcs7830_bind, | ||
497 | .rx_fixup = mcs7830_rx_fixup, | ||
498 | .flags = FLAG_ETHER, | ||
499 | .in = 1, | ||
500 | .out = 2, | ||
501 | }; | ||
502 | |||
503 | static const struct usb_device_id products[] = { | ||
504 | { | ||
505 | USB_DEVICE(MCS7830_VENDOR_ID, MCS7830_PRODUCT_ID), | ||
506 | .driver_info = (unsigned long) &moschip_info, | ||
507 | }, | ||
508 | {}, | ||
509 | }; | ||
510 | MODULE_DEVICE_TABLE(usb, products); | ||
511 | |||
512 | static struct usb_driver mcs7830_driver = { | ||
513 | .name = driver_name, | ||
514 | .id_table = products, | ||
515 | .probe = usbnet_probe, | ||
516 | .disconnect = usbnet_disconnect, | ||
517 | .suspend = usbnet_suspend, | ||
518 | .resume = usbnet_resume, | ||
519 | }; | ||
520 | |||
521 | static int __init mcs7830_init(void) | ||
522 | { | ||
523 | return usb_register(&mcs7830_driver); | ||
524 | } | ||
525 | module_init(mcs7830_init); | ||
526 | |||
527 | static void __exit mcs7830_exit(void) | ||
528 | { | ||
529 | usb_deregister(&mcs7830_driver); | ||
530 | } | ||
531 | module_exit(mcs7830_exit); | ||
532 | |||
533 | MODULE_DESCRIPTION("USB to network adapter MCS7830)"); | ||
534 | MODULE_LICENSE("GPL"); | ||
diff --git a/drivers/usb/net/net1080.c b/drivers/usb/net/net1080.c index ce00de8f13a1..a77410562e12 100644 --- a/drivers/usb/net/net1080.c +++ b/drivers/usb/net/net1080.c | |||
@@ -237,12 +237,12 @@ static inline void nc_dump_usbctl(struct usbnet *dev, u16 usbctl) | |||
237 | #define STATUS_CONN_OTHER (1 << 14) | 237 | #define STATUS_CONN_OTHER (1 << 14) |
238 | #define STATUS_SUSPEND_OTHER (1 << 13) | 238 | #define STATUS_SUSPEND_OTHER (1 << 13) |
239 | #define STATUS_MAILBOX_OTHER (1 << 12) | 239 | #define STATUS_MAILBOX_OTHER (1 << 12) |
240 | #define STATUS_PACKETS_OTHER(n) (((n) >> 8) && 0x03) | 240 | #define STATUS_PACKETS_OTHER(n) (((n) >> 8) & 0x03) |
241 | 241 | ||
242 | #define STATUS_CONN_THIS (1 << 6) | 242 | #define STATUS_CONN_THIS (1 << 6) |
243 | #define STATUS_SUSPEND_THIS (1 << 5) | 243 | #define STATUS_SUSPEND_THIS (1 << 5) |
244 | #define STATUS_MAILBOX_THIS (1 << 4) | 244 | #define STATUS_MAILBOX_THIS (1 << 4) |
245 | #define STATUS_PACKETS_THIS(n) (((n) >> 0) && 0x03) | 245 | #define STATUS_PACKETS_THIS(n) (((n) >> 0) & 0x03) |
246 | 246 | ||
247 | #define STATUS_UNSPEC_MASK 0x0c8c | 247 | #define STATUS_UNSPEC_MASK 0x0c8c |
248 | #define STATUS_NOISE_MASK ((u16)~(0x0303|STATUS_UNSPEC_MASK)) | 248 | #define STATUS_NOISE_MASK ((u16)~(0x0303|STATUS_UNSPEC_MASK)) |
diff --git a/drivers/usb/net/pegasus.c b/drivers/usb/net/pegasus.c index 33abbd2176b6..69eb0db399df 100644 --- a/drivers/usb/net/pegasus.c +++ b/drivers/usb/net/pegasus.c | |||
@@ -163,6 +163,7 @@ static int get_registers(pegasus_t * pegasus, __u16 indx, __u16 size, | |||
163 | 163 | ||
164 | /* using ATOMIC, we'd never wake up if we slept */ | 164 | /* using ATOMIC, we'd never wake up if we slept */ |
165 | if ((ret = usb_submit_urb(pegasus->ctrl_urb, GFP_ATOMIC))) { | 165 | if ((ret = usb_submit_urb(pegasus->ctrl_urb, GFP_ATOMIC))) { |
166 | set_current_state(TASK_RUNNING); | ||
166 | if (ret == -ENODEV) | 167 | if (ret == -ENODEV) |
167 | netif_device_detach(pegasus->net); | 168 | netif_device_detach(pegasus->net); |
168 | if (netif_msg_drv(pegasus)) | 169 | if (netif_msg_drv(pegasus)) |
diff --git a/drivers/usb/net/usbnet.c b/drivers/usb/net/usbnet.c index 24bd3486ee63..7672e11c94c4 100644 --- a/drivers/usb/net/usbnet.c +++ b/drivers/usb/net/usbnet.c | |||
@@ -116,7 +116,7 @@ int usbnet_get_endpoints(struct usbnet *dev, struct usb_interface *intf) | |||
116 | e = alt->endpoint + ep; | 116 | e = alt->endpoint + ep; |
117 | switch (e->desc.bmAttributes) { | 117 | switch (e->desc.bmAttributes) { |
118 | case USB_ENDPOINT_XFER_INT: | 118 | case USB_ENDPOINT_XFER_INT: |
119 | if (!(e->desc.bEndpointAddress & USB_DIR_IN)) | 119 | if (!usb_endpoint_dir_in(&e->desc)) |
120 | continue; | 120 | continue; |
121 | intr = 1; | 121 | intr = 1; |
122 | /* FALLTHROUGH */ | 122 | /* FALLTHROUGH */ |
@@ -125,7 +125,7 @@ int usbnet_get_endpoints(struct usbnet *dev, struct usb_interface *intf) | |||
125 | default: | 125 | default: |
126 | continue; | 126 | continue; |
127 | } | 127 | } |
128 | if (e->desc.bEndpointAddress & USB_DIR_IN) { | 128 | if (usb_endpoint_dir_in(&e->desc)) { |
129 | if (!intr && !in) | 129 | if (!intr && !in) |
130 | in = e; | 130 | in = e; |
131 | else if (intr && !status) | 131 | else if (intr && !status) |
@@ -554,7 +554,7 @@ static int usbnet_stop (struct net_device *net) | |||
554 | { | 554 | { |
555 | struct usbnet *dev = netdev_priv(net); | 555 | struct usbnet *dev = netdev_priv(net); |
556 | int temp; | 556 | int temp; |
557 | DECLARE_WAIT_QUEUE_HEAD (unlink_wakeup); | 557 | DECLARE_WAIT_QUEUE_HEAD_ONSTACK (unlink_wakeup); |
558 | DECLARE_WAITQUEUE (wait, current); | 558 | DECLARE_WAITQUEUE (wait, current); |
559 | 559 | ||
560 | netif_stop_queue (net); | 560 | netif_stop_queue (net); |
@@ -669,20 +669,40 @@ done: | |||
669 | * they'll probably want to use this base set. | 669 | * they'll probably want to use this base set. |
670 | */ | 670 | */ |
671 | 671 | ||
672 | void usbnet_get_drvinfo (struct net_device *net, struct ethtool_drvinfo *info) | 672 | #if defined(CONFIG_MII) || defined(CONFIG_MII_MODULE) |
673 | #define HAVE_MII | ||
674 | |||
675 | int usbnet_get_settings (struct net_device *net, struct ethtool_cmd *cmd) | ||
673 | { | 676 | { |
674 | struct usbnet *dev = netdev_priv(net); | 677 | struct usbnet *dev = netdev_priv(net); |
675 | 678 | ||
676 | /* REVISIT don't always return "usbnet" */ | 679 | if (!dev->mii.mdio_read) |
677 | strncpy (info->driver, driver_name, sizeof info->driver); | 680 | return -EOPNOTSUPP; |
678 | strncpy (info->version, DRIVER_VERSION, sizeof info->version); | 681 | |
679 | strncpy (info->fw_version, dev->driver_info->description, | 682 | return mii_ethtool_gset(&dev->mii, cmd); |
680 | sizeof info->fw_version); | ||
681 | usb_make_path (dev->udev, info->bus_info, sizeof info->bus_info); | ||
682 | } | 683 | } |
683 | EXPORT_SYMBOL_GPL(usbnet_get_drvinfo); | 684 | EXPORT_SYMBOL_GPL(usbnet_get_settings); |
685 | |||
686 | int usbnet_set_settings (struct net_device *net, struct ethtool_cmd *cmd) | ||
687 | { | ||
688 | struct usbnet *dev = netdev_priv(net); | ||
689 | int retval; | ||
690 | |||
691 | if (!dev->mii.mdio_write) | ||
692 | return -EOPNOTSUPP; | ||
684 | 693 | ||
685 | static u32 usbnet_get_link (struct net_device *net) | 694 | retval = mii_ethtool_sset(&dev->mii, cmd); |
695 | |||
696 | /* link speed/duplex might have changed */ | ||
697 | if (dev->driver_info->link_reset) | ||
698 | dev->driver_info->link_reset(dev); | ||
699 | |||
700 | return retval; | ||
701 | |||
702 | } | ||
703 | EXPORT_SYMBOL_GPL(usbnet_set_settings); | ||
704 | |||
705 | u32 usbnet_get_link (struct net_device *net) | ||
686 | { | 706 | { |
687 | struct usbnet *dev = netdev_priv(net); | 707 | struct usbnet *dev = netdev_priv(net); |
688 | 708 | ||
@@ -690,9 +710,40 @@ static u32 usbnet_get_link (struct net_device *net) | |||
690 | if (dev->driver_info->check_connect) | 710 | if (dev->driver_info->check_connect) |
691 | return dev->driver_info->check_connect (dev) == 0; | 711 | return dev->driver_info->check_connect (dev) == 0; |
692 | 712 | ||
713 | /* if the device has mii operations, use those */ | ||
714 | if (dev->mii.mdio_read) | ||
715 | return mii_link_ok(&dev->mii); | ||
716 | |||
693 | /* Otherwise, say we're up (to avoid breaking scripts) */ | 717 | /* Otherwise, say we're up (to avoid breaking scripts) */ |
694 | return 1; | 718 | return 1; |
695 | } | 719 | } |
720 | EXPORT_SYMBOL_GPL(usbnet_get_link); | ||
721 | |||
722 | int usbnet_nway_reset(struct net_device *net) | ||
723 | { | ||
724 | struct usbnet *dev = netdev_priv(net); | ||
725 | |||
726 | if (!dev->mii.mdio_write) | ||
727 | return -EOPNOTSUPP; | ||
728 | |||
729 | return mii_nway_restart(&dev->mii); | ||
730 | } | ||
731 | EXPORT_SYMBOL_GPL(usbnet_nway_reset); | ||
732 | |||
733 | #endif /* HAVE_MII */ | ||
734 | |||
735 | void usbnet_get_drvinfo (struct net_device *net, struct ethtool_drvinfo *info) | ||
736 | { | ||
737 | struct usbnet *dev = netdev_priv(net); | ||
738 | |||
739 | /* REVISIT don't always return "usbnet" */ | ||
740 | strncpy (info->driver, driver_name, sizeof info->driver); | ||
741 | strncpy (info->version, DRIVER_VERSION, sizeof info->version); | ||
742 | strncpy (info->fw_version, dev->driver_info->description, | ||
743 | sizeof info->fw_version); | ||
744 | usb_make_path (dev->udev, info->bus_info, sizeof info->bus_info); | ||
745 | } | ||
746 | EXPORT_SYMBOL_GPL(usbnet_get_drvinfo); | ||
696 | 747 | ||
697 | u32 usbnet_get_msglevel (struct net_device *net) | 748 | u32 usbnet_get_msglevel (struct net_device *net) |
698 | { | 749 | { |
@@ -712,8 +763,13 @@ EXPORT_SYMBOL_GPL(usbnet_set_msglevel); | |||
712 | 763 | ||
713 | /* drivers may override default ethtool_ops in their bind() routine */ | 764 | /* drivers may override default ethtool_ops in their bind() routine */ |
714 | static struct ethtool_ops usbnet_ethtool_ops = { | 765 | static struct ethtool_ops usbnet_ethtool_ops = { |
715 | .get_drvinfo = usbnet_get_drvinfo, | 766 | #ifdef HAVE_MII |
767 | .get_settings = usbnet_get_settings, | ||
768 | .set_settings = usbnet_set_settings, | ||
716 | .get_link = usbnet_get_link, | 769 | .get_link = usbnet_get_link, |
770 | .nway_reset = usbnet_nway_reset, | ||
771 | #endif | ||
772 | .get_drvinfo = usbnet_get_drvinfo, | ||
717 | .get_msglevel = usbnet_get_msglevel, | 773 | .get_msglevel = usbnet_get_msglevel, |
718 | .set_msglevel = usbnet_set_msglevel, | 774 | .set_msglevel = usbnet_set_msglevel, |
719 | }; | 775 | }; |
@@ -1094,6 +1150,7 @@ usbnet_probe (struct usb_interface *udev, const struct usb_device_id *prod) | |||
1094 | dev->delay.function = usbnet_bh; | 1150 | dev->delay.function = usbnet_bh; |
1095 | dev->delay.data = (unsigned long) dev; | 1151 | dev->delay.data = (unsigned long) dev; |
1096 | init_timer (&dev->delay); | 1152 | init_timer (&dev->delay); |
1153 | mutex_init (&dev->phy_mutex); | ||
1097 | 1154 | ||
1098 | SET_MODULE_OWNER (net); | 1155 | SET_MODULE_OWNER (net); |
1099 | dev->net = net; | 1156 | dev->net = net; |
@@ -1225,7 +1282,7 @@ EXPORT_SYMBOL_GPL(usbnet_resume); | |||
1225 | static int __init usbnet_init(void) | 1282 | static int __init usbnet_init(void) |
1226 | { | 1283 | { |
1227 | /* compiler should optimize this out */ | 1284 | /* compiler should optimize this out */ |
1228 | BUG_ON (sizeof (((struct sk_buff *)0)->cb) | 1285 | BUILD_BUG_ON (sizeof (((struct sk_buff *)0)->cb) |
1229 | < sizeof (struct skb_data)); | 1286 | < sizeof (struct skb_data)); |
1230 | 1287 | ||
1231 | random_ether_addr(node_id); | 1288 | random_ether_addr(node_id); |
diff --git a/drivers/usb/net/usbnet.h b/drivers/usb/net/usbnet.h index c0746f0454af..07c70abbe0ec 100644 --- a/drivers/usb/net/usbnet.h +++ b/drivers/usb/net/usbnet.h | |||
@@ -30,6 +30,7 @@ struct usbnet { | |||
30 | struct usb_device *udev; | 30 | struct usb_device *udev; |
31 | struct driver_info *driver_info; | 31 | struct driver_info *driver_info; |
32 | wait_queue_head_t *wait; | 32 | wait_queue_head_t *wait; |
33 | struct mutex phy_mutex; | ||
33 | 34 | ||
34 | /* i/o info: pipes etc */ | 35 | /* i/o info: pipes etc */ |
35 | unsigned in, out; | 36 | unsigned in, out; |
@@ -168,9 +169,13 @@ extern void usbnet_defer_kevent (struct usbnet *, int); | |||
168 | extern void usbnet_skb_return (struct usbnet *, struct sk_buff *); | 169 | extern void usbnet_skb_return (struct usbnet *, struct sk_buff *); |
169 | extern void usbnet_unlink_rx_urbs(struct usbnet *); | 170 | extern void usbnet_unlink_rx_urbs(struct usbnet *); |
170 | 171 | ||
172 | extern int usbnet_get_settings (struct net_device *net, struct ethtool_cmd *cmd); | ||
173 | extern int usbnet_set_settings (struct net_device *net, struct ethtool_cmd *cmd); | ||
174 | extern u32 usbnet_get_link (struct net_device *net); | ||
171 | extern u32 usbnet_get_msglevel (struct net_device *); | 175 | extern u32 usbnet_get_msglevel (struct net_device *); |
172 | extern void usbnet_set_msglevel (struct net_device *, u32); | 176 | extern void usbnet_set_msglevel (struct net_device *, u32); |
173 | extern void usbnet_get_drvinfo (struct net_device *, struct ethtool_drvinfo *); | 177 | extern void usbnet_get_drvinfo (struct net_device *, struct ethtool_drvinfo *); |
178 | extern int usbnet_nway_reset(struct net_device *net); | ||
174 | 179 | ||
175 | /* messaging support includes the interface name, so it must not be | 180 | /* messaging support includes the interface name, so it must not be |
176 | * used before it has one ... notably, in minidriver bind() calls. | 181 | * used before it has one ... notably, in minidriver bind() calls. |