1 /*
2 * usbif.h
3 *
4 * USB I/O interface for Xen guest OSes.
5 *
6 * Copyright (C) 2009, FUJITSU LABORATORIES LTD.
7 * Author: Noboru Iwamatsu <n_iwamatsu@jp.fujitsu.com>
8 *
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:
15 *
16 * The above copyright notice and this permission notice shall be included in
17 * all copies or substantial portions of the Software.
18 *
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.
26 */
27
28 #ifndef __XEN_PUBLIC_IO_USBIF_H__
29 #define __XEN_PUBLIC_IO_USBIF_H__
30
31 #include "ring.h"
32 #include "../grant_table.h"
33
34 enum usb_spec_version {
35 USB_VER_UNKNOWN = 0,
36 USB_VER_USB11,
37 USB_VER_USB20,
38 USB_VER_USB30, /* not supported yet */
39 };
40
41 /*
42 * USB pipe in usbif_request
43 *
44 * bits 0-5 are specific bits for virtual USB driver.
45 * bits 7-31 are standard urb pipe.
46 *
47 * - port number(NEW): bits 0-4
48 * (USB_MAXCHILDREN is 31)
49 *
50 * - operation flag(NEW): bit 5
51 * (0 = submit urb,
52 * 1 = unlink urb)
53 *
54 * - direction: bit 7
55 * (0 = Host-to-Device [Out]
56 * 1 = Device-to-Host [In])
57 *
58 * - device address: bits 8-14
59 *
60 * - endpoint: bits 15-18
61 *
62 * - pipe type: bits 30-31
63 * (00 = isochronous, 01 = interrupt,
64 * 10 = control, 11 = bulk)
65 */
66 #define usbif_pipeportnum(pipe) ((pipe) & 0x1f)
67 #define usbif_setportnum_pipe(pipe, portnum) \
68 ((pipe)|(portnum))
69
70 #define usbif_pipeunlink(pipe) ((pipe) & 0x20)
71 #define usbif_pipesubmit(pipe) (!usbif_pipeunlink(pipe))
72 #define usbif_setunlink_pipe(pipe) ((pipe)|(0x20))
73
74 #define USBIF_BACK_MAX_PENDING_REQS (128)
75 #define USBIF_MAX_SEGMENTS_PER_REQUEST (16)
76
77 /*
78 * RING for transferring urbs.
79 */
80 struct usbif_request_segment {
81 grant_ref_t gref;
82 uint16_t offset;
83 uint16_t length;
84 };
85
86 struct usbif_urb_request {
87 uint16_t id; /* request id */
88 uint16_t nr_buffer_segs; /* number of urb->transfer_buffer segments */
89
90 /* basic urb parameter */
91 uint32_t pipe;
92 uint16_t transfer_flags;
93 uint16_t buffer_length;
94 union {
95 uint8_t ctrl[8]; /* setup_packet (Ctrl) */
96
97 struct {
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 */
102 } isoc;
103
104 struct {
105 uint16_t interval; /* maximum (1024*8) in usb core */
106 uint16_t pad[3];
107 } intr;
108
109 struct {
110 uint16_t unlink_id; /* unlink request id */
111 uint16_t pad[3];
112 } unlink;
113
114 } u;
115
116 /* urb data segments */
117 struct usbif_request_segment seg[USBIF_MAX_SEGMENTS_PER_REQUEST];
118 };
119 typedef struct usbif_urb_request usbif_urb_request_t;
120
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 */
127 };
128 typedef struct usbif_urb_response usbif_urb_response_t;
129
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)
132
133 /*
134 * RING for notifying connect/disconnect events to frontend
135 */
136 struct usbif_conn_request {
137 uint16_t id;
138 };
139 typedef struct usbif_conn_request usbif_conn_request_t;
140
141 struct usbif_conn_response {
142 uint16_t id; /* request id */
143 uint8_t portnum; /* port number */
144 uint8_t speed; /* usb_device_speed */
145 };
146 typedef struct usbif_conn_response usbif_conn_response_t;
147
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)
150
151 #endif /* __XEN_PUBLIC_IO_USBIF_H__ */
Cache object: 95bca8e052d3397ba9b0804807908c53
|