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