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> 19203c4805SLuis R. Rodriguez #include <asm/unaligned.h> 20203c4805SLuis R. Rodriguez 21203c4805SLuis R. Rodriguez #include "ath9k.h" 22203c4805SLuis R. Rodriguez 23475a6e4dSLuis R. Rodriguez #define REG_WRITE_D(_ah, _reg, _val) \ 24475a6e4dSLuis R. Rodriguez ath9k_hw_common(_ah)->ops->write((_ah), (_val), (_reg)) 25475a6e4dSLuis R. Rodriguez #define REG_READ_D(_ah, _reg) \ 26475a6e4dSLuis R. Rodriguez ath9k_hw_common(_ah)->ops->read((_ah), (_reg)) 27475a6e4dSLuis R. Rodriguez 28203c4805SLuis R. Rodriguez static int ath9k_debugfs_open(struct inode *inode, struct file *file) 29203c4805SLuis R. Rodriguez { 30203c4805SLuis R. Rodriguez file->private_data = inode->i_private; 31203c4805SLuis R. Rodriguez return 0; 32203c4805SLuis R. Rodriguez } 33203c4805SLuis R. Rodriguez 34582d0064SVasanthakumar Thiagarajan static ssize_t ath9k_debugfs_read_buf(struct file *file, char __user *user_buf, 35582d0064SVasanthakumar Thiagarajan size_t count, loff_t *ppos) 36582d0064SVasanthakumar Thiagarajan { 37582d0064SVasanthakumar Thiagarajan u8 *buf = file->private_data; 38582d0064SVasanthakumar Thiagarajan return simple_read_from_buffer(user_buf, count, ppos, buf, strlen(buf)); 39582d0064SVasanthakumar Thiagarajan } 40582d0064SVasanthakumar Thiagarajan 41582d0064SVasanthakumar Thiagarajan static int ath9k_debugfs_release_buf(struct inode *inode, struct file *file) 42582d0064SVasanthakumar Thiagarajan { 43582d0064SVasanthakumar Thiagarajan vfree(file->private_data); 44582d0064SVasanthakumar Thiagarajan return 0; 45582d0064SVasanthakumar Thiagarajan } 46582d0064SVasanthakumar Thiagarajan 47a830df07SFelix Fietkau #ifdef CONFIG_ATH_DEBUG 48a830df07SFelix Fietkau 492493928eSJeff Hansen static ssize_t read_file_debug(struct file *file, char __user *user_buf, 502493928eSJeff Hansen size_t count, loff_t *ppos) 512493928eSJeff Hansen { 522493928eSJeff Hansen struct ath_softc *sc = file->private_data; 53c46917bbSLuis R. Rodriguez struct ath_common *common = ath9k_hw_common(sc->sc_ah); 542493928eSJeff Hansen char buf[32]; 55581f725cSVasanthakumar Thiagarajan unsigned int len; 56581f725cSVasanthakumar Thiagarajan 572b87f3aaSDan Carpenter len = sprintf(buf, "0x%08x\n", common->debug_mask); 582493928eSJeff Hansen return simple_read_from_buffer(user_buf, count, ppos, buf, len); 592493928eSJeff Hansen } 602493928eSJeff Hansen 612493928eSJeff Hansen static ssize_t write_file_debug(struct file *file, const char __user *user_buf, 622493928eSJeff Hansen size_t count, loff_t *ppos) 632493928eSJeff Hansen { 642493928eSJeff Hansen struct ath_softc *sc = file->private_data; 65c46917bbSLuis R. Rodriguez struct ath_common *common = ath9k_hw_common(sc->sc_ah); 662493928eSJeff Hansen unsigned long mask; 672493928eSJeff Hansen char buf[32]; 68581f725cSVasanthakumar Thiagarajan ssize_t len; 69581f725cSVasanthakumar Thiagarajan 70581f725cSVasanthakumar Thiagarajan len = min(count, sizeof(buf) - 1); 71581f725cSVasanthakumar Thiagarajan if (copy_from_user(buf, user_buf, len)) 7204236066SDan Carpenter return -EFAULT; 73581f725cSVasanthakumar Thiagarajan 74581f725cSVasanthakumar Thiagarajan buf[len] = '\0'; 75581f725cSVasanthakumar Thiagarajan if (strict_strtoul(buf, 0, &mask)) 76581f725cSVasanthakumar Thiagarajan return -EINVAL; 77581f725cSVasanthakumar Thiagarajan 78c46917bbSLuis R. Rodriguez common->debug_mask = mask; 792493928eSJeff Hansen return count; 802493928eSJeff Hansen } 812493928eSJeff Hansen 822493928eSJeff Hansen static const struct file_operations fops_debug = { 832493928eSJeff Hansen .read = read_file_debug, 842493928eSJeff Hansen .write = write_file_debug, 852493928eSJeff Hansen .open = ath9k_debugfs_open, 866038f373SArnd Bergmann .owner = THIS_MODULE, 876038f373SArnd Bergmann .llseek = default_llseek, 882493928eSJeff Hansen }; 892493928eSJeff Hansen 90a830df07SFelix Fietkau #endif 91a830df07SFelix Fietkau 92991a0987SPavel Roskin #define DMA_BUF_LEN 1024 93991a0987SPavel Roskin 9415340694SFelix Fietkau static ssize_t read_file_tx_chainmask(struct file *file, char __user *user_buf, 9515340694SFelix Fietkau size_t count, loff_t *ppos) 9615340694SFelix Fietkau { 9715340694SFelix Fietkau struct ath_softc *sc = file->private_data; 9882b2d334SFelix Fietkau struct ath_hw *ah = sc->sc_ah; 9915340694SFelix Fietkau char buf[32]; 10015340694SFelix Fietkau unsigned int len; 10115340694SFelix Fietkau 10282b2d334SFelix Fietkau len = sprintf(buf, "0x%08x\n", ah->txchainmask); 10315340694SFelix Fietkau return simple_read_from_buffer(user_buf, count, ppos, buf, len); 10415340694SFelix Fietkau } 10515340694SFelix Fietkau 10615340694SFelix Fietkau static ssize_t write_file_tx_chainmask(struct file *file, const char __user *user_buf, 10715340694SFelix Fietkau size_t count, loff_t *ppos) 10815340694SFelix Fietkau { 10915340694SFelix Fietkau struct ath_softc *sc = file->private_data; 11082b2d334SFelix Fietkau struct ath_hw *ah = sc->sc_ah; 11115340694SFelix Fietkau unsigned long mask; 11215340694SFelix Fietkau char buf[32]; 11315340694SFelix Fietkau ssize_t len; 11415340694SFelix Fietkau 11515340694SFelix Fietkau len = min(count, sizeof(buf) - 1); 11615340694SFelix Fietkau if (copy_from_user(buf, user_buf, len)) 11704236066SDan Carpenter return -EFAULT; 11815340694SFelix Fietkau 11915340694SFelix Fietkau buf[len] = '\0'; 12015340694SFelix Fietkau if (strict_strtoul(buf, 0, &mask)) 12115340694SFelix Fietkau return -EINVAL; 12215340694SFelix Fietkau 12382b2d334SFelix Fietkau ah->txchainmask = mask; 12482b2d334SFelix Fietkau ah->caps.tx_chainmask = mask; 12515340694SFelix Fietkau return count; 12615340694SFelix Fietkau } 12715340694SFelix Fietkau 12815340694SFelix Fietkau static const struct file_operations fops_tx_chainmask = { 12915340694SFelix Fietkau .read = read_file_tx_chainmask, 13015340694SFelix Fietkau .write = write_file_tx_chainmask, 13115340694SFelix Fietkau .open = ath9k_debugfs_open, 1326038f373SArnd Bergmann .owner = THIS_MODULE, 1336038f373SArnd Bergmann .llseek = default_llseek, 13415340694SFelix Fietkau }; 13515340694SFelix Fietkau 13615340694SFelix Fietkau 13715340694SFelix Fietkau static ssize_t read_file_rx_chainmask(struct file *file, char __user *user_buf, 13815340694SFelix Fietkau size_t count, loff_t *ppos) 13915340694SFelix Fietkau { 14015340694SFelix Fietkau struct ath_softc *sc = file->private_data; 14182b2d334SFelix Fietkau struct ath_hw *ah = sc->sc_ah; 14215340694SFelix Fietkau char buf[32]; 14315340694SFelix Fietkau unsigned int len; 14415340694SFelix Fietkau 14582b2d334SFelix Fietkau len = sprintf(buf, "0x%08x\n", ah->rxchainmask); 14615340694SFelix Fietkau return simple_read_from_buffer(user_buf, count, ppos, buf, len); 14715340694SFelix Fietkau } 14815340694SFelix Fietkau 14915340694SFelix Fietkau static ssize_t write_file_rx_chainmask(struct file *file, const char __user *user_buf, 15015340694SFelix Fietkau size_t count, loff_t *ppos) 15115340694SFelix Fietkau { 15215340694SFelix Fietkau struct ath_softc *sc = file->private_data; 15382b2d334SFelix Fietkau struct ath_hw *ah = sc->sc_ah; 15415340694SFelix Fietkau unsigned long mask; 15515340694SFelix Fietkau char buf[32]; 15615340694SFelix Fietkau ssize_t len; 15715340694SFelix Fietkau 15815340694SFelix Fietkau len = min(count, sizeof(buf) - 1); 15915340694SFelix Fietkau if (copy_from_user(buf, user_buf, len)) 16004236066SDan Carpenter return -EFAULT; 16115340694SFelix Fietkau 16215340694SFelix Fietkau buf[len] = '\0'; 16315340694SFelix Fietkau if (strict_strtoul(buf, 0, &mask)) 16415340694SFelix Fietkau return -EINVAL; 16515340694SFelix Fietkau 16682b2d334SFelix Fietkau ah->rxchainmask = mask; 16782b2d334SFelix Fietkau ah->caps.rx_chainmask = mask; 16815340694SFelix Fietkau return count; 16915340694SFelix Fietkau } 17015340694SFelix Fietkau 17115340694SFelix Fietkau static const struct file_operations fops_rx_chainmask = { 17215340694SFelix Fietkau .read = read_file_rx_chainmask, 17315340694SFelix Fietkau .write = write_file_rx_chainmask, 17415340694SFelix Fietkau .open = ath9k_debugfs_open, 1756038f373SArnd Bergmann .owner = THIS_MODULE, 1766038f373SArnd Bergmann .llseek = default_llseek, 17715340694SFelix Fietkau }; 17815340694SFelix Fietkau 17905c0be2fSMohammed Shafi Shajakhan static ssize_t read_file_disable_ani(struct file *file, char __user *user_buf, 18005c0be2fSMohammed Shafi Shajakhan size_t count, loff_t *ppos) 18105c0be2fSMohammed Shafi Shajakhan { 18205c0be2fSMohammed Shafi Shajakhan struct ath_softc *sc = file->private_data; 18305c0be2fSMohammed Shafi Shajakhan struct ath_common *common = ath9k_hw_common(sc->sc_ah); 18405c0be2fSMohammed Shafi Shajakhan char buf[32]; 18505c0be2fSMohammed Shafi Shajakhan unsigned int len; 18605c0be2fSMohammed Shafi Shajakhan 18705c0be2fSMohammed Shafi Shajakhan len = sprintf(buf, "%d\n", common->disable_ani); 18805c0be2fSMohammed Shafi Shajakhan return simple_read_from_buffer(user_buf, count, ppos, buf, len); 18905c0be2fSMohammed Shafi Shajakhan } 19005c0be2fSMohammed Shafi Shajakhan 19105c0be2fSMohammed Shafi Shajakhan static ssize_t write_file_disable_ani(struct file *file, 19205c0be2fSMohammed Shafi Shajakhan const char __user *user_buf, 19305c0be2fSMohammed Shafi Shajakhan size_t count, loff_t *ppos) 19405c0be2fSMohammed Shafi Shajakhan { 19505c0be2fSMohammed Shafi Shajakhan struct ath_softc *sc = file->private_data; 19605c0be2fSMohammed Shafi Shajakhan struct ath_common *common = ath9k_hw_common(sc->sc_ah); 19705c0be2fSMohammed Shafi Shajakhan unsigned long disable_ani; 19805c0be2fSMohammed Shafi Shajakhan char buf[32]; 19905c0be2fSMohammed Shafi Shajakhan ssize_t len; 20005c0be2fSMohammed Shafi Shajakhan 20105c0be2fSMohammed Shafi Shajakhan len = min(count, sizeof(buf) - 1); 20205c0be2fSMohammed Shafi Shajakhan if (copy_from_user(buf, user_buf, len)) 20305c0be2fSMohammed Shafi Shajakhan return -EFAULT; 20405c0be2fSMohammed Shafi Shajakhan 20505c0be2fSMohammed Shafi Shajakhan buf[len] = '\0'; 20605c0be2fSMohammed Shafi Shajakhan if (strict_strtoul(buf, 0, &disable_ani)) 20705c0be2fSMohammed Shafi Shajakhan return -EINVAL; 20805c0be2fSMohammed Shafi Shajakhan 20905c0be2fSMohammed Shafi Shajakhan common->disable_ani = !!disable_ani; 21005c0be2fSMohammed Shafi Shajakhan 21105c0be2fSMohammed Shafi Shajakhan if (disable_ani) { 21205c0be2fSMohammed Shafi Shajakhan sc->sc_flags &= ~SC_OP_ANI_RUN; 21305c0be2fSMohammed Shafi Shajakhan del_timer_sync(&common->ani.timer); 21405c0be2fSMohammed Shafi Shajakhan } else { 21505c0be2fSMohammed Shafi Shajakhan sc->sc_flags |= SC_OP_ANI_RUN; 21605c0be2fSMohammed Shafi Shajakhan ath_start_ani(common); 21705c0be2fSMohammed Shafi Shajakhan } 21805c0be2fSMohammed Shafi Shajakhan 21905c0be2fSMohammed Shafi Shajakhan return count; 22005c0be2fSMohammed Shafi Shajakhan } 22105c0be2fSMohammed Shafi Shajakhan 22205c0be2fSMohammed Shafi Shajakhan static const struct file_operations fops_disable_ani = { 22305c0be2fSMohammed Shafi Shajakhan .read = read_file_disable_ani, 22405c0be2fSMohammed Shafi Shajakhan .write = write_file_disable_ani, 22505c0be2fSMohammed Shafi Shajakhan .open = ath9k_debugfs_open, 22605c0be2fSMohammed Shafi Shajakhan .owner = THIS_MODULE, 22705c0be2fSMohammed Shafi Shajakhan .llseek = default_llseek, 22805c0be2fSMohammed Shafi Shajakhan }; 22915340694SFelix Fietkau 230203c4805SLuis R. Rodriguez static ssize_t read_file_dma(struct file *file, char __user *user_buf, 231203c4805SLuis R. Rodriguez size_t count, loff_t *ppos) 232203c4805SLuis R. Rodriguez { 233203c4805SLuis R. Rodriguez struct ath_softc *sc = file->private_data; 234203c4805SLuis R. Rodriguez struct ath_hw *ah = sc->sc_ah; 235991a0987SPavel Roskin char *buf; 236991a0987SPavel Roskin int retval; 237203c4805SLuis R. Rodriguez unsigned int len = 0; 238203c4805SLuis R. Rodriguez u32 val[ATH9K_NUM_DMA_DEBUG_REGS]; 239203c4805SLuis R. Rodriguez int i, qcuOffset = 0, dcuOffset = 0; 240203c4805SLuis R. Rodriguez u32 *qcuBase = &val[0], *dcuBase = &val[4]; 241203c4805SLuis R. Rodriguez 242991a0987SPavel Roskin buf = kmalloc(DMA_BUF_LEN, GFP_KERNEL); 243991a0987SPavel Roskin if (!buf) 24404236066SDan Carpenter return -ENOMEM; 245991a0987SPavel Roskin 2467cf4a2e7SSujith ath9k_ps_wakeup(sc); 2477cf4a2e7SSujith 248475a6e4dSLuis R. Rodriguez REG_WRITE_D(ah, AR_MACMISC, 249203c4805SLuis R. Rodriguez ((AR_MACMISC_DMA_OBS_LINE_8 << AR_MACMISC_DMA_OBS_S) | 250203c4805SLuis R. Rodriguez (AR_MACMISC_MISC_OBS_BUS_1 << 251203c4805SLuis R. Rodriguez AR_MACMISC_MISC_OBS_BUS_MSB_S))); 252203c4805SLuis R. Rodriguez 253991a0987SPavel Roskin len += snprintf(buf + len, DMA_BUF_LEN - len, 254203c4805SLuis R. Rodriguez "Raw DMA Debug values:\n"); 255203c4805SLuis R. Rodriguez 256203c4805SLuis R. Rodriguez for (i = 0; i < ATH9K_NUM_DMA_DEBUG_REGS; i++) { 257203c4805SLuis R. Rodriguez if (i % 4 == 0) 258991a0987SPavel Roskin len += snprintf(buf + len, DMA_BUF_LEN - len, "\n"); 259203c4805SLuis R. Rodriguez 260475a6e4dSLuis R. Rodriguez val[i] = REG_READ_D(ah, AR_DMADBG_0 + (i * sizeof(u32))); 261991a0987SPavel Roskin len += snprintf(buf + len, DMA_BUF_LEN - len, "%d: %08x ", 262203c4805SLuis R. Rodriguez i, val[i]); 263203c4805SLuis R. Rodriguez } 264203c4805SLuis R. Rodriguez 265991a0987SPavel Roskin len += snprintf(buf + len, DMA_BUF_LEN - len, "\n\n"); 266991a0987SPavel Roskin len += snprintf(buf + len, DMA_BUF_LEN - len, 267203c4805SLuis R. Rodriguez "Num QCU: chain_st fsp_ok fsp_st DCU: chain_st\n"); 268203c4805SLuis R. Rodriguez 269203c4805SLuis R. Rodriguez for (i = 0; i < ATH9K_NUM_QUEUES; i++, qcuOffset += 4, dcuOffset += 5) { 270203c4805SLuis R. Rodriguez if (i == 8) { 271203c4805SLuis R. Rodriguez qcuOffset = 0; 272203c4805SLuis R. Rodriguez qcuBase++; 273203c4805SLuis R. Rodriguez } 274203c4805SLuis R. Rodriguez 275203c4805SLuis R. Rodriguez if (i == 6) { 276203c4805SLuis R. Rodriguez dcuOffset = 0; 277203c4805SLuis R. Rodriguez dcuBase++; 278203c4805SLuis R. Rodriguez } 279203c4805SLuis R. Rodriguez 280991a0987SPavel Roskin len += snprintf(buf + len, DMA_BUF_LEN - len, 281203c4805SLuis R. Rodriguez "%2d %2x %1x %2x %2x\n", 282203c4805SLuis R. Rodriguez i, (*qcuBase & (0x7 << qcuOffset)) >> qcuOffset, 283203c4805SLuis R. Rodriguez (*qcuBase & (0x8 << qcuOffset)) >> (qcuOffset + 3), 284203c4805SLuis R. Rodriguez val[2] & (0x7 << (i * 3)) >> (i * 3), 285203c4805SLuis R. Rodriguez (*dcuBase & (0x1f << dcuOffset)) >> dcuOffset); 286203c4805SLuis R. Rodriguez } 287203c4805SLuis R. Rodriguez 288991a0987SPavel Roskin len += snprintf(buf + len, DMA_BUF_LEN - len, "\n"); 289203c4805SLuis R. Rodriguez 290991a0987SPavel Roskin len += snprintf(buf + len, DMA_BUF_LEN - len, 291203c4805SLuis R. Rodriguez "qcu_stitch state: %2x qcu_fetch state: %2x\n", 292203c4805SLuis R. Rodriguez (val[3] & 0x003c0000) >> 18, (val[3] & 0x03c00000) >> 22); 293991a0987SPavel Roskin len += snprintf(buf + len, DMA_BUF_LEN - len, 294203c4805SLuis R. Rodriguez "qcu_complete state: %2x dcu_complete state: %2x\n", 295203c4805SLuis R. Rodriguez (val[3] & 0x1c000000) >> 26, (val[6] & 0x3)); 296991a0987SPavel Roskin len += snprintf(buf + len, DMA_BUF_LEN - len, 297203c4805SLuis R. Rodriguez "dcu_arb state: %2x dcu_fp state: %2x\n", 298203c4805SLuis R. Rodriguez (val[5] & 0x06000000) >> 25, (val[5] & 0x38000000) >> 27); 299991a0987SPavel Roskin len += snprintf(buf + len, DMA_BUF_LEN - len, 300203c4805SLuis R. Rodriguez "chan_idle_dur: %3d chan_idle_dur_valid: %1d\n", 301203c4805SLuis R. Rodriguez (val[6] & 0x000003fc) >> 2, (val[6] & 0x00000400) >> 10); 302991a0987SPavel Roskin len += snprintf(buf + len, DMA_BUF_LEN - len, 303203c4805SLuis R. Rodriguez "txfifo_valid_0: %1d txfifo_valid_1: %1d\n", 304203c4805SLuis R. Rodriguez (val[6] & 0x00000800) >> 11, (val[6] & 0x00001000) >> 12); 305991a0987SPavel Roskin len += snprintf(buf + len, DMA_BUF_LEN - len, 306203c4805SLuis R. Rodriguez "txfifo_dcu_num_0: %2d txfifo_dcu_num_1: %2d\n", 307203c4805SLuis R. Rodriguez (val[6] & 0x0001e000) >> 13, (val[6] & 0x001e0000) >> 17); 308203c4805SLuis R. Rodriguez 309991a0987SPavel Roskin len += snprintf(buf + len, DMA_BUF_LEN - len, "pcu observe: 0x%x\n", 310475a6e4dSLuis R. Rodriguez REG_READ_D(ah, AR_OBS_BUS_1)); 311991a0987SPavel Roskin len += snprintf(buf + len, DMA_BUF_LEN - len, 312475a6e4dSLuis R. Rodriguez "AR_CR: 0x%x\n", REG_READ_D(ah, AR_CR)); 313203c4805SLuis R. Rodriguez 3147cf4a2e7SSujith ath9k_ps_restore(sc); 3157cf4a2e7SSujith 3162b87f3aaSDan Carpenter if (len > DMA_BUF_LEN) 3172b87f3aaSDan Carpenter len = DMA_BUF_LEN; 3182b87f3aaSDan Carpenter 319991a0987SPavel Roskin retval = simple_read_from_buffer(user_buf, count, ppos, buf, len); 320991a0987SPavel Roskin kfree(buf); 321991a0987SPavel Roskin return retval; 322203c4805SLuis R. Rodriguez } 323203c4805SLuis R. Rodriguez 324203c4805SLuis R. Rodriguez static const struct file_operations fops_dma = { 325203c4805SLuis R. Rodriguez .read = read_file_dma, 326203c4805SLuis R. Rodriguez .open = ath9k_debugfs_open, 3276038f373SArnd Bergmann .owner = THIS_MODULE, 3286038f373SArnd Bergmann .llseek = default_llseek, 329203c4805SLuis R. Rodriguez }; 330203c4805SLuis R. Rodriguez 331203c4805SLuis R. Rodriguez 332203c4805SLuis R. Rodriguez void ath_debug_stat_interrupt(struct ath_softc *sc, enum ath9k_int status) 333203c4805SLuis R. Rodriguez { 334203c4805SLuis R. Rodriguez if (status) 335203c4805SLuis R. Rodriguez sc->debug.stats.istats.total++; 336a9616f41SLuis R. Rodriguez if (sc->sc_ah->caps.hw_caps & ATH9K_HW_CAP_EDMA) { 337a9616f41SLuis R. Rodriguez if (status & ATH9K_INT_RXLP) 338a9616f41SLuis R. Rodriguez sc->debug.stats.istats.rxlp++; 339a9616f41SLuis R. Rodriguez if (status & ATH9K_INT_RXHP) 340a9616f41SLuis R. Rodriguez sc->debug.stats.istats.rxhp++; 34108578b8fSLuis R. Rodriguez if (status & ATH9K_INT_BB_WATCHDOG) 34208578b8fSLuis R. Rodriguez sc->debug.stats.istats.bb_watchdog++; 343a9616f41SLuis R. Rodriguez } else { 344203c4805SLuis R. Rodriguez if (status & ATH9K_INT_RX) 345203c4805SLuis R. Rodriguez sc->debug.stats.istats.rxok++; 346a9616f41SLuis R. Rodriguez } 347203c4805SLuis R. Rodriguez if (status & ATH9K_INT_RXEOL) 348203c4805SLuis R. Rodriguez sc->debug.stats.istats.rxeol++; 349203c4805SLuis R. Rodriguez if (status & ATH9K_INT_RXORN) 350203c4805SLuis R. Rodriguez sc->debug.stats.istats.rxorn++; 351203c4805SLuis R. Rodriguez if (status & ATH9K_INT_TX) 352203c4805SLuis R. Rodriguez sc->debug.stats.istats.txok++; 353203c4805SLuis R. Rodriguez if (status & ATH9K_INT_TXURN) 354203c4805SLuis R. Rodriguez sc->debug.stats.istats.txurn++; 355203c4805SLuis R. Rodriguez if (status & ATH9K_INT_MIB) 356203c4805SLuis R. Rodriguez sc->debug.stats.istats.mib++; 357203c4805SLuis R. Rodriguez if (status & ATH9K_INT_RXPHY) 358203c4805SLuis R. Rodriguez sc->debug.stats.istats.rxphyerr++; 359203c4805SLuis R. Rodriguez if (status & ATH9K_INT_RXKCM) 360203c4805SLuis R. Rodriguez sc->debug.stats.istats.rx_keycache_miss++; 361203c4805SLuis R. Rodriguez if (status & ATH9K_INT_SWBA) 362203c4805SLuis R. Rodriguez sc->debug.stats.istats.swba++; 363203c4805SLuis R. Rodriguez if (status & ATH9K_INT_BMISS) 364203c4805SLuis R. Rodriguez sc->debug.stats.istats.bmiss++; 365203c4805SLuis R. Rodriguez if (status & ATH9K_INT_BNR) 366203c4805SLuis R. Rodriguez sc->debug.stats.istats.bnr++; 367203c4805SLuis R. Rodriguez if (status & ATH9K_INT_CST) 368203c4805SLuis R. Rodriguez sc->debug.stats.istats.cst++; 369203c4805SLuis R. Rodriguez if (status & ATH9K_INT_GTT) 370203c4805SLuis R. Rodriguez sc->debug.stats.istats.gtt++; 371203c4805SLuis R. Rodriguez if (status & ATH9K_INT_TIM) 372203c4805SLuis R. Rodriguez sc->debug.stats.istats.tim++; 373203c4805SLuis R. Rodriguez if (status & ATH9K_INT_CABEND) 374203c4805SLuis R. Rodriguez sc->debug.stats.istats.cabend++; 375203c4805SLuis R. Rodriguez if (status & ATH9K_INT_DTIMSYNC) 376203c4805SLuis R. Rodriguez sc->debug.stats.istats.dtimsync++; 377203c4805SLuis R. Rodriguez if (status & ATH9K_INT_DTIM) 378203c4805SLuis R. Rodriguez sc->debug.stats.istats.dtim++; 3796dde1aabSMohammed Shafi Shajakhan if (status & ATH9K_INT_TSFOOR) 3806dde1aabSMohammed Shafi Shajakhan sc->debug.stats.istats.tsfoor++; 381203c4805SLuis R. Rodriguez } 382203c4805SLuis R. Rodriguez 383203c4805SLuis R. Rodriguez static ssize_t read_file_interrupt(struct file *file, char __user *user_buf, 384203c4805SLuis R. Rodriguez size_t count, loff_t *ppos) 385203c4805SLuis R. Rodriguez { 386203c4805SLuis R. Rodriguez struct ath_softc *sc = file->private_data; 387203c4805SLuis R. Rodriguez char buf[512]; 388203c4805SLuis R. Rodriguez unsigned int len = 0; 389203c4805SLuis R. Rodriguez 390a9616f41SLuis R. Rodriguez if (sc->sc_ah->caps.hw_caps & ATH9K_HW_CAP_EDMA) { 391a9616f41SLuis R. Rodriguez len += snprintf(buf + len, sizeof(buf) - len, 392a9616f41SLuis R. Rodriguez "%8s: %10u\n", "RXLP", sc->debug.stats.istats.rxlp); 393a9616f41SLuis R. Rodriguez len += snprintf(buf + len, sizeof(buf) - len, 394a9616f41SLuis R. Rodriguez "%8s: %10u\n", "RXHP", sc->debug.stats.istats.rxhp); 39508578b8fSLuis R. Rodriguez len += snprintf(buf + len, sizeof(buf) - len, 39608578b8fSLuis R. Rodriguez "%8s: %10u\n", "WATCHDOG", 39708578b8fSLuis R. Rodriguez sc->debug.stats.istats.bb_watchdog); 398a9616f41SLuis R. Rodriguez } else { 399203c4805SLuis R. Rodriguez len += snprintf(buf + len, sizeof(buf) - len, 400203c4805SLuis R. Rodriguez "%8s: %10u\n", "RX", sc->debug.stats.istats.rxok); 401a9616f41SLuis R. Rodriguez } 402203c4805SLuis R. Rodriguez len += snprintf(buf + len, sizeof(buf) - len, 403203c4805SLuis R. Rodriguez "%8s: %10u\n", "RXEOL", sc->debug.stats.istats.rxeol); 404203c4805SLuis R. Rodriguez len += snprintf(buf + len, sizeof(buf) - len, 405203c4805SLuis R. Rodriguez "%8s: %10u\n", "RXORN", sc->debug.stats.istats.rxorn); 406203c4805SLuis R. Rodriguez len += snprintf(buf + len, sizeof(buf) - len, 407203c4805SLuis R. Rodriguez "%8s: %10u\n", "TX", sc->debug.stats.istats.txok); 408203c4805SLuis R. Rodriguez len += snprintf(buf + len, sizeof(buf) - len, 409203c4805SLuis R. Rodriguez "%8s: %10u\n", "TXURN", sc->debug.stats.istats.txurn); 410203c4805SLuis R. Rodriguez len += snprintf(buf + len, sizeof(buf) - len, 411203c4805SLuis R. Rodriguez "%8s: %10u\n", "MIB", sc->debug.stats.istats.mib); 412203c4805SLuis R. Rodriguez len += snprintf(buf + len, sizeof(buf) - len, 413203c4805SLuis R. Rodriguez "%8s: %10u\n", "RXPHY", sc->debug.stats.istats.rxphyerr); 414203c4805SLuis R. Rodriguez len += snprintf(buf + len, sizeof(buf) - len, 415203c4805SLuis R. Rodriguez "%8s: %10u\n", "RXKCM", sc->debug.stats.istats.rx_keycache_miss); 416203c4805SLuis R. Rodriguez len += snprintf(buf + len, sizeof(buf) - len, 417203c4805SLuis R. Rodriguez "%8s: %10u\n", "SWBA", sc->debug.stats.istats.swba); 418203c4805SLuis R. Rodriguez len += snprintf(buf + len, sizeof(buf) - len, 419203c4805SLuis R. Rodriguez "%8s: %10u\n", "BMISS", sc->debug.stats.istats.bmiss); 420203c4805SLuis R. Rodriguez len += snprintf(buf + len, sizeof(buf) - len, 421203c4805SLuis R. Rodriguez "%8s: %10u\n", "BNR", sc->debug.stats.istats.bnr); 422203c4805SLuis R. Rodriguez len += snprintf(buf + len, sizeof(buf) - len, 423203c4805SLuis R. Rodriguez "%8s: %10u\n", "CST", sc->debug.stats.istats.cst); 424203c4805SLuis R. Rodriguez len += snprintf(buf + len, sizeof(buf) - len, 425203c4805SLuis R. Rodriguez "%8s: %10u\n", "GTT", sc->debug.stats.istats.gtt); 426203c4805SLuis R. Rodriguez len += snprintf(buf + len, sizeof(buf) - len, 427203c4805SLuis R. Rodriguez "%8s: %10u\n", "TIM", sc->debug.stats.istats.tim); 428203c4805SLuis R. Rodriguez len += snprintf(buf + len, sizeof(buf) - len, 429203c4805SLuis R. Rodriguez "%8s: %10u\n", "CABEND", sc->debug.stats.istats.cabend); 430203c4805SLuis R. Rodriguez len += snprintf(buf + len, sizeof(buf) - len, 431203c4805SLuis R. Rodriguez "%8s: %10u\n", "DTIMSYNC", sc->debug.stats.istats.dtimsync); 432203c4805SLuis R. Rodriguez len += snprintf(buf + len, sizeof(buf) - len, 433203c4805SLuis R. Rodriguez "%8s: %10u\n", "DTIM", sc->debug.stats.istats.dtim); 434203c4805SLuis R. Rodriguez len += snprintf(buf + len, sizeof(buf) - len, 4356dde1aabSMohammed Shafi Shajakhan "%8s: %10u\n", "TSFOOR", sc->debug.stats.istats.tsfoor); 4366dde1aabSMohammed Shafi Shajakhan len += snprintf(buf + len, sizeof(buf) - len, 437203c4805SLuis R. Rodriguez "%8s: %10u\n", "TOTAL", sc->debug.stats.istats.total); 438203c4805SLuis R. Rodriguez 4396dde1aabSMohammed Shafi Shajakhan 4402b87f3aaSDan Carpenter if (len > sizeof(buf)) 4412b87f3aaSDan Carpenter len = sizeof(buf); 4422b87f3aaSDan Carpenter 443203c4805SLuis R. Rodriguez return simple_read_from_buffer(user_buf, count, ppos, buf, len); 444203c4805SLuis R. Rodriguez } 445203c4805SLuis R. Rodriguez 446203c4805SLuis R. Rodriguez static const struct file_operations fops_interrupt = { 447203c4805SLuis R. Rodriguez .read = read_file_interrupt, 448203c4805SLuis R. Rodriguez .open = ath9k_debugfs_open, 4496038f373SArnd Bergmann .owner = THIS_MODULE, 4506038f373SArnd Bergmann .llseek = default_llseek, 451203c4805SLuis R. Rodriguez }; 452203c4805SLuis R. Rodriguez 4534e6975f7SBen Greear static const char *channel_type_str(enum nl80211_channel_type t) 4544e6975f7SBen Greear { 4554e6975f7SBen Greear switch (t) { 4564e6975f7SBen Greear case NL80211_CHAN_NO_HT: 4574e6975f7SBen Greear return "no ht"; 4584e6975f7SBen Greear case NL80211_CHAN_HT20: 4594e6975f7SBen Greear return "ht20"; 4604e6975f7SBen Greear case NL80211_CHAN_HT40MINUS: 4614e6975f7SBen Greear return "ht40-"; 4624e6975f7SBen Greear case NL80211_CHAN_HT40PLUS: 4634e6975f7SBen Greear return "ht40+"; 4644e6975f7SBen Greear default: 4654e6975f7SBen Greear return "???"; 4664e6975f7SBen Greear } 4674e6975f7SBen Greear } 4684e6975f7SBen Greear 469203c4805SLuis R. Rodriguez static ssize_t read_file_wiphy(struct file *file, char __user *user_buf, 470203c4805SLuis R. Rodriguez size_t count, loff_t *ppos) 471203c4805SLuis R. Rodriguez { 472203c4805SLuis R. Rodriguez struct ath_softc *sc = file->private_data; 47334302397SFelix Fietkau struct ieee80211_channel *chan = sc->hw->conf.channel; 4744e6975f7SBen Greear struct ieee80211_conf *conf = &(sc->hw->conf); 475203c4805SLuis R. Rodriguez char buf[512]; 476203c4805SLuis R. Rodriguez unsigned int len = 0; 477203c4805SLuis R. Rodriguez u8 addr[ETH_ALEN]; 47839057512SBen Greear u32 tmp; 479203c4805SLuis R. Rodriguez 480203c4805SLuis R. Rodriguez len += snprintf(buf + len, sizeof(buf) - len, 4814e6975f7SBen Greear "%s (chan=%d center-freq: %d MHz channel-type: %d (%s))\n", 48234302397SFelix Fietkau wiphy_name(sc->hw->wiphy), 4838e0167a4SMohammed Shafi Shajakhan ieee80211_frequency_to_channel(chan->center_freq), 4844e6975f7SBen Greear chan->center_freq, 4854e6975f7SBen Greear conf->channel_type, 4864e6975f7SBen Greear channel_type_str(conf->channel_type)); 487203c4805SLuis R. Rodriguez 488c6e38c06SMohammed Shafi Shajakhan ath9k_ps_wakeup(sc); 489475a6e4dSLuis R. Rodriguez put_unaligned_le32(REG_READ_D(sc->sc_ah, AR_STA_ID0), addr); 490475a6e4dSLuis R. Rodriguez put_unaligned_le16(REG_READ_D(sc->sc_ah, AR_STA_ID1) & 0xffff, addr + 4); 491203c4805SLuis R. Rodriguez len += snprintf(buf + len, sizeof(buf) - len, 492203c4805SLuis R. Rodriguez "addr: %pM\n", addr); 493475a6e4dSLuis R. Rodriguez put_unaligned_le32(REG_READ_D(sc->sc_ah, AR_BSSMSKL), addr); 494475a6e4dSLuis R. Rodriguez put_unaligned_le16(REG_READ_D(sc->sc_ah, AR_BSSMSKU) & 0xffff, addr + 4); 495203c4805SLuis R. Rodriguez len += snprintf(buf + len, sizeof(buf) - len, 496203c4805SLuis R. Rodriguez "addrmask: %pM\n", addr); 49739057512SBen Greear tmp = ath9k_hw_getrxfilter(sc->sc_ah); 49879d2b157SRajkumar Manoharan ath9k_ps_restore(sc); 49939057512SBen Greear len += snprintf(buf + len, sizeof(buf) - len, 50039057512SBen Greear "rfilt: 0x%x", tmp); 50139057512SBen Greear if (tmp & ATH9K_RX_FILTER_UCAST) 50239057512SBen Greear len += snprintf(buf + len, sizeof(buf) - len, " UCAST"); 50339057512SBen Greear if (tmp & ATH9K_RX_FILTER_MCAST) 50439057512SBen Greear len += snprintf(buf + len, sizeof(buf) - len, " MCAST"); 50539057512SBen Greear if (tmp & ATH9K_RX_FILTER_BCAST) 50639057512SBen Greear len += snprintf(buf + len, sizeof(buf) - len, " BCAST"); 50739057512SBen Greear if (tmp & ATH9K_RX_FILTER_CONTROL) 50839057512SBen Greear len += snprintf(buf + len, sizeof(buf) - len, " CONTROL"); 50939057512SBen Greear if (tmp & ATH9K_RX_FILTER_BEACON) 51039057512SBen Greear len += snprintf(buf + len, sizeof(buf) - len, " BEACON"); 51139057512SBen Greear if (tmp & ATH9K_RX_FILTER_PROM) 51239057512SBen Greear len += snprintf(buf + len, sizeof(buf) - len, " PROM"); 51339057512SBen Greear if (tmp & ATH9K_RX_FILTER_PROBEREQ) 51439057512SBen Greear len += snprintf(buf + len, sizeof(buf) - len, " PROBEREQ"); 51539057512SBen Greear if (tmp & ATH9K_RX_FILTER_PHYERR) 51639057512SBen Greear len += snprintf(buf + len, sizeof(buf) - len, " PHYERR"); 51739057512SBen Greear if (tmp & ATH9K_RX_FILTER_MYBEACON) 51839057512SBen Greear len += snprintf(buf + len, sizeof(buf) - len, " MYBEACON"); 51939057512SBen Greear if (tmp & ATH9K_RX_FILTER_COMP_BAR) 52039057512SBen Greear len += snprintf(buf + len, sizeof(buf) - len, " COMP_BAR"); 52139057512SBen Greear if (tmp & ATH9K_RX_FILTER_PSPOLL) 52239057512SBen Greear len += snprintf(buf + len, sizeof(buf) - len, " PSPOLL"); 52339057512SBen Greear if (tmp & ATH9K_RX_FILTER_PHYRADAR) 52439057512SBen Greear len += snprintf(buf + len, sizeof(buf) - len, " PHYRADAR"); 52539057512SBen Greear if (tmp & ATH9K_RX_FILTER_MCAST_BCAST_ALL) 526030d6294SFelix Fietkau len += snprintf(buf + len, sizeof(buf) - len, " MCAST_BCAST_ALL"); 527030d6294SFelix Fietkau 528030d6294SFelix Fietkau len += snprintf(buf + len, sizeof(buf) - len, 529030d6294SFelix Fietkau "\n\nReset causes:\n" 530030d6294SFelix Fietkau " baseband hang: %d\n" 531030d6294SFelix Fietkau " baseband watchdog: %d\n" 532030d6294SFelix Fietkau " fatal hardware error interrupt: %d\n" 533030d6294SFelix Fietkau " tx hardware error: %d\n" 534030d6294SFelix Fietkau " tx path hang: %d\n" 535030d6294SFelix Fietkau " pll rx hang: %d\n", 536030d6294SFelix Fietkau sc->debug.stats.reset[RESET_TYPE_BB_HANG], 537030d6294SFelix Fietkau sc->debug.stats.reset[RESET_TYPE_BB_WATCHDOG], 538030d6294SFelix Fietkau sc->debug.stats.reset[RESET_TYPE_FATAL_INT], 539030d6294SFelix Fietkau sc->debug.stats.reset[RESET_TYPE_TX_ERROR], 540030d6294SFelix Fietkau sc->debug.stats.reset[RESET_TYPE_TX_HANG], 541030d6294SFelix Fietkau sc->debug.stats.reset[RESET_TYPE_PLL_HANG]); 542203c4805SLuis R. Rodriguez 5432b87f3aaSDan Carpenter if (len > sizeof(buf)) 5442b87f3aaSDan Carpenter len = sizeof(buf); 5452b87f3aaSDan Carpenter 546203c4805SLuis R. Rodriguez return simple_read_from_buffer(user_buf, count, ppos, buf, len); 547203c4805SLuis R. Rodriguez } 548203c4805SLuis R. Rodriguez 549203c4805SLuis R. Rodriguez static const struct file_operations fops_wiphy = { 550203c4805SLuis R. Rodriguez .read = read_file_wiphy, 551203c4805SLuis R. Rodriguez .open = ath9k_debugfs_open, 5526038f373SArnd Bergmann .owner = THIS_MODULE, 5536038f373SArnd Bergmann .llseek = default_llseek, 554203c4805SLuis R. Rodriguez }; 555203c4805SLuis R. Rodriguez 5565bec3e5aSFelix Fietkau #define PR_QNUM(_n) sc->tx.txq_map[_n]->axq_qnum 557fec247c0SSujith #define PR(str, elem) \ 558fec247c0SSujith do { \ 559fec247c0SSujith len += snprintf(buf + len, size - len, \ 560fec247c0SSujith "%s%13u%11u%10u%10u\n", str, \ 5615bec3e5aSFelix Fietkau sc->debug.stats.txstats[PR_QNUM(WME_AC_BE)].elem, \ 5625bec3e5aSFelix Fietkau sc->debug.stats.txstats[PR_QNUM(WME_AC_BK)].elem, \ 5635bec3e5aSFelix Fietkau sc->debug.stats.txstats[PR_QNUM(WME_AC_VI)].elem, \ 5645bec3e5aSFelix Fietkau sc->debug.stats.txstats[PR_QNUM(WME_AC_VO)].elem); \ 5657f010c93SBen Greear if (len >= size) \ 5667f010c93SBen Greear goto done; \ 567fec247c0SSujith } while(0) 568fec247c0SSujith 5691f427dd9SBen Greear #define PRX(str, elem) \ 5701f427dd9SBen Greear do { \ 5711f427dd9SBen Greear len += snprintf(buf + len, size - len, \ 5721f427dd9SBen Greear "%s%13u%11u%10u%10u\n", str, \ 5735bec3e5aSFelix Fietkau (unsigned int)(sc->tx.txq_map[WME_AC_BE]->elem), \ 5745bec3e5aSFelix Fietkau (unsigned int)(sc->tx.txq_map[WME_AC_BK]->elem), \ 5755bec3e5aSFelix Fietkau (unsigned int)(sc->tx.txq_map[WME_AC_VI]->elem), \ 5765bec3e5aSFelix Fietkau (unsigned int)(sc->tx.txq_map[WME_AC_VO]->elem)); \ 5777f010c93SBen Greear if (len >= size) \ 5787f010c93SBen Greear goto done; \ 5791f427dd9SBen Greear } while(0) 5801f427dd9SBen Greear 5812dac4fb9SBen Greear #define PRQLE(str, elem) \ 5822dac4fb9SBen Greear do { \ 5832dac4fb9SBen Greear len += snprintf(buf + len, size - len, \ 5842dac4fb9SBen Greear "%s%13i%11i%10i%10i\n", str, \ 5855bec3e5aSFelix Fietkau list_empty(&sc->tx.txq_map[WME_AC_BE]->elem), \ 5865bec3e5aSFelix Fietkau list_empty(&sc->tx.txq_map[WME_AC_BK]->elem), \ 5875bec3e5aSFelix Fietkau list_empty(&sc->tx.txq_map[WME_AC_VI]->elem), \ 5885bec3e5aSFelix Fietkau list_empty(&sc->tx.txq_map[WME_AC_VO]->elem)); \ 5897f010c93SBen Greear if (len >= size) \ 5907f010c93SBen Greear goto done; \ 5912dac4fb9SBen Greear } while (0) 5922dac4fb9SBen Greear 593fec247c0SSujith static ssize_t read_file_xmit(struct file *file, char __user *user_buf, 594fec247c0SSujith size_t count, loff_t *ppos) 595fec247c0SSujith { 596fec247c0SSujith struct ath_softc *sc = file->private_data; 597fec247c0SSujith char *buf; 5987f010c93SBen Greear unsigned int len = 0, size = 8000; 5992dac4fb9SBen Greear int i; 600fec247c0SSujith ssize_t retval = 0; 6012dac4fb9SBen Greear char tmp[32]; 602fec247c0SSujith 603fec247c0SSujith buf = kzalloc(size, GFP_KERNEL); 604fec247c0SSujith if (buf == NULL) 60504236066SDan Carpenter return -ENOMEM; 606fec247c0SSujith 60760f2d1d5SBen Greear len += sprintf(buf, "Num-Tx-Queues: %i tx-queues-setup: 0x%x" 60860f2d1d5SBen Greear " poll-work-seen: %u\n" 6097f010c93SBen Greear "%30s %10s%10s%10s\n\n", 6107f010c93SBen Greear ATH9K_NUM_TX_QUEUES, sc->tx.txqsetup, 61160f2d1d5SBen Greear sc->tx_complete_poll_work_seen, 6127f010c93SBen Greear "BE", "BK", "VI", "VO"); 613fec247c0SSujith 614fec247c0SSujith PR("MPDUs Queued: ", queued); 615fec247c0SSujith PR("MPDUs Completed: ", completed); 6165a6f78afSFelix Fietkau PR("MPDUs XRetried: ", xretries); 617fec247c0SSujith PR("Aggregates: ", a_aggr); 618bda8addaSBen Greear PR("AMPDUs Queued HW:", a_queued_hw); 619bda8addaSBen Greear PR("AMPDUs Queued SW:", a_queued_sw); 620fec247c0SSujith PR("AMPDUs Completed:", a_completed); 621fec247c0SSujith PR("AMPDUs Retried: ", a_retries); 622fec247c0SSujith PR("AMPDUs XRetried: ", a_xretries); 623fec247c0SSujith PR("FIFO Underrun: ", fifo_underrun); 624fec247c0SSujith PR("TXOP Exceeded: ", xtxop); 625fec247c0SSujith PR("TXTIMER Expiry: ", timer_exp); 626fec247c0SSujith PR("DESC CFG Error: ", desc_cfg_err); 627fec247c0SSujith PR("DATA Underrun: ", data_underrun); 628fec247c0SSujith PR("DELIM Underrun: ", delim_underrun); 62999c15bf5SBen Greear PR("TX-Pkts-All: ", tx_pkts_all); 63099c15bf5SBen Greear PR("TX-Bytes-All: ", tx_bytes_all); 6312dac4fb9SBen Greear PR("hw-put-tx-buf: ", puttxbuf); 6322dac4fb9SBen Greear PR("hw-tx-start: ", txstart); 6332dac4fb9SBen Greear PR("hw-tx-proc-desc: ", txprocdesc); 6347f010c93SBen Greear len += snprintf(buf + len, size - len, 6357f010c93SBen Greear "%s%11p%11p%10p%10p\n", "txq-memory-address:", 636db7889cdSBen Greear sc->tx.txq_map[WME_AC_BE], 637db7889cdSBen Greear sc->tx.txq_map[WME_AC_BK], 638db7889cdSBen Greear sc->tx.txq_map[WME_AC_VI], 639db7889cdSBen Greear sc->tx.txq_map[WME_AC_VO]); 6407f010c93SBen Greear if (len >= size) 6417f010c93SBen Greear goto done; 642fec247c0SSujith 6431f427dd9SBen Greear PRX("axq-qnum: ", axq_qnum); 6441f427dd9SBen Greear PRX("axq-depth: ", axq_depth); 6452dac4fb9SBen Greear PRX("axq-ampdu_depth: ", axq_ampdu_depth); 6461f427dd9SBen Greear PRX("axq-stopped ", stopped); 6471f427dd9SBen Greear PRX("tx-in-progress ", axq_tx_inprogress); 6481f427dd9SBen Greear PRX("pending-frames ", pending_frames); 6492dac4fb9SBen Greear PRX("txq_headidx: ", txq_headidx); 6502dac4fb9SBen Greear PRX("txq_tailidx: ", txq_headidx); 6511f427dd9SBen Greear 6522dac4fb9SBen Greear PRQLE("axq_q empty: ", axq_q); 6532dac4fb9SBen Greear PRQLE("axq_acq empty: ", axq_acq); 6542dac4fb9SBen Greear for (i = 0; i < ATH_TXFIFO_DEPTH; i++) { 6552dac4fb9SBen Greear snprintf(tmp, sizeof(tmp) - 1, "txq_fifo[%i] empty: ", i); 6562dac4fb9SBen Greear PRQLE(tmp, txq_fifo[i]); 6572dac4fb9SBen Greear } 6587f010c93SBen Greear 65971e025a5SBen Greear /* Print out more detailed queue-info */ 66071e025a5SBen Greear for (i = 0; i <= WME_AC_BK; i++) { 66171e025a5SBen Greear struct ath_txq *txq = &(sc->tx.txq[i]); 66271e025a5SBen Greear struct ath_atx_ac *ac; 66371e025a5SBen Greear struct ath_atx_tid *tid; 66471e025a5SBen Greear if (len >= size) 66571e025a5SBen Greear goto done; 66671e025a5SBen Greear spin_lock_bh(&txq->axq_lock); 66771e025a5SBen Greear if (!list_empty(&txq->axq_acq)) { 66871e025a5SBen Greear ac = list_first_entry(&txq->axq_acq, struct ath_atx_ac, 66971e025a5SBen Greear list); 67071e025a5SBen Greear len += snprintf(buf + len, size - len, 67171e025a5SBen Greear "txq[%i] first-ac: %p sched: %i\n", 67271e025a5SBen Greear i, ac, ac->sched); 67371e025a5SBen Greear if (list_empty(&ac->tid_q) || (len >= size)) 67471e025a5SBen Greear goto done_for; 67571e025a5SBen Greear tid = list_first_entry(&ac->tid_q, struct ath_atx_tid, 67671e025a5SBen Greear list); 67771e025a5SBen Greear len += snprintf(buf + len, size - len, 67871e025a5SBen Greear " first-tid: %p sched: %i paused: %i\n", 67971e025a5SBen Greear tid, tid->sched, tid->paused); 68071e025a5SBen Greear } 68171e025a5SBen Greear done_for: 68271e025a5SBen Greear spin_unlock_bh(&txq->axq_lock); 68371e025a5SBen Greear } 68471e025a5SBen Greear 6857f010c93SBen Greear done: 6867f010c93SBen Greear if (len > size) 6877f010c93SBen Greear len = size; 6887f010c93SBen Greear 6897f010c93SBen Greear retval = simple_read_from_buffer(user_buf, count, ppos, buf, len); 6907f010c93SBen Greear kfree(buf); 6917f010c93SBen Greear 6927f010c93SBen Greear return retval; 6937f010c93SBen Greear } 6947f010c93SBen Greear 6957f010c93SBen Greear static ssize_t read_file_stations(struct file *file, char __user *user_buf, 6967f010c93SBen Greear size_t count, loff_t *ppos) 6977f010c93SBen Greear { 6987f010c93SBen Greear struct ath_softc *sc = file->private_data; 6997f010c93SBen Greear char *buf; 7007f010c93SBen Greear unsigned int len = 0, size = 64000; 7017f010c93SBen Greear struct ath_node *an = NULL; 7027f010c93SBen Greear ssize_t retval = 0; 7037f010c93SBen Greear int q; 7047f010c93SBen Greear 7057f010c93SBen Greear buf = kzalloc(size, GFP_KERNEL); 7067f010c93SBen Greear if (buf == NULL) 7077f010c93SBen Greear return -ENOMEM; 7087f010c93SBen Greear 7097f010c93SBen Greear len += snprintf(buf + len, size - len, 7107f010c93SBen Greear "Stations:\n" 711*7e1e3864SBen Greear " tid: addr sched paused buf_q-empty an ac baw\n" 7127f010c93SBen Greear " ac: addr sched tid_q-empty txq\n"); 7137f010c93SBen Greear 7147f010c93SBen Greear spin_lock(&sc->nodes_lock); 7157f010c93SBen Greear list_for_each_entry(an, &sc->nodes, list) { 716*7e1e3864SBen Greear unsigned short ma = an->maxampdu; 717*7e1e3864SBen Greear if (ma == 0) 718*7e1e3864SBen Greear ma = 65535; /* see ath_lookup_rate */ 7197f010c93SBen Greear len += snprintf(buf + len, size - len, 720*7e1e3864SBen Greear "iface: %pM sta: %pM max-ampdu: %hu mpdu-density: %uus\n", 721*7e1e3864SBen Greear an->vif->addr, an->sta->addr, ma, 722*7e1e3864SBen Greear (unsigned int)(an->mpdudensity)); 7237f010c93SBen Greear if (len >= size) 7247f010c93SBen Greear goto done; 7257f010c93SBen Greear 7267f010c93SBen Greear for (q = 0; q < WME_NUM_TID; q++) { 7277f010c93SBen Greear struct ath_atx_tid *tid = &(an->tid[q]); 7287f010c93SBen Greear len += snprintf(buf + len, size - len, 729*7e1e3864SBen Greear " tid: %p %s %s %i %p %p %hu\n", 7307f010c93SBen Greear tid, tid->sched ? "sched" : "idle", 7317f010c93SBen Greear tid->paused ? "paused" : "running", 73256dc6336SFelix Fietkau skb_queue_empty(&tid->buf_q), 733*7e1e3864SBen Greear tid->an, tid->ac, tid->baw_size); 7347f010c93SBen Greear if (len >= size) 7357f010c93SBen Greear goto done; 7367f010c93SBen Greear } 7377f010c93SBen Greear 7387f010c93SBen Greear for (q = 0; q < WME_NUM_AC; q++) { 7397f010c93SBen Greear struct ath_atx_ac *ac = &(an->ac[q]); 7407f010c93SBen Greear len += snprintf(buf + len, size - len, 7417f010c93SBen Greear " ac: %p %s %i %p\n", 7427f010c93SBen Greear ac, ac->sched ? "sched" : "idle", 7437f010c93SBen Greear list_empty(&ac->tid_q), ac->txq); 7447f010c93SBen Greear if (len >= size) 7457f010c93SBen Greear goto done; 7467f010c93SBen Greear } 7477f010c93SBen Greear } 7487f010c93SBen Greear 7497f010c93SBen Greear done: 7507f010c93SBen Greear spin_unlock(&sc->nodes_lock); 7512b87f3aaSDan Carpenter if (len > size) 7522b87f3aaSDan Carpenter len = size; 7532b87f3aaSDan Carpenter 754fec247c0SSujith retval = simple_read_from_buffer(user_buf, count, ppos, buf, len); 755fec247c0SSujith kfree(buf); 756fec247c0SSujith 757fec247c0SSujith return retval; 758fec247c0SSujith } 759fec247c0SSujith 76055f6d0ffSBen Greear static ssize_t read_file_misc(struct file *file, char __user *user_buf, 76155f6d0ffSBen Greear size_t count, loff_t *ppos) 76255f6d0ffSBen Greear { 76355f6d0ffSBen Greear struct ath_softc *sc = file->private_data; 76455f6d0ffSBen Greear struct ath_common *common = ath9k_hw_common(sc->sc_ah); 76555f6d0ffSBen Greear struct ath_hw *ah = sc->sc_ah; 76655f6d0ffSBen Greear struct ieee80211_hw *hw = sc->hw; 76755f6d0ffSBen Greear char *buf; 76855f6d0ffSBen Greear unsigned int len = 0, size = 8000; 76955f6d0ffSBen Greear ssize_t retval = 0; 77055f6d0ffSBen Greear unsigned int reg; 77155f6d0ffSBen Greear struct ath9k_vif_iter_data iter_data; 77255f6d0ffSBen Greear 77355f6d0ffSBen Greear ath9k_calculate_iter_data(hw, NULL, &iter_data); 77455f6d0ffSBen Greear 77555f6d0ffSBen Greear buf = kzalloc(size, GFP_KERNEL); 77655f6d0ffSBen Greear if (buf == NULL) 77755f6d0ffSBen Greear return -ENOMEM; 77855f6d0ffSBen Greear 77979d2b157SRajkumar Manoharan ath9k_ps_wakeup(sc); 78055f6d0ffSBen Greear len += snprintf(buf + len, size - len, 78155f6d0ffSBen Greear "curbssid: %pM\n" 78255f6d0ffSBen Greear "OP-Mode: %s(%i)\n" 78355f6d0ffSBen Greear "Beacon-Timer-Register: 0x%x\n", 78455f6d0ffSBen Greear common->curbssid, 78521ec489dSPavel Roskin ath_opmode_to_string(sc->sc_ah->opmode), 78621ec489dSPavel Roskin (int)(sc->sc_ah->opmode), 78755f6d0ffSBen Greear REG_READ(ah, AR_BEACON_PERIOD)); 78855f6d0ffSBen Greear 78955f6d0ffSBen Greear reg = REG_READ(ah, AR_TIMER_MODE); 79079d2b157SRajkumar Manoharan ath9k_ps_restore(sc); 79155f6d0ffSBen Greear len += snprintf(buf + len, size - len, "Timer-Mode-Register: 0x%x (", 79255f6d0ffSBen Greear reg); 79355f6d0ffSBen Greear if (reg & AR_TBTT_TIMER_EN) 79455f6d0ffSBen Greear len += snprintf(buf + len, size - len, "TBTT "); 79555f6d0ffSBen Greear if (reg & AR_DBA_TIMER_EN) 79655f6d0ffSBen Greear len += snprintf(buf + len, size - len, "DBA "); 79755f6d0ffSBen Greear if (reg & AR_SWBA_TIMER_EN) 79855f6d0ffSBen Greear len += snprintf(buf + len, size - len, "SWBA "); 79955f6d0ffSBen Greear if (reg & AR_HCF_TIMER_EN) 80055f6d0ffSBen Greear len += snprintf(buf + len, size - len, "HCF "); 80155f6d0ffSBen Greear if (reg & AR_TIM_TIMER_EN) 80255f6d0ffSBen Greear len += snprintf(buf + len, size - len, "TIM "); 80355f6d0ffSBen Greear if (reg & AR_DTIM_TIMER_EN) 80455f6d0ffSBen Greear len += snprintf(buf + len, size - len, "DTIM "); 80555f6d0ffSBen Greear len += snprintf(buf + len, size - len, ")\n"); 80655f6d0ffSBen Greear 80755f6d0ffSBen Greear reg = sc->sc_ah->imask; 80855f6d0ffSBen Greear len += snprintf(buf + len, size - len, "imask: 0x%x (", reg); 80955f6d0ffSBen Greear if (reg & ATH9K_INT_SWBA) 81055f6d0ffSBen Greear len += snprintf(buf + len, size - len, "SWBA "); 81155f6d0ffSBen Greear if (reg & ATH9K_INT_BMISS) 81255f6d0ffSBen Greear len += snprintf(buf + len, size - len, "BMISS "); 81355f6d0ffSBen Greear if (reg & ATH9K_INT_CST) 81455f6d0ffSBen Greear len += snprintf(buf + len, size - len, "CST "); 81555f6d0ffSBen Greear if (reg & ATH9K_INT_RX) 81655f6d0ffSBen Greear len += snprintf(buf + len, size - len, "RX "); 81755f6d0ffSBen Greear if (reg & ATH9K_INT_RXHP) 81855f6d0ffSBen Greear len += snprintf(buf + len, size - len, "RXHP "); 81955f6d0ffSBen Greear if (reg & ATH9K_INT_RXLP) 82055f6d0ffSBen Greear len += snprintf(buf + len, size - len, "RXLP "); 82155f6d0ffSBen Greear if (reg & ATH9K_INT_BB_WATCHDOG) 82255f6d0ffSBen Greear len += snprintf(buf + len, size - len, "BB_WATCHDOG "); 82355f6d0ffSBen Greear /* there are other IRQs if one wanted to add them. */ 82455f6d0ffSBen Greear len += snprintf(buf + len, size - len, ")\n"); 82555f6d0ffSBen Greear 82655f6d0ffSBen Greear len += snprintf(buf + len, size - len, 82755f6d0ffSBen Greear "VIF Counts: AP: %i STA: %i MESH: %i WDS: %i" 82855f6d0ffSBen Greear " ADHOC: %i OTHER: %i nvifs: %hi beacon-vifs: %hi\n", 82955f6d0ffSBen Greear iter_data.naps, iter_data.nstations, iter_data.nmeshes, 83055f6d0ffSBen Greear iter_data.nwds, iter_data.nadhocs, iter_data.nothers, 83155f6d0ffSBen Greear sc->nvifs, sc->nbcnvifs); 83255f6d0ffSBen Greear 83355f6d0ffSBen Greear len += snprintf(buf + len, size - len, 83455f6d0ffSBen Greear "Calculated-BSSID-Mask: %pM\n", 83555f6d0ffSBen Greear iter_data.mask); 83655f6d0ffSBen Greear 83755f6d0ffSBen Greear if (len > size) 83855f6d0ffSBen Greear len = size; 83955f6d0ffSBen Greear 84055f6d0ffSBen Greear retval = simple_read_from_buffer(user_buf, count, ppos, buf, len); 84155f6d0ffSBen Greear kfree(buf); 84255f6d0ffSBen Greear 84355f6d0ffSBen Greear return retval; 84455f6d0ffSBen Greear } 84555f6d0ffSBen Greear 846066dae93SFelix Fietkau void ath_debug_stat_tx(struct ath_softc *sc, struct ath_buf *bf, 84755797b1aSFelix Fietkau struct ath_tx_status *ts, struct ath_txq *txq, 84855797b1aSFelix Fietkau unsigned int flags) 849fec247c0SSujith { 850cf3af748SRajkumar Manoharan #define TX_SAMP_DBG(c) (sc->debug.bb_mac_samp[sc->debug.sampidx].ts\ 851cf3af748SRajkumar Manoharan [sc->debug.tsidx].c) 8525bec3e5aSFelix Fietkau int qnum = txq->axq_qnum; 853066dae93SFelix Fietkau 854066dae93SFelix Fietkau TX_STAT_INC(qnum, tx_pkts_all); 855066dae93SFelix Fietkau sc->debug.stats.txstats[qnum].tx_bytes_all += bf->bf_mpdu->len; 85699c15bf5SBen Greear 857fec247c0SSujith if (bf_isampdu(bf)) { 85855797b1aSFelix Fietkau if (flags & ATH_TX_BAR) 859066dae93SFelix Fietkau TX_STAT_INC(qnum, a_xretries); 860fec247c0SSujith else 861066dae93SFelix Fietkau TX_STAT_INC(qnum, a_completed); 862fec247c0SSujith } else { 86355797b1aSFelix Fietkau if (ts->ts_status & ATH9K_TXERR_XRETRY) 8645a6f78afSFelix Fietkau TX_STAT_INC(qnum, xretries); 8655a6f78afSFelix Fietkau else 866066dae93SFelix Fietkau TX_STAT_INC(qnum, completed); 867fec247c0SSujith } 868fec247c0SSujith 869db1a052bSFelix Fietkau if (ts->ts_status & ATH9K_TXERR_FIFO) 870066dae93SFelix Fietkau TX_STAT_INC(qnum, fifo_underrun); 871db1a052bSFelix Fietkau if (ts->ts_status & ATH9K_TXERR_XTXOP) 872066dae93SFelix Fietkau TX_STAT_INC(qnum, xtxop); 873db1a052bSFelix Fietkau if (ts->ts_status & ATH9K_TXERR_TIMER_EXPIRED) 874066dae93SFelix Fietkau TX_STAT_INC(qnum, timer_exp); 875db1a052bSFelix Fietkau if (ts->ts_flags & ATH9K_TX_DESC_CFG_ERR) 876066dae93SFelix Fietkau TX_STAT_INC(qnum, desc_cfg_err); 877db1a052bSFelix Fietkau if (ts->ts_flags & ATH9K_TX_DATA_UNDERRUN) 878066dae93SFelix Fietkau TX_STAT_INC(qnum, data_underrun); 879db1a052bSFelix Fietkau if (ts->ts_flags & ATH9K_TX_DELIM_UNDERRUN) 880066dae93SFelix Fietkau TX_STAT_INC(qnum, delim_underrun); 881cf3af748SRajkumar Manoharan 882cf3af748SRajkumar Manoharan spin_lock(&sc->debug.samp_lock); 883cf3af748SRajkumar Manoharan TX_SAMP_DBG(jiffies) = jiffies; 884cf3af748SRajkumar Manoharan TX_SAMP_DBG(rssi_ctl0) = ts->ts_rssi_ctl0; 885cf3af748SRajkumar Manoharan TX_SAMP_DBG(rssi_ctl1) = ts->ts_rssi_ctl1; 886cf3af748SRajkumar Manoharan TX_SAMP_DBG(rssi_ctl2) = ts->ts_rssi_ctl2; 887cf3af748SRajkumar Manoharan TX_SAMP_DBG(rssi_ext0) = ts->ts_rssi_ext0; 888cf3af748SRajkumar Manoharan TX_SAMP_DBG(rssi_ext1) = ts->ts_rssi_ext1; 889cf3af748SRajkumar Manoharan TX_SAMP_DBG(rssi_ext2) = ts->ts_rssi_ext2; 890cf3af748SRajkumar Manoharan TX_SAMP_DBG(rateindex) = ts->ts_rateindex; 891cf3af748SRajkumar Manoharan TX_SAMP_DBG(isok) = !!(ts->ts_status & ATH9K_TXERR_MASK); 892cf3af748SRajkumar Manoharan TX_SAMP_DBG(rts_fail_cnt) = ts->ts_shortretry; 893cf3af748SRajkumar Manoharan TX_SAMP_DBG(data_fail_cnt) = ts->ts_longretry; 894cf3af748SRajkumar Manoharan TX_SAMP_DBG(rssi) = ts->ts_rssi; 895cf3af748SRajkumar Manoharan TX_SAMP_DBG(tid) = ts->tid; 896cf3af748SRajkumar Manoharan TX_SAMP_DBG(qid) = ts->qid; 89712932180SMohammed Shafi Shajakhan 89812932180SMohammed Shafi Shajakhan if (ts->ts_flags & ATH9K_TX_BA) { 89912932180SMohammed Shafi Shajakhan TX_SAMP_DBG(ba_low) = ts->ba_low; 90012932180SMohammed Shafi Shajakhan TX_SAMP_DBG(ba_high) = ts->ba_high; 90112932180SMohammed Shafi Shajakhan } else { 90212932180SMohammed Shafi Shajakhan TX_SAMP_DBG(ba_low) = 0; 90312932180SMohammed Shafi Shajakhan TX_SAMP_DBG(ba_high) = 0; 90412932180SMohammed Shafi Shajakhan } 90512932180SMohammed Shafi Shajakhan 906cf3af748SRajkumar Manoharan sc->debug.tsidx = (sc->debug.tsidx + 1) % ATH_DBG_MAX_SAMPLES; 907cf3af748SRajkumar Manoharan spin_unlock(&sc->debug.samp_lock); 908cf3af748SRajkumar Manoharan 909cf3af748SRajkumar Manoharan #undef TX_SAMP_DBG 910fec247c0SSujith } 911fec247c0SSujith 912fec247c0SSujith static const struct file_operations fops_xmit = { 913fec247c0SSujith .read = read_file_xmit, 914fec247c0SSujith .open = ath9k_debugfs_open, 9156038f373SArnd Bergmann .owner = THIS_MODULE, 9166038f373SArnd Bergmann .llseek = default_llseek, 917fec247c0SSujith }; 918203c4805SLuis R. Rodriguez 9197f010c93SBen Greear static const struct file_operations fops_stations = { 9207f010c93SBen Greear .read = read_file_stations, 9217f010c93SBen Greear .open = ath9k_debugfs_open, 9227f010c93SBen Greear .owner = THIS_MODULE, 9237f010c93SBen Greear .llseek = default_llseek, 9247f010c93SBen Greear }; 9257f010c93SBen Greear 92655f6d0ffSBen Greear static const struct file_operations fops_misc = { 92755f6d0ffSBen Greear .read = read_file_misc, 92855f6d0ffSBen Greear .open = ath9k_debugfs_open, 92955f6d0ffSBen Greear .owner = THIS_MODULE, 93055f6d0ffSBen Greear .llseek = default_llseek, 93155f6d0ffSBen Greear }; 93255f6d0ffSBen Greear 9331395d3f0SSujith static ssize_t read_file_recv(struct file *file, char __user *user_buf, 9341395d3f0SSujith size_t count, loff_t *ppos) 9351395d3f0SSujith { 9361395d3f0SSujith #define PHY_ERR(s, p) \ 9371395d3f0SSujith len += snprintf(buf + len, size - len, "%18s : %10u\n", s, \ 9381395d3f0SSujith sc->debug.stats.rxstats.phy_err_stats[p]); 9391395d3f0SSujith 9401395d3f0SSujith struct ath_softc *sc = file->private_data; 9411395d3f0SSujith char *buf; 9427d755414SSenthil Balasubramanian unsigned int len = 0, size = 1400; 9431395d3f0SSujith ssize_t retval = 0; 9441395d3f0SSujith 9451395d3f0SSujith buf = kzalloc(size, GFP_KERNEL); 9461395d3f0SSujith if (buf == NULL) 94704236066SDan Carpenter return -ENOMEM; 9481395d3f0SSujith 9491395d3f0SSujith len += snprintf(buf + len, size - len, 9501395d3f0SSujith "%18s : %10u\n", "CRC ERR", 9511395d3f0SSujith sc->debug.stats.rxstats.crc_err); 9521395d3f0SSujith len += snprintf(buf + len, size - len, 9531395d3f0SSujith "%18s : %10u\n", "DECRYPT CRC ERR", 9541395d3f0SSujith sc->debug.stats.rxstats.decrypt_crc_err); 9551395d3f0SSujith len += snprintf(buf + len, size - len, 9561395d3f0SSujith "%18s : %10u\n", "PHY ERR", 9571395d3f0SSujith sc->debug.stats.rxstats.phy_err); 9581395d3f0SSujith len += snprintf(buf + len, size - len, 9591395d3f0SSujith "%18s : %10u\n", "MIC ERR", 9601395d3f0SSujith sc->debug.stats.rxstats.mic_err); 9611395d3f0SSujith len += snprintf(buf + len, size - len, 9621395d3f0SSujith "%18s : %10u\n", "PRE-DELIM CRC ERR", 9631395d3f0SSujith sc->debug.stats.rxstats.pre_delim_crc_err); 9641395d3f0SSujith len += snprintf(buf + len, size - len, 9651395d3f0SSujith "%18s : %10u\n", "POST-DELIM CRC ERR", 9661395d3f0SSujith sc->debug.stats.rxstats.post_delim_crc_err); 9671395d3f0SSujith len += snprintf(buf + len, size - len, 9681395d3f0SSujith "%18s : %10u\n", "DECRYPT BUSY ERR", 9691395d3f0SSujith sc->debug.stats.rxstats.decrypt_busy_err); 9701395d3f0SSujith 9717d755414SSenthil Balasubramanian len += snprintf(buf + len, size - len, 9727d755414SSenthil Balasubramanian "%18s : %10d\n", "RSSI-CTL0", 9737d755414SSenthil Balasubramanian sc->debug.stats.rxstats.rs_rssi_ctl0); 9747d755414SSenthil Balasubramanian 9757d755414SSenthil Balasubramanian len += snprintf(buf + len, size - len, 9767d755414SSenthil Balasubramanian "%18s : %10d\n", "RSSI-CTL1", 9777d755414SSenthil Balasubramanian sc->debug.stats.rxstats.rs_rssi_ctl1); 9787d755414SSenthil Balasubramanian 9797d755414SSenthil Balasubramanian len += snprintf(buf + len, size - len, 9807d755414SSenthil Balasubramanian "%18s : %10d\n", "RSSI-CTL2", 9817d755414SSenthil Balasubramanian sc->debug.stats.rxstats.rs_rssi_ctl2); 9827d755414SSenthil Balasubramanian 9837d755414SSenthil Balasubramanian len += snprintf(buf + len, size - len, 9847d755414SSenthil Balasubramanian "%18s : %10d\n", "RSSI-EXT0", 9857d755414SSenthil Balasubramanian sc->debug.stats.rxstats.rs_rssi_ext0); 9867d755414SSenthil Balasubramanian 9877d755414SSenthil Balasubramanian len += snprintf(buf + len, size - len, 9887d755414SSenthil Balasubramanian "%18s : %10d\n", "RSSI-EXT1", 9897d755414SSenthil Balasubramanian sc->debug.stats.rxstats.rs_rssi_ext1); 9907d755414SSenthil Balasubramanian 9917d755414SSenthil Balasubramanian len += snprintf(buf + len, size - len, 9927d755414SSenthil Balasubramanian "%18s : %10d\n", "RSSI-EXT2", 9937d755414SSenthil Balasubramanian sc->debug.stats.rxstats.rs_rssi_ext2); 9947d755414SSenthil Balasubramanian 9957d755414SSenthil Balasubramanian len += snprintf(buf + len, size - len, 9967d755414SSenthil Balasubramanian "%18s : %10d\n", "Rx Antenna", 9977d755414SSenthil Balasubramanian sc->debug.stats.rxstats.rs_antenna); 9987d755414SSenthil Balasubramanian 9991395d3f0SSujith PHY_ERR("UNDERRUN", ATH9K_PHYERR_UNDERRUN); 10001395d3f0SSujith PHY_ERR("TIMING", ATH9K_PHYERR_TIMING); 10011395d3f0SSujith PHY_ERR("PARITY", ATH9K_PHYERR_PARITY); 10021395d3f0SSujith PHY_ERR("RATE", ATH9K_PHYERR_RATE); 10031395d3f0SSujith PHY_ERR("LENGTH", ATH9K_PHYERR_LENGTH); 10041395d3f0SSujith PHY_ERR("RADAR", ATH9K_PHYERR_RADAR); 10051395d3f0SSujith PHY_ERR("SERVICE", ATH9K_PHYERR_SERVICE); 10061395d3f0SSujith PHY_ERR("TOR", ATH9K_PHYERR_TOR); 10071395d3f0SSujith PHY_ERR("OFDM-TIMING", ATH9K_PHYERR_OFDM_TIMING); 10081395d3f0SSujith PHY_ERR("OFDM-SIGNAL-PARITY", ATH9K_PHYERR_OFDM_SIGNAL_PARITY); 10091395d3f0SSujith PHY_ERR("OFDM-RATE", ATH9K_PHYERR_OFDM_RATE_ILLEGAL); 10101395d3f0SSujith PHY_ERR("OFDM-LENGTH", ATH9K_PHYERR_OFDM_LENGTH_ILLEGAL); 10111395d3f0SSujith PHY_ERR("OFDM-POWER-DROP", ATH9K_PHYERR_OFDM_POWER_DROP); 10121395d3f0SSujith PHY_ERR("OFDM-SERVICE", ATH9K_PHYERR_OFDM_SERVICE); 10131395d3f0SSujith PHY_ERR("OFDM-RESTART", ATH9K_PHYERR_OFDM_RESTART); 10141395d3f0SSujith PHY_ERR("FALSE-RADAR-EXT", ATH9K_PHYERR_FALSE_RADAR_EXT); 10151395d3f0SSujith PHY_ERR("CCK-TIMING", ATH9K_PHYERR_CCK_TIMING); 10161395d3f0SSujith PHY_ERR("CCK-HEADER-CRC", ATH9K_PHYERR_CCK_HEADER_CRC); 10171395d3f0SSujith PHY_ERR("CCK-RATE", ATH9K_PHYERR_CCK_RATE_ILLEGAL); 10181395d3f0SSujith PHY_ERR("CCK-SERVICE", ATH9K_PHYERR_CCK_SERVICE); 10191395d3f0SSujith PHY_ERR("CCK-RESTART", ATH9K_PHYERR_CCK_RESTART); 10201395d3f0SSujith PHY_ERR("CCK-LENGTH", ATH9K_PHYERR_CCK_LENGTH_ILLEGAL); 10211395d3f0SSujith PHY_ERR("CCK-POWER-DROP", ATH9K_PHYERR_CCK_POWER_DROP); 10221395d3f0SSujith PHY_ERR("HT-CRC", ATH9K_PHYERR_HT_CRC_ERROR); 10231395d3f0SSujith PHY_ERR("HT-LENGTH", ATH9K_PHYERR_HT_LENGTH_ILLEGAL); 10241395d3f0SSujith PHY_ERR("HT-RATE", ATH9K_PHYERR_HT_RATE_ILLEGAL); 10251395d3f0SSujith 102699c15bf5SBen Greear len += snprintf(buf + len, size - len, 102799c15bf5SBen Greear "%18s : %10u\n", "RX-Pkts-All", 102899c15bf5SBen Greear sc->debug.stats.rxstats.rx_pkts_all); 102999c15bf5SBen Greear len += snprintf(buf + len, size - len, 103099c15bf5SBen Greear "%18s : %10u\n", "RX-Bytes-All", 103199c15bf5SBen Greear sc->debug.stats.rxstats.rx_bytes_all); 103299c15bf5SBen Greear 10332b87f3aaSDan Carpenter if (len > size) 10342b87f3aaSDan Carpenter len = size; 10352b87f3aaSDan Carpenter 10361395d3f0SSujith retval = simple_read_from_buffer(user_buf, count, ppos, buf, len); 10371395d3f0SSujith kfree(buf); 10381395d3f0SSujith 10391395d3f0SSujith return retval; 10401395d3f0SSujith 10411395d3f0SSujith #undef PHY_ERR 10421395d3f0SSujith } 10431395d3f0SSujith 10448e6f5aa2SFelix Fietkau void ath_debug_stat_rx(struct ath_softc *sc, struct ath_rx_status *rs) 10451395d3f0SSujith { 10461395d3f0SSujith #define RX_STAT_INC(c) sc->debug.stats.rxstats.c++ 10471395d3f0SSujith #define RX_PHY_ERR_INC(c) sc->debug.stats.rxstats.phy_err_stats[c]++ 1048cf3af748SRajkumar Manoharan #define RX_SAMP_DBG(c) (sc->debug.bb_mac_samp[sc->debug.sampidx].rs\ 1049cf3af748SRajkumar Manoharan [sc->debug.rsidx].c) 10501395d3f0SSujith 10511395d3f0SSujith u32 phyerr; 10521395d3f0SSujith 105399c15bf5SBen Greear RX_STAT_INC(rx_pkts_all); 105499c15bf5SBen Greear sc->debug.stats.rxstats.rx_bytes_all += rs->rs_datalen; 105599c15bf5SBen Greear 10568e6f5aa2SFelix Fietkau if (rs->rs_status & ATH9K_RXERR_CRC) 10571395d3f0SSujith RX_STAT_INC(crc_err); 10588e6f5aa2SFelix Fietkau if (rs->rs_status & ATH9K_RXERR_DECRYPT) 10591395d3f0SSujith RX_STAT_INC(decrypt_crc_err); 10608e6f5aa2SFelix Fietkau if (rs->rs_status & ATH9K_RXERR_MIC) 10611395d3f0SSujith RX_STAT_INC(mic_err); 10628e6f5aa2SFelix Fietkau if (rs->rs_status & ATH9K_RX_DELIM_CRC_PRE) 10631395d3f0SSujith RX_STAT_INC(pre_delim_crc_err); 10648e6f5aa2SFelix Fietkau if (rs->rs_status & ATH9K_RX_DELIM_CRC_POST) 10651395d3f0SSujith RX_STAT_INC(post_delim_crc_err); 10668e6f5aa2SFelix Fietkau if (rs->rs_status & ATH9K_RX_DECRYPT_BUSY) 10671395d3f0SSujith RX_STAT_INC(decrypt_busy_err); 10681395d3f0SSujith 10698e6f5aa2SFelix Fietkau if (rs->rs_status & ATH9K_RXERR_PHY) { 10701395d3f0SSujith RX_STAT_INC(phy_err); 10718e6f5aa2SFelix Fietkau phyerr = rs->rs_phyerr & 0x24; 10721395d3f0SSujith RX_PHY_ERR_INC(phyerr); 10731395d3f0SSujith } 10741395d3f0SSujith 10757d755414SSenthil Balasubramanian sc->debug.stats.rxstats.rs_rssi_ctl0 = rs->rs_rssi_ctl0; 10767d755414SSenthil Balasubramanian sc->debug.stats.rxstats.rs_rssi_ctl1 = rs->rs_rssi_ctl1; 10777d755414SSenthil Balasubramanian sc->debug.stats.rxstats.rs_rssi_ctl2 = rs->rs_rssi_ctl2; 10787d755414SSenthil Balasubramanian 10797d755414SSenthil Balasubramanian sc->debug.stats.rxstats.rs_rssi_ext0 = rs->rs_rssi_ext0; 10807d755414SSenthil Balasubramanian sc->debug.stats.rxstats.rs_rssi_ext1 = rs->rs_rssi_ext1; 10817d755414SSenthil Balasubramanian sc->debug.stats.rxstats.rs_rssi_ext2 = rs->rs_rssi_ext2; 10827d755414SSenthil Balasubramanian 10837d755414SSenthil Balasubramanian sc->debug.stats.rxstats.rs_antenna = rs->rs_antenna; 10847d755414SSenthil Balasubramanian 1085cf3af748SRajkumar Manoharan spin_lock(&sc->debug.samp_lock); 1086cf3af748SRajkumar Manoharan RX_SAMP_DBG(jiffies) = jiffies; 1087cf3af748SRajkumar Manoharan RX_SAMP_DBG(rssi_ctl0) = rs->rs_rssi_ctl0; 1088cf3af748SRajkumar Manoharan RX_SAMP_DBG(rssi_ctl1) = rs->rs_rssi_ctl1; 1089cf3af748SRajkumar Manoharan RX_SAMP_DBG(rssi_ctl2) = rs->rs_rssi_ctl2; 1090cf3af748SRajkumar Manoharan RX_SAMP_DBG(rssi_ext0) = rs->rs_rssi_ext0; 1091cf3af748SRajkumar Manoharan RX_SAMP_DBG(rssi_ext1) = rs->rs_rssi_ext1; 1092cf3af748SRajkumar Manoharan RX_SAMP_DBG(rssi_ext2) = rs->rs_rssi_ext2; 1093cf3af748SRajkumar Manoharan RX_SAMP_DBG(antenna) = rs->rs_antenna; 1094cf3af748SRajkumar Manoharan RX_SAMP_DBG(rssi) = rs->rs_rssi; 1095cf3af748SRajkumar Manoharan RX_SAMP_DBG(rate) = rs->rs_rate; 1096cf3af748SRajkumar Manoharan RX_SAMP_DBG(is_mybeacon) = rs->is_mybeacon; 1097cf3af748SRajkumar Manoharan 1098cf3af748SRajkumar Manoharan sc->debug.rsidx = (sc->debug.rsidx + 1) % ATH_DBG_MAX_SAMPLES; 1099cf3af748SRajkumar Manoharan spin_unlock(&sc->debug.samp_lock); 1100cf3af748SRajkumar Manoharan 11011395d3f0SSujith #undef RX_STAT_INC 11021395d3f0SSujith #undef RX_PHY_ERR_INC 1103cf3af748SRajkumar Manoharan #undef RX_SAMP_DBG 11041395d3f0SSujith } 11051395d3f0SSujith 11061395d3f0SSujith static const struct file_operations fops_recv = { 11071395d3f0SSujith .read = read_file_recv, 11081395d3f0SSujith .open = ath9k_debugfs_open, 11096038f373SArnd Bergmann .owner = THIS_MODULE, 11106038f373SArnd Bergmann .llseek = default_llseek, 11111395d3f0SSujith }; 11121395d3f0SSujith 11139bff0bc4SFelix Fietkau static ssize_t read_file_regidx(struct file *file, char __user *user_buf, 11149bff0bc4SFelix Fietkau size_t count, loff_t *ppos) 11159bff0bc4SFelix Fietkau { 11169bff0bc4SFelix Fietkau struct ath_softc *sc = file->private_data; 11179bff0bc4SFelix Fietkau char buf[32]; 11189bff0bc4SFelix Fietkau unsigned int len; 11199bff0bc4SFelix Fietkau 11202b87f3aaSDan Carpenter len = sprintf(buf, "0x%08x\n", sc->debug.regidx); 11219bff0bc4SFelix Fietkau return simple_read_from_buffer(user_buf, count, ppos, buf, len); 11229bff0bc4SFelix Fietkau } 11239bff0bc4SFelix Fietkau 11249bff0bc4SFelix Fietkau static ssize_t write_file_regidx(struct file *file, const char __user *user_buf, 11259bff0bc4SFelix Fietkau size_t count, loff_t *ppos) 11269bff0bc4SFelix Fietkau { 11279bff0bc4SFelix Fietkau struct ath_softc *sc = file->private_data; 11289bff0bc4SFelix Fietkau unsigned long regidx; 11299bff0bc4SFelix Fietkau char buf[32]; 11309bff0bc4SFelix Fietkau ssize_t len; 11319bff0bc4SFelix Fietkau 11329bff0bc4SFelix Fietkau len = min(count, sizeof(buf) - 1); 11339bff0bc4SFelix Fietkau if (copy_from_user(buf, user_buf, len)) 113404236066SDan Carpenter return -EFAULT; 11359bff0bc4SFelix Fietkau 11369bff0bc4SFelix Fietkau buf[len] = '\0'; 11379bff0bc4SFelix Fietkau if (strict_strtoul(buf, 0, ®idx)) 11389bff0bc4SFelix Fietkau return -EINVAL; 11399bff0bc4SFelix Fietkau 11409bff0bc4SFelix Fietkau sc->debug.regidx = regidx; 11419bff0bc4SFelix Fietkau return count; 11429bff0bc4SFelix Fietkau } 11439bff0bc4SFelix Fietkau 11449bff0bc4SFelix Fietkau static const struct file_operations fops_regidx = { 11459bff0bc4SFelix Fietkau .read = read_file_regidx, 11469bff0bc4SFelix Fietkau .write = write_file_regidx, 11479bff0bc4SFelix Fietkau .open = ath9k_debugfs_open, 11486038f373SArnd Bergmann .owner = THIS_MODULE, 11496038f373SArnd Bergmann .llseek = default_llseek, 11509bff0bc4SFelix Fietkau }; 11519bff0bc4SFelix Fietkau 11529bff0bc4SFelix Fietkau static ssize_t read_file_regval(struct file *file, char __user *user_buf, 11539bff0bc4SFelix Fietkau size_t count, loff_t *ppos) 11549bff0bc4SFelix Fietkau { 11559bff0bc4SFelix Fietkau struct ath_softc *sc = file->private_data; 11569bff0bc4SFelix Fietkau struct ath_hw *ah = sc->sc_ah; 11579bff0bc4SFelix Fietkau char buf[32]; 11589bff0bc4SFelix Fietkau unsigned int len; 11599bff0bc4SFelix Fietkau u32 regval; 11609bff0bc4SFelix Fietkau 116179d2b157SRajkumar Manoharan ath9k_ps_wakeup(sc); 11629bff0bc4SFelix Fietkau regval = REG_READ_D(ah, sc->debug.regidx); 116379d2b157SRajkumar Manoharan ath9k_ps_restore(sc); 11642b87f3aaSDan Carpenter len = sprintf(buf, "0x%08x\n", regval); 11659bff0bc4SFelix Fietkau return simple_read_from_buffer(user_buf, count, ppos, buf, len); 11669bff0bc4SFelix Fietkau } 11679bff0bc4SFelix Fietkau 11689bff0bc4SFelix Fietkau static ssize_t write_file_regval(struct file *file, const char __user *user_buf, 11699bff0bc4SFelix Fietkau size_t count, loff_t *ppos) 11709bff0bc4SFelix Fietkau { 11719bff0bc4SFelix Fietkau struct ath_softc *sc = file->private_data; 11729bff0bc4SFelix Fietkau struct ath_hw *ah = sc->sc_ah; 11739bff0bc4SFelix Fietkau unsigned long regval; 11749bff0bc4SFelix Fietkau char buf[32]; 11759bff0bc4SFelix Fietkau ssize_t len; 11769bff0bc4SFelix Fietkau 11779bff0bc4SFelix Fietkau len = min(count, sizeof(buf) - 1); 11789bff0bc4SFelix Fietkau if (copy_from_user(buf, user_buf, len)) 117904236066SDan Carpenter return -EFAULT; 11809bff0bc4SFelix Fietkau 11819bff0bc4SFelix Fietkau buf[len] = '\0'; 11829bff0bc4SFelix Fietkau if (strict_strtoul(buf, 0, ®val)) 11839bff0bc4SFelix Fietkau return -EINVAL; 11849bff0bc4SFelix Fietkau 118579d2b157SRajkumar Manoharan ath9k_ps_wakeup(sc); 11869bff0bc4SFelix Fietkau REG_WRITE_D(ah, sc->debug.regidx, regval); 118779d2b157SRajkumar Manoharan ath9k_ps_restore(sc); 11889bff0bc4SFelix Fietkau return count; 11899bff0bc4SFelix Fietkau } 11909bff0bc4SFelix Fietkau 11919bff0bc4SFelix Fietkau static const struct file_operations fops_regval = { 11929bff0bc4SFelix Fietkau .read = read_file_regval, 11939bff0bc4SFelix Fietkau .write = write_file_regval, 11949bff0bc4SFelix Fietkau .open = ath9k_debugfs_open, 11956038f373SArnd Bergmann .owner = THIS_MODULE, 11966038f373SArnd Bergmann .llseek = default_llseek, 11979bff0bc4SFelix Fietkau }; 11989bff0bc4SFelix Fietkau 1199582d0064SVasanthakumar Thiagarajan #define REGDUMP_LINE_SIZE 20 1200582d0064SVasanthakumar Thiagarajan 1201582d0064SVasanthakumar Thiagarajan static int open_file_regdump(struct inode *inode, struct file *file) 1202582d0064SVasanthakumar Thiagarajan { 1203582d0064SVasanthakumar Thiagarajan struct ath_softc *sc = inode->i_private; 1204582d0064SVasanthakumar Thiagarajan unsigned int len = 0; 1205582d0064SVasanthakumar Thiagarajan u8 *buf; 1206582d0064SVasanthakumar Thiagarajan int i; 1207582d0064SVasanthakumar Thiagarajan unsigned long num_regs, regdump_len, max_reg_offset; 1208582d0064SVasanthakumar Thiagarajan 1209582d0064SVasanthakumar Thiagarajan max_reg_offset = AR_SREV_9300_20_OR_LATER(sc->sc_ah) ? 0x16bd4 : 0xb500; 1210582d0064SVasanthakumar Thiagarajan num_regs = max_reg_offset / 4 + 1; 1211582d0064SVasanthakumar Thiagarajan regdump_len = num_regs * REGDUMP_LINE_SIZE + 1; 1212582d0064SVasanthakumar Thiagarajan buf = vmalloc(regdump_len); 1213582d0064SVasanthakumar Thiagarajan if (!buf) 1214582d0064SVasanthakumar Thiagarajan return -ENOMEM; 1215582d0064SVasanthakumar Thiagarajan 1216582d0064SVasanthakumar Thiagarajan ath9k_ps_wakeup(sc); 1217582d0064SVasanthakumar Thiagarajan for (i = 0; i < num_regs; i++) 1218582d0064SVasanthakumar Thiagarajan len += scnprintf(buf + len, regdump_len - len, 1219582d0064SVasanthakumar Thiagarajan "0x%06x 0x%08x\n", i << 2, REG_READ(sc->sc_ah, i << 2)); 1220582d0064SVasanthakumar Thiagarajan ath9k_ps_restore(sc); 1221582d0064SVasanthakumar Thiagarajan 1222582d0064SVasanthakumar Thiagarajan file->private_data = buf; 1223582d0064SVasanthakumar Thiagarajan 1224582d0064SVasanthakumar Thiagarajan return 0; 1225582d0064SVasanthakumar Thiagarajan } 1226582d0064SVasanthakumar Thiagarajan 1227582d0064SVasanthakumar Thiagarajan static const struct file_operations fops_regdump = { 1228582d0064SVasanthakumar Thiagarajan .open = open_file_regdump, 1229582d0064SVasanthakumar Thiagarajan .read = ath9k_debugfs_read_buf, 1230582d0064SVasanthakumar Thiagarajan .release = ath9k_debugfs_release_buf, 1231582d0064SVasanthakumar Thiagarajan .owner = THIS_MODULE, 1232582d0064SVasanthakumar Thiagarajan .llseek = default_llseek,/* read accesses f_pos */ 1233582d0064SVasanthakumar Thiagarajan }; 1234582d0064SVasanthakumar Thiagarajan 1235d069a46bSRajkumar Manoharan static ssize_t read_file_dump_nfcal(struct file *file, char __user *user_buf, 1236d069a46bSRajkumar Manoharan size_t count, loff_t *ppos) 1237d069a46bSRajkumar Manoharan { 1238d069a46bSRajkumar Manoharan struct ath_softc *sc = file->private_data; 1239d069a46bSRajkumar Manoharan struct ath_hw *ah = sc->sc_ah; 1240d069a46bSRajkumar Manoharan struct ath9k_nfcal_hist *h = sc->caldata.nfCalHist; 1241d069a46bSRajkumar Manoharan struct ath_common *common = ath9k_hw_common(ah); 1242d069a46bSRajkumar Manoharan struct ieee80211_conf *conf = &common->hw->conf; 1243d069a46bSRajkumar Manoharan u32 len = 0, size = 1500; 1244d069a46bSRajkumar Manoharan u32 i, j; 1245d069a46bSRajkumar Manoharan ssize_t retval = 0; 1246d069a46bSRajkumar Manoharan char *buf; 1247d069a46bSRajkumar Manoharan u8 chainmask = (ah->rxchainmask << 3) | ah->rxchainmask; 1248d069a46bSRajkumar Manoharan u8 nread; 1249d069a46bSRajkumar Manoharan 1250d069a46bSRajkumar Manoharan buf = kzalloc(size, GFP_KERNEL); 1251d069a46bSRajkumar Manoharan if (!buf) 1252d069a46bSRajkumar Manoharan return -ENOMEM; 1253d069a46bSRajkumar Manoharan 1254d069a46bSRajkumar Manoharan len += snprintf(buf + len, size - len, 1255d069a46bSRajkumar Manoharan "Channel Noise Floor : %d\n", ah->noise); 1256d069a46bSRajkumar Manoharan len += snprintf(buf + len, size - len, 1257d069a46bSRajkumar Manoharan "Chain | privNF | # Readings | NF Readings\n"); 1258d069a46bSRajkumar Manoharan for (i = 0; i < NUM_NF_READINGS; i++) { 1259d069a46bSRajkumar Manoharan if (!(chainmask & (1 << i)) || 1260d069a46bSRajkumar Manoharan ((i >= AR5416_MAX_CHAINS) && !conf_is_ht40(conf))) 1261d069a46bSRajkumar Manoharan continue; 1262d069a46bSRajkumar Manoharan 1263d069a46bSRajkumar Manoharan nread = AR_PHY_CCA_FILTERWINDOW_LENGTH - h[i].invalidNFcount; 1264d069a46bSRajkumar Manoharan len += snprintf(buf + len, size - len, " %d\t %d\t %d\t\t", 1265d069a46bSRajkumar Manoharan i, h[i].privNF, nread); 1266d069a46bSRajkumar Manoharan for (j = 0; j < nread; j++) 1267d069a46bSRajkumar Manoharan len += snprintf(buf + len, size - len, 1268d069a46bSRajkumar Manoharan " %d", h[i].nfCalBuffer[j]); 1269d069a46bSRajkumar Manoharan len += snprintf(buf + len, size - len, "\n"); 1270d069a46bSRajkumar Manoharan } 1271d069a46bSRajkumar Manoharan 1272d069a46bSRajkumar Manoharan if (len > size) 1273d069a46bSRajkumar Manoharan len = size; 1274d069a46bSRajkumar Manoharan 1275d069a46bSRajkumar Manoharan retval = simple_read_from_buffer(user_buf, count, ppos, buf, len); 1276d069a46bSRajkumar Manoharan kfree(buf); 1277d069a46bSRajkumar Manoharan 1278d069a46bSRajkumar Manoharan return retval; 1279d069a46bSRajkumar Manoharan } 1280d069a46bSRajkumar Manoharan 1281d069a46bSRajkumar Manoharan static const struct file_operations fops_dump_nfcal = { 1282d069a46bSRajkumar Manoharan .read = read_file_dump_nfcal, 1283d069a46bSRajkumar Manoharan .open = ath9k_debugfs_open, 1284d069a46bSRajkumar Manoharan .owner = THIS_MODULE, 1285d069a46bSRajkumar Manoharan .llseek = default_llseek, 1286d069a46bSRajkumar Manoharan }; 1287d069a46bSRajkumar Manoharan 1288580f010fSRajkumar Manoharan static ssize_t read_file_base_eeprom(struct file *file, char __user *user_buf, 1289580f010fSRajkumar Manoharan size_t count, loff_t *ppos) 1290580f010fSRajkumar Manoharan { 1291580f010fSRajkumar Manoharan struct ath_softc *sc = file->private_data; 1292580f010fSRajkumar Manoharan struct ath_hw *ah = sc->sc_ah; 1293580f010fSRajkumar Manoharan u32 len = 0, size = 1500; 1294580f010fSRajkumar Manoharan ssize_t retval = 0; 1295580f010fSRajkumar Manoharan char *buf; 1296580f010fSRajkumar Manoharan 1297580f010fSRajkumar Manoharan buf = kzalloc(size, GFP_KERNEL); 1298580f010fSRajkumar Manoharan if (!buf) 1299580f010fSRajkumar Manoharan return -ENOMEM; 1300580f010fSRajkumar Manoharan 1301580f010fSRajkumar Manoharan len = ah->eep_ops->dump_eeprom(ah, true, buf, len, size); 1302580f010fSRajkumar Manoharan 1303580f010fSRajkumar Manoharan retval = simple_read_from_buffer(user_buf, count, ppos, buf, len); 1304580f010fSRajkumar Manoharan kfree(buf); 1305580f010fSRajkumar Manoharan 1306580f010fSRajkumar Manoharan return retval; 1307580f010fSRajkumar Manoharan } 1308580f010fSRajkumar Manoharan 1309580f010fSRajkumar Manoharan static const struct file_operations fops_base_eeprom = { 1310580f010fSRajkumar Manoharan .read = read_file_base_eeprom, 1311580f010fSRajkumar Manoharan .open = ath9k_debugfs_open, 1312580f010fSRajkumar Manoharan .owner = THIS_MODULE, 1313580f010fSRajkumar Manoharan .llseek = default_llseek, 1314580f010fSRajkumar Manoharan }; 1315580f010fSRajkumar Manoharan 13163f4c4bddSRajkumar Manoharan static ssize_t read_file_modal_eeprom(struct file *file, char __user *user_buf, 13173f4c4bddSRajkumar Manoharan size_t count, loff_t *ppos) 13183f4c4bddSRajkumar Manoharan { 13193f4c4bddSRajkumar Manoharan struct ath_softc *sc = file->private_data; 13203f4c4bddSRajkumar Manoharan struct ath_hw *ah = sc->sc_ah; 13213f4c4bddSRajkumar Manoharan u32 len = 0, size = 6000; 13223f4c4bddSRajkumar Manoharan char *buf; 13233f4c4bddSRajkumar Manoharan size_t retval; 13243f4c4bddSRajkumar Manoharan 13253f4c4bddSRajkumar Manoharan buf = kzalloc(size, GFP_KERNEL); 13263f4c4bddSRajkumar Manoharan if (buf == NULL) 13273f4c4bddSRajkumar Manoharan return -ENOMEM; 13283f4c4bddSRajkumar Manoharan 13293f4c4bddSRajkumar Manoharan len = ah->eep_ops->dump_eeprom(ah, false, buf, len, size); 13303f4c4bddSRajkumar Manoharan 13313f4c4bddSRajkumar Manoharan retval = simple_read_from_buffer(user_buf, count, ppos, buf, len); 13323f4c4bddSRajkumar Manoharan kfree(buf); 13333f4c4bddSRajkumar Manoharan 13343f4c4bddSRajkumar Manoharan return retval; 13353f4c4bddSRajkumar Manoharan } 13363f4c4bddSRajkumar Manoharan 13373f4c4bddSRajkumar Manoharan static const struct file_operations fops_modal_eeprom = { 13383f4c4bddSRajkumar Manoharan .read = read_file_modal_eeprom, 13393f4c4bddSRajkumar Manoharan .open = ath9k_debugfs_open, 13403f4c4bddSRajkumar Manoharan .owner = THIS_MODULE, 13413f4c4bddSRajkumar Manoharan .llseek = default_llseek, 13423f4c4bddSRajkumar Manoharan }; 13433f4c4bddSRajkumar Manoharan 1344cf3af748SRajkumar Manoharan void ath9k_debug_samp_bb_mac(struct ath_softc *sc) 1345cf3af748SRajkumar Manoharan { 1346cf3af748SRajkumar Manoharan #define ATH_SAMP_DBG(c) (sc->debug.bb_mac_samp[sc->debug.sampidx].c) 1347cf3af748SRajkumar Manoharan struct ath_hw *ah = sc->sc_ah; 1348cf3af748SRajkumar Manoharan struct ath_common *common = ath9k_hw_common(ah); 1349cf3af748SRajkumar Manoharan unsigned long flags; 1350cf3af748SRajkumar Manoharan int i; 1351cf3af748SRajkumar Manoharan 1352cf3af748SRajkumar Manoharan ath9k_ps_wakeup(sc); 1353cf3af748SRajkumar Manoharan 13546bc05a95SRajkumar Manoharan spin_lock_bh(&sc->debug.samp_lock); 13556bc05a95SRajkumar Manoharan 1356cf3af748SRajkumar Manoharan spin_lock_irqsave(&common->cc_lock, flags); 1357cf3af748SRajkumar Manoharan ath_hw_cycle_counters_update(common); 1358cf3af748SRajkumar Manoharan 1359cf3af748SRajkumar Manoharan ATH_SAMP_DBG(cc.cycles) = common->cc_ani.cycles; 1360cf3af748SRajkumar Manoharan ATH_SAMP_DBG(cc.rx_busy) = common->cc_ani.rx_busy; 1361cf3af748SRajkumar Manoharan ATH_SAMP_DBG(cc.rx_frame) = common->cc_ani.rx_frame; 1362cf3af748SRajkumar Manoharan ATH_SAMP_DBG(cc.tx_frame) = common->cc_ani.tx_frame; 13636bc05a95SRajkumar Manoharan spin_unlock_irqrestore(&common->cc_lock, flags); 13646bc05a95SRajkumar Manoharan 1365cf3af748SRajkumar Manoharan ATH_SAMP_DBG(noise) = ah->noise; 1366cf3af748SRajkumar Manoharan 1367cf3af748SRajkumar Manoharan REG_WRITE_D(ah, AR_MACMISC, 1368cf3af748SRajkumar Manoharan ((AR_MACMISC_DMA_OBS_LINE_8 << AR_MACMISC_DMA_OBS_S) | 1369cf3af748SRajkumar Manoharan (AR_MACMISC_MISC_OBS_BUS_1 << 1370cf3af748SRajkumar Manoharan AR_MACMISC_MISC_OBS_BUS_MSB_S))); 1371cf3af748SRajkumar Manoharan 1372cf3af748SRajkumar Manoharan for (i = 0; i < ATH9K_NUM_DMA_DEBUG_REGS; i++) 1373cf3af748SRajkumar Manoharan ATH_SAMP_DBG(dma_dbg_reg_vals[i]) = REG_READ_D(ah, 1374cf3af748SRajkumar Manoharan AR_DMADBG_0 + (i * sizeof(u32))); 1375cf3af748SRajkumar Manoharan 1376cf3af748SRajkumar Manoharan ATH_SAMP_DBG(pcu_obs) = REG_READ_D(ah, AR_OBS_BUS_1); 1377cf3af748SRajkumar Manoharan ATH_SAMP_DBG(pcu_cr) = REG_READ_D(ah, AR_CR); 1378cf3af748SRajkumar Manoharan 1379cf3af748SRajkumar Manoharan memcpy(ATH_SAMP_DBG(nfCalHist), sc->caldata.nfCalHist, 1380cf3af748SRajkumar Manoharan sizeof(ATH_SAMP_DBG(nfCalHist))); 1381cf3af748SRajkumar Manoharan 1382cf3af748SRajkumar Manoharan sc->debug.sampidx = (sc->debug.sampidx + 1) % ATH_DBG_MAX_SAMPLES; 1383cf3af748SRajkumar Manoharan spin_unlock_bh(&sc->debug.samp_lock); 1384cf3af748SRajkumar Manoharan ath9k_ps_restore(sc); 1385cf3af748SRajkumar Manoharan 1386cf3af748SRajkumar Manoharan #undef ATH_SAMP_DBG 1387cf3af748SRajkumar Manoharan } 1388cf3af748SRajkumar Manoharan 1389cf3af748SRajkumar Manoharan static int open_file_bb_mac_samps(struct inode *inode, struct file *file) 1390cf3af748SRajkumar Manoharan { 1391cf3af748SRajkumar Manoharan #define ATH_SAMP_DBG(c) bb_mac_samp[sampidx].c 1392cf3af748SRajkumar Manoharan struct ath_softc *sc = inode->i_private; 1393cf3af748SRajkumar Manoharan struct ath_hw *ah = sc->sc_ah; 1394cf3af748SRajkumar Manoharan struct ath_common *common = ath9k_hw_common(ah); 1395cf3af748SRajkumar Manoharan struct ieee80211_conf *conf = &common->hw->conf; 1396cf3af748SRajkumar Manoharan struct ath_dbg_bb_mac_samp *bb_mac_samp; 1397cf3af748SRajkumar Manoharan struct ath9k_nfcal_hist *h; 1398cf3af748SRajkumar Manoharan int i, j, qcuOffset = 0, dcuOffset = 0; 1399cf3af748SRajkumar Manoharan u32 *qcuBase, *dcuBase, size = 30000, len = 0; 1400cf3af748SRajkumar Manoharan u32 sampidx = 0; 1401cf3af748SRajkumar Manoharan u8 *buf; 1402cf3af748SRajkumar Manoharan u8 chainmask = (ah->rxchainmask << 3) | ah->rxchainmask; 1403cf3af748SRajkumar Manoharan u8 nread; 1404cf3af748SRajkumar Manoharan 1405f7e014daSRajkumar Manoharan if (sc->sc_flags & SC_OP_INVALID) 1406f7e014daSRajkumar Manoharan return -EAGAIN; 1407f7e014daSRajkumar Manoharan 1408cf3af748SRajkumar Manoharan buf = vmalloc(size); 1409cf3af748SRajkumar Manoharan if (!buf) 1410cf3af748SRajkumar Manoharan return -ENOMEM; 1411cf3af748SRajkumar Manoharan bb_mac_samp = vmalloc(sizeof(*bb_mac_samp) * ATH_DBG_MAX_SAMPLES); 1412cf3af748SRajkumar Manoharan if (!bb_mac_samp) { 1413cf3af748SRajkumar Manoharan vfree(buf); 1414cf3af748SRajkumar Manoharan return -ENOMEM; 1415cf3af748SRajkumar Manoharan } 1416f7e014daSRajkumar Manoharan /* Account the current state too */ 1417f7e014daSRajkumar Manoharan ath9k_debug_samp_bb_mac(sc); 1418cf3af748SRajkumar Manoharan 1419cf3af748SRajkumar Manoharan spin_lock_bh(&sc->debug.samp_lock); 1420cf3af748SRajkumar Manoharan memcpy(bb_mac_samp, sc->debug.bb_mac_samp, 1421cf3af748SRajkumar Manoharan sizeof(*bb_mac_samp) * ATH_DBG_MAX_SAMPLES); 14226bc05a95SRajkumar Manoharan len += snprintf(buf + len, size - len, 14236bc05a95SRajkumar Manoharan "Current Sample Index: %d\n", sc->debug.sampidx); 1424cf3af748SRajkumar Manoharan spin_unlock_bh(&sc->debug.samp_lock); 1425cf3af748SRajkumar Manoharan 1426cf3af748SRajkumar Manoharan len += snprintf(buf + len, size - len, 1427cf3af748SRajkumar Manoharan "Raw DMA Debug Dump:\n"); 1428cf3af748SRajkumar Manoharan len += snprintf(buf + len, size - len, "Sample |\t"); 1429cf3af748SRajkumar Manoharan for (i = 0; i < ATH9K_NUM_DMA_DEBUG_REGS; i++) 1430cf3af748SRajkumar Manoharan len += snprintf(buf + len, size - len, " DMA Reg%d |\t", i); 1431cf3af748SRajkumar Manoharan len += snprintf(buf + len, size - len, "\n"); 1432cf3af748SRajkumar Manoharan 1433cf3af748SRajkumar Manoharan for (sampidx = 0; sampidx < ATH_DBG_MAX_SAMPLES; sampidx++) { 1434cf3af748SRajkumar Manoharan len += snprintf(buf + len, size - len, "%d\t", sampidx); 1435cf3af748SRajkumar Manoharan 1436cf3af748SRajkumar Manoharan for (i = 0; i < ATH9K_NUM_DMA_DEBUG_REGS; i++) 1437cf3af748SRajkumar Manoharan len += snprintf(buf + len, size - len, " %08x\t", 1438cf3af748SRajkumar Manoharan ATH_SAMP_DBG(dma_dbg_reg_vals[i])); 1439cf3af748SRajkumar Manoharan len += snprintf(buf + len, size - len, "\n"); 1440cf3af748SRajkumar Manoharan } 1441cf3af748SRajkumar Manoharan len += snprintf(buf + len, size - len, "\n"); 1442cf3af748SRajkumar Manoharan 1443cf3af748SRajkumar Manoharan len += snprintf(buf + len, size - len, 1444cf3af748SRajkumar Manoharan "Sample Num QCU: chain_st fsp_ok fsp_st DCU: chain_st\n"); 1445cf3af748SRajkumar Manoharan for (sampidx = 0; sampidx < ATH_DBG_MAX_SAMPLES; sampidx++) { 1446cf3af748SRajkumar Manoharan qcuBase = &ATH_SAMP_DBG(dma_dbg_reg_vals[0]); 1447cf3af748SRajkumar Manoharan dcuBase = &ATH_SAMP_DBG(dma_dbg_reg_vals[4]); 1448cf3af748SRajkumar Manoharan 1449cf3af748SRajkumar Manoharan for (i = 0; i < ATH9K_NUM_QUEUES; i++, 1450cf3af748SRajkumar Manoharan qcuOffset += 4, dcuOffset += 5) { 1451cf3af748SRajkumar Manoharan if (i == 8) { 1452cf3af748SRajkumar Manoharan qcuOffset = 0; 1453cf3af748SRajkumar Manoharan qcuBase++; 1454cf3af748SRajkumar Manoharan } 1455cf3af748SRajkumar Manoharan 1456cf3af748SRajkumar Manoharan if (i == 6) { 1457cf3af748SRajkumar Manoharan dcuOffset = 0; 1458cf3af748SRajkumar Manoharan dcuBase++; 1459cf3af748SRajkumar Manoharan } 1460cf3af748SRajkumar Manoharan if (!sc->debug.stats.txstats[i].queued) 1461cf3af748SRajkumar Manoharan continue; 1462cf3af748SRajkumar Manoharan 1463cf3af748SRajkumar Manoharan len += snprintf(buf + len, size - len, 1464cf3af748SRajkumar Manoharan "%4d %7d %2x %1x %2x %2x\n", 1465cf3af748SRajkumar Manoharan sampidx, i, 1466cf3af748SRajkumar Manoharan (*qcuBase & (0x7 << qcuOffset)) >> qcuOffset, 1467cf3af748SRajkumar Manoharan (*qcuBase & (0x8 << qcuOffset)) >> 1468cf3af748SRajkumar Manoharan (qcuOffset + 3), 1469cf3af748SRajkumar Manoharan ATH_SAMP_DBG(dma_dbg_reg_vals[2]) & 1470cf3af748SRajkumar Manoharan (0x7 << (i * 3)) >> (i * 3), 1471cf3af748SRajkumar Manoharan (*dcuBase & (0x1f << dcuOffset)) >> dcuOffset); 1472cf3af748SRajkumar Manoharan } 1473cf3af748SRajkumar Manoharan len += snprintf(buf + len, size - len, "\n"); 1474cf3af748SRajkumar Manoharan } 1475cf3af748SRajkumar Manoharan len += snprintf(buf + len, size - len, 1476cf3af748SRajkumar Manoharan "samp qcu_sh qcu_fh qcu_comp dcu_comp dcu_arb dcu_fp " 1477cf3af748SRajkumar Manoharan "ch_idle_dur ch_idle_dur_val txfifo_val0 txfifo_val1 " 1478cf3af748SRajkumar Manoharan "txfifo_dcu0 txfifo_dcu1 pcu_obs AR_CR\n"); 1479cf3af748SRajkumar Manoharan 1480cf3af748SRajkumar Manoharan for (sampidx = 0; sampidx < ATH_DBG_MAX_SAMPLES; sampidx++) { 1481cf3af748SRajkumar Manoharan qcuBase = &ATH_SAMP_DBG(dma_dbg_reg_vals[0]); 1482cf3af748SRajkumar Manoharan dcuBase = &ATH_SAMP_DBG(dma_dbg_reg_vals[4]); 1483cf3af748SRajkumar Manoharan 1484cf3af748SRajkumar Manoharan len += snprintf(buf + len, size - len, "%4d %5x %5x ", sampidx, 1485cf3af748SRajkumar Manoharan (ATH_SAMP_DBG(dma_dbg_reg_vals[3]) & 0x003c0000) >> 18, 1486cf3af748SRajkumar Manoharan (ATH_SAMP_DBG(dma_dbg_reg_vals[3]) & 0x03c00000) >> 22); 1487cf3af748SRajkumar Manoharan len += snprintf(buf + len, size - len, "%7x %8x ", 1488cf3af748SRajkumar Manoharan (ATH_SAMP_DBG(dma_dbg_reg_vals[3]) & 0x1c000000) >> 26, 1489cf3af748SRajkumar Manoharan (ATH_SAMP_DBG(dma_dbg_reg_vals[6]) & 0x3)); 1490cf3af748SRajkumar Manoharan len += snprintf(buf + len, size - len, "%7x %7x ", 1491cf3af748SRajkumar Manoharan (ATH_SAMP_DBG(dma_dbg_reg_vals[5]) & 0x06000000) >> 25, 1492cf3af748SRajkumar Manoharan (ATH_SAMP_DBG(dma_dbg_reg_vals[5]) & 0x38000000) >> 27); 1493cf3af748SRajkumar Manoharan len += snprintf(buf + len, size - len, "%7d %12d ", 1494cf3af748SRajkumar Manoharan (ATH_SAMP_DBG(dma_dbg_reg_vals[6]) & 0x000003fc) >> 2, 1495cf3af748SRajkumar Manoharan (ATH_SAMP_DBG(dma_dbg_reg_vals[6]) & 0x00000400) >> 10); 1496cf3af748SRajkumar Manoharan len += snprintf(buf + len, size - len, "%12d %12d ", 1497cf3af748SRajkumar Manoharan (ATH_SAMP_DBG(dma_dbg_reg_vals[6]) & 0x00000800) >> 11, 1498cf3af748SRajkumar Manoharan (ATH_SAMP_DBG(dma_dbg_reg_vals[6]) & 0x00001000) >> 12); 1499cf3af748SRajkumar Manoharan len += snprintf(buf + len, size - len, "%12d %12d ", 1500cf3af748SRajkumar Manoharan (ATH_SAMP_DBG(dma_dbg_reg_vals[6]) & 0x0001e000) >> 13, 1501cf3af748SRajkumar Manoharan (ATH_SAMP_DBG(dma_dbg_reg_vals[6]) & 0x001e0000) >> 17); 1502cf3af748SRajkumar Manoharan len += snprintf(buf + len, size - len, "0x%07x 0x%07x\n", 1503cf3af748SRajkumar Manoharan ATH_SAMP_DBG(pcu_obs), ATH_SAMP_DBG(pcu_cr)); 1504cf3af748SRajkumar Manoharan } 1505cf3af748SRajkumar Manoharan 1506cf3af748SRajkumar Manoharan len += snprintf(buf + len, size - len, 1507cf3af748SRajkumar Manoharan "Sample ChNoise Chain privNF #Reading Readings\n"); 1508cf3af748SRajkumar Manoharan for (sampidx = 0; sampidx < ATH_DBG_MAX_SAMPLES; sampidx++) { 1509cf3af748SRajkumar Manoharan h = ATH_SAMP_DBG(nfCalHist); 1510cf3af748SRajkumar Manoharan if (!ATH_SAMP_DBG(noise)) 1511cf3af748SRajkumar Manoharan continue; 1512cf3af748SRajkumar Manoharan 1513cf3af748SRajkumar Manoharan for (i = 0; i < NUM_NF_READINGS; i++) { 1514cf3af748SRajkumar Manoharan if (!(chainmask & (1 << i)) || 1515cf3af748SRajkumar Manoharan ((i >= AR5416_MAX_CHAINS) && !conf_is_ht40(conf))) 1516cf3af748SRajkumar Manoharan continue; 1517cf3af748SRajkumar Manoharan 1518cf3af748SRajkumar Manoharan nread = AR_PHY_CCA_FILTERWINDOW_LENGTH - 1519cf3af748SRajkumar Manoharan h[i].invalidNFcount; 1520cf3af748SRajkumar Manoharan len += snprintf(buf + len, size - len, 1521cf3af748SRajkumar Manoharan "%4d %5d %4d\t %d\t %d\t", 1522cf3af748SRajkumar Manoharan sampidx, ATH_SAMP_DBG(noise), 1523cf3af748SRajkumar Manoharan i, h[i].privNF, nread); 1524cf3af748SRajkumar Manoharan for (j = 0; j < nread; j++) 1525cf3af748SRajkumar Manoharan len += snprintf(buf + len, size - len, 1526cf3af748SRajkumar Manoharan " %d", h[i].nfCalBuffer[j]); 1527cf3af748SRajkumar Manoharan len += snprintf(buf + len, size - len, "\n"); 1528cf3af748SRajkumar Manoharan } 1529cf3af748SRajkumar Manoharan } 1530cf3af748SRajkumar Manoharan len += snprintf(buf + len, size - len, "\nCycle counters:\n" 1531cf3af748SRajkumar Manoharan "Sample Total Rxbusy Rxframes Txframes\n"); 1532cf3af748SRajkumar Manoharan for (sampidx = 0; sampidx < ATH_DBG_MAX_SAMPLES; sampidx++) { 1533cf3af748SRajkumar Manoharan if (!ATH_SAMP_DBG(cc.cycles)) 1534cf3af748SRajkumar Manoharan continue; 1535cf3af748SRajkumar Manoharan len += snprintf(buf + len, size - len, 1536cf3af748SRajkumar Manoharan "%4d %08x %08x %08x %08x\n", 1537cf3af748SRajkumar Manoharan sampidx, ATH_SAMP_DBG(cc.cycles), 1538cf3af748SRajkumar Manoharan ATH_SAMP_DBG(cc.rx_busy), 1539cf3af748SRajkumar Manoharan ATH_SAMP_DBG(cc.rx_frame), 1540cf3af748SRajkumar Manoharan ATH_SAMP_DBG(cc.tx_frame)); 1541cf3af748SRajkumar Manoharan } 1542cf3af748SRajkumar Manoharan 1543cf3af748SRajkumar Manoharan len += snprintf(buf + len, size - len, "Tx status Dump :\n"); 1544cf3af748SRajkumar Manoharan len += snprintf(buf + len, size - len, 1545cf3af748SRajkumar Manoharan "Sample rssi:- ctl0 ctl1 ctl2 ext0 ext1 ext2 comb " 154612932180SMohammed Shafi Shajakhan "isok rts_fail data_fail rate tid qid " 154712932180SMohammed Shafi Shajakhan "ba_low ba_high tx_before(ms)\n"); 1548cf3af748SRajkumar Manoharan for (sampidx = 0; sampidx < ATH_DBG_MAX_SAMPLES; sampidx++) { 1549cf3af748SRajkumar Manoharan for (i = 0; i < ATH_DBG_MAX_SAMPLES; i++) { 1550cf3af748SRajkumar Manoharan if (!ATH_SAMP_DBG(ts[i].jiffies)) 1551cf3af748SRajkumar Manoharan continue; 155212932180SMohammed Shafi Shajakhan len += snprintf(buf + len, size - len, "%-14d" 155312932180SMohammed Shafi Shajakhan "%-4d %-4d %-4d %-4d %-4d %-4d %-4d %-4d %-8d " 155412932180SMohammed Shafi Shajakhan "%-9d %-4d %-3d %-3d %08x %08x %-11d\n", 1555cf3af748SRajkumar Manoharan sampidx, 1556cf3af748SRajkumar Manoharan ATH_SAMP_DBG(ts[i].rssi_ctl0), 1557cf3af748SRajkumar Manoharan ATH_SAMP_DBG(ts[i].rssi_ctl1), 1558cf3af748SRajkumar Manoharan ATH_SAMP_DBG(ts[i].rssi_ctl2), 1559cf3af748SRajkumar Manoharan ATH_SAMP_DBG(ts[i].rssi_ext0), 1560cf3af748SRajkumar Manoharan ATH_SAMP_DBG(ts[i].rssi_ext1), 1561cf3af748SRajkumar Manoharan ATH_SAMP_DBG(ts[i].rssi_ext2), 1562cf3af748SRajkumar Manoharan ATH_SAMP_DBG(ts[i].rssi), 1563cf3af748SRajkumar Manoharan ATH_SAMP_DBG(ts[i].isok), 1564cf3af748SRajkumar Manoharan ATH_SAMP_DBG(ts[i].rts_fail_cnt), 1565cf3af748SRajkumar Manoharan ATH_SAMP_DBG(ts[i].data_fail_cnt), 1566cf3af748SRajkumar Manoharan ATH_SAMP_DBG(ts[i].rateindex), 1567cf3af748SRajkumar Manoharan ATH_SAMP_DBG(ts[i].tid), 1568cf3af748SRajkumar Manoharan ATH_SAMP_DBG(ts[i].qid), 156912932180SMohammed Shafi Shajakhan ATH_SAMP_DBG(ts[i].ba_low), 157012932180SMohammed Shafi Shajakhan ATH_SAMP_DBG(ts[i].ba_high), 1571cf3af748SRajkumar Manoharan jiffies_to_msecs(jiffies - 1572cf3af748SRajkumar Manoharan ATH_SAMP_DBG(ts[i].jiffies))); 1573cf3af748SRajkumar Manoharan } 1574cf3af748SRajkumar Manoharan } 1575cf3af748SRajkumar Manoharan 1576cf3af748SRajkumar Manoharan len += snprintf(buf + len, size - len, "Rx status Dump :\n"); 1577cf3af748SRajkumar Manoharan len += snprintf(buf + len, size - len, "Sample rssi:- ctl0 ctl1 ctl2 " 1578cf3af748SRajkumar Manoharan "ext0 ext1 ext2 comb beacon ant rate rx_before(ms)\n"); 1579cf3af748SRajkumar Manoharan for (sampidx = 0; sampidx < ATH_DBG_MAX_SAMPLES; sampidx++) { 1580cf3af748SRajkumar Manoharan for (i = 0; i < ATH_DBG_MAX_SAMPLES; i++) { 1581cf3af748SRajkumar Manoharan if (!ATH_SAMP_DBG(rs[i].jiffies)) 1582cf3af748SRajkumar Manoharan continue; 158312932180SMohammed Shafi Shajakhan len += snprintf(buf + len, size - len, "%-14d" 158412932180SMohammed Shafi Shajakhan "%-4d %-4d %-4d %-4d %-4d %-4d %-4d %-9s %-2d %02x %-13d\n", 1585cf3af748SRajkumar Manoharan sampidx, 1586cf3af748SRajkumar Manoharan ATH_SAMP_DBG(rs[i].rssi_ctl0), 1587cf3af748SRajkumar Manoharan ATH_SAMP_DBG(rs[i].rssi_ctl1), 1588cf3af748SRajkumar Manoharan ATH_SAMP_DBG(rs[i].rssi_ctl2), 1589cf3af748SRajkumar Manoharan ATH_SAMP_DBG(rs[i].rssi_ext0), 1590cf3af748SRajkumar Manoharan ATH_SAMP_DBG(rs[i].rssi_ext1), 1591cf3af748SRajkumar Manoharan ATH_SAMP_DBG(rs[i].rssi_ext2), 1592cf3af748SRajkumar Manoharan ATH_SAMP_DBG(rs[i].rssi), 1593cf3af748SRajkumar Manoharan ATH_SAMP_DBG(rs[i].is_mybeacon) ? 1594cf3af748SRajkumar Manoharan "True" : "False", 1595cf3af748SRajkumar Manoharan ATH_SAMP_DBG(rs[i].antenna), 1596cf3af748SRajkumar Manoharan ATH_SAMP_DBG(rs[i].rate), 1597cf3af748SRajkumar Manoharan jiffies_to_msecs(jiffies - 1598cf3af748SRajkumar Manoharan ATH_SAMP_DBG(rs[i].jiffies))); 1599cf3af748SRajkumar Manoharan } 1600cf3af748SRajkumar Manoharan } 1601cf3af748SRajkumar Manoharan 1602cf3af748SRajkumar Manoharan vfree(bb_mac_samp); 1603cf3af748SRajkumar Manoharan file->private_data = buf; 1604cf3af748SRajkumar Manoharan 1605cf3af748SRajkumar Manoharan return 0; 1606cf3af748SRajkumar Manoharan #undef ATH_SAMP_DBG 1607cf3af748SRajkumar Manoharan } 1608cf3af748SRajkumar Manoharan 1609cf3af748SRajkumar Manoharan static const struct file_operations fops_samps = { 1610cf3af748SRajkumar Manoharan .open = open_file_bb_mac_samps, 1611cf3af748SRajkumar Manoharan .read = ath9k_debugfs_read_buf, 1612cf3af748SRajkumar Manoharan .release = ath9k_debugfs_release_buf, 1613cf3af748SRajkumar Manoharan .owner = THIS_MODULE, 1614cf3af748SRajkumar Manoharan .llseek = default_llseek, 1615cf3af748SRajkumar Manoharan }; 1616cf3af748SRajkumar Manoharan 1617cf3af748SRajkumar Manoharan 16184d6b228dSLuis R. Rodriguez int ath9k_init_debug(struct ath_hw *ah) 1619203c4805SLuis R. Rodriguez { 1620bc974f4aSLuis R. Rodriguez struct ath_common *common = ath9k_hw_common(ah); 1621bc974f4aSLuis R. Rodriguez struct ath_softc *sc = (struct ath_softc *) common->priv; 16224d6b228dSLuis R. Rodriguez 1623eb272441SBen Greear sc->debug.debugfs_phy = debugfs_create_dir("ath9k", 1624eb272441SBen Greear sc->hw->wiphy->debugfsdir); 1625203c4805SLuis R. Rodriguez if (!sc->debug.debugfs_phy) 1626c8a72c00SFelix Fietkau return -ENOMEM; 1627203c4805SLuis R. Rodriguez 1628a830df07SFelix Fietkau #ifdef CONFIG_ATH_DEBUG 1629c70cab1aSFelix Fietkau debugfs_create_file("debug", S_IRUSR | S_IWUSR, sc->debug.debugfs_phy, 1630c70cab1aSFelix Fietkau sc, &fops_debug); 1631a830df07SFelix Fietkau #endif 1632c70cab1aSFelix Fietkau debugfs_create_file("dma", S_IRUSR, sc->debug.debugfs_phy, sc, 1633c70cab1aSFelix Fietkau &fops_dma); 1634c70cab1aSFelix Fietkau debugfs_create_file("interrupt", S_IRUSR, sc->debug.debugfs_phy, sc, 1635c70cab1aSFelix Fietkau &fops_interrupt); 1636c70cab1aSFelix Fietkau debugfs_create_file("wiphy", S_IRUSR | S_IWUSR, sc->debug.debugfs_phy, 1637c70cab1aSFelix Fietkau sc, &fops_wiphy); 1638c70cab1aSFelix Fietkau debugfs_create_file("xmit", S_IRUSR, sc->debug.debugfs_phy, sc, 1639c70cab1aSFelix Fietkau &fops_xmit); 1640c70cab1aSFelix Fietkau debugfs_create_file("stations", S_IRUSR, sc->debug.debugfs_phy, sc, 1641c70cab1aSFelix Fietkau &fops_stations); 1642c70cab1aSFelix Fietkau debugfs_create_file("misc", S_IRUSR, sc->debug.debugfs_phy, sc, 1643c70cab1aSFelix Fietkau &fops_misc); 1644c70cab1aSFelix Fietkau debugfs_create_file("recv", S_IRUSR, sc->debug.debugfs_phy, sc, 1645c70cab1aSFelix Fietkau &fops_recv); 1646c70cab1aSFelix Fietkau debugfs_create_file("rx_chainmask", S_IRUSR | S_IWUSR, 1647c70cab1aSFelix Fietkau sc->debug.debugfs_phy, sc, &fops_rx_chainmask); 1648c70cab1aSFelix Fietkau debugfs_create_file("tx_chainmask", S_IRUSR | S_IWUSR, 1649c70cab1aSFelix Fietkau sc->debug.debugfs_phy, sc, &fops_tx_chainmask); 165005c0be2fSMohammed Shafi Shajakhan debugfs_create_file("disable_ani", S_IRUSR | S_IWUSR, 165105c0be2fSMohammed Shafi Shajakhan sc->debug.debugfs_phy, sc, &fops_disable_ani); 1652c70cab1aSFelix Fietkau debugfs_create_file("regidx", S_IRUSR | S_IWUSR, sc->debug.debugfs_phy, 1653c70cab1aSFelix Fietkau sc, &fops_regidx); 1654c70cab1aSFelix Fietkau debugfs_create_file("regval", S_IRUSR | S_IWUSR, sc->debug.debugfs_phy, 1655c70cab1aSFelix Fietkau sc, &fops_regval); 1656c70cab1aSFelix Fietkau debugfs_create_bool("ignore_extcca", S_IRUSR | S_IWUSR, 1657c70cab1aSFelix Fietkau sc->debug.debugfs_phy, 1658c70cab1aSFelix Fietkau &ah->config.cwm_ignore_extcca); 1659c70cab1aSFelix Fietkau debugfs_create_file("regdump", S_IRUSR, sc->debug.debugfs_phy, sc, 1660c70cab1aSFelix Fietkau &fops_regdump); 1661d069a46bSRajkumar Manoharan debugfs_create_file("dump_nfcal", S_IRUSR, sc->debug.debugfs_phy, sc, 1662d069a46bSRajkumar Manoharan &fops_dump_nfcal); 1663580f010fSRajkumar Manoharan debugfs_create_file("base_eeprom", S_IRUSR, sc->debug.debugfs_phy, sc, 1664580f010fSRajkumar Manoharan &fops_base_eeprom); 16653f4c4bddSRajkumar Manoharan debugfs_create_file("modal_eeprom", S_IRUSR, sc->debug.debugfs_phy, sc, 16663f4c4bddSRajkumar Manoharan &fops_modal_eeprom); 1667cf3af748SRajkumar Manoharan debugfs_create_file("samples", S_IRUSR, sc->debug.debugfs_phy, sc, 1668cf3af748SRajkumar Manoharan &fops_samps); 1669582d0064SVasanthakumar Thiagarajan 1670691680b8SFelix Fietkau debugfs_create_u32("gpio_mask", S_IRUSR | S_IWUSR, 1671691680b8SFelix Fietkau sc->debug.debugfs_phy, &sc->sc_ah->gpio_mask); 1672691680b8SFelix Fietkau 1673691680b8SFelix Fietkau debugfs_create_u32("gpio_val", S_IRUSR | S_IWUSR, 1674691680b8SFelix Fietkau sc->debug.debugfs_phy, &sc->sc_ah->gpio_val); 1675691680b8SFelix Fietkau 16769bff0bc4SFelix Fietkau sc->debug.regidx = 0; 1677cf3af748SRajkumar Manoharan memset(&sc->debug.bb_mac_samp, 0, sizeof(sc->debug.bb_mac_samp)); 1678cf3af748SRajkumar Manoharan sc->debug.sampidx = 0; 1679cf3af748SRajkumar Manoharan sc->debug.tsidx = 0; 1680cf3af748SRajkumar Manoharan sc->debug.rsidx = 0; 1681203c4805SLuis R. Rodriguez return 0; 1682203c4805SLuis R. Rodriguez } 1683