3 * UWB Standard definitions
5 * Copyright (C) 2005-2006 Intel Corporation
6 * Inaky Perez-Gonzalez <inaky.perez-gonzalez@intel.com>
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License version
10 * 2 as published by the Free Software Foundation.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
23 * All these definitions are based on the ECMA-368 standard.
25 * Note all definitions are Little Endian in the wire, and we will
26 * convert them to host order before operating on the bitfields (that
27 * yes, we use extensively).
30 #ifndef __LINUX__UWB_SPEC_H__
31 #define __LINUX__UWB_SPEC_H__
33 #include <linux/types.h>
34 #include <linux/bitmap.h>
36 #define i1480_FW 0x00000303
37 /* #define i1480_FW 0x00000302 */
40 * Number of Medium Access Slots in a superframe.
42 * UWB divides time in SuperFrames, each one divided in 256 pieces, or
43 * Medium Access Slots. See MBOA MAC[5.4.5] for details. The MAS is the
44 * basic bandwidth allocation unit in UWB.
46 enum { UWB_NUM_MAS = 256 };
49 * Number of Zones in superframe.
51 * UWB divides the superframe into zones with numbering starting from BPST.
52 * See MBOA MAC[16.8.6]
54 enum { UWB_NUM_ZONES = 16 };
57 * Number of MAS in a zone.
59 #define UWB_MAS_PER_ZONE (UWB_NUM_MAS / UWB_NUM_ZONES)
62 * Number of streams per DRP reservation between a pair of devices.
64 * [ECMA-368] section 16.8.6.
66 enum { UWB_NUM_STREAMS = 8 };
71 * The length of a MAS in microseconds.
73 * [ECMA-368] section 17.16.
75 enum { UWB_MAS_LENGTH_US = 256 };
80 * The length of the beacon slot in microseconds.
82 * [ECMA-368] section 17.16
84 enum { UWB_BEACON_SLOT_LENGTH_US = 85 };
89 * The number beacons missing in consecutive superframes before a
90 * device can be considered as unreachable.
92 * [ECMA-368] section 17.16
94 enum { UWB_MAX_LOST_BEACONS = 3 };
97 * Length of a superframe in microseconds.
99 #define UWB_SUPERFRAME_LENGTH_US (UWB_MAS_LENGTH_US * UWB_NUM_MAS)
104 * It is *imperative* that this struct is exactly 6 packed bytes (as
105 * it is also used to define headers sent down and up the wire/radio).
107 struct uwb_mac_addr {
109 } __attribute__((packed));
115 * It is *imperative* that this struct is exactly 6 packed bytes (as
116 * it is also used to define headers sent down and up the wire/radio).
118 struct uwb_dev_addr {
120 } __attribute__((packed));
124 * Types of UWB addresses
126 * Order matters (by size).
134 /** Size of a char buffer for printing a MAC/device address */
135 enum { UWB_ADDR_STRSIZE = 32 };
138 /** UWB WiMedia protocol IDs. */
140 UWB_PRID_WLP_RESERVED = 0x0000,
141 UWB_PRID_WLP = 0x0001,
142 UWB_PRID_WUSB_BOT = 0x0010,
143 UWB_PRID_WUSB = 0x0010,
144 UWB_PRID_WUSB_TOP = 0x001F,
148 /** PHY Rate (MBOA MAC[7.8.12, Table 61]) */
163 * Different ways to scan (MBOA MAC[6.2.2, Table 8], WUSB[Table 8-78])
168 UWB_SCAN_WHILE_INACTIVE,
170 UWB_SCAN_ONLY_STARTTIME,
175 /** ACK Policy types (MBOA MAC[7.2.1.3]) */
184 /** DRP reservation types ([ECMA-368 table 106) */
186 UWB_DRP_TYPE_ALIEN_BP = 0,
189 UWB_DRP_TYPE_PRIVATE,
194 /** DRP Reason Codes ([ECMA-368] table 107) */
195 enum uwb_drp_reason {
196 UWB_DRP_REASON_ACCEPTED = 0,
197 UWB_DRP_REASON_CONFLICT,
198 UWB_DRP_REASON_PENDING,
199 UWB_DRP_REASON_DENIED,
200 UWB_DRP_REASON_MODIFIED,
204 * DRP Notification Reason Codes (WHCI 0.95 [3.1.4.9])
206 enum uwb_drp_notif_reason {
207 UWB_DRP_NOTIF_DRP_IE_RCVD = 0,
208 UWB_DRP_NOTIF_CONFLICT,
209 UWB_DRP_NOTIF_TERMINATE,
213 /** Allocation of MAS slots in a DRP request MBOA MAC[7.8.7] */
214 struct uwb_drp_alloc {
217 } __attribute__((packed));
220 /** General MAC Header format (ECMA-368[16.2]) */
221 struct uwb_mac_frame_hdr {
222 __le16 Frame_Control;
223 struct uwb_dev_addr DestAddr;
224 struct uwb_dev_addr SrcAddr;
225 __le16 Sequence_Control;
226 __le16 Access_Information;
227 } __attribute__((packed));
231 * uwb_beacon_frame - a beacon frame including MAC headers
233 * [ECMA] section 16.3.
235 struct uwb_beacon_frame {
236 struct uwb_mac_frame_hdr hdr;
237 struct uwb_mac_addr Device_Identifier; /* may be a NULL EUI-48 */
238 u8 Beacon_Slot_Number;
241 } __attribute__((packed));
244 /** Information Element codes (MBOA MAC[T54]) */
246 UWB_PCA_AVAILABILITY = 2,
247 UWB_IE_DRP_AVAILABILITY = 8,
249 UWB_BP_SWITCH_IE = 11,
250 UWB_MAC_CAPABILITIES_IE = 12,
251 UWB_PHY_CAPABILITIES_IE = 13,
252 UWB_APP_SPEC_PROBE_IE = 15,
253 UWB_IDENTIFICATION_IE = 19,
254 UWB_MASTER_KEY_ID_IE = 20,
255 UWB_IE_WLP = 250, /* WiMedia Logical Link Control Protocol WLP 0.99 */
256 UWB_APP_SPEC_IE = 255,
261 * Header common to all Information Elements (IEs)
264 u8 element_id; /* enum uwb_ie */
266 } __attribute__((packed));
269 /** Dynamic Reservation Protocol IE (MBOA MAC[7.8.6]) */
271 struct uwb_ie_hdr hdr;
273 struct uwb_dev_addr dev_addr;
274 struct uwb_drp_alloc allocs[];
275 } __attribute__((packed));
277 static inline int uwb_ie_drp_type(struct uwb_ie_drp *ie)
279 return (le16_to_cpu(ie->drp_control) >> 0) & 0x7;
282 static inline int uwb_ie_drp_stream_index(struct uwb_ie_drp *ie)
284 return (le16_to_cpu(ie->drp_control) >> 3) & 0x7;
287 static inline int uwb_ie_drp_reason_code(struct uwb_ie_drp *ie)
289 return (le16_to_cpu(ie->drp_control) >> 6) & 0x7;
292 static inline int uwb_ie_drp_status(struct uwb_ie_drp *ie)
294 return (le16_to_cpu(ie->drp_control) >> 9) & 0x1;
297 static inline int uwb_ie_drp_owner(struct uwb_ie_drp *ie)
299 return (le16_to_cpu(ie->drp_control) >> 10) & 0x1;
302 static inline int uwb_ie_drp_tiebreaker(struct uwb_ie_drp *ie)
304 return (le16_to_cpu(ie->drp_control) >> 11) & 0x1;
307 static inline int uwb_ie_drp_unsafe(struct uwb_ie_drp *ie)
309 return (le16_to_cpu(ie->drp_control) >> 12) & 0x1;
312 static inline void uwb_ie_drp_set_type(struct uwb_ie_drp *ie, enum uwb_drp_type type)
314 u16 drp_control = le16_to_cpu(ie->drp_control);
315 drp_control = (drp_control & ~(0x7 << 0)) | (type << 0);
316 ie->drp_control = cpu_to_le16(drp_control);
319 static inline void uwb_ie_drp_set_stream_index(struct uwb_ie_drp *ie, int stream_index)
321 u16 drp_control = le16_to_cpu(ie->drp_control);
322 drp_control = (drp_control & ~(0x7 << 3)) | (stream_index << 3);
323 ie->drp_control = cpu_to_le16(drp_control);
326 static inline void uwb_ie_drp_set_reason_code(struct uwb_ie_drp *ie,
327 enum uwb_drp_reason reason_code)
329 u16 drp_control = le16_to_cpu(ie->drp_control);
330 drp_control = (ie->drp_control & ~(0x7 << 6)) | (reason_code << 6);
331 ie->drp_control = cpu_to_le16(drp_control);
334 static inline void uwb_ie_drp_set_status(struct uwb_ie_drp *ie, int status)
336 u16 drp_control = le16_to_cpu(ie->drp_control);
337 drp_control = (drp_control & ~(0x1 << 9)) | (status << 9);
338 ie->drp_control = cpu_to_le16(drp_control);
341 static inline void uwb_ie_drp_set_owner(struct uwb_ie_drp *ie, int owner)
343 u16 drp_control = le16_to_cpu(ie->drp_control);
344 drp_control = (drp_control & ~(0x1 << 10)) | (owner << 10);
345 ie->drp_control = cpu_to_le16(drp_control);
348 static inline void uwb_ie_drp_set_tiebreaker(struct uwb_ie_drp *ie, int tiebreaker)
350 u16 drp_control = le16_to_cpu(ie->drp_control);
351 drp_control = (drp_control & ~(0x1 << 11)) | (tiebreaker << 11);
352 ie->drp_control = cpu_to_le16(drp_control);
355 static inline void uwb_ie_drp_set_unsafe(struct uwb_ie_drp *ie, int unsafe)
357 u16 drp_control = le16_to_cpu(ie->drp_control);
358 drp_control = (drp_control & ~(0x1 << 12)) | (unsafe << 12);
359 ie->drp_control = cpu_to_le16(drp_control);
362 /** Dynamic Reservation Protocol IE (MBOA MAC[7.8.7]) */
363 struct uwb_ie_drp_avail {
364 struct uwb_ie_hdr hdr;
365 DECLARE_BITMAP(bmp, UWB_NUM_MAS);
366 } __attribute__((packed));
369 * The Vendor ID is set to an OUI that indicates the vendor of the device.
372 struct uwb_vendor_id {
374 } __attribute__((packed));
378 * FIXME: clarify what this means
381 struct uwb_device_type_id {
383 } __attribute__((packed));
387 * UWB device information types
390 enum uwb_dev_info_type {
391 UWB_DEV_INFO_VENDOR_ID = 0,
392 UWB_DEV_INFO_VENDOR_TYPE,
397 * UWB device information found in Identification IE
400 struct uwb_dev_info {
401 u8 type; /* enum uwb_dev_info_type */
404 } __attribute__((packed));
407 * UWB Identification IE
410 struct uwb_identification_ie {
411 struct uwb_ie_hdr hdr;
412 struct uwb_dev_info info[];
413 } __attribute__((packed));
416 * UWB Radio Controller
418 * These definitions are common to the Radio Control layers as
419 * exported by the WUSB1.0 HWA and WHCI interfaces.
422 /** Radio Control Command Block (WUSB1.0[Table 8-65] and WHCI 0.95) */
424 u8 bCommandType; /* enum hwa_cet */
425 __le16 wCommand; /* Command code */
426 u8 bCommandContext; /* Context ID */
427 } __attribute__((packed));
430 /** Radio Control Event Block (WUSB[table 8-66], WHCI 0.95) */
432 u8 bEventType; /* enum hwa_cet */
433 __le16 wEvent; /* Event code */
434 u8 bEventContext; /* Context ID */
435 } __attribute__((packed));
439 UWB_RC_CET_GENERAL = 0, /* General Command/Event type */
440 UWB_RC_CET_EX_TYPE_1 = 1, /* Extended Type 1 Command/Event type */
443 /* Commands to the radio controller */
445 UWB_RC_CMD_CHANNEL_CHANGE = 16,
446 UWB_RC_CMD_DEV_ADDR_MGMT = 17, /* Device Address Management */
447 UWB_RC_CMD_GET_IE = 18, /* GET Information Elements */
448 UWB_RC_CMD_RESET = 19,
449 UWB_RC_CMD_SCAN = 20, /* Scan management */
450 UWB_RC_CMD_SET_BEACON_FILTER = 21,
451 UWB_RC_CMD_SET_DRP_IE = 22, /* Dynamic Reservation Protocol IEs */
452 UWB_RC_CMD_SET_IE = 23, /* Information Element management */
453 UWB_RC_CMD_SET_NOTIFICATION_FILTER = 24,
454 UWB_RC_CMD_SET_TX_POWER = 25,
455 UWB_RC_CMD_SLEEP = 26,
456 UWB_RC_CMD_START_BEACON = 27,
457 UWB_RC_CMD_STOP_BEACON = 28,
458 UWB_RC_CMD_BP_MERGE = 29,
459 UWB_RC_CMD_SEND_COMMAND_FRAME = 30,
460 UWB_RC_CMD_SET_ASIE_NOTIF = 31,
463 /* Notifications from the radio controller */
465 UWB_RC_EVT_IE_RCV = 0,
466 UWB_RC_EVT_BEACON = 1,
467 UWB_RC_EVT_BEACON_SIZE = 2,
468 UWB_RC_EVT_BPOIE_CHANGE = 3,
469 UWB_RC_EVT_BP_SLOT_CHANGE = 4,
470 UWB_RC_EVT_BP_SWITCH_IE_RCV = 5,
471 UWB_RC_EVT_DEV_ADDR_CONFLICT = 6,
472 UWB_RC_EVT_DRP_AVAIL = 7,
474 UWB_RC_EVT_BP_SWITCH_STATUS = 9,
475 UWB_RC_EVT_CMD_FRAME_RCV = 10,
476 UWB_RC_EVT_CHANNEL_CHANGE_IE_RCV = 11,
477 /* Events (command responses) use the same code as the command */
478 UWB_RC_EVT_UNKNOWN_CMD_RCV = 65535,
481 enum uwb_rc_extended_type_1_cmd {
482 UWB_RC_SET_DAA_ENERGY_MASK = 32,
483 UWB_RC_SET_NOTIFICATION_FILTER_EX = 33,
486 enum uwb_rc_extended_type_1_evt {
487 UWB_RC_DAA_ENERGY_DETECTED = 0,
490 /* Radio Control Result Code. [WHCI] table 3-3. */
492 UWB_RC_RES_SUCCESS = 0,
494 UWB_RC_RES_FAIL_HARDWARE,
495 UWB_RC_RES_FAIL_NO_SLOTS,
496 UWB_RC_RES_FAIL_BEACON_TOO_LARGE,
497 UWB_RC_RES_FAIL_INVALID_PARAMETER,
498 UWB_RC_RES_FAIL_UNSUPPORTED_PWR_LEVEL,
499 UWB_RC_RES_FAIL_INVALID_IE_DATA,
500 UWB_RC_RES_FAIL_BEACON_SIZE_EXCEEDED,
501 UWB_RC_RES_FAIL_CANCELLED,
502 UWB_RC_RES_FAIL_INVALID_STATE,
503 UWB_RC_RES_FAIL_INVALID_SIZE,
504 UWB_RC_RES_FAIL_ACK_NOT_RECEIVED,
505 UWB_RC_RES_FAIL_NO_MORE_ASIE_NOTIF,
506 UWB_RC_RES_FAIL_TIME_OUT = 255,
509 /* Confirm event. [WHCI] section 3.1.3.1 etc. */
510 struct uwb_rc_evt_confirm {
511 struct uwb_rceb rceb;
513 } __attribute__((packed));
515 /* Device Address Management event. [WHCI] section 3.1.3.2. */
516 struct uwb_rc_evt_dev_addr_mgmt {
517 struct uwb_rceb rceb;
520 } __attribute__((packed));
523 /* Get IE Event. [WHCI] section 3.1.3.3. */
524 struct uwb_rc_evt_get_ie {
525 struct uwb_rceb rceb;
528 } __attribute__((packed));
530 /* Set DRP IE Event. [WHCI] section 3.1.3.7. */
531 struct uwb_rc_evt_set_drp_ie {
532 struct uwb_rceb rceb;
533 __le16 wRemainingSpace;
535 } __attribute__((packed));
537 /* Set IE Event. [WHCI] section 3.1.3.8. */
538 struct uwb_rc_evt_set_ie {
539 struct uwb_rceb rceb;
540 __le16 RemainingSpace;
542 } __attribute__((packed));
544 /* Scan command. [WHCI] 3.1.3.5. */
545 struct uwb_rc_cmd_scan {
546 struct uwb_rccb rccb;
550 } __attribute__((packed));
552 /* Set DRP IE command. [WHCI] section 3.1.3.7. */
553 struct uwb_rc_cmd_set_drp_ie {
554 struct uwb_rccb rccb;
556 struct uwb_ie_drp IEData[];
557 } __attribute__((packed));
559 /* Set IE command. [WHCI] section 3.1.3.8. */
560 struct uwb_rc_cmd_set_ie {
561 struct uwb_rccb rccb;
564 } __attribute__((packed));
566 /* Set DAA Energy Mask event. [WHCI 0.96] section 3.1.3.17. */
567 struct uwb_rc_evt_set_daa_energy_mask {
568 struct uwb_rceb rceb;
571 } __attribute__((packed));
573 /* Set Notification Filter Extended event. [WHCI 0.96] section 3.1.3.18. */
574 struct uwb_rc_evt_set_notification_filter_ex {
575 struct uwb_rceb rceb;
578 } __attribute__((packed));
580 /* IE Received notification. [WHCI] section 3.1.4.1. */
581 struct uwb_rc_evt_ie_rcv {
582 struct uwb_rceb rceb;
583 struct uwb_dev_addr SrcAddr;
586 } __attribute__((packed));
588 /* Type of the received beacon. [WHCI] section 3.1.4.2. */
589 enum uwb_rc_beacon_type {
590 UWB_RC_BEACON_TYPE_SCAN = 0,
591 UWB_RC_BEACON_TYPE_NEIGHBOR,
592 UWB_RC_BEACON_TYPE_OL_ALIEN,
593 UWB_RC_BEACON_TYPE_NOL_ALIEN,
596 /* Beacon received notification. [WHCI] 3.1.4.2. */
597 struct uwb_rc_evt_beacon {
598 struct uwb_rceb rceb;
604 __le16 wBeaconInfoLength;
606 } __attribute__((packed));
609 /* Beacon Size Change notification. [WHCI] section 3.1.4.3 */
610 struct uwb_rc_evt_beacon_size {
611 struct uwb_rceb rceb;
612 __le16 wNewBeaconSize;
613 } __attribute__((packed));
616 /* BPOIE Change notification. [WHCI] section 3.1.4.4. */
617 struct uwb_rc_evt_bpoie_change {
618 struct uwb_rceb rceb;
621 } __attribute__((packed));
624 /* Beacon Slot Change notification. [WHCI] section 3.1.4.5. */
625 struct uwb_rc_evt_bp_slot_change {
626 struct uwb_rceb rceb;
628 } __attribute__((packed));
630 static inline int uwb_rc_evt_bp_slot_change_slot_num(
631 const struct uwb_rc_evt_bp_slot_change *evt)
633 return evt->slot_info & 0x7f;
636 static inline int uwb_rc_evt_bp_slot_change_no_slot(
637 const struct uwb_rc_evt_bp_slot_change *evt)
639 return (evt->slot_info & 0x80) >> 7;
642 /* BP Switch IE Received notification. [WHCI] section 3.1.4.6. */
643 struct uwb_rc_evt_bp_switch_ie_rcv {
644 struct uwb_rceb rceb;
645 struct uwb_dev_addr wSrcAddr;
648 } __attribute__((packed));
650 /* DevAddr Conflict notification. [WHCI] section 3.1.4.7. */
651 struct uwb_rc_evt_dev_addr_conflict {
652 struct uwb_rceb rceb;
653 } __attribute__((packed));
655 /* DRP notification. [WHCI] section 3.1.4.9. */
656 struct uwb_rc_evt_drp {
657 struct uwb_rceb rceb;
658 struct uwb_dev_addr src_addr;
660 u8 beacon_slot_number;
663 } __attribute__((packed));
665 static inline enum uwb_drp_notif_reason uwb_rc_evt_drp_reason(struct uwb_rc_evt_drp *evt)
667 return evt->reason & 0x0f;
671 /* DRP Availability Change notification. [WHCI] section 3.1.4.8. */
672 struct uwb_rc_evt_drp_avail {
673 struct uwb_rceb rceb;
674 DECLARE_BITMAP(bmp, UWB_NUM_MAS);
675 } __attribute__((packed));
677 /* BP switch status notification. [WHCI] section 3.1.4.10. */
678 struct uwb_rc_evt_bp_switch_status {
679 struct uwb_rceb rceb;
684 } __attribute__((packed));
686 /* Command Frame Received notification. [WHCI] section 3.1.4.11. */
687 struct uwb_rc_evt_cmd_frame_rcv {
688 struct uwb_rceb rceb;
690 struct uwb_dev_addr wSrcAddr;
691 struct uwb_dev_addr wDstAddr;
696 } __attribute__((packed));
698 /* Channel Change IE Received notification. [WHCI] section 3.1.4.12. */
699 struct uwb_rc_evt_channel_change_ie_rcv {
700 struct uwb_rceb rceb;
701 struct uwb_dev_addr wSrcAddr;
704 } __attribute__((packed));
706 /* DAA Energy Detected notification. [WHCI 0.96] section 3.1.4.14. */
707 struct uwb_rc_evt_daa_energy_detected {
708 struct uwb_rceb rceb;
713 } __attribute__((packed));
717 * Radio Control Interface Class Descriptor
721 struct uwb_rc_control_intf_class_desc {
724 __le16 bcdRCIVersion;
725 } __attribute__((packed));
727 #endif /* #ifndef __LINUX__UWB_SPEC_H__ */