iwl-debugfs.c revision 0692fe41b36159be5d8c7d4eef0699e79c383c85
1/****************************************************************************** 2 * 3 * GPL LICENSE SUMMARY 4 * 5 * Copyright(c) 2008 - 2012 Intel Corporation. All rights reserved. 6 * 7 * This program is free software; you can redistribute it and/or modify 8 * it under the terms of version 2 of the GNU General Public License as 9 * published by the Free Software Foundation. 10 * 11 * This program is distributed in the hope that it will be useful, but 12 * WITHOUT ANY WARRANTY; without even the implied warranty of 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 * General Public License for more details. 15 * 16 * You should have received a copy of the GNU General Public License 17 * along with this program; if not, write to the Free Software 18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110, 19 * USA 20 * 21 * The full GNU General Public License is included in this distribution 22 * in the file called LICENSE.GPL. 23 * 24 * Contact Information: 25 * Intel Linux Wireless <ilw@linux.intel.com> 26 * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497 27 *****************************************************************************/ 28 29#include <linux/slab.h> 30#include <linux/kernel.h> 31#include <linux/module.h> 32#include <linux/debugfs.h> 33 34#include <linux/ieee80211.h> 35#include <net/mac80211.h> 36 37 38#include "iwl-dev.h" 39#include "iwl-debug.h" 40#include "iwl-core.h" 41#include "iwl-io.h" 42#include "iwl-agn.h" 43#include "iwl-wifi.h" 44 45/* create and remove of files */ 46#define DEBUGFS_ADD_FILE(name, parent, mode) do { \ 47 if (!debugfs_create_file(#name, mode, parent, priv, \ 48 &iwl_dbgfs_##name##_ops)) \ 49 goto err; \ 50} while (0) 51 52#define DEBUGFS_ADD_BOOL(name, parent, ptr) do { \ 53 struct dentry *__tmp; \ 54 __tmp = debugfs_create_bool(#name, S_IWUSR | S_IRUSR, \ 55 parent, ptr); \ 56 if (IS_ERR(__tmp) || !__tmp) \ 57 goto err; \ 58} while (0) 59 60#define DEBUGFS_ADD_X32(name, parent, ptr) do { \ 61 struct dentry *__tmp; \ 62 __tmp = debugfs_create_x32(#name, S_IWUSR | S_IRUSR, \ 63 parent, ptr); \ 64 if (IS_ERR(__tmp) || !__tmp) \ 65 goto err; \ 66} while (0) 67 68#define DEBUGFS_ADD_U32(name, parent, ptr, mode) do { \ 69 struct dentry *__tmp; \ 70 __tmp = debugfs_create_u32(#name, mode, \ 71 parent, ptr); \ 72 if (IS_ERR(__tmp) || !__tmp) \ 73 goto err; \ 74} while (0) 75 76/* file operation */ 77#define DEBUGFS_READ_FUNC(name) \ 78static ssize_t iwl_dbgfs_##name##_read(struct file *file, \ 79 char __user *user_buf, \ 80 size_t count, loff_t *ppos); 81 82#define DEBUGFS_WRITE_FUNC(name) \ 83static ssize_t iwl_dbgfs_##name##_write(struct file *file, \ 84 const char __user *user_buf, \ 85 size_t count, loff_t *ppos); 86 87 88static int iwl_dbgfs_open_file_generic(struct inode *inode, struct file *file) 89{ 90 file->private_data = inode->i_private; 91 return 0; 92} 93 94#define DEBUGFS_READ_FILE_OPS(name) \ 95 DEBUGFS_READ_FUNC(name); \ 96static const struct file_operations iwl_dbgfs_##name##_ops = { \ 97 .read = iwl_dbgfs_##name##_read, \ 98 .open = iwl_dbgfs_open_file_generic, \ 99 .llseek = generic_file_llseek, \ 100}; 101 102#define DEBUGFS_WRITE_FILE_OPS(name) \ 103 DEBUGFS_WRITE_FUNC(name); \ 104static const struct file_operations iwl_dbgfs_##name##_ops = { \ 105 .write = iwl_dbgfs_##name##_write, \ 106 .open = iwl_dbgfs_open_file_generic, \ 107 .llseek = generic_file_llseek, \ 108}; 109 110 111#define DEBUGFS_READ_WRITE_FILE_OPS(name) \ 112 DEBUGFS_READ_FUNC(name); \ 113 DEBUGFS_WRITE_FUNC(name); \ 114static const struct file_operations iwl_dbgfs_##name##_ops = { \ 115 .write = iwl_dbgfs_##name##_write, \ 116 .read = iwl_dbgfs_##name##_read, \ 117 .open = iwl_dbgfs_open_file_generic, \ 118 .llseek = generic_file_llseek, \ 119}; 120 121static ssize_t iwl_dbgfs_tx_statistics_read(struct file *file, 122 char __user *user_buf, 123 size_t count, loff_t *ppos) { 124 125 struct iwl_priv *priv = file->private_data; 126 char *buf; 127 int pos = 0; 128 129 int cnt; 130 ssize_t ret; 131 const size_t bufsz = 100 + 132 sizeof(char) * 50 * (MANAGEMENT_MAX + CONTROL_MAX); 133 buf = kzalloc(bufsz, GFP_KERNEL); 134 if (!buf) 135 return -ENOMEM; 136 pos += scnprintf(buf + pos, bufsz - pos, "Management:\n"); 137 for (cnt = 0; cnt < MANAGEMENT_MAX; cnt++) { 138 pos += scnprintf(buf + pos, bufsz - pos, 139 "\t%25s\t\t: %u\n", 140 get_mgmt_string(cnt), 141 priv->tx_stats.mgmt[cnt]); 142 } 143 pos += scnprintf(buf + pos, bufsz - pos, "Control\n"); 144 for (cnt = 0; cnt < CONTROL_MAX; cnt++) { 145 pos += scnprintf(buf + pos, bufsz - pos, 146 "\t%25s\t\t: %u\n", 147 get_ctrl_string(cnt), 148 priv->tx_stats.ctrl[cnt]); 149 } 150 pos += scnprintf(buf + pos, bufsz - pos, "Data:\n"); 151 pos += scnprintf(buf + pos, bufsz - pos, "\tcnt: %u\n", 152 priv->tx_stats.data_cnt); 153 pos += scnprintf(buf + pos, bufsz - pos, "\tbytes: %llu\n", 154 priv->tx_stats.data_bytes); 155 ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos); 156 kfree(buf); 157 return ret; 158} 159 160static ssize_t iwl_dbgfs_clear_traffic_statistics_write(struct file *file, 161 const char __user *user_buf, 162 size_t count, loff_t *ppos) 163{ 164 struct iwl_priv *priv = file->private_data; 165 u32 clear_flag; 166 char buf[8]; 167 int buf_size; 168 169 memset(buf, 0, sizeof(buf)); 170 buf_size = min(count, sizeof(buf) - 1); 171 if (copy_from_user(buf, user_buf, buf_size)) 172 return -EFAULT; 173 if (sscanf(buf, "%x", &clear_flag) != 1) 174 return -EFAULT; 175 iwl_clear_traffic_stats(priv); 176 177 return count; 178} 179 180static ssize_t iwl_dbgfs_rx_statistics_read(struct file *file, 181 char __user *user_buf, 182 size_t count, loff_t *ppos) { 183 184 struct iwl_priv *priv = file->private_data; 185 char *buf; 186 int pos = 0; 187 int cnt; 188 ssize_t ret; 189 const size_t bufsz = 100 + 190 sizeof(char) * 50 * (MANAGEMENT_MAX + CONTROL_MAX); 191 buf = kzalloc(bufsz, GFP_KERNEL); 192 if (!buf) 193 return -ENOMEM; 194 195 pos += scnprintf(buf + pos, bufsz - pos, "Management:\n"); 196 for (cnt = 0; cnt < MANAGEMENT_MAX; cnt++) { 197 pos += scnprintf(buf + pos, bufsz - pos, 198 "\t%25s\t\t: %u\n", 199 get_mgmt_string(cnt), 200 priv->rx_stats.mgmt[cnt]); 201 } 202 pos += scnprintf(buf + pos, bufsz - pos, "Control:\n"); 203 for (cnt = 0; cnt < CONTROL_MAX; cnt++) { 204 pos += scnprintf(buf + pos, bufsz - pos, 205 "\t%25s\t\t: %u\n", 206 get_ctrl_string(cnt), 207 priv->rx_stats.ctrl[cnt]); 208 } 209 pos += scnprintf(buf + pos, bufsz - pos, "Data:\n"); 210 pos += scnprintf(buf + pos, bufsz - pos, "\tcnt: %u\n", 211 priv->rx_stats.data_cnt); 212 pos += scnprintf(buf + pos, bufsz - pos, "\tbytes: %llu\n", 213 priv->rx_stats.data_bytes); 214 215 ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos); 216 kfree(buf); 217 return ret; 218} 219 220static ssize_t iwl_dbgfs_sram_read(struct file *file, 221 char __user *user_buf, 222 size_t count, loff_t *ppos) 223{ 224 u32 val = 0; 225 char *buf; 226 ssize_t ret; 227 int i = 0; 228 bool device_format = false; 229 int offset = 0; 230 int len = 0; 231 int pos = 0; 232 int sram; 233 struct iwl_priv *priv = file->private_data; 234 size_t bufsz; 235 236 /* default is to dump the entire data segment */ 237 if (!priv->dbgfs_sram_offset && !priv->dbgfs_sram_len) { 238 priv->dbgfs_sram_offset = 0x800000; 239 if (priv->shrd->ucode_type == IWL_UCODE_INIT) 240 priv->dbgfs_sram_len = priv->fw->ucode_init.data.len; 241 else 242 priv->dbgfs_sram_len = priv->fw->ucode_rt.data.len; 243 } 244 len = priv->dbgfs_sram_len; 245 246 if (len == -4) { 247 device_format = true; 248 len = 4; 249 } 250 251 bufsz = 50 + len * 4; 252 buf = kmalloc(bufsz, GFP_KERNEL); 253 if (!buf) 254 return -ENOMEM; 255 256 pos += scnprintf(buf + pos, bufsz - pos, "sram_len: 0x%x\n", 257 len); 258 pos += scnprintf(buf + pos, bufsz - pos, "sram_offset: 0x%x\n", 259 priv->dbgfs_sram_offset); 260 261 /* adjust sram address since reads are only on even u32 boundaries */ 262 offset = priv->dbgfs_sram_offset & 0x3; 263 sram = priv->dbgfs_sram_offset & ~0x3; 264 265 /* read the first u32 from sram */ 266 val = iwl_read_targ_mem(trans(priv), sram); 267 268 for (; len; len--) { 269 /* put the address at the start of every line */ 270 if (i == 0) 271 pos += scnprintf(buf + pos, bufsz - pos, 272 "%08X: ", sram + offset); 273 274 if (device_format) 275 pos += scnprintf(buf + pos, bufsz - pos, 276 "%02x", (val >> (8 * (3 - offset))) & 0xff); 277 else 278 pos += scnprintf(buf + pos, bufsz - pos, 279 "%02x ", (val >> (8 * offset)) & 0xff); 280 281 /* if all bytes processed, read the next u32 from sram */ 282 if (++offset == 4) { 283 sram += 4; 284 offset = 0; 285 val = iwl_read_targ_mem(trans(priv), sram); 286 } 287 288 /* put in extra spaces and split lines for human readability */ 289 if (++i == 16) { 290 i = 0; 291 pos += scnprintf(buf + pos, bufsz - pos, "\n"); 292 } else if (!(i & 7)) { 293 pos += scnprintf(buf + pos, bufsz - pos, " "); 294 } else if (!(i & 3)) { 295 pos += scnprintf(buf + pos, bufsz - pos, " "); 296 } 297 } 298 if (i) 299 pos += scnprintf(buf + pos, bufsz - pos, "\n"); 300 301 ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos); 302 kfree(buf); 303 return ret; 304} 305 306static ssize_t iwl_dbgfs_sram_write(struct file *file, 307 const char __user *user_buf, 308 size_t count, loff_t *ppos) 309{ 310 struct iwl_priv *priv = file->private_data; 311 char buf[64]; 312 int buf_size; 313 u32 offset, len; 314 315 memset(buf, 0, sizeof(buf)); 316 buf_size = min(count, sizeof(buf) - 1); 317 if (copy_from_user(buf, user_buf, buf_size)) 318 return -EFAULT; 319 320 if (sscanf(buf, "%x,%x", &offset, &len) == 2) { 321 priv->dbgfs_sram_offset = offset; 322 priv->dbgfs_sram_len = len; 323 } else if (sscanf(buf, "%x", &offset) == 1) { 324 priv->dbgfs_sram_offset = offset; 325 priv->dbgfs_sram_len = -4; 326 } else { 327 priv->dbgfs_sram_offset = 0; 328 priv->dbgfs_sram_len = 0; 329 } 330 331 return count; 332} 333 334static ssize_t iwl_dbgfs_wowlan_sram_read(struct file *file, 335 char __user *user_buf, 336 size_t count, loff_t *ppos) 337{ 338 struct iwl_priv *priv = file->private_data; 339 340 if (!priv->wowlan_sram) 341 return -ENODATA; 342 343 return simple_read_from_buffer(user_buf, count, ppos, 344 priv->wowlan_sram, 345 priv->fw->ucode_wowlan.data.len); 346} 347static ssize_t iwl_dbgfs_stations_read(struct file *file, char __user *user_buf, 348 size_t count, loff_t *ppos) 349{ 350 struct iwl_priv *priv = file->private_data; 351 struct iwl_station_entry *station; 352 struct iwl_tid_data *tid_data; 353 char *buf; 354 int i, j, pos = 0; 355 ssize_t ret; 356 /* Add 30 for initial string */ 357 const size_t bufsz = 30 + sizeof(char) * 500 * (priv->num_stations); 358 359 buf = kmalloc(bufsz, GFP_KERNEL); 360 if (!buf) 361 return -ENOMEM; 362 363 pos += scnprintf(buf + pos, bufsz - pos, "num of stations: %d\n\n", 364 priv->num_stations); 365 366 for (i = 0; i < IWLAGN_STATION_COUNT; i++) { 367 station = &priv->stations[i]; 368 if (!station->used) 369 continue; 370 pos += scnprintf(buf + pos, bufsz - pos, 371 "station %d - addr: %pM, flags: %#x\n", 372 i, station->sta.sta.addr, 373 station->sta.station_flags_msk); 374 pos += scnprintf(buf + pos, bufsz - pos, 375 "TID\tseq_num\trate_n_flags\n"); 376 377 for (j = 0; j < IWL_MAX_TID_COUNT; j++) { 378 tid_data = &priv->tid_data[i][j]; 379 pos += scnprintf(buf + pos, bufsz - pos, 380 "%d:\t%#x\t%#x", 381 j, tid_data->seq_number, 382 tid_data->agg.rate_n_flags); 383 384 if (tid_data->agg.wait_for_ba) 385 pos += scnprintf(buf + pos, bufsz - pos, 386 " - waitforba"); 387 pos += scnprintf(buf + pos, bufsz - pos, "\n"); 388 } 389 390 pos += scnprintf(buf + pos, bufsz - pos, "\n"); 391 } 392 393 ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos); 394 kfree(buf); 395 return ret; 396} 397 398static ssize_t iwl_dbgfs_nvm_read(struct file *file, 399 char __user *user_buf, 400 size_t count, 401 loff_t *ppos) 402{ 403 ssize_t ret; 404 struct iwl_priv *priv = file->private_data; 405 int pos = 0, ofs = 0, buf_size = 0; 406 const u8 *ptr; 407 char *buf; 408 u16 eeprom_ver; 409 size_t eeprom_len = cfg(priv)->base_params->eeprom_size; 410 buf_size = 4 * eeprom_len + 256; 411 412 if (eeprom_len % 16) { 413 IWL_ERR(priv, "NVM size is not multiple of 16.\n"); 414 return -ENODATA; 415 } 416 417 ptr = priv->shrd->eeprom; 418 if (!ptr) { 419 IWL_ERR(priv, "Invalid EEPROM/OTP memory\n"); 420 return -ENOMEM; 421 } 422 423 /* 4 characters for byte 0xYY */ 424 buf = kzalloc(buf_size, GFP_KERNEL); 425 if (!buf) { 426 IWL_ERR(priv, "Can not allocate Buffer\n"); 427 return -ENOMEM; 428 } 429 eeprom_ver = iwl_eeprom_query16(priv->shrd, EEPROM_VERSION); 430 pos += scnprintf(buf + pos, buf_size - pos, "NVM Type: %s, " 431 "version: 0x%x\n", 432 (trans(priv)->nvm_device_type == NVM_DEVICE_TYPE_OTP) 433 ? "OTP" : "EEPROM", eeprom_ver); 434 for (ofs = 0 ; ofs < eeprom_len ; ofs += 16) { 435 pos += scnprintf(buf + pos, buf_size - pos, "0x%.4x ", ofs); 436 hex_dump_to_buffer(ptr + ofs, 16 , 16, 2, buf + pos, 437 buf_size - pos, 0); 438 pos += strlen(buf + pos); 439 if (buf_size - pos > 0) 440 buf[pos++] = '\n'; 441 } 442 443 ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos); 444 kfree(buf); 445 return ret; 446} 447 448static ssize_t iwl_dbgfs_channels_read(struct file *file, char __user *user_buf, 449 size_t count, loff_t *ppos) 450{ 451 struct iwl_priv *priv = file->private_data; 452 struct ieee80211_channel *channels = NULL; 453 const struct ieee80211_supported_band *supp_band = NULL; 454 int pos = 0, i, bufsz = PAGE_SIZE; 455 char *buf; 456 ssize_t ret; 457 458 if (!test_bit(STATUS_GEO_CONFIGURED, &priv->shrd->status)) 459 return -EAGAIN; 460 461 buf = kzalloc(bufsz, GFP_KERNEL); 462 if (!buf) { 463 IWL_ERR(priv, "Can not allocate Buffer\n"); 464 return -ENOMEM; 465 } 466 467 supp_band = iwl_get_hw_mode(priv, IEEE80211_BAND_2GHZ); 468 if (supp_band) { 469 channels = supp_band->channels; 470 471 pos += scnprintf(buf + pos, bufsz - pos, 472 "Displaying %d channels in 2.4GHz band 802.11bg):\n", 473 supp_band->n_channels); 474 475 for (i = 0; i < supp_band->n_channels; i++) 476 pos += scnprintf(buf + pos, bufsz - pos, 477 "%d: %ddBm: BSS%s%s, %s.\n", 478 channels[i].hw_value, 479 channels[i].max_power, 480 channels[i].flags & IEEE80211_CHAN_RADAR ? 481 " (IEEE 802.11h required)" : "", 482 ((channels[i].flags & IEEE80211_CHAN_NO_IBSS) 483 || (channels[i].flags & 484 IEEE80211_CHAN_RADAR)) ? "" : 485 ", IBSS", 486 channels[i].flags & 487 IEEE80211_CHAN_PASSIVE_SCAN ? 488 "passive only" : "active/passive"); 489 } 490 supp_band = iwl_get_hw_mode(priv, IEEE80211_BAND_5GHZ); 491 if (supp_band) { 492 channels = supp_band->channels; 493 494 pos += scnprintf(buf + pos, bufsz - pos, 495 "Displaying %d channels in 5.2GHz band (802.11a)\n", 496 supp_band->n_channels); 497 498 for (i = 0; i < supp_band->n_channels; i++) 499 pos += scnprintf(buf + pos, bufsz - pos, 500 "%d: %ddBm: BSS%s%s, %s.\n", 501 channels[i].hw_value, 502 channels[i].max_power, 503 channels[i].flags & IEEE80211_CHAN_RADAR ? 504 " (IEEE 802.11h required)" : "", 505 ((channels[i].flags & IEEE80211_CHAN_NO_IBSS) 506 || (channels[i].flags & 507 IEEE80211_CHAN_RADAR)) ? "" : 508 ", IBSS", 509 channels[i].flags & 510 IEEE80211_CHAN_PASSIVE_SCAN ? 511 "passive only" : "active/passive"); 512 } 513 ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos); 514 kfree(buf); 515 return ret; 516} 517 518static ssize_t iwl_dbgfs_status_read(struct file *file, 519 char __user *user_buf, 520 size_t count, loff_t *ppos) { 521 522 struct iwl_priv *priv = file->private_data; 523 char buf[512]; 524 int pos = 0; 525 const size_t bufsz = sizeof(buf); 526 527 pos += scnprintf(buf + pos, bufsz - pos, "STATUS_HCMD_ACTIVE:\t %d\n", 528 test_bit(STATUS_HCMD_ACTIVE, &priv->shrd->status)); 529 pos += scnprintf(buf + pos, bufsz - pos, "STATUS_INT_ENABLED:\t %d\n", 530 test_bit(STATUS_INT_ENABLED, &priv->shrd->status)); 531 pos += scnprintf(buf + pos, bufsz - pos, "STATUS_RF_KILL_HW:\t %d\n", 532 test_bit(STATUS_RF_KILL_HW, &priv->shrd->status)); 533 pos += scnprintf(buf + pos, bufsz - pos, "STATUS_CT_KILL:\t\t %d\n", 534 test_bit(STATUS_CT_KILL, &priv->shrd->status)); 535 pos += scnprintf(buf + pos, bufsz - pos, "STATUS_INIT:\t\t %d\n", 536 test_bit(STATUS_INIT, &priv->shrd->status)); 537 pos += scnprintf(buf + pos, bufsz - pos, "STATUS_ALIVE:\t\t %d\n", 538 test_bit(STATUS_ALIVE, &priv->shrd->status)); 539 pos += scnprintf(buf + pos, bufsz - pos, "STATUS_READY:\t\t %d\n", 540 test_bit(STATUS_READY, &priv->shrd->status)); 541 pos += scnprintf(buf + pos, bufsz - pos, "STATUS_TEMPERATURE:\t %d\n", 542 test_bit(STATUS_TEMPERATURE, &priv->shrd->status)); 543 pos += scnprintf(buf + pos, bufsz - pos, "STATUS_GEO_CONFIGURED:\t %d\n", 544 test_bit(STATUS_GEO_CONFIGURED, &priv->shrd->status)); 545 pos += scnprintf(buf + pos, bufsz - pos, "STATUS_EXIT_PENDING:\t %d\n", 546 test_bit(STATUS_EXIT_PENDING, &priv->shrd->status)); 547 pos += scnprintf(buf + pos, bufsz - pos, "STATUS_STATISTICS:\t %d\n", 548 test_bit(STATUS_STATISTICS, &priv->shrd->status)); 549 pos += scnprintf(buf + pos, bufsz - pos, "STATUS_SCANNING:\t %d\n", 550 test_bit(STATUS_SCANNING, &priv->shrd->status)); 551 pos += scnprintf(buf + pos, bufsz - pos, "STATUS_SCAN_ABORTING:\t %d\n", 552 test_bit(STATUS_SCAN_ABORTING, &priv->shrd->status)); 553 pos += scnprintf(buf + pos, bufsz - pos, "STATUS_SCAN_HW:\t\t %d\n", 554 test_bit(STATUS_SCAN_HW, &priv->shrd->status)); 555 pos += scnprintf(buf + pos, bufsz - pos, "STATUS_POWER_PMI:\t %d\n", 556 test_bit(STATUS_POWER_PMI, &priv->shrd->status)); 557 pos += scnprintf(buf + pos, bufsz - pos, "STATUS_FW_ERROR:\t %d\n", 558 test_bit(STATUS_FW_ERROR, &priv->shrd->status)); 559 return simple_read_from_buffer(user_buf, count, ppos, buf, pos); 560} 561 562static ssize_t iwl_dbgfs_rx_handlers_read(struct file *file, 563 char __user *user_buf, 564 size_t count, loff_t *ppos) { 565 566 struct iwl_priv *priv = file->private_data; 567 568 int pos = 0; 569 int cnt = 0; 570 char *buf; 571 int bufsz = 24 * 64; /* 24 items * 64 char per item */ 572 ssize_t ret; 573 574 buf = kzalloc(bufsz, GFP_KERNEL); 575 if (!buf) { 576 IWL_ERR(priv, "Can not allocate Buffer\n"); 577 return -ENOMEM; 578 } 579 580 for (cnt = 0; cnt < REPLY_MAX; cnt++) { 581 if (priv->rx_handlers_stats[cnt] > 0) 582 pos += scnprintf(buf + pos, bufsz - pos, 583 "\tRx handler[%36s]:\t\t %u\n", 584 get_cmd_string(cnt), 585 priv->rx_handlers_stats[cnt]); 586 } 587 588 ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos); 589 kfree(buf); 590 return ret; 591} 592 593static ssize_t iwl_dbgfs_rx_handlers_write(struct file *file, 594 const char __user *user_buf, 595 size_t count, loff_t *ppos) 596{ 597 struct iwl_priv *priv = file->private_data; 598 599 char buf[8]; 600 int buf_size; 601 u32 reset_flag; 602 603 memset(buf, 0, sizeof(buf)); 604 buf_size = min(count, sizeof(buf) - 1); 605 if (copy_from_user(buf, user_buf, buf_size)) 606 return -EFAULT; 607 if (sscanf(buf, "%x", &reset_flag) != 1) 608 return -EFAULT; 609 if (reset_flag == 0) 610 memset(&priv->rx_handlers_stats[0], 0, 611 sizeof(priv->rx_handlers_stats)); 612 613 return count; 614} 615 616static ssize_t iwl_dbgfs_qos_read(struct file *file, char __user *user_buf, 617 size_t count, loff_t *ppos) 618{ 619 struct iwl_priv *priv = file->private_data; 620 struct iwl_rxon_context *ctx; 621 int pos = 0, i; 622 char buf[256 * NUM_IWL_RXON_CTX]; 623 const size_t bufsz = sizeof(buf); 624 625 for_each_context(priv, ctx) { 626 pos += scnprintf(buf + pos, bufsz - pos, "context %d:\n", 627 ctx->ctxid); 628 for (i = 0; i < AC_NUM; i++) { 629 pos += scnprintf(buf + pos, bufsz - pos, 630 "\tcw_min\tcw_max\taifsn\ttxop\n"); 631 pos += scnprintf(buf + pos, bufsz - pos, 632 "AC[%d]\t%u\t%u\t%u\t%u\n", i, 633 ctx->qos_data.def_qos_parm.ac[i].cw_min, 634 ctx->qos_data.def_qos_parm.ac[i].cw_max, 635 ctx->qos_data.def_qos_parm.ac[i].aifsn, 636 ctx->qos_data.def_qos_parm.ac[i].edca_txop); 637 } 638 pos += scnprintf(buf + pos, bufsz - pos, "\n"); 639 } 640 return simple_read_from_buffer(user_buf, count, ppos, buf, pos); 641} 642 643static ssize_t iwl_dbgfs_thermal_throttling_read(struct file *file, 644 char __user *user_buf, 645 size_t count, loff_t *ppos) 646{ 647 struct iwl_priv *priv = file->private_data; 648 struct iwl_tt_mgmt *tt = &priv->thermal_throttle; 649 struct iwl_tt_restriction *restriction; 650 char buf[100]; 651 int pos = 0; 652 const size_t bufsz = sizeof(buf); 653 654 pos += scnprintf(buf + pos, bufsz - pos, 655 "Thermal Throttling Mode: %s\n", 656 tt->advanced_tt ? "Advance" : "Legacy"); 657 pos += scnprintf(buf + pos, bufsz - pos, 658 "Thermal Throttling State: %d\n", 659 tt->state); 660 if (tt->advanced_tt) { 661 restriction = tt->restriction + tt->state; 662 pos += scnprintf(buf + pos, bufsz - pos, 663 "Tx mode: %d\n", 664 restriction->tx_stream); 665 pos += scnprintf(buf + pos, bufsz - pos, 666 "Rx mode: %d\n", 667 restriction->rx_stream); 668 pos += scnprintf(buf + pos, bufsz - pos, 669 "HT mode: %d\n", 670 restriction->is_ht); 671 } 672 return simple_read_from_buffer(user_buf, count, ppos, buf, pos); 673} 674 675static ssize_t iwl_dbgfs_disable_ht40_write(struct file *file, 676 const char __user *user_buf, 677 size_t count, loff_t *ppos) 678{ 679 struct iwl_priv *priv = file->private_data; 680 char buf[8]; 681 int buf_size; 682 int ht40; 683 684 memset(buf, 0, sizeof(buf)); 685 buf_size = min(count, sizeof(buf) - 1); 686 if (copy_from_user(buf, user_buf, buf_size)) 687 return -EFAULT; 688 if (sscanf(buf, "%d", &ht40) != 1) 689 return -EFAULT; 690 if (!iwl_is_any_associated(priv)) 691 priv->disable_ht40 = ht40 ? true : false; 692 else { 693 IWL_ERR(priv, "Sta associated with AP - " 694 "Change to 40MHz channel support is not allowed\n"); 695 return -EINVAL; 696 } 697 698 return count; 699} 700 701static ssize_t iwl_dbgfs_disable_ht40_read(struct file *file, 702 char __user *user_buf, 703 size_t count, loff_t *ppos) 704{ 705 struct iwl_priv *priv = file->private_data; 706 char buf[100]; 707 int pos = 0; 708 const size_t bufsz = sizeof(buf); 709 710 pos += scnprintf(buf + pos, bufsz - pos, 711 "11n 40MHz Mode: %s\n", 712 priv->disable_ht40 ? "Disabled" : "Enabled"); 713 return simple_read_from_buffer(user_buf, count, ppos, buf, pos); 714} 715 716static ssize_t iwl_dbgfs_temperature_read(struct file *file, 717 char __user *user_buf, 718 size_t count, loff_t *ppos) 719{ 720 struct iwl_priv *priv = file->private_data; 721 char buf[8]; 722 int pos = 0; 723 const size_t bufsz = sizeof(buf); 724 725 pos += scnprintf(buf + pos, bufsz - pos, "%d\n", priv->temperature); 726 return simple_read_from_buffer(user_buf, count, ppos, buf, pos); 727} 728 729 730static ssize_t iwl_dbgfs_sleep_level_override_write(struct file *file, 731 const char __user *user_buf, 732 size_t count, loff_t *ppos) 733{ 734 struct iwl_priv *priv = file->private_data; 735 char buf[8]; 736 int buf_size; 737 int value; 738 739 memset(buf, 0, sizeof(buf)); 740 buf_size = min(count, sizeof(buf) - 1); 741 if (copy_from_user(buf, user_buf, buf_size)) 742 return -EFAULT; 743 744 if (sscanf(buf, "%d", &value) != 1) 745 return -EINVAL; 746 747 /* 748 * Our users expect 0 to be "CAM", but 0 isn't actually 749 * valid here. However, let's not confuse them and present 750 * IWL_POWER_INDEX_1 as "1", not "0". 751 */ 752 if (value == 0) 753 return -EINVAL; 754 else if (value > 0) 755 value -= 1; 756 757 if (value != -1 && (value < 0 || value >= IWL_POWER_NUM)) 758 return -EINVAL; 759 760 if (!iwl_is_ready_rf(priv->shrd)) 761 return -EAGAIN; 762 763 priv->power_data.debug_sleep_level_override = value; 764 765 mutex_lock(&priv->shrd->mutex); 766 iwl_power_update_mode(priv, true); 767 mutex_unlock(&priv->shrd->mutex); 768 769 return count; 770} 771 772static ssize_t iwl_dbgfs_sleep_level_override_read(struct file *file, 773 char __user *user_buf, 774 size_t count, loff_t *ppos) 775{ 776 struct iwl_priv *priv = file->private_data; 777 char buf[10]; 778 int pos, value; 779 const size_t bufsz = sizeof(buf); 780 781 /* see the write function */ 782 value = priv->power_data.debug_sleep_level_override; 783 if (value >= 0) 784 value += 1; 785 786 pos = scnprintf(buf, bufsz, "%d\n", value); 787 return simple_read_from_buffer(user_buf, count, ppos, buf, pos); 788} 789 790static ssize_t iwl_dbgfs_current_sleep_command_read(struct file *file, 791 char __user *user_buf, 792 size_t count, loff_t *ppos) 793{ 794 struct iwl_priv *priv = file->private_data; 795 char buf[200]; 796 int pos = 0, i; 797 const size_t bufsz = sizeof(buf); 798 struct iwl_powertable_cmd *cmd = &priv->power_data.sleep_cmd; 799 800 pos += scnprintf(buf + pos, bufsz - pos, 801 "flags: %#.2x\n", le16_to_cpu(cmd->flags)); 802 pos += scnprintf(buf + pos, bufsz - pos, 803 "RX/TX timeout: %d/%d usec\n", 804 le32_to_cpu(cmd->rx_data_timeout), 805 le32_to_cpu(cmd->tx_data_timeout)); 806 for (i = 0; i < IWL_POWER_VEC_SIZE; i++) 807 pos += scnprintf(buf + pos, bufsz - pos, 808 "sleep_interval[%d]: %d\n", i, 809 le32_to_cpu(cmd->sleep_interval[i])); 810 811 return simple_read_from_buffer(user_buf, count, ppos, buf, pos); 812} 813 814DEBUGFS_READ_WRITE_FILE_OPS(sram); 815DEBUGFS_READ_FILE_OPS(wowlan_sram); 816DEBUGFS_READ_FILE_OPS(nvm); 817DEBUGFS_READ_FILE_OPS(stations); 818DEBUGFS_READ_FILE_OPS(channels); 819DEBUGFS_READ_FILE_OPS(status); 820DEBUGFS_READ_WRITE_FILE_OPS(rx_handlers); 821DEBUGFS_READ_FILE_OPS(qos); 822DEBUGFS_READ_FILE_OPS(thermal_throttling); 823DEBUGFS_READ_WRITE_FILE_OPS(disable_ht40); 824DEBUGFS_READ_FILE_OPS(temperature); 825DEBUGFS_READ_WRITE_FILE_OPS(sleep_level_override); 826DEBUGFS_READ_FILE_OPS(current_sleep_command); 827 828static ssize_t iwl_dbgfs_traffic_log_read(struct file *file, 829 char __user *user_buf, 830 size_t count, loff_t *ppos) 831{ 832 struct iwl_priv *priv = file->private_data; 833 int pos = 0, ofs = 0; 834 int cnt = 0, entry; 835 836 char *buf; 837 int bufsz = ((IWL_TRAFFIC_ENTRIES * IWL_TRAFFIC_ENTRY_SIZE * 64) * 2) + 838 (hw_params(priv).max_txq_num * 32 * 8) + 400; 839 const u8 *ptr; 840 ssize_t ret; 841 842 buf = kzalloc(bufsz, GFP_KERNEL); 843 if (!buf) { 844 IWL_ERR(priv, "Can not allocate buffer\n"); 845 return -ENOMEM; 846 } 847 if (priv->tx_traffic && iwl_have_debug_level(IWL_DL_TX)) { 848 ptr = priv->tx_traffic; 849 pos += scnprintf(buf + pos, bufsz - pos, 850 "Tx Traffic idx: %u\n", priv->tx_traffic_idx); 851 for (cnt = 0, ofs = 0; cnt < IWL_TRAFFIC_ENTRIES; cnt++) { 852 for (entry = 0; entry < IWL_TRAFFIC_ENTRY_SIZE / 16; 853 entry++, ofs += 16) { 854 pos += scnprintf(buf + pos, bufsz - pos, 855 "0x%.4x ", ofs); 856 hex_dump_to_buffer(ptr + ofs, 16, 16, 2, 857 buf + pos, bufsz - pos, 0); 858 pos += strlen(buf + pos); 859 if (bufsz - pos > 0) 860 buf[pos++] = '\n'; 861 } 862 } 863 } 864 865 if (priv->rx_traffic && iwl_have_debug_level(IWL_DL_RX)) { 866 ptr = priv->rx_traffic; 867 pos += scnprintf(buf + pos, bufsz - pos, 868 "Rx Traffic idx: %u\n", priv->rx_traffic_idx); 869 for (cnt = 0, ofs = 0; cnt < IWL_TRAFFIC_ENTRIES; cnt++) { 870 for (entry = 0; entry < IWL_TRAFFIC_ENTRY_SIZE / 16; 871 entry++, ofs += 16) { 872 pos += scnprintf(buf + pos, bufsz - pos, 873 "0x%.4x ", ofs); 874 hex_dump_to_buffer(ptr + ofs, 16, 16, 2, 875 buf + pos, bufsz - pos, 0); 876 pos += strlen(buf + pos); 877 if (bufsz - pos > 0) 878 buf[pos++] = '\n'; 879 } 880 } 881 } 882 883 ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos); 884 kfree(buf); 885 return ret; 886} 887 888static ssize_t iwl_dbgfs_traffic_log_write(struct file *file, 889 const char __user *user_buf, 890 size_t count, loff_t *ppos) 891{ 892 struct iwl_priv *priv = file->private_data; 893 char buf[8]; 894 int buf_size; 895 int traffic_log; 896 897 memset(buf, 0, sizeof(buf)); 898 buf_size = min(count, sizeof(buf) - 1); 899 if (copy_from_user(buf, user_buf, buf_size)) 900 return -EFAULT; 901 if (sscanf(buf, "%d", &traffic_log) != 1) 902 return -EFAULT; 903 if (traffic_log == 0) 904 iwl_reset_traffic_log(priv); 905 906 return count; 907} 908 909static const char *fmt_value = " %-30s %10u\n"; 910static const char *fmt_hex = " %-30s 0x%02X\n"; 911static const char *fmt_table = " %-30s %10u %10u %10u %10u\n"; 912static const char *fmt_header = 913 "%-32s current cumulative delta max\n"; 914 915static int iwl_statistics_flag(struct iwl_priv *priv, char *buf, int bufsz) 916{ 917 int p = 0; 918 u32 flag; 919 920 lockdep_assert_held(&priv->statistics.lock); 921 922 flag = le32_to_cpu(priv->statistics.flag); 923 924 p += scnprintf(buf + p, bufsz - p, "Statistics Flag(0x%X):\n", flag); 925 if (flag & UCODE_STATISTICS_CLEAR_MSK) 926 p += scnprintf(buf + p, bufsz - p, 927 "\tStatistics have been cleared\n"); 928 p += scnprintf(buf + p, bufsz - p, "\tOperational Frequency: %s\n", 929 (flag & UCODE_STATISTICS_FREQUENCY_MSK) 930 ? "2.4 GHz" : "5.2 GHz"); 931 p += scnprintf(buf + p, bufsz - p, "\tTGj Narrow Band: %s\n", 932 (flag & UCODE_STATISTICS_NARROW_BAND_MSK) 933 ? "enabled" : "disabled"); 934 935 return p; 936} 937 938static ssize_t iwl_dbgfs_ucode_rx_stats_read(struct file *file, 939 char __user *user_buf, 940 size_t count, loff_t *ppos) 941{ 942 struct iwl_priv *priv = file->private_data; 943 int pos = 0; 944 char *buf; 945 int bufsz = sizeof(struct statistics_rx_phy) * 40 + 946 sizeof(struct statistics_rx_non_phy) * 40 + 947 sizeof(struct statistics_rx_ht_phy) * 40 + 400; 948 ssize_t ret; 949 struct statistics_rx_phy *ofdm, *accum_ofdm, *delta_ofdm, *max_ofdm; 950 struct statistics_rx_phy *cck, *accum_cck, *delta_cck, *max_cck; 951 struct statistics_rx_non_phy *general, *accum_general; 952 struct statistics_rx_non_phy *delta_general, *max_general; 953 struct statistics_rx_ht_phy *ht, *accum_ht, *delta_ht, *max_ht; 954 955 if (!iwl_is_alive(priv->shrd)) 956 return -EAGAIN; 957 958 buf = kzalloc(bufsz, GFP_KERNEL); 959 if (!buf) { 960 IWL_ERR(priv, "Can not allocate Buffer\n"); 961 return -ENOMEM; 962 } 963 964 /* 965 * the statistic information display here is based on 966 * the last statistics notification from uCode 967 * might not reflect the current uCode activity 968 */ 969 spin_lock_bh(&priv->statistics.lock); 970 ofdm = &priv->statistics.rx_ofdm; 971 cck = &priv->statistics.rx_cck; 972 general = &priv->statistics.rx_non_phy; 973 ht = &priv->statistics.rx_ofdm_ht; 974 accum_ofdm = &priv->accum_stats.rx_ofdm; 975 accum_cck = &priv->accum_stats.rx_cck; 976 accum_general = &priv->accum_stats.rx_non_phy; 977 accum_ht = &priv->accum_stats.rx_ofdm_ht; 978 delta_ofdm = &priv->delta_stats.rx_ofdm; 979 delta_cck = &priv->delta_stats.rx_cck; 980 delta_general = &priv->delta_stats.rx_non_phy; 981 delta_ht = &priv->delta_stats.rx_ofdm_ht; 982 max_ofdm = &priv->max_delta_stats.rx_ofdm; 983 max_cck = &priv->max_delta_stats.rx_cck; 984 max_general = &priv->max_delta_stats.rx_non_phy; 985 max_ht = &priv->max_delta_stats.rx_ofdm_ht; 986 987 pos += iwl_statistics_flag(priv, buf, bufsz); 988 pos += scnprintf(buf + pos, bufsz - pos, 989 fmt_header, "Statistics_Rx - OFDM:"); 990 pos += scnprintf(buf + pos, bufsz - pos, 991 fmt_table, "ina_cnt:", 992 le32_to_cpu(ofdm->ina_cnt), 993 accum_ofdm->ina_cnt, 994 delta_ofdm->ina_cnt, max_ofdm->ina_cnt); 995 pos += scnprintf(buf + pos, bufsz - pos, 996 fmt_table, "fina_cnt:", 997 le32_to_cpu(ofdm->fina_cnt), accum_ofdm->fina_cnt, 998 delta_ofdm->fina_cnt, max_ofdm->fina_cnt); 999 pos += scnprintf(buf + pos, bufsz - pos, 1000 fmt_table, "plcp_err:", 1001 le32_to_cpu(ofdm->plcp_err), accum_ofdm->plcp_err, 1002 delta_ofdm->plcp_err, max_ofdm->plcp_err); 1003 pos += scnprintf(buf + pos, bufsz - pos, 1004 fmt_table, "crc32_err:", 1005 le32_to_cpu(ofdm->crc32_err), accum_ofdm->crc32_err, 1006 delta_ofdm->crc32_err, max_ofdm->crc32_err); 1007 pos += scnprintf(buf + pos, bufsz - pos, 1008 fmt_table, "overrun_err:", 1009 le32_to_cpu(ofdm->overrun_err), 1010 accum_ofdm->overrun_err, delta_ofdm->overrun_err, 1011 max_ofdm->overrun_err); 1012 pos += scnprintf(buf + pos, bufsz - pos, 1013 fmt_table, "early_overrun_err:", 1014 le32_to_cpu(ofdm->early_overrun_err), 1015 accum_ofdm->early_overrun_err, 1016 delta_ofdm->early_overrun_err, 1017 max_ofdm->early_overrun_err); 1018 pos += scnprintf(buf + pos, bufsz - pos, 1019 fmt_table, "crc32_good:", 1020 le32_to_cpu(ofdm->crc32_good), 1021 accum_ofdm->crc32_good, delta_ofdm->crc32_good, 1022 max_ofdm->crc32_good); 1023 pos += scnprintf(buf + pos, bufsz - pos, 1024 fmt_table, "false_alarm_cnt:", 1025 le32_to_cpu(ofdm->false_alarm_cnt), 1026 accum_ofdm->false_alarm_cnt, 1027 delta_ofdm->false_alarm_cnt, 1028 max_ofdm->false_alarm_cnt); 1029 pos += scnprintf(buf + pos, bufsz - pos, 1030 fmt_table, "fina_sync_err_cnt:", 1031 le32_to_cpu(ofdm->fina_sync_err_cnt), 1032 accum_ofdm->fina_sync_err_cnt, 1033 delta_ofdm->fina_sync_err_cnt, 1034 max_ofdm->fina_sync_err_cnt); 1035 pos += scnprintf(buf + pos, bufsz - pos, 1036 fmt_table, "sfd_timeout:", 1037 le32_to_cpu(ofdm->sfd_timeout), 1038 accum_ofdm->sfd_timeout, delta_ofdm->sfd_timeout, 1039 max_ofdm->sfd_timeout); 1040 pos += scnprintf(buf + pos, bufsz - pos, 1041 fmt_table, "fina_timeout:", 1042 le32_to_cpu(ofdm->fina_timeout), 1043 accum_ofdm->fina_timeout, delta_ofdm->fina_timeout, 1044 max_ofdm->fina_timeout); 1045 pos += scnprintf(buf + pos, bufsz - pos, 1046 fmt_table, "unresponded_rts:", 1047 le32_to_cpu(ofdm->unresponded_rts), 1048 accum_ofdm->unresponded_rts, 1049 delta_ofdm->unresponded_rts, 1050 max_ofdm->unresponded_rts); 1051 pos += scnprintf(buf + pos, bufsz - pos, 1052 fmt_table, "rxe_frame_lmt_ovrun:", 1053 le32_to_cpu(ofdm->rxe_frame_limit_overrun), 1054 accum_ofdm->rxe_frame_limit_overrun, 1055 delta_ofdm->rxe_frame_limit_overrun, 1056 max_ofdm->rxe_frame_limit_overrun); 1057 pos += scnprintf(buf + pos, bufsz - pos, 1058 fmt_table, "sent_ack_cnt:", 1059 le32_to_cpu(ofdm->sent_ack_cnt), 1060 accum_ofdm->sent_ack_cnt, delta_ofdm->sent_ack_cnt, 1061 max_ofdm->sent_ack_cnt); 1062 pos += scnprintf(buf + pos, bufsz - pos, 1063 fmt_table, "sent_cts_cnt:", 1064 le32_to_cpu(ofdm->sent_cts_cnt), 1065 accum_ofdm->sent_cts_cnt, delta_ofdm->sent_cts_cnt, 1066 max_ofdm->sent_cts_cnt); 1067 pos += scnprintf(buf + pos, bufsz - pos, 1068 fmt_table, "sent_ba_rsp_cnt:", 1069 le32_to_cpu(ofdm->sent_ba_rsp_cnt), 1070 accum_ofdm->sent_ba_rsp_cnt, 1071 delta_ofdm->sent_ba_rsp_cnt, 1072 max_ofdm->sent_ba_rsp_cnt); 1073 pos += scnprintf(buf + pos, bufsz - pos, 1074 fmt_table, "dsp_self_kill:", 1075 le32_to_cpu(ofdm->dsp_self_kill), 1076 accum_ofdm->dsp_self_kill, 1077 delta_ofdm->dsp_self_kill, 1078 max_ofdm->dsp_self_kill); 1079 pos += scnprintf(buf + pos, bufsz - pos, 1080 fmt_table, "mh_format_err:", 1081 le32_to_cpu(ofdm->mh_format_err), 1082 accum_ofdm->mh_format_err, 1083 delta_ofdm->mh_format_err, 1084 max_ofdm->mh_format_err); 1085 pos += scnprintf(buf + pos, bufsz - pos, 1086 fmt_table, "re_acq_main_rssi_sum:", 1087 le32_to_cpu(ofdm->re_acq_main_rssi_sum), 1088 accum_ofdm->re_acq_main_rssi_sum, 1089 delta_ofdm->re_acq_main_rssi_sum, 1090 max_ofdm->re_acq_main_rssi_sum); 1091 1092 pos += scnprintf(buf + pos, bufsz - pos, 1093 fmt_header, "Statistics_Rx - CCK:"); 1094 pos += scnprintf(buf + pos, bufsz - pos, 1095 fmt_table, "ina_cnt:", 1096 le32_to_cpu(cck->ina_cnt), accum_cck->ina_cnt, 1097 delta_cck->ina_cnt, max_cck->ina_cnt); 1098 pos += scnprintf(buf + pos, bufsz - pos, 1099 fmt_table, "fina_cnt:", 1100 le32_to_cpu(cck->fina_cnt), accum_cck->fina_cnt, 1101 delta_cck->fina_cnt, max_cck->fina_cnt); 1102 pos += scnprintf(buf + pos, bufsz - pos, 1103 fmt_table, "plcp_err:", 1104 le32_to_cpu(cck->plcp_err), accum_cck->plcp_err, 1105 delta_cck->plcp_err, max_cck->plcp_err); 1106 pos += scnprintf(buf + pos, bufsz - pos, 1107 fmt_table, "crc32_err:", 1108 le32_to_cpu(cck->crc32_err), accum_cck->crc32_err, 1109 delta_cck->crc32_err, max_cck->crc32_err); 1110 pos += scnprintf(buf + pos, bufsz - pos, 1111 fmt_table, "overrun_err:", 1112 le32_to_cpu(cck->overrun_err), 1113 accum_cck->overrun_err, delta_cck->overrun_err, 1114 max_cck->overrun_err); 1115 pos += scnprintf(buf + pos, bufsz - pos, 1116 fmt_table, "early_overrun_err:", 1117 le32_to_cpu(cck->early_overrun_err), 1118 accum_cck->early_overrun_err, 1119 delta_cck->early_overrun_err, 1120 max_cck->early_overrun_err); 1121 pos += scnprintf(buf + pos, bufsz - pos, 1122 fmt_table, "crc32_good:", 1123 le32_to_cpu(cck->crc32_good), accum_cck->crc32_good, 1124 delta_cck->crc32_good, max_cck->crc32_good); 1125 pos += scnprintf(buf + pos, bufsz - pos, 1126 fmt_table, "false_alarm_cnt:", 1127 le32_to_cpu(cck->false_alarm_cnt), 1128 accum_cck->false_alarm_cnt, 1129 delta_cck->false_alarm_cnt, max_cck->false_alarm_cnt); 1130 pos += scnprintf(buf + pos, bufsz - pos, 1131 fmt_table, "fina_sync_err_cnt:", 1132 le32_to_cpu(cck->fina_sync_err_cnt), 1133 accum_cck->fina_sync_err_cnt, 1134 delta_cck->fina_sync_err_cnt, 1135 max_cck->fina_sync_err_cnt); 1136 pos += scnprintf(buf + pos, bufsz - pos, 1137 fmt_table, "sfd_timeout:", 1138 le32_to_cpu(cck->sfd_timeout), 1139 accum_cck->sfd_timeout, delta_cck->sfd_timeout, 1140 max_cck->sfd_timeout); 1141 pos += scnprintf(buf + pos, bufsz - pos, 1142 fmt_table, "fina_timeout:", 1143 le32_to_cpu(cck->fina_timeout), 1144 accum_cck->fina_timeout, delta_cck->fina_timeout, 1145 max_cck->fina_timeout); 1146 pos += scnprintf(buf + pos, bufsz - pos, 1147 fmt_table, "unresponded_rts:", 1148 le32_to_cpu(cck->unresponded_rts), 1149 accum_cck->unresponded_rts, delta_cck->unresponded_rts, 1150 max_cck->unresponded_rts); 1151 pos += scnprintf(buf + pos, bufsz - pos, 1152 fmt_table, "rxe_frame_lmt_ovrun:", 1153 le32_to_cpu(cck->rxe_frame_limit_overrun), 1154 accum_cck->rxe_frame_limit_overrun, 1155 delta_cck->rxe_frame_limit_overrun, 1156 max_cck->rxe_frame_limit_overrun); 1157 pos += scnprintf(buf + pos, bufsz - pos, 1158 fmt_table, "sent_ack_cnt:", 1159 le32_to_cpu(cck->sent_ack_cnt), 1160 accum_cck->sent_ack_cnt, delta_cck->sent_ack_cnt, 1161 max_cck->sent_ack_cnt); 1162 pos += scnprintf(buf + pos, bufsz - pos, 1163 fmt_table, "sent_cts_cnt:", 1164 le32_to_cpu(cck->sent_cts_cnt), 1165 accum_cck->sent_cts_cnt, delta_cck->sent_cts_cnt, 1166 max_cck->sent_cts_cnt); 1167 pos += scnprintf(buf + pos, bufsz - pos, 1168 fmt_table, "sent_ba_rsp_cnt:", 1169 le32_to_cpu(cck->sent_ba_rsp_cnt), 1170 accum_cck->sent_ba_rsp_cnt, 1171 delta_cck->sent_ba_rsp_cnt, 1172 max_cck->sent_ba_rsp_cnt); 1173 pos += scnprintf(buf + pos, bufsz - pos, 1174 fmt_table, "dsp_self_kill:", 1175 le32_to_cpu(cck->dsp_self_kill), 1176 accum_cck->dsp_self_kill, delta_cck->dsp_self_kill, 1177 max_cck->dsp_self_kill); 1178 pos += scnprintf(buf + pos, bufsz - pos, 1179 fmt_table, "mh_format_err:", 1180 le32_to_cpu(cck->mh_format_err), 1181 accum_cck->mh_format_err, delta_cck->mh_format_err, 1182 max_cck->mh_format_err); 1183 pos += scnprintf(buf + pos, bufsz - pos, 1184 fmt_table, "re_acq_main_rssi_sum:", 1185 le32_to_cpu(cck->re_acq_main_rssi_sum), 1186 accum_cck->re_acq_main_rssi_sum, 1187 delta_cck->re_acq_main_rssi_sum, 1188 max_cck->re_acq_main_rssi_sum); 1189 1190 pos += scnprintf(buf + pos, bufsz - pos, 1191 fmt_header, "Statistics_Rx - GENERAL:"); 1192 pos += scnprintf(buf + pos, bufsz - pos, 1193 fmt_table, "bogus_cts:", 1194 le32_to_cpu(general->bogus_cts), 1195 accum_general->bogus_cts, delta_general->bogus_cts, 1196 max_general->bogus_cts); 1197 pos += scnprintf(buf + pos, bufsz - pos, 1198 fmt_table, "bogus_ack:", 1199 le32_to_cpu(general->bogus_ack), 1200 accum_general->bogus_ack, delta_general->bogus_ack, 1201 max_general->bogus_ack); 1202 pos += scnprintf(buf + pos, bufsz - pos, 1203 fmt_table, "non_bssid_frames:", 1204 le32_to_cpu(general->non_bssid_frames), 1205 accum_general->non_bssid_frames, 1206 delta_general->non_bssid_frames, 1207 max_general->non_bssid_frames); 1208 pos += scnprintf(buf + pos, bufsz - pos, 1209 fmt_table, "filtered_frames:", 1210 le32_to_cpu(general->filtered_frames), 1211 accum_general->filtered_frames, 1212 delta_general->filtered_frames, 1213 max_general->filtered_frames); 1214 pos += scnprintf(buf + pos, bufsz - pos, 1215 fmt_table, "non_channel_beacons:", 1216 le32_to_cpu(general->non_channel_beacons), 1217 accum_general->non_channel_beacons, 1218 delta_general->non_channel_beacons, 1219 max_general->non_channel_beacons); 1220 pos += scnprintf(buf + pos, bufsz - pos, 1221 fmt_table, "channel_beacons:", 1222 le32_to_cpu(general->channel_beacons), 1223 accum_general->channel_beacons, 1224 delta_general->channel_beacons, 1225 max_general->channel_beacons); 1226 pos += scnprintf(buf + pos, bufsz - pos, 1227 fmt_table, "num_missed_bcon:", 1228 le32_to_cpu(general->num_missed_bcon), 1229 accum_general->num_missed_bcon, 1230 delta_general->num_missed_bcon, 1231 max_general->num_missed_bcon); 1232 pos += scnprintf(buf + pos, bufsz - pos, 1233 fmt_table, "adc_rx_saturation_time:", 1234 le32_to_cpu(general->adc_rx_saturation_time), 1235 accum_general->adc_rx_saturation_time, 1236 delta_general->adc_rx_saturation_time, 1237 max_general->adc_rx_saturation_time); 1238 pos += scnprintf(buf + pos, bufsz - pos, 1239 fmt_table, "ina_detect_search_tm:", 1240 le32_to_cpu(general->ina_detection_search_time), 1241 accum_general->ina_detection_search_time, 1242 delta_general->ina_detection_search_time, 1243 max_general->ina_detection_search_time); 1244 pos += scnprintf(buf + pos, bufsz - pos, 1245 fmt_table, "beacon_silence_rssi_a:", 1246 le32_to_cpu(general->beacon_silence_rssi_a), 1247 accum_general->beacon_silence_rssi_a, 1248 delta_general->beacon_silence_rssi_a, 1249 max_general->beacon_silence_rssi_a); 1250 pos += scnprintf(buf + pos, bufsz - pos, 1251 fmt_table, "beacon_silence_rssi_b:", 1252 le32_to_cpu(general->beacon_silence_rssi_b), 1253 accum_general->beacon_silence_rssi_b, 1254 delta_general->beacon_silence_rssi_b, 1255 max_general->beacon_silence_rssi_b); 1256 pos += scnprintf(buf + pos, bufsz - pos, 1257 fmt_table, "beacon_silence_rssi_c:", 1258 le32_to_cpu(general->beacon_silence_rssi_c), 1259 accum_general->beacon_silence_rssi_c, 1260 delta_general->beacon_silence_rssi_c, 1261 max_general->beacon_silence_rssi_c); 1262 pos += scnprintf(buf + pos, bufsz - pos, 1263 fmt_table, "interference_data_flag:", 1264 le32_to_cpu(general->interference_data_flag), 1265 accum_general->interference_data_flag, 1266 delta_general->interference_data_flag, 1267 max_general->interference_data_flag); 1268 pos += scnprintf(buf + pos, bufsz - pos, 1269 fmt_table, "channel_load:", 1270 le32_to_cpu(general->channel_load), 1271 accum_general->channel_load, 1272 delta_general->channel_load, 1273 max_general->channel_load); 1274 pos += scnprintf(buf + pos, bufsz - pos, 1275 fmt_table, "dsp_false_alarms:", 1276 le32_to_cpu(general->dsp_false_alarms), 1277 accum_general->dsp_false_alarms, 1278 delta_general->dsp_false_alarms, 1279 max_general->dsp_false_alarms); 1280 pos += scnprintf(buf + pos, bufsz - pos, 1281 fmt_table, "beacon_rssi_a:", 1282 le32_to_cpu(general->beacon_rssi_a), 1283 accum_general->beacon_rssi_a, 1284 delta_general->beacon_rssi_a, 1285 max_general->beacon_rssi_a); 1286 pos += scnprintf(buf + pos, bufsz - pos, 1287 fmt_table, "beacon_rssi_b:", 1288 le32_to_cpu(general->beacon_rssi_b), 1289 accum_general->beacon_rssi_b, 1290 delta_general->beacon_rssi_b, 1291 max_general->beacon_rssi_b); 1292 pos += scnprintf(buf + pos, bufsz - pos, 1293 fmt_table, "beacon_rssi_c:", 1294 le32_to_cpu(general->beacon_rssi_c), 1295 accum_general->beacon_rssi_c, 1296 delta_general->beacon_rssi_c, 1297 max_general->beacon_rssi_c); 1298 pos += scnprintf(buf + pos, bufsz - pos, 1299 fmt_table, "beacon_energy_a:", 1300 le32_to_cpu(general->beacon_energy_a), 1301 accum_general->beacon_energy_a, 1302 delta_general->beacon_energy_a, 1303 max_general->beacon_energy_a); 1304 pos += scnprintf(buf + pos, bufsz - pos, 1305 fmt_table, "beacon_energy_b:", 1306 le32_to_cpu(general->beacon_energy_b), 1307 accum_general->beacon_energy_b, 1308 delta_general->beacon_energy_b, 1309 max_general->beacon_energy_b); 1310 pos += scnprintf(buf + pos, bufsz - pos, 1311 fmt_table, "beacon_energy_c:", 1312 le32_to_cpu(general->beacon_energy_c), 1313 accum_general->beacon_energy_c, 1314 delta_general->beacon_energy_c, 1315 max_general->beacon_energy_c); 1316 1317 pos += scnprintf(buf + pos, bufsz - pos, 1318 fmt_header, "Statistics_Rx - OFDM_HT:"); 1319 pos += scnprintf(buf + pos, bufsz - pos, 1320 fmt_table, "plcp_err:", 1321 le32_to_cpu(ht->plcp_err), accum_ht->plcp_err, 1322 delta_ht->plcp_err, max_ht->plcp_err); 1323 pos += scnprintf(buf + pos, bufsz - pos, 1324 fmt_table, "overrun_err:", 1325 le32_to_cpu(ht->overrun_err), accum_ht->overrun_err, 1326 delta_ht->overrun_err, max_ht->overrun_err); 1327 pos += scnprintf(buf + pos, bufsz - pos, 1328 fmt_table, "early_overrun_err:", 1329 le32_to_cpu(ht->early_overrun_err), 1330 accum_ht->early_overrun_err, 1331 delta_ht->early_overrun_err, 1332 max_ht->early_overrun_err); 1333 pos += scnprintf(buf + pos, bufsz - pos, 1334 fmt_table, "crc32_good:", 1335 le32_to_cpu(ht->crc32_good), accum_ht->crc32_good, 1336 delta_ht->crc32_good, max_ht->crc32_good); 1337 pos += scnprintf(buf + pos, bufsz - pos, 1338 fmt_table, "crc32_err:", 1339 le32_to_cpu(ht->crc32_err), accum_ht->crc32_err, 1340 delta_ht->crc32_err, max_ht->crc32_err); 1341 pos += scnprintf(buf + pos, bufsz - pos, 1342 fmt_table, "mh_format_err:", 1343 le32_to_cpu(ht->mh_format_err), 1344 accum_ht->mh_format_err, 1345 delta_ht->mh_format_err, max_ht->mh_format_err); 1346 pos += scnprintf(buf + pos, bufsz - pos, 1347 fmt_table, "agg_crc32_good:", 1348 le32_to_cpu(ht->agg_crc32_good), 1349 accum_ht->agg_crc32_good, 1350 delta_ht->agg_crc32_good, max_ht->agg_crc32_good); 1351 pos += scnprintf(buf + pos, bufsz - pos, 1352 fmt_table, "agg_mpdu_cnt:", 1353 le32_to_cpu(ht->agg_mpdu_cnt), 1354 accum_ht->agg_mpdu_cnt, 1355 delta_ht->agg_mpdu_cnt, max_ht->agg_mpdu_cnt); 1356 pos += scnprintf(buf + pos, bufsz - pos, 1357 fmt_table, "agg_cnt:", 1358 le32_to_cpu(ht->agg_cnt), accum_ht->agg_cnt, 1359 delta_ht->agg_cnt, max_ht->agg_cnt); 1360 pos += scnprintf(buf + pos, bufsz - pos, 1361 fmt_table, "unsupport_mcs:", 1362 le32_to_cpu(ht->unsupport_mcs), 1363 accum_ht->unsupport_mcs, 1364 delta_ht->unsupport_mcs, max_ht->unsupport_mcs); 1365 1366 spin_unlock_bh(&priv->statistics.lock); 1367 1368 ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos); 1369 kfree(buf); 1370 return ret; 1371} 1372 1373static ssize_t iwl_dbgfs_ucode_tx_stats_read(struct file *file, 1374 char __user *user_buf, 1375 size_t count, loff_t *ppos) 1376{ 1377 struct iwl_priv *priv = file->private_data; 1378 int pos = 0; 1379 char *buf; 1380 int bufsz = (sizeof(struct statistics_tx) * 48) + 250; 1381 ssize_t ret; 1382 struct statistics_tx *tx, *accum_tx, *delta_tx, *max_tx; 1383 1384 if (!iwl_is_alive(priv->shrd)) 1385 return -EAGAIN; 1386 1387 buf = kzalloc(bufsz, GFP_KERNEL); 1388 if (!buf) { 1389 IWL_ERR(priv, "Can not allocate Buffer\n"); 1390 return -ENOMEM; 1391 } 1392 1393 /* the statistic information display here is based on 1394 * the last statistics notification from uCode 1395 * might not reflect the current uCode activity 1396 */ 1397 spin_lock_bh(&priv->statistics.lock); 1398 1399 tx = &priv->statistics.tx; 1400 accum_tx = &priv->accum_stats.tx; 1401 delta_tx = &priv->delta_stats.tx; 1402 max_tx = &priv->max_delta_stats.tx; 1403 1404 pos += iwl_statistics_flag(priv, buf, bufsz); 1405 pos += scnprintf(buf + pos, bufsz - pos, 1406 fmt_header, "Statistics_Tx:"); 1407 pos += scnprintf(buf + pos, bufsz - pos, 1408 fmt_table, "preamble:", 1409 le32_to_cpu(tx->preamble_cnt), 1410 accum_tx->preamble_cnt, 1411 delta_tx->preamble_cnt, max_tx->preamble_cnt); 1412 pos += scnprintf(buf + pos, bufsz - pos, 1413 fmt_table, "rx_detected_cnt:", 1414 le32_to_cpu(tx->rx_detected_cnt), 1415 accum_tx->rx_detected_cnt, 1416 delta_tx->rx_detected_cnt, max_tx->rx_detected_cnt); 1417 pos += scnprintf(buf + pos, bufsz - pos, 1418 fmt_table, "bt_prio_defer_cnt:", 1419 le32_to_cpu(tx->bt_prio_defer_cnt), 1420 accum_tx->bt_prio_defer_cnt, 1421 delta_tx->bt_prio_defer_cnt, 1422 max_tx->bt_prio_defer_cnt); 1423 pos += scnprintf(buf + pos, bufsz - pos, 1424 fmt_table, "bt_prio_kill_cnt:", 1425 le32_to_cpu(tx->bt_prio_kill_cnt), 1426 accum_tx->bt_prio_kill_cnt, 1427 delta_tx->bt_prio_kill_cnt, 1428 max_tx->bt_prio_kill_cnt); 1429 pos += scnprintf(buf + pos, bufsz - pos, 1430 fmt_table, "few_bytes_cnt:", 1431 le32_to_cpu(tx->few_bytes_cnt), 1432 accum_tx->few_bytes_cnt, 1433 delta_tx->few_bytes_cnt, max_tx->few_bytes_cnt); 1434 pos += scnprintf(buf + pos, bufsz - pos, 1435 fmt_table, "cts_timeout:", 1436 le32_to_cpu(tx->cts_timeout), accum_tx->cts_timeout, 1437 delta_tx->cts_timeout, max_tx->cts_timeout); 1438 pos += scnprintf(buf + pos, bufsz - pos, 1439 fmt_table, "ack_timeout:", 1440 le32_to_cpu(tx->ack_timeout), 1441 accum_tx->ack_timeout, 1442 delta_tx->ack_timeout, max_tx->ack_timeout); 1443 pos += scnprintf(buf + pos, bufsz - pos, 1444 fmt_table, "expected_ack_cnt:", 1445 le32_to_cpu(tx->expected_ack_cnt), 1446 accum_tx->expected_ack_cnt, 1447 delta_tx->expected_ack_cnt, 1448 max_tx->expected_ack_cnt); 1449 pos += scnprintf(buf + pos, bufsz - pos, 1450 fmt_table, "actual_ack_cnt:", 1451 le32_to_cpu(tx->actual_ack_cnt), 1452 accum_tx->actual_ack_cnt, 1453 delta_tx->actual_ack_cnt, 1454 max_tx->actual_ack_cnt); 1455 pos += scnprintf(buf + pos, bufsz - pos, 1456 fmt_table, "dump_msdu_cnt:", 1457 le32_to_cpu(tx->dump_msdu_cnt), 1458 accum_tx->dump_msdu_cnt, 1459 delta_tx->dump_msdu_cnt, 1460 max_tx->dump_msdu_cnt); 1461 pos += scnprintf(buf + pos, bufsz - pos, 1462 fmt_table, "abort_nxt_frame_mismatch:", 1463 le32_to_cpu(tx->burst_abort_next_frame_mismatch_cnt), 1464 accum_tx->burst_abort_next_frame_mismatch_cnt, 1465 delta_tx->burst_abort_next_frame_mismatch_cnt, 1466 max_tx->burst_abort_next_frame_mismatch_cnt); 1467 pos += scnprintf(buf + pos, bufsz - pos, 1468 fmt_table, "abort_missing_nxt_frame:", 1469 le32_to_cpu(tx->burst_abort_missing_next_frame_cnt), 1470 accum_tx->burst_abort_missing_next_frame_cnt, 1471 delta_tx->burst_abort_missing_next_frame_cnt, 1472 max_tx->burst_abort_missing_next_frame_cnt); 1473 pos += scnprintf(buf + pos, bufsz - pos, 1474 fmt_table, "cts_timeout_collision:", 1475 le32_to_cpu(tx->cts_timeout_collision), 1476 accum_tx->cts_timeout_collision, 1477 delta_tx->cts_timeout_collision, 1478 max_tx->cts_timeout_collision); 1479 pos += scnprintf(buf + pos, bufsz - pos, 1480 fmt_table, "ack_ba_timeout_collision:", 1481 le32_to_cpu(tx->ack_or_ba_timeout_collision), 1482 accum_tx->ack_or_ba_timeout_collision, 1483 delta_tx->ack_or_ba_timeout_collision, 1484 max_tx->ack_or_ba_timeout_collision); 1485 pos += scnprintf(buf + pos, bufsz - pos, 1486 fmt_table, "agg ba_timeout:", 1487 le32_to_cpu(tx->agg.ba_timeout), 1488 accum_tx->agg.ba_timeout, 1489 delta_tx->agg.ba_timeout, 1490 max_tx->agg.ba_timeout); 1491 pos += scnprintf(buf + pos, bufsz - pos, 1492 fmt_table, "agg ba_resched_frames:", 1493 le32_to_cpu(tx->agg.ba_reschedule_frames), 1494 accum_tx->agg.ba_reschedule_frames, 1495 delta_tx->agg.ba_reschedule_frames, 1496 max_tx->agg.ba_reschedule_frames); 1497 pos += scnprintf(buf + pos, bufsz - pos, 1498 fmt_table, "agg scd_query_agg_frame:", 1499 le32_to_cpu(tx->agg.scd_query_agg_frame_cnt), 1500 accum_tx->agg.scd_query_agg_frame_cnt, 1501 delta_tx->agg.scd_query_agg_frame_cnt, 1502 max_tx->agg.scd_query_agg_frame_cnt); 1503 pos += scnprintf(buf + pos, bufsz - pos, 1504 fmt_table, "agg scd_query_no_agg:", 1505 le32_to_cpu(tx->agg.scd_query_no_agg), 1506 accum_tx->agg.scd_query_no_agg, 1507 delta_tx->agg.scd_query_no_agg, 1508 max_tx->agg.scd_query_no_agg); 1509 pos += scnprintf(buf + pos, bufsz - pos, 1510 fmt_table, "agg scd_query_agg:", 1511 le32_to_cpu(tx->agg.scd_query_agg), 1512 accum_tx->agg.scd_query_agg, 1513 delta_tx->agg.scd_query_agg, 1514 max_tx->agg.scd_query_agg); 1515 pos += scnprintf(buf + pos, bufsz - pos, 1516 fmt_table, "agg scd_query_mismatch:", 1517 le32_to_cpu(tx->agg.scd_query_mismatch), 1518 accum_tx->agg.scd_query_mismatch, 1519 delta_tx->agg.scd_query_mismatch, 1520 max_tx->agg.scd_query_mismatch); 1521 pos += scnprintf(buf + pos, bufsz - pos, 1522 fmt_table, "agg frame_not_ready:", 1523 le32_to_cpu(tx->agg.frame_not_ready), 1524 accum_tx->agg.frame_not_ready, 1525 delta_tx->agg.frame_not_ready, 1526 max_tx->agg.frame_not_ready); 1527 pos += scnprintf(buf + pos, bufsz - pos, 1528 fmt_table, "agg underrun:", 1529 le32_to_cpu(tx->agg.underrun), 1530 accum_tx->agg.underrun, 1531 delta_tx->agg.underrun, max_tx->agg.underrun); 1532 pos += scnprintf(buf + pos, bufsz - pos, 1533 fmt_table, "agg bt_prio_kill:", 1534 le32_to_cpu(tx->agg.bt_prio_kill), 1535 accum_tx->agg.bt_prio_kill, 1536 delta_tx->agg.bt_prio_kill, 1537 max_tx->agg.bt_prio_kill); 1538 pos += scnprintf(buf + pos, bufsz - pos, 1539 fmt_table, "agg rx_ba_rsp_cnt:", 1540 le32_to_cpu(tx->agg.rx_ba_rsp_cnt), 1541 accum_tx->agg.rx_ba_rsp_cnt, 1542 delta_tx->agg.rx_ba_rsp_cnt, 1543 max_tx->agg.rx_ba_rsp_cnt); 1544 1545 if (tx->tx_power.ant_a || tx->tx_power.ant_b || tx->tx_power.ant_c) { 1546 pos += scnprintf(buf + pos, bufsz - pos, 1547 "tx power: (1/2 dB step)\n"); 1548 if ((hw_params(priv).valid_tx_ant & ANT_A) && 1549 tx->tx_power.ant_a) 1550 pos += scnprintf(buf + pos, bufsz - pos, 1551 fmt_hex, "antenna A:", 1552 tx->tx_power.ant_a); 1553 if ((hw_params(priv).valid_tx_ant & ANT_B) && 1554 tx->tx_power.ant_b) 1555 pos += scnprintf(buf + pos, bufsz - pos, 1556 fmt_hex, "antenna B:", 1557 tx->tx_power.ant_b); 1558 if ((hw_params(priv).valid_tx_ant & ANT_C) && 1559 tx->tx_power.ant_c) 1560 pos += scnprintf(buf + pos, bufsz - pos, 1561 fmt_hex, "antenna C:", 1562 tx->tx_power.ant_c); 1563 } 1564 1565 spin_unlock_bh(&priv->statistics.lock); 1566 1567 ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos); 1568 kfree(buf); 1569 return ret; 1570} 1571 1572static ssize_t iwl_dbgfs_ucode_general_stats_read(struct file *file, 1573 char __user *user_buf, 1574 size_t count, loff_t *ppos) 1575{ 1576 struct iwl_priv *priv = file->private_data; 1577 int pos = 0; 1578 char *buf; 1579 int bufsz = sizeof(struct statistics_general) * 10 + 300; 1580 ssize_t ret; 1581 struct statistics_general_common *general, *accum_general; 1582 struct statistics_general_common *delta_general, *max_general; 1583 struct statistics_dbg *dbg, *accum_dbg, *delta_dbg, *max_dbg; 1584 struct statistics_div *div, *accum_div, *delta_div, *max_div; 1585 1586 if (!iwl_is_alive(priv->shrd)) 1587 return -EAGAIN; 1588 1589 buf = kzalloc(bufsz, GFP_KERNEL); 1590 if (!buf) { 1591 IWL_ERR(priv, "Can not allocate Buffer\n"); 1592 return -ENOMEM; 1593 } 1594 1595 /* the statistic information display here is based on 1596 * the last statistics notification from uCode 1597 * might not reflect the current uCode activity 1598 */ 1599 1600 spin_lock_bh(&priv->statistics.lock); 1601 1602 general = &priv->statistics.common; 1603 dbg = &priv->statistics.common.dbg; 1604 div = &priv->statistics.common.div; 1605 accum_general = &priv->accum_stats.common; 1606 accum_dbg = &priv->accum_stats.common.dbg; 1607 accum_div = &priv->accum_stats.common.div; 1608 delta_general = &priv->delta_stats.common; 1609 max_general = &priv->max_delta_stats.common; 1610 delta_dbg = &priv->delta_stats.common.dbg; 1611 max_dbg = &priv->max_delta_stats.common.dbg; 1612 delta_div = &priv->delta_stats.common.div; 1613 max_div = &priv->max_delta_stats.common.div; 1614 1615 pos += iwl_statistics_flag(priv, buf, bufsz); 1616 pos += scnprintf(buf + pos, bufsz - pos, 1617 fmt_header, "Statistics_General:"); 1618 pos += scnprintf(buf + pos, bufsz - pos, 1619 fmt_value, "temperature:", 1620 le32_to_cpu(general->temperature)); 1621 pos += scnprintf(buf + pos, bufsz - pos, 1622 fmt_value, "temperature_m:", 1623 le32_to_cpu(general->temperature_m)); 1624 pos += scnprintf(buf + pos, bufsz - pos, 1625 fmt_value, "ttl_timestamp:", 1626 le32_to_cpu(general->ttl_timestamp)); 1627 pos += scnprintf(buf + pos, bufsz - pos, 1628 fmt_table, "burst_check:", 1629 le32_to_cpu(dbg->burst_check), 1630 accum_dbg->burst_check, 1631 delta_dbg->burst_check, max_dbg->burst_check); 1632 pos += scnprintf(buf + pos, bufsz - pos, 1633 fmt_table, "burst_count:", 1634 le32_to_cpu(dbg->burst_count), 1635 accum_dbg->burst_count, 1636 delta_dbg->burst_count, max_dbg->burst_count); 1637 pos += scnprintf(buf + pos, bufsz - pos, 1638 fmt_table, "wait_for_silence_timeout_count:", 1639 le32_to_cpu(dbg->wait_for_silence_timeout_cnt), 1640 accum_dbg->wait_for_silence_timeout_cnt, 1641 delta_dbg->wait_for_silence_timeout_cnt, 1642 max_dbg->wait_for_silence_timeout_cnt); 1643 pos += scnprintf(buf + pos, bufsz - pos, 1644 fmt_table, "sleep_time:", 1645 le32_to_cpu(general->sleep_time), 1646 accum_general->sleep_time, 1647 delta_general->sleep_time, max_general->sleep_time); 1648 pos += scnprintf(buf + pos, bufsz - pos, 1649 fmt_table, "slots_out:", 1650 le32_to_cpu(general->slots_out), 1651 accum_general->slots_out, 1652 delta_general->slots_out, max_general->slots_out); 1653 pos += scnprintf(buf + pos, bufsz - pos, 1654 fmt_table, "slots_idle:", 1655 le32_to_cpu(general->slots_idle), 1656 accum_general->slots_idle, 1657 delta_general->slots_idle, max_general->slots_idle); 1658 pos += scnprintf(buf + pos, bufsz - pos, 1659 fmt_table, "tx_on_a:", 1660 le32_to_cpu(div->tx_on_a), accum_div->tx_on_a, 1661 delta_div->tx_on_a, max_div->tx_on_a); 1662 pos += scnprintf(buf + pos, bufsz - pos, 1663 fmt_table, "tx_on_b:", 1664 le32_to_cpu(div->tx_on_b), accum_div->tx_on_b, 1665 delta_div->tx_on_b, max_div->tx_on_b); 1666 pos += scnprintf(buf + pos, bufsz - pos, 1667 fmt_table, "exec_time:", 1668 le32_to_cpu(div->exec_time), accum_div->exec_time, 1669 delta_div->exec_time, max_div->exec_time); 1670 pos += scnprintf(buf + pos, bufsz - pos, 1671 fmt_table, "probe_time:", 1672 le32_to_cpu(div->probe_time), accum_div->probe_time, 1673 delta_div->probe_time, max_div->probe_time); 1674 pos += scnprintf(buf + pos, bufsz - pos, 1675 fmt_table, "rx_enable_counter:", 1676 le32_to_cpu(general->rx_enable_counter), 1677 accum_general->rx_enable_counter, 1678 delta_general->rx_enable_counter, 1679 max_general->rx_enable_counter); 1680 pos += scnprintf(buf + pos, bufsz - pos, 1681 fmt_table, "num_of_sos_states:", 1682 le32_to_cpu(general->num_of_sos_states), 1683 accum_general->num_of_sos_states, 1684 delta_general->num_of_sos_states, 1685 max_general->num_of_sos_states); 1686 1687 spin_unlock_bh(&priv->statistics.lock); 1688 1689 ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos); 1690 kfree(buf); 1691 return ret; 1692} 1693 1694static ssize_t iwl_dbgfs_ucode_bt_stats_read(struct file *file, 1695 char __user *user_buf, 1696 size_t count, loff_t *ppos) 1697{ 1698 struct iwl_priv *priv = (struct iwl_priv *)file->private_data; 1699 int pos = 0; 1700 char *buf; 1701 int bufsz = (sizeof(struct statistics_bt_activity) * 24) + 200; 1702 ssize_t ret; 1703 struct statistics_bt_activity *bt, *accum_bt; 1704 1705 if (!iwl_is_alive(priv->shrd)) 1706 return -EAGAIN; 1707 1708 if (!priv->bt_enable_flag) 1709 return -EINVAL; 1710 1711 /* make request to uCode to retrieve statistics information */ 1712 mutex_lock(&priv->shrd->mutex); 1713 ret = iwl_send_statistics_request(priv, CMD_SYNC, false); 1714 mutex_unlock(&priv->shrd->mutex); 1715 1716 if (ret) { 1717 IWL_ERR(priv, 1718 "Error sending statistics request: %zd\n", ret); 1719 return -EAGAIN; 1720 } 1721 buf = kzalloc(bufsz, GFP_KERNEL); 1722 if (!buf) { 1723 IWL_ERR(priv, "Can not allocate Buffer\n"); 1724 return -ENOMEM; 1725 } 1726 1727 /* 1728 * the statistic information display here is based on 1729 * the last statistics notification from uCode 1730 * might not reflect the current uCode activity 1731 */ 1732 1733 spin_lock_bh(&priv->statistics.lock); 1734 1735 bt = &priv->statistics.bt_activity; 1736 accum_bt = &priv->accum_stats.bt_activity; 1737 1738 pos += iwl_statistics_flag(priv, buf, bufsz); 1739 pos += scnprintf(buf + pos, bufsz - pos, "Statistics_BT:\n"); 1740 pos += scnprintf(buf + pos, bufsz - pos, 1741 "\t\t\tcurrent\t\t\taccumulative\n"); 1742 pos += scnprintf(buf + pos, bufsz - pos, 1743 "hi_priority_tx_req_cnt:\t\t%u\t\t\t%u\n", 1744 le32_to_cpu(bt->hi_priority_tx_req_cnt), 1745 accum_bt->hi_priority_tx_req_cnt); 1746 pos += scnprintf(buf + pos, bufsz - pos, 1747 "hi_priority_tx_denied_cnt:\t%u\t\t\t%u\n", 1748 le32_to_cpu(bt->hi_priority_tx_denied_cnt), 1749 accum_bt->hi_priority_tx_denied_cnt); 1750 pos += scnprintf(buf + pos, bufsz - pos, 1751 "lo_priority_tx_req_cnt:\t\t%u\t\t\t%u\n", 1752 le32_to_cpu(bt->lo_priority_tx_req_cnt), 1753 accum_bt->lo_priority_tx_req_cnt); 1754 pos += scnprintf(buf + pos, bufsz - pos, 1755 "lo_priority_tx_denied_cnt:\t%u\t\t\t%u\n", 1756 le32_to_cpu(bt->lo_priority_tx_denied_cnt), 1757 accum_bt->lo_priority_tx_denied_cnt); 1758 pos += scnprintf(buf + pos, bufsz - pos, 1759 "hi_priority_rx_req_cnt:\t\t%u\t\t\t%u\n", 1760 le32_to_cpu(bt->hi_priority_rx_req_cnt), 1761 accum_bt->hi_priority_rx_req_cnt); 1762 pos += scnprintf(buf + pos, bufsz - pos, 1763 "hi_priority_rx_denied_cnt:\t%u\t\t\t%u\n", 1764 le32_to_cpu(bt->hi_priority_rx_denied_cnt), 1765 accum_bt->hi_priority_rx_denied_cnt); 1766 pos += scnprintf(buf + pos, bufsz - pos, 1767 "lo_priority_rx_req_cnt:\t\t%u\t\t\t%u\n", 1768 le32_to_cpu(bt->lo_priority_rx_req_cnt), 1769 accum_bt->lo_priority_rx_req_cnt); 1770 pos += scnprintf(buf + pos, bufsz - pos, 1771 "lo_priority_rx_denied_cnt:\t%u\t\t\t%u\n", 1772 le32_to_cpu(bt->lo_priority_rx_denied_cnt), 1773 accum_bt->lo_priority_rx_denied_cnt); 1774 1775 pos += scnprintf(buf + pos, bufsz - pos, 1776 "(rx)num_bt_kills:\t\t%u\t\t\t%u\n", 1777 le32_to_cpu(priv->statistics.num_bt_kills), 1778 priv->statistics.accum_num_bt_kills); 1779 1780 spin_unlock_bh(&priv->statistics.lock); 1781 1782 ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos); 1783 kfree(buf); 1784 return ret; 1785} 1786 1787static ssize_t iwl_dbgfs_reply_tx_error_read(struct file *file, 1788 char __user *user_buf, 1789 size_t count, loff_t *ppos) 1790{ 1791 struct iwl_priv *priv = (struct iwl_priv *)file->private_data; 1792 int pos = 0; 1793 char *buf; 1794 int bufsz = (sizeof(struct reply_tx_error_statistics) * 24) + 1795 (sizeof(struct reply_agg_tx_error_statistics) * 24) + 200; 1796 ssize_t ret; 1797 1798 if (!iwl_is_alive(priv->shrd)) 1799 return -EAGAIN; 1800 1801 buf = kzalloc(bufsz, GFP_KERNEL); 1802 if (!buf) { 1803 IWL_ERR(priv, "Can not allocate Buffer\n"); 1804 return -ENOMEM; 1805 } 1806 1807 pos += scnprintf(buf + pos, bufsz - pos, "Statistics_TX_Error:\n"); 1808 pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t\t\t%u\n", 1809 iwl_get_tx_fail_reason(TX_STATUS_POSTPONE_DELAY), 1810 priv->reply_tx_stats.pp_delay); 1811 pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t\t%u\n", 1812 iwl_get_tx_fail_reason(TX_STATUS_POSTPONE_FEW_BYTES), 1813 priv->reply_tx_stats.pp_few_bytes); 1814 pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t\t%u\n", 1815 iwl_get_tx_fail_reason(TX_STATUS_POSTPONE_BT_PRIO), 1816 priv->reply_tx_stats.pp_bt_prio); 1817 pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t\t%u\n", 1818 iwl_get_tx_fail_reason(TX_STATUS_POSTPONE_QUIET_PERIOD), 1819 priv->reply_tx_stats.pp_quiet_period); 1820 pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t\t%u\n", 1821 iwl_get_tx_fail_reason(TX_STATUS_POSTPONE_CALC_TTAK), 1822 priv->reply_tx_stats.pp_calc_ttak); 1823 pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t%u\n", 1824 iwl_get_tx_fail_reason( 1825 TX_STATUS_FAIL_INTERNAL_CROSSED_RETRY), 1826 priv->reply_tx_stats.int_crossed_retry); 1827 pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t\t%u\n", 1828 iwl_get_tx_fail_reason(TX_STATUS_FAIL_SHORT_LIMIT), 1829 priv->reply_tx_stats.short_limit); 1830 pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t\t%u\n", 1831 iwl_get_tx_fail_reason(TX_STATUS_FAIL_LONG_LIMIT), 1832 priv->reply_tx_stats.long_limit); 1833 pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t\t%u\n", 1834 iwl_get_tx_fail_reason(TX_STATUS_FAIL_FIFO_UNDERRUN), 1835 priv->reply_tx_stats.fifo_underrun); 1836 pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t\t%u\n", 1837 iwl_get_tx_fail_reason(TX_STATUS_FAIL_DRAIN_FLOW), 1838 priv->reply_tx_stats.drain_flow); 1839 pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t\t%u\n", 1840 iwl_get_tx_fail_reason(TX_STATUS_FAIL_RFKILL_FLUSH), 1841 priv->reply_tx_stats.rfkill_flush); 1842 pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t\t%u\n", 1843 iwl_get_tx_fail_reason(TX_STATUS_FAIL_LIFE_EXPIRE), 1844 priv->reply_tx_stats.life_expire); 1845 pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t\t%u\n", 1846 iwl_get_tx_fail_reason(TX_STATUS_FAIL_DEST_PS), 1847 priv->reply_tx_stats.dest_ps); 1848 pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t\t%u\n", 1849 iwl_get_tx_fail_reason(TX_STATUS_FAIL_HOST_ABORTED), 1850 priv->reply_tx_stats.host_abort); 1851 pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t\t%u\n", 1852 iwl_get_tx_fail_reason(TX_STATUS_FAIL_BT_RETRY), 1853 priv->reply_tx_stats.pp_delay); 1854 pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t\t%u\n", 1855 iwl_get_tx_fail_reason(TX_STATUS_FAIL_STA_INVALID), 1856 priv->reply_tx_stats.sta_invalid); 1857 pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t\t%u\n", 1858 iwl_get_tx_fail_reason(TX_STATUS_FAIL_FRAG_DROPPED), 1859 priv->reply_tx_stats.frag_drop); 1860 pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t\t%u\n", 1861 iwl_get_tx_fail_reason(TX_STATUS_FAIL_TID_DISABLE), 1862 priv->reply_tx_stats.tid_disable); 1863 pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t\t%u\n", 1864 iwl_get_tx_fail_reason(TX_STATUS_FAIL_FIFO_FLUSHED), 1865 priv->reply_tx_stats.fifo_flush); 1866 pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t%u\n", 1867 iwl_get_tx_fail_reason( 1868 TX_STATUS_FAIL_INSUFFICIENT_CF_POLL), 1869 priv->reply_tx_stats.insuff_cf_poll); 1870 pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t\t%u\n", 1871 iwl_get_tx_fail_reason(TX_STATUS_FAIL_PASSIVE_NO_RX), 1872 priv->reply_tx_stats.fail_hw_drop); 1873 pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t%u\n", 1874 iwl_get_tx_fail_reason( 1875 TX_STATUS_FAIL_NO_BEACON_ON_RADAR), 1876 priv->reply_tx_stats.sta_color_mismatch); 1877 pos += scnprintf(buf + pos, bufsz - pos, "UNKNOWN:\t\t\t%u\n", 1878 priv->reply_tx_stats.unknown); 1879 1880 pos += scnprintf(buf + pos, bufsz - pos, 1881 "\nStatistics_Agg_TX_Error:\n"); 1882 1883 pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t\t%u\n", 1884 iwl_get_agg_tx_fail_reason(AGG_TX_STATE_UNDERRUN_MSK), 1885 priv->reply_agg_tx_stats.underrun); 1886 pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t\t%u\n", 1887 iwl_get_agg_tx_fail_reason(AGG_TX_STATE_BT_PRIO_MSK), 1888 priv->reply_agg_tx_stats.bt_prio); 1889 pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t\t%u\n", 1890 iwl_get_agg_tx_fail_reason(AGG_TX_STATE_FEW_BYTES_MSK), 1891 priv->reply_agg_tx_stats.few_bytes); 1892 pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t\t%u\n", 1893 iwl_get_agg_tx_fail_reason(AGG_TX_STATE_ABORT_MSK), 1894 priv->reply_agg_tx_stats.abort); 1895 pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t%u\n", 1896 iwl_get_agg_tx_fail_reason( 1897 AGG_TX_STATE_LAST_SENT_TTL_MSK), 1898 priv->reply_agg_tx_stats.last_sent_ttl); 1899 pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t%u\n", 1900 iwl_get_agg_tx_fail_reason( 1901 AGG_TX_STATE_LAST_SENT_TRY_CNT_MSK), 1902 priv->reply_agg_tx_stats.last_sent_try); 1903 pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t%u\n", 1904 iwl_get_agg_tx_fail_reason( 1905 AGG_TX_STATE_LAST_SENT_BT_KILL_MSK), 1906 priv->reply_agg_tx_stats.last_sent_bt_kill); 1907 pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t\t%u\n", 1908 iwl_get_agg_tx_fail_reason(AGG_TX_STATE_SCD_QUERY_MSK), 1909 priv->reply_agg_tx_stats.scd_query); 1910 pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t%u\n", 1911 iwl_get_agg_tx_fail_reason( 1912 AGG_TX_STATE_TEST_BAD_CRC32_MSK), 1913 priv->reply_agg_tx_stats.bad_crc32); 1914 pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t\t%u\n", 1915 iwl_get_agg_tx_fail_reason(AGG_TX_STATE_RESPONSE_MSK), 1916 priv->reply_agg_tx_stats.response); 1917 pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t\t%u\n", 1918 iwl_get_agg_tx_fail_reason(AGG_TX_STATE_DUMP_TX_MSK), 1919 priv->reply_agg_tx_stats.dump_tx); 1920 pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t\t%u\n", 1921 iwl_get_agg_tx_fail_reason(AGG_TX_STATE_DELAY_TX_MSK), 1922 priv->reply_agg_tx_stats.delay_tx); 1923 pos += scnprintf(buf + pos, bufsz - pos, "UNKNOWN:\t\t\t%u\n", 1924 priv->reply_agg_tx_stats.unknown); 1925 1926 ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos); 1927 kfree(buf); 1928 return ret; 1929} 1930 1931static ssize_t iwl_dbgfs_sensitivity_read(struct file *file, 1932 char __user *user_buf, 1933 size_t count, loff_t *ppos) { 1934 1935 struct iwl_priv *priv = file->private_data; 1936 int pos = 0; 1937 int cnt = 0; 1938 char *buf; 1939 int bufsz = sizeof(struct iwl_sensitivity_data) * 4 + 100; 1940 ssize_t ret; 1941 struct iwl_sensitivity_data *data; 1942 1943 data = &priv->sensitivity_data; 1944 buf = kzalloc(bufsz, GFP_KERNEL); 1945 if (!buf) { 1946 IWL_ERR(priv, "Can not allocate Buffer\n"); 1947 return -ENOMEM; 1948 } 1949 1950 pos += scnprintf(buf + pos, bufsz - pos, "auto_corr_ofdm:\t\t\t %u\n", 1951 data->auto_corr_ofdm); 1952 pos += scnprintf(buf + pos, bufsz - pos, 1953 "auto_corr_ofdm_mrc:\t\t %u\n", 1954 data->auto_corr_ofdm_mrc); 1955 pos += scnprintf(buf + pos, bufsz - pos, "auto_corr_ofdm_x1:\t\t %u\n", 1956 data->auto_corr_ofdm_x1); 1957 pos += scnprintf(buf + pos, bufsz - pos, 1958 "auto_corr_ofdm_mrc_x1:\t\t %u\n", 1959 data->auto_corr_ofdm_mrc_x1); 1960 pos += scnprintf(buf + pos, bufsz - pos, "auto_corr_cck:\t\t\t %u\n", 1961 data->auto_corr_cck); 1962 pos += scnprintf(buf + pos, bufsz - pos, "auto_corr_cck_mrc:\t\t %u\n", 1963 data->auto_corr_cck_mrc); 1964 pos += scnprintf(buf + pos, bufsz - pos, 1965 "last_bad_plcp_cnt_ofdm:\t\t %u\n", 1966 data->last_bad_plcp_cnt_ofdm); 1967 pos += scnprintf(buf + pos, bufsz - pos, "last_fa_cnt_ofdm:\t\t %u\n", 1968 data->last_fa_cnt_ofdm); 1969 pos += scnprintf(buf + pos, bufsz - pos, 1970 "last_bad_plcp_cnt_cck:\t\t %u\n", 1971 data->last_bad_plcp_cnt_cck); 1972 pos += scnprintf(buf + pos, bufsz - pos, "last_fa_cnt_cck:\t\t %u\n", 1973 data->last_fa_cnt_cck); 1974 pos += scnprintf(buf + pos, bufsz - pos, "nrg_curr_state:\t\t\t %u\n", 1975 data->nrg_curr_state); 1976 pos += scnprintf(buf + pos, bufsz - pos, "nrg_prev_state:\t\t\t %u\n", 1977 data->nrg_prev_state); 1978 pos += scnprintf(buf + pos, bufsz - pos, "nrg_value:\t\t\t"); 1979 for (cnt = 0; cnt < 10; cnt++) { 1980 pos += scnprintf(buf + pos, bufsz - pos, " %u", 1981 data->nrg_value[cnt]); 1982 } 1983 pos += scnprintf(buf + pos, bufsz - pos, "\n"); 1984 pos += scnprintf(buf + pos, bufsz - pos, "nrg_silence_rssi:\t\t"); 1985 for (cnt = 0; cnt < NRG_NUM_PREV_STAT_L; cnt++) { 1986 pos += scnprintf(buf + pos, bufsz - pos, " %u", 1987 data->nrg_silence_rssi[cnt]); 1988 } 1989 pos += scnprintf(buf + pos, bufsz - pos, "\n"); 1990 pos += scnprintf(buf + pos, bufsz - pos, "nrg_silence_ref:\t\t %u\n", 1991 data->nrg_silence_ref); 1992 pos += scnprintf(buf + pos, bufsz - pos, "nrg_energy_idx:\t\t\t %u\n", 1993 data->nrg_energy_idx); 1994 pos += scnprintf(buf + pos, bufsz - pos, "nrg_silence_idx:\t\t %u\n", 1995 data->nrg_silence_idx); 1996 pos += scnprintf(buf + pos, bufsz - pos, "nrg_th_cck:\t\t\t %u\n", 1997 data->nrg_th_cck); 1998 pos += scnprintf(buf + pos, bufsz - pos, 1999 "nrg_auto_corr_silence_diff:\t %u\n", 2000 data->nrg_auto_corr_silence_diff); 2001 pos += scnprintf(buf + pos, bufsz - pos, "num_in_cck_no_fa:\t\t %u\n", 2002 data->num_in_cck_no_fa); 2003 pos += scnprintf(buf + pos, bufsz - pos, "nrg_th_ofdm:\t\t\t %u\n", 2004 data->nrg_th_ofdm); 2005 2006 ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos); 2007 kfree(buf); 2008 return ret; 2009} 2010 2011 2012static ssize_t iwl_dbgfs_chain_noise_read(struct file *file, 2013 char __user *user_buf, 2014 size_t count, loff_t *ppos) { 2015 2016 struct iwl_priv *priv = file->private_data; 2017 int pos = 0; 2018 int cnt = 0; 2019 char *buf; 2020 int bufsz = sizeof(struct iwl_chain_noise_data) * 4 + 100; 2021 ssize_t ret; 2022 struct iwl_chain_noise_data *data; 2023 2024 data = &priv->chain_noise_data; 2025 buf = kzalloc(bufsz, GFP_KERNEL); 2026 if (!buf) { 2027 IWL_ERR(priv, "Can not allocate Buffer\n"); 2028 return -ENOMEM; 2029 } 2030 2031 pos += scnprintf(buf + pos, bufsz - pos, "active_chains:\t\t\t %u\n", 2032 data->active_chains); 2033 pos += scnprintf(buf + pos, bufsz - pos, "chain_noise_a:\t\t\t %u\n", 2034 data->chain_noise_a); 2035 pos += scnprintf(buf + pos, bufsz - pos, "chain_noise_b:\t\t\t %u\n", 2036 data->chain_noise_b); 2037 pos += scnprintf(buf + pos, bufsz - pos, "chain_noise_c:\t\t\t %u\n", 2038 data->chain_noise_c); 2039 pos += scnprintf(buf + pos, bufsz - pos, "chain_signal_a:\t\t\t %u\n", 2040 data->chain_signal_a); 2041 pos += scnprintf(buf + pos, bufsz - pos, "chain_signal_b:\t\t\t %u\n", 2042 data->chain_signal_b); 2043 pos += scnprintf(buf + pos, bufsz - pos, "chain_signal_c:\t\t\t %u\n", 2044 data->chain_signal_c); 2045 pos += scnprintf(buf + pos, bufsz - pos, "beacon_count:\t\t\t %u\n", 2046 data->beacon_count); 2047 2048 pos += scnprintf(buf + pos, bufsz - pos, "disconn_array:\t\t\t"); 2049 for (cnt = 0; cnt < NUM_RX_CHAINS; cnt++) { 2050 pos += scnprintf(buf + pos, bufsz - pos, " %u", 2051 data->disconn_array[cnt]); 2052 } 2053 pos += scnprintf(buf + pos, bufsz - pos, "\n"); 2054 pos += scnprintf(buf + pos, bufsz - pos, "delta_gain_code:\t\t"); 2055 for (cnt = 0; cnt < NUM_RX_CHAINS; cnt++) { 2056 pos += scnprintf(buf + pos, bufsz - pos, " %u", 2057 data->delta_gain_code[cnt]); 2058 } 2059 pos += scnprintf(buf + pos, bufsz - pos, "\n"); 2060 pos += scnprintf(buf + pos, bufsz - pos, "radio_write:\t\t\t %u\n", 2061 data->radio_write); 2062 pos += scnprintf(buf + pos, bufsz - pos, "state:\t\t\t\t %u\n", 2063 data->state); 2064 2065 ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos); 2066 kfree(buf); 2067 return ret; 2068} 2069 2070static ssize_t iwl_dbgfs_power_save_status_read(struct file *file, 2071 char __user *user_buf, 2072 size_t count, loff_t *ppos) 2073{ 2074 struct iwl_priv *priv = file->private_data; 2075 char buf[60]; 2076 int pos = 0; 2077 const size_t bufsz = sizeof(buf); 2078 u32 pwrsave_status; 2079 2080 pwrsave_status = iwl_read32(trans(priv), CSR_GP_CNTRL) & 2081 CSR_GP_REG_POWER_SAVE_STATUS_MSK; 2082 2083 pos += scnprintf(buf + pos, bufsz - pos, "Power Save Status: "); 2084 pos += scnprintf(buf + pos, bufsz - pos, "%s\n", 2085 (pwrsave_status == CSR_GP_REG_NO_POWER_SAVE) ? "none" : 2086 (pwrsave_status == CSR_GP_REG_MAC_POWER_SAVE) ? "MAC" : 2087 (pwrsave_status == CSR_GP_REG_PHY_POWER_SAVE) ? "PHY" : 2088 "error"); 2089 2090 return simple_read_from_buffer(user_buf, count, ppos, buf, pos); 2091} 2092 2093static ssize_t iwl_dbgfs_clear_ucode_statistics_write(struct file *file, 2094 const char __user *user_buf, 2095 size_t count, loff_t *ppos) 2096{ 2097 struct iwl_priv *priv = file->private_data; 2098 char buf[8]; 2099 int buf_size; 2100 int clear; 2101 2102 memset(buf, 0, sizeof(buf)); 2103 buf_size = min(count, sizeof(buf) - 1); 2104 if (copy_from_user(buf, user_buf, buf_size)) 2105 return -EFAULT; 2106 if (sscanf(buf, "%d", &clear) != 1) 2107 return -EFAULT; 2108 2109 /* make request to uCode to retrieve statistics information */ 2110 mutex_lock(&priv->shrd->mutex); 2111 iwl_send_statistics_request(priv, CMD_SYNC, true); 2112 mutex_unlock(&priv->shrd->mutex); 2113 2114 return count; 2115} 2116 2117static ssize_t iwl_dbgfs_ucode_tracing_read(struct file *file, 2118 char __user *user_buf, 2119 size_t count, loff_t *ppos) { 2120 2121 struct iwl_priv *priv = file->private_data; 2122 int pos = 0; 2123 char buf[128]; 2124 const size_t bufsz = sizeof(buf); 2125 2126 pos += scnprintf(buf + pos, bufsz - pos, "ucode trace timer is %s\n", 2127 priv->event_log.ucode_trace ? "On" : "Off"); 2128 pos += scnprintf(buf + pos, bufsz - pos, "non_wraps_count:\t\t %u\n", 2129 priv->event_log.non_wraps_count); 2130 pos += scnprintf(buf + pos, bufsz - pos, "wraps_once_count:\t\t %u\n", 2131 priv->event_log.wraps_once_count); 2132 pos += scnprintf(buf + pos, bufsz - pos, "wraps_more_count:\t\t %u\n", 2133 priv->event_log.wraps_more_count); 2134 2135 return simple_read_from_buffer(user_buf, count, ppos, buf, pos); 2136} 2137 2138static ssize_t iwl_dbgfs_ucode_tracing_write(struct file *file, 2139 const char __user *user_buf, 2140 size_t count, loff_t *ppos) 2141{ 2142 struct iwl_priv *priv = file->private_data; 2143 char buf[8]; 2144 int buf_size; 2145 int trace; 2146 2147 memset(buf, 0, sizeof(buf)); 2148 buf_size = min(count, sizeof(buf) - 1); 2149 if (copy_from_user(buf, user_buf, buf_size)) 2150 return -EFAULT; 2151 if (sscanf(buf, "%d", &trace) != 1) 2152 return -EFAULT; 2153 2154 if (trace) { 2155 priv->event_log.ucode_trace = true; 2156 if (iwl_is_alive(priv->shrd)) { 2157 /* start collecting data now */ 2158 mod_timer(&priv->ucode_trace, jiffies); 2159 } 2160 } else { 2161 priv->event_log.ucode_trace = false; 2162 del_timer_sync(&priv->ucode_trace); 2163 } 2164 2165 return count; 2166} 2167 2168static ssize_t iwl_dbgfs_rxon_flags_read(struct file *file, 2169 char __user *user_buf, 2170 size_t count, loff_t *ppos) { 2171 2172 struct iwl_priv *priv = file->private_data; 2173 int len = 0; 2174 char buf[20]; 2175 2176 len = sprintf(buf, "0x%04X\n", 2177 le32_to_cpu(priv->contexts[IWL_RXON_CTX_BSS].active.flags)); 2178 return simple_read_from_buffer(user_buf, count, ppos, buf, len); 2179} 2180 2181static ssize_t iwl_dbgfs_rxon_filter_flags_read(struct file *file, 2182 char __user *user_buf, 2183 size_t count, loff_t *ppos) { 2184 2185 struct iwl_priv *priv = file->private_data; 2186 int len = 0; 2187 char buf[20]; 2188 2189 len = sprintf(buf, "0x%04X\n", 2190 le32_to_cpu(priv->contexts[IWL_RXON_CTX_BSS].active.filter_flags)); 2191 return simple_read_from_buffer(user_buf, count, ppos, buf, len); 2192} 2193 2194static ssize_t iwl_dbgfs_missed_beacon_read(struct file *file, 2195 char __user *user_buf, 2196 size_t count, loff_t *ppos) { 2197 2198 struct iwl_priv *priv = file->private_data; 2199 int pos = 0; 2200 char buf[12]; 2201 const size_t bufsz = sizeof(buf); 2202 2203 pos += scnprintf(buf + pos, bufsz - pos, "%d\n", 2204 priv->missed_beacon_threshold); 2205 2206 return simple_read_from_buffer(user_buf, count, ppos, buf, pos); 2207} 2208 2209static ssize_t iwl_dbgfs_missed_beacon_write(struct file *file, 2210 const char __user *user_buf, 2211 size_t count, loff_t *ppos) 2212{ 2213 struct iwl_priv *priv = file->private_data; 2214 char buf[8]; 2215 int buf_size; 2216 int missed; 2217 2218 memset(buf, 0, sizeof(buf)); 2219 buf_size = min(count, sizeof(buf) - 1); 2220 if (copy_from_user(buf, user_buf, buf_size)) 2221 return -EFAULT; 2222 if (sscanf(buf, "%d", &missed) != 1) 2223 return -EINVAL; 2224 2225 if (missed < IWL_MISSED_BEACON_THRESHOLD_MIN || 2226 missed > IWL_MISSED_BEACON_THRESHOLD_MAX) 2227 priv->missed_beacon_threshold = 2228 IWL_MISSED_BEACON_THRESHOLD_DEF; 2229 else 2230 priv->missed_beacon_threshold = missed; 2231 2232 return count; 2233} 2234 2235static ssize_t iwl_dbgfs_plcp_delta_read(struct file *file, 2236 char __user *user_buf, 2237 size_t count, loff_t *ppos) { 2238 2239 struct iwl_priv *priv = file->private_data; 2240 int pos = 0; 2241 char buf[12]; 2242 const size_t bufsz = sizeof(buf); 2243 2244 pos += scnprintf(buf + pos, bufsz - pos, "%u\n", 2245 cfg(priv)->base_params->plcp_delta_threshold); 2246 2247 return simple_read_from_buffer(user_buf, count, ppos, buf, pos); 2248} 2249 2250static ssize_t iwl_dbgfs_plcp_delta_write(struct file *file, 2251 const char __user *user_buf, 2252 size_t count, loff_t *ppos) { 2253 2254 struct iwl_priv *priv = file->private_data; 2255 char buf[8]; 2256 int buf_size; 2257 int plcp; 2258 2259 memset(buf, 0, sizeof(buf)); 2260 buf_size = min(count, sizeof(buf) - 1); 2261 if (copy_from_user(buf, user_buf, buf_size)) 2262 return -EFAULT; 2263 if (sscanf(buf, "%d", &plcp) != 1) 2264 return -EINVAL; 2265 if ((plcp < IWL_MAX_PLCP_ERR_THRESHOLD_MIN) || 2266 (plcp > IWL_MAX_PLCP_ERR_THRESHOLD_MAX)) 2267 cfg(priv)->base_params->plcp_delta_threshold = 2268 IWL_MAX_PLCP_ERR_THRESHOLD_DISABLE; 2269 else 2270 cfg(priv)->base_params->plcp_delta_threshold = plcp; 2271 return count; 2272} 2273 2274static ssize_t iwl_dbgfs_force_reset_read(struct file *file, 2275 char __user *user_buf, 2276 size_t count, loff_t *ppos) 2277{ 2278 struct iwl_priv *priv = file->private_data; 2279 int i, pos = 0; 2280 char buf[300]; 2281 const size_t bufsz = sizeof(buf); 2282 struct iwl_force_reset *force_reset; 2283 2284 for (i = 0; i < IWL_MAX_FORCE_RESET; i++) { 2285 force_reset = &priv->force_reset[i]; 2286 pos += scnprintf(buf + pos, bufsz - pos, 2287 "Force reset method %d\n", i); 2288 pos += scnprintf(buf + pos, bufsz - pos, 2289 "\tnumber of reset request: %d\n", 2290 force_reset->reset_request_count); 2291 pos += scnprintf(buf + pos, bufsz - pos, 2292 "\tnumber of reset request success: %d\n", 2293 force_reset->reset_success_count); 2294 pos += scnprintf(buf + pos, bufsz - pos, 2295 "\tnumber of reset request reject: %d\n", 2296 force_reset->reset_reject_count); 2297 pos += scnprintf(buf + pos, bufsz - pos, 2298 "\treset duration: %lu\n", 2299 force_reset->reset_duration); 2300 } 2301 return simple_read_from_buffer(user_buf, count, ppos, buf, pos); 2302} 2303 2304static ssize_t iwl_dbgfs_force_reset_write(struct file *file, 2305 const char __user *user_buf, 2306 size_t count, loff_t *ppos) { 2307 2308 struct iwl_priv *priv = file->private_data; 2309 char buf[8]; 2310 int buf_size; 2311 int reset, ret; 2312 2313 memset(buf, 0, sizeof(buf)); 2314 buf_size = min(count, sizeof(buf) - 1); 2315 if (copy_from_user(buf, user_buf, buf_size)) 2316 return -EFAULT; 2317 if (sscanf(buf, "%d", &reset) != 1) 2318 return -EINVAL; 2319 switch (reset) { 2320 case IWL_RF_RESET: 2321 case IWL_FW_RESET: 2322 ret = iwl_force_reset(priv, reset, true); 2323 break; 2324 default: 2325 return -EINVAL; 2326 } 2327 return ret ? ret : count; 2328} 2329 2330static ssize_t iwl_dbgfs_txfifo_flush_write(struct file *file, 2331 const char __user *user_buf, 2332 size_t count, loff_t *ppos) { 2333 2334 struct iwl_priv *priv = file->private_data; 2335 char buf[8]; 2336 int buf_size; 2337 int flush; 2338 2339 memset(buf, 0, sizeof(buf)); 2340 buf_size = min(count, sizeof(buf) - 1); 2341 if (copy_from_user(buf, user_buf, buf_size)) 2342 return -EFAULT; 2343 if (sscanf(buf, "%d", &flush) != 1) 2344 return -EINVAL; 2345 2346 if (iwl_is_rfkill(priv->shrd)) 2347 return -EFAULT; 2348 2349 iwlagn_dev_txfifo_flush(priv, IWL_DROP_ALL); 2350 2351 return count; 2352} 2353 2354static ssize_t iwl_dbgfs_wd_timeout_write(struct file *file, 2355 const char __user *user_buf, 2356 size_t count, loff_t *ppos) 2357{ 2358 struct iwl_priv *priv = file->private_data; 2359 char buf[8]; 2360 int buf_size; 2361 int timeout; 2362 2363 memset(buf, 0, sizeof(buf)); 2364 buf_size = min(count, sizeof(buf) - 1); 2365 if (copy_from_user(buf, user_buf, buf_size)) 2366 return -EFAULT; 2367 if (sscanf(buf, "%d", &timeout) != 1) 2368 return -EINVAL; 2369 if (timeout < 0 || timeout > IWL_MAX_WD_TIMEOUT) 2370 timeout = IWL_DEF_WD_TIMEOUT; 2371 2372 cfg(priv)->base_params->wd_timeout = timeout; 2373 iwl_setup_watchdog(priv); 2374 return count; 2375} 2376 2377static ssize_t iwl_dbgfs_bt_traffic_read(struct file *file, 2378 char __user *user_buf, 2379 size_t count, loff_t *ppos) { 2380 2381 struct iwl_priv *priv = (struct iwl_priv *)file->private_data; 2382 int pos = 0; 2383 char buf[200]; 2384 const size_t bufsz = sizeof(buf); 2385 2386 if (!priv->bt_enable_flag) { 2387 pos += scnprintf(buf + pos, bufsz - pos, "BT coex disabled\n"); 2388 return simple_read_from_buffer(user_buf, count, ppos, buf, pos); 2389 } 2390 pos += scnprintf(buf + pos, bufsz - pos, "BT enable flag: 0x%x\n", 2391 priv->bt_enable_flag); 2392 pos += scnprintf(buf + pos, bufsz - pos, "BT in %s mode\n", 2393 priv->bt_full_concurrent ? "full concurrency" : "3-wire"); 2394 pos += scnprintf(buf + pos, bufsz - pos, "BT status: %s, " 2395 "last traffic notif: %d\n", 2396 priv->bt_status ? "On" : "Off", priv->last_bt_traffic_load); 2397 pos += scnprintf(buf + pos, bufsz - pos, "ch_announcement: %d, " 2398 "kill_ack_mask: %x, kill_cts_mask: %x\n", 2399 priv->bt_ch_announce, priv->kill_ack_mask, 2400 priv->kill_cts_mask); 2401 2402 pos += scnprintf(buf + pos, bufsz - pos, "bluetooth traffic load: "); 2403 switch (priv->bt_traffic_load) { 2404 case IWL_BT_COEX_TRAFFIC_LOAD_CONTINUOUS: 2405 pos += scnprintf(buf + pos, bufsz - pos, "Continuous\n"); 2406 break; 2407 case IWL_BT_COEX_TRAFFIC_LOAD_HIGH: 2408 pos += scnprintf(buf + pos, bufsz - pos, "High\n"); 2409 break; 2410 case IWL_BT_COEX_TRAFFIC_LOAD_LOW: 2411 pos += scnprintf(buf + pos, bufsz - pos, "Low\n"); 2412 break; 2413 case IWL_BT_COEX_TRAFFIC_LOAD_NONE: 2414 default: 2415 pos += scnprintf(buf + pos, bufsz - pos, "None\n"); 2416 break; 2417 } 2418 2419 return simple_read_from_buffer(user_buf, count, ppos, buf, pos); 2420} 2421 2422static ssize_t iwl_dbgfs_protection_mode_read(struct file *file, 2423 char __user *user_buf, 2424 size_t count, loff_t *ppos) 2425{ 2426 struct iwl_priv *priv = (struct iwl_priv *)file->private_data; 2427 2428 int pos = 0; 2429 char buf[40]; 2430 const size_t bufsz = sizeof(buf); 2431 2432 if (cfg(priv)->ht_params) 2433 pos += scnprintf(buf + pos, bufsz - pos, 2434 "use %s for aggregation\n", 2435 (cfg(priv)->ht_params->use_rts_for_aggregation) ? 2436 "rts/cts" : "cts-to-self"); 2437 else 2438 pos += scnprintf(buf + pos, bufsz - pos, "N/A"); 2439 2440 return simple_read_from_buffer(user_buf, count, ppos, buf, pos); 2441} 2442 2443static ssize_t iwl_dbgfs_protection_mode_write(struct file *file, 2444 const char __user *user_buf, 2445 size_t count, loff_t *ppos) { 2446 2447 struct iwl_priv *priv = file->private_data; 2448 char buf[8]; 2449 int buf_size; 2450 int rts; 2451 2452 if (!cfg(priv)->ht_params) 2453 return -EINVAL; 2454 2455 memset(buf, 0, sizeof(buf)); 2456 buf_size = min(count, sizeof(buf) - 1); 2457 if (copy_from_user(buf, user_buf, buf_size)) 2458 return -EFAULT; 2459 if (sscanf(buf, "%d", &rts) != 1) 2460 return -EINVAL; 2461 if (rts) 2462 cfg(priv)->ht_params->use_rts_for_aggregation = true; 2463 else 2464 cfg(priv)->ht_params->use_rts_for_aggregation = false; 2465 return count; 2466} 2467 2468static ssize_t iwl_dbgfs_echo_test_write(struct file *file, 2469 const char __user *user_buf, 2470 size_t count, loff_t *ppos) 2471{ 2472 struct iwl_priv *priv = file->private_data; 2473 char buf[8]; 2474 int buf_size; 2475 2476 memset(buf, 0, sizeof(buf)); 2477 buf_size = min(count, sizeof(buf) - 1); 2478 if (copy_from_user(buf, user_buf, buf_size)) 2479 return -EFAULT; 2480 2481 iwl_cmd_echo_test(priv); 2482 return count; 2483} 2484 2485DEBUGFS_READ_FILE_OPS(rx_statistics); 2486DEBUGFS_READ_FILE_OPS(tx_statistics); 2487DEBUGFS_READ_WRITE_FILE_OPS(traffic_log); 2488DEBUGFS_READ_FILE_OPS(ucode_rx_stats); 2489DEBUGFS_READ_FILE_OPS(ucode_tx_stats); 2490DEBUGFS_READ_FILE_OPS(ucode_general_stats); 2491DEBUGFS_READ_FILE_OPS(sensitivity); 2492DEBUGFS_READ_FILE_OPS(chain_noise); 2493DEBUGFS_READ_FILE_OPS(power_save_status); 2494DEBUGFS_WRITE_FILE_OPS(clear_ucode_statistics); 2495DEBUGFS_WRITE_FILE_OPS(clear_traffic_statistics); 2496DEBUGFS_READ_WRITE_FILE_OPS(ucode_tracing); 2497DEBUGFS_READ_WRITE_FILE_OPS(missed_beacon); 2498DEBUGFS_READ_WRITE_FILE_OPS(plcp_delta); 2499DEBUGFS_READ_WRITE_FILE_OPS(force_reset); 2500DEBUGFS_READ_FILE_OPS(rxon_flags); 2501DEBUGFS_READ_FILE_OPS(rxon_filter_flags); 2502DEBUGFS_WRITE_FILE_OPS(txfifo_flush); 2503DEBUGFS_READ_FILE_OPS(ucode_bt_stats); 2504DEBUGFS_WRITE_FILE_OPS(wd_timeout); 2505DEBUGFS_READ_FILE_OPS(bt_traffic); 2506DEBUGFS_READ_WRITE_FILE_OPS(protection_mode); 2507DEBUGFS_READ_FILE_OPS(reply_tx_error); 2508DEBUGFS_WRITE_FILE_OPS(echo_test); 2509 2510/* 2511 * Create the debugfs files and directories 2512 * 2513 */ 2514int iwl_dbgfs_register(struct iwl_priv *priv, const char *name) 2515{ 2516 struct dentry *phyd = priv->hw->wiphy->debugfsdir; 2517 struct dentry *dir_drv, *dir_data, *dir_rf, *dir_debug; 2518 2519 dir_drv = debugfs_create_dir(name, phyd); 2520 if (!dir_drv) 2521 return -ENOMEM; 2522 2523 priv->debugfs_dir = dir_drv; 2524 2525 dir_data = debugfs_create_dir("data", dir_drv); 2526 if (!dir_data) 2527 goto err; 2528 dir_rf = debugfs_create_dir("rf", dir_drv); 2529 if (!dir_rf) 2530 goto err; 2531 dir_debug = debugfs_create_dir("debug", dir_drv); 2532 if (!dir_debug) 2533 goto err; 2534 2535 DEBUGFS_ADD_FILE(nvm, dir_data, S_IRUSR); 2536 DEBUGFS_ADD_FILE(sram, dir_data, S_IWUSR | S_IRUSR); 2537 DEBUGFS_ADD_FILE(wowlan_sram, dir_data, S_IRUSR); 2538 DEBUGFS_ADD_FILE(stations, dir_data, S_IRUSR); 2539 DEBUGFS_ADD_FILE(channels, dir_data, S_IRUSR); 2540 DEBUGFS_ADD_FILE(status, dir_data, S_IRUSR); 2541 DEBUGFS_ADD_FILE(rx_handlers, dir_data, S_IWUSR | S_IRUSR); 2542 DEBUGFS_ADD_FILE(qos, dir_data, S_IRUSR); 2543 DEBUGFS_ADD_FILE(sleep_level_override, dir_data, S_IWUSR | S_IRUSR); 2544 DEBUGFS_ADD_FILE(current_sleep_command, dir_data, S_IRUSR); 2545 DEBUGFS_ADD_FILE(thermal_throttling, dir_data, S_IRUSR); 2546 DEBUGFS_ADD_FILE(disable_ht40, dir_data, S_IWUSR | S_IRUSR); 2547 DEBUGFS_ADD_FILE(temperature, dir_data, S_IRUSR); 2548 2549 DEBUGFS_ADD_FILE(rx_statistics, dir_debug, S_IRUSR); 2550 DEBUGFS_ADD_FILE(tx_statistics, dir_debug, S_IRUSR); 2551 DEBUGFS_ADD_FILE(traffic_log, dir_debug, S_IWUSR | S_IRUSR); 2552 DEBUGFS_ADD_FILE(power_save_status, dir_debug, S_IRUSR); 2553 DEBUGFS_ADD_FILE(clear_ucode_statistics, dir_debug, S_IWUSR); 2554 DEBUGFS_ADD_FILE(clear_traffic_statistics, dir_debug, S_IWUSR); 2555 DEBUGFS_ADD_FILE(missed_beacon, dir_debug, S_IWUSR); 2556 DEBUGFS_ADD_FILE(plcp_delta, dir_debug, S_IWUSR | S_IRUSR); 2557 DEBUGFS_ADD_FILE(force_reset, dir_debug, S_IWUSR | S_IRUSR); 2558 DEBUGFS_ADD_FILE(ucode_rx_stats, dir_debug, S_IRUSR); 2559 DEBUGFS_ADD_FILE(ucode_tx_stats, dir_debug, S_IRUSR); 2560 DEBUGFS_ADD_FILE(ucode_general_stats, dir_debug, S_IRUSR); 2561 DEBUGFS_ADD_FILE(txfifo_flush, dir_debug, S_IWUSR); 2562 DEBUGFS_ADD_FILE(protection_mode, dir_debug, S_IWUSR | S_IRUSR); 2563 DEBUGFS_ADD_FILE(sensitivity, dir_debug, S_IRUSR); 2564 DEBUGFS_ADD_FILE(chain_noise, dir_debug, S_IRUSR); 2565 DEBUGFS_ADD_FILE(ucode_tracing, dir_debug, S_IWUSR | S_IRUSR); 2566 DEBUGFS_ADD_FILE(ucode_bt_stats, dir_debug, S_IRUSR); 2567 DEBUGFS_ADD_FILE(reply_tx_error, dir_debug, S_IRUSR); 2568 DEBUGFS_ADD_FILE(rxon_flags, dir_debug, S_IWUSR); 2569 DEBUGFS_ADD_FILE(rxon_filter_flags, dir_debug, S_IWUSR); 2570 DEBUGFS_ADD_FILE(wd_timeout, dir_debug, S_IWUSR); 2571 DEBUGFS_ADD_FILE(echo_test, dir_debug, S_IWUSR); 2572 if (iwl_advanced_bt_coexist(priv)) 2573 DEBUGFS_ADD_FILE(bt_traffic, dir_debug, S_IRUSR); 2574 2575 DEBUGFS_ADD_BOOL(disable_sensitivity, dir_rf, 2576 &priv->disable_sens_cal); 2577 DEBUGFS_ADD_BOOL(disable_chain_noise, dir_rf, 2578 &priv->disable_chain_noise_cal); 2579 2580 if (iwl_trans_dbgfs_register(trans(priv), dir_debug)) 2581 goto err; 2582 return 0; 2583 2584err: 2585 IWL_ERR(priv, "Can't create the debugfs directory\n"); 2586 iwl_dbgfs_unregister(priv); 2587 return -ENOMEM; 2588} 2589 2590/** 2591 * Remove the debugfs files and directories 2592 * 2593 */ 2594void iwl_dbgfs_unregister(struct iwl_priv *priv) 2595{ 2596 if (!priv->debugfs_dir) 2597 return; 2598 2599 debugfs_remove_recursive(priv->debugfs_dir); 2600 priv->debugfs_dir = NULL; 2601} 2602