1203c4805SLuis R. Rodriguez /* 25b68138eSSujith Manoharan * Copyright (c) 2008-2011 Atheros Communications Inc. 3203c4805SLuis R. Rodriguez * 4203c4805SLuis R. Rodriguez * Permission to use, copy, modify, and/or distribute this software for any 5203c4805SLuis R. Rodriguez * purpose with or without fee is hereby granted, provided that the above 6203c4805SLuis R. Rodriguez * copyright notice and this permission notice appear in all copies. 7203c4805SLuis R. Rodriguez * 8203c4805SLuis R. Rodriguez * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 9203c4805SLuis R. Rodriguez * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 10203c4805SLuis R. Rodriguez * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 11203c4805SLuis R. Rodriguez * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 12203c4805SLuis R. Rodriguez * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 13203c4805SLuis R. Rodriguez * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 14203c4805SLuis R. Rodriguez * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 15203c4805SLuis R. Rodriguez */ 16203c4805SLuis R. Rodriguez 175a0e3ad6STejun Heo #include <linux/slab.h> 18582d0064SVasanthakumar Thiagarajan #include <linux/vmalloc.h> 19ee40fa06SPaul Gortmaker #include <linux/export.h> 20203c4805SLuis R. Rodriguez #include <asm/unaligned.h> 21203c4805SLuis R. Rodriguez 22203c4805SLuis R. Rodriguez #include "ath9k.h" 23203c4805SLuis R. Rodriguez 24475a6e4dSLuis R. Rodriguez #define REG_WRITE_D(_ah, _reg, _val) \ 25475a6e4dSLuis R. Rodriguez ath9k_hw_common(_ah)->ops->write((_ah), (_val), (_reg)) 26475a6e4dSLuis R. Rodriguez #define REG_READ_D(_ah, _reg) \ 27475a6e4dSLuis R. Rodriguez ath9k_hw_common(_ah)->ops->read((_ah), (_reg)) 28475a6e4dSLuis R. Rodriguez 29203c4805SLuis R. Rodriguez static int ath9k_debugfs_open(struct inode *inode, struct file *file) 30203c4805SLuis R. Rodriguez { 31203c4805SLuis R. Rodriguez file->private_data = inode->i_private; 32203c4805SLuis R. Rodriguez return 0; 33203c4805SLuis R. Rodriguez } 34203c4805SLuis R. Rodriguez 35582d0064SVasanthakumar Thiagarajan static ssize_t ath9k_debugfs_read_buf(struct file *file, char __user *user_buf, 36582d0064SVasanthakumar Thiagarajan size_t count, loff_t *ppos) 37582d0064SVasanthakumar Thiagarajan { 38582d0064SVasanthakumar Thiagarajan u8 *buf = file->private_data; 39582d0064SVasanthakumar Thiagarajan return simple_read_from_buffer(user_buf, count, ppos, buf, strlen(buf)); 40582d0064SVasanthakumar Thiagarajan } 41582d0064SVasanthakumar Thiagarajan 42582d0064SVasanthakumar Thiagarajan static int ath9k_debugfs_release_buf(struct inode *inode, struct file *file) 43582d0064SVasanthakumar Thiagarajan { 44582d0064SVasanthakumar Thiagarajan vfree(file->private_data); 45582d0064SVasanthakumar Thiagarajan return 0; 46582d0064SVasanthakumar Thiagarajan } 47582d0064SVasanthakumar Thiagarajan 48a830df07SFelix Fietkau #ifdef CONFIG_ATH_DEBUG 49a830df07SFelix Fietkau 502493928eSJeff Hansen static ssize_t read_file_debug(struct file *file, char __user *user_buf, 512493928eSJeff Hansen size_t count, loff_t *ppos) 522493928eSJeff Hansen { 532493928eSJeff Hansen struct ath_softc *sc = file->private_data; 54c46917bbSLuis R. Rodriguez struct ath_common *common = ath9k_hw_common(sc->sc_ah); 552493928eSJeff Hansen char buf[32]; 56581f725cSVasanthakumar Thiagarajan unsigned int len; 57581f725cSVasanthakumar Thiagarajan 582b87f3aaSDan Carpenter len = sprintf(buf, "0x%08x\n", common->debug_mask); 592493928eSJeff Hansen return simple_read_from_buffer(user_buf, count, ppos, buf, len); 602493928eSJeff Hansen } 612493928eSJeff Hansen 622493928eSJeff Hansen static ssize_t write_file_debug(struct file *file, const char __user *user_buf, 632493928eSJeff Hansen size_t count, loff_t *ppos) 642493928eSJeff Hansen { 652493928eSJeff Hansen struct ath_softc *sc = file->private_data; 66c46917bbSLuis R. Rodriguez struct ath_common *common = ath9k_hw_common(sc->sc_ah); 672493928eSJeff Hansen unsigned long mask; 682493928eSJeff Hansen char buf[32]; 69581f725cSVasanthakumar Thiagarajan ssize_t len; 70581f725cSVasanthakumar Thiagarajan 71581f725cSVasanthakumar Thiagarajan len = min(count, sizeof(buf) - 1); 72581f725cSVasanthakumar Thiagarajan if (copy_from_user(buf, user_buf, len)) 7304236066SDan Carpenter return -EFAULT; 74581f725cSVasanthakumar Thiagarajan 75581f725cSVasanthakumar Thiagarajan buf[len] = '\0'; 76581f725cSVasanthakumar Thiagarajan if (strict_strtoul(buf, 0, &mask)) 77581f725cSVasanthakumar Thiagarajan return -EINVAL; 78581f725cSVasanthakumar Thiagarajan 79c46917bbSLuis R. Rodriguez common->debug_mask = mask; 802493928eSJeff Hansen return count; 812493928eSJeff Hansen } 822493928eSJeff Hansen 832493928eSJeff Hansen static const struct file_operations fops_debug = { 842493928eSJeff Hansen .read = read_file_debug, 852493928eSJeff Hansen .write = write_file_debug, 862493928eSJeff Hansen .open = ath9k_debugfs_open, 876038f373SArnd Bergmann .owner = THIS_MODULE, 886038f373SArnd Bergmann .llseek = default_llseek, 892493928eSJeff Hansen }; 902493928eSJeff Hansen 91a830df07SFelix Fietkau #endif 92a830df07SFelix Fietkau 93991a0987SPavel Roskin #define DMA_BUF_LEN 1024 94991a0987SPavel Roskin 9515340694SFelix Fietkau static ssize_t read_file_tx_chainmask(struct file *file, char __user *user_buf, 9615340694SFelix Fietkau size_t count, loff_t *ppos) 9715340694SFelix Fietkau { 9815340694SFelix Fietkau struct ath_softc *sc = file->private_data; 9982b2d334SFelix Fietkau struct ath_hw *ah = sc->sc_ah; 10015340694SFelix Fietkau char buf[32]; 10115340694SFelix Fietkau unsigned int len; 10215340694SFelix Fietkau 10382b2d334SFelix Fietkau len = sprintf(buf, "0x%08x\n", ah->txchainmask); 10415340694SFelix Fietkau return simple_read_from_buffer(user_buf, count, ppos, buf, len); 10515340694SFelix Fietkau } 10615340694SFelix Fietkau 10715340694SFelix Fietkau static ssize_t write_file_tx_chainmask(struct file *file, const char __user *user_buf, 10815340694SFelix Fietkau size_t count, loff_t *ppos) 10915340694SFelix Fietkau { 11015340694SFelix Fietkau struct ath_softc *sc = file->private_data; 11182b2d334SFelix Fietkau struct ath_hw *ah = sc->sc_ah; 11215340694SFelix Fietkau unsigned long mask; 11315340694SFelix Fietkau char buf[32]; 11415340694SFelix Fietkau ssize_t len; 11515340694SFelix Fietkau 11615340694SFelix Fietkau len = min(count, sizeof(buf) - 1); 11715340694SFelix Fietkau if (copy_from_user(buf, user_buf, len)) 11804236066SDan Carpenter return -EFAULT; 11915340694SFelix Fietkau 12015340694SFelix Fietkau buf[len] = '\0'; 12115340694SFelix Fietkau if (strict_strtoul(buf, 0, &mask)) 12215340694SFelix Fietkau return -EINVAL; 12315340694SFelix Fietkau 12482b2d334SFelix Fietkau ah->txchainmask = mask; 12582b2d334SFelix Fietkau ah->caps.tx_chainmask = mask; 12615340694SFelix Fietkau return count; 12715340694SFelix Fietkau } 12815340694SFelix Fietkau 12915340694SFelix Fietkau static const struct file_operations fops_tx_chainmask = { 13015340694SFelix Fietkau .read = read_file_tx_chainmask, 13115340694SFelix Fietkau .write = write_file_tx_chainmask, 13215340694SFelix Fietkau .open = ath9k_debugfs_open, 1336038f373SArnd Bergmann .owner = THIS_MODULE, 1346038f373SArnd Bergmann .llseek = default_llseek, 13515340694SFelix Fietkau }; 13615340694SFelix Fietkau 13715340694SFelix Fietkau 13815340694SFelix Fietkau static ssize_t read_file_rx_chainmask(struct file *file, char __user *user_buf, 13915340694SFelix Fietkau size_t count, loff_t *ppos) 14015340694SFelix Fietkau { 14115340694SFelix Fietkau struct ath_softc *sc = file->private_data; 14282b2d334SFelix Fietkau struct ath_hw *ah = sc->sc_ah; 14315340694SFelix Fietkau char buf[32]; 14415340694SFelix Fietkau unsigned int len; 14515340694SFelix Fietkau 14682b2d334SFelix Fietkau len = sprintf(buf, "0x%08x\n", ah->rxchainmask); 14715340694SFelix Fietkau return simple_read_from_buffer(user_buf, count, ppos, buf, len); 14815340694SFelix Fietkau } 14915340694SFelix Fietkau 15015340694SFelix Fietkau static ssize_t write_file_rx_chainmask(struct file *file, const char __user *user_buf, 15115340694SFelix Fietkau size_t count, loff_t *ppos) 15215340694SFelix Fietkau { 15315340694SFelix Fietkau struct ath_softc *sc = file->private_data; 15482b2d334SFelix Fietkau struct ath_hw *ah = sc->sc_ah; 15515340694SFelix Fietkau unsigned long mask; 15615340694SFelix Fietkau char buf[32]; 15715340694SFelix Fietkau ssize_t len; 15815340694SFelix Fietkau 15915340694SFelix Fietkau len = min(count, sizeof(buf) - 1); 16015340694SFelix Fietkau if (copy_from_user(buf, user_buf, len)) 16104236066SDan Carpenter return -EFAULT; 16215340694SFelix Fietkau 16315340694SFelix Fietkau buf[len] = '\0'; 16415340694SFelix Fietkau if (strict_strtoul(buf, 0, &mask)) 16515340694SFelix Fietkau return -EINVAL; 16615340694SFelix Fietkau 16782b2d334SFelix Fietkau ah->rxchainmask = mask; 16882b2d334SFelix Fietkau ah->caps.rx_chainmask = mask; 16915340694SFelix Fietkau return count; 17015340694SFelix Fietkau } 17115340694SFelix Fietkau 17215340694SFelix Fietkau static const struct file_operations fops_rx_chainmask = { 17315340694SFelix Fietkau .read = read_file_rx_chainmask, 17415340694SFelix Fietkau .write = write_file_rx_chainmask, 17515340694SFelix Fietkau .open = ath9k_debugfs_open, 1766038f373SArnd Bergmann .owner = THIS_MODULE, 1776038f373SArnd Bergmann .llseek = default_llseek, 17815340694SFelix Fietkau }; 17915340694SFelix Fietkau 18005c0be2fSMohammed Shafi Shajakhan static ssize_t read_file_disable_ani(struct file *file, char __user *user_buf, 18105c0be2fSMohammed Shafi Shajakhan size_t count, loff_t *ppos) 18205c0be2fSMohammed Shafi Shajakhan { 18305c0be2fSMohammed Shafi Shajakhan struct ath_softc *sc = file->private_data; 18405c0be2fSMohammed Shafi Shajakhan struct ath_common *common = ath9k_hw_common(sc->sc_ah); 18505c0be2fSMohammed Shafi Shajakhan char buf[32]; 18605c0be2fSMohammed Shafi Shajakhan unsigned int len; 18705c0be2fSMohammed Shafi Shajakhan 18805c0be2fSMohammed Shafi Shajakhan len = sprintf(buf, "%d\n", common->disable_ani); 18905c0be2fSMohammed Shafi Shajakhan return simple_read_from_buffer(user_buf, count, ppos, buf, len); 19005c0be2fSMohammed Shafi Shajakhan } 19105c0be2fSMohammed Shafi Shajakhan 19205c0be2fSMohammed Shafi Shajakhan static ssize_t write_file_disable_ani(struct file *file, 19305c0be2fSMohammed Shafi Shajakhan const char __user *user_buf, 19405c0be2fSMohammed Shafi Shajakhan size_t count, loff_t *ppos) 19505c0be2fSMohammed Shafi Shajakhan { 19605c0be2fSMohammed Shafi Shajakhan struct ath_softc *sc = file->private_data; 19705c0be2fSMohammed Shafi Shajakhan struct ath_common *common = ath9k_hw_common(sc->sc_ah); 19805c0be2fSMohammed Shafi Shajakhan unsigned long disable_ani; 19905c0be2fSMohammed Shafi Shajakhan char buf[32]; 20005c0be2fSMohammed Shafi Shajakhan ssize_t len; 20105c0be2fSMohammed Shafi Shajakhan 20205c0be2fSMohammed Shafi Shajakhan len = min(count, sizeof(buf) - 1); 20305c0be2fSMohammed Shafi Shajakhan if (copy_from_user(buf, user_buf, len)) 20405c0be2fSMohammed Shafi Shajakhan return -EFAULT; 20505c0be2fSMohammed Shafi Shajakhan 20605c0be2fSMohammed Shafi Shajakhan buf[len] = '\0'; 20705c0be2fSMohammed Shafi Shajakhan if (strict_strtoul(buf, 0, &disable_ani)) 20805c0be2fSMohammed Shafi Shajakhan return -EINVAL; 20905c0be2fSMohammed Shafi Shajakhan 21005c0be2fSMohammed Shafi Shajakhan common->disable_ani = !!disable_ani; 21105c0be2fSMohammed Shafi Shajakhan 21205c0be2fSMohammed Shafi Shajakhan if (disable_ani) { 21305c0be2fSMohammed Shafi Shajakhan sc->sc_flags &= ~SC_OP_ANI_RUN; 21405c0be2fSMohammed Shafi Shajakhan del_timer_sync(&common->ani.timer); 21505c0be2fSMohammed Shafi Shajakhan } else { 21605c0be2fSMohammed Shafi Shajakhan sc->sc_flags |= SC_OP_ANI_RUN; 21705c0be2fSMohammed Shafi Shajakhan ath_start_ani(common); 21805c0be2fSMohammed Shafi Shajakhan } 21905c0be2fSMohammed Shafi Shajakhan 22005c0be2fSMohammed Shafi Shajakhan return count; 22105c0be2fSMohammed Shafi Shajakhan } 22205c0be2fSMohammed Shafi Shajakhan 22305c0be2fSMohammed Shafi Shajakhan static const struct file_operations fops_disable_ani = { 22405c0be2fSMohammed Shafi Shajakhan .read = read_file_disable_ani, 22505c0be2fSMohammed Shafi Shajakhan .write = write_file_disable_ani, 22605c0be2fSMohammed Shafi Shajakhan .open = ath9k_debugfs_open, 22705c0be2fSMohammed Shafi Shajakhan .owner = THIS_MODULE, 22805c0be2fSMohammed Shafi Shajakhan .llseek = default_llseek, 22905c0be2fSMohammed Shafi Shajakhan }; 23015340694SFelix Fietkau 231203c4805SLuis R. Rodriguez static ssize_t read_file_dma(struct file *file, char __user *user_buf, 232203c4805SLuis R. Rodriguez size_t count, loff_t *ppos) 233203c4805SLuis R. Rodriguez { 234203c4805SLuis R. Rodriguez struct ath_softc *sc = file->private_data; 235203c4805SLuis R. Rodriguez struct ath_hw *ah = sc->sc_ah; 236991a0987SPavel Roskin char *buf; 237991a0987SPavel Roskin int retval; 238203c4805SLuis R. Rodriguez unsigned int len = 0; 239203c4805SLuis R. Rodriguez u32 val[ATH9K_NUM_DMA_DEBUG_REGS]; 240203c4805SLuis R. Rodriguez int i, qcuOffset = 0, dcuOffset = 0; 241203c4805SLuis R. Rodriguez u32 *qcuBase = &val[0], *dcuBase = &val[4]; 242203c4805SLuis R. Rodriguez 243991a0987SPavel Roskin buf = kmalloc(DMA_BUF_LEN, GFP_KERNEL); 244991a0987SPavel Roskin if (!buf) 24504236066SDan Carpenter return -ENOMEM; 246991a0987SPavel Roskin 2477cf4a2e7SSujith ath9k_ps_wakeup(sc); 2487cf4a2e7SSujith 249475a6e4dSLuis R. Rodriguez REG_WRITE_D(ah, AR_MACMISC, 250203c4805SLuis R. Rodriguez ((AR_MACMISC_DMA_OBS_LINE_8 << AR_MACMISC_DMA_OBS_S) | 251203c4805SLuis R. Rodriguez (AR_MACMISC_MISC_OBS_BUS_1 << 252203c4805SLuis R. Rodriguez AR_MACMISC_MISC_OBS_BUS_MSB_S))); 253203c4805SLuis R. Rodriguez 254991a0987SPavel Roskin len += snprintf(buf + len, DMA_BUF_LEN - len, 255203c4805SLuis R. Rodriguez "Raw DMA Debug values:\n"); 256203c4805SLuis R. Rodriguez 257203c4805SLuis R. Rodriguez for (i = 0; i < ATH9K_NUM_DMA_DEBUG_REGS; i++) { 258203c4805SLuis R. Rodriguez if (i % 4 == 0) 259991a0987SPavel Roskin len += snprintf(buf + len, DMA_BUF_LEN - len, "\n"); 260203c4805SLuis R. Rodriguez 261475a6e4dSLuis R. Rodriguez val[i] = REG_READ_D(ah, AR_DMADBG_0 + (i * sizeof(u32))); 262991a0987SPavel Roskin len += snprintf(buf + len, DMA_BUF_LEN - len, "%d: %08x ", 263203c4805SLuis R. Rodriguez i, val[i]); 264203c4805SLuis R. Rodriguez } 265203c4805SLuis R. Rodriguez 266991a0987SPavel Roskin len += snprintf(buf + len, DMA_BUF_LEN - len, "\n\n"); 267991a0987SPavel Roskin len += snprintf(buf + len, DMA_BUF_LEN - len, 268203c4805SLuis R. Rodriguez "Num QCU: chain_st fsp_ok fsp_st DCU: chain_st\n"); 269203c4805SLuis R. Rodriguez 270203c4805SLuis R. Rodriguez for (i = 0; i < ATH9K_NUM_QUEUES; i++, qcuOffset += 4, dcuOffset += 5) { 271203c4805SLuis R. Rodriguez if (i == 8) { 272203c4805SLuis R. Rodriguez qcuOffset = 0; 273203c4805SLuis R. Rodriguez qcuBase++; 274203c4805SLuis R. Rodriguez } 275203c4805SLuis R. Rodriguez 276203c4805SLuis R. Rodriguez if (i == 6) { 277203c4805SLuis R. Rodriguez dcuOffset = 0; 278203c4805SLuis R. Rodriguez dcuBase++; 279203c4805SLuis R. Rodriguez } 280203c4805SLuis R. Rodriguez 281991a0987SPavel Roskin len += snprintf(buf + len, DMA_BUF_LEN - len, 282203c4805SLuis R. Rodriguez "%2d %2x %1x %2x %2x\n", 283203c4805SLuis R. Rodriguez i, (*qcuBase & (0x7 << qcuOffset)) >> qcuOffset, 284203c4805SLuis R. Rodriguez (*qcuBase & (0x8 << qcuOffset)) >> (qcuOffset + 3), 285203c4805SLuis R. Rodriguez val[2] & (0x7 << (i * 3)) >> (i * 3), 286203c4805SLuis R. Rodriguez (*dcuBase & (0x1f << dcuOffset)) >> dcuOffset); 287203c4805SLuis R. Rodriguez } 288203c4805SLuis R. Rodriguez 289991a0987SPavel Roskin len += snprintf(buf + len, DMA_BUF_LEN - len, "\n"); 290203c4805SLuis R. Rodriguez 291991a0987SPavel Roskin len += snprintf(buf + len, DMA_BUF_LEN - len, 292203c4805SLuis R. Rodriguez "qcu_stitch state: %2x qcu_fetch state: %2x\n", 293203c4805SLuis R. Rodriguez (val[3] & 0x003c0000) >> 18, (val[3] & 0x03c00000) >> 22); 294991a0987SPavel Roskin len += snprintf(buf + len, DMA_BUF_LEN - len, 295203c4805SLuis R. Rodriguez "qcu_complete state: %2x dcu_complete state: %2x\n", 296203c4805SLuis R. Rodriguez (val[3] & 0x1c000000) >> 26, (val[6] & 0x3)); 297991a0987SPavel Roskin len += snprintf(buf + len, DMA_BUF_LEN - len, 298203c4805SLuis R. Rodriguez "dcu_arb state: %2x dcu_fp state: %2x\n", 299203c4805SLuis R. Rodriguez (val[5] & 0x06000000) >> 25, (val[5] & 0x38000000) >> 27); 300991a0987SPavel Roskin len += snprintf(buf + len, DMA_BUF_LEN - len, 301203c4805SLuis R. Rodriguez "chan_idle_dur: %3d chan_idle_dur_valid: %1d\n", 302203c4805SLuis R. Rodriguez (val[6] & 0x000003fc) >> 2, (val[6] & 0x00000400) >> 10); 303991a0987SPavel Roskin len += snprintf(buf + len, DMA_BUF_LEN - len, 304203c4805SLuis R. Rodriguez "txfifo_valid_0: %1d txfifo_valid_1: %1d\n", 305203c4805SLuis R. Rodriguez (val[6] & 0x00000800) >> 11, (val[6] & 0x00001000) >> 12); 306991a0987SPavel Roskin len += snprintf(buf + len, DMA_BUF_LEN - len, 307203c4805SLuis R. Rodriguez "txfifo_dcu_num_0: %2d txfifo_dcu_num_1: %2d\n", 308203c4805SLuis R. Rodriguez (val[6] & 0x0001e000) >> 13, (val[6] & 0x001e0000) >> 17); 309203c4805SLuis R. Rodriguez 310991a0987SPavel Roskin len += snprintf(buf + len, DMA_BUF_LEN - len, "pcu observe: 0x%x\n", 311475a6e4dSLuis R. Rodriguez REG_READ_D(ah, AR_OBS_BUS_1)); 312991a0987SPavel Roskin len += snprintf(buf + len, DMA_BUF_LEN - len, 313475a6e4dSLuis R. Rodriguez "AR_CR: 0x%x\n", REG_READ_D(ah, AR_CR)); 314203c4805SLuis R. Rodriguez 3157cf4a2e7SSujith ath9k_ps_restore(sc); 3167cf4a2e7SSujith 3172b87f3aaSDan Carpenter if (len > DMA_BUF_LEN) 3182b87f3aaSDan Carpenter len = DMA_BUF_LEN; 3192b87f3aaSDan Carpenter 320991a0987SPavel Roskin retval = simple_read_from_buffer(user_buf, count, ppos, buf, len); 321991a0987SPavel Roskin kfree(buf); 322991a0987SPavel Roskin return retval; 323203c4805SLuis R. Rodriguez } 324203c4805SLuis R. Rodriguez 325203c4805SLuis R. Rodriguez static const struct file_operations fops_dma = { 326203c4805SLuis R. Rodriguez .read = read_file_dma, 327203c4805SLuis R. Rodriguez .open = ath9k_debugfs_open, 3286038f373SArnd Bergmann .owner = THIS_MODULE, 3296038f373SArnd Bergmann .llseek = default_llseek, 330203c4805SLuis R. Rodriguez }; 331203c4805SLuis R. Rodriguez 332203c4805SLuis R. Rodriguez 333203c4805SLuis R. Rodriguez void ath_debug_stat_interrupt(struct ath_softc *sc, enum ath9k_int status) 334203c4805SLuis R. Rodriguez { 335203c4805SLuis R. Rodriguez if (status) 336203c4805SLuis R. Rodriguez sc->debug.stats.istats.total++; 337a9616f41SLuis R. Rodriguez if (sc->sc_ah->caps.hw_caps & ATH9K_HW_CAP_EDMA) { 338a9616f41SLuis R. Rodriguez if (status & ATH9K_INT_RXLP) 339a9616f41SLuis R. Rodriguez sc->debug.stats.istats.rxlp++; 340a9616f41SLuis R. Rodriguez if (status & ATH9K_INT_RXHP) 341a9616f41SLuis R. Rodriguez sc->debug.stats.istats.rxhp++; 34208578b8fSLuis R. Rodriguez if (status & ATH9K_INT_BB_WATCHDOG) 34308578b8fSLuis R. Rodriguez sc->debug.stats.istats.bb_watchdog++; 344a9616f41SLuis R. Rodriguez } else { 345203c4805SLuis R. Rodriguez if (status & ATH9K_INT_RX) 346203c4805SLuis R. Rodriguez sc->debug.stats.istats.rxok++; 347a9616f41SLuis R. Rodriguez } 348203c4805SLuis R. Rodriguez if (status & ATH9K_INT_RXEOL) 349203c4805SLuis R. Rodriguez sc->debug.stats.istats.rxeol++; 350203c4805SLuis R. Rodriguez if (status & ATH9K_INT_RXORN) 351203c4805SLuis R. Rodriguez sc->debug.stats.istats.rxorn++; 352203c4805SLuis R. Rodriguez if (status & ATH9K_INT_TX) 353203c4805SLuis R. Rodriguez sc->debug.stats.istats.txok++; 354203c4805SLuis R. Rodriguez if (status & ATH9K_INT_TXURN) 355203c4805SLuis R. Rodriguez sc->debug.stats.istats.txurn++; 356203c4805SLuis R. Rodriguez if (status & ATH9K_INT_MIB) 357203c4805SLuis R. Rodriguez sc->debug.stats.istats.mib++; 358203c4805SLuis R. Rodriguez if (status & ATH9K_INT_RXPHY) 359203c4805SLuis R. Rodriguez sc->debug.stats.istats.rxphyerr++; 360203c4805SLuis R. Rodriguez if (status & ATH9K_INT_RXKCM) 361203c4805SLuis R. Rodriguez sc->debug.stats.istats.rx_keycache_miss++; 362203c4805SLuis R. Rodriguez if (status & ATH9K_INT_SWBA) 363203c4805SLuis R. Rodriguez sc->debug.stats.istats.swba++; 364203c4805SLuis R. Rodriguez if (status & ATH9K_INT_BMISS) 365203c4805SLuis R. Rodriguez sc->debug.stats.istats.bmiss++; 366203c4805SLuis R. Rodriguez if (status & ATH9K_INT_BNR) 367203c4805SLuis R. Rodriguez sc->debug.stats.istats.bnr++; 368203c4805SLuis R. Rodriguez if (status & ATH9K_INT_CST) 369203c4805SLuis R. Rodriguez sc->debug.stats.istats.cst++; 370203c4805SLuis R. Rodriguez if (status & ATH9K_INT_GTT) 371203c4805SLuis R. Rodriguez sc->debug.stats.istats.gtt++; 372203c4805SLuis R. Rodriguez if (status & ATH9K_INT_TIM) 373203c4805SLuis R. Rodriguez sc->debug.stats.istats.tim++; 374203c4805SLuis R. Rodriguez if (status & ATH9K_INT_CABEND) 375203c4805SLuis R. Rodriguez sc->debug.stats.istats.cabend++; 376203c4805SLuis R. Rodriguez if (status & ATH9K_INT_DTIMSYNC) 377203c4805SLuis R. Rodriguez sc->debug.stats.istats.dtimsync++; 378203c4805SLuis R. Rodriguez if (status & ATH9K_INT_DTIM) 379203c4805SLuis R. Rodriguez sc->debug.stats.istats.dtim++; 3806dde1aabSMohammed Shafi Shajakhan if (status & ATH9K_INT_TSFOOR) 3816dde1aabSMohammed Shafi Shajakhan sc->debug.stats.istats.tsfoor++; 382203c4805SLuis R. Rodriguez } 383203c4805SLuis R. Rodriguez 384203c4805SLuis R. Rodriguez static ssize_t read_file_interrupt(struct file *file, char __user *user_buf, 385203c4805SLuis R. Rodriguez size_t count, loff_t *ppos) 386203c4805SLuis R. Rodriguez { 387203c4805SLuis R. Rodriguez struct ath_softc *sc = file->private_data; 388203c4805SLuis R. Rodriguez char buf[512]; 389203c4805SLuis R. Rodriguez unsigned int len = 0; 390203c4805SLuis R. Rodriguez 391a9616f41SLuis R. Rodriguez if (sc->sc_ah->caps.hw_caps & ATH9K_HW_CAP_EDMA) { 392a9616f41SLuis R. Rodriguez len += snprintf(buf + len, sizeof(buf) - len, 393a9616f41SLuis R. Rodriguez "%8s: %10u\n", "RXLP", sc->debug.stats.istats.rxlp); 394a9616f41SLuis R. Rodriguez len += snprintf(buf + len, sizeof(buf) - len, 395a9616f41SLuis R. Rodriguez "%8s: %10u\n", "RXHP", sc->debug.stats.istats.rxhp); 39608578b8fSLuis R. Rodriguez len += snprintf(buf + len, sizeof(buf) - len, 39708578b8fSLuis R. Rodriguez "%8s: %10u\n", "WATCHDOG", 39808578b8fSLuis R. Rodriguez sc->debug.stats.istats.bb_watchdog); 399a9616f41SLuis R. Rodriguez } else { 400203c4805SLuis R. Rodriguez len += snprintf(buf + len, sizeof(buf) - len, 401203c4805SLuis R. Rodriguez "%8s: %10u\n", "RX", sc->debug.stats.istats.rxok); 402a9616f41SLuis R. Rodriguez } 403203c4805SLuis R. Rodriguez len += snprintf(buf + len, sizeof(buf) - len, 404203c4805SLuis R. Rodriguez "%8s: %10u\n", "RXEOL", sc->debug.stats.istats.rxeol); 405203c4805SLuis R. Rodriguez len += snprintf(buf + len, sizeof(buf) - len, 406203c4805SLuis R. Rodriguez "%8s: %10u\n", "RXORN", sc->debug.stats.istats.rxorn); 407203c4805SLuis R. Rodriguez len += snprintf(buf + len, sizeof(buf) - len, 408203c4805SLuis R. Rodriguez "%8s: %10u\n", "TX", sc->debug.stats.istats.txok); 409203c4805SLuis R. Rodriguez len += snprintf(buf + len, sizeof(buf) - len, 410203c4805SLuis R. Rodriguez "%8s: %10u\n", "TXURN", sc->debug.stats.istats.txurn); 411203c4805SLuis R. Rodriguez len += snprintf(buf + len, sizeof(buf) - len, 412203c4805SLuis R. Rodriguez "%8s: %10u\n", "MIB", sc->debug.stats.istats.mib); 413203c4805SLuis R. Rodriguez len += snprintf(buf + len, sizeof(buf) - len, 414203c4805SLuis R. Rodriguez "%8s: %10u\n", "RXPHY", sc->debug.stats.istats.rxphyerr); 415203c4805SLuis R. Rodriguez len += snprintf(buf + len, sizeof(buf) - len, 416203c4805SLuis R. Rodriguez "%8s: %10u\n", "RXKCM", sc->debug.stats.istats.rx_keycache_miss); 417203c4805SLuis R. Rodriguez len += snprintf(buf + len, sizeof(buf) - len, 418203c4805SLuis R. Rodriguez "%8s: %10u\n", "SWBA", sc->debug.stats.istats.swba); 419203c4805SLuis R. Rodriguez len += snprintf(buf + len, sizeof(buf) - len, 420203c4805SLuis R. Rodriguez "%8s: %10u\n", "BMISS", sc->debug.stats.istats.bmiss); 421203c4805SLuis R. Rodriguez len += snprintf(buf + len, sizeof(buf) - len, 422203c4805SLuis R. Rodriguez "%8s: %10u\n", "BNR", sc->debug.stats.istats.bnr); 423203c4805SLuis R. Rodriguez len += snprintf(buf + len, sizeof(buf) - len, 424203c4805SLuis R. Rodriguez "%8s: %10u\n", "CST", sc->debug.stats.istats.cst); 425203c4805SLuis R. Rodriguez len += snprintf(buf + len, sizeof(buf) - len, 426203c4805SLuis R. Rodriguez "%8s: %10u\n", "GTT", sc->debug.stats.istats.gtt); 427203c4805SLuis R. Rodriguez len += snprintf(buf + len, sizeof(buf) - len, 428203c4805SLuis R. Rodriguez "%8s: %10u\n", "TIM", sc->debug.stats.istats.tim); 429203c4805SLuis R. Rodriguez len += snprintf(buf + len, sizeof(buf) - len, 430203c4805SLuis R. Rodriguez "%8s: %10u\n", "CABEND", sc->debug.stats.istats.cabend); 431203c4805SLuis R. Rodriguez len += snprintf(buf + len, sizeof(buf) - len, 432203c4805SLuis R. Rodriguez "%8s: %10u\n", "DTIMSYNC", sc->debug.stats.istats.dtimsync); 433203c4805SLuis R. Rodriguez len += snprintf(buf + len, sizeof(buf) - len, 434203c4805SLuis R. Rodriguez "%8s: %10u\n", "DTIM", sc->debug.stats.istats.dtim); 435203c4805SLuis R. Rodriguez len += snprintf(buf + len, sizeof(buf) - len, 4366dde1aabSMohammed Shafi Shajakhan "%8s: %10u\n", "TSFOOR", sc->debug.stats.istats.tsfoor); 4376dde1aabSMohammed Shafi Shajakhan len += snprintf(buf + len, sizeof(buf) - len, 438203c4805SLuis R. Rodriguez "%8s: %10u\n", "TOTAL", sc->debug.stats.istats.total); 439203c4805SLuis R. Rodriguez 4406dde1aabSMohammed Shafi Shajakhan 4412b87f3aaSDan Carpenter if (len > sizeof(buf)) 4422b87f3aaSDan Carpenter len = sizeof(buf); 4432b87f3aaSDan Carpenter 444203c4805SLuis R. Rodriguez return simple_read_from_buffer(user_buf, count, ppos, buf, len); 445203c4805SLuis R. Rodriguez } 446203c4805SLuis R. Rodriguez 447203c4805SLuis R. Rodriguez static const struct file_operations fops_interrupt = { 448203c4805SLuis R. Rodriguez .read = read_file_interrupt, 449203c4805SLuis R. Rodriguez .open = ath9k_debugfs_open, 4506038f373SArnd Bergmann .owner = THIS_MODULE, 4516038f373SArnd Bergmann .llseek = default_llseek, 452203c4805SLuis R. Rodriguez }; 453203c4805SLuis R. Rodriguez 4544e6975f7SBen Greear static const char *channel_type_str(enum nl80211_channel_type t) 4554e6975f7SBen Greear { 4564e6975f7SBen Greear switch (t) { 4574e6975f7SBen Greear case NL80211_CHAN_NO_HT: 4584e6975f7SBen Greear return "no ht"; 4594e6975f7SBen Greear case NL80211_CHAN_HT20: 4604e6975f7SBen Greear return "ht20"; 4614e6975f7SBen Greear case NL80211_CHAN_HT40MINUS: 4624e6975f7SBen Greear return "ht40-"; 4634e6975f7SBen Greear case NL80211_CHAN_HT40PLUS: 4644e6975f7SBen Greear return "ht40+"; 4654e6975f7SBen Greear default: 4664e6975f7SBen Greear return "???"; 4674e6975f7SBen Greear } 4684e6975f7SBen Greear } 4694e6975f7SBen Greear 470203c4805SLuis R. Rodriguez static ssize_t read_file_wiphy(struct file *file, char __user *user_buf, 471203c4805SLuis R. Rodriguez size_t count, loff_t *ppos) 472203c4805SLuis R. Rodriguez { 473203c4805SLuis R. Rodriguez struct ath_softc *sc = file->private_data; 47434302397SFelix Fietkau struct ieee80211_channel *chan = sc->hw->conf.channel; 4754e6975f7SBen Greear struct ieee80211_conf *conf = &(sc->hw->conf); 476203c4805SLuis R. Rodriguez char buf[512]; 477203c4805SLuis R. Rodriguez unsigned int len = 0; 478203c4805SLuis R. Rodriguez u8 addr[ETH_ALEN]; 47939057512SBen Greear u32 tmp; 480203c4805SLuis R. Rodriguez 481203c4805SLuis R. Rodriguez len += snprintf(buf + len, sizeof(buf) - len, 4824e6975f7SBen Greear "%s (chan=%d center-freq: %d MHz channel-type: %d (%s))\n", 48334302397SFelix Fietkau wiphy_name(sc->hw->wiphy), 4848e0167a4SMohammed Shafi Shajakhan ieee80211_frequency_to_channel(chan->center_freq), 4854e6975f7SBen Greear chan->center_freq, 4864e6975f7SBen Greear conf->channel_type, 4874e6975f7SBen Greear channel_type_str(conf->channel_type)); 488203c4805SLuis R. Rodriguez 489c6e38c06SMohammed Shafi Shajakhan ath9k_ps_wakeup(sc); 490475a6e4dSLuis R. Rodriguez put_unaligned_le32(REG_READ_D(sc->sc_ah, AR_STA_ID0), addr); 491475a6e4dSLuis R. Rodriguez put_unaligned_le16(REG_READ_D(sc->sc_ah, AR_STA_ID1) & 0xffff, addr + 4); 492203c4805SLuis R. Rodriguez len += snprintf(buf + len, sizeof(buf) - len, 493203c4805SLuis R. Rodriguez "addr: %pM\n", addr); 494475a6e4dSLuis R. Rodriguez put_unaligned_le32(REG_READ_D(sc->sc_ah, AR_BSSMSKL), addr); 495475a6e4dSLuis R. Rodriguez put_unaligned_le16(REG_READ_D(sc->sc_ah, AR_BSSMSKU) & 0xffff, addr + 4); 496203c4805SLuis R. Rodriguez len += snprintf(buf + len, sizeof(buf) - len, 497203c4805SLuis R. Rodriguez "addrmask: %pM\n", addr); 49839057512SBen Greear tmp = ath9k_hw_getrxfilter(sc->sc_ah); 49979d2b157SRajkumar Manoharan ath9k_ps_restore(sc); 50039057512SBen Greear len += snprintf(buf + len, sizeof(buf) - len, 50139057512SBen Greear "rfilt: 0x%x", tmp); 50239057512SBen Greear if (tmp & ATH9K_RX_FILTER_UCAST) 50339057512SBen Greear len += snprintf(buf + len, sizeof(buf) - len, " UCAST"); 50439057512SBen Greear if (tmp & ATH9K_RX_FILTER_MCAST) 50539057512SBen Greear len += snprintf(buf + len, sizeof(buf) - len, " MCAST"); 50639057512SBen Greear if (tmp & ATH9K_RX_FILTER_BCAST) 50739057512SBen Greear len += snprintf(buf + len, sizeof(buf) - len, " BCAST"); 50839057512SBen Greear if (tmp & ATH9K_RX_FILTER_CONTROL) 50939057512SBen Greear len += snprintf(buf + len, sizeof(buf) - len, " CONTROL"); 51039057512SBen Greear if (tmp & ATH9K_RX_FILTER_BEACON) 51139057512SBen Greear len += snprintf(buf + len, sizeof(buf) - len, " BEACON"); 51239057512SBen Greear if (tmp & ATH9K_RX_FILTER_PROM) 51339057512SBen Greear len += snprintf(buf + len, sizeof(buf) - len, " PROM"); 51439057512SBen Greear if (tmp & ATH9K_RX_FILTER_PROBEREQ) 51539057512SBen Greear len += snprintf(buf + len, sizeof(buf) - len, " PROBEREQ"); 51639057512SBen Greear if (tmp & ATH9K_RX_FILTER_PHYERR) 51739057512SBen Greear len += snprintf(buf + len, sizeof(buf) - len, " PHYERR"); 51839057512SBen Greear if (tmp & ATH9K_RX_FILTER_MYBEACON) 51939057512SBen Greear len += snprintf(buf + len, sizeof(buf) - len, " MYBEACON"); 52039057512SBen Greear if (tmp & ATH9K_RX_FILTER_COMP_BAR) 52139057512SBen Greear len += snprintf(buf + len, sizeof(buf) - len, " COMP_BAR"); 52239057512SBen Greear if (tmp & ATH9K_RX_FILTER_PSPOLL) 52339057512SBen Greear len += snprintf(buf + len, sizeof(buf) - len, " PSPOLL"); 52439057512SBen Greear if (tmp & ATH9K_RX_FILTER_PHYRADAR) 52539057512SBen Greear len += snprintf(buf + len, sizeof(buf) - len, " PHYRADAR"); 52639057512SBen Greear if (tmp & ATH9K_RX_FILTER_MCAST_BCAST_ALL) 527030d6294SFelix Fietkau len += snprintf(buf + len, sizeof(buf) - len, " MCAST_BCAST_ALL"); 528030d6294SFelix Fietkau 529030d6294SFelix Fietkau len += snprintf(buf + len, sizeof(buf) - len, 530030d6294SFelix Fietkau "\n\nReset causes:\n" 531030d6294SFelix Fietkau " baseband hang: %d\n" 532030d6294SFelix Fietkau " baseband watchdog: %d\n" 533030d6294SFelix Fietkau " fatal hardware error interrupt: %d\n" 534030d6294SFelix Fietkau " tx hardware error: %d\n" 535030d6294SFelix Fietkau " tx path hang: %d\n" 536030d6294SFelix Fietkau " pll rx hang: %d\n", 537030d6294SFelix Fietkau sc->debug.stats.reset[RESET_TYPE_BB_HANG], 538030d6294SFelix Fietkau sc->debug.stats.reset[RESET_TYPE_BB_WATCHDOG], 539030d6294SFelix Fietkau sc->debug.stats.reset[RESET_TYPE_FATAL_INT], 540030d6294SFelix Fietkau sc->debug.stats.reset[RESET_TYPE_TX_ERROR], 541030d6294SFelix Fietkau sc->debug.stats.reset[RESET_TYPE_TX_HANG], 542030d6294SFelix Fietkau sc->debug.stats.reset[RESET_TYPE_PLL_HANG]); 543203c4805SLuis R. Rodriguez 5442b87f3aaSDan Carpenter if (len > sizeof(buf)) 5452b87f3aaSDan Carpenter len = sizeof(buf); 5462b87f3aaSDan Carpenter 547203c4805SLuis R. Rodriguez return simple_read_from_buffer(user_buf, count, ppos, buf, len); 548203c4805SLuis R. Rodriguez } 549203c4805SLuis R. Rodriguez 550203c4805SLuis R. Rodriguez static const struct file_operations fops_wiphy = { 551203c4805SLuis R. Rodriguez .read = read_file_wiphy, 552203c4805SLuis R. Rodriguez .open = ath9k_debugfs_open, 5536038f373SArnd Bergmann .owner = THIS_MODULE, 5546038f373SArnd Bergmann .llseek = default_llseek, 555203c4805SLuis R. Rodriguez }; 556203c4805SLuis R. Rodriguez 5575bec3e5aSFelix Fietkau #define PR_QNUM(_n) sc->tx.txq_map[_n]->axq_qnum 558fec247c0SSujith #define PR(str, elem) \ 559fec247c0SSujith do { \ 560fec247c0SSujith len += snprintf(buf + len, size - len, \ 561fec247c0SSujith "%s%13u%11u%10u%10u\n", str, \ 5625bec3e5aSFelix Fietkau sc->debug.stats.txstats[PR_QNUM(WME_AC_BE)].elem, \ 5635bec3e5aSFelix Fietkau sc->debug.stats.txstats[PR_QNUM(WME_AC_BK)].elem, \ 5645bec3e5aSFelix Fietkau sc->debug.stats.txstats[PR_QNUM(WME_AC_VI)].elem, \ 5655bec3e5aSFelix Fietkau sc->debug.stats.txstats[PR_QNUM(WME_AC_VO)].elem); \ 5667f010c93SBen Greear if (len >= size) \ 5677f010c93SBen Greear goto done; \ 568fec247c0SSujith } while(0) 569fec247c0SSujith 5701f427dd9SBen Greear #define PRX(str, elem) \ 5711f427dd9SBen Greear do { \ 5721f427dd9SBen Greear len += snprintf(buf + len, size - len, \ 5731f427dd9SBen Greear "%s%13u%11u%10u%10u\n", str, \ 5745bec3e5aSFelix Fietkau (unsigned int)(sc->tx.txq_map[WME_AC_BE]->elem), \ 5755bec3e5aSFelix Fietkau (unsigned int)(sc->tx.txq_map[WME_AC_BK]->elem), \ 5765bec3e5aSFelix Fietkau (unsigned int)(sc->tx.txq_map[WME_AC_VI]->elem), \ 5775bec3e5aSFelix Fietkau (unsigned int)(sc->tx.txq_map[WME_AC_VO]->elem)); \ 5787f010c93SBen Greear if (len >= size) \ 5797f010c93SBen Greear goto done; \ 5801f427dd9SBen Greear } while(0) 5811f427dd9SBen Greear 5822dac4fb9SBen Greear #define PRQLE(str, elem) \ 5832dac4fb9SBen Greear do { \ 5842dac4fb9SBen Greear len += snprintf(buf + len, size - len, \ 5852dac4fb9SBen Greear "%s%13i%11i%10i%10i\n", str, \ 5865bec3e5aSFelix Fietkau list_empty(&sc->tx.txq_map[WME_AC_BE]->elem), \ 5875bec3e5aSFelix Fietkau list_empty(&sc->tx.txq_map[WME_AC_BK]->elem), \ 5885bec3e5aSFelix Fietkau list_empty(&sc->tx.txq_map[WME_AC_VI]->elem), \ 5895bec3e5aSFelix Fietkau list_empty(&sc->tx.txq_map[WME_AC_VO]->elem)); \ 5907f010c93SBen Greear if (len >= size) \ 5917f010c93SBen Greear goto done; \ 5922dac4fb9SBen Greear } while (0) 5932dac4fb9SBen Greear 594fec247c0SSujith static ssize_t read_file_xmit(struct file *file, char __user *user_buf, 595fec247c0SSujith size_t count, loff_t *ppos) 596fec247c0SSujith { 597fec247c0SSujith struct ath_softc *sc = file->private_data; 598fec247c0SSujith char *buf; 5997f010c93SBen Greear unsigned int len = 0, size = 8000; 6002dac4fb9SBen Greear int i; 601fec247c0SSujith ssize_t retval = 0; 6022dac4fb9SBen Greear char tmp[32]; 603fec247c0SSujith 604fec247c0SSujith buf = kzalloc(size, GFP_KERNEL); 605fec247c0SSujith if (buf == NULL) 60604236066SDan Carpenter return -ENOMEM; 607fec247c0SSujith 60860f2d1d5SBen Greear len += sprintf(buf, "Num-Tx-Queues: %i tx-queues-setup: 0x%x" 60960f2d1d5SBen Greear " poll-work-seen: %u\n" 6107f010c93SBen Greear "%30s %10s%10s%10s\n\n", 6117f010c93SBen Greear ATH9K_NUM_TX_QUEUES, sc->tx.txqsetup, 61260f2d1d5SBen Greear sc->tx_complete_poll_work_seen, 6137f010c93SBen Greear "BE", "BK", "VI", "VO"); 614fec247c0SSujith 615fec247c0SSujith PR("MPDUs Queued: ", queued); 616fec247c0SSujith PR("MPDUs Completed: ", completed); 6175a6f78afSFelix Fietkau PR("MPDUs XRetried: ", xretries); 618fec247c0SSujith PR("Aggregates: ", a_aggr); 619bda8addaSBen Greear PR("AMPDUs Queued HW:", a_queued_hw); 620bda8addaSBen Greear PR("AMPDUs Queued SW:", a_queued_sw); 621fec247c0SSujith PR("AMPDUs Completed:", a_completed); 622fec247c0SSujith PR("AMPDUs Retried: ", a_retries); 623fec247c0SSujith PR("AMPDUs XRetried: ", a_xretries); 624fec247c0SSujith PR("FIFO Underrun: ", fifo_underrun); 625fec247c0SSujith PR("TXOP Exceeded: ", xtxop); 626fec247c0SSujith PR("TXTIMER Expiry: ", timer_exp); 627fec247c0SSujith PR("DESC CFG Error: ", desc_cfg_err); 628fec247c0SSujith PR("DATA Underrun: ", data_underrun); 629fec247c0SSujith PR("DELIM Underrun: ", delim_underrun); 63099c15bf5SBen Greear PR("TX-Pkts-All: ", tx_pkts_all); 63199c15bf5SBen Greear PR("TX-Bytes-All: ", tx_bytes_all); 6322dac4fb9SBen Greear PR("hw-put-tx-buf: ", puttxbuf); 6332dac4fb9SBen Greear PR("hw-tx-start: ", txstart); 6342dac4fb9SBen Greear PR("hw-tx-proc-desc: ", txprocdesc); 6357f010c93SBen Greear len += snprintf(buf + len, size - len, 6367f010c93SBen Greear "%s%11p%11p%10p%10p\n", "txq-memory-address:", 637db7889cdSBen Greear sc->tx.txq_map[WME_AC_BE], 638db7889cdSBen Greear sc->tx.txq_map[WME_AC_BK], 639db7889cdSBen Greear sc->tx.txq_map[WME_AC_VI], 640db7889cdSBen Greear sc->tx.txq_map[WME_AC_VO]); 6417f010c93SBen Greear if (len >= size) 6427f010c93SBen Greear goto done; 643fec247c0SSujith 6441f427dd9SBen Greear PRX("axq-qnum: ", axq_qnum); 6451f427dd9SBen Greear PRX("axq-depth: ", axq_depth); 6462dac4fb9SBen Greear PRX("axq-ampdu_depth: ", axq_ampdu_depth); 6471f427dd9SBen Greear PRX("axq-stopped ", stopped); 6481f427dd9SBen Greear PRX("tx-in-progress ", axq_tx_inprogress); 6491f427dd9SBen Greear PRX("pending-frames ", pending_frames); 6502dac4fb9SBen Greear PRX("txq_headidx: ", txq_headidx); 6512dac4fb9SBen Greear PRX("txq_tailidx: ", txq_headidx); 6521f427dd9SBen Greear 6532dac4fb9SBen Greear PRQLE("axq_q empty: ", axq_q); 6542dac4fb9SBen Greear PRQLE("axq_acq empty: ", axq_acq); 6552dac4fb9SBen Greear for (i = 0; i < ATH_TXFIFO_DEPTH; i++) { 6562dac4fb9SBen Greear snprintf(tmp, sizeof(tmp) - 1, "txq_fifo[%i] empty: ", i); 6572dac4fb9SBen Greear PRQLE(tmp, txq_fifo[i]); 6582dac4fb9SBen Greear } 6597f010c93SBen Greear 66071e025a5SBen Greear /* Print out more detailed queue-info */ 66171e025a5SBen Greear for (i = 0; i <= WME_AC_BK; i++) { 66271e025a5SBen Greear struct ath_txq *txq = &(sc->tx.txq[i]); 66371e025a5SBen Greear struct ath_atx_ac *ac; 66471e025a5SBen Greear struct ath_atx_tid *tid; 66571e025a5SBen Greear if (len >= size) 66671e025a5SBen Greear goto done; 66771e025a5SBen Greear spin_lock_bh(&txq->axq_lock); 66871e025a5SBen Greear if (!list_empty(&txq->axq_acq)) { 66971e025a5SBen Greear ac = list_first_entry(&txq->axq_acq, struct ath_atx_ac, 67071e025a5SBen Greear list); 67171e025a5SBen Greear len += snprintf(buf + len, size - len, 67271e025a5SBen Greear "txq[%i] first-ac: %p sched: %i\n", 67371e025a5SBen Greear i, ac, ac->sched); 67471e025a5SBen Greear if (list_empty(&ac->tid_q) || (len >= size)) 67571e025a5SBen Greear goto done_for; 67671e025a5SBen Greear tid = list_first_entry(&ac->tid_q, struct ath_atx_tid, 67771e025a5SBen Greear list); 67871e025a5SBen Greear len += snprintf(buf + len, size - len, 67971e025a5SBen Greear " first-tid: %p sched: %i paused: %i\n", 68071e025a5SBen Greear tid, tid->sched, tid->paused); 68171e025a5SBen Greear } 68271e025a5SBen Greear done_for: 68371e025a5SBen Greear spin_unlock_bh(&txq->axq_lock); 68471e025a5SBen Greear } 68571e025a5SBen Greear 6867f010c93SBen Greear done: 6877f010c93SBen Greear if (len > size) 6887f010c93SBen Greear len = size; 6897f010c93SBen Greear 6907f010c93SBen Greear retval = simple_read_from_buffer(user_buf, count, ppos, buf, len); 6917f010c93SBen Greear kfree(buf); 6927f010c93SBen Greear 6937f010c93SBen Greear return retval; 6947f010c93SBen Greear } 6957f010c93SBen Greear 6967f010c93SBen Greear static ssize_t read_file_stations(struct file *file, char __user *user_buf, 6977f010c93SBen Greear size_t count, loff_t *ppos) 6987f010c93SBen Greear { 6997f010c93SBen Greear struct ath_softc *sc = file->private_data; 7007f010c93SBen Greear char *buf; 7017f010c93SBen Greear unsigned int len = 0, size = 64000; 7027f010c93SBen Greear struct ath_node *an = NULL; 7037f010c93SBen Greear ssize_t retval = 0; 7047f010c93SBen Greear int q; 7057f010c93SBen Greear 7067f010c93SBen Greear buf = kzalloc(size, GFP_KERNEL); 7077f010c93SBen Greear if (buf == NULL) 7087f010c93SBen Greear return -ENOMEM; 7097f010c93SBen Greear 7107f010c93SBen Greear len += snprintf(buf + len, size - len, 7117f010c93SBen Greear "Stations:\n" 7127e1e3864SBen Greear " tid: addr sched paused buf_q-empty an ac baw\n" 7137f010c93SBen Greear " ac: addr sched tid_q-empty txq\n"); 7147f010c93SBen Greear 7157f010c93SBen Greear spin_lock(&sc->nodes_lock); 7167f010c93SBen Greear list_for_each_entry(an, &sc->nodes, list) { 7177e1e3864SBen Greear unsigned short ma = an->maxampdu; 7187e1e3864SBen Greear if (ma == 0) 7197e1e3864SBen Greear ma = 65535; /* see ath_lookup_rate */ 7207f010c93SBen Greear len += snprintf(buf + len, size - len, 7217e1e3864SBen Greear "iface: %pM sta: %pM max-ampdu: %hu mpdu-density: %uus\n", 7227e1e3864SBen Greear an->vif->addr, an->sta->addr, ma, 7237e1e3864SBen Greear (unsigned int)(an->mpdudensity)); 7247f010c93SBen Greear if (len >= size) 7257f010c93SBen Greear goto done; 7267f010c93SBen Greear 7277f010c93SBen Greear for (q = 0; q < WME_NUM_TID; q++) { 7287f010c93SBen Greear struct ath_atx_tid *tid = &(an->tid[q]); 7297f010c93SBen Greear len += snprintf(buf + len, size - len, 7307e1e3864SBen Greear " tid: %p %s %s %i %p %p %hu\n", 7317f010c93SBen Greear tid, tid->sched ? "sched" : "idle", 7327f010c93SBen Greear tid->paused ? "paused" : "running", 73356dc6336SFelix Fietkau skb_queue_empty(&tid->buf_q), 7347e1e3864SBen Greear tid->an, tid->ac, tid->baw_size); 7357f010c93SBen Greear if (len >= size) 7367f010c93SBen Greear goto done; 7377f010c93SBen Greear } 7387f010c93SBen Greear 7397f010c93SBen Greear for (q = 0; q < WME_NUM_AC; q++) { 7407f010c93SBen Greear struct ath_atx_ac *ac = &(an->ac[q]); 7417f010c93SBen Greear len += snprintf(buf + len, size - len, 7427f010c93SBen Greear " ac: %p %s %i %p\n", 7437f010c93SBen Greear ac, ac->sched ? "sched" : "idle", 7447f010c93SBen Greear list_empty(&ac->tid_q), ac->txq); 7457f010c93SBen Greear if (len >= size) 7467f010c93SBen Greear goto done; 7477f010c93SBen Greear } 7487f010c93SBen Greear } 7497f010c93SBen Greear 7507f010c93SBen Greear done: 7517f010c93SBen Greear spin_unlock(&sc->nodes_lock); 7522b87f3aaSDan Carpenter if (len > size) 7532b87f3aaSDan Carpenter len = size; 7542b87f3aaSDan Carpenter 755fec247c0SSujith retval = simple_read_from_buffer(user_buf, count, ppos, buf, len); 756fec247c0SSujith kfree(buf); 757fec247c0SSujith 758fec247c0SSujith return retval; 759fec247c0SSujith } 760fec247c0SSujith 76155f6d0ffSBen Greear static ssize_t read_file_misc(struct file *file, char __user *user_buf, 76255f6d0ffSBen Greear size_t count, loff_t *ppos) 76355f6d0ffSBen Greear { 76455f6d0ffSBen Greear struct ath_softc *sc = file->private_data; 76555f6d0ffSBen Greear struct ath_common *common = ath9k_hw_common(sc->sc_ah); 76655f6d0ffSBen Greear struct ath_hw *ah = sc->sc_ah; 76755f6d0ffSBen Greear struct ieee80211_hw *hw = sc->hw; 76855f6d0ffSBen Greear char *buf; 76955f6d0ffSBen Greear unsigned int len = 0, size = 8000; 77055f6d0ffSBen Greear ssize_t retval = 0; 77155f6d0ffSBen Greear unsigned int reg; 77255f6d0ffSBen Greear struct ath9k_vif_iter_data iter_data; 77355f6d0ffSBen Greear 77455f6d0ffSBen Greear ath9k_calculate_iter_data(hw, NULL, &iter_data); 77555f6d0ffSBen Greear 77655f6d0ffSBen Greear buf = kzalloc(size, GFP_KERNEL); 77755f6d0ffSBen Greear if (buf == NULL) 77855f6d0ffSBen Greear return -ENOMEM; 77955f6d0ffSBen Greear 78079d2b157SRajkumar Manoharan ath9k_ps_wakeup(sc); 78155f6d0ffSBen Greear len += snprintf(buf + len, size - len, 78255f6d0ffSBen Greear "curbssid: %pM\n" 78355f6d0ffSBen Greear "OP-Mode: %s(%i)\n" 78455f6d0ffSBen Greear "Beacon-Timer-Register: 0x%x\n", 78555f6d0ffSBen Greear common->curbssid, 78621ec489dSPavel Roskin ath_opmode_to_string(sc->sc_ah->opmode), 78721ec489dSPavel Roskin (int)(sc->sc_ah->opmode), 78855f6d0ffSBen Greear REG_READ(ah, AR_BEACON_PERIOD)); 78955f6d0ffSBen Greear 79055f6d0ffSBen Greear reg = REG_READ(ah, AR_TIMER_MODE); 79179d2b157SRajkumar Manoharan ath9k_ps_restore(sc); 79255f6d0ffSBen Greear len += snprintf(buf + len, size - len, "Timer-Mode-Register: 0x%x (", 79355f6d0ffSBen Greear reg); 79455f6d0ffSBen Greear if (reg & AR_TBTT_TIMER_EN) 79555f6d0ffSBen Greear len += snprintf(buf + len, size - len, "TBTT "); 79655f6d0ffSBen Greear if (reg & AR_DBA_TIMER_EN) 79755f6d0ffSBen Greear len += snprintf(buf + len, size - len, "DBA "); 79855f6d0ffSBen Greear if (reg & AR_SWBA_TIMER_EN) 79955f6d0ffSBen Greear len += snprintf(buf + len, size - len, "SWBA "); 80055f6d0ffSBen Greear if (reg & AR_HCF_TIMER_EN) 80155f6d0ffSBen Greear len += snprintf(buf + len, size - len, "HCF "); 80255f6d0ffSBen Greear if (reg & AR_TIM_TIMER_EN) 80355f6d0ffSBen Greear len += snprintf(buf + len, size - len, "TIM "); 80455f6d0ffSBen Greear if (reg & AR_DTIM_TIMER_EN) 80555f6d0ffSBen Greear len += snprintf(buf + len, size - len, "DTIM "); 80655f6d0ffSBen Greear len += snprintf(buf + len, size - len, ")\n"); 80755f6d0ffSBen Greear 80855f6d0ffSBen Greear reg = sc->sc_ah->imask; 80955f6d0ffSBen Greear len += snprintf(buf + len, size - len, "imask: 0x%x (", reg); 81055f6d0ffSBen Greear if (reg & ATH9K_INT_SWBA) 81155f6d0ffSBen Greear len += snprintf(buf + len, size - len, "SWBA "); 81255f6d0ffSBen Greear if (reg & ATH9K_INT_BMISS) 81355f6d0ffSBen Greear len += snprintf(buf + len, size - len, "BMISS "); 81455f6d0ffSBen Greear if (reg & ATH9K_INT_CST) 81555f6d0ffSBen Greear len += snprintf(buf + len, size - len, "CST "); 81655f6d0ffSBen Greear if (reg & ATH9K_INT_RX) 81755f6d0ffSBen Greear len += snprintf(buf + len, size - len, "RX "); 81855f6d0ffSBen Greear if (reg & ATH9K_INT_RXHP) 81955f6d0ffSBen Greear len += snprintf(buf + len, size - len, "RXHP "); 82055f6d0ffSBen Greear if (reg & ATH9K_INT_RXLP) 82155f6d0ffSBen Greear len += snprintf(buf + len, size - len, "RXLP "); 82255f6d0ffSBen Greear if (reg & ATH9K_INT_BB_WATCHDOG) 82355f6d0ffSBen Greear len += snprintf(buf + len, size - len, "BB_WATCHDOG "); 82455f6d0ffSBen Greear /* there are other IRQs if one wanted to add them. */ 82555f6d0ffSBen Greear len += snprintf(buf + len, size - len, ")\n"); 82655f6d0ffSBen Greear 82755f6d0ffSBen Greear len += snprintf(buf + len, size - len, 82855f6d0ffSBen Greear "VIF Counts: AP: %i STA: %i MESH: %i WDS: %i" 82955f6d0ffSBen Greear " ADHOC: %i OTHER: %i nvifs: %hi beacon-vifs: %hi\n", 83055f6d0ffSBen Greear iter_data.naps, iter_data.nstations, iter_data.nmeshes, 83155f6d0ffSBen Greear iter_data.nwds, iter_data.nadhocs, iter_data.nothers, 83255f6d0ffSBen Greear sc->nvifs, sc->nbcnvifs); 83355f6d0ffSBen Greear 83455f6d0ffSBen Greear len += snprintf(buf + len, size - len, 83555f6d0ffSBen Greear "Calculated-BSSID-Mask: %pM\n", 83655f6d0ffSBen Greear iter_data.mask); 83755f6d0ffSBen Greear 83855f6d0ffSBen Greear if (len > size) 83955f6d0ffSBen Greear len = size; 84055f6d0ffSBen Greear 84155f6d0ffSBen Greear retval = simple_read_from_buffer(user_buf, count, ppos, buf, len); 84255f6d0ffSBen Greear kfree(buf); 84355f6d0ffSBen Greear 84455f6d0ffSBen Greear return retval; 84555f6d0ffSBen Greear } 84655f6d0ffSBen Greear 847066dae93SFelix Fietkau void ath_debug_stat_tx(struct ath_softc *sc, struct ath_buf *bf, 84855797b1aSFelix Fietkau struct ath_tx_status *ts, struct ath_txq *txq, 84955797b1aSFelix Fietkau unsigned int flags) 850fec247c0SSujith { 851cf3af748SRajkumar Manoharan #define TX_SAMP_DBG(c) (sc->debug.bb_mac_samp[sc->debug.sampidx].ts\ 852cf3af748SRajkumar Manoharan [sc->debug.tsidx].c) 8535bec3e5aSFelix Fietkau int qnum = txq->axq_qnum; 854066dae93SFelix Fietkau 855066dae93SFelix Fietkau TX_STAT_INC(qnum, tx_pkts_all); 856066dae93SFelix Fietkau sc->debug.stats.txstats[qnum].tx_bytes_all += bf->bf_mpdu->len; 85799c15bf5SBen Greear 858fec247c0SSujith if (bf_isampdu(bf)) { 859156369faSFelix Fietkau if (flags & ATH_TX_ERROR) 860066dae93SFelix Fietkau TX_STAT_INC(qnum, a_xretries); 861fec247c0SSujith else 862066dae93SFelix Fietkau TX_STAT_INC(qnum, a_completed); 863fec247c0SSujith } else { 86455797b1aSFelix Fietkau if (ts->ts_status & ATH9K_TXERR_XRETRY) 8655a6f78afSFelix Fietkau TX_STAT_INC(qnum, xretries); 8665a6f78afSFelix Fietkau else 867066dae93SFelix Fietkau TX_STAT_INC(qnum, completed); 868fec247c0SSujith } 869fec247c0SSujith 870db1a052bSFelix Fietkau if (ts->ts_status & ATH9K_TXERR_FIFO) 871066dae93SFelix Fietkau TX_STAT_INC(qnum, fifo_underrun); 872db1a052bSFelix Fietkau if (ts->ts_status & ATH9K_TXERR_XTXOP) 873066dae93SFelix Fietkau TX_STAT_INC(qnum, xtxop); 874db1a052bSFelix Fietkau if (ts->ts_status & ATH9K_TXERR_TIMER_EXPIRED) 875066dae93SFelix Fietkau TX_STAT_INC(qnum, timer_exp); 876db1a052bSFelix Fietkau if (ts->ts_flags & ATH9K_TX_DESC_CFG_ERR) 877066dae93SFelix Fietkau TX_STAT_INC(qnum, desc_cfg_err); 878db1a052bSFelix Fietkau if (ts->ts_flags & ATH9K_TX_DATA_UNDERRUN) 879066dae93SFelix Fietkau TX_STAT_INC(qnum, data_underrun); 880db1a052bSFelix Fietkau if (ts->ts_flags & ATH9K_TX_DELIM_UNDERRUN) 881066dae93SFelix Fietkau TX_STAT_INC(qnum, delim_underrun); 882cf3af748SRajkumar Manoharan 883cf3af748SRajkumar Manoharan spin_lock(&sc->debug.samp_lock); 884cf3af748SRajkumar Manoharan TX_SAMP_DBG(jiffies) = jiffies; 885cf3af748SRajkumar Manoharan TX_SAMP_DBG(rssi_ctl0) = ts->ts_rssi_ctl0; 886cf3af748SRajkumar Manoharan TX_SAMP_DBG(rssi_ctl1) = ts->ts_rssi_ctl1; 887cf3af748SRajkumar Manoharan TX_SAMP_DBG(rssi_ctl2) = ts->ts_rssi_ctl2; 888cf3af748SRajkumar Manoharan TX_SAMP_DBG(rssi_ext0) = ts->ts_rssi_ext0; 889cf3af748SRajkumar Manoharan TX_SAMP_DBG(rssi_ext1) = ts->ts_rssi_ext1; 890cf3af748SRajkumar Manoharan TX_SAMP_DBG(rssi_ext2) = ts->ts_rssi_ext2; 891cf3af748SRajkumar Manoharan TX_SAMP_DBG(rateindex) = ts->ts_rateindex; 892cf3af748SRajkumar Manoharan TX_SAMP_DBG(isok) = !!(ts->ts_status & ATH9K_TXERR_MASK); 893cf3af748SRajkumar Manoharan TX_SAMP_DBG(rts_fail_cnt) = ts->ts_shortretry; 894cf3af748SRajkumar Manoharan TX_SAMP_DBG(data_fail_cnt) = ts->ts_longretry; 895cf3af748SRajkumar Manoharan TX_SAMP_DBG(rssi) = ts->ts_rssi; 896cf3af748SRajkumar Manoharan TX_SAMP_DBG(tid) = ts->tid; 897cf3af748SRajkumar Manoharan TX_SAMP_DBG(qid) = ts->qid; 89812932180SMohammed Shafi Shajakhan 89912932180SMohammed Shafi Shajakhan if (ts->ts_flags & ATH9K_TX_BA) { 90012932180SMohammed Shafi Shajakhan TX_SAMP_DBG(ba_low) = ts->ba_low; 90112932180SMohammed Shafi Shajakhan TX_SAMP_DBG(ba_high) = ts->ba_high; 90212932180SMohammed Shafi Shajakhan } else { 90312932180SMohammed Shafi Shajakhan TX_SAMP_DBG(ba_low) = 0; 90412932180SMohammed Shafi Shajakhan TX_SAMP_DBG(ba_high) = 0; 90512932180SMohammed Shafi Shajakhan } 90612932180SMohammed Shafi Shajakhan 907cf3af748SRajkumar Manoharan sc->debug.tsidx = (sc->debug.tsidx + 1) % ATH_DBG_MAX_SAMPLES; 908cf3af748SRajkumar Manoharan spin_unlock(&sc->debug.samp_lock); 909cf3af748SRajkumar Manoharan 910cf3af748SRajkumar Manoharan #undef TX_SAMP_DBG 911fec247c0SSujith } 912fec247c0SSujith 913fec247c0SSujith static const struct file_operations fops_xmit = { 914fec247c0SSujith .read = read_file_xmit, 915fec247c0SSujith .open = ath9k_debugfs_open, 9166038f373SArnd Bergmann .owner = THIS_MODULE, 9176038f373SArnd Bergmann .llseek = default_llseek, 918fec247c0SSujith }; 919203c4805SLuis R. Rodriguez 9207f010c93SBen Greear static const struct file_operations fops_stations = { 9217f010c93SBen Greear .read = read_file_stations, 9227f010c93SBen Greear .open = ath9k_debugfs_open, 9237f010c93SBen Greear .owner = THIS_MODULE, 9247f010c93SBen Greear .llseek = default_llseek, 9257f010c93SBen Greear }; 9267f010c93SBen Greear 92755f6d0ffSBen Greear static const struct file_operations fops_misc = { 92855f6d0ffSBen Greear .read = read_file_misc, 92955f6d0ffSBen Greear .open = ath9k_debugfs_open, 93055f6d0ffSBen Greear .owner = THIS_MODULE, 93155f6d0ffSBen Greear .llseek = default_llseek, 93255f6d0ffSBen Greear }; 93355f6d0ffSBen Greear 9341395d3f0SSujith static ssize_t read_file_recv(struct file *file, char __user *user_buf, 9351395d3f0SSujith size_t count, loff_t *ppos) 9361395d3f0SSujith { 9371395d3f0SSujith #define PHY_ERR(s, p) \ 9381395d3f0SSujith len += snprintf(buf + len, size - len, "%18s : %10u\n", s, \ 9391395d3f0SSujith sc->debug.stats.rxstats.phy_err_stats[p]); 9401395d3f0SSujith 9411395d3f0SSujith struct ath_softc *sc = file->private_data; 9421395d3f0SSujith char *buf; 9437d755414SSenthil Balasubramanian unsigned int len = 0, size = 1400; 9441395d3f0SSujith ssize_t retval = 0; 9451395d3f0SSujith 9461395d3f0SSujith buf = kzalloc(size, GFP_KERNEL); 9471395d3f0SSujith if (buf == NULL) 94804236066SDan Carpenter return -ENOMEM; 9491395d3f0SSujith 9501395d3f0SSujith len += snprintf(buf + len, size - len, 9511395d3f0SSujith "%18s : %10u\n", "CRC ERR", 9521395d3f0SSujith sc->debug.stats.rxstats.crc_err); 9531395d3f0SSujith len += snprintf(buf + len, size - len, 9541395d3f0SSujith "%18s : %10u\n", "DECRYPT CRC ERR", 9551395d3f0SSujith sc->debug.stats.rxstats.decrypt_crc_err); 9561395d3f0SSujith len += snprintf(buf + len, size - len, 9571395d3f0SSujith "%18s : %10u\n", "PHY ERR", 9581395d3f0SSujith sc->debug.stats.rxstats.phy_err); 9591395d3f0SSujith len += snprintf(buf + len, size - len, 9601395d3f0SSujith "%18s : %10u\n", "MIC ERR", 9611395d3f0SSujith sc->debug.stats.rxstats.mic_err); 9621395d3f0SSujith len += snprintf(buf + len, size - len, 9631395d3f0SSujith "%18s : %10u\n", "PRE-DELIM CRC ERR", 9641395d3f0SSujith sc->debug.stats.rxstats.pre_delim_crc_err); 9651395d3f0SSujith len += snprintf(buf + len, size - len, 9661395d3f0SSujith "%18s : %10u\n", "POST-DELIM CRC ERR", 9671395d3f0SSujith sc->debug.stats.rxstats.post_delim_crc_err); 9681395d3f0SSujith len += snprintf(buf + len, size - len, 9691395d3f0SSujith "%18s : %10u\n", "DECRYPT BUSY ERR", 9701395d3f0SSujith sc->debug.stats.rxstats.decrypt_busy_err); 9711395d3f0SSujith 9727d755414SSenthil Balasubramanian len += snprintf(buf + len, size - len, 9737d755414SSenthil Balasubramanian "%18s : %10d\n", "RSSI-CTL0", 9747d755414SSenthil Balasubramanian sc->debug.stats.rxstats.rs_rssi_ctl0); 9757d755414SSenthil Balasubramanian 9767d755414SSenthil Balasubramanian len += snprintf(buf + len, size - len, 9777d755414SSenthil Balasubramanian "%18s : %10d\n", "RSSI-CTL1", 9787d755414SSenthil Balasubramanian sc->debug.stats.rxstats.rs_rssi_ctl1); 9797d755414SSenthil Balasubramanian 9807d755414SSenthil Balasubramanian len += snprintf(buf + len, size - len, 9817d755414SSenthil Balasubramanian "%18s : %10d\n", "RSSI-CTL2", 9827d755414SSenthil Balasubramanian sc->debug.stats.rxstats.rs_rssi_ctl2); 9837d755414SSenthil Balasubramanian 9847d755414SSenthil Balasubramanian len += snprintf(buf + len, size - len, 9857d755414SSenthil Balasubramanian "%18s : %10d\n", "RSSI-EXT0", 9867d755414SSenthil Balasubramanian sc->debug.stats.rxstats.rs_rssi_ext0); 9877d755414SSenthil Balasubramanian 9887d755414SSenthil Balasubramanian len += snprintf(buf + len, size - len, 9897d755414SSenthil Balasubramanian "%18s : %10d\n", "RSSI-EXT1", 9907d755414SSenthil Balasubramanian sc->debug.stats.rxstats.rs_rssi_ext1); 9917d755414SSenthil Balasubramanian 9927d755414SSenthil Balasubramanian len += snprintf(buf + len, size - len, 9937d755414SSenthil Balasubramanian "%18s : %10d\n", "RSSI-EXT2", 9947d755414SSenthil Balasubramanian sc->debug.stats.rxstats.rs_rssi_ext2); 9957d755414SSenthil Balasubramanian 9967d755414SSenthil Balasubramanian len += snprintf(buf + len, size - len, 9977d755414SSenthil Balasubramanian "%18s : %10d\n", "Rx Antenna", 9987d755414SSenthil Balasubramanian sc->debug.stats.rxstats.rs_antenna); 9997d755414SSenthil Balasubramanian 10001395d3f0SSujith PHY_ERR("UNDERRUN", ATH9K_PHYERR_UNDERRUN); 10011395d3f0SSujith PHY_ERR("TIMING", ATH9K_PHYERR_TIMING); 10021395d3f0SSujith PHY_ERR("PARITY", ATH9K_PHYERR_PARITY); 10031395d3f0SSujith PHY_ERR("RATE", ATH9K_PHYERR_RATE); 10041395d3f0SSujith PHY_ERR("LENGTH", ATH9K_PHYERR_LENGTH); 10051395d3f0SSujith PHY_ERR("RADAR", ATH9K_PHYERR_RADAR); 10061395d3f0SSujith PHY_ERR("SERVICE", ATH9K_PHYERR_SERVICE); 10071395d3f0SSujith PHY_ERR("TOR", ATH9K_PHYERR_TOR); 10081395d3f0SSujith PHY_ERR("OFDM-TIMING", ATH9K_PHYERR_OFDM_TIMING); 10091395d3f0SSujith PHY_ERR("OFDM-SIGNAL-PARITY", ATH9K_PHYERR_OFDM_SIGNAL_PARITY); 10101395d3f0SSujith PHY_ERR("OFDM-RATE", ATH9K_PHYERR_OFDM_RATE_ILLEGAL); 10111395d3f0SSujith PHY_ERR("OFDM-LENGTH", ATH9K_PHYERR_OFDM_LENGTH_ILLEGAL); 10121395d3f0SSujith PHY_ERR("OFDM-POWER-DROP", ATH9K_PHYERR_OFDM_POWER_DROP); 10131395d3f0SSujith PHY_ERR("OFDM-SERVICE", ATH9K_PHYERR_OFDM_SERVICE); 10141395d3f0SSujith PHY_ERR("OFDM-RESTART", ATH9K_PHYERR_OFDM_RESTART); 10151395d3f0SSujith PHY_ERR("FALSE-RADAR-EXT", ATH9K_PHYERR_FALSE_RADAR_EXT); 10161395d3f0SSujith PHY_ERR("CCK-TIMING", ATH9K_PHYERR_CCK_TIMING); 10171395d3f0SSujith PHY_ERR("CCK-HEADER-CRC", ATH9K_PHYERR_CCK_HEADER_CRC); 10181395d3f0SSujith PHY_ERR("CCK-RATE", ATH9K_PHYERR_CCK_RATE_ILLEGAL); 10191395d3f0SSujith PHY_ERR("CCK-SERVICE", ATH9K_PHYERR_CCK_SERVICE); 10201395d3f0SSujith PHY_ERR("CCK-RESTART", ATH9K_PHYERR_CCK_RESTART); 10211395d3f0SSujith PHY_ERR("CCK-LENGTH", ATH9K_PHYERR_CCK_LENGTH_ILLEGAL); 10221395d3f0SSujith PHY_ERR("CCK-POWER-DROP", ATH9K_PHYERR_CCK_POWER_DROP); 10231395d3f0SSujith PHY_ERR("HT-CRC", ATH9K_PHYERR_HT_CRC_ERROR); 10241395d3f0SSujith PHY_ERR("HT-LENGTH", ATH9K_PHYERR_HT_LENGTH_ILLEGAL); 10251395d3f0SSujith PHY_ERR("HT-RATE", ATH9K_PHYERR_HT_RATE_ILLEGAL); 10261395d3f0SSujith 102799c15bf5SBen Greear len += snprintf(buf + len, size - len, 102899c15bf5SBen Greear "%18s : %10u\n", "RX-Pkts-All", 102999c15bf5SBen Greear sc->debug.stats.rxstats.rx_pkts_all); 103099c15bf5SBen Greear len += snprintf(buf + len, size - len, 103199c15bf5SBen Greear "%18s : %10u\n", "RX-Bytes-All", 103299c15bf5SBen Greear sc->debug.stats.rxstats.rx_bytes_all); 103399c15bf5SBen Greear 10342b87f3aaSDan Carpenter if (len > size) 10352b87f3aaSDan Carpenter len = size; 10362b87f3aaSDan Carpenter 10371395d3f0SSujith retval = simple_read_from_buffer(user_buf, count, ppos, buf, len); 10381395d3f0SSujith kfree(buf); 10391395d3f0SSujith 10401395d3f0SSujith return retval; 10411395d3f0SSujith 10421395d3f0SSujith #undef PHY_ERR 10431395d3f0SSujith } 10441395d3f0SSujith 10458e6f5aa2SFelix Fietkau void ath_debug_stat_rx(struct ath_softc *sc, struct ath_rx_status *rs) 10461395d3f0SSujith { 10471395d3f0SSujith #define RX_STAT_INC(c) sc->debug.stats.rxstats.c++ 10481395d3f0SSujith #define RX_PHY_ERR_INC(c) sc->debug.stats.rxstats.phy_err_stats[c]++ 1049cf3af748SRajkumar Manoharan #define RX_SAMP_DBG(c) (sc->debug.bb_mac_samp[sc->debug.sampidx].rs\ 1050cf3af748SRajkumar Manoharan [sc->debug.rsidx].c) 10511395d3f0SSujith 10521395d3f0SSujith u32 phyerr; 10531395d3f0SSujith 105499c15bf5SBen Greear RX_STAT_INC(rx_pkts_all); 105599c15bf5SBen Greear sc->debug.stats.rxstats.rx_bytes_all += rs->rs_datalen; 105699c15bf5SBen Greear 10578e6f5aa2SFelix Fietkau if (rs->rs_status & ATH9K_RXERR_CRC) 10581395d3f0SSujith RX_STAT_INC(crc_err); 10598e6f5aa2SFelix Fietkau if (rs->rs_status & ATH9K_RXERR_DECRYPT) 10601395d3f0SSujith RX_STAT_INC(decrypt_crc_err); 10618e6f5aa2SFelix Fietkau if (rs->rs_status & ATH9K_RXERR_MIC) 10621395d3f0SSujith RX_STAT_INC(mic_err); 10638e6f5aa2SFelix Fietkau if (rs->rs_status & ATH9K_RX_DELIM_CRC_PRE) 10641395d3f0SSujith RX_STAT_INC(pre_delim_crc_err); 10658e6f5aa2SFelix Fietkau if (rs->rs_status & ATH9K_RX_DELIM_CRC_POST) 10661395d3f0SSujith RX_STAT_INC(post_delim_crc_err); 10678e6f5aa2SFelix Fietkau if (rs->rs_status & ATH9K_RX_DECRYPT_BUSY) 10681395d3f0SSujith RX_STAT_INC(decrypt_busy_err); 10691395d3f0SSujith 10708e6f5aa2SFelix Fietkau if (rs->rs_status & ATH9K_RXERR_PHY) { 10711395d3f0SSujith RX_STAT_INC(phy_err); 10728e6f5aa2SFelix Fietkau phyerr = rs->rs_phyerr & 0x24; 10731395d3f0SSujith RX_PHY_ERR_INC(phyerr); 10741395d3f0SSujith } 10751395d3f0SSujith 10767d755414SSenthil Balasubramanian sc->debug.stats.rxstats.rs_rssi_ctl0 = rs->rs_rssi_ctl0; 10777d755414SSenthil Balasubramanian sc->debug.stats.rxstats.rs_rssi_ctl1 = rs->rs_rssi_ctl1; 10787d755414SSenthil Balasubramanian sc->debug.stats.rxstats.rs_rssi_ctl2 = rs->rs_rssi_ctl2; 10797d755414SSenthil Balasubramanian 10807d755414SSenthil Balasubramanian sc->debug.stats.rxstats.rs_rssi_ext0 = rs->rs_rssi_ext0; 10817d755414SSenthil Balasubramanian sc->debug.stats.rxstats.rs_rssi_ext1 = rs->rs_rssi_ext1; 10827d755414SSenthil Balasubramanian sc->debug.stats.rxstats.rs_rssi_ext2 = rs->rs_rssi_ext2; 10837d755414SSenthil Balasubramanian 10847d755414SSenthil Balasubramanian sc->debug.stats.rxstats.rs_antenna = rs->rs_antenna; 10857d755414SSenthil Balasubramanian 1086cf3af748SRajkumar Manoharan spin_lock(&sc->debug.samp_lock); 1087cf3af748SRajkumar Manoharan RX_SAMP_DBG(jiffies) = jiffies; 1088cf3af748SRajkumar Manoharan RX_SAMP_DBG(rssi_ctl0) = rs->rs_rssi_ctl0; 1089cf3af748SRajkumar Manoharan RX_SAMP_DBG(rssi_ctl1) = rs->rs_rssi_ctl1; 1090cf3af748SRajkumar Manoharan RX_SAMP_DBG(rssi_ctl2) = rs->rs_rssi_ctl2; 1091cf3af748SRajkumar Manoharan RX_SAMP_DBG(rssi_ext0) = rs->rs_rssi_ext0; 1092cf3af748SRajkumar Manoharan RX_SAMP_DBG(rssi_ext1) = rs->rs_rssi_ext1; 1093cf3af748SRajkumar Manoharan RX_SAMP_DBG(rssi_ext2) = rs->rs_rssi_ext2; 1094cf3af748SRajkumar Manoharan RX_SAMP_DBG(antenna) = rs->rs_antenna; 1095cf3af748SRajkumar Manoharan RX_SAMP_DBG(rssi) = rs->rs_rssi; 1096cf3af748SRajkumar Manoharan RX_SAMP_DBG(rate) = rs->rs_rate; 1097cf3af748SRajkumar Manoharan RX_SAMP_DBG(is_mybeacon) = rs->is_mybeacon; 1098cf3af748SRajkumar Manoharan 1099cf3af748SRajkumar Manoharan sc->debug.rsidx = (sc->debug.rsidx + 1) % ATH_DBG_MAX_SAMPLES; 1100cf3af748SRajkumar Manoharan spin_unlock(&sc->debug.samp_lock); 1101cf3af748SRajkumar Manoharan 11021395d3f0SSujith #undef RX_STAT_INC 11031395d3f0SSujith #undef RX_PHY_ERR_INC 1104cf3af748SRajkumar Manoharan #undef RX_SAMP_DBG 11051395d3f0SSujith } 11061395d3f0SSujith 11071395d3f0SSujith static const struct file_operations fops_recv = { 11081395d3f0SSujith .read = read_file_recv, 11091395d3f0SSujith .open = ath9k_debugfs_open, 11106038f373SArnd Bergmann .owner = THIS_MODULE, 11116038f373SArnd Bergmann .llseek = default_llseek, 11121395d3f0SSujith }; 11131395d3f0SSujith 11149bff0bc4SFelix Fietkau static ssize_t read_file_regidx(struct file *file, char __user *user_buf, 11159bff0bc4SFelix Fietkau size_t count, loff_t *ppos) 11169bff0bc4SFelix Fietkau { 11179bff0bc4SFelix Fietkau struct ath_softc *sc = file->private_data; 11189bff0bc4SFelix Fietkau char buf[32]; 11199bff0bc4SFelix Fietkau unsigned int len; 11209bff0bc4SFelix Fietkau 11212b87f3aaSDan Carpenter len = sprintf(buf, "0x%08x\n", sc->debug.regidx); 11229bff0bc4SFelix Fietkau return simple_read_from_buffer(user_buf, count, ppos, buf, len); 11239bff0bc4SFelix Fietkau } 11249bff0bc4SFelix Fietkau 11259bff0bc4SFelix Fietkau static ssize_t write_file_regidx(struct file *file, const char __user *user_buf, 11269bff0bc4SFelix Fietkau size_t count, loff_t *ppos) 11279bff0bc4SFelix Fietkau { 11289bff0bc4SFelix Fietkau struct ath_softc *sc = file->private_data; 11299bff0bc4SFelix Fietkau unsigned long regidx; 11309bff0bc4SFelix Fietkau char buf[32]; 11319bff0bc4SFelix Fietkau ssize_t len; 11329bff0bc4SFelix Fietkau 11339bff0bc4SFelix Fietkau len = min(count, sizeof(buf) - 1); 11349bff0bc4SFelix Fietkau if (copy_from_user(buf, user_buf, len)) 113504236066SDan Carpenter return -EFAULT; 11369bff0bc4SFelix Fietkau 11379bff0bc4SFelix Fietkau buf[len] = '\0'; 11389bff0bc4SFelix Fietkau if (strict_strtoul(buf, 0, ®idx)) 11399bff0bc4SFelix Fietkau return -EINVAL; 11409bff0bc4SFelix Fietkau 11419bff0bc4SFelix Fietkau sc->debug.regidx = regidx; 11429bff0bc4SFelix Fietkau return count; 11439bff0bc4SFelix Fietkau } 11449bff0bc4SFelix Fietkau 11459bff0bc4SFelix Fietkau static const struct file_operations fops_regidx = { 11469bff0bc4SFelix Fietkau .read = read_file_regidx, 11479bff0bc4SFelix Fietkau .write = write_file_regidx, 11489bff0bc4SFelix Fietkau .open = ath9k_debugfs_open, 11496038f373SArnd Bergmann .owner = THIS_MODULE, 11506038f373SArnd Bergmann .llseek = default_llseek, 11519bff0bc4SFelix Fietkau }; 11529bff0bc4SFelix Fietkau 11539bff0bc4SFelix Fietkau static ssize_t read_file_regval(struct file *file, char __user *user_buf, 11549bff0bc4SFelix Fietkau size_t count, loff_t *ppos) 11559bff0bc4SFelix Fietkau { 11569bff0bc4SFelix Fietkau struct ath_softc *sc = file->private_data; 11579bff0bc4SFelix Fietkau struct ath_hw *ah = sc->sc_ah; 11589bff0bc4SFelix Fietkau char buf[32]; 11599bff0bc4SFelix Fietkau unsigned int len; 11609bff0bc4SFelix Fietkau u32 regval; 11619bff0bc4SFelix Fietkau 116279d2b157SRajkumar Manoharan ath9k_ps_wakeup(sc); 11639bff0bc4SFelix Fietkau regval = REG_READ_D(ah, sc->debug.regidx); 116479d2b157SRajkumar Manoharan ath9k_ps_restore(sc); 11652b87f3aaSDan Carpenter len = sprintf(buf, "0x%08x\n", regval); 11669bff0bc4SFelix Fietkau return simple_read_from_buffer(user_buf, count, ppos, buf, len); 11679bff0bc4SFelix Fietkau } 11689bff0bc4SFelix Fietkau 11699bff0bc4SFelix Fietkau static ssize_t write_file_regval(struct file *file, const char __user *user_buf, 11709bff0bc4SFelix Fietkau size_t count, loff_t *ppos) 11719bff0bc4SFelix Fietkau { 11729bff0bc4SFelix Fietkau struct ath_softc *sc = file->private_data; 11739bff0bc4SFelix Fietkau struct ath_hw *ah = sc->sc_ah; 11749bff0bc4SFelix Fietkau unsigned long regval; 11759bff0bc4SFelix Fietkau char buf[32]; 11769bff0bc4SFelix Fietkau ssize_t len; 11779bff0bc4SFelix Fietkau 11789bff0bc4SFelix Fietkau len = min(count, sizeof(buf) - 1); 11799bff0bc4SFelix Fietkau if (copy_from_user(buf, user_buf, len)) 118004236066SDan Carpenter return -EFAULT; 11819bff0bc4SFelix Fietkau 11829bff0bc4SFelix Fietkau buf[len] = '\0'; 11839bff0bc4SFelix Fietkau if (strict_strtoul(buf, 0, ®val)) 11849bff0bc4SFelix Fietkau return -EINVAL; 11859bff0bc4SFelix Fietkau 118679d2b157SRajkumar Manoharan ath9k_ps_wakeup(sc); 11879bff0bc4SFelix Fietkau REG_WRITE_D(ah, sc->debug.regidx, regval); 118879d2b157SRajkumar Manoharan ath9k_ps_restore(sc); 11899bff0bc4SFelix Fietkau return count; 11909bff0bc4SFelix Fietkau } 11919bff0bc4SFelix Fietkau 11929bff0bc4SFelix Fietkau static const struct file_operations fops_regval = { 11939bff0bc4SFelix Fietkau .read = read_file_regval, 11949bff0bc4SFelix Fietkau .write = write_file_regval, 11959bff0bc4SFelix Fietkau .open = ath9k_debugfs_open, 11966038f373SArnd Bergmann .owner = THIS_MODULE, 11976038f373SArnd Bergmann .llseek = default_llseek, 11989bff0bc4SFelix Fietkau }; 11999bff0bc4SFelix Fietkau 1200582d0064SVasanthakumar Thiagarajan #define REGDUMP_LINE_SIZE 20 1201582d0064SVasanthakumar Thiagarajan 1202582d0064SVasanthakumar Thiagarajan static int open_file_regdump(struct inode *inode, struct file *file) 1203582d0064SVasanthakumar Thiagarajan { 1204582d0064SVasanthakumar Thiagarajan struct ath_softc *sc = inode->i_private; 1205582d0064SVasanthakumar Thiagarajan unsigned int len = 0; 1206582d0064SVasanthakumar Thiagarajan u8 *buf; 1207582d0064SVasanthakumar Thiagarajan int i; 1208582d0064SVasanthakumar Thiagarajan unsigned long num_regs, regdump_len, max_reg_offset; 1209582d0064SVasanthakumar Thiagarajan 1210582d0064SVasanthakumar Thiagarajan max_reg_offset = AR_SREV_9300_20_OR_LATER(sc->sc_ah) ? 0x16bd4 : 0xb500; 1211582d0064SVasanthakumar Thiagarajan num_regs = max_reg_offset / 4 + 1; 1212582d0064SVasanthakumar Thiagarajan regdump_len = num_regs * REGDUMP_LINE_SIZE + 1; 1213582d0064SVasanthakumar Thiagarajan buf = vmalloc(regdump_len); 1214582d0064SVasanthakumar Thiagarajan if (!buf) 1215582d0064SVasanthakumar Thiagarajan return -ENOMEM; 1216582d0064SVasanthakumar Thiagarajan 1217582d0064SVasanthakumar Thiagarajan ath9k_ps_wakeup(sc); 1218582d0064SVasanthakumar Thiagarajan for (i = 0; i < num_regs; i++) 1219582d0064SVasanthakumar Thiagarajan len += scnprintf(buf + len, regdump_len - len, 1220582d0064SVasanthakumar Thiagarajan "0x%06x 0x%08x\n", i << 2, REG_READ(sc->sc_ah, i << 2)); 1221582d0064SVasanthakumar Thiagarajan ath9k_ps_restore(sc); 1222582d0064SVasanthakumar Thiagarajan 1223582d0064SVasanthakumar Thiagarajan file->private_data = buf; 1224582d0064SVasanthakumar Thiagarajan 1225582d0064SVasanthakumar Thiagarajan return 0; 1226582d0064SVasanthakumar Thiagarajan } 1227582d0064SVasanthakumar Thiagarajan 1228582d0064SVasanthakumar Thiagarajan static const struct file_operations fops_regdump = { 1229582d0064SVasanthakumar Thiagarajan .open = open_file_regdump, 1230582d0064SVasanthakumar Thiagarajan .read = ath9k_debugfs_read_buf, 1231582d0064SVasanthakumar Thiagarajan .release = ath9k_debugfs_release_buf, 1232582d0064SVasanthakumar Thiagarajan .owner = THIS_MODULE, 1233582d0064SVasanthakumar Thiagarajan .llseek = default_llseek,/* read accesses f_pos */ 1234582d0064SVasanthakumar Thiagarajan }; 1235582d0064SVasanthakumar Thiagarajan 1236d069a46bSRajkumar Manoharan static ssize_t read_file_dump_nfcal(struct file *file, char __user *user_buf, 1237d069a46bSRajkumar Manoharan size_t count, loff_t *ppos) 1238d069a46bSRajkumar Manoharan { 1239d069a46bSRajkumar Manoharan struct ath_softc *sc = file->private_data; 1240d069a46bSRajkumar Manoharan struct ath_hw *ah = sc->sc_ah; 1241d069a46bSRajkumar Manoharan struct ath9k_nfcal_hist *h = sc->caldata.nfCalHist; 1242d069a46bSRajkumar Manoharan struct ath_common *common = ath9k_hw_common(ah); 1243d069a46bSRajkumar Manoharan struct ieee80211_conf *conf = &common->hw->conf; 1244d069a46bSRajkumar Manoharan u32 len = 0, size = 1500; 1245d069a46bSRajkumar Manoharan u32 i, j; 1246d069a46bSRajkumar Manoharan ssize_t retval = 0; 1247d069a46bSRajkumar Manoharan char *buf; 1248d069a46bSRajkumar Manoharan u8 chainmask = (ah->rxchainmask << 3) | ah->rxchainmask; 1249d069a46bSRajkumar Manoharan u8 nread; 1250d069a46bSRajkumar Manoharan 1251d069a46bSRajkumar Manoharan buf = kzalloc(size, GFP_KERNEL); 1252d069a46bSRajkumar Manoharan if (!buf) 1253d069a46bSRajkumar Manoharan return -ENOMEM; 1254d069a46bSRajkumar Manoharan 1255d069a46bSRajkumar Manoharan len += snprintf(buf + len, size - len, 1256d069a46bSRajkumar Manoharan "Channel Noise Floor : %d\n", ah->noise); 1257d069a46bSRajkumar Manoharan len += snprintf(buf + len, size - len, 1258d069a46bSRajkumar Manoharan "Chain | privNF | # Readings | NF Readings\n"); 1259d069a46bSRajkumar Manoharan for (i = 0; i < NUM_NF_READINGS; i++) { 1260d069a46bSRajkumar Manoharan if (!(chainmask & (1 << i)) || 1261d069a46bSRajkumar Manoharan ((i >= AR5416_MAX_CHAINS) && !conf_is_ht40(conf))) 1262d069a46bSRajkumar Manoharan continue; 1263d069a46bSRajkumar Manoharan 1264d069a46bSRajkumar Manoharan nread = AR_PHY_CCA_FILTERWINDOW_LENGTH - h[i].invalidNFcount; 1265d069a46bSRajkumar Manoharan len += snprintf(buf + len, size - len, " %d\t %d\t %d\t\t", 1266d069a46bSRajkumar Manoharan i, h[i].privNF, nread); 1267d069a46bSRajkumar Manoharan for (j = 0; j < nread; j++) 1268d069a46bSRajkumar Manoharan len += snprintf(buf + len, size - len, 1269d069a46bSRajkumar Manoharan " %d", h[i].nfCalBuffer[j]); 1270d069a46bSRajkumar Manoharan len += snprintf(buf + len, size - len, "\n"); 1271d069a46bSRajkumar Manoharan } 1272d069a46bSRajkumar Manoharan 1273d069a46bSRajkumar Manoharan if (len > size) 1274d069a46bSRajkumar Manoharan len = size; 1275d069a46bSRajkumar Manoharan 1276d069a46bSRajkumar Manoharan retval = simple_read_from_buffer(user_buf, count, ppos, buf, len); 1277d069a46bSRajkumar Manoharan kfree(buf); 1278d069a46bSRajkumar Manoharan 1279d069a46bSRajkumar Manoharan return retval; 1280d069a46bSRajkumar Manoharan } 1281d069a46bSRajkumar Manoharan 1282d069a46bSRajkumar Manoharan static const struct file_operations fops_dump_nfcal = { 1283d069a46bSRajkumar Manoharan .read = read_file_dump_nfcal, 1284d069a46bSRajkumar Manoharan .open = ath9k_debugfs_open, 1285d069a46bSRajkumar Manoharan .owner = THIS_MODULE, 1286d069a46bSRajkumar Manoharan .llseek = default_llseek, 1287d069a46bSRajkumar Manoharan }; 1288d069a46bSRajkumar Manoharan 1289580f010fSRajkumar Manoharan static ssize_t read_file_base_eeprom(struct file *file, char __user *user_buf, 1290580f010fSRajkumar Manoharan size_t count, loff_t *ppos) 1291580f010fSRajkumar Manoharan { 1292580f010fSRajkumar Manoharan struct ath_softc *sc = file->private_data; 1293580f010fSRajkumar Manoharan struct ath_hw *ah = sc->sc_ah; 1294580f010fSRajkumar Manoharan u32 len = 0, size = 1500; 1295580f010fSRajkumar Manoharan ssize_t retval = 0; 1296580f010fSRajkumar Manoharan char *buf; 1297580f010fSRajkumar Manoharan 1298580f010fSRajkumar Manoharan buf = kzalloc(size, GFP_KERNEL); 1299580f010fSRajkumar Manoharan if (!buf) 1300580f010fSRajkumar Manoharan return -ENOMEM; 1301580f010fSRajkumar Manoharan 1302580f010fSRajkumar Manoharan len = ah->eep_ops->dump_eeprom(ah, true, buf, len, size); 1303580f010fSRajkumar Manoharan 1304580f010fSRajkumar Manoharan retval = simple_read_from_buffer(user_buf, count, ppos, buf, len); 1305580f010fSRajkumar Manoharan kfree(buf); 1306580f010fSRajkumar Manoharan 1307580f010fSRajkumar Manoharan return retval; 1308580f010fSRajkumar Manoharan } 1309580f010fSRajkumar Manoharan 1310580f010fSRajkumar Manoharan static const struct file_operations fops_base_eeprom = { 1311580f010fSRajkumar Manoharan .read = read_file_base_eeprom, 1312580f010fSRajkumar Manoharan .open = ath9k_debugfs_open, 1313580f010fSRajkumar Manoharan .owner = THIS_MODULE, 1314580f010fSRajkumar Manoharan .llseek = default_llseek, 1315580f010fSRajkumar Manoharan }; 1316580f010fSRajkumar Manoharan 13173f4c4bddSRajkumar Manoharan static ssize_t read_file_modal_eeprom(struct file *file, char __user *user_buf, 13183f4c4bddSRajkumar Manoharan size_t count, loff_t *ppos) 13193f4c4bddSRajkumar Manoharan { 13203f4c4bddSRajkumar Manoharan struct ath_softc *sc = file->private_data; 13213f4c4bddSRajkumar Manoharan struct ath_hw *ah = sc->sc_ah; 13223f4c4bddSRajkumar Manoharan u32 len = 0, size = 6000; 13233f4c4bddSRajkumar Manoharan char *buf; 13243f4c4bddSRajkumar Manoharan size_t retval; 13253f4c4bddSRajkumar Manoharan 13263f4c4bddSRajkumar Manoharan buf = kzalloc(size, GFP_KERNEL); 13273f4c4bddSRajkumar Manoharan if (buf == NULL) 13283f4c4bddSRajkumar Manoharan return -ENOMEM; 13293f4c4bddSRajkumar Manoharan 13303f4c4bddSRajkumar Manoharan len = ah->eep_ops->dump_eeprom(ah, false, buf, len, size); 13313f4c4bddSRajkumar Manoharan 13323f4c4bddSRajkumar Manoharan retval = simple_read_from_buffer(user_buf, count, ppos, buf, len); 13333f4c4bddSRajkumar Manoharan kfree(buf); 13343f4c4bddSRajkumar Manoharan 13353f4c4bddSRajkumar Manoharan return retval; 13363f4c4bddSRajkumar Manoharan } 13373f4c4bddSRajkumar Manoharan 13383f4c4bddSRajkumar Manoharan static const struct file_operations fops_modal_eeprom = { 13393f4c4bddSRajkumar Manoharan .read = read_file_modal_eeprom, 13403f4c4bddSRajkumar Manoharan .open = ath9k_debugfs_open, 13413f4c4bddSRajkumar Manoharan .owner = THIS_MODULE, 13423f4c4bddSRajkumar Manoharan .llseek = default_llseek, 13433f4c4bddSRajkumar Manoharan }; 13443f4c4bddSRajkumar Manoharan 1345cf3af748SRajkumar Manoharan void ath9k_debug_samp_bb_mac(struct ath_softc *sc) 1346cf3af748SRajkumar Manoharan { 1347cf3af748SRajkumar Manoharan #define ATH_SAMP_DBG(c) (sc->debug.bb_mac_samp[sc->debug.sampidx].c) 1348cf3af748SRajkumar Manoharan struct ath_hw *ah = sc->sc_ah; 1349cf3af748SRajkumar Manoharan struct ath_common *common = ath9k_hw_common(ah); 1350cf3af748SRajkumar Manoharan unsigned long flags; 1351cf3af748SRajkumar Manoharan int i; 1352cf3af748SRajkumar Manoharan 1353cf3af748SRajkumar Manoharan ath9k_ps_wakeup(sc); 1354cf3af748SRajkumar Manoharan 13556bc05a95SRajkumar Manoharan spin_lock_bh(&sc->debug.samp_lock); 13566bc05a95SRajkumar Manoharan 1357cf3af748SRajkumar Manoharan spin_lock_irqsave(&common->cc_lock, flags); 1358cf3af748SRajkumar Manoharan ath_hw_cycle_counters_update(common); 1359cf3af748SRajkumar Manoharan 1360cf3af748SRajkumar Manoharan ATH_SAMP_DBG(cc.cycles) = common->cc_ani.cycles; 1361cf3af748SRajkumar Manoharan ATH_SAMP_DBG(cc.rx_busy) = common->cc_ani.rx_busy; 1362cf3af748SRajkumar Manoharan ATH_SAMP_DBG(cc.rx_frame) = common->cc_ani.rx_frame; 1363cf3af748SRajkumar Manoharan ATH_SAMP_DBG(cc.tx_frame) = common->cc_ani.tx_frame; 13646bc05a95SRajkumar Manoharan spin_unlock_irqrestore(&common->cc_lock, flags); 13656bc05a95SRajkumar Manoharan 1366cf3af748SRajkumar Manoharan ATH_SAMP_DBG(noise) = ah->noise; 1367cf3af748SRajkumar Manoharan 1368cf3af748SRajkumar Manoharan REG_WRITE_D(ah, AR_MACMISC, 1369cf3af748SRajkumar Manoharan ((AR_MACMISC_DMA_OBS_LINE_8 << AR_MACMISC_DMA_OBS_S) | 1370cf3af748SRajkumar Manoharan (AR_MACMISC_MISC_OBS_BUS_1 << 1371cf3af748SRajkumar Manoharan AR_MACMISC_MISC_OBS_BUS_MSB_S))); 1372cf3af748SRajkumar Manoharan 1373cf3af748SRajkumar Manoharan for (i = 0; i < ATH9K_NUM_DMA_DEBUG_REGS; i++) 1374cf3af748SRajkumar Manoharan ATH_SAMP_DBG(dma_dbg_reg_vals[i]) = REG_READ_D(ah, 1375cf3af748SRajkumar Manoharan AR_DMADBG_0 + (i * sizeof(u32))); 1376cf3af748SRajkumar Manoharan 1377cf3af748SRajkumar Manoharan ATH_SAMP_DBG(pcu_obs) = REG_READ_D(ah, AR_OBS_BUS_1); 1378cf3af748SRajkumar Manoharan ATH_SAMP_DBG(pcu_cr) = REG_READ_D(ah, AR_CR); 1379cf3af748SRajkumar Manoharan 1380cf3af748SRajkumar Manoharan memcpy(ATH_SAMP_DBG(nfCalHist), sc->caldata.nfCalHist, 1381cf3af748SRajkumar Manoharan sizeof(ATH_SAMP_DBG(nfCalHist))); 1382cf3af748SRajkumar Manoharan 1383cf3af748SRajkumar Manoharan sc->debug.sampidx = (sc->debug.sampidx + 1) % ATH_DBG_MAX_SAMPLES; 1384cf3af748SRajkumar Manoharan spin_unlock_bh(&sc->debug.samp_lock); 1385cf3af748SRajkumar Manoharan ath9k_ps_restore(sc); 1386cf3af748SRajkumar Manoharan 1387cf3af748SRajkumar Manoharan #undef ATH_SAMP_DBG 1388cf3af748SRajkumar Manoharan } 1389cf3af748SRajkumar Manoharan 1390cf3af748SRajkumar Manoharan static int open_file_bb_mac_samps(struct inode *inode, struct file *file) 1391cf3af748SRajkumar Manoharan { 1392cf3af748SRajkumar Manoharan #define ATH_SAMP_DBG(c) bb_mac_samp[sampidx].c 1393cf3af748SRajkumar Manoharan struct ath_softc *sc = inode->i_private; 1394cf3af748SRajkumar Manoharan struct ath_hw *ah = sc->sc_ah; 1395cf3af748SRajkumar Manoharan struct ath_common *common = ath9k_hw_common(ah); 1396cf3af748SRajkumar Manoharan struct ieee80211_conf *conf = &common->hw->conf; 1397cf3af748SRajkumar Manoharan struct ath_dbg_bb_mac_samp *bb_mac_samp; 1398cf3af748SRajkumar Manoharan struct ath9k_nfcal_hist *h; 1399cf3af748SRajkumar Manoharan int i, j, qcuOffset = 0, dcuOffset = 0; 1400cf3af748SRajkumar Manoharan u32 *qcuBase, *dcuBase, size = 30000, len = 0; 1401cf3af748SRajkumar Manoharan u32 sampidx = 0; 1402cf3af748SRajkumar Manoharan u8 *buf; 1403cf3af748SRajkumar Manoharan u8 chainmask = (ah->rxchainmask << 3) | ah->rxchainmask; 1404cf3af748SRajkumar Manoharan u8 nread; 1405cf3af748SRajkumar Manoharan 1406f7e014daSRajkumar Manoharan if (sc->sc_flags & SC_OP_INVALID) 1407f7e014daSRajkumar Manoharan return -EAGAIN; 1408f7e014daSRajkumar Manoharan 1409cf3af748SRajkumar Manoharan buf = vmalloc(size); 1410cf3af748SRajkumar Manoharan if (!buf) 1411cf3af748SRajkumar Manoharan return -ENOMEM; 1412cf3af748SRajkumar Manoharan bb_mac_samp = vmalloc(sizeof(*bb_mac_samp) * ATH_DBG_MAX_SAMPLES); 1413cf3af748SRajkumar Manoharan if (!bb_mac_samp) { 1414cf3af748SRajkumar Manoharan vfree(buf); 1415cf3af748SRajkumar Manoharan return -ENOMEM; 1416cf3af748SRajkumar Manoharan } 1417f7e014daSRajkumar Manoharan /* Account the current state too */ 1418f7e014daSRajkumar Manoharan ath9k_debug_samp_bb_mac(sc); 1419cf3af748SRajkumar Manoharan 1420cf3af748SRajkumar Manoharan spin_lock_bh(&sc->debug.samp_lock); 1421cf3af748SRajkumar Manoharan memcpy(bb_mac_samp, sc->debug.bb_mac_samp, 1422cf3af748SRajkumar Manoharan sizeof(*bb_mac_samp) * ATH_DBG_MAX_SAMPLES); 14236bc05a95SRajkumar Manoharan len += snprintf(buf + len, size - len, 14246bc05a95SRajkumar Manoharan "Current Sample Index: %d\n", sc->debug.sampidx); 1425cf3af748SRajkumar Manoharan spin_unlock_bh(&sc->debug.samp_lock); 1426cf3af748SRajkumar Manoharan 1427cf3af748SRajkumar Manoharan len += snprintf(buf + len, size - len, 1428cf3af748SRajkumar Manoharan "Raw DMA Debug Dump:\n"); 1429cf3af748SRajkumar Manoharan len += snprintf(buf + len, size - len, "Sample |\t"); 1430cf3af748SRajkumar Manoharan for (i = 0; i < ATH9K_NUM_DMA_DEBUG_REGS; i++) 1431cf3af748SRajkumar Manoharan len += snprintf(buf + len, size - len, " DMA Reg%d |\t", i); 1432cf3af748SRajkumar Manoharan len += snprintf(buf + len, size - len, "\n"); 1433cf3af748SRajkumar Manoharan 1434cf3af748SRajkumar Manoharan for (sampidx = 0; sampidx < ATH_DBG_MAX_SAMPLES; sampidx++) { 1435cf3af748SRajkumar Manoharan len += snprintf(buf + len, size - len, "%d\t", sampidx); 1436cf3af748SRajkumar Manoharan 1437cf3af748SRajkumar Manoharan for (i = 0; i < ATH9K_NUM_DMA_DEBUG_REGS; i++) 1438cf3af748SRajkumar Manoharan len += snprintf(buf + len, size - len, " %08x\t", 1439cf3af748SRajkumar Manoharan ATH_SAMP_DBG(dma_dbg_reg_vals[i])); 1440cf3af748SRajkumar Manoharan len += snprintf(buf + len, size - len, "\n"); 1441cf3af748SRajkumar Manoharan } 1442cf3af748SRajkumar Manoharan len += snprintf(buf + len, size - len, "\n"); 1443cf3af748SRajkumar Manoharan 1444cf3af748SRajkumar Manoharan len += snprintf(buf + len, size - len, 1445cf3af748SRajkumar Manoharan "Sample Num QCU: chain_st fsp_ok fsp_st DCU: chain_st\n"); 1446cf3af748SRajkumar Manoharan for (sampidx = 0; sampidx < ATH_DBG_MAX_SAMPLES; sampidx++) { 1447cf3af748SRajkumar Manoharan qcuBase = &ATH_SAMP_DBG(dma_dbg_reg_vals[0]); 1448cf3af748SRajkumar Manoharan dcuBase = &ATH_SAMP_DBG(dma_dbg_reg_vals[4]); 1449cf3af748SRajkumar Manoharan 1450cf3af748SRajkumar Manoharan for (i = 0; i < ATH9K_NUM_QUEUES; i++, 1451cf3af748SRajkumar Manoharan qcuOffset += 4, dcuOffset += 5) { 1452cf3af748SRajkumar Manoharan if (i == 8) { 1453cf3af748SRajkumar Manoharan qcuOffset = 0; 1454cf3af748SRajkumar Manoharan qcuBase++; 1455cf3af748SRajkumar Manoharan } 1456cf3af748SRajkumar Manoharan 1457cf3af748SRajkumar Manoharan if (i == 6) { 1458cf3af748SRajkumar Manoharan dcuOffset = 0; 1459cf3af748SRajkumar Manoharan dcuBase++; 1460cf3af748SRajkumar Manoharan } 1461cf3af748SRajkumar Manoharan if (!sc->debug.stats.txstats[i].queued) 1462cf3af748SRajkumar Manoharan continue; 1463cf3af748SRajkumar Manoharan 1464cf3af748SRajkumar Manoharan len += snprintf(buf + len, size - len, 1465cf3af748SRajkumar Manoharan "%4d %7d %2x %1x %2x %2x\n", 1466cf3af748SRajkumar Manoharan sampidx, i, 1467cf3af748SRajkumar Manoharan (*qcuBase & (0x7 << qcuOffset)) >> qcuOffset, 1468cf3af748SRajkumar Manoharan (*qcuBase & (0x8 << qcuOffset)) >> 1469cf3af748SRajkumar Manoharan (qcuOffset + 3), 1470cf3af748SRajkumar Manoharan ATH_SAMP_DBG(dma_dbg_reg_vals[2]) & 1471cf3af748SRajkumar Manoharan (0x7 << (i * 3)) >> (i * 3), 1472cf3af748SRajkumar Manoharan (*dcuBase & (0x1f << dcuOffset)) >> dcuOffset); 1473cf3af748SRajkumar Manoharan } 1474cf3af748SRajkumar Manoharan len += snprintf(buf + len, size - len, "\n"); 1475cf3af748SRajkumar Manoharan } 1476cf3af748SRajkumar Manoharan len += snprintf(buf + len, size - len, 1477cf3af748SRajkumar Manoharan "samp qcu_sh qcu_fh qcu_comp dcu_comp dcu_arb dcu_fp " 1478cf3af748SRajkumar Manoharan "ch_idle_dur ch_idle_dur_val txfifo_val0 txfifo_val1 " 1479cf3af748SRajkumar Manoharan "txfifo_dcu0 txfifo_dcu1 pcu_obs AR_CR\n"); 1480cf3af748SRajkumar Manoharan 1481cf3af748SRajkumar Manoharan for (sampidx = 0; sampidx < ATH_DBG_MAX_SAMPLES; sampidx++) { 1482cf3af748SRajkumar Manoharan qcuBase = &ATH_SAMP_DBG(dma_dbg_reg_vals[0]); 1483cf3af748SRajkumar Manoharan dcuBase = &ATH_SAMP_DBG(dma_dbg_reg_vals[4]); 1484cf3af748SRajkumar Manoharan 1485cf3af748SRajkumar Manoharan len += snprintf(buf + len, size - len, "%4d %5x %5x ", sampidx, 1486cf3af748SRajkumar Manoharan (ATH_SAMP_DBG(dma_dbg_reg_vals[3]) & 0x003c0000) >> 18, 1487cf3af748SRajkumar Manoharan (ATH_SAMP_DBG(dma_dbg_reg_vals[3]) & 0x03c00000) >> 22); 1488cf3af748SRajkumar Manoharan len += snprintf(buf + len, size - len, "%7x %8x ", 1489cf3af748SRajkumar Manoharan (ATH_SAMP_DBG(dma_dbg_reg_vals[3]) & 0x1c000000) >> 26, 1490cf3af748SRajkumar Manoharan (ATH_SAMP_DBG(dma_dbg_reg_vals[6]) & 0x3)); 1491cf3af748SRajkumar Manoharan len += snprintf(buf + len, size - len, "%7x %7x ", 1492cf3af748SRajkumar Manoharan (ATH_SAMP_DBG(dma_dbg_reg_vals[5]) & 0x06000000) >> 25, 1493cf3af748SRajkumar Manoharan (ATH_SAMP_DBG(dma_dbg_reg_vals[5]) & 0x38000000) >> 27); 1494cf3af748SRajkumar Manoharan len += snprintf(buf + len, size - len, "%7d %12d ", 1495cf3af748SRajkumar Manoharan (ATH_SAMP_DBG(dma_dbg_reg_vals[6]) & 0x000003fc) >> 2, 1496cf3af748SRajkumar Manoharan (ATH_SAMP_DBG(dma_dbg_reg_vals[6]) & 0x00000400) >> 10); 1497cf3af748SRajkumar Manoharan len += snprintf(buf + len, size - len, "%12d %12d ", 1498cf3af748SRajkumar Manoharan (ATH_SAMP_DBG(dma_dbg_reg_vals[6]) & 0x00000800) >> 11, 1499cf3af748SRajkumar Manoharan (ATH_SAMP_DBG(dma_dbg_reg_vals[6]) & 0x00001000) >> 12); 1500cf3af748SRajkumar Manoharan len += snprintf(buf + len, size - len, "%12d %12d ", 1501cf3af748SRajkumar Manoharan (ATH_SAMP_DBG(dma_dbg_reg_vals[6]) & 0x0001e000) >> 13, 1502cf3af748SRajkumar Manoharan (ATH_SAMP_DBG(dma_dbg_reg_vals[6]) & 0x001e0000) >> 17); 1503cf3af748SRajkumar Manoharan len += snprintf(buf + len, size - len, "0x%07x 0x%07x\n", 1504cf3af748SRajkumar Manoharan ATH_SAMP_DBG(pcu_obs), ATH_SAMP_DBG(pcu_cr)); 1505cf3af748SRajkumar Manoharan } 1506cf3af748SRajkumar Manoharan 1507cf3af748SRajkumar Manoharan len += snprintf(buf + len, size - len, 1508cf3af748SRajkumar Manoharan "Sample ChNoise Chain privNF #Reading Readings\n"); 1509cf3af748SRajkumar Manoharan for (sampidx = 0; sampidx < ATH_DBG_MAX_SAMPLES; sampidx++) { 1510cf3af748SRajkumar Manoharan h = ATH_SAMP_DBG(nfCalHist); 1511cf3af748SRajkumar Manoharan if (!ATH_SAMP_DBG(noise)) 1512cf3af748SRajkumar Manoharan continue; 1513cf3af748SRajkumar Manoharan 1514cf3af748SRajkumar Manoharan for (i = 0; i < NUM_NF_READINGS; i++) { 1515cf3af748SRajkumar Manoharan if (!(chainmask & (1 << i)) || 1516cf3af748SRajkumar Manoharan ((i >= AR5416_MAX_CHAINS) && !conf_is_ht40(conf))) 1517cf3af748SRajkumar Manoharan continue; 1518cf3af748SRajkumar Manoharan 1519cf3af748SRajkumar Manoharan nread = AR_PHY_CCA_FILTERWINDOW_LENGTH - 1520cf3af748SRajkumar Manoharan h[i].invalidNFcount; 1521cf3af748SRajkumar Manoharan len += snprintf(buf + len, size - len, 1522cf3af748SRajkumar Manoharan "%4d %5d %4d\t %d\t %d\t", 1523cf3af748SRajkumar Manoharan sampidx, ATH_SAMP_DBG(noise), 1524cf3af748SRajkumar Manoharan i, h[i].privNF, nread); 1525cf3af748SRajkumar Manoharan for (j = 0; j < nread; j++) 1526cf3af748SRajkumar Manoharan len += snprintf(buf + len, size - len, 1527cf3af748SRajkumar Manoharan " %d", h[i].nfCalBuffer[j]); 1528cf3af748SRajkumar Manoharan len += snprintf(buf + len, size - len, "\n"); 1529cf3af748SRajkumar Manoharan } 1530cf3af748SRajkumar Manoharan } 1531cf3af748SRajkumar Manoharan len += snprintf(buf + len, size - len, "\nCycle counters:\n" 1532cf3af748SRajkumar Manoharan "Sample Total Rxbusy Rxframes Txframes\n"); 1533cf3af748SRajkumar Manoharan for (sampidx = 0; sampidx < ATH_DBG_MAX_SAMPLES; sampidx++) { 1534cf3af748SRajkumar Manoharan if (!ATH_SAMP_DBG(cc.cycles)) 1535cf3af748SRajkumar Manoharan continue; 1536cf3af748SRajkumar Manoharan len += snprintf(buf + len, size - len, 1537cf3af748SRajkumar Manoharan "%4d %08x %08x %08x %08x\n", 1538cf3af748SRajkumar Manoharan sampidx, ATH_SAMP_DBG(cc.cycles), 1539cf3af748SRajkumar Manoharan ATH_SAMP_DBG(cc.rx_busy), 1540cf3af748SRajkumar Manoharan ATH_SAMP_DBG(cc.rx_frame), 1541cf3af748SRajkumar Manoharan ATH_SAMP_DBG(cc.tx_frame)); 1542cf3af748SRajkumar Manoharan } 1543cf3af748SRajkumar Manoharan 1544cf3af748SRajkumar Manoharan len += snprintf(buf + len, size - len, "Tx status Dump :\n"); 1545cf3af748SRajkumar Manoharan len += snprintf(buf + len, size - len, 1546cf3af748SRajkumar Manoharan "Sample rssi:- ctl0 ctl1 ctl2 ext0 ext1 ext2 comb " 154712932180SMohammed Shafi Shajakhan "isok rts_fail data_fail rate tid qid " 154812932180SMohammed Shafi Shajakhan "ba_low ba_high tx_before(ms)\n"); 1549cf3af748SRajkumar Manoharan for (sampidx = 0; sampidx < ATH_DBG_MAX_SAMPLES; sampidx++) { 1550cf3af748SRajkumar Manoharan for (i = 0; i < ATH_DBG_MAX_SAMPLES; i++) { 1551cf3af748SRajkumar Manoharan if (!ATH_SAMP_DBG(ts[i].jiffies)) 1552cf3af748SRajkumar Manoharan continue; 155312932180SMohammed Shafi Shajakhan len += snprintf(buf + len, size - len, "%-14d" 155412932180SMohammed Shafi Shajakhan "%-4d %-4d %-4d %-4d %-4d %-4d %-4d %-4d %-8d " 155512932180SMohammed Shafi Shajakhan "%-9d %-4d %-3d %-3d %08x %08x %-11d\n", 1556cf3af748SRajkumar Manoharan sampidx, 1557cf3af748SRajkumar Manoharan ATH_SAMP_DBG(ts[i].rssi_ctl0), 1558cf3af748SRajkumar Manoharan ATH_SAMP_DBG(ts[i].rssi_ctl1), 1559cf3af748SRajkumar Manoharan ATH_SAMP_DBG(ts[i].rssi_ctl2), 1560cf3af748SRajkumar Manoharan ATH_SAMP_DBG(ts[i].rssi_ext0), 1561cf3af748SRajkumar Manoharan ATH_SAMP_DBG(ts[i].rssi_ext1), 1562cf3af748SRajkumar Manoharan ATH_SAMP_DBG(ts[i].rssi_ext2), 1563cf3af748SRajkumar Manoharan ATH_SAMP_DBG(ts[i].rssi), 1564cf3af748SRajkumar Manoharan ATH_SAMP_DBG(ts[i].isok), 1565cf3af748SRajkumar Manoharan ATH_SAMP_DBG(ts[i].rts_fail_cnt), 1566cf3af748SRajkumar Manoharan ATH_SAMP_DBG(ts[i].data_fail_cnt), 1567cf3af748SRajkumar Manoharan ATH_SAMP_DBG(ts[i].rateindex), 1568cf3af748SRajkumar Manoharan ATH_SAMP_DBG(ts[i].tid), 1569cf3af748SRajkumar Manoharan ATH_SAMP_DBG(ts[i].qid), 157012932180SMohammed Shafi Shajakhan ATH_SAMP_DBG(ts[i].ba_low), 157112932180SMohammed Shafi Shajakhan ATH_SAMP_DBG(ts[i].ba_high), 1572cf3af748SRajkumar Manoharan jiffies_to_msecs(jiffies - 1573cf3af748SRajkumar Manoharan ATH_SAMP_DBG(ts[i].jiffies))); 1574cf3af748SRajkumar Manoharan } 1575cf3af748SRajkumar Manoharan } 1576cf3af748SRajkumar Manoharan 1577cf3af748SRajkumar Manoharan len += snprintf(buf + len, size - len, "Rx status Dump :\n"); 1578cf3af748SRajkumar Manoharan len += snprintf(buf + len, size - len, "Sample rssi:- ctl0 ctl1 ctl2 " 1579cf3af748SRajkumar Manoharan "ext0 ext1 ext2 comb beacon ant rate rx_before(ms)\n"); 1580cf3af748SRajkumar Manoharan for (sampidx = 0; sampidx < ATH_DBG_MAX_SAMPLES; sampidx++) { 1581cf3af748SRajkumar Manoharan for (i = 0; i < ATH_DBG_MAX_SAMPLES; i++) { 1582cf3af748SRajkumar Manoharan if (!ATH_SAMP_DBG(rs[i].jiffies)) 1583cf3af748SRajkumar Manoharan continue; 158412932180SMohammed Shafi Shajakhan len += snprintf(buf + len, size - len, "%-14d" 158512932180SMohammed Shafi Shajakhan "%-4d %-4d %-4d %-4d %-4d %-4d %-4d %-9s %-2d %02x %-13d\n", 1586cf3af748SRajkumar Manoharan sampidx, 1587cf3af748SRajkumar Manoharan ATH_SAMP_DBG(rs[i].rssi_ctl0), 1588cf3af748SRajkumar Manoharan ATH_SAMP_DBG(rs[i].rssi_ctl1), 1589cf3af748SRajkumar Manoharan ATH_SAMP_DBG(rs[i].rssi_ctl2), 1590cf3af748SRajkumar Manoharan ATH_SAMP_DBG(rs[i].rssi_ext0), 1591cf3af748SRajkumar Manoharan ATH_SAMP_DBG(rs[i].rssi_ext1), 1592cf3af748SRajkumar Manoharan ATH_SAMP_DBG(rs[i].rssi_ext2), 1593cf3af748SRajkumar Manoharan ATH_SAMP_DBG(rs[i].rssi), 1594cf3af748SRajkumar Manoharan ATH_SAMP_DBG(rs[i].is_mybeacon) ? 1595cf3af748SRajkumar Manoharan "True" : "False", 1596cf3af748SRajkumar Manoharan ATH_SAMP_DBG(rs[i].antenna), 1597cf3af748SRajkumar Manoharan ATH_SAMP_DBG(rs[i].rate), 1598cf3af748SRajkumar Manoharan jiffies_to_msecs(jiffies - 1599cf3af748SRajkumar Manoharan ATH_SAMP_DBG(rs[i].jiffies))); 1600cf3af748SRajkumar Manoharan } 1601cf3af748SRajkumar Manoharan } 1602cf3af748SRajkumar Manoharan 1603cf3af748SRajkumar Manoharan vfree(bb_mac_samp); 1604cf3af748SRajkumar Manoharan file->private_data = buf; 1605cf3af748SRajkumar Manoharan 1606cf3af748SRajkumar Manoharan return 0; 1607cf3af748SRajkumar Manoharan #undef ATH_SAMP_DBG 1608cf3af748SRajkumar Manoharan } 1609cf3af748SRajkumar Manoharan 1610cf3af748SRajkumar Manoharan static const struct file_operations fops_samps = { 1611cf3af748SRajkumar Manoharan .open = open_file_bb_mac_samps, 1612cf3af748SRajkumar Manoharan .read = ath9k_debugfs_read_buf, 1613cf3af748SRajkumar Manoharan .release = ath9k_debugfs_release_buf, 1614cf3af748SRajkumar Manoharan .owner = THIS_MODULE, 1615cf3af748SRajkumar Manoharan .llseek = default_llseek, 1616cf3af748SRajkumar Manoharan }; 1617cf3af748SRajkumar Manoharan 1618cf3af748SRajkumar Manoharan 16194d6b228dSLuis R. Rodriguez int ath9k_init_debug(struct ath_hw *ah) 1620203c4805SLuis R. Rodriguez { 1621bc974f4aSLuis R. Rodriguez struct ath_common *common = ath9k_hw_common(ah); 1622bc974f4aSLuis R. Rodriguez struct ath_softc *sc = (struct ath_softc *) common->priv; 16234d6b228dSLuis R. Rodriguez 1624eb272441SBen Greear sc->debug.debugfs_phy = debugfs_create_dir("ath9k", 1625eb272441SBen Greear sc->hw->wiphy->debugfsdir); 1626203c4805SLuis R. Rodriguez if (!sc->debug.debugfs_phy) 1627c8a72c00SFelix Fietkau return -ENOMEM; 1628203c4805SLuis R. Rodriguez 1629a830df07SFelix Fietkau #ifdef CONFIG_ATH_DEBUG 1630c70cab1aSFelix Fietkau debugfs_create_file("debug", S_IRUSR | S_IWUSR, sc->debug.debugfs_phy, 1631c70cab1aSFelix Fietkau sc, &fops_debug); 1632a830df07SFelix Fietkau #endif 1633*29942bc1SZefir Kurtisi 1634*29942bc1SZefir Kurtisi ath9k_dfs_init_debug(sc); 1635*29942bc1SZefir Kurtisi 1636c70cab1aSFelix Fietkau debugfs_create_file("dma", S_IRUSR, sc->debug.debugfs_phy, sc, 1637c70cab1aSFelix Fietkau &fops_dma); 1638c70cab1aSFelix Fietkau debugfs_create_file("interrupt", S_IRUSR, sc->debug.debugfs_phy, sc, 1639c70cab1aSFelix Fietkau &fops_interrupt); 1640c70cab1aSFelix Fietkau debugfs_create_file("wiphy", S_IRUSR | S_IWUSR, sc->debug.debugfs_phy, 1641c70cab1aSFelix Fietkau sc, &fops_wiphy); 1642c70cab1aSFelix Fietkau debugfs_create_file("xmit", S_IRUSR, sc->debug.debugfs_phy, sc, 1643c70cab1aSFelix Fietkau &fops_xmit); 1644c70cab1aSFelix Fietkau debugfs_create_file("stations", S_IRUSR, sc->debug.debugfs_phy, sc, 1645c70cab1aSFelix Fietkau &fops_stations); 1646c70cab1aSFelix Fietkau debugfs_create_file("misc", S_IRUSR, sc->debug.debugfs_phy, sc, 1647c70cab1aSFelix Fietkau &fops_misc); 1648c70cab1aSFelix Fietkau debugfs_create_file("recv", S_IRUSR, sc->debug.debugfs_phy, sc, 1649c70cab1aSFelix Fietkau &fops_recv); 1650c70cab1aSFelix Fietkau debugfs_create_file("rx_chainmask", S_IRUSR | S_IWUSR, 1651c70cab1aSFelix Fietkau sc->debug.debugfs_phy, sc, &fops_rx_chainmask); 1652c70cab1aSFelix Fietkau debugfs_create_file("tx_chainmask", S_IRUSR | S_IWUSR, 1653c70cab1aSFelix Fietkau sc->debug.debugfs_phy, sc, &fops_tx_chainmask); 165405c0be2fSMohammed Shafi Shajakhan debugfs_create_file("disable_ani", S_IRUSR | S_IWUSR, 165505c0be2fSMohammed Shafi Shajakhan sc->debug.debugfs_phy, sc, &fops_disable_ani); 1656c70cab1aSFelix Fietkau debugfs_create_file("regidx", S_IRUSR | S_IWUSR, sc->debug.debugfs_phy, 1657c70cab1aSFelix Fietkau sc, &fops_regidx); 1658c70cab1aSFelix Fietkau debugfs_create_file("regval", S_IRUSR | S_IWUSR, sc->debug.debugfs_phy, 1659c70cab1aSFelix Fietkau sc, &fops_regval); 1660c70cab1aSFelix Fietkau debugfs_create_bool("ignore_extcca", S_IRUSR | S_IWUSR, 1661c70cab1aSFelix Fietkau sc->debug.debugfs_phy, 1662c70cab1aSFelix Fietkau &ah->config.cwm_ignore_extcca); 1663c70cab1aSFelix Fietkau debugfs_create_file("regdump", S_IRUSR, sc->debug.debugfs_phy, sc, 1664c70cab1aSFelix Fietkau &fops_regdump); 1665d069a46bSRajkumar Manoharan debugfs_create_file("dump_nfcal", S_IRUSR, sc->debug.debugfs_phy, sc, 1666d069a46bSRajkumar Manoharan &fops_dump_nfcal); 1667580f010fSRajkumar Manoharan debugfs_create_file("base_eeprom", S_IRUSR, sc->debug.debugfs_phy, sc, 1668580f010fSRajkumar Manoharan &fops_base_eeprom); 16693f4c4bddSRajkumar Manoharan debugfs_create_file("modal_eeprom", S_IRUSR, sc->debug.debugfs_phy, sc, 16703f4c4bddSRajkumar Manoharan &fops_modal_eeprom); 1671cf3af748SRajkumar Manoharan debugfs_create_file("samples", S_IRUSR, sc->debug.debugfs_phy, sc, 1672cf3af748SRajkumar Manoharan &fops_samps); 1673582d0064SVasanthakumar Thiagarajan 1674691680b8SFelix Fietkau debugfs_create_u32("gpio_mask", S_IRUSR | S_IWUSR, 1675691680b8SFelix Fietkau sc->debug.debugfs_phy, &sc->sc_ah->gpio_mask); 1676691680b8SFelix Fietkau 1677691680b8SFelix Fietkau debugfs_create_u32("gpio_val", S_IRUSR | S_IWUSR, 1678691680b8SFelix Fietkau sc->debug.debugfs_phy, &sc->sc_ah->gpio_val); 1679691680b8SFelix Fietkau 16809bff0bc4SFelix Fietkau sc->debug.regidx = 0; 1681cf3af748SRajkumar Manoharan memset(&sc->debug.bb_mac_samp, 0, sizeof(sc->debug.bb_mac_samp)); 1682cf3af748SRajkumar Manoharan sc->debug.sampidx = 0; 1683cf3af748SRajkumar Manoharan sc->debug.tsidx = 0; 1684cf3af748SRajkumar Manoharan sc->debug.rsidx = 0; 1685203c4805SLuis R. Rodriguez return 0; 1686203c4805SLuis R. Rodriguez } 1687