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'; 7227d7f477SJingoo Han if (kstrtoul(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'; 11727d7f477SJingoo Han if (kstrtoul(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'; 16027d7f477SJingoo Han if (kstrtoul(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 1766e4d291eSSujith Manoharan static ssize_t read_file_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); 1816e4d291eSSujith Manoharan struct ath_hw *ah = sc->sc_ah; 1826e4d291eSSujith Manoharan unsigned int len = 0, size = 1024; 1836e4d291eSSujith Manoharan ssize_t retval = 0; 1846e4d291eSSujith Manoharan char *buf; 18505c0be2fSMohammed Shafi Shajakhan 1866e4d291eSSujith Manoharan buf = kzalloc(size, GFP_KERNEL); 1876e4d291eSSujith Manoharan if (buf == NULL) 1886e4d291eSSujith Manoharan return -ENOMEM; 1896e4d291eSSujith Manoharan 1906e4d291eSSujith Manoharan if (common->disable_ani) { 1916e4d291eSSujith Manoharan len += snprintf(buf + len, size - len, "%s: %s\n", 1926e4d291eSSujith Manoharan "ANI", "DISABLED"); 1936e4d291eSSujith Manoharan goto exit; 19405c0be2fSMohammed Shafi Shajakhan } 19505c0be2fSMohammed Shafi Shajakhan 1966e4d291eSSujith Manoharan len += snprintf(buf + len, size - len, "%15s: %s\n", 1976e4d291eSSujith Manoharan "ANI", "ENABLED"); 1986e4d291eSSujith Manoharan len += snprintf(buf + len, size - len, "%15s: %u\n", 1996e4d291eSSujith Manoharan "ANI RESET", ah->stats.ast_ani_reset); 2006e4d291eSSujith Manoharan len += snprintf(buf + len, size - len, "%15s: %u\n", 2016e4d291eSSujith Manoharan "SPUR UP", ah->stats.ast_ani_spurup); 2026e4d291eSSujith Manoharan len += snprintf(buf + len, size - len, "%15s: %u\n", 2036e4d291eSSujith Manoharan "SPUR DOWN", ah->stats.ast_ani_spurup); 2046e4d291eSSujith Manoharan len += snprintf(buf + len, size - len, "%15s: %u\n", 2056e4d291eSSujith Manoharan "OFDM WS-DET ON", ah->stats.ast_ani_ofdmon); 2066e4d291eSSujith Manoharan len += snprintf(buf + len, size - len, "%15s: %u\n", 2076e4d291eSSujith Manoharan "OFDM WS-DET OFF", ah->stats.ast_ani_ofdmoff); 2086e4d291eSSujith Manoharan len += snprintf(buf + len, size - len, "%15s: %u\n", 2096e4d291eSSujith Manoharan "MRC-CCK ON", ah->stats.ast_ani_ccklow); 2106e4d291eSSujith Manoharan len += snprintf(buf + len, size - len, "%15s: %u\n", 2116e4d291eSSujith Manoharan "MRC-CCK OFF", ah->stats.ast_ani_cckhigh); 2126e4d291eSSujith Manoharan len += snprintf(buf + len, size - len, "%15s: %u\n", 2136e4d291eSSujith Manoharan "FIR-STEP UP", ah->stats.ast_ani_stepup); 2146e4d291eSSujith Manoharan len += snprintf(buf + len, size - len, "%15s: %u\n", 2156e4d291eSSujith Manoharan "FIR-STEP DOWN", ah->stats.ast_ani_stepdown); 2166e4d291eSSujith Manoharan len += snprintf(buf + len, size - len, "%15s: %u\n", 2176e4d291eSSujith Manoharan "INV LISTENTIME", ah->stats.ast_ani_lneg_or_lzero); 2186e4d291eSSujith Manoharan len += snprintf(buf + len, size - len, "%15s: %u\n", 2196e4d291eSSujith Manoharan "OFDM ERRORS", ah->stats.ast_ani_ofdmerrs); 2206e4d291eSSujith Manoharan len += snprintf(buf + len, size - len, "%15s: %u\n", 2216e4d291eSSujith Manoharan "CCK ERRORS", ah->stats.ast_ani_cckerrs); 2226e4d291eSSujith Manoharan exit: 2236e4d291eSSujith Manoharan if (len > size) 2246e4d291eSSujith Manoharan len = size; 2256e4d291eSSujith Manoharan 2266e4d291eSSujith Manoharan retval = simple_read_from_buffer(user_buf, count, ppos, buf, len); 2276e4d291eSSujith Manoharan kfree(buf); 2286e4d291eSSujith Manoharan 2296e4d291eSSujith Manoharan return retval; 2306e4d291eSSujith Manoharan } 2316e4d291eSSujith Manoharan 2326e4d291eSSujith Manoharan static ssize_t write_file_ani(struct file *file, 23305c0be2fSMohammed Shafi Shajakhan const char __user *user_buf, 23405c0be2fSMohammed Shafi Shajakhan size_t count, loff_t *ppos) 23505c0be2fSMohammed Shafi Shajakhan { 23605c0be2fSMohammed Shafi Shajakhan struct ath_softc *sc = file->private_data; 23705c0be2fSMohammed Shafi Shajakhan struct ath_common *common = ath9k_hw_common(sc->sc_ah); 2386e4d291eSSujith Manoharan unsigned long ani; 23905c0be2fSMohammed Shafi Shajakhan char buf[32]; 24005c0be2fSMohammed Shafi Shajakhan ssize_t len; 24105c0be2fSMohammed Shafi Shajakhan 24205c0be2fSMohammed Shafi Shajakhan len = min(count, sizeof(buf) - 1); 24305c0be2fSMohammed Shafi Shajakhan if (copy_from_user(buf, user_buf, len)) 24405c0be2fSMohammed Shafi Shajakhan return -EFAULT; 24505c0be2fSMohammed Shafi Shajakhan 24605c0be2fSMohammed Shafi Shajakhan buf[len] = '\0'; 2473899ba90SJohn W. Linville if (kstrtoul(buf, 0, &ani)) 24805c0be2fSMohammed Shafi Shajakhan return -EINVAL; 24905c0be2fSMohammed Shafi Shajakhan 2506e4d291eSSujith Manoharan if (ani < 0 || ani > 1) 2516e4d291eSSujith Manoharan return -EINVAL; 25205c0be2fSMohammed Shafi Shajakhan 2536e4d291eSSujith Manoharan common->disable_ani = !ani; 2546e4d291eSSujith Manoharan 2556e4d291eSSujith Manoharan if (common->disable_ani) { 256781b14a3SSujith Manoharan clear_bit(SC_OP_ANI_RUN, &sc->sc_flags); 257da0d45f7SSujith Manoharan ath_stop_ani(sc); 25805c0be2fSMohammed Shafi Shajakhan } else { 259da0d45f7SSujith Manoharan ath_check_ani(sc); 26005c0be2fSMohammed Shafi Shajakhan } 26105c0be2fSMohammed Shafi Shajakhan 26205c0be2fSMohammed Shafi Shajakhan return count; 26305c0be2fSMohammed Shafi Shajakhan } 26405c0be2fSMohammed Shafi Shajakhan 2656e4d291eSSujith Manoharan static const struct file_operations fops_ani = { 2666e4d291eSSujith Manoharan .read = read_file_ani, 2676e4d291eSSujith Manoharan .write = write_file_ani, 268234e3405SStephen Boyd .open = simple_open, 26905c0be2fSMohammed Shafi Shajakhan .owner = THIS_MODULE, 27005c0be2fSMohammed Shafi Shajakhan .llseek = default_llseek, 27105c0be2fSMohammed Shafi Shajakhan }; 27215340694SFelix Fietkau 27363081305SSujith Manoharan static ssize_t read_file_bt_ant_diversity(struct file *file, 27463081305SSujith Manoharan char __user *user_buf, 275302a3c3aSSujith Manoharan size_t count, loff_t *ppos) 276302a3c3aSSujith Manoharan { 277302a3c3aSSujith Manoharan struct ath_softc *sc = file->private_data; 278302a3c3aSSujith Manoharan struct ath_common *common = ath9k_hw_common(sc->sc_ah); 279302a3c3aSSujith Manoharan char buf[32]; 280302a3c3aSSujith Manoharan unsigned int len; 281302a3c3aSSujith Manoharan 28263081305SSujith Manoharan len = sprintf(buf, "%d\n", common->bt_ant_diversity); 283302a3c3aSSujith Manoharan return simple_read_from_buffer(user_buf, count, ppos, buf, len); 284302a3c3aSSujith Manoharan } 285302a3c3aSSujith Manoharan 28663081305SSujith Manoharan static ssize_t write_file_bt_ant_diversity(struct file *file, 287302a3c3aSSujith Manoharan const char __user *user_buf, 288302a3c3aSSujith Manoharan size_t count, loff_t *ppos) 289302a3c3aSSujith Manoharan { 290302a3c3aSSujith Manoharan struct ath_softc *sc = file->private_data; 291302a3c3aSSujith Manoharan struct ath_common *common = ath9k_hw_common(sc->sc_ah); 292*3f2da955SSujith Manoharan struct ath9k_hw_capabilities *pCap = &sc->sc_ah->caps; 29363081305SSujith Manoharan unsigned long bt_ant_diversity; 294302a3c3aSSujith Manoharan char buf[32]; 295302a3c3aSSujith Manoharan ssize_t len; 296302a3c3aSSujith Manoharan 297302a3c3aSSujith Manoharan len = min(count, sizeof(buf) - 1); 298302a3c3aSSujith Manoharan if (copy_from_user(buf, user_buf, len)) 299302a3c3aSSujith Manoharan return -EFAULT; 300302a3c3aSSujith Manoharan 301*3f2da955SSujith Manoharan if (!(pCap->hw_caps & ATH9K_HW_CAP_BT_ANT_DIV)) 302*3f2da955SSujith Manoharan goto exit; 303*3f2da955SSujith Manoharan 304302a3c3aSSujith Manoharan buf[len] = '\0'; 30563081305SSujith Manoharan if (kstrtoul(buf, 0, &bt_ant_diversity)) 306302a3c3aSSujith Manoharan return -EINVAL; 307302a3c3aSSujith Manoharan 30863081305SSujith Manoharan common->bt_ant_diversity = !!bt_ant_diversity; 309302a3c3aSSujith Manoharan ath9k_ps_wakeup(sc); 310302a3c3aSSujith Manoharan ath_ant_comb_update(sc); 31163081305SSujith Manoharan ath_dbg(common, CONFIG, "Enable WLAN/BT RX Antenna diversity: %d\n", 31263081305SSujith Manoharan common->bt_ant_diversity); 313302a3c3aSSujith Manoharan ath9k_ps_restore(sc); 314*3f2da955SSujith Manoharan exit: 315302a3c3aSSujith Manoharan return count; 316302a3c3aSSujith Manoharan } 317302a3c3aSSujith Manoharan 31863081305SSujith Manoharan static const struct file_operations fops_bt_ant_diversity = { 31963081305SSujith Manoharan .read = read_file_bt_ant_diversity, 32063081305SSujith Manoharan .write = write_file_bt_ant_diversity, 321302a3c3aSSujith Manoharan .open = simple_open, 322302a3c3aSSujith Manoharan .owner = THIS_MODULE, 323302a3c3aSSujith Manoharan .llseek = default_llseek, 324302a3c3aSSujith Manoharan }; 325302a3c3aSSujith Manoharan 326e3d52914SSujith Manoharan void ath9k_debug_stat_ant(struct ath_softc *sc, 327e3d52914SSujith Manoharan struct ath_hw_antcomb_conf *div_ant_conf, 328e3d52914SSujith Manoharan int main_rssi_avg, int alt_rssi_avg) 329e3d52914SSujith Manoharan { 330e3d52914SSujith Manoharan struct ath_antenna_stats *as_main = &sc->debug.stats.ant_stats[ANT_MAIN]; 331e3d52914SSujith Manoharan struct ath_antenna_stats *as_alt = &sc->debug.stats.ant_stats[ANT_ALT]; 332e3d52914SSujith Manoharan 333e3d52914SSujith Manoharan as_main->lna_attempt_cnt[div_ant_conf->main_lna_conf]++; 334e3d52914SSujith Manoharan as_alt->lna_attempt_cnt[div_ant_conf->alt_lna_conf]++; 335e3d52914SSujith Manoharan 336e3d52914SSujith Manoharan as_main->rssi_avg = main_rssi_avg; 337e3d52914SSujith Manoharan as_alt->rssi_avg = alt_rssi_avg; 338e3d52914SSujith Manoharan } 339e3d52914SSujith Manoharan 3404eba10ccSSujith Manoharan static ssize_t read_file_antenna_diversity(struct file *file, 3414eba10ccSSujith Manoharan char __user *user_buf, 3424eba10ccSSujith Manoharan size_t count, loff_t *ppos) 3434eba10ccSSujith Manoharan { 3444eba10ccSSujith Manoharan struct ath_softc *sc = file->private_data; 3454eba10ccSSujith Manoharan struct ath_hw *ah = sc->sc_ah; 3464eba10ccSSujith Manoharan struct ath9k_hw_capabilities *pCap = &ah->caps; 3474eba10ccSSujith Manoharan struct ath_antenna_stats *as_main = &sc->debug.stats.ant_stats[ANT_MAIN]; 3484eba10ccSSujith Manoharan struct ath_antenna_stats *as_alt = &sc->debug.stats.ant_stats[ANT_ALT]; 349e3d52914SSujith Manoharan struct ath_hw_antcomb_conf div_ant_conf; 3504eba10ccSSujith Manoharan unsigned int len = 0, size = 1024; 3514eba10ccSSujith Manoharan ssize_t retval = 0; 3524eba10ccSSujith Manoharan char *buf; 353e3d52914SSujith Manoharan char *lna_conf_str[4] = {"LNA1_MINUS_LNA2", 354e3d52914SSujith Manoharan "LNA2", 355e3d52914SSujith Manoharan "LNA1", 356e3d52914SSujith Manoharan "LNA1_PLUS_LNA2"}; 3574eba10ccSSujith Manoharan 3584eba10ccSSujith Manoharan buf = kzalloc(size, GFP_KERNEL); 3594eba10ccSSujith Manoharan if (buf == NULL) 3604eba10ccSSujith Manoharan return -ENOMEM; 3614eba10ccSSujith Manoharan 3624eba10ccSSujith Manoharan if (!(pCap->hw_caps & ATH9K_HW_CAP_ANT_DIV_COMB)) { 3634eba10ccSSujith Manoharan len += snprintf(buf + len, size - len, "%s\n", 3644eba10ccSSujith Manoharan "Antenna Diversity Combining is disabled"); 3654eba10ccSSujith Manoharan goto exit; 3664eba10ccSSujith Manoharan } 3674eba10ccSSujith Manoharan 368e3d52914SSujith Manoharan ath9k_ps_wakeup(sc); 369e3d52914SSujith Manoharan ath9k_hw_antdiv_comb_conf_get(ah, &div_ant_conf); 370e3d52914SSujith Manoharan len += snprintf(buf + len, size - len, "Current MAIN config : %s\n", 371e3d52914SSujith Manoharan lna_conf_str[div_ant_conf.main_lna_conf]); 372e3d52914SSujith Manoharan len += snprintf(buf + len, size - len, "Current ALT config : %s\n", 373e3d52914SSujith Manoharan lna_conf_str[div_ant_conf.alt_lna_conf]); 374e3d52914SSujith Manoharan len += snprintf(buf + len, size - len, "Average MAIN RSSI : %d\n", 375e3d52914SSujith Manoharan as_main->rssi_avg); 376e3d52914SSujith Manoharan len += snprintf(buf + len, size - len, "Average ALT RSSI : %d\n\n", 377e3d52914SSujith Manoharan as_alt->rssi_avg); 378e3d52914SSujith Manoharan ath9k_ps_restore(sc); 379e3d52914SSujith Manoharan 380e3d52914SSujith Manoharan len += snprintf(buf + len, size - len, "Packet Receive Cnt:\n"); 381e3d52914SSujith Manoharan len += snprintf(buf + len, size - len, "-------------------\n"); 382e3d52914SSujith Manoharan 3834eba10ccSSujith Manoharan len += snprintf(buf + len, size - len, "%30s%15s\n", 3844eba10ccSSujith Manoharan "MAIN", "ALT"); 385e3d52914SSujith Manoharan len += snprintf(buf + len, size - len, "%-14s:%15d%15d\n", 386e3d52914SSujith Manoharan "TOTAL COUNT", 3874eba10ccSSujith Manoharan as_main->recv_cnt, 3884eba10ccSSujith Manoharan as_alt->recv_cnt); 389e3d52914SSujith Manoharan len += snprintf(buf + len, size - len, "%-14s:%15d%15d\n", 3904eba10ccSSujith Manoharan "LNA1", 391e3d52914SSujith Manoharan as_main->lna_recv_cnt[ATH_ANT_DIV_COMB_LNA1], 392e3d52914SSujith Manoharan as_alt->lna_recv_cnt[ATH_ANT_DIV_COMB_LNA1]); 393e3d52914SSujith Manoharan len += snprintf(buf + len, size - len, "%-14s:%15d%15d\n", 3944eba10ccSSujith Manoharan "LNA2", 395e3d52914SSujith Manoharan as_main->lna_recv_cnt[ATH_ANT_DIV_COMB_LNA2], 396e3d52914SSujith Manoharan as_alt->lna_recv_cnt[ATH_ANT_DIV_COMB_LNA2]); 397e3d52914SSujith Manoharan len += snprintf(buf + len, size - len, "%-14s:%15d%15d\n", 3984eba10ccSSujith Manoharan "LNA1 + LNA2", 399e3d52914SSujith Manoharan as_main->lna_recv_cnt[ATH_ANT_DIV_COMB_LNA1_PLUS_LNA2], 400e3d52914SSujith Manoharan as_alt->lna_recv_cnt[ATH_ANT_DIV_COMB_LNA1_PLUS_LNA2]); 401e3d52914SSujith Manoharan len += snprintf(buf + len, size - len, "%-14s:%15d%15d\n", 4024eba10ccSSujith Manoharan "LNA1 - LNA2", 403e3d52914SSujith Manoharan as_main->lna_recv_cnt[ATH_ANT_DIV_COMB_LNA1_MINUS_LNA2], 404e3d52914SSujith Manoharan as_alt->lna_recv_cnt[ATH_ANT_DIV_COMB_LNA1_MINUS_LNA2]); 405e3d52914SSujith Manoharan 406e3d52914SSujith Manoharan len += snprintf(buf + len, size - len, "\nLNA Config Attempts:\n"); 407e3d52914SSujith Manoharan len += snprintf(buf + len, size - len, "--------------------\n"); 408e3d52914SSujith Manoharan 409e3d52914SSujith Manoharan len += snprintf(buf + len, size - len, "%30s%15s\n", 410e3d52914SSujith Manoharan "MAIN", "ALT"); 411e3d52914SSujith Manoharan len += snprintf(buf + len, size - len, "%-14s:%15d%15d\n", 412e3d52914SSujith Manoharan "LNA1", 413e3d52914SSujith Manoharan as_main->lna_attempt_cnt[ATH_ANT_DIV_COMB_LNA1], 414e3d52914SSujith Manoharan as_alt->lna_attempt_cnt[ATH_ANT_DIV_COMB_LNA1]); 415e3d52914SSujith Manoharan len += snprintf(buf + len, size - len, "%-14s:%15d%15d\n", 416e3d52914SSujith Manoharan "LNA2", 417e3d52914SSujith Manoharan as_main->lna_attempt_cnt[ATH_ANT_DIV_COMB_LNA2], 418e3d52914SSujith Manoharan as_alt->lna_attempt_cnt[ATH_ANT_DIV_COMB_LNA2]); 419e3d52914SSujith Manoharan len += snprintf(buf + len, size - len, "%-14s:%15d%15d\n", 420e3d52914SSujith Manoharan "LNA1 + LNA2", 421e3d52914SSujith Manoharan as_main->lna_attempt_cnt[ATH_ANT_DIV_COMB_LNA1_PLUS_LNA2], 422e3d52914SSujith Manoharan as_alt->lna_attempt_cnt[ATH_ANT_DIV_COMB_LNA1_PLUS_LNA2]); 423e3d52914SSujith Manoharan len += snprintf(buf + len, size - len, "%-14s:%15d%15d\n", 424e3d52914SSujith Manoharan "LNA1 - LNA2", 425e3d52914SSujith Manoharan as_main->lna_attempt_cnt[ATH_ANT_DIV_COMB_LNA1_MINUS_LNA2], 426e3d52914SSujith Manoharan as_alt->lna_attempt_cnt[ATH_ANT_DIV_COMB_LNA1_MINUS_LNA2]); 427e3d52914SSujith Manoharan 4284eba10ccSSujith Manoharan exit: 4294eba10ccSSujith Manoharan if (len > size) 4304eba10ccSSujith Manoharan len = size; 4314eba10ccSSujith Manoharan 4324eba10ccSSujith Manoharan retval = simple_read_from_buffer(user_buf, count, ppos, buf, len); 4334eba10ccSSujith Manoharan kfree(buf); 4344eba10ccSSujith Manoharan 4354eba10ccSSujith Manoharan return retval; 4364eba10ccSSujith Manoharan } 4374eba10ccSSujith Manoharan 4384eba10ccSSujith Manoharan static const struct file_operations fops_antenna_diversity = { 4394eba10ccSSujith Manoharan .read = read_file_antenna_diversity, 4404eba10ccSSujith Manoharan .open = simple_open, 4414eba10ccSSujith Manoharan .owner = THIS_MODULE, 4424eba10ccSSujith Manoharan .llseek = default_llseek, 4434eba10ccSSujith Manoharan }; 4444eba10ccSSujith Manoharan 445203c4805SLuis R. Rodriguez static ssize_t read_file_dma(struct file *file, char __user *user_buf, 446203c4805SLuis R. Rodriguez size_t count, loff_t *ppos) 447203c4805SLuis R. Rodriguez { 448203c4805SLuis R. Rodriguez struct ath_softc *sc = file->private_data; 449203c4805SLuis R. Rodriguez struct ath_hw *ah = sc->sc_ah; 450991a0987SPavel Roskin char *buf; 451991a0987SPavel Roskin int retval; 452203c4805SLuis R. Rodriguez unsigned int len = 0; 453203c4805SLuis R. Rodriguez u32 val[ATH9K_NUM_DMA_DEBUG_REGS]; 454203c4805SLuis R. Rodriguez int i, qcuOffset = 0, dcuOffset = 0; 455203c4805SLuis R. Rodriguez u32 *qcuBase = &val[0], *dcuBase = &val[4]; 456203c4805SLuis R. Rodriguez 457991a0987SPavel Roskin buf = kmalloc(DMA_BUF_LEN, GFP_KERNEL); 458991a0987SPavel Roskin if (!buf) 45904236066SDan Carpenter return -ENOMEM; 460991a0987SPavel Roskin 4617cf4a2e7SSujith ath9k_ps_wakeup(sc); 4627cf4a2e7SSujith 463475a6e4dSLuis R. Rodriguez REG_WRITE_D(ah, AR_MACMISC, 464203c4805SLuis R. Rodriguez ((AR_MACMISC_DMA_OBS_LINE_8 << AR_MACMISC_DMA_OBS_S) | 465203c4805SLuis R. Rodriguez (AR_MACMISC_MISC_OBS_BUS_1 << 466203c4805SLuis R. Rodriguez AR_MACMISC_MISC_OBS_BUS_MSB_S))); 467203c4805SLuis R. Rodriguez 468991a0987SPavel Roskin len += snprintf(buf + len, DMA_BUF_LEN - len, 469203c4805SLuis R. Rodriguez "Raw DMA Debug values:\n"); 470203c4805SLuis R. Rodriguez 471203c4805SLuis R. Rodriguez for (i = 0; i < ATH9K_NUM_DMA_DEBUG_REGS; i++) { 472203c4805SLuis R. Rodriguez if (i % 4 == 0) 473991a0987SPavel Roskin len += snprintf(buf + len, DMA_BUF_LEN - len, "\n"); 474203c4805SLuis R. Rodriguez 475475a6e4dSLuis R. Rodriguez val[i] = REG_READ_D(ah, AR_DMADBG_0 + (i * sizeof(u32))); 476991a0987SPavel Roskin len += snprintf(buf + len, DMA_BUF_LEN - len, "%d: %08x ", 477203c4805SLuis R. Rodriguez i, val[i]); 478203c4805SLuis R. Rodriguez } 479203c4805SLuis R. Rodriguez 480991a0987SPavel Roskin len += snprintf(buf + len, DMA_BUF_LEN - len, "\n\n"); 481991a0987SPavel Roskin len += snprintf(buf + len, DMA_BUF_LEN - len, 482203c4805SLuis R. Rodriguez "Num QCU: chain_st fsp_ok fsp_st DCU: chain_st\n"); 483203c4805SLuis R. Rodriguez 484203c4805SLuis R. Rodriguez for (i = 0; i < ATH9K_NUM_QUEUES; i++, qcuOffset += 4, dcuOffset += 5) { 485203c4805SLuis R. Rodriguez if (i == 8) { 486203c4805SLuis R. Rodriguez qcuOffset = 0; 487203c4805SLuis R. Rodriguez qcuBase++; 488203c4805SLuis R. Rodriguez } 489203c4805SLuis R. Rodriguez 490203c4805SLuis R. Rodriguez if (i == 6) { 491203c4805SLuis R. Rodriguez dcuOffset = 0; 492203c4805SLuis R. Rodriguez dcuBase++; 493203c4805SLuis R. Rodriguez } 494203c4805SLuis R. Rodriguez 495991a0987SPavel Roskin len += snprintf(buf + len, DMA_BUF_LEN - len, 496203c4805SLuis R. Rodriguez "%2d %2x %1x %2x %2x\n", 497203c4805SLuis R. Rodriguez i, (*qcuBase & (0x7 << qcuOffset)) >> qcuOffset, 498203c4805SLuis R. Rodriguez (*qcuBase & (0x8 << qcuOffset)) >> (qcuOffset + 3), 499203c4805SLuis R. Rodriguez val[2] & (0x7 << (i * 3)) >> (i * 3), 500203c4805SLuis R. Rodriguez (*dcuBase & (0x1f << dcuOffset)) >> dcuOffset); 501203c4805SLuis R. Rodriguez } 502203c4805SLuis R. Rodriguez 503991a0987SPavel Roskin len += snprintf(buf + len, DMA_BUF_LEN - len, "\n"); 504203c4805SLuis R. Rodriguez 505991a0987SPavel Roskin len += snprintf(buf + len, DMA_BUF_LEN - len, 506203c4805SLuis R. Rodriguez "qcu_stitch state: %2x qcu_fetch state: %2x\n", 507203c4805SLuis R. Rodriguez (val[3] & 0x003c0000) >> 18, (val[3] & 0x03c00000) >> 22); 508991a0987SPavel Roskin len += snprintf(buf + len, DMA_BUF_LEN - len, 509203c4805SLuis R. Rodriguez "qcu_complete state: %2x dcu_complete state: %2x\n", 510203c4805SLuis R. Rodriguez (val[3] & 0x1c000000) >> 26, (val[6] & 0x3)); 511991a0987SPavel Roskin len += snprintf(buf + len, DMA_BUF_LEN - len, 512203c4805SLuis R. Rodriguez "dcu_arb state: %2x dcu_fp state: %2x\n", 513203c4805SLuis R. Rodriguez (val[5] & 0x06000000) >> 25, (val[5] & 0x38000000) >> 27); 514991a0987SPavel Roskin len += snprintf(buf + len, DMA_BUF_LEN - len, 515203c4805SLuis R. Rodriguez "chan_idle_dur: %3d chan_idle_dur_valid: %1d\n", 516203c4805SLuis R. Rodriguez (val[6] & 0x000003fc) >> 2, (val[6] & 0x00000400) >> 10); 517991a0987SPavel Roskin len += snprintf(buf + len, DMA_BUF_LEN - len, 518203c4805SLuis R. Rodriguez "txfifo_valid_0: %1d txfifo_valid_1: %1d\n", 519203c4805SLuis R. Rodriguez (val[6] & 0x00000800) >> 11, (val[6] & 0x00001000) >> 12); 520991a0987SPavel Roskin len += snprintf(buf + len, DMA_BUF_LEN - len, 521203c4805SLuis R. Rodriguez "txfifo_dcu_num_0: %2d txfifo_dcu_num_1: %2d\n", 522203c4805SLuis R. Rodriguez (val[6] & 0x0001e000) >> 13, (val[6] & 0x001e0000) >> 17); 523203c4805SLuis R. Rodriguez 524991a0987SPavel Roskin len += snprintf(buf + len, DMA_BUF_LEN - len, "pcu observe: 0x%x\n", 525475a6e4dSLuis R. Rodriguez REG_READ_D(ah, AR_OBS_BUS_1)); 526991a0987SPavel Roskin len += snprintf(buf + len, DMA_BUF_LEN - len, 527475a6e4dSLuis R. Rodriguez "AR_CR: 0x%x\n", REG_READ_D(ah, AR_CR)); 528203c4805SLuis R. Rodriguez 5297cf4a2e7SSujith ath9k_ps_restore(sc); 5307cf4a2e7SSujith 5312b87f3aaSDan Carpenter if (len > DMA_BUF_LEN) 5322b87f3aaSDan Carpenter len = DMA_BUF_LEN; 5332b87f3aaSDan Carpenter 534991a0987SPavel Roskin retval = simple_read_from_buffer(user_buf, count, ppos, buf, len); 535991a0987SPavel Roskin kfree(buf); 536991a0987SPavel Roskin return retval; 537203c4805SLuis R. Rodriguez } 538203c4805SLuis R. Rodriguez 539203c4805SLuis R. Rodriguez static const struct file_operations fops_dma = { 540203c4805SLuis R. Rodriguez .read = read_file_dma, 541234e3405SStephen Boyd .open = simple_open, 5426038f373SArnd Bergmann .owner = THIS_MODULE, 5436038f373SArnd Bergmann .llseek = default_llseek, 544203c4805SLuis R. Rodriguez }; 545203c4805SLuis R. Rodriguez 546203c4805SLuis R. Rodriguez 547203c4805SLuis R. Rodriguez void ath_debug_stat_interrupt(struct ath_softc *sc, enum ath9k_int status) 548203c4805SLuis R. Rodriguez { 549203c4805SLuis R. Rodriguez if (status) 550203c4805SLuis R. Rodriguez sc->debug.stats.istats.total++; 551a9616f41SLuis R. Rodriguez if (sc->sc_ah->caps.hw_caps & ATH9K_HW_CAP_EDMA) { 552a9616f41SLuis R. Rodriguez if (status & ATH9K_INT_RXLP) 553a9616f41SLuis R. Rodriguez sc->debug.stats.istats.rxlp++; 554a9616f41SLuis R. Rodriguez if (status & ATH9K_INT_RXHP) 555a9616f41SLuis R. Rodriguez sc->debug.stats.istats.rxhp++; 55608578b8fSLuis R. Rodriguez if (status & ATH9K_INT_BB_WATCHDOG) 55708578b8fSLuis R. Rodriguez sc->debug.stats.istats.bb_watchdog++; 558a9616f41SLuis R. Rodriguez } else { 559203c4805SLuis R. Rodriguez if (status & ATH9K_INT_RX) 560203c4805SLuis R. Rodriguez sc->debug.stats.istats.rxok++; 561a9616f41SLuis R. Rodriguez } 562203c4805SLuis R. Rodriguez if (status & ATH9K_INT_RXEOL) 563203c4805SLuis R. Rodriguez sc->debug.stats.istats.rxeol++; 564203c4805SLuis R. Rodriguez if (status & ATH9K_INT_RXORN) 565203c4805SLuis R. Rodriguez sc->debug.stats.istats.rxorn++; 566203c4805SLuis R. Rodriguez if (status & ATH9K_INT_TX) 567203c4805SLuis R. Rodriguez sc->debug.stats.istats.txok++; 568203c4805SLuis R. Rodriguez if (status & ATH9K_INT_TXURN) 569203c4805SLuis R. Rodriguez sc->debug.stats.istats.txurn++; 570203c4805SLuis R. Rodriguez if (status & ATH9K_INT_RXPHY) 571203c4805SLuis R. Rodriguez sc->debug.stats.istats.rxphyerr++; 572203c4805SLuis R. Rodriguez if (status & ATH9K_INT_RXKCM) 573203c4805SLuis R. Rodriguez sc->debug.stats.istats.rx_keycache_miss++; 574203c4805SLuis R. Rodriguez if (status & ATH9K_INT_SWBA) 575203c4805SLuis R. Rodriguez sc->debug.stats.istats.swba++; 576203c4805SLuis R. Rodriguez if (status & ATH9K_INT_BMISS) 577203c4805SLuis R. Rodriguez sc->debug.stats.istats.bmiss++; 578203c4805SLuis R. Rodriguez if (status & ATH9K_INT_BNR) 579203c4805SLuis R. Rodriguez sc->debug.stats.istats.bnr++; 580203c4805SLuis R. Rodriguez if (status & ATH9K_INT_CST) 581203c4805SLuis R. Rodriguez sc->debug.stats.istats.cst++; 582203c4805SLuis R. Rodriguez if (status & ATH9K_INT_GTT) 583203c4805SLuis R. Rodriguez sc->debug.stats.istats.gtt++; 584203c4805SLuis R. Rodriguez if (status & ATH9K_INT_TIM) 585203c4805SLuis R. Rodriguez sc->debug.stats.istats.tim++; 586203c4805SLuis R. Rodriguez if (status & ATH9K_INT_CABEND) 587203c4805SLuis R. Rodriguez sc->debug.stats.istats.cabend++; 588203c4805SLuis R. Rodriguez if (status & ATH9K_INT_DTIMSYNC) 589203c4805SLuis R. Rodriguez sc->debug.stats.istats.dtimsync++; 590203c4805SLuis R. Rodriguez if (status & ATH9K_INT_DTIM) 591203c4805SLuis R. Rodriguez sc->debug.stats.istats.dtim++; 5926dde1aabSMohammed Shafi Shajakhan if (status & ATH9K_INT_TSFOOR) 5936dde1aabSMohammed Shafi Shajakhan sc->debug.stats.istats.tsfoor++; 59497ba515aSSujith Manoharan if (status & ATH9K_INT_MCI) 59597ba515aSSujith Manoharan sc->debug.stats.istats.mci++; 596c9e6e980SMohammed Shafi Shajakhan if (status & ATH9K_INT_GENTIMER) 597c9e6e980SMohammed Shafi Shajakhan sc->debug.stats.istats.gen_timer++; 598203c4805SLuis R. Rodriguez } 599203c4805SLuis R. Rodriguez 600203c4805SLuis R. Rodriguez static ssize_t read_file_interrupt(struct file *file, char __user *user_buf, 601203c4805SLuis R. Rodriguez size_t count, loff_t *ppos) 602203c4805SLuis R. Rodriguez { 603203c4805SLuis R. Rodriguez struct ath_softc *sc = file->private_data; 604203c4805SLuis R. Rodriguez unsigned int len = 0; 605462e58f2SBen Greear int rv; 606462e58f2SBen Greear int mxlen = 4000; 607462e58f2SBen Greear char *buf = kmalloc(mxlen, GFP_KERNEL); 608462e58f2SBen Greear if (!buf) 609462e58f2SBen Greear return -ENOMEM; 610462e58f2SBen Greear 611462e58f2SBen Greear #define PR_IS(a, s) \ 612462e58f2SBen Greear do { \ 613462e58f2SBen Greear len += snprintf(buf + len, mxlen - len, \ 614462e58f2SBen Greear "%21s: %10u\n", a, \ 615462e58f2SBen Greear sc->debug.stats.istats.s); \ 616462e58f2SBen Greear } while (0) 617203c4805SLuis R. Rodriguez 618a9616f41SLuis R. Rodriguez if (sc->sc_ah->caps.hw_caps & ATH9K_HW_CAP_EDMA) { 619462e58f2SBen Greear PR_IS("RXLP", rxlp); 620462e58f2SBen Greear PR_IS("RXHP", rxhp); 621462e58f2SBen Greear PR_IS("WATHDOG", bb_watchdog); 622a9616f41SLuis R. Rodriguez } else { 623462e58f2SBen Greear PR_IS("RX", rxok); 624a9616f41SLuis R. Rodriguez } 625462e58f2SBen Greear PR_IS("RXEOL", rxeol); 626462e58f2SBen Greear PR_IS("RXORN", rxorn); 627462e58f2SBen Greear PR_IS("TX", txok); 628462e58f2SBen Greear PR_IS("TXURN", txurn); 629462e58f2SBen Greear PR_IS("MIB", mib); 630462e58f2SBen Greear PR_IS("RXPHY", rxphyerr); 631462e58f2SBen Greear PR_IS("RXKCM", rx_keycache_miss); 632462e58f2SBen Greear PR_IS("SWBA", swba); 633462e58f2SBen Greear PR_IS("BMISS", bmiss); 634462e58f2SBen Greear PR_IS("BNR", bnr); 635462e58f2SBen Greear PR_IS("CST", cst); 636462e58f2SBen Greear PR_IS("GTT", gtt); 637462e58f2SBen Greear PR_IS("TIM", tim); 638462e58f2SBen Greear PR_IS("CABEND", cabend); 639462e58f2SBen Greear PR_IS("DTIMSYNC", dtimsync); 640462e58f2SBen Greear PR_IS("DTIM", dtim); 641462e58f2SBen Greear PR_IS("TSFOOR", tsfoor); 64297ba515aSSujith Manoharan PR_IS("MCI", mci); 643c9e6e980SMohammed Shafi Shajakhan PR_IS("GENTIMER", gen_timer); 644462e58f2SBen Greear PR_IS("TOTAL", total); 645203c4805SLuis R. Rodriguez 646462e58f2SBen Greear len += snprintf(buf + len, mxlen - len, 647462e58f2SBen Greear "SYNC_CAUSE stats:\n"); 6486dde1aabSMohammed Shafi Shajakhan 649462e58f2SBen Greear PR_IS("Sync-All", sync_cause_all); 650462e58f2SBen Greear PR_IS("RTC-IRQ", sync_rtc_irq); 651462e58f2SBen Greear PR_IS("MAC-IRQ", sync_mac_irq); 652462e58f2SBen Greear PR_IS("EEPROM-Illegal-Access", eeprom_illegal_access); 653462e58f2SBen Greear PR_IS("APB-Timeout", apb_timeout); 654462e58f2SBen Greear PR_IS("PCI-Mode-Conflict", pci_mode_conflict); 655462e58f2SBen Greear PR_IS("HOST1-Fatal", host1_fatal); 656462e58f2SBen Greear PR_IS("HOST1-Perr", host1_perr); 657462e58f2SBen Greear PR_IS("TRCV-FIFO-Perr", trcv_fifo_perr); 658462e58f2SBen Greear PR_IS("RADM-CPL-EP", radm_cpl_ep); 659462e58f2SBen Greear PR_IS("RADM-CPL-DLLP-Abort", radm_cpl_dllp_abort); 660462e58f2SBen Greear PR_IS("RADM-CPL-TLP-Abort", radm_cpl_tlp_abort); 661462e58f2SBen Greear PR_IS("RADM-CPL-ECRC-Err", radm_cpl_ecrc_err); 662462e58f2SBen Greear PR_IS("RADM-CPL-Timeout", radm_cpl_timeout); 663462e58f2SBen Greear PR_IS("Local-Bus-Timeout", local_timeout); 664462e58f2SBen Greear PR_IS("PM-Access", pm_access); 665462e58f2SBen Greear PR_IS("MAC-Awake", mac_awake); 666462e58f2SBen Greear PR_IS("MAC-Asleep", mac_asleep); 667462e58f2SBen Greear PR_IS("MAC-Sleep-Access", mac_sleep_access); 6682b87f3aaSDan Carpenter 669462e58f2SBen Greear if (len > mxlen) 670462e58f2SBen Greear len = mxlen; 671462e58f2SBen Greear 672462e58f2SBen Greear rv = simple_read_from_buffer(user_buf, count, ppos, buf, len); 673462e58f2SBen Greear kfree(buf); 674462e58f2SBen Greear return rv; 675203c4805SLuis R. Rodriguez } 676203c4805SLuis R. Rodriguez 677203c4805SLuis R. Rodriguez static const struct file_operations fops_interrupt = { 678203c4805SLuis R. Rodriguez .read = read_file_interrupt, 679234e3405SStephen Boyd .open = simple_open, 6806038f373SArnd Bergmann .owner = THIS_MODULE, 6816038f373SArnd Bergmann .llseek = default_llseek, 682203c4805SLuis R. Rodriguez }; 683203c4805SLuis R. Rodriguez 684fec247c0SSujith static ssize_t read_file_xmit(struct file *file, char __user *user_buf, 685fec247c0SSujith size_t count, loff_t *ppos) 686fec247c0SSujith { 687fec247c0SSujith struct ath_softc *sc = file->private_data; 688fec247c0SSujith char *buf; 68978ef731cSSujith Manoharan unsigned int len = 0, size = 2048; 690fec247c0SSujith ssize_t retval = 0; 691fec247c0SSujith 692fec247c0SSujith buf = kzalloc(size, GFP_KERNEL); 693fec247c0SSujith if (buf == NULL) 69404236066SDan Carpenter return -ENOMEM; 695fec247c0SSujith 69678ef731cSSujith Manoharan len += sprintf(buf, "%30s %10s%10s%10s\n\n", 6977f010c93SBen Greear "BE", "BK", "VI", "VO"); 698fec247c0SSujith 699fec247c0SSujith PR("MPDUs Queued: ", queued); 700fec247c0SSujith PR("MPDUs Completed: ", completed); 7015a6f78afSFelix Fietkau PR("MPDUs XRetried: ", xretries); 702fec247c0SSujith PR("Aggregates: ", a_aggr); 703bda8addaSBen Greear PR("AMPDUs Queued HW:", a_queued_hw); 704bda8addaSBen Greear PR("AMPDUs Queued SW:", a_queued_sw); 705fec247c0SSujith PR("AMPDUs Completed:", a_completed); 706fec247c0SSujith PR("AMPDUs Retried: ", a_retries); 707fec247c0SSujith PR("AMPDUs XRetried: ", a_xretries); 7084d900389SBen Greear PR("TXERR Filtered: ", txerr_filtered); 709fec247c0SSujith PR("FIFO Underrun: ", fifo_underrun); 710fec247c0SSujith PR("TXOP Exceeded: ", xtxop); 711fec247c0SSujith PR("TXTIMER Expiry: ", timer_exp); 712fec247c0SSujith PR("DESC CFG Error: ", desc_cfg_err); 713fec247c0SSujith PR("DATA Underrun: ", data_underrun); 714fec247c0SSujith PR("DELIM Underrun: ", delim_underrun); 71599c15bf5SBen Greear PR("TX-Pkts-All: ", tx_pkts_all); 71699c15bf5SBen Greear PR("TX-Bytes-All: ", tx_bytes_all); 71778ef731cSSujith Manoharan PR("HW-put-tx-buf: ", puttxbuf); 71878ef731cSSujith Manoharan PR("HW-tx-start: ", txstart); 71978ef731cSSujith Manoharan PR("HW-tx-proc-desc: ", txprocdesc); 720a5a0bca1SBen Greear PR("TX-Failed: ", txfailed); 721fec247c0SSujith 7227f010c93SBen Greear if (len > size) 7237f010c93SBen Greear len = size; 7247f010c93SBen Greear 7257f010c93SBen Greear retval = simple_read_from_buffer(user_buf, count, ppos, buf, len); 7267f010c93SBen Greear kfree(buf); 7277f010c93SBen Greear 7287f010c93SBen Greear return retval; 7297f010c93SBen Greear } 7307f010c93SBen Greear 731c0b74876SSujith Manoharan static ssize_t read_file_queues(struct file *file, char __user *user_buf, 732c0b74876SSujith Manoharan size_t count, loff_t *ppos) 733c0b74876SSujith Manoharan { 734c0b74876SSujith Manoharan struct ath_softc *sc = file->private_data; 735c0b74876SSujith Manoharan struct ath_txq *txq; 736c0b74876SSujith Manoharan char *buf; 737c0b74876SSujith Manoharan unsigned int len = 0, size = 1024; 738c0b74876SSujith Manoharan ssize_t retval = 0; 739c0b74876SSujith Manoharan int i; 740c0b74876SSujith Manoharan char *qname[4] = {"VO", "VI", "BE", "BK"}; 741c0b74876SSujith Manoharan 742c0b74876SSujith Manoharan buf = kzalloc(size, GFP_KERNEL); 743c0b74876SSujith Manoharan if (buf == NULL) 744c0b74876SSujith Manoharan return -ENOMEM; 745c0b74876SSujith Manoharan 746c0b74876SSujith Manoharan for (i = 0; i < IEEE80211_NUM_ACS; i++) { 747c0b74876SSujith Manoharan txq = sc->tx.txq_map[i]; 748c0b74876SSujith Manoharan len += snprintf(buf + len, size - len, "(%s): ", qname[i]); 749c0b74876SSujith Manoharan 750c0b74876SSujith Manoharan ath_txq_lock(sc, txq); 751c0b74876SSujith Manoharan 752c0b74876SSujith Manoharan len += snprintf(buf + len, size - len, "%s: %d ", 753c0b74876SSujith Manoharan "qnum", txq->axq_qnum); 754c0b74876SSujith Manoharan len += snprintf(buf + len, size - len, "%s: %2d ", 755c0b74876SSujith Manoharan "qdepth", txq->axq_depth); 756c0b74876SSujith Manoharan len += snprintf(buf + len, size - len, "%s: %2d ", 757c0b74876SSujith Manoharan "ampdu-depth", txq->axq_ampdu_depth); 758c0b74876SSujith Manoharan len += snprintf(buf + len, size - len, "%s: %3d ", 759c0b74876SSujith Manoharan "pending", txq->pending_frames); 760c0b74876SSujith Manoharan len += snprintf(buf + len, size - len, "%s: %d\n", 761c0b74876SSujith Manoharan "stopped", txq->stopped); 762c0b74876SSujith Manoharan 763c0b74876SSujith Manoharan ath_txq_unlock(sc, txq); 764c0b74876SSujith Manoharan } 765c0b74876SSujith Manoharan 766c0b74876SSujith Manoharan if (len > size) 767c0b74876SSujith Manoharan len = size; 768c0b74876SSujith Manoharan 769c0b74876SSujith Manoharan retval = simple_read_from_buffer(user_buf, count, ppos, buf, len); 770c0b74876SSujith Manoharan kfree(buf); 771c0b74876SSujith Manoharan 772c0b74876SSujith Manoharan return retval; 773c0b74876SSujith Manoharan } 774c0b74876SSujith Manoharan 77555f6d0ffSBen Greear static ssize_t read_file_misc(struct file *file, char __user *user_buf, 77655f6d0ffSBen Greear size_t count, loff_t *ppos) 77755f6d0ffSBen Greear { 77855f6d0ffSBen Greear struct ath_softc *sc = file->private_data; 77955f6d0ffSBen Greear struct ath_common *common = ath9k_hw_common(sc->sc_ah); 78055f6d0ffSBen Greear struct ieee80211_hw *hw = sc->hw; 7816bcf6f64SSujith Manoharan struct ath9k_vif_iter_data iter_data; 7826bcf6f64SSujith Manoharan char buf[512]; 7836bcf6f64SSujith Manoharan unsigned int len = 0; 78455f6d0ffSBen Greear ssize_t retval = 0; 78555f6d0ffSBen Greear unsigned int reg; 7866bcf6f64SSujith Manoharan u32 rxfilter; 7876bcf6f64SSujith Manoharan 7886bcf6f64SSujith Manoharan len += snprintf(buf + len, sizeof(buf) - len, 7896bcf6f64SSujith Manoharan "BSSID: %pM\n", common->curbssid); 7906bcf6f64SSujith Manoharan len += snprintf(buf + len, sizeof(buf) - len, 7916bcf6f64SSujith Manoharan "BSSID-MASK: %pM\n", common->bssidmask); 7926bcf6f64SSujith Manoharan len += snprintf(buf + len, sizeof(buf) - len, 7936bcf6f64SSujith Manoharan "OPMODE: %s\n", ath_opmode_to_string(sc->sc_ah->opmode)); 7946bcf6f64SSujith Manoharan 7956bcf6f64SSujith Manoharan ath9k_ps_wakeup(sc); 7966bcf6f64SSujith Manoharan rxfilter = ath9k_hw_getrxfilter(sc->sc_ah); 7976bcf6f64SSujith Manoharan ath9k_ps_restore(sc); 7986bcf6f64SSujith Manoharan 7996bcf6f64SSujith Manoharan len += snprintf(buf + len, sizeof(buf) - len, 8006bcf6f64SSujith Manoharan "RXFILTER: 0x%x", rxfilter); 8016bcf6f64SSujith Manoharan 8026bcf6f64SSujith Manoharan if (rxfilter & ATH9K_RX_FILTER_UCAST) 8036bcf6f64SSujith Manoharan len += snprintf(buf + len, sizeof(buf) - len, " UCAST"); 8046bcf6f64SSujith Manoharan if (rxfilter & ATH9K_RX_FILTER_MCAST) 8056bcf6f64SSujith Manoharan len += snprintf(buf + len, sizeof(buf) - len, " MCAST"); 8066bcf6f64SSujith Manoharan if (rxfilter & ATH9K_RX_FILTER_BCAST) 8076bcf6f64SSujith Manoharan len += snprintf(buf + len, sizeof(buf) - len, " BCAST"); 8086bcf6f64SSujith Manoharan if (rxfilter & ATH9K_RX_FILTER_CONTROL) 8096bcf6f64SSujith Manoharan len += snprintf(buf + len, sizeof(buf) - len, " CONTROL"); 8106bcf6f64SSujith Manoharan if (rxfilter & ATH9K_RX_FILTER_BEACON) 8116bcf6f64SSujith Manoharan len += snprintf(buf + len, sizeof(buf) - len, " BEACON"); 8126bcf6f64SSujith Manoharan if (rxfilter & ATH9K_RX_FILTER_PROM) 8136bcf6f64SSujith Manoharan len += snprintf(buf + len, sizeof(buf) - len, " PROM"); 8146bcf6f64SSujith Manoharan if (rxfilter & ATH9K_RX_FILTER_PROBEREQ) 8156bcf6f64SSujith Manoharan len += snprintf(buf + len, sizeof(buf) - len, " PROBEREQ"); 8166bcf6f64SSujith Manoharan if (rxfilter & ATH9K_RX_FILTER_PHYERR) 8176bcf6f64SSujith Manoharan len += snprintf(buf + len, sizeof(buf) - len, " PHYERR"); 8186bcf6f64SSujith Manoharan if (rxfilter & ATH9K_RX_FILTER_MYBEACON) 8196bcf6f64SSujith Manoharan len += snprintf(buf + len, sizeof(buf) - len, " MYBEACON"); 8206bcf6f64SSujith Manoharan if (rxfilter & ATH9K_RX_FILTER_COMP_BAR) 8216bcf6f64SSujith Manoharan len += snprintf(buf + len, sizeof(buf) - len, " COMP_BAR"); 8226bcf6f64SSujith Manoharan if (rxfilter & ATH9K_RX_FILTER_PSPOLL) 8236bcf6f64SSujith Manoharan len += snprintf(buf + len, sizeof(buf) - len, " PSPOLL"); 8246bcf6f64SSujith Manoharan if (rxfilter & ATH9K_RX_FILTER_PHYRADAR) 8256bcf6f64SSujith Manoharan len += snprintf(buf + len, sizeof(buf) - len, " PHYRADAR"); 8266bcf6f64SSujith Manoharan if (rxfilter & ATH9K_RX_FILTER_MCAST_BCAST_ALL) 8276bcf6f64SSujith Manoharan len += snprintf(buf + len, sizeof(buf) - len, " MCAST_BCAST_ALL"); 8286bcf6f64SSujith Manoharan if (rxfilter & ATH9K_RX_FILTER_CONTROL_WRAPPER) 8296bcf6f64SSujith Manoharan len += snprintf(buf + len, sizeof(buf) - len, " CONTROL_WRAPPER"); 8306bcf6f64SSujith Manoharan 8316bcf6f64SSujith Manoharan len += snprintf(buf + len, sizeof(buf) - len, "\n"); 8326bcf6f64SSujith Manoharan 8336bcf6f64SSujith Manoharan reg = sc->sc_ah->imask; 8346bcf6f64SSujith Manoharan 8356bcf6f64SSujith Manoharan len += snprintf(buf + len, sizeof(buf) - len, "INTERRUPT-MASK: 0x%x", reg); 8366bcf6f64SSujith Manoharan 8376bcf6f64SSujith Manoharan if (reg & ATH9K_INT_SWBA) 8386bcf6f64SSujith Manoharan len += snprintf(buf + len, sizeof(buf) - len, " SWBA"); 8396bcf6f64SSujith Manoharan if (reg & ATH9K_INT_BMISS) 8406bcf6f64SSujith Manoharan len += snprintf(buf + len, sizeof(buf) - len, " BMISS"); 8416bcf6f64SSujith Manoharan if (reg & ATH9K_INT_CST) 8426bcf6f64SSujith Manoharan len += snprintf(buf + len, sizeof(buf) - len, " CST"); 8436bcf6f64SSujith Manoharan if (reg & ATH9K_INT_RX) 8446bcf6f64SSujith Manoharan len += snprintf(buf + len, sizeof(buf) - len, " RX"); 8456bcf6f64SSujith Manoharan if (reg & ATH9K_INT_RXHP) 8466bcf6f64SSujith Manoharan len += snprintf(buf + len, sizeof(buf) - len, " RXHP"); 8476bcf6f64SSujith Manoharan if (reg & ATH9K_INT_RXLP) 8486bcf6f64SSujith Manoharan len += snprintf(buf + len, sizeof(buf) - len, " RXLP"); 8496bcf6f64SSujith Manoharan if (reg & ATH9K_INT_BB_WATCHDOG) 8506bcf6f64SSujith Manoharan len += snprintf(buf + len, sizeof(buf) - len, " BB_WATCHDOG"); 8516bcf6f64SSujith Manoharan 8526bcf6f64SSujith Manoharan len += snprintf(buf + len, sizeof(buf) - len, "\n"); 85355f6d0ffSBen Greear 85455f6d0ffSBen Greear ath9k_calculate_iter_data(hw, NULL, &iter_data); 85555f6d0ffSBen Greear 8566bcf6f64SSujith Manoharan len += snprintf(buf + len, sizeof(buf) - len, 8576bcf6f64SSujith Manoharan "VIF-COUNTS: AP: %i STA: %i MESH: %i WDS: %i" 858bcf6f96eSSujith Manoharan " ADHOC: %i TOTAL: %hi BEACON-VIF: %hi\n", 85955f6d0ffSBen Greear iter_data.naps, iter_data.nstations, iter_data.nmeshes, 860bcf6f96eSSujith Manoharan iter_data.nwds, iter_data.nadhocs, 86155f6d0ffSBen Greear sc->nvifs, sc->nbcnvifs); 86255f6d0ffSBen Greear 8636bcf6f64SSujith Manoharan if (len > sizeof(buf)) 8646bcf6f64SSujith Manoharan len = sizeof(buf); 86555f6d0ffSBen Greear 86655f6d0ffSBen Greear retval = simple_read_from_buffer(user_buf, count, ppos, buf, len); 86755f6d0ffSBen Greear return retval; 86855f6d0ffSBen Greear } 86955f6d0ffSBen Greear 870f8b815dcSSujith Manoharan static ssize_t read_file_reset(struct file *file, char __user *user_buf, 871f8b815dcSSujith Manoharan size_t count, loff_t *ppos) 872f8b815dcSSujith Manoharan { 873f8b815dcSSujith Manoharan struct ath_softc *sc = file->private_data; 874f8b815dcSSujith Manoharan char buf[512]; 875f8b815dcSSujith Manoharan unsigned int len = 0; 876f8b815dcSSujith Manoharan 877f8b815dcSSujith Manoharan len += snprintf(buf + len, sizeof(buf) - len, 878f8b815dcSSujith Manoharan "%17s: %2d\n", "Baseband Hang", 879f8b815dcSSujith Manoharan sc->debug.stats.reset[RESET_TYPE_BB_HANG]); 880f8b815dcSSujith Manoharan len += snprintf(buf + len, sizeof(buf) - len, 881f8b815dcSSujith Manoharan "%17s: %2d\n", "Baseband Watchdog", 882f8b815dcSSujith Manoharan sc->debug.stats.reset[RESET_TYPE_BB_WATCHDOG]); 883f8b815dcSSujith Manoharan len += snprintf(buf + len, sizeof(buf) - len, 884f8b815dcSSujith Manoharan "%17s: %2d\n", "Fatal HW Error", 885f8b815dcSSujith Manoharan sc->debug.stats.reset[RESET_TYPE_FATAL_INT]); 886f8b815dcSSujith Manoharan len += snprintf(buf + len, sizeof(buf) - len, 887f8b815dcSSujith Manoharan "%17s: %2d\n", "TX HW error", 888f8b815dcSSujith Manoharan sc->debug.stats.reset[RESET_TYPE_TX_ERROR]); 889f8b815dcSSujith Manoharan len += snprintf(buf + len, sizeof(buf) - len, 890f8b815dcSSujith Manoharan "%17s: %2d\n", "TX Path Hang", 891f8b815dcSSujith Manoharan sc->debug.stats.reset[RESET_TYPE_TX_HANG]); 892f8b815dcSSujith Manoharan len += snprintf(buf + len, sizeof(buf) - len, 893f8b815dcSSujith Manoharan "%17s: %2d\n", "PLL RX Hang", 894f8b815dcSSujith Manoharan sc->debug.stats.reset[RESET_TYPE_PLL_HANG]); 895b88083bfSRajkumar Manoharan len += snprintf(buf + len, sizeof(buf) - len, 896b88083bfSRajkumar Manoharan "%17s: %2d\n", "MCI Reset", 897b88083bfSRajkumar Manoharan sc->debug.stats.reset[RESET_TYPE_MCI]); 898f8b815dcSSujith Manoharan 899f8b815dcSSujith Manoharan if (len > sizeof(buf)) 900f8b815dcSSujith Manoharan len = sizeof(buf); 901f8b815dcSSujith Manoharan 902f8b815dcSSujith Manoharan return simple_read_from_buffer(user_buf, count, ppos, buf, len); 903f8b815dcSSujith Manoharan } 904f8b815dcSSujith Manoharan 905066dae93SFelix Fietkau void ath_debug_stat_tx(struct ath_softc *sc, struct ath_buf *bf, 90655797b1aSFelix Fietkau struct ath_tx_status *ts, struct ath_txq *txq, 90755797b1aSFelix Fietkau unsigned int flags) 908fec247c0SSujith { 9095bec3e5aSFelix Fietkau int qnum = txq->axq_qnum; 910066dae93SFelix Fietkau 911066dae93SFelix Fietkau TX_STAT_INC(qnum, tx_pkts_all); 912066dae93SFelix Fietkau sc->debug.stats.txstats[qnum].tx_bytes_all += bf->bf_mpdu->len; 91399c15bf5SBen Greear 914fec247c0SSujith if (bf_isampdu(bf)) { 915156369faSFelix Fietkau if (flags & ATH_TX_ERROR) 916066dae93SFelix Fietkau TX_STAT_INC(qnum, a_xretries); 917fec247c0SSujith else 918066dae93SFelix Fietkau TX_STAT_INC(qnum, a_completed); 919fec247c0SSujith } else { 92055797b1aSFelix Fietkau if (ts->ts_status & ATH9K_TXERR_XRETRY) 9215a6f78afSFelix Fietkau TX_STAT_INC(qnum, xretries); 9225a6f78afSFelix Fietkau else 923066dae93SFelix Fietkau TX_STAT_INC(qnum, completed); 924fec247c0SSujith } 925fec247c0SSujith 9264d900389SBen Greear if (ts->ts_status & ATH9K_TXERR_FILT) 9274d900389SBen Greear TX_STAT_INC(qnum, txerr_filtered); 928db1a052bSFelix Fietkau if (ts->ts_status & ATH9K_TXERR_FIFO) 929066dae93SFelix Fietkau TX_STAT_INC(qnum, fifo_underrun); 930db1a052bSFelix Fietkau if (ts->ts_status & ATH9K_TXERR_XTXOP) 931066dae93SFelix Fietkau TX_STAT_INC(qnum, xtxop); 932db1a052bSFelix Fietkau if (ts->ts_status & ATH9K_TXERR_TIMER_EXPIRED) 933066dae93SFelix Fietkau TX_STAT_INC(qnum, timer_exp); 934db1a052bSFelix Fietkau if (ts->ts_flags & ATH9K_TX_DESC_CFG_ERR) 935066dae93SFelix Fietkau TX_STAT_INC(qnum, desc_cfg_err); 936db1a052bSFelix Fietkau if (ts->ts_flags & ATH9K_TX_DATA_UNDERRUN) 937066dae93SFelix Fietkau TX_STAT_INC(qnum, data_underrun); 938db1a052bSFelix Fietkau if (ts->ts_flags & ATH9K_TX_DELIM_UNDERRUN) 939066dae93SFelix Fietkau TX_STAT_INC(qnum, delim_underrun); 940fec247c0SSujith } 941fec247c0SSujith 942fec247c0SSujith static const struct file_operations fops_xmit = { 943fec247c0SSujith .read = read_file_xmit, 944234e3405SStephen Boyd .open = simple_open, 9456038f373SArnd Bergmann .owner = THIS_MODULE, 9466038f373SArnd Bergmann .llseek = default_llseek, 947fec247c0SSujith }; 948203c4805SLuis R. Rodriguez 949c0b74876SSujith Manoharan static const struct file_operations fops_queues = { 950c0b74876SSujith Manoharan .read = read_file_queues, 951c0b74876SSujith Manoharan .open = simple_open, 952c0b74876SSujith Manoharan .owner = THIS_MODULE, 953c0b74876SSujith Manoharan .llseek = default_llseek, 954c0b74876SSujith Manoharan }; 955c0b74876SSujith Manoharan 95655f6d0ffSBen Greear static const struct file_operations fops_misc = { 95755f6d0ffSBen Greear .read = read_file_misc, 958234e3405SStephen Boyd .open = simple_open, 95955f6d0ffSBen Greear .owner = THIS_MODULE, 96055f6d0ffSBen Greear .llseek = default_llseek, 96155f6d0ffSBen Greear }; 96255f6d0ffSBen Greear 963f8b815dcSSujith Manoharan static const struct file_operations fops_reset = { 964f8b815dcSSujith Manoharan .read = read_file_reset, 965234e3405SStephen Boyd .open = simple_open, 966f8b815dcSSujith Manoharan .owner = THIS_MODULE, 967f8b815dcSSujith Manoharan .llseek = default_llseek, 968f8b815dcSSujith Manoharan }; 969f8b815dcSSujith Manoharan 9701395d3f0SSujith static ssize_t read_file_recv(struct file *file, char __user *user_buf, 9711395d3f0SSujith size_t count, loff_t *ppos) 9721395d3f0SSujith { 9731395d3f0SSujith #define PHY_ERR(s, p) \ 9744203214eSSujith Manoharan len += snprintf(buf + len, size - len, "%22s : %10u\n", s, \ 9751395d3f0SSujith sc->debug.stats.rxstats.phy_err_stats[p]); 9761395d3f0SSujith 97724a0731eSBen Greear #define RXS_ERR(s, e) \ 97824a0731eSBen Greear do { \ 97924a0731eSBen Greear len += snprintf(buf + len, size - len, \ 98024a0731eSBen Greear "%22s : %10u\n", s, \ 98124a0731eSBen Greear sc->debug.stats.rxstats.e); \ 98224a0731eSBen Greear } while (0) 98324a0731eSBen Greear 9841395d3f0SSujith struct ath_softc *sc = file->private_data; 9851395d3f0SSujith char *buf; 9864203214eSSujith Manoharan unsigned int len = 0, size = 1600; 9871395d3f0SSujith ssize_t retval = 0; 9881395d3f0SSujith 9891395d3f0SSujith buf = kzalloc(size, GFP_KERNEL); 9901395d3f0SSujith if (buf == NULL) 99104236066SDan Carpenter return -ENOMEM; 9921395d3f0SSujith 99324a0731eSBen Greear RXS_ERR("CRC ERR", crc_err); 99424a0731eSBen Greear RXS_ERR("DECRYPT CRC ERR", decrypt_crc_err); 99524a0731eSBen Greear RXS_ERR("PHY ERR", phy_err); 99624a0731eSBen Greear RXS_ERR("MIC ERR", mic_err); 99724a0731eSBen Greear RXS_ERR("PRE-DELIM CRC ERR", pre_delim_crc_err); 99824a0731eSBen Greear RXS_ERR("POST-DELIM CRC ERR", post_delim_crc_err); 99924a0731eSBen Greear RXS_ERR("DECRYPT BUSY ERR", decrypt_busy_err); 100024a0731eSBen Greear RXS_ERR("RX-LENGTH-ERR", rx_len_err); 100124a0731eSBen Greear RXS_ERR("RX-OOM-ERR", rx_oom_err); 100224a0731eSBen Greear RXS_ERR("RX-RATE-ERR", rx_rate_err); 100324a0731eSBen Greear RXS_ERR("RX-TOO-MANY-FRAGS", rx_too_many_frags_err); 10041395d3f0SSujith 10054203214eSSujith Manoharan PHY_ERR("UNDERRUN ERR", ATH9K_PHYERR_UNDERRUN); 10064203214eSSujith Manoharan PHY_ERR("TIMING ERR", ATH9K_PHYERR_TIMING); 10074203214eSSujith Manoharan PHY_ERR("PARITY ERR", ATH9K_PHYERR_PARITY); 10084203214eSSujith Manoharan PHY_ERR("RATE ERR", ATH9K_PHYERR_RATE); 10094203214eSSujith Manoharan PHY_ERR("LENGTH ERR", ATH9K_PHYERR_LENGTH); 10104203214eSSujith Manoharan PHY_ERR("RADAR ERR", ATH9K_PHYERR_RADAR); 10114203214eSSujith Manoharan PHY_ERR("SERVICE ERR", ATH9K_PHYERR_SERVICE); 10124203214eSSujith Manoharan PHY_ERR("TOR ERR", ATH9K_PHYERR_TOR); 10134203214eSSujith Manoharan PHY_ERR("OFDM-TIMING ERR", ATH9K_PHYERR_OFDM_TIMING); 10144203214eSSujith Manoharan PHY_ERR("OFDM-SIGNAL-PARITY ERR", ATH9K_PHYERR_OFDM_SIGNAL_PARITY); 10154203214eSSujith Manoharan PHY_ERR("OFDM-RATE ERR", ATH9K_PHYERR_OFDM_RATE_ILLEGAL); 10164203214eSSujith Manoharan PHY_ERR("OFDM-LENGTH ERR", ATH9K_PHYERR_OFDM_LENGTH_ILLEGAL); 10174203214eSSujith Manoharan PHY_ERR("OFDM-POWER-DROP ERR", ATH9K_PHYERR_OFDM_POWER_DROP); 10184203214eSSujith Manoharan PHY_ERR("OFDM-SERVICE ERR", ATH9K_PHYERR_OFDM_SERVICE); 10194203214eSSujith Manoharan PHY_ERR("OFDM-RESTART ERR", ATH9K_PHYERR_OFDM_RESTART); 10204203214eSSujith Manoharan PHY_ERR("FALSE-RADAR-EXT ERR", ATH9K_PHYERR_FALSE_RADAR_EXT); 10214203214eSSujith Manoharan PHY_ERR("CCK-TIMING ERR", ATH9K_PHYERR_CCK_TIMING); 10224203214eSSujith Manoharan PHY_ERR("CCK-HEADER-CRC ERR", ATH9K_PHYERR_CCK_HEADER_CRC); 10234203214eSSujith Manoharan PHY_ERR("CCK-RATE ERR", ATH9K_PHYERR_CCK_RATE_ILLEGAL); 10244203214eSSujith Manoharan PHY_ERR("CCK-SERVICE ERR", ATH9K_PHYERR_CCK_SERVICE); 10254203214eSSujith Manoharan PHY_ERR("CCK-RESTART ERR", ATH9K_PHYERR_CCK_RESTART); 10264203214eSSujith Manoharan PHY_ERR("CCK-LENGTH ERR", ATH9K_PHYERR_CCK_LENGTH_ILLEGAL); 10274203214eSSujith Manoharan PHY_ERR("CCK-POWER-DROP ERR", ATH9K_PHYERR_CCK_POWER_DROP); 10284203214eSSujith Manoharan PHY_ERR("HT-CRC ERR", ATH9K_PHYERR_HT_CRC_ERROR); 10294203214eSSujith Manoharan PHY_ERR("HT-LENGTH ERR", ATH9K_PHYERR_HT_LENGTH_ILLEGAL); 10304203214eSSujith Manoharan PHY_ERR("HT-RATE ERR", ATH9K_PHYERR_HT_RATE_ILLEGAL); 10314203214eSSujith Manoharan 103224a0731eSBen Greear RXS_ERR("RX-Pkts-All", rx_pkts_all); 103324a0731eSBen Greear RXS_ERR("RX-Bytes-All", rx_bytes_all); 103424a0731eSBen Greear RXS_ERR("RX-Beacons", rx_beacons); 103524a0731eSBen Greear RXS_ERR("RX-Frags", rx_frags); 10369b99e665SSimon Wunderlich RXS_ERR("RX-Spectral", rx_spectral); 103799c15bf5SBen Greear 10382b87f3aaSDan Carpenter if (len > size) 10392b87f3aaSDan Carpenter len = size; 10402b87f3aaSDan Carpenter 10411395d3f0SSujith retval = simple_read_from_buffer(user_buf, count, ppos, buf, len); 10421395d3f0SSujith kfree(buf); 10431395d3f0SSujith 10441395d3f0SSujith return retval; 10451395d3f0SSujith 104624a0731eSBen Greear #undef RXS_ERR 10471395d3f0SSujith #undef PHY_ERR 10481395d3f0SSujith } 10491395d3f0SSujith 10508e6f5aa2SFelix Fietkau void ath_debug_stat_rx(struct ath_softc *sc, struct ath_rx_status *rs) 10511395d3f0SSujith { 10521395d3f0SSujith #define RX_PHY_ERR_INC(c) sc->debug.stats.rxstats.phy_err_stats[c]++ 10531395d3f0SSujith 105499c15bf5SBen Greear RX_STAT_INC(rx_pkts_all); 105599c15bf5SBen Greear sc->debug.stats.rxstats.rx_bytes_all += rs->rs_datalen; 105699c15bf5SBen Greear 10578e6f5aa2SFelix Fietkau if (rs->rs_status & ATH9K_RXERR_CRC) 10581395d3f0SSujith RX_STAT_INC(crc_err); 10598e6f5aa2SFelix Fietkau if (rs->rs_status & ATH9K_RXERR_DECRYPT) 10601395d3f0SSujith RX_STAT_INC(decrypt_crc_err); 10618e6f5aa2SFelix Fietkau if (rs->rs_status & ATH9K_RXERR_MIC) 10621395d3f0SSujith RX_STAT_INC(mic_err); 10638e6f5aa2SFelix Fietkau if (rs->rs_status & ATH9K_RX_DELIM_CRC_PRE) 10641395d3f0SSujith RX_STAT_INC(pre_delim_crc_err); 10658e6f5aa2SFelix Fietkau if (rs->rs_status & ATH9K_RX_DELIM_CRC_POST) 10661395d3f0SSujith RX_STAT_INC(post_delim_crc_err); 10678e6f5aa2SFelix Fietkau if (rs->rs_status & ATH9K_RX_DECRYPT_BUSY) 10681395d3f0SSujith RX_STAT_INC(decrypt_busy_err); 10691395d3f0SSujith 10708e6f5aa2SFelix Fietkau if (rs->rs_status & ATH9K_RXERR_PHY) { 10711395d3f0SSujith RX_STAT_INC(phy_err); 1072dbb07f00SSujith Manoharan if (rs->rs_phyerr < ATH9K_PHYERR_MAX) 1073dbb07f00SSujith Manoharan RX_PHY_ERR_INC(rs->rs_phyerr); 10741395d3f0SSujith } 10751395d3f0SSujith 10761395d3f0SSujith #undef RX_PHY_ERR_INC 10771395d3f0SSujith } 10781395d3f0SSujith 10791395d3f0SSujith static const struct file_operations fops_recv = { 10801395d3f0SSujith .read = read_file_recv, 1081234e3405SStephen Boyd .open = simple_open, 10826038f373SArnd Bergmann .owner = THIS_MODULE, 10836038f373SArnd Bergmann .llseek = default_llseek, 10841395d3f0SSujith }; 10851395d3f0SSujith 1086e93d083fSSimon Wunderlich static ssize_t read_file_spec_scan_ctl(struct file *file, char __user *user_buf, 1087e93d083fSSimon Wunderlich size_t count, loff_t *ppos) 1088e93d083fSSimon Wunderlich { 1089e93d083fSSimon Wunderlich struct ath_softc *sc = file->private_data; 1090e93d083fSSimon Wunderlich char *mode = ""; 1091e93d083fSSimon Wunderlich unsigned int len; 1092e93d083fSSimon Wunderlich 1093e93d083fSSimon Wunderlich switch (sc->spectral_mode) { 1094e93d083fSSimon Wunderlich case SPECTRAL_DISABLED: 1095e93d083fSSimon Wunderlich mode = "disable"; 1096e93d083fSSimon Wunderlich break; 1097e93d083fSSimon Wunderlich case SPECTRAL_BACKGROUND: 1098e93d083fSSimon Wunderlich mode = "background"; 1099e93d083fSSimon Wunderlich break; 1100e93d083fSSimon Wunderlich case SPECTRAL_CHANSCAN: 1101e93d083fSSimon Wunderlich mode = "chanscan"; 1102e93d083fSSimon Wunderlich break; 1103e93d083fSSimon Wunderlich case SPECTRAL_MANUAL: 1104e93d083fSSimon Wunderlich mode = "manual"; 1105e93d083fSSimon Wunderlich break; 1106e93d083fSSimon Wunderlich } 1107e93d083fSSimon Wunderlich len = strlen(mode); 1108e93d083fSSimon Wunderlich return simple_read_from_buffer(user_buf, count, ppos, mode, len); 1109e93d083fSSimon Wunderlich } 1110e93d083fSSimon Wunderlich 1111e93d083fSSimon Wunderlich static ssize_t write_file_spec_scan_ctl(struct file *file, 1112e93d083fSSimon Wunderlich const char __user *user_buf, 1113e93d083fSSimon Wunderlich size_t count, loff_t *ppos) 1114e93d083fSSimon Wunderlich { 1115e93d083fSSimon Wunderlich struct ath_softc *sc = file->private_data; 1116e93d083fSSimon Wunderlich struct ath_common *common = ath9k_hw_common(sc->sc_ah); 1117e93d083fSSimon Wunderlich char buf[32]; 1118e93d083fSSimon Wunderlich ssize_t len; 1119e93d083fSSimon Wunderlich 1120e93d083fSSimon Wunderlich len = min(count, sizeof(buf) - 1); 1121e93d083fSSimon Wunderlich if (copy_from_user(buf, user_buf, len)) 1122e93d083fSSimon Wunderlich return -EFAULT; 1123e93d083fSSimon Wunderlich 1124e93d083fSSimon Wunderlich buf[len] = '\0'; 1125e93d083fSSimon Wunderlich 1126e93d083fSSimon Wunderlich if (strncmp("trigger", buf, 7) == 0) { 1127e93d083fSSimon Wunderlich ath9k_spectral_scan_trigger(sc->hw); 1128e93d083fSSimon Wunderlich } else if (strncmp("background", buf, 9) == 0) { 1129e93d083fSSimon Wunderlich ath9k_spectral_scan_config(sc->hw, SPECTRAL_BACKGROUND); 1130e93d083fSSimon Wunderlich ath_dbg(common, CONFIG, "spectral scan: background mode enabled\n"); 1131e93d083fSSimon Wunderlich } else if (strncmp("chanscan", buf, 8) == 0) { 1132e93d083fSSimon Wunderlich ath9k_spectral_scan_config(sc->hw, SPECTRAL_CHANSCAN); 1133e93d083fSSimon Wunderlich ath_dbg(common, CONFIG, "spectral scan: channel scan mode enabled\n"); 1134e93d083fSSimon Wunderlich } else if (strncmp("manual", buf, 6) == 0) { 1135e93d083fSSimon Wunderlich ath9k_spectral_scan_config(sc->hw, SPECTRAL_MANUAL); 1136e93d083fSSimon Wunderlich ath_dbg(common, CONFIG, "spectral scan: manual mode enabled\n"); 1137e93d083fSSimon Wunderlich } else if (strncmp("disable", buf, 7) == 0) { 1138e93d083fSSimon Wunderlich ath9k_spectral_scan_config(sc->hw, SPECTRAL_DISABLED); 1139e93d083fSSimon Wunderlich ath_dbg(common, CONFIG, "spectral scan: disabled\n"); 1140e93d083fSSimon Wunderlich } else { 1141e93d083fSSimon Wunderlich return -EINVAL; 1142e93d083fSSimon Wunderlich } 1143e93d083fSSimon Wunderlich 1144e93d083fSSimon Wunderlich return count; 1145e93d083fSSimon Wunderlich } 1146e93d083fSSimon Wunderlich 1147e93d083fSSimon Wunderlich static const struct file_operations fops_spec_scan_ctl = { 1148e93d083fSSimon Wunderlich .read = read_file_spec_scan_ctl, 1149e93d083fSSimon Wunderlich .write = write_file_spec_scan_ctl, 1150e93d083fSSimon Wunderlich .open = simple_open, 1151e93d083fSSimon Wunderlich .owner = THIS_MODULE, 1152e93d083fSSimon Wunderlich .llseek = default_llseek, 1153e93d083fSSimon Wunderlich }; 1154e93d083fSSimon Wunderlich 115504ccd4a1SSimon Wunderlich static ssize_t read_file_spectral_short_repeat(struct file *file, 115604ccd4a1SSimon Wunderlich char __user *user_buf, 115704ccd4a1SSimon Wunderlich size_t count, loff_t *ppos) 115804ccd4a1SSimon Wunderlich { 115904ccd4a1SSimon Wunderlich struct ath_softc *sc = file->private_data; 116004ccd4a1SSimon Wunderlich char buf[32]; 116104ccd4a1SSimon Wunderlich unsigned int len; 116204ccd4a1SSimon Wunderlich 116304ccd4a1SSimon Wunderlich len = sprintf(buf, "%d\n", sc->spec_config.short_repeat); 116404ccd4a1SSimon Wunderlich return simple_read_from_buffer(user_buf, count, ppos, buf, len); 116504ccd4a1SSimon Wunderlich } 116604ccd4a1SSimon Wunderlich 116704ccd4a1SSimon Wunderlich static ssize_t write_file_spectral_short_repeat(struct file *file, 116804ccd4a1SSimon Wunderlich const char __user *user_buf, 116904ccd4a1SSimon Wunderlich size_t count, loff_t *ppos) 117004ccd4a1SSimon Wunderlich { 117104ccd4a1SSimon Wunderlich struct ath_softc *sc = file->private_data; 117204ccd4a1SSimon Wunderlich unsigned long val; 117304ccd4a1SSimon Wunderlich char buf[32]; 117404ccd4a1SSimon Wunderlich ssize_t len; 117504ccd4a1SSimon Wunderlich 117604ccd4a1SSimon Wunderlich len = min(count, sizeof(buf) - 1); 117704ccd4a1SSimon Wunderlich if (copy_from_user(buf, user_buf, len)) 117804ccd4a1SSimon Wunderlich return -EFAULT; 117904ccd4a1SSimon Wunderlich 118004ccd4a1SSimon Wunderlich buf[len] = '\0'; 118104ccd4a1SSimon Wunderlich if (kstrtoul(buf, 0, &val)) 118204ccd4a1SSimon Wunderlich return -EINVAL; 118304ccd4a1SSimon Wunderlich 118404ccd4a1SSimon Wunderlich if (val < 0 || val > 1) 118504ccd4a1SSimon Wunderlich return -EINVAL; 118604ccd4a1SSimon Wunderlich 118704ccd4a1SSimon Wunderlich sc->spec_config.short_repeat = val; 118804ccd4a1SSimon Wunderlich return count; 118904ccd4a1SSimon Wunderlich } 119004ccd4a1SSimon Wunderlich 119104ccd4a1SSimon Wunderlich static const struct file_operations fops_spectral_short_repeat = { 119204ccd4a1SSimon Wunderlich .read = read_file_spectral_short_repeat, 119304ccd4a1SSimon Wunderlich .write = write_file_spectral_short_repeat, 119404ccd4a1SSimon Wunderlich .open = simple_open, 119504ccd4a1SSimon Wunderlich .owner = THIS_MODULE, 119604ccd4a1SSimon Wunderlich .llseek = default_llseek, 119704ccd4a1SSimon Wunderlich }; 119804ccd4a1SSimon Wunderlich 119904ccd4a1SSimon Wunderlich static ssize_t read_file_spectral_count(struct file *file, 120004ccd4a1SSimon Wunderlich char __user *user_buf, 120104ccd4a1SSimon Wunderlich size_t count, loff_t *ppos) 120204ccd4a1SSimon Wunderlich { 120304ccd4a1SSimon Wunderlich struct ath_softc *sc = file->private_data; 120404ccd4a1SSimon Wunderlich char buf[32]; 120504ccd4a1SSimon Wunderlich unsigned int len; 120604ccd4a1SSimon Wunderlich 120704ccd4a1SSimon Wunderlich len = sprintf(buf, "%d\n", sc->spec_config.count); 120804ccd4a1SSimon Wunderlich return simple_read_from_buffer(user_buf, count, ppos, buf, len); 120904ccd4a1SSimon Wunderlich } 121004ccd4a1SSimon Wunderlich 121104ccd4a1SSimon Wunderlich static ssize_t write_file_spectral_count(struct file *file, 121204ccd4a1SSimon Wunderlich const char __user *user_buf, 121304ccd4a1SSimon Wunderlich size_t count, loff_t *ppos) 121404ccd4a1SSimon Wunderlich { 121504ccd4a1SSimon Wunderlich struct ath_softc *sc = file->private_data; 121604ccd4a1SSimon Wunderlich unsigned long val; 121704ccd4a1SSimon Wunderlich char buf[32]; 121804ccd4a1SSimon Wunderlich ssize_t len; 121904ccd4a1SSimon Wunderlich 122004ccd4a1SSimon Wunderlich len = min(count, sizeof(buf) - 1); 122104ccd4a1SSimon Wunderlich if (copy_from_user(buf, user_buf, len)) 122204ccd4a1SSimon Wunderlich return -EFAULT; 122304ccd4a1SSimon Wunderlich 122404ccd4a1SSimon Wunderlich buf[len] = '\0'; 122504ccd4a1SSimon Wunderlich if (kstrtoul(buf, 0, &val)) 122604ccd4a1SSimon Wunderlich return -EINVAL; 122704ccd4a1SSimon Wunderlich 122804ccd4a1SSimon Wunderlich if (val < 0 || val > 255) 122904ccd4a1SSimon Wunderlich return -EINVAL; 123004ccd4a1SSimon Wunderlich 123104ccd4a1SSimon Wunderlich sc->spec_config.count = val; 123204ccd4a1SSimon Wunderlich return count; 123304ccd4a1SSimon Wunderlich } 123404ccd4a1SSimon Wunderlich 123504ccd4a1SSimon Wunderlich static const struct file_operations fops_spectral_count = { 123604ccd4a1SSimon Wunderlich .read = read_file_spectral_count, 123704ccd4a1SSimon Wunderlich .write = write_file_spectral_count, 123804ccd4a1SSimon Wunderlich .open = simple_open, 123904ccd4a1SSimon Wunderlich .owner = THIS_MODULE, 124004ccd4a1SSimon Wunderlich .llseek = default_llseek, 124104ccd4a1SSimon Wunderlich }; 124204ccd4a1SSimon Wunderlich 124304ccd4a1SSimon Wunderlich static ssize_t read_file_spectral_period(struct file *file, 124404ccd4a1SSimon Wunderlich char __user *user_buf, 124504ccd4a1SSimon Wunderlich size_t count, loff_t *ppos) 124604ccd4a1SSimon Wunderlich { 124704ccd4a1SSimon Wunderlich struct ath_softc *sc = file->private_data; 124804ccd4a1SSimon Wunderlich char buf[32]; 124904ccd4a1SSimon Wunderlich unsigned int len; 125004ccd4a1SSimon Wunderlich 125104ccd4a1SSimon Wunderlich len = sprintf(buf, "%d\n", sc->spec_config.period); 125204ccd4a1SSimon Wunderlich return simple_read_from_buffer(user_buf, count, ppos, buf, len); 125304ccd4a1SSimon Wunderlich } 125404ccd4a1SSimon Wunderlich 125504ccd4a1SSimon Wunderlich static ssize_t write_file_spectral_period(struct file *file, 125604ccd4a1SSimon Wunderlich const char __user *user_buf, 125704ccd4a1SSimon Wunderlich size_t count, loff_t *ppos) 125804ccd4a1SSimon Wunderlich { 125904ccd4a1SSimon Wunderlich struct ath_softc *sc = file->private_data; 126004ccd4a1SSimon Wunderlich unsigned long val; 126104ccd4a1SSimon Wunderlich char buf[32]; 126204ccd4a1SSimon Wunderlich ssize_t len; 126304ccd4a1SSimon Wunderlich 126404ccd4a1SSimon Wunderlich len = min(count, sizeof(buf) - 1); 126504ccd4a1SSimon Wunderlich if (copy_from_user(buf, user_buf, len)) 126604ccd4a1SSimon Wunderlich return -EFAULT; 126704ccd4a1SSimon Wunderlich 126804ccd4a1SSimon Wunderlich buf[len] = '\0'; 126904ccd4a1SSimon Wunderlich if (kstrtoul(buf, 0, &val)) 127004ccd4a1SSimon Wunderlich return -EINVAL; 127104ccd4a1SSimon Wunderlich 127204ccd4a1SSimon Wunderlich if (val < 0 || val > 255) 127304ccd4a1SSimon Wunderlich return -EINVAL; 127404ccd4a1SSimon Wunderlich 127504ccd4a1SSimon Wunderlich sc->spec_config.period = val; 127604ccd4a1SSimon Wunderlich return count; 127704ccd4a1SSimon Wunderlich } 127804ccd4a1SSimon Wunderlich 127904ccd4a1SSimon Wunderlich static const struct file_operations fops_spectral_period = { 128004ccd4a1SSimon Wunderlich .read = read_file_spectral_period, 128104ccd4a1SSimon Wunderlich .write = write_file_spectral_period, 128204ccd4a1SSimon Wunderlich .open = simple_open, 128304ccd4a1SSimon Wunderlich .owner = THIS_MODULE, 128404ccd4a1SSimon Wunderlich .llseek = default_llseek, 128504ccd4a1SSimon Wunderlich }; 128604ccd4a1SSimon Wunderlich 128704ccd4a1SSimon Wunderlich static ssize_t read_file_spectral_fft_period(struct file *file, 128804ccd4a1SSimon Wunderlich char __user *user_buf, 128904ccd4a1SSimon Wunderlich size_t count, loff_t *ppos) 129004ccd4a1SSimon Wunderlich { 129104ccd4a1SSimon Wunderlich struct ath_softc *sc = file->private_data; 129204ccd4a1SSimon Wunderlich char buf[32]; 129304ccd4a1SSimon Wunderlich unsigned int len; 129404ccd4a1SSimon Wunderlich 129504ccd4a1SSimon Wunderlich len = sprintf(buf, "%d\n", sc->spec_config.fft_period); 129604ccd4a1SSimon Wunderlich return simple_read_from_buffer(user_buf, count, ppos, buf, len); 129704ccd4a1SSimon Wunderlich } 129804ccd4a1SSimon Wunderlich 129904ccd4a1SSimon Wunderlich static ssize_t write_file_spectral_fft_period(struct file *file, 130004ccd4a1SSimon Wunderlich const char __user *user_buf, 130104ccd4a1SSimon Wunderlich size_t count, loff_t *ppos) 130204ccd4a1SSimon Wunderlich { 130304ccd4a1SSimon Wunderlich struct ath_softc *sc = file->private_data; 130404ccd4a1SSimon Wunderlich unsigned long val; 130504ccd4a1SSimon Wunderlich char buf[32]; 130604ccd4a1SSimon Wunderlich ssize_t len; 130704ccd4a1SSimon Wunderlich 130804ccd4a1SSimon Wunderlich len = min(count, sizeof(buf) - 1); 130904ccd4a1SSimon Wunderlich if (copy_from_user(buf, user_buf, len)) 131004ccd4a1SSimon Wunderlich return -EFAULT; 131104ccd4a1SSimon Wunderlich 131204ccd4a1SSimon Wunderlich buf[len] = '\0'; 131304ccd4a1SSimon Wunderlich if (kstrtoul(buf, 0, &val)) 131404ccd4a1SSimon Wunderlich return -EINVAL; 131504ccd4a1SSimon Wunderlich 131604ccd4a1SSimon Wunderlich if (val < 0 || val > 15) 131704ccd4a1SSimon Wunderlich return -EINVAL; 131804ccd4a1SSimon Wunderlich 131904ccd4a1SSimon Wunderlich sc->spec_config.fft_period = val; 132004ccd4a1SSimon Wunderlich return count; 132104ccd4a1SSimon Wunderlich } 132204ccd4a1SSimon Wunderlich 132304ccd4a1SSimon Wunderlich static const struct file_operations fops_spectral_fft_period = { 132404ccd4a1SSimon Wunderlich .read = read_file_spectral_fft_period, 132504ccd4a1SSimon Wunderlich .write = write_file_spectral_fft_period, 132604ccd4a1SSimon Wunderlich .open = simple_open, 132704ccd4a1SSimon Wunderlich .owner = THIS_MODULE, 132804ccd4a1SSimon Wunderlich .llseek = default_llseek, 132904ccd4a1SSimon Wunderlich }; 133004ccd4a1SSimon Wunderlich 1331e93d083fSSimon Wunderlich static struct dentry *create_buf_file_handler(const char *filename, 1332e93d083fSSimon Wunderlich struct dentry *parent, 1333e93d083fSSimon Wunderlich umode_t mode, 1334e93d083fSSimon Wunderlich struct rchan_buf *buf, 1335e93d083fSSimon Wunderlich int *is_global) 1336e93d083fSSimon Wunderlich { 1337e93d083fSSimon Wunderlich struct dentry *buf_file; 1338e93d083fSSimon Wunderlich 1339e93d083fSSimon Wunderlich buf_file = debugfs_create_file(filename, mode, parent, buf, 1340e93d083fSSimon Wunderlich &relay_file_operations); 1341e93d083fSSimon Wunderlich *is_global = 1; 1342e93d083fSSimon Wunderlich return buf_file; 1343e93d083fSSimon Wunderlich } 1344e93d083fSSimon Wunderlich 1345e93d083fSSimon Wunderlich static int remove_buf_file_handler(struct dentry *dentry) 1346e93d083fSSimon Wunderlich { 1347e93d083fSSimon Wunderlich debugfs_remove(dentry); 1348e93d083fSSimon Wunderlich 1349e93d083fSSimon Wunderlich return 0; 1350e93d083fSSimon Wunderlich } 1351e93d083fSSimon Wunderlich 1352e93d083fSSimon Wunderlich void ath_debug_send_fft_sample(struct ath_softc *sc, 1353e93d083fSSimon Wunderlich struct fft_sample_tlv *fft_sample_tlv) 1354e93d083fSSimon Wunderlich { 13554ab0b0aaSSven Eckelmann int length; 1356e93d083fSSimon Wunderlich if (!sc->rfs_chan_spec_scan) 1357e93d083fSSimon Wunderlich return; 1358e93d083fSSimon Wunderlich 13594ab0b0aaSSven Eckelmann length = __be16_to_cpu(fft_sample_tlv->length) + 13604ab0b0aaSSven Eckelmann sizeof(*fft_sample_tlv); 13614ab0b0aaSSven Eckelmann relay_write(sc->rfs_chan_spec_scan, fft_sample_tlv, length); 1362e93d083fSSimon Wunderlich } 1363e93d083fSSimon Wunderlich 1364e93d083fSSimon Wunderlich static struct rchan_callbacks rfs_spec_scan_cb = { 1365e93d083fSSimon Wunderlich .create_buf_file = create_buf_file_handler, 1366e93d083fSSimon Wunderlich .remove_buf_file = remove_buf_file_handler, 1367e93d083fSSimon Wunderlich }; 1368e93d083fSSimon Wunderlich 1369e93d083fSSimon Wunderlich 13709bff0bc4SFelix Fietkau static ssize_t read_file_regidx(struct file *file, char __user *user_buf, 13719bff0bc4SFelix Fietkau size_t count, loff_t *ppos) 13729bff0bc4SFelix Fietkau { 13739bff0bc4SFelix Fietkau struct ath_softc *sc = file->private_data; 13749bff0bc4SFelix Fietkau char buf[32]; 13759bff0bc4SFelix Fietkau unsigned int len; 13769bff0bc4SFelix Fietkau 13772b87f3aaSDan Carpenter len = sprintf(buf, "0x%08x\n", sc->debug.regidx); 13789bff0bc4SFelix Fietkau return simple_read_from_buffer(user_buf, count, ppos, buf, len); 13799bff0bc4SFelix Fietkau } 13809bff0bc4SFelix Fietkau 13819bff0bc4SFelix Fietkau static ssize_t write_file_regidx(struct file *file, const char __user *user_buf, 13829bff0bc4SFelix Fietkau size_t count, loff_t *ppos) 13839bff0bc4SFelix Fietkau { 13849bff0bc4SFelix Fietkau struct ath_softc *sc = file->private_data; 13859bff0bc4SFelix Fietkau unsigned long regidx; 13869bff0bc4SFelix Fietkau char buf[32]; 13879bff0bc4SFelix Fietkau ssize_t len; 13889bff0bc4SFelix Fietkau 13899bff0bc4SFelix Fietkau len = min(count, sizeof(buf) - 1); 13909bff0bc4SFelix Fietkau if (copy_from_user(buf, user_buf, len)) 139104236066SDan Carpenter return -EFAULT; 13929bff0bc4SFelix Fietkau 13939bff0bc4SFelix Fietkau buf[len] = '\0'; 139427d7f477SJingoo Han if (kstrtoul(buf, 0, ®idx)) 13959bff0bc4SFelix Fietkau return -EINVAL; 13969bff0bc4SFelix Fietkau 13979bff0bc4SFelix Fietkau sc->debug.regidx = regidx; 13989bff0bc4SFelix Fietkau return count; 13999bff0bc4SFelix Fietkau } 14009bff0bc4SFelix Fietkau 14019bff0bc4SFelix Fietkau static const struct file_operations fops_regidx = { 14029bff0bc4SFelix Fietkau .read = read_file_regidx, 14039bff0bc4SFelix Fietkau .write = write_file_regidx, 1404234e3405SStephen Boyd .open = simple_open, 14056038f373SArnd Bergmann .owner = THIS_MODULE, 14066038f373SArnd Bergmann .llseek = default_llseek, 14079bff0bc4SFelix Fietkau }; 14089bff0bc4SFelix Fietkau 14099bff0bc4SFelix Fietkau static ssize_t read_file_regval(struct file *file, char __user *user_buf, 14109bff0bc4SFelix Fietkau size_t count, loff_t *ppos) 14119bff0bc4SFelix Fietkau { 14129bff0bc4SFelix Fietkau struct ath_softc *sc = file->private_data; 14139bff0bc4SFelix Fietkau struct ath_hw *ah = sc->sc_ah; 14149bff0bc4SFelix Fietkau char buf[32]; 14159bff0bc4SFelix Fietkau unsigned int len; 14169bff0bc4SFelix Fietkau u32 regval; 14179bff0bc4SFelix Fietkau 141879d2b157SRajkumar Manoharan ath9k_ps_wakeup(sc); 14199bff0bc4SFelix Fietkau regval = REG_READ_D(ah, sc->debug.regidx); 142079d2b157SRajkumar Manoharan ath9k_ps_restore(sc); 14212b87f3aaSDan Carpenter len = sprintf(buf, "0x%08x\n", regval); 14229bff0bc4SFelix Fietkau return simple_read_from_buffer(user_buf, count, ppos, buf, len); 14239bff0bc4SFelix Fietkau } 14249bff0bc4SFelix Fietkau 14259bff0bc4SFelix Fietkau static ssize_t write_file_regval(struct file *file, const char __user *user_buf, 14269bff0bc4SFelix Fietkau size_t count, loff_t *ppos) 14279bff0bc4SFelix Fietkau { 14289bff0bc4SFelix Fietkau struct ath_softc *sc = file->private_data; 14299bff0bc4SFelix Fietkau struct ath_hw *ah = sc->sc_ah; 14309bff0bc4SFelix Fietkau unsigned long regval; 14319bff0bc4SFelix Fietkau char buf[32]; 14329bff0bc4SFelix Fietkau ssize_t len; 14339bff0bc4SFelix Fietkau 14349bff0bc4SFelix Fietkau len = min(count, sizeof(buf) - 1); 14359bff0bc4SFelix Fietkau if (copy_from_user(buf, user_buf, len)) 143604236066SDan Carpenter return -EFAULT; 14379bff0bc4SFelix Fietkau 14389bff0bc4SFelix Fietkau buf[len] = '\0'; 143927d7f477SJingoo Han if (kstrtoul(buf, 0, ®val)) 14409bff0bc4SFelix Fietkau return -EINVAL; 14419bff0bc4SFelix Fietkau 144279d2b157SRajkumar Manoharan ath9k_ps_wakeup(sc); 14439bff0bc4SFelix Fietkau REG_WRITE_D(ah, sc->debug.regidx, regval); 144479d2b157SRajkumar Manoharan ath9k_ps_restore(sc); 14459bff0bc4SFelix Fietkau return count; 14469bff0bc4SFelix Fietkau } 14479bff0bc4SFelix Fietkau 14489bff0bc4SFelix Fietkau static const struct file_operations fops_regval = { 14499bff0bc4SFelix Fietkau .read = read_file_regval, 14509bff0bc4SFelix Fietkau .write = write_file_regval, 1451234e3405SStephen Boyd .open = simple_open, 14526038f373SArnd Bergmann .owner = THIS_MODULE, 14536038f373SArnd Bergmann .llseek = default_llseek, 14549bff0bc4SFelix Fietkau }; 14559bff0bc4SFelix Fietkau 1456582d0064SVasanthakumar Thiagarajan #define REGDUMP_LINE_SIZE 20 1457582d0064SVasanthakumar Thiagarajan 1458582d0064SVasanthakumar Thiagarajan static int open_file_regdump(struct inode *inode, struct file *file) 1459582d0064SVasanthakumar Thiagarajan { 1460582d0064SVasanthakumar Thiagarajan struct ath_softc *sc = inode->i_private; 1461582d0064SVasanthakumar Thiagarajan unsigned int len = 0; 1462582d0064SVasanthakumar Thiagarajan u8 *buf; 1463582d0064SVasanthakumar Thiagarajan int i; 1464582d0064SVasanthakumar Thiagarajan unsigned long num_regs, regdump_len, max_reg_offset; 1465582d0064SVasanthakumar Thiagarajan 1466582d0064SVasanthakumar Thiagarajan max_reg_offset = AR_SREV_9300_20_OR_LATER(sc->sc_ah) ? 0x16bd4 : 0xb500; 1467582d0064SVasanthakumar Thiagarajan num_regs = max_reg_offset / 4 + 1; 1468582d0064SVasanthakumar Thiagarajan regdump_len = num_regs * REGDUMP_LINE_SIZE + 1; 1469582d0064SVasanthakumar Thiagarajan buf = vmalloc(regdump_len); 1470582d0064SVasanthakumar Thiagarajan if (!buf) 1471582d0064SVasanthakumar Thiagarajan return -ENOMEM; 1472582d0064SVasanthakumar Thiagarajan 1473582d0064SVasanthakumar Thiagarajan ath9k_ps_wakeup(sc); 1474582d0064SVasanthakumar Thiagarajan for (i = 0; i < num_regs; i++) 1475582d0064SVasanthakumar Thiagarajan len += scnprintf(buf + len, regdump_len - len, 1476582d0064SVasanthakumar Thiagarajan "0x%06x 0x%08x\n", i << 2, REG_READ(sc->sc_ah, i << 2)); 1477582d0064SVasanthakumar Thiagarajan ath9k_ps_restore(sc); 1478582d0064SVasanthakumar Thiagarajan 1479582d0064SVasanthakumar Thiagarajan file->private_data = buf; 1480582d0064SVasanthakumar Thiagarajan 1481582d0064SVasanthakumar Thiagarajan return 0; 1482582d0064SVasanthakumar Thiagarajan } 1483582d0064SVasanthakumar Thiagarajan 1484582d0064SVasanthakumar Thiagarajan static const struct file_operations fops_regdump = { 1485582d0064SVasanthakumar Thiagarajan .open = open_file_regdump, 1486582d0064SVasanthakumar Thiagarajan .read = ath9k_debugfs_read_buf, 1487582d0064SVasanthakumar Thiagarajan .release = ath9k_debugfs_release_buf, 1488582d0064SVasanthakumar Thiagarajan .owner = THIS_MODULE, 1489582d0064SVasanthakumar Thiagarajan .llseek = default_llseek,/* read accesses f_pos */ 1490582d0064SVasanthakumar Thiagarajan }; 1491582d0064SVasanthakumar Thiagarajan 1492d069a46bSRajkumar Manoharan static ssize_t read_file_dump_nfcal(struct file *file, char __user *user_buf, 1493d069a46bSRajkumar Manoharan size_t count, loff_t *ppos) 1494d069a46bSRajkumar Manoharan { 1495d069a46bSRajkumar Manoharan struct ath_softc *sc = file->private_data; 1496d069a46bSRajkumar Manoharan struct ath_hw *ah = sc->sc_ah; 1497d069a46bSRajkumar Manoharan struct ath9k_nfcal_hist *h = sc->caldata.nfCalHist; 1498d069a46bSRajkumar Manoharan struct ath_common *common = ath9k_hw_common(ah); 1499d069a46bSRajkumar Manoharan struct ieee80211_conf *conf = &common->hw->conf; 1500d069a46bSRajkumar Manoharan u32 len = 0, size = 1500; 1501d069a46bSRajkumar Manoharan u32 i, j; 1502d069a46bSRajkumar Manoharan ssize_t retval = 0; 1503d069a46bSRajkumar Manoharan char *buf; 1504d069a46bSRajkumar Manoharan u8 chainmask = (ah->rxchainmask << 3) | ah->rxchainmask; 1505d069a46bSRajkumar Manoharan u8 nread; 1506d069a46bSRajkumar Manoharan 1507d069a46bSRajkumar Manoharan buf = kzalloc(size, GFP_KERNEL); 1508d069a46bSRajkumar Manoharan if (!buf) 1509d069a46bSRajkumar Manoharan return -ENOMEM; 1510d069a46bSRajkumar Manoharan 1511d069a46bSRajkumar Manoharan len += snprintf(buf + len, size - len, 1512d069a46bSRajkumar Manoharan "Channel Noise Floor : %d\n", ah->noise); 1513d069a46bSRajkumar Manoharan len += snprintf(buf + len, size - len, 1514d069a46bSRajkumar Manoharan "Chain | privNF | # Readings | NF Readings\n"); 1515d069a46bSRajkumar Manoharan for (i = 0; i < NUM_NF_READINGS; i++) { 1516d069a46bSRajkumar Manoharan if (!(chainmask & (1 << i)) || 1517d069a46bSRajkumar Manoharan ((i >= AR5416_MAX_CHAINS) && !conf_is_ht40(conf))) 1518d069a46bSRajkumar Manoharan continue; 1519d069a46bSRajkumar Manoharan 1520d069a46bSRajkumar Manoharan nread = AR_PHY_CCA_FILTERWINDOW_LENGTH - h[i].invalidNFcount; 1521d069a46bSRajkumar Manoharan len += snprintf(buf + len, size - len, " %d\t %d\t %d\t\t", 1522d069a46bSRajkumar Manoharan i, h[i].privNF, nread); 1523d069a46bSRajkumar Manoharan for (j = 0; j < nread; j++) 1524d069a46bSRajkumar Manoharan len += snprintf(buf + len, size - len, 1525d069a46bSRajkumar Manoharan " %d", h[i].nfCalBuffer[j]); 1526d069a46bSRajkumar Manoharan len += snprintf(buf + len, size - len, "\n"); 1527d069a46bSRajkumar Manoharan } 1528d069a46bSRajkumar Manoharan 1529d069a46bSRajkumar Manoharan if (len > size) 1530d069a46bSRajkumar Manoharan len = size; 1531d069a46bSRajkumar Manoharan 1532d069a46bSRajkumar Manoharan retval = simple_read_from_buffer(user_buf, count, ppos, buf, len); 1533d069a46bSRajkumar Manoharan kfree(buf); 1534d069a46bSRajkumar Manoharan 1535d069a46bSRajkumar Manoharan return retval; 1536d069a46bSRajkumar Manoharan } 1537d069a46bSRajkumar Manoharan 1538d069a46bSRajkumar Manoharan static const struct file_operations fops_dump_nfcal = { 1539d069a46bSRajkumar Manoharan .read = read_file_dump_nfcal, 1540234e3405SStephen Boyd .open = simple_open, 1541d069a46bSRajkumar Manoharan .owner = THIS_MODULE, 1542d069a46bSRajkumar Manoharan .llseek = default_llseek, 1543d069a46bSRajkumar Manoharan }; 1544d069a46bSRajkumar Manoharan 1545580f010fSRajkumar Manoharan static ssize_t read_file_base_eeprom(struct file *file, char __user *user_buf, 1546580f010fSRajkumar Manoharan size_t count, loff_t *ppos) 1547580f010fSRajkumar Manoharan { 1548580f010fSRajkumar Manoharan struct ath_softc *sc = file->private_data; 1549580f010fSRajkumar Manoharan struct ath_hw *ah = sc->sc_ah; 1550580f010fSRajkumar Manoharan u32 len = 0, size = 1500; 1551580f010fSRajkumar Manoharan ssize_t retval = 0; 1552580f010fSRajkumar Manoharan char *buf; 1553580f010fSRajkumar Manoharan 1554580f010fSRajkumar Manoharan buf = kzalloc(size, GFP_KERNEL); 1555580f010fSRajkumar Manoharan if (!buf) 1556580f010fSRajkumar Manoharan return -ENOMEM; 1557580f010fSRajkumar Manoharan 1558580f010fSRajkumar Manoharan len = ah->eep_ops->dump_eeprom(ah, true, buf, len, size); 1559580f010fSRajkumar Manoharan 1560580f010fSRajkumar Manoharan retval = simple_read_from_buffer(user_buf, count, ppos, buf, len); 1561580f010fSRajkumar Manoharan kfree(buf); 1562580f010fSRajkumar Manoharan 1563580f010fSRajkumar Manoharan return retval; 1564580f010fSRajkumar Manoharan } 1565580f010fSRajkumar Manoharan 1566580f010fSRajkumar Manoharan static const struct file_operations fops_base_eeprom = { 1567580f010fSRajkumar Manoharan .read = read_file_base_eeprom, 1568234e3405SStephen Boyd .open = simple_open, 1569580f010fSRajkumar Manoharan .owner = THIS_MODULE, 1570580f010fSRajkumar Manoharan .llseek = default_llseek, 1571580f010fSRajkumar Manoharan }; 1572580f010fSRajkumar Manoharan 15733f4c4bddSRajkumar Manoharan static ssize_t read_file_modal_eeprom(struct file *file, char __user *user_buf, 15743f4c4bddSRajkumar Manoharan size_t count, loff_t *ppos) 15753f4c4bddSRajkumar Manoharan { 15763f4c4bddSRajkumar Manoharan struct ath_softc *sc = file->private_data; 15773f4c4bddSRajkumar Manoharan struct ath_hw *ah = sc->sc_ah; 15783f4c4bddSRajkumar Manoharan u32 len = 0, size = 6000; 15793f4c4bddSRajkumar Manoharan char *buf; 15803f4c4bddSRajkumar Manoharan size_t retval; 15813f4c4bddSRajkumar Manoharan 15823f4c4bddSRajkumar Manoharan buf = kzalloc(size, GFP_KERNEL); 15833f4c4bddSRajkumar Manoharan if (buf == NULL) 15843f4c4bddSRajkumar Manoharan return -ENOMEM; 15853f4c4bddSRajkumar Manoharan 15863f4c4bddSRajkumar Manoharan len = ah->eep_ops->dump_eeprom(ah, false, buf, len, size); 15873f4c4bddSRajkumar Manoharan 15883f4c4bddSRajkumar Manoharan retval = simple_read_from_buffer(user_buf, count, ppos, buf, len); 15893f4c4bddSRajkumar Manoharan kfree(buf); 15903f4c4bddSRajkumar Manoharan 15913f4c4bddSRajkumar Manoharan return retval; 15923f4c4bddSRajkumar Manoharan } 15933f4c4bddSRajkumar Manoharan 15943f4c4bddSRajkumar Manoharan static const struct file_operations fops_modal_eeprom = { 15953f4c4bddSRajkumar Manoharan .read = read_file_modal_eeprom, 1596234e3405SStephen Boyd .open = simple_open, 15973f4c4bddSRajkumar Manoharan .owner = THIS_MODULE, 15983f4c4bddSRajkumar Manoharan .llseek = default_llseek, 15993f4c4bddSRajkumar Manoharan }; 16003f4c4bddSRajkumar Manoharan 16014df50ca8SRajkumar Manoharan #ifdef CONFIG_ATH9K_BTCOEX_SUPPORT 16024df50ca8SRajkumar Manoharan static ssize_t read_file_btcoex(struct file *file, char __user *user_buf, 16034df50ca8SRajkumar Manoharan size_t count, loff_t *ppos) 16044df50ca8SRajkumar Manoharan { 16054df50ca8SRajkumar Manoharan struct ath_softc *sc = file->private_data; 16064df50ca8SRajkumar Manoharan u32 len = 0, size = 1500; 16074df50ca8SRajkumar Manoharan char *buf; 16084df50ca8SRajkumar Manoharan size_t retval; 16094df50ca8SRajkumar Manoharan 16104df50ca8SRajkumar Manoharan buf = kzalloc(size, GFP_KERNEL); 16114df50ca8SRajkumar Manoharan if (buf == NULL) 16124df50ca8SRajkumar Manoharan return -ENOMEM; 16134df50ca8SRajkumar Manoharan 1614ac46ba43SSujith Manoharan if (!sc->sc_ah->common.btcoex_enabled) { 1615ac46ba43SSujith Manoharan len = snprintf(buf, size, "%s\n", 1616ac46ba43SSujith Manoharan "BTCOEX is disabled"); 1617ac46ba43SSujith Manoharan goto exit; 1618ac46ba43SSujith Manoharan } 16194df50ca8SRajkumar Manoharan 1620ac46ba43SSujith Manoharan len = ath9k_dump_btcoex(sc, buf, size); 1621ac46ba43SSujith Manoharan exit: 16224df50ca8SRajkumar Manoharan retval = simple_read_from_buffer(user_buf, count, ppos, buf, len); 16234df50ca8SRajkumar Manoharan kfree(buf); 16244df50ca8SRajkumar Manoharan 16254df50ca8SRajkumar Manoharan return retval; 16264df50ca8SRajkumar Manoharan } 16274df50ca8SRajkumar Manoharan 16284df50ca8SRajkumar Manoharan static const struct file_operations fops_btcoex = { 16294df50ca8SRajkumar Manoharan .read = read_file_btcoex, 16304df50ca8SRajkumar Manoharan .open = simple_open, 16314df50ca8SRajkumar Manoharan .owner = THIS_MODULE, 16324df50ca8SRajkumar Manoharan .llseek = default_llseek, 16334df50ca8SRajkumar Manoharan }; 16344df50ca8SRajkumar Manoharan #endif 16354df50ca8SRajkumar Manoharan 1636a145daf7SSujith Manoharan static ssize_t read_file_node_stat(struct file *file, char __user *user_buf, 1637a145daf7SSujith Manoharan size_t count, loff_t *ppos) 1638a145daf7SSujith Manoharan { 1639a145daf7SSujith Manoharan struct ath_node *an = file->private_data; 1640a145daf7SSujith Manoharan struct ath_softc *sc = an->sc; 1641a145daf7SSujith Manoharan struct ath_atx_tid *tid; 1642a145daf7SSujith Manoharan struct ath_atx_ac *ac; 1643a145daf7SSujith Manoharan struct ath_txq *txq; 1644a145daf7SSujith Manoharan u32 len = 0, size = 4096; 1645a145daf7SSujith Manoharan char *buf; 1646a145daf7SSujith Manoharan size_t retval; 1647a145daf7SSujith Manoharan int tidno, acno; 1648a145daf7SSujith Manoharan 1649a145daf7SSujith Manoharan buf = kzalloc(size, GFP_KERNEL); 1650a145daf7SSujith Manoharan if (buf == NULL) 1651a145daf7SSujith Manoharan return -ENOMEM; 1652a145daf7SSujith Manoharan 1653a145daf7SSujith Manoharan if (!an->sta->ht_cap.ht_supported) { 1654a145daf7SSujith Manoharan len = snprintf(buf, size, "%s\n", 1655a145daf7SSujith Manoharan "HT not supported"); 1656a145daf7SSujith Manoharan goto exit; 1657a145daf7SSujith Manoharan } 1658a145daf7SSujith Manoharan 1659a145daf7SSujith Manoharan len = snprintf(buf, size, "Max-AMPDU: %d\n", 1660a145daf7SSujith Manoharan an->maxampdu); 1661a145daf7SSujith Manoharan len += snprintf(buf + len, size - len, "MPDU Density: %d\n\n", 1662a145daf7SSujith Manoharan an->mpdudensity); 1663a145daf7SSujith Manoharan 1664a145daf7SSujith Manoharan len += snprintf(buf + len, size - len, 1665a145daf7SSujith Manoharan "%2s%7s\n", "AC", "SCHED"); 1666a145daf7SSujith Manoharan 1667a145daf7SSujith Manoharan for (acno = 0, ac = &an->ac[acno]; 1668a145daf7SSujith Manoharan acno < IEEE80211_NUM_ACS; acno++, ac++) { 1669a145daf7SSujith Manoharan txq = ac->txq; 1670a145daf7SSujith Manoharan ath_txq_lock(sc, txq); 1671a145daf7SSujith Manoharan len += snprintf(buf + len, size - len, 1672a145daf7SSujith Manoharan "%2d%7d\n", 1673a145daf7SSujith Manoharan acno, ac->sched); 1674a145daf7SSujith Manoharan ath_txq_unlock(sc, txq); 1675a145daf7SSujith Manoharan } 1676a145daf7SSujith Manoharan 1677a145daf7SSujith Manoharan len += snprintf(buf + len, size - len, 1678a145daf7SSujith Manoharan "\n%3s%11s%10s%10s%10s%10s%9s%6s%8s\n", 1679a145daf7SSujith Manoharan "TID", "SEQ_START", "SEQ_NEXT", "BAW_SIZE", 1680a145daf7SSujith Manoharan "BAW_HEAD", "BAW_TAIL", "BAR_IDX", "SCHED", "PAUSED"); 1681a145daf7SSujith Manoharan 1682a145daf7SSujith Manoharan for (tidno = 0, tid = &an->tid[tidno]; 1683a145daf7SSujith Manoharan tidno < IEEE80211_NUM_TIDS; tidno++, tid++) { 1684a145daf7SSujith Manoharan txq = tid->ac->txq; 1685a145daf7SSujith Manoharan ath_txq_lock(sc, txq); 1686a145daf7SSujith Manoharan len += snprintf(buf + len, size - len, 1687a145daf7SSujith Manoharan "%3d%11d%10d%10d%10d%10d%9d%6d%8d\n", 1688a145daf7SSujith Manoharan tid->tidno, tid->seq_start, tid->seq_next, 1689a145daf7SSujith Manoharan tid->baw_size, tid->baw_head, tid->baw_tail, 1690a145daf7SSujith Manoharan tid->bar_index, tid->sched, tid->paused); 1691a145daf7SSujith Manoharan ath_txq_unlock(sc, txq); 1692a145daf7SSujith Manoharan } 1693a145daf7SSujith Manoharan exit: 1694a145daf7SSujith Manoharan retval = simple_read_from_buffer(user_buf, count, ppos, buf, len); 1695a145daf7SSujith Manoharan kfree(buf); 1696a145daf7SSujith Manoharan 1697a145daf7SSujith Manoharan return retval; 1698a145daf7SSujith Manoharan } 1699a145daf7SSujith Manoharan 1700a145daf7SSujith Manoharan static const struct file_operations fops_node_stat = { 1701a145daf7SSujith Manoharan .read = read_file_node_stat, 1702a145daf7SSujith Manoharan .open = simple_open, 1703a145daf7SSujith Manoharan .owner = THIS_MODULE, 1704a145daf7SSujith Manoharan .llseek = default_llseek, 1705a145daf7SSujith Manoharan }; 1706a145daf7SSujith Manoharan 1707a145daf7SSujith Manoharan void ath9k_sta_add_debugfs(struct ieee80211_hw *hw, 1708a145daf7SSujith Manoharan struct ieee80211_vif *vif, 1709a145daf7SSujith Manoharan struct ieee80211_sta *sta, 1710a145daf7SSujith Manoharan struct dentry *dir) 1711a145daf7SSujith Manoharan { 1712a145daf7SSujith Manoharan struct ath_node *an = (struct ath_node *)sta->drv_priv; 1713a145daf7SSujith Manoharan an->node_stat = debugfs_create_file("node_stat", S_IRUGO, 1714a145daf7SSujith Manoharan dir, an, &fops_node_stat); 1715a145daf7SSujith Manoharan } 1716a145daf7SSujith Manoharan 1717a145daf7SSujith Manoharan void ath9k_sta_remove_debugfs(struct ieee80211_hw *hw, 1718a145daf7SSujith Manoharan struct ieee80211_vif *vif, 1719a145daf7SSujith Manoharan struct ieee80211_sta *sta, 1720a145daf7SSujith Manoharan struct dentry *dir) 1721a145daf7SSujith Manoharan { 1722a145daf7SSujith Manoharan struct ath_node *an = (struct ath_node *)sta->drv_priv; 1723a145daf7SSujith Manoharan debugfs_remove(an->node_stat); 1724a145daf7SSujith Manoharan } 1725a145daf7SSujith Manoharan 1726c175db87SSujith Manoharan /* Ethtool support for get-stats */ 1727c175db87SSujith Manoharan 1728c175db87SSujith Manoharan #define AMKSTR(nm) #nm "_BE", #nm "_BK", #nm "_VI", #nm "_VO" 1729c175db87SSujith Manoharan static const char ath9k_gstrings_stats[][ETH_GSTRING_LEN] = { 1730c175db87SSujith Manoharan "tx_pkts_nic", 1731c175db87SSujith Manoharan "tx_bytes_nic", 1732c175db87SSujith Manoharan "rx_pkts_nic", 1733c175db87SSujith Manoharan "rx_bytes_nic", 1734c175db87SSujith Manoharan AMKSTR(d_tx_pkts), 1735c175db87SSujith Manoharan AMKSTR(d_tx_bytes), 1736c175db87SSujith Manoharan AMKSTR(d_tx_mpdus_queued), 1737c175db87SSujith Manoharan AMKSTR(d_tx_mpdus_completed), 1738c175db87SSujith Manoharan AMKSTR(d_tx_mpdu_xretries), 1739c175db87SSujith Manoharan AMKSTR(d_tx_aggregates), 1740c175db87SSujith Manoharan AMKSTR(d_tx_ampdus_queued_hw), 1741c175db87SSujith Manoharan AMKSTR(d_tx_ampdus_queued_sw), 1742c175db87SSujith Manoharan AMKSTR(d_tx_ampdus_completed), 1743c175db87SSujith Manoharan AMKSTR(d_tx_ampdu_retries), 1744c175db87SSujith Manoharan AMKSTR(d_tx_ampdu_xretries), 1745c175db87SSujith Manoharan AMKSTR(d_tx_fifo_underrun), 1746c175db87SSujith Manoharan AMKSTR(d_tx_op_exceeded), 1747c175db87SSujith Manoharan AMKSTR(d_tx_timer_expiry), 1748c175db87SSujith Manoharan AMKSTR(d_tx_desc_cfg_err), 1749c175db87SSujith Manoharan AMKSTR(d_tx_data_underrun), 1750c175db87SSujith Manoharan AMKSTR(d_tx_delim_underrun), 175118c45b10SBen Greear "d_rx_crc_err", 1752c175db87SSujith Manoharan "d_rx_decrypt_crc_err", 1753c175db87SSujith Manoharan "d_rx_phy_err", 1754c175db87SSujith Manoharan "d_rx_mic_err", 1755c175db87SSujith Manoharan "d_rx_pre_delim_crc_err", 1756c175db87SSujith Manoharan "d_rx_post_delim_crc_err", 1757c175db87SSujith Manoharan "d_rx_decrypt_busy_err", 1758c175db87SSujith Manoharan 1759c175db87SSujith Manoharan "d_rx_phyerr_radar", 1760c175db87SSujith Manoharan "d_rx_phyerr_ofdm_timing", 1761c175db87SSujith Manoharan "d_rx_phyerr_cck_timing", 1762c175db87SSujith Manoharan 1763c175db87SSujith Manoharan }; 1764c175db87SSujith Manoharan #define ATH9K_SSTATS_LEN ARRAY_SIZE(ath9k_gstrings_stats) 1765c175db87SSujith Manoharan 1766c175db87SSujith Manoharan void ath9k_get_et_strings(struct ieee80211_hw *hw, 1767c175db87SSujith Manoharan struct ieee80211_vif *vif, 1768c175db87SSujith Manoharan u32 sset, u8 *data) 1769c175db87SSujith Manoharan { 1770c175db87SSujith Manoharan if (sset == ETH_SS_STATS) 1771c175db87SSujith Manoharan memcpy(data, *ath9k_gstrings_stats, 1772c175db87SSujith Manoharan sizeof(ath9k_gstrings_stats)); 1773c175db87SSujith Manoharan } 1774c175db87SSujith Manoharan 1775c175db87SSujith Manoharan int ath9k_get_et_sset_count(struct ieee80211_hw *hw, 1776c175db87SSujith Manoharan struct ieee80211_vif *vif, int sset) 1777c175db87SSujith Manoharan { 1778c175db87SSujith Manoharan if (sset == ETH_SS_STATS) 1779c175db87SSujith Manoharan return ATH9K_SSTATS_LEN; 1780c175db87SSujith Manoharan return 0; 1781c175db87SSujith Manoharan } 1782c175db87SSujith Manoharan 1783c175db87SSujith Manoharan #define AWDATA(elem) \ 1784c175db87SSujith Manoharan do { \ 1785c175db87SSujith Manoharan data[i++] = sc->debug.stats.txstats[PR_QNUM(IEEE80211_AC_BE)].elem; \ 1786c175db87SSujith Manoharan data[i++] = sc->debug.stats.txstats[PR_QNUM(IEEE80211_AC_BK)].elem; \ 1787c175db87SSujith Manoharan data[i++] = sc->debug.stats.txstats[PR_QNUM(IEEE80211_AC_VI)].elem; \ 1788c175db87SSujith Manoharan data[i++] = sc->debug.stats.txstats[PR_QNUM(IEEE80211_AC_VO)].elem; \ 1789c175db87SSujith Manoharan } while (0) 1790c175db87SSujith Manoharan 1791c175db87SSujith Manoharan #define AWDATA_RX(elem) \ 1792c175db87SSujith Manoharan do { \ 1793c175db87SSujith Manoharan data[i++] = sc->debug.stats.rxstats.elem; \ 1794c175db87SSujith Manoharan } while (0) 1795c175db87SSujith Manoharan 1796c175db87SSujith Manoharan void ath9k_get_et_stats(struct ieee80211_hw *hw, 1797c175db87SSujith Manoharan struct ieee80211_vif *vif, 1798c175db87SSujith Manoharan struct ethtool_stats *stats, u64 *data) 1799c175db87SSujith Manoharan { 1800c175db87SSujith Manoharan struct ath_softc *sc = hw->priv; 1801c175db87SSujith Manoharan int i = 0; 1802c175db87SSujith Manoharan 1803c175db87SSujith Manoharan data[i++] = (sc->debug.stats.txstats[PR_QNUM(IEEE80211_AC_BE)].tx_pkts_all + 1804c175db87SSujith Manoharan sc->debug.stats.txstats[PR_QNUM(IEEE80211_AC_BK)].tx_pkts_all + 1805c175db87SSujith Manoharan sc->debug.stats.txstats[PR_QNUM(IEEE80211_AC_VI)].tx_pkts_all + 1806c175db87SSujith Manoharan sc->debug.stats.txstats[PR_QNUM(IEEE80211_AC_VO)].tx_pkts_all); 1807c175db87SSujith Manoharan data[i++] = (sc->debug.stats.txstats[PR_QNUM(IEEE80211_AC_BE)].tx_bytes_all + 1808c175db87SSujith Manoharan sc->debug.stats.txstats[PR_QNUM(IEEE80211_AC_BK)].tx_bytes_all + 1809c175db87SSujith Manoharan sc->debug.stats.txstats[PR_QNUM(IEEE80211_AC_VI)].tx_bytes_all + 1810c175db87SSujith Manoharan sc->debug.stats.txstats[PR_QNUM(IEEE80211_AC_VO)].tx_bytes_all); 1811c175db87SSujith Manoharan AWDATA_RX(rx_pkts_all); 1812c175db87SSujith Manoharan AWDATA_RX(rx_bytes_all); 1813c175db87SSujith Manoharan 1814c175db87SSujith Manoharan AWDATA(tx_pkts_all); 1815c175db87SSujith Manoharan AWDATA(tx_bytes_all); 1816c175db87SSujith Manoharan AWDATA(queued); 1817c175db87SSujith Manoharan AWDATA(completed); 1818c175db87SSujith Manoharan AWDATA(xretries); 1819c175db87SSujith Manoharan AWDATA(a_aggr); 1820c175db87SSujith Manoharan AWDATA(a_queued_hw); 1821c175db87SSujith Manoharan AWDATA(a_queued_sw); 1822c175db87SSujith Manoharan AWDATA(a_completed); 1823c175db87SSujith Manoharan AWDATA(a_retries); 1824c175db87SSujith Manoharan AWDATA(a_xretries); 1825c175db87SSujith Manoharan AWDATA(fifo_underrun); 1826c175db87SSujith Manoharan AWDATA(xtxop); 1827c175db87SSujith Manoharan AWDATA(timer_exp); 1828c175db87SSujith Manoharan AWDATA(desc_cfg_err); 1829c175db87SSujith Manoharan AWDATA(data_underrun); 1830c175db87SSujith Manoharan AWDATA(delim_underrun); 1831c175db87SSujith Manoharan 183218c45b10SBen Greear AWDATA_RX(crc_err); 1833c175db87SSujith Manoharan AWDATA_RX(decrypt_crc_err); 1834c175db87SSujith Manoharan AWDATA_RX(phy_err); 1835c175db87SSujith Manoharan AWDATA_RX(mic_err); 1836c175db87SSujith Manoharan AWDATA_RX(pre_delim_crc_err); 1837c175db87SSujith Manoharan AWDATA_RX(post_delim_crc_err); 1838c175db87SSujith Manoharan AWDATA_RX(decrypt_busy_err); 1839c175db87SSujith Manoharan 1840c175db87SSujith Manoharan AWDATA_RX(phy_err_stats[ATH9K_PHYERR_RADAR]); 1841c175db87SSujith Manoharan AWDATA_RX(phy_err_stats[ATH9K_PHYERR_OFDM_TIMING]); 1842c175db87SSujith Manoharan AWDATA_RX(phy_err_stats[ATH9K_PHYERR_CCK_TIMING]); 1843c175db87SSujith Manoharan 1844c175db87SSujith Manoharan WARN_ON(i != ATH9K_SSTATS_LEN); 1845c175db87SSujith Manoharan } 1846c175db87SSujith Manoharan 1847af690092SSujith Manoharan void ath9k_deinit_debug(struct ath_softc *sc) 1848af690092SSujith Manoharan { 1849af690092SSujith Manoharan if (config_enabled(CONFIG_ATH9K_DEBUGFS) && sc->rfs_chan_spec_scan) { 1850af690092SSujith Manoharan relay_close(sc->rfs_chan_spec_scan); 1851af690092SSujith Manoharan sc->rfs_chan_spec_scan = NULL; 1852af690092SSujith Manoharan } 1853af690092SSujith Manoharan } 1854af690092SSujith Manoharan 18554d6b228dSLuis R. Rodriguez int ath9k_init_debug(struct ath_hw *ah) 1856203c4805SLuis R. Rodriguez { 1857bc974f4aSLuis R. Rodriguez struct ath_common *common = ath9k_hw_common(ah); 1858bc974f4aSLuis R. Rodriguez struct ath_softc *sc = (struct ath_softc *) common->priv; 18594d6b228dSLuis R. Rodriguez 1860eb272441SBen Greear sc->debug.debugfs_phy = debugfs_create_dir("ath9k", 1861eb272441SBen Greear sc->hw->wiphy->debugfsdir); 1862203c4805SLuis R. Rodriguez if (!sc->debug.debugfs_phy) 1863c8a72c00SFelix Fietkau return -ENOMEM; 1864203c4805SLuis R. Rodriguez 1865a830df07SFelix Fietkau #ifdef CONFIG_ATH_DEBUG 1866c70cab1aSFelix Fietkau debugfs_create_file("debug", S_IRUSR | S_IWUSR, sc->debug.debugfs_phy, 1867c70cab1aSFelix Fietkau sc, &fops_debug); 1868a830df07SFelix Fietkau #endif 186929942bc1SZefir Kurtisi 187029942bc1SZefir Kurtisi ath9k_dfs_init_debug(sc); 187129942bc1SZefir Kurtisi 1872c70cab1aSFelix Fietkau debugfs_create_file("dma", S_IRUSR, sc->debug.debugfs_phy, sc, 1873c70cab1aSFelix Fietkau &fops_dma); 1874c70cab1aSFelix Fietkau debugfs_create_file("interrupt", S_IRUSR, sc->debug.debugfs_phy, sc, 1875c70cab1aSFelix Fietkau &fops_interrupt); 1876c70cab1aSFelix Fietkau debugfs_create_file("xmit", S_IRUSR, sc->debug.debugfs_phy, sc, 1877c70cab1aSFelix Fietkau &fops_xmit); 1878c0b74876SSujith Manoharan debugfs_create_file("queues", S_IRUSR, sc->debug.debugfs_phy, sc, 1879c0b74876SSujith Manoharan &fops_queues); 18807702e788SFelix Fietkau debugfs_create_u32("qlen_bk", S_IRUSR | S_IWUSR, sc->debug.debugfs_phy, 1881bea843c7SSujith Manoharan &sc->tx.txq_max_pending[IEEE80211_AC_BK]); 18827702e788SFelix Fietkau debugfs_create_u32("qlen_be", S_IRUSR | S_IWUSR, sc->debug.debugfs_phy, 1883bea843c7SSujith Manoharan &sc->tx.txq_max_pending[IEEE80211_AC_BE]); 18847702e788SFelix Fietkau debugfs_create_u32("qlen_vi", S_IRUSR | S_IWUSR, sc->debug.debugfs_phy, 1885bea843c7SSujith Manoharan &sc->tx.txq_max_pending[IEEE80211_AC_VI]); 18867702e788SFelix Fietkau debugfs_create_u32("qlen_vo", S_IRUSR | S_IWUSR, sc->debug.debugfs_phy, 1887bea843c7SSujith Manoharan &sc->tx.txq_max_pending[IEEE80211_AC_VO]); 1888c70cab1aSFelix Fietkau debugfs_create_file("misc", S_IRUSR, sc->debug.debugfs_phy, sc, 1889c70cab1aSFelix Fietkau &fops_misc); 1890f8b815dcSSujith Manoharan debugfs_create_file("reset", S_IRUSR, sc->debug.debugfs_phy, sc, 1891f8b815dcSSujith Manoharan &fops_reset); 1892c70cab1aSFelix Fietkau debugfs_create_file("recv", S_IRUSR, sc->debug.debugfs_phy, sc, 1893c70cab1aSFelix Fietkau &fops_recv); 1894c70cab1aSFelix Fietkau debugfs_create_file("rx_chainmask", S_IRUSR | S_IWUSR, 1895c70cab1aSFelix Fietkau sc->debug.debugfs_phy, sc, &fops_rx_chainmask); 1896c70cab1aSFelix Fietkau debugfs_create_file("tx_chainmask", S_IRUSR | S_IWUSR, 1897c70cab1aSFelix Fietkau sc->debug.debugfs_phy, sc, &fops_tx_chainmask); 18986e4d291eSSujith Manoharan debugfs_create_file("ani", S_IRUSR | S_IWUSR, 18996e4d291eSSujith Manoharan sc->debug.debugfs_phy, sc, &fops_ani); 190074673db9SFelix Fietkau debugfs_create_bool("paprd", S_IRUSR | S_IWUSR, sc->debug.debugfs_phy, 190174673db9SFelix Fietkau &sc->sc_ah->config.enable_paprd); 1902c70cab1aSFelix Fietkau debugfs_create_file("regidx", S_IRUSR | S_IWUSR, sc->debug.debugfs_phy, 1903c70cab1aSFelix Fietkau sc, &fops_regidx); 1904c70cab1aSFelix Fietkau debugfs_create_file("regval", S_IRUSR | S_IWUSR, sc->debug.debugfs_phy, 1905c70cab1aSFelix Fietkau sc, &fops_regval); 1906c70cab1aSFelix Fietkau debugfs_create_bool("ignore_extcca", S_IRUSR | S_IWUSR, 1907c70cab1aSFelix Fietkau sc->debug.debugfs_phy, 1908c70cab1aSFelix Fietkau &ah->config.cwm_ignore_extcca); 1909c70cab1aSFelix Fietkau debugfs_create_file("regdump", S_IRUSR, sc->debug.debugfs_phy, sc, 1910c70cab1aSFelix Fietkau &fops_regdump); 1911d069a46bSRajkumar Manoharan debugfs_create_file("dump_nfcal", S_IRUSR, sc->debug.debugfs_phy, sc, 1912d069a46bSRajkumar Manoharan &fops_dump_nfcal); 1913580f010fSRajkumar Manoharan debugfs_create_file("base_eeprom", S_IRUSR, sc->debug.debugfs_phy, sc, 1914580f010fSRajkumar Manoharan &fops_base_eeprom); 19153f4c4bddSRajkumar Manoharan debugfs_create_file("modal_eeprom", S_IRUSR, sc->debug.debugfs_phy, sc, 19163f4c4bddSRajkumar Manoharan &fops_modal_eeprom); 1917e93d083fSSimon Wunderlich sc->rfs_chan_spec_scan = relay_open("spectral_scan", 1918e93d083fSSimon Wunderlich sc->debug.debugfs_phy, 191955f39e67SZefir Kurtisi 1024, 256, &rfs_spec_scan_cb, 1920e93d083fSSimon Wunderlich NULL); 1921e93d083fSSimon Wunderlich debugfs_create_file("spectral_scan_ctl", S_IRUSR | S_IWUSR, 1922e93d083fSSimon Wunderlich sc->debug.debugfs_phy, sc, 1923e93d083fSSimon Wunderlich &fops_spec_scan_ctl); 192404ccd4a1SSimon Wunderlich debugfs_create_file("spectral_short_repeat", S_IRUSR | S_IWUSR, 192504ccd4a1SSimon Wunderlich sc->debug.debugfs_phy, sc, 192604ccd4a1SSimon Wunderlich &fops_spectral_short_repeat); 192704ccd4a1SSimon Wunderlich debugfs_create_file("spectral_count", S_IRUSR | S_IWUSR, 192804ccd4a1SSimon Wunderlich sc->debug.debugfs_phy, sc, &fops_spectral_count); 192904ccd4a1SSimon Wunderlich debugfs_create_file("spectral_period", S_IRUSR | S_IWUSR, 193004ccd4a1SSimon Wunderlich sc->debug.debugfs_phy, sc, &fops_spectral_period); 193104ccd4a1SSimon Wunderlich debugfs_create_file("spectral_fft_period", S_IRUSR | S_IWUSR, 193204ccd4a1SSimon Wunderlich sc->debug.debugfs_phy, sc, 193304ccd4a1SSimon Wunderlich &fops_spectral_fft_period); 1934691680b8SFelix Fietkau debugfs_create_u32("gpio_mask", S_IRUSR | S_IWUSR, 1935691680b8SFelix Fietkau sc->debug.debugfs_phy, &sc->sc_ah->gpio_mask); 1936691680b8SFelix Fietkau debugfs_create_u32("gpio_val", S_IRUSR | S_IWUSR, 1937691680b8SFelix Fietkau sc->debug.debugfs_phy, &sc->sc_ah->gpio_val); 193863081305SSujith Manoharan debugfs_create_file("bt_ant_diversity", S_IRUSR | S_IWUSR, 193963081305SSujith Manoharan sc->debug.debugfs_phy, sc, &fops_bt_ant_diversity); 19404eba10ccSSujith Manoharan debugfs_create_file("antenna_diversity", S_IRUSR, 19414eba10ccSSujith Manoharan sc->debug.debugfs_phy, sc, &fops_antenna_diversity); 19424df50ca8SRajkumar Manoharan #ifdef CONFIG_ATH9K_BTCOEX_SUPPORT 19434df50ca8SRajkumar Manoharan debugfs_create_file("btcoex", S_IRUSR, sc->debug.debugfs_phy, sc, 19444df50ca8SRajkumar Manoharan &fops_btcoex); 19454df50ca8SRajkumar Manoharan #endif 1946203c4805SLuis R. Rodriguez return 0; 1947203c4805SLuis R. Rodriguez } 1948