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