]> Pileus Git - ~andy/linux/blob - drivers/net/wireless/brcm80211/brcmfmac/dhd_dbg.c
brcmfmac: remove WL_TRACE() macro
[~andy/linux] / drivers / net / wireless / brcm80211 / brcmfmac / dhd_dbg.c
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  */
16 #include <linux/debugfs.h>
17 #include <linux/netdevice.h>
18 #include <linux/module.h>
19
20 #include <brcmu_wifi.h>
21 #include <brcmu_utils.h>
22 #include "dhd.h"
23 #include "dhd_bus.h"
24 #include "dhd_dbg.h"
25
26 static struct dentry *root_folder;
27
28 void brcmf_debugfs_init(void)
29 {
30         root_folder = debugfs_create_dir(KBUILD_MODNAME, NULL);
31         if (IS_ERR(root_folder))
32                 root_folder = NULL;
33 }
34
35 void brcmf_debugfs_exit(void)
36 {
37         if (!root_folder)
38                 return;
39
40         debugfs_remove_recursive(root_folder);
41         root_folder = NULL;
42 }
43
44 int brcmf_debugfs_attach(struct brcmf_pub *drvr)
45 {
46         struct device *dev = drvr->bus_if->dev;
47
48         if (!root_folder)
49                 return -ENODEV;
50
51         drvr->dbgfs_dir = debugfs_create_dir(dev_name(dev), root_folder);
52         return PTR_RET(drvr->dbgfs_dir);
53 }
54
55 void brcmf_debugfs_detach(struct brcmf_pub *drvr)
56 {
57         if (!IS_ERR_OR_NULL(drvr->dbgfs_dir))
58                 debugfs_remove_recursive(drvr->dbgfs_dir);
59 }
60
61 struct dentry *brcmf_debugfs_get_devdir(struct brcmf_pub *drvr)
62 {
63         return drvr->dbgfs_dir;
64 }
65
66 static
67 ssize_t brcmf_debugfs_sdio_counter_read(struct file *f, char __user *data,
68                                         size_t count, loff_t *ppos)
69 {
70         struct brcmf_sdio_count *sdcnt = f->private_data;
71         char buf[750];
72         int res;
73
74         /* only allow read from start */
75         if (*ppos > 0)
76                 return 0;
77
78         res = scnprintf(buf, sizeof(buf),
79                         "intrcount:    %u\nlastintrs:    %u\n"
80                         "pollcnt:      %u\nregfails:     %u\n"
81                         "tx_sderrs:    %u\nfcqueued:     %u\n"
82                         "rxrtx:        %u\nrx_toolong:   %u\n"
83                         "rxc_errors:   %u\nrx_hdrfail:   %u\n"
84                         "rx_badhdr:    %u\nrx_badseq:    %u\n"
85                         "fc_rcvd:      %u\nfc_xoff:      %u\n"
86                         "fc_xon:       %u\nrxglomfail:   %u\n"
87                         "rxglomframes: %u\nrxglompkts:   %u\n"
88                         "f2rxhdrs:     %u\nf2rxdata:     %u\n"
89                         "f2txdata:     %u\nf1regdata:    %u\n"
90                         "tickcnt:      %u\ntx_ctlerrs:   %lu\n"
91                         "tx_ctlpkts:   %lu\nrx_ctlerrs:   %lu\n"
92                         "rx_ctlpkts:   %lu\nrx_readahead: %lu\n",
93                         sdcnt->intrcount, sdcnt->lastintrs,
94                         sdcnt->pollcnt, sdcnt->regfails,
95                         sdcnt->tx_sderrs, sdcnt->fcqueued,
96                         sdcnt->rxrtx, sdcnt->rx_toolong,
97                         sdcnt->rxc_errors, sdcnt->rx_hdrfail,
98                         sdcnt->rx_badhdr, sdcnt->rx_badseq,
99                         sdcnt->fc_rcvd, sdcnt->fc_xoff,
100                         sdcnt->fc_xon, sdcnt->rxglomfail,
101                         sdcnt->rxglomframes, sdcnt->rxglompkts,
102                         sdcnt->f2rxhdrs, sdcnt->f2rxdata,
103                         sdcnt->f2txdata, sdcnt->f1regdata,
104                         sdcnt->tickcnt, sdcnt->tx_ctlerrs,
105                         sdcnt->tx_ctlpkts, sdcnt->rx_ctlerrs,
106                         sdcnt->rx_ctlpkts, sdcnt->rx_readahead_cnt);
107
108         return simple_read_from_buffer(data, count, ppos, buf, res);
109 }
110
111 static const struct file_operations brcmf_debugfs_sdio_counter_ops = {
112         .owner = THIS_MODULE,
113         .open = simple_open,
114         .read = brcmf_debugfs_sdio_counter_read
115 };
116
117 void brcmf_debugfs_create_sdio_count(struct brcmf_pub *drvr,
118                                      struct brcmf_sdio_count *sdcnt)
119 {
120         struct dentry *dentry = drvr->dbgfs_dir;
121
122         if (!IS_ERR_OR_NULL(dentry))
123                 debugfs_create_file("counters", S_IRUGO, dentry,
124                                     sdcnt, &brcmf_debugfs_sdio_counter_ops);
125 }