Re: What does struct usb_tt * tt used for?
Alan Stern <[email protected]>
| Newsgroups | gmane.linux.usb.devel |
|---|---|
| Message-ID | <[email protected]> |
On Mon, 10 Sep 2007, jidong xiao wrote:
> I saw there is a struct usb_tt *tt as an element of struct
> usb_device, and there also is a struct usb_tt tt as an element of
> struct usb_hub, I am confused by these two "tt". I thought only hubs
> can have tt, so what does the pointer tt within struct usb_deivce used
> for normal usb device?In other words, why do we prepare a pointer tt
> for struct usb_device?
>
> In particular, inside hub_port_init(),
>
> /* Set up TT records, if needed */
> if (hdev->tt) {
> udev->tt = hdev->tt;
> udev->ttport = hdev->ttport;
> } else if (udev->speed != USB_SPEED_HIGH
> && hdev->speed == USB_SPEED_HIGH) {
> udev->tt = &hub->tt;
> udev->ttport = port1;
> }
>
> I don't understand this entire "if statement",say, if hdev->tt is
> true, this means it is a high speed hub, so what? else if the device
> is full/low speed and the hub is high speed, still so what?
You can't understand this unless you know how TTs work. A TT
(Transaction Translator) converts USB packets between high speed and
full/low speed. Thus, if you have a full- or low-speed device attached
to a high-speed hub, the computer will have to communicate with the hub
at high speed. Then the only way for the computer to communicate with
the device is to send the device's packets at high speed to the hub's
TT, which will then send those packets at full- or low-speed to the
device and will send the device's replies at high speed back to the
computer.
That's why usb_device structures need to have a tt pointer: If the
device runs at full or low speed and it is behind a high-speed hub,
then the device structure's tt points to the tt member of the hub
structure. The pointer is needed because that TT is the one the
computer must use when it wants to communicate with the device.
There are some lengthy descriptions of all this in the USB 2.0 spec,
sections 8.5, 11.14, and 11.15.
Alan Stern
-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2005.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
[email protected]
To unsubscribe, use the last form field at:
https://lists.sourceforge.net/lists/listinfo/linux-usb-devel