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