2 BlueZ - Bluetooth protocol stack for Linux
4 Copyright (C) 2014 Intel Corporation
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License version 2 as
8 published by the Free Software Foundation;
10 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
11 OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
12 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF THIRD PARTY RIGHTS.
13 IN NO EVENT SHALL THE COPYRIGHT HOLDER(S) AND AUTHOR(S) BE LIABLE FOR ANY
14 CLAIM, OR ANY SPECIAL INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES
15 WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
16 ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
17 OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
19 ALL LIABILITY, INCLUDING LIABILITY FOR INFRINGEMENT OF ANY PATENTS,
20 COPYRIGHTS, TRADEMARKS OR OTHER RIGHTS, RELATING TO USE OF THIS
21 SOFTWARE IS DISCLAIMED.
24 #include <linux/debugfs.h>
26 #include <net/bluetooth/bluetooth.h>
27 #include <net/bluetooth/hci_core.h>
29 #include "hci_debugfs.h"
31 static int features_show(struct seq_file
*f
, void *ptr
)
33 struct hci_dev
*hdev
= f
->private;
37 for (p
= 0; p
< HCI_MAX_PAGES
&& p
<= hdev
->max_page
; p
++) {
38 seq_printf(f
, "%2u: 0x%2.2x 0x%2.2x 0x%2.2x 0x%2.2x "
39 "0x%2.2x 0x%2.2x 0x%2.2x 0x%2.2x\n", p
,
40 hdev
->features
[p
][0], hdev
->features
[p
][1],
41 hdev
->features
[p
][2], hdev
->features
[p
][3],
42 hdev
->features
[p
][4], hdev
->features
[p
][5],
43 hdev
->features
[p
][6], hdev
->features
[p
][7]);
45 if (lmp_le_capable(hdev
))
46 seq_printf(f
, "LE: 0x%2.2x 0x%2.2x 0x%2.2x 0x%2.2x "
47 "0x%2.2x 0x%2.2x 0x%2.2x 0x%2.2x\n",
48 hdev
->le_features
[0], hdev
->le_features
[1],
49 hdev
->le_features
[2], hdev
->le_features
[3],
50 hdev
->le_features
[4], hdev
->le_features
[5],
51 hdev
->le_features
[6], hdev
->le_features
[7]);
57 static int features_open(struct inode
*inode
, struct file
*file
)
59 return single_open(file
, features_show
, inode
->i_private
);
62 static const struct file_operations features_fops
= {
63 .open
= features_open
,
66 .release
= single_release
,
69 static int device_list_show(struct seq_file
*f
, void *ptr
)
71 struct hci_dev
*hdev
= f
->private;
72 struct hci_conn_params
*p
;
73 struct bdaddr_list
*b
;
76 list_for_each_entry(b
, &hdev
->whitelist
, list
)
77 seq_printf(f
, "%pMR (type %u)\n", &b
->bdaddr
, b
->bdaddr_type
);
78 list_for_each_entry(p
, &hdev
->le_conn_params
, list
) {
79 seq_printf(f
, "%pMR (type %u) %u\n", &p
->addr
, p
->addr_type
,
87 static int device_list_open(struct inode
*inode
, struct file
*file
)
89 return single_open(file
, device_list_show
, inode
->i_private
);
92 static const struct file_operations device_list_fops
= {
93 .open
= device_list_open
,
96 .release
= single_release
,
99 static int blacklist_show(struct seq_file
*f
, void *p
)
101 struct hci_dev
*hdev
= f
->private;
102 struct bdaddr_list
*b
;
105 list_for_each_entry(b
, &hdev
->blacklist
, list
)
106 seq_printf(f
, "%pMR (type %u)\n", &b
->bdaddr
, b
->bdaddr_type
);
107 hci_dev_unlock(hdev
);
112 static int blacklist_open(struct inode
*inode
, struct file
*file
)
114 return single_open(file
, blacklist_show
, inode
->i_private
);
117 static const struct file_operations blacklist_fops
= {
118 .open
= blacklist_open
,
121 .release
= single_release
,
124 static int uuids_show(struct seq_file
*f
, void *p
)
126 struct hci_dev
*hdev
= f
->private;
127 struct bt_uuid
*uuid
;
130 list_for_each_entry(uuid
, &hdev
->uuids
, list
) {
133 /* The Bluetooth UUID values are stored in big endian,
134 * but with reversed byte order. So convert them into
135 * the right order for the %pUb modifier.
137 for (i
= 0; i
< 16; i
++)
138 val
[i
] = uuid
->uuid
[15 - i
];
140 seq_printf(f
, "%pUb\n", val
);
142 hci_dev_unlock(hdev
);
147 static int uuids_open(struct inode
*inode
, struct file
*file
)
149 return single_open(file
, uuids_show
, inode
->i_private
);
152 static const struct file_operations uuids_fops
= {
156 .release
= single_release
,
159 static int remote_oob_show(struct seq_file
*f
, void *ptr
)
161 struct hci_dev
*hdev
= f
->private;
162 struct oob_data
*data
;
165 list_for_each_entry(data
, &hdev
->remote_oob_data
, list
) {
166 seq_printf(f
, "%pMR (type %u) %u %*phN %*phN %*phN %*phN\n",
167 &data
->bdaddr
, data
->bdaddr_type
, data
->present
,
168 16, data
->hash192
, 16, data
->rand192
,
169 16, data
->hash256
, 19, data
->rand256
);
171 hci_dev_unlock(hdev
);
176 static int remote_oob_open(struct inode
*inode
, struct file
*file
)
178 return single_open(file
, remote_oob_show
, inode
->i_private
);
181 static const struct file_operations remote_oob_fops
= {
182 .open
= remote_oob_open
,
185 .release
= single_release
,
188 static int conn_info_min_age_set(void *data
, u64 val
)
190 struct hci_dev
*hdev
= data
;
192 if (val
== 0 || val
> hdev
->conn_info_max_age
)
196 hdev
->conn_info_min_age
= val
;
197 hci_dev_unlock(hdev
);
202 static int conn_info_min_age_get(void *data
, u64
*val
)
204 struct hci_dev
*hdev
= data
;
207 *val
= hdev
->conn_info_min_age
;
208 hci_dev_unlock(hdev
);
213 DEFINE_SIMPLE_ATTRIBUTE(conn_info_min_age_fops
, conn_info_min_age_get
,
214 conn_info_min_age_set
, "%llu\n");
216 static int conn_info_max_age_set(void *data
, u64 val
)
218 struct hci_dev
*hdev
= data
;
220 if (val
== 0 || val
< hdev
->conn_info_min_age
)
224 hdev
->conn_info_max_age
= val
;
225 hci_dev_unlock(hdev
);
230 static int conn_info_max_age_get(void *data
, u64
*val
)
232 struct hci_dev
*hdev
= data
;
235 *val
= hdev
->conn_info_max_age
;
236 hci_dev_unlock(hdev
);
241 DEFINE_SIMPLE_ATTRIBUTE(conn_info_max_age_fops
, conn_info_max_age_get
,
242 conn_info_max_age_set
, "%llu\n");
244 static ssize_t
use_debug_keys_read(struct file
*file
, char __user
*user_buf
,
245 size_t count
, loff_t
*ppos
)
247 struct hci_dev
*hdev
= file
->private_data
;
250 buf
[0] = test_bit(HCI_USE_DEBUG_KEYS
, &hdev
->dev_flags
) ? 'Y': 'N';
253 return simple_read_from_buffer(user_buf
, count
, ppos
, buf
, 2);
256 static const struct file_operations use_debug_keys_fops
= {
258 .read
= use_debug_keys_read
,
259 .llseek
= default_llseek
,
262 static ssize_t
sc_only_mode_read(struct file
*file
, char __user
*user_buf
,
263 size_t count
, loff_t
*ppos
)
265 struct hci_dev
*hdev
= file
->private_data
;
268 buf
[0] = test_bit(HCI_SC_ONLY
, &hdev
->dev_flags
) ? 'Y': 'N';
271 return simple_read_from_buffer(user_buf
, count
, ppos
, buf
, 2);
274 static const struct file_operations sc_only_mode_fops
= {
276 .read
= sc_only_mode_read
,
277 .llseek
= default_llseek
,
280 void hci_debugfs_create_common(struct hci_dev
*hdev
)
282 debugfs_create_file("features", 0444, hdev
->debugfs
, hdev
,
284 debugfs_create_u16("manufacturer", 0444, hdev
->debugfs
,
285 &hdev
->manufacturer
);
286 debugfs_create_u8("hci_version", 0444, hdev
->debugfs
, &hdev
->hci_ver
);
287 debugfs_create_u16("hci_revision", 0444, hdev
->debugfs
, &hdev
->hci_rev
);
288 debugfs_create_u8("hardware_error", 0444, hdev
->debugfs
,
289 &hdev
->hw_error_code
);
291 debugfs_create_file("device_list", 0444, hdev
->debugfs
, hdev
,
293 debugfs_create_file("blacklist", 0444, hdev
->debugfs
, hdev
,
295 debugfs_create_file("uuids", 0444, hdev
->debugfs
, hdev
, &uuids_fops
);
296 debugfs_create_file("remote_oob", 0400, hdev
->debugfs
, hdev
,
299 debugfs_create_file("conn_info_min_age", 0644, hdev
->debugfs
, hdev
,
300 &conn_info_min_age_fops
);
301 debugfs_create_file("conn_info_max_age", 0644, hdev
->debugfs
, hdev
,
302 &conn_info_max_age_fops
);
304 if (lmp_ssp_capable(hdev
) || lmp_le_capable(hdev
))
305 debugfs_create_file("use_debug_keys", 0444, hdev
->debugfs
,
306 hdev
, &use_debug_keys_fops
);
308 if (lmp_sc_capable(hdev
) || lmp_le_capable(hdev
))
309 debugfs_create_file("sc_only_mode", 0444, hdev
->debugfs
,
310 hdev
, &sc_only_mode_fops
);
313 static int inquiry_cache_show(struct seq_file
*f
, void *p
)
315 struct hci_dev
*hdev
= f
->private;
316 struct discovery_state
*cache
= &hdev
->discovery
;
317 struct inquiry_entry
*e
;
321 list_for_each_entry(e
, &cache
->all
, all
) {
322 struct inquiry_data
*data
= &e
->data
;
323 seq_printf(f
, "%pMR %d %d %d 0x%.2x%.2x%.2x 0x%.4x %d %d %u\n",
325 data
->pscan_rep_mode
, data
->pscan_period_mode
,
326 data
->pscan_mode
, data
->dev_class
[2],
327 data
->dev_class
[1], data
->dev_class
[0],
328 __le16_to_cpu(data
->clock_offset
),
329 data
->rssi
, data
->ssp_mode
, e
->timestamp
);
332 hci_dev_unlock(hdev
);
337 static int inquiry_cache_open(struct inode
*inode
, struct file
*file
)
339 return single_open(file
, inquiry_cache_show
, inode
->i_private
);
342 static const struct file_operations inquiry_cache_fops
= {
343 .open
= inquiry_cache_open
,
346 .release
= single_release
,
349 static int link_keys_show(struct seq_file
*f
, void *ptr
)
351 struct hci_dev
*hdev
= f
->private;
352 struct link_key
*key
;
355 list_for_each_entry_rcu(key
, &hdev
->link_keys
, list
)
356 seq_printf(f
, "%pMR %u %*phN %u\n", &key
->bdaddr
, key
->type
,
357 HCI_LINK_KEY_SIZE
, key
->val
, key
->pin_len
);
363 static int link_keys_open(struct inode
*inode
, struct file
*file
)
365 return single_open(file
, link_keys_show
, inode
->i_private
);
368 static const struct file_operations link_keys_fops
= {
369 .open
= link_keys_open
,
372 .release
= single_release
,
375 static int dev_class_show(struct seq_file
*f
, void *ptr
)
377 struct hci_dev
*hdev
= f
->private;
380 seq_printf(f
, "0x%.2x%.2x%.2x\n", hdev
->dev_class
[2],
381 hdev
->dev_class
[1], hdev
->dev_class
[0]);
382 hci_dev_unlock(hdev
);
387 static int dev_class_open(struct inode
*inode
, struct file
*file
)
389 return single_open(file
, dev_class_show
, inode
->i_private
);
392 static const struct file_operations dev_class_fops
= {
393 .open
= dev_class_open
,
396 .release
= single_release
,
399 static int voice_setting_get(void *data
, u64
*val
)
401 struct hci_dev
*hdev
= data
;
404 *val
= hdev
->voice_setting
;
405 hci_dev_unlock(hdev
);
410 DEFINE_SIMPLE_ATTRIBUTE(voice_setting_fops
, voice_setting_get
,
411 NULL
, "0x%4.4llx\n");
413 static ssize_t
ssp_debug_mode_read(struct file
*file
, char __user
*user_buf
,
414 size_t count
, loff_t
*ppos
)
416 struct hci_dev
*hdev
= file
->private_data
;
419 buf
[0] = hdev
->ssp_debug_mode
? 'Y': 'N';
422 return simple_read_from_buffer(user_buf
, count
, ppos
, buf
, 2);
425 static const struct file_operations ssp_debug_mode_fops
= {
427 .read
= ssp_debug_mode_read
,
428 .llseek
= default_llseek
,
431 static int auto_accept_delay_set(void *data
, u64 val
)
433 struct hci_dev
*hdev
= data
;
436 hdev
->auto_accept_delay
= val
;
437 hci_dev_unlock(hdev
);
442 static int auto_accept_delay_get(void *data
, u64
*val
)
444 struct hci_dev
*hdev
= data
;
447 *val
= hdev
->auto_accept_delay
;
448 hci_dev_unlock(hdev
);
453 DEFINE_SIMPLE_ATTRIBUTE(auto_accept_delay_fops
, auto_accept_delay_get
,
454 auto_accept_delay_set
, "%llu\n");
456 static int idle_timeout_set(void *data
, u64 val
)
458 struct hci_dev
*hdev
= data
;
460 if (val
!= 0 && (val
< 500 || val
> 3600000))
464 hdev
->idle_timeout
= val
;
465 hci_dev_unlock(hdev
);
470 static int idle_timeout_get(void *data
, u64
*val
)
472 struct hci_dev
*hdev
= data
;
475 *val
= hdev
->idle_timeout
;
476 hci_dev_unlock(hdev
);
481 DEFINE_SIMPLE_ATTRIBUTE(idle_timeout_fops
, idle_timeout_get
,
482 idle_timeout_set
, "%llu\n");
484 static int sniff_min_interval_set(void *data
, u64 val
)
486 struct hci_dev
*hdev
= data
;
488 if (val
== 0 || val
% 2 || val
> hdev
->sniff_max_interval
)
492 hdev
->sniff_min_interval
= val
;
493 hci_dev_unlock(hdev
);
498 static int sniff_min_interval_get(void *data
, u64
*val
)
500 struct hci_dev
*hdev
= data
;
503 *val
= hdev
->sniff_min_interval
;
504 hci_dev_unlock(hdev
);
509 DEFINE_SIMPLE_ATTRIBUTE(sniff_min_interval_fops
, sniff_min_interval_get
,
510 sniff_min_interval_set
, "%llu\n");
512 static int sniff_max_interval_set(void *data
, u64 val
)
514 struct hci_dev
*hdev
= data
;
516 if (val
== 0 || val
% 2 || val
< hdev
->sniff_min_interval
)
520 hdev
->sniff_max_interval
= val
;
521 hci_dev_unlock(hdev
);
526 static int sniff_max_interval_get(void *data
, u64
*val
)
528 struct hci_dev
*hdev
= data
;
531 *val
= hdev
->sniff_max_interval
;
532 hci_dev_unlock(hdev
);
537 DEFINE_SIMPLE_ATTRIBUTE(sniff_max_interval_fops
, sniff_max_interval_get
,
538 sniff_max_interval_set
, "%llu\n");
540 void hci_debugfs_create_bredr(struct hci_dev
*hdev
)
542 debugfs_create_file("inquiry_cache", 0444, hdev
->debugfs
, hdev
,
543 &inquiry_cache_fops
);
544 debugfs_create_file("link_keys", 0400, hdev
->debugfs
, hdev
,
546 debugfs_create_file("dev_class", 0444, hdev
->debugfs
, hdev
,
548 debugfs_create_file("voice_setting", 0444, hdev
->debugfs
, hdev
,
549 &voice_setting_fops
);
551 if (lmp_ssp_capable(hdev
)) {
552 debugfs_create_file("ssp_debug_mode", 0444, hdev
->debugfs
,
553 hdev
, &ssp_debug_mode_fops
);
554 debugfs_create_file("auto_accept_delay", 0644, hdev
->debugfs
,
555 hdev
, &auto_accept_delay_fops
);
558 if (lmp_sniff_capable(hdev
)) {
559 debugfs_create_file("idle_timeout", 0644, hdev
->debugfs
,
560 hdev
, &idle_timeout_fops
);
561 debugfs_create_file("sniff_min_interval", 0644, hdev
->debugfs
,
562 hdev
, &sniff_min_interval_fops
);
563 debugfs_create_file("sniff_max_interval", 0644, hdev
->debugfs
,
564 hdev
, &sniff_max_interval_fops
);
568 static int identity_show(struct seq_file
*f
, void *p
)
570 struct hci_dev
*hdev
= f
->private;
576 hci_copy_identity_address(hdev
, &addr
, &addr_type
);
578 seq_printf(f
, "%pMR (type %u) %*phN %pMR\n", &addr
, addr_type
,
579 16, hdev
->irk
, &hdev
->rpa
);
581 hci_dev_unlock(hdev
);
586 static int identity_open(struct inode
*inode
, struct file
*file
)
588 return single_open(file
, identity_show
, inode
->i_private
);
591 static const struct file_operations identity_fops
= {
592 .open
= identity_open
,
595 .release
= single_release
,
598 static int rpa_timeout_set(void *data
, u64 val
)
600 struct hci_dev
*hdev
= data
;
602 /* Require the RPA timeout to be at least 30 seconds and at most
605 if (val
< 30 || val
> (60 * 60 * 24))
609 hdev
->rpa_timeout
= val
;
610 hci_dev_unlock(hdev
);
615 static int rpa_timeout_get(void *data
, u64
*val
)
617 struct hci_dev
*hdev
= data
;
620 *val
= hdev
->rpa_timeout
;
621 hci_dev_unlock(hdev
);
626 DEFINE_SIMPLE_ATTRIBUTE(rpa_timeout_fops
, rpa_timeout_get
,
627 rpa_timeout_set
, "%llu\n");
629 static int random_address_show(struct seq_file
*f
, void *p
)
631 struct hci_dev
*hdev
= f
->private;
634 seq_printf(f
, "%pMR\n", &hdev
->random_addr
);
635 hci_dev_unlock(hdev
);
640 static int random_address_open(struct inode
*inode
, struct file
*file
)
642 return single_open(file
, random_address_show
, inode
->i_private
);
645 static const struct file_operations random_address_fops
= {
646 .open
= random_address_open
,
649 .release
= single_release
,
652 static int static_address_show(struct seq_file
*f
, void *p
)
654 struct hci_dev
*hdev
= f
->private;
657 seq_printf(f
, "%pMR\n", &hdev
->static_addr
);
658 hci_dev_unlock(hdev
);
663 static int static_address_open(struct inode
*inode
, struct file
*file
)
665 return single_open(file
, static_address_show
, inode
->i_private
);
668 static const struct file_operations static_address_fops
= {
669 .open
= static_address_open
,
672 .release
= single_release
,
675 static ssize_t
force_static_address_read(struct file
*file
,
676 char __user
*user_buf
,
677 size_t count
, loff_t
*ppos
)
679 struct hci_dev
*hdev
= file
->private_data
;
682 buf
[0] = test_bit(HCI_FORCE_STATIC_ADDR
, &hdev
->dbg_flags
) ? 'Y': 'N';
685 return simple_read_from_buffer(user_buf
, count
, ppos
, buf
, 2);
688 static ssize_t
force_static_address_write(struct file
*file
,
689 const char __user
*user_buf
,
690 size_t count
, loff_t
*ppos
)
692 struct hci_dev
*hdev
= file
->private_data
;
694 size_t buf_size
= min(count
, (sizeof(buf
)-1));
697 if (test_bit(HCI_UP
, &hdev
->flags
))
700 if (copy_from_user(buf
, user_buf
, buf_size
))
703 buf
[buf_size
] = '\0';
704 if (strtobool(buf
, &enable
))
707 if (enable
== test_bit(HCI_FORCE_STATIC_ADDR
, &hdev
->dbg_flags
))
710 change_bit(HCI_FORCE_STATIC_ADDR
, &hdev
->dbg_flags
);
715 static const struct file_operations force_static_address_fops
= {
717 .read
= force_static_address_read
,
718 .write
= force_static_address_write
,
719 .llseek
= default_llseek
,
722 static int white_list_show(struct seq_file
*f
, void *ptr
)
724 struct hci_dev
*hdev
= f
->private;
725 struct bdaddr_list
*b
;
728 list_for_each_entry(b
, &hdev
->le_white_list
, list
)
729 seq_printf(f
, "%pMR (type %u)\n", &b
->bdaddr
, b
->bdaddr_type
);
730 hci_dev_unlock(hdev
);
735 static int white_list_open(struct inode
*inode
, struct file
*file
)
737 return single_open(file
, white_list_show
, inode
->i_private
);
740 static const struct file_operations white_list_fops
= {
741 .open
= white_list_open
,
744 .release
= single_release
,
747 static int identity_resolving_keys_show(struct seq_file
*f
, void *ptr
)
749 struct hci_dev
*hdev
= f
->private;
753 list_for_each_entry_rcu(irk
, &hdev
->identity_resolving_keys
, list
) {
754 seq_printf(f
, "%pMR (type %u) %*phN %pMR\n",
755 &irk
->bdaddr
, irk
->addr_type
,
756 16, irk
->val
, &irk
->rpa
);
763 static int identity_resolving_keys_open(struct inode
*inode
, struct file
*file
)
765 return single_open(file
, identity_resolving_keys_show
,
769 static const struct file_operations identity_resolving_keys_fops
= {
770 .open
= identity_resolving_keys_open
,
773 .release
= single_release
,
776 static int long_term_keys_show(struct seq_file
*f
, void *ptr
)
778 struct hci_dev
*hdev
= f
->private;
782 list_for_each_entry_rcu(ltk
, &hdev
->long_term_keys
, list
)
783 seq_printf(f
, "%pMR (type %u) %u 0x%02x %u %.4x %.16llx %*phN\n",
784 <k
->bdaddr
, ltk
->bdaddr_type
, ltk
->authenticated
,
785 ltk
->type
, ltk
->enc_size
, __le16_to_cpu(ltk
->ediv
),
786 __le64_to_cpu(ltk
->rand
), 16, ltk
->val
);
792 static int long_term_keys_open(struct inode
*inode
, struct file
*file
)
794 return single_open(file
, long_term_keys_show
, inode
->i_private
);
797 static const struct file_operations long_term_keys_fops
= {
798 .open
= long_term_keys_open
,
801 .release
= single_release
,
804 static int conn_min_interval_set(void *data
, u64 val
)
806 struct hci_dev
*hdev
= data
;
808 if (val
< 0x0006 || val
> 0x0c80 || val
> hdev
->le_conn_max_interval
)
812 hdev
->le_conn_min_interval
= val
;
813 hci_dev_unlock(hdev
);
818 static int conn_min_interval_get(void *data
, u64
*val
)
820 struct hci_dev
*hdev
= data
;
823 *val
= hdev
->le_conn_min_interval
;
824 hci_dev_unlock(hdev
);
829 DEFINE_SIMPLE_ATTRIBUTE(conn_min_interval_fops
, conn_min_interval_get
,
830 conn_min_interval_set
, "%llu\n");
832 static int conn_max_interval_set(void *data
, u64 val
)
834 struct hci_dev
*hdev
= data
;
836 if (val
< 0x0006 || val
> 0x0c80 || val
< hdev
->le_conn_min_interval
)
840 hdev
->le_conn_max_interval
= val
;
841 hci_dev_unlock(hdev
);
846 static int conn_max_interval_get(void *data
, u64
*val
)
848 struct hci_dev
*hdev
= data
;
851 *val
= hdev
->le_conn_max_interval
;
852 hci_dev_unlock(hdev
);
857 DEFINE_SIMPLE_ATTRIBUTE(conn_max_interval_fops
, conn_max_interval_get
,
858 conn_max_interval_set
, "%llu\n");
860 static int conn_latency_set(void *data
, u64 val
)
862 struct hci_dev
*hdev
= data
;
868 hdev
->le_conn_latency
= val
;
869 hci_dev_unlock(hdev
);
874 static int conn_latency_get(void *data
, u64
*val
)
876 struct hci_dev
*hdev
= data
;
879 *val
= hdev
->le_conn_latency
;
880 hci_dev_unlock(hdev
);
885 DEFINE_SIMPLE_ATTRIBUTE(conn_latency_fops
, conn_latency_get
,
886 conn_latency_set
, "%llu\n");
888 static int supervision_timeout_set(void *data
, u64 val
)
890 struct hci_dev
*hdev
= data
;
892 if (val
< 0x000a || val
> 0x0c80)
896 hdev
->le_supv_timeout
= val
;
897 hci_dev_unlock(hdev
);
902 static int supervision_timeout_get(void *data
, u64
*val
)
904 struct hci_dev
*hdev
= data
;
907 *val
= hdev
->le_supv_timeout
;
908 hci_dev_unlock(hdev
);
913 DEFINE_SIMPLE_ATTRIBUTE(supervision_timeout_fops
, supervision_timeout_get
,
914 supervision_timeout_set
, "%llu\n");
916 static int adv_channel_map_set(void *data
, u64 val
)
918 struct hci_dev
*hdev
= data
;
920 if (val
< 0x01 || val
> 0x07)
924 hdev
->le_adv_channel_map
= val
;
925 hci_dev_unlock(hdev
);
930 static int adv_channel_map_get(void *data
, u64
*val
)
932 struct hci_dev
*hdev
= data
;
935 *val
= hdev
->le_adv_channel_map
;
936 hci_dev_unlock(hdev
);
941 DEFINE_SIMPLE_ATTRIBUTE(adv_channel_map_fops
, adv_channel_map_get
,
942 adv_channel_map_set
, "%llu\n");
944 static int adv_min_interval_set(void *data
, u64 val
)
946 struct hci_dev
*hdev
= data
;
948 if (val
< 0x0020 || val
> 0x4000 || val
> hdev
->le_adv_max_interval
)
952 hdev
->le_adv_min_interval
= val
;
953 hci_dev_unlock(hdev
);
958 static int adv_min_interval_get(void *data
, u64
*val
)
960 struct hci_dev
*hdev
= data
;
963 *val
= hdev
->le_adv_min_interval
;
964 hci_dev_unlock(hdev
);
969 DEFINE_SIMPLE_ATTRIBUTE(adv_min_interval_fops
, adv_min_interval_get
,
970 adv_min_interval_set
, "%llu\n");
972 static int adv_max_interval_set(void *data
, u64 val
)
974 struct hci_dev
*hdev
= data
;
976 if (val
< 0x0020 || val
> 0x4000 || val
< hdev
->le_adv_min_interval
)
980 hdev
->le_adv_max_interval
= val
;
981 hci_dev_unlock(hdev
);
986 static int adv_max_interval_get(void *data
, u64
*val
)
988 struct hci_dev
*hdev
= data
;
991 *val
= hdev
->le_adv_max_interval
;
992 hci_dev_unlock(hdev
);
997 DEFINE_SIMPLE_ATTRIBUTE(adv_max_interval_fops
, adv_max_interval_get
,
998 adv_max_interval_set
, "%llu\n");
1000 void hci_debugfs_create_le(struct hci_dev
*hdev
)
1002 debugfs_create_file("identity", 0400, hdev
->debugfs
, hdev
,
1004 debugfs_create_file("rpa_timeout", 0644, hdev
->debugfs
, hdev
,
1006 debugfs_create_file("random_address", 0444, hdev
->debugfs
, hdev
,
1007 &random_address_fops
);
1008 debugfs_create_file("static_address", 0444, hdev
->debugfs
, hdev
,
1009 &static_address_fops
);
1011 /* For controllers with a public address, provide a debug
1012 * option to force the usage of the configured static
1013 * address. By default the public address is used.
1015 if (bacmp(&hdev
->bdaddr
, BDADDR_ANY
))
1016 debugfs_create_file("force_static_address", 0644,
1017 hdev
->debugfs
, hdev
,
1018 &force_static_address_fops
);
1020 debugfs_create_u8("white_list_size", 0444, hdev
->debugfs
,
1021 &hdev
->le_white_list_size
);
1022 debugfs_create_file("white_list", 0444, hdev
->debugfs
, hdev
,
1024 debugfs_create_file("identity_resolving_keys", 0400, hdev
->debugfs
,
1025 hdev
, &identity_resolving_keys_fops
);
1026 debugfs_create_file("long_term_keys", 0400, hdev
->debugfs
, hdev
,
1027 &long_term_keys_fops
);
1028 debugfs_create_file("conn_min_interval", 0644, hdev
->debugfs
, hdev
,
1029 &conn_min_interval_fops
);
1030 debugfs_create_file("conn_max_interval", 0644, hdev
->debugfs
, hdev
,
1031 &conn_max_interval_fops
);
1032 debugfs_create_file("conn_latency", 0644, hdev
->debugfs
, hdev
,
1033 &conn_latency_fops
);
1034 debugfs_create_file("supervision_timeout", 0644, hdev
->debugfs
, hdev
,
1035 &supervision_timeout_fops
);
1036 debugfs_create_file("adv_channel_map", 0644, hdev
->debugfs
, hdev
,
1037 &adv_channel_map_fops
);
1038 debugfs_create_file("adv_min_interval", 0644, hdev
->debugfs
, hdev
,
1039 &adv_min_interval_fops
);
1040 debugfs_create_file("adv_max_interval", 0644, hdev
->debugfs
, hdev
,
1041 &adv_max_interval_fops
);
1042 debugfs_create_u16("discov_interleaved_timeout", 0644, hdev
->debugfs
,
1043 &hdev
->discov_interleaved_timeout
);
1046 void hci_debugfs_create_conn(struct hci_conn
*conn
)
1048 struct hci_dev
*hdev
= conn
->hdev
;
1051 if (IS_ERR_OR_NULL(hdev
->debugfs
))
1054 snprintf(name
, sizeof(name
), "%u", conn
->handle
);
1055 conn
->debugfs
= debugfs_create_dir(name
, hdev
->debugfs
);