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 conn_info_min_age_set(void *data, u64 val)
161 struct hci_dev *hdev = data;
163 if (val == 0 || val > hdev->conn_info_max_age)
167 hdev->conn_info_min_age = val;
168 hci_dev_unlock(hdev);
173 static int conn_info_min_age_get(void *data, u64 *val)
175 struct hci_dev *hdev = data;
178 *val = hdev->conn_info_min_age;
179 hci_dev_unlock(hdev);
184 DEFINE_SIMPLE_ATTRIBUTE(conn_info_min_age_fops, conn_info_min_age_get,
185 conn_info_min_age_set, "%llu\n");
187 static int conn_info_max_age_set(void *data, u64 val)
189 struct hci_dev *hdev = data;
191 if (val == 0 || val < hdev->conn_info_min_age)
195 hdev->conn_info_max_age = val;
196 hci_dev_unlock(hdev);
201 static int conn_info_max_age_get(void *data, u64 *val)
203 struct hci_dev *hdev = data;
206 *val = hdev->conn_info_max_age;
207 hci_dev_unlock(hdev);
212 DEFINE_SIMPLE_ATTRIBUTE(conn_info_max_age_fops, conn_info_max_age_get,
213 conn_info_max_age_set, "%llu\n");
215 void hci_debugfs_create_common(struct hci_dev *hdev)
217 debugfs_create_file("features", 0444, hdev->debugfs, hdev,
219 debugfs_create_u16("manufacturer", 0444, hdev->debugfs,
220 &hdev->manufacturer);
221 debugfs_create_u8("hci_version", 0444, hdev->debugfs, &hdev->hci_ver);
222 debugfs_create_u16("hci_revision", 0444, hdev->debugfs, &hdev->hci_rev);
223 debugfs_create_file("device_list", 0444, hdev->debugfs, hdev,
225 debugfs_create_file("blacklist", 0444, hdev->debugfs, hdev,
227 debugfs_create_file("uuids", 0444, hdev->debugfs, hdev, &uuids_fops);
229 debugfs_create_file("conn_info_min_age", 0644, hdev->debugfs, hdev,
230 &conn_info_min_age_fops);
231 debugfs_create_file("conn_info_max_age", 0644, hdev->debugfs, hdev,
232 &conn_info_max_age_fops);
235 void hci_debugfs_create_bredr(struct hci_dev *hdev)
239 void hci_debugfs_create_le(struct hci_dev *hdev)