Linux Audio

Check our new training course

Open-source upstreaming

Need help get the support for your hardware in upstream Linux?
Loading...
Note: File does not exist in v6.8.
  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#include "iwl-4965.h"
 29#include "iwl-4965-debugfs.h"
 30
 31static const char *fmt_value = "  %-30s %10u\n";
 32static const char *fmt_table = "  %-30s %10u  %10u  %10u  %10u\n";
 33static const char *fmt_header =
 34	"%-32s    current  cumulative       delta         max\n";
 35
 36static int iwl4965_statistics_flag(struct iwl_priv *priv, char *buf, int bufsz)
 37{
 38	int p = 0;
 39	u32 flag;
 40
 41	flag = le32_to_cpu(priv->_4965.statistics.flag);
 42
 43	p += scnprintf(buf + p, bufsz - p, "Statistics Flag(0x%X):\n", flag);
 44	if (flag & UCODE_STATISTICS_CLEAR_MSK)
 45		p += scnprintf(buf + p, bufsz - p,
 46		"\tStatistics have been cleared\n");
 47	p += scnprintf(buf + p, bufsz - p, "\tOperational Frequency: %s\n",
 48		(flag & UCODE_STATISTICS_FREQUENCY_MSK)
 49		? "2.4 GHz" : "5.2 GHz");
 50	p += scnprintf(buf + p, bufsz - p, "\tTGj Narrow Band: %s\n",
 51		(flag & UCODE_STATISTICS_NARROW_BAND_MSK)
 52		 ? "enabled" : "disabled");
 53
 54	return p;
 55}
 56
 57ssize_t iwl4965_ucode_rx_stats_read(struct file *file, char __user *user_buf,
 58				size_t count, loff_t *ppos)
 59{
 60	struct iwl_priv *priv = file->private_data;
 61	int pos = 0;
 62	char *buf;
 63	int bufsz = sizeof(struct statistics_rx_phy) * 40 +
 64		    sizeof(struct statistics_rx_non_phy) * 40 +
 65		    sizeof(struct statistics_rx_ht_phy) * 40 + 400;
 66	ssize_t ret;
 67	struct statistics_rx_phy *ofdm, *accum_ofdm, *delta_ofdm, *max_ofdm;
 68	struct statistics_rx_phy *cck, *accum_cck, *delta_cck, *max_cck;
 69	struct statistics_rx_non_phy *general, *accum_general;
 70	struct statistics_rx_non_phy *delta_general, *max_general;
 71	struct statistics_rx_ht_phy *ht, *accum_ht, *delta_ht, *max_ht;
 72
 73	if (!iwl_legacy_is_alive(priv))
 74		return -EAGAIN;
 75
 76	buf = kzalloc(bufsz, GFP_KERNEL);
 77	if (!buf) {
 78		IWL_ERR(priv, "Can not allocate Buffer\n");
 79		return -ENOMEM;
 80	}
 81
 82	/*
 83	 * the statistic information display here is based on
 84	 * the last statistics notification from uCode
 85	 * might not reflect the current uCode activity
 86	 */
 87	ofdm = &priv->_4965.statistics.rx.ofdm;
 88	cck = &priv->_4965.statistics.rx.cck;
 89	general = &priv->_4965.statistics.rx.general;
 90	ht = &priv->_4965.statistics.rx.ofdm_ht;
 91	accum_ofdm = &priv->_4965.accum_statistics.rx.ofdm;
 92	accum_cck = &priv->_4965.accum_statistics.rx.cck;
 93	accum_general = &priv->_4965.accum_statistics.rx.general;
 94	accum_ht = &priv->_4965.accum_statistics.rx.ofdm_ht;
 95	delta_ofdm = &priv->_4965.delta_statistics.rx.ofdm;
 96	delta_cck = &priv->_4965.delta_statistics.rx.cck;
 97	delta_general = &priv->_4965.delta_statistics.rx.general;
 98	delta_ht = &priv->_4965.delta_statistics.rx.ofdm_ht;
 99	max_ofdm = &priv->_4965.max_delta.rx.ofdm;
100	max_cck = &priv->_4965.max_delta.rx.cck;
101	max_general = &priv->_4965.max_delta.rx.general;
102	max_ht = &priv->_4965.max_delta.rx.ofdm_ht;
103
104	pos += iwl4965_statistics_flag(priv, buf, bufsz);
105	pos += scnprintf(buf + pos, bufsz - pos,
106			 fmt_header, "Statistics_Rx - OFDM:");
107	pos += scnprintf(buf + pos, bufsz - pos,
108			 fmt_table, "ina_cnt:",
109			 le32_to_cpu(ofdm->ina_cnt),
110			 accum_ofdm->ina_cnt,
111			 delta_ofdm->ina_cnt, max_ofdm->ina_cnt);
112	pos += scnprintf(buf + pos, bufsz - pos,
113			 fmt_table, "fina_cnt:",
114			 le32_to_cpu(ofdm->fina_cnt), accum_ofdm->fina_cnt,
115			 delta_ofdm->fina_cnt, max_ofdm->fina_cnt);
116	pos += scnprintf(buf + pos, bufsz - pos,
117			 fmt_table, "plcp_err:",
118			 le32_to_cpu(ofdm->plcp_err), accum_ofdm->plcp_err,
119			 delta_ofdm->plcp_err, max_ofdm->plcp_err);
120	pos += scnprintf(buf + pos, bufsz - pos,
121			 fmt_table, "crc32_err:",
122			 le32_to_cpu(ofdm->crc32_err), accum_ofdm->crc32_err,
123			 delta_ofdm->crc32_err, max_ofdm->crc32_err);
124	pos += scnprintf(buf + pos, bufsz - pos,
125			 fmt_table, "overrun_err:",
126			 le32_to_cpu(ofdm->overrun_err),
127			 accum_ofdm->overrun_err, delta_ofdm->overrun_err,
128			 max_ofdm->overrun_err);
129	pos += scnprintf(buf + pos, bufsz - pos,
130			 fmt_table, "early_overrun_err:",
131			 le32_to_cpu(ofdm->early_overrun_err),
132			 accum_ofdm->early_overrun_err,
133			 delta_ofdm->early_overrun_err,
134			 max_ofdm->early_overrun_err);
135	pos += scnprintf(buf + pos, bufsz - pos,
136			 fmt_table, "crc32_good:",
137			 le32_to_cpu(ofdm->crc32_good),
138			 accum_ofdm->crc32_good, delta_ofdm->crc32_good,
139			 max_ofdm->crc32_good);
140	pos += scnprintf(buf + pos, bufsz - pos,
141			 fmt_table, "false_alarm_cnt:",
142			 le32_to_cpu(ofdm->false_alarm_cnt),
143			 accum_ofdm->false_alarm_cnt,
144			 delta_ofdm->false_alarm_cnt,
145			 max_ofdm->false_alarm_cnt);
146	pos += scnprintf(buf + pos, bufsz - pos,
147			 fmt_table, "fina_sync_err_cnt:",
148			 le32_to_cpu(ofdm->fina_sync_err_cnt),
149			 accum_ofdm->fina_sync_err_cnt,
150			 delta_ofdm->fina_sync_err_cnt,
151			 max_ofdm->fina_sync_err_cnt);
152	pos += scnprintf(buf + pos, bufsz - pos,
153			 fmt_table, "sfd_timeout:",
154			 le32_to_cpu(ofdm->sfd_timeout),
155			 accum_ofdm->sfd_timeout, delta_ofdm->sfd_timeout,
156			 max_ofdm->sfd_timeout);
157	pos += scnprintf(buf + pos, bufsz - pos,
158			 fmt_table, "fina_timeout:",
159			 le32_to_cpu(ofdm->fina_timeout),
160			 accum_ofdm->fina_timeout, delta_ofdm->fina_timeout,
161			 max_ofdm->fina_timeout);
162	pos += scnprintf(buf + pos, bufsz - pos,
163			 fmt_table, "unresponded_rts:",
164			 le32_to_cpu(ofdm->unresponded_rts),
165			 accum_ofdm->unresponded_rts,
166			 delta_ofdm->unresponded_rts,
167			 max_ofdm->unresponded_rts);
168	pos += scnprintf(buf + pos, bufsz - pos,
169			 fmt_table, "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 += scnprintf(buf + pos, bufsz - pos,
175			 fmt_table, "sent_ack_cnt:",
176			 le32_to_cpu(ofdm->sent_ack_cnt),
177			 accum_ofdm->sent_ack_cnt, delta_ofdm->sent_ack_cnt,
178			 max_ofdm->sent_ack_cnt);
179	pos += scnprintf(buf + pos, bufsz - pos,
180			 fmt_table, "sent_cts_cnt:",
181			 le32_to_cpu(ofdm->sent_cts_cnt),
182			 accum_ofdm->sent_cts_cnt, delta_ofdm->sent_cts_cnt,
183			 max_ofdm->sent_cts_cnt);
184	pos += scnprintf(buf + pos, bufsz - pos,
185			 fmt_table, "sent_ba_rsp_cnt:",
186			 le32_to_cpu(ofdm->sent_ba_rsp_cnt),
187			 accum_ofdm->sent_ba_rsp_cnt,
188			 delta_ofdm->sent_ba_rsp_cnt,
189			 max_ofdm->sent_ba_rsp_cnt);
190	pos += scnprintf(buf + pos, bufsz - pos,
191			 fmt_table, "dsp_self_kill:",
192			 le32_to_cpu(ofdm->dsp_self_kill),
193			 accum_ofdm->dsp_self_kill,
194			 delta_ofdm->dsp_self_kill,
195			 max_ofdm->dsp_self_kill);
196	pos += scnprintf(buf + pos, bufsz - pos,
197			 fmt_table, "mh_format_err:",
198			 le32_to_cpu(ofdm->mh_format_err),
199			 accum_ofdm->mh_format_err,
200			 delta_ofdm->mh_format_err,
201			 max_ofdm->mh_format_err);
202	pos += scnprintf(buf + pos, bufsz - pos,
203			 fmt_table, "re_acq_main_rssi_sum:",
204			 le32_to_cpu(ofdm->re_acq_main_rssi_sum),
205			 accum_ofdm->re_acq_main_rssi_sum,
206			 delta_ofdm->re_acq_main_rssi_sum,
207			 max_ofdm->re_acq_main_rssi_sum);
208
209	pos += scnprintf(buf + pos, bufsz - pos,
210			 fmt_header, "Statistics_Rx - CCK:");
211	pos += scnprintf(buf + pos, bufsz - pos,
212			 fmt_table, "ina_cnt:",
213			 le32_to_cpu(cck->ina_cnt), accum_cck->ina_cnt,
214			 delta_cck->ina_cnt, max_cck->ina_cnt);
215	pos += scnprintf(buf + pos, bufsz - pos,
216			 fmt_table, "fina_cnt:",
217			 le32_to_cpu(cck->fina_cnt), accum_cck->fina_cnt,
218			 delta_cck->fina_cnt, max_cck->fina_cnt);
219	pos += scnprintf(buf + pos, bufsz - pos,
220			 fmt_table, "plcp_err:",
221			 le32_to_cpu(cck->plcp_err), accum_cck->plcp_err,
222			 delta_cck->plcp_err, max_cck->plcp_err);
223	pos += scnprintf(buf + pos, bufsz - pos,
224			 fmt_table, "crc32_err:",
225			 le32_to_cpu(cck->crc32_err), accum_cck->crc32_err,
226			 delta_cck->crc32_err, max_cck->crc32_err);
227	pos += scnprintf(buf + pos, bufsz - pos,
228			 fmt_table, "overrun_err:",
229			 le32_to_cpu(cck->overrun_err),
230			 accum_cck->overrun_err, delta_cck->overrun_err,
231			 max_cck->overrun_err);
232	pos += scnprintf(buf + pos, bufsz - pos,
233			 fmt_table, "early_overrun_err:",
234			 le32_to_cpu(cck->early_overrun_err),
235			 accum_cck->early_overrun_err,
236			 delta_cck->early_overrun_err,
237			 max_cck->early_overrun_err);
238	pos += scnprintf(buf + pos, bufsz - pos,
239			 fmt_table, "crc32_good:",
240			 le32_to_cpu(cck->crc32_good), accum_cck->crc32_good,
241			 delta_cck->crc32_good, max_cck->crc32_good);
242	pos += scnprintf(buf + pos, bufsz - pos,
243			 fmt_table, "false_alarm_cnt:",
244			 le32_to_cpu(cck->false_alarm_cnt),
245			 accum_cck->false_alarm_cnt,
246			 delta_cck->false_alarm_cnt, max_cck->false_alarm_cnt);
247	pos += scnprintf(buf + pos, bufsz - pos,
248			 fmt_table, "fina_sync_err_cnt:",
249			 le32_to_cpu(cck->fina_sync_err_cnt),
250			 accum_cck->fina_sync_err_cnt,
251			 delta_cck->fina_sync_err_cnt,
252			 max_cck->fina_sync_err_cnt);
253	pos += scnprintf(buf + pos, bufsz - pos,
254			 fmt_table, "sfd_timeout:",
255			 le32_to_cpu(cck->sfd_timeout),
256			 accum_cck->sfd_timeout, delta_cck->sfd_timeout,
257			 max_cck->sfd_timeout);
258	pos += scnprintf(buf + pos, bufsz - pos,
259			 fmt_table, "fina_timeout:",
260			 le32_to_cpu(cck->fina_timeout),
261			 accum_cck->fina_timeout, delta_cck->fina_timeout,
262			 max_cck->fina_timeout);
263	pos += scnprintf(buf + pos, bufsz - pos,
264			 fmt_table, "unresponded_rts:",
265			 le32_to_cpu(cck->unresponded_rts),
266			 accum_cck->unresponded_rts, delta_cck->unresponded_rts,
267			 max_cck->unresponded_rts);
268	pos += scnprintf(buf + pos, bufsz - pos,
269			 fmt_table, "rxe_frame_lmt_ovrun:",
270			 le32_to_cpu(cck->rxe_frame_limit_overrun),
271			 accum_cck->rxe_frame_limit_overrun,
272			 delta_cck->rxe_frame_limit_overrun,
273			 max_cck->rxe_frame_limit_overrun);
274	pos += scnprintf(buf + pos, bufsz - pos,
275			 fmt_table, "sent_ack_cnt:",
276			 le32_to_cpu(cck->sent_ack_cnt),
277			 accum_cck->sent_ack_cnt, delta_cck->sent_ack_cnt,
278			 max_cck->sent_ack_cnt);
279	pos += scnprintf(buf + pos, bufsz - pos,
280			 fmt_table, "sent_cts_cnt:",
281			 le32_to_cpu(cck->sent_cts_cnt),
282			 accum_cck->sent_cts_cnt, delta_cck->sent_cts_cnt,
283			 max_cck->sent_cts_cnt);
284	pos += scnprintf(buf + pos, bufsz - pos,
285			 fmt_table, "sent_ba_rsp_cnt:",
286			 le32_to_cpu(cck->sent_ba_rsp_cnt),
287			 accum_cck->sent_ba_rsp_cnt,
288			 delta_cck->sent_ba_rsp_cnt,
289			 max_cck->sent_ba_rsp_cnt);
290	pos += scnprintf(buf + pos, bufsz - pos,
291			 fmt_table, "dsp_self_kill:",
292			 le32_to_cpu(cck->dsp_self_kill),
293			 accum_cck->dsp_self_kill, delta_cck->dsp_self_kill,
294			 max_cck->dsp_self_kill);
295	pos += scnprintf(buf + pos, bufsz - pos,
296			 fmt_table, "mh_format_err:",
297			 le32_to_cpu(cck->mh_format_err),
298			 accum_cck->mh_format_err, delta_cck->mh_format_err,
299			 max_cck->mh_format_err);
300	pos += scnprintf(buf + pos, bufsz - pos,
301			 fmt_table, "re_acq_main_rssi_sum:",
302			 le32_to_cpu(cck->re_acq_main_rssi_sum),
303			 accum_cck->re_acq_main_rssi_sum,
304			 delta_cck->re_acq_main_rssi_sum,
305			 max_cck->re_acq_main_rssi_sum);
306
307	pos += scnprintf(buf + pos, bufsz - pos,
308			 fmt_header, "Statistics_Rx - GENERAL:");
309	pos += scnprintf(buf + pos, bufsz - pos,
310			 fmt_table, "bogus_cts:",
311			 le32_to_cpu(general->bogus_cts),
312			 accum_general->bogus_cts, delta_general->bogus_cts,
313			 max_general->bogus_cts);
314	pos += scnprintf(buf + pos, bufsz - pos,
315			 fmt_table, "bogus_ack:",
316			 le32_to_cpu(general->bogus_ack),
317			 accum_general->bogus_ack, delta_general->bogus_ack,
318			 max_general->bogus_ack);
319	pos += scnprintf(buf + pos, bufsz - pos,
320			 fmt_table, "non_bssid_frames:",
321			 le32_to_cpu(general->non_bssid_frames),
322			 accum_general->non_bssid_frames,
323			 delta_general->non_bssid_frames,
324			 max_general->non_bssid_frames);
325	pos += scnprintf(buf + pos, bufsz - pos,
326			 fmt_table, "filtered_frames:",
327			 le32_to_cpu(general->filtered_frames),
328			 accum_general->filtered_frames,
329			 delta_general->filtered_frames,
330			 max_general->filtered_frames);
331	pos += scnprintf(buf + pos, bufsz - pos,
332			 fmt_table, "non_channel_beacons:",
333			 le32_to_cpu(general->non_channel_beacons),
334			 accum_general->non_channel_beacons,
335			 delta_general->non_channel_beacons,
336			 max_general->non_channel_beacons);
337	pos += scnprintf(buf + pos, bufsz - pos,
338			 fmt_table, "channel_beacons:",
339			 le32_to_cpu(general->channel_beacons),
340			 accum_general->channel_beacons,
341			 delta_general->channel_beacons,
342			 max_general->channel_beacons);
343	pos += scnprintf(buf + pos, bufsz - pos,
344			 fmt_table, "num_missed_bcon:",
345			 le32_to_cpu(general->num_missed_bcon),
346			 accum_general->num_missed_bcon,
347			 delta_general->num_missed_bcon,
348			 max_general->num_missed_bcon);
349	pos += scnprintf(buf + pos, bufsz - pos,
350			 fmt_table, "adc_rx_saturation_time:",
351			 le32_to_cpu(general->adc_rx_saturation_time),
352			 accum_general->adc_rx_saturation_time,
353			 delta_general->adc_rx_saturation_time,
354			 max_general->adc_rx_saturation_time);
355	pos += scnprintf(buf + pos, bufsz - pos,
356			 fmt_table, "ina_detect_search_tm:",
357			 le32_to_cpu(general->ina_detection_search_time),
358			 accum_general->ina_detection_search_time,
359			 delta_general->ina_detection_search_time,
360			 max_general->ina_detection_search_time);
361	pos += scnprintf(buf + pos, bufsz - pos,
362			 fmt_table, "beacon_silence_rssi_a:",
363			 le32_to_cpu(general->beacon_silence_rssi_a),
364			 accum_general->beacon_silence_rssi_a,
365			 delta_general->beacon_silence_rssi_a,
366			 max_general->beacon_silence_rssi_a);
367	pos += scnprintf(buf + pos, bufsz - pos,
368			 fmt_table, "beacon_silence_rssi_b:",
369			 le32_to_cpu(general->beacon_silence_rssi_b),
370			 accum_general->beacon_silence_rssi_b,
371			 delta_general->beacon_silence_rssi_b,
372			 max_general->beacon_silence_rssi_b);
373	pos += scnprintf(buf + pos, bufsz - pos,
374			 fmt_table, "beacon_silence_rssi_c:",
375			 le32_to_cpu(general->beacon_silence_rssi_c),
376			 accum_general->beacon_silence_rssi_c,
377			 delta_general->beacon_silence_rssi_c,
378			 max_general->beacon_silence_rssi_c);
379	pos += scnprintf(buf + pos, bufsz - pos,
380			 fmt_table, "interference_data_flag:",
381			 le32_to_cpu(general->interference_data_flag),
382			 accum_general->interference_data_flag,
383			 delta_general->interference_data_flag,
384			 max_general->interference_data_flag);
385	pos += scnprintf(buf + pos, bufsz - pos,
386			 fmt_table, "channel_load:",
387			 le32_to_cpu(general->channel_load),
388			 accum_general->channel_load,
389			 delta_general->channel_load,
390			 max_general->channel_load);
391	pos += scnprintf(buf + pos, bufsz - pos,
392			 fmt_table, "dsp_false_alarms:",
393			 le32_to_cpu(general->dsp_false_alarms),
394			 accum_general->dsp_false_alarms,
395			 delta_general->dsp_false_alarms,
396			 max_general->dsp_false_alarms);
397	pos += scnprintf(buf + pos, bufsz - pos,
398			 fmt_table, "beacon_rssi_a:",
399			 le32_to_cpu(general->beacon_rssi_a),
400			 accum_general->beacon_rssi_a,
401			 delta_general->beacon_rssi_a,
402			 max_general->beacon_rssi_a);
403	pos += scnprintf(buf + pos, bufsz - pos,
404			 fmt_table, "beacon_rssi_b:",
405			 le32_to_cpu(general->beacon_rssi_b),
406			 accum_general->beacon_rssi_b,
407			 delta_general->beacon_rssi_b,
408			 max_general->beacon_rssi_b);
409	pos += scnprintf(buf + pos, bufsz - pos,
410			 fmt_table, "beacon_rssi_c:",
411			 le32_to_cpu(general->beacon_rssi_c),
412			 accum_general->beacon_rssi_c,
413			 delta_general->beacon_rssi_c,
414			 max_general->beacon_rssi_c);
415	pos += scnprintf(buf + pos, bufsz - pos,
416			 fmt_table, "beacon_energy_a:",
417			 le32_to_cpu(general->beacon_energy_a),
418			 accum_general->beacon_energy_a,
419			 delta_general->beacon_energy_a,
420			 max_general->beacon_energy_a);
421	pos += scnprintf(buf + pos, bufsz - pos,
422			 fmt_table, "beacon_energy_b:",
423			 le32_to_cpu(general->beacon_energy_b),
424			 accum_general->beacon_energy_b,
425			 delta_general->beacon_energy_b,
426			 max_general->beacon_energy_b);
427	pos += scnprintf(buf + pos, bufsz - pos,
428			 fmt_table, "beacon_energy_c:",
429			 le32_to_cpu(general->beacon_energy_c),
430			 accum_general->beacon_energy_c,
431			 delta_general->beacon_energy_c,
432			 max_general->beacon_energy_c);
433
434	pos += scnprintf(buf + pos, bufsz - pos,
435			 fmt_header, "Statistics_Rx - OFDM_HT:");
436	pos += scnprintf(buf + pos, bufsz - pos,
437			 fmt_table, "plcp_err:",
438			 le32_to_cpu(ht->plcp_err), accum_ht->plcp_err,
439			 delta_ht->plcp_err, max_ht->plcp_err);
440	pos += scnprintf(buf + pos, bufsz - pos,
441			 fmt_table, "overrun_err:",
442			 le32_to_cpu(ht->overrun_err), accum_ht->overrun_err,
443			 delta_ht->overrun_err, max_ht->overrun_err);
444	pos += scnprintf(buf + pos, bufsz - pos,
445			 fmt_table, "early_overrun_err:",
446			 le32_to_cpu(ht->early_overrun_err),
447			 accum_ht->early_overrun_err,
448			 delta_ht->early_overrun_err,
449			 max_ht->early_overrun_err);
450	pos += scnprintf(buf + pos, bufsz - pos,
451			 fmt_table, "crc32_good:",
452			 le32_to_cpu(ht->crc32_good), accum_ht->crc32_good,
453			 delta_ht->crc32_good, max_ht->crc32_good);
454	pos += scnprintf(buf + pos, bufsz - pos,
455			 fmt_table, "crc32_err:",
456			 le32_to_cpu(ht->crc32_err), accum_ht->crc32_err,
457			 delta_ht->crc32_err, max_ht->crc32_err);
458	pos += scnprintf(buf + pos, bufsz - pos,
459			 fmt_table, "mh_format_err:",
460			 le32_to_cpu(ht->mh_format_err),
461			 accum_ht->mh_format_err,
462			 delta_ht->mh_format_err, max_ht->mh_format_err);
463	pos += scnprintf(buf + pos, bufsz - pos,
464			 fmt_table, "agg_crc32_good:",
465			 le32_to_cpu(ht->agg_crc32_good),
466			 accum_ht->agg_crc32_good,
467			 delta_ht->agg_crc32_good, max_ht->agg_crc32_good);
468	pos += scnprintf(buf + pos, bufsz - pos,
469			 fmt_table, "agg_mpdu_cnt:",
470			 le32_to_cpu(ht->agg_mpdu_cnt),
471			 accum_ht->agg_mpdu_cnt,
472			 delta_ht->agg_mpdu_cnt, max_ht->agg_mpdu_cnt);
473	pos += scnprintf(buf + pos, bufsz - pos,
474			 fmt_table, "agg_cnt:",
475			 le32_to_cpu(ht->agg_cnt), accum_ht->agg_cnt,
476			 delta_ht->agg_cnt, max_ht->agg_cnt);
477	pos += scnprintf(buf + pos, bufsz - pos,
478			 fmt_table, "unsupport_mcs:",
479			 le32_to_cpu(ht->unsupport_mcs),
480			 accum_ht->unsupport_mcs,
481			 delta_ht->unsupport_mcs, max_ht->unsupport_mcs);
482
483	ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos);
484	kfree(buf);
485	return ret;
486}
487
488ssize_t iwl4965_ucode_tx_stats_read(struct file *file,
489				char __user *user_buf,
490				size_t count, loff_t *ppos)
491{
492	struct iwl_priv *priv = file->private_data;
493	int pos = 0;
494	char *buf;
495	int bufsz = (sizeof(struct statistics_tx) * 48) + 250;
496	ssize_t ret;
497	struct statistics_tx *tx, *accum_tx, *delta_tx, *max_tx;
498
499	if (!iwl_legacy_is_alive(priv))
500		return -EAGAIN;
501
502	buf = kzalloc(bufsz, GFP_KERNEL);
503	if (!buf) {
504		IWL_ERR(priv, "Can not allocate Buffer\n");
505		return -ENOMEM;
506	}
507
508	/* the statistic information display here is based on
509	  * the last statistics notification from uCode
510	  * might not reflect the current uCode activity
511	  */
512	tx = &priv->_4965.statistics.tx;
513	accum_tx = &priv->_4965.accum_statistics.tx;
514	delta_tx = &priv->_4965.delta_statistics.tx;
515	max_tx = &priv->_4965.max_delta.tx;
516
517	pos += iwl4965_statistics_flag(priv, buf, bufsz);
518	pos += scnprintf(buf + pos, bufsz - pos,
519			 fmt_header, "Statistics_Tx:");
520	pos += scnprintf(buf + pos, bufsz - pos,
521			 fmt_table, "preamble:",
522			 le32_to_cpu(tx->preamble_cnt),
523			 accum_tx->preamble_cnt,
524			 delta_tx->preamble_cnt, max_tx->preamble_cnt);
525	pos += scnprintf(buf + pos, bufsz - pos,
526			 fmt_table, "rx_detected_cnt:",
527			 le32_to_cpu(tx->rx_detected_cnt),
528			 accum_tx->rx_detected_cnt,
529			 delta_tx->rx_detected_cnt, max_tx->rx_detected_cnt);
530	pos += scnprintf(buf + pos, bufsz - pos,
531			 fmt_table, "bt_prio_defer_cnt:",
532			 le32_to_cpu(tx->bt_prio_defer_cnt),
533			 accum_tx->bt_prio_defer_cnt,
534			 delta_tx->bt_prio_defer_cnt,
535			 max_tx->bt_prio_defer_cnt);
536	pos += scnprintf(buf + pos, bufsz - pos,
537			 fmt_table, "bt_prio_kill_cnt:",
538			 le32_to_cpu(tx->bt_prio_kill_cnt),
539			 accum_tx->bt_prio_kill_cnt,
540			 delta_tx->bt_prio_kill_cnt,
541			 max_tx->bt_prio_kill_cnt);
542	pos += scnprintf(buf + pos, bufsz - pos,
543			 fmt_table, "few_bytes_cnt:",
544			 le32_to_cpu(tx->few_bytes_cnt),
545			 accum_tx->few_bytes_cnt,
546			 delta_tx->few_bytes_cnt, max_tx->few_bytes_cnt);
547	pos += scnprintf(buf + pos, bufsz - pos,
548			 fmt_table, "cts_timeout:",
549			 le32_to_cpu(tx->cts_timeout), accum_tx->cts_timeout,
550			 delta_tx->cts_timeout, max_tx->cts_timeout);
551	pos += scnprintf(buf + pos, bufsz - pos,
552			 fmt_table, "ack_timeout:",
553			 le32_to_cpu(tx->ack_timeout),
554			 accum_tx->ack_timeout,
555			 delta_tx->ack_timeout, max_tx->ack_timeout);
556	pos += scnprintf(buf + pos, bufsz - pos,
557			 fmt_table, "expected_ack_cnt:",
558			 le32_to_cpu(tx->expected_ack_cnt),
559			 accum_tx->expected_ack_cnt,
560			 delta_tx->expected_ack_cnt,
561			 max_tx->expected_ack_cnt);
562	pos += scnprintf(buf + pos, bufsz - pos,
563			 fmt_table, "actual_ack_cnt:",
564			 le32_to_cpu(tx->actual_ack_cnt),
565			 accum_tx->actual_ack_cnt,
566			 delta_tx->actual_ack_cnt,
567			 max_tx->actual_ack_cnt);
568	pos += scnprintf(buf + pos, bufsz - pos,
569			 fmt_table, "dump_msdu_cnt:",
570			 le32_to_cpu(tx->dump_msdu_cnt),
571			 accum_tx->dump_msdu_cnt,
572			 delta_tx->dump_msdu_cnt,
573			 max_tx->dump_msdu_cnt);
574	pos += scnprintf(buf + pos, bufsz - pos,
575			 fmt_table, "abort_nxt_frame_mismatch:",
576			 le32_to_cpu(tx->burst_abort_next_frame_mismatch_cnt),
577			 accum_tx->burst_abort_next_frame_mismatch_cnt,
578			 delta_tx->burst_abort_next_frame_mismatch_cnt,
579			 max_tx->burst_abort_next_frame_mismatch_cnt);
580	pos += scnprintf(buf + pos, bufsz - pos,
581			 fmt_table, "abort_missing_nxt_frame:",
582			 le32_to_cpu(tx->burst_abort_missing_next_frame_cnt),
583			 accum_tx->burst_abort_missing_next_frame_cnt,
584			 delta_tx->burst_abort_missing_next_frame_cnt,
585			 max_tx->burst_abort_missing_next_frame_cnt);
586	pos += scnprintf(buf + pos, bufsz - pos,
587			 fmt_table, "cts_timeout_collision:",
588			 le32_to_cpu(tx->cts_timeout_collision),
589			 accum_tx->cts_timeout_collision,
590			 delta_tx->cts_timeout_collision,
591			 max_tx->cts_timeout_collision);
592	pos += scnprintf(buf + pos, bufsz - pos,
593			 fmt_table, "ack_ba_timeout_collision:",
594			 le32_to_cpu(tx->ack_or_ba_timeout_collision),
595			 accum_tx->ack_or_ba_timeout_collision,
596			 delta_tx->ack_or_ba_timeout_collision,
597			 max_tx->ack_or_ba_timeout_collision);
598	pos += scnprintf(buf + pos, bufsz - pos,
599			 fmt_table, "agg ba_timeout:",
600			 le32_to_cpu(tx->agg.ba_timeout),
601			 accum_tx->agg.ba_timeout,
602			 delta_tx->agg.ba_timeout,
603			 max_tx->agg.ba_timeout);
604	pos += scnprintf(buf + pos, bufsz - pos,
605			 fmt_table, "agg ba_resched_frames:",
606			 le32_to_cpu(tx->agg.ba_reschedule_frames),
607			 accum_tx->agg.ba_reschedule_frames,
608			 delta_tx->agg.ba_reschedule_frames,
609			 max_tx->agg.ba_reschedule_frames);
610	pos += scnprintf(buf + pos, bufsz - pos,
611			 fmt_table, "agg scd_query_agg_frame:",
612			 le32_to_cpu(tx->agg.scd_query_agg_frame_cnt),
613			 accum_tx->agg.scd_query_agg_frame_cnt,
614			 delta_tx->agg.scd_query_agg_frame_cnt,
615			 max_tx->agg.scd_query_agg_frame_cnt);
616	pos += scnprintf(buf + pos, bufsz - pos,
617			 fmt_table, "agg scd_query_no_agg:",
618			 le32_to_cpu(tx->agg.scd_query_no_agg),
619			 accum_tx->agg.scd_query_no_agg,
620			 delta_tx->agg.scd_query_no_agg,
621			 max_tx->agg.scd_query_no_agg);
622	pos += scnprintf(buf + pos, bufsz - pos,
623			 fmt_table, "agg scd_query_agg:",
624			 le32_to_cpu(tx->agg.scd_query_agg),
625			 accum_tx->agg.scd_query_agg,
626			 delta_tx->agg.scd_query_agg,
627			 max_tx->agg.scd_query_agg);
628	pos += scnprintf(buf + pos, bufsz - pos,
629			 fmt_table, "agg scd_query_mismatch:",
630			 le32_to_cpu(tx->agg.scd_query_mismatch),
631			 accum_tx->agg.scd_query_mismatch,
632			 delta_tx->agg.scd_query_mismatch,
633			 max_tx->agg.scd_query_mismatch);
634	pos += scnprintf(buf + pos, bufsz - pos,
635			 fmt_table, "agg frame_not_ready:",
636			 le32_to_cpu(tx->agg.frame_not_ready),
637			 accum_tx->agg.frame_not_ready,
638			 delta_tx->agg.frame_not_ready,
639			 max_tx->agg.frame_not_ready);
640	pos += scnprintf(buf + pos, bufsz - pos,
641			 fmt_table, "agg underrun:",
642			 le32_to_cpu(tx->agg.underrun),
643			 accum_tx->agg.underrun,
644			 delta_tx->agg.underrun, max_tx->agg.underrun);
645	pos += scnprintf(buf + pos, bufsz - pos,
646			 fmt_table, "agg bt_prio_kill:",
647			 le32_to_cpu(tx->agg.bt_prio_kill),
648			 accum_tx->agg.bt_prio_kill,
649			 delta_tx->agg.bt_prio_kill,
650			 max_tx->agg.bt_prio_kill);
651	pos += scnprintf(buf + pos, bufsz - pos,
652			 fmt_table, "agg rx_ba_rsp_cnt:",
653			 le32_to_cpu(tx->agg.rx_ba_rsp_cnt),
654			 accum_tx->agg.rx_ba_rsp_cnt,
655			 delta_tx->agg.rx_ba_rsp_cnt,
656			 max_tx->agg.rx_ba_rsp_cnt);
657
658	ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos);
659	kfree(buf);
660	return ret;
661}
662
663ssize_t
664iwl4965_ucode_general_stats_read(struct file *file, char __user *user_buf,
665				     size_t count, loff_t *ppos)
666{
667	struct iwl_priv *priv = file->private_data;
668	int pos = 0;
669	char *buf;
670	int bufsz = sizeof(struct statistics_general) * 10 + 300;
671	ssize_t ret;
672	struct statistics_general_common *general, *accum_general;
673	struct statistics_general_common *delta_general, *max_general;
674	struct statistics_dbg *dbg, *accum_dbg, *delta_dbg, *max_dbg;
675	struct statistics_div *div, *accum_div, *delta_div, *max_div;
676
677	if (!iwl_legacy_is_alive(priv))
678		return -EAGAIN;
679
680	buf = kzalloc(bufsz, GFP_KERNEL);
681	if (!buf) {
682		IWL_ERR(priv, "Can not allocate Buffer\n");
683		return -ENOMEM;
684	}
685
686	/* the statistic information display here is based on
687	  * the last statistics notification from uCode
688	  * might not reflect the current uCode activity
689	  */
690	general = &priv->_4965.statistics.general.common;
691	dbg = &priv->_4965.statistics.general.common.dbg;
692	div = &priv->_4965.statistics.general.common.div;
693	accum_general = &priv->_4965.accum_statistics.general.common;
694	accum_dbg = &priv->_4965.accum_statistics.general.common.dbg;
695	accum_div = &priv->_4965.accum_statistics.general.common.div;
696	delta_general = &priv->_4965.delta_statistics.general.common;
697	max_general = &priv->_4965.max_delta.general.common;
698	delta_dbg = &priv->_4965.delta_statistics.general.common.dbg;
699	max_dbg = &priv->_4965.max_delta.general.common.dbg;
700	delta_div = &priv->_4965.delta_statistics.general.common.div;
701	max_div = &priv->_4965.max_delta.general.common.div;
702
703	pos += iwl4965_statistics_flag(priv, buf, bufsz);
704	pos += scnprintf(buf + pos, bufsz - pos,
705			 fmt_header, "Statistics_General:");
706	pos += scnprintf(buf + pos, bufsz - pos,
707			 fmt_value, "temperature:",
708			 le32_to_cpu(general->temperature));
709	pos += scnprintf(buf + pos, bufsz - pos,
710			 fmt_value, "ttl_timestamp:",
711			 le32_to_cpu(general->ttl_timestamp));
712	pos += scnprintf(buf + pos, bufsz - pos,
713			 fmt_table, "burst_check:",
714			 le32_to_cpu(dbg->burst_check),
715			 accum_dbg->burst_check,
716			 delta_dbg->burst_check, max_dbg->burst_check);
717	pos += scnprintf(buf + pos, bufsz - pos,
718			 fmt_table, "burst_count:",
719			 le32_to_cpu(dbg->burst_count),
720			 accum_dbg->burst_count,
721			 delta_dbg->burst_count, max_dbg->burst_count);
722	pos += scnprintf(buf + pos, bufsz - pos,
723			 fmt_table, "wait_for_silence_timeout_count:",
724			 le32_to_cpu(dbg->wait_for_silence_timeout_cnt),
725			 accum_dbg->wait_for_silence_timeout_cnt,
726			 delta_dbg->wait_for_silence_timeout_cnt,
727			 max_dbg->wait_for_silence_timeout_cnt);
728	pos += scnprintf(buf + pos, bufsz - pos,
729			 fmt_table, "sleep_time:",
730			 le32_to_cpu(general->sleep_time),
731			 accum_general->sleep_time,
732			 delta_general->sleep_time, max_general->sleep_time);
733	pos += scnprintf(buf + pos, bufsz - pos,
734			 fmt_table, "slots_out:",
735			 le32_to_cpu(general->slots_out),
736			 accum_general->slots_out,
737			 delta_general->slots_out, max_general->slots_out);
738	pos += scnprintf(buf + pos, bufsz - pos,
739			 fmt_table, "slots_idle:",
740			 le32_to_cpu(general->slots_idle),
741			 accum_general->slots_idle,
742			 delta_general->slots_idle, max_general->slots_idle);
743	pos += scnprintf(buf + pos, bufsz - pos,
744			 fmt_table, "tx_on_a:",
745			 le32_to_cpu(div->tx_on_a), accum_div->tx_on_a,
746			 delta_div->tx_on_a, max_div->tx_on_a);
747	pos += scnprintf(buf + pos, bufsz - pos,
748			 fmt_table, "tx_on_b:",
749			 le32_to_cpu(div->tx_on_b), accum_div->tx_on_b,
750			 delta_div->tx_on_b, max_div->tx_on_b);
751	pos += scnprintf(buf + pos, bufsz - pos,
752			 fmt_table, "exec_time:",
753			 le32_to_cpu(div->exec_time), accum_div->exec_time,
754			 delta_div->exec_time, max_div->exec_time);
755	pos += scnprintf(buf + pos, bufsz - pos,
756			 fmt_table, "probe_time:",
757			 le32_to_cpu(div->probe_time), accum_div->probe_time,
758			 delta_div->probe_time, max_div->probe_time);
759	pos += scnprintf(buf + pos, bufsz - pos,
760			 fmt_table, "rx_enable_counter:",
761			 le32_to_cpu(general->rx_enable_counter),
762			 accum_general->rx_enable_counter,
763			 delta_general->rx_enable_counter,
764			 max_general->rx_enable_counter);
765	pos += scnprintf(buf + pos, bufsz - pos,
766			 fmt_table, "num_of_sos_states:",
767			 le32_to_cpu(general->num_of_sos_states),
768			 accum_general->num_of_sos_states,
769			 delta_general->num_of_sos_states,
770			 max_general->num_of_sos_states);
771	ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos);
772	kfree(buf);
773	return ret;
774}