diff options
author | Marcel Holtmann <marcel@holtmann.org> | 2013-10-19 10:09:13 -0400 |
---|---|---|
committer | Johan Hedberg <johan.hedberg@intel.com> | 2013-10-19 11:56:54 -0400 |
commit | 4e70c7e71c5f9cf11013628ab5a0ced449b1c7b2 (patch) | |
tree | ea047f7b59948dc6c114b722b35e26927cb3d0a2 /net | |
parent | 06f5b7785af6beebb7b2a452687b5a102c90ca6e (diff) |
Bluetooth: Expose debugfs settings for LE connection interval
For testing purposes expose the default LE connection interval values
via debugfs.
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Diffstat (limited to 'net')
-rw-r--r-- | net/bluetooth/hci_conn.c | 5 | ||||
-rw-r--r-- | net/bluetooth/hci_core.c | 62 |
2 files changed, 65 insertions, 2 deletions
diff --git a/net/bluetooth/hci_conn.c b/net/bluetooth/hci_conn.c index 974d7bccbb6f..ba5366c320da 100644 --- a/net/bluetooth/hci_conn.c +++ b/net/bluetooth/hci_conn.c | |||
@@ -558,11 +558,12 @@ static int hci_create_le_conn(struct hci_conn *conn) | |||
558 | bacpy(&cp.peer_addr, &conn->dst); | 558 | bacpy(&cp.peer_addr, &conn->dst); |
559 | cp.peer_addr_type = conn->dst_type; | 559 | cp.peer_addr_type = conn->dst_type; |
560 | cp.own_address_type = conn->src_type; | 560 | cp.own_address_type = conn->src_type; |
561 | cp.conn_interval_min = __constant_cpu_to_le16(0x0028); | 561 | cp.conn_interval_min = cpu_to_le16(hdev->le_conn_min_interval); |
562 | cp.conn_interval_max = __constant_cpu_to_le16(0x0038); | 562 | cp.conn_interval_max = cpu_to_le16(hdev->le_conn_max_interval); |
563 | cp.supervision_timeout = __constant_cpu_to_le16(0x002a); | 563 | cp.supervision_timeout = __constant_cpu_to_le16(0x002a); |
564 | cp.min_ce_len = __constant_cpu_to_le16(0x0000); | 564 | cp.min_ce_len = __constant_cpu_to_le16(0x0000); |
565 | cp.max_ce_len = __constant_cpu_to_le16(0x0000); | 565 | cp.max_ce_len = __constant_cpu_to_le16(0x0000); |
566 | |||
566 | hci_req_add(&req, HCI_OP_LE_CREATE_CONN, sizeof(cp), &cp); | 567 | hci_req_add(&req, HCI_OP_LE_CREATE_CONN, sizeof(cp), &cp); |
567 | 568 | ||
568 | err = hci_req_run(&req, create_le_conn_complete); | 569 | err = hci_req_run(&req, create_le_conn_complete); |
diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c index 2a9e92503fd6..8149e1303e2b 100644 --- a/net/bluetooth/hci_core.c +++ b/net/bluetooth/hci_core.c | |||
@@ -517,6 +517,62 @@ static const struct file_operations long_term_keys_fops = { | |||
517 | .release = single_release, | 517 | .release = single_release, |
518 | }; | 518 | }; |
519 | 519 | ||
520 | static int conn_min_interval_set(void *data, u64 val) | ||
521 | { | ||
522 | struct hci_dev *hdev = data; | ||
523 | |||
524 | if (val < 0x0006 || val > 0x0c80 || val > hdev->le_conn_max_interval) | ||
525 | return -EINVAL; | ||
526 | |||
527 | hci_dev_lock(hdev); | ||
528 | hdev->le_conn_min_interval= val; | ||
529 | hci_dev_unlock(hdev); | ||
530 | |||
531 | return 0; | ||
532 | } | ||
533 | |||
534 | static int conn_min_interval_get(void *data, u64 *val) | ||
535 | { | ||
536 | struct hci_dev *hdev = data; | ||
537 | |||
538 | hci_dev_lock(hdev); | ||
539 | *val = hdev->le_conn_min_interval; | ||
540 | hci_dev_unlock(hdev); | ||
541 | |||
542 | return 0; | ||
543 | } | ||
544 | |||
545 | DEFINE_SIMPLE_ATTRIBUTE(conn_min_interval_fops, conn_min_interval_get, | ||
546 | conn_min_interval_set, "%llu\n"); | ||
547 | |||
548 | static int conn_max_interval_set(void *data, u64 val) | ||
549 | { | ||
550 | struct hci_dev *hdev = data; | ||
551 | |||
552 | if (val < 0x0006 || val > 0x0c80 || val < hdev->le_conn_min_interval) | ||
553 | return -EINVAL; | ||
554 | |||
555 | hci_dev_lock(hdev); | ||
556 | hdev->le_conn_max_interval= val; | ||
557 | hci_dev_unlock(hdev); | ||
558 | |||
559 | return 0; | ||
560 | } | ||
561 | |||
562 | static int conn_max_interval_get(void *data, u64 *val) | ||
563 | { | ||
564 | struct hci_dev *hdev = data; | ||
565 | |||
566 | hci_dev_lock(hdev); | ||
567 | *val = hdev->le_conn_max_interval; | ||
568 | hci_dev_unlock(hdev); | ||
569 | |||
570 | return 0; | ||
571 | } | ||
572 | |||
573 | DEFINE_SIMPLE_ATTRIBUTE(conn_max_interval_fops, conn_max_interval_get, | ||
574 | conn_max_interval_set, "%llu\n"); | ||
575 | |||
520 | /* ---- HCI requests ---- */ | 576 | /* ---- HCI requests ---- */ |
521 | 577 | ||
522 | static void hci_req_sync_complete(struct hci_dev *hdev, u8 result) | 578 | static void hci_req_sync_complete(struct hci_dev *hdev, u8 result) |
@@ -1273,6 +1329,10 @@ static int __hci_init(struct hci_dev *hdev) | |||
1273 | hdev, &own_address_type_fops); | 1329 | hdev, &own_address_type_fops); |
1274 | debugfs_create_file("long_term_keys", 0400, hdev->debugfs, | 1330 | debugfs_create_file("long_term_keys", 0400, hdev->debugfs, |
1275 | hdev, &long_term_keys_fops); | 1331 | hdev, &long_term_keys_fops); |
1332 | debugfs_create_file("conn_min_interval", 0644, hdev->debugfs, | ||
1333 | hdev, &conn_min_interval_fops); | ||
1334 | debugfs_create_file("conn_max_interval", 0644, hdev->debugfs, | ||
1335 | hdev, &conn_max_interval_fops); | ||
1276 | } | 1336 | } |
1277 | 1337 | ||
1278 | return 0; | 1338 | return 0; |
@@ -2738,6 +2798,8 @@ struct hci_dev *hci_alloc_dev(void) | |||
2738 | 2798 | ||
2739 | hdev->le_scan_interval = 0x0060; | 2799 | hdev->le_scan_interval = 0x0060; |
2740 | hdev->le_scan_window = 0x0030; | 2800 | hdev->le_scan_window = 0x0030; |
2801 | hdev->le_conn_min_interval = 0x0028; | ||
2802 | hdev->le_conn_max_interval = 0x0038; | ||
2741 | 2803 | ||
2742 | mutex_init(&hdev->lock); | 2804 | mutex_init(&hdev->lock); |
2743 | mutex_init(&hdev->req_lock); | 2805 | mutex_init(&hdev->req_lock); |