Solaris USB driver for Linksys USB Ethernet controller (USB200M)

Solaris USB driver for Linksys USB Ethernet controller (USB200M)

Post by maxim_sadov.. » Thu, 06 Nov 2003 01:23:42



I have been trying to write a Solaris USB driver for USB200M Linksys
card.
The driver uses GLD for all DLPI related stuff.
The driver seems to work - but there are two problems that are related
to Solaris USB kernel framework and that affect the driver's
performance:

1. USB200M has for endpoints (control, interrupt, bulk out and bulk
in). Both bulk endpoints have MaxPacketSize of 64. If request is made
to receive 64 bytes (or less - SHORT_XFER) from the bulk in pipe, the
driver works fine, albeit very slow, because it has to wait for an
interrupt for each 64 byte message. If you attempt to set Max Packet
Size to ETHERMAX (1514) and try to get a longer message, USB framework
returns only the LAST message block of the message - basically, if you
are supposed to get 257 bytes, you'd get only 1 byte message (257 % 64
= 1). This looks like a defect to me... Looking at the mblk_t and the
linked struct datab does not point to any other mblk_t...
At the same time, sending of 1514 byte messages works just fine. The
end result - data transfer FROM Solaris machine is ~350k/sec, TO
Solaris machine is ~30k/sec.

2. When trying to unload the driver, it calls usb_pipe_close for all
data pipes (bulk in and bulk out). There is almost always a read
request active for the bulk in pipe, to make sure that we do not miss
the incoming data. What happens is that sometimes usb_pipe_close
deadlocks on a condition variable. Using usb_pipe_reset before
usb_pipe_close does not help. Also, attempting to use usb_pipe_abort
before usb_pipe_close also deadlocks the driver, even in the same
stack. All other kernel threads are just waiting for something else,
there are no other threads in the driver's context.

Does anyone have any idea what is going on in the Solaris USB kernel
side? I have tried to get the source code, but to no avail. Sun's SCSL
does not list Solaris anymore.

Comments and suggestions are much appreciated.

 
 
 

Solaris USB driver for Linksys USB Ethernet controller (USB200M)

Post by Philip Bro » Thu, 06 Nov 2003 05:17:37



Quote:>I have been trying to write a Solaris USB driver for USB200M Linksys
>card.
>The driver uses GLD for all DLPI related stuff.
>The driver seems to work - but there are two problems that are related
>to Solaris USB kernel framework and that affect the driver's
>performance:

>1. USB200M has for endpoints (control, interrupt, bulk out and bulk
>in). Both bulk endpoints have MaxPacketSize of 64.

Is that what the USB framework tells you, or what the physical device tells
you in some other way? Can you cross-reference it, to point out that the
framework is telling you the "wrong" thing somehow?

Quote:

>2. When trying to unload the driver, it calls usb_pipe_close for all
>data pipes (bulk in and bulk out). There is almost always a read
>request active for the bulk in pipe, to make sure that we do not miss
>the incoming data. What happens is that sometimes usb_pipe_close
>deadlocks on a condition variable.

Unfortunately, yes. I think that's one of the many "dont hold any locks now"
places in the framework :-/

[sidebar: you make it sound like you do a pre-emptive read, even
  when one isnt requested by the user. true?]

A workaround for you might be to see if the driver is busy on detach().
  If it is, set some kind of internal "dont do any more reads" flag,
 and return DDI_FAILURE

 At some point, possible the unload will be attempted again, at
 which point, hopefully, the driver will then be inactive, and you
 can return successfully

[not speaking for sun, seeing as how I dont work for them.
 I've just banged a fair amount on USB drivers]

PS: gald to hear you're working on this. Keep going!

--
  http://www.blastwave.org/ for solaris pre-packaged binaries with pkg-get
    Organized by the author of pkg-get
[Trim the no-bots from my address to reply to me by email!]

                            http://www.spamlaws.com/state/ca1.html

 
 
 

Solaris USB driver for Linksys USB Ethernet controller (USB200M)

Post by MSadovski » Thu, 06 Nov 2003 06:25:30


- Max Packet Size == 64 - this is what USB framework tells me. I found ASIX
AX88172 chip specs, but they do not state anything. But if I recall, USB 1.1
specs says that 64 bytes is the allowed maximum (USB 2.0 has 1024, I think).
- in GLD you do not get a read request, you are supposed to furnish GLD with
received packets asynchronously. So the driver places async bulk read request,
waits for the interrupt and then pushes the data to GLD.
- returning an error on detach seems a good idea ;)

I'll try it on Solaris 10, just got b42 pre-release...

 
 
 

Solaris USB driver for Linksys USB Ethernet controller (USB200M)

Post by Philip Bro » Thu, 06 Nov 2003 11:54:22



Quote:>- in GLD you do not get a read request, you are supposed to furnish GLD with
>received packets asynchronously. So the driver places async bulk read request,
>waits for the interrupt and then pushes the data to GLD.

I've never written an ethernet driver... but I heard that nowadays, there
is hardware support for "This is my MAC address" type recognition.
So ideally, you would set up the hardware to send you an interrupt or
something when there is data ?

Odd, though... I think I've seen more then 64bytes for bulk read with my
epsonscan driver. but its been a while, so I could be mistaken.
and hooking up the old scanner is a pain to check :->

But it sounds like one heck of a bug, if a "bulk" transfer cant transfer
more than 64 bytes?!?!!

--
  http://www.blastwave.org/ for solaris pre-packaged binaries with pkg-get
    Organized by the author of pkg-get
[Trim the no-bots from my address to reply to me by email!]

                            http://www.spamlaws.com/state/ca1.html