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_UWB_UWB_H
27#define	_SYS_UWB_UWB_H
28
29
30#ifdef	__cplusplus
31extern "C" {
32#endif
33
34/*
35 * IOCTLs and related data structures for UWB Radio Controller drivers.
36 */
37
38/* IOCTLs */
39#define	UWB_IOCTL_BASE			0x1000
40#define	UWB_COMMAND			(UWB_IOCTL_BASE + 0x1)
41#define	UWB_GET_NOTIFICATION		(UWB_IOCTL_BASE + 0x2)
42
43#define	UWB_CE_TYPE_GENERAL 0		/* General Command/Event type */
44
45/*
46 * UWB Radio Controller Commands and Events:
47 *
48 * See WUSB spec 1.0 [Table 8-68]
49 * See WHCI 0.95 [Table 3-2],[Table 3-5]
50 */
51/* Commands */
52#define	UWB_CE_CHANNEL_CHANGE			16
53#define	UWB_CE_DEV_ADDR_MGMT			17
54#define	UWB_CE_GET_IE				18
55#define	UWB_CE_RESET				19
56#define	UWB_CE_SCAN				20
57#define	UWB_CE_SET_BEACON_FILTER		21
58#define	UWB_CE_SET_DRP_IE			22
59#define	UWB_CE_SET_IE				23
60#define	UWB_CE_SET_NOTIFICATION_FILTER		24
61#define	UWB_CE_SET_TX_POWER			25
62#define	UWB_CE_SLEEP				26
63#define	UWB_CE_START_BEACON			27
64#define	UWB_CE_STOP_BEACON			28
65#define	UWB_CE_BP_MERGE				29
66#define	UWB_CE_SEND_COMMAND_FRAME		30
67#define	UWB_CE_SET_ASIE_NOTIFICATION		31
68
69/* Notifications */
70#define	UWB_NOTIF_IE_RECEIVED			0
71#define	UWB_NOTIF_BEACON_RECEIVED 		1
72#define	UWB_NOTIF_BEACON_SIZE_CHANGE    	2
73#define	UWB_NOTIF_BPOIE_CHANGE			3
74#define	UWB_NOTIF_BP_SLOT_CHANGE 		4
75#define	UWB_NOTIF_BP_SWITCH_IE_RECEIVED 	5
76#define	UWB_NOTIF_DEV_ADDR_CONFLICT 		6
77#define	UWB_NOTIF_DRP_AVAILABILITY_CHANGE 	7
78#define	UWB_NOTIF_DRP				8
79#define	UWB_NOTIF_BP_SWITCH_STATUS 		9
80#define	UWB_NOTIF_CMD_FRAME_RCV 		10
81#define	UWB_NOTIF_CHANNEL_CHANGE_IE_RCV 	11
82#define	UWB_NOTIF_RESERVED 			12
83
84/*
85 * Scan types.
86 * WUSB spec 1.0 [Table 8-78. Scan RCCB]
87 * WHCI 0.95 [Table 3-14. Scan RCCB Format]
88 */
89#define	UWB_RC_SCAN_ONLY			0
90#define	UWB_RC_SCAN_OUTSIDE_BP			1
91#define	UWB_RC_SCAN_WHILE_INACTIVE		2
92#define	UWB_RC_SCAN_DISABLED			3
93#define	UWB_RC_SCAN_ONLY_STARTTIME 		4
94
95/*
96 * See ECMA-368 [7.2.2 Device address]
97 * Individual MAC sublayers are addressed via an EUI-48 [I3]
98 * DevAddrs are 16-bit values
99 */
100typedef struct uwb_mac_addr {
101	uint8_t addr[6];
102} uwb_mac_addr_t;
103
104typedef struct uwb_dev_addr {
105	uint8_t addr[2];
106} uwb_dev_addr_t;
107
108/*
109 * See ECMA-368 [16.8.6]
110 * One superframe has 256 Medium Access Slots.
111 * One superframe has 16 zones.
112 */
113#define	UWB_MAS_NUM 256
114#define	UWB_ZONE_NUM 16
115
116/* Type of DRP reservation. ECMA-368 [table 106] */
117#define	UWB_DRP_TP_ALIEN	0
118#define	UWB_DRP_TP_HARD		1
119#define	UWB_DRP_TP_SOFT		2
120#define	UWB_DRP_TP_PRVT		3
121#define	UWB_DRP_TP_PCA		4
122#define	UWB_DRP_TP_RESVD	5
123
124/* DRP Reasons. ECMA-368 [table 107] */
125#define	UWB_DRP_RS_ACCEP	0
126#define	UWB_DRP_RS_CNFLCT	1
127#define	UWB_DRP_RS_PNDNG	2
128#define	UWB_DRP_RS_DENI		3
129#define	UWB_DRP_RS_MODIF	4
130#define	UWB_DRP_RS_RSEVD	5
131
132/* Allocation of MAS slots in a DRP request. ECMA-368 */
133typedef struct uwb_drp_bm_alloc {
134	uint16_t zone;
135	uint16_t mas;
136} uwb_drp_bm_alloc_t;
137
138/*  Information elements. ECMA-368 [Table 104] */
139#define	UWB_IE_TIM		0
140#define	UWB_IE_BPO		1
141#define	UWB_IE_PCA_AVAIL 	2
142#define	UWB_IE_DRP_AVAIL 	8
143#define	UWB_IE_DRP 		9
144#define	UWB_IE_HIB_MODE		10
145#define	UWB_IE_BP_SWITCH 	11
146#define	UWB_IE_MAC_CAP 		12
147#define	UWB_IE_PHY_CAP 		13
148#define	UWB_IE_PROBE 		14
149#define	UWB_IE_APPSPEC_PROBE	15
150#define	UWB_IE_LINK_FB		16
151#define	UWB_IE_HIB_ANCHOR	17
152#define	UWB_IE_CHNL_CHG		18
153#define	UWB_IE_IDENT		19
154#define	UWB_IE_MASTER_KEY_ID	20
155#define	UWB_IE_RELQ_REQ		21
156#define	UWB_IE_MAB		22
157#define	UWB_IE_APP_SPEC		255
158
159/* UWB Information Element header. ECMA-368 [16.8] */
160typedef struct uwb_ie_head {
161	uint8_t		id; 	/* Element ID */
162	uint8_t		len; 	/* Length */
163} uwb_ie_head_t;
164
165/* Dynamic Reservation Protocol IE. ECMA-368 [16.8.6] */
166typedef struct uwb_drp_ie {
167	uwb_ie_head_t		head;
168	uint16_t 		drp_ctrl;
169	uwb_dev_addr_t		dev_addr;
170	uwb_drp_bm_alloc_t	allocs[1];
171} uwb_drp_ie_t;
172
173/* Dynamic Reservation Protocol IE. ECMA-368 [16.8.7] */
174typedef struct uwb_drp_avail_ie {
175	uwb_ie_head_t	head;
176	ulong_t 	bitmap[8];
177} uwb_drp_avail_ie_t;
178
179
180/* Data structures for UWB commands */
181
182/* WUSB spec 1.0 [Table 8-65] Radio Control Command Block (RCCB) */
183typedef struct uwb_rccb_head {
184	uint8_t bCommandType;		/* Command Type */
185	uint16_t wCommand;		/* Command code */
186	uint8_t bCommandContext;	/* Context ID */
187} uwb_rccb_head_t;
188
189/* Generic RCCB Command */
190typedef struct uwb_rccb_cmd {
191	uwb_rccb_head_t rccb;
192	uint8_t	buf[1];
193} uwb_rccb_cmd_t;
194
195/* WUSB spec 1.0. Table 8-78. Scan RCCB */
196typedef struct uwb_rccb_scan {
197	uwb_rccb_head_t rccb;
198	uint8_t bChannelNumber;
199	uint8_t bScanState;
200	uint16_t wStartTime;
201} uwb_rccb_scan_t;
202
203/* WUSB spec 1.0 Table 8-93. Start Beaconing RCCB */
204typedef struct uwb_rccb_start_beacon {
205	uwb_rccb_head_t rccb;
206	uint16_t 	wBPSTOffset;
207	uint8_t 	bChannelNumber;
208} uwb_rccb_start_beacon_t;
209
210/* WUSB spec 1.0 Table 8-82. Set DRP IE RCCB */
211typedef struct uwb_rccb_set_drp_ie {
212	uwb_rccb_head_t rccb;
213	uint16_t 	wIELength;
214	uint8_t 	IEData[1];
215} uwb_rccb_set_drp_ie_t;
216
217/* WUSB spec 1.0 Table 8-84. Set IE RCCB */
218typedef struct uwb_rccb_set_ie {
219	uwb_rccb_head_t rccb;
220	uint16_t 	wIELength;
221	uint8_t 	IEData[1];
222}uwb_rccb_set_ie_t;
223
224/* WUSB spec 1.0 Table 8-72. Device Address Management RCCB */
225typedef struct uwb_rccb_dev_addr_mgmt {
226	uwb_rccb_head_t rccb;
227	uint8_t 	bmOperationType;
228	uint8_t 	baAddr[6];
229} uwb_rccb_dev_addr_mgmt_t;
230
231/* Data structures for UWB Command results (Events) */
232
233/*  WUSB spec 1.0 Table 8-66. Radio Control Event Block (RCEB) */
234typedef struct uwb_rceb_head {
235	uint8_t 	bEventType;
236	uint16_t 	wEvent;
237	uint8_t 	bEventContext;
238} uwb_rceb_head_t;
239
240/*
241 * Generic RCEB for commands that returns result code only.
242 * Including channel change, scan, reset, etc.
243 */
244typedef struct uwb_rceb_result_code {
245	uwb_rceb_head_t rceb;
246	uint8_t 	bResultCode;
247} uwb_rceb_result_code_t;
248
249/*
250 * WUSB 1.0 Table 8-73. Device Address Management RCEB
251 * baAddr should be ignored if the Set bit in the associated
252 * RCCB is set to 1. The spec is fixed in Errata.
253 */
254typedef struct uwb_rceb_dev_addr_mgmt {
255	uwb_rceb_head_t rceb;
256	uint8_t 	baAddr[6];
257	uint8_t 	bResultCode;
258} uwb_rceb_dev_addr_mgmt_t;
259
260/* WUSB 1.0 Table 8-75. Get IE RCEB */
261typedef struct uwb_rceb_get_ie {
262	uwb_rceb_head_t rceb;
263	uint16_t 	wIELength;
264	uint8_t 	IEData[1];
265} uwb_rceb_get_ie_t;
266
267/* WUSB 1.0 Table 8-86. Set IE RCEB */
268typedef struct uwb_rceb_set_ie {
269	uwb_rceb_head_t rceb;
270	uint16_t 	RemainingSpace;
271	uint8_t 	bResultCode;
272} uwb_rceb_set_ie_t;
273
274/* WUSB 1.0 Table 8-83. Set DRP IE RCEB */
275typedef struct uwb_rceb_set_drp_ie {
276	uwb_rceb_head_t rceb;
277	uint16_t 	wRemainingSpace;
278	uint8_t 	bResultCode;
279} uwb_rceb_set_drp_ie_t;
280
281
282/* Data structures for UWB Notifications */
283
284/* Notification from device */
285typedef struct uwb_rceb_notif {
286	uwb_rceb_head_t rceb;
287	uint8_t		buf[1];
288} uwb_rceb_notif_t;
289
290typedef struct uwb_notif_get {
291	/* wait for milliseconds untile get a notification */
292	uint_t		timeout;
293	uwb_rceb_notif_t notif;
294} uwb_notif_get_t;
295
296/*
297 * UWB_NOTIF_BEACON_RECEIVED, Beacon received notification
298 * WHCI [3.1.4.2].
299 * NOTICE:In WUSB Spec, Table 8-98. No bBeaconType. Below follow
300 * WHCI spec
301 */
302typedef struct uwb_rceb_beacon {
303	uwb_rceb_head_t rceb;
304	uint8_t 	bChannelNumber;
305	uint8_t 	bBeaconType;
306	uint16_t	wBPSTOffset;
307	uint8_t		bLQI;
308	uint8_t		bRSSI;
309	uint16_t	wBeaconInfoLength;
310	uint8_t		BeaconInfo[1];
311} uwb_rceb_beacon_t;
312
313/* MAC Header field values for beacon frames. ECMA 368 [table 96] */
314typedef struct uwb_bcfrm_mac_hdr {
315	uint16_t	Frame_Control;
316	uwb_dev_addr_t	DestAddr;
317	uwb_dev_addr_t	SrcAddr;
318	uint16_t	Sequence_Control;
319	uint16_t	Access_Information;
320} uwb_bcfrm_mac_hdr_t;
321
322/* Beacon Frame [ECMA-368] page 151 */
323typedef struct uwb_beacon_frame {
324	uwb_bcfrm_mac_hdr_t	hdr;
325	uwb_mac_addr_t		Device_Identifier;
326	uint8_t			Beacon_Slot_Number;
327	uint8_t			Device_Control;
328	uint8_t			IEData[1];
329} uwb_beacon_frame_t;
330
331/* WUSB 1.0. Table 8-99. Beacon Size Change Notification RCEB */
332typedef struct uwb_rceb_beacon_size_change {
333	uwb_rceb_head_t		rceb;
334	uint16_t		wNewBeaconSize;
335} uwb_rceb_beacon_size_change_t;
336
337/* WUSB 1.0. Table 8-100. BPOIE Change Notification RCEB */
338typedef struct uwb_rceb_bpoie_change {
339	uwb_rceb_head_t		rceb;
340	uint16_t		wBPOIELength;
341	uint8_t			BPOIE[1];
342} uwb_rceb_bpoie_change_t;
343
344/* WHCI 0.95  Table 3-42. BP Slot Change Notification RCEB Format */
345typedef struct uwb_rceb_bp_slot_change {
346	uwb_rceb_head_t		rceb;
347	uint8_t			bNewSlotNumber;
348} uwb_rceb_bp_slot_change_t;
349
350/* WHCI 0.95 Table 3-45. DRP Availability Changed Notification RCEB Format */
351typedef struct uwb_rceb_drp_availability {
352	uwb_rceb_head_t		rceb;
353	uint8_t			DRPAvailability[32]; /* 256 bit bitmap */
354} uwb_rceb_drp_availability_t;
355
356/* WHCI 0.95 [3.1.4.9] * Table 3-46. DRP Notification RCEB Format */
357typedef struct uwb_rceb_drp {
358	uwb_rceb_head_t		rceb;
359	uint16_t 		wSrcAddr;
360	uint8_t 		bReason;
361	uint8_t 		bBeaconSlotNumber;
362	uint16_t 		wIELength;
363	uint8_t 		IEData[1];
364} uwb_rceb_drp_t;
365
366
367#ifdef __cplusplus
368}
369#endif
370
371#endif	/* _SYS_UWB_UWB_H */
372