1 /* hci.h - Bluetooth Host Control Interface types */
2 
3 /*
4  * Copyright (c) 2015-2016 Intel Corporation
5  * Copyright (c) 2023 Nordic Semiconductor ASA
6  *
7  * SPDX-License-Identifier: Apache-2.0
8  */
9 #ifndef ZEPHYR_INCLUDE_BLUETOOTH_HCI_TYPES_H_
10 #define ZEPHYR_INCLUDE_BLUETOOTH_HCI_TYPES_H_
11 
12 #include <stdbool.h>
13 #include <stdint.h>
14 #include <string.h>
15 
16 #include <zephyr/toolchain.h>
17 #include <zephyr/types.h>
18 #include <zephyr/sys/util.h>
19 #include <zephyr/bluetooth/addr.h>
20 
21 #ifdef __cplusplus
22 extern "C" {
23 #endif
24 
25 /* Special own address types for LL privacy (used in adv & scan parameters) */
26 #define BT_HCI_OWN_ADDR_RPA_OR_PUBLIC  0x02
27 #define BT_HCI_OWN_ADDR_RPA_OR_RANDOM  0x03
28 #define BT_HCI_OWN_ADDR_RPA_MASK       0x02
29 
30 #define BT_HCI_PEER_ADDR_RPA_UNRESOLVED 0xfe
31 #define BT_HCI_PEER_ADDR_ANONYMOUS      0xff
32 
33 #define BT_ENC_KEY_SIZE_MIN                     0x07
34 #define BT_ENC_KEY_SIZE_MAX                     0x10
35 
36 #define BT_HCI_ADV_HANDLE_INVALID 0xff
37 #define BT_HCI_SYNC_HANDLE_INVALID 0xffff
38 #define BT_HCI_PAWR_SUBEVENT_MAX 128
39 
40 /* Bluetooth spec v5.4 Vol 4, Part E - 5.4.3 HCI Synchronous Data Packets */
41 struct bt_hci_sco_hdr {
42 	uint16_t handle; /* 12 bit handle, 2 bit Packet Status Flag, 1 bit RFU */
43 	uint8_t  len;
44 } __packed;
45 #define BT_HCI_SCO_HDR_SIZE             3
46 
47 /* Bluetooth spec v5.4 Vol 4, Part E - 5.4.4 HCI Event Packet */
48 struct bt_hci_evt_hdr {
49 	uint8_t  evt;
50 	uint8_t  len;
51 } __packed;
52 #define BT_HCI_EVT_HDR_SIZE             2
53 
54 #define BT_ACL_START_NO_FLUSH           0x00
55 #define BT_ACL_CONT                     0x01
56 #define BT_ACL_START                    0x02
57 #define BT_ACL_COMPLETE                 0x03
58 
59 #define BT_ACL_POINT_TO_POINT           0x00
60 #define BT_ACL_BROADCAST                0x01
61 
62 #define BT_ACL_HANDLE_MASK              BIT_MASK(12)
63 
64 #define bt_acl_handle(h)                ((h) & BT_ACL_HANDLE_MASK)
65 #define bt_acl_flags(h)                 ((h) >> 12)
66 #define bt_acl_flags_pb(f)              ((f) & BIT_MASK(2))
67 #define bt_acl_flags_bc(f)              ((f) >> 2)
68 #define bt_acl_handle_pack(h, f)        ((h) | ((f) << 12))
69 
70 /* Bluetooth spec v5.4 Vol 4, Part E - 5.4.2 ACL Data Packets */
71 struct bt_hci_acl_hdr {
72 	uint16_t handle;
73 	uint16_t len;
74 } __packed;
75 #define BT_HCI_ACL_HDR_SIZE             4
76 
77 #define BT_ISO_START                    0x00
78 #define BT_ISO_CONT                     0x01
79 #define BT_ISO_SINGLE                   0x02
80 #define BT_ISO_END                      0x03
81 
82 #define bt_iso_handle(h)                ((h) & 0x0fff)
83 #define bt_iso_flags(h)                 ((h) >> 12)
84 #define bt_iso_flags_pb(f)              ((f) & 0x0003)
85 #define bt_iso_flags_ts(f)              (((f) >> 2) & 0x0001)
86 #define bt_iso_pack_flags(pb, ts) \
87 	(((pb) & 0x0003) | (((ts) & 0x0001) << 2))
88 #define bt_iso_handle_pack(h, pb, ts) \
89 	((h) | (bt_iso_pack_flags(pb, ts) << 12))
90 #define bt_iso_hdr_len(h)                ((h) & BIT_MASK(14))
91 
92 #define BT_ISO_DATA_VALID                0x00
93 #define BT_ISO_DATA_INVALID              0x01
94 #define BT_ISO_DATA_NOP                  0x02
95 
96 #define bt_iso_pkt_len(h)                ((h) & BIT_MASK(12))
97 #define bt_iso_pkt_flags(h)              ((h) >> 14)
98 #define bt_iso_pkt_len_pack(h, f)        (((h) & BIT_MASK(12)) | ((f) << 14))
99 
100 struct bt_hci_iso_data_hdr {
101 	uint16_t sn;
102 	uint16_t slen; /* 12 bit len, 2 bit RFU, 2 bit packet status */
103 } __packed;
104 #define BT_HCI_ISO_DATA_HDR_SIZE	4
105 
106 struct bt_hci_iso_ts_data_hdr {
107 	uint32_t ts;
108 	struct bt_hci_iso_data_hdr data;
109 } __packed;
110 #define BT_HCI_ISO_TS_DATA_HDR_SIZE     8
111 
112 /* Bluetooth spec v5.4 Vol 4, Part E - 5.4.5 HCI ISO Data Packets */
113 struct bt_hci_iso_hdr {
114 	uint16_t handle; /* 12 bit handle, 2 bit PB flags, 1 bit TS_Flag, 1 bit RFU */
115 	uint16_t len; /* 14 bits, 2 bits RFU */
116 } __packed;
117 #define BT_HCI_ISO_HDR_SIZE             4
118 
119 /* Bluetooth spec v5.4 Vol 4, Part E - 5.4.1 HCI Command Packet */
120 struct bt_hci_cmd_hdr {
121 	uint16_t opcode;
122 	uint8_t  param_len;
123 } __packed;
124 #define BT_HCI_CMD_HDR_SIZE             3
125 
126 /* Supported Commands */
127 #define BT_CMD_TEST(cmd, octet, bit)            (cmd[octet] & BIT(bit))
128 #define BT_CMD_LE_STATES(cmd)                   BT_CMD_TEST(cmd, 28, 3)
129 
130 #define BT_FEAT_TEST(feat, page, octet, bit)    (feat[page][octet] & BIT(bit))
131 
132 #define BT_FEAT_BREDR(feat)                     !BT_FEAT_TEST(feat, 0, 4, 5)
133 #define BT_FEAT_LE(feat)                        BT_FEAT_TEST(feat, 0, 4, 6)
134 #define BT_FEAT_EXT_FEATURES(feat)              BT_FEAT_TEST(feat, 0, 7, 7)
135 #define BT_FEAT_HOST_SSP(feat)                  BT_FEAT_TEST(feat, 1, 0, 0)
136 #define BT_FEAT_SC(feat)                        BT_FEAT_TEST(feat, 2, 1, 0)
137 
138 #define BT_FEAT_LMP_SCO_CAPABLE(feat)           BT_FEAT_TEST(feat, 0, 1, 3)
139 #define BT_FEAT_LMP_ESCO_CAPABLE(feat)          BT_FEAT_TEST(feat, 0, 3, 7)
140 #define BT_FEAT_HV2_PKT(feat)                   BT_FEAT_TEST(feat, 0, 1, 4)
141 #define BT_FEAT_HV3_PKT(feat)                   BT_FEAT_TEST(feat, 0, 1, 5)
142 #define BT_FEAT_EV4_PKT(feat)                   BT_FEAT_TEST(feat, 0, 4, 0)
143 #define BT_FEAT_EV5_PKT(feat)                   BT_FEAT_TEST(feat, 0, 4, 1)
144 #define BT_FEAT_2EV3_PKT(feat)                  BT_FEAT_TEST(feat, 0, 5, 5)
145 #define BT_FEAT_3EV3_PKT(feat)                  BT_FEAT_TEST(feat, 0, 5, 6)
146 #define BT_FEAT_3SLOT_PKT(feat)                 BT_FEAT_TEST(feat, 0, 5, 7)
147 
148 /* LE features */
149 #define BT_LE_FEAT_BIT_ENC                      0
150 #define BT_LE_FEAT_BIT_CONN_PARAM_REQ           1
151 #define BT_LE_FEAT_BIT_EXT_REJ_IND              2
152 #define BT_LE_FEAT_BIT_PER_INIT_FEAT_XCHG       3
153 #define BT_LE_FEAT_BIT_PING                     4
154 #define BT_LE_FEAT_BIT_DLE                      5
155 #define BT_LE_FEAT_BIT_PRIVACY                  6
156 #define BT_LE_FEAT_BIT_EXT_SCAN                 7
157 #define BT_LE_FEAT_BIT_PHY_2M                   8
158 #define BT_LE_FEAT_BIT_SMI_TX                   9
159 #define BT_LE_FEAT_BIT_SMI_RX                   10
160 #define BT_LE_FEAT_BIT_PHY_CODED                11
161 #define BT_LE_FEAT_BIT_EXT_ADV                  12
162 #define BT_LE_FEAT_BIT_PER_ADV                  13
163 #define BT_LE_FEAT_BIT_CHAN_SEL_ALGO_2          14
164 #define BT_LE_FEAT_BIT_PWR_CLASS_1              15
165 #define BT_LE_FEAT_BIT_MIN_USED_CHAN_PROC       16
166 #define BT_LE_FEAT_BIT_CONN_CTE_REQ             17
167 #define BT_LE_FEAT_BIT_CONN_CTE_RESP            18
168 #define BT_LE_FEAT_BIT_CONNECTIONLESS_CTE_TX    19
169 #define BT_LE_FEAT_BIT_CONNECTIONLESS_CTE_RX    20
170 #define BT_LE_FEAT_BIT_ANT_SWITCH_TX_AOD        21
171 #define BT_LE_FEAT_BIT_ANT_SWITCH_RX_AOA        22
172 #define BT_LE_FEAT_BIT_RX_CTE                   23
173 #define BT_LE_FEAT_BIT_PAST_SEND                24
174 #define BT_LE_FEAT_BIT_PAST_RECV                25
175 #define BT_LE_FEAT_BIT_SCA_UPDATE               26
176 #define BT_LE_FEAT_BIT_REMOTE_PUB_KEY_VALIDATE  27
177 #define BT_LE_FEAT_BIT_CIS_CENTRAL              28
178 #define BT_LE_FEAT_BIT_CIS_PERIPHERAL           29
179 #define BT_LE_FEAT_BIT_ISO_BROADCASTER          30
180 #define BT_LE_FEAT_BIT_SYNC_RECEIVER            31
181 #define BT_LE_FEAT_BIT_ISO_CHANNELS             32
182 #define BT_LE_FEAT_BIT_PWR_CTRL_REQ             33
183 #define BT_LE_FEAT_BIT_PWR_CHG_IND              34
184 #define BT_LE_FEAT_BIT_PATH_LOSS_MONITOR        35
185 #define BT_LE_FEAT_BIT_PER_ADV_ADI_SUPP         36
186 #define BT_LE_FEAT_BIT_CONN_SUBRATING           37
187 #define BT_LE_FEAT_BIT_CONN_SUBRATING_HOST_SUPP 38
188 #define BT_LE_FEAT_BIT_CHANNEL_CLASSIFICATION   39
189 
190 #define BT_LE_FEAT_BIT_PAWR_ADVERTISER          43
191 #define BT_LE_FEAT_BIT_PAWR_SCANNER             44
192 
193 #define BT_LE_FEAT_TEST(feat, n)                (feat[(n) >> 3] & \
194 						 BIT((n) & 7))
195 
196 #define BT_FEAT_LE_ENCR(feat)                     BT_LE_FEAT_TEST(feat, \
197 						  BT_LE_FEAT_BIT_ENC)
198 #define BT_FEAT_LE_CONN_PARAM_REQ_PROC(feat)      BT_LE_FEAT_TEST(feat, \
199 						  BT_LE_FEAT_BIT_CONN_PARAM_REQ)
200 #define BT_FEAT_LE_PER_INIT_FEAT_XCHG(feat)       BT_LE_FEAT_TEST(feat, \
201 						  BT_LE_FEAT_BIT_PER_INIT_FEAT_XCHG)
202 #define BT_FEAT_LE_DLE(feat)                      BT_LE_FEAT_TEST(feat, \
203 						  BT_LE_FEAT_BIT_DLE)
204 #define BT_FEAT_LE_PHY_2M(feat)                   BT_LE_FEAT_TEST(feat, \
205 						  BT_LE_FEAT_BIT_PHY_2M)
206 #define BT_FEAT_LE_PHY_CODED(feat)                BT_LE_FEAT_TEST(feat, \
207 						  BT_LE_FEAT_BIT_PHY_CODED)
208 #define BT_FEAT_LE_PRIVACY(feat)                  BT_LE_FEAT_TEST(feat, \
209 						  BT_LE_FEAT_BIT_PRIVACY)
210 #define BT_FEAT_LE_EXT_ADV(feat)                  BT_LE_FEAT_TEST(feat, \
211 						  BT_LE_FEAT_BIT_EXT_ADV)
212 #define BT_FEAT_LE_EXT_PER_ADV(feat)              BT_LE_FEAT_TEST(feat, \
213 						  BT_LE_FEAT_BIT_PER_ADV)
214 #define BT_FEAT_LE_CONNECTION_CTE_REQ(feat)       BT_LE_FEAT_TEST(feat, \
215 						  BT_LE_FEAT_BIT_CONN_CTE_REQ)
216 #define BT_FEAT_LE_CONNECTION_CTE_RESP(feat)      BT_LE_FEAT_TEST(feat, \
217 						  BT_LE_FEAT_BIT_CONN_CTE_RESP)
218 #define BT_FEAT_LE_CONNECTIONLESS_CTE_TX(feat)    BT_LE_FEAT_TEST(feat, \
219 						  BT_LE_FEAT_BIT_CONNECTIONLESS_CTE_TX)
220 #define BT_FEAT_LE_CONNECTIONLESS_CTE_RX(feat)    BT_LE_FEAT_TEST(feat, \
221 						  BT_LE_FEAT_BIT_CONNECTIONLESS_CTE_RX)
222 #define BT_FEAT_LE_ANT_SWITCH_TX_AOD(feat)        BT_LE_FEAT_TEST(feat, \
223 						  BT_LE_FEAT_BIT_ANT_SWITCH_TX_AOD)
224 #define BT_FEAT_LE_ANT_SWITCH_RX_AOA(feat)        BT_LE_FEAT_TEST(feat, \
225 						  BT_LE_FEAT_BIT_ANT_SWITCH_RX_AOA)
226 #define BT_FEAT_LE_RX_CTE(feat)                   BT_LE_FEAT_TEST(feat, \
227 						  BT_LE_FEAT_BIT_RX_CTE)
228 #define BT_FEAT_LE_PAST_SEND(feat)                BT_LE_FEAT_TEST(feat, \
229 						  BT_LE_FEAT_BIT_PAST_SEND)
230 #define BT_FEAT_LE_PAST_RECV(feat)                BT_LE_FEAT_TEST(feat, \
231 						  BT_LE_FEAT_BIT_PAST_RECV)
232 #define BT_FEAT_LE_CIS_CENTRAL(feat)              BT_LE_FEAT_TEST(feat, \
233 						  BT_LE_FEAT_BIT_CIS_CENTRAL)
234 #define BT_FEAT_LE_CIS_PERIPHERAL(feat)           BT_LE_FEAT_TEST(feat, \
235 						  BT_LE_FEAT_BIT_CIS_PERIPHERAL)
236 #define BT_FEAT_LE_ISO_BROADCASTER(feat)          BT_LE_FEAT_TEST(feat, \
237 						  BT_LE_FEAT_BIT_ISO_BROADCASTER)
238 #define BT_FEAT_LE_SYNC_RECEIVER(feat)            BT_LE_FEAT_TEST(feat, \
239 						  BT_LE_FEAT_BIT_SYNC_RECEIVER)
240 #define BT_FEAT_LE_ISO_CHANNELS(feat)             BT_LE_FEAT_TEST(feat, \
241 						  BT_LE_FEAT_BIT_ISO_CHANNELS)
242 #define BT_FEAT_LE_PWR_CTRL_REQ(feat)             BT_LE_FEAT_TEST(feat, \
243 						  BT_LE_FEAT_BIT_PWR_CTRL_REQ)
244 #define BT_FEAT_LE_PWR_CHG_IND(feat)              BT_LE_FEAT_TEST(feat, \
245 						  BT_LE_FEAT_BIT_PWR_CHG_IND)
246 #define BT_FEAT_LE_PATH_LOSS_MONITOR(feat)        BT_LE_FEAT_TEST(feat, \
247 						  BT_LE_FEAT_BIT_PATH_LOSS_MONITOR)
248 #define BT_FEAT_LE_PER_ADV_ADI_SUPP(feat)         BT_LE_FEAT_TEST(feat, \
249 						  BT_LE_FEAT_BIT_PER_ADV_ADI_SUPP)
250 #define BT_FEAT_LE_CONN_SUBRATING(feat)           BT_LE_FEAT_TEST(feat, \
251 						  BT_LE_FEAT_BIT_CONN_SUBRATING)
252 #define BT_FEAT_LE_CONN_SUBRATING_HOST_SUPP(feat) BT_LE_FEAT_TEST(feat, \
253 						  BT_LE_FEAT_BIT_CONN_SUBRATING_HOST_SUPP)
254 #define BT_FEAT_LE_CHANNEL_CLASSIFICATION(feat)   BT_LE_FEAT_TEST(feat, \
255 						  BT_LE_FEAT_BIT_CHANNEL_CLASSIFICATION)
256 #define BT_FEAT_LE_PAWR_ADVERTISER(feat)	  BT_LE_FEAT_TEST(feat, \
257 						  BT_LE_FEAT_BIT_PAWR_ADVERTISER)
258 #define BT_FEAT_LE_PAWR_SCANNER(feat)             BT_LE_FEAT_TEST(feat, \
259 						  BT_LE_FEAT_BIT_PAWR_SCANNER)
260 
261 #define BT_FEAT_LE_CIS(feat)            (BT_FEAT_LE_CIS_CENTRAL(feat) | \
262 					BT_FEAT_LE_CIS_PERIPHERAL(feat))
263 #define BT_FEAT_LE_BIS(feat)            (BT_FEAT_LE_ISO_BROADCASTER(feat) | \
264 					BT_FEAT_LE_SYNC_RECEIVER(feat))
265 #define BT_FEAT_LE_ISO(feat)            (BT_FEAT_LE_CIS(feat) | \
266 					BT_FEAT_LE_BIS(feat))
267 
268 /* LE States */
269 #define BT_LE_STATES_PER_CONN_ADV(states)     (states & 0x0000004000000000)
270 
271 /* Bonding/authentication types */
272 #define BT_HCI_NO_BONDING                       0x00
273 #define BT_HCI_NO_BONDING_MITM                  0x01
274 #define BT_HCI_DEDICATED_BONDING                0x02
275 #define BT_HCI_DEDICATED_BONDING_MITM           0x03
276 #define BT_HCI_GENERAL_BONDING                  0x04
277 #define BT_HCI_GENERAL_BONDING_MITM             0x05
278 
279 /*
280  * MITM protection is enabled in SSP authentication requirements octet when
281  * LSB bit is set.
282  */
283 #define BT_MITM                                 0x01
284 
285 /* I/O capabilities */
286 #define BT_IO_DISPLAY_ONLY                      0x00
287 #define BT_IO_DISPLAY_YESNO                     0x01
288 #define BT_IO_KEYBOARD_ONLY                     0x02
289 #define BT_IO_NO_INPUT_OUTPUT                   0x03
290 
291 /* SCO packet types */
292 #define HCI_PKT_TYPE_HV1                        0x0020
293 #define HCI_PKT_TYPE_HV2                        0x0040
294 #define HCI_PKT_TYPE_HV3                        0x0080
295 
296 /* eSCO packet types */
297 #define HCI_PKT_TYPE_SCO_HV1                    0x0001
298 #define HCI_PKT_TYPE_SCO_HV2                    0x0002
299 #define HCI_PKT_TYPE_SCO_HV3                    0x0004
300 #define HCI_PKT_TYPE_ESCO_EV3                   0x0008
301 #define HCI_PKT_TYPE_ESCO_EV4                   0x0010
302 #define HCI_PKT_TYPE_ESCO_EV5                   0x0020
303 #define HCI_PKT_TYPE_ESCO_2EV3                  0x0040
304 #define HCI_PKT_TYPE_ESCO_3EV3                  0x0080
305 #define HCI_PKT_TYPE_ESCO_2EV5                  0x0100
306 #define HCI_PKT_TYPE_ESCO_3EV5                  0x0200
307 
308 
309 #define ESCO_PKT_MASK                           (HCI_PKT_TYPE_SCO_HV1 | \
310 						 HCI_PKT_TYPE_SCO_HV2 | \
311 						 HCI_PKT_TYPE_SCO_HV3 | \
312 						 HCI_PKT_TYPE_ESCO_EV3 | \
313 						 HCI_PKT_TYPE_ESCO_EV4 | \
314 						 HCI_PKT_TYPE_ESCO_EV5)
315 #define SCO_PKT_MASK                            (HCI_PKT_TYPE_SCO_HV1 | \
316 						 HCI_PKT_TYPE_SCO_HV2 | \
317 						 HCI_PKT_TYPE_SCO_HV3)
318 #define EDR_ESCO_PKT_MASK                       (HCI_PKT_TYPE_ESCO_2EV3 | \
319 						 HCI_PKT_TYPE_ESCO_3EV3 | \
320 						 HCI_PKT_TYPE_ESCO_2EV5 | \
321 						 HCI_PKT_TYPE_ESCO_3EV5)
322 
323 /* HCI BR/EDR link types */
324 #define BT_HCI_SCO                              0x00
325 #define BT_HCI_ACL                              0x01
326 #define BT_HCI_ESCO                             0x02
327 
328 /* OpCode Group Fields */
329 #define BT_OGF_LINK_CTRL                        0x01
330 #define BT_OGF_BASEBAND                         0x03
331 #define BT_OGF_INFO                             0x04
332 #define BT_OGF_STATUS                           0x05
333 #define BT_OGF_LE                               0x08
334 #define BT_OGF_VS                               0x3f
335 
336 /* Construct OpCode from OGF and OCF */
337 #define BT_OP(ogf, ocf)                         ((ocf) | ((ogf) << 10))
338 
339 /* Invalid opcode */
340 #define BT_OP_NOP				0x0000
341 
342 /* Obtain OGF from OpCode */
343 #define BT_OGF(opcode)                          (((opcode) >> 10) & BIT_MASK(6))
344 /* Obtain OCF from OpCode */
345 #define BT_OCF(opcode)                          ((opcode) & BIT_MASK(10))
346 
347 #define BT_HCI_OP_INQUIRY                       BT_OP(BT_OGF_LINK_CTRL, 0x0001) /* 0x0401 */
348 struct bt_hci_op_inquiry {
349 	uint8_t lap[3];
350 	uint8_t length;
351 	uint8_t num_rsp;
352 } __packed;
353 
354 #define BT_HCI_OP_INQUIRY_CANCEL                BT_OP(BT_OGF_LINK_CTRL, 0x0002) /* 0x0402 */
355 
356 #define BT_HCI_OP_CONNECT                       BT_OP(BT_OGF_LINK_CTRL, 0x0005) /* 0x0405 */
357 struct bt_hci_cp_connect {
358 	bt_addr_t bdaddr;
359 	uint16_t  packet_type;
360 	uint8_t   pscan_rep_mode;
361 	uint8_t   reserved;
362 	uint16_t  clock_offset;
363 	uint8_t   allow_role_switch;
364 } __packed;
365 
366 #define BT_HCI_OP_DISCONNECT                    BT_OP(BT_OGF_LINK_CTRL, 0x0006) /* 0x0406 */
367 struct bt_hci_cp_disconnect {
368 	uint16_t handle;
369 	uint8_t  reason;
370 } __packed;
371 
372 #define BT_HCI_OP_CONNECT_CANCEL                BT_OP(BT_OGF_LINK_CTRL, 0x0008) /* 0x0408 */
373 struct bt_hci_cp_connect_cancel {
374 	bt_addr_t bdaddr;
375 } __packed;
376 struct bt_hci_rp_connect_cancel {
377 	uint8_t   status;
378 	bt_addr_t bdaddr;
379 } __packed;
380 
381 #define BT_HCI_OP_ACCEPT_CONN_REQ               BT_OP(BT_OGF_LINK_CTRL, 0x0009) /* 0x0409 */
382 struct bt_hci_cp_accept_conn_req {
383 	bt_addr_t bdaddr;
384 	uint8_t   role;
385 } __packed;
386 
387 #define BT_HCI_OP_SETUP_SYNC_CONN               BT_OP(BT_OGF_LINK_CTRL, 0x0028) /* 0x0428 */
388 struct bt_hci_cp_setup_sync_conn {
389 	uint16_t  handle;
390 	uint32_t  tx_bandwidth;
391 	uint32_t  rx_bandwidth;
392 	uint16_t  max_latency;
393 	uint16_t  content_format;
394 	uint8_t   retrans_effort;
395 	uint16_t  pkt_type;
396 } __packed;
397 
398 #define BT_HCI_OP_ACCEPT_SYNC_CONN_REQ          BT_OP(BT_OGF_LINK_CTRL, 0x0029) /* 0x0429 */
399 struct bt_hci_cp_accept_sync_conn_req {
400 	bt_addr_t bdaddr;
401 	uint32_t  tx_bandwidth;
402 	uint32_t  rx_bandwidth;
403 	uint16_t  max_latency;
404 	uint16_t  content_format;
405 	uint8_t   retrans_effort;
406 	uint16_t  pkt_type;
407 } __packed;
408 
409 #define BT_HCI_OP_REJECT_CONN_REQ               BT_OP(BT_OGF_LINK_CTRL, 0x000a) /* 0x040a */
410 struct bt_hci_cp_reject_conn_req {
411 	bt_addr_t bdaddr;
412 	uint8_t   reason;
413 } __packed;
414 
415 #define BT_HCI_OP_LINK_KEY_REPLY                BT_OP(BT_OGF_LINK_CTRL, 0x000b) /* 0x040b */
416 struct bt_hci_cp_link_key_reply {
417 	bt_addr_t bdaddr;
418 	uint8_t   link_key[16];
419 } __packed;
420 
421 #define BT_HCI_OP_LINK_KEY_NEG_REPLY            BT_OP(BT_OGF_LINK_CTRL, 0x000c) /* 0x040c */
422 struct bt_hci_cp_link_key_neg_reply {
423 	bt_addr_t bdaddr;
424 } __packed;
425 
426 #define BT_HCI_OP_PIN_CODE_REPLY                BT_OP(BT_OGF_LINK_CTRL, 0x000d) /* 0x040d */
427 struct bt_hci_cp_pin_code_reply {
428 	bt_addr_t bdaddr;
429 	uint8_t   pin_len;
430 	uint8_t   pin_code[16];
431 } __packed;
432 struct bt_hci_rp_pin_code_reply {
433 	uint8_t      status;
434 	bt_addr_t bdaddr;
435 } __packed;
436 
437 #define BT_HCI_OP_PIN_CODE_NEG_REPLY            BT_OP(BT_OGF_LINK_CTRL, 0x000e) /* 0x040e */
438 struct bt_hci_cp_pin_code_neg_reply {
439 	bt_addr_t bdaddr;
440 } __packed;
441 struct bt_hci_rp_pin_code_neg_reply {
442 	uint8_t   status;
443 	bt_addr_t bdaddr;
444 } __packed;
445 
446 #define BT_HCI_OP_AUTH_REQUESTED                BT_OP(BT_OGF_LINK_CTRL, 0x0011) /* 0x0411 */
447 struct bt_hci_cp_auth_requested {
448 	uint16_t handle;
449 } __packed;
450 
451 #define BT_HCI_OP_SET_CONN_ENCRYPT              BT_OP(BT_OGF_LINK_CTRL, 0x0013) /* 0x0413 */
452 struct bt_hci_cp_set_conn_encrypt {
453 	uint16_t handle;
454 	uint8_t  encrypt;
455 } __packed;
456 
457 #define BT_HCI_OP_REMOTE_NAME_REQUEST           BT_OP(BT_OGF_LINK_CTRL, 0x0019) /* 0x0419 */
458 struct bt_hci_cp_remote_name_request {
459 	bt_addr_t bdaddr;
460 	uint8_t   pscan_rep_mode;
461 	uint8_t   reserved;
462 	uint16_t  clock_offset;
463 } __packed;
464 
465 #define BT_HCI_OP_REMOTE_NAME_CANCEL            BT_OP(BT_OGF_LINK_CTRL, 0x001a) /* 0x041a */
466 struct bt_hci_cp_remote_name_cancel {
467 	bt_addr_t bdaddr;
468 } __packed;
469 struct bt_hci_rp_remote_name_cancel {
470 	uint8_t   status;
471 	bt_addr_t bdaddr;
472 } __packed;
473 
474 #define BT_HCI_OP_READ_REMOTE_FEATURES          BT_OP(BT_OGF_LINK_CTRL, 0x001b) /* 0x041b */
475 struct bt_hci_cp_read_remote_features {
476 	uint16_t handle;
477 } __packed;
478 
479 #define BT_HCI_OP_READ_REMOTE_EXT_FEATURES      BT_OP(BT_OGF_LINK_CTRL, 0x001c) /* 0x041c */
480 struct bt_hci_cp_read_remote_ext_features {
481 	uint16_t handle;
482 	uint8_t  page;
483 } __packed;
484 
485 #define BT_HCI_OP_READ_REMOTE_VERSION_INFO      BT_OP(BT_OGF_LINK_CTRL, 0x001d) /* 0x041d */
486 struct bt_hci_cp_read_remote_version_info {
487 	uint16_t handle;
488 } __packed;
489 
490 #define BT_HCI_OP_IO_CAPABILITY_REPLY           BT_OP(BT_OGF_LINK_CTRL, 0x002b) /* 0x042b */
491 struct bt_hci_cp_io_capability_reply {
492 	bt_addr_t bdaddr;
493 	uint8_t   capability;
494 	uint8_t   oob_data;
495 	uint8_t   authentication;
496 } __packed;
497 
498 #define BT_HCI_OP_USER_CONFIRM_REPLY            BT_OP(BT_OGF_LINK_CTRL, 0x002c) /* 0x042c */
499 #define BT_HCI_OP_USER_CONFIRM_NEG_REPLY        BT_OP(BT_OGF_LINK_CTRL, 0x002d) /* 0x042d */
500 struct bt_hci_cp_user_confirm_reply {
501 	bt_addr_t bdaddr;
502 } __packed;
503 struct bt_hci_rp_user_confirm_reply {
504 	uint8_t   status;
505 	bt_addr_t bdaddr;
506 } __packed;
507 
508 #define BT_HCI_OP_USER_PASSKEY_REPLY            BT_OP(BT_OGF_LINK_CTRL, 0x002e) /* 0x042e */
509 struct bt_hci_cp_user_passkey_reply {
510 	bt_addr_t bdaddr;
511 	uint32_t  passkey;
512 } __packed;
513 
514 #define BT_HCI_OP_USER_PASSKEY_NEG_REPLY        BT_OP(BT_OGF_LINK_CTRL, 0x002f) /* 0x042f */
515 struct bt_hci_cp_user_passkey_neg_reply {
516 	bt_addr_t bdaddr;
517 } __packed;
518 
519 #define BT_HCI_OP_IO_CAPABILITY_NEG_REPLY       BT_OP(BT_OGF_LINK_CTRL, 0x0034) /* 0x0434 */
520 struct bt_hci_cp_io_capability_neg_reply {
521 	bt_addr_t bdaddr;
522 	uint8_t   reason;
523 } __packed;
524 
525 #define BT_HCI_OP_SET_EVENT_MASK                BT_OP(BT_OGF_BASEBAND, 0x0001) /* 0x0c01 */
526 struct bt_hci_cp_set_event_mask {
527 	uint8_t  events[8];
528 } __packed;
529 
530 #define BT_HCI_OP_RESET                         BT_OP(BT_OGF_BASEBAND, 0x0003) /* 0x0c03 */
531 
532 #define BT_HCI_OP_WRITE_LOCAL_NAME              BT_OP(BT_OGF_BASEBAND, 0x0013) /* 0x0c13 */
533 struct bt_hci_write_local_name {
534 	uint8_t local_name[248];
535 } __packed;
536 
537 #define BT_HCI_OP_READ_CONN_ACCEPT_TIMEOUT      BT_OP(BT_OGF_BASEBAND, 0x0015) /* 0x0c15 */
538 struct bt_hci_rp_read_conn_accept_timeout {
539 	uint8_t  status;
540 	uint16_t conn_accept_timeout;
541 } __packed;
542 
543 #define BT_HCI_OP_WRITE_CONN_ACCEPT_TIMEOUT     BT_OP(BT_OGF_BASEBAND, 0x0016) /* 0x0c16 */
544 struct bt_hci_cp_write_conn_accept_timeout {
545 	uint16_t conn_accept_timeout;
546 } __packed;
547 
548 struct bt_hci_rp_write_conn_accept_timeout {
549 	uint8_t  status;
550 } __packed;
551 
552 #define BT_HCI_OP_WRITE_PAGE_TIMEOUT            BT_OP(BT_OGF_BASEBAND, 0x0018) /* 0x0c18 */
553 
554 #define BT_HCI_OP_WRITE_SCAN_ENABLE             BT_OP(BT_OGF_BASEBAND, 0x001a) /* 0x0c1a */
555 #define BT_BREDR_SCAN_DISABLED                  0x00
556 #define BT_BREDR_SCAN_INQUIRY                   0x01
557 #define BT_BREDR_SCAN_PAGE                      0x02
558 
559 #define BT_HCI_OP_WRITE_CLASS_OF_DEVICE         BT_OP(BT_OGF_BASEBAND, 0x0024) /* 0x0c24 */
560 struct bt_hci_cp_write_class_of_device {
561 	uint8_t  class_of_device[3];
562 } __packed;
563 
564 #define BT_TX_POWER_LEVEL_CURRENT               0x00
565 #define BT_TX_POWER_LEVEL_MAX                   0x01
566 #define BT_HCI_OP_READ_TX_POWER_LEVEL           BT_OP(BT_OGF_BASEBAND, 0x002d) /* 0x0c2d */
567 struct bt_hci_cp_read_tx_power_level {
568 	uint16_t handle;
569 	uint8_t  type;
570 } __packed;
571 
572 struct bt_hci_rp_read_tx_power_level {
573 	uint8_t  status;
574 	uint16_t handle;
575 	int8_t   tx_power_level;
576 } __packed;
577 
578 #define BT_HCI_LE_TX_POWER_PHY_1M               0x01
579 #define BT_HCI_LE_TX_POWER_PHY_2M               0x02
580 #define BT_HCI_LE_TX_POWER_PHY_CODED_S8         0x03
581 #define BT_HCI_LE_TX_POWER_PHY_CODED_S2         0x04
582 #define BT_HCI_OP_LE_ENH_READ_TX_POWER_LEVEL    BT_OP(BT_OGF_LE, 0x0076) /* 0x2076 */
583 struct bt_hci_cp_le_read_tx_power_level {
584 	uint16_t handle;
585 	uint8_t  phy;
586 } __packed;
587 
588 struct bt_hci_rp_le_read_tx_power_level {
589 	uint8_t  status;
590 	uint16_t handle;
591 	uint8_t  phy;
592 	int8_t   current_tx_power_level;
593 	int8_t   max_tx_power_level;
594 } __packed;
595 
596 #define BT_HCI_OP_LE_READ_REMOTE_TX_POWER_LEVEL	BT_OP(BT_OGF_LE, 0x0077) /* 0x2077 */
597 
598 #define BT_HCI_LE_TX_POWER_REPORT_DISABLE       0x00
599 #define BT_HCI_LE_TX_POWER_REPORT_ENABLE        0x01
600 #define BT_HCI_OP_LE_SET_TX_POWER_REPORT_ENABLE BT_OP(BT_OGF_LE, 0x007A) /* 0x207A */
601 struct bt_hci_cp_le_set_tx_power_report_enable {
602 	uint16_t handle;
603 	uint8_t  local_enable;
604 	uint8_t  remote_enable;
605 } __packed;
606 
607 #define BT_HCI_CTL_TO_HOST_FLOW_DISABLE         0x00
608 #define BT_HCI_CTL_TO_HOST_FLOW_ENABLE          0x01
609 #define BT_HCI_OP_SET_CTL_TO_HOST_FLOW          BT_OP(BT_OGF_BASEBAND, 0x0031) /* 0x0c31 */
610 struct bt_hci_cp_set_ctl_to_host_flow {
611 	uint8_t  flow_enable;
612 } __packed;
613 
614 #define BT_HCI_OP_HOST_BUFFER_SIZE              BT_OP(BT_OGF_BASEBAND, 0x0033) /* 0x0c33 */
615 struct bt_hci_cp_host_buffer_size {
616 	uint16_t acl_mtu;
617 	uint8_t  sco_mtu;
618 	uint16_t acl_pkts;
619 	uint16_t sco_pkts;
620 } __packed;
621 
622 struct bt_hci_handle_count {
623 	uint16_t handle;
624 	uint16_t count;
625 } __packed;
626 
627 #define BT_HCI_OP_HOST_NUM_COMPLETED_PACKETS    BT_OP(BT_OGF_BASEBAND, 0x0035) /* 0x0c35 */
628 struct bt_hci_cp_host_num_completed_packets {
629 	uint8_t  num_handles;
630 	struct bt_hci_handle_count h[0];
631 } __packed;
632 
633 #define BT_HCI_OP_WRITE_INQUIRY_MODE            BT_OP(BT_OGF_BASEBAND, 0x0045) /* 0x0c45 */
634 struct bt_hci_cp_write_inquiry_mode {
635 	uint8_t  mode;
636 } __packed;
637 
638 #define BT_HCI_OP_WRITE_SSP_MODE                BT_OP(BT_OGF_BASEBAND, 0x0056) /* 0x0c56 */
639 struct bt_hci_cp_write_ssp_mode {
640 	uint8_t mode;
641 } __packed;
642 
643 #define BT_HCI_OP_SET_EVENT_MASK_PAGE_2         BT_OP(BT_OGF_BASEBAND, 0x0063) /* 0x0c63 */
644 struct bt_hci_cp_set_event_mask_page_2 {
645 	uint8_t  events_page_2[8];
646 } __packed;
647 
648 #define BT_HCI_OP_LE_WRITE_LE_HOST_SUPP         BT_OP(BT_OGF_BASEBAND, 0x006d) /* 0x0c6d */
649 struct bt_hci_cp_write_le_host_supp {
650 	uint8_t  le;
651 	uint8_t  simul;
652 } __packed;
653 
654 #define BT_HCI_OP_WRITE_SC_HOST_SUPP            BT_OP(BT_OGF_BASEBAND, 0x007a) /* 0x0c7a */
655 struct bt_hci_cp_write_sc_host_supp {
656 	uint8_t  sc_support;
657 } __packed;
658 
659 #define BT_HCI_OP_READ_AUTH_PAYLOAD_TIMEOUT     BT_OP(BT_OGF_BASEBAND, 0x007b) /* 0x0c7b */
660 struct bt_hci_cp_read_auth_payload_timeout {
661 	uint16_t handle;
662 } __packed;
663 
664 struct bt_hci_rp_read_auth_payload_timeout {
665 	uint8_t  status;
666 	uint16_t handle;
667 	uint16_t auth_payload_timeout;
668 } __packed;
669 
670 #define BT_HCI_OP_WRITE_AUTH_PAYLOAD_TIMEOUT    BT_OP(BT_OGF_BASEBAND, 0x007c) /* 0x0c7c */
671 struct bt_hci_cp_write_auth_payload_timeout {
672 	uint16_t handle;
673 	uint16_t auth_payload_timeout;
674 } __packed;
675 
676 struct bt_hci_rp_write_auth_payload_timeout {
677 	uint8_t  status;
678 	uint16_t handle;
679 } __packed;
680 
681 #define BT_HCI_OP_CONFIGURE_DATA_PATH           BT_OP(BT_OGF_BASEBAND, 0x0083) /* 0x0c83 */
682 struct bt_hci_cp_configure_data_path {
683 	uint8_t  data_path_dir;
684 	uint8_t  data_path_id;
685 	uint8_t  vs_config_len;
686 	uint8_t  vs_config[0];
687 } __packed;
688 
689 struct bt_hci_rp_configure_data_path {
690 	uint8_t  status;
691 } __packed;
692 
693 /* HCI version from Assigned Numbers */
694 #define BT_HCI_VERSION_1_0B                     0
695 #define BT_HCI_VERSION_1_1                      1
696 #define BT_HCI_VERSION_1_2                      2
697 #define BT_HCI_VERSION_2_0                      3
698 #define BT_HCI_VERSION_2_1                      4
699 #define BT_HCI_VERSION_3_0                      5
700 #define BT_HCI_VERSION_4_0                      6
701 #define BT_HCI_VERSION_4_1                      7
702 #define BT_HCI_VERSION_4_2                      8
703 #define BT_HCI_VERSION_5_0                      9
704 #define BT_HCI_VERSION_5_1                      10
705 #define BT_HCI_VERSION_5_2                      11
706 #define BT_HCI_VERSION_5_3                      12
707 #define BT_HCI_VERSION_5_4                      13
708 
709 #define BT_HCI_OP_READ_LOCAL_VERSION_INFO       BT_OP(BT_OGF_INFO, 0x0001) /* 0x1001 */
710 struct bt_hci_rp_read_local_version_info {
711 	uint8_t  status;
712 	uint8_t  hci_version;
713 	uint16_t hci_revision;
714 	uint8_t  lmp_version;
715 	uint16_t manufacturer;
716 	uint16_t lmp_subversion;
717 } __packed;
718 
719 #define BT_HCI_OP_READ_SUPPORTED_COMMANDS       BT_OP(BT_OGF_INFO, 0x0002) /* 0x1002 */
720 struct bt_hci_rp_read_supported_commands {
721 	uint8_t  status;
722 	uint8_t  commands[64];
723 } __packed;
724 
725 #define BT_HCI_OP_READ_LOCAL_EXT_FEATURES       BT_OP(BT_OGF_INFO, 0x0004) /* 0x1004 */
726 struct bt_hci_cp_read_local_ext_features {
727 	uint8_t page;
728 };
729 struct bt_hci_rp_read_local_ext_features {
730 	uint8_t  status;
731 	uint8_t  page;
732 	uint8_t  max_page;
733 	uint8_t  ext_features[8];
734 } __packed;
735 
736 #define BT_HCI_OP_READ_LOCAL_FEATURES           BT_OP(BT_OGF_INFO, 0x0003) /* 0x1003 */
737 struct bt_hci_rp_read_local_features {
738 	uint8_t  status;
739 	uint8_t  features[8];
740 } __packed;
741 
742 #define BT_HCI_OP_READ_BUFFER_SIZE              BT_OP(BT_OGF_INFO, 0x0005) /* 0x1005 */
743 struct bt_hci_rp_read_buffer_size {
744 	uint8_t  status;
745 	uint16_t acl_max_len;
746 	uint8_t  sco_max_len;
747 	uint16_t acl_max_num;
748 	uint16_t sco_max_num;
749 } __packed;
750 
751 #define BT_HCI_OP_READ_BD_ADDR                  BT_OP(BT_OGF_INFO, 0x0009) /* 0x1009 */
752 struct bt_hci_rp_read_bd_addr {
753 	uint8_t   status;
754 	bt_addr_t bdaddr;
755 } __packed;
756 
757 /* logic transport type bits as returned when reading supported codecs */
758 #define BT_HCI_CODEC_TRANSPORT_MASK_BREDR_ACL BIT(0)
759 #define BT_HCI_CODEC_TRANSPORT_MASK_BREDR_SCO BIT(1)
760 #define BT_HCI_CODEC_TRANSPORT_MASK_LE_CIS    BIT(2)
761 #define BT_HCI_CODEC_TRANSPORT_MASK_LE_BIS    BIT(3)
762 
763 /* logic transport types for reading codec capabilities and controller delays */
764 #define BT_HCI_LOGICAL_TRANSPORT_TYPE_BREDR_ACL 0x00
765 #define BT_HCI_LOGICAL_TRANSPORT_TYPE_BREDR_SCO 0x01
766 #define BT_HCI_LOGICAL_TRANSPORT_TYPE_LE_CIS    0x02
767 #define BT_HCI_LOGICAL_TRANSPORT_TYPE_LE_BIS    0x03
768 
769 /* audio datapath directions */
770 #define BT_HCI_DATAPATH_DIR_HOST_TO_CTLR 0x00
771 #define BT_HCI_DATAPATH_DIR_CTLR_TO_HOST 0x01
772 
773 /* audio datapath IDs */
774 #define BT_HCI_DATAPATH_ID_HCI      0x00
775 #define BT_HCI_DATAPATH_ID_VS       0x01
776 #define BT_HCI_DATAPATH_ID_VS_END   0xfe
777 
778 /* coding format assigned numbers, used for codec IDs */
779 #define BT_HCI_CODING_FORMAT_ULAW_LOG    0x00
780 #define BT_HCI_CODING_FORMAT_ALAW_LOG    0x01
781 #define BT_HCI_CODING_FORMAT_CVSD        0x02
782 #define BT_HCI_CODING_FORMAT_TRANSPARENT 0x03
783 #define BT_HCI_CODING_FORMAT_LINEAR_PCM  0x04
784 #define BT_HCI_CODING_FORMAT_MSBC        0x05
785 #define BT_HCI_CODING_FORMAT_LC3         0x06
786 #define BT_HCI_CODING_FORMAT_G729A       0x07
787 #define BT_HCI_CODING_FORMAT_VS          0xFF
788 
789 
790 #define BT_HCI_OP_READ_CODECS                   BT_OP(BT_OGF_INFO, 0x000b) /* 0x100b */
791 struct bt_hci_std_codec_info {
792 	uint8_t codec_id;
793 } __packed;
794 struct bt_hci_std_codecs {
795 	uint8_t num_codecs;
796 	struct bt_hci_std_codec_info codec_info[0];
797 } __packed;
798 struct bt_hci_vs_codec_info {
799 	uint16_t company_id;
800 	uint16_t codec_id;
801 } __packed;
802 struct bt_hci_vs_codecs {
803 	uint8_t num_codecs;
804 	struct bt_hci_vs_codec_info codec_info[0];
805 } __packed;
806 struct bt_hci_rp_read_codecs {
807 	uint8_t status;
808 	/* other fields filled in dynamically */
809 	uint8_t codecs[0];
810 } __packed;
811 
812 #define BT_HCI_OP_READ_CODECS_V2                BT_OP(BT_OGF_INFO, 0x000d) /* 0x100d */
813 struct bt_hci_std_codec_info_v2 {
814 	uint8_t codec_id;
815 	uint8_t transports; /* bitmap */
816 } __packed;
817 struct bt_hci_std_codecs_v2 {
818 	uint8_t num_codecs;
819 	struct bt_hci_std_codec_info_v2 codec_info[0];
820 } __packed;
821 struct bt_hci_vs_codec_info_v2 {
822 	uint16_t company_id;
823 	uint16_t codec_id;
824 	uint8_t transports; /* bitmap */
825 } __packed;
826 struct bt_hci_vs_codecs_v2 {
827 	uint8_t num_codecs;
828 	struct bt_hci_vs_codec_info_v2 codec_info[0];
829 } __packed;
830 struct bt_hci_rp_read_codecs_v2 {
831 	uint8_t status;
832 	/* other fields filled in dynamically */
833 	uint8_t codecs[0];
834 } __packed;
835 
836 struct bt_hci_cp_codec_id {
837 	uint8_t coding_format;
838 	uint16_t company_id;
839 	uint16_t vs_codec_id;
840 } __packed;
841 
842 #define BT_HCI_OP_READ_CODEC_CAPABILITIES       BT_OP(BT_OGF_INFO, 0x000e) /* 0x100e */
843 struct bt_hci_cp_read_codec_capabilities {
844 	struct bt_hci_cp_codec_id codec_id;
845 	uint8_t transport;
846 	uint8_t direction;
847 } __packed;
848 struct bt_hci_codec_capability_info {
849 	uint8_t length;
850 	uint8_t data[0];
851 } __packed;
852 struct bt_hci_rp_read_codec_capabilities {
853 	uint8_t status;
854 	uint8_t num_capabilities;
855 	/* other fields filled in dynamically */
856 	uint8_t capabilities[0];
857 } __packed;
858 
859 #define BT_HCI_OP_READ_CTLR_DELAY               BT_OP(BT_OGF_INFO, 0x000f) /* 0x100f */
860 struct bt_hci_cp_read_ctlr_delay {
861 	struct bt_hci_cp_codec_id codec_id;
862 	uint8_t transport;
863 	uint8_t direction;
864 	uint8_t codec_config_len;
865 	uint8_t codec_config[0];
866 } __packed;
867 struct bt_hci_rp_read_ctlr_delay {
868 	uint8_t status;
869 	uint8_t min_ctlr_delay[3];
870 	uint8_t max_ctlr_delay[3];
871 } __packed;
872 
873 #define BT_HCI_OP_READ_RSSI                     BT_OP(BT_OGF_STATUS, 0x0005) /* 0x1405 */
874 struct bt_hci_cp_read_rssi {
875 	uint16_t handle;
876 } __packed;
877 struct bt_hci_rp_read_rssi {
878 	uint8_t  status;
879 	uint16_t handle;
880 	int8_t   rssi;
881 } __packed;
882 
883 #define BT_HCI_ENCRYPTION_KEY_SIZE_MIN          7
884 #define BT_HCI_ENCRYPTION_KEY_SIZE_MAX          16
885 
886 #define BT_HCI_OP_READ_ENCRYPTION_KEY_SIZE      BT_OP(BT_OGF_STATUS, 0x0008) /* 0x1408 */
887 struct bt_hci_cp_read_encryption_key_size {
888 	uint16_t handle;
889 } __packed;
890 struct bt_hci_rp_read_encryption_key_size {
891 	uint8_t  status;
892 	uint16_t handle;
893 	uint8_t  key_size;
894 } __packed;
895 
896 /* BLE */
897 
898 #define BT_HCI_OP_LE_SET_EVENT_MASK             BT_OP(BT_OGF_LE, 0x0001) /* 0x2001 */
899 struct bt_hci_cp_le_set_event_mask {
900 	uint8_t events[8];
901 } __packed;
902 
903 #define BT_HCI_OP_LE_READ_BUFFER_SIZE           BT_OP(BT_OGF_LE, 0x0002) /* 0x2002 */
904 struct bt_hci_rp_le_read_buffer_size {
905 	uint8_t  status;
906 	uint16_t le_max_len;
907 	uint8_t  le_max_num;
908 } __packed;
909 
910 #define BT_HCI_OP_LE_READ_LOCAL_FEATURES        BT_OP(BT_OGF_LE, 0x0003) /* 0x2003 */
911 struct bt_hci_rp_le_read_local_features {
912 	uint8_t  status;
913 	uint8_t  features[8];
914 } __packed;
915 
916 #define BT_HCI_OP_LE_SET_RANDOM_ADDRESS         BT_OP(BT_OGF_LE, 0x0005) /* 0x2005 */
917 struct bt_hci_cp_le_set_random_address {
918 	bt_addr_t bdaddr;
919 } __packed;
920 
921 #define BT_HCI_ADV_IND                          0x00
922 #define BT_HCI_ADV_DIRECT_IND                   0x01
923 #define BT_HCI_ADV_SCAN_IND                     0x02
924 #define BT_HCI_ADV_NONCONN_IND                  0x03
925 #define BT_HCI_ADV_DIRECT_IND_LOW_DUTY          0x04
926 #define BT_HCI_ADV_SCAN_RSP                     0x04
927 
928 #define BT_LE_ADV_INTERVAL_MIN                  0x0020
929 #define BT_LE_ADV_INTERVAL_MAX                  0x4000
930 #define BT_LE_ADV_INTERVAL_DEFAULT              0x0800
931 
932 #define BT_LE_ADV_CHAN_MAP_CHAN_37              0x01
933 #define BT_LE_ADV_CHAN_MAP_CHAN_38              0x02
934 #define BT_LE_ADV_CHAN_MAP_CHAN_39              0x04
935 #define BT_LE_ADV_CHAN_MAP_ALL                  0x07
936 
937 #define BT_LE_ADV_FP_NO_FILTER                  0x00
938 #define BT_LE_ADV_FP_FILTER_SCAN_REQ            0x01
939 #define BT_LE_ADV_FP_FILTER_CONN_IND            0x02
940 #define BT_LE_ADV_FP_FILTER_BOTH                0x03
941 
942 #define BT_HCI_OP_LE_SET_ADV_PARAM              BT_OP(BT_OGF_LE, 0x0006) /* 0x2006 */
943 struct bt_hci_cp_le_set_adv_param {
944 	uint16_t     min_interval;
945 	uint16_t     max_interval;
946 	uint8_t      type;
947 	uint8_t      own_addr_type;
948 	bt_addr_le_t direct_addr;
949 	uint8_t      channel_map;
950 	uint8_t      filter_policy;
951 } __packed;
952 
953 #define BT_HCI_OP_LE_READ_ADV_CHAN_TX_POWER     BT_OP(BT_OGF_LE, 0x0007) /* 0x2007 */
954 struct bt_hci_rp_le_read_chan_tx_power {
955 	uint8_t status;
956 	int8_t  tx_power_level;
957 } __packed;
958 
959 #define BT_HCI_OP_LE_SET_ADV_DATA               BT_OP(BT_OGF_LE, 0x0008) /* 0x2008 */
960 struct bt_hci_cp_le_set_adv_data {
961 	uint8_t  len;
962 	uint8_t  data[31];
963 } __packed;
964 
965 #define BT_HCI_OP_LE_SET_SCAN_RSP_DATA          BT_OP(BT_OGF_LE, 0x0009) /* 0x2009 */
966 struct bt_hci_cp_le_set_scan_rsp_data {
967 	uint8_t  len;
968 	uint8_t  data[31];
969 } __packed;
970 
971 #define BT_HCI_LE_ADV_DISABLE                   0x00
972 #define BT_HCI_LE_ADV_ENABLE                    0x01
973 
974 #define BT_HCI_OP_LE_SET_ADV_ENABLE             BT_OP(BT_OGF_LE, 0x000a) /* 0x200a */
975 struct bt_hci_cp_le_set_adv_enable {
976 	uint8_t  enable;
977 } __packed;
978 
979 /* Scan types */
980 #define BT_HCI_OP_LE_SET_SCAN_PARAM             BT_OP(BT_OGF_LE, 0x000b) /* 0x200b */
981 #define BT_HCI_LE_SCAN_PASSIVE                  0x00
982 #define BT_HCI_LE_SCAN_ACTIVE                   0x01
983 
984 #define BT_HCI_LE_SCAN_FP_BASIC_NO_FILTER       0x00
985 #define BT_HCI_LE_SCAN_FP_BASIC_FILTER          0x01
986 #define BT_HCI_LE_SCAN_FP_EXT_NO_FILTER         0x02
987 #define BT_HCI_LE_SCAN_FP_EXT_FILTER            0x03
988 
989 struct bt_hci_cp_le_set_scan_param {
990 	uint8_t  scan_type;
991 	uint16_t interval;
992 	uint16_t window;
993 	uint8_t  addr_type;
994 	uint8_t  filter_policy;
995 } __packed;
996 
997 #define BT_HCI_OP_LE_SET_SCAN_ENABLE            BT_OP(BT_OGF_LE, 0x000c) /* 0x200c */
998 
999 #define BT_HCI_LE_SCAN_DISABLE                  0x00
1000 #define BT_HCI_LE_SCAN_ENABLE                   0x01
1001 
1002 #define BT_HCI_LE_SCAN_FILTER_DUP_DISABLE       0x00
1003 #define BT_HCI_LE_SCAN_FILTER_DUP_ENABLE        0x01
1004 
1005 struct bt_hci_cp_le_set_scan_enable {
1006 	uint8_t  enable;
1007 	uint8_t  filter_dup;
1008 } __packed;
1009 
1010 #define BT_HCI_OP_LE_CREATE_CONN                BT_OP(BT_OGF_LE, 0x000d) /* 0x200d */
1011 
1012 #define BT_HCI_LE_CREATE_CONN_FP_NO_FILTER      0x00
1013 #define BT_HCI_LE_CREATE_CONN_FP_FILTER         0x01
1014 
1015 struct bt_hci_cp_le_create_conn {
1016 	uint16_t     scan_interval;
1017 	uint16_t     scan_window;
1018 	uint8_t      filter_policy;
1019 	bt_addr_le_t peer_addr;
1020 	uint8_t      own_addr_type;
1021 	uint16_t     conn_interval_min;
1022 	uint16_t     conn_interval_max;
1023 	uint16_t     conn_latency;
1024 	uint16_t     supervision_timeout;
1025 	uint16_t     min_ce_len;
1026 	uint16_t     max_ce_len;
1027 } __packed;
1028 
1029 #define BT_HCI_OP_LE_CREATE_CONN_CANCEL         BT_OP(BT_OGF_LE, 0x000e) /* 0x200e */
1030 
1031 #define BT_HCI_OP_LE_READ_FAL_SIZE               BT_OP(BT_OGF_LE, 0x000f) /* 0x200f */
1032 struct bt_hci_rp_le_read_fal_size {
1033 	uint8_t  status;
1034 	uint8_t  fal_size;
1035 } __packed;
1036 
1037 #define BT_HCI_OP_LE_CLEAR_FAL                   BT_OP(BT_OGF_LE, 0x0010) /* 0x2010 */
1038 
1039 #define BT_HCI_OP_LE_ADD_DEV_TO_FAL              BT_OP(BT_OGF_LE, 0x0011) /* 0x2011 */
1040 struct bt_hci_cp_le_add_dev_to_fal {
1041 	bt_addr_le_t  addr;
1042 } __packed;
1043 
1044 #define BT_HCI_OP_LE_REM_DEV_FROM_FAL            BT_OP(BT_OGF_LE, 0x0012) /* 0x2012 */
1045 struct bt_hci_cp_le_rem_dev_from_fal {
1046 	bt_addr_le_t  addr;
1047 } __packed;
1048 
1049 #define BT_HCI_OP_LE_CONN_UPDATE                BT_OP(BT_OGF_LE, 0x0013) /* 0x2013 */
1050 struct hci_cp_le_conn_update {
1051 	uint16_t handle;
1052 	uint16_t conn_interval_min;
1053 	uint16_t conn_interval_max;
1054 	uint16_t conn_latency;
1055 	uint16_t supervision_timeout;
1056 	uint16_t min_ce_len;
1057 	uint16_t max_ce_len;
1058 } __packed;
1059 
1060 #define BT_HCI_OP_LE_SET_HOST_CHAN_CLASSIF      BT_OP(BT_OGF_LE, 0x0014) /* 0x2014 */
1061 struct bt_hci_cp_le_set_host_chan_classif {
1062 	uint8_t  ch_map[5];
1063 } __packed;
1064 
1065 #define BT_HCI_OP_LE_READ_CHAN_MAP              BT_OP(BT_OGF_LE, 0x0015) /* 0x2015 */
1066 struct bt_hci_cp_le_read_chan_map {
1067 	uint16_t handle;
1068 } __packed;
1069 struct bt_hci_rp_le_read_chan_map {
1070 	uint8_t  status;
1071 	uint16_t handle;
1072 	uint8_t  ch_map[5];
1073 } __packed;
1074 
1075 #define BT_HCI_OP_LE_READ_REMOTE_FEATURES       BT_OP(BT_OGF_LE, 0x0016) /* 0x2016 */
1076 struct bt_hci_cp_le_read_remote_features {
1077 	uint16_t  handle;
1078 } __packed;
1079 
1080 #define BT_HCI_OP_LE_ENCRYPT                    BT_OP(BT_OGF_LE, 0x0017) /* 0x2017 */
1081 struct bt_hci_cp_le_encrypt {
1082 	uint8_t  key[16];
1083 	uint8_t  plaintext[16];
1084 } __packed;
1085 struct bt_hci_rp_le_encrypt {
1086 	uint8_t  status;
1087 	uint8_t  enc_data[16];
1088 } __packed;
1089 
1090 #define BT_HCI_OP_LE_RAND                       BT_OP(BT_OGF_LE, 0x0018) /* 0x2018 */
1091 struct bt_hci_rp_le_rand {
1092 	uint8_t  status;
1093 	uint8_t  rand[8];
1094 } __packed;
1095 
1096 #define BT_HCI_OP_LE_START_ENCRYPTION           BT_OP(BT_OGF_LE, 0x0019) /* 0x2019 */
1097 struct bt_hci_cp_le_start_encryption {
1098 	uint16_t handle;
1099 	uint64_t rand;
1100 	uint16_t ediv;
1101 	uint8_t  ltk[16];
1102 } __packed;
1103 
1104 #define BT_HCI_OP_LE_LTK_REQ_REPLY              BT_OP(BT_OGF_LE, 0x001a) /* 0x201a */
1105 struct bt_hci_cp_le_ltk_req_reply {
1106 	uint16_t handle;
1107 	uint8_t  ltk[16];
1108 } __packed;
1109 struct bt_hci_rp_le_ltk_req_reply {
1110 	uint8_t  status;
1111 	uint16_t handle;
1112 } __packed;
1113 
1114 #define BT_HCI_OP_LE_LTK_REQ_NEG_REPLY          BT_OP(BT_OGF_LE, 0x001b) /* 0x201b */
1115 struct bt_hci_cp_le_ltk_req_neg_reply {
1116 	uint16_t handle;
1117 } __packed;
1118 struct bt_hci_rp_le_ltk_req_neg_reply {
1119 	uint8_t  status;
1120 	uint16_t handle;
1121 } __packed;
1122 
1123 #define BT_HCI_OP_LE_READ_SUPP_STATES           BT_OP(BT_OGF_LE, 0x001c) /* 0x201c */
1124 struct bt_hci_rp_le_read_supp_states {
1125 	uint8_t  status;
1126 	uint8_t  le_states[8];
1127 } __packed;
1128 
1129 #define BT_HCI_OP_LE_RX_TEST                    BT_OP(BT_OGF_LE, 0x001d) /* 0x201d */
1130 struct bt_hci_cp_le_rx_test {
1131 	uint8_t  rx_ch;
1132 } __packed;
1133 
1134 #define BT_HCI_TEST_PKT_PAYLOAD_PRBS9           0x00
1135 #define BT_HCI_TEST_PKT_PAYLOAD_11110000        0x01
1136 #define BT_HCI_TEST_PKT_PAYLOAD_10101010        0x02
1137 #define BT_HCI_TEST_PKT_PAYLOAD_PRBS15          0x03
1138 #define BT_HCI_TEST_PKT_PAYLOAD_11111111        0x04
1139 #define BT_HCI_TEST_PKT_PAYLOAD_00000000        0x05
1140 #define BT_HCI_TEST_PKT_PAYLOAD_00001111        0x06
1141 #define BT_HCI_TEST_PKT_PAYLOAD_01010101        0x07
1142 
1143 #define BT_HCI_OP_LE_TX_TEST                    BT_OP(BT_OGF_LE, 0x001e) /* 0x201e */
1144 struct bt_hci_cp_le_tx_test {
1145 	uint8_t  tx_ch;
1146 	uint8_t  test_data_len;
1147 	uint8_t  pkt_payload;
1148 } __packed;
1149 
1150 #define BT_HCI_OP_LE_TEST_END                   BT_OP(BT_OGF_LE, 0x001f) /* 0x201f */
1151 struct bt_hci_rp_le_test_end {
1152 	uint8_t  status;
1153 	uint16_t rx_pkt_count;
1154 } __packed;
1155 
1156 #define BT_HCI_OP_LE_CONN_PARAM_REQ_REPLY       BT_OP(BT_OGF_LE, 0x0020) /* 0x2020 */
1157 struct bt_hci_cp_le_conn_param_req_reply {
1158 	uint16_t handle;
1159 	uint16_t interval_min;
1160 	uint16_t interval_max;
1161 	uint16_t latency;
1162 	uint16_t timeout;
1163 	uint16_t min_ce_len;
1164 	uint16_t max_ce_len;
1165 } __packed;
1166 struct bt_hci_rp_le_conn_param_req_reply {
1167 	uint8_t  status;
1168 	uint16_t handle;
1169 } __packed;
1170 
1171 #define BT_HCI_OP_LE_CONN_PARAM_REQ_NEG_REPLY   BT_OP(BT_OGF_LE, 0x0021) /* 0x2021 */
1172 struct bt_hci_cp_le_conn_param_req_neg_reply {
1173 	uint16_t handle;
1174 	uint8_t  reason;
1175 } __packed;
1176 struct bt_hci_rp_le_conn_param_req_neg_reply {
1177 	uint8_t  status;
1178 	uint16_t handle;
1179 } __packed;
1180 
1181 #define BT_HCI_OP_LE_SET_DATA_LEN               BT_OP(BT_OGF_LE, 0x0022) /* 0x2022 */
1182 struct bt_hci_cp_le_set_data_len {
1183 	uint16_t handle;
1184 	uint16_t tx_octets;
1185 	uint16_t tx_time;
1186 } __packed;
1187 struct bt_hci_rp_le_set_data_len {
1188 	uint8_t  status;
1189 	uint16_t handle;
1190 } __packed;
1191 
1192 #define BT_HCI_OP_LE_READ_DEFAULT_DATA_LEN      BT_OP(BT_OGF_LE, 0x0023) /* 0x2023 */
1193 struct bt_hci_rp_le_read_default_data_len {
1194 	uint8_t  status;
1195 	uint16_t max_tx_octets;
1196 	uint16_t max_tx_time;
1197 } __packed;
1198 
1199 #define BT_HCI_OP_LE_WRITE_DEFAULT_DATA_LEN     BT_OP(BT_OGF_LE, 0x0024) /* 0x2024 */
1200 struct bt_hci_cp_le_write_default_data_len {
1201 	uint16_t max_tx_octets;
1202 	uint16_t max_tx_time;
1203 } __packed;
1204 
1205 #define BT_HCI_OP_LE_P256_PUBLIC_KEY            BT_OP(BT_OGF_LE, 0x0025) /* 0x2025 */
1206 
1207 #define BT_HCI_OP_LE_GENERATE_DHKEY             BT_OP(BT_OGF_LE, 0x0026) /* 0x2026 */
1208 struct bt_hci_cp_le_generate_dhkey {
1209 	uint8_t key[64];
1210 } __packed;
1211 
1212 
1213 #define BT_HCI_OP_LE_GENERATE_DHKEY_V2          BT_OP(BT_OGF_LE, 0x005e) /* 0x205e */
1214 
1215 #define BT_HCI_LE_KEY_TYPE_GENERATED            0x00
1216 #define BT_HCI_LE_KEY_TYPE_DEBUG                0x01
1217 
1218 struct bt_hci_cp_le_generate_dhkey_v2 {
1219 	uint8_t key[64];
1220 	uint8_t key_type;
1221 } __packed;
1222 
1223 
1224 #define BT_HCI_OP_LE_ADD_DEV_TO_RL              BT_OP(BT_OGF_LE, 0x0027) /* 0x2027 */
1225 struct bt_hci_cp_le_add_dev_to_rl {
1226 	bt_addr_le_t  peer_id_addr;
1227 	uint8_t       peer_irk[16];
1228 	uint8_t       local_irk[16];
1229 } __packed;
1230 
1231 #define BT_HCI_OP_LE_REM_DEV_FROM_RL            BT_OP(BT_OGF_LE, 0x0028) /* 0x2028 */
1232 struct bt_hci_cp_le_rem_dev_from_rl {
1233 	bt_addr_le_t  peer_id_addr;
1234 } __packed;
1235 
1236 #define BT_HCI_OP_LE_CLEAR_RL                   BT_OP(BT_OGF_LE, 0x0029) /* 0x2029 */
1237 
1238 #define BT_HCI_OP_LE_READ_RL_SIZE               BT_OP(BT_OGF_LE, 0x002a) /* 0x202a */
1239 struct bt_hci_rp_le_read_rl_size {
1240 	uint8_t  status;
1241 	uint8_t  rl_size;
1242 } __packed;
1243 
1244 #define BT_HCI_OP_LE_READ_PEER_RPA              BT_OP(BT_OGF_LE, 0x002b) /* 0x202b */
1245 struct bt_hci_cp_le_read_peer_rpa {
1246 	bt_addr_le_t  peer_id_addr;
1247 } __packed;
1248 struct bt_hci_rp_le_read_peer_rpa {
1249 	uint8_t    status;
1250 	bt_addr_t  peer_rpa;
1251 } __packed;
1252 
1253 #define BT_HCI_OP_LE_READ_LOCAL_RPA             BT_OP(BT_OGF_LE, 0x002c) /* 0x202c */
1254 struct bt_hci_cp_le_read_local_rpa {
1255 	bt_addr_le_t  peer_id_addr;
1256 } __packed;
1257 struct bt_hci_rp_le_read_local_rpa {
1258 	uint8_t    status;
1259 	bt_addr_t  local_rpa;
1260 } __packed;
1261 
1262 #define BT_HCI_ADDR_RES_DISABLE                 0x00
1263 #define BT_HCI_ADDR_RES_ENABLE                  0x01
1264 
1265 #define BT_HCI_OP_LE_SET_ADDR_RES_ENABLE        BT_OP(BT_OGF_LE, 0x002d) /* 0x202d */
1266 struct bt_hci_cp_le_set_addr_res_enable {
1267 	uint8_t  enable;
1268 } __packed;
1269 
1270 #define BT_HCI_OP_LE_SET_RPA_TIMEOUT            BT_OP(BT_OGF_LE, 0x002e) /* 0x202e */
1271 struct bt_hci_cp_le_set_rpa_timeout {
1272 	uint16_t rpa_timeout;
1273 } __packed;
1274 
1275 #define BT_HCI_OP_LE_READ_MAX_DATA_LEN          BT_OP(BT_OGF_LE, 0x002f) /* 0x202f */
1276 struct bt_hci_rp_le_read_max_data_len {
1277 	uint8_t  status;
1278 	uint16_t max_tx_octets;
1279 	uint16_t max_tx_time;
1280 	uint16_t max_rx_octets;
1281 	uint16_t max_rx_time;
1282 } __packed;
1283 
1284 #define BT_HCI_LE_PHY_1M                        0x01
1285 #define BT_HCI_LE_PHY_2M                        0x02
1286 #define BT_HCI_LE_PHY_CODED                     0x03
1287 
1288 #define BT_HCI_OP_LE_READ_PHY                   BT_OP(BT_OGF_LE, 0x0030) /* 0x2030 */
1289 struct bt_hci_cp_le_read_phy {
1290 	uint16_t handle;
1291 } __packed;
1292 struct bt_hci_rp_le_read_phy {
1293 	uint8_t  status;
1294 	uint16_t handle;
1295 	uint8_t  tx_phy;
1296 	uint8_t  rx_phy;
1297 } __packed;
1298 
1299 #define BT_HCI_LE_PHY_TX_ANY                    BIT(0)
1300 #define BT_HCI_LE_PHY_RX_ANY                    BIT(1)
1301 
1302 #define BT_HCI_LE_PHY_PREFER_1M                 BIT(0)
1303 #define BT_HCI_LE_PHY_PREFER_2M                 BIT(1)
1304 #define BT_HCI_LE_PHY_PREFER_CODED              BIT(2)
1305 
1306 #define BT_HCI_OP_LE_SET_DEFAULT_PHY            BT_OP(BT_OGF_LE, 0x0031) /* 0x2031 */
1307 struct bt_hci_cp_le_set_default_phy {
1308 	uint8_t all_phys;
1309 	uint8_t tx_phys;
1310 	uint8_t rx_phys;
1311 } __packed;
1312 
1313 #define BT_HCI_LE_PHY_CODED_ANY                 0x00
1314 #define BT_HCI_LE_PHY_CODED_S2                  0x01
1315 #define BT_HCI_LE_PHY_CODED_S8                  0x02
1316 
1317 #define BT_HCI_OP_LE_SET_PHY                    BT_OP(BT_OGF_LE, 0x0032) /* 0x2032 */
1318 struct bt_hci_cp_le_set_phy {
1319 	uint16_t  handle;
1320 	uint8_t   all_phys;
1321 	uint8_t   tx_phys;
1322 	uint8_t   rx_phys;
1323 	uint16_t  phy_opts;
1324 } __packed;
1325 
1326 #define BT_HCI_LE_MOD_INDEX_STANDARD            0x00
1327 #define BT_HCI_LE_MOD_INDEX_STABLE              0x01
1328 
1329 #define BT_HCI_LE_RX_PHY_1M                     0x01
1330 #define BT_HCI_LE_RX_PHY_2M                     0x02
1331 #define BT_HCI_LE_RX_PHY_CODED                  0x03
1332 
1333 #define BT_HCI_OP_LE_ENH_RX_TEST                BT_OP(BT_OGF_LE, 0x0033) /* 0x2033 */
1334 struct bt_hci_cp_le_enh_rx_test {
1335 	uint8_t  rx_ch;
1336 	uint8_t  phy;
1337 	uint8_t  mod_index;
1338 } __packed;
1339 
1340 #define BT_HCI_LE_TX_PHY_1M                     0x01
1341 #define BT_HCI_LE_TX_PHY_2M                     0x02
1342 #define BT_HCI_LE_TX_PHY_CODED_S8               0x03
1343 #define BT_HCI_LE_TX_PHY_CODED_S2               0x04
1344 
1345 #define BT_HCI_OP_LE_ENH_TX_TEST                BT_OP(BT_OGF_LE, 0x0034) /* 0x2034 */
1346 struct bt_hci_cp_le_enh_tx_test {
1347 	uint8_t  tx_ch;
1348 	uint8_t  test_data_len;
1349 	uint8_t  pkt_payload;
1350 	uint8_t  phy;
1351 } __packed;
1352 
1353 #define BT_HCI_OP_LE_SET_ADV_SET_RANDOM_ADDR    BT_OP(BT_OGF_LE, 0x0035) /* 0x2035 */
1354 struct bt_hci_cp_le_set_adv_set_random_addr {
1355 	uint8_t   handle;
1356 	bt_addr_t bdaddr;
1357 } __packed;
1358 
1359 #define BT_HCI_LE_ADV_PROP_CONN                 BIT(0)
1360 #define BT_HCI_LE_ADV_PROP_SCAN                 BIT(1)
1361 #define BT_HCI_LE_ADV_PROP_DIRECT               BIT(2)
1362 #define BT_HCI_LE_ADV_PROP_HI_DC_CONN           BIT(3)
1363 #define BT_HCI_LE_ADV_PROP_LEGACY               BIT(4)
1364 #define BT_HCI_LE_ADV_PROP_ANON                 BIT(5)
1365 #define BT_HCI_LE_ADV_PROP_TX_POWER             BIT(6)
1366 
1367 #define BT_HCI_LE_PRIM_ADV_INTERVAL_MIN         0x000020
1368 #define BT_HCI_LE_PRIM_ADV_INTERVAL_MAX         0xFFFFFF
1369 
1370 #define BT_HCI_LE_ADV_SCAN_REQ_ENABLE  1
1371 #define BT_HCI_LE_ADV_SCAN_REQ_DISABLE 0
1372 
1373 #define BT_HCI_LE_ADV_TX_POWER_NO_PREF 0x7F
1374 
1375 #define BT_HCI_LE_ADV_HANDLE_MAX       0xEF
1376 
1377 #define BT_HCI_LE_EXT_ADV_SID_INVALID  0xFF
1378 
1379 #define BT_HCI_OP_LE_SET_EXT_ADV_PARAM          BT_OP(BT_OGF_LE, 0x0036) /* 0x2036 */
1380 struct bt_hci_cp_le_set_ext_adv_param {
1381 	uint8_t      handle;
1382 	uint16_t     props;
1383 	uint8_t      prim_min_interval[3];
1384 	uint8_t      prim_max_interval[3];
1385 	uint8_t      prim_channel_map;
1386 	uint8_t      own_addr_type;
1387 	bt_addr_le_t peer_addr;
1388 	uint8_t      filter_policy;
1389 	int8_t       tx_power;
1390 	uint8_t      prim_adv_phy;
1391 	uint8_t      sec_adv_max_skip;
1392 	uint8_t      sec_adv_phy;
1393 	uint8_t      sid;
1394 	uint8_t      scan_req_notify_enable;
1395 } __packed;
1396 struct bt_hci_rp_le_set_ext_adv_param {
1397 	uint8_t status;
1398 	int8_t  tx_power;
1399 } __packed;
1400 
1401 #define BT_HCI_LE_EXT_ADV_OP_INTERM_FRAG        0x00
1402 #define BT_HCI_LE_EXT_ADV_OP_FIRST_FRAG         0x01
1403 #define BT_HCI_LE_EXT_ADV_OP_LAST_FRAG          0x02
1404 #define BT_HCI_LE_EXT_ADV_OP_COMPLETE_DATA      0x03
1405 #define BT_HCI_LE_EXT_ADV_OP_UNCHANGED_DATA     0x04
1406 
1407 #define BT_HCI_LE_EXT_ADV_FRAG_ENABLED          0x00
1408 #define BT_HCI_LE_EXT_ADV_FRAG_DISABLED         0x01
1409 
1410 #define BT_HCI_LE_EXT_ADV_FRAG_MAX_LEN          251
1411 
1412 #define BT_HCI_OP_LE_SET_EXT_ADV_DATA           BT_OP(BT_OGF_LE, 0x0037) /* 0x2037 */
1413 struct bt_hci_cp_le_set_ext_adv_data {
1414 	uint8_t  handle;
1415 	uint8_t  op;
1416 	uint8_t  frag_pref;
1417 	uint8_t  len;
1418 	uint8_t  data[0];
1419 } __packed;
1420 
1421 #define BT_HCI_OP_LE_SET_EXT_SCAN_RSP_DATA      BT_OP(BT_OGF_LE, 0x0038) /* 0x2038 */
1422 struct bt_hci_cp_le_set_ext_scan_rsp_data {
1423 	uint8_t  handle;
1424 	uint8_t  op;
1425 	uint8_t  frag_pref;
1426 	uint8_t  len;
1427 	uint8_t  data[0];
1428 } __packed;
1429 
1430 #define BT_HCI_OP_LE_SET_EXT_ADV_ENABLE         BT_OP(BT_OGF_LE, 0x0039) /* 0x2039 */
1431 struct bt_hci_ext_adv_set {
1432 	uint8_t  handle;
1433 	uint16_t duration;
1434 	uint8_t  max_ext_adv_evts;
1435 } __packed;
1436 
1437 struct bt_hci_cp_le_set_ext_adv_enable {
1438 	uint8_t  enable;
1439 	uint8_t  set_num;
1440 	struct bt_hci_ext_adv_set s[0];
1441 } __packed;
1442 
1443 #define BT_HCI_OP_LE_READ_MAX_ADV_DATA_LEN      BT_OP(BT_OGF_LE, 0x003a) /* 0x203a */
1444 struct bt_hci_rp_le_read_max_adv_data_len {
1445 	uint8_t  status;
1446 	uint16_t max_adv_data_len;
1447 } __packed;
1448 
1449 #define BT_HCI_OP_LE_READ_NUM_ADV_SETS          BT_OP(BT_OGF_LE, 0x003b) /* 0x203b */
1450 struct bt_hci_rp_le_read_num_adv_sets {
1451 	uint8_t  status;
1452 	uint8_t  num_sets;
1453 } __packed;
1454 
1455 #define BT_HCI_OP_LE_REMOVE_ADV_SET             BT_OP(BT_OGF_LE, 0x003c) /* 0x203c */
1456 struct bt_hci_cp_le_remove_adv_set {
1457 	uint8_t  handle;
1458 } __packed;
1459 
1460 #define BT_HCI_OP_CLEAR_ADV_SETS                BT_OP(BT_OGF_LE, 0x003d) /* 0x203d */
1461 
1462 #define BT_HCI_LE_PER_ADV_INTERVAL_MIN          0x0006
1463 #define BT_HCI_LE_PER_ADV_INTERVAL_MAX          0xFFFF
1464 
1465 #define BT_HCI_OP_LE_SET_PER_ADV_PARAM          BT_OP(BT_OGF_LE, 0x003e) /* 0x203e */
1466 struct bt_hci_cp_le_set_per_adv_param {
1467 	uint8_t  handle;
1468 	uint16_t min_interval;
1469 	uint16_t max_interval;
1470 	uint16_t props;
1471 } __packed;
1472 
1473 #define BT_HCI_LE_PER_ADV_OP_INTERM_FRAG        0x00
1474 #define BT_HCI_LE_PER_ADV_OP_FIRST_FRAG         0x01
1475 #define BT_HCI_LE_PER_ADV_OP_LAST_FRAG          0x02
1476 #define BT_HCI_LE_PER_ADV_OP_COMPLETE_DATA      0x03
1477 
1478 #define BT_HCI_LE_PER_ADV_FRAG_MAX_LEN          252
1479 
1480 #define BT_HCI_OP_LE_SET_PER_ADV_DATA           BT_OP(BT_OGF_LE, 0x003f) /* 0x203f */
1481 struct bt_hci_cp_le_set_per_adv_data {
1482 	uint8_t  handle;
1483 	uint8_t  op;
1484 	uint8_t  len;
1485 	uint8_t  data[0];
1486 } __packed;
1487 
1488 #define BT_HCI_LE_SET_PER_ADV_ENABLE_ENABLE     BIT(0)
1489 #define BT_HCI_LE_SET_PER_ADV_ENABLE_ADI        BIT(1)
1490 
1491 #define BT_HCI_OP_LE_SET_PER_ADV_ENABLE         BT_OP(BT_OGF_LE, 0x0040) /* 0x2040 */
1492 struct bt_hci_cp_le_set_per_adv_enable {
1493 	uint8_t  enable;
1494 	uint8_t  handle;
1495 } __packed;
1496 
1497 #define BT_HCI_OP_LE_SET_EXT_SCAN_PARAM         BT_OP(BT_OGF_LE, 0x0041) /* 0x2041 */
1498 struct bt_hci_ext_scan_phy {
1499 	uint8_t  type;
1500 	uint16_t interval;
1501 	uint16_t window;
1502 } __packed;
1503 
1504 #define BT_HCI_LE_EXT_SCAN_PHY_1M               BIT(0)
1505 #define BT_HCI_LE_EXT_SCAN_PHY_2M               BIT(1)
1506 #define BT_HCI_LE_EXT_SCAN_PHY_CODED            BIT(2)
1507 
1508 struct bt_hci_cp_le_set_ext_scan_param {
1509 	uint8_t  own_addr_type;
1510 	uint8_t  filter_policy;
1511 	uint8_t  phys;
1512 	struct bt_hci_ext_scan_phy p[0];
1513 } __packed;
1514 
1515 /* Extends BT_HCI_LE_SCAN_FILTER_DUP */
1516 #define BT_HCI_LE_EXT_SCAN_FILTER_DUP_ENABLE_RESET  0x02
1517 
1518 #define BT_HCI_OP_LE_SET_EXT_SCAN_ENABLE        BT_OP(BT_OGF_LE, 0x0042) /* 0x2042 */
1519 struct bt_hci_cp_le_set_ext_scan_enable {
1520 	uint8_t  enable;
1521 	uint8_t  filter_dup;
1522 	uint16_t duration;
1523 	uint16_t period;
1524 } __packed;
1525 
1526 #define BT_HCI_OP_LE_EXT_CREATE_CONN            BT_OP(BT_OGF_LE, 0x0043) /* 0x2043 */
1527 #define BT_HCI_OP_LE_EXT_CREATE_CONN_V2         BT_OP(BT_OGF_LE, 0x0085) /* 0x2085 */
1528 struct bt_hci_ext_conn_phy {
1529 	uint16_t scan_interval;
1530 	uint16_t scan_window;
1531 	uint16_t conn_interval_min;
1532 	uint16_t conn_interval_max;
1533 	uint16_t conn_latency;
1534 	uint16_t supervision_timeout;
1535 	uint16_t min_ce_len;
1536 	uint16_t max_ce_len;
1537 } __packed;
1538 
1539 struct bt_hci_cp_le_ext_create_conn {
1540 	uint8_t      filter_policy;
1541 	uint8_t      own_addr_type;
1542 	bt_addr_le_t peer_addr;
1543 	uint8_t      phys;
1544 	struct bt_hci_ext_conn_phy p[0];
1545 } __packed;
1546 
1547 struct bt_hci_cp_le_ext_create_conn_v2 {
1548 	uint8_t      adv_handle;
1549 	uint8_t      subevent;
1550 	uint8_t      filter_policy;
1551 	uint8_t      own_addr_type;
1552 	bt_addr_le_t peer_addr;
1553 	uint8_t      phys;
1554 	struct bt_hci_ext_conn_phy p[0];
1555 } __packed;
1556 
1557 #define BT_HCI_OP_LE_SET_PER_ADV_SUBEVENT_DATA  BT_OP(BT_OGF_LE, 0x0082) /* 0x2082 */
1558 struct bt_hci_cp_le_set_pawr_subevent_data_element {
1559 	uint8_t subevent;
1560 	uint8_t response_slot_start;
1561 	uint8_t response_slot_count;
1562 	uint8_t subevent_data_length;
1563 	uint8_t subevent_data[0];
1564 } __packed;
1565 
1566 struct bt_hci_cp_le_set_pawr_subevent_data {
1567 	uint8_t adv_handle;
1568 	uint8_t num_subevents;
1569 	struct bt_hci_cp_le_set_pawr_subevent_data_element subevents[0];
1570 } __packed;
1571 
1572 
1573 #define BT_HCI_OP_LE_SET_PER_ADV_RESPONSE_DATA  BT_OP(BT_OGF_LE, 0x0083) /* 0x2083 */
1574 struct bt_hci_cp_le_set_pawr_response_data {
1575 	uint16_t sync_handle;
1576 	uint16_t request_event;
1577 	uint8_t request_subevent;
1578 	uint8_t response_subevent;
1579 	uint8_t response_slot;
1580 	uint8_t response_data_length;
1581 	uint8_t response_data[0];
1582 } __packed;
1583 
1584 #define BT_HCI_OP_LE_SET_PER_ADV_SYNC_SUBEVENT  BT_OP(BT_OGF_LE, 0x0084) /* 0x2084 */
1585 struct bt_hci_cp_le_set_pawr_sync_subevent {
1586 	uint16_t sync_handle;
1587 	uint16_t periodic_adv_properties;
1588 	uint8_t num_subevents;
1589 	uint8_t subevents[0];
1590 } __packed;
1591 
1592 
1593 #define BT_HCI_OP_LE_SET_PER_ADV_PARAM_V2       BT_OP(BT_OGF_LE, 0x0086) /* 0x2086 */
1594 struct bt_hci_cp_le_set_per_adv_param_v2 {
1595 	uint8_t  handle;
1596 	uint16_t min_interval;
1597 	uint16_t max_interval;
1598 	uint16_t props;
1599 	uint8_t num_subevents;
1600 	uint8_t subevent_interval;
1601 	uint8_t response_slot_delay;
1602 	uint8_t response_slot_spacing;
1603 	uint8_t num_response_slots;
1604 } __packed;
1605 
1606 
1607 #define BT_HCI_LE_PER_ADV_CREATE_SYNC_FP_USE_LIST               BIT(0)
1608 #define BT_HCI_LE_PER_ADV_CREATE_SYNC_FP_REPORTS_DISABLED       BIT(1)
1609 #define BT_HCI_LE_PER_ADV_CREATE_SYNC_FP_FILTER_DUPLICATE       BIT(2)
1610 
1611 #define BT_HCI_LE_PER_ADV_CREATE_SYNC_CTE_TYPE_NO_FILTERING     0
1612 #define BT_HCI_LE_PER_ADV_CREATE_SYNC_CTE_TYPE_NO_AOA           BIT(0)
1613 #define BT_HCI_LE_PER_ADV_CREATE_SYNC_CTE_TYPE_NO_AOD_1US       BIT(1)
1614 #define BT_HCI_LE_PER_ADV_CREATE_SYNC_CTE_TYPE_NO_AOD_2US       BIT(2)
1615 #define BT_HCI_LE_PER_ADV_CREATE_SYNC_CTE_TYPE_NO_CTE           BIT(3)
1616 #define BT_HCI_LE_PER_ADV_CREATE_SYNC_CTE_TYPE_ONLY_CTE         BIT(4)
1617 /* Constants to check correctness of CTE type */
1618 #define BT_HCI_LE_PER_ADV_CREATE_SYNC_CTE_TYPE_ALLOWED_BITS 5
1619 #define BT_HCI_LE_PER_ADV_CREATE_SYNC_CTE_TYPE_INVALID_VALUE \
1620 	(~BIT_MASK(BT_HCI_LE_PER_ADV_CREATE_SYNC_CTE_TYPE_ALLOWED_BITS))
1621 
1622 #define BT_HCI_OP_LE_PER_ADV_CREATE_SYNC        BT_OP(BT_OGF_LE, 0x0044) /* 0x2044 */
1623 struct bt_hci_cp_le_per_adv_create_sync {
1624 	uint8_t options;
1625 	uint8_t      sid;
1626 	bt_addr_le_t addr;
1627 	uint16_t     skip;
1628 	uint16_t     sync_timeout;
1629 	uint8_t      cte_type;
1630 } __packed;
1631 
1632 #define BT_HCI_OP_LE_PER_ADV_CREATE_SYNC_CANCEL BT_OP(BT_OGF_LE, 0x0045) /* 0x2045 */
1633 
1634 #define BT_HCI_OP_LE_PER_ADV_TERMINATE_SYNC     BT_OP(BT_OGF_LE, 0x0046) /* 0x2046 */
1635 struct bt_hci_cp_le_per_adv_terminate_sync {
1636 	uint16_t handle;
1637 } __packed;
1638 
1639 #define BT_HCI_OP_LE_ADD_DEV_TO_PER_ADV_LIST    BT_OP(BT_OGF_LE, 0x0047) /* 0x2047 */
1640 struct bt_hci_cp_le_add_dev_to_per_adv_list {
1641 	bt_addr_le_t addr;
1642 	uint8_t      sid;
1643 } __packed;
1644 
1645 #define BT_HCI_OP_LE_REM_DEV_FROM_PER_ADV_LIST  BT_OP(BT_OGF_LE, 0x0048) /* 0x2048 */
1646 struct bt_hci_cp_le_rem_dev_from_per_adv_list {
1647 	bt_addr_le_t addr;
1648 	uint8_t      sid;
1649 } __packed;
1650 
1651 #define BT_HCI_OP_LE_CLEAR_PER_ADV_LIST         BT_OP(BT_OGF_LE, 0x0049) /* 0x2049 */
1652 
1653 #define BT_HCI_OP_LE_READ_PER_ADV_LIST_SIZE     BT_OP(BT_OGF_LE, 0x004a) /* 0x204a */
1654 struct bt_hci_rp_le_read_per_adv_list_size {
1655 	uint8_t  status;
1656 	uint8_t  list_size;
1657 } __packed;
1658 
1659 #define BT_HCI_OP_LE_READ_TX_POWER              BT_OP(BT_OGF_LE, 0x004b) /* 0x204b */
1660 struct bt_hci_rp_le_read_tx_power {
1661 	uint8_t status;
1662 	int8_t  min_tx_power;
1663 	int8_t  max_tx_power;
1664 } __packed;
1665 
1666 #define BT_HCI_OP_LE_READ_RF_PATH_COMP          BT_OP(BT_OGF_LE, 0x004c) /* 0x204c */
1667 struct bt_hci_rp_le_read_rf_path_comp {
1668 	uint8_t status;
1669 	int16_t tx_path_comp;
1670 	int16_t rx_path_comp;
1671 } __packed;
1672 
1673 #define BT_HCI_OP_LE_WRITE_RF_PATH_COMP         BT_OP(BT_OGF_LE, 0x004d) /* 0x204d */
1674 struct bt_hci_cp_le_write_rf_path_comp {
1675 	int16_t  tx_path_comp;
1676 	int16_t  rx_path_comp;
1677 } __packed;
1678 
1679 #define BT_HCI_LE_PRIVACY_MODE_NETWORK          0x00
1680 #define BT_HCI_LE_PRIVACY_MODE_DEVICE           0x01
1681 
1682 #define BT_HCI_OP_LE_SET_PRIVACY_MODE           BT_OP(BT_OGF_LE, 0x004e) /* 0x204e */
1683 struct bt_hci_cp_le_set_privacy_mode {
1684 	bt_addr_le_t id_addr;
1685 	uint8_t         mode;
1686 } __packed;
1687 
1688 #define BT_HCI_LE_TEST_CTE_DISABLED             0x00
1689 #define BT_HCI_LE_TEST_CTE_TYPE_ANY             0x00
1690 #define BT_HCI_LE_TEST_SLOT_DURATION_ANY        0x00
1691 #define BT_HCI_LE_TEST_SWITCH_PATTERN_LEN_ANY   0x00
1692 
1693 #define BT_HCI_OP_LE_RX_TEST_V3                 BT_OP(BT_OGF_LE, 0x004f) /* 0x204f */
1694 struct bt_hci_cp_le_rx_test_v3 {
1695 	uint8_t  rx_ch;
1696 	uint8_t  phy;
1697 	uint8_t  mod_index;
1698 	uint8_t  expected_cte_len;
1699 	uint8_t  expected_cte_type;
1700 	uint8_t  slot_durations;
1701 	uint8_t  switch_pattern_len;
1702 	uint8_t  ant_ids[0];
1703 } __packed;
1704 
1705 #define BT_HCI_OP_LE_TX_TEST_V3                 BT_OP(BT_OGF_LE, 0x0050) /* 0x2050 */
1706 
1707 struct bt_hci_cp_le_tx_test_v3 {
1708 	uint8_t  tx_ch;
1709 	uint8_t  test_data_len;
1710 	uint8_t  pkt_payload;
1711 	uint8_t  phy;
1712 	uint8_t  cte_len;
1713 	uint8_t  cte_type;
1714 	uint8_t  switch_pattern_len;
1715 	uint8_t  ant_ids[0];
1716 } __packed;
1717 
1718 /* Min and max Constant Tone Extension length in 8us units */
1719 #define BT_HCI_LE_CTE_LEN_MIN                  0x2
1720 #define BT_HCI_LE_CTE_LEN_MAX                  0x14
1721 
1722 #define BT_HCI_LE_AOA_CTE                      0x0
1723 #define BT_HCI_LE_AOD_CTE_1US                  0x1
1724 #define BT_HCI_LE_AOD_CTE_2US                  0x2
1725 #define BT_HCI_LE_NO_CTE                       0xFF
1726 
1727 #define BT_HCI_LE_CTE_COUNT_MIN                0x1
1728 #define BT_HCI_LE_CTE_COUNT_MAX                0x10
1729 
1730 #define BT_HCI_OP_LE_SET_CL_CTE_TX_PARAMS      BT_OP(BT_OGF_LE, 0x0051) /* 0x2051 */
1731 struct bt_hci_cp_le_set_cl_cte_tx_params {
1732 	uint8_t handle;
1733 	uint8_t cte_len;
1734 	uint8_t cte_type;
1735 	uint8_t cte_count;
1736 	uint8_t switch_pattern_len;
1737 	uint8_t ant_ids[0];
1738 } __packed;
1739 
1740 #define BT_HCI_OP_LE_SET_CL_CTE_TX_ENABLE      BT_OP(BT_OGF_LE, 0x0052) /* 0x2052 */
1741 struct bt_hci_cp_le_set_cl_cte_tx_enable {
1742 	uint8_t handle;
1743 	uint8_t cte_enable;
1744 } __packed;
1745 
1746 #define BT_HCI_LE_ANTENNA_SWITCHING_SLOT_1US   0x1
1747 #define BT_HCI_LE_ANTENNA_SWITCHING_SLOT_2US   0x2
1748 
1749 #define BT_HCI_LE_SAMPLE_CTE_ALL               0x0
1750 #define BT_HCI_LE_SAMPLE_CTE_COUNT_MIN         0x1
1751 #define BT_HCI_LE_SAMPLE_CTE_COUNT_MAX         0x10
1752 
1753 #define BT_HCI_OP_LE_SET_CL_CTE_SAMPLING_ENABLE BT_OP(BT_OGF_LE, 0x0053) /* 0x2053 */
1754 struct bt_hci_cp_le_set_cl_cte_sampling_enable {
1755 	uint16_t sync_handle;
1756 	uint8_t  sampling_enable;
1757 	uint8_t  slot_durations;
1758 	uint8_t  max_sampled_cte;
1759 	uint8_t  switch_pattern_len;
1760 	uint8_t  ant_ids[0];
1761 } __packed;
1762 
1763 struct bt_hci_rp_le_set_cl_cte_sampling_enable {
1764 	uint8_t  status;
1765 	uint16_t sync_handle;
1766 } __packed;
1767 
1768 #define BT_HCI_OP_LE_SET_CONN_CTE_RX_PARAMS BT_OP(BT_OGF_LE, 0x0054) /* 0x2054 */
1769 struct bt_hci_cp_le_set_conn_cte_rx_params {
1770 	uint16_t handle;
1771 	uint8_t  sampling_enable;
1772 	uint8_t  slot_durations;
1773 	uint8_t  switch_pattern_len;
1774 	uint8_t  ant_ids[0];
1775 } __packed;
1776 
1777 struct bt_hci_rp_le_set_conn_cte_rx_params {
1778 	uint8_t  status;
1779 	uint16_t handle;
1780 } __packed;
1781 
1782 #define BT_HCI_LE_AOA_CTE_RSP                   BIT(0)
1783 #define BT_HCI_LE_AOD_CTE_RSP_1US               BIT(1)
1784 #define BT_HCI_LE_AOD_CTE_RSP_2US               BIT(2)
1785 
1786 #define BT_HCI_LE_SWITCH_PATTERN_LEN_MIN        0x2
1787 #define BT_HCI_LE_SWITCH_PATTERN_LEN_MAX        0x4B
1788 
1789 #define BT_HCI_OP_LE_SET_CONN_CTE_TX_PARAMS     BT_OP(BT_OGF_LE, 0x0055) /* 0x2055 */
1790 struct bt_hci_cp_le_set_conn_cte_tx_params {
1791 	uint16_t handle;
1792 	uint8_t  cte_types;
1793 	uint8_t  switch_pattern_len;
1794 	uint8_t  ant_ids[0];
1795 } __packed;
1796 
1797 struct bt_hci_rp_le_set_conn_cte_tx_params {
1798 	uint8_t  status;
1799 	uint16_t handle;
1800 } __packed;
1801 
1802 /* Interval between consecutive CTE request procedure starts in number of connection events. */
1803 #define BT_HCI_REQUEST_CTE_ONCE                0x0
1804 #define BT_HCI_REQUEST_CTE_INTERVAL_MIN        0x1
1805 #define BT_HCI_REQUEST_CTE_INTERVAL_MAX        0xFFFF
1806 
1807 #define BT_HCI_OP_LE_CONN_CTE_REQ_ENABLE       BT_OP(BT_OGF_LE, 0x0056) /* 0x2056 */
1808 struct bt_hci_cp_le_conn_cte_req_enable {
1809 	uint16_t handle;
1810 	uint8_t  enable;
1811 	uint16_t cte_request_interval;
1812 	uint8_t  requested_cte_length;
1813 	uint8_t  requested_cte_type;
1814 } __packed;
1815 
1816 struct bt_hci_rp_le_conn_cte_req_enable {
1817 	uint8_t  status;
1818 	uint16_t handle;
1819 } __packed;
1820 
1821 #define BT_HCI_OP_LE_CONN_CTE_RSP_ENABLE       BT_OP(BT_OGF_LE, 0x0057) /* 0x2057 */
1822 struct bt_hci_cp_le_conn_cte_rsp_enable {
1823 	uint16_t handle;
1824 	uint8_t  enable;
1825 } __packed;
1826 
1827 struct bt_hci_rp_le_conn_cte_rsp_enable {
1828 	uint8_t  status;
1829 	uint16_t handle;
1830 } __packed;
1831 
1832 #define BT_HCI_LE_1US_AOD_TX                    BIT(0)
1833 #define BT_HCI_LE_1US_AOD_RX                    BIT(1)
1834 #define BT_HCI_LE_1US_AOA_RX                    BIT(2)
1835 
1836 #define BT_HCI_LE_NUM_ANT_MIN                   0x1
1837 #define BT_HCI_LE_NUM_ANT_MAX                   0x4B
1838 
1839 #define BT_HCI_LE_MAX_SWITCH_PATTERN_LEN_MIN    0x2
1840 #define BT_HCI_LE_MAX_SWITCH_PATTERN_LEN_MAX    0x4B
1841 
1842 #define BT_HCI_LE_MAX_CTE_LEN_MIN               0x2
1843 #define BT_HCI_LE_MAX_CTE_LEN_MAX               0x14
1844 
1845 #define BT_HCI_OP_LE_READ_ANT_INFO              BT_OP(BT_OGF_LE, 0x0058) /* 0x2058 */
1846 struct bt_hci_rp_le_read_ant_info {
1847 	uint8_t status;
1848 	uint8_t switch_sample_rates;
1849 	uint8_t num_ant;
1850 	uint8_t max_switch_pattern_len;
1851 	uint8_t max_cte_len;
1852 };
1853 
1854 #define BT_HCI_LE_SET_PER_ADV_RECV_ENABLE_ENABLE           BIT(0)
1855 #define BT_HCI_LE_SET_PER_ADV_RECV_ENABLE_FILTER_DUPLICATE BIT(1)
1856 
1857 #define BT_HCI_OP_LE_SET_PER_ADV_RECV_ENABLE     BT_OP(BT_OGF_LE, 0x0059) /* 0x2059 */
1858 struct bt_hci_cp_le_set_per_adv_recv_enable {
1859 	uint16_t handle;
1860 	uint8_t  enable;
1861 } __packed;
1862 
1863 #define BT_HCI_OP_LE_PER_ADV_SYNC_TRANSFER      BT_OP(BT_OGF_LE, 0x005a) /* 0x205a */
1864 struct bt_hci_cp_le_per_adv_sync_transfer {
1865 	uint16_t conn_handle;
1866 	uint16_t service_data;
1867 	uint16_t sync_handle;
1868 } __packed;
1869 
1870 struct bt_hci_rp_le_per_adv_sync_transfer {
1871 	uint8_t  status;
1872 	uint16_t conn_handle;
1873 } __packed;
1874 
1875 #define BT_HCI_OP_LE_PER_ADV_SET_INFO_TRANSFER  BT_OP(BT_OGF_LE, 0x005b) /* 0x205b */
1876 struct bt_hci_cp_le_per_adv_set_info_transfer {
1877 	uint16_t conn_handle;
1878 	uint16_t service_data;
1879 	uint8_t  adv_handle;
1880 } __packed;
1881 
1882 struct bt_hci_rp_le_per_adv_set_info_transfer {
1883 	uint8_t  status;
1884 	uint16_t conn_handle;
1885 } __packed;
1886 
1887 #define BT_HCI_LE_PAST_MODE_NO_SYNC                0x00
1888 #define BT_HCI_LE_PAST_MODE_NO_REPORTS             0x01
1889 #define BT_HCI_LE_PAST_MODE_SYNC                   0x02
1890 #define BT_HCI_LE_PAST_MODE_SYNC_FILTER_DUPLICATES 0x03
1891 
1892 #define BT_HCI_LE_PAST_CTE_TYPE_NO_AOA           BIT(0)
1893 #define BT_HCI_LE_PAST_CTE_TYPE_NO_AOD_1US       BIT(1)
1894 #define BT_HCI_LE_PAST_CTE_TYPE_NO_AOD_2US       BIT(2)
1895 #define BT_HCI_LE_PAST_CTE_TYPE_NO_CTE           BIT(3)
1896 #define BT_HCI_LE_PAST_CTE_TYPE_ONLY_CTE         BIT(4)
1897 
1898 #define BT_HCI_OP_LE_PAST_PARAM                 BT_OP(BT_OGF_LE, 0x005c) /* 0x205c */
1899 struct bt_hci_cp_le_past_param {
1900 	uint16_t conn_handle;
1901 	uint8_t  mode;
1902 	uint16_t skip;
1903 	uint16_t timeout;
1904 	uint8_t  cte_type;
1905 } __packed;
1906 
1907 struct bt_hci_rp_le_past_param {
1908 	uint8_t  status;
1909 	uint16_t conn_handle;
1910 } __packed;
1911 
1912 #define BT_HCI_OP_LE_DEFAULT_PAST_PARAM         BT_OP(BT_OGF_LE, 0x005d) /* 0x205d */
1913 struct bt_hci_cp_le_default_past_param {
1914 	uint8_t  mode;
1915 	uint16_t skip;
1916 	uint16_t timeout;
1917 	uint8_t  cte_type;
1918 } __packed;
1919 
1920 struct bt_hci_rp_le_default_past_param {
1921 	uint8_t  status;
1922 } __packed;
1923 
1924 #define BT_HCI_OP_LE_READ_BUFFER_SIZE_V2        BT_OP(BT_OGF_LE, 0x0060) /* 0x2060 */
1925 struct bt_hci_rp_le_read_buffer_size_v2 {
1926 	uint8_t  status;
1927 	uint16_t acl_max_len;
1928 	uint8_t  acl_max_num;
1929 	uint16_t iso_max_len;
1930 	uint8_t  iso_max_num;
1931 } __packed;
1932 
1933 #define BT_HCI_OP_LE_READ_ISO_TX_SYNC           BT_OP(BT_OGF_LE, 0x0061) /* 0x2061 */
1934 struct bt_hci_cp_le_read_iso_tx_sync {
1935 	uint16_t handle;
1936 } __packed;
1937 
1938 struct bt_hci_rp_le_read_iso_tx_sync {
1939 	uint8_t  status;
1940 	uint16_t handle;
1941 	uint16_t seq;
1942 	uint32_t timestamp;
1943 	uint8_t  offset[3];
1944 } __packed;
1945 
1946 #define BT_HCI_ISO_CIG_ID_MAX                   0xFE
1947 #define BT_HCI_ISO_CIS_COUNT_MAX                0x1F
1948 #define BT_HCI_ISO_SDU_INTERVAL_MIN             0x0000FF
1949 #define BT_HCI_ISO_SDU_INTERVAL_MAX             0x0FFFFF
1950 #define BT_HCI_ISO_WORST_CASE_SCA_VALID_MASK    0x07
1951 #define BT_HCI_ISO_PACKING_VALID_MASK           0x01
1952 #define BT_HCI_ISO_FRAMING_VALID_MASK           0x01
1953 #define BT_HCI_ISO_MAX_TRANSPORT_LATENCY_MIN    0x0005
1954 #define BT_HCI_ISO_MAX_TRANSPORT_LATENCY_MAX    0x0FA0
1955 #define BT_HCI_ISO_CIS_ID_VALID_MAX             0xEF
1956 #define BT_HCI_ISO_MAX_SDU_VALID_MASK           0x0FFF
1957 #define BT_HCI_ISO_PHY_VALID_MASK               0x07
1958 #define BT_HCI_ISO_INTERVAL_MIN                 0x0004
1959 #define BT_HCI_ISO_INTERVAL_MAX                 0x0C80
1960 
1961 #define BT_HCI_OP_LE_SET_CIG_PARAMS             BT_OP(BT_OGF_LE, 0x0062) /* 0x2062 */
1962 struct bt_hci_cis_params {
1963 	uint8_t  cis_id;
1964 	uint16_t c_sdu;
1965 	uint16_t p_sdu;
1966 	uint8_t  c_phy;
1967 	uint8_t  p_phy;
1968 	uint8_t  c_rtn;
1969 	uint8_t  p_rtn;
1970 } __packed;
1971 
1972 struct bt_hci_cp_le_set_cig_params {
1973 	uint8_t  cig_id;
1974 	uint8_t  c_interval[3];
1975 	uint8_t  p_interval[3];
1976 	uint8_t  sca;
1977 	uint8_t  packing;
1978 	uint8_t  framing;
1979 	uint16_t c_latency;
1980 	uint16_t p_latency;
1981 	uint8_t  num_cis;
1982 	struct bt_hci_cis_params cis[0];
1983 } __packed;
1984 
1985 struct bt_hci_rp_le_set_cig_params {
1986 	uint8_t  status;
1987 	uint8_t  cig_id;
1988 	uint8_t  num_handles;
1989 	uint16_t handle[0];
1990 } __packed;
1991 
1992 #define BT_HCI_OP_LE_SET_CIG_PARAMS_TEST        BT_OP(BT_OGF_LE, 0x0063) /* 0x2063 */
1993 struct bt_hci_cis_params_test {
1994 	uint8_t  cis_id;
1995 	uint8_t  nse;
1996 	uint16_t c_sdu;
1997 	uint16_t p_sdu;
1998 	uint16_t c_pdu;
1999 	uint16_t p_pdu;
2000 	uint8_t  c_phy;
2001 	uint8_t  p_phy;
2002 	uint8_t  c_bn;
2003 	uint8_t  p_bn;
2004 } __packed;
2005 
2006 struct bt_hci_cp_le_set_cig_params_test {
2007 	uint8_t  cig_id;
2008 	uint8_t  c_interval[3];
2009 	uint8_t  p_interval[3];
2010 	uint8_t  c_ft;
2011 	uint8_t  p_ft;
2012 	uint16_t iso_interval;
2013 	uint8_t  sca;
2014 	uint8_t  packing;
2015 	uint8_t  framing;
2016 	uint8_t  num_cis;
2017 	struct bt_hci_cis_params_test cis[0];
2018 } __packed;
2019 
2020 struct bt_hci_rp_le_set_cig_params_test {
2021 	uint8_t  status;
2022 	uint8_t  cig_id;
2023 	uint8_t  num_handles;
2024 	uint16_t handle[0];
2025 } __packed;
2026 
2027 #define BT_HCI_OP_LE_CREATE_CIS                 BT_OP(BT_OGF_LE, 0x0064) /* 0x2064 */
2028 struct bt_hci_cis {
2029 	uint16_t  cis_handle;
2030 	uint16_t  acl_handle;
2031 } __packed;
2032 
2033 struct bt_hci_cp_le_create_cis {
2034 	uint8_t  num_cis;
2035 	struct bt_hci_cis cis[0];
2036 } __packed;
2037 
2038 #define BT_HCI_OP_LE_REMOVE_CIG                 BT_OP(BT_OGF_LE, 0x0065) /* 0x2065 */
2039 struct bt_hci_cp_le_remove_cig {
2040 	uint8_t  cig_id;
2041 } __packed;
2042 
2043 struct bt_hci_rp_le_remove_cig {
2044 	uint8_t  status;
2045 	uint8_t  cig_id;
2046 } __packed;
2047 
2048 #define BT_HCI_OP_LE_ACCEPT_CIS                 BT_OP(BT_OGF_LE, 0x0066) /* 0x2066 */
2049 struct bt_hci_cp_le_accept_cis {
2050 	uint16_t handle;
2051 } __packed;
2052 
2053 #define BT_HCI_OP_LE_REJECT_CIS                 BT_OP(BT_OGF_LE, 0x0067) /* 0x2067 */
2054 struct bt_hci_cp_le_reject_cis {
2055 	uint16_t handle;
2056 	uint8_t  reason;
2057 } __packed;
2058 
2059 struct bt_hci_rp_le_reject_cis {
2060 	uint8_t  status;
2061 	uint16_t handle;
2062 } __packed;
2063 
2064 #define BT_HCI_OP_LE_CREATE_BIG                 BT_OP(BT_OGF_LE, 0x0068) /* 0x2068 */
2065 struct bt_hci_cp_le_create_big {
2066 	uint8_t  big_handle;
2067 	uint8_t  adv_handle;
2068 	uint8_t  num_bis;
2069 	uint8_t  sdu_interval[3];
2070 	uint16_t max_sdu;
2071 	uint16_t max_latency;
2072 	uint8_t  rtn;
2073 	uint8_t  phy;
2074 	uint8_t  packing;
2075 	uint8_t  framing;
2076 	uint8_t  encryption;
2077 	uint8_t  bcode[16];
2078 } __packed;
2079 
2080 #define BT_HCI_OP_LE_CREATE_BIG_TEST            BT_OP(BT_OGF_LE, 0x0069) /* 0x2069 */
2081 struct bt_hci_cp_le_create_big_test {
2082 	uint8_t  big_handle;
2083 	uint8_t  adv_handle;
2084 	uint8_t  num_bis;
2085 	uint8_t  sdu_interval[3];
2086 	uint16_t iso_interval;
2087 	uint8_t  nse;
2088 	uint16_t max_sdu;
2089 	uint16_t max_pdu;
2090 	uint8_t  phy;
2091 	uint8_t  packing;
2092 	uint8_t  framing;
2093 	uint8_t  bn;
2094 	uint8_t  irc;
2095 	uint8_t  pto;
2096 	uint8_t  encryption;
2097 	uint8_t  bcode[16];
2098 } __packed;
2099 
2100 #define BT_HCI_OP_LE_TERMINATE_BIG              BT_OP(BT_OGF_LE, 0x006a) /* 0x206a */
2101 struct bt_hci_cp_le_terminate_big {
2102 	uint8_t  big_handle;
2103 	uint8_t  reason;
2104 } __packed;
2105 
2106 #define BT_HCI_OP_LE_BIG_CREATE_SYNC            BT_OP(BT_OGF_LE, 0x006b) /* 0x206b */
2107 struct bt_hci_cp_le_big_create_sync {
2108 	uint8_t  big_handle;
2109 	uint16_t sync_handle;
2110 	uint8_t  encryption;
2111 	uint8_t  bcode[16];
2112 	uint8_t  mse;
2113 	uint16_t sync_timeout;
2114 	uint8_t  num_bis;
2115 	uint8_t  bis[0];
2116 } __packed;
2117 
2118 #define BT_HCI_OP_LE_BIG_TERMINATE_SYNC         BT_OP(BT_OGF_LE, 0x006c) /* 0x206c */
2119 struct bt_hci_cp_le_big_terminate_sync {
2120 	uint8_t  big_handle;
2121 } __packed;
2122 
2123 struct bt_hci_rp_le_big_terminate_sync {
2124 	uint8_t  status;
2125 	uint8_t  big_handle;
2126 } __packed;
2127 
2128 #define BT_HCI_OP_LE_REQ_PEER_SC                BT_OP(BT_OGF_LE, 0x006d) /* 0x206d */
2129 struct bt_hci_cp_le_req_peer_sca {
2130 	uint16_t handle;
2131 } __packed;
2132 
2133 #define BT_HCI_OP_LE_SETUP_ISO_PATH             BT_OP(BT_OGF_LE, 0x006e) /* 0x206e */
2134 struct bt_hci_cp_le_setup_iso_path {
2135 	uint16_t handle;
2136 	uint8_t  path_dir;
2137 	uint8_t  path_id;
2138 	struct bt_hci_cp_codec_id codec_id;
2139 	uint8_t  controller_delay[3];
2140 	uint8_t  codec_config_len;
2141 	uint8_t  codec_config[0];
2142 } __packed;
2143 
2144 struct bt_hci_rp_le_setup_iso_path {
2145 	uint8_t  status;
2146 	uint16_t handle;
2147 } __packed;
2148 
2149 #define BT_HCI_OP_LE_REMOVE_ISO_PATH            BT_OP(BT_OGF_LE, 0x006f) /* 0x206f */
2150 struct bt_hci_cp_le_remove_iso_path {
2151 	uint16_t handle;
2152 	uint8_t  path_dir;
2153 } __packed;
2154 
2155 struct bt_hci_rp_le_remove_iso_path {
2156 	uint8_t  status;
2157 	uint16_t handle;
2158 } __packed;
2159 
2160 #define BT_HCI_ISO_TEST_ZERO_SIZE_SDU     0
2161 #define BT_HCI_ISO_TEST_VARIABLE_SIZE_SDU 1
2162 #define BT_HCI_ISO_TEST_MAX_SIZE_SDU      2
2163 
2164 #define BT_HCI_OP_LE_ISO_TRANSMIT_TEST          BT_OP(BT_OGF_LE, 0x0070) /* 0x2070 */
2165 struct bt_hci_cp_le_iso_transmit_test {
2166 	uint16_t handle;
2167 	uint8_t  payload_type;
2168 } __packed;
2169 
2170 struct bt_hci_rp_le_iso_transmit_test {
2171 	uint8_t  status;
2172 	uint16_t handle;
2173 } __packed;
2174 
2175 #define BT_HCI_OP_LE_ISO_RECEIVE_TEST           BT_OP(BT_OGF_LE, 0x0071) /* 0x2071 */
2176 struct bt_hci_cp_le_iso_receive_test {
2177 	uint16_t handle;
2178 	uint8_t  payload_type;
2179 } __packed;
2180 
2181 struct bt_hci_rp_le_iso_receive_test {
2182 	uint8_t  status;
2183 	uint16_t handle;
2184 } __packed;
2185 
2186 #define BT_HCI_OP_LE_ISO_READ_TEST_COUNTERS     BT_OP(BT_OGF_LE, 0x0072) /* 0x2072 */
2187 struct bt_hci_cp_le_read_test_counters {
2188 	uint16_t handle;
2189 } __packed;
2190 
2191 struct bt_hci_rp_le_read_test_counters {
2192 	uint8_t  status;
2193 	uint16_t handle;
2194 	uint32_t received_cnt;
2195 	uint32_t missed_cnt;
2196 	uint32_t failed_cnt;
2197 } __packed;
2198 
2199 #define BT_HCI_OP_LE_ISO_TEST_END               BT_OP(BT_OGF_LE, 0x0073) /* 0x2073 */
2200 struct bt_hci_cp_le_iso_test_end {
2201 	uint16_t handle;
2202 } __packed;
2203 
2204 struct bt_hci_rp_le_iso_test_end {
2205 	uint8_t  status;
2206 	uint16_t handle;
2207 	uint32_t received_cnt;
2208 	uint32_t missed_cnt;
2209 	uint32_t failed_cnt;
2210 } __packed;
2211 
2212 #define BT_HCI_OP_LE_SET_HOST_FEATURE           BT_OP(BT_OGF_LE, 0x0074) /* 0x2074 */
2213 struct bt_hci_cp_le_set_host_feature {
2214 	uint8_t  bit_number;
2215 	uint8_t  bit_value;
2216 } __packed;
2217 
2218 struct bt_hci_rp_le_set_host_feature {
2219 	uint8_t  status;
2220 } __packed;
2221 
2222 #define BT_HCI_OP_LE_READ_ISO_LINK_QUALITY      BT_OP(BT_OGF_LE, 0x0075) /* 0x2075 */
2223 struct bt_hci_cp_le_read_iso_link_quality {
2224 	uint16_t handle;
2225 } __packed;
2226 
2227 struct bt_hci_rp_le_read_iso_link_quality {
2228 	uint8_t  status;
2229 	uint16_t handle;
2230 	uint32_t tx_unacked_packets;
2231 	uint32_t tx_flushed_packets;
2232 	uint32_t tx_last_subevent_packets;
2233 	uint32_t retransmitted_packets;
2234 	uint32_t crc_error_packets;
2235 	uint32_t rx_unreceived_packets;
2236 	uint32_t duplicate_packets;
2237 } __packed;
2238 
2239 #define BT_HCI_OP_LE_TX_TEST_V4                 BT_OP(BT_OGF_LE, 0x007B) /* 0x207B */
2240 
2241 struct bt_hci_cp_le_tx_test_v4 {
2242 	uint8_t  tx_ch;
2243 	uint8_t  test_data_len;
2244 	uint8_t  pkt_payload;
2245 	uint8_t  phy;
2246 	uint8_t  cte_len;
2247 	uint8_t  cte_type;
2248 	uint8_t  switch_pattern_len;
2249 	uint8_t  ant_ids[0];
2250 } __packed;
2251 
2252 #define BT_HCI_TX_TEST_POWER_MIN -0x7F
2253 #define BT_HCI_TX_TEST_POWER_MAX 0x14
2254 
2255 #define BT_HCI_TX_TEST_POWER_MIN_SET 0x7E
2256 #define BT_HCI_TX_TEST_POWER_MAX_SET 0x7F
2257 
2258 /* Helper structure for Tx power parameter in the HCI Tx Test v4 command.
2259  * Previous parameter of this command is variable size so having separated structure
2260  * for this parameter helps in command parameters unpacking.
2261  */
2262 struct bt_hci_cp_le_tx_test_v4_tx_power {
2263 	int8_t tx_power;
2264 } __packed;
2265 
2266 /* Event definitions */
2267 
2268 #define BT_HCI_EVT_UNKNOWN                      0x00
2269 #define BT_HCI_EVT_VENDOR                       0xff
2270 
2271 #define BT_HCI_EVT_INQUIRY_COMPLETE             0x01
2272 struct bt_hci_evt_inquiry_complete {
2273 	uint8_t status;
2274 } __packed;
2275 
2276 #define BT_HCI_EVT_CONN_COMPLETE                0x03
2277 struct bt_hci_evt_conn_complete {
2278 	uint8_t   status;
2279 	uint16_t  handle;
2280 	bt_addr_t bdaddr;
2281 	uint8_t   link_type;
2282 	uint8_t   encr_enabled;
2283 } __packed;
2284 
2285 #define BT_HCI_EVT_CONN_REQUEST                 0x04
2286 struct bt_hci_evt_conn_request {
2287 	bt_addr_t bdaddr;
2288 	uint8_t   dev_class[3];
2289 	uint8_t   link_type;
2290 } __packed;
2291 
2292 #define BT_HCI_EVT_DISCONN_COMPLETE             0x05
2293 struct bt_hci_evt_disconn_complete {
2294 	uint8_t  status;
2295 	uint16_t handle;
2296 	uint8_t  reason;
2297 } __packed;
2298 
2299 #define BT_HCI_EVT_AUTH_COMPLETE                0x06
2300 struct bt_hci_evt_auth_complete {
2301 	uint8_t  status;
2302 	uint16_t handle;
2303 } __packed;
2304 
2305 #define BT_HCI_EVT_REMOTE_NAME_REQ_COMPLETE     0x07
2306 struct bt_hci_evt_remote_name_req_complete {
2307 	uint8_t   status;
2308 	bt_addr_t bdaddr;
2309 	uint8_t   name[248];
2310 } __packed;
2311 
2312 #define BT_HCI_EVT_ENCRYPT_CHANGE               0x08
2313 struct bt_hci_evt_encrypt_change {
2314 	uint8_t  status;
2315 	uint16_t handle;
2316 	uint8_t  encrypt;
2317 } __packed;
2318 
2319 #define BT_HCI_EVT_REMOTE_FEATURES              0x0b
2320 struct bt_hci_evt_remote_features {
2321 	uint8_t  status;
2322 	uint16_t handle;
2323 	uint8_t  features[8];
2324 } __packed;
2325 
2326 #define BT_HCI_EVT_REMOTE_VERSION_INFO          0x0c
2327 struct bt_hci_evt_remote_version_info {
2328 	uint8_t  status;
2329 	uint16_t handle;
2330 	uint8_t  version;
2331 	uint16_t manufacturer;
2332 	uint16_t subversion;
2333 } __packed;
2334 
2335 #define BT_HCI_EVT_CMD_COMPLETE                 0x0e
2336 struct bt_hci_evt_cmd_complete {
2337 	uint8_t  ncmd;
2338 	uint16_t opcode;
2339 } __packed;
2340 
2341 struct bt_hci_evt_cc_status {
2342 	uint8_t  status;
2343 } __packed;
2344 
2345 #define BT_HCI_EVT_CMD_STATUS                   0x0f
2346 struct bt_hci_evt_cmd_status {
2347 	uint8_t  status;
2348 	uint8_t  ncmd;
2349 	uint16_t opcode;
2350 } __packed;
2351 
2352 #define BT_HCI_EVT_HARDWARE_ERROR               0x10
2353 struct bt_hci_evt_hardware_error {
2354 	uint8_t  hardware_code;
2355 } __packed;
2356 
2357 #define BT_HCI_EVT_ROLE_CHANGE                  0x12
2358 struct bt_hci_evt_role_change {
2359 	uint8_t   status;
2360 	bt_addr_t bdaddr;
2361 	uint8_t   role;
2362 } __packed;
2363 
2364 #define BT_HCI_EVT_NUM_COMPLETED_PACKETS        0x13
2365 struct bt_hci_evt_num_completed_packets {
2366 	uint8_t  num_handles;
2367 	struct bt_hci_handle_count h[0];
2368 } __packed;
2369 
2370 #define BT_HCI_EVT_PIN_CODE_REQ                 0x16
2371 struct bt_hci_evt_pin_code_req {
2372 	bt_addr_t bdaddr;
2373 } __packed;
2374 
2375 #define BT_HCI_EVT_LINK_KEY_REQ                 0x17
2376 struct bt_hci_evt_link_key_req {
2377 	bt_addr_t bdaddr;
2378 } __packed;
2379 
2380 /* Link Key types */
2381 #define BT_LK_COMBINATION                       0x00
2382 #define BT_LK_LOCAL_UNIT                        0x01
2383 #define BT_LK_REMOTE_UNIT                       0x02
2384 #define BT_LK_DEBUG_COMBINATION                 0x03
2385 #define BT_LK_UNAUTH_COMBINATION_P192           0x04
2386 #define BT_LK_AUTH_COMBINATION_P192             0x05
2387 #define BT_LK_CHANGED_COMBINATION               0x06
2388 #define BT_LK_UNAUTH_COMBINATION_P256           0x07
2389 #define BT_LK_AUTH_COMBINATION_P256             0x08
2390 
2391 #define BT_HCI_EVT_LINK_KEY_NOTIFY              0x18
2392 struct bt_hci_evt_link_key_notify {
2393 	bt_addr_t bdaddr;
2394 	uint8_t   link_key[16];
2395 	uint8_t   key_type;
2396 } __packed;
2397 
2398 /* Overflow link types */
2399 #define BT_OVERFLOW_LINK_SYNCH                  0x00
2400 #define BT_OVERFLOW_LINK_ACL                    0x01
2401 #define BT_OVERFLOW_LINK_ISO                    0x02
2402 
2403 #define BT_HCI_EVT_DATA_BUF_OVERFLOW            0x1a
2404 struct bt_hci_evt_data_buf_overflow {
2405 	uint8_t  link_type;
2406 } __packed;
2407 
2408 #define BT_HCI_EVT_INQUIRY_RESULT_WITH_RSSI     0x22
2409 struct bt_hci_evt_inquiry_result_with_rssi {
2410 	bt_addr_t addr;
2411 	uint8_t   pscan_rep_mode;
2412 	uint8_t   reserved;
2413 	uint8_t   cod[3];
2414 	uint16_t  clock_offset;
2415 	int8_t    rssi;
2416 } __packed;
2417 
2418 #define BT_HCI_EVT_REMOTE_EXT_FEATURES          0x23
2419 struct bt_hci_evt_remote_ext_features {
2420 	uint8_t  status;
2421 	uint16_t handle;
2422 	uint8_t  page;
2423 	uint8_t  max_page;
2424 	uint8_t  features[8];
2425 } __packed;
2426 
2427 #define BT_HCI_EVT_LE_PER_ADV_SYNC_ESTABLISHED_V2 0x24
2428 struct bt_hci_evt_le_per_adv_sync_established_v2 {
2429 	uint8_t status;
2430 	uint16_t handle;
2431 	uint8_t sid;
2432 	bt_addr_le_t adv_addr;
2433 	uint8_t phy;
2434 	uint16_t interval;
2435 	uint8_t clock_accuracy;
2436 	uint8_t num_subevents;
2437 	uint8_t subevent_interval;
2438 	uint8_t response_slot_delay;
2439 	uint8_t response_slot_spacing;
2440 } __packed;
2441 
2442 #define BT_HCI_EVT_LE_PER_ADVERTISING_REPORT_V2 0x25
2443 struct bt_hci_evt_le_per_advertising_report_v2 {
2444 	uint16_t handle;
2445 	int8_t tx_power;
2446 	int8_t rssi;
2447 	uint8_t cte_type;
2448 	uint16_t periodic_event_counter;
2449 	uint8_t subevent;
2450 	uint8_t data_status;
2451 	uint8_t length;
2452 	uint8_t data[0];
2453 } __packed;
2454 
2455 #define BT_HCI_EVT_LE_PAST_RECEIVED_V2 0x26
2456 struct bt_hci_evt_le_past_received_v2 {
2457 	uint8_t status;
2458 	uint16_t conn_handle;
2459 	uint16_t service_data;
2460 	uint16_t sync_handle;
2461 	uint8_t adv_sid;
2462 	bt_addr_le_t addr;
2463 	uint8_t phy;
2464 	uint16_t interval;
2465 	uint8_t clock_accuracy;
2466 	uint8_t num_subevents;
2467 	uint8_t subevent_interval;
2468 	uint8_t response_slot_delay;
2469 	uint8_t response_slot_spacing;
2470 } __packed;
2471 
2472 #define BT_HCI_EVT_LE_PER_ADV_SUBEVENT_DATA_REQUEST 0x27
2473 struct bt_hci_evt_le_per_adv_subevent_data_request {
2474 	uint8_t adv_handle;
2475 	uint8_t subevent_start;
2476 	uint8_t subevent_data_count;
2477 } __packed;
2478 
2479 #define BT_HCI_EVT_LE_PER_ADV_RESPONSE_REPORT 0x28
2480 
2481 struct bt_hci_evt_le_per_adv_response {
2482 	int8_t tx_power;
2483 	int8_t rssi;
2484 	uint8_t cte_type;
2485 	uint8_t response_slot;
2486 	uint8_t data_status;
2487 	uint8_t data_length;
2488 	uint8_t data[0];
2489 } __packed;
2490 
2491 struct bt_hci_evt_le_per_adv_response_report {
2492 	uint8_t adv_handle;
2493 	uint8_t subevent;
2494 	uint8_t tx_status;
2495 	uint8_t num_responses;
2496 	struct bt_hci_evt_le_per_adv_response responses[0];
2497 } __packed;
2498 
2499 #define BT_HCI_EVT_LE_ENH_CONN_COMPLETE_V2 0x29
2500 struct bt_hci_evt_le_enh_conn_complete_v2 {
2501 	uint8_t      status;
2502 	uint16_t     handle;
2503 	uint8_t      role;
2504 	bt_addr_le_t peer_addr;
2505 	bt_addr_t    local_rpa;
2506 	bt_addr_t    peer_rpa;
2507 	uint16_t     interval;
2508 	uint16_t     latency;
2509 	uint16_t     supv_timeout;
2510 	uint8_t      clock_accuracy;
2511 	uint8_t adv_handle;
2512 	uint16_t sync_handle;
2513 } __packed;
2514 
2515 #define BT_HCI_EVT_SYNC_CONN_COMPLETE           0x2c
2516 struct bt_hci_evt_sync_conn_complete {
2517 	uint8_t    status;
2518 	uint16_t   handle;
2519 	bt_addr_t  bdaddr;
2520 	uint8_t    link_type;
2521 	uint8_t    tx_interval;
2522 	uint8_t    retansmission_window;
2523 	uint16_t   rx_pkt_length;
2524 	uint16_t   tx_pkt_length;
2525 	uint8_t    air_mode;
2526 } __packed;
2527 
2528 #define BT_HCI_EVT_EXTENDED_INQUIRY_RESULT      0x2f
2529 struct bt_hci_evt_extended_inquiry_result {
2530 	uint8_t    num_reports;
2531 	bt_addr_t  addr;
2532 	uint8_t    pscan_rep_mode;
2533 	uint8_t    reserved;
2534 	uint8_t    cod[3];
2535 	uint16_t   clock_offset;
2536 	int8_t     rssi;
2537 	uint8_t    eir[240];
2538 } __packed;
2539 
2540 #define BT_HCI_EVT_ENCRYPT_KEY_REFRESH_COMPLETE 0x30
2541 struct bt_hci_evt_encrypt_key_refresh_complete {
2542 	uint8_t  status;
2543 	uint16_t handle;
2544 } __packed;
2545 
2546 #define BT_HCI_EVT_IO_CAPA_REQ                  0x31
2547 struct bt_hci_evt_io_capa_req {
2548 	bt_addr_t bdaddr;
2549 } __packed;
2550 
2551 #define BT_HCI_EVT_IO_CAPA_RESP                 0x32
2552 struct bt_hci_evt_io_capa_resp {
2553 	bt_addr_t bdaddr;
2554 	uint8_t   capability;
2555 	uint8_t   oob_data;
2556 	uint8_t   authentication;
2557 } __packed;
2558 
2559 #define BT_HCI_EVT_USER_CONFIRM_REQ             0x33
2560 struct bt_hci_evt_user_confirm_req {
2561 	bt_addr_t bdaddr;
2562 	uint32_t  passkey;
2563 } __packed;
2564 
2565 #define BT_HCI_EVT_USER_PASSKEY_REQ             0x34
2566 struct bt_hci_evt_user_passkey_req {
2567 	bt_addr_t bdaddr;
2568 } __packed;
2569 
2570 #define BT_HCI_EVT_SSP_COMPLETE                 0x36
2571 struct bt_hci_evt_ssp_complete {
2572 	uint8_t   status;
2573 	bt_addr_t bdaddr;
2574 } __packed;
2575 
2576 #define BT_HCI_EVT_USER_PASSKEY_NOTIFY          0x3b
2577 struct bt_hci_evt_user_passkey_notify {
2578 	bt_addr_t bdaddr;
2579 	uint32_t  passkey;
2580 } __packed;
2581 
2582 #define BT_HCI_EVT_LE_META_EVENT                0x3e
2583 struct bt_hci_evt_le_meta_event {
2584 	uint8_t  subevent;
2585 } __packed;
2586 
2587 #define BT_HCI_EVT_AUTH_PAYLOAD_TIMEOUT_EXP     0x57
2588 struct bt_hci_evt_auth_payload_timeout_exp {
2589 	uint16_t handle;
2590 } __packed;
2591 
2592 #define BT_HCI_ROLE_CENTRAL                     0x00
2593 #define BT_HCI_ROLE_PERIPHERAL                  0x01
2594 
2595 #define BT_HCI_EVT_LE_CONN_COMPLETE             0x01
2596 struct bt_hci_evt_le_conn_complete {
2597 	uint8_t      status;
2598 	uint16_t     handle;
2599 	uint8_t      role;
2600 	bt_addr_le_t peer_addr;
2601 	uint16_t     interval;
2602 	uint16_t     latency;
2603 	uint16_t     supv_timeout;
2604 	uint8_t      clock_accuracy;
2605 } __packed;
2606 
2607 #define BT_HCI_LE_RSSI_NOT_AVAILABLE            0x7F
2608 
2609 #define BT_HCI_EVT_LE_ADVERTISING_REPORT        0x02
2610 struct bt_hci_evt_le_advertising_info {
2611 	uint8_t      evt_type;
2612 	bt_addr_le_t addr;
2613 	uint8_t      length;
2614 	uint8_t      data[0];
2615 } __packed;
2616 struct bt_hci_evt_le_advertising_report {
2617 	uint8_t num_reports;
2618 	struct bt_hci_evt_le_advertising_info adv_info[0];
2619 } __packed;
2620 
2621 #define BT_HCI_EVT_LE_CONN_UPDATE_COMPLETE      0x03
2622 struct bt_hci_evt_le_conn_update_complete {
2623 	uint8_t  status;
2624 	uint16_t handle;
2625 	uint16_t interval;
2626 	uint16_t latency;
2627 	uint16_t supv_timeout;
2628 } __packed;
2629 
2630 #define BT_HCI_EVT_LE_REMOTE_FEAT_COMPLETE      0x04
2631 struct bt_hci_evt_le_remote_feat_complete {
2632 	uint8_t  status;
2633 	uint16_t handle;
2634 	uint8_t  features[8];
2635 } __packed;
2636 
2637 #define BT_HCI_EVT_LE_LTK_REQUEST               0x05
2638 struct bt_hci_evt_le_ltk_request {
2639 	uint16_t handle;
2640 	uint64_t rand;
2641 	uint16_t ediv;
2642 } __packed;
2643 
2644 #define BT_HCI_EVT_LE_CONN_PARAM_REQ            0x06
2645 struct bt_hci_evt_le_conn_param_req {
2646 	uint16_t handle;
2647 	uint16_t interval_min;
2648 	uint16_t interval_max;
2649 	uint16_t latency;
2650 	uint16_t timeout;
2651 } __packed;
2652 
2653 #define BT_HCI_EVT_LE_DATA_LEN_CHANGE           0x07
2654 struct bt_hci_evt_le_data_len_change {
2655 	uint16_t handle;
2656 	uint16_t max_tx_octets;
2657 	uint16_t max_tx_time;
2658 	uint16_t max_rx_octets;
2659 	uint16_t max_rx_time;
2660 } __packed;
2661 
2662 #define BT_HCI_EVT_LE_P256_PUBLIC_KEY_COMPLETE  0x08
2663 struct bt_hci_evt_le_p256_public_key_complete {
2664 	uint8_t status;
2665 	uint8_t key[64];
2666 } __packed;
2667 
2668 #define BT_HCI_EVT_LE_GENERATE_DHKEY_COMPLETE   0x09
2669 struct bt_hci_evt_le_generate_dhkey_complete {
2670 	uint8_t status;
2671 	uint8_t dhkey[32];
2672 } __packed;
2673 
2674 #define BT_HCI_EVT_LE_ENH_CONN_COMPLETE         0x0a
2675 struct bt_hci_evt_le_enh_conn_complete {
2676 	uint8_t      status;
2677 	uint16_t     handle;
2678 	uint8_t      role;
2679 	bt_addr_le_t peer_addr;
2680 	bt_addr_t    local_rpa;
2681 	bt_addr_t    peer_rpa;
2682 	uint16_t     interval;
2683 	uint16_t     latency;
2684 	uint16_t     supv_timeout;
2685 	uint8_t      clock_accuracy;
2686 } __packed;
2687 
2688 #define BT_HCI_EVT_LE_DIRECT_ADV_REPORT         0x0b
2689 struct bt_hci_evt_le_direct_adv_info {
2690 	uint8_t      evt_type;
2691 	bt_addr_le_t addr;
2692 	bt_addr_le_t dir_addr;
2693 	int8_t       rssi;
2694 } __packed;
2695 struct bt_hci_evt_le_direct_adv_report {
2696 	uint8_t num_reports;
2697 	struct bt_hci_evt_le_direct_adv_info direct_adv_info[0];
2698 } __packed;
2699 
2700 #define BT_HCI_EVT_LE_PHY_UPDATE_COMPLETE       0x0c
2701 struct bt_hci_evt_le_phy_update_complete {
2702 	uint8_t  status;
2703 	uint16_t handle;
2704 	uint8_t  tx_phy;
2705 	uint8_t  rx_phy;
2706 } __packed;
2707 
2708 #define BT_HCI_EVT_LE_EXT_ADVERTISING_REPORT    0x0d
2709 
2710 #define BT_HCI_LE_ADV_EVT_TYPE_CONN                 BIT(0)
2711 #define BT_HCI_LE_ADV_EVT_TYPE_SCAN                 BIT(1)
2712 #define BT_HCI_LE_ADV_EVT_TYPE_DIRECT               BIT(2)
2713 #define BT_HCI_LE_ADV_EVT_TYPE_SCAN_RSP             BIT(3)
2714 #define BT_HCI_LE_ADV_EVT_TYPE_LEGACY               BIT(4)
2715 
2716 #define BT_HCI_LE_ADV_EVT_TYPE_DATA_STATUS(ev_type) (((ev_type) >> 5) & 0x03)
2717 #define BT_HCI_LE_ADV_EVT_TYPE_DATA_STATUS_COMPLETE   0
2718 #define BT_HCI_LE_ADV_EVT_TYPE_DATA_STATUS_PARTIAL    1
2719 #define BT_HCI_LE_ADV_EVT_TYPE_DATA_STATUS_INCOMPLETE 2
2720 #define BT_HCI_LE_ADV_EVT_TYPE_DATA_STATUS_RX_FAILED  0xFF
2721 
2722 struct bt_hci_evt_le_ext_advertising_info {
2723 	uint16_t     evt_type;
2724 	bt_addr_le_t addr;
2725 	uint8_t      prim_phy;
2726 	uint8_t      sec_phy;
2727 	uint8_t      sid;
2728 	int8_t       tx_power;
2729 	int8_t       rssi;
2730 	uint16_t     interval;
2731 	bt_addr_le_t direct_addr;
2732 	uint8_t      length;
2733 	uint8_t      data[0];
2734 } __packed;
2735 struct bt_hci_evt_le_ext_advertising_report {
2736 	uint8_t num_reports;
2737 	struct bt_hci_evt_le_ext_advertising_info adv_info[0];
2738 } __packed;
2739 
2740 #define BT_HCI_EVT_LE_PER_ADV_SYNC_ESTABLISHED  0x0e
2741 struct bt_hci_evt_le_per_adv_sync_established {
2742 	uint8_t      status;
2743 	uint16_t     handle;
2744 	uint8_t      sid;
2745 	bt_addr_le_t adv_addr;
2746 	uint8_t      phy;
2747 	uint16_t     interval;
2748 	uint8_t      clock_accuracy;
2749 } __packed;
2750 
2751 #define BT_HCI_EVT_LE_PER_ADVERTISING_REPORT    0x0f
2752 struct bt_hci_evt_le_per_advertising_report {
2753 	uint16_t handle;
2754 	int8_t   tx_power;
2755 	int8_t   rssi;
2756 	uint8_t  cte_type;
2757 	uint8_t  data_status;
2758 	uint8_t  length;
2759 	uint8_t  data[0];
2760 } __packed;
2761 
2762 #define BT_HCI_EVT_LE_PER_ADV_SYNC_LOST         0x10
2763 struct bt_hci_evt_le_per_adv_sync_lost {
2764 	uint16_t handle;
2765 } __packed;
2766 
2767 #define BT_HCI_EVT_LE_SCAN_TIMEOUT              0x11
2768 
2769 #define BT_HCI_EVT_LE_ADV_SET_TERMINATED        0x12
2770 struct bt_hci_evt_le_adv_set_terminated {
2771 	uint8_t  status;
2772 	uint8_t  adv_handle;
2773 	uint16_t conn_handle;
2774 	uint8_t  num_completed_ext_adv_evts;
2775 } __packed;
2776 
2777 #define BT_HCI_EVT_LE_SCAN_REQ_RECEIVED         0x13
2778 struct bt_hci_evt_le_scan_req_received {
2779 	uint8_t      handle;
2780 	bt_addr_le_t addr;
2781 } __packed;
2782 
2783 #define BT_HCI_LE_CHAN_SEL_ALGO_1               0x00
2784 #define BT_HCI_LE_CHAN_SEL_ALGO_2               0x01
2785 
2786 #define BT_HCI_EVT_LE_CHAN_SEL_ALGO             0x14
2787 struct bt_hci_evt_le_chan_sel_algo {
2788 	uint16_t handle;
2789 	uint8_t  chan_sel_algo;
2790 } __packed;
2791 
2792 #define BT_HCI_LE_CTE_CRC_OK                    0x0
2793 #define BT_HCI_LE_CTE_CRC_ERR_CTE_BASED_TIME    0x1
2794 #define BT_HCI_LE_CTE_CRC_ERR_CTE_BASED_OTHER   0x2
2795 #define BT_HCI_LE_CTE_INSUFFICIENT_RESOURCES    0xFF
2796 
2797 #define B_HCI_LE_CTE_REPORT_SAMPLE_COUNT_MIN    0x9
2798 #define B_HCI_LE_CTE_REPORT_SAMPLE_COUNT_MAX    0x52
2799 
2800 #define BT_HCI_LE_CTE_REPORT_NO_VALID_SAMPLE    0x80
2801 
2802 #define BT_HCI_EVT_LE_CONNECTIONLESS_IQ_REPORT  0x15
2803 struct bt_hci_le_iq_sample {
2804 	int8_t i;
2805 	int8_t q;
2806 };
2807 
2808 struct bt_hci_evt_le_connectionless_iq_report {
2809 	uint16_t sync_handle;
2810 	uint8_t  chan_idx;
2811 	int16_t  rssi;
2812 	uint8_t  rssi_ant_id;
2813 	uint8_t  cte_type;
2814 	uint8_t  slot_durations;
2815 	uint8_t  packet_status;
2816 	uint16_t per_evt_counter;
2817 	uint8_t  sample_count;
2818 	struct bt_hci_le_iq_sample sample[0];
2819 } __packed;
2820 
2821 #define BT_HCI_EVT_LE_CONNECTION_IQ_REPORT      0x16
2822 struct bt_hci_evt_le_connection_iq_report {
2823 	uint16_t conn_handle;
2824 	uint8_t  rx_phy;
2825 	uint8_t  data_chan_idx;
2826 	int16_t  rssi;
2827 	uint8_t  rssi_ant_id;
2828 	uint8_t  cte_type;
2829 	uint8_t  slot_durations;
2830 	uint8_t  packet_status;
2831 	uint16_t conn_evt_counter;
2832 	uint8_t  sample_count;
2833 	struct bt_hci_le_iq_sample sample[0];
2834 } __packed;
2835 
2836 #define BT_HCI_CTE_REQ_STATUS_RSP_WITHOUT_CTE  0x0
2837 
2838 #define BT_HCI_EVT_LE_CTE_REQUEST_FAILED       0x17
2839 struct bt_hci_evt_le_cte_req_failed {
2840 	/* According to BT 5.3 Core Spec the status field may have following
2841 	 * values:
2842 	 * - BT_HCI_CTE_REQ_STATUS_RSP_WITHOUT_CTE when received LL_CTE_RSP_PDU without CTE.
2843 	 * - Other Controller error code for peer rejected request.
2844 	 */
2845 	uint8_t  status;
2846 	uint16_t conn_handle;
2847 } __packed;
2848 
2849 #define BT_HCI_EVT_LE_PAST_RECEIVED                0x18
2850 struct bt_hci_evt_le_past_received {
2851 	uint8_t      status;
2852 	uint16_t     conn_handle;
2853 	uint16_t     service_data;
2854 	uint16_t     sync_handle;
2855 	uint8_t      adv_sid;
2856 	bt_addr_le_t addr;
2857 	uint8_t      phy;
2858 	uint16_t     interval;
2859 	uint8_t      clock_accuracy;
2860 } __packed;
2861 
2862 #define BT_HCI_EVT_LE_CIS_ESTABLISHED           0x19
2863 struct bt_hci_evt_le_cis_established {
2864 	uint8_t  status;
2865 	uint16_t conn_handle;
2866 	uint8_t  cig_sync_delay[3];
2867 	uint8_t  cis_sync_delay[3];
2868 	uint8_t  c_latency[3];
2869 	uint8_t  p_latency[3];
2870 	uint8_t  c_phy;
2871 	uint8_t  p_phy;
2872 	uint8_t  nse;
2873 	uint8_t  c_bn;
2874 	uint8_t  p_bn;
2875 	uint8_t  c_ft;
2876 	uint8_t  p_ft;
2877 	uint16_t c_max_pdu;
2878 	uint16_t p_max_pdu;
2879 	uint16_t interval;
2880 } __packed;
2881 
2882 #define BT_HCI_EVT_LE_CIS_REQ                   0x1a
2883 struct bt_hci_evt_le_cis_req {
2884 	uint16_t acl_handle;
2885 	uint16_t cis_handle;
2886 	uint8_t  cig_id;
2887 	uint8_t  cis_id;
2888 } __packed;
2889 
2890 #define BT_HCI_EVT_LE_BIG_COMPLETE              0x1b
2891 struct bt_hci_evt_le_big_complete {
2892 	uint8_t  status;
2893 	uint8_t  big_handle;
2894 	uint8_t  sync_delay[3];
2895 	uint8_t  latency[3];
2896 	uint8_t  phy;
2897 	uint8_t  nse;
2898 	uint8_t  bn;
2899 	uint8_t  pto;
2900 	uint8_t  irc;
2901 	uint16_t max_pdu;
2902 	uint16_t iso_interval;
2903 	uint8_t  num_bis;
2904 	uint16_t handle[0];
2905 } __packed;
2906 
2907 #define BT_HCI_EVT_LE_BIG_TERMINATE             0x1c
2908 struct bt_hci_evt_le_big_terminate {
2909 	uint8_t  big_handle;
2910 	uint8_t  reason;
2911 } __packed;
2912 
2913 #define BT_HCI_EVT_LE_BIG_SYNC_ESTABLISHED      0x1d
2914 struct bt_hci_evt_le_big_sync_established {
2915 	uint8_t  status;
2916 	uint8_t  big_handle;
2917 	uint8_t  latency[3];
2918 	uint8_t  nse;
2919 	uint8_t  bn;
2920 	uint8_t  pto;
2921 	uint8_t  irc;
2922 	uint16_t max_pdu;
2923 	uint16_t iso_interval;
2924 	uint8_t  num_bis;
2925 	uint16_t handle[0];
2926 } __packed;
2927 
2928 #define BT_HCI_EVT_LE_BIG_SYNC_LOST             0x1e
2929 struct bt_hci_evt_le_big_sync_lost {
2930 	uint8_t  big_handle;
2931 	uint8_t  reason;
2932 } __packed;
2933 
2934 #define BT_HCI_EVT_LE_REQ_PEER_SCA_COMPLETE     0x1f
2935 struct bt_hci_evt_le_req_peer_sca_complete {
2936 	uint8_t  status;
2937 	uint16_t handle;
2938 	uint8_t  sca;
2939 } __packed;
2940 
2941 /** Reason for Transmit power reporting.
2942  */
2943 /* Local Transmit power changed. */
2944 #define	BT_HCI_LE_TX_POWER_REPORT_REASON_LOCAL_CHANGED         0x00
2945 /* Remote Transmit power changed. */
2946 #define	BT_HCI_LE_TX_POWER_REPORT_REASON_REMOTE_CHANGED        0x01
2947 /* HCI_LE_Read_Remote_Transmit_Power_Level command completed. */
2948 #define	BT_HCI_LE_TX_POWER_REPORT_REASON_READ_REMOTE_COMPLETED 0x02
2949 
2950 #define BT_HCI_EVT_LE_TRANSMIT_POWER_REPORT     0x21
2951 struct bt_hci_evt_le_transmit_power_report {
2952 	uint8_t	 status;
2953 	uint16_t handle;
2954 	uint8_t  reason;
2955 	uint8_t  phy;
2956 	int8_t   tx_power_level;
2957 	uint8_t  tx_power_level_flag;
2958 	int8_t   delta;
2959 } __packed;
2960 
2961 #define BT_HCI_EVT_LE_BIGINFO_ADV_REPORT        0x22
2962 struct bt_hci_evt_le_biginfo_adv_report {
2963 	uint16_t sync_handle;
2964 	uint8_t  num_bis;
2965 	uint8_t  nse;
2966 	uint16_t iso_interval;
2967 	uint8_t  bn;
2968 	uint8_t  pto;
2969 	uint8_t  irc;
2970 	uint16_t max_pdu;
2971 	uint8_t  sdu_interval[3];
2972 	uint16_t max_sdu;
2973 	uint8_t  phy;
2974 	uint8_t  framing;
2975 	uint8_t  encryption;
2976 } __packed;
2977 
2978 /* Event mask bits */
2979 
2980 #define BT_EVT_BIT(n) (1ULL << (n))
2981 
2982 #define BT_EVT_MASK_INQUIRY_COMPLETE             BT_EVT_BIT(0)
2983 #define BT_EVT_MASK_CONN_COMPLETE                BT_EVT_BIT(2)
2984 #define BT_EVT_MASK_CONN_REQUEST                 BT_EVT_BIT(3)
2985 #define BT_EVT_MASK_DISCONN_COMPLETE             BT_EVT_BIT(4)
2986 #define BT_EVT_MASK_AUTH_COMPLETE                BT_EVT_BIT(5)
2987 #define BT_EVT_MASK_REMOTE_NAME_REQ_COMPLETE     BT_EVT_BIT(6)
2988 #define BT_EVT_MASK_ENCRYPT_CHANGE               BT_EVT_BIT(7)
2989 #define BT_EVT_MASK_REMOTE_FEATURES              BT_EVT_BIT(10)
2990 #define BT_EVT_MASK_REMOTE_VERSION_INFO          BT_EVT_BIT(11)
2991 #define BT_EVT_MASK_HARDWARE_ERROR               BT_EVT_BIT(15)
2992 #define BT_EVT_MASK_ROLE_CHANGE                  BT_EVT_BIT(17)
2993 #define BT_EVT_MASK_PIN_CODE_REQ                 BT_EVT_BIT(21)
2994 #define BT_EVT_MASK_LINK_KEY_REQ                 BT_EVT_BIT(22)
2995 #define BT_EVT_MASK_LINK_KEY_NOTIFY              BT_EVT_BIT(23)
2996 #define BT_EVT_MASK_DATA_BUFFER_OVERFLOW         BT_EVT_BIT(25)
2997 #define BT_EVT_MASK_INQUIRY_RESULT_WITH_RSSI     BT_EVT_BIT(33)
2998 #define BT_EVT_MASK_REMOTE_EXT_FEATURES          BT_EVT_BIT(34)
2999 #define BT_EVT_MASK_SYNC_CONN_COMPLETE           BT_EVT_BIT(43)
3000 #define BT_EVT_MASK_EXTENDED_INQUIRY_RESULT      BT_EVT_BIT(46)
3001 #define BT_EVT_MASK_ENCRYPT_KEY_REFRESH_COMPLETE BT_EVT_BIT(47)
3002 #define BT_EVT_MASK_IO_CAPA_REQ                  BT_EVT_BIT(48)
3003 #define BT_EVT_MASK_IO_CAPA_RESP                 BT_EVT_BIT(49)
3004 #define BT_EVT_MASK_USER_CONFIRM_REQ             BT_EVT_BIT(50)
3005 #define BT_EVT_MASK_USER_PASSKEY_REQ             BT_EVT_BIT(51)
3006 #define BT_EVT_MASK_SSP_COMPLETE                 BT_EVT_BIT(53)
3007 #define BT_EVT_MASK_USER_PASSKEY_NOTIFY          BT_EVT_BIT(58)
3008 #define BT_EVT_MASK_LE_META_EVENT                BT_EVT_BIT(61)
3009 
3010 /* Page 2 */
3011 #define BT_EVT_MASK_NUM_COMPLETE_DATA_BLOCKS     BT_EVT_BIT(8)
3012 #define BT_EVT_MASK_TRIGG_CLOCK_CAPTURE          BT_EVT_BIT(14)
3013 #define BT_EVT_MASK_SYNCH_TRAIN_COMPLETE         BT_EVT_BIT(15)
3014 #define BT_EVT_MASK_SYNCH_TRAIN_RX               BT_EVT_BIT(16)
3015 #define BT_EVT_MASK_CL_PER_BC_RX                 BT_EVT_BIT(17)
3016 #define BT_EVT_MASK_CL_PER_BC_TIMEOUT            BT_EVT_BIT(18)
3017 #define BT_EVT_MASK_TRUNC_PAGE_COMPLETE          BT_EVT_BIT(19)
3018 #define BT_EVT_MASK_PER_PAGE_RSP_TIMEOUT         BT_EVT_BIT(20)
3019 #define BT_EVT_MASK_CL_PER_BC_CH_MAP_CHANGE      BT_EVT_BIT(21)
3020 #define BT_EVT_MASK_INQUIRY_RSP_NOT              BT_EVT_BIT(22)
3021 #define BT_EVT_MASK_AUTH_PAYLOAD_TIMEOUT_EXP     BT_EVT_BIT(23)
3022 #define BT_EVT_MASK_SAM_STATUS_CHANGE            BT_EVT_BIT(24)
3023 
3024 #define BT_EVT_MASK_LE_CONN_COMPLETE             BT_EVT_BIT(0)
3025 #define BT_EVT_MASK_LE_ADVERTISING_REPORT        BT_EVT_BIT(1)
3026 #define BT_EVT_MASK_LE_CONN_UPDATE_COMPLETE      BT_EVT_BIT(2)
3027 #define BT_EVT_MASK_LE_REMOTE_FEAT_COMPLETE      BT_EVT_BIT(3)
3028 #define BT_EVT_MASK_LE_LTK_REQUEST               BT_EVT_BIT(4)
3029 #define BT_EVT_MASK_LE_CONN_PARAM_REQ            BT_EVT_BIT(5)
3030 #define BT_EVT_MASK_LE_DATA_LEN_CHANGE           BT_EVT_BIT(6)
3031 #define BT_EVT_MASK_LE_P256_PUBLIC_KEY_COMPLETE  BT_EVT_BIT(7)
3032 #define BT_EVT_MASK_LE_GENERATE_DHKEY_COMPLETE   BT_EVT_BIT(8)
3033 #define BT_EVT_MASK_LE_ENH_CONN_COMPLETE         BT_EVT_BIT(9)
3034 #define BT_EVT_MASK_LE_DIRECT_ADV_REPORT         BT_EVT_BIT(10)
3035 #define BT_EVT_MASK_LE_PHY_UPDATE_COMPLETE       BT_EVT_BIT(11)
3036 #define BT_EVT_MASK_LE_EXT_ADVERTISING_REPORT    BT_EVT_BIT(12)
3037 #define BT_EVT_MASK_LE_PER_ADV_SYNC_ESTABLISHED  BT_EVT_BIT(13)
3038 #define BT_EVT_MASK_LE_PER_ADVERTISING_REPORT    BT_EVT_BIT(14)
3039 #define BT_EVT_MASK_LE_PER_ADV_SYNC_LOST         BT_EVT_BIT(15)
3040 #define BT_EVT_MASK_LE_SCAN_TIMEOUT              BT_EVT_BIT(16)
3041 #define BT_EVT_MASK_LE_ADV_SET_TERMINATED        BT_EVT_BIT(17)
3042 #define BT_EVT_MASK_LE_SCAN_REQ_RECEIVED         BT_EVT_BIT(18)
3043 #define BT_EVT_MASK_LE_CHAN_SEL_ALGO             BT_EVT_BIT(19)
3044 #define BT_EVT_MASK_LE_CONNECTIONLESS_IQ_REPORT  BT_EVT_BIT(20)
3045 #define BT_EVT_MASK_LE_CONNECTION_IQ_REPORT      BT_EVT_BIT(21)
3046 #define BT_EVT_MASK_LE_CTE_REQUEST_FAILED        BT_EVT_BIT(22)
3047 #define BT_EVT_MASK_LE_PAST_RECEIVED             BT_EVT_BIT(23)
3048 #define BT_EVT_MASK_LE_CIS_ESTABLISHED           BT_EVT_BIT(24)
3049 #define BT_EVT_MASK_LE_CIS_REQ                   BT_EVT_BIT(25)
3050 #define BT_EVT_MASK_LE_BIG_COMPLETE              BT_EVT_BIT(26)
3051 #define BT_EVT_MASK_LE_BIG_TERMINATED            BT_EVT_BIT(27)
3052 #define BT_EVT_MASK_LE_BIG_SYNC_ESTABLISHED      BT_EVT_BIT(28)
3053 #define BT_EVT_MASK_LE_BIG_SYNC_LOST             BT_EVT_BIT(29)
3054 #define BT_EVT_MASK_LE_REQ_PEER_SCA_COMPLETE     BT_EVT_BIT(30)
3055 #define BT_EVT_MASK_LE_PATH_LOSS_THRESHOLD       BT_EVT_BIT(31)
3056 #define BT_EVT_MASK_LE_TRANSMIT_POWER_REPORTING  BT_EVT_BIT(32)
3057 #define BT_EVT_MASK_LE_BIGINFO_ADV_REPORT        BT_EVT_BIT(33)
3058 
3059 #define BT_EVT_MASK_LE_PER_ADV_SYNC_ESTABLISHED_V2 BT_EVT_BIT(35)
3060 #define BT_EVT_MASK_LE_PER_ADVERTISING_REPORT_V2   BT_EVT_BIT(36)
3061 #define BT_EVT_MASK_LE_PAST_RECEIVED_V2            BT_EVT_BIT(37)
3062 #define BT_EVT_MASK_LE_PER_ADV_SUBEVENT_DATA_REQ   BT_EVT_BIT(38)
3063 #define BT_EVT_MASK_LE_PER_ADV_RESPONSE_REPORT     BT_EVT_BIT(39)
3064 #define BT_EVT_MASK_LE_ENH_CONN_COMPLETE_V2        BT_EVT_BIT(40)
3065 
3066 /** HCI Error Codes, BT Core Spec v5.4 [Vol 1, Part F]. */
3067 #define BT_HCI_ERR_SUCCESS                      0x00
3068 #define BT_HCI_ERR_UNKNOWN_CMD                  0x01
3069 #define BT_HCI_ERR_UNKNOWN_CONN_ID              0x02
3070 #define BT_HCI_ERR_HW_FAILURE                   0x03
3071 #define BT_HCI_ERR_PAGE_TIMEOUT                 0x04
3072 #define BT_HCI_ERR_AUTH_FAIL                    0x05
3073 #define BT_HCI_ERR_PIN_OR_KEY_MISSING           0x06
3074 #define BT_HCI_ERR_MEM_CAPACITY_EXCEEDED        0x07
3075 #define BT_HCI_ERR_CONN_TIMEOUT                 0x08
3076 #define BT_HCI_ERR_CONN_LIMIT_EXCEEDED          0x09
3077 #define BT_HCI_ERR_SYNC_CONN_LIMIT_EXCEEDED     0x0a
3078 #define BT_HCI_ERR_CONN_ALREADY_EXISTS          0x0b
3079 #define BT_HCI_ERR_CMD_DISALLOWED               0x0c
3080 #define BT_HCI_ERR_INSUFFICIENT_RESOURCES       0x0d
3081 #define BT_HCI_ERR_INSUFFICIENT_SECURITY        0x0e
3082 #define BT_HCI_ERR_BD_ADDR_UNACCEPTABLE         0x0f
3083 #define BT_HCI_ERR_CONN_ACCEPT_TIMEOUT          0x10
3084 #define BT_HCI_ERR_UNSUPP_FEATURE_PARAM_VAL     0x11
3085 #define BT_HCI_ERR_INVALID_PARAM                0x12
3086 #define BT_HCI_ERR_REMOTE_USER_TERM_CONN        0x13
3087 #define BT_HCI_ERR_REMOTE_LOW_RESOURCES         0x14
3088 #define BT_HCI_ERR_REMOTE_POWER_OFF             0x15
3089 #define BT_HCI_ERR_LOCALHOST_TERM_CONN          0x16
3090 #define BT_HCI_ERR_REPEATED_ATTEMPTS            0x17
3091 #define BT_HCI_ERR_PAIRING_NOT_ALLOWED          0x18
3092 #define BT_HCI_ERR_UNKNOWN_LMP_PDU              0x19
3093 #define BT_HCI_ERR_UNSUPP_REMOTE_FEATURE        0x1a
3094 #define BT_HCI_ERR_SCO_OFFSET_REJECTED          0x1b
3095 #define BT_HCI_ERR_SCO_INTERVAL_REJECTED        0x1c
3096 #define BT_HCI_ERR_SCO_AIR_MODE_REJECTED        0x1d
3097 #define BT_HCI_ERR_INVALID_LL_PARAM             0x1e
3098 #define BT_HCI_ERR_UNSPECIFIED                  0x1f
3099 #define BT_HCI_ERR_UNSUPP_LL_PARAM_VAL          0x20
3100 #define BT_HCI_ERR_ROLE_CHANGE_NOT_ALLOWED      0x21
3101 #define BT_HCI_ERR_LL_RESP_TIMEOUT              0x22
3102 #define BT_HCI_ERR_LL_PROC_COLLISION            0x23
3103 #define BT_HCI_ERR_LMP_PDU_NOT_ALLOWED          0x24
3104 #define BT_HCI_ERR_ENC_MODE_NOT_ACCEPTABLE      0x25
3105 #define BT_HCI_ERR_LINK_KEY_CANNOT_BE_CHANGED   0x26
3106 #define BT_HCI_ERR_REQUESTED_QOS_NOT_SUPPORTED  0x27
3107 #define BT_HCI_ERR_INSTANT_PASSED               0x28
3108 #define BT_HCI_ERR_PAIRING_NOT_SUPPORTED        0x29
3109 #define BT_HCI_ERR_DIFF_TRANS_COLLISION         0x2a
3110 #define BT_HCI_ERR_QOS_UNACCEPTABLE_PARAM       0x2c
3111 #define BT_HCI_ERR_QOS_REJECTED                 0x2d
3112 #define BT_HCI_ERR_CHAN_ASSESS_NOT_SUPPORTED    0x2e
3113 #define BT_HCI_ERR_INSUFF_SECURITY              0x2f
3114 #define BT_HCI_ERR_PARAM_OUT_OF_MANDATORY_RANGE 0x30
3115 #define BT_HCI_ERR_ROLE_SWITCH_PENDING          0x32
3116 #define BT_HCI_ERR_RESERVED_SLOT_VIOLATION      0x34
3117 #define BT_HCI_ERR_ROLE_SWITCH_FAILED           0x35
3118 #define BT_HCI_ERR_EXT_INQ_RESP_TOO_LARGE       0x36
3119 #define BT_HCI_ERR_SIMPLE_PAIR_NOT_SUPP_BY_HOST 0x37
3120 #define BT_HCI_ERR_HOST_BUSY_PAIRING            0x38
3121 #define BT_HCI_ERR_CONN_REJECTED_DUE_TO_NO_CHAN 0x39
3122 #define BT_HCI_ERR_CONTROLLER_BUSY              0x3a
3123 #define BT_HCI_ERR_UNACCEPT_CONN_PARAM          0x3b
3124 #define BT_HCI_ERR_ADV_TIMEOUT                  0x3c
3125 #define BT_HCI_ERR_TERM_DUE_TO_MIC_FAIL         0x3d
3126 #define BT_HCI_ERR_CONN_FAIL_TO_ESTAB           0x3e
3127 #define BT_HCI_ERR_MAC_CONN_FAILED              0x3f
3128 #define BT_HCI_ERR_CLOCK_ADJUST_REJECTED        0x40
3129 #define BT_HCI_ERR_SUBMAP_NOT_DEFINED           0x41
3130 #define BT_HCI_ERR_UNKNOWN_ADV_IDENTIFIER       0x42
3131 #define BT_HCI_ERR_LIMIT_REACHED                0x43
3132 #define BT_HCI_ERR_OP_CANCELLED_BY_HOST         0x44
3133 #define BT_HCI_ERR_PACKET_TOO_LONG              0x45
3134 #define BT_HCI_ERR_TOO_LATE                     0x46
3135 #define BT_HCI_ERR_TOO_EARLY                    0x47
3136 
3137 #ifdef __cplusplus
3138 }
3139 #endif
3140 
3141 #endif /* ZEPHYR_INCLUDE_BLUETOOTH_HCI_TYPES_H_ */
3142