aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/wireless/brcm80211
diff options
context:
space:
mode:
authorPiotr Haber <phaber@broadcom.com>2012-11-28 15:44:08 -0500
committerJohn W. Linville <linville@tuxdriver.com>2012-11-30 13:38:17 -0500
commit8e21df23894e12937fb3b51197bf5d0c4d7cc8ba (patch)
treedb931d33e29c6149050f630d00f268a6f865a863 /drivers/net/wireless/brcm80211
parent57fe504817ccec9b6ac23e973d2925343bf1e3b6 (diff)
brcmsmac: hardware info in debugfs
Put basic information about hardware in debugfs. Reviewed-by: Pieter-Paul Giesberts <pieterpg@broadcom.com> Reviewed-by: Hante Meuleman <meuleman@broadcom.com> Reviewed-by: Arend van Spriel <arend@broadcom.com> Signed-off-by: Piotr Haber <phaber@broadcom.com> Signed-off-by: Arend van Spriel <arend@broadcom.com> Acked-by: Seth Forshee <seth.forshee@canonical.com> Signed-off-by: John W. Linville <linville@tuxdriver.com>
Diffstat (limited to 'drivers/net/wireless/brcm80211')
-rw-r--r--drivers/net/wireless/brcm80211/brcmsmac/debug.c113
-rw-r--r--drivers/net/wireless/brcm80211/brcmsmac/debug.h23
-rw-r--r--drivers/net/wireless/brcm80211/brcmsmac/mac80211_if.c8
-rw-r--r--drivers/net/wireless/brcm80211/brcmsmac/pub.h1
4 files changed, 144 insertions, 1 deletions
diff --git a/drivers/net/wireless/brcm80211/brcmsmac/debug.c b/drivers/net/wireless/brcm80211/brcmsmac/debug.c
index 6ba4136c7cf6..be84791857cb 100644
--- a/drivers/net/wireless/brcm80211/brcmsmac/debug.c
+++ b/drivers/net/wireless/brcm80211/brcmsmac/debug.c
@@ -1,8 +1,121 @@
1/*
2 * Copyright (c) 2012 Broadcom Corporation
3 * Copyright (c) 2012 Canonical Ltd.
4 *
5 * Permission to use, copy, modify, and/or distribute this software for any
6 * purpose with or without fee is hereby granted, provided that the above
7 * copyright notice and this permission notice appear in all copies.
8 *
9 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
12 * SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
14 * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
15 * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16 */
17#include <linux/debugfs.h>
18#include <linux/if_ether.h>
19#include <linux/if.h>
1#include <linux/net.h> 20#include <linux/net.h>
21#include <linux/netdevice.h>
22#include <linux/ieee80211.h>
23#include <linux/module.h>
24#include <linux/netdevice.h>
25#include <net/mac80211.h>
26
27#include <defs.h>
28#include <brcmu_wifi.h>
29#include <brcmu_utils.h>
2#include "types.h" 30#include "types.h"
31#include "main.h"
3#include "debug.h" 32#include "debug.h"
4#include "brcms_trace_events.h" 33#include "brcms_trace_events.h"
5 34
35static struct dentry *root_folder;
36
37void brcms_debugfs_init(void)
38{
39 root_folder = debugfs_create_dir(KBUILD_MODNAME, NULL);
40 if (IS_ERR(root_folder))
41 root_folder = NULL;
42}
43
44void brcms_debugfs_exit(void)
45{
46 if (!root_folder)
47 return;
48
49 debugfs_remove_recursive(root_folder);
50 root_folder = NULL;
51}
52
53int brcms_debugfs_attach(struct brcms_pub *drvr)
54{
55 if (!root_folder)
56 return -ENODEV;
57
58 drvr->dbgfs_dir = debugfs_create_dir(
59 dev_name(&drvr->wlc->hw->d11core->dev), root_folder);
60 return PTR_RET(drvr->dbgfs_dir);
61}
62
63void brcms_debugfs_detach(struct brcms_pub *drvr)
64{
65 if (!IS_ERR_OR_NULL(drvr->dbgfs_dir))
66 debugfs_remove_recursive(drvr->dbgfs_dir);
67}
68
69struct dentry *brcms_debugfs_get_devdir(struct brcms_pub *drvr)
70{
71 return drvr->dbgfs_dir;
72}
73
74static
75ssize_t brcms_debugfs_hardware_read(struct file *f, char __user *data,
76 size_t count, loff_t *ppos)
77{
78 char buf[128];
79 int res;
80 struct brcms_pub *drvr = f->private_data;
81
82 /* only allow read from start */
83 if (*ppos > 0)
84 return 0;
85
86 res = scnprintf(buf, sizeof(buf),
87 "board vendor: %x\n"
88 "board type: %x\n"
89 "board revision: %x\n"
90 "board flags: %x\n"
91 "board flags2: %x\n"
92 "firmware revision: %x\n",
93 drvr->wlc->hw->d11core->bus->boardinfo.vendor,
94 drvr->wlc->hw->d11core->bus->boardinfo.type,
95 drvr->wlc->hw->boardrev,
96 drvr->wlc->hw->boardflags,
97 drvr->wlc->hw->boardflags2,
98 drvr->wlc->ucode_rev
99 );
100
101 return simple_read_from_buffer(data, count, ppos, buf, res);
102}
103
104static const struct file_operations brcms_debugfs_hardware_ops = {
105 .owner = THIS_MODULE,
106 .open = simple_open,
107 .read = brcms_debugfs_hardware_read
108};
109
110void brcms_debugfs_create_files(struct brcms_pub *drvr)
111{
112 struct dentry *dentry = drvr->dbgfs_dir;
113
114 if (!IS_ERR_OR_NULL(dentry))
115 debugfs_create_file("hardware", S_IRUGO, dentry,
116 drvr, &brcms_debugfs_hardware_ops);
117}
118
6#define __brcms_fn(fn) \ 119#define __brcms_fn(fn) \
7void __brcms_ ##fn(struct device *dev, const char *fmt, ...) \ 120void __brcms_ ##fn(struct device *dev, const char *fmt, ...) \
8{ \ 121{ \
diff --git a/drivers/net/wireless/brcm80211/brcmsmac/debug.h b/drivers/net/wireless/brcm80211/brcmsmac/debug.h
index f77066bda9d2..796836b0f469 100644
--- a/drivers/net/wireless/brcm80211/brcmsmac/debug.h
+++ b/drivers/net/wireless/brcm80211/brcmsmac/debug.h
@@ -1,3 +1,18 @@
1/*
2 * Copyright (c) 2012 Broadcom Corporation
3 *
4 * Permission to use, copy, modify, and/or distribute this software for any
5 * purpose with or without fee is hereby granted, provided that the above
6 * copyright notice and this permission notice appear in all copies.
7 *
8 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
9 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
10 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
11 * SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
12 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
13 * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
14 * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
15 */
1#ifndef _BRCMS_DEBUG_H_ 16#ifndef _BRCMS_DEBUG_H_
2#define _BRCMS_DEBUG_H_ 17#define _BRCMS_DEBUG_H_
3 18
@@ -49,4 +64,12 @@ void __brcms_dbg(struct device *dev, u32 level, const char *func,
49#define brcms_dbg_dma(core, f, a...) brcms_dbg(core, BRCM_DL_DMA, f, ##a) 64#define brcms_dbg_dma(core, f, a...) brcms_dbg(core, BRCM_DL_DMA, f, ##a)
50#define brcms_dbg_ht(core, f, a...) brcms_dbg(core, BRCM_DL_HT, f, ##a) 65#define brcms_dbg_ht(core, f, a...) brcms_dbg(core, BRCM_DL_HT, f, ##a)
51 66
67struct brcms_pub;
68void brcms_debugfs_init(void);
69void brcms_debugfs_exit(void);
70int brcms_debugfs_attach(struct brcms_pub *drvr);
71void brcms_debugfs_detach(struct brcms_pub *drvr);
72struct dentry *brcms_debugfs_get_devdir(struct brcms_pub *drvr);
73void brcms_debugfs_create_files(struct brcms_pub *drvr);
74
52#endif /* _BRCMS_DEBUG_H_ */ 75#endif /* _BRCMS_DEBUG_H_ */
diff --git a/drivers/net/wireless/brcm80211/brcmsmac/mac80211_if.c b/drivers/net/wireless/brcm80211/brcmsmac/mac80211_if.c
index 976720ccf17a..85dbaf8ac997 100644
--- a/drivers/net/wireless/brcm80211/brcmsmac/mac80211_if.c
+++ b/drivers/net/wireless/brcm80211/brcmsmac/mac80211_if.c
@@ -846,8 +846,10 @@ static void brcms_free(struct brcms_info *wl)
846 /* kill dpc */ 846 /* kill dpc */
847 tasklet_kill(&wl->tasklet); 847 tasklet_kill(&wl->tasklet);
848 848
849 if (wl->pub) 849 if (wl->pub) {
850 brcms_debugfs_detach(wl->pub);
850 brcms_c_module_unregister(wl->pub, "linux", wl); 851 brcms_c_module_unregister(wl->pub, "linux", wl);
852 }
851 853
852 /* free common resources */ 854 /* free common resources */
853 if (wl->wlc) { 855 if (wl->wlc) {
@@ -1077,6 +1079,8 @@ static struct brcms_info *brcms_attach(struct bcma_device *pdev)
1077 regulatory_hint(wl->wiphy, wl->pub->srom_ccode)) 1079 regulatory_hint(wl->wiphy, wl->pub->srom_ccode))
1078 wiphy_err(wl->wiphy, "%s: regulatory hint failed\n", __func__); 1080 wiphy_err(wl->wiphy, "%s: regulatory hint failed\n", __func__);
1079 1081
1082 brcms_debugfs_attach(wl->pub);
1083 brcms_debugfs_create_files(wl->pub);
1080 n_adapters_found++; 1084 n_adapters_found++;
1081 return wl; 1085 return wl;
1082 1086
@@ -1185,6 +1189,7 @@ static DECLARE_WORK(brcms_driver_work, brcms_driver_init);
1185 1189
1186static int __init brcms_module_init(void) 1190static int __init brcms_module_init(void)
1187{ 1191{
1192 brcms_debugfs_init();
1188 if (!schedule_work(&brcms_driver_work)) 1193 if (!schedule_work(&brcms_driver_work))
1189 return -EBUSY; 1194 return -EBUSY;
1190 1195
@@ -1202,6 +1207,7 @@ static void __exit brcms_module_exit(void)
1202{ 1207{
1203 cancel_work_sync(&brcms_driver_work); 1208 cancel_work_sync(&brcms_driver_work);
1204 bcma_driver_unregister(&brcms_bcma_driver); 1209 bcma_driver_unregister(&brcms_bcma_driver);
1210 brcms_debugfs_exit();
1205} 1211}
1206 1212
1207module_init(brcms_module_init); 1213module_init(brcms_module_init);
diff --git a/drivers/net/wireless/brcm80211/brcmsmac/pub.h b/drivers/net/wireless/brcm80211/brcmsmac/pub.h
index 2aafe740ebd8..4fb2834f4e64 100644
--- a/drivers/net/wireless/brcm80211/brcmsmac/pub.h
+++ b/drivers/net/wireless/brcm80211/brcmsmac/pub.h
@@ -176,6 +176,7 @@ struct brcms_pub {
176 bool phy_11ncapable; /* the PHY/HW is capable of 802.11N */ 176 bool phy_11ncapable; /* the PHY/HW is capable of 802.11N */
177 177
178 struct wl_cnt *_cnt; /* low-level counters in driver */ 178 struct wl_cnt *_cnt; /* low-level counters in driver */
179 struct dentry *dbgfs_dir;
179}; 180};
180 181
181enum wlc_par_id { 182enum wlc_par_id {