1 /* 2 * Copyright (c) 2008-2011 Atheros Communications Inc. 3 * 4 * Permission to use, copy, modify, and/or distribute this software for any 5 * purpose with or without fee is hereby granted, provided that the above 6 * copyright notice and this permission notice appear in all copies. 7 * 8 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 9 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 10 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 11 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 12 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 13 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 14 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 15 */ 16 17 #include <linux/slab.h> 18 #include <linux/vmalloc.h> 19 #include <linux/export.h> 20 #include <asm/unaligned.h> 21 22 #include "ath9k.h" 23 24 #define REG_WRITE_D(_ah, _reg, _val) \ 25 ath9k_hw_common(_ah)->ops->write((_ah), (_val), (_reg)) 26 #define REG_READ_D(_ah, _reg) \ 27 ath9k_hw_common(_ah)->ops->read((_ah), (_reg)) 28 29 30 static ssize_t ath9k_debugfs_read_buf(struct file *file, char __user *user_buf, 31 size_t count, loff_t *ppos) 32 { 33 u8 *buf = file->private_data; 34 return simple_read_from_buffer(user_buf, count, ppos, buf, strlen(buf)); 35 } 36 37 static int ath9k_debugfs_release_buf(struct inode *inode, struct file *file) 38 { 39 vfree(file->private_data); 40 return 0; 41 } 42 43 #ifdef CONFIG_ATH_DEBUG 44 45 static ssize_t read_file_debug(struct file *file, char __user *user_buf, 46 size_t count, loff_t *ppos) 47 { 48 struct ath_softc *sc = file->private_data; 49 struct ath_common *common = ath9k_hw_common(sc->sc_ah); 50 char buf[32]; 51 unsigned int len; 52 53 len = sprintf(buf, "0x%08x\n", common->debug_mask); 54 return simple_read_from_buffer(user_buf, count, ppos, buf, len); 55 } 56 57 static ssize_t write_file_debug(struct file *file, const char __user *user_buf, 58 size_t count, loff_t *ppos) 59 { 60 struct ath_softc *sc = file->private_data; 61 struct ath_common *common = ath9k_hw_common(sc->sc_ah); 62 unsigned long mask; 63 char buf[32]; 64 ssize_t len; 65 66 len = min(count, sizeof(buf) - 1); 67 if (copy_from_user(buf, user_buf, len)) 68 return -EFAULT; 69 70 buf[len] = '\0'; 71 if (strict_strtoul(buf, 0, &mask)) 72 return -EINVAL; 73 74 common->debug_mask = mask; 75 return count; 76 } 77 78 static const struct file_operations fops_debug = { 79 .read = read_file_debug, 80 .write = write_file_debug, 81 .open = simple_open, 82 .owner = THIS_MODULE, 83 .llseek = default_llseek, 84 }; 85 86 #endif 87 88 #define DMA_BUF_LEN 1024 89 90 static ssize_t read_file_tx_chainmask(struct file *file, char __user *user_buf, 91 size_t count, loff_t *ppos) 92 { 93 struct ath_softc *sc = file->private_data; 94 struct ath_hw *ah = sc->sc_ah; 95 char buf[32]; 96 unsigned int len; 97 98 len = sprintf(buf, "0x%08x\n", ah->txchainmask); 99 return simple_read_from_buffer(user_buf, count, ppos, buf, len); 100 } 101 102 static ssize_t write_file_tx_chainmask(struct file *file, const char __user *user_buf, 103 size_t count, loff_t *ppos) 104 { 105 struct ath_softc *sc = file->private_data; 106 struct ath_hw *ah = sc->sc_ah; 107 unsigned long mask; 108 char buf[32]; 109 ssize_t len; 110 111 len = min(count, sizeof(buf) - 1); 112 if (copy_from_user(buf, user_buf, len)) 113 return -EFAULT; 114 115 buf[len] = '\0'; 116 if (strict_strtoul(buf, 0, &mask)) 117 return -EINVAL; 118 119 ah->txchainmask = mask; 120 ah->caps.tx_chainmask = mask; 121 return count; 122 } 123 124 static const struct file_operations fops_tx_chainmask = { 125 .read = read_file_tx_chainmask, 126 .write = write_file_tx_chainmask, 127 .open = simple_open, 128 .owner = THIS_MODULE, 129 .llseek = default_llseek, 130 }; 131 132 133 static ssize_t read_file_rx_chainmask(struct file *file, char __user *user_buf, 134 size_t count, loff_t *ppos) 135 { 136 struct ath_softc *sc = file->private_data; 137 struct ath_hw *ah = sc->sc_ah; 138 char buf[32]; 139 unsigned int len; 140 141 len = sprintf(buf, "0x%08x\n", ah->rxchainmask); 142 return simple_read_from_buffer(user_buf, count, ppos, buf, len); 143 } 144 145 static ssize_t write_file_rx_chainmask(struct file *file, const char __user *user_buf, 146 size_t count, loff_t *ppos) 147 { 148 struct ath_softc *sc = file->private_data; 149 struct ath_hw *ah = sc->sc_ah; 150 unsigned long mask; 151 char buf[32]; 152 ssize_t len; 153 154 len = min(count, sizeof(buf) - 1); 155 if (copy_from_user(buf, user_buf, len)) 156 return -EFAULT; 157 158 buf[len] = '\0'; 159 if (strict_strtoul(buf, 0, &mask)) 160 return -EINVAL; 161 162 ah->rxchainmask = mask; 163 ah->caps.rx_chainmask = mask; 164 return count; 165 } 166 167 static const struct file_operations fops_rx_chainmask = { 168 .read = read_file_rx_chainmask, 169 .write = write_file_rx_chainmask, 170 .open = simple_open, 171 .owner = THIS_MODULE, 172 .llseek = default_llseek, 173 }; 174 175 static ssize_t read_file_disable_ani(struct file *file, char __user *user_buf, 176 size_t count, loff_t *ppos) 177 { 178 struct ath_softc *sc = file->private_data; 179 struct ath_common *common = ath9k_hw_common(sc->sc_ah); 180 char buf[32]; 181 unsigned int len; 182 183 len = sprintf(buf, "%d\n", common->disable_ani); 184 return simple_read_from_buffer(user_buf, count, ppos, buf, len); 185 } 186 187 static ssize_t write_file_disable_ani(struct file *file, 188 const char __user *user_buf, 189 size_t count, loff_t *ppos) 190 { 191 struct ath_softc *sc = file->private_data; 192 struct ath_common *common = ath9k_hw_common(sc->sc_ah); 193 unsigned long disable_ani; 194 char buf[32]; 195 ssize_t len; 196 197 len = min(count, sizeof(buf) - 1); 198 if (copy_from_user(buf, user_buf, len)) 199 return -EFAULT; 200 201 buf[len] = '\0'; 202 if (strict_strtoul(buf, 0, &disable_ani)) 203 return -EINVAL; 204 205 common->disable_ani = !!disable_ani; 206 207 if (disable_ani) { 208 clear_bit(SC_OP_ANI_RUN, &sc->sc_flags); 209 ath_stop_ani(sc); 210 } else { 211 ath_check_ani(sc); 212 } 213 214 return count; 215 } 216 217 static const struct file_operations fops_disable_ani = { 218 .read = read_file_disable_ani, 219 .write = write_file_disable_ani, 220 .open = simple_open, 221 .owner = THIS_MODULE, 222 .llseek = default_llseek, 223 }; 224 225 static ssize_t read_file_ant_diversity(struct file *file, char __user *user_buf, 226 size_t count, loff_t *ppos) 227 { 228 struct ath_softc *sc = file->private_data; 229 struct ath_common *common = ath9k_hw_common(sc->sc_ah); 230 char buf[32]; 231 unsigned int len; 232 233 len = sprintf(buf, "%d\n", common->antenna_diversity); 234 return simple_read_from_buffer(user_buf, count, ppos, buf, len); 235 } 236 237 static ssize_t write_file_ant_diversity(struct file *file, 238 const char __user *user_buf, 239 size_t count, loff_t *ppos) 240 { 241 struct ath_softc *sc = file->private_data; 242 struct ath_common *common = ath9k_hw_common(sc->sc_ah); 243 unsigned long antenna_diversity; 244 char buf[32]; 245 ssize_t len; 246 247 len = min(count, sizeof(buf) - 1); 248 if (copy_from_user(buf, user_buf, len)) 249 return -EFAULT; 250 251 if (!AR_SREV_9565(sc->sc_ah)) 252 goto exit; 253 254 buf[len] = '\0'; 255 if (strict_strtoul(buf, 0, &antenna_diversity)) 256 return -EINVAL; 257 258 common->antenna_diversity = !!antenna_diversity; 259 ath9k_ps_wakeup(sc); 260 ath_ant_comb_update(sc); 261 ath_dbg(common, CONFIG, "Antenna diversity: %d\n", 262 common->antenna_diversity); 263 ath9k_ps_restore(sc); 264 exit: 265 return count; 266 } 267 268 static const struct file_operations fops_ant_diversity = { 269 .read = read_file_ant_diversity, 270 .write = write_file_ant_diversity, 271 .open = simple_open, 272 .owner = THIS_MODULE, 273 .llseek = default_llseek, 274 }; 275 276 static ssize_t read_file_dma(struct file *file, char __user *user_buf, 277 size_t count, loff_t *ppos) 278 { 279 struct ath_softc *sc = file->private_data; 280 struct ath_hw *ah = sc->sc_ah; 281 char *buf; 282 int retval; 283 unsigned int len = 0; 284 u32 val[ATH9K_NUM_DMA_DEBUG_REGS]; 285 int i, qcuOffset = 0, dcuOffset = 0; 286 u32 *qcuBase = &val[0], *dcuBase = &val[4]; 287 288 buf = kmalloc(DMA_BUF_LEN, GFP_KERNEL); 289 if (!buf) 290 return -ENOMEM; 291 292 ath9k_ps_wakeup(sc); 293 294 REG_WRITE_D(ah, AR_MACMISC, 295 ((AR_MACMISC_DMA_OBS_LINE_8 << AR_MACMISC_DMA_OBS_S) | 296 (AR_MACMISC_MISC_OBS_BUS_1 << 297 AR_MACMISC_MISC_OBS_BUS_MSB_S))); 298 299 len += snprintf(buf + len, DMA_BUF_LEN - len, 300 "Raw DMA Debug values:\n"); 301 302 for (i = 0; i < ATH9K_NUM_DMA_DEBUG_REGS; i++) { 303 if (i % 4 == 0) 304 len += snprintf(buf + len, DMA_BUF_LEN - len, "\n"); 305 306 val[i] = REG_READ_D(ah, AR_DMADBG_0 + (i * sizeof(u32))); 307 len += snprintf(buf + len, DMA_BUF_LEN - len, "%d: %08x ", 308 i, val[i]); 309 } 310 311 len += snprintf(buf + len, DMA_BUF_LEN - len, "\n\n"); 312 len += snprintf(buf + len, DMA_BUF_LEN - len, 313 "Num QCU: chain_st fsp_ok fsp_st DCU: chain_st\n"); 314 315 for (i = 0; i < ATH9K_NUM_QUEUES; i++, qcuOffset += 4, dcuOffset += 5) { 316 if (i == 8) { 317 qcuOffset = 0; 318 qcuBase++; 319 } 320 321 if (i == 6) { 322 dcuOffset = 0; 323 dcuBase++; 324 } 325 326 len += snprintf(buf + len, DMA_BUF_LEN - len, 327 "%2d %2x %1x %2x %2x\n", 328 i, (*qcuBase & (0x7 << qcuOffset)) >> qcuOffset, 329 (*qcuBase & (0x8 << qcuOffset)) >> (qcuOffset + 3), 330 val[2] & (0x7 << (i * 3)) >> (i * 3), 331 (*dcuBase & (0x1f << dcuOffset)) >> dcuOffset); 332 } 333 334 len += snprintf(buf + len, DMA_BUF_LEN - len, "\n"); 335 336 len += snprintf(buf + len, DMA_BUF_LEN - len, 337 "qcu_stitch state: %2x qcu_fetch state: %2x\n", 338 (val[3] & 0x003c0000) >> 18, (val[3] & 0x03c00000) >> 22); 339 len += snprintf(buf + len, DMA_BUF_LEN - len, 340 "qcu_complete state: %2x dcu_complete state: %2x\n", 341 (val[3] & 0x1c000000) >> 26, (val[6] & 0x3)); 342 len += snprintf(buf + len, DMA_BUF_LEN - len, 343 "dcu_arb state: %2x dcu_fp state: %2x\n", 344 (val[5] & 0x06000000) >> 25, (val[5] & 0x38000000) >> 27); 345 len += snprintf(buf + len, DMA_BUF_LEN - len, 346 "chan_idle_dur: %3d chan_idle_dur_valid: %1d\n", 347 (val[6] & 0x000003fc) >> 2, (val[6] & 0x00000400) >> 10); 348 len += snprintf(buf + len, DMA_BUF_LEN - len, 349 "txfifo_valid_0: %1d txfifo_valid_1: %1d\n", 350 (val[6] & 0x00000800) >> 11, (val[6] & 0x00001000) >> 12); 351 len += snprintf(buf + len, DMA_BUF_LEN - len, 352 "txfifo_dcu_num_0: %2d txfifo_dcu_num_1: %2d\n", 353 (val[6] & 0x0001e000) >> 13, (val[6] & 0x001e0000) >> 17); 354 355 len += snprintf(buf + len, DMA_BUF_LEN - len, "pcu observe: 0x%x\n", 356 REG_READ_D(ah, AR_OBS_BUS_1)); 357 len += snprintf(buf + len, DMA_BUF_LEN - len, 358 "AR_CR: 0x%x\n", REG_READ_D(ah, AR_CR)); 359 360 ath9k_ps_restore(sc); 361 362 if (len > DMA_BUF_LEN) 363 len = DMA_BUF_LEN; 364 365 retval = simple_read_from_buffer(user_buf, count, ppos, buf, len); 366 kfree(buf); 367 return retval; 368 } 369 370 static const struct file_operations fops_dma = { 371 .read = read_file_dma, 372 .open = simple_open, 373 .owner = THIS_MODULE, 374 .llseek = default_llseek, 375 }; 376 377 378 void ath_debug_stat_interrupt(struct ath_softc *sc, enum ath9k_int status) 379 { 380 if (status) 381 sc->debug.stats.istats.total++; 382 if (sc->sc_ah->caps.hw_caps & ATH9K_HW_CAP_EDMA) { 383 if (status & ATH9K_INT_RXLP) 384 sc->debug.stats.istats.rxlp++; 385 if (status & ATH9K_INT_RXHP) 386 sc->debug.stats.istats.rxhp++; 387 if (status & ATH9K_INT_BB_WATCHDOG) 388 sc->debug.stats.istats.bb_watchdog++; 389 } else { 390 if (status & ATH9K_INT_RX) 391 sc->debug.stats.istats.rxok++; 392 } 393 if (status & ATH9K_INT_RXEOL) 394 sc->debug.stats.istats.rxeol++; 395 if (status & ATH9K_INT_RXORN) 396 sc->debug.stats.istats.rxorn++; 397 if (status & ATH9K_INT_TX) 398 sc->debug.stats.istats.txok++; 399 if (status & ATH9K_INT_TXURN) 400 sc->debug.stats.istats.txurn++; 401 if (status & ATH9K_INT_RXPHY) 402 sc->debug.stats.istats.rxphyerr++; 403 if (status & ATH9K_INT_RXKCM) 404 sc->debug.stats.istats.rx_keycache_miss++; 405 if (status & ATH9K_INT_SWBA) 406 sc->debug.stats.istats.swba++; 407 if (status & ATH9K_INT_BMISS) 408 sc->debug.stats.istats.bmiss++; 409 if (status & ATH9K_INT_BNR) 410 sc->debug.stats.istats.bnr++; 411 if (status & ATH9K_INT_CST) 412 sc->debug.stats.istats.cst++; 413 if (status & ATH9K_INT_GTT) 414 sc->debug.stats.istats.gtt++; 415 if (status & ATH9K_INT_TIM) 416 sc->debug.stats.istats.tim++; 417 if (status & ATH9K_INT_CABEND) 418 sc->debug.stats.istats.cabend++; 419 if (status & ATH9K_INT_DTIMSYNC) 420 sc->debug.stats.istats.dtimsync++; 421 if (status & ATH9K_INT_DTIM) 422 sc->debug.stats.istats.dtim++; 423 if (status & ATH9K_INT_TSFOOR) 424 sc->debug.stats.istats.tsfoor++; 425 if (status & ATH9K_INT_MCI) 426 sc->debug.stats.istats.mci++; 427 if (status & ATH9K_INT_GENTIMER) 428 sc->debug.stats.istats.gen_timer++; 429 } 430 431 static ssize_t read_file_interrupt(struct file *file, char __user *user_buf, 432 size_t count, loff_t *ppos) 433 { 434 struct ath_softc *sc = file->private_data; 435 unsigned int len = 0; 436 int rv; 437 int mxlen = 4000; 438 char *buf = kmalloc(mxlen, GFP_KERNEL); 439 if (!buf) 440 return -ENOMEM; 441 442 #define PR_IS(a, s) \ 443 do { \ 444 len += snprintf(buf + len, mxlen - len, \ 445 "%21s: %10u\n", a, \ 446 sc->debug.stats.istats.s); \ 447 } while (0) 448 449 if (sc->sc_ah->caps.hw_caps & ATH9K_HW_CAP_EDMA) { 450 PR_IS("RXLP", rxlp); 451 PR_IS("RXHP", rxhp); 452 PR_IS("WATHDOG", bb_watchdog); 453 } else { 454 PR_IS("RX", rxok); 455 } 456 PR_IS("RXEOL", rxeol); 457 PR_IS("RXORN", rxorn); 458 PR_IS("TX", txok); 459 PR_IS("TXURN", txurn); 460 PR_IS("MIB", mib); 461 PR_IS("RXPHY", rxphyerr); 462 PR_IS("RXKCM", rx_keycache_miss); 463 PR_IS("SWBA", swba); 464 PR_IS("BMISS", bmiss); 465 PR_IS("BNR", bnr); 466 PR_IS("CST", cst); 467 PR_IS("GTT", gtt); 468 PR_IS("TIM", tim); 469 PR_IS("CABEND", cabend); 470 PR_IS("DTIMSYNC", dtimsync); 471 PR_IS("DTIM", dtim); 472 PR_IS("TSFOOR", tsfoor); 473 PR_IS("MCI", mci); 474 PR_IS("GENTIMER", gen_timer); 475 PR_IS("TOTAL", total); 476 477 len += snprintf(buf + len, mxlen - len, 478 "SYNC_CAUSE stats:\n"); 479 480 PR_IS("Sync-All", sync_cause_all); 481 PR_IS("RTC-IRQ", sync_rtc_irq); 482 PR_IS("MAC-IRQ", sync_mac_irq); 483 PR_IS("EEPROM-Illegal-Access", eeprom_illegal_access); 484 PR_IS("APB-Timeout", apb_timeout); 485 PR_IS("PCI-Mode-Conflict", pci_mode_conflict); 486 PR_IS("HOST1-Fatal", host1_fatal); 487 PR_IS("HOST1-Perr", host1_perr); 488 PR_IS("TRCV-FIFO-Perr", trcv_fifo_perr); 489 PR_IS("RADM-CPL-EP", radm_cpl_ep); 490 PR_IS("RADM-CPL-DLLP-Abort", radm_cpl_dllp_abort); 491 PR_IS("RADM-CPL-TLP-Abort", radm_cpl_tlp_abort); 492 PR_IS("RADM-CPL-ECRC-Err", radm_cpl_ecrc_err); 493 PR_IS("RADM-CPL-Timeout", radm_cpl_timeout); 494 PR_IS("Local-Bus-Timeout", local_timeout); 495 PR_IS("PM-Access", pm_access); 496 PR_IS("MAC-Awake", mac_awake); 497 PR_IS("MAC-Asleep", mac_asleep); 498 PR_IS("MAC-Sleep-Access", mac_sleep_access); 499 500 if (len > mxlen) 501 len = mxlen; 502 503 rv = simple_read_from_buffer(user_buf, count, ppos, buf, len); 504 kfree(buf); 505 return rv; 506 } 507 508 static const struct file_operations fops_interrupt = { 509 .read = read_file_interrupt, 510 .open = simple_open, 511 .owner = THIS_MODULE, 512 .llseek = default_llseek, 513 }; 514 515 static ssize_t read_file_xmit(struct file *file, char __user *user_buf, 516 size_t count, loff_t *ppos) 517 { 518 struct ath_softc *sc = file->private_data; 519 char *buf; 520 unsigned int len = 0, size = 2048; 521 ssize_t retval = 0; 522 523 buf = kzalloc(size, GFP_KERNEL); 524 if (buf == NULL) 525 return -ENOMEM; 526 527 len += sprintf(buf, "%30s %10s%10s%10s\n\n", 528 "BE", "BK", "VI", "VO"); 529 530 PR("MPDUs Queued: ", queued); 531 PR("MPDUs Completed: ", completed); 532 PR("MPDUs XRetried: ", xretries); 533 PR("Aggregates: ", a_aggr); 534 PR("AMPDUs Queued HW:", a_queued_hw); 535 PR("AMPDUs Queued SW:", a_queued_sw); 536 PR("AMPDUs Completed:", a_completed); 537 PR("AMPDUs Retried: ", a_retries); 538 PR("AMPDUs XRetried: ", a_xretries); 539 PR("FIFO Underrun: ", fifo_underrun); 540 PR("TXOP Exceeded: ", xtxop); 541 PR("TXTIMER Expiry: ", timer_exp); 542 PR("DESC CFG Error: ", desc_cfg_err); 543 PR("DATA Underrun: ", data_underrun); 544 PR("DELIM Underrun: ", delim_underrun); 545 PR("TX-Pkts-All: ", tx_pkts_all); 546 PR("TX-Bytes-All: ", tx_bytes_all); 547 PR("HW-put-tx-buf: ", puttxbuf); 548 PR("HW-tx-start: ", txstart); 549 PR("HW-tx-proc-desc: ", txprocdesc); 550 PR("TX-Failed: ", txfailed); 551 552 if (len > size) 553 len = size; 554 555 retval = simple_read_from_buffer(user_buf, count, ppos, buf, len); 556 kfree(buf); 557 558 return retval; 559 } 560 561 static ssize_t read_file_queues(struct file *file, char __user *user_buf, 562 size_t count, loff_t *ppos) 563 { 564 struct ath_softc *sc = file->private_data; 565 struct ath_txq *txq; 566 char *buf; 567 unsigned int len = 0, size = 1024; 568 ssize_t retval = 0; 569 int i; 570 char *qname[4] = {"VO", "VI", "BE", "BK"}; 571 572 buf = kzalloc(size, GFP_KERNEL); 573 if (buf == NULL) 574 return -ENOMEM; 575 576 for (i = 0; i < IEEE80211_NUM_ACS; i++) { 577 txq = sc->tx.txq_map[i]; 578 len += snprintf(buf + len, size - len, "(%s): ", qname[i]); 579 580 ath_txq_lock(sc, txq); 581 582 len += snprintf(buf + len, size - len, "%s: %d ", 583 "qnum", txq->axq_qnum); 584 len += snprintf(buf + len, size - len, "%s: %2d ", 585 "qdepth", txq->axq_depth); 586 len += snprintf(buf + len, size - len, "%s: %2d ", 587 "ampdu-depth", txq->axq_ampdu_depth); 588 len += snprintf(buf + len, size - len, "%s: %3d ", 589 "pending", txq->pending_frames); 590 len += snprintf(buf + len, size - len, "%s: %d\n", 591 "stopped", txq->stopped); 592 593 ath_txq_unlock(sc, txq); 594 } 595 596 if (len > size) 597 len = size; 598 599 retval = simple_read_from_buffer(user_buf, count, ppos, buf, len); 600 kfree(buf); 601 602 return retval; 603 } 604 605 static ssize_t read_file_misc(struct file *file, char __user *user_buf, 606 size_t count, loff_t *ppos) 607 { 608 struct ath_softc *sc = file->private_data; 609 struct ath_common *common = ath9k_hw_common(sc->sc_ah); 610 struct ieee80211_hw *hw = sc->hw; 611 struct ath9k_vif_iter_data iter_data; 612 char buf[512]; 613 unsigned int len = 0; 614 ssize_t retval = 0; 615 unsigned int reg; 616 u32 rxfilter; 617 618 len += snprintf(buf + len, sizeof(buf) - len, 619 "BSSID: %pM\n", common->curbssid); 620 len += snprintf(buf + len, sizeof(buf) - len, 621 "BSSID-MASK: %pM\n", common->bssidmask); 622 len += snprintf(buf + len, sizeof(buf) - len, 623 "OPMODE: %s\n", ath_opmode_to_string(sc->sc_ah->opmode)); 624 625 ath9k_ps_wakeup(sc); 626 rxfilter = ath9k_hw_getrxfilter(sc->sc_ah); 627 ath9k_ps_restore(sc); 628 629 len += snprintf(buf + len, sizeof(buf) - len, 630 "RXFILTER: 0x%x", rxfilter); 631 632 if (rxfilter & ATH9K_RX_FILTER_UCAST) 633 len += snprintf(buf + len, sizeof(buf) - len, " UCAST"); 634 if (rxfilter & ATH9K_RX_FILTER_MCAST) 635 len += snprintf(buf + len, sizeof(buf) - len, " MCAST"); 636 if (rxfilter & ATH9K_RX_FILTER_BCAST) 637 len += snprintf(buf + len, sizeof(buf) - len, " BCAST"); 638 if (rxfilter & ATH9K_RX_FILTER_CONTROL) 639 len += snprintf(buf + len, sizeof(buf) - len, " CONTROL"); 640 if (rxfilter & ATH9K_RX_FILTER_BEACON) 641 len += snprintf(buf + len, sizeof(buf) - len, " BEACON"); 642 if (rxfilter & ATH9K_RX_FILTER_PROM) 643 len += snprintf(buf + len, sizeof(buf) - len, " PROM"); 644 if (rxfilter & ATH9K_RX_FILTER_PROBEREQ) 645 len += snprintf(buf + len, sizeof(buf) - len, " PROBEREQ"); 646 if (rxfilter & ATH9K_RX_FILTER_PHYERR) 647 len += snprintf(buf + len, sizeof(buf) - len, " PHYERR"); 648 if (rxfilter & ATH9K_RX_FILTER_MYBEACON) 649 len += snprintf(buf + len, sizeof(buf) - len, " MYBEACON"); 650 if (rxfilter & ATH9K_RX_FILTER_COMP_BAR) 651 len += snprintf(buf + len, sizeof(buf) - len, " COMP_BAR"); 652 if (rxfilter & ATH9K_RX_FILTER_PSPOLL) 653 len += snprintf(buf + len, sizeof(buf) - len, " PSPOLL"); 654 if (rxfilter & ATH9K_RX_FILTER_PHYRADAR) 655 len += snprintf(buf + len, sizeof(buf) - len, " PHYRADAR"); 656 if (rxfilter & ATH9K_RX_FILTER_MCAST_BCAST_ALL) 657 len += snprintf(buf + len, sizeof(buf) - len, " MCAST_BCAST_ALL"); 658 if (rxfilter & ATH9K_RX_FILTER_CONTROL_WRAPPER) 659 len += snprintf(buf + len, sizeof(buf) - len, " CONTROL_WRAPPER"); 660 661 len += snprintf(buf + len, sizeof(buf) - len, "\n"); 662 663 reg = sc->sc_ah->imask; 664 665 len += snprintf(buf + len, sizeof(buf) - len, "INTERRUPT-MASK: 0x%x", reg); 666 667 if (reg & ATH9K_INT_SWBA) 668 len += snprintf(buf + len, sizeof(buf) - len, " SWBA"); 669 if (reg & ATH9K_INT_BMISS) 670 len += snprintf(buf + len, sizeof(buf) - len, " BMISS"); 671 if (reg & ATH9K_INT_CST) 672 len += snprintf(buf + len, sizeof(buf) - len, " CST"); 673 if (reg & ATH9K_INT_RX) 674 len += snprintf(buf + len, sizeof(buf) - len, " RX"); 675 if (reg & ATH9K_INT_RXHP) 676 len += snprintf(buf + len, sizeof(buf) - len, " RXHP"); 677 if (reg & ATH9K_INT_RXLP) 678 len += snprintf(buf + len, sizeof(buf) - len, " RXLP"); 679 if (reg & ATH9K_INT_BB_WATCHDOG) 680 len += snprintf(buf + len, sizeof(buf) - len, " BB_WATCHDOG"); 681 682 len += snprintf(buf + len, sizeof(buf) - len, "\n"); 683 684 ath9k_calculate_iter_data(hw, NULL, &iter_data); 685 686 len += snprintf(buf + len, sizeof(buf) - len, 687 "VIF-COUNTS: AP: %i STA: %i MESH: %i WDS: %i" 688 " ADHOC: %i TOTAL: %hi BEACON-VIF: %hi\n", 689 iter_data.naps, iter_data.nstations, iter_data.nmeshes, 690 iter_data.nwds, iter_data.nadhocs, 691 sc->nvifs, sc->nbcnvifs); 692 693 if (len > sizeof(buf)) 694 len = sizeof(buf); 695 696 retval = simple_read_from_buffer(user_buf, count, ppos, buf, len); 697 return retval; 698 } 699 700 static ssize_t read_file_reset(struct file *file, char __user *user_buf, 701 size_t count, loff_t *ppos) 702 { 703 struct ath_softc *sc = file->private_data; 704 char buf[512]; 705 unsigned int len = 0; 706 707 len += snprintf(buf + len, sizeof(buf) - len, 708 "%17s: %2d\n", "Baseband Hang", 709 sc->debug.stats.reset[RESET_TYPE_BB_HANG]); 710 len += snprintf(buf + len, sizeof(buf) - len, 711 "%17s: %2d\n", "Baseband Watchdog", 712 sc->debug.stats.reset[RESET_TYPE_BB_WATCHDOG]); 713 len += snprintf(buf + len, sizeof(buf) - len, 714 "%17s: %2d\n", "Fatal HW Error", 715 sc->debug.stats.reset[RESET_TYPE_FATAL_INT]); 716 len += snprintf(buf + len, sizeof(buf) - len, 717 "%17s: %2d\n", "TX HW error", 718 sc->debug.stats.reset[RESET_TYPE_TX_ERROR]); 719 len += snprintf(buf + len, sizeof(buf) - len, 720 "%17s: %2d\n", "TX Path Hang", 721 sc->debug.stats.reset[RESET_TYPE_TX_HANG]); 722 len += snprintf(buf + len, sizeof(buf) - len, 723 "%17s: %2d\n", "PLL RX Hang", 724 sc->debug.stats.reset[RESET_TYPE_PLL_HANG]); 725 len += snprintf(buf + len, sizeof(buf) - len, 726 "%17s: %2d\n", "MCI Reset", 727 sc->debug.stats.reset[RESET_TYPE_MCI]); 728 729 if (len > sizeof(buf)) 730 len = sizeof(buf); 731 732 return simple_read_from_buffer(user_buf, count, ppos, buf, len); 733 } 734 735 void ath_debug_stat_tx(struct ath_softc *sc, struct ath_buf *bf, 736 struct ath_tx_status *ts, struct ath_txq *txq, 737 unsigned int flags) 738 { 739 #define TX_SAMP_DBG(c) (sc->debug.bb_mac_samp[sc->debug.sampidx].ts\ 740 [sc->debug.tsidx].c) 741 int qnum = txq->axq_qnum; 742 743 TX_STAT_INC(qnum, tx_pkts_all); 744 sc->debug.stats.txstats[qnum].tx_bytes_all += bf->bf_mpdu->len; 745 746 if (bf_isampdu(bf)) { 747 if (flags & ATH_TX_ERROR) 748 TX_STAT_INC(qnum, a_xretries); 749 else 750 TX_STAT_INC(qnum, a_completed); 751 } else { 752 if (ts->ts_status & ATH9K_TXERR_XRETRY) 753 TX_STAT_INC(qnum, xretries); 754 else 755 TX_STAT_INC(qnum, completed); 756 } 757 758 if (ts->ts_status & ATH9K_TXERR_FIFO) 759 TX_STAT_INC(qnum, fifo_underrun); 760 if (ts->ts_status & ATH9K_TXERR_XTXOP) 761 TX_STAT_INC(qnum, xtxop); 762 if (ts->ts_status & ATH9K_TXERR_TIMER_EXPIRED) 763 TX_STAT_INC(qnum, timer_exp); 764 if (ts->ts_flags & ATH9K_TX_DESC_CFG_ERR) 765 TX_STAT_INC(qnum, desc_cfg_err); 766 if (ts->ts_flags & ATH9K_TX_DATA_UNDERRUN) 767 TX_STAT_INC(qnum, data_underrun); 768 if (ts->ts_flags & ATH9K_TX_DELIM_UNDERRUN) 769 TX_STAT_INC(qnum, delim_underrun); 770 771 #ifdef CONFIG_ATH9K_MAC_DEBUG 772 spin_lock(&sc->debug.samp_lock); 773 TX_SAMP_DBG(jiffies) = jiffies; 774 TX_SAMP_DBG(rssi_ctl0) = ts->ts_rssi_ctl0; 775 TX_SAMP_DBG(rssi_ctl1) = ts->ts_rssi_ctl1; 776 TX_SAMP_DBG(rssi_ctl2) = ts->ts_rssi_ctl2; 777 TX_SAMP_DBG(rssi_ext0) = ts->ts_rssi_ext0; 778 TX_SAMP_DBG(rssi_ext1) = ts->ts_rssi_ext1; 779 TX_SAMP_DBG(rssi_ext2) = ts->ts_rssi_ext2; 780 TX_SAMP_DBG(rateindex) = ts->ts_rateindex; 781 TX_SAMP_DBG(isok) = !!(ts->ts_status & ATH9K_TXERR_MASK); 782 TX_SAMP_DBG(rts_fail_cnt) = ts->ts_shortretry; 783 TX_SAMP_DBG(data_fail_cnt) = ts->ts_longretry; 784 TX_SAMP_DBG(rssi) = ts->ts_rssi; 785 TX_SAMP_DBG(tid) = ts->tid; 786 TX_SAMP_DBG(qid) = ts->qid; 787 788 if (ts->ts_flags & ATH9K_TX_BA) { 789 TX_SAMP_DBG(ba_low) = ts->ba_low; 790 TX_SAMP_DBG(ba_high) = ts->ba_high; 791 } else { 792 TX_SAMP_DBG(ba_low) = 0; 793 TX_SAMP_DBG(ba_high) = 0; 794 } 795 796 sc->debug.tsidx = (sc->debug.tsidx + 1) % ATH_DBG_MAX_SAMPLES; 797 spin_unlock(&sc->debug.samp_lock); 798 #endif 799 800 #undef TX_SAMP_DBG 801 } 802 803 static const struct file_operations fops_xmit = { 804 .read = read_file_xmit, 805 .open = simple_open, 806 .owner = THIS_MODULE, 807 .llseek = default_llseek, 808 }; 809 810 static const struct file_operations fops_queues = { 811 .read = read_file_queues, 812 .open = simple_open, 813 .owner = THIS_MODULE, 814 .llseek = default_llseek, 815 }; 816 817 static const struct file_operations fops_misc = { 818 .read = read_file_misc, 819 .open = simple_open, 820 .owner = THIS_MODULE, 821 .llseek = default_llseek, 822 }; 823 824 static const struct file_operations fops_reset = { 825 .read = read_file_reset, 826 .open = simple_open, 827 .owner = THIS_MODULE, 828 .llseek = default_llseek, 829 }; 830 831 static ssize_t read_file_recv(struct file *file, char __user *user_buf, 832 size_t count, loff_t *ppos) 833 { 834 #define PHY_ERR(s, p) \ 835 len += snprintf(buf + len, size - len, "%22s : %10u\n", s, \ 836 sc->debug.stats.rxstats.phy_err_stats[p]); 837 838 #define RXS_ERR(s, e) \ 839 do { \ 840 len += snprintf(buf + len, size - len, \ 841 "%22s : %10u\n", s, \ 842 sc->debug.stats.rxstats.e); \ 843 } while (0) 844 845 struct ath_softc *sc = file->private_data; 846 char *buf; 847 unsigned int len = 0, size = 1600; 848 ssize_t retval = 0; 849 850 buf = kzalloc(size, GFP_KERNEL); 851 if (buf == NULL) 852 return -ENOMEM; 853 854 RXS_ERR("CRC ERR", crc_err); 855 RXS_ERR("DECRYPT CRC ERR", decrypt_crc_err); 856 RXS_ERR("PHY ERR", phy_err); 857 RXS_ERR("MIC ERR", mic_err); 858 RXS_ERR("PRE-DELIM CRC ERR", pre_delim_crc_err); 859 RXS_ERR("POST-DELIM CRC ERR", post_delim_crc_err); 860 RXS_ERR("DECRYPT BUSY ERR", decrypt_busy_err); 861 RXS_ERR("RX-LENGTH-ERR", rx_len_err); 862 RXS_ERR("RX-OOM-ERR", rx_oom_err); 863 RXS_ERR("RX-RATE-ERR", rx_rate_err); 864 RXS_ERR("RX-DROP-RXFLUSH", rx_drop_rxflush); 865 RXS_ERR("RX-TOO-MANY-FRAGS", rx_too_many_frags_err); 866 867 PHY_ERR("UNDERRUN ERR", ATH9K_PHYERR_UNDERRUN); 868 PHY_ERR("TIMING ERR", ATH9K_PHYERR_TIMING); 869 PHY_ERR("PARITY ERR", ATH9K_PHYERR_PARITY); 870 PHY_ERR("RATE ERR", ATH9K_PHYERR_RATE); 871 PHY_ERR("LENGTH ERR", ATH9K_PHYERR_LENGTH); 872 PHY_ERR("RADAR ERR", ATH9K_PHYERR_RADAR); 873 PHY_ERR("SERVICE ERR", ATH9K_PHYERR_SERVICE); 874 PHY_ERR("TOR ERR", ATH9K_PHYERR_TOR); 875 PHY_ERR("OFDM-TIMING ERR", ATH9K_PHYERR_OFDM_TIMING); 876 PHY_ERR("OFDM-SIGNAL-PARITY ERR", ATH9K_PHYERR_OFDM_SIGNAL_PARITY); 877 PHY_ERR("OFDM-RATE ERR", ATH9K_PHYERR_OFDM_RATE_ILLEGAL); 878 PHY_ERR("OFDM-LENGTH ERR", ATH9K_PHYERR_OFDM_LENGTH_ILLEGAL); 879 PHY_ERR("OFDM-POWER-DROP ERR", ATH9K_PHYERR_OFDM_POWER_DROP); 880 PHY_ERR("OFDM-SERVICE ERR", ATH9K_PHYERR_OFDM_SERVICE); 881 PHY_ERR("OFDM-RESTART ERR", ATH9K_PHYERR_OFDM_RESTART); 882 PHY_ERR("FALSE-RADAR-EXT ERR", ATH9K_PHYERR_FALSE_RADAR_EXT); 883 PHY_ERR("CCK-TIMING ERR", ATH9K_PHYERR_CCK_TIMING); 884 PHY_ERR("CCK-HEADER-CRC ERR", ATH9K_PHYERR_CCK_HEADER_CRC); 885 PHY_ERR("CCK-RATE ERR", ATH9K_PHYERR_CCK_RATE_ILLEGAL); 886 PHY_ERR("CCK-SERVICE ERR", ATH9K_PHYERR_CCK_SERVICE); 887 PHY_ERR("CCK-RESTART ERR", ATH9K_PHYERR_CCK_RESTART); 888 PHY_ERR("CCK-LENGTH ERR", ATH9K_PHYERR_CCK_LENGTH_ILLEGAL); 889 PHY_ERR("CCK-POWER-DROP ERR", ATH9K_PHYERR_CCK_POWER_DROP); 890 PHY_ERR("HT-CRC ERR", ATH9K_PHYERR_HT_CRC_ERROR); 891 PHY_ERR("HT-LENGTH ERR", ATH9K_PHYERR_HT_LENGTH_ILLEGAL); 892 PHY_ERR("HT-RATE ERR", ATH9K_PHYERR_HT_RATE_ILLEGAL); 893 894 RXS_ERR("RX-Pkts-All", rx_pkts_all); 895 RXS_ERR("RX-Bytes-All", rx_bytes_all); 896 RXS_ERR("RX-Beacons", rx_beacons); 897 RXS_ERR("RX-Frags", rx_frags); 898 899 if (len > size) 900 len = size; 901 902 retval = simple_read_from_buffer(user_buf, count, ppos, buf, len); 903 kfree(buf); 904 905 return retval; 906 907 #undef RXS_ERR 908 #undef PHY_ERR 909 } 910 911 void ath_debug_stat_rx(struct ath_softc *sc, struct ath_rx_status *rs) 912 { 913 #define RX_PHY_ERR_INC(c) sc->debug.stats.rxstats.phy_err_stats[c]++ 914 #define RX_SAMP_DBG(c) (sc->debug.bb_mac_samp[sc->debug.sampidx].rs\ 915 [sc->debug.rsidx].c) 916 917 RX_STAT_INC(rx_pkts_all); 918 sc->debug.stats.rxstats.rx_bytes_all += rs->rs_datalen; 919 920 if (rs->rs_status & ATH9K_RXERR_CRC) 921 RX_STAT_INC(crc_err); 922 if (rs->rs_status & ATH9K_RXERR_DECRYPT) 923 RX_STAT_INC(decrypt_crc_err); 924 if (rs->rs_status & ATH9K_RXERR_MIC) 925 RX_STAT_INC(mic_err); 926 if (rs->rs_status & ATH9K_RX_DELIM_CRC_PRE) 927 RX_STAT_INC(pre_delim_crc_err); 928 if (rs->rs_status & ATH9K_RX_DELIM_CRC_POST) 929 RX_STAT_INC(post_delim_crc_err); 930 if (rs->rs_status & ATH9K_RX_DECRYPT_BUSY) 931 RX_STAT_INC(decrypt_busy_err); 932 933 if (rs->rs_status & ATH9K_RXERR_PHY) { 934 RX_STAT_INC(phy_err); 935 if (rs->rs_phyerr < ATH9K_PHYERR_MAX) 936 RX_PHY_ERR_INC(rs->rs_phyerr); 937 } 938 939 #ifdef CONFIG_ATH9K_MAC_DEBUG 940 spin_lock(&sc->debug.samp_lock); 941 RX_SAMP_DBG(jiffies) = jiffies; 942 RX_SAMP_DBG(rssi_ctl0) = rs->rs_rssi_ctl0; 943 RX_SAMP_DBG(rssi_ctl1) = rs->rs_rssi_ctl1; 944 RX_SAMP_DBG(rssi_ctl2) = rs->rs_rssi_ctl2; 945 RX_SAMP_DBG(rssi_ext0) = rs->rs_rssi_ext0; 946 RX_SAMP_DBG(rssi_ext1) = rs->rs_rssi_ext1; 947 RX_SAMP_DBG(rssi_ext2) = rs->rs_rssi_ext2; 948 RX_SAMP_DBG(antenna) = rs->rs_antenna; 949 RX_SAMP_DBG(rssi) = rs->rs_rssi; 950 RX_SAMP_DBG(rate) = rs->rs_rate; 951 RX_SAMP_DBG(is_mybeacon) = rs->is_mybeacon; 952 953 sc->debug.rsidx = (sc->debug.rsidx + 1) % ATH_DBG_MAX_SAMPLES; 954 spin_unlock(&sc->debug.samp_lock); 955 956 #endif 957 958 #undef RX_PHY_ERR_INC 959 #undef RX_SAMP_DBG 960 } 961 962 static const struct file_operations fops_recv = { 963 .read = read_file_recv, 964 .open = simple_open, 965 .owner = THIS_MODULE, 966 .llseek = default_llseek, 967 }; 968 969 static ssize_t read_file_regidx(struct file *file, char __user *user_buf, 970 size_t count, loff_t *ppos) 971 { 972 struct ath_softc *sc = file->private_data; 973 char buf[32]; 974 unsigned int len; 975 976 len = sprintf(buf, "0x%08x\n", sc->debug.regidx); 977 return simple_read_from_buffer(user_buf, count, ppos, buf, len); 978 } 979 980 static ssize_t write_file_regidx(struct file *file, const char __user *user_buf, 981 size_t count, loff_t *ppos) 982 { 983 struct ath_softc *sc = file->private_data; 984 unsigned long regidx; 985 char buf[32]; 986 ssize_t len; 987 988 len = min(count, sizeof(buf) - 1); 989 if (copy_from_user(buf, user_buf, len)) 990 return -EFAULT; 991 992 buf[len] = '\0'; 993 if (strict_strtoul(buf, 0, ®idx)) 994 return -EINVAL; 995 996 sc->debug.regidx = regidx; 997 return count; 998 } 999 1000 static const struct file_operations fops_regidx = { 1001 .read = read_file_regidx, 1002 .write = write_file_regidx, 1003 .open = simple_open, 1004 .owner = THIS_MODULE, 1005 .llseek = default_llseek, 1006 }; 1007 1008 static ssize_t read_file_regval(struct file *file, char __user *user_buf, 1009 size_t count, loff_t *ppos) 1010 { 1011 struct ath_softc *sc = file->private_data; 1012 struct ath_hw *ah = sc->sc_ah; 1013 char buf[32]; 1014 unsigned int len; 1015 u32 regval; 1016 1017 ath9k_ps_wakeup(sc); 1018 regval = REG_READ_D(ah, sc->debug.regidx); 1019 ath9k_ps_restore(sc); 1020 len = sprintf(buf, "0x%08x\n", regval); 1021 return simple_read_from_buffer(user_buf, count, ppos, buf, len); 1022 } 1023 1024 static ssize_t write_file_regval(struct file *file, const char __user *user_buf, 1025 size_t count, loff_t *ppos) 1026 { 1027 struct ath_softc *sc = file->private_data; 1028 struct ath_hw *ah = sc->sc_ah; 1029 unsigned long regval; 1030 char buf[32]; 1031 ssize_t len; 1032 1033 len = min(count, sizeof(buf) - 1); 1034 if (copy_from_user(buf, user_buf, len)) 1035 return -EFAULT; 1036 1037 buf[len] = '\0'; 1038 if (strict_strtoul(buf, 0, ®val)) 1039 return -EINVAL; 1040 1041 ath9k_ps_wakeup(sc); 1042 REG_WRITE_D(ah, sc->debug.regidx, regval); 1043 ath9k_ps_restore(sc); 1044 return count; 1045 } 1046 1047 static const struct file_operations fops_regval = { 1048 .read = read_file_regval, 1049 .write = write_file_regval, 1050 .open = simple_open, 1051 .owner = THIS_MODULE, 1052 .llseek = default_llseek, 1053 }; 1054 1055 #define REGDUMP_LINE_SIZE 20 1056 1057 static int open_file_regdump(struct inode *inode, struct file *file) 1058 { 1059 struct ath_softc *sc = inode->i_private; 1060 unsigned int len = 0; 1061 u8 *buf; 1062 int i; 1063 unsigned long num_regs, regdump_len, max_reg_offset; 1064 1065 max_reg_offset = AR_SREV_9300_20_OR_LATER(sc->sc_ah) ? 0x16bd4 : 0xb500; 1066 num_regs = max_reg_offset / 4 + 1; 1067 regdump_len = num_regs * REGDUMP_LINE_SIZE + 1; 1068 buf = vmalloc(regdump_len); 1069 if (!buf) 1070 return -ENOMEM; 1071 1072 ath9k_ps_wakeup(sc); 1073 for (i = 0; i < num_regs; i++) 1074 len += scnprintf(buf + len, regdump_len - len, 1075 "0x%06x 0x%08x\n", i << 2, REG_READ(sc->sc_ah, i << 2)); 1076 ath9k_ps_restore(sc); 1077 1078 file->private_data = buf; 1079 1080 return 0; 1081 } 1082 1083 static const struct file_operations fops_regdump = { 1084 .open = open_file_regdump, 1085 .read = ath9k_debugfs_read_buf, 1086 .release = ath9k_debugfs_release_buf, 1087 .owner = THIS_MODULE, 1088 .llseek = default_llseek,/* read accesses f_pos */ 1089 }; 1090 1091 static ssize_t read_file_dump_nfcal(struct file *file, char __user *user_buf, 1092 size_t count, loff_t *ppos) 1093 { 1094 struct ath_softc *sc = file->private_data; 1095 struct ath_hw *ah = sc->sc_ah; 1096 struct ath9k_nfcal_hist *h = sc->caldata.nfCalHist; 1097 struct ath_common *common = ath9k_hw_common(ah); 1098 struct ieee80211_conf *conf = &common->hw->conf; 1099 u32 len = 0, size = 1500; 1100 u32 i, j; 1101 ssize_t retval = 0; 1102 char *buf; 1103 u8 chainmask = (ah->rxchainmask << 3) | ah->rxchainmask; 1104 u8 nread; 1105 1106 buf = kzalloc(size, GFP_KERNEL); 1107 if (!buf) 1108 return -ENOMEM; 1109 1110 len += snprintf(buf + len, size - len, 1111 "Channel Noise Floor : %d\n", ah->noise); 1112 len += snprintf(buf + len, size - len, 1113 "Chain | privNF | # Readings | NF Readings\n"); 1114 for (i = 0; i < NUM_NF_READINGS; i++) { 1115 if (!(chainmask & (1 << i)) || 1116 ((i >= AR5416_MAX_CHAINS) && !conf_is_ht40(conf))) 1117 continue; 1118 1119 nread = AR_PHY_CCA_FILTERWINDOW_LENGTH - h[i].invalidNFcount; 1120 len += snprintf(buf + len, size - len, " %d\t %d\t %d\t\t", 1121 i, h[i].privNF, nread); 1122 for (j = 0; j < nread; j++) 1123 len += snprintf(buf + len, size - len, 1124 " %d", h[i].nfCalBuffer[j]); 1125 len += snprintf(buf + len, size - len, "\n"); 1126 } 1127 1128 if (len > size) 1129 len = size; 1130 1131 retval = simple_read_from_buffer(user_buf, count, ppos, buf, len); 1132 kfree(buf); 1133 1134 return retval; 1135 } 1136 1137 static const struct file_operations fops_dump_nfcal = { 1138 .read = read_file_dump_nfcal, 1139 .open = simple_open, 1140 .owner = THIS_MODULE, 1141 .llseek = default_llseek, 1142 }; 1143 1144 static ssize_t read_file_base_eeprom(struct file *file, char __user *user_buf, 1145 size_t count, loff_t *ppos) 1146 { 1147 struct ath_softc *sc = file->private_data; 1148 struct ath_hw *ah = sc->sc_ah; 1149 u32 len = 0, size = 1500; 1150 ssize_t retval = 0; 1151 char *buf; 1152 1153 buf = kzalloc(size, GFP_KERNEL); 1154 if (!buf) 1155 return -ENOMEM; 1156 1157 len = ah->eep_ops->dump_eeprom(ah, true, buf, len, size); 1158 1159 retval = simple_read_from_buffer(user_buf, count, ppos, buf, len); 1160 kfree(buf); 1161 1162 return retval; 1163 } 1164 1165 static const struct file_operations fops_base_eeprom = { 1166 .read = read_file_base_eeprom, 1167 .open = simple_open, 1168 .owner = THIS_MODULE, 1169 .llseek = default_llseek, 1170 }; 1171 1172 static ssize_t read_file_modal_eeprom(struct file *file, char __user *user_buf, 1173 size_t count, loff_t *ppos) 1174 { 1175 struct ath_softc *sc = file->private_data; 1176 struct ath_hw *ah = sc->sc_ah; 1177 u32 len = 0, size = 6000; 1178 char *buf; 1179 size_t retval; 1180 1181 buf = kzalloc(size, GFP_KERNEL); 1182 if (buf == NULL) 1183 return -ENOMEM; 1184 1185 len = ah->eep_ops->dump_eeprom(ah, false, buf, len, size); 1186 1187 retval = simple_read_from_buffer(user_buf, count, ppos, buf, len); 1188 kfree(buf); 1189 1190 return retval; 1191 } 1192 1193 static const struct file_operations fops_modal_eeprom = { 1194 .read = read_file_modal_eeprom, 1195 .open = simple_open, 1196 .owner = THIS_MODULE, 1197 .llseek = default_llseek, 1198 }; 1199 1200 #ifdef CONFIG_ATH9K_MAC_DEBUG 1201 1202 void ath9k_debug_samp_bb_mac(struct ath_softc *sc) 1203 { 1204 #define ATH_SAMP_DBG(c) (sc->debug.bb_mac_samp[sc->debug.sampidx].c) 1205 struct ath_hw *ah = sc->sc_ah; 1206 struct ath_common *common = ath9k_hw_common(ah); 1207 unsigned long flags; 1208 int i; 1209 1210 ath9k_ps_wakeup(sc); 1211 1212 spin_lock_bh(&sc->debug.samp_lock); 1213 1214 spin_lock_irqsave(&common->cc_lock, flags); 1215 ath_hw_cycle_counters_update(common); 1216 1217 ATH_SAMP_DBG(cc.cycles) = common->cc_ani.cycles; 1218 ATH_SAMP_DBG(cc.rx_busy) = common->cc_ani.rx_busy; 1219 ATH_SAMP_DBG(cc.rx_frame) = common->cc_ani.rx_frame; 1220 ATH_SAMP_DBG(cc.tx_frame) = common->cc_ani.tx_frame; 1221 spin_unlock_irqrestore(&common->cc_lock, flags); 1222 1223 ATH_SAMP_DBG(noise) = ah->noise; 1224 1225 REG_WRITE_D(ah, AR_MACMISC, 1226 ((AR_MACMISC_DMA_OBS_LINE_8 << AR_MACMISC_DMA_OBS_S) | 1227 (AR_MACMISC_MISC_OBS_BUS_1 << 1228 AR_MACMISC_MISC_OBS_BUS_MSB_S))); 1229 1230 for (i = 0; i < ATH9K_NUM_DMA_DEBUG_REGS; i++) 1231 ATH_SAMP_DBG(dma_dbg_reg_vals[i]) = REG_READ_D(ah, 1232 AR_DMADBG_0 + (i * sizeof(u32))); 1233 1234 ATH_SAMP_DBG(pcu_obs) = REG_READ_D(ah, AR_OBS_BUS_1); 1235 ATH_SAMP_DBG(pcu_cr) = REG_READ_D(ah, AR_CR); 1236 1237 memcpy(ATH_SAMP_DBG(nfCalHist), sc->caldata.nfCalHist, 1238 sizeof(ATH_SAMP_DBG(nfCalHist))); 1239 1240 sc->debug.sampidx = (sc->debug.sampidx + 1) % ATH_DBG_MAX_SAMPLES; 1241 spin_unlock_bh(&sc->debug.samp_lock); 1242 ath9k_ps_restore(sc); 1243 1244 #undef ATH_SAMP_DBG 1245 } 1246 1247 static int open_file_bb_mac_samps(struct inode *inode, struct file *file) 1248 { 1249 #define ATH_SAMP_DBG(c) bb_mac_samp[sampidx].c 1250 struct ath_softc *sc = inode->i_private; 1251 struct ath_hw *ah = sc->sc_ah; 1252 struct ath_common *common = ath9k_hw_common(ah); 1253 struct ieee80211_conf *conf = &common->hw->conf; 1254 struct ath_dbg_bb_mac_samp *bb_mac_samp; 1255 struct ath9k_nfcal_hist *h; 1256 int i, j, qcuOffset = 0, dcuOffset = 0; 1257 u32 *qcuBase, *dcuBase, size = 30000, len = 0; 1258 u32 sampidx = 0; 1259 u8 *buf; 1260 u8 chainmask = (ah->rxchainmask << 3) | ah->rxchainmask; 1261 u8 nread; 1262 1263 if (test_bit(SC_OP_INVALID, &sc->sc_flags)) 1264 return -EAGAIN; 1265 1266 buf = vmalloc(size); 1267 if (!buf) 1268 return -ENOMEM; 1269 bb_mac_samp = vmalloc(sizeof(*bb_mac_samp) * ATH_DBG_MAX_SAMPLES); 1270 if (!bb_mac_samp) { 1271 vfree(buf); 1272 return -ENOMEM; 1273 } 1274 /* Account the current state too */ 1275 ath9k_debug_samp_bb_mac(sc); 1276 1277 spin_lock_bh(&sc->debug.samp_lock); 1278 memcpy(bb_mac_samp, sc->debug.bb_mac_samp, 1279 sizeof(*bb_mac_samp) * ATH_DBG_MAX_SAMPLES); 1280 len += snprintf(buf + len, size - len, 1281 "Current Sample Index: %d\n", sc->debug.sampidx); 1282 spin_unlock_bh(&sc->debug.samp_lock); 1283 1284 len += snprintf(buf + len, size - len, 1285 "Raw DMA Debug Dump:\n"); 1286 len += snprintf(buf + len, size - len, "Sample |\t"); 1287 for (i = 0; i < ATH9K_NUM_DMA_DEBUG_REGS; i++) 1288 len += snprintf(buf + len, size - len, " DMA Reg%d |\t", i); 1289 len += snprintf(buf + len, size - len, "\n"); 1290 1291 for (sampidx = 0; sampidx < ATH_DBG_MAX_SAMPLES; sampidx++) { 1292 len += snprintf(buf + len, size - len, "%d\t", sampidx); 1293 1294 for (i = 0; i < ATH9K_NUM_DMA_DEBUG_REGS; i++) 1295 len += snprintf(buf + len, size - len, " %08x\t", 1296 ATH_SAMP_DBG(dma_dbg_reg_vals[i])); 1297 len += snprintf(buf + len, size - len, "\n"); 1298 } 1299 len += snprintf(buf + len, size - len, "\n"); 1300 1301 len += snprintf(buf + len, size - len, 1302 "Sample Num QCU: chain_st fsp_ok fsp_st DCU: chain_st\n"); 1303 for (sampidx = 0; sampidx < ATH_DBG_MAX_SAMPLES; sampidx++) { 1304 qcuBase = &ATH_SAMP_DBG(dma_dbg_reg_vals[0]); 1305 dcuBase = &ATH_SAMP_DBG(dma_dbg_reg_vals[4]); 1306 1307 for (i = 0; i < ATH9K_NUM_QUEUES; i++, 1308 qcuOffset += 4, dcuOffset += 5) { 1309 if (i == 8) { 1310 qcuOffset = 0; 1311 qcuBase++; 1312 } 1313 1314 if (i == 6) { 1315 dcuOffset = 0; 1316 dcuBase++; 1317 } 1318 if (!sc->debug.stats.txstats[i].queued) 1319 continue; 1320 1321 len += snprintf(buf + len, size - len, 1322 "%4d %7d %2x %1x %2x %2x\n", 1323 sampidx, i, 1324 (*qcuBase & (0x7 << qcuOffset)) >> qcuOffset, 1325 (*qcuBase & (0x8 << qcuOffset)) >> 1326 (qcuOffset + 3), 1327 ATH_SAMP_DBG(dma_dbg_reg_vals[2]) & 1328 (0x7 << (i * 3)) >> (i * 3), 1329 (*dcuBase & (0x1f << dcuOffset)) >> dcuOffset); 1330 } 1331 len += snprintf(buf + len, size - len, "\n"); 1332 } 1333 len += snprintf(buf + len, size - len, 1334 "samp qcu_sh qcu_fh qcu_comp dcu_comp dcu_arb dcu_fp " 1335 "ch_idle_dur ch_idle_dur_val txfifo_val0 txfifo_val1 " 1336 "txfifo_dcu0 txfifo_dcu1 pcu_obs AR_CR\n"); 1337 1338 for (sampidx = 0; sampidx < ATH_DBG_MAX_SAMPLES; sampidx++) { 1339 qcuBase = &ATH_SAMP_DBG(dma_dbg_reg_vals[0]); 1340 dcuBase = &ATH_SAMP_DBG(dma_dbg_reg_vals[4]); 1341 1342 len += snprintf(buf + len, size - len, "%4d %5x %5x ", sampidx, 1343 (ATH_SAMP_DBG(dma_dbg_reg_vals[3]) & 0x003c0000) >> 18, 1344 (ATH_SAMP_DBG(dma_dbg_reg_vals[3]) & 0x03c00000) >> 22); 1345 len += snprintf(buf + len, size - len, "%7x %8x ", 1346 (ATH_SAMP_DBG(dma_dbg_reg_vals[3]) & 0x1c000000) >> 26, 1347 (ATH_SAMP_DBG(dma_dbg_reg_vals[6]) & 0x3)); 1348 len += snprintf(buf + len, size - len, "%7x %7x ", 1349 (ATH_SAMP_DBG(dma_dbg_reg_vals[5]) & 0x06000000) >> 25, 1350 (ATH_SAMP_DBG(dma_dbg_reg_vals[5]) & 0x38000000) >> 27); 1351 len += snprintf(buf + len, size - len, "%7d %12d ", 1352 (ATH_SAMP_DBG(dma_dbg_reg_vals[6]) & 0x000003fc) >> 2, 1353 (ATH_SAMP_DBG(dma_dbg_reg_vals[6]) & 0x00000400) >> 10); 1354 len += snprintf(buf + len, size - len, "%12d %12d ", 1355 (ATH_SAMP_DBG(dma_dbg_reg_vals[6]) & 0x00000800) >> 11, 1356 (ATH_SAMP_DBG(dma_dbg_reg_vals[6]) & 0x00001000) >> 12); 1357 len += snprintf(buf + len, size - len, "%12d %12d ", 1358 (ATH_SAMP_DBG(dma_dbg_reg_vals[6]) & 0x0001e000) >> 13, 1359 (ATH_SAMP_DBG(dma_dbg_reg_vals[6]) & 0x001e0000) >> 17); 1360 len += snprintf(buf + len, size - len, "0x%07x 0x%07x\n", 1361 ATH_SAMP_DBG(pcu_obs), ATH_SAMP_DBG(pcu_cr)); 1362 } 1363 1364 len += snprintf(buf + len, size - len, 1365 "Sample ChNoise Chain privNF #Reading Readings\n"); 1366 for (sampidx = 0; sampidx < ATH_DBG_MAX_SAMPLES; sampidx++) { 1367 h = ATH_SAMP_DBG(nfCalHist); 1368 if (!ATH_SAMP_DBG(noise)) 1369 continue; 1370 1371 for (i = 0; i < NUM_NF_READINGS; i++) { 1372 if (!(chainmask & (1 << i)) || 1373 ((i >= AR5416_MAX_CHAINS) && !conf_is_ht40(conf))) 1374 continue; 1375 1376 nread = AR_PHY_CCA_FILTERWINDOW_LENGTH - 1377 h[i].invalidNFcount; 1378 len += snprintf(buf + len, size - len, 1379 "%4d %5d %4d\t %d\t %d\t", 1380 sampidx, ATH_SAMP_DBG(noise), 1381 i, h[i].privNF, nread); 1382 for (j = 0; j < nread; j++) 1383 len += snprintf(buf + len, size - len, 1384 " %d", h[i].nfCalBuffer[j]); 1385 len += snprintf(buf + len, size - len, "\n"); 1386 } 1387 } 1388 len += snprintf(buf + len, size - len, "\nCycle counters:\n" 1389 "Sample Total Rxbusy Rxframes Txframes\n"); 1390 for (sampidx = 0; sampidx < ATH_DBG_MAX_SAMPLES; sampidx++) { 1391 if (!ATH_SAMP_DBG(cc.cycles)) 1392 continue; 1393 len += snprintf(buf + len, size - len, 1394 "%4d %08x %08x %08x %08x\n", 1395 sampidx, ATH_SAMP_DBG(cc.cycles), 1396 ATH_SAMP_DBG(cc.rx_busy), 1397 ATH_SAMP_DBG(cc.rx_frame), 1398 ATH_SAMP_DBG(cc.tx_frame)); 1399 } 1400 1401 len += snprintf(buf + len, size - len, "Tx status Dump :\n"); 1402 len += snprintf(buf + len, size - len, 1403 "Sample rssi:- ctl0 ctl1 ctl2 ext0 ext1 ext2 comb " 1404 "isok rts_fail data_fail rate tid qid " 1405 "ba_low ba_high tx_before(ms)\n"); 1406 for (sampidx = 0; sampidx < ATH_DBG_MAX_SAMPLES; sampidx++) { 1407 for (i = 0; i < ATH_DBG_MAX_SAMPLES; i++) { 1408 if (!ATH_SAMP_DBG(ts[i].jiffies)) 1409 continue; 1410 len += snprintf(buf + len, size - len, "%-14d" 1411 "%-4d %-4d %-4d %-4d %-4d %-4d %-4d %-4d %-8d " 1412 "%-9d %-4d %-3d %-3d %08x %08x %-11d\n", 1413 sampidx, 1414 ATH_SAMP_DBG(ts[i].rssi_ctl0), 1415 ATH_SAMP_DBG(ts[i].rssi_ctl1), 1416 ATH_SAMP_DBG(ts[i].rssi_ctl2), 1417 ATH_SAMP_DBG(ts[i].rssi_ext0), 1418 ATH_SAMP_DBG(ts[i].rssi_ext1), 1419 ATH_SAMP_DBG(ts[i].rssi_ext2), 1420 ATH_SAMP_DBG(ts[i].rssi), 1421 ATH_SAMP_DBG(ts[i].isok), 1422 ATH_SAMP_DBG(ts[i].rts_fail_cnt), 1423 ATH_SAMP_DBG(ts[i].data_fail_cnt), 1424 ATH_SAMP_DBG(ts[i].rateindex), 1425 ATH_SAMP_DBG(ts[i].tid), 1426 ATH_SAMP_DBG(ts[i].qid), 1427 ATH_SAMP_DBG(ts[i].ba_low), 1428 ATH_SAMP_DBG(ts[i].ba_high), 1429 jiffies_to_msecs(jiffies - 1430 ATH_SAMP_DBG(ts[i].jiffies))); 1431 } 1432 } 1433 1434 len += snprintf(buf + len, size - len, "Rx status Dump :\n"); 1435 len += snprintf(buf + len, size - len, "Sample rssi:- ctl0 ctl1 ctl2 " 1436 "ext0 ext1 ext2 comb beacon ant rate rx_before(ms)\n"); 1437 for (sampidx = 0; sampidx < ATH_DBG_MAX_SAMPLES; sampidx++) { 1438 for (i = 0; i < ATH_DBG_MAX_SAMPLES; i++) { 1439 if (!ATH_SAMP_DBG(rs[i].jiffies)) 1440 continue; 1441 len += snprintf(buf + len, size - len, "%-14d" 1442 "%-4d %-4d %-4d %-4d %-4d %-4d %-4d %-9s %-2d %02x %-13d\n", 1443 sampidx, 1444 ATH_SAMP_DBG(rs[i].rssi_ctl0), 1445 ATH_SAMP_DBG(rs[i].rssi_ctl1), 1446 ATH_SAMP_DBG(rs[i].rssi_ctl2), 1447 ATH_SAMP_DBG(rs[i].rssi_ext0), 1448 ATH_SAMP_DBG(rs[i].rssi_ext1), 1449 ATH_SAMP_DBG(rs[i].rssi_ext2), 1450 ATH_SAMP_DBG(rs[i].rssi), 1451 ATH_SAMP_DBG(rs[i].is_mybeacon) ? 1452 "True" : "False", 1453 ATH_SAMP_DBG(rs[i].antenna), 1454 ATH_SAMP_DBG(rs[i].rate), 1455 jiffies_to_msecs(jiffies - 1456 ATH_SAMP_DBG(rs[i].jiffies))); 1457 } 1458 } 1459 1460 vfree(bb_mac_samp); 1461 file->private_data = buf; 1462 1463 return 0; 1464 #undef ATH_SAMP_DBG 1465 } 1466 1467 static const struct file_operations fops_samps = { 1468 .open = open_file_bb_mac_samps, 1469 .read = ath9k_debugfs_read_buf, 1470 .release = ath9k_debugfs_release_buf, 1471 .owner = THIS_MODULE, 1472 .llseek = default_llseek, 1473 }; 1474 1475 #endif 1476 1477 #ifdef CONFIG_ATH9K_BTCOEX_SUPPORT 1478 static ssize_t read_file_btcoex(struct file *file, char __user *user_buf, 1479 size_t count, loff_t *ppos) 1480 { 1481 struct ath_softc *sc = file->private_data; 1482 u32 len = 0, size = 1500; 1483 char *buf; 1484 size_t retval; 1485 1486 buf = kzalloc(size, GFP_KERNEL); 1487 if (buf == NULL) 1488 return -ENOMEM; 1489 1490 if (!sc->sc_ah->common.btcoex_enabled) { 1491 len = snprintf(buf, size, "%s\n", 1492 "BTCOEX is disabled"); 1493 goto exit; 1494 } 1495 1496 len = ath9k_dump_btcoex(sc, buf, size); 1497 exit: 1498 retval = simple_read_from_buffer(user_buf, count, ppos, buf, len); 1499 kfree(buf); 1500 1501 return retval; 1502 } 1503 1504 static const struct file_operations fops_btcoex = { 1505 .read = read_file_btcoex, 1506 .open = simple_open, 1507 .owner = THIS_MODULE, 1508 .llseek = default_llseek, 1509 }; 1510 #endif 1511 1512 static ssize_t read_file_node_stat(struct file *file, char __user *user_buf, 1513 size_t count, loff_t *ppos) 1514 { 1515 struct ath_node *an = file->private_data; 1516 struct ath_softc *sc = an->sc; 1517 struct ath_atx_tid *tid; 1518 struct ath_atx_ac *ac; 1519 struct ath_txq *txq; 1520 u32 len = 0, size = 4096; 1521 char *buf; 1522 size_t retval; 1523 int tidno, acno; 1524 1525 buf = kzalloc(size, GFP_KERNEL); 1526 if (buf == NULL) 1527 return -ENOMEM; 1528 1529 if (!an->sta->ht_cap.ht_supported) { 1530 len = snprintf(buf, size, "%s\n", 1531 "HT not supported"); 1532 goto exit; 1533 } 1534 1535 len = snprintf(buf, size, "Max-AMPDU: %d\n", 1536 an->maxampdu); 1537 len += snprintf(buf + len, size - len, "MPDU Density: %d\n\n", 1538 an->mpdudensity); 1539 1540 len += snprintf(buf + len, size - len, 1541 "%2s%7s\n", "AC", "SCHED"); 1542 1543 for (acno = 0, ac = &an->ac[acno]; 1544 acno < IEEE80211_NUM_ACS; acno++, ac++) { 1545 txq = ac->txq; 1546 ath_txq_lock(sc, txq); 1547 len += snprintf(buf + len, size - len, 1548 "%2d%7d\n", 1549 acno, ac->sched); 1550 ath_txq_unlock(sc, txq); 1551 } 1552 1553 len += snprintf(buf + len, size - len, 1554 "\n%3s%11s%10s%10s%10s%10s%9s%6s%8s\n", 1555 "TID", "SEQ_START", "SEQ_NEXT", "BAW_SIZE", 1556 "BAW_HEAD", "BAW_TAIL", "BAR_IDX", "SCHED", "PAUSED"); 1557 1558 for (tidno = 0, tid = &an->tid[tidno]; 1559 tidno < IEEE80211_NUM_TIDS; tidno++, tid++) { 1560 txq = tid->ac->txq; 1561 ath_txq_lock(sc, txq); 1562 len += snprintf(buf + len, size - len, 1563 "%3d%11d%10d%10d%10d%10d%9d%6d%8d\n", 1564 tid->tidno, tid->seq_start, tid->seq_next, 1565 tid->baw_size, tid->baw_head, tid->baw_tail, 1566 tid->bar_index, tid->sched, tid->paused); 1567 ath_txq_unlock(sc, txq); 1568 } 1569 exit: 1570 retval = simple_read_from_buffer(user_buf, count, ppos, buf, len); 1571 kfree(buf); 1572 1573 return retval; 1574 } 1575 1576 static const struct file_operations fops_node_stat = { 1577 .read = read_file_node_stat, 1578 .open = simple_open, 1579 .owner = THIS_MODULE, 1580 .llseek = default_llseek, 1581 }; 1582 1583 void ath9k_sta_add_debugfs(struct ieee80211_hw *hw, 1584 struct ieee80211_vif *vif, 1585 struct ieee80211_sta *sta, 1586 struct dentry *dir) 1587 { 1588 struct ath_node *an = (struct ath_node *)sta->drv_priv; 1589 an->node_stat = debugfs_create_file("node_stat", S_IRUGO, 1590 dir, an, &fops_node_stat); 1591 } 1592 1593 void ath9k_sta_remove_debugfs(struct ieee80211_hw *hw, 1594 struct ieee80211_vif *vif, 1595 struct ieee80211_sta *sta, 1596 struct dentry *dir) 1597 { 1598 struct ath_node *an = (struct ath_node *)sta->drv_priv; 1599 debugfs_remove(an->node_stat); 1600 } 1601 1602 /* Ethtool support for get-stats */ 1603 1604 #define AMKSTR(nm) #nm "_BE", #nm "_BK", #nm "_VI", #nm "_VO" 1605 static const char ath9k_gstrings_stats[][ETH_GSTRING_LEN] = { 1606 "tx_pkts_nic", 1607 "tx_bytes_nic", 1608 "rx_pkts_nic", 1609 "rx_bytes_nic", 1610 AMKSTR(d_tx_pkts), 1611 AMKSTR(d_tx_bytes), 1612 AMKSTR(d_tx_mpdus_queued), 1613 AMKSTR(d_tx_mpdus_completed), 1614 AMKSTR(d_tx_mpdu_xretries), 1615 AMKSTR(d_tx_aggregates), 1616 AMKSTR(d_tx_ampdus_queued_hw), 1617 AMKSTR(d_tx_ampdus_queued_sw), 1618 AMKSTR(d_tx_ampdus_completed), 1619 AMKSTR(d_tx_ampdu_retries), 1620 AMKSTR(d_tx_ampdu_xretries), 1621 AMKSTR(d_tx_fifo_underrun), 1622 AMKSTR(d_tx_op_exceeded), 1623 AMKSTR(d_tx_timer_expiry), 1624 AMKSTR(d_tx_desc_cfg_err), 1625 AMKSTR(d_tx_data_underrun), 1626 AMKSTR(d_tx_delim_underrun), 1627 "d_rx_decrypt_crc_err", 1628 "d_rx_phy_err", 1629 "d_rx_mic_err", 1630 "d_rx_pre_delim_crc_err", 1631 "d_rx_post_delim_crc_err", 1632 "d_rx_decrypt_busy_err", 1633 1634 "d_rx_phyerr_radar", 1635 "d_rx_phyerr_ofdm_timing", 1636 "d_rx_phyerr_cck_timing", 1637 1638 }; 1639 #define ATH9K_SSTATS_LEN ARRAY_SIZE(ath9k_gstrings_stats) 1640 1641 void ath9k_get_et_strings(struct ieee80211_hw *hw, 1642 struct ieee80211_vif *vif, 1643 u32 sset, u8 *data) 1644 { 1645 if (sset == ETH_SS_STATS) 1646 memcpy(data, *ath9k_gstrings_stats, 1647 sizeof(ath9k_gstrings_stats)); 1648 } 1649 1650 int ath9k_get_et_sset_count(struct ieee80211_hw *hw, 1651 struct ieee80211_vif *vif, int sset) 1652 { 1653 if (sset == ETH_SS_STATS) 1654 return ATH9K_SSTATS_LEN; 1655 return 0; 1656 } 1657 1658 #define AWDATA(elem) \ 1659 do { \ 1660 data[i++] = sc->debug.stats.txstats[PR_QNUM(IEEE80211_AC_BE)].elem; \ 1661 data[i++] = sc->debug.stats.txstats[PR_QNUM(IEEE80211_AC_BK)].elem; \ 1662 data[i++] = sc->debug.stats.txstats[PR_QNUM(IEEE80211_AC_VI)].elem; \ 1663 data[i++] = sc->debug.stats.txstats[PR_QNUM(IEEE80211_AC_VO)].elem; \ 1664 } while (0) 1665 1666 #define AWDATA_RX(elem) \ 1667 do { \ 1668 data[i++] = sc->debug.stats.rxstats.elem; \ 1669 } while (0) 1670 1671 void ath9k_get_et_stats(struct ieee80211_hw *hw, 1672 struct ieee80211_vif *vif, 1673 struct ethtool_stats *stats, u64 *data) 1674 { 1675 struct ath_softc *sc = hw->priv; 1676 int i = 0; 1677 1678 data[i++] = (sc->debug.stats.txstats[PR_QNUM(IEEE80211_AC_BE)].tx_pkts_all + 1679 sc->debug.stats.txstats[PR_QNUM(IEEE80211_AC_BK)].tx_pkts_all + 1680 sc->debug.stats.txstats[PR_QNUM(IEEE80211_AC_VI)].tx_pkts_all + 1681 sc->debug.stats.txstats[PR_QNUM(IEEE80211_AC_VO)].tx_pkts_all); 1682 data[i++] = (sc->debug.stats.txstats[PR_QNUM(IEEE80211_AC_BE)].tx_bytes_all + 1683 sc->debug.stats.txstats[PR_QNUM(IEEE80211_AC_BK)].tx_bytes_all + 1684 sc->debug.stats.txstats[PR_QNUM(IEEE80211_AC_VI)].tx_bytes_all + 1685 sc->debug.stats.txstats[PR_QNUM(IEEE80211_AC_VO)].tx_bytes_all); 1686 AWDATA_RX(rx_pkts_all); 1687 AWDATA_RX(rx_bytes_all); 1688 1689 AWDATA(tx_pkts_all); 1690 AWDATA(tx_bytes_all); 1691 AWDATA(queued); 1692 AWDATA(completed); 1693 AWDATA(xretries); 1694 AWDATA(a_aggr); 1695 AWDATA(a_queued_hw); 1696 AWDATA(a_queued_sw); 1697 AWDATA(a_completed); 1698 AWDATA(a_retries); 1699 AWDATA(a_xretries); 1700 AWDATA(fifo_underrun); 1701 AWDATA(xtxop); 1702 AWDATA(timer_exp); 1703 AWDATA(desc_cfg_err); 1704 AWDATA(data_underrun); 1705 AWDATA(delim_underrun); 1706 1707 AWDATA_RX(decrypt_crc_err); 1708 AWDATA_RX(phy_err); 1709 AWDATA_RX(mic_err); 1710 AWDATA_RX(pre_delim_crc_err); 1711 AWDATA_RX(post_delim_crc_err); 1712 AWDATA_RX(decrypt_busy_err); 1713 1714 AWDATA_RX(phy_err_stats[ATH9K_PHYERR_RADAR]); 1715 AWDATA_RX(phy_err_stats[ATH9K_PHYERR_OFDM_TIMING]); 1716 AWDATA_RX(phy_err_stats[ATH9K_PHYERR_CCK_TIMING]); 1717 1718 WARN_ON(i != ATH9K_SSTATS_LEN); 1719 } 1720 1721 int ath9k_init_debug(struct ath_hw *ah) 1722 { 1723 struct ath_common *common = ath9k_hw_common(ah); 1724 struct ath_softc *sc = (struct ath_softc *) common->priv; 1725 1726 sc->debug.debugfs_phy = debugfs_create_dir("ath9k", 1727 sc->hw->wiphy->debugfsdir); 1728 if (!sc->debug.debugfs_phy) 1729 return -ENOMEM; 1730 1731 #ifdef CONFIG_ATH_DEBUG 1732 debugfs_create_file("debug", S_IRUSR | S_IWUSR, sc->debug.debugfs_phy, 1733 sc, &fops_debug); 1734 #endif 1735 1736 ath9k_dfs_init_debug(sc); 1737 1738 debugfs_create_file("dma", S_IRUSR, sc->debug.debugfs_phy, sc, 1739 &fops_dma); 1740 debugfs_create_file("interrupt", S_IRUSR, sc->debug.debugfs_phy, sc, 1741 &fops_interrupt); 1742 debugfs_create_file("xmit", S_IRUSR, sc->debug.debugfs_phy, sc, 1743 &fops_xmit); 1744 debugfs_create_file("queues", S_IRUSR, sc->debug.debugfs_phy, sc, 1745 &fops_queues); 1746 debugfs_create_u32("qlen_bk", S_IRUSR | S_IWUSR, sc->debug.debugfs_phy, 1747 &sc->tx.txq_max_pending[IEEE80211_AC_BK]); 1748 debugfs_create_u32("qlen_be", S_IRUSR | S_IWUSR, sc->debug.debugfs_phy, 1749 &sc->tx.txq_max_pending[IEEE80211_AC_BE]); 1750 debugfs_create_u32("qlen_vi", S_IRUSR | S_IWUSR, sc->debug.debugfs_phy, 1751 &sc->tx.txq_max_pending[IEEE80211_AC_VI]); 1752 debugfs_create_u32("qlen_vo", S_IRUSR | S_IWUSR, sc->debug.debugfs_phy, 1753 &sc->tx.txq_max_pending[IEEE80211_AC_VO]); 1754 debugfs_create_file("misc", S_IRUSR, sc->debug.debugfs_phy, sc, 1755 &fops_misc); 1756 debugfs_create_file("reset", S_IRUSR, sc->debug.debugfs_phy, sc, 1757 &fops_reset); 1758 debugfs_create_file("recv", S_IRUSR, sc->debug.debugfs_phy, sc, 1759 &fops_recv); 1760 debugfs_create_file("rx_chainmask", S_IRUSR | S_IWUSR, 1761 sc->debug.debugfs_phy, sc, &fops_rx_chainmask); 1762 debugfs_create_file("tx_chainmask", S_IRUSR | S_IWUSR, 1763 sc->debug.debugfs_phy, sc, &fops_tx_chainmask); 1764 debugfs_create_file("disable_ani", S_IRUSR | S_IWUSR, 1765 sc->debug.debugfs_phy, sc, &fops_disable_ani); 1766 debugfs_create_bool("paprd", S_IRUSR | S_IWUSR, sc->debug.debugfs_phy, 1767 &sc->sc_ah->config.enable_paprd); 1768 debugfs_create_file("regidx", S_IRUSR | S_IWUSR, sc->debug.debugfs_phy, 1769 sc, &fops_regidx); 1770 debugfs_create_file("regval", S_IRUSR | S_IWUSR, sc->debug.debugfs_phy, 1771 sc, &fops_regval); 1772 debugfs_create_bool("ignore_extcca", S_IRUSR | S_IWUSR, 1773 sc->debug.debugfs_phy, 1774 &ah->config.cwm_ignore_extcca); 1775 debugfs_create_file("regdump", S_IRUSR, sc->debug.debugfs_phy, sc, 1776 &fops_regdump); 1777 debugfs_create_file("dump_nfcal", S_IRUSR, sc->debug.debugfs_phy, sc, 1778 &fops_dump_nfcal); 1779 debugfs_create_file("base_eeprom", S_IRUSR, sc->debug.debugfs_phy, sc, 1780 &fops_base_eeprom); 1781 debugfs_create_file("modal_eeprom", S_IRUSR, sc->debug.debugfs_phy, sc, 1782 &fops_modal_eeprom); 1783 #ifdef CONFIG_ATH9K_MAC_DEBUG 1784 debugfs_create_file("samples", S_IRUSR, sc->debug.debugfs_phy, sc, 1785 &fops_samps); 1786 #endif 1787 debugfs_create_u32("gpio_mask", S_IRUSR | S_IWUSR, 1788 sc->debug.debugfs_phy, &sc->sc_ah->gpio_mask); 1789 debugfs_create_u32("gpio_val", S_IRUSR | S_IWUSR, 1790 sc->debug.debugfs_phy, &sc->sc_ah->gpio_val); 1791 debugfs_create_file("diversity", S_IRUSR | S_IWUSR, 1792 sc->debug.debugfs_phy, sc, &fops_ant_diversity); 1793 #ifdef CONFIG_ATH9K_BTCOEX_SUPPORT 1794 debugfs_create_file("btcoex", S_IRUSR, sc->debug.debugfs_phy, sc, 1795 &fops_btcoex); 1796 #endif 1797 return 0; 1798 } 1799