Print this page
7215 usba logging through cmn_err (via usba_bus_ctl) output erroneously includes tab
7216 usba logging through cmn_err (via usba_bus_ctl) output truncates (leading) some device names
Split |
Close |
Expand all |
Collapse all |
--- old/usr/src/uts/common/sys/usb/usba/usba_impl.h
+++ new/usr/src/uts/common/sys/usb/usba/usba_impl.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 * Copyright 2014 Garrett D'Amore <garrett@damore.org>
26 26 */
27 27
28 28 #ifndef _SYS_USB_USBA_USBA_IMPL_H
29 29 #define _SYS_USB_USBA_USBA_IMPL_H
30 30
31 31
32 32 #include <sys/usb/usba.h>
33 33 #include <sys/usb/usba/hcdi.h>
34 34 #include <sys/usb/usba/hubdi.h>
35 35 #include <sys/usb/usba/usba_private.h>
36 36 #include <sys/usb/usba/usba_types.h>
37 37 #include <sys/taskq.h>
38 38 #include <sys/disp.h>
39 39
40 40 #ifdef __cplusplus
41 41 extern "C" {
42 42 #endif
43 43
44 44
45 45 /*
46 46 * UGEN binding values specified in <hcd>.conf files
47 47 */
48 48 #define USBA_UGEN_DEVICE_BINDING 1
49 49 #define USBA_UGEN_INTERFACE_BINDING 2
50 50 #define USBA_UGEN_INTERFACE_ASSOCIATION_BINDING 3
51 51
52 52 /*
53 53 * Allocating a USB address
54 54 */
55 55 #define USBA_MAX_ADDRESS 127
56 56 #define USBA_ADDRESS_ARRAY_SIZE ((USBA_MAX_ADDRESS+8)/8)
57 57
58 58 /*
59 59 * async execution of usb_pipe_* functions which have a
60 60 * completion callback parameter (eg. usb_pipe_close(),
61 61 * usb_pipe_reset(), usb_pipe_stop_*_polling()
62 62 */
63 63 typedef struct usba_pipe_async_req {
64 64 dev_info_t *dip;
65 65 struct usba_ph_impl *ph_impl;
66 66 usb_opaque_t arg;
67 67 usb_flags_t usb_flags;
68 68 void (*callback)(
69 69 usb_pipe_handle_t ph,
70 70 usb_opaque_t callback_arg,
71 71 int rval,
72 72 usb_cb_flags_t error_code);
73 73 usb_opaque_t callback_arg;
74 74 int (*sync_func)(dev_info_t *,
75 75 usba_ph_impl_t *,
76 76 struct usba_pipe_async_req *,
77 77 usb_flags_t);
78 78 } usba_pipe_async_req_t;
79 79 _NOTE(SCHEME_PROTECTS_DATA("unique per call", usba_pipe_async_req_t))
80 80
81 81 /* per-pipe taskq */
82 82 int usba_async_ph_req(usba_pipe_handle_data_t *, void (*func)(void *),
83 83 void *, usb_flags_t);
84 84
85 85 /*
86 86 * usb wrapper around pm_request_power_change to allow for
87 87 * non blocking behavior
88 88 */
89 89 typedef struct usba_pm_req {
90 90 dev_info_t *dip;
91 91 int comp;
92 92 int old_level;
93 93 int level;
94 94 void (*cb)(void *, int);
95 95 void *arg;
96 96 uint_t flags;
97 97 } usba_pm_req_t;
98 98 _NOTE(SCHEME_PROTECTS_DATA("unique per call", usba_pm_req_t))
99 99
100 100
101 101 /*
102 102 * Request wrappers for control/bulk/interrupt and isoch pipes
103 103 * These are hidden from client driver. They serve as place-holders
104 104 * for doing callbacks
105 105 *
106 106 * Request allocation: wrapper + usb_*_req_t alloc'ed together:
107 107 *
108 108 * +-----------------------+
109 109 * | wr_queue | for callbacks
110 110 * +-----------------------+
111 111 * | wr_req |-------+ wr_req points to
112 112 * +-----------------------+ | the req below.
113 113 * | | |
114 114 * | .... | |
115 115 * | req_wrapper_t | |
116 116 * | | |
117 117 * +-----------------------+<------+
118 118 * | |
119 119 * | .... |
120 120 * | ctrl/bulk/intr/isoch |
121 121 * | req_t |
122 122 * | |
123 123 * | |
124 124 * +-----------------------+
125 125 */
126 126 typedef struct usba_req_wrapper {
127 127 /* queueing in either a request or callback queue */
128 128 usba_list_entry_t wr_queue;
129 129
130 130 /*
131 131 * The request could be control/bulk/intr/isoc
132 132 * See usbai.h usb_ctrl_req_t/usb_bulk_req_t
133 133 * usb_intr_req_t/usb_isoc_req_t
134 134 */
135 135 usb_opaque_t wr_req;
136 136
137 137 /* for allocation tracking in usba_device_t */
138 138 usba_list_entry_t wr_allocated_list;
139 139
140 140 /*
141 141 * All reqs that are synchronous sleep on this cv
142 142 * for completion notification.
143 143 * In hcdi soft interrupt handler we call cv_signal()
144 144 */
145 145 kcondvar_t wr_cv;
146 146
147 147 /*
148 148 * This goes hand-in-hand with wr_cv. It is set by the soft intr hdlr
149 149 * before doing a cv_signal
150 150 */
151 151 boolean_t wr_done;
152 152 dev_info_t *wr_dip; /* owner */
153 153
154 154 usb_opaque_t wr_hcd_private; /* for HCD's use */
155 155
156 156 usba_pipe_handle_data_t *wr_ph_data; /* ptr to pipe handle */
157 157
158 158 usb_cr_t wr_cr; /* save cr from HCDI */
159 159 usb_cb_flags_t wr_cb_flags; /* save cb_flags */
160 160 usb_flags_t wr_usb_flags; /* save usb flags from HCDI */
161 161 usb_req_attrs_t wr_attrs; /* save attrs from HCDI */
162 162
163 163 /* total lenght of wrapper and request */
164 164 size_t wr_length;
165 165 } usba_req_wrapper_t;
166 166
167 167 _NOTE(SCHEME_PROTECTS_DATA("method", usba_req_wrapper))
168 168 _NOTE(SCHEME_PROTECTS_DATA("method", usb_ctrl_req))
169 169 _NOTE(SCHEME_PROTECTS_DATA("method", usb_bulk_req))
170 170 _NOTE(SCHEME_PROTECTS_DATA("method", usb_intr_req))
171 171 _NOTE(SCHEME_PROTECTS_DATA("method", usb_isoc_req))
172 172
173 173 /* additional flag for wr_usb_flags */
174 174 #define USBA_WRP_FLAGS_WAIT 0x01
175 175
176 176 /* additional usb flags, not exposed to clients */
177 177 #define USBA_FLAGS_PRIVILEGED 0x02 /* for default pipe operations */
178 178
179 179 /* Macros to convert wrapper to different request and vice-versa */
180 180
181 181 /* to get the wr->wr_req field */
182 182 #define USBA_WRP2REQ(wrp) ((wrp)->wr_req)
183 183
184 184 /* to get the wrapper form the wr_req field */
185 185 #define USBA_REQ2WRP(req) (usba_req_wrapper_t *)\
186 186 ((uintptr_t)(req) - sizeof (usba_req_wrapper_t))
187 187
188 188 /* to set the the address in the wr_req field */
189 189 #define USBA_SETREQ_ADDR(wrp) ((uintptr_t)(wrp) + sizeof (*(wrp)))
190 190
191 191 /* to get the 4 xfer type requests */
192 192 #define USBA_WRP2CTRL_REQ(wrp) ((usb_ctrl_req_t *)USBA_WRP2REQ((wrp)))
193 193 #define USBA_WRP2INTR_REQ(wrp) ((usb_intr_req_t *)USBA_WRP2REQ((wrp)))
194 194 #define USBA_WRP2BULK_REQ(wrp) ((usb_bulk_req_t *)USBA_WRP2REQ((wrp)))
195 195 #define USBA_WRP2ISOC_REQ(wrp) ((usb_isoc_req_t *)USBA_WRP2REQ((wrp)))
196 196
197 197 /* to get pipe_handle from the wrapper */
198 198 #define USBA_WRP2PH_DATA(wrp) \
199 199 (usba_pipe_handle_data_t *)((wrp)->wr_ph_data)
200 200
201 201 /* to get to the wr_queue from the wrapper */
202 202 #define USBA_WRQUEUE2WRP(queue) (usba_req_wrapper_t *)(queue)
203 203
204 204 /* to get to the wr_allocated queue from the wrapper */
205 205 #define USBA_ALLOCQ2WRP(queue) (usba_req_wrapper_t *)((uintptr_t) \
206 206 (queue) - sizeof (usba_list_entry_t) - sizeof (usb_opaque_t))
207 207
208 208
209 209 /* alias for pipe handle member p_usba_private */
210 210 #define p_active_cntrl_req_wrp p_usba_private
211 211
212 212 /*
213 213 * This function is used to get the HCD private field maintained by USBA.
214 214 * HCD calls this function.
215 215 */
216 216 usb_opaque_t usba_hcdi_get_ctrl_req_hcd_private(usb_ctrl_req_t *);
217 217
218 218 /*
219 219 * This function is used to set the HCD private field maintained by USBA.
220 220 * HCD calls this function.
221 221 */
222 222 void usba_hcdi_set_ctrl_req_hcd_private(usb_ctrl_req_t *, usb_opaque_t);
223 223
224 224 int usba_set_usb_address(usba_device_t *);
225 225 void usba_unset_usb_address(usba_device_t *);
226 226
227 227 /*
228 228 * Per Hub Data Structures
229 229 */
230 230 typedef struct usba_hubdi {
231 231 usba_list_entry_t hubdi_list; /* linking in hubdi list */
↓ open down ↓ |
231 lines elided |
↑ open up ↑ |
232 232
233 233 dev_info_t *hubdi_dip; /* ptr to devinfo struct */
234 234
235 235 int hubdi_flags; /* flag options */
236 236
237 237 } usba_hubdi_t;
238 238
239 239 /*
240 240 * usba_get_mfg_prod_sn_str:
241 241 * Return a string containing mfg, product, serial number strings.
242 - * Remove duplicates if some strings are the same.
243 242 */
244 243 char *usba_get_mfg_prod_sn_str(dev_info_t *, char *, int);
245 244
246 245 /* return value when user doesn't specify configuration index */
247 246 #define USBA_DEV_CONFIG_INDEX_UNDEFINED -1
248 247
249 248 /*
250 249 * prototypes
251 250 */
252 251 void usba_usba_initialization();
253 252 void usba_usba_destroy();
254 253
255 254 void usba_usbai_register_initialization();
256 255 void usba_usbai_register_destroy();
257 256
258 257 void usba_usbai_initialization();
259 258 void usba_usbai_destroy();
260 259
261 260 void usba_hubdi_initialization();
262 261 void usba_hubdi_destroy();
263 262
264 263 void usba_devdb_initialization();
265 264 void usba_devdb_destroy();
266 265
267 266 int usba_hubdi_register(dev_info_t *, uint_t);
268 267 int usba_hubdi_unregister(dev_info_t *);
269 268
270 269 int usba_is_root_hub(dev_info_t *dip);
271 270
272 271 usba_device_t *usba_alloc_usba_device(dev_info_t *);
273 272 void usba_free_usba_device(usba_device_t *usba_device_t);
274 273 void usba_clear_data_toggle(usba_device_t *usba_device);
275 274
276 275 void usba_start_next_req(usba_pipe_handle_data_t *ph);
277 276
278 277 int usba_pipe_check_handle(usba_pipe_handle_data_t *);
279 278 int usba_drain_cbs(usba_pipe_handle_data_t *, usb_cb_flags_t,
280 279 usb_cr_t);
281 280 int usba_pipe_setup_func_call(dev_info_t *,
282 281 int (*sync_func)(dev_info_t *,
283 282 usba_ph_impl_t *, usba_pipe_async_req_t *,
284 283 usb_flags_t),
285 284 usba_ph_impl_t *,
286 285 usb_opaque_t,
287 286 usb_flags_t,
288 287 void (*cb)(usb_pipe_handle_t, usb_opaque_t,
289 288 int, usb_cb_flags_t),
290 289 usb_opaque_t);
291 290
292 291
293 292 void usba_pipe_new_state(usba_pipe_handle_data_t *, usb_pipe_state_t);
294 293
295 294 void usba_add_root_hub(dev_info_t *dip);
296 295 void usba_rem_root_hub(dev_info_t *dip);
297 296
298 297 /*
299 298 * retrieve string descriptors for manufacturer, vendor and serial
300 299 * number
301 300 */
302 301 void usba_get_dev_string_descrs(dev_info_t *, usba_device_t *);
303 302
304 303 /*
305 304 * Check if we are not in interrupt context and have
306 305 * USB_FLAGS_SLEEP flags set.
307 306 */
308 307 #define USBA_CHECK_CONTEXT() ASSERT(!(servicing_interrupt()))
309 308
310 309 /*
311 310 * USBA module Masks
312 311 */
313 312 #define DPRINT_MASK_USBA 0x00000001
314 313 #define DPRINT_MASK_USBAI 0x00000002
315 314 #define DPRINT_MASK_HUBDI 0x00000004
316 315 #define DPRINT_MASK_HCDI 0x00000008
317 316 #define DPRINT_MASK_HCDI_DUMPING 0x00000010
318 317 #define DPRINT_MASK_HUBDI_DUMPING 0x00000020
319 318 #define DPRINT_MASK_REGISTER 0x00000040
320 319 #define DPRINT_MASK_DEVDB 0x00000080
321 320 #define DPRINT_MASK_WHCDI 0x00000100
322 321 #define DPRINT_MASK_ALL 0xFFFFFFFF
323 322
324 323 typedef struct usba_log_handle_impl {
325 324 dev_info_t *lh_dip;
326 325 char *lh_name;
327 326 uint_t *lh_errlevel;
328 327 uint_t *lh_mask;
329 328 uint_t *lh_instance_filter;
330 329 uint_t lh_flags;
331 330 } usba_log_handle_impl_t;
332 331
333 332 _NOTE(SCHEME_PROTECTS_DATA("USBA managed data", usba_log_handle_impl))
334 333
335 334 /*
336 335 * Miscellaneous definitions.
337 336 */
338 337
339 338 /* possible strlen of a USB driver's name */
340 339 #define USBA_DRVNAME_LEN 40
341 340
342 341 /* strings passed to usb_dprintfN() are this long */
343 342 #define USBA_PRINT_BUF_LEN 256
344 343
345 344 /*
346 345 * usba_set_node_name() sets a device info node name
347 346 * according to class, subclass, and protocol.
348 347 * a subclass == -1 or protocol == -1 is considered a "don't care".
349 348 */
350 349 #define DONTCARE ((int16_t)-1)
351 350 #define FLAG_INTERFACE_NODE 0
352 351 #define FLAG_DEVICE_NODE 1
353 352 #define FLAG_COMBINED_NODE 2
354 353 #define FLAG_INTERFACE_ASSOCIATION_NODE 3
355 354
356 355 typedef struct node_name_entry {
357 356 int16_t class;
358 357 int16_t subclass;
359 358 int16_t protocol;
360 359 char *name;
361 360 } node_name_entry_t;
362 361
363 362
364 363 /*
365 364 * USB enumeration statistics support
366 365 */
367 366
368 367 /* Flags telling which stats usba_update_hotplug_stats should update */
369 368 #define USBA_TOTAL_HOTPLUG_SUCCESS 0x01
370 369 #define USBA_HOTPLUG_SUCCESS 0x02
371 370 #define USBA_TOTAL_HOTPLUG_FAILURE 0x04
372 371 #define USBA_HOTPLUG_FAILURE 0x08
373 372
374 373 /*
375 374 * Increment enumeration stats indicated by the flags
376 375 */
377 376 void usba_update_hotplug_stats(dev_info_t *, usb_flags_t);
378 377
379 378 /* Retrieve the current enumeration hotplug statistics */
380 379 void usba_get_hotplug_stats(dev_info_t *,
381 380 ulong_t *, ulong_t *, ulong_t *,
382 381 ulong_t *, uchar_t *);
383 382
384 383 /* Reset the resetable hotplug stats */
385 384 void usba_reset_hotplug_stats(dev_info_t *);
386 385
387 386
388 387 extern usb_log_handle_t usbai_log_handle;
389 388 extern kmutex_t usbai_mutex;
390 389
391 390 void usba_req_normal_cb(usba_req_wrapper_t *);
392 391 void usba_req_exc_cb(usba_req_wrapper_t *, usb_cr_t, usb_cb_flags_t);
393 392 void usba_do_req_exc_cb(usba_req_wrapper_t *, usb_cr_t,
394 393 usb_cb_flags_t);
395 394 void usba_req_set_cb_flags(usba_req_wrapper_t *, usb_cb_flags_t);
396 395
397 396 /*
398 397 * Creating/Destroying children (root hub, and hub children)
399 398 */
400 399 int usba_create_child_devi(dev_info_t *, char *, usba_hcdi_ops_t *,
401 400 dev_info_t *, usb_port_status_t,
402 401 usba_device_t *, dev_info_t **);
403 402
404 403 int usba_destroy_child_devi(dev_info_t *, uint_t);
405 404
406 405 /* utility function to map rval to a meaningful cr */
407 406 usb_cr_t usba_rval2cr(int);
408 407
409 408 /* various conversion functions */
410 409 usb_pipe_handle_t usba_get_dflt_pipe_handle(dev_info_t *);
411 410 dev_info_t *usba_get_dip(usb_pipe_handle_t);
412 411 usb_pipe_handle_t usba_usbdev_to_dflt_pipe_handle(usba_device_t *);
413 412 usb_pipe_handle_t usba_get_pipe_handle(usba_pipe_handle_data_t *);
414 413 usba_pipe_handle_data_t *usba_get_ph_data(usb_pipe_handle_t);
415 414 usb_pipe_state_t usba_get_ph_state(usba_pipe_handle_data_t *);
416 415 int usba_get_ph_ref_count(usba_pipe_handle_data_t *);
417 416
418 417 /* increment and decrement ref_count */
419 418 usba_pipe_handle_data_t *usba_hold_ph_data(usb_pipe_handle_t);
420 419 void usba_release_ph_data(usba_ph_impl_t *);
421 420
422 421 /* close all pipe and mark them persistent */
423 422 void usba_persistent_pipe_close(usba_device_t *);
424 423
425 424 /* reopen pipes that are marked persistent */
426 425 int usba_persistent_pipe_open(usba_device_t *);
427 426
428 427 /* check for leaks in hubd and usb_mid */
429 428 void usba_check_for_leaks(usba_device_t *);
430 429
431 430 /* free request wrappers */
432 431 void usba_req_wrapper_free(usba_req_wrapper_t *);
433 432
434 433 /* usb device capture for the specific client driver */
435 434 typedef struct usb_dev_cap {
436 435 dev_info_t *dip;
437 436 usb_dev_driver_callback_t usba_dev_driver_cb;
438 437 } usb_dev_cap_t;
439 438
440 439 usb_dev_cap_t usb_cap;
441 440 _NOTE(SCHEME_PROTECTS_DATA("unique device capture data", usb_cap))
442 441
443 442 #ifdef __cplusplus
444 443 }
445 444 #endif
446 445
447 446 #endif /* _SYS_USB_USBA_USBA_IMPL_H */
↓ open down ↓ |
195 lines elided |
↑ open up ↑ |
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX