Print this page
3503 usba doesn't initialize cc_no_resources, causes gibberish output in kstat
Reviewed by: Garrett D'Amore <garrett@damore.org>
Reviewed by: Richard Lowe <richlowe@richlowe.net>
Split |
Close |
Expand all |
Collapse all |
--- old/usr/src/uts/common/sys/usb/usba/hcdi.h
+++ new/usr/src/uts/common/sys/usb/usba/hcdi.h
1 1 /*
2 2 * CDDL HEADER START
3 3 *
4 4 * The contents of this file are subject to the terms of the
5 5 * Common Development and Distribution License (the "License").
6 6 * You may not use this file except in compliance with the License.
7 7 *
8 8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 9 * or http://www.opensolaris.org/os/licensing.
10 10 * See the License for the specific language governing permissions
11 11 * and limitations under the License.
12 12 *
13 13 * When distributing Covered Code, include this CDDL HEADER in each
14 14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 15 * If applicable, add the following below this CDDL HEADER, with the
16 16 * fields enclosed by brackets "[]" replaced with your own identifying
17 17 * information: Portions Copyright [yyyy] [name of copyright owner]
18 18 *
19 19 * CDDL HEADER END
20 20 */
21 21 /*
22 22 * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
23 23 * Use is subject to license terms.
24 24 */
25 25
26 26 #ifndef _SYS_USB_HCDI_H
27 27 #define _SYS_USB_HCDI_H
28 28
29 29
30 30 #ifdef __cplusplus
31 31 extern "C" {
32 32 #endif
33 33
34 34 #include <sys/usb/usba/genconsole.h>
35 35 #include <sys/usb/usba/usba_types.h>
36 36
37 37 /*
38 38 * HCD ops structure
39 39 *
40 40 * - this structure defines all entry points into HCD
41 41 *
42 42 * - all client driver USBAI functions that require HCD
43 43 * involvement go through this ops table
44 44 *
45 45 * - at HCD attach time, the HCD ops are passed to
46 46 * to the USBA through usba_hcdi_attach()
47 47 *
48 48 * some of these ops implement the semantics of the corresponding
49 49 * USBAI interfaces. Refer to usbai.h for detailed description
50 50 */
51 51 #define HCDI_OPS_VERSION_0 0
52 52 #define HCDI_OPS_VERSION_1 1
53 53 #define HCDI_OPS_VERSION HCDI_OPS_VERSION_1
54 54
55 55 typedef struct usba_hcdi_ops {
56 56 int usba_hcdi_ops_version; /* implementation version */
57 57
58 58 dev_info_t *usba_hcdi_dip; /* HCD's devinfo ptr */
59 59
60 60 /* can this hcd support pm? */
61 61 int (*usba_hcdi_pm_support)(dev_info_t *dip);
62 62
63 63 /*
64 64 * usba_hcdi_pipe_open:
65 65 * implements the semantics of usb_pipe_open()
66 66 * USBA allocate the pipe_handle which contains
67 67 * pipe_policy and endpoint pointers
68 68 */
69 69 int (*usba_hcdi_pipe_open)(
70 70 usba_pipe_handle_data_t *pipe_handle,
71 71 usb_flags_t usb_flags);
72 72
73 73 /*
74 74 * close a pipe
75 75 */
76 76 int (*usba_hcdi_pipe_close)(
77 77 usba_pipe_handle_data_t *pipe_handle,
78 78 usb_flags_t usb_flags);
79 79
80 80 /*
81 81 * pipe management
82 82 */
83 83 int (*usba_hcdi_pipe_reset)(
84 84 usba_pipe_handle_data_t *pipe_handle,
85 85 usb_flags_t usb_flags);
86 86
87 87 /*
88 88 * pipe management
89 89 */
90 90 void (*usba_hcdi_pipe_reset_data_toggle)(
91 91 usba_pipe_handle_data_t *pipe_handle);
92 92
93 93 /*
94 94 * data transfer management
95 95 */
96 96 int (*usba_hcdi_pipe_ctrl_xfer)(
97 97 usba_pipe_handle_data_t *pipe_handle,
98 98 usb_ctrl_req_t *usb_ctrl_req,
99 99 usb_flags_t usb_flags);
100 100
101 101 /*
102 102 * get HCD limitation on bulk xfer at a time?
103 103 */
104 104 int (*usba_hcdi_bulk_transfer_size)(
105 105 usba_device_t *usba_device,
106 106 size_t *size);
107 107
108 108 /*
109 109 * do bulk read/write
110 110 */
111 111 int (*usba_hcdi_pipe_bulk_xfer)(
112 112 usba_pipe_handle_data_t *pipe_handle,
113 113 usb_bulk_req_t *usb_bulk_req,
114 114 usb_flags_t usb_flags);
115 115
116 116 /*
117 117 * do interrupt pipe read/write
118 118 */
119 119 int (*usba_hcdi_pipe_intr_xfer)(
120 120 usba_pipe_handle_data_t *pipe_handle,
121 121 usb_intr_req_t *usb_intr_req,
122 122 usb_flags_t usb_flags);
123 123
124 124 /*
125 125 * stop interrupt pipe polling
126 126 */
127 127 int (*usba_hcdi_pipe_stop_intr_polling)(
128 128 usba_pipe_handle_data_t *pipe_handle,
129 129 usb_flags_t usb_flags);
130 130
131 131 /*
132 132 * do isoch pipe read/write
133 133 */
134 134 int (*usba_hcdi_pipe_isoc_xfer)(
135 135 usba_pipe_handle_data_t *pipe_handle,
136 136 usb_isoc_req_t *usb_isoc_req,
137 137 usb_flags_t usb_flags);
138 138
139 139 /*
140 140 * stop isoc pipe polling
141 141 */
142 142 int (*usba_hcdi_pipe_stop_isoc_polling)(
143 143 usba_pipe_handle_data_t *pipe_handle,
144 144 usb_flags_t usb_flags);
145 145
146 146 /* utility isoc functions */
147 147 int (*usba_hcdi_get_current_frame_number)(
148 148 usba_device_t *usba_device,
149 149 usb_frame_number_t *frame_number);
150 150
151 151 int (*usba_hcdi_get_max_isoc_pkts)(
152 152 usba_device_t *usba_device,
153 153 uint_t *max_isoc_pkts_per_request);
154 154
155 155 /*
156 156 * Initialize OBP support for input
157 157 */
158 158 int (*usba_hcdi_console_input_init)(
159 159 usba_pipe_handle_data_t *pipe_handle,
160 160 uchar_t **obp_buf,
161 161 usb_console_info_impl_t *console_input_info);
162 162
163 163 /*
164 164 * Free resources allocated by usba_hcdi_console_input_init
165 165 */
166 166 int (*usba_hcdi_console_input_fini)(
167 167 usb_console_info_impl_t *console_input_info);
168 168
169 169 /*
170 170 * Save controller state information
171 171 */
172 172 int (*usba_hcdi_console_input_enter)(
173 173 usb_console_info_impl_t *console_input_info);
174 174
175 175 /*
176 176 * Read character from controller
177 177 */
178 178 int (*usba_hcdi_console_read)(
179 179 usb_console_info_impl_t *console_input_info,
180 180 uint_t *num_characters);
181 181
182 182 /*
183 183 * Restore controller state information
184 184 */
185 185 int (*usba_hcdi_console_input_exit)(
186 186 usb_console_info_impl_t *console_input_info);
187 187
188 188
189 189 /*
190 190 * VERSION 1 ops: support for polled output
191 191 */
192 192 int (*usba_hcdi_console_output_init)(
193 193 usba_pipe_handle_data_t *pipe_handle,
194 194 usb_console_info_impl_t *console_output_info);
195 195
196 196 int (*usba_hcdi_console_output_fini)(
197 197 usb_console_info_impl_t *console_output_info);
198 198
199 199 int (*usba_hcdi_console_output_enter)(
200 200 usb_console_info_impl_t *console_output_info);
201 201
202 202 int (*usba_hcdi_console_write)(
203 203 usb_console_info_impl_t *console_output_info,
204 204 uchar_t *buf,
205 205 uint_t num_characters,
206 206 uint_t *num_characters_written);
207 207
208 208 int (*usba_hcdi_console_output_exit)(
209 209 usb_console_info_impl_t *console_output_info);
210 210 } usba_hcdi_ops_t;
211 211
212 212
213 213 /*
214 214 * callback support:
215 215 * this function handles all HCD callbacks as follows:
216 216 * - USB_FLAGS_SLEEP determines whether the client driver made
217 217 * a synchronous or asynchronous USBAI call
218 218 * - for synchronous calls, the args are copied into the pipe handle
219 219 * and the sync cv of the pipe handle is signalled
220 220 * - for async calls and completion_reason = 0, the normal callback
221 221 * is invoked
222 222 * - for async calls and completion_reason != 0, the exception
223 223 * callback is invoked
224 224 */
225 225 void
226 226 usba_hcdi_cb(usba_pipe_handle_data_t *ph,
227 227 usb_opaque_t req,
228 228 usb_cr_t completion_reason);
229 229
230 230 /*
231 231 * function to duplicate a interrupt/isoc request (for HCD)
232 232 */
233 233 usb_intr_req_t *usba_hcdi_dup_intr_req(dev_info_t *,
234 234 usb_intr_req_t *, size_t, usb_flags_t);
235 235 usb_isoc_req_t *usba_hcdi_dup_isoc_req(dev_info_t *,
236 236 usb_isoc_req_t *, usb_flags_t);
237 237
238 238 /* access to private member of requests */
239 239 usb_opaque_t usba_hcdi_get_req_private(usb_opaque_t);
240 240 void usba_hcdi_set_req_private(usb_opaque_t, usb_opaque_t);
241 241 usba_pipe_handle_data_t *
242 242 usba_hcdi_get_ph_data(usba_device_t *, uint8_t);
243 243
244 244 /* data toggle get and set */
245 245 uchar_t usba_hcdi_get_data_toggle(usba_device_t *, uint8_t);
246 246 void usba_hcdi_set_data_toggle(usba_device_t *, uint8_t, uchar_t);
247 247
248 248 /*
249 249 * HCD Nexus driver support:
250 250 */
251 251
252 252 /*
253 253 * hcd_ops allocator/deallocator
254 254 * USBA allocates the usba_hcdi_ops so we can easily handle
255 255 * versioning
256 256 */
257 257 usba_hcdi_ops_t *usba_alloc_hcdi_ops();
258 258 void usba_free_hcdi_ops(usba_hcdi_ops_t *);
259 259
260 260 /*
261 261 * Argument structure for usba_hcdi_register
262 262 */
263 263 typedef struct usba_hcdi_register_args {
264 264 uint_t usba_hcdi_register_version;
265 265 dev_info_t *usba_hcdi_register_dip;
266 266 usba_hcdi_ops_t *usba_hcdi_register_ops;
267 267 ddi_dma_attr_t *usba_hcdi_register_dma_attr;
268 268 ddi_iblock_cookie_t usba_hcdi_register_iblock_cookie;
269 269
270 270 } usba_hcdi_register_args_t;
271 271
272 272 #define HCDI_REGISTER_VERS_0 0
273 273 #define HCDI_REGISTER_VERSION HCDI_REGISTER_VERS_0
274 274
275 275
276 276 /*
277 277 * make this instance known to USBA
278 278 *
279 279 * the HCD must initialize the hcdi_ops before calling this function
280 280 */
281 281 int usba_hcdi_register(usba_hcdi_register_args_t *, uint_t);
282 282
283 283 /*
284 284 * detach support
285 285 */
286 286 void usba_hcdi_unregister(dev_info_t *);
287 287
288 288 /*
289 289 * Hotplug kstats named structure
290 290 *
291 291 * Number of types of USB transfers
292 292 */
293 293 #define USB_N_COUNT_KSTATS 4
294 294
295 295 typedef struct hcdi_hotplug_stats {
296 296 struct kstat_named hcdi_hotplug_total_success;
297 297 struct kstat_named hcdi_hotplug_success;
298 298 struct kstat_named hcdi_hotplug_total_failure;
299 299 struct kstat_named hcdi_hotplug_failure;
300 300 struct kstat_named hcdi_device_count;
301 301 } hcdi_hotplug_stats_t;
302 302
303 303 /*
304 304 * USB error kstats named structure
305 305 */
306 306 typedef struct hcdi_error_stats {
307 307 /* transport completion codes */
308 308 struct kstat_named cc_crc;
309 309 struct kstat_named cc_bitstuffing;
310 310 struct kstat_named cc_data_toggle_mm;
311 311 struct kstat_named cc_stall;
312 312 struct kstat_named cc_dev_not_resp;
313 313 struct kstat_named cc_pid_checkfailure;
314 314 struct kstat_named cc_unexp_pid;
315 315 struct kstat_named cc_data_overrun;
316 316 struct kstat_named cc_data_underrun;
317 317 struct kstat_named cc_buffer_overrun;
↓ open down ↓ |
317 lines elided |
↑ open up ↑ |
318 318 struct kstat_named cc_buffer_underrun;
319 319 struct kstat_named cc_timeout;
320 320 struct kstat_named cc_not_accessed;
321 321 struct kstat_named cc_no_resources;
322 322 struct kstat_named cc_unspecified_err;
323 323 struct kstat_named cc_stopped_polling;
324 324 struct kstat_named cc_pipe_closing;
325 325 struct kstat_named cc_pipe_reset;
326 326 struct kstat_named cc_not_supported;
327 327 struct kstat_named cc_flushed;
328 -
329 -#ifdef NOTYETNEEDED
330 - /* USBA function return values */
331 - struct kstat_named hcdi_usb_failure;
332 - struct kstat_named hcdi_usb_no_resources;
333 - struct kstat_named hcdi_usb_no_bandwidth;
334 - struct kstat_named hcdi_usb_pipe_reserved;
335 - struct kstat_named hcdi_usb_pipe_unshareable;
336 - struct kstat_named hcdi_usb_not_supported;
337 - struct kstat_named hcdi_usb_pipe_error;
338 - struct kstat_named hcdi_usb_pipe_busy;
339 -#endif
340 328 } hcdi_error_stats_t;
341 329
342 330 /*
343 331 * hcdi kstat defines
344 332 * XXX this needs to be a function
345 333 */
346 334 #define HCDI_HOTPLUG_STATS(hcdi) ((hcdi)->hcdi_hotplug_stats)
347 335 #define HCDI_HOTPLUG_STATS_DATA(hcdi) \
348 336 ((hcdi_hotplug_stats_t *)HCDI_HOTPLUG_STATS((hcdi))->ks_data)
349 337
350 338 #define HCDI_ERROR_STATS(hcdi) ((hcdi)->hcdi_error_stats)
351 339 #define HCDI_ERROR_STATS_DATA(hcdi) \
352 340 ((hcdi_error_stats_t *)HCDI_ERROR_STATS((hcdi))->ks_data)
353 341
354 342
355 343 #ifdef __cplusplus
356 344 }
357 345 #endif
358 346
359 347 #endif /* _SYS_USB_HCDI_H */
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX