net: wifi: rockchip: update broadcom drivers for kernel4.4
[firefly-linux-kernel-4.4.55.git] / drivers / net / wireless / rockchip_wlan / rkwifi / bcmdhd / include / proto / bt_amp_hci.h
1 /*
2  * BT-AMP (BlueTooth Alternate Mac and Phy) HCI (Host/Controller Interface)
3  *
4  * Copyright (C) 1999-2016, Broadcom Corporation
5  * 
6  *      Unless you and Broadcom execute a separate written software license
7  * agreement governing use of this software, this software is licensed to you
8  * under the terms of the GNU General Public License version 2 (the "GPL"),
9  * available at http://www.broadcom.com/licenses/GPLv2.php, with the
10  * following added to such license:
11  * 
12  *      As a special exception, the copyright holders of this software give you
13  * permission to link this software with independent modules, and to copy and
14  * distribute the resulting executable under terms of your choice, provided that
15  * you also meet, for each linked independent module, the terms and conditions of
16  * the license of that module.  An independent module is a module which is not
17  * derived from this software.  The special exception does not apply to any
18  * modifications of the software.
19  * 
20  *      Notwithstanding the above, under no circumstances may you combine this
21  * software in any way with any other Broadcom software provided under a license
22  * other than the GPL, without Broadcom's express prior written consent.
23  *
24  *
25  * <<Broadcom-WL-IPTag/Open:>>
26  *
27  * $Id: bt_amp_hci.h 518342 2014-12-01 23:21:41Z $
28 */
29
30 #ifndef _bt_amp_hci_h
31 #define _bt_amp_hci_h
32
33 /* This marks the start of a packed structure section. */
34 #include <packed_section_start.h>
35
36
37 /* AMP HCI CMD packet format */
38 typedef BWL_PRE_PACKED_STRUCT struct amp_hci_cmd {
39         uint16 opcode;
40         uint8 plen;
41         uint8 parms[1];
42 } BWL_POST_PACKED_STRUCT amp_hci_cmd_t;
43
44 #define HCI_CMD_PREAMBLE_SIZE           OFFSETOF(amp_hci_cmd_t, parms)
45 #define HCI_CMD_DATA_SIZE               255
46
47 /* AMP HCI CMD opcode layout */
48 #define HCI_CMD_OPCODE(ogf, ocf)        ((((ogf) & 0x3F) << 10) | ((ocf) & 0x03FF))
49 #define HCI_CMD_OGF(opcode)             ((uint8)(((opcode) >> 10) & 0x3F))
50 #define HCI_CMD_OCF(opcode)             ((opcode) & 0x03FF)
51
52 /* AMP HCI command opcodes */
53 #define HCI_Read_Failed_Contact_Counter         HCI_CMD_OPCODE(0x05, 0x0001)
54 #define HCI_Reset_Failed_Contact_Counter        HCI_CMD_OPCODE(0x05, 0x0002)
55 #define HCI_Read_Link_Quality                   HCI_CMD_OPCODE(0x05, 0x0003)
56 #define HCI_Read_Local_AMP_Info                 HCI_CMD_OPCODE(0x05, 0x0009)
57 #define HCI_Read_Local_AMP_ASSOC                HCI_CMD_OPCODE(0x05, 0x000A)
58 #define HCI_Write_Remote_AMP_ASSOC              HCI_CMD_OPCODE(0x05, 0x000B)
59 #define HCI_Create_Physical_Link                HCI_CMD_OPCODE(0x01, 0x0035)
60 #define HCI_Accept_Physical_Link_Request        HCI_CMD_OPCODE(0x01, 0x0036)
61 #define HCI_Disconnect_Physical_Link            HCI_CMD_OPCODE(0x01, 0x0037)
62 #define HCI_Create_Logical_Link                 HCI_CMD_OPCODE(0x01, 0x0038)
63 #define HCI_Accept_Logical_Link                 HCI_CMD_OPCODE(0x01, 0x0039)
64 #define HCI_Disconnect_Logical_Link             HCI_CMD_OPCODE(0x01, 0x003A)
65 #define HCI_Logical_Link_Cancel                 HCI_CMD_OPCODE(0x01, 0x003B)
66 #define HCI_Flow_Spec_Modify                    HCI_CMD_OPCODE(0x01, 0x003C)
67 #define HCI_Write_Flow_Control_Mode             HCI_CMD_OPCODE(0x01, 0x0067)
68 #define HCI_Read_Best_Effort_Flush_Timeout      HCI_CMD_OPCODE(0x01, 0x0069)
69 #define HCI_Write_Best_Effort_Flush_Timeout     HCI_CMD_OPCODE(0x01, 0x006A)
70 #define HCI_Short_Range_Mode                    HCI_CMD_OPCODE(0x01, 0x006B)
71 #define HCI_Reset                               HCI_CMD_OPCODE(0x03, 0x0003)
72 #define HCI_Read_Connection_Accept_Timeout      HCI_CMD_OPCODE(0x03, 0x0015)
73 #define HCI_Write_Connection_Accept_Timeout     HCI_CMD_OPCODE(0x03, 0x0016)
74 #define HCI_Read_Link_Supervision_Timeout       HCI_CMD_OPCODE(0x03, 0x0036)
75 #define HCI_Write_Link_Supervision_Timeout      HCI_CMD_OPCODE(0x03, 0x0037)
76 #define HCI_Enhanced_Flush                      HCI_CMD_OPCODE(0x03, 0x005F)
77 #define HCI_Read_Logical_Link_Accept_Timeout    HCI_CMD_OPCODE(0x03, 0x0061)
78 #define HCI_Write_Logical_Link_Accept_Timeout   HCI_CMD_OPCODE(0x03, 0x0062)
79 #define HCI_Set_Event_Mask_Page_2               HCI_CMD_OPCODE(0x03, 0x0063)
80 #define HCI_Read_Location_Data_Command          HCI_CMD_OPCODE(0x03, 0x0064)
81 #define HCI_Write_Location_Data_Command         HCI_CMD_OPCODE(0x03, 0x0065)
82 #define HCI_Read_Local_Version_Info             HCI_CMD_OPCODE(0x04, 0x0001)
83 #define HCI_Read_Local_Supported_Commands       HCI_CMD_OPCODE(0x04, 0x0002)
84 #define HCI_Read_Buffer_Size                    HCI_CMD_OPCODE(0x04, 0x0005)
85 #define HCI_Read_Data_Block_Size                HCI_CMD_OPCODE(0x04, 0x000A)
86
87 /* AMP HCI command parameters */
88 typedef BWL_PRE_PACKED_STRUCT struct read_local_cmd_parms {
89         uint8 plh;
90         uint8 offset[2];                        /* length so far */
91         uint8 max_remote[2];
92 } BWL_POST_PACKED_STRUCT read_local_cmd_parms_t;
93
94 typedef BWL_PRE_PACKED_STRUCT struct write_remote_cmd_parms {
95         uint8 plh;
96         uint8 offset[2];
97         uint8 len[2];
98         uint8 frag[1];
99 } BWL_POST_PACKED_STRUCT write_remote_cmd_parms_t;
100
101 typedef BWL_PRE_PACKED_STRUCT struct phy_link_cmd_parms {
102         uint8 plh;
103         uint8 key_length;
104         uint8 key_type;
105         uint8 key[1];
106 } BWL_POST_PACKED_STRUCT phy_link_cmd_parms_t;
107
108 typedef BWL_PRE_PACKED_STRUCT struct dis_phy_link_cmd_parms {
109         uint8 plh;
110         uint8 reason;
111 } BWL_POST_PACKED_STRUCT dis_phy_link_cmd_parms_t;
112
113 typedef BWL_PRE_PACKED_STRUCT struct log_link_cmd_parms {
114         uint8 plh;
115         uint8 txflow[16];
116         uint8 rxflow[16];
117 } BWL_POST_PACKED_STRUCT log_link_cmd_parms_t;
118
119 typedef BWL_PRE_PACKED_STRUCT struct ext_flow_spec {
120         uint8 id;
121         uint8 service_type;
122         uint8 max_sdu[2];
123         uint8 sdu_ia_time[4];
124         uint8 access_latency[4];
125         uint8 flush_timeout[4];
126 } BWL_POST_PACKED_STRUCT ext_flow_spec_t;
127
128 typedef BWL_PRE_PACKED_STRUCT struct log_link_cancel_cmd_parms {
129         uint8 plh;
130         uint8 tx_fs_ID;
131 } BWL_POST_PACKED_STRUCT log_link_cancel_cmd_parms_t;
132
133 typedef BWL_PRE_PACKED_STRUCT struct flow_spec_mod_cmd_parms {
134         uint8 llh[2];
135         uint8 txflow[16];
136         uint8 rxflow[16];
137 } BWL_POST_PACKED_STRUCT flow_spec_mod_cmd_parms_t;
138
139 typedef BWL_PRE_PACKED_STRUCT struct plh_pad {
140         uint8 plh;
141         uint8 pad;
142 } BWL_POST_PACKED_STRUCT plh_pad_t;
143
144 typedef BWL_PRE_PACKED_STRUCT union hci_handle {
145         uint16 bredr;
146         plh_pad_t amp;
147 } BWL_POST_PACKED_STRUCT hci_handle_t;
148
149 typedef BWL_PRE_PACKED_STRUCT struct ls_to_cmd_parms {
150         hci_handle_t handle;
151         uint8 timeout[2];
152 } BWL_POST_PACKED_STRUCT ls_to_cmd_parms_t;
153
154 typedef BWL_PRE_PACKED_STRUCT struct befto_cmd_parms {
155         uint8 llh[2];
156         uint8 befto[4];
157 } BWL_POST_PACKED_STRUCT befto_cmd_parms_t;
158
159 typedef BWL_PRE_PACKED_STRUCT struct srm_cmd_parms {
160         uint8 plh;
161         uint8 srm;
162 } BWL_POST_PACKED_STRUCT srm_cmd_parms_t;
163
164 typedef BWL_PRE_PACKED_STRUCT struct ld_cmd_parms {
165         uint8 ld_aware;
166         uint8 ld[2];
167         uint8 ld_opts;
168         uint8 l_opts;
169 } BWL_POST_PACKED_STRUCT ld_cmd_parms_t;
170
171 typedef BWL_PRE_PACKED_STRUCT struct eflush_cmd_parms {
172         uint8 llh[2];
173         uint8 packet_type;
174 } BWL_POST_PACKED_STRUCT eflush_cmd_parms_t;
175
176 /* Generic AMP extended flow spec service types */
177 #define EFS_SVCTYPE_NO_TRAFFIC          0
178 #define EFS_SVCTYPE_BEST_EFFORT         1
179 #define EFS_SVCTYPE_GUARANTEED          2
180
181 /* AMP HCI event packet format */
182 typedef BWL_PRE_PACKED_STRUCT struct amp_hci_event {
183         uint8 ecode;
184         uint8 plen;
185         uint8 parms[1];
186 } BWL_POST_PACKED_STRUCT amp_hci_event_t;
187
188 #define HCI_EVT_PREAMBLE_SIZE                   OFFSETOF(amp_hci_event_t, parms)
189
190 /* AMP HCI event codes */
191 #define HCI_Command_Complete                    0x0E
192 #define HCI_Command_Status                      0x0F
193 #define HCI_Flush_Occurred                      0x11
194 #define HCI_Enhanced_Flush_Complete             0x39
195 #define HCI_Physical_Link_Complete              0x40
196 #define HCI_Channel_Select                      0x41
197 #define HCI_Disconnect_Physical_Link_Complete   0x42
198 #define HCI_Logical_Link_Complete               0x45
199 #define HCI_Disconnect_Logical_Link_Complete    0x46
200 #define HCI_Flow_Spec_Modify_Complete           0x47
201 #define HCI_Number_of_Completed_Data_Blocks     0x48
202 #define HCI_Short_Range_Mode_Change_Complete    0x4C
203 #define HCI_Status_Change_Event                 0x4D
204 #define HCI_Vendor_Specific                     0xFF
205
206 /* AMP HCI event mask bit positions */
207 #define HCI_Physical_Link_Complete_Event_Mask                   0x0001
208 #define HCI_Channel_Select_Event_Mask                           0x0002
209 #define HCI_Disconnect_Physical_Link_Complete_Event_Mask        0x0004
210 #define HCI_Logical_Link_Complete_Event_Mask                    0x0020
211 #define HCI_Disconnect_Logical_Link_Complete_Event_Mask         0x0040
212 #define HCI_Flow_Spec_Modify_Complete_Event_Mask                0x0080
213 #define HCI_Number_of_Completed_Data_Blocks_Event_Mask          0x0100
214 #define HCI_Short_Range_Mode_Change_Complete_Event_Mask         0x1000
215 #define HCI_Status_Change_Event_Mask                            0x2000
216 #define HCI_All_Event_Mask                                      0x31e7
217 /* AMP HCI event parameters */
218 typedef BWL_PRE_PACKED_STRUCT struct cmd_status_parms {
219         uint8 status;
220         uint8 cmdpkts;
221         uint16 opcode;
222 } BWL_POST_PACKED_STRUCT cmd_status_parms_t;
223
224 typedef BWL_PRE_PACKED_STRUCT struct cmd_complete_parms {
225         uint8 cmdpkts;
226         uint16 opcode;
227         uint8 parms[1];
228 } BWL_POST_PACKED_STRUCT cmd_complete_parms_t;
229
230 typedef BWL_PRE_PACKED_STRUCT struct flush_occurred_evt_parms {
231         uint16 handle;
232 } BWL_POST_PACKED_STRUCT flush_occurred_evt_parms_t;
233
234 typedef BWL_PRE_PACKED_STRUCT struct write_remote_evt_parms {
235         uint8 status;
236         uint8 plh;
237 } BWL_POST_PACKED_STRUCT write_remote_evt_parms_t;
238
239 typedef BWL_PRE_PACKED_STRUCT struct read_local_evt_parms {
240         uint8 status;
241         uint8 plh;
242         uint16 len;
243         uint8 frag[1];
244 } BWL_POST_PACKED_STRUCT read_local_evt_parms_t;
245
246 typedef BWL_PRE_PACKED_STRUCT struct read_local_info_evt_parms {
247         uint8 status;
248         uint8 AMP_status;
249         uint32 bandwidth;
250         uint32 gbandwidth;
251         uint32 latency;
252         uint32 PDU_size;
253         uint8 ctrl_type;
254         uint16 PAL_cap;
255         uint16 AMP_ASSOC_len;
256         uint32 max_flush_timeout;
257         uint32 be_flush_timeout;
258 } BWL_POST_PACKED_STRUCT read_local_info_evt_parms_t;
259
260 typedef BWL_PRE_PACKED_STRUCT struct log_link_evt_parms {
261         uint8 status;
262         uint16 llh;
263         uint8 plh;
264         uint8 tx_fs_ID;
265 } BWL_POST_PACKED_STRUCT log_link_evt_parms_t;
266
267 typedef BWL_PRE_PACKED_STRUCT struct disc_log_link_evt_parms {
268         uint8 status;
269         uint16 llh;
270         uint8 reason;
271 } BWL_POST_PACKED_STRUCT disc_log_link_evt_parms_t;
272
273 typedef BWL_PRE_PACKED_STRUCT struct log_link_cancel_evt_parms {
274         uint8 status;
275         uint8 plh;
276         uint8 tx_fs_ID;
277 } BWL_POST_PACKED_STRUCT log_link_cancel_evt_parms_t;
278
279 typedef BWL_PRE_PACKED_STRUCT struct flow_spec_mod_evt_parms {
280         uint8 status;
281         uint16 llh;
282 } BWL_POST_PACKED_STRUCT flow_spec_mod_evt_parms_t;
283
284 typedef BWL_PRE_PACKED_STRUCT struct phy_link_evt_parms {
285         uint8 status;
286         uint8 plh;
287 } BWL_POST_PACKED_STRUCT phy_link_evt_parms_t;
288
289 typedef BWL_PRE_PACKED_STRUCT struct dis_phy_link_evt_parms {
290         uint8 status;
291         uint8 plh;
292         uint8 reason;
293 } BWL_POST_PACKED_STRUCT dis_phy_link_evt_parms_t;
294
295 typedef BWL_PRE_PACKED_STRUCT struct read_ls_to_evt_parms {
296         uint8 status;
297         hci_handle_t handle;
298         uint16 timeout;
299 } BWL_POST_PACKED_STRUCT read_ls_to_evt_parms_t;
300
301 typedef BWL_PRE_PACKED_STRUCT struct read_lla_ca_to_evt_parms {
302         uint8 status;
303         uint16 timeout;
304 } BWL_POST_PACKED_STRUCT read_lla_ca_to_evt_parms_t;
305
306 typedef BWL_PRE_PACKED_STRUCT struct read_data_block_size_evt_parms {
307         uint8 status;
308         uint16 ACL_pkt_len;
309         uint16 data_block_len;
310         uint16 data_block_num;
311 } BWL_POST_PACKED_STRUCT read_data_block_size_evt_parms_t;
312
313 typedef BWL_PRE_PACKED_STRUCT struct data_blocks {
314         uint16 handle;
315         uint16 pkts;
316         uint16 blocks;
317 } BWL_POST_PACKED_STRUCT data_blocks_t;
318
319 typedef BWL_PRE_PACKED_STRUCT struct num_completed_data_blocks_evt_parms {
320         uint16 num_blocks;
321         uint8 num_handles;
322         data_blocks_t completed[1];
323 } BWL_POST_PACKED_STRUCT num_completed_data_blocks_evt_parms_t;
324
325 typedef BWL_PRE_PACKED_STRUCT struct befto_evt_parms {
326         uint8 status;
327         uint32 befto;
328 } BWL_POST_PACKED_STRUCT befto_evt_parms_t;
329
330 typedef BWL_PRE_PACKED_STRUCT struct srm_evt_parms {
331         uint8 status;
332         uint8 plh;
333         uint8 srm;
334 } BWL_POST_PACKED_STRUCT srm_evt_parms_t;
335
336 typedef BWL_PRE_PACKED_STRUCT struct contact_counter_evt_parms {
337         uint8 status;
338         uint8 llh[2];
339         uint16 counter;
340 } BWL_POST_PACKED_STRUCT contact_counter_evt_parms_t;
341
342 typedef BWL_PRE_PACKED_STRUCT struct contact_counter_reset_evt_parms {
343         uint8 status;
344         uint8 llh[2];
345 } BWL_POST_PACKED_STRUCT contact_counter_reset_evt_parms_t;
346
347 typedef BWL_PRE_PACKED_STRUCT struct read_linkq_evt_parms {
348         uint8 status;
349         hci_handle_t handle;
350         uint8 link_quality;
351 } BWL_POST_PACKED_STRUCT read_linkq_evt_parms_t;
352
353 typedef BWL_PRE_PACKED_STRUCT struct ld_evt_parms {
354         uint8 status;
355         uint8 ld_aware;
356         uint8 ld[2];
357         uint8 ld_opts;
358         uint8 l_opts;
359 } BWL_POST_PACKED_STRUCT ld_evt_parms_t;
360
361 typedef BWL_PRE_PACKED_STRUCT struct eflush_complete_evt_parms {
362         uint16 handle;
363 } BWL_POST_PACKED_STRUCT eflush_complete_evt_parms_t;
364
365 typedef BWL_PRE_PACKED_STRUCT struct vendor_specific_evt_parms {
366         uint8 len;
367         uint8 parms[1];
368 } BWL_POST_PACKED_STRUCT vendor_specific_evt_parms_t;
369
370 typedef BWL_PRE_PACKED_STRUCT struct local_version_info_evt_parms {
371         uint8 status;
372         uint8 hci_version;
373         uint16 hci_revision;
374         uint8 pal_version;
375         uint16 mfg_name;
376         uint16 pal_subversion;
377 } BWL_POST_PACKED_STRUCT local_version_info_evt_parms_t;
378
379 #define MAX_SUPPORTED_CMD_BYTE  64
380 typedef BWL_PRE_PACKED_STRUCT struct local_supported_cmd_evt_parms {
381         uint8 status;
382         uint8 cmd[MAX_SUPPORTED_CMD_BYTE];
383 } BWL_POST_PACKED_STRUCT local_supported_cmd_evt_parms_t;
384
385 typedef BWL_PRE_PACKED_STRUCT struct status_change_evt_parms {
386         uint8 status;
387         uint8 amp_status;
388 } BWL_POST_PACKED_STRUCT status_change_evt_parms_t;
389
390 /* AMP HCI error codes */
391 #define HCI_SUCCESS                             0x00
392 #define HCI_ERR_ILLEGAL_COMMAND                 0x01
393 #define HCI_ERR_NO_CONNECTION                   0x02
394 #define HCI_ERR_MEMORY_FULL                     0x07
395 #define HCI_ERR_CONNECTION_TIMEOUT              0x08
396 #define HCI_ERR_MAX_NUM_OF_CONNECTIONS          0x09
397 #define HCI_ERR_CONNECTION_EXISTS               0x0B
398 #define HCI_ERR_CONNECTION_DISALLOWED           0x0C
399 #define HCI_ERR_CONNECTION_ACCEPT_TIMEOUT       0x10
400 #define HCI_ERR_UNSUPPORTED_VALUE               0x11
401 #define HCI_ERR_ILLEGAL_PARAMETER_FMT           0x12
402 #define HCI_ERR_CONN_TERM_BY_LOCAL_HOST         0x16
403 #define HCI_ERR_UNSPECIFIED                     0x1F
404 #define HCI_ERR_UNIT_KEY_USED                   0x26
405 #define HCI_ERR_QOS_REJECTED                    0x2D
406 #define HCI_ERR_PARAM_OUT_OF_RANGE              0x30
407 #define HCI_ERR_NO_SUITABLE_CHANNEL             0x39
408 #define HCI_ERR_CHANNEL_MOVE                    0xFF
409
410 /* AMP HCI ACL Data packet format */
411 typedef BWL_PRE_PACKED_STRUCT struct amp_hci_ACL_data {
412         uint16  handle;                 /* 12-bit connection handle + 2-bit PB and 2-bit BC flags */
413         uint16  dlen;                   /* data total length */
414         uint8 data[1];
415 } BWL_POST_PACKED_STRUCT amp_hci_ACL_data_t;
416
417 #define HCI_ACL_DATA_PREAMBLE_SIZE      OFFSETOF(amp_hci_ACL_data_t, data)
418
419 #define HCI_ACL_DATA_BC_FLAGS           (0x0 << 14)
420 #define HCI_ACL_DATA_PB_FLAGS           (0x3 << 12)
421
422 #define HCI_ACL_DATA_HANDLE(handle)     ((handle) & 0x0fff)
423 #define HCI_ACL_DATA_FLAGS(handle)      ((handle) >> 12)
424
425 /* AMP Activity Report packet formats */
426 typedef BWL_PRE_PACKED_STRUCT struct amp_hci_activity_report {
427         uint8   ScheduleKnown;
428         uint8   NumReports;
429         uint8   data[1];
430 } BWL_POST_PACKED_STRUCT amp_hci_activity_report_t;
431
432 typedef BWL_PRE_PACKED_STRUCT struct amp_hci_activity_report_triple {
433         uint32  StartTime;
434         uint32  Duration;
435         uint32  Periodicity;
436 } BWL_POST_PACKED_STRUCT amp_hci_activity_report_triple_t;
437
438 #define HCI_AR_SCHEDULE_KNOWN           0x01
439
440
441 /* This marks the end of a packed structure section. */
442 #include <packed_section_end.h>
443
444 #endif /* _bt_amp_hci_h_ */