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