1 /* SPDX-License-Identifier: GPL-2.0-only */
2 /*
3  * Ultra Wide Band
4  * UWB Standard definitions
5  *
6  * Copyright (C) 2005-2006 Intel Corporation
7  * Inaky Perez-Gonzalez <inaky.perez-gonzalez@intel.com>
8  *
9  * All these definitions are based on the ECMA-368 standard.
10  *
11  * Note all definitions are Little Endian in the wire, and we will
12  * convert them to host order before operating on the bitfields (that
13  * yes, we use extensively).
14  */
15 
16 #ifndef __LINUX__UWB_SPEC_H__
17 #define __LINUX__UWB_SPEC_H__
18 
19 #include <linux/types.h>
20 #include <linux/bitmap.h>
21 #include <linux/if_ether.h>
22 
23 #define i1480_FW 0x00000303
24 /* #define i1480_FW 0x00000302 */
25 
26 /**
27  * Number of Medium Access Slots in a superframe.
28  *
29  * UWB divides time in SuperFrames, each one divided in 256 pieces, or
30  * Medium Access Slots. See MBOA MAC[5.4.5] for details. The MAS is the
31  * basic bandwidth allocation unit in UWB.
32  */
33 enum { UWB_NUM_MAS = 256 };
34 
35 /**
36  * Number of Zones in superframe.
37  *
38  * UWB divides the superframe into zones with numbering starting from BPST.
39  * See MBOA MAC[16.8.6]
40  */
41 enum { UWB_NUM_ZONES = 16 };
42 
43 /*
44  * Number of MAS in a zone.
45  */
46 #define UWB_MAS_PER_ZONE (UWB_NUM_MAS / UWB_NUM_ZONES)
47 
48 /*
49  * Number of MAS required before a row can be considered available.
50  */
51 #define UWB_USABLE_MAS_PER_ROW (UWB_NUM_ZONES - 1)
52 
53 /*
54  * Number of streams per DRP reservation between a pair of devices.
55  *
56  * [ECMA-368] section 16.8.6.
57  */
58 enum { UWB_NUM_STREAMS = 8 };
59 
60 /*
61  * mMasLength
62  *
63  * The length of a MAS in microseconds.
64  *
65  * [ECMA-368] section 17.16.
66  */
67 enum { UWB_MAS_LENGTH_US = 256 };
68 
69 /*
70  * mBeaconSlotLength
71  *
72  * The length of the beacon slot in microseconds.
73  *
74  * [ECMA-368] section 17.16
75  */
76 enum { UWB_BEACON_SLOT_LENGTH_US = 85 };
77 
78 /*
79  * mMaxLostBeacons
80  *
81  * The number beacons missing in consecutive superframes before a
82  * device can be considered as unreachable.
83  *
84  * [ECMA-368] section 17.16
85  */
86 enum { UWB_MAX_LOST_BEACONS = 3 };
87 
88 /*
89  * mDRPBackOffWinMin
90  *
91  * The minimum number of superframes to wait before trying to reserve
92  * extra MAS.
93  *
94  * [ECMA-368] section 17.16
95  */
96 enum { UWB_DRP_BACKOFF_WIN_MIN = 2 };
97 
98 /*
99  * mDRPBackOffWinMax
100  *
101  * The maximum number of superframes to wait before trying to reserve
102  * extra MAS.
103  *
104  * [ECMA-368] section 17.16
105  */
106 enum { UWB_DRP_BACKOFF_WIN_MAX = 16 };
107 
108 /*
109  * Length of a superframe in microseconds.
110  */
111 #define UWB_SUPERFRAME_LENGTH_US (UWB_MAS_LENGTH_US * UWB_NUM_MAS)
112 
113 /**
114  * UWB MAC address
115  *
116  * It is *imperative* that this struct is exactly 6 packed bytes (as
117  * it is also used to define headers sent down and up the wire/radio).
118  */
119 struct uwb_mac_addr {
120 	u8 data[ETH_ALEN];
121 } __attribute__((packed));
122 
123 
124 /**
125  * UWB device address
126  *
127  * It is *imperative* that this struct is exactly 6 packed bytes (as
128  * it is also used to define headers sent down and up the wire/radio).
129  */
130 struct uwb_dev_addr {
131 	u8 data[2];
132 } __attribute__((packed));
133 
134 
135 /**
136  * Types of UWB addresses
137  *
138  * Order matters (by size).
139  */
140 enum uwb_addr_type {
141 	UWB_ADDR_DEV = 0,
142 	UWB_ADDR_MAC = 1,
143 };
144 
145 
146 /** Size of a char buffer for printing a MAC/device address */
147 enum { UWB_ADDR_STRSIZE = 32 };
148 
149 
150 /** UWB WiMedia protocol IDs. */
151 enum uwb_prid {
152 	UWB_PRID_WLP_RESERVED   = 0x0000,
153 	UWB_PRID_WLP		= 0x0001,
154 	UWB_PRID_WUSB_BOT	= 0x0010,
155 	UWB_PRID_WUSB		= 0x0010,
156 	UWB_PRID_WUSB_TOP	= 0x001F,
157 };
158 
159 
160 /** PHY Rate (MBOA MAC[7.8.12, Table 61]) */
161 enum uwb_phy_rate {
162 	UWB_PHY_RATE_53 = 0,
163 	UWB_PHY_RATE_80,
164 	UWB_PHY_RATE_106,
165 	UWB_PHY_RATE_160,
166 	UWB_PHY_RATE_200,
167 	UWB_PHY_RATE_320,
168 	UWB_PHY_RATE_400,
169 	UWB_PHY_RATE_480,
170 	UWB_PHY_RATE_INVALID
171 };
172 
173 
174 /**
175  * Different ways to scan (MBOA MAC[6.2.2, Table 8], WUSB[Table 8-78])
176  */
177 enum uwb_scan_type {
178 	UWB_SCAN_ONLY = 0,
179 	UWB_SCAN_OUTSIDE_BP,
180 	UWB_SCAN_WHILE_INACTIVE,
181 	UWB_SCAN_DISABLED,
182 	UWB_SCAN_ONLY_STARTTIME,
183 	UWB_SCAN_TOP
184 };
185 
186 
187 /** ACK Policy types (MBOA MAC[7.2.1.3]) */
188 enum uwb_ack_pol {
189 	UWB_ACK_NO = 0,
190 	UWB_ACK_INM = 1,
191 	UWB_ACK_B = 2,
192 	UWB_ACK_B_REQ = 3,
193 };
194 
195 
196 /** DRP reservation types ([ECMA-368 table 106) */
197 enum uwb_drp_type {
198 	UWB_DRP_TYPE_ALIEN_BP = 0,
199 	UWB_DRP_TYPE_HARD,
200 	UWB_DRP_TYPE_SOFT,
201 	UWB_DRP_TYPE_PRIVATE,
202 	UWB_DRP_TYPE_PCA,
203 };
204 
205 
206 /** DRP Reason Codes ([ECMA-368] table 107) */
207 enum uwb_drp_reason {
208 	UWB_DRP_REASON_ACCEPTED = 0,
209 	UWB_DRP_REASON_CONFLICT,
210 	UWB_DRP_REASON_PENDING,
211 	UWB_DRP_REASON_DENIED,
212 	UWB_DRP_REASON_MODIFIED,
213 };
214 
215 /** Relinquish Request Reason Codes ([ECMA-368] table 113) */
216 enum uwb_relinquish_req_reason {
217 	UWB_RELINQUISH_REQ_REASON_NON_SPECIFIC = 0,
218 	UWB_RELINQUISH_REQ_REASON_OVER_ALLOCATION,
219 };
220 
221 /**
222  *  DRP Notification Reason Codes (WHCI 0.95 [3.1.4.9])
223  */
224 enum uwb_drp_notif_reason {
225 	UWB_DRP_NOTIF_DRP_IE_RCVD = 0,
226 	UWB_DRP_NOTIF_CONFLICT,
227 	UWB_DRP_NOTIF_TERMINATE,
228 };
229 
230 
231 /** Allocation of MAS slots in a DRP request MBOA MAC[7.8.7] */
232 struct uwb_drp_alloc {
233 	__le16 zone_bm;
234 	__le16 mas_bm;
235 } __attribute__((packed));
236 
237 
238 /** General MAC Header format (ECMA-368[16.2]) */
239 struct uwb_mac_frame_hdr {
240 	__le16 Frame_Control;
241 	struct uwb_dev_addr DestAddr;
242 	struct uwb_dev_addr SrcAddr;
243 	__le16 Sequence_Control;
244 	__le16 Access_Information;
245 } __attribute__((packed));
246 
247 
248 /**
249  * uwb_beacon_frame - a beacon frame including MAC headers
250  *
251  * [ECMA] section 16.3.
252  */
253 struct uwb_beacon_frame {
254 	struct uwb_mac_frame_hdr hdr;
255 	struct uwb_mac_addr Device_Identifier;	/* may be a NULL EUI-48 */
256 	u8 Beacon_Slot_Number;
257 	u8 Device_Control;
258 	u8 IEData[];
259 } __attribute__((packed));
260 
261 
262 /** Information Element codes (MBOA MAC[T54]) */
263 enum uwb_ie {
264 	UWB_PCA_AVAILABILITY = 2,
265 	UWB_IE_DRP_AVAILABILITY = 8,
266 	UWB_IE_DRP = 9,
267 	UWB_BP_SWITCH_IE = 11,
268 	UWB_MAC_CAPABILITIES_IE = 12,
269 	UWB_PHY_CAPABILITIES_IE = 13,
270 	UWB_APP_SPEC_PROBE_IE = 15,
271 	UWB_IDENTIFICATION_IE = 19,
272 	UWB_MASTER_KEY_ID_IE = 20,
273 	UWB_RELINQUISH_REQUEST_IE = 21,
274 	UWB_IE_WLP = 250, /* WiMedia Logical Link Control Protocol WLP 0.99 */
275 	UWB_APP_SPEC_IE = 255,
276 };
277 
278 
279 /**
280  * Header common to all Information Elements (IEs)
281  */
282 struct uwb_ie_hdr {
283 	u8 element_id;	/* enum uwb_ie */
284 	u8 length;
285 } __attribute__((packed));
286 
287 
288 /** Dynamic Reservation Protocol IE (MBOA MAC[7.8.6]) */
289 struct uwb_ie_drp {
290 	struct uwb_ie_hdr	hdr;
291 	__le16                  drp_control;
292 	struct uwb_dev_addr	dev_addr;
293 	struct uwb_drp_alloc	allocs[];
294 } __attribute__((packed));
295 
uwb_ie_drp_type(struct uwb_ie_drp * ie)296 static inline int uwb_ie_drp_type(struct uwb_ie_drp *ie)
297 {
298 	return (le16_to_cpu(ie->drp_control) >> 0) & 0x7;
299 }
300 
uwb_ie_drp_stream_index(struct uwb_ie_drp * ie)301 static inline int uwb_ie_drp_stream_index(struct uwb_ie_drp *ie)
302 {
303 	return (le16_to_cpu(ie->drp_control) >> 3) & 0x7;
304 }
305 
uwb_ie_drp_reason_code(struct uwb_ie_drp * ie)306 static inline int uwb_ie_drp_reason_code(struct uwb_ie_drp *ie)
307 {
308 	return (le16_to_cpu(ie->drp_control) >> 6) & 0x7;
309 }
310 
uwb_ie_drp_status(struct uwb_ie_drp * ie)311 static inline int uwb_ie_drp_status(struct uwb_ie_drp *ie)
312 {
313 	return (le16_to_cpu(ie->drp_control) >> 9) & 0x1;
314 }
315 
uwb_ie_drp_owner(struct uwb_ie_drp * ie)316 static inline int uwb_ie_drp_owner(struct uwb_ie_drp *ie)
317 {
318 	return (le16_to_cpu(ie->drp_control) >> 10) & 0x1;
319 }
320 
uwb_ie_drp_tiebreaker(struct uwb_ie_drp * ie)321 static inline int uwb_ie_drp_tiebreaker(struct uwb_ie_drp *ie)
322 {
323 	return (le16_to_cpu(ie->drp_control) >> 11) & 0x1;
324 }
325 
uwb_ie_drp_unsafe(struct uwb_ie_drp * ie)326 static inline int uwb_ie_drp_unsafe(struct uwb_ie_drp *ie)
327 {
328 	return (le16_to_cpu(ie->drp_control) >> 12) & 0x1;
329 }
330 
uwb_ie_drp_set_type(struct uwb_ie_drp * ie,enum uwb_drp_type type)331 static inline void uwb_ie_drp_set_type(struct uwb_ie_drp *ie, enum uwb_drp_type type)
332 {
333 	u16 drp_control = le16_to_cpu(ie->drp_control);
334 	drp_control = (drp_control & ~(0x7 << 0)) | (type << 0);
335 	ie->drp_control = cpu_to_le16(drp_control);
336 }
337 
uwb_ie_drp_set_stream_index(struct uwb_ie_drp * ie,int stream_index)338 static inline void uwb_ie_drp_set_stream_index(struct uwb_ie_drp *ie, int stream_index)
339 {
340 	u16 drp_control = le16_to_cpu(ie->drp_control);
341 	drp_control = (drp_control & ~(0x7 << 3)) | (stream_index << 3);
342 	ie->drp_control = cpu_to_le16(drp_control);
343 }
344 
uwb_ie_drp_set_reason_code(struct uwb_ie_drp * ie,enum uwb_drp_reason reason_code)345 static inline void uwb_ie_drp_set_reason_code(struct uwb_ie_drp *ie,
346 				       enum uwb_drp_reason reason_code)
347 {
348 	u16 drp_control = le16_to_cpu(ie->drp_control);
349 	drp_control = (ie->drp_control & ~(0x7 << 6)) | (reason_code << 6);
350 	ie->drp_control = cpu_to_le16(drp_control);
351 }
352 
uwb_ie_drp_set_status(struct uwb_ie_drp * ie,int status)353 static inline void uwb_ie_drp_set_status(struct uwb_ie_drp *ie, int status)
354 {
355 	u16 drp_control = le16_to_cpu(ie->drp_control);
356 	drp_control = (drp_control & ~(0x1 << 9)) | (status << 9);
357 	ie->drp_control = cpu_to_le16(drp_control);
358 }
359 
uwb_ie_drp_set_owner(struct uwb_ie_drp * ie,int owner)360 static inline void uwb_ie_drp_set_owner(struct uwb_ie_drp *ie, int owner)
361 {
362 	u16 drp_control = le16_to_cpu(ie->drp_control);
363 	drp_control = (drp_control & ~(0x1 << 10)) | (owner << 10);
364 	ie->drp_control = cpu_to_le16(drp_control);
365 }
366 
uwb_ie_drp_set_tiebreaker(struct uwb_ie_drp * ie,int tiebreaker)367 static inline void uwb_ie_drp_set_tiebreaker(struct uwb_ie_drp *ie, int tiebreaker)
368 {
369 	u16 drp_control = le16_to_cpu(ie->drp_control);
370 	drp_control = (drp_control & ~(0x1 << 11)) | (tiebreaker << 11);
371 	ie->drp_control = cpu_to_le16(drp_control);
372 }
373 
uwb_ie_drp_set_unsafe(struct uwb_ie_drp * ie,int unsafe)374 static inline void uwb_ie_drp_set_unsafe(struct uwb_ie_drp *ie, int unsafe)
375 {
376 	u16 drp_control = le16_to_cpu(ie->drp_control);
377 	drp_control = (drp_control & ~(0x1 << 12)) | (unsafe << 12);
378 	ie->drp_control = cpu_to_le16(drp_control);
379 }
380 
381 /** Dynamic Reservation Protocol IE (MBOA MAC[7.8.7]) */
382 struct uwb_ie_drp_avail {
383 	struct uwb_ie_hdr	hdr;
384 	DECLARE_BITMAP(bmp, UWB_NUM_MAS);
385 } __attribute__((packed));
386 
387 /* Relinqish Request IE ([ECMA-368] section 16.8.19). */
388 struct uwb_relinquish_request_ie {
389         struct uwb_ie_hdr       hdr;
390         __le16                  relinquish_req_control;
391         struct uwb_dev_addr     dev_addr;
392         struct uwb_drp_alloc    allocs[];
393 } __attribute__((packed));
394 
uwb_ie_relinquish_req_reason_code(struct uwb_relinquish_request_ie * ie)395 static inline int uwb_ie_relinquish_req_reason_code(struct uwb_relinquish_request_ie *ie)
396 {
397 	return (le16_to_cpu(ie->relinquish_req_control) >> 0) & 0xf;
398 }
399 
uwb_ie_relinquish_req_set_reason_code(struct uwb_relinquish_request_ie * ie,int reason_code)400 static inline void uwb_ie_relinquish_req_set_reason_code(struct uwb_relinquish_request_ie *ie,
401 							 int reason_code)
402 {
403 	u16 ctrl = le16_to_cpu(ie->relinquish_req_control);
404 	ctrl = (ctrl & ~(0xf << 0)) | (reason_code << 0);
405 	ie->relinquish_req_control = cpu_to_le16(ctrl);
406 }
407 
408 /**
409  * The Vendor ID is set to an OUI that indicates the vendor of the device.
410  * ECMA-368 [16.8.10]
411  */
412 struct uwb_vendor_id {
413 	u8 data[3];
414 } __attribute__((packed));
415 
416 /**
417  * The device type ID
418  * FIXME: clarify what this means
419  * ECMA-368 [16.8.10]
420  */
421 struct uwb_device_type_id {
422 	u8 data[3];
423 } __attribute__((packed));
424 
425 
426 /**
427  * UWB device information types
428  * ECMA-368 [16.8.10]
429  */
430 enum uwb_dev_info_type {
431 	UWB_DEV_INFO_VENDOR_ID = 0,
432 	UWB_DEV_INFO_VENDOR_TYPE,
433 	UWB_DEV_INFO_NAME,
434 };
435 
436 /**
437  * UWB device information found in Identification IE
438  * ECMA-368 [16.8.10]
439  */
440 struct uwb_dev_info {
441 	u8 type;	/* enum uwb_dev_info_type */
442 	u8 length;
443 	u8 data[];
444 } __attribute__((packed));
445 
446 /**
447  * UWB Identification IE
448  * ECMA-368 [16.8.10]
449  */
450 struct uwb_identification_ie {
451 	struct uwb_ie_hdr hdr;
452 	struct uwb_dev_info info[];
453 } __attribute__((packed));
454 
455 /*
456  * UWB Radio Controller
457  *
458  * These definitions are common to the Radio Control layers as
459  * exported by the WUSB1.0 HWA and WHCI interfaces.
460  */
461 
462 /** Radio Control Command Block (WUSB1.0[Table 8-65] and WHCI 0.95) */
463 struct uwb_rccb {
464 	u8 bCommandType;		/* enum hwa_cet */
465 	__le16 wCommand;		/* Command code */
466 	u8 bCommandContext;		/* Context ID */
467 } __attribute__((packed));
468 
469 
470 /** Radio Control Event Block (WUSB[table 8-66], WHCI 0.95) */
471 struct uwb_rceb {
472 	u8 bEventType;			/* enum hwa_cet */
473 	__le16 wEvent;			/* Event code */
474 	u8 bEventContext;		/* Context ID */
475 } __attribute__((packed));
476 
477 
478 enum {
479 	UWB_RC_CET_GENERAL = 0,		/* General Command/Event type */
480 	UWB_RC_CET_EX_TYPE_1 = 1,	/* Extended Type 1 Command/Event type */
481 };
482 
483 /* Commands to the radio controller */
484 enum uwb_rc_cmd {
485 	UWB_RC_CMD_CHANNEL_CHANGE = 16,
486 	UWB_RC_CMD_DEV_ADDR_MGMT = 17,	/* Device Address Management */
487 	UWB_RC_CMD_GET_IE = 18,		/* GET Information Elements */
488 	UWB_RC_CMD_RESET = 19,
489 	UWB_RC_CMD_SCAN = 20,		/* Scan management  */
490 	UWB_RC_CMD_SET_BEACON_FILTER = 21,
491 	UWB_RC_CMD_SET_DRP_IE = 22,	/* Dynamic Reservation Protocol IEs */
492 	UWB_RC_CMD_SET_IE = 23,		/* Information Element management */
493 	UWB_RC_CMD_SET_NOTIFICATION_FILTER = 24,
494 	UWB_RC_CMD_SET_TX_POWER = 25,
495 	UWB_RC_CMD_SLEEP = 26,
496 	UWB_RC_CMD_START_BEACON = 27,
497 	UWB_RC_CMD_STOP_BEACON = 28,
498 	UWB_RC_CMD_BP_MERGE = 29,
499 	UWB_RC_CMD_SEND_COMMAND_FRAME = 30,
500 	UWB_RC_CMD_SET_ASIE_NOTIF = 31,
501 };
502 
503 /* Notifications from the radio controller */
504 enum uwb_rc_evt {
505 	UWB_RC_EVT_IE_RCV = 0,
506 	UWB_RC_EVT_BEACON = 1,
507 	UWB_RC_EVT_BEACON_SIZE = 2,
508 	UWB_RC_EVT_BPOIE_CHANGE = 3,
509 	UWB_RC_EVT_BP_SLOT_CHANGE = 4,
510 	UWB_RC_EVT_BP_SWITCH_IE_RCV = 5,
511 	UWB_RC_EVT_DEV_ADDR_CONFLICT = 6,
512 	UWB_RC_EVT_DRP_AVAIL = 7,
513 	UWB_RC_EVT_DRP = 8,
514 	UWB_RC_EVT_BP_SWITCH_STATUS = 9,
515 	UWB_RC_EVT_CMD_FRAME_RCV = 10,
516 	UWB_RC_EVT_CHANNEL_CHANGE_IE_RCV = 11,
517 	/* Events (command responses) use the same code as the command */
518 	UWB_RC_EVT_UNKNOWN_CMD_RCV = 65535,
519 };
520 
521 enum uwb_rc_extended_type_1_cmd {
522 	UWB_RC_SET_DAA_ENERGY_MASK = 32,
523 	UWB_RC_SET_NOTIFICATION_FILTER_EX = 33,
524 };
525 
526 enum uwb_rc_extended_type_1_evt {
527 	UWB_RC_DAA_ENERGY_DETECTED = 0,
528 };
529 
530 /* Radio Control Result Code. [WHCI] table 3-3. */
531 enum {
532 	UWB_RC_RES_SUCCESS = 0,
533 	UWB_RC_RES_FAIL,
534 	UWB_RC_RES_FAIL_HARDWARE,
535 	UWB_RC_RES_FAIL_NO_SLOTS,
536 	UWB_RC_RES_FAIL_BEACON_TOO_LARGE,
537 	UWB_RC_RES_FAIL_INVALID_PARAMETER,
538 	UWB_RC_RES_FAIL_UNSUPPORTED_PWR_LEVEL,
539 	UWB_RC_RES_FAIL_INVALID_IE_DATA,
540 	UWB_RC_RES_FAIL_BEACON_SIZE_EXCEEDED,
541 	UWB_RC_RES_FAIL_CANCELLED,
542 	UWB_RC_RES_FAIL_INVALID_STATE,
543 	UWB_RC_RES_FAIL_INVALID_SIZE,
544 	UWB_RC_RES_FAIL_ACK_NOT_RECEIVED,
545 	UWB_RC_RES_FAIL_NO_MORE_ASIE_NOTIF,
546 	UWB_RC_RES_FAIL_TIME_OUT = 255,
547 };
548 
549 /* Confirm event. [WHCI] section 3.1.3.1 etc. */
550 struct uwb_rc_evt_confirm {
551 	struct uwb_rceb rceb;
552 	u8 bResultCode;
553 } __attribute__((packed));
554 
555 /* Device Address Management event. [WHCI] section 3.1.3.2. */
556 struct uwb_rc_evt_dev_addr_mgmt {
557 	struct uwb_rceb rceb;
558 	u8 baAddr[ETH_ALEN];
559 	u8 bResultCode;
560 } __attribute__((packed));
561 
562 
563 /* Get IE Event. [WHCI] section 3.1.3.3. */
564 struct uwb_rc_evt_get_ie {
565 	struct uwb_rceb rceb;
566 	__le16 wIELength;
567 	u8 IEData[];
568 } __attribute__((packed));
569 
570 /* Set DRP IE Event. [WHCI] section 3.1.3.7. */
571 struct uwb_rc_evt_set_drp_ie {
572 	struct uwb_rceb rceb;
573 	__le16 wRemainingSpace;
574 	u8 bResultCode;
575 } __attribute__((packed));
576 
577 /* Set IE Event. [WHCI] section 3.1.3.8. */
578 struct uwb_rc_evt_set_ie {
579 	struct uwb_rceb rceb;
580 	__le16 RemainingSpace;
581 	u8 bResultCode;
582 } __attribute__((packed));
583 
584 /* Scan command. [WHCI] 3.1.3.5. */
585 struct uwb_rc_cmd_scan {
586 	struct uwb_rccb rccb;
587 	u8 bChannelNumber;
588 	u8 bScanState;
589 	__le16 wStartTime;
590 } __attribute__((packed));
591 
592 /* Set DRP IE command. [WHCI] section 3.1.3.7. */
593 struct uwb_rc_cmd_set_drp_ie {
594 	struct uwb_rccb rccb;
595 	__le16 wIELength;
596 	struct uwb_ie_drp IEData[];
597 } __attribute__((packed));
598 
599 /* Set IE command. [WHCI] section 3.1.3.8. */
600 struct uwb_rc_cmd_set_ie {
601 	struct uwb_rccb rccb;
602 	__le16 wIELength;
603 	u8 IEData[];
604 } __attribute__((packed));
605 
606 /* Set DAA Energy Mask event. [WHCI 0.96] section 3.1.3.17. */
607 struct uwb_rc_evt_set_daa_energy_mask {
608 	struct uwb_rceb rceb;
609 	__le16 wLength;
610 	u8 result;
611 } __attribute__((packed));
612 
613 /* Set Notification Filter Extended event. [WHCI 0.96] section 3.1.3.18. */
614 struct uwb_rc_evt_set_notification_filter_ex {
615 	struct uwb_rceb rceb;
616 	__le16 wLength;
617 	u8 result;
618 } __attribute__((packed));
619 
620 /* IE Received notification. [WHCI] section 3.1.4.1. */
621 struct uwb_rc_evt_ie_rcv {
622 	struct uwb_rceb rceb;
623 	struct uwb_dev_addr SrcAddr;
624 	__le16 wIELength;
625 	u8 IEData[];
626 } __attribute__((packed));
627 
628 /* Type of the received beacon. [WHCI] section 3.1.4.2. */
629 enum uwb_rc_beacon_type {
630 	UWB_RC_BEACON_TYPE_SCAN = 0,
631 	UWB_RC_BEACON_TYPE_NEIGHBOR,
632 	UWB_RC_BEACON_TYPE_OL_ALIEN,
633 	UWB_RC_BEACON_TYPE_NOL_ALIEN,
634 };
635 
636 /* Beacon received notification. [WHCI] 3.1.4.2. */
637 struct uwb_rc_evt_beacon {
638 	struct uwb_rceb rceb;
639 	u8	bChannelNumber;
640 	u8	bBeaconType;
641 	__le16	wBPSTOffset;
642 	u8	bLQI;
643 	u8	bRSSI;
644 	__le16	wBeaconInfoLength;
645 	u8	BeaconInfo[];
646 } __attribute__((packed));
647 
648 
649 /* Beacon Size Change notification. [WHCI] section 3.1.4.3 */
650 struct uwb_rc_evt_beacon_size {
651 	struct uwb_rceb rceb;
652 	__le16 wNewBeaconSize;
653 } __attribute__((packed));
654 
655 
656 /* BPOIE Change notification. [WHCI] section 3.1.4.4. */
657 struct uwb_rc_evt_bpoie_change {
658 	struct uwb_rceb rceb;
659 	__le16 wBPOIELength;
660 	u8 BPOIE[];
661 } __attribute__((packed));
662 
663 
664 /* Beacon Slot Change notification. [WHCI] section 3.1.4.5. */
665 struct uwb_rc_evt_bp_slot_change {
666 	struct uwb_rceb rceb;
667 	u8 slot_info;
668 } __attribute__((packed));
669 
uwb_rc_evt_bp_slot_change_slot_num(const struct uwb_rc_evt_bp_slot_change * evt)670 static inline int uwb_rc_evt_bp_slot_change_slot_num(
671 	const struct uwb_rc_evt_bp_slot_change *evt)
672 {
673 	return evt->slot_info & 0x7f;
674 }
675 
uwb_rc_evt_bp_slot_change_no_slot(const struct uwb_rc_evt_bp_slot_change * evt)676 static inline int uwb_rc_evt_bp_slot_change_no_slot(
677 	const struct uwb_rc_evt_bp_slot_change *evt)
678 {
679 	return (evt->slot_info & 0x80) >> 7;
680 }
681 
682 /* BP Switch IE Received notification. [WHCI] section 3.1.4.6. */
683 struct uwb_rc_evt_bp_switch_ie_rcv {
684 	struct uwb_rceb rceb;
685 	struct uwb_dev_addr wSrcAddr;
686 	__le16 wIELength;
687 	u8 IEData[];
688 } __attribute__((packed));
689 
690 /* DevAddr Conflict notification. [WHCI] section 3.1.4.7. */
691 struct uwb_rc_evt_dev_addr_conflict {
692 	struct uwb_rceb rceb;
693 } __attribute__((packed));
694 
695 /* DRP notification. [WHCI] section 3.1.4.9. */
696 struct uwb_rc_evt_drp {
697 	struct uwb_rceb           rceb;
698 	struct uwb_dev_addr       src_addr;
699 	u8                        reason;
700 	u8                        beacon_slot_number;
701 	__le16                    ie_length;
702 	u8                        ie_data[];
703 } __attribute__((packed));
704 
uwb_rc_evt_drp_reason(struct uwb_rc_evt_drp * evt)705 static inline enum uwb_drp_notif_reason uwb_rc_evt_drp_reason(struct uwb_rc_evt_drp *evt)
706 {
707 	return evt->reason & 0x0f;
708 }
709 
710 
711 /* DRP Availability Change notification. [WHCI] section 3.1.4.8. */
712 struct uwb_rc_evt_drp_avail {
713 	struct uwb_rceb rceb;
714 	DECLARE_BITMAP(bmp, UWB_NUM_MAS);
715 } __attribute__((packed));
716 
717 /* BP switch status notification. [WHCI] section 3.1.4.10. */
718 struct uwb_rc_evt_bp_switch_status {
719 	struct uwb_rceb rceb;
720 	u8 status;
721 	u8 slot_offset;
722 	__le16 bpst_offset;
723 	u8 move_countdown;
724 } __attribute__((packed));
725 
726 /* Command Frame Received notification. [WHCI] section 3.1.4.11. */
727 struct uwb_rc_evt_cmd_frame_rcv {
728 	struct uwb_rceb rceb;
729 	__le16 receive_time;
730 	struct uwb_dev_addr wSrcAddr;
731 	struct uwb_dev_addr wDstAddr;
732 	__le16 control;
733 	__le16 reserved;
734 	__le16 dataLength;
735 	u8 data[];
736 } __attribute__((packed));
737 
738 /* Channel Change IE Received notification. [WHCI] section 3.1.4.12. */
739 struct uwb_rc_evt_channel_change_ie_rcv {
740 	struct uwb_rceb rceb;
741 	struct uwb_dev_addr wSrcAddr;
742 	__le16 wIELength;
743 	u8 IEData[];
744 } __attribute__((packed));
745 
746 /* DAA Energy Detected notification. [WHCI 0.96] section 3.1.4.14. */
747 struct uwb_rc_evt_daa_energy_detected {
748 	struct uwb_rceb rceb;
749 	__le16 wLength;
750 	u8 bandID;
751 	u8 reserved;
752 	u8 toneBmp[16];
753 } __attribute__((packed));
754 
755 
756 /**
757  * Radio Control Interface Class Descriptor
758  *
759  *  WUSB 1.0 [8.6.1.2]
760  */
761 struct uwb_rc_control_intf_class_desc {
762 	u8 bLength;
763 	u8 bDescriptorType;
764 	__le16 bcdRCIVersion;
765 } __attribute__((packed));
766 
767 #endif /* #ifndef __LINUX__UWB_SPEC_H__ */
768