1 /* 2 * Copyright (c) 2008-2009 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 <asm/unaligned.h> 20 21 #include "ath9k.h" 22 23 #define REG_WRITE_D(_ah, _reg, _val) \ 24 ath9k_hw_common(_ah)->ops->write((_ah), (_val), (_reg)) 25 #define REG_READ_D(_ah, _reg) \ 26 ath9k_hw_common(_ah)->ops->read((_ah), (_reg)) 27 28 static int ath9k_debugfs_open(struct inode *inode, struct file *file) 29 { 30 file->private_data = inode->i_private; 31 return 0; 32 } 33 34 static ssize_t ath9k_debugfs_read_buf(struct file *file, char __user *user_buf, 35 size_t count, loff_t *ppos) 36 { 37 u8 *buf = file->private_data; 38 return simple_read_from_buffer(user_buf, count, ppos, buf, strlen(buf)); 39 } 40 41 static int ath9k_debugfs_release_buf(struct inode *inode, struct file *file) 42 { 43 vfree(file->private_data); 44 return 0; 45 } 46 47 #ifdef CONFIG_ATH_DEBUG 48 49 static ssize_t read_file_debug(struct file *file, char __user *user_buf, 50 size_t count, loff_t *ppos) 51 { 52 struct ath_softc *sc = file->private_data; 53 struct ath_common *common = ath9k_hw_common(sc->sc_ah); 54 char buf[32]; 55 unsigned int len; 56 57 len = sprintf(buf, "0x%08x\n", common->debug_mask); 58 return simple_read_from_buffer(user_buf, count, ppos, buf, len); 59 } 60 61 static ssize_t write_file_debug(struct file *file, const char __user *user_buf, 62 size_t count, loff_t *ppos) 63 { 64 struct ath_softc *sc = file->private_data; 65 struct ath_common *common = ath9k_hw_common(sc->sc_ah); 66 unsigned long mask; 67 char buf[32]; 68 ssize_t len; 69 70 len = min(count, sizeof(buf) - 1); 71 if (copy_from_user(buf, user_buf, len)) 72 return -EFAULT; 73 74 buf[len] = '\0'; 75 if (strict_strtoul(buf, 0, &mask)) 76 return -EINVAL; 77 78 common->debug_mask = mask; 79 return count; 80 } 81 82 static const struct file_operations fops_debug = { 83 .read = read_file_debug, 84 .write = write_file_debug, 85 .open = ath9k_debugfs_open, 86 .owner = THIS_MODULE, 87 .llseek = default_llseek, 88 }; 89 90 #endif 91 92 #define DMA_BUF_LEN 1024 93 94 static ssize_t read_file_tx_chainmask(struct file *file, char __user *user_buf, 95 size_t count, loff_t *ppos) 96 { 97 struct ath_softc *sc = file->private_data; 98 struct ath_common *common = ath9k_hw_common(sc->sc_ah); 99 char buf[32]; 100 unsigned int len; 101 102 len = sprintf(buf, "0x%08x\n", common->tx_chainmask); 103 return simple_read_from_buffer(user_buf, count, ppos, buf, len); 104 } 105 106 static ssize_t write_file_tx_chainmask(struct file *file, const char __user *user_buf, 107 size_t count, loff_t *ppos) 108 { 109 struct ath_softc *sc = file->private_data; 110 struct ath_common *common = ath9k_hw_common(sc->sc_ah); 111 unsigned long mask; 112 char buf[32]; 113 ssize_t len; 114 115 len = min(count, sizeof(buf) - 1); 116 if (copy_from_user(buf, user_buf, len)) 117 return -EFAULT; 118 119 buf[len] = '\0'; 120 if (strict_strtoul(buf, 0, &mask)) 121 return -EINVAL; 122 123 common->tx_chainmask = mask; 124 sc->sc_ah->caps.tx_chainmask = mask; 125 return count; 126 } 127 128 static const struct file_operations fops_tx_chainmask = { 129 .read = read_file_tx_chainmask, 130 .write = write_file_tx_chainmask, 131 .open = ath9k_debugfs_open, 132 .owner = THIS_MODULE, 133 .llseek = default_llseek, 134 }; 135 136 137 static ssize_t read_file_rx_chainmask(struct file *file, char __user *user_buf, 138 size_t count, loff_t *ppos) 139 { 140 struct ath_softc *sc = file->private_data; 141 struct ath_common *common = ath9k_hw_common(sc->sc_ah); 142 char buf[32]; 143 unsigned int len; 144 145 len = sprintf(buf, "0x%08x\n", common->rx_chainmask); 146 return simple_read_from_buffer(user_buf, count, ppos, buf, len); 147 } 148 149 static ssize_t write_file_rx_chainmask(struct file *file, const char __user *user_buf, 150 size_t count, loff_t *ppos) 151 { 152 struct ath_softc *sc = file->private_data; 153 struct ath_common *common = ath9k_hw_common(sc->sc_ah); 154 unsigned long mask; 155 char buf[32]; 156 ssize_t len; 157 158 len = min(count, sizeof(buf) - 1); 159 if (copy_from_user(buf, user_buf, len)) 160 return -EFAULT; 161 162 buf[len] = '\0'; 163 if (strict_strtoul(buf, 0, &mask)) 164 return -EINVAL; 165 166 common->rx_chainmask = mask; 167 sc->sc_ah->caps.rx_chainmask = mask; 168 return count; 169 } 170 171 static const struct file_operations fops_rx_chainmask = { 172 .read = read_file_rx_chainmask, 173 .write = write_file_rx_chainmask, 174 .open = ath9k_debugfs_open, 175 .owner = THIS_MODULE, 176 .llseek = default_llseek, 177 }; 178 179 180 static ssize_t read_file_dma(struct file *file, char __user *user_buf, 181 size_t count, loff_t *ppos) 182 { 183 struct ath_softc *sc = file->private_data; 184 struct ath_hw *ah = sc->sc_ah; 185 char *buf; 186 int retval; 187 unsigned int len = 0; 188 u32 val[ATH9K_NUM_DMA_DEBUG_REGS]; 189 int i, qcuOffset = 0, dcuOffset = 0; 190 u32 *qcuBase = &val[0], *dcuBase = &val[4]; 191 192 buf = kmalloc(DMA_BUF_LEN, GFP_KERNEL); 193 if (!buf) 194 return -ENOMEM; 195 196 ath9k_ps_wakeup(sc); 197 198 REG_WRITE_D(ah, AR_MACMISC, 199 ((AR_MACMISC_DMA_OBS_LINE_8 << AR_MACMISC_DMA_OBS_S) | 200 (AR_MACMISC_MISC_OBS_BUS_1 << 201 AR_MACMISC_MISC_OBS_BUS_MSB_S))); 202 203 len += snprintf(buf + len, DMA_BUF_LEN - len, 204 "Raw DMA Debug values:\n"); 205 206 for (i = 0; i < ATH9K_NUM_DMA_DEBUG_REGS; i++) { 207 if (i % 4 == 0) 208 len += snprintf(buf + len, DMA_BUF_LEN - len, "\n"); 209 210 val[i] = REG_READ_D(ah, AR_DMADBG_0 + (i * sizeof(u32))); 211 len += snprintf(buf + len, DMA_BUF_LEN - len, "%d: %08x ", 212 i, val[i]); 213 } 214 215 len += snprintf(buf + len, DMA_BUF_LEN - len, "\n\n"); 216 len += snprintf(buf + len, DMA_BUF_LEN - len, 217 "Num QCU: chain_st fsp_ok fsp_st DCU: chain_st\n"); 218 219 for (i = 0; i < ATH9K_NUM_QUEUES; i++, qcuOffset += 4, dcuOffset += 5) { 220 if (i == 8) { 221 qcuOffset = 0; 222 qcuBase++; 223 } 224 225 if (i == 6) { 226 dcuOffset = 0; 227 dcuBase++; 228 } 229 230 len += snprintf(buf + len, DMA_BUF_LEN - len, 231 "%2d %2x %1x %2x %2x\n", 232 i, (*qcuBase & (0x7 << qcuOffset)) >> qcuOffset, 233 (*qcuBase & (0x8 << qcuOffset)) >> (qcuOffset + 3), 234 val[2] & (0x7 << (i * 3)) >> (i * 3), 235 (*dcuBase & (0x1f << dcuOffset)) >> dcuOffset); 236 } 237 238 len += snprintf(buf + len, DMA_BUF_LEN - len, "\n"); 239 240 len += snprintf(buf + len, DMA_BUF_LEN - len, 241 "qcu_stitch state: %2x qcu_fetch state: %2x\n", 242 (val[3] & 0x003c0000) >> 18, (val[3] & 0x03c00000) >> 22); 243 len += snprintf(buf + len, DMA_BUF_LEN - len, 244 "qcu_complete state: %2x dcu_complete state: %2x\n", 245 (val[3] & 0x1c000000) >> 26, (val[6] & 0x3)); 246 len += snprintf(buf + len, DMA_BUF_LEN - len, 247 "dcu_arb state: %2x dcu_fp state: %2x\n", 248 (val[5] & 0x06000000) >> 25, (val[5] & 0x38000000) >> 27); 249 len += snprintf(buf + len, DMA_BUF_LEN - len, 250 "chan_idle_dur: %3d chan_idle_dur_valid: %1d\n", 251 (val[6] & 0x000003fc) >> 2, (val[6] & 0x00000400) >> 10); 252 len += snprintf(buf + len, DMA_BUF_LEN - len, 253 "txfifo_valid_0: %1d txfifo_valid_1: %1d\n", 254 (val[6] & 0x00000800) >> 11, (val[6] & 0x00001000) >> 12); 255 len += snprintf(buf + len, DMA_BUF_LEN - len, 256 "txfifo_dcu_num_0: %2d txfifo_dcu_num_1: %2d\n", 257 (val[6] & 0x0001e000) >> 13, (val[6] & 0x001e0000) >> 17); 258 259 len += snprintf(buf + len, DMA_BUF_LEN - len, "pcu observe: 0x%x\n", 260 REG_READ_D(ah, AR_OBS_BUS_1)); 261 len += snprintf(buf + len, DMA_BUF_LEN - len, 262 "AR_CR: 0x%x\n", REG_READ_D(ah, AR_CR)); 263 264 ath9k_ps_restore(sc); 265 266 if (len > DMA_BUF_LEN) 267 len = DMA_BUF_LEN; 268 269 retval = simple_read_from_buffer(user_buf, count, ppos, buf, len); 270 kfree(buf); 271 return retval; 272 } 273 274 static const struct file_operations fops_dma = { 275 .read = read_file_dma, 276 .open = ath9k_debugfs_open, 277 .owner = THIS_MODULE, 278 .llseek = default_llseek, 279 }; 280 281 282 void ath_debug_stat_interrupt(struct ath_softc *sc, enum ath9k_int status) 283 { 284 if (status) 285 sc->debug.stats.istats.total++; 286 if (sc->sc_ah->caps.hw_caps & ATH9K_HW_CAP_EDMA) { 287 if (status & ATH9K_INT_RXLP) 288 sc->debug.stats.istats.rxlp++; 289 if (status & ATH9K_INT_RXHP) 290 sc->debug.stats.istats.rxhp++; 291 if (status & ATH9K_INT_BB_WATCHDOG) 292 sc->debug.stats.istats.bb_watchdog++; 293 } else { 294 if (status & ATH9K_INT_RX) 295 sc->debug.stats.istats.rxok++; 296 } 297 if (status & ATH9K_INT_RXEOL) 298 sc->debug.stats.istats.rxeol++; 299 if (status & ATH9K_INT_RXORN) 300 sc->debug.stats.istats.rxorn++; 301 if (status & ATH9K_INT_TX) 302 sc->debug.stats.istats.txok++; 303 if (status & ATH9K_INT_TXURN) 304 sc->debug.stats.istats.txurn++; 305 if (status & ATH9K_INT_MIB) 306 sc->debug.stats.istats.mib++; 307 if (status & ATH9K_INT_RXPHY) 308 sc->debug.stats.istats.rxphyerr++; 309 if (status & ATH9K_INT_RXKCM) 310 sc->debug.stats.istats.rx_keycache_miss++; 311 if (status & ATH9K_INT_SWBA) 312 sc->debug.stats.istats.swba++; 313 if (status & ATH9K_INT_BMISS) 314 sc->debug.stats.istats.bmiss++; 315 if (status & ATH9K_INT_BNR) 316 sc->debug.stats.istats.bnr++; 317 if (status & ATH9K_INT_CST) 318 sc->debug.stats.istats.cst++; 319 if (status & ATH9K_INT_GTT) 320 sc->debug.stats.istats.gtt++; 321 if (status & ATH9K_INT_TIM) 322 sc->debug.stats.istats.tim++; 323 if (status & ATH9K_INT_CABEND) 324 sc->debug.stats.istats.cabend++; 325 if (status & ATH9K_INT_DTIMSYNC) 326 sc->debug.stats.istats.dtimsync++; 327 if (status & ATH9K_INT_DTIM) 328 sc->debug.stats.istats.dtim++; 329 } 330 331 static ssize_t read_file_interrupt(struct file *file, char __user *user_buf, 332 size_t count, loff_t *ppos) 333 { 334 struct ath_softc *sc = file->private_data; 335 char buf[512]; 336 unsigned int len = 0; 337 338 if (sc->sc_ah->caps.hw_caps & ATH9K_HW_CAP_EDMA) { 339 len += snprintf(buf + len, sizeof(buf) - len, 340 "%8s: %10u\n", "RXLP", sc->debug.stats.istats.rxlp); 341 len += snprintf(buf + len, sizeof(buf) - len, 342 "%8s: %10u\n", "RXHP", sc->debug.stats.istats.rxhp); 343 len += snprintf(buf + len, sizeof(buf) - len, 344 "%8s: %10u\n", "WATCHDOG", 345 sc->debug.stats.istats.bb_watchdog); 346 } else { 347 len += snprintf(buf + len, sizeof(buf) - len, 348 "%8s: %10u\n", "RX", sc->debug.stats.istats.rxok); 349 } 350 len += snprintf(buf + len, sizeof(buf) - len, 351 "%8s: %10u\n", "RXEOL", sc->debug.stats.istats.rxeol); 352 len += snprintf(buf + len, sizeof(buf) - len, 353 "%8s: %10u\n", "RXORN", sc->debug.stats.istats.rxorn); 354 len += snprintf(buf + len, sizeof(buf) - len, 355 "%8s: %10u\n", "TX", sc->debug.stats.istats.txok); 356 len += snprintf(buf + len, sizeof(buf) - len, 357 "%8s: %10u\n", "TXURN", sc->debug.stats.istats.txurn); 358 len += snprintf(buf + len, sizeof(buf) - len, 359 "%8s: %10u\n", "MIB", sc->debug.stats.istats.mib); 360 len += snprintf(buf + len, sizeof(buf) - len, 361 "%8s: %10u\n", "RXPHY", sc->debug.stats.istats.rxphyerr); 362 len += snprintf(buf + len, sizeof(buf) - len, 363 "%8s: %10u\n", "RXKCM", sc->debug.stats.istats.rx_keycache_miss); 364 len += snprintf(buf + len, sizeof(buf) - len, 365 "%8s: %10u\n", "SWBA", sc->debug.stats.istats.swba); 366 len += snprintf(buf + len, sizeof(buf) - len, 367 "%8s: %10u\n", "BMISS", sc->debug.stats.istats.bmiss); 368 len += snprintf(buf + len, sizeof(buf) - len, 369 "%8s: %10u\n", "BNR", sc->debug.stats.istats.bnr); 370 len += snprintf(buf + len, sizeof(buf) - len, 371 "%8s: %10u\n", "CST", sc->debug.stats.istats.cst); 372 len += snprintf(buf + len, sizeof(buf) - len, 373 "%8s: %10u\n", "GTT", sc->debug.stats.istats.gtt); 374 len += snprintf(buf + len, sizeof(buf) - len, 375 "%8s: %10u\n", "TIM", sc->debug.stats.istats.tim); 376 len += snprintf(buf + len, sizeof(buf) - len, 377 "%8s: %10u\n", "CABEND", sc->debug.stats.istats.cabend); 378 len += snprintf(buf + len, sizeof(buf) - len, 379 "%8s: %10u\n", "DTIMSYNC", sc->debug.stats.istats.dtimsync); 380 len += snprintf(buf + len, sizeof(buf) - len, 381 "%8s: %10u\n", "DTIM", sc->debug.stats.istats.dtim); 382 len += snprintf(buf + len, sizeof(buf) - len, 383 "%8s: %10u\n", "TOTAL", sc->debug.stats.istats.total); 384 385 if (len > sizeof(buf)) 386 len = sizeof(buf); 387 388 return simple_read_from_buffer(user_buf, count, ppos, buf, len); 389 } 390 391 static const struct file_operations fops_interrupt = { 392 .read = read_file_interrupt, 393 .open = ath9k_debugfs_open, 394 .owner = THIS_MODULE, 395 .llseek = default_llseek, 396 }; 397 398 static const char *channel_type_str(enum nl80211_channel_type t) 399 { 400 switch (t) { 401 case NL80211_CHAN_NO_HT: 402 return "no ht"; 403 case NL80211_CHAN_HT20: 404 return "ht20"; 405 case NL80211_CHAN_HT40MINUS: 406 return "ht40-"; 407 case NL80211_CHAN_HT40PLUS: 408 return "ht40+"; 409 default: 410 return "???"; 411 } 412 } 413 414 static ssize_t read_file_wiphy(struct file *file, char __user *user_buf, 415 size_t count, loff_t *ppos) 416 { 417 struct ath_softc *sc = file->private_data; 418 struct ieee80211_channel *chan = sc->hw->conf.channel; 419 struct ieee80211_conf *conf = &(sc->hw->conf); 420 char buf[512]; 421 unsigned int len = 0; 422 u8 addr[ETH_ALEN]; 423 u32 tmp; 424 425 len += snprintf(buf + len, sizeof(buf) - len, 426 "%s (chan=%d center-freq: %d MHz channel-type: %d (%s))\n", 427 wiphy_name(sc->hw->wiphy), 428 ieee80211_frequency_to_channel(chan->center_freq), 429 chan->center_freq, 430 conf->channel_type, 431 channel_type_str(conf->channel_type)); 432 433 put_unaligned_le32(REG_READ_D(sc->sc_ah, AR_STA_ID0), addr); 434 put_unaligned_le16(REG_READ_D(sc->sc_ah, AR_STA_ID1) & 0xffff, addr + 4); 435 len += snprintf(buf + len, sizeof(buf) - len, 436 "addr: %pM\n", addr); 437 put_unaligned_le32(REG_READ_D(sc->sc_ah, AR_BSSMSKL), addr); 438 put_unaligned_le16(REG_READ_D(sc->sc_ah, AR_BSSMSKU) & 0xffff, addr + 4); 439 len += snprintf(buf + len, sizeof(buf) - len, 440 "addrmask: %pM\n", addr); 441 tmp = ath9k_hw_getrxfilter(sc->sc_ah); 442 len += snprintf(buf + len, sizeof(buf) - len, 443 "rfilt: 0x%x", tmp); 444 if (tmp & ATH9K_RX_FILTER_UCAST) 445 len += snprintf(buf + len, sizeof(buf) - len, " UCAST"); 446 if (tmp & ATH9K_RX_FILTER_MCAST) 447 len += snprintf(buf + len, sizeof(buf) - len, " MCAST"); 448 if (tmp & ATH9K_RX_FILTER_BCAST) 449 len += snprintf(buf + len, sizeof(buf) - len, " BCAST"); 450 if (tmp & ATH9K_RX_FILTER_CONTROL) 451 len += snprintf(buf + len, sizeof(buf) - len, " CONTROL"); 452 if (tmp & ATH9K_RX_FILTER_BEACON) 453 len += snprintf(buf + len, sizeof(buf) - len, " BEACON"); 454 if (tmp & ATH9K_RX_FILTER_PROM) 455 len += snprintf(buf + len, sizeof(buf) - len, " PROM"); 456 if (tmp & ATH9K_RX_FILTER_PROBEREQ) 457 len += snprintf(buf + len, sizeof(buf) - len, " PROBEREQ"); 458 if (tmp & ATH9K_RX_FILTER_PHYERR) 459 len += snprintf(buf + len, sizeof(buf) - len, " PHYERR"); 460 if (tmp & ATH9K_RX_FILTER_MYBEACON) 461 len += snprintf(buf + len, sizeof(buf) - len, " MYBEACON"); 462 if (tmp & ATH9K_RX_FILTER_COMP_BAR) 463 len += snprintf(buf + len, sizeof(buf) - len, " COMP_BAR"); 464 if (tmp & ATH9K_RX_FILTER_PSPOLL) 465 len += snprintf(buf + len, sizeof(buf) - len, " PSPOLL"); 466 if (tmp & ATH9K_RX_FILTER_PHYRADAR) 467 len += snprintf(buf + len, sizeof(buf) - len, " PHYRADAR"); 468 if (tmp & ATH9K_RX_FILTER_MCAST_BCAST_ALL) 469 len += snprintf(buf + len, sizeof(buf) - len, " MCAST_BCAST_ALL\n"); 470 else 471 len += snprintf(buf + len, sizeof(buf) - len, "\n"); 472 473 if (len > sizeof(buf)) 474 len = sizeof(buf); 475 476 return simple_read_from_buffer(user_buf, count, ppos, buf, len); 477 } 478 479 static const struct file_operations fops_wiphy = { 480 .read = read_file_wiphy, 481 .open = ath9k_debugfs_open, 482 .owner = THIS_MODULE, 483 .llseek = default_llseek, 484 }; 485 486 #define PR_QNUM(_n) sc->tx.txq_map[_n]->axq_qnum 487 #define PR(str, elem) \ 488 do { \ 489 len += snprintf(buf + len, size - len, \ 490 "%s%13u%11u%10u%10u\n", str, \ 491 sc->debug.stats.txstats[PR_QNUM(WME_AC_BE)].elem, \ 492 sc->debug.stats.txstats[PR_QNUM(WME_AC_BK)].elem, \ 493 sc->debug.stats.txstats[PR_QNUM(WME_AC_VI)].elem, \ 494 sc->debug.stats.txstats[PR_QNUM(WME_AC_VO)].elem); \ 495 if (len >= size) \ 496 goto done; \ 497 } while(0) 498 499 #define PRX(str, elem) \ 500 do { \ 501 len += snprintf(buf + len, size - len, \ 502 "%s%13u%11u%10u%10u\n", str, \ 503 (unsigned int)(sc->tx.txq_map[WME_AC_BE]->elem), \ 504 (unsigned int)(sc->tx.txq_map[WME_AC_BK]->elem), \ 505 (unsigned int)(sc->tx.txq_map[WME_AC_VI]->elem), \ 506 (unsigned int)(sc->tx.txq_map[WME_AC_VO]->elem)); \ 507 if (len >= size) \ 508 goto done; \ 509 } while(0) 510 511 #define PRQLE(str, elem) \ 512 do { \ 513 len += snprintf(buf + len, size - len, \ 514 "%s%13i%11i%10i%10i\n", str, \ 515 list_empty(&sc->tx.txq_map[WME_AC_BE]->elem), \ 516 list_empty(&sc->tx.txq_map[WME_AC_BK]->elem), \ 517 list_empty(&sc->tx.txq_map[WME_AC_VI]->elem), \ 518 list_empty(&sc->tx.txq_map[WME_AC_VO]->elem)); \ 519 if (len >= size) \ 520 goto done; \ 521 } while (0) 522 523 static ssize_t read_file_xmit(struct file *file, char __user *user_buf, 524 size_t count, loff_t *ppos) 525 { 526 struct ath_softc *sc = file->private_data; 527 char *buf; 528 unsigned int len = 0, size = 8000; 529 int i; 530 ssize_t retval = 0; 531 char tmp[32]; 532 533 buf = kzalloc(size, GFP_KERNEL); 534 if (buf == NULL) 535 return -ENOMEM; 536 537 len += sprintf(buf, "Num-Tx-Queues: %i tx-queues-setup: 0x%x" 538 " poll-work-seen: %u\n" 539 "%30s %10s%10s%10s\n\n", 540 ATH9K_NUM_TX_QUEUES, sc->tx.txqsetup, 541 sc->tx_complete_poll_work_seen, 542 "BE", "BK", "VI", "VO"); 543 544 PR("MPDUs Queued: ", queued); 545 PR("MPDUs Completed: ", completed); 546 PR("Aggregates: ", a_aggr); 547 PR("AMPDUs Queued HW:", a_queued_hw); 548 PR("AMPDUs Queued SW:", a_queued_sw); 549 PR("AMPDUs Completed:", a_completed); 550 PR("AMPDUs Retried: ", a_retries); 551 PR("AMPDUs XRetried: ", a_xretries); 552 PR("FIFO Underrun: ", fifo_underrun); 553 PR("TXOP Exceeded: ", xtxop); 554 PR("TXTIMER Expiry: ", timer_exp); 555 PR("DESC CFG Error: ", desc_cfg_err); 556 PR("DATA Underrun: ", data_underrun); 557 PR("DELIM Underrun: ", delim_underrun); 558 PR("TX-Pkts-All: ", tx_pkts_all); 559 PR("TX-Bytes-All: ", tx_bytes_all); 560 PR("hw-put-tx-buf: ", puttxbuf); 561 PR("hw-tx-start: ", txstart); 562 PR("hw-tx-proc-desc: ", txprocdesc); 563 len += snprintf(buf + len, size - len, 564 "%s%11p%11p%10p%10p\n", "txq-memory-address:", 565 sc->tx.txq_map[WME_AC_BE], 566 sc->tx.txq_map[WME_AC_BK], 567 sc->tx.txq_map[WME_AC_VI], 568 sc->tx.txq_map[WME_AC_VO]); 569 if (len >= size) 570 goto done; 571 572 PRX("axq-qnum: ", axq_qnum); 573 PRX("axq-depth: ", axq_depth); 574 PRX("axq-ampdu_depth: ", axq_ampdu_depth); 575 PRX("axq-stopped ", stopped); 576 PRX("tx-in-progress ", axq_tx_inprogress); 577 PRX("pending-frames ", pending_frames); 578 PRX("txq_headidx: ", txq_headidx); 579 PRX("txq_tailidx: ", txq_headidx); 580 581 PRQLE("axq_q empty: ", axq_q); 582 PRQLE("axq_acq empty: ", axq_acq); 583 PRQLE("txq_fifo_pending: ", txq_fifo_pending); 584 for (i = 0; i < ATH_TXFIFO_DEPTH; i++) { 585 snprintf(tmp, sizeof(tmp) - 1, "txq_fifo[%i] empty: ", i); 586 PRQLE(tmp, txq_fifo[i]); 587 } 588 589 /* Print out more detailed queue-info */ 590 for (i = 0; i <= WME_AC_BK; i++) { 591 struct ath_txq *txq = &(sc->tx.txq[i]); 592 struct ath_atx_ac *ac; 593 struct ath_atx_tid *tid; 594 if (len >= size) 595 goto done; 596 spin_lock_bh(&txq->axq_lock); 597 if (!list_empty(&txq->axq_acq)) { 598 ac = list_first_entry(&txq->axq_acq, struct ath_atx_ac, 599 list); 600 len += snprintf(buf + len, size - len, 601 "txq[%i] first-ac: %p sched: %i\n", 602 i, ac, ac->sched); 603 if (list_empty(&ac->tid_q) || (len >= size)) 604 goto done_for; 605 tid = list_first_entry(&ac->tid_q, struct ath_atx_tid, 606 list); 607 len += snprintf(buf + len, size - len, 608 " first-tid: %p sched: %i paused: %i\n", 609 tid, tid->sched, tid->paused); 610 } 611 done_for: 612 spin_unlock_bh(&txq->axq_lock); 613 } 614 615 done: 616 if (len > size) 617 len = size; 618 619 retval = simple_read_from_buffer(user_buf, count, ppos, buf, len); 620 kfree(buf); 621 622 return retval; 623 } 624 625 static ssize_t read_file_stations(struct file *file, char __user *user_buf, 626 size_t count, loff_t *ppos) 627 { 628 struct ath_softc *sc = file->private_data; 629 char *buf; 630 unsigned int len = 0, size = 64000; 631 struct ath_node *an = NULL; 632 ssize_t retval = 0; 633 int q; 634 635 buf = kzalloc(size, GFP_KERNEL); 636 if (buf == NULL) 637 return -ENOMEM; 638 639 len += snprintf(buf + len, size - len, 640 "Stations:\n" 641 " tid: addr sched paused buf_q-empty an ac\n" 642 " ac: addr sched tid_q-empty txq\n"); 643 644 spin_lock(&sc->nodes_lock); 645 list_for_each_entry(an, &sc->nodes, list) { 646 len += snprintf(buf + len, size - len, 647 "%pM\n", an->sta->addr); 648 if (len >= size) 649 goto done; 650 651 for (q = 0; q < WME_NUM_TID; q++) { 652 struct ath_atx_tid *tid = &(an->tid[q]); 653 len += snprintf(buf + len, size - len, 654 " tid: %p %s %s %i %p %p\n", 655 tid, tid->sched ? "sched" : "idle", 656 tid->paused ? "paused" : "running", 657 list_empty(&tid->buf_q), 658 tid->an, tid->ac); 659 if (len >= size) 660 goto done; 661 } 662 663 for (q = 0; q < WME_NUM_AC; q++) { 664 struct ath_atx_ac *ac = &(an->ac[q]); 665 len += snprintf(buf + len, size - len, 666 " ac: %p %s %i %p\n", 667 ac, ac->sched ? "sched" : "idle", 668 list_empty(&ac->tid_q), ac->txq); 669 if (len >= size) 670 goto done; 671 } 672 } 673 674 done: 675 spin_unlock(&sc->nodes_lock); 676 if (len > size) 677 len = size; 678 679 retval = simple_read_from_buffer(user_buf, count, ppos, buf, len); 680 kfree(buf); 681 682 return retval; 683 } 684 685 static ssize_t read_file_misc(struct file *file, char __user *user_buf, 686 size_t count, loff_t *ppos) 687 { 688 struct ath_softc *sc = file->private_data; 689 struct ath_common *common = ath9k_hw_common(sc->sc_ah); 690 struct ath_hw *ah = sc->sc_ah; 691 struct ieee80211_hw *hw = sc->hw; 692 char *buf; 693 unsigned int len = 0, size = 8000; 694 ssize_t retval = 0; 695 const char *tmp; 696 unsigned int reg; 697 struct ath9k_vif_iter_data iter_data; 698 699 ath9k_calculate_iter_data(hw, NULL, &iter_data); 700 701 buf = kzalloc(size, GFP_KERNEL); 702 if (buf == NULL) 703 return -ENOMEM; 704 705 switch (sc->sc_ah->opmode) { 706 case NL80211_IFTYPE_ADHOC: 707 tmp = "ADHOC"; 708 break; 709 case NL80211_IFTYPE_MESH_POINT: 710 tmp = "MESH"; 711 break; 712 case NL80211_IFTYPE_AP: 713 tmp = "AP"; 714 break; 715 case NL80211_IFTYPE_STATION: 716 tmp = "STATION"; 717 break; 718 default: 719 tmp = "???"; 720 break; 721 } 722 723 len += snprintf(buf + len, size - len, 724 "curbssid: %pM\n" 725 "OP-Mode: %s(%i)\n" 726 "Beacon-Timer-Register: 0x%x\n", 727 common->curbssid, 728 tmp, (int)(sc->sc_ah->opmode), 729 REG_READ(ah, AR_BEACON_PERIOD)); 730 731 reg = REG_READ(ah, AR_TIMER_MODE); 732 len += snprintf(buf + len, size - len, "Timer-Mode-Register: 0x%x (", 733 reg); 734 if (reg & AR_TBTT_TIMER_EN) 735 len += snprintf(buf + len, size - len, "TBTT "); 736 if (reg & AR_DBA_TIMER_EN) 737 len += snprintf(buf + len, size - len, "DBA "); 738 if (reg & AR_SWBA_TIMER_EN) 739 len += snprintf(buf + len, size - len, "SWBA "); 740 if (reg & AR_HCF_TIMER_EN) 741 len += snprintf(buf + len, size - len, "HCF "); 742 if (reg & AR_TIM_TIMER_EN) 743 len += snprintf(buf + len, size - len, "TIM "); 744 if (reg & AR_DTIM_TIMER_EN) 745 len += snprintf(buf + len, size - len, "DTIM "); 746 len += snprintf(buf + len, size - len, ")\n"); 747 748 reg = sc->sc_ah->imask; 749 len += snprintf(buf + len, size - len, "imask: 0x%x (", reg); 750 if (reg & ATH9K_INT_SWBA) 751 len += snprintf(buf + len, size - len, "SWBA "); 752 if (reg & ATH9K_INT_BMISS) 753 len += snprintf(buf + len, size - len, "BMISS "); 754 if (reg & ATH9K_INT_CST) 755 len += snprintf(buf + len, size - len, "CST "); 756 if (reg & ATH9K_INT_RX) 757 len += snprintf(buf + len, size - len, "RX "); 758 if (reg & ATH9K_INT_RXHP) 759 len += snprintf(buf + len, size - len, "RXHP "); 760 if (reg & ATH9K_INT_RXLP) 761 len += snprintf(buf + len, size - len, "RXLP "); 762 if (reg & ATH9K_INT_BB_WATCHDOG) 763 len += snprintf(buf + len, size - len, "BB_WATCHDOG "); 764 /* there are other IRQs if one wanted to add them. */ 765 len += snprintf(buf + len, size - len, ")\n"); 766 767 len += snprintf(buf + len, size - len, 768 "VIF Counts: AP: %i STA: %i MESH: %i WDS: %i" 769 " ADHOC: %i OTHER: %i nvifs: %hi beacon-vifs: %hi\n", 770 iter_data.naps, iter_data.nstations, iter_data.nmeshes, 771 iter_data.nwds, iter_data.nadhocs, iter_data.nothers, 772 sc->nvifs, sc->nbcnvifs); 773 774 len += snprintf(buf + len, size - len, 775 "Calculated-BSSID-Mask: %pM\n", 776 iter_data.mask); 777 778 if (len > size) 779 len = size; 780 781 retval = simple_read_from_buffer(user_buf, count, ppos, buf, len); 782 kfree(buf); 783 784 return retval; 785 } 786 787 void ath_debug_stat_tx(struct ath_softc *sc, struct ath_buf *bf, 788 struct ath_tx_status *ts, struct ath_txq *txq) 789 { 790 int qnum = txq->axq_qnum; 791 792 TX_STAT_INC(qnum, tx_pkts_all); 793 sc->debug.stats.txstats[qnum].tx_bytes_all += bf->bf_mpdu->len; 794 795 if (bf_isampdu(bf)) { 796 if (bf_isxretried(bf)) 797 TX_STAT_INC(qnum, a_xretries); 798 else 799 TX_STAT_INC(qnum, a_completed); 800 } else { 801 TX_STAT_INC(qnum, completed); 802 } 803 804 if (ts->ts_status & ATH9K_TXERR_FIFO) 805 TX_STAT_INC(qnum, fifo_underrun); 806 if (ts->ts_status & ATH9K_TXERR_XTXOP) 807 TX_STAT_INC(qnum, xtxop); 808 if (ts->ts_status & ATH9K_TXERR_TIMER_EXPIRED) 809 TX_STAT_INC(qnum, timer_exp); 810 if (ts->ts_flags & ATH9K_TX_DESC_CFG_ERR) 811 TX_STAT_INC(qnum, desc_cfg_err); 812 if (ts->ts_flags & ATH9K_TX_DATA_UNDERRUN) 813 TX_STAT_INC(qnum, data_underrun); 814 if (ts->ts_flags & ATH9K_TX_DELIM_UNDERRUN) 815 TX_STAT_INC(qnum, delim_underrun); 816 } 817 818 static const struct file_operations fops_xmit = { 819 .read = read_file_xmit, 820 .open = ath9k_debugfs_open, 821 .owner = THIS_MODULE, 822 .llseek = default_llseek, 823 }; 824 825 static const struct file_operations fops_stations = { 826 .read = read_file_stations, 827 .open = ath9k_debugfs_open, 828 .owner = THIS_MODULE, 829 .llseek = default_llseek, 830 }; 831 832 static const struct file_operations fops_misc = { 833 .read = read_file_misc, 834 .open = ath9k_debugfs_open, 835 .owner = THIS_MODULE, 836 .llseek = default_llseek, 837 }; 838 839 static ssize_t read_file_recv(struct file *file, char __user *user_buf, 840 size_t count, loff_t *ppos) 841 { 842 #define PHY_ERR(s, p) \ 843 len += snprintf(buf + len, size - len, "%18s : %10u\n", s, \ 844 sc->debug.stats.rxstats.phy_err_stats[p]); 845 846 struct ath_softc *sc = file->private_data; 847 char *buf; 848 unsigned int len = 0, size = 1152; 849 ssize_t retval = 0; 850 851 buf = kzalloc(size, GFP_KERNEL); 852 if (buf == NULL) 853 return -ENOMEM; 854 855 len += snprintf(buf + len, size - len, 856 "%18s : %10u\n", "CRC ERR", 857 sc->debug.stats.rxstats.crc_err); 858 len += snprintf(buf + len, size - len, 859 "%18s : %10u\n", "DECRYPT CRC ERR", 860 sc->debug.stats.rxstats.decrypt_crc_err); 861 len += snprintf(buf + len, size - len, 862 "%18s : %10u\n", "PHY ERR", 863 sc->debug.stats.rxstats.phy_err); 864 len += snprintf(buf + len, size - len, 865 "%18s : %10u\n", "MIC ERR", 866 sc->debug.stats.rxstats.mic_err); 867 len += snprintf(buf + len, size - len, 868 "%18s : %10u\n", "PRE-DELIM CRC ERR", 869 sc->debug.stats.rxstats.pre_delim_crc_err); 870 len += snprintf(buf + len, size - len, 871 "%18s : %10u\n", "POST-DELIM CRC ERR", 872 sc->debug.stats.rxstats.post_delim_crc_err); 873 len += snprintf(buf + len, size - len, 874 "%18s : %10u\n", "DECRYPT BUSY ERR", 875 sc->debug.stats.rxstats.decrypt_busy_err); 876 877 PHY_ERR("UNDERRUN", ATH9K_PHYERR_UNDERRUN); 878 PHY_ERR("TIMING", ATH9K_PHYERR_TIMING); 879 PHY_ERR("PARITY", ATH9K_PHYERR_PARITY); 880 PHY_ERR("RATE", ATH9K_PHYERR_RATE); 881 PHY_ERR("LENGTH", ATH9K_PHYERR_LENGTH); 882 PHY_ERR("RADAR", ATH9K_PHYERR_RADAR); 883 PHY_ERR("SERVICE", ATH9K_PHYERR_SERVICE); 884 PHY_ERR("TOR", ATH9K_PHYERR_TOR); 885 PHY_ERR("OFDM-TIMING", ATH9K_PHYERR_OFDM_TIMING); 886 PHY_ERR("OFDM-SIGNAL-PARITY", ATH9K_PHYERR_OFDM_SIGNAL_PARITY); 887 PHY_ERR("OFDM-RATE", ATH9K_PHYERR_OFDM_RATE_ILLEGAL); 888 PHY_ERR("OFDM-LENGTH", ATH9K_PHYERR_OFDM_LENGTH_ILLEGAL); 889 PHY_ERR("OFDM-POWER-DROP", ATH9K_PHYERR_OFDM_POWER_DROP); 890 PHY_ERR("OFDM-SERVICE", ATH9K_PHYERR_OFDM_SERVICE); 891 PHY_ERR("OFDM-RESTART", ATH9K_PHYERR_OFDM_RESTART); 892 PHY_ERR("FALSE-RADAR-EXT", ATH9K_PHYERR_FALSE_RADAR_EXT); 893 PHY_ERR("CCK-TIMING", ATH9K_PHYERR_CCK_TIMING); 894 PHY_ERR("CCK-HEADER-CRC", ATH9K_PHYERR_CCK_HEADER_CRC); 895 PHY_ERR("CCK-RATE", ATH9K_PHYERR_CCK_RATE_ILLEGAL); 896 PHY_ERR("CCK-SERVICE", ATH9K_PHYERR_CCK_SERVICE); 897 PHY_ERR("CCK-RESTART", ATH9K_PHYERR_CCK_RESTART); 898 PHY_ERR("CCK-LENGTH", ATH9K_PHYERR_CCK_LENGTH_ILLEGAL); 899 PHY_ERR("CCK-POWER-DROP", ATH9K_PHYERR_CCK_POWER_DROP); 900 PHY_ERR("HT-CRC", ATH9K_PHYERR_HT_CRC_ERROR); 901 PHY_ERR("HT-LENGTH", ATH9K_PHYERR_HT_LENGTH_ILLEGAL); 902 PHY_ERR("HT-RATE", ATH9K_PHYERR_HT_RATE_ILLEGAL); 903 904 len += snprintf(buf + len, size - len, 905 "%18s : %10u\n", "RX-Pkts-All", 906 sc->debug.stats.rxstats.rx_pkts_all); 907 len += snprintf(buf + len, size - len, 908 "%18s : %10u\n", "RX-Bytes-All", 909 sc->debug.stats.rxstats.rx_bytes_all); 910 911 if (len > size) 912 len = size; 913 914 retval = simple_read_from_buffer(user_buf, count, ppos, buf, len); 915 kfree(buf); 916 917 return retval; 918 919 #undef PHY_ERR 920 } 921 922 void ath_debug_stat_rx(struct ath_softc *sc, struct ath_rx_status *rs) 923 { 924 #define RX_STAT_INC(c) sc->debug.stats.rxstats.c++ 925 #define RX_PHY_ERR_INC(c) sc->debug.stats.rxstats.phy_err_stats[c]++ 926 927 u32 phyerr; 928 929 RX_STAT_INC(rx_pkts_all); 930 sc->debug.stats.rxstats.rx_bytes_all += rs->rs_datalen; 931 932 if (rs->rs_status & ATH9K_RXERR_CRC) 933 RX_STAT_INC(crc_err); 934 if (rs->rs_status & ATH9K_RXERR_DECRYPT) 935 RX_STAT_INC(decrypt_crc_err); 936 if (rs->rs_status & ATH9K_RXERR_MIC) 937 RX_STAT_INC(mic_err); 938 if (rs->rs_status & ATH9K_RX_DELIM_CRC_PRE) 939 RX_STAT_INC(pre_delim_crc_err); 940 if (rs->rs_status & ATH9K_RX_DELIM_CRC_POST) 941 RX_STAT_INC(post_delim_crc_err); 942 if (rs->rs_status & ATH9K_RX_DECRYPT_BUSY) 943 RX_STAT_INC(decrypt_busy_err); 944 945 if (rs->rs_status & ATH9K_RXERR_PHY) { 946 RX_STAT_INC(phy_err); 947 phyerr = rs->rs_phyerr & 0x24; 948 RX_PHY_ERR_INC(phyerr); 949 } 950 951 #undef RX_STAT_INC 952 #undef RX_PHY_ERR_INC 953 } 954 955 static const struct file_operations fops_recv = { 956 .read = read_file_recv, 957 .open = ath9k_debugfs_open, 958 .owner = THIS_MODULE, 959 .llseek = default_llseek, 960 }; 961 962 static ssize_t read_file_regidx(struct file *file, char __user *user_buf, 963 size_t count, loff_t *ppos) 964 { 965 struct ath_softc *sc = file->private_data; 966 char buf[32]; 967 unsigned int len; 968 969 len = sprintf(buf, "0x%08x\n", sc->debug.regidx); 970 return simple_read_from_buffer(user_buf, count, ppos, buf, len); 971 } 972 973 static ssize_t write_file_regidx(struct file *file, const char __user *user_buf, 974 size_t count, loff_t *ppos) 975 { 976 struct ath_softc *sc = file->private_data; 977 unsigned long regidx; 978 char buf[32]; 979 ssize_t len; 980 981 len = min(count, sizeof(buf) - 1); 982 if (copy_from_user(buf, user_buf, len)) 983 return -EFAULT; 984 985 buf[len] = '\0'; 986 if (strict_strtoul(buf, 0, ®idx)) 987 return -EINVAL; 988 989 sc->debug.regidx = regidx; 990 return count; 991 } 992 993 static const struct file_operations fops_regidx = { 994 .read = read_file_regidx, 995 .write = write_file_regidx, 996 .open = ath9k_debugfs_open, 997 .owner = THIS_MODULE, 998 .llseek = default_llseek, 999 }; 1000 1001 static ssize_t read_file_regval(struct file *file, char __user *user_buf, 1002 size_t count, loff_t *ppos) 1003 { 1004 struct ath_softc *sc = file->private_data; 1005 struct ath_hw *ah = sc->sc_ah; 1006 char buf[32]; 1007 unsigned int len; 1008 u32 regval; 1009 1010 regval = REG_READ_D(ah, sc->debug.regidx); 1011 len = sprintf(buf, "0x%08x\n", regval); 1012 return simple_read_from_buffer(user_buf, count, ppos, buf, len); 1013 } 1014 1015 static ssize_t write_file_regval(struct file *file, const char __user *user_buf, 1016 size_t count, loff_t *ppos) 1017 { 1018 struct ath_softc *sc = file->private_data; 1019 struct ath_hw *ah = sc->sc_ah; 1020 unsigned long regval; 1021 char buf[32]; 1022 ssize_t len; 1023 1024 len = min(count, sizeof(buf) - 1); 1025 if (copy_from_user(buf, user_buf, len)) 1026 return -EFAULT; 1027 1028 buf[len] = '\0'; 1029 if (strict_strtoul(buf, 0, ®val)) 1030 return -EINVAL; 1031 1032 REG_WRITE_D(ah, sc->debug.regidx, regval); 1033 return count; 1034 } 1035 1036 static const struct file_operations fops_regval = { 1037 .read = read_file_regval, 1038 .write = write_file_regval, 1039 .open = ath9k_debugfs_open, 1040 .owner = THIS_MODULE, 1041 .llseek = default_llseek, 1042 }; 1043 1044 #define REGDUMP_LINE_SIZE 20 1045 1046 static int open_file_regdump(struct inode *inode, struct file *file) 1047 { 1048 struct ath_softc *sc = inode->i_private; 1049 unsigned int len = 0; 1050 u8 *buf; 1051 int i; 1052 unsigned long num_regs, regdump_len, max_reg_offset; 1053 1054 max_reg_offset = AR_SREV_9300_20_OR_LATER(sc->sc_ah) ? 0x16bd4 : 0xb500; 1055 num_regs = max_reg_offset / 4 + 1; 1056 regdump_len = num_regs * REGDUMP_LINE_SIZE + 1; 1057 buf = vmalloc(regdump_len); 1058 if (!buf) 1059 return -ENOMEM; 1060 1061 ath9k_ps_wakeup(sc); 1062 for (i = 0; i < num_regs; i++) 1063 len += scnprintf(buf + len, regdump_len - len, 1064 "0x%06x 0x%08x\n", i << 2, REG_READ(sc->sc_ah, i << 2)); 1065 ath9k_ps_restore(sc); 1066 1067 file->private_data = buf; 1068 1069 return 0; 1070 } 1071 1072 static const struct file_operations fops_regdump = { 1073 .open = open_file_regdump, 1074 .read = ath9k_debugfs_read_buf, 1075 .release = ath9k_debugfs_release_buf, 1076 .owner = THIS_MODULE, 1077 .llseek = default_llseek,/* read accesses f_pos */ 1078 }; 1079 1080 int ath9k_init_debug(struct ath_hw *ah) 1081 { 1082 struct ath_common *common = ath9k_hw_common(ah); 1083 struct ath_softc *sc = (struct ath_softc *) common->priv; 1084 1085 sc->debug.debugfs_phy = debugfs_create_dir("ath9k", 1086 sc->hw->wiphy->debugfsdir); 1087 if (!sc->debug.debugfs_phy) 1088 return -ENOMEM; 1089 1090 #ifdef CONFIG_ATH_DEBUG 1091 if (!debugfs_create_file("debug", S_IRUSR | S_IWUSR, 1092 sc->debug.debugfs_phy, sc, &fops_debug)) 1093 goto err; 1094 #endif 1095 1096 if (!debugfs_create_file("dma", S_IRUSR, sc->debug.debugfs_phy, 1097 sc, &fops_dma)) 1098 goto err; 1099 1100 if (!debugfs_create_file("interrupt", S_IRUSR, sc->debug.debugfs_phy, 1101 sc, &fops_interrupt)) 1102 goto err; 1103 1104 if (!debugfs_create_file("wiphy", S_IRUSR | S_IWUSR, 1105 sc->debug.debugfs_phy, sc, &fops_wiphy)) 1106 goto err; 1107 1108 if (!debugfs_create_file("xmit", S_IRUSR, sc->debug.debugfs_phy, 1109 sc, &fops_xmit)) 1110 goto err; 1111 1112 if (!debugfs_create_file("stations", S_IRUSR, sc->debug.debugfs_phy, 1113 sc, &fops_stations)) 1114 goto err; 1115 1116 if (!debugfs_create_file("misc", S_IRUSR, sc->debug.debugfs_phy, 1117 sc, &fops_misc)) 1118 goto err; 1119 1120 if (!debugfs_create_file("recv", S_IRUSR, sc->debug.debugfs_phy, 1121 sc, &fops_recv)) 1122 goto err; 1123 1124 if (!debugfs_create_file("rx_chainmask", S_IRUSR | S_IWUSR, 1125 sc->debug.debugfs_phy, sc, &fops_rx_chainmask)) 1126 goto err; 1127 1128 if (!debugfs_create_file("tx_chainmask", S_IRUSR | S_IWUSR, 1129 sc->debug.debugfs_phy, sc, &fops_tx_chainmask)) 1130 goto err; 1131 1132 if (!debugfs_create_file("regidx", S_IRUSR | S_IWUSR, 1133 sc->debug.debugfs_phy, sc, &fops_regidx)) 1134 goto err; 1135 1136 if (!debugfs_create_file("regval", S_IRUSR | S_IWUSR, 1137 sc->debug.debugfs_phy, sc, &fops_regval)) 1138 goto err; 1139 1140 if (!debugfs_create_bool("ignore_extcca", S_IRUSR | S_IWUSR, 1141 sc->debug.debugfs_phy, &ah->config.cwm_ignore_extcca)) 1142 goto err; 1143 1144 if (!debugfs_create_file("regdump", S_IRUSR, sc->debug.debugfs_phy, 1145 sc, &fops_regdump)) 1146 goto err; 1147 1148 sc->debug.regidx = 0; 1149 return 0; 1150 err: 1151 debugfs_remove_recursive(sc->debug.debugfs_phy); 1152 sc->debug.debugfs_phy = NULL; 1153 return -ENOMEM; 1154 } 1155