winusb.sys vs bulkusb.sys

Hi

I need to write a driver which works with a bulk usb device (both XP and Vista). I will need to reach transfer speed as high as possible.

My question would be if winusb.sys would fit my needs?
I saw that it’s instalable on XP too, it works with bulk devices.
OSR’s learning kit has a driver based on it.

I will have complicated math and stuff and I would like to have this code in user mode for safety, even is I will use the bulkusb driver from WDK. Winusb seems to me a good option since this way I would skip the kernel code and I could work only user mode.

So which is the best solution for a high speed bulk usb device: winusb or bulkusb? Or it’s almost the same?

-Barni

You can fully saturate a usb 2.0 controller from winusb with a user mode application. Your best solution will be winusb by a long shot.

d

-----Original Message-----
From: xxxxx@lists.osr.com [mailto:xxxxx@lists.osr.com] On Behalf Of xxxxx@yahoo.com
Sent: Tuesday, March 04, 2008 5:42 AM
To: Windows System Software Devs Interest List
Subject: [ntdev] winusb.sys vs bulkusb.sys

Hi

I need to write a driver which works with a bulk usb device (both XP and Vista). I will need to reach transfer speed as high as possible.

My question would be if winusb.sys would fit my needs?
I saw that it’s instalable on XP too, it works with bulk devices.
OSR’s learning kit has a driver based on it.

I will have complicated math and stuff and I would like to have this code in user mode for safety, even is I will use the bulkusb driver from WDK. Winusb seems to me a good option since this way I would skip the kernel code and I could work only user mode.

So which is the best solution for a high speed bulk usb device: winusb or bulkusb? Or it’s almost the same?

-Barni


NTDEV is sponsored by OSR

For our schedule of WDF, WDM, debugging and other seminars visit:
http://www.osr.com/seminars

To unsubscribe, visit the List Server section of OSR Online at http://www.osronline.com/page.cfm?name=ListServer

Thanks Doron …

From Your experience what is the max speed reachable with winusb?
I know that the bulkusb driver (from DDK) suport up to 300Mbit/sec from experiences or even more - does the winusb suports such a speed or using user mode switch will kill me?

I will have to transfer really huge amount of data so I would like to go in the right direction from start. Most probably I will make some tests with my OSR devboard when it arrives in a few days to see what happens …

But I would appreaciate if You can tell me a ~ transfer rate for winusb …

-Barni

Like I said, you can fully saturate the bus w/winusb. for such speeds you will need to use async i/o and be smart about how you communicate with the device, but the same is true for bulkusb as well

d

-----Original Message-----
From: xxxxx@lists.osr.com [mailto:xxxxx@lists.osr.com] On Behalf Of xxxxx@yahoo.com
Sent: Tuesday, March 04, 2008 8:52 AM
To: Windows System Software Devs Interest List
Subject: RE:[ntdev] winusb.sys vs bulkusb.sys

Thanks Doron …

From Your experience what is the max speed reachable with winusb?
I know that the bulkusb driver (from DDK) suport up to 300Mbit/sec from experiences or even more - does the winusb suports such a speed or using user mode switch will kill me?

I will have to transfer really huge amount of data so I would like to go in the right direction from start. Most probably I will make some tests with my OSR devboard when it arrives in a few days to see what happens …

But I would appreaciate if You can tell me a ~ transfer rate for winusb …

-Barni


NTDEV is sponsored by OSR

For our schedule of WDF, WDM, debugging and other seminars visit:
http://www.osr.com/seminars

To unsubscribe, visit the List Server section of OSR Online at http://www.osronline.com/page.cfm?name=ListServer

> From Your experience what is the max speed reachable with winusb? I

know that the bulkusb driver (from DDK) suport up to 300Mbit/sec from
experiences or even more - does the winusb suports such a speed or
using user mode switch will kill me?

But I would appreaciate if You can tell me a ~ transfer rate for
winusb …

Here’s a performance report based on using a NetChip (PLX) NET2280 USB device:

http://www.plxtech.com/pdf/usb/Net2280.Performance_Report.RE030409a.pdf

An interesting observation is that that maximum observed data transfer rate on the bus when the device never NAKs using an Intel ICH EHCI controller as the host is 10 512-byte Bulk IN packets per microframe and 8 512-byte Bulk OUT packets per microframe. That’s 40,960,000 IN bytes/second and 32,768,000 OUT bytes/second.

The maximum theoretical data transfer rate is 13 512-byte Bulk packets per microframe, or 53,248,000 bytes/second. (See Table 5-10. High-speed Bulk Transaction Limits in the Universal Serial Bus Specification Revision 2.0). The inability to achieve the maximum theoretical data transfer rate under the best case USB device and USB host software conditions appears to be a USB host controller chipset hardware limitation.

So that gives you some maximum transfer rate figures to start with. The transfer rate will slow down considerably if the device frequently sends short packets instead of 512-byte packets. The transfer rate will also slow down as the request transfer size decreases and if there is only one transfer request active at a time instead of at least two. The transfer rate will of course also slow down if the device NAKs and if there are other devices transferring data on the bus at the same time. The transfer rate can even slow down if there are other devices attached which are not actively transferring data but which have endpoints configured in the host controller endpoint schedule.

If you design your device and software too closely to the maximum possible transfer rates you may find that it cannot achieve those rates in practice in many real world scenarios. There is guaranteed transfer rate for Bulk endpoint data transfers.

But in any case, using WinUSB should not be the limiting factor.

I have no idea what data transfer rate an OSR FX2 device can sustain with its standard OSR firmware, or what the maximum data transfer rate an FX2 can sustain with custom firmware when the endpoint FIFOs are emptied or filled by firmware instead of external hardware.

If you don’t have a hardware bus analyzer it may be difficult to pinpoint data transfer rate bottlenecks. If you cannot observe NAKs and NYETs you won’t be able to know what is really happening.

> There is guaranteed transfer rate for Bulk endpoint data transfers.

Correction, small typo, big change in meaning:

There is NO guaranteed transfer rate for Bulk endpoint data transfers.

xxxxx@microsoft.com wrote:

Here’s a performance report based on using a NetChip (PLX) NET2280 USB device:

http://www.plxtech.com/pdf/usb/Net2280.Performance_Report.RE030409a.pdf

An interesting observation is that that maximum observed data transfer rate on the bus when the device never NAKs using an Intel ICH EHCI controller as the host is 10 512-byte Bulk IN packets per microframe and 8 512-byte Bulk OUT packets per microframe. That’s 40,960,000 IN bytes/second and 32,768,000 OUT bytes/second.

The maximum theoretical data transfer rate is 13 512-byte Bulk packets per microframe, or 53,248,000 bytes/second. (See Table 5-10. High-speed Bulk Transaction Limits in the Universal Serial Bus Specification Revision 2.0). The inability to achieve the maximum theoretical data transfer rate under the best case USB device and USB host software conditions appears to be a USB host controller chipset hardware limitation.

I can confirm this from our empirical evidence. We have sustained as
much as 45 MB/s over a bulk pipe on many host controllers, but there are
others (ATI IXP SB400) that cannot reliably sustain even 30 MB/s.

I have no idea what data transfer rate an OSR FX2 device can sustain with its standard OSR firmware, or what the maximum data transfer rate an FX2 can sustain with custom firmware when the endpoint FIFOs are emptied or filled by firmware instead of external hardware.

Our tests were with an FX2 using “slave” mode, where the filling is done
by an external device. You can’t use the firmware to handle data;
remember that the 8051 runs at 3 MIPS (assuming 48 MHz clock, 4 cycles
per tick, most instructions are 4 ticks).


Tim Roberts, xxxxx@probo.com
Providenza & Boekelheide, Inc.

In my experience there is no substantial difference between BulkUsb
based driver and WinUsb. There is no reason for it; both just deliver
application requests to OS USB drivers. What makes the difference is an
application. To achieve the best performance you have to use
asynchronous IO and always have enough requests sent to the driver and
pending so HC driver has always data to send or a buffer for received
data. You can tune buffers size because big buffers aren’t always the
best (more smaller can be better). As Glen said, you need hw USB
analyser to find possible bottleneck.

The other viewpoint is drivers quality. BulkUsb is miserable and can
lead to support nightmare (you can search list archives for my rants
about it :). WinUsb should be better and if there is a problem, it’s MS
problem, not yours. So until you need a specific functionality in kernel
mode and/or support obsolete OSes, use WinUsb.

Best regards,

Michal Vodicka
UPEK, Inc.
[xxxxx@upek.com, http://www.upek.com]

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of
xxxxx@yahoo.com
Sent: Tuesday, March 04, 2008 2:42 PM
To: Windows System Software Devs Interest List
Subject: [ntdev] winusb.sys vs bulkusb.sys

Hi

I need to write a driver which works with a bulk usb device
(both XP and Vista). I will need to reach transfer speed as
high as possible.

My question would be if winusb.sys would fit my needs?
I saw that it’s instalable on XP too, it works with bulk devices.
OSR’s learning kit has a driver based on it.

I will have complicated math and stuff and I would like to
have this code in user mode for safety, even is I will use
the bulkusb driver from WDK. Winusb seems to me a good option
since this way I would skip the kernel code and I could work
only user mode.

So which is the best solution for a high speed bulk usb
device: winusb or bulkusb? Or it’s almost the same?

-Barni


NTDEV is sponsored by OSR

For our schedule of WDF, WDM, debugging and other seminars visit:
http://www.osr.com/seminars

To unsubscribe, visit the List Server section of OSR Online
at http://www.osronline.com/page.cfm?name=ListServer

xxxxx@microsoft.com wrote:

The transfer rate can even slow down if there are other devices
attached which are not actively transferring data but which have
endpoints configured in the host controller endpoint schedule.

We even have a weird effect when an additional USB2 monitor hub is
attached to the same root hub as our device: the transfer rate speeds up
slightly, and latency decreases by a few microseconds.

My assumption is this is either a side effect of some additional
polling, or a glitch of the PC root hub controller.

Michal Vodicka wrote:

WinUsb should be better and if there is a problem, it’s MS problem,
not yours.

I was thinking about this comment. Is this actually better?

> -----Original Message-----

From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of
xxxxx@gmail.com
Sent: Tuesday, March 04, 2008 11:10 PM
To: Windows System Software Devs Interest List
Subject: RE:[ntdev] winusb.sys vs bulkusb.sys

> WinUsb should be better and if there is a problem, it’s MS problem,
> not yours.

I was thinking about this comment. Is this actually better?

It depends. You can claim you don’t provide any kernel code so any BSOD
can’t be your fault. Also, bugchecks would be always assigned to an MS
driver. If your customer is an OEM, it’d be sufficient arguments for
them to open support case with MS and get the fix quickly. Not always,
of course. Some OEMs still apply the logic: it started crashing after
your software installation so it has to be your fault.

WinQual reports assigned to an MS driver should be examined by MS people
and there is a chance they develop fix on their own and it appears as a
hotfix or in the next SP. At least I hope so.

On the other hand, you can fix bugs coming from miserable sample code
yourself. You can even make some workarounds against bugs in other OS
components. It is generally faster than trying to get a hotfix from MS
yourself but supporting it isn’t easy. But after every fix and
workaround you have to sign your driver again which is PITA.

The worst problem with bugs in built-in OS drivers is they’re usually
assigned to your driver which issued an IRP. It is hard to explain an
OEM it is in fact MS bug and they should make support request which has
much higher priority than yours. They claim WinDbg analysis assigned it
to your driver so it is you who should solve the problem.

Best regards,

Michal Vodicka
UPEK, Inc.
[xxxxx@upek.com, http://www.upek.com]