USB maximum packet size transfer

Hi all,

I want to ask you very basic question…
In Usbsamp sample WDK driver, i found that in bulk write and read, it use maximum transfer buffer size for test board usb device = 64 *1024 and maximum transfer size = 256.
What does it mean? How can we define this value for our specific device?

Thank you
Anton

The maximum bulk transfer packet sizes for low speed, full speed, and high
speed USB connections are defined by the USB standard. You cannot change
these. 256 is the maximum transfer size for a bulk USB 1.x transfer. I
think it is 512 for USB 2.0, if I remember the values correctly.

The maximum transfer size of 64K is something that was established by the
firmware in the USB board in question. What you define for your board is up
to you, since presumably you are writing the firmware.

Look at http://www.usb.org/developers/docs/usb_20_040908.zip
for the 2.0 spec, particularly note section 5.8.3.
joe

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of xxxxx@ohio.edu
Sent: Monday, November 24, 2008 9:28 PM
To: Windows System Software Devs Interest List
Subject: [ntdev] USB maximum packet size transfer

Hi all,

I want to ask you very basic question…
In Usbsamp sample WDK driver, i found that in bulk write and read, it use
maximum transfer buffer size for test board usb device = 64 *1024 and
maximum transfer size = 256.
What does it mean? How can we define this value for our specific device?

Thank you
Anton


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


This message has been scanned for viruses and
dangerous content by MailScanner, and is
believed to be clean.

Ok, After I read the spesification I found that maximum packet size (data payload) for fullspeed is 64 bytes and maximum bandwidth is 1.2 Mbytes/s. So, what is the relationship between maximum packet size and maximum bandwidth itself??

And I’m still confused about maximum transfer buffer size for test board usb device in usbsamp or osrusbfx2 sample driver in wdk. Why the value must be set to 64 *1024?

Thank you,
Anton

The max transfer buffer size is purely based on the protocol that your device communicates over the wire. If your device has a deep fifo the buffer can be very large. If your device has very little memory, the max xfer will probably be very small.

d

-----Original Message-----
From: xxxxx@lists.osr.com [mailto:xxxxx@lists.osr.com] On Behalf Of xxxxx@ohio.edu
Sent: Monday, November 24, 2008 8:32 PM
To: Windows System Software Devs Interest List
Subject: RE:[ntdev] USB maximum packet size transfer

Ok, After I read the spesification I found that maximum packet size (data payload) for fullspeed is 64 bytes and maximum bandwidth is 1.2 Mbytes/s. So, what is the relationship between maximum packet size and maximum bandwidth itself??

And I’m still confused about maximum transfer buffer size for test board usb device in usbsamp or osrusbfx2 sample driver in wdk. Why the value must be set to 64 *1024?

Thank you,
Anton


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

See below…

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of xxxxx@ohio.edu
Sent: Monday, November 24, 2008 11:32 PM
To: Windows System Software Devs Interest List
Subject: RE:[ntdev] USB maximum packet size transfer

Ok, After I read the spesification I found that maximum packet size (data
payload) for fullspeed is 64 bytes and maximum bandwidth is 1.2 Mbytes/s.
So, what is the relationship between maximum packet size and maximum
bandwidth itself??
****
Because packets are sent at specific intervals, and because there is a
certain overhead to send any packet at all. That is, if you sent a bunch of
8-byte packets, there are some number of overhead bytes so the total
available bandwidth is reduced by the amount of time required to send the
overhead. So if you send a 256-byte packet, and the overhead is n bytes,
you have to send 256+n bytes, and the number of packets you can send per
second is ultimately limited by the total amount of time required to send.
Think of it as (physical bandwidth) / (256+n) packets per second. If you
send an 8-byte packet, it’s (physical bandwidth) / (8+n) packets per second.
The effective bandwidth is much lower (if n==8, then 50% of the transmission
bandwidth is available for sending 8-byte packets; but for 256-byte packets,
something like 97% of the bandwidth can be used. These are rough numbers,
because the USB framing time also gets factored in; that’s what all those
complex tables are in the USB Standard document)
****
And I’m still confused about maximum transfer buffer size for test board usb
device in usbsamp or osrusbfx2 sample driver in wdk. Why the value must be
set to 64 *1024?
****
64*1024=65536. That is, the creator of the firmware of the test board put a
64K buffer in RAM on that board, and you can consider this a whimsical
decision on the part of the implementor of that firmware. Perhaps it was a
coin toss: heads, 64K, tails, 32K. Or tails, 128K, but it came up heads, so
it was 64K. Nothing deeper than that. On your board, YOU get to make a
decision about the maximum number of bytes that can be transferred. For
example, if you are implementing a USB interface to a 512GB hard drive, you
might say that the longest transfer is 512GB. My recollection of the
original Intel test board was that it just allowed you to write bytes to the
buffer, and a Read request would read bytes out of the buffer, and the
buffer was only 64K. Perhaps the implementor rolled a die, and for the
number of dots that came up, 2**n * 1024 bytes of buffer would be created,
and a 6 was rolled. 2**6 = 64. So there’s nothing special about that
limit. When you write your hardware spec, you might roll two dice. You
will have *some* basis for making a decision; perhaps it is random, perhaps
it is based on some physical characteristic of the implementation of your
hardware, such as having a 64K RAM chip as the only memory. Or 2MB of RAM.

joe

****
Thank you,
Anton


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


This message has been scanned for viruses and
dangerous content by MailScanner, and is
believed to be clean.

Thanks for the detail explanation.
I understand it now

Joseph M. Newcomer wrote:

The maximum bulk transfer packet sizes for low speed, full speed, and high
speed USB connections are defined by the USB standard. You cannot change
these. 256 is the maximum transfer size for a bulk USB 1.x transfer. I
think it is 512 for USB 2.0, if I remember the values correctly.

Just for the sake of the archive, I’d like to clarify a couple of points
here. There is a difference between “maximum transfer size” and
“maximum packet size”. The maximum packet size for an endpoint is
specified in the configuration descriptor; for a bulk pipe, a full-speed
(USB 1.x) endpoint can have a packet size of 8, 16, 32, or 64 bytes. A
high-speed (2.0) bulk pipe is always 512. Low speed devices cannot have
bulk pipes.

“Maximum transfer size” has several meanings. Each of the host
controller drivers has an upper limit on the size of a single transfer
(which gets chopped up into packet-sized requests for the hardware), and
that limit varies based on the controller type and the operating system
version. There’s a knowledge-base article on this:
http://msdn.microsoft.com/en-us/library/ms790486.aspx

For the most part, the maximum transfer size is not related to the
device. The USB spec has a successful flow control scheme, so that the
device can simply stop accepting more data when its full, or signal that
its queues are empty in the other direction.


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

There is another source of maximum transfer buffer size. There is an artifact of host controller design and the corresponding USB stack implementation that sometimes imposes a limit to the size of a buffer in a single URB. I believe this limit is different depending on the OS version and the particular host controller. I don’t have all of the data on what those limits are, but I can tell you what I did in WinUsb to ensure that the transfers worked on all systems down to XP.

For high-speed devices, WinUsb imposes a 4MB transfer size limit, for low and full speed the limit is 256KB. For control endpoints (all speeds) the limit is 4KB. The actual limits may be higher than this, but I’m pretty certain they aren’t lower.

I believe, however, that in this particular example, it is referring to the buffering size on the device, which imposed another transfer size limit. Do note that these limits have nothing to do with the endpoint’s MaxPacketSize.

-----Original Message-----
From: xxxxx@lists.osr.com [mailto:xxxxx@lists.osr.com] On Behalf Of Doron Holan
Sent: Monday, November 24, 2008 8:46 PM
To: Windows System Software Devs Interest List
Subject: RE: RE:[ntdev] USB maximum packet size transfer

The max transfer buffer size is purely based on the protocol that your device communicates over the wire. If your device has a deep fifo the buffer can be very large. If your device has very little memory, the max xfer will probably be very small.

d

-----Original Message-----
From: xxxxx@lists.osr.com [mailto:xxxxx@lists.osr.com] On Behalf Of xxxxx@ohio.edu
Sent: Monday, November 24, 2008 8:32 PM
To: Windows System Software Devs Interest List
Subject: RE:[ntdev] USB maximum packet size transfer

Ok, After I read the spesification I found that maximum packet size (data payload) for fullspeed is 64 bytes and maximum bandwidth is 1.2 Mbytes/s. So, what is the relationship between maximum packet size and maximum bandwidth itself??

And I’m still confused about maximum transfer buffer size for test board usb device in usbsamp or osrusbfx2 sample driver in wdk. Why the value must be set to 64 *1024?

Thank you,
Anton


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


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

That’s interesting information. Is there any documentation that could be
cited to support that…I’d like to know, so I can tell my students.
joe

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Randy Aull
Sent: Tuesday, November 25, 2008 2:55 PM
To: Windows System Software Devs Interest List
Subject: RE: RE:[ntdev] USB maximum packet size transfer

There is another source of maximum transfer buffer size. There is an
artifact of host controller design and the corresponding USB stack
implementation that sometimes imposes a limit to the size of a buffer in a
single URB. I believe this limit is different depending on the OS version
and the particular host controller. I don’t have all of the data on what
those limits are, but I can tell you what I did in WinUsb to ensure that the
transfers worked on all systems down to XP.

For high-speed devices, WinUsb imposes a 4MB transfer size limit, for low
and full speed the limit is 256KB. For control endpoints (all speeds) the
limit is 4KB. The actual limits may be higher than this, but I’m pretty
certain they aren’t lower.

I believe, however, that in this particular example, it is referring to the
buffering size on the device, which imposed another transfer size limit. Do
note that these limits have nothing to do with the endpoint’s MaxPacketSize.

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Doron Holan
Sent: Monday, November 24, 2008 8:46 PM
To: Windows System Software Devs Interest List
Subject: RE: RE:[ntdev] USB maximum packet size transfer

The max transfer buffer size is purely based on the protocol that your
device communicates over the wire. If your device has a deep fifo the
buffer can be very large. If your device has very little memory, the max
xfer will probably be very small.

d

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of xxxxx@ohio.edu
Sent: Monday, November 24, 2008 8:32 PM
To: Windows System Software Devs Interest List
Subject: RE:[ntdev] USB maximum packet size transfer

Ok, After I read the spesification I found that maximum packet size (data
payload) for fullspeed is 64 bytes and maximum bandwidth is 1.2 Mbytes/s.
So, what is the relationship between maximum packet size and maximum
bandwidth itself??

And I’m still confused about maximum transfer buffer size for test board usb
device in usbsamp or osrusbfx2 sample driver in wdk. Why the value must be
set to 64 *1024?

Thank you,
Anton


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


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


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


This message has been scanned for viruses and
dangerous content by MailScanner, and is
believed to be clean.

Joseph M. Newcomer wrote:

That’s interesting information. Is there any documentation that could be
cited to support that…I’d like to know, so I can tell my students.

If you’re talking about the host controller dependent maximum transfer
size, I cited the canonical MSDN article on this earlier in the thread:

http://msdn.microsoft.com/en-us/library/ms790486.aspx

If you’re talking specifically about the WinUSB limit, I have to think
that Randy’s assertion is as canonical as it gets


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

By the way, the WinUSB limit is programmatically discoverable through the WinUsb APIs (WinUSB_GetPipePolicy(MAXIMUM_TRANSFER_SIZE)). In the future there may be controllers/scenarios where these values change.

-----Original Message-----
From: xxxxx@lists.osr.com [mailto:xxxxx@lists.osr.com] On Behalf Of Tim Roberts
Sent: Tuesday, November 25, 2008 2:24 PM
To: Windows System Software Devs Interest List
Subject: Re: [ntdev] USB maximum packet size transfer

Joseph M. Newcomer wrote:

That’s interesting information. Is there any documentation that could be
cited to support that…I’d like to know, so I can tell my students.

If you’re talking about the host controller dependent maximum transfer
size, I cited the canonical MSDN article on this earlier in the thread:

http://msdn.microsoft.com/en-us/library/ms790486.aspx

If you’re talking specifically about the WinUSB limit, I have to think
that Randy’s assertion is as canonical as it gets


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


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. That’s good information.
joe

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Randy Aull
Sent: Tuesday, November 25, 2008 9:38 PM
To: Windows System Software Devs Interest List
Subject: RE: [ntdev] USB maximum packet size transfer

By the way, the WinUSB limit is programmatically discoverable through the
WinUsb APIs (WinUSB_GetPipePolicy(MAXIMUM_TRANSFER_SIZE)). In the future
there may be controllers/scenarios where these values change.

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Tim Roberts
Sent: Tuesday, November 25, 2008 2:24 PM
To: Windows System Software Devs Interest List
Subject: Re: [ntdev] USB maximum packet size transfer

Joseph M. Newcomer wrote:

That’s interesting information. Is there any documentation that could be
cited to support that…I’d like to know, so I can tell my students.

If you’re talking about the host controller dependent maximum transfer
size, I cited the canonical MSDN article on this earlier in the thread:

http://msdn.microsoft.com/en-us/library/ms790486.aspx

If you’re talking specifically about the WinUSB limit, I have to think
that Randy’s assertion is as canonical as it gets


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


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


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


This message has been scanned for viruses and
dangerous content by MailScanner, and is
believed to be clean.