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