xref: /titanic_41/usr/src/uts/common/sys/usb/usba/wusba.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_WUSBA_H
27 #define	_SYS_USB_WUSBA_H
28 
29 #ifdef	__cplusplus
30 extern "C" {
31 #endif
32 
33 /* Wireless USB feature selectors */
34 #define	WUSB_FEAT_TX_DRP_IE		0
35 #define	WUSB_FEAT_DEV_XMIT_PKT		1
36 #define	WUSB_FEAT_COUNT_PKTS		2
37 #define	WUSB_FEAT_CAPT_PKTS		3
38 
39 /* Wireless USB status selector for GET_STATUS request */
40 #define	WUSB_STS_TYPE_STANDARD		0
41 #define	WUSB_STS_TYPE_WIRELESS_FEAT	1
42 #define	WUSB_STS_TYPE_CHANNEL_INFO	2
43 #define	WUSB_STS_TYPE_RECVD_DATA	3
44 #define	WUSB_STS_TYPE_MAS_AVAIL		4
45 #define	WUSB_STS_TYPE_TRANS_PWR		5
46 
47 /*
48  * Device buffer length for count packets and capture packet functions,
49  * refer to WUSB 1.0 4.3.7.2
50  */
51 #define	WUSB_COUNT_CAPT_PKT_LEN		512
52 
53 /* Length for Wireless USB GET_STATUS request */
54 #define	WUSB_STANDARD_STS_LEN		2
55 #define	WUSB_FEAT_STAT_LEN		1
56 #define	WUSB_CHANNEL_INFO_STS_LEN	1
57 #define	WUSB_RECVD_DATA_STS_LEN		WUSB_COUNT_CAPT_PKT_LEN
58 #define	WUSB_MAS_AVAIL_STS_LEN		1
59 #define	WUSB_TRANS_PWR_STS_LEN		2
60 
61 /* Wiless USB feature status bits */
62 #define	WUSB_TX_DRP_IE_STATUS		1
63 #define	WUSB_TRANS_PWR_STATUS		2
64 #define	WUSB_COUNT_PKTS_STATUS		4
65 #define	WUSB_CAPT_PKTS_STATUS		8
66 
67 /* Status data */
68 typedef struct wusb_counted_pkt {
69 	uint8_t		recp_time[3];
70 	uint8_t		mac_header[6];
71 	uint8_t		lqi;
72 } wusb_counted_pkt_t;
73 
74 typedef struct wusb_count_pkts {
75 	uint8_t			pkt_count;
76 	wusb_counted_pkt_t	pkt_block[51];
77 } wusb_count_pkts_t;
78 
79 typedef struct wusb_trans_pwr {
80 	uint8_t		bTxNotifTransPwr;
81 	uint8_t		bTxBeaconTransPwr;
82 } wusb_trans_pwr_t;
83 
84 /* Wireless USB data selectors for SetWUSBDate request */
85 #define	WUSB_DATA_DRPIE_INFO		1
86 #define	WUSB_DATA_TRANS_DATA		2
87 #define	WUSB_DATA_TRANS_PARAMS		3
88 #define	WUSB_DATA_RECV_PARAMS		4
89 #define	WUSB_DATA_TRANS_PWR		5
90 
91 typedef struct wusb_trans_params {
92 	uint8_t		trans_time[3];
93 	uint8_t		trans_adjust;
94 } wusb_trans_params_t;
95 
96 typedef struct wusb_recv_params {
97 	uint8_t		recv_filter;
98 	uint8_t		recv_channel;
99 	uint8_t		recv_start_time[3];
100 	uint8_t		recv_end_time[3];
101 } wusb_recv_params_t;
102 
103 /* Wireless USB key index bits */
104 #define	WUSB_KEY_INDEX_MASK		0x0f
105 #define	WUSB_KEY_TYPE_MASK		0x30
106 #define	WUSB_KEY_TYPE_ASSOCIATION	0x10
107 #define	WUSB_KEY_TYPE_GTK		0x20
108 #define	WUSB_KEY_ORIGIN_MASK		0x40
109 #define	WUSB_KEY_ORIGIN_HOST		0x00
110 #define	WUSB_KEY_ORIGIN_DEV		0x40
111 
112 typedef struct wusb_key {
113 #if defined(_BIT_FIELDS_LTOH)
114 	uint8_t		key_index	:4,
115 			key_type	:2,
116 			key_origin	:1,
117 			key_resv	:1;
118 #elif defined(_BIT_FIELDS_HTOL)
119 	uint8_t		key_resv	:1,
120 			key_origin	:1,
121 			key_type	:2,
122 			key_index	:4;
123 #endif
124 } wusb_key_t;
125 
126 /* Wireless USB handshake data */
127 typedef struct wusb_hndshk_data {
128 	uint8_t		bMessageNumber;
129 	uint8_t		bStatus;
130 	uint8_t		tTKID[3];
131 	uint8_t		bReserved;
132 	uint8_t		CDID[16];
133 	uint8_t		Nonce[16];
134 	uint8_t		MIC[8];
135 } wusb_hndshk_data_t;
136 
137 /* Handshake stage */
138 #define	WUSB_HNDSHK_MSG_NUM1		1
139 #define	WUSB_HNDSHK_MSG_NUM2		2
140 #define	WUSB_HNDSHK_MSG_NUM3		3
141 
142 /* Handshake status */
143 #define	WUSB_HNDSHK_NORMAL		0
144 #define	WUSB_HNDSHK_ABORT_PER_POLICY	1
145 #define	WUSB_HNDSHK_IN_PROGRESS		2
146 #define	WUSB_HNDSHK_TKID_CONFLICT	3
147 
148 #define	WUSB_HNDSHK_DATA_LEN		46
149 
150 /* Wireless USB connection context */
151 #define	WUSB_CHID_LEN			16
152 #define	WUSB_CDID_LEN			16
153 #define	WUSB_CK_LEN			16
154 #define	WUSB_CC_LEN			48
155 
156 
157 /*
158  * ****************************************
159  * IE definitions
160  * ****************************************
161  */
162 
163 /* Wireless USB channel IE identifiers */
164 #define	WUSB_IE_WCTA			0x80
165 #define	WUSB_IE_CONNECTACK		0x81
166 #define	WUSB_IE_HOSTINFO		0x82
167 #define	WUSB_IE_CHCHANGEANNOUNCE	0x83
168 #define	WUSB_IE_DEV_DISCONNECT		0x84
169 #define	WUSB_IE_HOST_DISCONNECT		0x85
170 #define	WUSB_IE_RELEASE_CHANNEL		0x86
171 #define	WUSB_IE_WORK			0x87
172 #define	WUSB_IE_CHANNEL_STOP		0x88
173 #define	WUSB_IE_DEV_KEEPALIVE		0x89
174 #define	WUSB_IE_ISOC_DISCARD		0x8a
175 #define	WUSB_IE_RESETDEVICE		0x8b
176 #define	WUSB_IE_XMIT_PACKET_ADJUST	0x8c
177 
178 /* Array-based IE must not include more than 4 elements */
179 #define	WUSB_IE_MAX_ELEMENT		4
180 #define	WUSB_ACK_BLOCK_SIZE		18
181 #define	WUSB_ACK_IE_MAX_DATA_LEN	\
182 	(WUSB_ACK_BLOCK_SIZE * WUSB_IE_MAX_ELEMENT)
183 #define	WUSB_DISCONN_IE_MAX_DATA_LEN	(WUSB_IE_MAX_ELEMENT + 2)
184 
185 typedef struct wusb_ie_header {
186 	uint8_t			bLength;
187 	uint8_t			bIEIdentifier;
188 } wusb_ie_header_t;
189 
190 typedef struct wusb_connectack_block {
191 	uint8_t			CDID[16];
192 	uint8_t			bDeviceAddress;
193 	uint8_t			bReserved;
194 } wusb_connectack_block_t;
195 
196 typedef struct wusb_ie_connect_ack {
197 	uint8_t			bLength;
198 	uint8_t			bIEIdentifier;
199 	uint8_t			bAckBlock[WUSB_ACK_IE_MAX_DATA_LEN];
200 } wusb_ie_connect_ack_t;
201 
202 typedef struct wusb_ie_host_info {
203 	uint8_t			bLength;
204 	uint8_t			bIEIdentifier;
205 	uint8_t			bmAttributes[2];
206 	uint8_t			CHID[16];
207 } wusb_ie_host_info_t;
208 
209 #define	WUSB_HI_RECONN_ONLY	0x00
210 #define	WUSB_HI_CONN_LMTED	0x01
211 #define	WUSB_HI_CONN_ALL	0x03
212 #define	WUSB_HI_P2P_DRD_CAP	0x04
213 #define	WUSB_HI_STRIDX_SHIFT	3
214 #define	WUSB_HI_STRIDX_MASK	0x38
215 
216 typedef struct wusb_ie_chchange_announce {
217 	uint8_t			bLength;
218 	uint8_t			bIEIdentifier;
219 	uint8_t			bNewPHYChannelNumber;
220 	uint8_t			SwitchTime[3];
221 } wusb_ie_chchange_announce_t;
222 
223 /* the size must be even multiple of 2 bytes */
224 typedef struct wusb_ie_dev_disconnect {
225 	uint8_t			bLength;
226 	uint8_t			bIEIdentifier;
227 	uint8_t			bDeviceAddress[WUSB_DISCONN_IE_MAX_DATA_LEN];
228 } wusb_ie_dev_disconnect_t;
229 
230 typedef wusb_ie_dev_disconnect_t wusb_ie_keepalive_t;
231 
232 typedef struct wusb_ie_host_disconnect {
233 	uint8_t			bLength;
234 	uint8_t			bIEIdentifier;
235 } wusb_ie_host_disconnect_t;
236 
237 typedef struct wusb_udrb {
238 	uint16_t		wStart;
239 	uint16_t		wDurationValue;
240 	uint8_t			bDeviceAddress;
241 	uint8_t			bReserved;
242 } wusb_udrb_t;
243 
244 typedef struct wusb_ie_release_channel {
245 	uint8_t			bLength;
246 	uint8_t			bIEIdentifier;
247 	wusb_udrb_t		udrb[WUSB_IE_MAX_ELEMENT];
248 } wusb_ie_release_channel_t;
249 
250 typedef struct wusb_ie_channel_stop {
251 	uint8_t			bLength;
252 	uint8_t			bIEIdentifier;
253 	uint8_t			bmAttributes;
254 	uint8_t			StopTime[3];
255 } wusb_ie_channel_stop_t;
256 
257 typedef struct wusb_ie_isoc_discard {
258 	uint8_t			bLength;
259 	uint8_t			bIEIdentifier;
260 	uint8_t			bDiscardID;
261 	uint8_t			bDeviceAddress;
262 	uint8_t			bmAttributes;
263 	uint8_t			bFirstReceiveWindowPosition;
264 	uint16_t		wNumberDiscardedPackets;
265 	uint16_t		wNumberDiscardedSegments;
266 	uint8_t			bmDeviceReceiveWindow[4];
267 } wusb_ie_isoc_discard_t;
268 
269 typedef struct wusb_ie_reset_device {
270 	uint8_t			bLength;
271 	uint8_t			bIEIdentifier;
272 	uint8_t			CDID[4 * WUSB_IE_MAX_ELEMENT];
273 } wusb_ie_reset_device_t;
274 
275 typedef struct wusb_ie_xmit_packet_adjust {
276 	uint8_t			bLength;
277 	uint8_t			bIEIdentifier;
278 	uint8_t			bTransmitAdjustment;
279 	uint8_t			bReserved;
280 } wusb_ie_xmit_packet_adjust_t;
281 
282 /*
283  * **************************************
284  * Device notification definitions
285  * **************************************
286  */
287 
288 /* Device notification message types */
289 #define	WUSB_DN_CONNECT			1
290 #define	WUSB_DN_DISCONNECT		2
291 #define	WUSB_DN_EPRDY			3
292 #define	WUSB_DN_MASAVAILCHANGED		4
293 #define	WUSB_DN_REMOTEWAKEUP		5
294 #define	WUSB_DN_SLEEP			6
295 #define	WUSB_DN_ALIVE			7
296 
297 /* WUSB Errata 06.12 specifies WUSB header must not be included */
298 typedef struct wusb_dn_header {
299 	uint8_t			bType;
300 } wusb_dn_header_t;
301 
302 #define	WUSB_DN_CONN_PKT_LEN		19
303 #define	WUSB_DN_DISCONN_PKT_LEN		1
304 #define	WUSB_DN_EPRDY_HDR_LEN		2
305 #define	WUSB_DN_MASAVAILCHANGED_PKT_LEN	1
306 #define	WUSB_DN_SLEEP_PKT_LEN		2
307 #define	WUSB_DN_REMOTEWAKEUP_PKT_LEN	1
308 #define	WUSB_DN_ALIVE_PKT_LEN		1
309 
310 typedef struct wusb_dn_connect {
311 	uint8_t			bType;
312 	uint8_t			bmConnAttributes[2];
313 	uint8_t			CDID[16];
314 } wusb_dn_connect_t;
315 
316 typedef struct wusb_dn_disconnect {
317 	uint8_t			bType;
318 } wusb_dn_disconnect_t;
319 
320 typedef struct wusb_dn_eprdy {
321 	uint8_t			bType;
322 	uint8_t			bLength;
323 	uint8_t			bEPsReadyArray[1];
324 } wusb_dn_eprdy_t;
325 
326 typedef struct wusb_dn_masavail_changed {
327 	uint8_t			bType;
328 } wusb_dn_masavail_changed_t;
329 
330 typedef struct wusb_dn_sleep {
331 	uint8_t			bType;
332 	uint8_t			bmSlpAttributes;
333 } wusb_dn_sleep_t;
334 
335 typedef struct wusb_dn_remote_wakeup {
336 	uint8_t			bType;
337 } wusb_dn_remote_wakeup_t;
338 
339 typedef struct wusb_dn_alive {
340 	uint8_t			bType;
341 } wusb_dn_alive_t;
342 
343 #define	WUSB_DN_CONN_NEW		0x01
344 #define	WUSB_DN_CONN_BEACON_MASK	0x06
345 #define	WUSB_DN_CONN_SELF_BEACON	0x02
346 #define	WUSB_DN_CONN_DIRECTED_BEACON	0x04
347 #define	WUSB_DN_CONN_NO_BEACON		0x06
348 
349 #define	WUSB_DN_SLP_ATTR_GTS		0
350 #define	WUSB_DN_SLP_ATTR_WTS		1
351 
352 /*
353  * WUSB data rate definitions. See WUSB 7.4.1.1
354  */
355 #define	WUSB_DATA_RATE_BIT_53	1 << 0	/* 53.3 Mbps */
356 #define	WUSB_DATA_RATE_BIT_80	1 << 1	/* 80 Mbps */
357 #define	WUSB_DATA_RATE_BIT_106	1 << 2	/* 106.7 Mbps */
358 #define	WUSB_DATA_RATE_BIT_160	1 << 3	/* 160 Mbps */
359 #define	WUSB_DATA_RATE_BIT_200	1 << 4	/* 200 Mbps */
360 #define	WUSB_DATA_RATE_BIT_320	1 << 5	/* 320 Mbps */
361 #define	WUSB_DATA_RATE_BIT_400	1 << 6	/* 400 Mbps */
362 #define	WUSB_DATA_RATE_BIT_480	1 << 7	/* 480 Mbps */
363 
364 /*
365  * WUSB PHY Transfer Rate. See WUSB 5.6
366  */
367 #define	WUSB_PHY_TX_RATE_53	0	/* 53.3 Mbps */
368 #define	WUSB_PHY_TX_RATE_80	1	/* 80 Mbps */
369 #define	WUSB_PHY_TX_RATE_106	2	/* 106.7 Mbps */
370 #define	WUSB_PHY_TX_RATE_160	3	/* 160 Mbps */
371 #define	WUSB_PHY_TX_RATE_200	4	/* 200 Mbps */
372 #define	WUSB_PHY_TX_RATE_320	5	/* 320 Mbps */
373 #define	WUSB_PHY_TX_RATE_400	6	/* 400 Mbps */
374 #define	WUSB_PHY_TX_RATE_480	7	/* 480 Mbps */
375 #define	WUSB_PHY_TX_RATE_RES	8	/* 8~1F, reserved */
376 
377 /*
378  * *****************************************
379  * crypto definition
380  * *****************************************
381  */
382 
383 typedef struct wusb_ccm_nonce {
384 	uint64_t		sfn;
385 	uint32_t		tkid;
386 	uint16_t		daddr;
387 	uint16_t		saddr;
388 } wusb_ccm_nonce_t;
389 
390 #define	CCM_MAC_LEN		8	/* from WUSB 6.4 */
391 #define	CCM_NONCE_LEN		13	/* from WUSB 6.4 */
392 
393 /* WUSB encryption types. see table 7-35 */
394 #define	WUSB_ENCRYP_TYPE_UNSECURE	0
395 #define	WUSB_ENCRYP_TYPE_WIRED		1
396 #define	WUSB_ENCRYP_TYPE_CCM_1		2
397 #define	WUSB_ENCRYP_TYPE_RSA_1		3
398 
399 /* association, refer to WUSB AM Spec 3.8 */
400 enum wusb_association_attr {
401 	attrAssociationTypeId			= 0x0000,
402 	attrAssociationSubTypeId		= 0x0001,
403 	attrLength				= 0x0002,
404 	attrAssociationStatus			= 0x0004,
405 	attrLangID				= 0x0008,
406 	attrDeviceFriendlyName			= 0x000B,
407 	attrHostFriendlyName			= 0x000C,
408 	attrCHID				= 0x1000,
409 	attrCDID				= 0x1001,
410 	attrConnectionContext			= 0x1002,
411 	attrBandGroups				= 0x1004
412 };
413 
414 typedef	uint16_t	wusb_asso_attr_t;
415 
416 typedef struct wusb_cbaf_info_item {
417 	wusb_asso_attr_t	typeID;
418 	uint16_t		length;
419 } wusb_cbaf_info_item_t;
420 
421 #define	fieldAssociationTypeId			"\x00\x00\x02\x00"
422 #define	fieldAssociationSubTypeId		"\x01\x00\x02\x00"
423 #define	fieldLength				"\x02\x00\x04\x00"
424 #define	fieldAssociationStatus			"\x04\x00\x04\x00"
425 #define	fieldLangID				"\x08\x00\x02\x00"
426 #define	fieldDeviceFriendlyName			"\x0B\x00\x40\x00"
427 #define	fieldHostFriendlyName			"\x0C\x00\x40\x00"
428 #define	fieldCHID				"\x00\x10\x10\x00"
429 #define	fieldCDID				"\x01\x10\x10\x00"
430 #define	fieldConnectionContext			"\x02\x10\x30\x00"
431 #define	fieldBandGroups				"\x04\x10\x02\x00"
432 
433 
434 #ifdef __cplusplus
435 }
436 #endif
437 
438 #endif /* _SYS_USB_WUSBA_H */
439