Ron Shaffer | 04fafe4 | 2010-05-28 11:53:45 -0400 | [diff] [blame] | 1 | /* |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2 | BlueZ - Bluetooth protocol stack for Linux |
Ron Shaffer | 2d0a034 | 2010-05-28 11:53:46 -0400 | [diff] [blame] | 3 | Copyright (c) 2000-2001, 2010, Code Aurora Forum. All rights reserved. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 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 |
Ron Shaffer | 04fafe4 | 2010-05-28 11:53:45 -0400 | [diff] [blame] | 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 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 18 | OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. |
| 19 | |
Ron Shaffer | 04fafe4 | 2010-05-28 11:53:45 -0400 | [diff] [blame] | 20 | ALL LIABILITY, INCLUDING LIABILITY FOR INFRINGEMENT OF ANY PATENTS, |
| 21 | COPYRIGHTS, TRADEMARKS OR OTHER RIGHTS, RELATING TO USE OF THIS |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 22 | SOFTWARE IS DISCLAIMED. |
| 23 | */ |
| 24 | |
| 25 | #ifndef __HCI_CORE_H |
| 26 | #define __HCI_CORE_H |
| 27 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 28 | #include <net/bluetooth/hci.h> |
Marcel Holtmann | f49daa8 | 2014-07-11 04:58:29 +0200 | [diff] [blame] | 29 | #include <net/bluetooth/hci_sock.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 30 | |
Luiz Augusto von Dentz | 5e59b79 | 2011-11-01 10:58:57 +0200 | [diff] [blame] | 31 | /* HCI priority */ |
| 32 | #define HCI_PRIO_MAX 7 |
| 33 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 34 | /* HCI Core structures */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 35 | struct inquiry_data { |
| 36 | bdaddr_t bdaddr; |
| 37 | __u8 pscan_rep_mode; |
| 38 | __u8 pscan_period_mode; |
| 39 | __u8 pscan_mode; |
| 40 | __u8 dev_class[3]; |
Marcel Holtmann | 1ebb925 | 2005-11-08 09:57:21 -0800 | [diff] [blame] | 41 | __le16 clock_offset; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 42 | __s8 rssi; |
Marcel Holtmann | 41a9621 | 2008-07-14 20:13:48 +0200 | [diff] [blame] | 43 | __u8 ssp_mode; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 44 | }; |
| 45 | |
| 46 | struct inquiry_entry { |
Johan Hedberg | 561aafb | 2012-01-04 13:31:59 +0200 | [diff] [blame] | 47 | struct list_head all; /* inq_cache.all */ |
| 48 | struct list_head list; /* unknown or resolve */ |
| 49 | enum { |
| 50 | NAME_NOT_KNOWN, |
| 51 | NAME_NEEDED, |
| 52 | NAME_PENDING, |
| 53 | NAME_KNOWN, |
| 54 | } name_state; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 55 | __u32 timestamp; |
| 56 | struct inquiry_data data; |
| 57 | }; |
| 58 | |
Johan Hedberg | 3088351 | 2012-01-04 14:16:21 +0200 | [diff] [blame] | 59 | struct discovery_state { |
Gustavo F. Padovan | f64b993 | 2012-03-06 23:48:33 -0300 | [diff] [blame] | 60 | int type; |
Johan Hedberg | ff9ef57 | 2012-01-04 14:23:45 +0200 | [diff] [blame] | 61 | enum { |
| 62 | DISCOVERY_STOPPED, |
| 63 | DISCOVERY_STARTING, |
Andre Guedes | 343f935 | 2012-02-17 20:39:37 -0300 | [diff] [blame] | 64 | DISCOVERY_FINDING, |
Johan Hedberg | 30dc78e | 2012-01-04 15:44:20 +0200 | [diff] [blame] | 65 | DISCOVERY_RESOLVING, |
Johan Hedberg | ff9ef57 | 2012-01-04 14:23:45 +0200 | [diff] [blame] | 66 | DISCOVERY_STOPPING, |
| 67 | } state; |
Gustavo Padovan | c3c7ea6 | 2012-05-23 04:04:20 -0300 | [diff] [blame] | 68 | struct list_head all; /* All devices found during inquiry */ |
Gustavo F. Padovan | f64b993 | 2012-03-06 23:48:33 -0300 | [diff] [blame] | 69 | struct list_head unknown; /* Name state not known */ |
| 70 | struct list_head resolve; /* Name needs to be resolved */ |
| 71 | __u32 timestamp; |
Johan Hedberg | b9a6328 | 2014-03-25 10:51:52 +0200 | [diff] [blame] | 72 | bdaddr_t last_adv_addr; |
| 73 | u8 last_adv_addr_type; |
Johan Hedberg | ff5cd29 | 2014-03-25 14:40:52 +0200 | [diff] [blame] | 74 | s8 last_adv_rssi; |
Marcel Holtmann | c70a7e4 | 2014-07-01 14:11:21 +0200 | [diff] [blame] | 75 | u32 last_adv_flags; |
Johan Hedberg | b9a6328 | 2014-03-25 10:51:52 +0200 | [diff] [blame] | 76 | u8 last_adv_data[HCI_MAX_AD_LENGTH]; |
| 77 | u8 last_adv_data_len; |
Marcel Holtmann | da25cf6 | 2014-12-05 13:03:35 +0100 | [diff] [blame] | 78 | bool report_invalid_rssi; |
Jakub Pawlowski | 82f8b65 | 2015-03-04 16:24:26 -0800 | [diff] [blame] | 79 | bool result_filtering; |
Jakub Pawlowski | 37eab04 | 2014-12-05 10:55:55 +0100 | [diff] [blame] | 80 | s8 rssi; |
| 81 | u16 uuid_count; |
| 82 | u8 (*uuids)[16]; |
Jakub Pawlowski | 2d28cfe | 2015-02-01 23:07:54 -0800 | [diff] [blame] | 83 | unsigned long scan_start; |
| 84 | unsigned long scan_duration; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 85 | }; |
| 86 | |
| 87 | struct hci_conn_hash { |
| 88 | struct list_head list; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 89 | unsigned int acl_num; |
Andrei Emeltchenko | bd1eb66 | 2012-10-10 17:38:30 +0300 | [diff] [blame] | 90 | unsigned int amp_num; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 91 | unsigned int sco_num; |
Ville Tervo | fcd89c0 | 2011-02-10 22:38:47 -0300 | [diff] [blame] | 92 | unsigned int le_num; |
Johan Hedberg | f8218dc | 2014-07-16 11:56:08 +0300 | [diff] [blame] | 93 | unsigned int le_num_slave; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 94 | }; |
| 95 | |
Johan Hedberg | f035856 | 2010-05-18 13:20:32 +0200 | [diff] [blame] | 96 | struct bdaddr_list { |
| 97 | struct list_head list; |
| 98 | bdaddr_t bdaddr; |
Marcel Holtmann | b9ee0a7 | 2013-10-17 17:24:13 -0700 | [diff] [blame] | 99 | u8 bdaddr_type; |
Johan Hedberg | f035856 | 2010-05-18 13:20:32 +0200 | [diff] [blame] | 100 | }; |
Johan Hedberg | 2aeb9a1 | 2011-01-04 12:08:51 +0200 | [diff] [blame] | 101 | |
| 102 | struct bt_uuid { |
| 103 | struct list_head list; |
| 104 | u8 uuid[16]; |
Johan Hedberg | 83be8ec | 2013-01-27 00:31:29 +0200 | [diff] [blame] | 105 | u8 size; |
Johan Hedberg | 1aff6f0 | 2011-01-13 21:56:52 +0200 | [diff] [blame] | 106 | u8 svc_hint; |
Johan Hedberg | 2aeb9a1 | 2011-01-04 12:08:51 +0200 | [diff] [blame] | 107 | }; |
| 108 | |
Marcel Holtmann | 7ee4ea3 | 2014-03-09 12:19:17 -0700 | [diff] [blame] | 109 | struct smp_csrk { |
| 110 | bdaddr_t bdaddr; |
| 111 | u8 bdaddr_type; |
Johan Hedberg | 4cd3928 | 2015-02-27 10:11:13 +0200 | [diff] [blame] | 112 | u8 type; |
Marcel Holtmann | 7ee4ea3 | 2014-03-09 12:19:17 -0700 | [diff] [blame] | 113 | u8 val[16]; |
| 114 | }; |
| 115 | |
Vinicius Costa Gomes | b899efa | 2012-02-02 21:08:00 -0300 | [diff] [blame] | 116 | struct smp_ltk { |
| 117 | struct list_head list; |
Johan Hedberg | 970d0f1 | 2014-11-13 14:37:47 +0200 | [diff] [blame] | 118 | struct rcu_head rcu; |
Vinicius Costa Gomes | b899efa | 2012-02-02 21:08:00 -0300 | [diff] [blame] | 119 | bdaddr_t bdaddr; |
| 120 | u8 bdaddr_type; |
| 121 | u8 authenticated; |
| 122 | u8 type; |
| 123 | u8 enc_size; |
| 124 | __le16 ediv; |
Marcel Holtmann | fe39c7b | 2014-02-27 16:00:28 -0800 | [diff] [blame] | 125 | __le64 rand; |
Vinicius Costa Gomes | b899efa | 2012-02-02 21:08:00 -0300 | [diff] [blame] | 126 | u8 val[16]; |
Marcel Holtmann | 03c515d | 2014-01-31 18:42:18 -0800 | [diff] [blame] | 127 | }; |
Vinicius Costa Gomes | b899efa | 2012-02-02 21:08:00 -0300 | [diff] [blame] | 128 | |
Johan Hedberg | 970c4e4 | 2014-02-18 10:19:33 +0200 | [diff] [blame] | 129 | struct smp_irk { |
| 130 | struct list_head list; |
Johan Hedberg | adae20c | 2014-11-13 14:37:48 +0200 | [diff] [blame] | 131 | struct rcu_head rcu; |
Johan Hedberg | 970c4e4 | 2014-02-18 10:19:33 +0200 | [diff] [blame] | 132 | bdaddr_t rpa; |
| 133 | bdaddr_t bdaddr; |
| 134 | u8 addr_type; |
| 135 | u8 val[16]; |
| 136 | }; |
| 137 | |
Johan Hedberg | 55ed8ca1 | 2011-01-17 14:41:05 +0200 | [diff] [blame] | 138 | struct link_key { |
| 139 | struct list_head list; |
Johan Hedberg | 0378b59 | 2014-11-19 15:22:22 +0200 | [diff] [blame] | 140 | struct rcu_head rcu; |
Johan Hedberg | 55ed8ca1 | 2011-01-17 14:41:05 +0200 | [diff] [blame] | 141 | bdaddr_t bdaddr; |
| 142 | u8 type; |
Andrei Emeltchenko | 9b3b446 | 2012-05-23 11:31:20 +0300 | [diff] [blame] | 143 | u8 val[HCI_LINK_KEY_SIZE]; |
Johan Hedberg | 55ed8ca1 | 2011-01-17 14:41:05 +0200 | [diff] [blame] | 144 | u8 pin_len; |
| 145 | }; |
| 146 | |
Szymon Janc | 2763eda | 2011-03-22 13:12:22 +0100 | [diff] [blame] | 147 | struct oob_data { |
| 148 | struct list_head list; |
| 149 | bdaddr_t bdaddr; |
Johan Hedberg | 6928a92 | 2014-10-26 20:46:09 +0100 | [diff] [blame] | 150 | u8 bdaddr_type; |
Marcel Holtmann | f7697b1 | 2015-01-30 23:20:55 -0800 | [diff] [blame] | 151 | u8 present; |
Marcel Holtmann | 519ca9d | 2014-01-10 02:07:28 -0800 | [diff] [blame] | 152 | u8 hash192[16]; |
Johan Hedberg | 38da170 | 2014-11-17 20:52:20 +0200 | [diff] [blame] | 153 | u8 rand192[16]; |
Marcel Holtmann | 519ca9d | 2014-01-10 02:07:28 -0800 | [diff] [blame] | 154 | u8 hash256[16]; |
Johan Hedberg | 38da170 | 2014-11-17 20:52:20 +0200 | [diff] [blame] | 155 | u8 rand256[16]; |
Szymon Janc | 2763eda | 2011-03-22 13:12:22 +0100 | [diff] [blame] | 156 | }; |
| 157 | |
Arman Uguray | 203fea0 | 2015-03-23 15:57:11 -0700 | [diff] [blame] | 158 | struct adv_info { |
Arman Uguray | 912098a | 2015-03-23 15:57:15 -0700 | [diff] [blame] | 159 | struct delayed_work timeout_exp; |
Arman Uguray | 203fea0 | 2015-03-23 15:57:11 -0700 | [diff] [blame] | 160 | __u8 instance; |
| 161 | __u32 flags; |
Arman Uguray | 912098a | 2015-03-23 15:57:15 -0700 | [diff] [blame] | 162 | __u16 timeout; |
Arman Uguray | 203fea0 | 2015-03-23 15:57:11 -0700 | [diff] [blame] | 163 | __u16 adv_data_len; |
| 164 | __u8 adv_data[HCI_MAX_AD_LENGTH]; |
| 165 | __u16 scan_rsp_len; |
| 166 | __u8 scan_rsp_data[HCI_MAX_AD_LENGTH]; |
| 167 | }; |
| 168 | |
Johan Hedberg | 490c5ba | 2012-02-22 19:19:09 +0200 | [diff] [blame] | 169 | #define HCI_MAX_SHORT_NAME_LENGTH 10 |
| 170 | |
Johan Hedberg | d6bfd59 | 2014-02-23 19:42:20 +0200 | [diff] [blame] | 171 | /* Default LE RPA expiry time, 15 minutes */ |
| 172 | #define HCI_DEFAULT_RPA_TIMEOUT (15 * 60) |
| 173 | |
Andrzej Kaczmarek | 31ad169 | 2014-05-14 13:43:02 +0200 | [diff] [blame] | 174 | /* Default min/max age of connection information (1s/3s) */ |
| 175 | #define DEFAULT_CONN_INFO_MIN_AGE 1000 |
| 176 | #define DEFAULT_CONN_INFO_MAX_AGE 3000 |
| 177 | |
Andrei Emeltchenko | 903e454 | 2012-09-27 17:26:09 +0300 | [diff] [blame] | 178 | struct amp_assoc { |
| 179 | __u16 len; |
| 180 | __u16 offset; |
Andrei Emeltchenko | 93c284e | 2012-09-27 17:26:20 +0300 | [diff] [blame] | 181 | __u16 rem_len; |
| 182 | __u16 len_so_far; |
Andrei Emeltchenko | 903e454 | 2012-09-27 17:26:09 +0300 | [diff] [blame] | 183 | __u8 data[HCI_MAX_AMP_ASSOC_SIZE]; |
| 184 | }; |
| 185 | |
Johan Hedberg | d2c5d77 | 2013-04-17 15:00:52 +0300 | [diff] [blame] | 186 | #define HCI_MAX_PAGES 3 |
Johan Hedberg | cad718e | 2013-04-17 15:00:51 +0300 | [diff] [blame] | 187 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 188 | struct hci_dev { |
| 189 | struct list_head list; |
Gustavo F. Padovan | 09fd0de | 2011-06-17 13:03:21 -0300 | [diff] [blame] | 190 | struct mutex lock; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 191 | |
| 192 | char name[8]; |
| 193 | unsigned long flags; |
| 194 | __u16 id; |
Marcel Holtmann | c13854c | 2010-02-08 15:27:07 +0100 | [diff] [blame] | 195 | __u8 bus; |
Marcel Holtmann | 943da25 | 2010-02-13 02:28:41 +0100 | [diff] [blame] | 196 | __u8 dev_type; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 197 | bdaddr_t bdaddr; |
Marcel Holtmann | e30d3f5 | 2014-07-05 10:48:03 +0200 | [diff] [blame] | 198 | bdaddr_t setup_addr; |
Marcel Holtmann | 24c457e | 2014-07-02 00:53:47 +0200 | [diff] [blame] | 199 | bdaddr_t public_addr; |
Marcel Holtmann | 7a4cd51 | 2014-02-19 19:52:13 -0800 | [diff] [blame] | 200 | bdaddr_t random_addr; |
Marcel Holtmann | d13eafc | 2013-10-02 04:41:30 -0700 | [diff] [blame] | 201 | bdaddr_t static_addr; |
Johan Hedberg | 56ed2cb | 2014-02-27 14:05:40 +0200 | [diff] [blame] | 202 | __u8 adv_addr_type; |
Johan Hedberg | 1f6c637 | 2011-03-16 14:29:35 +0200 | [diff] [blame] | 203 | __u8 dev_name[HCI_MAX_NAME_LENGTH]; |
Johan Hedberg | 490c5ba | 2012-02-22 19:19:09 +0200 | [diff] [blame] | 204 | __u8 short_name[HCI_MAX_SHORT_NAME_LENGTH]; |
Johan Hedberg | 80a1e1d | 2011-03-28 14:07:23 +0300 | [diff] [blame] | 205 | __u8 eir[HCI_MAX_EIR_LENGTH]; |
Marcel Holtmann | a9de924 | 2007-10-20 13:33:56 +0200 | [diff] [blame] | 206 | __u8 dev_class[3]; |
Johan Hedberg | 1aff6f0 | 2011-01-13 21:56:52 +0200 | [diff] [blame] | 207 | __u8 major_class; |
| 208 | __u8 minor_class; |
Johan Hedberg | d2c5d77 | 2013-04-17 15:00:52 +0300 | [diff] [blame] | 209 | __u8 max_page; |
Johan Hedberg | cad718e | 2013-04-17 15:00:51 +0300 | [diff] [blame] | 210 | __u8 features[HCI_MAX_PAGES][8]; |
Johan Hedberg | 60e7732 | 2013-01-22 14:01:59 +0200 | [diff] [blame] | 211 | __u8 le_features[8]; |
Johan Hedberg | cf1d081 | 2013-01-22 14:02:00 +0200 | [diff] [blame] | 212 | __u8 le_white_list_size; |
Johan Hedberg | 9b008c0 | 2013-01-22 14:02:01 +0200 | [diff] [blame] | 213 | __u8 le_states[8]; |
Marcel Holtmann | a9de924 | 2007-10-20 13:33:56 +0200 | [diff] [blame] | 214 | __u8 commands[64]; |
Marcel Holtmann | 1143e5a | 2006-09-23 09:57:20 +0200 | [diff] [blame] | 215 | __u8 hci_ver; |
| 216 | __u16 hci_rev; |
Johan Hedberg | d5859e2 | 2011-01-25 01:19:58 +0200 | [diff] [blame] | 217 | __u8 lmp_ver; |
Marcel Holtmann | 1143e5a | 2006-09-23 09:57:20 +0200 | [diff] [blame] | 218 | __u16 manufacturer; |
Andrei Emeltchenko | 7d69230 | 2012-03-09 11:46:49 +0200 | [diff] [blame] | 219 | __u16 lmp_subver; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 220 | __u16 voice_setting; |
Marcel Holtmann | b4cb9fb | 2013-10-14 13:56:16 -0700 | [diff] [blame] | 221 | __u8 num_iac; |
Marcel Holtmann | c2f0f97 | 2015-01-12 09:21:25 -0800 | [diff] [blame] | 222 | __u8 stored_max_keys; |
| 223 | __u8 stored_num_keys; |
Johan Hedberg | 17fa4b9 | 2011-01-25 13:28:33 +0200 | [diff] [blame] | 224 | __u8 io_capability; |
Marcel Holtmann | 91c4e9b | 2012-03-11 19:27:21 -0700 | [diff] [blame] | 225 | __s8 inq_tx_power; |
Johan Hedberg | f332ec6 | 2013-03-15 17:07:11 -0500 | [diff] [blame] | 226 | __u16 page_scan_interval; |
| 227 | __u16 page_scan_window; |
| 228 | __u8 page_scan_type; |
Marcel Holtmann | 3f959d4 | 2014-02-20 11:55:56 -0800 | [diff] [blame] | 229 | __u8 le_adv_channel_map; |
Georg Lukas | 628531c | 2014-07-26 13:59:57 +0200 | [diff] [blame] | 230 | __u16 le_adv_min_interval; |
| 231 | __u16 le_adv_max_interval; |
Marcel Holtmann | 533553f | 2014-03-21 12:18:10 -0700 | [diff] [blame] | 232 | __u8 le_scan_type; |
Marcel Holtmann | bef6473 | 2013-10-11 08:23:19 -0700 | [diff] [blame] | 233 | __u16 le_scan_interval; |
| 234 | __u16 le_scan_window; |
Marcel Holtmann | 4e70c7e | 2013-10-19 07:09:13 -0700 | [diff] [blame] | 235 | __u16 le_conn_min_interval; |
| 236 | __u16 le_conn_max_interval; |
Marcel Holtmann | 04fb7d9 | 2014-06-30 12:34:36 +0200 | [diff] [blame] | 237 | __u16 le_conn_latency; |
| 238 | __u16 le_supv_timeout; |
Marcel Holtmann | a8e1bfa | 2014-12-20 16:28:40 +0100 | [diff] [blame] | 239 | __u16 le_def_tx_len; |
| 240 | __u16 le_def_tx_time; |
| 241 | __u16 le_max_tx_len; |
| 242 | __u16 le_max_tx_time; |
| 243 | __u16 le_max_rx_len; |
| 244 | __u16 le_max_rx_time; |
Lukasz Rymanowski | b9a7a61 | 2014-03-27 20:55:20 +0100 | [diff] [blame] | 245 | __u16 discov_interleaved_timeout; |
Andrzej Kaczmarek | 31ad169 | 2014-05-14 13:43:02 +0200 | [diff] [blame] | 246 | __u16 conn_info_min_age; |
| 247 | __u16 conn_info_max_age; |
Marcel Holtmann | 06f5b77 | 2013-10-19 07:09:11 -0700 | [diff] [blame] | 248 | __u8 ssp_debug_mode; |
Marcel Holtmann | c7741d1 | 2015-01-28 11:09:55 -0800 | [diff] [blame] | 249 | __u8 hw_error_code; |
Johan Hedberg | 33f3572 | 2014-06-28 17:54:06 +0300 | [diff] [blame] | 250 | __u32 clock; |
Johan Hedberg | f332ec6 | 2013-03-15 17:07:11 -0500 | [diff] [blame] | 251 | |
Marcel Holtmann | 2b9be13 | 2012-03-11 19:32:12 -0700 | [diff] [blame] | 252 | __u16 devid_source; |
| 253 | __u16 devid_vendor; |
| 254 | __u16 devid_product; |
| 255 | __u16 devid_version; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 256 | |
| 257 | __u16 pkt_type; |
Marcel Holtmann | 5b7f990 | 2007-07-11 09:51:55 +0200 | [diff] [blame] | 258 | __u16 esco_type; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 259 | __u16 link_policy; |
| 260 | __u16 link_mode; |
| 261 | |
Marcel Holtmann | 04837f6 | 2006-07-03 10:02:33 +0200 | [diff] [blame] | 262 | __u32 idle_timeout; |
| 263 | __u16 sniff_min_interval; |
| 264 | __u16 sniff_max_interval; |
| 265 | |
Andrei Emeltchenko | 928abaa | 2011-10-12 10:53:57 +0300 | [diff] [blame] | 266 | __u8 amp_status; |
| 267 | __u32 amp_total_bw; |
| 268 | __u32 amp_max_bw; |
| 269 | __u32 amp_min_latency; |
| 270 | __u32 amp_max_pdu; |
| 271 | __u8 amp_type; |
| 272 | __u16 amp_pal_cap; |
| 273 | __u16 amp_assoc_size; |
| 274 | __u32 amp_max_flush_to; |
| 275 | __u32 amp_be_flush_to; |
| 276 | |
Andrei Emeltchenko | 903e454 | 2012-09-27 17:26:09 +0300 | [diff] [blame] | 277 | struct amp_assoc loc_assoc; |
| 278 | |
Andrei Emeltchenko | 1e89cff | 2011-11-24 14:52:02 +0200 | [diff] [blame] | 279 | __u8 flow_ctl_mode; |
| 280 | |
Johan Hedberg | 9f61656 | 2011-04-28 11:28:54 -0700 | [diff] [blame] | 281 | unsigned int auto_accept_delay; |
| 282 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 283 | unsigned long quirks; |
| 284 | |
| 285 | atomic_t cmd_cnt; |
| 286 | unsigned int acl_cnt; |
| 287 | unsigned int sco_cnt; |
Ville Tervo | 6ed58ec | 2011-02-10 22:38:48 -0300 | [diff] [blame] | 288 | unsigned int le_cnt; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 289 | |
| 290 | unsigned int acl_mtu; |
| 291 | unsigned int sco_mtu; |
Ville Tervo | 6ed58ec | 2011-02-10 22:38:48 -0300 | [diff] [blame] | 292 | unsigned int le_mtu; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 293 | unsigned int acl_pkts; |
| 294 | unsigned int sco_pkts; |
Ville Tervo | 6ed58ec | 2011-02-10 22:38:48 -0300 | [diff] [blame] | 295 | unsigned int le_pkts; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 296 | |
Andrei Emeltchenko | 350ee4c | 2011-12-07 15:56:51 +0200 | [diff] [blame] | 297 | __u16 block_len; |
| 298 | __u16 block_mtu; |
| 299 | __u16 num_blocks; |
| 300 | __u16 block_cnt; |
| 301 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 302 | unsigned long acl_last_tx; |
| 303 | unsigned long sco_last_tx; |
Ville Tervo | 6ed58ec | 2011-02-10 22:38:48 -0300 | [diff] [blame] | 304 | unsigned long le_last_tx; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 305 | |
Marcel Holtmann | f48fd9c | 2010-03-20 15:20:04 +0100 | [diff] [blame] | 306 | struct workqueue_struct *workqueue; |
Johan Hedberg | 6ead1bb | 2013-01-14 22:33:50 +0200 | [diff] [blame] | 307 | struct workqueue_struct *req_workqueue; |
Marcel Holtmann | f48fd9c | 2010-03-20 15:20:04 +0100 | [diff] [blame] | 308 | |
Johan Hedberg | ab81cbf | 2010-12-15 13:53:18 +0200 | [diff] [blame] | 309 | struct work_struct power_on; |
Johan Hedberg | 3243553 | 2011-11-07 22:16:04 +0200 | [diff] [blame] | 310 | struct delayed_work power_off; |
Marcel Holtmann | c7741d1 | 2015-01-28 11:09:55 -0800 | [diff] [blame] | 311 | struct work_struct error_reset; |
Johan Hedberg | ab81cbf | 2010-12-15 13:53:18 +0200 | [diff] [blame] | 312 | |
Johan Hedberg | 16ab91a | 2011-11-07 22:16:02 +0200 | [diff] [blame] | 313 | __u16 discov_timeout; |
| 314 | struct delayed_work discov_off; |
| 315 | |
Johan Hedberg | 7d78525 | 2011-12-15 00:47:39 +0200 | [diff] [blame] | 316 | struct delayed_work service_cache; |
| 317 | |
Marcel Holtmann | 65cc2b4 | 2014-06-16 12:30:56 +0200 | [diff] [blame] | 318 | struct delayed_work cmd_timer; |
Marcel Holtmann | b78752c | 2010-08-08 23:06:53 -0400 | [diff] [blame] | 319 | |
| 320 | struct work_struct rx_work; |
Gustavo F. Padovan | c347b76 | 2011-12-14 23:53:47 -0200 | [diff] [blame] | 321 | struct work_struct cmd_work; |
Gustavo F. Padovan | 3eff45e | 2011-12-15 00:50:02 -0200 | [diff] [blame] | 322 | struct work_struct tx_work; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 323 | |
| 324 | struct sk_buff_head rx_q; |
| 325 | struct sk_buff_head raw_q; |
| 326 | struct sk_buff_head cmd_q; |
| 327 | |
| 328 | struct sk_buff *sent_cmd; |
| 329 | |
Thomas Gleixner | a6a67ef | 2009-07-26 08:18:19 +0000 | [diff] [blame] | 330 | struct mutex req_lock; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 331 | wait_queue_head_t req_wait_q; |
| 332 | __u32 req_status; |
| 333 | __u32 req_result; |
Johan Hedberg | f60cb30 | 2015-04-02 13:41:09 +0300 | [diff] [blame] | 334 | struct sk_buff *req_skb; |
Johan Hedberg | a5040ef | 2011-01-10 13:28:59 +0200 | [diff] [blame] | 335 | |
Johan Hedberg | 70db83c | 2014-08-08 09:37:16 +0300 | [diff] [blame] | 336 | void *smp_data; |
Johan Hedberg | ef8efe4 | 2014-08-13 15:12:32 +0300 | [diff] [blame] | 337 | void *smp_bredr_data; |
Johan Hedberg | 2e58ef3 | 2011-11-08 20:40:15 +0200 | [diff] [blame] | 338 | |
Johan Hedberg | 3088351 | 2012-01-04 14:16:21 +0200 | [diff] [blame] | 339 | struct discovery_state discovery; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 340 | struct hci_conn_hash conn_hash; |
Andre Guedes | 5c136e9 | 2014-01-30 18:22:05 -0300 | [diff] [blame] | 341 | |
| 342 | struct list_head mgmt_pending; |
David Miller | ea4bd8b | 2010-07-30 21:54:49 -0700 | [diff] [blame] | 343 | struct list_head blacklist; |
Johan Hedberg | 6659358 | 2014-07-09 12:59:14 +0300 | [diff] [blame] | 344 | struct list_head whitelist; |
Johan Hedberg | 2aeb9a1 | 2011-01-04 12:08:51 +0200 | [diff] [blame] | 345 | struct list_head uuids; |
Johan Hedberg | 55ed8ca1 | 2011-01-17 14:41:05 +0200 | [diff] [blame] | 346 | struct list_head link_keys; |
Vinicius Costa Gomes | b899efa | 2012-02-02 21:08:00 -0300 | [diff] [blame] | 347 | struct list_head long_term_keys; |
Johan Hedberg | 970c4e4 | 2014-02-18 10:19:33 +0200 | [diff] [blame] | 348 | struct list_head identity_resolving_keys; |
Szymon Janc | 2763eda | 2011-03-22 13:12:22 +0100 | [diff] [blame] | 349 | struct list_head remote_oob_data; |
Marcel Holtmann | d2ab0ac | 2014-02-27 20:37:30 -0800 | [diff] [blame] | 350 | struct list_head le_white_list; |
Andre Guedes | 15819a7 | 2014-02-03 13:56:18 -0300 | [diff] [blame] | 351 | struct list_head le_conn_params; |
Andre Guedes | 77a77a3 | 2014-02-26 20:21:46 -0300 | [diff] [blame] | 352 | struct list_head pend_le_conns; |
Johan Hedberg | 66f8455 | 2014-07-04 12:37:18 +0300 | [diff] [blame] | 353 | struct list_head pend_le_reports; |
Szymon Janc | 2763eda | 2011-03-22 13:12:22 +0100 | [diff] [blame] | 354 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 355 | struct hci_dev_stats stat; |
| 356 | |
Andrei Emeltchenko | 70f23020 | 2010-12-01 16:58:25 +0200 | [diff] [blame] | 357 | atomic_t promisc; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 358 | |
Marcel Holtmann | ca325f6 | 2010-02-08 16:22:31 +0100 | [diff] [blame] | 359 | struct dentry *debugfs; |
| 360 | |
Marcel Holtmann | a91f2e3 | 2006-07-03 10:02:41 +0200 | [diff] [blame] | 361 | struct device dev; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 362 | |
Marcel Holtmann | 611b30f | 2009-06-08 14:41:38 +0200 | [diff] [blame] | 363 | struct rfkill *rfkill; |
| 364 | |
Marcel Holtmann | eacb44d | 2015-03-13 09:04:17 -0700 | [diff] [blame] | 365 | DECLARE_BITMAP(dev_flags, __HCI_NUM_FLAGS); |
Andre Guedes | d23264a | 2011-11-25 20:53:38 -0300 | [diff] [blame] | 366 | |
Andre Guedes | 7ba8b4b | 2012-02-03 17:47:59 -0300 | [diff] [blame] | 367 | struct delayed_work le_scan_disable; |
Jakub Pawlowski | 2d28cfe | 2015-02-01 23:07:54 -0800 | [diff] [blame] | 368 | struct delayed_work le_scan_restart; |
Andre Guedes | 7ba8b4b | 2012-02-03 17:47:59 -0300 | [diff] [blame] | 369 | |
Johan Hedberg | 8fa1909 | 2012-10-19 20:57:49 +0300 | [diff] [blame] | 370 | __s8 adv_tx_power; |
Johan Hedberg | 3f0f524 | 2012-11-08 01:23:00 +0100 | [diff] [blame] | 371 | __u8 adv_data[HCI_MAX_AD_LENGTH]; |
| 372 | __u8 adv_data_len; |
Marcel Holtmann | f8e808b | 2013-10-16 00:16:47 -0700 | [diff] [blame] | 373 | __u8 scan_rsp_data[HCI_MAX_AD_LENGTH]; |
| 374 | __u8 scan_rsp_data_len; |
Johan Hedberg | 8fa1909 | 2012-10-19 20:57:49 +0300 | [diff] [blame] | 375 | |
Arman Uguray | 203fea0 | 2015-03-23 15:57:11 -0700 | [diff] [blame] | 376 | struct adv_info adv_instance; |
| 377 | |
Johan Hedberg | 863efaf | 2014-02-22 19:06:32 +0200 | [diff] [blame] | 378 | __u8 irk[16]; |
Johan Hedberg | d6bfd59 | 2014-02-23 19:42:20 +0200 | [diff] [blame] | 379 | __u32 rpa_timeout; |
| 380 | struct delayed_work rpa_expired; |
Marcel Holtmann | 2b5224d | 2014-02-23 20:39:22 -0800 | [diff] [blame] | 381 | bdaddr_t rpa; |
Johan Hedberg | 863efaf | 2014-02-22 19:06:32 +0200 | [diff] [blame] | 382 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 383 | int (*open)(struct hci_dev *hdev); |
| 384 | int (*close)(struct hci_dev *hdev); |
| 385 | int (*flush)(struct hci_dev *hdev); |
Marcel Holtmann | f41c70c | 2012-11-12 14:02:14 +0900 | [diff] [blame] | 386 | int (*setup)(struct hci_dev *hdev); |
Tedd Ho-Jeong An | a44fecb | 2015-02-13 09:20:50 -0800 | [diff] [blame] | 387 | int (*shutdown)(struct hci_dev *hdev); |
Marcel Holtmann | 7bd8f09 | 2013-10-11 06:19:18 -0700 | [diff] [blame] | 388 | int (*send)(struct hci_dev *hdev, struct sk_buff *skb); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 389 | void (*notify)(struct hci_dev *hdev, unsigned int evt); |
Marcel Holtmann | c7741d1 | 2015-01-28 11:09:55 -0800 | [diff] [blame] | 390 | void (*hw_error)(struct hci_dev *hdev, u8 code); |
Marcel Holtmann | 24c457e | 2014-07-02 00:53:47 +0200 | [diff] [blame] | 391 | int (*set_bdaddr)(struct hci_dev *hdev, const bdaddr_t *bdaddr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 392 | }; |
| 393 | |
Andrei Emeltchenko | 53502d6 | 2012-10-10 17:38:27 +0300 | [diff] [blame] | 394 | #define HCI_PHY_HANDLE(handle) (handle & 0xff) |
| 395 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 396 | struct hci_conn { |
| 397 | struct list_head list; |
| 398 | |
Szymon Janc | adc4266 | 2011-02-17 16:42:00 +0100 | [diff] [blame] | 399 | atomic_t refcnt; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 400 | |
Szymon Janc | adc4266 | 2011-02-17 16:42:00 +0100 | [diff] [blame] | 401 | bdaddr_t dst; |
Waldemar Rymarkiewicz | 5a9d0a3 | 2011-06-07 11:18:06 +0200 | [diff] [blame] | 402 | __u8 dst_type; |
Marcel Holtmann | 662e882 | 2013-10-13 05:23:59 -0700 | [diff] [blame] | 403 | bdaddr_t src; |
Marcel Holtmann | e7c4096 | 2013-10-13 03:57:39 -0700 | [diff] [blame] | 404 | __u8 src_type; |
Johan Hedberg | cb1d68f | 2014-02-28 12:54:16 +0200 | [diff] [blame] | 405 | bdaddr_t init_addr; |
| 406 | __u8 init_addr_type; |
| 407 | bdaddr_t resp_addr; |
| 408 | __u8 resp_addr_type; |
Szymon Janc | adc4266 | 2011-02-17 16:42:00 +0100 | [diff] [blame] | 409 | __u16 handle; |
| 410 | __u16 state; |
| 411 | __u8 mode; |
| 412 | __u8 type; |
Johan Hedberg | 40bef30 | 2014-07-16 11:42:27 +0300 | [diff] [blame] | 413 | __u8 role; |
Johan Hedberg | a0c808b | 2012-01-16 09:49:58 +0200 | [diff] [blame] | 414 | bool out; |
Szymon Janc | adc4266 | 2011-02-17 16:42:00 +0100 | [diff] [blame] | 415 | __u8 attempt; |
| 416 | __u8 dev_class[3]; |
Johan Hedberg | cad718e | 2013-04-17 15:00:51 +0300 | [diff] [blame] | 417 | __u8 features[HCI_MAX_PAGES][8]; |
Szymon Janc | adc4266 | 2011-02-17 16:42:00 +0100 | [diff] [blame] | 418 | __u16 pkt_type; |
| 419 | __u16 link_policy; |
Waldemar Rymarkiewicz | 13d3931 | 2011-04-28 12:07:55 +0200 | [diff] [blame] | 420 | __u8 key_type; |
Szymon Janc | adc4266 | 2011-02-17 16:42:00 +0100 | [diff] [blame] | 421 | __u8 auth_type; |
| 422 | __u8 sec_level; |
| 423 | __u8 pending_sec_level; |
| 424 | __u8 pin_length; |
Vinicius Costa Gomes | 726b4ff | 2011-07-08 18:31:45 -0300 | [diff] [blame] | 425 | __u8 enc_key_size; |
Szymon Janc | adc4266 | 2011-02-17 16:42:00 +0100 | [diff] [blame] | 426 | __u8 io_capability; |
Johan Hedberg | 92a2525 | 2012-09-06 18:39:26 +0300 | [diff] [blame] | 427 | __u32 passkey_notify; |
| 428 | __u8 passkey_entered; |
Szymon Janc | adc4266 | 2011-02-17 16:42:00 +0100 | [diff] [blame] | 429 | __u16 disc_timeout; |
Johan Hedberg | 09ae260 | 2014-07-06 13:41:15 +0300 | [diff] [blame] | 430 | __u16 conn_timeout; |
Frédéric Dalleau | 10c62dd | 2013-08-19 14:23:59 +0200 | [diff] [blame] | 431 | __u16 setting; |
Andre Guedes | 1e406ee | 2014-01-30 18:22:04 -0300 | [diff] [blame] | 432 | __u16 le_conn_min_interval; |
| 433 | __u16 le_conn_max_interval; |
Marcel Holtmann | e04fde6 | 2014-06-23 11:40:04 +0200 | [diff] [blame] | 434 | __u16 le_conn_interval; |
| 435 | __u16 le_conn_latency; |
| 436 | __u16 le_supv_timeout; |
Alfonso Acosta | fd45ada | 2014-10-07 08:44:11 +0000 | [diff] [blame] | 437 | __u8 le_adv_data[HCI_MAX_AD_LENGTH]; |
| 438 | __u8 le_adv_data_len; |
Andrzej Kaczmarek | 5ae76a9 | 2014-05-08 15:32:08 +0200 | [diff] [blame] | 439 | __s8 rssi; |
Andrzej Kaczmarek | 5a134fa | 2014-05-09 21:35:28 +0200 | [diff] [blame] | 440 | __s8 tx_power; |
Andrzej Kaczmarek | d0455ed | 2014-05-14 13:43:05 +0200 | [diff] [blame] | 441 | __s8 max_tx_power; |
Johan Hedberg | 51a8efd | 2012-01-16 06:10:31 +0200 | [diff] [blame] | 442 | unsigned long flags; |
Marcel Holtmann | 04837f6 | 2006-07-03 10:02:33 +0200 | [diff] [blame] | 443 | |
Johan Hedberg | 33f3572 | 2014-06-28 17:54:06 +0300 | [diff] [blame] | 444 | __u32 clock; |
| 445 | __u16 clock_accuracy; |
| 446 | |
Andrzej Kaczmarek | dd98380 | 2014-05-14 13:43:03 +0200 | [diff] [blame] | 447 | unsigned long conn_info_timestamp; |
| 448 | |
Johan Hedberg | 03b555e | 2011-01-04 15:40:05 +0200 | [diff] [blame] | 449 | __u8 remote_cap; |
Johan Hedberg | 03b555e | 2011-01-04 15:40:05 +0200 | [diff] [blame] | 450 | __u8 remote_auth; |
Andrei Emeltchenko | 3161ae1 | 2012-09-27 17:26:11 +0300 | [diff] [blame] | 451 | __u8 remote_id; |
Johan Hedberg | 03b555e | 2011-01-04 15:40:05 +0200 | [diff] [blame] | 452 | |
Szymon Janc | adc4266 | 2011-02-17 16:42:00 +0100 | [diff] [blame] | 453 | unsigned int sent; |
Marcel Holtmann | 04837f6 | 2006-07-03 10:02:33 +0200 | [diff] [blame] | 454 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 455 | struct sk_buff_head data_q; |
Gustavo F. Padovan | 2c33c06 | 2011-12-14 13:02:51 -0200 | [diff] [blame] | 456 | struct list_head chan_list; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 457 | |
Gustavo F. Padovan | 19c40e3 | 2011-06-17 13:03:21 -0300 | [diff] [blame] | 458 | struct delayed_work disc_work; |
Johan Hedberg | 7bc18d9 | 2013-10-16 18:11:39 +0300 | [diff] [blame] | 459 | struct delayed_work auto_accept_work; |
Johan Hedberg | a74a84f | 2013-10-16 18:11:40 +0300 | [diff] [blame] | 460 | struct delayed_work idle_work; |
Johan Hedberg | 9489eca | 2014-02-28 17:45:46 +0200 | [diff] [blame] | 461 | struct delayed_work le_conn_timeout; |
Marcel Holtmann | 04837f6 | 2006-07-03 10:02:33 +0200 | [diff] [blame] | 462 | |
Marcel Holtmann | b219e3a | 2006-07-06 12:38:46 +0200 | [diff] [blame] | 463 | struct device dev; |
Marcel Holtmann | 23b9ceb | 2014-12-20 17:13:41 +0100 | [diff] [blame] | 464 | struct dentry *debugfs; |
Marcel Holtmann | b219e3a | 2006-07-06 12:38:46 +0200 | [diff] [blame] | 465 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 466 | struct hci_dev *hdev; |
| 467 | void *l2cap_data; |
| 468 | void *sco_data; |
Andrei Emeltchenko | 9740e49 | 2012-05-29 13:59:02 +0300 | [diff] [blame] | 469 | struct amp_mgr *amp_mgr; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 470 | |
| 471 | struct hci_conn *link; |
Johan Hedberg | e9a416b | 2011-02-19 12:05:56 -0300 | [diff] [blame] | 472 | |
| 473 | void (*connect_cfm_cb) (struct hci_conn *conn, u8 status); |
| 474 | void (*security_cfm_cb) (struct hci_conn *conn, u8 status); |
| 475 | void (*disconn_cfm_cb) (struct hci_conn *conn, u8 reason); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 476 | }; |
| 477 | |
Luiz Augusto von Dentz | 73d80de | 2011-11-02 15:52:01 +0200 | [diff] [blame] | 478 | struct hci_chan { |
| 479 | struct list_head list; |
Andrei Emeltchenko | 42c4e53 | 2012-10-10 17:38:28 +0300 | [diff] [blame] | 480 | __u16 handle; |
Luiz Augusto von Dentz | 73d80de | 2011-11-02 15:52:01 +0200 | [diff] [blame] | 481 | struct hci_conn *conn; |
| 482 | struct sk_buff_head data_q; |
| 483 | unsigned int sent; |
Mat Martineau | 168df8e | 2012-10-23 15:24:13 -0700 | [diff] [blame] | 484 | __u8 state; |
Luiz Augusto von Dentz | 73d80de | 2011-11-02 15:52:01 +0200 | [diff] [blame] | 485 | }; |
| 486 | |
Andre Guedes | 15819a7 | 2014-02-03 13:56:18 -0300 | [diff] [blame] | 487 | struct hci_conn_params { |
| 488 | struct list_head list; |
Johan Hedberg | 93450c7 | 2014-07-04 12:37:17 +0300 | [diff] [blame] | 489 | struct list_head action; |
Andre Guedes | 15819a7 | 2014-02-03 13:56:18 -0300 | [diff] [blame] | 490 | |
| 491 | bdaddr_t addr; |
| 492 | u8 addr_type; |
| 493 | |
| 494 | u16 conn_min_interval; |
| 495 | u16 conn_max_interval; |
Marcel Holtmann | f044eb0 | 2014-06-29 16:43:26 +0200 | [diff] [blame] | 496 | u16 conn_latency; |
| 497 | u16 supervision_timeout; |
Andre Guedes | 9fcb18e | 2014-02-26 20:21:48 -0300 | [diff] [blame] | 498 | |
| 499 | enum { |
| 500 | HCI_AUTO_CONN_DISABLED, |
Johan Hedberg | a3451d2 | 2014-07-02 17:37:27 +0300 | [diff] [blame] | 501 | HCI_AUTO_CONN_REPORT, |
Marcel Holtmann | 4b9e7e7 | 2014-07-23 21:55:23 +0200 | [diff] [blame] | 502 | HCI_AUTO_CONN_DIRECT, |
Andre Guedes | 9fcb18e | 2014-02-26 20:21:48 -0300 | [diff] [blame] | 503 | HCI_AUTO_CONN_ALWAYS, |
| 504 | HCI_AUTO_CONN_LINK_LOSS, |
| 505 | } auto_connect; |
Johan Hedberg | f161dd4 | 2014-08-15 21:06:54 +0300 | [diff] [blame] | 506 | |
| 507 | struct hci_conn *conn; |
Andre Guedes | 15819a7 | 2014-02-03 13:56:18 -0300 | [diff] [blame] | 508 | }; |
| 509 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 510 | extern struct list_head hci_dev_list; |
| 511 | extern struct list_head hci_cb_list; |
| 512 | extern rwlock_t hci_dev_list_lock; |
Johan Hedberg | fba7ecf | 2015-02-18 14:53:55 +0200 | [diff] [blame] | 513 | extern struct mutex hci_cb_list_lock; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 514 | |
Marcel Holtmann | eacb44d | 2015-03-13 09:04:17 -0700 | [diff] [blame] | 515 | #define hci_dev_set_flag(hdev, nr) set_bit((nr), (hdev)->dev_flags) |
| 516 | #define hci_dev_clear_flag(hdev, nr) clear_bit((nr), (hdev)->dev_flags) |
| 517 | #define hci_dev_change_flag(hdev, nr) change_bit((nr), (hdev)->dev_flags) |
| 518 | #define hci_dev_test_flag(hdev, nr) test_bit((nr), (hdev)->dev_flags) |
| 519 | #define hci_dev_test_and_set_flag(hdev, nr) test_and_set_bit((nr), (hdev)->dev_flags) |
| 520 | #define hci_dev_test_and_clear_flag(hdev, nr) test_and_clear_bit((nr), (hdev)->dev_flags) |
| 521 | #define hci_dev_test_and_change_flag(hdev, nr) test_and_change_bit((nr), (hdev)->dev_flags) |
Marcel Holtmann | d7a5a11 | 2015-03-13 02:11:00 -0700 | [diff] [blame] | 522 | |
Marcel Holtmann | eacb44d | 2015-03-13 09:04:17 -0700 | [diff] [blame] | 523 | #define hci_dev_clear_volatile_flags(hdev) \ |
| 524 | do { \ |
| 525 | hci_dev_clear_flag(hdev, HCI_LE_SCAN); \ |
| 526 | hci_dev_clear_flag(hdev, HCI_LE_ADV); \ |
| 527 | hci_dev_clear_flag(hdev, HCI_PERIODIC_INQ); \ |
| 528 | } while (0) |
Marcel Holtmann | 516018a | 2015-03-13 02:11:04 -0700 | [diff] [blame] | 529 | |
Ulisses Furquim | 686ebf2 | 2011-12-21 10:11:33 -0200 | [diff] [blame] | 530 | /* ----- HCI interface to upper protocols ----- */ |
Joe Perches | e74e58f | 2013-09-23 11:37:36 -0700 | [diff] [blame] | 531 | int l2cap_connect_ind(struct hci_dev *hdev, bdaddr_t *bdaddr); |
Joe Perches | e74e58f | 2013-09-23 11:37:36 -0700 | [diff] [blame] | 532 | int l2cap_disconn_ind(struct hci_conn *hcon); |
Arron Wang | 9b4c333 | 2015-06-09 17:47:22 +0800 | [diff] [blame] | 533 | void l2cap_recv_acldata(struct hci_conn *hcon, struct sk_buff *skb, u16 flags); |
Ulisses Furquim | 686ebf2 | 2011-12-21 10:11:33 -0200 | [diff] [blame] | 534 | |
Arron Wang | ff50e8a | 2015-06-09 17:47:23 +0800 | [diff] [blame^] | 535 | #if IS_ENABLED(CONFIG_BT_BREDR) |
Joe Perches | e74e58f | 2013-09-23 11:37:36 -0700 | [diff] [blame] | 536 | int sco_connect_ind(struct hci_dev *hdev, bdaddr_t *bdaddr, __u8 *flags); |
Arron Wang | 9b4c333 | 2015-06-09 17:47:22 +0800 | [diff] [blame] | 537 | void sco_recv_scodata(struct hci_conn *hcon, struct sk_buff *skb); |
Arron Wang | ff50e8a | 2015-06-09 17:47:23 +0800 | [diff] [blame^] | 538 | #else |
| 539 | static inline int sco_connect_ind(struct hci_dev *hdev, bdaddr_t *bdaddr, |
| 540 | __u8 *flags) |
| 541 | { |
| 542 | return 0; |
| 543 | } |
| 544 | |
| 545 | static inline void sco_recv_scodata(struct hci_conn *hcon, struct sk_buff *skb) |
| 546 | { |
| 547 | } |
| 548 | #endif |
Ulisses Furquim | 686ebf2 | 2011-12-21 10:11:33 -0200 | [diff] [blame] | 549 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 550 | /* ----- Inquiry cache ----- */ |
Andrei Emeltchenko | 70f23020 | 2010-12-01 16:58:25 +0200 | [diff] [blame] | 551 | #define INQUIRY_CACHE_AGE_MAX (HZ*30) /* 30 seconds */ |
| 552 | #define INQUIRY_ENTRY_AGE_MAX (HZ*60) /* 60 seconds */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 553 | |
Johan Hedberg | 3088351 | 2012-01-04 14:16:21 +0200 | [diff] [blame] | 554 | static inline void discovery_init(struct hci_dev *hdev) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 555 | { |
Johan Hedberg | ff9ef57 | 2012-01-04 14:23:45 +0200 | [diff] [blame] | 556 | hdev->discovery.state = DISCOVERY_STOPPED; |
Johan Hedberg | 3088351 | 2012-01-04 14:16:21 +0200 | [diff] [blame] | 557 | INIT_LIST_HEAD(&hdev->discovery.all); |
| 558 | INIT_LIST_HEAD(&hdev->discovery.unknown); |
| 559 | INIT_LIST_HEAD(&hdev->discovery.resolve); |
Marcel Holtmann | da25cf6 | 2014-12-05 13:03:35 +0100 | [diff] [blame] | 560 | hdev->discovery.report_invalid_rssi = true; |
Jakub Pawlowski | 37eab04 | 2014-12-05 10:55:55 +0100 | [diff] [blame] | 561 | hdev->discovery.rssi = HCI_RSSI_INVALID; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 562 | } |
| 563 | |
Marcel Holtmann | 0256325 | 2014-12-05 11:45:21 +0100 | [diff] [blame] | 564 | static inline void hci_discovery_filter_clear(struct hci_dev *hdev) |
| 565 | { |
Jakub Pawlowski | 82f8b65 | 2015-03-04 16:24:26 -0800 | [diff] [blame] | 566 | hdev->discovery.result_filtering = false; |
Marcel Holtmann | da25cf6 | 2014-12-05 13:03:35 +0100 | [diff] [blame] | 567 | hdev->discovery.report_invalid_rssi = true; |
Marcel Holtmann | 0256325 | 2014-12-05 11:45:21 +0100 | [diff] [blame] | 568 | hdev->discovery.rssi = HCI_RSSI_INVALID; |
| 569 | hdev->discovery.uuid_count = 0; |
| 570 | kfree(hdev->discovery.uuids); |
| 571 | hdev->discovery.uuids = NULL; |
Jakub Pawlowski | 2d28cfe | 2015-02-01 23:07:54 -0800 | [diff] [blame] | 572 | hdev->discovery.scan_start = 0; |
| 573 | hdev->discovery.scan_duration = 0; |
Marcel Holtmann | 0256325 | 2014-12-05 11:45:21 +0100 | [diff] [blame] | 574 | } |
| 575 | |
Arman Uguray | 203fea0 | 2015-03-23 15:57:11 -0700 | [diff] [blame] | 576 | static inline void adv_info_init(struct hci_dev *hdev) |
| 577 | { |
| 578 | memset(&hdev->adv_instance, 0, sizeof(struct adv_info)); |
| 579 | } |
| 580 | |
Johan Hedberg | 30dc78e | 2012-01-04 15:44:20 +0200 | [diff] [blame] | 581 | bool hci_discovery_active(struct hci_dev *hdev); |
| 582 | |
Johan Hedberg | ff9ef57 | 2012-01-04 14:23:45 +0200 | [diff] [blame] | 583 | void hci_discovery_set_state(struct hci_dev *hdev, int state); |
| 584 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 585 | static inline int inquiry_cache_empty(struct hci_dev *hdev) |
| 586 | { |
Johan Hedberg | 3088351 | 2012-01-04 14:16:21 +0200 | [diff] [blame] | 587 | return list_empty(&hdev->discovery.all); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 588 | } |
| 589 | |
| 590 | static inline long inquiry_cache_age(struct hci_dev *hdev) |
| 591 | { |
Johan Hedberg | 3088351 | 2012-01-04 14:16:21 +0200 | [diff] [blame] | 592 | struct discovery_state *c = &hdev->discovery; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 593 | return jiffies - c->timestamp; |
| 594 | } |
| 595 | |
| 596 | static inline long inquiry_entry_age(struct inquiry_entry *e) |
| 597 | { |
| 598 | return jiffies - e->timestamp; |
| 599 | } |
| 600 | |
Waldemar Rymarkiewicz | 5a9d0a3 | 2011-06-07 11:18:06 +0200 | [diff] [blame] | 601 | struct inquiry_entry *hci_inquiry_cache_lookup(struct hci_dev *hdev, |
Gustavo F. Padovan | 0412468 | 2012-03-08 01:25:00 -0300 | [diff] [blame] | 602 | bdaddr_t *bdaddr); |
Johan Hedberg | 561aafb | 2012-01-04 13:31:59 +0200 | [diff] [blame] | 603 | struct inquiry_entry *hci_inquiry_cache_lookup_unknown(struct hci_dev *hdev, |
Gustavo F. Padovan | 0412468 | 2012-03-08 01:25:00 -0300 | [diff] [blame] | 604 | bdaddr_t *bdaddr); |
Johan Hedberg | 30dc78e | 2012-01-04 15:44:20 +0200 | [diff] [blame] | 605 | struct inquiry_entry *hci_inquiry_cache_lookup_resolve(struct hci_dev *hdev, |
Gustavo F. Padovan | 0412468 | 2012-03-08 01:25:00 -0300 | [diff] [blame] | 606 | bdaddr_t *bdaddr, |
| 607 | int state); |
Johan Hedberg | a3d4e20 | 2012-01-09 00:53:02 +0200 | [diff] [blame] | 608 | void hci_inquiry_cache_update_resolve(struct hci_dev *hdev, |
Gustavo F. Padovan | 0412468 | 2012-03-08 01:25:00 -0300 | [diff] [blame] | 609 | struct inquiry_entry *ie); |
Marcel Holtmann | af58925 | 2014-07-01 14:11:20 +0200 | [diff] [blame] | 610 | u32 hci_inquiry_cache_update(struct hci_dev *hdev, struct inquiry_data *data, |
| 611 | bool name_known); |
Andre Guedes | 1f9b9a5 | 2013-04-30 15:29:27 -0300 | [diff] [blame] | 612 | void hci_inquiry_cache_flush(struct hci_dev *hdev); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 613 | |
| 614 | /* ----- HCI Connections ----- */ |
| 615 | enum { |
| 616 | HCI_CONN_AUTH_PEND, |
Waldemar Rymarkiewicz | 19f8def | 2011-05-31 15:49:25 +0200 | [diff] [blame] | 617 | HCI_CONN_REAUTH_PEND, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 618 | HCI_CONN_ENCRYPT_PEND, |
Marcel Holtmann | 04837f6 | 2006-07-03 10:02:33 +0200 | [diff] [blame] | 619 | HCI_CONN_RSWITCH_PEND, |
| 620 | HCI_CONN_MODE_CHANGE_PEND, |
Marcel Holtmann | e73439d | 2010-07-26 10:06:00 -0400 | [diff] [blame] | 621 | HCI_CONN_SCO_SETUP_PEND, |
Johan Hedberg | b644ba3 | 2012-01-17 21:48:47 +0200 | [diff] [blame] | 622 | HCI_CONN_MGMT_CONNECTED, |
Johan Hedberg | 58a681e | 2012-01-16 06:47:28 +0200 | [diff] [blame] | 623 | HCI_CONN_SSP_ENABLED, |
Marcel Holtmann | eb9a8f3 | 2014-01-15 22:37:38 -0800 | [diff] [blame] | 624 | HCI_CONN_SC_ENABLED, |
Marcel Holtmann | abf76ba | 2014-01-31 16:24:28 -0800 | [diff] [blame] | 625 | HCI_CONN_AES_CCM, |
Johan Hedberg | 58a681e | 2012-01-16 06:47:28 +0200 | [diff] [blame] | 626 | HCI_CONN_POWER_SAVE, |
Johan Hedberg | af6a9c3 | 2014-06-24 13:15:53 +0300 | [diff] [blame] | 627 | HCI_CONN_FLUSH_KEY, |
Johan Hedberg | 4dae279 | 2014-06-24 17:03:50 +0300 | [diff] [blame] | 628 | HCI_CONN_ENCRYPT, |
| 629 | HCI_CONN_AUTH, |
| 630 | HCI_CONN_SECURE, |
| 631 | HCI_CONN_FIPS, |
Johan Hedberg | fe59a05 | 2014-07-01 19:14:12 +0300 | [diff] [blame] | 632 | HCI_CONN_STK_ENCRYPT, |
Johan Hedberg | 977f8fc | 2014-07-17 15:35:39 +0300 | [diff] [blame] | 633 | HCI_CONN_AUTH_INITIATOR, |
Johan Hedberg | f94b665 | 2014-08-18 00:41:44 +0300 | [diff] [blame] | 634 | HCI_CONN_DROP, |
Alfonso Acosta | 89cbb06 | 2014-10-11 21:44:47 +0000 | [diff] [blame] | 635 | HCI_CONN_PARAM_REMOVAL_PEND, |
Johan Hedberg | fe8bc5a | 2014-08-14 12:33:17 +0300 | [diff] [blame] | 636 | HCI_CONN_NEW_LINK_KEY, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 637 | }; |
| 638 | |
Johan Hedberg | aa64a8b | 2012-01-18 21:33:12 +0200 | [diff] [blame] | 639 | static inline bool hci_conn_ssp_enabled(struct hci_conn *conn) |
| 640 | { |
| 641 | struct hci_dev *hdev = conn->hdev; |
Marcel Holtmann | d7a5a11 | 2015-03-13 02:11:00 -0700 | [diff] [blame] | 642 | return hci_dev_test_flag(hdev, HCI_SSP_ENABLED) && |
Gustavo Padovan | c3c7ea6 | 2012-05-23 04:04:20 -0300 | [diff] [blame] | 643 | test_bit(HCI_CONN_SSP_ENABLED, &conn->flags); |
Johan Hedberg | aa64a8b | 2012-01-18 21:33:12 +0200 | [diff] [blame] | 644 | } |
| 645 | |
Marcel Holtmann | eb9a8f3 | 2014-01-15 22:37:38 -0800 | [diff] [blame] | 646 | static inline bool hci_conn_sc_enabled(struct hci_conn *conn) |
| 647 | { |
| 648 | struct hci_dev *hdev = conn->hdev; |
Marcel Holtmann | d7a5a11 | 2015-03-13 02:11:00 -0700 | [diff] [blame] | 649 | return hci_dev_test_flag(hdev, HCI_SC_ENABLED) && |
Marcel Holtmann | eb9a8f3 | 2014-01-15 22:37:38 -0800 | [diff] [blame] | 650 | test_bit(HCI_CONN_SC_ENABLED, &conn->flags); |
| 651 | } |
| 652 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 653 | static inline void hci_conn_hash_add(struct hci_dev *hdev, struct hci_conn *c) |
| 654 | { |
| 655 | struct hci_conn_hash *h = &hdev->conn_hash; |
Gustavo F. Padovan | bf4c632 | 2011-12-14 22:54:12 -0200 | [diff] [blame] | 656 | list_add_rcu(&c->list, &h->list); |
Ville Tervo | fcd89c0 | 2011-02-10 22:38:47 -0300 | [diff] [blame] | 657 | switch (c->type) { |
| 658 | case ACL_LINK: |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 659 | h->acl_num++; |
Ville Tervo | fcd89c0 | 2011-02-10 22:38:47 -0300 | [diff] [blame] | 660 | break; |
Andrei Emeltchenko | bd1eb66 | 2012-10-10 17:38:30 +0300 | [diff] [blame] | 661 | case AMP_LINK: |
| 662 | h->amp_num++; |
| 663 | break; |
Ville Tervo | fcd89c0 | 2011-02-10 22:38:47 -0300 | [diff] [blame] | 664 | case LE_LINK: |
| 665 | h->le_num++; |
Johan Hedberg | f8218dc | 2014-07-16 11:56:08 +0300 | [diff] [blame] | 666 | if (c->role == HCI_ROLE_SLAVE) |
| 667 | h->le_num_slave++; |
Ville Tervo | fcd89c0 | 2011-02-10 22:38:47 -0300 | [diff] [blame] | 668 | break; |
| 669 | case SCO_LINK: |
| 670 | case ESCO_LINK: |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 671 | h->sco_num++; |
Ville Tervo | fcd89c0 | 2011-02-10 22:38:47 -0300 | [diff] [blame] | 672 | break; |
| 673 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 674 | } |
| 675 | |
| 676 | static inline void hci_conn_hash_del(struct hci_dev *hdev, struct hci_conn *c) |
| 677 | { |
| 678 | struct hci_conn_hash *h = &hdev->conn_hash; |
Gustavo F. Padovan | bf4c632 | 2011-12-14 22:54:12 -0200 | [diff] [blame] | 679 | |
| 680 | list_del_rcu(&c->list); |
| 681 | synchronize_rcu(); |
| 682 | |
Ville Tervo | fcd89c0 | 2011-02-10 22:38:47 -0300 | [diff] [blame] | 683 | switch (c->type) { |
| 684 | case ACL_LINK: |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 685 | h->acl_num--; |
Ville Tervo | fcd89c0 | 2011-02-10 22:38:47 -0300 | [diff] [blame] | 686 | break; |
Andrei Emeltchenko | bd1eb66 | 2012-10-10 17:38:30 +0300 | [diff] [blame] | 687 | case AMP_LINK: |
| 688 | h->amp_num--; |
| 689 | break; |
Ville Tervo | fcd89c0 | 2011-02-10 22:38:47 -0300 | [diff] [blame] | 690 | case LE_LINK: |
| 691 | h->le_num--; |
Johan Hedberg | f8218dc | 2014-07-16 11:56:08 +0300 | [diff] [blame] | 692 | if (c->role == HCI_ROLE_SLAVE) |
| 693 | h->le_num_slave--; |
Ville Tervo | fcd89c0 | 2011-02-10 22:38:47 -0300 | [diff] [blame] | 694 | break; |
| 695 | case SCO_LINK: |
| 696 | case ESCO_LINK: |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 697 | h->sco_num--; |
Ville Tervo | fcd89c0 | 2011-02-10 22:38:47 -0300 | [diff] [blame] | 698 | break; |
| 699 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 700 | } |
| 701 | |
Luiz Augusto von Dentz | 52087a7 | 2011-08-17 16:23:00 +0300 | [diff] [blame] | 702 | static inline unsigned int hci_conn_num(struct hci_dev *hdev, __u8 type) |
| 703 | { |
| 704 | struct hci_conn_hash *h = &hdev->conn_hash; |
| 705 | switch (type) { |
| 706 | case ACL_LINK: |
| 707 | return h->acl_num; |
Andrei Emeltchenko | bd1eb66 | 2012-10-10 17:38:30 +0300 | [diff] [blame] | 708 | case AMP_LINK: |
| 709 | return h->amp_num; |
Luiz Augusto von Dentz | 52087a7 | 2011-08-17 16:23:00 +0300 | [diff] [blame] | 710 | case LE_LINK: |
| 711 | return h->le_num; |
| 712 | case SCO_LINK: |
| 713 | case ESCO_LINK: |
| 714 | return h->sco_num; |
| 715 | default: |
| 716 | return 0; |
| 717 | } |
| 718 | } |
| 719 | |
Johan Hedberg | f4f0750 | 2014-02-24 14:52:16 +0200 | [diff] [blame] | 720 | static inline unsigned int hci_conn_count(struct hci_dev *hdev) |
| 721 | { |
| 722 | struct hci_conn_hash *c = &hdev->conn_hash; |
| 723 | |
| 724 | return c->acl_num + c->amp_num + c->sco_num + c->le_num; |
| 725 | } |
| 726 | |
Marcel Holtmann | 845472e8 | 2014-11-03 05:16:08 +0100 | [diff] [blame] | 727 | static inline __u8 hci_conn_lookup_type(struct hci_dev *hdev, __u16 handle) |
| 728 | { |
| 729 | struct hci_conn_hash *h = &hdev->conn_hash; |
| 730 | struct hci_conn *c; |
| 731 | __u8 type = INVALID_LINK; |
| 732 | |
| 733 | rcu_read_lock(); |
| 734 | |
| 735 | list_for_each_entry_rcu(c, &h->list, list) { |
| 736 | if (c->handle == handle) { |
| 737 | type = c->type; |
| 738 | break; |
| 739 | } |
| 740 | } |
| 741 | |
| 742 | rcu_read_unlock(); |
| 743 | |
| 744 | return type; |
| 745 | } |
| 746 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 747 | static inline struct hci_conn *hci_conn_hash_lookup_handle(struct hci_dev *hdev, |
Szymon Janc | adc4266 | 2011-02-17 16:42:00 +0100 | [diff] [blame] | 748 | __u16 handle) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 749 | { |
| 750 | struct hci_conn_hash *h = &hdev->conn_hash; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 751 | struct hci_conn *c; |
| 752 | |
Gustavo F. Padovan | bf4c632 | 2011-12-14 22:54:12 -0200 | [diff] [blame] | 753 | rcu_read_lock(); |
| 754 | |
| 755 | list_for_each_entry_rcu(c, &h->list, list) { |
| 756 | if (c->handle == handle) { |
| 757 | rcu_read_unlock(); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 758 | return c; |
Gustavo F. Padovan | bf4c632 | 2011-12-14 22:54:12 -0200 | [diff] [blame] | 759 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 760 | } |
Gustavo F. Padovan | bf4c632 | 2011-12-14 22:54:12 -0200 | [diff] [blame] | 761 | rcu_read_unlock(); |
| 762 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 763 | return NULL; |
| 764 | } |
| 765 | |
| 766 | static inline struct hci_conn *hci_conn_hash_lookup_ba(struct hci_dev *hdev, |
Szymon Janc | adc4266 | 2011-02-17 16:42:00 +0100 | [diff] [blame] | 767 | __u8 type, bdaddr_t *ba) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 768 | { |
| 769 | struct hci_conn_hash *h = &hdev->conn_hash; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 770 | struct hci_conn *c; |
| 771 | |
Gustavo F. Padovan | bf4c632 | 2011-12-14 22:54:12 -0200 | [diff] [blame] | 772 | rcu_read_lock(); |
| 773 | |
| 774 | list_for_each_entry_rcu(c, &h->list, list) { |
| 775 | if (c->type == type && !bacmp(&c->dst, ba)) { |
| 776 | rcu_read_unlock(); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 777 | return c; |
Gustavo F. Padovan | bf4c632 | 2011-12-14 22:54:12 -0200 | [diff] [blame] | 778 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 779 | } |
Gustavo F. Padovan | bf4c632 | 2011-12-14 22:54:12 -0200 | [diff] [blame] | 780 | |
| 781 | rcu_read_unlock(); |
| 782 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 783 | return NULL; |
| 784 | } |
| 785 | |
Marcel Holtmann | 4c67bc7 | 2006-10-15 17:30:56 +0200 | [diff] [blame] | 786 | static inline struct hci_conn *hci_conn_hash_lookup_state(struct hci_dev *hdev, |
Szymon Janc | adc4266 | 2011-02-17 16:42:00 +0100 | [diff] [blame] | 787 | __u8 type, __u16 state) |
Marcel Holtmann | 4c67bc7 | 2006-10-15 17:30:56 +0200 | [diff] [blame] | 788 | { |
| 789 | struct hci_conn_hash *h = &hdev->conn_hash; |
Marcel Holtmann | 4c67bc7 | 2006-10-15 17:30:56 +0200 | [diff] [blame] | 790 | struct hci_conn *c; |
| 791 | |
Gustavo F. Padovan | bf4c632 | 2011-12-14 22:54:12 -0200 | [diff] [blame] | 792 | rcu_read_lock(); |
| 793 | |
| 794 | list_for_each_entry_rcu(c, &h->list, list) { |
| 795 | if (c->type == type && c->state == state) { |
| 796 | rcu_read_unlock(); |
Marcel Holtmann | 4c67bc7 | 2006-10-15 17:30:56 +0200 | [diff] [blame] | 797 | return c; |
Gustavo F. Padovan | bf4c632 | 2011-12-14 22:54:12 -0200 | [diff] [blame] | 798 | } |
Marcel Holtmann | 4c67bc7 | 2006-10-15 17:30:56 +0200 | [diff] [blame] | 799 | } |
Gustavo F. Padovan | bf4c632 | 2011-12-14 22:54:12 -0200 | [diff] [blame] | 800 | |
| 801 | rcu_read_unlock(); |
| 802 | |
Marcel Holtmann | 4c67bc7 | 2006-10-15 17:30:56 +0200 | [diff] [blame] | 803 | return NULL; |
| 804 | } |
| 805 | |
Johan Hedberg | e3b679d | 2014-08-18 20:33:32 +0300 | [diff] [blame] | 806 | int hci_disconnect(struct hci_conn *conn, __u8 reason); |
Frédéric Dalleau | 2dea632 | 2013-08-19 14:24:03 +0200 | [diff] [blame] | 807 | bool hci_setup_sync(struct hci_conn *conn, __u16 handle); |
Marcel Holtmann | e73439d | 2010-07-26 10:06:00 -0400 | [diff] [blame] | 808 | void hci_sco_setup(struct hci_conn *conn, __u8 status); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 809 | |
Johan Hedberg | a5c4e30 | 2014-07-16 11:56:07 +0300 | [diff] [blame] | 810 | struct hci_conn *hci_conn_add(struct hci_dev *hdev, int type, bdaddr_t *dst, |
| 811 | u8 role); |
Marcel Holtmann | a9de924 | 2007-10-20 13:33:56 +0200 | [diff] [blame] | 812 | int hci_conn_del(struct hci_conn *conn); |
| 813 | void hci_conn_hash_flush(struct hci_dev *hdev); |
| 814 | void hci_conn_check_pending(struct hci_dev *hdev); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 815 | |
Luiz Augusto von Dentz | 73d80de | 2011-11-02 15:52:01 +0200 | [diff] [blame] | 816 | struct hci_chan *hci_chan_create(struct hci_conn *conn); |
Andrei Emeltchenko | 9472007 | 2012-09-06 15:05:43 +0300 | [diff] [blame] | 817 | void hci_chan_del(struct hci_chan *chan); |
Gustavo F. Padovan | 2c33c06 | 2011-12-14 13:02:51 -0200 | [diff] [blame] | 818 | void hci_chan_list_flush(struct hci_conn *conn); |
Andrei Emeltchenko | 42c4e53 | 2012-10-10 17:38:28 +0300 | [diff] [blame] | 819 | struct hci_chan *hci_chan_lookup_handle(struct hci_dev *hdev, __u16 handle); |
Luiz Augusto von Dentz | 73d80de | 2011-11-02 15:52:01 +0200 | [diff] [blame] | 820 | |
Andre Guedes | 04a6c58 | 2014-02-26 20:21:44 -0300 | [diff] [blame] | 821 | struct hci_conn *hci_connect_le(struct hci_dev *hdev, bdaddr_t *dst, |
Johan Hedberg | cdd6275 | 2014-07-07 15:02:28 +0300 | [diff] [blame] | 822 | u8 dst_type, u8 sec_level, u16 conn_timeout, |
Johan Hedberg | e804d25 | 2014-07-16 11:42:28 +0300 | [diff] [blame] | 823 | u8 role); |
Andre Guedes | 04a6c58 | 2014-02-26 20:21:44 -0300 | [diff] [blame] | 824 | struct hci_conn *hci_connect_acl(struct hci_dev *hdev, bdaddr_t *dst, |
| 825 | u8 sec_level, u8 auth_type); |
Frédéric Dalleau | 10c62dd | 2013-08-19 14:23:59 +0200 | [diff] [blame] | 826 | struct hci_conn *hci_connect_sco(struct hci_dev *hdev, int type, bdaddr_t *dst, |
| 827 | __u16 setting); |
Marcel Holtmann | e7c29cb | 2008-09-09 07:19:20 +0200 | [diff] [blame] | 828 | int hci_conn_check_link_mode(struct hci_conn *conn); |
Waldemar Rymarkiewicz | b3b1b06 | 2011-05-06 09:42:31 +0200 | [diff] [blame] | 829 | int hci_conn_check_secure(struct hci_conn *conn, __u8 sec_level); |
Johan Hedberg | e7cafc4 | 2014-07-17 15:35:38 +0300 | [diff] [blame] | 830 | int hci_conn_security(struct hci_conn *conn, __u8 sec_level, __u8 auth_type, |
| 831 | bool initiator); |
Marcel Holtmann | 8c1b235 | 2009-01-15 21:58:04 +0100 | [diff] [blame] | 832 | int hci_conn_switch_role(struct hci_conn *conn, __u8 role); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 833 | |
Jaikumar Ganesh | 14b12d0 | 2011-05-23 18:06:04 -0700 | [diff] [blame] | 834 | void hci_conn_enter_active_mode(struct hci_conn *conn, __u8 force_active); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 835 | |
Andre Guedes | 06c053f | 2014-02-26 20:21:41 -0300 | [diff] [blame] | 836 | void hci_le_conn_failed(struct hci_conn *conn, u8 status); |
| 837 | |
David Herrmann | 8d12356 | 2013-04-06 20:28:39 +0200 | [diff] [blame] | 838 | /* |
| 839 | * hci_conn_get() and hci_conn_put() are used to control the life-time of an |
| 840 | * "hci_conn" object. They do not guarantee that the hci_conn object is running, |
| 841 | * working or anything else. They just guarantee that the object is available |
| 842 | * and can be dereferenced. So you can use its locks, local variables and any |
| 843 | * other constant data. |
| 844 | * Before accessing runtime data, you _must_ lock the object and then check that |
| 845 | * it is still running. As soon as you release the locks, the connection might |
| 846 | * get dropped, though. |
| 847 | * |
| 848 | * On the other hand, hci_conn_hold() and hci_conn_drop() are used to control |
| 849 | * how long the underlying connection is held. So every channel that runs on the |
| 850 | * hci_conn object calls this to prevent the connection from disappearing. As |
| 851 | * long as you hold a device, you must also guarantee that you have a valid |
| 852 | * reference to the device via hci_conn_get() (or the initial reference from |
| 853 | * hci_conn_add()). |
| 854 | * The hold()/drop() ref-count is known to drop below 0 sometimes, which doesn't |
| 855 | * break because nobody cares for that. But this means, we cannot use |
| 856 | * _get()/_drop() in it, but require the caller to have a valid ref (FIXME). |
| 857 | */ |
| 858 | |
Johan Hedberg | 51bb8457 | 2014-08-15 21:06:57 +0300 | [diff] [blame] | 859 | static inline struct hci_conn *hci_conn_get(struct hci_conn *conn) |
David Herrmann | 8d12356 | 2013-04-06 20:28:39 +0200 | [diff] [blame] | 860 | { |
| 861 | get_device(&conn->dev); |
Johan Hedberg | 51bb8457 | 2014-08-15 21:06:57 +0300 | [diff] [blame] | 862 | return conn; |
David Herrmann | 8d12356 | 2013-04-06 20:28:39 +0200 | [diff] [blame] | 863 | } |
| 864 | |
| 865 | static inline void hci_conn_put(struct hci_conn *conn) |
| 866 | { |
| 867 | put_device(&conn->dev); |
| 868 | } |
| 869 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 870 | static inline void hci_conn_hold(struct hci_conn *conn) |
| 871 | { |
Andrei Emeltchenko | 71becf0 | 2012-07-19 17:03:42 +0300 | [diff] [blame] | 872 | BT_DBG("hcon %p orig refcnt %d", conn, atomic_read(&conn->refcnt)); |
Andrei Emeltchenko | 38b3fef | 2012-06-15 11:50:28 +0300 | [diff] [blame] | 873 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 874 | atomic_inc(&conn->refcnt); |
Andre Guedes | 2f304d1 | 2012-01-27 19:42:02 -0300 | [diff] [blame] | 875 | cancel_delayed_work(&conn->disc_work); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 876 | } |
| 877 | |
David Herrmann | 76a68ba | 2013-04-06 20:28:37 +0200 | [diff] [blame] | 878 | static inline void hci_conn_drop(struct hci_conn *conn) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 879 | { |
Andrei Emeltchenko | 71becf0 | 2012-07-19 17:03:42 +0300 | [diff] [blame] | 880 | BT_DBG("hcon %p orig refcnt %d", conn, atomic_read(&conn->refcnt)); |
Andrei Emeltchenko | 38b3fef | 2012-06-15 11:50:28 +0300 | [diff] [blame] | 881 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 882 | if (atomic_dec_and_test(&conn->refcnt)) { |
Marcel Holtmann | 04837f6 | 2006-07-03 10:02:33 +0200 | [diff] [blame] | 883 | unsigned long timeo; |
Andrei Emeltchenko | 716e4ab | 2012-10-10 17:38:31 +0300 | [diff] [blame] | 884 | |
| 885 | switch (conn->type) { |
| 886 | case ACL_LINK: |
| 887 | case LE_LINK: |
Johan Hedberg | a74a84f | 2013-10-16 18:11:40 +0300 | [diff] [blame] | 888 | cancel_delayed_work(&conn->idle_work); |
Marcel Holtmann | 6ac5934 | 2006-09-26 09:43:48 +0200 | [diff] [blame] | 889 | if (conn->state == BT_CONNECTED) { |
Andrei Emeltchenko | 5f246e8 | 2012-06-11 11:13:07 +0300 | [diff] [blame] | 890 | timeo = conn->disc_timeout; |
Marcel Holtmann | 6ac5934 | 2006-09-26 09:43:48 +0200 | [diff] [blame] | 891 | if (!conn->out) |
Marcel Holtmann | 052b30b | 2009-04-26 20:01:22 +0200 | [diff] [blame] | 892 | timeo *= 2; |
Waldemar Rymarkiewicz | 5a9d0a3 | 2011-06-07 11:18:06 +0200 | [diff] [blame] | 893 | } else { |
Johan Hedberg | eb78d7e | 2014-08-18 00:41:41 +0300 | [diff] [blame] | 894 | timeo = 0; |
Waldemar Rymarkiewicz | 5a9d0a3 | 2011-06-07 11:18:06 +0200 | [diff] [blame] | 895 | } |
Andrei Emeltchenko | 716e4ab | 2012-10-10 17:38:31 +0300 | [diff] [blame] | 896 | break; |
| 897 | |
| 898 | case AMP_LINK: |
| 899 | timeo = conn->disc_timeout; |
| 900 | break; |
| 901 | |
| 902 | default: |
Johan Hedberg | eb78d7e | 2014-08-18 00:41:41 +0300 | [diff] [blame] | 903 | timeo = 0; |
Andrei Emeltchenko | 716e4ab | 2012-10-10 17:38:31 +0300 | [diff] [blame] | 904 | break; |
Waldemar Rymarkiewicz | 5a9d0a3 | 2011-06-07 11:18:06 +0200 | [diff] [blame] | 905 | } |
Andrei Emeltchenko | 716e4ab | 2012-10-10 17:38:31 +0300 | [diff] [blame] | 906 | |
Andre Guedes | 2f304d1 | 2012-01-27 19:42:02 -0300 | [diff] [blame] | 907 | cancel_delayed_work(&conn->disc_work); |
Gustavo F. Padovan | 19c40e3 | 2011-06-17 13:03:21 -0300 | [diff] [blame] | 908 | queue_delayed_work(conn->hdev->workqueue, |
Andrei Emeltchenko | 716e4ab | 2012-10-10 17:38:31 +0300 | [diff] [blame] | 909 | &conn->disc_work, timeo); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 910 | } |
| 911 | } |
| 912 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 913 | /* ----- HCI Devices ----- */ |
David Herrmann | dc946bd | 2012-01-07 15:47:24 +0100 | [diff] [blame] | 914 | static inline void hci_dev_put(struct hci_dev *d) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 915 | { |
Andrei Emeltchenko | 376261a | 2012-09-06 15:05:45 +0300 | [diff] [blame] | 916 | BT_DBG("%s orig refcnt %d", d->name, |
| 917 | atomic_read(&d->dev.kobj.kref.refcount)); |
| 918 | |
David Herrmann | 4c724c7 | 2012-01-07 15:47:23 +0100 | [diff] [blame] | 919 | put_device(&d->dev); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 920 | } |
| 921 | |
David Herrmann | dc946bd | 2012-01-07 15:47:24 +0100 | [diff] [blame] | 922 | static inline struct hci_dev *hci_dev_hold(struct hci_dev *d) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 923 | { |
Andrei Emeltchenko | 376261a | 2012-09-06 15:05:45 +0300 | [diff] [blame] | 924 | BT_DBG("%s orig refcnt %d", d->name, |
| 925 | atomic_read(&d->dev.kobj.kref.refcount)); |
| 926 | |
David Herrmann | 4c724c7 | 2012-01-07 15:47:23 +0100 | [diff] [blame] | 927 | get_device(&d->dev); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 928 | return d; |
| 929 | } |
| 930 | |
Gustavo F. Padovan | 09fd0de | 2011-06-17 13:03:21 -0300 | [diff] [blame] | 931 | #define hci_dev_lock(d) mutex_lock(&d->lock) |
| 932 | #define hci_dev_unlock(d) mutex_unlock(&d->lock) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 933 | |
David Herrmann | aa2b86d | 2012-02-09 21:58:30 +0100 | [diff] [blame] | 934 | #define to_hci_dev(d) container_of(d, struct hci_dev, dev) |
David Herrmann | 3dc0732 | 2012-02-09 21:58:33 +0100 | [diff] [blame] | 935 | #define to_hci_conn(c) container_of(c, struct hci_conn, dev) |
David Herrmann | aa2b86d | 2012-02-09 21:58:30 +0100 | [diff] [blame] | 936 | |
David Herrmann | 155961e | 2012-02-09 21:58:32 +0100 | [diff] [blame] | 937 | static inline void *hci_get_drvdata(struct hci_dev *hdev) |
| 938 | { |
| 939 | return dev_get_drvdata(&hdev->dev); |
| 940 | } |
| 941 | |
| 942 | static inline void hci_set_drvdata(struct hci_dev *hdev, void *data) |
| 943 | { |
| 944 | dev_set_drvdata(&hdev->dev, data); |
| 945 | } |
| 946 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 947 | struct hci_dev *hci_dev_get(int index); |
Johan Hedberg | 0c0afed | 2012-11-01 13:27:26 +0200 | [diff] [blame] | 948 | struct hci_dev *hci_get_route(bdaddr_t *dst, bdaddr_t *src); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 949 | |
| 950 | struct hci_dev *hci_alloc_dev(void); |
| 951 | void hci_free_dev(struct hci_dev *hdev); |
| 952 | int hci_register_dev(struct hci_dev *hdev); |
David Herrmann | 5973563 | 2011-10-26 10:43:19 +0200 | [diff] [blame] | 953 | void hci_unregister_dev(struct hci_dev *hdev); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 954 | int hci_suspend_dev(struct hci_dev *hdev); |
| 955 | int hci_resume_dev(struct hci_dev *hdev); |
Marcel Holtmann | 75e0569 | 2014-11-02 08:15:38 +0100 | [diff] [blame] | 956 | int hci_reset_dev(struct hci_dev *hdev); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 957 | int hci_dev_open(__u16 dev); |
| 958 | int hci_dev_close(__u16 dev); |
| 959 | int hci_dev_reset(__u16 dev); |
| 960 | int hci_dev_reset_stat(__u16 dev); |
| 961 | int hci_dev_cmd(unsigned int cmd, void __user *arg); |
| 962 | int hci_get_dev_list(void __user *arg); |
| 963 | int hci_get_dev_info(void __user *arg); |
| 964 | int hci_get_conn_list(void __user *arg); |
| 965 | int hci_get_conn_info(struct hci_dev *hdev, void __user *arg); |
Marcel Holtmann | 40be492 | 2008-07-14 20:13:50 +0200 | [diff] [blame] | 966 | int hci_get_auth_info(struct hci_dev *hdev, void __user *arg); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 967 | int hci_inquiry(void __user *arg); |
| 968 | |
Johan Hedberg | dcc36c1 | 2014-07-09 12:59:13 +0300 | [diff] [blame] | 969 | struct bdaddr_list *hci_bdaddr_list_lookup(struct list_head *list, |
| 970 | bdaddr_t *bdaddr, u8 type); |
| 971 | int hci_bdaddr_list_add(struct list_head *list, bdaddr_t *bdaddr, u8 type); |
| 972 | int hci_bdaddr_list_del(struct list_head *list, bdaddr_t *bdaddr, u8 type); |
| 973 | void hci_bdaddr_list_clear(struct list_head *list); |
Marcel Holtmann | d2ab0ac | 2014-02-27 20:37:30 -0800 | [diff] [blame] | 974 | |
Andre Guedes | 15819a7 | 2014-02-03 13:56:18 -0300 | [diff] [blame] | 975 | struct hci_conn_params *hci_conn_params_lookup(struct hci_dev *hdev, |
| 976 | bdaddr_t *addr, u8 addr_type); |
Marcel Holtmann | 51d167c | 2014-07-01 12:11:04 +0200 | [diff] [blame] | 977 | struct hci_conn_params *hci_conn_params_add(struct hci_dev *hdev, |
| 978 | bdaddr_t *addr, u8 addr_type); |
Andre Guedes | 15819a7 | 2014-02-03 13:56:18 -0300 | [diff] [blame] | 979 | void hci_conn_params_del(struct hci_dev *hdev, bdaddr_t *addr, u8 addr_type); |
Johan Hedberg | 373110c | 2014-07-02 17:37:25 +0300 | [diff] [blame] | 980 | void hci_conn_params_clear_all(struct hci_dev *hdev); |
Johan Hedberg | 55af49a | 2014-07-02 17:37:26 +0300 | [diff] [blame] | 981 | void hci_conn_params_clear_disabled(struct hci_dev *hdev); |
Andre Guedes | 15819a7 | 2014-02-03 13:56:18 -0300 | [diff] [blame] | 982 | |
Johan Hedberg | 501f882 | 2014-07-04 12:37:26 +0300 | [diff] [blame] | 983 | struct hci_conn_params *hci_pend_le_action_lookup(struct list_head *list, |
| 984 | bdaddr_t *addr, |
| 985 | u8 addr_type); |
Andre Guedes | 77a77a3 | 2014-02-26 20:21:46 -0300 | [diff] [blame] | 986 | |
Johan Hedberg | 35f7498 | 2014-02-18 17:14:32 +0200 | [diff] [blame] | 987 | void hci_uuids_clear(struct hci_dev *hdev); |
Johan Hedberg | 2aeb9a1 | 2011-01-04 12:08:51 +0200 | [diff] [blame] | 988 | |
Johan Hedberg | 35f7498 | 2014-02-18 17:14:32 +0200 | [diff] [blame] | 989 | void hci_link_keys_clear(struct hci_dev *hdev); |
Johan Hedberg | 55ed8ca1 | 2011-01-17 14:41:05 +0200 | [diff] [blame] | 990 | struct link_key *hci_find_link_key(struct hci_dev *hdev, bdaddr_t *bdaddr); |
Johan Hedberg | 567fa2a | 2014-06-24 13:15:48 +0300 | [diff] [blame] | 991 | struct link_key *hci_add_link_key(struct hci_dev *hdev, struct hci_conn *conn, |
Johan Hedberg | 7652ff6 | 2014-06-24 13:15:49 +0300 | [diff] [blame] | 992 | bdaddr_t *bdaddr, u8 *val, u8 type, |
| 993 | u8 pin_len, bool *persistent); |
Johan Hedberg | ca9142b | 2014-02-19 14:57:44 +0200 | [diff] [blame] | 994 | struct smp_ltk *hci_add_ltk(struct hci_dev *hdev, bdaddr_t *bdaddr, |
Johan Hedberg | 35d7027 | 2014-02-19 14:57:47 +0200 | [diff] [blame] | 995 | u8 addr_type, u8 type, u8 authenticated, |
Marcel Holtmann | fe39c7b | 2014-02-27 16:00:28 -0800 | [diff] [blame] | 996 | u8 tk[16], u8 enc_size, __le16 ediv, __le64 rand); |
Johan Hedberg | f3a73d9 | 2014-05-29 15:02:59 +0300 | [diff] [blame] | 997 | struct smp_ltk *hci_find_ltk(struct hci_dev *hdev, bdaddr_t *bdaddr, |
| 998 | u8 addr_type, u8 role); |
Johan Hedberg | e0b2b27 | 2014-02-18 17:14:31 +0200 | [diff] [blame] | 999 | int hci_remove_ltk(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 bdaddr_type); |
Johan Hedberg | 35f7498 | 2014-02-18 17:14:32 +0200 | [diff] [blame] | 1000 | void hci_smp_ltks_clear(struct hci_dev *hdev); |
Johan Hedberg | 55ed8ca1 | 2011-01-17 14:41:05 +0200 | [diff] [blame] | 1001 | int hci_remove_link_key(struct hci_dev *hdev, bdaddr_t *bdaddr); |
| 1002 | |
Johan Hedberg | 970c4e4 | 2014-02-18 10:19:33 +0200 | [diff] [blame] | 1003 | struct smp_irk *hci_find_irk_by_rpa(struct hci_dev *hdev, bdaddr_t *rpa); |
| 1004 | struct smp_irk *hci_find_irk_by_addr(struct hci_dev *hdev, bdaddr_t *bdaddr, |
| 1005 | u8 addr_type); |
Johan Hedberg | ca9142b | 2014-02-19 14:57:44 +0200 | [diff] [blame] | 1006 | struct smp_irk *hci_add_irk(struct hci_dev *hdev, bdaddr_t *bdaddr, |
| 1007 | u8 addr_type, u8 val[16], bdaddr_t *rpa); |
Johan Hedberg | a7ec733 | 2014-02-18 17:14:35 +0200 | [diff] [blame] | 1008 | void hci_remove_irk(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 addr_type); |
Johan Hedberg | 970c4e4 | 2014-02-18 10:19:33 +0200 | [diff] [blame] | 1009 | void hci_smp_irks_clear(struct hci_dev *hdev); |
| 1010 | |
Johan Hedberg | 55e76b3 | 2015-03-10 22:34:40 +0200 | [diff] [blame] | 1011 | bool hci_bdaddr_is_paired(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 type); |
| 1012 | |
Johan Hedberg | 35f7498 | 2014-02-18 17:14:32 +0200 | [diff] [blame] | 1013 | void hci_remote_oob_data_clear(struct hci_dev *hdev); |
Szymon Janc | 2763eda | 2011-03-22 13:12:22 +0100 | [diff] [blame] | 1014 | struct oob_data *hci_find_remote_oob_data(struct hci_dev *hdev, |
Johan Hedberg | 6928a92 | 2014-10-26 20:46:09 +0100 | [diff] [blame] | 1015 | bdaddr_t *bdaddr, u8 bdaddr_type); |
Marcel Holtmann | 0798872 | 2014-01-10 02:07:29 -0800 | [diff] [blame] | 1016 | int hci_add_remote_oob_data(struct hci_dev *hdev, bdaddr_t *bdaddr, |
Johan Hedberg | 6928a92 | 2014-10-26 20:46:09 +0100 | [diff] [blame] | 1017 | u8 bdaddr_type, u8 *hash192, u8 *rand192, |
Johan Hedberg | 81328d5 | 2014-10-26 20:33:47 +0100 | [diff] [blame] | 1018 | u8 *hash256, u8 *rand256); |
Johan Hedberg | 6928a92 | 2014-10-26 20:46:09 +0100 | [diff] [blame] | 1019 | int hci_remove_remote_oob_data(struct hci_dev *hdev, bdaddr_t *bdaddr, |
| 1020 | u8 bdaddr_type); |
Szymon Janc | 2763eda | 2011-03-22 13:12:22 +0100 | [diff] [blame] | 1021 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1022 | void hci_event_packet(struct hci_dev *hdev, struct sk_buff *skb); |
| 1023 | |
Marcel Holtmann | e1a2617 | 2013-10-10 16:52:43 -0700 | [diff] [blame] | 1024 | int hci_recv_frame(struct hci_dev *hdev, struct sk_buff *skb); |
Marcel Holtmann | ef22201 | 2007-07-11 06:42:04 +0200 | [diff] [blame] | 1025 | |
David Herrmann | 0ac7e70 | 2011-10-08 14:58:47 +0200 | [diff] [blame] | 1026 | void hci_init_sysfs(struct hci_dev *hdev); |
Marcel Holtmann | a67e899 | 2009-05-02 18:24:06 -0700 | [diff] [blame] | 1027 | void hci_conn_init_sysfs(struct hci_conn *conn); |
Marcel Holtmann | b219e3a | 2006-07-06 12:38:46 +0200 | [diff] [blame] | 1028 | void hci_conn_add_sysfs(struct hci_conn *conn); |
| 1029 | void hci_conn_del_sysfs(struct hci_conn *conn); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1030 | |
David Herrmann | 6935e0f | 2012-03-09 15:53:42 +0100 | [diff] [blame] | 1031 | #define SET_HCIDEV_DEV(hdev, pdev) ((hdev)->dev.parent = (pdev)) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1032 | |
| 1033 | /* ----- LMP capabilities ----- */ |
Johan Hedberg | cad718e | 2013-04-17 15:00:51 +0300 | [diff] [blame] | 1034 | #define lmp_encrypt_capable(dev) ((dev)->features[0][0] & LMP_ENCRYPT) |
| 1035 | #define lmp_rswitch_capable(dev) ((dev)->features[0][0] & LMP_RSWITCH) |
| 1036 | #define lmp_hold_capable(dev) ((dev)->features[0][0] & LMP_HOLD) |
| 1037 | #define lmp_sniff_capable(dev) ((dev)->features[0][0] & LMP_SNIFF) |
| 1038 | #define lmp_park_capable(dev) ((dev)->features[0][1] & LMP_PARK) |
| 1039 | #define lmp_inq_rssi_capable(dev) ((dev)->features[0][3] & LMP_RSSI_INQ) |
| 1040 | #define lmp_esco_capable(dev) ((dev)->features[0][3] & LMP_ESCO) |
| 1041 | #define lmp_bredr_capable(dev) (!((dev)->features[0][4] & LMP_NO_BREDR)) |
| 1042 | #define lmp_le_capable(dev) ((dev)->features[0][4] & LMP_LE) |
| 1043 | #define lmp_sniffsubr_capable(dev) ((dev)->features[0][5] & LMP_SNIFF_SUBR) |
| 1044 | #define lmp_pause_enc_capable(dev) ((dev)->features[0][5] & LMP_PAUSE_ENC) |
| 1045 | #define lmp_ext_inq_capable(dev) ((dev)->features[0][6] & LMP_EXT_INQ) |
| 1046 | #define lmp_le_br_capable(dev) (!!((dev)->features[0][6] & LMP_SIMUL_LE_BR)) |
| 1047 | #define lmp_ssp_capable(dev) ((dev)->features[0][6] & LMP_SIMPLE_PAIR) |
| 1048 | #define lmp_no_flush_capable(dev) ((dev)->features[0][6] & LMP_NO_FLUSH) |
| 1049 | #define lmp_lsto_capable(dev) ((dev)->features[0][7] & LMP_LSTO) |
| 1050 | #define lmp_inq_tx_pwr_capable(dev) ((dev)->features[0][7] & LMP_INQ_TX_PWR) |
| 1051 | #define lmp_ext_feat_capable(dev) ((dev)->features[0][7] & LMP_EXTFEATURES) |
Frédéric Dalleau | 07a5c61 | 2013-08-19 14:24:00 +0200 | [diff] [blame] | 1052 | #define lmp_transp_capable(dev) ((dev)->features[0][2] & LMP_TRANSPARENT) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1053 | |
Andre Guedes | eead27d | 2011-06-30 19:20:55 -0300 | [diff] [blame] | 1054 | /* ----- Extended LMP capabilities ----- */ |
Marcel Holtmann | 53b834d2 | 2013-12-08 11:55:33 -0800 | [diff] [blame] | 1055 | #define lmp_csb_master_capable(dev) ((dev)->features[2][0] & LMP_CSB_MASTER) |
| 1056 | #define lmp_csb_slave_capable(dev) ((dev)->features[2][0] & LMP_CSB_SLAVE) |
| 1057 | #define lmp_sync_train_capable(dev) ((dev)->features[2][0] & LMP_SYNC_TRAIN) |
| 1058 | #define lmp_sync_scan_capable(dev) ((dev)->features[2][0] & LMP_SYNC_SCAN) |
Marcel Holtmann | d599158 | 2014-01-10 02:07:16 -0800 | [diff] [blame] | 1059 | #define lmp_sc_capable(dev) ((dev)->features[2][1] & LMP_SC) |
| 1060 | #define lmp_ping_capable(dev) ((dev)->features[2][1] & LMP_PING) |
Marcel Holtmann | 53b834d2 | 2013-12-08 11:55:33 -0800 | [diff] [blame] | 1061 | |
| 1062 | /* ----- Host capabilities ----- */ |
Johan Hedberg | cad718e | 2013-04-17 15:00:51 +0300 | [diff] [blame] | 1063 | #define lmp_host_ssp_capable(dev) ((dev)->features[1][0] & LMP_HOST_SSP) |
Marcel Holtmann | d599158 | 2014-01-10 02:07:16 -0800 | [diff] [blame] | 1064 | #define lmp_host_sc_capable(dev) ((dev)->features[1][0] & LMP_HOST_SC) |
Johan Hedberg | cad718e | 2013-04-17 15:00:51 +0300 | [diff] [blame] | 1065 | #define lmp_host_le_capable(dev) (!!((dev)->features[1][0] & LMP_HOST_LE)) |
| 1066 | #define lmp_host_le_br_capable(dev) (!!((dev)->features[1][0] & LMP_HOST_LE_BREDR)) |
Andre Guedes | eead27d | 2011-06-30 19:20:55 -0300 | [diff] [blame] | 1067 | |
Marcel Holtmann | d7a5a11 | 2015-03-13 02:11:00 -0700 | [diff] [blame] | 1068 | #define hdev_is_powered(dev) (test_bit(HCI_UP, &(dev)->flags) && \ |
| 1069 | !hci_dev_test_flag(dev, HCI_AUTO_OFF)) |
| 1070 | #define bredr_sc_enabled(dev) (lmp_sc_capable(dev) && \ |
| 1071 | hci_dev_test_flag(dev, HCI_SC_ENABLED)) |
Johan Hedberg | 432df05 | 2014-08-01 11:13:31 +0300 | [diff] [blame] | 1072 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1073 | /* ----- HCI protocols ----- */ |
Frédéric Dalleau | 20714bf | 2012-11-21 10:51:12 +0100 | [diff] [blame] | 1074 | #define HCI_PROTO_DEFER 0x01 |
| 1075 | |
Waldemar Rymarkiewicz | 5a9d0a3 | 2011-06-07 11:18:06 +0200 | [diff] [blame] | 1076 | static inline int hci_proto_connect_ind(struct hci_dev *hdev, bdaddr_t *bdaddr, |
Frédéric Dalleau | 20714bf | 2012-11-21 10:51:12 +0100 | [diff] [blame] | 1077 | __u8 type, __u8 *flags) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1078 | { |
Ulisses Furquim | 686ebf2 | 2011-12-21 10:11:33 -0200 | [diff] [blame] | 1079 | switch (type) { |
| 1080 | case ACL_LINK: |
| 1081 | return l2cap_connect_ind(hdev, bdaddr); |
Marcel Holtmann | 8c1b235 | 2009-01-15 21:58:04 +0100 | [diff] [blame] | 1082 | |
Ulisses Furquim | 686ebf2 | 2011-12-21 10:11:33 -0200 | [diff] [blame] | 1083 | case SCO_LINK: |
| 1084 | case ESCO_LINK: |
Frédéric Dalleau | 20714bf | 2012-11-21 10:51:12 +0100 | [diff] [blame] | 1085 | return sco_connect_ind(hdev, bdaddr, flags); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1086 | |
Ulisses Furquim | 686ebf2 | 2011-12-21 10:11:33 -0200 | [diff] [blame] | 1087 | default: |
| 1088 | BT_ERR("unknown link type %d", type); |
| 1089 | return -EINVAL; |
| 1090 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1091 | } |
| 1092 | |
Marcel Holtmann | 2950f21 | 2009-02-12 14:02:50 +0100 | [diff] [blame] | 1093 | static inline int hci_proto_disconn_ind(struct hci_conn *conn) |
| 1094 | { |
Ulisses Furquim | 686ebf2 | 2011-12-21 10:11:33 -0200 | [diff] [blame] | 1095 | if (conn->type != ACL_LINK && conn->type != LE_LINK) |
| 1096 | return HCI_ERROR_REMOTE_USER_TERM; |
Marcel Holtmann | 2950f21 | 2009-02-12 14:02:50 +0100 | [diff] [blame] | 1097 | |
Ulisses Furquim | 686ebf2 | 2011-12-21 10:11:33 -0200 | [diff] [blame] | 1098 | return l2cap_disconn_ind(conn); |
Marcel Holtmann | 2950f21 | 2009-02-12 14:02:50 +0100 | [diff] [blame] | 1099 | } |
| 1100 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1101 | /* ----- HCI callbacks ----- */ |
| 1102 | struct hci_cb { |
| 1103 | struct list_head list; |
| 1104 | |
| 1105 | char *name; |
| 1106 | |
Johan Hedberg | 539c496 | 2015-02-18 14:53:57 +0200 | [diff] [blame] | 1107 | void (*connect_cfm) (struct hci_conn *conn, __u8 status); |
Johan Hedberg | 3a6d576 | 2015-02-18 14:53:58 +0200 | [diff] [blame] | 1108 | void (*disconn_cfm) (struct hci_conn *conn, __u8 status); |
Waldemar Rymarkiewicz | 5a9d0a3 | 2011-06-07 11:18:06 +0200 | [diff] [blame] | 1109 | void (*security_cfm) (struct hci_conn *conn, __u8 status, |
| 1110 | __u8 encrypt); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1111 | void (*key_change_cfm) (struct hci_conn *conn, __u8 status); |
| 1112 | void (*role_switch_cfm) (struct hci_conn *conn, __u8 status, __u8 role); |
| 1113 | }; |
| 1114 | |
Johan Hedberg | 539c496 | 2015-02-18 14:53:57 +0200 | [diff] [blame] | 1115 | static inline void hci_connect_cfm(struct hci_conn *conn, __u8 status) |
| 1116 | { |
| 1117 | struct hci_cb *cb; |
| 1118 | |
| 1119 | mutex_lock(&hci_cb_list_lock); |
| 1120 | list_for_each_entry(cb, &hci_cb_list, list) { |
| 1121 | if (cb->connect_cfm) |
| 1122 | cb->connect_cfm(conn, status); |
| 1123 | } |
| 1124 | mutex_unlock(&hci_cb_list_lock); |
| 1125 | |
| 1126 | if (conn->connect_cfm_cb) |
| 1127 | conn->connect_cfm_cb(conn, status); |
| 1128 | } |
| 1129 | |
Johan Hedberg | 3a6d576 | 2015-02-18 14:53:58 +0200 | [diff] [blame] | 1130 | static inline void hci_disconn_cfm(struct hci_conn *conn, __u8 reason) |
| 1131 | { |
| 1132 | struct hci_cb *cb; |
| 1133 | |
| 1134 | mutex_lock(&hci_cb_list_lock); |
| 1135 | list_for_each_entry(cb, &hci_cb_list, list) { |
| 1136 | if (cb->disconn_cfm) |
| 1137 | cb->disconn_cfm(conn, reason); |
| 1138 | } |
| 1139 | mutex_unlock(&hci_cb_list_lock); |
| 1140 | |
| 1141 | if (conn->disconn_cfm_cb) |
| 1142 | conn->disconn_cfm_cb(conn, reason); |
| 1143 | } |
| 1144 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1145 | static inline void hci_auth_cfm(struct hci_conn *conn, __u8 status) |
| 1146 | { |
Denis Kirjanov | 711584e | 2012-10-22 17:22:01 +0400 | [diff] [blame] | 1147 | struct hci_cb *cb; |
Marcel Holtmann | 8c1b235 | 2009-01-15 21:58:04 +0100 | [diff] [blame] | 1148 | __u8 encrypt; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1149 | |
Johan Hedberg | 51a8efd | 2012-01-16 06:10:31 +0200 | [diff] [blame] | 1150 | if (test_bit(HCI_CONN_ENCRYPT_PEND, &conn->flags)) |
Marcel Holtmann | 8c1b235 | 2009-01-15 21:58:04 +0100 | [diff] [blame] | 1151 | return; |
| 1152 | |
Johan Hedberg | 4dae279 | 2014-06-24 17:03:50 +0300 | [diff] [blame] | 1153 | encrypt = test_bit(HCI_CONN_ENCRYPT, &conn->flags) ? 0x01 : 0x00; |
Marcel Holtmann | 8c1b235 | 2009-01-15 21:58:04 +0100 | [diff] [blame] | 1154 | |
Johan Hedberg | fba7ecf | 2015-02-18 14:53:55 +0200 | [diff] [blame] | 1155 | mutex_lock(&hci_cb_list_lock); |
Denis Kirjanov | 711584e | 2012-10-22 17:22:01 +0400 | [diff] [blame] | 1156 | list_for_each_entry(cb, &hci_cb_list, list) { |
Marcel Holtmann | 8c1b235 | 2009-01-15 21:58:04 +0100 | [diff] [blame] | 1157 | if (cb->security_cfm) |
| 1158 | cb->security_cfm(conn, status, encrypt); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1159 | } |
Johan Hedberg | fba7ecf | 2015-02-18 14:53:55 +0200 | [diff] [blame] | 1160 | mutex_unlock(&hci_cb_list_lock); |
Johan Hedberg | 354fe80 | 2015-02-18 14:53:56 +0200 | [diff] [blame] | 1161 | |
| 1162 | if (conn->security_cfm_cb) |
| 1163 | conn->security_cfm_cb(conn, status); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1164 | } |
| 1165 | |
Waldemar Rymarkiewicz | 5a9d0a3 | 2011-06-07 11:18:06 +0200 | [diff] [blame] | 1166 | static inline void hci_encrypt_cfm(struct hci_conn *conn, __u8 status, |
| 1167 | __u8 encrypt) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1168 | { |
Denis Kirjanov | 711584e | 2012-10-22 17:22:01 +0400 | [diff] [blame] | 1169 | struct hci_cb *cb; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1170 | |
Marcel Holtmann | 435fef2 | 2009-02-09 03:55:28 +0100 | [diff] [blame] | 1171 | if (conn->sec_level == BT_SECURITY_SDP) |
| 1172 | conn->sec_level = BT_SECURITY_LOW; |
| 1173 | |
Vinicius Costa Gomes | 88167ae | 2011-06-09 18:50:51 -0300 | [diff] [blame] | 1174 | if (conn->pending_sec_level > conn->sec_level) |
| 1175 | conn->sec_level = conn->pending_sec_level; |
| 1176 | |
Johan Hedberg | fba7ecf | 2015-02-18 14:53:55 +0200 | [diff] [blame] | 1177 | mutex_lock(&hci_cb_list_lock); |
Denis Kirjanov | 711584e | 2012-10-22 17:22:01 +0400 | [diff] [blame] | 1178 | list_for_each_entry(cb, &hci_cb_list, list) { |
Marcel Holtmann | 8c1b235 | 2009-01-15 21:58:04 +0100 | [diff] [blame] | 1179 | if (cb->security_cfm) |
| 1180 | cb->security_cfm(conn, status, encrypt); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1181 | } |
Johan Hedberg | fba7ecf | 2015-02-18 14:53:55 +0200 | [diff] [blame] | 1182 | mutex_unlock(&hci_cb_list_lock); |
Johan Hedberg | 354fe80 | 2015-02-18 14:53:56 +0200 | [diff] [blame] | 1183 | |
| 1184 | if (conn->security_cfm_cb) |
| 1185 | conn->security_cfm_cb(conn, status); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1186 | } |
| 1187 | |
| 1188 | static inline void hci_key_change_cfm(struct hci_conn *conn, __u8 status) |
| 1189 | { |
Denis Kirjanov | 711584e | 2012-10-22 17:22:01 +0400 | [diff] [blame] | 1190 | struct hci_cb *cb; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1191 | |
Johan Hedberg | fba7ecf | 2015-02-18 14:53:55 +0200 | [diff] [blame] | 1192 | mutex_lock(&hci_cb_list_lock); |
Denis Kirjanov | 711584e | 2012-10-22 17:22:01 +0400 | [diff] [blame] | 1193 | list_for_each_entry(cb, &hci_cb_list, list) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1194 | if (cb->key_change_cfm) |
| 1195 | cb->key_change_cfm(conn, status); |
| 1196 | } |
Johan Hedberg | fba7ecf | 2015-02-18 14:53:55 +0200 | [diff] [blame] | 1197 | mutex_unlock(&hci_cb_list_lock); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1198 | } |
| 1199 | |
Waldemar Rymarkiewicz | 5a9d0a3 | 2011-06-07 11:18:06 +0200 | [diff] [blame] | 1200 | static inline void hci_role_switch_cfm(struct hci_conn *conn, __u8 status, |
| 1201 | __u8 role) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1202 | { |
Denis Kirjanov | 711584e | 2012-10-22 17:22:01 +0400 | [diff] [blame] | 1203 | struct hci_cb *cb; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1204 | |
Johan Hedberg | fba7ecf | 2015-02-18 14:53:55 +0200 | [diff] [blame] | 1205 | mutex_lock(&hci_cb_list_lock); |
Denis Kirjanov | 711584e | 2012-10-22 17:22:01 +0400 | [diff] [blame] | 1206 | list_for_each_entry(cb, &hci_cb_list, list) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1207 | if (cb->role_switch_cfm) |
| 1208 | cb->role_switch_cfm(conn, status, role); |
| 1209 | } |
Johan Hedberg | fba7ecf | 2015-02-18 14:53:55 +0200 | [diff] [blame] | 1210 | mutex_unlock(&hci_cb_list_lock); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1211 | } |
| 1212 | |
Johan Hedberg | 6759a67 | 2012-01-15 20:51:14 +0200 | [diff] [blame] | 1213 | static inline bool eir_has_data_type(u8 *data, size_t data_len, u8 type) |
| 1214 | { |
Johan Hedberg | 84d9d07 | 2012-03-26 14:21:41 +0300 | [diff] [blame] | 1215 | size_t parsed = 0; |
Johan Hedberg | 6759a67 | 2012-01-15 20:51:14 +0200 | [diff] [blame] | 1216 | |
Johan Hedberg | 6c0c331 | 2012-03-26 14:21:42 +0300 | [diff] [blame] | 1217 | if (data_len < 2) |
| 1218 | return false; |
| 1219 | |
Johan Hedberg | 84d9d07 | 2012-03-26 14:21:41 +0300 | [diff] [blame] | 1220 | while (parsed < data_len - 1) { |
| 1221 | u8 field_len = data[0]; |
Johan Hedberg | 6759a67 | 2012-01-15 20:51:14 +0200 | [diff] [blame] | 1222 | |
| 1223 | if (field_len == 0) |
| 1224 | break; |
| 1225 | |
| 1226 | parsed += field_len + 1; |
| 1227 | |
| 1228 | if (parsed > data_len) |
| 1229 | break; |
| 1230 | |
| 1231 | if (data[1] == type) |
| 1232 | return true; |
| 1233 | |
| 1234 | data += field_len + 1; |
| 1235 | } |
| 1236 | |
| 1237 | return false; |
| 1238 | } |
| 1239 | |
Johan Hedberg | 301cb2d | 2014-02-18 10:19:34 +0200 | [diff] [blame] | 1240 | static inline bool hci_bdaddr_is_rpa(bdaddr_t *bdaddr, u8 addr_type) |
| 1241 | { |
Andre Guedes | dbbfa2a | 2014-06-25 16:44:45 -0300 | [diff] [blame] | 1242 | if (addr_type != ADDR_LE_DEV_RANDOM) |
Johan Hedberg | 301cb2d | 2014-02-18 10:19:34 +0200 | [diff] [blame] | 1243 | return false; |
| 1244 | |
| 1245 | if ((bdaddr->b[5] & 0xc0) == 0x40) |
| 1246 | return true; |
| 1247 | |
| 1248 | return false; |
| 1249 | } |
| 1250 | |
Johan Hedberg | c46245b | 2014-07-02 17:37:33 +0300 | [diff] [blame] | 1251 | static inline bool hci_is_identity_address(bdaddr_t *addr, u8 addr_type) |
| 1252 | { |
| 1253 | if (addr_type == ADDR_LE_DEV_PUBLIC) |
| 1254 | return true; |
| 1255 | |
| 1256 | /* Check for Random Static address type */ |
| 1257 | if ((addr->b[5] & 0xc0) == 0xc0) |
| 1258 | return true; |
| 1259 | |
| 1260 | return false; |
| 1261 | } |
| 1262 | |
Johan Hedberg | 2426f3a | 2014-02-18 17:14:36 +0200 | [diff] [blame] | 1263 | static inline struct smp_irk *hci_get_irk(struct hci_dev *hdev, |
| 1264 | bdaddr_t *bdaddr, u8 addr_type) |
| 1265 | { |
| 1266 | if (!hci_bdaddr_is_rpa(bdaddr, addr_type)) |
| 1267 | return NULL; |
| 1268 | |
| 1269 | return hci_find_irk_by_rpa(hdev, bdaddr); |
| 1270 | } |
| 1271 | |
Andre Guedes | d4905f2 | 2014-06-25 21:52:52 -0300 | [diff] [blame] | 1272 | static inline int hci_check_conn_params(u16 min, u16 max, u16 latency, |
| 1273 | u16 to_multiplier) |
| 1274 | { |
| 1275 | u16 max_latency; |
| 1276 | |
| 1277 | if (min > max || min < 6 || max > 3200) |
| 1278 | return -EINVAL; |
| 1279 | |
| 1280 | if (to_multiplier < 10 || to_multiplier > 3200) |
| 1281 | return -EINVAL; |
| 1282 | |
| 1283 | if (max >= to_multiplier * 8) |
| 1284 | return -EINVAL; |
| 1285 | |
| 1286 | max_latency = (to_multiplier * 8 / max) - 1; |
| 1287 | if (latency > 499 || latency > max_latency) |
| 1288 | return -EINVAL; |
| 1289 | |
| 1290 | return 0; |
| 1291 | } |
| 1292 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1293 | int hci_register_cb(struct hci_cb *hcb); |
| 1294 | int hci_unregister_cb(struct hci_cb *hcb); |
| 1295 | |
Johan Hedberg | 75e84b7 | 2013-04-02 13:35:04 +0300 | [diff] [blame] | 1296 | struct sk_buff *__hci_cmd_sync(struct hci_dev *hdev, u16 opcode, u32 plen, |
Johan Hedberg | 07dc93d | 2013-04-19 10:14:51 +0300 | [diff] [blame] | 1297 | const void *param, u32 timeout); |
Johan Hedberg | 7b1abbb | 2013-04-03 21:54:47 +0300 | [diff] [blame] | 1298 | struct sk_buff *__hci_cmd_sync_ev(struct hci_dev *hdev, u16 opcode, u32 plen, |
Johan Hedberg | 07dc93d | 2013-04-19 10:14:51 +0300 | [diff] [blame] | 1299 | const void *param, u8 event, u32 timeout); |
Johan Hedberg | 75e84b7 | 2013-04-02 13:35:04 +0300 | [diff] [blame] | 1300 | |
Johan Hedberg | 07dc93d | 2013-04-19 10:14:51 +0300 | [diff] [blame] | 1301 | int hci_send_cmd(struct hci_dev *hdev, __u16 opcode, __u32 plen, |
| 1302 | const void *param); |
Luiz Augusto von Dentz | 73d80de | 2011-11-02 15:52:01 +0200 | [diff] [blame] | 1303 | void hci_send_acl(struct hci_chan *chan, struct sk_buff *skb, __u16 flags); |
Gustavo F. Padovan | 0d861d8 | 2010-05-01 16:15:35 -0300 | [diff] [blame] | 1304 | void hci_send_sco(struct hci_conn *conn, struct sk_buff *skb); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1305 | |
Marcel Holtmann | a9de924 | 2007-10-20 13:33:56 +0200 | [diff] [blame] | 1306 | void *hci_sent_cmd_data(struct hci_dev *hdev, __u16 opcode); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1307 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1308 | /* ----- HCI Sockets ----- */ |
Marcel Holtmann | 470fe1b | 2012-02-20 14:50:30 +0100 | [diff] [blame] | 1309 | void hci_send_to_sock(struct hci_dev *hdev, struct sk_buff *skb); |
Johan Hedberg | 7129069 | 2015-02-20 13:26:23 +0200 | [diff] [blame] | 1310 | void hci_send_to_channel(unsigned short channel, struct sk_buff *skb, |
Marcel Holtmann | c08b1a1 | 2015-03-14 19:27:59 -0700 | [diff] [blame] | 1311 | int flag, struct sock *skip_sk); |
Marcel Holtmann | cd82e61 | 2012-02-20 20:34:38 +0100 | [diff] [blame] | 1312 | void hci_send_to_monitor(struct hci_dev *hdev, struct sk_buff *skb); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1313 | |
Marcel Holtmann | 040030e | 2012-02-20 14:50:37 +0100 | [diff] [blame] | 1314 | void hci_sock_dev_event(struct hci_dev *hdev, int event); |
| 1315 | |
Marcel Holtmann | a958452 | 2015-03-14 19:28:06 -0700 | [diff] [blame] | 1316 | #define HCI_MGMT_VAR_LEN BIT(0) |
| 1317 | #define HCI_MGMT_NO_HDEV BIT(1) |
| 1318 | #define HCI_MGMT_UNTRUSTED BIT(2) |
| 1319 | #define HCI_MGMT_UNCONFIGURED BIT(3) |
Johan Hedberg | b9a245fb | 2015-03-06 21:08:52 +0200 | [diff] [blame] | 1320 | |
Johan Hedberg | 801c1e8 | 2015-03-06 21:08:50 +0200 | [diff] [blame] | 1321 | struct hci_mgmt_handler { |
| 1322 | int (*func) (struct sock *sk, struct hci_dev *hdev, void *data, |
| 1323 | u16 data_len); |
Johan Hedberg | 801c1e8 | 2015-03-06 21:08:50 +0200 | [diff] [blame] | 1324 | size_t data_len; |
Johan Hedberg | b9a245fb | 2015-03-06 21:08:52 +0200 | [diff] [blame] | 1325 | unsigned long flags; |
Johan Hedberg | 801c1e8 | 2015-03-06 21:08:50 +0200 | [diff] [blame] | 1326 | }; |
| 1327 | |
| 1328 | struct hci_mgmt_chan { |
| 1329 | struct list_head list; |
| 1330 | unsigned short channel; |
| 1331 | size_t handler_count; |
| 1332 | const struct hci_mgmt_handler *handlers; |
Johan Hedberg | 88b94ce | 2015-03-17 13:48:49 +0200 | [diff] [blame] | 1333 | void (*hdev_init) (struct sock *sk, struct hci_dev *hdev); |
Johan Hedberg | 801c1e8 | 2015-03-06 21:08:50 +0200 | [diff] [blame] | 1334 | }; |
| 1335 | |
| 1336 | int hci_mgmt_chan_register(struct hci_mgmt_chan *c); |
| 1337 | void hci_mgmt_chan_unregister(struct hci_mgmt_chan *c); |
| 1338 | |
Johan Hedberg | 0381101 | 2010-12-08 00:21:06 +0200 | [diff] [blame] | 1339 | /* Management interface */ |
Andre Guedes | 591f47f | 2012-04-24 21:02:49 -0300 | [diff] [blame] | 1340 | #define DISCOV_TYPE_BREDR (BIT(BDADDR_BREDR)) |
| 1341 | #define DISCOV_TYPE_LE (BIT(BDADDR_LE_PUBLIC) | \ |
| 1342 | BIT(BDADDR_LE_RANDOM)) |
| 1343 | #define DISCOV_TYPE_INTERLEAVED (BIT(BDADDR_BREDR) | \ |
| 1344 | BIT(BDADDR_LE_PUBLIC) | \ |
| 1345 | BIT(BDADDR_LE_RANDOM)) |
Andre Guedes | f39799f | 2012-02-17 20:39:35 -0300 | [diff] [blame] | 1346 | |
Andre Guedes | 0d8cc93 | 2013-04-30 15:29:31 -0300 | [diff] [blame] | 1347 | /* These LE scan and inquiry parameters were chosen according to LE General |
| 1348 | * Discovery Procedure specification. |
| 1349 | */ |
| 1350 | #define DISCOV_LE_SCAN_WIN 0x12 |
| 1351 | #define DISCOV_LE_SCAN_INT 0x12 |
Lukasz Rymanowski | 3d5a76f | 2014-03-27 20:55:21 +0100 | [diff] [blame] | 1352 | #define DISCOV_LE_TIMEOUT 10240 /* msec */ |
Lukasz Rymanowski | ae55f59 | 2014-03-27 20:55:19 +0100 | [diff] [blame] | 1353 | #define DISCOV_INTERLEAVED_TIMEOUT 5120 /* msec */ |
Andre Guedes | 0d8cc93 | 2013-04-30 15:29:31 -0300 | [diff] [blame] | 1354 | #define DISCOV_INTERLEAVED_INQUIRY_LEN 0x04 |
| 1355 | #define DISCOV_BREDR_INQUIRY_LEN 0x08 |
Jakub Pawlowski | 4b0e0ce | 2015-02-01 23:07:55 -0800 | [diff] [blame] | 1356 | #define DISCOV_LE_RESTART_DELAY msecs_to_jiffies(200) /* msec */ |
Andre Guedes | 0d8cc93 | 2013-04-30 15:29:31 -0300 | [diff] [blame] | 1357 | |
Johan Hedberg | 91a668b | 2014-07-09 13:28:26 +0300 | [diff] [blame] | 1358 | int mgmt_new_settings(struct hci_dev *hdev); |
Marcel Holtmann | bf6b56d | 2013-10-06 23:55:45 -0700 | [diff] [blame] | 1359 | void mgmt_index_added(struct hci_dev *hdev); |
| 1360 | void mgmt_index_removed(struct hci_dev *hdev); |
Marcel Holtmann | 3eec705 | 2013-10-06 23:55:46 -0700 | [diff] [blame] | 1361 | void mgmt_set_powered_failed(struct hci_dev *hdev, int err); |
Johan Hedberg | 744cf19 | 2011-11-08 20:40:14 +0200 | [diff] [blame] | 1362 | int mgmt_powered(struct hci_dev *hdev, u8 powered); |
Johan Hedberg | bc6d2d0 | 2014-07-10 12:09:08 +0300 | [diff] [blame] | 1363 | int mgmt_update_adv_data(struct hci_dev *hdev); |
Marcel Holtmann | d1967ff | 2013-10-15 10:57:40 -0700 | [diff] [blame] | 1364 | void mgmt_discoverable_timeout(struct hci_dev *hdev); |
Marcel Holtmann | dc4a5ee | 2013-10-15 10:15:57 -0700 | [diff] [blame] | 1365 | void mgmt_new_link_key(struct hci_dev *hdev, struct link_key *key, |
| 1366 | bool persistent); |
Alfonso Acosta | 48ec92f | 2014-10-07 08:44:10 +0000 | [diff] [blame] | 1367 | void mgmt_device_connected(struct hci_dev *hdev, struct hci_conn *conn, |
| 1368 | u32 flags, u8 *name, u8 name_len); |
Marcel Holtmann | 9b80ec5 | 2013-10-06 23:55:50 -0700 | [diff] [blame] | 1369 | void mgmt_device_disconnected(struct hci_dev *hdev, bdaddr_t *bdaddr, |
Johan Hedberg | 12d4a3b | 2014-02-24 14:52:18 +0200 | [diff] [blame] | 1370 | u8 link_type, u8 addr_type, u8 reason, |
| 1371 | bool mgmt_connected); |
Marcel Holtmann | 7892924 | 2013-10-06 23:55:47 -0700 | [diff] [blame] | 1372 | void mgmt_disconnect_failed(struct hci_dev *hdev, bdaddr_t *bdaddr, |
| 1373 | u8 link_type, u8 addr_type, u8 status); |
Marcel Holtmann | 445608d | 2013-10-06 23:55:48 -0700 | [diff] [blame] | 1374 | void mgmt_connect_failed(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 link_type, |
| 1375 | u8 addr_type, u8 status); |
Marcel Holtmann | ce0e4a0 | 2013-10-15 14:26:20 -0700 | [diff] [blame] | 1376 | void mgmt_pin_code_request(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 secure); |
Marcel Holtmann | e669cf8 | 2013-10-15 14:26:21 -0700 | [diff] [blame] | 1377 | void mgmt_pin_code_reply_complete(struct hci_dev *hdev, bdaddr_t *bdaddr, |
| 1378 | u8 status); |
Marcel Holtmann | 3eb3852 | 2013-10-15 14:26:22 -0700 | [diff] [blame] | 1379 | void mgmt_pin_code_neg_reply_complete(struct hci_dev *hdev, bdaddr_t *bdaddr, |
| 1380 | u8 status); |
Johan Hedberg | 744cf19 | 2011-11-08 20:40:14 +0200 | [diff] [blame] | 1381 | int mgmt_user_confirm_request(struct hci_dev *hdev, bdaddr_t *bdaddr, |
Johan Hedberg | 39adbff | 2014-03-20 08:18:14 +0200 | [diff] [blame] | 1382 | u8 link_type, u8 addr_type, u32 value, |
Gustavo F. Padovan | 0412468 | 2012-03-08 01:25:00 -0300 | [diff] [blame] | 1383 | u8 confirm_hint); |
Johan Hedberg | 744cf19 | 2011-11-08 20:40:14 +0200 | [diff] [blame] | 1384 | int mgmt_user_confirm_reply_complete(struct hci_dev *hdev, bdaddr_t *bdaddr, |
Gustavo F. Padovan | 0412468 | 2012-03-08 01:25:00 -0300 | [diff] [blame] | 1385 | u8 link_type, u8 addr_type, u8 status); |
Johan Hedberg | 272d90d | 2012-02-09 15:26:12 +0200 | [diff] [blame] | 1386 | int mgmt_user_confirm_neg_reply_complete(struct hci_dev *hdev, bdaddr_t *bdaddr, |
Gustavo F. Padovan | 0412468 | 2012-03-08 01:25:00 -0300 | [diff] [blame] | 1387 | u8 link_type, u8 addr_type, u8 status); |
Johan Hedberg | 272d90d | 2012-02-09 15:26:12 +0200 | [diff] [blame] | 1388 | int mgmt_user_passkey_request(struct hci_dev *hdev, bdaddr_t *bdaddr, |
Gustavo F. Padovan | 0412468 | 2012-03-08 01:25:00 -0300 | [diff] [blame] | 1389 | u8 link_type, u8 addr_type); |
Brian Gix | 604086b | 2011-11-23 08:28:33 -0800 | [diff] [blame] | 1390 | int mgmt_user_passkey_reply_complete(struct hci_dev *hdev, bdaddr_t *bdaddr, |
Gustavo F. Padovan | 0412468 | 2012-03-08 01:25:00 -0300 | [diff] [blame] | 1391 | u8 link_type, u8 addr_type, u8 status); |
Johan Hedberg | 272d90d | 2012-02-09 15:26:12 +0200 | [diff] [blame] | 1392 | int mgmt_user_passkey_neg_reply_complete(struct hci_dev *hdev, bdaddr_t *bdaddr, |
Gustavo F. Padovan | 0412468 | 2012-03-08 01:25:00 -0300 | [diff] [blame] | 1393 | u8 link_type, u8 addr_type, u8 status); |
Johan Hedberg | 92a2525 | 2012-09-06 18:39:26 +0300 | [diff] [blame] | 1394 | int mgmt_user_passkey_notify(struct hci_dev *hdev, bdaddr_t *bdaddr, |
| 1395 | u8 link_type, u8 addr_type, u32 passkey, |
| 1396 | u8 entered); |
Johan Hedberg | e1e930f | 2014-09-08 17:09:49 -0700 | [diff] [blame] | 1397 | void mgmt_auth_failed(struct hci_conn *conn, u8 status); |
Marcel Holtmann | 464996a | 2013-10-15 14:26:24 -0700 | [diff] [blame] | 1398 | void mgmt_auth_enable_complete(struct hci_dev *hdev, u8 status); |
Marcel Holtmann | 3e24856 | 2013-10-15 14:26:25 -0700 | [diff] [blame] | 1399 | void mgmt_ssp_enable_complete(struct hci_dev *hdev, u8 enable, u8 status); |
Marcel Holtmann | 4e1b024 | 2013-10-15 14:26:26 -0700 | [diff] [blame] | 1400 | void mgmt_set_class_of_dev_complete(struct hci_dev *hdev, u8 *dev_class, |
| 1401 | u8 status); |
Marcel Holtmann | 7667da3 | 2013-10-15 14:26:27 -0700 | [diff] [blame] | 1402 | void mgmt_set_local_name_complete(struct hci_dev *hdev, u8 *name, u8 status); |
Marcel Holtmann | 901801b | 2013-10-06 23:55:51 -0700 | [diff] [blame] | 1403 | void mgmt_device_found(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 link_type, |
Marcel Holtmann | af58925 | 2014-07-01 14:11:20 +0200 | [diff] [blame] | 1404 | u8 addr_type, u8 *dev_class, s8 rssi, u32 flags, |
| 1405 | u8 *eir, u16 eir_len, u8 *scan_rsp, u8 scan_rsp_len); |
Marcel Holtmann | 9cf12ae | 2013-10-06 23:55:52 -0700 | [diff] [blame] | 1406 | void mgmt_remote_name(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 link_type, |
| 1407 | u8 addr_type, s8 rssi, u8 *name, u8 name_len); |
Marcel Holtmann | 2f1e063 | 2013-10-06 23:55:53 -0700 | [diff] [blame] | 1408 | void mgmt_discovering(struct hci_dev *hdev, u8 discovering); |
Johan Hedberg | 84c61d9 | 2014-08-01 11:13:30 +0300 | [diff] [blame] | 1409 | bool mgmt_powering_down(struct hci_dev *hdev); |
Marcel Holtmann | 53ac6ab | 2014-03-09 23:38:42 -0700 | [diff] [blame] | 1410 | void mgmt_new_ltk(struct hci_dev *hdev, struct smp_ltk *key, bool persistent); |
Johan Hedberg | 95fbac8 | 2014-02-19 15:18:31 +0200 | [diff] [blame] | 1411 | void mgmt_new_irk(struct hci_dev *hdev, struct smp_irk *irk); |
Marcel Holtmann | 53ac6ab | 2014-03-09 23:38:42 -0700 | [diff] [blame] | 1412 | void mgmt_new_csrk(struct hci_dev *hdev, struct smp_csrk *csrk, |
| 1413 | bool persistent); |
Andre Guedes | ffb5a827 | 2014-07-01 18:10:11 -0300 | [diff] [blame] | 1414 | void mgmt_new_conn_param(struct hci_dev *hdev, bdaddr_t *bdaddr, |
Johan Hedberg | f4869e2 | 2014-07-02 17:37:32 +0300 | [diff] [blame] | 1415 | u8 bdaddr_type, u8 store_hint, u16 min_interval, |
| 1416 | u16 max_interval, u16 latency, u16 timeout); |
Marcel Holtmann | 5976e60 | 2013-10-06 04:08:14 -0700 | [diff] [blame] | 1417 | void mgmt_reenable_advertising(struct hci_dev *hdev); |
Johan Hedberg | f4a407b | 2014-02-18 21:41:34 +0200 | [diff] [blame] | 1418 | void mgmt_smp_complete(struct hci_conn *conn, bool complete); |
Vinicius Costa Gomes | 346af67 | 2012-02-02 21:08:02 -0300 | [diff] [blame] | 1419 | |
Johan Hedberg | 7d6ca69 | 2014-07-02 17:37:31 +0300 | [diff] [blame] | 1420 | u8 hci_le_conn_update(struct hci_conn *conn, u16 min, u16 max, u16 latency, |
| 1421 | u16 to_multiplier); |
Marcel Holtmann | fe39c7b | 2014-02-27 16:00:28 -0800 | [diff] [blame] | 1422 | void hci_le_start_enc(struct hci_conn *conn, __le16 ediv, __le64 rand, |
Johan Hedberg | 8b76ce3 | 2015-06-08 18:14:39 +0300 | [diff] [blame] | 1423 | __u8 ltk[16], __u8 key_size); |
Andre Guedes | 2519a1f | 2011-11-07 11:45:24 -0300 | [diff] [blame] | 1424 | |
Johan Hedberg | a1f4c31 | 2014-02-27 14:05:41 +0200 | [diff] [blame] | 1425 | void hci_copy_identity_address(struct hci_dev *hdev, bdaddr_t *bdaddr, |
| 1426 | u8 *bdaddr_type); |
Johan Hedberg | ebd3a74 | 2014-02-23 19:42:21 +0200 | [diff] [blame] | 1427 | |
Frédéric Dalleau | 5d4d62f | 2013-08-19 14:23:57 +0200 | [diff] [blame] | 1428 | #define SCO_AIRMODE_MASK 0x0003 |
| 1429 | #define SCO_AIRMODE_CVSD 0x0000 |
| 1430 | #define SCO_AIRMODE_TRANSP 0x0003 |
| 1431 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1432 | #endif /* __HCI_CORE_H */ |