diff options
author | Sujith Manoharan <Sujith.Manoharan@atheros.com> | 2011-04-13 01:54:00 -0400 |
---|---|---|
committer | John W. Linville <linville@tuxdriver.com> | 2011-04-13 15:22:37 -0400 |
commit | 8e42e4ba98f986be64016df79eacbb671dbd3d18 (patch) | |
tree | 05191ee5162eaf0959e78756d7a1f954cb28597e /drivers/net/wireless/ath/ath9k/htc_drv_debug.c | |
parent | f4c88991f51e097b6541f998fd23d477999e5886 (diff) |
ath9k_htc: Move debug code to a separate file
Signed-off-by: Sujith Manoharan <Sujith.Manoharan@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
Diffstat (limited to 'drivers/net/wireless/ath/ath9k/htc_drv_debug.c')
-rw-r--r-- | drivers/net/wireless/ath/ath9k/htc_drv_debug.c | 219 |
1 files changed, 219 insertions, 0 deletions
diff --git a/drivers/net/wireless/ath/ath9k/htc_drv_debug.c b/drivers/net/wireless/ath/ath9k/htc_drv_debug.c new file mode 100644 index 000000000000..8b679aab338a --- /dev/null +++ b/drivers/net/wireless/ath/ath9k/htc_drv_debug.c | |||
@@ -0,0 +1,219 @@ | |||
1 | /* | ||
2 | * Copyright (c) 2010-2011 Atheros Communications Inc. | ||
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 | ||
11 | * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES | ||
12 | * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN | ||
13 | * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF | ||
14 | * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. | ||
15 | */ | ||
16 | |||
17 | #include "htc.h" | ||
18 | |||
19 | static struct dentry *ath9k_debugfs_root; | ||
20 | |||
21 | static int ath9k_debugfs_open(struct inode *inode, struct file *file) | ||
22 | { | ||
23 | file->private_data = inode->i_private; | ||
24 | return 0; | ||
25 | } | ||
26 | |||
27 | static ssize_t read_file_tgt_stats(struct file *file, char __user *user_buf, | ||
28 | size_t count, loff_t *ppos) | ||
29 | { | ||
30 | struct ath9k_htc_priv *priv = file->private_data; | ||
31 | struct ath9k_htc_target_stats cmd_rsp; | ||
32 | char buf[512]; | ||
33 | unsigned int len = 0; | ||
34 | int ret = 0; | ||
35 | |||
36 | memset(&cmd_rsp, 0, sizeof(cmd_rsp)); | ||
37 | |||
38 | WMI_CMD(WMI_TGT_STATS_CMDID); | ||
39 | if (ret) | ||
40 | return -EINVAL; | ||
41 | |||
42 | |||
43 | len += snprintf(buf + len, sizeof(buf) - len, | ||
44 | "%19s : %10u\n", "TX Short Retries", | ||
45 | be32_to_cpu(cmd_rsp.tx_shortretry)); | ||
46 | len += snprintf(buf + len, sizeof(buf) - len, | ||
47 | "%19s : %10u\n", "TX Long Retries", | ||
48 | be32_to_cpu(cmd_rsp.tx_longretry)); | ||
49 | len += snprintf(buf + len, sizeof(buf) - len, | ||
50 | "%19s : %10u\n", "TX Xretries", | ||
51 | be32_to_cpu(cmd_rsp.tx_xretries)); | ||
52 | len += snprintf(buf + len, sizeof(buf) - len, | ||
53 | "%19s : %10u\n", "TX Unaggr. Xretries", | ||
54 | be32_to_cpu(cmd_rsp.ht_txunaggr_xretry)); | ||
55 | len += snprintf(buf + len, sizeof(buf) - len, | ||
56 | "%19s : %10u\n", "TX Xretries (HT)", | ||
57 | be32_to_cpu(cmd_rsp.ht_tx_xretries)); | ||
58 | len += snprintf(buf + len, sizeof(buf) - len, | ||
59 | "%19s : %10u\n", "TX Rate", priv->debug.txrate); | ||
60 | |||
61 | if (len > sizeof(buf)) | ||
62 | len = sizeof(buf); | ||
63 | |||
64 | return simple_read_from_buffer(user_buf, count, ppos, buf, len); | ||
65 | } | ||
66 | |||
67 | static const struct file_operations fops_tgt_stats = { | ||
68 | .read = read_file_tgt_stats, | ||
69 | .open = ath9k_debugfs_open, | ||
70 | .owner = THIS_MODULE, | ||
71 | .llseek = default_llseek, | ||
72 | }; | ||
73 | |||
74 | static ssize_t read_file_xmit(struct file *file, char __user *user_buf, | ||
75 | size_t count, loff_t *ppos) | ||
76 | { | ||
77 | struct ath9k_htc_priv *priv = file->private_data; | ||
78 | char buf[512]; | ||
79 | unsigned int len = 0; | ||
80 | |||
81 | len += snprintf(buf + len, sizeof(buf) - len, | ||
82 | "%20s : %10u\n", "Buffers queued", | ||
83 | priv->debug.tx_stats.buf_queued); | ||
84 | len += snprintf(buf + len, sizeof(buf) - len, | ||
85 | "%20s : %10u\n", "Buffers completed", | ||
86 | priv->debug.tx_stats.buf_completed); | ||
87 | len += snprintf(buf + len, sizeof(buf) - len, | ||
88 | "%20s : %10u\n", "SKBs queued", | ||
89 | priv->debug.tx_stats.skb_queued); | ||
90 | len += snprintf(buf + len, sizeof(buf) - len, | ||
91 | "%20s : %10u\n", "SKBs completed", | ||
92 | priv->debug.tx_stats.skb_completed); | ||
93 | len += snprintf(buf + len, sizeof(buf) - len, | ||
94 | "%20s : %10u\n", "SKBs dropped", | ||
95 | priv->debug.tx_stats.skb_dropped); | ||
96 | len += snprintf(buf + len, sizeof(buf) - len, | ||
97 | "%20s : %10u\n", "CAB queued", | ||
98 | priv->debug.tx_stats.cab_queued); | ||
99 | |||
100 | len += snprintf(buf + len, sizeof(buf) - len, | ||
101 | "%20s : %10u\n", "BE queued", | ||
102 | priv->debug.tx_stats.queue_stats[WME_AC_BE]); | ||
103 | len += snprintf(buf + len, sizeof(buf) - len, | ||
104 | "%20s : %10u\n", "BK queued", | ||
105 | priv->debug.tx_stats.queue_stats[WME_AC_BK]); | ||
106 | len += snprintf(buf + len, sizeof(buf) - len, | ||
107 | "%20s : %10u\n", "VI queued", | ||
108 | priv->debug.tx_stats.queue_stats[WME_AC_VI]); | ||
109 | len += snprintf(buf + len, sizeof(buf) - len, | ||
110 | "%20s : %10u\n", "VO queued", | ||
111 | priv->debug.tx_stats.queue_stats[WME_AC_VO]); | ||
112 | |||
113 | if (len > sizeof(buf)) | ||
114 | len = sizeof(buf); | ||
115 | |||
116 | return simple_read_from_buffer(user_buf, count, ppos, buf, len); | ||
117 | } | ||
118 | |||
119 | static const struct file_operations fops_xmit = { | ||
120 | .read = read_file_xmit, | ||
121 | .open = ath9k_debugfs_open, | ||
122 | .owner = THIS_MODULE, | ||
123 | .llseek = default_llseek, | ||
124 | }; | ||
125 | |||
126 | static ssize_t read_file_recv(struct file *file, char __user *user_buf, | ||
127 | size_t count, loff_t *ppos) | ||
128 | { | ||
129 | struct ath9k_htc_priv *priv = file->private_data; | ||
130 | char buf[512]; | ||
131 | unsigned int len = 0; | ||
132 | |||
133 | len += snprintf(buf + len, sizeof(buf) - len, | ||
134 | "%20s : %10u\n", "SKBs allocated", | ||
135 | priv->debug.rx_stats.skb_allocated); | ||
136 | len += snprintf(buf + len, sizeof(buf) - len, | ||
137 | "%20s : %10u\n", "SKBs completed", | ||
138 | priv->debug.rx_stats.skb_completed); | ||
139 | len += snprintf(buf + len, sizeof(buf) - len, | ||
140 | "%20s : %10u\n", "SKBs Dropped", | ||
141 | priv->debug.rx_stats.skb_dropped); | ||
142 | |||
143 | if (len > sizeof(buf)) | ||
144 | len = sizeof(buf); | ||
145 | |||
146 | return simple_read_from_buffer(user_buf, count, ppos, buf, len); | ||
147 | } | ||
148 | |||
149 | static const struct file_operations fops_recv = { | ||
150 | .read = read_file_recv, | ||
151 | .open = ath9k_debugfs_open, | ||
152 | .owner = THIS_MODULE, | ||
153 | .llseek = default_llseek, | ||
154 | }; | ||
155 | |||
156 | int ath9k_htc_init_debug(struct ath_hw *ah) | ||
157 | { | ||
158 | struct ath_common *common = ath9k_hw_common(ah); | ||
159 | struct ath9k_htc_priv *priv = (struct ath9k_htc_priv *) common->priv; | ||
160 | |||
161 | if (!ath9k_debugfs_root) | ||
162 | return -ENOENT; | ||
163 | |||
164 | priv->debug.debugfs_phy = debugfs_create_dir(wiphy_name(priv->hw->wiphy), | ||
165 | ath9k_debugfs_root); | ||
166 | if (!priv->debug.debugfs_phy) | ||
167 | goto err; | ||
168 | |||
169 | priv->debug.debugfs_tgt_stats = debugfs_create_file("tgt_stats", S_IRUSR, | ||
170 | priv->debug.debugfs_phy, | ||
171 | priv, &fops_tgt_stats); | ||
172 | if (!priv->debug.debugfs_tgt_stats) | ||
173 | goto err; | ||
174 | |||
175 | |||
176 | priv->debug.debugfs_xmit = debugfs_create_file("xmit", S_IRUSR, | ||
177 | priv->debug.debugfs_phy, | ||
178 | priv, &fops_xmit); | ||
179 | if (!priv->debug.debugfs_xmit) | ||
180 | goto err; | ||
181 | |||
182 | priv->debug.debugfs_recv = debugfs_create_file("recv", S_IRUSR, | ||
183 | priv->debug.debugfs_phy, | ||
184 | priv, &fops_recv); | ||
185 | if (!priv->debug.debugfs_recv) | ||
186 | goto err; | ||
187 | |||
188 | return 0; | ||
189 | |||
190 | err: | ||
191 | ath9k_htc_exit_debug(ah); | ||
192 | return -ENOMEM; | ||
193 | } | ||
194 | |||
195 | void ath9k_htc_exit_debug(struct ath_hw *ah) | ||
196 | { | ||
197 | struct ath_common *common = ath9k_hw_common(ah); | ||
198 | struct ath9k_htc_priv *priv = (struct ath9k_htc_priv *) common->priv; | ||
199 | |||
200 | debugfs_remove(priv->debug.debugfs_recv); | ||
201 | debugfs_remove(priv->debug.debugfs_xmit); | ||
202 | debugfs_remove(priv->debug.debugfs_tgt_stats); | ||
203 | debugfs_remove(priv->debug.debugfs_phy); | ||
204 | } | ||
205 | |||
206 | int ath9k_htc_debug_create_root(void) | ||
207 | { | ||
208 | ath9k_debugfs_root = debugfs_create_dir(KBUILD_MODNAME, NULL); | ||
209 | if (!ath9k_debugfs_root) | ||
210 | return -ENOENT; | ||
211 | |||
212 | return 0; | ||
213 | } | ||
214 | |||
215 | void ath9k_htc_debug_remove_root(void) | ||
216 | { | ||
217 | debugfs_remove(ath9k_debugfs_root); | ||
218 | ath9k_debugfs_root = NULL; | ||
219 | } | ||