18c2ecf20Sopenharmony_ci/* 28c2ecf20Sopenharmony_ci * Copyright (c) 2008-2011 Atheros Communications Inc. 38c2ecf20Sopenharmony_ci * 48c2ecf20Sopenharmony_ci * Permission to use, copy, modify, and/or distribute this software for any 58c2ecf20Sopenharmony_ci * purpose with or without fee is hereby granted, provided that the above 68c2ecf20Sopenharmony_ci * copyright notice and this permission notice appear in all copies. 78c2ecf20Sopenharmony_ci * 88c2ecf20Sopenharmony_ci * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 98c2ecf20Sopenharmony_ci * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 108c2ecf20Sopenharmony_ci * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 118c2ecf20Sopenharmony_ci * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 128c2ecf20Sopenharmony_ci * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 138c2ecf20Sopenharmony_ci * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 148c2ecf20Sopenharmony_ci * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 158c2ecf20Sopenharmony_ci */ 168c2ecf20Sopenharmony_ci 178c2ecf20Sopenharmony_ci#include <linux/slab.h> 188c2ecf20Sopenharmony_ci#include <linux/vmalloc.h> 198c2ecf20Sopenharmony_ci#include <linux/export.h> 208c2ecf20Sopenharmony_ci#include <asm/unaligned.h> 218c2ecf20Sopenharmony_ci 228c2ecf20Sopenharmony_ci#include "ath9k.h" 238c2ecf20Sopenharmony_ci 248c2ecf20Sopenharmony_ci#define REG_WRITE_D(_ah, _reg, _val) \ 258c2ecf20Sopenharmony_ci ath9k_hw_common(_ah)->ops->write((_ah), (_val), (_reg)) 268c2ecf20Sopenharmony_ci#define REG_READ_D(_ah, _reg) \ 278c2ecf20Sopenharmony_ci ath9k_hw_common(_ah)->ops->read((_ah), (_reg)) 288c2ecf20Sopenharmony_ci 298c2ecf20Sopenharmony_civoid ath9k_debug_sync_cause(struct ath_softc *sc, u32 sync_cause) 308c2ecf20Sopenharmony_ci{ 318c2ecf20Sopenharmony_ci if (sync_cause) 328c2ecf20Sopenharmony_ci sc->debug.stats.istats.sync_cause_all++; 338c2ecf20Sopenharmony_ci if (sync_cause & AR_INTR_SYNC_RTC_IRQ) 348c2ecf20Sopenharmony_ci sc->debug.stats.istats.sync_rtc_irq++; 358c2ecf20Sopenharmony_ci if (sync_cause & AR_INTR_SYNC_MAC_IRQ) 368c2ecf20Sopenharmony_ci sc->debug.stats.istats.sync_mac_irq++; 378c2ecf20Sopenharmony_ci if (sync_cause & AR_INTR_SYNC_EEPROM_ILLEGAL_ACCESS) 388c2ecf20Sopenharmony_ci sc->debug.stats.istats.eeprom_illegal_access++; 398c2ecf20Sopenharmony_ci if (sync_cause & AR_INTR_SYNC_APB_TIMEOUT) 408c2ecf20Sopenharmony_ci sc->debug.stats.istats.apb_timeout++; 418c2ecf20Sopenharmony_ci if (sync_cause & AR_INTR_SYNC_PCI_MODE_CONFLICT) 428c2ecf20Sopenharmony_ci sc->debug.stats.istats.pci_mode_conflict++; 438c2ecf20Sopenharmony_ci if (sync_cause & AR_INTR_SYNC_HOST1_FATAL) 448c2ecf20Sopenharmony_ci sc->debug.stats.istats.host1_fatal++; 458c2ecf20Sopenharmony_ci if (sync_cause & AR_INTR_SYNC_HOST1_PERR) 468c2ecf20Sopenharmony_ci sc->debug.stats.istats.host1_perr++; 478c2ecf20Sopenharmony_ci if (sync_cause & AR_INTR_SYNC_TRCV_FIFO_PERR) 488c2ecf20Sopenharmony_ci sc->debug.stats.istats.trcv_fifo_perr++; 498c2ecf20Sopenharmony_ci if (sync_cause & AR_INTR_SYNC_RADM_CPL_EP) 508c2ecf20Sopenharmony_ci sc->debug.stats.istats.radm_cpl_ep++; 518c2ecf20Sopenharmony_ci if (sync_cause & AR_INTR_SYNC_RADM_CPL_DLLP_ABORT) 528c2ecf20Sopenharmony_ci sc->debug.stats.istats.radm_cpl_dllp_abort++; 538c2ecf20Sopenharmony_ci if (sync_cause & AR_INTR_SYNC_RADM_CPL_TLP_ABORT) 548c2ecf20Sopenharmony_ci sc->debug.stats.istats.radm_cpl_tlp_abort++; 558c2ecf20Sopenharmony_ci if (sync_cause & AR_INTR_SYNC_RADM_CPL_ECRC_ERR) 568c2ecf20Sopenharmony_ci sc->debug.stats.istats.radm_cpl_ecrc_err++; 578c2ecf20Sopenharmony_ci if (sync_cause & AR_INTR_SYNC_RADM_CPL_TIMEOUT) 588c2ecf20Sopenharmony_ci sc->debug.stats.istats.radm_cpl_timeout++; 598c2ecf20Sopenharmony_ci if (sync_cause & AR_INTR_SYNC_LOCAL_TIMEOUT) 608c2ecf20Sopenharmony_ci sc->debug.stats.istats.local_timeout++; 618c2ecf20Sopenharmony_ci if (sync_cause & AR_INTR_SYNC_PM_ACCESS) 628c2ecf20Sopenharmony_ci sc->debug.stats.istats.pm_access++; 638c2ecf20Sopenharmony_ci if (sync_cause & AR_INTR_SYNC_MAC_AWAKE) 648c2ecf20Sopenharmony_ci sc->debug.stats.istats.mac_awake++; 658c2ecf20Sopenharmony_ci if (sync_cause & AR_INTR_SYNC_MAC_ASLEEP) 668c2ecf20Sopenharmony_ci sc->debug.stats.istats.mac_asleep++; 678c2ecf20Sopenharmony_ci if (sync_cause & AR_INTR_SYNC_MAC_SLEEP_ACCESS) 688c2ecf20Sopenharmony_ci sc->debug.stats.istats.mac_sleep_access++; 698c2ecf20Sopenharmony_ci} 708c2ecf20Sopenharmony_ci 718c2ecf20Sopenharmony_cistatic ssize_t ath9k_debugfs_read_buf(struct file *file, char __user *user_buf, 728c2ecf20Sopenharmony_ci size_t count, loff_t *ppos) 738c2ecf20Sopenharmony_ci{ 748c2ecf20Sopenharmony_ci u8 *buf = file->private_data; 758c2ecf20Sopenharmony_ci return simple_read_from_buffer(user_buf, count, ppos, buf, strlen(buf)); 768c2ecf20Sopenharmony_ci} 778c2ecf20Sopenharmony_ci 788c2ecf20Sopenharmony_cistatic int ath9k_debugfs_release_buf(struct inode *inode, struct file *file) 798c2ecf20Sopenharmony_ci{ 808c2ecf20Sopenharmony_ci vfree(file->private_data); 818c2ecf20Sopenharmony_ci return 0; 828c2ecf20Sopenharmony_ci} 838c2ecf20Sopenharmony_ci 848c2ecf20Sopenharmony_ci#ifdef CONFIG_ATH_DEBUG 858c2ecf20Sopenharmony_ci 868c2ecf20Sopenharmony_cistatic ssize_t read_file_debug(struct file *file, char __user *user_buf, 878c2ecf20Sopenharmony_ci size_t count, loff_t *ppos) 888c2ecf20Sopenharmony_ci{ 898c2ecf20Sopenharmony_ci struct ath_softc *sc = file->private_data; 908c2ecf20Sopenharmony_ci struct ath_common *common = ath9k_hw_common(sc->sc_ah); 918c2ecf20Sopenharmony_ci char buf[32]; 928c2ecf20Sopenharmony_ci unsigned int len; 938c2ecf20Sopenharmony_ci 948c2ecf20Sopenharmony_ci len = sprintf(buf, "0x%08x\n", common->debug_mask); 958c2ecf20Sopenharmony_ci return simple_read_from_buffer(user_buf, count, ppos, buf, len); 968c2ecf20Sopenharmony_ci} 978c2ecf20Sopenharmony_ci 988c2ecf20Sopenharmony_cistatic ssize_t write_file_debug(struct file *file, const char __user *user_buf, 998c2ecf20Sopenharmony_ci size_t count, loff_t *ppos) 1008c2ecf20Sopenharmony_ci{ 1018c2ecf20Sopenharmony_ci struct ath_softc *sc = file->private_data; 1028c2ecf20Sopenharmony_ci struct ath_common *common = ath9k_hw_common(sc->sc_ah); 1038c2ecf20Sopenharmony_ci unsigned long mask; 1048c2ecf20Sopenharmony_ci char buf[32]; 1058c2ecf20Sopenharmony_ci ssize_t len; 1068c2ecf20Sopenharmony_ci 1078c2ecf20Sopenharmony_ci len = min(count, sizeof(buf) - 1); 1088c2ecf20Sopenharmony_ci if (copy_from_user(buf, user_buf, len)) 1098c2ecf20Sopenharmony_ci return -EFAULT; 1108c2ecf20Sopenharmony_ci 1118c2ecf20Sopenharmony_ci buf[len] = '\0'; 1128c2ecf20Sopenharmony_ci if (kstrtoul(buf, 0, &mask)) 1138c2ecf20Sopenharmony_ci return -EINVAL; 1148c2ecf20Sopenharmony_ci 1158c2ecf20Sopenharmony_ci common->debug_mask = mask; 1168c2ecf20Sopenharmony_ci return count; 1178c2ecf20Sopenharmony_ci} 1188c2ecf20Sopenharmony_ci 1198c2ecf20Sopenharmony_cistatic const struct file_operations fops_debug = { 1208c2ecf20Sopenharmony_ci .read = read_file_debug, 1218c2ecf20Sopenharmony_ci .write = write_file_debug, 1228c2ecf20Sopenharmony_ci .open = simple_open, 1238c2ecf20Sopenharmony_ci .owner = THIS_MODULE, 1248c2ecf20Sopenharmony_ci .llseek = default_llseek, 1258c2ecf20Sopenharmony_ci}; 1268c2ecf20Sopenharmony_ci 1278c2ecf20Sopenharmony_ci#endif 1288c2ecf20Sopenharmony_ci 1298c2ecf20Sopenharmony_ci#define DMA_BUF_LEN 1024 1308c2ecf20Sopenharmony_ci 1318c2ecf20Sopenharmony_ci 1328c2ecf20Sopenharmony_cistatic ssize_t read_file_ani(struct file *file, char __user *user_buf, 1338c2ecf20Sopenharmony_ci size_t count, loff_t *ppos) 1348c2ecf20Sopenharmony_ci{ 1358c2ecf20Sopenharmony_ci struct ath_softc *sc = file->private_data; 1368c2ecf20Sopenharmony_ci struct ath_common *common = ath9k_hw_common(sc->sc_ah); 1378c2ecf20Sopenharmony_ci struct ath_hw *ah = sc->sc_ah; 1388c2ecf20Sopenharmony_ci unsigned int len = 0; 1398c2ecf20Sopenharmony_ci const unsigned int size = 1024; 1408c2ecf20Sopenharmony_ci ssize_t retval = 0; 1418c2ecf20Sopenharmony_ci char *buf; 1428c2ecf20Sopenharmony_ci int i; 1438c2ecf20Sopenharmony_ci struct { 1448c2ecf20Sopenharmony_ci const char *name; 1458c2ecf20Sopenharmony_ci unsigned int val; 1468c2ecf20Sopenharmony_ci } ani_info[] = { 1478c2ecf20Sopenharmony_ci { "ANI RESET", ah->stats.ast_ani_reset }, 1488c2ecf20Sopenharmony_ci { "OFDM LEVEL", ah->ani.ofdmNoiseImmunityLevel }, 1498c2ecf20Sopenharmony_ci { "CCK LEVEL", ah->ani.cckNoiseImmunityLevel }, 1508c2ecf20Sopenharmony_ci { "SPUR UP", ah->stats.ast_ani_spurup }, 1518c2ecf20Sopenharmony_ci { "SPUR DOWN", ah->stats.ast_ani_spurdown }, 1528c2ecf20Sopenharmony_ci { "OFDM WS-DET ON", ah->stats.ast_ani_ofdmon }, 1538c2ecf20Sopenharmony_ci { "OFDM WS-DET OFF", ah->stats.ast_ani_ofdmoff }, 1548c2ecf20Sopenharmony_ci { "MRC-CCK ON", ah->stats.ast_ani_ccklow }, 1558c2ecf20Sopenharmony_ci { "MRC-CCK OFF", ah->stats.ast_ani_cckhigh }, 1568c2ecf20Sopenharmony_ci { "FIR-STEP UP", ah->stats.ast_ani_stepup }, 1578c2ecf20Sopenharmony_ci { "FIR-STEP DOWN", ah->stats.ast_ani_stepdown }, 1588c2ecf20Sopenharmony_ci { "INV LISTENTIME", ah->stats.ast_ani_lneg_or_lzero }, 1598c2ecf20Sopenharmony_ci { "OFDM ERRORS", ah->stats.ast_ani_ofdmerrs }, 1608c2ecf20Sopenharmony_ci { "CCK ERRORS", ah->stats.ast_ani_cckerrs }, 1618c2ecf20Sopenharmony_ci }; 1628c2ecf20Sopenharmony_ci 1638c2ecf20Sopenharmony_ci buf = kzalloc(size, GFP_KERNEL); 1648c2ecf20Sopenharmony_ci if (buf == NULL) 1658c2ecf20Sopenharmony_ci return -ENOMEM; 1668c2ecf20Sopenharmony_ci 1678c2ecf20Sopenharmony_ci len += scnprintf(buf + len, size - len, "%15s: %s\n", "ANI", 1688c2ecf20Sopenharmony_ci common->disable_ani ? "DISABLED" : "ENABLED"); 1698c2ecf20Sopenharmony_ci 1708c2ecf20Sopenharmony_ci if (common->disable_ani) 1718c2ecf20Sopenharmony_ci goto exit; 1728c2ecf20Sopenharmony_ci 1738c2ecf20Sopenharmony_ci for (i = 0; i < ARRAY_SIZE(ani_info); i++) 1748c2ecf20Sopenharmony_ci len += scnprintf(buf + len, size - len, "%15s: %u\n", 1758c2ecf20Sopenharmony_ci ani_info[i].name, ani_info[i].val); 1768c2ecf20Sopenharmony_ci 1778c2ecf20Sopenharmony_ciexit: 1788c2ecf20Sopenharmony_ci if (len > size) 1798c2ecf20Sopenharmony_ci len = size; 1808c2ecf20Sopenharmony_ci 1818c2ecf20Sopenharmony_ci retval = simple_read_from_buffer(user_buf, count, ppos, buf, len); 1828c2ecf20Sopenharmony_ci kfree(buf); 1838c2ecf20Sopenharmony_ci 1848c2ecf20Sopenharmony_ci return retval; 1858c2ecf20Sopenharmony_ci} 1868c2ecf20Sopenharmony_ci 1878c2ecf20Sopenharmony_cistatic ssize_t write_file_ani(struct file *file, 1888c2ecf20Sopenharmony_ci const char __user *user_buf, 1898c2ecf20Sopenharmony_ci size_t count, loff_t *ppos) 1908c2ecf20Sopenharmony_ci{ 1918c2ecf20Sopenharmony_ci struct ath_softc *sc = file->private_data; 1928c2ecf20Sopenharmony_ci struct ath_common *common = ath9k_hw_common(sc->sc_ah); 1938c2ecf20Sopenharmony_ci unsigned long ani; 1948c2ecf20Sopenharmony_ci char buf[32]; 1958c2ecf20Sopenharmony_ci ssize_t len; 1968c2ecf20Sopenharmony_ci 1978c2ecf20Sopenharmony_ci len = min(count, sizeof(buf) - 1); 1988c2ecf20Sopenharmony_ci if (copy_from_user(buf, user_buf, len)) 1998c2ecf20Sopenharmony_ci return -EFAULT; 2008c2ecf20Sopenharmony_ci 2018c2ecf20Sopenharmony_ci buf[len] = '\0'; 2028c2ecf20Sopenharmony_ci if (kstrtoul(buf, 0, &ani)) 2038c2ecf20Sopenharmony_ci return -EINVAL; 2048c2ecf20Sopenharmony_ci 2058c2ecf20Sopenharmony_ci if (ani > 1) 2068c2ecf20Sopenharmony_ci return -EINVAL; 2078c2ecf20Sopenharmony_ci 2088c2ecf20Sopenharmony_ci common->disable_ani = !ani; 2098c2ecf20Sopenharmony_ci 2108c2ecf20Sopenharmony_ci if (common->disable_ani) { 2118c2ecf20Sopenharmony_ci clear_bit(ATH_OP_ANI_RUN, &common->op_flags); 2128c2ecf20Sopenharmony_ci ath_stop_ani(sc); 2138c2ecf20Sopenharmony_ci } else { 2148c2ecf20Sopenharmony_ci ath_check_ani(sc); 2158c2ecf20Sopenharmony_ci } 2168c2ecf20Sopenharmony_ci 2178c2ecf20Sopenharmony_ci return count; 2188c2ecf20Sopenharmony_ci} 2198c2ecf20Sopenharmony_ci 2208c2ecf20Sopenharmony_cistatic const struct file_operations fops_ani = { 2218c2ecf20Sopenharmony_ci .read = read_file_ani, 2228c2ecf20Sopenharmony_ci .write = write_file_ani, 2238c2ecf20Sopenharmony_ci .open = simple_open, 2248c2ecf20Sopenharmony_ci .owner = THIS_MODULE, 2258c2ecf20Sopenharmony_ci .llseek = default_llseek, 2268c2ecf20Sopenharmony_ci}; 2278c2ecf20Sopenharmony_ci 2288c2ecf20Sopenharmony_ci#ifdef CONFIG_ATH9K_BTCOEX_SUPPORT 2298c2ecf20Sopenharmony_ci 2308c2ecf20Sopenharmony_cistatic ssize_t read_file_bt_ant_diversity(struct file *file, 2318c2ecf20Sopenharmony_ci char __user *user_buf, 2328c2ecf20Sopenharmony_ci size_t count, loff_t *ppos) 2338c2ecf20Sopenharmony_ci{ 2348c2ecf20Sopenharmony_ci struct ath_softc *sc = file->private_data; 2358c2ecf20Sopenharmony_ci struct ath_common *common = ath9k_hw_common(sc->sc_ah); 2368c2ecf20Sopenharmony_ci char buf[32]; 2378c2ecf20Sopenharmony_ci unsigned int len; 2388c2ecf20Sopenharmony_ci 2398c2ecf20Sopenharmony_ci len = sprintf(buf, "%d\n", common->bt_ant_diversity); 2408c2ecf20Sopenharmony_ci return simple_read_from_buffer(user_buf, count, ppos, buf, len); 2418c2ecf20Sopenharmony_ci} 2428c2ecf20Sopenharmony_ci 2438c2ecf20Sopenharmony_cistatic ssize_t write_file_bt_ant_diversity(struct file *file, 2448c2ecf20Sopenharmony_ci const char __user *user_buf, 2458c2ecf20Sopenharmony_ci size_t count, loff_t *ppos) 2468c2ecf20Sopenharmony_ci{ 2478c2ecf20Sopenharmony_ci struct ath_softc *sc = file->private_data; 2488c2ecf20Sopenharmony_ci struct ath_common *common = ath9k_hw_common(sc->sc_ah); 2498c2ecf20Sopenharmony_ci struct ath9k_hw_capabilities *pCap = &sc->sc_ah->caps; 2508c2ecf20Sopenharmony_ci unsigned long bt_ant_diversity; 2518c2ecf20Sopenharmony_ci char buf[32]; 2528c2ecf20Sopenharmony_ci ssize_t len; 2538c2ecf20Sopenharmony_ci 2548c2ecf20Sopenharmony_ci len = min(count, sizeof(buf) - 1); 2558c2ecf20Sopenharmony_ci if (copy_from_user(buf, user_buf, len)) 2568c2ecf20Sopenharmony_ci return -EFAULT; 2578c2ecf20Sopenharmony_ci 2588c2ecf20Sopenharmony_ci if (!(pCap->hw_caps & ATH9K_HW_CAP_BT_ANT_DIV)) 2598c2ecf20Sopenharmony_ci goto exit; 2608c2ecf20Sopenharmony_ci 2618c2ecf20Sopenharmony_ci buf[len] = '\0'; 2628c2ecf20Sopenharmony_ci if (kstrtoul(buf, 0, &bt_ant_diversity)) 2638c2ecf20Sopenharmony_ci return -EINVAL; 2648c2ecf20Sopenharmony_ci 2658c2ecf20Sopenharmony_ci common->bt_ant_diversity = !!bt_ant_diversity; 2668c2ecf20Sopenharmony_ci ath9k_ps_wakeup(sc); 2678c2ecf20Sopenharmony_ci ath9k_hw_set_bt_ant_diversity(sc->sc_ah, common->bt_ant_diversity); 2688c2ecf20Sopenharmony_ci ath_dbg(common, CONFIG, "Enable WLAN/BT RX Antenna diversity: %d\n", 2698c2ecf20Sopenharmony_ci common->bt_ant_diversity); 2708c2ecf20Sopenharmony_ci ath9k_ps_restore(sc); 2718c2ecf20Sopenharmony_ciexit: 2728c2ecf20Sopenharmony_ci return count; 2738c2ecf20Sopenharmony_ci} 2748c2ecf20Sopenharmony_ci 2758c2ecf20Sopenharmony_cistatic const struct file_operations fops_bt_ant_diversity = { 2768c2ecf20Sopenharmony_ci .read = read_file_bt_ant_diversity, 2778c2ecf20Sopenharmony_ci .write = write_file_bt_ant_diversity, 2788c2ecf20Sopenharmony_ci .open = simple_open, 2798c2ecf20Sopenharmony_ci .owner = THIS_MODULE, 2808c2ecf20Sopenharmony_ci .llseek = default_llseek, 2818c2ecf20Sopenharmony_ci}; 2828c2ecf20Sopenharmony_ci 2838c2ecf20Sopenharmony_ci#endif 2848c2ecf20Sopenharmony_ci 2858c2ecf20Sopenharmony_civoid ath9k_debug_stat_ant(struct ath_softc *sc, 2868c2ecf20Sopenharmony_ci struct ath_hw_antcomb_conf *div_ant_conf, 2878c2ecf20Sopenharmony_ci int main_rssi_avg, int alt_rssi_avg) 2888c2ecf20Sopenharmony_ci{ 2898c2ecf20Sopenharmony_ci struct ath_antenna_stats *as_main = &sc->debug.stats.ant_stats[ANT_MAIN]; 2908c2ecf20Sopenharmony_ci struct ath_antenna_stats *as_alt = &sc->debug.stats.ant_stats[ANT_ALT]; 2918c2ecf20Sopenharmony_ci 2928c2ecf20Sopenharmony_ci as_main->lna_attempt_cnt[div_ant_conf->main_lna_conf]++; 2938c2ecf20Sopenharmony_ci as_alt->lna_attempt_cnt[div_ant_conf->alt_lna_conf]++; 2948c2ecf20Sopenharmony_ci 2958c2ecf20Sopenharmony_ci as_main->rssi_avg = main_rssi_avg; 2968c2ecf20Sopenharmony_ci as_alt->rssi_avg = alt_rssi_avg; 2978c2ecf20Sopenharmony_ci} 2988c2ecf20Sopenharmony_ci 2998c2ecf20Sopenharmony_cistatic ssize_t read_file_antenna_diversity(struct file *file, 3008c2ecf20Sopenharmony_ci char __user *user_buf, 3018c2ecf20Sopenharmony_ci size_t count, loff_t *ppos) 3028c2ecf20Sopenharmony_ci{ 3038c2ecf20Sopenharmony_ci struct ath_softc *sc = file->private_data; 3048c2ecf20Sopenharmony_ci struct ath_hw *ah = sc->sc_ah; 3058c2ecf20Sopenharmony_ci struct ath9k_hw_capabilities *pCap = &ah->caps; 3068c2ecf20Sopenharmony_ci struct ath_antenna_stats *as_main = &sc->debug.stats.ant_stats[ANT_MAIN]; 3078c2ecf20Sopenharmony_ci struct ath_antenna_stats *as_alt = &sc->debug.stats.ant_stats[ANT_ALT]; 3088c2ecf20Sopenharmony_ci struct ath_hw_antcomb_conf div_ant_conf; 3098c2ecf20Sopenharmony_ci unsigned int len = 0; 3108c2ecf20Sopenharmony_ci const unsigned int size = 1024; 3118c2ecf20Sopenharmony_ci ssize_t retval = 0; 3128c2ecf20Sopenharmony_ci char *buf; 3138c2ecf20Sopenharmony_ci static const char *lna_conf_str[4] = { 3148c2ecf20Sopenharmony_ci "LNA1_MINUS_LNA2", "LNA2", "LNA1", "LNA1_PLUS_LNA2" 3158c2ecf20Sopenharmony_ci }; 3168c2ecf20Sopenharmony_ci 3178c2ecf20Sopenharmony_ci buf = kzalloc(size, GFP_KERNEL); 3188c2ecf20Sopenharmony_ci if (buf == NULL) 3198c2ecf20Sopenharmony_ci return -ENOMEM; 3208c2ecf20Sopenharmony_ci 3218c2ecf20Sopenharmony_ci if (!(pCap->hw_caps & ATH9K_HW_CAP_ANT_DIV_COMB)) { 3228c2ecf20Sopenharmony_ci len += scnprintf(buf + len, size - len, "%s\n", 3238c2ecf20Sopenharmony_ci "Antenna Diversity Combining is disabled"); 3248c2ecf20Sopenharmony_ci goto exit; 3258c2ecf20Sopenharmony_ci } 3268c2ecf20Sopenharmony_ci 3278c2ecf20Sopenharmony_ci ath9k_ps_wakeup(sc); 3288c2ecf20Sopenharmony_ci ath9k_hw_antdiv_comb_conf_get(ah, &div_ant_conf); 3298c2ecf20Sopenharmony_ci len += scnprintf(buf + len, size - len, "Current MAIN config : %s\n", 3308c2ecf20Sopenharmony_ci lna_conf_str[div_ant_conf.main_lna_conf]); 3318c2ecf20Sopenharmony_ci len += scnprintf(buf + len, size - len, "Current ALT config : %s\n", 3328c2ecf20Sopenharmony_ci lna_conf_str[div_ant_conf.alt_lna_conf]); 3338c2ecf20Sopenharmony_ci len += scnprintf(buf + len, size - len, "Average MAIN RSSI : %d\n", 3348c2ecf20Sopenharmony_ci as_main->rssi_avg); 3358c2ecf20Sopenharmony_ci len += scnprintf(buf + len, size - len, "Average ALT RSSI : %d\n\n", 3368c2ecf20Sopenharmony_ci as_alt->rssi_avg); 3378c2ecf20Sopenharmony_ci ath9k_ps_restore(sc); 3388c2ecf20Sopenharmony_ci 3398c2ecf20Sopenharmony_ci len += scnprintf(buf + len, size - len, "Packet Receive Cnt:\n"); 3408c2ecf20Sopenharmony_ci len += scnprintf(buf + len, size - len, "-------------------\n"); 3418c2ecf20Sopenharmony_ci 3428c2ecf20Sopenharmony_ci len += scnprintf(buf + len, size - len, "%30s%15s\n", 3438c2ecf20Sopenharmony_ci "MAIN", "ALT"); 3448c2ecf20Sopenharmony_ci len += scnprintf(buf + len, size - len, "%-14s:%15d%15d\n", 3458c2ecf20Sopenharmony_ci "TOTAL COUNT", 3468c2ecf20Sopenharmony_ci as_main->recv_cnt, 3478c2ecf20Sopenharmony_ci as_alt->recv_cnt); 3488c2ecf20Sopenharmony_ci len += scnprintf(buf + len, size - len, "%-14s:%15d%15d\n", 3498c2ecf20Sopenharmony_ci "LNA1", 3508c2ecf20Sopenharmony_ci as_main->lna_recv_cnt[ATH_ANT_DIV_COMB_LNA1], 3518c2ecf20Sopenharmony_ci as_alt->lna_recv_cnt[ATH_ANT_DIV_COMB_LNA1]); 3528c2ecf20Sopenharmony_ci len += scnprintf(buf + len, size - len, "%-14s:%15d%15d\n", 3538c2ecf20Sopenharmony_ci "LNA2", 3548c2ecf20Sopenharmony_ci as_main->lna_recv_cnt[ATH_ANT_DIV_COMB_LNA2], 3558c2ecf20Sopenharmony_ci as_alt->lna_recv_cnt[ATH_ANT_DIV_COMB_LNA2]); 3568c2ecf20Sopenharmony_ci len += scnprintf(buf + len, size - len, "%-14s:%15d%15d\n", 3578c2ecf20Sopenharmony_ci "LNA1 + LNA2", 3588c2ecf20Sopenharmony_ci as_main->lna_recv_cnt[ATH_ANT_DIV_COMB_LNA1_PLUS_LNA2], 3598c2ecf20Sopenharmony_ci as_alt->lna_recv_cnt[ATH_ANT_DIV_COMB_LNA1_PLUS_LNA2]); 3608c2ecf20Sopenharmony_ci len += scnprintf(buf + len, size - len, "%-14s:%15d%15d\n", 3618c2ecf20Sopenharmony_ci "LNA1 - LNA2", 3628c2ecf20Sopenharmony_ci as_main->lna_recv_cnt[ATH_ANT_DIV_COMB_LNA1_MINUS_LNA2], 3638c2ecf20Sopenharmony_ci as_alt->lna_recv_cnt[ATH_ANT_DIV_COMB_LNA1_MINUS_LNA2]); 3648c2ecf20Sopenharmony_ci 3658c2ecf20Sopenharmony_ci len += scnprintf(buf + len, size - len, "\nLNA Config Attempts:\n"); 3668c2ecf20Sopenharmony_ci len += scnprintf(buf + len, size - len, "--------------------\n"); 3678c2ecf20Sopenharmony_ci 3688c2ecf20Sopenharmony_ci len += scnprintf(buf + len, size - len, "%30s%15s\n", 3698c2ecf20Sopenharmony_ci "MAIN", "ALT"); 3708c2ecf20Sopenharmony_ci len += scnprintf(buf + len, size - len, "%-14s:%15d%15d\n", 3718c2ecf20Sopenharmony_ci "LNA1", 3728c2ecf20Sopenharmony_ci as_main->lna_attempt_cnt[ATH_ANT_DIV_COMB_LNA1], 3738c2ecf20Sopenharmony_ci as_alt->lna_attempt_cnt[ATH_ANT_DIV_COMB_LNA1]); 3748c2ecf20Sopenharmony_ci len += scnprintf(buf + len, size - len, "%-14s:%15d%15d\n", 3758c2ecf20Sopenharmony_ci "LNA2", 3768c2ecf20Sopenharmony_ci as_main->lna_attempt_cnt[ATH_ANT_DIV_COMB_LNA2], 3778c2ecf20Sopenharmony_ci as_alt->lna_attempt_cnt[ATH_ANT_DIV_COMB_LNA2]); 3788c2ecf20Sopenharmony_ci len += scnprintf(buf + len, size - len, "%-14s:%15d%15d\n", 3798c2ecf20Sopenharmony_ci "LNA1 + LNA2", 3808c2ecf20Sopenharmony_ci as_main->lna_attempt_cnt[ATH_ANT_DIV_COMB_LNA1_PLUS_LNA2], 3818c2ecf20Sopenharmony_ci as_alt->lna_attempt_cnt[ATH_ANT_DIV_COMB_LNA1_PLUS_LNA2]); 3828c2ecf20Sopenharmony_ci len += scnprintf(buf + len, size - len, "%-14s:%15d%15d\n", 3838c2ecf20Sopenharmony_ci "LNA1 - LNA2", 3848c2ecf20Sopenharmony_ci as_main->lna_attempt_cnt[ATH_ANT_DIV_COMB_LNA1_MINUS_LNA2], 3858c2ecf20Sopenharmony_ci as_alt->lna_attempt_cnt[ATH_ANT_DIV_COMB_LNA1_MINUS_LNA2]); 3868c2ecf20Sopenharmony_ci 3878c2ecf20Sopenharmony_ciexit: 3888c2ecf20Sopenharmony_ci if (len > size) 3898c2ecf20Sopenharmony_ci len = size; 3908c2ecf20Sopenharmony_ci 3918c2ecf20Sopenharmony_ci retval = simple_read_from_buffer(user_buf, count, ppos, buf, len); 3928c2ecf20Sopenharmony_ci kfree(buf); 3938c2ecf20Sopenharmony_ci 3948c2ecf20Sopenharmony_ci return retval; 3958c2ecf20Sopenharmony_ci} 3968c2ecf20Sopenharmony_ci 3978c2ecf20Sopenharmony_cistatic const struct file_operations fops_antenna_diversity = { 3988c2ecf20Sopenharmony_ci .read = read_file_antenna_diversity, 3998c2ecf20Sopenharmony_ci .open = simple_open, 4008c2ecf20Sopenharmony_ci .owner = THIS_MODULE, 4018c2ecf20Sopenharmony_ci .llseek = default_llseek, 4028c2ecf20Sopenharmony_ci}; 4038c2ecf20Sopenharmony_ci 4048c2ecf20Sopenharmony_cistatic int read_file_dma(struct seq_file *file, void *data) 4058c2ecf20Sopenharmony_ci{ 4068c2ecf20Sopenharmony_ci struct ieee80211_hw *hw = dev_get_drvdata(file->private); 4078c2ecf20Sopenharmony_ci struct ath_softc *sc = hw->priv; 4088c2ecf20Sopenharmony_ci struct ath_hw *ah = sc->sc_ah; 4098c2ecf20Sopenharmony_ci u32 val[ATH9K_NUM_DMA_DEBUG_REGS]; 4108c2ecf20Sopenharmony_ci int i, qcuOffset = 0, dcuOffset = 0; 4118c2ecf20Sopenharmony_ci u32 *qcuBase = &val[0], *dcuBase = &val[4]; 4128c2ecf20Sopenharmony_ci 4138c2ecf20Sopenharmony_ci ath9k_ps_wakeup(sc); 4148c2ecf20Sopenharmony_ci 4158c2ecf20Sopenharmony_ci REG_WRITE_D(ah, AR_MACMISC, 4168c2ecf20Sopenharmony_ci ((AR_MACMISC_DMA_OBS_LINE_8 << AR_MACMISC_DMA_OBS_S) | 4178c2ecf20Sopenharmony_ci (AR_MACMISC_MISC_OBS_BUS_1 << 4188c2ecf20Sopenharmony_ci AR_MACMISC_MISC_OBS_BUS_MSB_S))); 4198c2ecf20Sopenharmony_ci 4208c2ecf20Sopenharmony_ci seq_puts(file, "Raw DMA Debug values:\n"); 4218c2ecf20Sopenharmony_ci 4228c2ecf20Sopenharmony_ci for (i = 0; i < ATH9K_NUM_DMA_DEBUG_REGS; i++) { 4238c2ecf20Sopenharmony_ci if (i % 4 == 0) 4248c2ecf20Sopenharmony_ci seq_puts(file, "\n"); 4258c2ecf20Sopenharmony_ci 4268c2ecf20Sopenharmony_ci val[i] = REG_READ_D(ah, AR_DMADBG_0 + (i * sizeof(u32))); 4278c2ecf20Sopenharmony_ci seq_printf(file, "%d: %08x ", i, val[i]); 4288c2ecf20Sopenharmony_ci } 4298c2ecf20Sopenharmony_ci 4308c2ecf20Sopenharmony_ci seq_puts(file, "\n\n"); 4318c2ecf20Sopenharmony_ci seq_puts(file, "Num QCU: chain_st fsp_ok fsp_st DCU: chain_st\n"); 4328c2ecf20Sopenharmony_ci 4338c2ecf20Sopenharmony_ci for (i = 0; i < ATH9K_NUM_QUEUES; i++, qcuOffset += 4, dcuOffset += 5) { 4348c2ecf20Sopenharmony_ci if (i == 8) { 4358c2ecf20Sopenharmony_ci qcuOffset = 0; 4368c2ecf20Sopenharmony_ci qcuBase++; 4378c2ecf20Sopenharmony_ci } 4388c2ecf20Sopenharmony_ci 4398c2ecf20Sopenharmony_ci if (i == 6) { 4408c2ecf20Sopenharmony_ci dcuOffset = 0; 4418c2ecf20Sopenharmony_ci dcuBase++; 4428c2ecf20Sopenharmony_ci } 4438c2ecf20Sopenharmony_ci 4448c2ecf20Sopenharmony_ci seq_printf(file, "%2d %2x %1x %2x %2x\n", 4458c2ecf20Sopenharmony_ci i, (*qcuBase & (0x7 << qcuOffset)) >> qcuOffset, 4468c2ecf20Sopenharmony_ci (*qcuBase & (0x8 << qcuOffset)) >> (qcuOffset + 3), 4478c2ecf20Sopenharmony_ci (val[2] & (0x7 << (i * 3))) >> (i * 3), 4488c2ecf20Sopenharmony_ci (*dcuBase & (0x1f << dcuOffset)) >> dcuOffset); 4498c2ecf20Sopenharmony_ci } 4508c2ecf20Sopenharmony_ci 4518c2ecf20Sopenharmony_ci seq_puts(file, "\n"); 4528c2ecf20Sopenharmony_ci 4538c2ecf20Sopenharmony_ci seq_printf(file, "qcu_stitch state: %2x qcu_fetch state: %2x\n", 4548c2ecf20Sopenharmony_ci (val[3] & 0x003c0000) >> 18, (val[3] & 0x03c00000) >> 22); 4558c2ecf20Sopenharmony_ci seq_printf(file, "qcu_complete state: %2x dcu_complete state: %2x\n", 4568c2ecf20Sopenharmony_ci (val[3] & 0x1c000000) >> 26, (val[6] & 0x3)); 4578c2ecf20Sopenharmony_ci seq_printf(file, "dcu_arb state: %2x dcu_fp state: %2x\n", 4588c2ecf20Sopenharmony_ci (val[5] & 0x06000000) >> 25, (val[5] & 0x38000000) >> 27); 4598c2ecf20Sopenharmony_ci seq_printf(file, "chan_idle_dur: %3d chan_idle_dur_valid: %1d\n", 4608c2ecf20Sopenharmony_ci (val[6] & 0x000003fc) >> 2, (val[6] & 0x00000400) >> 10); 4618c2ecf20Sopenharmony_ci seq_printf(file, "txfifo_valid_0: %1d txfifo_valid_1: %1d\n", 4628c2ecf20Sopenharmony_ci (val[6] & 0x00000800) >> 11, (val[6] & 0x00001000) >> 12); 4638c2ecf20Sopenharmony_ci seq_printf(file, "txfifo_dcu_num_0: %2d txfifo_dcu_num_1: %2d\n", 4648c2ecf20Sopenharmony_ci (val[6] & 0x0001e000) >> 13, (val[6] & 0x001e0000) >> 17); 4658c2ecf20Sopenharmony_ci 4668c2ecf20Sopenharmony_ci seq_printf(file, "pcu observe: 0x%x\n", REG_READ_D(ah, AR_OBS_BUS_1)); 4678c2ecf20Sopenharmony_ci seq_printf(file, "AR_CR: 0x%x\n", REG_READ_D(ah, AR_CR)); 4688c2ecf20Sopenharmony_ci 4698c2ecf20Sopenharmony_ci ath9k_ps_restore(sc); 4708c2ecf20Sopenharmony_ci 4718c2ecf20Sopenharmony_ci return 0; 4728c2ecf20Sopenharmony_ci} 4738c2ecf20Sopenharmony_ci 4748c2ecf20Sopenharmony_civoid ath_debug_stat_interrupt(struct ath_softc *sc, enum ath9k_int status) 4758c2ecf20Sopenharmony_ci{ 4768c2ecf20Sopenharmony_ci if (status) 4778c2ecf20Sopenharmony_ci sc->debug.stats.istats.total++; 4788c2ecf20Sopenharmony_ci if (sc->sc_ah->caps.hw_caps & ATH9K_HW_CAP_EDMA) { 4798c2ecf20Sopenharmony_ci if (status & ATH9K_INT_RXLP) 4808c2ecf20Sopenharmony_ci sc->debug.stats.istats.rxlp++; 4818c2ecf20Sopenharmony_ci if (status & ATH9K_INT_RXHP) 4828c2ecf20Sopenharmony_ci sc->debug.stats.istats.rxhp++; 4838c2ecf20Sopenharmony_ci if (status & ATH9K_INT_BB_WATCHDOG) 4848c2ecf20Sopenharmony_ci sc->debug.stats.istats.bb_watchdog++; 4858c2ecf20Sopenharmony_ci } else { 4868c2ecf20Sopenharmony_ci if (status & ATH9K_INT_RX) 4878c2ecf20Sopenharmony_ci sc->debug.stats.istats.rxok++; 4888c2ecf20Sopenharmony_ci } 4898c2ecf20Sopenharmony_ci if (status & ATH9K_INT_RXEOL) 4908c2ecf20Sopenharmony_ci sc->debug.stats.istats.rxeol++; 4918c2ecf20Sopenharmony_ci if (status & ATH9K_INT_RXORN) 4928c2ecf20Sopenharmony_ci sc->debug.stats.istats.rxorn++; 4938c2ecf20Sopenharmony_ci if (status & ATH9K_INT_TX) 4948c2ecf20Sopenharmony_ci sc->debug.stats.istats.txok++; 4958c2ecf20Sopenharmony_ci if (status & ATH9K_INT_TXURN) 4968c2ecf20Sopenharmony_ci sc->debug.stats.istats.txurn++; 4978c2ecf20Sopenharmony_ci if (status & ATH9K_INT_RXPHY) 4988c2ecf20Sopenharmony_ci sc->debug.stats.istats.rxphyerr++; 4998c2ecf20Sopenharmony_ci if (status & ATH9K_INT_RXKCM) 5008c2ecf20Sopenharmony_ci sc->debug.stats.istats.rx_keycache_miss++; 5018c2ecf20Sopenharmony_ci if (status & ATH9K_INT_SWBA) 5028c2ecf20Sopenharmony_ci sc->debug.stats.istats.swba++; 5038c2ecf20Sopenharmony_ci if (status & ATH9K_INT_BMISS) 5048c2ecf20Sopenharmony_ci sc->debug.stats.istats.bmiss++; 5058c2ecf20Sopenharmony_ci if (status & ATH9K_INT_BNR) 5068c2ecf20Sopenharmony_ci sc->debug.stats.istats.bnr++; 5078c2ecf20Sopenharmony_ci if (status & ATH9K_INT_CST) 5088c2ecf20Sopenharmony_ci sc->debug.stats.istats.cst++; 5098c2ecf20Sopenharmony_ci if (status & ATH9K_INT_GTT) 5108c2ecf20Sopenharmony_ci sc->debug.stats.istats.gtt++; 5118c2ecf20Sopenharmony_ci if (status & ATH9K_INT_TIM) 5128c2ecf20Sopenharmony_ci sc->debug.stats.istats.tim++; 5138c2ecf20Sopenharmony_ci if (status & ATH9K_INT_CABEND) 5148c2ecf20Sopenharmony_ci sc->debug.stats.istats.cabend++; 5158c2ecf20Sopenharmony_ci if (status & ATH9K_INT_DTIMSYNC) 5168c2ecf20Sopenharmony_ci sc->debug.stats.istats.dtimsync++; 5178c2ecf20Sopenharmony_ci if (status & ATH9K_INT_DTIM) 5188c2ecf20Sopenharmony_ci sc->debug.stats.istats.dtim++; 5198c2ecf20Sopenharmony_ci if (status & ATH9K_INT_TSFOOR) 5208c2ecf20Sopenharmony_ci sc->debug.stats.istats.tsfoor++; 5218c2ecf20Sopenharmony_ci if (status & ATH9K_INT_MCI) 5228c2ecf20Sopenharmony_ci sc->debug.stats.istats.mci++; 5238c2ecf20Sopenharmony_ci if (status & ATH9K_INT_GENTIMER) 5248c2ecf20Sopenharmony_ci sc->debug.stats.istats.gen_timer++; 5258c2ecf20Sopenharmony_ci} 5268c2ecf20Sopenharmony_ci 5278c2ecf20Sopenharmony_cistatic int read_file_interrupt(struct seq_file *file, void *data) 5288c2ecf20Sopenharmony_ci{ 5298c2ecf20Sopenharmony_ci struct ieee80211_hw *hw = dev_get_drvdata(file->private); 5308c2ecf20Sopenharmony_ci struct ath_softc *sc = hw->priv; 5318c2ecf20Sopenharmony_ci 5328c2ecf20Sopenharmony_ci#define PR_IS(a, s) \ 5338c2ecf20Sopenharmony_ci do { \ 5348c2ecf20Sopenharmony_ci seq_printf(file, "%21s: %10u\n", a, \ 5358c2ecf20Sopenharmony_ci sc->debug.stats.istats.s); \ 5368c2ecf20Sopenharmony_ci } while (0) 5378c2ecf20Sopenharmony_ci 5388c2ecf20Sopenharmony_ci if (sc->sc_ah->caps.hw_caps & ATH9K_HW_CAP_EDMA) { 5398c2ecf20Sopenharmony_ci PR_IS("RXLP", rxlp); 5408c2ecf20Sopenharmony_ci PR_IS("RXHP", rxhp); 5418c2ecf20Sopenharmony_ci PR_IS("WATCHDOG", bb_watchdog); 5428c2ecf20Sopenharmony_ci } else { 5438c2ecf20Sopenharmony_ci PR_IS("RX", rxok); 5448c2ecf20Sopenharmony_ci } 5458c2ecf20Sopenharmony_ci PR_IS("RXEOL", rxeol); 5468c2ecf20Sopenharmony_ci PR_IS("RXORN", rxorn); 5478c2ecf20Sopenharmony_ci PR_IS("TX", txok); 5488c2ecf20Sopenharmony_ci PR_IS("TXURN", txurn); 5498c2ecf20Sopenharmony_ci PR_IS("MIB", mib); 5508c2ecf20Sopenharmony_ci PR_IS("RXPHY", rxphyerr); 5518c2ecf20Sopenharmony_ci PR_IS("RXKCM", rx_keycache_miss); 5528c2ecf20Sopenharmony_ci PR_IS("SWBA", swba); 5538c2ecf20Sopenharmony_ci PR_IS("BMISS", bmiss); 5548c2ecf20Sopenharmony_ci PR_IS("BNR", bnr); 5558c2ecf20Sopenharmony_ci PR_IS("CST", cst); 5568c2ecf20Sopenharmony_ci PR_IS("GTT", gtt); 5578c2ecf20Sopenharmony_ci PR_IS("TIM", tim); 5588c2ecf20Sopenharmony_ci PR_IS("CABEND", cabend); 5598c2ecf20Sopenharmony_ci PR_IS("DTIMSYNC", dtimsync); 5608c2ecf20Sopenharmony_ci PR_IS("DTIM", dtim); 5618c2ecf20Sopenharmony_ci PR_IS("TSFOOR", tsfoor); 5628c2ecf20Sopenharmony_ci PR_IS("MCI", mci); 5638c2ecf20Sopenharmony_ci PR_IS("GENTIMER", gen_timer); 5648c2ecf20Sopenharmony_ci PR_IS("TOTAL", total); 5658c2ecf20Sopenharmony_ci 5668c2ecf20Sopenharmony_ci seq_puts(file, "SYNC_CAUSE stats:\n"); 5678c2ecf20Sopenharmony_ci 5688c2ecf20Sopenharmony_ci PR_IS("Sync-All", sync_cause_all); 5698c2ecf20Sopenharmony_ci PR_IS("RTC-IRQ", sync_rtc_irq); 5708c2ecf20Sopenharmony_ci PR_IS("MAC-IRQ", sync_mac_irq); 5718c2ecf20Sopenharmony_ci PR_IS("EEPROM-Illegal-Access", eeprom_illegal_access); 5728c2ecf20Sopenharmony_ci PR_IS("APB-Timeout", apb_timeout); 5738c2ecf20Sopenharmony_ci PR_IS("PCI-Mode-Conflict", pci_mode_conflict); 5748c2ecf20Sopenharmony_ci PR_IS("HOST1-Fatal", host1_fatal); 5758c2ecf20Sopenharmony_ci PR_IS("HOST1-Perr", host1_perr); 5768c2ecf20Sopenharmony_ci PR_IS("TRCV-FIFO-Perr", trcv_fifo_perr); 5778c2ecf20Sopenharmony_ci PR_IS("RADM-CPL-EP", radm_cpl_ep); 5788c2ecf20Sopenharmony_ci PR_IS("RADM-CPL-DLLP-Abort", radm_cpl_dllp_abort); 5798c2ecf20Sopenharmony_ci PR_IS("RADM-CPL-TLP-Abort", radm_cpl_tlp_abort); 5808c2ecf20Sopenharmony_ci PR_IS("RADM-CPL-ECRC-Err", radm_cpl_ecrc_err); 5818c2ecf20Sopenharmony_ci PR_IS("RADM-CPL-Timeout", radm_cpl_timeout); 5828c2ecf20Sopenharmony_ci PR_IS("Local-Bus-Timeout", local_timeout); 5838c2ecf20Sopenharmony_ci PR_IS("PM-Access", pm_access); 5848c2ecf20Sopenharmony_ci PR_IS("MAC-Awake", mac_awake); 5858c2ecf20Sopenharmony_ci PR_IS("MAC-Asleep", mac_asleep); 5868c2ecf20Sopenharmony_ci PR_IS("MAC-Sleep-Access", mac_sleep_access); 5878c2ecf20Sopenharmony_ci 5888c2ecf20Sopenharmony_ci return 0; 5898c2ecf20Sopenharmony_ci} 5908c2ecf20Sopenharmony_ci 5918c2ecf20Sopenharmony_cistatic int read_file_xmit(struct seq_file *file, void *data) 5928c2ecf20Sopenharmony_ci{ 5938c2ecf20Sopenharmony_ci struct ieee80211_hw *hw = dev_get_drvdata(file->private); 5948c2ecf20Sopenharmony_ci struct ath_softc *sc = hw->priv; 5958c2ecf20Sopenharmony_ci 5968c2ecf20Sopenharmony_ci seq_printf(file, "%30s %10s%10s%10s\n\n", "BE", "BK", "VI", "VO"); 5978c2ecf20Sopenharmony_ci 5988c2ecf20Sopenharmony_ci PR("MPDUs Queued: ", queued); 5998c2ecf20Sopenharmony_ci PR("MPDUs Completed: ", completed); 6008c2ecf20Sopenharmony_ci PR("MPDUs XRetried: ", xretries); 6018c2ecf20Sopenharmony_ci PR("Aggregates: ", a_aggr); 6028c2ecf20Sopenharmony_ci PR("AMPDUs Queued HW:", a_queued_hw); 6038c2ecf20Sopenharmony_ci PR("AMPDUs Completed:", a_completed); 6048c2ecf20Sopenharmony_ci PR("AMPDUs Retried: ", a_retries); 6058c2ecf20Sopenharmony_ci PR("AMPDUs XRetried: ", a_xretries); 6068c2ecf20Sopenharmony_ci PR("TXERR Filtered: ", txerr_filtered); 6078c2ecf20Sopenharmony_ci PR("FIFO Underrun: ", fifo_underrun); 6088c2ecf20Sopenharmony_ci PR("TXOP Exceeded: ", xtxop); 6098c2ecf20Sopenharmony_ci PR("TXTIMER Expiry: ", timer_exp); 6108c2ecf20Sopenharmony_ci PR("DESC CFG Error: ", desc_cfg_err); 6118c2ecf20Sopenharmony_ci PR("DATA Underrun: ", data_underrun); 6128c2ecf20Sopenharmony_ci PR("DELIM Underrun: ", delim_underrun); 6138c2ecf20Sopenharmony_ci PR("TX-Pkts-All: ", tx_pkts_all); 6148c2ecf20Sopenharmony_ci PR("TX-Bytes-All: ", tx_bytes_all); 6158c2ecf20Sopenharmony_ci PR("HW-put-tx-buf: ", puttxbuf); 6168c2ecf20Sopenharmony_ci PR("HW-tx-start: ", txstart); 6178c2ecf20Sopenharmony_ci PR("HW-tx-proc-desc: ", txprocdesc); 6188c2ecf20Sopenharmony_ci PR("TX-Failed: ", txfailed); 6198c2ecf20Sopenharmony_ci 6208c2ecf20Sopenharmony_ci return 0; 6218c2ecf20Sopenharmony_ci} 6228c2ecf20Sopenharmony_ci 6238c2ecf20Sopenharmony_cistatic void print_queue(struct ath_softc *sc, struct ath_txq *txq, 6248c2ecf20Sopenharmony_ci struct seq_file *file) 6258c2ecf20Sopenharmony_ci{ 6268c2ecf20Sopenharmony_ci ath_txq_lock(sc, txq); 6278c2ecf20Sopenharmony_ci 6288c2ecf20Sopenharmony_ci seq_printf(file, "%s: %d ", "qnum", txq->axq_qnum); 6298c2ecf20Sopenharmony_ci seq_printf(file, "%s: %2d ", "qdepth", txq->axq_depth); 6308c2ecf20Sopenharmony_ci seq_printf(file, "%s: %2d ", "ampdu-depth", txq->axq_ampdu_depth); 6318c2ecf20Sopenharmony_ci seq_printf(file, "%s: %3d\n", "pending", txq->pending_frames); 6328c2ecf20Sopenharmony_ci 6338c2ecf20Sopenharmony_ci ath_txq_unlock(sc, txq); 6348c2ecf20Sopenharmony_ci} 6358c2ecf20Sopenharmony_ci 6368c2ecf20Sopenharmony_cistatic int read_file_queues(struct seq_file *file, void *data) 6378c2ecf20Sopenharmony_ci{ 6388c2ecf20Sopenharmony_ci struct ieee80211_hw *hw = dev_get_drvdata(file->private); 6398c2ecf20Sopenharmony_ci struct ath_softc *sc = hw->priv; 6408c2ecf20Sopenharmony_ci struct ath_txq *txq; 6418c2ecf20Sopenharmony_ci int i; 6428c2ecf20Sopenharmony_ci static const char *qname[4] = { 6438c2ecf20Sopenharmony_ci "VO", "VI", "BE", "BK" 6448c2ecf20Sopenharmony_ci }; 6458c2ecf20Sopenharmony_ci 6468c2ecf20Sopenharmony_ci for (i = 0; i < IEEE80211_NUM_ACS; i++) { 6478c2ecf20Sopenharmony_ci txq = sc->tx.txq_map[i]; 6488c2ecf20Sopenharmony_ci seq_printf(file, "(%s): ", qname[i]); 6498c2ecf20Sopenharmony_ci print_queue(sc, txq, file); 6508c2ecf20Sopenharmony_ci } 6518c2ecf20Sopenharmony_ci 6528c2ecf20Sopenharmony_ci seq_puts(file, "(CAB): "); 6538c2ecf20Sopenharmony_ci print_queue(sc, sc->beacon.cabq, file); 6548c2ecf20Sopenharmony_ci 6558c2ecf20Sopenharmony_ci return 0; 6568c2ecf20Sopenharmony_ci} 6578c2ecf20Sopenharmony_ci 6588c2ecf20Sopenharmony_cistatic int read_file_misc(struct seq_file *file, void *data) 6598c2ecf20Sopenharmony_ci{ 6608c2ecf20Sopenharmony_ci struct ieee80211_hw *hw = dev_get_drvdata(file->private); 6618c2ecf20Sopenharmony_ci struct ath_softc *sc = hw->priv; 6628c2ecf20Sopenharmony_ci struct ath_common *common = ath9k_hw_common(sc->sc_ah); 6638c2ecf20Sopenharmony_ci struct ath9k_vif_iter_data iter_data; 6648c2ecf20Sopenharmony_ci struct ath_chanctx *ctx; 6658c2ecf20Sopenharmony_ci unsigned int reg; 6668c2ecf20Sopenharmony_ci u32 rxfilter, i; 6678c2ecf20Sopenharmony_ci 6688c2ecf20Sopenharmony_ci seq_printf(file, "BSSID: %pM\n", common->curbssid); 6698c2ecf20Sopenharmony_ci seq_printf(file, "BSSID-MASK: %pM\n", common->bssidmask); 6708c2ecf20Sopenharmony_ci seq_printf(file, "OPMODE: %s\n", 6718c2ecf20Sopenharmony_ci ath_opmode_to_string(sc->sc_ah->opmode)); 6728c2ecf20Sopenharmony_ci 6738c2ecf20Sopenharmony_ci ath9k_ps_wakeup(sc); 6748c2ecf20Sopenharmony_ci rxfilter = ath9k_hw_getrxfilter(sc->sc_ah); 6758c2ecf20Sopenharmony_ci ath9k_ps_restore(sc); 6768c2ecf20Sopenharmony_ci 6778c2ecf20Sopenharmony_ci seq_printf(file, "RXFILTER: 0x%x", rxfilter); 6788c2ecf20Sopenharmony_ci 6798c2ecf20Sopenharmony_ci if (rxfilter & ATH9K_RX_FILTER_UCAST) 6808c2ecf20Sopenharmony_ci seq_puts(file, " UCAST"); 6818c2ecf20Sopenharmony_ci if (rxfilter & ATH9K_RX_FILTER_MCAST) 6828c2ecf20Sopenharmony_ci seq_puts(file, " MCAST"); 6838c2ecf20Sopenharmony_ci if (rxfilter & ATH9K_RX_FILTER_BCAST) 6848c2ecf20Sopenharmony_ci seq_puts(file, " BCAST"); 6858c2ecf20Sopenharmony_ci if (rxfilter & ATH9K_RX_FILTER_CONTROL) 6868c2ecf20Sopenharmony_ci seq_puts(file, " CONTROL"); 6878c2ecf20Sopenharmony_ci if (rxfilter & ATH9K_RX_FILTER_BEACON) 6888c2ecf20Sopenharmony_ci seq_puts(file, " BEACON"); 6898c2ecf20Sopenharmony_ci if (rxfilter & ATH9K_RX_FILTER_PROM) 6908c2ecf20Sopenharmony_ci seq_puts(file, " PROM"); 6918c2ecf20Sopenharmony_ci if (rxfilter & ATH9K_RX_FILTER_PROBEREQ) 6928c2ecf20Sopenharmony_ci seq_puts(file, " PROBEREQ"); 6938c2ecf20Sopenharmony_ci if (rxfilter & ATH9K_RX_FILTER_PHYERR) 6948c2ecf20Sopenharmony_ci seq_puts(file, " PHYERR"); 6958c2ecf20Sopenharmony_ci if (rxfilter & ATH9K_RX_FILTER_MYBEACON) 6968c2ecf20Sopenharmony_ci seq_puts(file, " MYBEACON"); 6978c2ecf20Sopenharmony_ci if (rxfilter & ATH9K_RX_FILTER_COMP_BAR) 6988c2ecf20Sopenharmony_ci seq_puts(file, " COMP_BAR"); 6998c2ecf20Sopenharmony_ci if (rxfilter & ATH9K_RX_FILTER_PSPOLL) 7008c2ecf20Sopenharmony_ci seq_puts(file, " PSPOLL"); 7018c2ecf20Sopenharmony_ci if (rxfilter & ATH9K_RX_FILTER_PHYRADAR) 7028c2ecf20Sopenharmony_ci seq_puts(file, " PHYRADAR"); 7038c2ecf20Sopenharmony_ci if (rxfilter & ATH9K_RX_FILTER_MCAST_BCAST_ALL) 7048c2ecf20Sopenharmony_ci seq_puts(file, " MCAST_BCAST_ALL"); 7058c2ecf20Sopenharmony_ci if (rxfilter & ATH9K_RX_FILTER_CONTROL_WRAPPER) 7068c2ecf20Sopenharmony_ci seq_puts(file, " CONTROL_WRAPPER"); 7078c2ecf20Sopenharmony_ci 7088c2ecf20Sopenharmony_ci seq_puts(file, "\n"); 7098c2ecf20Sopenharmony_ci 7108c2ecf20Sopenharmony_ci reg = sc->sc_ah->imask; 7118c2ecf20Sopenharmony_ci 7128c2ecf20Sopenharmony_ci seq_printf(file, "INTERRUPT-MASK: 0x%x", reg); 7138c2ecf20Sopenharmony_ci 7148c2ecf20Sopenharmony_ci if (reg & ATH9K_INT_SWBA) 7158c2ecf20Sopenharmony_ci seq_puts(file, " SWBA"); 7168c2ecf20Sopenharmony_ci if (reg & ATH9K_INT_BMISS) 7178c2ecf20Sopenharmony_ci seq_puts(file, " BMISS"); 7188c2ecf20Sopenharmony_ci if (reg & ATH9K_INT_CST) 7198c2ecf20Sopenharmony_ci seq_puts(file, " CST"); 7208c2ecf20Sopenharmony_ci if (reg & ATH9K_INT_RX) 7218c2ecf20Sopenharmony_ci seq_puts(file, " RX"); 7228c2ecf20Sopenharmony_ci if (reg & ATH9K_INT_RXHP) 7238c2ecf20Sopenharmony_ci seq_puts(file, " RXHP"); 7248c2ecf20Sopenharmony_ci if (reg & ATH9K_INT_RXLP) 7258c2ecf20Sopenharmony_ci seq_puts(file, " RXLP"); 7268c2ecf20Sopenharmony_ci if (reg & ATH9K_INT_BB_WATCHDOG) 7278c2ecf20Sopenharmony_ci seq_puts(file, " BB_WATCHDOG"); 7288c2ecf20Sopenharmony_ci 7298c2ecf20Sopenharmony_ci seq_puts(file, "\n"); 7308c2ecf20Sopenharmony_ci 7318c2ecf20Sopenharmony_ci i = 0; 7328c2ecf20Sopenharmony_ci ath_for_each_chanctx(sc, ctx) { 7338c2ecf20Sopenharmony_ci if (list_empty(&ctx->vifs)) 7348c2ecf20Sopenharmony_ci continue; 7358c2ecf20Sopenharmony_ci ath9k_calculate_iter_data(sc, ctx, &iter_data); 7368c2ecf20Sopenharmony_ci 7378c2ecf20Sopenharmony_ci seq_printf(file, 7388c2ecf20Sopenharmony_ci "VIFS: CTX %i(%i) AP: %i STA: %i MESH: %i WDS: %i", 7398c2ecf20Sopenharmony_ci i++, (int)(ctx->assigned), iter_data.naps, 7408c2ecf20Sopenharmony_ci iter_data.nstations, 7418c2ecf20Sopenharmony_ci iter_data.nmeshes, iter_data.nwds); 7428c2ecf20Sopenharmony_ci seq_printf(file, " ADHOC: %i OCB: %i TOTAL: %hi BEACON-VIF: %hi\n", 7438c2ecf20Sopenharmony_ci iter_data.nadhocs, iter_data.nocbs, sc->cur_chan->nvifs, 7448c2ecf20Sopenharmony_ci sc->nbcnvifs); 7458c2ecf20Sopenharmony_ci } 7468c2ecf20Sopenharmony_ci 7478c2ecf20Sopenharmony_ci return 0; 7488c2ecf20Sopenharmony_ci} 7498c2ecf20Sopenharmony_ci 7508c2ecf20Sopenharmony_cistatic int read_file_reset(struct seq_file *file, void *data) 7518c2ecf20Sopenharmony_ci{ 7528c2ecf20Sopenharmony_ci struct ieee80211_hw *hw = dev_get_drvdata(file->private); 7538c2ecf20Sopenharmony_ci struct ath_softc *sc = hw->priv; 7548c2ecf20Sopenharmony_ci static const char * const reset_cause[__RESET_TYPE_MAX] = { 7558c2ecf20Sopenharmony_ci [RESET_TYPE_BB_HANG] = "Baseband Hang", 7568c2ecf20Sopenharmony_ci [RESET_TYPE_BB_WATCHDOG] = "Baseband Watchdog", 7578c2ecf20Sopenharmony_ci [RESET_TYPE_FATAL_INT] = "Fatal HW Error", 7588c2ecf20Sopenharmony_ci [RESET_TYPE_TX_ERROR] = "TX HW error", 7598c2ecf20Sopenharmony_ci [RESET_TYPE_TX_GTT] = "Transmit timeout", 7608c2ecf20Sopenharmony_ci [RESET_TYPE_TX_HANG] = "TX Path Hang", 7618c2ecf20Sopenharmony_ci [RESET_TYPE_PLL_HANG] = "PLL RX Hang", 7628c2ecf20Sopenharmony_ci [RESET_TYPE_MAC_HANG] = "MAC Hang", 7638c2ecf20Sopenharmony_ci [RESET_TYPE_BEACON_STUCK] = "Stuck Beacon", 7648c2ecf20Sopenharmony_ci [RESET_TYPE_MCI] = "MCI Reset", 7658c2ecf20Sopenharmony_ci [RESET_TYPE_CALIBRATION] = "Calibration error", 7668c2ecf20Sopenharmony_ci [RESET_TX_DMA_ERROR] = "Tx DMA stop error", 7678c2ecf20Sopenharmony_ci [RESET_RX_DMA_ERROR] = "Rx DMA stop error", 7688c2ecf20Sopenharmony_ci }; 7698c2ecf20Sopenharmony_ci int i; 7708c2ecf20Sopenharmony_ci 7718c2ecf20Sopenharmony_ci for (i = 0; i < ARRAY_SIZE(reset_cause); i++) { 7728c2ecf20Sopenharmony_ci if (!reset_cause[i]) 7738c2ecf20Sopenharmony_ci continue; 7748c2ecf20Sopenharmony_ci 7758c2ecf20Sopenharmony_ci seq_printf(file, "%17s: %2d\n", reset_cause[i], 7768c2ecf20Sopenharmony_ci sc->debug.stats.reset[i]); 7778c2ecf20Sopenharmony_ci } 7788c2ecf20Sopenharmony_ci 7798c2ecf20Sopenharmony_ci return 0; 7808c2ecf20Sopenharmony_ci} 7818c2ecf20Sopenharmony_ci 7828c2ecf20Sopenharmony_civoid ath_debug_stat_tx(struct ath_softc *sc, struct ath_buf *bf, 7838c2ecf20Sopenharmony_ci struct ath_tx_status *ts, struct ath_txq *txq, 7848c2ecf20Sopenharmony_ci unsigned int flags) 7858c2ecf20Sopenharmony_ci{ 7868c2ecf20Sopenharmony_ci int qnum = txq->axq_qnum; 7878c2ecf20Sopenharmony_ci 7888c2ecf20Sopenharmony_ci TX_STAT_INC(sc, qnum, tx_pkts_all); 7898c2ecf20Sopenharmony_ci sc->debug.stats.txstats[qnum].tx_bytes_all += bf->bf_mpdu->len; 7908c2ecf20Sopenharmony_ci 7918c2ecf20Sopenharmony_ci if (bf_isampdu(bf)) { 7928c2ecf20Sopenharmony_ci if (flags & ATH_TX_ERROR) 7938c2ecf20Sopenharmony_ci TX_STAT_INC(sc, qnum, a_xretries); 7948c2ecf20Sopenharmony_ci else 7958c2ecf20Sopenharmony_ci TX_STAT_INC(sc, qnum, a_completed); 7968c2ecf20Sopenharmony_ci } else { 7978c2ecf20Sopenharmony_ci if (ts->ts_status & ATH9K_TXERR_XRETRY) 7988c2ecf20Sopenharmony_ci TX_STAT_INC(sc, qnum, xretries); 7998c2ecf20Sopenharmony_ci else 8008c2ecf20Sopenharmony_ci TX_STAT_INC(sc, qnum, completed); 8018c2ecf20Sopenharmony_ci } 8028c2ecf20Sopenharmony_ci 8038c2ecf20Sopenharmony_ci if (ts->ts_status & ATH9K_TXERR_FILT) 8048c2ecf20Sopenharmony_ci TX_STAT_INC(sc, qnum, txerr_filtered); 8058c2ecf20Sopenharmony_ci if (ts->ts_status & ATH9K_TXERR_FIFO) 8068c2ecf20Sopenharmony_ci TX_STAT_INC(sc, qnum, fifo_underrun); 8078c2ecf20Sopenharmony_ci if (ts->ts_status & ATH9K_TXERR_XTXOP) 8088c2ecf20Sopenharmony_ci TX_STAT_INC(sc, qnum, xtxop); 8098c2ecf20Sopenharmony_ci if (ts->ts_status & ATH9K_TXERR_TIMER_EXPIRED) 8108c2ecf20Sopenharmony_ci TX_STAT_INC(sc, qnum, timer_exp); 8118c2ecf20Sopenharmony_ci if (ts->ts_flags & ATH9K_TX_DESC_CFG_ERR) 8128c2ecf20Sopenharmony_ci TX_STAT_INC(sc, qnum, desc_cfg_err); 8138c2ecf20Sopenharmony_ci if (ts->ts_flags & ATH9K_TX_DATA_UNDERRUN) 8148c2ecf20Sopenharmony_ci TX_STAT_INC(sc, qnum, data_underrun); 8158c2ecf20Sopenharmony_ci if (ts->ts_flags & ATH9K_TX_DELIM_UNDERRUN) 8168c2ecf20Sopenharmony_ci TX_STAT_INC(sc, qnum, delim_underrun); 8178c2ecf20Sopenharmony_ci} 8188c2ecf20Sopenharmony_ci 8198c2ecf20Sopenharmony_civoid ath_debug_stat_rx(struct ath_softc *sc, struct ath_rx_status *rs) 8208c2ecf20Sopenharmony_ci{ 8218c2ecf20Sopenharmony_ci ath9k_cmn_debug_stat_rx(&sc->debug.stats.rxstats, rs); 8228c2ecf20Sopenharmony_ci} 8238c2ecf20Sopenharmony_ci 8248c2ecf20Sopenharmony_cistatic ssize_t read_file_regidx(struct file *file, char __user *user_buf, 8258c2ecf20Sopenharmony_ci size_t count, loff_t *ppos) 8268c2ecf20Sopenharmony_ci{ 8278c2ecf20Sopenharmony_ci struct ath_softc *sc = file->private_data; 8288c2ecf20Sopenharmony_ci char buf[32]; 8298c2ecf20Sopenharmony_ci unsigned int len; 8308c2ecf20Sopenharmony_ci 8318c2ecf20Sopenharmony_ci len = sprintf(buf, "0x%08x\n", sc->debug.regidx); 8328c2ecf20Sopenharmony_ci return simple_read_from_buffer(user_buf, count, ppos, buf, len); 8338c2ecf20Sopenharmony_ci} 8348c2ecf20Sopenharmony_ci 8358c2ecf20Sopenharmony_cistatic ssize_t write_file_regidx(struct file *file, const char __user *user_buf, 8368c2ecf20Sopenharmony_ci size_t count, loff_t *ppos) 8378c2ecf20Sopenharmony_ci{ 8388c2ecf20Sopenharmony_ci struct ath_softc *sc = file->private_data; 8398c2ecf20Sopenharmony_ci unsigned long regidx; 8408c2ecf20Sopenharmony_ci char buf[32]; 8418c2ecf20Sopenharmony_ci ssize_t len; 8428c2ecf20Sopenharmony_ci 8438c2ecf20Sopenharmony_ci len = min(count, sizeof(buf) - 1); 8448c2ecf20Sopenharmony_ci if (copy_from_user(buf, user_buf, len)) 8458c2ecf20Sopenharmony_ci return -EFAULT; 8468c2ecf20Sopenharmony_ci 8478c2ecf20Sopenharmony_ci buf[len] = '\0'; 8488c2ecf20Sopenharmony_ci if (kstrtoul(buf, 0, ®idx)) 8498c2ecf20Sopenharmony_ci return -EINVAL; 8508c2ecf20Sopenharmony_ci 8518c2ecf20Sopenharmony_ci sc->debug.regidx = regidx; 8528c2ecf20Sopenharmony_ci return count; 8538c2ecf20Sopenharmony_ci} 8548c2ecf20Sopenharmony_ci 8558c2ecf20Sopenharmony_cistatic const struct file_operations fops_regidx = { 8568c2ecf20Sopenharmony_ci .read = read_file_regidx, 8578c2ecf20Sopenharmony_ci .write = write_file_regidx, 8588c2ecf20Sopenharmony_ci .open = simple_open, 8598c2ecf20Sopenharmony_ci .owner = THIS_MODULE, 8608c2ecf20Sopenharmony_ci .llseek = default_llseek, 8618c2ecf20Sopenharmony_ci}; 8628c2ecf20Sopenharmony_ci 8638c2ecf20Sopenharmony_cistatic ssize_t read_file_regval(struct file *file, char __user *user_buf, 8648c2ecf20Sopenharmony_ci size_t count, loff_t *ppos) 8658c2ecf20Sopenharmony_ci{ 8668c2ecf20Sopenharmony_ci struct ath_softc *sc = file->private_data; 8678c2ecf20Sopenharmony_ci struct ath_hw *ah = sc->sc_ah; 8688c2ecf20Sopenharmony_ci char buf[32]; 8698c2ecf20Sopenharmony_ci unsigned int len; 8708c2ecf20Sopenharmony_ci u32 regval; 8718c2ecf20Sopenharmony_ci 8728c2ecf20Sopenharmony_ci ath9k_ps_wakeup(sc); 8738c2ecf20Sopenharmony_ci regval = REG_READ_D(ah, sc->debug.regidx); 8748c2ecf20Sopenharmony_ci ath9k_ps_restore(sc); 8758c2ecf20Sopenharmony_ci len = sprintf(buf, "0x%08x\n", regval); 8768c2ecf20Sopenharmony_ci return simple_read_from_buffer(user_buf, count, ppos, buf, len); 8778c2ecf20Sopenharmony_ci} 8788c2ecf20Sopenharmony_ci 8798c2ecf20Sopenharmony_cistatic ssize_t write_file_regval(struct file *file, const char __user *user_buf, 8808c2ecf20Sopenharmony_ci size_t count, loff_t *ppos) 8818c2ecf20Sopenharmony_ci{ 8828c2ecf20Sopenharmony_ci struct ath_softc *sc = file->private_data; 8838c2ecf20Sopenharmony_ci struct ath_hw *ah = sc->sc_ah; 8848c2ecf20Sopenharmony_ci unsigned long regval; 8858c2ecf20Sopenharmony_ci char buf[32]; 8868c2ecf20Sopenharmony_ci ssize_t len; 8878c2ecf20Sopenharmony_ci 8888c2ecf20Sopenharmony_ci len = min(count, sizeof(buf) - 1); 8898c2ecf20Sopenharmony_ci if (copy_from_user(buf, user_buf, len)) 8908c2ecf20Sopenharmony_ci return -EFAULT; 8918c2ecf20Sopenharmony_ci 8928c2ecf20Sopenharmony_ci buf[len] = '\0'; 8938c2ecf20Sopenharmony_ci if (kstrtoul(buf, 0, ®val)) 8948c2ecf20Sopenharmony_ci return -EINVAL; 8958c2ecf20Sopenharmony_ci 8968c2ecf20Sopenharmony_ci ath9k_ps_wakeup(sc); 8978c2ecf20Sopenharmony_ci REG_WRITE_D(ah, sc->debug.regidx, regval); 8988c2ecf20Sopenharmony_ci ath9k_ps_restore(sc); 8998c2ecf20Sopenharmony_ci return count; 9008c2ecf20Sopenharmony_ci} 9018c2ecf20Sopenharmony_ci 9028c2ecf20Sopenharmony_cistatic const struct file_operations fops_regval = { 9038c2ecf20Sopenharmony_ci .read = read_file_regval, 9048c2ecf20Sopenharmony_ci .write = write_file_regval, 9058c2ecf20Sopenharmony_ci .open = simple_open, 9068c2ecf20Sopenharmony_ci .owner = THIS_MODULE, 9078c2ecf20Sopenharmony_ci .llseek = default_llseek, 9088c2ecf20Sopenharmony_ci}; 9098c2ecf20Sopenharmony_ci 9108c2ecf20Sopenharmony_ci#define REGDUMP_LINE_SIZE 20 9118c2ecf20Sopenharmony_ci 9128c2ecf20Sopenharmony_cistatic int open_file_regdump(struct inode *inode, struct file *file) 9138c2ecf20Sopenharmony_ci{ 9148c2ecf20Sopenharmony_ci struct ath_softc *sc = inode->i_private; 9158c2ecf20Sopenharmony_ci unsigned int len = 0; 9168c2ecf20Sopenharmony_ci u8 *buf; 9178c2ecf20Sopenharmony_ci int i, j = 0; 9188c2ecf20Sopenharmony_ci unsigned long num_regs, regdump_len, max_reg_offset; 9198c2ecf20Sopenharmony_ci static const struct reg_hole { 9208c2ecf20Sopenharmony_ci u32 start; 9218c2ecf20Sopenharmony_ci u32 end; 9228c2ecf20Sopenharmony_ci } reg_hole_list[] = { 9238c2ecf20Sopenharmony_ci {0x0200, 0x07fc}, 9248c2ecf20Sopenharmony_ci {0x0c00, 0x0ffc}, 9258c2ecf20Sopenharmony_ci {0x2000, 0x3ffc}, 9268c2ecf20Sopenharmony_ci {0x4100, 0x6ffc}, 9278c2ecf20Sopenharmony_ci {0x705c, 0x7ffc}, 9288c2ecf20Sopenharmony_ci {0x0000, 0x0000} 9298c2ecf20Sopenharmony_ci }; 9308c2ecf20Sopenharmony_ci 9318c2ecf20Sopenharmony_ci max_reg_offset = AR_SREV_9300_20_OR_LATER(sc->sc_ah) ? 0x8800 : 0xb500; 9328c2ecf20Sopenharmony_ci num_regs = max_reg_offset / 4 + 1; 9338c2ecf20Sopenharmony_ci regdump_len = num_regs * REGDUMP_LINE_SIZE + 1; 9348c2ecf20Sopenharmony_ci buf = vmalloc(regdump_len); 9358c2ecf20Sopenharmony_ci if (!buf) 9368c2ecf20Sopenharmony_ci return -ENOMEM; 9378c2ecf20Sopenharmony_ci 9388c2ecf20Sopenharmony_ci ath9k_ps_wakeup(sc); 9398c2ecf20Sopenharmony_ci for (i = 0; i < num_regs; i++) { 9408c2ecf20Sopenharmony_ci if (reg_hole_list[j].start == i << 2) { 9418c2ecf20Sopenharmony_ci i = reg_hole_list[j].end >> 2; 9428c2ecf20Sopenharmony_ci j++; 9438c2ecf20Sopenharmony_ci continue; 9448c2ecf20Sopenharmony_ci } 9458c2ecf20Sopenharmony_ci 9468c2ecf20Sopenharmony_ci len += scnprintf(buf + len, regdump_len - len, 9478c2ecf20Sopenharmony_ci "0x%06x 0x%08x\n", i << 2, REG_READ(sc->sc_ah, i << 2)); 9488c2ecf20Sopenharmony_ci } 9498c2ecf20Sopenharmony_ci ath9k_ps_restore(sc); 9508c2ecf20Sopenharmony_ci 9518c2ecf20Sopenharmony_ci file->private_data = buf; 9528c2ecf20Sopenharmony_ci 9538c2ecf20Sopenharmony_ci return 0; 9548c2ecf20Sopenharmony_ci} 9558c2ecf20Sopenharmony_ci 9568c2ecf20Sopenharmony_cistatic const struct file_operations fops_regdump = { 9578c2ecf20Sopenharmony_ci .open = open_file_regdump, 9588c2ecf20Sopenharmony_ci .read = ath9k_debugfs_read_buf, 9598c2ecf20Sopenharmony_ci .release = ath9k_debugfs_release_buf, 9608c2ecf20Sopenharmony_ci .owner = THIS_MODULE, 9618c2ecf20Sopenharmony_ci .llseek = default_llseek,/* read accesses f_pos */ 9628c2ecf20Sopenharmony_ci}; 9638c2ecf20Sopenharmony_ci 9648c2ecf20Sopenharmony_cistatic int read_file_dump_nfcal(struct seq_file *file, void *data) 9658c2ecf20Sopenharmony_ci{ 9668c2ecf20Sopenharmony_ci struct ieee80211_hw *hw = dev_get_drvdata(file->private); 9678c2ecf20Sopenharmony_ci struct ath_softc *sc = hw->priv; 9688c2ecf20Sopenharmony_ci struct ath_hw *ah = sc->sc_ah; 9698c2ecf20Sopenharmony_ci struct ath9k_nfcal_hist *h = sc->cur_chan->caldata.nfCalHist; 9708c2ecf20Sopenharmony_ci struct ath_common *common = ath9k_hw_common(ah); 9718c2ecf20Sopenharmony_ci struct ieee80211_conf *conf = &common->hw->conf; 9728c2ecf20Sopenharmony_ci u32 i, j; 9738c2ecf20Sopenharmony_ci u8 chainmask = (ah->rxchainmask << 3) | ah->rxchainmask; 9748c2ecf20Sopenharmony_ci u8 nread; 9758c2ecf20Sopenharmony_ci 9768c2ecf20Sopenharmony_ci seq_printf(file, "Channel Noise Floor : %d\n", ah->noise); 9778c2ecf20Sopenharmony_ci seq_puts(file, "Chain | privNF | # Readings | NF Readings\n"); 9788c2ecf20Sopenharmony_ci for (i = 0; i < NUM_NF_READINGS; i++) { 9798c2ecf20Sopenharmony_ci if (!(chainmask & (1 << i)) || 9808c2ecf20Sopenharmony_ci ((i >= AR5416_MAX_CHAINS) && !conf_is_ht40(conf))) 9818c2ecf20Sopenharmony_ci continue; 9828c2ecf20Sopenharmony_ci 9838c2ecf20Sopenharmony_ci nread = AR_PHY_CCA_FILTERWINDOW_LENGTH - h[i].invalidNFcount; 9848c2ecf20Sopenharmony_ci seq_printf(file, " %d\t %d\t %d\t\t", i, h[i].privNF, nread); 9858c2ecf20Sopenharmony_ci for (j = 0; j < nread; j++) 9868c2ecf20Sopenharmony_ci seq_printf(file, " %d", h[i].nfCalBuffer[j]); 9878c2ecf20Sopenharmony_ci seq_puts(file, "\n"); 9888c2ecf20Sopenharmony_ci } 9898c2ecf20Sopenharmony_ci 9908c2ecf20Sopenharmony_ci return 0; 9918c2ecf20Sopenharmony_ci} 9928c2ecf20Sopenharmony_ci 9938c2ecf20Sopenharmony_ci#ifdef CONFIG_ATH9K_BTCOEX_SUPPORT 9948c2ecf20Sopenharmony_cistatic ssize_t read_file_btcoex(struct file *file, char __user *user_buf, 9958c2ecf20Sopenharmony_ci size_t count, loff_t *ppos) 9968c2ecf20Sopenharmony_ci{ 9978c2ecf20Sopenharmony_ci struct ath_softc *sc = file->private_data; 9988c2ecf20Sopenharmony_ci u32 len = 0, size = 1500; 9998c2ecf20Sopenharmony_ci char *buf; 10008c2ecf20Sopenharmony_ci size_t retval; 10018c2ecf20Sopenharmony_ci 10028c2ecf20Sopenharmony_ci buf = kzalloc(size, GFP_KERNEL); 10038c2ecf20Sopenharmony_ci if (buf == NULL) 10048c2ecf20Sopenharmony_ci return -ENOMEM; 10058c2ecf20Sopenharmony_ci 10068c2ecf20Sopenharmony_ci if (!sc->sc_ah->common.btcoex_enabled) { 10078c2ecf20Sopenharmony_ci len = scnprintf(buf, size, "%s\n", 10088c2ecf20Sopenharmony_ci "BTCOEX is disabled"); 10098c2ecf20Sopenharmony_ci goto exit; 10108c2ecf20Sopenharmony_ci } 10118c2ecf20Sopenharmony_ci 10128c2ecf20Sopenharmony_ci len = ath9k_dump_btcoex(sc, buf, size); 10138c2ecf20Sopenharmony_ciexit: 10148c2ecf20Sopenharmony_ci retval = simple_read_from_buffer(user_buf, count, ppos, buf, len); 10158c2ecf20Sopenharmony_ci kfree(buf); 10168c2ecf20Sopenharmony_ci 10178c2ecf20Sopenharmony_ci return retval; 10188c2ecf20Sopenharmony_ci} 10198c2ecf20Sopenharmony_ci 10208c2ecf20Sopenharmony_cistatic const struct file_operations fops_btcoex = { 10218c2ecf20Sopenharmony_ci .read = read_file_btcoex, 10228c2ecf20Sopenharmony_ci .open = simple_open, 10238c2ecf20Sopenharmony_ci .owner = THIS_MODULE, 10248c2ecf20Sopenharmony_ci .llseek = default_llseek, 10258c2ecf20Sopenharmony_ci}; 10268c2ecf20Sopenharmony_ci#endif 10278c2ecf20Sopenharmony_ci 10288c2ecf20Sopenharmony_ci#ifdef CONFIG_ATH9K_DYNACK 10298c2ecf20Sopenharmony_cistatic ssize_t read_file_ackto(struct file *file, char __user *user_buf, 10308c2ecf20Sopenharmony_ci size_t count, loff_t *ppos) 10318c2ecf20Sopenharmony_ci{ 10328c2ecf20Sopenharmony_ci struct ath_softc *sc = file->private_data; 10338c2ecf20Sopenharmony_ci struct ath_hw *ah = sc->sc_ah; 10348c2ecf20Sopenharmony_ci char buf[32]; 10358c2ecf20Sopenharmony_ci unsigned int len; 10368c2ecf20Sopenharmony_ci 10378c2ecf20Sopenharmony_ci len = sprintf(buf, "%u %c\n", ah->dynack.ackto, 10388c2ecf20Sopenharmony_ci (ah->dynack.enabled) ? 'A' : 'S'); 10398c2ecf20Sopenharmony_ci 10408c2ecf20Sopenharmony_ci return simple_read_from_buffer(user_buf, count, ppos, buf, len); 10418c2ecf20Sopenharmony_ci} 10428c2ecf20Sopenharmony_ci 10438c2ecf20Sopenharmony_cistatic const struct file_operations fops_ackto = { 10448c2ecf20Sopenharmony_ci .read = read_file_ackto, 10458c2ecf20Sopenharmony_ci .open = simple_open, 10468c2ecf20Sopenharmony_ci .owner = THIS_MODULE, 10478c2ecf20Sopenharmony_ci .llseek = default_llseek, 10488c2ecf20Sopenharmony_ci}; 10498c2ecf20Sopenharmony_ci#endif 10508c2ecf20Sopenharmony_ci 10518c2ecf20Sopenharmony_ci#ifdef CONFIG_ATH9K_WOW 10528c2ecf20Sopenharmony_ci 10538c2ecf20Sopenharmony_cistatic ssize_t read_file_wow(struct file *file, char __user *user_buf, 10548c2ecf20Sopenharmony_ci size_t count, loff_t *ppos) 10558c2ecf20Sopenharmony_ci{ 10568c2ecf20Sopenharmony_ci struct ath_softc *sc = file->private_data; 10578c2ecf20Sopenharmony_ci unsigned int len = 0, size = 32; 10588c2ecf20Sopenharmony_ci ssize_t retval; 10598c2ecf20Sopenharmony_ci char *buf; 10608c2ecf20Sopenharmony_ci 10618c2ecf20Sopenharmony_ci buf = kzalloc(size, GFP_KERNEL); 10628c2ecf20Sopenharmony_ci if (!buf) 10638c2ecf20Sopenharmony_ci return -ENOMEM; 10648c2ecf20Sopenharmony_ci 10658c2ecf20Sopenharmony_ci len += scnprintf(buf + len, size - len, "WOW: %s\n", 10668c2ecf20Sopenharmony_ci sc->force_wow ? "ENABLED" : "DISABLED"); 10678c2ecf20Sopenharmony_ci 10688c2ecf20Sopenharmony_ci if (len > size) 10698c2ecf20Sopenharmony_ci len = size; 10708c2ecf20Sopenharmony_ci 10718c2ecf20Sopenharmony_ci retval = simple_read_from_buffer(user_buf, count, ppos, buf, len); 10728c2ecf20Sopenharmony_ci kfree(buf); 10738c2ecf20Sopenharmony_ci 10748c2ecf20Sopenharmony_ci return retval; 10758c2ecf20Sopenharmony_ci} 10768c2ecf20Sopenharmony_ci 10778c2ecf20Sopenharmony_cistatic ssize_t write_file_wow(struct file *file, const char __user *user_buf, 10788c2ecf20Sopenharmony_ci size_t count, loff_t *ppos) 10798c2ecf20Sopenharmony_ci{ 10808c2ecf20Sopenharmony_ci struct ath_softc *sc = file->private_data; 10818c2ecf20Sopenharmony_ci unsigned long val; 10828c2ecf20Sopenharmony_ci char buf[32]; 10838c2ecf20Sopenharmony_ci ssize_t len; 10848c2ecf20Sopenharmony_ci 10858c2ecf20Sopenharmony_ci len = min(count, sizeof(buf) - 1); 10868c2ecf20Sopenharmony_ci if (copy_from_user(buf, user_buf, len)) 10878c2ecf20Sopenharmony_ci return -EFAULT; 10888c2ecf20Sopenharmony_ci 10898c2ecf20Sopenharmony_ci buf[len] = '\0'; 10908c2ecf20Sopenharmony_ci if (kstrtoul(buf, 0, &val)) 10918c2ecf20Sopenharmony_ci return -EINVAL; 10928c2ecf20Sopenharmony_ci 10938c2ecf20Sopenharmony_ci if (val != 1) 10948c2ecf20Sopenharmony_ci return -EINVAL; 10958c2ecf20Sopenharmony_ci 10968c2ecf20Sopenharmony_ci if (!sc->force_wow) { 10978c2ecf20Sopenharmony_ci sc->force_wow = true; 10988c2ecf20Sopenharmony_ci ath9k_init_wow(sc->hw); 10998c2ecf20Sopenharmony_ci } 11008c2ecf20Sopenharmony_ci 11018c2ecf20Sopenharmony_ci return count; 11028c2ecf20Sopenharmony_ci} 11038c2ecf20Sopenharmony_ci 11048c2ecf20Sopenharmony_cistatic const struct file_operations fops_wow = { 11058c2ecf20Sopenharmony_ci .read = read_file_wow, 11068c2ecf20Sopenharmony_ci .write = write_file_wow, 11078c2ecf20Sopenharmony_ci .open = simple_open, 11088c2ecf20Sopenharmony_ci .owner = THIS_MODULE, 11098c2ecf20Sopenharmony_ci .llseek = default_llseek, 11108c2ecf20Sopenharmony_ci}; 11118c2ecf20Sopenharmony_ci 11128c2ecf20Sopenharmony_ci#endif 11138c2ecf20Sopenharmony_ci 11148c2ecf20Sopenharmony_cistatic ssize_t read_file_tpc(struct file *file, char __user *user_buf, 11158c2ecf20Sopenharmony_ci size_t count, loff_t *ppos) 11168c2ecf20Sopenharmony_ci{ 11178c2ecf20Sopenharmony_ci struct ath_softc *sc = file->private_data; 11188c2ecf20Sopenharmony_ci struct ath_hw *ah = sc->sc_ah; 11198c2ecf20Sopenharmony_ci unsigned int len = 0, size = 32; 11208c2ecf20Sopenharmony_ci ssize_t retval; 11218c2ecf20Sopenharmony_ci char *buf; 11228c2ecf20Sopenharmony_ci 11238c2ecf20Sopenharmony_ci buf = kzalloc(size, GFP_KERNEL); 11248c2ecf20Sopenharmony_ci if (!buf) 11258c2ecf20Sopenharmony_ci return -ENOMEM; 11268c2ecf20Sopenharmony_ci 11278c2ecf20Sopenharmony_ci len += scnprintf(buf + len, size - len, "%s\n", 11288c2ecf20Sopenharmony_ci ah->tpc_enabled ? "ENABLED" : "DISABLED"); 11298c2ecf20Sopenharmony_ci 11308c2ecf20Sopenharmony_ci if (len > size) 11318c2ecf20Sopenharmony_ci len = size; 11328c2ecf20Sopenharmony_ci 11338c2ecf20Sopenharmony_ci retval = simple_read_from_buffer(user_buf, count, ppos, buf, len); 11348c2ecf20Sopenharmony_ci kfree(buf); 11358c2ecf20Sopenharmony_ci 11368c2ecf20Sopenharmony_ci return retval; 11378c2ecf20Sopenharmony_ci} 11388c2ecf20Sopenharmony_ci 11398c2ecf20Sopenharmony_cistatic ssize_t write_file_tpc(struct file *file, const char __user *user_buf, 11408c2ecf20Sopenharmony_ci size_t count, loff_t *ppos) 11418c2ecf20Sopenharmony_ci{ 11428c2ecf20Sopenharmony_ci struct ath_softc *sc = file->private_data; 11438c2ecf20Sopenharmony_ci struct ath_hw *ah = sc->sc_ah; 11448c2ecf20Sopenharmony_ci unsigned long val; 11458c2ecf20Sopenharmony_ci char buf[32]; 11468c2ecf20Sopenharmony_ci ssize_t len; 11478c2ecf20Sopenharmony_ci bool tpc_enabled; 11488c2ecf20Sopenharmony_ci 11498c2ecf20Sopenharmony_ci len = min(count, sizeof(buf) - 1); 11508c2ecf20Sopenharmony_ci if (copy_from_user(buf, user_buf, len)) 11518c2ecf20Sopenharmony_ci return -EFAULT; 11528c2ecf20Sopenharmony_ci 11538c2ecf20Sopenharmony_ci buf[len] = '\0'; 11548c2ecf20Sopenharmony_ci if (kstrtoul(buf, 0, &val)) 11558c2ecf20Sopenharmony_ci return -EINVAL; 11568c2ecf20Sopenharmony_ci 11578c2ecf20Sopenharmony_ci if (val > 1) 11588c2ecf20Sopenharmony_ci return -EINVAL; 11598c2ecf20Sopenharmony_ci 11608c2ecf20Sopenharmony_ci tpc_enabled = !!val; 11618c2ecf20Sopenharmony_ci 11628c2ecf20Sopenharmony_ci if (tpc_enabled != ah->tpc_enabled) { 11638c2ecf20Sopenharmony_ci ah->tpc_enabled = tpc_enabled; 11648c2ecf20Sopenharmony_ci 11658c2ecf20Sopenharmony_ci mutex_lock(&sc->mutex); 11668c2ecf20Sopenharmony_ci ath9k_set_txpower(sc, NULL); 11678c2ecf20Sopenharmony_ci mutex_unlock(&sc->mutex); 11688c2ecf20Sopenharmony_ci } 11698c2ecf20Sopenharmony_ci 11708c2ecf20Sopenharmony_ci return count; 11718c2ecf20Sopenharmony_ci} 11728c2ecf20Sopenharmony_ci 11738c2ecf20Sopenharmony_cistatic const struct file_operations fops_tpc = { 11748c2ecf20Sopenharmony_ci .read = read_file_tpc, 11758c2ecf20Sopenharmony_ci .write = write_file_tpc, 11768c2ecf20Sopenharmony_ci .open = simple_open, 11778c2ecf20Sopenharmony_ci .owner = THIS_MODULE, 11788c2ecf20Sopenharmony_ci .llseek = default_llseek, 11798c2ecf20Sopenharmony_ci}; 11808c2ecf20Sopenharmony_ci 11818c2ecf20Sopenharmony_cistatic ssize_t read_file_nf_override(struct file *file, 11828c2ecf20Sopenharmony_ci char __user *user_buf, 11838c2ecf20Sopenharmony_ci size_t count, loff_t *ppos) 11848c2ecf20Sopenharmony_ci{ 11858c2ecf20Sopenharmony_ci struct ath_softc *sc = file->private_data; 11868c2ecf20Sopenharmony_ci struct ath_hw *ah = sc->sc_ah; 11878c2ecf20Sopenharmony_ci char buf[32]; 11888c2ecf20Sopenharmony_ci unsigned int len; 11898c2ecf20Sopenharmony_ci 11908c2ecf20Sopenharmony_ci if (ah->nf_override == 0) 11918c2ecf20Sopenharmony_ci len = sprintf(buf, "off\n"); 11928c2ecf20Sopenharmony_ci else 11938c2ecf20Sopenharmony_ci len = sprintf(buf, "%d\n", ah->nf_override); 11948c2ecf20Sopenharmony_ci 11958c2ecf20Sopenharmony_ci return simple_read_from_buffer(user_buf, count, ppos, buf, len); 11968c2ecf20Sopenharmony_ci} 11978c2ecf20Sopenharmony_ci 11988c2ecf20Sopenharmony_cistatic ssize_t write_file_nf_override(struct file *file, 11998c2ecf20Sopenharmony_ci const char __user *user_buf, 12008c2ecf20Sopenharmony_ci size_t count, loff_t *ppos) 12018c2ecf20Sopenharmony_ci{ 12028c2ecf20Sopenharmony_ci struct ath_softc *sc = file->private_data; 12038c2ecf20Sopenharmony_ci struct ath_hw *ah = sc->sc_ah; 12048c2ecf20Sopenharmony_ci long val; 12058c2ecf20Sopenharmony_ci char buf[32]; 12068c2ecf20Sopenharmony_ci ssize_t len; 12078c2ecf20Sopenharmony_ci 12088c2ecf20Sopenharmony_ci len = min(count, sizeof(buf) - 1); 12098c2ecf20Sopenharmony_ci if (copy_from_user(buf, user_buf, len)) 12108c2ecf20Sopenharmony_ci return -EFAULT; 12118c2ecf20Sopenharmony_ci 12128c2ecf20Sopenharmony_ci buf[len] = '\0'; 12138c2ecf20Sopenharmony_ci if (strncmp("off", buf, 3) == 0) 12148c2ecf20Sopenharmony_ci val = 0; 12158c2ecf20Sopenharmony_ci else if (kstrtol(buf, 0, &val)) 12168c2ecf20Sopenharmony_ci return -EINVAL; 12178c2ecf20Sopenharmony_ci 12188c2ecf20Sopenharmony_ci if (val > 0) 12198c2ecf20Sopenharmony_ci return -EINVAL; 12208c2ecf20Sopenharmony_ci 12218c2ecf20Sopenharmony_ci if (val < -120) 12228c2ecf20Sopenharmony_ci return -EINVAL; 12238c2ecf20Sopenharmony_ci 12248c2ecf20Sopenharmony_ci ah->nf_override = val; 12258c2ecf20Sopenharmony_ci 12268c2ecf20Sopenharmony_ci if (ah->curchan) { 12278c2ecf20Sopenharmony_ci ath9k_ps_wakeup(sc); 12288c2ecf20Sopenharmony_ci ath9k_hw_loadnf(ah, ah->curchan); 12298c2ecf20Sopenharmony_ci ath9k_ps_restore(sc); 12308c2ecf20Sopenharmony_ci } 12318c2ecf20Sopenharmony_ci 12328c2ecf20Sopenharmony_ci return count; 12338c2ecf20Sopenharmony_ci} 12348c2ecf20Sopenharmony_ci 12358c2ecf20Sopenharmony_cistatic const struct file_operations fops_nf_override = { 12368c2ecf20Sopenharmony_ci .read = read_file_nf_override, 12378c2ecf20Sopenharmony_ci .write = write_file_nf_override, 12388c2ecf20Sopenharmony_ci .open = simple_open, 12398c2ecf20Sopenharmony_ci .owner = THIS_MODULE, 12408c2ecf20Sopenharmony_ci .llseek = default_llseek, 12418c2ecf20Sopenharmony_ci}; 12428c2ecf20Sopenharmony_ci 12438c2ecf20Sopenharmony_ci/* Ethtool support for get-stats */ 12448c2ecf20Sopenharmony_ci 12458c2ecf20Sopenharmony_ci#define AMKSTR(nm) #nm "_BE", #nm "_BK", #nm "_VI", #nm "_VO" 12468c2ecf20Sopenharmony_cistatic const char ath9k_gstrings_stats[][ETH_GSTRING_LEN] = { 12478c2ecf20Sopenharmony_ci "tx_pkts_nic", 12488c2ecf20Sopenharmony_ci "tx_bytes_nic", 12498c2ecf20Sopenharmony_ci "rx_pkts_nic", 12508c2ecf20Sopenharmony_ci "rx_bytes_nic", 12518c2ecf20Sopenharmony_ci AMKSTR(d_tx_pkts), 12528c2ecf20Sopenharmony_ci AMKSTR(d_tx_bytes), 12538c2ecf20Sopenharmony_ci AMKSTR(d_tx_mpdus_queued), 12548c2ecf20Sopenharmony_ci AMKSTR(d_tx_mpdus_completed), 12558c2ecf20Sopenharmony_ci AMKSTR(d_tx_mpdu_xretries), 12568c2ecf20Sopenharmony_ci AMKSTR(d_tx_aggregates), 12578c2ecf20Sopenharmony_ci AMKSTR(d_tx_ampdus_queued_hw), 12588c2ecf20Sopenharmony_ci AMKSTR(d_tx_ampdus_completed), 12598c2ecf20Sopenharmony_ci AMKSTR(d_tx_ampdu_retries), 12608c2ecf20Sopenharmony_ci AMKSTR(d_tx_ampdu_xretries), 12618c2ecf20Sopenharmony_ci AMKSTR(d_tx_fifo_underrun), 12628c2ecf20Sopenharmony_ci AMKSTR(d_tx_op_exceeded), 12638c2ecf20Sopenharmony_ci AMKSTR(d_tx_timer_expiry), 12648c2ecf20Sopenharmony_ci AMKSTR(d_tx_desc_cfg_err), 12658c2ecf20Sopenharmony_ci AMKSTR(d_tx_data_underrun), 12668c2ecf20Sopenharmony_ci AMKSTR(d_tx_delim_underrun), 12678c2ecf20Sopenharmony_ci "d_rx_crc_err", 12688c2ecf20Sopenharmony_ci "d_rx_decrypt_crc_err", 12698c2ecf20Sopenharmony_ci "d_rx_phy_err", 12708c2ecf20Sopenharmony_ci "d_rx_mic_err", 12718c2ecf20Sopenharmony_ci "d_rx_pre_delim_crc_err", 12728c2ecf20Sopenharmony_ci "d_rx_post_delim_crc_err", 12738c2ecf20Sopenharmony_ci "d_rx_decrypt_busy_err", 12748c2ecf20Sopenharmony_ci 12758c2ecf20Sopenharmony_ci "d_rx_phyerr_radar", 12768c2ecf20Sopenharmony_ci "d_rx_phyerr_ofdm_timing", 12778c2ecf20Sopenharmony_ci "d_rx_phyerr_cck_timing", 12788c2ecf20Sopenharmony_ci 12798c2ecf20Sopenharmony_ci}; 12808c2ecf20Sopenharmony_ci#define ATH9K_SSTATS_LEN ARRAY_SIZE(ath9k_gstrings_stats) 12818c2ecf20Sopenharmony_ci 12828c2ecf20Sopenharmony_civoid ath9k_get_et_strings(struct ieee80211_hw *hw, 12838c2ecf20Sopenharmony_ci struct ieee80211_vif *vif, 12848c2ecf20Sopenharmony_ci u32 sset, u8 *data) 12858c2ecf20Sopenharmony_ci{ 12868c2ecf20Sopenharmony_ci if (sset == ETH_SS_STATS) 12878c2ecf20Sopenharmony_ci memcpy(data, ath9k_gstrings_stats, 12888c2ecf20Sopenharmony_ci sizeof(ath9k_gstrings_stats)); 12898c2ecf20Sopenharmony_ci} 12908c2ecf20Sopenharmony_ci 12918c2ecf20Sopenharmony_ciint ath9k_get_et_sset_count(struct ieee80211_hw *hw, 12928c2ecf20Sopenharmony_ci struct ieee80211_vif *vif, int sset) 12938c2ecf20Sopenharmony_ci{ 12948c2ecf20Sopenharmony_ci if (sset == ETH_SS_STATS) 12958c2ecf20Sopenharmony_ci return ATH9K_SSTATS_LEN; 12968c2ecf20Sopenharmony_ci return 0; 12978c2ecf20Sopenharmony_ci} 12988c2ecf20Sopenharmony_ci 12998c2ecf20Sopenharmony_ci#define AWDATA(elem) \ 13008c2ecf20Sopenharmony_ci do { \ 13018c2ecf20Sopenharmony_ci data[i++] = sc->debug.stats.txstats[PR_QNUM(IEEE80211_AC_BE)].elem; \ 13028c2ecf20Sopenharmony_ci data[i++] = sc->debug.stats.txstats[PR_QNUM(IEEE80211_AC_BK)].elem; \ 13038c2ecf20Sopenharmony_ci data[i++] = sc->debug.stats.txstats[PR_QNUM(IEEE80211_AC_VI)].elem; \ 13048c2ecf20Sopenharmony_ci data[i++] = sc->debug.stats.txstats[PR_QNUM(IEEE80211_AC_VO)].elem; \ 13058c2ecf20Sopenharmony_ci } while (0) 13068c2ecf20Sopenharmony_ci 13078c2ecf20Sopenharmony_ci#define AWDATA_RX(elem) \ 13088c2ecf20Sopenharmony_ci do { \ 13098c2ecf20Sopenharmony_ci data[i++] = sc->debug.stats.rxstats.elem; \ 13108c2ecf20Sopenharmony_ci } while (0) 13118c2ecf20Sopenharmony_ci 13128c2ecf20Sopenharmony_civoid ath9k_get_et_stats(struct ieee80211_hw *hw, 13138c2ecf20Sopenharmony_ci struct ieee80211_vif *vif, 13148c2ecf20Sopenharmony_ci struct ethtool_stats *stats, u64 *data) 13158c2ecf20Sopenharmony_ci{ 13168c2ecf20Sopenharmony_ci struct ath_softc *sc = hw->priv; 13178c2ecf20Sopenharmony_ci int i = 0; 13188c2ecf20Sopenharmony_ci 13198c2ecf20Sopenharmony_ci data[i++] = (sc->debug.stats.txstats[PR_QNUM(IEEE80211_AC_BE)].tx_pkts_all + 13208c2ecf20Sopenharmony_ci sc->debug.stats.txstats[PR_QNUM(IEEE80211_AC_BK)].tx_pkts_all + 13218c2ecf20Sopenharmony_ci sc->debug.stats.txstats[PR_QNUM(IEEE80211_AC_VI)].tx_pkts_all + 13228c2ecf20Sopenharmony_ci sc->debug.stats.txstats[PR_QNUM(IEEE80211_AC_VO)].tx_pkts_all); 13238c2ecf20Sopenharmony_ci data[i++] = (sc->debug.stats.txstats[PR_QNUM(IEEE80211_AC_BE)].tx_bytes_all + 13248c2ecf20Sopenharmony_ci sc->debug.stats.txstats[PR_QNUM(IEEE80211_AC_BK)].tx_bytes_all + 13258c2ecf20Sopenharmony_ci sc->debug.stats.txstats[PR_QNUM(IEEE80211_AC_VI)].tx_bytes_all + 13268c2ecf20Sopenharmony_ci sc->debug.stats.txstats[PR_QNUM(IEEE80211_AC_VO)].tx_bytes_all); 13278c2ecf20Sopenharmony_ci AWDATA_RX(rx_pkts_all); 13288c2ecf20Sopenharmony_ci AWDATA_RX(rx_bytes_all); 13298c2ecf20Sopenharmony_ci 13308c2ecf20Sopenharmony_ci AWDATA(tx_pkts_all); 13318c2ecf20Sopenharmony_ci AWDATA(tx_bytes_all); 13328c2ecf20Sopenharmony_ci AWDATA(queued); 13338c2ecf20Sopenharmony_ci AWDATA(completed); 13348c2ecf20Sopenharmony_ci AWDATA(xretries); 13358c2ecf20Sopenharmony_ci AWDATA(a_aggr); 13368c2ecf20Sopenharmony_ci AWDATA(a_queued_hw); 13378c2ecf20Sopenharmony_ci AWDATA(a_completed); 13388c2ecf20Sopenharmony_ci AWDATA(a_retries); 13398c2ecf20Sopenharmony_ci AWDATA(a_xretries); 13408c2ecf20Sopenharmony_ci AWDATA(fifo_underrun); 13418c2ecf20Sopenharmony_ci AWDATA(xtxop); 13428c2ecf20Sopenharmony_ci AWDATA(timer_exp); 13438c2ecf20Sopenharmony_ci AWDATA(desc_cfg_err); 13448c2ecf20Sopenharmony_ci AWDATA(data_underrun); 13458c2ecf20Sopenharmony_ci AWDATA(delim_underrun); 13468c2ecf20Sopenharmony_ci 13478c2ecf20Sopenharmony_ci AWDATA_RX(crc_err); 13488c2ecf20Sopenharmony_ci AWDATA_RX(decrypt_crc_err); 13498c2ecf20Sopenharmony_ci AWDATA_RX(phy_err); 13508c2ecf20Sopenharmony_ci AWDATA_RX(mic_err); 13518c2ecf20Sopenharmony_ci AWDATA_RX(pre_delim_crc_err); 13528c2ecf20Sopenharmony_ci AWDATA_RX(post_delim_crc_err); 13538c2ecf20Sopenharmony_ci AWDATA_RX(decrypt_busy_err); 13548c2ecf20Sopenharmony_ci 13558c2ecf20Sopenharmony_ci AWDATA_RX(phy_err_stats[ATH9K_PHYERR_RADAR]); 13568c2ecf20Sopenharmony_ci AWDATA_RX(phy_err_stats[ATH9K_PHYERR_OFDM_TIMING]); 13578c2ecf20Sopenharmony_ci AWDATA_RX(phy_err_stats[ATH9K_PHYERR_CCK_TIMING]); 13588c2ecf20Sopenharmony_ci 13598c2ecf20Sopenharmony_ci WARN_ON(i != ATH9K_SSTATS_LEN); 13608c2ecf20Sopenharmony_ci} 13618c2ecf20Sopenharmony_ci 13628c2ecf20Sopenharmony_civoid ath9k_deinit_debug(struct ath_softc *sc) 13638c2ecf20Sopenharmony_ci{ 13648c2ecf20Sopenharmony_ci ath9k_cmn_spectral_deinit_debug(&sc->spec_priv); 13658c2ecf20Sopenharmony_ci} 13668c2ecf20Sopenharmony_ci 13678c2ecf20Sopenharmony_ciint ath9k_init_debug(struct ath_hw *ah) 13688c2ecf20Sopenharmony_ci{ 13698c2ecf20Sopenharmony_ci struct ath_common *common = ath9k_hw_common(ah); 13708c2ecf20Sopenharmony_ci struct ath_softc *sc = (struct ath_softc *) common->priv; 13718c2ecf20Sopenharmony_ci 13728c2ecf20Sopenharmony_ci sc->debug.debugfs_phy = debugfs_create_dir("ath9k", 13738c2ecf20Sopenharmony_ci sc->hw->wiphy->debugfsdir); 13748c2ecf20Sopenharmony_ci if (!sc->debug.debugfs_phy) 13758c2ecf20Sopenharmony_ci return -ENOMEM; 13768c2ecf20Sopenharmony_ci 13778c2ecf20Sopenharmony_ci#ifdef CONFIG_ATH_DEBUG 13788c2ecf20Sopenharmony_ci debugfs_create_file("debug", 0600, sc->debug.debugfs_phy, 13798c2ecf20Sopenharmony_ci sc, &fops_debug); 13808c2ecf20Sopenharmony_ci#endif 13818c2ecf20Sopenharmony_ci 13828c2ecf20Sopenharmony_ci ath9k_dfs_init_debug(sc); 13838c2ecf20Sopenharmony_ci ath9k_tx99_init_debug(sc); 13848c2ecf20Sopenharmony_ci ath9k_cmn_spectral_init_debug(&sc->spec_priv, sc->debug.debugfs_phy); 13858c2ecf20Sopenharmony_ci 13868c2ecf20Sopenharmony_ci debugfs_create_devm_seqfile(sc->dev, "dma", sc->debug.debugfs_phy, 13878c2ecf20Sopenharmony_ci read_file_dma); 13888c2ecf20Sopenharmony_ci debugfs_create_devm_seqfile(sc->dev, "interrupt", sc->debug.debugfs_phy, 13898c2ecf20Sopenharmony_ci read_file_interrupt); 13908c2ecf20Sopenharmony_ci debugfs_create_devm_seqfile(sc->dev, "xmit", sc->debug.debugfs_phy, 13918c2ecf20Sopenharmony_ci read_file_xmit); 13928c2ecf20Sopenharmony_ci debugfs_create_devm_seqfile(sc->dev, "queues", sc->debug.debugfs_phy, 13938c2ecf20Sopenharmony_ci read_file_queues); 13948c2ecf20Sopenharmony_ci debugfs_create_devm_seqfile(sc->dev, "misc", sc->debug.debugfs_phy, 13958c2ecf20Sopenharmony_ci read_file_misc); 13968c2ecf20Sopenharmony_ci debugfs_create_devm_seqfile(sc->dev, "reset", sc->debug.debugfs_phy, 13978c2ecf20Sopenharmony_ci read_file_reset); 13988c2ecf20Sopenharmony_ci 13998c2ecf20Sopenharmony_ci ath9k_cmn_debug_recv(sc->debug.debugfs_phy, &sc->debug.stats.rxstats); 14008c2ecf20Sopenharmony_ci ath9k_cmn_debug_phy_err(sc->debug.debugfs_phy, &sc->debug.stats.rxstats); 14018c2ecf20Sopenharmony_ci 14028c2ecf20Sopenharmony_ci debugfs_create_u8("rx_chainmask", 0400, sc->debug.debugfs_phy, 14038c2ecf20Sopenharmony_ci &ah->rxchainmask); 14048c2ecf20Sopenharmony_ci debugfs_create_u8("tx_chainmask", 0400, sc->debug.debugfs_phy, 14058c2ecf20Sopenharmony_ci &ah->txchainmask); 14068c2ecf20Sopenharmony_ci debugfs_create_file("ani", 0600, 14078c2ecf20Sopenharmony_ci sc->debug.debugfs_phy, sc, &fops_ani); 14088c2ecf20Sopenharmony_ci debugfs_create_bool("paprd", 0600, sc->debug.debugfs_phy, 14098c2ecf20Sopenharmony_ci &sc->sc_ah->config.enable_paprd); 14108c2ecf20Sopenharmony_ci debugfs_create_file("regidx", 0600, sc->debug.debugfs_phy, 14118c2ecf20Sopenharmony_ci sc, &fops_regidx); 14128c2ecf20Sopenharmony_ci debugfs_create_file("regval", 0600, sc->debug.debugfs_phy, 14138c2ecf20Sopenharmony_ci sc, &fops_regval); 14148c2ecf20Sopenharmony_ci debugfs_create_bool("ignore_extcca", 0600, 14158c2ecf20Sopenharmony_ci sc->debug.debugfs_phy, 14168c2ecf20Sopenharmony_ci &ah->config.cwm_ignore_extcca); 14178c2ecf20Sopenharmony_ci debugfs_create_file("regdump", 0400, sc->debug.debugfs_phy, sc, 14188c2ecf20Sopenharmony_ci &fops_regdump); 14198c2ecf20Sopenharmony_ci debugfs_create_devm_seqfile(sc->dev, "dump_nfcal", 14208c2ecf20Sopenharmony_ci sc->debug.debugfs_phy, 14218c2ecf20Sopenharmony_ci read_file_dump_nfcal); 14228c2ecf20Sopenharmony_ci 14238c2ecf20Sopenharmony_ci ath9k_cmn_debug_base_eeprom(sc->debug.debugfs_phy, sc->sc_ah); 14248c2ecf20Sopenharmony_ci ath9k_cmn_debug_modal_eeprom(sc->debug.debugfs_phy, sc->sc_ah); 14258c2ecf20Sopenharmony_ci 14268c2ecf20Sopenharmony_ci debugfs_create_u32("gpio_mask", 0600, 14278c2ecf20Sopenharmony_ci sc->debug.debugfs_phy, &sc->sc_ah->gpio_mask); 14288c2ecf20Sopenharmony_ci debugfs_create_u32("gpio_val", 0600, 14298c2ecf20Sopenharmony_ci sc->debug.debugfs_phy, &sc->sc_ah->gpio_val); 14308c2ecf20Sopenharmony_ci debugfs_create_file("antenna_diversity", 0400, 14318c2ecf20Sopenharmony_ci sc->debug.debugfs_phy, sc, &fops_antenna_diversity); 14328c2ecf20Sopenharmony_ci#ifdef CONFIG_ATH9K_BTCOEX_SUPPORT 14338c2ecf20Sopenharmony_ci debugfs_create_file("bt_ant_diversity", 0600, 14348c2ecf20Sopenharmony_ci sc->debug.debugfs_phy, sc, &fops_bt_ant_diversity); 14358c2ecf20Sopenharmony_ci debugfs_create_file("btcoex", 0400, sc->debug.debugfs_phy, sc, 14368c2ecf20Sopenharmony_ci &fops_btcoex); 14378c2ecf20Sopenharmony_ci#endif 14388c2ecf20Sopenharmony_ci 14398c2ecf20Sopenharmony_ci#ifdef CONFIG_ATH9K_WOW 14408c2ecf20Sopenharmony_ci debugfs_create_file("wow", 0600, sc->debug.debugfs_phy, sc, &fops_wow); 14418c2ecf20Sopenharmony_ci#endif 14428c2ecf20Sopenharmony_ci 14438c2ecf20Sopenharmony_ci#ifdef CONFIG_ATH9K_DYNACK 14448c2ecf20Sopenharmony_ci debugfs_create_file("ack_to", 0400, sc->debug.debugfs_phy, 14458c2ecf20Sopenharmony_ci sc, &fops_ackto); 14468c2ecf20Sopenharmony_ci#endif 14478c2ecf20Sopenharmony_ci debugfs_create_file("tpc", 0600, sc->debug.debugfs_phy, sc, &fops_tpc); 14488c2ecf20Sopenharmony_ci 14498c2ecf20Sopenharmony_ci debugfs_create_file("nf_override", 0600, 14508c2ecf20Sopenharmony_ci sc->debug.debugfs_phy, sc, &fops_nf_override); 14518c2ecf20Sopenharmony_ci 14528c2ecf20Sopenharmony_ci return 0; 14538c2ecf20Sopenharmony_ci} 1454