xref: /titanic_41/usr/src/uts/common/sys/usb/usba/wa.h (revision ff0e937b36dcde1a47ff7b00aa76a491c0dc07a8)
1 /*
2  * CDDL HEADER START
3  *
4  * The contents of this file are subject to the terms of the
5  * Common Development and Distribution License (the "License").
6  * You may not use this file except in compliance with the License.
7  *
8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9  * or http://www.opensolaris.org/os/licensing.
10  * See the License for the specific language governing permissions
11  * and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL HEADER in each
14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15  * If applicable, add the following below this CDDL HEADER, with the
16  * fields enclosed by brackets "[]" replaced with your own identifying
17  * information: Portions Copyright [yyyy] [name of copyright owner]
18  *
19  * CDDL HEADER END
20  */
21 /*
22  * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
23  * Use is subject to license terms.
24  */
25 
26 #ifndef	_SYS_USB_WA_H
27 #define	_SYS_USB_WA_H
28 
29 #ifdef	__cplusplus
30 extern "C" {
31 #endif
32 
33 #include <sys/usb/usba.h>
34 #include <sys/usb/usba/usba_types.h>
35 #include <sys/id32.h>
36 
37 /* Wire adapter class extension for descriptors */
38 typedef struct usb_wa_descr {
39 	uint8_t		bLength;
40 	uint8_t		bDescriptorType;
41 	uint16_t	bcdWAVersion;
42 	uint8_t		bNumPorts;
43 	uint8_t		bmAttributes;
44 	uint16_t	wNumRPipes;
45 	uint16_t	wRPipeMaxBlock;
46 	uint8_t		bRPipeBlockSize;
47 	uint8_t		bPwrOn2PwrGood;
48 	uint8_t		bNumMMCIEs;
49 	uint8_t		DeviceRemovable;
50 } usb_wa_descr_t;
51 
52 typedef struct usb_wa_rpipe_descr {
53 	uint8_t		bLength;
54 	uint8_t		bDescriptorType;
55 	uint16_t	wRPipeIndex;
56 	uint16_t	wRequests;
57 	uint16_t	wBlocks;
58 	uint16_t	wMaxPacketSize;
59 	union {
60 		struct {
61 			uint8_t	bHSHubAddress;
62 			uint8_t	bHSHubPort;
63 		} dwa_value;
64 
65 		struct {
66 			uint8_t	bMaxBurst;
67 			uint8_t	bDeviceInfoIndex;
68 		} hwa_value;
69 	} wa_value;
70 
71 	uint8_t		bSpeed;
72 	uint8_t		bDeviceAddress;
73 	uint8_t		bEndpointAddress;
74 	uint8_t		bDataSequence;
75 	uint32_t	dwCurrentWindow;
76 	uint8_t		bMaxDataSequence;
77 	uint8_t		bInterval;
78 	uint8_t		bOverTheAirInterval;
79 	uint8_t		bmAttribute;
80 	uint8_t		bmCharacteristics;
81 	uint8_t		bmRetryOptions;
82 	uint16_t	wNumTransactionErrors;
83 } usb_wa_rpipe_descr_t;
84 
85 /* Rpipe bmCharacteristics mask and bits */
86 #define	USB_RPIPE_CHA_MASK		0x0f
87 #define	USB_RPIPE_CHA_CTRL		0x01
88 #define	USB_RRIPE_CHA_ISOC		0x02
89 #define	USB_RRIPE_CHA_BULK		0x04
90 #define	USB_RPIPE_CHA_INTR		0x08
91 
92 /*
93  * ************************************************************
94  * Wire adapter class request related structures and data types
95  * ************************************************************
96  */
97 
98 /* Wire adapter class specific requests */
99 #define	WA_REQ_ABORT_RPIPE		0x0e
100 #define	WA_REQ_RESET_RPIPE		0x0f
101 
102 /* HWA specific requests as host controller, T8-50 */
103 #define	HWA_REQ_ADD_MMC_IE		0x14
104 #define	HWA_REQ_REMOVE_MMC_IE		0x15
105 #define	HWA_REQ_SET_NUM_DNTS		0x16
106 #define	HWA_REQ_SET_CLUSTER_ID		0x17
107 #define	HWA_REQ_SET_DEVICE_INFO		0x18
108 #define	HWA_REQ_GET_TIME		0x19
109 #define	HWA_REQ_SET_STREAM_IDX		0x1a
110 #define	HWA_REQ_SET_WUSB_MAS		0x1b
111 #define	HWA_REQ_CH_STOP			0x1c
112 
113 /* DWA specific requests */
114 #define	DWA_REQ_SET_EP_ATTRIB		0x1e
115 
116 /* wLength for wire adapter class requests */
117 #define	WA_GET_RPIPE_STATUS_LEN		1
118 #define	WA_GET_WA_STATUS_LEN		4
119 
120 /* wLength for HWA specific requests */
121 #define	WUSB_SET_DEV_INFO_LEN		36
122 #define	WUSB_SET_WUSB_MAS_LEN		32
123 
124 /* wLength for DWA specific requests */
125 #define	DWA_GET_STATUS_LEN		4
126 #define	DWA_ISOC_EP_ATTRIB_LEN		6
127 
128 /* Wire adapter class feature selector */
129 #define	WA_DEV_ENABLE			1
130 #define	WA_DEV_RESET			2
131 #define	WA_RPIPE_PAUSE			1
132 #define	WA_RPIPE_STALL			2
133 
134 /* Rpipe status bits */
135 #define	WA_RPIPE_IDLE			0x01
136 #define	WA_PRIPE_PAUSED			0x02
137 #define	WA_RPIPE_CONFIGURED		0x04
138 #define	WA_RPIPE_STALLED		0x08
139 
140 /* Wire adapter status bits */
141 #define	WA_HC_ENABLED			0x00000001
142 #define	WA_HC_RESET_IN_PROGRESS		0x00000002
143 
144 /* HWA specific definitions */
145 #define	WUSB_CLASS_IF_REQ_IN_TYPE	(USB_DEV_REQ_DEV_TO_HOST \
146 					|USB_DEV_REQ_TYPE_CLASS \
147 					|USB_DEV_REQ_RCPT_IF)
148 
149 #define	WUSB_CLASS_IF_REQ_OUT_TYPE	(USB_DEV_REQ_HOST_TO_DEV \
150 					|USB_DEV_REQ_TYPE_CLASS \
151 					|USB_DEV_REQ_RCPT_IF)
152 
153 #define	WA_CLASS_RPIPE_REQ_IN_TYPE	(USB_DEV_REQ_DEV_TO_HOST \
154 					|USB_DEV_REQ_TYPE_CLASS \
155 					|USB_DEV_REQ_RCPT_RPIPE)
156 
157 #define	WA_CLASS_RPIPE_REQ_OUT_TYPE	(USB_DEV_REQ_HOST_TO_DEV \
158 					|USB_DEV_REQ_TYPE_CLASS \
159 					|USB_DEV_REQ_RCPT_RPIPE)
160 
161 #define	HWA_TIME_ADJ			0
162 #define	HWA_TIME_BPST			1
163 #define	HWA_TIME_WUSB			2
164 
165 typedef struct hwa_dev_info {
166 	uint8_t		bmDeviceAvailablilityInfo[32];
167 	uint8_t		bDeviceAddress;
168 	uint8_t		wPHYRates[2];
169 	uint8_t		bmDeviceAttribute;
170 } hwa_dev_info_t;
171 
172 /* DWA specific definitions */
173 typedef struct dwa_isoc_ep_attrib {
174 	uint16_t	wMaxStreamDelay;
175 	uint16_t	wOverTheAirPacketSize;
176 	uint16_t	wReserved;
177 } dwa_isoc_ep_attrib_t;
178 
179 
180 /*
181  * *****************************************************************
182  * Wire adapter class notification related structures and data types
183  * *****************************************************************
184  */
185 
186 /* Wire adapter class specific notification */
187 #define	WA_NOTIF_TYPE_TRANSFER		0x93
188 
189 typedef struct wa_notif_header {
190 	uint8_t		bLength;
191 	uint8_t		bNotifyType;
192 } wa_notif_header_t;
193 
194 typedef struct wa_notif_transfer {
195 	uint8_t		bLength;
196 	uint8_t		bNotifyType;
197 	uint8_t		bEndpoint;
198 	uint8_t		bReserved;
199 } wa_notif_transfer_t;
200 
201 /* HWA specific notifications */
202 #define	HWA_NOTIF_TYPE_BPST_ADJ		0x94
203 #define	HWA_NOTIF_TYPE_DN_RECEIVED	0x95
204 
205 typedef struct hwa_notif_bpst_adj {
206 	uint8_t		bLength;
207 	uint8_t		bNotifyType;
208 	uint8_t		bAdjustment;
209 } hwa_notif_bpst_adj_t;
210 
211 typedef struct hwa_notif_dn_recvd {
212 	uint8_t		bLength;
213 	uint8_t		bNotifyType;
214 	uint8_t		bSourceDeviceAddr;
215 	uint8_t		bmAttributes;
216 	uint8_t		notifdata[1];	/* variable length raw data */
217 } hwa_notif_dn_recvd_t;
218 
219 /* DWA specific notifications */
220 #define	DWA_NOTIF_TYPE_RWAKE		0x91
221 #define	DWA_NOTIF_TYPE_PORTSTATUS	0x92
222 
223 typedef struct dwa_notif_rwake {
224 	uint8_t		bLength;
225 	uint8_t		bNotifyType;
226 } dwa_notif_rwake;
227 
228 typedef struct dwa_notif_portstatus {
229 	uint8_t		bLength;
230 	uint8_t		bNotifyType;
231 	uint8_t		bPortIndex;
232 } dwa_notif_portstatus;
233 
234 
235 /*
236  * *********************************************************************
237  * Wire adapter class transfer request related structures and data types
238  * *********************************************************************
239  */
240 
241 /* Wire adapter class transfer requests */
242 #define	WA_XFER_REQ_TYPE_CTRL		0x80
243 #define	WA_XFER_REQ_TYPE_BULK_INTR	0x81
244 #define	WA_XFER_REQ_TYPE_ABORT		0x84
245 /* HWA specific transfer request */
246 #define	HWA_XFER_REQ_TYPE_ISOC		0x82
247 
248 /* Wire adapter class transfer request length */
249 #define	WA_CTRL_REQ_LEN			0x18
250 #define	WA_BULK_INTR_REQ_LEN		0x10
251 #define	WA_ABORT_REQ_LEN		0x08
252 /* HWA specific transfer request length */
253 #define	HWA_ISOC_REQ_LEN		0x14
254 
255 typedef struct wa_ctrl_req {
256 	uint8_t		bLength;
257 	uint8_t		bRequestType;
258 	uint16_t	wRPipe;
259 	uint32_t	dwTransferID;
260 	uint32_t	dwTransferLength;
261 	uint8_t		bTransferSegment;
262 	uint8_t		bmAttribute;
263 	uint16_t	wReserved;
264 	uint8_t		baSetupData[8];
265 } wa_ctrl_req_t;
266 
267 /* ctrl request bmAttribute */
268 #define	WA_CTRL_DIR_MASK		0x01
269 #define	WA_CTRL_DIR_IN			0x01
270 #define	WA_CTRL_DIR_OUT			0x00
271 
272 /* ctrl request bmAttribute valid only for HWA */
273 #define	WA_CTRL_SECRT_MASK		0x02
274 #define	WA_CTRL_SECRT_REGULAR		0x00
275 #define	WA_CTRL_SECRT_NONE		0x02
276 
277 typedef struct wa_bulk_intr_req {
278 	uint8_t		bLength;
279 	uint8_t		bRequestType;
280 	uint16_t	wRPipe;
281 	uint32_t	dwTransferID;
282 	uint32_t	dwTransferLength;
283 	uint8_t		bTransferSegment;
284 	uint8_t		bReserved;
285 	uint16_t	wReserved;
286 } wa_bulk_intr_req_t;
287 
288 typedef struct wa_abort_req {
289 	uint8_t		bLength;
290 	uint8_t		bRequestType;
291 	uint16_t	wRPipe;
292 	uint32_t	dwTransferID;
293 } wa_abort_req_t;
294 
295 
296 /* HWA specific transfer request definitions */
297 typedef struct hwa_isoc_req {
298 	uint8_t		bLength;
299 	uint8_t		bRequestType;
300 	uint16_t	wRPipe;
301 	uint32_t	dwTransferID;
302 	uint32_t	dwTransferLength;
303 	uint8_t		bTransferSegment;
304 	uint8_t		bReserved;
305 	uint16_t	wPresentationTime;
306 	uint32_t	dwNumOfPackets;
307 } wa_isoc_req_t;
308 
309 typedef struct hwa_isoc_pkt {
310 	uint16_t	wLength;
311 	uint8_t		bPacketType;
312 	uint8_t		bReserved;
313 	uint16_t	PacketLength[1];	/* variable length array */
314 } hwa_isoc_pkt_t;
315 
316 #define	HWA_ISOC_PKT_INFO_TYPE		0xa0
317 
318 /* Wire adapter class transfer result */
319 typedef struct wa_xfer_result {
320 	uint8_t		bLength;
321 	uint8_t		bResultType;
322 	uint32_t	dwTransferID;
323 	uint32_t	dwTransferLength;
324 	uint8_t		bTransferSegment;
325 	uint8_t		bTransferStatus;
326 	uint32_t	dwNumOfPackets;
327 } wa_xfer_result_t;
328 
329 #define	WA_RESULT_TYPE_TRANSFER		0x83
330 #define	WA_XFER_RESULT_LEN		0x10
331 
332 enum wa_xfer_status {
333 	WA_STS_SUCCESS = 0,
334 	WA_STS_HALTED = 1,
335 	WA_STS_DATA_BUFFER_ERROR = 2,
336 	WA_STS_BABBLE = 3,
337 	WA_STS_NOT_FOUND = 5,
338 	WA_STS_INSUFFICIENT_RESOURCE = 6,
339 	WA_STS_TRANSACTION_ERROR = 7,
340 	WA_STS_ABORTED = 8,
341 	WA_STS_RPIPE_NOT_READY = 9,
342 	WA_STS_INVALID_REQ_FORMAT = 10,
343 	WA_STS_UNEXPECTED_SEGMENT_NUM = 11,
344 	WA_STS_RPIPE_TYPE_MISMATCH = 12,
345 	WA_STS_PACKET_DISCARDED = 13,
346 } wa_xfer_status_t;
347 
348 #define	WA_RPIPE_STATE_FREE		0	/* not assigned */
349 #define	WA_RPIPE_STATE_IDLE		1	/* configured but not active */
350 #define	WA_RPIPE_STATE_ACTIVE		2	/* configured and active */
351 #define	WA_RPIPE_STATE_PAUSE		3	/* configured and paused */
352 #define	WA_RPIPE_STATE_ERROR		4	/* error */
353 
354 #define	WA_RPIPE_DEFAULT_TIMEOUT	5
355 #define	WA_MAX_SEG_COUNT		128	/* 7bit */
356 #define	WA_DIR_IN			1
357 #define	WA_DIR_OUT			0
358 
359 #define	WA_GET_ID(x)		id32_alloc((void *)(x), KM_NOSLEEP)
360 #define	WA_LOOKUP_ID(x)		id32_lookup((x))
361 #define	WA_FREE_ID(x)		id32_free((x))
362 
363 typedef struct wusb_wa_seg {
364 	void			*seg_wr;	/* wrapper */
365 	uint8_t			seg_num;
366 	uint32_t		seg_id;		/* will delete */
367 	uint32_t		seg_len;
368 	uint32_t		seg_actual_len;
369 	uint8_t			seg_status;	/* WA result status */
370 	uint8_t			seg_state;	/* segment state */
371 	uint8_t			seg_done;
372 
373 	usb_bulk_req_t		*seg_trans_reqp; /* for transfer reqp */
374 	uint8_t			seg_trans_req_state; /* state:submitted */
375 	kcondvar_t		seg_trans_cv;
376 
377 	usb_bulk_req_t		*seg_data_reqp;  /* for out data */
378 	uint8_t			seg_data_req_state; /* state */
379 	kcondvar_t		seg_data_cv;
380 } wusb_wa_seg_t;
381 
382 _NOTE(DATA_READABLE_WITHOUT_LOCK(wusb_wa_seg_t::seg_wr
383 		wusb_wa_seg_t::seg_num
384 		wusb_wa_seg_t::seg_id
385 		wusb_wa_seg_t::seg_len
386 		wusb_wa_seg_t::seg_trans_reqp
387 		wusb_wa_seg_t::seg_data_reqp))
388 
389 struct wusb_wa_trans_wrapper;
390 
391 typedef struct wusb_wa_rpipe_hdl {
392 	uint_t			rp_state; /* free, idle, active, pause, err */
393 	kmutex_t		rp_mutex;
394 	kcondvar_t		rp_cv;
395 	uint_t			rp_refcnt;	/* for multiplexing */
396 	timeout_id_t		rp_timer_id;
397 	usb_wa_rpipe_descr_t	rp_descr;
398 	uint8_t			rp_block_chg;	/* wBlocks changed? */
399 	uint16_t		rp_avail_reqs;	/* available req slots */
400 	void			*rp_curr_wr;	/* current wr */
401 	struct wusb_wa_trans_wrapper *rp_timeout_list;	/* timeout list */
402 } wusb_wa_rpipe_hdl_t;
403 
404 _NOTE(MUTEX_PROTECTS_DATA(wusb_wa_rpipe_hdl_t::rp_mutex, wusb_wa_rpipe_hdl_t))
405 _NOTE(DATA_READABLE_WITHOUT_LOCK(wusb_wa_rpipe_hdl_t::rp_descr))
406 
407 typedef struct wusb_wa_data {
408 	dev_info_t		*wa_dip;
409 	void			*wa_private_data;
410 
411 	kmutex_t		wa_mutex;
412 
413 	uint8_t			wa_ifno;
414 	usb_if_descr_t		wa_if_descr;
415 	usb_wa_descr_t		wa_descr;
416 	uint16_t		wa_avail_blocks; /* available blocks */
417 
418 	usb_ep_descr_t		wa_intr_ept;
419 	usb_ep_descr_t		wa_bulkin_ept;
420 	usb_ep_descr_t		wa_bulkout_ept;
421 
422 	uint_t			wa_state;
423 	usb_pipe_policy_t	wa_pipe_policy;
424 
425 	usb_pipe_handle_t	wa_default_pipe;
426 
427 	/* INTR IN ep */
428 	usb_pipe_handle_t	wa_intr_ph;
429 	usb_pipe_policy_t	wa_intr_pipe_policy;
430 	uint_t			wa_intr_pipe_state;
431 
432 	/* BULK IN ep */
433 	usb_pipe_handle_t	wa_bulkin_ph;
434 	usb_pipe_policy_t	wa_bulkin_pipe_policy;
435 	uint_t			wa_bulkin_pipe_state;
436 
437 	/* BULK OUT ep */
438 	usb_pipe_handle_t	wa_bulkout_ph;
439 	usb_pipe_policy_t	wa_bulkout_pipe_policy;
440 	uint_t			wa_bulkout_pipe_state;
441 
442 	uint16_t		wa_num_rpipes;
443 	wusb_wa_rpipe_hdl_t	*wa_rpipe_hdl;
444 
445 	int  (*pipe_periodic_req)(struct wusb_wa_data *,
446 		usba_pipe_handle_data_t *);
447 	void (*intr_cb)(usb_pipe_handle_t ph, struct usb_intr_req *req);
448 	void (*intr_exc_cb)(usb_pipe_handle_t ph, struct usb_intr_req *req);
449 	void (*rpipe_xfer_cb)(dev_info_t *dip, usba_pipe_handle_data_t *ph,
450 	    struct wusb_wa_trans_wrapper *, usb_cr_t cr);
451 } wusb_wa_data_t;
452 
453 _NOTE(MUTEX_PROTECTS_DATA(wusb_wa_data_t::wa_mutex, wusb_wa_data_t))
454 
455 _NOTE(DATA_READABLE_WITHOUT_LOCK(wusb_wa_data_t::wa_dip))
456 _NOTE(DATA_READABLE_WITHOUT_LOCK(wusb_wa_data_t::wa_default_pipe))
457 _NOTE(DATA_READABLE_WITHOUT_LOCK(wusb_wa_data_t::wa_bulkout_ph))
458 _NOTE(DATA_READABLE_WITHOUT_LOCK(wusb_wa_data_t::wa_bulkin_ph))
459 _NOTE(DATA_READABLE_WITHOUT_LOCK(wusb_wa_data_t::wa_intr_ph))
460 _NOTE(DATA_READABLE_WITHOUT_LOCK(wusb_wa_data_t::wa_ifno
461 		wusb_wa_data_t::wa_descr
462 		wusb_wa_data_t::wa_private_data))
463 _NOTE(DATA_READABLE_WITHOUT_LOCK(wusb_wa_data_t::rpipe_xfer_cb))
464 _NOTE(DATA_READABLE_WITHOUT_LOCK(wusb_wa_data_t::pipe_periodic_req))
465 
466 typedef enum {
467 	WR_NO_ERROR = 0,
468 	WR_SEG_REQ_ERR = 1,	/* send seg request error */
469 	WR_SEG_DAT_ERR = 2,	/* send seg data error */
470 	WR_XFER_ERR = 3,	/* general xfer error */
471 	WR_ABORTED = 4,		/* aborted */
472 	WR_TIMEOUT = 5,		/* timeout */
473 	WR_INTERRUPTED = 6,	/* user interrupted */
474 	WR_FINISHED = 7,	/* finished successfully */
475 } wusb_wa_wr_state_t;
476 
477 typedef struct wusb_wa_trans_wrapper {
478 	usba_pipe_handle_data_t	*wr_ph;
479 	wusb_wa_rpipe_hdl_t	*wr_rp;
480 	wusb_wa_data_t		*wr_wa_data;
481 	kcondvar_t		wr_cv;	/* cv, use Rpipe's mutex to protect */
482 	usb_flags_t		wr_flags;
483 	uint8_t			wr_type;	/* transfer type */
484 	uint8_t			wr_nsegs;	/* number of segs */
485 	uint32_t		wr_max_seglen;	/* max data len per seg */
486 	uint8_t			wr_dir;		/* transfer direction */
487 	uint32_t		wr_id;		/* unique id */
488 	usb_opaque_t		wr_reqp;	/* original reqp */
489 	int			wr_timeout;
490 	wusb_wa_seg_t		*wr_seg_array;
491 	uint8_t			wr_curr_seg;	/* next seg to process */
492 	wusb_wa_wr_state_t	wr_state;	/* 1 - error, not continue */
493 	uint8_t			wr_has_aborted; /* boolean */
494 	uint8_t			wr_seg_done;	/* number of segs done */
495 	void			(*wr_cb)(wusb_wa_data_t *wa_data,
496 				struct wusb_wa_trans_wrapper *wr,
497 				usb_cr_t cr,
498 				uint_t reset_flag);	/* callback func */
499 
500 	struct wusb_wa_trans_wrapper *wr_timeout_next; /* timeout list */
501 } wusb_wa_trans_wrapper_t;
502 
503 _NOTE(MUTEX_PROTECTS_DATA(wusb_wa_rpipe_hdl_t::rp_mutex,
504     wusb_wa_trans_wrapper_t))
505 _NOTE(MUTEX_PROTECTS_DATA(wusb_wa_rpipe_hdl_t::rp_mutex, wusb_wa_seg_t))
506 
507 _NOTE(DATA_READABLE_WITHOUT_LOCK(wusb_wa_trans_wrapper_t::wr_rp))
508 _NOTE(DATA_READABLE_WITHOUT_LOCK(wusb_wa_trans_wrapper_t::wr_ph))
509 _NOTE(DATA_READABLE_WITHOUT_LOCK(wusb_wa_trans_wrapper_t::wr_cb))
510 _NOTE(DATA_READABLE_WITHOUT_LOCK(wusb_wa_trans_wrapper_t::wr_reqp
511 		wusb_wa_trans_wrapper_t::wr_dir
512 		wusb_wa_trans_wrapper_t::wr_nsegs
513 		wusb_wa_trans_wrapper_t::wr_seg_array
514 		wusb_wa_trans_wrapper_t::wr_id))
515 _NOTE(DATA_READABLE_WITHOUT_LOCK(wusb_wa_trans_wrapper_t::wr_wa_data))
516 
517 typedef struct wusb_secrt_data {
518 	usb_security_descr_t	secrt_descr;
519 	uint_t			secrt_n_encry;
520 	usb_encryption_descr_t	*secrt_encry_descr;
521 } wusb_secrt_data_t;
522 
523 typedef struct wusb_wa_cb {
524 	int  (*pipe_periodic_req)(wusb_wa_data_t *,
525 		usba_pipe_handle_data_t *);
526 	void (*intr_cb)(usb_pipe_handle_t ph, struct usb_intr_req *req);
527 	void (*intr_exc_cb)(usb_pipe_handle_t ph, struct usb_intr_req *req);
528 	void (*rpipe_xfer_cb)(dev_info_t *dip, usba_pipe_handle_data_t *ph,
529 	    wusb_wa_trans_wrapper_t *, usb_cr_t cr);
530 } wusb_wa_cb_t;
531 
532 #define	WA_PIPE_CLOSED		0x00
533 #define	WA_PIPE_ACTIVE		0x01
534 #define	WA_PIPE_STOPPED		0X02
535 #define	WA_PIPE_CLOSING		0x03
536 #define	WA_PIPE_RESET		0x04
537 
538 #define	WA_PIPES_OPENED		0x00000001
539 
540 int	wusb_parse_wa_descr(usb_wa_descr_t *, usb_alt_if_data_t *);
541 void	wusb_wa_rpipes_init(wusb_wa_data_t *);
542 void	wusb_wa_rpipes_fini(wusb_wa_data_t *);
543 int	wusb_wa_data_init(dev_info_t *, wusb_wa_data_t *, wusb_wa_cb_t *,
544 	usb_client_dev_data_t *, uint_t, usb_log_handle_t);
545 void	wusb_wa_data_fini(wusb_wa_data_t *);
546 int	wusb_wa_get_rpipe_descr(dev_info_t *, usb_pipe_handle_t, uint16_t,
547 	usb_wa_rpipe_descr_t *, uint_t, usb_log_handle_t);
548 int	wusb_wa_get_rpipe_descrs(wusb_wa_data_t *, usb_pipe_handle_t,
549 	uint_t, usb_log_handle_t);
550 int	wusb_get_wa_status(wusb_wa_data_t *, usb_pipe_handle_t, uint32_t *);
551 int	wusb_wa_reset(wusb_wa_data_t *, usb_pipe_handle_t);
552 int	wusb_wa_enable(wusb_wa_data_t *, usb_pipe_handle_t);
553 int	wusb_wa_disable(wusb_wa_data_t *, usb_pipe_handle_t);
554 int	wusb_wa_open_pipes(wusb_wa_data_t *);
555 void	wusb_wa_close_pipes(wusb_wa_data_t *);
556 int	wusb_wa_start_nep(wusb_wa_data_t *, usb_flags_t);
557 void	wusb_wa_stop_nep(wusb_wa_data_t *);
558 
559 int	wusb_wa_get_rpipe(wusb_wa_data_t *, usb_pipe_handle_t, uint8_t,
560 	wusb_wa_rpipe_hdl_t **, uint_t, usb_log_handle_t);
561 int	wusb_wa_release_rpipe(wusb_wa_data_t *, wusb_wa_rpipe_hdl_t *);
562 int	wusb_wa_get_ep_comp_descr(usba_pipe_handle_data_t *,
563 	usb_ep_comp_descr_t *);
564 int	wusb_wa_set_rpipe_descr(dev_info_t *, usb_pipe_handle_t,
565 	usb_wa_rpipe_descr_t *);
566 int	wusb_wa_set_rpipe_target(dev_info_t *, wusb_wa_data_t *,
567 	usb_pipe_handle_t, usba_pipe_handle_data_t *, wusb_wa_rpipe_hdl_t *);
568 int	wusb_wa_rpipe_abort(dev_info_t *, usb_pipe_handle_t,
569 	wusb_wa_rpipe_hdl_t *);
570 int	wusb_wa_rpipe_reset(dev_info_t *, usba_pipe_handle_data_t *,
571 	wusb_wa_rpipe_hdl_t *, int);
572 int	wusb_wa_get_rpipe_status(dev_info_t *, usb_pipe_handle_t, uint16_t,
573 	uint8_t	*);
574 wusb_wa_trans_wrapper_t *
575 wusb_wa_create_ctrl_wrapper(wusb_wa_data_t *, wusb_wa_rpipe_hdl_t *,
576 	usba_pipe_handle_data_t	*, usb_ctrl_req_t *, usb_flags_t);
577 wusb_wa_trans_wrapper_t *
578 wusb_wa_create_bulk_wrapper(wusb_wa_data_t *, wusb_wa_rpipe_hdl_t *,
579 	usba_pipe_handle_data_t *, usb_bulk_req_t *, usb_flags_t);
580 wusb_wa_trans_wrapper_t *
581 wusb_wa_create_intr_wrapper(wusb_wa_data_t *, wusb_wa_rpipe_hdl_t *,
582 	usba_pipe_handle_data_t *, usb_intr_req_t *, usb_flags_t);
583 wusb_wa_trans_wrapper_t *
584 wusb_wa_alloc_ctrl_resources(wusb_wa_data_t *, wusb_wa_rpipe_hdl_t *,
585 	usba_pipe_handle_data_t *, usb_ctrl_req_t *, usb_flags_t);
586 wusb_wa_trans_wrapper_t *
587 wusb_wa_alloc_bulk_resources(wusb_wa_data_t *, wusb_wa_rpipe_hdl_t *,
588 	usba_pipe_handle_data_t *, usb_bulk_req_t *, usb_flags_t);
589 wusb_wa_trans_wrapper_t *
590 wusb_wa_alloc_intr_resources(wusb_wa_data_t *, wusb_wa_rpipe_hdl_t *,
591 	usba_pipe_handle_data_t *, usb_intr_req_t *, usb_flags_t);
592 
593 void	wusb_wa_setup_trans_req(wusb_wa_trans_wrapper_t *, wusb_wa_seg_t *,
594 	uint8_t);
595 int	wusb_wa_setup_segs(wusb_wa_data_t *, wusb_wa_trans_wrapper_t *,
596 	uint32_t, mblk_t *);
597 void	wusb_wa_free_segs(wusb_wa_trans_wrapper_t *);
598 void	wusb_wa_free_trans_wrapper(wusb_wa_trans_wrapper_t *);
599 
600 void	wusb_wa_abort_req(wusb_wa_data_t *, wusb_wa_trans_wrapper_t *,
601 	uint32_t);
602 int	wusb_wa_wr_xfer(wusb_wa_data_t *, wusb_wa_rpipe_hdl_t *,
603 	wusb_wa_trans_wrapper_t *, usb_flags_t);
604 int	wusb_wa_submit_ctrl_wr(wusb_wa_data_t *, wusb_wa_rpipe_hdl_t *,
605 	wusb_wa_trans_wrapper_t *, usb_ctrl_req_t *, usb_flags_t);
606 int	wusb_wa_ctrl_xfer(wusb_wa_data_t *, wusb_wa_rpipe_hdl_t *,
607 	usba_pipe_handle_data_t *, usb_ctrl_req_t *, usb_flags_t);
608 int	wusb_wa_submit_bulk_wr(wusb_wa_data_t *, wusb_wa_rpipe_hdl_t *,
609 	wusb_wa_trans_wrapper_t *, usb_bulk_req_t *, usb_flags_t);
610 int	wusb_wa_bulk_xfer(wusb_wa_data_t *, wusb_wa_rpipe_hdl_t *,
611 	usba_pipe_handle_data_t *, usb_bulk_req_t *, usb_flags_t);
612 int	wusb_wa_submit_intr_wr(wusb_wa_data_t *, wusb_wa_rpipe_hdl_t *,
613 	wusb_wa_trans_wrapper_t *, usb_intr_req_t *, usb_flags_t);
614 int	wusb_wa_intr_xfer(wusb_wa_data_t *, wusb_wa_rpipe_hdl_t *,
615 	usba_pipe_handle_data_t *, usb_intr_req_t *, usb_flags_t);
616 
617 void	wusb_wa_start_xfer_timer(wusb_wa_rpipe_hdl_t *);
618 
619 void	wusb_wa_xfer_timeout_handler(void *);
620 void	wusb_wa_stop_xfer_timer(wusb_wa_trans_wrapper_t *);
621 
622 void	wusb_wa_clear_dev_ep(usba_pipe_handle_data_t *ph);
623 
624 int	wusb_wa_get_data(wusb_wa_data_t *, wusb_wa_seg_t *, uint32_t);
625 int	wusb_wa_get_xfer_result(wusb_wa_data_t *);
626 void	wusb_wa_check_req_done(wusb_wa_data_t *, wusb_wa_trans_wrapper_t *,
627 	uint8_t);
628 void	wusb_wa_handle_ctrl(wusb_wa_data_t *, wusb_wa_trans_wrapper_t *,
629 	usb_cr_t, uint_t);
630 void	wusb_wa_handle_bulk(wusb_wa_data_t *, wusb_wa_trans_wrapper_t *,
631 	usb_cr_t, uint_t);
632 void	wusb_wa_handle_intr(wusb_wa_data_t *, wusb_wa_trans_wrapper_t *,
633 	usb_cr_t, uint_t);
634 void	wusb_wa_callback(wusb_wa_data_t *, usba_pipe_handle_data_t *,
635 	wusb_wa_trans_wrapper_t *, usb_cr_t);
636 usb_cr_t wusb_wa_sts2cr(uint8_t);
637 
638 
639 #ifdef __cplusplus
640 }
641 #endif
642 
643 #endif /* _SYS_USB_WA_H */
644