Linux Audio

Check our new training course

Loading...
v6.8
  1// SPDX-License-Identifier: GPL-2.0-only
  2/******************************************************************************
  3 *
 
 
  4 * Copyright(c) 2008 - 2011 Intel Corporation. All rights reserved.
  5 *
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
  6 * Contact Information:
  7 *  Intel Linux Wireless <ilw@linux.intel.com>
  8 * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
  9 *****************************************************************************/
 10
 11#include "common.h"
 12#include "3945.h"
 13
 14static int
 15il3945_stats_flag(struct il_priv *il, char *buf, int bufsz)
 16{
 17	int p = 0;
 18
 19	p += scnprintf(buf + p, bufsz - p, "Statistics Flag(0x%X):\n",
 20		       le32_to_cpu(il->_3945.stats.flag));
 21	if (le32_to_cpu(il->_3945.stats.flag) & UCODE_STATS_CLEAR_MSK)
 22		p += scnprintf(buf + p, bufsz - p,
 23			       "\tStatistics have been cleared\n");
 24	p += scnprintf(buf + p, bufsz - p, "\tOperational Frequency: %s\n",
 25		       (le32_to_cpu(il->_3945.stats.flag) &
 26			UCODE_STATS_FREQUENCY_MSK) ? "2.4 GHz" : "5.2 GHz");
 27	p += scnprintf(buf + p, bufsz - p, "\tTGj Narrow Band: %s\n",
 28		       (le32_to_cpu(il->_3945.stats.flag) &
 29			UCODE_STATS_NARROW_BAND_MSK) ? "enabled" : "disabled");
 30	return p;
 31}
 32
 33static ssize_t
 34il3945_ucode_rx_stats_read(struct file *file, char __user *user_buf,
 35			   size_t count, loff_t *ppos)
 36{
 37	struct il_priv *il = file->private_data;
 38	int pos = 0;
 39	char *buf;
 40	int bufsz =
 41	    sizeof(struct iwl39_stats_rx_phy) * 40 +
 42	    sizeof(struct iwl39_stats_rx_non_phy) * 40 + 400;
 43	ssize_t ret;
 44	struct iwl39_stats_rx_phy *ofdm, *accum_ofdm, *delta_ofdm, *max_ofdm;
 45	struct iwl39_stats_rx_phy *cck, *accum_cck, *delta_cck, *max_cck;
 46	struct iwl39_stats_rx_non_phy *general, *accum_general;
 47	struct iwl39_stats_rx_non_phy *delta_general, *max_general;
 48
 49	if (!il_is_alive(il))
 50		return -EAGAIN;
 51
 52	buf = kzalloc(bufsz, GFP_KERNEL);
 53	if (!buf) {
 54		IL_ERR("Can not allocate Buffer\n");
 55		return -ENOMEM;
 56	}
 57
 58	/*
 59	 * The statistic information display here is based on
 60	 * the last stats notification from uCode
 61	 * might not reflect the current uCode activity
 62	 */
 63	ofdm = &il->_3945.stats.rx.ofdm;
 64	cck = &il->_3945.stats.rx.cck;
 65	general = &il->_3945.stats.rx.general;
 66	accum_ofdm = &il->_3945.accum_stats.rx.ofdm;
 67	accum_cck = &il->_3945.accum_stats.rx.cck;
 68	accum_general = &il->_3945.accum_stats.rx.general;
 69	delta_ofdm = &il->_3945.delta_stats.rx.ofdm;
 70	delta_cck = &il->_3945.delta_stats.rx.cck;
 71	delta_general = &il->_3945.delta_stats.rx.general;
 72	max_ofdm = &il->_3945.max_delta.rx.ofdm;
 73	max_cck = &il->_3945.max_delta.rx.cck;
 74	max_general = &il->_3945.max_delta.rx.general;
 75
 76	pos += il3945_stats_flag(il, buf, bufsz);
 77	pos +=
 78	    scnprintf(buf + pos, bufsz - pos,
 79		      "%-32s     current"
 80		      "accumulative      delta         max\n",
 81		      "Statistics_Rx - OFDM:");
 82	pos +=
 83	    scnprintf(buf + pos, bufsz - pos,
 84		      "  %-30s %10u  %10u  %10u  %10u\n", "ina_cnt:",
 85		      le32_to_cpu(ofdm->ina_cnt), accum_ofdm->ina_cnt,
 86		      delta_ofdm->ina_cnt, max_ofdm->ina_cnt);
 87	pos +=
 88	    scnprintf(buf + pos, bufsz - pos,
 89		      "  %-30s %10u  %10u  %10u  %10u\n", "fina_cnt:",
 90		      le32_to_cpu(ofdm->fina_cnt), accum_ofdm->fina_cnt,
 91		      delta_ofdm->fina_cnt, max_ofdm->fina_cnt);
 92	pos +=
 93	    scnprintf(buf + pos, bufsz - pos,
 94		      "  %-30s %10u  %10u  %10u  %10u\n", "plcp_err:",
 95		      le32_to_cpu(ofdm->plcp_err), accum_ofdm->plcp_err,
 96		      delta_ofdm->plcp_err, max_ofdm->plcp_err);
 97	pos +=
 98	    scnprintf(buf + pos, bufsz - pos,
 99		      "  %-30s %10u  %10u  %10u  %10u\n", "crc32_err:",
100		      le32_to_cpu(ofdm->crc32_err), accum_ofdm->crc32_err,
101		      delta_ofdm->crc32_err, max_ofdm->crc32_err);
102	pos +=
103	    scnprintf(buf + pos, bufsz - pos,
104		      "  %-30s %10u  %10u  %10u  %10u\n", "overrun_err:",
105		      le32_to_cpu(ofdm->overrun_err), accum_ofdm->overrun_err,
106		      delta_ofdm->overrun_err, max_ofdm->overrun_err);
107	pos +=
108	    scnprintf(buf + pos, bufsz - pos,
109		      "  %-30s %10u  %10u  %10u  %10u\n", "early_overrun_err:",
110		      le32_to_cpu(ofdm->early_overrun_err),
111		      accum_ofdm->early_overrun_err,
112		      delta_ofdm->early_overrun_err,
113		      max_ofdm->early_overrun_err);
114	pos +=
115	    scnprintf(buf + pos, bufsz - pos,
116		      "  %-30s %10u  %10u  %10u  %10u\n", "crc32_good:",
117		      le32_to_cpu(ofdm->crc32_good), accum_ofdm->crc32_good,
118		      delta_ofdm->crc32_good, max_ofdm->crc32_good);
119	pos +=
120	    scnprintf(buf + pos, bufsz - pos,
121		      "  %-30s %10u  %10u  %10u  %10u\n", "false_alarm_cnt:",
122		      le32_to_cpu(ofdm->false_alarm_cnt),
123		      accum_ofdm->false_alarm_cnt, delta_ofdm->false_alarm_cnt,
124		      max_ofdm->false_alarm_cnt);
125	pos +=
126	    scnprintf(buf + pos, bufsz - pos,
127		      "  %-30s %10u  %10u  %10u  %10u\n", "fina_sync_err_cnt:",
128		      le32_to_cpu(ofdm->fina_sync_err_cnt),
129		      accum_ofdm->fina_sync_err_cnt,
130		      delta_ofdm->fina_sync_err_cnt,
131		      max_ofdm->fina_sync_err_cnt);
132	pos +=
133	    scnprintf(buf + pos, bufsz - pos,
134		      "  %-30s %10u  %10u  %10u  %10u\n", "sfd_timeout:",
135		      le32_to_cpu(ofdm->sfd_timeout), accum_ofdm->sfd_timeout,
136		      delta_ofdm->sfd_timeout, max_ofdm->sfd_timeout);
137	pos +=
138	    scnprintf(buf + pos, bufsz - pos,
139		      "  %-30s %10u  %10u  %10u  %10u\n", "fina_timeout:",
140		      le32_to_cpu(ofdm->fina_timeout), accum_ofdm->fina_timeout,
141		      delta_ofdm->fina_timeout, max_ofdm->fina_timeout);
142	pos +=
143	    scnprintf(buf + pos, bufsz - pos,
144		      "  %-30s %10u  %10u  %10u  %10u\n", "unresponded_rts:",
145		      le32_to_cpu(ofdm->unresponded_rts),
146		      accum_ofdm->unresponded_rts, delta_ofdm->unresponded_rts,
147		      max_ofdm->unresponded_rts);
148	pos +=
149	    scnprintf(buf + pos, bufsz - pos,
150		      "  %-30s %10u  %10u  %10u  %10u\n",
151		      "rxe_frame_lmt_ovrun:",
152		      le32_to_cpu(ofdm->rxe_frame_limit_overrun),
153		      accum_ofdm->rxe_frame_limit_overrun,
154		      delta_ofdm->rxe_frame_limit_overrun,
155		      max_ofdm->rxe_frame_limit_overrun);
156	pos +=
157	    scnprintf(buf + pos, bufsz - pos,
158		      "  %-30s %10u  %10u  %10u  %10u\n", "sent_ack_cnt:",
159		      le32_to_cpu(ofdm->sent_ack_cnt), accum_ofdm->sent_ack_cnt,
160		      delta_ofdm->sent_ack_cnt, max_ofdm->sent_ack_cnt);
161	pos +=
162	    scnprintf(buf + pos, bufsz - pos,
163		      "  %-30s %10u  %10u  %10u  %10u\n", "sent_cts_cnt:",
164		      le32_to_cpu(ofdm->sent_cts_cnt), accum_ofdm->sent_cts_cnt,
165		      delta_ofdm->sent_cts_cnt, max_ofdm->sent_cts_cnt);
166
167	pos +=
168	    scnprintf(buf + pos, bufsz - pos,
169		      "%-32s     current"
170		      "accumulative      delta         max\n",
171		      "Statistics_Rx - CCK:");
172	pos +=
173	    scnprintf(buf + pos, bufsz - pos,
174		      "  %-30s %10u  %10u  %10u  %10u\n", "ina_cnt:",
175		      le32_to_cpu(cck->ina_cnt), accum_cck->ina_cnt,
176		      delta_cck->ina_cnt, max_cck->ina_cnt);
177	pos +=
178	    scnprintf(buf + pos, bufsz - pos,
179		      "  %-30s %10u  %10u  %10u  %10u\n", "fina_cnt:",
180		      le32_to_cpu(cck->fina_cnt), accum_cck->fina_cnt,
181		      delta_cck->fina_cnt, max_cck->fina_cnt);
182	pos +=
183	    scnprintf(buf + pos, bufsz - pos,
184		      "  %-30s %10u  %10u  %10u  %10u\n", "plcp_err:",
185		      le32_to_cpu(cck->plcp_err), accum_cck->plcp_err,
186		      delta_cck->plcp_err, max_cck->plcp_err);
187	pos +=
188	    scnprintf(buf + pos, bufsz - pos,
189		      "  %-30s %10u  %10u  %10u  %10u\n", "crc32_err:",
190		      le32_to_cpu(cck->crc32_err), accum_cck->crc32_err,
191		      delta_cck->crc32_err, max_cck->crc32_err);
192	pos +=
193	    scnprintf(buf + pos, bufsz - pos,
194		      "  %-30s %10u  %10u  %10u  %10u\n", "overrun_err:",
195		      le32_to_cpu(cck->overrun_err), accum_cck->overrun_err,
196		      delta_cck->overrun_err, max_cck->overrun_err);
197	pos +=
198	    scnprintf(buf + pos, bufsz - pos,
199		      "  %-30s %10u  %10u  %10u  %10u\n", "early_overrun_err:",
200		      le32_to_cpu(cck->early_overrun_err),
201		      accum_cck->early_overrun_err,
202		      delta_cck->early_overrun_err, max_cck->early_overrun_err);
203	pos +=
204	    scnprintf(buf + pos, bufsz - pos,
205		      "  %-30s %10u  %10u  %10u  %10u\n", "crc32_good:",
206		      le32_to_cpu(cck->crc32_good), accum_cck->crc32_good,
207		      delta_cck->crc32_good, max_cck->crc32_good);
208	pos +=
209	    scnprintf(buf + pos, bufsz - pos,
210		      "  %-30s %10u  %10u  %10u  %10u\n", "false_alarm_cnt:",
211		      le32_to_cpu(cck->false_alarm_cnt),
212		      accum_cck->false_alarm_cnt, delta_cck->false_alarm_cnt,
213		      max_cck->false_alarm_cnt);
214	pos +=
215	    scnprintf(buf + pos, bufsz - pos,
216		      "  %-30s %10u  %10u  %10u  %10u\n", "fina_sync_err_cnt:",
217		      le32_to_cpu(cck->fina_sync_err_cnt),
218		      accum_cck->fina_sync_err_cnt,
219		      delta_cck->fina_sync_err_cnt, max_cck->fina_sync_err_cnt);
220	pos +=
221	    scnprintf(buf + pos, bufsz - pos,
222		      "  %-30s %10u  %10u  %10u  %10u\n", "sfd_timeout:",
223		      le32_to_cpu(cck->sfd_timeout), accum_cck->sfd_timeout,
224		      delta_cck->sfd_timeout, max_cck->sfd_timeout);
225	pos +=
226	    scnprintf(buf + pos, bufsz - pos,
227		      "  %-30s %10u  %10u  %10u  %10u\n", "fina_timeout:",
228		      le32_to_cpu(cck->fina_timeout), accum_cck->fina_timeout,
229		      delta_cck->fina_timeout, max_cck->fina_timeout);
230	pos +=
231	    scnprintf(buf + pos, bufsz - pos,
232		      "  %-30s %10u  %10u  %10u  %10u\n", "unresponded_rts:",
233		      le32_to_cpu(cck->unresponded_rts),
234		      accum_cck->unresponded_rts, delta_cck->unresponded_rts,
235		      max_cck->unresponded_rts);
236	pos +=
237	    scnprintf(buf + pos, bufsz - pos,
238		      "  %-30s %10u  %10u  %10u  %10u\n",
239		      "rxe_frame_lmt_ovrun:",
240		      le32_to_cpu(cck->rxe_frame_limit_overrun),
241		      accum_cck->rxe_frame_limit_overrun,
242		      delta_cck->rxe_frame_limit_overrun,
243		      max_cck->rxe_frame_limit_overrun);
244	pos +=
245	    scnprintf(buf + pos, bufsz - pos,
246		      "  %-30s %10u  %10u  %10u  %10u\n", "sent_ack_cnt:",
247		      le32_to_cpu(cck->sent_ack_cnt), accum_cck->sent_ack_cnt,
248		      delta_cck->sent_ack_cnt, max_cck->sent_ack_cnt);
249	pos +=
250	    scnprintf(buf + pos, bufsz - pos,
251		      "  %-30s %10u  %10u  %10u  %10u\n", "sent_cts_cnt:",
252		      le32_to_cpu(cck->sent_cts_cnt), accum_cck->sent_cts_cnt,
253		      delta_cck->sent_cts_cnt, max_cck->sent_cts_cnt);
254
255	pos +=
256	    scnprintf(buf + pos, bufsz - pos,
257		      "%-32s     current"
258		      "accumulative      delta         max\n",
259		      "Statistics_Rx - GENERAL:");
260	pos +=
261	    scnprintf(buf + pos, bufsz - pos,
262		      "  %-30s %10u  %10u  %10u  %10u\n", "bogus_cts:",
263		      le32_to_cpu(general->bogus_cts), accum_general->bogus_cts,
264		      delta_general->bogus_cts, max_general->bogus_cts);
265	pos +=
266	    scnprintf(buf + pos, bufsz - pos,
267		      "  %-30s %10u  %10u  %10u  %10u\n", "bogus_ack:",
268		      le32_to_cpu(general->bogus_ack), accum_general->bogus_ack,
269		      delta_general->bogus_ack, max_general->bogus_ack);
270	pos +=
271	    scnprintf(buf + pos, bufsz - pos,
272		      "  %-30s %10u  %10u  %10u  %10u\n", "non_bssid_frames:",
273		      le32_to_cpu(general->non_bssid_frames),
274		      accum_general->non_bssid_frames,
275		      delta_general->non_bssid_frames,
276		      max_general->non_bssid_frames);
277	pos +=
278	    scnprintf(buf + pos, bufsz - pos,
279		      "  %-30s %10u  %10u  %10u  %10u\n", "filtered_frames:",
280		      le32_to_cpu(general->filtered_frames),
281		      accum_general->filtered_frames,
282		      delta_general->filtered_frames,
283		      max_general->filtered_frames);
284	pos +=
285	    scnprintf(buf + pos, bufsz - pos,
286		      "  %-30s %10u  %10u  %10u  %10u\n",
287		      "non_channel_beacons:",
288		      le32_to_cpu(general->non_channel_beacons),
289		      accum_general->non_channel_beacons,
290		      delta_general->non_channel_beacons,
291		      max_general->non_channel_beacons);
292
293	ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos);
294	kfree(buf);
295	return ret;
296}
297
298static ssize_t
299il3945_ucode_tx_stats_read(struct file *file, char __user *user_buf,
300			   size_t count, loff_t *ppos)
301{
302	struct il_priv *il = file->private_data;
303	int pos = 0;
304	char *buf;
305	int bufsz = (sizeof(struct iwl39_stats_tx) * 48) + 250;
306	ssize_t ret;
307	struct iwl39_stats_tx *tx, *accum_tx, *delta_tx, *max_tx;
308
309	if (!il_is_alive(il))
310		return -EAGAIN;
311
312	buf = kzalloc(bufsz, GFP_KERNEL);
313	if (!buf) {
314		IL_ERR("Can not allocate Buffer\n");
315		return -ENOMEM;
316	}
317
318	/*
319	 * The statistic information display here is based on
320	 * the last stats notification from uCode
321	 * might not reflect the current uCode activity
322	 */
323	tx = &il->_3945.stats.tx;
324	accum_tx = &il->_3945.accum_stats.tx;
325	delta_tx = &il->_3945.delta_stats.tx;
326	max_tx = &il->_3945.max_delta.tx;
327	pos += il3945_stats_flag(il, buf, bufsz);
328	pos +=
329	    scnprintf(buf + pos, bufsz - pos,
330		      "%-32s     current"
331		      "accumulative      delta         max\n",
332		      "Statistics_Tx:");
333	pos +=
334	    scnprintf(buf + pos, bufsz - pos,
335		      "  %-30s %10u  %10u  %10u  %10u\n", "preamble:",
336		      le32_to_cpu(tx->preamble_cnt), accum_tx->preamble_cnt,
337		      delta_tx->preamble_cnt, max_tx->preamble_cnt);
338	pos +=
339	    scnprintf(buf + pos, bufsz - pos,
340		      "  %-30s %10u  %10u  %10u  %10u\n", "rx_detected_cnt:",
341		      le32_to_cpu(tx->rx_detected_cnt),
342		      accum_tx->rx_detected_cnt, delta_tx->rx_detected_cnt,
343		      max_tx->rx_detected_cnt);
344	pos +=
345	    scnprintf(buf + pos, bufsz - pos,
346		      "  %-30s %10u  %10u  %10u  %10u\n", "bt_prio_defer_cnt:",
347		      le32_to_cpu(tx->bt_prio_defer_cnt),
348		      accum_tx->bt_prio_defer_cnt, delta_tx->bt_prio_defer_cnt,
349		      max_tx->bt_prio_defer_cnt);
350	pos +=
351	    scnprintf(buf + pos, bufsz - pos,
352		      "  %-30s %10u  %10u  %10u  %10u\n", "bt_prio_kill_cnt:",
353		      le32_to_cpu(tx->bt_prio_kill_cnt),
354		      accum_tx->bt_prio_kill_cnt, delta_tx->bt_prio_kill_cnt,
355		      max_tx->bt_prio_kill_cnt);
356	pos +=
357	    scnprintf(buf + pos, bufsz - pos,
358		      "  %-30s %10u  %10u  %10u  %10u\n", "few_bytes_cnt:",
359		      le32_to_cpu(tx->few_bytes_cnt), accum_tx->few_bytes_cnt,
360		      delta_tx->few_bytes_cnt, max_tx->few_bytes_cnt);
361	pos +=
362	    scnprintf(buf + pos, bufsz - pos,
363		      "  %-30s %10u  %10u  %10u  %10u\n", "cts_timeout:",
364		      le32_to_cpu(tx->cts_timeout), accum_tx->cts_timeout,
365		      delta_tx->cts_timeout, max_tx->cts_timeout);
366	pos +=
367	    scnprintf(buf + pos, bufsz - pos,
368		      "  %-30s %10u  %10u  %10u  %10u\n", "ack_timeout:",
369		      le32_to_cpu(tx->ack_timeout), accum_tx->ack_timeout,
370		      delta_tx->ack_timeout, max_tx->ack_timeout);
371	pos +=
372	    scnprintf(buf + pos, bufsz - pos,
373		      "  %-30s %10u  %10u  %10u  %10u\n", "expected_ack_cnt:",
374		      le32_to_cpu(tx->expected_ack_cnt),
375		      accum_tx->expected_ack_cnt, delta_tx->expected_ack_cnt,
376		      max_tx->expected_ack_cnt);
377	pos +=
378	    scnprintf(buf + pos, bufsz - pos,
379		      "  %-30s %10u  %10u  %10u  %10u\n", "actual_ack_cnt:",
380		      le32_to_cpu(tx->actual_ack_cnt), accum_tx->actual_ack_cnt,
381		      delta_tx->actual_ack_cnt, max_tx->actual_ack_cnt);
382
383	ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos);
384	kfree(buf);
385	return ret;
386}
387
388static ssize_t
389il3945_ucode_general_stats_read(struct file *file, char __user *user_buf,
390				size_t count, loff_t *ppos)
391{
392	struct il_priv *il = file->private_data;
393	int pos = 0;
394	char *buf;
395	int bufsz = sizeof(struct iwl39_stats_general) * 10 + 300;
396	ssize_t ret;
397	struct iwl39_stats_general *general, *accum_general;
398	struct iwl39_stats_general *delta_general, *max_general;
399	struct stats_dbg *dbg, *accum_dbg, *delta_dbg, *max_dbg;
400	struct iwl39_stats_div *div, *accum_div, *delta_div, *max_div;
401
402	if (!il_is_alive(il))
403		return -EAGAIN;
404
405	buf = kzalloc(bufsz, GFP_KERNEL);
406	if (!buf) {
407		IL_ERR("Can not allocate Buffer\n");
408		return -ENOMEM;
409	}
410
411	/*
412	 * The statistic information display here is based on
413	 * the last stats notification from uCode
414	 * might not reflect the current uCode activity
415	 */
416	general = &il->_3945.stats.general;
417	dbg = &il->_3945.stats.general.dbg;
418	div = &il->_3945.stats.general.div;
419	accum_general = &il->_3945.accum_stats.general;
420	delta_general = &il->_3945.delta_stats.general;
421	max_general = &il->_3945.max_delta.general;
422	accum_dbg = &il->_3945.accum_stats.general.dbg;
423	delta_dbg = &il->_3945.delta_stats.general.dbg;
424	max_dbg = &il->_3945.max_delta.general.dbg;
425	accum_div = &il->_3945.accum_stats.general.div;
426	delta_div = &il->_3945.delta_stats.general.div;
427	max_div = &il->_3945.max_delta.general.div;
428	pos += il3945_stats_flag(il, buf, bufsz);
429	pos +=
430	    scnprintf(buf + pos, bufsz - pos,
431		      "%-32s     current"
432		      "accumulative      delta         max\n",
433		      "Statistics_General:");
434	pos +=
435	    scnprintf(buf + pos, bufsz - pos,
436		      "  %-30s %10u  %10u  %10u  %10u\n", "burst_check:",
437		      le32_to_cpu(dbg->burst_check), accum_dbg->burst_check,
438		      delta_dbg->burst_check, max_dbg->burst_check);
439	pos +=
440	    scnprintf(buf + pos, bufsz - pos,
441		      "  %-30s %10u  %10u  %10u  %10u\n", "burst_count:",
442		      le32_to_cpu(dbg->burst_count), accum_dbg->burst_count,
443		      delta_dbg->burst_count, max_dbg->burst_count);
444	pos +=
445	    scnprintf(buf + pos, bufsz - pos,
446		      "  %-30s %10u  %10u  %10u  %10u\n", "sleep_time:",
447		      le32_to_cpu(general->sleep_time),
448		      accum_general->sleep_time, delta_general->sleep_time,
449		      max_general->sleep_time);
450	pos +=
451	    scnprintf(buf + pos, bufsz - pos,
452		      "  %-30s %10u  %10u  %10u  %10u\n", "slots_out:",
453		      le32_to_cpu(general->slots_out), accum_general->slots_out,
454		      delta_general->slots_out, max_general->slots_out);
455	pos +=
456	    scnprintf(buf + pos, bufsz - pos,
457		      "  %-30s %10u  %10u  %10u  %10u\n", "slots_idle:",
458		      le32_to_cpu(general->slots_idle),
459		      accum_general->slots_idle, delta_general->slots_idle,
460		      max_general->slots_idle);
461	pos +=
462	    scnprintf(buf + pos, bufsz - pos, "ttl_timestamp:\t\t\t%u\n",
463		      le32_to_cpu(general->ttl_timestamp));
464	pos +=
465	    scnprintf(buf + pos, bufsz - pos,
466		      "  %-30s %10u  %10u  %10u  %10u\n", "tx_on_a:",
467		      le32_to_cpu(div->tx_on_a), accum_div->tx_on_a,
468		      delta_div->tx_on_a, max_div->tx_on_a);
469	pos +=
470	    scnprintf(buf + pos, bufsz - pos,
471		      "  %-30s %10u  %10u  %10u  %10u\n", "tx_on_b:",
472		      le32_to_cpu(div->tx_on_b), accum_div->tx_on_b,
473		      delta_div->tx_on_b, max_div->tx_on_b);
474	pos +=
475	    scnprintf(buf + pos, bufsz - pos,
476		      "  %-30s %10u  %10u  %10u  %10u\n", "exec_time:",
477		      le32_to_cpu(div->exec_time), accum_div->exec_time,
478		      delta_div->exec_time, max_div->exec_time);
479	pos +=
480	    scnprintf(buf + pos, bufsz - pos,
481		      "  %-30s %10u  %10u  %10u  %10u\n", "probe_time:",
482		      le32_to_cpu(div->probe_time), accum_div->probe_time,
483		      delta_div->probe_time, max_div->probe_time);
484	ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos);
485	kfree(buf);
486	return ret;
487}
488
489const struct il_debugfs_ops il3945_debugfs_ops = {
490	.rx_stats_read = il3945_ucode_rx_stats_read,
491	.tx_stats_read = il3945_ucode_tx_stats_read,
492	.general_stats_read = il3945_ucode_general_stats_read,
493};
v4.6
 
  1/******************************************************************************
  2 *
  3 * GPL LICENSE SUMMARY
  4 *
  5 * Copyright(c) 2008 - 2011 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 "common.h"
 30#include "3945.h"
 31
 32static int
 33il3945_stats_flag(struct il_priv *il, char *buf, int bufsz)
 34{
 35	int p = 0;
 36
 37	p += scnprintf(buf + p, bufsz - p, "Statistics Flag(0x%X):\n",
 38		       le32_to_cpu(il->_3945.stats.flag));
 39	if (le32_to_cpu(il->_3945.stats.flag) & UCODE_STATS_CLEAR_MSK)
 40		p += scnprintf(buf + p, bufsz - p,
 41			       "\tStatistics have been cleared\n");
 42	p += scnprintf(buf + p, bufsz - p, "\tOperational Frequency: %s\n",
 43		       (le32_to_cpu(il->_3945.stats.flag) &
 44			UCODE_STATS_FREQUENCY_MSK) ? "2.4 GHz" : "5.2 GHz");
 45	p += scnprintf(buf + p, bufsz - p, "\tTGj Narrow Band: %s\n",
 46		       (le32_to_cpu(il->_3945.stats.flag) &
 47			UCODE_STATS_NARROW_BAND_MSK) ? "enabled" : "disabled");
 48	return p;
 49}
 50
 51static ssize_t
 52il3945_ucode_rx_stats_read(struct file *file, char __user *user_buf,
 53			   size_t count, loff_t *ppos)
 54{
 55	struct il_priv *il = file->private_data;
 56	int pos = 0;
 57	char *buf;
 58	int bufsz =
 59	    sizeof(struct iwl39_stats_rx_phy) * 40 +
 60	    sizeof(struct iwl39_stats_rx_non_phy) * 40 + 400;
 61	ssize_t ret;
 62	struct iwl39_stats_rx_phy *ofdm, *accum_ofdm, *delta_ofdm, *max_ofdm;
 63	struct iwl39_stats_rx_phy *cck, *accum_cck, *delta_cck, *max_cck;
 64	struct iwl39_stats_rx_non_phy *general, *accum_general;
 65	struct iwl39_stats_rx_non_phy *delta_general, *max_general;
 66
 67	if (!il_is_alive(il))
 68		return -EAGAIN;
 69
 70	buf = kzalloc(bufsz, GFP_KERNEL);
 71	if (!buf) {
 72		IL_ERR("Can not allocate Buffer\n");
 73		return -ENOMEM;
 74	}
 75
 76	/*
 77	 * The statistic information display here is based on
 78	 * the last stats notification from uCode
 79	 * might not reflect the current uCode activity
 80	 */
 81	ofdm = &il->_3945.stats.rx.ofdm;
 82	cck = &il->_3945.stats.rx.cck;
 83	general = &il->_3945.stats.rx.general;
 84	accum_ofdm = &il->_3945.accum_stats.rx.ofdm;
 85	accum_cck = &il->_3945.accum_stats.rx.cck;
 86	accum_general = &il->_3945.accum_stats.rx.general;
 87	delta_ofdm = &il->_3945.delta_stats.rx.ofdm;
 88	delta_cck = &il->_3945.delta_stats.rx.cck;
 89	delta_general = &il->_3945.delta_stats.rx.general;
 90	max_ofdm = &il->_3945.max_delta.rx.ofdm;
 91	max_cck = &il->_3945.max_delta.rx.cck;
 92	max_general = &il->_3945.max_delta.rx.general;
 93
 94	pos += il3945_stats_flag(il, buf, bufsz);
 95	pos +=
 96	    scnprintf(buf + pos, bufsz - pos,
 97		      "%-32s     current"
 98		      "acumulative       delta         max\n",
 99		      "Statistics_Rx - OFDM:");
100	pos +=
101	    scnprintf(buf + pos, bufsz - pos,
102		      "  %-30s %10u  %10u  %10u  %10u\n", "ina_cnt:",
103		      le32_to_cpu(ofdm->ina_cnt), accum_ofdm->ina_cnt,
104		      delta_ofdm->ina_cnt, max_ofdm->ina_cnt);
105	pos +=
106	    scnprintf(buf + pos, bufsz - pos,
107		      "  %-30s %10u  %10u  %10u  %10u\n", "fina_cnt:",
108		      le32_to_cpu(ofdm->fina_cnt), accum_ofdm->fina_cnt,
109		      delta_ofdm->fina_cnt, max_ofdm->fina_cnt);
110	pos +=
111	    scnprintf(buf + pos, bufsz - pos,
112		      "  %-30s %10u  %10u  %10u  %10u\n", "plcp_err:",
113		      le32_to_cpu(ofdm->plcp_err), accum_ofdm->plcp_err,
114		      delta_ofdm->plcp_err, max_ofdm->plcp_err);
115	pos +=
116	    scnprintf(buf + pos, bufsz - pos,
117		      "  %-30s %10u  %10u  %10u  %10u\n", "crc32_err:",
118		      le32_to_cpu(ofdm->crc32_err), accum_ofdm->crc32_err,
119		      delta_ofdm->crc32_err, max_ofdm->crc32_err);
120	pos +=
121	    scnprintf(buf + pos, bufsz - pos,
122		      "  %-30s %10u  %10u  %10u  %10u\n", "overrun_err:",
123		      le32_to_cpu(ofdm->overrun_err), accum_ofdm->overrun_err,
124		      delta_ofdm->overrun_err, max_ofdm->overrun_err);
125	pos +=
126	    scnprintf(buf + pos, bufsz - pos,
127		      "  %-30s %10u  %10u  %10u  %10u\n", "early_overrun_err:",
128		      le32_to_cpu(ofdm->early_overrun_err),
129		      accum_ofdm->early_overrun_err,
130		      delta_ofdm->early_overrun_err,
131		      max_ofdm->early_overrun_err);
132	pos +=
133	    scnprintf(buf + pos, bufsz - pos,
134		      "  %-30s %10u  %10u  %10u  %10u\n", "crc32_good:",
135		      le32_to_cpu(ofdm->crc32_good), accum_ofdm->crc32_good,
136		      delta_ofdm->crc32_good, max_ofdm->crc32_good);
137	pos +=
138	    scnprintf(buf + pos, bufsz - pos,
139		      "  %-30s %10u  %10u  %10u  %10u\n", "false_alarm_cnt:",
140		      le32_to_cpu(ofdm->false_alarm_cnt),
141		      accum_ofdm->false_alarm_cnt, delta_ofdm->false_alarm_cnt,
142		      max_ofdm->false_alarm_cnt);
143	pos +=
144	    scnprintf(buf + pos, bufsz - pos,
145		      "  %-30s %10u  %10u  %10u  %10u\n", "fina_sync_err_cnt:",
146		      le32_to_cpu(ofdm->fina_sync_err_cnt),
147		      accum_ofdm->fina_sync_err_cnt,
148		      delta_ofdm->fina_sync_err_cnt,
149		      max_ofdm->fina_sync_err_cnt);
150	pos +=
151	    scnprintf(buf + pos, bufsz - pos,
152		      "  %-30s %10u  %10u  %10u  %10u\n", "sfd_timeout:",
153		      le32_to_cpu(ofdm->sfd_timeout), accum_ofdm->sfd_timeout,
154		      delta_ofdm->sfd_timeout, max_ofdm->sfd_timeout);
155	pos +=
156	    scnprintf(buf + pos, bufsz - pos,
157		      "  %-30s %10u  %10u  %10u  %10u\n", "fina_timeout:",
158		      le32_to_cpu(ofdm->fina_timeout), accum_ofdm->fina_timeout,
159		      delta_ofdm->fina_timeout, max_ofdm->fina_timeout);
160	pos +=
161	    scnprintf(buf + pos, bufsz - pos,
162		      "  %-30s %10u  %10u  %10u  %10u\n", "unresponded_rts:",
163		      le32_to_cpu(ofdm->unresponded_rts),
164		      accum_ofdm->unresponded_rts, delta_ofdm->unresponded_rts,
165		      max_ofdm->unresponded_rts);
166	pos +=
167	    scnprintf(buf + pos, bufsz - pos,
168		      "  %-30s %10u  %10u  %10u  %10u\n",
169		      "rxe_frame_lmt_ovrun:",
170		      le32_to_cpu(ofdm->rxe_frame_limit_overrun),
171		      accum_ofdm->rxe_frame_limit_overrun,
172		      delta_ofdm->rxe_frame_limit_overrun,
173		      max_ofdm->rxe_frame_limit_overrun);
174	pos +=
175	    scnprintf(buf + pos, bufsz - pos,
176		      "  %-30s %10u  %10u  %10u  %10u\n", "sent_ack_cnt:",
177		      le32_to_cpu(ofdm->sent_ack_cnt), accum_ofdm->sent_ack_cnt,
178		      delta_ofdm->sent_ack_cnt, max_ofdm->sent_ack_cnt);
179	pos +=
180	    scnprintf(buf + pos, bufsz - pos,
181		      "  %-30s %10u  %10u  %10u  %10u\n", "sent_cts_cnt:",
182		      le32_to_cpu(ofdm->sent_cts_cnt), accum_ofdm->sent_cts_cnt,
183		      delta_ofdm->sent_cts_cnt, max_ofdm->sent_cts_cnt);
184
185	pos +=
186	    scnprintf(buf + pos, bufsz - pos,
187		      "%-32s     current"
188		      "acumulative       delta         max\n",
189		      "Statistics_Rx - CCK:");
190	pos +=
191	    scnprintf(buf + pos, bufsz - pos,
192		      "  %-30s %10u  %10u  %10u  %10u\n", "ina_cnt:",
193		      le32_to_cpu(cck->ina_cnt), accum_cck->ina_cnt,
194		      delta_cck->ina_cnt, max_cck->ina_cnt);
195	pos +=
196	    scnprintf(buf + pos, bufsz - pos,
197		      "  %-30s %10u  %10u  %10u  %10u\n", "fina_cnt:",
198		      le32_to_cpu(cck->fina_cnt), accum_cck->fina_cnt,
199		      delta_cck->fina_cnt, max_cck->fina_cnt);
200	pos +=
201	    scnprintf(buf + pos, bufsz - pos,
202		      "  %-30s %10u  %10u  %10u  %10u\n", "plcp_err:",
203		      le32_to_cpu(cck->plcp_err), accum_cck->plcp_err,
204		      delta_cck->plcp_err, max_cck->plcp_err);
205	pos +=
206	    scnprintf(buf + pos, bufsz - pos,
207		      "  %-30s %10u  %10u  %10u  %10u\n", "crc32_err:",
208		      le32_to_cpu(cck->crc32_err), accum_cck->crc32_err,
209		      delta_cck->crc32_err, max_cck->crc32_err);
210	pos +=
211	    scnprintf(buf + pos, bufsz - pos,
212		      "  %-30s %10u  %10u  %10u  %10u\n", "overrun_err:",
213		      le32_to_cpu(cck->overrun_err), accum_cck->overrun_err,
214		      delta_cck->overrun_err, max_cck->overrun_err);
215	pos +=
216	    scnprintf(buf + pos, bufsz - pos,
217		      "  %-30s %10u  %10u  %10u  %10u\n", "early_overrun_err:",
218		      le32_to_cpu(cck->early_overrun_err),
219		      accum_cck->early_overrun_err,
220		      delta_cck->early_overrun_err, max_cck->early_overrun_err);
221	pos +=
222	    scnprintf(buf + pos, bufsz - pos,
223		      "  %-30s %10u  %10u  %10u  %10u\n", "crc32_good:",
224		      le32_to_cpu(cck->crc32_good), accum_cck->crc32_good,
225		      delta_cck->crc32_good, max_cck->crc32_good);
226	pos +=
227	    scnprintf(buf + pos, bufsz - pos,
228		      "  %-30s %10u  %10u  %10u  %10u\n", "false_alarm_cnt:",
229		      le32_to_cpu(cck->false_alarm_cnt),
230		      accum_cck->false_alarm_cnt, delta_cck->false_alarm_cnt,
231		      max_cck->false_alarm_cnt);
232	pos +=
233	    scnprintf(buf + pos, bufsz - pos,
234		      "  %-30s %10u  %10u  %10u  %10u\n", "fina_sync_err_cnt:",
235		      le32_to_cpu(cck->fina_sync_err_cnt),
236		      accum_cck->fina_sync_err_cnt,
237		      delta_cck->fina_sync_err_cnt, max_cck->fina_sync_err_cnt);
238	pos +=
239	    scnprintf(buf + pos, bufsz - pos,
240		      "  %-30s %10u  %10u  %10u  %10u\n", "sfd_timeout:",
241		      le32_to_cpu(cck->sfd_timeout), accum_cck->sfd_timeout,
242		      delta_cck->sfd_timeout, max_cck->sfd_timeout);
243	pos +=
244	    scnprintf(buf + pos, bufsz - pos,
245		      "  %-30s %10u  %10u  %10u  %10u\n", "fina_timeout:",
246		      le32_to_cpu(cck->fina_timeout), accum_cck->fina_timeout,
247		      delta_cck->fina_timeout, max_cck->fina_timeout);
248	pos +=
249	    scnprintf(buf + pos, bufsz - pos,
250		      "  %-30s %10u  %10u  %10u  %10u\n", "unresponded_rts:",
251		      le32_to_cpu(cck->unresponded_rts),
252		      accum_cck->unresponded_rts, delta_cck->unresponded_rts,
253		      max_cck->unresponded_rts);
254	pos +=
255	    scnprintf(buf + pos, bufsz - pos,
256		      "  %-30s %10u  %10u  %10u  %10u\n",
257		      "rxe_frame_lmt_ovrun:",
258		      le32_to_cpu(cck->rxe_frame_limit_overrun),
259		      accum_cck->rxe_frame_limit_overrun,
260		      delta_cck->rxe_frame_limit_overrun,
261		      max_cck->rxe_frame_limit_overrun);
262	pos +=
263	    scnprintf(buf + pos, bufsz - pos,
264		      "  %-30s %10u  %10u  %10u  %10u\n", "sent_ack_cnt:",
265		      le32_to_cpu(cck->sent_ack_cnt), accum_cck->sent_ack_cnt,
266		      delta_cck->sent_ack_cnt, max_cck->sent_ack_cnt);
267	pos +=
268	    scnprintf(buf + pos, bufsz - pos,
269		      "  %-30s %10u  %10u  %10u  %10u\n", "sent_cts_cnt:",
270		      le32_to_cpu(cck->sent_cts_cnt), accum_cck->sent_cts_cnt,
271		      delta_cck->sent_cts_cnt, max_cck->sent_cts_cnt);
272
273	pos +=
274	    scnprintf(buf + pos, bufsz - pos,
275		      "%-32s     current"
276		      "acumulative       delta         max\n",
277		      "Statistics_Rx - GENERAL:");
278	pos +=
279	    scnprintf(buf + pos, bufsz - pos,
280		      "  %-30s %10u  %10u  %10u  %10u\n", "bogus_cts:",
281		      le32_to_cpu(general->bogus_cts), accum_general->bogus_cts,
282		      delta_general->bogus_cts, max_general->bogus_cts);
283	pos +=
284	    scnprintf(buf + pos, bufsz - pos,
285		      "  %-30s %10u  %10u  %10u  %10u\n", "bogus_ack:",
286		      le32_to_cpu(general->bogus_ack), accum_general->bogus_ack,
287		      delta_general->bogus_ack, max_general->bogus_ack);
288	pos +=
289	    scnprintf(buf + pos, bufsz - pos,
290		      "  %-30s %10u  %10u  %10u  %10u\n", "non_bssid_frames:",
291		      le32_to_cpu(general->non_bssid_frames),
292		      accum_general->non_bssid_frames,
293		      delta_general->non_bssid_frames,
294		      max_general->non_bssid_frames);
295	pos +=
296	    scnprintf(buf + pos, bufsz - pos,
297		      "  %-30s %10u  %10u  %10u  %10u\n", "filtered_frames:",
298		      le32_to_cpu(general->filtered_frames),
299		      accum_general->filtered_frames,
300		      delta_general->filtered_frames,
301		      max_general->filtered_frames);
302	pos +=
303	    scnprintf(buf + pos, bufsz - pos,
304		      "  %-30s %10u  %10u  %10u  %10u\n",
305		      "non_channel_beacons:",
306		      le32_to_cpu(general->non_channel_beacons),
307		      accum_general->non_channel_beacons,
308		      delta_general->non_channel_beacons,
309		      max_general->non_channel_beacons);
310
311	ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos);
312	kfree(buf);
313	return ret;
314}
315
316static ssize_t
317il3945_ucode_tx_stats_read(struct file *file, char __user *user_buf,
318			   size_t count, loff_t *ppos)
319{
320	struct il_priv *il = file->private_data;
321	int pos = 0;
322	char *buf;
323	int bufsz = (sizeof(struct iwl39_stats_tx) * 48) + 250;
324	ssize_t ret;
325	struct iwl39_stats_tx *tx, *accum_tx, *delta_tx, *max_tx;
326
327	if (!il_is_alive(il))
328		return -EAGAIN;
329
330	buf = kzalloc(bufsz, GFP_KERNEL);
331	if (!buf) {
332		IL_ERR("Can not allocate Buffer\n");
333		return -ENOMEM;
334	}
335
336	/*
337	 * The statistic information display here is based on
338	 * the last stats notification from uCode
339	 * might not reflect the current uCode activity
340	 */
341	tx = &il->_3945.stats.tx;
342	accum_tx = &il->_3945.accum_stats.tx;
343	delta_tx = &il->_3945.delta_stats.tx;
344	max_tx = &il->_3945.max_delta.tx;
345	pos += il3945_stats_flag(il, buf, bufsz);
346	pos +=
347	    scnprintf(buf + pos, bufsz - pos,
348		      "%-32s     current"
349		      "acumulative       delta         max\n",
350		      "Statistics_Tx:");
351	pos +=
352	    scnprintf(buf + pos, bufsz - pos,
353		      "  %-30s %10u  %10u  %10u  %10u\n", "preamble:",
354		      le32_to_cpu(tx->preamble_cnt), accum_tx->preamble_cnt,
355		      delta_tx->preamble_cnt, max_tx->preamble_cnt);
356	pos +=
357	    scnprintf(buf + pos, bufsz - pos,
358		      "  %-30s %10u  %10u  %10u  %10u\n", "rx_detected_cnt:",
359		      le32_to_cpu(tx->rx_detected_cnt),
360		      accum_tx->rx_detected_cnt, delta_tx->rx_detected_cnt,
361		      max_tx->rx_detected_cnt);
362	pos +=
363	    scnprintf(buf + pos, bufsz - pos,
364		      "  %-30s %10u  %10u  %10u  %10u\n", "bt_prio_defer_cnt:",
365		      le32_to_cpu(tx->bt_prio_defer_cnt),
366		      accum_tx->bt_prio_defer_cnt, delta_tx->bt_prio_defer_cnt,
367		      max_tx->bt_prio_defer_cnt);
368	pos +=
369	    scnprintf(buf + pos, bufsz - pos,
370		      "  %-30s %10u  %10u  %10u  %10u\n", "bt_prio_kill_cnt:",
371		      le32_to_cpu(tx->bt_prio_kill_cnt),
372		      accum_tx->bt_prio_kill_cnt, delta_tx->bt_prio_kill_cnt,
373		      max_tx->bt_prio_kill_cnt);
374	pos +=
375	    scnprintf(buf + pos, bufsz - pos,
376		      "  %-30s %10u  %10u  %10u  %10u\n", "few_bytes_cnt:",
377		      le32_to_cpu(tx->few_bytes_cnt), accum_tx->few_bytes_cnt,
378		      delta_tx->few_bytes_cnt, max_tx->few_bytes_cnt);
379	pos +=
380	    scnprintf(buf + pos, bufsz - pos,
381		      "  %-30s %10u  %10u  %10u  %10u\n", "cts_timeout:",
382		      le32_to_cpu(tx->cts_timeout), accum_tx->cts_timeout,
383		      delta_tx->cts_timeout, max_tx->cts_timeout);
384	pos +=
385	    scnprintf(buf + pos, bufsz - pos,
386		      "  %-30s %10u  %10u  %10u  %10u\n", "ack_timeout:",
387		      le32_to_cpu(tx->ack_timeout), accum_tx->ack_timeout,
388		      delta_tx->ack_timeout, max_tx->ack_timeout);
389	pos +=
390	    scnprintf(buf + pos, bufsz - pos,
391		      "  %-30s %10u  %10u  %10u  %10u\n", "expected_ack_cnt:",
392		      le32_to_cpu(tx->expected_ack_cnt),
393		      accum_tx->expected_ack_cnt, delta_tx->expected_ack_cnt,
394		      max_tx->expected_ack_cnt);
395	pos +=
396	    scnprintf(buf + pos, bufsz - pos,
397		      "  %-30s %10u  %10u  %10u  %10u\n", "actual_ack_cnt:",
398		      le32_to_cpu(tx->actual_ack_cnt), accum_tx->actual_ack_cnt,
399		      delta_tx->actual_ack_cnt, max_tx->actual_ack_cnt);
400
401	ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos);
402	kfree(buf);
403	return ret;
404}
405
406static ssize_t
407il3945_ucode_general_stats_read(struct file *file, char __user *user_buf,
408				size_t count, loff_t *ppos)
409{
410	struct il_priv *il = file->private_data;
411	int pos = 0;
412	char *buf;
413	int bufsz = sizeof(struct iwl39_stats_general) * 10 + 300;
414	ssize_t ret;
415	struct iwl39_stats_general *general, *accum_general;
416	struct iwl39_stats_general *delta_general, *max_general;
417	struct stats_dbg *dbg, *accum_dbg, *delta_dbg, *max_dbg;
418	struct iwl39_stats_div *div, *accum_div, *delta_div, *max_div;
419
420	if (!il_is_alive(il))
421		return -EAGAIN;
422
423	buf = kzalloc(bufsz, GFP_KERNEL);
424	if (!buf) {
425		IL_ERR("Can not allocate Buffer\n");
426		return -ENOMEM;
427	}
428
429	/*
430	 * The statistic information display here is based on
431	 * the last stats notification from uCode
432	 * might not reflect the current uCode activity
433	 */
434	general = &il->_3945.stats.general;
435	dbg = &il->_3945.stats.general.dbg;
436	div = &il->_3945.stats.general.div;
437	accum_general = &il->_3945.accum_stats.general;
438	delta_general = &il->_3945.delta_stats.general;
439	max_general = &il->_3945.max_delta.general;
440	accum_dbg = &il->_3945.accum_stats.general.dbg;
441	delta_dbg = &il->_3945.delta_stats.general.dbg;
442	max_dbg = &il->_3945.max_delta.general.dbg;
443	accum_div = &il->_3945.accum_stats.general.div;
444	delta_div = &il->_3945.delta_stats.general.div;
445	max_div = &il->_3945.max_delta.general.div;
446	pos += il3945_stats_flag(il, buf, bufsz);
447	pos +=
448	    scnprintf(buf + pos, bufsz - pos,
449		      "%-32s     current"
450		      "acumulative       delta         max\n",
451		      "Statistics_General:");
452	pos +=
453	    scnprintf(buf + pos, bufsz - pos,
454		      "  %-30s %10u  %10u  %10u  %10u\n", "burst_check:",
455		      le32_to_cpu(dbg->burst_check), accum_dbg->burst_check,
456		      delta_dbg->burst_check, max_dbg->burst_check);
457	pos +=
458	    scnprintf(buf + pos, bufsz - pos,
459		      "  %-30s %10u  %10u  %10u  %10u\n", "burst_count:",
460		      le32_to_cpu(dbg->burst_count), accum_dbg->burst_count,
461		      delta_dbg->burst_count, max_dbg->burst_count);
462	pos +=
463	    scnprintf(buf + pos, bufsz - pos,
464		      "  %-30s %10u  %10u  %10u  %10u\n", "sleep_time:",
465		      le32_to_cpu(general->sleep_time),
466		      accum_general->sleep_time, delta_general->sleep_time,
467		      max_general->sleep_time);
468	pos +=
469	    scnprintf(buf + pos, bufsz - pos,
470		      "  %-30s %10u  %10u  %10u  %10u\n", "slots_out:",
471		      le32_to_cpu(general->slots_out), accum_general->slots_out,
472		      delta_general->slots_out, max_general->slots_out);
473	pos +=
474	    scnprintf(buf + pos, bufsz - pos,
475		      "  %-30s %10u  %10u  %10u  %10u\n", "slots_idle:",
476		      le32_to_cpu(general->slots_idle),
477		      accum_general->slots_idle, delta_general->slots_idle,
478		      max_general->slots_idle);
479	pos +=
480	    scnprintf(buf + pos, bufsz - pos, "ttl_timestamp:\t\t\t%u\n",
481		      le32_to_cpu(general->ttl_timestamp));
482	pos +=
483	    scnprintf(buf + pos, bufsz - pos,
484		      "  %-30s %10u  %10u  %10u  %10u\n", "tx_on_a:",
485		      le32_to_cpu(div->tx_on_a), accum_div->tx_on_a,
486		      delta_div->tx_on_a, max_div->tx_on_a);
487	pos +=
488	    scnprintf(buf + pos, bufsz - pos,
489		      "  %-30s %10u  %10u  %10u  %10u\n", "tx_on_b:",
490		      le32_to_cpu(div->tx_on_b), accum_div->tx_on_b,
491		      delta_div->tx_on_b, max_div->tx_on_b);
492	pos +=
493	    scnprintf(buf + pos, bufsz - pos,
494		      "  %-30s %10u  %10u  %10u  %10u\n", "exec_time:",
495		      le32_to_cpu(div->exec_time), accum_div->exec_time,
496		      delta_div->exec_time, max_div->exec_time);
497	pos +=
498	    scnprintf(buf + pos, bufsz - pos,
499		      "  %-30s %10u  %10u  %10u  %10u\n", "probe_time:",
500		      le32_to_cpu(div->probe_time), accum_div->probe_time,
501		      delta_div->probe_time, max_div->probe_time);
502	ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos);
503	kfree(buf);
504	return ret;
505}
506
507const struct il_debugfs_ops il3945_debugfs_ops = {
508	.rx_stats_read = il3945_ucode_rx_stats_read,
509	.tx_stats_read = il3945_ucode_tx_stats_read,
510	.general_stats_read = il3945_ucode_general_stats_read,
511};