aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarcel Holtmann <marcel@holtmann.org>2013-10-19 10:09:11 -0400
committerJohan Hedberg <johan.hedberg@intel.com>2013-10-19 11:56:52 -0400
commit06f5b7785af6beebb7b2a452687b5a102c90ca6e (patch)
tree33945c97ce1f48736cb71925bb60993e2a54f70c
parent3497ac84bd35bc5b984a3a20625021bfb0ca3f37 (diff)
Bluetooth: Add support for setting SSP debug mode
Enabling and disabling SSP debug mode is useful for development. This adds a debugfs entry that allows to configure the SSP debug mode. On purpose this has been implemented as debugfs entry and not a public API since it is really only useful during testing and development. Signed-off-by: Marcel Holtmann <marcel@holtmann.org> Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
-rw-r--r--include/net/bluetooth/hci.h2
-rw-r--r--include/net/bluetooth/hci_core.h1
-rw-r--r--net/bluetooth/hci_core.c54
-rw-r--r--net/bluetooth/hci_event.c2
4 files changed, 58 insertions, 1 deletions
diff --git a/include/net/bluetooth/hci.h b/include/net/bluetooth/hci.h
index 77a971aefcff..ac9c4a75e314 100644
--- a/include/net/bluetooth/hci.h
+++ b/include/net/bluetooth/hci.h
@@ -1043,6 +1043,8 @@ struct hci_rp_write_remote_amp_assoc {
1043 __u8 phy_handle; 1043 __u8 phy_handle;
1044} __packed; 1044} __packed;
1045 1045
1046#define HCI_OP_WRITE_SSP_DEBUG_MODE 0x1804
1047
1046#define HCI_OP_LE_SET_EVENT_MASK 0x2001 1048#define HCI_OP_LE_SET_EVENT_MASK 0x2001
1047struct hci_cp_le_set_event_mask { 1049struct hci_cp_le_set_event_mask {
1048 __u8 mask[8]; 1050 __u8 mask[8];
diff --git a/include/net/bluetooth/hci_core.h b/include/net/bluetooth/hci_core.h
index c689bcf4a0f7..d50cc7aca4e4 100644
--- a/include/net/bluetooth/hci_core.h
+++ b/include/net/bluetooth/hci_core.h
@@ -169,6 +169,7 @@ struct hci_dev {
169 __u8 page_scan_type; 169 __u8 page_scan_type;
170 __u16 le_scan_interval; 170 __u16 le_scan_interval;
171 __u16 le_scan_window; 171 __u16 le_scan_window;
172 __u8 ssp_debug_mode;
172 173
173 __u16 devid_source; 174 __u16 devid_source;
174 __u16 devid_vendor; 175 __u16 devid_vendor;
diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c
index 384b9db16f69..2a9e92503fd6 100644
--- a/net/bluetooth/hci_core.c
+++ b/net/bluetooth/hci_core.c
@@ -303,6 +303,55 @@ static int auto_accept_delay_get(void *data, u64 *val)
303DEFINE_SIMPLE_ATTRIBUTE(auto_accept_delay_fops, auto_accept_delay_get, 303DEFINE_SIMPLE_ATTRIBUTE(auto_accept_delay_fops, auto_accept_delay_get,
304 auto_accept_delay_set, "%llu\n"); 304 auto_accept_delay_set, "%llu\n");
305 305
306static int ssp_debug_mode_set(void *data, u64 val)
307{
308 struct hci_dev *hdev = data;
309 struct sk_buff *skb;
310 __u8 mode;
311 int err;
312
313 if (val != 0 && val != 1)
314 return -EINVAL;
315
316 if (!test_bit(HCI_UP, &hdev->flags))
317 return -ENETDOWN;
318
319 hci_req_lock(hdev);
320 mode = val;
321 skb = __hci_cmd_sync(hdev, HCI_OP_WRITE_SSP_DEBUG_MODE, sizeof(mode),
322 &mode, HCI_CMD_TIMEOUT);
323 hci_req_unlock(hdev);
324
325 if (IS_ERR(skb))
326 return PTR_ERR(skb);
327
328 err = -bt_to_errno(skb->data[0]);
329 kfree_skb(skb);
330
331 if (err < 0)
332 return err;
333
334 hci_dev_lock(hdev);
335 hdev->ssp_debug_mode = val;
336 hci_dev_unlock(hdev);
337
338 return 0;
339}
340
341static int ssp_debug_mode_get(void *data, u64 *val)
342{
343 struct hci_dev *hdev = data;
344
345 hci_dev_lock(hdev);
346 *val = hdev->ssp_debug_mode;
347 hci_dev_unlock(hdev);
348
349 return 0;
350}
351
352DEFINE_SIMPLE_ATTRIBUTE(ssp_debug_mode_fops, ssp_debug_mode_get,
353 ssp_debug_mode_set, "%llu\n");
354
306static int idle_timeout_set(void *data, u64 val) 355static int idle_timeout_set(void *data, u64 val)
307{ 356{
308 struct hci_dev *hdev = data; 357 struct hci_dev *hdev = data;
@@ -1199,9 +1248,12 @@ static int __hci_init(struct hci_dev *hdev)
1199 hdev, &voice_setting_fops); 1248 hdev, &voice_setting_fops);
1200 } 1249 }
1201 1250
1202 if (lmp_ssp_capable(hdev)) 1251 if (lmp_ssp_capable(hdev)) {
1203 debugfs_create_file("auto_accept_delay", 0644, hdev->debugfs, 1252 debugfs_create_file("auto_accept_delay", 0644, hdev->debugfs,
1204 hdev, &auto_accept_delay_fops); 1253 hdev, &auto_accept_delay_fops);
1254 debugfs_create_file("ssp_debug_mode", 0644, hdev->debugfs,
1255 hdev, &ssp_debug_mode_fops);
1256 }
1205 1257
1206 if (lmp_sniff_capable(hdev)) { 1258 if (lmp_sniff_capable(hdev)) {
1207 debugfs_create_file("idle_timeout", 0644, hdev->debugfs, 1259 debugfs_create_file("idle_timeout", 0644, hdev->debugfs,
diff --git a/net/bluetooth/hci_event.c b/net/bluetooth/hci_event.c
index 1214d4b6f541..5935f748c0f9 100644
--- a/net/bluetooth/hci_event.c
+++ b/net/bluetooth/hci_event.c
@@ -198,6 +198,8 @@ static void hci_cc_reset(struct hci_dev *hdev, struct sk_buff *skb)
198 198
199 memset(hdev->scan_rsp_data, 0, sizeof(hdev->scan_rsp_data)); 199 memset(hdev->scan_rsp_data, 0, sizeof(hdev->scan_rsp_data));
200 hdev->scan_rsp_data_len = 0; 200 hdev->scan_rsp_data_len = 0;
201
202 hdev->ssp_debug_mode = 0;
201} 203}
202 204
203static void hci_cc_write_local_name(struct hci_dev *hdev, struct sk_buff *skb) 205static void hci_cc_write_local_name(struct hci_dev *hdev, struct sk_buff *skb)