1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
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
38
39
40
41
42
43
44
45
46enum { UWB_NUM_MAS = 256 };
47
48
49
50
51
52
53
54enum { UWB_NUM_ZONES = 16 };
55
56
57
58
59#define UWB_MAS_PER_ZONE (UWB_NUM_MAS / UWB_NUM_ZONES)
60
61
62
63
64#define UWB_USABLE_MAS_PER_ROW (UWB_NUM_ZONES - 1)
65
66
67
68
69
70
71enum { UWB_NUM_STREAMS = 8 };
72
73
74
75
76
77
78
79
80enum { UWB_MAS_LENGTH_US = 256 };
81
82
83
84
85
86
87
88
89enum { UWB_BEACON_SLOT_LENGTH_US = 85 };
90
91
92
93
94
95
96
97
98
99enum { UWB_MAX_LOST_BEACONS = 3 };
100
101
102
103
104
105
106
107
108
109enum { UWB_DRP_BACKOFF_WIN_MIN = 2 };
110
111
112
113
114
115
116
117
118
119enum { UWB_DRP_BACKOFF_WIN_MAX = 16 };
120
121
122
123
124#define UWB_SUPERFRAME_LENGTH_US (UWB_MAS_LENGTH_US * UWB_NUM_MAS)
125
126
127
128
129
130
131
132struct uwb_mac_addr {
133 u8 data[6];
134} __attribute__((packed));
135
136
137
138
139
140
141
142
143struct uwb_dev_addr {
144 u8 data[2];
145} __attribute__((packed));
146
147
148
149
150
151
152
153enum uwb_addr_type {
154 UWB_ADDR_DEV = 0,
155 UWB_ADDR_MAC = 1,
156};
157
158
159
160enum { UWB_ADDR_STRSIZE = 32 };
161
162
163
164enum uwb_prid {
165 UWB_PRID_WLP_RESERVED = 0x0000,
166 UWB_PRID_WLP = 0x0001,
167 UWB_PRID_WUSB_BOT = 0x0010,
168 UWB_PRID_WUSB = 0x0010,
169 UWB_PRID_WUSB_TOP = 0x001F,
170};
171
172
173
174enum uwb_phy_rate {
175 UWB_PHY_RATE_53 = 0,
176 UWB_PHY_RATE_80,
177 UWB_PHY_RATE_106,
178 UWB_PHY_RATE_160,
179 UWB_PHY_RATE_200,
180 UWB_PHY_RATE_320,
181 UWB_PHY_RATE_400,
182 UWB_PHY_RATE_480,
183 UWB_PHY_RATE_INVALID
184};
185
186
187
188
189
190enum uwb_scan_type {
191 UWB_SCAN_ONLY = 0,
192 UWB_SCAN_OUTSIDE_BP,
193 UWB_SCAN_WHILE_INACTIVE,
194 UWB_SCAN_DISABLED,
195 UWB_SCAN_ONLY_STARTTIME,
196 UWB_SCAN_TOP
197};
198
199
200
201enum uwb_ack_pol {
202 UWB_ACK_NO = 0,
203 UWB_ACK_INM = 1,
204 UWB_ACK_B = 2,
205 UWB_ACK_B_REQ = 3,
206};
207
208
209
210enum uwb_drp_type {
211 UWB_DRP_TYPE_ALIEN_BP = 0,
212 UWB_DRP_TYPE_HARD,
213 UWB_DRP_TYPE_SOFT,
214 UWB_DRP_TYPE_PRIVATE,
215 UWB_DRP_TYPE_PCA,
216};
217
218
219
220enum uwb_drp_reason {
221 UWB_DRP_REASON_ACCEPTED = 0,
222 UWB_DRP_REASON_CONFLICT,
223 UWB_DRP_REASON_PENDING,
224 UWB_DRP_REASON_DENIED,
225 UWB_DRP_REASON_MODIFIED,
226};
227
228
229enum uwb_relinquish_req_reason {
230 UWB_RELINQUISH_REQ_REASON_NON_SPECIFIC = 0,
231 UWB_RELINQUISH_REQ_REASON_OVER_ALLOCATION,
232};
233
234
235
236
237enum uwb_drp_notif_reason {
238 UWB_DRP_NOTIF_DRP_IE_RCVD = 0,
239 UWB_DRP_NOTIF_CONFLICT,
240 UWB_DRP_NOTIF_TERMINATE,
241};
242
243
244
245struct uwb_drp_alloc {
246 __le16 zone_bm;
247 __le16 mas_bm;
248} __attribute__((packed));
249
250
251
252struct uwb_mac_frame_hdr {
253 __le16 Frame_Control;
254 struct uwb_dev_addr DestAddr;
255 struct uwb_dev_addr SrcAddr;
256 __le16 Sequence_Control;
257 __le16 Access_Information;
258} __attribute__((packed));
259
260
261
262
263
264
265
266struct uwb_beacon_frame {
267 struct uwb_mac_frame_hdr hdr;
268 struct uwb_mac_addr Device_Identifier;
269 u8 Beacon_Slot_Number;
270 u8 Device_Control;
271 u8 IEData[];
272} __attribute__((packed));
273
274
275
276enum uwb_ie {
277 UWB_PCA_AVAILABILITY = 2,
278 UWB_IE_DRP_AVAILABILITY = 8,
279 UWB_IE_DRP = 9,
280 UWB_BP_SWITCH_IE = 11,
281 UWB_MAC_CAPABILITIES_IE = 12,
282 UWB_PHY_CAPABILITIES_IE = 13,
283 UWB_APP_SPEC_PROBE_IE = 15,
284 UWB_IDENTIFICATION_IE = 19,
285 UWB_MASTER_KEY_ID_IE = 20,
286 UWB_RELINQUISH_REQUEST_IE = 21,
287 UWB_IE_WLP = 250,
288 UWB_APP_SPEC_IE = 255,
289};
290
291
292
293
294
295struct uwb_ie_hdr {
296 u8 element_id;
297 u8 length;
298} __attribute__((packed));
299
300
301
302struct uwb_ie_drp {
303 struct uwb_ie_hdr hdr;
304 __le16 drp_control;
305 struct uwb_dev_addr dev_addr;
306 struct uwb_drp_alloc allocs[];
307} __attribute__((packed));
308
309static inline int uwb_ie_drp_type(struct uwb_ie_drp *ie)
310{
311 return (le16_to_cpu(ie->drp_control) >> 0) & 0x7;
312}
313
314static 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
319static 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
324static inline int uwb_ie_drp_status(struct uwb_ie_drp *ie)
325{
326 return (le16_to_cpu(ie->drp_control) >> 9) & 0x1;
327}
328
329static inline int uwb_ie_drp_owner(struct uwb_ie_drp *ie)
330{
331 return (le16_to_cpu(ie->drp_control) >> 10) & 0x1;
332}
333
334static inline int uwb_ie_drp_tiebreaker(struct uwb_ie_drp *ie)
335{
336 return (le16_to_cpu(ie->drp_control) >> 11) & 0x1;
337}
338
339static inline int uwb_ie_drp_unsafe(struct uwb_ie_drp *ie)
340{
341 return (le16_to_cpu(ie->drp_control) >> 12) & 0x1;
342}
343
344static inline void uwb_ie_drp_set_type(struct uwb_ie_drp *ie, enum uwb_drp_type type)
345{
346 u16 drp_control = le16_to_cpu(ie->drp_control);
347 drp_control = (drp_control & ~(0x7 << 0)) | (type << 0);
348 ie->drp_control = cpu_to_le16(drp_control);
349}
350
351static inline void uwb_ie_drp_set_stream_index(struct uwb_ie_drp *ie, int stream_index)
352{
353 u16 drp_control = le16_to_cpu(ie->drp_control);
354 drp_control = (drp_control & ~(0x7 << 3)) | (stream_index << 3);
355 ie->drp_control = cpu_to_le16(drp_control);
356}
357
358static inline void uwb_ie_drp_set_reason_code(struct uwb_ie_drp *ie,
359 enum uwb_drp_reason reason_code)
360{
361 u16 drp_control = le16_to_cpu(ie->drp_control);
362 drp_control = (ie->drp_control & ~(0x7 << 6)) | (reason_code << 6);
363 ie->drp_control = cpu_to_le16(drp_control);
364}
365
366static inline void uwb_ie_drp_set_status(struct uwb_ie_drp *ie, int status)
367{
368 u16 drp_control = le16_to_cpu(ie->drp_control);
369 drp_control = (drp_control & ~(0x1 << 9)) | (status << 9);
370 ie->drp_control = cpu_to_le16(drp_control);
371}
372
373static inline void uwb_ie_drp_set_owner(struct uwb_ie_drp *ie, int owner)
374{
375 u16 drp_control = le16_to_cpu(ie->drp_control);
376 drp_control = (drp_control & ~(0x1 << 10)) | (owner << 10);
377 ie->drp_control = cpu_to_le16(drp_control);
378}
379
380static inline void uwb_ie_drp_set_tiebreaker(struct uwb_ie_drp *ie, int tiebreaker)
381{
382 u16 drp_control = le16_to_cpu(ie->drp_control);
383 drp_control = (drp_control & ~(0x1 << 11)) | (tiebreaker << 11);
384 ie->drp_control = cpu_to_le16(drp_control);
385}
386
387static inline void uwb_ie_drp_set_unsafe(struct uwb_ie_drp *ie, int unsafe)
388{
389 u16 drp_control = le16_to_cpu(ie->drp_control);
390 drp_control = (drp_control & ~(0x1 << 12)) | (unsafe << 12);
391 ie->drp_control = cpu_to_le16(drp_control);
392}
393
394
395struct uwb_ie_drp_avail {
396 struct uwb_ie_hdr hdr;
397 DECLARE_BITMAP(bmp, UWB_NUM_MAS);
398} __attribute__((packed));
399
400
401struct uwb_relinquish_request_ie {
402 struct uwb_ie_hdr hdr;
403 __le16 relinquish_req_control;
404 struct uwb_dev_addr dev_addr;
405 struct uwb_drp_alloc allocs[];
406} __attribute__((packed));
407
408static 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
413static inline void uwb_ie_relinquish_req_set_reason_code(struct uwb_relinquish_request_ie *ie,
414 int reason_code)
415{
416 u16 ctrl = le16_to_cpu(ie->relinquish_req_control);
417 ctrl = (ctrl & ~(0xf << 0)) | (reason_code << 0);
418 ie->relinquish_req_control = cpu_to_le16(ctrl);
419}
420
421
422
423
424
425struct uwb_vendor_id {
426 u8 data[3];
427} __attribute__((packed));
428
429
430
431
432
433
434struct uwb_device_type_id {
435 u8 data[3];
436} __attribute__((packed));
437
438
439
440
441
442
443enum uwb_dev_info_type {
444 UWB_DEV_INFO_VENDOR_ID = 0,
445 UWB_DEV_INFO_VENDOR_TYPE,
446 UWB_DEV_INFO_NAME,
447};
448
449
450
451
452
453struct uwb_dev_info {
454 u8 type;
455 u8 length;
456 u8 data[];
457} __attribute__((packed));
458
459
460
461
462
463struct uwb_identification_ie {
464 struct uwb_ie_hdr hdr;
465 struct uwb_dev_info info[];
466} __attribute__((packed));
467
468
469
470
471
472
473
474
475
476struct uwb_rccb {
477 u8 bCommandType;
478 __le16 wCommand;
479 u8 bCommandContext;
480} __attribute__((packed));
481
482
483
484struct uwb_rceb {
485 u8 bEventType;
486 __le16 wEvent;
487 u8 bEventContext;
488} __attribute__((packed));
489
490
491enum {
492 UWB_RC_CET_GENERAL = 0,
493 UWB_RC_CET_EX_TYPE_1 = 1,
494};
495
496
497enum uwb_rc_cmd {
498 UWB_RC_CMD_CHANNEL_CHANGE = 16,
499 UWB_RC_CMD_DEV_ADDR_MGMT = 17,
500 UWB_RC_CMD_GET_IE = 18,
501 UWB_RC_CMD_RESET = 19,
502 UWB_RC_CMD_SCAN = 20,
503 UWB_RC_CMD_SET_BEACON_FILTER = 21,
504 UWB_RC_CMD_SET_DRP_IE = 22,
505 UWB_RC_CMD_SET_IE = 23,
506 UWB_RC_CMD_SET_NOTIFICATION_FILTER = 24,
507 UWB_RC_CMD_SET_TX_POWER = 25,
508 UWB_RC_CMD_SLEEP = 26,
509 UWB_RC_CMD_START_BEACON = 27,
510 UWB_RC_CMD_STOP_BEACON = 28,
511 UWB_RC_CMD_BP_MERGE = 29,
512 UWB_RC_CMD_SEND_COMMAND_FRAME = 30,
513 UWB_RC_CMD_SET_ASIE_NOTIF = 31,
514};
515
516
517enum uwb_rc_evt {
518 UWB_RC_EVT_IE_RCV = 0,
519 UWB_RC_EVT_BEACON = 1,
520 UWB_RC_EVT_BEACON_SIZE = 2,
521 UWB_RC_EVT_BPOIE_CHANGE = 3,
522 UWB_RC_EVT_BP_SLOT_CHANGE = 4,
523 UWB_RC_EVT_BP_SWITCH_IE_RCV = 5,
524 UWB_RC_EVT_DEV_ADDR_CONFLICT = 6,
525 UWB_RC_EVT_DRP_AVAIL = 7,
526 UWB_RC_EVT_DRP = 8,
527 UWB_RC_EVT_BP_SWITCH_STATUS = 9,
528 UWB_RC_EVT_CMD_FRAME_RCV = 10,
529 UWB_RC_EVT_CHANNEL_CHANGE_IE_RCV = 11,
530
531 UWB_RC_EVT_UNKNOWN_CMD_RCV = 65535,
532};
533
534enum uwb_rc_extended_type_1_cmd {
535 UWB_RC_SET_DAA_ENERGY_MASK = 32,
536 UWB_RC_SET_NOTIFICATION_FILTER_EX = 33,
537};
538
539enum uwb_rc_extended_type_1_evt {
540 UWB_RC_DAA_ENERGY_DETECTED = 0,
541};
542
543
544enum {
545 UWB_RC_RES_SUCCESS = 0,
546 UWB_RC_RES_FAIL,
547 UWB_RC_RES_FAIL_HARDWARE,
548 UWB_RC_RES_FAIL_NO_SLOTS,
549 UWB_RC_RES_FAIL_BEACON_TOO_LARGE,
550 UWB_RC_RES_FAIL_INVALID_PARAMETER,
551 UWB_RC_RES_FAIL_UNSUPPORTED_PWR_LEVEL,
552 UWB_RC_RES_FAIL_INVALID_IE_DATA,
553 UWB_RC_RES_FAIL_BEACON_SIZE_EXCEEDED,
554 UWB_RC_RES_FAIL_CANCELLED,
555 UWB_RC_RES_FAIL_INVALID_STATE,
556 UWB_RC_RES_FAIL_INVALID_SIZE,
557 UWB_RC_RES_FAIL_ACK_NOT_RECEIVED,
558 UWB_RC_RES_FAIL_NO_MORE_ASIE_NOTIF,
559 UWB_RC_RES_FAIL_TIME_OUT = 255,
560};
561
562
563struct uwb_rc_evt_confirm {
564 struct uwb_rceb rceb;
565 u8 bResultCode;
566} __attribute__((packed));
567
568
569struct uwb_rc_evt_dev_addr_mgmt {
570 struct uwb_rceb rceb;
571 u8 baAddr[6];
572 u8 bResultCode;
573} __attribute__((packed));
574
575
576
577struct uwb_rc_evt_get_ie {
578 struct uwb_rceb rceb;
579 __le16 wIELength;
580 u8 IEData[];
581} __attribute__((packed));
582
583
584struct uwb_rc_evt_set_drp_ie {
585 struct uwb_rceb rceb;
586 __le16 wRemainingSpace;
587 u8 bResultCode;
588} __attribute__((packed));
589
590
591struct uwb_rc_evt_set_ie {
592 struct uwb_rceb rceb;
593 __le16 RemainingSpace;
594 u8 bResultCode;
595} __attribute__((packed));
596
597
598struct uwb_rc_cmd_scan {
599 struct uwb_rccb rccb;
600 u8 bChannelNumber;
601 u8 bScanState;
602 __le16 wStartTime;
603} __attribute__((packed));
604
605
606struct uwb_rc_cmd_set_drp_ie {
607 struct uwb_rccb rccb;
608 __le16 wIELength;
609 struct uwb_ie_drp IEData[];
610} __attribute__((packed));
611
612
613struct uwb_rc_cmd_set_ie {
614 struct uwb_rccb rccb;
615 __le16 wIELength;
616 u8 IEData[];
617} __attribute__((packed));
618
619
620struct uwb_rc_evt_set_daa_energy_mask {
621 struct uwb_rceb rceb;
622 __le16 wLength;
623 u8 result;
624} __attribute__((packed));
625
626
627struct uwb_rc_evt_set_notification_filter_ex {
628 struct uwb_rceb rceb;
629 __le16 wLength;
630 u8 result;
631} __attribute__((packed));
632
633
634struct uwb_rc_evt_ie_rcv {
635 struct uwb_rceb rceb;
636 struct uwb_dev_addr SrcAddr;
637 __le16 wIELength;
638 u8 IEData[];
639} __attribute__((packed));
640
641
642enum uwb_rc_beacon_type {
643 UWB_RC_BEACON_TYPE_SCAN = 0,
644 UWB_RC_BEACON_TYPE_NEIGHBOR,
645 UWB_RC_BEACON_TYPE_OL_ALIEN,
646 UWB_RC_BEACON_TYPE_NOL_ALIEN,
647};
648
649
650struct uwb_rc_evt_beacon {
651 struct uwb_rceb rceb;
652 u8 bChannelNumber;
653 u8 bBeaconType;
654 __le16 wBPSTOffset;
655 u8 bLQI;
656 u8 bRSSI;
657 __le16 wBeaconInfoLength;
658 u8 BeaconInfo[];
659} __attribute__((packed));
660
661
662
663struct uwb_rc_evt_beacon_size {
664 struct uwb_rceb rceb;
665 __le16 wNewBeaconSize;
666} __attribute__((packed));
667
668
669
670struct uwb_rc_evt_bpoie_change {
671 struct uwb_rceb rceb;
672 __le16 wBPOIELength;
673 u8 BPOIE[];
674} __attribute__((packed));
675
676
677
678struct uwb_rc_evt_bp_slot_change {
679 struct uwb_rceb rceb;
680 u8 slot_info;
681} __attribute__((packed));
682
683static 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
689static 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
696struct uwb_rc_evt_bp_switch_ie_rcv {
697 struct uwb_rceb rceb;
698 struct uwb_dev_addr wSrcAddr;
699 __le16 wIELength;
700 u8 IEData[];
701} __attribute__((packed));
702
703
704struct uwb_rc_evt_dev_addr_conflict {
705 struct uwb_rceb rceb;
706} __attribute__((packed));
707
708
709struct uwb_rc_evt_drp {
710 struct uwb_rceb rceb;
711 struct uwb_dev_addr src_addr;
712 u8 reason;
713 u8 beacon_slot_number;
714 __le16 ie_length;
715 u8 ie_data[];
716} __attribute__((packed));
717
718static inline enum uwb_drp_notif_reason uwb_rc_evt_drp_reason(struct uwb_rc_evt_drp *evt)
719{
720 return evt->reason & 0x0f;
721}
722
723
724
725struct uwb_rc_evt_drp_avail {
726 struct uwb_rceb rceb;
727 DECLARE_BITMAP(bmp, UWB_NUM_MAS);
728} __attribute__((packed));
729
730
731struct uwb_rc_evt_bp_switch_status {
732 struct uwb_rceb rceb;
733 u8 status;
734 u8 slot_offset;
735 __le16 bpst_offset;
736 u8 move_countdown;
737} __attribute__((packed));
738
739
740struct uwb_rc_evt_cmd_frame_rcv {
741 struct uwb_rceb rceb;
742 __le16 receive_time;
743 struct uwb_dev_addr wSrcAddr;
744 struct uwb_dev_addr wDstAddr;
745 __le16 control;
746 __le16 reserved;
747 __le16 dataLength;
748 u8 data[];
749} __attribute__((packed));
750
751
752struct uwb_rc_evt_channel_change_ie_rcv {
753 struct uwb_rceb rceb;
754 struct uwb_dev_addr wSrcAddr;
755 __le16 wIELength;
756 u8 IEData[];
757} __attribute__((packed));
758
759
760struct uwb_rc_evt_daa_energy_detected {
761 struct uwb_rceb rceb;
762 __le16 wLength;
763 u8 bandID;
764 u8 reserved;
765 u8 toneBmp[16];
766} __attribute__((packed));
767
768
769
770
771
772
773
774struct uwb_rc_control_intf_class_desc {
775 u8 bLength;
776 u8 bDescriptorType;
777 __le16 bcdRCIVersion;
778} __attribute__((packed));
779
780#endif
781