aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorAbhijeet Kolekar <abhijeet.kolekar@intel.com>2010-04-16 13:03:54 -0400
committerReinette Chatre <reinette.chatre@intel.com>2010-04-30 18:34:31 -0400
commit17f36fc6ef3d1ab15f9d2160a9daa107db0887ca (patch)
treed578f43affda2b1fd859256f7d24f9ba74aa55e2 /drivers
parentc2845d010b0e58a17cd2301e657b614962331550 (diff)
iwl3945: add ucode statistics
Add general, rx and tx uCode statistics to 3945. This will help in debugging Signed-off-by: Abhijeet Kolekar <abhijeet.kolekar@intel.com> Signed-off-by: Reinette Chatre <reinette.chatre@intel.com>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/net/wireless/iwlwifi/Makefile1
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-3945-debugfs.c500
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-3945-debugfs.h60
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-3945.c72
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-3945.h2
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-debugfs.c18
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-dev.h5
-rw-r--r--drivers/net/wireless/iwlwifi/iwl3945-base.c2
8 files changed, 646 insertions, 14 deletions
diff --git a/drivers/net/wireless/iwlwifi/Makefile b/drivers/net/wireless/iwlwifi/Makefile
index 5ed2dcbe6d01..7c7235385513 100644
--- a/drivers/net/wireless/iwlwifi/Makefile
+++ b/drivers/net/wireless/iwlwifi/Makefile
@@ -22,5 +22,6 @@ iwlagn-$(CONFIG_IWL5000) += iwl-1000.o
22# 3945 22# 3945
23obj-$(CONFIG_IWL3945) += iwl3945.o 23obj-$(CONFIG_IWL3945) += iwl3945.o
24iwl3945-objs := iwl3945-base.o iwl-3945.o iwl-3945-rs.o iwl-3945-led.o 24iwl3945-objs := iwl3945-base.o iwl-3945.o iwl-3945-rs.o iwl-3945-led.o
25iwl3945-$(CONFIG_IWLWIFI_DEBUGFS) += iwl-3945-debugfs.o
25 26
26ccflags-y += -D__CHECK_ENDIAN__ 27ccflags-y += -D__CHECK_ENDIAN__
diff --git a/drivers/net/wireless/iwlwifi/iwl-3945-debugfs.c b/drivers/net/wireless/iwlwifi/iwl-3945-debugfs.c
new file mode 100644
index 000000000000..6a9c64a50e36
--- /dev/null
+++ b/drivers/net/wireless/iwlwifi/iwl-3945-debugfs.c
@@ -0,0 +1,500 @@
1/******************************************************************************
2 *
3 * GPL LICENSE SUMMARY
4 *
5 * Copyright(c) 2008 - 2010 Intel Corporation. All rights reserved.
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of version 2 of the GNU General Public License as
9 * published by the Free Software Foundation.
10 *
11 * This program is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110,
19 * USA
20 *
21 * The full GNU General Public License is included in this distribution
22 * in the file called LICENSE.GPL.
23 *
24 * Contact Information:
25 * Intel Linux Wireless <ilw@linux.intel.com>
26 * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
27 *****************************************************************************/
28
29#include "iwl-3945-debugfs.h"
30
31ssize_t iwl3945_ucode_rx_stats_read(struct file *file,
32 char __user *user_buf,
33 size_t count, loff_t *ppos)
34{
35 struct iwl_priv *priv = file->private_data;
36 int pos = 0;
37 char *buf;
38 int bufsz = sizeof(struct iwl39_statistics_rx_phy) * 40 +
39 sizeof(struct iwl39_statistics_rx_non_phy) * 40 + 400;
40 ssize_t ret;
41 struct iwl39_statistics_rx_phy *ofdm, *accum_ofdm, *delta_ofdm, *max_ofdm;
42 struct iwl39_statistics_rx_phy *cck, *accum_cck, *delta_cck, *max_cck;
43 struct iwl39_statistics_rx_non_phy *general, *accum_general;
44 struct iwl39_statistics_rx_non_phy *delta_general, *max_general;
45
46 if (!iwl_is_alive(priv))
47 return -EAGAIN;
48
49 buf = kzalloc(bufsz, GFP_KERNEL);
50 if (!buf) {
51 IWL_ERR(priv, "Can not allocate Buffer\n");
52 return -ENOMEM;
53 }
54
55 /*
56 * The statistic information display here is based on
57 * the last statistics notification from uCode
58 * might not reflect the current uCode activity
59 */
60 ofdm = &priv->_3945.statistics.rx.ofdm;
61 cck = &priv->_3945.statistics.rx.cck;
62 general = &priv->_3945.statistics.rx.general;
63 accum_ofdm = &priv->_3945.accum_statistics.rx.ofdm;
64 accum_cck = &priv->_3945.accum_statistics.rx.cck;
65 accum_general = &priv->_3945.accum_statistics.rx.general;
66 delta_ofdm = &priv->_3945.delta_statistics.rx.ofdm;
67 delta_cck = &priv->_3945.delta_statistics.rx.cck;
68 delta_general = &priv->_3945.delta_statistics.rx.general;
69 max_ofdm = &priv->_3945.max_delta.rx.ofdm;
70 max_cck = &priv->_3945.max_delta.rx.cck;
71 max_general = &priv->_3945.max_delta.rx.general;
72
73 pos += iwl_dbgfs_statistics_flag(priv, buf, bufsz);
74 pos += scnprintf(buf + pos, bufsz - pos, "%-32s current"
75 "acumulative delta max\n",
76 "Statistics_Rx - OFDM:");
77 pos += scnprintf(buf + pos, bufsz - pos,
78 " %-30s %10u %10u %10u %10u\n",
79 "ina_cnt:", le32_to_cpu(ofdm->ina_cnt),
80 accum_ofdm->ina_cnt,
81 delta_ofdm->ina_cnt, max_ofdm->ina_cnt);
82 pos += scnprintf(buf + pos, bufsz - pos,
83 " %-30s %10u %10u %10u %10u\n",
84 "fina_cnt:",
85 le32_to_cpu(ofdm->fina_cnt), accum_ofdm->fina_cnt,
86 delta_ofdm->fina_cnt, max_ofdm->fina_cnt);
87 pos += scnprintf(buf + pos, bufsz - pos,
88 " %-30s %10u %10u %10u %10u\n", "plcp_err:",
89 le32_to_cpu(ofdm->plcp_err), accum_ofdm->plcp_err,
90 delta_ofdm->plcp_err, max_ofdm->plcp_err);
91 pos += scnprintf(buf + pos, bufsz - pos,
92 " %-30s %10u %10u %10u %10u\n", "crc32_err:",
93 le32_to_cpu(ofdm->crc32_err), accum_ofdm->crc32_err,
94 delta_ofdm->crc32_err, max_ofdm->crc32_err);
95 pos += scnprintf(buf + pos, bufsz - pos,
96 " %-30s %10u %10u %10u %10u\n", "overrun_err:",
97 le32_to_cpu(ofdm->overrun_err),
98 accum_ofdm->overrun_err, delta_ofdm->overrun_err,
99 max_ofdm->overrun_err);
100 pos += scnprintf(buf + pos, bufsz - pos,
101 " %-30s %10u %10u %10u %10u\n",
102 "early_overrun_err:",
103 le32_to_cpu(ofdm->early_overrun_err),
104 accum_ofdm->early_overrun_err,
105 delta_ofdm->early_overrun_err,
106 max_ofdm->early_overrun_err);
107 pos += scnprintf(buf + pos, bufsz - pos,
108 " %-30s %10u %10u %10u %10u\n",
109 "crc32_good:", le32_to_cpu(ofdm->crc32_good),
110 accum_ofdm->crc32_good, delta_ofdm->crc32_good,
111 max_ofdm->crc32_good);
112 pos += scnprintf(buf + pos, bufsz - pos,
113 " %-30s %10u %10u %10u %10u\n", "false_alarm_cnt:",
114 le32_to_cpu(ofdm->false_alarm_cnt),
115 accum_ofdm->false_alarm_cnt,
116 delta_ofdm->false_alarm_cnt,
117 max_ofdm->false_alarm_cnt);
118 pos += scnprintf(buf + pos, bufsz - pos,
119 " %-30s %10u %10u %10u %10u\n",
120 "fina_sync_err_cnt:",
121 le32_to_cpu(ofdm->fina_sync_err_cnt),
122 accum_ofdm->fina_sync_err_cnt,
123 delta_ofdm->fina_sync_err_cnt,
124 max_ofdm->fina_sync_err_cnt);
125 pos += scnprintf(buf + pos, bufsz - pos,
126 " %-30s %10u %10u %10u %10u\n",
127 "sfd_timeout:",
128 le32_to_cpu(ofdm->sfd_timeout),
129 accum_ofdm->sfd_timeout,
130 delta_ofdm->sfd_timeout,
131 max_ofdm->sfd_timeout);
132 pos += scnprintf(buf + pos, bufsz - pos,
133 " %-30s %10u %10u %10u %10u\n",
134 "fina_timeout:",
135 le32_to_cpu(ofdm->fina_timeout),
136 accum_ofdm->fina_timeout,
137 delta_ofdm->fina_timeout,
138 max_ofdm->fina_timeout);
139 pos += scnprintf(buf + pos, bufsz - pos,
140 " %-30s %10u %10u %10u %10u\n",
141 "unresponded_rts:",
142 le32_to_cpu(ofdm->unresponded_rts),
143 accum_ofdm->unresponded_rts,
144 delta_ofdm->unresponded_rts,
145 max_ofdm->unresponded_rts);
146 pos += scnprintf(buf + pos, bufsz - pos,
147 " %-30s %10u %10u %10u %10u\n",
148 "rxe_frame_lmt_ovrun:",
149 le32_to_cpu(ofdm->rxe_frame_limit_overrun),
150 accum_ofdm->rxe_frame_limit_overrun,
151 delta_ofdm->rxe_frame_limit_overrun,
152 max_ofdm->rxe_frame_limit_overrun);
153 pos += scnprintf(buf + pos, bufsz - pos,
154 " %-30s %10u %10u %10u %10u\n",
155 "sent_ack_cnt:",
156 le32_to_cpu(ofdm->sent_ack_cnt),
157 accum_ofdm->sent_ack_cnt,
158 delta_ofdm->sent_ack_cnt,
159 max_ofdm->sent_ack_cnt);
160 pos += scnprintf(buf + pos, bufsz - pos,
161 " %-30s %10u %10u %10u %10u\n",
162 "sent_cts_cnt:",
163 le32_to_cpu(ofdm->sent_cts_cnt),
164 accum_ofdm->sent_cts_cnt,
165 delta_ofdm->sent_cts_cnt, max_ofdm->sent_cts_cnt);
166
167 pos += scnprintf(buf + pos, bufsz - pos, "%-32s current"
168 "acumulative delta max\n",
169 "Statistics_Rx - CCK:");
170 pos += scnprintf(buf + pos, bufsz - pos,
171 " %-30s %10u %10u %10u %10u\n",
172 "ina_cnt:",
173 le32_to_cpu(cck->ina_cnt), accum_cck->ina_cnt,
174 delta_cck->ina_cnt, max_cck->ina_cnt);
175 pos += scnprintf(buf + pos, bufsz - pos,
176 " %-30s %10u %10u %10u %10u\n",
177 "fina_cnt:",
178 le32_to_cpu(cck->fina_cnt), accum_cck->fina_cnt,
179 delta_cck->fina_cnt, max_cck->fina_cnt);
180 pos += scnprintf(buf + pos, bufsz - pos,
181 " %-30s %10u %10u %10u %10u\n",
182 "plcp_err:",
183 le32_to_cpu(cck->plcp_err), accum_cck->plcp_err,
184 delta_cck->plcp_err, max_cck->plcp_err);
185 pos += scnprintf(buf + pos, bufsz - pos,
186 " %-30s %10u %10u %10u %10u\n",
187 "crc32_err:",
188 le32_to_cpu(cck->crc32_err), accum_cck->crc32_err,
189 delta_cck->crc32_err, max_cck->crc32_err);
190 pos += scnprintf(buf + pos, bufsz - pos,
191 " %-30s %10u %10u %10u %10u\n",
192 "overrun_err:",
193 le32_to_cpu(cck->overrun_err),
194 accum_cck->overrun_err,
195 delta_cck->overrun_err, max_cck->overrun_err);
196 pos += scnprintf(buf + pos, bufsz - pos,
197 " %-30s %10u %10u %10u %10u\n",
198 "early_overrun_err:",
199 le32_to_cpu(cck->early_overrun_err),
200 accum_cck->early_overrun_err,
201 delta_cck->early_overrun_err,
202 max_cck->early_overrun_err);
203 pos += scnprintf(buf + pos, bufsz - pos,
204 " %-30s %10u %10u %10u %10u\n",
205 "crc32_good:",
206 le32_to_cpu(cck->crc32_good), accum_cck->crc32_good,
207 delta_cck->crc32_good,
208 max_cck->crc32_good);
209 pos += scnprintf(buf + pos, bufsz - pos,
210 " %-30s %10u %10u %10u %10u\n",
211 "false_alarm_cnt:",
212 le32_to_cpu(cck->false_alarm_cnt),
213 accum_cck->false_alarm_cnt,
214 delta_cck->false_alarm_cnt, max_cck->false_alarm_cnt);
215 pos += scnprintf(buf + pos, bufsz - pos,
216 " %-30s %10u %10u %10u %10u\n",
217 "fina_sync_err_cnt:",
218 le32_to_cpu(cck->fina_sync_err_cnt),
219 accum_cck->fina_sync_err_cnt,
220 delta_cck->fina_sync_err_cnt,
221 max_cck->fina_sync_err_cnt);
222 pos += scnprintf(buf + pos, bufsz - pos,
223 " %-30s %10u %10u %10u %10u\n",
224 "sfd_timeout:",
225 le32_to_cpu(cck->sfd_timeout),
226 accum_cck->sfd_timeout,
227 delta_cck->sfd_timeout, max_cck->sfd_timeout);
228 pos += scnprintf(buf + pos, bufsz - pos,
229 " %-30s %10u %10u %10u %10u\n",
230 "fina_timeout:",
231 le32_to_cpu(cck->fina_timeout),
232 accum_cck->fina_timeout,
233 delta_cck->fina_timeout, max_cck->fina_timeout);
234 pos += scnprintf(buf + pos, bufsz - pos,
235 " %-30s %10u %10u %10u %10u\n",
236 "unresponded_rts:",
237 le32_to_cpu(cck->unresponded_rts),
238 accum_cck->unresponded_rts,
239 delta_cck->unresponded_rts,
240 max_cck->unresponded_rts);
241 pos += scnprintf(buf + pos, bufsz - pos,
242 " %-30s %10u %10u %10u %10u\n",
243 "rxe_frame_lmt_ovrun:",
244 le32_to_cpu(cck->rxe_frame_limit_overrun),
245 accum_cck->rxe_frame_limit_overrun,
246 delta_cck->rxe_frame_limit_overrun,
247 max_cck->rxe_frame_limit_overrun);
248 pos += scnprintf(buf + pos, bufsz - pos,
249 " %-30s %10u %10u %10u %10u\n",
250 "sent_ack_cnt:",
251 le32_to_cpu(cck->sent_ack_cnt),
252 accum_cck->sent_ack_cnt,
253 delta_cck->sent_ack_cnt,
254 max_cck->sent_ack_cnt);
255 pos += scnprintf(buf + pos, bufsz - pos,
256 " %-30s %10u %10u %10u %10u\n",
257 "sent_cts_cnt:",
258 le32_to_cpu(cck->sent_cts_cnt),
259 accum_cck->sent_cts_cnt,
260 delta_cck->sent_cts_cnt,
261 max_cck->sent_cts_cnt);
262
263 pos += scnprintf(buf + pos, bufsz - pos, "%-32s current"
264 "acumulative delta max\n",
265 "Statistics_Rx - GENERAL:");
266 pos += scnprintf(buf + pos, bufsz - pos,
267 " %-30s %10u %10u %10u %10u\n",
268 "bogus_cts:",
269 le32_to_cpu(general->bogus_cts),
270 accum_general->bogus_cts,
271 delta_general->bogus_cts, max_general->bogus_cts);
272 pos += scnprintf(buf + pos, bufsz - pos,
273 " %-30s %10u %10u %10u %10u\n",
274 "bogus_ack:",
275 le32_to_cpu(general->bogus_ack),
276 accum_general->bogus_ack,
277 delta_general->bogus_ack, max_general->bogus_ack);
278 pos += scnprintf(buf + pos, bufsz - pos,
279 " %-30s %10u %10u %10u %10u\n",
280 "non_bssid_frames:",
281 le32_to_cpu(general->non_bssid_frames),
282 accum_general->non_bssid_frames,
283 delta_general->non_bssid_frames,
284 max_general->non_bssid_frames);
285 pos += scnprintf(buf + pos, bufsz - pos,
286 " %-30s %10u %10u %10u %10u\n",
287 "filtered_frames:",
288 le32_to_cpu(general->filtered_frames),
289 accum_general->filtered_frames,
290 delta_general->filtered_frames,
291 max_general->filtered_frames);
292 pos += scnprintf(buf + pos, bufsz - pos,
293 " %-30s %10u %10u %10u %10u\n",
294 "non_channel_beacons:",
295 le32_to_cpu(general->non_channel_beacons),
296 accum_general->non_channel_beacons,
297 delta_general->non_channel_beacons,
298 max_general->non_channel_beacons);
299
300 ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos);
301 kfree(buf);
302 return ret;
303}
304
305ssize_t iwl3945_ucode_tx_stats_read(struct file *file,
306 char __user *user_buf,
307 size_t count, loff_t *ppos)
308{
309 struct iwl_priv *priv = file->private_data;
310 int pos = 0;
311 char *buf;
312 int bufsz = (sizeof(struct iwl39_statistics_tx) * 48) + 250;
313 ssize_t ret;
314 struct iwl39_statistics_tx *tx, *accum_tx, *delta_tx, *max_tx;
315
316 if (!iwl_is_alive(priv))
317 return -EAGAIN;
318
319 buf = kzalloc(bufsz, GFP_KERNEL);
320 if (!buf) {
321 IWL_ERR(priv, "Can not allocate Buffer\n");
322 return -ENOMEM;
323 }
324
325 /*
326 * The statistic information display here is based on
327 * the last statistics notification from uCode
328 * might not reflect the current uCode activity
329 */
330 tx = &priv->_3945.statistics.tx;
331 accum_tx = &priv->_3945.accum_statistics.tx;
332 delta_tx = &priv->_3945.delta_statistics.tx;
333 max_tx = &priv->_3945.max_delta.tx;
334 pos += iwl_dbgfs_statistics_flag(priv, buf, bufsz);
335 pos += scnprintf(buf + pos, bufsz - pos, "%-32s current"
336 "acumulative delta max\n",
337 "Statistics_Tx:");
338 pos += scnprintf(buf + pos, bufsz - pos,
339 " %-30s %10u %10u %10u %10u\n",
340 "preamble:",
341 le32_to_cpu(tx->preamble_cnt),
342 accum_tx->preamble_cnt,
343 delta_tx->preamble_cnt, max_tx->preamble_cnt);
344 pos += scnprintf(buf + pos, bufsz - pos,
345 " %-30s %10u %10u %10u %10u\n",
346 "rx_detected_cnt:",
347 le32_to_cpu(tx->rx_detected_cnt),
348 accum_tx->rx_detected_cnt,
349 delta_tx->rx_detected_cnt, max_tx->rx_detected_cnt);
350 pos += scnprintf(buf + pos, bufsz - pos,
351 " %-30s %10u %10u %10u %10u\n",
352 "bt_prio_defer_cnt:",
353 le32_to_cpu(tx->bt_prio_defer_cnt),
354 accum_tx->bt_prio_defer_cnt,
355 delta_tx->bt_prio_defer_cnt,
356 max_tx->bt_prio_defer_cnt);
357 pos += scnprintf(buf + pos, bufsz - pos,
358 " %-30s %10u %10u %10u %10u\n",
359 "bt_prio_kill_cnt:",
360 le32_to_cpu(tx->bt_prio_kill_cnt),
361 accum_tx->bt_prio_kill_cnt,
362 delta_tx->bt_prio_kill_cnt,
363 max_tx->bt_prio_kill_cnt);
364 pos += scnprintf(buf + pos, bufsz - pos,
365 " %-30s %10u %10u %10u %10u\n",
366 "few_bytes_cnt:",
367 le32_to_cpu(tx->few_bytes_cnt),
368 accum_tx->few_bytes_cnt,
369 delta_tx->few_bytes_cnt, max_tx->few_bytes_cnt);
370 pos += scnprintf(buf + pos, bufsz - pos,
371 " %-30s %10u %10u %10u %10u\n",
372 "cts_timeout:",
373 le32_to_cpu(tx->cts_timeout), accum_tx->cts_timeout,
374 delta_tx->cts_timeout, max_tx->cts_timeout);
375 pos += scnprintf(buf + pos, bufsz - pos,
376 " %-30s %10u %10u %10u %10u\n",
377 "ack_timeout:",
378 le32_to_cpu(tx->ack_timeout),
379 accum_tx->ack_timeout,
380 delta_tx->ack_timeout, max_tx->ack_timeout);
381 pos += scnprintf(buf + pos, bufsz - pos,
382 " %-30s %10u %10u %10u %10u\n",
383 "expected_ack_cnt:",
384 le32_to_cpu(tx->expected_ack_cnt),
385 accum_tx->expected_ack_cnt,
386 delta_tx->expected_ack_cnt,
387 max_tx->expected_ack_cnt);
388 pos += scnprintf(buf + pos, bufsz - pos,
389 " %-30s %10u %10u %10u %10u\n",
390 "actual_ack_cnt:",
391 le32_to_cpu(tx->actual_ack_cnt),
392 accum_tx->actual_ack_cnt,
393 delta_tx->actual_ack_cnt,
394 max_tx->actual_ack_cnt);
395
396 ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos);
397 kfree(buf);
398 return ret;
399}
400
401ssize_t iwl3945_ucode_general_stats_read(struct file *file,
402 char __user *user_buf,
403 size_t count, loff_t *ppos)
404{
405 struct iwl_priv *priv = file->private_data;
406 int pos = 0;
407 char *buf;
408 int bufsz = sizeof(struct iwl39_statistics_general) * 10 + 300;
409 ssize_t ret;
410 struct iwl39_statistics_general *general, *accum_general;
411 struct iwl39_statistics_general *delta_general, *max_general;
412 struct statistics_dbg *dbg, *accum_dbg, *delta_dbg, *max_dbg;
413 struct iwl39_statistics_div *div, *accum_div, *delta_div, *max_div;
414
415 if (!iwl_is_alive(priv))
416 return -EAGAIN;
417
418 buf = kzalloc(bufsz, GFP_KERNEL);
419 if (!buf) {
420 IWL_ERR(priv, "Can not allocate Buffer\n");
421 return -ENOMEM;
422 }
423
424 /*
425 * The statistic information display here is based on
426 * the last statistics notification from uCode
427 * might not reflect the current uCode activity
428 */
429 general = &priv->_3945.statistics.general;
430 dbg = &priv->_3945.statistics.general.dbg;
431 div = &priv->_3945.statistics.general.div;
432 accum_general = &priv->_3945.accum_statistics.general;
433 delta_general = &priv->_3945.delta_statistics.general;
434 max_general = &priv->_3945.max_delta.general;
435 accum_dbg = &priv->_3945.accum_statistics.general.dbg;
436 delta_dbg = &priv->_3945.delta_statistics.general.dbg;
437 max_dbg = &priv->_3945.max_delta.general.dbg;
438 accum_div = &priv->_3945.accum_statistics.general.div;
439 delta_div = &priv->_3945.delta_statistics.general.div;
440 max_div = &priv->_3945.max_delta.general.div;
441 pos += iwl_dbgfs_statistics_flag(priv, buf, bufsz);
442 pos += scnprintf(buf + pos, bufsz - pos, "%-32s current"
443 "acumulative delta max\n",
444 "Statistics_General:");
445 pos += scnprintf(buf + pos, bufsz - pos,
446 " %-30s %10u %10u %10u %10u\n",
447 "burst_check:",
448 le32_to_cpu(dbg->burst_check),
449 accum_dbg->burst_check,
450 delta_dbg->burst_check, max_dbg->burst_check);
451 pos += scnprintf(buf + pos, bufsz - pos,
452 " %-30s %10u %10u %10u %10u\n",
453 "burst_count:",
454 le32_to_cpu(dbg->burst_count),
455 accum_dbg->burst_count,
456 delta_dbg->burst_count, max_dbg->burst_count);
457 pos += scnprintf(buf + pos, bufsz - pos,
458 " %-30s %10u %10u %10u %10u\n",
459 "sleep_time:",
460 le32_to_cpu(general->sleep_time),
461 accum_general->sleep_time,
462 delta_general->sleep_time, max_general->sleep_time);
463 pos += scnprintf(buf + pos, bufsz - pos,
464 " %-30s %10u %10u %10u %10u\n",
465 "slots_out:",
466 le32_to_cpu(general->slots_out),
467 accum_general->slots_out,
468 delta_general->slots_out, max_general->slots_out);
469 pos += scnprintf(buf + pos, bufsz - pos,
470 " %-30s %10u %10u %10u %10u\n",
471 "slots_idle:",
472 le32_to_cpu(general->slots_idle),
473 accum_general->slots_idle,
474 delta_general->slots_idle, max_general->slots_idle);
475 pos += scnprintf(buf + pos, bufsz - pos, "ttl_timestamp:\t\t\t%u\n",
476 le32_to_cpu(general->ttl_timestamp));
477 pos += scnprintf(buf + pos, bufsz - pos,
478 " %-30s %10u %10u %10u %10u\n",
479 "tx_on_a:",
480 le32_to_cpu(div->tx_on_a), accum_div->tx_on_a,
481 delta_div->tx_on_a, max_div->tx_on_a);
482 pos += scnprintf(buf + pos, bufsz - pos,
483 " %-30s %10u %10u %10u %10u\n",
484 "tx_on_b:",
485 le32_to_cpu(div->tx_on_b), accum_div->tx_on_b,
486 delta_div->tx_on_b, max_div->tx_on_b);
487 pos += scnprintf(buf + pos, bufsz - pos,
488 " %-30s %10u %10u %10u %10u\n",
489 "exec_time:",
490 le32_to_cpu(div->exec_time), accum_div->exec_time,
491 delta_div->exec_time, max_div->exec_time);
492 pos += scnprintf(buf + pos, bufsz - pos,
493 " %-30s %10u %10u %10u %10u\n",
494 "probe_time:",
495 le32_to_cpu(div->probe_time), accum_div->probe_time,
496 delta_div->probe_time, max_div->probe_time);
497 ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos);
498 kfree(buf);
499 return ret;
500}
diff --git a/drivers/net/wireless/iwlwifi/iwl-3945-debugfs.h b/drivers/net/wireless/iwlwifi/iwl-3945-debugfs.h
new file mode 100644
index 000000000000..70809c53c215
--- /dev/null
+++ b/drivers/net/wireless/iwlwifi/iwl-3945-debugfs.h
@@ -0,0 +1,60 @@
1/******************************************************************************
2 *
3 * GPL LICENSE SUMMARY
4 *
5 * Copyright(c) 2008 - 2010 Intel Corporation. All rights reserved.
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of version 2 of the GNU General Public License as
9 * published by the Free Software Foundation.
10 *
11 * This program is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110,
19 * USA
20 *
21 * The full GNU General Public License is included in this distribution
22 * in the file called LICENSE.GPL.
23 *
24 * Contact Information:
25 * Intel Linux Wireless <ilw@linux.intel.com>
26 * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
27 *****************************************************************************/
28
29#include "iwl-dev.h"
30#include "iwl-core.h"
31#include "iwl-debug.h"
32
33#ifdef CONFIG_IWLWIFI_DEBUGFS
34ssize_t iwl3945_ucode_rx_stats_read(struct file *file, char __user *user_buf,
35 size_t count, loff_t *ppos);
36ssize_t iwl3945_ucode_tx_stats_read(struct file *file, char __user *user_buf,
37 size_t count, loff_t *ppos);
38ssize_t iwl3945_ucode_general_stats_read(struct file *file,
39 char __user *user_buf, size_t count,
40 loff_t *ppos);
41#else
42static ssize_t iwl3945_ucode_rx_stats_read(struct file *file,
43 char __user *user_buf, size_t count,
44 loff_t *ppos)
45{
46 return 0;
47}
48static ssize_t iwl3945_ucode_tx_stats_read(struct file *file,
49 char __user *user_buf, size_t count,
50 loff_t *ppos)
51{
52 return 0;
53}
54static ssize_t iwl3945_ucode_general_stats_read(struct file *file,
55 char __user *user_buf,
56 size_t count, loff_t *ppos)
57{
58 return 0;
59}
60#endif
diff --git a/drivers/net/wireless/iwlwifi/iwl-3945.c b/drivers/net/wireless/iwlwifi/iwl-3945.c
index d10e59def53e..9dad8672d700 100644
--- a/drivers/net/wireless/iwlwifi/iwl-3945.c
+++ b/drivers/net/wireless/iwlwifi/iwl-3945.c
@@ -49,6 +49,7 @@
49#include "iwl-helpers.h" 49#include "iwl-helpers.h"
50#include "iwl-led.h" 50#include "iwl-led.h"
51#include "iwl-3945-led.h" 51#include "iwl-3945-led.h"
52#include "iwl-3945-debugfs.h"
52 53
53#define IWL_DECLARE_RATE_INFO(r, ip, in, rp, rn, pp, np) \ 54#define IWL_DECLARE_RATE_INFO(r, ip, in, rp, rn, pp, np) \
54 [IWL_RATE_##r##M_INDEX] = { IWL_RATE_##r##M_PLCP, \ 55 [IWL_RATE_##r##M_INDEX] = { IWL_RATE_##r##M_PLCP, \
@@ -292,7 +293,7 @@ static void iwl3945_tx_queue_reclaim(struct iwl_priv *priv,
292 * iwl3945_rx_reply_tx - Handle Tx response 293 * iwl3945_rx_reply_tx - Handle Tx response
293 */ 294 */
294static void iwl3945_rx_reply_tx(struct iwl_priv *priv, 295static void iwl3945_rx_reply_tx(struct iwl_priv *priv,
295 struct iwl_rx_mem_buffer *rxb) 296 struct iwl_rx_mem_buffer *rxb)
296{ 297{
297 struct iwl_rx_packet *pkt = rxb_addr(rxb); 298 struct iwl_rx_packet *pkt = rxb_addr(rxb);
298 u16 sequence = le16_to_cpu(pkt->hdr.sequence); 299 u16 sequence = le16_to_cpu(pkt->hdr.sequence);
@@ -350,18 +351,81 @@ static void iwl3945_rx_reply_tx(struct iwl_priv *priv,
350 * RX handler implementations 351 * RX handler implementations
351 * 352 *
352 *****************************************************************************/ 353 *****************************************************************************/
354#ifdef CONFIG_IWLWIFI_DEBUG
355/*
356 * based on the assumption of all statistics counter are in DWORD
357 * FIXME: This function is for debugging, do not deal with
358 * the case of counters roll-over.
359 */
360static void iwl3945_accumulative_statistics(struct iwl_priv *priv,
361 __le32 *stats)
362{
363 int i;
364 __le32 *prev_stats;
365 u32 *accum_stats;
366 u32 *delta, *max_delta;
367
368 prev_stats = (__le32 *)&priv->_3945.statistics;
369 accum_stats = (u32 *)&priv->_3945.accum_statistics;
370 delta = (u32 *)&priv->_3945.delta_statistics;
371 max_delta = (u32 *)&priv->_3945.max_delta;
372
373 for (i = sizeof(__le32); i < sizeof(struct iwl3945_notif_statistics);
374 i += sizeof(__le32), stats++, prev_stats++, delta++,
375 max_delta++, accum_stats++) {
376 if (le32_to_cpu(*stats) > le32_to_cpu(*prev_stats)) {
377 *delta = (le32_to_cpu(*stats) -
378 le32_to_cpu(*prev_stats));
379 *accum_stats += *delta;
380 if (*delta > *max_delta)
381 *max_delta = *delta;
382 }
383 }
384
385 /* reset accumulative statistics for "no-counter" type statistics */
386 priv->_3945.accum_statistics.general.temperature =
387 priv->_3945.statistics.general.temperature;
388 priv->_3945.accum_statistics.general.ttl_timestamp =
389 priv->_3945.statistics.general.ttl_timestamp;
390}
391#endif
353 392
354void iwl3945_hw_rx_statistics(struct iwl_priv *priv, 393void iwl3945_hw_rx_statistics(struct iwl_priv *priv,
355 struct iwl_rx_mem_buffer *rxb) 394 struct iwl_rx_mem_buffer *rxb)
356{ 395{
357 struct iwl_rx_packet *pkt = rxb_addr(rxb); 396 struct iwl_rx_packet *pkt = rxb_addr(rxb);
397
358 IWL_DEBUG_RX(priv, "Statistics notification received (%d vs %d).\n", 398 IWL_DEBUG_RX(priv, "Statistics notification received (%d vs %d).\n",
359 (int)sizeof(struct iwl3945_notif_statistics), 399 (int)sizeof(struct iwl3945_notif_statistics),
360 le32_to_cpu(pkt->len_n_flags) & FH_RSCSR_FRAME_SIZE_MSK); 400 le32_to_cpu(pkt->len_n_flags) & FH_RSCSR_FRAME_SIZE_MSK);
401#ifdef CONFIG_IWLWIFI_DEBUG
402 iwl3945_accumulative_statistics(priv, (__le32 *)&pkt->u.raw);
403#endif
361 404
362 memcpy(&priv->_3945.statistics, pkt->u.raw, sizeof(priv->_3945.statistics)); 405 memcpy(&priv->_3945.statistics, pkt->u.raw, sizeof(priv->_3945.statistics));
363} 406}
364 407
408void iwl3945_reply_statistics(struct iwl_priv *priv,
409 struct iwl_rx_mem_buffer *rxb)
410{
411 struct iwl_rx_packet *pkt = rxb_addr(rxb);
412 __le32 *flag = (__le32 *)&pkt->u.raw;
413
414 if (le32_to_cpu(*flag) & UCODE_STATISTICS_CLEAR_MSK) {
415#ifdef CONFIG_IWLWIFI_DEBUG
416 memset(&priv->_3945.accum_statistics, 0,
417 sizeof(struct iwl3945_notif_statistics));
418 memset(&priv->_3945.delta_statistics, 0,
419 sizeof(struct iwl3945_notif_statistics));
420 memset(&priv->_3945.max_delta, 0,
421 sizeof(struct iwl3945_notif_statistics));
422#endif
423 IWL_DEBUG_RX(priv, "Statistics have been cleared\n");
424 }
425 iwl3945_hw_rx_statistics(priv, rxb);
426}
427
428
365/****************************************************************************** 429/******************************************************************************
366 * 430 *
367 * Misc. internal state and helper functions 431 * Misc. internal state and helper functions
@@ -2735,6 +2799,12 @@ static struct iwl_lib_ops iwl3945_lib = {
2735 .isr = iwl_isr_legacy, 2799 .isr = iwl_isr_legacy,
2736 .config_ap = iwl3945_config_ap, 2800 .config_ap = iwl3945_config_ap,
2737 .add_bcast_station = iwl3945_add_bcast_station, 2801 .add_bcast_station = iwl3945_add_bcast_station,
2802
2803 .debugfs_ops = {
2804 .rx_stats_read = iwl3945_ucode_rx_stats_read,
2805 .tx_stats_read = iwl3945_ucode_tx_stats_read,
2806 .general_stats_read = iwl3945_ucode_general_stats_read,
2807 },
2738}; 2808};
2739 2809
2740static struct iwl_hcmd_utils_ops iwl3945_hcmd_utils = { 2810static struct iwl_hcmd_utils_ops iwl3945_hcmd_utils = {
diff --git a/drivers/net/wireless/iwlwifi/iwl-3945.h b/drivers/net/wireless/iwlwifi/iwl-3945.h
index e9674f0a1e94..643adb644bb8 100644
--- a/drivers/net/wireless/iwlwifi/iwl-3945.h
+++ b/drivers/net/wireless/iwlwifi/iwl-3945.h
@@ -264,6 +264,8 @@ extern int iwl3945_hw_reg_send_txpower(struct iwl_priv *priv);
264extern int iwl3945_hw_reg_set_txpower(struct iwl_priv *priv, s8 power); 264extern int iwl3945_hw_reg_set_txpower(struct iwl_priv *priv, s8 power);
265extern void iwl3945_hw_rx_statistics(struct iwl_priv *priv, 265extern void iwl3945_hw_rx_statistics(struct iwl_priv *priv,
266 struct iwl_rx_mem_buffer *rxb); 266 struct iwl_rx_mem_buffer *rxb);
267void iwl3945_reply_statistics(struct iwl_priv *priv,
268 struct iwl_rx_mem_buffer *rxb);
267extern void iwl3945_disable_events(struct iwl_priv *priv); 269extern void iwl3945_disable_events(struct iwl_priv *priv);
268extern int iwl4965_get_temperature(const struct iwl_priv *priv); 270extern int iwl4965_get_temperature(const struct iwl_priv *priv);
269extern void iwl3945_post_associate(struct iwl_priv *priv); 271extern void iwl3945_post_associate(struct iwl_priv *priv);
diff --git a/drivers/net/wireless/iwlwifi/iwl-debugfs.c b/drivers/net/wireless/iwlwifi/iwl-debugfs.c
index d789f8db4481..0aedbec9cbc8 100644
--- a/drivers/net/wireless/iwlwifi/iwl-debugfs.c
+++ b/drivers/net/wireless/iwlwifi/iwl-debugfs.c
@@ -1053,10 +1053,8 @@ static ssize_t iwl_dbgfs_ucode_rx_stats_read(struct file *file,
1053 size_t count, loff_t *ppos) 1053 size_t count, loff_t *ppos)
1054{ 1054{
1055 struct iwl_priv *priv = file->private_data; 1055 struct iwl_priv *priv = file->private_data;
1056 if (priv->cfg->ops->lib->debugfs_ops.rx_stats_read) 1056 return priv->cfg->ops->lib->debugfs_ops.rx_stats_read(file,
1057 return priv->cfg->ops->lib->debugfs_ops.rx_stats_read(file, 1057 user_buf, count, ppos);
1058 user_buf, count, ppos);
1059 return 0;
1060} 1058}
1061 1059
1062static ssize_t iwl_dbgfs_ucode_tx_stats_read(struct file *file, 1060static ssize_t iwl_dbgfs_ucode_tx_stats_read(struct file *file,
@@ -1064,10 +1062,8 @@ static ssize_t iwl_dbgfs_ucode_tx_stats_read(struct file *file,
1064 size_t count, loff_t *ppos) 1062 size_t count, loff_t *ppos)
1065{ 1063{
1066 struct iwl_priv *priv = file->private_data; 1064 struct iwl_priv *priv = file->private_data;
1067 if (priv->cfg->ops->lib->debugfs_ops.tx_stats_read) 1065 return priv->cfg->ops->lib->debugfs_ops.tx_stats_read(file,
1068 return priv->cfg->ops->lib->debugfs_ops.tx_stats_read(file, 1066 user_buf, count, ppos);
1069 user_buf, count, ppos);
1070 return 0;
1071} 1067}
1072 1068
1073static ssize_t iwl_dbgfs_ucode_general_stats_read(struct file *file, 1069static ssize_t iwl_dbgfs_ucode_general_stats_read(struct file *file,
@@ -1075,10 +1071,8 @@ static ssize_t iwl_dbgfs_ucode_general_stats_read(struct file *file,
1075 size_t count, loff_t *ppos) 1071 size_t count, loff_t *ppos)
1076{ 1072{
1077 struct iwl_priv *priv = file->private_data; 1073 struct iwl_priv *priv = file->private_data;
1078 if (priv->cfg->ops->lib->debugfs_ops.general_stats_read) 1074 return priv->cfg->ops->lib->debugfs_ops.general_stats_read(file,
1079 return priv->cfg->ops->lib->debugfs_ops.general_stats_read(file, 1075 user_buf, count, ppos);
1080 user_buf, count, ppos);
1081 return 0;
1082} 1076}
1083 1077
1084static ssize_t iwl_dbgfs_sensitivity_read(struct file *file, 1078static ssize_t iwl_dbgfs_sensitivity_read(struct file *file,
diff --git a/drivers/net/wireless/iwlwifi/iwl-dev.h b/drivers/net/wireless/iwlwifi/iwl-dev.h
index bdc60aae75ec..58c69a5798d4 100644
--- a/drivers/net/wireless/iwlwifi/iwl-dev.h
+++ b/drivers/net/wireless/iwlwifi/iwl-dev.h
@@ -1202,6 +1202,11 @@ struct iwl_priv {
1202 struct delayed_work rfkill_poll; 1202 struct delayed_work rfkill_poll;
1203 1203
1204 struct iwl3945_notif_statistics statistics; 1204 struct iwl3945_notif_statistics statistics;
1205#ifdef CONFIG_IWLWIFI_DEBUG
1206 struct iwl3945_notif_statistics accum_statistics;
1207 struct iwl3945_notif_statistics delta_statistics;
1208 struct iwl3945_notif_statistics max_delta;
1209#endif
1205 1210
1206 u32 sta_supp_rates; 1211 u32 sta_supp_rates;
1207 int last_rx_rssi; /* From Rx packet statistics */ 1212 int last_rx_rssi; /* From Rx packet statistics */
diff --git a/drivers/net/wireless/iwlwifi/iwl3945-base.c b/drivers/net/wireless/iwlwifi/iwl3945-base.c
index 789480b89a6e..98055fb5caf0 100644
--- a/drivers/net/wireless/iwlwifi/iwl3945-base.c
+++ b/drivers/net/wireless/iwlwifi/iwl3945-base.c
@@ -956,7 +956,7 @@ static void iwl3945_setup_rx_handlers(struct iwl_priv *priv)
956 * statistics request from the host as well as for the periodic 956 * statistics request from the host as well as for the periodic
957 * statistics notifications (after received beacons) from the uCode. 957 * statistics notifications (after received beacons) from the uCode.
958 */ 958 */
959 priv->rx_handlers[REPLY_STATISTICS_CMD] = iwl3945_hw_rx_statistics; 959 priv->rx_handlers[REPLY_STATISTICS_CMD] = iwl3945_reply_statistics;
960 priv->rx_handlers[STATISTICS_NOTIFICATION] = iwl3945_hw_rx_statistics; 960 priv->rx_handlers[STATISTICS_NOTIFICATION] = iwl3945_hw_rx_statistics;
961 961
962 iwl_setup_rx_scan_handlers(priv); 962 iwl_setup_rx_scan_handlers(priv);