Sujith | 88b126a | 2008-11-28 22:19:02 +0530 | [diff] [blame] | 1 | /* |
Sujith Manoharan | 5b68138 | 2011-05-17 13:36:18 +0530 | [diff] [blame] | 2 | * Copyright (c) 2008-2011 Atheros Communications Inc. |
Sujith | 88b126a | 2008-11-28 22:19:02 +0530 | [diff] [blame] | 3 | * |
| 4 | * Permission to use, copy, modify, and/or distribute this software for any |
| 5 | * purpose with or without fee is hereby granted, provided that the above |
| 6 | * copyright notice and this permission notice appear in all copies. |
| 7 | * |
| 8 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES |
| 9 | * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF |
| 10 | * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR |
| 11 | * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES |
| 12 | * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN |
| 13 | * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF |
| 14 | * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. |
| 15 | */ |
| 16 | |
Tejun Heo | 5a0e3ad | 2010-03-24 17:04:11 +0900 | [diff] [blame] | 17 | #include <linux/slab.h> |
Vasanthakumar Thiagarajan | 582d006 | 2011-03-01 05:30:55 -0800 | [diff] [blame] | 18 | #include <linux/vmalloc.h> |
Paul Gortmaker | ee40fa0 | 2011-05-27 16:14:23 -0400 | [diff] [blame] | 19 | #include <linux/export.h> |
Gabor Juhos | 5210311 | 2009-03-06 09:57:39 +0100 | [diff] [blame] | 20 | #include <asm/unaligned.h> |
| 21 | |
Sujith | 394cf0a | 2009-02-09 13:26:54 +0530 | [diff] [blame] | 22 | #include "ath9k.h" |
Sujith | 88b126a | 2008-11-28 22:19:02 +0530 | [diff] [blame] | 23 | |
Luis R. Rodriguez | 475a6e4 | 2009-09-23 23:06:59 -0400 | [diff] [blame] | 24 | #define REG_WRITE_D(_ah, _reg, _val) \ |
| 25 | ath9k_hw_common(_ah)->ops->write((_ah), (_val), (_reg)) |
| 26 | #define REG_READ_D(_ah, _reg) \ |
| 27 | ath9k_hw_common(_ah)->ops->read((_ah), (_reg)) |
| 28 | |
Felix Fietkau | 6a4d05d | 2013-12-19 18:01:48 +0100 | [diff] [blame] | 29 | void ath9k_debug_sync_cause(struct ath_softc *sc, u32 sync_cause) |
| 30 | { |
| 31 | if (sync_cause) |
| 32 | sc->debug.stats.istats.sync_cause_all++; |
| 33 | if (sync_cause & AR_INTR_SYNC_RTC_IRQ) |
| 34 | sc->debug.stats.istats.sync_rtc_irq++; |
| 35 | if (sync_cause & AR_INTR_SYNC_MAC_IRQ) |
| 36 | sc->debug.stats.istats.sync_mac_irq++; |
| 37 | if (sync_cause & AR_INTR_SYNC_EEPROM_ILLEGAL_ACCESS) |
| 38 | sc->debug.stats.istats.eeprom_illegal_access++; |
| 39 | if (sync_cause & AR_INTR_SYNC_APB_TIMEOUT) |
| 40 | sc->debug.stats.istats.apb_timeout++; |
| 41 | if (sync_cause & AR_INTR_SYNC_PCI_MODE_CONFLICT) |
| 42 | sc->debug.stats.istats.pci_mode_conflict++; |
| 43 | if (sync_cause & AR_INTR_SYNC_HOST1_FATAL) |
| 44 | sc->debug.stats.istats.host1_fatal++; |
| 45 | if (sync_cause & AR_INTR_SYNC_HOST1_PERR) |
| 46 | sc->debug.stats.istats.host1_perr++; |
| 47 | if (sync_cause & AR_INTR_SYNC_TRCV_FIFO_PERR) |
| 48 | sc->debug.stats.istats.trcv_fifo_perr++; |
| 49 | if (sync_cause & AR_INTR_SYNC_RADM_CPL_EP) |
| 50 | sc->debug.stats.istats.radm_cpl_ep++; |
| 51 | if (sync_cause & AR_INTR_SYNC_RADM_CPL_DLLP_ABORT) |
| 52 | sc->debug.stats.istats.radm_cpl_dllp_abort++; |
| 53 | if (sync_cause & AR_INTR_SYNC_RADM_CPL_TLP_ABORT) |
| 54 | sc->debug.stats.istats.radm_cpl_tlp_abort++; |
| 55 | if (sync_cause & AR_INTR_SYNC_RADM_CPL_ECRC_ERR) |
| 56 | sc->debug.stats.istats.radm_cpl_ecrc_err++; |
| 57 | if (sync_cause & AR_INTR_SYNC_RADM_CPL_TIMEOUT) |
| 58 | sc->debug.stats.istats.radm_cpl_timeout++; |
| 59 | if (sync_cause & AR_INTR_SYNC_LOCAL_TIMEOUT) |
| 60 | sc->debug.stats.istats.local_timeout++; |
| 61 | if (sync_cause & AR_INTR_SYNC_PM_ACCESS) |
| 62 | sc->debug.stats.istats.pm_access++; |
| 63 | if (sync_cause & AR_INTR_SYNC_MAC_AWAKE) |
| 64 | sc->debug.stats.istats.mac_awake++; |
| 65 | if (sync_cause & AR_INTR_SYNC_MAC_ASLEEP) |
| 66 | sc->debug.stats.istats.mac_asleep++; |
| 67 | if (sync_cause & AR_INTR_SYNC_MAC_SLEEP_ACCESS) |
| 68 | sc->debug.stats.istats.mac_sleep_access++; |
| 69 | } |
Sujith | 2a163c6 | 2008-11-28 22:21:08 +0530 | [diff] [blame] | 70 | |
Vasanthakumar Thiagarajan | 582d006 | 2011-03-01 05:30:55 -0800 | [diff] [blame] | 71 | static ssize_t ath9k_debugfs_read_buf(struct file *file, char __user *user_buf, |
| 72 | size_t count, loff_t *ppos) |
| 73 | { |
| 74 | u8 *buf = file->private_data; |
| 75 | return simple_read_from_buffer(user_buf, count, ppos, buf, strlen(buf)); |
| 76 | } |
| 77 | |
| 78 | static int ath9k_debugfs_release_buf(struct inode *inode, struct file *file) |
| 79 | { |
| 80 | vfree(file->private_data); |
| 81 | return 0; |
| 82 | } |
| 83 | |
Felix Fietkau | a830df0 | 2009-11-23 22:33:27 +0100 | [diff] [blame] | 84 | #ifdef CONFIG_ATH_DEBUG |
| 85 | |
Jeff Hansen | 2493928 | 2009-05-27 12:48:29 +0000 | [diff] [blame] | 86 | static ssize_t read_file_debug(struct file *file, char __user *user_buf, |
| 87 | size_t count, loff_t *ppos) |
| 88 | { |
| 89 | struct ath_softc *sc = file->private_data; |
Luis R. Rodriguez | c46917b | 2009-09-13 02:42:02 -0700 | [diff] [blame] | 90 | struct ath_common *common = ath9k_hw_common(sc->sc_ah); |
Jeff Hansen | 2493928 | 2009-05-27 12:48:29 +0000 | [diff] [blame] | 91 | char buf[32]; |
Vasanthakumar Thiagarajan | 581f725 | 2009-06-02 19:28:55 +0530 | [diff] [blame] | 92 | unsigned int len; |
| 93 | |
Dan Carpenter | 2b87f3a | 2010-05-14 15:24:37 +0200 | [diff] [blame] | 94 | len = sprintf(buf, "0x%08x\n", common->debug_mask); |
Jeff Hansen | 2493928 | 2009-05-27 12:48:29 +0000 | [diff] [blame] | 95 | return simple_read_from_buffer(user_buf, count, ppos, buf, len); |
| 96 | } |
| 97 | |
| 98 | static ssize_t write_file_debug(struct file *file, const char __user *user_buf, |
| 99 | size_t count, loff_t *ppos) |
| 100 | { |
| 101 | struct ath_softc *sc = file->private_data; |
Luis R. Rodriguez | c46917b | 2009-09-13 02:42:02 -0700 | [diff] [blame] | 102 | struct ath_common *common = ath9k_hw_common(sc->sc_ah); |
Jeff Hansen | 2493928 | 2009-05-27 12:48:29 +0000 | [diff] [blame] | 103 | unsigned long mask; |
| 104 | char buf[32]; |
Vasanthakumar Thiagarajan | 581f725 | 2009-06-02 19:28:55 +0530 | [diff] [blame] | 105 | ssize_t len; |
| 106 | |
| 107 | len = min(count, sizeof(buf) - 1); |
| 108 | if (copy_from_user(buf, user_buf, len)) |
Dan Carpenter | 0423606 | 2010-05-14 15:25:39 +0200 | [diff] [blame] | 109 | return -EFAULT; |
Vasanthakumar Thiagarajan | 581f725 | 2009-06-02 19:28:55 +0530 | [diff] [blame] | 110 | |
| 111 | buf[len] = '\0'; |
Jingoo Han | 27d7f47 | 2013-05-31 21:24:06 +0000 | [diff] [blame] | 112 | if (kstrtoul(buf, 0, &mask)) |
Vasanthakumar Thiagarajan | 581f725 | 2009-06-02 19:28:55 +0530 | [diff] [blame] | 113 | return -EINVAL; |
| 114 | |
Luis R. Rodriguez | c46917b | 2009-09-13 02:42:02 -0700 | [diff] [blame] | 115 | common->debug_mask = mask; |
Jeff Hansen | 2493928 | 2009-05-27 12:48:29 +0000 | [diff] [blame] | 116 | return count; |
| 117 | } |
| 118 | |
| 119 | static const struct file_operations fops_debug = { |
| 120 | .read = read_file_debug, |
| 121 | .write = write_file_debug, |
Stephen Boyd | 234e340 | 2012-04-05 14:25:11 -0700 | [diff] [blame] | 122 | .open = simple_open, |
Arnd Bergmann | 6038f37 | 2010-08-15 18:52:59 +0200 | [diff] [blame] | 123 | .owner = THIS_MODULE, |
| 124 | .llseek = default_llseek, |
Jeff Hansen | 2493928 | 2009-05-27 12:48:29 +0000 | [diff] [blame] | 125 | }; |
| 126 | |
Felix Fietkau | a830df0 | 2009-11-23 22:33:27 +0100 | [diff] [blame] | 127 | #endif |
| 128 | |
Pavel Roskin | 991a098 | 2010-01-29 17:22:26 -0500 | [diff] [blame] | 129 | #define DMA_BUF_LEN 1024 |
| 130 | |
Felix Fietkau | 1534069 | 2010-05-11 17:23:01 +0200 | [diff] [blame] | 131 | |
Sujith Manoharan | 6e4d291 | 2013-06-03 09:19:28 +0530 | [diff] [blame] | 132 | static ssize_t read_file_ani(struct file *file, char __user *user_buf, |
Mohammed Shafi Shajakhan | 05c0be2 | 2011-05-26 10:56:15 +0530 | [diff] [blame] | 133 | size_t count, loff_t *ppos) |
| 134 | { |
| 135 | struct ath_softc *sc = file->private_data; |
| 136 | struct ath_common *common = ath9k_hw_common(sc->sc_ah); |
Sujith Manoharan | 6e4d291 | 2013-06-03 09:19:28 +0530 | [diff] [blame] | 137 | struct ath_hw *ah = sc->sc_ah; |
Joe Perches | 2120ac9 | 2014-02-21 14:46:43 -0800 | [diff] [blame] | 138 | unsigned int len = 0; |
| 139 | const unsigned int size = 1024; |
Sujith Manoharan | 6e4d291 | 2013-06-03 09:19:28 +0530 | [diff] [blame] | 140 | ssize_t retval = 0; |
| 141 | char *buf; |
Mohammed Shafi Shajakhan | 05c0be2 | 2011-05-26 10:56:15 +0530 | [diff] [blame] | 142 | |
Sujith Manoharan | 6e4d291 | 2013-06-03 09:19:28 +0530 | [diff] [blame] | 143 | buf = kzalloc(size, GFP_KERNEL); |
| 144 | if (buf == NULL) |
| 145 | return -ENOMEM; |
| 146 | |
| 147 | if (common->disable_ani) { |
Zefir Kurtisi | 5e88ba6 | 2013-09-05 14:11:57 +0200 | [diff] [blame] | 148 | len += scnprintf(buf + len, size - len, "%s: %s\n", |
| 149 | "ANI", "DISABLED"); |
Sujith Manoharan | 6e4d291 | 2013-06-03 09:19:28 +0530 | [diff] [blame] | 150 | goto exit; |
| 151 | } |
| 152 | |
Zefir Kurtisi | 5e88ba6 | 2013-09-05 14:11:57 +0200 | [diff] [blame] | 153 | len += scnprintf(buf + len, size - len, "%15s: %s\n", |
| 154 | "ANI", "ENABLED"); |
| 155 | len += scnprintf(buf + len, size - len, "%15s: %u\n", |
| 156 | "ANI RESET", ah->stats.ast_ani_reset); |
| 157 | len += scnprintf(buf + len, size - len, "%15s: %u\n", |
| 158 | "SPUR UP", ah->stats.ast_ani_spurup); |
| 159 | len += scnprintf(buf + len, size - len, "%15s: %u\n", |
| 160 | "SPUR DOWN", ah->stats.ast_ani_spurup); |
| 161 | len += scnprintf(buf + len, size - len, "%15s: %u\n", |
| 162 | "OFDM WS-DET ON", ah->stats.ast_ani_ofdmon); |
| 163 | len += scnprintf(buf + len, size - len, "%15s: %u\n", |
| 164 | "OFDM WS-DET OFF", ah->stats.ast_ani_ofdmoff); |
| 165 | len += scnprintf(buf + len, size - len, "%15s: %u\n", |
| 166 | "MRC-CCK ON", ah->stats.ast_ani_ccklow); |
| 167 | len += scnprintf(buf + len, size - len, "%15s: %u\n", |
| 168 | "MRC-CCK OFF", ah->stats.ast_ani_cckhigh); |
| 169 | len += scnprintf(buf + len, size - len, "%15s: %u\n", |
| 170 | "FIR-STEP UP", ah->stats.ast_ani_stepup); |
| 171 | len += scnprintf(buf + len, size - len, "%15s: %u\n", |
| 172 | "FIR-STEP DOWN", ah->stats.ast_ani_stepdown); |
| 173 | len += scnprintf(buf + len, size - len, "%15s: %u\n", |
| 174 | "INV LISTENTIME", ah->stats.ast_ani_lneg_or_lzero); |
| 175 | len += scnprintf(buf + len, size - len, "%15s: %u\n", |
| 176 | "OFDM ERRORS", ah->stats.ast_ani_ofdmerrs); |
| 177 | len += scnprintf(buf + len, size - len, "%15s: %u\n", |
| 178 | "CCK ERRORS", ah->stats.ast_ani_cckerrs); |
Sujith Manoharan | 6e4d291 | 2013-06-03 09:19:28 +0530 | [diff] [blame] | 179 | exit: |
| 180 | if (len > size) |
| 181 | len = size; |
| 182 | |
| 183 | retval = simple_read_from_buffer(user_buf, count, ppos, buf, len); |
| 184 | kfree(buf); |
| 185 | |
| 186 | return retval; |
Mohammed Shafi Shajakhan | 05c0be2 | 2011-05-26 10:56:15 +0530 | [diff] [blame] | 187 | } |
| 188 | |
Sujith Manoharan | 6e4d291 | 2013-06-03 09:19:28 +0530 | [diff] [blame] | 189 | static ssize_t write_file_ani(struct file *file, |
| 190 | const char __user *user_buf, |
| 191 | size_t count, loff_t *ppos) |
Mohammed Shafi Shajakhan | 05c0be2 | 2011-05-26 10:56:15 +0530 | [diff] [blame] | 192 | { |
| 193 | struct ath_softc *sc = file->private_data; |
| 194 | struct ath_common *common = ath9k_hw_common(sc->sc_ah); |
Sujith Manoharan | 6e4d291 | 2013-06-03 09:19:28 +0530 | [diff] [blame] | 195 | unsigned long ani; |
Mohammed Shafi Shajakhan | 05c0be2 | 2011-05-26 10:56:15 +0530 | [diff] [blame] | 196 | char buf[32]; |
| 197 | ssize_t len; |
| 198 | |
| 199 | len = min(count, sizeof(buf) - 1); |
| 200 | if (copy_from_user(buf, user_buf, len)) |
| 201 | return -EFAULT; |
| 202 | |
| 203 | buf[len] = '\0'; |
John W. Linville | 3899ba9 | 2013-06-11 14:48:32 -0400 | [diff] [blame] | 204 | if (kstrtoul(buf, 0, &ani)) |
Mohammed Shafi Shajakhan | 05c0be2 | 2011-05-26 10:56:15 +0530 | [diff] [blame] | 205 | return -EINVAL; |
| 206 | |
Sujith Manoharan | 6e4d291 | 2013-06-03 09:19:28 +0530 | [diff] [blame] | 207 | if (ani < 0 || ani > 1) |
| 208 | return -EINVAL; |
Mohammed Shafi Shajakhan | 05c0be2 | 2011-05-26 10:56:15 +0530 | [diff] [blame] | 209 | |
Sujith Manoharan | 6e4d291 | 2013-06-03 09:19:28 +0530 | [diff] [blame] | 210 | common->disable_ani = !ani; |
| 211 | |
| 212 | if (common->disable_ani) { |
Sujith Manoharan | 781b14a | 2012-06-04 20:23:55 +0530 | [diff] [blame] | 213 | clear_bit(SC_OP_ANI_RUN, &sc->sc_flags); |
Sujith Manoharan | da0d45f | 2012-07-17 17:16:29 +0530 | [diff] [blame] | 214 | ath_stop_ani(sc); |
Mohammed Shafi Shajakhan | 05c0be2 | 2011-05-26 10:56:15 +0530 | [diff] [blame] | 215 | } else { |
Sujith Manoharan | da0d45f | 2012-07-17 17:16:29 +0530 | [diff] [blame] | 216 | ath_check_ani(sc); |
Mohammed Shafi Shajakhan | 05c0be2 | 2011-05-26 10:56:15 +0530 | [diff] [blame] | 217 | } |
| 218 | |
| 219 | return count; |
| 220 | } |
| 221 | |
Sujith Manoharan | 6e4d291 | 2013-06-03 09:19:28 +0530 | [diff] [blame] | 222 | static const struct file_operations fops_ani = { |
| 223 | .read = read_file_ani, |
| 224 | .write = write_file_ani, |
Stephen Boyd | 234e340 | 2012-04-05 14:25:11 -0700 | [diff] [blame] | 225 | .open = simple_open, |
Mohammed Shafi Shajakhan | 05c0be2 | 2011-05-26 10:56:15 +0530 | [diff] [blame] | 226 | .owner = THIS_MODULE, |
| 227 | .llseek = default_llseek, |
| 228 | }; |
Felix Fietkau | 1534069 | 2010-05-11 17:23:01 +0200 | [diff] [blame] | 229 | |
Sujith Manoharan | 36e8825 | 2013-08-06 12:44:15 +0530 | [diff] [blame] | 230 | #ifdef CONFIG_ATH9K_BTCOEX_SUPPORT |
| 231 | |
Sujith Manoharan | 6308130 | 2013-08-04 14:21:55 +0530 | [diff] [blame] | 232 | static ssize_t read_file_bt_ant_diversity(struct file *file, |
| 233 | char __user *user_buf, |
| 234 | size_t count, loff_t *ppos) |
Sujith Manoharan | 302a3c3 | 2012-09-26 07:55:18 +0530 | [diff] [blame] | 235 | { |
| 236 | struct ath_softc *sc = file->private_data; |
| 237 | struct ath_common *common = ath9k_hw_common(sc->sc_ah); |
| 238 | char buf[32]; |
| 239 | unsigned int len; |
| 240 | |
Sujith Manoharan | 6308130 | 2013-08-04 14:21:55 +0530 | [diff] [blame] | 241 | len = sprintf(buf, "%d\n", common->bt_ant_diversity); |
Sujith Manoharan | 302a3c3 | 2012-09-26 07:55:18 +0530 | [diff] [blame] | 242 | return simple_read_from_buffer(user_buf, count, ppos, buf, len); |
| 243 | } |
| 244 | |
Sujith Manoharan | 6308130 | 2013-08-04 14:21:55 +0530 | [diff] [blame] | 245 | static ssize_t write_file_bt_ant_diversity(struct file *file, |
| 246 | const char __user *user_buf, |
| 247 | size_t count, loff_t *ppos) |
Sujith Manoharan | 302a3c3 | 2012-09-26 07:55:18 +0530 | [diff] [blame] | 248 | { |
| 249 | struct ath_softc *sc = file->private_data; |
| 250 | struct ath_common *common = ath9k_hw_common(sc->sc_ah); |
Sujith Manoharan | 3f2da95 | 2013-08-04 14:21:56 +0530 | [diff] [blame] | 251 | struct ath9k_hw_capabilities *pCap = &sc->sc_ah->caps; |
Sujith Manoharan | 6308130 | 2013-08-04 14:21:55 +0530 | [diff] [blame] | 252 | unsigned long bt_ant_diversity; |
Sujith Manoharan | 302a3c3 | 2012-09-26 07:55:18 +0530 | [diff] [blame] | 253 | char buf[32]; |
| 254 | ssize_t len; |
| 255 | |
| 256 | len = min(count, sizeof(buf) - 1); |
| 257 | if (copy_from_user(buf, user_buf, len)) |
| 258 | return -EFAULT; |
| 259 | |
Sujith Manoharan | 3f2da95 | 2013-08-04 14:21:56 +0530 | [diff] [blame] | 260 | if (!(pCap->hw_caps & ATH9K_HW_CAP_BT_ANT_DIV)) |
| 261 | goto exit; |
| 262 | |
Sujith Manoharan | 302a3c3 | 2012-09-26 07:55:18 +0530 | [diff] [blame] | 263 | buf[len] = '\0'; |
Sujith Manoharan | 6308130 | 2013-08-04 14:21:55 +0530 | [diff] [blame] | 264 | if (kstrtoul(buf, 0, &bt_ant_diversity)) |
Sujith Manoharan | 302a3c3 | 2012-09-26 07:55:18 +0530 | [diff] [blame] | 265 | return -EINVAL; |
| 266 | |
Sujith Manoharan | 6308130 | 2013-08-04 14:21:55 +0530 | [diff] [blame] | 267 | common->bt_ant_diversity = !!bt_ant_diversity; |
Sujith Manoharan | 302a3c3 | 2012-09-26 07:55:18 +0530 | [diff] [blame] | 268 | ath9k_ps_wakeup(sc); |
Sujith Manoharan | 047dc3a | 2013-08-05 15:08:26 +0530 | [diff] [blame] | 269 | ath9k_hw_set_bt_ant_diversity(sc->sc_ah, common->bt_ant_diversity); |
Sujith Manoharan | 6308130 | 2013-08-04 14:21:55 +0530 | [diff] [blame] | 270 | ath_dbg(common, CONFIG, "Enable WLAN/BT RX Antenna diversity: %d\n", |
| 271 | common->bt_ant_diversity); |
Sujith Manoharan | 302a3c3 | 2012-09-26 07:55:18 +0530 | [diff] [blame] | 272 | ath9k_ps_restore(sc); |
Sujith Manoharan | 3f2da95 | 2013-08-04 14:21:56 +0530 | [diff] [blame] | 273 | exit: |
Sujith Manoharan | 302a3c3 | 2012-09-26 07:55:18 +0530 | [diff] [blame] | 274 | return count; |
| 275 | } |
| 276 | |
Sujith Manoharan | 6308130 | 2013-08-04 14:21:55 +0530 | [diff] [blame] | 277 | static const struct file_operations fops_bt_ant_diversity = { |
| 278 | .read = read_file_bt_ant_diversity, |
| 279 | .write = write_file_bt_ant_diversity, |
Sujith Manoharan | 302a3c3 | 2012-09-26 07:55:18 +0530 | [diff] [blame] | 280 | .open = simple_open, |
| 281 | .owner = THIS_MODULE, |
| 282 | .llseek = default_llseek, |
| 283 | }; |
| 284 | |
Sujith Manoharan | 36e8825 | 2013-08-06 12:44:15 +0530 | [diff] [blame] | 285 | #endif |
| 286 | |
Sujith Manoharan | e3d5291 | 2013-08-01 20:57:06 +0530 | [diff] [blame] | 287 | void ath9k_debug_stat_ant(struct ath_softc *sc, |
| 288 | struct ath_hw_antcomb_conf *div_ant_conf, |
| 289 | int main_rssi_avg, int alt_rssi_avg) |
| 290 | { |
| 291 | struct ath_antenna_stats *as_main = &sc->debug.stats.ant_stats[ANT_MAIN]; |
| 292 | struct ath_antenna_stats *as_alt = &sc->debug.stats.ant_stats[ANT_ALT]; |
| 293 | |
| 294 | as_main->lna_attempt_cnt[div_ant_conf->main_lna_conf]++; |
| 295 | as_alt->lna_attempt_cnt[div_ant_conf->alt_lna_conf]++; |
| 296 | |
| 297 | as_main->rssi_avg = main_rssi_avg; |
| 298 | as_alt->rssi_avg = alt_rssi_avg; |
| 299 | } |
| 300 | |
Sujith Manoharan | 4eba10c | 2013-07-29 16:04:49 +0530 | [diff] [blame] | 301 | static ssize_t read_file_antenna_diversity(struct file *file, |
| 302 | char __user *user_buf, |
| 303 | size_t count, loff_t *ppos) |
| 304 | { |
| 305 | struct ath_softc *sc = file->private_data; |
| 306 | struct ath_hw *ah = sc->sc_ah; |
| 307 | struct ath9k_hw_capabilities *pCap = &ah->caps; |
| 308 | struct ath_antenna_stats *as_main = &sc->debug.stats.ant_stats[ANT_MAIN]; |
| 309 | struct ath_antenna_stats *as_alt = &sc->debug.stats.ant_stats[ANT_ALT]; |
Sujith Manoharan | e3d5291 | 2013-08-01 20:57:06 +0530 | [diff] [blame] | 310 | struct ath_hw_antcomb_conf div_ant_conf; |
Joe Perches | 2120ac9 | 2014-02-21 14:46:43 -0800 | [diff] [blame] | 311 | unsigned int len = 0; |
| 312 | const unsigned int size = 1024; |
Sujith Manoharan | 4eba10c | 2013-07-29 16:04:49 +0530 | [diff] [blame] | 313 | ssize_t retval = 0; |
| 314 | char *buf; |
Joe Perches | 2120ac9 | 2014-02-21 14:46:43 -0800 | [diff] [blame] | 315 | static const char *lna_conf_str[4] = { |
| 316 | "LNA1_MINUS_LNA2", "LNA2", "LNA1", "LNA1_PLUS_LNA2" |
| 317 | }; |
Sujith Manoharan | 4eba10c | 2013-07-29 16:04:49 +0530 | [diff] [blame] | 318 | |
| 319 | buf = kzalloc(size, GFP_KERNEL); |
| 320 | if (buf == NULL) |
| 321 | return -ENOMEM; |
| 322 | |
| 323 | if (!(pCap->hw_caps & ATH9K_HW_CAP_ANT_DIV_COMB)) { |
Zefir Kurtisi | 5e88ba6 | 2013-09-05 14:11:57 +0200 | [diff] [blame] | 324 | len += scnprintf(buf + len, size - len, "%s\n", |
| 325 | "Antenna Diversity Combining is disabled"); |
Sujith Manoharan | 4eba10c | 2013-07-29 16:04:49 +0530 | [diff] [blame] | 326 | goto exit; |
| 327 | } |
| 328 | |
Sujith Manoharan | e3d5291 | 2013-08-01 20:57:06 +0530 | [diff] [blame] | 329 | ath9k_ps_wakeup(sc); |
| 330 | ath9k_hw_antdiv_comb_conf_get(ah, &div_ant_conf); |
Zefir Kurtisi | 5e88ba6 | 2013-09-05 14:11:57 +0200 | [diff] [blame] | 331 | len += scnprintf(buf + len, size - len, "Current MAIN config : %s\n", |
| 332 | lna_conf_str[div_ant_conf.main_lna_conf]); |
| 333 | len += scnprintf(buf + len, size - len, "Current ALT config : %s\n", |
| 334 | lna_conf_str[div_ant_conf.alt_lna_conf]); |
| 335 | len += scnprintf(buf + len, size - len, "Average MAIN RSSI : %d\n", |
| 336 | as_main->rssi_avg); |
| 337 | len += scnprintf(buf + len, size - len, "Average ALT RSSI : %d\n\n", |
| 338 | as_alt->rssi_avg); |
Sujith Manoharan | e3d5291 | 2013-08-01 20:57:06 +0530 | [diff] [blame] | 339 | ath9k_ps_restore(sc); |
| 340 | |
Zefir Kurtisi | 5e88ba6 | 2013-09-05 14:11:57 +0200 | [diff] [blame] | 341 | len += scnprintf(buf + len, size - len, "Packet Receive Cnt:\n"); |
| 342 | len += scnprintf(buf + len, size - len, "-------------------\n"); |
Sujith Manoharan | e3d5291 | 2013-08-01 20:57:06 +0530 | [diff] [blame] | 343 | |
Zefir Kurtisi | 5e88ba6 | 2013-09-05 14:11:57 +0200 | [diff] [blame] | 344 | len += scnprintf(buf + len, size - len, "%30s%15s\n", |
| 345 | "MAIN", "ALT"); |
| 346 | len += scnprintf(buf + len, size - len, "%-14s:%15d%15d\n", |
| 347 | "TOTAL COUNT", |
| 348 | as_main->recv_cnt, |
| 349 | as_alt->recv_cnt); |
| 350 | len += scnprintf(buf + len, size - len, "%-14s:%15d%15d\n", |
| 351 | "LNA1", |
| 352 | as_main->lna_recv_cnt[ATH_ANT_DIV_COMB_LNA1], |
| 353 | as_alt->lna_recv_cnt[ATH_ANT_DIV_COMB_LNA1]); |
| 354 | len += scnprintf(buf + len, size - len, "%-14s:%15d%15d\n", |
| 355 | "LNA2", |
| 356 | as_main->lna_recv_cnt[ATH_ANT_DIV_COMB_LNA2], |
| 357 | as_alt->lna_recv_cnt[ATH_ANT_DIV_COMB_LNA2]); |
| 358 | len += scnprintf(buf + len, size - len, "%-14s:%15d%15d\n", |
| 359 | "LNA1 + LNA2", |
| 360 | as_main->lna_recv_cnt[ATH_ANT_DIV_COMB_LNA1_PLUS_LNA2], |
| 361 | as_alt->lna_recv_cnt[ATH_ANT_DIV_COMB_LNA1_PLUS_LNA2]); |
| 362 | len += scnprintf(buf + len, size - len, "%-14s:%15d%15d\n", |
| 363 | "LNA1 - LNA2", |
| 364 | as_main->lna_recv_cnt[ATH_ANT_DIV_COMB_LNA1_MINUS_LNA2], |
| 365 | as_alt->lna_recv_cnt[ATH_ANT_DIV_COMB_LNA1_MINUS_LNA2]); |
Sujith Manoharan | e3d5291 | 2013-08-01 20:57:06 +0530 | [diff] [blame] | 366 | |
Zefir Kurtisi | 5e88ba6 | 2013-09-05 14:11:57 +0200 | [diff] [blame] | 367 | len += scnprintf(buf + len, size - len, "\nLNA Config Attempts:\n"); |
| 368 | len += scnprintf(buf + len, size - len, "--------------------\n"); |
Sujith Manoharan | e3d5291 | 2013-08-01 20:57:06 +0530 | [diff] [blame] | 369 | |
Zefir Kurtisi | 5e88ba6 | 2013-09-05 14:11:57 +0200 | [diff] [blame] | 370 | len += scnprintf(buf + len, size - len, "%30s%15s\n", |
| 371 | "MAIN", "ALT"); |
| 372 | len += scnprintf(buf + len, size - len, "%-14s:%15d%15d\n", |
| 373 | "LNA1", |
| 374 | as_main->lna_attempt_cnt[ATH_ANT_DIV_COMB_LNA1], |
| 375 | as_alt->lna_attempt_cnt[ATH_ANT_DIV_COMB_LNA1]); |
| 376 | len += scnprintf(buf + len, size - len, "%-14s:%15d%15d\n", |
| 377 | "LNA2", |
| 378 | as_main->lna_attempt_cnt[ATH_ANT_DIV_COMB_LNA2], |
| 379 | as_alt->lna_attempt_cnt[ATH_ANT_DIV_COMB_LNA2]); |
| 380 | len += scnprintf(buf + len, size - len, "%-14s:%15d%15d\n", |
| 381 | "LNA1 + LNA2", |
| 382 | as_main->lna_attempt_cnt[ATH_ANT_DIV_COMB_LNA1_PLUS_LNA2], |
| 383 | as_alt->lna_attempt_cnt[ATH_ANT_DIV_COMB_LNA1_PLUS_LNA2]); |
| 384 | len += scnprintf(buf + len, size - len, "%-14s:%15d%15d\n", |
| 385 | "LNA1 - LNA2", |
| 386 | as_main->lna_attempt_cnt[ATH_ANT_DIV_COMB_LNA1_MINUS_LNA2], |
| 387 | as_alt->lna_attempt_cnt[ATH_ANT_DIV_COMB_LNA1_MINUS_LNA2]); |
Sujith Manoharan | e3d5291 | 2013-08-01 20:57:06 +0530 | [diff] [blame] | 388 | |
Sujith Manoharan | 4eba10c | 2013-07-29 16:04:49 +0530 | [diff] [blame] | 389 | exit: |
| 390 | if (len > size) |
| 391 | len = size; |
| 392 | |
| 393 | retval = simple_read_from_buffer(user_buf, count, ppos, buf, len); |
| 394 | kfree(buf); |
| 395 | |
| 396 | return retval; |
| 397 | } |
| 398 | |
| 399 | static const struct file_operations fops_antenna_diversity = { |
| 400 | .read = read_file_antenna_diversity, |
| 401 | .open = simple_open, |
| 402 | .owner = THIS_MODULE, |
| 403 | .llseek = default_llseek, |
| 404 | }; |
| 405 | |
Sujith | 2a163c6 | 2008-11-28 22:21:08 +0530 | [diff] [blame] | 406 | static ssize_t read_file_dma(struct file *file, char __user *user_buf, |
| 407 | size_t count, loff_t *ppos) |
| 408 | { |
| 409 | struct ath_softc *sc = file->private_data; |
Sujith | cbe61d8 | 2009-02-09 13:27:12 +0530 | [diff] [blame] | 410 | struct ath_hw *ah = sc->sc_ah; |
Pavel Roskin | 991a098 | 2010-01-29 17:22:26 -0500 | [diff] [blame] | 411 | char *buf; |
| 412 | int retval; |
Sujith | 2a163c6 | 2008-11-28 22:21:08 +0530 | [diff] [blame] | 413 | unsigned int len = 0; |
| 414 | u32 val[ATH9K_NUM_DMA_DEBUG_REGS]; |
| 415 | int i, qcuOffset = 0, dcuOffset = 0; |
| 416 | u32 *qcuBase = &val[0], *dcuBase = &val[4]; |
| 417 | |
Pavel Roskin | 991a098 | 2010-01-29 17:22:26 -0500 | [diff] [blame] | 418 | buf = kmalloc(DMA_BUF_LEN, GFP_KERNEL); |
| 419 | if (!buf) |
Dan Carpenter | 0423606 | 2010-05-14 15:25:39 +0200 | [diff] [blame] | 420 | return -ENOMEM; |
Pavel Roskin | 991a098 | 2010-01-29 17:22:26 -0500 | [diff] [blame] | 421 | |
Sujith | 7cf4a2e | 2009-08-26 11:11:57 +0530 | [diff] [blame] | 422 | ath9k_ps_wakeup(sc); |
| 423 | |
Luis R. Rodriguez | 475a6e4 | 2009-09-23 23:06:59 -0400 | [diff] [blame] | 424 | REG_WRITE_D(ah, AR_MACMISC, |
Sujith | 2a163c6 | 2008-11-28 22:21:08 +0530 | [diff] [blame] | 425 | ((AR_MACMISC_DMA_OBS_LINE_8 << AR_MACMISC_DMA_OBS_S) | |
| 426 | (AR_MACMISC_MISC_OBS_BUS_1 << |
| 427 | AR_MACMISC_MISC_OBS_BUS_MSB_S))); |
| 428 | |
Zefir Kurtisi | 5e88ba6 | 2013-09-05 14:11:57 +0200 | [diff] [blame] | 429 | len += scnprintf(buf + len, DMA_BUF_LEN - len, |
| 430 | "Raw DMA Debug values:\n"); |
Sujith | 2a163c6 | 2008-11-28 22:21:08 +0530 | [diff] [blame] | 431 | |
| 432 | for (i = 0; i < ATH9K_NUM_DMA_DEBUG_REGS; i++) { |
| 433 | if (i % 4 == 0) |
Zefir Kurtisi | 5e88ba6 | 2013-09-05 14:11:57 +0200 | [diff] [blame] | 434 | len += scnprintf(buf + len, DMA_BUF_LEN - len, "\n"); |
Sujith | 2a163c6 | 2008-11-28 22:21:08 +0530 | [diff] [blame] | 435 | |
Luis R. Rodriguez | 475a6e4 | 2009-09-23 23:06:59 -0400 | [diff] [blame] | 436 | val[i] = REG_READ_D(ah, AR_DMADBG_0 + (i * sizeof(u32))); |
Zefir Kurtisi | 5e88ba6 | 2013-09-05 14:11:57 +0200 | [diff] [blame] | 437 | len += scnprintf(buf + len, DMA_BUF_LEN - len, "%d: %08x ", |
| 438 | i, val[i]); |
Sujith | 2a163c6 | 2008-11-28 22:21:08 +0530 | [diff] [blame] | 439 | } |
| 440 | |
Zefir Kurtisi | 5e88ba6 | 2013-09-05 14:11:57 +0200 | [diff] [blame] | 441 | len += scnprintf(buf + len, DMA_BUF_LEN - len, "\n\n"); |
| 442 | len += scnprintf(buf + len, DMA_BUF_LEN - len, |
| 443 | "Num QCU: chain_st fsp_ok fsp_st DCU: chain_st\n"); |
Sujith | 2a163c6 | 2008-11-28 22:21:08 +0530 | [diff] [blame] | 444 | |
| 445 | for (i = 0; i < ATH9K_NUM_QUEUES; i++, qcuOffset += 4, dcuOffset += 5) { |
| 446 | if (i == 8) { |
| 447 | qcuOffset = 0; |
| 448 | qcuBase++; |
| 449 | } |
| 450 | |
| 451 | if (i == 6) { |
| 452 | dcuOffset = 0; |
| 453 | dcuBase++; |
| 454 | } |
| 455 | |
Zefir Kurtisi | 5e88ba6 | 2013-09-05 14:11:57 +0200 | [diff] [blame] | 456 | len += scnprintf(buf + len, DMA_BUF_LEN - len, |
| 457 | "%2d %2x %1x %2x %2x\n", |
| 458 | i, (*qcuBase & (0x7 << qcuOffset)) >> qcuOffset, |
| 459 | (*qcuBase & (0x8 << qcuOffset)) >> (qcuOffset + 3), |
| 460 | val[2] & (0x7 << (i * 3)) >> (i * 3), |
| 461 | (*dcuBase & (0x1f << dcuOffset)) >> dcuOffset); |
Sujith | 2a163c6 | 2008-11-28 22:21:08 +0530 | [diff] [blame] | 462 | } |
| 463 | |
Zefir Kurtisi | 5e88ba6 | 2013-09-05 14:11:57 +0200 | [diff] [blame] | 464 | len += scnprintf(buf + len, DMA_BUF_LEN - len, "\n"); |
Sujith | 2a163c6 | 2008-11-28 22:21:08 +0530 | [diff] [blame] | 465 | |
Zefir Kurtisi | 5e88ba6 | 2013-09-05 14:11:57 +0200 | [diff] [blame] | 466 | len += scnprintf(buf + len, DMA_BUF_LEN - len, |
Sujith | 2a163c6 | 2008-11-28 22:21:08 +0530 | [diff] [blame] | 467 | "qcu_stitch state: %2x qcu_fetch state: %2x\n", |
| 468 | (val[3] & 0x003c0000) >> 18, (val[3] & 0x03c00000) >> 22); |
Zefir Kurtisi | 5e88ba6 | 2013-09-05 14:11:57 +0200 | [diff] [blame] | 469 | len += scnprintf(buf + len, DMA_BUF_LEN - len, |
Sujith | 2a163c6 | 2008-11-28 22:21:08 +0530 | [diff] [blame] | 470 | "qcu_complete state: %2x dcu_complete state: %2x\n", |
| 471 | (val[3] & 0x1c000000) >> 26, (val[6] & 0x3)); |
Zefir Kurtisi | 5e88ba6 | 2013-09-05 14:11:57 +0200 | [diff] [blame] | 472 | len += scnprintf(buf + len, DMA_BUF_LEN - len, |
Sujith | 2a163c6 | 2008-11-28 22:21:08 +0530 | [diff] [blame] | 473 | "dcu_arb state: %2x dcu_fp state: %2x\n", |
| 474 | (val[5] & 0x06000000) >> 25, (val[5] & 0x38000000) >> 27); |
Zefir Kurtisi | 5e88ba6 | 2013-09-05 14:11:57 +0200 | [diff] [blame] | 475 | len += scnprintf(buf + len, DMA_BUF_LEN - len, |
Sujith | 2a163c6 | 2008-11-28 22:21:08 +0530 | [diff] [blame] | 476 | "chan_idle_dur: %3d chan_idle_dur_valid: %1d\n", |
| 477 | (val[6] & 0x000003fc) >> 2, (val[6] & 0x00000400) >> 10); |
Zefir Kurtisi | 5e88ba6 | 2013-09-05 14:11:57 +0200 | [diff] [blame] | 478 | len += scnprintf(buf + len, DMA_BUF_LEN - len, |
Sujith | 2a163c6 | 2008-11-28 22:21:08 +0530 | [diff] [blame] | 479 | "txfifo_valid_0: %1d txfifo_valid_1: %1d\n", |
| 480 | (val[6] & 0x00000800) >> 11, (val[6] & 0x00001000) >> 12); |
Zefir Kurtisi | 5e88ba6 | 2013-09-05 14:11:57 +0200 | [diff] [blame] | 481 | len += scnprintf(buf + len, DMA_BUF_LEN - len, |
Sujith | 2a163c6 | 2008-11-28 22:21:08 +0530 | [diff] [blame] | 482 | "txfifo_dcu_num_0: %2d txfifo_dcu_num_1: %2d\n", |
| 483 | (val[6] & 0x0001e000) >> 13, (val[6] & 0x001e0000) >> 17); |
| 484 | |
Zefir Kurtisi | 5e88ba6 | 2013-09-05 14:11:57 +0200 | [diff] [blame] | 485 | len += scnprintf(buf + len, DMA_BUF_LEN - len, "pcu observe: 0x%x\n", |
| 486 | REG_READ_D(ah, AR_OBS_BUS_1)); |
| 487 | len += scnprintf(buf + len, DMA_BUF_LEN - len, |
| 488 | "AR_CR: 0x%x\n", REG_READ_D(ah, AR_CR)); |
Sujith | 2a163c6 | 2008-11-28 22:21:08 +0530 | [diff] [blame] | 489 | |
Sujith | 7cf4a2e | 2009-08-26 11:11:57 +0530 | [diff] [blame] | 490 | ath9k_ps_restore(sc); |
| 491 | |
Dan Carpenter | 2b87f3a | 2010-05-14 15:24:37 +0200 | [diff] [blame] | 492 | if (len > DMA_BUF_LEN) |
| 493 | len = DMA_BUF_LEN; |
| 494 | |
Pavel Roskin | 991a098 | 2010-01-29 17:22:26 -0500 | [diff] [blame] | 495 | retval = simple_read_from_buffer(user_buf, count, ppos, buf, len); |
| 496 | kfree(buf); |
| 497 | return retval; |
Sujith | 2a163c6 | 2008-11-28 22:21:08 +0530 | [diff] [blame] | 498 | } |
| 499 | |
| 500 | static const struct file_operations fops_dma = { |
| 501 | .read = read_file_dma, |
Stephen Boyd | 234e340 | 2012-04-05 14:25:11 -0700 | [diff] [blame] | 502 | .open = simple_open, |
Arnd Bergmann | 6038f37 | 2010-08-15 18:52:59 +0200 | [diff] [blame] | 503 | .owner = THIS_MODULE, |
| 504 | .llseek = default_llseek, |
Sujith | 2a163c6 | 2008-11-28 22:21:08 +0530 | [diff] [blame] | 505 | }; |
| 506 | |
Sujith | 817e11d | 2008-12-07 21:42:44 +0530 | [diff] [blame] | 507 | |
| 508 | void ath_debug_stat_interrupt(struct ath_softc *sc, enum ath9k_int status) |
| 509 | { |
| 510 | if (status) |
Sujith | 17d7904 | 2009-02-09 13:27:03 +0530 | [diff] [blame] | 511 | sc->debug.stats.istats.total++; |
Luis R. Rodriguez | a9616f4 | 2010-04-15 17:39:30 -0400 | [diff] [blame] | 512 | if (sc->sc_ah->caps.hw_caps & ATH9K_HW_CAP_EDMA) { |
| 513 | if (status & ATH9K_INT_RXLP) |
| 514 | sc->debug.stats.istats.rxlp++; |
| 515 | if (status & ATH9K_INT_RXHP) |
| 516 | sc->debug.stats.istats.rxhp++; |
Luis R. Rodriguez | 08578b8 | 2010-05-13 13:33:44 -0400 | [diff] [blame] | 517 | if (status & ATH9K_INT_BB_WATCHDOG) |
| 518 | sc->debug.stats.istats.bb_watchdog++; |
Luis R. Rodriguez | a9616f4 | 2010-04-15 17:39:30 -0400 | [diff] [blame] | 519 | } else { |
| 520 | if (status & ATH9K_INT_RX) |
| 521 | sc->debug.stats.istats.rxok++; |
| 522 | } |
Sujith | 817e11d | 2008-12-07 21:42:44 +0530 | [diff] [blame] | 523 | if (status & ATH9K_INT_RXEOL) |
Sujith | 17d7904 | 2009-02-09 13:27:03 +0530 | [diff] [blame] | 524 | sc->debug.stats.istats.rxeol++; |
Sujith | 817e11d | 2008-12-07 21:42:44 +0530 | [diff] [blame] | 525 | if (status & ATH9K_INT_RXORN) |
Sujith | 17d7904 | 2009-02-09 13:27:03 +0530 | [diff] [blame] | 526 | sc->debug.stats.istats.rxorn++; |
Sujith | 817e11d | 2008-12-07 21:42:44 +0530 | [diff] [blame] | 527 | if (status & ATH9K_INT_TX) |
Sujith | 17d7904 | 2009-02-09 13:27:03 +0530 | [diff] [blame] | 528 | sc->debug.stats.istats.txok++; |
Sujith | 817e11d | 2008-12-07 21:42:44 +0530 | [diff] [blame] | 529 | if (status & ATH9K_INT_TXURN) |
Sujith | 17d7904 | 2009-02-09 13:27:03 +0530 | [diff] [blame] | 530 | sc->debug.stats.istats.txurn++; |
Sujith | 817e11d | 2008-12-07 21:42:44 +0530 | [diff] [blame] | 531 | if (status & ATH9K_INT_RXPHY) |
Sujith | 17d7904 | 2009-02-09 13:27:03 +0530 | [diff] [blame] | 532 | sc->debug.stats.istats.rxphyerr++; |
Sujith | 817e11d | 2008-12-07 21:42:44 +0530 | [diff] [blame] | 533 | if (status & ATH9K_INT_RXKCM) |
Sujith | 17d7904 | 2009-02-09 13:27:03 +0530 | [diff] [blame] | 534 | sc->debug.stats.istats.rx_keycache_miss++; |
Sujith | 817e11d | 2008-12-07 21:42:44 +0530 | [diff] [blame] | 535 | if (status & ATH9K_INT_SWBA) |
Sujith | 17d7904 | 2009-02-09 13:27:03 +0530 | [diff] [blame] | 536 | sc->debug.stats.istats.swba++; |
Sujith | 817e11d | 2008-12-07 21:42:44 +0530 | [diff] [blame] | 537 | if (status & ATH9K_INT_BMISS) |
Sujith | 17d7904 | 2009-02-09 13:27:03 +0530 | [diff] [blame] | 538 | sc->debug.stats.istats.bmiss++; |
Sujith | 817e11d | 2008-12-07 21:42:44 +0530 | [diff] [blame] | 539 | if (status & ATH9K_INT_BNR) |
Sujith | 17d7904 | 2009-02-09 13:27:03 +0530 | [diff] [blame] | 540 | sc->debug.stats.istats.bnr++; |
Sujith | 817e11d | 2008-12-07 21:42:44 +0530 | [diff] [blame] | 541 | if (status & ATH9K_INT_CST) |
Sujith | 17d7904 | 2009-02-09 13:27:03 +0530 | [diff] [blame] | 542 | sc->debug.stats.istats.cst++; |
Sujith | 817e11d | 2008-12-07 21:42:44 +0530 | [diff] [blame] | 543 | if (status & ATH9K_INT_GTT) |
Sujith | 17d7904 | 2009-02-09 13:27:03 +0530 | [diff] [blame] | 544 | sc->debug.stats.istats.gtt++; |
Sujith | 817e11d | 2008-12-07 21:42:44 +0530 | [diff] [blame] | 545 | if (status & ATH9K_INT_TIM) |
Sujith | 17d7904 | 2009-02-09 13:27:03 +0530 | [diff] [blame] | 546 | sc->debug.stats.istats.tim++; |
Sujith | 817e11d | 2008-12-07 21:42:44 +0530 | [diff] [blame] | 547 | if (status & ATH9K_INT_CABEND) |
Sujith | 17d7904 | 2009-02-09 13:27:03 +0530 | [diff] [blame] | 548 | sc->debug.stats.istats.cabend++; |
Sujith | 817e11d | 2008-12-07 21:42:44 +0530 | [diff] [blame] | 549 | if (status & ATH9K_INT_DTIMSYNC) |
Sujith | 17d7904 | 2009-02-09 13:27:03 +0530 | [diff] [blame] | 550 | sc->debug.stats.istats.dtimsync++; |
Sujith | 817e11d | 2008-12-07 21:42:44 +0530 | [diff] [blame] | 551 | if (status & ATH9K_INT_DTIM) |
Sujith | 17d7904 | 2009-02-09 13:27:03 +0530 | [diff] [blame] | 552 | sc->debug.stats.istats.dtim++; |
Mohammed Shafi Shajakhan | 6dde1aa | 2011-04-22 17:27:01 +0530 | [diff] [blame] | 553 | if (status & ATH9K_INT_TSFOOR) |
| 554 | sc->debug.stats.istats.tsfoor++; |
Sujith Manoharan | 97ba515 | 2012-06-04 16:27:41 +0530 | [diff] [blame] | 555 | if (status & ATH9K_INT_MCI) |
| 556 | sc->debug.stats.istats.mci++; |
Mohammed Shafi Shajakhan | c9e6e98 | 2012-09-07 15:54:13 +0530 | [diff] [blame] | 557 | if (status & ATH9K_INT_GENTIMER) |
| 558 | sc->debug.stats.istats.gen_timer++; |
Sujith | 817e11d | 2008-12-07 21:42:44 +0530 | [diff] [blame] | 559 | } |
| 560 | |
| 561 | static ssize_t read_file_interrupt(struct file *file, char __user *user_buf, |
| 562 | size_t count, loff_t *ppos) |
| 563 | { |
| 564 | struct ath_softc *sc = file->private_data; |
Sujith | 817e11d | 2008-12-07 21:42:44 +0530 | [diff] [blame] | 565 | unsigned int len = 0; |
Ben Greear | 462e58f | 2012-04-12 10:04:00 -0700 | [diff] [blame] | 566 | int rv; |
| 567 | int mxlen = 4000; |
| 568 | char *buf = kmalloc(mxlen, GFP_KERNEL); |
| 569 | if (!buf) |
| 570 | return -ENOMEM; |
| 571 | |
| 572 | #define PR_IS(a, s) \ |
| 573 | do { \ |
Zefir Kurtisi | 5e88ba6 | 2013-09-05 14:11:57 +0200 | [diff] [blame] | 574 | len += scnprintf(buf + len, mxlen - len, \ |
| 575 | "%21s: %10u\n", a, \ |
| 576 | sc->debug.stats.istats.s); \ |
Ben Greear | 462e58f | 2012-04-12 10:04:00 -0700 | [diff] [blame] | 577 | } while (0) |
Sujith | 817e11d | 2008-12-07 21:42:44 +0530 | [diff] [blame] | 578 | |
Luis R. Rodriguez | a9616f4 | 2010-04-15 17:39:30 -0400 | [diff] [blame] | 579 | if (sc->sc_ah->caps.hw_caps & ATH9K_HW_CAP_EDMA) { |
Ben Greear | 462e58f | 2012-04-12 10:04:00 -0700 | [diff] [blame] | 580 | PR_IS("RXLP", rxlp); |
| 581 | PR_IS("RXHP", rxhp); |
| 582 | PR_IS("WATHDOG", bb_watchdog); |
Luis R. Rodriguez | a9616f4 | 2010-04-15 17:39:30 -0400 | [diff] [blame] | 583 | } else { |
Ben Greear | 462e58f | 2012-04-12 10:04:00 -0700 | [diff] [blame] | 584 | PR_IS("RX", rxok); |
Luis R. Rodriguez | a9616f4 | 2010-04-15 17:39:30 -0400 | [diff] [blame] | 585 | } |
Ben Greear | 462e58f | 2012-04-12 10:04:00 -0700 | [diff] [blame] | 586 | PR_IS("RXEOL", rxeol); |
| 587 | PR_IS("RXORN", rxorn); |
| 588 | PR_IS("TX", txok); |
| 589 | PR_IS("TXURN", txurn); |
| 590 | PR_IS("MIB", mib); |
| 591 | PR_IS("RXPHY", rxphyerr); |
| 592 | PR_IS("RXKCM", rx_keycache_miss); |
| 593 | PR_IS("SWBA", swba); |
| 594 | PR_IS("BMISS", bmiss); |
| 595 | PR_IS("BNR", bnr); |
| 596 | PR_IS("CST", cst); |
| 597 | PR_IS("GTT", gtt); |
| 598 | PR_IS("TIM", tim); |
| 599 | PR_IS("CABEND", cabend); |
| 600 | PR_IS("DTIMSYNC", dtimsync); |
| 601 | PR_IS("DTIM", dtim); |
| 602 | PR_IS("TSFOOR", tsfoor); |
Sujith Manoharan | 97ba515 | 2012-06-04 16:27:41 +0530 | [diff] [blame] | 603 | PR_IS("MCI", mci); |
Mohammed Shafi Shajakhan | c9e6e98 | 2012-09-07 15:54:13 +0530 | [diff] [blame] | 604 | PR_IS("GENTIMER", gen_timer); |
Ben Greear | 462e58f | 2012-04-12 10:04:00 -0700 | [diff] [blame] | 605 | PR_IS("TOTAL", total); |
Sujith | 817e11d | 2008-12-07 21:42:44 +0530 | [diff] [blame] | 606 | |
Zefir Kurtisi | 5e88ba6 | 2013-09-05 14:11:57 +0200 | [diff] [blame] | 607 | len += scnprintf(buf + len, mxlen - len, |
| 608 | "SYNC_CAUSE stats:\n"); |
Mohammed Shafi Shajakhan | 6dde1aa | 2011-04-22 17:27:01 +0530 | [diff] [blame] | 609 | |
Ben Greear | 462e58f | 2012-04-12 10:04:00 -0700 | [diff] [blame] | 610 | PR_IS("Sync-All", sync_cause_all); |
| 611 | PR_IS("RTC-IRQ", sync_rtc_irq); |
| 612 | PR_IS("MAC-IRQ", sync_mac_irq); |
| 613 | PR_IS("EEPROM-Illegal-Access", eeprom_illegal_access); |
| 614 | PR_IS("APB-Timeout", apb_timeout); |
| 615 | PR_IS("PCI-Mode-Conflict", pci_mode_conflict); |
| 616 | PR_IS("HOST1-Fatal", host1_fatal); |
| 617 | PR_IS("HOST1-Perr", host1_perr); |
| 618 | PR_IS("TRCV-FIFO-Perr", trcv_fifo_perr); |
| 619 | PR_IS("RADM-CPL-EP", radm_cpl_ep); |
| 620 | PR_IS("RADM-CPL-DLLP-Abort", radm_cpl_dllp_abort); |
| 621 | PR_IS("RADM-CPL-TLP-Abort", radm_cpl_tlp_abort); |
| 622 | PR_IS("RADM-CPL-ECRC-Err", radm_cpl_ecrc_err); |
| 623 | PR_IS("RADM-CPL-Timeout", radm_cpl_timeout); |
| 624 | PR_IS("Local-Bus-Timeout", local_timeout); |
| 625 | PR_IS("PM-Access", pm_access); |
| 626 | PR_IS("MAC-Awake", mac_awake); |
| 627 | PR_IS("MAC-Asleep", mac_asleep); |
| 628 | PR_IS("MAC-Sleep-Access", mac_sleep_access); |
Dan Carpenter | 2b87f3a | 2010-05-14 15:24:37 +0200 | [diff] [blame] | 629 | |
Ben Greear | 462e58f | 2012-04-12 10:04:00 -0700 | [diff] [blame] | 630 | if (len > mxlen) |
| 631 | len = mxlen; |
| 632 | |
| 633 | rv = simple_read_from_buffer(user_buf, count, ppos, buf, len); |
| 634 | kfree(buf); |
| 635 | return rv; |
Sujith | 817e11d | 2008-12-07 21:42:44 +0530 | [diff] [blame] | 636 | } |
| 637 | |
| 638 | static const struct file_operations fops_interrupt = { |
| 639 | .read = read_file_interrupt, |
Stephen Boyd | 234e340 | 2012-04-05 14:25:11 -0700 | [diff] [blame] | 640 | .open = simple_open, |
Arnd Bergmann | 6038f37 | 2010-08-15 18:52:59 +0200 | [diff] [blame] | 641 | .owner = THIS_MODULE, |
| 642 | .llseek = default_llseek, |
Sujith | 817e11d | 2008-12-07 21:42:44 +0530 | [diff] [blame] | 643 | }; |
| 644 | |
Sujith | fec247c | 2009-07-27 12:08:16 +0530 | [diff] [blame] | 645 | static ssize_t read_file_xmit(struct file *file, char __user *user_buf, |
| 646 | size_t count, loff_t *ppos) |
| 647 | { |
| 648 | struct ath_softc *sc = file->private_data; |
| 649 | char *buf; |
Sujith Manoharan | 78ef731 | 2012-11-21 18:13:11 +0530 | [diff] [blame] | 650 | unsigned int len = 0, size = 2048; |
Sujith | fec247c | 2009-07-27 12:08:16 +0530 | [diff] [blame] | 651 | ssize_t retval = 0; |
| 652 | |
| 653 | buf = kzalloc(size, GFP_KERNEL); |
| 654 | if (buf == NULL) |
Dan Carpenter | 0423606 | 2010-05-14 15:25:39 +0200 | [diff] [blame] | 655 | return -ENOMEM; |
Sujith | fec247c | 2009-07-27 12:08:16 +0530 | [diff] [blame] | 656 | |
Sujith Manoharan | 78ef731 | 2012-11-21 18:13:11 +0530 | [diff] [blame] | 657 | len += sprintf(buf, "%30s %10s%10s%10s\n\n", |
Ben Greear | 7f010c9 | 2011-01-09 23:11:49 -0800 | [diff] [blame] | 658 | "BE", "BK", "VI", "VO"); |
Sujith | fec247c | 2009-07-27 12:08:16 +0530 | [diff] [blame] | 659 | |
| 660 | PR("MPDUs Queued: ", queued); |
| 661 | PR("MPDUs Completed: ", completed); |
Felix Fietkau | 5a6f78a | 2011-05-31 21:21:41 +0200 | [diff] [blame] | 662 | PR("MPDUs XRetried: ", xretries); |
Sujith | fec247c | 2009-07-27 12:08:16 +0530 | [diff] [blame] | 663 | PR("Aggregates: ", a_aggr); |
Ben Greear | bda8add | 2011-01-09 23:11:48 -0800 | [diff] [blame] | 664 | PR("AMPDUs Queued HW:", a_queued_hw); |
| 665 | PR("AMPDUs Queued SW:", a_queued_sw); |
Sujith | fec247c | 2009-07-27 12:08:16 +0530 | [diff] [blame] | 666 | PR("AMPDUs Completed:", a_completed); |
| 667 | PR("AMPDUs Retried: ", a_retries); |
| 668 | PR("AMPDUs XRetried: ", a_xretries); |
Ben Greear | 4d90038 | 2013-03-04 15:31:16 -0800 | [diff] [blame] | 669 | PR("TXERR Filtered: ", txerr_filtered); |
Sujith | fec247c | 2009-07-27 12:08:16 +0530 | [diff] [blame] | 670 | PR("FIFO Underrun: ", fifo_underrun); |
| 671 | PR("TXOP Exceeded: ", xtxop); |
| 672 | PR("TXTIMER Expiry: ", timer_exp); |
| 673 | PR("DESC CFG Error: ", desc_cfg_err); |
| 674 | PR("DATA Underrun: ", data_underrun); |
| 675 | PR("DELIM Underrun: ", delim_underrun); |
Ben Greear | 99c15bf | 2010-10-01 12:26:30 -0700 | [diff] [blame] | 676 | PR("TX-Pkts-All: ", tx_pkts_all); |
| 677 | PR("TX-Bytes-All: ", tx_bytes_all); |
Sujith Manoharan | 78ef731 | 2012-11-21 18:13:11 +0530 | [diff] [blame] | 678 | PR("HW-put-tx-buf: ", puttxbuf); |
| 679 | PR("HW-tx-start: ", txstart); |
| 680 | PR("HW-tx-proc-desc: ", txprocdesc); |
Ben Greear | a5a0bca | 2012-04-03 09:16:55 -0700 | [diff] [blame] | 681 | PR("TX-Failed: ", txfailed); |
Sujith | fec247c | 2009-07-27 12:08:16 +0530 | [diff] [blame] | 682 | |
Ben Greear | 7f010c9 | 2011-01-09 23:11:49 -0800 | [diff] [blame] | 683 | if (len > size) |
| 684 | len = size; |
| 685 | |
| 686 | retval = simple_read_from_buffer(user_buf, count, ppos, buf, len); |
| 687 | kfree(buf); |
| 688 | |
| 689 | return retval; |
| 690 | } |
| 691 | |
Felix Fietkau | 18fcf1c | 2013-08-06 14:18:05 +0200 | [diff] [blame] | 692 | static ssize_t print_queue(struct ath_softc *sc, struct ath_txq *txq, |
| 693 | char *buf, ssize_t size) |
| 694 | { |
| 695 | ssize_t len = 0; |
| 696 | |
| 697 | ath_txq_lock(sc, txq); |
| 698 | |
Zefir Kurtisi | 5e88ba6 | 2013-09-05 14:11:57 +0200 | [diff] [blame] | 699 | len += scnprintf(buf + len, size - len, "%s: %d ", |
| 700 | "qnum", txq->axq_qnum); |
| 701 | len += scnprintf(buf + len, size - len, "%s: %2d ", |
| 702 | "qdepth", txq->axq_depth); |
| 703 | len += scnprintf(buf + len, size - len, "%s: %2d ", |
| 704 | "ampdu-depth", txq->axq_ampdu_depth); |
| 705 | len += scnprintf(buf + len, size - len, "%s: %3d ", |
| 706 | "pending", txq->pending_frames); |
| 707 | len += scnprintf(buf + len, size - len, "%s: %d\n", |
| 708 | "stopped", txq->stopped); |
Felix Fietkau | 18fcf1c | 2013-08-06 14:18:05 +0200 | [diff] [blame] | 709 | |
| 710 | ath_txq_unlock(sc, txq); |
| 711 | return len; |
| 712 | } |
| 713 | |
Sujith Manoharan | c0b7487 | 2012-11-21 18:13:12 +0530 | [diff] [blame] | 714 | static ssize_t read_file_queues(struct file *file, char __user *user_buf, |
| 715 | size_t count, loff_t *ppos) |
| 716 | { |
| 717 | struct ath_softc *sc = file->private_data; |
| 718 | struct ath_txq *txq; |
| 719 | char *buf; |
Joe Perches | 2120ac9 | 2014-02-21 14:46:43 -0800 | [diff] [blame] | 720 | unsigned int len = 0; |
| 721 | const unsigned int size = 1024; |
Sujith Manoharan | c0b7487 | 2012-11-21 18:13:12 +0530 | [diff] [blame] | 722 | ssize_t retval = 0; |
| 723 | int i; |
Joe Perches | 2120ac9 | 2014-02-21 14:46:43 -0800 | [diff] [blame] | 724 | static const char *qname[4] = { |
| 725 | "VO", "VI", "BE", "BK" |
| 726 | }; |
Sujith Manoharan | c0b7487 | 2012-11-21 18:13:12 +0530 | [diff] [blame] | 727 | |
| 728 | buf = kzalloc(size, GFP_KERNEL); |
| 729 | if (buf == NULL) |
| 730 | return -ENOMEM; |
| 731 | |
| 732 | for (i = 0; i < IEEE80211_NUM_ACS; i++) { |
| 733 | txq = sc->tx.txq_map[i]; |
Zefir Kurtisi | 5e88ba6 | 2013-09-05 14:11:57 +0200 | [diff] [blame] | 734 | len += scnprintf(buf + len, size - len, "(%s): ", qname[i]); |
Felix Fietkau | 18fcf1c | 2013-08-06 14:18:05 +0200 | [diff] [blame] | 735 | len += print_queue(sc, txq, buf + len, size - len); |
Sujith Manoharan | c0b7487 | 2012-11-21 18:13:12 +0530 | [diff] [blame] | 736 | } |
| 737 | |
Zefir Kurtisi | 5e88ba6 | 2013-09-05 14:11:57 +0200 | [diff] [blame] | 738 | len += scnprintf(buf + len, size - len, "(CAB): "); |
Felix Fietkau | 18fcf1c | 2013-08-06 14:18:05 +0200 | [diff] [blame] | 739 | len += print_queue(sc, sc->beacon.cabq, buf + len, size - len); |
| 740 | |
Sujith Manoharan | c0b7487 | 2012-11-21 18:13:12 +0530 | [diff] [blame] | 741 | if (len > size) |
| 742 | len = size; |
| 743 | |
| 744 | retval = simple_read_from_buffer(user_buf, count, ppos, buf, len); |
| 745 | kfree(buf); |
| 746 | |
| 747 | return retval; |
| 748 | } |
| 749 | |
Ben Greear | 55f6d0f | 2011-01-17 11:54:50 -0800 | [diff] [blame] | 750 | static ssize_t read_file_misc(struct file *file, char __user *user_buf, |
| 751 | size_t count, loff_t *ppos) |
| 752 | { |
| 753 | struct ath_softc *sc = file->private_data; |
| 754 | struct ath_common *common = ath9k_hw_common(sc->sc_ah); |
Ben Greear | 55f6d0f | 2011-01-17 11:54:50 -0800 | [diff] [blame] | 755 | struct ieee80211_hw *hw = sc->hw; |
Sujith Manoharan | 6bcf6f6 | 2012-02-16 11:51:02 +0530 | [diff] [blame] | 756 | struct ath9k_vif_iter_data iter_data; |
| 757 | char buf[512]; |
| 758 | unsigned int len = 0; |
Ben Greear | 55f6d0f | 2011-01-17 11:54:50 -0800 | [diff] [blame] | 759 | ssize_t retval = 0; |
Ben Greear | 55f6d0f | 2011-01-17 11:54:50 -0800 | [diff] [blame] | 760 | unsigned int reg; |
Sujith Manoharan | 6bcf6f6 | 2012-02-16 11:51:02 +0530 | [diff] [blame] | 761 | u32 rxfilter; |
Ben Greear | 55f6d0f | 2011-01-17 11:54:50 -0800 | [diff] [blame] | 762 | |
Zefir Kurtisi | 5e88ba6 | 2013-09-05 14:11:57 +0200 | [diff] [blame] | 763 | len += scnprintf(buf + len, sizeof(buf) - len, |
| 764 | "BSSID: %pM\n", common->curbssid); |
| 765 | len += scnprintf(buf + len, sizeof(buf) - len, |
| 766 | "BSSID-MASK: %pM\n", common->bssidmask); |
| 767 | len += scnprintf(buf + len, sizeof(buf) - len, |
| 768 | "OPMODE: %s\n", |
| 769 | ath_opmode_to_string(sc->sc_ah->opmode)); |
Ben Greear | 55f6d0f | 2011-01-17 11:54:50 -0800 | [diff] [blame] | 770 | |
Rajkumar Manoharan | 79d2b15 | 2011-05-16 18:23:23 +0530 | [diff] [blame] | 771 | ath9k_ps_wakeup(sc); |
Sujith Manoharan | 6bcf6f6 | 2012-02-16 11:51:02 +0530 | [diff] [blame] | 772 | rxfilter = ath9k_hw_getrxfilter(sc->sc_ah); |
Rajkumar Manoharan | 79d2b15 | 2011-05-16 18:23:23 +0530 | [diff] [blame] | 773 | ath9k_ps_restore(sc); |
Sujith Manoharan | 6bcf6f6 | 2012-02-16 11:51:02 +0530 | [diff] [blame] | 774 | |
Zefir Kurtisi | 5e88ba6 | 2013-09-05 14:11:57 +0200 | [diff] [blame] | 775 | len += scnprintf(buf + len, sizeof(buf) - len, |
| 776 | "RXFILTER: 0x%x", rxfilter); |
Sujith Manoharan | 6bcf6f6 | 2012-02-16 11:51:02 +0530 | [diff] [blame] | 777 | |
| 778 | if (rxfilter & ATH9K_RX_FILTER_UCAST) |
Zefir Kurtisi | 5e88ba6 | 2013-09-05 14:11:57 +0200 | [diff] [blame] | 779 | len += scnprintf(buf + len, sizeof(buf) - len, " UCAST"); |
Sujith Manoharan | 6bcf6f6 | 2012-02-16 11:51:02 +0530 | [diff] [blame] | 780 | if (rxfilter & ATH9K_RX_FILTER_MCAST) |
Zefir Kurtisi | 5e88ba6 | 2013-09-05 14:11:57 +0200 | [diff] [blame] | 781 | len += scnprintf(buf + len, sizeof(buf) - len, " MCAST"); |
Sujith Manoharan | 6bcf6f6 | 2012-02-16 11:51:02 +0530 | [diff] [blame] | 782 | if (rxfilter & ATH9K_RX_FILTER_BCAST) |
Zefir Kurtisi | 5e88ba6 | 2013-09-05 14:11:57 +0200 | [diff] [blame] | 783 | len += scnprintf(buf + len, sizeof(buf) - len, " BCAST"); |
Sujith Manoharan | 6bcf6f6 | 2012-02-16 11:51:02 +0530 | [diff] [blame] | 784 | if (rxfilter & ATH9K_RX_FILTER_CONTROL) |
Zefir Kurtisi | 5e88ba6 | 2013-09-05 14:11:57 +0200 | [diff] [blame] | 785 | len += scnprintf(buf + len, sizeof(buf) - len, " CONTROL"); |
Sujith Manoharan | 6bcf6f6 | 2012-02-16 11:51:02 +0530 | [diff] [blame] | 786 | if (rxfilter & ATH9K_RX_FILTER_BEACON) |
Zefir Kurtisi | 5e88ba6 | 2013-09-05 14:11:57 +0200 | [diff] [blame] | 787 | len += scnprintf(buf + len, sizeof(buf) - len, " BEACON"); |
Sujith Manoharan | 6bcf6f6 | 2012-02-16 11:51:02 +0530 | [diff] [blame] | 788 | if (rxfilter & ATH9K_RX_FILTER_PROM) |
Zefir Kurtisi | 5e88ba6 | 2013-09-05 14:11:57 +0200 | [diff] [blame] | 789 | len += scnprintf(buf + len, sizeof(buf) - len, " PROM"); |
Sujith Manoharan | 6bcf6f6 | 2012-02-16 11:51:02 +0530 | [diff] [blame] | 790 | if (rxfilter & ATH9K_RX_FILTER_PROBEREQ) |
Zefir Kurtisi | 5e88ba6 | 2013-09-05 14:11:57 +0200 | [diff] [blame] | 791 | len += scnprintf(buf + len, sizeof(buf) - len, " PROBEREQ"); |
Sujith Manoharan | 6bcf6f6 | 2012-02-16 11:51:02 +0530 | [diff] [blame] | 792 | if (rxfilter & ATH9K_RX_FILTER_PHYERR) |
Zefir Kurtisi | 5e88ba6 | 2013-09-05 14:11:57 +0200 | [diff] [blame] | 793 | len += scnprintf(buf + len, sizeof(buf) - len, " PHYERR"); |
Sujith Manoharan | 6bcf6f6 | 2012-02-16 11:51:02 +0530 | [diff] [blame] | 794 | if (rxfilter & ATH9K_RX_FILTER_MYBEACON) |
Zefir Kurtisi | 5e88ba6 | 2013-09-05 14:11:57 +0200 | [diff] [blame] | 795 | len += scnprintf(buf + len, sizeof(buf) - len, " MYBEACON"); |
Sujith Manoharan | 6bcf6f6 | 2012-02-16 11:51:02 +0530 | [diff] [blame] | 796 | if (rxfilter & ATH9K_RX_FILTER_COMP_BAR) |
Zefir Kurtisi | 5e88ba6 | 2013-09-05 14:11:57 +0200 | [diff] [blame] | 797 | len += scnprintf(buf + len, sizeof(buf) - len, " COMP_BAR"); |
Sujith Manoharan | 6bcf6f6 | 2012-02-16 11:51:02 +0530 | [diff] [blame] | 798 | if (rxfilter & ATH9K_RX_FILTER_PSPOLL) |
Zefir Kurtisi | 5e88ba6 | 2013-09-05 14:11:57 +0200 | [diff] [blame] | 799 | len += scnprintf(buf + len, sizeof(buf) - len, " PSPOLL"); |
Sujith Manoharan | 6bcf6f6 | 2012-02-16 11:51:02 +0530 | [diff] [blame] | 800 | if (rxfilter & ATH9K_RX_FILTER_PHYRADAR) |
Zefir Kurtisi | 5e88ba6 | 2013-09-05 14:11:57 +0200 | [diff] [blame] | 801 | len += scnprintf(buf + len, sizeof(buf) - len, " PHYRADAR"); |
Sujith Manoharan | 6bcf6f6 | 2012-02-16 11:51:02 +0530 | [diff] [blame] | 802 | if (rxfilter & ATH9K_RX_FILTER_MCAST_BCAST_ALL) |
Zefir Kurtisi | 5e88ba6 | 2013-09-05 14:11:57 +0200 | [diff] [blame] | 803 | len += scnprintf(buf + len, sizeof(buf) - len, " MCAST_BCAST_ALL"); |
Sujith Manoharan | 6bcf6f6 | 2012-02-16 11:51:02 +0530 | [diff] [blame] | 804 | if (rxfilter & ATH9K_RX_FILTER_CONTROL_WRAPPER) |
Zefir Kurtisi | 5e88ba6 | 2013-09-05 14:11:57 +0200 | [diff] [blame] | 805 | len += scnprintf(buf + len, sizeof(buf) - len, " CONTROL_WRAPPER"); |
Sujith Manoharan | 6bcf6f6 | 2012-02-16 11:51:02 +0530 | [diff] [blame] | 806 | |
Zefir Kurtisi | 5e88ba6 | 2013-09-05 14:11:57 +0200 | [diff] [blame] | 807 | len += scnprintf(buf + len, sizeof(buf) - len, "\n"); |
Ben Greear | 55f6d0f | 2011-01-17 11:54:50 -0800 | [diff] [blame] | 808 | |
| 809 | reg = sc->sc_ah->imask; |
Ben Greear | 55f6d0f | 2011-01-17 11:54:50 -0800 | [diff] [blame] | 810 | |
Zefir Kurtisi | 5e88ba6 | 2013-09-05 14:11:57 +0200 | [diff] [blame] | 811 | len += scnprintf(buf + len, sizeof(buf) - len, |
| 812 | "INTERRUPT-MASK: 0x%x", reg); |
Sujith Manoharan | 6bcf6f6 | 2012-02-16 11:51:02 +0530 | [diff] [blame] | 813 | |
| 814 | if (reg & ATH9K_INT_SWBA) |
Zefir Kurtisi | 5e88ba6 | 2013-09-05 14:11:57 +0200 | [diff] [blame] | 815 | len += scnprintf(buf + len, sizeof(buf) - len, " SWBA"); |
Sujith Manoharan | 6bcf6f6 | 2012-02-16 11:51:02 +0530 | [diff] [blame] | 816 | if (reg & ATH9K_INT_BMISS) |
Zefir Kurtisi | 5e88ba6 | 2013-09-05 14:11:57 +0200 | [diff] [blame] | 817 | len += scnprintf(buf + len, sizeof(buf) - len, " BMISS"); |
Sujith Manoharan | 6bcf6f6 | 2012-02-16 11:51:02 +0530 | [diff] [blame] | 818 | if (reg & ATH9K_INT_CST) |
Zefir Kurtisi | 5e88ba6 | 2013-09-05 14:11:57 +0200 | [diff] [blame] | 819 | len += scnprintf(buf + len, sizeof(buf) - len, " CST"); |
Sujith Manoharan | 6bcf6f6 | 2012-02-16 11:51:02 +0530 | [diff] [blame] | 820 | if (reg & ATH9K_INT_RX) |
Zefir Kurtisi | 5e88ba6 | 2013-09-05 14:11:57 +0200 | [diff] [blame] | 821 | len += scnprintf(buf + len, sizeof(buf) - len, " RX"); |
Sujith Manoharan | 6bcf6f6 | 2012-02-16 11:51:02 +0530 | [diff] [blame] | 822 | if (reg & ATH9K_INT_RXHP) |
Zefir Kurtisi | 5e88ba6 | 2013-09-05 14:11:57 +0200 | [diff] [blame] | 823 | len += scnprintf(buf + len, sizeof(buf) - len, " RXHP"); |
Sujith Manoharan | 6bcf6f6 | 2012-02-16 11:51:02 +0530 | [diff] [blame] | 824 | if (reg & ATH9K_INT_RXLP) |
Zefir Kurtisi | 5e88ba6 | 2013-09-05 14:11:57 +0200 | [diff] [blame] | 825 | len += scnprintf(buf + len, sizeof(buf) - len, " RXLP"); |
Sujith Manoharan | 6bcf6f6 | 2012-02-16 11:51:02 +0530 | [diff] [blame] | 826 | if (reg & ATH9K_INT_BB_WATCHDOG) |
Zefir Kurtisi | 5e88ba6 | 2013-09-05 14:11:57 +0200 | [diff] [blame] | 827 | len += scnprintf(buf + len, sizeof(buf) - len, " BB_WATCHDOG"); |
Sujith Manoharan | 6bcf6f6 | 2012-02-16 11:51:02 +0530 | [diff] [blame] | 828 | |
Zefir Kurtisi | 5e88ba6 | 2013-09-05 14:11:57 +0200 | [diff] [blame] | 829 | len += scnprintf(buf + len, sizeof(buf) - len, "\n"); |
Sujith Manoharan | 6bcf6f6 | 2012-02-16 11:51:02 +0530 | [diff] [blame] | 830 | |
| 831 | ath9k_calculate_iter_data(hw, NULL, &iter_data); |
| 832 | |
Zefir Kurtisi | 5e88ba6 | 2013-09-05 14:11:57 +0200 | [diff] [blame] | 833 | len += scnprintf(buf + len, sizeof(buf) - len, |
| 834 | "VIF-COUNTS: AP: %i STA: %i MESH: %i WDS: %i" |
| 835 | " ADHOC: %i TOTAL: %hi BEACON-VIF: %hi\n", |
| 836 | iter_data.naps, iter_data.nstations, iter_data.nmeshes, |
| 837 | iter_data.nwds, iter_data.nadhocs, |
| 838 | sc->nvifs, sc->nbcnvifs); |
Ben Greear | 55f6d0f | 2011-01-17 11:54:50 -0800 | [diff] [blame] | 839 | |
Sujith Manoharan | 6bcf6f6 | 2012-02-16 11:51:02 +0530 | [diff] [blame] | 840 | if (len > sizeof(buf)) |
| 841 | len = sizeof(buf); |
Ben Greear | 55f6d0f | 2011-01-17 11:54:50 -0800 | [diff] [blame] | 842 | |
| 843 | retval = simple_read_from_buffer(user_buf, count, ppos, buf, len); |
Ben Greear | 55f6d0f | 2011-01-17 11:54:50 -0800 | [diff] [blame] | 844 | return retval; |
| 845 | } |
| 846 | |
Sujith Manoharan | f8b815d | 2012-02-16 11:51:11 +0530 | [diff] [blame] | 847 | static ssize_t read_file_reset(struct file *file, char __user *user_buf, |
| 848 | size_t count, loff_t *ppos) |
| 849 | { |
| 850 | struct ath_softc *sc = file->private_data; |
| 851 | char buf[512]; |
| 852 | unsigned int len = 0; |
| 853 | |
Zefir Kurtisi | 5e88ba6 | 2013-09-05 14:11:57 +0200 | [diff] [blame] | 854 | len += scnprintf(buf + len, sizeof(buf) - len, |
| 855 | "%17s: %2d\n", "Baseband Hang", |
| 856 | sc->debug.stats.reset[RESET_TYPE_BB_HANG]); |
| 857 | len += scnprintf(buf + len, sizeof(buf) - len, |
| 858 | "%17s: %2d\n", "Baseband Watchdog", |
| 859 | sc->debug.stats.reset[RESET_TYPE_BB_WATCHDOG]); |
| 860 | len += scnprintf(buf + len, sizeof(buf) - len, |
| 861 | "%17s: %2d\n", "Fatal HW Error", |
| 862 | sc->debug.stats.reset[RESET_TYPE_FATAL_INT]); |
| 863 | len += scnprintf(buf + len, sizeof(buf) - len, |
| 864 | "%17s: %2d\n", "TX HW error", |
| 865 | sc->debug.stats.reset[RESET_TYPE_TX_ERROR]); |
| 866 | len += scnprintf(buf + len, sizeof(buf) - len, |
| 867 | "%17s: %2d\n", "TX Path Hang", |
| 868 | sc->debug.stats.reset[RESET_TYPE_TX_HANG]); |
| 869 | len += scnprintf(buf + len, sizeof(buf) - len, |
| 870 | "%17s: %2d\n", "PLL RX Hang", |
| 871 | sc->debug.stats.reset[RESET_TYPE_PLL_HANG]); |
| 872 | len += scnprintf(buf + len, sizeof(buf) - len, |
Felix Fietkau | 443626e5 | 2014-02-21 11:45:36 +0100 | [diff] [blame] | 873 | "%17s: %2d\n", "MAC Hang", |
| 874 | sc->debug.stats.reset[RESET_TYPE_MAC_HANG]); |
| 875 | len += scnprintf(buf + len, sizeof(buf) - len, |
| 876 | "%17s: %2d\n", "Stuck Beacon", |
| 877 | sc->debug.stats.reset[RESET_TYPE_BEACON_STUCK]); |
| 878 | len += scnprintf(buf + len, sizeof(buf) - len, |
Zefir Kurtisi | 5e88ba6 | 2013-09-05 14:11:57 +0200 | [diff] [blame] | 879 | "%17s: %2d\n", "MCI Reset", |
| 880 | sc->debug.stats.reset[RESET_TYPE_MCI]); |
Sujith Manoharan | f8b815d | 2012-02-16 11:51:11 +0530 | [diff] [blame] | 881 | |
| 882 | if (len > sizeof(buf)) |
| 883 | len = sizeof(buf); |
| 884 | |
| 885 | return simple_read_from_buffer(user_buf, count, ppos, buf, len); |
| 886 | } |
| 887 | |
Felix Fietkau | 066dae9 | 2010-11-07 14:59:39 +0100 | [diff] [blame] | 888 | void ath_debug_stat_tx(struct ath_softc *sc, struct ath_buf *bf, |
Felix Fietkau | 55797b1 | 2011-09-14 21:24:16 +0200 | [diff] [blame] | 889 | struct ath_tx_status *ts, struct ath_txq *txq, |
| 890 | unsigned int flags) |
Sujith | fec247c | 2009-07-27 12:08:16 +0530 | [diff] [blame] | 891 | { |
Felix Fietkau | 5bec3e5 | 2011-01-24 21:29:25 +0100 | [diff] [blame] | 892 | int qnum = txq->axq_qnum; |
Felix Fietkau | 066dae9 | 2010-11-07 14:59:39 +0100 | [diff] [blame] | 893 | |
| 894 | TX_STAT_INC(qnum, tx_pkts_all); |
| 895 | sc->debug.stats.txstats[qnum].tx_bytes_all += bf->bf_mpdu->len; |
Ben Greear | 99c15bf | 2010-10-01 12:26:30 -0700 | [diff] [blame] | 896 | |
Sujith | fec247c | 2009-07-27 12:08:16 +0530 | [diff] [blame] | 897 | if (bf_isampdu(bf)) { |
Felix Fietkau | 156369f | 2011-12-14 22:08:04 +0100 | [diff] [blame] | 898 | if (flags & ATH_TX_ERROR) |
Felix Fietkau | 066dae9 | 2010-11-07 14:59:39 +0100 | [diff] [blame] | 899 | TX_STAT_INC(qnum, a_xretries); |
Sujith | fec247c | 2009-07-27 12:08:16 +0530 | [diff] [blame] | 900 | else |
Felix Fietkau | 066dae9 | 2010-11-07 14:59:39 +0100 | [diff] [blame] | 901 | TX_STAT_INC(qnum, a_completed); |
Sujith | fec247c | 2009-07-27 12:08:16 +0530 | [diff] [blame] | 902 | } else { |
Felix Fietkau | 55797b1 | 2011-09-14 21:24:16 +0200 | [diff] [blame] | 903 | if (ts->ts_status & ATH9K_TXERR_XRETRY) |
Felix Fietkau | 5a6f78a | 2011-05-31 21:21:41 +0200 | [diff] [blame] | 904 | TX_STAT_INC(qnum, xretries); |
| 905 | else |
| 906 | TX_STAT_INC(qnum, completed); |
Sujith | fec247c | 2009-07-27 12:08:16 +0530 | [diff] [blame] | 907 | } |
| 908 | |
Ben Greear | 4d90038 | 2013-03-04 15:31:16 -0800 | [diff] [blame] | 909 | if (ts->ts_status & ATH9K_TXERR_FILT) |
| 910 | TX_STAT_INC(qnum, txerr_filtered); |
Felix Fietkau | db1a052 | 2010-03-29 20:07:11 -0700 | [diff] [blame] | 911 | if (ts->ts_status & ATH9K_TXERR_FIFO) |
Felix Fietkau | 066dae9 | 2010-11-07 14:59:39 +0100 | [diff] [blame] | 912 | TX_STAT_INC(qnum, fifo_underrun); |
Felix Fietkau | db1a052 | 2010-03-29 20:07:11 -0700 | [diff] [blame] | 913 | if (ts->ts_status & ATH9K_TXERR_XTXOP) |
Felix Fietkau | 066dae9 | 2010-11-07 14:59:39 +0100 | [diff] [blame] | 914 | TX_STAT_INC(qnum, xtxop); |
Felix Fietkau | db1a052 | 2010-03-29 20:07:11 -0700 | [diff] [blame] | 915 | if (ts->ts_status & ATH9K_TXERR_TIMER_EXPIRED) |
Felix Fietkau | 066dae9 | 2010-11-07 14:59:39 +0100 | [diff] [blame] | 916 | TX_STAT_INC(qnum, timer_exp); |
Felix Fietkau | db1a052 | 2010-03-29 20:07:11 -0700 | [diff] [blame] | 917 | if (ts->ts_flags & ATH9K_TX_DESC_CFG_ERR) |
Felix Fietkau | 066dae9 | 2010-11-07 14:59:39 +0100 | [diff] [blame] | 918 | TX_STAT_INC(qnum, desc_cfg_err); |
Felix Fietkau | db1a052 | 2010-03-29 20:07:11 -0700 | [diff] [blame] | 919 | if (ts->ts_flags & ATH9K_TX_DATA_UNDERRUN) |
Felix Fietkau | 066dae9 | 2010-11-07 14:59:39 +0100 | [diff] [blame] | 920 | TX_STAT_INC(qnum, data_underrun); |
Felix Fietkau | db1a052 | 2010-03-29 20:07:11 -0700 | [diff] [blame] | 921 | if (ts->ts_flags & ATH9K_TX_DELIM_UNDERRUN) |
Felix Fietkau | 066dae9 | 2010-11-07 14:59:39 +0100 | [diff] [blame] | 922 | TX_STAT_INC(qnum, delim_underrun); |
Sujith | fec247c | 2009-07-27 12:08:16 +0530 | [diff] [blame] | 923 | } |
| 924 | |
| 925 | static const struct file_operations fops_xmit = { |
| 926 | .read = read_file_xmit, |
Stephen Boyd | 234e340 | 2012-04-05 14:25:11 -0700 | [diff] [blame] | 927 | .open = simple_open, |
Arnd Bergmann | 6038f37 | 2010-08-15 18:52:59 +0200 | [diff] [blame] | 928 | .owner = THIS_MODULE, |
| 929 | .llseek = default_llseek, |
Sujith | fec247c | 2009-07-27 12:08:16 +0530 | [diff] [blame] | 930 | }; |
Jouni Malinen | 39d89cd | 2009-03-03 19:23:40 +0200 | [diff] [blame] | 931 | |
Sujith Manoharan | c0b7487 | 2012-11-21 18:13:12 +0530 | [diff] [blame] | 932 | static const struct file_operations fops_queues = { |
| 933 | .read = read_file_queues, |
| 934 | .open = simple_open, |
| 935 | .owner = THIS_MODULE, |
| 936 | .llseek = default_llseek, |
| 937 | }; |
| 938 | |
Ben Greear | 55f6d0f | 2011-01-17 11:54:50 -0800 | [diff] [blame] | 939 | static const struct file_operations fops_misc = { |
| 940 | .read = read_file_misc, |
Stephen Boyd | 234e340 | 2012-04-05 14:25:11 -0700 | [diff] [blame] | 941 | .open = simple_open, |
Ben Greear | 55f6d0f | 2011-01-17 11:54:50 -0800 | [diff] [blame] | 942 | .owner = THIS_MODULE, |
| 943 | .llseek = default_llseek, |
| 944 | }; |
| 945 | |
Sujith Manoharan | f8b815d | 2012-02-16 11:51:11 +0530 | [diff] [blame] | 946 | static const struct file_operations fops_reset = { |
| 947 | .read = read_file_reset, |
Stephen Boyd | 234e340 | 2012-04-05 14:25:11 -0700 | [diff] [blame] | 948 | .open = simple_open, |
Sujith Manoharan | f8b815d | 2012-02-16 11:51:11 +0530 | [diff] [blame] | 949 | .owner = THIS_MODULE, |
| 950 | .llseek = default_llseek, |
| 951 | }; |
| 952 | |
Sujith | 1395d3f | 2010-01-08 10:36:11 +0530 | [diff] [blame] | 953 | static ssize_t read_file_recv(struct file *file, char __user *user_buf, |
| 954 | size_t count, loff_t *ppos) |
| 955 | { |
Ben Greear | 24a0731 | 2012-04-12 10:03:59 -0700 | [diff] [blame] | 956 | #define RXS_ERR(s, e) \ |
| 957 | do { \ |
Zefir Kurtisi | 5e88ba6 | 2013-09-05 14:11:57 +0200 | [diff] [blame] | 958 | len += scnprintf(buf + len, size - len, \ |
Sujith Manoharan | c3b9f9e | 2014-01-13 07:29:29 +0530 | [diff] [blame] | 959 | "%18s : %10u\n", s, \ |
Zefir Kurtisi | 5e88ba6 | 2013-09-05 14:11:57 +0200 | [diff] [blame] | 960 | sc->debug.stats.rxstats.e);\ |
Ben Greear | 24a0731 | 2012-04-12 10:03:59 -0700 | [diff] [blame] | 961 | } while (0) |
| 962 | |
Sujith | 1395d3f | 2010-01-08 10:36:11 +0530 | [diff] [blame] | 963 | struct ath_softc *sc = file->private_data; |
| 964 | char *buf; |
Sujith Manoharan | 4203214 | 2012-02-16 11:51:23 +0530 | [diff] [blame] | 965 | unsigned int len = 0, size = 1600; |
Sujith | 1395d3f | 2010-01-08 10:36:11 +0530 | [diff] [blame] | 966 | ssize_t retval = 0; |
| 967 | |
| 968 | buf = kzalloc(size, GFP_KERNEL); |
| 969 | if (buf == NULL) |
Dan Carpenter | 0423606 | 2010-05-14 15:25:39 +0200 | [diff] [blame] | 970 | return -ENOMEM; |
Sujith | 1395d3f | 2010-01-08 10:36:11 +0530 | [diff] [blame] | 971 | |
Sujith Manoharan | c3b9f9e | 2014-01-13 07:29:29 +0530 | [diff] [blame] | 972 | RXS_ERR("PKTS-ALL", rx_pkts_all); |
| 973 | RXS_ERR("BYTES-ALL", rx_bytes_all); |
| 974 | RXS_ERR("BEACONS", rx_beacons); |
| 975 | RXS_ERR("FRAGS", rx_frags); |
| 976 | RXS_ERR("SPECTRAL", rx_spectral); |
| 977 | |
Ben Greear | 24a0731 | 2012-04-12 10:03:59 -0700 | [diff] [blame] | 978 | RXS_ERR("CRC ERR", crc_err); |
| 979 | RXS_ERR("DECRYPT CRC ERR", decrypt_crc_err); |
| 980 | RXS_ERR("PHY ERR", phy_err); |
| 981 | RXS_ERR("MIC ERR", mic_err); |
| 982 | RXS_ERR("PRE-DELIM CRC ERR", pre_delim_crc_err); |
| 983 | RXS_ERR("POST-DELIM CRC ERR", post_delim_crc_err); |
| 984 | RXS_ERR("DECRYPT BUSY ERR", decrypt_busy_err); |
Sujith Manoharan | c3b9f9e | 2014-01-13 07:29:29 +0530 | [diff] [blame] | 985 | RXS_ERR("LENGTH-ERR", rx_len_err); |
| 986 | RXS_ERR("OOM-ERR", rx_oom_err); |
| 987 | RXS_ERR("RATE-ERR", rx_rate_err); |
| 988 | RXS_ERR("TOO-MANY-FRAGS", rx_too_many_frags_err); |
Ben Greear | 99c15bf | 2010-10-01 12:26:30 -0700 | [diff] [blame] | 989 | |
Dan Carpenter | 2b87f3a | 2010-05-14 15:24:37 +0200 | [diff] [blame] | 990 | if (len > size) |
| 991 | len = size; |
| 992 | |
Sujith | 1395d3f | 2010-01-08 10:36:11 +0530 | [diff] [blame] | 993 | retval = simple_read_from_buffer(user_buf, count, ppos, buf, len); |
| 994 | kfree(buf); |
| 995 | |
| 996 | return retval; |
| 997 | |
Ben Greear | 24a0731 | 2012-04-12 10:03:59 -0700 | [diff] [blame] | 998 | #undef RXS_ERR |
Sujith | 1395d3f | 2010-01-08 10:36:11 +0530 | [diff] [blame] | 999 | } |
| 1000 | |
Felix Fietkau | 8e6f5aa | 2010-03-29 20:09:27 -0700 | [diff] [blame] | 1001 | void ath_debug_stat_rx(struct ath_softc *sc, struct ath_rx_status *rs) |
Sujith | 1395d3f | 2010-01-08 10:36:11 +0530 | [diff] [blame] | 1002 | { |
Sujith | 1395d3f | 2010-01-08 10:36:11 +0530 | [diff] [blame] | 1003 | #define RX_PHY_ERR_INC(c) sc->debug.stats.rxstats.phy_err_stats[c]++ |
| 1004 | |
Ben Greear | 99c15bf | 2010-10-01 12:26:30 -0700 | [diff] [blame] | 1005 | RX_STAT_INC(rx_pkts_all); |
| 1006 | sc->debug.stats.rxstats.rx_bytes_all += rs->rs_datalen; |
| 1007 | |
Felix Fietkau | 8e6f5aa | 2010-03-29 20:09:27 -0700 | [diff] [blame] | 1008 | if (rs->rs_status & ATH9K_RXERR_CRC) |
Sujith | 1395d3f | 2010-01-08 10:36:11 +0530 | [diff] [blame] | 1009 | RX_STAT_INC(crc_err); |
Felix Fietkau | 8e6f5aa | 2010-03-29 20:09:27 -0700 | [diff] [blame] | 1010 | if (rs->rs_status & ATH9K_RXERR_DECRYPT) |
Sujith | 1395d3f | 2010-01-08 10:36:11 +0530 | [diff] [blame] | 1011 | RX_STAT_INC(decrypt_crc_err); |
Felix Fietkau | 8e6f5aa | 2010-03-29 20:09:27 -0700 | [diff] [blame] | 1012 | if (rs->rs_status & ATH9K_RXERR_MIC) |
Sujith | 1395d3f | 2010-01-08 10:36:11 +0530 | [diff] [blame] | 1013 | RX_STAT_INC(mic_err); |
Felix Fietkau | 8e6f5aa | 2010-03-29 20:09:27 -0700 | [diff] [blame] | 1014 | if (rs->rs_status & ATH9K_RX_DELIM_CRC_PRE) |
Sujith | 1395d3f | 2010-01-08 10:36:11 +0530 | [diff] [blame] | 1015 | RX_STAT_INC(pre_delim_crc_err); |
Felix Fietkau | 8e6f5aa | 2010-03-29 20:09:27 -0700 | [diff] [blame] | 1016 | if (rs->rs_status & ATH9K_RX_DELIM_CRC_POST) |
Sujith | 1395d3f | 2010-01-08 10:36:11 +0530 | [diff] [blame] | 1017 | RX_STAT_INC(post_delim_crc_err); |
Felix Fietkau | 8e6f5aa | 2010-03-29 20:09:27 -0700 | [diff] [blame] | 1018 | if (rs->rs_status & ATH9K_RX_DECRYPT_BUSY) |
Sujith | 1395d3f | 2010-01-08 10:36:11 +0530 | [diff] [blame] | 1019 | RX_STAT_INC(decrypt_busy_err); |
| 1020 | |
Felix Fietkau | 8e6f5aa | 2010-03-29 20:09:27 -0700 | [diff] [blame] | 1021 | if (rs->rs_status & ATH9K_RXERR_PHY) { |
Sujith | 1395d3f | 2010-01-08 10:36:11 +0530 | [diff] [blame] | 1022 | RX_STAT_INC(phy_err); |
Sujith Manoharan | dbb07f0 | 2012-02-16 11:52:25 +0530 | [diff] [blame] | 1023 | if (rs->rs_phyerr < ATH9K_PHYERR_MAX) |
| 1024 | RX_PHY_ERR_INC(rs->rs_phyerr); |
Sujith | 1395d3f | 2010-01-08 10:36:11 +0530 | [diff] [blame] | 1025 | } |
| 1026 | |
Sujith | 1395d3f | 2010-01-08 10:36:11 +0530 | [diff] [blame] | 1027 | #undef RX_PHY_ERR_INC |
| 1028 | } |
| 1029 | |
| 1030 | static const struct file_operations fops_recv = { |
| 1031 | .read = read_file_recv, |
Stephen Boyd | 234e340 | 2012-04-05 14:25:11 -0700 | [diff] [blame] | 1032 | .open = simple_open, |
Arnd Bergmann | 6038f37 | 2010-08-15 18:52:59 +0200 | [diff] [blame] | 1033 | .owner = THIS_MODULE, |
| 1034 | .llseek = default_llseek, |
Sujith | 1395d3f | 2010-01-08 10:36:11 +0530 | [diff] [blame] | 1035 | }; |
| 1036 | |
Sujith Manoharan | c3b9f9e | 2014-01-13 07:29:29 +0530 | [diff] [blame] | 1037 | static ssize_t read_file_phy_err(struct file *file, char __user *user_buf, |
| 1038 | size_t count, loff_t *ppos) |
| 1039 | { |
| 1040 | #define PHY_ERR(s, p) \ |
| 1041 | len += scnprintf(buf + len, size - len, "%22s : %10u\n", s, \ |
| 1042 | sc->debug.stats.rxstats.phy_err_stats[p]); |
| 1043 | |
| 1044 | struct ath_softc *sc = file->private_data; |
| 1045 | char *buf; |
| 1046 | unsigned int len = 0, size = 1600; |
| 1047 | ssize_t retval = 0; |
| 1048 | |
| 1049 | buf = kzalloc(size, GFP_KERNEL); |
| 1050 | if (buf == NULL) |
| 1051 | return -ENOMEM; |
| 1052 | |
| 1053 | PHY_ERR("UNDERRUN ERR", ATH9K_PHYERR_UNDERRUN); |
| 1054 | PHY_ERR("TIMING ERR", ATH9K_PHYERR_TIMING); |
| 1055 | PHY_ERR("PARITY ERR", ATH9K_PHYERR_PARITY); |
| 1056 | PHY_ERR("RATE ERR", ATH9K_PHYERR_RATE); |
| 1057 | PHY_ERR("LENGTH ERR", ATH9K_PHYERR_LENGTH); |
| 1058 | PHY_ERR("RADAR ERR", ATH9K_PHYERR_RADAR); |
| 1059 | PHY_ERR("SERVICE ERR", ATH9K_PHYERR_SERVICE); |
| 1060 | PHY_ERR("TOR ERR", ATH9K_PHYERR_TOR); |
| 1061 | PHY_ERR("OFDM-TIMING ERR", ATH9K_PHYERR_OFDM_TIMING); |
| 1062 | PHY_ERR("OFDM-SIGNAL-PARITY ERR", ATH9K_PHYERR_OFDM_SIGNAL_PARITY); |
| 1063 | PHY_ERR("OFDM-RATE ERR", ATH9K_PHYERR_OFDM_RATE_ILLEGAL); |
| 1064 | PHY_ERR("OFDM-LENGTH ERR", ATH9K_PHYERR_OFDM_LENGTH_ILLEGAL); |
| 1065 | PHY_ERR("OFDM-POWER-DROP ERR", ATH9K_PHYERR_OFDM_POWER_DROP); |
| 1066 | PHY_ERR("OFDM-SERVICE ERR", ATH9K_PHYERR_OFDM_SERVICE); |
| 1067 | PHY_ERR("OFDM-RESTART ERR", ATH9K_PHYERR_OFDM_RESTART); |
| 1068 | PHY_ERR("FALSE-RADAR-EXT ERR", ATH9K_PHYERR_FALSE_RADAR_EXT); |
| 1069 | PHY_ERR("CCK-TIMING ERR", ATH9K_PHYERR_CCK_TIMING); |
| 1070 | PHY_ERR("CCK-HEADER-CRC ERR", ATH9K_PHYERR_CCK_HEADER_CRC); |
| 1071 | PHY_ERR("CCK-RATE ERR", ATH9K_PHYERR_CCK_RATE_ILLEGAL); |
| 1072 | PHY_ERR("CCK-SERVICE ERR", ATH9K_PHYERR_CCK_SERVICE); |
| 1073 | PHY_ERR("CCK-RESTART ERR", ATH9K_PHYERR_CCK_RESTART); |
| 1074 | PHY_ERR("CCK-LENGTH ERR", ATH9K_PHYERR_CCK_LENGTH_ILLEGAL); |
| 1075 | PHY_ERR("CCK-POWER-DROP ERR", ATH9K_PHYERR_CCK_POWER_DROP); |
| 1076 | PHY_ERR("HT-CRC ERR", ATH9K_PHYERR_HT_CRC_ERROR); |
| 1077 | PHY_ERR("HT-LENGTH ERR", ATH9K_PHYERR_HT_LENGTH_ILLEGAL); |
| 1078 | PHY_ERR("HT-RATE ERR", ATH9K_PHYERR_HT_RATE_ILLEGAL); |
| 1079 | |
| 1080 | if (len > size) |
| 1081 | len = size; |
| 1082 | |
| 1083 | retval = simple_read_from_buffer(user_buf, count, ppos, buf, len); |
| 1084 | kfree(buf); |
| 1085 | |
| 1086 | return retval; |
| 1087 | |
| 1088 | #undef PHY_ERR |
| 1089 | } |
| 1090 | |
| 1091 | static const struct file_operations fops_phy_err = { |
| 1092 | .read = read_file_phy_err, |
| 1093 | .open = simple_open, |
| 1094 | .owner = THIS_MODULE, |
| 1095 | .llseek = default_llseek, |
| 1096 | }; |
| 1097 | |
Felix Fietkau | 9bff0bc | 2010-05-11 17:23:02 +0200 | [diff] [blame] | 1098 | static ssize_t read_file_regidx(struct file *file, char __user *user_buf, |
| 1099 | size_t count, loff_t *ppos) |
| 1100 | { |
| 1101 | struct ath_softc *sc = file->private_data; |
| 1102 | char buf[32]; |
| 1103 | unsigned int len; |
| 1104 | |
Dan Carpenter | 2b87f3a | 2010-05-14 15:24:37 +0200 | [diff] [blame] | 1105 | len = sprintf(buf, "0x%08x\n", sc->debug.regidx); |
Felix Fietkau | 9bff0bc | 2010-05-11 17:23:02 +0200 | [diff] [blame] | 1106 | return simple_read_from_buffer(user_buf, count, ppos, buf, len); |
| 1107 | } |
| 1108 | |
| 1109 | static ssize_t write_file_regidx(struct file *file, const char __user *user_buf, |
| 1110 | size_t count, loff_t *ppos) |
| 1111 | { |
| 1112 | struct ath_softc *sc = file->private_data; |
| 1113 | unsigned long regidx; |
| 1114 | char buf[32]; |
| 1115 | ssize_t len; |
| 1116 | |
| 1117 | len = min(count, sizeof(buf) - 1); |
| 1118 | if (copy_from_user(buf, user_buf, len)) |
Dan Carpenter | 0423606 | 2010-05-14 15:25:39 +0200 | [diff] [blame] | 1119 | return -EFAULT; |
Felix Fietkau | 9bff0bc | 2010-05-11 17:23:02 +0200 | [diff] [blame] | 1120 | |
| 1121 | buf[len] = '\0'; |
Jingoo Han | 27d7f47 | 2013-05-31 21:24:06 +0000 | [diff] [blame] | 1122 | if (kstrtoul(buf, 0, ®idx)) |
Felix Fietkau | 9bff0bc | 2010-05-11 17:23:02 +0200 | [diff] [blame] | 1123 | return -EINVAL; |
| 1124 | |
| 1125 | sc->debug.regidx = regidx; |
| 1126 | return count; |
| 1127 | } |
| 1128 | |
| 1129 | static const struct file_operations fops_regidx = { |
| 1130 | .read = read_file_regidx, |
| 1131 | .write = write_file_regidx, |
Stephen Boyd | 234e340 | 2012-04-05 14:25:11 -0700 | [diff] [blame] | 1132 | .open = simple_open, |
Arnd Bergmann | 6038f37 | 2010-08-15 18:52:59 +0200 | [diff] [blame] | 1133 | .owner = THIS_MODULE, |
| 1134 | .llseek = default_llseek, |
Felix Fietkau | 9bff0bc | 2010-05-11 17:23:02 +0200 | [diff] [blame] | 1135 | }; |
| 1136 | |
| 1137 | static ssize_t read_file_regval(struct file *file, char __user *user_buf, |
| 1138 | size_t count, loff_t *ppos) |
| 1139 | { |
| 1140 | struct ath_softc *sc = file->private_data; |
| 1141 | struct ath_hw *ah = sc->sc_ah; |
| 1142 | char buf[32]; |
| 1143 | unsigned int len; |
| 1144 | u32 regval; |
| 1145 | |
Rajkumar Manoharan | 79d2b15 | 2011-05-16 18:23:23 +0530 | [diff] [blame] | 1146 | ath9k_ps_wakeup(sc); |
Felix Fietkau | 9bff0bc | 2010-05-11 17:23:02 +0200 | [diff] [blame] | 1147 | regval = REG_READ_D(ah, sc->debug.regidx); |
Rajkumar Manoharan | 79d2b15 | 2011-05-16 18:23:23 +0530 | [diff] [blame] | 1148 | ath9k_ps_restore(sc); |
Dan Carpenter | 2b87f3a | 2010-05-14 15:24:37 +0200 | [diff] [blame] | 1149 | len = sprintf(buf, "0x%08x\n", regval); |
Felix Fietkau | 9bff0bc | 2010-05-11 17:23:02 +0200 | [diff] [blame] | 1150 | return simple_read_from_buffer(user_buf, count, ppos, buf, len); |
| 1151 | } |
| 1152 | |
| 1153 | static ssize_t write_file_regval(struct file *file, const char __user *user_buf, |
| 1154 | size_t count, loff_t *ppos) |
| 1155 | { |
| 1156 | struct ath_softc *sc = file->private_data; |
| 1157 | struct ath_hw *ah = sc->sc_ah; |
| 1158 | unsigned long regval; |
| 1159 | char buf[32]; |
| 1160 | ssize_t len; |
| 1161 | |
| 1162 | len = min(count, sizeof(buf) - 1); |
| 1163 | if (copy_from_user(buf, user_buf, len)) |
Dan Carpenter | 0423606 | 2010-05-14 15:25:39 +0200 | [diff] [blame] | 1164 | return -EFAULT; |
Felix Fietkau | 9bff0bc | 2010-05-11 17:23:02 +0200 | [diff] [blame] | 1165 | |
| 1166 | buf[len] = '\0'; |
Jingoo Han | 27d7f47 | 2013-05-31 21:24:06 +0000 | [diff] [blame] | 1167 | if (kstrtoul(buf, 0, ®val)) |
Felix Fietkau | 9bff0bc | 2010-05-11 17:23:02 +0200 | [diff] [blame] | 1168 | return -EINVAL; |
| 1169 | |
Rajkumar Manoharan | 79d2b15 | 2011-05-16 18:23:23 +0530 | [diff] [blame] | 1170 | ath9k_ps_wakeup(sc); |
Felix Fietkau | 9bff0bc | 2010-05-11 17:23:02 +0200 | [diff] [blame] | 1171 | REG_WRITE_D(ah, sc->debug.regidx, regval); |
Rajkumar Manoharan | 79d2b15 | 2011-05-16 18:23:23 +0530 | [diff] [blame] | 1172 | ath9k_ps_restore(sc); |
Felix Fietkau | 9bff0bc | 2010-05-11 17:23:02 +0200 | [diff] [blame] | 1173 | return count; |
| 1174 | } |
| 1175 | |
| 1176 | static const struct file_operations fops_regval = { |
| 1177 | .read = read_file_regval, |
| 1178 | .write = write_file_regval, |
Stephen Boyd | 234e340 | 2012-04-05 14:25:11 -0700 | [diff] [blame] | 1179 | .open = simple_open, |
Arnd Bergmann | 6038f37 | 2010-08-15 18:52:59 +0200 | [diff] [blame] | 1180 | .owner = THIS_MODULE, |
| 1181 | .llseek = default_llseek, |
Felix Fietkau | 9bff0bc | 2010-05-11 17:23:02 +0200 | [diff] [blame] | 1182 | }; |
| 1183 | |
Vasanthakumar Thiagarajan | 582d006 | 2011-03-01 05:30:55 -0800 | [diff] [blame] | 1184 | #define REGDUMP_LINE_SIZE 20 |
| 1185 | |
| 1186 | static int open_file_regdump(struct inode *inode, struct file *file) |
| 1187 | { |
| 1188 | struct ath_softc *sc = inode->i_private; |
| 1189 | unsigned int len = 0; |
| 1190 | u8 *buf; |
| 1191 | int i; |
| 1192 | unsigned long num_regs, regdump_len, max_reg_offset; |
| 1193 | |
| 1194 | max_reg_offset = AR_SREV_9300_20_OR_LATER(sc->sc_ah) ? 0x16bd4 : 0xb500; |
| 1195 | num_regs = max_reg_offset / 4 + 1; |
| 1196 | regdump_len = num_regs * REGDUMP_LINE_SIZE + 1; |
| 1197 | buf = vmalloc(regdump_len); |
| 1198 | if (!buf) |
| 1199 | return -ENOMEM; |
| 1200 | |
| 1201 | ath9k_ps_wakeup(sc); |
| 1202 | for (i = 0; i < num_regs; i++) |
| 1203 | len += scnprintf(buf + len, regdump_len - len, |
| 1204 | "0x%06x 0x%08x\n", i << 2, REG_READ(sc->sc_ah, i << 2)); |
| 1205 | ath9k_ps_restore(sc); |
| 1206 | |
| 1207 | file->private_data = buf; |
| 1208 | |
| 1209 | return 0; |
| 1210 | } |
| 1211 | |
| 1212 | static const struct file_operations fops_regdump = { |
| 1213 | .open = open_file_regdump, |
| 1214 | .read = ath9k_debugfs_read_buf, |
| 1215 | .release = ath9k_debugfs_release_buf, |
| 1216 | .owner = THIS_MODULE, |
| 1217 | .llseek = default_llseek,/* read accesses f_pos */ |
| 1218 | }; |
| 1219 | |
Rajkumar Manoharan | d069a46 | 2011-08-13 10:28:18 +0530 | [diff] [blame] | 1220 | static ssize_t read_file_dump_nfcal(struct file *file, char __user *user_buf, |
| 1221 | size_t count, loff_t *ppos) |
| 1222 | { |
| 1223 | struct ath_softc *sc = file->private_data; |
| 1224 | struct ath_hw *ah = sc->sc_ah; |
| 1225 | struct ath9k_nfcal_hist *h = sc->caldata.nfCalHist; |
| 1226 | struct ath_common *common = ath9k_hw_common(ah); |
| 1227 | struct ieee80211_conf *conf = &common->hw->conf; |
| 1228 | u32 len = 0, size = 1500; |
| 1229 | u32 i, j; |
| 1230 | ssize_t retval = 0; |
| 1231 | char *buf; |
| 1232 | u8 chainmask = (ah->rxchainmask << 3) | ah->rxchainmask; |
| 1233 | u8 nread; |
| 1234 | |
| 1235 | buf = kzalloc(size, GFP_KERNEL); |
| 1236 | if (!buf) |
| 1237 | return -ENOMEM; |
| 1238 | |
Zefir Kurtisi | 5e88ba6 | 2013-09-05 14:11:57 +0200 | [diff] [blame] | 1239 | len += scnprintf(buf + len, size - len, |
| 1240 | "Channel Noise Floor : %d\n", ah->noise); |
| 1241 | len += scnprintf(buf + len, size - len, |
| 1242 | "Chain | privNF | # Readings | NF Readings\n"); |
Rajkumar Manoharan | d069a46 | 2011-08-13 10:28:18 +0530 | [diff] [blame] | 1243 | for (i = 0; i < NUM_NF_READINGS; i++) { |
| 1244 | if (!(chainmask & (1 << i)) || |
| 1245 | ((i >= AR5416_MAX_CHAINS) && !conf_is_ht40(conf))) |
| 1246 | continue; |
| 1247 | |
| 1248 | nread = AR_PHY_CCA_FILTERWINDOW_LENGTH - h[i].invalidNFcount; |
Zefir Kurtisi | 5e88ba6 | 2013-09-05 14:11:57 +0200 | [diff] [blame] | 1249 | len += scnprintf(buf + len, size - len, " %d\t %d\t %d\t\t", |
| 1250 | i, h[i].privNF, nread); |
Rajkumar Manoharan | d069a46 | 2011-08-13 10:28:18 +0530 | [diff] [blame] | 1251 | for (j = 0; j < nread; j++) |
Zefir Kurtisi | 5e88ba6 | 2013-09-05 14:11:57 +0200 | [diff] [blame] | 1252 | len += scnprintf(buf + len, size - len, |
| 1253 | " %d", h[i].nfCalBuffer[j]); |
| 1254 | len += scnprintf(buf + len, size - len, "\n"); |
Rajkumar Manoharan | d069a46 | 2011-08-13 10:28:18 +0530 | [diff] [blame] | 1255 | } |
| 1256 | |
| 1257 | if (len > size) |
| 1258 | len = size; |
| 1259 | |
| 1260 | retval = simple_read_from_buffer(user_buf, count, ppos, buf, len); |
| 1261 | kfree(buf); |
| 1262 | |
| 1263 | return retval; |
| 1264 | } |
| 1265 | |
| 1266 | static const struct file_operations fops_dump_nfcal = { |
| 1267 | .read = read_file_dump_nfcal, |
Stephen Boyd | 234e340 | 2012-04-05 14:25:11 -0700 | [diff] [blame] | 1268 | .open = simple_open, |
Rajkumar Manoharan | d069a46 | 2011-08-13 10:28:18 +0530 | [diff] [blame] | 1269 | .owner = THIS_MODULE, |
| 1270 | .llseek = default_llseek, |
| 1271 | }; |
| 1272 | |
Rajkumar Manoharan | 580f010 | 2011-07-29 17:38:12 +0530 | [diff] [blame] | 1273 | static ssize_t read_file_base_eeprom(struct file *file, char __user *user_buf, |
| 1274 | size_t count, loff_t *ppos) |
| 1275 | { |
| 1276 | struct ath_softc *sc = file->private_data; |
| 1277 | struct ath_hw *ah = sc->sc_ah; |
| 1278 | u32 len = 0, size = 1500; |
| 1279 | ssize_t retval = 0; |
| 1280 | char *buf; |
| 1281 | |
| 1282 | buf = kzalloc(size, GFP_KERNEL); |
| 1283 | if (!buf) |
| 1284 | return -ENOMEM; |
| 1285 | |
| 1286 | len = ah->eep_ops->dump_eeprom(ah, true, buf, len, size); |
| 1287 | |
| 1288 | retval = simple_read_from_buffer(user_buf, count, ppos, buf, len); |
| 1289 | kfree(buf); |
| 1290 | |
| 1291 | return retval; |
| 1292 | } |
| 1293 | |
| 1294 | static const struct file_operations fops_base_eeprom = { |
| 1295 | .read = read_file_base_eeprom, |
Stephen Boyd | 234e340 | 2012-04-05 14:25:11 -0700 | [diff] [blame] | 1296 | .open = simple_open, |
Rajkumar Manoharan | 580f010 | 2011-07-29 17:38:12 +0530 | [diff] [blame] | 1297 | .owner = THIS_MODULE, |
| 1298 | .llseek = default_llseek, |
| 1299 | }; |
| 1300 | |
Rajkumar Manoharan | 3f4c4bd | 2011-07-29 17:38:13 +0530 | [diff] [blame] | 1301 | static ssize_t read_file_modal_eeprom(struct file *file, char __user *user_buf, |
| 1302 | size_t count, loff_t *ppos) |
| 1303 | { |
| 1304 | struct ath_softc *sc = file->private_data; |
| 1305 | struct ath_hw *ah = sc->sc_ah; |
| 1306 | u32 len = 0, size = 6000; |
| 1307 | char *buf; |
| 1308 | size_t retval; |
| 1309 | |
| 1310 | buf = kzalloc(size, GFP_KERNEL); |
| 1311 | if (buf == NULL) |
| 1312 | return -ENOMEM; |
| 1313 | |
| 1314 | len = ah->eep_ops->dump_eeprom(ah, false, buf, len, size); |
| 1315 | |
| 1316 | retval = simple_read_from_buffer(user_buf, count, ppos, buf, len); |
| 1317 | kfree(buf); |
| 1318 | |
| 1319 | return retval; |
| 1320 | } |
| 1321 | |
| 1322 | static const struct file_operations fops_modal_eeprom = { |
| 1323 | .read = read_file_modal_eeprom, |
Stephen Boyd | 234e340 | 2012-04-05 14:25:11 -0700 | [diff] [blame] | 1324 | .open = simple_open, |
Rajkumar Manoharan | 3f4c4bd | 2011-07-29 17:38:13 +0530 | [diff] [blame] | 1325 | .owner = THIS_MODULE, |
| 1326 | .llseek = default_llseek, |
| 1327 | }; |
| 1328 | |
Rajkumar Manoharan | 4df50ca | 2012-10-25 17:16:54 +0530 | [diff] [blame] | 1329 | #ifdef CONFIG_ATH9K_BTCOEX_SUPPORT |
| 1330 | static ssize_t read_file_btcoex(struct file *file, char __user *user_buf, |
| 1331 | size_t count, loff_t *ppos) |
| 1332 | { |
| 1333 | struct ath_softc *sc = file->private_data; |
| 1334 | u32 len = 0, size = 1500; |
| 1335 | char *buf; |
| 1336 | size_t retval; |
| 1337 | |
| 1338 | buf = kzalloc(size, GFP_KERNEL); |
| 1339 | if (buf == NULL) |
| 1340 | return -ENOMEM; |
| 1341 | |
Sujith Manoharan | ac46ba4 | 2012-11-19 14:24:46 +0530 | [diff] [blame] | 1342 | if (!sc->sc_ah->common.btcoex_enabled) { |
Zefir Kurtisi | 5e88ba6 | 2013-09-05 14:11:57 +0200 | [diff] [blame] | 1343 | len = scnprintf(buf, size, "%s\n", |
| 1344 | "BTCOEX is disabled"); |
Sujith Manoharan | ac46ba4 | 2012-11-19 14:24:46 +0530 | [diff] [blame] | 1345 | goto exit; |
| 1346 | } |
Rajkumar Manoharan | 4df50ca | 2012-10-25 17:16:54 +0530 | [diff] [blame] | 1347 | |
Sujith Manoharan | ac46ba4 | 2012-11-19 14:24:46 +0530 | [diff] [blame] | 1348 | len = ath9k_dump_btcoex(sc, buf, size); |
| 1349 | exit: |
Rajkumar Manoharan | 4df50ca | 2012-10-25 17:16:54 +0530 | [diff] [blame] | 1350 | retval = simple_read_from_buffer(user_buf, count, ppos, buf, len); |
| 1351 | kfree(buf); |
| 1352 | |
| 1353 | return retval; |
| 1354 | } |
| 1355 | |
| 1356 | static const struct file_operations fops_btcoex = { |
| 1357 | .read = read_file_btcoex, |
| 1358 | .open = simple_open, |
| 1359 | .owner = THIS_MODULE, |
| 1360 | .llseek = default_llseek, |
| 1361 | }; |
| 1362 | #endif |
| 1363 | |
Sujith Manoharan | c175db8 | 2012-11-28 15:08:52 +0530 | [diff] [blame] | 1364 | /* Ethtool support for get-stats */ |
| 1365 | |
| 1366 | #define AMKSTR(nm) #nm "_BE", #nm "_BK", #nm "_VI", #nm "_VO" |
| 1367 | static const char ath9k_gstrings_stats[][ETH_GSTRING_LEN] = { |
| 1368 | "tx_pkts_nic", |
| 1369 | "tx_bytes_nic", |
| 1370 | "rx_pkts_nic", |
| 1371 | "rx_bytes_nic", |
| 1372 | AMKSTR(d_tx_pkts), |
| 1373 | AMKSTR(d_tx_bytes), |
| 1374 | AMKSTR(d_tx_mpdus_queued), |
| 1375 | AMKSTR(d_tx_mpdus_completed), |
| 1376 | AMKSTR(d_tx_mpdu_xretries), |
| 1377 | AMKSTR(d_tx_aggregates), |
| 1378 | AMKSTR(d_tx_ampdus_queued_hw), |
| 1379 | AMKSTR(d_tx_ampdus_queued_sw), |
| 1380 | AMKSTR(d_tx_ampdus_completed), |
| 1381 | AMKSTR(d_tx_ampdu_retries), |
| 1382 | AMKSTR(d_tx_ampdu_xretries), |
| 1383 | AMKSTR(d_tx_fifo_underrun), |
| 1384 | AMKSTR(d_tx_op_exceeded), |
| 1385 | AMKSTR(d_tx_timer_expiry), |
| 1386 | AMKSTR(d_tx_desc_cfg_err), |
| 1387 | AMKSTR(d_tx_data_underrun), |
| 1388 | AMKSTR(d_tx_delim_underrun), |
Ben Greear | 18c45b1 | 2013-03-04 15:31:17 -0800 | [diff] [blame] | 1389 | "d_rx_crc_err", |
Sujith Manoharan | c175db8 | 2012-11-28 15:08:52 +0530 | [diff] [blame] | 1390 | "d_rx_decrypt_crc_err", |
| 1391 | "d_rx_phy_err", |
| 1392 | "d_rx_mic_err", |
| 1393 | "d_rx_pre_delim_crc_err", |
| 1394 | "d_rx_post_delim_crc_err", |
| 1395 | "d_rx_decrypt_busy_err", |
| 1396 | |
| 1397 | "d_rx_phyerr_radar", |
| 1398 | "d_rx_phyerr_ofdm_timing", |
| 1399 | "d_rx_phyerr_cck_timing", |
| 1400 | |
| 1401 | }; |
| 1402 | #define ATH9K_SSTATS_LEN ARRAY_SIZE(ath9k_gstrings_stats) |
| 1403 | |
| 1404 | void ath9k_get_et_strings(struct ieee80211_hw *hw, |
| 1405 | struct ieee80211_vif *vif, |
| 1406 | u32 sset, u8 *data) |
| 1407 | { |
| 1408 | if (sset == ETH_SS_STATS) |
| 1409 | memcpy(data, *ath9k_gstrings_stats, |
| 1410 | sizeof(ath9k_gstrings_stats)); |
| 1411 | } |
| 1412 | |
| 1413 | int ath9k_get_et_sset_count(struct ieee80211_hw *hw, |
| 1414 | struct ieee80211_vif *vif, int sset) |
| 1415 | { |
| 1416 | if (sset == ETH_SS_STATS) |
| 1417 | return ATH9K_SSTATS_LEN; |
| 1418 | return 0; |
| 1419 | } |
| 1420 | |
| 1421 | #define AWDATA(elem) \ |
| 1422 | do { \ |
| 1423 | data[i++] = sc->debug.stats.txstats[PR_QNUM(IEEE80211_AC_BE)].elem; \ |
| 1424 | data[i++] = sc->debug.stats.txstats[PR_QNUM(IEEE80211_AC_BK)].elem; \ |
| 1425 | data[i++] = sc->debug.stats.txstats[PR_QNUM(IEEE80211_AC_VI)].elem; \ |
| 1426 | data[i++] = sc->debug.stats.txstats[PR_QNUM(IEEE80211_AC_VO)].elem; \ |
| 1427 | } while (0) |
| 1428 | |
| 1429 | #define AWDATA_RX(elem) \ |
| 1430 | do { \ |
| 1431 | data[i++] = sc->debug.stats.rxstats.elem; \ |
| 1432 | } while (0) |
| 1433 | |
| 1434 | void ath9k_get_et_stats(struct ieee80211_hw *hw, |
| 1435 | struct ieee80211_vif *vif, |
| 1436 | struct ethtool_stats *stats, u64 *data) |
| 1437 | { |
| 1438 | struct ath_softc *sc = hw->priv; |
| 1439 | int i = 0; |
| 1440 | |
| 1441 | data[i++] = (sc->debug.stats.txstats[PR_QNUM(IEEE80211_AC_BE)].tx_pkts_all + |
| 1442 | sc->debug.stats.txstats[PR_QNUM(IEEE80211_AC_BK)].tx_pkts_all + |
| 1443 | sc->debug.stats.txstats[PR_QNUM(IEEE80211_AC_VI)].tx_pkts_all + |
| 1444 | sc->debug.stats.txstats[PR_QNUM(IEEE80211_AC_VO)].tx_pkts_all); |
| 1445 | data[i++] = (sc->debug.stats.txstats[PR_QNUM(IEEE80211_AC_BE)].tx_bytes_all + |
| 1446 | sc->debug.stats.txstats[PR_QNUM(IEEE80211_AC_BK)].tx_bytes_all + |
| 1447 | sc->debug.stats.txstats[PR_QNUM(IEEE80211_AC_VI)].tx_bytes_all + |
| 1448 | sc->debug.stats.txstats[PR_QNUM(IEEE80211_AC_VO)].tx_bytes_all); |
| 1449 | AWDATA_RX(rx_pkts_all); |
| 1450 | AWDATA_RX(rx_bytes_all); |
| 1451 | |
| 1452 | AWDATA(tx_pkts_all); |
| 1453 | AWDATA(tx_bytes_all); |
| 1454 | AWDATA(queued); |
| 1455 | AWDATA(completed); |
| 1456 | AWDATA(xretries); |
| 1457 | AWDATA(a_aggr); |
| 1458 | AWDATA(a_queued_hw); |
| 1459 | AWDATA(a_queued_sw); |
| 1460 | AWDATA(a_completed); |
| 1461 | AWDATA(a_retries); |
| 1462 | AWDATA(a_xretries); |
| 1463 | AWDATA(fifo_underrun); |
| 1464 | AWDATA(xtxop); |
| 1465 | AWDATA(timer_exp); |
| 1466 | AWDATA(desc_cfg_err); |
| 1467 | AWDATA(data_underrun); |
| 1468 | AWDATA(delim_underrun); |
| 1469 | |
Ben Greear | 18c45b1 | 2013-03-04 15:31:17 -0800 | [diff] [blame] | 1470 | AWDATA_RX(crc_err); |
Sujith Manoharan | c175db8 | 2012-11-28 15:08:52 +0530 | [diff] [blame] | 1471 | AWDATA_RX(decrypt_crc_err); |
| 1472 | AWDATA_RX(phy_err); |
| 1473 | AWDATA_RX(mic_err); |
| 1474 | AWDATA_RX(pre_delim_crc_err); |
| 1475 | AWDATA_RX(post_delim_crc_err); |
| 1476 | AWDATA_RX(decrypt_busy_err); |
| 1477 | |
| 1478 | AWDATA_RX(phy_err_stats[ATH9K_PHYERR_RADAR]); |
| 1479 | AWDATA_RX(phy_err_stats[ATH9K_PHYERR_OFDM_TIMING]); |
| 1480 | AWDATA_RX(phy_err_stats[ATH9K_PHYERR_CCK_TIMING]); |
| 1481 | |
| 1482 | WARN_ON(i != ATH9K_SSTATS_LEN); |
| 1483 | } |
| 1484 | |
Sujith Manoharan | af69009 | 2013-05-10 18:41:06 +0530 | [diff] [blame] | 1485 | void ath9k_deinit_debug(struct ath_softc *sc) |
| 1486 | { |
Sujith Manoharan | f65c082 | 2013-12-18 09:53:18 +0530 | [diff] [blame] | 1487 | ath9k_spectral_deinit_debug(sc); |
Sujith Manoharan | af69009 | 2013-05-10 18:41:06 +0530 | [diff] [blame] | 1488 | } |
| 1489 | |
Luis R. Rodriguez | 4d6b228 | 2009-09-07 04:52:26 -0700 | [diff] [blame] | 1490 | int ath9k_init_debug(struct ath_hw *ah) |
Sujith | 88b126a | 2008-11-28 22:19:02 +0530 | [diff] [blame] | 1491 | { |
Luis R. Rodriguez | bc974f4 | 2009-09-28 02:54:40 -0400 | [diff] [blame] | 1492 | struct ath_common *common = ath9k_hw_common(ah); |
| 1493 | struct ath_softc *sc = (struct ath_softc *) common->priv; |
Luis R. Rodriguez | 4d6b228 | 2009-09-07 04:52:26 -0700 | [diff] [blame] | 1494 | |
Ben Greear | eb27244 | 2010-11-29 14:13:22 -0800 | [diff] [blame] | 1495 | sc->debug.debugfs_phy = debugfs_create_dir("ath9k", |
| 1496 | sc->hw->wiphy->debugfsdir); |
Sujith | 17d7904 | 2009-02-09 13:27:03 +0530 | [diff] [blame] | 1497 | if (!sc->debug.debugfs_phy) |
Felix Fietkau | c8a72c0 | 2010-05-11 17:23:00 +0200 | [diff] [blame] | 1498 | return -ENOMEM; |
Sujith | 826d268 | 2008-11-28 22:20:23 +0530 | [diff] [blame] | 1499 | |
Felix Fietkau | a830df0 | 2009-11-23 22:33:27 +0100 | [diff] [blame] | 1500 | #ifdef CONFIG_ATH_DEBUG |
Felix Fietkau | c70cab1 | 2011-03-19 13:55:37 +0100 | [diff] [blame] | 1501 | debugfs_create_file("debug", S_IRUSR | S_IWUSR, sc->debug.debugfs_phy, |
| 1502 | sc, &fops_debug); |
Felix Fietkau | a830df0 | 2009-11-23 22:33:27 +0100 | [diff] [blame] | 1503 | #endif |
Zefir Kurtisi | 29942bc | 2011-12-14 20:16:34 -0800 | [diff] [blame] | 1504 | |
| 1505 | ath9k_dfs_init_debug(sc); |
Sujith Manoharan | ef6b19e | 2013-10-24 12:04:39 +0530 | [diff] [blame] | 1506 | ath9k_tx99_init_debug(sc); |
Sujith Manoharan | f65c082 | 2013-12-18 09:53:18 +0530 | [diff] [blame] | 1507 | ath9k_spectral_init_debug(sc); |
Zefir Kurtisi | 29942bc | 2011-12-14 20:16:34 -0800 | [diff] [blame] | 1508 | |
Felix Fietkau | c70cab1 | 2011-03-19 13:55:37 +0100 | [diff] [blame] | 1509 | debugfs_create_file("dma", S_IRUSR, sc->debug.debugfs_phy, sc, |
| 1510 | &fops_dma); |
| 1511 | debugfs_create_file("interrupt", S_IRUSR, sc->debug.debugfs_phy, sc, |
| 1512 | &fops_interrupt); |
Felix Fietkau | c70cab1 | 2011-03-19 13:55:37 +0100 | [diff] [blame] | 1513 | debugfs_create_file("xmit", S_IRUSR, sc->debug.debugfs_phy, sc, |
| 1514 | &fops_xmit); |
Sujith Manoharan | c0b7487 | 2012-11-21 18:13:12 +0530 | [diff] [blame] | 1515 | debugfs_create_file("queues", S_IRUSR, sc->debug.debugfs_phy, sc, |
| 1516 | &fops_queues); |
Felix Fietkau | 7702e78 | 2012-07-15 19:53:35 +0200 | [diff] [blame] | 1517 | debugfs_create_u32("qlen_bk", S_IRUSR | S_IWUSR, sc->debug.debugfs_phy, |
Sujith Manoharan | bea843c | 2012-11-21 18:13:10 +0530 | [diff] [blame] | 1518 | &sc->tx.txq_max_pending[IEEE80211_AC_BK]); |
Felix Fietkau | 7702e78 | 2012-07-15 19:53:35 +0200 | [diff] [blame] | 1519 | debugfs_create_u32("qlen_be", S_IRUSR | S_IWUSR, sc->debug.debugfs_phy, |
Sujith Manoharan | bea843c | 2012-11-21 18:13:10 +0530 | [diff] [blame] | 1520 | &sc->tx.txq_max_pending[IEEE80211_AC_BE]); |
Felix Fietkau | 7702e78 | 2012-07-15 19:53:35 +0200 | [diff] [blame] | 1521 | debugfs_create_u32("qlen_vi", S_IRUSR | S_IWUSR, sc->debug.debugfs_phy, |
Sujith Manoharan | bea843c | 2012-11-21 18:13:10 +0530 | [diff] [blame] | 1522 | &sc->tx.txq_max_pending[IEEE80211_AC_VI]); |
Felix Fietkau | 7702e78 | 2012-07-15 19:53:35 +0200 | [diff] [blame] | 1523 | debugfs_create_u32("qlen_vo", S_IRUSR | S_IWUSR, sc->debug.debugfs_phy, |
Sujith Manoharan | bea843c | 2012-11-21 18:13:10 +0530 | [diff] [blame] | 1524 | &sc->tx.txq_max_pending[IEEE80211_AC_VO]); |
Felix Fietkau | c70cab1 | 2011-03-19 13:55:37 +0100 | [diff] [blame] | 1525 | debugfs_create_file("misc", S_IRUSR, sc->debug.debugfs_phy, sc, |
| 1526 | &fops_misc); |
Sujith Manoharan | f8b815d | 2012-02-16 11:51:11 +0530 | [diff] [blame] | 1527 | debugfs_create_file("reset", S_IRUSR, sc->debug.debugfs_phy, sc, |
| 1528 | &fops_reset); |
Felix Fietkau | c70cab1 | 2011-03-19 13:55:37 +0100 | [diff] [blame] | 1529 | debugfs_create_file("recv", S_IRUSR, sc->debug.debugfs_phy, sc, |
| 1530 | &fops_recv); |
Sujith Manoharan | c3b9f9e | 2014-01-13 07:29:29 +0530 | [diff] [blame] | 1531 | debugfs_create_file("phy_err", S_IRUSR, sc->debug.debugfs_phy, sc, |
| 1532 | &fops_phy_err); |
Felix Fietkau | ca6d4a7 | 2013-08-13 12:33:27 +0200 | [diff] [blame] | 1533 | debugfs_create_u8("rx_chainmask", S_IRUSR, sc->debug.debugfs_phy, |
| 1534 | &ah->rxchainmask); |
| 1535 | debugfs_create_u8("tx_chainmask", S_IRUSR, sc->debug.debugfs_phy, |
| 1536 | &ah->txchainmask); |
Sujith Manoharan | 6e4d291 | 2013-06-03 09:19:28 +0530 | [diff] [blame] | 1537 | debugfs_create_file("ani", S_IRUSR | S_IWUSR, |
| 1538 | sc->debug.debugfs_phy, sc, &fops_ani); |
Felix Fietkau | 74673db | 2012-09-08 15:24:17 +0200 | [diff] [blame] | 1539 | debugfs_create_bool("paprd", S_IRUSR | S_IWUSR, sc->debug.debugfs_phy, |
| 1540 | &sc->sc_ah->config.enable_paprd); |
Felix Fietkau | c70cab1 | 2011-03-19 13:55:37 +0100 | [diff] [blame] | 1541 | debugfs_create_file("regidx", S_IRUSR | S_IWUSR, sc->debug.debugfs_phy, |
| 1542 | sc, &fops_regidx); |
| 1543 | debugfs_create_file("regval", S_IRUSR | S_IWUSR, sc->debug.debugfs_phy, |
| 1544 | sc, &fops_regval); |
| 1545 | debugfs_create_bool("ignore_extcca", S_IRUSR | S_IWUSR, |
| 1546 | sc->debug.debugfs_phy, |
| 1547 | &ah->config.cwm_ignore_extcca); |
| 1548 | debugfs_create_file("regdump", S_IRUSR, sc->debug.debugfs_phy, sc, |
| 1549 | &fops_regdump); |
Rajkumar Manoharan | d069a46 | 2011-08-13 10:28:18 +0530 | [diff] [blame] | 1550 | debugfs_create_file("dump_nfcal", S_IRUSR, sc->debug.debugfs_phy, sc, |
| 1551 | &fops_dump_nfcal); |
Rajkumar Manoharan | 580f010 | 2011-07-29 17:38:12 +0530 | [diff] [blame] | 1552 | debugfs_create_file("base_eeprom", S_IRUSR, sc->debug.debugfs_phy, sc, |
| 1553 | &fops_base_eeprom); |
Rajkumar Manoharan | 3f4c4bd | 2011-07-29 17:38:13 +0530 | [diff] [blame] | 1554 | debugfs_create_file("modal_eeprom", S_IRUSR, sc->debug.debugfs_phy, sc, |
| 1555 | &fops_modal_eeprom); |
Felix Fietkau | 691680b | 2011-03-19 13:55:38 +0100 | [diff] [blame] | 1556 | debugfs_create_u32("gpio_mask", S_IRUSR | S_IWUSR, |
| 1557 | sc->debug.debugfs_phy, &sc->sc_ah->gpio_mask); |
Felix Fietkau | 691680b | 2011-03-19 13:55:38 +0100 | [diff] [blame] | 1558 | debugfs_create_u32("gpio_val", S_IRUSR | S_IWUSR, |
| 1559 | sc->debug.debugfs_phy, &sc->sc_ah->gpio_val); |
Sujith Manoharan | 4eba10c | 2013-07-29 16:04:49 +0530 | [diff] [blame] | 1560 | debugfs_create_file("antenna_diversity", S_IRUSR, |
| 1561 | sc->debug.debugfs_phy, sc, &fops_antenna_diversity); |
Rajkumar Manoharan | 4df50ca | 2012-10-25 17:16:54 +0530 | [diff] [blame] | 1562 | #ifdef CONFIG_ATH9K_BTCOEX_SUPPORT |
Sujith Manoharan | 36e8825 | 2013-08-06 12:44:15 +0530 | [diff] [blame] | 1563 | debugfs_create_file("bt_ant_diversity", S_IRUSR | S_IWUSR, |
| 1564 | sc->debug.debugfs_phy, sc, &fops_bt_ant_diversity); |
Rajkumar Manoharan | 4df50ca | 2012-10-25 17:16:54 +0530 | [diff] [blame] | 1565 | debugfs_create_file("btcoex", S_IRUSR, sc->debug.debugfs_phy, sc, |
| 1566 | &fops_btcoex); |
| 1567 | #endif |
Luis R. Rodriguez | 89f927a | 2013-10-14 17:42:11 -0700 | [diff] [blame] | 1568 | |
Sujith | 826d268 | 2008-11-28 22:20:23 +0530 | [diff] [blame] | 1569 | return 0; |
Sujith | 88b126a | 2008-11-28 22:19:02 +0530 | [diff] [blame] | 1570 | } |