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> |
Simon Wunderlich | e93d083 | 2013-01-08 14:48:58 +0100 | [diff] [blame] | 20 | #include <linux/relay.h> |
Gabor Juhos | 5210311 | 2009-03-06 09:57:39 +0100 | [diff] [blame] | 21 | #include <asm/unaligned.h> |
| 22 | |
Sujith | 394cf0a | 2009-02-09 13:26:54 +0530 | [diff] [blame] | 23 | #include "ath9k.h" |
Sujith | 88b126a | 2008-11-28 22:19:02 +0530 | [diff] [blame] | 24 | |
Luis R. Rodriguez | 475a6e4 | 2009-09-23 23:06:59 -0400 | [diff] [blame] | 25 | #define REG_WRITE_D(_ah, _reg, _val) \ |
| 26 | ath9k_hw_common(_ah)->ops->write((_ah), (_val), (_reg)) |
| 27 | #define REG_READ_D(_ah, _reg) \ |
| 28 | ath9k_hw_common(_ah)->ops->read((_ah), (_reg)) |
| 29 | |
Sujith | 2a163c6 | 2008-11-28 22:21:08 +0530 | [diff] [blame] | 30 | |
Vasanthakumar Thiagarajan | 582d006 | 2011-03-01 05:30:55 -0800 | [diff] [blame] | 31 | static ssize_t ath9k_debugfs_read_buf(struct file *file, char __user *user_buf, |
| 32 | size_t count, loff_t *ppos) |
| 33 | { |
| 34 | u8 *buf = file->private_data; |
| 35 | return simple_read_from_buffer(user_buf, count, ppos, buf, strlen(buf)); |
| 36 | } |
| 37 | |
| 38 | static int ath9k_debugfs_release_buf(struct inode *inode, struct file *file) |
| 39 | { |
| 40 | vfree(file->private_data); |
| 41 | return 0; |
| 42 | } |
| 43 | |
Felix Fietkau | a830df0 | 2009-11-23 22:33:27 +0100 | [diff] [blame] | 44 | #ifdef CONFIG_ATH_DEBUG |
| 45 | |
Jeff Hansen | 2493928 | 2009-05-27 12:48:29 +0000 | [diff] [blame] | 46 | static ssize_t read_file_debug(struct file *file, char __user *user_buf, |
| 47 | size_t count, loff_t *ppos) |
| 48 | { |
| 49 | struct ath_softc *sc = file->private_data; |
Luis R. Rodriguez | c46917b | 2009-09-13 02:42:02 -0700 | [diff] [blame] | 50 | struct ath_common *common = ath9k_hw_common(sc->sc_ah); |
Jeff Hansen | 2493928 | 2009-05-27 12:48:29 +0000 | [diff] [blame] | 51 | char buf[32]; |
Vasanthakumar Thiagarajan | 581f725 | 2009-06-02 19:28:55 +0530 | [diff] [blame] | 52 | unsigned int len; |
| 53 | |
Dan Carpenter | 2b87f3a | 2010-05-14 15:24:37 +0200 | [diff] [blame] | 54 | len = sprintf(buf, "0x%08x\n", common->debug_mask); |
Jeff Hansen | 2493928 | 2009-05-27 12:48:29 +0000 | [diff] [blame] | 55 | return simple_read_from_buffer(user_buf, count, ppos, buf, len); |
| 56 | } |
| 57 | |
| 58 | static ssize_t write_file_debug(struct file *file, const char __user *user_buf, |
| 59 | size_t count, loff_t *ppos) |
| 60 | { |
| 61 | struct ath_softc *sc = file->private_data; |
Luis R. Rodriguez | c46917b | 2009-09-13 02:42:02 -0700 | [diff] [blame] | 62 | struct ath_common *common = ath9k_hw_common(sc->sc_ah); |
Jeff Hansen | 2493928 | 2009-05-27 12:48:29 +0000 | [diff] [blame] | 63 | unsigned long mask; |
| 64 | char buf[32]; |
Vasanthakumar Thiagarajan | 581f725 | 2009-06-02 19:28:55 +0530 | [diff] [blame] | 65 | ssize_t len; |
| 66 | |
| 67 | len = min(count, sizeof(buf) - 1); |
| 68 | if (copy_from_user(buf, user_buf, len)) |
Dan Carpenter | 0423606 | 2010-05-14 15:25:39 +0200 | [diff] [blame] | 69 | return -EFAULT; |
Vasanthakumar Thiagarajan | 581f725 | 2009-06-02 19:28:55 +0530 | [diff] [blame] | 70 | |
| 71 | buf[len] = '\0'; |
Jingoo Han | 27d7f47 | 2013-05-31 21:24:06 +0000 | [diff] [blame] | 72 | if (kstrtoul(buf, 0, &mask)) |
Vasanthakumar Thiagarajan | 581f725 | 2009-06-02 19:28:55 +0530 | [diff] [blame] | 73 | return -EINVAL; |
| 74 | |
Luis R. Rodriguez | c46917b | 2009-09-13 02:42:02 -0700 | [diff] [blame] | 75 | common->debug_mask = mask; |
Jeff Hansen | 2493928 | 2009-05-27 12:48:29 +0000 | [diff] [blame] | 76 | return count; |
| 77 | } |
| 78 | |
| 79 | static const struct file_operations fops_debug = { |
| 80 | .read = read_file_debug, |
| 81 | .write = write_file_debug, |
Stephen Boyd | 234e340 | 2012-04-05 14:25:11 -0700 | [diff] [blame] | 82 | .open = simple_open, |
Arnd Bergmann | 6038f37 | 2010-08-15 18:52:59 +0200 | [diff] [blame] | 83 | .owner = THIS_MODULE, |
| 84 | .llseek = default_llseek, |
Jeff Hansen | 2493928 | 2009-05-27 12:48:29 +0000 | [diff] [blame] | 85 | }; |
| 86 | |
Felix Fietkau | a830df0 | 2009-11-23 22:33:27 +0100 | [diff] [blame] | 87 | #endif |
| 88 | |
Pavel Roskin | 991a098 | 2010-01-29 17:22:26 -0500 | [diff] [blame] | 89 | #define DMA_BUF_LEN 1024 |
| 90 | |
Felix Fietkau | 1534069 | 2010-05-11 17:23:01 +0200 | [diff] [blame] | 91 | static ssize_t read_file_tx_chainmask(struct file *file, char __user *user_buf, |
| 92 | size_t count, loff_t *ppos) |
| 93 | { |
| 94 | struct ath_softc *sc = file->private_data; |
Felix Fietkau | 82b2d33 | 2011-09-03 01:40:23 +0200 | [diff] [blame] | 95 | struct ath_hw *ah = sc->sc_ah; |
Felix Fietkau | 1534069 | 2010-05-11 17:23:01 +0200 | [diff] [blame] | 96 | char buf[32]; |
| 97 | unsigned int len; |
| 98 | |
Felix Fietkau | 82b2d33 | 2011-09-03 01:40:23 +0200 | [diff] [blame] | 99 | len = sprintf(buf, "0x%08x\n", ah->txchainmask); |
Felix Fietkau | 1534069 | 2010-05-11 17:23:01 +0200 | [diff] [blame] | 100 | return simple_read_from_buffer(user_buf, count, ppos, buf, len); |
| 101 | } |
| 102 | |
| 103 | static ssize_t write_file_tx_chainmask(struct file *file, const char __user *user_buf, |
| 104 | size_t count, loff_t *ppos) |
| 105 | { |
| 106 | struct ath_softc *sc = file->private_data; |
Felix Fietkau | 82b2d33 | 2011-09-03 01:40:23 +0200 | [diff] [blame] | 107 | struct ath_hw *ah = sc->sc_ah; |
Felix Fietkau | 1534069 | 2010-05-11 17:23:01 +0200 | [diff] [blame] | 108 | unsigned long mask; |
| 109 | char buf[32]; |
| 110 | ssize_t len; |
| 111 | |
| 112 | len = min(count, sizeof(buf) - 1); |
| 113 | if (copy_from_user(buf, user_buf, len)) |
Dan Carpenter | 0423606 | 2010-05-14 15:25:39 +0200 | [diff] [blame] | 114 | return -EFAULT; |
Felix Fietkau | 1534069 | 2010-05-11 17:23:01 +0200 | [diff] [blame] | 115 | |
| 116 | buf[len] = '\0'; |
Jingoo Han | 27d7f47 | 2013-05-31 21:24:06 +0000 | [diff] [blame] | 117 | if (kstrtoul(buf, 0, &mask)) |
Felix Fietkau | 1534069 | 2010-05-11 17:23:01 +0200 | [diff] [blame] | 118 | return -EINVAL; |
| 119 | |
Felix Fietkau | 82b2d33 | 2011-09-03 01:40:23 +0200 | [diff] [blame] | 120 | ah->txchainmask = mask; |
| 121 | ah->caps.tx_chainmask = mask; |
Felix Fietkau | 1534069 | 2010-05-11 17:23:01 +0200 | [diff] [blame] | 122 | return count; |
| 123 | } |
| 124 | |
| 125 | static const struct file_operations fops_tx_chainmask = { |
| 126 | .read = read_file_tx_chainmask, |
| 127 | .write = write_file_tx_chainmask, |
Stephen Boyd | 234e340 | 2012-04-05 14:25:11 -0700 | [diff] [blame] | 128 | .open = simple_open, |
Arnd Bergmann | 6038f37 | 2010-08-15 18:52:59 +0200 | [diff] [blame] | 129 | .owner = THIS_MODULE, |
| 130 | .llseek = default_llseek, |
Felix Fietkau | 1534069 | 2010-05-11 17:23:01 +0200 | [diff] [blame] | 131 | }; |
| 132 | |
| 133 | |
| 134 | static ssize_t read_file_rx_chainmask(struct file *file, char __user *user_buf, |
| 135 | size_t count, loff_t *ppos) |
| 136 | { |
| 137 | struct ath_softc *sc = file->private_data; |
Felix Fietkau | 82b2d33 | 2011-09-03 01:40:23 +0200 | [diff] [blame] | 138 | struct ath_hw *ah = sc->sc_ah; |
Felix Fietkau | 1534069 | 2010-05-11 17:23:01 +0200 | [diff] [blame] | 139 | char buf[32]; |
| 140 | unsigned int len; |
| 141 | |
Felix Fietkau | 82b2d33 | 2011-09-03 01:40:23 +0200 | [diff] [blame] | 142 | len = sprintf(buf, "0x%08x\n", ah->rxchainmask); |
Felix Fietkau | 1534069 | 2010-05-11 17:23:01 +0200 | [diff] [blame] | 143 | return simple_read_from_buffer(user_buf, count, ppos, buf, len); |
| 144 | } |
| 145 | |
| 146 | static ssize_t write_file_rx_chainmask(struct file *file, const char __user *user_buf, |
| 147 | size_t count, loff_t *ppos) |
| 148 | { |
| 149 | struct ath_softc *sc = file->private_data; |
Felix Fietkau | 82b2d33 | 2011-09-03 01:40:23 +0200 | [diff] [blame] | 150 | struct ath_hw *ah = sc->sc_ah; |
Felix Fietkau | 1534069 | 2010-05-11 17:23:01 +0200 | [diff] [blame] | 151 | unsigned long mask; |
| 152 | char buf[32]; |
| 153 | ssize_t len; |
| 154 | |
| 155 | len = min(count, sizeof(buf) - 1); |
| 156 | if (copy_from_user(buf, user_buf, len)) |
Dan Carpenter | 0423606 | 2010-05-14 15:25:39 +0200 | [diff] [blame] | 157 | return -EFAULT; |
Felix Fietkau | 1534069 | 2010-05-11 17:23:01 +0200 | [diff] [blame] | 158 | |
| 159 | buf[len] = '\0'; |
Jingoo Han | 27d7f47 | 2013-05-31 21:24:06 +0000 | [diff] [blame] | 160 | if (kstrtoul(buf, 0, &mask)) |
Felix Fietkau | 1534069 | 2010-05-11 17:23:01 +0200 | [diff] [blame] | 161 | return -EINVAL; |
| 162 | |
Felix Fietkau | 82b2d33 | 2011-09-03 01:40:23 +0200 | [diff] [blame] | 163 | ah->rxchainmask = mask; |
| 164 | ah->caps.rx_chainmask = mask; |
Felix Fietkau | 1534069 | 2010-05-11 17:23:01 +0200 | [diff] [blame] | 165 | return count; |
| 166 | } |
| 167 | |
| 168 | static const struct file_operations fops_rx_chainmask = { |
| 169 | .read = read_file_rx_chainmask, |
| 170 | .write = write_file_rx_chainmask, |
Stephen Boyd | 234e340 | 2012-04-05 14:25:11 -0700 | [diff] [blame] | 171 | .open = simple_open, |
Arnd Bergmann | 6038f37 | 2010-08-15 18:52:59 +0200 | [diff] [blame] | 172 | .owner = THIS_MODULE, |
| 173 | .llseek = default_llseek, |
Felix Fietkau | 1534069 | 2010-05-11 17:23:01 +0200 | [diff] [blame] | 174 | }; |
| 175 | |
Sujith Manoharan | 6e4d291 | 2013-06-03 09:19:28 +0530 | [diff] [blame] | 176 | 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] | 177 | size_t count, loff_t *ppos) |
| 178 | { |
| 179 | struct ath_softc *sc = file->private_data; |
| 180 | struct ath_common *common = ath9k_hw_common(sc->sc_ah); |
Sujith Manoharan | 6e4d291 | 2013-06-03 09:19:28 +0530 | [diff] [blame] | 181 | struct ath_hw *ah = sc->sc_ah; |
| 182 | unsigned int len = 0, size = 1024; |
| 183 | ssize_t retval = 0; |
| 184 | char *buf; |
Mohammed Shafi Shajakhan | 05c0be2 | 2011-05-26 10:56:15 +0530 | [diff] [blame] | 185 | |
Sujith Manoharan | 6e4d291 | 2013-06-03 09:19:28 +0530 | [diff] [blame] | 186 | buf = kzalloc(size, GFP_KERNEL); |
| 187 | if (buf == NULL) |
| 188 | return -ENOMEM; |
| 189 | |
| 190 | if (common->disable_ani) { |
| 191 | len += snprintf(buf + len, size - len, "%s: %s\n", |
| 192 | "ANI", "DISABLED"); |
| 193 | goto exit; |
| 194 | } |
| 195 | |
| 196 | len += snprintf(buf + len, size - len, "%15s: %s\n", |
| 197 | "ANI", "ENABLED"); |
| 198 | len += snprintf(buf + len, size - len, "%15s: %u\n", |
| 199 | "ANI RESET", ah->stats.ast_ani_reset); |
| 200 | len += snprintf(buf + len, size - len, "%15s: %u\n", |
| 201 | "SPUR UP", ah->stats.ast_ani_spurup); |
| 202 | len += snprintf(buf + len, size - len, "%15s: %u\n", |
| 203 | "SPUR DOWN", ah->stats.ast_ani_spurup); |
| 204 | len += snprintf(buf + len, size - len, "%15s: %u\n", |
| 205 | "OFDM WS-DET ON", ah->stats.ast_ani_ofdmon); |
| 206 | len += snprintf(buf + len, size - len, "%15s: %u\n", |
| 207 | "OFDM WS-DET OFF", ah->stats.ast_ani_ofdmoff); |
| 208 | len += snprintf(buf + len, size - len, "%15s: %u\n", |
| 209 | "MRC-CCK ON", ah->stats.ast_ani_ccklow); |
| 210 | len += snprintf(buf + len, size - len, "%15s: %u\n", |
| 211 | "MRC-CCK OFF", ah->stats.ast_ani_cckhigh); |
| 212 | len += snprintf(buf + len, size - len, "%15s: %u\n", |
| 213 | "FIR-STEP UP", ah->stats.ast_ani_stepup); |
| 214 | len += snprintf(buf + len, size - len, "%15s: %u\n", |
| 215 | "FIR-STEP DOWN", ah->stats.ast_ani_stepdown); |
| 216 | len += snprintf(buf + len, size - len, "%15s: %u\n", |
| 217 | "INV LISTENTIME", ah->stats.ast_ani_lneg_or_lzero); |
| 218 | len += snprintf(buf + len, size - len, "%15s: %u\n", |
| 219 | "OFDM ERRORS", ah->stats.ast_ani_ofdmerrs); |
| 220 | len += snprintf(buf + len, size - len, "%15s: %u\n", |
| 221 | "CCK ERRORS", ah->stats.ast_ani_cckerrs); |
| 222 | exit: |
| 223 | if (len > size) |
| 224 | len = size; |
| 225 | |
| 226 | retval = simple_read_from_buffer(user_buf, count, ppos, buf, len); |
| 227 | kfree(buf); |
| 228 | |
| 229 | return retval; |
Mohammed Shafi Shajakhan | 05c0be2 | 2011-05-26 10:56:15 +0530 | [diff] [blame] | 230 | } |
| 231 | |
Sujith Manoharan | 6e4d291 | 2013-06-03 09:19:28 +0530 | [diff] [blame] | 232 | static ssize_t write_file_ani(struct file *file, |
| 233 | const char __user *user_buf, |
| 234 | size_t count, loff_t *ppos) |
Mohammed Shafi Shajakhan | 05c0be2 | 2011-05-26 10:56:15 +0530 | [diff] [blame] | 235 | { |
| 236 | struct ath_softc *sc = file->private_data; |
| 237 | struct ath_common *common = ath9k_hw_common(sc->sc_ah); |
Sujith Manoharan | 6e4d291 | 2013-06-03 09:19:28 +0530 | [diff] [blame] | 238 | unsigned long ani; |
Mohammed Shafi Shajakhan | 05c0be2 | 2011-05-26 10:56:15 +0530 | [diff] [blame] | 239 | char buf[32]; |
| 240 | ssize_t len; |
| 241 | |
| 242 | len = min(count, sizeof(buf) - 1); |
| 243 | if (copy_from_user(buf, user_buf, len)) |
| 244 | return -EFAULT; |
| 245 | |
| 246 | buf[len] = '\0'; |
John W. Linville | 3899ba9 | 2013-06-11 14:48:32 -0400 | [diff] [blame] | 247 | if (kstrtoul(buf, 0, &ani)) |
Mohammed Shafi Shajakhan | 05c0be2 | 2011-05-26 10:56:15 +0530 | [diff] [blame] | 248 | return -EINVAL; |
| 249 | |
Sujith Manoharan | 6e4d291 | 2013-06-03 09:19:28 +0530 | [diff] [blame] | 250 | if (ani < 0 || ani > 1) |
| 251 | return -EINVAL; |
Mohammed Shafi Shajakhan | 05c0be2 | 2011-05-26 10:56:15 +0530 | [diff] [blame] | 252 | |
Sujith Manoharan | 6e4d291 | 2013-06-03 09:19:28 +0530 | [diff] [blame] | 253 | common->disable_ani = !ani; |
| 254 | |
| 255 | if (common->disable_ani) { |
Sujith Manoharan | 781b14a | 2012-06-04 20:23:55 +0530 | [diff] [blame] | 256 | clear_bit(SC_OP_ANI_RUN, &sc->sc_flags); |
Sujith Manoharan | da0d45f | 2012-07-17 17:16:29 +0530 | [diff] [blame] | 257 | ath_stop_ani(sc); |
Mohammed Shafi Shajakhan | 05c0be2 | 2011-05-26 10:56:15 +0530 | [diff] [blame] | 258 | } else { |
Sujith Manoharan | da0d45f | 2012-07-17 17:16:29 +0530 | [diff] [blame] | 259 | ath_check_ani(sc); |
Mohammed Shafi Shajakhan | 05c0be2 | 2011-05-26 10:56:15 +0530 | [diff] [blame] | 260 | } |
| 261 | |
| 262 | return count; |
| 263 | } |
| 264 | |
Sujith Manoharan | 6e4d291 | 2013-06-03 09:19:28 +0530 | [diff] [blame] | 265 | static const struct file_operations fops_ani = { |
| 266 | .read = read_file_ani, |
| 267 | .write = write_file_ani, |
Stephen Boyd | 234e340 | 2012-04-05 14:25:11 -0700 | [diff] [blame] | 268 | .open = simple_open, |
Mohammed Shafi Shajakhan | 05c0be2 | 2011-05-26 10:56:15 +0530 | [diff] [blame] | 269 | .owner = THIS_MODULE, |
| 270 | .llseek = default_llseek, |
| 271 | }; |
Felix Fietkau | 1534069 | 2010-05-11 17:23:01 +0200 | [diff] [blame] | 272 | |
Sujith Manoharan | 6308130 | 2013-08-04 14:21:55 +0530 | [diff] [blame^] | 273 | static ssize_t read_file_bt_ant_diversity(struct file *file, |
| 274 | char __user *user_buf, |
| 275 | size_t count, loff_t *ppos) |
Sujith Manoharan | 302a3c3 | 2012-09-26 07:55:18 +0530 | [diff] [blame] | 276 | { |
| 277 | struct ath_softc *sc = file->private_data; |
| 278 | struct ath_common *common = ath9k_hw_common(sc->sc_ah); |
| 279 | char buf[32]; |
| 280 | unsigned int len; |
| 281 | |
Sujith Manoharan | 6308130 | 2013-08-04 14:21:55 +0530 | [diff] [blame^] | 282 | len = sprintf(buf, "%d\n", common->bt_ant_diversity); |
Sujith Manoharan | 302a3c3 | 2012-09-26 07:55:18 +0530 | [diff] [blame] | 283 | return simple_read_from_buffer(user_buf, count, ppos, buf, len); |
| 284 | } |
| 285 | |
Sujith Manoharan | 6308130 | 2013-08-04 14:21:55 +0530 | [diff] [blame^] | 286 | static ssize_t write_file_bt_ant_diversity(struct file *file, |
| 287 | const char __user *user_buf, |
| 288 | size_t count, loff_t *ppos) |
Sujith Manoharan | 302a3c3 | 2012-09-26 07:55:18 +0530 | [diff] [blame] | 289 | { |
| 290 | struct ath_softc *sc = file->private_data; |
| 291 | struct ath_common *common = ath9k_hw_common(sc->sc_ah); |
Sujith Manoharan | 6308130 | 2013-08-04 14:21:55 +0530 | [diff] [blame^] | 292 | unsigned long bt_ant_diversity; |
Sujith Manoharan | 302a3c3 | 2012-09-26 07:55:18 +0530 | [diff] [blame] | 293 | char buf[32]; |
| 294 | ssize_t len; |
| 295 | |
| 296 | len = min(count, sizeof(buf) - 1); |
| 297 | if (copy_from_user(buf, user_buf, len)) |
| 298 | return -EFAULT; |
| 299 | |
Sujith Manoharan | 302a3c3 | 2012-09-26 07:55:18 +0530 | [diff] [blame] | 300 | buf[len] = '\0'; |
Sujith Manoharan | 6308130 | 2013-08-04 14:21:55 +0530 | [diff] [blame^] | 301 | if (kstrtoul(buf, 0, &bt_ant_diversity)) |
Sujith Manoharan | 302a3c3 | 2012-09-26 07:55:18 +0530 | [diff] [blame] | 302 | return -EINVAL; |
| 303 | |
Sujith Manoharan | 6308130 | 2013-08-04 14:21:55 +0530 | [diff] [blame^] | 304 | common->bt_ant_diversity = !!bt_ant_diversity; |
Sujith Manoharan | 302a3c3 | 2012-09-26 07:55:18 +0530 | [diff] [blame] | 305 | ath9k_ps_wakeup(sc); |
| 306 | ath_ant_comb_update(sc); |
Sujith Manoharan | 6308130 | 2013-08-04 14:21:55 +0530 | [diff] [blame^] | 307 | ath_dbg(common, CONFIG, "Enable WLAN/BT RX Antenna diversity: %d\n", |
| 308 | common->bt_ant_diversity); |
Sujith Manoharan | 302a3c3 | 2012-09-26 07:55:18 +0530 | [diff] [blame] | 309 | ath9k_ps_restore(sc); |
Sujith Manoharan | 6308130 | 2013-08-04 14:21:55 +0530 | [diff] [blame^] | 310 | |
Sujith Manoharan | 302a3c3 | 2012-09-26 07:55:18 +0530 | [diff] [blame] | 311 | return count; |
| 312 | } |
| 313 | |
Sujith Manoharan | 6308130 | 2013-08-04 14:21:55 +0530 | [diff] [blame^] | 314 | static const struct file_operations fops_bt_ant_diversity = { |
| 315 | .read = read_file_bt_ant_diversity, |
| 316 | .write = write_file_bt_ant_diversity, |
Sujith Manoharan | 302a3c3 | 2012-09-26 07:55:18 +0530 | [diff] [blame] | 317 | .open = simple_open, |
| 318 | .owner = THIS_MODULE, |
| 319 | .llseek = default_llseek, |
| 320 | }; |
| 321 | |
Sujith Manoharan | e3d5291 | 2013-08-01 20:57:06 +0530 | [diff] [blame] | 322 | void ath9k_debug_stat_ant(struct ath_softc *sc, |
| 323 | struct ath_hw_antcomb_conf *div_ant_conf, |
| 324 | int main_rssi_avg, int alt_rssi_avg) |
| 325 | { |
| 326 | struct ath_antenna_stats *as_main = &sc->debug.stats.ant_stats[ANT_MAIN]; |
| 327 | struct ath_antenna_stats *as_alt = &sc->debug.stats.ant_stats[ANT_ALT]; |
| 328 | |
| 329 | as_main->lna_attempt_cnt[div_ant_conf->main_lna_conf]++; |
| 330 | as_alt->lna_attempt_cnt[div_ant_conf->alt_lna_conf]++; |
| 331 | |
| 332 | as_main->rssi_avg = main_rssi_avg; |
| 333 | as_alt->rssi_avg = alt_rssi_avg; |
| 334 | } |
| 335 | |
Sujith Manoharan | 4eba10c | 2013-07-29 16:04:49 +0530 | [diff] [blame] | 336 | static ssize_t read_file_antenna_diversity(struct file *file, |
| 337 | char __user *user_buf, |
| 338 | size_t count, loff_t *ppos) |
| 339 | { |
| 340 | struct ath_softc *sc = file->private_data; |
| 341 | struct ath_hw *ah = sc->sc_ah; |
| 342 | struct ath9k_hw_capabilities *pCap = &ah->caps; |
| 343 | struct ath_antenna_stats *as_main = &sc->debug.stats.ant_stats[ANT_MAIN]; |
| 344 | 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] | 345 | struct ath_hw_antcomb_conf div_ant_conf; |
Sujith Manoharan | 4eba10c | 2013-07-29 16:04:49 +0530 | [diff] [blame] | 346 | unsigned int len = 0, size = 1024; |
| 347 | ssize_t retval = 0; |
| 348 | char *buf; |
Sujith Manoharan | e3d5291 | 2013-08-01 20:57:06 +0530 | [diff] [blame] | 349 | char *lna_conf_str[4] = {"LNA1_MINUS_LNA2", |
| 350 | "LNA2", |
| 351 | "LNA1", |
| 352 | "LNA1_PLUS_LNA2"}; |
Sujith Manoharan | 4eba10c | 2013-07-29 16:04:49 +0530 | [diff] [blame] | 353 | |
| 354 | buf = kzalloc(size, GFP_KERNEL); |
| 355 | if (buf == NULL) |
| 356 | return -ENOMEM; |
| 357 | |
| 358 | if (!(pCap->hw_caps & ATH9K_HW_CAP_ANT_DIV_COMB)) { |
| 359 | len += snprintf(buf + len, size - len, "%s\n", |
| 360 | "Antenna Diversity Combining is disabled"); |
| 361 | goto exit; |
| 362 | } |
| 363 | |
Sujith Manoharan | e3d5291 | 2013-08-01 20:57:06 +0530 | [diff] [blame] | 364 | ath9k_ps_wakeup(sc); |
| 365 | ath9k_hw_antdiv_comb_conf_get(ah, &div_ant_conf); |
| 366 | len += snprintf(buf + len, size - len, "Current MAIN config : %s\n", |
| 367 | lna_conf_str[div_ant_conf.main_lna_conf]); |
| 368 | len += snprintf(buf + len, size - len, "Current ALT config : %s\n", |
| 369 | lna_conf_str[div_ant_conf.alt_lna_conf]); |
| 370 | len += snprintf(buf + len, size - len, "Average MAIN RSSI : %d\n", |
| 371 | as_main->rssi_avg); |
| 372 | len += snprintf(buf + len, size - len, "Average ALT RSSI : %d\n\n", |
| 373 | as_alt->rssi_avg); |
| 374 | ath9k_ps_restore(sc); |
| 375 | |
| 376 | len += snprintf(buf + len, size - len, "Packet Receive Cnt:\n"); |
| 377 | len += snprintf(buf + len, size - len, "-------------------\n"); |
| 378 | |
Sujith Manoharan | 4eba10c | 2013-07-29 16:04:49 +0530 | [diff] [blame] | 379 | len += snprintf(buf + len, size - len, "%30s%15s\n", |
| 380 | "MAIN", "ALT"); |
Sujith Manoharan | e3d5291 | 2013-08-01 20:57:06 +0530 | [diff] [blame] | 381 | len += snprintf(buf + len, size - len, "%-14s:%15d%15d\n", |
| 382 | "TOTAL COUNT", |
Sujith Manoharan | 4eba10c | 2013-07-29 16:04:49 +0530 | [diff] [blame] | 383 | as_main->recv_cnt, |
| 384 | as_alt->recv_cnt); |
Sujith Manoharan | e3d5291 | 2013-08-01 20:57:06 +0530 | [diff] [blame] | 385 | len += snprintf(buf + len, size - len, "%-14s:%15d%15d\n", |
Sujith Manoharan | 4eba10c | 2013-07-29 16:04:49 +0530 | [diff] [blame] | 386 | "LNA1", |
Sujith Manoharan | e3d5291 | 2013-08-01 20:57:06 +0530 | [diff] [blame] | 387 | as_main->lna_recv_cnt[ATH_ANT_DIV_COMB_LNA1], |
| 388 | as_alt->lna_recv_cnt[ATH_ANT_DIV_COMB_LNA1]); |
| 389 | len += snprintf(buf + len, size - len, "%-14s:%15d%15d\n", |
Sujith Manoharan | 4eba10c | 2013-07-29 16:04:49 +0530 | [diff] [blame] | 390 | "LNA2", |
Sujith Manoharan | e3d5291 | 2013-08-01 20:57:06 +0530 | [diff] [blame] | 391 | as_main->lna_recv_cnt[ATH_ANT_DIV_COMB_LNA2], |
| 392 | as_alt->lna_recv_cnt[ATH_ANT_DIV_COMB_LNA2]); |
| 393 | len += snprintf(buf + len, size - len, "%-14s:%15d%15d\n", |
Sujith Manoharan | 4eba10c | 2013-07-29 16:04:49 +0530 | [diff] [blame] | 394 | "LNA1 + LNA2", |
Sujith Manoharan | e3d5291 | 2013-08-01 20:57:06 +0530 | [diff] [blame] | 395 | as_main->lna_recv_cnt[ATH_ANT_DIV_COMB_LNA1_PLUS_LNA2], |
| 396 | as_alt->lna_recv_cnt[ATH_ANT_DIV_COMB_LNA1_PLUS_LNA2]); |
| 397 | len += snprintf(buf + len, size - len, "%-14s:%15d%15d\n", |
Sujith Manoharan | 4eba10c | 2013-07-29 16:04:49 +0530 | [diff] [blame] | 398 | "LNA1 - LNA2", |
Sujith Manoharan | e3d5291 | 2013-08-01 20:57:06 +0530 | [diff] [blame] | 399 | as_main->lna_recv_cnt[ATH_ANT_DIV_COMB_LNA1_MINUS_LNA2], |
| 400 | as_alt->lna_recv_cnt[ATH_ANT_DIV_COMB_LNA1_MINUS_LNA2]); |
| 401 | |
| 402 | len += snprintf(buf + len, size - len, "\nLNA Config Attempts:\n"); |
| 403 | len += snprintf(buf + len, size - len, "--------------------\n"); |
| 404 | |
| 405 | len += snprintf(buf + len, size - len, "%30s%15s\n", |
| 406 | "MAIN", "ALT"); |
| 407 | len += snprintf(buf + len, size - len, "%-14s:%15d%15d\n", |
| 408 | "LNA1", |
| 409 | as_main->lna_attempt_cnt[ATH_ANT_DIV_COMB_LNA1], |
| 410 | as_alt->lna_attempt_cnt[ATH_ANT_DIV_COMB_LNA1]); |
| 411 | len += snprintf(buf + len, size - len, "%-14s:%15d%15d\n", |
| 412 | "LNA2", |
| 413 | as_main->lna_attempt_cnt[ATH_ANT_DIV_COMB_LNA2], |
| 414 | as_alt->lna_attempt_cnt[ATH_ANT_DIV_COMB_LNA2]); |
| 415 | len += snprintf(buf + len, size - len, "%-14s:%15d%15d\n", |
| 416 | "LNA1 + LNA2", |
| 417 | as_main->lna_attempt_cnt[ATH_ANT_DIV_COMB_LNA1_PLUS_LNA2], |
| 418 | as_alt->lna_attempt_cnt[ATH_ANT_DIV_COMB_LNA1_PLUS_LNA2]); |
| 419 | len += snprintf(buf + len, size - len, "%-14s:%15d%15d\n", |
| 420 | "LNA1 - LNA2", |
| 421 | as_main->lna_attempt_cnt[ATH_ANT_DIV_COMB_LNA1_MINUS_LNA2], |
| 422 | as_alt->lna_attempt_cnt[ATH_ANT_DIV_COMB_LNA1_MINUS_LNA2]); |
| 423 | |
Sujith Manoharan | 4eba10c | 2013-07-29 16:04:49 +0530 | [diff] [blame] | 424 | exit: |
| 425 | if (len > size) |
| 426 | len = size; |
| 427 | |
| 428 | retval = simple_read_from_buffer(user_buf, count, ppos, buf, len); |
| 429 | kfree(buf); |
| 430 | |
| 431 | return retval; |
| 432 | } |
| 433 | |
| 434 | static const struct file_operations fops_antenna_diversity = { |
| 435 | .read = read_file_antenna_diversity, |
| 436 | .open = simple_open, |
| 437 | .owner = THIS_MODULE, |
| 438 | .llseek = default_llseek, |
| 439 | }; |
| 440 | |
Sujith | 2a163c6 | 2008-11-28 22:21:08 +0530 | [diff] [blame] | 441 | static ssize_t read_file_dma(struct file *file, char __user *user_buf, |
| 442 | size_t count, loff_t *ppos) |
| 443 | { |
| 444 | struct ath_softc *sc = file->private_data; |
Sujith | cbe61d8 | 2009-02-09 13:27:12 +0530 | [diff] [blame] | 445 | struct ath_hw *ah = sc->sc_ah; |
Pavel Roskin | 991a098 | 2010-01-29 17:22:26 -0500 | [diff] [blame] | 446 | char *buf; |
| 447 | int retval; |
Sujith | 2a163c6 | 2008-11-28 22:21:08 +0530 | [diff] [blame] | 448 | unsigned int len = 0; |
| 449 | u32 val[ATH9K_NUM_DMA_DEBUG_REGS]; |
| 450 | int i, qcuOffset = 0, dcuOffset = 0; |
| 451 | u32 *qcuBase = &val[0], *dcuBase = &val[4]; |
| 452 | |
Pavel Roskin | 991a098 | 2010-01-29 17:22:26 -0500 | [diff] [blame] | 453 | buf = kmalloc(DMA_BUF_LEN, GFP_KERNEL); |
| 454 | if (!buf) |
Dan Carpenter | 0423606 | 2010-05-14 15:25:39 +0200 | [diff] [blame] | 455 | return -ENOMEM; |
Pavel Roskin | 991a098 | 2010-01-29 17:22:26 -0500 | [diff] [blame] | 456 | |
Sujith | 7cf4a2e | 2009-08-26 11:11:57 +0530 | [diff] [blame] | 457 | ath9k_ps_wakeup(sc); |
| 458 | |
Luis R. Rodriguez | 475a6e4 | 2009-09-23 23:06:59 -0400 | [diff] [blame] | 459 | REG_WRITE_D(ah, AR_MACMISC, |
Sujith | 2a163c6 | 2008-11-28 22:21:08 +0530 | [diff] [blame] | 460 | ((AR_MACMISC_DMA_OBS_LINE_8 << AR_MACMISC_DMA_OBS_S) | |
| 461 | (AR_MACMISC_MISC_OBS_BUS_1 << |
| 462 | AR_MACMISC_MISC_OBS_BUS_MSB_S))); |
| 463 | |
Pavel Roskin | 991a098 | 2010-01-29 17:22:26 -0500 | [diff] [blame] | 464 | len += snprintf(buf + len, DMA_BUF_LEN - len, |
Sujith | 2a163c6 | 2008-11-28 22:21:08 +0530 | [diff] [blame] | 465 | "Raw DMA Debug values:\n"); |
| 466 | |
| 467 | for (i = 0; i < ATH9K_NUM_DMA_DEBUG_REGS; i++) { |
| 468 | if (i % 4 == 0) |
Pavel Roskin | 991a098 | 2010-01-29 17:22:26 -0500 | [diff] [blame] | 469 | len += snprintf(buf + len, DMA_BUF_LEN - len, "\n"); |
Sujith | 2a163c6 | 2008-11-28 22:21:08 +0530 | [diff] [blame] | 470 | |
Luis R. Rodriguez | 475a6e4 | 2009-09-23 23:06:59 -0400 | [diff] [blame] | 471 | val[i] = REG_READ_D(ah, AR_DMADBG_0 + (i * sizeof(u32))); |
Pavel Roskin | 991a098 | 2010-01-29 17:22:26 -0500 | [diff] [blame] | 472 | len += snprintf(buf + len, DMA_BUF_LEN - len, "%d: %08x ", |
Sujith | 2a163c6 | 2008-11-28 22:21:08 +0530 | [diff] [blame] | 473 | i, val[i]); |
| 474 | } |
| 475 | |
Pavel Roskin | 991a098 | 2010-01-29 17:22:26 -0500 | [diff] [blame] | 476 | len += snprintf(buf + len, DMA_BUF_LEN - len, "\n\n"); |
| 477 | len += snprintf(buf + len, DMA_BUF_LEN - len, |
Sujith | 2a163c6 | 2008-11-28 22:21:08 +0530 | [diff] [blame] | 478 | "Num QCU: chain_st fsp_ok fsp_st DCU: chain_st\n"); |
| 479 | |
| 480 | for (i = 0; i < ATH9K_NUM_QUEUES; i++, qcuOffset += 4, dcuOffset += 5) { |
| 481 | if (i == 8) { |
| 482 | qcuOffset = 0; |
| 483 | qcuBase++; |
| 484 | } |
| 485 | |
| 486 | if (i == 6) { |
| 487 | dcuOffset = 0; |
| 488 | dcuBase++; |
| 489 | } |
| 490 | |
Pavel Roskin | 991a098 | 2010-01-29 17:22:26 -0500 | [diff] [blame] | 491 | len += snprintf(buf + len, DMA_BUF_LEN - len, |
Sujith | 2a163c6 | 2008-11-28 22:21:08 +0530 | [diff] [blame] | 492 | "%2d %2x %1x %2x %2x\n", |
| 493 | i, (*qcuBase & (0x7 << qcuOffset)) >> qcuOffset, |
| 494 | (*qcuBase & (0x8 << qcuOffset)) >> (qcuOffset + 3), |
| 495 | val[2] & (0x7 << (i * 3)) >> (i * 3), |
| 496 | (*dcuBase & (0x1f << dcuOffset)) >> dcuOffset); |
| 497 | } |
| 498 | |
Pavel Roskin | 991a098 | 2010-01-29 17:22:26 -0500 | [diff] [blame] | 499 | len += snprintf(buf + len, DMA_BUF_LEN - len, "\n"); |
Sujith | 2a163c6 | 2008-11-28 22:21:08 +0530 | [diff] [blame] | 500 | |
Pavel Roskin | 991a098 | 2010-01-29 17:22:26 -0500 | [diff] [blame] | 501 | len += snprintf(buf + len, DMA_BUF_LEN - len, |
Sujith | 2a163c6 | 2008-11-28 22:21:08 +0530 | [diff] [blame] | 502 | "qcu_stitch state: %2x qcu_fetch state: %2x\n", |
| 503 | (val[3] & 0x003c0000) >> 18, (val[3] & 0x03c00000) >> 22); |
Pavel Roskin | 991a098 | 2010-01-29 17:22:26 -0500 | [diff] [blame] | 504 | len += snprintf(buf + len, DMA_BUF_LEN - len, |
Sujith | 2a163c6 | 2008-11-28 22:21:08 +0530 | [diff] [blame] | 505 | "qcu_complete state: %2x dcu_complete state: %2x\n", |
| 506 | (val[3] & 0x1c000000) >> 26, (val[6] & 0x3)); |
Pavel Roskin | 991a098 | 2010-01-29 17:22:26 -0500 | [diff] [blame] | 507 | len += snprintf(buf + len, DMA_BUF_LEN - len, |
Sujith | 2a163c6 | 2008-11-28 22:21:08 +0530 | [diff] [blame] | 508 | "dcu_arb state: %2x dcu_fp state: %2x\n", |
| 509 | (val[5] & 0x06000000) >> 25, (val[5] & 0x38000000) >> 27); |
Pavel Roskin | 991a098 | 2010-01-29 17:22:26 -0500 | [diff] [blame] | 510 | len += snprintf(buf + len, DMA_BUF_LEN - len, |
Sujith | 2a163c6 | 2008-11-28 22:21:08 +0530 | [diff] [blame] | 511 | "chan_idle_dur: %3d chan_idle_dur_valid: %1d\n", |
| 512 | (val[6] & 0x000003fc) >> 2, (val[6] & 0x00000400) >> 10); |
Pavel Roskin | 991a098 | 2010-01-29 17:22:26 -0500 | [diff] [blame] | 513 | len += snprintf(buf + len, DMA_BUF_LEN - len, |
Sujith | 2a163c6 | 2008-11-28 22:21:08 +0530 | [diff] [blame] | 514 | "txfifo_valid_0: %1d txfifo_valid_1: %1d\n", |
| 515 | (val[6] & 0x00000800) >> 11, (val[6] & 0x00001000) >> 12); |
Pavel Roskin | 991a098 | 2010-01-29 17:22:26 -0500 | [diff] [blame] | 516 | len += snprintf(buf + len, DMA_BUF_LEN - len, |
Sujith | 2a163c6 | 2008-11-28 22:21:08 +0530 | [diff] [blame] | 517 | "txfifo_dcu_num_0: %2d txfifo_dcu_num_1: %2d\n", |
| 518 | (val[6] & 0x0001e000) >> 13, (val[6] & 0x001e0000) >> 17); |
| 519 | |
Frans Pop | 60ece40 | 2010-03-24 19:46:30 +0100 | [diff] [blame] | 520 | len += snprintf(buf + len, DMA_BUF_LEN - len, "pcu observe: 0x%x\n", |
Luis R. Rodriguez | 475a6e4 | 2009-09-23 23:06:59 -0400 | [diff] [blame] | 521 | REG_READ_D(ah, AR_OBS_BUS_1)); |
Pavel Roskin | 991a098 | 2010-01-29 17:22:26 -0500 | [diff] [blame] | 522 | len += snprintf(buf + len, DMA_BUF_LEN - len, |
Frans Pop | 60ece40 | 2010-03-24 19:46:30 +0100 | [diff] [blame] | 523 | "AR_CR: 0x%x\n", REG_READ_D(ah, AR_CR)); |
Sujith | 2a163c6 | 2008-11-28 22:21:08 +0530 | [diff] [blame] | 524 | |
Sujith | 7cf4a2e | 2009-08-26 11:11:57 +0530 | [diff] [blame] | 525 | ath9k_ps_restore(sc); |
| 526 | |
Dan Carpenter | 2b87f3a | 2010-05-14 15:24:37 +0200 | [diff] [blame] | 527 | if (len > DMA_BUF_LEN) |
| 528 | len = DMA_BUF_LEN; |
| 529 | |
Pavel Roskin | 991a098 | 2010-01-29 17:22:26 -0500 | [diff] [blame] | 530 | retval = simple_read_from_buffer(user_buf, count, ppos, buf, len); |
| 531 | kfree(buf); |
| 532 | return retval; |
Sujith | 2a163c6 | 2008-11-28 22:21:08 +0530 | [diff] [blame] | 533 | } |
| 534 | |
| 535 | static const struct file_operations fops_dma = { |
| 536 | .read = read_file_dma, |
Stephen Boyd | 234e340 | 2012-04-05 14:25:11 -0700 | [diff] [blame] | 537 | .open = simple_open, |
Arnd Bergmann | 6038f37 | 2010-08-15 18:52:59 +0200 | [diff] [blame] | 538 | .owner = THIS_MODULE, |
| 539 | .llseek = default_llseek, |
Sujith | 2a163c6 | 2008-11-28 22:21:08 +0530 | [diff] [blame] | 540 | }; |
| 541 | |
Sujith | 817e11d | 2008-12-07 21:42:44 +0530 | [diff] [blame] | 542 | |
| 543 | void ath_debug_stat_interrupt(struct ath_softc *sc, enum ath9k_int status) |
| 544 | { |
| 545 | if (status) |
Sujith | 17d7904 | 2009-02-09 13:27:03 +0530 | [diff] [blame] | 546 | sc->debug.stats.istats.total++; |
Luis R. Rodriguez | a9616f4 | 2010-04-15 17:39:30 -0400 | [diff] [blame] | 547 | if (sc->sc_ah->caps.hw_caps & ATH9K_HW_CAP_EDMA) { |
| 548 | if (status & ATH9K_INT_RXLP) |
| 549 | sc->debug.stats.istats.rxlp++; |
| 550 | if (status & ATH9K_INT_RXHP) |
| 551 | sc->debug.stats.istats.rxhp++; |
Luis R. Rodriguez | 08578b8 | 2010-05-13 13:33:44 -0400 | [diff] [blame] | 552 | if (status & ATH9K_INT_BB_WATCHDOG) |
| 553 | sc->debug.stats.istats.bb_watchdog++; |
Luis R. Rodriguez | a9616f4 | 2010-04-15 17:39:30 -0400 | [diff] [blame] | 554 | } else { |
| 555 | if (status & ATH9K_INT_RX) |
| 556 | sc->debug.stats.istats.rxok++; |
| 557 | } |
Sujith | 817e11d | 2008-12-07 21:42:44 +0530 | [diff] [blame] | 558 | if (status & ATH9K_INT_RXEOL) |
Sujith | 17d7904 | 2009-02-09 13:27:03 +0530 | [diff] [blame] | 559 | sc->debug.stats.istats.rxeol++; |
Sujith | 817e11d | 2008-12-07 21:42:44 +0530 | [diff] [blame] | 560 | if (status & ATH9K_INT_RXORN) |
Sujith | 17d7904 | 2009-02-09 13:27:03 +0530 | [diff] [blame] | 561 | sc->debug.stats.istats.rxorn++; |
Sujith | 817e11d | 2008-12-07 21:42:44 +0530 | [diff] [blame] | 562 | if (status & ATH9K_INT_TX) |
Sujith | 17d7904 | 2009-02-09 13:27:03 +0530 | [diff] [blame] | 563 | sc->debug.stats.istats.txok++; |
Sujith | 817e11d | 2008-12-07 21:42:44 +0530 | [diff] [blame] | 564 | if (status & ATH9K_INT_TXURN) |
Sujith | 17d7904 | 2009-02-09 13:27:03 +0530 | [diff] [blame] | 565 | sc->debug.stats.istats.txurn++; |
Sujith | 817e11d | 2008-12-07 21:42:44 +0530 | [diff] [blame] | 566 | if (status & ATH9K_INT_RXPHY) |
Sujith | 17d7904 | 2009-02-09 13:27:03 +0530 | [diff] [blame] | 567 | sc->debug.stats.istats.rxphyerr++; |
Sujith | 817e11d | 2008-12-07 21:42:44 +0530 | [diff] [blame] | 568 | if (status & ATH9K_INT_RXKCM) |
Sujith | 17d7904 | 2009-02-09 13:27:03 +0530 | [diff] [blame] | 569 | sc->debug.stats.istats.rx_keycache_miss++; |
Sujith | 817e11d | 2008-12-07 21:42:44 +0530 | [diff] [blame] | 570 | if (status & ATH9K_INT_SWBA) |
Sujith | 17d7904 | 2009-02-09 13:27:03 +0530 | [diff] [blame] | 571 | sc->debug.stats.istats.swba++; |
Sujith | 817e11d | 2008-12-07 21:42:44 +0530 | [diff] [blame] | 572 | if (status & ATH9K_INT_BMISS) |
Sujith | 17d7904 | 2009-02-09 13:27:03 +0530 | [diff] [blame] | 573 | sc->debug.stats.istats.bmiss++; |
Sujith | 817e11d | 2008-12-07 21:42:44 +0530 | [diff] [blame] | 574 | if (status & ATH9K_INT_BNR) |
Sujith | 17d7904 | 2009-02-09 13:27:03 +0530 | [diff] [blame] | 575 | sc->debug.stats.istats.bnr++; |
Sujith | 817e11d | 2008-12-07 21:42:44 +0530 | [diff] [blame] | 576 | if (status & ATH9K_INT_CST) |
Sujith | 17d7904 | 2009-02-09 13:27:03 +0530 | [diff] [blame] | 577 | sc->debug.stats.istats.cst++; |
Sujith | 817e11d | 2008-12-07 21:42:44 +0530 | [diff] [blame] | 578 | if (status & ATH9K_INT_GTT) |
Sujith | 17d7904 | 2009-02-09 13:27:03 +0530 | [diff] [blame] | 579 | sc->debug.stats.istats.gtt++; |
Sujith | 817e11d | 2008-12-07 21:42:44 +0530 | [diff] [blame] | 580 | if (status & ATH9K_INT_TIM) |
Sujith | 17d7904 | 2009-02-09 13:27:03 +0530 | [diff] [blame] | 581 | sc->debug.stats.istats.tim++; |
Sujith | 817e11d | 2008-12-07 21:42:44 +0530 | [diff] [blame] | 582 | if (status & ATH9K_INT_CABEND) |
Sujith | 17d7904 | 2009-02-09 13:27:03 +0530 | [diff] [blame] | 583 | sc->debug.stats.istats.cabend++; |
Sujith | 817e11d | 2008-12-07 21:42:44 +0530 | [diff] [blame] | 584 | if (status & ATH9K_INT_DTIMSYNC) |
Sujith | 17d7904 | 2009-02-09 13:27:03 +0530 | [diff] [blame] | 585 | sc->debug.stats.istats.dtimsync++; |
Sujith | 817e11d | 2008-12-07 21:42:44 +0530 | [diff] [blame] | 586 | if (status & ATH9K_INT_DTIM) |
Sujith | 17d7904 | 2009-02-09 13:27:03 +0530 | [diff] [blame] | 587 | sc->debug.stats.istats.dtim++; |
Mohammed Shafi Shajakhan | 6dde1aa | 2011-04-22 17:27:01 +0530 | [diff] [blame] | 588 | if (status & ATH9K_INT_TSFOOR) |
| 589 | sc->debug.stats.istats.tsfoor++; |
Sujith Manoharan | 97ba515 | 2012-06-04 16:27:41 +0530 | [diff] [blame] | 590 | if (status & ATH9K_INT_MCI) |
| 591 | sc->debug.stats.istats.mci++; |
Mohammed Shafi Shajakhan | c9e6e98 | 2012-09-07 15:54:13 +0530 | [diff] [blame] | 592 | if (status & ATH9K_INT_GENTIMER) |
| 593 | sc->debug.stats.istats.gen_timer++; |
Sujith | 817e11d | 2008-12-07 21:42:44 +0530 | [diff] [blame] | 594 | } |
| 595 | |
| 596 | static ssize_t read_file_interrupt(struct file *file, char __user *user_buf, |
| 597 | size_t count, loff_t *ppos) |
| 598 | { |
| 599 | struct ath_softc *sc = file->private_data; |
Sujith | 817e11d | 2008-12-07 21:42:44 +0530 | [diff] [blame] | 600 | unsigned int len = 0; |
Ben Greear | 462e58f | 2012-04-12 10:04:00 -0700 | [diff] [blame] | 601 | int rv; |
| 602 | int mxlen = 4000; |
| 603 | char *buf = kmalloc(mxlen, GFP_KERNEL); |
| 604 | if (!buf) |
| 605 | return -ENOMEM; |
| 606 | |
| 607 | #define PR_IS(a, s) \ |
| 608 | do { \ |
| 609 | len += snprintf(buf + len, mxlen - len, \ |
| 610 | "%21s: %10u\n", a, \ |
| 611 | sc->debug.stats.istats.s); \ |
| 612 | } while (0) |
Sujith | 817e11d | 2008-12-07 21:42:44 +0530 | [diff] [blame] | 613 | |
Luis R. Rodriguez | a9616f4 | 2010-04-15 17:39:30 -0400 | [diff] [blame] | 614 | if (sc->sc_ah->caps.hw_caps & ATH9K_HW_CAP_EDMA) { |
Ben Greear | 462e58f | 2012-04-12 10:04:00 -0700 | [diff] [blame] | 615 | PR_IS("RXLP", rxlp); |
| 616 | PR_IS("RXHP", rxhp); |
| 617 | PR_IS("WATHDOG", bb_watchdog); |
Luis R. Rodriguez | a9616f4 | 2010-04-15 17:39:30 -0400 | [diff] [blame] | 618 | } else { |
Ben Greear | 462e58f | 2012-04-12 10:04:00 -0700 | [diff] [blame] | 619 | PR_IS("RX", rxok); |
Luis R. Rodriguez | a9616f4 | 2010-04-15 17:39:30 -0400 | [diff] [blame] | 620 | } |
Ben Greear | 462e58f | 2012-04-12 10:04:00 -0700 | [diff] [blame] | 621 | PR_IS("RXEOL", rxeol); |
| 622 | PR_IS("RXORN", rxorn); |
| 623 | PR_IS("TX", txok); |
| 624 | PR_IS("TXURN", txurn); |
| 625 | PR_IS("MIB", mib); |
| 626 | PR_IS("RXPHY", rxphyerr); |
| 627 | PR_IS("RXKCM", rx_keycache_miss); |
| 628 | PR_IS("SWBA", swba); |
| 629 | PR_IS("BMISS", bmiss); |
| 630 | PR_IS("BNR", bnr); |
| 631 | PR_IS("CST", cst); |
| 632 | PR_IS("GTT", gtt); |
| 633 | PR_IS("TIM", tim); |
| 634 | PR_IS("CABEND", cabend); |
| 635 | PR_IS("DTIMSYNC", dtimsync); |
| 636 | PR_IS("DTIM", dtim); |
| 637 | PR_IS("TSFOOR", tsfoor); |
Sujith Manoharan | 97ba515 | 2012-06-04 16:27:41 +0530 | [diff] [blame] | 638 | PR_IS("MCI", mci); |
Mohammed Shafi Shajakhan | c9e6e98 | 2012-09-07 15:54:13 +0530 | [diff] [blame] | 639 | PR_IS("GENTIMER", gen_timer); |
Ben Greear | 462e58f | 2012-04-12 10:04:00 -0700 | [diff] [blame] | 640 | PR_IS("TOTAL", total); |
Sujith | 817e11d | 2008-12-07 21:42:44 +0530 | [diff] [blame] | 641 | |
Ben Greear | 462e58f | 2012-04-12 10:04:00 -0700 | [diff] [blame] | 642 | len += snprintf(buf + len, mxlen - len, |
| 643 | "SYNC_CAUSE stats:\n"); |
Mohammed Shafi Shajakhan | 6dde1aa | 2011-04-22 17:27:01 +0530 | [diff] [blame] | 644 | |
Ben Greear | 462e58f | 2012-04-12 10:04:00 -0700 | [diff] [blame] | 645 | PR_IS("Sync-All", sync_cause_all); |
| 646 | PR_IS("RTC-IRQ", sync_rtc_irq); |
| 647 | PR_IS("MAC-IRQ", sync_mac_irq); |
| 648 | PR_IS("EEPROM-Illegal-Access", eeprom_illegal_access); |
| 649 | PR_IS("APB-Timeout", apb_timeout); |
| 650 | PR_IS("PCI-Mode-Conflict", pci_mode_conflict); |
| 651 | PR_IS("HOST1-Fatal", host1_fatal); |
| 652 | PR_IS("HOST1-Perr", host1_perr); |
| 653 | PR_IS("TRCV-FIFO-Perr", trcv_fifo_perr); |
| 654 | PR_IS("RADM-CPL-EP", radm_cpl_ep); |
| 655 | PR_IS("RADM-CPL-DLLP-Abort", radm_cpl_dllp_abort); |
| 656 | PR_IS("RADM-CPL-TLP-Abort", radm_cpl_tlp_abort); |
| 657 | PR_IS("RADM-CPL-ECRC-Err", radm_cpl_ecrc_err); |
| 658 | PR_IS("RADM-CPL-Timeout", radm_cpl_timeout); |
| 659 | PR_IS("Local-Bus-Timeout", local_timeout); |
| 660 | PR_IS("PM-Access", pm_access); |
| 661 | PR_IS("MAC-Awake", mac_awake); |
| 662 | PR_IS("MAC-Asleep", mac_asleep); |
| 663 | PR_IS("MAC-Sleep-Access", mac_sleep_access); |
Dan Carpenter | 2b87f3a | 2010-05-14 15:24:37 +0200 | [diff] [blame] | 664 | |
Ben Greear | 462e58f | 2012-04-12 10:04:00 -0700 | [diff] [blame] | 665 | if (len > mxlen) |
| 666 | len = mxlen; |
| 667 | |
| 668 | rv = simple_read_from_buffer(user_buf, count, ppos, buf, len); |
| 669 | kfree(buf); |
| 670 | return rv; |
Sujith | 817e11d | 2008-12-07 21:42:44 +0530 | [diff] [blame] | 671 | } |
| 672 | |
| 673 | static const struct file_operations fops_interrupt = { |
| 674 | .read = read_file_interrupt, |
Stephen Boyd | 234e340 | 2012-04-05 14:25:11 -0700 | [diff] [blame] | 675 | .open = simple_open, |
Arnd Bergmann | 6038f37 | 2010-08-15 18:52:59 +0200 | [diff] [blame] | 676 | .owner = THIS_MODULE, |
| 677 | .llseek = default_llseek, |
Sujith | 817e11d | 2008-12-07 21:42:44 +0530 | [diff] [blame] | 678 | }; |
| 679 | |
Sujith | fec247c | 2009-07-27 12:08:16 +0530 | [diff] [blame] | 680 | static ssize_t read_file_xmit(struct file *file, char __user *user_buf, |
| 681 | size_t count, loff_t *ppos) |
| 682 | { |
| 683 | struct ath_softc *sc = file->private_data; |
| 684 | char *buf; |
Sujith Manoharan | 78ef731 | 2012-11-21 18:13:11 +0530 | [diff] [blame] | 685 | unsigned int len = 0, size = 2048; |
Sujith | fec247c | 2009-07-27 12:08:16 +0530 | [diff] [blame] | 686 | ssize_t retval = 0; |
| 687 | |
| 688 | buf = kzalloc(size, GFP_KERNEL); |
| 689 | if (buf == NULL) |
Dan Carpenter | 0423606 | 2010-05-14 15:25:39 +0200 | [diff] [blame] | 690 | return -ENOMEM; |
Sujith | fec247c | 2009-07-27 12:08:16 +0530 | [diff] [blame] | 691 | |
Sujith Manoharan | 78ef731 | 2012-11-21 18:13:11 +0530 | [diff] [blame] | 692 | len += sprintf(buf, "%30s %10s%10s%10s\n\n", |
Ben Greear | 7f010c9 | 2011-01-09 23:11:49 -0800 | [diff] [blame] | 693 | "BE", "BK", "VI", "VO"); |
Sujith | fec247c | 2009-07-27 12:08:16 +0530 | [diff] [blame] | 694 | |
| 695 | PR("MPDUs Queued: ", queued); |
| 696 | PR("MPDUs Completed: ", completed); |
Felix Fietkau | 5a6f78a | 2011-05-31 21:21:41 +0200 | [diff] [blame] | 697 | PR("MPDUs XRetried: ", xretries); |
Sujith | fec247c | 2009-07-27 12:08:16 +0530 | [diff] [blame] | 698 | PR("Aggregates: ", a_aggr); |
Ben Greear | bda8add | 2011-01-09 23:11:48 -0800 | [diff] [blame] | 699 | PR("AMPDUs Queued HW:", a_queued_hw); |
| 700 | PR("AMPDUs Queued SW:", a_queued_sw); |
Sujith | fec247c | 2009-07-27 12:08:16 +0530 | [diff] [blame] | 701 | PR("AMPDUs Completed:", a_completed); |
| 702 | PR("AMPDUs Retried: ", a_retries); |
| 703 | PR("AMPDUs XRetried: ", a_xretries); |
Ben Greear | 4d90038 | 2013-03-04 15:31:16 -0800 | [diff] [blame] | 704 | PR("TXERR Filtered: ", txerr_filtered); |
Sujith | fec247c | 2009-07-27 12:08:16 +0530 | [diff] [blame] | 705 | PR("FIFO Underrun: ", fifo_underrun); |
| 706 | PR("TXOP Exceeded: ", xtxop); |
| 707 | PR("TXTIMER Expiry: ", timer_exp); |
| 708 | PR("DESC CFG Error: ", desc_cfg_err); |
| 709 | PR("DATA Underrun: ", data_underrun); |
| 710 | PR("DELIM Underrun: ", delim_underrun); |
Ben Greear | 99c15bf | 2010-10-01 12:26:30 -0700 | [diff] [blame] | 711 | PR("TX-Pkts-All: ", tx_pkts_all); |
| 712 | PR("TX-Bytes-All: ", tx_bytes_all); |
Sujith Manoharan | 78ef731 | 2012-11-21 18:13:11 +0530 | [diff] [blame] | 713 | PR("HW-put-tx-buf: ", puttxbuf); |
| 714 | PR("HW-tx-start: ", txstart); |
| 715 | PR("HW-tx-proc-desc: ", txprocdesc); |
Ben Greear | a5a0bca | 2012-04-03 09:16:55 -0700 | [diff] [blame] | 716 | PR("TX-Failed: ", txfailed); |
Sujith | fec247c | 2009-07-27 12:08:16 +0530 | [diff] [blame] | 717 | |
Ben Greear | 7f010c9 | 2011-01-09 23:11:49 -0800 | [diff] [blame] | 718 | if (len > size) |
| 719 | len = size; |
| 720 | |
| 721 | retval = simple_read_from_buffer(user_buf, count, ppos, buf, len); |
| 722 | kfree(buf); |
| 723 | |
| 724 | return retval; |
| 725 | } |
| 726 | |
Sujith Manoharan | c0b7487 | 2012-11-21 18:13:12 +0530 | [diff] [blame] | 727 | static ssize_t read_file_queues(struct file *file, char __user *user_buf, |
| 728 | size_t count, loff_t *ppos) |
| 729 | { |
| 730 | struct ath_softc *sc = file->private_data; |
| 731 | struct ath_txq *txq; |
| 732 | char *buf; |
| 733 | unsigned int len = 0, size = 1024; |
| 734 | ssize_t retval = 0; |
| 735 | int i; |
| 736 | char *qname[4] = {"VO", "VI", "BE", "BK"}; |
| 737 | |
| 738 | buf = kzalloc(size, GFP_KERNEL); |
| 739 | if (buf == NULL) |
| 740 | return -ENOMEM; |
| 741 | |
| 742 | for (i = 0; i < IEEE80211_NUM_ACS; i++) { |
| 743 | txq = sc->tx.txq_map[i]; |
| 744 | len += snprintf(buf + len, size - len, "(%s): ", qname[i]); |
| 745 | |
| 746 | ath_txq_lock(sc, txq); |
| 747 | |
| 748 | len += snprintf(buf + len, size - len, "%s: %d ", |
| 749 | "qnum", txq->axq_qnum); |
| 750 | len += snprintf(buf + len, size - len, "%s: %2d ", |
| 751 | "qdepth", txq->axq_depth); |
| 752 | len += snprintf(buf + len, size - len, "%s: %2d ", |
| 753 | "ampdu-depth", txq->axq_ampdu_depth); |
| 754 | len += snprintf(buf + len, size - len, "%s: %3d ", |
| 755 | "pending", txq->pending_frames); |
| 756 | len += snprintf(buf + len, size - len, "%s: %d\n", |
| 757 | "stopped", txq->stopped); |
| 758 | |
| 759 | ath_txq_unlock(sc, txq); |
| 760 | } |
| 761 | |
| 762 | if (len > size) |
| 763 | len = size; |
| 764 | |
| 765 | retval = simple_read_from_buffer(user_buf, count, ppos, buf, len); |
| 766 | kfree(buf); |
| 767 | |
| 768 | return retval; |
| 769 | } |
| 770 | |
Ben Greear | 55f6d0f | 2011-01-17 11:54:50 -0800 | [diff] [blame] | 771 | static ssize_t read_file_misc(struct file *file, char __user *user_buf, |
| 772 | size_t count, loff_t *ppos) |
| 773 | { |
| 774 | struct ath_softc *sc = file->private_data; |
| 775 | struct ath_common *common = ath9k_hw_common(sc->sc_ah); |
Ben Greear | 55f6d0f | 2011-01-17 11:54:50 -0800 | [diff] [blame] | 776 | struct ieee80211_hw *hw = sc->hw; |
Sujith Manoharan | 6bcf6f6 | 2012-02-16 11:51:02 +0530 | [diff] [blame] | 777 | struct ath9k_vif_iter_data iter_data; |
| 778 | char buf[512]; |
| 779 | unsigned int len = 0; |
Ben Greear | 55f6d0f | 2011-01-17 11:54:50 -0800 | [diff] [blame] | 780 | ssize_t retval = 0; |
Ben Greear | 55f6d0f | 2011-01-17 11:54:50 -0800 | [diff] [blame] | 781 | unsigned int reg; |
Sujith Manoharan | 6bcf6f6 | 2012-02-16 11:51:02 +0530 | [diff] [blame] | 782 | u32 rxfilter; |
Ben Greear | 55f6d0f | 2011-01-17 11:54:50 -0800 | [diff] [blame] | 783 | |
Sujith Manoharan | 6bcf6f6 | 2012-02-16 11:51:02 +0530 | [diff] [blame] | 784 | len += snprintf(buf + len, sizeof(buf) - len, |
| 785 | "BSSID: %pM\n", common->curbssid); |
| 786 | len += snprintf(buf + len, sizeof(buf) - len, |
| 787 | "BSSID-MASK: %pM\n", common->bssidmask); |
| 788 | len += snprintf(buf + len, sizeof(buf) - len, |
| 789 | "OPMODE: %s\n", ath_opmode_to_string(sc->sc_ah->opmode)); |
Ben Greear | 55f6d0f | 2011-01-17 11:54:50 -0800 | [diff] [blame] | 790 | |
Rajkumar Manoharan | 79d2b15 | 2011-05-16 18:23:23 +0530 | [diff] [blame] | 791 | ath9k_ps_wakeup(sc); |
Sujith Manoharan | 6bcf6f6 | 2012-02-16 11:51:02 +0530 | [diff] [blame] | 792 | rxfilter = ath9k_hw_getrxfilter(sc->sc_ah); |
Rajkumar Manoharan | 79d2b15 | 2011-05-16 18:23:23 +0530 | [diff] [blame] | 793 | ath9k_ps_restore(sc); |
Sujith Manoharan | 6bcf6f6 | 2012-02-16 11:51:02 +0530 | [diff] [blame] | 794 | |
| 795 | len += snprintf(buf + len, sizeof(buf) - len, |
| 796 | "RXFILTER: 0x%x", rxfilter); |
| 797 | |
| 798 | if (rxfilter & ATH9K_RX_FILTER_UCAST) |
| 799 | len += snprintf(buf + len, sizeof(buf) - len, " UCAST"); |
| 800 | if (rxfilter & ATH9K_RX_FILTER_MCAST) |
| 801 | len += snprintf(buf + len, sizeof(buf) - len, " MCAST"); |
| 802 | if (rxfilter & ATH9K_RX_FILTER_BCAST) |
| 803 | len += snprintf(buf + len, sizeof(buf) - len, " BCAST"); |
| 804 | if (rxfilter & ATH9K_RX_FILTER_CONTROL) |
| 805 | len += snprintf(buf + len, sizeof(buf) - len, " CONTROL"); |
| 806 | if (rxfilter & ATH9K_RX_FILTER_BEACON) |
| 807 | len += snprintf(buf + len, sizeof(buf) - len, " BEACON"); |
| 808 | if (rxfilter & ATH9K_RX_FILTER_PROM) |
| 809 | len += snprintf(buf + len, sizeof(buf) - len, " PROM"); |
| 810 | if (rxfilter & ATH9K_RX_FILTER_PROBEREQ) |
| 811 | len += snprintf(buf + len, sizeof(buf) - len, " PROBEREQ"); |
| 812 | if (rxfilter & ATH9K_RX_FILTER_PHYERR) |
| 813 | len += snprintf(buf + len, sizeof(buf) - len, " PHYERR"); |
| 814 | if (rxfilter & ATH9K_RX_FILTER_MYBEACON) |
| 815 | len += snprintf(buf + len, sizeof(buf) - len, " MYBEACON"); |
| 816 | if (rxfilter & ATH9K_RX_FILTER_COMP_BAR) |
| 817 | len += snprintf(buf + len, sizeof(buf) - len, " COMP_BAR"); |
| 818 | if (rxfilter & ATH9K_RX_FILTER_PSPOLL) |
| 819 | len += snprintf(buf + len, sizeof(buf) - len, " PSPOLL"); |
| 820 | if (rxfilter & ATH9K_RX_FILTER_PHYRADAR) |
| 821 | len += snprintf(buf + len, sizeof(buf) - len, " PHYRADAR"); |
| 822 | if (rxfilter & ATH9K_RX_FILTER_MCAST_BCAST_ALL) |
| 823 | len += snprintf(buf + len, sizeof(buf) - len, " MCAST_BCAST_ALL"); |
| 824 | if (rxfilter & ATH9K_RX_FILTER_CONTROL_WRAPPER) |
| 825 | len += snprintf(buf + len, sizeof(buf) - len, " CONTROL_WRAPPER"); |
| 826 | |
| 827 | len += snprintf(buf + len, sizeof(buf) - len, "\n"); |
Ben Greear | 55f6d0f | 2011-01-17 11:54:50 -0800 | [diff] [blame] | 828 | |
| 829 | reg = sc->sc_ah->imask; |
Ben Greear | 55f6d0f | 2011-01-17 11:54:50 -0800 | [diff] [blame] | 830 | |
Sujith Manoharan | 6bcf6f6 | 2012-02-16 11:51:02 +0530 | [diff] [blame] | 831 | len += snprintf(buf + len, sizeof(buf) - len, "INTERRUPT-MASK: 0x%x", reg); |
| 832 | |
| 833 | if (reg & ATH9K_INT_SWBA) |
| 834 | len += snprintf(buf + len, sizeof(buf) - len, " SWBA"); |
| 835 | if (reg & ATH9K_INT_BMISS) |
| 836 | len += snprintf(buf + len, sizeof(buf) - len, " BMISS"); |
| 837 | if (reg & ATH9K_INT_CST) |
| 838 | len += snprintf(buf + len, sizeof(buf) - len, " CST"); |
| 839 | if (reg & ATH9K_INT_RX) |
| 840 | len += snprintf(buf + len, sizeof(buf) - len, " RX"); |
| 841 | if (reg & ATH9K_INT_RXHP) |
| 842 | len += snprintf(buf + len, sizeof(buf) - len, " RXHP"); |
| 843 | if (reg & ATH9K_INT_RXLP) |
| 844 | len += snprintf(buf + len, sizeof(buf) - len, " RXLP"); |
| 845 | if (reg & ATH9K_INT_BB_WATCHDOG) |
| 846 | len += snprintf(buf + len, sizeof(buf) - len, " BB_WATCHDOG"); |
| 847 | |
| 848 | len += snprintf(buf + len, sizeof(buf) - len, "\n"); |
| 849 | |
| 850 | ath9k_calculate_iter_data(hw, NULL, &iter_data); |
| 851 | |
| 852 | len += snprintf(buf + len, sizeof(buf) - len, |
| 853 | "VIF-COUNTS: AP: %i STA: %i MESH: %i WDS: %i" |
Sujith Manoharan | bcf6f96 | 2012-03-14 14:40:38 +0530 | [diff] [blame] | 854 | " ADHOC: %i TOTAL: %hi BEACON-VIF: %hi\n", |
Ben Greear | 55f6d0f | 2011-01-17 11:54:50 -0800 | [diff] [blame] | 855 | iter_data.naps, iter_data.nstations, iter_data.nmeshes, |
Sujith Manoharan | bcf6f96 | 2012-03-14 14:40:38 +0530 | [diff] [blame] | 856 | iter_data.nwds, iter_data.nadhocs, |
Ben Greear | 55f6d0f | 2011-01-17 11:54:50 -0800 | [diff] [blame] | 857 | sc->nvifs, sc->nbcnvifs); |
| 858 | |
Sujith Manoharan | 6bcf6f6 | 2012-02-16 11:51:02 +0530 | [diff] [blame] | 859 | if (len > sizeof(buf)) |
| 860 | len = sizeof(buf); |
Ben Greear | 55f6d0f | 2011-01-17 11:54:50 -0800 | [diff] [blame] | 861 | |
| 862 | retval = simple_read_from_buffer(user_buf, count, ppos, buf, len); |
Ben Greear | 55f6d0f | 2011-01-17 11:54:50 -0800 | [diff] [blame] | 863 | return retval; |
| 864 | } |
| 865 | |
Sujith Manoharan | f8b815d | 2012-02-16 11:51:11 +0530 | [diff] [blame] | 866 | static ssize_t read_file_reset(struct file *file, char __user *user_buf, |
| 867 | size_t count, loff_t *ppos) |
| 868 | { |
| 869 | struct ath_softc *sc = file->private_data; |
| 870 | char buf[512]; |
| 871 | unsigned int len = 0; |
| 872 | |
| 873 | len += snprintf(buf + len, sizeof(buf) - len, |
| 874 | "%17s: %2d\n", "Baseband Hang", |
| 875 | sc->debug.stats.reset[RESET_TYPE_BB_HANG]); |
| 876 | len += snprintf(buf + len, sizeof(buf) - len, |
| 877 | "%17s: %2d\n", "Baseband Watchdog", |
| 878 | sc->debug.stats.reset[RESET_TYPE_BB_WATCHDOG]); |
| 879 | len += snprintf(buf + len, sizeof(buf) - len, |
| 880 | "%17s: %2d\n", "Fatal HW Error", |
| 881 | sc->debug.stats.reset[RESET_TYPE_FATAL_INT]); |
| 882 | len += snprintf(buf + len, sizeof(buf) - len, |
| 883 | "%17s: %2d\n", "TX HW error", |
| 884 | sc->debug.stats.reset[RESET_TYPE_TX_ERROR]); |
| 885 | len += snprintf(buf + len, sizeof(buf) - len, |
| 886 | "%17s: %2d\n", "TX Path Hang", |
| 887 | sc->debug.stats.reset[RESET_TYPE_TX_HANG]); |
| 888 | len += snprintf(buf + len, sizeof(buf) - len, |
| 889 | "%17s: %2d\n", "PLL RX Hang", |
| 890 | sc->debug.stats.reset[RESET_TYPE_PLL_HANG]); |
Rajkumar Manoharan | b88083b | 2012-11-20 18:30:00 +0530 | [diff] [blame] | 891 | len += snprintf(buf + len, sizeof(buf) - len, |
| 892 | "%17s: %2d\n", "MCI Reset", |
| 893 | sc->debug.stats.reset[RESET_TYPE_MCI]); |
Sujith Manoharan | f8b815d | 2012-02-16 11:51:11 +0530 | [diff] [blame] | 894 | |
| 895 | if (len > sizeof(buf)) |
| 896 | len = sizeof(buf); |
| 897 | |
| 898 | return simple_read_from_buffer(user_buf, count, ppos, buf, len); |
| 899 | } |
| 900 | |
Felix Fietkau | 066dae9 | 2010-11-07 14:59:39 +0100 | [diff] [blame] | 901 | 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] | 902 | struct ath_tx_status *ts, struct ath_txq *txq, |
| 903 | unsigned int flags) |
Sujith | fec247c | 2009-07-27 12:08:16 +0530 | [diff] [blame] | 904 | { |
Felix Fietkau | 5bec3e5 | 2011-01-24 21:29:25 +0100 | [diff] [blame] | 905 | int qnum = txq->axq_qnum; |
Felix Fietkau | 066dae9 | 2010-11-07 14:59:39 +0100 | [diff] [blame] | 906 | |
| 907 | TX_STAT_INC(qnum, tx_pkts_all); |
| 908 | sc->debug.stats.txstats[qnum].tx_bytes_all += bf->bf_mpdu->len; |
Ben Greear | 99c15bf | 2010-10-01 12:26:30 -0700 | [diff] [blame] | 909 | |
Sujith | fec247c | 2009-07-27 12:08:16 +0530 | [diff] [blame] | 910 | if (bf_isampdu(bf)) { |
Felix Fietkau | 156369f | 2011-12-14 22:08:04 +0100 | [diff] [blame] | 911 | if (flags & ATH_TX_ERROR) |
Felix Fietkau | 066dae9 | 2010-11-07 14:59:39 +0100 | [diff] [blame] | 912 | TX_STAT_INC(qnum, a_xretries); |
Sujith | fec247c | 2009-07-27 12:08:16 +0530 | [diff] [blame] | 913 | else |
Felix Fietkau | 066dae9 | 2010-11-07 14:59:39 +0100 | [diff] [blame] | 914 | TX_STAT_INC(qnum, a_completed); |
Sujith | fec247c | 2009-07-27 12:08:16 +0530 | [diff] [blame] | 915 | } else { |
Felix Fietkau | 55797b1 | 2011-09-14 21:24:16 +0200 | [diff] [blame] | 916 | if (ts->ts_status & ATH9K_TXERR_XRETRY) |
Felix Fietkau | 5a6f78a | 2011-05-31 21:21:41 +0200 | [diff] [blame] | 917 | TX_STAT_INC(qnum, xretries); |
| 918 | else |
| 919 | TX_STAT_INC(qnum, completed); |
Sujith | fec247c | 2009-07-27 12:08:16 +0530 | [diff] [blame] | 920 | } |
| 921 | |
Ben Greear | 4d90038 | 2013-03-04 15:31:16 -0800 | [diff] [blame] | 922 | if (ts->ts_status & ATH9K_TXERR_FILT) |
| 923 | TX_STAT_INC(qnum, txerr_filtered); |
Felix Fietkau | db1a052 | 2010-03-29 20:07:11 -0700 | [diff] [blame] | 924 | if (ts->ts_status & ATH9K_TXERR_FIFO) |
Felix Fietkau | 066dae9 | 2010-11-07 14:59:39 +0100 | [diff] [blame] | 925 | TX_STAT_INC(qnum, fifo_underrun); |
Felix Fietkau | db1a052 | 2010-03-29 20:07:11 -0700 | [diff] [blame] | 926 | if (ts->ts_status & ATH9K_TXERR_XTXOP) |
Felix Fietkau | 066dae9 | 2010-11-07 14:59:39 +0100 | [diff] [blame] | 927 | TX_STAT_INC(qnum, xtxop); |
Felix Fietkau | db1a052 | 2010-03-29 20:07:11 -0700 | [diff] [blame] | 928 | if (ts->ts_status & ATH9K_TXERR_TIMER_EXPIRED) |
Felix Fietkau | 066dae9 | 2010-11-07 14:59:39 +0100 | [diff] [blame] | 929 | TX_STAT_INC(qnum, timer_exp); |
Felix Fietkau | db1a052 | 2010-03-29 20:07:11 -0700 | [diff] [blame] | 930 | if (ts->ts_flags & ATH9K_TX_DESC_CFG_ERR) |
Felix Fietkau | 066dae9 | 2010-11-07 14:59:39 +0100 | [diff] [blame] | 931 | TX_STAT_INC(qnum, desc_cfg_err); |
Felix Fietkau | db1a052 | 2010-03-29 20:07:11 -0700 | [diff] [blame] | 932 | if (ts->ts_flags & ATH9K_TX_DATA_UNDERRUN) |
Felix Fietkau | 066dae9 | 2010-11-07 14:59:39 +0100 | [diff] [blame] | 933 | TX_STAT_INC(qnum, data_underrun); |
Felix Fietkau | db1a052 | 2010-03-29 20:07:11 -0700 | [diff] [blame] | 934 | if (ts->ts_flags & ATH9K_TX_DELIM_UNDERRUN) |
Felix Fietkau | 066dae9 | 2010-11-07 14:59:39 +0100 | [diff] [blame] | 935 | TX_STAT_INC(qnum, delim_underrun); |
Sujith | fec247c | 2009-07-27 12:08:16 +0530 | [diff] [blame] | 936 | } |
| 937 | |
| 938 | static const struct file_operations fops_xmit = { |
| 939 | .read = read_file_xmit, |
Stephen Boyd | 234e340 | 2012-04-05 14:25:11 -0700 | [diff] [blame] | 940 | .open = simple_open, |
Arnd Bergmann | 6038f37 | 2010-08-15 18:52:59 +0200 | [diff] [blame] | 941 | .owner = THIS_MODULE, |
| 942 | .llseek = default_llseek, |
Sujith | fec247c | 2009-07-27 12:08:16 +0530 | [diff] [blame] | 943 | }; |
Jouni Malinen | 39d89cd | 2009-03-03 19:23:40 +0200 | [diff] [blame] | 944 | |
Sujith Manoharan | c0b7487 | 2012-11-21 18:13:12 +0530 | [diff] [blame] | 945 | static const struct file_operations fops_queues = { |
| 946 | .read = read_file_queues, |
| 947 | .open = simple_open, |
| 948 | .owner = THIS_MODULE, |
| 949 | .llseek = default_llseek, |
| 950 | }; |
| 951 | |
Ben Greear | 55f6d0f | 2011-01-17 11:54:50 -0800 | [diff] [blame] | 952 | static const struct file_operations fops_misc = { |
| 953 | .read = read_file_misc, |
Stephen Boyd | 234e340 | 2012-04-05 14:25:11 -0700 | [diff] [blame] | 954 | .open = simple_open, |
Ben Greear | 55f6d0f | 2011-01-17 11:54:50 -0800 | [diff] [blame] | 955 | .owner = THIS_MODULE, |
| 956 | .llseek = default_llseek, |
| 957 | }; |
| 958 | |
Sujith Manoharan | f8b815d | 2012-02-16 11:51:11 +0530 | [diff] [blame] | 959 | static const struct file_operations fops_reset = { |
| 960 | .read = read_file_reset, |
Stephen Boyd | 234e340 | 2012-04-05 14:25:11 -0700 | [diff] [blame] | 961 | .open = simple_open, |
Sujith Manoharan | f8b815d | 2012-02-16 11:51:11 +0530 | [diff] [blame] | 962 | .owner = THIS_MODULE, |
| 963 | .llseek = default_llseek, |
| 964 | }; |
| 965 | |
Sujith | 1395d3f | 2010-01-08 10:36:11 +0530 | [diff] [blame] | 966 | static ssize_t read_file_recv(struct file *file, char __user *user_buf, |
| 967 | size_t count, loff_t *ppos) |
| 968 | { |
| 969 | #define PHY_ERR(s, p) \ |
Sujith Manoharan | 4203214 | 2012-02-16 11:51:23 +0530 | [diff] [blame] | 970 | len += snprintf(buf + len, size - len, "%22s : %10u\n", s, \ |
Sujith | 1395d3f | 2010-01-08 10:36:11 +0530 | [diff] [blame] | 971 | sc->debug.stats.rxstats.phy_err_stats[p]); |
| 972 | |
Ben Greear | 24a0731 | 2012-04-12 10:03:59 -0700 | [diff] [blame] | 973 | #define RXS_ERR(s, e) \ |
| 974 | do { \ |
| 975 | len += snprintf(buf + len, size - len, \ |
| 976 | "%22s : %10u\n", s, \ |
| 977 | sc->debug.stats.rxstats.e); \ |
| 978 | } while (0) |
| 979 | |
Sujith | 1395d3f | 2010-01-08 10:36:11 +0530 | [diff] [blame] | 980 | struct ath_softc *sc = file->private_data; |
| 981 | char *buf; |
Sujith Manoharan | 4203214 | 2012-02-16 11:51:23 +0530 | [diff] [blame] | 982 | unsigned int len = 0, size = 1600; |
Sujith | 1395d3f | 2010-01-08 10:36:11 +0530 | [diff] [blame] | 983 | ssize_t retval = 0; |
| 984 | |
| 985 | buf = kzalloc(size, GFP_KERNEL); |
| 986 | if (buf == NULL) |
Dan Carpenter | 0423606 | 2010-05-14 15:25:39 +0200 | [diff] [blame] | 987 | return -ENOMEM; |
Sujith | 1395d3f | 2010-01-08 10:36:11 +0530 | [diff] [blame] | 988 | |
Ben Greear | 24a0731 | 2012-04-12 10:03:59 -0700 | [diff] [blame] | 989 | RXS_ERR("CRC ERR", crc_err); |
| 990 | RXS_ERR("DECRYPT CRC ERR", decrypt_crc_err); |
| 991 | RXS_ERR("PHY ERR", phy_err); |
| 992 | RXS_ERR("MIC ERR", mic_err); |
| 993 | RXS_ERR("PRE-DELIM CRC ERR", pre_delim_crc_err); |
| 994 | RXS_ERR("POST-DELIM CRC ERR", post_delim_crc_err); |
| 995 | RXS_ERR("DECRYPT BUSY ERR", decrypt_busy_err); |
| 996 | RXS_ERR("RX-LENGTH-ERR", rx_len_err); |
| 997 | RXS_ERR("RX-OOM-ERR", rx_oom_err); |
| 998 | RXS_ERR("RX-RATE-ERR", rx_rate_err); |
Ben Greear | 24a0731 | 2012-04-12 10:03:59 -0700 | [diff] [blame] | 999 | RXS_ERR("RX-TOO-MANY-FRAGS", rx_too_many_frags_err); |
Sujith | 1395d3f | 2010-01-08 10:36:11 +0530 | [diff] [blame] | 1000 | |
Sujith Manoharan | 4203214 | 2012-02-16 11:51:23 +0530 | [diff] [blame] | 1001 | PHY_ERR("UNDERRUN ERR", ATH9K_PHYERR_UNDERRUN); |
| 1002 | PHY_ERR("TIMING ERR", ATH9K_PHYERR_TIMING); |
| 1003 | PHY_ERR("PARITY ERR", ATH9K_PHYERR_PARITY); |
| 1004 | PHY_ERR("RATE ERR", ATH9K_PHYERR_RATE); |
| 1005 | PHY_ERR("LENGTH ERR", ATH9K_PHYERR_LENGTH); |
| 1006 | PHY_ERR("RADAR ERR", ATH9K_PHYERR_RADAR); |
| 1007 | PHY_ERR("SERVICE ERR", ATH9K_PHYERR_SERVICE); |
| 1008 | PHY_ERR("TOR ERR", ATH9K_PHYERR_TOR); |
| 1009 | PHY_ERR("OFDM-TIMING ERR", ATH9K_PHYERR_OFDM_TIMING); |
| 1010 | PHY_ERR("OFDM-SIGNAL-PARITY ERR", ATH9K_PHYERR_OFDM_SIGNAL_PARITY); |
| 1011 | PHY_ERR("OFDM-RATE ERR", ATH9K_PHYERR_OFDM_RATE_ILLEGAL); |
| 1012 | PHY_ERR("OFDM-LENGTH ERR", ATH9K_PHYERR_OFDM_LENGTH_ILLEGAL); |
| 1013 | PHY_ERR("OFDM-POWER-DROP ERR", ATH9K_PHYERR_OFDM_POWER_DROP); |
| 1014 | PHY_ERR("OFDM-SERVICE ERR", ATH9K_PHYERR_OFDM_SERVICE); |
| 1015 | PHY_ERR("OFDM-RESTART ERR", ATH9K_PHYERR_OFDM_RESTART); |
| 1016 | PHY_ERR("FALSE-RADAR-EXT ERR", ATH9K_PHYERR_FALSE_RADAR_EXT); |
| 1017 | PHY_ERR("CCK-TIMING ERR", ATH9K_PHYERR_CCK_TIMING); |
| 1018 | PHY_ERR("CCK-HEADER-CRC ERR", ATH9K_PHYERR_CCK_HEADER_CRC); |
| 1019 | PHY_ERR("CCK-RATE ERR", ATH9K_PHYERR_CCK_RATE_ILLEGAL); |
| 1020 | PHY_ERR("CCK-SERVICE ERR", ATH9K_PHYERR_CCK_SERVICE); |
| 1021 | PHY_ERR("CCK-RESTART ERR", ATH9K_PHYERR_CCK_RESTART); |
| 1022 | PHY_ERR("CCK-LENGTH ERR", ATH9K_PHYERR_CCK_LENGTH_ILLEGAL); |
| 1023 | PHY_ERR("CCK-POWER-DROP ERR", ATH9K_PHYERR_CCK_POWER_DROP); |
| 1024 | PHY_ERR("HT-CRC ERR", ATH9K_PHYERR_HT_CRC_ERROR); |
| 1025 | PHY_ERR("HT-LENGTH ERR", ATH9K_PHYERR_HT_LENGTH_ILLEGAL); |
| 1026 | PHY_ERR("HT-RATE ERR", ATH9K_PHYERR_HT_RATE_ILLEGAL); |
| 1027 | |
Ben Greear | 24a0731 | 2012-04-12 10:03:59 -0700 | [diff] [blame] | 1028 | RXS_ERR("RX-Pkts-All", rx_pkts_all); |
| 1029 | RXS_ERR("RX-Bytes-All", rx_bytes_all); |
| 1030 | RXS_ERR("RX-Beacons", rx_beacons); |
| 1031 | RXS_ERR("RX-Frags", rx_frags); |
Simon Wunderlich | 9b99e66 | 2013-01-23 17:38:05 +0100 | [diff] [blame] | 1032 | RXS_ERR("RX-Spectral", rx_spectral); |
Ben Greear | 99c15bf | 2010-10-01 12:26:30 -0700 | [diff] [blame] | 1033 | |
Dan Carpenter | 2b87f3a | 2010-05-14 15:24:37 +0200 | [diff] [blame] | 1034 | if (len > size) |
| 1035 | len = size; |
| 1036 | |
Sujith | 1395d3f | 2010-01-08 10:36:11 +0530 | [diff] [blame] | 1037 | retval = simple_read_from_buffer(user_buf, count, ppos, buf, len); |
| 1038 | kfree(buf); |
| 1039 | |
| 1040 | return retval; |
| 1041 | |
Ben Greear | 24a0731 | 2012-04-12 10:03:59 -0700 | [diff] [blame] | 1042 | #undef RXS_ERR |
Sujith | 1395d3f | 2010-01-08 10:36:11 +0530 | [diff] [blame] | 1043 | #undef PHY_ERR |
| 1044 | } |
| 1045 | |
Felix Fietkau | 8e6f5aa | 2010-03-29 20:09:27 -0700 | [diff] [blame] | 1046 | 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] | 1047 | { |
Sujith | 1395d3f | 2010-01-08 10:36:11 +0530 | [diff] [blame] | 1048 | #define RX_PHY_ERR_INC(c) sc->debug.stats.rxstats.phy_err_stats[c]++ |
| 1049 | |
Ben Greear | 99c15bf | 2010-10-01 12:26:30 -0700 | [diff] [blame] | 1050 | RX_STAT_INC(rx_pkts_all); |
| 1051 | sc->debug.stats.rxstats.rx_bytes_all += rs->rs_datalen; |
| 1052 | |
Felix Fietkau | 8e6f5aa | 2010-03-29 20:09:27 -0700 | [diff] [blame] | 1053 | if (rs->rs_status & ATH9K_RXERR_CRC) |
Sujith | 1395d3f | 2010-01-08 10:36:11 +0530 | [diff] [blame] | 1054 | RX_STAT_INC(crc_err); |
Felix Fietkau | 8e6f5aa | 2010-03-29 20:09:27 -0700 | [diff] [blame] | 1055 | if (rs->rs_status & ATH9K_RXERR_DECRYPT) |
Sujith | 1395d3f | 2010-01-08 10:36:11 +0530 | [diff] [blame] | 1056 | RX_STAT_INC(decrypt_crc_err); |
Felix Fietkau | 8e6f5aa | 2010-03-29 20:09:27 -0700 | [diff] [blame] | 1057 | if (rs->rs_status & ATH9K_RXERR_MIC) |
Sujith | 1395d3f | 2010-01-08 10:36:11 +0530 | [diff] [blame] | 1058 | RX_STAT_INC(mic_err); |
Felix Fietkau | 8e6f5aa | 2010-03-29 20:09:27 -0700 | [diff] [blame] | 1059 | if (rs->rs_status & ATH9K_RX_DELIM_CRC_PRE) |
Sujith | 1395d3f | 2010-01-08 10:36:11 +0530 | [diff] [blame] | 1060 | RX_STAT_INC(pre_delim_crc_err); |
Felix Fietkau | 8e6f5aa | 2010-03-29 20:09:27 -0700 | [diff] [blame] | 1061 | if (rs->rs_status & ATH9K_RX_DELIM_CRC_POST) |
Sujith | 1395d3f | 2010-01-08 10:36:11 +0530 | [diff] [blame] | 1062 | RX_STAT_INC(post_delim_crc_err); |
Felix Fietkau | 8e6f5aa | 2010-03-29 20:09:27 -0700 | [diff] [blame] | 1063 | if (rs->rs_status & ATH9K_RX_DECRYPT_BUSY) |
Sujith | 1395d3f | 2010-01-08 10:36:11 +0530 | [diff] [blame] | 1064 | RX_STAT_INC(decrypt_busy_err); |
| 1065 | |
Felix Fietkau | 8e6f5aa | 2010-03-29 20:09:27 -0700 | [diff] [blame] | 1066 | if (rs->rs_status & ATH9K_RXERR_PHY) { |
Sujith | 1395d3f | 2010-01-08 10:36:11 +0530 | [diff] [blame] | 1067 | RX_STAT_INC(phy_err); |
Sujith Manoharan | dbb07f0 | 2012-02-16 11:52:25 +0530 | [diff] [blame] | 1068 | if (rs->rs_phyerr < ATH9K_PHYERR_MAX) |
| 1069 | RX_PHY_ERR_INC(rs->rs_phyerr); |
Sujith | 1395d3f | 2010-01-08 10:36:11 +0530 | [diff] [blame] | 1070 | } |
| 1071 | |
Sujith | 1395d3f | 2010-01-08 10:36:11 +0530 | [diff] [blame] | 1072 | #undef RX_PHY_ERR_INC |
| 1073 | } |
| 1074 | |
| 1075 | static const struct file_operations fops_recv = { |
| 1076 | .read = read_file_recv, |
Stephen Boyd | 234e340 | 2012-04-05 14:25:11 -0700 | [diff] [blame] | 1077 | .open = simple_open, |
Arnd Bergmann | 6038f37 | 2010-08-15 18:52:59 +0200 | [diff] [blame] | 1078 | .owner = THIS_MODULE, |
| 1079 | .llseek = default_llseek, |
Sujith | 1395d3f | 2010-01-08 10:36:11 +0530 | [diff] [blame] | 1080 | }; |
| 1081 | |
Simon Wunderlich | e93d083 | 2013-01-08 14:48:58 +0100 | [diff] [blame] | 1082 | static ssize_t read_file_spec_scan_ctl(struct file *file, char __user *user_buf, |
| 1083 | size_t count, loff_t *ppos) |
| 1084 | { |
| 1085 | struct ath_softc *sc = file->private_data; |
| 1086 | char *mode = ""; |
| 1087 | unsigned int len; |
| 1088 | |
| 1089 | switch (sc->spectral_mode) { |
| 1090 | case SPECTRAL_DISABLED: |
| 1091 | mode = "disable"; |
| 1092 | break; |
| 1093 | case SPECTRAL_BACKGROUND: |
| 1094 | mode = "background"; |
| 1095 | break; |
| 1096 | case SPECTRAL_CHANSCAN: |
| 1097 | mode = "chanscan"; |
| 1098 | break; |
| 1099 | case SPECTRAL_MANUAL: |
| 1100 | mode = "manual"; |
| 1101 | break; |
| 1102 | } |
| 1103 | len = strlen(mode); |
| 1104 | return simple_read_from_buffer(user_buf, count, ppos, mode, len); |
| 1105 | } |
| 1106 | |
| 1107 | static ssize_t write_file_spec_scan_ctl(struct file *file, |
| 1108 | const char __user *user_buf, |
| 1109 | size_t count, loff_t *ppos) |
| 1110 | { |
| 1111 | struct ath_softc *sc = file->private_data; |
| 1112 | struct ath_common *common = ath9k_hw_common(sc->sc_ah); |
| 1113 | char buf[32]; |
| 1114 | ssize_t len; |
| 1115 | |
| 1116 | len = min(count, sizeof(buf) - 1); |
| 1117 | if (copy_from_user(buf, user_buf, len)) |
| 1118 | return -EFAULT; |
| 1119 | |
| 1120 | buf[len] = '\0'; |
| 1121 | |
| 1122 | if (strncmp("trigger", buf, 7) == 0) { |
| 1123 | ath9k_spectral_scan_trigger(sc->hw); |
| 1124 | } else if (strncmp("background", buf, 9) == 0) { |
| 1125 | ath9k_spectral_scan_config(sc->hw, SPECTRAL_BACKGROUND); |
| 1126 | ath_dbg(common, CONFIG, "spectral scan: background mode enabled\n"); |
| 1127 | } else if (strncmp("chanscan", buf, 8) == 0) { |
| 1128 | ath9k_spectral_scan_config(sc->hw, SPECTRAL_CHANSCAN); |
| 1129 | ath_dbg(common, CONFIG, "spectral scan: channel scan mode enabled\n"); |
| 1130 | } else if (strncmp("manual", buf, 6) == 0) { |
| 1131 | ath9k_spectral_scan_config(sc->hw, SPECTRAL_MANUAL); |
| 1132 | ath_dbg(common, CONFIG, "spectral scan: manual mode enabled\n"); |
| 1133 | } else if (strncmp("disable", buf, 7) == 0) { |
| 1134 | ath9k_spectral_scan_config(sc->hw, SPECTRAL_DISABLED); |
| 1135 | ath_dbg(common, CONFIG, "spectral scan: disabled\n"); |
| 1136 | } else { |
| 1137 | return -EINVAL; |
| 1138 | } |
| 1139 | |
| 1140 | return count; |
| 1141 | } |
| 1142 | |
| 1143 | static const struct file_operations fops_spec_scan_ctl = { |
| 1144 | .read = read_file_spec_scan_ctl, |
| 1145 | .write = write_file_spec_scan_ctl, |
| 1146 | .open = simple_open, |
| 1147 | .owner = THIS_MODULE, |
| 1148 | .llseek = default_llseek, |
| 1149 | }; |
| 1150 | |
Simon Wunderlich | 04ccd4a | 2013-01-23 17:38:04 +0100 | [diff] [blame] | 1151 | static ssize_t read_file_spectral_short_repeat(struct file *file, |
| 1152 | char __user *user_buf, |
| 1153 | size_t count, loff_t *ppos) |
| 1154 | { |
| 1155 | struct ath_softc *sc = file->private_data; |
| 1156 | char buf[32]; |
| 1157 | unsigned int len; |
| 1158 | |
| 1159 | len = sprintf(buf, "%d\n", sc->spec_config.short_repeat); |
| 1160 | return simple_read_from_buffer(user_buf, count, ppos, buf, len); |
| 1161 | } |
| 1162 | |
| 1163 | static ssize_t write_file_spectral_short_repeat(struct file *file, |
| 1164 | const char __user *user_buf, |
| 1165 | size_t count, loff_t *ppos) |
| 1166 | { |
| 1167 | struct ath_softc *sc = file->private_data; |
| 1168 | unsigned long val; |
| 1169 | char buf[32]; |
| 1170 | ssize_t len; |
| 1171 | |
| 1172 | len = min(count, sizeof(buf) - 1); |
| 1173 | if (copy_from_user(buf, user_buf, len)) |
| 1174 | return -EFAULT; |
| 1175 | |
| 1176 | buf[len] = '\0'; |
| 1177 | if (kstrtoul(buf, 0, &val)) |
| 1178 | return -EINVAL; |
| 1179 | |
| 1180 | if (val < 0 || val > 1) |
| 1181 | return -EINVAL; |
| 1182 | |
| 1183 | sc->spec_config.short_repeat = val; |
| 1184 | return count; |
| 1185 | } |
| 1186 | |
| 1187 | static const struct file_operations fops_spectral_short_repeat = { |
| 1188 | .read = read_file_spectral_short_repeat, |
| 1189 | .write = write_file_spectral_short_repeat, |
| 1190 | .open = simple_open, |
| 1191 | .owner = THIS_MODULE, |
| 1192 | .llseek = default_llseek, |
| 1193 | }; |
| 1194 | |
| 1195 | static ssize_t read_file_spectral_count(struct file *file, |
| 1196 | char __user *user_buf, |
| 1197 | size_t count, loff_t *ppos) |
| 1198 | { |
| 1199 | struct ath_softc *sc = file->private_data; |
| 1200 | char buf[32]; |
| 1201 | unsigned int len; |
| 1202 | |
| 1203 | len = sprintf(buf, "%d\n", sc->spec_config.count); |
| 1204 | return simple_read_from_buffer(user_buf, count, ppos, buf, len); |
| 1205 | } |
| 1206 | |
| 1207 | static ssize_t write_file_spectral_count(struct file *file, |
| 1208 | const char __user *user_buf, |
| 1209 | size_t count, loff_t *ppos) |
| 1210 | { |
| 1211 | struct ath_softc *sc = file->private_data; |
| 1212 | unsigned long val; |
| 1213 | char buf[32]; |
| 1214 | ssize_t len; |
| 1215 | |
| 1216 | len = min(count, sizeof(buf) - 1); |
| 1217 | if (copy_from_user(buf, user_buf, len)) |
| 1218 | return -EFAULT; |
| 1219 | |
| 1220 | buf[len] = '\0'; |
| 1221 | if (kstrtoul(buf, 0, &val)) |
| 1222 | return -EINVAL; |
| 1223 | |
| 1224 | if (val < 0 || val > 255) |
| 1225 | return -EINVAL; |
| 1226 | |
| 1227 | sc->spec_config.count = val; |
| 1228 | return count; |
| 1229 | } |
| 1230 | |
| 1231 | static const struct file_operations fops_spectral_count = { |
| 1232 | .read = read_file_spectral_count, |
| 1233 | .write = write_file_spectral_count, |
| 1234 | .open = simple_open, |
| 1235 | .owner = THIS_MODULE, |
| 1236 | .llseek = default_llseek, |
| 1237 | }; |
| 1238 | |
| 1239 | static ssize_t read_file_spectral_period(struct file *file, |
| 1240 | char __user *user_buf, |
| 1241 | size_t count, loff_t *ppos) |
| 1242 | { |
| 1243 | struct ath_softc *sc = file->private_data; |
| 1244 | char buf[32]; |
| 1245 | unsigned int len; |
| 1246 | |
| 1247 | len = sprintf(buf, "%d\n", sc->spec_config.period); |
| 1248 | return simple_read_from_buffer(user_buf, count, ppos, buf, len); |
| 1249 | } |
| 1250 | |
| 1251 | static ssize_t write_file_spectral_period(struct file *file, |
| 1252 | const char __user *user_buf, |
| 1253 | size_t count, loff_t *ppos) |
| 1254 | { |
| 1255 | struct ath_softc *sc = file->private_data; |
| 1256 | unsigned long val; |
| 1257 | char buf[32]; |
| 1258 | ssize_t len; |
| 1259 | |
| 1260 | len = min(count, sizeof(buf) - 1); |
| 1261 | if (copy_from_user(buf, user_buf, len)) |
| 1262 | return -EFAULT; |
| 1263 | |
| 1264 | buf[len] = '\0'; |
| 1265 | if (kstrtoul(buf, 0, &val)) |
| 1266 | return -EINVAL; |
| 1267 | |
| 1268 | if (val < 0 || val > 255) |
| 1269 | return -EINVAL; |
| 1270 | |
| 1271 | sc->spec_config.period = val; |
| 1272 | return count; |
| 1273 | } |
| 1274 | |
| 1275 | static const struct file_operations fops_spectral_period = { |
| 1276 | .read = read_file_spectral_period, |
| 1277 | .write = write_file_spectral_period, |
| 1278 | .open = simple_open, |
| 1279 | .owner = THIS_MODULE, |
| 1280 | .llseek = default_llseek, |
| 1281 | }; |
| 1282 | |
| 1283 | static ssize_t read_file_spectral_fft_period(struct file *file, |
| 1284 | char __user *user_buf, |
| 1285 | size_t count, loff_t *ppos) |
| 1286 | { |
| 1287 | struct ath_softc *sc = file->private_data; |
| 1288 | char buf[32]; |
| 1289 | unsigned int len; |
| 1290 | |
| 1291 | len = sprintf(buf, "%d\n", sc->spec_config.fft_period); |
| 1292 | return simple_read_from_buffer(user_buf, count, ppos, buf, len); |
| 1293 | } |
| 1294 | |
| 1295 | static ssize_t write_file_spectral_fft_period(struct file *file, |
| 1296 | const char __user *user_buf, |
| 1297 | size_t count, loff_t *ppos) |
| 1298 | { |
| 1299 | struct ath_softc *sc = file->private_data; |
| 1300 | unsigned long val; |
| 1301 | char buf[32]; |
| 1302 | ssize_t len; |
| 1303 | |
| 1304 | len = min(count, sizeof(buf) - 1); |
| 1305 | if (copy_from_user(buf, user_buf, len)) |
| 1306 | return -EFAULT; |
| 1307 | |
| 1308 | buf[len] = '\0'; |
| 1309 | if (kstrtoul(buf, 0, &val)) |
| 1310 | return -EINVAL; |
| 1311 | |
| 1312 | if (val < 0 || val > 15) |
| 1313 | return -EINVAL; |
| 1314 | |
| 1315 | sc->spec_config.fft_period = val; |
| 1316 | return count; |
| 1317 | } |
| 1318 | |
| 1319 | static const struct file_operations fops_spectral_fft_period = { |
| 1320 | .read = read_file_spectral_fft_period, |
| 1321 | .write = write_file_spectral_fft_period, |
| 1322 | .open = simple_open, |
| 1323 | .owner = THIS_MODULE, |
| 1324 | .llseek = default_llseek, |
| 1325 | }; |
| 1326 | |
Simon Wunderlich | e93d083 | 2013-01-08 14:48:58 +0100 | [diff] [blame] | 1327 | static struct dentry *create_buf_file_handler(const char *filename, |
| 1328 | struct dentry *parent, |
| 1329 | umode_t mode, |
| 1330 | struct rchan_buf *buf, |
| 1331 | int *is_global) |
| 1332 | { |
| 1333 | struct dentry *buf_file; |
| 1334 | |
| 1335 | buf_file = debugfs_create_file(filename, mode, parent, buf, |
| 1336 | &relay_file_operations); |
| 1337 | *is_global = 1; |
| 1338 | return buf_file; |
| 1339 | } |
| 1340 | |
| 1341 | static int remove_buf_file_handler(struct dentry *dentry) |
| 1342 | { |
| 1343 | debugfs_remove(dentry); |
| 1344 | |
| 1345 | return 0; |
| 1346 | } |
| 1347 | |
| 1348 | void ath_debug_send_fft_sample(struct ath_softc *sc, |
| 1349 | struct fft_sample_tlv *fft_sample_tlv) |
| 1350 | { |
Sven Eckelmann | 4ab0b0a | 2013-01-23 20:12:39 +0100 | [diff] [blame] | 1351 | int length; |
Simon Wunderlich | e93d083 | 2013-01-08 14:48:58 +0100 | [diff] [blame] | 1352 | if (!sc->rfs_chan_spec_scan) |
| 1353 | return; |
| 1354 | |
Sven Eckelmann | 4ab0b0a | 2013-01-23 20:12:39 +0100 | [diff] [blame] | 1355 | length = __be16_to_cpu(fft_sample_tlv->length) + |
| 1356 | sizeof(*fft_sample_tlv); |
| 1357 | relay_write(sc->rfs_chan_spec_scan, fft_sample_tlv, length); |
Simon Wunderlich | e93d083 | 2013-01-08 14:48:58 +0100 | [diff] [blame] | 1358 | } |
| 1359 | |
| 1360 | static struct rchan_callbacks rfs_spec_scan_cb = { |
| 1361 | .create_buf_file = create_buf_file_handler, |
| 1362 | .remove_buf_file = remove_buf_file_handler, |
| 1363 | }; |
| 1364 | |
| 1365 | |
Felix Fietkau | 9bff0bc | 2010-05-11 17:23:02 +0200 | [diff] [blame] | 1366 | static ssize_t read_file_regidx(struct file *file, char __user *user_buf, |
| 1367 | size_t count, loff_t *ppos) |
| 1368 | { |
| 1369 | struct ath_softc *sc = file->private_data; |
| 1370 | char buf[32]; |
| 1371 | unsigned int len; |
| 1372 | |
Dan Carpenter | 2b87f3a | 2010-05-14 15:24:37 +0200 | [diff] [blame] | 1373 | len = sprintf(buf, "0x%08x\n", sc->debug.regidx); |
Felix Fietkau | 9bff0bc | 2010-05-11 17:23:02 +0200 | [diff] [blame] | 1374 | return simple_read_from_buffer(user_buf, count, ppos, buf, len); |
| 1375 | } |
| 1376 | |
| 1377 | static ssize_t write_file_regidx(struct file *file, const char __user *user_buf, |
| 1378 | size_t count, loff_t *ppos) |
| 1379 | { |
| 1380 | struct ath_softc *sc = file->private_data; |
| 1381 | unsigned long regidx; |
| 1382 | char buf[32]; |
| 1383 | ssize_t len; |
| 1384 | |
| 1385 | len = min(count, sizeof(buf) - 1); |
| 1386 | if (copy_from_user(buf, user_buf, len)) |
Dan Carpenter | 0423606 | 2010-05-14 15:25:39 +0200 | [diff] [blame] | 1387 | return -EFAULT; |
Felix Fietkau | 9bff0bc | 2010-05-11 17:23:02 +0200 | [diff] [blame] | 1388 | |
| 1389 | buf[len] = '\0'; |
Jingoo Han | 27d7f47 | 2013-05-31 21:24:06 +0000 | [diff] [blame] | 1390 | if (kstrtoul(buf, 0, ®idx)) |
Felix Fietkau | 9bff0bc | 2010-05-11 17:23:02 +0200 | [diff] [blame] | 1391 | return -EINVAL; |
| 1392 | |
| 1393 | sc->debug.regidx = regidx; |
| 1394 | return count; |
| 1395 | } |
| 1396 | |
| 1397 | static const struct file_operations fops_regidx = { |
| 1398 | .read = read_file_regidx, |
| 1399 | .write = write_file_regidx, |
Stephen Boyd | 234e340 | 2012-04-05 14:25:11 -0700 | [diff] [blame] | 1400 | .open = simple_open, |
Arnd Bergmann | 6038f37 | 2010-08-15 18:52:59 +0200 | [diff] [blame] | 1401 | .owner = THIS_MODULE, |
| 1402 | .llseek = default_llseek, |
Felix Fietkau | 9bff0bc | 2010-05-11 17:23:02 +0200 | [diff] [blame] | 1403 | }; |
| 1404 | |
| 1405 | static ssize_t read_file_regval(struct file *file, char __user *user_buf, |
| 1406 | size_t count, loff_t *ppos) |
| 1407 | { |
| 1408 | struct ath_softc *sc = file->private_data; |
| 1409 | struct ath_hw *ah = sc->sc_ah; |
| 1410 | char buf[32]; |
| 1411 | unsigned int len; |
| 1412 | u32 regval; |
| 1413 | |
Rajkumar Manoharan | 79d2b15 | 2011-05-16 18:23:23 +0530 | [diff] [blame] | 1414 | ath9k_ps_wakeup(sc); |
Felix Fietkau | 9bff0bc | 2010-05-11 17:23:02 +0200 | [diff] [blame] | 1415 | regval = REG_READ_D(ah, sc->debug.regidx); |
Rajkumar Manoharan | 79d2b15 | 2011-05-16 18:23:23 +0530 | [diff] [blame] | 1416 | ath9k_ps_restore(sc); |
Dan Carpenter | 2b87f3a | 2010-05-14 15:24:37 +0200 | [diff] [blame] | 1417 | len = sprintf(buf, "0x%08x\n", regval); |
Felix Fietkau | 9bff0bc | 2010-05-11 17:23:02 +0200 | [diff] [blame] | 1418 | return simple_read_from_buffer(user_buf, count, ppos, buf, len); |
| 1419 | } |
| 1420 | |
| 1421 | static ssize_t write_file_regval(struct file *file, const char __user *user_buf, |
| 1422 | size_t count, loff_t *ppos) |
| 1423 | { |
| 1424 | struct ath_softc *sc = file->private_data; |
| 1425 | struct ath_hw *ah = sc->sc_ah; |
| 1426 | unsigned long regval; |
| 1427 | char buf[32]; |
| 1428 | ssize_t len; |
| 1429 | |
| 1430 | len = min(count, sizeof(buf) - 1); |
| 1431 | if (copy_from_user(buf, user_buf, len)) |
Dan Carpenter | 0423606 | 2010-05-14 15:25:39 +0200 | [diff] [blame] | 1432 | return -EFAULT; |
Felix Fietkau | 9bff0bc | 2010-05-11 17:23:02 +0200 | [diff] [blame] | 1433 | |
| 1434 | buf[len] = '\0'; |
Jingoo Han | 27d7f47 | 2013-05-31 21:24:06 +0000 | [diff] [blame] | 1435 | if (kstrtoul(buf, 0, ®val)) |
Felix Fietkau | 9bff0bc | 2010-05-11 17:23:02 +0200 | [diff] [blame] | 1436 | return -EINVAL; |
| 1437 | |
Rajkumar Manoharan | 79d2b15 | 2011-05-16 18:23:23 +0530 | [diff] [blame] | 1438 | ath9k_ps_wakeup(sc); |
Felix Fietkau | 9bff0bc | 2010-05-11 17:23:02 +0200 | [diff] [blame] | 1439 | REG_WRITE_D(ah, sc->debug.regidx, regval); |
Rajkumar Manoharan | 79d2b15 | 2011-05-16 18:23:23 +0530 | [diff] [blame] | 1440 | ath9k_ps_restore(sc); |
Felix Fietkau | 9bff0bc | 2010-05-11 17:23:02 +0200 | [diff] [blame] | 1441 | return count; |
| 1442 | } |
| 1443 | |
| 1444 | static const struct file_operations fops_regval = { |
| 1445 | .read = read_file_regval, |
| 1446 | .write = write_file_regval, |
Stephen Boyd | 234e340 | 2012-04-05 14:25:11 -0700 | [diff] [blame] | 1447 | .open = simple_open, |
Arnd Bergmann | 6038f37 | 2010-08-15 18:52:59 +0200 | [diff] [blame] | 1448 | .owner = THIS_MODULE, |
| 1449 | .llseek = default_llseek, |
Felix Fietkau | 9bff0bc | 2010-05-11 17:23:02 +0200 | [diff] [blame] | 1450 | }; |
| 1451 | |
Vasanthakumar Thiagarajan | 582d006 | 2011-03-01 05:30:55 -0800 | [diff] [blame] | 1452 | #define REGDUMP_LINE_SIZE 20 |
| 1453 | |
| 1454 | static int open_file_regdump(struct inode *inode, struct file *file) |
| 1455 | { |
| 1456 | struct ath_softc *sc = inode->i_private; |
| 1457 | unsigned int len = 0; |
| 1458 | u8 *buf; |
| 1459 | int i; |
| 1460 | unsigned long num_regs, regdump_len, max_reg_offset; |
| 1461 | |
| 1462 | max_reg_offset = AR_SREV_9300_20_OR_LATER(sc->sc_ah) ? 0x16bd4 : 0xb500; |
| 1463 | num_regs = max_reg_offset / 4 + 1; |
| 1464 | regdump_len = num_regs * REGDUMP_LINE_SIZE + 1; |
| 1465 | buf = vmalloc(regdump_len); |
| 1466 | if (!buf) |
| 1467 | return -ENOMEM; |
| 1468 | |
| 1469 | ath9k_ps_wakeup(sc); |
| 1470 | for (i = 0; i < num_regs; i++) |
| 1471 | len += scnprintf(buf + len, regdump_len - len, |
| 1472 | "0x%06x 0x%08x\n", i << 2, REG_READ(sc->sc_ah, i << 2)); |
| 1473 | ath9k_ps_restore(sc); |
| 1474 | |
| 1475 | file->private_data = buf; |
| 1476 | |
| 1477 | return 0; |
| 1478 | } |
| 1479 | |
| 1480 | static const struct file_operations fops_regdump = { |
| 1481 | .open = open_file_regdump, |
| 1482 | .read = ath9k_debugfs_read_buf, |
| 1483 | .release = ath9k_debugfs_release_buf, |
| 1484 | .owner = THIS_MODULE, |
| 1485 | .llseek = default_llseek,/* read accesses f_pos */ |
| 1486 | }; |
| 1487 | |
Rajkumar Manoharan | d069a46 | 2011-08-13 10:28:18 +0530 | [diff] [blame] | 1488 | static ssize_t read_file_dump_nfcal(struct file *file, char __user *user_buf, |
| 1489 | size_t count, loff_t *ppos) |
| 1490 | { |
| 1491 | struct ath_softc *sc = file->private_data; |
| 1492 | struct ath_hw *ah = sc->sc_ah; |
| 1493 | struct ath9k_nfcal_hist *h = sc->caldata.nfCalHist; |
| 1494 | struct ath_common *common = ath9k_hw_common(ah); |
| 1495 | struct ieee80211_conf *conf = &common->hw->conf; |
| 1496 | u32 len = 0, size = 1500; |
| 1497 | u32 i, j; |
| 1498 | ssize_t retval = 0; |
| 1499 | char *buf; |
| 1500 | u8 chainmask = (ah->rxchainmask << 3) | ah->rxchainmask; |
| 1501 | u8 nread; |
| 1502 | |
| 1503 | buf = kzalloc(size, GFP_KERNEL); |
| 1504 | if (!buf) |
| 1505 | return -ENOMEM; |
| 1506 | |
| 1507 | len += snprintf(buf + len, size - len, |
| 1508 | "Channel Noise Floor : %d\n", ah->noise); |
| 1509 | len += snprintf(buf + len, size - len, |
| 1510 | "Chain | privNF | # Readings | NF Readings\n"); |
| 1511 | for (i = 0; i < NUM_NF_READINGS; i++) { |
| 1512 | if (!(chainmask & (1 << i)) || |
| 1513 | ((i >= AR5416_MAX_CHAINS) && !conf_is_ht40(conf))) |
| 1514 | continue; |
| 1515 | |
| 1516 | nread = AR_PHY_CCA_FILTERWINDOW_LENGTH - h[i].invalidNFcount; |
| 1517 | len += snprintf(buf + len, size - len, " %d\t %d\t %d\t\t", |
| 1518 | i, h[i].privNF, nread); |
| 1519 | for (j = 0; j < nread; j++) |
| 1520 | len += snprintf(buf + len, size - len, |
| 1521 | " %d", h[i].nfCalBuffer[j]); |
| 1522 | len += snprintf(buf + len, size - len, "\n"); |
| 1523 | } |
| 1524 | |
| 1525 | if (len > size) |
| 1526 | len = size; |
| 1527 | |
| 1528 | retval = simple_read_from_buffer(user_buf, count, ppos, buf, len); |
| 1529 | kfree(buf); |
| 1530 | |
| 1531 | return retval; |
| 1532 | } |
| 1533 | |
| 1534 | static const struct file_operations fops_dump_nfcal = { |
| 1535 | .read = read_file_dump_nfcal, |
Stephen Boyd | 234e340 | 2012-04-05 14:25:11 -0700 | [diff] [blame] | 1536 | .open = simple_open, |
Rajkumar Manoharan | d069a46 | 2011-08-13 10:28:18 +0530 | [diff] [blame] | 1537 | .owner = THIS_MODULE, |
| 1538 | .llseek = default_llseek, |
| 1539 | }; |
| 1540 | |
Rajkumar Manoharan | 580f010 | 2011-07-29 17:38:12 +0530 | [diff] [blame] | 1541 | static ssize_t read_file_base_eeprom(struct file *file, char __user *user_buf, |
| 1542 | size_t count, loff_t *ppos) |
| 1543 | { |
| 1544 | struct ath_softc *sc = file->private_data; |
| 1545 | struct ath_hw *ah = sc->sc_ah; |
| 1546 | u32 len = 0, size = 1500; |
| 1547 | ssize_t retval = 0; |
| 1548 | char *buf; |
| 1549 | |
| 1550 | buf = kzalloc(size, GFP_KERNEL); |
| 1551 | if (!buf) |
| 1552 | return -ENOMEM; |
| 1553 | |
| 1554 | len = ah->eep_ops->dump_eeprom(ah, true, buf, len, size); |
| 1555 | |
| 1556 | retval = simple_read_from_buffer(user_buf, count, ppos, buf, len); |
| 1557 | kfree(buf); |
| 1558 | |
| 1559 | return retval; |
| 1560 | } |
| 1561 | |
| 1562 | static const struct file_operations fops_base_eeprom = { |
| 1563 | .read = read_file_base_eeprom, |
Stephen Boyd | 234e340 | 2012-04-05 14:25:11 -0700 | [diff] [blame] | 1564 | .open = simple_open, |
Rajkumar Manoharan | 580f010 | 2011-07-29 17:38:12 +0530 | [diff] [blame] | 1565 | .owner = THIS_MODULE, |
| 1566 | .llseek = default_llseek, |
| 1567 | }; |
| 1568 | |
Rajkumar Manoharan | 3f4c4bd | 2011-07-29 17:38:13 +0530 | [diff] [blame] | 1569 | static ssize_t read_file_modal_eeprom(struct file *file, char __user *user_buf, |
| 1570 | size_t count, loff_t *ppos) |
| 1571 | { |
| 1572 | struct ath_softc *sc = file->private_data; |
| 1573 | struct ath_hw *ah = sc->sc_ah; |
| 1574 | u32 len = 0, size = 6000; |
| 1575 | char *buf; |
| 1576 | size_t retval; |
| 1577 | |
| 1578 | buf = kzalloc(size, GFP_KERNEL); |
| 1579 | if (buf == NULL) |
| 1580 | return -ENOMEM; |
| 1581 | |
| 1582 | len = ah->eep_ops->dump_eeprom(ah, false, buf, len, size); |
| 1583 | |
| 1584 | retval = simple_read_from_buffer(user_buf, count, ppos, buf, len); |
| 1585 | kfree(buf); |
| 1586 | |
| 1587 | return retval; |
| 1588 | } |
| 1589 | |
| 1590 | static const struct file_operations fops_modal_eeprom = { |
| 1591 | .read = read_file_modal_eeprom, |
Stephen Boyd | 234e340 | 2012-04-05 14:25:11 -0700 | [diff] [blame] | 1592 | .open = simple_open, |
Rajkumar Manoharan | 3f4c4bd | 2011-07-29 17:38:13 +0530 | [diff] [blame] | 1593 | .owner = THIS_MODULE, |
| 1594 | .llseek = default_llseek, |
| 1595 | }; |
| 1596 | |
Rajkumar Manoharan | 4df50ca | 2012-10-25 17:16:54 +0530 | [diff] [blame] | 1597 | #ifdef CONFIG_ATH9K_BTCOEX_SUPPORT |
| 1598 | static ssize_t read_file_btcoex(struct file *file, char __user *user_buf, |
| 1599 | size_t count, loff_t *ppos) |
| 1600 | { |
| 1601 | struct ath_softc *sc = file->private_data; |
| 1602 | u32 len = 0, size = 1500; |
| 1603 | char *buf; |
| 1604 | size_t retval; |
| 1605 | |
| 1606 | buf = kzalloc(size, GFP_KERNEL); |
| 1607 | if (buf == NULL) |
| 1608 | return -ENOMEM; |
| 1609 | |
Sujith Manoharan | ac46ba4 | 2012-11-19 14:24:46 +0530 | [diff] [blame] | 1610 | if (!sc->sc_ah->common.btcoex_enabled) { |
| 1611 | len = snprintf(buf, size, "%s\n", |
| 1612 | "BTCOEX is disabled"); |
| 1613 | goto exit; |
| 1614 | } |
Rajkumar Manoharan | 4df50ca | 2012-10-25 17:16:54 +0530 | [diff] [blame] | 1615 | |
Sujith Manoharan | ac46ba4 | 2012-11-19 14:24:46 +0530 | [diff] [blame] | 1616 | len = ath9k_dump_btcoex(sc, buf, size); |
| 1617 | exit: |
Rajkumar Manoharan | 4df50ca | 2012-10-25 17:16:54 +0530 | [diff] [blame] | 1618 | retval = simple_read_from_buffer(user_buf, count, ppos, buf, len); |
| 1619 | kfree(buf); |
| 1620 | |
| 1621 | return retval; |
| 1622 | } |
| 1623 | |
| 1624 | static const struct file_operations fops_btcoex = { |
| 1625 | .read = read_file_btcoex, |
| 1626 | .open = simple_open, |
| 1627 | .owner = THIS_MODULE, |
| 1628 | .llseek = default_llseek, |
| 1629 | }; |
| 1630 | #endif |
| 1631 | |
Sujith Manoharan | a145daf | 2012-11-28 15:08:54 +0530 | [diff] [blame] | 1632 | static ssize_t read_file_node_stat(struct file *file, char __user *user_buf, |
| 1633 | size_t count, loff_t *ppos) |
| 1634 | { |
| 1635 | struct ath_node *an = file->private_data; |
| 1636 | struct ath_softc *sc = an->sc; |
| 1637 | struct ath_atx_tid *tid; |
| 1638 | struct ath_atx_ac *ac; |
| 1639 | struct ath_txq *txq; |
| 1640 | u32 len = 0, size = 4096; |
| 1641 | char *buf; |
| 1642 | size_t retval; |
| 1643 | int tidno, acno; |
| 1644 | |
| 1645 | buf = kzalloc(size, GFP_KERNEL); |
| 1646 | if (buf == NULL) |
| 1647 | return -ENOMEM; |
| 1648 | |
| 1649 | if (!an->sta->ht_cap.ht_supported) { |
| 1650 | len = snprintf(buf, size, "%s\n", |
| 1651 | "HT not supported"); |
| 1652 | goto exit; |
| 1653 | } |
| 1654 | |
| 1655 | len = snprintf(buf, size, "Max-AMPDU: %d\n", |
| 1656 | an->maxampdu); |
| 1657 | len += snprintf(buf + len, size - len, "MPDU Density: %d\n\n", |
| 1658 | an->mpdudensity); |
| 1659 | |
| 1660 | len += snprintf(buf + len, size - len, |
| 1661 | "%2s%7s\n", "AC", "SCHED"); |
| 1662 | |
| 1663 | for (acno = 0, ac = &an->ac[acno]; |
| 1664 | acno < IEEE80211_NUM_ACS; acno++, ac++) { |
| 1665 | txq = ac->txq; |
| 1666 | ath_txq_lock(sc, txq); |
| 1667 | len += snprintf(buf + len, size - len, |
| 1668 | "%2d%7d\n", |
| 1669 | acno, ac->sched); |
| 1670 | ath_txq_unlock(sc, txq); |
| 1671 | } |
| 1672 | |
| 1673 | len += snprintf(buf + len, size - len, |
| 1674 | "\n%3s%11s%10s%10s%10s%10s%9s%6s%8s\n", |
| 1675 | "TID", "SEQ_START", "SEQ_NEXT", "BAW_SIZE", |
| 1676 | "BAW_HEAD", "BAW_TAIL", "BAR_IDX", "SCHED", "PAUSED"); |
| 1677 | |
| 1678 | for (tidno = 0, tid = &an->tid[tidno]; |
| 1679 | tidno < IEEE80211_NUM_TIDS; tidno++, tid++) { |
| 1680 | txq = tid->ac->txq; |
| 1681 | ath_txq_lock(sc, txq); |
| 1682 | len += snprintf(buf + len, size - len, |
| 1683 | "%3d%11d%10d%10d%10d%10d%9d%6d%8d\n", |
| 1684 | tid->tidno, tid->seq_start, tid->seq_next, |
| 1685 | tid->baw_size, tid->baw_head, tid->baw_tail, |
| 1686 | tid->bar_index, tid->sched, tid->paused); |
| 1687 | ath_txq_unlock(sc, txq); |
| 1688 | } |
| 1689 | exit: |
| 1690 | retval = simple_read_from_buffer(user_buf, count, ppos, buf, len); |
| 1691 | kfree(buf); |
| 1692 | |
| 1693 | return retval; |
| 1694 | } |
| 1695 | |
| 1696 | static const struct file_operations fops_node_stat = { |
| 1697 | .read = read_file_node_stat, |
| 1698 | .open = simple_open, |
| 1699 | .owner = THIS_MODULE, |
| 1700 | .llseek = default_llseek, |
| 1701 | }; |
| 1702 | |
| 1703 | void ath9k_sta_add_debugfs(struct ieee80211_hw *hw, |
| 1704 | struct ieee80211_vif *vif, |
| 1705 | struct ieee80211_sta *sta, |
| 1706 | struct dentry *dir) |
| 1707 | { |
| 1708 | struct ath_node *an = (struct ath_node *)sta->drv_priv; |
| 1709 | an->node_stat = debugfs_create_file("node_stat", S_IRUGO, |
| 1710 | dir, an, &fops_node_stat); |
| 1711 | } |
| 1712 | |
| 1713 | void ath9k_sta_remove_debugfs(struct ieee80211_hw *hw, |
| 1714 | struct ieee80211_vif *vif, |
| 1715 | struct ieee80211_sta *sta, |
| 1716 | struct dentry *dir) |
| 1717 | { |
| 1718 | struct ath_node *an = (struct ath_node *)sta->drv_priv; |
| 1719 | debugfs_remove(an->node_stat); |
| 1720 | } |
| 1721 | |
Sujith Manoharan | c175db8 | 2012-11-28 15:08:52 +0530 | [diff] [blame] | 1722 | /* Ethtool support for get-stats */ |
| 1723 | |
| 1724 | #define AMKSTR(nm) #nm "_BE", #nm "_BK", #nm "_VI", #nm "_VO" |
| 1725 | static const char ath9k_gstrings_stats[][ETH_GSTRING_LEN] = { |
| 1726 | "tx_pkts_nic", |
| 1727 | "tx_bytes_nic", |
| 1728 | "rx_pkts_nic", |
| 1729 | "rx_bytes_nic", |
| 1730 | AMKSTR(d_tx_pkts), |
| 1731 | AMKSTR(d_tx_bytes), |
| 1732 | AMKSTR(d_tx_mpdus_queued), |
| 1733 | AMKSTR(d_tx_mpdus_completed), |
| 1734 | AMKSTR(d_tx_mpdu_xretries), |
| 1735 | AMKSTR(d_tx_aggregates), |
| 1736 | AMKSTR(d_tx_ampdus_queued_hw), |
| 1737 | AMKSTR(d_tx_ampdus_queued_sw), |
| 1738 | AMKSTR(d_tx_ampdus_completed), |
| 1739 | AMKSTR(d_tx_ampdu_retries), |
| 1740 | AMKSTR(d_tx_ampdu_xretries), |
| 1741 | AMKSTR(d_tx_fifo_underrun), |
| 1742 | AMKSTR(d_tx_op_exceeded), |
| 1743 | AMKSTR(d_tx_timer_expiry), |
| 1744 | AMKSTR(d_tx_desc_cfg_err), |
| 1745 | AMKSTR(d_tx_data_underrun), |
| 1746 | AMKSTR(d_tx_delim_underrun), |
Ben Greear | 18c45b1 | 2013-03-04 15:31:17 -0800 | [diff] [blame] | 1747 | "d_rx_crc_err", |
Sujith Manoharan | c175db8 | 2012-11-28 15:08:52 +0530 | [diff] [blame] | 1748 | "d_rx_decrypt_crc_err", |
| 1749 | "d_rx_phy_err", |
| 1750 | "d_rx_mic_err", |
| 1751 | "d_rx_pre_delim_crc_err", |
| 1752 | "d_rx_post_delim_crc_err", |
| 1753 | "d_rx_decrypt_busy_err", |
| 1754 | |
| 1755 | "d_rx_phyerr_radar", |
| 1756 | "d_rx_phyerr_ofdm_timing", |
| 1757 | "d_rx_phyerr_cck_timing", |
| 1758 | |
| 1759 | }; |
| 1760 | #define ATH9K_SSTATS_LEN ARRAY_SIZE(ath9k_gstrings_stats) |
| 1761 | |
| 1762 | void ath9k_get_et_strings(struct ieee80211_hw *hw, |
| 1763 | struct ieee80211_vif *vif, |
| 1764 | u32 sset, u8 *data) |
| 1765 | { |
| 1766 | if (sset == ETH_SS_STATS) |
| 1767 | memcpy(data, *ath9k_gstrings_stats, |
| 1768 | sizeof(ath9k_gstrings_stats)); |
| 1769 | } |
| 1770 | |
| 1771 | int ath9k_get_et_sset_count(struct ieee80211_hw *hw, |
| 1772 | struct ieee80211_vif *vif, int sset) |
| 1773 | { |
| 1774 | if (sset == ETH_SS_STATS) |
| 1775 | return ATH9K_SSTATS_LEN; |
| 1776 | return 0; |
| 1777 | } |
| 1778 | |
| 1779 | #define AWDATA(elem) \ |
| 1780 | do { \ |
| 1781 | data[i++] = sc->debug.stats.txstats[PR_QNUM(IEEE80211_AC_BE)].elem; \ |
| 1782 | data[i++] = sc->debug.stats.txstats[PR_QNUM(IEEE80211_AC_BK)].elem; \ |
| 1783 | data[i++] = sc->debug.stats.txstats[PR_QNUM(IEEE80211_AC_VI)].elem; \ |
| 1784 | data[i++] = sc->debug.stats.txstats[PR_QNUM(IEEE80211_AC_VO)].elem; \ |
| 1785 | } while (0) |
| 1786 | |
| 1787 | #define AWDATA_RX(elem) \ |
| 1788 | do { \ |
| 1789 | data[i++] = sc->debug.stats.rxstats.elem; \ |
| 1790 | } while (0) |
| 1791 | |
| 1792 | void ath9k_get_et_stats(struct ieee80211_hw *hw, |
| 1793 | struct ieee80211_vif *vif, |
| 1794 | struct ethtool_stats *stats, u64 *data) |
| 1795 | { |
| 1796 | struct ath_softc *sc = hw->priv; |
| 1797 | int i = 0; |
| 1798 | |
| 1799 | data[i++] = (sc->debug.stats.txstats[PR_QNUM(IEEE80211_AC_BE)].tx_pkts_all + |
| 1800 | sc->debug.stats.txstats[PR_QNUM(IEEE80211_AC_BK)].tx_pkts_all + |
| 1801 | sc->debug.stats.txstats[PR_QNUM(IEEE80211_AC_VI)].tx_pkts_all + |
| 1802 | sc->debug.stats.txstats[PR_QNUM(IEEE80211_AC_VO)].tx_pkts_all); |
| 1803 | data[i++] = (sc->debug.stats.txstats[PR_QNUM(IEEE80211_AC_BE)].tx_bytes_all + |
| 1804 | sc->debug.stats.txstats[PR_QNUM(IEEE80211_AC_BK)].tx_bytes_all + |
| 1805 | sc->debug.stats.txstats[PR_QNUM(IEEE80211_AC_VI)].tx_bytes_all + |
| 1806 | sc->debug.stats.txstats[PR_QNUM(IEEE80211_AC_VO)].tx_bytes_all); |
| 1807 | AWDATA_RX(rx_pkts_all); |
| 1808 | AWDATA_RX(rx_bytes_all); |
| 1809 | |
| 1810 | AWDATA(tx_pkts_all); |
| 1811 | AWDATA(tx_bytes_all); |
| 1812 | AWDATA(queued); |
| 1813 | AWDATA(completed); |
| 1814 | AWDATA(xretries); |
| 1815 | AWDATA(a_aggr); |
| 1816 | AWDATA(a_queued_hw); |
| 1817 | AWDATA(a_queued_sw); |
| 1818 | AWDATA(a_completed); |
| 1819 | AWDATA(a_retries); |
| 1820 | AWDATA(a_xretries); |
| 1821 | AWDATA(fifo_underrun); |
| 1822 | AWDATA(xtxop); |
| 1823 | AWDATA(timer_exp); |
| 1824 | AWDATA(desc_cfg_err); |
| 1825 | AWDATA(data_underrun); |
| 1826 | AWDATA(delim_underrun); |
| 1827 | |
Ben Greear | 18c45b1 | 2013-03-04 15:31:17 -0800 | [diff] [blame] | 1828 | AWDATA_RX(crc_err); |
Sujith Manoharan | c175db8 | 2012-11-28 15:08:52 +0530 | [diff] [blame] | 1829 | AWDATA_RX(decrypt_crc_err); |
| 1830 | AWDATA_RX(phy_err); |
| 1831 | AWDATA_RX(mic_err); |
| 1832 | AWDATA_RX(pre_delim_crc_err); |
| 1833 | AWDATA_RX(post_delim_crc_err); |
| 1834 | AWDATA_RX(decrypt_busy_err); |
| 1835 | |
| 1836 | AWDATA_RX(phy_err_stats[ATH9K_PHYERR_RADAR]); |
| 1837 | AWDATA_RX(phy_err_stats[ATH9K_PHYERR_OFDM_TIMING]); |
| 1838 | AWDATA_RX(phy_err_stats[ATH9K_PHYERR_CCK_TIMING]); |
| 1839 | |
| 1840 | WARN_ON(i != ATH9K_SSTATS_LEN); |
| 1841 | } |
| 1842 | |
Sujith Manoharan | af69009 | 2013-05-10 18:41:06 +0530 | [diff] [blame] | 1843 | void ath9k_deinit_debug(struct ath_softc *sc) |
| 1844 | { |
| 1845 | if (config_enabled(CONFIG_ATH9K_DEBUGFS) && sc->rfs_chan_spec_scan) { |
| 1846 | relay_close(sc->rfs_chan_spec_scan); |
| 1847 | sc->rfs_chan_spec_scan = NULL; |
| 1848 | } |
| 1849 | } |
| 1850 | |
Luis R. Rodriguez | 4d6b228 | 2009-09-07 04:52:26 -0700 | [diff] [blame] | 1851 | int ath9k_init_debug(struct ath_hw *ah) |
Sujith | 88b126a | 2008-11-28 22:19:02 +0530 | [diff] [blame] | 1852 | { |
Luis R. Rodriguez | bc974f4 | 2009-09-28 02:54:40 -0400 | [diff] [blame] | 1853 | struct ath_common *common = ath9k_hw_common(ah); |
| 1854 | struct ath_softc *sc = (struct ath_softc *) common->priv; |
Luis R. Rodriguez | 4d6b228 | 2009-09-07 04:52:26 -0700 | [diff] [blame] | 1855 | |
Ben Greear | eb27244 | 2010-11-29 14:13:22 -0800 | [diff] [blame] | 1856 | sc->debug.debugfs_phy = debugfs_create_dir("ath9k", |
| 1857 | sc->hw->wiphy->debugfsdir); |
Sujith | 17d7904 | 2009-02-09 13:27:03 +0530 | [diff] [blame] | 1858 | if (!sc->debug.debugfs_phy) |
Felix Fietkau | c8a72c0 | 2010-05-11 17:23:00 +0200 | [diff] [blame] | 1859 | return -ENOMEM; |
Sujith | 826d268 | 2008-11-28 22:20:23 +0530 | [diff] [blame] | 1860 | |
Felix Fietkau | a830df0 | 2009-11-23 22:33:27 +0100 | [diff] [blame] | 1861 | #ifdef CONFIG_ATH_DEBUG |
Felix Fietkau | c70cab1 | 2011-03-19 13:55:37 +0100 | [diff] [blame] | 1862 | debugfs_create_file("debug", S_IRUSR | S_IWUSR, sc->debug.debugfs_phy, |
| 1863 | sc, &fops_debug); |
Felix Fietkau | a830df0 | 2009-11-23 22:33:27 +0100 | [diff] [blame] | 1864 | #endif |
Zefir Kurtisi | 29942bc | 2011-12-14 20:16:34 -0800 | [diff] [blame] | 1865 | |
| 1866 | ath9k_dfs_init_debug(sc); |
| 1867 | |
Felix Fietkau | c70cab1 | 2011-03-19 13:55:37 +0100 | [diff] [blame] | 1868 | debugfs_create_file("dma", S_IRUSR, sc->debug.debugfs_phy, sc, |
| 1869 | &fops_dma); |
| 1870 | debugfs_create_file("interrupt", S_IRUSR, sc->debug.debugfs_phy, sc, |
| 1871 | &fops_interrupt); |
Felix Fietkau | c70cab1 | 2011-03-19 13:55:37 +0100 | [diff] [blame] | 1872 | debugfs_create_file("xmit", S_IRUSR, sc->debug.debugfs_phy, sc, |
| 1873 | &fops_xmit); |
Sujith Manoharan | c0b7487 | 2012-11-21 18:13:12 +0530 | [diff] [blame] | 1874 | debugfs_create_file("queues", S_IRUSR, sc->debug.debugfs_phy, sc, |
| 1875 | &fops_queues); |
Felix Fietkau | 7702e78 | 2012-07-15 19:53:35 +0200 | [diff] [blame] | 1876 | 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] | 1877 | &sc->tx.txq_max_pending[IEEE80211_AC_BK]); |
Felix Fietkau | 7702e78 | 2012-07-15 19:53:35 +0200 | [diff] [blame] | 1878 | 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] | 1879 | &sc->tx.txq_max_pending[IEEE80211_AC_BE]); |
Felix Fietkau | 7702e78 | 2012-07-15 19:53:35 +0200 | [diff] [blame] | 1880 | 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] | 1881 | &sc->tx.txq_max_pending[IEEE80211_AC_VI]); |
Felix Fietkau | 7702e78 | 2012-07-15 19:53:35 +0200 | [diff] [blame] | 1882 | 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] | 1883 | &sc->tx.txq_max_pending[IEEE80211_AC_VO]); |
Felix Fietkau | c70cab1 | 2011-03-19 13:55:37 +0100 | [diff] [blame] | 1884 | debugfs_create_file("misc", S_IRUSR, sc->debug.debugfs_phy, sc, |
| 1885 | &fops_misc); |
Sujith Manoharan | f8b815d | 2012-02-16 11:51:11 +0530 | [diff] [blame] | 1886 | debugfs_create_file("reset", S_IRUSR, sc->debug.debugfs_phy, sc, |
| 1887 | &fops_reset); |
Felix Fietkau | c70cab1 | 2011-03-19 13:55:37 +0100 | [diff] [blame] | 1888 | debugfs_create_file("recv", S_IRUSR, sc->debug.debugfs_phy, sc, |
| 1889 | &fops_recv); |
| 1890 | debugfs_create_file("rx_chainmask", S_IRUSR | S_IWUSR, |
| 1891 | sc->debug.debugfs_phy, sc, &fops_rx_chainmask); |
| 1892 | debugfs_create_file("tx_chainmask", S_IRUSR | S_IWUSR, |
| 1893 | sc->debug.debugfs_phy, sc, &fops_tx_chainmask); |
Sujith Manoharan | 6e4d291 | 2013-06-03 09:19:28 +0530 | [diff] [blame] | 1894 | debugfs_create_file("ani", S_IRUSR | S_IWUSR, |
| 1895 | sc->debug.debugfs_phy, sc, &fops_ani); |
Felix Fietkau | 74673db | 2012-09-08 15:24:17 +0200 | [diff] [blame] | 1896 | debugfs_create_bool("paprd", S_IRUSR | S_IWUSR, sc->debug.debugfs_phy, |
| 1897 | &sc->sc_ah->config.enable_paprd); |
Felix Fietkau | c70cab1 | 2011-03-19 13:55:37 +0100 | [diff] [blame] | 1898 | debugfs_create_file("regidx", S_IRUSR | S_IWUSR, sc->debug.debugfs_phy, |
| 1899 | sc, &fops_regidx); |
| 1900 | debugfs_create_file("regval", S_IRUSR | S_IWUSR, sc->debug.debugfs_phy, |
| 1901 | sc, &fops_regval); |
| 1902 | debugfs_create_bool("ignore_extcca", S_IRUSR | S_IWUSR, |
| 1903 | sc->debug.debugfs_phy, |
| 1904 | &ah->config.cwm_ignore_extcca); |
| 1905 | debugfs_create_file("regdump", S_IRUSR, sc->debug.debugfs_phy, sc, |
| 1906 | &fops_regdump); |
Rajkumar Manoharan | d069a46 | 2011-08-13 10:28:18 +0530 | [diff] [blame] | 1907 | debugfs_create_file("dump_nfcal", S_IRUSR, sc->debug.debugfs_phy, sc, |
| 1908 | &fops_dump_nfcal); |
Rajkumar Manoharan | 580f010 | 2011-07-29 17:38:12 +0530 | [diff] [blame] | 1909 | debugfs_create_file("base_eeprom", S_IRUSR, sc->debug.debugfs_phy, sc, |
| 1910 | &fops_base_eeprom); |
Rajkumar Manoharan | 3f4c4bd | 2011-07-29 17:38:13 +0530 | [diff] [blame] | 1911 | debugfs_create_file("modal_eeprom", S_IRUSR, sc->debug.debugfs_phy, sc, |
| 1912 | &fops_modal_eeprom); |
Simon Wunderlich | e93d083 | 2013-01-08 14:48:58 +0100 | [diff] [blame] | 1913 | sc->rfs_chan_spec_scan = relay_open("spectral_scan", |
| 1914 | sc->debug.debugfs_phy, |
Zefir Kurtisi | 55f39e6 | 2013-03-22 12:58:23 +0100 | [diff] [blame] | 1915 | 1024, 256, &rfs_spec_scan_cb, |
Simon Wunderlich | e93d083 | 2013-01-08 14:48:58 +0100 | [diff] [blame] | 1916 | NULL); |
| 1917 | debugfs_create_file("spectral_scan_ctl", S_IRUSR | S_IWUSR, |
| 1918 | sc->debug.debugfs_phy, sc, |
| 1919 | &fops_spec_scan_ctl); |
Simon Wunderlich | 04ccd4a | 2013-01-23 17:38:04 +0100 | [diff] [blame] | 1920 | debugfs_create_file("spectral_short_repeat", S_IRUSR | S_IWUSR, |
| 1921 | sc->debug.debugfs_phy, sc, |
| 1922 | &fops_spectral_short_repeat); |
| 1923 | debugfs_create_file("spectral_count", S_IRUSR | S_IWUSR, |
| 1924 | sc->debug.debugfs_phy, sc, &fops_spectral_count); |
| 1925 | debugfs_create_file("spectral_period", S_IRUSR | S_IWUSR, |
| 1926 | sc->debug.debugfs_phy, sc, &fops_spectral_period); |
| 1927 | debugfs_create_file("spectral_fft_period", S_IRUSR | S_IWUSR, |
| 1928 | sc->debug.debugfs_phy, sc, |
| 1929 | &fops_spectral_fft_period); |
Felix Fietkau | 691680b | 2011-03-19 13:55:38 +0100 | [diff] [blame] | 1930 | debugfs_create_u32("gpio_mask", S_IRUSR | S_IWUSR, |
| 1931 | sc->debug.debugfs_phy, &sc->sc_ah->gpio_mask); |
Felix Fietkau | 691680b | 2011-03-19 13:55:38 +0100 | [diff] [blame] | 1932 | debugfs_create_u32("gpio_val", S_IRUSR | S_IWUSR, |
| 1933 | sc->debug.debugfs_phy, &sc->sc_ah->gpio_val); |
Sujith Manoharan | 6308130 | 2013-08-04 14:21:55 +0530 | [diff] [blame^] | 1934 | debugfs_create_file("bt_ant_diversity", S_IRUSR | S_IWUSR, |
| 1935 | sc->debug.debugfs_phy, sc, &fops_bt_ant_diversity); |
Sujith Manoharan | 4eba10c | 2013-07-29 16:04:49 +0530 | [diff] [blame] | 1936 | debugfs_create_file("antenna_diversity", S_IRUSR, |
| 1937 | sc->debug.debugfs_phy, sc, &fops_antenna_diversity); |
Rajkumar Manoharan | 4df50ca | 2012-10-25 17:16:54 +0530 | [diff] [blame] | 1938 | #ifdef CONFIG_ATH9K_BTCOEX_SUPPORT |
| 1939 | debugfs_create_file("btcoex", S_IRUSR, sc->debug.debugfs_phy, sc, |
| 1940 | &fops_btcoex); |
| 1941 | #endif |
Sujith | 826d268 | 2008-11-28 22:20:23 +0530 | [diff] [blame] | 1942 | return 0; |
Sujith | 88b126a | 2008-11-28 22:19:02 +0530 | [diff] [blame] | 1943 | } |