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