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