Mauro Carvalho Chehab | d80b500 | 2019-04-15 23:56:01 -0300 | [diff] [blame] | 1 | =============== |
| 2 | USB/IP protocol |
| 3 | =============== |
| 4 | |
Hongren Zheng (Zenithal) | 17af793 | 2021-03-31 01:00:13 +0800 | [diff] [blame] | 5 | Architecture |
| 6 | ============ |
Márton Németh | c8742cf | 2011-08-22 09:52:47 +0800 | [diff] [blame] | 7 | |
| 8 | The USB/IP protocol follows a server/client architecture. The server exports the |
Hongren Zheng (Zenithal) | 17af793 | 2021-03-31 01:00:13 +0800 | [diff] [blame] | 9 | USB devices and the clients import them. The device driver for the exported |
Márton Németh | c8742cf | 2011-08-22 09:52:47 +0800 | [diff] [blame] | 10 | USB device runs on the client machine. |
| 11 | |
| 12 | The client may ask for the list of the exported USB devices. To get the list the |
Hongren Zheng (Zenithal) | 17af793 | 2021-03-31 01:00:13 +0800 | [diff] [blame] | 13 | client opens a TCP/IP connection to the server, and sends an OP_REQ_DEVLIST |
Márton Németh | c8742cf | 2011-08-22 09:52:47 +0800 | [diff] [blame] | 14 | packet on top of the TCP/IP connection (so the actual OP_REQ_DEVLIST may be sent |
| 15 | in one or more pieces at the low level transport layer). The server sends back |
| 16 | the OP_REP_DEVLIST packet which lists the exported USB devices. Finally the |
| 17 | TCP/IP connection is closed. |
| 18 | |
Mauro Carvalho Chehab | d80b500 | 2019-04-15 23:56:01 -0300 | [diff] [blame] | 19 | :: |
| 20 | |
Márton Németh | c8742cf | 2011-08-22 09:52:47 +0800 | [diff] [blame] | 21 | virtual host controller usb host |
| 22 | "client" "server" |
| 23 | (imports USB devices) (exports USB devices) |
| 24 | | | |
| 25 | | OP_REQ_DEVLIST | |
| 26 | | ----------------------------------------------> | |
| 27 | | | |
| 28 | | OP_REP_DEVLIST | |
| 29 | | <---------------------------------------------- | |
| 30 | | | |
| 31 | |
| 32 | Once the client knows the list of exported USB devices it may decide to use one |
Hongren Zheng (Zenithal) | 17af793 | 2021-03-31 01:00:13 +0800 | [diff] [blame] | 33 | of them. First the client opens a TCP/IP connection to the server and |
Márton Németh | c8742cf | 2011-08-22 09:52:47 +0800 | [diff] [blame] | 34 | sends an OP_REQ_IMPORT packet. The server replies with OP_REP_IMPORT. If the |
| 35 | import was successful the TCP/IP connection remains open and will be used |
Masanari Iida | 73e2918 | 2012-04-06 23:33:52 +0900 | [diff] [blame] | 36 | to transfer the URB traffic between the client and the server. The client may |
Márton Németh | c8742cf | 2011-08-22 09:52:47 +0800 | [diff] [blame] | 37 | send two types of packets: the USBIP_CMD_SUBMIT to submit an URB, and |
| 38 | USBIP_CMD_UNLINK to unlink a previously submitted URB. The answers of the |
| 39 | server may be USBIP_RET_SUBMIT and USBIP_RET_UNLINK respectively. |
| 40 | |
Mauro Carvalho Chehab | d80b500 | 2019-04-15 23:56:01 -0300 | [diff] [blame] | 41 | :: |
| 42 | |
Márton Németh | c8742cf | 2011-08-22 09:52:47 +0800 | [diff] [blame] | 43 | virtual host controller usb host |
| 44 | "client" "server" |
| 45 | (imports USB devices) (exports USB devices) |
| 46 | | | |
| 47 | | OP_REQ_IMPORT | |
| 48 | | ----------------------------------------------> | |
| 49 | | | |
| 50 | | OP_REP_IMPORT | |
| 51 | | <---------------------------------------------- | |
| 52 | | | |
| 53 | | | |
| 54 | | USBIP_CMD_SUBMIT(seqnum = n) | |
| 55 | | ----------------------------------------------> | |
| 56 | | | |
| 57 | | USBIP_RET_SUBMIT(seqnum = n) | |
| 58 | | <---------------------------------------------- | |
| 59 | | . | |
| 60 | | : | |
| 61 | | | |
| 62 | | USBIP_CMD_SUBMIT(seqnum = m) | |
| 63 | | ----------------------------------------------> | |
| 64 | | | |
| 65 | | USBIP_CMD_SUBMIT(seqnum = m+1) | |
| 66 | | ----------------------------------------------> | |
| 67 | | | |
| 68 | | USBIP_CMD_SUBMIT(seqnum = m+2) | |
| 69 | | ----------------------------------------------> | |
| 70 | | | |
| 71 | | USBIP_RET_SUBMIT(seqnum = m) | |
| 72 | | <---------------------------------------------- | |
| 73 | | | |
| 74 | | USBIP_CMD_SUBMIT(seqnum = m+3) | |
| 75 | | ----------------------------------------------> | |
| 76 | | | |
| 77 | | USBIP_RET_SUBMIT(seqnum = m+1) | |
| 78 | | <---------------------------------------------- | |
| 79 | | | |
| 80 | | USBIP_CMD_SUBMIT(seqnum = m+4) | |
| 81 | | ----------------------------------------------> | |
| 82 | | | |
| 83 | | USBIP_RET_SUBMIT(seqnum = m+2) | |
| 84 | | <---------------------------------------------- | |
| 85 | | . | |
| 86 | | : | |
Hongren Zheng (Zenithal) | 17af793 | 2021-03-31 01:00:13 +0800 | [diff] [blame] | 87 | |
| 88 | For UNLINK, note that after a successful USBIP_RET_UNLINK, the unlinked URB |
| 89 | submission would not have a corresponding USBIP_RET_SUBMIT (this is explained in |
| 90 | function stub_recv_cmd_unlink of drivers/usb/usbip/stub_rx.c). |
| 91 | |
| 92 | :: |
| 93 | |
| 94 | virtual host controller usb host |
| 95 | "client" "server" |
| 96 | (imports USB devices) (exports USB devices) |
| 97 | | | |
| 98 | | USBIP_CMD_SUBMIT(seqnum = p) | |
| 99 | | ----------------------------------------------> | |
Márton Németh | c8742cf | 2011-08-22 09:52:47 +0800 | [diff] [blame] | 100 | | | |
| 101 | | USBIP_CMD_UNLINK | |
Hongren Zheng (Zenithal) | 17af793 | 2021-03-31 01:00:13 +0800 | [diff] [blame] | 102 | | (seqnum = p+1, unlink_seqnum = p) | |
Márton Németh | c8742cf | 2011-08-22 09:52:47 +0800 | [diff] [blame] | 103 | | ----------------------------------------------> | |
| 104 | | | |
| 105 | | USBIP_RET_UNLINK | |
Hongren Zheng (Zenithal) | 17af793 | 2021-03-31 01:00:13 +0800 | [diff] [blame] | 106 | | (seqnum = p+1, status = -ECONNRESET) | |
| 107 | | <---------------------------------------------- | |
| 108 | | | |
| 109 | | Note: No USBIP_RET_SUBMIT(seqnum = p) | |
| 110 | | <--X---X---X---X---X---X---X---X---X---X---X--- | |
| 111 | | . | |
| 112 | | : | |
| 113 | | | |
| 114 | | USBIP_CMD_SUBMIT(seqnum = q) | |
| 115 | | ----------------------------------------------> | |
| 116 | | | |
| 117 | | USBIP_RET_SUBMIT(seqnum = q) | |
| 118 | | <---------------------------------------------- | |
| 119 | | | |
| 120 | | USBIP_CMD_UNLINK | |
| 121 | | (seqnum = q+1, unlink_seqnum = q) | |
| 122 | | ----------------------------------------------> | |
| 123 | | | |
| 124 | | USBIP_RET_UNLINK | |
| 125 | | (seqnum = q+1, status = 0) | |
Márton Németh | c8742cf | 2011-08-22 09:52:47 +0800 | [diff] [blame] | 126 | | <---------------------------------------------- | |
| 127 | | | |
| 128 | |
| 129 | The fields are in network (big endian) byte order meaning that the most significant |
| 130 | byte (MSB) is stored at the lowest address. |
| 131 | |
Hongren Zheng (Zenithal) | 17af793 | 2021-03-31 01:00:13 +0800 | [diff] [blame] | 132 | Protocol Version |
| 133 | ================ |
| 134 | |
| 135 | The documented USBIP version is v1.1.1. The binary representation of this |
| 136 | version in message headers is 0x0111. |
| 137 | |
| 138 | This is defined in tools/usb/usbip/configure.ac |
| 139 | |
| 140 | Message Format |
| 141 | ============== |
Márton Németh | c8742cf | 2011-08-22 09:52:47 +0800 | [diff] [blame] | 142 | |
Mauro Carvalho Chehab | d80b500 | 2019-04-15 23:56:01 -0300 | [diff] [blame] | 143 | OP_REQ_DEVLIST: |
| 144 | Retrieve the list of exported USB devices. |
Márton Németh | c8742cf | 2011-08-22 09:52:47 +0800 | [diff] [blame] | 145 | |
Mauro Carvalho Chehab | d80b500 | 2019-04-15 23:56:01 -0300 | [diff] [blame] | 146 | +-----------+--------+------------+---------------------------------------------------+ |
| 147 | | Offset | Length | Value | Description | |
| 148 | +===========+========+============+===================================================+ |
Hongren Zheng (Zenithal) | 17af793 | 2021-03-31 01:00:13 +0800 | [diff] [blame] | 149 | | 0 | 2 | | USBIP version | |
Mauro Carvalho Chehab | d80b500 | 2019-04-15 23:56:01 -0300 | [diff] [blame] | 150 | +-----------+--------+------------+---------------------------------------------------+ |
| 151 | | 2 | 2 | 0x8005 | Command code: Retrieve the list of exported USB | |
| 152 | | | | | devices. | |
| 153 | +-----------+--------+------------+---------------------------------------------------+ |
| 154 | | 4 | 4 | 0x00000000 | Status: unused, shall be set to 0 | |
| 155 | +-----------+--------+------------+---------------------------------------------------+ |
Márton Németh | c8742cf | 2011-08-22 09:52:47 +0800 | [diff] [blame] | 156 | |
Mauro Carvalho Chehab | d80b500 | 2019-04-15 23:56:01 -0300 | [diff] [blame] | 157 | OP_REP_DEVLIST: |
| 158 | Reply with the list of exported USB devices. |
Márton Németh | c8742cf | 2011-08-22 09:52:47 +0800 | [diff] [blame] | 159 | |
Mauro Carvalho Chehab | d80b500 | 2019-04-15 23:56:01 -0300 | [diff] [blame] | 160 | +-----------+--------+------------+---------------------------------------------------+ |
| 161 | | Offset | Length | Value | Description | |
| 162 | +===========+========+============+===================================================+ |
Hongren Zheng (Zenithal) | 17af793 | 2021-03-31 01:00:13 +0800 | [diff] [blame] | 163 | | 0 | 2 | | USBIP version | |
Mauro Carvalho Chehab | d80b500 | 2019-04-15 23:56:01 -0300 | [diff] [blame] | 164 | +-----------+--------+------------+---------------------------------------------------+ |
| 165 | | 2 | 2 | 0x0005 | Reply code: The list of exported USB devices. | |
| 166 | +-----------+--------+------------+---------------------------------------------------+ |
| 167 | | 4 | 4 | 0x00000000 | Status: 0 for OK | |
| 168 | +-----------+--------+------------+---------------------------------------------------+ |
| 169 | | 8 | 4 | n | Number of exported devices: 0 means no exported | |
| 170 | | | | | devices. | |
| 171 | +-----------+--------+------------+---------------------------------------------------+ |
| 172 | | 0x0C | | | From now on the exported n devices are described, | |
| 173 | | | | | if any. If no devices are exported the message | |
| 174 | | | | | ends with the previous "number of exported | |
| 175 | | | | | devices" field. | |
| 176 | +-----------+--------+------------+---------------------------------------------------+ |
| 177 | | | 256 | | path: Path of the device on the host exporting the| |
| 178 | | | | | USB device, string closed with zero byte, e.g. | |
| 179 | | | | | "/sys/devices/pci0000:00/0000:00:1d.1/usb3/3-2" | |
| 180 | | | | | The unused bytes shall be filled with zero | |
| 181 | | | | | bytes. | |
| 182 | +-----------+--------+------------+---------------------------------------------------+ |
| 183 | | 0x10C | 32 | | busid: Bus ID of the exported device, string | |
| 184 | | | | | closed with zero byte, e.g. "3-2". The unused | |
| 185 | | | | | bytes shall be filled with zero bytes. | |
| 186 | +-----------+--------+------------+---------------------------------------------------+ |
| 187 | | 0x12C | 4 | | busnum | |
| 188 | +-----------+--------+------------+---------------------------------------------------+ |
| 189 | | 0x130 | 4 | | devnum | |
| 190 | +-----------+--------+------------+---------------------------------------------------+ |
| 191 | | 0x134 | 4 | | speed | |
| 192 | +-----------+--------+------------+---------------------------------------------------+ |
| 193 | | 0x138 | 2 | | idVendor | |
| 194 | +-----------+--------+------------+---------------------------------------------------+ |
| 195 | | 0x13A | 2 | | idProduct | |
| 196 | +-----------+--------+------------+---------------------------------------------------+ |
| 197 | | 0x13C | 2 | | bcdDevice | |
| 198 | +-----------+--------+------------+---------------------------------------------------+ |
| 199 | | 0x13E | 1 | | bDeviceClass | |
| 200 | +-----------+--------+------------+---------------------------------------------------+ |
| 201 | | 0x13F | 1 | | bDeviceSubClass | |
| 202 | +-----------+--------+------------+---------------------------------------------------+ |
| 203 | | 0x140 | 1 | | bDeviceProtocol | |
| 204 | +-----------+--------+------------+---------------------------------------------------+ |
| 205 | | 0x141 | 1 | | bConfigurationValue | |
| 206 | +-----------+--------+------------+---------------------------------------------------+ |
| 207 | | 0x142 | 1 | | bNumConfigurations | |
| 208 | +-----------+--------+------------+---------------------------------------------------+ |
| 209 | | 0x143 | 1 | | bNumInterfaces | |
| 210 | +-----------+--------+------------+---------------------------------------------------+ |
| 211 | | 0x144 | | m_0 | From now on each interface is described, all | |
Hongren Zheng (Zenithal) | 17af793 | 2021-03-31 01:00:13 +0800 | [diff] [blame] | 212 | | | | | together bNumInterfaces times, with the following | |
| 213 | | | | | 4 fields: | |
Mauro Carvalho Chehab | d80b500 | 2019-04-15 23:56:01 -0300 | [diff] [blame] | 214 | +-----------+--------+------------+---------------------------------------------------+ |
| 215 | | | 1 | | bInterfaceClass | |
| 216 | +-----------+--------+------------+---------------------------------------------------+ |
| 217 | | 0x145 | 1 | | bInterfaceSubClass | |
| 218 | +-----------+--------+------------+---------------------------------------------------+ |
| 219 | | 0x146 | 1 | | bInterfaceProtocol | |
| 220 | +-----------+--------+------------+---------------------------------------------------+ |
| 221 | | 0x147 | 1 | | padding byte for alignment, shall be set to zero | |
| 222 | +-----------+--------+------------+---------------------------------------------------+ |
| 223 | | 0xC + | | | The second exported USB device starts at i=1 | |
Hongren Zheng (Zenithal) | 17af793 | 2021-03-31 01:00:13 +0800 | [diff] [blame] | 224 | | i*0x138 + | | | with the path field. | |
Mauro Carvalho Chehab | d80b500 | 2019-04-15 23:56:01 -0300 | [diff] [blame] | 225 | | m_(i-1)*4 | | | | |
| 226 | +-----------+--------+------------+---------------------------------------------------+ |
Márton Németh | c8742cf | 2011-08-22 09:52:47 +0800 | [diff] [blame] | 227 | |
Mauro Carvalho Chehab | d80b500 | 2019-04-15 23:56:01 -0300 | [diff] [blame] | 228 | OP_REQ_IMPORT: |
| 229 | Request to import (attach) a remote USB device. |
Márton Németh | c8742cf | 2011-08-22 09:52:47 +0800 | [diff] [blame] | 230 | |
Mauro Carvalho Chehab | d80b500 | 2019-04-15 23:56:01 -0300 | [diff] [blame] | 231 | +-----------+--------+------------+---------------------------------------------------+ |
| 232 | | Offset | Length | Value | Description | |
| 233 | +===========+========+============+===================================================+ |
Hongren Zheng (Zenithal) | 17af793 | 2021-03-31 01:00:13 +0800 | [diff] [blame] | 234 | | 0 | 2 | | USBIP version | |
Mauro Carvalho Chehab | d80b500 | 2019-04-15 23:56:01 -0300 | [diff] [blame] | 235 | +-----------+--------+------------+---------------------------------------------------+ |
| 236 | | 2 | 2 | 0x8003 | Command code: import a remote USB device. | |
| 237 | +-----------+--------+------------+---------------------------------------------------+ |
| 238 | | 4 | 4 | 0x00000000 | Status: unused, shall be set to 0 | |
| 239 | +-----------+--------+------------+---------------------------------------------------+ |
| 240 | | 8 | 32 | | busid: the busid of the exported device on the | |
| 241 | | | | | remote host. The possible values are taken | |
| 242 | | | | | from the message field OP_REP_DEVLIST.busid. | |
| 243 | | | | | A string closed with zero, the unused bytes | |
| 244 | | | | | shall be filled with zeros. | |
| 245 | +-----------+--------+------------+---------------------------------------------------+ |
Márton Németh | c8742cf | 2011-08-22 09:52:47 +0800 | [diff] [blame] | 246 | |
Mauro Carvalho Chehab | d80b500 | 2019-04-15 23:56:01 -0300 | [diff] [blame] | 247 | OP_REP_IMPORT: |
| 248 | Reply to import (attach) a remote USB device. |
Márton Németh | c8742cf | 2011-08-22 09:52:47 +0800 | [diff] [blame] | 249 | |
Mauro Carvalho Chehab | d80b500 | 2019-04-15 23:56:01 -0300 | [diff] [blame] | 250 | +-----------+--------+------------+---------------------------------------------------+ |
| 251 | | Offset | Length | Value | Description | |
| 252 | +===========+========+============+===================================================+ |
Hongren Zheng (Zenithal) | 17af793 | 2021-03-31 01:00:13 +0800 | [diff] [blame] | 253 | | 0 | 2 | | USBIP version | |
Mauro Carvalho Chehab | d80b500 | 2019-04-15 23:56:01 -0300 | [diff] [blame] | 254 | +-----------+--------+------------+---------------------------------------------------+ |
| 255 | | 2 | 2 | 0x0003 | Reply code: Reply to import. | |
| 256 | +-----------+--------+------------+---------------------------------------------------+ |
| 257 | | 4 | 4 | 0x00000000 | Status: | |
| 258 | | | | | | |
| 259 | | | | | - 0 for OK | |
| 260 | | | | | - 1 for error | |
| 261 | +-----------+--------+------------+---------------------------------------------------+ |
| 262 | | 8 | | | From now on comes the details of the imported | |
| 263 | | | | | device, if the previous status field was OK (0), | |
| 264 | | | | | otherwise the reply ends with the status field. | |
| 265 | +-----------+--------+------------+---------------------------------------------------+ |
| 266 | | | 256 | | path: Path of the device on the host exporting the| |
| 267 | | | | | USB device, string closed with zero byte, e.g. | |
| 268 | | | | | "/sys/devices/pci0000:00/0000:00:1d.1/usb3/3-2" | |
| 269 | | | | | The unused bytes shall be filled with zero | |
| 270 | | | | | bytes. | |
| 271 | +-----------+--------+------------+---------------------------------------------------+ |
| 272 | | 0x108 | 32 | | busid: Bus ID of the exported device, string | |
| 273 | | | | | closed with zero byte, e.g. "3-2". The unused | |
| 274 | | | | | bytes shall be filled with zero bytes. | |
| 275 | +-----------+--------+------------+---------------------------------------------------+ |
| 276 | | 0x128 | 4 | | busnum | |
| 277 | +-----------+--------+------------+---------------------------------------------------+ |
| 278 | | 0x12C | 4 | | devnum | |
| 279 | +-----------+--------+------------+---------------------------------------------------+ |
| 280 | | 0x130 | 4 | | speed | |
| 281 | +-----------+--------+------------+---------------------------------------------------+ |
| 282 | | 0x134 | 2 | | idVendor | |
| 283 | +-----------+--------+------------+---------------------------------------------------+ |
| 284 | | 0x136 | 2 | | idProduct | |
| 285 | +-----------+--------+------------+---------------------------------------------------+ |
| 286 | | 0x138 | 2 | | bcdDevice | |
| 287 | +-----------+--------+------------+---------------------------------------------------+ |
| 288 | | 0x139 | 1 | | bDeviceClass | |
| 289 | +-----------+--------+------------+---------------------------------------------------+ |
| 290 | | 0x13A | 1 | | bDeviceSubClass | |
| 291 | +-----------+--------+------------+---------------------------------------------------+ |
| 292 | | 0x13B | 1 | | bDeviceProtocol | |
| 293 | +-----------+--------+------------+---------------------------------------------------+ |
| 294 | | 0x13C | 1 | | bConfigurationValue | |
| 295 | +-----------+--------+------------+---------------------------------------------------+ |
| 296 | | 0x13D | 1 | | bNumConfigurations | |
| 297 | +-----------+--------+------------+---------------------------------------------------+ |
| 298 | | 0x13E | 1 | | bNumInterfaces | |
| 299 | +-----------+--------+------------+---------------------------------------------------+ |
Márton Németh | c8742cf | 2011-08-22 09:52:47 +0800 | [diff] [blame] | 300 | |
Hongren Zheng (Zenithal) | 17af793 | 2021-03-31 01:00:13 +0800 | [diff] [blame] | 301 | The following four commands have a common basic header called |
| 302 | 'usbip_header_basic', and their headers, called 'usbip_header' (before |
| 303 | transfer_buffer payload), have the same length, therefore paddings are needed. |
| 304 | |
| 305 | usbip_header_basic: |
| 306 | |
| 307 | +-----------+--------+---------------------------------------------------+ |
| 308 | | Offset | Length | Description | |
| 309 | +===========+========+===================================================+ |
| 310 | | 0 | 4 | command | |
| 311 | +-----------+--------+---------------------------------------------------+ |
| 312 | | 4 | 4 | seqnum: sequential number that identifies requests| |
| 313 | | | | and corresponding responses; | |
| 314 | | | | incremented per connection | |
| 315 | +-----------+--------+---------------------------------------------------+ |
| 316 | | 8 | 4 | devid: specifies a remote USB device uniquely | |
| 317 | | | | instead of busnum and devnum; | |
| 318 | | | | for client (request), this value is | |
| 319 | | | | ((busnum << 16) | devnum); | |
| 320 | | | | for server (response), this shall be set to 0 | |
| 321 | +-----------+--------+---------------------------------------------------+ |
| 322 | | 0xC | 4 | direction: | |
| 323 | | | | | |
| 324 | | | | - 0: USBIP_DIR_OUT | |
| 325 | | | | - 1: USBIP_DIR_IN | |
| 326 | | | | | |
| 327 | | | | only used by client, for server this shall be 0 | |
| 328 | +-----------+--------+---------------------------------------------------+ |
| 329 | | 0x10 | 4 | ep: endpoint number | |
| 330 | | | | only used by client, for server this shall be 0; | |
| 331 | | | | for UNLINK, this shall be 0 | |
| 332 | +-----------+--------+---------------------------------------------------+ |
| 333 | |
Mauro Carvalho Chehab | d80b500 | 2019-04-15 23:56:01 -0300 | [diff] [blame] | 334 | USBIP_CMD_SUBMIT: |
| 335 | Submit an URB |
Márton Németh | c8742cf | 2011-08-22 09:52:47 +0800 | [diff] [blame] | 336 | |
Hongren Zheng (Zenithal) | 17af793 | 2021-03-31 01:00:13 +0800 | [diff] [blame] | 337 | +-----------+--------+---------------------------------------------------+ |
| 338 | | Offset | Length | Description | |
| 339 | +===========+========+===================================================+ |
| 340 | | 0 | 20 | usbip_header_basic, 'command' shall be 0x00000001 | |
| 341 | +-----------+--------+---------------------------------------------------+ |
| 342 | | 0x14 | 4 | transfer_flags: possible values depend on the | |
| 343 | | | | URB transfer_flags (refer to URB doc in | |
| 344 | | | | Documentation/driver-api/usb/URB.rst) | |
| 345 | | | | but with URB_NO_TRANSFER_DMA_MAP masked. Refer to | |
| 346 | | | | function usbip_pack_cmd_submit and function | |
| 347 | | | | tweak_transfer_flags in drivers/usb/usbip/ | |
| 348 | | | | usbip_common.c. The following fields may also ref | |
| 349 | | | | to function usbip_pack_cmd_submit and URB doc | |
| 350 | +-----------+--------+---------------------------------------------------+ |
| 351 | | 0x18 | 4 | transfer_buffer_length: | |
| 352 | | | | use URB transfer_buffer_length | |
| 353 | +-----------+--------+---------------------------------------------------+ |
| 354 | | 0x1C | 4 | start_frame: use URB start_frame; | |
| 355 | | | | initial frame for ISO transfer; | |
| 356 | | | | shall be set to 0 if not ISO transfer | |
| 357 | +-----------+--------+---------------------------------------------------+ |
| 358 | | 0x20 | 4 | number_of_packets: number of ISO packets; | |
| 359 | | | | shall be set to 0xffffffff if not ISO transfer | |
| 360 | +-----------+--------+---------------------------------------------------+ |
| 361 | | 0x24 | 4 | interval: maximum time for the request on the | |
| 362 | | | | server-side host controller | |
| 363 | +-----------+--------+---------------------------------------------------+ |
| 364 | | 0x28 | 8 | setup: data bytes for USB setup, filled with | |
| 365 | | | | zeros if not used. | |
| 366 | +-----------+--------+---------------------------------------------------+ |
| 367 | | 0x30 | n | transfer_buffer. | |
| 368 | | | | If direction is USBIP_DIR_OUT then n equals | |
| 369 | | | | transfer_buffer_length; otherwise n equals 0. | |
| 370 | | | | For ISO transfers the padding between each ISO | |
| 371 | | | | packets is not transmitted. | |
| 372 | +-----------+--------+---------------------------------------------------+ |
| 373 | | 0x30+n | m | iso_packet_descriptor | |
| 374 | +-----------+--------+---------------------------------------------------+ |
Márton Németh | c8742cf | 2011-08-22 09:52:47 +0800 | [diff] [blame] | 375 | |
Mauro Carvalho Chehab | d80b500 | 2019-04-15 23:56:01 -0300 | [diff] [blame] | 376 | USBIP_RET_SUBMIT: |
| 377 | Reply for submitting an URB |
Márton Németh | c8742cf | 2011-08-22 09:52:47 +0800 | [diff] [blame] | 378 | |
Hongren Zheng (Zenithal) | 17af793 | 2021-03-31 01:00:13 +0800 | [diff] [blame] | 379 | +-----------+--------+---------------------------------------------------+ |
| 380 | | Offset | Length | Description | |
| 381 | +===========+========+===================================================+ |
| 382 | | 0 | 20 | usbip_header_basic, 'command' shall be 0x00000003 | |
| 383 | +-----------+--------+---------------------------------------------------+ |
| 384 | | 0x14 | 4 | status: zero for successful URB transaction, | |
| 385 | | | | otherwise some kind of error happened. | |
| 386 | +-----------+--------+---------------------------------------------------+ |
| 387 | | 0x18 | 4 | actual_length: number of URB data bytes; | |
| 388 | | | | use URB actual_length | |
| 389 | +-----------+--------+---------------------------------------------------+ |
| 390 | | 0x1C | 4 | start_frame: use URB start_frame; | |
| 391 | | | | initial frame for ISO transfer; | |
| 392 | | | | shall be set to 0 if not ISO transfer | |
| 393 | +-----------+--------+---------------------------------------------------+ |
| 394 | | 0x20 | 4 | number_of_packets: number of ISO packets; | |
| 395 | | | | shall be set to 0xffffffff if not ISO transfer | |
| 396 | +-----------+--------+---------------------------------------------------+ |
| 397 | | 0x24 | 4 | error_count | |
| 398 | +-----------+--------+---------------------------------------------------+ |
| 399 | | 0x28 | 8 | padding, shall be set to 0 | |
| 400 | +-----------+--------+---------------------------------------------------+ |
| 401 | | 0x30 | n | transfer_buffer. | |
| 402 | | | | If direction is USBIP_DIR_IN then n equals | |
| 403 | | | | actual_length; otherwise n equals 0. | |
| 404 | | | | For ISO transfers the padding between each ISO | |
| 405 | | | | packets is not transmitted. | |
| 406 | +-----------+--------+---------------------------------------------------+ |
| 407 | | 0x30+n | m | iso_packet_descriptor | |
| 408 | +-----------+--------+---------------------------------------------------+ |
Márton Németh | c8742cf | 2011-08-22 09:52:47 +0800 | [diff] [blame] | 409 | |
Mauro Carvalho Chehab | d80b500 | 2019-04-15 23:56:01 -0300 | [diff] [blame] | 410 | USBIP_CMD_UNLINK: |
| 411 | Unlink an URB |
Márton Németh | c8742cf | 2011-08-22 09:52:47 +0800 | [diff] [blame] | 412 | |
Hongren Zheng (Zenithal) | 17af793 | 2021-03-31 01:00:13 +0800 | [diff] [blame] | 413 | +-----------+--------+---------------------------------------------------+ |
| 414 | | Offset | Length | Description | |
| 415 | +===========+========+===================================================+ |
| 416 | | 0 | 20 | usbip_header_basic, 'command' shall be 0x00000002 | |
| 417 | +-----------+--------+---------------------------------------------------+ |
| 418 | | 0x14 | 4 | unlink_seqnum, of the SUBMIT request to unlink | |
| 419 | +-----------+--------+---------------------------------------------------+ |
| 420 | | 0x18 | 24 | padding, shall be set to 0 | |
| 421 | +-----------+--------+---------------------------------------------------+ |
Márton Németh | c8742cf | 2011-08-22 09:52:47 +0800 | [diff] [blame] | 422 | |
Mauro Carvalho Chehab | d80b500 | 2019-04-15 23:56:01 -0300 | [diff] [blame] | 423 | USBIP_RET_UNLINK: |
| 424 | Reply for URB unlink |
Márton Németh | c8742cf | 2011-08-22 09:52:47 +0800 | [diff] [blame] | 425 | |
Hongren Zheng (Zenithal) | 17af793 | 2021-03-31 01:00:13 +0800 | [diff] [blame] | 426 | +-----------+--------+---------------------------------------------------+ |
| 427 | | Offset | Length | Description | |
| 428 | +===========+========+===================================================+ |
| 429 | | 0 | 20 | usbip_header_basic, 'command' shall be 0x00000004 | |
| 430 | +-----------+--------+---------------------------------------------------+ |
| 431 | | 0x14 | 4 | status: This is similar to the status of | |
| 432 | | | | USBIP_RET_SUBMIT (share the same memory offset). | |
| 433 | | | | When UNLINK is successful, status is -ECONNRESET; | |
| 434 | | | | when USBIP_CMD_UNLINK is after USBIP_RET_SUBMIT | |
| 435 | | | | status is 0 | |
| 436 | +-----------+--------+---------------------------------------------------+ |
| 437 | | 0x18 | 24 | padding, shall be set to 0 | |
| 438 | +-----------+--------+---------------------------------------------------+ |
| 439 | |
| 440 | EXAMPLE |
| 441 | ======= |
| 442 | |
| 443 | The following data is captured from wire with Human Interface Devices (HID) |
| 444 | payload |
| 445 | |
| 446 | :: |
| 447 | |
| 448 | CmdIntrIN: 00000001 00000d05 0001000f 00000001 00000001 00000200 00000040 ffffffff 00000000 00000004 00000000 00000000 |
| 449 | CmdIntrOUT: 00000001 00000d06 0001000f 00000000 00000001 00000000 00000040 ffffffff 00000000 00000004 00000000 00000000 |
| 450 | ffffffff860008a784ce5ae212376300000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 |
| 451 | RetIntrOut: 00000003 00000d06 00000000 00000000 00000000 00000000 00000040 ffffffff 00000000 00000000 00000000 00000000 |
| 452 | RetIntrIn: 00000003 00000d05 00000000 00000000 00000000 00000000 00000040 ffffffff 00000000 00000000 00000000 00000000 |
| 453 | ffffffff860011a784ce5ae2123763612891b1020100000400000000000000000000000000000000000000000000000000000000000000000000000000000000 |