Skip to content

Commit 31ad169

Browse files
Andrzej Kaczmarekholtmann
authored andcommitted
Bluetooth: Add conn info lifetime parameters to debugfs
This patch adds conn_info_min_age and conn_info_max_age parameters to debugfs which determine lifetime of connection information. Actual lifetime will be random value between min and max age. Default values for min and max age are 1000ms and 3000ms respectively. Signed-off-by: Andrzej Kaczmarek <[email protected]> Signed-off-by: Marcel Holtmann <[email protected]>
1 parent 5a134fa commit 31ad169

File tree

2 files changed

+69
-0
lines changed

2 files changed

+69
-0
lines changed

include/net/bluetooth/hci_core.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,10 @@ struct oob_data {
145145
/* Default LE RPA expiry time, 15 minutes */
146146
#define HCI_DEFAULT_RPA_TIMEOUT (15 * 60)
147147

148+
/* Default min/max age of connection information (1s/3s) */
149+
#define DEFAULT_CONN_INFO_MIN_AGE 1000
150+
#define DEFAULT_CONN_INFO_MAX_AGE 3000
151+
148152
struct amp_assoc {
149153
__u16 len;
150154
__u16 offset;
@@ -200,6 +204,8 @@ struct hci_dev {
200204
__u16 le_conn_min_interval;
201205
__u16 le_conn_max_interval;
202206
__u16 discov_interleaved_timeout;
207+
__u16 conn_info_min_age;
208+
__u16 conn_info_max_age;
203209
__u8 ssp_debug_mode;
204210

205211
__u16 devid_source;

net/bluetooth/hci_core.c

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -579,6 +579,62 @@ static int sniff_max_interval_get(void *data, u64 *val)
579579
DEFINE_SIMPLE_ATTRIBUTE(sniff_max_interval_fops, sniff_max_interval_get,
580580
sniff_max_interval_set, "%llu\n");
581581

582+
static int conn_info_min_age_set(void *data, u64 val)
583+
{
584+
struct hci_dev *hdev = data;
585+
586+
if (val == 0 || val > hdev->conn_info_max_age)
587+
return -EINVAL;
588+
589+
hci_dev_lock(hdev);
590+
hdev->conn_info_min_age = val;
591+
hci_dev_unlock(hdev);
592+
593+
return 0;
594+
}
595+
596+
static int conn_info_min_age_get(void *data, u64 *val)
597+
{
598+
struct hci_dev *hdev = data;
599+
600+
hci_dev_lock(hdev);
601+
*val = hdev->conn_info_min_age;
602+
hci_dev_unlock(hdev);
603+
604+
return 0;
605+
}
606+
607+
DEFINE_SIMPLE_ATTRIBUTE(conn_info_min_age_fops, conn_info_min_age_get,
608+
conn_info_min_age_set, "%llu\n");
609+
610+
static int conn_info_max_age_set(void *data, u64 val)
611+
{
612+
struct hci_dev *hdev = data;
613+
614+
if (val == 0 || val < hdev->conn_info_min_age)
615+
return -EINVAL;
616+
617+
hci_dev_lock(hdev);
618+
hdev->conn_info_max_age = val;
619+
hci_dev_unlock(hdev);
620+
621+
return 0;
622+
}
623+
624+
static int conn_info_max_age_get(void *data, u64 *val)
625+
{
626+
struct hci_dev *hdev = data;
627+
628+
hci_dev_lock(hdev);
629+
*val = hdev->conn_info_max_age;
630+
hci_dev_unlock(hdev);
631+
632+
return 0;
633+
}
634+
635+
DEFINE_SIMPLE_ATTRIBUTE(conn_info_max_age_fops, conn_info_max_age_get,
636+
conn_info_max_age_set, "%llu\n");
637+
582638
static int identity_show(struct seq_file *f, void *p)
583639
{
584640
struct hci_dev *hdev = f->private;
@@ -1754,6 +1810,11 @@ static int __hci_init(struct hci_dev *hdev)
17541810
&blacklist_fops);
17551811
debugfs_create_file("uuids", 0444, hdev->debugfs, hdev, &uuids_fops);
17561812

1813+
debugfs_create_file("conn_info_min_age", 0644, hdev->debugfs, hdev,
1814+
&conn_info_min_age_fops);
1815+
debugfs_create_file("conn_info_max_age", 0644, hdev->debugfs, hdev,
1816+
&conn_info_max_age_fops);
1817+
17571818
if (lmp_bredr_capable(hdev)) {
17581819
debugfs_create_file("inquiry_cache", 0444, hdev->debugfs,
17591820
hdev, &inquiry_cache_fops);
@@ -3789,6 +3850,8 @@ struct hci_dev *hci_alloc_dev(void)
37893850

37903851
hdev->rpa_timeout = HCI_DEFAULT_RPA_TIMEOUT;
37913852
hdev->discov_interleaved_timeout = DISCOV_INTERLEAVED_TIMEOUT;
3853+
hdev->conn_info_min_age = DEFAULT_CONN_INFO_MIN_AGE;
3854+
hdev->conn_info_max_age = DEFAULT_CONN_INFO_MAX_AGE;
37923855

37933856
mutex_init(&hdev->lock);
37943857
mutex_init(&hdev->req_lock);

0 commit comments

Comments
 (0)