2001-02-07 06:38:58

by Eric Sandeen

[permalink] [raw]
Subject: [PATCH] updates for KLSI usb->ethernet

This patch, against 2.4.1-ac4, does the following for the KLSI
USB->ethernet adapter:

(patch at http://lager.dyndns.org/kaweth/KLSI-2.4.1-ac4.patch.bz2)

o Fixes firmware downloading. If firmware is already loaded
and an attempt is made to download it again, the device
will hang. This will happen on a warm boot. Driver now
checks the bcdDevice value, which changes after firmware
is loaded. It does this via usb_get_device_descriptor()
to avoid caching. If device already has firmware, it will
skip the download.

o Reports bcdDevice revision in debugging messages

o Updates firmware revision, fresh from KLSI

o Actually _uses_ interrupt parameter passed to
kaweth_trigger_firmware()

o added function prototype for
kaweth_internal_control_msg() to avoid warning

o spells "receive" correctly. :)

There is another way to handle the firmware download check - there is a
chunk of firmware which can be downloaded that causes the device to
disconnect, wait, then reconnect to the USB bus. When it reappears, it
has the new bcdDevice value in the descriptor.

This might be a better way to go, so that the device descriptor doesn't
silently change. I've also seen some errors when I try to re-read the
device descriptor with usb_get_device_descriptor(), for some reason.

Any thoughts on what would be more correct,

a) device descriptor silently changes
b) device magically disconnects/reconnects on its own

Both seem a bit odd, but take your pick. :)

-Eric


2001-02-07 08:50:40

by Greg KH

[permalink] [raw]
Subject: Re: [PATCH] updates for KLSI usb->ethernet

On Wed, Feb 07, 2001 at 12:38:52AM -0600, Eric Sandeen wrote:
> Any thoughts on what would be more correct,
>
> a) device descriptor silently changes
> b) device magically disconnects/reconnects on its own
>
> Both seem a bit odd, but take your pick. :)

b) is more like other devices. They use 1 descriptor id for the "I have
no firmware" state, then after firmware is downloaded, they disconnect,
and reconnect with a new id which means they have the firmware loaded.

Lots of usb-serial devices do this, and so does just about any
Anchor/Cypress EZ-USB chip based design.

Silently changing descriptor ids while connected is just asking for
trouble :)

You also might want to post this to linux-usb-devel as that's where the
authors of this driver are known to hang out.

greg k-h

--
greg@(kroah|wirex).com
http://immunix.org/~greg

2001-02-08 20:22:01

by Eric Sandeen

[permalink] [raw]
Subject: Re: [NEW][PATCH] updates for KLSI

--- linux/drivers/usb/kaweth.c.ac6 Thu Feb 8 10:47:40 2001
+++ linux/drivers/usb/kaweth.c Thu Feb 8 11:08:16 2001
@@ -131,6 +131,7 @@
{ USB_DEVICE(0x066b, 0x2202) }, /* Linksys USB10T */
{ USB_DEVICE(0x1645, 0x0005) }, /* Entrega E45 */
{ USB_DEVICE(0x2001, 0x4000) }, /* D-link DSB-650C */
+ { USB_DEVICE(0x07b8, 0x4000) }, /* D-Link DU-E10 */
{} /* Null terminator */
};

@@ -647,9 +648,10 @@
if (net->flags & IFF_PROMISC) {
packet_filter_bitmap |= KAWETH_PACKET_FILTER_PROMISCUOUS;
}
- else if ((net->mc_count) || (net->flags & IFF_ALLMULTI)) {
+ else if ((net->mc_count) || (net->flags & IFF_ALLMULTI)) {
packet_filter_bitmap |= KAWETH_PACKET_FILTER_ALL_MULTICAST;
}
+
kaweth->packet_filter_bitmap = packet_filter_bitmap;
netif_wake_queue(net);
}
@@ -721,11 +723,7 @@
const eth_addr_t bcast_addr = { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF };
int result = 0;

- result = usb_get_device_descriptor(dev);
- if (result < 0)
- kaweth_err("Error re-loading device descriptor");
-
- kaweth_dbg("Kawasaki Device Probe (Device number:%d): 0x%4.4x:0x%4.4x revision 0x%4.4x",
+ kaweth_dbg("Kawasaki Device Probe (Device number:%d): 0x%4.4x:0x%4.4x:0x%4.4x",
dev->devnum,
(int)dev->descriptor.idVendor,
(int)dev->descriptor.idProduct,
@@ -754,52 +752,65 @@
kaweth_reset(kaweth);

/*
- * If we got bcdDevice 0x0202, firmware is already present,
- * don't try to download again.
+ * If high byte of bcdDevice is nonzero, firmware is already
+ * downloaded. Don't try to do it again, or we'll hang the device.
*/

- if ((int)dev->descriptor.bcdDevice != 0x0202) {
-
- if((result = kaweth_download_firmware(kaweth,
+ if (dev->descriptor.bcdDevice >> 8) {
+ kaweth_info("Firmware present in device.");
+ } else {
+ /* Download the firmware */
+ kaweth_info("Downloading firmware...");
+ if ((result = kaweth_download_firmware(kaweth,
kaweth_new_code,
len_kaweth_new_code,
100,
- 2)) < 0){
- kaweth_err("Error downloading firmware (%d), no net device created", result);
+ 2)) < 0) {
+ kaweth_err("Error downloading firmware (%d)", result);
kfree(kaweth);
return NULL;
}

- if((result = kaweth_download_firmware(kaweth,
+ if ((result = kaweth_download_firmware(kaweth,
kaweth_new_code_fix,
len_kaweth_new_code_fix,
100,
3)) < 0) {
- kaweth_err("Error downloading firmware fix (%d), no net device created", result);
+ kaweth_err("Error downloading firmware fix (%d)", result);
kfree(kaweth);
return NULL;
}

- if((result = kaweth_trigger_firmware(kaweth, 100)) < 0){
- kaweth_err("Error triggering firmware (%d), no net device created\n", result);
+ if ((result = kaweth_download_firmware(kaweth,
+ kaweth_trigger_code,
+ len_kaweth_trigger_code,
+ 126,
+ 2)) < 0) {
+ kaweth_err("Error downloading trigger code (%d)", result);
kfree(kaweth);
return NULL;
}

- udelay(1000);
+ if ((result = kaweth_download_firmware(kaweth,
+ kaweth_trigger_code_fix,
+ len_kaweth_trigger_code_fix,
+ 126,
+ 3)) < 0) {
+ kaweth_err("Error downloading trigger code fix (%d)", result);
+ kfree(kaweth);
+ return NULL;
+ }

- kaweth_dbg("Resetting device (jiffies: %lx)", jiffies);

- if(kaweth_reset(kaweth)) {
- kaweth_err("Error resetting device\n");
+ if ((result = kaweth_trigger_firmware(kaweth, 126)) < 0) {
+ kaweth_err("Error triggering firmware (%d)", result);
kfree(kaweth);
return NULL;
}

- kaweth_dbg("Reset device (jiffies: %lx)", jiffies);
-
- } else {
- kaweth_dbg("Firmware already present");
+ /* Device will now disappear for a moment... */
+ kaweth_info("Firmware loaded. I'll be back...");
+ return NULL;
}

result = kaweth_read_configuration(kaweth);


Attachments:
KLSI-2.4.1-ac6.patch (3.82 kB)