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