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 273*36e8825eSSujith Manoharan #ifdef CONFIG_ATH9K_BTCOEX_SUPPORT 274*36e8825eSSujith Manoharan 27563081305SSujith Manoharan static ssize_t read_file_bt_ant_diversity(struct file *file, 27663081305SSujith Manoharan char __user *user_buf, 277302a3c3aSSujith Manoharan size_t count, loff_t *ppos) 278302a3c3aSSujith Manoharan { 279302a3c3aSSujith Manoharan struct ath_softc *sc = file->private_data; 280302a3c3aSSujith Manoharan struct ath_common *common = ath9k_hw_common(sc->sc_ah); 281302a3c3aSSujith Manoharan char buf[32]; 282302a3c3aSSujith Manoharan unsigned int len; 283302a3c3aSSujith Manoharan 28463081305SSujith Manoharan len = sprintf(buf, "%d\n", common->bt_ant_diversity); 285302a3c3aSSujith Manoharan return simple_read_from_buffer(user_buf, count, ppos, buf, len); 286302a3c3aSSujith Manoharan } 287302a3c3aSSujith Manoharan 28863081305SSujith Manoharan static ssize_t write_file_bt_ant_diversity(struct file *file, 289302a3c3aSSujith Manoharan const char __user *user_buf, 290302a3c3aSSujith Manoharan size_t count, loff_t *ppos) 291302a3c3aSSujith Manoharan { 292302a3c3aSSujith Manoharan struct ath_softc *sc = file->private_data; 293302a3c3aSSujith Manoharan struct ath_common *common = ath9k_hw_common(sc->sc_ah); 2943f2da955SSujith Manoharan struct ath9k_hw_capabilities *pCap = &sc->sc_ah->caps; 29563081305SSujith Manoharan unsigned long bt_ant_diversity; 296302a3c3aSSujith Manoharan char buf[32]; 297302a3c3aSSujith Manoharan ssize_t len; 298302a3c3aSSujith Manoharan 299302a3c3aSSujith Manoharan len = min(count, sizeof(buf) - 1); 300302a3c3aSSujith Manoharan if (copy_from_user(buf, user_buf, len)) 301302a3c3aSSujith Manoharan return -EFAULT; 302302a3c3aSSujith Manoharan 3033f2da955SSujith Manoharan if (!(pCap->hw_caps & ATH9K_HW_CAP_BT_ANT_DIV)) 3043f2da955SSujith Manoharan goto exit; 3053f2da955SSujith Manoharan 306302a3c3aSSujith Manoharan buf[len] = '\0'; 30763081305SSujith Manoharan if (kstrtoul(buf, 0, &bt_ant_diversity)) 308302a3c3aSSujith Manoharan return -EINVAL; 309302a3c3aSSujith Manoharan 31063081305SSujith Manoharan common->bt_ant_diversity = !!bt_ant_diversity; 311302a3c3aSSujith Manoharan ath9k_ps_wakeup(sc); 312047dc3acSSujith Manoharan ath9k_hw_set_bt_ant_diversity(sc->sc_ah, common->bt_ant_diversity); 31363081305SSujith Manoharan ath_dbg(common, CONFIG, "Enable WLAN/BT RX Antenna diversity: %d\n", 31463081305SSujith Manoharan common->bt_ant_diversity); 315302a3c3aSSujith Manoharan ath9k_ps_restore(sc); 3163f2da955SSujith Manoharan exit: 317302a3c3aSSujith Manoharan return count; 318302a3c3aSSujith Manoharan } 319302a3c3aSSujith Manoharan 32063081305SSujith Manoharan static const struct file_operations fops_bt_ant_diversity = { 32163081305SSujith Manoharan .read = read_file_bt_ant_diversity, 32263081305SSujith Manoharan .write = write_file_bt_ant_diversity, 323302a3c3aSSujith Manoharan .open = simple_open, 324302a3c3aSSujith Manoharan .owner = THIS_MODULE, 325302a3c3aSSujith Manoharan .llseek = default_llseek, 326302a3c3aSSujith Manoharan }; 327302a3c3aSSujith Manoharan 328*36e8825eSSujith Manoharan #endif 329*36e8825eSSujith Manoharan 330e3d52914SSujith Manoharan void ath9k_debug_stat_ant(struct ath_softc *sc, 331e3d52914SSujith Manoharan struct ath_hw_antcomb_conf *div_ant_conf, 332e3d52914SSujith Manoharan int main_rssi_avg, int alt_rssi_avg) 333e3d52914SSujith Manoharan { 334e3d52914SSujith Manoharan struct ath_antenna_stats *as_main = &sc->debug.stats.ant_stats[ANT_MAIN]; 335e3d52914SSujith Manoharan struct ath_antenna_stats *as_alt = &sc->debug.stats.ant_stats[ANT_ALT]; 336e3d52914SSujith Manoharan 337e3d52914SSujith Manoharan as_main->lna_attempt_cnt[div_ant_conf->main_lna_conf]++; 338e3d52914SSujith Manoharan as_alt->lna_attempt_cnt[div_ant_conf->alt_lna_conf]++; 339e3d52914SSujith Manoharan 340e3d52914SSujith Manoharan as_main->rssi_avg = main_rssi_avg; 341e3d52914SSujith Manoharan as_alt->rssi_avg = alt_rssi_avg; 342e3d52914SSujith Manoharan } 343e3d52914SSujith Manoharan 3444eba10ccSSujith Manoharan static ssize_t read_file_antenna_diversity(struct file *file, 3454eba10ccSSujith Manoharan char __user *user_buf, 3464eba10ccSSujith Manoharan size_t count, loff_t *ppos) 3474eba10ccSSujith Manoharan { 3484eba10ccSSujith Manoharan struct ath_softc *sc = file->private_data; 3494eba10ccSSujith Manoharan struct ath_hw *ah = sc->sc_ah; 3504eba10ccSSujith Manoharan struct ath9k_hw_capabilities *pCap = &ah->caps; 3514eba10ccSSujith Manoharan struct ath_antenna_stats *as_main = &sc->debug.stats.ant_stats[ANT_MAIN]; 3524eba10ccSSujith Manoharan struct ath_antenna_stats *as_alt = &sc->debug.stats.ant_stats[ANT_ALT]; 353e3d52914SSujith Manoharan struct ath_hw_antcomb_conf div_ant_conf; 3544eba10ccSSujith Manoharan unsigned int len = 0, size = 1024; 3554eba10ccSSujith Manoharan ssize_t retval = 0; 3564eba10ccSSujith Manoharan char *buf; 357e3d52914SSujith Manoharan char *lna_conf_str[4] = {"LNA1_MINUS_LNA2", 358e3d52914SSujith Manoharan "LNA2", 359e3d52914SSujith Manoharan "LNA1", 360e3d52914SSujith Manoharan "LNA1_PLUS_LNA2"}; 3614eba10ccSSujith Manoharan 3624eba10ccSSujith Manoharan buf = kzalloc(size, GFP_KERNEL); 3634eba10ccSSujith Manoharan if (buf == NULL) 3644eba10ccSSujith Manoharan return -ENOMEM; 3654eba10ccSSujith Manoharan 3664eba10ccSSujith Manoharan if (!(pCap->hw_caps & ATH9K_HW_CAP_ANT_DIV_COMB)) { 3674eba10ccSSujith Manoharan len += snprintf(buf + len, size - len, "%s\n", 3684eba10ccSSujith Manoharan "Antenna Diversity Combining is disabled"); 3694eba10ccSSujith Manoharan goto exit; 3704eba10ccSSujith Manoharan } 3714eba10ccSSujith Manoharan 372e3d52914SSujith Manoharan ath9k_ps_wakeup(sc); 373e3d52914SSujith Manoharan ath9k_hw_antdiv_comb_conf_get(ah, &div_ant_conf); 374e3d52914SSujith Manoharan len += snprintf(buf + len, size - len, "Current MAIN config : %s\n", 375e3d52914SSujith Manoharan lna_conf_str[div_ant_conf.main_lna_conf]); 376e3d52914SSujith Manoharan len += snprintf(buf + len, size - len, "Current ALT config : %s\n", 377e3d52914SSujith Manoharan lna_conf_str[div_ant_conf.alt_lna_conf]); 378e3d52914SSujith Manoharan len += snprintf(buf + len, size - len, "Average MAIN RSSI : %d\n", 379e3d52914SSujith Manoharan as_main->rssi_avg); 380e3d52914SSujith Manoharan len += snprintf(buf + len, size - len, "Average ALT RSSI : %d\n\n", 381e3d52914SSujith Manoharan as_alt->rssi_avg); 382e3d52914SSujith Manoharan ath9k_ps_restore(sc); 383e3d52914SSujith Manoharan 384e3d52914SSujith Manoharan len += snprintf(buf + len, size - len, "Packet Receive Cnt:\n"); 385e3d52914SSujith Manoharan len += snprintf(buf + len, size - len, "-------------------\n"); 386e3d52914SSujith Manoharan 3874eba10ccSSujith Manoharan len += snprintf(buf + len, size - len, "%30s%15s\n", 3884eba10ccSSujith Manoharan "MAIN", "ALT"); 389e3d52914SSujith Manoharan len += snprintf(buf + len, size - len, "%-14s:%15d%15d\n", 390e3d52914SSujith Manoharan "TOTAL COUNT", 3914eba10ccSSujith Manoharan as_main->recv_cnt, 3924eba10ccSSujith Manoharan as_alt->recv_cnt); 393e3d52914SSujith Manoharan len += snprintf(buf + len, size - len, "%-14s:%15d%15d\n", 3944eba10ccSSujith Manoharan "LNA1", 395e3d52914SSujith Manoharan as_main->lna_recv_cnt[ATH_ANT_DIV_COMB_LNA1], 396e3d52914SSujith Manoharan as_alt->lna_recv_cnt[ATH_ANT_DIV_COMB_LNA1]); 397e3d52914SSujith Manoharan len += snprintf(buf + len, size - len, "%-14s:%15d%15d\n", 3984eba10ccSSujith Manoharan "LNA2", 399e3d52914SSujith Manoharan as_main->lna_recv_cnt[ATH_ANT_DIV_COMB_LNA2], 400e3d52914SSujith Manoharan as_alt->lna_recv_cnt[ATH_ANT_DIV_COMB_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_PLUS_LNA2], 404e3d52914SSujith Manoharan as_alt->lna_recv_cnt[ATH_ANT_DIV_COMB_LNA1_PLUS_LNA2]); 405e3d52914SSujith Manoharan len += snprintf(buf + len, size - len, "%-14s:%15d%15d\n", 4064eba10ccSSujith Manoharan "LNA1 - LNA2", 407e3d52914SSujith Manoharan as_main->lna_recv_cnt[ATH_ANT_DIV_COMB_LNA1_MINUS_LNA2], 408e3d52914SSujith Manoharan as_alt->lna_recv_cnt[ATH_ANT_DIV_COMB_LNA1_MINUS_LNA2]); 409e3d52914SSujith Manoharan 410e3d52914SSujith Manoharan len += snprintf(buf + len, size - len, "\nLNA Config Attempts:\n"); 411e3d52914SSujith Manoharan len += snprintf(buf + len, size - len, "--------------------\n"); 412e3d52914SSujith Manoharan 413e3d52914SSujith Manoharan len += snprintf(buf + len, size - len, "%30s%15s\n", 414e3d52914SSujith Manoharan "MAIN", "ALT"); 415e3d52914SSujith Manoharan len += snprintf(buf + len, size - len, "%-14s:%15d%15d\n", 416e3d52914SSujith Manoharan "LNA1", 417e3d52914SSujith Manoharan as_main->lna_attempt_cnt[ATH_ANT_DIV_COMB_LNA1], 418e3d52914SSujith Manoharan as_alt->lna_attempt_cnt[ATH_ANT_DIV_COMB_LNA1]); 419e3d52914SSujith Manoharan len += snprintf(buf + len, size - len, "%-14s:%15d%15d\n", 420e3d52914SSujith Manoharan "LNA2", 421e3d52914SSujith Manoharan as_main->lna_attempt_cnt[ATH_ANT_DIV_COMB_LNA2], 422e3d52914SSujith Manoharan as_alt->lna_attempt_cnt[ATH_ANT_DIV_COMB_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_PLUS_LNA2], 426e3d52914SSujith Manoharan as_alt->lna_attempt_cnt[ATH_ANT_DIV_COMB_LNA1_PLUS_LNA2]); 427e3d52914SSujith Manoharan len += snprintf(buf + len, size - len, "%-14s:%15d%15d\n", 428e3d52914SSujith Manoharan "LNA1 - LNA2", 429e3d52914SSujith Manoharan as_main->lna_attempt_cnt[ATH_ANT_DIV_COMB_LNA1_MINUS_LNA2], 430e3d52914SSujith Manoharan as_alt->lna_attempt_cnt[ATH_ANT_DIV_COMB_LNA1_MINUS_LNA2]); 431e3d52914SSujith Manoharan 4324eba10ccSSujith Manoharan exit: 4334eba10ccSSujith Manoharan if (len > size) 4344eba10ccSSujith Manoharan len = size; 4354eba10ccSSujith Manoharan 4364eba10ccSSujith Manoharan retval = simple_read_from_buffer(user_buf, count, ppos, buf, len); 4374eba10ccSSujith Manoharan kfree(buf); 4384eba10ccSSujith Manoharan 4394eba10ccSSujith Manoharan return retval; 4404eba10ccSSujith Manoharan } 4414eba10ccSSujith Manoharan 4424eba10ccSSujith Manoharan static const struct file_operations fops_antenna_diversity = { 4434eba10ccSSujith Manoharan .read = read_file_antenna_diversity, 4444eba10ccSSujith Manoharan .open = simple_open, 4454eba10ccSSujith Manoharan .owner = THIS_MODULE, 4464eba10ccSSujith Manoharan .llseek = default_llseek, 4474eba10ccSSujith Manoharan }; 4484eba10ccSSujith Manoharan 449203c4805SLuis R. Rodriguez static ssize_t read_file_dma(struct file *file, char __user *user_buf, 450203c4805SLuis R. Rodriguez size_t count, loff_t *ppos) 451203c4805SLuis R. Rodriguez { 452203c4805SLuis R. Rodriguez struct ath_softc *sc = file->private_data; 453203c4805SLuis R. Rodriguez struct ath_hw *ah = sc->sc_ah; 454991a0987SPavel Roskin char *buf; 455991a0987SPavel Roskin int retval; 456203c4805SLuis R. Rodriguez unsigned int len = 0; 457203c4805SLuis R. Rodriguez u32 val[ATH9K_NUM_DMA_DEBUG_REGS]; 458203c4805SLuis R. Rodriguez int i, qcuOffset = 0, dcuOffset = 0; 459203c4805SLuis R. Rodriguez u32 *qcuBase = &val[0], *dcuBase = &val[4]; 460203c4805SLuis R. Rodriguez 461991a0987SPavel Roskin buf = kmalloc(DMA_BUF_LEN, GFP_KERNEL); 462991a0987SPavel Roskin if (!buf) 46304236066SDan Carpenter return -ENOMEM; 464991a0987SPavel Roskin 4657cf4a2e7SSujith ath9k_ps_wakeup(sc); 4667cf4a2e7SSujith 467475a6e4dSLuis R. Rodriguez REG_WRITE_D(ah, AR_MACMISC, 468203c4805SLuis R. Rodriguez ((AR_MACMISC_DMA_OBS_LINE_8 << AR_MACMISC_DMA_OBS_S) | 469203c4805SLuis R. Rodriguez (AR_MACMISC_MISC_OBS_BUS_1 << 470203c4805SLuis R. Rodriguez AR_MACMISC_MISC_OBS_BUS_MSB_S))); 471203c4805SLuis R. Rodriguez 472991a0987SPavel Roskin len += snprintf(buf + len, DMA_BUF_LEN - len, 473203c4805SLuis R. Rodriguez "Raw DMA Debug values:\n"); 474203c4805SLuis R. Rodriguez 475203c4805SLuis R. Rodriguez for (i = 0; i < ATH9K_NUM_DMA_DEBUG_REGS; i++) { 476203c4805SLuis R. Rodriguez if (i % 4 == 0) 477991a0987SPavel Roskin len += snprintf(buf + len, DMA_BUF_LEN - len, "\n"); 478203c4805SLuis R. Rodriguez 479475a6e4dSLuis R. Rodriguez val[i] = REG_READ_D(ah, AR_DMADBG_0 + (i * sizeof(u32))); 480991a0987SPavel Roskin len += snprintf(buf + len, DMA_BUF_LEN - len, "%d: %08x ", 481203c4805SLuis R. Rodriguez i, val[i]); 482203c4805SLuis R. Rodriguez } 483203c4805SLuis R. Rodriguez 484991a0987SPavel Roskin len += snprintf(buf + len, DMA_BUF_LEN - len, "\n\n"); 485991a0987SPavel Roskin len += snprintf(buf + len, DMA_BUF_LEN - len, 486203c4805SLuis R. Rodriguez "Num QCU: chain_st fsp_ok fsp_st DCU: chain_st\n"); 487203c4805SLuis R. Rodriguez 488203c4805SLuis R. Rodriguez for (i = 0; i < ATH9K_NUM_QUEUES; i++, qcuOffset += 4, dcuOffset += 5) { 489203c4805SLuis R. Rodriguez if (i == 8) { 490203c4805SLuis R. Rodriguez qcuOffset = 0; 491203c4805SLuis R. Rodriguez qcuBase++; 492203c4805SLuis R. Rodriguez } 493203c4805SLuis R. Rodriguez 494203c4805SLuis R. Rodriguez if (i == 6) { 495203c4805SLuis R. Rodriguez dcuOffset = 0; 496203c4805SLuis R. Rodriguez dcuBase++; 497203c4805SLuis R. Rodriguez } 498203c4805SLuis R. Rodriguez 499991a0987SPavel Roskin len += snprintf(buf + len, DMA_BUF_LEN - len, 500203c4805SLuis R. Rodriguez "%2d %2x %1x %2x %2x\n", 501203c4805SLuis R. Rodriguez i, (*qcuBase & (0x7 << qcuOffset)) >> qcuOffset, 502203c4805SLuis R. Rodriguez (*qcuBase & (0x8 << qcuOffset)) >> (qcuOffset + 3), 503203c4805SLuis R. Rodriguez val[2] & (0x7 << (i * 3)) >> (i * 3), 504203c4805SLuis R. Rodriguez (*dcuBase & (0x1f << dcuOffset)) >> dcuOffset); 505203c4805SLuis R. Rodriguez } 506203c4805SLuis R. Rodriguez 507991a0987SPavel Roskin len += snprintf(buf + len, DMA_BUF_LEN - len, "\n"); 508203c4805SLuis R. Rodriguez 509991a0987SPavel Roskin len += snprintf(buf + len, DMA_BUF_LEN - len, 510203c4805SLuis R. Rodriguez "qcu_stitch state: %2x qcu_fetch state: %2x\n", 511203c4805SLuis R. Rodriguez (val[3] & 0x003c0000) >> 18, (val[3] & 0x03c00000) >> 22); 512991a0987SPavel Roskin len += snprintf(buf + len, DMA_BUF_LEN - len, 513203c4805SLuis R. Rodriguez "qcu_complete state: %2x dcu_complete state: %2x\n", 514203c4805SLuis R. Rodriguez (val[3] & 0x1c000000) >> 26, (val[6] & 0x3)); 515991a0987SPavel Roskin len += snprintf(buf + len, DMA_BUF_LEN - len, 516203c4805SLuis R. Rodriguez "dcu_arb state: %2x dcu_fp state: %2x\n", 517203c4805SLuis R. Rodriguez (val[5] & 0x06000000) >> 25, (val[5] & 0x38000000) >> 27); 518991a0987SPavel Roskin len += snprintf(buf + len, DMA_BUF_LEN - len, 519203c4805SLuis R. Rodriguez "chan_idle_dur: %3d chan_idle_dur_valid: %1d\n", 520203c4805SLuis R. Rodriguez (val[6] & 0x000003fc) >> 2, (val[6] & 0x00000400) >> 10); 521991a0987SPavel Roskin len += snprintf(buf + len, DMA_BUF_LEN - len, 522203c4805SLuis R. Rodriguez "txfifo_valid_0: %1d txfifo_valid_1: %1d\n", 523203c4805SLuis R. Rodriguez (val[6] & 0x00000800) >> 11, (val[6] & 0x00001000) >> 12); 524991a0987SPavel Roskin len += snprintf(buf + len, DMA_BUF_LEN - len, 525203c4805SLuis R. Rodriguez "txfifo_dcu_num_0: %2d txfifo_dcu_num_1: %2d\n", 526203c4805SLuis R. Rodriguez (val[6] & 0x0001e000) >> 13, (val[6] & 0x001e0000) >> 17); 527203c4805SLuis R. Rodriguez 528991a0987SPavel Roskin len += snprintf(buf + len, DMA_BUF_LEN - len, "pcu observe: 0x%x\n", 529475a6e4dSLuis R. Rodriguez REG_READ_D(ah, AR_OBS_BUS_1)); 530991a0987SPavel Roskin len += snprintf(buf + len, DMA_BUF_LEN - len, 531475a6e4dSLuis R. Rodriguez "AR_CR: 0x%x\n", REG_READ_D(ah, AR_CR)); 532203c4805SLuis R. Rodriguez 5337cf4a2e7SSujith ath9k_ps_restore(sc); 5347cf4a2e7SSujith 5352b87f3aaSDan Carpenter if (len > DMA_BUF_LEN) 5362b87f3aaSDan Carpenter len = DMA_BUF_LEN; 5372b87f3aaSDan Carpenter 538991a0987SPavel Roskin retval = simple_read_from_buffer(user_buf, count, ppos, buf, len); 539991a0987SPavel Roskin kfree(buf); 540991a0987SPavel Roskin return retval; 541203c4805SLuis R. Rodriguez } 542203c4805SLuis R. Rodriguez 543203c4805SLuis R. Rodriguez static const struct file_operations fops_dma = { 544203c4805SLuis R. Rodriguez .read = read_file_dma, 545234e3405SStephen Boyd .open = simple_open, 5466038f373SArnd Bergmann .owner = THIS_MODULE, 5476038f373SArnd Bergmann .llseek = default_llseek, 548203c4805SLuis R. Rodriguez }; 549203c4805SLuis R. Rodriguez 550203c4805SLuis R. Rodriguez 551203c4805SLuis R. Rodriguez void ath_debug_stat_interrupt(struct ath_softc *sc, enum ath9k_int status) 552203c4805SLuis R. Rodriguez { 553203c4805SLuis R. Rodriguez if (status) 554203c4805SLuis R. Rodriguez sc->debug.stats.istats.total++; 555a9616f41SLuis R. Rodriguez if (sc->sc_ah->caps.hw_caps & ATH9K_HW_CAP_EDMA) { 556a9616f41SLuis R. Rodriguez if (status & ATH9K_INT_RXLP) 557a9616f41SLuis R. Rodriguez sc->debug.stats.istats.rxlp++; 558a9616f41SLuis R. Rodriguez if (status & ATH9K_INT_RXHP) 559a9616f41SLuis R. Rodriguez sc->debug.stats.istats.rxhp++; 56008578b8fSLuis R. Rodriguez if (status & ATH9K_INT_BB_WATCHDOG) 56108578b8fSLuis R. Rodriguez sc->debug.stats.istats.bb_watchdog++; 562a9616f41SLuis R. Rodriguez } else { 563203c4805SLuis R. Rodriguez if (status & ATH9K_INT_RX) 564203c4805SLuis R. Rodriguez sc->debug.stats.istats.rxok++; 565a9616f41SLuis R. Rodriguez } 566203c4805SLuis R. Rodriguez if (status & ATH9K_INT_RXEOL) 567203c4805SLuis R. Rodriguez sc->debug.stats.istats.rxeol++; 568203c4805SLuis R. Rodriguez if (status & ATH9K_INT_RXORN) 569203c4805SLuis R. Rodriguez sc->debug.stats.istats.rxorn++; 570203c4805SLuis R. Rodriguez if (status & ATH9K_INT_TX) 571203c4805SLuis R. Rodriguez sc->debug.stats.istats.txok++; 572203c4805SLuis R. Rodriguez if (status & ATH9K_INT_TXURN) 573203c4805SLuis R. Rodriguez sc->debug.stats.istats.txurn++; 574203c4805SLuis R. Rodriguez if (status & ATH9K_INT_RXPHY) 575203c4805SLuis R. Rodriguez sc->debug.stats.istats.rxphyerr++; 576203c4805SLuis R. Rodriguez if (status & ATH9K_INT_RXKCM) 577203c4805SLuis R. Rodriguez sc->debug.stats.istats.rx_keycache_miss++; 578203c4805SLuis R. Rodriguez if (status & ATH9K_INT_SWBA) 579203c4805SLuis R. Rodriguez sc->debug.stats.istats.swba++; 580203c4805SLuis R. Rodriguez if (status & ATH9K_INT_BMISS) 581203c4805SLuis R. Rodriguez sc->debug.stats.istats.bmiss++; 582203c4805SLuis R. Rodriguez if (status & ATH9K_INT_BNR) 583203c4805SLuis R. Rodriguez sc->debug.stats.istats.bnr++; 584203c4805SLuis R. Rodriguez if (status & ATH9K_INT_CST) 585203c4805SLuis R. Rodriguez sc->debug.stats.istats.cst++; 586203c4805SLuis R. Rodriguez if (status & ATH9K_INT_GTT) 587203c4805SLuis R. Rodriguez sc->debug.stats.istats.gtt++; 588203c4805SLuis R. Rodriguez if (status & ATH9K_INT_TIM) 589203c4805SLuis R. Rodriguez sc->debug.stats.istats.tim++; 590203c4805SLuis R. Rodriguez if (status & ATH9K_INT_CABEND) 591203c4805SLuis R. Rodriguez sc->debug.stats.istats.cabend++; 592203c4805SLuis R. Rodriguez if (status & ATH9K_INT_DTIMSYNC) 593203c4805SLuis R. Rodriguez sc->debug.stats.istats.dtimsync++; 594203c4805SLuis R. Rodriguez if (status & ATH9K_INT_DTIM) 595203c4805SLuis R. Rodriguez sc->debug.stats.istats.dtim++; 5966dde1aabSMohammed Shafi Shajakhan if (status & ATH9K_INT_TSFOOR) 5976dde1aabSMohammed Shafi Shajakhan sc->debug.stats.istats.tsfoor++; 59897ba515aSSujith Manoharan if (status & ATH9K_INT_MCI) 59997ba515aSSujith Manoharan sc->debug.stats.istats.mci++; 600c9e6e980SMohammed Shafi Shajakhan if (status & ATH9K_INT_GENTIMER) 601c9e6e980SMohammed Shafi Shajakhan sc->debug.stats.istats.gen_timer++; 602203c4805SLuis R. Rodriguez } 603203c4805SLuis R. Rodriguez 604203c4805SLuis R. Rodriguez static ssize_t read_file_interrupt(struct file *file, char __user *user_buf, 605203c4805SLuis R. Rodriguez size_t count, loff_t *ppos) 606203c4805SLuis R. Rodriguez { 607203c4805SLuis R. Rodriguez struct ath_softc *sc = file->private_data; 608203c4805SLuis R. Rodriguez unsigned int len = 0; 609462e58f2SBen Greear int rv; 610462e58f2SBen Greear int mxlen = 4000; 611462e58f2SBen Greear char *buf = kmalloc(mxlen, GFP_KERNEL); 612462e58f2SBen Greear if (!buf) 613462e58f2SBen Greear return -ENOMEM; 614462e58f2SBen Greear 615462e58f2SBen Greear #define PR_IS(a, s) \ 616462e58f2SBen Greear do { \ 617462e58f2SBen Greear len += snprintf(buf + len, mxlen - len, \ 618462e58f2SBen Greear "%21s: %10u\n", a, \ 619462e58f2SBen Greear sc->debug.stats.istats.s); \ 620462e58f2SBen Greear } while (0) 621203c4805SLuis R. Rodriguez 622a9616f41SLuis R. Rodriguez if (sc->sc_ah->caps.hw_caps & ATH9K_HW_CAP_EDMA) { 623462e58f2SBen Greear PR_IS("RXLP", rxlp); 624462e58f2SBen Greear PR_IS("RXHP", rxhp); 625462e58f2SBen Greear PR_IS("WATHDOG", bb_watchdog); 626a9616f41SLuis R. Rodriguez } else { 627462e58f2SBen Greear PR_IS("RX", rxok); 628a9616f41SLuis R. Rodriguez } 629462e58f2SBen Greear PR_IS("RXEOL", rxeol); 630462e58f2SBen Greear PR_IS("RXORN", rxorn); 631462e58f2SBen Greear PR_IS("TX", txok); 632462e58f2SBen Greear PR_IS("TXURN", txurn); 633462e58f2SBen Greear PR_IS("MIB", mib); 634462e58f2SBen Greear PR_IS("RXPHY", rxphyerr); 635462e58f2SBen Greear PR_IS("RXKCM", rx_keycache_miss); 636462e58f2SBen Greear PR_IS("SWBA", swba); 637462e58f2SBen Greear PR_IS("BMISS", bmiss); 638462e58f2SBen Greear PR_IS("BNR", bnr); 639462e58f2SBen Greear PR_IS("CST", cst); 640462e58f2SBen Greear PR_IS("GTT", gtt); 641462e58f2SBen Greear PR_IS("TIM", tim); 642462e58f2SBen Greear PR_IS("CABEND", cabend); 643462e58f2SBen Greear PR_IS("DTIMSYNC", dtimsync); 644462e58f2SBen Greear PR_IS("DTIM", dtim); 645462e58f2SBen Greear PR_IS("TSFOOR", tsfoor); 64697ba515aSSujith Manoharan PR_IS("MCI", mci); 647c9e6e980SMohammed Shafi Shajakhan PR_IS("GENTIMER", gen_timer); 648462e58f2SBen Greear PR_IS("TOTAL", total); 649203c4805SLuis R. Rodriguez 650462e58f2SBen Greear len += snprintf(buf + len, mxlen - len, 651462e58f2SBen Greear "SYNC_CAUSE stats:\n"); 6526dde1aabSMohammed Shafi Shajakhan 653462e58f2SBen Greear PR_IS("Sync-All", sync_cause_all); 654462e58f2SBen Greear PR_IS("RTC-IRQ", sync_rtc_irq); 655462e58f2SBen Greear PR_IS("MAC-IRQ", sync_mac_irq); 656462e58f2SBen Greear PR_IS("EEPROM-Illegal-Access", eeprom_illegal_access); 657462e58f2SBen Greear PR_IS("APB-Timeout", apb_timeout); 658462e58f2SBen Greear PR_IS("PCI-Mode-Conflict", pci_mode_conflict); 659462e58f2SBen Greear PR_IS("HOST1-Fatal", host1_fatal); 660462e58f2SBen Greear PR_IS("HOST1-Perr", host1_perr); 661462e58f2SBen Greear PR_IS("TRCV-FIFO-Perr", trcv_fifo_perr); 662462e58f2SBen Greear PR_IS("RADM-CPL-EP", radm_cpl_ep); 663462e58f2SBen Greear PR_IS("RADM-CPL-DLLP-Abort", radm_cpl_dllp_abort); 664462e58f2SBen Greear PR_IS("RADM-CPL-TLP-Abort", radm_cpl_tlp_abort); 665462e58f2SBen Greear PR_IS("RADM-CPL-ECRC-Err", radm_cpl_ecrc_err); 666462e58f2SBen Greear PR_IS("RADM-CPL-Timeout", radm_cpl_timeout); 667462e58f2SBen Greear PR_IS("Local-Bus-Timeout", local_timeout); 668462e58f2SBen Greear PR_IS("PM-Access", pm_access); 669462e58f2SBen Greear PR_IS("MAC-Awake", mac_awake); 670462e58f2SBen Greear PR_IS("MAC-Asleep", mac_asleep); 671462e58f2SBen Greear PR_IS("MAC-Sleep-Access", mac_sleep_access); 6722b87f3aaSDan Carpenter 673462e58f2SBen Greear if (len > mxlen) 674462e58f2SBen Greear len = mxlen; 675462e58f2SBen Greear 676462e58f2SBen Greear rv = simple_read_from_buffer(user_buf, count, ppos, buf, len); 677462e58f2SBen Greear kfree(buf); 678462e58f2SBen Greear return rv; 679203c4805SLuis R. Rodriguez } 680203c4805SLuis R. Rodriguez 681203c4805SLuis R. Rodriguez static const struct file_operations fops_interrupt = { 682203c4805SLuis R. Rodriguez .read = read_file_interrupt, 683234e3405SStephen Boyd .open = simple_open, 6846038f373SArnd Bergmann .owner = THIS_MODULE, 6856038f373SArnd Bergmann .llseek = default_llseek, 686203c4805SLuis R. Rodriguez }; 687203c4805SLuis R. Rodriguez 688fec247c0SSujith static ssize_t read_file_xmit(struct file *file, char __user *user_buf, 689fec247c0SSujith size_t count, loff_t *ppos) 690fec247c0SSujith { 691fec247c0SSujith struct ath_softc *sc = file->private_data; 692fec247c0SSujith char *buf; 69378ef731cSSujith Manoharan unsigned int len = 0, size = 2048; 694fec247c0SSujith ssize_t retval = 0; 695fec247c0SSujith 696fec247c0SSujith buf = kzalloc(size, GFP_KERNEL); 697fec247c0SSujith if (buf == NULL) 69804236066SDan Carpenter return -ENOMEM; 699fec247c0SSujith 70078ef731cSSujith Manoharan len += sprintf(buf, "%30s %10s%10s%10s\n\n", 7017f010c93SBen Greear "BE", "BK", "VI", "VO"); 702fec247c0SSujith 703fec247c0SSujith PR("MPDUs Queued: ", queued); 704fec247c0SSujith PR("MPDUs Completed: ", completed); 7055a6f78afSFelix Fietkau PR("MPDUs XRetried: ", xretries); 706fec247c0SSujith PR("Aggregates: ", a_aggr); 707bda8addaSBen Greear PR("AMPDUs Queued HW:", a_queued_hw); 708bda8addaSBen Greear PR("AMPDUs Queued SW:", a_queued_sw); 709fec247c0SSujith PR("AMPDUs Completed:", a_completed); 710fec247c0SSujith PR("AMPDUs Retried: ", a_retries); 711fec247c0SSujith PR("AMPDUs XRetried: ", a_xretries); 7124d900389SBen Greear PR("TXERR Filtered: ", txerr_filtered); 713fec247c0SSujith PR("FIFO Underrun: ", fifo_underrun); 714fec247c0SSujith PR("TXOP Exceeded: ", xtxop); 715fec247c0SSujith PR("TXTIMER Expiry: ", timer_exp); 716fec247c0SSujith PR("DESC CFG Error: ", desc_cfg_err); 717fec247c0SSujith PR("DATA Underrun: ", data_underrun); 718fec247c0SSujith PR("DELIM Underrun: ", delim_underrun); 71999c15bf5SBen Greear PR("TX-Pkts-All: ", tx_pkts_all); 72099c15bf5SBen Greear PR("TX-Bytes-All: ", tx_bytes_all); 72178ef731cSSujith Manoharan PR("HW-put-tx-buf: ", puttxbuf); 72278ef731cSSujith Manoharan PR("HW-tx-start: ", txstart); 72378ef731cSSujith Manoharan PR("HW-tx-proc-desc: ", txprocdesc); 724a5a0bca1SBen Greear PR("TX-Failed: ", txfailed); 725fec247c0SSujith 7267f010c93SBen Greear if (len > size) 7277f010c93SBen Greear len = size; 7287f010c93SBen Greear 7297f010c93SBen Greear retval = simple_read_from_buffer(user_buf, count, ppos, buf, len); 7307f010c93SBen Greear kfree(buf); 7317f010c93SBen Greear 7327f010c93SBen Greear return retval; 7337f010c93SBen Greear } 7347f010c93SBen Greear 735c0b74876SSujith Manoharan static ssize_t read_file_queues(struct file *file, char __user *user_buf, 736c0b74876SSujith Manoharan size_t count, loff_t *ppos) 737c0b74876SSujith Manoharan { 738c0b74876SSujith Manoharan struct ath_softc *sc = file->private_data; 739c0b74876SSujith Manoharan struct ath_txq *txq; 740c0b74876SSujith Manoharan char *buf; 741c0b74876SSujith Manoharan unsigned int len = 0, size = 1024; 742c0b74876SSujith Manoharan ssize_t retval = 0; 743c0b74876SSujith Manoharan int i; 744c0b74876SSujith Manoharan char *qname[4] = {"VO", "VI", "BE", "BK"}; 745c0b74876SSujith Manoharan 746c0b74876SSujith Manoharan buf = kzalloc(size, GFP_KERNEL); 747c0b74876SSujith Manoharan if (buf == NULL) 748c0b74876SSujith Manoharan return -ENOMEM; 749c0b74876SSujith Manoharan 750c0b74876SSujith Manoharan for (i = 0; i < IEEE80211_NUM_ACS; i++) { 751c0b74876SSujith Manoharan txq = sc->tx.txq_map[i]; 752c0b74876SSujith Manoharan len += snprintf(buf + len, size - len, "(%s): ", qname[i]); 753c0b74876SSujith Manoharan 754c0b74876SSujith Manoharan ath_txq_lock(sc, txq); 755c0b74876SSujith Manoharan 756c0b74876SSujith Manoharan len += snprintf(buf + len, size - len, "%s: %d ", 757c0b74876SSujith Manoharan "qnum", txq->axq_qnum); 758c0b74876SSujith Manoharan len += snprintf(buf + len, size - len, "%s: %2d ", 759c0b74876SSujith Manoharan "qdepth", txq->axq_depth); 760c0b74876SSujith Manoharan len += snprintf(buf + len, size - len, "%s: %2d ", 761c0b74876SSujith Manoharan "ampdu-depth", txq->axq_ampdu_depth); 762c0b74876SSujith Manoharan len += snprintf(buf + len, size - len, "%s: %3d ", 763c0b74876SSujith Manoharan "pending", txq->pending_frames); 764c0b74876SSujith Manoharan len += snprintf(buf + len, size - len, "%s: %d\n", 765c0b74876SSujith Manoharan "stopped", txq->stopped); 766c0b74876SSujith Manoharan 767c0b74876SSujith Manoharan ath_txq_unlock(sc, txq); 768c0b74876SSujith Manoharan } 769c0b74876SSujith Manoharan 770c0b74876SSujith Manoharan if (len > size) 771c0b74876SSujith Manoharan len = size; 772c0b74876SSujith Manoharan 773c0b74876SSujith Manoharan retval = simple_read_from_buffer(user_buf, count, ppos, buf, len); 774c0b74876SSujith Manoharan kfree(buf); 775c0b74876SSujith Manoharan 776c0b74876SSujith Manoharan return retval; 777c0b74876SSujith Manoharan } 778c0b74876SSujith Manoharan 77955f6d0ffSBen Greear static ssize_t read_file_misc(struct file *file, char __user *user_buf, 78055f6d0ffSBen Greear size_t count, loff_t *ppos) 78155f6d0ffSBen Greear { 78255f6d0ffSBen Greear struct ath_softc *sc = file->private_data; 78355f6d0ffSBen Greear struct ath_common *common = ath9k_hw_common(sc->sc_ah); 78455f6d0ffSBen Greear struct ieee80211_hw *hw = sc->hw; 7856bcf6f64SSujith Manoharan struct ath9k_vif_iter_data iter_data; 7866bcf6f64SSujith Manoharan char buf[512]; 7876bcf6f64SSujith Manoharan unsigned int len = 0; 78855f6d0ffSBen Greear ssize_t retval = 0; 78955f6d0ffSBen Greear unsigned int reg; 7906bcf6f64SSujith Manoharan u32 rxfilter; 7916bcf6f64SSujith Manoharan 7926bcf6f64SSujith Manoharan len += snprintf(buf + len, sizeof(buf) - len, 7936bcf6f64SSujith Manoharan "BSSID: %pM\n", common->curbssid); 7946bcf6f64SSujith Manoharan len += snprintf(buf + len, sizeof(buf) - len, 7956bcf6f64SSujith Manoharan "BSSID-MASK: %pM\n", common->bssidmask); 7966bcf6f64SSujith Manoharan len += snprintf(buf + len, sizeof(buf) - len, 7976bcf6f64SSujith Manoharan "OPMODE: %s\n", ath_opmode_to_string(sc->sc_ah->opmode)); 7986bcf6f64SSujith Manoharan 7996bcf6f64SSujith Manoharan ath9k_ps_wakeup(sc); 8006bcf6f64SSujith Manoharan rxfilter = ath9k_hw_getrxfilter(sc->sc_ah); 8016bcf6f64SSujith Manoharan ath9k_ps_restore(sc); 8026bcf6f64SSujith Manoharan 8036bcf6f64SSujith Manoharan len += snprintf(buf + len, sizeof(buf) - len, 8046bcf6f64SSujith Manoharan "RXFILTER: 0x%x", rxfilter); 8056bcf6f64SSujith Manoharan 8066bcf6f64SSujith Manoharan if (rxfilter & ATH9K_RX_FILTER_UCAST) 8076bcf6f64SSujith Manoharan len += snprintf(buf + len, sizeof(buf) - len, " UCAST"); 8086bcf6f64SSujith Manoharan if (rxfilter & ATH9K_RX_FILTER_MCAST) 8096bcf6f64SSujith Manoharan len += snprintf(buf + len, sizeof(buf) - len, " MCAST"); 8106bcf6f64SSujith Manoharan if (rxfilter & ATH9K_RX_FILTER_BCAST) 8116bcf6f64SSujith Manoharan len += snprintf(buf + len, sizeof(buf) - len, " BCAST"); 8126bcf6f64SSujith Manoharan if (rxfilter & ATH9K_RX_FILTER_CONTROL) 8136bcf6f64SSujith Manoharan len += snprintf(buf + len, sizeof(buf) - len, " CONTROL"); 8146bcf6f64SSujith Manoharan if (rxfilter & ATH9K_RX_FILTER_BEACON) 8156bcf6f64SSujith Manoharan len += snprintf(buf + len, sizeof(buf) - len, " BEACON"); 8166bcf6f64SSujith Manoharan if (rxfilter & ATH9K_RX_FILTER_PROM) 8176bcf6f64SSujith Manoharan len += snprintf(buf + len, sizeof(buf) - len, " PROM"); 8186bcf6f64SSujith Manoharan if (rxfilter & ATH9K_RX_FILTER_PROBEREQ) 8196bcf6f64SSujith Manoharan len += snprintf(buf + len, sizeof(buf) - len, " PROBEREQ"); 8206bcf6f64SSujith Manoharan if (rxfilter & ATH9K_RX_FILTER_PHYERR) 8216bcf6f64SSujith Manoharan len += snprintf(buf + len, sizeof(buf) - len, " PHYERR"); 8226bcf6f64SSujith Manoharan if (rxfilter & ATH9K_RX_FILTER_MYBEACON) 8236bcf6f64SSujith Manoharan len += snprintf(buf + len, sizeof(buf) - len, " MYBEACON"); 8246bcf6f64SSujith Manoharan if (rxfilter & ATH9K_RX_FILTER_COMP_BAR) 8256bcf6f64SSujith Manoharan len += snprintf(buf + len, sizeof(buf) - len, " COMP_BAR"); 8266bcf6f64SSujith Manoharan if (rxfilter & ATH9K_RX_FILTER_PSPOLL) 8276bcf6f64SSujith Manoharan len += snprintf(buf + len, sizeof(buf) - len, " PSPOLL"); 8286bcf6f64SSujith Manoharan if (rxfilter & ATH9K_RX_FILTER_PHYRADAR) 8296bcf6f64SSujith Manoharan len += snprintf(buf + len, sizeof(buf) - len, " PHYRADAR"); 8306bcf6f64SSujith Manoharan if (rxfilter & ATH9K_RX_FILTER_MCAST_BCAST_ALL) 8316bcf6f64SSujith Manoharan len += snprintf(buf + len, sizeof(buf) - len, " MCAST_BCAST_ALL"); 8326bcf6f64SSujith Manoharan if (rxfilter & ATH9K_RX_FILTER_CONTROL_WRAPPER) 8336bcf6f64SSujith Manoharan len += snprintf(buf + len, sizeof(buf) - len, " CONTROL_WRAPPER"); 8346bcf6f64SSujith Manoharan 8356bcf6f64SSujith Manoharan len += snprintf(buf + len, sizeof(buf) - len, "\n"); 8366bcf6f64SSujith Manoharan 8376bcf6f64SSujith Manoharan reg = sc->sc_ah->imask; 8386bcf6f64SSujith Manoharan 8396bcf6f64SSujith Manoharan len += snprintf(buf + len, sizeof(buf) - len, "INTERRUPT-MASK: 0x%x", reg); 8406bcf6f64SSujith Manoharan 8416bcf6f64SSujith Manoharan if (reg & ATH9K_INT_SWBA) 8426bcf6f64SSujith Manoharan len += snprintf(buf + len, sizeof(buf) - len, " SWBA"); 8436bcf6f64SSujith Manoharan if (reg & ATH9K_INT_BMISS) 8446bcf6f64SSujith Manoharan len += snprintf(buf + len, sizeof(buf) - len, " BMISS"); 8456bcf6f64SSujith Manoharan if (reg & ATH9K_INT_CST) 8466bcf6f64SSujith Manoharan len += snprintf(buf + len, sizeof(buf) - len, " CST"); 8476bcf6f64SSujith Manoharan if (reg & ATH9K_INT_RX) 8486bcf6f64SSujith Manoharan len += snprintf(buf + len, sizeof(buf) - len, " RX"); 8496bcf6f64SSujith Manoharan if (reg & ATH9K_INT_RXHP) 8506bcf6f64SSujith Manoharan len += snprintf(buf + len, sizeof(buf) - len, " RXHP"); 8516bcf6f64SSujith Manoharan if (reg & ATH9K_INT_RXLP) 8526bcf6f64SSujith Manoharan len += snprintf(buf + len, sizeof(buf) - len, " RXLP"); 8536bcf6f64SSujith Manoharan if (reg & ATH9K_INT_BB_WATCHDOG) 8546bcf6f64SSujith Manoharan len += snprintf(buf + len, sizeof(buf) - len, " BB_WATCHDOG"); 8556bcf6f64SSujith Manoharan 8566bcf6f64SSujith Manoharan len += snprintf(buf + len, sizeof(buf) - len, "\n"); 85755f6d0ffSBen Greear 85855f6d0ffSBen Greear ath9k_calculate_iter_data(hw, NULL, &iter_data); 85955f6d0ffSBen Greear 8606bcf6f64SSujith Manoharan len += snprintf(buf + len, sizeof(buf) - len, 8616bcf6f64SSujith Manoharan "VIF-COUNTS: AP: %i STA: %i MESH: %i WDS: %i" 862bcf6f96eSSujith Manoharan " ADHOC: %i TOTAL: %hi BEACON-VIF: %hi\n", 86355f6d0ffSBen Greear iter_data.naps, iter_data.nstations, iter_data.nmeshes, 864bcf6f96eSSujith Manoharan iter_data.nwds, iter_data.nadhocs, 86555f6d0ffSBen Greear sc->nvifs, sc->nbcnvifs); 86655f6d0ffSBen Greear 8676bcf6f64SSujith Manoharan if (len > sizeof(buf)) 8686bcf6f64SSujith Manoharan len = sizeof(buf); 86955f6d0ffSBen Greear 87055f6d0ffSBen Greear retval = simple_read_from_buffer(user_buf, count, ppos, buf, len); 87155f6d0ffSBen Greear return retval; 87255f6d0ffSBen Greear } 87355f6d0ffSBen Greear 874f8b815dcSSujith Manoharan static ssize_t read_file_reset(struct file *file, char __user *user_buf, 875f8b815dcSSujith Manoharan size_t count, loff_t *ppos) 876f8b815dcSSujith Manoharan { 877f8b815dcSSujith Manoharan struct ath_softc *sc = file->private_data; 878f8b815dcSSujith Manoharan char buf[512]; 879f8b815dcSSujith Manoharan unsigned int len = 0; 880f8b815dcSSujith Manoharan 881f8b815dcSSujith Manoharan len += snprintf(buf + len, sizeof(buf) - len, 882f8b815dcSSujith Manoharan "%17s: %2d\n", "Baseband Hang", 883f8b815dcSSujith Manoharan sc->debug.stats.reset[RESET_TYPE_BB_HANG]); 884f8b815dcSSujith Manoharan len += snprintf(buf + len, sizeof(buf) - len, 885f8b815dcSSujith Manoharan "%17s: %2d\n", "Baseband Watchdog", 886f8b815dcSSujith Manoharan sc->debug.stats.reset[RESET_TYPE_BB_WATCHDOG]); 887f8b815dcSSujith Manoharan len += snprintf(buf + len, sizeof(buf) - len, 888f8b815dcSSujith Manoharan "%17s: %2d\n", "Fatal HW Error", 889f8b815dcSSujith Manoharan sc->debug.stats.reset[RESET_TYPE_FATAL_INT]); 890f8b815dcSSujith Manoharan len += snprintf(buf + len, sizeof(buf) - len, 891f8b815dcSSujith Manoharan "%17s: %2d\n", "TX HW error", 892f8b815dcSSujith Manoharan sc->debug.stats.reset[RESET_TYPE_TX_ERROR]); 893f8b815dcSSujith Manoharan len += snprintf(buf + len, sizeof(buf) - len, 894f8b815dcSSujith Manoharan "%17s: %2d\n", "TX Path Hang", 895f8b815dcSSujith Manoharan sc->debug.stats.reset[RESET_TYPE_TX_HANG]); 896f8b815dcSSujith Manoharan len += snprintf(buf + len, sizeof(buf) - len, 897f8b815dcSSujith Manoharan "%17s: %2d\n", "PLL RX Hang", 898f8b815dcSSujith Manoharan sc->debug.stats.reset[RESET_TYPE_PLL_HANG]); 899b88083bfSRajkumar Manoharan len += snprintf(buf + len, sizeof(buf) - len, 900b88083bfSRajkumar Manoharan "%17s: %2d\n", "MCI Reset", 901b88083bfSRajkumar Manoharan sc->debug.stats.reset[RESET_TYPE_MCI]); 902f8b815dcSSujith Manoharan 903f8b815dcSSujith Manoharan if (len > sizeof(buf)) 904f8b815dcSSujith Manoharan len = sizeof(buf); 905f8b815dcSSujith Manoharan 906f8b815dcSSujith Manoharan return simple_read_from_buffer(user_buf, count, ppos, buf, len); 907f8b815dcSSujith Manoharan } 908f8b815dcSSujith Manoharan 909066dae93SFelix Fietkau void ath_debug_stat_tx(struct ath_softc *sc, struct ath_buf *bf, 91055797b1aSFelix Fietkau struct ath_tx_status *ts, struct ath_txq *txq, 91155797b1aSFelix Fietkau unsigned int flags) 912fec247c0SSujith { 9135bec3e5aSFelix Fietkau int qnum = txq->axq_qnum; 914066dae93SFelix Fietkau 915066dae93SFelix Fietkau TX_STAT_INC(qnum, tx_pkts_all); 916066dae93SFelix Fietkau sc->debug.stats.txstats[qnum].tx_bytes_all += bf->bf_mpdu->len; 91799c15bf5SBen Greear 918fec247c0SSujith if (bf_isampdu(bf)) { 919156369faSFelix Fietkau if (flags & ATH_TX_ERROR) 920066dae93SFelix Fietkau TX_STAT_INC(qnum, a_xretries); 921fec247c0SSujith else 922066dae93SFelix Fietkau TX_STAT_INC(qnum, a_completed); 923fec247c0SSujith } else { 92455797b1aSFelix Fietkau if (ts->ts_status & ATH9K_TXERR_XRETRY) 9255a6f78afSFelix Fietkau TX_STAT_INC(qnum, xretries); 9265a6f78afSFelix Fietkau else 927066dae93SFelix Fietkau TX_STAT_INC(qnum, completed); 928fec247c0SSujith } 929fec247c0SSujith 9304d900389SBen Greear if (ts->ts_status & ATH9K_TXERR_FILT) 9314d900389SBen Greear TX_STAT_INC(qnum, txerr_filtered); 932db1a052bSFelix Fietkau if (ts->ts_status & ATH9K_TXERR_FIFO) 933066dae93SFelix Fietkau TX_STAT_INC(qnum, fifo_underrun); 934db1a052bSFelix Fietkau if (ts->ts_status & ATH9K_TXERR_XTXOP) 935066dae93SFelix Fietkau TX_STAT_INC(qnum, xtxop); 936db1a052bSFelix Fietkau if (ts->ts_status & ATH9K_TXERR_TIMER_EXPIRED) 937066dae93SFelix Fietkau TX_STAT_INC(qnum, timer_exp); 938db1a052bSFelix Fietkau if (ts->ts_flags & ATH9K_TX_DESC_CFG_ERR) 939066dae93SFelix Fietkau TX_STAT_INC(qnum, desc_cfg_err); 940db1a052bSFelix Fietkau if (ts->ts_flags & ATH9K_TX_DATA_UNDERRUN) 941066dae93SFelix Fietkau TX_STAT_INC(qnum, data_underrun); 942db1a052bSFelix Fietkau if (ts->ts_flags & ATH9K_TX_DELIM_UNDERRUN) 943066dae93SFelix Fietkau TX_STAT_INC(qnum, delim_underrun); 944fec247c0SSujith } 945fec247c0SSujith 946fec247c0SSujith static const struct file_operations fops_xmit = { 947fec247c0SSujith .read = read_file_xmit, 948234e3405SStephen Boyd .open = simple_open, 9496038f373SArnd Bergmann .owner = THIS_MODULE, 9506038f373SArnd Bergmann .llseek = default_llseek, 951fec247c0SSujith }; 952203c4805SLuis R. Rodriguez 953c0b74876SSujith Manoharan static const struct file_operations fops_queues = { 954c0b74876SSujith Manoharan .read = read_file_queues, 955c0b74876SSujith Manoharan .open = simple_open, 956c0b74876SSujith Manoharan .owner = THIS_MODULE, 957c0b74876SSujith Manoharan .llseek = default_llseek, 958c0b74876SSujith Manoharan }; 959c0b74876SSujith Manoharan 96055f6d0ffSBen Greear static const struct file_operations fops_misc = { 96155f6d0ffSBen Greear .read = read_file_misc, 962234e3405SStephen Boyd .open = simple_open, 96355f6d0ffSBen Greear .owner = THIS_MODULE, 96455f6d0ffSBen Greear .llseek = default_llseek, 96555f6d0ffSBen Greear }; 96655f6d0ffSBen Greear 967f8b815dcSSujith Manoharan static const struct file_operations fops_reset = { 968f8b815dcSSujith Manoharan .read = read_file_reset, 969234e3405SStephen Boyd .open = simple_open, 970f8b815dcSSujith Manoharan .owner = THIS_MODULE, 971f8b815dcSSujith Manoharan .llseek = default_llseek, 972f8b815dcSSujith Manoharan }; 973f8b815dcSSujith Manoharan 9741395d3f0SSujith static ssize_t read_file_recv(struct file *file, char __user *user_buf, 9751395d3f0SSujith size_t count, loff_t *ppos) 9761395d3f0SSujith { 9771395d3f0SSujith #define PHY_ERR(s, p) \ 9784203214eSSujith Manoharan len += snprintf(buf + len, size - len, "%22s : %10u\n", s, \ 9791395d3f0SSujith sc->debug.stats.rxstats.phy_err_stats[p]); 9801395d3f0SSujith 98124a0731eSBen Greear #define RXS_ERR(s, e) \ 98224a0731eSBen Greear do { \ 98324a0731eSBen Greear len += snprintf(buf + len, size - len, \ 98424a0731eSBen Greear "%22s : %10u\n", s, \ 98524a0731eSBen Greear sc->debug.stats.rxstats.e); \ 98624a0731eSBen Greear } while (0) 98724a0731eSBen Greear 9881395d3f0SSujith struct ath_softc *sc = file->private_data; 9891395d3f0SSujith char *buf; 9904203214eSSujith Manoharan unsigned int len = 0, size = 1600; 9911395d3f0SSujith ssize_t retval = 0; 9921395d3f0SSujith 9931395d3f0SSujith buf = kzalloc(size, GFP_KERNEL); 9941395d3f0SSujith if (buf == NULL) 99504236066SDan Carpenter return -ENOMEM; 9961395d3f0SSujith 99724a0731eSBen Greear RXS_ERR("CRC ERR", crc_err); 99824a0731eSBen Greear RXS_ERR("DECRYPT CRC ERR", decrypt_crc_err); 99924a0731eSBen Greear RXS_ERR("PHY ERR", phy_err); 100024a0731eSBen Greear RXS_ERR("MIC ERR", mic_err); 100124a0731eSBen Greear RXS_ERR("PRE-DELIM CRC ERR", pre_delim_crc_err); 100224a0731eSBen Greear RXS_ERR("POST-DELIM CRC ERR", post_delim_crc_err); 100324a0731eSBen Greear RXS_ERR("DECRYPT BUSY ERR", decrypt_busy_err); 100424a0731eSBen Greear RXS_ERR("RX-LENGTH-ERR", rx_len_err); 100524a0731eSBen Greear RXS_ERR("RX-OOM-ERR", rx_oom_err); 100624a0731eSBen Greear RXS_ERR("RX-RATE-ERR", rx_rate_err); 100724a0731eSBen Greear RXS_ERR("RX-TOO-MANY-FRAGS", rx_too_many_frags_err); 10081395d3f0SSujith 10094203214eSSujith Manoharan PHY_ERR("UNDERRUN ERR", ATH9K_PHYERR_UNDERRUN); 10104203214eSSujith Manoharan PHY_ERR("TIMING ERR", ATH9K_PHYERR_TIMING); 10114203214eSSujith Manoharan PHY_ERR("PARITY ERR", ATH9K_PHYERR_PARITY); 10124203214eSSujith Manoharan PHY_ERR("RATE ERR", ATH9K_PHYERR_RATE); 10134203214eSSujith Manoharan PHY_ERR("LENGTH ERR", ATH9K_PHYERR_LENGTH); 10144203214eSSujith Manoharan PHY_ERR("RADAR ERR", ATH9K_PHYERR_RADAR); 10154203214eSSujith Manoharan PHY_ERR("SERVICE ERR", ATH9K_PHYERR_SERVICE); 10164203214eSSujith Manoharan PHY_ERR("TOR ERR", ATH9K_PHYERR_TOR); 10174203214eSSujith Manoharan PHY_ERR("OFDM-TIMING ERR", ATH9K_PHYERR_OFDM_TIMING); 10184203214eSSujith Manoharan PHY_ERR("OFDM-SIGNAL-PARITY ERR", ATH9K_PHYERR_OFDM_SIGNAL_PARITY); 10194203214eSSujith Manoharan PHY_ERR("OFDM-RATE ERR", ATH9K_PHYERR_OFDM_RATE_ILLEGAL); 10204203214eSSujith Manoharan PHY_ERR("OFDM-LENGTH ERR", ATH9K_PHYERR_OFDM_LENGTH_ILLEGAL); 10214203214eSSujith Manoharan PHY_ERR("OFDM-POWER-DROP ERR", ATH9K_PHYERR_OFDM_POWER_DROP); 10224203214eSSujith Manoharan PHY_ERR("OFDM-SERVICE ERR", ATH9K_PHYERR_OFDM_SERVICE); 10234203214eSSujith Manoharan PHY_ERR("OFDM-RESTART ERR", ATH9K_PHYERR_OFDM_RESTART); 10244203214eSSujith Manoharan PHY_ERR("FALSE-RADAR-EXT ERR", ATH9K_PHYERR_FALSE_RADAR_EXT); 10254203214eSSujith Manoharan PHY_ERR("CCK-TIMING ERR", ATH9K_PHYERR_CCK_TIMING); 10264203214eSSujith Manoharan PHY_ERR("CCK-HEADER-CRC ERR", ATH9K_PHYERR_CCK_HEADER_CRC); 10274203214eSSujith Manoharan PHY_ERR("CCK-RATE ERR", ATH9K_PHYERR_CCK_RATE_ILLEGAL); 10284203214eSSujith Manoharan PHY_ERR("CCK-SERVICE ERR", ATH9K_PHYERR_CCK_SERVICE); 10294203214eSSujith Manoharan PHY_ERR("CCK-RESTART ERR", ATH9K_PHYERR_CCK_RESTART); 10304203214eSSujith Manoharan PHY_ERR("CCK-LENGTH ERR", ATH9K_PHYERR_CCK_LENGTH_ILLEGAL); 10314203214eSSujith Manoharan PHY_ERR("CCK-POWER-DROP ERR", ATH9K_PHYERR_CCK_POWER_DROP); 10324203214eSSujith Manoharan PHY_ERR("HT-CRC ERR", ATH9K_PHYERR_HT_CRC_ERROR); 10334203214eSSujith Manoharan PHY_ERR("HT-LENGTH ERR", ATH9K_PHYERR_HT_LENGTH_ILLEGAL); 10344203214eSSujith Manoharan PHY_ERR("HT-RATE ERR", ATH9K_PHYERR_HT_RATE_ILLEGAL); 10354203214eSSujith Manoharan 103624a0731eSBen Greear RXS_ERR("RX-Pkts-All", rx_pkts_all); 103724a0731eSBen Greear RXS_ERR("RX-Bytes-All", rx_bytes_all); 103824a0731eSBen Greear RXS_ERR("RX-Beacons", rx_beacons); 103924a0731eSBen Greear RXS_ERR("RX-Frags", rx_frags); 10409b99e665SSimon Wunderlich RXS_ERR("RX-Spectral", rx_spectral); 104199c15bf5SBen Greear 10422b87f3aaSDan Carpenter if (len > size) 10432b87f3aaSDan Carpenter len = size; 10442b87f3aaSDan Carpenter 10451395d3f0SSujith retval = simple_read_from_buffer(user_buf, count, ppos, buf, len); 10461395d3f0SSujith kfree(buf); 10471395d3f0SSujith 10481395d3f0SSujith return retval; 10491395d3f0SSujith 105024a0731eSBen Greear #undef RXS_ERR 10511395d3f0SSujith #undef PHY_ERR 10521395d3f0SSujith } 10531395d3f0SSujith 10548e6f5aa2SFelix Fietkau void ath_debug_stat_rx(struct ath_softc *sc, struct ath_rx_status *rs) 10551395d3f0SSujith { 10561395d3f0SSujith #define RX_PHY_ERR_INC(c) sc->debug.stats.rxstats.phy_err_stats[c]++ 10571395d3f0SSujith 105899c15bf5SBen Greear RX_STAT_INC(rx_pkts_all); 105999c15bf5SBen Greear sc->debug.stats.rxstats.rx_bytes_all += rs->rs_datalen; 106099c15bf5SBen Greear 10618e6f5aa2SFelix Fietkau if (rs->rs_status & ATH9K_RXERR_CRC) 10621395d3f0SSujith RX_STAT_INC(crc_err); 10638e6f5aa2SFelix Fietkau if (rs->rs_status & ATH9K_RXERR_DECRYPT) 10641395d3f0SSujith RX_STAT_INC(decrypt_crc_err); 10658e6f5aa2SFelix Fietkau if (rs->rs_status & ATH9K_RXERR_MIC) 10661395d3f0SSujith RX_STAT_INC(mic_err); 10678e6f5aa2SFelix Fietkau if (rs->rs_status & ATH9K_RX_DELIM_CRC_PRE) 10681395d3f0SSujith RX_STAT_INC(pre_delim_crc_err); 10698e6f5aa2SFelix Fietkau if (rs->rs_status & ATH9K_RX_DELIM_CRC_POST) 10701395d3f0SSujith RX_STAT_INC(post_delim_crc_err); 10718e6f5aa2SFelix Fietkau if (rs->rs_status & ATH9K_RX_DECRYPT_BUSY) 10721395d3f0SSujith RX_STAT_INC(decrypt_busy_err); 10731395d3f0SSujith 10748e6f5aa2SFelix Fietkau if (rs->rs_status & ATH9K_RXERR_PHY) { 10751395d3f0SSujith RX_STAT_INC(phy_err); 1076dbb07f00SSujith Manoharan if (rs->rs_phyerr < ATH9K_PHYERR_MAX) 1077dbb07f00SSujith Manoharan RX_PHY_ERR_INC(rs->rs_phyerr); 10781395d3f0SSujith } 10791395d3f0SSujith 10801395d3f0SSujith #undef RX_PHY_ERR_INC 10811395d3f0SSujith } 10821395d3f0SSujith 10831395d3f0SSujith static const struct file_operations fops_recv = { 10841395d3f0SSujith .read = read_file_recv, 1085234e3405SStephen Boyd .open = simple_open, 10866038f373SArnd Bergmann .owner = THIS_MODULE, 10876038f373SArnd Bergmann .llseek = default_llseek, 10881395d3f0SSujith }; 10891395d3f0SSujith 1090e93d083fSSimon Wunderlich static ssize_t read_file_spec_scan_ctl(struct file *file, char __user *user_buf, 1091e93d083fSSimon Wunderlich size_t count, loff_t *ppos) 1092e93d083fSSimon Wunderlich { 1093e93d083fSSimon Wunderlich struct ath_softc *sc = file->private_data; 1094e93d083fSSimon Wunderlich char *mode = ""; 1095e93d083fSSimon Wunderlich unsigned int len; 1096e93d083fSSimon Wunderlich 1097e93d083fSSimon Wunderlich switch (sc->spectral_mode) { 1098e93d083fSSimon Wunderlich case SPECTRAL_DISABLED: 1099e93d083fSSimon Wunderlich mode = "disable"; 1100e93d083fSSimon Wunderlich break; 1101e93d083fSSimon Wunderlich case SPECTRAL_BACKGROUND: 1102e93d083fSSimon Wunderlich mode = "background"; 1103e93d083fSSimon Wunderlich break; 1104e93d083fSSimon Wunderlich case SPECTRAL_CHANSCAN: 1105e93d083fSSimon Wunderlich mode = "chanscan"; 1106e93d083fSSimon Wunderlich break; 1107e93d083fSSimon Wunderlich case SPECTRAL_MANUAL: 1108e93d083fSSimon Wunderlich mode = "manual"; 1109e93d083fSSimon Wunderlich break; 1110e93d083fSSimon Wunderlich } 1111e93d083fSSimon Wunderlich len = strlen(mode); 1112e93d083fSSimon Wunderlich return simple_read_from_buffer(user_buf, count, ppos, mode, len); 1113e93d083fSSimon Wunderlich } 1114e93d083fSSimon Wunderlich 1115e93d083fSSimon Wunderlich static ssize_t write_file_spec_scan_ctl(struct file *file, 1116e93d083fSSimon Wunderlich const char __user *user_buf, 1117e93d083fSSimon Wunderlich size_t count, loff_t *ppos) 1118e93d083fSSimon Wunderlich { 1119e93d083fSSimon Wunderlich struct ath_softc *sc = file->private_data; 1120e93d083fSSimon Wunderlich struct ath_common *common = ath9k_hw_common(sc->sc_ah); 1121e93d083fSSimon Wunderlich char buf[32]; 1122e93d083fSSimon Wunderlich ssize_t len; 1123e93d083fSSimon Wunderlich 1124e93d083fSSimon Wunderlich len = min(count, sizeof(buf) - 1); 1125e93d083fSSimon Wunderlich if (copy_from_user(buf, user_buf, len)) 1126e93d083fSSimon Wunderlich return -EFAULT; 1127e93d083fSSimon Wunderlich 1128e93d083fSSimon Wunderlich buf[len] = '\0'; 1129e93d083fSSimon Wunderlich 1130e93d083fSSimon Wunderlich if (strncmp("trigger", buf, 7) == 0) { 1131e93d083fSSimon Wunderlich ath9k_spectral_scan_trigger(sc->hw); 1132e93d083fSSimon Wunderlich } else if (strncmp("background", buf, 9) == 0) { 1133e93d083fSSimon Wunderlich ath9k_spectral_scan_config(sc->hw, SPECTRAL_BACKGROUND); 1134e93d083fSSimon Wunderlich ath_dbg(common, CONFIG, "spectral scan: background mode enabled\n"); 1135e93d083fSSimon Wunderlich } else if (strncmp("chanscan", buf, 8) == 0) { 1136e93d083fSSimon Wunderlich ath9k_spectral_scan_config(sc->hw, SPECTRAL_CHANSCAN); 1137e93d083fSSimon Wunderlich ath_dbg(common, CONFIG, "spectral scan: channel scan mode enabled\n"); 1138e93d083fSSimon Wunderlich } else if (strncmp("manual", buf, 6) == 0) { 1139e93d083fSSimon Wunderlich ath9k_spectral_scan_config(sc->hw, SPECTRAL_MANUAL); 1140e93d083fSSimon Wunderlich ath_dbg(common, CONFIG, "spectral scan: manual mode enabled\n"); 1141e93d083fSSimon Wunderlich } else if (strncmp("disable", buf, 7) == 0) { 1142e93d083fSSimon Wunderlich ath9k_spectral_scan_config(sc->hw, SPECTRAL_DISABLED); 1143e93d083fSSimon Wunderlich ath_dbg(common, CONFIG, "spectral scan: disabled\n"); 1144e93d083fSSimon Wunderlich } else { 1145e93d083fSSimon Wunderlich return -EINVAL; 1146e93d083fSSimon Wunderlich } 1147e93d083fSSimon Wunderlich 1148e93d083fSSimon Wunderlich return count; 1149e93d083fSSimon Wunderlich } 1150e93d083fSSimon Wunderlich 1151e93d083fSSimon Wunderlich static const struct file_operations fops_spec_scan_ctl = { 1152e93d083fSSimon Wunderlich .read = read_file_spec_scan_ctl, 1153e93d083fSSimon Wunderlich .write = write_file_spec_scan_ctl, 1154e93d083fSSimon Wunderlich .open = simple_open, 1155e93d083fSSimon Wunderlich .owner = THIS_MODULE, 1156e93d083fSSimon Wunderlich .llseek = default_llseek, 1157e93d083fSSimon Wunderlich }; 1158e93d083fSSimon Wunderlich 115904ccd4a1SSimon Wunderlich static ssize_t read_file_spectral_short_repeat(struct file *file, 116004ccd4a1SSimon Wunderlich char __user *user_buf, 116104ccd4a1SSimon Wunderlich size_t count, loff_t *ppos) 116204ccd4a1SSimon Wunderlich { 116304ccd4a1SSimon Wunderlich struct ath_softc *sc = file->private_data; 116404ccd4a1SSimon Wunderlich char buf[32]; 116504ccd4a1SSimon Wunderlich unsigned int len; 116604ccd4a1SSimon Wunderlich 116704ccd4a1SSimon Wunderlich len = sprintf(buf, "%d\n", sc->spec_config.short_repeat); 116804ccd4a1SSimon Wunderlich return simple_read_from_buffer(user_buf, count, ppos, buf, len); 116904ccd4a1SSimon Wunderlich } 117004ccd4a1SSimon Wunderlich 117104ccd4a1SSimon Wunderlich static ssize_t write_file_spectral_short_repeat(struct file *file, 117204ccd4a1SSimon Wunderlich const char __user *user_buf, 117304ccd4a1SSimon Wunderlich size_t count, loff_t *ppos) 117404ccd4a1SSimon Wunderlich { 117504ccd4a1SSimon Wunderlich struct ath_softc *sc = file->private_data; 117604ccd4a1SSimon Wunderlich unsigned long val; 117704ccd4a1SSimon Wunderlich char buf[32]; 117804ccd4a1SSimon Wunderlich ssize_t len; 117904ccd4a1SSimon Wunderlich 118004ccd4a1SSimon Wunderlich len = min(count, sizeof(buf) - 1); 118104ccd4a1SSimon Wunderlich if (copy_from_user(buf, user_buf, len)) 118204ccd4a1SSimon Wunderlich return -EFAULT; 118304ccd4a1SSimon Wunderlich 118404ccd4a1SSimon Wunderlich buf[len] = '\0'; 118504ccd4a1SSimon Wunderlich if (kstrtoul(buf, 0, &val)) 118604ccd4a1SSimon Wunderlich return -EINVAL; 118704ccd4a1SSimon Wunderlich 118804ccd4a1SSimon Wunderlich if (val < 0 || val > 1) 118904ccd4a1SSimon Wunderlich return -EINVAL; 119004ccd4a1SSimon Wunderlich 119104ccd4a1SSimon Wunderlich sc->spec_config.short_repeat = val; 119204ccd4a1SSimon Wunderlich return count; 119304ccd4a1SSimon Wunderlich } 119404ccd4a1SSimon Wunderlich 119504ccd4a1SSimon Wunderlich static const struct file_operations fops_spectral_short_repeat = { 119604ccd4a1SSimon Wunderlich .read = read_file_spectral_short_repeat, 119704ccd4a1SSimon Wunderlich .write = write_file_spectral_short_repeat, 119804ccd4a1SSimon Wunderlich .open = simple_open, 119904ccd4a1SSimon Wunderlich .owner = THIS_MODULE, 120004ccd4a1SSimon Wunderlich .llseek = default_llseek, 120104ccd4a1SSimon Wunderlich }; 120204ccd4a1SSimon Wunderlich 120304ccd4a1SSimon Wunderlich static ssize_t read_file_spectral_count(struct file *file, 120404ccd4a1SSimon Wunderlich char __user *user_buf, 120504ccd4a1SSimon Wunderlich size_t count, loff_t *ppos) 120604ccd4a1SSimon Wunderlich { 120704ccd4a1SSimon Wunderlich struct ath_softc *sc = file->private_data; 120804ccd4a1SSimon Wunderlich char buf[32]; 120904ccd4a1SSimon Wunderlich unsigned int len; 121004ccd4a1SSimon Wunderlich 121104ccd4a1SSimon Wunderlich len = sprintf(buf, "%d\n", sc->spec_config.count); 121204ccd4a1SSimon Wunderlich return simple_read_from_buffer(user_buf, count, ppos, buf, len); 121304ccd4a1SSimon Wunderlich } 121404ccd4a1SSimon Wunderlich 121504ccd4a1SSimon Wunderlich static ssize_t write_file_spectral_count(struct file *file, 121604ccd4a1SSimon Wunderlich const char __user *user_buf, 121704ccd4a1SSimon Wunderlich size_t count, loff_t *ppos) 121804ccd4a1SSimon Wunderlich { 121904ccd4a1SSimon Wunderlich struct ath_softc *sc = file->private_data; 122004ccd4a1SSimon Wunderlich unsigned long val; 122104ccd4a1SSimon Wunderlich char buf[32]; 122204ccd4a1SSimon Wunderlich ssize_t len; 122304ccd4a1SSimon Wunderlich 122404ccd4a1SSimon Wunderlich len = min(count, sizeof(buf) - 1); 122504ccd4a1SSimon Wunderlich if (copy_from_user(buf, user_buf, len)) 122604ccd4a1SSimon Wunderlich return -EFAULT; 122704ccd4a1SSimon Wunderlich 122804ccd4a1SSimon Wunderlich buf[len] = '\0'; 122904ccd4a1SSimon Wunderlich if (kstrtoul(buf, 0, &val)) 123004ccd4a1SSimon Wunderlich return -EINVAL; 123104ccd4a1SSimon Wunderlich 123204ccd4a1SSimon Wunderlich if (val < 0 || val > 255) 123304ccd4a1SSimon Wunderlich return -EINVAL; 123404ccd4a1SSimon Wunderlich 123504ccd4a1SSimon Wunderlich sc->spec_config.count = val; 123604ccd4a1SSimon Wunderlich return count; 123704ccd4a1SSimon Wunderlich } 123804ccd4a1SSimon Wunderlich 123904ccd4a1SSimon Wunderlich static const struct file_operations fops_spectral_count = { 124004ccd4a1SSimon Wunderlich .read = read_file_spectral_count, 124104ccd4a1SSimon Wunderlich .write = write_file_spectral_count, 124204ccd4a1SSimon Wunderlich .open = simple_open, 124304ccd4a1SSimon Wunderlich .owner = THIS_MODULE, 124404ccd4a1SSimon Wunderlich .llseek = default_llseek, 124504ccd4a1SSimon Wunderlich }; 124604ccd4a1SSimon Wunderlich 124704ccd4a1SSimon Wunderlich static ssize_t read_file_spectral_period(struct file *file, 124804ccd4a1SSimon Wunderlich char __user *user_buf, 124904ccd4a1SSimon Wunderlich size_t count, loff_t *ppos) 125004ccd4a1SSimon Wunderlich { 125104ccd4a1SSimon Wunderlich struct ath_softc *sc = file->private_data; 125204ccd4a1SSimon Wunderlich char buf[32]; 125304ccd4a1SSimon Wunderlich unsigned int len; 125404ccd4a1SSimon Wunderlich 125504ccd4a1SSimon Wunderlich len = sprintf(buf, "%d\n", sc->spec_config.period); 125604ccd4a1SSimon Wunderlich return simple_read_from_buffer(user_buf, count, ppos, buf, len); 125704ccd4a1SSimon Wunderlich } 125804ccd4a1SSimon Wunderlich 125904ccd4a1SSimon Wunderlich static ssize_t write_file_spectral_period(struct file *file, 126004ccd4a1SSimon Wunderlich const char __user *user_buf, 126104ccd4a1SSimon Wunderlich size_t count, loff_t *ppos) 126204ccd4a1SSimon Wunderlich { 126304ccd4a1SSimon Wunderlich struct ath_softc *sc = file->private_data; 126404ccd4a1SSimon Wunderlich unsigned long val; 126504ccd4a1SSimon Wunderlich char buf[32]; 126604ccd4a1SSimon Wunderlich ssize_t len; 126704ccd4a1SSimon Wunderlich 126804ccd4a1SSimon Wunderlich len = min(count, sizeof(buf) - 1); 126904ccd4a1SSimon Wunderlich if (copy_from_user(buf, user_buf, len)) 127004ccd4a1SSimon Wunderlich return -EFAULT; 127104ccd4a1SSimon Wunderlich 127204ccd4a1SSimon Wunderlich buf[len] = '\0'; 127304ccd4a1SSimon Wunderlich if (kstrtoul(buf, 0, &val)) 127404ccd4a1SSimon Wunderlich return -EINVAL; 127504ccd4a1SSimon Wunderlich 127604ccd4a1SSimon Wunderlich if (val < 0 || val > 255) 127704ccd4a1SSimon Wunderlich return -EINVAL; 127804ccd4a1SSimon Wunderlich 127904ccd4a1SSimon Wunderlich sc->spec_config.period = val; 128004ccd4a1SSimon Wunderlich return count; 128104ccd4a1SSimon Wunderlich } 128204ccd4a1SSimon Wunderlich 128304ccd4a1SSimon Wunderlich static const struct file_operations fops_spectral_period = { 128404ccd4a1SSimon Wunderlich .read = read_file_spectral_period, 128504ccd4a1SSimon Wunderlich .write = write_file_spectral_period, 128604ccd4a1SSimon Wunderlich .open = simple_open, 128704ccd4a1SSimon Wunderlich .owner = THIS_MODULE, 128804ccd4a1SSimon Wunderlich .llseek = default_llseek, 128904ccd4a1SSimon Wunderlich }; 129004ccd4a1SSimon Wunderlich 129104ccd4a1SSimon Wunderlich static ssize_t read_file_spectral_fft_period(struct file *file, 129204ccd4a1SSimon Wunderlich char __user *user_buf, 129304ccd4a1SSimon Wunderlich size_t count, loff_t *ppos) 129404ccd4a1SSimon Wunderlich { 129504ccd4a1SSimon Wunderlich struct ath_softc *sc = file->private_data; 129604ccd4a1SSimon Wunderlich char buf[32]; 129704ccd4a1SSimon Wunderlich unsigned int len; 129804ccd4a1SSimon Wunderlich 129904ccd4a1SSimon Wunderlich len = sprintf(buf, "%d\n", sc->spec_config.fft_period); 130004ccd4a1SSimon Wunderlich return simple_read_from_buffer(user_buf, count, ppos, buf, len); 130104ccd4a1SSimon Wunderlich } 130204ccd4a1SSimon Wunderlich 130304ccd4a1SSimon Wunderlich static ssize_t write_file_spectral_fft_period(struct file *file, 130404ccd4a1SSimon Wunderlich const char __user *user_buf, 130504ccd4a1SSimon Wunderlich size_t count, loff_t *ppos) 130604ccd4a1SSimon Wunderlich { 130704ccd4a1SSimon Wunderlich struct ath_softc *sc = file->private_data; 130804ccd4a1SSimon Wunderlich unsigned long val; 130904ccd4a1SSimon Wunderlich char buf[32]; 131004ccd4a1SSimon Wunderlich ssize_t len; 131104ccd4a1SSimon Wunderlich 131204ccd4a1SSimon Wunderlich len = min(count, sizeof(buf) - 1); 131304ccd4a1SSimon Wunderlich if (copy_from_user(buf, user_buf, len)) 131404ccd4a1SSimon Wunderlich return -EFAULT; 131504ccd4a1SSimon Wunderlich 131604ccd4a1SSimon Wunderlich buf[len] = '\0'; 131704ccd4a1SSimon Wunderlich if (kstrtoul(buf, 0, &val)) 131804ccd4a1SSimon Wunderlich return -EINVAL; 131904ccd4a1SSimon Wunderlich 132004ccd4a1SSimon Wunderlich if (val < 0 || val > 15) 132104ccd4a1SSimon Wunderlich return -EINVAL; 132204ccd4a1SSimon Wunderlich 132304ccd4a1SSimon Wunderlich sc->spec_config.fft_period = val; 132404ccd4a1SSimon Wunderlich return count; 132504ccd4a1SSimon Wunderlich } 132604ccd4a1SSimon Wunderlich 132704ccd4a1SSimon Wunderlich static const struct file_operations fops_spectral_fft_period = { 132804ccd4a1SSimon Wunderlich .read = read_file_spectral_fft_period, 132904ccd4a1SSimon Wunderlich .write = write_file_spectral_fft_period, 133004ccd4a1SSimon Wunderlich .open = simple_open, 133104ccd4a1SSimon Wunderlich .owner = THIS_MODULE, 133204ccd4a1SSimon Wunderlich .llseek = default_llseek, 133304ccd4a1SSimon Wunderlich }; 133404ccd4a1SSimon Wunderlich 1335e93d083fSSimon Wunderlich static struct dentry *create_buf_file_handler(const char *filename, 1336e93d083fSSimon Wunderlich struct dentry *parent, 1337e93d083fSSimon Wunderlich umode_t mode, 1338e93d083fSSimon Wunderlich struct rchan_buf *buf, 1339e93d083fSSimon Wunderlich int *is_global) 1340e93d083fSSimon Wunderlich { 1341e93d083fSSimon Wunderlich struct dentry *buf_file; 1342e93d083fSSimon Wunderlich 1343e93d083fSSimon Wunderlich buf_file = debugfs_create_file(filename, mode, parent, buf, 1344e93d083fSSimon Wunderlich &relay_file_operations); 1345e93d083fSSimon Wunderlich *is_global = 1; 1346e93d083fSSimon Wunderlich return buf_file; 1347e93d083fSSimon Wunderlich } 1348e93d083fSSimon Wunderlich 1349e93d083fSSimon Wunderlich static int remove_buf_file_handler(struct dentry *dentry) 1350e93d083fSSimon Wunderlich { 1351e93d083fSSimon Wunderlich debugfs_remove(dentry); 1352e93d083fSSimon Wunderlich 1353e93d083fSSimon Wunderlich return 0; 1354e93d083fSSimon Wunderlich } 1355e93d083fSSimon Wunderlich 1356e93d083fSSimon Wunderlich void ath_debug_send_fft_sample(struct ath_softc *sc, 1357e93d083fSSimon Wunderlich struct fft_sample_tlv *fft_sample_tlv) 1358e93d083fSSimon Wunderlich { 13594ab0b0aaSSven Eckelmann int length; 1360e93d083fSSimon Wunderlich if (!sc->rfs_chan_spec_scan) 1361e93d083fSSimon Wunderlich return; 1362e93d083fSSimon Wunderlich 13634ab0b0aaSSven Eckelmann length = __be16_to_cpu(fft_sample_tlv->length) + 13644ab0b0aaSSven Eckelmann sizeof(*fft_sample_tlv); 13654ab0b0aaSSven Eckelmann relay_write(sc->rfs_chan_spec_scan, fft_sample_tlv, length); 1366e93d083fSSimon Wunderlich } 1367e93d083fSSimon Wunderlich 1368e93d083fSSimon Wunderlich static struct rchan_callbacks rfs_spec_scan_cb = { 1369e93d083fSSimon Wunderlich .create_buf_file = create_buf_file_handler, 1370e93d083fSSimon Wunderlich .remove_buf_file = remove_buf_file_handler, 1371e93d083fSSimon Wunderlich }; 1372e93d083fSSimon Wunderlich 1373e93d083fSSimon Wunderlich 13749bff0bc4SFelix Fietkau static ssize_t read_file_regidx(struct file *file, char __user *user_buf, 13759bff0bc4SFelix Fietkau size_t count, loff_t *ppos) 13769bff0bc4SFelix Fietkau { 13779bff0bc4SFelix Fietkau struct ath_softc *sc = file->private_data; 13789bff0bc4SFelix Fietkau char buf[32]; 13799bff0bc4SFelix Fietkau unsigned int len; 13809bff0bc4SFelix Fietkau 13812b87f3aaSDan Carpenter len = sprintf(buf, "0x%08x\n", sc->debug.regidx); 13829bff0bc4SFelix Fietkau return simple_read_from_buffer(user_buf, count, ppos, buf, len); 13839bff0bc4SFelix Fietkau } 13849bff0bc4SFelix Fietkau 13859bff0bc4SFelix Fietkau static ssize_t write_file_regidx(struct file *file, const char __user *user_buf, 13869bff0bc4SFelix Fietkau size_t count, loff_t *ppos) 13879bff0bc4SFelix Fietkau { 13889bff0bc4SFelix Fietkau struct ath_softc *sc = file->private_data; 13899bff0bc4SFelix Fietkau unsigned long regidx; 13909bff0bc4SFelix Fietkau char buf[32]; 13919bff0bc4SFelix Fietkau ssize_t len; 13929bff0bc4SFelix Fietkau 13939bff0bc4SFelix Fietkau len = min(count, sizeof(buf) - 1); 13949bff0bc4SFelix Fietkau if (copy_from_user(buf, user_buf, len)) 139504236066SDan Carpenter return -EFAULT; 13969bff0bc4SFelix Fietkau 13979bff0bc4SFelix Fietkau buf[len] = '\0'; 139827d7f477SJingoo Han if (kstrtoul(buf, 0, ®idx)) 13999bff0bc4SFelix Fietkau return -EINVAL; 14009bff0bc4SFelix Fietkau 14019bff0bc4SFelix Fietkau sc->debug.regidx = regidx; 14029bff0bc4SFelix Fietkau return count; 14039bff0bc4SFelix Fietkau } 14049bff0bc4SFelix Fietkau 14059bff0bc4SFelix Fietkau static const struct file_operations fops_regidx = { 14069bff0bc4SFelix Fietkau .read = read_file_regidx, 14079bff0bc4SFelix Fietkau .write = write_file_regidx, 1408234e3405SStephen Boyd .open = simple_open, 14096038f373SArnd Bergmann .owner = THIS_MODULE, 14106038f373SArnd Bergmann .llseek = default_llseek, 14119bff0bc4SFelix Fietkau }; 14129bff0bc4SFelix Fietkau 14139bff0bc4SFelix Fietkau static ssize_t read_file_regval(struct file *file, char __user *user_buf, 14149bff0bc4SFelix Fietkau size_t count, loff_t *ppos) 14159bff0bc4SFelix Fietkau { 14169bff0bc4SFelix Fietkau struct ath_softc *sc = file->private_data; 14179bff0bc4SFelix Fietkau struct ath_hw *ah = sc->sc_ah; 14189bff0bc4SFelix Fietkau char buf[32]; 14199bff0bc4SFelix Fietkau unsigned int len; 14209bff0bc4SFelix Fietkau u32 regval; 14219bff0bc4SFelix Fietkau 142279d2b157SRajkumar Manoharan ath9k_ps_wakeup(sc); 14239bff0bc4SFelix Fietkau regval = REG_READ_D(ah, sc->debug.regidx); 142479d2b157SRajkumar Manoharan ath9k_ps_restore(sc); 14252b87f3aaSDan Carpenter len = sprintf(buf, "0x%08x\n", regval); 14269bff0bc4SFelix Fietkau return simple_read_from_buffer(user_buf, count, ppos, buf, len); 14279bff0bc4SFelix Fietkau } 14289bff0bc4SFelix Fietkau 14299bff0bc4SFelix Fietkau static ssize_t write_file_regval(struct file *file, const char __user *user_buf, 14309bff0bc4SFelix Fietkau size_t count, loff_t *ppos) 14319bff0bc4SFelix Fietkau { 14329bff0bc4SFelix Fietkau struct ath_softc *sc = file->private_data; 14339bff0bc4SFelix Fietkau struct ath_hw *ah = sc->sc_ah; 14349bff0bc4SFelix Fietkau unsigned long regval; 14359bff0bc4SFelix Fietkau char buf[32]; 14369bff0bc4SFelix Fietkau ssize_t len; 14379bff0bc4SFelix Fietkau 14389bff0bc4SFelix Fietkau len = min(count, sizeof(buf) - 1); 14399bff0bc4SFelix Fietkau if (copy_from_user(buf, user_buf, len)) 144004236066SDan Carpenter return -EFAULT; 14419bff0bc4SFelix Fietkau 14429bff0bc4SFelix Fietkau buf[len] = '\0'; 144327d7f477SJingoo Han if (kstrtoul(buf, 0, ®val)) 14449bff0bc4SFelix Fietkau return -EINVAL; 14459bff0bc4SFelix Fietkau 144679d2b157SRajkumar Manoharan ath9k_ps_wakeup(sc); 14479bff0bc4SFelix Fietkau REG_WRITE_D(ah, sc->debug.regidx, regval); 144879d2b157SRajkumar Manoharan ath9k_ps_restore(sc); 14499bff0bc4SFelix Fietkau return count; 14509bff0bc4SFelix Fietkau } 14519bff0bc4SFelix Fietkau 14529bff0bc4SFelix Fietkau static const struct file_operations fops_regval = { 14539bff0bc4SFelix Fietkau .read = read_file_regval, 14549bff0bc4SFelix Fietkau .write = write_file_regval, 1455234e3405SStephen Boyd .open = simple_open, 14566038f373SArnd Bergmann .owner = THIS_MODULE, 14576038f373SArnd Bergmann .llseek = default_llseek, 14589bff0bc4SFelix Fietkau }; 14599bff0bc4SFelix Fietkau 1460582d0064SVasanthakumar Thiagarajan #define REGDUMP_LINE_SIZE 20 1461582d0064SVasanthakumar Thiagarajan 1462582d0064SVasanthakumar Thiagarajan static int open_file_regdump(struct inode *inode, struct file *file) 1463582d0064SVasanthakumar Thiagarajan { 1464582d0064SVasanthakumar Thiagarajan struct ath_softc *sc = inode->i_private; 1465582d0064SVasanthakumar Thiagarajan unsigned int len = 0; 1466582d0064SVasanthakumar Thiagarajan u8 *buf; 1467582d0064SVasanthakumar Thiagarajan int i; 1468582d0064SVasanthakumar Thiagarajan unsigned long num_regs, regdump_len, max_reg_offset; 1469582d0064SVasanthakumar Thiagarajan 1470582d0064SVasanthakumar Thiagarajan max_reg_offset = AR_SREV_9300_20_OR_LATER(sc->sc_ah) ? 0x16bd4 : 0xb500; 1471582d0064SVasanthakumar Thiagarajan num_regs = max_reg_offset / 4 + 1; 1472582d0064SVasanthakumar Thiagarajan regdump_len = num_regs * REGDUMP_LINE_SIZE + 1; 1473582d0064SVasanthakumar Thiagarajan buf = vmalloc(regdump_len); 1474582d0064SVasanthakumar Thiagarajan if (!buf) 1475582d0064SVasanthakumar Thiagarajan return -ENOMEM; 1476582d0064SVasanthakumar Thiagarajan 1477582d0064SVasanthakumar Thiagarajan ath9k_ps_wakeup(sc); 1478582d0064SVasanthakumar Thiagarajan for (i = 0; i < num_regs; i++) 1479582d0064SVasanthakumar Thiagarajan len += scnprintf(buf + len, regdump_len - len, 1480582d0064SVasanthakumar Thiagarajan "0x%06x 0x%08x\n", i << 2, REG_READ(sc->sc_ah, i << 2)); 1481582d0064SVasanthakumar Thiagarajan ath9k_ps_restore(sc); 1482582d0064SVasanthakumar Thiagarajan 1483582d0064SVasanthakumar Thiagarajan file->private_data = buf; 1484582d0064SVasanthakumar Thiagarajan 1485582d0064SVasanthakumar Thiagarajan return 0; 1486582d0064SVasanthakumar Thiagarajan } 1487582d0064SVasanthakumar Thiagarajan 1488582d0064SVasanthakumar Thiagarajan static const struct file_operations fops_regdump = { 1489582d0064SVasanthakumar Thiagarajan .open = open_file_regdump, 1490582d0064SVasanthakumar Thiagarajan .read = ath9k_debugfs_read_buf, 1491582d0064SVasanthakumar Thiagarajan .release = ath9k_debugfs_release_buf, 1492582d0064SVasanthakumar Thiagarajan .owner = THIS_MODULE, 1493582d0064SVasanthakumar Thiagarajan .llseek = default_llseek,/* read accesses f_pos */ 1494582d0064SVasanthakumar Thiagarajan }; 1495582d0064SVasanthakumar Thiagarajan 1496d069a46bSRajkumar Manoharan static ssize_t read_file_dump_nfcal(struct file *file, char __user *user_buf, 1497d069a46bSRajkumar Manoharan size_t count, loff_t *ppos) 1498d069a46bSRajkumar Manoharan { 1499d069a46bSRajkumar Manoharan struct ath_softc *sc = file->private_data; 1500d069a46bSRajkumar Manoharan struct ath_hw *ah = sc->sc_ah; 1501d069a46bSRajkumar Manoharan struct ath9k_nfcal_hist *h = sc->caldata.nfCalHist; 1502d069a46bSRajkumar Manoharan struct ath_common *common = ath9k_hw_common(ah); 1503d069a46bSRajkumar Manoharan struct ieee80211_conf *conf = &common->hw->conf; 1504d069a46bSRajkumar Manoharan u32 len = 0, size = 1500; 1505d069a46bSRajkumar Manoharan u32 i, j; 1506d069a46bSRajkumar Manoharan ssize_t retval = 0; 1507d069a46bSRajkumar Manoharan char *buf; 1508d069a46bSRajkumar Manoharan u8 chainmask = (ah->rxchainmask << 3) | ah->rxchainmask; 1509d069a46bSRajkumar Manoharan u8 nread; 1510d069a46bSRajkumar Manoharan 1511d069a46bSRajkumar Manoharan buf = kzalloc(size, GFP_KERNEL); 1512d069a46bSRajkumar Manoharan if (!buf) 1513d069a46bSRajkumar Manoharan return -ENOMEM; 1514d069a46bSRajkumar Manoharan 1515d069a46bSRajkumar Manoharan len += snprintf(buf + len, size - len, 1516d069a46bSRajkumar Manoharan "Channel Noise Floor : %d\n", ah->noise); 1517d069a46bSRajkumar Manoharan len += snprintf(buf + len, size - len, 1518d069a46bSRajkumar Manoharan "Chain | privNF | # Readings | NF Readings\n"); 1519d069a46bSRajkumar Manoharan for (i = 0; i < NUM_NF_READINGS; i++) { 1520d069a46bSRajkumar Manoharan if (!(chainmask & (1 << i)) || 1521d069a46bSRajkumar Manoharan ((i >= AR5416_MAX_CHAINS) && !conf_is_ht40(conf))) 1522d069a46bSRajkumar Manoharan continue; 1523d069a46bSRajkumar Manoharan 1524d069a46bSRajkumar Manoharan nread = AR_PHY_CCA_FILTERWINDOW_LENGTH - h[i].invalidNFcount; 1525d069a46bSRajkumar Manoharan len += snprintf(buf + len, size - len, " %d\t %d\t %d\t\t", 1526d069a46bSRajkumar Manoharan i, h[i].privNF, nread); 1527d069a46bSRajkumar Manoharan for (j = 0; j < nread; j++) 1528d069a46bSRajkumar Manoharan len += snprintf(buf + len, size - len, 1529d069a46bSRajkumar Manoharan " %d", h[i].nfCalBuffer[j]); 1530d069a46bSRajkumar Manoharan len += snprintf(buf + len, size - len, "\n"); 1531d069a46bSRajkumar Manoharan } 1532d069a46bSRajkumar Manoharan 1533d069a46bSRajkumar Manoharan if (len > size) 1534d069a46bSRajkumar Manoharan len = size; 1535d069a46bSRajkumar Manoharan 1536d069a46bSRajkumar Manoharan retval = simple_read_from_buffer(user_buf, count, ppos, buf, len); 1537d069a46bSRajkumar Manoharan kfree(buf); 1538d069a46bSRajkumar Manoharan 1539d069a46bSRajkumar Manoharan return retval; 1540d069a46bSRajkumar Manoharan } 1541d069a46bSRajkumar Manoharan 1542d069a46bSRajkumar Manoharan static const struct file_operations fops_dump_nfcal = { 1543d069a46bSRajkumar Manoharan .read = read_file_dump_nfcal, 1544234e3405SStephen Boyd .open = simple_open, 1545d069a46bSRajkumar Manoharan .owner = THIS_MODULE, 1546d069a46bSRajkumar Manoharan .llseek = default_llseek, 1547d069a46bSRajkumar Manoharan }; 1548d069a46bSRajkumar Manoharan 1549580f010fSRajkumar Manoharan static ssize_t read_file_base_eeprom(struct file *file, char __user *user_buf, 1550580f010fSRajkumar Manoharan size_t count, loff_t *ppos) 1551580f010fSRajkumar Manoharan { 1552580f010fSRajkumar Manoharan struct ath_softc *sc = file->private_data; 1553580f010fSRajkumar Manoharan struct ath_hw *ah = sc->sc_ah; 1554580f010fSRajkumar Manoharan u32 len = 0, size = 1500; 1555580f010fSRajkumar Manoharan ssize_t retval = 0; 1556580f010fSRajkumar Manoharan char *buf; 1557580f010fSRajkumar Manoharan 1558580f010fSRajkumar Manoharan buf = kzalloc(size, GFP_KERNEL); 1559580f010fSRajkumar Manoharan if (!buf) 1560580f010fSRajkumar Manoharan return -ENOMEM; 1561580f010fSRajkumar Manoharan 1562580f010fSRajkumar Manoharan len = ah->eep_ops->dump_eeprom(ah, true, buf, len, size); 1563580f010fSRajkumar Manoharan 1564580f010fSRajkumar Manoharan retval = simple_read_from_buffer(user_buf, count, ppos, buf, len); 1565580f010fSRajkumar Manoharan kfree(buf); 1566580f010fSRajkumar Manoharan 1567580f010fSRajkumar Manoharan return retval; 1568580f010fSRajkumar Manoharan } 1569580f010fSRajkumar Manoharan 1570580f010fSRajkumar Manoharan static const struct file_operations fops_base_eeprom = { 1571580f010fSRajkumar Manoharan .read = read_file_base_eeprom, 1572234e3405SStephen Boyd .open = simple_open, 1573580f010fSRajkumar Manoharan .owner = THIS_MODULE, 1574580f010fSRajkumar Manoharan .llseek = default_llseek, 1575580f010fSRajkumar Manoharan }; 1576580f010fSRajkumar Manoharan 15773f4c4bddSRajkumar Manoharan static ssize_t read_file_modal_eeprom(struct file *file, char __user *user_buf, 15783f4c4bddSRajkumar Manoharan size_t count, loff_t *ppos) 15793f4c4bddSRajkumar Manoharan { 15803f4c4bddSRajkumar Manoharan struct ath_softc *sc = file->private_data; 15813f4c4bddSRajkumar Manoharan struct ath_hw *ah = sc->sc_ah; 15823f4c4bddSRajkumar Manoharan u32 len = 0, size = 6000; 15833f4c4bddSRajkumar Manoharan char *buf; 15843f4c4bddSRajkumar Manoharan size_t retval; 15853f4c4bddSRajkumar Manoharan 15863f4c4bddSRajkumar Manoharan buf = kzalloc(size, GFP_KERNEL); 15873f4c4bddSRajkumar Manoharan if (buf == NULL) 15883f4c4bddSRajkumar Manoharan return -ENOMEM; 15893f4c4bddSRajkumar Manoharan 15903f4c4bddSRajkumar Manoharan len = ah->eep_ops->dump_eeprom(ah, false, buf, len, size); 15913f4c4bddSRajkumar Manoharan 15923f4c4bddSRajkumar Manoharan retval = simple_read_from_buffer(user_buf, count, ppos, buf, len); 15933f4c4bddSRajkumar Manoharan kfree(buf); 15943f4c4bddSRajkumar Manoharan 15953f4c4bddSRajkumar Manoharan return retval; 15963f4c4bddSRajkumar Manoharan } 15973f4c4bddSRajkumar Manoharan 15983f4c4bddSRajkumar Manoharan static const struct file_operations fops_modal_eeprom = { 15993f4c4bddSRajkumar Manoharan .read = read_file_modal_eeprom, 1600234e3405SStephen Boyd .open = simple_open, 16013f4c4bddSRajkumar Manoharan .owner = THIS_MODULE, 16023f4c4bddSRajkumar Manoharan .llseek = default_llseek, 16033f4c4bddSRajkumar Manoharan }; 16043f4c4bddSRajkumar Manoharan 16054df50ca8SRajkumar Manoharan #ifdef CONFIG_ATH9K_BTCOEX_SUPPORT 16064df50ca8SRajkumar Manoharan static ssize_t read_file_btcoex(struct file *file, char __user *user_buf, 16074df50ca8SRajkumar Manoharan size_t count, loff_t *ppos) 16084df50ca8SRajkumar Manoharan { 16094df50ca8SRajkumar Manoharan struct ath_softc *sc = file->private_data; 16104df50ca8SRajkumar Manoharan u32 len = 0, size = 1500; 16114df50ca8SRajkumar Manoharan char *buf; 16124df50ca8SRajkumar Manoharan size_t retval; 16134df50ca8SRajkumar Manoharan 16144df50ca8SRajkumar Manoharan buf = kzalloc(size, GFP_KERNEL); 16154df50ca8SRajkumar Manoharan if (buf == NULL) 16164df50ca8SRajkumar Manoharan return -ENOMEM; 16174df50ca8SRajkumar Manoharan 1618ac46ba43SSujith Manoharan if (!sc->sc_ah->common.btcoex_enabled) { 1619ac46ba43SSujith Manoharan len = snprintf(buf, size, "%s\n", 1620ac46ba43SSujith Manoharan "BTCOEX is disabled"); 1621ac46ba43SSujith Manoharan goto exit; 1622ac46ba43SSujith Manoharan } 16234df50ca8SRajkumar Manoharan 1624ac46ba43SSujith Manoharan len = ath9k_dump_btcoex(sc, buf, size); 1625ac46ba43SSujith Manoharan exit: 16264df50ca8SRajkumar Manoharan retval = simple_read_from_buffer(user_buf, count, ppos, buf, len); 16274df50ca8SRajkumar Manoharan kfree(buf); 16284df50ca8SRajkumar Manoharan 16294df50ca8SRajkumar Manoharan return retval; 16304df50ca8SRajkumar Manoharan } 16314df50ca8SRajkumar Manoharan 16324df50ca8SRajkumar Manoharan static const struct file_operations fops_btcoex = { 16334df50ca8SRajkumar Manoharan .read = read_file_btcoex, 16344df50ca8SRajkumar Manoharan .open = simple_open, 16354df50ca8SRajkumar Manoharan .owner = THIS_MODULE, 16364df50ca8SRajkumar Manoharan .llseek = default_llseek, 16374df50ca8SRajkumar Manoharan }; 16384df50ca8SRajkumar Manoharan #endif 16394df50ca8SRajkumar Manoharan 1640a145daf7SSujith Manoharan static ssize_t read_file_node_stat(struct file *file, char __user *user_buf, 1641a145daf7SSujith Manoharan size_t count, loff_t *ppos) 1642a145daf7SSujith Manoharan { 1643a145daf7SSujith Manoharan struct ath_node *an = file->private_data; 1644a145daf7SSujith Manoharan struct ath_softc *sc = an->sc; 1645a145daf7SSujith Manoharan struct ath_atx_tid *tid; 1646a145daf7SSujith Manoharan struct ath_atx_ac *ac; 1647a145daf7SSujith Manoharan struct ath_txq *txq; 1648a145daf7SSujith Manoharan u32 len = 0, size = 4096; 1649a145daf7SSujith Manoharan char *buf; 1650a145daf7SSujith Manoharan size_t retval; 1651a145daf7SSujith Manoharan int tidno, acno; 1652a145daf7SSujith Manoharan 1653a145daf7SSujith Manoharan buf = kzalloc(size, GFP_KERNEL); 1654a145daf7SSujith Manoharan if (buf == NULL) 1655a145daf7SSujith Manoharan return -ENOMEM; 1656a145daf7SSujith Manoharan 1657a145daf7SSujith Manoharan if (!an->sta->ht_cap.ht_supported) { 1658a145daf7SSujith Manoharan len = snprintf(buf, size, "%s\n", 1659a145daf7SSujith Manoharan "HT not supported"); 1660a145daf7SSujith Manoharan goto exit; 1661a145daf7SSujith Manoharan } 1662a145daf7SSujith Manoharan 1663a145daf7SSujith Manoharan len = snprintf(buf, size, "Max-AMPDU: %d\n", 1664a145daf7SSujith Manoharan an->maxampdu); 1665a145daf7SSujith Manoharan len += snprintf(buf + len, size - len, "MPDU Density: %d\n\n", 1666a145daf7SSujith Manoharan an->mpdudensity); 1667a145daf7SSujith Manoharan 1668a145daf7SSujith Manoharan len += snprintf(buf + len, size - len, 1669a145daf7SSujith Manoharan "%2s%7s\n", "AC", "SCHED"); 1670a145daf7SSujith Manoharan 1671a145daf7SSujith Manoharan for (acno = 0, ac = &an->ac[acno]; 1672a145daf7SSujith Manoharan acno < IEEE80211_NUM_ACS; acno++, ac++) { 1673a145daf7SSujith Manoharan txq = ac->txq; 1674a145daf7SSujith Manoharan ath_txq_lock(sc, txq); 1675a145daf7SSujith Manoharan len += snprintf(buf + len, size - len, 1676a145daf7SSujith Manoharan "%2d%7d\n", 1677a145daf7SSujith Manoharan acno, ac->sched); 1678a145daf7SSujith Manoharan ath_txq_unlock(sc, txq); 1679a145daf7SSujith Manoharan } 1680a145daf7SSujith Manoharan 1681a145daf7SSujith Manoharan len += snprintf(buf + len, size - len, 1682a145daf7SSujith Manoharan "\n%3s%11s%10s%10s%10s%10s%9s%6s%8s\n", 1683a145daf7SSujith Manoharan "TID", "SEQ_START", "SEQ_NEXT", "BAW_SIZE", 1684a145daf7SSujith Manoharan "BAW_HEAD", "BAW_TAIL", "BAR_IDX", "SCHED", "PAUSED"); 1685a145daf7SSujith Manoharan 1686a145daf7SSujith Manoharan for (tidno = 0, tid = &an->tid[tidno]; 1687a145daf7SSujith Manoharan tidno < IEEE80211_NUM_TIDS; tidno++, tid++) { 1688a145daf7SSujith Manoharan txq = tid->ac->txq; 1689a145daf7SSujith Manoharan ath_txq_lock(sc, txq); 1690a145daf7SSujith Manoharan len += snprintf(buf + len, size - len, 1691a145daf7SSujith Manoharan "%3d%11d%10d%10d%10d%10d%9d%6d%8d\n", 1692a145daf7SSujith Manoharan tid->tidno, tid->seq_start, tid->seq_next, 1693a145daf7SSujith Manoharan tid->baw_size, tid->baw_head, tid->baw_tail, 1694a145daf7SSujith Manoharan tid->bar_index, tid->sched, tid->paused); 1695a145daf7SSujith Manoharan ath_txq_unlock(sc, txq); 1696a145daf7SSujith Manoharan } 1697a145daf7SSujith Manoharan exit: 1698a145daf7SSujith Manoharan retval = simple_read_from_buffer(user_buf, count, ppos, buf, len); 1699a145daf7SSujith Manoharan kfree(buf); 1700a145daf7SSujith Manoharan 1701a145daf7SSujith Manoharan return retval; 1702a145daf7SSujith Manoharan } 1703a145daf7SSujith Manoharan 1704a145daf7SSujith Manoharan static const struct file_operations fops_node_stat = { 1705a145daf7SSujith Manoharan .read = read_file_node_stat, 1706a145daf7SSujith Manoharan .open = simple_open, 1707a145daf7SSujith Manoharan .owner = THIS_MODULE, 1708a145daf7SSujith Manoharan .llseek = default_llseek, 1709a145daf7SSujith Manoharan }; 1710a145daf7SSujith Manoharan 1711a145daf7SSujith Manoharan void ath9k_sta_add_debugfs(struct ieee80211_hw *hw, 1712a145daf7SSujith Manoharan struct ieee80211_vif *vif, 1713a145daf7SSujith Manoharan struct ieee80211_sta *sta, 1714a145daf7SSujith Manoharan struct dentry *dir) 1715a145daf7SSujith Manoharan { 1716a145daf7SSujith Manoharan struct ath_node *an = (struct ath_node *)sta->drv_priv; 1717a145daf7SSujith Manoharan an->node_stat = debugfs_create_file("node_stat", S_IRUGO, 1718a145daf7SSujith Manoharan dir, an, &fops_node_stat); 1719a145daf7SSujith Manoharan } 1720a145daf7SSujith Manoharan 1721a145daf7SSujith Manoharan void ath9k_sta_remove_debugfs(struct ieee80211_hw *hw, 1722a145daf7SSujith Manoharan struct ieee80211_vif *vif, 1723a145daf7SSujith Manoharan struct ieee80211_sta *sta, 1724a145daf7SSujith Manoharan struct dentry *dir) 1725a145daf7SSujith Manoharan { 1726a145daf7SSujith Manoharan struct ath_node *an = (struct ath_node *)sta->drv_priv; 1727a145daf7SSujith Manoharan debugfs_remove(an->node_stat); 1728a145daf7SSujith Manoharan } 1729a145daf7SSujith Manoharan 1730c175db87SSujith Manoharan /* Ethtool support for get-stats */ 1731c175db87SSujith Manoharan 1732c175db87SSujith Manoharan #define AMKSTR(nm) #nm "_BE", #nm "_BK", #nm "_VI", #nm "_VO" 1733c175db87SSujith Manoharan static const char ath9k_gstrings_stats[][ETH_GSTRING_LEN] = { 1734c175db87SSujith Manoharan "tx_pkts_nic", 1735c175db87SSujith Manoharan "tx_bytes_nic", 1736c175db87SSujith Manoharan "rx_pkts_nic", 1737c175db87SSujith Manoharan "rx_bytes_nic", 1738c175db87SSujith Manoharan AMKSTR(d_tx_pkts), 1739c175db87SSujith Manoharan AMKSTR(d_tx_bytes), 1740c175db87SSujith Manoharan AMKSTR(d_tx_mpdus_queued), 1741c175db87SSujith Manoharan AMKSTR(d_tx_mpdus_completed), 1742c175db87SSujith Manoharan AMKSTR(d_tx_mpdu_xretries), 1743c175db87SSujith Manoharan AMKSTR(d_tx_aggregates), 1744c175db87SSujith Manoharan AMKSTR(d_tx_ampdus_queued_hw), 1745c175db87SSujith Manoharan AMKSTR(d_tx_ampdus_queued_sw), 1746c175db87SSujith Manoharan AMKSTR(d_tx_ampdus_completed), 1747c175db87SSujith Manoharan AMKSTR(d_tx_ampdu_retries), 1748c175db87SSujith Manoharan AMKSTR(d_tx_ampdu_xretries), 1749c175db87SSujith Manoharan AMKSTR(d_tx_fifo_underrun), 1750c175db87SSujith Manoharan AMKSTR(d_tx_op_exceeded), 1751c175db87SSujith Manoharan AMKSTR(d_tx_timer_expiry), 1752c175db87SSujith Manoharan AMKSTR(d_tx_desc_cfg_err), 1753c175db87SSujith Manoharan AMKSTR(d_tx_data_underrun), 1754c175db87SSujith Manoharan AMKSTR(d_tx_delim_underrun), 175518c45b10SBen Greear "d_rx_crc_err", 1756c175db87SSujith Manoharan "d_rx_decrypt_crc_err", 1757c175db87SSujith Manoharan "d_rx_phy_err", 1758c175db87SSujith Manoharan "d_rx_mic_err", 1759c175db87SSujith Manoharan "d_rx_pre_delim_crc_err", 1760c175db87SSujith Manoharan "d_rx_post_delim_crc_err", 1761c175db87SSujith Manoharan "d_rx_decrypt_busy_err", 1762c175db87SSujith Manoharan 1763c175db87SSujith Manoharan "d_rx_phyerr_radar", 1764c175db87SSujith Manoharan "d_rx_phyerr_ofdm_timing", 1765c175db87SSujith Manoharan "d_rx_phyerr_cck_timing", 1766c175db87SSujith Manoharan 1767c175db87SSujith Manoharan }; 1768c175db87SSujith Manoharan #define ATH9K_SSTATS_LEN ARRAY_SIZE(ath9k_gstrings_stats) 1769c175db87SSujith Manoharan 1770c175db87SSujith Manoharan void ath9k_get_et_strings(struct ieee80211_hw *hw, 1771c175db87SSujith Manoharan struct ieee80211_vif *vif, 1772c175db87SSujith Manoharan u32 sset, u8 *data) 1773c175db87SSujith Manoharan { 1774c175db87SSujith Manoharan if (sset == ETH_SS_STATS) 1775c175db87SSujith Manoharan memcpy(data, *ath9k_gstrings_stats, 1776c175db87SSujith Manoharan sizeof(ath9k_gstrings_stats)); 1777c175db87SSujith Manoharan } 1778c175db87SSujith Manoharan 1779c175db87SSujith Manoharan int ath9k_get_et_sset_count(struct ieee80211_hw *hw, 1780c175db87SSujith Manoharan struct ieee80211_vif *vif, int sset) 1781c175db87SSujith Manoharan { 1782c175db87SSujith Manoharan if (sset == ETH_SS_STATS) 1783c175db87SSujith Manoharan return ATH9K_SSTATS_LEN; 1784c175db87SSujith Manoharan return 0; 1785c175db87SSujith Manoharan } 1786c175db87SSujith Manoharan 1787c175db87SSujith Manoharan #define AWDATA(elem) \ 1788c175db87SSujith Manoharan do { \ 1789c175db87SSujith Manoharan data[i++] = sc->debug.stats.txstats[PR_QNUM(IEEE80211_AC_BE)].elem; \ 1790c175db87SSujith Manoharan data[i++] = sc->debug.stats.txstats[PR_QNUM(IEEE80211_AC_BK)].elem; \ 1791c175db87SSujith Manoharan data[i++] = sc->debug.stats.txstats[PR_QNUM(IEEE80211_AC_VI)].elem; \ 1792c175db87SSujith Manoharan data[i++] = sc->debug.stats.txstats[PR_QNUM(IEEE80211_AC_VO)].elem; \ 1793c175db87SSujith Manoharan } while (0) 1794c175db87SSujith Manoharan 1795c175db87SSujith Manoharan #define AWDATA_RX(elem) \ 1796c175db87SSujith Manoharan do { \ 1797c175db87SSujith Manoharan data[i++] = sc->debug.stats.rxstats.elem; \ 1798c175db87SSujith Manoharan } while (0) 1799c175db87SSujith Manoharan 1800c175db87SSujith Manoharan void ath9k_get_et_stats(struct ieee80211_hw *hw, 1801c175db87SSujith Manoharan struct ieee80211_vif *vif, 1802c175db87SSujith Manoharan struct ethtool_stats *stats, u64 *data) 1803c175db87SSujith Manoharan { 1804c175db87SSujith Manoharan struct ath_softc *sc = hw->priv; 1805c175db87SSujith Manoharan int i = 0; 1806c175db87SSujith Manoharan 1807c175db87SSujith Manoharan data[i++] = (sc->debug.stats.txstats[PR_QNUM(IEEE80211_AC_BE)].tx_pkts_all + 1808c175db87SSujith Manoharan sc->debug.stats.txstats[PR_QNUM(IEEE80211_AC_BK)].tx_pkts_all + 1809c175db87SSujith Manoharan sc->debug.stats.txstats[PR_QNUM(IEEE80211_AC_VI)].tx_pkts_all + 1810c175db87SSujith Manoharan sc->debug.stats.txstats[PR_QNUM(IEEE80211_AC_VO)].tx_pkts_all); 1811c175db87SSujith Manoharan data[i++] = (sc->debug.stats.txstats[PR_QNUM(IEEE80211_AC_BE)].tx_bytes_all + 1812c175db87SSujith Manoharan sc->debug.stats.txstats[PR_QNUM(IEEE80211_AC_BK)].tx_bytes_all + 1813c175db87SSujith Manoharan sc->debug.stats.txstats[PR_QNUM(IEEE80211_AC_VI)].tx_bytes_all + 1814c175db87SSujith Manoharan sc->debug.stats.txstats[PR_QNUM(IEEE80211_AC_VO)].tx_bytes_all); 1815c175db87SSujith Manoharan AWDATA_RX(rx_pkts_all); 1816c175db87SSujith Manoharan AWDATA_RX(rx_bytes_all); 1817c175db87SSujith Manoharan 1818c175db87SSujith Manoharan AWDATA(tx_pkts_all); 1819c175db87SSujith Manoharan AWDATA(tx_bytes_all); 1820c175db87SSujith Manoharan AWDATA(queued); 1821c175db87SSujith Manoharan AWDATA(completed); 1822c175db87SSujith Manoharan AWDATA(xretries); 1823c175db87SSujith Manoharan AWDATA(a_aggr); 1824c175db87SSujith Manoharan AWDATA(a_queued_hw); 1825c175db87SSujith Manoharan AWDATA(a_queued_sw); 1826c175db87SSujith Manoharan AWDATA(a_completed); 1827c175db87SSujith Manoharan AWDATA(a_retries); 1828c175db87SSujith Manoharan AWDATA(a_xretries); 1829c175db87SSujith Manoharan AWDATA(fifo_underrun); 1830c175db87SSujith Manoharan AWDATA(xtxop); 1831c175db87SSujith Manoharan AWDATA(timer_exp); 1832c175db87SSujith Manoharan AWDATA(desc_cfg_err); 1833c175db87SSujith Manoharan AWDATA(data_underrun); 1834c175db87SSujith Manoharan AWDATA(delim_underrun); 1835c175db87SSujith Manoharan 183618c45b10SBen Greear AWDATA_RX(crc_err); 1837c175db87SSujith Manoharan AWDATA_RX(decrypt_crc_err); 1838c175db87SSujith Manoharan AWDATA_RX(phy_err); 1839c175db87SSujith Manoharan AWDATA_RX(mic_err); 1840c175db87SSujith Manoharan AWDATA_RX(pre_delim_crc_err); 1841c175db87SSujith Manoharan AWDATA_RX(post_delim_crc_err); 1842c175db87SSujith Manoharan AWDATA_RX(decrypt_busy_err); 1843c175db87SSujith Manoharan 1844c175db87SSujith Manoharan AWDATA_RX(phy_err_stats[ATH9K_PHYERR_RADAR]); 1845c175db87SSujith Manoharan AWDATA_RX(phy_err_stats[ATH9K_PHYERR_OFDM_TIMING]); 1846c175db87SSujith Manoharan AWDATA_RX(phy_err_stats[ATH9K_PHYERR_CCK_TIMING]); 1847c175db87SSujith Manoharan 1848c175db87SSujith Manoharan WARN_ON(i != ATH9K_SSTATS_LEN); 1849c175db87SSujith Manoharan } 1850c175db87SSujith Manoharan 1851af690092SSujith Manoharan void ath9k_deinit_debug(struct ath_softc *sc) 1852af690092SSujith Manoharan { 1853af690092SSujith Manoharan if (config_enabled(CONFIG_ATH9K_DEBUGFS) && sc->rfs_chan_spec_scan) { 1854af690092SSujith Manoharan relay_close(sc->rfs_chan_spec_scan); 1855af690092SSujith Manoharan sc->rfs_chan_spec_scan = NULL; 1856af690092SSujith Manoharan } 1857af690092SSujith Manoharan } 1858af690092SSujith Manoharan 18594d6b228dSLuis R. Rodriguez int ath9k_init_debug(struct ath_hw *ah) 1860203c4805SLuis R. Rodriguez { 1861bc974f4aSLuis R. Rodriguez struct ath_common *common = ath9k_hw_common(ah); 1862bc974f4aSLuis R. Rodriguez struct ath_softc *sc = (struct ath_softc *) common->priv; 18634d6b228dSLuis R. Rodriguez 1864eb272441SBen Greear sc->debug.debugfs_phy = debugfs_create_dir("ath9k", 1865eb272441SBen Greear sc->hw->wiphy->debugfsdir); 1866203c4805SLuis R. Rodriguez if (!sc->debug.debugfs_phy) 1867c8a72c00SFelix Fietkau return -ENOMEM; 1868203c4805SLuis R. Rodriguez 1869a830df07SFelix Fietkau #ifdef CONFIG_ATH_DEBUG 1870c70cab1aSFelix Fietkau debugfs_create_file("debug", S_IRUSR | S_IWUSR, sc->debug.debugfs_phy, 1871c70cab1aSFelix Fietkau sc, &fops_debug); 1872a830df07SFelix Fietkau #endif 187329942bc1SZefir Kurtisi 187429942bc1SZefir Kurtisi ath9k_dfs_init_debug(sc); 187529942bc1SZefir Kurtisi 1876c70cab1aSFelix Fietkau debugfs_create_file("dma", S_IRUSR, sc->debug.debugfs_phy, sc, 1877c70cab1aSFelix Fietkau &fops_dma); 1878c70cab1aSFelix Fietkau debugfs_create_file("interrupt", S_IRUSR, sc->debug.debugfs_phy, sc, 1879c70cab1aSFelix Fietkau &fops_interrupt); 1880c70cab1aSFelix Fietkau debugfs_create_file("xmit", S_IRUSR, sc->debug.debugfs_phy, sc, 1881c70cab1aSFelix Fietkau &fops_xmit); 1882c0b74876SSujith Manoharan debugfs_create_file("queues", S_IRUSR, sc->debug.debugfs_phy, sc, 1883c0b74876SSujith Manoharan &fops_queues); 18847702e788SFelix Fietkau debugfs_create_u32("qlen_bk", S_IRUSR | S_IWUSR, sc->debug.debugfs_phy, 1885bea843c7SSujith Manoharan &sc->tx.txq_max_pending[IEEE80211_AC_BK]); 18867702e788SFelix Fietkau debugfs_create_u32("qlen_be", S_IRUSR | S_IWUSR, sc->debug.debugfs_phy, 1887bea843c7SSujith Manoharan &sc->tx.txq_max_pending[IEEE80211_AC_BE]); 18887702e788SFelix Fietkau debugfs_create_u32("qlen_vi", S_IRUSR | S_IWUSR, sc->debug.debugfs_phy, 1889bea843c7SSujith Manoharan &sc->tx.txq_max_pending[IEEE80211_AC_VI]); 18907702e788SFelix Fietkau debugfs_create_u32("qlen_vo", S_IRUSR | S_IWUSR, sc->debug.debugfs_phy, 1891bea843c7SSujith Manoharan &sc->tx.txq_max_pending[IEEE80211_AC_VO]); 1892c70cab1aSFelix Fietkau debugfs_create_file("misc", S_IRUSR, sc->debug.debugfs_phy, sc, 1893c70cab1aSFelix Fietkau &fops_misc); 1894f8b815dcSSujith Manoharan debugfs_create_file("reset", S_IRUSR, sc->debug.debugfs_phy, sc, 1895f8b815dcSSujith Manoharan &fops_reset); 1896c70cab1aSFelix Fietkau debugfs_create_file("recv", S_IRUSR, sc->debug.debugfs_phy, sc, 1897c70cab1aSFelix Fietkau &fops_recv); 1898c70cab1aSFelix Fietkau debugfs_create_file("rx_chainmask", S_IRUSR | S_IWUSR, 1899c70cab1aSFelix Fietkau sc->debug.debugfs_phy, sc, &fops_rx_chainmask); 1900c70cab1aSFelix Fietkau debugfs_create_file("tx_chainmask", S_IRUSR | S_IWUSR, 1901c70cab1aSFelix Fietkau sc->debug.debugfs_phy, sc, &fops_tx_chainmask); 19026e4d291eSSujith Manoharan debugfs_create_file("ani", S_IRUSR | S_IWUSR, 19036e4d291eSSujith Manoharan sc->debug.debugfs_phy, sc, &fops_ani); 190474673db9SFelix Fietkau debugfs_create_bool("paprd", S_IRUSR | S_IWUSR, sc->debug.debugfs_phy, 190574673db9SFelix Fietkau &sc->sc_ah->config.enable_paprd); 1906c70cab1aSFelix Fietkau debugfs_create_file("regidx", S_IRUSR | S_IWUSR, sc->debug.debugfs_phy, 1907c70cab1aSFelix Fietkau sc, &fops_regidx); 1908c70cab1aSFelix Fietkau debugfs_create_file("regval", S_IRUSR | S_IWUSR, sc->debug.debugfs_phy, 1909c70cab1aSFelix Fietkau sc, &fops_regval); 1910c70cab1aSFelix Fietkau debugfs_create_bool("ignore_extcca", S_IRUSR | S_IWUSR, 1911c70cab1aSFelix Fietkau sc->debug.debugfs_phy, 1912c70cab1aSFelix Fietkau &ah->config.cwm_ignore_extcca); 1913c70cab1aSFelix Fietkau debugfs_create_file("regdump", S_IRUSR, sc->debug.debugfs_phy, sc, 1914c70cab1aSFelix Fietkau &fops_regdump); 1915d069a46bSRajkumar Manoharan debugfs_create_file("dump_nfcal", S_IRUSR, sc->debug.debugfs_phy, sc, 1916d069a46bSRajkumar Manoharan &fops_dump_nfcal); 1917580f010fSRajkumar Manoharan debugfs_create_file("base_eeprom", S_IRUSR, sc->debug.debugfs_phy, sc, 1918580f010fSRajkumar Manoharan &fops_base_eeprom); 19193f4c4bddSRajkumar Manoharan debugfs_create_file("modal_eeprom", S_IRUSR, sc->debug.debugfs_phy, sc, 19203f4c4bddSRajkumar Manoharan &fops_modal_eeprom); 1921e93d083fSSimon Wunderlich sc->rfs_chan_spec_scan = relay_open("spectral_scan", 1922e93d083fSSimon Wunderlich sc->debug.debugfs_phy, 192355f39e67SZefir Kurtisi 1024, 256, &rfs_spec_scan_cb, 1924e93d083fSSimon Wunderlich NULL); 1925e93d083fSSimon Wunderlich debugfs_create_file("spectral_scan_ctl", S_IRUSR | S_IWUSR, 1926e93d083fSSimon Wunderlich sc->debug.debugfs_phy, sc, 1927e93d083fSSimon Wunderlich &fops_spec_scan_ctl); 192804ccd4a1SSimon Wunderlich debugfs_create_file("spectral_short_repeat", S_IRUSR | S_IWUSR, 192904ccd4a1SSimon Wunderlich sc->debug.debugfs_phy, sc, 193004ccd4a1SSimon Wunderlich &fops_spectral_short_repeat); 193104ccd4a1SSimon Wunderlich debugfs_create_file("spectral_count", S_IRUSR | S_IWUSR, 193204ccd4a1SSimon Wunderlich sc->debug.debugfs_phy, sc, &fops_spectral_count); 193304ccd4a1SSimon Wunderlich debugfs_create_file("spectral_period", S_IRUSR | S_IWUSR, 193404ccd4a1SSimon Wunderlich sc->debug.debugfs_phy, sc, &fops_spectral_period); 193504ccd4a1SSimon Wunderlich debugfs_create_file("spectral_fft_period", S_IRUSR | S_IWUSR, 193604ccd4a1SSimon Wunderlich sc->debug.debugfs_phy, sc, 193704ccd4a1SSimon Wunderlich &fops_spectral_fft_period); 1938691680b8SFelix Fietkau debugfs_create_u32("gpio_mask", S_IRUSR | S_IWUSR, 1939691680b8SFelix Fietkau sc->debug.debugfs_phy, &sc->sc_ah->gpio_mask); 1940691680b8SFelix Fietkau debugfs_create_u32("gpio_val", S_IRUSR | S_IWUSR, 1941691680b8SFelix Fietkau sc->debug.debugfs_phy, &sc->sc_ah->gpio_val); 19424eba10ccSSujith Manoharan debugfs_create_file("antenna_diversity", S_IRUSR, 19434eba10ccSSujith Manoharan sc->debug.debugfs_phy, sc, &fops_antenna_diversity); 19444df50ca8SRajkumar Manoharan #ifdef CONFIG_ATH9K_BTCOEX_SUPPORT 1945*36e8825eSSujith Manoharan debugfs_create_file("bt_ant_diversity", S_IRUSR | S_IWUSR, 1946*36e8825eSSujith Manoharan sc->debug.debugfs_phy, sc, &fops_bt_ant_diversity); 19474df50ca8SRajkumar Manoharan debugfs_create_file("btcoex", S_IRUSR, sc->debug.debugfs_phy, sc, 19484df50ca8SRajkumar Manoharan &fops_btcoex); 19494df50ca8SRajkumar Manoharan #endif 1950203c4805SLuis R. Rodriguez return 0; 1951203c4805SLuis R. Rodriguez } 1952