4 * USB I/O interface for Xen guest OSes.
6 * Copyright (C) 2009, FUJITSU LABORATORIES LTD.
7 * Author: Noboru Iwamatsu <n_iwamatsu@jp.fujitsu.com>
9 * Permission is hereby granted, free of charge, to any person obtaining a copy
10 * of this software and associated documentation files (the "Software"), to
11 * deal in the Software without restriction, including without limitation the
12 * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
13 * sell copies of the Software, and to permit persons to whom the Software is
14 * furnished to do so, subject to the following conditions:
16 * The above copyright notice and this permission notice shall be included in
17 * all copies or substantial portions of the Software.
19 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
24 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
25 * DEALINGS IN THE SOFTWARE.
28 #ifndef __XEN_PUBLIC_IO_USBIF_H__
29 #define __XEN_PUBLIC_IO_USBIF_H__
32 #include "../grant_table.h"
34 enum usb_spec_version {
38 USB_VER_USB30, /* not supported yet */
42 * USB pipe in usbif_request
44 * bits 0-5 are specific bits for virtual USB driver.
45 * bits 7-31 are standard urb pipe.
47 * - port number(NEW): bits 0-4
48 * (USB_MAXCHILDREN is 31)
50 * - operation flag(NEW): bit 5
55 * (0 = Host-to-Device [Out]
56 * 1 = Device-to-Host [In])
58 * - device address: bits 8-14
60 * - endpoint: bits 15-18
62 * - pipe type: bits 30-31
63 * (00 = isochronous, 01 = interrupt,
64 * 10 = control, 11 = bulk)
66 #define usbif_pipeportnum(pipe) ((pipe) & 0x1f)
67 #define usbif_setportnum_pipe(pipe, portnum) \
70 #define usbif_pipeunlink(pipe) ((pipe) & 0x20)
71 #define usbif_pipesubmit(pipe) (!usbif_pipeunlink(pipe))
72 #define usbif_setunlink_pipe(pipe) ((pipe)|(0x20))
74 #define USBIF_BACK_MAX_PENDING_REQS (128)
75 #define USBIF_MAX_SEGMENTS_PER_REQUEST (16)
78 * RING for transferring urbs.
80 struct usbif_request_segment {
86 struct usbif_urb_request {
87 uint16_t id; /* request id */
88 uint16_t nr_buffer_segs; /* number of urb->transfer_buffer segments */
90 /* basic urb parameter */
92 uint16_t transfer_flags;
93 uint16_t buffer_length;
95 uint8_t ctrl[8]; /* setup_packet (Ctrl) */
98 uint16_t interval; /* maximum (1024*8) in usb core */
99 uint16_t start_frame; /* start frame */
100 uint16_t number_of_packets; /* number of ISO packet */
101 uint16_t nr_frame_desc_segs; /* number of iso_frame_desc segments */
105 uint16_t interval; /* maximum (1024*8) in usb core */
110 uint16_t unlink_id; /* unlink request id */
116 /* urb data segments */
117 struct usbif_request_segment seg[USBIF_MAX_SEGMENTS_PER_REQUEST];
119 typedef struct usbif_urb_request usbif_urb_request_t;
121 struct usbif_urb_response {
122 uint16_t id; /* request id */
123 uint16_t start_frame; /* start frame (ISO) */
124 int32_t status; /* status (non-ISO) */
125 int32_t actual_length; /* actual transfer length */
126 int32_t error_count; /* number of ISO errors */
128 typedef struct usbif_urb_response usbif_urb_response_t;
130 DEFINE_RING_TYPES(usbif_urb, struct usbif_urb_request, struct usbif_urb_response);
131 #define USB_URB_RING_SIZE __CONST_RING_SIZE(usbif_urb, PAGE_SIZE)
134 * RING for notifying connect/disconnect events to frontend
136 struct usbif_conn_request {
139 typedef struct usbif_conn_request usbif_conn_request_t;
141 struct usbif_conn_response {
142 uint16_t id; /* request id */
143 uint8_t portnum; /* port number */
144 uint8_t speed; /* usb_device_speed */
146 typedef struct usbif_conn_response usbif_conn_response_t;
148 DEFINE_RING_TYPES(usbif_conn, struct usbif_conn_request, struct usbif_conn_response);
149 #define USB_CONN_RING_SIZE __CONST_RING_SIZE(usbif_conn, PAGE_SIZE)
151 #endif /* __XEN_PUBLIC_IO_USBIF_H__ */