Linux Kernel  3.7.1
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
spec.h
Go to the documentation of this file.
1 /*
2  * Ultra Wide Band
3  * UWB Standard definitions
4  *
5  * Copyright (C) 2005-2006 Intel Corporation
6  * Inaky Perez-Gonzalez <[email protected]>
7  *
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.
11  *
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.
16  *
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
20  * 02110-1301, USA.
21  *
22  *
23  * All these definitions are based on the ECMA-368 standard.
24  *
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).
28  */
29 
30 #ifndef __LINUX__UWB_SPEC_H__
31 #define __LINUX__UWB_SPEC_H__
32 
33 #include <linux/types.h>
34 #include <linux/bitmap.h>
35 
36 #define i1480_FW 0x00000303
37 /* #define i1480_FW 0x00000302 */
38 
46 enum { UWB_NUM_MAS = 256 };
47 
54 enum { UWB_NUM_ZONES = 16 };
55 
56 /*
57  * Number of MAS in a zone.
58  */
59 #define UWB_MAS_PER_ZONE (UWB_NUM_MAS / UWB_NUM_ZONES)
60 
61 /*
62  * Number of MAS required before a row can be considered available.
63  */
64 #define UWB_USABLE_MAS_PER_ROW (UWB_NUM_ZONES - 1)
65 
66 /*
67  * Number of streams per DRP reservation between a pair of devices.
68  *
69  * [ECMA-368] section 16.8.6.
70  */
71 enum { UWB_NUM_STREAMS = 8 };
72 
73 /*
74  * mMasLength
75  *
76  * The length of a MAS in microseconds.
77  *
78  * [ECMA-368] section 17.16.
79  */
80 enum { UWB_MAS_LENGTH_US = 256 };
81 
82 /*
83  * mBeaconSlotLength
84  *
85  * The length of the beacon slot in microseconds.
86  *
87  * [ECMA-368] section 17.16
88  */
90 
91 /*
92  * mMaxLostBeacons
93  *
94  * The number beacons missing in consecutive superframes before a
95  * device can be considered as unreachable.
96  *
97  * [ECMA-368] section 17.16
98  */
99 enum { UWB_MAX_LOST_BEACONS = 3 };
100 
101 /*
102  * mDRPBackOffWinMin
103  *
104  * The minimum number of superframes to wait before trying to reserve
105  * extra MAS.
106  *
107  * [ECMA-368] section 17.16
108  */
110 
111 /*
112  * mDRPBackOffWinMax
113  *
114  * The maximum number of superframes to wait before trying to reserve
115  * extra MAS.
116  *
117  * [ECMA-368] section 17.16
118  */
120 
121 /*
122  * Length of a superframe in microseconds.
123  */
124 #define UWB_SUPERFRAME_LENGTH_US (UWB_MAS_LENGTH_US * UWB_NUM_MAS)
125 
132 struct uwb_mac_addr {
133  u8 data[6];
134 } __attribute__((packed));
136 
143 struct uwb_dev_addr {
144  u8 data[2];
145 } __attribute__((packed));
146 
147 
156 };
157 
158 
160 enum { UWB_ADDR_STRSIZE = 32 };
161 
162 
164 enum uwb_prid {
166  UWB_PRID_WLP = 0x0001,
168  UWB_PRID_WUSB = 0x0010,
170 };
171 
172 
184 };
185 
186 
197 };
198 
199 
206 };
207 
208 
216 };
217 
218 
226 };
227 
232 };
233 
241 };
242 
243 
248 } __attribute__((packed));
258 } __attribute__((packed));
268  struct uwb_mac_addr Device_Identifier; /* may be a NULL EUI-48 */
272 } __attribute__((packed));
276 enum uwb_ie {
287  UWB_IE_WLP = 250, /* WiMedia Logical Link Control Protocol WLP 0.99 */
289 };
290 
291 
295 struct uwb_ie_hdr {
296  u8 element_id; /* enum uwb_ie */
298 } __attribute__((packed));
302 struct uwb_ie_drp {
303  struct uwb_ie_hdr hdr;
307 } __attribute__((packed));
308 
309 static inline int uwb_ie_drp_type(struct uwb_ie_drp *ie)
310 {
311  return (le16_to_cpu(ie->drp_control) >> 0) & 0x7;
312 }
313 
314 static inline int uwb_ie_drp_stream_index(struct uwb_ie_drp *ie)
315 {
316  return (le16_to_cpu(ie->drp_control) >> 3) & 0x7;
317 }
318 
319 static inline int uwb_ie_drp_reason_code(struct uwb_ie_drp *ie)
320 {
321  return (le16_to_cpu(ie->drp_control) >> 6) & 0x7;
322 }
323 
324 static inline int uwb_ie_drp_status(struct uwb_ie_drp *ie)
325 {
326  return (le16_to_cpu(ie->drp_control) >> 9) & 0x1;
327 }
328 
329 static inline int uwb_ie_drp_owner(struct uwb_ie_drp *ie)
330 {
331  return (le16_to_cpu(ie->drp_control) >> 10) & 0x1;
332 }
333 
334 static inline int uwb_ie_drp_tiebreaker(struct uwb_ie_drp *ie)
335 {
336  return (le16_to_cpu(ie->drp_control) >> 11) & 0x1;
337 }
338 
339 static inline int uwb_ie_drp_unsafe(struct uwb_ie_drp *ie)
340 {
341  return (le16_to_cpu(ie->drp_control) >> 12) & 0x1;
342 }
343 
344 static inline void uwb_ie_drp_set_type(struct uwb_ie_drp *ie, enum uwb_drp_type type)
345 {
347  drp_control = (drp_control & ~(0x7 << 0)) | (type << 0);
348  ie->drp_control = cpu_to_le16(drp_control);
349 }
350 
351 static inline void uwb_ie_drp_set_stream_index(struct uwb_ie_drp *ie, int stream_index)
352 {
354  drp_control = (drp_control & ~(0x7 << 3)) | (stream_index << 3);
355  ie->drp_control = cpu_to_le16(drp_control);
356 }
357 
358 static inline void uwb_ie_drp_set_reason_code(struct uwb_ie_drp *ie,
360 {
362  drp_control = (ie->drp_control & ~(0x7 << 6)) | (reason_code << 6);
363  ie->drp_control = cpu_to_le16(drp_control);
364 }
365 
366 static inline void uwb_ie_drp_set_status(struct uwb_ie_drp *ie, int status)
367 {
369  drp_control = (drp_control & ~(0x1 << 9)) | (status << 9);
370  ie->drp_control = cpu_to_le16(drp_control);
371 }
372 
373 static inline void uwb_ie_drp_set_owner(struct uwb_ie_drp *ie, int owner)
374 {
376  drp_control = (drp_control & ~(0x1 << 10)) | (owner << 10);
377  ie->drp_control = cpu_to_le16(drp_control);
378 }
379 
380 static inline void uwb_ie_drp_set_tiebreaker(struct uwb_ie_drp *ie, int tiebreaker)
381 {
383  drp_control = (drp_control & ~(0x1 << 11)) | (tiebreaker << 11);
384  ie->drp_control = cpu_to_le16(drp_control);
385 }
386 
387 static inline void uwb_ie_drp_set_unsafe(struct uwb_ie_drp *ie, int unsafe)
388 {
390  drp_control = (drp_control & ~(0x1 << 12)) | (unsafe << 12);
391  ie->drp_control = cpu_to_le16(drp_control);
392 }
393 
396  struct uwb_ie_hdr hdr;
398 } __attribute__((packed));
399 
400 /* Relinqish Request IE ([ECMA-368] section 16.8.19). */
402  struct uwb_ie_hdr hdr;
406 } __attribute__((packed));
407 
408 static inline int uwb_ie_relinquish_req_reason_code(struct uwb_relinquish_request_ie *ie)
409 {
410  return (le16_to_cpu(ie->relinquish_req_control) >> 0) & 0xf;
411 }
412 
413 static inline void uwb_ie_relinquish_req_set_reason_code(struct uwb_relinquish_request_ie *ie,
414  int reason_code)
415 {
417  ctrl = (ctrl & ~(0xf << 0)) | (reason_code << 0);
419 }
420 
426  u8 data[3];
427 } __attribute__((packed));
428 
435  u8 data[3];
436 } __attribute__((packed));
437 
438 
447 };
448 
453 struct uwb_dev_info {
454  u8 type; /* enum uwb_dev_info_type */
456  u8 data[];
457 } __attribute__((packed));
464  struct uwb_ie_hdr hdr;
465  struct uwb_dev_info info[];
466 } __attribute__((packed));
467 
468 /*
469  * UWB Radio Controller
470  *
471  * These definitions are common to the Radio Control layers as
472  * exported by the WUSB1.0 HWA and WHCI interfaces.
473  */
474 
476 struct uwb_rccb {
477  u8 bCommandType; /* enum hwa_cet */
478  __le16 wCommand; /* Command code */
479  u8 bCommandContext; /* Context ID */
480 } __attribute__((packed));
484 struct uwb_rceb {
485  u8 bEventType; /* enum hwa_cet */
486  __le16 wEvent; /* Event code */
487  u8 bEventContext; /* Context ID */
488 } __attribute__((packed));
491 enum {
492  UWB_RC_CET_GENERAL = 0, /* General Command/Event type */
493  UWB_RC_CET_EX_TYPE_1 = 1, /* Extended Type 1 Command/Event type */
494 };
495 
496 /* Commands to the radio controller */
499  UWB_RC_CMD_DEV_ADDR_MGMT = 17, /* Device Address Management */
500  UWB_RC_CMD_GET_IE = 18, /* GET Information Elements */
502  UWB_RC_CMD_SCAN = 20, /* Scan management */
504  UWB_RC_CMD_SET_DRP_IE = 22, /* Dynamic Reservation Protocol IEs */
505  UWB_RC_CMD_SET_IE = 23, /* Information Element management */
514 };
515 
516 /* Notifications from the radio controller */
530  /* Events (command responses) use the same code as the command */
532 };
533 
537 };
538 
541 };
542 
543 /* Radio Control Result Code. [WHCI] table 3-3. */
544 enum {
560 };
561 
562 /* Confirm event. [WHCI] section 3.1.3.1 etc. */
564  struct uwb_rceb rceb;
566 } __attribute__((packed));
568 /* Device Address Management event. [WHCI] section 3.1.3.2. */
570  struct uwb_rceb rceb;
571  u8 baAddr[6];
573 } __attribute__((packed));
574 
576 /* Get IE Event. [WHCI] section 3.1.3.3. */
578  struct uwb_rceb rceb;
581 } __attribute__((packed));
582 
583 /* Set DRP IE Event. [WHCI] section 3.1.3.7. */
585  struct uwb_rceb rceb;
588 } __attribute__((packed));
589 
590 /* Set IE Event. [WHCI] section 3.1.3.8. */
592  struct uwb_rceb rceb;
595 } __attribute__((packed));
596 
597 /* Scan command. [WHCI] 3.1.3.5. */
599  struct uwb_rccb rccb;
603 } __attribute__((packed));
605 /* Set DRP IE command. [WHCI] section 3.1.3.7. */
607  struct uwb_rccb rccb;
609  struct uwb_ie_drp IEData[];
610 } __attribute__((packed));
611 
612 /* Set IE command. [WHCI] section 3.1.3.8. */
614  struct uwb_rccb rccb;
617 } __attribute__((packed));
618 
619 /* Set DAA Energy Mask event. [WHCI 0.96] section 3.1.3.17. */
621  struct uwb_rceb rceb;
624 } __attribute__((packed));
625 
626 /* Set Notification Filter Extended event. [WHCI 0.96] section 3.1.3.18. */
628  struct uwb_rceb rceb;
631 } __attribute__((packed));
632 
633 /* IE Received notification. [WHCI] section 3.1.4.1. */
635  struct uwb_rceb rceb;
639 } __attribute__((packed));
640 
641 /* Type of the received beacon. [WHCI] section 3.1.4.2. */
647 };
648 
649 /* Beacon received notification. [WHCI] 3.1.4.2. */
651  struct uwb_rceb rceb;
659 } __attribute__((packed));
660 
661 
662 /* Beacon Size Change notification. [WHCI] section 3.1.4.3 */
664  struct uwb_rceb rceb;
666 } __attribute__((packed));
669 /* BPOIE Change notification. [WHCI] section 3.1.4.4. */
671  struct uwb_rceb rceb;
674 } __attribute__((packed));
675 
677 /* Beacon Slot Change notification. [WHCI] section 3.1.4.5. */
679  struct uwb_rceb rceb;
681 } __attribute__((packed));
682 
683 static inline int uwb_rc_evt_bp_slot_change_slot_num(
684  const struct uwb_rc_evt_bp_slot_change *evt)
685 {
686  return evt->slot_info & 0x7f;
687 }
688 
689 static inline int uwb_rc_evt_bp_slot_change_no_slot(
690  const struct uwb_rc_evt_bp_slot_change *evt)
691 {
692  return (evt->slot_info & 0x80) >> 7;
693 }
694 
695 /* BP Switch IE Received notification. [WHCI] section 3.1.4.6. */
697  struct uwb_rceb rceb;
701 } __attribute__((packed));
702 
703 /* DevAddr Conflict notification. [WHCI] section 3.1.4.7. */
705  struct uwb_rceb rceb;
706 } __attribute__((packed));
707 
708 /* DRP notification. [WHCI] section 3.1.4.9. */
710  struct uwb_rceb rceb;
716 } __attribute__((packed));
717 
718 static inline enum uwb_drp_notif_reason uwb_rc_evt_drp_reason(struct uwb_rc_evt_drp *evt)
719 {
720  return evt->reason & 0x0f;
721 }
723 
724 /* DRP Availability Change notification. [WHCI] section 3.1.4.8. */
726  struct uwb_rceb rceb;
728 } __attribute__((packed));
729 
730 /* BP switch status notification. [WHCI] section 3.1.4.10. */
732  struct uwb_rceb rceb;
737 } __attribute__((packed));
738 
739 /* Command Frame Received notification. [WHCI] section 3.1.4.11. */
741  struct uwb_rceb rceb;
748  u8 data[];
749 } __attribute__((packed));
750 
751 /* Channel Change IE Received notification. [WHCI] section 3.1.4.12. */
753  struct uwb_rceb rceb;
757 } __attribute__((packed));
758 
759 /* DAA Energy Detected notification. [WHCI 0.96] section 3.1.4.14. */
761  struct uwb_rceb rceb;
765  u8 toneBmp[16];
766 } __attribute__((packed));
767 
768 
778 } __attribute__((packed));
780 #endif /* #ifndef __LINUX__UWB_SPEC_H__ */