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