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>
35 #include <linux/if_ether.h>
37 #define i1480_FW 0x00000303
38 /* #define i1480_FW 0x00000302 */
41 * Number of Medium Access Slots in a superframe.
43 * UWB divides time in SuperFrames, each one divided in 256 pieces, or
44 * Medium Access Slots. See MBOA MAC[5.4.5] for details. The MAS is the
45 * basic bandwidth allocation unit in UWB.
47 enum { UWB_NUM_MAS = 256 };
50 * Number of Zones in superframe.
52 * UWB divides the superframe into zones with numbering starting from BPST.
53 * See MBOA MAC[16.8.6]
55 enum { UWB_NUM_ZONES = 16 };
58 * Number of MAS in a zone.
60 #define UWB_MAS_PER_ZONE (UWB_NUM_MAS / UWB_NUM_ZONES)
63 * Number of MAS required before a row can be considered available.
65 #define UWB_USABLE_MAS_PER_ROW (UWB_NUM_ZONES - 1)
68 * Number of streams per DRP reservation between a pair of devices.
70 * [ECMA-368] section 16.8.6.
72 enum { UWB_NUM_STREAMS = 8 };
77 * The length of a MAS in microseconds.
79 * [ECMA-368] section 17.16.
81 enum { UWB_MAS_LENGTH_US = 256 };
86 * The length of the beacon slot in microseconds.
88 * [ECMA-368] section 17.16
90 enum { UWB_BEACON_SLOT_LENGTH_US = 85 };
95 * The number beacons missing in consecutive superframes before a
96 * device can be considered as unreachable.
98 * [ECMA-368] section 17.16
100 enum { UWB_MAX_LOST_BEACONS = 3 };
105 * The minimum number of superframes to wait before trying to reserve
108 * [ECMA-368] section 17.16
110 enum { UWB_DRP_BACKOFF_WIN_MIN = 2 };
115 * The maximum number of superframes to wait before trying to reserve
118 * [ECMA-368] section 17.16
120 enum { UWB_DRP_BACKOFF_WIN_MAX = 16 };
123 * Length of a superframe in microseconds.
125 #define UWB_SUPERFRAME_LENGTH_US (UWB_MAS_LENGTH_US * UWB_NUM_MAS)
130 * It is *imperative* that this struct is exactly 6 packed bytes (as
131 * it is also used to define headers sent down and up the wire/radio).
133 struct uwb_mac_addr {
135 } __attribute__((packed));
141 * It is *imperative* that this struct is exactly 6 packed bytes (as
142 * it is also used to define headers sent down and up the wire/radio).
144 struct uwb_dev_addr {
146 } __attribute__((packed));
150 * Types of UWB addresses
152 * Order matters (by size).
160 /** Size of a char buffer for printing a MAC/device address */
161 enum { UWB_ADDR_STRSIZE = 32 };
164 /** UWB WiMedia protocol IDs. */
166 UWB_PRID_WLP_RESERVED = 0x0000,
167 UWB_PRID_WLP = 0x0001,
168 UWB_PRID_WUSB_BOT = 0x0010,
169 UWB_PRID_WUSB = 0x0010,
170 UWB_PRID_WUSB_TOP = 0x001F,
174 /** PHY Rate (MBOA MAC[7.8.12, Table 61]) */
189 * Different ways to scan (MBOA MAC[6.2.2, Table 8], WUSB[Table 8-78])
194 UWB_SCAN_WHILE_INACTIVE,
196 UWB_SCAN_ONLY_STARTTIME,
201 /** ACK Policy types (MBOA MAC[7.2.1.3]) */
210 /** DRP reservation types ([ECMA-368 table 106) */
212 UWB_DRP_TYPE_ALIEN_BP = 0,
215 UWB_DRP_TYPE_PRIVATE,
220 /** DRP Reason Codes ([ECMA-368] table 107) */
221 enum uwb_drp_reason {
222 UWB_DRP_REASON_ACCEPTED = 0,
223 UWB_DRP_REASON_CONFLICT,
224 UWB_DRP_REASON_PENDING,
225 UWB_DRP_REASON_DENIED,
226 UWB_DRP_REASON_MODIFIED,
229 /** Relinquish Request Reason Codes ([ECMA-368] table 113) */
230 enum uwb_relinquish_req_reason {
231 UWB_RELINQUISH_REQ_REASON_NON_SPECIFIC = 0,
232 UWB_RELINQUISH_REQ_REASON_OVER_ALLOCATION,
236 * DRP Notification Reason Codes (WHCI 0.95 [3.1.4.9])
238 enum uwb_drp_notif_reason {
239 UWB_DRP_NOTIF_DRP_IE_RCVD = 0,
240 UWB_DRP_NOTIF_CONFLICT,
241 UWB_DRP_NOTIF_TERMINATE,
245 /** Allocation of MAS slots in a DRP request MBOA MAC[7.8.7] */
246 struct uwb_drp_alloc {
249 } __attribute__((packed));
252 /** General MAC Header format (ECMA-368[16.2]) */
253 struct uwb_mac_frame_hdr {
254 __le16 Frame_Control;
255 struct uwb_dev_addr DestAddr;
256 struct uwb_dev_addr SrcAddr;
257 __le16 Sequence_Control;
258 __le16 Access_Information;
259 } __attribute__((packed));
263 * uwb_beacon_frame - a beacon frame including MAC headers
265 * [ECMA] section 16.3.
267 struct uwb_beacon_frame {
268 struct uwb_mac_frame_hdr hdr;
269 struct uwb_mac_addr Device_Identifier; /* may be a NULL EUI-48 */
270 u8 Beacon_Slot_Number;
273 } __attribute__((packed));
276 /** Information Element codes (MBOA MAC[T54]) */
278 UWB_PCA_AVAILABILITY = 2,
279 UWB_IE_DRP_AVAILABILITY = 8,
281 UWB_BP_SWITCH_IE = 11,
282 UWB_MAC_CAPABILITIES_IE = 12,
283 UWB_PHY_CAPABILITIES_IE = 13,
284 UWB_APP_SPEC_PROBE_IE = 15,
285 UWB_IDENTIFICATION_IE = 19,
286 UWB_MASTER_KEY_ID_IE = 20,
287 UWB_RELINQUISH_REQUEST_IE = 21,
288 UWB_IE_WLP = 250, /* WiMedia Logical Link Control Protocol WLP 0.99 */
289 UWB_APP_SPEC_IE = 255,
294 * Header common to all Information Elements (IEs)
297 u8 element_id; /* enum uwb_ie */
299 } __attribute__((packed));
302 /** Dynamic Reservation Protocol IE (MBOA MAC[7.8.6]) */
304 struct uwb_ie_hdr hdr;
306 struct uwb_dev_addr dev_addr;
307 struct uwb_drp_alloc allocs[];
308 } __attribute__((packed));
310 static inline int uwb_ie_drp_type(struct uwb_ie_drp *ie)
312 return (le16_to_cpu(ie->drp_control) >> 0) & 0x7;
315 static inline int uwb_ie_drp_stream_index(struct uwb_ie_drp *ie)
317 return (le16_to_cpu(ie->drp_control) >> 3) & 0x7;
320 static inline int uwb_ie_drp_reason_code(struct uwb_ie_drp *ie)
322 return (le16_to_cpu(ie->drp_control) >> 6) & 0x7;
325 static inline int uwb_ie_drp_status(struct uwb_ie_drp *ie)
327 return (le16_to_cpu(ie->drp_control) >> 9) & 0x1;
330 static inline int uwb_ie_drp_owner(struct uwb_ie_drp *ie)
332 return (le16_to_cpu(ie->drp_control) >> 10) & 0x1;
335 static inline int uwb_ie_drp_tiebreaker(struct uwb_ie_drp *ie)
337 return (le16_to_cpu(ie->drp_control) >> 11) & 0x1;
340 static inline int uwb_ie_drp_unsafe(struct uwb_ie_drp *ie)
342 return (le16_to_cpu(ie->drp_control) >> 12) & 0x1;
345 static inline void uwb_ie_drp_set_type(struct uwb_ie_drp *ie, enum uwb_drp_type type)
347 u16 drp_control = le16_to_cpu(ie->drp_control);
348 drp_control = (drp_control & ~(0x7 << 0)) | (type << 0);
349 ie->drp_control = cpu_to_le16(drp_control);
352 static inline void uwb_ie_drp_set_stream_index(struct uwb_ie_drp *ie, int stream_index)
354 u16 drp_control = le16_to_cpu(ie->drp_control);
355 drp_control = (drp_control & ~(0x7 << 3)) | (stream_index << 3);
356 ie->drp_control = cpu_to_le16(drp_control);
359 static inline void uwb_ie_drp_set_reason_code(struct uwb_ie_drp *ie,
360 enum uwb_drp_reason reason_code)
362 u16 drp_control = le16_to_cpu(ie->drp_control);
363 drp_control = (ie->drp_control & ~(0x7 << 6)) | (reason_code << 6);
364 ie->drp_control = cpu_to_le16(drp_control);
367 static inline void uwb_ie_drp_set_status(struct uwb_ie_drp *ie, int status)
369 u16 drp_control = le16_to_cpu(ie->drp_control);
370 drp_control = (drp_control & ~(0x1 << 9)) | (status << 9);
371 ie->drp_control = cpu_to_le16(drp_control);
374 static inline void uwb_ie_drp_set_owner(struct uwb_ie_drp *ie, int owner)
376 u16 drp_control = le16_to_cpu(ie->drp_control);
377 drp_control = (drp_control & ~(0x1 << 10)) | (owner << 10);
378 ie->drp_control = cpu_to_le16(drp_control);
381 static inline void uwb_ie_drp_set_tiebreaker(struct uwb_ie_drp *ie, int tiebreaker)
383 u16 drp_control = le16_to_cpu(ie->drp_control);
384 drp_control = (drp_control & ~(0x1 << 11)) | (tiebreaker << 11);
385 ie->drp_control = cpu_to_le16(drp_control);
388 static inline void uwb_ie_drp_set_unsafe(struct uwb_ie_drp *ie, int unsafe)
390 u16 drp_control = le16_to_cpu(ie->drp_control);
391 drp_control = (drp_control & ~(0x1 << 12)) | (unsafe << 12);
392 ie->drp_control = cpu_to_le16(drp_control);
395 /** Dynamic Reservation Protocol IE (MBOA MAC[7.8.7]) */
396 struct uwb_ie_drp_avail {
397 struct uwb_ie_hdr hdr;
398 DECLARE_BITMAP(bmp, UWB_NUM_MAS);
399 } __attribute__((packed));
401 /* Relinqish Request IE ([ECMA-368] section 16.8.19). */
402 struct uwb_relinquish_request_ie {
403 struct uwb_ie_hdr hdr;
404 __le16 relinquish_req_control;
405 struct uwb_dev_addr dev_addr;
406 struct uwb_drp_alloc allocs[];
407 } __attribute__((packed));
409 static inline int uwb_ie_relinquish_req_reason_code(struct uwb_relinquish_request_ie *ie)
411 return (le16_to_cpu(ie->relinquish_req_control) >> 0) & 0xf;
414 static inline void uwb_ie_relinquish_req_set_reason_code(struct uwb_relinquish_request_ie *ie,
417 u16 ctrl = le16_to_cpu(ie->relinquish_req_control);
418 ctrl = (ctrl & ~(0xf << 0)) | (reason_code << 0);
419 ie->relinquish_req_control = cpu_to_le16(ctrl);
423 * The Vendor ID is set to an OUI that indicates the vendor of the device.
426 struct uwb_vendor_id {
428 } __attribute__((packed));
432 * FIXME: clarify what this means
435 struct uwb_device_type_id {
437 } __attribute__((packed));
441 * UWB device information types
444 enum uwb_dev_info_type {
445 UWB_DEV_INFO_VENDOR_ID = 0,
446 UWB_DEV_INFO_VENDOR_TYPE,
451 * UWB device information found in Identification IE
454 struct uwb_dev_info {
455 u8 type; /* enum uwb_dev_info_type */
458 } __attribute__((packed));
461 * UWB Identification IE
464 struct uwb_identification_ie {
465 struct uwb_ie_hdr hdr;
466 struct uwb_dev_info info[];
467 } __attribute__((packed));
470 * UWB Radio Controller
472 * These definitions are common to the Radio Control layers as
473 * exported by the WUSB1.0 HWA and WHCI interfaces.
476 /** Radio Control Command Block (WUSB1.0[Table 8-65] and WHCI 0.95) */
478 u8 bCommandType; /* enum hwa_cet */
479 __le16 wCommand; /* Command code */
480 u8 bCommandContext; /* Context ID */
481 } __attribute__((packed));
484 /** Radio Control Event Block (WUSB[table 8-66], WHCI 0.95) */
486 u8 bEventType; /* enum hwa_cet */
487 __le16 wEvent; /* Event code */
488 u8 bEventContext; /* Context ID */
489 } __attribute__((packed));
493 UWB_RC_CET_GENERAL = 0, /* General Command/Event type */
494 UWB_RC_CET_EX_TYPE_1 = 1, /* Extended Type 1 Command/Event type */
497 /* Commands to the radio controller */
499 UWB_RC_CMD_CHANNEL_CHANGE = 16,
500 UWB_RC_CMD_DEV_ADDR_MGMT = 17, /* Device Address Management */
501 UWB_RC_CMD_GET_IE = 18, /* GET Information Elements */
502 UWB_RC_CMD_RESET = 19,
503 UWB_RC_CMD_SCAN = 20, /* Scan management */
504 UWB_RC_CMD_SET_BEACON_FILTER = 21,
505 UWB_RC_CMD_SET_DRP_IE = 22, /* Dynamic Reservation Protocol IEs */
506 UWB_RC_CMD_SET_IE = 23, /* Information Element management */
507 UWB_RC_CMD_SET_NOTIFICATION_FILTER = 24,
508 UWB_RC_CMD_SET_TX_POWER = 25,
509 UWB_RC_CMD_SLEEP = 26,
510 UWB_RC_CMD_START_BEACON = 27,
511 UWB_RC_CMD_STOP_BEACON = 28,
512 UWB_RC_CMD_BP_MERGE = 29,
513 UWB_RC_CMD_SEND_COMMAND_FRAME = 30,
514 UWB_RC_CMD_SET_ASIE_NOTIF = 31,
517 /* Notifications from the radio controller */
519 UWB_RC_EVT_IE_RCV = 0,
520 UWB_RC_EVT_BEACON = 1,
521 UWB_RC_EVT_BEACON_SIZE = 2,
522 UWB_RC_EVT_BPOIE_CHANGE = 3,
523 UWB_RC_EVT_BP_SLOT_CHANGE = 4,
524 UWB_RC_EVT_BP_SWITCH_IE_RCV = 5,
525 UWB_RC_EVT_DEV_ADDR_CONFLICT = 6,
526 UWB_RC_EVT_DRP_AVAIL = 7,
528 UWB_RC_EVT_BP_SWITCH_STATUS = 9,
529 UWB_RC_EVT_CMD_FRAME_RCV = 10,
530 UWB_RC_EVT_CHANNEL_CHANGE_IE_RCV = 11,
531 /* Events (command responses) use the same code as the command */
532 UWB_RC_EVT_UNKNOWN_CMD_RCV = 65535,
535 enum uwb_rc_extended_type_1_cmd {
536 UWB_RC_SET_DAA_ENERGY_MASK = 32,
537 UWB_RC_SET_NOTIFICATION_FILTER_EX = 33,
540 enum uwb_rc_extended_type_1_evt {
541 UWB_RC_DAA_ENERGY_DETECTED = 0,
544 /* Radio Control Result Code. [WHCI] table 3-3. */
546 UWB_RC_RES_SUCCESS = 0,
548 UWB_RC_RES_FAIL_HARDWARE,
549 UWB_RC_RES_FAIL_NO_SLOTS,
550 UWB_RC_RES_FAIL_BEACON_TOO_LARGE,
551 UWB_RC_RES_FAIL_INVALID_PARAMETER,
552 UWB_RC_RES_FAIL_UNSUPPORTED_PWR_LEVEL,
553 UWB_RC_RES_FAIL_INVALID_IE_DATA,
554 UWB_RC_RES_FAIL_BEACON_SIZE_EXCEEDED,
555 UWB_RC_RES_FAIL_CANCELLED,
556 UWB_RC_RES_FAIL_INVALID_STATE,
557 UWB_RC_RES_FAIL_INVALID_SIZE,
558 UWB_RC_RES_FAIL_ACK_NOT_RECEIVED,
559 UWB_RC_RES_FAIL_NO_MORE_ASIE_NOTIF,
560 UWB_RC_RES_FAIL_TIME_OUT = 255,
563 /* Confirm event. [WHCI] section 3.1.3.1 etc. */
564 struct uwb_rc_evt_confirm {
565 struct uwb_rceb rceb;
567 } __attribute__((packed));
569 /* Device Address Management event. [WHCI] section 3.1.3.2. */
570 struct uwb_rc_evt_dev_addr_mgmt {
571 struct uwb_rceb rceb;
574 } __attribute__((packed));
577 /* Get IE Event. [WHCI] section 3.1.3.3. */
578 struct uwb_rc_evt_get_ie {
579 struct uwb_rceb rceb;
582 } __attribute__((packed));
584 /* Set DRP IE Event. [WHCI] section 3.1.3.7. */
585 struct uwb_rc_evt_set_drp_ie {
586 struct uwb_rceb rceb;
587 __le16 wRemainingSpace;
589 } __attribute__((packed));
591 /* Set IE Event. [WHCI] section 3.1.3.8. */
592 struct uwb_rc_evt_set_ie {
593 struct uwb_rceb rceb;
594 __le16 RemainingSpace;
596 } __attribute__((packed));
598 /* Scan command. [WHCI] 3.1.3.5. */
599 struct uwb_rc_cmd_scan {
600 struct uwb_rccb rccb;
604 } __attribute__((packed));
606 /* Set DRP IE command. [WHCI] section 3.1.3.7. */
607 struct uwb_rc_cmd_set_drp_ie {
608 struct uwb_rccb rccb;
610 struct uwb_ie_drp IEData[];
611 } __attribute__((packed));
613 /* Set IE command. [WHCI] section 3.1.3.8. */
614 struct uwb_rc_cmd_set_ie {
615 struct uwb_rccb rccb;
618 } __attribute__((packed));
620 /* Set DAA Energy Mask event. [WHCI 0.96] section 3.1.3.17. */
621 struct uwb_rc_evt_set_daa_energy_mask {
622 struct uwb_rceb rceb;
625 } __attribute__((packed));
627 /* Set Notification Filter Extended event. [WHCI 0.96] section 3.1.3.18. */
628 struct uwb_rc_evt_set_notification_filter_ex {
629 struct uwb_rceb rceb;
632 } __attribute__((packed));
634 /* IE Received notification. [WHCI] section 3.1.4.1. */
635 struct uwb_rc_evt_ie_rcv {
636 struct uwb_rceb rceb;
637 struct uwb_dev_addr SrcAddr;
640 } __attribute__((packed));
642 /* Type of the received beacon. [WHCI] section 3.1.4.2. */
643 enum uwb_rc_beacon_type {
644 UWB_RC_BEACON_TYPE_SCAN = 0,
645 UWB_RC_BEACON_TYPE_NEIGHBOR,
646 UWB_RC_BEACON_TYPE_OL_ALIEN,
647 UWB_RC_BEACON_TYPE_NOL_ALIEN,
650 /* Beacon received notification. [WHCI] 3.1.4.2. */
651 struct uwb_rc_evt_beacon {
652 struct uwb_rceb rceb;
658 __le16 wBeaconInfoLength;
660 } __attribute__((packed));
663 /* Beacon Size Change notification. [WHCI] section 3.1.4.3 */
664 struct uwb_rc_evt_beacon_size {
665 struct uwb_rceb rceb;
666 __le16 wNewBeaconSize;
667 } __attribute__((packed));
670 /* BPOIE Change notification. [WHCI] section 3.1.4.4. */
671 struct uwb_rc_evt_bpoie_change {
672 struct uwb_rceb rceb;
675 } __attribute__((packed));
678 /* Beacon Slot Change notification. [WHCI] section 3.1.4.5. */
679 struct uwb_rc_evt_bp_slot_change {
680 struct uwb_rceb rceb;
682 } __attribute__((packed));
684 static inline int uwb_rc_evt_bp_slot_change_slot_num(
685 const struct uwb_rc_evt_bp_slot_change *evt)
687 return evt->slot_info & 0x7f;
690 static inline int uwb_rc_evt_bp_slot_change_no_slot(
691 const struct uwb_rc_evt_bp_slot_change *evt)
693 return (evt->slot_info & 0x80) >> 7;
696 /* BP Switch IE Received notification. [WHCI] section 3.1.4.6. */
697 struct uwb_rc_evt_bp_switch_ie_rcv {
698 struct uwb_rceb rceb;
699 struct uwb_dev_addr wSrcAddr;
702 } __attribute__((packed));
704 /* DevAddr Conflict notification. [WHCI] section 3.1.4.7. */
705 struct uwb_rc_evt_dev_addr_conflict {
706 struct uwb_rceb rceb;
707 } __attribute__((packed));
709 /* DRP notification. [WHCI] section 3.1.4.9. */
710 struct uwb_rc_evt_drp {
711 struct uwb_rceb rceb;
712 struct uwb_dev_addr src_addr;
714 u8 beacon_slot_number;
717 } __attribute__((packed));
719 static inline enum uwb_drp_notif_reason uwb_rc_evt_drp_reason(struct uwb_rc_evt_drp *evt)
721 return evt->reason & 0x0f;
725 /* DRP Availability Change notification. [WHCI] section 3.1.4.8. */
726 struct uwb_rc_evt_drp_avail {
727 struct uwb_rceb rceb;
728 DECLARE_BITMAP(bmp, UWB_NUM_MAS);
729 } __attribute__((packed));
731 /* BP switch status notification. [WHCI] section 3.1.4.10. */
732 struct uwb_rc_evt_bp_switch_status {
733 struct uwb_rceb rceb;
738 } __attribute__((packed));
740 /* Command Frame Received notification. [WHCI] section 3.1.4.11. */
741 struct uwb_rc_evt_cmd_frame_rcv {
742 struct uwb_rceb rceb;
744 struct uwb_dev_addr wSrcAddr;
745 struct uwb_dev_addr wDstAddr;
750 } __attribute__((packed));
752 /* Channel Change IE Received notification. [WHCI] section 3.1.4.12. */
753 struct uwb_rc_evt_channel_change_ie_rcv {
754 struct uwb_rceb rceb;
755 struct uwb_dev_addr wSrcAddr;
758 } __attribute__((packed));
760 /* DAA Energy Detected notification. [WHCI 0.96] section 3.1.4.14. */
761 struct uwb_rc_evt_daa_energy_detected {
762 struct uwb_rceb rceb;
767 } __attribute__((packed));
771 * Radio Control Interface Class Descriptor
775 struct uwb_rc_control_intf_class_desc {
778 __le16 bcdRCIVersion;
779 } __attribute__((packed));
781 #endif /* #ifndef __LINUX__UWB_SPEC_H__ */