aboutsummaryrefslogtreecommitdiffstats
path: root/net/6lowpan
diff options
context:
space:
mode:
authorAlexander Aring <alex.aring@gmail.com>2015-12-09 16:46:30 -0500
committerMarcel Holtmann <marcel@holtmann.org>2015-12-09 19:25:25 -0500
commitb1815fd949e5bd06d118019acf68f87c9414f705 (patch)
tree5c3964d3a3020cbc75a1184834af8a0cda56a90e /net/6lowpan
parent00f59314111a6b18ee65b238b38c470dbdbf3be5 (diff)
6lowpan: add debugfs support
This patch will introduce a 6lowpan entry into the debugfs if enabled. Inside this 6lowpan directory we create a subdirectories of all 6lowpan interfaces to offer a per interface debugfs support. Reviewed-by: Stefan Schmidt <stefan@osg.samsung.com> Signed-off-by: Alexander Aring <alex.aring@gmail.com> Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
Diffstat (limited to 'net/6lowpan')
-rw-r--r--net/6lowpan/6lowpan_i.h28
-rw-r--r--net/6lowpan/Kconfig8
-rw-r--r--net/6lowpan/Makefile1
-rw-r--r--net/6lowpan/core.c28
-rw-r--r--net/6lowpan/debugfs.c53
5 files changed, 117 insertions, 1 deletions
diff --git a/net/6lowpan/6lowpan_i.h b/net/6lowpan/6lowpan_i.h
new file mode 100644
index 000000000000..d16bb4b14aa1
--- /dev/null
+++ b/net/6lowpan/6lowpan_i.h
@@ -0,0 +1,28 @@
1#ifndef __6LOWPAN_I_H
2#define __6LOWPAN_I_H
3
4#include <linux/netdevice.h>
5
6#ifdef CONFIG_6LOWPAN_DEBUGFS
7int lowpan_dev_debugfs_init(struct net_device *dev);
8void lowpan_dev_debugfs_exit(struct net_device *dev);
9
10int __init lowpan_debugfs_init(void);
11void lowpan_debugfs_exit(void);
12#else
13static inline int lowpan_dev_debugfs_init(struct net_device *dev)
14{
15 return 0;
16}
17
18static inline void lowpan_dev_debugfs_exit(struct net_device *dev) { }
19
20static inline int __init lowpan_debugfs_init(void)
21{
22 return 0;
23}
24
25static inline void lowpan_debugfs_exit(void) { }
26#endif /* CONFIG_6LOWPAN_DEBUGFS */
27
28#endif /* __6LOWPAN_I_H */
diff --git a/net/6lowpan/Kconfig b/net/6lowpan/Kconfig
index bcb9d8a21fc0..9c051512d14f 100644
--- a/net/6lowpan/Kconfig
+++ b/net/6lowpan/Kconfig
@@ -5,6 +5,14 @@ menuconfig 6LOWPAN
5 This enables IPv6 over Low power Wireless Personal Area Network - 5 This enables IPv6 over Low power Wireless Personal Area Network -
6 "6LoWPAN" which is supported by IEEE 802.15.4 or Bluetooth stacks. 6 "6LoWPAN" which is supported by IEEE 802.15.4 or Bluetooth stacks.
7 7
8config 6LOWPAN_DEBUGFS
9 bool "6LoWPAN debugfs support"
10 depends on 6LOWPAN
11 depends on DEBUG_FS
12 ---help---
13 This enables 6LoWPAN debugfs support. For example to manipulate
14 IPHC context information at runtime.
15
8menuconfig 6LOWPAN_NHC 16menuconfig 6LOWPAN_NHC
9 tristate "Next Header and Generic Header Compression Support" 17 tristate "Next Header and Generic Header Compression Support"
10 depends on 6LOWPAN 18 depends on 6LOWPAN
diff --git a/net/6lowpan/Makefile b/net/6lowpan/Makefile
index 9e35a5d7b92d..e44f3bf2dd42 100644
--- a/net/6lowpan/Makefile
+++ b/net/6lowpan/Makefile
@@ -1,6 +1,7 @@
1obj-$(CONFIG_6LOWPAN) += 6lowpan.o 1obj-$(CONFIG_6LOWPAN) += 6lowpan.o
2 2
36lowpan-y := core.o iphc.o nhc.o 36lowpan-y := core.o iphc.o nhc.o
46lowpan-$(CONFIG_6LOWPAN_DEBUGFS) += debugfs.o
4 5
5#rfc6282 nhcs 6#rfc6282 nhcs
6obj-$(CONFIG_6LOWPAN_NHC_DEST) += nhc_dest.o 7obj-$(CONFIG_6LOWPAN_NHC_DEST) += nhc_dest.o
diff --git a/net/6lowpan/core.c b/net/6lowpan/core.c
index 80fc50987cf3..c7f06f5c0121 100644
--- a/net/6lowpan/core.c
+++ b/net/6lowpan/core.c
@@ -15,9 +15,13 @@
15 15
16#include <net/6lowpan.h> 16#include <net/6lowpan.h>
17 17
18#include "6lowpan_i.h"
19
18int lowpan_register_netdevice(struct net_device *dev, 20int lowpan_register_netdevice(struct net_device *dev,
19 enum lowpan_lltypes lltype) 21 enum lowpan_lltypes lltype)
20{ 22{
23 int ret;
24
21 dev->addr_len = EUI64_ADDR_LEN; 25 dev->addr_len = EUI64_ADDR_LEN;
22 dev->type = ARPHRD_6LOWPAN; 26 dev->type = ARPHRD_6LOWPAN;
23 dev->mtu = IPV6_MIN_MTU; 27 dev->mtu = IPV6_MIN_MTU;
@@ -25,7 +29,15 @@ int lowpan_register_netdevice(struct net_device *dev,
25 29
26 lowpan_priv(dev)->lltype = lltype; 30 lowpan_priv(dev)->lltype = lltype;
27 31
28 return register_netdevice(dev); 32 ret = lowpan_dev_debugfs_init(dev);
33 if (ret < 0)
34 return ret;
35
36 ret = register_netdevice(dev);
37 if (ret < 0)
38 lowpan_dev_debugfs_exit(dev);
39
40 return ret;
29} 41}
30EXPORT_SYMBOL(lowpan_register_netdevice); 42EXPORT_SYMBOL(lowpan_register_netdevice);
31 43
@@ -44,6 +56,7 @@ EXPORT_SYMBOL(lowpan_register_netdev);
44void lowpan_unregister_netdevice(struct net_device *dev) 56void lowpan_unregister_netdevice(struct net_device *dev)
45{ 57{
46 unregister_netdevice(dev); 58 unregister_netdevice(dev);
59 lowpan_dev_debugfs_exit(dev);
47} 60}
48EXPORT_SYMBOL(lowpan_unregister_netdevice); 61EXPORT_SYMBOL(lowpan_unregister_netdevice);
49 62
@@ -57,6 +70,12 @@ EXPORT_SYMBOL(lowpan_unregister_netdev);
57 70
58static int __init lowpan_module_init(void) 71static int __init lowpan_module_init(void)
59{ 72{
73 int ret;
74
75 ret = lowpan_debugfs_init();
76 if (ret < 0)
77 return ret;
78
60 request_module_nowait("ipv6"); 79 request_module_nowait("ipv6");
61 80
62 request_module_nowait("nhc_dest"); 81 request_module_nowait("nhc_dest");
@@ -69,6 +88,13 @@ static int __init lowpan_module_init(void)
69 88
70 return 0; 89 return 0;
71} 90}
91
92static void __exit lowpan_module_exit(void)
93{
94 lowpan_debugfs_exit();
95}
96
72module_init(lowpan_module_init); 97module_init(lowpan_module_init);
98module_exit(lowpan_module_exit);
73 99
74MODULE_LICENSE("GPL"); 100MODULE_LICENSE("GPL");
diff --git a/net/6lowpan/debugfs.c b/net/6lowpan/debugfs.c
new file mode 100644
index 000000000000..88eef84df0fc
--- /dev/null
+++ b/net/6lowpan/debugfs.c
@@ -0,0 +1,53 @@
1/* This program is free software; you can redistribute it and/or modify
2 * it under the terms of the GNU General Public License version 2
3 * as published by the Free Software Foundation.
4 *
5 * This program is distributed in the hope that it will be useful,
6 * but WITHOUT ANY WARRANTY; without even the implied warranty of
7 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
8 * GNU General Public License for more details.
9 *
10 * Authors:
11 * (C) 2015 Pengutronix, Alexander Aring <aar@pengutronix.de>
12 * Copyright (c) 2015 Nordic Semiconductor. All Rights Reserved.
13 */
14
15#include <net/6lowpan.h>
16
17#include "6lowpan_i.h"
18
19static struct dentry *lowpan_debugfs;
20
21int lowpan_dev_debugfs_init(struct net_device *dev)
22{
23 struct lowpan_priv *lpriv = lowpan_priv(dev);
24
25 /* creating the root */
26 lpriv->iface_debugfs = debugfs_create_dir(dev->name, lowpan_debugfs);
27 if (!lpriv->iface_debugfs)
28 goto fail;
29
30 return 0;
31
32fail:
33 return -EINVAL;
34}
35
36void lowpan_dev_debugfs_exit(struct net_device *dev)
37{
38 debugfs_remove_recursive(lowpan_priv(dev)->iface_debugfs);
39}
40
41int __init lowpan_debugfs_init(void)
42{
43 lowpan_debugfs = debugfs_create_dir("6lowpan", NULL);
44 if (!lowpan_debugfs)
45 return -EINVAL;
46
47 return 0;
48}
49
50void lowpan_debugfs_exit(void)
51{
52 debugfs_remove_recursive(lowpan_debugfs);
53}