Author Topic: USB Packet scheduling  (Read 7923 times)

nvd

  • Member
  • ***
  • Posts: 42
USB Packet scheduling
« on: February 19, 2013, 09:49:02 am »
Hello,
 On control Endpoint, we have the Setupphase-Dataphase-Statusphase format of communication.
 Each phase is supposed to be atomic sequence. i.e Setupphase - (Token-data-H/S) is always atomic.

 In case of Control transfers Is it also necessary that the complete sequence of Setupphase-Dataphase-Statusphase is also Atomic?
 i.e if Host is talking to two Target devices on control EP at same time,
 the transfers will look like   SetupT1-DataT1-StatusT1 .......SetupT2-DataT2-StatusT2


 Otherwise if Host is capable and needs to talk to different target devices on control endpoint at same time,
 then it can schedule SetupT1-DATAT1-SetUpT2-StatusT1-DataT2-Status-T2  etc.


Jan Axelson

  • Administrator
  • Frequent Contributor
  • *****
  • Posts: 3033
    • Lakeview Research
Re: USB Packet scheduling
« Reply #1 on: February 19, 2013, 10:12:24 am »
Yes, the host can schedule other transactions of any type and to any device in between the stages of a control transfer in progress.

And if a device is NAKing in the Data or Status stage, the host can schedule other transactions before retrying the transaction that was NAKed.

nvd

  • Member
  • ***
  • Posts: 42
Re: USB Packet scheduling
« Reply #2 on: February 19, 2013, 11:24:33 am »
Thanks Jan! :)

Bret

  • Frequent Contributor
  • ****
  • Posts: 68
Re: USB Packet scheduling
« Reply #3 on: February 19, 2013, 11:45:59 am »
In my implementation, I saw this as a potentially disastrous scenario and took pains to avoid it.  There is no way to tell with 100% certainty in 100% of the situations which transaction (1, 2, ..., n) is associated with which packet when they overlap in time and use the same end point (especially with the possibility of NAK's).  There is a potential for mass confusion on either the host or device end.

In my host implementation, I queue all control transactions to end point 0 and make sure the previous one is done before the next one starts.

I have no idea if any other host implementation does anything like this or not.

Jan Axelson

  • Administrator
  • Frequent Contributor
  • *****
  • Posts: 3033
    • Lakeview Research
Re: USB Packet scheduling
« Reply #4 on: February 19, 2013, 11:57:35 am »
I wasn't thinking about scheduling simultaneous control transfers to endpoint zero on a single device. I don't think the spec forbids it but would be surprised if any host did that.

Tsuneo

  • Frequent Contributor
  • ****
  • Posts: 145
Re: USB Packet scheduling
« Reply #5 on: February 21, 2013, 02:00:05 am »
Quote
nvd:
Otherwise if Host is capable and needs to talk to different target devices on control endpoint at same time,
 then it can schedule SetupT1-DATAT1-SetUpT2-StatusT1-DataT2-Status-T2  etc.
Such a sequence is often seen when a hub is sit on the bus. OS hub driver periodically scans hub ports using Get_Port_Status, though it is also waiting the status change notification over the interrupt EP. This Get_Port_Status sometimes occurs in a sequence of control transfer on the device at the hub port.

Quote
Jan Axelson:
I wasn't thinking about scheduling simultaneous control transfers to endpoint zero on a single device.
Ya, of course. "Simultaneous control transfers to endpoint zero on a single device" has different meaning - cancel to the last control transfer.

8.5.3 Control Transfers on the USB 2.0 spec
If a Setup transaction is received by an endpoint before a previously initiated control transfer is completed, the device must abort the current transfer/operation and handle the new control Setup transaction.


Tsuneo

Jan Axelson

  • Administrator
  • Frequent Contributor
  • *****
  • Posts: 3033
    • Lakeview Research
Re: USB Packet scheduling
« Reply #6 on: February 21, 2013, 10:42:01 am »
Yes of course, thanks Tsuneo, one control transfer at a time per endpoint!