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