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