Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/ecryptfs...
[pandora-kernel.git] / drivers / net / wireless / iwlwifi / iwl-agn-debugfs.c
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 #include "iwl-agn.h"
29 #include "iwl-agn-debugfs.h"
30
31 static const char *fmt_value = "  %-30s %10u\n";
32 static const char *fmt_hex   = "  %-30s       0x%02X\n";
33 static const char *fmt_table = "  %-30s %10u  %10u  %10u  %10u\n";
34 static const char *fmt_header =
35         "%-32s    current  cumulative       delta         max\n";
36
37 static int iwl_statistics_flag(struct iwl_priv *priv, char *buf, int bufsz)
38 {
39         int p = 0;
40         u32 flag;
41
42         if (priv->cfg->bt_params &&
43             priv->cfg->bt_params->bt_statistics)
44                 flag = le32_to_cpu(priv->_agn.statistics_bt.flag);
45         else
46                 flag = le32_to_cpu(priv->_agn.statistics.flag);
47
48         p += scnprintf(buf + p, bufsz - p, "Statistics Flag(0x%X):\n", flag);
49         if (flag & UCODE_STATISTICS_CLEAR_MSK)
50                 p += scnprintf(buf + p, bufsz - p,
51                 "\tStatistics have been cleared\n");
52         p += scnprintf(buf + p, bufsz - p, "\tOperational Frequency: %s\n",
53                 (flag & UCODE_STATISTICS_FREQUENCY_MSK)
54                 ? "2.4 GHz" : "5.2 GHz");
55         p += scnprintf(buf + p, bufsz - p, "\tTGj Narrow Band: %s\n",
56                 (flag & UCODE_STATISTICS_NARROW_BAND_MSK)
57                  ? "enabled" : "disabled");
58
59         return p;
60 }
61
62 ssize_t iwl_ucode_rx_stats_read(struct file *file, char __user *user_buf,
63                                 size_t count, loff_t *ppos)
64   {
65         struct iwl_priv *priv = file->private_data;
66         int pos = 0;
67         char *buf;
68         int bufsz = sizeof(struct statistics_rx_phy) * 40 +
69                     sizeof(struct statistics_rx_non_phy) * 40 +
70                     sizeof(struct statistics_rx_ht_phy) * 40 + 400;
71         ssize_t ret;
72         struct statistics_rx_phy *ofdm, *accum_ofdm, *delta_ofdm, *max_ofdm;
73         struct statistics_rx_phy *cck, *accum_cck, *delta_cck, *max_cck;
74         struct statistics_rx_non_phy *general, *accum_general;
75         struct statistics_rx_non_phy *delta_general, *max_general;
76         struct statistics_rx_ht_phy *ht, *accum_ht, *delta_ht, *max_ht;
77
78         if (!iwl_is_alive(priv))
79                 return -EAGAIN;
80
81         buf = kzalloc(bufsz, GFP_KERNEL);
82         if (!buf) {
83                 IWL_ERR(priv, "Can not allocate Buffer\n");
84                 return -ENOMEM;
85         }
86
87         /*
88          * the statistic information display here is based on
89          * the last statistics notification from uCode
90          * might not reflect the current uCode activity
91          */
92         if (priv->cfg->bt_params &&
93             priv->cfg->bt_params->bt_statistics) {
94                 ofdm = &priv->_agn.statistics_bt.rx.ofdm;
95                 cck = &priv->_agn.statistics_bt.rx.cck;
96                 general = &priv->_agn.statistics_bt.rx.general.common;
97                 ht = &priv->_agn.statistics_bt.rx.ofdm_ht;
98                 accum_ofdm = &priv->_agn.accum_statistics_bt.rx.ofdm;
99                 accum_cck = &priv->_agn.accum_statistics_bt.rx.cck;
100                 accum_general =
101                         &priv->_agn.accum_statistics_bt.rx.general.common;
102                 accum_ht = &priv->_agn.accum_statistics_bt.rx.ofdm_ht;
103                 delta_ofdm = &priv->_agn.delta_statistics_bt.rx.ofdm;
104                 delta_cck = &priv->_agn.delta_statistics_bt.rx.cck;
105                 delta_general =
106                         &priv->_agn.delta_statistics_bt.rx.general.common;
107                 delta_ht = &priv->_agn.delta_statistics_bt.rx.ofdm_ht;
108                 max_ofdm = &priv->_agn.max_delta_bt.rx.ofdm;
109                 max_cck = &priv->_agn.max_delta_bt.rx.cck;
110                 max_general = &priv->_agn.max_delta_bt.rx.general.common;
111                 max_ht = &priv->_agn.max_delta_bt.rx.ofdm_ht;
112         } else {
113                 ofdm = &priv->_agn.statistics.rx.ofdm;
114                 cck = &priv->_agn.statistics.rx.cck;
115                 general = &priv->_agn.statistics.rx.general;
116                 ht = &priv->_agn.statistics.rx.ofdm_ht;
117                 accum_ofdm = &priv->_agn.accum_statistics.rx.ofdm;
118                 accum_cck = &priv->_agn.accum_statistics.rx.cck;
119                 accum_general = &priv->_agn.accum_statistics.rx.general;
120                 accum_ht = &priv->_agn.accum_statistics.rx.ofdm_ht;
121                 delta_ofdm = &priv->_agn.delta_statistics.rx.ofdm;
122                 delta_cck = &priv->_agn.delta_statistics.rx.cck;
123                 delta_general = &priv->_agn.delta_statistics.rx.general;
124                 delta_ht = &priv->_agn.delta_statistics.rx.ofdm_ht;
125                 max_ofdm = &priv->_agn.max_delta.rx.ofdm;
126                 max_cck = &priv->_agn.max_delta.rx.cck;
127                 max_general = &priv->_agn.max_delta.rx.general;
128                 max_ht = &priv->_agn.max_delta.rx.ofdm_ht;
129         }
130
131         pos += iwl_statistics_flag(priv, buf, bufsz);
132         pos += scnprintf(buf + pos, bufsz - pos,
133                          fmt_header, "Statistics_Rx - OFDM:");
134         pos += scnprintf(buf + pos, bufsz - pos,
135                          fmt_table, "ina_cnt:",
136                          le32_to_cpu(ofdm->ina_cnt),
137                          accum_ofdm->ina_cnt,
138                          delta_ofdm->ina_cnt, max_ofdm->ina_cnt);
139         pos += scnprintf(buf + pos, bufsz - pos,
140                          fmt_table, "fina_cnt:",
141                          le32_to_cpu(ofdm->fina_cnt), accum_ofdm->fina_cnt,
142                          delta_ofdm->fina_cnt, max_ofdm->fina_cnt);
143         pos += scnprintf(buf + pos, bufsz - pos,
144                          fmt_table, "plcp_err:",
145                          le32_to_cpu(ofdm->plcp_err), accum_ofdm->plcp_err,
146                          delta_ofdm->plcp_err, max_ofdm->plcp_err);
147         pos += scnprintf(buf + pos, bufsz - pos,
148                          fmt_table, "crc32_err:",
149                          le32_to_cpu(ofdm->crc32_err), accum_ofdm->crc32_err,
150                          delta_ofdm->crc32_err, max_ofdm->crc32_err);
151         pos += scnprintf(buf + pos, bufsz - pos,
152                          fmt_table, "overrun_err:",
153                          le32_to_cpu(ofdm->overrun_err),
154                          accum_ofdm->overrun_err, delta_ofdm->overrun_err,
155                          max_ofdm->overrun_err);
156         pos += scnprintf(buf + pos, bufsz - pos,
157                          fmt_table, "early_overrun_err:",
158                          le32_to_cpu(ofdm->early_overrun_err),
159                          accum_ofdm->early_overrun_err,
160                          delta_ofdm->early_overrun_err,
161                          max_ofdm->early_overrun_err);
162         pos += scnprintf(buf + pos, bufsz - pos,
163                          fmt_table, "crc32_good:",
164                          le32_to_cpu(ofdm->crc32_good),
165                          accum_ofdm->crc32_good, delta_ofdm->crc32_good,
166                          max_ofdm->crc32_good);
167         pos += scnprintf(buf + pos, bufsz - pos,
168                          fmt_table, "false_alarm_cnt:",
169                          le32_to_cpu(ofdm->false_alarm_cnt),
170                          accum_ofdm->false_alarm_cnt,
171                          delta_ofdm->false_alarm_cnt,
172                          max_ofdm->false_alarm_cnt);
173         pos += scnprintf(buf + pos, bufsz - pos,
174                          fmt_table, "fina_sync_err_cnt:",
175                          le32_to_cpu(ofdm->fina_sync_err_cnt),
176                          accum_ofdm->fina_sync_err_cnt,
177                          delta_ofdm->fina_sync_err_cnt,
178                          max_ofdm->fina_sync_err_cnt);
179         pos += scnprintf(buf + pos, bufsz - pos,
180                          fmt_table, "sfd_timeout:",
181                          le32_to_cpu(ofdm->sfd_timeout),
182                          accum_ofdm->sfd_timeout, delta_ofdm->sfd_timeout,
183                          max_ofdm->sfd_timeout);
184         pos += scnprintf(buf + pos, bufsz - pos,
185                          fmt_table, "fina_timeout:",
186                          le32_to_cpu(ofdm->fina_timeout),
187                          accum_ofdm->fina_timeout, delta_ofdm->fina_timeout,
188                          max_ofdm->fina_timeout);
189         pos += scnprintf(buf + pos, bufsz - pos,
190                          fmt_table, "unresponded_rts:",
191                          le32_to_cpu(ofdm->unresponded_rts),
192                          accum_ofdm->unresponded_rts,
193                          delta_ofdm->unresponded_rts,
194                          max_ofdm->unresponded_rts);
195         pos += scnprintf(buf + pos, bufsz - pos,
196                          fmt_table, "rxe_frame_lmt_ovrun:",
197                          le32_to_cpu(ofdm->rxe_frame_limit_overrun),
198                          accum_ofdm->rxe_frame_limit_overrun,
199                          delta_ofdm->rxe_frame_limit_overrun,
200                          max_ofdm->rxe_frame_limit_overrun);
201         pos += scnprintf(buf + pos, bufsz - pos,
202                          fmt_table, "sent_ack_cnt:",
203                          le32_to_cpu(ofdm->sent_ack_cnt),
204                          accum_ofdm->sent_ack_cnt, delta_ofdm->sent_ack_cnt,
205                          max_ofdm->sent_ack_cnt);
206         pos += scnprintf(buf + pos, bufsz - pos,
207                          fmt_table, "sent_cts_cnt:",
208                          le32_to_cpu(ofdm->sent_cts_cnt),
209                          accum_ofdm->sent_cts_cnt, delta_ofdm->sent_cts_cnt,
210                          max_ofdm->sent_cts_cnt);
211         pos += scnprintf(buf + pos, bufsz - pos,
212                          fmt_table, "sent_ba_rsp_cnt:",
213                          le32_to_cpu(ofdm->sent_ba_rsp_cnt),
214                          accum_ofdm->sent_ba_rsp_cnt,
215                          delta_ofdm->sent_ba_rsp_cnt,
216                          max_ofdm->sent_ba_rsp_cnt);
217         pos += scnprintf(buf + pos, bufsz - pos,
218                          fmt_table, "dsp_self_kill:",
219                          le32_to_cpu(ofdm->dsp_self_kill),
220                          accum_ofdm->dsp_self_kill,
221                          delta_ofdm->dsp_self_kill,
222                          max_ofdm->dsp_self_kill);
223         pos += scnprintf(buf + pos, bufsz - pos,
224                          fmt_table, "mh_format_err:",
225                          le32_to_cpu(ofdm->mh_format_err),
226                          accum_ofdm->mh_format_err,
227                          delta_ofdm->mh_format_err,
228                          max_ofdm->mh_format_err);
229         pos += scnprintf(buf + pos, bufsz - pos,
230                          fmt_table, "re_acq_main_rssi_sum:",
231                          le32_to_cpu(ofdm->re_acq_main_rssi_sum),
232                          accum_ofdm->re_acq_main_rssi_sum,
233                          delta_ofdm->re_acq_main_rssi_sum,
234                          max_ofdm->re_acq_main_rssi_sum);
235
236         pos += scnprintf(buf + pos, bufsz - pos,
237                          fmt_header, "Statistics_Rx - CCK:");
238         pos += scnprintf(buf + pos, bufsz - pos,
239                          fmt_table, "ina_cnt:",
240                          le32_to_cpu(cck->ina_cnt), accum_cck->ina_cnt,
241                          delta_cck->ina_cnt, max_cck->ina_cnt);
242         pos += scnprintf(buf + pos, bufsz - pos,
243                          fmt_table, "fina_cnt:",
244                          le32_to_cpu(cck->fina_cnt), accum_cck->fina_cnt,
245                          delta_cck->fina_cnt, max_cck->fina_cnt);
246         pos += scnprintf(buf + pos, bufsz - pos,
247                          fmt_table, "plcp_err:",
248                          le32_to_cpu(cck->plcp_err), accum_cck->plcp_err,
249                          delta_cck->plcp_err, max_cck->plcp_err);
250         pos += scnprintf(buf + pos, bufsz - pos,
251                          fmt_table, "crc32_err:",
252                          le32_to_cpu(cck->crc32_err), accum_cck->crc32_err,
253                          delta_cck->crc32_err, max_cck->crc32_err);
254         pos += scnprintf(buf + pos, bufsz - pos,
255                          fmt_table, "overrun_err:",
256                          le32_to_cpu(cck->overrun_err),
257                          accum_cck->overrun_err, delta_cck->overrun_err,
258                          max_cck->overrun_err);
259         pos += scnprintf(buf + pos, bufsz - pos,
260                          fmt_table, "early_overrun_err:",
261                          le32_to_cpu(cck->early_overrun_err),
262                          accum_cck->early_overrun_err,
263                          delta_cck->early_overrun_err,
264                          max_cck->early_overrun_err);
265         pos += scnprintf(buf + pos, bufsz - pos,
266                          fmt_table, "crc32_good:",
267                          le32_to_cpu(cck->crc32_good), accum_cck->crc32_good,
268                          delta_cck->crc32_good, max_cck->crc32_good);
269         pos += scnprintf(buf + pos, bufsz - pos,
270                          fmt_table, "false_alarm_cnt:",
271                          le32_to_cpu(cck->false_alarm_cnt),
272                          accum_cck->false_alarm_cnt,
273                          delta_cck->false_alarm_cnt, max_cck->false_alarm_cnt);
274         pos += scnprintf(buf + pos, bufsz - pos,
275                          fmt_table, "fina_sync_err_cnt:",
276                          le32_to_cpu(cck->fina_sync_err_cnt),
277                          accum_cck->fina_sync_err_cnt,
278                          delta_cck->fina_sync_err_cnt,
279                          max_cck->fina_sync_err_cnt);
280         pos += scnprintf(buf + pos, bufsz - pos,
281                          fmt_table, "sfd_timeout:",
282                          le32_to_cpu(cck->sfd_timeout),
283                          accum_cck->sfd_timeout, delta_cck->sfd_timeout,
284                          max_cck->sfd_timeout);
285         pos += scnprintf(buf + pos, bufsz - pos,
286                          fmt_table, "fina_timeout:",
287                          le32_to_cpu(cck->fina_timeout),
288                          accum_cck->fina_timeout, delta_cck->fina_timeout,
289                          max_cck->fina_timeout);
290         pos += scnprintf(buf + pos, bufsz - pos,
291                          fmt_table, "unresponded_rts:",
292                          le32_to_cpu(cck->unresponded_rts),
293                          accum_cck->unresponded_rts, delta_cck->unresponded_rts,
294                          max_cck->unresponded_rts);
295         pos += scnprintf(buf + pos, bufsz - pos,
296                          fmt_table, "rxe_frame_lmt_ovrun:",
297                          le32_to_cpu(cck->rxe_frame_limit_overrun),
298                          accum_cck->rxe_frame_limit_overrun,
299                          delta_cck->rxe_frame_limit_overrun,
300                          max_cck->rxe_frame_limit_overrun);
301         pos += scnprintf(buf + pos, bufsz - pos,
302                          fmt_table, "sent_ack_cnt:",
303                          le32_to_cpu(cck->sent_ack_cnt),
304                          accum_cck->sent_ack_cnt, delta_cck->sent_ack_cnt,
305                          max_cck->sent_ack_cnt);
306         pos += scnprintf(buf + pos, bufsz - pos,
307                          fmt_table, "sent_cts_cnt:",
308                          le32_to_cpu(cck->sent_cts_cnt),
309                          accum_cck->sent_cts_cnt, delta_cck->sent_cts_cnt,
310                          max_cck->sent_cts_cnt);
311         pos += scnprintf(buf + pos, bufsz - pos,
312                          fmt_table, "sent_ba_rsp_cnt:",
313                          le32_to_cpu(cck->sent_ba_rsp_cnt),
314                          accum_cck->sent_ba_rsp_cnt,
315                          delta_cck->sent_ba_rsp_cnt,
316                          max_cck->sent_ba_rsp_cnt);
317         pos += scnprintf(buf + pos, bufsz - pos,
318                          fmt_table, "dsp_self_kill:",
319                          le32_to_cpu(cck->dsp_self_kill),
320                          accum_cck->dsp_self_kill, delta_cck->dsp_self_kill,
321                          max_cck->dsp_self_kill);
322         pos += scnprintf(buf + pos, bufsz - pos,
323                          fmt_table, "mh_format_err:",
324                          le32_to_cpu(cck->mh_format_err),
325                          accum_cck->mh_format_err, delta_cck->mh_format_err,
326                          max_cck->mh_format_err);
327         pos += scnprintf(buf + pos, bufsz - pos,
328                          fmt_table, "re_acq_main_rssi_sum:",
329                          le32_to_cpu(cck->re_acq_main_rssi_sum),
330                          accum_cck->re_acq_main_rssi_sum,
331                          delta_cck->re_acq_main_rssi_sum,
332                          max_cck->re_acq_main_rssi_sum);
333
334         pos += scnprintf(buf + pos, bufsz - pos,
335                          fmt_header, "Statistics_Rx - GENERAL:");
336         pos += scnprintf(buf + pos, bufsz - pos,
337                          fmt_table, "bogus_cts:",
338                          le32_to_cpu(general->bogus_cts),
339                          accum_general->bogus_cts, delta_general->bogus_cts,
340                          max_general->bogus_cts);
341         pos += scnprintf(buf + pos, bufsz - pos,
342                          fmt_table, "bogus_ack:",
343                          le32_to_cpu(general->bogus_ack),
344                          accum_general->bogus_ack, delta_general->bogus_ack,
345                          max_general->bogus_ack);
346         pos += scnprintf(buf + pos, bufsz - pos,
347                          fmt_table, "non_bssid_frames:",
348                          le32_to_cpu(general->non_bssid_frames),
349                          accum_general->non_bssid_frames,
350                          delta_general->non_bssid_frames,
351                          max_general->non_bssid_frames);
352         pos += scnprintf(buf + pos, bufsz - pos,
353                          fmt_table, "filtered_frames:",
354                          le32_to_cpu(general->filtered_frames),
355                          accum_general->filtered_frames,
356                          delta_general->filtered_frames,
357                          max_general->filtered_frames);
358         pos += scnprintf(buf + pos, bufsz - pos,
359                          fmt_table, "non_channel_beacons:",
360                          le32_to_cpu(general->non_channel_beacons),
361                          accum_general->non_channel_beacons,
362                          delta_general->non_channel_beacons,
363                          max_general->non_channel_beacons);
364         pos += scnprintf(buf + pos, bufsz - pos,
365                          fmt_table, "channel_beacons:",
366                          le32_to_cpu(general->channel_beacons),
367                          accum_general->channel_beacons,
368                          delta_general->channel_beacons,
369                          max_general->channel_beacons);
370         pos += scnprintf(buf + pos, bufsz - pos,
371                          fmt_table, "num_missed_bcon:",
372                          le32_to_cpu(general->num_missed_bcon),
373                          accum_general->num_missed_bcon,
374                          delta_general->num_missed_bcon,
375                          max_general->num_missed_bcon);
376         pos += scnprintf(buf + pos, bufsz - pos,
377                          fmt_table, "adc_rx_saturation_time:",
378                          le32_to_cpu(general->adc_rx_saturation_time),
379                          accum_general->adc_rx_saturation_time,
380                          delta_general->adc_rx_saturation_time,
381                          max_general->adc_rx_saturation_time);
382         pos += scnprintf(buf + pos, bufsz - pos,
383                          fmt_table, "ina_detect_search_tm:",
384                          le32_to_cpu(general->ina_detection_search_time),
385                          accum_general->ina_detection_search_time,
386                          delta_general->ina_detection_search_time,
387                          max_general->ina_detection_search_time);
388         pos += scnprintf(buf + pos, bufsz - pos,
389                          fmt_table, "beacon_silence_rssi_a:",
390                          le32_to_cpu(general->beacon_silence_rssi_a),
391                          accum_general->beacon_silence_rssi_a,
392                          delta_general->beacon_silence_rssi_a,
393                          max_general->beacon_silence_rssi_a);
394         pos += scnprintf(buf + pos, bufsz - pos,
395                          fmt_table, "beacon_silence_rssi_b:",
396                          le32_to_cpu(general->beacon_silence_rssi_b),
397                          accum_general->beacon_silence_rssi_b,
398                          delta_general->beacon_silence_rssi_b,
399                          max_general->beacon_silence_rssi_b);
400         pos += scnprintf(buf + pos, bufsz - pos,
401                          fmt_table, "beacon_silence_rssi_c:",
402                          le32_to_cpu(general->beacon_silence_rssi_c),
403                          accum_general->beacon_silence_rssi_c,
404                          delta_general->beacon_silence_rssi_c,
405                          max_general->beacon_silence_rssi_c);
406         pos += scnprintf(buf + pos, bufsz - pos,
407                          fmt_table, "interference_data_flag:",
408                          le32_to_cpu(general->interference_data_flag),
409                          accum_general->interference_data_flag,
410                          delta_general->interference_data_flag,
411                          max_general->interference_data_flag);
412         pos += scnprintf(buf + pos, bufsz - pos,
413                          fmt_table, "channel_load:",
414                          le32_to_cpu(general->channel_load),
415                          accum_general->channel_load,
416                          delta_general->channel_load,
417                          max_general->channel_load);
418         pos += scnprintf(buf + pos, bufsz - pos,
419                          fmt_table, "dsp_false_alarms:",
420                          le32_to_cpu(general->dsp_false_alarms),
421                          accum_general->dsp_false_alarms,
422                          delta_general->dsp_false_alarms,
423                          max_general->dsp_false_alarms);
424         pos += scnprintf(buf + pos, bufsz - pos,
425                          fmt_table, "beacon_rssi_a:",
426                          le32_to_cpu(general->beacon_rssi_a),
427                          accum_general->beacon_rssi_a,
428                          delta_general->beacon_rssi_a,
429                          max_general->beacon_rssi_a);
430         pos += scnprintf(buf + pos, bufsz - pos,
431                          fmt_table, "beacon_rssi_b:",
432                          le32_to_cpu(general->beacon_rssi_b),
433                          accum_general->beacon_rssi_b,
434                          delta_general->beacon_rssi_b,
435                          max_general->beacon_rssi_b);
436         pos += scnprintf(buf + pos, bufsz - pos,
437                          fmt_table, "beacon_rssi_c:",
438                          le32_to_cpu(general->beacon_rssi_c),
439                          accum_general->beacon_rssi_c,
440                          delta_general->beacon_rssi_c,
441                          max_general->beacon_rssi_c);
442         pos += scnprintf(buf + pos, bufsz - pos,
443                          fmt_table, "beacon_energy_a:",
444                          le32_to_cpu(general->beacon_energy_a),
445                          accum_general->beacon_energy_a,
446                          delta_general->beacon_energy_a,
447                          max_general->beacon_energy_a);
448         pos += scnprintf(buf + pos, bufsz - pos,
449                          fmt_table, "beacon_energy_b:",
450                          le32_to_cpu(general->beacon_energy_b),
451                          accum_general->beacon_energy_b,
452                          delta_general->beacon_energy_b,
453                          max_general->beacon_energy_b);
454         pos += scnprintf(buf + pos, bufsz - pos,
455                          fmt_table, "beacon_energy_c:",
456                          le32_to_cpu(general->beacon_energy_c),
457                          accum_general->beacon_energy_c,
458                          delta_general->beacon_energy_c,
459                          max_general->beacon_energy_c);
460
461         pos += scnprintf(buf + pos, bufsz - pos,
462                          fmt_header, "Statistics_Rx - OFDM_HT:");
463         pos += scnprintf(buf + pos, bufsz - pos,
464                          fmt_table, "plcp_err:",
465                          le32_to_cpu(ht->plcp_err), accum_ht->plcp_err,
466                          delta_ht->plcp_err, max_ht->plcp_err);
467         pos += scnprintf(buf + pos, bufsz - pos,
468                          fmt_table, "overrun_err:",
469                          le32_to_cpu(ht->overrun_err), accum_ht->overrun_err,
470                          delta_ht->overrun_err, max_ht->overrun_err);
471         pos += scnprintf(buf + pos, bufsz - pos,
472                          fmt_table, "early_overrun_err:",
473                          le32_to_cpu(ht->early_overrun_err),
474                          accum_ht->early_overrun_err,
475                          delta_ht->early_overrun_err,
476                          max_ht->early_overrun_err);
477         pos += scnprintf(buf + pos, bufsz - pos,
478                          fmt_table, "crc32_good:",
479                          le32_to_cpu(ht->crc32_good), accum_ht->crc32_good,
480                          delta_ht->crc32_good, max_ht->crc32_good);
481         pos += scnprintf(buf + pos, bufsz - pos,
482                          fmt_table, "crc32_err:",
483                          le32_to_cpu(ht->crc32_err), accum_ht->crc32_err,
484                          delta_ht->crc32_err, max_ht->crc32_err);
485         pos += scnprintf(buf + pos, bufsz - pos,
486                          fmt_table, "mh_format_err:",
487                          le32_to_cpu(ht->mh_format_err),
488                          accum_ht->mh_format_err,
489                          delta_ht->mh_format_err, max_ht->mh_format_err);
490         pos += scnprintf(buf + pos, bufsz - pos,
491                          fmt_table, "agg_crc32_good:",
492                          le32_to_cpu(ht->agg_crc32_good),
493                          accum_ht->agg_crc32_good,
494                          delta_ht->agg_crc32_good, max_ht->agg_crc32_good);
495         pos += scnprintf(buf + pos, bufsz - pos,
496                          fmt_table, "agg_mpdu_cnt:",
497                          le32_to_cpu(ht->agg_mpdu_cnt),
498                          accum_ht->agg_mpdu_cnt,
499                          delta_ht->agg_mpdu_cnt, max_ht->agg_mpdu_cnt);
500         pos += scnprintf(buf + pos, bufsz - pos,
501                          fmt_table, "agg_cnt:",
502                          le32_to_cpu(ht->agg_cnt), accum_ht->agg_cnt,
503                          delta_ht->agg_cnt, max_ht->agg_cnt);
504         pos += scnprintf(buf + pos, bufsz - pos,
505                          fmt_table, "unsupport_mcs:",
506                          le32_to_cpu(ht->unsupport_mcs),
507                          accum_ht->unsupport_mcs,
508                          delta_ht->unsupport_mcs, max_ht->unsupport_mcs);
509
510         ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos);
511         kfree(buf);
512         return ret;
513 }
514
515 ssize_t iwl_ucode_tx_stats_read(struct file *file,
516                                 char __user *user_buf,
517                                 size_t count, loff_t *ppos)
518 {
519         struct iwl_priv *priv = file->private_data;
520         int pos = 0;
521         char *buf;
522         int bufsz = (sizeof(struct statistics_tx) * 48) + 250;
523         ssize_t ret;
524         struct statistics_tx *tx, *accum_tx, *delta_tx, *max_tx;
525
526         if (!iwl_is_alive(priv))
527                 return -EAGAIN;
528
529         buf = kzalloc(bufsz, GFP_KERNEL);
530         if (!buf) {
531                 IWL_ERR(priv, "Can not allocate Buffer\n");
532                 return -ENOMEM;
533         }
534
535         /* the statistic information display here is based on
536           * the last statistics notification from uCode
537           * might not reflect the current uCode activity
538           */
539         if (priv->cfg->bt_params &&
540             priv->cfg->bt_params->bt_statistics) {
541                 tx = &priv->_agn.statistics_bt.tx;
542                 accum_tx = &priv->_agn.accum_statistics_bt.tx;
543                 delta_tx = &priv->_agn.delta_statistics_bt.tx;
544                 max_tx = &priv->_agn.max_delta_bt.tx;
545         } else {
546                 tx = &priv->_agn.statistics.tx;
547                 accum_tx = &priv->_agn.accum_statistics.tx;
548                 delta_tx = &priv->_agn.delta_statistics.tx;
549                 max_tx = &priv->_agn.max_delta.tx;
550         }
551
552         pos += iwl_statistics_flag(priv, buf, bufsz);
553         pos += scnprintf(buf + pos, bufsz - pos,
554                          fmt_header, "Statistics_Tx:");
555         pos += scnprintf(buf + pos, bufsz - pos,
556                          fmt_table, "preamble:",
557                          le32_to_cpu(tx->preamble_cnt),
558                          accum_tx->preamble_cnt,
559                          delta_tx->preamble_cnt, max_tx->preamble_cnt);
560         pos += scnprintf(buf + pos, bufsz - pos,
561                          fmt_table, "rx_detected_cnt:",
562                          le32_to_cpu(tx->rx_detected_cnt),
563                          accum_tx->rx_detected_cnt,
564                          delta_tx->rx_detected_cnt, max_tx->rx_detected_cnt);
565         pos += scnprintf(buf + pos, bufsz - pos,
566                          fmt_table, "bt_prio_defer_cnt:",
567                          le32_to_cpu(tx->bt_prio_defer_cnt),
568                          accum_tx->bt_prio_defer_cnt,
569                          delta_tx->bt_prio_defer_cnt,
570                          max_tx->bt_prio_defer_cnt);
571         pos += scnprintf(buf + pos, bufsz - pos,
572                          fmt_table, "bt_prio_kill_cnt:",
573                          le32_to_cpu(tx->bt_prio_kill_cnt),
574                          accum_tx->bt_prio_kill_cnt,
575                          delta_tx->bt_prio_kill_cnt,
576                          max_tx->bt_prio_kill_cnt);
577         pos += scnprintf(buf + pos, bufsz - pos,
578                          fmt_table, "few_bytes_cnt:",
579                          le32_to_cpu(tx->few_bytes_cnt),
580                          accum_tx->few_bytes_cnt,
581                          delta_tx->few_bytes_cnt, max_tx->few_bytes_cnt);
582         pos += scnprintf(buf + pos, bufsz - pos,
583                          fmt_table, "cts_timeout:",
584                          le32_to_cpu(tx->cts_timeout), accum_tx->cts_timeout,
585                          delta_tx->cts_timeout, max_tx->cts_timeout);
586         pos += scnprintf(buf + pos, bufsz - pos,
587                          fmt_table, "ack_timeout:",
588                          le32_to_cpu(tx->ack_timeout),
589                          accum_tx->ack_timeout,
590                          delta_tx->ack_timeout, max_tx->ack_timeout);
591         pos += scnprintf(buf + pos, bufsz - pos,
592                          fmt_table, "expected_ack_cnt:",
593                          le32_to_cpu(tx->expected_ack_cnt),
594                          accum_tx->expected_ack_cnt,
595                          delta_tx->expected_ack_cnt,
596                          max_tx->expected_ack_cnt);
597         pos += scnprintf(buf + pos, bufsz - pos,
598                          fmt_table, "actual_ack_cnt:",
599                          le32_to_cpu(tx->actual_ack_cnt),
600                          accum_tx->actual_ack_cnt,
601                          delta_tx->actual_ack_cnt,
602                          max_tx->actual_ack_cnt);
603         pos += scnprintf(buf + pos, bufsz - pos,
604                          fmt_table, "dump_msdu_cnt:",
605                          le32_to_cpu(tx->dump_msdu_cnt),
606                          accum_tx->dump_msdu_cnt,
607                          delta_tx->dump_msdu_cnt,
608                          max_tx->dump_msdu_cnt);
609         pos += scnprintf(buf + pos, bufsz - pos,
610                          fmt_table, "abort_nxt_frame_mismatch:",
611                          le32_to_cpu(tx->burst_abort_next_frame_mismatch_cnt),
612                          accum_tx->burst_abort_next_frame_mismatch_cnt,
613                          delta_tx->burst_abort_next_frame_mismatch_cnt,
614                          max_tx->burst_abort_next_frame_mismatch_cnt);
615         pos += scnprintf(buf + pos, bufsz - pos,
616                          fmt_table, "abort_missing_nxt_frame:",
617                          le32_to_cpu(tx->burst_abort_missing_next_frame_cnt),
618                          accum_tx->burst_abort_missing_next_frame_cnt,
619                          delta_tx->burst_abort_missing_next_frame_cnt,
620                          max_tx->burst_abort_missing_next_frame_cnt);
621         pos += scnprintf(buf + pos, bufsz - pos,
622                          fmt_table, "cts_timeout_collision:",
623                          le32_to_cpu(tx->cts_timeout_collision),
624                          accum_tx->cts_timeout_collision,
625                          delta_tx->cts_timeout_collision,
626                          max_tx->cts_timeout_collision);
627         pos += scnprintf(buf + pos, bufsz - pos,
628                          fmt_table, "ack_ba_timeout_collision:",
629                          le32_to_cpu(tx->ack_or_ba_timeout_collision),
630                          accum_tx->ack_or_ba_timeout_collision,
631                          delta_tx->ack_or_ba_timeout_collision,
632                          max_tx->ack_or_ba_timeout_collision);
633         pos += scnprintf(buf + pos, bufsz - pos,
634                          fmt_table, "agg ba_timeout:",
635                          le32_to_cpu(tx->agg.ba_timeout),
636                          accum_tx->agg.ba_timeout,
637                          delta_tx->agg.ba_timeout,
638                          max_tx->agg.ba_timeout);
639         pos += scnprintf(buf + pos, bufsz - pos,
640                          fmt_table, "agg ba_resched_frames:",
641                          le32_to_cpu(tx->agg.ba_reschedule_frames),
642                          accum_tx->agg.ba_reschedule_frames,
643                          delta_tx->agg.ba_reschedule_frames,
644                          max_tx->agg.ba_reschedule_frames);
645         pos += scnprintf(buf + pos, bufsz - pos,
646                          fmt_table, "agg scd_query_agg_frame:",
647                          le32_to_cpu(tx->agg.scd_query_agg_frame_cnt),
648                          accum_tx->agg.scd_query_agg_frame_cnt,
649                          delta_tx->agg.scd_query_agg_frame_cnt,
650                          max_tx->agg.scd_query_agg_frame_cnt);
651         pos += scnprintf(buf + pos, bufsz - pos,
652                          fmt_table, "agg scd_query_no_agg:",
653                          le32_to_cpu(tx->agg.scd_query_no_agg),
654                          accum_tx->agg.scd_query_no_agg,
655                          delta_tx->agg.scd_query_no_agg,
656                          max_tx->agg.scd_query_no_agg);
657         pos += scnprintf(buf + pos, bufsz - pos,
658                          fmt_table, "agg scd_query_agg:",
659                          le32_to_cpu(tx->agg.scd_query_agg),
660                          accum_tx->agg.scd_query_agg,
661                          delta_tx->agg.scd_query_agg,
662                          max_tx->agg.scd_query_agg);
663         pos += scnprintf(buf + pos, bufsz - pos,
664                          fmt_table, "agg scd_query_mismatch:",
665                          le32_to_cpu(tx->agg.scd_query_mismatch),
666                          accum_tx->agg.scd_query_mismatch,
667                          delta_tx->agg.scd_query_mismatch,
668                          max_tx->agg.scd_query_mismatch);
669         pos += scnprintf(buf + pos, bufsz - pos,
670                          fmt_table, "agg frame_not_ready:",
671                          le32_to_cpu(tx->agg.frame_not_ready),
672                          accum_tx->agg.frame_not_ready,
673                          delta_tx->agg.frame_not_ready,
674                          max_tx->agg.frame_not_ready);
675         pos += scnprintf(buf + pos, bufsz - pos,
676                          fmt_table, "agg underrun:",
677                          le32_to_cpu(tx->agg.underrun),
678                          accum_tx->agg.underrun,
679                          delta_tx->agg.underrun, max_tx->agg.underrun);
680         pos += scnprintf(buf + pos, bufsz - pos,
681                          fmt_table, "agg bt_prio_kill:",
682                          le32_to_cpu(tx->agg.bt_prio_kill),
683                          accum_tx->agg.bt_prio_kill,
684                          delta_tx->agg.bt_prio_kill,
685                          max_tx->agg.bt_prio_kill);
686         pos += scnprintf(buf + pos, bufsz - pos,
687                          fmt_table, "agg rx_ba_rsp_cnt:",
688                          le32_to_cpu(tx->agg.rx_ba_rsp_cnt),
689                          accum_tx->agg.rx_ba_rsp_cnt,
690                          delta_tx->agg.rx_ba_rsp_cnt,
691                          max_tx->agg.rx_ba_rsp_cnt);
692
693         if (tx->tx_power.ant_a || tx->tx_power.ant_b || tx->tx_power.ant_c) {
694                 pos += scnprintf(buf + pos, bufsz - pos,
695                         "tx power: (1/2 dB step)\n");
696                 if ((priv->cfg->valid_tx_ant & ANT_A) && tx->tx_power.ant_a)
697                         pos += scnprintf(buf + pos, bufsz - pos,
698                                         fmt_hex, "antenna A:",
699                                         tx->tx_power.ant_a);
700                 if ((priv->cfg->valid_tx_ant & ANT_B) && tx->tx_power.ant_b)
701                         pos += scnprintf(buf + pos, bufsz - pos,
702                                         fmt_hex, "antenna B:",
703                                         tx->tx_power.ant_b);
704                 if ((priv->cfg->valid_tx_ant & ANT_C) && tx->tx_power.ant_c)
705                         pos += scnprintf(buf + pos, bufsz - pos,
706                                         fmt_hex, "antenna C:",
707                                         tx->tx_power.ant_c);
708         }
709         ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos);
710         kfree(buf);
711         return ret;
712 }
713
714 ssize_t iwl_ucode_general_stats_read(struct file *file, char __user *user_buf,
715                                      size_t count, loff_t *ppos)
716 {
717         struct iwl_priv *priv = file->private_data;
718         int pos = 0;
719         char *buf;
720         int bufsz = sizeof(struct statistics_general) * 10 + 300;
721         ssize_t ret;
722         struct statistics_general_common *general, *accum_general;
723         struct statistics_general_common *delta_general, *max_general;
724         struct statistics_dbg *dbg, *accum_dbg, *delta_dbg, *max_dbg;
725         struct statistics_div *div, *accum_div, *delta_div, *max_div;
726
727         if (!iwl_is_alive(priv))
728                 return -EAGAIN;
729
730         buf = kzalloc(bufsz, GFP_KERNEL);
731         if (!buf) {
732                 IWL_ERR(priv, "Can not allocate Buffer\n");
733                 return -ENOMEM;
734         }
735
736         /* the statistic information display here is based on
737           * the last statistics notification from uCode
738           * might not reflect the current uCode activity
739           */
740         if (priv->cfg->bt_params &&
741             priv->cfg->bt_params->bt_statistics) {
742                 general = &priv->_agn.statistics_bt.general.common;
743                 dbg = &priv->_agn.statistics_bt.general.common.dbg;
744                 div = &priv->_agn.statistics_bt.general.common.div;
745                 accum_general = &priv->_agn.accum_statistics_bt.general.common;
746                 accum_dbg = &priv->_agn.accum_statistics_bt.general.common.dbg;
747                 accum_div = &priv->_agn.accum_statistics_bt.general.common.div;
748                 delta_general = &priv->_agn.delta_statistics_bt.general.common;
749                 max_general = &priv->_agn.max_delta_bt.general.common;
750                 delta_dbg = &priv->_agn.delta_statistics_bt.general.common.dbg;
751                 max_dbg = &priv->_agn.max_delta_bt.general.common.dbg;
752                 delta_div = &priv->_agn.delta_statistics_bt.general.common.div;
753                 max_div = &priv->_agn.max_delta_bt.general.common.div;
754         } else {
755                 general = &priv->_agn.statistics.general.common;
756                 dbg = &priv->_agn.statistics.general.common.dbg;
757                 div = &priv->_agn.statistics.general.common.div;
758                 accum_general = &priv->_agn.accum_statistics.general.common;
759                 accum_dbg = &priv->_agn.accum_statistics.general.common.dbg;
760                 accum_div = &priv->_agn.accum_statistics.general.common.div;
761                 delta_general = &priv->_agn.delta_statistics.general.common;
762                 max_general = &priv->_agn.max_delta.general.common;
763                 delta_dbg = &priv->_agn.delta_statistics.general.common.dbg;
764                 max_dbg = &priv->_agn.max_delta.general.common.dbg;
765                 delta_div = &priv->_agn.delta_statistics.general.common.div;
766                 max_div = &priv->_agn.max_delta.general.common.div;
767         }
768
769         pos += iwl_statistics_flag(priv, buf, bufsz);
770         pos += scnprintf(buf + pos, bufsz - pos,
771                          fmt_header, "Statistics_General:");
772         pos += scnprintf(buf + pos, bufsz - pos,
773                          fmt_value, "temperature:",
774                          le32_to_cpu(general->temperature));
775         pos += scnprintf(buf + pos, bufsz - pos,
776                          fmt_value, "temperature_m:",
777                          le32_to_cpu(general->temperature_m));
778         pos += scnprintf(buf + pos, bufsz - pos,
779                          fmt_value, "ttl_timestamp:",
780                          le32_to_cpu(general->ttl_timestamp));
781         pos += scnprintf(buf + pos, bufsz - pos,
782                          fmt_table, "burst_check:",
783                          le32_to_cpu(dbg->burst_check),
784                          accum_dbg->burst_check,
785                          delta_dbg->burst_check, max_dbg->burst_check);
786         pos += scnprintf(buf + pos, bufsz - pos,
787                          fmt_table, "burst_count:",
788                          le32_to_cpu(dbg->burst_count),
789                          accum_dbg->burst_count,
790                          delta_dbg->burst_count, max_dbg->burst_count);
791         pos += scnprintf(buf + pos, bufsz - pos,
792                          fmt_table, "wait_for_silence_timeout_count:",
793                          le32_to_cpu(dbg->wait_for_silence_timeout_cnt),
794                          accum_dbg->wait_for_silence_timeout_cnt,
795                          delta_dbg->wait_for_silence_timeout_cnt,
796                          max_dbg->wait_for_silence_timeout_cnt);
797         pos += scnprintf(buf + pos, bufsz - pos,
798                          fmt_table, "sleep_time:",
799                          le32_to_cpu(general->sleep_time),
800                          accum_general->sleep_time,
801                          delta_general->sleep_time, max_general->sleep_time);
802         pos += scnprintf(buf + pos, bufsz - pos,
803                          fmt_table, "slots_out:",
804                          le32_to_cpu(general->slots_out),
805                          accum_general->slots_out,
806                          delta_general->slots_out, max_general->slots_out);
807         pos += scnprintf(buf + pos, bufsz - pos,
808                          fmt_table, "slots_idle:",
809                          le32_to_cpu(general->slots_idle),
810                          accum_general->slots_idle,
811                          delta_general->slots_idle, max_general->slots_idle);
812         pos += scnprintf(buf + pos, bufsz - pos,
813                          fmt_table, "tx_on_a:",
814                          le32_to_cpu(div->tx_on_a), accum_div->tx_on_a,
815                          delta_div->tx_on_a, max_div->tx_on_a);
816         pos += scnprintf(buf + pos, bufsz - pos,
817                          fmt_table, "tx_on_b:",
818                          le32_to_cpu(div->tx_on_b), accum_div->tx_on_b,
819                          delta_div->tx_on_b, max_div->tx_on_b);
820         pos += scnprintf(buf + pos, bufsz - pos,
821                          fmt_table, "exec_time:",
822                          le32_to_cpu(div->exec_time), accum_div->exec_time,
823                          delta_div->exec_time, max_div->exec_time);
824         pos += scnprintf(buf + pos, bufsz - pos,
825                          fmt_table, "probe_time:",
826                          le32_to_cpu(div->probe_time), accum_div->probe_time,
827                          delta_div->probe_time, max_div->probe_time);
828         pos += scnprintf(buf + pos, bufsz - pos,
829                          fmt_table, "rx_enable_counter:",
830                          le32_to_cpu(general->rx_enable_counter),
831                          accum_general->rx_enable_counter,
832                          delta_general->rx_enable_counter,
833                          max_general->rx_enable_counter);
834         pos += scnprintf(buf + pos, bufsz - pos,
835                          fmt_table, "num_of_sos_states:",
836                          le32_to_cpu(general->num_of_sos_states),
837                          accum_general->num_of_sos_states,
838                          delta_general->num_of_sos_states,
839                          max_general->num_of_sos_states);
840         ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos);
841         kfree(buf);
842         return ret;
843 }
844
845 ssize_t iwl_ucode_bt_stats_read(struct file *file,
846                                 char __user *user_buf,
847                                 size_t count, loff_t *ppos)
848 {
849         struct iwl_priv *priv = (struct iwl_priv *)file->private_data;
850         int pos = 0;
851         char *buf;
852         int bufsz = (sizeof(struct statistics_bt_activity) * 24) + 200;
853         ssize_t ret;
854         struct statistics_bt_activity *bt, *accum_bt;
855
856         if (!iwl_is_alive(priv))
857                 return -EAGAIN;
858
859         /* make request to uCode to retrieve statistics information */
860         mutex_lock(&priv->mutex);
861         ret = iwl_send_statistics_request(priv, CMD_SYNC, false);
862         mutex_unlock(&priv->mutex);
863
864         if (ret) {
865                 IWL_ERR(priv,
866                         "Error sending statistics request: %zd\n", ret);
867                 return -EAGAIN;
868         }
869         buf = kzalloc(bufsz, GFP_KERNEL);
870         if (!buf) {
871                 IWL_ERR(priv, "Can not allocate Buffer\n");
872                 return -ENOMEM;
873         }
874
875         /*
876          * the statistic information display here is based on
877          * the last statistics notification from uCode
878          * might not reflect the current uCode activity
879          */
880         bt = &priv->_agn.statistics_bt.general.activity;
881         accum_bt = &priv->_agn.accum_statistics_bt.general.activity;
882
883         pos += iwl_statistics_flag(priv, buf, bufsz);
884         pos += scnprintf(buf + pos, bufsz - pos, "Statistics_BT:\n");
885         pos += scnprintf(buf + pos, bufsz - pos,
886                         "\t\t\tcurrent\t\t\taccumulative\n");
887         pos += scnprintf(buf + pos, bufsz - pos,
888                          "hi_priority_tx_req_cnt:\t\t%u\t\t\t%u\n",
889                          le32_to_cpu(bt->hi_priority_tx_req_cnt),
890                          accum_bt->hi_priority_tx_req_cnt);
891         pos += scnprintf(buf + pos, bufsz - pos,
892                          "hi_priority_tx_denied_cnt:\t%u\t\t\t%u\n",
893                          le32_to_cpu(bt->hi_priority_tx_denied_cnt),
894                          accum_bt->hi_priority_tx_denied_cnt);
895         pos += scnprintf(buf + pos, bufsz - pos,
896                          "lo_priority_tx_req_cnt:\t\t%u\t\t\t%u\n",
897                          le32_to_cpu(bt->lo_priority_tx_req_cnt),
898                          accum_bt->lo_priority_tx_req_cnt);
899         pos += scnprintf(buf + pos, bufsz - pos,
900                          "lo_priority_tx_denied_cnt:\t%u\t\t\t%u\n",
901                          le32_to_cpu(bt->lo_priority_tx_denied_cnt),
902                          accum_bt->lo_priority_tx_denied_cnt);
903         pos += scnprintf(buf + pos, bufsz - pos,
904                          "hi_priority_rx_req_cnt:\t\t%u\t\t\t%u\n",
905                          le32_to_cpu(bt->hi_priority_rx_req_cnt),
906                          accum_bt->hi_priority_rx_req_cnt);
907         pos += scnprintf(buf + pos, bufsz - pos,
908                          "hi_priority_rx_denied_cnt:\t%u\t\t\t%u\n",
909                          le32_to_cpu(bt->hi_priority_rx_denied_cnt),
910                          accum_bt->hi_priority_rx_denied_cnt);
911         pos += scnprintf(buf + pos, bufsz - pos,
912                          "lo_priority_rx_req_cnt:\t\t%u\t\t\t%u\n",
913                          le32_to_cpu(bt->lo_priority_rx_req_cnt),
914                          accum_bt->lo_priority_rx_req_cnt);
915         pos += scnprintf(buf + pos, bufsz - pos,
916                          "lo_priority_rx_denied_cnt:\t%u\t\t\t%u\n",
917                          le32_to_cpu(bt->lo_priority_rx_denied_cnt),
918                          accum_bt->lo_priority_rx_denied_cnt);
919
920         pos += scnprintf(buf + pos, bufsz - pos,
921                          "(rx)num_bt_kills:\t\t%u\t\t\t%u\n",
922                          le32_to_cpu(priv->_agn.statistics_bt.rx.
923                                 general.num_bt_kills),
924                          priv->_agn.accum_statistics_bt.rx.
925                                 general.num_bt_kills);
926
927         ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos);
928         kfree(buf);
929         return ret;
930 }
931
932 ssize_t iwl_reply_tx_error_read(struct file *file,
933                                 char __user *user_buf,
934                                 size_t count, loff_t *ppos)
935 {
936         struct iwl_priv *priv = (struct iwl_priv *)file->private_data;
937         int pos = 0;
938         char *buf;
939         int bufsz = (sizeof(struct reply_tx_error_statistics) * 24) +
940                 (sizeof(struct reply_agg_tx_error_statistics) * 24) + 200;
941         ssize_t ret;
942
943         if (!iwl_is_alive(priv))
944                 return -EAGAIN;
945
946         buf = kzalloc(bufsz, GFP_KERNEL);
947         if (!buf) {
948                 IWL_ERR(priv, "Can not allocate Buffer\n");
949                 return -ENOMEM;
950         }
951
952         pos += scnprintf(buf + pos, bufsz - pos, "Statistics_TX_Error:\n");
953         pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t\t\t%u\n",
954                          iwl_get_tx_fail_reason(TX_STATUS_POSTPONE_DELAY),
955                          priv->_agn.reply_tx_stats.pp_delay);
956         pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t\t%u\n",
957                          iwl_get_tx_fail_reason(TX_STATUS_POSTPONE_FEW_BYTES),
958                          priv->_agn.reply_tx_stats.pp_few_bytes);
959         pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t\t%u\n",
960                          iwl_get_tx_fail_reason(TX_STATUS_POSTPONE_BT_PRIO),
961                          priv->_agn.reply_tx_stats.pp_bt_prio);
962         pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t\t%u\n",
963                          iwl_get_tx_fail_reason(TX_STATUS_POSTPONE_QUIET_PERIOD),
964                          priv->_agn.reply_tx_stats.pp_quiet_period);
965         pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t\t%u\n",
966                          iwl_get_tx_fail_reason(TX_STATUS_POSTPONE_CALC_TTAK),
967                          priv->_agn.reply_tx_stats.pp_calc_ttak);
968         pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t%u\n",
969                          iwl_get_tx_fail_reason(
970                                 TX_STATUS_FAIL_INTERNAL_CROSSED_RETRY),
971                          priv->_agn.reply_tx_stats.int_crossed_retry);
972         pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t\t%u\n",
973                          iwl_get_tx_fail_reason(TX_STATUS_FAIL_SHORT_LIMIT),
974                          priv->_agn.reply_tx_stats.short_limit);
975         pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t\t%u\n",
976                          iwl_get_tx_fail_reason(TX_STATUS_FAIL_LONG_LIMIT),
977                          priv->_agn.reply_tx_stats.long_limit);
978         pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t\t%u\n",
979                          iwl_get_tx_fail_reason(TX_STATUS_FAIL_FIFO_UNDERRUN),
980                          priv->_agn.reply_tx_stats.fifo_underrun);
981         pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t\t%u\n",
982                          iwl_get_tx_fail_reason(TX_STATUS_FAIL_DRAIN_FLOW),
983                          priv->_agn.reply_tx_stats.drain_flow);
984         pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t\t%u\n",
985                          iwl_get_tx_fail_reason(TX_STATUS_FAIL_RFKILL_FLUSH),
986                          priv->_agn.reply_tx_stats.rfkill_flush);
987         pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t\t%u\n",
988                          iwl_get_tx_fail_reason(TX_STATUS_FAIL_LIFE_EXPIRE),
989                          priv->_agn.reply_tx_stats.life_expire);
990         pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t\t%u\n",
991                          iwl_get_tx_fail_reason(TX_STATUS_FAIL_DEST_PS),
992                          priv->_agn.reply_tx_stats.dest_ps);
993         pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t\t%u\n",
994                          iwl_get_tx_fail_reason(TX_STATUS_FAIL_HOST_ABORTED),
995                          priv->_agn.reply_tx_stats.host_abort);
996         pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t\t%u\n",
997                          iwl_get_tx_fail_reason(TX_STATUS_FAIL_BT_RETRY),
998                          priv->_agn.reply_tx_stats.pp_delay);
999         pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t\t%u\n",
1000                          iwl_get_tx_fail_reason(TX_STATUS_FAIL_STA_INVALID),
1001                          priv->_agn.reply_tx_stats.sta_invalid);
1002         pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t\t%u\n",
1003                          iwl_get_tx_fail_reason(TX_STATUS_FAIL_FRAG_DROPPED),
1004                          priv->_agn.reply_tx_stats.frag_drop);
1005         pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t\t%u\n",
1006                          iwl_get_tx_fail_reason(TX_STATUS_FAIL_TID_DISABLE),
1007                          priv->_agn.reply_tx_stats.tid_disable);
1008         pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t\t%u\n",
1009                          iwl_get_tx_fail_reason(TX_STATUS_FAIL_FIFO_FLUSHED),
1010                          priv->_agn.reply_tx_stats.fifo_flush);
1011         pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t%u\n",
1012                          iwl_get_tx_fail_reason(
1013                                 TX_STATUS_FAIL_INSUFFICIENT_CF_POLL),
1014                          priv->_agn.reply_tx_stats.insuff_cf_poll);
1015         pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t\t%u\n",
1016                          iwl_get_tx_fail_reason(TX_STATUS_FAIL_PASSIVE_NO_RX),
1017                          priv->_agn.reply_tx_stats.fail_hw_drop);
1018         pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t%u\n",
1019                          iwl_get_tx_fail_reason(
1020                                 TX_STATUS_FAIL_NO_BEACON_ON_RADAR),
1021                          priv->_agn.reply_tx_stats.sta_color_mismatch);
1022         pos += scnprintf(buf + pos, bufsz - pos, "UNKNOWN:\t\t\t%u\n",
1023                          priv->_agn.reply_tx_stats.unknown);
1024
1025         pos += scnprintf(buf + pos, bufsz - pos,
1026                          "\nStatistics_Agg_TX_Error:\n");
1027
1028         pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t\t%u\n",
1029                          iwl_get_agg_tx_fail_reason(AGG_TX_STATE_UNDERRUN_MSK),
1030                          priv->_agn.reply_agg_tx_stats.underrun);
1031         pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t\t%u\n",
1032                          iwl_get_agg_tx_fail_reason(AGG_TX_STATE_BT_PRIO_MSK),
1033                          priv->_agn.reply_agg_tx_stats.bt_prio);
1034         pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t\t%u\n",
1035                          iwl_get_agg_tx_fail_reason(AGG_TX_STATE_FEW_BYTES_MSK),
1036                          priv->_agn.reply_agg_tx_stats.few_bytes);
1037         pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t\t%u\n",
1038                          iwl_get_agg_tx_fail_reason(AGG_TX_STATE_ABORT_MSK),
1039                          priv->_agn.reply_agg_tx_stats.abort);
1040         pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t%u\n",
1041                          iwl_get_agg_tx_fail_reason(
1042                                 AGG_TX_STATE_LAST_SENT_TTL_MSK),
1043                          priv->_agn.reply_agg_tx_stats.last_sent_ttl);
1044         pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t%u\n",
1045                          iwl_get_agg_tx_fail_reason(
1046                                 AGG_TX_STATE_LAST_SENT_TRY_CNT_MSK),
1047                          priv->_agn.reply_agg_tx_stats.last_sent_try);
1048         pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t%u\n",
1049                          iwl_get_agg_tx_fail_reason(
1050                                 AGG_TX_STATE_LAST_SENT_BT_KILL_MSK),
1051                          priv->_agn.reply_agg_tx_stats.last_sent_bt_kill);
1052         pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t\t%u\n",
1053                          iwl_get_agg_tx_fail_reason(AGG_TX_STATE_SCD_QUERY_MSK),
1054                          priv->_agn.reply_agg_tx_stats.scd_query);
1055         pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t%u\n",
1056                          iwl_get_agg_tx_fail_reason(
1057                                 AGG_TX_STATE_TEST_BAD_CRC32_MSK),
1058                          priv->_agn.reply_agg_tx_stats.bad_crc32);
1059         pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t\t%u\n",
1060                          iwl_get_agg_tx_fail_reason(AGG_TX_STATE_RESPONSE_MSK),
1061                          priv->_agn.reply_agg_tx_stats.response);
1062         pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t\t%u\n",
1063                          iwl_get_agg_tx_fail_reason(AGG_TX_STATE_DUMP_TX_MSK),
1064                          priv->_agn.reply_agg_tx_stats.dump_tx);
1065         pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t\t%u\n",
1066                          iwl_get_agg_tx_fail_reason(AGG_TX_STATE_DELAY_TX_MSK),
1067                          priv->_agn.reply_agg_tx_stats.delay_tx);
1068         pos += scnprintf(buf + pos, bufsz - pos, "UNKNOWN:\t\t\t%u\n",
1069                          priv->_agn.reply_agg_tx_stats.unknown);
1070
1071         ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos);
1072         kfree(buf);
1073         return ret;
1074 }