xref: /openbmc/linux/include/net/bluetooth/hci.h (revision b8c5a806)
1 /*
2    BlueZ - Bluetooth protocol stack for Linux
3    Copyright (C) 2000-2001 Qualcomm Incorporated
4 
5    Written 2000,2001 by Maxim Krasnyansky <maxk@qualcomm.com>
6 
7    This program is free software; you can redistribute it and/or modify
8    it under the terms of the GNU General Public License version 2 as
9    published by the Free Software Foundation;
10 
11    THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
12    OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
13    FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF THIRD PARTY RIGHTS.
14    IN NO EVENT SHALL THE COPYRIGHT HOLDER(S) AND AUTHOR(S) BE LIABLE FOR ANY
15    CLAIM, OR ANY SPECIAL INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES
16    WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
17    ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
18    OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
19 
20    ALL LIABILITY, INCLUDING LIABILITY FOR INFRINGEMENT OF ANY PATENTS,
21    COPYRIGHTS, TRADEMARKS OR OTHER RIGHTS, RELATING TO USE OF THIS
22    SOFTWARE IS DISCLAIMED.
23 */
24 
25 #ifndef __HCI_H
26 #define __HCI_H
27 
28 #define HCI_MAX_ACL_SIZE	1024
29 #define HCI_MAX_SCO_SIZE	255
30 #define HCI_MAX_ISO_SIZE	251
31 #define HCI_MAX_EVENT_SIZE	260
32 #define HCI_MAX_FRAME_SIZE	(HCI_MAX_ACL_SIZE + 4)
33 
34 #define HCI_LINK_KEY_SIZE	16
35 #define HCI_AMP_LINK_KEY_SIZE	(2 * HCI_LINK_KEY_SIZE)
36 
37 #define HCI_MAX_AMP_ASSOC_SIZE	672
38 
39 #define HCI_MAX_CSB_DATA_SIZE	252
40 
41 /* HCI dev events */
42 #define HCI_DEV_REG			1
43 #define HCI_DEV_UNREG			2
44 #define HCI_DEV_UP			3
45 #define HCI_DEV_DOWN			4
46 #define HCI_DEV_SUSPEND			5
47 #define HCI_DEV_RESUME			6
48 #define HCI_DEV_OPEN			7
49 #define HCI_DEV_CLOSE			8
50 #define HCI_DEV_SETUP			9
51 
52 /* HCI notify events */
53 #define HCI_NOTIFY_CONN_ADD		1
54 #define HCI_NOTIFY_CONN_DEL		2
55 #define HCI_NOTIFY_VOICE_SETTING	3
56 
57 /* HCI bus types */
58 #define HCI_VIRTUAL	0
59 #define HCI_USB		1
60 #define HCI_PCCARD	2
61 #define HCI_UART	3
62 #define HCI_RS232	4
63 #define HCI_PCI		5
64 #define HCI_SDIO	6
65 #define HCI_SPI		7
66 #define HCI_I2C		8
67 #define HCI_SMD		9
68 
69 /* HCI controller types */
70 #define HCI_PRIMARY	0x00
71 #define HCI_AMP		0x01
72 
73 /* First BR/EDR Controller shall have ID = 0 */
74 #define AMP_ID_BREDR	0x00
75 
76 /* AMP controller types */
77 #define AMP_TYPE_BREDR	0x00
78 #define AMP_TYPE_80211	0x01
79 
80 /* AMP controller status */
81 #define AMP_STATUS_POWERED_DOWN			0x00
82 #define AMP_STATUS_BLUETOOTH_ONLY		0x01
83 #define AMP_STATUS_NO_CAPACITY			0x02
84 #define AMP_STATUS_LOW_CAPACITY			0x03
85 #define AMP_STATUS_MEDIUM_CAPACITY		0x04
86 #define AMP_STATUS_HIGH_CAPACITY		0x05
87 #define AMP_STATUS_FULL_CAPACITY		0x06
88 
89 /* HCI device quirks */
90 enum {
91 	/* When this quirk is set, the HCI Reset command is send when
92 	 * closing the transport instead of when opening it.
93 	 *
94 	 * This quirk must be set before hci_register_dev is called.
95 	 */
96 	HCI_QUIRK_RESET_ON_CLOSE,
97 
98 	/* When this quirk is set, the device is turned into a raw-only
99 	 * device and it will stay in unconfigured state.
100 	 *
101 	 * This quirk must be set before hci_register_dev is called.
102 	 */
103 	HCI_QUIRK_RAW_DEVICE,
104 
105 	/* When this quirk is set, the buffer sizes reported by
106 	 * HCI Read Buffer Size command are corrected if invalid.
107 	 *
108 	 * This quirk must be set before hci_register_dev is called.
109 	 */
110 	HCI_QUIRK_FIXUP_BUFFER_SIZE,
111 
112 	/* When this quirk is set, then a controller that does not
113 	 * indicate support for Inquiry Result with RSSI is assumed to
114 	 * support it anyway. Some early Bluetooth 1.2 controllers had
115 	 * wrongly configured local features that will require forcing
116 	 * them to enable this mode. Getting RSSI information with the
117 	 * inquiry responses is preferred since it allows for a better
118 	 * user experience.
119 	 *
120 	 * This quirk must be set before hci_register_dev is called.
121 	 */
122 	HCI_QUIRK_FIXUP_INQUIRY_MODE,
123 
124 	/* When this quirk is set, then the HCI Read Local Supported
125 	 * Commands command is not supported. In general Bluetooth 1.2
126 	 * and later controllers should support this command. However
127 	 * some controllers indicate Bluetooth 1.2 support, but do
128 	 * not support this command.
129 	 *
130 	 * This quirk must be set before hci_register_dev is called.
131 	 */
132 	HCI_QUIRK_BROKEN_LOCAL_COMMANDS,
133 
134 	/* When this quirk is set, then no stored link key handling
135 	 * is performed. This is mainly due to the fact that the
136 	 * HCI Delete Stored Link Key command is advertised, but
137 	 * not supported.
138 	 *
139 	 * This quirk must be set before hci_register_dev is called.
140 	 */
141 	HCI_QUIRK_BROKEN_STORED_LINK_KEY,
142 
143 	/* When this quirk is set, an external configuration step
144 	 * is required and will be indicated with the controller
145 	 * configuration.
146 	 *
147 	 * This quirk can be set before hci_register_dev is called or
148 	 * during the hdev->setup vendor callback.
149 	 */
150 	HCI_QUIRK_EXTERNAL_CONFIG,
151 
152 	/* When this quirk is set, the public Bluetooth address
153 	 * initially reported by HCI Read BD Address command
154 	 * is considered invalid. Controller configuration is
155 	 * required before this device can be used.
156 	 *
157 	 * This quirk can be set before hci_register_dev is called or
158 	 * during the hdev->setup vendor callback.
159 	 */
160 	HCI_QUIRK_INVALID_BDADDR,
161 
162 	/* When this quirk is set, the public Bluetooth address
163 	 * initially reported by HCI Read BD Address command
164 	 * is considered invalid. The public BD Address can be
165 	 * specified in the fwnode property 'local-bd-address'.
166 	 * If this property does not exist or is invalid controller
167 	 * configuration is required before this device can be used.
168 	 *
169 	 * This quirk can be set before hci_register_dev is called or
170 	 * during the hdev->setup vendor callback.
171 	 */
172 	HCI_QUIRK_USE_BDADDR_PROPERTY,
173 
174 	/* When this quirk is set, the duplicate filtering during
175 	 * scanning is based on Bluetooth devices addresses. To allow
176 	 * RSSI based updates, restart scanning if needed.
177 	 *
178 	 * This quirk can be set before hci_register_dev is called or
179 	 * during the hdev->setup vendor callback.
180 	 */
181 	HCI_QUIRK_STRICT_DUPLICATE_FILTER,
182 
183 	/* When this quirk is set, LE scan and BR/EDR inquiry is done
184 	 * simultaneously, otherwise it's interleaved.
185 	 *
186 	 * This quirk can be set before hci_register_dev is called or
187 	 * during the hdev->setup vendor callback.
188 	 */
189 	HCI_QUIRK_SIMULTANEOUS_DISCOVERY,
190 
191 	/* When this quirk is set, the enabling of diagnostic mode is
192 	 * not persistent over HCI Reset. Every time the controller
193 	 * is brought up it needs to be reprogrammed.
194 	 *
195 	 * This quirk can be set before hci_register_dev is called or
196 	 * during the hdev->setup vendor callback.
197 	 */
198 	HCI_QUIRK_NON_PERSISTENT_DIAG,
199 
200 	/* When this quirk is set, setup() would be run after every
201 	 * open() and not just after the first open().
202 	 *
203 	 * This quirk can be set before hci_register_dev is called or
204 	 * during the hdev->setup vendor callback.
205 	 *
206 	 */
207 	HCI_QUIRK_NON_PERSISTENT_SETUP,
208 
209 	/* When this quirk is set, wide band speech is supported by
210 	 * the driver since no reliable mechanism exist to report
211 	 * this from the hardware, a driver flag is use to convey
212 	 * this support
213 	 *
214 	 * This quirk must be set before hci_register_dev is called.
215 	 */
216 	HCI_QUIRK_WIDEBAND_SPEECH_SUPPORTED,
217 };
218 
219 /* HCI device flags */
220 enum {
221 	HCI_UP,
222 	HCI_INIT,
223 	HCI_RUNNING,
224 
225 	HCI_PSCAN,
226 	HCI_ISCAN,
227 	HCI_AUTH,
228 	HCI_ENCRYPT,
229 	HCI_INQUIRY,
230 
231 	HCI_RAW,
232 
233 	HCI_RESET,
234 };
235 
236 /* HCI socket flags */
237 enum {
238 	HCI_SOCK_TRUSTED,
239 	HCI_MGMT_INDEX_EVENTS,
240 	HCI_MGMT_UNCONF_INDEX_EVENTS,
241 	HCI_MGMT_EXT_INDEX_EVENTS,
242 	HCI_MGMT_EXT_INFO_EVENTS,
243 	HCI_MGMT_OPTION_EVENTS,
244 	HCI_MGMT_SETTING_EVENTS,
245 	HCI_MGMT_DEV_CLASS_EVENTS,
246 	HCI_MGMT_LOCAL_NAME_EVENTS,
247 	HCI_MGMT_OOB_DATA_EVENTS,
248 };
249 
250 /*
251  * BR/EDR and/or LE controller flags: the flags defined here should represent
252  * states from the controller.
253  */
254 enum {
255 	HCI_SETUP,
256 	HCI_CONFIG,
257 	HCI_AUTO_OFF,
258 	HCI_RFKILLED,
259 	HCI_MGMT,
260 	HCI_BONDABLE,
261 	HCI_SERVICE_CACHE,
262 	HCI_KEEP_DEBUG_KEYS,
263 	HCI_USE_DEBUG_KEYS,
264 	HCI_UNREGISTER,
265 	HCI_UNCONFIGURED,
266 	HCI_USER_CHANNEL,
267 	HCI_EXT_CONFIGURED,
268 	HCI_LE_ADV,
269 	HCI_LE_SCAN,
270 	HCI_SSP_ENABLED,
271 	HCI_SC_ENABLED,
272 	HCI_SC_ONLY,
273 	HCI_PRIVACY,
274 	HCI_LIMITED_PRIVACY,
275 	HCI_RPA_EXPIRED,
276 	HCI_RPA_RESOLVING,
277 	HCI_HS_ENABLED,
278 	HCI_LE_ENABLED,
279 	HCI_ADVERTISING,
280 	HCI_ADVERTISING_CONNECTABLE,
281 	HCI_CONNECTABLE,
282 	HCI_DISCOVERABLE,
283 	HCI_LIMITED_DISCOVERABLE,
284 	HCI_LINK_SECURITY,
285 	HCI_PERIODIC_INQ,
286 	HCI_FAST_CONNECTABLE,
287 	HCI_BREDR_ENABLED,
288 	HCI_LE_SCAN_INTERRUPTED,
289 	HCI_WIDEBAND_SPEECH_ENABLED,
290 
291 	HCI_DUT_MODE,
292 	HCI_VENDOR_DIAG,
293 	HCI_FORCE_BREDR_SMP,
294 	HCI_FORCE_STATIC_ADDR,
295 	HCI_LL_RPA_RESOLUTION,
296 	HCI_CMD_PENDING,
297 
298 	__HCI_NUM_FLAGS,
299 };
300 
301 /* HCI timeouts */
302 #define HCI_DISCONN_TIMEOUT	msecs_to_jiffies(2000)	/* 2 seconds */
303 #define HCI_PAIRING_TIMEOUT	msecs_to_jiffies(60000)	/* 60 seconds */
304 #define HCI_INIT_TIMEOUT	msecs_to_jiffies(10000)	/* 10 seconds */
305 #define HCI_CMD_TIMEOUT		msecs_to_jiffies(2000)	/* 2 seconds */
306 #define HCI_ACL_TX_TIMEOUT	msecs_to_jiffies(45000)	/* 45 seconds */
307 #define HCI_AUTO_OFF_TIMEOUT	msecs_to_jiffies(2000)	/* 2 seconds */
308 #define HCI_POWER_OFF_TIMEOUT	msecs_to_jiffies(5000)	/* 5 seconds */
309 #define HCI_LE_CONN_TIMEOUT	msecs_to_jiffies(20000)	/* 20 seconds */
310 #define HCI_LE_AUTOCONN_TIMEOUT	msecs_to_jiffies(4000)	/* 4 seconds */
311 
312 /* HCI data types */
313 #define HCI_COMMAND_PKT		0x01
314 #define HCI_ACLDATA_PKT		0x02
315 #define HCI_SCODATA_PKT		0x03
316 #define HCI_EVENT_PKT		0x04
317 #define HCI_ISODATA_PKT		0x05
318 #define HCI_DIAG_PKT		0xf0
319 #define HCI_VENDOR_PKT		0xff
320 
321 /* HCI packet types */
322 #define HCI_DM1		0x0008
323 #define HCI_DM3		0x0400
324 #define HCI_DM5		0x4000
325 #define HCI_DH1		0x0010
326 #define HCI_DH3		0x0800
327 #define HCI_DH5		0x8000
328 
329 /* HCI packet types inverted masks */
330 #define HCI_2DH1	0x0002
331 #define HCI_3DH1	0x0004
332 #define HCI_2DH3	0x0100
333 #define HCI_3DH3	0x0200
334 #define HCI_2DH5	0x1000
335 #define HCI_3DH5	0x2000
336 
337 #define HCI_HV1		0x0020
338 #define HCI_HV2		0x0040
339 #define HCI_HV3		0x0080
340 
341 #define SCO_PTYPE_MASK	(HCI_HV1 | HCI_HV2 | HCI_HV3)
342 #define ACL_PTYPE_MASK	(~SCO_PTYPE_MASK)
343 
344 /* eSCO packet types */
345 #define ESCO_HV1	0x0001
346 #define ESCO_HV2	0x0002
347 #define ESCO_HV3	0x0004
348 #define ESCO_EV3	0x0008
349 #define ESCO_EV4	0x0010
350 #define ESCO_EV5	0x0020
351 #define ESCO_2EV3	0x0040
352 #define ESCO_3EV3	0x0080
353 #define ESCO_2EV5	0x0100
354 #define ESCO_3EV5	0x0200
355 
356 #define SCO_ESCO_MASK  (ESCO_HV1 | ESCO_HV2 | ESCO_HV3)
357 #define EDR_ESCO_MASK  (ESCO_2EV3 | ESCO_3EV3 | ESCO_2EV5 | ESCO_3EV5)
358 
359 /* ACL flags */
360 #define ACL_START_NO_FLUSH	0x00
361 #define ACL_CONT		0x01
362 #define ACL_START		0x02
363 #define ACL_COMPLETE		0x03
364 #define ACL_ACTIVE_BCAST	0x04
365 #define ACL_PICO_BCAST		0x08
366 
367 /* ISO PB flags */
368 #define ISO_START		0x00
369 #define ISO_CONT		0x01
370 #define ISO_SINGLE		0x02
371 #define ISO_END			0x03
372 
373 /* ISO TS flags */
374 #define ISO_TS			0x01
375 
376 /* Baseband links */
377 #define SCO_LINK	0x00
378 #define ACL_LINK	0x01
379 #define ESCO_LINK	0x02
380 /* Low Energy links do not have defined link type. Use invented one */
381 #define LE_LINK		0x80
382 #define AMP_LINK	0x81
383 #define ISO_LINK	0x82
384 #define INVALID_LINK	0xff
385 
386 /* LMP features */
387 #define LMP_3SLOT	0x01
388 #define LMP_5SLOT	0x02
389 #define LMP_ENCRYPT	0x04
390 #define LMP_SOFFSET	0x08
391 #define LMP_TACCURACY	0x10
392 #define LMP_RSWITCH	0x20
393 #define LMP_HOLD	0x40
394 #define LMP_SNIFF	0x80
395 
396 #define LMP_PARK	0x01
397 #define LMP_RSSI	0x02
398 #define LMP_QUALITY	0x04
399 #define LMP_SCO		0x08
400 #define LMP_HV2		0x10
401 #define LMP_HV3		0x20
402 #define LMP_ULAW	0x40
403 #define LMP_ALAW	0x80
404 
405 #define LMP_CVSD	0x01
406 #define LMP_PSCHEME	0x02
407 #define LMP_PCONTROL	0x04
408 #define LMP_TRANSPARENT	0x08
409 
410 #define LMP_EDR_2M		0x02
411 #define LMP_EDR_3M		0x04
412 #define LMP_RSSI_INQ	0x40
413 #define LMP_ESCO	0x80
414 
415 #define LMP_EV4		0x01
416 #define LMP_EV5		0x02
417 #define LMP_NO_BREDR	0x20
418 #define LMP_LE		0x40
419 #define LMP_EDR_3SLOT	0x80
420 
421 #define LMP_EDR_5SLOT	0x01
422 #define LMP_SNIFF_SUBR	0x02
423 #define LMP_PAUSE_ENC	0x04
424 #define LMP_EDR_ESCO_2M	0x20
425 #define LMP_EDR_ESCO_3M	0x40
426 #define LMP_EDR_3S_ESCO	0x80
427 
428 #define LMP_EXT_INQ	0x01
429 #define LMP_SIMUL_LE_BR	0x02
430 #define LMP_SIMPLE_PAIR	0x08
431 #define LMP_NO_FLUSH	0x40
432 
433 #define LMP_LSTO	0x01
434 #define LMP_INQ_TX_PWR	0x02
435 #define LMP_EXTFEATURES	0x80
436 
437 /* Extended LMP features */
438 #define LMP_CSB_MASTER	0x01
439 #define LMP_CSB_SLAVE	0x02
440 #define LMP_SYNC_TRAIN	0x04
441 #define LMP_SYNC_SCAN	0x08
442 
443 #define LMP_SC		0x01
444 #define LMP_PING	0x02
445 
446 /* Host features */
447 #define LMP_HOST_SSP		0x01
448 #define LMP_HOST_LE		0x02
449 #define LMP_HOST_LE_BREDR	0x04
450 #define LMP_HOST_SC		0x08
451 
452 /* LE features */
453 #define HCI_LE_ENCRYPTION		0x01
454 #define HCI_LE_CONN_PARAM_REQ_PROC	0x02
455 #define HCI_LE_SLAVE_FEATURES		0x08
456 #define HCI_LE_PING			0x10
457 #define HCI_LE_DATA_LEN_EXT		0x20
458 #define HCI_LE_PHY_2M			0x01
459 #define HCI_LE_PHY_CODED		0x08
460 #define HCI_LE_EXT_ADV			0x10
461 #define HCI_LE_EXT_SCAN_POLICY		0x80
462 #define HCI_LE_PHY_2M			0x01
463 #define HCI_LE_PHY_CODED		0x08
464 #define HCI_LE_CHAN_SEL_ALG2		0x40
465 #define HCI_LE_CIS_MASTER		0x10
466 #define HCI_LE_CIS_SLAVE		0x20
467 
468 /* Connection modes */
469 #define HCI_CM_ACTIVE	0x0000
470 #define HCI_CM_HOLD	0x0001
471 #define HCI_CM_SNIFF	0x0002
472 #define HCI_CM_PARK	0x0003
473 
474 /* Link policies */
475 #define HCI_LP_RSWITCH	0x0001
476 #define HCI_LP_HOLD	0x0002
477 #define HCI_LP_SNIFF	0x0004
478 #define HCI_LP_PARK	0x0008
479 
480 /* Link modes */
481 #define HCI_LM_ACCEPT	0x8000
482 #define HCI_LM_MASTER	0x0001
483 #define HCI_LM_AUTH	0x0002
484 #define HCI_LM_ENCRYPT	0x0004
485 #define HCI_LM_TRUSTED	0x0008
486 #define HCI_LM_RELIABLE	0x0010
487 #define HCI_LM_SECURE	0x0020
488 #define HCI_LM_FIPS	0x0040
489 
490 /* Authentication types */
491 #define HCI_AT_NO_BONDING		0x00
492 #define HCI_AT_NO_BONDING_MITM		0x01
493 #define HCI_AT_DEDICATED_BONDING	0x02
494 #define HCI_AT_DEDICATED_BONDING_MITM	0x03
495 #define HCI_AT_GENERAL_BONDING		0x04
496 #define HCI_AT_GENERAL_BONDING_MITM	0x05
497 
498 /* I/O capabilities */
499 #define HCI_IO_DISPLAY_ONLY	0x00
500 #define HCI_IO_DISPLAY_YESNO	0x01
501 #define HCI_IO_KEYBOARD_ONLY	0x02
502 #define HCI_IO_NO_INPUT_OUTPUT	0x03
503 
504 /* Link Key types */
505 #define HCI_LK_COMBINATION		0x00
506 #define HCI_LK_LOCAL_UNIT		0x01
507 #define HCI_LK_REMOTE_UNIT		0x02
508 #define HCI_LK_DEBUG_COMBINATION	0x03
509 #define HCI_LK_UNAUTH_COMBINATION_P192	0x04
510 #define HCI_LK_AUTH_COMBINATION_P192	0x05
511 #define HCI_LK_CHANGED_COMBINATION	0x06
512 #define HCI_LK_UNAUTH_COMBINATION_P256	0x07
513 #define HCI_LK_AUTH_COMBINATION_P256	0x08
514 
515 /* ---- HCI Error Codes ---- */
516 #define HCI_ERROR_UNKNOWN_CONN_ID	0x02
517 #define HCI_ERROR_AUTH_FAILURE		0x05
518 #define HCI_ERROR_PIN_OR_KEY_MISSING	0x06
519 #define HCI_ERROR_MEMORY_EXCEEDED	0x07
520 #define HCI_ERROR_CONNECTION_TIMEOUT	0x08
521 #define HCI_ERROR_REJ_LIMITED_RESOURCES	0x0d
522 #define HCI_ERROR_REJ_BAD_ADDR		0x0f
523 #define HCI_ERROR_REMOTE_USER_TERM	0x13
524 #define HCI_ERROR_REMOTE_LOW_RESOURCES	0x14
525 #define HCI_ERROR_REMOTE_POWER_OFF	0x15
526 #define HCI_ERROR_LOCAL_HOST_TERM	0x16
527 #define HCI_ERROR_PAIRING_NOT_ALLOWED	0x18
528 #define HCI_ERROR_INVALID_LL_PARAMS	0x1e
529 #define HCI_ERROR_UNSPECIFIED		0x1f
530 #define HCI_ERROR_ADVERTISING_TIMEOUT	0x3c
531 
532 /* Flow control modes */
533 #define HCI_FLOW_CTL_MODE_PACKET_BASED	0x00
534 #define HCI_FLOW_CTL_MODE_BLOCK_BASED	0x01
535 
536 /* The core spec defines 127 as the "not available" value */
537 #define HCI_TX_POWER_INVALID	127
538 #define HCI_RSSI_INVALID	127
539 
540 #define HCI_ROLE_MASTER		0x00
541 #define HCI_ROLE_SLAVE		0x01
542 
543 /* Extended Inquiry Response field types */
544 #define EIR_FLAGS		0x01 /* flags */
545 #define EIR_UUID16_SOME		0x02 /* 16-bit UUID, more available */
546 #define EIR_UUID16_ALL		0x03 /* 16-bit UUID, all listed */
547 #define EIR_UUID32_SOME		0x04 /* 32-bit UUID, more available */
548 #define EIR_UUID32_ALL		0x05 /* 32-bit UUID, all listed */
549 #define EIR_UUID128_SOME	0x06 /* 128-bit UUID, more available */
550 #define EIR_UUID128_ALL		0x07 /* 128-bit UUID, all listed */
551 #define EIR_NAME_SHORT		0x08 /* shortened local name */
552 #define EIR_NAME_COMPLETE	0x09 /* complete local name */
553 #define EIR_TX_POWER		0x0A /* transmit power level */
554 #define EIR_CLASS_OF_DEV	0x0D /* Class of Device */
555 #define EIR_SSP_HASH_C192	0x0E /* Simple Pairing Hash C-192 */
556 #define EIR_SSP_RAND_R192	0x0F /* Simple Pairing Randomizer R-192 */
557 #define EIR_DEVICE_ID		0x10 /* device ID */
558 #define EIR_APPEARANCE		0x19 /* Device appearance */
559 #define EIR_LE_BDADDR		0x1B /* LE Bluetooth device address */
560 #define EIR_LE_ROLE		0x1C /* LE role */
561 #define EIR_SSP_HASH_C256	0x1D /* Simple Pairing Hash C-256 */
562 #define EIR_SSP_RAND_R256	0x1E /* Simple Pairing Rand R-256 */
563 #define EIR_LE_SC_CONFIRM	0x22 /* LE SC Confirmation Value */
564 #define EIR_LE_SC_RANDOM	0x23 /* LE SC Random Value */
565 
566 /* Low Energy Advertising Flags */
567 #define LE_AD_LIMITED		0x01 /* Limited Discoverable */
568 #define LE_AD_GENERAL		0x02 /* General Discoverable */
569 #define LE_AD_NO_BREDR		0x04 /* BR/EDR not supported */
570 #define LE_AD_SIM_LE_BREDR_CTRL	0x08 /* Simultaneous LE & BR/EDR Controller */
571 #define LE_AD_SIM_LE_BREDR_HOST	0x10 /* Simultaneous LE & BR/EDR Host */
572 
573 /* -----  HCI Commands ---- */
574 #define HCI_OP_NOP			0x0000
575 
576 #define HCI_OP_INQUIRY			0x0401
577 struct hci_cp_inquiry {
578 	__u8     lap[3];
579 	__u8     length;
580 	__u8     num_rsp;
581 } __packed;
582 
583 #define HCI_OP_INQUIRY_CANCEL		0x0402
584 
585 #define HCI_OP_PERIODIC_INQ		0x0403
586 
587 #define HCI_OP_EXIT_PERIODIC_INQ	0x0404
588 
589 #define HCI_OP_CREATE_CONN		0x0405
590 struct hci_cp_create_conn {
591 	bdaddr_t bdaddr;
592 	__le16   pkt_type;
593 	__u8     pscan_rep_mode;
594 	__u8     pscan_mode;
595 	__le16   clock_offset;
596 	__u8     role_switch;
597 } __packed;
598 
599 #define HCI_OP_DISCONNECT		0x0406
600 struct hci_cp_disconnect {
601 	__le16   handle;
602 	__u8     reason;
603 } __packed;
604 
605 #define HCI_OP_ADD_SCO			0x0407
606 struct hci_cp_add_sco {
607 	__le16   handle;
608 	__le16   pkt_type;
609 } __packed;
610 
611 #define HCI_OP_CREATE_CONN_CANCEL	0x0408
612 struct hci_cp_create_conn_cancel {
613 	bdaddr_t bdaddr;
614 } __packed;
615 
616 #define HCI_OP_ACCEPT_CONN_REQ		0x0409
617 struct hci_cp_accept_conn_req {
618 	bdaddr_t bdaddr;
619 	__u8     role;
620 } __packed;
621 
622 #define HCI_OP_REJECT_CONN_REQ		0x040a
623 struct hci_cp_reject_conn_req {
624 	bdaddr_t bdaddr;
625 	__u8     reason;
626 } __packed;
627 
628 #define HCI_OP_LINK_KEY_REPLY		0x040b
629 struct hci_cp_link_key_reply {
630 	bdaddr_t bdaddr;
631 	__u8     link_key[HCI_LINK_KEY_SIZE];
632 } __packed;
633 
634 #define HCI_OP_LINK_KEY_NEG_REPLY	0x040c
635 struct hci_cp_link_key_neg_reply {
636 	bdaddr_t bdaddr;
637 } __packed;
638 
639 #define HCI_OP_PIN_CODE_REPLY		0x040d
640 struct hci_cp_pin_code_reply {
641 	bdaddr_t bdaddr;
642 	__u8     pin_len;
643 	__u8     pin_code[16];
644 } __packed;
645 struct hci_rp_pin_code_reply {
646 	__u8     status;
647 	bdaddr_t bdaddr;
648 } __packed;
649 
650 #define HCI_OP_PIN_CODE_NEG_REPLY	0x040e
651 struct hci_cp_pin_code_neg_reply {
652 	bdaddr_t bdaddr;
653 } __packed;
654 struct hci_rp_pin_code_neg_reply {
655 	__u8     status;
656 	bdaddr_t bdaddr;
657 } __packed;
658 
659 #define HCI_OP_CHANGE_CONN_PTYPE	0x040f
660 struct hci_cp_change_conn_ptype {
661 	__le16   handle;
662 	__le16   pkt_type;
663 } __packed;
664 
665 #define HCI_OP_AUTH_REQUESTED		0x0411
666 struct hci_cp_auth_requested {
667 	__le16   handle;
668 } __packed;
669 
670 #define HCI_OP_SET_CONN_ENCRYPT		0x0413
671 struct hci_cp_set_conn_encrypt {
672 	__le16   handle;
673 	__u8     encrypt;
674 } __packed;
675 
676 #define HCI_OP_CHANGE_CONN_LINK_KEY	0x0415
677 struct hci_cp_change_conn_link_key {
678 	__le16   handle;
679 } __packed;
680 
681 #define HCI_OP_REMOTE_NAME_REQ		0x0419
682 struct hci_cp_remote_name_req {
683 	bdaddr_t bdaddr;
684 	__u8     pscan_rep_mode;
685 	__u8     pscan_mode;
686 	__le16   clock_offset;
687 } __packed;
688 
689 #define HCI_OP_REMOTE_NAME_REQ_CANCEL	0x041a
690 struct hci_cp_remote_name_req_cancel {
691 	bdaddr_t bdaddr;
692 } __packed;
693 
694 #define HCI_OP_READ_REMOTE_FEATURES	0x041b
695 struct hci_cp_read_remote_features {
696 	__le16   handle;
697 } __packed;
698 
699 #define HCI_OP_READ_REMOTE_EXT_FEATURES	0x041c
700 struct hci_cp_read_remote_ext_features {
701 	__le16   handle;
702 	__u8     page;
703 } __packed;
704 
705 #define HCI_OP_READ_REMOTE_VERSION	0x041d
706 struct hci_cp_read_remote_version {
707 	__le16   handle;
708 } __packed;
709 
710 #define HCI_OP_READ_CLOCK_OFFSET	0x041f
711 struct hci_cp_read_clock_offset {
712 	__le16   handle;
713 } __packed;
714 
715 #define HCI_OP_SETUP_SYNC_CONN		0x0428
716 struct hci_cp_setup_sync_conn {
717 	__le16   handle;
718 	__le32   tx_bandwidth;
719 	__le32   rx_bandwidth;
720 	__le16   max_latency;
721 	__le16   voice_setting;
722 	__u8     retrans_effort;
723 	__le16   pkt_type;
724 } __packed;
725 
726 #define HCI_OP_ACCEPT_SYNC_CONN_REQ	0x0429
727 struct hci_cp_accept_sync_conn_req {
728 	bdaddr_t bdaddr;
729 	__le32   tx_bandwidth;
730 	__le32   rx_bandwidth;
731 	__le16   max_latency;
732 	__le16   content_format;
733 	__u8     retrans_effort;
734 	__le16   pkt_type;
735 } __packed;
736 
737 #define HCI_OP_REJECT_SYNC_CONN_REQ	0x042a
738 struct hci_cp_reject_sync_conn_req {
739 	bdaddr_t bdaddr;
740 	__u8     reason;
741 } __packed;
742 
743 #define HCI_OP_IO_CAPABILITY_REPLY	0x042b
744 struct hci_cp_io_capability_reply {
745 	bdaddr_t bdaddr;
746 	__u8     capability;
747 	__u8     oob_data;
748 	__u8     authentication;
749 } __packed;
750 
751 #define HCI_OP_USER_CONFIRM_REPLY		0x042c
752 struct hci_cp_user_confirm_reply {
753 	bdaddr_t bdaddr;
754 } __packed;
755 struct hci_rp_user_confirm_reply {
756 	__u8     status;
757 	bdaddr_t bdaddr;
758 } __packed;
759 
760 #define HCI_OP_USER_CONFIRM_NEG_REPLY	0x042d
761 
762 #define HCI_OP_USER_PASSKEY_REPLY		0x042e
763 struct hci_cp_user_passkey_reply {
764 	bdaddr_t bdaddr;
765 	__le32	passkey;
766 } __packed;
767 
768 #define HCI_OP_USER_PASSKEY_NEG_REPLY	0x042f
769 
770 #define HCI_OP_REMOTE_OOB_DATA_REPLY	0x0430
771 struct hci_cp_remote_oob_data_reply {
772 	bdaddr_t bdaddr;
773 	__u8     hash[16];
774 	__u8     rand[16];
775 } __packed;
776 
777 #define HCI_OP_REMOTE_OOB_DATA_NEG_REPLY	0x0433
778 struct hci_cp_remote_oob_data_neg_reply {
779 	bdaddr_t bdaddr;
780 } __packed;
781 
782 #define HCI_OP_IO_CAPABILITY_NEG_REPLY	0x0434
783 struct hci_cp_io_capability_neg_reply {
784 	bdaddr_t bdaddr;
785 	__u8     reason;
786 } __packed;
787 
788 #define HCI_OP_CREATE_PHY_LINK		0x0435
789 struct hci_cp_create_phy_link {
790 	__u8     phy_handle;
791 	__u8     key_len;
792 	__u8     key_type;
793 	__u8     key[HCI_AMP_LINK_KEY_SIZE];
794 } __packed;
795 
796 #define HCI_OP_ACCEPT_PHY_LINK		0x0436
797 struct hci_cp_accept_phy_link {
798 	__u8     phy_handle;
799 	__u8     key_len;
800 	__u8     key_type;
801 	__u8     key[HCI_AMP_LINK_KEY_SIZE];
802 } __packed;
803 
804 #define HCI_OP_DISCONN_PHY_LINK		0x0437
805 struct hci_cp_disconn_phy_link {
806 	__u8     phy_handle;
807 	__u8     reason;
808 } __packed;
809 
810 struct ext_flow_spec {
811 	__u8       id;
812 	__u8       stype;
813 	__le16     msdu;
814 	__le32     sdu_itime;
815 	__le32     acc_lat;
816 	__le32     flush_to;
817 } __packed;
818 
819 #define HCI_OP_CREATE_LOGICAL_LINK	0x0438
820 #define HCI_OP_ACCEPT_LOGICAL_LINK	0x0439
821 struct hci_cp_create_accept_logical_link {
822 	__u8                  phy_handle;
823 	struct ext_flow_spec  tx_flow_spec;
824 	struct ext_flow_spec  rx_flow_spec;
825 } __packed;
826 
827 #define HCI_OP_DISCONN_LOGICAL_LINK	0x043a
828 struct hci_cp_disconn_logical_link {
829 	__le16   log_handle;
830 } __packed;
831 
832 #define HCI_OP_LOGICAL_LINK_CANCEL	0x043b
833 struct hci_cp_logical_link_cancel {
834 	__u8     phy_handle;
835 	__u8     flow_spec_id;
836 } __packed;
837 
838 struct hci_rp_logical_link_cancel {
839 	__u8     status;
840 	__u8     phy_handle;
841 	__u8     flow_spec_id;
842 } __packed;
843 
844 #define HCI_OP_SET_CSB			0x0441
845 struct hci_cp_set_csb {
846 	__u8	enable;
847 	__u8	lt_addr;
848 	__u8	lpo_allowed;
849 	__le16	packet_type;
850 	__le16	interval_min;
851 	__le16	interval_max;
852 	__le16	csb_sv_tout;
853 } __packed;
854 struct hci_rp_set_csb {
855 	__u8	status;
856 	__u8	lt_addr;
857 	__le16	interval;
858 } __packed;
859 
860 #define HCI_OP_START_SYNC_TRAIN		0x0443
861 
862 #define HCI_OP_REMOTE_OOB_EXT_DATA_REPLY	0x0445
863 struct hci_cp_remote_oob_ext_data_reply {
864 	bdaddr_t bdaddr;
865 	__u8     hash192[16];
866 	__u8     rand192[16];
867 	__u8     hash256[16];
868 	__u8     rand256[16];
869 } __packed;
870 
871 #define HCI_OP_SNIFF_MODE		0x0803
872 struct hci_cp_sniff_mode {
873 	__le16   handle;
874 	__le16   max_interval;
875 	__le16   min_interval;
876 	__le16   attempt;
877 	__le16   timeout;
878 } __packed;
879 
880 #define HCI_OP_EXIT_SNIFF_MODE		0x0804
881 struct hci_cp_exit_sniff_mode {
882 	__le16   handle;
883 } __packed;
884 
885 #define HCI_OP_ROLE_DISCOVERY		0x0809
886 struct hci_cp_role_discovery {
887 	__le16   handle;
888 } __packed;
889 struct hci_rp_role_discovery {
890 	__u8     status;
891 	__le16   handle;
892 	__u8     role;
893 } __packed;
894 
895 #define HCI_OP_SWITCH_ROLE		0x080b
896 struct hci_cp_switch_role {
897 	bdaddr_t bdaddr;
898 	__u8     role;
899 } __packed;
900 
901 #define HCI_OP_READ_LINK_POLICY		0x080c
902 struct hci_cp_read_link_policy {
903 	__le16   handle;
904 } __packed;
905 struct hci_rp_read_link_policy {
906 	__u8     status;
907 	__le16   handle;
908 	__le16   policy;
909 } __packed;
910 
911 #define HCI_OP_WRITE_LINK_POLICY	0x080d
912 struct hci_cp_write_link_policy {
913 	__le16   handle;
914 	__le16   policy;
915 } __packed;
916 struct hci_rp_write_link_policy {
917 	__u8     status;
918 	__le16   handle;
919 } __packed;
920 
921 #define HCI_OP_READ_DEF_LINK_POLICY	0x080e
922 struct hci_rp_read_def_link_policy {
923 	__u8     status;
924 	__le16   policy;
925 } __packed;
926 
927 #define HCI_OP_WRITE_DEF_LINK_POLICY	0x080f
928 struct hci_cp_write_def_link_policy {
929 	__le16   policy;
930 } __packed;
931 
932 #define HCI_OP_SNIFF_SUBRATE		0x0811
933 struct hci_cp_sniff_subrate {
934 	__le16   handle;
935 	__le16   max_latency;
936 	__le16   min_remote_timeout;
937 	__le16   min_local_timeout;
938 } __packed;
939 
940 #define HCI_OP_SET_EVENT_MASK		0x0c01
941 
942 #define HCI_OP_RESET			0x0c03
943 
944 #define HCI_OP_SET_EVENT_FLT		0x0c05
945 #define HCI_SET_EVENT_FLT_SIZE		9
946 struct hci_cp_set_event_filter {
947 	__u8		flt_type;
948 	__u8		cond_type;
949 	struct {
950 		bdaddr_t bdaddr;
951 		__u8 auto_accept;
952 	} __packed	addr_conn_flt;
953 } __packed;
954 
955 /* Filter types */
956 #define HCI_FLT_CLEAR_ALL	0x00
957 #define HCI_FLT_INQ_RESULT	0x01
958 #define HCI_FLT_CONN_SETUP	0x02
959 
960 /* CONN_SETUP Condition types */
961 #define HCI_CONN_SETUP_ALLOW_ALL	0x00
962 #define HCI_CONN_SETUP_ALLOW_CLASS	0x01
963 #define HCI_CONN_SETUP_ALLOW_BDADDR	0x02
964 
965 /* CONN_SETUP Conditions */
966 #define HCI_CONN_SETUP_AUTO_OFF		0x01
967 #define HCI_CONN_SETUP_AUTO_ON		0x02
968 #define HCI_CONN_SETUP_AUTO_ON_WITH_RS	0x03
969 
970 #define HCI_OP_READ_STORED_LINK_KEY	0x0c0d
971 struct hci_cp_read_stored_link_key {
972 	bdaddr_t bdaddr;
973 	__u8     read_all;
974 } __packed;
975 struct hci_rp_read_stored_link_key {
976 	__u8     status;
977 	__u8     max_keys;
978 	__u8     num_keys;
979 } __packed;
980 
981 #define HCI_OP_DELETE_STORED_LINK_KEY	0x0c12
982 struct hci_cp_delete_stored_link_key {
983 	bdaddr_t bdaddr;
984 	__u8     delete_all;
985 } __packed;
986 struct hci_rp_delete_stored_link_key {
987 	__u8     status;
988 	__u8     num_keys;
989 } __packed;
990 
991 #define HCI_MAX_NAME_LENGTH		248
992 
993 #define HCI_OP_WRITE_LOCAL_NAME		0x0c13
994 struct hci_cp_write_local_name {
995 	__u8     name[HCI_MAX_NAME_LENGTH];
996 } __packed;
997 
998 #define HCI_OP_READ_LOCAL_NAME		0x0c14
999 struct hci_rp_read_local_name {
1000 	__u8     status;
1001 	__u8     name[HCI_MAX_NAME_LENGTH];
1002 } __packed;
1003 
1004 #define HCI_OP_WRITE_CA_TIMEOUT		0x0c16
1005 
1006 #define HCI_OP_WRITE_PG_TIMEOUT		0x0c18
1007 
1008 #define HCI_OP_WRITE_SCAN_ENABLE	0x0c1a
1009 	#define SCAN_DISABLED		0x00
1010 	#define SCAN_INQUIRY		0x01
1011 	#define SCAN_PAGE		0x02
1012 
1013 #define HCI_OP_READ_AUTH_ENABLE		0x0c1f
1014 
1015 #define HCI_OP_WRITE_AUTH_ENABLE	0x0c20
1016 	#define AUTH_DISABLED		0x00
1017 	#define AUTH_ENABLED		0x01
1018 
1019 #define HCI_OP_READ_ENCRYPT_MODE	0x0c21
1020 
1021 #define HCI_OP_WRITE_ENCRYPT_MODE	0x0c22
1022 	#define ENCRYPT_DISABLED	0x00
1023 	#define ENCRYPT_P2P		0x01
1024 	#define ENCRYPT_BOTH		0x02
1025 
1026 #define HCI_OP_READ_CLASS_OF_DEV	0x0c23
1027 struct hci_rp_read_class_of_dev {
1028 	__u8     status;
1029 	__u8     dev_class[3];
1030 } __packed;
1031 
1032 #define HCI_OP_WRITE_CLASS_OF_DEV	0x0c24
1033 struct hci_cp_write_class_of_dev {
1034 	__u8     dev_class[3];
1035 } __packed;
1036 
1037 #define HCI_OP_READ_VOICE_SETTING	0x0c25
1038 struct hci_rp_read_voice_setting {
1039 	__u8     status;
1040 	__le16   voice_setting;
1041 } __packed;
1042 
1043 #define HCI_OP_WRITE_VOICE_SETTING	0x0c26
1044 struct hci_cp_write_voice_setting {
1045 	__le16   voice_setting;
1046 } __packed;
1047 
1048 #define HCI_OP_HOST_BUFFER_SIZE		0x0c33
1049 struct hci_cp_host_buffer_size {
1050 	__le16   acl_mtu;
1051 	__u8     sco_mtu;
1052 	__le16   acl_max_pkt;
1053 	__le16   sco_max_pkt;
1054 } __packed;
1055 
1056 #define HCI_OP_READ_NUM_SUPPORTED_IAC	0x0c38
1057 struct hci_rp_read_num_supported_iac {
1058 	__u8	status;
1059 	__u8	num_iac;
1060 } __packed;
1061 
1062 #define HCI_OP_READ_CURRENT_IAC_LAP	0x0c39
1063 
1064 #define HCI_OP_WRITE_CURRENT_IAC_LAP	0x0c3a
1065 struct hci_cp_write_current_iac_lap {
1066 	__u8	num_iac;
1067 	__u8	iac_lap[6];
1068 } __packed;
1069 
1070 #define HCI_OP_WRITE_INQUIRY_MODE	0x0c45
1071 
1072 #define HCI_MAX_EIR_LENGTH		240
1073 
1074 #define HCI_OP_WRITE_EIR		0x0c52
1075 struct hci_cp_write_eir {
1076 	__u8	fec;
1077 	__u8	data[HCI_MAX_EIR_LENGTH];
1078 } __packed;
1079 
1080 #define HCI_OP_READ_SSP_MODE		0x0c55
1081 struct hci_rp_read_ssp_mode {
1082 	__u8     status;
1083 	__u8     mode;
1084 } __packed;
1085 
1086 #define HCI_OP_WRITE_SSP_MODE		0x0c56
1087 struct hci_cp_write_ssp_mode {
1088 	__u8     mode;
1089 } __packed;
1090 
1091 #define HCI_OP_READ_LOCAL_OOB_DATA		0x0c57
1092 struct hci_rp_read_local_oob_data {
1093 	__u8     status;
1094 	__u8     hash[16];
1095 	__u8     rand[16];
1096 } __packed;
1097 
1098 #define HCI_OP_READ_INQ_RSP_TX_POWER	0x0c58
1099 struct hci_rp_read_inq_rsp_tx_power {
1100 	__u8     status;
1101 	__s8     tx_power;
1102 } __packed;
1103 
1104 #define HCI_OP_READ_DEF_ERR_DATA_REPORTING	0x0c5a
1105 	#define ERR_DATA_REPORTING_DISABLED	0x00
1106 	#define ERR_DATA_REPORTING_ENABLED	0x01
1107 struct hci_rp_read_def_err_data_reporting {
1108 	__u8     status;
1109 	__u8     err_data_reporting;
1110 } __packed;
1111 
1112 #define HCI_OP_WRITE_DEF_ERR_DATA_REPORTING	0x0c5b
1113 struct hci_cp_write_def_err_data_reporting {
1114 	__u8     err_data_reporting;
1115 } __packed;
1116 
1117 #define HCI_OP_SET_EVENT_MASK_PAGE_2	0x0c63
1118 
1119 #define HCI_OP_READ_LOCATION_DATA	0x0c64
1120 
1121 #define HCI_OP_READ_FLOW_CONTROL_MODE	0x0c66
1122 struct hci_rp_read_flow_control_mode {
1123 	__u8     status;
1124 	__u8     mode;
1125 } __packed;
1126 
1127 #define HCI_OP_WRITE_LE_HOST_SUPPORTED	0x0c6d
1128 struct hci_cp_write_le_host_supported {
1129 	__u8	le;
1130 	__u8	simul;
1131 } __packed;
1132 
1133 #define HCI_OP_SET_RESERVED_LT_ADDR	0x0c74
1134 struct hci_cp_set_reserved_lt_addr {
1135 	__u8	lt_addr;
1136 } __packed;
1137 struct hci_rp_set_reserved_lt_addr {
1138 	__u8	status;
1139 	__u8	lt_addr;
1140 } __packed;
1141 
1142 #define HCI_OP_DELETE_RESERVED_LT_ADDR	0x0c75
1143 struct hci_cp_delete_reserved_lt_addr {
1144 	__u8	lt_addr;
1145 } __packed;
1146 struct hci_rp_delete_reserved_lt_addr {
1147 	__u8	status;
1148 	__u8	lt_addr;
1149 } __packed;
1150 
1151 #define HCI_OP_SET_CSB_DATA		0x0c76
1152 struct hci_cp_set_csb_data {
1153 	__u8	lt_addr;
1154 	__u8	fragment;
1155 	__u8	data_length;
1156 	__u8	data[HCI_MAX_CSB_DATA_SIZE];
1157 } __packed;
1158 struct hci_rp_set_csb_data {
1159 	__u8	status;
1160 	__u8	lt_addr;
1161 } __packed;
1162 
1163 #define HCI_OP_READ_SYNC_TRAIN_PARAMS	0x0c77
1164 
1165 #define HCI_OP_WRITE_SYNC_TRAIN_PARAMS	0x0c78
1166 struct hci_cp_write_sync_train_params {
1167 	__le16	interval_min;
1168 	__le16	interval_max;
1169 	__le32	sync_train_tout;
1170 	__u8	service_data;
1171 } __packed;
1172 struct hci_rp_write_sync_train_params {
1173 	__u8	status;
1174 	__le16	sync_train_int;
1175 } __packed;
1176 
1177 #define HCI_OP_READ_SC_SUPPORT		0x0c79
1178 struct hci_rp_read_sc_support {
1179 	__u8	status;
1180 	__u8	support;
1181 } __packed;
1182 
1183 #define HCI_OP_WRITE_SC_SUPPORT		0x0c7a
1184 struct hci_cp_write_sc_support {
1185 	__u8	support;
1186 } __packed;
1187 
1188 #define HCI_OP_READ_AUTH_PAYLOAD_TO    0x0c7b
1189 struct hci_cp_read_auth_payload_to {
1190 	__le16  handle;
1191 } __packed;
1192 struct hci_rp_read_auth_payload_to {
1193 	__u8    status;
1194 	__le16  handle;
1195 	__le16  timeout;
1196 } __packed;
1197 
1198 #define HCI_OP_WRITE_AUTH_PAYLOAD_TO    0x0c7c
1199 struct hci_cp_write_auth_payload_to {
1200 	__le16  handle;
1201 	__le16  timeout;
1202 } __packed;
1203 struct hci_rp_write_auth_payload_to {
1204 	__u8    status;
1205 	__le16  handle;
1206 } __packed;
1207 
1208 #define HCI_OP_READ_LOCAL_OOB_EXT_DATA	0x0c7d
1209 struct hci_rp_read_local_oob_ext_data {
1210 	__u8     status;
1211 	__u8     hash192[16];
1212 	__u8     rand192[16];
1213 	__u8     hash256[16];
1214 	__u8     rand256[16];
1215 } __packed;
1216 
1217 #define HCI_OP_READ_LOCAL_VERSION	0x1001
1218 struct hci_rp_read_local_version {
1219 	__u8     status;
1220 	__u8     hci_ver;
1221 	__le16   hci_rev;
1222 	__u8     lmp_ver;
1223 	__le16   manufacturer;
1224 	__le16   lmp_subver;
1225 } __packed;
1226 
1227 #define HCI_OP_READ_LOCAL_COMMANDS	0x1002
1228 struct hci_rp_read_local_commands {
1229 	__u8     status;
1230 	__u8     commands[64];
1231 } __packed;
1232 
1233 #define HCI_OP_READ_LOCAL_FEATURES	0x1003
1234 struct hci_rp_read_local_features {
1235 	__u8     status;
1236 	__u8     features[8];
1237 } __packed;
1238 
1239 #define HCI_OP_READ_LOCAL_EXT_FEATURES	0x1004
1240 struct hci_cp_read_local_ext_features {
1241 	__u8     page;
1242 } __packed;
1243 struct hci_rp_read_local_ext_features {
1244 	__u8     status;
1245 	__u8     page;
1246 	__u8     max_page;
1247 	__u8     features[8];
1248 } __packed;
1249 
1250 #define HCI_OP_READ_BUFFER_SIZE		0x1005
1251 struct hci_rp_read_buffer_size {
1252 	__u8     status;
1253 	__le16   acl_mtu;
1254 	__u8     sco_mtu;
1255 	__le16   acl_max_pkt;
1256 	__le16   sco_max_pkt;
1257 } __packed;
1258 
1259 #define HCI_OP_READ_BD_ADDR		0x1009
1260 struct hci_rp_read_bd_addr {
1261 	__u8     status;
1262 	bdaddr_t bdaddr;
1263 } __packed;
1264 
1265 #define HCI_OP_READ_DATA_BLOCK_SIZE	0x100a
1266 struct hci_rp_read_data_block_size {
1267 	__u8     status;
1268 	__le16   max_acl_len;
1269 	__le16   block_len;
1270 	__le16   num_blocks;
1271 } __packed;
1272 
1273 #define HCI_OP_READ_LOCAL_CODECS	0x100b
1274 
1275 #define HCI_OP_READ_PAGE_SCAN_ACTIVITY	0x0c1b
1276 struct hci_rp_read_page_scan_activity {
1277 	__u8     status;
1278 	__le16   interval;
1279 	__le16   window;
1280 } __packed;
1281 
1282 #define HCI_OP_WRITE_PAGE_SCAN_ACTIVITY	0x0c1c
1283 struct hci_cp_write_page_scan_activity {
1284 	__le16   interval;
1285 	__le16   window;
1286 } __packed;
1287 
1288 #define HCI_OP_READ_TX_POWER		0x0c2d
1289 struct hci_cp_read_tx_power {
1290 	__le16   handle;
1291 	__u8     type;
1292 } __packed;
1293 struct hci_rp_read_tx_power {
1294 	__u8     status;
1295 	__le16   handle;
1296 	__s8     tx_power;
1297 } __packed;
1298 
1299 #define HCI_OP_READ_PAGE_SCAN_TYPE	0x0c46
1300 struct hci_rp_read_page_scan_type {
1301 	__u8     status;
1302 	__u8     type;
1303 } __packed;
1304 
1305 #define HCI_OP_WRITE_PAGE_SCAN_TYPE	0x0c47
1306 	#define PAGE_SCAN_TYPE_STANDARD		0x00
1307 	#define PAGE_SCAN_TYPE_INTERLACED	0x01
1308 
1309 #define HCI_OP_READ_RSSI		0x1405
1310 struct hci_cp_read_rssi {
1311 	__le16   handle;
1312 } __packed;
1313 struct hci_rp_read_rssi {
1314 	__u8     status;
1315 	__le16   handle;
1316 	__s8     rssi;
1317 } __packed;
1318 
1319 #define HCI_OP_READ_CLOCK		0x1407
1320 struct hci_cp_read_clock {
1321 	__le16   handle;
1322 	__u8     which;
1323 } __packed;
1324 struct hci_rp_read_clock {
1325 	__u8     status;
1326 	__le16   handle;
1327 	__le32   clock;
1328 	__le16   accuracy;
1329 } __packed;
1330 
1331 #define HCI_OP_READ_ENC_KEY_SIZE	0x1408
1332 struct hci_cp_read_enc_key_size {
1333 	__le16   handle;
1334 } __packed;
1335 struct hci_rp_read_enc_key_size {
1336 	__u8     status;
1337 	__le16   handle;
1338 	__u8     key_size;
1339 } __packed;
1340 
1341 #define HCI_OP_READ_LOCAL_AMP_INFO	0x1409
1342 struct hci_rp_read_local_amp_info {
1343 	__u8     status;
1344 	__u8     amp_status;
1345 	__le32   total_bw;
1346 	__le32   max_bw;
1347 	__le32   min_latency;
1348 	__le32   max_pdu;
1349 	__u8     amp_type;
1350 	__le16   pal_cap;
1351 	__le16   max_assoc_size;
1352 	__le32   max_flush_to;
1353 	__le32   be_flush_to;
1354 } __packed;
1355 
1356 #define HCI_OP_READ_LOCAL_AMP_ASSOC	0x140a
1357 struct hci_cp_read_local_amp_assoc {
1358 	__u8     phy_handle;
1359 	__le16   len_so_far;
1360 	__le16   max_len;
1361 } __packed;
1362 struct hci_rp_read_local_amp_assoc {
1363 	__u8     status;
1364 	__u8     phy_handle;
1365 	__le16   rem_len;
1366 	__u8     frag[];
1367 } __packed;
1368 
1369 #define HCI_OP_WRITE_REMOTE_AMP_ASSOC	0x140b
1370 struct hci_cp_write_remote_amp_assoc {
1371 	__u8     phy_handle;
1372 	__le16   len_so_far;
1373 	__le16   rem_len;
1374 	__u8     frag[];
1375 } __packed;
1376 struct hci_rp_write_remote_amp_assoc {
1377 	__u8     status;
1378 	__u8     phy_handle;
1379 } __packed;
1380 
1381 #define HCI_OP_GET_MWS_TRANSPORT_CONFIG	0x140c
1382 
1383 #define HCI_OP_ENABLE_DUT_MODE		0x1803
1384 
1385 #define HCI_OP_WRITE_SSP_DEBUG_MODE	0x1804
1386 
1387 #define HCI_OP_LE_SET_EVENT_MASK	0x2001
1388 struct hci_cp_le_set_event_mask {
1389 	__u8     mask[8];
1390 } __packed;
1391 
1392 #define HCI_OP_LE_READ_BUFFER_SIZE	0x2002
1393 struct hci_rp_le_read_buffer_size {
1394 	__u8     status;
1395 	__le16   le_mtu;
1396 	__u8     le_max_pkt;
1397 } __packed;
1398 
1399 #define HCI_OP_LE_READ_LOCAL_FEATURES	0x2003
1400 struct hci_rp_le_read_local_features {
1401 	__u8     status;
1402 	__u8     features[8];
1403 } __packed;
1404 
1405 #define HCI_OP_LE_SET_RANDOM_ADDR	0x2005
1406 
1407 #define HCI_OP_LE_SET_ADV_PARAM		0x2006
1408 struct hci_cp_le_set_adv_param {
1409 	__le16   min_interval;
1410 	__le16   max_interval;
1411 	__u8     type;
1412 	__u8     own_address_type;
1413 	__u8     direct_addr_type;
1414 	bdaddr_t direct_addr;
1415 	__u8     channel_map;
1416 	__u8     filter_policy;
1417 } __packed;
1418 
1419 #define HCI_OP_LE_READ_ADV_TX_POWER	0x2007
1420 struct hci_rp_le_read_adv_tx_power {
1421 	__u8	status;
1422 	__s8	tx_power;
1423 } __packed;
1424 
1425 #define HCI_MAX_AD_LENGTH		31
1426 
1427 #define HCI_OP_LE_SET_ADV_DATA		0x2008
1428 struct hci_cp_le_set_adv_data {
1429 	__u8	length;
1430 	__u8	data[HCI_MAX_AD_LENGTH];
1431 } __packed;
1432 
1433 #define HCI_OP_LE_SET_SCAN_RSP_DATA	0x2009
1434 struct hci_cp_le_set_scan_rsp_data {
1435 	__u8	length;
1436 	__u8	data[HCI_MAX_AD_LENGTH];
1437 } __packed;
1438 
1439 #define HCI_OP_LE_SET_ADV_ENABLE	0x200a
1440 
1441 #define LE_SCAN_PASSIVE			0x00
1442 #define LE_SCAN_ACTIVE			0x01
1443 
1444 #define HCI_OP_LE_SET_SCAN_PARAM	0x200b
1445 struct hci_cp_le_set_scan_param {
1446 	__u8    type;
1447 	__le16  interval;
1448 	__le16  window;
1449 	__u8    own_address_type;
1450 	__u8    filter_policy;
1451 } __packed;
1452 
1453 #define LE_SCAN_DISABLE			0x00
1454 #define LE_SCAN_ENABLE			0x01
1455 #define LE_SCAN_FILTER_DUP_DISABLE	0x00
1456 #define LE_SCAN_FILTER_DUP_ENABLE	0x01
1457 
1458 #define HCI_OP_LE_SET_SCAN_ENABLE	0x200c
1459 struct hci_cp_le_set_scan_enable {
1460 	__u8     enable;
1461 	__u8     filter_dup;
1462 } __packed;
1463 
1464 #define HCI_LE_USE_PEER_ADDR		0x00
1465 #define HCI_LE_USE_WHITELIST		0x01
1466 
1467 #define HCI_OP_LE_CREATE_CONN		0x200d
1468 struct hci_cp_le_create_conn {
1469 	__le16   scan_interval;
1470 	__le16   scan_window;
1471 	__u8     filter_policy;
1472 	__u8     peer_addr_type;
1473 	bdaddr_t peer_addr;
1474 	__u8     own_address_type;
1475 	__le16   conn_interval_min;
1476 	__le16   conn_interval_max;
1477 	__le16   conn_latency;
1478 	__le16   supervision_timeout;
1479 	__le16   min_ce_len;
1480 	__le16   max_ce_len;
1481 } __packed;
1482 
1483 #define HCI_OP_LE_CREATE_CONN_CANCEL	0x200e
1484 
1485 #define HCI_OP_LE_READ_WHITE_LIST_SIZE	0x200f
1486 struct hci_rp_le_read_white_list_size {
1487 	__u8	status;
1488 	__u8	size;
1489 } __packed;
1490 
1491 #define HCI_OP_LE_CLEAR_WHITE_LIST	0x2010
1492 
1493 #define HCI_OP_LE_ADD_TO_WHITE_LIST	0x2011
1494 struct hci_cp_le_add_to_white_list {
1495 	__u8     bdaddr_type;
1496 	bdaddr_t bdaddr;
1497 } __packed;
1498 
1499 #define HCI_OP_LE_DEL_FROM_WHITE_LIST	0x2012
1500 struct hci_cp_le_del_from_white_list {
1501 	__u8     bdaddr_type;
1502 	bdaddr_t bdaddr;
1503 } __packed;
1504 
1505 #define HCI_OP_LE_CONN_UPDATE		0x2013
1506 struct hci_cp_le_conn_update {
1507 	__le16   handle;
1508 	__le16   conn_interval_min;
1509 	__le16   conn_interval_max;
1510 	__le16   conn_latency;
1511 	__le16   supervision_timeout;
1512 	__le16   min_ce_len;
1513 	__le16   max_ce_len;
1514 } __packed;
1515 
1516 #define HCI_OP_LE_READ_REMOTE_FEATURES	0x2016
1517 struct hci_cp_le_read_remote_features {
1518 	__le16	 handle;
1519 } __packed;
1520 
1521 #define HCI_OP_LE_START_ENC		0x2019
1522 struct hci_cp_le_start_enc {
1523 	__le16	handle;
1524 	__le64	rand;
1525 	__le16	ediv;
1526 	__u8	ltk[16];
1527 } __packed;
1528 
1529 #define HCI_OP_LE_LTK_REPLY		0x201a
1530 struct hci_cp_le_ltk_reply {
1531 	__le16	handle;
1532 	__u8	ltk[16];
1533 } __packed;
1534 struct hci_rp_le_ltk_reply {
1535 	__u8	status;
1536 	__le16	handle;
1537 } __packed;
1538 
1539 #define HCI_OP_LE_LTK_NEG_REPLY		0x201b
1540 struct hci_cp_le_ltk_neg_reply {
1541 	__le16	handle;
1542 } __packed;
1543 struct hci_rp_le_ltk_neg_reply {
1544 	__u8	status;
1545 	__le16	handle;
1546 } __packed;
1547 
1548 #define HCI_OP_LE_READ_SUPPORTED_STATES	0x201c
1549 struct hci_rp_le_read_supported_states {
1550 	__u8	status;
1551 	__u8	le_states[8];
1552 } __packed;
1553 
1554 #define HCI_OP_LE_CONN_PARAM_REQ_REPLY	0x2020
1555 struct hci_cp_le_conn_param_req_reply {
1556 	__le16	handle;
1557 	__le16	interval_min;
1558 	__le16	interval_max;
1559 	__le16	latency;
1560 	__le16	timeout;
1561 	__le16	min_ce_len;
1562 	__le16	max_ce_len;
1563 } __packed;
1564 
1565 #define HCI_OP_LE_CONN_PARAM_REQ_NEG_REPLY	0x2021
1566 struct hci_cp_le_conn_param_req_neg_reply {
1567 	__le16	handle;
1568 	__u8	reason;
1569 } __packed;
1570 
1571 #define HCI_OP_LE_SET_DATA_LEN		0x2022
1572 struct hci_cp_le_set_data_len {
1573 	__le16	handle;
1574 	__le16	tx_len;
1575 	__le16	tx_time;
1576 } __packed;
1577 struct hci_rp_le_set_data_len {
1578 	__u8	status;
1579 	__le16	handle;
1580 } __packed;
1581 
1582 #define HCI_OP_LE_READ_DEF_DATA_LEN	0x2023
1583 struct hci_rp_le_read_def_data_len {
1584 	__u8	status;
1585 	__le16	tx_len;
1586 	__le16	tx_time;
1587 } __packed;
1588 
1589 #define HCI_OP_LE_WRITE_DEF_DATA_LEN	0x2024
1590 struct hci_cp_le_write_def_data_len {
1591 	__le16	tx_len;
1592 	__le16	tx_time;
1593 } __packed;
1594 
1595 #define HCI_OP_LE_ADD_TO_RESOLV_LIST	0x2027
1596 struct hci_cp_le_add_to_resolv_list {
1597 	__u8	 bdaddr_type;
1598 	bdaddr_t bdaddr;
1599 	__u8	 peer_irk[16];
1600 	__u8	 local_irk[16];
1601 } __packed;
1602 
1603 #define HCI_OP_LE_DEL_FROM_RESOLV_LIST	0x2028
1604 struct hci_cp_le_del_from_resolv_list {
1605 	__u8	 bdaddr_type;
1606 	bdaddr_t bdaddr;
1607 } __packed;
1608 
1609 #define HCI_OP_LE_CLEAR_RESOLV_LIST	0x2029
1610 
1611 #define HCI_OP_LE_READ_RESOLV_LIST_SIZE	0x202a
1612 struct hci_rp_le_read_resolv_list_size {
1613 	__u8	status;
1614 	__u8	size;
1615 } __packed;
1616 
1617 #define HCI_OP_LE_SET_ADDR_RESOLV_ENABLE 0x202d
1618 
1619 #define HCI_OP_LE_READ_MAX_DATA_LEN	0x202f
1620 struct hci_rp_le_read_max_data_len {
1621 	__u8	status;
1622 	__le16	tx_len;
1623 	__le16	tx_time;
1624 	__le16	rx_len;
1625 	__le16	rx_time;
1626 } __packed;
1627 
1628 #define HCI_OP_LE_SET_DEFAULT_PHY	0x2031
1629 struct hci_cp_le_set_default_phy {
1630 	__u8    all_phys;
1631 	__u8    tx_phys;
1632 	__u8    rx_phys;
1633 } __packed;
1634 
1635 #define HCI_LE_SET_PHY_1M		0x01
1636 #define HCI_LE_SET_PHY_2M		0x02
1637 #define HCI_LE_SET_PHY_CODED		0x04
1638 
1639 #define HCI_OP_LE_SET_EXT_SCAN_PARAMS   0x2041
1640 struct hci_cp_le_set_ext_scan_params {
1641 	__u8    own_addr_type;
1642 	__u8    filter_policy;
1643 	__u8    scanning_phys;
1644 	__u8    data[];
1645 } __packed;
1646 
1647 #define LE_SCAN_PHY_1M		0x01
1648 #define LE_SCAN_PHY_2M		0x02
1649 #define LE_SCAN_PHY_CODED	0x04
1650 
1651 struct hci_cp_le_scan_phy_params {
1652 	__u8    type;
1653 	__le16  interval;
1654 	__le16  window;
1655 } __packed;
1656 
1657 #define HCI_OP_LE_SET_EXT_SCAN_ENABLE   0x2042
1658 struct hci_cp_le_set_ext_scan_enable {
1659 	__u8    enable;
1660 	__u8    filter_dup;
1661 	__le16  duration;
1662 	__le16  period;
1663 } __packed;
1664 
1665 #define HCI_OP_LE_EXT_CREATE_CONN    0x2043
1666 struct hci_cp_le_ext_create_conn {
1667 	__u8      filter_policy;
1668 	__u8      own_addr_type;
1669 	__u8      peer_addr_type;
1670 	bdaddr_t  peer_addr;
1671 	__u8      phys;
1672 	__u8      data[];
1673 } __packed;
1674 
1675 struct hci_cp_le_ext_conn_param {
1676 	__le16 scan_interval;
1677 	__le16 scan_window;
1678 	__le16 conn_interval_min;
1679 	__le16 conn_interval_max;
1680 	__le16 conn_latency;
1681 	__le16 supervision_timeout;
1682 	__le16 min_ce_len;
1683 	__le16 max_ce_len;
1684 } __packed;
1685 
1686 #define HCI_OP_LE_READ_NUM_SUPPORTED_ADV_SETS	0x203b
1687 struct hci_rp_le_read_num_supported_adv_sets {
1688 	__u8  status;
1689 	__u8  num_of_sets;
1690 } __packed;
1691 
1692 #define HCI_OP_LE_SET_EXT_ADV_PARAMS		0x2036
1693 struct hci_cp_le_set_ext_adv_params {
1694 	__u8      handle;
1695 	__le16    evt_properties;
1696 	__u8      min_interval[3];
1697 	__u8      max_interval[3];
1698 	__u8      channel_map;
1699 	__u8      own_addr_type;
1700 	__u8      peer_addr_type;
1701 	bdaddr_t  peer_addr;
1702 	__u8      filter_policy;
1703 	__u8      tx_power;
1704 	__u8      primary_phy;
1705 	__u8      secondary_max_skip;
1706 	__u8      secondary_phy;
1707 	__u8      sid;
1708 	__u8      notif_enable;
1709 } __packed;
1710 
1711 #define HCI_ADV_PHY_1M		0X01
1712 #define HCI_ADV_PHY_2M		0x02
1713 #define HCI_ADV_PHY_CODED	0x03
1714 
1715 struct hci_rp_le_set_ext_adv_params {
1716 	__u8  status;
1717 	__u8  tx_power;
1718 } __packed;
1719 
1720 #define HCI_OP_LE_SET_EXT_ADV_ENABLE		0x2039
1721 struct hci_cp_le_set_ext_adv_enable {
1722 	__u8  enable;
1723 	__u8  num_of_sets;
1724 	__u8  data[];
1725 } __packed;
1726 
1727 struct hci_cp_ext_adv_set {
1728 	__u8  handle;
1729 	__le16 duration;
1730 	__u8  max_events;
1731 } __packed;
1732 
1733 #define HCI_OP_LE_SET_EXT_ADV_DATA		0x2037
1734 struct hci_cp_le_set_ext_adv_data {
1735 	__u8  handle;
1736 	__u8  operation;
1737 	__u8  frag_pref;
1738 	__u8  length;
1739 	__u8  data[HCI_MAX_AD_LENGTH];
1740 } __packed;
1741 
1742 #define HCI_OP_LE_SET_EXT_SCAN_RSP_DATA		0x2038
1743 struct hci_cp_le_set_ext_scan_rsp_data {
1744 	__u8  handle;
1745 	__u8  operation;
1746 	__u8  frag_pref;
1747 	__u8  length;
1748 	__u8  data[HCI_MAX_AD_LENGTH];
1749 } __packed;
1750 
1751 #define LE_SET_ADV_DATA_OP_COMPLETE	0x03
1752 
1753 #define LE_SET_ADV_DATA_NO_FRAG		0x01
1754 
1755 #define HCI_OP_LE_REMOVE_ADV_SET	0x203c
1756 
1757 #define HCI_OP_LE_CLEAR_ADV_SETS	0x203d
1758 
1759 #define HCI_OP_LE_SET_ADV_SET_RAND_ADDR	0x2035
1760 struct hci_cp_le_set_adv_set_rand_addr {
1761 	__u8  handle;
1762 	bdaddr_t  bdaddr;
1763 } __packed;
1764 
1765 #define HCI_OP_LE_READ_BUFFER_SIZE_V2	0x2060
1766 struct hci_rp_le_read_buffer_size_v2 {
1767 	__u8    status;
1768 	__le16  acl_mtu;
1769 	__u8    acl_max_pkt;
1770 	__le16  iso_mtu;
1771 	__u8    iso_max_pkt;
1772 } __packed;
1773 
1774 #define HCI_OP_LE_READ_ISO_TX_SYNC		0x2061
1775 struct hci_cp_le_read_iso_tx_sync {
1776 	__le16  handle;
1777 } __packed;
1778 
1779 struct hci_rp_le_read_iso_tx_sync {
1780 	__u8    status;
1781 	__le16  handle;
1782 	__le16  seq;
1783 	__le32  imestamp;
1784 	__u8    offset[3];
1785 } __packed;
1786 
1787 #define HCI_OP_LE_SET_CIG_PARAMS		0x2062
1788 struct hci_cis_params {
1789 	__u8    cis_id;
1790 	__le16  m_sdu;
1791 	__le16  s_sdu;
1792 	__u8    m_phy;
1793 	__u8    s_phy;
1794 	__u8    m_rtn;
1795 	__u8    s_rtn;
1796 } __packed;
1797 
1798 struct hci_cp_le_set_cig_params {
1799 	__u8    cig_id;
1800 	__u8    m_interval[3];
1801 	__u8    s_interval[3];
1802 	__u8    sca;
1803 	__u8    packing;
1804 	__u8    framing;
1805 	__le16  m_latency;
1806 	__le16  s_latency;
1807 	__u8    num_cis;
1808 	struct hci_cis_params cis[];
1809 } __packed;
1810 
1811 struct hci_rp_le_set_cig_params {
1812 	__u8    status;
1813 	__u8    cig_id;
1814 	__u8    num_handles;
1815 	__le16  handle[];
1816 } __packed;
1817 
1818 #define HCI_OP_LE_CREATE_CIS			0x2064
1819 struct hci_cis {
1820 	__le16  cis_handle;
1821 	__le16  acl_handle;
1822 } __packed;
1823 
1824 struct hci_cp_le_create_cis {
1825 	__u8    num_cis;
1826 	struct hci_cis cis[];
1827 } __packed;
1828 
1829 #define HCI_OP_LE_REMOVE_CIG			0x2065
1830 struct hci_cp_le_remove_cig {
1831 	__u8    cig_id;
1832 } __packed;
1833 
1834 #define HCI_OP_LE_ACCEPT_CIS			0x2066
1835 struct hci_cp_le_accept_cis {
1836 	__le16  handle;
1837 } __packed;
1838 
1839 #define HCI_OP_LE_REJECT_CIS			0x2067
1840 struct hci_cp_le_reject_cis {
1841 	__le16  handle;
1842 	__u8    reason;
1843 } __packed;
1844 
1845 /* ---- HCI Events ---- */
1846 #define HCI_EV_INQUIRY_COMPLETE		0x01
1847 
1848 #define HCI_EV_INQUIRY_RESULT		0x02
1849 struct inquiry_info {
1850 	bdaddr_t bdaddr;
1851 	__u8     pscan_rep_mode;
1852 	__u8     pscan_period_mode;
1853 	__u8     pscan_mode;
1854 	__u8     dev_class[3];
1855 	__le16   clock_offset;
1856 } __packed;
1857 
1858 #define HCI_EV_CONN_COMPLETE		0x03
1859 struct hci_ev_conn_complete {
1860 	__u8     status;
1861 	__le16   handle;
1862 	bdaddr_t bdaddr;
1863 	__u8     link_type;
1864 	__u8     encr_mode;
1865 } __packed;
1866 
1867 #define HCI_EV_CONN_REQUEST		0x04
1868 struct hci_ev_conn_request {
1869 	bdaddr_t bdaddr;
1870 	__u8     dev_class[3];
1871 	__u8     link_type;
1872 } __packed;
1873 
1874 #define HCI_EV_DISCONN_COMPLETE		0x05
1875 struct hci_ev_disconn_complete {
1876 	__u8     status;
1877 	__le16   handle;
1878 	__u8     reason;
1879 } __packed;
1880 
1881 #define HCI_EV_AUTH_COMPLETE		0x06
1882 struct hci_ev_auth_complete {
1883 	__u8     status;
1884 	__le16   handle;
1885 } __packed;
1886 
1887 #define HCI_EV_REMOTE_NAME		0x07
1888 struct hci_ev_remote_name {
1889 	__u8     status;
1890 	bdaddr_t bdaddr;
1891 	__u8     name[HCI_MAX_NAME_LENGTH];
1892 } __packed;
1893 
1894 #define HCI_EV_ENCRYPT_CHANGE		0x08
1895 struct hci_ev_encrypt_change {
1896 	__u8     status;
1897 	__le16   handle;
1898 	__u8     encrypt;
1899 } __packed;
1900 
1901 #define HCI_EV_CHANGE_LINK_KEY_COMPLETE	0x09
1902 struct hci_ev_change_link_key_complete {
1903 	__u8     status;
1904 	__le16   handle;
1905 } __packed;
1906 
1907 #define HCI_EV_REMOTE_FEATURES		0x0b
1908 struct hci_ev_remote_features {
1909 	__u8     status;
1910 	__le16   handle;
1911 	__u8     features[8];
1912 } __packed;
1913 
1914 #define HCI_EV_REMOTE_VERSION		0x0c
1915 struct hci_ev_remote_version {
1916 	__u8     status;
1917 	__le16   handle;
1918 	__u8     lmp_ver;
1919 	__le16   manufacturer;
1920 	__le16   lmp_subver;
1921 } __packed;
1922 
1923 #define HCI_EV_QOS_SETUP_COMPLETE	0x0d
1924 struct hci_qos {
1925 	__u8     service_type;
1926 	__u32    token_rate;
1927 	__u32    peak_bandwidth;
1928 	__u32    latency;
1929 	__u32    delay_variation;
1930 } __packed;
1931 struct hci_ev_qos_setup_complete {
1932 	__u8     status;
1933 	__le16   handle;
1934 	struct   hci_qos qos;
1935 } __packed;
1936 
1937 #define HCI_EV_CMD_COMPLETE		0x0e
1938 struct hci_ev_cmd_complete {
1939 	__u8     ncmd;
1940 	__le16   opcode;
1941 } __packed;
1942 
1943 #define HCI_EV_CMD_STATUS		0x0f
1944 struct hci_ev_cmd_status {
1945 	__u8     status;
1946 	__u8     ncmd;
1947 	__le16   opcode;
1948 } __packed;
1949 
1950 #define HCI_EV_HARDWARE_ERROR		0x10
1951 struct hci_ev_hardware_error {
1952 	__u8     code;
1953 } __packed;
1954 
1955 #define HCI_EV_ROLE_CHANGE		0x12
1956 struct hci_ev_role_change {
1957 	__u8     status;
1958 	bdaddr_t bdaddr;
1959 	__u8     role;
1960 } __packed;
1961 
1962 #define HCI_EV_NUM_COMP_PKTS		0x13
1963 struct hci_comp_pkts_info {
1964 	__le16   handle;
1965 	__le16   count;
1966 } __packed;
1967 
1968 struct hci_ev_num_comp_pkts {
1969 	__u8     num_hndl;
1970 	struct hci_comp_pkts_info handles[];
1971 } __packed;
1972 
1973 #define HCI_EV_MODE_CHANGE		0x14
1974 struct hci_ev_mode_change {
1975 	__u8     status;
1976 	__le16   handle;
1977 	__u8     mode;
1978 	__le16   interval;
1979 } __packed;
1980 
1981 #define HCI_EV_PIN_CODE_REQ		0x16
1982 struct hci_ev_pin_code_req {
1983 	bdaddr_t bdaddr;
1984 } __packed;
1985 
1986 #define HCI_EV_LINK_KEY_REQ		0x17
1987 struct hci_ev_link_key_req {
1988 	bdaddr_t bdaddr;
1989 } __packed;
1990 
1991 #define HCI_EV_LINK_KEY_NOTIFY		0x18
1992 struct hci_ev_link_key_notify {
1993 	bdaddr_t bdaddr;
1994 	__u8     link_key[HCI_LINK_KEY_SIZE];
1995 	__u8     key_type;
1996 } __packed;
1997 
1998 #define HCI_EV_CLOCK_OFFSET		0x1c
1999 struct hci_ev_clock_offset {
2000 	__u8     status;
2001 	__le16   handle;
2002 	__le16   clock_offset;
2003 } __packed;
2004 
2005 #define HCI_EV_PKT_TYPE_CHANGE		0x1d
2006 struct hci_ev_pkt_type_change {
2007 	__u8     status;
2008 	__le16   handle;
2009 	__le16   pkt_type;
2010 } __packed;
2011 
2012 #define HCI_EV_PSCAN_REP_MODE		0x20
2013 struct hci_ev_pscan_rep_mode {
2014 	bdaddr_t bdaddr;
2015 	__u8     pscan_rep_mode;
2016 } __packed;
2017 
2018 #define HCI_EV_INQUIRY_RESULT_WITH_RSSI	0x22
2019 struct inquiry_info_with_rssi {
2020 	bdaddr_t bdaddr;
2021 	__u8     pscan_rep_mode;
2022 	__u8     pscan_period_mode;
2023 	__u8     dev_class[3];
2024 	__le16   clock_offset;
2025 	__s8     rssi;
2026 } __packed;
2027 struct inquiry_info_with_rssi_and_pscan_mode {
2028 	bdaddr_t bdaddr;
2029 	__u8     pscan_rep_mode;
2030 	__u8     pscan_period_mode;
2031 	__u8     pscan_mode;
2032 	__u8     dev_class[3];
2033 	__le16   clock_offset;
2034 	__s8     rssi;
2035 } __packed;
2036 
2037 #define HCI_EV_REMOTE_EXT_FEATURES	0x23
2038 struct hci_ev_remote_ext_features {
2039 	__u8     status;
2040 	__le16   handle;
2041 	__u8     page;
2042 	__u8     max_page;
2043 	__u8     features[8];
2044 } __packed;
2045 
2046 #define HCI_EV_SYNC_CONN_COMPLETE	0x2c
2047 struct hci_ev_sync_conn_complete {
2048 	__u8     status;
2049 	__le16   handle;
2050 	bdaddr_t bdaddr;
2051 	__u8     link_type;
2052 	__u8     tx_interval;
2053 	__u8     retrans_window;
2054 	__le16   rx_pkt_len;
2055 	__le16   tx_pkt_len;
2056 	__u8     air_mode;
2057 } __packed;
2058 
2059 #define HCI_EV_SYNC_CONN_CHANGED	0x2d
2060 struct hci_ev_sync_conn_changed {
2061 	__u8     status;
2062 	__le16   handle;
2063 	__u8     tx_interval;
2064 	__u8     retrans_window;
2065 	__le16   rx_pkt_len;
2066 	__le16   tx_pkt_len;
2067 } __packed;
2068 
2069 #define HCI_EV_SNIFF_SUBRATE		0x2e
2070 struct hci_ev_sniff_subrate {
2071 	__u8     status;
2072 	__le16   handle;
2073 	__le16   max_tx_latency;
2074 	__le16   max_rx_latency;
2075 	__le16   max_remote_timeout;
2076 	__le16   max_local_timeout;
2077 } __packed;
2078 
2079 #define HCI_EV_EXTENDED_INQUIRY_RESULT	0x2f
2080 struct extended_inquiry_info {
2081 	bdaddr_t bdaddr;
2082 	__u8     pscan_rep_mode;
2083 	__u8     pscan_period_mode;
2084 	__u8     dev_class[3];
2085 	__le16   clock_offset;
2086 	__s8     rssi;
2087 	__u8     data[240];
2088 } __packed;
2089 
2090 #define HCI_EV_KEY_REFRESH_COMPLETE	0x30
2091 struct hci_ev_key_refresh_complete {
2092 	__u8	status;
2093 	__le16	handle;
2094 } __packed;
2095 
2096 #define HCI_EV_IO_CAPA_REQUEST		0x31
2097 struct hci_ev_io_capa_request {
2098 	bdaddr_t bdaddr;
2099 } __packed;
2100 
2101 #define HCI_EV_IO_CAPA_REPLY		0x32
2102 struct hci_ev_io_capa_reply {
2103 	bdaddr_t bdaddr;
2104 	__u8     capability;
2105 	__u8     oob_data;
2106 	__u8     authentication;
2107 } __packed;
2108 
2109 #define HCI_EV_USER_CONFIRM_REQUEST	0x33
2110 struct hci_ev_user_confirm_req {
2111 	bdaddr_t	bdaddr;
2112 	__le32		passkey;
2113 } __packed;
2114 
2115 #define HCI_EV_USER_PASSKEY_REQUEST	0x34
2116 struct hci_ev_user_passkey_req {
2117 	bdaddr_t	bdaddr;
2118 } __packed;
2119 
2120 #define HCI_EV_REMOTE_OOB_DATA_REQUEST	0x35
2121 struct hci_ev_remote_oob_data_request {
2122 	bdaddr_t bdaddr;
2123 } __packed;
2124 
2125 #define HCI_EV_SIMPLE_PAIR_COMPLETE	0x36
2126 struct hci_ev_simple_pair_complete {
2127 	__u8     status;
2128 	bdaddr_t bdaddr;
2129 } __packed;
2130 
2131 #define HCI_EV_USER_PASSKEY_NOTIFY	0x3b
2132 struct hci_ev_user_passkey_notify {
2133 	bdaddr_t	bdaddr;
2134 	__le32		passkey;
2135 } __packed;
2136 
2137 #define HCI_KEYPRESS_STARTED		0
2138 #define HCI_KEYPRESS_ENTERED		1
2139 #define HCI_KEYPRESS_ERASED		2
2140 #define HCI_KEYPRESS_CLEARED		3
2141 #define HCI_KEYPRESS_COMPLETED		4
2142 
2143 #define HCI_EV_KEYPRESS_NOTIFY		0x3c
2144 struct hci_ev_keypress_notify {
2145 	bdaddr_t	bdaddr;
2146 	__u8		type;
2147 } __packed;
2148 
2149 #define HCI_EV_REMOTE_HOST_FEATURES	0x3d
2150 struct hci_ev_remote_host_features {
2151 	bdaddr_t bdaddr;
2152 	__u8     features[8];
2153 } __packed;
2154 
2155 #define HCI_EV_LE_META			0x3e
2156 struct hci_ev_le_meta {
2157 	__u8     subevent;
2158 } __packed;
2159 
2160 #define HCI_EV_PHY_LINK_COMPLETE	0x40
2161 struct hci_ev_phy_link_complete {
2162 	__u8     status;
2163 	__u8     phy_handle;
2164 } __packed;
2165 
2166 #define HCI_EV_CHANNEL_SELECTED		0x41
2167 struct hci_ev_channel_selected {
2168 	__u8     phy_handle;
2169 } __packed;
2170 
2171 #define HCI_EV_DISCONN_PHY_LINK_COMPLETE	0x42
2172 struct hci_ev_disconn_phy_link_complete {
2173 	__u8     status;
2174 	__u8     phy_handle;
2175 	__u8     reason;
2176 } __packed;
2177 
2178 #define HCI_EV_LOGICAL_LINK_COMPLETE		0x45
2179 struct hci_ev_logical_link_complete {
2180 	__u8     status;
2181 	__le16   handle;
2182 	__u8     phy_handle;
2183 	__u8     flow_spec_id;
2184 } __packed;
2185 
2186 #define HCI_EV_DISCONN_LOGICAL_LINK_COMPLETE	0x46
2187 struct hci_ev_disconn_logical_link_complete {
2188 	__u8     status;
2189 	__le16   handle;
2190 	__u8     reason;
2191 } __packed;
2192 
2193 #define HCI_EV_NUM_COMP_BLOCKS		0x48
2194 struct hci_comp_blocks_info {
2195 	__le16   handle;
2196 	__le16   pkts;
2197 	__le16   blocks;
2198 } __packed;
2199 
2200 struct hci_ev_num_comp_blocks {
2201 	__le16   num_blocks;
2202 	__u8     num_hndl;
2203 	struct hci_comp_blocks_info handles[];
2204 } __packed;
2205 
2206 #define HCI_EV_SYNC_TRAIN_COMPLETE	0x4F
2207 struct hci_ev_sync_train_complete {
2208 	__u8	status;
2209 } __packed;
2210 
2211 #define HCI_EV_SLAVE_PAGE_RESP_TIMEOUT	0x54
2212 
2213 #define HCI_EV_LE_CONN_COMPLETE		0x01
2214 struct hci_ev_le_conn_complete {
2215 	__u8     status;
2216 	__le16   handle;
2217 	__u8     role;
2218 	__u8     bdaddr_type;
2219 	bdaddr_t bdaddr;
2220 	__le16   interval;
2221 	__le16   latency;
2222 	__le16   supervision_timeout;
2223 	__u8     clk_accurancy;
2224 } __packed;
2225 
2226 /* Advertising report event types */
2227 #define LE_ADV_IND		0x00
2228 #define LE_ADV_DIRECT_IND	0x01
2229 #define LE_ADV_SCAN_IND		0x02
2230 #define LE_ADV_NONCONN_IND	0x03
2231 #define LE_ADV_SCAN_RSP		0x04
2232 #define LE_ADV_INVALID		0x05
2233 
2234 /* Legacy event types in extended adv report */
2235 #define LE_LEGACY_ADV_IND		0x0013
2236 #define LE_LEGACY_ADV_DIRECT_IND 	0x0015
2237 #define LE_LEGACY_ADV_SCAN_IND		0x0012
2238 #define LE_LEGACY_NONCONN_IND		0x0010
2239 #define LE_LEGACY_SCAN_RSP_ADV		0x001b
2240 #define LE_LEGACY_SCAN_RSP_ADV_SCAN	0x001a
2241 
2242 /* Extended Advertising event types */
2243 #define LE_EXT_ADV_NON_CONN_IND		0x0000
2244 #define LE_EXT_ADV_CONN_IND		0x0001
2245 #define LE_EXT_ADV_SCAN_IND		0x0002
2246 #define LE_EXT_ADV_DIRECT_IND		0x0004
2247 #define LE_EXT_ADV_SCAN_RSP		0x0008
2248 #define LE_EXT_ADV_LEGACY_PDU		0x0010
2249 
2250 #define ADDR_LE_DEV_PUBLIC	0x00
2251 #define ADDR_LE_DEV_RANDOM	0x01
2252 
2253 #define HCI_EV_LE_ADVERTISING_REPORT	0x02
2254 struct hci_ev_le_advertising_info {
2255 	__u8	 evt_type;
2256 	__u8	 bdaddr_type;
2257 	bdaddr_t bdaddr;
2258 	__u8	 length;
2259 	__u8	 data[];
2260 } __packed;
2261 
2262 #define HCI_EV_LE_CONN_UPDATE_COMPLETE	0x03
2263 struct hci_ev_le_conn_update_complete {
2264 	__u8     status;
2265 	__le16   handle;
2266 	__le16   interval;
2267 	__le16   latency;
2268 	__le16   supervision_timeout;
2269 } __packed;
2270 
2271 #define HCI_EV_LE_REMOTE_FEAT_COMPLETE	0x04
2272 struct hci_ev_le_remote_feat_complete {
2273 	__u8     status;
2274 	__le16   handle;
2275 	__u8     features[8];
2276 } __packed;
2277 
2278 #define HCI_EV_LE_LTK_REQ		0x05
2279 struct hci_ev_le_ltk_req {
2280 	__le16	handle;
2281 	__le64	rand;
2282 	__le16	ediv;
2283 } __packed;
2284 
2285 #define HCI_EV_LE_REMOTE_CONN_PARAM_REQ	0x06
2286 struct hci_ev_le_remote_conn_param_req {
2287 	__le16 handle;
2288 	__le16 interval_min;
2289 	__le16 interval_max;
2290 	__le16 latency;
2291 	__le16 timeout;
2292 } __packed;
2293 
2294 #define HCI_EV_LE_DATA_LEN_CHANGE	0x07
2295 struct hci_ev_le_data_len_change {
2296 	__le16	handle;
2297 	__le16	tx_len;
2298 	__le16	tx_time;
2299 	__le16	rx_len;
2300 	__le16	rx_time;
2301 } __packed;
2302 
2303 #define HCI_EV_LE_DIRECT_ADV_REPORT	0x0B
2304 struct hci_ev_le_direct_adv_info {
2305 	__u8	 evt_type;
2306 	__u8	 bdaddr_type;
2307 	bdaddr_t bdaddr;
2308 	__u8	 direct_addr_type;
2309 	bdaddr_t direct_addr;
2310 	__s8	 rssi;
2311 } __packed;
2312 
2313 #define HCI_EV_LE_PHY_UPDATE_COMPLETE	0x0c
2314 struct hci_ev_le_phy_update_complete {
2315 	__u8  status;
2316 	__le16 handle;
2317 	__u8  tx_phy;
2318 	__u8  rx_phy;
2319 } __packed;
2320 
2321 #define HCI_EV_LE_EXT_ADV_REPORT    0x0d
2322 struct hci_ev_le_ext_adv_report {
2323 	__le16 	 evt_type;
2324 	__u8	 bdaddr_type;
2325 	bdaddr_t bdaddr;
2326 	__u8	 primary_phy;
2327 	__u8	 secondary_phy;
2328 	__u8	 sid;
2329 	__u8	 tx_power;
2330 	__s8	 rssi;
2331 	__le16 	 interval;
2332 	__u8  	 direct_addr_type;
2333 	bdaddr_t direct_addr;
2334 	__u8  	 length;
2335 	__u8	 data[];
2336 } __packed;
2337 
2338 #define HCI_EV_LE_ENHANCED_CONN_COMPLETE    0x0a
2339 struct hci_ev_le_enh_conn_complete {
2340 	__u8      status;
2341 	__le16    handle;
2342 	__u8      role;
2343 	__u8      bdaddr_type;
2344 	bdaddr_t  bdaddr;
2345 	bdaddr_t  local_rpa;
2346 	bdaddr_t  peer_rpa;
2347 	__le16    interval;
2348 	__le16    latency;
2349 	__le16    supervision_timeout;
2350 	__u8      clk_accurancy;
2351 } __packed;
2352 
2353 #define HCI_EV_LE_EXT_ADV_SET_TERM	0x12
2354 struct hci_evt_le_ext_adv_set_term {
2355 	__u8	status;
2356 	__u8	handle;
2357 	__le16	conn_handle;
2358 	__u8	num_evts;
2359 } __packed;
2360 
2361 #define HCI_EVT_LE_CIS_ESTABLISHED	0x19
2362 struct hci_evt_le_cis_established {
2363 	__u8  status;
2364 	__le16 handle;
2365 	__u8  cig_sync_delay[3];
2366 	__u8  cis_sync_delay[3];
2367 	__u8  m_latency[3];
2368 	__u8  s_latency[3];
2369 	__u8  m_phy;
2370 	__u8  s_phy;
2371 	__u8  nse;
2372 	__u8  m_bn;
2373 	__u8  s_bn;
2374 	__u8  m_ft;
2375 	__u8  s_ft;
2376 	__le16 m_mtu;
2377 	__le16 s_mtu;
2378 	__le16 interval;
2379 } __packed;
2380 
2381 #define HCI_EVT_LE_CIS_REQ		0x1a
2382 struct hci_evt_le_cis_req {
2383 	__le16 acl_handle;
2384 	__le16 cis_handle;
2385 	__u8  cig_id;
2386 	__u8  cis_id;
2387 } __packed;
2388 
2389 #define HCI_EV_VENDOR			0xff
2390 
2391 /* Internal events generated by Bluetooth stack */
2392 #define HCI_EV_STACK_INTERNAL	0xfd
2393 struct hci_ev_stack_internal {
2394 	__u16    type;
2395 	__u8     data[];
2396 } __packed;
2397 
2398 #define HCI_EV_SI_DEVICE	0x01
2399 struct hci_ev_si_device {
2400 	__u16    event;
2401 	__u16    dev_id;
2402 } __packed;
2403 
2404 #define HCI_EV_SI_SECURITY	0x02
2405 struct hci_ev_si_security {
2406 	__u16    event;
2407 	__u16    proto;
2408 	__u16    subproto;
2409 	__u8     incoming;
2410 } __packed;
2411 
2412 /* ---- HCI Packet structures ---- */
2413 #define HCI_COMMAND_HDR_SIZE 3
2414 #define HCI_EVENT_HDR_SIZE   2
2415 #define HCI_ACL_HDR_SIZE     4
2416 #define HCI_SCO_HDR_SIZE     3
2417 #define HCI_ISO_HDR_SIZE     4
2418 
2419 struct hci_command_hdr {
2420 	__le16	opcode;		/* OCF & OGF */
2421 	__u8	plen;
2422 } __packed;
2423 
2424 struct hci_event_hdr {
2425 	__u8	evt;
2426 	__u8	plen;
2427 } __packed;
2428 
2429 struct hci_acl_hdr {
2430 	__le16	handle;		/* Handle & Flags(PB, BC) */
2431 	__le16	dlen;
2432 } __packed;
2433 
2434 struct hci_sco_hdr {
2435 	__le16	handle;
2436 	__u8	dlen;
2437 } __packed;
2438 
2439 struct hci_iso_hdr {
2440 	__le16	handle;
2441 	__le16	dlen;
2442 	__u8	data[];
2443 } __packed;
2444 
2445 /* ISO data packet status flags */
2446 #define HCI_ISO_STATUS_VALID	0x00
2447 #define HCI_ISO_STATUS_INVALID	0x01
2448 #define HCI_ISO_STATUS_NOP	0x02
2449 
2450 #define HCI_ISO_DATA_HDR_SIZE	4
2451 struct hci_iso_data_hdr {
2452 	__le16	sn;
2453 	__le16	slen;
2454 };
2455 
2456 #define HCI_ISO_TS_DATA_HDR_SIZE 8
2457 struct hci_iso_ts_data_hdr {
2458 	__le32	ts;
2459 	__le16	sn;
2460 	__le16	slen;
2461 };
2462 
2463 static inline struct hci_event_hdr *hci_event_hdr(const struct sk_buff *skb)
2464 {
2465 	return (struct hci_event_hdr *) skb->data;
2466 }
2467 
2468 static inline struct hci_acl_hdr *hci_acl_hdr(const struct sk_buff *skb)
2469 {
2470 	return (struct hci_acl_hdr *) skb->data;
2471 }
2472 
2473 static inline struct hci_sco_hdr *hci_sco_hdr(const struct sk_buff *skb)
2474 {
2475 	return (struct hci_sco_hdr *) skb->data;
2476 }
2477 
2478 /* Command opcode pack/unpack */
2479 #define hci_opcode_pack(ogf, ocf)	((__u16) ((ocf & 0x03ff)|(ogf << 10)))
2480 #define hci_opcode_ogf(op)		(op >> 10)
2481 #define hci_opcode_ocf(op)		(op & 0x03ff)
2482 
2483 /* ACL handle and flags pack/unpack */
2484 #define hci_handle_pack(h, f)	((__u16) ((h & 0x0fff)|(f << 12)))
2485 #define hci_handle(h)		(h & 0x0fff)
2486 #define hci_flags(h)		(h >> 12)
2487 
2488 /* ISO handle and flags pack/unpack */
2489 #define hci_iso_flags_pb(f)		(f & 0x0003)
2490 #define hci_iso_flags_ts(f)		((f >> 2) & 0x0001)
2491 #define hci_iso_flags_pack(pb, ts)	((pb & 0x03) | ((ts & 0x01) << 2))
2492 
2493 /* ISO data length and flags pack/unpack */
2494 #define hci_iso_data_len_pack(h, f)	((__u16) ((h) | ((f) << 14)))
2495 #define hci_iso_data_len(h)		((h) & 0x3fff)
2496 #define hci_iso_data_flags(h)		((h) >> 14)
2497 
2498 #endif /* __HCI_H */
2499