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 #define DEFINE_QUIRK_ATTRIBUTE(__name, __quirk) \
32 static ssize_t __name ## _read(struct file *file, \
33 char __user *user_buf, \
34 size_t count, loff_t *ppos) \
36 struct hci_dev *hdev = file->private_data; \
39 buf[0] = test_bit(__quirk, &hdev->quirks) ? 'Y' : 'N'; \
42 return simple_read_from_buffer(user_buf, count, ppos, buf, 2); \
45 static ssize_t __name ## _write(struct file *file, \
46 const char __user *user_buf, \
47 size_t count, loff_t *ppos) \
49 struct hci_dev *hdev = file->private_data; \
51 size_t buf_size = min(count, (sizeof(buf) - 1)); \
54 if (test_bit(HCI_UP, &hdev->flags)) \
57 if (copy_from_user(buf, user_buf, buf_size)) \
60 buf[buf_size] = '\0'; \
61 if (strtobool(buf, &enable)) \
64 if (enable == test_bit(__quirk, &hdev->quirks)) \
67 change_bit(__quirk, &hdev->quirks); \
72 static const struct file_operations __name ## _fops = { \
73 .open = simple_open, \
74 .read = __name ## _read, \
75 .write = __name ## _write, \
76 .llseek = default_llseek, \
79 #define DEFINE_INFO_ATTRIBUTE(__name, __field) \
80 static int __name ## _show(struct seq_file *f, void *ptr) \
82 struct hci_dev *hdev = f->private; \
85 seq_printf(f, "%s\n", hdev->__field ? : ""); \
86 hci_dev_unlock(hdev); \
91 DEFINE_SHOW_ATTRIBUTE(__name)
93 #define DEFINE_SHOW_ATTRIBUTE(__name) \
94 static int __name ## _open(struct inode *inode, struct file *file) \
96 return single_open(file, __name ## _show, inode->i_private); \
99 static const struct file_operations __name ## _fops = { \
100 .open = __name ## _open, \
102 .llseek = seq_lseek, \
103 .release = single_release, \
106 static int features_show(struct seq_file *f, void *ptr)
108 struct hci_dev *hdev = f->private;
112 for (p = 0; p < HCI_MAX_PAGES && p <= hdev->max_page; p++)
113 seq_printf(f, "%2u: %8ph\n", p, hdev->features[p]);
114 if (lmp_le_capable(hdev))
115 seq_printf(f, "LE: %8ph\n", hdev->le_features);
116 hci_dev_unlock(hdev);
121 DEFINE_SHOW_ATTRIBUTE(features);
123 static int device_id_show(struct seq_file *f, void *ptr)
125 struct hci_dev *hdev = f->private;
128 seq_printf(f, "%4.4x:%4.4x:%4.4x:%4.4x\n", hdev->devid_source,
129 hdev->devid_vendor, hdev->devid_product, hdev->devid_version);
130 hci_dev_unlock(hdev);
135 DEFINE_SHOW_ATTRIBUTE(device_id);
137 static int device_list_show(struct seq_file *f, void *ptr)
139 struct hci_dev *hdev = f->private;
140 struct hci_conn_params *p;
141 struct bdaddr_list *b;
144 list_for_each_entry(b, &hdev->whitelist, list)
145 seq_printf(f, "%pMR (type %u)\n", &b->bdaddr, b->bdaddr_type);
146 list_for_each_entry(p, &hdev->le_conn_params, list) {
147 seq_printf(f, "%pMR (type %u) %u\n", &p->addr, p->addr_type,
150 hci_dev_unlock(hdev);
155 DEFINE_SHOW_ATTRIBUTE(device_list);
157 static int blacklist_show(struct seq_file *f, void *p)
159 struct hci_dev *hdev = f->private;
160 struct bdaddr_list *b;
163 list_for_each_entry(b, &hdev->blacklist, list)
164 seq_printf(f, "%pMR (type %u)\n", &b->bdaddr, b->bdaddr_type);
165 hci_dev_unlock(hdev);
170 DEFINE_SHOW_ATTRIBUTE(blacklist);
172 static int uuids_show(struct seq_file *f, void *p)
174 struct hci_dev *hdev = f->private;
175 struct bt_uuid *uuid;
178 list_for_each_entry(uuid, &hdev->uuids, list) {
181 /* The Bluetooth UUID values are stored in big endian,
182 * but with reversed byte order. So convert them into
183 * the right order for the %pUb modifier.
185 for (i = 0; i < 16; i++)
186 val[i] = uuid->uuid[15 - i];
188 seq_printf(f, "%pUb\n", val);
190 hci_dev_unlock(hdev);
195 DEFINE_SHOW_ATTRIBUTE(uuids);
197 static int remote_oob_show(struct seq_file *f, void *ptr)
199 struct hci_dev *hdev = f->private;
200 struct oob_data *data;
203 list_for_each_entry(data, &hdev->remote_oob_data, list) {
204 seq_printf(f, "%pMR (type %u) %u %*phN %*phN %*phN %*phN\n",
205 &data->bdaddr, data->bdaddr_type, data->present,
206 16, data->hash192, 16, data->rand192,
207 16, data->hash256, 16, data->rand256);
209 hci_dev_unlock(hdev);
214 DEFINE_SHOW_ATTRIBUTE(remote_oob);
216 static int conn_info_min_age_set(void *data, u64 val)
218 struct hci_dev *hdev = data;
220 if (val == 0 || val > hdev->conn_info_max_age)
224 hdev->conn_info_min_age = val;
225 hci_dev_unlock(hdev);
230 static int conn_info_min_age_get(void *data, u64 *val)
232 struct hci_dev *hdev = data;
235 *val = hdev->conn_info_min_age;
236 hci_dev_unlock(hdev);
241 DEFINE_SIMPLE_ATTRIBUTE(conn_info_min_age_fops, conn_info_min_age_get,
242 conn_info_min_age_set, "%llu\n");
244 static int conn_info_max_age_set(void *data, u64 val)
246 struct hci_dev *hdev = data;
248 if (val == 0 || val < hdev->conn_info_min_age)
252 hdev->conn_info_max_age = val;
253 hci_dev_unlock(hdev);
258 static int conn_info_max_age_get(void *data, u64 *val)
260 struct hci_dev *hdev = data;
263 *val = hdev->conn_info_max_age;
264 hci_dev_unlock(hdev);
269 DEFINE_SIMPLE_ATTRIBUTE(conn_info_max_age_fops, conn_info_max_age_get,
270 conn_info_max_age_set, "%llu\n");
272 static ssize_t use_debug_keys_read(struct file *file, char __user *user_buf,
273 size_t count, loff_t *ppos)
275 struct hci_dev *hdev = file->private_data;
278 buf[0] = hci_dev_test_flag(hdev, HCI_USE_DEBUG_KEYS) ? 'Y': 'N';
281 return simple_read_from_buffer(user_buf, count, ppos, buf, 2);
284 static const struct file_operations use_debug_keys_fops = {
286 .read = use_debug_keys_read,
287 .llseek = default_llseek,
290 static ssize_t sc_only_mode_read(struct file *file, char __user *user_buf,
291 size_t count, loff_t *ppos)
293 struct hci_dev *hdev = file->private_data;
296 buf[0] = hci_dev_test_flag(hdev, HCI_SC_ONLY) ? 'Y': 'N';
299 return simple_read_from_buffer(user_buf, count, ppos, buf, 2);
302 static const struct file_operations sc_only_mode_fops = {
304 .read = sc_only_mode_read,
305 .llseek = default_llseek,
308 DEFINE_INFO_ATTRIBUTE(hardware_info, hw_info);
309 DEFINE_INFO_ATTRIBUTE(firmware_info, fw_info);
311 void hci_debugfs_create_common(struct hci_dev *hdev)
313 debugfs_create_file("features", 0444, hdev->debugfs, hdev,
315 debugfs_create_u16("manufacturer", 0444, hdev->debugfs,
316 &hdev->manufacturer);
317 debugfs_create_u8("hci_version", 0444, hdev->debugfs, &hdev->hci_ver);
318 debugfs_create_u16("hci_revision", 0444, hdev->debugfs, &hdev->hci_rev);
319 debugfs_create_u8("hardware_error", 0444, hdev->debugfs,
320 &hdev->hw_error_code);
321 debugfs_create_file("device_id", 0444, hdev->debugfs, hdev,
324 debugfs_create_file("device_list", 0444, hdev->debugfs, hdev,
326 debugfs_create_file("blacklist", 0444, hdev->debugfs, hdev,
328 debugfs_create_file("uuids", 0444, hdev->debugfs, hdev, &uuids_fops);
329 debugfs_create_file("remote_oob", 0400, hdev->debugfs, hdev,
332 debugfs_create_file("conn_info_min_age", 0644, hdev->debugfs, hdev,
333 &conn_info_min_age_fops);
334 debugfs_create_file("conn_info_max_age", 0644, hdev->debugfs, hdev,
335 &conn_info_max_age_fops);
337 if (lmp_ssp_capable(hdev) || lmp_le_capable(hdev))
338 debugfs_create_file("use_debug_keys", 0444, hdev->debugfs,
339 hdev, &use_debug_keys_fops);
341 if (lmp_sc_capable(hdev) || lmp_le_capable(hdev))
342 debugfs_create_file("sc_only_mode", 0444, hdev->debugfs,
343 hdev, &sc_only_mode_fops);
346 debugfs_create_file("hardware_info", 0444, hdev->debugfs,
347 hdev, &hardware_info_fops);
350 debugfs_create_file("firmware_info", 0444, hdev->debugfs,
351 hdev, &firmware_info_fops);
354 static int inquiry_cache_show(struct seq_file *f, void *p)
356 struct hci_dev *hdev = f->private;
357 struct discovery_state *cache = &hdev->discovery;
358 struct inquiry_entry *e;
362 list_for_each_entry(e, &cache->all, all) {
363 struct inquiry_data *data = &e->data;
364 seq_printf(f, "%pMR %d %d %d 0x%.2x%.2x%.2x 0x%.4x %d %d %u\n",
366 data->pscan_rep_mode, data->pscan_period_mode,
367 data->pscan_mode, data->dev_class[2],
368 data->dev_class[1], data->dev_class[0],
369 __le16_to_cpu(data->clock_offset),
370 data->rssi, data->ssp_mode, e->timestamp);
373 hci_dev_unlock(hdev);
378 DEFINE_SHOW_ATTRIBUTE(inquiry_cache);
380 static int link_keys_show(struct seq_file *f, void *ptr)
382 struct hci_dev *hdev = f->private;
383 struct link_key *key;
386 list_for_each_entry_rcu(key, &hdev->link_keys, list)
387 seq_printf(f, "%pMR %u %*phN %u\n", &key->bdaddr, key->type,
388 HCI_LINK_KEY_SIZE, key->val, key->pin_len);
394 DEFINE_SHOW_ATTRIBUTE(link_keys);
396 static int dev_class_show(struct seq_file *f, void *ptr)
398 struct hci_dev *hdev = f->private;
401 seq_printf(f, "0x%.2x%.2x%.2x\n", hdev->dev_class[2],
402 hdev->dev_class[1], hdev->dev_class[0]);
403 hci_dev_unlock(hdev);
408 DEFINE_SHOW_ATTRIBUTE(dev_class);
410 static int voice_setting_get(void *data, u64 *val)
412 struct hci_dev *hdev = data;
415 *val = hdev->voice_setting;
416 hci_dev_unlock(hdev);
421 DEFINE_SIMPLE_ATTRIBUTE(voice_setting_fops, voice_setting_get,
422 NULL, "0x%4.4llx\n");
424 static ssize_t ssp_debug_mode_read(struct file *file, char __user *user_buf,
425 size_t count, loff_t *ppos)
427 struct hci_dev *hdev = file->private_data;
430 buf[0] = hdev->ssp_debug_mode ? 'Y': 'N';
433 return simple_read_from_buffer(user_buf, count, ppos, buf, 2);
436 static const struct file_operations ssp_debug_mode_fops = {
438 .read = ssp_debug_mode_read,
439 .llseek = default_llseek,
442 static int auto_accept_delay_set(void *data, u64 val)
444 struct hci_dev *hdev = data;
447 hdev->auto_accept_delay = val;
448 hci_dev_unlock(hdev);
453 static int auto_accept_delay_get(void *data, u64 *val)
455 struct hci_dev *hdev = data;
458 *val = hdev->auto_accept_delay;
459 hci_dev_unlock(hdev);
464 DEFINE_SIMPLE_ATTRIBUTE(auto_accept_delay_fops, auto_accept_delay_get,
465 auto_accept_delay_set, "%llu\n");
467 static int idle_timeout_set(void *data, u64 val)
469 struct hci_dev *hdev = data;
471 if (val != 0 && (val < 500 || val > 3600000))
475 hdev->idle_timeout = val;
476 hci_dev_unlock(hdev);
481 static int idle_timeout_get(void *data, u64 *val)
483 struct hci_dev *hdev = data;
486 *val = hdev->idle_timeout;
487 hci_dev_unlock(hdev);
492 DEFINE_SIMPLE_ATTRIBUTE(idle_timeout_fops, idle_timeout_get,
493 idle_timeout_set, "%llu\n");
495 static int sniff_min_interval_set(void *data, u64 val)
497 struct hci_dev *hdev = data;
499 if (val == 0 || val % 2 || val > hdev->sniff_max_interval)
503 hdev->sniff_min_interval = val;
504 hci_dev_unlock(hdev);
509 static int sniff_min_interval_get(void *data, u64 *val)
511 struct hci_dev *hdev = data;
514 *val = hdev->sniff_min_interval;
515 hci_dev_unlock(hdev);
520 DEFINE_SIMPLE_ATTRIBUTE(sniff_min_interval_fops, sniff_min_interval_get,
521 sniff_min_interval_set, "%llu\n");
523 static int sniff_max_interval_set(void *data, u64 val)
525 struct hci_dev *hdev = data;
527 if (val == 0 || val % 2 || val < hdev->sniff_min_interval)
531 hdev->sniff_max_interval = val;
532 hci_dev_unlock(hdev);
537 static int sniff_max_interval_get(void *data, u64 *val)
539 struct hci_dev *hdev = data;
542 *val = hdev->sniff_max_interval;
543 hci_dev_unlock(hdev);
548 DEFINE_SIMPLE_ATTRIBUTE(sniff_max_interval_fops, sniff_max_interval_get,
549 sniff_max_interval_set, "%llu\n");
551 void hci_debugfs_create_bredr(struct hci_dev *hdev)
553 debugfs_create_file("inquiry_cache", 0444, hdev->debugfs, hdev,
554 &inquiry_cache_fops);
555 debugfs_create_file("link_keys", 0400, hdev->debugfs, hdev,
557 debugfs_create_file("dev_class", 0444, hdev->debugfs, hdev,
559 debugfs_create_file("voice_setting", 0444, hdev->debugfs, hdev,
560 &voice_setting_fops);
562 if (lmp_ssp_capable(hdev)) {
563 debugfs_create_file("ssp_debug_mode", 0444, hdev->debugfs,
564 hdev, &ssp_debug_mode_fops);
565 debugfs_create_file("auto_accept_delay", 0644, hdev->debugfs,
566 hdev, &auto_accept_delay_fops);
569 if (lmp_sniff_capable(hdev)) {
570 debugfs_create_file("idle_timeout", 0644, hdev->debugfs,
571 hdev, &idle_timeout_fops);
572 debugfs_create_file("sniff_min_interval", 0644, hdev->debugfs,
573 hdev, &sniff_min_interval_fops);
574 debugfs_create_file("sniff_max_interval", 0644, hdev->debugfs,
575 hdev, &sniff_max_interval_fops);
579 static int identity_show(struct seq_file *f, void *p)
581 struct hci_dev *hdev = f->private;
587 hci_copy_identity_address(hdev, &addr, &addr_type);
589 seq_printf(f, "%pMR (type %u) %*phN %pMR\n", &addr, addr_type,
590 16, hdev->irk, &hdev->rpa);
592 hci_dev_unlock(hdev);
597 DEFINE_SHOW_ATTRIBUTE(identity);
599 static int rpa_timeout_set(void *data, u64 val)
601 struct hci_dev *hdev = data;
603 /* Require the RPA timeout to be at least 30 seconds and at most
606 if (val < 30 || val > (60 * 60 * 24))
610 hdev->rpa_timeout = val;
611 hci_dev_unlock(hdev);
616 static int rpa_timeout_get(void *data, u64 *val)
618 struct hci_dev *hdev = data;
621 *val = hdev->rpa_timeout;
622 hci_dev_unlock(hdev);
627 DEFINE_SIMPLE_ATTRIBUTE(rpa_timeout_fops, rpa_timeout_get,
628 rpa_timeout_set, "%llu\n");
630 static int random_address_show(struct seq_file *f, void *p)
632 struct hci_dev *hdev = f->private;
635 seq_printf(f, "%pMR\n", &hdev->random_addr);
636 hci_dev_unlock(hdev);
641 DEFINE_SHOW_ATTRIBUTE(random_address);
643 static int static_address_show(struct seq_file *f, void *p)
645 struct hci_dev *hdev = f->private;
648 seq_printf(f, "%pMR\n", &hdev->static_addr);
649 hci_dev_unlock(hdev);
654 DEFINE_SHOW_ATTRIBUTE(static_address);
656 static ssize_t force_static_address_read(struct file *file,
657 char __user *user_buf,
658 size_t count, loff_t *ppos)
660 struct hci_dev *hdev = file->private_data;
663 buf[0] = hci_dev_test_flag(hdev, HCI_FORCE_STATIC_ADDR) ? 'Y': 'N';
666 return simple_read_from_buffer(user_buf, count, ppos, buf, 2);
669 static ssize_t force_static_address_write(struct file *file,
670 const char __user *user_buf,
671 size_t count, loff_t *ppos)
673 struct hci_dev *hdev = file->private_data;
675 size_t buf_size = min(count, (sizeof(buf)-1));
678 if (test_bit(HCI_UP, &hdev->flags))
681 if (copy_from_user(buf, user_buf, buf_size))
684 buf[buf_size] = '\0';
685 if (strtobool(buf, &enable))
688 if (enable == hci_dev_test_flag(hdev, HCI_FORCE_STATIC_ADDR))
691 hci_dev_change_flag(hdev, HCI_FORCE_STATIC_ADDR);
696 static const struct file_operations force_static_address_fops = {
698 .read = force_static_address_read,
699 .write = force_static_address_write,
700 .llseek = default_llseek,
703 static int white_list_show(struct seq_file *f, void *ptr)
705 struct hci_dev *hdev = f->private;
706 struct bdaddr_list *b;
709 list_for_each_entry(b, &hdev->le_white_list, list)
710 seq_printf(f, "%pMR (type %u)\n", &b->bdaddr, b->bdaddr_type);
711 hci_dev_unlock(hdev);
716 DEFINE_SHOW_ATTRIBUTE(white_list);
718 static int identity_resolving_keys_show(struct seq_file *f, void *ptr)
720 struct hci_dev *hdev = f->private;
724 list_for_each_entry_rcu(irk, &hdev->identity_resolving_keys, list) {
725 seq_printf(f, "%pMR (type %u) %*phN %pMR\n",
726 &irk->bdaddr, irk->addr_type,
727 16, irk->val, &irk->rpa);
734 DEFINE_SHOW_ATTRIBUTE(identity_resolving_keys);
736 static int long_term_keys_show(struct seq_file *f, void *ptr)
738 struct hci_dev *hdev = f->private;
742 list_for_each_entry_rcu(ltk, &hdev->long_term_keys, list)
743 seq_printf(f, "%pMR (type %u) %u 0x%02x %u %.4x %.16llx %*phN\n",
744 <k->bdaddr, ltk->bdaddr_type, ltk->authenticated,
745 ltk->type, ltk->enc_size, __le16_to_cpu(ltk->ediv),
746 __le64_to_cpu(ltk->rand), 16, ltk->val);
752 DEFINE_SHOW_ATTRIBUTE(long_term_keys);
754 static int conn_min_interval_set(void *data, u64 val)
756 struct hci_dev *hdev = data;
758 if (val < 0x0006 || val > 0x0c80 || val > hdev->le_conn_max_interval)
762 hdev->le_conn_min_interval = val;
763 hci_dev_unlock(hdev);
768 static int conn_min_interval_get(void *data, u64 *val)
770 struct hci_dev *hdev = data;
773 *val = hdev->le_conn_min_interval;
774 hci_dev_unlock(hdev);
779 DEFINE_SIMPLE_ATTRIBUTE(conn_min_interval_fops, conn_min_interval_get,
780 conn_min_interval_set, "%llu\n");
782 static int conn_max_interval_set(void *data, u64 val)
784 struct hci_dev *hdev = data;
786 if (val < 0x0006 || val > 0x0c80 || val < hdev->le_conn_min_interval)
790 hdev->le_conn_max_interval = val;
791 hci_dev_unlock(hdev);
796 static int conn_max_interval_get(void *data, u64 *val)
798 struct hci_dev *hdev = data;
801 *val = hdev->le_conn_max_interval;
802 hci_dev_unlock(hdev);
807 DEFINE_SIMPLE_ATTRIBUTE(conn_max_interval_fops, conn_max_interval_get,
808 conn_max_interval_set, "%llu\n");
810 static int conn_latency_set(void *data, u64 val)
812 struct hci_dev *hdev = data;
818 hdev->le_conn_latency = val;
819 hci_dev_unlock(hdev);
824 static int conn_latency_get(void *data, u64 *val)
826 struct hci_dev *hdev = data;
829 *val = hdev->le_conn_latency;
830 hci_dev_unlock(hdev);
835 DEFINE_SIMPLE_ATTRIBUTE(conn_latency_fops, conn_latency_get,
836 conn_latency_set, "%llu\n");
838 static int supervision_timeout_set(void *data, u64 val)
840 struct hci_dev *hdev = data;
842 if (val < 0x000a || val > 0x0c80)
846 hdev->le_supv_timeout = val;
847 hci_dev_unlock(hdev);
852 static int supervision_timeout_get(void *data, u64 *val)
854 struct hci_dev *hdev = data;
857 *val = hdev->le_supv_timeout;
858 hci_dev_unlock(hdev);
863 DEFINE_SIMPLE_ATTRIBUTE(supervision_timeout_fops, supervision_timeout_get,
864 supervision_timeout_set, "%llu\n");
866 static int adv_channel_map_set(void *data, u64 val)
868 struct hci_dev *hdev = data;
870 if (val < 0x01 || val > 0x07)
874 hdev->le_adv_channel_map = val;
875 hci_dev_unlock(hdev);
880 static int adv_channel_map_get(void *data, u64 *val)
882 struct hci_dev *hdev = data;
885 *val = hdev->le_adv_channel_map;
886 hci_dev_unlock(hdev);
891 DEFINE_SIMPLE_ATTRIBUTE(adv_channel_map_fops, adv_channel_map_get,
892 adv_channel_map_set, "%llu\n");
894 static int adv_min_interval_set(void *data, u64 val)
896 struct hci_dev *hdev = data;
898 if (val < 0x0020 || val > 0x4000 || val > hdev->le_adv_max_interval)
902 hdev->le_adv_min_interval = val;
903 hci_dev_unlock(hdev);
908 static int adv_min_interval_get(void *data, u64 *val)
910 struct hci_dev *hdev = data;
913 *val = hdev->le_adv_min_interval;
914 hci_dev_unlock(hdev);
919 DEFINE_SIMPLE_ATTRIBUTE(adv_min_interval_fops, adv_min_interval_get,
920 adv_min_interval_set, "%llu\n");
922 static int adv_max_interval_set(void *data, u64 val)
924 struct hci_dev *hdev = data;
926 if (val < 0x0020 || val > 0x4000 || val < hdev->le_adv_min_interval)
930 hdev->le_adv_max_interval = val;
931 hci_dev_unlock(hdev);
936 static int adv_max_interval_get(void *data, u64 *val)
938 struct hci_dev *hdev = data;
941 *val = hdev->le_adv_max_interval;
942 hci_dev_unlock(hdev);
947 DEFINE_SIMPLE_ATTRIBUTE(adv_max_interval_fops, adv_max_interval_get,
948 adv_max_interval_set, "%llu\n");
950 DEFINE_QUIRK_ATTRIBUTE(quirk_strict_duplicate_filter,
951 HCI_QUIRK_STRICT_DUPLICATE_FILTER);
952 DEFINE_QUIRK_ATTRIBUTE(quirk_simultaneous_discovery,
953 HCI_QUIRK_SIMULTANEOUS_DISCOVERY);
955 void hci_debugfs_create_le(struct hci_dev *hdev)
957 debugfs_create_file("identity", 0400, hdev->debugfs, hdev,
959 debugfs_create_file("rpa_timeout", 0644, hdev->debugfs, hdev,
961 debugfs_create_file("random_address", 0444, hdev->debugfs, hdev,
962 &random_address_fops);
963 debugfs_create_file("static_address", 0444, hdev->debugfs, hdev,
964 &static_address_fops);
966 /* For controllers with a public address, provide a debug
967 * option to force the usage of the configured static
968 * address. By default the public address is used.
970 if (bacmp(&hdev->bdaddr, BDADDR_ANY))
971 debugfs_create_file("force_static_address", 0644,
973 &force_static_address_fops);
975 debugfs_create_u8("white_list_size", 0444, hdev->debugfs,
976 &hdev->le_white_list_size);
977 debugfs_create_file("white_list", 0444, hdev->debugfs, hdev,
979 debugfs_create_file("identity_resolving_keys", 0400, hdev->debugfs,
980 hdev, &identity_resolving_keys_fops);
981 debugfs_create_file("long_term_keys", 0400, hdev->debugfs, hdev,
982 &long_term_keys_fops);
983 debugfs_create_file("conn_min_interval", 0644, hdev->debugfs, hdev,
984 &conn_min_interval_fops);
985 debugfs_create_file("conn_max_interval", 0644, hdev->debugfs, hdev,
986 &conn_max_interval_fops);
987 debugfs_create_file("conn_latency", 0644, hdev->debugfs, hdev,
989 debugfs_create_file("supervision_timeout", 0644, hdev->debugfs, hdev,
990 &supervision_timeout_fops);
991 debugfs_create_file("adv_channel_map", 0644, hdev->debugfs, hdev,
992 &adv_channel_map_fops);
993 debugfs_create_file("adv_min_interval", 0644, hdev->debugfs, hdev,
994 &adv_min_interval_fops);
995 debugfs_create_file("adv_max_interval", 0644, hdev->debugfs, hdev,
996 &adv_max_interval_fops);
997 debugfs_create_u16("discov_interleaved_timeout", 0644, hdev->debugfs,
998 &hdev->discov_interleaved_timeout);
1000 debugfs_create_file("quirk_strict_duplicate_filter", 0644,
1001 hdev->debugfs, hdev,
1002 &quirk_strict_duplicate_filter_fops);
1003 debugfs_create_file("quirk_simultaneous_discovery", 0644,
1004 hdev->debugfs, hdev,
1005 &quirk_simultaneous_discovery_fops);
1008 void hci_debugfs_create_conn(struct hci_conn *conn)
1010 struct hci_dev *hdev = conn->hdev;
1013 if (IS_ERR_OR_NULL(hdev->debugfs))
1016 snprintf(name, sizeof(name), "%u", conn->handle);
1017 conn->debugfs = debugfs_create_dir(name, hdev->debugfs);