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