|
High Speed USB Transactions
We have looked at the
mechanisms for communicating at 480 Mb/s. We now examine the packet
formats in more depth, and then see how these are used to provide
the various transactions: Control,
Interrupt, Bulk and Isochronous.x
|
|
|
Subjects covered
in this part...
|
|
|
|
The
New Packets
The packet types which
have been added for high speed are:
- DATA2
- MDATA
- NYET
- ERR
- SPLIT
- PING
The table on the right
gives brief details of the purposes of the six new packet types.
|
|
Packet
Identifier
|
Usage
|
DATA2
|
This data packet
token has been added as part of a system for controlling multiple
isochronous IN packets during one microframe at high speed.
For each isochronous
IN packet requested, the suffix of the DATAx PID represents
the remaining number of packets to be transferred during the
current micro-frame.
|
MDATA
|
This data packet
token has been added as part of a system for controlling multiple
isochronous OUT packets during one microframe at high speed.
All but the last
packet sent during a microframe use the MDATA PID. The last
packet sent uses DATA0, DATA1 or DATA2 depending on whether
one, two or three packets were sent.
|
NYET
|
NYET handshake
packets are used in 2 different high speed situations.
One use is when
a hub wishes to respond to a 'complete split' transaction
to say that it is has not yet been completed.
The other use is
during the high speed control or bulk OUT PING protocol. It
means that the endpoint has accepted the data but is not yet
ready for further data.
|
ERR
|
Used
during the high speed split protocol by a hub, to indicate that
there was an error on the full or low speed bus. |
SPLIT
|
This packet introduces
a Start Split transaction or a Complete Split transaction.
Split transactions
are used at high speed to communicate to a hub, the details
of a low or full speed transaction which it is expected to
handle, and to get back the results.
|
PING
|
A PING packet is
used on high speed Control and Bulk OUT endpoints. They may
be sent by the host to establish whether the endpoint is ready
to accept a DATA0 or DATA1 packet, and will result in an ACK
or a NAK packet from the device.
This is an efficiency
improvement, as at full or low speed, the data packet has
to be sent in full, and only then can the endpoint respond
with a NAK.
|
|
For the sake of completeness
we will now look at the packet formats for all the available packets
type, including the ones already covered for low and full speed.
There are five different
packet formats based on which PID the packet starts with.
|
|
|
Token
Packet
Sync
|
PID
|
ADDR
|
ENDP
|
CRC5
|
EOP
|
|
8
bits
|
7
bits
|
4
bits
|
5
bits
|
|
Used for SETUP, OUT,
IN and PING packets. They are always the first packet in
a transaction, identifying the targeted endpoint, and the purpose
of the transaction.
(The SOF packet is also
defined as a Token packet, but has a slightly different format and
purpose, which is described below.)
|
|
The token packet contains
two addressing elements:
Address (7 bits)
This device address can
address up to 127 devices. Address 0 is reserved for a device which
has not yet had its address set.
Endpoint number (4 bits)
There can be up to 16
possible endpoints in a device in each direction. The direction
is implicit in the PID. OUT, SETUP and PING PIDs will refer to the
OUT endpoint, and an IN PID will refer to the IN endpoint.
|
Data
Packet
Sync
|
PID
|
DATA
|
CRC16
|
EOP
|
|
8
bits
|
(0-1024)
x 8 bits
|
16
bits
|
|
Used for DATA0, DATA1,
DATA2 and MDATA packets. If a transaction has a data stage
this is the packet format used.
|
|
DATA0 and DATA1
PIDs are used in Low and Full speed links as part of an
error-checking system. When used, all data packets on a particular
endpoint use an alternating DATA0 / DATA1 so that the endpoint
knows if a received packet is the one it is expecting. If
it is not it will still acknowledge (ACK) the packet as it
is correctly received, but will then discard the data, assuming
that it has been re-sent because the host missed seeing the
ACK the first time it sent the data packet.
DATA2 (along
with DATA1 and DATA0) is used in High Speed links as part
of a system for controlling multiple isochronous IN packets
during one microframe at high speed.
MDATA (along
with DATA2, DATA1 and DATA0) is used in High Speed links as
part of a system for controlling multiple isochronous OUT
packets during one microframe at high speed.
|
|
Handshake
Packet
Used for ACK, NAK, STALL
and NYET packets. This is the packet format used in the status
stage of a transaction, when required.
|
|
ACK
Receiver acknowledges
receiving error free packet.
NAK
Receiving device
cannot accept data or transmitting device cannot send data.
STALL
Endpoint is halted,
or control pipe request is not supported.
NYET
No response yet
from receiver (high speed only).
|
|
SOF
Packet
Sync
|
PID
|
Frame
No.
|
CRC5
|
EOP
|
|
8
bits
|
11
bits
|
5
bits
|
|
The Start of Frame packet
is sent every 1 ms on full speed links. The frame is used as a time
frame in which to schedule the data transfers which are required.
For example, an isochronous endpoint will be assigned one transfer
per frame.
|
|
Frames and Microframes
On a low speed
link, to preserve bandwidth, a Keep Alive signal is sent every
millisecond, instead of a Start of Frame packet. In fact Keep
Alives may be sent by a hub on a low speed link whenever the
hub sees a full speed token packet.
At
high speed the 1 ms frame is divided into 8 microframes of
125 us. A SOF is sent at the start of each of these 8 microframes,
each having the same frame number, which then increments every
1 ms frame.
|
|
Split
Packet
Sync
|
PID
|
Hub
Addr
|
SC
|
Port
|
S
|
E
|
ET
|
CRC5
|
EOP
|
|
8
bits
|
7
bits
|
1
bit
|
7
bits |
1
bit |
1
bit |
2
bits |
5
bits
|
|
The SPLIT packet
is the first packet in either a Start Split transaction or a Complete
Split transaction, sent to a high speed hub when it is handling
a low or full speed device.
|
|
Control, Interrupt
or Bulk Endpoints
SC |
Start
/ Complete |
0 =
Start, 1 = Complete |
S |
Speed |
0 =
Full, 1 = Low |
E |
not
used |
0 |
ET |
Endpoint
Type |
00 = Control
01 = Isochronous
10 = Bulk
11 = Interrupt
|
Isochronous Endpoints
SC |
Start
/ Complete |
0 =
Start, 1 = Complete |
S and
E |
Start
and End |
00 = HS data is
middle of FS data payload
01 = HS data is
end of FS data payload
10 = HS data is
start of FS data payload
11 = HS data is
all of FS data payload
|
ET |
Endpoint
Type |
00
= Control
01 = Isochronous
10 = Bulk
11 = Interrupt
|
|
|
|
|
|
High
Speed Bulk Transactions
These work much like
full speed bulk transactions. The differences are:
- The maximum packet
size can only be specifed as 512 bytes.
- A more efficient method
of doing OUT transfers has been introduced, involving the use
of PING transactions, and the new NYET handshake packet.
Ping
Protocol
Before sending an OUT
transaction to a bulk endpoint, the host controller may send a PING
packet. The response to the PING will be ACK or NAK. ACK means that
the endpoint is ready to accept an OUT transaction of maximum packet
size for the endpoint. NAK means it is not. The host may continue
to send PINGs after a NAK, or it may choose to wait for a number
of microframes before re-trying.
On high speed Bulk OUT
endpoints, the endpoint descriptor value bInterval is required
to specify the NAK rate of the endpoint. The specification is misleading
when it defines this value. The value represents the number of microframes
which the host would have to wait, after receiving a NAK in response
to a PING, before a further PING is guaranteed to elicit an ACK
response. 0 means the endpoint never NAKs.
A further new feature
is that, after a successful OUT transaction, the endpoint may respond
with ACK to indicate that it is already prepared to accept a further
packet, or NYET to indicate that it received the data correctly,
but is not yet ready to accept further data.
|
|
BULK Transfer Error
Control Flow
|
|
High
Speed Isochronous Transfers
High speed isochronous
transfers have an extended control system to allow up to 3 isochronous
transactions per microframe, allowing a data rate of up to 192 Mb/s.
(The specification refers to an isochronous endpoint with more than
1 packet per microframe as a 'High Bandwidth' endpoint.)
As isochronous transactions
do not include a acknowledgement (handshake) packet, a system was
specified which allows the recipient to be aware, if a data packet
is lost, which one it was*.
Isochronous IN
When requesting IN transactions,
the device packages them in DATA2, DATA1 or DATA0 packets, depending
on how many packets per microframe are specified, and which one
it is. See diagram on the right.
|
|
Isochronous IN Protocol
|
Isochronous OUT
When sending OUT transactions,
the host packages them either in MDATA or DATA0 DATA1 or DATA2 packets,
as shown in the diagram on the right
*In fact this does
not apply to Isochronous OUT transfers with three transactions per
microframe because the first two packets use MDATA as a PID.
|
|
Isochronous OUT Protocol
|
|
High
Speed Interrupt Transactions
These work much as for
full and low speed, except that the endpoint descriptor may specify
up to 3 interrupt transactions per microframe, allowing a data rate
of up to 192 Mb/s. (The specification refers to an interrupt endpoint
with more than 1 packet per microframe as a 'High Bandwidth' endpoint.)
The protocol is the same
as for full and low speed, in that DATA0 and DATA1 packets are alternated.
If more than one transaction
per frame is specified and a transaction is NAKed, then the host
should attempt no more transactions on that endpoint within the
same microframe.
|
|
Interrupt Transfer Error
Control Flow
|
|
High
Speed Control Transfers
High speed control transfers
are the same as full and low speed transfers, with the following
exceptions:
- For high speed control
endpoints, the maximum packet size for the data stage is fixed
at 64 bytes.
- During a data phase,
using an OUT PID, the transaction follows the rules above for
a Bulk OUT transaction, including the PING protocol.
|
|
Error Control
Flow
SETUP STAGE
Notice
that it is not permitted for a device to respond to a SETUP with
a NAK, STALL or NYET.
DATA STAGE
(same as
for high speed bulk transfer)
STATUS
STAGE
(same as
for bulk transfer)
|
|
Split
Transactions
Transaction Translator
Split transactions form
a high speed only protocol between host controllers and high speed
hubs, which are handling full or low speed traffic. This is the
means by which the full or low speed traffic is prevented from degrading
the high speed bus performance. Each high speed hub is required
to have a 'Transaction Translator' which handles the full or low
speed transactions to particular ports.
Packet Sequences
To overcome the difference
in speeds, each full or low speed transaction is split into two
parts on the high speed bus; a Start Split Transaction and a Complete
Split Transaction. In between, the Transaction Translator independently
handles the full or low speed transaction.
The illustration to the
right shows how the host defines the required full or low speed
transaction, allows the hub to deal with the transaction at that
speed and then checks back later for the result.
The actual packet sequence
in a split transaction varies, depending on the type of transaction
involved, and will be described in more detail, in the following
paragraphs.
This will be a brief
summary of what to expect, however the full USB specification contains
masses of detail which would be needed to actually implement a host
controller or hub.
|
|
Transaction Translator
This is a much simplified
diagram of the transaction translator within a high speed hub.
Example Split Transaction
Sequence
This illustrates a typical
split transaction sequence; in this case a split interrupt IN.
|
|
Split
Bulk OUT Transaction
For a split bulk OUT
transaction, the host sends a Start Split packet specifying the
hub address and port number, and speed (full), with the 'endpoint
type' set to 'bulk'.
It then sends an OUT
token packet to identify the full speed transaction type, device
and endpoint address, followed by the data packet for onward transmission
to the target endpoint.
If the Transaction Translator
receives these packets correctly and has an available buffer, it
will respond with an ACK packet, otherwise it will respond with
a NAK packet.
At this point the Transaction
Translator proceeds to send this transaction to the specified full
speed endpoint, and to get a response, which it stores, ready to
pass back to the host during a Complete Split transaction.
When the host controller
decides it is appropriate, it checks for the result by issuing a
Complete Split transaction. The Complete Split packet and the OUT
token packet are the same as for the Start Split transaction, except
for the Start/Complete bit of the packet. This allows the hub to
verify which transaction it is to present the results of.
If the full speed transaction
is not yet completed, the hub will respond with a NYET packet and
the host will attempt the Compete Split transaction sometime later.
If it is complete, then a packet containing the actual result
(ACK, NAK or STALL) is sent to the host.
|
|
Split Bulk OUT Transaction
|
|
Split
Bulk IN Transaction
A split bulk IN transaction
is similar to a split bulk OUT, except that the DATA0/1 packet occurs
during the Complete Split stage because it is now part of the response.
If data was returned then the data packet appears in lieu of a handshake
packet.
The actual ACK of the
full speed transaction was sent by the Transaction Translator to
the device on receiving the DATA0 or DATA1 packet from the device,
and the host will keep track of which data it has received. If it
fails to receive a valid packet it will retry the Complete Split
Transaction.
|
|
Split Bulk IN Transaction
|
|
Periodic
Split Transactions
Interrupt and
Isochronous
Split Interrupt
and Isochronous transactions need special treatment because
of the bandwidth guarantee which they offer. Every full /
low speed device using these endpoint types, which is added
to the bus, is given a guaranteed allocation on the full /
low speed bus, which also has to be conveyed on the high speed
bus. The mechanism is complex and described in full in chapter
11 of the USB specification.
The result of this
mechanism is that periodic transactions on the full or low
speed bus are transferred in packets of data of at most 188
bytes.
|
So a longer transaction,
which can be up to 1023 bytes long for an isochronous endpoint,
will be transferred in multiple Start Split transactions for
OUT transfers, or multiple Complete Split transactions for
IN transfers.
Furthermore, on
periodic IN transactions, data received by the hub from the
device within a given microframe is sent in response to a
Complete Split, even though it represents only part of the
full or low speed data packet. A full speed interrupt IN packet
of, say, 64 bytes, which spans two microframes, will be conveyed
in up to two Complete Splits. The data packet in the first
part will use an MDATA PID to indicate that it is not complete.
Isochronous IN
transactions are similar, but can span up to 6 microframes.
|
|
Split
Interrupt OUT Transaction
For an interrupt OUT
transaction the maximum data size is 64 bytes, so these are always
transferred within a single Start Split transaction. There is no
need for a handshake packet from the hub, as the interrupt will
not be retried in the same frame, if missed.
As with a Bulk transaction,
the Complete Split will elicit a handshake packet from the device
if it responded with one itself, or with ERR if there was an error
on the full or low speed bus, or NYET if the Transaction Translator
has not completed its task.
|
|
Split Interrupt OUT
Transaction
|
|
Split
Interrupt IN Transaction
For a split interrupt
IN, we issue a Start Split (without expecting a handshake from the
hub).
The Complete Split may
result in the complete data packet (DATA0 / DATA1) being returned,
but it is also possible that during the microframe, only part of
the data was so far collected, in which case an MDATA PID is used
to indicate that a further Complete Split will be necessary in the
next microframe.
Handshake packets NAK
or STALL will indicate that the device responded with this packet.
ERR indicates that there was an error on the full or low speed bus.
NYET indicates that the Transaction Translator has not completed
its task.
|
|
Split Interrupt IN Transaction
|
|
Split
Isochronous OUT Transaction
On the face of it, this
is the simplest split transaction. There is no handshake from the
hub, and no Complete Split, as the delivery of isochronous transactions
is not checked.
It is complicated by
the fact that single full speed isochronous transactions are divided
up into separate Start Split transactions of at most 188 bytes each,
sent one per microframe.
The Start Split packet
has its Start and End bits set to identify which part
of the payload is being transferred.
|
|
Split Isochronous OUT
Transaction
|
|
Split
Isochronous IN Transaction
For a split isochronous
IN, we issue a Start Split (without expecting a handshake from the
hub).
The Complete Split may
result in the complete data packet (DATA0) being returned, but it
is also possible that during the microframe, only part of the data
was so far collected, in which case an MDATA PID is used to indicate
that a further Complete Split will be necessary in the next microframe.
ERR indicates that there
was an error on the full or low speed bus. NYET indicates that the
Transaction Translator has not completed its task.
|
|
Split Isochronous IN
Transaction
|
|
Summary
We have examined how
each type of data transfer works at high speed.
|
|
|
Coming up...
...to be announced...
|
|
Forward |
Copyright
© 2006-2008 MQP Electronics Ltd
|
|
|
ADVERTISEMENT
Packet-Master
USB Bus Analysers and Generators from MQP Electronics
|
|
|
|
|
- Radically
cut development time
- Intuitive
graphical interface
- Detailed
timing information
- Full analysis
of all standard events
- Results
can be printed
- Optional
class analysis modules
|
|
|