All of lore.kernel.org
 help / color / mirror / Atom feed
* [RFC v2 2/4] Bluetooth: Expose hci connections through debugfs
@ 2011-09-02 23:51 Peter Hurley
  2011-09-13 19:55 ` Gustavo Padovan
  0 siblings, 1 reply; 2+ messages in thread
From: Peter Hurley @ 2011-09-02 23:51 UTC (permalink / raw)
  To: linux-bluetooth

Add "connections" file to "hciX" debugfs directory and output
hci_conn internal state.

Example file contents:
                          s            a     p
                  h   t   t  o  s  k   u  s  s  p  r
                  n   y   a  u  s  e   t  e  e  i  e
Dest              l   p   t  t  p  y   h  c  c  n  f
BC:0D:A5:7A:F5:96 14  ACL 1  1  1 0xff 0  1  0  0  1
00:0D:FD:1E:99:30 13  ACL 1  0  0 0xff 4  2  2  0  1
00:07:61:B2:3E:97 12  ACL 1  0  0 0xff 4  0  0  0  2
00:07:61:76:D8:1B 11  ACL 1  0  0 0xff 4  1  0  0  2

Signed-off-by: Peter Hurley <peter@hurleysoftware.com>
---

v2: Add example output to commit msg

 net/bluetooth/hci_sysfs.c |   46 +++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 46 insertions(+), 0 deletions(-)

diff --git a/net/bluetooth/hci_sysfs.c b/net/bluetooth/hci_sysfs.c
index 22f1a6c..3d00769 100644
--- a/net/bluetooth/hci_sysfs.c
+++ b/net/bluetooth/hci_sysfs.c
@@ -542,6 +542,49 @@ static int auto_accept_delay_get(void *data, u64 *val)
 DEFINE_SIMPLE_ATTRIBUTE(auto_accept_delay_fops, auto_accept_delay_get,
 					auto_accept_delay_set, "%llu\n");
 
+static int connections_show(struct seq_file *f, void *p)
+{
+	struct hci_dev *hdev = f->private;
+	struct hci_conn_hash *h = &hdev->conn_hash;
+	struct list_head *l;
+	
+	hci_dev_lock_bh(hdev);
+
+	seq_printf(f, "                          s            a     p\n");
+	seq_printf(f, "                  h   t   t  o  s  k   u  s  s  p  r\n");
+	seq_printf(f, "                  n   y   a  u  s  e   t  e  e  i  e\n");
+	seq_printf(f, "Dest              l   p   t  t  p  y   h  c  c  n  f\n");
+
+	list_for_each(l, &h->list) {
+		struct hci_conn *c;
+		c = list_entry(l, struct hci_conn, list);
+
+		seq_printf(f, "%s %-3d %3s %d  %d  %d 0x%.2x %d  %d  %d %2d  %d\n",
+				batostr(&c->dst), c->handle, 
+				link_typetostr(c->type),
+				c->state, c->out, c->ssp_mode,
+				c->key_type, c->auth_type, c->sec_level,
+				c->pending_sec_level, c->pin_length,
+				atomic_read(&c->devref));
+	}
+
+	hci_dev_unlock_bh(hdev);
+
+	return 0;
+}
+
+static int connections_open(struct inode *inode, struct file *file)
+{
+	return single_open(file, connections_show, inode->i_private);
+}
+
+static const struct file_operations connections_fops = {
+	.open		= connections_open,
+	.read		= seq_read,
+	.llseek		= seq_lseek,
+	.release	= single_release,
+};
+
 int hci_register_sysfs(struct hci_dev *hdev)
 {
 	struct device *dev = &hdev->dev;
@@ -578,6 +621,9 @@ int hci_register_sysfs(struct hci_dev *hdev)
 
 	debugfs_create_file("auto_accept_delay", 0444, hdev->debugfs, hdev,
 						&auto_accept_delay_fops);
+
+	debugfs_create_file("connections", 0444, hdev->debugfs, hdev,
+						&connections_fops);
 	return 0;
 }
 
-- 
1.7.4.1


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [RFC v2 2/4] Bluetooth: Expose hci connections through debugfs
  2011-09-02 23:51 [RFC v2 2/4] Bluetooth: Expose hci connections through debugfs Peter Hurley
@ 2011-09-13 19:55 ` Gustavo Padovan
  0 siblings, 0 replies; 2+ messages in thread
From: Gustavo Padovan @ 2011-09-13 19:55 UTC (permalink / raw)
  To: Peter Hurley; +Cc: linux-bluetooth

Hi Peter,

* Peter Hurley <peter@hurleysoftware.com> [2011-09-02 19:51:40 -0400]:

> Add "connections" file to "hciX" debugfs directory and output
> hci_conn internal state.
> 
> Example file contents:
>                           s            a     p
>                   h   t   t  o  s  k   u  s  s  p  r
>                   n   y   a  u  s  e   t  e  e  i  e
> Dest              l   p   t  t  p  y   h  c  c  n  f

I prefer if you do like this:

Dest		    handle type stat out ssp ...

everything on the same line.

> BC:0D:A5:7A:F5:96 14  ACL 1  1  1 0xff 0  1  0  0  1
> 00:0D:FD:1E:99:30 13  ACL 1  0  0 0xff 4  2  2  0  1
> 00:07:61:B2:3E:97 12  ACL 1  0  0 0xff 4  0  0  0  2
> 00:07:61:76:D8:1B 11  ACL 1  0  0 0xff 4  1  0  0  2
> 
> Signed-off-by: Peter Hurley <peter@hurleysoftware.com>
> ---
> 
> v2: Add example output to commit msg
> 
>  net/bluetooth/hci_sysfs.c |   46 +++++++++++++++++++++++++++++++++++++++++++++
>  1 files changed, 46 insertions(+), 0 deletions(-)
> 
> diff --git a/net/bluetooth/hci_sysfs.c b/net/bluetooth/hci_sysfs.c
> index 22f1a6c..3d00769 100644
> --- a/net/bluetooth/hci_sysfs.c
> +++ b/net/bluetooth/hci_sysfs.c
> @@ -542,6 +542,49 @@ static int auto_accept_delay_get(void *data, u64 *val)
>  DEFINE_SIMPLE_ATTRIBUTE(auto_accept_delay_fops, auto_accept_delay_get,
>  					auto_accept_delay_set, "%llu\n");
>  
> +static int connections_show(struct seq_file *f, void *p)
> +{
> +	struct hci_dev *hdev = f->private;
> +	struct hci_conn_hash *h = &hdev->conn_hash;
> +	struct list_head *l;
> +	
> +	hci_dev_lock_bh(hdev);
> +
> +	seq_printf(f, "                          s            a     p\n");
> +	seq_printf(f, "                  h   t   t  o  s  k   u  s  s  p  r\n");
> +	seq_printf(f, "                  n   y   a  u  s  e   t  e  e  i  e\n");
> +	seq_printf(f, "Dest              l   p   t  t  p  y   h  c  c  n  f\n");
> +
> +	list_for_each(l, &h->list) {
> +		struct hci_conn *c;
> +		c = list_entry(l, struct hci_conn, list);
> +
> +		seq_printf(f, "%s %-3d %3s %d  %d  %d 0x%.2x %d  %d  %d %2d  %d\n",
> +				batostr(&c->dst), c->handle, 
> +				link_typetostr(c->type),
> +				c->state, c->out, c->ssp_mode,
> +				c->key_type, c->auth_type, c->sec_level,
> +				c->pending_sec_level, c->pin_length,
> +				atomic_read(&c->devref));
> +	}
> +
> +	hci_dev_unlock_bh(hdev);
> +
> +	return 0;
> +}
> +
> +static int connections_open(struct inode *inode, struct file *file)
> +{
> +	return single_open(file, connections_show, inode->i_private);
> +}
> +
> +static const struct file_operations connections_fops = {
> +	.open		= connections_open,
> +	.read		= seq_read,
> +	.llseek		= seq_lseek,
> +	.release	= single_release,
> +};
> +
>  int hci_register_sysfs(struct hci_dev *hdev)
>  {
>  	struct device *dev = &hdev->dev;
> @@ -578,6 +621,9 @@ int hci_register_sysfs(struct hci_dev *hdev)
>  
>  	debugfs_create_file("auto_accept_delay", 0444, hdev->debugfs, hdev,
>  						&auto_accept_delay_fops);
> +
> +	debugfs_create_file("connections", 0444, hdev->debugfs, hdev,
> +						&connections_fops);
>  	return 0;
>  }

otherwise looks good.

	Gustavo

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2011-09-13 19:55 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-09-02 23:51 [RFC v2 2/4] Bluetooth: Expose hci connections through debugfs Peter Hurley
2011-09-13 19:55 ` Gustavo Padovan

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.