1*bae9401dSJuergen Gross /* SPDX-License-Identifier: MIT */ 2*bae9401dSJuergen Gross 3*bae9401dSJuergen Gross /* 4*bae9401dSJuergen Gross * usbif.h 5*bae9401dSJuergen Gross * 6*bae9401dSJuergen Gross * USB I/O interface for Xen guest OSes. 7*bae9401dSJuergen Gross * 8*bae9401dSJuergen Gross * Copyright (C) 2009, FUJITSU LABORATORIES LTD. 9*bae9401dSJuergen Gross * Author: Noboru Iwamatsu <n_iwamatsu@jp.fujitsu.com> 10*bae9401dSJuergen Gross */ 11*bae9401dSJuergen Gross 12*bae9401dSJuergen Gross #ifndef __XEN_PUBLIC_IO_USBIF_H__ 13*bae9401dSJuergen Gross #define __XEN_PUBLIC_IO_USBIF_H__ 14*bae9401dSJuergen Gross 15*bae9401dSJuergen Gross #include "ring.h" 16*bae9401dSJuergen Gross #include "../grant_table.h" 17*bae9401dSJuergen Gross 18*bae9401dSJuergen Gross /* 19*bae9401dSJuergen Gross * Detailed Interface Description 20*bae9401dSJuergen Gross * ============================== 21*bae9401dSJuergen Gross * The pvUSB interface is using a split driver design: a frontend driver in 22*bae9401dSJuergen Gross * the guest and a backend driver in a driver domain (normally dom0) having 23*bae9401dSJuergen Gross * access to the physical USB device(s) being passed to the guest. 24*bae9401dSJuergen Gross * 25*bae9401dSJuergen Gross * The frontend and backend drivers use XenStore to initiate the connection 26*bae9401dSJuergen Gross * between them, the I/O activity is handled via two shared ring pages and an 27*bae9401dSJuergen Gross * event channel. As the interface between frontend and backend is at the USB 28*bae9401dSJuergen Gross * host connector level, multiple (up to 31) physical USB devices can be 29*bae9401dSJuergen Gross * handled by a single connection. 30*bae9401dSJuergen Gross * 31*bae9401dSJuergen Gross * The Xen pvUSB device name is "qusb", so the frontend's XenStore entries are 32*bae9401dSJuergen Gross * to be found under "device/qusb", while the backend's XenStore entries are 33*bae9401dSJuergen Gross * under "backend/<guest-dom-id>/qusb". 34*bae9401dSJuergen Gross * 35*bae9401dSJuergen Gross * When a new pvUSB connection is established, the frontend needs to setup the 36*bae9401dSJuergen Gross * two shared ring pages for communication and the event channel. The ring 37*bae9401dSJuergen Gross * pages need to be made available to the backend via the grant table 38*bae9401dSJuergen Gross * interface. 39*bae9401dSJuergen Gross * 40*bae9401dSJuergen Gross * One of the shared ring pages is used by the backend to inform the frontend 41*bae9401dSJuergen Gross * about USB device plug events (device to be added or removed). This is the 42*bae9401dSJuergen Gross * "conn-ring". 43*bae9401dSJuergen Gross * 44*bae9401dSJuergen Gross * The other ring page is used for USB I/O communication (requests and 45*bae9401dSJuergen Gross * responses). This is the "urb-ring". 46*bae9401dSJuergen Gross * 47*bae9401dSJuergen Gross * Feature and Parameter Negotiation 48*bae9401dSJuergen Gross * ================================= 49*bae9401dSJuergen Gross * The two halves of a Xen pvUSB driver utilize nodes within the XenStore to 50*bae9401dSJuergen Gross * communicate capabilities and to negotiate operating parameters. This 51*bae9401dSJuergen Gross * section enumerates these nodes which reside in the respective front and 52*bae9401dSJuergen Gross * backend portions of the XenStore, following the XenBus convention. 53*bae9401dSJuergen Gross * 54*bae9401dSJuergen Gross * Any specified default value is in effect if the corresponding XenBus node 55*bae9401dSJuergen Gross * is not present in the XenStore. 56*bae9401dSJuergen Gross * 57*bae9401dSJuergen Gross * XenStore nodes in sections marked "PRIVATE" are solely for use by the 58*bae9401dSJuergen Gross * driver side whose XenBus tree contains them. 59*bae9401dSJuergen Gross * 60*bae9401dSJuergen Gross ***************************************************************************** 61*bae9401dSJuergen Gross * Backend XenBus Nodes 62*bae9401dSJuergen Gross ***************************************************************************** 63*bae9401dSJuergen Gross * 64*bae9401dSJuergen Gross *------------------ Backend Device Identification (PRIVATE) ------------------ 65*bae9401dSJuergen Gross * 66*bae9401dSJuergen Gross * num-ports 67*bae9401dSJuergen Gross * Values: unsigned [1...31] 68*bae9401dSJuergen Gross * 69*bae9401dSJuergen Gross * Number of ports for this (virtual) USB host connector. 70*bae9401dSJuergen Gross * 71*bae9401dSJuergen Gross * usb-ver 72*bae9401dSJuergen Gross * Values: unsigned [1...2] 73*bae9401dSJuergen Gross * 74*bae9401dSJuergen Gross * USB version of this host connector: 1 = USB 1.1, 2 = USB 2.0. 75*bae9401dSJuergen Gross * 76*bae9401dSJuergen Gross * port/[1...31] 77*bae9401dSJuergen Gross * Values: string 78*bae9401dSJuergen Gross * 79*bae9401dSJuergen Gross * Physical USB device connected to the given port, e.g. "3-1.5". 80*bae9401dSJuergen Gross * 81*bae9401dSJuergen Gross ***************************************************************************** 82*bae9401dSJuergen Gross * Frontend XenBus Nodes 83*bae9401dSJuergen Gross ***************************************************************************** 84*bae9401dSJuergen Gross * 85*bae9401dSJuergen Gross *----------------------- Request Transport Parameters ----------------------- 86*bae9401dSJuergen Gross * 87*bae9401dSJuergen Gross * event-channel 88*bae9401dSJuergen Gross * Values: unsigned 89*bae9401dSJuergen Gross * 90*bae9401dSJuergen Gross * The identifier of the Xen event channel used to signal activity 91*bae9401dSJuergen Gross * in the ring buffer. 92*bae9401dSJuergen Gross * 93*bae9401dSJuergen Gross * urb-ring-ref 94*bae9401dSJuergen Gross * Values: unsigned 95*bae9401dSJuergen Gross * 96*bae9401dSJuergen Gross * The Xen grant reference granting permission for the backend to map 97*bae9401dSJuergen Gross * the sole page in a single page sized ring buffer. This is the ring 98*bae9401dSJuergen Gross * buffer for urb requests. 99*bae9401dSJuergen Gross * 100*bae9401dSJuergen Gross * conn-ring-ref 101*bae9401dSJuergen Gross * Values: unsigned 102*bae9401dSJuergen Gross * 103*bae9401dSJuergen Gross * The Xen grant reference granting permission for the backend to map 104*bae9401dSJuergen Gross * the sole page in a single page sized ring buffer. This is the ring 105*bae9401dSJuergen Gross * buffer for connection/disconnection requests. 106*bae9401dSJuergen Gross * 107*bae9401dSJuergen Gross * protocol 108*bae9401dSJuergen Gross * Values: string (XEN_IO_PROTO_ABI_*) 109*bae9401dSJuergen Gross * Default Value: XEN_IO_PROTO_ABI_NATIVE 110*bae9401dSJuergen Gross * 111*bae9401dSJuergen Gross * The machine ABI rules governing the format of all ring request and 112*bae9401dSJuergen Gross * response structures. 113*bae9401dSJuergen Gross * 114*bae9401dSJuergen Gross * Protocol Description 115*bae9401dSJuergen Gross * ==================== 116*bae9401dSJuergen Gross * 117*bae9401dSJuergen Gross *-------------------------- USB device plug events -------------------------- 118*bae9401dSJuergen Gross * 119*bae9401dSJuergen Gross * USB device plug events are send via the "conn-ring" shared page. As only 120*bae9401dSJuergen Gross * events are being sent, the respective requests from the frontend to the 121*bae9401dSJuergen Gross * backend are just dummy ones. 122*bae9401dSJuergen Gross * The events sent to the frontend have the following layout: 123*bae9401dSJuergen Gross * 0 1 2 3 octet 124*bae9401dSJuergen Gross * +----------------+----------------+----------------+----------------+ 125*bae9401dSJuergen Gross * | id | portnum | speed | 4 126*bae9401dSJuergen Gross * +----------------+----------------+----------------+----------------+ 127*bae9401dSJuergen Gross * id - uint16_t, event id (taken from the actual frontend dummy request) 128*bae9401dSJuergen Gross * portnum - uint8_t, port number (1 ... 31) 129*bae9401dSJuergen Gross * speed - uint8_t, device XENUSB_SPEED_*, XENUSB_SPEED_NONE == unplug 130*bae9401dSJuergen Gross * 131*bae9401dSJuergen Gross * The dummy request: 132*bae9401dSJuergen Gross * 0 1 octet 133*bae9401dSJuergen Gross * +----------------+----------------+ 134*bae9401dSJuergen Gross * | id | 2 135*bae9401dSJuergen Gross * +----------------+----------------+ 136*bae9401dSJuergen Gross * id - uint16_t, guest supplied value (no need for being unique) 137*bae9401dSJuergen Gross * 138*bae9401dSJuergen Gross *-------------------------- USB I/O request --------------------------------- 139*bae9401dSJuergen Gross * 140*bae9401dSJuergen Gross * A single USB I/O request on the "urb-ring" has the following layout: 141*bae9401dSJuergen Gross * 0 1 2 3 octet 142*bae9401dSJuergen Gross * +----------------+----------------+----------------+----------------+ 143*bae9401dSJuergen Gross * | id | nr_buffer_segs | 4 144*bae9401dSJuergen Gross * +----------------+----------------+----------------+----------------+ 145*bae9401dSJuergen Gross * | pipe | 8 146*bae9401dSJuergen Gross * +----------------+----------------+----------------+----------------+ 147*bae9401dSJuergen Gross * | transfer_flags | buffer_length | 12 148*bae9401dSJuergen Gross * +----------------+----------------+----------------+----------------+ 149*bae9401dSJuergen Gross * | request type specific | 16 150*bae9401dSJuergen Gross * | data | 20 151*bae9401dSJuergen Gross * +----------------+----------------+----------------+----------------+ 152*bae9401dSJuergen Gross * | seg[0] | 24 153*bae9401dSJuergen Gross * | data | 28 154*bae9401dSJuergen Gross * +----------------+----------------+----------------+----------------+ 155*bae9401dSJuergen Gross * |/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/| 156*bae9401dSJuergen Gross * +----------------+----------------+----------------+----------------+ 157*bae9401dSJuergen Gross * | seg[XENUSB_MAX_SEGMENTS_PER_REQUEST - 1] | 144 158*bae9401dSJuergen Gross * | data | 148 159*bae9401dSJuergen Gross * +----------------+----------------+----------------+----------------+ 160*bae9401dSJuergen Gross * Bit field bit number 0 is always least significant bit, undefined bits must 161*bae9401dSJuergen Gross * be zero. 162*bae9401dSJuergen Gross * id - uint16_t, guest supplied value 163*bae9401dSJuergen Gross * nr_buffer_segs - uint16_t, number of segment entries in seg[] array 164*bae9401dSJuergen Gross * pipe - uint32_t, bit field with multiple information: 165*bae9401dSJuergen Gross * bits 0-4: port request to send to 166*bae9401dSJuergen Gross * bit 5: unlink request with specified id (cancel I/O) if set (see below) 167*bae9401dSJuergen Gross * bit 7: direction (1 = read from device) 168*bae9401dSJuergen Gross * bits 8-14: device number on port 169*bae9401dSJuergen Gross * bits 15-18: endpoint of device 170*bae9401dSJuergen Gross * bits 30-31: request type: 00 = isochronous, 01 = interrupt, 171*bae9401dSJuergen Gross * 10 = control, 11 = bulk 172*bae9401dSJuergen Gross * transfer_flags - uint16_t, bit field with processing flags: 173*bae9401dSJuergen Gross * bit 0: less data than specified allowed 174*bae9401dSJuergen Gross * buffer_length - uint16_t, total length of data 175*bae9401dSJuergen Gross * request type specific data - 8 bytes, see below 176*bae9401dSJuergen Gross * seg[] - array with 8 byte elements, see below 177*bae9401dSJuergen Gross * 178*bae9401dSJuergen Gross * Request type specific data for isochronous request: 179*bae9401dSJuergen Gross * 0 1 2 3 octet 180*bae9401dSJuergen Gross * +----------------+----------------+----------------+----------------+ 181*bae9401dSJuergen Gross * | interval | start_frame | 4 182*bae9401dSJuergen Gross * +----------------+----------------+----------------+----------------+ 183*bae9401dSJuergen Gross * | number_of_packets | nr_frame_desc_segs | 8 184*bae9401dSJuergen Gross * +----------------+----------------+----------------+----------------+ 185*bae9401dSJuergen Gross * interval - uint16_t, time interval in msecs between frames 186*bae9401dSJuergen Gross * start_frame - uint16_t, start frame number 187*bae9401dSJuergen Gross * number_of_packets - uint16_t, number of packets to transfer 188*bae9401dSJuergen Gross * nr_frame_desc_segs - uint16_t number of seg[] frame descriptors elements 189*bae9401dSJuergen Gross * 190*bae9401dSJuergen Gross * Request type specific data for interrupt request: 191*bae9401dSJuergen Gross * 0 1 2 3 octet 192*bae9401dSJuergen Gross * +----------------+----------------+----------------+----------------+ 193*bae9401dSJuergen Gross * | interval | 0 | 4 194*bae9401dSJuergen Gross * +----------------+----------------+----------------+----------------+ 195*bae9401dSJuergen Gross * | 0 | 8 196*bae9401dSJuergen Gross * +----------------+----------------+----------------+----------------+ 197*bae9401dSJuergen Gross * interval - uint16_t, time in msecs until interruption 198*bae9401dSJuergen Gross * 199*bae9401dSJuergen Gross * Request type specific data for control request: 200*bae9401dSJuergen Gross * 0 1 2 3 octet 201*bae9401dSJuergen Gross * +----------------+----------------+----------------+----------------+ 202*bae9401dSJuergen Gross * | data of setup packet | 4 203*bae9401dSJuergen Gross * | | 8 204*bae9401dSJuergen Gross * +----------------+----------------+----------------+----------------+ 205*bae9401dSJuergen Gross * 206*bae9401dSJuergen Gross * Request type specific data for bulk request: 207*bae9401dSJuergen Gross * 0 1 2 3 octet 208*bae9401dSJuergen Gross * +----------------+----------------+----------------+----------------+ 209*bae9401dSJuergen Gross * | 0 | 4 210*bae9401dSJuergen Gross * | 0 | 8 211*bae9401dSJuergen Gross * +----------------+----------------+----------------+----------------+ 212*bae9401dSJuergen Gross * 213*bae9401dSJuergen Gross * Request type specific data for unlink request: 214*bae9401dSJuergen Gross * 0 1 2 3 octet 215*bae9401dSJuergen Gross * +----------------+----------------+----------------+----------------+ 216*bae9401dSJuergen Gross * | unlink_id | 0 | 4 217*bae9401dSJuergen Gross * +----------------+----------------+----------------+----------------+ 218*bae9401dSJuergen Gross * | 0 | 8 219*bae9401dSJuergen Gross * +----------------+----------------+----------------+----------------+ 220*bae9401dSJuergen Gross * unlink_id - uint16_t, request id of request to terminate 221*bae9401dSJuergen Gross * 222*bae9401dSJuergen Gross * seg[] array element layout: 223*bae9401dSJuergen Gross * 0 1 2 3 octet 224*bae9401dSJuergen Gross * +----------------+----------------+----------------+----------------+ 225*bae9401dSJuergen Gross * | gref | 4 226*bae9401dSJuergen Gross * +----------------+----------------+----------------+----------------+ 227*bae9401dSJuergen Gross * | offset | length | 8 228*bae9401dSJuergen Gross * +----------------+----------------+----------------+----------------+ 229*bae9401dSJuergen Gross * gref - uint32_t, grant reference of buffer page 230*bae9401dSJuergen Gross * offset - uint16_t, offset of buffer start in page 231*bae9401dSJuergen Gross * length - uint16_t, length of buffer in page 232*bae9401dSJuergen Gross * 233*bae9401dSJuergen Gross *-------------------------- USB I/O response -------------------------------- 234*bae9401dSJuergen Gross * 235*bae9401dSJuergen Gross * 0 1 2 3 octet 236*bae9401dSJuergen Gross * +----------------+----------------+----------------+----------------+ 237*bae9401dSJuergen Gross * | id | start_frame | 4 238*bae9401dSJuergen Gross * +----------------+----------------+----------------+----------------+ 239*bae9401dSJuergen Gross * | status | 8 240*bae9401dSJuergen Gross * +----------------+----------------+----------------+----------------+ 241*bae9401dSJuergen Gross * | actual_length | 12 242*bae9401dSJuergen Gross * +----------------+----------------+----------------+----------------+ 243*bae9401dSJuergen Gross * | error_count | 16 244*bae9401dSJuergen Gross * +----------------+----------------+----------------+----------------+ 245*bae9401dSJuergen Gross * id - uint16_t, id of the request this response belongs to 246*bae9401dSJuergen Gross * start_frame - uint16_t, start_frame this response (iso requests only) 247*bae9401dSJuergen Gross * status - int32_t, XENUSB_STATUS_* (non-iso requests) 248*bae9401dSJuergen Gross * actual_length - uint32_t, actual size of data transferred 249*bae9401dSJuergen Gross * error_count - uint32_t, number of errors (iso requests) 250*bae9401dSJuergen Gross */ 251*bae9401dSJuergen Gross 252*bae9401dSJuergen Gross enum xenusb_spec_version { 253*bae9401dSJuergen Gross XENUSB_VER_UNKNOWN = 0, 254*bae9401dSJuergen Gross XENUSB_VER_USB11, 255*bae9401dSJuergen Gross XENUSB_VER_USB20, 256*bae9401dSJuergen Gross XENUSB_VER_USB30, /* not supported yet */ 257*bae9401dSJuergen Gross }; 258*bae9401dSJuergen Gross 259*bae9401dSJuergen Gross /* 260*bae9401dSJuergen Gross * USB pipe in xenusb_request 261*bae9401dSJuergen Gross * 262*bae9401dSJuergen Gross * - port number: bits 0-4 263*bae9401dSJuergen Gross * (USB_MAXCHILDREN is 31) 264*bae9401dSJuergen Gross * 265*bae9401dSJuergen Gross * - operation flag: bit 5 266*bae9401dSJuergen Gross * (0 = submit urb, 267*bae9401dSJuergen Gross * 1 = unlink urb) 268*bae9401dSJuergen Gross * 269*bae9401dSJuergen Gross * - direction: bit 7 270*bae9401dSJuergen Gross * (0 = Host-to-Device [Out] 271*bae9401dSJuergen Gross * 1 = Device-to-Host [In]) 272*bae9401dSJuergen Gross * 273*bae9401dSJuergen Gross * - device address: bits 8-14 274*bae9401dSJuergen Gross * 275*bae9401dSJuergen Gross * - endpoint: bits 15-18 276*bae9401dSJuergen Gross * 277*bae9401dSJuergen Gross * - pipe type: bits 30-31 278*bae9401dSJuergen Gross * (00 = isochronous, 01 = interrupt, 279*bae9401dSJuergen Gross * 10 = control, 11 = bulk) 280*bae9401dSJuergen Gross */ 281*bae9401dSJuergen Gross 282*bae9401dSJuergen Gross #define XENUSB_PIPE_PORT_MASK 0x0000001f 283*bae9401dSJuergen Gross #define XENUSB_PIPE_UNLINK 0x00000020 284*bae9401dSJuergen Gross #define XENUSB_PIPE_DIR 0x00000080 285*bae9401dSJuergen Gross #define XENUSB_PIPE_DEV_MASK 0x0000007f 286*bae9401dSJuergen Gross #define XENUSB_PIPE_DEV_SHIFT 8 287*bae9401dSJuergen Gross #define XENUSB_PIPE_EP_MASK 0x0000000f 288*bae9401dSJuergen Gross #define XENUSB_PIPE_EP_SHIFT 15 289*bae9401dSJuergen Gross #define XENUSB_PIPE_TYPE_MASK 0x00000003 290*bae9401dSJuergen Gross #define XENUSB_PIPE_TYPE_SHIFT 30 291*bae9401dSJuergen Gross #define XENUSB_PIPE_TYPE_ISOC 0 292*bae9401dSJuergen Gross #define XENUSB_PIPE_TYPE_INT 1 293*bae9401dSJuergen Gross #define XENUSB_PIPE_TYPE_CTRL 2 294*bae9401dSJuergen Gross #define XENUSB_PIPE_TYPE_BULK 3 295*bae9401dSJuergen Gross 296*bae9401dSJuergen Gross #define xenusb_pipeportnum(pipe) ((pipe) & XENUSB_PIPE_PORT_MASK) 297*bae9401dSJuergen Gross #define xenusb_setportnum_pipe(pipe, portnum) ((pipe) | (portnum)) 298*bae9401dSJuergen Gross 299*bae9401dSJuergen Gross #define xenusb_pipeunlink(pipe) ((pipe) & XENUSB_PIPE_UNLINK) 300*bae9401dSJuergen Gross #define xenusb_pipesubmit(pipe) (!xenusb_pipeunlink(pipe)) 301*bae9401dSJuergen Gross #define xenusb_setunlink_pipe(pipe) ((pipe) | XENUSB_PIPE_UNLINK) 302*bae9401dSJuergen Gross 303*bae9401dSJuergen Gross #define xenusb_pipein(pipe) ((pipe) & XENUSB_PIPE_DIR) 304*bae9401dSJuergen Gross #define xenusb_pipeout(pipe) (!xenusb_pipein(pipe)) 305*bae9401dSJuergen Gross 306*bae9401dSJuergen Gross #define xenusb_pipedevice(pipe) \ 307*bae9401dSJuergen Gross (((pipe) >> XENUSB_PIPE_DEV_SHIFT) & XENUSB_PIPE_DEV_MASK) 308*bae9401dSJuergen Gross 309*bae9401dSJuergen Gross #define xenusb_pipeendpoint(pipe) \ 310*bae9401dSJuergen Gross (((pipe) >> XENUSB_PIPE_EP_SHIFT) & XENUSB_PIPE_EP_MASK) 311*bae9401dSJuergen Gross 312*bae9401dSJuergen Gross #define xenusb_pipetype(pipe) \ 313*bae9401dSJuergen Gross (((pipe) >> XENUSB_PIPE_TYPE_SHIFT) & XENUSB_PIPE_TYPE_MASK) 314*bae9401dSJuergen Gross #define xenusb_pipeisoc(pipe) (xenusb_pipetype(pipe) == XENUSB_PIPE_TYPE_ISOC) 315*bae9401dSJuergen Gross #define xenusb_pipeint(pipe) (xenusb_pipetype(pipe) == XENUSB_PIPE_TYPE_INT) 316*bae9401dSJuergen Gross #define xenusb_pipectrl(pipe) (xenusb_pipetype(pipe) == XENUSB_PIPE_TYPE_CTRL) 317*bae9401dSJuergen Gross #define xenusb_pipebulk(pipe) (xenusb_pipetype(pipe) == XENUSB_PIPE_TYPE_BULK) 318*bae9401dSJuergen Gross 319*bae9401dSJuergen Gross #define XENUSB_MAX_SEGMENTS_PER_REQUEST (16) 320*bae9401dSJuergen Gross #define XENUSB_MAX_PORTNR 31 321*bae9401dSJuergen Gross #define XENUSB_RING_SIZE 4096 322*bae9401dSJuergen Gross 323*bae9401dSJuergen Gross /* 324*bae9401dSJuergen Gross * RING for transferring urbs. 325*bae9401dSJuergen Gross */ 326*bae9401dSJuergen Gross struct xenusb_request_segment { 327*bae9401dSJuergen Gross grant_ref_t gref; 328*bae9401dSJuergen Gross uint16_t offset; 329*bae9401dSJuergen Gross uint16_t length; 330*bae9401dSJuergen Gross }; 331*bae9401dSJuergen Gross 332*bae9401dSJuergen Gross struct xenusb_urb_request { 333*bae9401dSJuergen Gross uint16_t id; /* request id */ 334*bae9401dSJuergen Gross uint16_t nr_buffer_segs; /* number of urb->transfer_buffer segments */ 335*bae9401dSJuergen Gross 336*bae9401dSJuergen Gross /* basic urb parameter */ 337*bae9401dSJuergen Gross uint32_t pipe; 338*bae9401dSJuergen Gross uint16_t transfer_flags; 339*bae9401dSJuergen Gross #define XENUSB_SHORT_NOT_OK 0x0001 340*bae9401dSJuergen Gross uint16_t buffer_length; 341*bae9401dSJuergen Gross union { 342*bae9401dSJuergen Gross uint8_t ctrl[8]; /* setup_packet (Ctrl) */ 343*bae9401dSJuergen Gross 344*bae9401dSJuergen Gross struct { 345*bae9401dSJuergen Gross uint16_t interval; /* maximum (1024*8) in usb core */ 346*bae9401dSJuergen Gross uint16_t start_frame; /* start frame */ 347*bae9401dSJuergen Gross uint16_t number_of_packets; /* number of ISO packet */ 348*bae9401dSJuergen Gross uint16_t nr_frame_desc_segs; /* number of iso_frame_desc segments */ 349*bae9401dSJuergen Gross } isoc; 350*bae9401dSJuergen Gross 351*bae9401dSJuergen Gross struct { 352*bae9401dSJuergen Gross uint16_t interval; /* maximum (1024*8) in usb core */ 353*bae9401dSJuergen Gross uint16_t pad[3]; 354*bae9401dSJuergen Gross } intr; 355*bae9401dSJuergen Gross 356*bae9401dSJuergen Gross struct { 357*bae9401dSJuergen Gross uint16_t unlink_id; /* unlink request id */ 358*bae9401dSJuergen Gross uint16_t pad[3]; 359*bae9401dSJuergen Gross } unlink; 360*bae9401dSJuergen Gross 361*bae9401dSJuergen Gross } u; 362*bae9401dSJuergen Gross 363*bae9401dSJuergen Gross /* urb data segments */ 364*bae9401dSJuergen Gross struct xenusb_request_segment seg[XENUSB_MAX_SEGMENTS_PER_REQUEST]; 365*bae9401dSJuergen Gross }; 366*bae9401dSJuergen Gross 367*bae9401dSJuergen Gross struct xenusb_urb_response { 368*bae9401dSJuergen Gross uint16_t id; /* request id */ 369*bae9401dSJuergen Gross uint16_t start_frame; /* start frame (ISO) */ 370*bae9401dSJuergen Gross int32_t status; /* status (non-ISO) */ 371*bae9401dSJuergen Gross #define XENUSB_STATUS_OK 0 372*bae9401dSJuergen Gross #define XENUSB_STATUS_NODEV (-19) 373*bae9401dSJuergen Gross #define XENUSB_STATUS_INVAL (-22) 374*bae9401dSJuergen Gross #define XENUSB_STATUS_STALL (-32) 375*bae9401dSJuergen Gross #define XENUSB_STATUS_IOERROR (-71) 376*bae9401dSJuergen Gross #define XENUSB_STATUS_BABBLE (-75) 377*bae9401dSJuergen Gross #define XENUSB_STATUS_SHUTDOWN (-108) 378*bae9401dSJuergen Gross int32_t actual_length; /* actual transfer length */ 379*bae9401dSJuergen Gross int32_t error_count; /* number of ISO errors */ 380*bae9401dSJuergen Gross }; 381*bae9401dSJuergen Gross 382*bae9401dSJuergen Gross DEFINE_RING_TYPES(xenusb_urb, struct xenusb_urb_request, struct xenusb_urb_response); 383*bae9401dSJuergen Gross #define XENUSB_URB_RING_SIZE __CONST_RING_SIZE(xenusb_urb, XENUSB_RING_SIZE) 384*bae9401dSJuergen Gross 385*bae9401dSJuergen Gross /* 386*bae9401dSJuergen Gross * RING for notifying connect/disconnect events to frontend 387*bae9401dSJuergen Gross */ 388*bae9401dSJuergen Gross struct xenusb_conn_request { 389*bae9401dSJuergen Gross uint16_t id; 390*bae9401dSJuergen Gross }; 391*bae9401dSJuergen Gross 392*bae9401dSJuergen Gross struct xenusb_conn_response { 393*bae9401dSJuergen Gross uint16_t id; /* request id */ 394*bae9401dSJuergen Gross uint8_t portnum; /* port number */ 395*bae9401dSJuergen Gross uint8_t speed; /* usb_device_speed */ 396*bae9401dSJuergen Gross #define XENUSB_SPEED_NONE 0 397*bae9401dSJuergen Gross #define XENUSB_SPEED_LOW 1 398*bae9401dSJuergen Gross #define XENUSB_SPEED_FULL 2 399*bae9401dSJuergen Gross #define XENUSB_SPEED_HIGH 3 400*bae9401dSJuergen Gross }; 401*bae9401dSJuergen Gross 402*bae9401dSJuergen Gross DEFINE_RING_TYPES(xenusb_conn, struct xenusb_conn_request, struct xenusb_conn_response); 403*bae9401dSJuergen Gross #define XENUSB_CONN_RING_SIZE __CONST_RING_SIZE(xenusb_conn, XENUSB_RING_SIZE) 404*bae9401dSJuergen Gross 405*bae9401dSJuergen Gross #endif /* __XEN_PUBLIC_IO_USBIF_H__ */ 406