xref: /OK3568_Linux_fs/kernel/Documentation/usb/usbip_protocol.rst (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1*4882a593Smuzhiyun===============
2*4882a593SmuzhiyunUSB/IP protocol
3*4882a593Smuzhiyun===============
4*4882a593Smuzhiyun
5*4882a593SmuzhiyunPRELIMINARY DRAFT, MAY CONTAIN MISTAKES!
6*4882a593Smuzhiyun28 Jun 2011
7*4882a593Smuzhiyun
8*4882a593SmuzhiyunThe USB/IP protocol follows a server/client architecture. The server exports the
9*4882a593SmuzhiyunUSB devices and the clients imports them. The device driver for the exported
10*4882a593SmuzhiyunUSB device runs on the client machine.
11*4882a593Smuzhiyun
12*4882a593SmuzhiyunThe client may ask for the list of the exported USB devices. To get the list the
13*4882a593Smuzhiyunclient opens a TCP/IP connection towards the server, and sends an OP_REQ_DEVLIST
14*4882a593Smuzhiyunpacket on top of the TCP/IP connection (so the actual OP_REQ_DEVLIST may be sent
15*4882a593Smuzhiyunin one or more pieces at the low level transport layer). The server sends back
16*4882a593Smuzhiyunthe OP_REP_DEVLIST packet which lists the exported USB devices. Finally the
17*4882a593SmuzhiyunTCP/IP connection is closed.
18*4882a593Smuzhiyun
19*4882a593Smuzhiyun::
20*4882a593Smuzhiyun
21*4882a593Smuzhiyun virtual host controller                                 usb host
22*4882a593Smuzhiyun      "client"                                           "server"
23*4882a593Smuzhiyun  (imports USB devices)                             (exports USB devices)
24*4882a593Smuzhiyun          |                                                 |
25*4882a593Smuzhiyun          |                  OP_REQ_DEVLIST                 |
26*4882a593Smuzhiyun          | ----------------------------------------------> |
27*4882a593Smuzhiyun          |                                                 |
28*4882a593Smuzhiyun          |                  OP_REP_DEVLIST                 |
29*4882a593Smuzhiyun          | <---------------------------------------------- |
30*4882a593Smuzhiyun          |                                                 |
31*4882a593Smuzhiyun
32*4882a593SmuzhiyunOnce the client knows the list of exported USB devices it may decide to use one
33*4882a593Smuzhiyunof them. First the client opens a TCP/IP connection towards the server and
34*4882a593Smuzhiyunsends an OP_REQ_IMPORT packet. The server replies with OP_REP_IMPORT. If the
35*4882a593Smuzhiyunimport was successful the TCP/IP connection remains open and will be used
36*4882a593Smuzhiyunto transfer the URB traffic between the client and the server. The client may
37*4882a593Smuzhiyunsend two types of packets: the USBIP_CMD_SUBMIT to submit an URB, and
38*4882a593SmuzhiyunUSBIP_CMD_UNLINK to unlink a previously submitted URB. The answers of the
39*4882a593Smuzhiyunserver may be USBIP_RET_SUBMIT and USBIP_RET_UNLINK respectively.
40*4882a593Smuzhiyun
41*4882a593Smuzhiyun::
42*4882a593Smuzhiyun
43*4882a593Smuzhiyun virtual host controller                                 usb host
44*4882a593Smuzhiyun      "client"                                           "server"
45*4882a593Smuzhiyun  (imports USB devices)                             (exports USB devices)
46*4882a593Smuzhiyun          |                                                 |
47*4882a593Smuzhiyun          |                  OP_REQ_IMPORT                  |
48*4882a593Smuzhiyun          | ----------------------------------------------> |
49*4882a593Smuzhiyun          |                                                 |
50*4882a593Smuzhiyun          |                  OP_REP_IMPORT                  |
51*4882a593Smuzhiyun          | <---------------------------------------------- |
52*4882a593Smuzhiyun          |                                                 |
53*4882a593Smuzhiyun          |                                                 |
54*4882a593Smuzhiyun          |            USBIP_CMD_SUBMIT(seqnum = n)         |
55*4882a593Smuzhiyun          | ----------------------------------------------> |
56*4882a593Smuzhiyun          |                                                 |
57*4882a593Smuzhiyun          |            USBIP_RET_SUBMIT(seqnum = n)         |
58*4882a593Smuzhiyun          | <---------------------------------------------- |
59*4882a593Smuzhiyun          |                        .                        |
60*4882a593Smuzhiyun          |                        :                        |
61*4882a593Smuzhiyun          |                                                 |
62*4882a593Smuzhiyun          |            USBIP_CMD_SUBMIT(seqnum = m)         |
63*4882a593Smuzhiyun          | ----------------------------------------------> |
64*4882a593Smuzhiyun          |                                                 |
65*4882a593Smuzhiyun          |            USBIP_CMD_SUBMIT(seqnum = m+1)       |
66*4882a593Smuzhiyun          | ----------------------------------------------> |
67*4882a593Smuzhiyun          |                                                 |
68*4882a593Smuzhiyun          |            USBIP_CMD_SUBMIT(seqnum = m+2)       |
69*4882a593Smuzhiyun          | ----------------------------------------------> |
70*4882a593Smuzhiyun          |                                                 |
71*4882a593Smuzhiyun          |            USBIP_RET_SUBMIT(seqnum = m)         |
72*4882a593Smuzhiyun          | <---------------------------------------------- |
73*4882a593Smuzhiyun          |                                                 |
74*4882a593Smuzhiyun          |            USBIP_CMD_SUBMIT(seqnum = m+3)       |
75*4882a593Smuzhiyun          | ----------------------------------------------> |
76*4882a593Smuzhiyun          |                                                 |
77*4882a593Smuzhiyun          |            USBIP_RET_SUBMIT(seqnum = m+1)       |
78*4882a593Smuzhiyun          | <---------------------------------------------- |
79*4882a593Smuzhiyun          |                                                 |
80*4882a593Smuzhiyun          |            USBIP_CMD_SUBMIT(seqnum = m+4)       |
81*4882a593Smuzhiyun          | ----------------------------------------------> |
82*4882a593Smuzhiyun          |                                                 |
83*4882a593Smuzhiyun          |            USBIP_RET_SUBMIT(seqnum = m+2)       |
84*4882a593Smuzhiyun          | <---------------------------------------------- |
85*4882a593Smuzhiyun          |                        .                        |
86*4882a593Smuzhiyun          |                        :                        |
87*4882a593Smuzhiyun          |                                                 |
88*4882a593Smuzhiyun          |               USBIP_CMD_UNLINK                  |
89*4882a593Smuzhiyun          | ----------------------------------------------> |
90*4882a593Smuzhiyun          |                                                 |
91*4882a593Smuzhiyun          |               USBIP_RET_UNLINK                  |
92*4882a593Smuzhiyun          | <---------------------------------------------- |
93*4882a593Smuzhiyun          |                                                 |
94*4882a593Smuzhiyun
95*4882a593SmuzhiyunThe fields are in network (big endian) byte order meaning that the most significant
96*4882a593Smuzhiyunbyte (MSB) is stored at the lowest address.
97*4882a593Smuzhiyun
98*4882a593Smuzhiyun
99*4882a593SmuzhiyunOP_REQ_DEVLIST:
100*4882a593Smuzhiyun	Retrieve the list of exported USB devices.
101*4882a593Smuzhiyun
102*4882a593Smuzhiyun+-----------+--------+------------+---------------------------------------------------+
103*4882a593Smuzhiyun| Offset    | Length | Value      | Description                                       |
104*4882a593Smuzhiyun+===========+========+============+===================================================+
105*4882a593Smuzhiyun| 0         | 2      | 0x0100     | Binary-coded decimal USBIP version number: v1.0.0 |
106*4882a593Smuzhiyun+-----------+--------+------------+---------------------------------------------------+
107*4882a593Smuzhiyun| 2         | 2      | 0x8005     | Command code: Retrieve the list of exported USB   |
108*4882a593Smuzhiyun|           |        |            | devices.                                          |
109*4882a593Smuzhiyun+-----------+--------+------------+---------------------------------------------------+
110*4882a593Smuzhiyun| 4         | 4      | 0x00000000 | Status: unused, shall be set to 0                 |
111*4882a593Smuzhiyun+-----------+--------+------------+---------------------------------------------------+
112*4882a593Smuzhiyun
113*4882a593SmuzhiyunOP_REP_DEVLIST:
114*4882a593Smuzhiyun	Reply with the list of exported USB devices.
115*4882a593Smuzhiyun
116*4882a593Smuzhiyun+-----------+--------+------------+---------------------------------------------------+
117*4882a593Smuzhiyun| Offset    | Length | Value      | Description                                       |
118*4882a593Smuzhiyun+===========+========+============+===================================================+
119*4882a593Smuzhiyun| 0         | 2      | 0x0100     | Binary-coded decimal USBIP version number: v1.0.0.|
120*4882a593Smuzhiyun+-----------+--------+------------+---------------------------------------------------+
121*4882a593Smuzhiyun| 2         | 2      | 0x0005     | Reply code: The list of exported USB devices.     |
122*4882a593Smuzhiyun+-----------+--------+------------+---------------------------------------------------+
123*4882a593Smuzhiyun| 4         | 4      | 0x00000000 | Status: 0 for OK                                  |
124*4882a593Smuzhiyun+-----------+--------+------------+---------------------------------------------------+
125*4882a593Smuzhiyun| 8         | 4      | n          | Number of exported devices: 0 means no exported   |
126*4882a593Smuzhiyun|           |        |            | devices.                                          |
127*4882a593Smuzhiyun+-----------+--------+------------+---------------------------------------------------+
128*4882a593Smuzhiyun| 0x0C      |        |            | From now on the exported n devices are described, |
129*4882a593Smuzhiyun|           |        |            | if any. If no devices are exported the message    |
130*4882a593Smuzhiyun|           |        |            | ends with the previous "number of exported        |
131*4882a593Smuzhiyun|           |        |            | devices" field.                                   |
132*4882a593Smuzhiyun+-----------+--------+------------+---------------------------------------------------+
133*4882a593Smuzhiyun|           | 256    |            | path: Path of the device on the host exporting the|
134*4882a593Smuzhiyun|           |        |            | USB device, string closed with zero byte, e.g.    |
135*4882a593Smuzhiyun|           |        |            | "/sys/devices/pci0000:00/0000:00:1d.1/usb3/3-2"   |
136*4882a593Smuzhiyun|           |        |            | The unused bytes shall be filled with zero        |
137*4882a593Smuzhiyun|           |        |            | bytes.                                            |
138*4882a593Smuzhiyun+-----------+--------+------------+---------------------------------------------------+
139*4882a593Smuzhiyun| 0x10C     | 32     |            | busid: Bus ID of the exported device, string      |
140*4882a593Smuzhiyun|           |        |            | closed with zero byte, e.g. "3-2". The unused     |
141*4882a593Smuzhiyun|           |        |            | bytes shall be filled with zero bytes.            |
142*4882a593Smuzhiyun+-----------+--------+------------+---------------------------------------------------+
143*4882a593Smuzhiyun| 0x12C     | 4      |            | busnum                                            |
144*4882a593Smuzhiyun+-----------+--------+------------+---------------------------------------------------+
145*4882a593Smuzhiyun| 0x130     | 4      |            | devnum                                            |
146*4882a593Smuzhiyun+-----------+--------+------------+---------------------------------------------------+
147*4882a593Smuzhiyun| 0x134     | 4      |            | speed                                             |
148*4882a593Smuzhiyun+-----------+--------+------------+---------------------------------------------------+
149*4882a593Smuzhiyun| 0x138     | 2      |            | idVendor                                          |
150*4882a593Smuzhiyun+-----------+--------+------------+---------------------------------------------------+
151*4882a593Smuzhiyun| 0x13A     | 2      |            | idProduct                                         |
152*4882a593Smuzhiyun+-----------+--------+------------+---------------------------------------------------+
153*4882a593Smuzhiyun| 0x13C     | 2      |            | bcdDevice                                         |
154*4882a593Smuzhiyun+-----------+--------+------------+---------------------------------------------------+
155*4882a593Smuzhiyun| 0x13E     | 1      |            | bDeviceClass                                      |
156*4882a593Smuzhiyun+-----------+--------+------------+---------------------------------------------------+
157*4882a593Smuzhiyun| 0x13F     | 1      |            | bDeviceSubClass                                   |
158*4882a593Smuzhiyun+-----------+--------+------------+---------------------------------------------------+
159*4882a593Smuzhiyun| 0x140     | 1      |            | bDeviceProtocol                                   |
160*4882a593Smuzhiyun+-----------+--------+------------+---------------------------------------------------+
161*4882a593Smuzhiyun| 0x141     | 1      |            | bConfigurationValue                               |
162*4882a593Smuzhiyun+-----------+--------+------------+---------------------------------------------------+
163*4882a593Smuzhiyun| 0x142     | 1      |            | bNumConfigurations                                |
164*4882a593Smuzhiyun+-----------+--------+------------+---------------------------------------------------+
165*4882a593Smuzhiyun| 0x143     | 1      |            | bNumInterfaces                                    |
166*4882a593Smuzhiyun+-----------+--------+------------+---------------------------------------------------+
167*4882a593Smuzhiyun| 0x144     |        | m_0        | From now on each interface is described, all      |
168*4882a593Smuzhiyun|           |        |            | together bNumInterfaces times, with the           |
169*4882a593Smuzhiyun|           |        |            | the following 4 fields:                           |
170*4882a593Smuzhiyun+-----------+--------+------------+---------------------------------------------------+
171*4882a593Smuzhiyun|           | 1      |            | bInterfaceClass                                   |
172*4882a593Smuzhiyun+-----------+--------+------------+---------------------------------------------------+
173*4882a593Smuzhiyun| 0x145     | 1      |            | bInterfaceSubClass                                |
174*4882a593Smuzhiyun+-----------+--------+------------+---------------------------------------------------+
175*4882a593Smuzhiyun| 0x146     | 1      |            | bInterfaceProtocol                                |
176*4882a593Smuzhiyun+-----------+--------+------------+---------------------------------------------------+
177*4882a593Smuzhiyun| 0x147     | 1      |            | padding byte for alignment, shall be set to zero  |
178*4882a593Smuzhiyun+-----------+--------+------------+---------------------------------------------------+
179*4882a593Smuzhiyun| 0xC +     |        |            | The second exported USB device starts at i=1      |
180*4882a593Smuzhiyun| i*0x138 + |        |            | with the busid field.                             |
181*4882a593Smuzhiyun| m_(i-1)*4 |        |            |                                                   |
182*4882a593Smuzhiyun+-----------+--------+------------+---------------------------------------------------+
183*4882a593Smuzhiyun
184*4882a593SmuzhiyunOP_REQ_IMPORT:
185*4882a593Smuzhiyun	Request to import (attach) a remote USB device.
186*4882a593Smuzhiyun
187*4882a593Smuzhiyun+-----------+--------+------------+---------------------------------------------------+
188*4882a593Smuzhiyun| Offset    | Length | Value      | Description                                       |
189*4882a593Smuzhiyun+===========+========+============+===================================================+
190*4882a593Smuzhiyun| 0         | 2      | 0x0100     | Binary-coded decimal USBIP version number: v1.0.0 |
191*4882a593Smuzhiyun+-----------+--------+------------+---------------------------------------------------+
192*4882a593Smuzhiyun| 2         | 2      | 0x8003     | Command code: import a remote USB device.         |
193*4882a593Smuzhiyun+-----------+--------+------------+---------------------------------------------------+
194*4882a593Smuzhiyun| 4         | 4      | 0x00000000 | Status: unused, shall be set to 0                 |
195*4882a593Smuzhiyun+-----------+--------+------------+---------------------------------------------------+
196*4882a593Smuzhiyun| 8         | 32     |            | busid: the busid of the exported device on the    |
197*4882a593Smuzhiyun|           |        |            | remote host. The possible values are taken        |
198*4882a593Smuzhiyun|           |        |            | from the message field OP_REP_DEVLIST.busid.      |
199*4882a593Smuzhiyun|           |        |            | A string closed with zero, the unused bytes       |
200*4882a593Smuzhiyun|           |        |            | shall be filled with zeros.                       |
201*4882a593Smuzhiyun+-----------+--------+------------+---------------------------------------------------+
202*4882a593Smuzhiyun
203*4882a593SmuzhiyunOP_REP_IMPORT:
204*4882a593Smuzhiyun	Reply to import (attach) a remote USB device.
205*4882a593Smuzhiyun
206*4882a593Smuzhiyun+-----------+--------+------------+---------------------------------------------------+
207*4882a593Smuzhiyun| Offset    | Length | Value      | Description                                       |
208*4882a593Smuzhiyun+===========+========+============+===================================================+
209*4882a593Smuzhiyun| 0         | 2      | 0x0100     | Binary-coded decimal USBIP version number: v1.0.0 |
210*4882a593Smuzhiyun+-----------+--------+------------+---------------------------------------------------+
211*4882a593Smuzhiyun| 2         | 2      | 0x0003     | Reply code: Reply to import.                      |
212*4882a593Smuzhiyun+-----------+--------+------------+---------------------------------------------------+
213*4882a593Smuzhiyun| 4         | 4      | 0x00000000 | Status:                                           |
214*4882a593Smuzhiyun|           |        |            |                                                   |
215*4882a593Smuzhiyun|           |        |            |   - 0 for OK                                      |
216*4882a593Smuzhiyun|           |        |            |   - 1 for error                                   |
217*4882a593Smuzhiyun+-----------+--------+------------+---------------------------------------------------+
218*4882a593Smuzhiyun| 8         |        |            | From now on comes the details of the imported     |
219*4882a593Smuzhiyun|           |        |            | device, if the previous status field was OK (0),  |
220*4882a593Smuzhiyun|           |        |            | otherwise the reply ends with the status field.   |
221*4882a593Smuzhiyun+-----------+--------+------------+---------------------------------------------------+
222*4882a593Smuzhiyun|           | 256    |            | path: Path of the device on the host exporting the|
223*4882a593Smuzhiyun|           |        |            | USB device, string closed with zero byte, e.g.    |
224*4882a593Smuzhiyun|           |        |            | "/sys/devices/pci0000:00/0000:00:1d.1/usb3/3-2"   |
225*4882a593Smuzhiyun|           |        |            | The unused bytes shall be filled with zero        |
226*4882a593Smuzhiyun|           |        |            | bytes.                                            |
227*4882a593Smuzhiyun+-----------+--------+------------+---------------------------------------------------+
228*4882a593Smuzhiyun| 0x108     | 32     |            | busid: Bus ID of the exported device, string      |
229*4882a593Smuzhiyun|           |        |            | closed with zero byte, e.g. "3-2". The unused     |
230*4882a593Smuzhiyun|           |        |            | bytes shall be filled with zero bytes.            |
231*4882a593Smuzhiyun+-----------+--------+------------+---------------------------------------------------+
232*4882a593Smuzhiyun| 0x128     | 4      |            | busnum                                            |
233*4882a593Smuzhiyun+-----------+--------+------------+---------------------------------------------------+
234*4882a593Smuzhiyun| 0x12C     | 4      |            | devnum                                            |
235*4882a593Smuzhiyun+-----------+--------+------------+---------------------------------------------------+
236*4882a593Smuzhiyun| 0x130     | 4      |            | speed                                             |
237*4882a593Smuzhiyun+-----------+--------+------------+---------------------------------------------------+
238*4882a593Smuzhiyun| 0x134     | 2      |            | idVendor                                          |
239*4882a593Smuzhiyun+-----------+--------+------------+---------------------------------------------------+
240*4882a593Smuzhiyun| 0x136     | 2      |            | idProduct                                         |
241*4882a593Smuzhiyun+-----------+--------+------------+---------------------------------------------------+
242*4882a593Smuzhiyun| 0x138     | 2      |            | bcdDevice                                         |
243*4882a593Smuzhiyun+-----------+--------+------------+---------------------------------------------------+
244*4882a593Smuzhiyun| 0x139     | 1      |            | bDeviceClass                                      |
245*4882a593Smuzhiyun+-----------+--------+------------+---------------------------------------------------+
246*4882a593Smuzhiyun| 0x13A     | 1      |            | bDeviceSubClass                                   |
247*4882a593Smuzhiyun+-----------+--------+------------+---------------------------------------------------+
248*4882a593Smuzhiyun| 0x13B     | 1      |            | bDeviceProtocol                                   |
249*4882a593Smuzhiyun+-----------+--------+------------+---------------------------------------------------+
250*4882a593Smuzhiyun| 0x13C     | 1      |            | bConfigurationValue                               |
251*4882a593Smuzhiyun+-----------+--------+------------+---------------------------------------------------+
252*4882a593Smuzhiyun| 0x13D     | 1      |            | bNumConfigurations                                |
253*4882a593Smuzhiyun+-----------+--------+------------+---------------------------------------------------+
254*4882a593Smuzhiyun| 0x13E     | 1      |            | bNumInterfaces                                    |
255*4882a593Smuzhiyun+-----------+--------+------------+---------------------------------------------------+
256*4882a593Smuzhiyun
257*4882a593SmuzhiyunUSBIP_CMD_SUBMIT:
258*4882a593Smuzhiyun	Submit an URB
259*4882a593Smuzhiyun
260*4882a593Smuzhiyun+-----------+--------+------------+---------------------------------------------------+
261*4882a593Smuzhiyun| Offset    | Length | Value      | Description                                       |
262*4882a593Smuzhiyun+===========+========+============+===================================================+
263*4882a593Smuzhiyun| 0         | 4      | 0x00000001 | command: Submit an URB                            |
264*4882a593Smuzhiyun+-----------+--------+------------+---------------------------------------------------+
265*4882a593Smuzhiyun| 4         | 4      |            | seqnum: the sequence number of the URB to submit  |
266*4882a593Smuzhiyun+-----------+--------+------------+---------------------------------------------------+
267*4882a593Smuzhiyun| 8         | 4      |            | devid                                             |
268*4882a593Smuzhiyun+-----------+--------+------------+---------------------------------------------------+
269*4882a593Smuzhiyun| 0xC       | 4      |            | direction:                                        |
270*4882a593Smuzhiyun|           |        |            |                                                   |
271*4882a593Smuzhiyun|           |        |            |    - 0: USBIP_DIR_OUT                             |
272*4882a593Smuzhiyun|           |        |            |    - 1: USBIP_DIR_IN                              |
273*4882a593Smuzhiyun+-----------+--------+------------+---------------------------------------------------+
274*4882a593Smuzhiyun| 0x10      | 4      |            | ep: endpoint number, possible values are: 0...15  |
275*4882a593Smuzhiyun+-----------+--------+------------+---------------------------------------------------+
276*4882a593Smuzhiyun| 0x14      | 4      |            | transfer_flags: possible values depend on the     |
277*4882a593Smuzhiyun|           |        |            | URB transfer type, see below                      |
278*4882a593Smuzhiyun+-----------+--------+------------+---------------------------------------------------+
279*4882a593Smuzhiyun| 0x18      | 4      |            | transfer_buffer_length                            |
280*4882a593Smuzhiyun+-----------+--------+------------+---------------------------------------------------+
281*4882a593Smuzhiyun| 0x1C      | 4      |            | start_frame: specify the selected frame to        |
282*4882a593Smuzhiyun|           |        |            | transmit an ISO frame, ignored if URB_ISO_ASAP    |
283*4882a593Smuzhiyun|           |        |            | is specified at transfer_flags                    |
284*4882a593Smuzhiyun+-----------+--------+------------+---------------------------------------------------+
285*4882a593Smuzhiyun| 0x20      | 4      |            | number_of_packets: number of ISO packets          |
286*4882a593Smuzhiyun+-----------+--------+------------+---------------------------------------------------+
287*4882a593Smuzhiyun| 0x24      | 4      |            | interval: maximum time for the request on the     |
288*4882a593Smuzhiyun|           |        |            | server-side host controller                       |
289*4882a593Smuzhiyun+-----------+--------+------------+---------------------------------------------------+
290*4882a593Smuzhiyun| 0x28      | 8      |            | setup: data bytes for USB setup, filled with      |
291*4882a593Smuzhiyun|           |        |            | zeros if not used                                 |
292*4882a593Smuzhiyun+-----------+--------+------------+---------------------------------------------------+
293*4882a593Smuzhiyun| 0x30      |        |            | URB data. For ISO transfers the padding between   |
294*4882a593Smuzhiyun|           |        |            | each ISO packets is not transmitted.              |
295*4882a593Smuzhiyun+-----------+--------+------------+---------------------------------------------------+
296*4882a593Smuzhiyun
297*4882a593Smuzhiyun
298*4882a593Smuzhiyun +-------------------------+------------+---------+-----------+----------+-------------+
299*4882a593Smuzhiyun | Allowed transfer_flags  | value      | control | interrupt | bulk     | isochronous |
300*4882a593Smuzhiyun +=========================+============+=========+===========+==========+=============+
301*4882a593Smuzhiyun | URB_SHORT_NOT_OK        | 0x00000001 | only in | only in   | only in  | no          |
302*4882a593Smuzhiyun +-------------------------+------------+---------+-----------+----------+-------------+
303*4882a593Smuzhiyun | URB_ISO_ASAP            | 0x00000002 | no      | no        | no       | yes         |
304*4882a593Smuzhiyun +-------------------------+------------+---------+-----------+----------+-------------+
305*4882a593Smuzhiyun | URB_NO_TRANSFER_DMA_MAP | 0x00000004 | yes     | yes       | yes      | yes         |
306*4882a593Smuzhiyun +-------------------------+------------+---------+-----------+----------+-------------+
307*4882a593Smuzhiyun | URB_ZERO_PACKET         | 0x00000040 | no      | no        | only out | no          |
308*4882a593Smuzhiyun +-------------------------+------------+---------+-----------+----------+-------------+
309*4882a593Smuzhiyun | URB_NO_INTERRUPT        | 0x00000080 | yes     | yes       | yes      | yes         |
310*4882a593Smuzhiyun +-------------------------+------------+---------+-----------+----------+-------------+
311*4882a593Smuzhiyun | URB_FREE_BUFFER         | 0x00000100 | yes     | yes       | yes      | yes         |
312*4882a593Smuzhiyun +-------------------------+------------+---------+-----------+----------+-------------+
313*4882a593Smuzhiyun | URB_DIR_MASK            | 0x00000200 | yes     | yes       | yes      | yes         |
314*4882a593Smuzhiyun +-------------------------+------------+---------+-----------+----------+-------------+
315*4882a593Smuzhiyun
316*4882a593Smuzhiyun
317*4882a593SmuzhiyunUSBIP_RET_SUBMIT:
318*4882a593Smuzhiyun	Reply for submitting an URB
319*4882a593Smuzhiyun
320*4882a593Smuzhiyun+-----------+--------+------------+---------------------------------------------------+
321*4882a593Smuzhiyun| Offset    | Length | Value      | Description                                       |
322*4882a593Smuzhiyun+===========+========+============+===================================================+
323*4882a593Smuzhiyun| 0         | 4      | 0x00000003 | command                                           |
324*4882a593Smuzhiyun+-----------+--------+------------+---------------------------------------------------+
325*4882a593Smuzhiyun| 4         | 4      |            | seqnum: URB sequence number                       |
326*4882a593Smuzhiyun+-----------+--------+------------+---------------------------------------------------+
327*4882a593Smuzhiyun| 8         | 4      |            | devid                                             |
328*4882a593Smuzhiyun+-----------+--------+------------+---------------------------------------------------+
329*4882a593Smuzhiyun| 0xC       | 4      |            | direction:                                        |
330*4882a593Smuzhiyun|           |        |            |                                                   |
331*4882a593Smuzhiyun|           |        |            |    - 0: USBIP_DIR_OUT                             |
332*4882a593Smuzhiyun|           |        |            |    - 1: USBIP_DIR_IN                              |
333*4882a593Smuzhiyun+-----------+--------+------------+---------------------------------------------------+
334*4882a593Smuzhiyun| 0x10      | 4      |            | ep: endpoint number                               |
335*4882a593Smuzhiyun+-----------+--------+------------+---------------------------------------------------+
336*4882a593Smuzhiyun| 0x14      | 4      |            | status: zero for successful URB transaction,      |
337*4882a593Smuzhiyun|           |        |            | otherwise some kind of error happened.            |
338*4882a593Smuzhiyun+-----------+--------+------------+---------------------------------------------------+
339*4882a593Smuzhiyun| 0x18      | 4      | n          | actual_length: number of URB data bytes           |
340*4882a593Smuzhiyun+-----------+--------+------------+---------------------------------------------------+
341*4882a593Smuzhiyun| 0x1C      | 4      |            | start_frame: for an ISO frame the actually        |
342*4882a593Smuzhiyun|           |        |            | selected frame for transmit.                      |
343*4882a593Smuzhiyun+-----------+--------+------------+---------------------------------------------------+
344*4882a593Smuzhiyun| 0x20      | 4      |            | number_of_packets                                 |
345*4882a593Smuzhiyun+-----------+--------+------------+---------------------------------------------------+
346*4882a593Smuzhiyun| 0x24      | 4      |            | error_count                                       |
347*4882a593Smuzhiyun+-----------+--------+------------+---------------------------------------------------+
348*4882a593Smuzhiyun| 0x28      | 8      |            | setup: data bytes for USB setup, filled with      |
349*4882a593Smuzhiyun|           |        |            | zeros if not used                                 |
350*4882a593Smuzhiyun+-----------+--------+------------+---------------------------------------------------+
351*4882a593Smuzhiyun| 0x30      | n      |            | URB data bytes. For ISO transfers the padding     |
352*4882a593Smuzhiyun|           |        |            | between each ISO packets is not transmitted.      |
353*4882a593Smuzhiyun+-----------+--------+------------+---------------------------------------------------+
354*4882a593Smuzhiyun
355*4882a593SmuzhiyunUSBIP_CMD_UNLINK:
356*4882a593Smuzhiyun	Unlink an URB
357*4882a593Smuzhiyun
358*4882a593Smuzhiyun+-----------+--------+------------+---------------------------------------------------+
359*4882a593Smuzhiyun| Offset    | Length | Value      | Description                                       |
360*4882a593Smuzhiyun+===========+========+============+===================================================+
361*4882a593Smuzhiyun| 0         | 4      | 0x00000002 | command: URB unlink command                       |
362*4882a593Smuzhiyun+-----------+--------+------------+---------------------------------------------------+
363*4882a593Smuzhiyun| 4         | 4      |            | seqnum: URB sequence number to unlink:            |
364*4882a593Smuzhiyun|           |        |            |                                                   |
365*4882a593Smuzhiyun|           |        |            | FIXME:                                            |
366*4882a593Smuzhiyun|           |        |            |    is this so?                                    |
367*4882a593Smuzhiyun+-----------+--------+------------+---------------------------------------------------+
368*4882a593Smuzhiyun| 8         | 4      |            | devid                                             |
369*4882a593Smuzhiyun+-----------+--------+------------+---------------------------------------------------+
370*4882a593Smuzhiyun| 0xC       | 4      |            | direction:                                        |
371*4882a593Smuzhiyun|           |        |            |                                                   |
372*4882a593Smuzhiyun|           |        |            |    - 0: USBIP_DIR_OUT                             |
373*4882a593Smuzhiyun|           |        |            |    - 1: USBIP_DIR_IN                              |
374*4882a593Smuzhiyun+-----------+--------+------------+---------------------------------------------------+
375*4882a593Smuzhiyun| 0x10      | 4      |            | ep: endpoint number: zero                         |
376*4882a593Smuzhiyun+-----------+--------+------------+---------------------------------------------------+
377*4882a593Smuzhiyun| 0x14      | 4      |            | seqnum: the URB sequence number given previously  |
378*4882a593Smuzhiyun|           |        |            | at USBIP_CMD_SUBMIT.seqnum field                  |
379*4882a593Smuzhiyun+-----------+--------+------------+---------------------------------------------------+
380*4882a593Smuzhiyun| 0x30      | n      |            | URB data bytes. For ISO transfers the padding     |
381*4882a593Smuzhiyun|           |        |            | between each ISO packets is not transmitted.      |
382*4882a593Smuzhiyun+-----------+--------+------------+---------------------------------------------------+
383*4882a593Smuzhiyun
384*4882a593SmuzhiyunUSBIP_RET_UNLINK:
385*4882a593Smuzhiyun	Reply for URB unlink
386*4882a593Smuzhiyun
387*4882a593Smuzhiyun+-----------+--------+------------+---------------------------------------------------+
388*4882a593Smuzhiyun| Offset    | Length | Value      | Description                                       |
389*4882a593Smuzhiyun+===========+========+============+===================================================+
390*4882a593Smuzhiyun| 0         | 4      | 0x00000004 | command: reply for the URB unlink command         |
391*4882a593Smuzhiyun+-----------+--------+------------+---------------------------------------------------+
392*4882a593Smuzhiyun| 4         | 4      |            | seqnum: the unlinked URB sequence number          |
393*4882a593Smuzhiyun+-----------+--------+------------+---------------------------------------------------+
394*4882a593Smuzhiyun| 8         | 4      |            | devid                                             |
395*4882a593Smuzhiyun+-----------+--------+------------+---------------------------------------------------+
396*4882a593Smuzhiyun| 0xC       | 4      |            | direction:                                        |
397*4882a593Smuzhiyun|           |        |            |                                                   |
398*4882a593Smuzhiyun|           |        |            |    - 0: USBIP_DIR_OUT                             |
399*4882a593Smuzhiyun|           |        |            |    - 1: USBIP_DIR_IN                              |
400*4882a593Smuzhiyun+-----------+--------+------------+---------------------------------------------------+
401*4882a593Smuzhiyun| 0x10      | 4      |            | ep: endpoint number                               |
402*4882a593Smuzhiyun+-----------+--------+------------+---------------------------------------------------+
403*4882a593Smuzhiyun| 0x14      | 4      |            | status: This is the value contained in the        |
404*4882a593Smuzhiyun|           |        |            | urb->status in the URB completition handler.      |
405*4882a593Smuzhiyun|           |        |            |                                                   |
406*4882a593Smuzhiyun|           |        |            | FIXME:                                            |
407*4882a593Smuzhiyun|           |        |            |      a better explanation needed.                 |
408*4882a593Smuzhiyun+-----------+--------+------------+---------------------------------------------------+
409*4882a593Smuzhiyun| 0x30      | n      |            | URB data bytes. For ISO transfers the padding     |
410*4882a593Smuzhiyun|           |        |            | between each ISO packets is not transmitted.      |
411*4882a593Smuzhiyun+-----------+--------+------------+---------------------------------------------------+
412