aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/wireless/iwlwifi/iwl-debugfs.c
diff options
context:
space:
mode:
authorAndrea Bastoni <bastoni@cs.unc.edu>2010-05-30 19:16:45 -0400
committerAndrea Bastoni <bastoni@cs.unc.edu>2010-05-30 19:16:45 -0400
commitada47b5fe13d89735805b566185f4885f5a3f750 (patch)
tree644b88f8a71896307d71438e9b3af49126ffb22b /drivers/net/wireless/iwlwifi/iwl-debugfs.c
parent43e98717ad40a4ae64545b5ba047c7b86aa44f4f (diff)
parent3280f21d43ee541f97f8cda5792150d2dbec20d5 (diff)
Merge branch 'wip-2.6.34' into old-private-masterarchived-private-master
Diffstat (limited to 'drivers/net/wireless/iwlwifi/iwl-debugfs.c')
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-debugfs.c1610
1 files changed, 1124 insertions, 486 deletions
diff --git a/drivers/net/wireless/iwlwifi/iwl-debugfs.c b/drivers/net/wireless/iwlwifi/iwl-debugfs.c
index a198bcf61022..b6e1b0ebe230 100644
--- a/drivers/net/wireless/iwlwifi/iwl-debugfs.c
+++ b/drivers/net/wireless/iwlwifi/iwl-debugfs.c
@@ -2,7 +2,7 @@
2 * 2 *
3 * GPL LICENSE SUMMARY 3 * GPL LICENSE SUMMARY
4 * 4 *
5 * Copyright(c) 2008 - 2009 Intel Corporation. All rights reserved. 5 * Copyright(c) 2008 - 2010 Intel Corporation. All rights reserved.
6 * 6 *
7 * This program is free software; you can redistribute it and/or modify 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 8 * it under the terms of version 2 of the GNU General Public License as
@@ -26,6 +26,7 @@
26 * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497 26 * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
27 *****************************************************************************/ 27 *****************************************************************************/
28 28
29#include <linux/slab.h>
29#include <linux/kernel.h> 30#include <linux/kernel.h>
30#include <linux/module.h> 31#include <linux/module.h>
31#include <linux/debugfs.h> 32#include <linux/debugfs.h>
@@ -41,43 +42,28 @@
41#include "iwl-calib.h" 42#include "iwl-calib.h"
42 43
43/* create and remove of files */ 44/* create and remove of files */
44#define DEBUGFS_ADD_DIR(name, parent) do { \ 45#define DEBUGFS_ADD_FILE(name, parent, mode) do { \
45 dbgfs->dir_##name = debugfs_create_dir(#name, parent); \ 46 if (!debugfs_create_file(#name, mode, parent, priv, \
46 if (!(dbgfs->dir_##name)) \ 47 &iwl_dbgfs_##name##_ops)) \
47 goto err; \ 48 goto err; \
48} while (0) 49} while (0)
49 50
50#define DEBUGFS_ADD_FILE(name, parent) do { \ 51#define DEBUGFS_ADD_BOOL(name, parent, ptr) do { \
51 dbgfs->dbgfs_##parent##_files.file_##name = \ 52 struct dentry *__tmp; \
52 debugfs_create_file(#name, S_IWUSR | S_IRUSR, \ 53 __tmp = debugfs_create_bool(#name, S_IWUSR | S_IRUSR, \
53 dbgfs->dir_##parent, priv, \ 54 parent, ptr); \
54 &iwl_dbgfs_##name##_ops); \ 55 if (IS_ERR(__tmp) || !__tmp) \
55 if (!(dbgfs->dbgfs_##parent##_files.file_##name)) \ 56 goto err; \
56 goto err; \
57} while (0) 57} while (0)
58 58
59#define DEBUGFS_ADD_BOOL(name, parent, ptr) do { \ 59#define DEBUGFS_ADD_X32(name, parent, ptr) do { \
60 dbgfs->dbgfs_##parent##_files.file_##name = \ 60 struct dentry *__tmp; \
61 debugfs_create_bool(#name, S_IWUSR | S_IRUSR, \ 61 __tmp = debugfs_create_x32(#name, S_IWUSR | S_IRUSR, \
62 dbgfs->dir_##parent, ptr); \ 62 parent, ptr); \
63 if (IS_ERR(dbgfs->dbgfs_##parent##_files.file_##name) \ 63 if (IS_ERR(__tmp) || !__tmp) \
64 || !dbgfs->dbgfs_##parent##_files.file_##name) \ 64 goto err; \
65 goto err; \
66} while (0) 65} while (0)
67 66
68#define DEBUGFS_ADD_X32(name, parent, ptr) do { \
69 dbgfs->dbgfs_##parent##_files.file_##name = \
70 debugfs_create_x32(#name, S_IRUSR, dbgfs->dir_##parent, ptr); \
71 if (IS_ERR(dbgfs->dbgfs_##parent##_files.file_##name) \
72 || !dbgfs->dbgfs_##parent##_files.file_##name) \
73 goto err; \
74} while (0)
75
76#define DEBUGFS_REMOVE(name) do { \
77 debugfs_remove(name); \
78 name = NULL; \
79} while (0);
80
81/* file operation */ 67/* file operation */
82#define DEBUGFS_READ_FUNC(name) \ 68#define DEBUGFS_READ_FUNC(name) \
83static ssize_t iwl_dbgfs_##name##_read(struct file *file, \ 69static ssize_t iwl_dbgfs_##name##_read(struct file *file, \
@@ -125,27 +111,28 @@ static ssize_t iwl_dbgfs_tx_statistics_read(struct file *file,
125 char __user *user_buf, 111 char __user *user_buf,
126 size_t count, loff_t *ppos) { 112 size_t count, loff_t *ppos) {
127 113
128 struct iwl_priv *priv = (struct iwl_priv *)file->private_data; 114 struct iwl_priv *priv = file->private_data;
129 char *buf; 115 char *buf;
130 int pos = 0; 116 int pos = 0;
131 117
132 int cnt; 118 int cnt;
133 ssize_t ret; 119 ssize_t ret;
134 const size_t bufsz = 100 + sizeof(char) * 24 * (MANAGEMENT_MAX + CONTROL_MAX); 120 const size_t bufsz = 100 +
121 sizeof(char) * 50 * (MANAGEMENT_MAX + CONTROL_MAX);
135 buf = kzalloc(bufsz, GFP_KERNEL); 122 buf = kzalloc(bufsz, GFP_KERNEL);
136 if (!buf) 123 if (!buf)
137 return -ENOMEM; 124 return -ENOMEM;
138 pos += scnprintf(buf + pos, bufsz - pos, "Management:\n"); 125 pos += scnprintf(buf + pos, bufsz - pos, "Management:\n");
139 for (cnt = 0; cnt < MANAGEMENT_MAX; cnt++) { 126 for (cnt = 0; cnt < MANAGEMENT_MAX; cnt++) {
140 pos += scnprintf(buf + pos, bufsz - pos, 127 pos += scnprintf(buf + pos, bufsz - pos,
141 "\t%s\t\t: %u\n", 128 "\t%25s\t\t: %u\n",
142 get_mgmt_string(cnt), 129 get_mgmt_string(cnt),
143 priv->tx_stats.mgmt[cnt]); 130 priv->tx_stats.mgmt[cnt]);
144 } 131 }
145 pos += scnprintf(buf + pos, bufsz - pos, "Control\n"); 132 pos += scnprintf(buf + pos, bufsz - pos, "Control\n");
146 for (cnt = 0; cnt < CONTROL_MAX; cnt++) { 133 for (cnt = 0; cnt < CONTROL_MAX; cnt++) {
147 pos += scnprintf(buf + pos, bufsz - pos, 134 pos += scnprintf(buf + pos, bufsz - pos,
148 "\t%s\t\t: %u\n", 135 "\t%25s\t\t: %u\n",
149 get_ctrl_string(cnt), 136 get_ctrl_string(cnt),
150 priv->tx_stats.ctrl[cnt]); 137 priv->tx_stats.ctrl[cnt]);
151 } 138 }
@@ -159,7 +146,7 @@ static ssize_t iwl_dbgfs_tx_statistics_read(struct file *file,
159 return ret; 146 return ret;
160} 147}
161 148
162static ssize_t iwl_dbgfs_tx_statistics_write(struct file *file, 149static ssize_t iwl_dbgfs_clear_traffic_statistics_write(struct file *file,
163 const char __user *user_buf, 150 const char __user *user_buf,
164 size_t count, loff_t *ppos) 151 size_t count, loff_t *ppos)
165{ 152{
@@ -174,8 +161,7 @@ static ssize_t iwl_dbgfs_tx_statistics_write(struct file *file,
174 return -EFAULT; 161 return -EFAULT;
175 if (sscanf(buf, "%x", &clear_flag) != 1) 162 if (sscanf(buf, "%x", &clear_flag) != 1)
176 return -EFAULT; 163 return -EFAULT;
177 if (clear_flag == 1) 164 iwl_clear_traffic_stats(priv);
178 iwl_clear_tx_stats(priv);
179 165
180 return count; 166 return count;
181} 167}
@@ -184,13 +170,13 @@ static ssize_t iwl_dbgfs_rx_statistics_read(struct file *file,
184 char __user *user_buf, 170 char __user *user_buf,
185 size_t count, loff_t *ppos) { 171 size_t count, loff_t *ppos) {
186 172
187 struct iwl_priv *priv = (struct iwl_priv *)file->private_data; 173 struct iwl_priv *priv = file->private_data;
188 char *buf; 174 char *buf;
189 int pos = 0; 175 int pos = 0;
190 int cnt; 176 int cnt;
191 ssize_t ret; 177 ssize_t ret;
192 const size_t bufsz = 100 + 178 const size_t bufsz = 100 +
193 sizeof(char) * 24 * (MANAGEMENT_MAX + CONTROL_MAX); 179 sizeof(char) * 50 * (MANAGEMENT_MAX + CONTROL_MAX);
194 buf = kzalloc(bufsz, GFP_KERNEL); 180 buf = kzalloc(bufsz, GFP_KERNEL);
195 if (!buf) 181 if (!buf)
196 return -ENOMEM; 182 return -ENOMEM;
@@ -198,14 +184,14 @@ static ssize_t iwl_dbgfs_rx_statistics_read(struct file *file,
198 pos += scnprintf(buf + pos, bufsz - pos, "Management:\n"); 184 pos += scnprintf(buf + pos, bufsz - pos, "Management:\n");
199 for (cnt = 0; cnt < MANAGEMENT_MAX; cnt++) { 185 for (cnt = 0; cnt < MANAGEMENT_MAX; cnt++) {
200 pos += scnprintf(buf + pos, bufsz - pos, 186 pos += scnprintf(buf + pos, bufsz - pos,
201 "\t%s\t\t: %u\n", 187 "\t%25s\t\t: %u\n",
202 get_mgmt_string(cnt), 188 get_mgmt_string(cnt),
203 priv->rx_stats.mgmt[cnt]); 189 priv->rx_stats.mgmt[cnt]);
204 } 190 }
205 pos += scnprintf(buf + pos, bufsz - pos, "Control:\n"); 191 pos += scnprintf(buf + pos, bufsz - pos, "Control:\n");
206 for (cnt = 0; cnt < CONTROL_MAX; cnt++) { 192 for (cnt = 0; cnt < CONTROL_MAX; cnt++) {
207 pos += scnprintf(buf + pos, bufsz - pos, 193 pos += scnprintf(buf + pos, bufsz - pos,
208 "\t%s\t\t: %u\n", 194 "\t%25s\t\t: %u\n",
209 get_ctrl_string(cnt), 195 get_ctrl_string(cnt),
210 priv->rx_stats.ctrl[cnt]); 196 priv->rx_stats.ctrl[cnt]);
211 } 197 }
@@ -220,26 +206,6 @@ static ssize_t iwl_dbgfs_rx_statistics_read(struct file *file,
220 return ret; 206 return ret;
221} 207}
222 208
223static ssize_t iwl_dbgfs_rx_statistics_write(struct file *file,
224 const char __user *user_buf,
225 size_t count, loff_t *ppos)
226{
227 struct iwl_priv *priv = file->private_data;
228 u32 clear_flag;
229 char buf[8];
230 int buf_size;
231
232 memset(buf, 0, sizeof(buf));
233 buf_size = min(count, sizeof(buf) - 1);
234 if (copy_from_user(buf, user_buf, buf_size))
235 return -EFAULT;
236 if (sscanf(buf, "%x", &clear_flag) != 1)
237 return -EFAULT;
238 if (clear_flag == 1)
239 iwl_clear_rx_stats(priv);
240 return count;
241}
242
243#define BYTE1_MASK 0x000000ff; 209#define BYTE1_MASK 0x000000ff;
244#define BYTE2_MASK 0x0000ffff; 210#define BYTE2_MASK 0x0000ffff;
245#define BYTE3_MASK 0x00ffffff; 211#define BYTE3_MASK 0x00ffffff;
@@ -248,16 +214,32 @@ static ssize_t iwl_dbgfs_sram_read(struct file *file,
248 size_t count, loff_t *ppos) 214 size_t count, loff_t *ppos)
249{ 215{
250 u32 val; 216 u32 val;
251 char buf[1024]; 217 char *buf;
252 ssize_t ret; 218 ssize_t ret;
253 int i; 219 int i;
254 int pos = 0; 220 int pos = 0;
255 struct iwl_priv *priv = (struct iwl_priv *)file->private_data; 221 struct iwl_priv *priv = file->private_data;
256 const size_t bufsz = sizeof(buf); 222 size_t bufsz;
257 223
258 for (i = priv->dbgfs->sram_len; i > 0; i -= 4) { 224 /* default is to dump the entire data segment */
259 val = iwl_read_targ_mem(priv, priv->dbgfs->sram_offset + \ 225 if (!priv->dbgfs_sram_offset && !priv->dbgfs_sram_len) {
260 priv->dbgfs->sram_len - i); 226 priv->dbgfs_sram_offset = 0x800000;
227 if (priv->ucode_type == UCODE_INIT)
228 priv->dbgfs_sram_len = priv->ucode_init_data.len;
229 else
230 priv->dbgfs_sram_len = priv->ucode_data.len;
231 }
232 bufsz = 30 + priv->dbgfs_sram_len * sizeof(char) * 10;
233 buf = kmalloc(bufsz, GFP_KERNEL);
234 if (!buf)
235 return -ENOMEM;
236 pos += scnprintf(buf + pos, bufsz - pos, "sram_len: 0x%x\n",
237 priv->dbgfs_sram_len);
238 pos += scnprintf(buf + pos, bufsz - pos, "sram_offset: 0x%x\n",
239 priv->dbgfs_sram_offset);
240 for (i = priv->dbgfs_sram_len; i > 0; i -= 4) {
241 val = iwl_read_targ_mem(priv, priv->dbgfs_sram_offset + \
242 priv->dbgfs_sram_len - i);
261 if (i < 4) { 243 if (i < 4) {
262 switch (i) { 244 switch (i) {
263 case 1: 245 case 1:
@@ -271,11 +253,14 @@ static ssize_t iwl_dbgfs_sram_read(struct file *file,
271 break; 253 break;
272 } 254 }
273 } 255 }
256 if (!(i % 16))
257 pos += scnprintf(buf + pos, bufsz - pos, "\n");
274 pos += scnprintf(buf + pos, bufsz - pos, "0x%08x ", val); 258 pos += scnprintf(buf + pos, bufsz - pos, "0x%08x ", val);
275 } 259 }
276 pos += scnprintf(buf + pos, bufsz - pos, "\n"); 260 pos += scnprintf(buf + pos, bufsz - pos, "\n");
277 261
278 ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos); 262 ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos);
263 kfree(buf);
279 return ret; 264 return ret;
280} 265}
281 266
@@ -294,11 +279,11 @@ static ssize_t iwl_dbgfs_sram_write(struct file *file,
294 return -EFAULT; 279 return -EFAULT;
295 280
296 if (sscanf(buf, "%x,%x", &offset, &len) == 2) { 281 if (sscanf(buf, "%x,%x", &offset, &len) == 2) {
297 priv->dbgfs->sram_offset = offset; 282 priv->dbgfs_sram_offset = offset;
298 priv->dbgfs->sram_len = len; 283 priv->dbgfs_sram_len = len;
299 } else { 284 } else {
300 priv->dbgfs->sram_offset = 0; 285 priv->dbgfs_sram_offset = 0;
301 priv->dbgfs->sram_len = 0; 286 priv->dbgfs_sram_len = 0;
302 } 287 }
303 288
304 return count; 289 return count;
@@ -307,7 +292,7 @@ static ssize_t iwl_dbgfs_sram_write(struct file *file,
307static ssize_t iwl_dbgfs_stations_read(struct file *file, char __user *user_buf, 292static ssize_t iwl_dbgfs_stations_read(struct file *file, char __user *user_buf,
308 size_t count, loff_t *ppos) 293 size_t count, loff_t *ppos)
309{ 294{
310 struct iwl_priv *priv = (struct iwl_priv *)file->private_data; 295 struct iwl_priv *priv = file->private_data;
311 struct iwl_station_entry *station; 296 struct iwl_station_entry *station;
312 int max_sta = priv->hw_params.max_stations; 297 int max_sta = priv->hw_params.max_stations;
313 char *buf; 298 char *buf;
@@ -335,8 +320,6 @@ static ssize_t iwl_dbgfs_stations_read(struct file *file, char __user *user_buf,
335 pos += scnprintf(buf + pos, bufsz - pos, 320 pos += scnprintf(buf + pos, bufsz - pos,
336 "flags: 0x%x\n", 321 "flags: 0x%x\n",
337 station->sta.station_flags_msk); 322 station->sta.station_flags_msk);
338 pos += scnprintf(buf + pos, bufsz - pos,
339 "ps_status: %u\n", station->ps_status);
340 pos += scnprintf(buf + pos, bufsz - pos, "tid data:\n"); 323 pos += scnprintf(buf + pos, bufsz - pos, "tid data:\n");
341 pos += scnprintf(buf + pos, bufsz - pos, 324 pos += scnprintf(buf + pos, bufsz - pos,
342 "seq_num\t\ttxq_id"); 325 "seq_num\t\ttxq_id");
@@ -379,10 +362,11 @@ static ssize_t iwl_dbgfs_nvm_read(struct file *file,
379 loff_t *ppos) 362 loff_t *ppos)
380{ 363{
381 ssize_t ret; 364 ssize_t ret;
382 struct iwl_priv *priv = (struct iwl_priv *)file->private_data; 365 struct iwl_priv *priv = file->private_data;
383 int pos = 0, ofs = 0, buf_size = 0; 366 int pos = 0, ofs = 0, buf_size = 0;
384 const u8 *ptr; 367 const u8 *ptr;
385 char *buf; 368 char *buf;
369 u16 eeprom_ver;
386 size_t eeprom_len = priv->cfg->eeprom_size; 370 size_t eeprom_len = priv->cfg->eeprom_size;
387 buf_size = 4 * eeprom_len + 256; 371 buf_size = 4 * eeprom_len + 256;
388 372
@@ -403,9 +387,11 @@ static ssize_t iwl_dbgfs_nvm_read(struct file *file,
403 IWL_ERR(priv, "Can not allocate Buffer\n"); 387 IWL_ERR(priv, "Can not allocate Buffer\n");
404 return -ENOMEM; 388 return -ENOMEM;
405 } 389 }
406 pos += scnprintf(buf + pos, buf_size - pos, "NVM Type: %s\n", 390 eeprom_ver = iwl_eeprom_query16(priv, EEPROM_VERSION);
391 pos += scnprintf(buf + pos, buf_size - pos, "NVM Type: %s, "
392 "version: 0x%x\n",
407 (priv->nvm_device_type == NVM_DEVICE_TYPE_OTP) 393 (priv->nvm_device_type == NVM_DEVICE_TYPE_OTP)
408 ? "OTP" : "EEPROM"); 394 ? "OTP" : "EEPROM", eeprom_ver);
409 for (ofs = 0 ; ofs < eeprom_len ; ofs += 16) { 395 for (ofs = 0 ; ofs < eeprom_len ; ofs += 16) {
410 pos += scnprintf(buf + pos, buf_size - pos, "0x%.4x ", ofs); 396 pos += scnprintf(buf + pos, buf_size - pos, "0x%.4x ", ofs);
411 hex_dump_to_buffer(ptr + ofs, 16 , 16, 2, buf + pos, 397 hex_dump_to_buffer(ptr + ofs, 16 , 16, 2, buf + pos,
@@ -420,6 +406,24 @@ static ssize_t iwl_dbgfs_nvm_read(struct file *file,
420 return ret; 406 return ret;
421} 407}
422 408
409static ssize_t iwl_dbgfs_log_event_read(struct file *file,
410 char __user *user_buf,
411 size_t count, loff_t *ppos)
412{
413 struct iwl_priv *priv = file->private_data;
414 char *buf;
415 int pos = 0;
416 ssize_t ret = -ENOMEM;
417
418 ret = pos = priv->cfg->ops->lib->dump_nic_event_log(
419 priv, true, &buf, true);
420 if (buf) {
421 ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos);
422 kfree(buf);
423 }
424 return ret;
425}
426
423static ssize_t iwl_dbgfs_log_event_write(struct file *file, 427static ssize_t iwl_dbgfs_log_event_write(struct file *file,
424 const char __user *user_buf, 428 const char __user *user_buf,
425 size_t count, loff_t *ppos) 429 size_t count, loff_t *ppos)
@@ -436,7 +440,8 @@ static ssize_t iwl_dbgfs_log_event_write(struct file *file,
436 if (sscanf(buf, "%d", &event_log_flag) != 1) 440 if (sscanf(buf, "%d", &event_log_flag) != 1)
437 return -EFAULT; 441 return -EFAULT;
438 if (event_log_flag == 1) 442 if (event_log_flag == 1)
439 priv->cfg->ops->lib->dump_nic_event_log(priv); 443 priv->cfg->ops->lib->dump_nic_event_log(priv, true,
444 NULL, false);
440 445
441 return count; 446 return count;
442} 447}
@@ -446,7 +451,7 @@ static ssize_t iwl_dbgfs_log_event_write(struct file *file,
446static ssize_t iwl_dbgfs_channels_read(struct file *file, char __user *user_buf, 451static ssize_t iwl_dbgfs_channels_read(struct file *file, char __user *user_buf,
447 size_t count, loff_t *ppos) 452 size_t count, loff_t *ppos)
448{ 453{
449 struct iwl_priv *priv = (struct iwl_priv *)file->private_data; 454 struct iwl_priv *priv = file->private_data;
450 struct ieee80211_channel *channels = NULL; 455 struct ieee80211_channel *channels = NULL;
451 const struct ieee80211_supported_band *supp_band = NULL; 456 const struct ieee80211_supported_band *supp_band = NULL;
452 int pos = 0, i, bufsz = PAGE_SIZE; 457 int pos = 0, i, bufsz = PAGE_SIZE;
@@ -519,19 +524,19 @@ static ssize_t iwl_dbgfs_status_read(struct file *file,
519 char __user *user_buf, 524 char __user *user_buf,
520 size_t count, loff_t *ppos) { 525 size_t count, loff_t *ppos) {
521 526
522 struct iwl_priv *priv = (struct iwl_priv *)file->private_data; 527 struct iwl_priv *priv = file->private_data;
523 char buf[512]; 528 char buf[512];
524 int pos = 0; 529 int pos = 0;
525 const size_t bufsz = sizeof(buf); 530 const size_t bufsz = sizeof(buf);
526 531
527 pos += scnprintf(buf + pos, bufsz - pos, "STATUS_HCMD_ACTIVE:\t %d\n", 532 pos += scnprintf(buf + pos, bufsz - pos, "STATUS_HCMD_ACTIVE:\t %d\n",
528 test_bit(STATUS_HCMD_ACTIVE, &priv->status)); 533 test_bit(STATUS_HCMD_ACTIVE, &priv->status));
529 pos += scnprintf(buf + pos, bufsz - pos, "STATUS_HCMD_SYNC_ACTIVE: %d\n",
530 test_bit(STATUS_HCMD_SYNC_ACTIVE, &priv->status));
531 pos += scnprintf(buf + pos, bufsz - pos, "STATUS_INT_ENABLED:\t %d\n", 534 pos += scnprintf(buf + pos, bufsz - pos, "STATUS_INT_ENABLED:\t %d\n",
532 test_bit(STATUS_INT_ENABLED, &priv->status)); 535 test_bit(STATUS_INT_ENABLED, &priv->status));
533 pos += scnprintf(buf + pos, bufsz - pos, "STATUS_RF_KILL_HW:\t %d\n", 536 pos += scnprintf(buf + pos, bufsz - pos, "STATUS_RF_KILL_HW:\t %d\n",
534 test_bit(STATUS_RF_KILL_HW, &priv->status)); 537 test_bit(STATUS_RF_KILL_HW, &priv->status));
538 pos += scnprintf(buf + pos, bufsz - pos, "STATUS_CT_KILL:\t\t %d\n",
539 test_bit(STATUS_CT_KILL, &priv->status));
535 pos += scnprintf(buf + pos, bufsz - pos, "STATUS_INIT:\t\t %d\n", 540 pos += scnprintf(buf + pos, bufsz - pos, "STATUS_INIT:\t\t %d\n",
536 test_bit(STATUS_INIT, &priv->status)); 541 test_bit(STATUS_INIT, &priv->status));
537 pos += scnprintf(buf + pos, bufsz - pos, "STATUS_ALIVE:\t\t %d\n", 542 pos += scnprintf(buf + pos, bufsz - pos, "STATUS_ALIVE:\t\t %d\n",
@@ -565,7 +570,7 @@ static ssize_t iwl_dbgfs_interrupt_read(struct file *file,
565 char __user *user_buf, 570 char __user *user_buf,
566 size_t count, loff_t *ppos) { 571 size_t count, loff_t *ppos) {
567 572
568 struct iwl_priv *priv = (struct iwl_priv *)file->private_data; 573 struct iwl_priv *priv = file->private_data;
569 int pos = 0; 574 int pos = 0;
570 int cnt = 0; 575 int cnt = 0;
571 char *buf; 576 char *buf;
@@ -652,7 +657,7 @@ static ssize_t iwl_dbgfs_interrupt_write(struct file *file,
652static ssize_t iwl_dbgfs_qos_read(struct file *file, char __user *user_buf, 657static ssize_t iwl_dbgfs_qos_read(struct file *file, char __user *user_buf,
653 size_t count, loff_t *ppos) 658 size_t count, loff_t *ppos)
654{ 659{
655 struct iwl_priv *priv = (struct iwl_priv *)file->private_data; 660 struct iwl_priv *priv = file->private_data;
656 int pos = 0, i; 661 int pos = 0, i;
657 char buf[256]; 662 char buf[256];
658 const size_t bufsz = sizeof(buf); 663 const size_t bufsz = sizeof(buf);
@@ -672,11 +677,10 @@ static ssize_t iwl_dbgfs_qos_read(struct file *file, char __user *user_buf,
672 return ret; 677 return ret;
673} 678}
674 679
675#ifdef CONFIG_IWLWIFI_LEDS
676static ssize_t iwl_dbgfs_led_read(struct file *file, char __user *user_buf, 680static ssize_t iwl_dbgfs_led_read(struct file *file, char __user *user_buf,
677 size_t count, loff_t *ppos) 681 size_t count, loff_t *ppos)
678{ 682{
679 struct iwl_priv *priv = (struct iwl_priv *)file->private_data; 683 struct iwl_priv *priv = file->private_data;
680 int pos = 0; 684 int pos = 0;
681 char buf[256]; 685 char buf[256];
682 const size_t bufsz = sizeof(buf); 686 const size_t bufsz = sizeof(buf);
@@ -697,13 +701,12 @@ static ssize_t iwl_dbgfs_led_read(struct file *file, char __user *user_buf,
697 ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos); 701 ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos);
698 return ret; 702 return ret;
699} 703}
700#endif
701 704
702static ssize_t iwl_dbgfs_thermal_throttling_read(struct file *file, 705static ssize_t iwl_dbgfs_thermal_throttling_read(struct file *file,
703 char __user *user_buf, 706 char __user *user_buf,
704 size_t count, loff_t *ppos) 707 size_t count, loff_t *ppos)
705{ 708{
706 struct iwl_priv *priv = (struct iwl_priv *)file->private_data; 709 struct iwl_priv *priv = file->private_data;
707 struct iwl_tt_mgmt *tt = &priv->thermal_throttle; 710 struct iwl_tt_mgmt *tt = &priv->thermal_throttle;
708 struct iwl_tt_restriction *restriction; 711 struct iwl_tt_restriction *restriction;
709 char buf[100]; 712 char buf[100];
@@ -763,7 +766,7 @@ static ssize_t iwl_dbgfs_disable_ht40_read(struct file *file,
763 char __user *user_buf, 766 char __user *user_buf,
764 size_t count, loff_t *ppos) 767 size_t count, loff_t *ppos)
765{ 768{
766 struct iwl_priv *priv = (struct iwl_priv *)file->private_data; 769 struct iwl_priv *priv = file->private_data;
767 char buf[100]; 770 char buf[100];
768 int pos = 0; 771 int pos = 0;
769 const size_t bufsz = sizeof(buf); 772 const size_t bufsz = sizeof(buf);
@@ -798,15 +801,22 @@ static ssize_t iwl_dbgfs_sleep_level_override_write(struct file *file,
798 * valid here. However, let's not confuse them and present 801 * valid here. However, let's not confuse them and present
799 * IWL_POWER_INDEX_1 as "1", not "0". 802 * IWL_POWER_INDEX_1 as "1", not "0".
800 */ 803 */
801 if (value > 0) 804 if (value == 0)
805 return -EINVAL;
806 else if (value > 0)
802 value -= 1; 807 value -= 1;
803 808
804 if (value != -1 && (value < 0 || value >= IWL_POWER_NUM)) 809 if (value != -1 && (value < 0 || value >= IWL_POWER_NUM))
805 return -EINVAL; 810 return -EINVAL;
806 811
812 if (!iwl_is_ready_rf(priv))
813 return -EAGAIN;
814
807 priv->power_data.debug_sleep_level_override = value; 815 priv->power_data.debug_sleep_level_override = value;
808 816
809 iwl_power_update_mode(priv, false); 817 mutex_lock(&priv->mutex);
818 iwl_power_update_mode(priv, true);
819 mutex_unlock(&priv->mutex);
810 820
811 return count; 821 return count;
812} 822}
@@ -815,7 +825,7 @@ static ssize_t iwl_dbgfs_sleep_level_override_read(struct file *file,
815 char __user *user_buf, 825 char __user *user_buf,
816 size_t count, loff_t *ppos) 826 size_t count, loff_t *ppos)
817{ 827{
818 struct iwl_priv *priv = (struct iwl_priv *)file->private_data; 828 struct iwl_priv *priv = file->private_data;
819 char buf[10]; 829 char buf[10];
820 int pos, value; 830 int pos, value;
821 const size_t bufsz = sizeof(buf); 831 const size_t bufsz = sizeof(buf);
@@ -833,7 +843,7 @@ static ssize_t iwl_dbgfs_current_sleep_command_read(struct file *file,
833 char __user *user_buf, 843 char __user *user_buf,
834 size_t count, loff_t *ppos) 844 size_t count, loff_t *ppos)
835{ 845{
836 struct iwl_priv *priv = (struct iwl_priv *)file->private_data; 846 struct iwl_priv *priv = file->private_data;
837 char buf[200]; 847 char buf[200];
838 int pos = 0, i; 848 int pos = 0, i;
839 const size_t bufsz = sizeof(buf); 849 const size_t bufsz = sizeof(buf);
@@ -854,16 +864,14 @@ static ssize_t iwl_dbgfs_current_sleep_command_read(struct file *file,
854} 864}
855 865
856DEBUGFS_READ_WRITE_FILE_OPS(sram); 866DEBUGFS_READ_WRITE_FILE_OPS(sram);
857DEBUGFS_WRITE_FILE_OPS(log_event); 867DEBUGFS_READ_WRITE_FILE_OPS(log_event);
858DEBUGFS_READ_FILE_OPS(nvm); 868DEBUGFS_READ_FILE_OPS(nvm);
859DEBUGFS_READ_FILE_OPS(stations); 869DEBUGFS_READ_FILE_OPS(stations);
860DEBUGFS_READ_FILE_OPS(channels); 870DEBUGFS_READ_FILE_OPS(channels);
861DEBUGFS_READ_FILE_OPS(status); 871DEBUGFS_READ_FILE_OPS(status);
862DEBUGFS_READ_WRITE_FILE_OPS(interrupt); 872DEBUGFS_READ_WRITE_FILE_OPS(interrupt);
863DEBUGFS_READ_FILE_OPS(qos); 873DEBUGFS_READ_FILE_OPS(qos);
864#ifdef CONFIG_IWLWIFI_LEDS
865DEBUGFS_READ_FILE_OPS(led); 874DEBUGFS_READ_FILE_OPS(led);
866#endif
867DEBUGFS_READ_FILE_OPS(thermal_throttling); 875DEBUGFS_READ_FILE_OPS(thermal_throttling);
868DEBUGFS_READ_WRITE_FILE_OPS(disable_ht40); 876DEBUGFS_READ_WRITE_FILE_OPS(disable_ht40);
869DEBUGFS_READ_WRITE_FILE_OPS(sleep_level_override); 877DEBUGFS_READ_WRITE_FILE_OPS(sleep_level_override);
@@ -881,10 +889,14 @@ static ssize_t iwl_dbgfs_traffic_log_read(struct file *file,
881 struct iwl_rx_queue *rxq = &priv->rxq; 889 struct iwl_rx_queue *rxq = &priv->rxq;
882 char *buf; 890 char *buf;
883 int bufsz = ((IWL_TRAFFIC_ENTRIES * IWL_TRAFFIC_ENTRY_SIZE * 64) * 2) + 891 int bufsz = ((IWL_TRAFFIC_ENTRIES * IWL_TRAFFIC_ENTRY_SIZE * 64) * 2) +
884 (IWL_MAX_NUM_QUEUES * 32 * 8) + 400; 892 (priv->cfg->num_of_queues * 32 * 8) + 400;
885 const u8 *ptr; 893 const u8 *ptr;
886 ssize_t ret; 894 ssize_t ret;
887 895
896 if (!priv->txq) {
897 IWL_ERR(priv, "txq not ready\n");
898 return -EAGAIN;
899 }
888 buf = kzalloc(bufsz, GFP_KERNEL); 900 buf = kzalloc(bufsz, GFP_KERNEL);
889 if (!buf) { 901 if (!buf) {
890 IWL_ERR(priv, "Can not allocate buffer\n"); 902 IWL_ERR(priv, "Can not allocate buffer\n");
@@ -969,15 +981,19 @@ static ssize_t iwl_dbgfs_tx_queue_read(struct file *file,
969 char __user *user_buf, 981 char __user *user_buf,
970 size_t count, loff_t *ppos) { 982 size_t count, loff_t *ppos) {
971 983
972 struct iwl_priv *priv = (struct iwl_priv *)file->private_data; 984 struct iwl_priv *priv = file->private_data;
973 struct iwl_tx_queue *txq; 985 struct iwl_tx_queue *txq;
974 struct iwl_queue *q; 986 struct iwl_queue *q;
975 char *buf; 987 char *buf;
976 int pos = 0; 988 int pos = 0;
977 int cnt; 989 int cnt;
978 int ret; 990 int ret;
979 const size_t bufsz = sizeof(char) * 60 * IWL_MAX_NUM_QUEUES; 991 const size_t bufsz = sizeof(char) * 64 * priv->cfg->num_of_queues;
980 992
993 if (!priv->txq) {
994 IWL_ERR(priv, "txq not ready\n");
995 return -EAGAIN;
996 }
981 buf = kzalloc(bufsz, GFP_KERNEL); 997 buf = kzalloc(bufsz, GFP_KERNEL);
982 if (!buf) 998 if (!buf)
983 return -ENOMEM; 999 return -ENOMEM;
@@ -1011,7 +1027,7 @@ static ssize_t iwl_dbgfs_rx_queue_read(struct file *file,
1011 char __user *user_buf, 1027 char __user *user_buf,
1012 size_t count, loff_t *ppos) { 1028 size_t count, loff_t *ppos) {
1013 1029
1014 struct iwl_priv *priv = (struct iwl_priv *)file->private_data; 1030 struct iwl_priv *priv = file->private_data;
1015 struct iwl_rx_queue *rxq = &priv->rxq; 1031 struct iwl_rx_queue *rxq = &priv->rxq;
1016 char buf[256]; 1032 char buf[256];
1017 int pos = 0; 1033 int pos = 0;
@@ -1028,10 +1044,6 @@ static ssize_t iwl_dbgfs_rx_queue_read(struct file *file,
1028 return simple_read_from_buffer(user_buf, count, ppos, buf, pos); 1044 return simple_read_from_buffer(user_buf, count, ppos, buf, pos);
1029} 1045}
1030 1046
1031#define UCODE_STATISTICS_CLEAR_MSK (0x1 << 0)
1032#define UCODE_STATISTICS_FREQUENCY_MSK (0x1 << 1)
1033#define UCODE_STATISTICS_NARROW_BAND_MSK (0x1 << 2)
1034
1035static int iwl_dbgfs_statistics_flag(struct iwl_priv *priv, char *buf, 1047static int iwl_dbgfs_statistics_flag(struct iwl_priv *priv, char *buf,
1036 int bufsz) 1048 int bufsz)
1037{ 1049{
@@ -1056,36 +1068,33 @@ static int iwl_dbgfs_statistics_flag(struct iwl_priv *priv, char *buf,
1056 return p; 1068 return p;
1057} 1069}
1058 1070
1071static const char ucode_stats_header[] =
1072 "%-32s current acumulative delta max\n";
1073static const char ucode_stats_short_format[] =
1074 " %-30s %10u\n";
1075static const char ucode_stats_format[] =
1076 " %-30s %10u %10u %10u %10u\n";
1059 1077
1060static ssize_t iwl_dbgfs_ucode_rx_stats_read(struct file *file, 1078static ssize_t iwl_dbgfs_ucode_rx_stats_read(struct file *file,
1061 char __user *user_buf, 1079 char __user *user_buf,
1062 size_t count, loff_t *ppos) 1080 size_t count, loff_t *ppos)
1063{ 1081{
1064 struct iwl_priv *priv = (struct iwl_priv *)file->private_data; 1082 struct iwl_priv *priv = file->private_data;
1065 int pos = 0; 1083 int pos = 0;
1066 char *buf; 1084 char *buf;
1067 int bufsz = sizeof(struct statistics_rx_phy) * 20 + 1085 int bufsz = sizeof(struct statistics_rx_phy) * 40 +
1068 sizeof(struct statistics_rx_non_phy) * 20 + 1086 sizeof(struct statistics_rx_non_phy) * 40 +
1069 sizeof(struct statistics_rx_ht_phy) * 20 + 400; 1087 sizeof(struct statistics_rx_ht_phy) * 40 + 400;
1070 ssize_t ret; 1088 ssize_t ret;
1071 struct statistics_rx_phy *ofdm; 1089 struct statistics_rx_phy *ofdm, *accum_ofdm, *delta_ofdm, *max_ofdm;
1072 struct statistics_rx_phy *cck; 1090 struct statistics_rx_phy *cck, *accum_cck, *delta_cck, *max_cck;
1073 struct statistics_rx_non_phy *general; 1091 struct statistics_rx_non_phy *general, *accum_general;
1074 struct statistics_rx_ht_phy *ht; 1092 struct statistics_rx_non_phy *delta_general, *max_general;
1093 struct statistics_rx_ht_phy *ht, *accum_ht, *delta_ht, *max_ht;
1075 1094
1076 if (!iwl_is_alive(priv)) 1095 if (!iwl_is_alive(priv))
1077 return -EAGAIN; 1096 return -EAGAIN;
1078 1097
1079 /* make request to uCode to retrieve statistics information */
1080 mutex_lock(&priv->mutex);
1081 ret = iwl_send_statistics_request(priv, 0);
1082 mutex_unlock(&priv->mutex);
1083
1084 if (ret) {
1085 IWL_ERR(priv,
1086 "Error sending statistics request: %zd\n", ret);
1087 return -EAGAIN;
1088 }
1089 buf = kzalloc(bufsz, GFP_KERNEL); 1098 buf = kzalloc(bufsz, GFP_KERNEL);
1090 if (!buf) { 1099 if (!buf) {
1091 IWL_ERR(priv, "Can not allocate Buffer\n"); 1100 IWL_ERR(priv, "Can not allocate Buffer\n");
@@ -1100,155 +1109,405 @@ static ssize_t iwl_dbgfs_ucode_rx_stats_read(struct file *file,
1100 cck = &priv->statistics.rx.cck; 1109 cck = &priv->statistics.rx.cck;
1101 general = &priv->statistics.rx.general; 1110 general = &priv->statistics.rx.general;
1102 ht = &priv->statistics.rx.ofdm_ht; 1111 ht = &priv->statistics.rx.ofdm_ht;
1112 accum_ofdm = &priv->accum_statistics.rx.ofdm;
1113 accum_cck = &priv->accum_statistics.rx.cck;
1114 accum_general = &priv->accum_statistics.rx.general;
1115 accum_ht = &priv->accum_statistics.rx.ofdm_ht;
1116 delta_ofdm = &priv->delta_statistics.rx.ofdm;
1117 delta_cck = &priv->delta_statistics.rx.cck;
1118 delta_general = &priv->delta_statistics.rx.general;
1119 delta_ht = &priv->delta_statistics.rx.ofdm_ht;
1120 max_ofdm = &priv->max_delta.rx.ofdm;
1121 max_cck = &priv->max_delta.rx.cck;
1122 max_general = &priv->max_delta.rx.general;
1123 max_ht = &priv->max_delta.rx.ofdm_ht;
1124
1103 pos += iwl_dbgfs_statistics_flag(priv, buf, bufsz); 1125 pos += iwl_dbgfs_statistics_flag(priv, buf, bufsz);
1104 pos += scnprintf(buf + pos, bufsz - pos, "Statistics_Rx - OFDM:\n"); 1126 pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_header,
1105 pos += scnprintf(buf + pos, bufsz - pos, "ina_cnt: %u\n", 1127 "Statistics_Rx - OFDM:");
1106 le32_to_cpu(ofdm->ina_cnt)); 1128 pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
1107 pos += scnprintf(buf + pos, bufsz - pos, "fina_cnt: %u\n", 1129 "ina_cnt:", le32_to_cpu(ofdm->ina_cnt),
1108 le32_to_cpu(ofdm->fina_cnt)); 1130 accum_ofdm->ina_cnt,
1109 pos += scnprintf(buf + pos, bufsz - pos, "plcp_err: %u\n", 1131 delta_ofdm->ina_cnt, max_ofdm->ina_cnt);
1110 le32_to_cpu(ofdm->plcp_err)); 1132 pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
1111 pos += scnprintf(buf + pos, bufsz - pos, "crc32_err: %u\n", 1133 "fina_cnt:",
1112 le32_to_cpu(ofdm->crc32_err)); 1134 le32_to_cpu(ofdm->fina_cnt), accum_ofdm->fina_cnt,
1113 pos += scnprintf(buf + pos, bufsz - pos, "overrun_err: %u\n", 1135 delta_ofdm->fina_cnt, max_ofdm->fina_cnt);
1114 le32_to_cpu(ofdm->overrun_err)); 1136 pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
1115 pos += scnprintf(buf + pos, bufsz - pos, "early_overrun_err: %u\n", 1137 "plcp_err:",
1116 le32_to_cpu(ofdm->early_overrun_err)); 1138 le32_to_cpu(ofdm->plcp_err), accum_ofdm->plcp_err,
1117 pos += scnprintf(buf + pos, bufsz - pos, "crc32_good: %u\n", 1139 delta_ofdm->plcp_err, max_ofdm->plcp_err);
1118 le32_to_cpu(ofdm->crc32_good)); 1140 pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
1119 pos += scnprintf(buf + pos, bufsz - pos, "false_alarm_cnt: %u\n", 1141 "crc32_err:",
1120 le32_to_cpu(ofdm->false_alarm_cnt)); 1142 le32_to_cpu(ofdm->crc32_err), accum_ofdm->crc32_err,
1121 pos += scnprintf(buf + pos, bufsz - pos, "fina_sync_err_cnt: %u\n", 1143 delta_ofdm->crc32_err, max_ofdm->crc32_err);
1122 le32_to_cpu(ofdm->fina_sync_err_cnt)); 1144 pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
1123 pos += scnprintf(buf + pos, bufsz - pos, "sfd_timeout: %u\n", 1145 "overrun_err:",
1124 le32_to_cpu(ofdm->sfd_timeout)); 1146 le32_to_cpu(ofdm->overrun_err),
1125 pos += scnprintf(buf + pos, bufsz - pos, "fina_timeout: %u\n", 1147 accum_ofdm->overrun_err,
1126 le32_to_cpu(ofdm->fina_timeout)); 1148 delta_ofdm->overrun_err, max_ofdm->overrun_err);
1127 pos += scnprintf(buf + pos, bufsz - pos, "unresponded_rts: %u\n", 1149 pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
1128 le32_to_cpu(ofdm->unresponded_rts)); 1150 "early_overrun_err:",
1129 pos += scnprintf(buf + pos, bufsz - pos, 1151 le32_to_cpu(ofdm->early_overrun_err),
1130 "rxe_frame_limit_overrun: %u\n", 1152 accum_ofdm->early_overrun_err,
1131 le32_to_cpu(ofdm->rxe_frame_limit_overrun)); 1153 delta_ofdm->early_overrun_err,
1132 pos += scnprintf(buf + pos, bufsz - pos, "sent_ack_cnt: %u\n", 1154 max_ofdm->early_overrun_err);
1133 le32_to_cpu(ofdm->sent_ack_cnt)); 1155 pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
1134 pos += scnprintf(buf + pos, bufsz - pos, "sent_cts_cnt: %u\n", 1156 "crc32_good:",
1135 le32_to_cpu(ofdm->sent_cts_cnt)); 1157 le32_to_cpu(ofdm->crc32_good),
1136 pos += scnprintf(buf + pos, bufsz - pos, "sent_ba_rsp_cnt: %u\n", 1158 accum_ofdm->crc32_good,
1137 le32_to_cpu(ofdm->sent_ba_rsp_cnt)); 1159 delta_ofdm->crc32_good, max_ofdm->crc32_good);
1138 pos += scnprintf(buf + pos, bufsz - pos, "dsp_self_kill: %u\n", 1160 pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
1139 le32_to_cpu(ofdm->dsp_self_kill)); 1161 "false_alarm_cnt:",
1140 pos += scnprintf(buf + pos, bufsz - pos, "mh_format_err: %u\n", 1162 le32_to_cpu(ofdm->false_alarm_cnt),
1141 le32_to_cpu(ofdm->mh_format_err)); 1163 accum_ofdm->false_alarm_cnt,
1142 pos += scnprintf(buf + pos, bufsz - pos, "re_acq_main_rssi_sum: %u\n", 1164 delta_ofdm->false_alarm_cnt,
1143 le32_to_cpu(ofdm->re_acq_main_rssi_sum)); 1165 max_ofdm->false_alarm_cnt);
1144 1166 pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
1145 pos += scnprintf(buf + pos, bufsz - pos, "Statistics_Rx - CCK:\n"); 1167 "fina_sync_err_cnt:",
1146 pos += scnprintf(buf + pos, bufsz - pos, "ina_cnt: %u\n", 1168 le32_to_cpu(ofdm->fina_sync_err_cnt),
1147 le32_to_cpu(cck->ina_cnt)); 1169 accum_ofdm->fina_sync_err_cnt,
1148 pos += scnprintf(buf + pos, bufsz - pos, "fina_cnt: %u\n", 1170 delta_ofdm->fina_sync_err_cnt,
1149 le32_to_cpu(cck->fina_cnt)); 1171 max_ofdm->fina_sync_err_cnt);
1150 pos += scnprintf(buf + pos, bufsz - pos, "plcp_err: %u\n", 1172 pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
1151 le32_to_cpu(cck->plcp_err)); 1173 "sfd_timeout:",
1152 pos += scnprintf(buf + pos, bufsz - pos, "crc32_err: %u\n", 1174 le32_to_cpu(ofdm->sfd_timeout),
1153 le32_to_cpu(cck->crc32_err)); 1175 accum_ofdm->sfd_timeout,
1154 pos += scnprintf(buf + pos, bufsz - pos, "overrun_err: %u\n", 1176 delta_ofdm->sfd_timeout,
1155 le32_to_cpu(cck->overrun_err)); 1177 max_ofdm->sfd_timeout);
1156 pos += scnprintf(buf + pos, bufsz - pos, "early_overrun_err: %u\n", 1178 pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
1157 le32_to_cpu(cck->early_overrun_err)); 1179 "fina_timeout:",
1158 pos += scnprintf(buf + pos, bufsz - pos, "crc32_good: %u\n", 1180 le32_to_cpu(ofdm->fina_timeout),
1159 le32_to_cpu(cck->crc32_good)); 1181 accum_ofdm->fina_timeout,
1160 pos += scnprintf(buf + pos, bufsz - pos, "false_alarm_cnt: %u\n", 1182 delta_ofdm->fina_timeout,
1161 le32_to_cpu(cck->false_alarm_cnt)); 1183 max_ofdm->fina_timeout);
1162 pos += scnprintf(buf + pos, bufsz - pos, "fina_sync_err_cnt: %u\n", 1184 pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
1163 le32_to_cpu(cck->fina_sync_err_cnt)); 1185 "unresponded_rts:",
1164 pos += scnprintf(buf + pos, bufsz - pos, "sfd_timeout: %u\n", 1186 le32_to_cpu(ofdm->unresponded_rts),
1165 le32_to_cpu(cck->sfd_timeout)); 1187 accum_ofdm->unresponded_rts,
1166 pos += scnprintf(buf + pos, bufsz - pos, "fina_timeout: %u\n", 1188 delta_ofdm->unresponded_rts,
1167 le32_to_cpu(cck->fina_timeout)); 1189 max_ofdm->unresponded_rts);
1168 pos += scnprintf(buf + pos, bufsz - pos, "unresponded_rts: %u\n", 1190 pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
1169 le32_to_cpu(cck->unresponded_rts)); 1191 "rxe_frame_lmt_ovrun:",
1170 pos += scnprintf(buf + pos, bufsz - pos, 1192 le32_to_cpu(ofdm->rxe_frame_limit_overrun),
1171 "rxe_frame_limit_overrun: %u\n", 1193 accum_ofdm->rxe_frame_limit_overrun,
1172 le32_to_cpu(cck->rxe_frame_limit_overrun)); 1194 delta_ofdm->rxe_frame_limit_overrun,
1173 pos += scnprintf(buf + pos, bufsz - pos, "sent_ack_cnt: %u\n", 1195 max_ofdm->rxe_frame_limit_overrun);
1174 le32_to_cpu(cck->sent_ack_cnt)); 1196 pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
1175 pos += scnprintf(buf + pos, bufsz - pos, "sent_cts_cnt: %u\n", 1197 "sent_ack_cnt:",
1176 le32_to_cpu(cck->sent_cts_cnt)); 1198 le32_to_cpu(ofdm->sent_ack_cnt),
1177 pos += scnprintf(buf + pos, bufsz - pos, "sent_ba_rsp_cnt: %u\n", 1199 accum_ofdm->sent_ack_cnt,
1178 le32_to_cpu(cck->sent_ba_rsp_cnt)); 1200 delta_ofdm->sent_ack_cnt,
1179 pos += scnprintf(buf + pos, bufsz - pos, "dsp_self_kill: %u\n", 1201 max_ofdm->sent_ack_cnt);
1180 le32_to_cpu(cck->dsp_self_kill)); 1202 pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
1181 pos += scnprintf(buf + pos, bufsz - pos, "mh_format_err: %u\n", 1203 "sent_cts_cnt:",
1182 le32_to_cpu(cck->mh_format_err)); 1204 le32_to_cpu(ofdm->sent_cts_cnt),
1183 pos += scnprintf(buf + pos, bufsz - pos, "re_acq_main_rssi_sum: %u\n", 1205 accum_ofdm->sent_cts_cnt,
1184 le32_to_cpu(cck->re_acq_main_rssi_sum)); 1206 delta_ofdm->sent_cts_cnt, max_ofdm->sent_cts_cnt);
1185 1207 pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
1186 pos += scnprintf(buf + pos, bufsz - pos, "Statistics_Rx - GENERAL:\n"); 1208 "sent_ba_rsp_cnt:",
1187 pos += scnprintf(buf + pos, bufsz - pos, "bogus_cts: %u\n", 1209 le32_to_cpu(ofdm->sent_ba_rsp_cnt),
1188 le32_to_cpu(general->bogus_cts)); 1210 accum_ofdm->sent_ba_rsp_cnt,
1189 pos += scnprintf(buf + pos, bufsz - pos, "bogus_ack: %u\n", 1211 delta_ofdm->sent_ba_rsp_cnt,
1190 le32_to_cpu(general->bogus_ack)); 1212 max_ofdm->sent_ba_rsp_cnt);
1191 pos += scnprintf(buf + pos, bufsz - pos, "non_bssid_frames: %u\n", 1213 pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
1192 le32_to_cpu(general->non_bssid_frames)); 1214 "dsp_self_kill:",
1193 pos += scnprintf(buf + pos, bufsz - pos, "filtered_frames: %u\n", 1215 le32_to_cpu(ofdm->dsp_self_kill),
1194 le32_to_cpu(general->filtered_frames)); 1216 accum_ofdm->dsp_self_kill,
1195 pos += scnprintf(buf + pos, bufsz - pos, "non_channel_beacons: %u\n", 1217 delta_ofdm->dsp_self_kill,
1196 le32_to_cpu(general->non_channel_beacons)); 1218 max_ofdm->dsp_self_kill);
1197 pos += scnprintf(buf + pos, bufsz - pos, "channel_beacons: %u\n", 1219 pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
1198 le32_to_cpu(general->channel_beacons)); 1220 "mh_format_err:",
1199 pos += scnprintf(buf + pos, bufsz - pos, "num_missed_bcon: %u\n", 1221 le32_to_cpu(ofdm->mh_format_err),
1200 le32_to_cpu(general->num_missed_bcon)); 1222 accum_ofdm->mh_format_err,
1201 pos += scnprintf(buf + pos, bufsz - pos, 1223 delta_ofdm->mh_format_err,
1202 "adc_rx_saturation_time: %u\n", 1224 max_ofdm->mh_format_err);
1203 le32_to_cpu(general->adc_rx_saturation_time)); 1225 pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
1204 pos += scnprintf(buf + pos, bufsz - pos, 1226 "re_acq_main_rssi_sum:",
1205 "ina_detection_search_time: %u\n", 1227 le32_to_cpu(ofdm->re_acq_main_rssi_sum),
1206 le32_to_cpu(general->ina_detection_search_time)); 1228 accum_ofdm->re_acq_main_rssi_sum,
1207 pos += scnprintf(buf + pos, bufsz - pos, "beacon_silence_rssi_a: %u\n", 1229 delta_ofdm->re_acq_main_rssi_sum,
1208 le32_to_cpu(general->beacon_silence_rssi_a)); 1230 max_ofdm->re_acq_main_rssi_sum);
1209 pos += scnprintf(buf + pos, bufsz - pos, "beacon_silence_rssi_b: %u\n", 1231
1210 le32_to_cpu(general->beacon_silence_rssi_b)); 1232 pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_header,
1211 pos += scnprintf(buf + pos, bufsz - pos, "beacon_silence_rssi_c: %u\n", 1233 "Statistics_Rx - CCK:");
1212 le32_to_cpu(general->beacon_silence_rssi_c)); 1234 pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
1213 pos += scnprintf(buf + pos, bufsz - pos, 1235 "ina_cnt:",
1214 "interference_data_flag: %u\n", 1236 le32_to_cpu(cck->ina_cnt), accum_cck->ina_cnt,
1215 le32_to_cpu(general->interference_data_flag)); 1237 delta_cck->ina_cnt, max_cck->ina_cnt);
1216 pos += scnprintf(buf + pos, bufsz - pos, "channel_load: %u\n", 1238 pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
1217 le32_to_cpu(general->channel_load)); 1239 "fina_cnt:",
1218 pos += scnprintf(buf + pos, bufsz - pos, "dsp_false_alarms: %u\n", 1240 le32_to_cpu(cck->fina_cnt), accum_cck->fina_cnt,
1219 le32_to_cpu(general->dsp_false_alarms)); 1241 delta_cck->fina_cnt, max_cck->fina_cnt);
1220 pos += scnprintf(buf + pos, bufsz - pos, "beacon_rssi_a: %u\n", 1242 pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
1221 le32_to_cpu(general->beacon_rssi_a)); 1243 "plcp_err:",
1222 pos += scnprintf(buf + pos, bufsz - pos, "beacon_rssi_b: %u\n", 1244 le32_to_cpu(cck->plcp_err), accum_cck->plcp_err,
1223 le32_to_cpu(general->beacon_rssi_b)); 1245 delta_cck->plcp_err, max_cck->plcp_err);
1224 pos += scnprintf(buf + pos, bufsz - pos, "beacon_rssi_c: %u\n", 1246 pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
1225 le32_to_cpu(general->beacon_rssi_c)); 1247 "crc32_err:",
1226 pos += scnprintf(buf + pos, bufsz - pos, "beacon_energy_a: %u\n", 1248 le32_to_cpu(cck->crc32_err), accum_cck->crc32_err,
1227 le32_to_cpu(general->beacon_energy_a)); 1249 delta_cck->crc32_err, max_cck->crc32_err);
1228 pos += scnprintf(buf + pos, bufsz - pos, "beacon_energy_b: %u\n", 1250 pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
1229 le32_to_cpu(general->beacon_energy_b)); 1251 "overrun_err:",
1230 pos += scnprintf(buf + pos, bufsz - pos, "beacon_energy_c: %u\n", 1252 le32_to_cpu(cck->overrun_err),
1231 le32_to_cpu(general->beacon_energy_c)); 1253 accum_cck->overrun_err,
1254 delta_cck->overrun_err, max_cck->overrun_err);
1255 pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
1256 "early_overrun_err:",
1257 le32_to_cpu(cck->early_overrun_err),
1258 accum_cck->early_overrun_err,
1259 delta_cck->early_overrun_err,
1260 max_cck->early_overrun_err);
1261 pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
1262 "crc32_good:",
1263 le32_to_cpu(cck->crc32_good), accum_cck->crc32_good,
1264 delta_cck->crc32_good,
1265 max_cck->crc32_good);
1266 pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
1267 "false_alarm_cnt:",
1268 le32_to_cpu(cck->false_alarm_cnt),
1269 accum_cck->false_alarm_cnt,
1270 delta_cck->false_alarm_cnt, max_cck->false_alarm_cnt);
1271 pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
1272 "fina_sync_err_cnt:",
1273 le32_to_cpu(cck->fina_sync_err_cnt),
1274 accum_cck->fina_sync_err_cnt,
1275 delta_cck->fina_sync_err_cnt,
1276 max_cck->fina_sync_err_cnt);
1277 pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
1278 "sfd_timeout:",
1279 le32_to_cpu(cck->sfd_timeout),
1280 accum_cck->sfd_timeout,
1281 delta_cck->sfd_timeout, max_cck->sfd_timeout);
1282 pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
1283 "fina_timeout:",
1284 le32_to_cpu(cck->fina_timeout),
1285 accum_cck->fina_timeout,
1286 delta_cck->fina_timeout, max_cck->fina_timeout);
1287 pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
1288 "unresponded_rts:",
1289 le32_to_cpu(cck->unresponded_rts),
1290 accum_cck->unresponded_rts,
1291 delta_cck->unresponded_rts,
1292 max_cck->unresponded_rts);
1293 pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
1294 "rxe_frame_lmt_ovrun:",
1295 le32_to_cpu(cck->rxe_frame_limit_overrun),
1296 accum_cck->rxe_frame_limit_overrun,
1297 delta_cck->rxe_frame_limit_overrun,
1298 max_cck->rxe_frame_limit_overrun);
1299 pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
1300 "sent_ack_cnt:",
1301 le32_to_cpu(cck->sent_ack_cnt),
1302 accum_cck->sent_ack_cnt,
1303 delta_cck->sent_ack_cnt,
1304 max_cck->sent_ack_cnt);
1305 pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
1306 "sent_cts_cnt:",
1307 le32_to_cpu(cck->sent_cts_cnt),
1308 accum_cck->sent_cts_cnt,
1309 delta_cck->sent_cts_cnt,
1310 max_cck->sent_cts_cnt);
1311 pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
1312 "sent_ba_rsp_cnt:",
1313 le32_to_cpu(cck->sent_ba_rsp_cnt),
1314 accum_cck->sent_ba_rsp_cnt,
1315 delta_cck->sent_ba_rsp_cnt,
1316 max_cck->sent_ba_rsp_cnt);
1317 pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
1318 "dsp_self_kill:",
1319 le32_to_cpu(cck->dsp_self_kill),
1320 accum_cck->dsp_self_kill,
1321 delta_cck->dsp_self_kill,
1322 max_cck->dsp_self_kill);
1323 pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
1324 "mh_format_err:",
1325 le32_to_cpu(cck->mh_format_err),
1326 accum_cck->mh_format_err,
1327 delta_cck->mh_format_err, max_cck->mh_format_err);
1328 pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
1329 "re_acq_main_rssi_sum:",
1330 le32_to_cpu(cck->re_acq_main_rssi_sum),
1331 accum_cck->re_acq_main_rssi_sum,
1332 delta_cck->re_acq_main_rssi_sum,
1333 max_cck->re_acq_main_rssi_sum);
1334
1335 pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_header,
1336 "Statistics_Rx - GENERAL:");
1337 pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
1338 "bogus_cts:",
1339 le32_to_cpu(general->bogus_cts),
1340 accum_general->bogus_cts,
1341 delta_general->bogus_cts, max_general->bogus_cts);
1342 pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
1343 "bogus_ack:",
1344 le32_to_cpu(general->bogus_ack),
1345 accum_general->bogus_ack,
1346 delta_general->bogus_ack, max_general->bogus_ack);
1347 pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
1348 "non_bssid_frames:",
1349 le32_to_cpu(general->non_bssid_frames),
1350 accum_general->non_bssid_frames,
1351 delta_general->non_bssid_frames,
1352 max_general->non_bssid_frames);
1353 pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
1354 "filtered_frames:",
1355 le32_to_cpu(general->filtered_frames),
1356 accum_general->filtered_frames,
1357 delta_general->filtered_frames,
1358 max_general->filtered_frames);
1359 pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
1360 "non_channel_beacons:",
1361 le32_to_cpu(general->non_channel_beacons),
1362 accum_general->non_channel_beacons,
1363 delta_general->non_channel_beacons,
1364 max_general->non_channel_beacons);
1365 pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
1366 "channel_beacons:",
1367 le32_to_cpu(general->channel_beacons),
1368 accum_general->channel_beacons,
1369 delta_general->channel_beacons,
1370 max_general->channel_beacons);
1371 pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
1372 "num_missed_bcon:",
1373 le32_to_cpu(general->num_missed_bcon),
1374 accum_general->num_missed_bcon,
1375 delta_general->num_missed_bcon,
1376 max_general->num_missed_bcon);
1377 pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
1378 "adc_rx_saturation_time:",
1379 le32_to_cpu(general->adc_rx_saturation_time),
1380 accum_general->adc_rx_saturation_time,
1381 delta_general->adc_rx_saturation_time,
1382 max_general->adc_rx_saturation_time);
1383 pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
1384 "ina_detect_search_tm:",
1385 le32_to_cpu(general->ina_detection_search_time),
1386 accum_general->ina_detection_search_time,
1387 delta_general->ina_detection_search_time,
1388 max_general->ina_detection_search_time);
1389 pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
1390 "beacon_silence_rssi_a:",
1391 le32_to_cpu(general->beacon_silence_rssi_a),
1392 accum_general->beacon_silence_rssi_a,
1393 delta_general->beacon_silence_rssi_a,
1394 max_general->beacon_silence_rssi_a);
1395 pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
1396 "beacon_silence_rssi_b:",
1397 le32_to_cpu(general->beacon_silence_rssi_b),
1398 accum_general->beacon_silence_rssi_b,
1399 delta_general->beacon_silence_rssi_b,
1400 max_general->beacon_silence_rssi_b);
1401 pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
1402 "beacon_silence_rssi_c:",
1403 le32_to_cpu(general->beacon_silence_rssi_c),
1404 accum_general->beacon_silence_rssi_c,
1405 delta_general->beacon_silence_rssi_c,
1406 max_general->beacon_silence_rssi_c);
1407 pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
1408 "interference_data_flag:",
1409 le32_to_cpu(general->interference_data_flag),
1410 accum_general->interference_data_flag,
1411 delta_general->interference_data_flag,
1412 max_general->interference_data_flag);
1413 pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
1414 "channel_load:",
1415 le32_to_cpu(general->channel_load),
1416 accum_general->channel_load,
1417 delta_general->channel_load,
1418 max_general->channel_load);
1419 pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
1420 "dsp_false_alarms:",
1421 le32_to_cpu(general->dsp_false_alarms),
1422 accum_general->dsp_false_alarms,
1423 delta_general->dsp_false_alarms,
1424 max_general->dsp_false_alarms);
1425 pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
1426 "beacon_rssi_a:",
1427 le32_to_cpu(general->beacon_rssi_a),
1428 accum_general->beacon_rssi_a,
1429 delta_general->beacon_rssi_a,
1430 max_general->beacon_rssi_a);
1431 pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
1432 "beacon_rssi_b:",
1433 le32_to_cpu(general->beacon_rssi_b),
1434 accum_general->beacon_rssi_b,
1435 delta_general->beacon_rssi_b,
1436 max_general->beacon_rssi_b);
1437 pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
1438 "beacon_rssi_c:",
1439 le32_to_cpu(general->beacon_rssi_c),
1440 accum_general->beacon_rssi_c,
1441 delta_general->beacon_rssi_c,
1442 max_general->beacon_rssi_c);
1443 pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
1444 "beacon_energy_a:",
1445 le32_to_cpu(general->beacon_energy_a),
1446 accum_general->beacon_energy_a,
1447 delta_general->beacon_energy_a,
1448 max_general->beacon_energy_a);
1449 pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
1450 "beacon_energy_b:",
1451 le32_to_cpu(general->beacon_energy_b),
1452 accum_general->beacon_energy_b,
1453 delta_general->beacon_energy_b,
1454 max_general->beacon_energy_b);
1455 pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
1456 "beacon_energy_c:",
1457 le32_to_cpu(general->beacon_energy_c),
1458 accum_general->beacon_energy_c,
1459 delta_general->beacon_energy_c,
1460 max_general->beacon_energy_c);
1232 1461
1233 pos += scnprintf(buf + pos, bufsz - pos, "Statistics_Rx - OFDM_HT:\n"); 1462 pos += scnprintf(buf + pos, bufsz - pos, "Statistics_Rx - OFDM_HT:\n");
1234 pos += scnprintf(buf + pos, bufsz - pos, "plcp_err: %u\n", 1463 pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_header,
1235 le32_to_cpu(ht->plcp_err)); 1464 "Statistics_Rx - OFDM_HT:");
1236 pos += scnprintf(buf + pos, bufsz - pos, "overrun_err: %u\n", 1465 pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
1237 le32_to_cpu(ht->overrun_err)); 1466 "plcp_err:",
1238 pos += scnprintf(buf + pos, bufsz - pos, "early_overrun_err: %u\n", 1467 le32_to_cpu(ht->plcp_err), accum_ht->plcp_err,
1239 le32_to_cpu(ht->early_overrun_err)); 1468 delta_ht->plcp_err, max_ht->plcp_err);
1240 pos += scnprintf(buf + pos, bufsz - pos, "crc32_good: %u\n", 1469 pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
1241 le32_to_cpu(ht->crc32_good)); 1470 "overrun_err:",
1242 pos += scnprintf(buf + pos, bufsz - pos, "crc32_err: %u\n", 1471 le32_to_cpu(ht->overrun_err), accum_ht->overrun_err,
1243 le32_to_cpu(ht->crc32_err)); 1472 delta_ht->overrun_err, max_ht->overrun_err);
1244 pos += scnprintf(buf + pos, bufsz - pos, "mh_format_err: %u\n", 1473 pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
1245 le32_to_cpu(ht->mh_format_err)); 1474 "early_overrun_err:",
1246 pos += scnprintf(buf + pos, bufsz - pos, "agg_crc32_good: %u\n", 1475 le32_to_cpu(ht->early_overrun_err),
1247 le32_to_cpu(ht->agg_crc32_good)); 1476 accum_ht->early_overrun_err,
1248 pos += scnprintf(buf + pos, bufsz - pos, "agg_mpdu_cnt: %u\n", 1477 delta_ht->early_overrun_err,
1249 le32_to_cpu(ht->agg_mpdu_cnt)); 1478 max_ht->early_overrun_err);
1250 pos += scnprintf(buf + pos, bufsz - pos, "agg_cnt: %u\n", 1479 pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
1251 le32_to_cpu(ht->agg_cnt)); 1480 "crc32_good:",
1481 le32_to_cpu(ht->crc32_good), accum_ht->crc32_good,
1482 delta_ht->crc32_good, max_ht->crc32_good);
1483 pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
1484 "crc32_err:",
1485 le32_to_cpu(ht->crc32_err), accum_ht->crc32_err,
1486 delta_ht->crc32_err, max_ht->crc32_err);
1487 pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
1488 "mh_format_err:",
1489 le32_to_cpu(ht->mh_format_err),
1490 accum_ht->mh_format_err,
1491 delta_ht->mh_format_err, max_ht->mh_format_err);
1492 pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
1493 "agg_crc32_good:",
1494 le32_to_cpu(ht->agg_crc32_good),
1495 accum_ht->agg_crc32_good,
1496 delta_ht->agg_crc32_good, max_ht->agg_crc32_good);
1497 pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
1498 "agg_mpdu_cnt:",
1499 le32_to_cpu(ht->agg_mpdu_cnt),
1500 accum_ht->agg_mpdu_cnt,
1501 delta_ht->agg_mpdu_cnt, max_ht->agg_mpdu_cnt);
1502 pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
1503 "agg_cnt:",
1504 le32_to_cpu(ht->agg_cnt), accum_ht->agg_cnt,
1505 delta_ht->agg_cnt, max_ht->agg_cnt);
1506 pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
1507 "unsupport_mcs:",
1508 le32_to_cpu(ht->unsupport_mcs),
1509 accum_ht->unsupport_mcs,
1510 delta_ht->unsupport_mcs, max_ht->unsupport_mcs);
1252 1511
1253 ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos); 1512 ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos);
1254 kfree(buf); 1513 kfree(buf);
@@ -1259,26 +1518,16 @@ static ssize_t iwl_dbgfs_ucode_tx_stats_read(struct file *file,
1259 char __user *user_buf, 1518 char __user *user_buf,
1260 size_t count, loff_t *ppos) 1519 size_t count, loff_t *ppos)
1261{ 1520{
1262 struct iwl_priv *priv = (struct iwl_priv *)file->private_data; 1521 struct iwl_priv *priv = file->private_data;
1263 int pos = 0; 1522 int pos = 0;
1264 char *buf; 1523 char *buf;
1265 int bufsz = (sizeof(struct statistics_tx) * 24) + 250; 1524 int bufsz = (sizeof(struct statistics_tx) * 48) + 250;
1266 ssize_t ret; 1525 ssize_t ret;
1267 struct statistics_tx *tx; 1526 struct statistics_tx *tx, *accum_tx, *delta_tx, *max_tx;
1268 1527
1269 if (!iwl_is_alive(priv)) 1528 if (!iwl_is_alive(priv))
1270 return -EAGAIN; 1529 return -EAGAIN;
1271 1530
1272 /* make request to uCode to retrieve statistics information */
1273 mutex_lock(&priv->mutex);
1274 ret = iwl_send_statistics_request(priv, 0);
1275 mutex_unlock(&priv->mutex);
1276
1277 if (ret) {
1278 IWL_ERR(priv,
1279 "Error sending statistics request: %zd\n", ret);
1280 return -EAGAIN;
1281 }
1282 buf = kzalloc(bufsz, GFP_KERNEL); 1531 buf = kzalloc(bufsz, GFP_KERNEL);
1283 if (!buf) { 1532 if (!buf) {
1284 IWL_ERR(priv, "Can not allocate Buffer\n"); 1533 IWL_ERR(priv, "Can not allocate Buffer\n");
@@ -1290,62 +1539,149 @@ static ssize_t iwl_dbgfs_ucode_tx_stats_read(struct file *file,
1290 * might not reflect the current uCode activity 1539 * might not reflect the current uCode activity
1291 */ 1540 */
1292 tx = &priv->statistics.tx; 1541 tx = &priv->statistics.tx;
1542 accum_tx = &priv->accum_statistics.tx;
1543 delta_tx = &priv->delta_statistics.tx;
1544 max_tx = &priv->max_delta.tx;
1293 pos += iwl_dbgfs_statistics_flag(priv, buf, bufsz); 1545 pos += iwl_dbgfs_statistics_flag(priv, buf, bufsz);
1294 pos += scnprintf(buf + pos, bufsz - pos, "Statistics_Tx:\n"); 1546 pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_header,
1295 pos += scnprintf(buf + pos, bufsz - pos, "preamble: %u\n", 1547 "Statistics_Tx:");
1296 le32_to_cpu(tx->preamble_cnt)); 1548 pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
1297 pos += scnprintf(buf + pos, bufsz - pos, "rx_detected_cnt: %u\n", 1549 "preamble:",
1298 le32_to_cpu(tx->rx_detected_cnt)); 1550 le32_to_cpu(tx->preamble_cnt),
1299 pos += scnprintf(buf + pos, bufsz - pos, "bt_prio_defer_cnt: %u\n", 1551 accum_tx->preamble_cnt,
1300 le32_to_cpu(tx->bt_prio_defer_cnt)); 1552 delta_tx->preamble_cnt, max_tx->preamble_cnt);
1301 pos += scnprintf(buf + pos, bufsz - pos, "bt_prio_kill_cnt: %u\n", 1553 pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
1302 le32_to_cpu(tx->bt_prio_kill_cnt)); 1554 "rx_detected_cnt:",
1303 pos += scnprintf(buf + pos, bufsz - pos, "few_bytes_cnt: %u\n", 1555 le32_to_cpu(tx->rx_detected_cnt),
1304 le32_to_cpu(tx->few_bytes_cnt)); 1556 accum_tx->rx_detected_cnt,
1305 pos += scnprintf(buf + pos, bufsz - pos, "cts_timeout: %u\n", 1557 delta_tx->rx_detected_cnt, max_tx->rx_detected_cnt);
1306 le32_to_cpu(tx->cts_timeout)); 1558 pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
1307 pos += scnprintf(buf + pos, bufsz - pos, "ack_timeout: %u\n", 1559 "bt_prio_defer_cnt:",
1308 le32_to_cpu(tx->ack_timeout)); 1560 le32_to_cpu(tx->bt_prio_defer_cnt),
1309 pos += scnprintf(buf + pos, bufsz - pos, "expected_ack_cnt: %u\n", 1561 accum_tx->bt_prio_defer_cnt,
1310 le32_to_cpu(tx->expected_ack_cnt)); 1562 delta_tx->bt_prio_defer_cnt,
1311 pos += scnprintf(buf + pos, bufsz - pos, "actual_ack_cnt: %u\n", 1563 max_tx->bt_prio_defer_cnt);
1312 le32_to_cpu(tx->actual_ack_cnt)); 1564 pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
1313 pos += scnprintf(buf + pos, bufsz - pos, "dump_msdu_cnt: %u\n", 1565 "bt_prio_kill_cnt:",
1314 le32_to_cpu(tx->dump_msdu_cnt)); 1566 le32_to_cpu(tx->bt_prio_kill_cnt),
1315 pos += scnprintf(buf + pos, bufsz - pos, 1567 accum_tx->bt_prio_kill_cnt,
1316 "burst_abort_next_frame_mismatch_cnt: %u\n", 1568 delta_tx->bt_prio_kill_cnt,
1317 le32_to_cpu(tx->burst_abort_next_frame_mismatch_cnt)); 1569 max_tx->bt_prio_kill_cnt);
1318 pos += scnprintf(buf + pos, bufsz - pos, 1570 pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
1319 "burst_abort_missing_next_frame_cnt: %u\n", 1571 "few_bytes_cnt:",
1320 le32_to_cpu(tx->burst_abort_missing_next_frame_cnt)); 1572 le32_to_cpu(tx->few_bytes_cnt),
1321 pos += scnprintf(buf + pos, bufsz - pos, "cts_timeout_collision: %u\n", 1573 accum_tx->few_bytes_cnt,
1322 le32_to_cpu(tx->cts_timeout_collision)); 1574 delta_tx->few_bytes_cnt, max_tx->few_bytes_cnt);
1323 pos += scnprintf(buf + pos, bufsz - pos, 1575 pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
1324 "ack_or_ba_timeout_collision: %u\n", 1576 "cts_timeout:",
1325 le32_to_cpu(tx->ack_or_ba_timeout_collision)); 1577 le32_to_cpu(tx->cts_timeout), accum_tx->cts_timeout,
1326 pos += scnprintf(buf + pos, bufsz - pos, "agg ba_timeout: %u\n", 1578 delta_tx->cts_timeout, max_tx->cts_timeout);
1327 le32_to_cpu(tx->agg.ba_timeout)); 1579 pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
1328 pos += scnprintf(buf + pos, bufsz - pos, 1580 "ack_timeout:",
1329 "agg ba_reschedule_frames: %u\n", 1581 le32_to_cpu(tx->ack_timeout),
1330 le32_to_cpu(tx->agg.ba_reschedule_frames)); 1582 accum_tx->ack_timeout,
1331 pos += scnprintf(buf + pos, bufsz - pos, 1583 delta_tx->ack_timeout, max_tx->ack_timeout);
1332 "agg scd_query_agg_frame_cnt: %u\n", 1584 pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
1333 le32_to_cpu(tx->agg.scd_query_agg_frame_cnt)); 1585 "expected_ack_cnt:",
1334 pos += scnprintf(buf + pos, bufsz - pos, "agg scd_query_no_agg: %u\n", 1586 le32_to_cpu(tx->expected_ack_cnt),
1335 le32_to_cpu(tx->agg.scd_query_no_agg)); 1587 accum_tx->expected_ack_cnt,
1336 pos += scnprintf(buf + pos, bufsz - pos, "agg scd_query_agg: %u\n", 1588 delta_tx->expected_ack_cnt,
1337 le32_to_cpu(tx->agg.scd_query_agg)); 1589 max_tx->expected_ack_cnt);
1338 pos += scnprintf(buf + pos, bufsz - pos, 1590 pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
1339 "agg scd_query_mismatch: %u\n", 1591 "actual_ack_cnt:",
1340 le32_to_cpu(tx->agg.scd_query_mismatch)); 1592 le32_to_cpu(tx->actual_ack_cnt),
1341 pos += scnprintf(buf + pos, bufsz - pos, "agg frame_not_ready: %u\n", 1593 accum_tx->actual_ack_cnt,
1342 le32_to_cpu(tx->agg.frame_not_ready)); 1594 delta_tx->actual_ack_cnt,
1343 pos += scnprintf(buf + pos, bufsz - pos, "agg underrun: %u\n", 1595 max_tx->actual_ack_cnt);
1344 le32_to_cpu(tx->agg.underrun)); 1596 pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
1345 pos += scnprintf(buf + pos, bufsz - pos, "agg bt_prio_kill: %u\n", 1597 "dump_msdu_cnt:",
1346 le32_to_cpu(tx->agg.bt_prio_kill)); 1598 le32_to_cpu(tx->dump_msdu_cnt),
1347 pos += scnprintf(buf + pos, bufsz - pos, "agg rx_ba_rsp_cnt: %u\n", 1599 accum_tx->dump_msdu_cnt,
1348 le32_to_cpu(tx->agg.rx_ba_rsp_cnt)); 1600 delta_tx->dump_msdu_cnt,
1601 max_tx->dump_msdu_cnt);
1602 pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
1603 "abort_nxt_frame_mismatch:",
1604 le32_to_cpu(tx->burst_abort_next_frame_mismatch_cnt),
1605 accum_tx->burst_abort_next_frame_mismatch_cnt,
1606 delta_tx->burst_abort_next_frame_mismatch_cnt,
1607 max_tx->burst_abort_next_frame_mismatch_cnt);
1608 pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
1609 "abort_missing_nxt_frame:",
1610 le32_to_cpu(tx->burst_abort_missing_next_frame_cnt),
1611 accum_tx->burst_abort_missing_next_frame_cnt,
1612 delta_tx->burst_abort_missing_next_frame_cnt,
1613 max_tx->burst_abort_missing_next_frame_cnt);
1614 pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
1615 "cts_timeout_collision:",
1616 le32_to_cpu(tx->cts_timeout_collision),
1617 accum_tx->cts_timeout_collision,
1618 delta_tx->cts_timeout_collision,
1619 max_tx->cts_timeout_collision);
1620 pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
1621 "ack_ba_timeout_collision:",
1622 le32_to_cpu(tx->ack_or_ba_timeout_collision),
1623 accum_tx->ack_or_ba_timeout_collision,
1624 delta_tx->ack_or_ba_timeout_collision,
1625 max_tx->ack_or_ba_timeout_collision);
1626 pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
1627 "agg ba_timeout:",
1628 le32_to_cpu(tx->agg.ba_timeout),
1629 accum_tx->agg.ba_timeout,
1630 delta_tx->agg.ba_timeout,
1631 max_tx->agg.ba_timeout);
1632 pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
1633 "agg ba_resched_frames:",
1634 le32_to_cpu(tx->agg.ba_reschedule_frames),
1635 accum_tx->agg.ba_reschedule_frames,
1636 delta_tx->agg.ba_reschedule_frames,
1637 max_tx->agg.ba_reschedule_frames);
1638 pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
1639 "agg scd_query_agg_frame:",
1640 le32_to_cpu(tx->agg.scd_query_agg_frame_cnt),
1641 accum_tx->agg.scd_query_agg_frame_cnt,
1642 delta_tx->agg.scd_query_agg_frame_cnt,
1643 max_tx->agg.scd_query_agg_frame_cnt);
1644 pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
1645 "agg scd_query_no_agg:",
1646 le32_to_cpu(tx->agg.scd_query_no_agg),
1647 accum_tx->agg.scd_query_no_agg,
1648 delta_tx->agg.scd_query_no_agg,
1649 max_tx->agg.scd_query_no_agg);
1650 pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
1651 "agg scd_query_agg:",
1652 le32_to_cpu(tx->agg.scd_query_agg),
1653 accum_tx->agg.scd_query_agg,
1654 delta_tx->agg.scd_query_agg,
1655 max_tx->agg.scd_query_agg);
1656 pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
1657 "agg scd_query_mismatch:",
1658 le32_to_cpu(tx->agg.scd_query_mismatch),
1659 accum_tx->agg.scd_query_mismatch,
1660 delta_tx->agg.scd_query_mismatch,
1661 max_tx->agg.scd_query_mismatch);
1662 pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
1663 "agg frame_not_ready:",
1664 le32_to_cpu(tx->agg.frame_not_ready),
1665 accum_tx->agg.frame_not_ready,
1666 delta_tx->agg.frame_not_ready,
1667 max_tx->agg.frame_not_ready);
1668 pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
1669 "agg underrun:",
1670 le32_to_cpu(tx->agg.underrun),
1671 accum_tx->agg.underrun,
1672 delta_tx->agg.underrun, max_tx->agg.underrun);
1673 pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
1674 "agg bt_prio_kill:",
1675 le32_to_cpu(tx->agg.bt_prio_kill),
1676 accum_tx->agg.bt_prio_kill,
1677 delta_tx->agg.bt_prio_kill,
1678 max_tx->agg.bt_prio_kill);
1679 pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
1680 "agg rx_ba_rsp_cnt:",
1681 le32_to_cpu(tx->agg.rx_ba_rsp_cnt),
1682 accum_tx->agg.rx_ba_rsp_cnt,
1683 delta_tx->agg.rx_ba_rsp_cnt,
1684 max_tx->agg.rx_ba_rsp_cnt);
1349 1685
1350 ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos); 1686 ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos);
1351 kfree(buf); 1687 kfree(buf);
@@ -1356,28 +1692,19 @@ static ssize_t iwl_dbgfs_ucode_general_stats_read(struct file *file,
1356 char __user *user_buf, 1692 char __user *user_buf,
1357 size_t count, loff_t *ppos) 1693 size_t count, loff_t *ppos)
1358{ 1694{
1359 struct iwl_priv *priv = (struct iwl_priv *)file->private_data; 1695 struct iwl_priv *priv = file->private_data;
1360 int pos = 0; 1696 int pos = 0;
1361 char *buf; 1697 char *buf;
1362 int bufsz = sizeof(struct statistics_general) * 4 + 250; 1698 int bufsz = sizeof(struct statistics_general) * 10 + 300;
1363 ssize_t ret; 1699 ssize_t ret;
1364 struct statistics_general *general; 1700 struct statistics_general *general, *accum_general;
1365 struct statistics_dbg *dbg; 1701 struct statistics_general *delta_general, *max_general;
1366 struct statistics_div *div; 1702 struct statistics_dbg *dbg, *accum_dbg, *delta_dbg, *max_dbg;
1703 struct statistics_div *div, *accum_div, *delta_div, *max_div;
1367 1704
1368 if (!iwl_is_alive(priv)) 1705 if (!iwl_is_alive(priv))
1369 return -EAGAIN; 1706 return -EAGAIN;
1370 1707
1371 /* make request to uCode to retrieve statistics information */
1372 mutex_lock(&priv->mutex);
1373 ret = iwl_send_statistics_request(priv, 0);
1374 mutex_unlock(&priv->mutex);
1375
1376 if (ret) {
1377 IWL_ERR(priv,
1378 "Error sending statistics request: %zd\n", ret);
1379 return -EAGAIN;
1380 }
1381 buf = kzalloc(bufsz, GFP_KERNEL); 1708 buf = kzalloc(bufsz, GFP_KERNEL);
1382 if (!buf) { 1709 if (!buf) {
1383 IWL_ERR(priv, "Can not allocate Buffer\n"); 1710 IWL_ERR(priv, "Can not allocate Buffer\n");
@@ -1391,34 +1718,79 @@ static ssize_t iwl_dbgfs_ucode_general_stats_read(struct file *file,
1391 general = &priv->statistics.general; 1718 general = &priv->statistics.general;
1392 dbg = &priv->statistics.general.dbg; 1719 dbg = &priv->statistics.general.dbg;
1393 div = &priv->statistics.general.div; 1720 div = &priv->statistics.general.div;
1721 accum_general = &priv->accum_statistics.general;
1722 delta_general = &priv->delta_statistics.general;
1723 max_general = &priv->max_delta.general;
1724 accum_dbg = &priv->accum_statistics.general.dbg;
1725 delta_dbg = &priv->delta_statistics.general.dbg;
1726 max_dbg = &priv->max_delta.general.dbg;
1727 accum_div = &priv->accum_statistics.general.div;
1728 delta_div = &priv->delta_statistics.general.div;
1729 max_div = &priv->max_delta.general.div;
1394 pos += iwl_dbgfs_statistics_flag(priv, buf, bufsz); 1730 pos += iwl_dbgfs_statistics_flag(priv, buf, bufsz);
1395 pos += scnprintf(buf + pos, bufsz - pos, "Statistics_General:\n"); 1731 pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_header,
1396 pos += scnprintf(buf + pos, bufsz - pos, "temperature: %u\n", 1732 "Statistics_General:");
1733 pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_short_format,
1734 "temperature:",
1397 le32_to_cpu(general->temperature)); 1735 le32_to_cpu(general->temperature));
1398 pos += scnprintf(buf + pos, bufsz - pos, "temperature_m: %u\n", 1736 pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_short_format,
1737 "temperature_m:",
1399 le32_to_cpu(general->temperature_m)); 1738 le32_to_cpu(general->temperature_m));
1400 pos += scnprintf(buf + pos, bufsz - pos, "burst_check: %u\n", 1739 pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
1401 le32_to_cpu(dbg->burst_check)); 1740 "burst_check:",
1402 pos += scnprintf(buf + pos, bufsz - pos, "burst_count: %u\n", 1741 le32_to_cpu(dbg->burst_check),
1403 le32_to_cpu(dbg->burst_count)); 1742 accum_dbg->burst_check,
1404 pos += scnprintf(buf + pos, bufsz - pos, "sleep_time: %u\n", 1743 delta_dbg->burst_check, max_dbg->burst_check);
1405 le32_to_cpu(general->sleep_time)); 1744 pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
1406 pos += scnprintf(buf + pos, bufsz - pos, "slots_out: %u\n", 1745 "burst_count:",
1407 le32_to_cpu(general->slots_out)); 1746 le32_to_cpu(dbg->burst_count),
1408 pos += scnprintf(buf + pos, bufsz - pos, "slots_idle: %u\n", 1747 accum_dbg->burst_count,
1409 le32_to_cpu(general->slots_idle)); 1748 delta_dbg->burst_count, max_dbg->burst_count);
1410 pos += scnprintf(buf + pos, bufsz - pos, "ttl_timestamp: %u\n", 1749 pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
1750 "sleep_time:",
1751 le32_to_cpu(general->sleep_time),
1752 accum_general->sleep_time,
1753 delta_general->sleep_time, max_general->sleep_time);
1754 pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
1755 "slots_out:",
1756 le32_to_cpu(general->slots_out),
1757 accum_general->slots_out,
1758 delta_general->slots_out, max_general->slots_out);
1759 pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
1760 "slots_idle:",
1761 le32_to_cpu(general->slots_idle),
1762 accum_general->slots_idle,
1763 delta_general->slots_idle, max_general->slots_idle);
1764 pos += scnprintf(buf + pos, bufsz - pos, "ttl_timestamp:\t\t\t%u\n",
1411 le32_to_cpu(general->ttl_timestamp)); 1765 le32_to_cpu(general->ttl_timestamp));
1412 pos += scnprintf(buf + pos, bufsz - pos, "tx_on_a: %u\n", 1766 pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
1413 le32_to_cpu(div->tx_on_a)); 1767 "tx_on_a:",
1414 pos += scnprintf(buf + pos, bufsz - pos, "tx_on_b: %u\n", 1768 le32_to_cpu(div->tx_on_a), accum_div->tx_on_a,
1415 le32_to_cpu(div->tx_on_b)); 1769 delta_div->tx_on_a, max_div->tx_on_a);
1416 pos += scnprintf(buf + pos, bufsz - pos, "exec_time: %u\n", 1770 pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
1417 le32_to_cpu(div->exec_time)); 1771 "tx_on_b:",
1418 pos += scnprintf(buf + pos, bufsz - pos, "probe_time: %u\n", 1772 le32_to_cpu(div->tx_on_b), accum_div->tx_on_b,
1419 le32_to_cpu(div->probe_time)); 1773 delta_div->tx_on_b, max_div->tx_on_b);
1420 pos += scnprintf(buf + pos, bufsz - pos, "rx_enable_counter: %u\n", 1774 pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
1421 le32_to_cpu(general->rx_enable_counter)); 1775 "exec_time:",
1776 le32_to_cpu(div->exec_time), accum_div->exec_time,
1777 delta_div->exec_time, max_div->exec_time);
1778 pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
1779 "probe_time:",
1780 le32_to_cpu(div->probe_time), accum_div->probe_time,
1781 delta_div->probe_time, max_div->probe_time);
1782 pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
1783 "rx_enable_counter:",
1784 le32_to_cpu(general->rx_enable_counter),
1785 accum_general->rx_enable_counter,
1786 delta_general->rx_enable_counter,
1787 max_general->rx_enable_counter);
1788 pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
1789 "num_of_sos_states:",
1790 le32_to_cpu(general->num_of_sos_states),
1791 accum_general->num_of_sos_states,
1792 delta_general->num_of_sos_states,
1793 max_general->num_of_sos_states);
1422 ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos); 1794 ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos);
1423 kfree(buf); 1795 kfree(buf);
1424 return ret; 1796 return ret;
@@ -1428,7 +1800,7 @@ static ssize_t iwl_dbgfs_sensitivity_read(struct file *file,
1428 char __user *user_buf, 1800 char __user *user_buf,
1429 size_t count, loff_t *ppos) { 1801 size_t count, loff_t *ppos) {
1430 1802
1431 struct iwl_priv *priv = (struct iwl_priv *)file->private_data; 1803 struct iwl_priv *priv = file->private_data;
1432 int pos = 0; 1804 int pos = 0;
1433 int cnt = 0; 1805 int cnt = 0;
1434 char *buf; 1806 char *buf;
@@ -1509,7 +1881,7 @@ static ssize_t iwl_dbgfs_chain_noise_read(struct file *file,
1509 char __user *user_buf, 1881 char __user *user_buf,
1510 size_t count, loff_t *ppos) { 1882 size_t count, loff_t *ppos) {
1511 1883
1512 struct iwl_priv *priv = (struct iwl_priv *)file->private_data; 1884 struct iwl_priv *priv = file->private_data;
1513 int pos = 0; 1885 int pos = 0;
1514 int cnt = 0; 1886 int cnt = 0;
1515 char *buf; 1887 char *buf;
@@ -1567,26 +1939,15 @@ static ssize_t iwl_dbgfs_tx_power_read(struct file *file,
1567 char __user *user_buf, 1939 char __user *user_buf,
1568 size_t count, loff_t *ppos) { 1940 size_t count, loff_t *ppos) {
1569 1941
1570 struct iwl_priv *priv = (struct iwl_priv *)file->private_data; 1942 struct iwl_priv *priv = file->private_data;
1571 char buf[128]; 1943 char buf[128];
1572 int pos = 0; 1944 int pos = 0;
1573 ssize_t ret;
1574 const size_t bufsz = sizeof(buf); 1945 const size_t bufsz = sizeof(buf);
1575 struct statistics_tx *tx; 1946 struct statistics_tx *tx;
1576 1947
1577 if (!iwl_is_alive(priv)) 1948 if (!iwl_is_alive(priv))
1578 pos += scnprintf(buf + pos, bufsz - pos, "N/A\n"); 1949 pos += scnprintf(buf + pos, bufsz - pos, "N/A\n");
1579 else { 1950 else {
1580 /* make request to uCode to retrieve statistics information */
1581 mutex_lock(&priv->mutex);
1582 ret = iwl_send_statistics_request(priv, 0);
1583 mutex_unlock(&priv->mutex);
1584
1585 if (ret) {
1586 IWL_ERR(priv, "Error sending statistics request: %zd\n",
1587 ret);
1588 return -EAGAIN;
1589 }
1590 tx = &priv->statistics.tx; 1951 tx = &priv->statistics.tx;
1591 if (tx->tx_power.ant_a || 1952 if (tx->tx_power.ant_a ||
1592 tx->tx_power.ant_b || 1953 tx->tx_power.ant_b ||
@@ -1614,8 +1975,311 @@ static ssize_t iwl_dbgfs_tx_power_read(struct file *file,
1614 return simple_read_from_buffer(user_buf, count, ppos, buf, pos); 1975 return simple_read_from_buffer(user_buf, count, ppos, buf, pos);
1615} 1976}
1616 1977
1617DEBUGFS_READ_WRITE_FILE_OPS(rx_statistics); 1978static ssize_t iwl_dbgfs_power_save_status_read(struct file *file,
1618DEBUGFS_READ_WRITE_FILE_OPS(tx_statistics); 1979 char __user *user_buf,
1980 size_t count, loff_t *ppos)
1981{
1982 struct iwl_priv *priv = file->private_data;
1983 char buf[60];
1984 int pos = 0;
1985 const size_t bufsz = sizeof(buf);
1986 u32 pwrsave_status;
1987
1988 pwrsave_status = iwl_read32(priv, CSR_GP_CNTRL) &
1989 CSR_GP_REG_POWER_SAVE_STATUS_MSK;
1990
1991 pos += scnprintf(buf + pos, bufsz - pos, "Power Save Status: ");
1992 pos += scnprintf(buf + pos, bufsz - pos, "%s\n",
1993 (pwrsave_status == CSR_GP_REG_NO_POWER_SAVE) ? "none" :
1994 (pwrsave_status == CSR_GP_REG_MAC_POWER_SAVE) ? "MAC" :
1995 (pwrsave_status == CSR_GP_REG_PHY_POWER_SAVE) ? "PHY" :
1996 "error");
1997
1998 return simple_read_from_buffer(user_buf, count, ppos, buf, pos);
1999}
2000
2001static ssize_t iwl_dbgfs_clear_ucode_statistics_write(struct file *file,
2002 const char __user *user_buf,
2003 size_t count, loff_t *ppos)
2004{
2005 struct iwl_priv *priv = file->private_data;
2006 char buf[8];
2007 int buf_size;
2008 int clear;
2009
2010 memset(buf, 0, sizeof(buf));
2011 buf_size = min(count, sizeof(buf) - 1);
2012 if (copy_from_user(buf, user_buf, buf_size))
2013 return -EFAULT;
2014 if (sscanf(buf, "%d", &clear) != 1)
2015 return -EFAULT;
2016
2017 /* make request to uCode to retrieve statistics information */
2018 mutex_lock(&priv->mutex);
2019 iwl_send_statistics_request(priv, CMD_SYNC, true);
2020 mutex_unlock(&priv->mutex);
2021
2022 return count;
2023}
2024
2025static ssize_t iwl_dbgfs_csr_write(struct file *file,
2026 const char __user *user_buf,
2027 size_t count, loff_t *ppos)
2028{
2029 struct iwl_priv *priv = file->private_data;
2030 char buf[8];
2031 int buf_size;
2032 int csr;
2033
2034 memset(buf, 0, sizeof(buf));
2035 buf_size = min(count, sizeof(buf) - 1);
2036 if (copy_from_user(buf, user_buf, buf_size))
2037 return -EFAULT;
2038 if (sscanf(buf, "%d", &csr) != 1)
2039 return -EFAULT;
2040
2041 if (priv->cfg->ops->lib->dump_csr)
2042 priv->cfg->ops->lib->dump_csr(priv);
2043
2044 return count;
2045}
2046
2047static ssize_t iwl_dbgfs_ucode_tracing_read(struct file *file,
2048 char __user *user_buf,
2049 size_t count, loff_t *ppos) {
2050
2051 struct iwl_priv *priv = (struct iwl_priv *)file->private_data;
2052 int pos = 0;
2053 char buf[128];
2054 const size_t bufsz = sizeof(buf);
2055 ssize_t ret;
2056
2057 pos += scnprintf(buf + pos, bufsz - pos, "ucode trace timer is %s\n",
2058 priv->event_log.ucode_trace ? "On" : "Off");
2059 pos += scnprintf(buf + pos, bufsz - pos, "non_wraps_count:\t\t %u\n",
2060 priv->event_log.non_wraps_count);
2061 pos += scnprintf(buf + pos, bufsz - pos, "wraps_once_count:\t\t %u\n",
2062 priv->event_log.wraps_once_count);
2063 pos += scnprintf(buf + pos, bufsz - pos, "wraps_more_count:\t\t %u\n",
2064 priv->event_log.wraps_more_count);
2065
2066 ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos);
2067 return ret;
2068}
2069
2070static ssize_t iwl_dbgfs_ucode_tracing_write(struct file *file,
2071 const char __user *user_buf,
2072 size_t count, loff_t *ppos)
2073{
2074 struct iwl_priv *priv = file->private_data;
2075 char buf[8];
2076 int buf_size;
2077 int trace;
2078
2079 memset(buf, 0, sizeof(buf));
2080 buf_size = min(count, sizeof(buf) - 1);
2081 if (copy_from_user(buf, user_buf, buf_size))
2082 return -EFAULT;
2083 if (sscanf(buf, "%d", &trace) != 1)
2084 return -EFAULT;
2085
2086 if (trace) {
2087 priv->event_log.ucode_trace = true;
2088 /* schedule the ucode timer to occur in UCODE_TRACE_PERIOD */
2089 mod_timer(&priv->ucode_trace,
2090 jiffies + msecs_to_jiffies(UCODE_TRACE_PERIOD));
2091 } else {
2092 priv->event_log.ucode_trace = false;
2093 del_timer_sync(&priv->ucode_trace);
2094 }
2095
2096 return count;
2097}
2098
2099static ssize_t iwl_dbgfs_fh_reg_read(struct file *file,
2100 char __user *user_buf,
2101 size_t count, loff_t *ppos)
2102{
2103 struct iwl_priv *priv = (struct iwl_priv *)file->private_data;
2104 char *buf;
2105 int pos = 0;
2106 ssize_t ret = -EFAULT;
2107
2108 if (priv->cfg->ops->lib->dump_fh) {
2109 ret = pos = priv->cfg->ops->lib->dump_fh(priv, &buf, true);
2110 if (buf) {
2111 ret = simple_read_from_buffer(user_buf,
2112 count, ppos, buf, pos);
2113 kfree(buf);
2114 }
2115 }
2116
2117 return ret;
2118}
2119
2120static ssize_t iwl_dbgfs_missed_beacon_read(struct file *file,
2121 char __user *user_buf,
2122 size_t count, loff_t *ppos) {
2123
2124 struct iwl_priv *priv = file->private_data;
2125 int pos = 0;
2126 char buf[12];
2127 const size_t bufsz = sizeof(buf);
2128 ssize_t ret;
2129
2130 pos += scnprintf(buf + pos, bufsz - pos, "%d\n",
2131 priv->missed_beacon_threshold);
2132
2133 ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos);
2134 return ret;
2135}
2136
2137static ssize_t iwl_dbgfs_missed_beacon_write(struct file *file,
2138 const char __user *user_buf,
2139 size_t count, loff_t *ppos)
2140{
2141 struct iwl_priv *priv = file->private_data;
2142 char buf[8];
2143 int buf_size;
2144 int missed;
2145
2146 memset(buf, 0, sizeof(buf));
2147 buf_size = min(count, sizeof(buf) - 1);
2148 if (copy_from_user(buf, user_buf, buf_size))
2149 return -EFAULT;
2150 if (sscanf(buf, "%d", &missed) != 1)
2151 return -EINVAL;
2152
2153 if (missed < IWL_MISSED_BEACON_THRESHOLD_MIN ||
2154 missed > IWL_MISSED_BEACON_THRESHOLD_MAX)
2155 priv->missed_beacon_threshold =
2156 IWL_MISSED_BEACON_THRESHOLD_DEF;
2157 else
2158 priv->missed_beacon_threshold = missed;
2159
2160 return count;
2161}
2162
2163static ssize_t iwl_dbgfs_internal_scan_write(struct file *file,
2164 const char __user *user_buf,
2165 size_t count, loff_t *ppos)
2166{
2167 struct iwl_priv *priv = file->private_data;
2168 char buf[8];
2169 int buf_size;
2170 int scan;
2171
2172 memset(buf, 0, sizeof(buf));
2173 buf_size = min(count, sizeof(buf) - 1);
2174 if (copy_from_user(buf, user_buf, buf_size))
2175 return -EFAULT;
2176 if (sscanf(buf, "%d", &scan) != 1)
2177 return -EINVAL;
2178
2179 iwl_internal_short_hw_scan(priv);
2180
2181 return count;
2182}
2183
2184static ssize_t iwl_dbgfs_plcp_delta_read(struct file *file,
2185 char __user *user_buf,
2186 size_t count, loff_t *ppos) {
2187
2188 struct iwl_priv *priv = (struct iwl_priv *)file->private_data;
2189 int pos = 0;
2190 char buf[12];
2191 const size_t bufsz = sizeof(buf);
2192 ssize_t ret;
2193
2194 pos += scnprintf(buf + pos, bufsz - pos, "%u\n",
2195 priv->cfg->plcp_delta_threshold);
2196
2197 ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos);
2198 return ret;
2199}
2200
2201static ssize_t iwl_dbgfs_plcp_delta_write(struct file *file,
2202 const char __user *user_buf,
2203 size_t count, loff_t *ppos) {
2204
2205 struct iwl_priv *priv = file->private_data;
2206 char buf[8];
2207 int buf_size;
2208 int plcp;
2209
2210 memset(buf, 0, sizeof(buf));
2211 buf_size = min(count, sizeof(buf) - 1);
2212 if (copy_from_user(buf, user_buf, buf_size))
2213 return -EFAULT;
2214 if (sscanf(buf, "%d", &plcp) != 1)
2215 return -EINVAL;
2216 if ((plcp <= IWL_MAX_PLCP_ERR_THRESHOLD_MIN) ||
2217 (plcp > IWL_MAX_PLCP_ERR_THRESHOLD_MAX))
2218 priv->cfg->plcp_delta_threshold =
2219 IWL_MAX_PLCP_ERR_THRESHOLD_DEF;
2220 else
2221 priv->cfg->plcp_delta_threshold = plcp;
2222 return count;
2223}
2224
2225static ssize_t iwl_dbgfs_force_reset_read(struct file *file,
2226 char __user *user_buf,
2227 size_t count, loff_t *ppos) {
2228
2229 struct iwl_priv *priv = file->private_data;
2230 int i, pos = 0;
2231 char buf[300];
2232 const size_t bufsz = sizeof(buf);
2233 struct iwl_force_reset *force_reset;
2234
2235 for (i = 0; i < IWL_MAX_FORCE_RESET; i++) {
2236 force_reset = &priv->force_reset[i];
2237 pos += scnprintf(buf + pos, bufsz - pos,
2238 "Force reset method %d\n", i);
2239 pos += scnprintf(buf + pos, bufsz - pos,
2240 "\tnumber of reset request: %d\n",
2241 force_reset->reset_request_count);
2242 pos += scnprintf(buf + pos, bufsz - pos,
2243 "\tnumber of reset request success: %d\n",
2244 force_reset->reset_success_count);
2245 pos += scnprintf(buf + pos, bufsz - pos,
2246 "\tnumber of reset request reject: %d\n",
2247 force_reset->reset_reject_count);
2248 pos += scnprintf(buf + pos, bufsz - pos,
2249 "\treset duration: %lu\n",
2250 force_reset->reset_duration);
2251 }
2252 return simple_read_from_buffer(user_buf, count, ppos, buf, pos);
2253}
2254
2255static ssize_t iwl_dbgfs_force_reset_write(struct file *file,
2256 const char __user *user_buf,
2257 size_t count, loff_t *ppos) {
2258
2259 struct iwl_priv *priv = file->private_data;
2260 char buf[8];
2261 int buf_size;
2262 int reset, ret;
2263
2264 memset(buf, 0, sizeof(buf));
2265 buf_size = min(count, sizeof(buf) - 1);
2266 if (copy_from_user(buf, user_buf, buf_size))
2267 return -EFAULT;
2268 if (sscanf(buf, "%d", &reset) != 1)
2269 return -EINVAL;
2270 switch (reset) {
2271 case IWL_RF_RESET:
2272 case IWL_FW_RESET:
2273 ret = iwl_force_reset(priv, reset);
2274 break;
2275 default:
2276 return -EINVAL;
2277 }
2278 return ret ? ret : count;
2279}
2280
2281DEBUGFS_READ_FILE_OPS(rx_statistics);
2282DEBUGFS_READ_FILE_OPS(tx_statistics);
1619DEBUGFS_READ_WRITE_FILE_OPS(traffic_log); 2283DEBUGFS_READ_WRITE_FILE_OPS(traffic_log);
1620DEBUGFS_READ_FILE_OPS(rx_queue); 2284DEBUGFS_READ_FILE_OPS(rx_queue);
1621DEBUGFS_READ_FILE_OPS(tx_queue); 2285DEBUGFS_READ_FILE_OPS(tx_queue);
@@ -1625,6 +2289,16 @@ DEBUGFS_READ_FILE_OPS(ucode_general_stats);
1625DEBUGFS_READ_FILE_OPS(sensitivity); 2289DEBUGFS_READ_FILE_OPS(sensitivity);
1626DEBUGFS_READ_FILE_OPS(chain_noise); 2290DEBUGFS_READ_FILE_OPS(chain_noise);
1627DEBUGFS_READ_FILE_OPS(tx_power); 2291DEBUGFS_READ_FILE_OPS(tx_power);
2292DEBUGFS_READ_FILE_OPS(power_save_status);
2293DEBUGFS_WRITE_FILE_OPS(clear_ucode_statistics);
2294DEBUGFS_WRITE_FILE_OPS(clear_traffic_statistics);
2295DEBUGFS_WRITE_FILE_OPS(csr);
2296DEBUGFS_READ_WRITE_FILE_OPS(ucode_tracing);
2297DEBUGFS_READ_FILE_OPS(fh_reg);
2298DEBUGFS_READ_WRITE_FILE_OPS(missed_beacon);
2299DEBUGFS_WRITE_FILE_OPS(internal_scan);
2300DEBUGFS_READ_WRITE_FILE_OPS(plcp_delta);
2301DEBUGFS_READ_WRITE_FILE_OPS(force_reset);
1628 2302
1629/* 2303/*
1630 * Create the debugfs files and directories 2304 * Create the debugfs files and directories
@@ -1632,68 +2306,74 @@ DEBUGFS_READ_FILE_OPS(tx_power);
1632 */ 2306 */
1633int iwl_dbgfs_register(struct iwl_priv *priv, const char *name) 2307int iwl_dbgfs_register(struct iwl_priv *priv, const char *name)
1634{ 2308{
1635 struct iwl_debugfs *dbgfs;
1636 struct dentry *phyd = priv->hw->wiphy->debugfsdir; 2309 struct dentry *phyd = priv->hw->wiphy->debugfsdir;
1637 int ret = 0; 2310 struct dentry *dir_drv, *dir_data, *dir_rf, *dir_debug;
1638 2311
1639 dbgfs = kzalloc(sizeof(struct iwl_debugfs), GFP_KERNEL); 2312 dir_drv = debugfs_create_dir(name, phyd);
1640 if (!dbgfs) { 2313 if (!dir_drv)
1641 ret = -ENOMEM; 2314 return -ENOMEM;
1642 goto err; 2315
1643 } 2316 priv->debugfs_dir = dir_drv;
1644 2317
1645 priv->dbgfs = dbgfs; 2318 dir_data = debugfs_create_dir("data", dir_drv);
1646 dbgfs->name = name; 2319 if (!dir_data)
1647 dbgfs->dir_drv = debugfs_create_dir(name, phyd); 2320 goto err;
1648 if (!dbgfs->dir_drv || IS_ERR(dbgfs->dir_drv)) { 2321 dir_rf = debugfs_create_dir("rf", dir_drv);
1649 ret = -ENOENT; 2322 if (!dir_rf)
2323 goto err;
2324 dir_debug = debugfs_create_dir("debug", dir_drv);
2325 if (!dir_debug)
1650 goto err; 2326 goto err;
1651 }
1652 2327
1653 DEBUGFS_ADD_DIR(data, dbgfs->dir_drv); 2328 DEBUGFS_ADD_FILE(nvm, dir_data, S_IRUSR);
1654 DEBUGFS_ADD_DIR(rf, dbgfs->dir_drv); 2329 DEBUGFS_ADD_FILE(sram, dir_data, S_IWUSR | S_IRUSR);
1655 DEBUGFS_ADD_DIR(debug, dbgfs->dir_drv); 2330 DEBUGFS_ADD_FILE(log_event, dir_data, S_IWUSR | S_IRUSR);
1656 DEBUGFS_ADD_FILE(nvm, data); 2331 DEBUGFS_ADD_FILE(stations, dir_data, S_IRUSR);
1657 DEBUGFS_ADD_FILE(sram, data); 2332 DEBUGFS_ADD_FILE(channels, dir_data, S_IRUSR);
1658 DEBUGFS_ADD_FILE(log_event, data); 2333 DEBUGFS_ADD_FILE(status, dir_data, S_IRUSR);
1659 DEBUGFS_ADD_FILE(stations, data); 2334 DEBUGFS_ADD_FILE(interrupt, dir_data, S_IWUSR | S_IRUSR);
1660 DEBUGFS_ADD_FILE(channels, data); 2335 DEBUGFS_ADD_FILE(qos, dir_data, S_IRUSR);
1661 DEBUGFS_ADD_FILE(status, data); 2336 DEBUGFS_ADD_FILE(led, dir_data, S_IRUSR);
1662 DEBUGFS_ADD_FILE(interrupt, data); 2337 DEBUGFS_ADD_FILE(sleep_level_override, dir_data, S_IWUSR | S_IRUSR);
1663 DEBUGFS_ADD_FILE(qos, data); 2338 DEBUGFS_ADD_FILE(current_sleep_command, dir_data, S_IRUSR);
1664#ifdef CONFIG_IWLWIFI_LEDS 2339 DEBUGFS_ADD_FILE(thermal_throttling, dir_data, S_IRUSR);
1665 DEBUGFS_ADD_FILE(led, data); 2340 DEBUGFS_ADD_FILE(disable_ht40, dir_data, S_IWUSR | S_IRUSR);
1666#endif 2341 DEBUGFS_ADD_FILE(rx_statistics, dir_debug, S_IRUSR);
1667 DEBUGFS_ADD_FILE(sleep_level_override, data); 2342 DEBUGFS_ADD_FILE(tx_statistics, dir_debug, S_IRUSR);
1668 DEBUGFS_ADD_FILE(current_sleep_command, data); 2343 DEBUGFS_ADD_FILE(traffic_log, dir_debug, S_IWUSR | S_IRUSR);
1669 DEBUGFS_ADD_FILE(thermal_throttling, data); 2344 DEBUGFS_ADD_FILE(rx_queue, dir_debug, S_IRUSR);
1670 DEBUGFS_ADD_FILE(disable_ht40, data); 2345 DEBUGFS_ADD_FILE(tx_queue, dir_debug, S_IRUSR);
1671 DEBUGFS_ADD_FILE(rx_statistics, debug); 2346 DEBUGFS_ADD_FILE(tx_power, dir_debug, S_IRUSR);
1672 DEBUGFS_ADD_FILE(tx_statistics, debug); 2347 DEBUGFS_ADD_FILE(power_save_status, dir_debug, S_IRUSR);
1673 DEBUGFS_ADD_FILE(traffic_log, debug); 2348 DEBUGFS_ADD_FILE(clear_ucode_statistics, dir_debug, S_IWUSR);
1674 DEBUGFS_ADD_FILE(rx_queue, debug); 2349 DEBUGFS_ADD_FILE(clear_traffic_statistics, dir_debug, S_IWUSR);
1675 DEBUGFS_ADD_FILE(tx_queue, debug); 2350 DEBUGFS_ADD_FILE(csr, dir_debug, S_IWUSR);
1676 DEBUGFS_ADD_FILE(tx_power, debug); 2351 DEBUGFS_ADD_FILE(fh_reg, dir_debug, S_IRUSR);
2352 DEBUGFS_ADD_FILE(missed_beacon, dir_debug, S_IWUSR);
2353 DEBUGFS_ADD_FILE(internal_scan, dir_debug, S_IWUSR);
2354 DEBUGFS_ADD_FILE(plcp_delta, dir_debug, S_IWUSR | S_IRUSR);
2355 DEBUGFS_ADD_FILE(force_reset, dir_debug, S_IWUSR | S_IRUSR);
1677 if ((priv->hw_rev & CSR_HW_REV_TYPE_MSK) != CSR_HW_REV_TYPE_3945) { 2356 if ((priv->hw_rev & CSR_HW_REV_TYPE_MSK) != CSR_HW_REV_TYPE_3945) {
1678 DEBUGFS_ADD_FILE(ucode_rx_stats, debug); 2357 DEBUGFS_ADD_FILE(ucode_rx_stats, dir_debug, S_IRUSR);
1679 DEBUGFS_ADD_FILE(ucode_tx_stats, debug); 2358 DEBUGFS_ADD_FILE(ucode_tx_stats, dir_debug, S_IRUSR);
1680 DEBUGFS_ADD_FILE(ucode_general_stats, debug); 2359 DEBUGFS_ADD_FILE(ucode_general_stats, dir_debug, S_IRUSR);
1681 DEBUGFS_ADD_FILE(sensitivity, debug); 2360 DEBUGFS_ADD_FILE(sensitivity, dir_debug, S_IRUSR);
1682 DEBUGFS_ADD_FILE(chain_noise, debug); 2361 DEBUGFS_ADD_FILE(chain_noise, dir_debug, S_IRUSR);
2362 DEBUGFS_ADD_FILE(ucode_tracing, dir_debug, S_IWUSR | S_IRUSR);
1683 } 2363 }
1684 DEBUGFS_ADD_BOOL(disable_sensitivity, rf, &priv->disable_sens_cal); 2364 DEBUGFS_ADD_BOOL(disable_sensitivity, dir_rf, &priv->disable_sens_cal);
1685 DEBUGFS_ADD_BOOL(disable_chain_noise, rf, 2365 DEBUGFS_ADD_BOOL(disable_chain_noise, dir_rf,
1686 &priv->disable_chain_noise_cal); 2366 &priv->disable_chain_noise_cal);
1687 if (((priv->hw_rev & CSR_HW_REV_TYPE_MSK) == CSR_HW_REV_TYPE_4965) || 2367 if (((priv->hw_rev & CSR_HW_REV_TYPE_MSK) == CSR_HW_REV_TYPE_4965) ||
1688 ((priv->hw_rev & CSR_HW_REV_TYPE_MSK) == CSR_HW_REV_TYPE_3945)) 2368 ((priv->hw_rev & CSR_HW_REV_TYPE_MSK) == CSR_HW_REV_TYPE_3945))
1689 DEBUGFS_ADD_BOOL(disable_tx_power, rf, 2369 DEBUGFS_ADD_BOOL(disable_tx_power, dir_rf,
1690 &priv->disable_tx_power_cal); 2370 &priv->disable_tx_power_cal);
1691 return 0; 2371 return 0;
1692 2372
1693err: 2373err:
1694 IWL_ERR(priv, "Can't open the debugfs directory\n"); 2374 IWL_ERR(priv, "Can't create the debugfs directory\n");
1695 iwl_dbgfs_unregister(priv); 2375 iwl_dbgfs_unregister(priv);
1696 return ret; 2376 return -ENOMEM;
1697} 2377}
1698EXPORT_SYMBOL(iwl_dbgfs_register); 2378EXPORT_SYMBOL(iwl_dbgfs_register);
1699 2379
@@ -1703,53 +2383,11 @@ EXPORT_SYMBOL(iwl_dbgfs_register);
1703 */ 2383 */
1704void iwl_dbgfs_unregister(struct iwl_priv *priv) 2384void iwl_dbgfs_unregister(struct iwl_priv *priv)
1705{ 2385{
1706 if (!priv->dbgfs) 2386 if (!priv->debugfs_dir)
1707 return; 2387 return;
1708 2388
1709 DEBUGFS_REMOVE(priv->dbgfs->dbgfs_data_files.file_sleep_level_override); 2389 debugfs_remove_recursive(priv->debugfs_dir);
1710 DEBUGFS_REMOVE(priv->dbgfs->dbgfs_data_files.file_current_sleep_command); 2390 priv->debugfs_dir = NULL;
1711 DEBUGFS_REMOVE(priv->dbgfs->dbgfs_data_files.file_nvm);
1712 DEBUGFS_REMOVE(priv->dbgfs->dbgfs_data_files.file_sram);
1713 DEBUGFS_REMOVE(priv->dbgfs->dbgfs_data_files.file_log_event);
1714 DEBUGFS_REMOVE(priv->dbgfs->dbgfs_data_files.file_stations);
1715 DEBUGFS_REMOVE(priv->dbgfs->dbgfs_data_files.file_channels);
1716 DEBUGFS_REMOVE(priv->dbgfs->dbgfs_data_files.file_status);
1717 DEBUGFS_REMOVE(priv->dbgfs->dbgfs_data_files.file_interrupt);
1718 DEBUGFS_REMOVE(priv->dbgfs->dbgfs_data_files.file_qos);
1719#ifdef CONFIG_IWLWIFI_LEDS
1720 DEBUGFS_REMOVE(priv->dbgfs->dbgfs_data_files.file_led);
1721#endif
1722 DEBUGFS_REMOVE(priv->dbgfs->dbgfs_data_files.file_thermal_throttling);
1723 DEBUGFS_REMOVE(priv->dbgfs->dbgfs_data_files.file_disable_ht40);
1724 DEBUGFS_REMOVE(priv->dbgfs->dir_data);
1725 DEBUGFS_REMOVE(priv->dbgfs->dbgfs_debug_files.file_rx_statistics);
1726 DEBUGFS_REMOVE(priv->dbgfs->dbgfs_debug_files.file_tx_statistics);
1727 DEBUGFS_REMOVE(priv->dbgfs->dbgfs_debug_files.file_traffic_log);
1728 DEBUGFS_REMOVE(priv->dbgfs->dbgfs_debug_files.file_rx_queue);
1729 DEBUGFS_REMOVE(priv->dbgfs->dbgfs_debug_files.file_tx_queue);
1730 DEBUGFS_REMOVE(priv->dbgfs->dbgfs_debug_files.file_tx_power);
1731 if ((priv->hw_rev & CSR_HW_REV_TYPE_MSK) != CSR_HW_REV_TYPE_3945) {
1732 DEBUGFS_REMOVE(priv->dbgfs->dbgfs_debug_files.
1733 file_ucode_rx_stats);
1734 DEBUGFS_REMOVE(priv->dbgfs->dbgfs_debug_files.
1735 file_ucode_tx_stats);
1736 DEBUGFS_REMOVE(priv->dbgfs->dbgfs_debug_files.
1737 file_ucode_general_stats);
1738 DEBUGFS_REMOVE(priv->dbgfs->dbgfs_debug_files.
1739 file_sensitivity);
1740 DEBUGFS_REMOVE(priv->dbgfs->dbgfs_debug_files.
1741 file_chain_noise);
1742 }
1743 DEBUGFS_REMOVE(priv->dbgfs->dir_debug);
1744 DEBUGFS_REMOVE(priv->dbgfs->dbgfs_rf_files.file_disable_sensitivity);
1745 DEBUGFS_REMOVE(priv->dbgfs->dbgfs_rf_files.file_disable_chain_noise);
1746 if (((priv->hw_rev & CSR_HW_REV_TYPE_MSK) == CSR_HW_REV_TYPE_4965) ||
1747 ((priv->hw_rev & CSR_HW_REV_TYPE_MSK) == CSR_HW_REV_TYPE_3945))
1748 DEBUGFS_REMOVE(priv->dbgfs->dbgfs_rf_files.file_disable_tx_power);
1749 DEBUGFS_REMOVE(priv->dbgfs->dir_rf);
1750 DEBUGFS_REMOVE(priv->dbgfs->dir_drv);
1751 kfree(priv->dbgfs);
1752 priv->dbgfs = NULL;
1753} 2391}
1754EXPORT_SYMBOL(iwl_dbgfs_unregister); 2392EXPORT_SYMBOL(iwl_dbgfs_unregister);
1755 2393