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_types.h
+++ new/usr/src/uts/common/sys/usb/usba/usba_types.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 *
↓ open down ↓ |
12 lines elided |
↑ open up ↑ |
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 * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
22 22 * Use is subject to license terms.
23 + *
24 + * Copyright 2014 Garrett D'Amore <garrett@damore.org>
23 25 */
24 26
25 27 #ifndef _SYS_USB_USBA_USBA_TYPES_H
26 28 #define _SYS_USB_USBA_USBA_TYPES_H
27 29
28 30
29 31 #include <sys/taskq.h>
30 32 #include <sys/usb/usba/usba_private.h>
31 33 #include <sys/usb/usba/usbai_private.h>
32 34
33 35 #ifdef __cplusplus
34 36 extern "C" {
35 37 #endif
36 38
37 39 /* backup structure for opaque usb_pipe_handle_t */
38 40 typedef struct usba_ph_impl {
39 41 kmutex_t usba_ph_mutex;
40 42 struct usba_pipe_handle_data *usba_ph_data; /* actual pipe handle */
41 43 dev_info_t *usba_ph_dip; /* owner dip */
42 44 usb_ep_descr_t usba_ph_ep; /* save ep descr */
43 45 usb_pipe_policy_t usba_ph_policy; /* saved pipe policy */
44 46 uint_t usba_ph_flags;
45 47
46 48 /*
47 49 * usba_ph_ref_count is a count of the number of
48 50 * concurrent activities on this pipe
49 51 */
50 52 int usba_ph_ref_count;
51 53
52 54 /* pipe state management */
53 55 usb_pipe_state_t usba_ph_state;
54 56 int usba_ph_state_changing;
55 57 } usba_ph_impl_t;
56 58
57 59 _NOTE(MUTEX_PROTECTS_DATA(usba_ph_impl::usba_ph_mutex, usba_ph_impl))
58 60 _NOTE(DATA_READABLE_WITHOUT_LOCK(usba_ph_impl::usba_ph_data))
59 61 _NOTE(DATA_READABLE_WITHOUT_LOCK(usba_ph_impl::usba_ph_dip))
60 62 _NOTE(DATA_READABLE_WITHOUT_LOCK(usba_ph_impl::usba_ph_ep))
61 63 _NOTE(DATA_READABLE_WITHOUT_LOCK(usba_ph_impl::usba_ph_policy))
62 64
63 65 /* for usba_ph_flags */
64 66 #define USBA_PH_DATA_TOGGLE 0x01 /* mask for data toggle */
65 67 #define USBA_PH_DATA_PERSISTENT 0x02 /* persistent pipe */
66 68
67 69
68 70 /*
69 71 * usba_pipe_handle_data
70 72 * allocated by USBA and used by USBA and HCD but opaque to
71 73 * client driver
72 74 *
73 75 * pipes can be shared but pipe_handles are unique
74 76 *
75 77 * p_hcd_private is a pointer to private data for HCD. This space
76 78 * is allocated and maintained by HCD
77 79 */
78 80 typedef struct usba_pipe_handle_data {
79 81 struct usba_ph_impl *p_ph_impl; /* backpointer to ph_impl */
80 82
81 83 /* For linking pipe requests on the pipe */
82 84 usba_list_entry_t p_queue;
83 85
84 86 /* shared usba_device structure */
85 87 struct usba_device *p_usba_device; /* set on pipe open */
86 88
87 89 /* pipe policy and endpoint descriptor for this pipe */
88 90 usb_pipe_policy_t p_policy; /* maintained by USBA */
89 91 usb_ep_descr_t p_ep;
90 92
91 93 /* passed during open. needed for reset etc. */
92 94 dev_info_t *p_dip;
93 95
94 96 /* access control */
95 97 kmutex_t p_mutex; /* mutex protecting pipe handle */
96 98
97 99 /* per-pipe private data for HCD */
98 100 usb_opaque_t p_hcd_private;
99 101
100 102 /* per-pipe private data for client */
101 103 usb_opaque_t p_client_private;
102 104
103 105 /*
104 106 * p_req_count is the count of number requests active
105 107 * on this pipe
106 108 */
107 109 int p_req_count;
108 110
109 111 /* private use by USBA */
110 112 usb_opaque_t p_usba_private;
111 113
112 114 /*
113 115 * each pipe handle has its own taskq for callbacks and async reqs
114 116 * Note that this will not be used for normal callbacks if
115 117 * USB_FLAGS_SERIALIZED_CB is passed to usb_pipe_open().
116 118 */
117 119 taskq_t *p_taskq;
118 120
119 121 /* thread currently serving the queue */
120 122 kthread_t *p_thread_id;
121 123
122 124 /* cb queue serviced by taskq thread */
123 125 usba_list_entry_t p_cb_queue;
124 126
125 127 /* count for soft interrupts */
126 128 uint_t p_soft_intr;
127 129
128 130 /* flag for special things */
129 131 uint_t p_spec_flag;
130 132
131 133 } usba_pipe_handle_data_t;
132 134
133 135 #define USBA_PH_FLAG_USE_SOFT_INTR 0x1
134 136 #define USBA_PH_FLAG_TQ_SHARE 0x2 /* Shared TaskQ for callbacks */
135 137
136 138
137 139
138 140 /* macro to get the endpoint descriptor */
139 141 #define USBA_DEFAULT_PIPE_EP 0 /* ep 0 is default pipe */
140 142 #define USBA_PH2ENDPOINT(ph) (((usba_pipe_handle_data_t *)(ph))->p_ep)
141 143
142 144 #define USBA_PIPE_CLOSING(state) \
143 145 (((state) == USB_PIPE_STATE_CLOSING) || \
144 146 ((state) == USB_PIPE_STATE_CLOSED))
145 147
146 148 #define USBA_IS_DEFAULT_PIPE(ph) ((ph) == \
147 149 (ph)->p_usba_device->usb_ph_list[USBA_DEFAULT_PIPE_EP].usba_ph_data)
148 150
149 151 _NOTE(MUTEX_PROTECTS_DATA(usba_pipe_handle_data::p_mutex, \
150 152 usba_pipe_handle_data))
151 153
152 154 /* these should be really stable data */
153 155 _NOTE(DATA_READABLE_WITHOUT_LOCK(usba_pipe_handle_data::p_ph_impl))
154 156 _NOTE(DATA_READABLE_WITHOUT_LOCK(usba_pipe_handle_data::p_usba_device))
155 157 _NOTE(DATA_READABLE_WITHOUT_LOCK(usba_pipe_handle_data::p_hcd_private))
156 158 _NOTE(DATA_READABLE_WITHOUT_LOCK(usba_pipe_handle_data::p_client_private))
157 159 _NOTE(DATA_READABLE_WITHOUT_LOCK(usba_pipe_handle_data::p_ep))
158 160 _NOTE(DATA_READABLE_WITHOUT_LOCK(usba_pipe_handle_data::p_dip))
159 161 _NOTE(DATA_READABLE_WITHOUT_LOCK(usba_pipe_handle_data::p_taskq))
160 162
161 163
162 164 /*
163 165 * usb_addr:
164 166 * This is the USB address of a device
165 167 */
166 168 typedef uchar_t usb_addr_t;
167 169
168 170 #define USBA_DEFAULT_ADDR 0
169 171
170 172 /*
171 173 * number of endpoint per device, 16 IN and 16 OUT.
172 174 * this define is used for pipehandle list, pipe reserved list
173 175 * and pipe open count array.
174 176 * these lists are indexed by endpoint number * ((address & direction)? 2 : 1)
175 177 *
176 178 * We use a bit mask for exclusive open tracking and therefore
177 179 * USB_N_ENDPOINTS must be equal to the bit size of int.
178 180 *
179 181 */
180 182 #define USBA_N_ENDPOINTS 32
181 183
182 184 /*
183 185 * USB spec defines 4 different power states of any usb device.
184 186 * They are D0, D1, D2 & D3. So, we need a total of 5 pm-components
185 187 * 4 for power and 1 for name.
186 188 */
187 189 #define USBA_N_PMCOMP 5
188 190
189 191 /*
190 192 * usb port status
191 193 */
192 194 typedef uint8_t usb_port_status_t;
193 195 typedef uint16_t usb_port_t;
194 196 typedef uint32_t usb_port_mask_t;
195 197
196 198 #define USBA_LOW_SPEED_DEV 0x1
197 199 #define USBA_FULL_SPEED_DEV 0x2
198 200 #define USBA_HIGH_SPEED_DEV 0x3
199 201
200 202 /*
201 203 * NDI event is registered on a per-dip basis. usba_device can be
202 204 * shared by multiple dips, hence the following structure is
203 205 * need to keep per-dip event info.
204 206 */
205 207 typedef struct usba_evdata {
206 208 struct usba_evdata *ev_next;
207 209 dev_info_t *ev_dip;
208 210
209 211 /* NDI evetn service callback ids */
210 212 ddi_callback_id_t ev_rm_cb_id;
211 213 ddi_callback_id_t ev_ins_cb_id;
212 214 ddi_callback_id_t ev_suspend_cb_id;
213 215 ddi_callback_id_t ev_resume_cb_id;
214 216 } usba_evdata_t;
215 217
216 218 /*
217 219 * a client may request dev_data multiple times (eg. for
218 220 * ugen support) so we need a linked list
↓ open down ↓ |
186 lines elided |
↑ open up ↑ |
219 221 */
220 222 typedef struct usb_client_dev_data_list {
221 223 struct usb_client_dev_data_list *cddl_next;
222 224 struct usb_client_dev_data_list *cddl_prev;
223 225 dev_info_t *cddl_dip;
224 226 usb_client_dev_data_t *cddl_dev_data;
225 227 uint_t cddl_ifno;
226 228 } usb_client_dev_data_list_t;
227 229
228 230 /*
229 - * wireless usb specific data
230 - */
231 -typedef struct usba_wireless_data {
232 - uint8_t *wusb_bos; /* raw bos descr */
233 - uint_t wusb_bos_length; /* length of bos descr */
234 - usb_uwb_cap_descr_t *uwb_descr; /* UWB capability descr */
235 -} usba_wireless_data_t;
236 -
237 -
238 -/*
239 231 * This structure uniquely identifies a USB device
240 232 * with all interfaces, or just one interface of a USB device.
241 233 * usba_device is associated with a devinfo node
242 234 *
243 235 * This structure is allocated and maintained by USBA and
244 236 * read-only for HCD
245 237 *
246 238 * There can be multiple clients per device (multi-class
247 239 * device) in which case this structure is shared.
248 240 */
249 241 typedef struct usba_device {
250 242 /* for linking all usba_devices on this bus */
251 243 usba_list_entry_t usb_device_list;
252 244
253 245 /* linked list of all pipe handles on this device per endpoint */
254 246 struct usba_ph_impl usb_ph_list[USBA_N_ENDPOINTS];
255 247
256 248 kmutex_t usb_mutex; /* protecting usba_device */
257 249
258 250 dev_info_t *usb_dip;
259 251
260 252 struct usba_hcdi_ops *usb_hcdi_ops; /* ptr to HCD ops */
261 253
262 254 struct usba_hubdi *usb_hubdi;
263 255
264 256 usb_addr_t usb_addr; /* usb address */
265 257
266 258 uchar_t usb_no_cpr; /* CPR? */
267 259
268 260 dev_info_t *usb_root_hub_dip;
269 261 struct hubd *usb_root_hubd; /* for HC or WA */
270 262
271 263 usb_dev_descr_t *usb_dev_descr; /* device descriptor */
272 264
273 265 uchar_t *usb_cfg; /* raw config descriptor */
274 266 size_t usb_cfg_length; /* length of raw descr */
275 267
276 268 char *usb_mfg_str; /* manufacturer string */
277 269 char *usb_product_str; /* product string */
278 270 char *usb_serialno_str; /* serial number string */
279 271 char *usb_preferred_driver; /* user's choice */
280 272
281 273 usb_port_status_t usb_port_status; /* usb hub port status */
282 274 usb_port_t usb_port;
283 275
284 276 /* To support split transactions */
285 277 struct usba_device *usb_hs_hub_usba_dev; /* HS hub usba device */
286 278 usb_addr_t usb_hs_hub_addr; /* High speed hub address */
287 279 usb_port_t usb_hs_hub_port; /* High speed hub port */
288 280
289 281 /* For high speed hub bandwidth allocation scheme */
290 282 uint_t usb_hs_hub_min_bandwidth;
291 283 uint_t usb_hs_hub_bandwidth[32];
292 284
293 285 /* store all config cloud here */
294 286 uchar_t **usb_cfg_array;
295 287 uint_t usb_cfg_array_length;
↓ open down ↓ |
47 lines elided |
↑ open up ↑ |
296 288
297 289 uint16_t *usb_cfg_array_len;
298 290 uint_t usb_cfg_array_len_length;
299 291
300 292 uint_t usb_cfg_value;
301 293 uint_t usb_active_cfg_ndx;
302 294 char **usb_cfg_str_descr;
303 295 uchar_t usb_n_cfgs;
304 296 uchar_t usb_n_ifs;
305 297
306 - /* To support WUSB */
307 - boolean_t usb_is_wa;
308 - boolean_t usb_is_wireless;
309 - usba_wireless_data_t *usb_wireless_data;
310 -
311 298 /*
312 299 * power drawn from hub, if > 0, the power has been
313 300 * subtracted from the parent hub's power budget
314 301 */
315 302 uint16_t usb_pwr_from_hub;
316 303
317 304 /* ref count, if > 0, this structure is in use */
318 305 int usb_ref_count;
319 306
320 307 /* list of requests allocated for this device, detects leaks */
321 308 usba_list_entry_t usb_allocated; /* alloc'ed reqs list */
322 309
323 310 /* NDI event service cookies */
324 311 ddi_eventcookie_t rm_cookie;
325 312 ddi_eventcookie_t ins_cookie;
326 313 ddi_eventcookie_t suspend_cookie;
327 314 ddi_eventcookie_t resume_cookie;
328 315
329 316 /* linked list of callid (per-devinfo) */
330 317 usba_evdata_t *usb_evdata;
331 318
332 319 /* client cleanup checks */
333 320 uchar_t *usb_client_flags;
334 321
335 322 struct {
336 323 dev_info_t *dip;
337 324 } *usb_client_attach_list;
338 325
339 326 usb_client_dev_data_list_t usb_client_dev_data_list;
340 327
341 328 struct {
342 329 dev_info_t *dip;
343 330 usb_event_t *ev_data;
344 331 } *usb_client_ev_cb_list;
345 332
346 333 /* Shared task queue implementation. */
347 334 taskq_t *usb_shared_taskq[USBA_N_ENDPOINTS];
348 335 uchar_t usb_shared_taskq_ref_count
↓ open down ↓ |
28 lines elided |
↑ open up ↑ |
349 336 [USBA_N_ENDPOINTS];
350 337 } usba_device_t;
351 338
352 339 #define USBA_CLIENT_FLAG_SIZE 1
353 340 #define USBA_CLIENT_FLAG_ATTACH 0x01
354 341 #define USBA_CLIENT_FLAG_EV_CBS 0x02
355 342 #define USBA_CLIENT_FLAG_DEV_DATA 0x04
356 343
357 344 _NOTE(MUTEX_PROTECTS_DATA(usba_device::usb_mutex, usba_device))
358 345 _NOTE(MUTEX_PROTECTS_DATA(usba_device::usb_mutex, usba_evdata))
359 -_NOTE(MUTEX_PROTECTS_DATA(usba_device::usb_mutex, usba_wireless_data))
360 346
361 347 _NOTE(SCHEME_PROTECTS_DATA("chg at attach only",
362 348 usba_evdata::ev_rm_cb_id))
363 349 _NOTE(SCHEME_PROTECTS_DATA("chg at attach only",
364 350 usba_evdata::ev_ins_cb_id))
365 351 _NOTE(SCHEME_PROTECTS_DATA("chg at attach only",
366 352 usba_evdata::ev_suspend_cb_id))
367 353 _NOTE(SCHEME_PROTECTS_DATA("chg at attach only",
368 354 usba_evdata::ev_resume_cb_id))
369 355
370 -_NOTE(SCHEME_PROTECTS_DATA("chg at attach only",
371 - usba_wireless_data::wusb_bos))
372 -_NOTE(SCHEME_PROTECTS_DATA("chg at attach only",
373 - usba_wireless_data::wusb_bos_length))
374 -_NOTE(SCHEME_PROTECTS_DATA("chg at attach only",
375 - usba_wireless_data::uwb_descr))
376 -
377 356 /* this should be really stable data */
378 357 _NOTE(DATA_READABLE_WITHOUT_LOCK(usba_device::usb_serialno_str))
379 358 _NOTE(DATA_READABLE_WITHOUT_LOCK(usba_device::usb_root_hub_dip))
380 359 _NOTE(DATA_READABLE_WITHOUT_LOCK(usba_device::usb_root_hubd))
381 360 _NOTE(DATA_READABLE_WITHOUT_LOCK(usba_device::usb_product_str))
382 361 _NOTE(DATA_READABLE_WITHOUT_LOCK(usba_device::usb_preferred_driver))
383 362 _NOTE(DATA_READABLE_WITHOUT_LOCK(usba_device::usb_port))
384 363 _NOTE(DATA_READABLE_WITHOUT_LOCK(usba_device::usb_n_ifs))
385 364 _NOTE(DATA_READABLE_WITHOUT_LOCK(usba_device::usb_n_cfgs))
386 365 _NOTE(DATA_READABLE_WITHOUT_LOCK(usba_device::usb_mfg_str))
387 366 _NOTE(DATA_READABLE_WITHOUT_LOCK(usba_device::usb_dev_descr))
388 367 _NOTE(DATA_READABLE_WITHOUT_LOCK(usba_device::usb_ph_list))
389 368 _NOTE(DATA_READABLE_WITHOUT_LOCK(usba_device::usb_cfg_value))
390 369 _NOTE(DATA_READABLE_WITHOUT_LOCK(usba_device::usb_cfg_str_descr))
391 370 _NOTE(DATA_READABLE_WITHOUT_LOCK(usba_device::usb_cfg_length))
392 371 _NOTE(DATA_READABLE_WITHOUT_LOCK(usba_device::usb_cfg_array))
393 372 _NOTE(DATA_READABLE_WITHOUT_LOCK(usba_device::usb_cfg_array_len))
394 373 _NOTE(DATA_READABLE_WITHOUT_LOCK(usba_device::usb_cfg_array_length))
395 374 _NOTE(DATA_READABLE_WITHOUT_LOCK(usba_device::usb_cfg_array_len_length))
396 375 _NOTE(DATA_READABLE_WITHOUT_LOCK(usba_device::usb_cfg))
397 376 _NOTE(DATA_READABLE_WITHOUT_LOCK(usba_device::usb_hcdi_ops))
↓ open down ↓ |
11 lines elided |
↑ open up ↑ |
398 377 _NOTE(DATA_READABLE_WITHOUT_LOCK(usba_device::usb_addr))
399 378 _NOTE(DATA_READABLE_WITHOUT_LOCK(usba_device::usb_port_status))
400 379 _NOTE(DATA_READABLE_WITHOUT_LOCK(usba_device::rm_cookie))
401 380 _NOTE(DATA_READABLE_WITHOUT_LOCK(usba_device::ins_cookie))
402 381 _NOTE(DATA_READABLE_WITHOUT_LOCK(usba_device::suspend_cookie))
403 382 _NOTE(DATA_READABLE_WITHOUT_LOCK(usba_device::resume_cookie))
404 383 _NOTE(DATA_READABLE_WITHOUT_LOCK(usba_device::usb_client_flags))
405 384 _NOTE(DATA_READABLE_WITHOUT_LOCK(usba_device::usb_client_attach_list))
406 385 _NOTE(DATA_READABLE_WITHOUT_LOCK(usba_device::usb_client_ev_cb_list))
407 386 _NOTE(DATA_READABLE_WITHOUT_LOCK(usba_device::usb_dip))
408 -_NOTE(DATA_READABLE_WITHOUT_LOCK(usba_device::usb_is_wireless))
409 -_NOTE(DATA_READABLE_WITHOUT_LOCK(usba_device::usb_wireless_data))
410 -_NOTE(DATA_READABLE_WITHOUT_LOCK(usba_device::usb_is_wa))
411 387 _NOTE(SCHEME_PROTECTS_DATA("set at device creation",
412 388 usba_device::usb_shared_taskq))
413 389
414 390 _NOTE(SCHEME_PROTECTS_DATA("local use only",
415 391 usb_key_descr::bDescriptorType))
416 392 _NOTE(SCHEME_PROTECTS_DATA("local use only",
417 393 usb_key_descr::bLength))
418 394 /*
419 395 * serialization in drivers
420 396 */
421 397 typedef struct usba_serialization_impl {
422 398 dev_info_t *s_dip;
423 399 kcondvar_t s_cv;
424 400 kmutex_t s_mutex;
425 401 kthread_t *s_thread;
426 402 int s_count;
427 403 uint_t s_flag;
428 404 } usba_serialization_impl_t;
429 405
430 406 _NOTE(SCHEME_PROTECTS_DATA("unshared private data",
431 407 usba_serialization_impl))
432 408
433 409 #ifdef __cplusplus
434 410 }
435 411 #endif
436 412
437 413 #endif /* _SYS_USB_USBA_USBA_TYPES_H */
↓ open down ↓ |
17 lines elided |
↑ open up ↑ |
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX