Windows System Software -- Consulting, Training, Development -- Unique Expertise, Guaranteed Results

Before Posting...
Please check out the Community Guidelines in the Announcements and Administration Category.

Re: How to increase the speed of ?USB reading?

David_J._CraigDavid_J._Craig Member Posts: 1,885
Maybe instead of you repeatedly posting the same message, providing some
relevant data would get you an answer. How fast in MB/sec? What level of
USB (1, 2, or 3)? Provide the read code proving proper usage of overlapped
I/O and thread utilization.


<xxxxx@gmail.com> wrote in message news:xxxxx@ntdev...
>
> How to increase the speed of USB reading ?
>
> A usb device which performans bulk transfer.
>
> The reading operaion launched in the APP layer can't meet the speed
> requirement, so there should be set up some mechanisms in order to
> transfer data as soon as posssible.
>
> The simple way I can find is allocating some buffers in the driver, the
> driver itself builds reading IRPs continuously and implementing the
> reading operaion and stores the reading data in the buffer . So , the APP
> can get the data in buffer sometimes but not often .
>
> Is this ways should launch a kernel thread to perfomrmans reading
> operations?
>
> Or is there any more accurate ways ?
>
> Thanks.
>
>
>
>
>

Comments

  • Doron_HolanDoron_Holan Member - All Emails Posts: 10,428
    How many concurrent reads do you have pending at any point in time?

    d

    dent from a phpne with no keynoard

    -----Original Message-----
    From: xxxxx@gmail.com <xxxxx@gmail.com>
    Sent: June 12, 2010 8:52 PM
    To: Windows System Software Devs Interest List <xxxxx@lists.osr.com>
    Subject: [ntdev] How to increase the speed of ?USB reading?


    A usb device which performans bulk transfer.

    The reading operaion launched in the APP layer can't meet the speed requirement, so there should be set up some mechanisms in order to transfer data as soon as posssible.

    The simple way I can find is allocating some buffers in the driver, the driver itself builds reading IRPs continuously and implementing the reading operaion ?and stores the reading data in the buffer . So , the APP can reading the data in buffer sometimes but not often .

    Is this ways should launch a kernel thread to perfomrmans reading operations?

    Or is there any ?more accurate? ways ?

    Thanks.






    ---
    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
    d
  • CyberPunkerXCyberPunkerX Member Posts: 89
    sorry for repeat posting , I just want to conquer the garbage characters problem .

    The occasion is:
    a USB2.0( cypress 68013 ) device;
    the speed requires 4MB/s ;
    windows XP .

    Just now , we just utilize the cypress's driver package, and just access the device form the APP layber , it can't run fast enough , so we want to launch the reading operation in the kernel .
  • CyberPunkerXCyberPunkerX Member Posts: 89
    If any one has the authorization ? please delete the garbage characters post.

    Thanks.

    By the way , I deeply hope this froum can be more functional .
  • Doron_HolanDoron_Holan Member - All Emails Posts: 10,428
    Before you write your own driver, look at both WinUSB and making sure that your app has enough pending io to the device such that you use as much of the HC schedule as possible.

    d

    dent from a phpne with no keynoard

    -----Original Message-----
    From: xxxxx@gmail.com <xxxxx@gmail.com>
    Sent: June 12, 2010 11:45 PM
    To: Windows System Software Devs Interest List <xxxxx@lists.osr.com>
    Subject: RE:[ntdev] Re: How to increase the speed of ?USB reading?


    sorry for repeat posting , I just want to conquer the garbage characters problem .

    The occasion is:
    a USB2.0( cypress 68013 ) device;
    the speed requires 4MB/s ;
    windows XP .

    Just now , we just utilize the cypress's driver package, and just access the device form the APP layber , it can't run fast enough , so we want to launch the reading operation in the kernel .





    ---
    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
    d
  • CyberPunkerXCyberPunkerX Member Posts: 89
    You mean just use the WinUSB driver provided by Mircosoft ? and then can send musch "pending io" to it ? what is the HC schedule means ? high critical ?

    I don't mush of the WinUSB ,and we want to build our own driver.
  • Peter_Viscarola_(OSR)Peter_Viscarola_(OSR) Administrator Posts: 7,138
    <QUOTE>
    By the way , I deeply hope this froum can be more functional .
    </QUOTE>

    I deeply hope you realize this forum is just a front-end for a mailing list (like listserv) that's also accessible via NNTP. That's why you can't edit or delete posts: A few short seconds after you've "posted" them, they've been emailed to several thousand people.

    So, is the forum likely to increase in functionality? Not anytime soon.

    Peter
    OSR

    Peter Viscarola
    OSR
    @OSRDrivers

  • Doron_HolanDoron_Holan Member - All Emails Posts: 10,428
    HC == host controller. Why are you bell bent on writing your own driver if you can reuse one?

    d

    dent from a phpne with no keynoard

    -----Original Message-----
    From: xxxxx@gmail.com <xxxxx@gmail.com>
    Sent: June 13, 2010 12:29 AM
    To: Windows System Software Devs Interest List <xxxxx@lists.osr.com>
    Subject: RE:[ntdev] Re: How to increase the speed of ?USB reading?


    You mean just use the WinUSB driver provided by Mircosoft ? and then can send musch "pending io" to it ? what is the HC schedule means ? high critical ?

    I don't mush of the WinUSB ,and we want to build our own driver.






    ---
    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
    d
  • CyberPunkerXCyberPunkerX Member Posts: 89
    Can the WinUSB providing source code ?

    Any way , I just want to know a method , I would very preciate if some one can give me a positive answer .

    Thanks
  • Doron_HolanDoron_Holan Member - All Emails Posts: 10,428
    You do not get WinUSB source code, it does run on xp through win7 though. I gave you the right advice, have multiple pending reads to the hardware at the same time. It doesn't matter if it is your driver or WinUSB, it is the same approach. If you want to write your own driver and the associated cost of maintaining and debugging it, look at the usbsamp sample in the win7 WDK.

    d

    dent from a phpne with no keynoard

    -----Original Message-----
    From: xxxxx@gmail.com <xxxxx@gmail.com>
    Sent: June 13, 2010 9:28 AM
    To: Windows System Software Devs Interest List <xxxxx@lists.osr.com>
    Subject: RE:[ntdev] Re: How to increase the speed of ?USB reading?


    Can the WinUSB providing source code ?

    Any way , I just want to know a method , I would very preciate if some one can give me a positive answer .

    Thanks





    ---
    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
    d
  • OSR_Community_UserOSR_Community_User Member Posts: 110,217
    > How to increase the speed of USB [bulk transfer reads]?
    >
    > The reading operaion launched in the APP layer can't meet the speed
    > requirement, so there should be set up some mechanisms in order to
    > transfer data as soon as posssible.

    (1) Is your "speed requirement" violated by the system's bandwidth or
    latency? (If you don't understand the question, please learn about
    bandwidth and latency [problems], then come back with a reply.)

    (2) As Doron already pointed out, use multiple pending requests to make
    sure the OS fully utilizes the host controller for your app requests and
    your logic does not add latency.

    (3) What is your application level transfer block size? (No, not the
    64/512 bytes on USB level, but the "APDU" size.)
    If e.g. the application block size is in the 16kB range, using WUDF
    results in a 10-15% bandwidth degradation compared to WDM. If your
    blocks can be made much bigger (e.g. several MB), WUDF/KMDF/WinUSB
    should be very much able to saturate the USB bus.

    > Can the WinUSB providing source code ?

    (4) Windows is a commercial operating system developed and maintained by
    Microsoft Corporation. MS happens to live from selling it. Also the OS
    is used in commercial environments. Understandably, MS will very likely
    not make its OS source code base open in the foreseeable future.
    If you want to look at operating system USB code, go and check out any
    open source OS that has an USB driver.
    If you want to look at Windows source code, go and check out the
    academic and industry programmes where MS offers this (under NDA).
  • Taed_WynnellTaed_Wynnell Member Posts: 105
    I don't think you said what the device is, but if it's a file system,
    you could enable NTFS compression or whatever, and that will give you a
    2-3x boost in apparent bandwidth as you'll be copying less data (and
    then it's up to the CPU to uncompress it). You may be able to use other
    compression schemes with other USB devices to lessen the amount of data
    that is actually copied.

    Also, are you after increasing the bandwidth (amount of data coming
    through per time period) or the delay (time between a request and when
    the first data arrives)? If the first, you're probably not going to be
    able to do much as you might already be hitting the point where you're
    running at the limits of the physical USB bandwidth. Have you performed
    measurement tests to see?
  • Alex_GrigAlex_Grig Member Posts: 3,238
    It's very possible to get 40 MB/s on a USB-2 host with Cypress USB device, I'v done that. You need to post requests large enough, though. Use 16 kB as a good start. Even posting a single 16 kB request to a bulk pipe will give you at least 8 MB/s, assuming that the host controller driver will miss every other frame.
  • Tim_RobertsTim_Roberts Member - All Emails Posts: 12,914
    On 6/12/2010 11:46 PM, xxxxx@gmail.com wrote:
    > The occasion is:
    > a USB2.0( cypress 68013 ) device;
    > the speed requires 4MB/s ;
    > windows XP .
    >
    > Just now , we just utilize the cypress's driver package, and just access the device form the APP layber , it can't run fast enough , so we want to launch the reading operation in the kernel .
    >

    You can stream 30 MB/s from a bulk pipe on a FX2 device (and I don't
    want to hear any teasing). The KEY, as has been pointed out several
    times in this thread, is that you must have multiple requests
    outstanding at any given time.

    Remember that USB is a scheduled bus. The host controller lays out a
    plan for the next millisecond based on the requests that it has at the
    time. If you only have one request to read 4k bytes, for example, then
    that's all the host controller will schedule. You won't get another
    chance until that request gets sent back up to your application, is
    processed, and is returned. That's a lot of wasted time.

    But if you send 10 requests for 64k bytes, for example, then the host
    controller will schedule them all. As each one completes, your other
    requests will be processed while your application handles it and returns
    it for processing.

    That can be done with WinUSB just as easily as it can from a kernel driver.

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

    Tim Roberts, [email protected]
    Providenza & Boekelheide, Inc.

  • CyberPunkerXCyberPunkerX Member Posts: 89
    Thanks,

    The device can be known as a AD card.

    "have multiple pending reads to the hardware at the same time" ?? Can you give me some more information to implemet this ? Just launch "large size( like 4k bytes )" reading operation in APP ?

    Thanks again.
  • Tim_RobertsTim_Roberts Member - All Emails Posts: 12,914
    On 6/15/2010 9:13 AM, xxxxx@gmail.com wrote:
    > The device can be known as a AD card.
    >
    > "have multiple pending reads to the hardware at the same time" ?? Can you give me some more information to implemet this ? Just launch "large size( like 4k bytes )" reading operation in APP ?
    >

    If you use FILE_FLAG_OVERLAPPED when you open the file, you can call
    ReadFile several times in a row. Each ReadFile submits a read request,
    and then returns control to you before the read has completed. That
    way, when the first read finishes, there is already another request
    waiting to go, without having to wait for you to resubmit.

    There are lots of web articles on overlapped I/O.

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

    Tim Roberts, [email protected]
    Providenza & Boekelheide, Inc.

  • CyberPunkerXCyberPunkerX Member Posts: 89
    I think you mean that I should have to realization a FILE_FLAG_OVERLAPPED driver ?
    If I don't follow this , hwo to do ? The APP Just reads , In my driver , making the IRP pending and queue them ?And then how to ?


    Another quetion is if I launch "large size( like 4k bytes )" reading operation in APP , then the USB bus dirver( Mircosoft's USBD.sys driver) will divided it into 512B( bulk type ) ? that will transfer 8 times , until all these 8 transfer is over, the IRP will be completed ?
  • Tim_RobertsTim_Roberts Member - All Emails Posts: 12,914
    On 6/15/2010 9:51 AM, xxxxx@gmail.com wrote:
    > I think you mean that I should have to realization a FILE_FLAG_OVERLAPPED driver ?
    >

    The driver probably does not have to change. You're already creating an
    URB and sending it to the device, then returning STATUS_PENDING while
    the URB runs. Right?

    It is your application that has to specify FILE_FLAG_OVERLAPPED when it
    calls CreateFile.

    > If I don't follow this , hwo to do ? The APP Just reads , In my driver , making the IRP pending and queue them ?And then how to ?
    >

    As I said, there are many web sites that describe overlapped I/O on
    Windows. If you're going to have 3 requests outstanding, you create 3
    OVERLAPPED structures, each with an event inside it. You then call
    ReadFile three times in a row. Then, as an example, you can call
    WaitForMultipleObjects to wait for one of the requests to complete. You
    call GetOverlappedResult to make sure it completed successfully, then
    you process it, and resubmit it by calling ReadFile again.


    > Another quetion is if I launch "large size( like 4k bytes )" reading operation in APP , then the USB bus dirver( Mircosoft's USBD.sys driver) will divided it into 512B( bulk type ) ? that will transfer 8 times , until all these 8 transfer is over, the IRP will be completed ?
    >

    Yes. The limit for a single transfer depends on the operating system,
    but up to 1MB or 2MB is safe.

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

    Tim Roberts, [email protected]
    Providenza & Boekelheide, Inc.

  • CyberPunkerXCyberPunkerX Member Posts: 89
    Thanks all above .

    Yesterday , I got to know the URB's UrbLink field.

    I think if I can do it like this :
    To form a chain of URBs to ONE IRP and then send to the USBD.sys, so , a series of USB bus's sequential millisecond can be occupied by this BIG IRP . So It is me to help the host controller do its schedule operation.
  • Doron_HolanDoron_Holan Member - All Emails Posts: 10,428
    Sorry no. UrbLink is not supported. You need to send multiple IRPs. Each IRP has one URB in it

    d

    -----Original Message-----
    From: xxxxx@lists.osr.com [mailto:xxxxx@lists.osr.com] On Behalf Of xxxxx@gmail.com
    Sent: Wednesday, June 16, 2010 8:55 PM
    To: Windows System Software Devs Interest List
    Subject: RE:[ntdev] Re: How to increase the speed of ?USB reading?


    Thanks all above .

    Yesterday , I got to know the URB's UrbLink field.

    I think if I can do it like this :
    To form a chain of URBs to ONE IRP and then send to the USBD.sys, so , a series of USB bus's sequential millisecond can be occupied by this BIG IRP . So It is me to help the host controller do its schedule operation.




    ---
    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
    d
  • CyberPunkerXCyberPunkerX Member Posts: 89
    When it is not supported ?

    Why not supported ?
  • Tim_RobertsTim_Roberts Member - All Emails Posts: 12,914
    On 6/16/2010 8:55 PM, xxxxx@gmail.com wrote:
    >
    > Thanks all above .
    >
    > Yesterday , I got to know the URB's UrbLink field.
    >
    > I think if I can do it like this :
    > To form a chain of URBs to ONE IRP and then send to the USBD.sys, so , a series of USB bus's sequential millisecond can be occupied by this BIG IRP . So It is me to help the host controller do its schedule operation.
    >

    This is completely unnecessary. If you submit several bulk URBs, enough
    to fill up the whole frame, then the host controller will schedule them
    all as tightly as possible. You cannot do any better than that.

    In virtually every case, unless you have hit the maximum bus throughput,
    poor USB performance is caused by not having enough requests queued up.
    If you do not have a request queued up and ready to go by the time the
    host controller is scheduling a frame, then you will MISS that entire
    frame. USB is all scheduled in advanced. You have to plan ahead. You
    can't handle things one at a time.

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

    Tim Roberts, [email protected]
    Providenza & Boekelheide, Inc.

  • CyberPunkerXCyberPunkerX Member Posts: 89
    Ok, I know it.

    I want to know: on the ?Isochronous Transfers? occasion, is this way the standard technique ?
  • Tim_RobertsTim_Roberts Member - All Emails Posts: 12,914
    On 6/17/2010 11:38 PM, xxxxx@gmail.com wrote:
    > I want to know: on the ?Isochronous Transfers? occasion, is this way the standard technique ?
    >

    I'm not sure I understand the question. The type of endpoint is not
    relevant. The concepts are all the same. If you need maximum
    throughput through the pipe, then you must have several requests
    outstanding, so that there is always a second one ready to go as soon as
    the first one completes.

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

    Tim Roberts, [email protected]
    Providenza & Boekelheide, Inc.

  • CyberPunkerXCyberPunkerX Member Posts: 89
    I just mean , if it was a USB deivce that perform Isochronous Transfers, in order to receive data as fast as possible from it , using the UrbLink field is a good idea ? Or, is the standard technique ?
  • Chris_AseltineChris_Aseltine Member Posts: 1,228
    CyberPunkerX wrote:

    > in order to receive data as fast as possible from it , using the
    > UrbLink field is a good idea ? Or, is the standard technique ?

    No, and no. Are you dense? Doron just told you no, it's not supported. The docs say the field is reserved and must be NULL.
  • CyberPunkerXCyberPunkerX Member Posts: 89
    OK , thanks
  • Tim_RobertsTim_Roberts Member - All Emails Posts: 12,914
    You wrote:
    >>>
    I just mean , if it was a USB deivce that perform Isochronous Transfers, in order to receive data as fast as possible from it , using the UrbLink field is a good idea ? Or, is the standard technique ?
    <<<

    No, the UrbLink field serves no purpose at all. It is useless.

    I will say it again. To get maximum throughput, just make sure you have several requests outstanding at all times, so there's always another request ready to go when one completes. USB is just not that fast -- it isn't that hard to keep up.

    You are guilty of premature optimization here. You don't start exploring wild options until you know whether you have a problem or not.
    --
    Tim Roberts, xxxxx@probo.com
    Providenza & Boekelheide, Inc.

    Tim Roberts, [email protected]
    Providenza & Boekelheide, Inc.

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Upcoming OSR Seminars
Writing WDF Drivers 25 Feb 2019 OSR Seminar Space
Developing Minifilters 8 April 2019 OSR Seminar Space