1203c4805SLuis R. Rodriguez /* 25b68138eSSujith Manoharan * Copyright (c) 2008-2011 Atheros Communications Inc. 3203c4805SLuis R. Rodriguez * 4203c4805SLuis R. Rodriguez * Permission to use, copy, modify, and/or distribute this software for any 5203c4805SLuis R. Rodriguez * purpose with or without fee is hereby granted, provided that the above 6203c4805SLuis R. Rodriguez * copyright notice and this permission notice appear in all copies. 7203c4805SLuis R. Rodriguez * 8203c4805SLuis R. Rodriguez * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 9203c4805SLuis R. Rodriguez * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 10203c4805SLuis R. Rodriguez * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 11203c4805SLuis R. Rodriguez * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 12203c4805SLuis R. Rodriguez * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 13203c4805SLuis R. Rodriguez * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 14203c4805SLuis R. Rodriguez * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 15203c4805SLuis R. Rodriguez */ 16203c4805SLuis R. Rodriguez 175a0e3ad6STejun Heo #include <linux/slab.h> 18582d0064SVasanthakumar Thiagarajan #include <linux/vmalloc.h> 19ee40fa06SPaul Gortmaker #include <linux/export.h> 20e93d083fSSimon Wunderlich #include <linux/relay.h> 21203c4805SLuis R. Rodriguez #include <asm/unaligned.h> 22203c4805SLuis R. Rodriguez 23203c4805SLuis R. Rodriguez #include "ath9k.h" 24203c4805SLuis R. Rodriguez 25475a6e4dSLuis R. Rodriguez #define REG_WRITE_D(_ah, _reg, _val) \ 26475a6e4dSLuis R. Rodriguez ath9k_hw_common(_ah)->ops->write((_ah), (_val), (_reg)) 27475a6e4dSLuis R. Rodriguez #define REG_READ_D(_ah, _reg) \ 28475a6e4dSLuis R. Rodriguez ath9k_hw_common(_ah)->ops->read((_ah), (_reg)) 29475a6e4dSLuis R. Rodriguez 30203c4805SLuis R. Rodriguez 31582d0064SVasanthakumar Thiagarajan static ssize_t ath9k_debugfs_read_buf(struct file *file, char __user *user_buf, 32582d0064SVasanthakumar Thiagarajan size_t count, loff_t *ppos) 33582d0064SVasanthakumar Thiagarajan { 34582d0064SVasanthakumar Thiagarajan u8 *buf = file->private_data; 35582d0064SVasanthakumar Thiagarajan return simple_read_from_buffer(user_buf, count, ppos, buf, strlen(buf)); 36582d0064SVasanthakumar Thiagarajan } 37582d0064SVasanthakumar Thiagarajan 38582d0064SVasanthakumar Thiagarajan static int ath9k_debugfs_release_buf(struct inode *inode, struct file *file) 39582d0064SVasanthakumar Thiagarajan { 40582d0064SVasanthakumar Thiagarajan vfree(file->private_data); 41582d0064SVasanthakumar Thiagarajan return 0; 42582d0064SVasanthakumar Thiagarajan } 43582d0064SVasanthakumar Thiagarajan 44a830df07SFelix Fietkau #ifdef CONFIG_ATH_DEBUG 45a830df07SFelix Fietkau 462493928eSJeff Hansen static ssize_t read_file_debug(struct file *file, char __user *user_buf, 472493928eSJeff Hansen size_t count, loff_t *ppos) 482493928eSJeff Hansen { 492493928eSJeff Hansen struct ath_softc *sc = file->private_data; 50c46917bbSLuis R. Rodriguez struct ath_common *common = ath9k_hw_common(sc->sc_ah); 512493928eSJeff Hansen char buf[32]; 52581f725cSVasanthakumar Thiagarajan unsigned int len; 53581f725cSVasanthakumar Thiagarajan 542b87f3aaSDan Carpenter len = sprintf(buf, "0x%08x\n", common->debug_mask); 552493928eSJeff Hansen return simple_read_from_buffer(user_buf, count, ppos, buf, len); 562493928eSJeff Hansen } 572493928eSJeff Hansen 582493928eSJeff Hansen static ssize_t write_file_debug(struct file *file, const char __user *user_buf, 592493928eSJeff Hansen size_t count, loff_t *ppos) 602493928eSJeff Hansen { 612493928eSJeff Hansen struct ath_softc *sc = file->private_data; 62c46917bbSLuis R. Rodriguez struct ath_common *common = ath9k_hw_common(sc->sc_ah); 632493928eSJeff Hansen unsigned long mask; 642493928eSJeff Hansen char buf[32]; 65581f725cSVasanthakumar Thiagarajan ssize_t len; 66581f725cSVasanthakumar Thiagarajan 67581f725cSVasanthakumar Thiagarajan len = min(count, sizeof(buf) - 1); 68581f725cSVasanthakumar Thiagarajan if (copy_from_user(buf, user_buf, len)) 6904236066SDan Carpenter return -EFAULT; 70581f725cSVasanthakumar Thiagarajan 71581f725cSVasanthakumar Thiagarajan buf[len] = '\0'; 72581f725cSVasanthakumar Thiagarajan if (strict_strtoul(buf, 0, &mask)) 73581f725cSVasanthakumar Thiagarajan return -EINVAL; 74581f725cSVasanthakumar Thiagarajan 75c46917bbSLuis R. Rodriguez common->debug_mask = mask; 762493928eSJeff Hansen return count; 772493928eSJeff Hansen } 782493928eSJeff Hansen 792493928eSJeff Hansen static const struct file_operations fops_debug = { 802493928eSJeff Hansen .read = read_file_debug, 812493928eSJeff Hansen .write = write_file_debug, 82234e3405SStephen Boyd .open = simple_open, 836038f373SArnd Bergmann .owner = THIS_MODULE, 846038f373SArnd Bergmann .llseek = default_llseek, 852493928eSJeff Hansen }; 862493928eSJeff Hansen 87a830df07SFelix Fietkau #endif 88a830df07SFelix Fietkau 89991a0987SPavel Roskin #define DMA_BUF_LEN 1024 90991a0987SPavel Roskin 9115340694SFelix Fietkau static ssize_t read_file_tx_chainmask(struct file *file, char __user *user_buf, 9215340694SFelix Fietkau size_t count, loff_t *ppos) 9315340694SFelix Fietkau { 9415340694SFelix Fietkau struct ath_softc *sc = file->private_data; 9582b2d334SFelix Fietkau struct ath_hw *ah = sc->sc_ah; 9615340694SFelix Fietkau char buf[32]; 9715340694SFelix Fietkau unsigned int len; 9815340694SFelix Fietkau 9982b2d334SFelix Fietkau len = sprintf(buf, "0x%08x\n", ah->txchainmask); 10015340694SFelix Fietkau return simple_read_from_buffer(user_buf, count, ppos, buf, len); 10115340694SFelix Fietkau } 10215340694SFelix Fietkau 10315340694SFelix Fietkau static ssize_t write_file_tx_chainmask(struct file *file, const char __user *user_buf, 10415340694SFelix Fietkau size_t count, loff_t *ppos) 10515340694SFelix Fietkau { 10615340694SFelix Fietkau struct ath_softc *sc = file->private_data; 10782b2d334SFelix Fietkau struct ath_hw *ah = sc->sc_ah; 10815340694SFelix Fietkau unsigned long mask; 10915340694SFelix Fietkau char buf[32]; 11015340694SFelix Fietkau ssize_t len; 11115340694SFelix Fietkau 11215340694SFelix Fietkau len = min(count, sizeof(buf) - 1); 11315340694SFelix Fietkau if (copy_from_user(buf, user_buf, len)) 11404236066SDan Carpenter return -EFAULT; 11515340694SFelix Fietkau 11615340694SFelix Fietkau buf[len] = '\0'; 11715340694SFelix Fietkau if (strict_strtoul(buf, 0, &mask)) 11815340694SFelix Fietkau return -EINVAL; 11915340694SFelix Fietkau 12082b2d334SFelix Fietkau ah->txchainmask = mask; 12182b2d334SFelix Fietkau ah->caps.tx_chainmask = mask; 12215340694SFelix Fietkau return count; 12315340694SFelix Fietkau } 12415340694SFelix Fietkau 12515340694SFelix Fietkau static const struct file_operations fops_tx_chainmask = { 12615340694SFelix Fietkau .read = read_file_tx_chainmask, 12715340694SFelix Fietkau .write = write_file_tx_chainmask, 128234e3405SStephen Boyd .open = simple_open, 1296038f373SArnd Bergmann .owner = THIS_MODULE, 1306038f373SArnd Bergmann .llseek = default_llseek, 13115340694SFelix Fietkau }; 13215340694SFelix Fietkau 13315340694SFelix Fietkau 13415340694SFelix Fietkau static ssize_t read_file_rx_chainmask(struct file *file, char __user *user_buf, 13515340694SFelix Fietkau size_t count, loff_t *ppos) 13615340694SFelix Fietkau { 13715340694SFelix Fietkau struct ath_softc *sc = file->private_data; 13882b2d334SFelix Fietkau struct ath_hw *ah = sc->sc_ah; 13915340694SFelix Fietkau char buf[32]; 14015340694SFelix Fietkau unsigned int len; 14115340694SFelix Fietkau 14282b2d334SFelix Fietkau len = sprintf(buf, "0x%08x\n", ah->rxchainmask); 14315340694SFelix Fietkau return simple_read_from_buffer(user_buf, count, ppos, buf, len); 14415340694SFelix Fietkau } 14515340694SFelix Fietkau 14615340694SFelix Fietkau static ssize_t write_file_rx_chainmask(struct file *file, const char __user *user_buf, 14715340694SFelix Fietkau size_t count, loff_t *ppos) 14815340694SFelix Fietkau { 14915340694SFelix Fietkau struct ath_softc *sc = file->private_data; 15082b2d334SFelix Fietkau struct ath_hw *ah = sc->sc_ah; 15115340694SFelix Fietkau unsigned long mask; 15215340694SFelix Fietkau char buf[32]; 15315340694SFelix Fietkau ssize_t len; 15415340694SFelix Fietkau 15515340694SFelix Fietkau len = min(count, sizeof(buf) - 1); 15615340694SFelix Fietkau if (copy_from_user(buf, user_buf, len)) 15704236066SDan Carpenter return -EFAULT; 15815340694SFelix Fietkau 15915340694SFelix Fietkau buf[len] = '\0'; 16015340694SFelix Fietkau if (strict_strtoul(buf, 0, &mask)) 16115340694SFelix Fietkau return -EINVAL; 16215340694SFelix Fietkau 16382b2d334SFelix Fietkau ah->rxchainmask = mask; 16482b2d334SFelix Fietkau ah->caps.rx_chainmask = mask; 16515340694SFelix Fietkau return count; 16615340694SFelix Fietkau } 16715340694SFelix Fietkau 16815340694SFelix Fietkau static const struct file_operations fops_rx_chainmask = { 16915340694SFelix Fietkau .read = read_file_rx_chainmask, 17015340694SFelix Fietkau .write = write_file_rx_chainmask, 171234e3405SStephen Boyd .open = simple_open, 1726038f373SArnd Bergmann .owner = THIS_MODULE, 1736038f373SArnd Bergmann .llseek = default_llseek, 17415340694SFelix Fietkau }; 17515340694SFelix Fietkau 17605c0be2fSMohammed Shafi Shajakhan static ssize_t read_file_disable_ani(struct file *file, char __user *user_buf, 17705c0be2fSMohammed Shafi Shajakhan size_t count, loff_t *ppos) 17805c0be2fSMohammed Shafi Shajakhan { 17905c0be2fSMohammed Shafi Shajakhan struct ath_softc *sc = file->private_data; 18005c0be2fSMohammed Shafi Shajakhan struct ath_common *common = ath9k_hw_common(sc->sc_ah); 18105c0be2fSMohammed Shafi Shajakhan char buf[32]; 18205c0be2fSMohammed Shafi Shajakhan unsigned int len; 18305c0be2fSMohammed Shafi Shajakhan 18405c0be2fSMohammed Shafi Shajakhan len = sprintf(buf, "%d\n", common->disable_ani); 18505c0be2fSMohammed Shafi Shajakhan return simple_read_from_buffer(user_buf, count, ppos, buf, len); 18605c0be2fSMohammed Shafi Shajakhan } 18705c0be2fSMohammed Shafi Shajakhan 18805c0be2fSMohammed Shafi Shajakhan static ssize_t write_file_disable_ani(struct file *file, 18905c0be2fSMohammed Shafi Shajakhan const char __user *user_buf, 19005c0be2fSMohammed Shafi Shajakhan size_t count, loff_t *ppos) 19105c0be2fSMohammed Shafi Shajakhan { 19205c0be2fSMohammed Shafi Shajakhan struct ath_softc *sc = file->private_data; 19305c0be2fSMohammed Shafi Shajakhan struct ath_common *common = ath9k_hw_common(sc->sc_ah); 19405c0be2fSMohammed Shafi Shajakhan unsigned long disable_ani; 19505c0be2fSMohammed Shafi Shajakhan char buf[32]; 19605c0be2fSMohammed Shafi Shajakhan ssize_t len; 19705c0be2fSMohammed Shafi Shajakhan 19805c0be2fSMohammed Shafi Shajakhan len = min(count, sizeof(buf) - 1); 19905c0be2fSMohammed Shafi Shajakhan if (copy_from_user(buf, user_buf, len)) 20005c0be2fSMohammed Shafi Shajakhan return -EFAULT; 20105c0be2fSMohammed Shafi Shajakhan 20205c0be2fSMohammed Shafi Shajakhan buf[len] = '\0'; 20305c0be2fSMohammed Shafi Shajakhan if (strict_strtoul(buf, 0, &disable_ani)) 20405c0be2fSMohammed Shafi Shajakhan return -EINVAL; 20505c0be2fSMohammed Shafi Shajakhan 20605c0be2fSMohammed Shafi Shajakhan common->disable_ani = !!disable_ani; 20705c0be2fSMohammed Shafi Shajakhan 20805c0be2fSMohammed Shafi Shajakhan if (disable_ani) { 209781b14a3SSujith Manoharan clear_bit(SC_OP_ANI_RUN, &sc->sc_flags); 210da0d45f7SSujith Manoharan ath_stop_ani(sc); 21105c0be2fSMohammed Shafi Shajakhan } else { 212da0d45f7SSujith Manoharan ath_check_ani(sc); 21305c0be2fSMohammed Shafi Shajakhan } 21405c0be2fSMohammed Shafi Shajakhan 21505c0be2fSMohammed Shafi Shajakhan return count; 21605c0be2fSMohammed Shafi Shajakhan } 21705c0be2fSMohammed Shafi Shajakhan 21805c0be2fSMohammed Shafi Shajakhan static const struct file_operations fops_disable_ani = { 21905c0be2fSMohammed Shafi Shajakhan .read = read_file_disable_ani, 22005c0be2fSMohammed Shafi Shajakhan .write = write_file_disable_ani, 221234e3405SStephen Boyd .open = simple_open, 22205c0be2fSMohammed Shafi Shajakhan .owner = THIS_MODULE, 22305c0be2fSMohammed Shafi Shajakhan .llseek = default_llseek, 22405c0be2fSMohammed Shafi Shajakhan }; 22515340694SFelix Fietkau 226302a3c3aSSujith Manoharan static ssize_t read_file_ant_diversity(struct file *file, char __user *user_buf, 227302a3c3aSSujith Manoharan size_t count, loff_t *ppos) 228302a3c3aSSujith Manoharan { 229302a3c3aSSujith Manoharan struct ath_softc *sc = file->private_data; 230302a3c3aSSujith Manoharan struct ath_common *common = ath9k_hw_common(sc->sc_ah); 231302a3c3aSSujith Manoharan char buf[32]; 232302a3c3aSSujith Manoharan unsigned int len; 233302a3c3aSSujith Manoharan 234302a3c3aSSujith Manoharan len = sprintf(buf, "%d\n", common->antenna_diversity); 235302a3c3aSSujith Manoharan return simple_read_from_buffer(user_buf, count, ppos, buf, len); 236302a3c3aSSujith Manoharan } 237302a3c3aSSujith Manoharan 238302a3c3aSSujith Manoharan static ssize_t write_file_ant_diversity(struct file *file, 239302a3c3aSSujith Manoharan const char __user *user_buf, 240302a3c3aSSujith Manoharan size_t count, loff_t *ppos) 241302a3c3aSSujith Manoharan { 242302a3c3aSSujith Manoharan struct ath_softc *sc = file->private_data; 243302a3c3aSSujith Manoharan struct ath_common *common = ath9k_hw_common(sc->sc_ah); 244302a3c3aSSujith Manoharan unsigned long antenna_diversity; 245302a3c3aSSujith Manoharan char buf[32]; 246302a3c3aSSujith Manoharan ssize_t len; 247302a3c3aSSujith Manoharan 248302a3c3aSSujith Manoharan len = min(count, sizeof(buf) - 1); 249302a3c3aSSujith Manoharan if (copy_from_user(buf, user_buf, len)) 250302a3c3aSSujith Manoharan return -EFAULT; 251302a3c3aSSujith Manoharan 252302a3c3aSSujith Manoharan if (!AR_SREV_9565(sc->sc_ah)) 253302a3c3aSSujith Manoharan goto exit; 254302a3c3aSSujith Manoharan 255302a3c3aSSujith Manoharan buf[len] = '\0'; 256302a3c3aSSujith Manoharan if (strict_strtoul(buf, 0, &antenna_diversity)) 257302a3c3aSSujith Manoharan return -EINVAL; 258302a3c3aSSujith Manoharan 259302a3c3aSSujith Manoharan common->antenna_diversity = !!antenna_diversity; 260302a3c3aSSujith Manoharan ath9k_ps_wakeup(sc); 261302a3c3aSSujith Manoharan ath_ant_comb_update(sc); 262302a3c3aSSujith Manoharan ath_dbg(common, CONFIG, "Antenna diversity: %d\n", 263302a3c3aSSujith Manoharan common->antenna_diversity); 264302a3c3aSSujith Manoharan ath9k_ps_restore(sc); 265302a3c3aSSujith Manoharan exit: 266302a3c3aSSujith Manoharan return count; 267302a3c3aSSujith Manoharan } 268302a3c3aSSujith Manoharan 269302a3c3aSSujith Manoharan static const struct file_operations fops_ant_diversity = { 270302a3c3aSSujith Manoharan .read = read_file_ant_diversity, 271302a3c3aSSujith Manoharan .write = write_file_ant_diversity, 272302a3c3aSSujith Manoharan .open = simple_open, 273302a3c3aSSujith Manoharan .owner = THIS_MODULE, 274302a3c3aSSujith Manoharan .llseek = default_llseek, 275302a3c3aSSujith Manoharan }; 276302a3c3aSSujith Manoharan 277203c4805SLuis R. Rodriguez static ssize_t read_file_dma(struct file *file, char __user *user_buf, 278203c4805SLuis R. Rodriguez size_t count, loff_t *ppos) 279203c4805SLuis R. Rodriguez { 280203c4805SLuis R. Rodriguez struct ath_softc *sc = file->private_data; 281203c4805SLuis R. Rodriguez struct ath_hw *ah = sc->sc_ah; 282991a0987SPavel Roskin char *buf; 283991a0987SPavel Roskin int retval; 284203c4805SLuis R. Rodriguez unsigned int len = 0; 285203c4805SLuis R. Rodriguez u32 val[ATH9K_NUM_DMA_DEBUG_REGS]; 286203c4805SLuis R. Rodriguez int i, qcuOffset = 0, dcuOffset = 0; 287203c4805SLuis R. Rodriguez u32 *qcuBase = &val[0], *dcuBase = &val[4]; 288203c4805SLuis R. Rodriguez 289991a0987SPavel Roskin buf = kmalloc(DMA_BUF_LEN, GFP_KERNEL); 290991a0987SPavel Roskin if (!buf) 29104236066SDan Carpenter return -ENOMEM; 292991a0987SPavel Roskin 2937cf4a2e7SSujith ath9k_ps_wakeup(sc); 2947cf4a2e7SSujith 295475a6e4dSLuis R. Rodriguez REG_WRITE_D(ah, AR_MACMISC, 296203c4805SLuis R. Rodriguez ((AR_MACMISC_DMA_OBS_LINE_8 << AR_MACMISC_DMA_OBS_S) | 297203c4805SLuis R. Rodriguez (AR_MACMISC_MISC_OBS_BUS_1 << 298203c4805SLuis R. Rodriguez AR_MACMISC_MISC_OBS_BUS_MSB_S))); 299203c4805SLuis R. Rodriguez 300991a0987SPavel Roskin len += snprintf(buf + len, DMA_BUF_LEN - len, 301203c4805SLuis R. Rodriguez "Raw DMA Debug values:\n"); 302203c4805SLuis R. Rodriguez 303203c4805SLuis R. Rodriguez for (i = 0; i < ATH9K_NUM_DMA_DEBUG_REGS; i++) { 304203c4805SLuis R. Rodriguez if (i % 4 == 0) 305991a0987SPavel Roskin len += snprintf(buf + len, DMA_BUF_LEN - len, "\n"); 306203c4805SLuis R. Rodriguez 307475a6e4dSLuis R. Rodriguez val[i] = REG_READ_D(ah, AR_DMADBG_0 + (i * sizeof(u32))); 308991a0987SPavel Roskin len += snprintf(buf + len, DMA_BUF_LEN - len, "%d: %08x ", 309203c4805SLuis R. Rodriguez i, val[i]); 310203c4805SLuis R. Rodriguez } 311203c4805SLuis R. Rodriguez 312991a0987SPavel Roskin len += snprintf(buf + len, DMA_BUF_LEN - len, "\n\n"); 313991a0987SPavel Roskin len += snprintf(buf + len, DMA_BUF_LEN - len, 314203c4805SLuis R. Rodriguez "Num QCU: chain_st fsp_ok fsp_st DCU: chain_st\n"); 315203c4805SLuis R. Rodriguez 316203c4805SLuis R. Rodriguez for (i = 0; i < ATH9K_NUM_QUEUES; i++, qcuOffset += 4, dcuOffset += 5) { 317203c4805SLuis R. Rodriguez if (i == 8) { 318203c4805SLuis R. Rodriguez qcuOffset = 0; 319203c4805SLuis R. Rodriguez qcuBase++; 320203c4805SLuis R. Rodriguez } 321203c4805SLuis R. Rodriguez 322203c4805SLuis R. Rodriguez if (i == 6) { 323203c4805SLuis R. Rodriguez dcuOffset = 0; 324203c4805SLuis R. Rodriguez dcuBase++; 325203c4805SLuis R. Rodriguez } 326203c4805SLuis R. Rodriguez 327991a0987SPavel Roskin len += snprintf(buf + len, DMA_BUF_LEN - len, 328203c4805SLuis R. Rodriguez "%2d %2x %1x %2x %2x\n", 329203c4805SLuis R. Rodriguez i, (*qcuBase & (0x7 << qcuOffset)) >> qcuOffset, 330203c4805SLuis R. Rodriguez (*qcuBase & (0x8 << qcuOffset)) >> (qcuOffset + 3), 331203c4805SLuis R. Rodriguez val[2] & (0x7 << (i * 3)) >> (i * 3), 332203c4805SLuis R. Rodriguez (*dcuBase & (0x1f << dcuOffset)) >> dcuOffset); 333203c4805SLuis R. Rodriguez } 334203c4805SLuis R. Rodriguez 335991a0987SPavel Roskin len += snprintf(buf + len, DMA_BUF_LEN - len, "\n"); 336203c4805SLuis R. Rodriguez 337991a0987SPavel Roskin len += snprintf(buf + len, DMA_BUF_LEN - len, 338203c4805SLuis R. Rodriguez "qcu_stitch state: %2x qcu_fetch state: %2x\n", 339203c4805SLuis R. Rodriguez (val[3] & 0x003c0000) >> 18, (val[3] & 0x03c00000) >> 22); 340991a0987SPavel Roskin len += snprintf(buf + len, DMA_BUF_LEN - len, 341203c4805SLuis R. Rodriguez "qcu_complete state: %2x dcu_complete state: %2x\n", 342203c4805SLuis R. Rodriguez (val[3] & 0x1c000000) >> 26, (val[6] & 0x3)); 343991a0987SPavel Roskin len += snprintf(buf + len, DMA_BUF_LEN - len, 344203c4805SLuis R. Rodriguez "dcu_arb state: %2x dcu_fp state: %2x\n", 345203c4805SLuis R. Rodriguez (val[5] & 0x06000000) >> 25, (val[5] & 0x38000000) >> 27); 346991a0987SPavel Roskin len += snprintf(buf + len, DMA_BUF_LEN - len, 347203c4805SLuis R. Rodriguez "chan_idle_dur: %3d chan_idle_dur_valid: %1d\n", 348203c4805SLuis R. Rodriguez (val[6] & 0x000003fc) >> 2, (val[6] & 0x00000400) >> 10); 349991a0987SPavel Roskin len += snprintf(buf + len, DMA_BUF_LEN - len, 350203c4805SLuis R. Rodriguez "txfifo_valid_0: %1d txfifo_valid_1: %1d\n", 351203c4805SLuis R. Rodriguez (val[6] & 0x00000800) >> 11, (val[6] & 0x00001000) >> 12); 352991a0987SPavel Roskin len += snprintf(buf + len, DMA_BUF_LEN - len, 353203c4805SLuis R. Rodriguez "txfifo_dcu_num_0: %2d txfifo_dcu_num_1: %2d\n", 354203c4805SLuis R. Rodriguez (val[6] & 0x0001e000) >> 13, (val[6] & 0x001e0000) >> 17); 355203c4805SLuis R. Rodriguez 356991a0987SPavel Roskin len += snprintf(buf + len, DMA_BUF_LEN - len, "pcu observe: 0x%x\n", 357475a6e4dSLuis R. Rodriguez REG_READ_D(ah, AR_OBS_BUS_1)); 358991a0987SPavel Roskin len += snprintf(buf + len, DMA_BUF_LEN - len, 359475a6e4dSLuis R. Rodriguez "AR_CR: 0x%x\n", REG_READ_D(ah, AR_CR)); 360203c4805SLuis R. Rodriguez 3617cf4a2e7SSujith ath9k_ps_restore(sc); 3627cf4a2e7SSujith 3632b87f3aaSDan Carpenter if (len > DMA_BUF_LEN) 3642b87f3aaSDan Carpenter len = DMA_BUF_LEN; 3652b87f3aaSDan Carpenter 366991a0987SPavel Roskin retval = simple_read_from_buffer(user_buf, count, ppos, buf, len); 367991a0987SPavel Roskin kfree(buf); 368991a0987SPavel Roskin return retval; 369203c4805SLuis R. Rodriguez } 370203c4805SLuis R. Rodriguez 371203c4805SLuis R. Rodriguez static const struct file_operations fops_dma = { 372203c4805SLuis R. Rodriguez .read = read_file_dma, 373234e3405SStephen Boyd .open = simple_open, 3746038f373SArnd Bergmann .owner = THIS_MODULE, 3756038f373SArnd Bergmann .llseek = default_llseek, 376203c4805SLuis R. Rodriguez }; 377203c4805SLuis R. Rodriguez 378203c4805SLuis R. Rodriguez 379203c4805SLuis R. Rodriguez void ath_debug_stat_interrupt(struct ath_softc *sc, enum ath9k_int status) 380203c4805SLuis R. Rodriguez { 381203c4805SLuis R. Rodriguez if (status) 382203c4805SLuis R. Rodriguez sc->debug.stats.istats.total++; 383a9616f41SLuis R. Rodriguez if (sc->sc_ah->caps.hw_caps & ATH9K_HW_CAP_EDMA) { 384a9616f41SLuis R. Rodriguez if (status & ATH9K_INT_RXLP) 385a9616f41SLuis R. Rodriguez sc->debug.stats.istats.rxlp++; 386a9616f41SLuis R. Rodriguez if (status & ATH9K_INT_RXHP) 387a9616f41SLuis R. Rodriguez sc->debug.stats.istats.rxhp++; 38808578b8fSLuis R. Rodriguez if (status & ATH9K_INT_BB_WATCHDOG) 38908578b8fSLuis R. Rodriguez sc->debug.stats.istats.bb_watchdog++; 390a9616f41SLuis R. Rodriguez } else { 391203c4805SLuis R. Rodriguez if (status & ATH9K_INT_RX) 392203c4805SLuis R. Rodriguez sc->debug.stats.istats.rxok++; 393a9616f41SLuis R. Rodriguez } 394203c4805SLuis R. Rodriguez if (status & ATH9K_INT_RXEOL) 395203c4805SLuis R. Rodriguez sc->debug.stats.istats.rxeol++; 396203c4805SLuis R. Rodriguez if (status & ATH9K_INT_RXORN) 397203c4805SLuis R. Rodriguez sc->debug.stats.istats.rxorn++; 398203c4805SLuis R. Rodriguez if (status & ATH9K_INT_TX) 399203c4805SLuis R. Rodriguez sc->debug.stats.istats.txok++; 400203c4805SLuis R. Rodriguez if (status & ATH9K_INT_TXURN) 401203c4805SLuis R. Rodriguez sc->debug.stats.istats.txurn++; 402203c4805SLuis R. Rodriguez if (status & ATH9K_INT_RXPHY) 403203c4805SLuis R. Rodriguez sc->debug.stats.istats.rxphyerr++; 404203c4805SLuis R. Rodriguez if (status & ATH9K_INT_RXKCM) 405203c4805SLuis R. Rodriguez sc->debug.stats.istats.rx_keycache_miss++; 406203c4805SLuis R. Rodriguez if (status & ATH9K_INT_SWBA) 407203c4805SLuis R. Rodriguez sc->debug.stats.istats.swba++; 408203c4805SLuis R. Rodriguez if (status & ATH9K_INT_BMISS) 409203c4805SLuis R. Rodriguez sc->debug.stats.istats.bmiss++; 410203c4805SLuis R. Rodriguez if (status & ATH9K_INT_BNR) 411203c4805SLuis R. Rodriguez sc->debug.stats.istats.bnr++; 412203c4805SLuis R. Rodriguez if (status & ATH9K_INT_CST) 413203c4805SLuis R. Rodriguez sc->debug.stats.istats.cst++; 414203c4805SLuis R. Rodriguez if (status & ATH9K_INT_GTT) 415203c4805SLuis R. Rodriguez sc->debug.stats.istats.gtt++; 416203c4805SLuis R. Rodriguez if (status & ATH9K_INT_TIM) 417203c4805SLuis R. Rodriguez sc->debug.stats.istats.tim++; 418203c4805SLuis R. Rodriguez if (status & ATH9K_INT_CABEND) 419203c4805SLuis R. Rodriguez sc->debug.stats.istats.cabend++; 420203c4805SLuis R. Rodriguez if (status & ATH9K_INT_DTIMSYNC) 421203c4805SLuis R. Rodriguez sc->debug.stats.istats.dtimsync++; 422203c4805SLuis R. Rodriguez if (status & ATH9K_INT_DTIM) 423203c4805SLuis R. Rodriguez sc->debug.stats.istats.dtim++; 4246dde1aabSMohammed Shafi Shajakhan if (status & ATH9K_INT_TSFOOR) 4256dde1aabSMohammed Shafi Shajakhan sc->debug.stats.istats.tsfoor++; 42697ba515aSSujith Manoharan if (status & ATH9K_INT_MCI) 42797ba515aSSujith Manoharan sc->debug.stats.istats.mci++; 428c9e6e980SMohammed Shafi Shajakhan if (status & ATH9K_INT_GENTIMER) 429c9e6e980SMohammed Shafi Shajakhan sc->debug.stats.istats.gen_timer++; 430203c4805SLuis R. Rodriguez } 431203c4805SLuis R. Rodriguez 432203c4805SLuis R. Rodriguez static ssize_t read_file_interrupt(struct file *file, char __user *user_buf, 433203c4805SLuis R. Rodriguez size_t count, loff_t *ppos) 434203c4805SLuis R. Rodriguez { 435203c4805SLuis R. Rodriguez struct ath_softc *sc = file->private_data; 436203c4805SLuis R. Rodriguez unsigned int len = 0; 437462e58f2SBen Greear int rv; 438462e58f2SBen Greear int mxlen = 4000; 439462e58f2SBen Greear char *buf = kmalloc(mxlen, GFP_KERNEL); 440462e58f2SBen Greear if (!buf) 441462e58f2SBen Greear return -ENOMEM; 442462e58f2SBen Greear 443462e58f2SBen Greear #define PR_IS(a, s) \ 444462e58f2SBen Greear do { \ 445462e58f2SBen Greear len += snprintf(buf + len, mxlen - len, \ 446462e58f2SBen Greear "%21s: %10u\n", a, \ 447462e58f2SBen Greear sc->debug.stats.istats.s); \ 448462e58f2SBen Greear } while (0) 449203c4805SLuis R. Rodriguez 450a9616f41SLuis R. Rodriguez if (sc->sc_ah->caps.hw_caps & ATH9K_HW_CAP_EDMA) { 451462e58f2SBen Greear PR_IS("RXLP", rxlp); 452462e58f2SBen Greear PR_IS("RXHP", rxhp); 453462e58f2SBen Greear PR_IS("WATHDOG", bb_watchdog); 454a9616f41SLuis R. Rodriguez } else { 455462e58f2SBen Greear PR_IS("RX", rxok); 456a9616f41SLuis R. Rodriguez } 457462e58f2SBen Greear PR_IS("RXEOL", rxeol); 458462e58f2SBen Greear PR_IS("RXORN", rxorn); 459462e58f2SBen Greear PR_IS("TX", txok); 460462e58f2SBen Greear PR_IS("TXURN", txurn); 461462e58f2SBen Greear PR_IS("MIB", mib); 462462e58f2SBen Greear PR_IS("RXPHY", rxphyerr); 463462e58f2SBen Greear PR_IS("RXKCM", rx_keycache_miss); 464462e58f2SBen Greear PR_IS("SWBA", swba); 465462e58f2SBen Greear PR_IS("BMISS", bmiss); 466462e58f2SBen Greear PR_IS("BNR", bnr); 467462e58f2SBen Greear PR_IS("CST", cst); 468462e58f2SBen Greear PR_IS("GTT", gtt); 469462e58f2SBen Greear PR_IS("TIM", tim); 470462e58f2SBen Greear PR_IS("CABEND", cabend); 471462e58f2SBen Greear PR_IS("DTIMSYNC", dtimsync); 472462e58f2SBen Greear PR_IS("DTIM", dtim); 473462e58f2SBen Greear PR_IS("TSFOOR", tsfoor); 47497ba515aSSujith Manoharan PR_IS("MCI", mci); 475c9e6e980SMohammed Shafi Shajakhan PR_IS("GENTIMER", gen_timer); 476462e58f2SBen Greear PR_IS("TOTAL", total); 477203c4805SLuis R. Rodriguez 478462e58f2SBen Greear len += snprintf(buf + len, mxlen - len, 479462e58f2SBen Greear "SYNC_CAUSE stats:\n"); 4806dde1aabSMohammed Shafi Shajakhan 481462e58f2SBen Greear PR_IS("Sync-All", sync_cause_all); 482462e58f2SBen Greear PR_IS("RTC-IRQ", sync_rtc_irq); 483462e58f2SBen Greear PR_IS("MAC-IRQ", sync_mac_irq); 484462e58f2SBen Greear PR_IS("EEPROM-Illegal-Access", eeprom_illegal_access); 485462e58f2SBen Greear PR_IS("APB-Timeout", apb_timeout); 486462e58f2SBen Greear PR_IS("PCI-Mode-Conflict", pci_mode_conflict); 487462e58f2SBen Greear PR_IS("HOST1-Fatal", host1_fatal); 488462e58f2SBen Greear PR_IS("HOST1-Perr", host1_perr); 489462e58f2SBen Greear PR_IS("TRCV-FIFO-Perr", trcv_fifo_perr); 490462e58f2SBen Greear PR_IS("RADM-CPL-EP", radm_cpl_ep); 491462e58f2SBen Greear PR_IS("RADM-CPL-DLLP-Abort", radm_cpl_dllp_abort); 492462e58f2SBen Greear PR_IS("RADM-CPL-TLP-Abort", radm_cpl_tlp_abort); 493462e58f2SBen Greear PR_IS("RADM-CPL-ECRC-Err", radm_cpl_ecrc_err); 494462e58f2SBen Greear PR_IS("RADM-CPL-Timeout", radm_cpl_timeout); 495462e58f2SBen Greear PR_IS("Local-Bus-Timeout", local_timeout); 496462e58f2SBen Greear PR_IS("PM-Access", pm_access); 497462e58f2SBen Greear PR_IS("MAC-Awake", mac_awake); 498462e58f2SBen Greear PR_IS("MAC-Asleep", mac_asleep); 499462e58f2SBen Greear PR_IS("MAC-Sleep-Access", mac_sleep_access); 5002b87f3aaSDan Carpenter 501462e58f2SBen Greear if (len > mxlen) 502462e58f2SBen Greear len = mxlen; 503462e58f2SBen Greear 504462e58f2SBen Greear rv = simple_read_from_buffer(user_buf, count, ppos, buf, len); 505462e58f2SBen Greear kfree(buf); 506462e58f2SBen Greear return rv; 507203c4805SLuis R. Rodriguez } 508203c4805SLuis R. Rodriguez 509203c4805SLuis R. Rodriguez static const struct file_operations fops_interrupt = { 510203c4805SLuis R. Rodriguez .read = read_file_interrupt, 511234e3405SStephen Boyd .open = simple_open, 5126038f373SArnd Bergmann .owner = THIS_MODULE, 5136038f373SArnd Bergmann .llseek = default_llseek, 514203c4805SLuis R. Rodriguez }; 515203c4805SLuis R. Rodriguez 516fec247c0SSujith static ssize_t read_file_xmit(struct file *file, char __user *user_buf, 517fec247c0SSujith size_t count, loff_t *ppos) 518fec247c0SSujith { 519fec247c0SSujith struct ath_softc *sc = file->private_data; 520fec247c0SSujith char *buf; 52178ef731cSSujith Manoharan unsigned int len = 0, size = 2048; 522fec247c0SSujith ssize_t retval = 0; 523fec247c0SSujith 524fec247c0SSujith buf = kzalloc(size, GFP_KERNEL); 525fec247c0SSujith if (buf == NULL) 52604236066SDan Carpenter return -ENOMEM; 527fec247c0SSujith 52878ef731cSSujith Manoharan len += sprintf(buf, "%30s %10s%10s%10s\n\n", 5297f010c93SBen Greear "BE", "BK", "VI", "VO"); 530fec247c0SSujith 531fec247c0SSujith PR("MPDUs Queued: ", queued); 532fec247c0SSujith PR("MPDUs Completed: ", completed); 5335a6f78afSFelix Fietkau PR("MPDUs XRetried: ", xretries); 534fec247c0SSujith PR("Aggregates: ", a_aggr); 535bda8addaSBen Greear PR("AMPDUs Queued HW:", a_queued_hw); 536bda8addaSBen Greear PR("AMPDUs Queued SW:", a_queued_sw); 537fec247c0SSujith PR("AMPDUs Completed:", a_completed); 538fec247c0SSujith PR("AMPDUs Retried: ", a_retries); 539fec247c0SSujith PR("AMPDUs XRetried: ", a_xretries); 5404d900389SBen Greear PR("TXERR Filtered: ", txerr_filtered); 541fec247c0SSujith PR("FIFO Underrun: ", fifo_underrun); 542fec247c0SSujith PR("TXOP Exceeded: ", xtxop); 543fec247c0SSujith PR("TXTIMER Expiry: ", timer_exp); 544fec247c0SSujith PR("DESC CFG Error: ", desc_cfg_err); 545fec247c0SSujith PR("DATA Underrun: ", data_underrun); 546fec247c0SSujith PR("DELIM Underrun: ", delim_underrun); 54799c15bf5SBen Greear PR("TX-Pkts-All: ", tx_pkts_all); 54899c15bf5SBen Greear PR("TX-Bytes-All: ", tx_bytes_all); 54978ef731cSSujith Manoharan PR("HW-put-tx-buf: ", puttxbuf); 55078ef731cSSujith Manoharan PR("HW-tx-start: ", txstart); 55178ef731cSSujith Manoharan PR("HW-tx-proc-desc: ", txprocdesc); 552a5a0bca1SBen Greear PR("TX-Failed: ", txfailed); 553fec247c0SSujith 5547f010c93SBen Greear if (len > size) 5557f010c93SBen Greear len = size; 5567f010c93SBen Greear 5577f010c93SBen Greear retval = simple_read_from_buffer(user_buf, count, ppos, buf, len); 5587f010c93SBen Greear kfree(buf); 5597f010c93SBen Greear 5607f010c93SBen Greear return retval; 5617f010c93SBen Greear } 5627f010c93SBen Greear 563c0b74876SSujith Manoharan static ssize_t read_file_queues(struct file *file, char __user *user_buf, 564c0b74876SSujith Manoharan size_t count, loff_t *ppos) 565c0b74876SSujith Manoharan { 566c0b74876SSujith Manoharan struct ath_softc *sc = file->private_data; 567c0b74876SSujith Manoharan struct ath_txq *txq; 568c0b74876SSujith Manoharan char *buf; 569c0b74876SSujith Manoharan unsigned int len = 0, size = 1024; 570c0b74876SSujith Manoharan ssize_t retval = 0; 571c0b74876SSujith Manoharan int i; 572c0b74876SSujith Manoharan char *qname[4] = {"VO", "VI", "BE", "BK"}; 573c0b74876SSujith Manoharan 574c0b74876SSujith Manoharan buf = kzalloc(size, GFP_KERNEL); 575c0b74876SSujith Manoharan if (buf == NULL) 576c0b74876SSujith Manoharan return -ENOMEM; 577c0b74876SSujith Manoharan 578c0b74876SSujith Manoharan for (i = 0; i < IEEE80211_NUM_ACS; i++) { 579c0b74876SSujith Manoharan txq = sc->tx.txq_map[i]; 580c0b74876SSujith Manoharan len += snprintf(buf + len, size - len, "(%s): ", qname[i]); 581c0b74876SSujith Manoharan 582c0b74876SSujith Manoharan ath_txq_lock(sc, txq); 583c0b74876SSujith Manoharan 584c0b74876SSujith Manoharan len += snprintf(buf + len, size - len, "%s: %d ", 585c0b74876SSujith Manoharan "qnum", txq->axq_qnum); 586c0b74876SSujith Manoharan len += snprintf(buf + len, size - len, "%s: %2d ", 587c0b74876SSujith Manoharan "qdepth", txq->axq_depth); 588c0b74876SSujith Manoharan len += snprintf(buf + len, size - len, "%s: %2d ", 589c0b74876SSujith Manoharan "ampdu-depth", txq->axq_ampdu_depth); 590c0b74876SSujith Manoharan len += snprintf(buf + len, size - len, "%s: %3d ", 591c0b74876SSujith Manoharan "pending", txq->pending_frames); 592c0b74876SSujith Manoharan len += snprintf(buf + len, size - len, "%s: %d\n", 593c0b74876SSujith Manoharan "stopped", txq->stopped); 594c0b74876SSujith Manoharan 595c0b74876SSujith Manoharan ath_txq_unlock(sc, txq); 596c0b74876SSujith Manoharan } 597c0b74876SSujith Manoharan 598c0b74876SSujith Manoharan if (len > size) 599c0b74876SSujith Manoharan len = size; 600c0b74876SSujith Manoharan 601c0b74876SSujith Manoharan retval = simple_read_from_buffer(user_buf, count, ppos, buf, len); 602c0b74876SSujith Manoharan kfree(buf); 603c0b74876SSujith Manoharan 604c0b74876SSujith Manoharan return retval; 605c0b74876SSujith Manoharan } 606c0b74876SSujith Manoharan 60755f6d0ffSBen Greear static ssize_t read_file_misc(struct file *file, char __user *user_buf, 60855f6d0ffSBen Greear size_t count, loff_t *ppos) 60955f6d0ffSBen Greear { 61055f6d0ffSBen Greear struct ath_softc *sc = file->private_data; 61155f6d0ffSBen Greear struct ath_common *common = ath9k_hw_common(sc->sc_ah); 61255f6d0ffSBen Greear struct ieee80211_hw *hw = sc->hw; 6136bcf6f64SSujith Manoharan struct ath9k_vif_iter_data iter_data; 6146bcf6f64SSujith Manoharan char buf[512]; 6156bcf6f64SSujith Manoharan unsigned int len = 0; 61655f6d0ffSBen Greear ssize_t retval = 0; 61755f6d0ffSBen Greear unsigned int reg; 6186bcf6f64SSujith Manoharan u32 rxfilter; 6196bcf6f64SSujith Manoharan 6206bcf6f64SSujith Manoharan len += snprintf(buf + len, sizeof(buf) - len, 6216bcf6f64SSujith Manoharan "BSSID: %pM\n", common->curbssid); 6226bcf6f64SSujith Manoharan len += snprintf(buf + len, sizeof(buf) - len, 6236bcf6f64SSujith Manoharan "BSSID-MASK: %pM\n", common->bssidmask); 6246bcf6f64SSujith Manoharan len += snprintf(buf + len, sizeof(buf) - len, 6256bcf6f64SSujith Manoharan "OPMODE: %s\n", ath_opmode_to_string(sc->sc_ah->opmode)); 6266bcf6f64SSujith Manoharan 6276bcf6f64SSujith Manoharan ath9k_ps_wakeup(sc); 6286bcf6f64SSujith Manoharan rxfilter = ath9k_hw_getrxfilter(sc->sc_ah); 6296bcf6f64SSujith Manoharan ath9k_ps_restore(sc); 6306bcf6f64SSujith Manoharan 6316bcf6f64SSujith Manoharan len += snprintf(buf + len, sizeof(buf) - len, 6326bcf6f64SSujith Manoharan "RXFILTER: 0x%x", rxfilter); 6336bcf6f64SSujith Manoharan 6346bcf6f64SSujith Manoharan if (rxfilter & ATH9K_RX_FILTER_UCAST) 6356bcf6f64SSujith Manoharan len += snprintf(buf + len, sizeof(buf) - len, " UCAST"); 6366bcf6f64SSujith Manoharan if (rxfilter & ATH9K_RX_FILTER_MCAST) 6376bcf6f64SSujith Manoharan len += snprintf(buf + len, sizeof(buf) - len, " MCAST"); 6386bcf6f64SSujith Manoharan if (rxfilter & ATH9K_RX_FILTER_BCAST) 6396bcf6f64SSujith Manoharan len += snprintf(buf + len, sizeof(buf) - len, " BCAST"); 6406bcf6f64SSujith Manoharan if (rxfilter & ATH9K_RX_FILTER_CONTROL) 6416bcf6f64SSujith Manoharan len += snprintf(buf + len, sizeof(buf) - len, " CONTROL"); 6426bcf6f64SSujith Manoharan if (rxfilter & ATH9K_RX_FILTER_BEACON) 6436bcf6f64SSujith Manoharan len += snprintf(buf + len, sizeof(buf) - len, " BEACON"); 6446bcf6f64SSujith Manoharan if (rxfilter & ATH9K_RX_FILTER_PROM) 6456bcf6f64SSujith Manoharan len += snprintf(buf + len, sizeof(buf) - len, " PROM"); 6466bcf6f64SSujith Manoharan if (rxfilter & ATH9K_RX_FILTER_PROBEREQ) 6476bcf6f64SSujith Manoharan len += snprintf(buf + len, sizeof(buf) - len, " PROBEREQ"); 6486bcf6f64SSujith Manoharan if (rxfilter & ATH9K_RX_FILTER_PHYERR) 6496bcf6f64SSujith Manoharan len += snprintf(buf + len, sizeof(buf) - len, " PHYERR"); 6506bcf6f64SSujith Manoharan if (rxfilter & ATH9K_RX_FILTER_MYBEACON) 6516bcf6f64SSujith Manoharan len += snprintf(buf + len, sizeof(buf) - len, " MYBEACON"); 6526bcf6f64SSujith Manoharan if (rxfilter & ATH9K_RX_FILTER_COMP_BAR) 6536bcf6f64SSujith Manoharan len += snprintf(buf + len, sizeof(buf) - len, " COMP_BAR"); 6546bcf6f64SSujith Manoharan if (rxfilter & ATH9K_RX_FILTER_PSPOLL) 6556bcf6f64SSujith Manoharan len += snprintf(buf + len, sizeof(buf) - len, " PSPOLL"); 6566bcf6f64SSujith Manoharan if (rxfilter & ATH9K_RX_FILTER_PHYRADAR) 6576bcf6f64SSujith Manoharan len += snprintf(buf + len, sizeof(buf) - len, " PHYRADAR"); 6586bcf6f64SSujith Manoharan if (rxfilter & ATH9K_RX_FILTER_MCAST_BCAST_ALL) 6596bcf6f64SSujith Manoharan len += snprintf(buf + len, sizeof(buf) - len, " MCAST_BCAST_ALL"); 6606bcf6f64SSujith Manoharan if (rxfilter & ATH9K_RX_FILTER_CONTROL_WRAPPER) 6616bcf6f64SSujith Manoharan len += snprintf(buf + len, sizeof(buf) - len, " CONTROL_WRAPPER"); 6626bcf6f64SSujith Manoharan 6636bcf6f64SSujith Manoharan len += snprintf(buf + len, sizeof(buf) - len, "\n"); 6646bcf6f64SSujith Manoharan 6656bcf6f64SSujith Manoharan reg = sc->sc_ah->imask; 6666bcf6f64SSujith Manoharan 6676bcf6f64SSujith Manoharan len += snprintf(buf + len, sizeof(buf) - len, "INTERRUPT-MASK: 0x%x", reg); 6686bcf6f64SSujith Manoharan 6696bcf6f64SSujith Manoharan if (reg & ATH9K_INT_SWBA) 6706bcf6f64SSujith Manoharan len += snprintf(buf + len, sizeof(buf) - len, " SWBA"); 6716bcf6f64SSujith Manoharan if (reg & ATH9K_INT_BMISS) 6726bcf6f64SSujith Manoharan len += snprintf(buf + len, sizeof(buf) - len, " BMISS"); 6736bcf6f64SSujith Manoharan if (reg & ATH9K_INT_CST) 6746bcf6f64SSujith Manoharan len += snprintf(buf + len, sizeof(buf) - len, " CST"); 6756bcf6f64SSujith Manoharan if (reg & ATH9K_INT_RX) 6766bcf6f64SSujith Manoharan len += snprintf(buf + len, sizeof(buf) - len, " RX"); 6776bcf6f64SSujith Manoharan if (reg & ATH9K_INT_RXHP) 6786bcf6f64SSujith Manoharan len += snprintf(buf + len, sizeof(buf) - len, " RXHP"); 6796bcf6f64SSujith Manoharan if (reg & ATH9K_INT_RXLP) 6806bcf6f64SSujith Manoharan len += snprintf(buf + len, sizeof(buf) - len, " RXLP"); 6816bcf6f64SSujith Manoharan if (reg & ATH9K_INT_BB_WATCHDOG) 6826bcf6f64SSujith Manoharan len += snprintf(buf + len, sizeof(buf) - len, " BB_WATCHDOG"); 6836bcf6f64SSujith Manoharan 6846bcf6f64SSujith Manoharan len += snprintf(buf + len, sizeof(buf) - len, "\n"); 68555f6d0ffSBen Greear 68655f6d0ffSBen Greear ath9k_calculate_iter_data(hw, NULL, &iter_data); 68755f6d0ffSBen Greear 6886bcf6f64SSujith Manoharan len += snprintf(buf + len, sizeof(buf) - len, 6896bcf6f64SSujith Manoharan "VIF-COUNTS: AP: %i STA: %i MESH: %i WDS: %i" 690bcf6f96eSSujith Manoharan " ADHOC: %i TOTAL: %hi BEACON-VIF: %hi\n", 69155f6d0ffSBen Greear iter_data.naps, iter_data.nstations, iter_data.nmeshes, 692bcf6f96eSSujith Manoharan iter_data.nwds, iter_data.nadhocs, 69355f6d0ffSBen Greear sc->nvifs, sc->nbcnvifs); 69455f6d0ffSBen Greear 6956bcf6f64SSujith Manoharan if (len > sizeof(buf)) 6966bcf6f64SSujith Manoharan len = sizeof(buf); 69755f6d0ffSBen Greear 69855f6d0ffSBen Greear retval = simple_read_from_buffer(user_buf, count, ppos, buf, len); 69955f6d0ffSBen Greear return retval; 70055f6d0ffSBen Greear } 70155f6d0ffSBen Greear 702f8b815dcSSujith Manoharan static ssize_t read_file_reset(struct file *file, char __user *user_buf, 703f8b815dcSSujith Manoharan size_t count, loff_t *ppos) 704f8b815dcSSujith Manoharan { 705f8b815dcSSujith Manoharan struct ath_softc *sc = file->private_data; 706f8b815dcSSujith Manoharan char buf[512]; 707f8b815dcSSujith Manoharan unsigned int len = 0; 708f8b815dcSSujith Manoharan 709f8b815dcSSujith Manoharan len += snprintf(buf + len, sizeof(buf) - len, 710f8b815dcSSujith Manoharan "%17s: %2d\n", "Baseband Hang", 711f8b815dcSSujith Manoharan sc->debug.stats.reset[RESET_TYPE_BB_HANG]); 712f8b815dcSSujith Manoharan len += snprintf(buf + len, sizeof(buf) - len, 713f8b815dcSSujith Manoharan "%17s: %2d\n", "Baseband Watchdog", 714f8b815dcSSujith Manoharan sc->debug.stats.reset[RESET_TYPE_BB_WATCHDOG]); 715f8b815dcSSujith Manoharan len += snprintf(buf + len, sizeof(buf) - len, 716f8b815dcSSujith Manoharan "%17s: %2d\n", "Fatal HW Error", 717f8b815dcSSujith Manoharan sc->debug.stats.reset[RESET_TYPE_FATAL_INT]); 718f8b815dcSSujith Manoharan len += snprintf(buf + len, sizeof(buf) - len, 719f8b815dcSSujith Manoharan "%17s: %2d\n", "TX HW error", 720f8b815dcSSujith Manoharan sc->debug.stats.reset[RESET_TYPE_TX_ERROR]); 721f8b815dcSSujith Manoharan len += snprintf(buf + len, sizeof(buf) - len, 722f8b815dcSSujith Manoharan "%17s: %2d\n", "TX Path Hang", 723f8b815dcSSujith Manoharan sc->debug.stats.reset[RESET_TYPE_TX_HANG]); 724f8b815dcSSujith Manoharan len += snprintf(buf + len, sizeof(buf) - len, 725f8b815dcSSujith Manoharan "%17s: %2d\n", "PLL RX Hang", 726f8b815dcSSujith Manoharan sc->debug.stats.reset[RESET_TYPE_PLL_HANG]); 727b88083bfSRajkumar Manoharan len += snprintf(buf + len, sizeof(buf) - len, 728b88083bfSRajkumar Manoharan "%17s: %2d\n", "MCI Reset", 729b88083bfSRajkumar Manoharan sc->debug.stats.reset[RESET_TYPE_MCI]); 730f8b815dcSSujith Manoharan 731f8b815dcSSujith Manoharan if (len > sizeof(buf)) 732f8b815dcSSujith Manoharan len = sizeof(buf); 733f8b815dcSSujith Manoharan 734f8b815dcSSujith Manoharan return simple_read_from_buffer(user_buf, count, ppos, buf, len); 735f8b815dcSSujith Manoharan } 736f8b815dcSSujith Manoharan 737066dae93SFelix Fietkau void ath_debug_stat_tx(struct ath_softc *sc, struct ath_buf *bf, 73855797b1aSFelix Fietkau struct ath_tx_status *ts, struct ath_txq *txq, 73955797b1aSFelix Fietkau unsigned int flags) 740fec247c0SSujith { 741cf3af748SRajkumar Manoharan #define TX_SAMP_DBG(c) (sc->debug.bb_mac_samp[sc->debug.sampidx].ts\ 742cf3af748SRajkumar Manoharan [sc->debug.tsidx].c) 7435bec3e5aSFelix Fietkau int qnum = txq->axq_qnum; 744066dae93SFelix Fietkau 745066dae93SFelix Fietkau TX_STAT_INC(qnum, tx_pkts_all); 746066dae93SFelix Fietkau sc->debug.stats.txstats[qnum].tx_bytes_all += bf->bf_mpdu->len; 74799c15bf5SBen Greear 748fec247c0SSujith if (bf_isampdu(bf)) { 749156369faSFelix Fietkau if (flags & ATH_TX_ERROR) 750066dae93SFelix Fietkau TX_STAT_INC(qnum, a_xretries); 751fec247c0SSujith else 752066dae93SFelix Fietkau TX_STAT_INC(qnum, a_completed); 753fec247c0SSujith } else { 75455797b1aSFelix Fietkau if (ts->ts_status & ATH9K_TXERR_XRETRY) 7555a6f78afSFelix Fietkau TX_STAT_INC(qnum, xretries); 7565a6f78afSFelix Fietkau else 757066dae93SFelix Fietkau TX_STAT_INC(qnum, completed); 758fec247c0SSujith } 759fec247c0SSujith 7604d900389SBen Greear if (ts->ts_status & ATH9K_TXERR_FILT) 7614d900389SBen Greear TX_STAT_INC(qnum, txerr_filtered); 762db1a052bSFelix Fietkau if (ts->ts_status & ATH9K_TXERR_FIFO) 763066dae93SFelix Fietkau TX_STAT_INC(qnum, fifo_underrun); 764db1a052bSFelix Fietkau if (ts->ts_status & ATH9K_TXERR_XTXOP) 765066dae93SFelix Fietkau TX_STAT_INC(qnum, xtxop); 766db1a052bSFelix Fietkau if (ts->ts_status & ATH9K_TXERR_TIMER_EXPIRED) 767066dae93SFelix Fietkau TX_STAT_INC(qnum, timer_exp); 768db1a052bSFelix Fietkau if (ts->ts_flags & ATH9K_TX_DESC_CFG_ERR) 769066dae93SFelix Fietkau TX_STAT_INC(qnum, desc_cfg_err); 770db1a052bSFelix Fietkau if (ts->ts_flags & ATH9K_TX_DATA_UNDERRUN) 771066dae93SFelix Fietkau TX_STAT_INC(qnum, data_underrun); 772db1a052bSFelix Fietkau if (ts->ts_flags & ATH9K_TX_DELIM_UNDERRUN) 773066dae93SFelix Fietkau TX_STAT_INC(qnum, delim_underrun); 774cf3af748SRajkumar Manoharan 7755baec742SFelix Fietkau #ifdef CONFIG_ATH9K_MAC_DEBUG 776cf3af748SRajkumar Manoharan spin_lock(&sc->debug.samp_lock); 777cf3af748SRajkumar Manoharan TX_SAMP_DBG(jiffies) = jiffies; 778cf3af748SRajkumar Manoharan TX_SAMP_DBG(rssi_ctl0) = ts->ts_rssi_ctl0; 779cf3af748SRajkumar Manoharan TX_SAMP_DBG(rssi_ctl1) = ts->ts_rssi_ctl1; 780cf3af748SRajkumar Manoharan TX_SAMP_DBG(rssi_ctl2) = ts->ts_rssi_ctl2; 781cf3af748SRajkumar Manoharan TX_SAMP_DBG(rssi_ext0) = ts->ts_rssi_ext0; 782cf3af748SRajkumar Manoharan TX_SAMP_DBG(rssi_ext1) = ts->ts_rssi_ext1; 783cf3af748SRajkumar Manoharan TX_SAMP_DBG(rssi_ext2) = ts->ts_rssi_ext2; 784cf3af748SRajkumar Manoharan TX_SAMP_DBG(rateindex) = ts->ts_rateindex; 785cf3af748SRajkumar Manoharan TX_SAMP_DBG(isok) = !!(ts->ts_status & ATH9K_TXERR_MASK); 786cf3af748SRajkumar Manoharan TX_SAMP_DBG(rts_fail_cnt) = ts->ts_shortretry; 787cf3af748SRajkumar Manoharan TX_SAMP_DBG(data_fail_cnt) = ts->ts_longretry; 788cf3af748SRajkumar Manoharan TX_SAMP_DBG(rssi) = ts->ts_rssi; 789cf3af748SRajkumar Manoharan TX_SAMP_DBG(tid) = ts->tid; 790cf3af748SRajkumar Manoharan TX_SAMP_DBG(qid) = ts->qid; 79112932180SMohammed Shafi Shajakhan 79212932180SMohammed Shafi Shajakhan if (ts->ts_flags & ATH9K_TX_BA) { 79312932180SMohammed Shafi Shajakhan TX_SAMP_DBG(ba_low) = ts->ba_low; 79412932180SMohammed Shafi Shajakhan TX_SAMP_DBG(ba_high) = ts->ba_high; 79512932180SMohammed Shafi Shajakhan } else { 79612932180SMohammed Shafi Shajakhan TX_SAMP_DBG(ba_low) = 0; 79712932180SMohammed Shafi Shajakhan TX_SAMP_DBG(ba_high) = 0; 79812932180SMohammed Shafi Shajakhan } 79912932180SMohammed Shafi Shajakhan 800cf3af748SRajkumar Manoharan sc->debug.tsidx = (sc->debug.tsidx + 1) % ATH_DBG_MAX_SAMPLES; 801cf3af748SRajkumar Manoharan spin_unlock(&sc->debug.samp_lock); 8025baec742SFelix Fietkau #endif 803cf3af748SRajkumar Manoharan 804cf3af748SRajkumar Manoharan #undef TX_SAMP_DBG 805fec247c0SSujith } 806fec247c0SSujith 807fec247c0SSujith static const struct file_operations fops_xmit = { 808fec247c0SSujith .read = read_file_xmit, 809234e3405SStephen Boyd .open = simple_open, 8106038f373SArnd Bergmann .owner = THIS_MODULE, 8116038f373SArnd Bergmann .llseek = default_llseek, 812fec247c0SSujith }; 813203c4805SLuis R. Rodriguez 814c0b74876SSujith Manoharan static const struct file_operations fops_queues = { 815c0b74876SSujith Manoharan .read = read_file_queues, 816c0b74876SSujith Manoharan .open = simple_open, 817c0b74876SSujith Manoharan .owner = THIS_MODULE, 818c0b74876SSujith Manoharan .llseek = default_llseek, 819c0b74876SSujith Manoharan }; 820c0b74876SSujith Manoharan 82155f6d0ffSBen Greear static const struct file_operations fops_misc = { 82255f6d0ffSBen Greear .read = read_file_misc, 823234e3405SStephen Boyd .open = simple_open, 82455f6d0ffSBen Greear .owner = THIS_MODULE, 82555f6d0ffSBen Greear .llseek = default_llseek, 82655f6d0ffSBen Greear }; 82755f6d0ffSBen Greear 828f8b815dcSSujith Manoharan static const struct file_operations fops_reset = { 829f8b815dcSSujith Manoharan .read = read_file_reset, 830234e3405SStephen Boyd .open = simple_open, 831f8b815dcSSujith Manoharan .owner = THIS_MODULE, 832f8b815dcSSujith Manoharan .llseek = default_llseek, 833f8b815dcSSujith Manoharan }; 834f8b815dcSSujith Manoharan 8351395d3f0SSujith static ssize_t read_file_recv(struct file *file, char __user *user_buf, 8361395d3f0SSujith size_t count, loff_t *ppos) 8371395d3f0SSujith { 8381395d3f0SSujith #define PHY_ERR(s, p) \ 8394203214eSSujith Manoharan len += snprintf(buf + len, size - len, "%22s : %10u\n", s, \ 8401395d3f0SSujith sc->debug.stats.rxstats.phy_err_stats[p]); 8411395d3f0SSujith 84224a0731eSBen Greear #define RXS_ERR(s, e) \ 84324a0731eSBen Greear do { \ 84424a0731eSBen Greear len += snprintf(buf + len, size - len, \ 84524a0731eSBen Greear "%22s : %10u\n", s, \ 84624a0731eSBen Greear sc->debug.stats.rxstats.e); \ 84724a0731eSBen Greear } while (0) 84824a0731eSBen Greear 8491395d3f0SSujith struct ath_softc *sc = file->private_data; 8501395d3f0SSujith char *buf; 8514203214eSSujith Manoharan unsigned int len = 0, size = 1600; 8521395d3f0SSujith ssize_t retval = 0; 8531395d3f0SSujith 8541395d3f0SSujith buf = kzalloc(size, GFP_KERNEL); 8551395d3f0SSujith if (buf == NULL) 85604236066SDan Carpenter return -ENOMEM; 8571395d3f0SSujith 85824a0731eSBen Greear RXS_ERR("CRC ERR", crc_err); 85924a0731eSBen Greear RXS_ERR("DECRYPT CRC ERR", decrypt_crc_err); 86024a0731eSBen Greear RXS_ERR("PHY ERR", phy_err); 86124a0731eSBen Greear RXS_ERR("MIC ERR", mic_err); 86224a0731eSBen Greear RXS_ERR("PRE-DELIM CRC ERR", pre_delim_crc_err); 86324a0731eSBen Greear RXS_ERR("POST-DELIM CRC ERR", post_delim_crc_err); 86424a0731eSBen Greear RXS_ERR("DECRYPT BUSY ERR", decrypt_busy_err); 86524a0731eSBen Greear RXS_ERR("RX-LENGTH-ERR", rx_len_err); 86624a0731eSBen Greear RXS_ERR("RX-OOM-ERR", rx_oom_err); 86724a0731eSBen Greear RXS_ERR("RX-RATE-ERR", rx_rate_err); 86824a0731eSBen Greear RXS_ERR("RX-TOO-MANY-FRAGS", rx_too_many_frags_err); 8691395d3f0SSujith 8704203214eSSujith Manoharan PHY_ERR("UNDERRUN ERR", ATH9K_PHYERR_UNDERRUN); 8714203214eSSujith Manoharan PHY_ERR("TIMING ERR", ATH9K_PHYERR_TIMING); 8724203214eSSujith Manoharan PHY_ERR("PARITY ERR", ATH9K_PHYERR_PARITY); 8734203214eSSujith Manoharan PHY_ERR("RATE ERR", ATH9K_PHYERR_RATE); 8744203214eSSujith Manoharan PHY_ERR("LENGTH ERR", ATH9K_PHYERR_LENGTH); 8754203214eSSujith Manoharan PHY_ERR("RADAR ERR", ATH9K_PHYERR_RADAR); 8764203214eSSujith Manoharan PHY_ERR("SERVICE ERR", ATH9K_PHYERR_SERVICE); 8774203214eSSujith Manoharan PHY_ERR("TOR ERR", ATH9K_PHYERR_TOR); 8784203214eSSujith Manoharan PHY_ERR("OFDM-TIMING ERR", ATH9K_PHYERR_OFDM_TIMING); 8794203214eSSujith Manoharan PHY_ERR("OFDM-SIGNAL-PARITY ERR", ATH9K_PHYERR_OFDM_SIGNAL_PARITY); 8804203214eSSujith Manoharan PHY_ERR("OFDM-RATE ERR", ATH9K_PHYERR_OFDM_RATE_ILLEGAL); 8814203214eSSujith Manoharan PHY_ERR("OFDM-LENGTH ERR", ATH9K_PHYERR_OFDM_LENGTH_ILLEGAL); 8824203214eSSujith Manoharan PHY_ERR("OFDM-POWER-DROP ERR", ATH9K_PHYERR_OFDM_POWER_DROP); 8834203214eSSujith Manoharan PHY_ERR("OFDM-SERVICE ERR", ATH9K_PHYERR_OFDM_SERVICE); 8844203214eSSujith Manoharan PHY_ERR("OFDM-RESTART ERR", ATH9K_PHYERR_OFDM_RESTART); 8854203214eSSujith Manoharan PHY_ERR("FALSE-RADAR-EXT ERR", ATH9K_PHYERR_FALSE_RADAR_EXT); 8864203214eSSujith Manoharan PHY_ERR("CCK-TIMING ERR", ATH9K_PHYERR_CCK_TIMING); 8874203214eSSujith Manoharan PHY_ERR("CCK-HEADER-CRC ERR", ATH9K_PHYERR_CCK_HEADER_CRC); 8884203214eSSujith Manoharan PHY_ERR("CCK-RATE ERR", ATH9K_PHYERR_CCK_RATE_ILLEGAL); 8894203214eSSujith Manoharan PHY_ERR("CCK-SERVICE ERR", ATH9K_PHYERR_CCK_SERVICE); 8904203214eSSujith Manoharan PHY_ERR("CCK-RESTART ERR", ATH9K_PHYERR_CCK_RESTART); 8914203214eSSujith Manoharan PHY_ERR("CCK-LENGTH ERR", ATH9K_PHYERR_CCK_LENGTH_ILLEGAL); 8924203214eSSujith Manoharan PHY_ERR("CCK-POWER-DROP ERR", ATH9K_PHYERR_CCK_POWER_DROP); 8934203214eSSujith Manoharan PHY_ERR("HT-CRC ERR", ATH9K_PHYERR_HT_CRC_ERROR); 8944203214eSSujith Manoharan PHY_ERR("HT-LENGTH ERR", ATH9K_PHYERR_HT_LENGTH_ILLEGAL); 8954203214eSSujith Manoharan PHY_ERR("HT-RATE ERR", ATH9K_PHYERR_HT_RATE_ILLEGAL); 8964203214eSSujith Manoharan 89724a0731eSBen Greear RXS_ERR("RX-Pkts-All", rx_pkts_all); 89824a0731eSBen Greear RXS_ERR("RX-Bytes-All", rx_bytes_all); 89924a0731eSBen Greear RXS_ERR("RX-Beacons", rx_beacons); 90024a0731eSBen Greear RXS_ERR("RX-Frags", rx_frags); 9019b99e665SSimon Wunderlich RXS_ERR("RX-Spectral", rx_spectral); 90299c15bf5SBen Greear 9032b87f3aaSDan Carpenter if (len > size) 9042b87f3aaSDan Carpenter len = size; 9052b87f3aaSDan Carpenter 9061395d3f0SSujith retval = simple_read_from_buffer(user_buf, count, ppos, buf, len); 9071395d3f0SSujith kfree(buf); 9081395d3f0SSujith 9091395d3f0SSujith return retval; 9101395d3f0SSujith 91124a0731eSBen Greear #undef RXS_ERR 9121395d3f0SSujith #undef PHY_ERR 9131395d3f0SSujith } 9141395d3f0SSujith 9158e6f5aa2SFelix Fietkau void ath_debug_stat_rx(struct ath_softc *sc, struct ath_rx_status *rs) 9161395d3f0SSujith { 9171395d3f0SSujith #define RX_PHY_ERR_INC(c) sc->debug.stats.rxstats.phy_err_stats[c]++ 918cf3af748SRajkumar Manoharan #define RX_SAMP_DBG(c) (sc->debug.bb_mac_samp[sc->debug.sampidx].rs\ 919cf3af748SRajkumar Manoharan [sc->debug.rsidx].c) 9201395d3f0SSujith 92199c15bf5SBen Greear RX_STAT_INC(rx_pkts_all); 92299c15bf5SBen Greear sc->debug.stats.rxstats.rx_bytes_all += rs->rs_datalen; 92399c15bf5SBen Greear 9248e6f5aa2SFelix Fietkau if (rs->rs_status & ATH9K_RXERR_CRC) 9251395d3f0SSujith RX_STAT_INC(crc_err); 9268e6f5aa2SFelix Fietkau if (rs->rs_status & ATH9K_RXERR_DECRYPT) 9271395d3f0SSujith RX_STAT_INC(decrypt_crc_err); 9288e6f5aa2SFelix Fietkau if (rs->rs_status & ATH9K_RXERR_MIC) 9291395d3f0SSujith RX_STAT_INC(mic_err); 9308e6f5aa2SFelix Fietkau if (rs->rs_status & ATH9K_RX_DELIM_CRC_PRE) 9311395d3f0SSujith RX_STAT_INC(pre_delim_crc_err); 9328e6f5aa2SFelix Fietkau if (rs->rs_status & ATH9K_RX_DELIM_CRC_POST) 9331395d3f0SSujith RX_STAT_INC(post_delim_crc_err); 9348e6f5aa2SFelix Fietkau if (rs->rs_status & ATH9K_RX_DECRYPT_BUSY) 9351395d3f0SSujith RX_STAT_INC(decrypt_busy_err); 9361395d3f0SSujith 9378e6f5aa2SFelix Fietkau if (rs->rs_status & ATH9K_RXERR_PHY) { 9381395d3f0SSujith RX_STAT_INC(phy_err); 939dbb07f00SSujith Manoharan if (rs->rs_phyerr < ATH9K_PHYERR_MAX) 940dbb07f00SSujith Manoharan RX_PHY_ERR_INC(rs->rs_phyerr); 9411395d3f0SSujith } 9421395d3f0SSujith 9435baec742SFelix Fietkau #ifdef CONFIG_ATH9K_MAC_DEBUG 944cf3af748SRajkumar Manoharan spin_lock(&sc->debug.samp_lock); 945cf3af748SRajkumar Manoharan RX_SAMP_DBG(jiffies) = jiffies; 946cf3af748SRajkumar Manoharan RX_SAMP_DBG(rssi_ctl0) = rs->rs_rssi_ctl0; 947cf3af748SRajkumar Manoharan RX_SAMP_DBG(rssi_ctl1) = rs->rs_rssi_ctl1; 948cf3af748SRajkumar Manoharan RX_SAMP_DBG(rssi_ctl2) = rs->rs_rssi_ctl2; 949cf3af748SRajkumar Manoharan RX_SAMP_DBG(rssi_ext0) = rs->rs_rssi_ext0; 950cf3af748SRajkumar Manoharan RX_SAMP_DBG(rssi_ext1) = rs->rs_rssi_ext1; 951cf3af748SRajkumar Manoharan RX_SAMP_DBG(rssi_ext2) = rs->rs_rssi_ext2; 952cf3af748SRajkumar Manoharan RX_SAMP_DBG(antenna) = rs->rs_antenna; 953cf3af748SRajkumar Manoharan RX_SAMP_DBG(rssi) = rs->rs_rssi; 954cf3af748SRajkumar Manoharan RX_SAMP_DBG(rate) = rs->rs_rate; 955cf3af748SRajkumar Manoharan RX_SAMP_DBG(is_mybeacon) = rs->is_mybeacon; 956cf3af748SRajkumar Manoharan 957cf3af748SRajkumar Manoharan sc->debug.rsidx = (sc->debug.rsidx + 1) % ATH_DBG_MAX_SAMPLES; 958cf3af748SRajkumar Manoharan spin_unlock(&sc->debug.samp_lock); 959cf3af748SRajkumar Manoharan 9605baec742SFelix Fietkau #endif 9615baec742SFelix Fietkau 9621395d3f0SSujith #undef RX_PHY_ERR_INC 963cf3af748SRajkumar Manoharan #undef RX_SAMP_DBG 9641395d3f0SSujith } 9651395d3f0SSujith 9661395d3f0SSujith static const struct file_operations fops_recv = { 9671395d3f0SSujith .read = read_file_recv, 968234e3405SStephen Boyd .open = simple_open, 9696038f373SArnd Bergmann .owner = THIS_MODULE, 9706038f373SArnd Bergmann .llseek = default_llseek, 9711395d3f0SSujith }; 9721395d3f0SSujith 973e93d083fSSimon Wunderlich static ssize_t read_file_spec_scan_ctl(struct file *file, char __user *user_buf, 974e93d083fSSimon Wunderlich size_t count, loff_t *ppos) 975e93d083fSSimon Wunderlich { 976e93d083fSSimon Wunderlich struct ath_softc *sc = file->private_data; 977e93d083fSSimon Wunderlich char *mode = ""; 978e93d083fSSimon Wunderlich unsigned int len; 979e93d083fSSimon Wunderlich 980e93d083fSSimon Wunderlich switch (sc->spectral_mode) { 981e93d083fSSimon Wunderlich case SPECTRAL_DISABLED: 982e93d083fSSimon Wunderlich mode = "disable"; 983e93d083fSSimon Wunderlich break; 984e93d083fSSimon Wunderlich case SPECTRAL_BACKGROUND: 985e93d083fSSimon Wunderlich mode = "background"; 986e93d083fSSimon Wunderlich break; 987e93d083fSSimon Wunderlich case SPECTRAL_CHANSCAN: 988e93d083fSSimon Wunderlich mode = "chanscan"; 989e93d083fSSimon Wunderlich break; 990e93d083fSSimon Wunderlich case SPECTRAL_MANUAL: 991e93d083fSSimon Wunderlich mode = "manual"; 992e93d083fSSimon Wunderlich break; 993e93d083fSSimon Wunderlich } 994e93d083fSSimon Wunderlich len = strlen(mode); 995e93d083fSSimon Wunderlich return simple_read_from_buffer(user_buf, count, ppos, mode, len); 996e93d083fSSimon Wunderlich } 997e93d083fSSimon Wunderlich 998e93d083fSSimon Wunderlich static ssize_t write_file_spec_scan_ctl(struct file *file, 999e93d083fSSimon Wunderlich const char __user *user_buf, 1000e93d083fSSimon Wunderlich size_t count, loff_t *ppos) 1001e93d083fSSimon Wunderlich { 1002e93d083fSSimon Wunderlich struct ath_softc *sc = file->private_data; 1003e93d083fSSimon Wunderlich struct ath_common *common = ath9k_hw_common(sc->sc_ah); 1004e93d083fSSimon Wunderlich char buf[32]; 1005e93d083fSSimon Wunderlich ssize_t len; 1006e93d083fSSimon Wunderlich 1007e93d083fSSimon Wunderlich len = min(count, sizeof(buf) - 1); 1008e93d083fSSimon Wunderlich if (copy_from_user(buf, user_buf, len)) 1009e93d083fSSimon Wunderlich return -EFAULT; 1010e93d083fSSimon Wunderlich 1011e93d083fSSimon Wunderlich buf[len] = '\0'; 1012e93d083fSSimon Wunderlich 1013e93d083fSSimon Wunderlich if (strncmp("trigger", buf, 7) == 0) { 1014e93d083fSSimon Wunderlich ath9k_spectral_scan_trigger(sc->hw); 1015e93d083fSSimon Wunderlich } else if (strncmp("background", buf, 9) == 0) { 1016e93d083fSSimon Wunderlich ath9k_spectral_scan_config(sc->hw, SPECTRAL_BACKGROUND); 1017e93d083fSSimon Wunderlich ath_dbg(common, CONFIG, "spectral scan: background mode enabled\n"); 1018e93d083fSSimon Wunderlich } else if (strncmp("chanscan", buf, 8) == 0) { 1019e93d083fSSimon Wunderlich ath9k_spectral_scan_config(sc->hw, SPECTRAL_CHANSCAN); 1020e93d083fSSimon Wunderlich ath_dbg(common, CONFIG, "spectral scan: channel scan mode enabled\n"); 1021e93d083fSSimon Wunderlich } else if (strncmp("manual", buf, 6) == 0) { 1022e93d083fSSimon Wunderlich ath9k_spectral_scan_config(sc->hw, SPECTRAL_MANUAL); 1023e93d083fSSimon Wunderlich ath_dbg(common, CONFIG, "spectral scan: manual mode enabled\n"); 1024e93d083fSSimon Wunderlich } else if (strncmp("disable", buf, 7) == 0) { 1025e93d083fSSimon Wunderlich ath9k_spectral_scan_config(sc->hw, SPECTRAL_DISABLED); 1026e93d083fSSimon Wunderlich ath_dbg(common, CONFIG, "spectral scan: disabled\n"); 1027e93d083fSSimon Wunderlich } else { 1028e93d083fSSimon Wunderlich return -EINVAL; 1029e93d083fSSimon Wunderlich } 1030e93d083fSSimon Wunderlich 1031e93d083fSSimon Wunderlich return count; 1032e93d083fSSimon Wunderlich } 1033e93d083fSSimon Wunderlich 1034e93d083fSSimon Wunderlich static const struct file_operations fops_spec_scan_ctl = { 1035e93d083fSSimon Wunderlich .read = read_file_spec_scan_ctl, 1036e93d083fSSimon Wunderlich .write = write_file_spec_scan_ctl, 1037e93d083fSSimon Wunderlich .open = simple_open, 1038e93d083fSSimon Wunderlich .owner = THIS_MODULE, 1039e93d083fSSimon Wunderlich .llseek = default_llseek, 1040e93d083fSSimon Wunderlich }; 1041e93d083fSSimon Wunderlich 104204ccd4a1SSimon Wunderlich static ssize_t read_file_spectral_short_repeat(struct file *file, 104304ccd4a1SSimon Wunderlich char __user *user_buf, 104404ccd4a1SSimon Wunderlich size_t count, loff_t *ppos) 104504ccd4a1SSimon Wunderlich { 104604ccd4a1SSimon Wunderlich struct ath_softc *sc = file->private_data; 104704ccd4a1SSimon Wunderlich char buf[32]; 104804ccd4a1SSimon Wunderlich unsigned int len; 104904ccd4a1SSimon Wunderlich 105004ccd4a1SSimon Wunderlich len = sprintf(buf, "%d\n", sc->spec_config.short_repeat); 105104ccd4a1SSimon Wunderlich return simple_read_from_buffer(user_buf, count, ppos, buf, len); 105204ccd4a1SSimon Wunderlich } 105304ccd4a1SSimon Wunderlich 105404ccd4a1SSimon Wunderlich static ssize_t write_file_spectral_short_repeat(struct file *file, 105504ccd4a1SSimon Wunderlich const char __user *user_buf, 105604ccd4a1SSimon Wunderlich size_t count, loff_t *ppos) 105704ccd4a1SSimon Wunderlich { 105804ccd4a1SSimon Wunderlich struct ath_softc *sc = file->private_data; 105904ccd4a1SSimon Wunderlich unsigned long val; 106004ccd4a1SSimon Wunderlich char buf[32]; 106104ccd4a1SSimon Wunderlich ssize_t len; 106204ccd4a1SSimon Wunderlich 106304ccd4a1SSimon Wunderlich len = min(count, sizeof(buf) - 1); 106404ccd4a1SSimon Wunderlich if (copy_from_user(buf, user_buf, len)) 106504ccd4a1SSimon Wunderlich return -EFAULT; 106604ccd4a1SSimon Wunderlich 106704ccd4a1SSimon Wunderlich buf[len] = '\0'; 106804ccd4a1SSimon Wunderlich if (kstrtoul(buf, 0, &val)) 106904ccd4a1SSimon Wunderlich return -EINVAL; 107004ccd4a1SSimon Wunderlich 107104ccd4a1SSimon Wunderlich if (val < 0 || val > 1) 107204ccd4a1SSimon Wunderlich return -EINVAL; 107304ccd4a1SSimon Wunderlich 107404ccd4a1SSimon Wunderlich sc->spec_config.short_repeat = val; 107504ccd4a1SSimon Wunderlich return count; 107604ccd4a1SSimon Wunderlich } 107704ccd4a1SSimon Wunderlich 107804ccd4a1SSimon Wunderlich static const struct file_operations fops_spectral_short_repeat = { 107904ccd4a1SSimon Wunderlich .read = read_file_spectral_short_repeat, 108004ccd4a1SSimon Wunderlich .write = write_file_spectral_short_repeat, 108104ccd4a1SSimon Wunderlich .open = simple_open, 108204ccd4a1SSimon Wunderlich .owner = THIS_MODULE, 108304ccd4a1SSimon Wunderlich .llseek = default_llseek, 108404ccd4a1SSimon Wunderlich }; 108504ccd4a1SSimon Wunderlich 108604ccd4a1SSimon Wunderlich static ssize_t read_file_spectral_count(struct file *file, 108704ccd4a1SSimon Wunderlich char __user *user_buf, 108804ccd4a1SSimon Wunderlich size_t count, loff_t *ppos) 108904ccd4a1SSimon Wunderlich { 109004ccd4a1SSimon Wunderlich struct ath_softc *sc = file->private_data; 109104ccd4a1SSimon Wunderlich char buf[32]; 109204ccd4a1SSimon Wunderlich unsigned int len; 109304ccd4a1SSimon Wunderlich 109404ccd4a1SSimon Wunderlich len = sprintf(buf, "%d\n", sc->spec_config.count); 109504ccd4a1SSimon Wunderlich return simple_read_from_buffer(user_buf, count, ppos, buf, len); 109604ccd4a1SSimon Wunderlich } 109704ccd4a1SSimon Wunderlich 109804ccd4a1SSimon Wunderlich static ssize_t write_file_spectral_count(struct file *file, 109904ccd4a1SSimon Wunderlich const char __user *user_buf, 110004ccd4a1SSimon Wunderlich size_t count, loff_t *ppos) 110104ccd4a1SSimon Wunderlich { 110204ccd4a1SSimon Wunderlich struct ath_softc *sc = file->private_data; 110304ccd4a1SSimon Wunderlich unsigned long val; 110404ccd4a1SSimon Wunderlich char buf[32]; 110504ccd4a1SSimon Wunderlich ssize_t len; 110604ccd4a1SSimon Wunderlich 110704ccd4a1SSimon Wunderlich len = min(count, sizeof(buf) - 1); 110804ccd4a1SSimon Wunderlich if (copy_from_user(buf, user_buf, len)) 110904ccd4a1SSimon Wunderlich return -EFAULT; 111004ccd4a1SSimon Wunderlich 111104ccd4a1SSimon Wunderlich buf[len] = '\0'; 111204ccd4a1SSimon Wunderlich if (kstrtoul(buf, 0, &val)) 111304ccd4a1SSimon Wunderlich return -EINVAL; 111404ccd4a1SSimon Wunderlich 111504ccd4a1SSimon Wunderlich if (val < 0 || val > 255) 111604ccd4a1SSimon Wunderlich return -EINVAL; 111704ccd4a1SSimon Wunderlich 111804ccd4a1SSimon Wunderlich sc->spec_config.count = val; 111904ccd4a1SSimon Wunderlich return count; 112004ccd4a1SSimon Wunderlich } 112104ccd4a1SSimon Wunderlich 112204ccd4a1SSimon Wunderlich static const struct file_operations fops_spectral_count = { 112304ccd4a1SSimon Wunderlich .read = read_file_spectral_count, 112404ccd4a1SSimon Wunderlich .write = write_file_spectral_count, 112504ccd4a1SSimon Wunderlich .open = simple_open, 112604ccd4a1SSimon Wunderlich .owner = THIS_MODULE, 112704ccd4a1SSimon Wunderlich .llseek = default_llseek, 112804ccd4a1SSimon Wunderlich }; 112904ccd4a1SSimon Wunderlich 113004ccd4a1SSimon Wunderlich static ssize_t read_file_spectral_period(struct file *file, 113104ccd4a1SSimon Wunderlich char __user *user_buf, 113204ccd4a1SSimon Wunderlich size_t count, loff_t *ppos) 113304ccd4a1SSimon Wunderlich { 113404ccd4a1SSimon Wunderlich struct ath_softc *sc = file->private_data; 113504ccd4a1SSimon Wunderlich char buf[32]; 113604ccd4a1SSimon Wunderlich unsigned int len; 113704ccd4a1SSimon Wunderlich 113804ccd4a1SSimon Wunderlich len = sprintf(buf, "%d\n", sc->spec_config.period); 113904ccd4a1SSimon Wunderlich return simple_read_from_buffer(user_buf, count, ppos, buf, len); 114004ccd4a1SSimon Wunderlich } 114104ccd4a1SSimon Wunderlich 114204ccd4a1SSimon Wunderlich static ssize_t write_file_spectral_period(struct file *file, 114304ccd4a1SSimon Wunderlich const char __user *user_buf, 114404ccd4a1SSimon Wunderlich size_t count, loff_t *ppos) 114504ccd4a1SSimon Wunderlich { 114604ccd4a1SSimon Wunderlich struct ath_softc *sc = file->private_data; 114704ccd4a1SSimon Wunderlich unsigned long val; 114804ccd4a1SSimon Wunderlich char buf[32]; 114904ccd4a1SSimon Wunderlich ssize_t len; 115004ccd4a1SSimon Wunderlich 115104ccd4a1SSimon Wunderlich len = min(count, sizeof(buf) - 1); 115204ccd4a1SSimon Wunderlich if (copy_from_user(buf, user_buf, len)) 115304ccd4a1SSimon Wunderlich return -EFAULT; 115404ccd4a1SSimon Wunderlich 115504ccd4a1SSimon Wunderlich buf[len] = '\0'; 115604ccd4a1SSimon Wunderlich if (kstrtoul(buf, 0, &val)) 115704ccd4a1SSimon Wunderlich return -EINVAL; 115804ccd4a1SSimon Wunderlich 115904ccd4a1SSimon Wunderlich if (val < 0 || val > 255) 116004ccd4a1SSimon Wunderlich return -EINVAL; 116104ccd4a1SSimon Wunderlich 116204ccd4a1SSimon Wunderlich sc->spec_config.period = val; 116304ccd4a1SSimon Wunderlich return count; 116404ccd4a1SSimon Wunderlich } 116504ccd4a1SSimon Wunderlich 116604ccd4a1SSimon Wunderlich static const struct file_operations fops_spectral_period = { 116704ccd4a1SSimon Wunderlich .read = read_file_spectral_period, 116804ccd4a1SSimon Wunderlich .write = write_file_spectral_period, 116904ccd4a1SSimon Wunderlich .open = simple_open, 117004ccd4a1SSimon Wunderlich .owner = THIS_MODULE, 117104ccd4a1SSimon Wunderlich .llseek = default_llseek, 117204ccd4a1SSimon Wunderlich }; 117304ccd4a1SSimon Wunderlich 117404ccd4a1SSimon Wunderlich static ssize_t read_file_spectral_fft_period(struct file *file, 117504ccd4a1SSimon Wunderlich char __user *user_buf, 117604ccd4a1SSimon Wunderlich size_t count, loff_t *ppos) 117704ccd4a1SSimon Wunderlich { 117804ccd4a1SSimon Wunderlich struct ath_softc *sc = file->private_data; 117904ccd4a1SSimon Wunderlich char buf[32]; 118004ccd4a1SSimon Wunderlich unsigned int len; 118104ccd4a1SSimon Wunderlich 118204ccd4a1SSimon Wunderlich len = sprintf(buf, "%d\n", sc->spec_config.fft_period); 118304ccd4a1SSimon Wunderlich return simple_read_from_buffer(user_buf, count, ppos, buf, len); 118404ccd4a1SSimon Wunderlich } 118504ccd4a1SSimon Wunderlich 118604ccd4a1SSimon Wunderlich static ssize_t write_file_spectral_fft_period(struct file *file, 118704ccd4a1SSimon Wunderlich const char __user *user_buf, 118804ccd4a1SSimon Wunderlich size_t count, loff_t *ppos) 118904ccd4a1SSimon Wunderlich { 119004ccd4a1SSimon Wunderlich struct ath_softc *sc = file->private_data; 119104ccd4a1SSimon Wunderlich unsigned long val; 119204ccd4a1SSimon Wunderlich char buf[32]; 119304ccd4a1SSimon Wunderlich ssize_t len; 119404ccd4a1SSimon Wunderlich 119504ccd4a1SSimon Wunderlich len = min(count, sizeof(buf) - 1); 119604ccd4a1SSimon Wunderlich if (copy_from_user(buf, user_buf, len)) 119704ccd4a1SSimon Wunderlich return -EFAULT; 119804ccd4a1SSimon Wunderlich 119904ccd4a1SSimon Wunderlich buf[len] = '\0'; 120004ccd4a1SSimon Wunderlich if (kstrtoul(buf, 0, &val)) 120104ccd4a1SSimon Wunderlich return -EINVAL; 120204ccd4a1SSimon Wunderlich 120304ccd4a1SSimon Wunderlich if (val < 0 || val > 15) 120404ccd4a1SSimon Wunderlich return -EINVAL; 120504ccd4a1SSimon Wunderlich 120604ccd4a1SSimon Wunderlich sc->spec_config.fft_period = val; 120704ccd4a1SSimon Wunderlich return count; 120804ccd4a1SSimon Wunderlich } 120904ccd4a1SSimon Wunderlich 121004ccd4a1SSimon Wunderlich static const struct file_operations fops_spectral_fft_period = { 121104ccd4a1SSimon Wunderlich .read = read_file_spectral_fft_period, 121204ccd4a1SSimon Wunderlich .write = write_file_spectral_fft_period, 121304ccd4a1SSimon Wunderlich .open = simple_open, 121404ccd4a1SSimon Wunderlich .owner = THIS_MODULE, 121504ccd4a1SSimon Wunderlich .llseek = default_llseek, 121604ccd4a1SSimon Wunderlich }; 121704ccd4a1SSimon Wunderlich 1218e93d083fSSimon Wunderlich static struct dentry *create_buf_file_handler(const char *filename, 1219e93d083fSSimon Wunderlich struct dentry *parent, 1220e93d083fSSimon Wunderlich umode_t mode, 1221e93d083fSSimon Wunderlich struct rchan_buf *buf, 1222e93d083fSSimon Wunderlich int *is_global) 1223e93d083fSSimon Wunderlich { 1224e93d083fSSimon Wunderlich struct dentry *buf_file; 1225e93d083fSSimon Wunderlich 1226e93d083fSSimon Wunderlich buf_file = debugfs_create_file(filename, mode, parent, buf, 1227e93d083fSSimon Wunderlich &relay_file_operations); 1228e93d083fSSimon Wunderlich *is_global = 1; 1229e93d083fSSimon Wunderlich return buf_file; 1230e93d083fSSimon Wunderlich } 1231e93d083fSSimon Wunderlich 1232e93d083fSSimon Wunderlich static int remove_buf_file_handler(struct dentry *dentry) 1233e93d083fSSimon Wunderlich { 1234e93d083fSSimon Wunderlich debugfs_remove(dentry); 1235e93d083fSSimon Wunderlich 1236e93d083fSSimon Wunderlich return 0; 1237e93d083fSSimon Wunderlich } 1238e93d083fSSimon Wunderlich 1239e93d083fSSimon Wunderlich void ath_debug_send_fft_sample(struct ath_softc *sc, 1240e93d083fSSimon Wunderlich struct fft_sample_tlv *fft_sample_tlv) 1241e93d083fSSimon Wunderlich { 12424ab0b0aaSSven Eckelmann int length; 1243e93d083fSSimon Wunderlich if (!sc->rfs_chan_spec_scan) 1244e93d083fSSimon Wunderlich return; 1245e93d083fSSimon Wunderlich 12464ab0b0aaSSven Eckelmann length = __be16_to_cpu(fft_sample_tlv->length) + 12474ab0b0aaSSven Eckelmann sizeof(*fft_sample_tlv); 12484ab0b0aaSSven Eckelmann relay_write(sc->rfs_chan_spec_scan, fft_sample_tlv, length); 1249e93d083fSSimon Wunderlich } 1250e93d083fSSimon Wunderlich 1251e93d083fSSimon Wunderlich static struct rchan_callbacks rfs_spec_scan_cb = { 1252e93d083fSSimon Wunderlich .create_buf_file = create_buf_file_handler, 1253e93d083fSSimon Wunderlich .remove_buf_file = remove_buf_file_handler, 1254e93d083fSSimon Wunderlich }; 1255e93d083fSSimon Wunderlich 1256e93d083fSSimon Wunderlich 12579bff0bc4SFelix Fietkau static ssize_t read_file_regidx(struct file *file, char __user *user_buf, 12589bff0bc4SFelix Fietkau size_t count, loff_t *ppos) 12599bff0bc4SFelix Fietkau { 12609bff0bc4SFelix Fietkau struct ath_softc *sc = file->private_data; 12619bff0bc4SFelix Fietkau char buf[32]; 12629bff0bc4SFelix Fietkau unsigned int len; 12639bff0bc4SFelix Fietkau 12642b87f3aaSDan Carpenter len = sprintf(buf, "0x%08x\n", sc->debug.regidx); 12659bff0bc4SFelix Fietkau return simple_read_from_buffer(user_buf, count, ppos, buf, len); 12669bff0bc4SFelix Fietkau } 12679bff0bc4SFelix Fietkau 12689bff0bc4SFelix Fietkau static ssize_t write_file_regidx(struct file *file, const char __user *user_buf, 12699bff0bc4SFelix Fietkau size_t count, loff_t *ppos) 12709bff0bc4SFelix Fietkau { 12719bff0bc4SFelix Fietkau struct ath_softc *sc = file->private_data; 12729bff0bc4SFelix Fietkau unsigned long regidx; 12739bff0bc4SFelix Fietkau char buf[32]; 12749bff0bc4SFelix Fietkau ssize_t len; 12759bff0bc4SFelix Fietkau 12769bff0bc4SFelix Fietkau len = min(count, sizeof(buf) - 1); 12779bff0bc4SFelix Fietkau if (copy_from_user(buf, user_buf, len)) 127804236066SDan Carpenter return -EFAULT; 12799bff0bc4SFelix Fietkau 12809bff0bc4SFelix Fietkau buf[len] = '\0'; 12819bff0bc4SFelix Fietkau if (strict_strtoul(buf, 0, ®idx)) 12829bff0bc4SFelix Fietkau return -EINVAL; 12839bff0bc4SFelix Fietkau 12849bff0bc4SFelix Fietkau sc->debug.regidx = regidx; 12859bff0bc4SFelix Fietkau return count; 12869bff0bc4SFelix Fietkau } 12879bff0bc4SFelix Fietkau 12889bff0bc4SFelix Fietkau static const struct file_operations fops_regidx = { 12899bff0bc4SFelix Fietkau .read = read_file_regidx, 12909bff0bc4SFelix Fietkau .write = write_file_regidx, 1291234e3405SStephen Boyd .open = simple_open, 12926038f373SArnd Bergmann .owner = THIS_MODULE, 12936038f373SArnd Bergmann .llseek = default_llseek, 12949bff0bc4SFelix Fietkau }; 12959bff0bc4SFelix Fietkau 12969bff0bc4SFelix Fietkau static ssize_t read_file_regval(struct file *file, char __user *user_buf, 12979bff0bc4SFelix Fietkau size_t count, loff_t *ppos) 12989bff0bc4SFelix Fietkau { 12999bff0bc4SFelix Fietkau struct ath_softc *sc = file->private_data; 13009bff0bc4SFelix Fietkau struct ath_hw *ah = sc->sc_ah; 13019bff0bc4SFelix Fietkau char buf[32]; 13029bff0bc4SFelix Fietkau unsigned int len; 13039bff0bc4SFelix Fietkau u32 regval; 13049bff0bc4SFelix Fietkau 130579d2b157SRajkumar Manoharan ath9k_ps_wakeup(sc); 13069bff0bc4SFelix Fietkau regval = REG_READ_D(ah, sc->debug.regidx); 130779d2b157SRajkumar Manoharan ath9k_ps_restore(sc); 13082b87f3aaSDan Carpenter len = sprintf(buf, "0x%08x\n", regval); 13099bff0bc4SFelix Fietkau return simple_read_from_buffer(user_buf, count, ppos, buf, len); 13109bff0bc4SFelix Fietkau } 13119bff0bc4SFelix Fietkau 13129bff0bc4SFelix Fietkau static ssize_t write_file_regval(struct file *file, const char __user *user_buf, 13139bff0bc4SFelix Fietkau size_t count, loff_t *ppos) 13149bff0bc4SFelix Fietkau { 13159bff0bc4SFelix Fietkau struct ath_softc *sc = file->private_data; 13169bff0bc4SFelix Fietkau struct ath_hw *ah = sc->sc_ah; 13179bff0bc4SFelix Fietkau unsigned long regval; 13189bff0bc4SFelix Fietkau char buf[32]; 13199bff0bc4SFelix Fietkau ssize_t len; 13209bff0bc4SFelix Fietkau 13219bff0bc4SFelix Fietkau len = min(count, sizeof(buf) - 1); 13229bff0bc4SFelix Fietkau if (copy_from_user(buf, user_buf, len)) 132304236066SDan Carpenter return -EFAULT; 13249bff0bc4SFelix Fietkau 13259bff0bc4SFelix Fietkau buf[len] = '\0'; 13269bff0bc4SFelix Fietkau if (strict_strtoul(buf, 0, ®val)) 13279bff0bc4SFelix Fietkau return -EINVAL; 13289bff0bc4SFelix Fietkau 132979d2b157SRajkumar Manoharan ath9k_ps_wakeup(sc); 13309bff0bc4SFelix Fietkau REG_WRITE_D(ah, sc->debug.regidx, regval); 133179d2b157SRajkumar Manoharan ath9k_ps_restore(sc); 13329bff0bc4SFelix Fietkau return count; 13339bff0bc4SFelix Fietkau } 13349bff0bc4SFelix Fietkau 13359bff0bc4SFelix Fietkau static const struct file_operations fops_regval = { 13369bff0bc4SFelix Fietkau .read = read_file_regval, 13379bff0bc4SFelix Fietkau .write = write_file_regval, 1338234e3405SStephen Boyd .open = simple_open, 13396038f373SArnd Bergmann .owner = THIS_MODULE, 13406038f373SArnd Bergmann .llseek = default_llseek, 13419bff0bc4SFelix Fietkau }; 13429bff0bc4SFelix Fietkau 1343582d0064SVasanthakumar Thiagarajan #define REGDUMP_LINE_SIZE 20 1344582d0064SVasanthakumar Thiagarajan 1345582d0064SVasanthakumar Thiagarajan static int open_file_regdump(struct inode *inode, struct file *file) 1346582d0064SVasanthakumar Thiagarajan { 1347582d0064SVasanthakumar Thiagarajan struct ath_softc *sc = inode->i_private; 1348582d0064SVasanthakumar Thiagarajan unsigned int len = 0; 1349582d0064SVasanthakumar Thiagarajan u8 *buf; 1350582d0064SVasanthakumar Thiagarajan int i; 1351582d0064SVasanthakumar Thiagarajan unsigned long num_regs, regdump_len, max_reg_offset; 1352582d0064SVasanthakumar Thiagarajan 1353582d0064SVasanthakumar Thiagarajan max_reg_offset = AR_SREV_9300_20_OR_LATER(sc->sc_ah) ? 0x16bd4 : 0xb500; 1354582d0064SVasanthakumar Thiagarajan num_regs = max_reg_offset / 4 + 1; 1355582d0064SVasanthakumar Thiagarajan regdump_len = num_regs * REGDUMP_LINE_SIZE + 1; 1356582d0064SVasanthakumar Thiagarajan buf = vmalloc(regdump_len); 1357582d0064SVasanthakumar Thiagarajan if (!buf) 1358582d0064SVasanthakumar Thiagarajan return -ENOMEM; 1359582d0064SVasanthakumar Thiagarajan 1360582d0064SVasanthakumar Thiagarajan ath9k_ps_wakeup(sc); 1361582d0064SVasanthakumar Thiagarajan for (i = 0; i < num_regs; i++) 1362582d0064SVasanthakumar Thiagarajan len += scnprintf(buf + len, regdump_len - len, 1363582d0064SVasanthakumar Thiagarajan "0x%06x 0x%08x\n", i << 2, REG_READ(sc->sc_ah, i << 2)); 1364582d0064SVasanthakumar Thiagarajan ath9k_ps_restore(sc); 1365582d0064SVasanthakumar Thiagarajan 1366582d0064SVasanthakumar Thiagarajan file->private_data = buf; 1367582d0064SVasanthakumar Thiagarajan 1368582d0064SVasanthakumar Thiagarajan return 0; 1369582d0064SVasanthakumar Thiagarajan } 1370582d0064SVasanthakumar Thiagarajan 1371582d0064SVasanthakumar Thiagarajan static const struct file_operations fops_regdump = { 1372582d0064SVasanthakumar Thiagarajan .open = open_file_regdump, 1373582d0064SVasanthakumar Thiagarajan .read = ath9k_debugfs_read_buf, 1374582d0064SVasanthakumar Thiagarajan .release = ath9k_debugfs_release_buf, 1375582d0064SVasanthakumar Thiagarajan .owner = THIS_MODULE, 1376582d0064SVasanthakumar Thiagarajan .llseek = default_llseek,/* read accesses f_pos */ 1377582d0064SVasanthakumar Thiagarajan }; 1378582d0064SVasanthakumar Thiagarajan 1379d069a46bSRajkumar Manoharan static ssize_t read_file_dump_nfcal(struct file *file, char __user *user_buf, 1380d069a46bSRajkumar Manoharan size_t count, loff_t *ppos) 1381d069a46bSRajkumar Manoharan { 1382d069a46bSRajkumar Manoharan struct ath_softc *sc = file->private_data; 1383d069a46bSRajkumar Manoharan struct ath_hw *ah = sc->sc_ah; 1384d069a46bSRajkumar Manoharan struct ath9k_nfcal_hist *h = sc->caldata.nfCalHist; 1385d069a46bSRajkumar Manoharan struct ath_common *common = ath9k_hw_common(ah); 1386d069a46bSRajkumar Manoharan struct ieee80211_conf *conf = &common->hw->conf; 1387d069a46bSRajkumar Manoharan u32 len = 0, size = 1500; 1388d069a46bSRajkumar Manoharan u32 i, j; 1389d069a46bSRajkumar Manoharan ssize_t retval = 0; 1390d069a46bSRajkumar Manoharan char *buf; 1391d069a46bSRajkumar Manoharan u8 chainmask = (ah->rxchainmask << 3) | ah->rxchainmask; 1392d069a46bSRajkumar Manoharan u8 nread; 1393d069a46bSRajkumar Manoharan 1394d069a46bSRajkumar Manoharan buf = kzalloc(size, GFP_KERNEL); 1395d069a46bSRajkumar Manoharan if (!buf) 1396d069a46bSRajkumar Manoharan return -ENOMEM; 1397d069a46bSRajkumar Manoharan 1398d069a46bSRajkumar Manoharan len += snprintf(buf + len, size - len, 1399d069a46bSRajkumar Manoharan "Channel Noise Floor : %d\n", ah->noise); 1400d069a46bSRajkumar Manoharan len += snprintf(buf + len, size - len, 1401d069a46bSRajkumar Manoharan "Chain | privNF | # Readings | NF Readings\n"); 1402d069a46bSRajkumar Manoharan for (i = 0; i < NUM_NF_READINGS; i++) { 1403d069a46bSRajkumar Manoharan if (!(chainmask & (1 << i)) || 1404d069a46bSRajkumar Manoharan ((i >= AR5416_MAX_CHAINS) && !conf_is_ht40(conf))) 1405d069a46bSRajkumar Manoharan continue; 1406d069a46bSRajkumar Manoharan 1407d069a46bSRajkumar Manoharan nread = AR_PHY_CCA_FILTERWINDOW_LENGTH - h[i].invalidNFcount; 1408d069a46bSRajkumar Manoharan len += snprintf(buf + len, size - len, " %d\t %d\t %d\t\t", 1409d069a46bSRajkumar Manoharan i, h[i].privNF, nread); 1410d069a46bSRajkumar Manoharan for (j = 0; j < nread; j++) 1411d069a46bSRajkumar Manoharan len += snprintf(buf + len, size - len, 1412d069a46bSRajkumar Manoharan " %d", h[i].nfCalBuffer[j]); 1413d069a46bSRajkumar Manoharan len += snprintf(buf + len, size - len, "\n"); 1414d069a46bSRajkumar Manoharan } 1415d069a46bSRajkumar Manoharan 1416d069a46bSRajkumar Manoharan if (len > size) 1417d069a46bSRajkumar Manoharan len = size; 1418d069a46bSRajkumar Manoharan 1419d069a46bSRajkumar Manoharan retval = simple_read_from_buffer(user_buf, count, ppos, buf, len); 1420d069a46bSRajkumar Manoharan kfree(buf); 1421d069a46bSRajkumar Manoharan 1422d069a46bSRajkumar Manoharan return retval; 1423d069a46bSRajkumar Manoharan } 1424d069a46bSRajkumar Manoharan 1425d069a46bSRajkumar Manoharan static const struct file_operations fops_dump_nfcal = { 1426d069a46bSRajkumar Manoharan .read = read_file_dump_nfcal, 1427234e3405SStephen Boyd .open = simple_open, 1428d069a46bSRajkumar Manoharan .owner = THIS_MODULE, 1429d069a46bSRajkumar Manoharan .llseek = default_llseek, 1430d069a46bSRajkumar Manoharan }; 1431d069a46bSRajkumar Manoharan 1432580f010fSRajkumar Manoharan static ssize_t read_file_base_eeprom(struct file *file, char __user *user_buf, 1433580f010fSRajkumar Manoharan size_t count, loff_t *ppos) 1434580f010fSRajkumar Manoharan { 1435580f010fSRajkumar Manoharan struct ath_softc *sc = file->private_data; 1436580f010fSRajkumar Manoharan struct ath_hw *ah = sc->sc_ah; 1437580f010fSRajkumar Manoharan u32 len = 0, size = 1500; 1438580f010fSRajkumar Manoharan ssize_t retval = 0; 1439580f010fSRajkumar Manoharan char *buf; 1440580f010fSRajkumar Manoharan 1441580f010fSRajkumar Manoharan buf = kzalloc(size, GFP_KERNEL); 1442580f010fSRajkumar Manoharan if (!buf) 1443580f010fSRajkumar Manoharan return -ENOMEM; 1444580f010fSRajkumar Manoharan 1445580f010fSRajkumar Manoharan len = ah->eep_ops->dump_eeprom(ah, true, buf, len, size); 1446580f010fSRajkumar Manoharan 1447580f010fSRajkumar Manoharan retval = simple_read_from_buffer(user_buf, count, ppos, buf, len); 1448580f010fSRajkumar Manoharan kfree(buf); 1449580f010fSRajkumar Manoharan 1450580f010fSRajkumar Manoharan return retval; 1451580f010fSRajkumar Manoharan } 1452580f010fSRajkumar Manoharan 1453580f010fSRajkumar Manoharan static const struct file_operations fops_base_eeprom = { 1454580f010fSRajkumar Manoharan .read = read_file_base_eeprom, 1455234e3405SStephen Boyd .open = simple_open, 1456580f010fSRajkumar Manoharan .owner = THIS_MODULE, 1457580f010fSRajkumar Manoharan .llseek = default_llseek, 1458580f010fSRajkumar Manoharan }; 1459580f010fSRajkumar Manoharan 14603f4c4bddSRajkumar Manoharan static ssize_t read_file_modal_eeprom(struct file *file, char __user *user_buf, 14613f4c4bddSRajkumar Manoharan size_t count, loff_t *ppos) 14623f4c4bddSRajkumar Manoharan { 14633f4c4bddSRajkumar Manoharan struct ath_softc *sc = file->private_data; 14643f4c4bddSRajkumar Manoharan struct ath_hw *ah = sc->sc_ah; 14653f4c4bddSRajkumar Manoharan u32 len = 0, size = 6000; 14663f4c4bddSRajkumar Manoharan char *buf; 14673f4c4bddSRajkumar Manoharan size_t retval; 14683f4c4bddSRajkumar Manoharan 14693f4c4bddSRajkumar Manoharan buf = kzalloc(size, GFP_KERNEL); 14703f4c4bddSRajkumar Manoharan if (buf == NULL) 14713f4c4bddSRajkumar Manoharan return -ENOMEM; 14723f4c4bddSRajkumar Manoharan 14733f4c4bddSRajkumar Manoharan len = ah->eep_ops->dump_eeprom(ah, false, buf, len, size); 14743f4c4bddSRajkumar Manoharan 14753f4c4bddSRajkumar Manoharan retval = simple_read_from_buffer(user_buf, count, ppos, buf, len); 14763f4c4bddSRajkumar Manoharan kfree(buf); 14773f4c4bddSRajkumar Manoharan 14783f4c4bddSRajkumar Manoharan return retval; 14793f4c4bddSRajkumar Manoharan } 14803f4c4bddSRajkumar Manoharan 14813f4c4bddSRajkumar Manoharan static const struct file_operations fops_modal_eeprom = { 14823f4c4bddSRajkumar Manoharan .read = read_file_modal_eeprom, 1483234e3405SStephen Boyd .open = simple_open, 14843f4c4bddSRajkumar Manoharan .owner = THIS_MODULE, 14853f4c4bddSRajkumar Manoharan .llseek = default_llseek, 14863f4c4bddSRajkumar Manoharan }; 14873f4c4bddSRajkumar Manoharan 14885baec742SFelix Fietkau #ifdef CONFIG_ATH9K_MAC_DEBUG 14895baec742SFelix Fietkau 1490cf3af748SRajkumar Manoharan void ath9k_debug_samp_bb_mac(struct ath_softc *sc) 1491cf3af748SRajkumar Manoharan { 1492cf3af748SRajkumar Manoharan #define ATH_SAMP_DBG(c) (sc->debug.bb_mac_samp[sc->debug.sampidx].c) 1493cf3af748SRajkumar Manoharan struct ath_hw *ah = sc->sc_ah; 1494cf3af748SRajkumar Manoharan struct ath_common *common = ath9k_hw_common(ah); 1495cf3af748SRajkumar Manoharan unsigned long flags; 1496cf3af748SRajkumar Manoharan int i; 1497cf3af748SRajkumar Manoharan 1498cf3af748SRajkumar Manoharan ath9k_ps_wakeup(sc); 1499cf3af748SRajkumar Manoharan 15006bc05a95SRajkumar Manoharan spin_lock_bh(&sc->debug.samp_lock); 15016bc05a95SRajkumar Manoharan 1502cf3af748SRajkumar Manoharan spin_lock_irqsave(&common->cc_lock, flags); 1503cf3af748SRajkumar Manoharan ath_hw_cycle_counters_update(common); 1504cf3af748SRajkumar Manoharan 1505cf3af748SRajkumar Manoharan ATH_SAMP_DBG(cc.cycles) = common->cc_ani.cycles; 1506cf3af748SRajkumar Manoharan ATH_SAMP_DBG(cc.rx_busy) = common->cc_ani.rx_busy; 1507cf3af748SRajkumar Manoharan ATH_SAMP_DBG(cc.rx_frame) = common->cc_ani.rx_frame; 1508cf3af748SRajkumar Manoharan ATH_SAMP_DBG(cc.tx_frame) = common->cc_ani.tx_frame; 15096bc05a95SRajkumar Manoharan spin_unlock_irqrestore(&common->cc_lock, flags); 15106bc05a95SRajkumar Manoharan 1511cf3af748SRajkumar Manoharan ATH_SAMP_DBG(noise) = ah->noise; 1512cf3af748SRajkumar Manoharan 1513cf3af748SRajkumar Manoharan REG_WRITE_D(ah, AR_MACMISC, 1514cf3af748SRajkumar Manoharan ((AR_MACMISC_DMA_OBS_LINE_8 << AR_MACMISC_DMA_OBS_S) | 1515cf3af748SRajkumar Manoharan (AR_MACMISC_MISC_OBS_BUS_1 << 1516cf3af748SRajkumar Manoharan AR_MACMISC_MISC_OBS_BUS_MSB_S))); 1517cf3af748SRajkumar Manoharan 1518cf3af748SRajkumar Manoharan for (i = 0; i < ATH9K_NUM_DMA_DEBUG_REGS; i++) 1519cf3af748SRajkumar Manoharan ATH_SAMP_DBG(dma_dbg_reg_vals[i]) = REG_READ_D(ah, 1520cf3af748SRajkumar Manoharan AR_DMADBG_0 + (i * sizeof(u32))); 1521cf3af748SRajkumar Manoharan 1522cf3af748SRajkumar Manoharan ATH_SAMP_DBG(pcu_obs) = REG_READ_D(ah, AR_OBS_BUS_1); 1523cf3af748SRajkumar Manoharan ATH_SAMP_DBG(pcu_cr) = REG_READ_D(ah, AR_CR); 1524cf3af748SRajkumar Manoharan 1525cf3af748SRajkumar Manoharan memcpy(ATH_SAMP_DBG(nfCalHist), sc->caldata.nfCalHist, 1526cf3af748SRajkumar Manoharan sizeof(ATH_SAMP_DBG(nfCalHist))); 1527cf3af748SRajkumar Manoharan 1528cf3af748SRajkumar Manoharan sc->debug.sampidx = (sc->debug.sampidx + 1) % ATH_DBG_MAX_SAMPLES; 1529cf3af748SRajkumar Manoharan spin_unlock_bh(&sc->debug.samp_lock); 1530cf3af748SRajkumar Manoharan ath9k_ps_restore(sc); 1531cf3af748SRajkumar Manoharan 1532cf3af748SRajkumar Manoharan #undef ATH_SAMP_DBG 1533cf3af748SRajkumar Manoharan } 1534cf3af748SRajkumar Manoharan 1535cf3af748SRajkumar Manoharan static int open_file_bb_mac_samps(struct inode *inode, struct file *file) 1536cf3af748SRajkumar Manoharan { 1537cf3af748SRajkumar Manoharan #define ATH_SAMP_DBG(c) bb_mac_samp[sampidx].c 1538cf3af748SRajkumar Manoharan struct ath_softc *sc = inode->i_private; 1539cf3af748SRajkumar Manoharan struct ath_hw *ah = sc->sc_ah; 1540cf3af748SRajkumar Manoharan struct ath_common *common = ath9k_hw_common(ah); 1541cf3af748SRajkumar Manoharan struct ieee80211_conf *conf = &common->hw->conf; 1542cf3af748SRajkumar Manoharan struct ath_dbg_bb_mac_samp *bb_mac_samp; 1543cf3af748SRajkumar Manoharan struct ath9k_nfcal_hist *h; 1544cf3af748SRajkumar Manoharan int i, j, qcuOffset = 0, dcuOffset = 0; 1545cf3af748SRajkumar Manoharan u32 *qcuBase, *dcuBase, size = 30000, len = 0; 1546cf3af748SRajkumar Manoharan u32 sampidx = 0; 1547cf3af748SRajkumar Manoharan u8 *buf; 1548cf3af748SRajkumar Manoharan u8 chainmask = (ah->rxchainmask << 3) | ah->rxchainmask; 1549cf3af748SRajkumar Manoharan u8 nread; 1550cf3af748SRajkumar Manoharan 1551781b14a3SSujith Manoharan if (test_bit(SC_OP_INVALID, &sc->sc_flags)) 1552f7e014daSRajkumar Manoharan return -EAGAIN; 1553f7e014daSRajkumar Manoharan 1554cf3af748SRajkumar Manoharan buf = vmalloc(size); 1555cf3af748SRajkumar Manoharan if (!buf) 1556cf3af748SRajkumar Manoharan return -ENOMEM; 1557cf3af748SRajkumar Manoharan bb_mac_samp = vmalloc(sizeof(*bb_mac_samp) * ATH_DBG_MAX_SAMPLES); 1558cf3af748SRajkumar Manoharan if (!bb_mac_samp) { 1559cf3af748SRajkumar Manoharan vfree(buf); 1560cf3af748SRajkumar Manoharan return -ENOMEM; 1561cf3af748SRajkumar Manoharan } 1562f7e014daSRajkumar Manoharan /* Account the current state too */ 1563f7e014daSRajkumar Manoharan ath9k_debug_samp_bb_mac(sc); 1564cf3af748SRajkumar Manoharan 1565cf3af748SRajkumar Manoharan spin_lock_bh(&sc->debug.samp_lock); 1566cf3af748SRajkumar Manoharan memcpy(bb_mac_samp, sc->debug.bb_mac_samp, 1567cf3af748SRajkumar Manoharan sizeof(*bb_mac_samp) * ATH_DBG_MAX_SAMPLES); 15686bc05a95SRajkumar Manoharan len += snprintf(buf + len, size - len, 15696bc05a95SRajkumar Manoharan "Current Sample Index: %d\n", sc->debug.sampidx); 1570cf3af748SRajkumar Manoharan spin_unlock_bh(&sc->debug.samp_lock); 1571cf3af748SRajkumar Manoharan 1572cf3af748SRajkumar Manoharan len += snprintf(buf + len, size - len, 1573cf3af748SRajkumar Manoharan "Raw DMA Debug Dump:\n"); 1574cf3af748SRajkumar Manoharan len += snprintf(buf + len, size - len, "Sample |\t"); 1575cf3af748SRajkumar Manoharan for (i = 0; i < ATH9K_NUM_DMA_DEBUG_REGS; i++) 1576cf3af748SRajkumar Manoharan len += snprintf(buf + len, size - len, " DMA Reg%d |\t", i); 1577cf3af748SRajkumar Manoharan len += snprintf(buf + len, size - len, "\n"); 1578cf3af748SRajkumar Manoharan 1579cf3af748SRajkumar Manoharan for (sampidx = 0; sampidx < ATH_DBG_MAX_SAMPLES; sampidx++) { 1580cf3af748SRajkumar Manoharan len += snprintf(buf + len, size - len, "%d\t", sampidx); 1581cf3af748SRajkumar Manoharan 1582cf3af748SRajkumar Manoharan for (i = 0; i < ATH9K_NUM_DMA_DEBUG_REGS; i++) 1583cf3af748SRajkumar Manoharan len += snprintf(buf + len, size - len, " %08x\t", 1584cf3af748SRajkumar Manoharan ATH_SAMP_DBG(dma_dbg_reg_vals[i])); 1585cf3af748SRajkumar Manoharan len += snprintf(buf + len, size - len, "\n"); 1586cf3af748SRajkumar Manoharan } 1587cf3af748SRajkumar Manoharan len += snprintf(buf + len, size - len, "\n"); 1588cf3af748SRajkumar Manoharan 1589cf3af748SRajkumar Manoharan len += snprintf(buf + len, size - len, 1590cf3af748SRajkumar Manoharan "Sample Num QCU: chain_st fsp_ok fsp_st DCU: chain_st\n"); 1591cf3af748SRajkumar Manoharan for (sampidx = 0; sampidx < ATH_DBG_MAX_SAMPLES; sampidx++) { 1592cf3af748SRajkumar Manoharan qcuBase = &ATH_SAMP_DBG(dma_dbg_reg_vals[0]); 1593cf3af748SRajkumar Manoharan dcuBase = &ATH_SAMP_DBG(dma_dbg_reg_vals[4]); 1594cf3af748SRajkumar Manoharan 1595cf3af748SRajkumar Manoharan for (i = 0; i < ATH9K_NUM_QUEUES; i++, 1596cf3af748SRajkumar Manoharan qcuOffset += 4, dcuOffset += 5) { 1597cf3af748SRajkumar Manoharan if (i == 8) { 1598cf3af748SRajkumar Manoharan qcuOffset = 0; 1599cf3af748SRajkumar Manoharan qcuBase++; 1600cf3af748SRajkumar Manoharan } 1601cf3af748SRajkumar Manoharan 1602cf3af748SRajkumar Manoharan if (i == 6) { 1603cf3af748SRajkumar Manoharan dcuOffset = 0; 1604cf3af748SRajkumar Manoharan dcuBase++; 1605cf3af748SRajkumar Manoharan } 1606cf3af748SRajkumar Manoharan if (!sc->debug.stats.txstats[i].queued) 1607cf3af748SRajkumar Manoharan continue; 1608cf3af748SRajkumar Manoharan 1609cf3af748SRajkumar Manoharan len += snprintf(buf + len, size - len, 1610cf3af748SRajkumar Manoharan "%4d %7d %2x %1x %2x %2x\n", 1611cf3af748SRajkumar Manoharan sampidx, i, 1612cf3af748SRajkumar Manoharan (*qcuBase & (0x7 << qcuOffset)) >> qcuOffset, 1613cf3af748SRajkumar Manoharan (*qcuBase & (0x8 << qcuOffset)) >> 1614cf3af748SRajkumar Manoharan (qcuOffset + 3), 1615cf3af748SRajkumar Manoharan ATH_SAMP_DBG(dma_dbg_reg_vals[2]) & 1616cf3af748SRajkumar Manoharan (0x7 << (i * 3)) >> (i * 3), 1617cf3af748SRajkumar Manoharan (*dcuBase & (0x1f << dcuOffset)) >> dcuOffset); 1618cf3af748SRajkumar Manoharan } 1619cf3af748SRajkumar Manoharan len += snprintf(buf + len, size - len, "\n"); 1620cf3af748SRajkumar Manoharan } 1621cf3af748SRajkumar Manoharan len += snprintf(buf + len, size - len, 1622cf3af748SRajkumar Manoharan "samp qcu_sh qcu_fh qcu_comp dcu_comp dcu_arb dcu_fp " 1623cf3af748SRajkumar Manoharan "ch_idle_dur ch_idle_dur_val txfifo_val0 txfifo_val1 " 1624cf3af748SRajkumar Manoharan "txfifo_dcu0 txfifo_dcu1 pcu_obs AR_CR\n"); 1625cf3af748SRajkumar Manoharan 1626cf3af748SRajkumar Manoharan for (sampidx = 0; sampidx < ATH_DBG_MAX_SAMPLES; sampidx++) { 1627cf3af748SRajkumar Manoharan qcuBase = &ATH_SAMP_DBG(dma_dbg_reg_vals[0]); 1628cf3af748SRajkumar Manoharan dcuBase = &ATH_SAMP_DBG(dma_dbg_reg_vals[4]); 1629cf3af748SRajkumar Manoharan 1630cf3af748SRajkumar Manoharan len += snprintf(buf + len, size - len, "%4d %5x %5x ", sampidx, 1631cf3af748SRajkumar Manoharan (ATH_SAMP_DBG(dma_dbg_reg_vals[3]) & 0x003c0000) >> 18, 1632cf3af748SRajkumar Manoharan (ATH_SAMP_DBG(dma_dbg_reg_vals[3]) & 0x03c00000) >> 22); 1633cf3af748SRajkumar Manoharan len += snprintf(buf + len, size - len, "%7x %8x ", 1634cf3af748SRajkumar Manoharan (ATH_SAMP_DBG(dma_dbg_reg_vals[3]) & 0x1c000000) >> 26, 1635cf3af748SRajkumar Manoharan (ATH_SAMP_DBG(dma_dbg_reg_vals[6]) & 0x3)); 1636cf3af748SRajkumar Manoharan len += snprintf(buf + len, size - len, "%7x %7x ", 1637cf3af748SRajkumar Manoharan (ATH_SAMP_DBG(dma_dbg_reg_vals[5]) & 0x06000000) >> 25, 1638cf3af748SRajkumar Manoharan (ATH_SAMP_DBG(dma_dbg_reg_vals[5]) & 0x38000000) >> 27); 1639cf3af748SRajkumar Manoharan len += snprintf(buf + len, size - len, "%7d %12d ", 1640cf3af748SRajkumar Manoharan (ATH_SAMP_DBG(dma_dbg_reg_vals[6]) & 0x000003fc) >> 2, 1641cf3af748SRajkumar Manoharan (ATH_SAMP_DBG(dma_dbg_reg_vals[6]) & 0x00000400) >> 10); 1642cf3af748SRajkumar Manoharan len += snprintf(buf + len, size - len, "%12d %12d ", 1643cf3af748SRajkumar Manoharan (ATH_SAMP_DBG(dma_dbg_reg_vals[6]) & 0x00000800) >> 11, 1644cf3af748SRajkumar Manoharan (ATH_SAMP_DBG(dma_dbg_reg_vals[6]) & 0x00001000) >> 12); 1645cf3af748SRajkumar Manoharan len += snprintf(buf + len, size - len, "%12d %12d ", 1646cf3af748SRajkumar Manoharan (ATH_SAMP_DBG(dma_dbg_reg_vals[6]) & 0x0001e000) >> 13, 1647cf3af748SRajkumar Manoharan (ATH_SAMP_DBG(dma_dbg_reg_vals[6]) & 0x001e0000) >> 17); 1648cf3af748SRajkumar Manoharan len += snprintf(buf + len, size - len, "0x%07x 0x%07x\n", 1649cf3af748SRajkumar Manoharan ATH_SAMP_DBG(pcu_obs), ATH_SAMP_DBG(pcu_cr)); 1650cf3af748SRajkumar Manoharan } 1651cf3af748SRajkumar Manoharan 1652cf3af748SRajkumar Manoharan len += snprintf(buf + len, size - len, 1653cf3af748SRajkumar Manoharan "Sample ChNoise Chain privNF #Reading Readings\n"); 1654cf3af748SRajkumar Manoharan for (sampidx = 0; sampidx < ATH_DBG_MAX_SAMPLES; sampidx++) { 1655cf3af748SRajkumar Manoharan h = ATH_SAMP_DBG(nfCalHist); 1656cf3af748SRajkumar Manoharan if (!ATH_SAMP_DBG(noise)) 1657cf3af748SRajkumar Manoharan continue; 1658cf3af748SRajkumar Manoharan 1659cf3af748SRajkumar Manoharan for (i = 0; i < NUM_NF_READINGS; i++) { 1660cf3af748SRajkumar Manoharan if (!(chainmask & (1 << i)) || 1661cf3af748SRajkumar Manoharan ((i >= AR5416_MAX_CHAINS) && !conf_is_ht40(conf))) 1662cf3af748SRajkumar Manoharan continue; 1663cf3af748SRajkumar Manoharan 1664cf3af748SRajkumar Manoharan nread = AR_PHY_CCA_FILTERWINDOW_LENGTH - 1665cf3af748SRajkumar Manoharan h[i].invalidNFcount; 1666cf3af748SRajkumar Manoharan len += snprintf(buf + len, size - len, 1667cf3af748SRajkumar Manoharan "%4d %5d %4d\t %d\t %d\t", 1668cf3af748SRajkumar Manoharan sampidx, ATH_SAMP_DBG(noise), 1669cf3af748SRajkumar Manoharan i, h[i].privNF, nread); 1670cf3af748SRajkumar Manoharan for (j = 0; j < nread; j++) 1671cf3af748SRajkumar Manoharan len += snprintf(buf + len, size - len, 1672cf3af748SRajkumar Manoharan " %d", h[i].nfCalBuffer[j]); 1673cf3af748SRajkumar Manoharan len += snprintf(buf + len, size - len, "\n"); 1674cf3af748SRajkumar Manoharan } 1675cf3af748SRajkumar Manoharan } 1676cf3af748SRajkumar Manoharan len += snprintf(buf + len, size - len, "\nCycle counters:\n" 1677cf3af748SRajkumar Manoharan "Sample Total Rxbusy Rxframes Txframes\n"); 1678cf3af748SRajkumar Manoharan for (sampidx = 0; sampidx < ATH_DBG_MAX_SAMPLES; sampidx++) { 1679cf3af748SRajkumar Manoharan if (!ATH_SAMP_DBG(cc.cycles)) 1680cf3af748SRajkumar Manoharan continue; 1681cf3af748SRajkumar Manoharan len += snprintf(buf + len, size - len, 1682cf3af748SRajkumar Manoharan "%4d %08x %08x %08x %08x\n", 1683cf3af748SRajkumar Manoharan sampidx, ATH_SAMP_DBG(cc.cycles), 1684cf3af748SRajkumar Manoharan ATH_SAMP_DBG(cc.rx_busy), 1685cf3af748SRajkumar Manoharan ATH_SAMP_DBG(cc.rx_frame), 1686cf3af748SRajkumar Manoharan ATH_SAMP_DBG(cc.tx_frame)); 1687cf3af748SRajkumar Manoharan } 1688cf3af748SRajkumar Manoharan 1689cf3af748SRajkumar Manoharan len += snprintf(buf + len, size - len, "Tx status Dump :\n"); 1690cf3af748SRajkumar Manoharan len += snprintf(buf + len, size - len, 1691cf3af748SRajkumar Manoharan "Sample rssi:- ctl0 ctl1 ctl2 ext0 ext1 ext2 comb " 169212932180SMohammed Shafi Shajakhan "isok rts_fail data_fail rate tid qid " 169312932180SMohammed Shafi Shajakhan "ba_low ba_high tx_before(ms)\n"); 1694cf3af748SRajkumar Manoharan for (sampidx = 0; sampidx < ATH_DBG_MAX_SAMPLES; sampidx++) { 1695cf3af748SRajkumar Manoharan for (i = 0; i < ATH_DBG_MAX_SAMPLES; i++) { 1696cf3af748SRajkumar Manoharan if (!ATH_SAMP_DBG(ts[i].jiffies)) 1697cf3af748SRajkumar Manoharan continue; 169812932180SMohammed Shafi Shajakhan len += snprintf(buf + len, size - len, "%-14d" 169912932180SMohammed Shafi Shajakhan "%-4d %-4d %-4d %-4d %-4d %-4d %-4d %-4d %-8d " 170012932180SMohammed Shafi Shajakhan "%-9d %-4d %-3d %-3d %08x %08x %-11d\n", 1701cf3af748SRajkumar Manoharan sampidx, 1702cf3af748SRajkumar Manoharan ATH_SAMP_DBG(ts[i].rssi_ctl0), 1703cf3af748SRajkumar Manoharan ATH_SAMP_DBG(ts[i].rssi_ctl1), 1704cf3af748SRajkumar Manoharan ATH_SAMP_DBG(ts[i].rssi_ctl2), 1705cf3af748SRajkumar Manoharan ATH_SAMP_DBG(ts[i].rssi_ext0), 1706cf3af748SRajkumar Manoharan ATH_SAMP_DBG(ts[i].rssi_ext1), 1707cf3af748SRajkumar Manoharan ATH_SAMP_DBG(ts[i].rssi_ext2), 1708cf3af748SRajkumar Manoharan ATH_SAMP_DBG(ts[i].rssi), 1709cf3af748SRajkumar Manoharan ATH_SAMP_DBG(ts[i].isok), 1710cf3af748SRajkumar Manoharan ATH_SAMP_DBG(ts[i].rts_fail_cnt), 1711cf3af748SRajkumar Manoharan ATH_SAMP_DBG(ts[i].data_fail_cnt), 1712cf3af748SRajkumar Manoharan ATH_SAMP_DBG(ts[i].rateindex), 1713cf3af748SRajkumar Manoharan ATH_SAMP_DBG(ts[i].tid), 1714cf3af748SRajkumar Manoharan ATH_SAMP_DBG(ts[i].qid), 171512932180SMohammed Shafi Shajakhan ATH_SAMP_DBG(ts[i].ba_low), 171612932180SMohammed Shafi Shajakhan ATH_SAMP_DBG(ts[i].ba_high), 1717cf3af748SRajkumar Manoharan jiffies_to_msecs(jiffies - 1718cf3af748SRajkumar Manoharan ATH_SAMP_DBG(ts[i].jiffies))); 1719cf3af748SRajkumar Manoharan } 1720cf3af748SRajkumar Manoharan } 1721cf3af748SRajkumar Manoharan 1722cf3af748SRajkumar Manoharan len += snprintf(buf + len, size - len, "Rx status Dump :\n"); 1723cf3af748SRajkumar Manoharan len += snprintf(buf + len, size - len, "Sample rssi:- ctl0 ctl1 ctl2 " 1724cf3af748SRajkumar Manoharan "ext0 ext1 ext2 comb beacon ant rate rx_before(ms)\n"); 1725cf3af748SRajkumar Manoharan for (sampidx = 0; sampidx < ATH_DBG_MAX_SAMPLES; sampidx++) { 1726cf3af748SRajkumar Manoharan for (i = 0; i < ATH_DBG_MAX_SAMPLES; i++) { 1727cf3af748SRajkumar Manoharan if (!ATH_SAMP_DBG(rs[i].jiffies)) 1728cf3af748SRajkumar Manoharan continue; 172912932180SMohammed Shafi Shajakhan len += snprintf(buf + len, size - len, "%-14d" 173012932180SMohammed Shafi Shajakhan "%-4d %-4d %-4d %-4d %-4d %-4d %-4d %-9s %-2d %02x %-13d\n", 1731cf3af748SRajkumar Manoharan sampidx, 1732cf3af748SRajkumar Manoharan ATH_SAMP_DBG(rs[i].rssi_ctl0), 1733cf3af748SRajkumar Manoharan ATH_SAMP_DBG(rs[i].rssi_ctl1), 1734cf3af748SRajkumar Manoharan ATH_SAMP_DBG(rs[i].rssi_ctl2), 1735cf3af748SRajkumar Manoharan ATH_SAMP_DBG(rs[i].rssi_ext0), 1736cf3af748SRajkumar Manoharan ATH_SAMP_DBG(rs[i].rssi_ext1), 1737cf3af748SRajkumar Manoharan ATH_SAMP_DBG(rs[i].rssi_ext2), 1738cf3af748SRajkumar Manoharan ATH_SAMP_DBG(rs[i].rssi), 1739cf3af748SRajkumar Manoharan ATH_SAMP_DBG(rs[i].is_mybeacon) ? 1740cf3af748SRajkumar Manoharan "True" : "False", 1741cf3af748SRajkumar Manoharan ATH_SAMP_DBG(rs[i].antenna), 1742cf3af748SRajkumar Manoharan ATH_SAMP_DBG(rs[i].rate), 1743cf3af748SRajkumar Manoharan jiffies_to_msecs(jiffies - 1744cf3af748SRajkumar Manoharan ATH_SAMP_DBG(rs[i].jiffies))); 1745cf3af748SRajkumar Manoharan } 1746cf3af748SRajkumar Manoharan } 1747cf3af748SRajkumar Manoharan 1748cf3af748SRajkumar Manoharan vfree(bb_mac_samp); 1749cf3af748SRajkumar Manoharan file->private_data = buf; 1750cf3af748SRajkumar Manoharan 1751cf3af748SRajkumar Manoharan return 0; 1752cf3af748SRajkumar Manoharan #undef ATH_SAMP_DBG 1753cf3af748SRajkumar Manoharan } 1754cf3af748SRajkumar Manoharan 1755cf3af748SRajkumar Manoharan static const struct file_operations fops_samps = { 1756cf3af748SRajkumar Manoharan .open = open_file_bb_mac_samps, 1757cf3af748SRajkumar Manoharan .read = ath9k_debugfs_read_buf, 1758cf3af748SRajkumar Manoharan .release = ath9k_debugfs_release_buf, 1759cf3af748SRajkumar Manoharan .owner = THIS_MODULE, 1760cf3af748SRajkumar Manoharan .llseek = default_llseek, 1761cf3af748SRajkumar Manoharan }; 1762cf3af748SRajkumar Manoharan 17635baec742SFelix Fietkau #endif 1764cf3af748SRajkumar Manoharan 17654df50ca8SRajkumar Manoharan #ifdef CONFIG_ATH9K_BTCOEX_SUPPORT 17664df50ca8SRajkumar Manoharan static ssize_t read_file_btcoex(struct file *file, char __user *user_buf, 17674df50ca8SRajkumar Manoharan size_t count, loff_t *ppos) 17684df50ca8SRajkumar Manoharan { 17694df50ca8SRajkumar Manoharan struct ath_softc *sc = file->private_data; 17704df50ca8SRajkumar Manoharan u32 len = 0, size = 1500; 17714df50ca8SRajkumar Manoharan char *buf; 17724df50ca8SRajkumar Manoharan size_t retval; 17734df50ca8SRajkumar Manoharan 17744df50ca8SRajkumar Manoharan buf = kzalloc(size, GFP_KERNEL); 17754df50ca8SRajkumar Manoharan if (buf == NULL) 17764df50ca8SRajkumar Manoharan return -ENOMEM; 17774df50ca8SRajkumar Manoharan 1778ac46ba43SSujith Manoharan if (!sc->sc_ah->common.btcoex_enabled) { 1779ac46ba43SSujith Manoharan len = snprintf(buf, size, "%s\n", 1780ac46ba43SSujith Manoharan "BTCOEX is disabled"); 1781ac46ba43SSujith Manoharan goto exit; 1782ac46ba43SSujith Manoharan } 17834df50ca8SRajkumar Manoharan 1784ac46ba43SSujith Manoharan len = ath9k_dump_btcoex(sc, buf, size); 1785ac46ba43SSujith Manoharan exit: 17864df50ca8SRajkumar Manoharan retval = simple_read_from_buffer(user_buf, count, ppos, buf, len); 17874df50ca8SRajkumar Manoharan kfree(buf); 17884df50ca8SRajkumar Manoharan 17894df50ca8SRajkumar Manoharan return retval; 17904df50ca8SRajkumar Manoharan } 17914df50ca8SRajkumar Manoharan 17924df50ca8SRajkumar Manoharan static const struct file_operations fops_btcoex = { 17934df50ca8SRajkumar Manoharan .read = read_file_btcoex, 17944df50ca8SRajkumar Manoharan .open = simple_open, 17954df50ca8SRajkumar Manoharan .owner = THIS_MODULE, 17964df50ca8SRajkumar Manoharan .llseek = default_llseek, 17974df50ca8SRajkumar Manoharan }; 17984df50ca8SRajkumar Manoharan #endif 17994df50ca8SRajkumar Manoharan 1800a145daf7SSujith Manoharan static ssize_t read_file_node_stat(struct file *file, char __user *user_buf, 1801a145daf7SSujith Manoharan size_t count, loff_t *ppos) 1802a145daf7SSujith Manoharan { 1803a145daf7SSujith Manoharan struct ath_node *an = file->private_data; 1804a145daf7SSujith Manoharan struct ath_softc *sc = an->sc; 1805a145daf7SSujith Manoharan struct ath_atx_tid *tid; 1806a145daf7SSujith Manoharan struct ath_atx_ac *ac; 1807a145daf7SSujith Manoharan struct ath_txq *txq; 1808a145daf7SSujith Manoharan u32 len = 0, size = 4096; 1809a145daf7SSujith Manoharan char *buf; 1810a145daf7SSujith Manoharan size_t retval; 1811a145daf7SSujith Manoharan int tidno, acno; 1812a145daf7SSujith Manoharan 1813a145daf7SSujith Manoharan buf = kzalloc(size, GFP_KERNEL); 1814a145daf7SSujith Manoharan if (buf == NULL) 1815a145daf7SSujith Manoharan return -ENOMEM; 1816a145daf7SSujith Manoharan 1817a145daf7SSujith Manoharan if (!an->sta->ht_cap.ht_supported) { 1818a145daf7SSujith Manoharan len = snprintf(buf, size, "%s\n", 1819a145daf7SSujith Manoharan "HT not supported"); 1820a145daf7SSujith Manoharan goto exit; 1821a145daf7SSujith Manoharan } 1822a145daf7SSujith Manoharan 1823a145daf7SSujith Manoharan len = snprintf(buf, size, "Max-AMPDU: %d\n", 1824a145daf7SSujith Manoharan an->maxampdu); 1825a145daf7SSujith Manoharan len += snprintf(buf + len, size - len, "MPDU Density: %d\n\n", 1826a145daf7SSujith Manoharan an->mpdudensity); 1827a145daf7SSujith Manoharan 1828a145daf7SSujith Manoharan len += snprintf(buf + len, size - len, 1829a145daf7SSujith Manoharan "%2s%7s\n", "AC", "SCHED"); 1830a145daf7SSujith Manoharan 1831a145daf7SSujith Manoharan for (acno = 0, ac = &an->ac[acno]; 1832a145daf7SSujith Manoharan acno < IEEE80211_NUM_ACS; acno++, ac++) { 1833a145daf7SSujith Manoharan txq = ac->txq; 1834a145daf7SSujith Manoharan ath_txq_lock(sc, txq); 1835a145daf7SSujith Manoharan len += snprintf(buf + len, size - len, 1836a145daf7SSujith Manoharan "%2d%7d\n", 1837a145daf7SSujith Manoharan acno, ac->sched); 1838a145daf7SSujith Manoharan ath_txq_unlock(sc, txq); 1839a145daf7SSujith Manoharan } 1840a145daf7SSujith Manoharan 1841a145daf7SSujith Manoharan len += snprintf(buf + len, size - len, 1842a145daf7SSujith Manoharan "\n%3s%11s%10s%10s%10s%10s%9s%6s%8s\n", 1843a145daf7SSujith Manoharan "TID", "SEQ_START", "SEQ_NEXT", "BAW_SIZE", 1844a145daf7SSujith Manoharan "BAW_HEAD", "BAW_TAIL", "BAR_IDX", "SCHED", "PAUSED"); 1845a145daf7SSujith Manoharan 1846a145daf7SSujith Manoharan for (tidno = 0, tid = &an->tid[tidno]; 1847a145daf7SSujith Manoharan tidno < IEEE80211_NUM_TIDS; tidno++, tid++) { 1848a145daf7SSujith Manoharan txq = tid->ac->txq; 1849a145daf7SSujith Manoharan ath_txq_lock(sc, txq); 1850a145daf7SSujith Manoharan len += snprintf(buf + len, size - len, 1851a145daf7SSujith Manoharan "%3d%11d%10d%10d%10d%10d%9d%6d%8d\n", 1852a145daf7SSujith Manoharan tid->tidno, tid->seq_start, tid->seq_next, 1853a145daf7SSujith Manoharan tid->baw_size, tid->baw_head, tid->baw_tail, 1854a145daf7SSujith Manoharan tid->bar_index, tid->sched, tid->paused); 1855a145daf7SSujith Manoharan ath_txq_unlock(sc, txq); 1856a145daf7SSujith Manoharan } 1857a145daf7SSujith Manoharan exit: 1858a145daf7SSujith Manoharan retval = simple_read_from_buffer(user_buf, count, ppos, buf, len); 1859a145daf7SSujith Manoharan kfree(buf); 1860a145daf7SSujith Manoharan 1861a145daf7SSujith Manoharan return retval; 1862a145daf7SSujith Manoharan } 1863a145daf7SSujith Manoharan 1864a145daf7SSujith Manoharan static const struct file_operations fops_node_stat = { 1865a145daf7SSujith Manoharan .read = read_file_node_stat, 1866a145daf7SSujith Manoharan .open = simple_open, 1867a145daf7SSujith Manoharan .owner = THIS_MODULE, 1868a145daf7SSujith Manoharan .llseek = default_llseek, 1869a145daf7SSujith Manoharan }; 1870a145daf7SSujith Manoharan 1871a145daf7SSujith Manoharan void ath9k_sta_add_debugfs(struct ieee80211_hw *hw, 1872a145daf7SSujith Manoharan struct ieee80211_vif *vif, 1873a145daf7SSujith Manoharan struct ieee80211_sta *sta, 1874a145daf7SSujith Manoharan struct dentry *dir) 1875a145daf7SSujith Manoharan { 1876a145daf7SSujith Manoharan struct ath_node *an = (struct ath_node *)sta->drv_priv; 1877a145daf7SSujith Manoharan an->node_stat = debugfs_create_file("node_stat", S_IRUGO, 1878a145daf7SSujith Manoharan dir, an, &fops_node_stat); 1879a145daf7SSujith Manoharan } 1880a145daf7SSujith Manoharan 1881a145daf7SSujith Manoharan void ath9k_sta_remove_debugfs(struct ieee80211_hw *hw, 1882a145daf7SSujith Manoharan struct ieee80211_vif *vif, 1883a145daf7SSujith Manoharan struct ieee80211_sta *sta, 1884a145daf7SSujith Manoharan struct dentry *dir) 1885a145daf7SSujith Manoharan { 1886a145daf7SSujith Manoharan struct ath_node *an = (struct ath_node *)sta->drv_priv; 1887a145daf7SSujith Manoharan debugfs_remove(an->node_stat); 1888a145daf7SSujith Manoharan } 1889a145daf7SSujith Manoharan 1890c175db87SSujith Manoharan /* Ethtool support for get-stats */ 1891c175db87SSujith Manoharan 1892c175db87SSujith Manoharan #define AMKSTR(nm) #nm "_BE", #nm "_BK", #nm "_VI", #nm "_VO" 1893c175db87SSujith Manoharan static const char ath9k_gstrings_stats[][ETH_GSTRING_LEN] = { 1894c175db87SSujith Manoharan "tx_pkts_nic", 1895c175db87SSujith Manoharan "tx_bytes_nic", 1896c175db87SSujith Manoharan "rx_pkts_nic", 1897c175db87SSujith Manoharan "rx_bytes_nic", 1898c175db87SSujith Manoharan AMKSTR(d_tx_pkts), 1899c175db87SSujith Manoharan AMKSTR(d_tx_bytes), 1900c175db87SSujith Manoharan AMKSTR(d_tx_mpdus_queued), 1901c175db87SSujith Manoharan AMKSTR(d_tx_mpdus_completed), 1902c175db87SSujith Manoharan AMKSTR(d_tx_mpdu_xretries), 1903c175db87SSujith Manoharan AMKSTR(d_tx_aggregates), 1904c175db87SSujith Manoharan AMKSTR(d_tx_ampdus_queued_hw), 1905c175db87SSujith Manoharan AMKSTR(d_tx_ampdus_queued_sw), 1906c175db87SSujith Manoharan AMKSTR(d_tx_ampdus_completed), 1907c175db87SSujith Manoharan AMKSTR(d_tx_ampdu_retries), 1908c175db87SSujith Manoharan AMKSTR(d_tx_ampdu_xretries), 1909c175db87SSujith Manoharan AMKSTR(d_tx_fifo_underrun), 1910c175db87SSujith Manoharan AMKSTR(d_tx_op_exceeded), 1911c175db87SSujith Manoharan AMKSTR(d_tx_timer_expiry), 1912c175db87SSujith Manoharan AMKSTR(d_tx_desc_cfg_err), 1913c175db87SSujith Manoharan AMKSTR(d_tx_data_underrun), 1914c175db87SSujith Manoharan AMKSTR(d_tx_delim_underrun), 191518c45b10SBen Greear "d_rx_crc_err", 1916c175db87SSujith Manoharan "d_rx_decrypt_crc_err", 1917c175db87SSujith Manoharan "d_rx_phy_err", 1918c175db87SSujith Manoharan "d_rx_mic_err", 1919c175db87SSujith Manoharan "d_rx_pre_delim_crc_err", 1920c175db87SSujith Manoharan "d_rx_post_delim_crc_err", 1921c175db87SSujith Manoharan "d_rx_decrypt_busy_err", 1922c175db87SSujith Manoharan 1923c175db87SSujith Manoharan "d_rx_phyerr_radar", 1924c175db87SSujith Manoharan "d_rx_phyerr_ofdm_timing", 1925c175db87SSujith Manoharan "d_rx_phyerr_cck_timing", 1926c175db87SSujith Manoharan 1927c175db87SSujith Manoharan }; 1928c175db87SSujith Manoharan #define ATH9K_SSTATS_LEN ARRAY_SIZE(ath9k_gstrings_stats) 1929c175db87SSujith Manoharan 1930c175db87SSujith Manoharan void ath9k_get_et_strings(struct ieee80211_hw *hw, 1931c175db87SSujith Manoharan struct ieee80211_vif *vif, 1932c175db87SSujith Manoharan u32 sset, u8 *data) 1933c175db87SSujith Manoharan { 1934c175db87SSujith Manoharan if (sset == ETH_SS_STATS) 1935c175db87SSujith Manoharan memcpy(data, *ath9k_gstrings_stats, 1936c175db87SSujith Manoharan sizeof(ath9k_gstrings_stats)); 1937c175db87SSujith Manoharan } 1938c175db87SSujith Manoharan 1939c175db87SSujith Manoharan int ath9k_get_et_sset_count(struct ieee80211_hw *hw, 1940c175db87SSujith Manoharan struct ieee80211_vif *vif, int sset) 1941c175db87SSujith Manoharan { 1942c175db87SSujith Manoharan if (sset == ETH_SS_STATS) 1943c175db87SSujith Manoharan return ATH9K_SSTATS_LEN; 1944c175db87SSujith Manoharan return 0; 1945c175db87SSujith Manoharan } 1946c175db87SSujith Manoharan 1947c175db87SSujith Manoharan #define AWDATA(elem) \ 1948c175db87SSujith Manoharan do { \ 1949c175db87SSujith Manoharan data[i++] = sc->debug.stats.txstats[PR_QNUM(IEEE80211_AC_BE)].elem; \ 1950c175db87SSujith Manoharan data[i++] = sc->debug.stats.txstats[PR_QNUM(IEEE80211_AC_BK)].elem; \ 1951c175db87SSujith Manoharan data[i++] = sc->debug.stats.txstats[PR_QNUM(IEEE80211_AC_VI)].elem; \ 1952c175db87SSujith Manoharan data[i++] = sc->debug.stats.txstats[PR_QNUM(IEEE80211_AC_VO)].elem; \ 1953c175db87SSujith Manoharan } while (0) 1954c175db87SSujith Manoharan 1955c175db87SSujith Manoharan #define AWDATA_RX(elem) \ 1956c175db87SSujith Manoharan do { \ 1957c175db87SSujith Manoharan data[i++] = sc->debug.stats.rxstats.elem; \ 1958c175db87SSujith Manoharan } while (0) 1959c175db87SSujith Manoharan 1960c175db87SSujith Manoharan void ath9k_get_et_stats(struct ieee80211_hw *hw, 1961c175db87SSujith Manoharan struct ieee80211_vif *vif, 1962c175db87SSujith Manoharan struct ethtool_stats *stats, u64 *data) 1963c175db87SSujith Manoharan { 1964c175db87SSujith Manoharan struct ath_softc *sc = hw->priv; 1965c175db87SSujith Manoharan int i = 0; 1966c175db87SSujith Manoharan 1967c175db87SSujith Manoharan data[i++] = (sc->debug.stats.txstats[PR_QNUM(IEEE80211_AC_BE)].tx_pkts_all + 1968c175db87SSujith Manoharan sc->debug.stats.txstats[PR_QNUM(IEEE80211_AC_BK)].tx_pkts_all + 1969c175db87SSujith Manoharan sc->debug.stats.txstats[PR_QNUM(IEEE80211_AC_VI)].tx_pkts_all + 1970c175db87SSujith Manoharan sc->debug.stats.txstats[PR_QNUM(IEEE80211_AC_VO)].tx_pkts_all); 1971c175db87SSujith Manoharan data[i++] = (sc->debug.stats.txstats[PR_QNUM(IEEE80211_AC_BE)].tx_bytes_all + 1972c175db87SSujith Manoharan sc->debug.stats.txstats[PR_QNUM(IEEE80211_AC_BK)].tx_bytes_all + 1973c175db87SSujith Manoharan sc->debug.stats.txstats[PR_QNUM(IEEE80211_AC_VI)].tx_bytes_all + 1974c175db87SSujith Manoharan sc->debug.stats.txstats[PR_QNUM(IEEE80211_AC_VO)].tx_bytes_all); 1975c175db87SSujith Manoharan AWDATA_RX(rx_pkts_all); 1976c175db87SSujith Manoharan AWDATA_RX(rx_bytes_all); 1977c175db87SSujith Manoharan 1978c175db87SSujith Manoharan AWDATA(tx_pkts_all); 1979c175db87SSujith Manoharan AWDATA(tx_bytes_all); 1980c175db87SSujith Manoharan AWDATA(queued); 1981c175db87SSujith Manoharan AWDATA(completed); 1982c175db87SSujith Manoharan AWDATA(xretries); 1983c175db87SSujith Manoharan AWDATA(a_aggr); 1984c175db87SSujith Manoharan AWDATA(a_queued_hw); 1985c175db87SSujith Manoharan AWDATA(a_queued_sw); 1986c175db87SSujith Manoharan AWDATA(a_completed); 1987c175db87SSujith Manoharan AWDATA(a_retries); 1988c175db87SSujith Manoharan AWDATA(a_xretries); 1989c175db87SSujith Manoharan AWDATA(fifo_underrun); 1990c175db87SSujith Manoharan AWDATA(xtxop); 1991c175db87SSujith Manoharan AWDATA(timer_exp); 1992c175db87SSujith Manoharan AWDATA(desc_cfg_err); 1993c175db87SSujith Manoharan AWDATA(data_underrun); 1994c175db87SSujith Manoharan AWDATA(delim_underrun); 1995c175db87SSujith Manoharan 199618c45b10SBen Greear AWDATA_RX(crc_err); 1997c175db87SSujith Manoharan AWDATA_RX(decrypt_crc_err); 1998c175db87SSujith Manoharan AWDATA_RX(phy_err); 1999c175db87SSujith Manoharan AWDATA_RX(mic_err); 2000c175db87SSujith Manoharan AWDATA_RX(pre_delim_crc_err); 2001c175db87SSujith Manoharan AWDATA_RX(post_delim_crc_err); 2002c175db87SSujith Manoharan AWDATA_RX(decrypt_busy_err); 2003c175db87SSujith Manoharan 2004c175db87SSujith Manoharan AWDATA_RX(phy_err_stats[ATH9K_PHYERR_RADAR]); 2005c175db87SSujith Manoharan AWDATA_RX(phy_err_stats[ATH9K_PHYERR_OFDM_TIMING]); 2006c175db87SSujith Manoharan AWDATA_RX(phy_err_stats[ATH9K_PHYERR_CCK_TIMING]); 2007c175db87SSujith Manoharan 2008c175db87SSujith Manoharan WARN_ON(i != ATH9K_SSTATS_LEN); 2009c175db87SSujith Manoharan } 2010c175db87SSujith Manoharan 20114d6b228dSLuis R. Rodriguez int ath9k_init_debug(struct ath_hw *ah) 2012203c4805SLuis R. Rodriguez { 2013bc974f4aSLuis R. Rodriguez struct ath_common *common = ath9k_hw_common(ah); 2014bc974f4aSLuis R. Rodriguez struct ath_softc *sc = (struct ath_softc *) common->priv; 20154d6b228dSLuis R. Rodriguez 2016eb272441SBen Greear sc->debug.debugfs_phy = debugfs_create_dir("ath9k", 2017eb272441SBen Greear sc->hw->wiphy->debugfsdir); 2018203c4805SLuis R. Rodriguez if (!sc->debug.debugfs_phy) 2019c8a72c00SFelix Fietkau return -ENOMEM; 2020203c4805SLuis R. Rodriguez 2021a830df07SFelix Fietkau #ifdef CONFIG_ATH_DEBUG 2022c70cab1aSFelix Fietkau debugfs_create_file("debug", S_IRUSR | S_IWUSR, sc->debug.debugfs_phy, 2023c70cab1aSFelix Fietkau sc, &fops_debug); 2024a830df07SFelix Fietkau #endif 202529942bc1SZefir Kurtisi 202629942bc1SZefir Kurtisi ath9k_dfs_init_debug(sc); 202729942bc1SZefir Kurtisi 2028c70cab1aSFelix Fietkau debugfs_create_file("dma", S_IRUSR, sc->debug.debugfs_phy, sc, 2029c70cab1aSFelix Fietkau &fops_dma); 2030c70cab1aSFelix Fietkau debugfs_create_file("interrupt", S_IRUSR, sc->debug.debugfs_phy, sc, 2031c70cab1aSFelix Fietkau &fops_interrupt); 2032c70cab1aSFelix Fietkau debugfs_create_file("xmit", S_IRUSR, sc->debug.debugfs_phy, sc, 2033c70cab1aSFelix Fietkau &fops_xmit); 2034c0b74876SSujith Manoharan debugfs_create_file("queues", S_IRUSR, sc->debug.debugfs_phy, sc, 2035c0b74876SSujith Manoharan &fops_queues); 20367702e788SFelix Fietkau debugfs_create_u32("qlen_bk", S_IRUSR | S_IWUSR, sc->debug.debugfs_phy, 2037bea843c7SSujith Manoharan &sc->tx.txq_max_pending[IEEE80211_AC_BK]); 20387702e788SFelix Fietkau debugfs_create_u32("qlen_be", S_IRUSR | S_IWUSR, sc->debug.debugfs_phy, 2039bea843c7SSujith Manoharan &sc->tx.txq_max_pending[IEEE80211_AC_BE]); 20407702e788SFelix Fietkau debugfs_create_u32("qlen_vi", S_IRUSR | S_IWUSR, sc->debug.debugfs_phy, 2041bea843c7SSujith Manoharan &sc->tx.txq_max_pending[IEEE80211_AC_VI]); 20427702e788SFelix Fietkau debugfs_create_u32("qlen_vo", S_IRUSR | S_IWUSR, sc->debug.debugfs_phy, 2043bea843c7SSujith Manoharan &sc->tx.txq_max_pending[IEEE80211_AC_VO]); 2044c70cab1aSFelix Fietkau debugfs_create_file("misc", S_IRUSR, sc->debug.debugfs_phy, sc, 2045c70cab1aSFelix Fietkau &fops_misc); 2046f8b815dcSSujith Manoharan debugfs_create_file("reset", S_IRUSR, sc->debug.debugfs_phy, sc, 2047f8b815dcSSujith Manoharan &fops_reset); 2048c70cab1aSFelix Fietkau debugfs_create_file("recv", S_IRUSR, sc->debug.debugfs_phy, sc, 2049c70cab1aSFelix Fietkau &fops_recv); 2050c70cab1aSFelix Fietkau debugfs_create_file("rx_chainmask", S_IRUSR | S_IWUSR, 2051c70cab1aSFelix Fietkau sc->debug.debugfs_phy, sc, &fops_rx_chainmask); 2052c70cab1aSFelix Fietkau debugfs_create_file("tx_chainmask", S_IRUSR | S_IWUSR, 2053c70cab1aSFelix Fietkau sc->debug.debugfs_phy, sc, &fops_tx_chainmask); 205405c0be2fSMohammed Shafi Shajakhan debugfs_create_file("disable_ani", S_IRUSR | S_IWUSR, 205505c0be2fSMohammed Shafi Shajakhan sc->debug.debugfs_phy, sc, &fops_disable_ani); 205674673db9SFelix Fietkau debugfs_create_bool("paprd", S_IRUSR | S_IWUSR, sc->debug.debugfs_phy, 205774673db9SFelix Fietkau &sc->sc_ah->config.enable_paprd); 2058c70cab1aSFelix Fietkau debugfs_create_file("regidx", S_IRUSR | S_IWUSR, sc->debug.debugfs_phy, 2059c70cab1aSFelix Fietkau sc, &fops_regidx); 2060c70cab1aSFelix Fietkau debugfs_create_file("regval", S_IRUSR | S_IWUSR, sc->debug.debugfs_phy, 2061c70cab1aSFelix Fietkau sc, &fops_regval); 2062c70cab1aSFelix Fietkau debugfs_create_bool("ignore_extcca", S_IRUSR | S_IWUSR, 2063c70cab1aSFelix Fietkau sc->debug.debugfs_phy, 2064c70cab1aSFelix Fietkau &ah->config.cwm_ignore_extcca); 2065c70cab1aSFelix Fietkau debugfs_create_file("regdump", S_IRUSR, sc->debug.debugfs_phy, sc, 2066c70cab1aSFelix Fietkau &fops_regdump); 2067d069a46bSRajkumar Manoharan debugfs_create_file("dump_nfcal", S_IRUSR, sc->debug.debugfs_phy, sc, 2068d069a46bSRajkumar Manoharan &fops_dump_nfcal); 2069580f010fSRajkumar Manoharan debugfs_create_file("base_eeprom", S_IRUSR, sc->debug.debugfs_phy, sc, 2070580f010fSRajkumar Manoharan &fops_base_eeprom); 20713f4c4bddSRajkumar Manoharan debugfs_create_file("modal_eeprom", S_IRUSR, sc->debug.debugfs_phy, sc, 20723f4c4bddSRajkumar Manoharan &fops_modal_eeprom); 2073e93d083fSSimon Wunderlich sc->rfs_chan_spec_scan = relay_open("spectral_scan", 2074e93d083fSSimon Wunderlich sc->debug.debugfs_phy, 2075*55f39e67SZefir Kurtisi 1024, 256, &rfs_spec_scan_cb, 2076e93d083fSSimon Wunderlich NULL); 2077e93d083fSSimon Wunderlich debugfs_create_file("spectral_scan_ctl", S_IRUSR | S_IWUSR, 2078e93d083fSSimon Wunderlich sc->debug.debugfs_phy, sc, 2079e93d083fSSimon Wunderlich &fops_spec_scan_ctl); 208004ccd4a1SSimon Wunderlich debugfs_create_file("spectral_short_repeat", S_IRUSR | S_IWUSR, 208104ccd4a1SSimon Wunderlich sc->debug.debugfs_phy, sc, 208204ccd4a1SSimon Wunderlich &fops_spectral_short_repeat); 208304ccd4a1SSimon Wunderlich debugfs_create_file("spectral_count", S_IRUSR | S_IWUSR, 208404ccd4a1SSimon Wunderlich sc->debug.debugfs_phy, sc, &fops_spectral_count); 208504ccd4a1SSimon Wunderlich debugfs_create_file("spectral_period", S_IRUSR | S_IWUSR, 208604ccd4a1SSimon Wunderlich sc->debug.debugfs_phy, sc, &fops_spectral_period); 208704ccd4a1SSimon Wunderlich debugfs_create_file("spectral_fft_period", S_IRUSR | S_IWUSR, 208804ccd4a1SSimon Wunderlich sc->debug.debugfs_phy, sc, 208904ccd4a1SSimon Wunderlich &fops_spectral_fft_period); 2090e93d083fSSimon Wunderlich 20915baec742SFelix Fietkau #ifdef CONFIG_ATH9K_MAC_DEBUG 2092cf3af748SRajkumar Manoharan debugfs_create_file("samples", S_IRUSR, sc->debug.debugfs_phy, sc, 2093cf3af748SRajkumar Manoharan &fops_samps); 20945baec742SFelix Fietkau #endif 2095691680b8SFelix Fietkau debugfs_create_u32("gpio_mask", S_IRUSR | S_IWUSR, 2096691680b8SFelix Fietkau sc->debug.debugfs_phy, &sc->sc_ah->gpio_mask); 2097691680b8SFelix Fietkau debugfs_create_u32("gpio_val", S_IRUSR | S_IWUSR, 2098691680b8SFelix Fietkau sc->debug.debugfs_phy, &sc->sc_ah->gpio_val); 2099302a3c3aSSujith Manoharan debugfs_create_file("diversity", S_IRUSR | S_IWUSR, 2100302a3c3aSSujith Manoharan sc->debug.debugfs_phy, sc, &fops_ant_diversity); 21014df50ca8SRajkumar Manoharan #ifdef CONFIG_ATH9K_BTCOEX_SUPPORT 21024df50ca8SRajkumar Manoharan debugfs_create_file("btcoex", S_IRUSR, sc->debug.debugfs_phy, sc, 21034df50ca8SRajkumar Manoharan &fops_btcoex); 21044df50ca8SRajkumar Manoharan #endif 2105203c4805SLuis R. Rodriguez return 0; 2106203c4805SLuis R. Rodriguez } 2107