162306a36Sopenharmony_ci/* SPDX-License-Identifier: MIT */ 262306a36Sopenharmony_ci 362306a36Sopenharmony_ci/* 462306a36Sopenharmony_ci * usbif.h 562306a36Sopenharmony_ci * 662306a36Sopenharmony_ci * USB I/O interface for Xen guest OSes. 762306a36Sopenharmony_ci * 862306a36Sopenharmony_ci * Copyright (C) 2009, FUJITSU LABORATORIES LTD. 962306a36Sopenharmony_ci * Author: Noboru Iwamatsu <n_iwamatsu@jp.fujitsu.com> 1062306a36Sopenharmony_ci */ 1162306a36Sopenharmony_ci 1262306a36Sopenharmony_ci#ifndef __XEN_PUBLIC_IO_USBIF_H__ 1362306a36Sopenharmony_ci#define __XEN_PUBLIC_IO_USBIF_H__ 1462306a36Sopenharmony_ci 1562306a36Sopenharmony_ci#include "ring.h" 1662306a36Sopenharmony_ci#include "../grant_table.h" 1762306a36Sopenharmony_ci 1862306a36Sopenharmony_ci/* 1962306a36Sopenharmony_ci * Detailed Interface Description 2062306a36Sopenharmony_ci * ============================== 2162306a36Sopenharmony_ci * The pvUSB interface is using a split driver design: a frontend driver in 2262306a36Sopenharmony_ci * the guest and a backend driver in a driver domain (normally dom0) having 2362306a36Sopenharmony_ci * access to the physical USB device(s) being passed to the guest. 2462306a36Sopenharmony_ci * 2562306a36Sopenharmony_ci * The frontend and backend drivers use XenStore to initiate the connection 2662306a36Sopenharmony_ci * between them, the I/O activity is handled via two shared ring pages and an 2762306a36Sopenharmony_ci * event channel. As the interface between frontend and backend is at the USB 2862306a36Sopenharmony_ci * host connector level, multiple (up to 31) physical USB devices can be 2962306a36Sopenharmony_ci * handled by a single connection. 3062306a36Sopenharmony_ci * 3162306a36Sopenharmony_ci * The Xen pvUSB device name is "qusb", so the frontend's XenStore entries are 3262306a36Sopenharmony_ci * to be found under "device/qusb", while the backend's XenStore entries are 3362306a36Sopenharmony_ci * under "backend/<guest-dom-id>/qusb". 3462306a36Sopenharmony_ci * 3562306a36Sopenharmony_ci * When a new pvUSB connection is established, the frontend needs to setup the 3662306a36Sopenharmony_ci * two shared ring pages for communication and the event channel. The ring 3762306a36Sopenharmony_ci * pages need to be made available to the backend via the grant table 3862306a36Sopenharmony_ci * interface. 3962306a36Sopenharmony_ci * 4062306a36Sopenharmony_ci * One of the shared ring pages is used by the backend to inform the frontend 4162306a36Sopenharmony_ci * about USB device plug events (device to be added or removed). This is the 4262306a36Sopenharmony_ci * "conn-ring". 4362306a36Sopenharmony_ci * 4462306a36Sopenharmony_ci * The other ring page is used for USB I/O communication (requests and 4562306a36Sopenharmony_ci * responses). This is the "urb-ring". 4662306a36Sopenharmony_ci * 4762306a36Sopenharmony_ci * Feature and Parameter Negotiation 4862306a36Sopenharmony_ci * ================================= 4962306a36Sopenharmony_ci * The two halves of a Xen pvUSB driver utilize nodes within the XenStore to 5062306a36Sopenharmony_ci * communicate capabilities and to negotiate operating parameters. This 5162306a36Sopenharmony_ci * section enumerates these nodes which reside in the respective front and 5262306a36Sopenharmony_ci * backend portions of the XenStore, following the XenBus convention. 5362306a36Sopenharmony_ci * 5462306a36Sopenharmony_ci * Any specified default value is in effect if the corresponding XenBus node 5562306a36Sopenharmony_ci * is not present in the XenStore. 5662306a36Sopenharmony_ci * 5762306a36Sopenharmony_ci * XenStore nodes in sections marked "PRIVATE" are solely for use by the 5862306a36Sopenharmony_ci * driver side whose XenBus tree contains them. 5962306a36Sopenharmony_ci * 6062306a36Sopenharmony_ci ***************************************************************************** 6162306a36Sopenharmony_ci * Backend XenBus Nodes 6262306a36Sopenharmony_ci ***************************************************************************** 6362306a36Sopenharmony_ci * 6462306a36Sopenharmony_ci *------------------ Backend Device Identification (PRIVATE) ------------------ 6562306a36Sopenharmony_ci * 6662306a36Sopenharmony_ci * num-ports 6762306a36Sopenharmony_ci * Values: unsigned [1...31] 6862306a36Sopenharmony_ci * 6962306a36Sopenharmony_ci * Number of ports for this (virtual) USB host connector. 7062306a36Sopenharmony_ci * 7162306a36Sopenharmony_ci * usb-ver 7262306a36Sopenharmony_ci * Values: unsigned [1...2] 7362306a36Sopenharmony_ci * 7462306a36Sopenharmony_ci * USB version of this host connector: 1 = USB 1.1, 2 = USB 2.0. 7562306a36Sopenharmony_ci * 7662306a36Sopenharmony_ci * port/[1...31] 7762306a36Sopenharmony_ci * Values: string 7862306a36Sopenharmony_ci * 7962306a36Sopenharmony_ci * Physical USB device connected to the given port, e.g. "3-1.5". 8062306a36Sopenharmony_ci * 8162306a36Sopenharmony_ci ***************************************************************************** 8262306a36Sopenharmony_ci * Frontend XenBus Nodes 8362306a36Sopenharmony_ci ***************************************************************************** 8462306a36Sopenharmony_ci * 8562306a36Sopenharmony_ci *----------------------- Request Transport Parameters ----------------------- 8662306a36Sopenharmony_ci * 8762306a36Sopenharmony_ci * event-channel 8862306a36Sopenharmony_ci * Values: unsigned 8962306a36Sopenharmony_ci * 9062306a36Sopenharmony_ci * The identifier of the Xen event channel used to signal activity 9162306a36Sopenharmony_ci * in the ring buffer. 9262306a36Sopenharmony_ci * 9362306a36Sopenharmony_ci * urb-ring-ref 9462306a36Sopenharmony_ci * Values: unsigned 9562306a36Sopenharmony_ci * 9662306a36Sopenharmony_ci * The Xen grant reference granting permission for the backend to map 9762306a36Sopenharmony_ci * the sole page in a single page sized ring buffer. This is the ring 9862306a36Sopenharmony_ci * buffer for urb requests. 9962306a36Sopenharmony_ci * 10062306a36Sopenharmony_ci * conn-ring-ref 10162306a36Sopenharmony_ci * Values: unsigned 10262306a36Sopenharmony_ci * 10362306a36Sopenharmony_ci * The Xen grant reference granting permission for the backend to map 10462306a36Sopenharmony_ci * the sole page in a single page sized ring buffer. This is the ring 10562306a36Sopenharmony_ci * buffer for connection/disconnection requests. 10662306a36Sopenharmony_ci * 10762306a36Sopenharmony_ci * protocol 10862306a36Sopenharmony_ci * Values: string (XEN_IO_PROTO_ABI_*) 10962306a36Sopenharmony_ci * Default Value: XEN_IO_PROTO_ABI_NATIVE 11062306a36Sopenharmony_ci * 11162306a36Sopenharmony_ci * The machine ABI rules governing the format of all ring request and 11262306a36Sopenharmony_ci * response structures. 11362306a36Sopenharmony_ci * 11462306a36Sopenharmony_ci * Protocol Description 11562306a36Sopenharmony_ci * ==================== 11662306a36Sopenharmony_ci * 11762306a36Sopenharmony_ci *-------------------------- USB device plug events -------------------------- 11862306a36Sopenharmony_ci * 11962306a36Sopenharmony_ci * USB device plug events are send via the "conn-ring" shared page. As only 12062306a36Sopenharmony_ci * events are being sent, the respective requests from the frontend to the 12162306a36Sopenharmony_ci * backend are just dummy ones. 12262306a36Sopenharmony_ci * The events sent to the frontend have the following layout: 12362306a36Sopenharmony_ci * 0 1 2 3 octet 12462306a36Sopenharmony_ci * +----------------+----------------+----------------+----------------+ 12562306a36Sopenharmony_ci * | id | portnum | speed | 4 12662306a36Sopenharmony_ci * +----------------+----------------+----------------+----------------+ 12762306a36Sopenharmony_ci * id - uint16_t, event id (taken from the actual frontend dummy request) 12862306a36Sopenharmony_ci * portnum - uint8_t, port number (1 ... 31) 12962306a36Sopenharmony_ci * speed - uint8_t, device XENUSB_SPEED_*, XENUSB_SPEED_NONE == unplug 13062306a36Sopenharmony_ci * 13162306a36Sopenharmony_ci * The dummy request: 13262306a36Sopenharmony_ci * 0 1 octet 13362306a36Sopenharmony_ci * +----------------+----------------+ 13462306a36Sopenharmony_ci * | id | 2 13562306a36Sopenharmony_ci * +----------------+----------------+ 13662306a36Sopenharmony_ci * id - uint16_t, guest supplied value (no need for being unique) 13762306a36Sopenharmony_ci * 13862306a36Sopenharmony_ci *-------------------------- USB I/O request --------------------------------- 13962306a36Sopenharmony_ci * 14062306a36Sopenharmony_ci * A single USB I/O request on the "urb-ring" has the following layout: 14162306a36Sopenharmony_ci * 0 1 2 3 octet 14262306a36Sopenharmony_ci * +----------------+----------------+----------------+----------------+ 14362306a36Sopenharmony_ci * | id | nr_buffer_segs | 4 14462306a36Sopenharmony_ci * +----------------+----------------+----------------+----------------+ 14562306a36Sopenharmony_ci * | pipe | 8 14662306a36Sopenharmony_ci * +----------------+----------------+----------------+----------------+ 14762306a36Sopenharmony_ci * | transfer_flags | buffer_length | 12 14862306a36Sopenharmony_ci * +----------------+----------------+----------------+----------------+ 14962306a36Sopenharmony_ci * | request type specific | 16 15062306a36Sopenharmony_ci * | data | 20 15162306a36Sopenharmony_ci * +----------------+----------------+----------------+----------------+ 15262306a36Sopenharmony_ci * | seg[0] | 24 15362306a36Sopenharmony_ci * | data | 28 15462306a36Sopenharmony_ci * +----------------+----------------+----------------+----------------+ 15562306a36Sopenharmony_ci * |/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/| 15662306a36Sopenharmony_ci * +----------------+----------------+----------------+----------------+ 15762306a36Sopenharmony_ci * | seg[XENUSB_MAX_SEGMENTS_PER_REQUEST - 1] | 144 15862306a36Sopenharmony_ci * | data | 148 15962306a36Sopenharmony_ci * +----------------+----------------+----------------+----------------+ 16062306a36Sopenharmony_ci * Bit field bit number 0 is always least significant bit, undefined bits must 16162306a36Sopenharmony_ci * be zero. 16262306a36Sopenharmony_ci * id - uint16_t, guest supplied value 16362306a36Sopenharmony_ci * nr_buffer_segs - uint16_t, number of segment entries in seg[] array 16462306a36Sopenharmony_ci * pipe - uint32_t, bit field with multiple information: 16562306a36Sopenharmony_ci * bits 0-4: port request to send to 16662306a36Sopenharmony_ci * bit 5: unlink request with specified id (cancel I/O) if set (see below) 16762306a36Sopenharmony_ci * bit 7: direction (1 = read from device) 16862306a36Sopenharmony_ci * bits 8-14: device number on port 16962306a36Sopenharmony_ci * bits 15-18: endpoint of device 17062306a36Sopenharmony_ci * bits 30-31: request type: 00 = isochronous, 01 = interrupt, 17162306a36Sopenharmony_ci * 10 = control, 11 = bulk 17262306a36Sopenharmony_ci * transfer_flags - uint16_t, bit field with processing flags: 17362306a36Sopenharmony_ci * bit 0: less data than specified allowed 17462306a36Sopenharmony_ci * buffer_length - uint16_t, total length of data 17562306a36Sopenharmony_ci * request type specific data - 8 bytes, see below 17662306a36Sopenharmony_ci * seg[] - array with 8 byte elements, see below 17762306a36Sopenharmony_ci * 17862306a36Sopenharmony_ci * Request type specific data for isochronous request: 17962306a36Sopenharmony_ci * 0 1 2 3 octet 18062306a36Sopenharmony_ci * +----------------+----------------+----------------+----------------+ 18162306a36Sopenharmony_ci * | interval | start_frame | 4 18262306a36Sopenharmony_ci * +----------------+----------------+----------------+----------------+ 18362306a36Sopenharmony_ci * | number_of_packets | nr_frame_desc_segs | 8 18462306a36Sopenharmony_ci * +----------------+----------------+----------------+----------------+ 18562306a36Sopenharmony_ci * interval - uint16_t, time interval in msecs between frames 18662306a36Sopenharmony_ci * start_frame - uint16_t, start frame number 18762306a36Sopenharmony_ci * number_of_packets - uint16_t, number of packets to transfer 18862306a36Sopenharmony_ci * nr_frame_desc_segs - uint16_t number of seg[] frame descriptors elements 18962306a36Sopenharmony_ci * 19062306a36Sopenharmony_ci * Request type specific data for interrupt request: 19162306a36Sopenharmony_ci * 0 1 2 3 octet 19262306a36Sopenharmony_ci * +----------------+----------------+----------------+----------------+ 19362306a36Sopenharmony_ci * | interval | 0 | 4 19462306a36Sopenharmony_ci * +----------------+----------------+----------------+----------------+ 19562306a36Sopenharmony_ci * | 0 | 8 19662306a36Sopenharmony_ci * +----------------+----------------+----------------+----------------+ 19762306a36Sopenharmony_ci * interval - uint16_t, time in msecs until interruption 19862306a36Sopenharmony_ci * 19962306a36Sopenharmony_ci * Request type specific data for control request: 20062306a36Sopenharmony_ci * 0 1 2 3 octet 20162306a36Sopenharmony_ci * +----------------+----------------+----------------+----------------+ 20262306a36Sopenharmony_ci * | data of setup packet | 4 20362306a36Sopenharmony_ci * | | 8 20462306a36Sopenharmony_ci * +----------------+----------------+----------------+----------------+ 20562306a36Sopenharmony_ci * 20662306a36Sopenharmony_ci * Request type specific data for bulk request: 20762306a36Sopenharmony_ci * 0 1 2 3 octet 20862306a36Sopenharmony_ci * +----------------+----------------+----------------+----------------+ 20962306a36Sopenharmony_ci * | 0 | 4 21062306a36Sopenharmony_ci * | 0 | 8 21162306a36Sopenharmony_ci * +----------------+----------------+----------------+----------------+ 21262306a36Sopenharmony_ci * 21362306a36Sopenharmony_ci * Request type specific data for unlink request: 21462306a36Sopenharmony_ci * 0 1 2 3 octet 21562306a36Sopenharmony_ci * +----------------+----------------+----------------+----------------+ 21662306a36Sopenharmony_ci * | unlink_id | 0 | 4 21762306a36Sopenharmony_ci * +----------------+----------------+----------------+----------------+ 21862306a36Sopenharmony_ci * | 0 | 8 21962306a36Sopenharmony_ci * +----------------+----------------+----------------+----------------+ 22062306a36Sopenharmony_ci * unlink_id - uint16_t, request id of request to terminate 22162306a36Sopenharmony_ci * 22262306a36Sopenharmony_ci * seg[] array element layout: 22362306a36Sopenharmony_ci * 0 1 2 3 octet 22462306a36Sopenharmony_ci * +----------------+----------------+----------------+----------------+ 22562306a36Sopenharmony_ci * | gref | 4 22662306a36Sopenharmony_ci * +----------------+----------------+----------------+----------------+ 22762306a36Sopenharmony_ci * | offset | length | 8 22862306a36Sopenharmony_ci * +----------------+----------------+----------------+----------------+ 22962306a36Sopenharmony_ci * gref - uint32_t, grant reference of buffer page 23062306a36Sopenharmony_ci * offset - uint16_t, offset of buffer start in page 23162306a36Sopenharmony_ci * length - uint16_t, length of buffer in page 23262306a36Sopenharmony_ci * 23362306a36Sopenharmony_ci *-------------------------- USB I/O response -------------------------------- 23462306a36Sopenharmony_ci * 23562306a36Sopenharmony_ci * 0 1 2 3 octet 23662306a36Sopenharmony_ci * +----------------+----------------+----------------+----------------+ 23762306a36Sopenharmony_ci * | id | start_frame | 4 23862306a36Sopenharmony_ci * +----------------+----------------+----------------+----------------+ 23962306a36Sopenharmony_ci * | status | 8 24062306a36Sopenharmony_ci * +----------------+----------------+----------------+----------------+ 24162306a36Sopenharmony_ci * | actual_length | 12 24262306a36Sopenharmony_ci * +----------------+----------------+----------------+----------------+ 24362306a36Sopenharmony_ci * | error_count | 16 24462306a36Sopenharmony_ci * +----------------+----------------+----------------+----------------+ 24562306a36Sopenharmony_ci * id - uint16_t, id of the request this response belongs to 24662306a36Sopenharmony_ci * start_frame - uint16_t, start_frame this response (iso requests only) 24762306a36Sopenharmony_ci * status - int32_t, XENUSB_STATUS_* (non-iso requests) 24862306a36Sopenharmony_ci * actual_length - uint32_t, actual size of data transferred 24962306a36Sopenharmony_ci * error_count - uint32_t, number of errors (iso requests) 25062306a36Sopenharmony_ci */ 25162306a36Sopenharmony_ci 25262306a36Sopenharmony_cienum xenusb_spec_version { 25362306a36Sopenharmony_ci XENUSB_VER_UNKNOWN = 0, 25462306a36Sopenharmony_ci XENUSB_VER_USB11, 25562306a36Sopenharmony_ci XENUSB_VER_USB20, 25662306a36Sopenharmony_ci XENUSB_VER_USB30, /* not supported yet */ 25762306a36Sopenharmony_ci}; 25862306a36Sopenharmony_ci 25962306a36Sopenharmony_ci/* 26062306a36Sopenharmony_ci * USB pipe in xenusb_request 26162306a36Sopenharmony_ci * 26262306a36Sopenharmony_ci * - port number: bits 0-4 26362306a36Sopenharmony_ci * (USB_MAXCHILDREN is 31) 26462306a36Sopenharmony_ci * 26562306a36Sopenharmony_ci * - operation flag: bit 5 26662306a36Sopenharmony_ci * (0 = submit urb, 26762306a36Sopenharmony_ci * 1 = unlink urb) 26862306a36Sopenharmony_ci * 26962306a36Sopenharmony_ci * - direction: bit 7 27062306a36Sopenharmony_ci * (0 = Host-to-Device [Out] 27162306a36Sopenharmony_ci * 1 = Device-to-Host [In]) 27262306a36Sopenharmony_ci * 27362306a36Sopenharmony_ci * - device address: bits 8-14 27462306a36Sopenharmony_ci * 27562306a36Sopenharmony_ci * - endpoint: bits 15-18 27662306a36Sopenharmony_ci * 27762306a36Sopenharmony_ci * - pipe type: bits 30-31 27862306a36Sopenharmony_ci * (00 = isochronous, 01 = interrupt, 27962306a36Sopenharmony_ci * 10 = control, 11 = bulk) 28062306a36Sopenharmony_ci */ 28162306a36Sopenharmony_ci 28262306a36Sopenharmony_ci#define XENUSB_PIPE_PORT_MASK 0x0000001f 28362306a36Sopenharmony_ci#define XENUSB_PIPE_UNLINK 0x00000020 28462306a36Sopenharmony_ci#define XENUSB_PIPE_DIR 0x00000080 28562306a36Sopenharmony_ci#define XENUSB_PIPE_DEV_MASK 0x0000007f 28662306a36Sopenharmony_ci#define XENUSB_PIPE_DEV_SHIFT 8 28762306a36Sopenharmony_ci#define XENUSB_PIPE_EP_MASK 0x0000000f 28862306a36Sopenharmony_ci#define XENUSB_PIPE_EP_SHIFT 15 28962306a36Sopenharmony_ci#define XENUSB_PIPE_TYPE_MASK 0x00000003 29062306a36Sopenharmony_ci#define XENUSB_PIPE_TYPE_SHIFT 30 29162306a36Sopenharmony_ci#define XENUSB_PIPE_TYPE_ISOC 0 29262306a36Sopenharmony_ci#define XENUSB_PIPE_TYPE_INT 1 29362306a36Sopenharmony_ci#define XENUSB_PIPE_TYPE_CTRL 2 29462306a36Sopenharmony_ci#define XENUSB_PIPE_TYPE_BULK 3 29562306a36Sopenharmony_ci 29662306a36Sopenharmony_ci#define xenusb_pipeportnum(pipe) ((pipe) & XENUSB_PIPE_PORT_MASK) 29762306a36Sopenharmony_ci#define xenusb_setportnum_pipe(pipe, portnum) ((pipe) | (portnum)) 29862306a36Sopenharmony_ci 29962306a36Sopenharmony_ci#define xenusb_pipeunlink(pipe) ((pipe) & XENUSB_PIPE_UNLINK) 30062306a36Sopenharmony_ci#define xenusb_pipesubmit(pipe) (!xenusb_pipeunlink(pipe)) 30162306a36Sopenharmony_ci#define xenusb_setunlink_pipe(pipe) ((pipe) | XENUSB_PIPE_UNLINK) 30262306a36Sopenharmony_ci 30362306a36Sopenharmony_ci#define xenusb_pipein(pipe) ((pipe) & XENUSB_PIPE_DIR) 30462306a36Sopenharmony_ci#define xenusb_pipeout(pipe) (!xenusb_pipein(pipe)) 30562306a36Sopenharmony_ci 30662306a36Sopenharmony_ci#define xenusb_pipedevice(pipe) \ 30762306a36Sopenharmony_ci (((pipe) >> XENUSB_PIPE_DEV_SHIFT) & XENUSB_PIPE_DEV_MASK) 30862306a36Sopenharmony_ci 30962306a36Sopenharmony_ci#define xenusb_pipeendpoint(pipe) \ 31062306a36Sopenharmony_ci (((pipe) >> XENUSB_PIPE_EP_SHIFT) & XENUSB_PIPE_EP_MASK) 31162306a36Sopenharmony_ci 31262306a36Sopenharmony_ci#define xenusb_pipetype(pipe) \ 31362306a36Sopenharmony_ci (((pipe) >> XENUSB_PIPE_TYPE_SHIFT) & XENUSB_PIPE_TYPE_MASK) 31462306a36Sopenharmony_ci#define xenusb_pipeisoc(pipe) (xenusb_pipetype(pipe) == XENUSB_PIPE_TYPE_ISOC) 31562306a36Sopenharmony_ci#define xenusb_pipeint(pipe) (xenusb_pipetype(pipe) == XENUSB_PIPE_TYPE_INT) 31662306a36Sopenharmony_ci#define xenusb_pipectrl(pipe) (xenusb_pipetype(pipe) == XENUSB_PIPE_TYPE_CTRL) 31762306a36Sopenharmony_ci#define xenusb_pipebulk(pipe) (xenusb_pipetype(pipe) == XENUSB_PIPE_TYPE_BULK) 31862306a36Sopenharmony_ci 31962306a36Sopenharmony_ci#define XENUSB_MAX_SEGMENTS_PER_REQUEST (16) 32062306a36Sopenharmony_ci#define XENUSB_MAX_PORTNR 31 32162306a36Sopenharmony_ci#define XENUSB_RING_SIZE 4096 32262306a36Sopenharmony_ci 32362306a36Sopenharmony_ci/* 32462306a36Sopenharmony_ci * RING for transferring urbs. 32562306a36Sopenharmony_ci */ 32662306a36Sopenharmony_cistruct xenusb_request_segment { 32762306a36Sopenharmony_ci grant_ref_t gref; 32862306a36Sopenharmony_ci uint16_t offset; 32962306a36Sopenharmony_ci uint16_t length; 33062306a36Sopenharmony_ci}; 33162306a36Sopenharmony_ci 33262306a36Sopenharmony_cistruct xenusb_urb_request { 33362306a36Sopenharmony_ci uint16_t id; /* request id */ 33462306a36Sopenharmony_ci uint16_t nr_buffer_segs; /* number of urb->transfer_buffer segments */ 33562306a36Sopenharmony_ci 33662306a36Sopenharmony_ci /* basic urb parameter */ 33762306a36Sopenharmony_ci uint32_t pipe; 33862306a36Sopenharmony_ci uint16_t transfer_flags; 33962306a36Sopenharmony_ci#define XENUSB_SHORT_NOT_OK 0x0001 34062306a36Sopenharmony_ci uint16_t buffer_length; 34162306a36Sopenharmony_ci union { 34262306a36Sopenharmony_ci uint8_t ctrl[8]; /* setup_packet (Ctrl) */ 34362306a36Sopenharmony_ci 34462306a36Sopenharmony_ci struct { 34562306a36Sopenharmony_ci uint16_t interval; /* maximum (1024*8) in usb core */ 34662306a36Sopenharmony_ci uint16_t start_frame; /* start frame */ 34762306a36Sopenharmony_ci uint16_t number_of_packets; /* number of ISO packet */ 34862306a36Sopenharmony_ci uint16_t nr_frame_desc_segs; /* number of iso_frame_desc segments */ 34962306a36Sopenharmony_ci } isoc; 35062306a36Sopenharmony_ci 35162306a36Sopenharmony_ci struct { 35262306a36Sopenharmony_ci uint16_t interval; /* maximum (1024*8) in usb core */ 35362306a36Sopenharmony_ci uint16_t pad[3]; 35462306a36Sopenharmony_ci } intr; 35562306a36Sopenharmony_ci 35662306a36Sopenharmony_ci struct { 35762306a36Sopenharmony_ci uint16_t unlink_id; /* unlink request id */ 35862306a36Sopenharmony_ci uint16_t pad[3]; 35962306a36Sopenharmony_ci } unlink; 36062306a36Sopenharmony_ci 36162306a36Sopenharmony_ci } u; 36262306a36Sopenharmony_ci 36362306a36Sopenharmony_ci /* urb data segments */ 36462306a36Sopenharmony_ci struct xenusb_request_segment seg[XENUSB_MAX_SEGMENTS_PER_REQUEST]; 36562306a36Sopenharmony_ci}; 36662306a36Sopenharmony_ci 36762306a36Sopenharmony_cistruct xenusb_urb_response { 36862306a36Sopenharmony_ci uint16_t id; /* request id */ 36962306a36Sopenharmony_ci uint16_t start_frame; /* start frame (ISO) */ 37062306a36Sopenharmony_ci int32_t status; /* status (non-ISO) */ 37162306a36Sopenharmony_ci#define XENUSB_STATUS_OK 0 37262306a36Sopenharmony_ci#define XENUSB_STATUS_NODEV (-19) 37362306a36Sopenharmony_ci#define XENUSB_STATUS_INVAL (-22) 37462306a36Sopenharmony_ci#define XENUSB_STATUS_STALL (-32) 37562306a36Sopenharmony_ci#define XENUSB_STATUS_IOERROR (-71) 37662306a36Sopenharmony_ci#define XENUSB_STATUS_BABBLE (-75) 37762306a36Sopenharmony_ci#define XENUSB_STATUS_SHUTDOWN (-108) 37862306a36Sopenharmony_ci int32_t actual_length; /* actual transfer length */ 37962306a36Sopenharmony_ci int32_t error_count; /* number of ISO errors */ 38062306a36Sopenharmony_ci}; 38162306a36Sopenharmony_ci 38262306a36Sopenharmony_ciDEFINE_RING_TYPES(xenusb_urb, struct xenusb_urb_request, struct xenusb_urb_response); 38362306a36Sopenharmony_ci#define XENUSB_URB_RING_SIZE __CONST_RING_SIZE(xenusb_urb, XENUSB_RING_SIZE) 38462306a36Sopenharmony_ci 38562306a36Sopenharmony_ci/* 38662306a36Sopenharmony_ci * RING for notifying connect/disconnect events to frontend 38762306a36Sopenharmony_ci */ 38862306a36Sopenharmony_cistruct xenusb_conn_request { 38962306a36Sopenharmony_ci uint16_t id; 39062306a36Sopenharmony_ci}; 39162306a36Sopenharmony_ci 39262306a36Sopenharmony_cistruct xenusb_conn_response { 39362306a36Sopenharmony_ci uint16_t id; /* request id */ 39462306a36Sopenharmony_ci uint8_t portnum; /* port number */ 39562306a36Sopenharmony_ci uint8_t speed; /* usb_device_speed */ 39662306a36Sopenharmony_ci#define XENUSB_SPEED_NONE 0 39762306a36Sopenharmony_ci#define XENUSB_SPEED_LOW 1 39862306a36Sopenharmony_ci#define XENUSB_SPEED_FULL 2 39962306a36Sopenharmony_ci#define XENUSB_SPEED_HIGH 3 40062306a36Sopenharmony_ci}; 40162306a36Sopenharmony_ci 40262306a36Sopenharmony_ciDEFINE_RING_TYPES(xenusb_conn, struct xenusb_conn_request, struct xenusb_conn_response); 40362306a36Sopenharmony_ci#define XENUSB_CONN_RING_SIZE __CONST_RING_SIZE(xenusb_conn, XENUSB_RING_SIZE) 40462306a36Sopenharmony_ci 40562306a36Sopenharmony_ci#endif /* __XEN_PUBLIC_IO_USBIF_H__ */ 406