Tomas Winkler | 712b6cf | 2008-03-12 16:58:52 -0700 | [diff] [blame] | 1 | /****************************************************************************** |
| 2 | * |
| 3 | * GPL LICENSE SUMMARY |
| 4 | * |
Wey-Yi Guy | 4e31826 | 2011-12-27 11:21:32 -0800 | [diff] [blame] | 5 | * Copyright(c) 2008 - 2012 Intel Corporation. All rights reserved. |
Tomas Winkler | 712b6cf | 2008-03-12 16:58:52 -0700 | [diff] [blame] | 6 | * |
| 7 | * This program is free software; you can redistribute it and/or modify |
| 8 | * it under the terms of version 2 of the GNU General Public License as |
| 9 | * published by the Free Software Foundation. |
| 10 | * |
| 11 | * This program is distributed in the hope that it will be useful, but |
| 12 | * WITHOUT ANY WARRANTY; without even the implied warranty of |
| 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 14 | * General Public License for more details. |
| 15 | * |
| 16 | * You should have received a copy of the GNU General Public License |
| 17 | * along with this program; if not, write to the Free Software |
| 18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110, |
| 19 | * USA |
| 20 | * |
| 21 | * The full GNU General Public License is included in this distribution |
| 22 | * in the file called LICENSE.GPL. |
| 23 | * |
| 24 | * Contact Information: |
Winkler, Tomas | 759ef89 | 2008-12-09 11:28:58 -0800 | [diff] [blame] | 25 | * Intel Linux Wireless <ilw@linux.intel.com> |
Tomas Winkler | 712b6cf | 2008-03-12 16:58:52 -0700 | [diff] [blame] | 26 | * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497 |
| 27 | *****************************************************************************/ |
| 28 | |
Tejun Heo | 5a0e3ad | 2010-03-24 17:04:11 +0900 | [diff] [blame] | 29 | #include <linux/slab.h> |
Tomas Winkler | 712b6cf | 2008-03-12 16:58:52 -0700 | [diff] [blame] | 30 | #include <linux/kernel.h> |
| 31 | #include <linux/module.h> |
| 32 | #include <linux/debugfs.h> |
| 33 | |
| 34 | #include <linux/ieee80211.h> |
| 35 | #include <net/mac80211.h> |
| 36 | |
| 37 | |
Tomas Winkler | 3e0d4cb | 2008-04-24 11:55:38 -0700 | [diff] [blame] | 38 | #include "iwl-dev.h" |
Tomas Winkler | 712b6cf | 2008-03-12 16:58:52 -0700 | [diff] [blame] | 39 | #include "iwl-debug.h" |
Tomas Winkler | fee1247 | 2008-04-03 16:05:21 -0700 | [diff] [blame] | 40 | #include "iwl-core.h" |
Tomas Winkler | 3395f6e | 2008-03-25 16:33:37 -0700 | [diff] [blame] | 41 | #include "iwl-io.h" |
Wey-Yi Guy | d6d023a | 2011-04-30 09:10:53 -0700 | [diff] [blame] | 42 | #include "iwl-agn.h" |
Tomas Winkler | 712b6cf | 2008-03-12 16:58:52 -0700 | [diff] [blame] | 43 | |
| 44 | /* create and remove of files */ |
Johannes Berg | 4c84a8f | 2010-01-22 14:22:54 -0800 | [diff] [blame] | 45 | #define DEBUGFS_ADD_FILE(name, parent, mode) do { \ |
| 46 | if (!debugfs_create_file(#name, mode, parent, priv, \ |
| 47 | &iwl_dbgfs_##name##_ops)) \ |
| 48 | goto err; \ |
Tomas Winkler | 712b6cf | 2008-03-12 16:58:52 -0700 | [diff] [blame] | 49 | } while (0) |
| 50 | |
Johannes Berg | 4c84a8f | 2010-01-22 14:22:54 -0800 | [diff] [blame] | 51 | #define DEBUGFS_ADD_BOOL(name, parent, ptr) do { \ |
| 52 | struct dentry *__tmp; \ |
| 53 | __tmp = debugfs_create_bool(#name, S_IWUSR | S_IRUSR, \ |
| 54 | parent, ptr); \ |
| 55 | if (IS_ERR(__tmp) || !__tmp) \ |
| 56 | goto err; \ |
Tomas Winkler | 712b6cf | 2008-03-12 16:58:52 -0700 | [diff] [blame] | 57 | } while (0) |
| 58 | |
Johannes Berg | 4c84a8f | 2010-01-22 14:22:54 -0800 | [diff] [blame] | 59 | #define DEBUGFS_ADD_X32(name, parent, ptr) do { \ |
| 60 | struct dentry *__tmp; \ |
| 61 | __tmp = debugfs_create_x32(#name, S_IWUSR | S_IRUSR, \ |
| 62 | parent, ptr); \ |
| 63 | if (IS_ERR(__tmp) || !__tmp) \ |
| 64 | goto err; \ |
Tomas Winkler | 445c2df | 2008-05-15 13:54:16 +0800 | [diff] [blame] | 65 | } while (0) |
| 66 | |
Johannes Berg | ca934b6 | 2011-09-15 11:46:48 -0700 | [diff] [blame] | 67 | #define DEBUGFS_ADD_U32(name, parent, ptr, mode) do { \ |
| 68 | struct dentry *__tmp; \ |
| 69 | __tmp = debugfs_create_u32(#name, mode, \ |
| 70 | parent, ptr); \ |
| 71 | if (IS_ERR(__tmp) || !__tmp) \ |
| 72 | goto err; \ |
| 73 | } while (0) |
| 74 | |
Tomas Winkler | 712b6cf | 2008-03-12 16:58:52 -0700 | [diff] [blame] | 75 | /* file operation */ |
| 76 | #define DEBUGFS_READ_FUNC(name) \ |
| 77 | static ssize_t iwl_dbgfs_##name##_read(struct file *file, \ |
| 78 | char __user *user_buf, \ |
| 79 | size_t count, loff_t *ppos); |
| 80 | |
| 81 | #define DEBUGFS_WRITE_FUNC(name) \ |
| 82 | static ssize_t iwl_dbgfs_##name##_write(struct file *file, \ |
| 83 | const char __user *user_buf, \ |
| 84 | size_t count, loff_t *ppos); |
| 85 | |
| 86 | |
| 87 | static int iwl_dbgfs_open_file_generic(struct inode *inode, struct file *file) |
| 88 | { |
| 89 | file->private_data = inode->i_private; |
| 90 | return 0; |
| 91 | } |
| 92 | |
| 93 | #define DEBUGFS_READ_FILE_OPS(name) \ |
| 94 | DEBUGFS_READ_FUNC(name); \ |
| 95 | static const struct file_operations iwl_dbgfs_##name##_ops = { \ |
| 96 | .read = iwl_dbgfs_##name##_read, \ |
| 97 | .open = iwl_dbgfs_open_file_generic, \ |
Arnd Bergmann | 2b18ab36 | 2010-07-06 19:05:31 +0200 | [diff] [blame] | 98 | .llseek = generic_file_llseek, \ |
Tomas Winkler | 712b6cf | 2008-03-12 16:58:52 -0700 | [diff] [blame] | 99 | }; |
| 100 | |
Ester Kummer | 189a2b5 | 2008-05-15 13:54:18 +0800 | [diff] [blame] | 101 | #define DEBUGFS_WRITE_FILE_OPS(name) \ |
| 102 | DEBUGFS_WRITE_FUNC(name); \ |
| 103 | static const struct file_operations iwl_dbgfs_##name##_ops = { \ |
| 104 | .write = iwl_dbgfs_##name##_write, \ |
| 105 | .open = iwl_dbgfs_open_file_generic, \ |
Arnd Bergmann | 2b18ab36 | 2010-07-06 19:05:31 +0200 | [diff] [blame] | 106 | .llseek = generic_file_llseek, \ |
Ester Kummer | 189a2b5 | 2008-05-15 13:54:18 +0800 | [diff] [blame] | 107 | }; |
| 108 | |
| 109 | |
Tomas Winkler | 712b6cf | 2008-03-12 16:58:52 -0700 | [diff] [blame] | 110 | #define DEBUGFS_READ_WRITE_FILE_OPS(name) \ |
| 111 | DEBUGFS_READ_FUNC(name); \ |
| 112 | DEBUGFS_WRITE_FUNC(name); \ |
| 113 | static const struct file_operations iwl_dbgfs_##name##_ops = { \ |
| 114 | .write = iwl_dbgfs_##name##_write, \ |
| 115 | .read = iwl_dbgfs_##name##_read, \ |
| 116 | .open = iwl_dbgfs_open_file_generic, \ |
Arnd Bergmann | 2b18ab36 | 2010-07-06 19:05:31 +0200 | [diff] [blame] | 117 | .llseek = generic_file_llseek, \ |
Tomas Winkler | 712b6cf | 2008-03-12 16:58:52 -0700 | [diff] [blame] | 118 | }; |
| 119 | |
Tomas Winkler | 712b6cf | 2008-03-12 16:58:52 -0700 | [diff] [blame] | 120 | static ssize_t iwl_dbgfs_tx_statistics_read(struct file *file, |
| 121 | char __user *user_buf, |
| 122 | size_t count, loff_t *ppos) { |
| 123 | |
H Hartley Sweeten | 28f63a4 | 2010-01-08 16:14:10 -0700 | [diff] [blame] | 124 | struct iwl_priv *priv = file->private_data; |
Wey-Yi Guy | 22fdf3c | 2009-08-07 15:41:40 -0700 | [diff] [blame] | 125 | char *buf; |
Tomas Winkler | 712b6cf | 2008-03-12 16:58:52 -0700 | [diff] [blame] | 126 | int pos = 0; |
| 127 | |
Wey-Yi Guy | 22fdf3c | 2009-08-07 15:41:40 -0700 | [diff] [blame] | 128 | int cnt; |
| 129 | ssize_t ret; |
Wey-Yi Guy | 98a7b43 | 2009-11-13 11:56:31 -0800 | [diff] [blame] | 130 | const size_t bufsz = 100 + |
| 131 | sizeof(char) * 50 * (MANAGEMENT_MAX + CONTROL_MAX); |
Wey-Yi Guy | 22fdf3c | 2009-08-07 15:41:40 -0700 | [diff] [blame] | 132 | buf = kzalloc(bufsz, GFP_KERNEL); |
| 133 | if (!buf) |
| 134 | return -ENOMEM; |
| 135 | pos += scnprintf(buf + pos, bufsz - pos, "Management:\n"); |
| 136 | for (cnt = 0; cnt < MANAGEMENT_MAX; cnt++) { |
| 137 | pos += scnprintf(buf + pos, bufsz - pos, |
Wey-Yi Guy | 98a7b43 | 2009-11-13 11:56:31 -0800 | [diff] [blame] | 138 | "\t%25s\t\t: %u\n", |
Wey-Yi Guy | 22fdf3c | 2009-08-07 15:41:40 -0700 | [diff] [blame] | 139 | get_mgmt_string(cnt), |
| 140 | priv->tx_stats.mgmt[cnt]); |
| 141 | } |
| 142 | pos += scnprintf(buf + pos, bufsz - pos, "Control\n"); |
| 143 | for (cnt = 0; cnt < CONTROL_MAX; cnt++) { |
| 144 | pos += scnprintf(buf + pos, bufsz - pos, |
Wey-Yi Guy | 98a7b43 | 2009-11-13 11:56:31 -0800 | [diff] [blame] | 145 | "\t%25s\t\t: %u\n", |
Wey-Yi Guy | 22fdf3c | 2009-08-07 15:41:40 -0700 | [diff] [blame] | 146 | get_ctrl_string(cnt), |
| 147 | priv->tx_stats.ctrl[cnt]); |
| 148 | } |
| 149 | pos += scnprintf(buf + pos, bufsz - pos, "Data:\n"); |
| 150 | pos += scnprintf(buf + pos, bufsz - pos, "\tcnt: %u\n", |
| 151 | priv->tx_stats.data_cnt); |
| 152 | pos += scnprintf(buf + pos, bufsz - pos, "\tbytes: %llu\n", |
| 153 | priv->tx_stats.data_bytes); |
| 154 | ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos); |
| 155 | kfree(buf); |
| 156 | return ret; |
| 157 | } |
Tomas Winkler | 712b6cf | 2008-03-12 16:58:52 -0700 | [diff] [blame] | 158 | |
Wey-Yi Guy | 7163b8a | 2009-11-20 12:04:56 -0800 | [diff] [blame] | 159 | static ssize_t iwl_dbgfs_clear_traffic_statistics_write(struct file *file, |
Wey-Yi Guy | 22fdf3c | 2009-08-07 15:41:40 -0700 | [diff] [blame] | 160 | const char __user *user_buf, |
| 161 | size_t count, loff_t *ppos) |
| 162 | { |
| 163 | struct iwl_priv *priv = file->private_data; |
| 164 | u32 clear_flag; |
| 165 | char buf[8]; |
| 166 | int buf_size; |
| 167 | |
| 168 | memset(buf, 0, sizeof(buf)); |
| 169 | buf_size = min(count, sizeof(buf) - 1); |
| 170 | if (copy_from_user(buf, user_buf, buf_size)) |
| 171 | return -EFAULT; |
| 172 | if (sscanf(buf, "%x", &clear_flag) != 1) |
| 173 | return -EFAULT; |
Wey-Yi Guy | 7163b8a | 2009-11-20 12:04:56 -0800 | [diff] [blame] | 174 | iwl_clear_traffic_stats(priv); |
Wey-Yi Guy | 22fdf3c | 2009-08-07 15:41:40 -0700 | [diff] [blame] | 175 | |
| 176 | return count; |
Tomas Winkler | 712b6cf | 2008-03-12 16:58:52 -0700 | [diff] [blame] | 177 | } |
| 178 | |
| 179 | static ssize_t iwl_dbgfs_rx_statistics_read(struct file *file, |
| 180 | char __user *user_buf, |
| 181 | size_t count, loff_t *ppos) { |
| 182 | |
H Hartley Sweeten | 28f63a4 | 2010-01-08 16:14:10 -0700 | [diff] [blame] | 183 | struct iwl_priv *priv = file->private_data; |
Wey-Yi Guy | 22fdf3c | 2009-08-07 15:41:40 -0700 | [diff] [blame] | 184 | char *buf; |
Tomas Winkler | 712b6cf | 2008-03-12 16:58:52 -0700 | [diff] [blame] | 185 | int pos = 0; |
Wey-Yi Guy | 22fdf3c | 2009-08-07 15:41:40 -0700 | [diff] [blame] | 186 | int cnt; |
| 187 | ssize_t ret; |
| 188 | const size_t bufsz = 100 + |
Wey-Yi Guy | 98a7b43 | 2009-11-13 11:56:31 -0800 | [diff] [blame] | 189 | sizeof(char) * 50 * (MANAGEMENT_MAX + CONTROL_MAX); |
Wey-Yi Guy | 22fdf3c | 2009-08-07 15:41:40 -0700 | [diff] [blame] | 190 | buf = kzalloc(bufsz, GFP_KERNEL); |
| 191 | if (!buf) |
| 192 | return -ENOMEM; |
Tomas Winkler | 712b6cf | 2008-03-12 16:58:52 -0700 | [diff] [blame] | 193 | |
Wey-Yi Guy | 22fdf3c | 2009-08-07 15:41:40 -0700 | [diff] [blame] | 194 | pos += scnprintf(buf + pos, bufsz - pos, "Management:\n"); |
| 195 | for (cnt = 0; cnt < MANAGEMENT_MAX; cnt++) { |
| 196 | pos += scnprintf(buf + pos, bufsz - pos, |
Wey-Yi Guy | 98a7b43 | 2009-11-13 11:56:31 -0800 | [diff] [blame] | 197 | "\t%25s\t\t: %u\n", |
Wey-Yi Guy | 22fdf3c | 2009-08-07 15:41:40 -0700 | [diff] [blame] | 198 | get_mgmt_string(cnt), |
| 199 | priv->rx_stats.mgmt[cnt]); |
| 200 | } |
| 201 | pos += scnprintf(buf + pos, bufsz - pos, "Control:\n"); |
| 202 | for (cnt = 0; cnt < CONTROL_MAX; cnt++) { |
| 203 | pos += scnprintf(buf + pos, bufsz - pos, |
Wey-Yi Guy | 98a7b43 | 2009-11-13 11:56:31 -0800 | [diff] [blame] | 204 | "\t%25s\t\t: %u\n", |
Wey-Yi Guy | 22fdf3c | 2009-08-07 15:41:40 -0700 | [diff] [blame] | 205 | get_ctrl_string(cnt), |
| 206 | priv->rx_stats.ctrl[cnt]); |
| 207 | } |
| 208 | pos += scnprintf(buf + pos, bufsz - pos, "Data:\n"); |
| 209 | pos += scnprintf(buf + pos, bufsz - pos, "\tcnt: %u\n", |
| 210 | priv->rx_stats.data_cnt); |
| 211 | pos += scnprintf(buf + pos, bufsz - pos, "\tbytes: %llu\n", |
| 212 | priv->rx_stats.data_bytes); |
Tomas Winkler | 712b6cf | 2008-03-12 16:58:52 -0700 | [diff] [blame] | 213 | |
Wey-Yi Guy | 22fdf3c | 2009-08-07 15:41:40 -0700 | [diff] [blame] | 214 | ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos); |
| 215 | kfree(buf); |
| 216 | return ret; |
| 217 | } |
| 218 | |
Tomas Winkler | 712b6cf | 2008-03-12 16:58:52 -0700 | [diff] [blame] | 219 | static ssize_t iwl_dbgfs_sram_read(struct file *file, |
| 220 | char __user *user_buf, |
| 221 | size_t count, loff_t *ppos) |
| 222 | { |
Jay Sternberg | 24834d2 | 2011-01-11 15:41:00 -0800 | [diff] [blame] | 223 | u32 val = 0; |
Wey-Yi Guy | 2943f13 | 2009-11-20 12:05:00 -0800 | [diff] [blame] | 224 | char *buf; |
Tomas Winkler | 712b6cf | 2008-03-12 16:58:52 -0700 | [diff] [blame] | 225 | ssize_t ret; |
Jay Sternberg | 24834d2 | 2011-01-11 15:41:00 -0800 | [diff] [blame] | 226 | int i = 0; |
| 227 | bool device_format = false; |
| 228 | int offset = 0; |
| 229 | int len = 0; |
Tomas Winkler | 712b6cf | 2008-03-12 16:58:52 -0700 | [diff] [blame] | 230 | int pos = 0; |
Jay Sternberg | 24834d2 | 2011-01-11 15:41:00 -0800 | [diff] [blame] | 231 | int sram; |
H Hartley Sweeten | 28f63a4 | 2010-01-08 16:14:10 -0700 | [diff] [blame] | 232 | struct iwl_priv *priv = file->private_data; |
Wey-Yi Guy | 2943f13 | 2009-11-20 12:05:00 -0800 | [diff] [blame] | 233 | size_t bufsz; |
Tomas Winkler | 712b6cf | 2008-03-12 16:58:52 -0700 | [diff] [blame] | 234 | |
Wey-Yi Guy | 5ade1e4 | 2009-11-20 12:05:04 -0800 | [diff] [blame] | 235 | /* default is to dump the entire data segment */ |
Johannes Berg | 4c84a8f | 2010-01-22 14:22:54 -0800 | [diff] [blame] | 236 | if (!priv->dbgfs_sram_offset && !priv->dbgfs_sram_len) { |
| 237 | priv->dbgfs_sram_offset = 0x800000; |
Johannes Berg | 0692fe4 | 2012-03-06 13:30:37 -0800 | [diff] [blame] | 238 | if (priv->shrd->ucode_type == IWL_UCODE_INIT) |
| 239 | priv->dbgfs_sram_len = priv->fw->ucode_init.data.len; |
Wey-Yi Guy | 5ade1e4 | 2009-11-20 12:05:04 -0800 | [diff] [blame] | 240 | else |
Johannes Berg | 0692fe4 | 2012-03-06 13:30:37 -0800 | [diff] [blame] | 241 | priv->dbgfs_sram_len = priv->fw->ucode_rt.data.len; |
Wey-Yi Guy | 5ade1e4 | 2009-11-20 12:05:04 -0800 | [diff] [blame] | 242 | } |
Jay Sternberg | 24834d2 | 2011-01-11 15:41:00 -0800 | [diff] [blame] | 243 | len = priv->dbgfs_sram_len; |
| 244 | |
| 245 | if (len == -4) { |
| 246 | device_format = true; |
| 247 | len = 4; |
| 248 | } |
| 249 | |
| 250 | bufsz = 50 + len * 4; |
Wey-Yi Guy | 2943f13 | 2009-11-20 12:05:00 -0800 | [diff] [blame] | 251 | buf = kmalloc(bufsz, GFP_KERNEL); |
| 252 | if (!buf) |
| 253 | return -ENOMEM; |
Jay Sternberg | 24834d2 | 2011-01-11 15:41:00 -0800 | [diff] [blame] | 254 | |
Wey-Yi Guy | 5ade1e4 | 2009-11-20 12:05:04 -0800 | [diff] [blame] | 255 | pos += scnprintf(buf + pos, bufsz - pos, "sram_len: 0x%x\n", |
Jay Sternberg | 24834d2 | 2011-01-11 15:41:00 -0800 | [diff] [blame] | 256 | len); |
Wey-Yi Guy | 5ade1e4 | 2009-11-20 12:05:04 -0800 | [diff] [blame] | 257 | pos += scnprintf(buf + pos, bufsz - pos, "sram_offset: 0x%x\n", |
Johannes Berg | 4c84a8f | 2010-01-22 14:22:54 -0800 | [diff] [blame] | 258 | priv->dbgfs_sram_offset); |
Jay Sternberg | 24834d2 | 2011-01-11 15:41:00 -0800 | [diff] [blame] | 259 | |
| 260 | /* adjust sram address since reads are only on even u32 boundaries */ |
| 261 | offset = priv->dbgfs_sram_offset & 0x3; |
| 262 | sram = priv->dbgfs_sram_offset & ~0x3; |
| 263 | |
| 264 | /* read the first u32 from sram */ |
Emmanuel Grumbach | 1042db2 | 2012-01-03 16:56:15 +0200 | [diff] [blame] | 265 | val = iwl_read_targ_mem(trans(priv), sram); |
Jay Sternberg | 24834d2 | 2011-01-11 15:41:00 -0800 | [diff] [blame] | 266 | |
| 267 | for (; len; len--) { |
| 268 | /* put the address at the start of every line */ |
| 269 | if (i == 0) |
| 270 | pos += scnprintf(buf + pos, bufsz - pos, |
| 271 | "%08X: ", sram + offset); |
| 272 | |
| 273 | if (device_format) |
| 274 | pos += scnprintf(buf + pos, bufsz - pos, |
| 275 | "%02x", (val >> (8 * (3 - offset))) & 0xff); |
| 276 | else |
| 277 | pos += scnprintf(buf + pos, bufsz - pos, |
| 278 | "%02x ", (val >> (8 * offset)) & 0xff); |
| 279 | |
| 280 | /* if all bytes processed, read the next u32 from sram */ |
| 281 | if (++offset == 4) { |
| 282 | sram += 4; |
| 283 | offset = 0; |
Emmanuel Grumbach | 1042db2 | 2012-01-03 16:56:15 +0200 | [diff] [blame] | 284 | val = iwl_read_targ_mem(trans(priv), sram); |
Tomas Winkler | 712b6cf | 2008-03-12 16:58:52 -0700 | [diff] [blame] | 285 | } |
Jay Sternberg | 24834d2 | 2011-01-11 15:41:00 -0800 | [diff] [blame] | 286 | |
| 287 | /* put in extra spaces and split lines for human readability */ |
| 288 | if (++i == 16) { |
| 289 | i = 0; |
Wey-Yi Guy | 2943f13 | 2009-11-20 12:05:00 -0800 | [diff] [blame] | 290 | pos += scnprintf(buf + pos, bufsz - pos, "\n"); |
Jay Sternberg | 24834d2 | 2011-01-11 15:41:00 -0800 | [diff] [blame] | 291 | } else if (!(i & 7)) { |
| 292 | pos += scnprintf(buf + pos, bufsz - pos, " "); |
| 293 | } else if (!(i & 3)) { |
| 294 | pos += scnprintf(buf + pos, bufsz - pos, " "); |
| 295 | } |
Tomas Winkler | 712b6cf | 2008-03-12 16:58:52 -0700 | [diff] [blame] | 296 | } |
Jay Sternberg | 24834d2 | 2011-01-11 15:41:00 -0800 | [diff] [blame] | 297 | if (i) |
| 298 | pos += scnprintf(buf + pos, bufsz - pos, "\n"); |
Tomas Winkler | 712b6cf | 2008-03-12 16:58:52 -0700 | [diff] [blame] | 299 | |
| 300 | ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos); |
Wey-Yi Guy | 2943f13 | 2009-11-20 12:05:00 -0800 | [diff] [blame] | 301 | kfree(buf); |
Tomas Winkler | 712b6cf | 2008-03-12 16:58:52 -0700 | [diff] [blame] | 302 | return ret; |
| 303 | } |
| 304 | |
| 305 | static ssize_t iwl_dbgfs_sram_write(struct file *file, |
| 306 | const char __user *user_buf, |
| 307 | size_t count, loff_t *ppos) |
| 308 | { |
| 309 | struct iwl_priv *priv = file->private_data; |
| 310 | char buf[64]; |
| 311 | int buf_size; |
| 312 | u32 offset, len; |
| 313 | |
| 314 | memset(buf, 0, sizeof(buf)); |
| 315 | buf_size = min(count, sizeof(buf) - 1); |
| 316 | if (copy_from_user(buf, user_buf, buf_size)) |
| 317 | return -EFAULT; |
| 318 | |
| 319 | if (sscanf(buf, "%x,%x", &offset, &len) == 2) { |
Johannes Berg | 4c84a8f | 2010-01-22 14:22:54 -0800 | [diff] [blame] | 320 | priv->dbgfs_sram_offset = offset; |
| 321 | priv->dbgfs_sram_len = len; |
Jay Sternberg | 24834d2 | 2011-01-11 15:41:00 -0800 | [diff] [blame] | 322 | } else if (sscanf(buf, "%x", &offset) == 1) { |
| 323 | priv->dbgfs_sram_offset = offset; |
| 324 | priv->dbgfs_sram_len = -4; |
Tomas Winkler | 712b6cf | 2008-03-12 16:58:52 -0700 | [diff] [blame] | 325 | } else { |
Johannes Berg | 4c84a8f | 2010-01-22 14:22:54 -0800 | [diff] [blame] | 326 | priv->dbgfs_sram_offset = 0; |
| 327 | priv->dbgfs_sram_len = 0; |
Tomas Winkler | 712b6cf | 2008-03-12 16:58:52 -0700 | [diff] [blame] | 328 | } |
| 329 | |
| 330 | return count; |
| 331 | } |
| 332 | |
Johannes Berg | c8ac61c | 2011-07-15 13:23:45 -0700 | [diff] [blame] | 333 | static ssize_t iwl_dbgfs_wowlan_sram_read(struct file *file, |
| 334 | char __user *user_buf, |
| 335 | size_t count, loff_t *ppos) |
| 336 | { |
| 337 | struct iwl_priv *priv = file->private_data; |
| 338 | |
| 339 | if (!priv->wowlan_sram) |
| 340 | return -ENODATA; |
| 341 | |
| 342 | return simple_read_from_buffer(user_buf, count, ppos, |
| 343 | priv->wowlan_sram, |
Johannes Berg | 0692fe4 | 2012-03-06 13:30:37 -0800 | [diff] [blame] | 344 | priv->fw->ucode_wowlan.data.len); |
Johannes Berg | c8ac61c | 2011-07-15 13:23:45 -0700 | [diff] [blame] | 345 | } |
Tomas Winkler | 712b6cf | 2008-03-12 16:58:52 -0700 | [diff] [blame] | 346 | static ssize_t iwl_dbgfs_stations_read(struct file *file, char __user *user_buf, |
| 347 | size_t count, loff_t *ppos) |
| 348 | { |
H Hartley Sweeten | 28f63a4 | 2010-01-08 16:14:10 -0700 | [diff] [blame] | 349 | struct iwl_priv *priv = file->private_data; |
Tomas Winkler | 6def976 | 2008-05-05 10:22:31 +0800 | [diff] [blame] | 350 | struct iwl_station_entry *station; |
Emmanuel Grumbach | 5f85a78 | 2011-08-25 23:11:18 -0700 | [diff] [blame] | 351 | struct iwl_tid_data *tid_data; |
Tomas Winkler | 712b6cf | 2008-03-12 16:58:52 -0700 | [diff] [blame] | 352 | char *buf; |
| 353 | int i, j, pos = 0; |
| 354 | ssize_t ret; |
| 355 | /* Add 30 for initial string */ |
| 356 | const size_t bufsz = 30 + sizeof(char) * 500 * (priv->num_stations); |
Tomas Winkler | 712b6cf | 2008-03-12 16:58:52 -0700 | [diff] [blame] | 357 | |
| 358 | buf = kmalloc(bufsz, GFP_KERNEL); |
Tomas Winkler | 3ac7f14 | 2008-07-21 02:40:14 +0300 | [diff] [blame] | 359 | if (!buf) |
Tomas Winkler | 712b6cf | 2008-03-12 16:58:52 -0700 | [diff] [blame] | 360 | return -ENOMEM; |
| 361 | |
Abhijeet Kolekar | db0589f | 2008-04-14 21:16:04 -0700 | [diff] [blame] | 362 | pos += scnprintf(buf + pos, bufsz - pos, "num of stations: %d\n\n", |
Tomas Winkler | 712b6cf | 2008-03-12 16:58:52 -0700 | [diff] [blame] | 363 | priv->num_stations); |
| 364 | |
Emmanuel Grumbach | 3eae4bb | 2011-10-10 07:26:55 -0700 | [diff] [blame] | 365 | for (i = 0; i < IWLAGN_STATION_COUNT; i++) { |
Tomas Winkler | 712b6cf | 2008-03-12 16:58:52 -0700 | [diff] [blame] | 366 | station = &priv->stations[i]; |
Johannes Berg | da73511 | 2010-05-03 01:25:24 -0700 | [diff] [blame] | 367 | if (!station->used) |
| 368 | continue; |
| 369 | pos += scnprintf(buf + pos, bufsz - pos, |
| 370 | "station %d - addr: %pM, flags: %#x\n", |
| 371 | i, station->sta.sta.addr, |
| 372 | station->sta.station_flags_msk); |
| 373 | pos += scnprintf(buf + pos, bufsz - pos, |
Emmanuel Grumbach | 76bc10f | 2011-11-21 13:25:31 +0200 | [diff] [blame] | 374 | "TID\tseq_num\trate_n_flags\n"); |
Tomas Winkler | 712b6cf | 2008-03-12 16:58:52 -0700 | [diff] [blame] | 375 | |
Emmanuel Grumbach | 5f85a78 | 2011-08-25 23:11:18 -0700 | [diff] [blame] | 376 | for (j = 0; j < IWL_MAX_TID_COUNT; j++) { |
Emmanuel Grumbach | 04cf682 | 2011-11-23 11:06:12 +0200 | [diff] [blame] | 377 | tid_data = &priv->tid_data[i][j]; |
Johannes Berg | da73511 | 2010-05-03 01:25:24 -0700 | [diff] [blame] | 378 | pos += scnprintf(buf + pos, bufsz - pos, |
Emmanuel Grumbach | 76bc10f | 2011-11-21 13:25:31 +0200 | [diff] [blame] | 379 | "%d:\t%#x\t%#x", |
Emmanuel Grumbach | 5f85a78 | 2011-08-25 23:11:18 -0700 | [diff] [blame] | 380 | j, tid_data->seq_number, |
Emmanuel Grumbach | 5f85a78 | 2011-08-25 23:11:18 -0700 | [diff] [blame] | 381 | tid_data->agg.rate_n_flags); |
Johannes Berg | da73511 | 2010-05-03 01:25:24 -0700 | [diff] [blame] | 382 | |
Emmanuel Grumbach | 5f85a78 | 2011-08-25 23:11:18 -0700 | [diff] [blame] | 383 | if (tid_data->agg.wait_for_ba) |
Abhijeet Kolekar | db0589f | 2008-04-14 21:16:04 -0700 | [diff] [blame] | 384 | pos += scnprintf(buf + pos, bufsz - pos, |
Johannes Berg | da73511 | 2010-05-03 01:25:24 -0700 | [diff] [blame] | 385 | " - waitforba"); |
Abhijeet Kolekar | db0589f | 2008-04-14 21:16:04 -0700 | [diff] [blame] | 386 | pos += scnprintf(buf + pos, bufsz - pos, "\n"); |
Tomas Winkler | 712b6cf | 2008-03-12 16:58:52 -0700 | [diff] [blame] | 387 | } |
Johannes Berg | da73511 | 2010-05-03 01:25:24 -0700 | [diff] [blame] | 388 | |
| 389 | pos += scnprintf(buf + pos, bufsz - pos, "\n"); |
Tomas Winkler | 712b6cf | 2008-03-12 16:58:52 -0700 | [diff] [blame] | 390 | } |
| 391 | |
| 392 | ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos); |
| 393 | kfree(buf); |
| 394 | return ret; |
| 395 | } |
| 396 | |
Wey-Yi Guy | 0848e29 | 2009-05-22 11:01:46 -0700 | [diff] [blame] | 397 | static ssize_t iwl_dbgfs_nvm_read(struct file *file, |
Tomas Winkler | 8dd266e | 2008-05-05 10:22:32 +0800 | [diff] [blame] | 398 | char __user *user_buf, |
| 399 | size_t count, |
| 400 | loff_t *ppos) |
| 401 | { |
| 402 | ssize_t ret; |
H Hartley Sweeten | 28f63a4 | 2010-01-08 16:14:10 -0700 | [diff] [blame] | 403 | struct iwl_priv *priv = file->private_data; |
Tomas Winkler | 8dd266e | 2008-05-05 10:22:32 +0800 | [diff] [blame] | 404 | int pos = 0, ofs = 0, buf_size = 0; |
| 405 | const u8 *ptr; |
| 406 | char *buf; |
Wey-Yi Guy | e307ddc | 2009-09-11 10:38:16 -0700 | [diff] [blame] | 407 | u16 eeprom_ver; |
Don Fry | 3862241 | 2011-12-16 07:07:36 -0800 | [diff] [blame] | 408 | size_t eeprom_len = cfg(priv)->base_params->eeprom_size; |
Tomas Winkler | 8dd266e | 2008-05-05 10:22:32 +0800 | [diff] [blame] | 409 | buf_size = 4 * eeprom_len + 256; |
| 410 | |
| 411 | if (eeprom_len % 16) { |
Wey-Yi Guy | 0848e29 | 2009-05-22 11:01:46 -0700 | [diff] [blame] | 412 | IWL_ERR(priv, "NVM size is not multiple of 16.\n"); |
Tomas Winkler | 8dd266e | 2008-05-05 10:22:32 +0800 | [diff] [blame] | 413 | return -ENODATA; |
| 414 | } |
| 415 | |
Don Fry | ab36eab | 2011-11-30 15:37:32 -0800 | [diff] [blame] | 416 | ptr = priv->shrd->eeprom; |
Julia Lawall | c37457e | 2009-08-03 11:11:45 +0200 | [diff] [blame] | 417 | if (!ptr) { |
| 418 | IWL_ERR(priv, "Invalid EEPROM/OTP memory\n"); |
| 419 | return -ENOMEM; |
| 420 | } |
| 421 | |
Tomas Winkler | 8dd266e | 2008-05-05 10:22:32 +0800 | [diff] [blame] | 422 | /* 4 characters for byte 0xYY */ |
| 423 | buf = kzalloc(buf_size, GFP_KERNEL); |
| 424 | if (!buf) { |
Winkler, Tomas | 15b1687 | 2008-12-19 10:37:33 +0800 | [diff] [blame] | 425 | IWL_ERR(priv, "Can not allocate Buffer\n"); |
Tomas Winkler | 8dd266e | 2008-05-05 10:22:32 +0800 | [diff] [blame] | 426 | return -ENOMEM; |
| 427 | } |
Don Fry | ab36eab | 2011-11-30 15:37:32 -0800 | [diff] [blame] | 428 | eeprom_ver = iwl_eeprom_query16(priv->shrd, EEPROM_VERSION); |
Wey-Yi Guy | e307ddc | 2009-09-11 10:38:16 -0700 | [diff] [blame] | 429 | pos += scnprintf(buf + pos, buf_size - pos, "NVM Type: %s, " |
| 430 | "version: 0x%x\n", |
Don Fry | 97b52cf | 2011-11-10 06:55:27 -0800 | [diff] [blame] | 431 | (trans(priv)->nvm_device_type == NVM_DEVICE_TYPE_OTP) |
Wey-Yi Guy | e307ddc | 2009-09-11 10:38:16 -0700 | [diff] [blame] | 432 | ? "OTP" : "EEPROM", eeprom_ver); |
Tomas Winkler | 8dd266e | 2008-05-05 10:22:32 +0800 | [diff] [blame] | 433 | for (ofs = 0 ; ofs < eeprom_len ; ofs += 16) { |
| 434 | pos += scnprintf(buf + pos, buf_size - pos, "0x%.4x ", ofs); |
| 435 | hex_dump_to_buffer(ptr + ofs, 16 , 16, 2, buf + pos, |
| 436 | buf_size - pos, 0); |
Reinette Chatre | 2fac971 | 2009-09-25 14:24:21 -0700 | [diff] [blame] | 437 | pos += strlen(buf + pos); |
Tomas Winkler | 8dd266e | 2008-05-05 10:22:32 +0800 | [diff] [blame] | 438 | if (buf_size - pos > 0) |
| 439 | buf[pos++] = '\n'; |
| 440 | } |
| 441 | |
| 442 | ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos); |
| 443 | kfree(buf); |
| 444 | return ret; |
| 445 | } |
Tomas Winkler | 712b6cf | 2008-03-12 16:58:52 -0700 | [diff] [blame] | 446 | |
Winkler, Tomas | d366df5 | 2008-12-02 12:14:01 -0800 | [diff] [blame] | 447 | static ssize_t iwl_dbgfs_channels_read(struct file *file, char __user *user_buf, |
| 448 | size_t count, loff_t *ppos) |
| 449 | { |
H Hartley Sweeten | 28f63a4 | 2010-01-08 16:14:10 -0700 | [diff] [blame] | 450 | struct iwl_priv *priv = file->private_data; |
Winkler, Tomas | d366df5 | 2008-12-02 12:14:01 -0800 | [diff] [blame] | 451 | struct ieee80211_channel *channels = NULL; |
| 452 | const struct ieee80211_supported_band *supp_band = NULL; |
| 453 | int pos = 0, i, bufsz = PAGE_SIZE; |
| 454 | char *buf; |
| 455 | ssize_t ret; |
| 456 | |
Emmanuel Grumbach | 63013ae | 2011-08-25 23:10:42 -0700 | [diff] [blame] | 457 | if (!test_bit(STATUS_GEO_CONFIGURED, &priv->shrd->status)) |
Winkler, Tomas | d366df5 | 2008-12-02 12:14:01 -0800 | [diff] [blame] | 458 | return -EAGAIN; |
| 459 | |
| 460 | buf = kzalloc(bufsz, GFP_KERNEL); |
| 461 | if (!buf) { |
Winkler, Tomas | 15b1687 | 2008-12-19 10:37:33 +0800 | [diff] [blame] | 462 | IWL_ERR(priv, "Can not allocate Buffer\n"); |
Winkler, Tomas | d366df5 | 2008-12-02 12:14:01 -0800 | [diff] [blame] | 463 | return -ENOMEM; |
| 464 | } |
| 465 | |
| 466 | supp_band = iwl_get_hw_mode(priv, IEEE80211_BAND_2GHZ); |
Wey-Yi Guy | a2e2322 | 2009-05-22 11:01:55 -0700 | [diff] [blame] | 467 | if (supp_band) { |
| 468 | channels = supp_band->channels; |
Winkler, Tomas | d366df5 | 2008-12-02 12:14:01 -0800 | [diff] [blame] | 469 | |
Winkler, Tomas | d366df5 | 2008-12-02 12:14:01 -0800 | [diff] [blame] | 470 | pos += scnprintf(buf + pos, bufsz - pos, |
Wey-Yi Guy | a2e2322 | 2009-05-22 11:01:55 -0700 | [diff] [blame] | 471 | "Displaying %d channels in 2.4GHz band 802.11bg):\n", |
| 472 | supp_band->n_channels); |
Winkler, Tomas | d366df5 | 2008-12-02 12:14:01 -0800 | [diff] [blame] | 473 | |
Wey-Yi Guy | a2e2322 | 2009-05-22 11:01:55 -0700 | [diff] [blame] | 474 | for (i = 0; i < supp_band->n_channels; i++) |
| 475 | pos += scnprintf(buf + pos, bufsz - pos, |
| 476 | "%d: %ddBm: BSS%s%s, %s.\n", |
Shanyu Zhao | 81e9543 | 2010-07-28 13:40:27 -0700 | [diff] [blame] | 477 | channels[i].hw_value, |
Wey-Yi Guy | a2e2322 | 2009-05-22 11:01:55 -0700 | [diff] [blame] | 478 | channels[i].max_power, |
| 479 | channels[i].flags & IEEE80211_CHAN_RADAR ? |
| 480 | " (IEEE 802.11h required)" : "", |
| 481 | ((channels[i].flags & IEEE80211_CHAN_NO_IBSS) |
| 482 | || (channels[i].flags & |
| 483 | IEEE80211_CHAN_RADAR)) ? "" : |
| 484 | ", IBSS", |
| 485 | channels[i].flags & |
| 486 | IEEE80211_CHAN_PASSIVE_SCAN ? |
| 487 | "passive only" : "active/passive"); |
| 488 | } |
Winkler, Tomas | d366df5 | 2008-12-02 12:14:01 -0800 | [diff] [blame] | 489 | supp_band = iwl_get_hw_mode(priv, IEEE80211_BAND_5GHZ); |
Wey-Yi Guy | a2e2322 | 2009-05-22 11:01:55 -0700 | [diff] [blame] | 490 | if (supp_band) { |
| 491 | channels = supp_band->channels; |
Winkler, Tomas | d366df5 | 2008-12-02 12:14:01 -0800 | [diff] [blame] | 492 | |
Winkler, Tomas | d366df5 | 2008-12-02 12:14:01 -0800 | [diff] [blame] | 493 | pos += scnprintf(buf + pos, bufsz - pos, |
Wey-Yi Guy | a2e2322 | 2009-05-22 11:01:55 -0700 | [diff] [blame] | 494 | "Displaying %d channels in 5.2GHz band (802.11a)\n", |
| 495 | supp_band->n_channels); |
| 496 | |
| 497 | for (i = 0; i < supp_band->n_channels; i++) |
| 498 | pos += scnprintf(buf + pos, bufsz - pos, |
| 499 | "%d: %ddBm: BSS%s%s, %s.\n", |
Shanyu Zhao | 81e9543 | 2010-07-28 13:40:27 -0700 | [diff] [blame] | 500 | channels[i].hw_value, |
Wey-Yi Guy | a2e2322 | 2009-05-22 11:01:55 -0700 | [diff] [blame] | 501 | channels[i].max_power, |
| 502 | channels[i].flags & IEEE80211_CHAN_RADAR ? |
| 503 | " (IEEE 802.11h required)" : "", |
| 504 | ((channels[i].flags & IEEE80211_CHAN_NO_IBSS) |
| 505 | || (channels[i].flags & |
| 506 | IEEE80211_CHAN_RADAR)) ? "" : |
| 507 | ", IBSS", |
| 508 | channels[i].flags & |
| 509 | IEEE80211_CHAN_PASSIVE_SCAN ? |
| 510 | "passive only" : "active/passive"); |
| 511 | } |
Winkler, Tomas | d366df5 | 2008-12-02 12:14:01 -0800 | [diff] [blame] | 512 | ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos); |
| 513 | kfree(buf); |
| 514 | return ret; |
| 515 | } |
| 516 | |
Wey-Yi Guy | 08df05a | 2009-03-24 10:02:54 -0700 | [diff] [blame] | 517 | static ssize_t iwl_dbgfs_status_read(struct file *file, |
| 518 | char __user *user_buf, |
| 519 | size_t count, loff_t *ppos) { |
| 520 | |
H Hartley Sweeten | 28f63a4 | 2010-01-08 16:14:10 -0700 | [diff] [blame] | 521 | struct iwl_priv *priv = file->private_data; |
Wey-Yi Guy | 08df05a | 2009-03-24 10:02:54 -0700 | [diff] [blame] | 522 | char buf[512]; |
| 523 | int pos = 0; |
| 524 | const size_t bufsz = sizeof(buf); |
| 525 | |
| 526 | pos += scnprintf(buf + pos, bufsz - pos, "STATUS_HCMD_ACTIVE:\t %d\n", |
Emmanuel Grumbach | 63013ae | 2011-08-25 23:10:42 -0700 | [diff] [blame] | 527 | test_bit(STATUS_HCMD_ACTIVE, &priv->shrd->status)); |
Wey-Yi Guy | 08df05a | 2009-03-24 10:02:54 -0700 | [diff] [blame] | 528 | pos += scnprintf(buf + pos, bufsz - pos, "STATUS_INT_ENABLED:\t %d\n", |
Emmanuel Grumbach | 63013ae | 2011-08-25 23:10:42 -0700 | [diff] [blame] | 529 | test_bit(STATUS_INT_ENABLED, &priv->shrd->status)); |
Wey-Yi Guy | 08df05a | 2009-03-24 10:02:54 -0700 | [diff] [blame] | 530 | pos += scnprintf(buf + pos, bufsz - pos, "STATUS_RF_KILL_HW:\t %d\n", |
Emmanuel Grumbach | 63013ae | 2011-08-25 23:10:42 -0700 | [diff] [blame] | 531 | test_bit(STATUS_RF_KILL_HW, &priv->shrd->status)); |
Wey-Yi Guy | 7812b16 | 2009-10-02 13:43:58 -0700 | [diff] [blame] | 532 | pos += scnprintf(buf + pos, bufsz - pos, "STATUS_CT_KILL:\t\t %d\n", |
Don Fry | 9a71686 | 2012-03-07 09:52:32 -0800 | [diff] [blame^] | 533 | test_bit(STATUS_CT_KILL, &priv->status)); |
Wey-Yi Guy | 08df05a | 2009-03-24 10:02:54 -0700 | [diff] [blame] | 534 | pos += scnprintf(buf + pos, bufsz - pos, "STATUS_ALIVE:\t\t %d\n", |
Emmanuel Grumbach | 63013ae | 2011-08-25 23:10:42 -0700 | [diff] [blame] | 535 | test_bit(STATUS_ALIVE, &priv->shrd->status)); |
Wey-Yi Guy | 08df05a | 2009-03-24 10:02:54 -0700 | [diff] [blame] | 536 | pos += scnprintf(buf + pos, bufsz - pos, "STATUS_READY:\t\t %d\n", |
Emmanuel Grumbach | 63013ae | 2011-08-25 23:10:42 -0700 | [diff] [blame] | 537 | test_bit(STATUS_READY, &priv->shrd->status)); |
Wey-Yi Guy | 08df05a | 2009-03-24 10:02:54 -0700 | [diff] [blame] | 538 | pos += scnprintf(buf + pos, bufsz - pos, "STATUS_GEO_CONFIGURED:\t %d\n", |
Emmanuel Grumbach | 63013ae | 2011-08-25 23:10:42 -0700 | [diff] [blame] | 539 | test_bit(STATUS_GEO_CONFIGURED, &priv->shrd->status)); |
Wey-Yi Guy | 08df05a | 2009-03-24 10:02:54 -0700 | [diff] [blame] | 540 | pos += scnprintf(buf + pos, bufsz - pos, "STATUS_EXIT_PENDING:\t %d\n", |
Emmanuel Grumbach | 63013ae | 2011-08-25 23:10:42 -0700 | [diff] [blame] | 541 | test_bit(STATUS_EXIT_PENDING, &priv->shrd->status)); |
Wey-Yi Guy | 08df05a | 2009-03-24 10:02:54 -0700 | [diff] [blame] | 542 | pos += scnprintf(buf + pos, bufsz - pos, "STATUS_STATISTICS:\t %d\n", |
Emmanuel Grumbach | 63013ae | 2011-08-25 23:10:42 -0700 | [diff] [blame] | 543 | test_bit(STATUS_STATISTICS, &priv->shrd->status)); |
Wey-Yi Guy | 08df05a | 2009-03-24 10:02:54 -0700 | [diff] [blame] | 544 | pos += scnprintf(buf + pos, bufsz - pos, "STATUS_SCANNING:\t %d\n", |
Emmanuel Grumbach | 63013ae | 2011-08-25 23:10:42 -0700 | [diff] [blame] | 545 | test_bit(STATUS_SCANNING, &priv->shrd->status)); |
Wey-Yi Guy | 08df05a | 2009-03-24 10:02:54 -0700 | [diff] [blame] | 546 | pos += scnprintf(buf + pos, bufsz - pos, "STATUS_SCAN_ABORTING:\t %d\n", |
Emmanuel Grumbach | 63013ae | 2011-08-25 23:10:42 -0700 | [diff] [blame] | 547 | test_bit(STATUS_SCAN_ABORTING, &priv->shrd->status)); |
Wey-Yi Guy | 08df05a | 2009-03-24 10:02:54 -0700 | [diff] [blame] | 548 | pos += scnprintf(buf + pos, bufsz - pos, "STATUS_SCAN_HW:\t\t %d\n", |
Emmanuel Grumbach | 63013ae | 2011-08-25 23:10:42 -0700 | [diff] [blame] | 549 | test_bit(STATUS_SCAN_HW, &priv->shrd->status)); |
Wey-Yi Guy | 08df05a | 2009-03-24 10:02:54 -0700 | [diff] [blame] | 550 | pos += scnprintf(buf + pos, bufsz - pos, "STATUS_POWER_PMI:\t %d\n", |
Emmanuel Grumbach | 63013ae | 2011-08-25 23:10:42 -0700 | [diff] [blame] | 551 | test_bit(STATUS_POWER_PMI, &priv->shrd->status)); |
Wey-Yi Guy | 08df05a | 2009-03-24 10:02:54 -0700 | [diff] [blame] | 552 | pos += scnprintf(buf + pos, bufsz - pos, "STATUS_FW_ERROR:\t %d\n", |
Emmanuel Grumbach | 63013ae | 2011-08-25 23:10:42 -0700 | [diff] [blame] | 553 | test_bit(STATUS_FW_ERROR, &priv->shrd->status)); |
Wey-Yi Guy | 08df05a | 2009-03-24 10:02:54 -0700 | [diff] [blame] | 554 | return simple_read_from_buffer(user_buf, count, ppos, buf, pos); |
| 555 | } |
| 556 | |
Emmanuel Grumbach | 1f7b617 | 2011-08-25 23:10:59 -0700 | [diff] [blame] | 557 | static ssize_t iwl_dbgfs_rx_handlers_read(struct file *file, |
Wey-Yi Guy | a83b914 | 2009-04-08 11:39:32 -0700 | [diff] [blame] | 558 | char __user *user_buf, |
| 559 | size_t count, loff_t *ppos) { |
| 560 | |
H Hartley Sweeten | 28f63a4 | 2010-01-08 16:14:10 -0700 | [diff] [blame] | 561 | struct iwl_priv *priv = file->private_data; |
Emmanuel Grumbach | 1f7b617 | 2011-08-25 23:10:59 -0700 | [diff] [blame] | 562 | |
Wey-Yi Guy | a83b914 | 2009-04-08 11:39:32 -0700 | [diff] [blame] | 563 | int pos = 0; |
| 564 | int cnt = 0; |
| 565 | char *buf; |
| 566 | int bufsz = 24 * 64; /* 24 items * 64 char per item */ |
| 567 | ssize_t ret; |
| 568 | |
| 569 | buf = kzalloc(bufsz, GFP_KERNEL); |
| 570 | if (!buf) { |
| 571 | IWL_ERR(priv, "Can not allocate Buffer\n"); |
| 572 | return -ENOMEM; |
| 573 | } |
| 574 | |
Wey-Yi Guy | a83b914 | 2009-04-08 11:39:32 -0700 | [diff] [blame] | 575 | for (cnt = 0; cnt < REPLY_MAX; cnt++) { |
Emmanuel Grumbach | 1f7b617 | 2011-08-25 23:10:59 -0700 | [diff] [blame] | 576 | if (priv->rx_handlers_stats[cnt] > 0) |
Wey-Yi Guy | a83b914 | 2009-04-08 11:39:32 -0700 | [diff] [blame] | 577 | pos += scnprintf(buf + pos, bufsz - pos, |
| 578 | "\tRx handler[%36s]:\t\t %u\n", |
| 579 | get_cmd_string(cnt), |
Emmanuel Grumbach | 1f7b617 | 2011-08-25 23:10:59 -0700 | [diff] [blame] | 580 | priv->rx_handlers_stats[cnt]); |
Wey-Yi Guy | a83b914 | 2009-04-08 11:39:32 -0700 | [diff] [blame] | 581 | } |
| 582 | |
Wey-Yi Guy | a83b914 | 2009-04-08 11:39:32 -0700 | [diff] [blame] | 583 | ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos); |
| 584 | kfree(buf); |
| 585 | return ret; |
| 586 | } |
| 587 | |
Emmanuel Grumbach | 1f7b617 | 2011-08-25 23:10:59 -0700 | [diff] [blame] | 588 | static ssize_t iwl_dbgfs_rx_handlers_write(struct file *file, |
Wey-Yi Guy | a83b914 | 2009-04-08 11:39:32 -0700 | [diff] [blame] | 589 | const char __user *user_buf, |
| 590 | size_t count, loff_t *ppos) |
| 591 | { |
| 592 | struct iwl_priv *priv = file->private_data; |
Emmanuel Grumbach | 1f7b617 | 2011-08-25 23:10:59 -0700 | [diff] [blame] | 593 | |
Wey-Yi Guy | a83b914 | 2009-04-08 11:39:32 -0700 | [diff] [blame] | 594 | char buf[8]; |
| 595 | int buf_size; |
| 596 | u32 reset_flag; |
| 597 | |
| 598 | memset(buf, 0, sizeof(buf)); |
| 599 | buf_size = min(count, sizeof(buf) - 1); |
| 600 | if (copy_from_user(buf, user_buf, buf_size)) |
| 601 | return -EFAULT; |
| 602 | if (sscanf(buf, "%x", &reset_flag) != 1) |
| 603 | return -EFAULT; |
| 604 | if (reset_flag == 0) |
Emmanuel Grumbach | 1f7b617 | 2011-08-25 23:10:59 -0700 | [diff] [blame] | 605 | memset(&priv->rx_handlers_stats[0], 0, |
| 606 | sizeof(priv->rx_handlers_stats)); |
Wey-Yi Guy | a83b914 | 2009-04-08 11:39:32 -0700 | [diff] [blame] | 607 | |
| 608 | return count; |
| 609 | } |
| 610 | |
Wey-Yi Guy | f5ad69f | 2009-07-09 10:33:36 -0700 | [diff] [blame] | 611 | static ssize_t iwl_dbgfs_qos_read(struct file *file, char __user *user_buf, |
| 612 | size_t count, loff_t *ppos) |
| 613 | { |
H Hartley Sweeten | 28f63a4 | 2010-01-08 16:14:10 -0700 | [diff] [blame] | 614 | struct iwl_priv *priv = file->private_data; |
Johannes Berg | 8dfdb9d | 2010-08-23 10:46:38 +0200 | [diff] [blame] | 615 | struct iwl_rxon_context *ctx; |
Wey-Yi Guy | f5ad69f | 2009-07-09 10:33:36 -0700 | [diff] [blame] | 616 | int pos = 0, i; |
Johannes Berg | 8dfdb9d | 2010-08-23 10:46:38 +0200 | [diff] [blame] | 617 | char buf[256 * NUM_IWL_RXON_CTX]; |
Wey-Yi Guy | f5ad69f | 2009-07-09 10:33:36 -0700 | [diff] [blame] | 618 | const size_t bufsz = sizeof(buf); |
Wey-Yi Guy | f5ad69f | 2009-07-09 10:33:36 -0700 | [diff] [blame] | 619 | |
Johannes Berg | 8dfdb9d | 2010-08-23 10:46:38 +0200 | [diff] [blame] | 620 | for_each_context(priv, ctx) { |
| 621 | pos += scnprintf(buf + pos, bufsz - pos, "context %d:\n", |
| 622 | ctx->ctxid); |
| 623 | for (i = 0; i < AC_NUM; i++) { |
| 624 | pos += scnprintf(buf + pos, bufsz - pos, |
| 625 | "\tcw_min\tcw_max\taifsn\ttxop\n"); |
| 626 | pos += scnprintf(buf + pos, bufsz - pos, |
Wey-Yi Guy | f5ad69f | 2009-07-09 10:33:36 -0700 | [diff] [blame] | 627 | "AC[%d]\t%u\t%u\t%u\t%u\n", i, |
Johannes Berg | 8dfdb9d | 2010-08-23 10:46:38 +0200 | [diff] [blame] | 628 | ctx->qos_data.def_qos_parm.ac[i].cw_min, |
| 629 | ctx->qos_data.def_qos_parm.ac[i].cw_max, |
| 630 | ctx->qos_data.def_qos_parm.ac[i].aifsn, |
| 631 | ctx->qos_data.def_qos_parm.ac[i].edca_txop); |
| 632 | } |
| 633 | pos += scnprintf(buf + pos, bufsz - pos, "\n"); |
Wey-Yi Guy | f5ad69f | 2009-07-09 10:33:36 -0700 | [diff] [blame] | 634 | } |
Wey-Yi Guy | 4967c31 | 2010-02-18 15:22:07 -0800 | [diff] [blame] | 635 | return simple_read_from_buffer(user_buf, count, ppos, buf, pos); |
Wey-Yi Guy | f5ad69f | 2009-07-09 10:33:36 -0700 | [diff] [blame] | 636 | } |
Wey-Yi Guy | a83b914 | 2009-04-08 11:39:32 -0700 | [diff] [blame] | 637 | |
Wey-Yi Guy | fbf3a2a | 2009-07-24 11:13:04 -0700 | [diff] [blame] | 638 | static ssize_t iwl_dbgfs_thermal_throttling_read(struct file *file, |
| 639 | char __user *user_buf, |
| 640 | size_t count, loff_t *ppos) |
| 641 | { |
H Hartley Sweeten | 28f63a4 | 2010-01-08 16:14:10 -0700 | [diff] [blame] | 642 | struct iwl_priv *priv = file->private_data; |
Johannes Berg | 3ad3b92 | 2009-08-07 15:41:48 -0700 | [diff] [blame] | 643 | struct iwl_tt_mgmt *tt = &priv->thermal_throttle; |
Wey-Yi Guy | fbf3a2a | 2009-07-24 11:13:04 -0700 | [diff] [blame] | 644 | struct iwl_tt_restriction *restriction; |
| 645 | char buf[100]; |
| 646 | int pos = 0; |
| 647 | const size_t bufsz = sizeof(buf); |
Wey-Yi Guy | fbf3a2a | 2009-07-24 11:13:04 -0700 | [diff] [blame] | 648 | |
| 649 | pos += scnprintf(buf + pos, bufsz - pos, |
| 650 | "Thermal Throttling Mode: %s\n", |
Johannes Berg | 3ad3b92 | 2009-08-07 15:41:48 -0700 | [diff] [blame] | 651 | tt->advanced_tt ? "Advance" : "Legacy"); |
Wey-Yi Guy | fbf3a2a | 2009-07-24 11:13:04 -0700 | [diff] [blame] | 652 | pos += scnprintf(buf + pos, bufsz - pos, |
| 653 | "Thermal Throttling State: %d\n", |
| 654 | tt->state); |
Johannes Berg | 3ad3b92 | 2009-08-07 15:41:48 -0700 | [diff] [blame] | 655 | if (tt->advanced_tt) { |
Wey-Yi Guy | fbf3a2a | 2009-07-24 11:13:04 -0700 | [diff] [blame] | 656 | restriction = tt->restriction + tt->state; |
| 657 | pos += scnprintf(buf + pos, bufsz - pos, |
| 658 | "Tx mode: %d\n", |
| 659 | restriction->tx_stream); |
| 660 | pos += scnprintf(buf + pos, bufsz - pos, |
| 661 | "Rx mode: %d\n", |
| 662 | restriction->rx_stream); |
| 663 | pos += scnprintf(buf + pos, bufsz - pos, |
| 664 | "HT mode: %d\n", |
| 665 | restriction->is_ht); |
| 666 | } |
Wey-Yi Guy | 4967c31 | 2010-02-18 15:22:07 -0800 | [diff] [blame] | 667 | return simple_read_from_buffer(user_buf, count, ppos, buf, pos); |
Wey-Yi Guy | fbf3a2a | 2009-07-24 11:13:04 -0700 | [diff] [blame] | 668 | } |
| 669 | |
Wey-Yi Guy | 1e4247d | 2009-07-27 13:50:15 -0700 | [diff] [blame] | 670 | static ssize_t iwl_dbgfs_disable_ht40_write(struct file *file, |
| 671 | const char __user *user_buf, |
| 672 | size_t count, loff_t *ppos) |
| 673 | { |
| 674 | struct iwl_priv *priv = file->private_data; |
| 675 | char buf[8]; |
| 676 | int buf_size; |
| 677 | int ht40; |
| 678 | |
| 679 | memset(buf, 0, sizeof(buf)); |
| 680 | buf_size = min(count, sizeof(buf) - 1); |
| 681 | if (copy_from_user(buf, user_buf, buf_size)) |
| 682 | return -EFAULT; |
| 683 | if (sscanf(buf, "%d", &ht40) != 1) |
| 684 | return -EFAULT; |
Johannes Berg | 246ed35 | 2010-08-23 10:46:32 +0200 | [diff] [blame] | 685 | if (!iwl_is_any_associated(priv)) |
Wey-Yi Guy | 1e4247d | 2009-07-27 13:50:15 -0700 | [diff] [blame] | 686 | priv->disable_ht40 = ht40 ? true : false; |
| 687 | else { |
| 688 | IWL_ERR(priv, "Sta associated with AP - " |
| 689 | "Change to 40MHz channel support is not allowed\n"); |
| 690 | return -EINVAL; |
| 691 | } |
| 692 | |
| 693 | return count; |
| 694 | } |
| 695 | |
| 696 | static ssize_t iwl_dbgfs_disable_ht40_read(struct file *file, |
| 697 | char __user *user_buf, |
| 698 | size_t count, loff_t *ppos) |
| 699 | { |
H Hartley Sweeten | 28f63a4 | 2010-01-08 16:14:10 -0700 | [diff] [blame] | 700 | struct iwl_priv *priv = file->private_data; |
Wey-Yi Guy | 1e4247d | 2009-07-27 13:50:15 -0700 | [diff] [blame] | 701 | char buf[100]; |
| 702 | int pos = 0; |
| 703 | const size_t bufsz = sizeof(buf); |
Wey-Yi Guy | 1e4247d | 2009-07-27 13:50:15 -0700 | [diff] [blame] | 704 | |
| 705 | pos += scnprintf(buf + pos, bufsz - pos, |
| 706 | "11n 40MHz Mode: %s\n", |
| 707 | priv->disable_ht40 ? "Disabled" : "Enabled"); |
Wey-Yi Guy | 4967c31 | 2010-02-18 15:22:07 -0800 | [diff] [blame] | 708 | return simple_read_from_buffer(user_buf, count, ppos, buf, pos); |
Wey-Yi Guy | 1e4247d | 2009-07-27 13:50:15 -0700 | [diff] [blame] | 709 | } |
| 710 | |
Emmanuel Grumbach | 511afa3 | 2011-09-22 07:15:37 -0700 | [diff] [blame] | 711 | static ssize_t iwl_dbgfs_temperature_read(struct file *file, |
| 712 | char __user *user_buf, |
| 713 | size_t count, loff_t *ppos) |
| 714 | { |
| 715 | struct iwl_priv *priv = file->private_data; |
| 716 | char buf[8]; |
| 717 | int pos = 0; |
| 718 | const size_t bufsz = sizeof(buf); |
| 719 | |
| 720 | pos += scnprintf(buf + pos, bufsz - pos, "%d\n", priv->temperature); |
| 721 | return simple_read_from_buffer(user_buf, count, ppos, buf, pos); |
| 722 | } |
| 723 | |
| 724 | |
Johannes Berg | e312c24 | 2009-08-07 15:41:51 -0700 | [diff] [blame] | 725 | static ssize_t iwl_dbgfs_sleep_level_override_write(struct file *file, |
| 726 | const char __user *user_buf, |
| 727 | size_t count, loff_t *ppos) |
| 728 | { |
| 729 | struct iwl_priv *priv = file->private_data; |
| 730 | char buf[8]; |
| 731 | int buf_size; |
| 732 | int value; |
| 733 | |
| 734 | memset(buf, 0, sizeof(buf)); |
| 735 | buf_size = min(count, sizeof(buf) - 1); |
| 736 | if (copy_from_user(buf, user_buf, buf_size)) |
| 737 | return -EFAULT; |
| 738 | |
| 739 | if (sscanf(buf, "%d", &value) != 1) |
| 740 | return -EINVAL; |
| 741 | |
| 742 | /* |
| 743 | * Our users expect 0 to be "CAM", but 0 isn't actually |
| 744 | * valid here. However, let's not confuse them and present |
| 745 | * IWL_POWER_INDEX_1 as "1", not "0". |
| 746 | */ |
Reinette Chatre | 1a34c04 | 2009-10-09 13:20:25 -0700 | [diff] [blame] | 747 | if (value == 0) |
| 748 | return -EINVAL; |
| 749 | else if (value > 0) |
Johannes Berg | e312c24 | 2009-08-07 15:41:51 -0700 | [diff] [blame] | 750 | value -= 1; |
| 751 | |
| 752 | if (value != -1 && (value < 0 || value >= IWL_POWER_NUM)) |
| 753 | return -EINVAL; |
| 754 | |
Emmanuel Grumbach | 845a9c0 | 2011-08-25 23:11:04 -0700 | [diff] [blame] | 755 | if (!iwl_is_ready_rf(priv->shrd)) |
Wey-Yi Guy | 4ad177b | 2009-10-16 14:25:58 -0700 | [diff] [blame] | 756 | return -EAGAIN; |
| 757 | |
Johannes Berg | e312c24 | 2009-08-07 15:41:51 -0700 | [diff] [blame] | 758 | priv->power_data.debug_sleep_level_override = value; |
| 759 | |
Johannes Berg | b1eea29 | 2012-03-06 13:30:42 -0800 | [diff] [blame] | 760 | mutex_lock(&priv->mutex); |
Wey-Yi Guy | 4ad177b | 2009-10-16 14:25:58 -0700 | [diff] [blame] | 761 | iwl_power_update_mode(priv, true); |
Johannes Berg | b1eea29 | 2012-03-06 13:30:42 -0800 | [diff] [blame] | 762 | mutex_unlock(&priv->mutex); |
Johannes Berg | e312c24 | 2009-08-07 15:41:51 -0700 | [diff] [blame] | 763 | |
| 764 | return count; |
| 765 | } |
| 766 | |
| 767 | static ssize_t iwl_dbgfs_sleep_level_override_read(struct file *file, |
| 768 | char __user *user_buf, |
| 769 | size_t count, loff_t *ppos) |
| 770 | { |
H Hartley Sweeten | 28f63a4 | 2010-01-08 16:14:10 -0700 | [diff] [blame] | 771 | struct iwl_priv *priv = file->private_data; |
Johannes Berg | e312c24 | 2009-08-07 15:41:51 -0700 | [diff] [blame] | 772 | char buf[10]; |
| 773 | int pos, value; |
| 774 | const size_t bufsz = sizeof(buf); |
| 775 | |
| 776 | /* see the write function */ |
| 777 | value = priv->power_data.debug_sleep_level_override; |
| 778 | if (value >= 0) |
| 779 | value += 1; |
| 780 | |
| 781 | pos = scnprintf(buf, bufsz, "%d\n", value); |
| 782 | return simple_read_from_buffer(user_buf, count, ppos, buf, pos); |
| 783 | } |
| 784 | |
| 785 | static ssize_t iwl_dbgfs_current_sleep_command_read(struct file *file, |
| 786 | char __user *user_buf, |
| 787 | size_t count, loff_t *ppos) |
| 788 | { |
H Hartley Sweeten | 28f63a4 | 2010-01-08 16:14:10 -0700 | [diff] [blame] | 789 | struct iwl_priv *priv = file->private_data; |
Johannes Berg | e312c24 | 2009-08-07 15:41:51 -0700 | [diff] [blame] | 790 | char buf[200]; |
| 791 | int pos = 0, i; |
| 792 | const size_t bufsz = sizeof(buf); |
| 793 | struct iwl_powertable_cmd *cmd = &priv->power_data.sleep_cmd; |
| 794 | |
| 795 | pos += scnprintf(buf + pos, bufsz - pos, |
| 796 | "flags: %#.2x\n", le16_to_cpu(cmd->flags)); |
| 797 | pos += scnprintf(buf + pos, bufsz - pos, |
| 798 | "RX/TX timeout: %d/%d usec\n", |
| 799 | le32_to_cpu(cmd->rx_data_timeout), |
| 800 | le32_to_cpu(cmd->tx_data_timeout)); |
| 801 | for (i = 0; i < IWL_POWER_VEC_SIZE; i++) |
| 802 | pos += scnprintf(buf + pos, bufsz - pos, |
| 803 | "sleep_interval[%d]: %d\n", i, |
| 804 | le32_to_cpu(cmd->sleep_interval[i])); |
| 805 | |
| 806 | return simple_read_from_buffer(user_buf, count, ppos, buf, pos); |
| 807 | } |
| 808 | |
Tomas Winkler | 712b6cf | 2008-03-12 16:58:52 -0700 | [diff] [blame] | 809 | DEBUGFS_READ_WRITE_FILE_OPS(sram); |
Johannes Berg | c8ac61c | 2011-07-15 13:23:45 -0700 | [diff] [blame] | 810 | DEBUGFS_READ_FILE_OPS(wowlan_sram); |
Wey-Yi Guy | 0848e29 | 2009-05-22 11:01:46 -0700 | [diff] [blame] | 811 | DEBUGFS_READ_FILE_OPS(nvm); |
Tomas Winkler | 712b6cf | 2008-03-12 16:58:52 -0700 | [diff] [blame] | 812 | DEBUGFS_READ_FILE_OPS(stations); |
Winkler, Tomas | d366df5 | 2008-12-02 12:14:01 -0800 | [diff] [blame] | 813 | DEBUGFS_READ_FILE_OPS(channels); |
Wey-Yi Guy | 08df05a | 2009-03-24 10:02:54 -0700 | [diff] [blame] | 814 | DEBUGFS_READ_FILE_OPS(status); |
Emmanuel Grumbach | 1f7b617 | 2011-08-25 23:10:59 -0700 | [diff] [blame] | 815 | DEBUGFS_READ_WRITE_FILE_OPS(rx_handlers); |
Wey-Yi Guy | f5ad69f | 2009-07-09 10:33:36 -0700 | [diff] [blame] | 816 | DEBUGFS_READ_FILE_OPS(qos); |
Wey-Yi Guy | fbf3a2a | 2009-07-24 11:13:04 -0700 | [diff] [blame] | 817 | DEBUGFS_READ_FILE_OPS(thermal_throttling); |
Wey-Yi Guy | 1e4247d | 2009-07-27 13:50:15 -0700 | [diff] [blame] | 818 | DEBUGFS_READ_WRITE_FILE_OPS(disable_ht40); |
Emmanuel Grumbach | 511afa3 | 2011-09-22 07:15:37 -0700 | [diff] [blame] | 819 | DEBUGFS_READ_FILE_OPS(temperature); |
Johannes Berg | e312c24 | 2009-08-07 15:41:51 -0700 | [diff] [blame] | 820 | DEBUGFS_READ_WRITE_FILE_OPS(sleep_level_override); |
| 821 | DEBUGFS_READ_FILE_OPS(current_sleep_command); |
Tomas Winkler | 712b6cf | 2008-03-12 16:58:52 -0700 | [diff] [blame] | 822 | |
Emmanuel Grumbach | 41f5e04 | 2011-09-06 09:31:20 -0700 | [diff] [blame] | 823 | static ssize_t iwl_dbgfs_traffic_log_read(struct file *file, |
| 824 | char __user *user_buf, |
| 825 | size_t count, loff_t *ppos) |
| 826 | { |
| 827 | struct iwl_priv *priv = file->private_data; |
| 828 | int pos = 0, ofs = 0; |
| 829 | int cnt = 0, entry; |
| 830 | |
| 831 | char *buf; |
| 832 | int bufsz = ((IWL_TRAFFIC_ENTRIES * IWL_TRAFFIC_ENTRY_SIZE * 64) * 2) + |
| 833 | (hw_params(priv).max_txq_num * 32 * 8) + 400; |
| 834 | const u8 *ptr; |
| 835 | ssize_t ret; |
| 836 | |
| 837 | buf = kzalloc(bufsz, GFP_KERNEL); |
| 838 | if (!buf) { |
| 839 | IWL_ERR(priv, "Can not allocate buffer\n"); |
| 840 | return -ENOMEM; |
| 841 | } |
Johannes Berg | a8bceb3 | 2012-03-05 11:24:30 -0800 | [diff] [blame] | 842 | if (priv->tx_traffic && iwl_have_debug_level(IWL_DL_TX)) { |
Emmanuel Grumbach | 41f5e04 | 2011-09-06 09:31:20 -0700 | [diff] [blame] | 843 | ptr = priv->tx_traffic; |
| 844 | pos += scnprintf(buf + pos, bufsz - pos, |
| 845 | "Tx Traffic idx: %u\n", priv->tx_traffic_idx); |
| 846 | for (cnt = 0, ofs = 0; cnt < IWL_TRAFFIC_ENTRIES; cnt++) { |
| 847 | for (entry = 0; entry < IWL_TRAFFIC_ENTRY_SIZE / 16; |
| 848 | entry++, ofs += 16) { |
| 849 | pos += scnprintf(buf + pos, bufsz - pos, |
| 850 | "0x%.4x ", ofs); |
| 851 | hex_dump_to_buffer(ptr + ofs, 16, 16, 2, |
| 852 | buf + pos, bufsz - pos, 0); |
| 853 | pos += strlen(buf + pos); |
| 854 | if (bufsz - pos > 0) |
| 855 | buf[pos++] = '\n'; |
| 856 | } |
| 857 | } |
| 858 | } |
| 859 | |
Johannes Berg | a8bceb3 | 2012-03-05 11:24:30 -0800 | [diff] [blame] | 860 | if (priv->rx_traffic && iwl_have_debug_level(IWL_DL_RX)) { |
Emmanuel Grumbach | 41f5e04 | 2011-09-06 09:31:20 -0700 | [diff] [blame] | 861 | ptr = priv->rx_traffic; |
| 862 | pos += scnprintf(buf + pos, bufsz - pos, |
| 863 | "Rx Traffic idx: %u\n", priv->rx_traffic_idx); |
| 864 | for (cnt = 0, ofs = 0; cnt < IWL_TRAFFIC_ENTRIES; cnt++) { |
| 865 | for (entry = 0; entry < IWL_TRAFFIC_ENTRY_SIZE / 16; |
| 866 | entry++, ofs += 16) { |
| 867 | pos += scnprintf(buf + pos, bufsz - pos, |
| 868 | "0x%.4x ", ofs); |
| 869 | hex_dump_to_buffer(ptr + ofs, 16, 16, 2, |
| 870 | buf + pos, bufsz - pos, 0); |
| 871 | pos += strlen(buf + pos); |
| 872 | if (bufsz - pos > 0) |
| 873 | buf[pos++] = '\n'; |
| 874 | } |
| 875 | } |
| 876 | } |
| 877 | |
| 878 | ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos); |
| 879 | kfree(buf); |
| 880 | return ret; |
| 881 | } |
| 882 | |
| 883 | static ssize_t iwl_dbgfs_traffic_log_write(struct file *file, |
| 884 | const char __user *user_buf, |
| 885 | size_t count, loff_t *ppos) |
| 886 | { |
| 887 | struct iwl_priv *priv = file->private_data; |
| 888 | char buf[8]; |
| 889 | int buf_size; |
| 890 | int traffic_log; |
| 891 | |
| 892 | memset(buf, 0, sizeof(buf)); |
| 893 | buf_size = min(count, sizeof(buf) - 1); |
| 894 | if (copy_from_user(buf, user_buf, buf_size)) |
| 895 | return -EFAULT; |
| 896 | if (sscanf(buf, "%d", &traffic_log) != 1) |
| 897 | return -EFAULT; |
| 898 | if (traffic_log == 0) |
| 899 | iwl_reset_traffic_log(priv); |
| 900 | |
| 901 | return count; |
| 902 | } |
| 903 | |
Wey-Yi Guy | d6d023a | 2011-04-30 09:10:53 -0700 | [diff] [blame] | 904 | static const char *fmt_value = " %-30s %10u\n"; |
| 905 | static const char *fmt_hex = " %-30s 0x%02X\n"; |
| 906 | static const char *fmt_table = " %-30s %10u %10u %10u %10u\n"; |
| 907 | static const char *fmt_header = |
| 908 | "%-32s current cumulative delta max\n"; |
| 909 | |
| 910 | static int iwl_statistics_flag(struct iwl_priv *priv, char *buf, int bufsz) |
| 911 | { |
| 912 | int p = 0; |
| 913 | u32 flag; |
| 914 | |
Johannes Berg | 4ff70fc | 2012-03-05 11:24:26 -0800 | [diff] [blame] | 915 | lockdep_assert_held(&priv->statistics.lock); |
| 916 | |
Wey-Yi Guy | d6d023a | 2011-04-30 09:10:53 -0700 | [diff] [blame] | 917 | flag = le32_to_cpu(priv->statistics.flag); |
| 918 | |
| 919 | p += scnprintf(buf + p, bufsz - p, "Statistics Flag(0x%X):\n", flag); |
| 920 | if (flag & UCODE_STATISTICS_CLEAR_MSK) |
| 921 | p += scnprintf(buf + p, bufsz - p, |
| 922 | "\tStatistics have been cleared\n"); |
| 923 | p += scnprintf(buf + p, bufsz - p, "\tOperational Frequency: %s\n", |
| 924 | (flag & UCODE_STATISTICS_FREQUENCY_MSK) |
| 925 | ? "2.4 GHz" : "5.2 GHz"); |
| 926 | p += scnprintf(buf + p, bufsz - p, "\tTGj Narrow Band: %s\n", |
| 927 | (flag & UCODE_STATISTICS_NARROW_BAND_MSK) |
| 928 | ? "enabled" : "disabled"); |
| 929 | |
| 930 | return p; |
| 931 | } |
| 932 | |
Wey-Yi Guy | e8fe59a | 2009-08-07 15:41:42 -0700 | [diff] [blame] | 933 | static ssize_t iwl_dbgfs_ucode_rx_stats_read(struct file *file, |
| 934 | char __user *user_buf, |
| 935 | size_t count, loff_t *ppos) |
| 936 | { |
H Hartley Sweeten | 28f63a4 | 2010-01-08 16:14:10 -0700 | [diff] [blame] | 937 | struct iwl_priv *priv = file->private_data; |
Wey-Yi Guy | d6d023a | 2011-04-30 09:10:53 -0700 | [diff] [blame] | 938 | int pos = 0; |
| 939 | char *buf; |
| 940 | int bufsz = sizeof(struct statistics_rx_phy) * 40 + |
| 941 | sizeof(struct statistics_rx_non_phy) * 40 + |
| 942 | sizeof(struct statistics_rx_ht_phy) * 40 + 400; |
| 943 | ssize_t ret; |
| 944 | struct statistics_rx_phy *ofdm, *accum_ofdm, *delta_ofdm, *max_ofdm; |
| 945 | struct statistics_rx_phy *cck, *accum_cck, *delta_cck, *max_cck; |
| 946 | struct statistics_rx_non_phy *general, *accum_general; |
| 947 | struct statistics_rx_non_phy *delta_general, *max_general; |
| 948 | struct statistics_rx_ht_phy *ht, *accum_ht, *delta_ht, *max_ht; |
| 949 | |
Emmanuel Grumbach | 845a9c0 | 2011-08-25 23:11:04 -0700 | [diff] [blame] | 950 | if (!iwl_is_alive(priv->shrd)) |
Wey-Yi Guy | d6d023a | 2011-04-30 09:10:53 -0700 | [diff] [blame] | 951 | return -EAGAIN; |
| 952 | |
| 953 | buf = kzalloc(bufsz, GFP_KERNEL); |
| 954 | if (!buf) { |
| 955 | IWL_ERR(priv, "Can not allocate Buffer\n"); |
| 956 | return -ENOMEM; |
| 957 | } |
| 958 | |
| 959 | /* |
| 960 | * the statistic information display here is based on |
| 961 | * the last statistics notification from uCode |
| 962 | * might not reflect the current uCode activity |
| 963 | */ |
Johannes Berg | 4ff70fc | 2012-03-05 11:24:26 -0800 | [diff] [blame] | 964 | spin_lock_bh(&priv->statistics.lock); |
Wey-Yi Guy | d6d023a | 2011-04-30 09:10:53 -0700 | [diff] [blame] | 965 | ofdm = &priv->statistics.rx_ofdm; |
| 966 | cck = &priv->statistics.rx_cck; |
| 967 | general = &priv->statistics.rx_non_phy; |
| 968 | ht = &priv->statistics.rx_ofdm_ht; |
| 969 | accum_ofdm = &priv->accum_stats.rx_ofdm; |
| 970 | accum_cck = &priv->accum_stats.rx_cck; |
| 971 | accum_general = &priv->accum_stats.rx_non_phy; |
| 972 | accum_ht = &priv->accum_stats.rx_ofdm_ht; |
| 973 | delta_ofdm = &priv->delta_stats.rx_ofdm; |
| 974 | delta_cck = &priv->delta_stats.rx_cck; |
| 975 | delta_general = &priv->delta_stats.rx_non_phy; |
| 976 | delta_ht = &priv->delta_stats.rx_ofdm_ht; |
| 977 | max_ofdm = &priv->max_delta_stats.rx_ofdm; |
| 978 | max_cck = &priv->max_delta_stats.rx_cck; |
| 979 | max_general = &priv->max_delta_stats.rx_non_phy; |
| 980 | max_ht = &priv->max_delta_stats.rx_ofdm_ht; |
| 981 | |
| 982 | pos += iwl_statistics_flag(priv, buf, bufsz); |
| 983 | pos += scnprintf(buf + pos, bufsz - pos, |
| 984 | fmt_header, "Statistics_Rx - OFDM:"); |
| 985 | pos += scnprintf(buf + pos, bufsz - pos, |
| 986 | fmt_table, "ina_cnt:", |
| 987 | le32_to_cpu(ofdm->ina_cnt), |
| 988 | accum_ofdm->ina_cnt, |
| 989 | delta_ofdm->ina_cnt, max_ofdm->ina_cnt); |
| 990 | pos += scnprintf(buf + pos, bufsz - pos, |
| 991 | fmt_table, "fina_cnt:", |
| 992 | le32_to_cpu(ofdm->fina_cnt), accum_ofdm->fina_cnt, |
| 993 | delta_ofdm->fina_cnt, max_ofdm->fina_cnt); |
| 994 | pos += scnprintf(buf + pos, bufsz - pos, |
| 995 | fmt_table, "plcp_err:", |
| 996 | le32_to_cpu(ofdm->plcp_err), accum_ofdm->plcp_err, |
| 997 | delta_ofdm->plcp_err, max_ofdm->plcp_err); |
| 998 | pos += scnprintf(buf + pos, bufsz - pos, |
| 999 | fmt_table, "crc32_err:", |
| 1000 | le32_to_cpu(ofdm->crc32_err), accum_ofdm->crc32_err, |
| 1001 | delta_ofdm->crc32_err, max_ofdm->crc32_err); |
| 1002 | pos += scnprintf(buf + pos, bufsz - pos, |
| 1003 | fmt_table, "overrun_err:", |
| 1004 | le32_to_cpu(ofdm->overrun_err), |
| 1005 | accum_ofdm->overrun_err, delta_ofdm->overrun_err, |
| 1006 | max_ofdm->overrun_err); |
| 1007 | pos += scnprintf(buf + pos, bufsz - pos, |
| 1008 | fmt_table, "early_overrun_err:", |
| 1009 | le32_to_cpu(ofdm->early_overrun_err), |
| 1010 | accum_ofdm->early_overrun_err, |
| 1011 | delta_ofdm->early_overrun_err, |
| 1012 | max_ofdm->early_overrun_err); |
| 1013 | pos += scnprintf(buf + pos, bufsz - pos, |
| 1014 | fmt_table, "crc32_good:", |
| 1015 | le32_to_cpu(ofdm->crc32_good), |
| 1016 | accum_ofdm->crc32_good, delta_ofdm->crc32_good, |
| 1017 | max_ofdm->crc32_good); |
| 1018 | pos += scnprintf(buf + pos, bufsz - pos, |
| 1019 | fmt_table, "false_alarm_cnt:", |
| 1020 | le32_to_cpu(ofdm->false_alarm_cnt), |
| 1021 | accum_ofdm->false_alarm_cnt, |
| 1022 | delta_ofdm->false_alarm_cnt, |
| 1023 | max_ofdm->false_alarm_cnt); |
| 1024 | pos += scnprintf(buf + pos, bufsz - pos, |
| 1025 | fmt_table, "fina_sync_err_cnt:", |
| 1026 | le32_to_cpu(ofdm->fina_sync_err_cnt), |
| 1027 | accum_ofdm->fina_sync_err_cnt, |
| 1028 | delta_ofdm->fina_sync_err_cnt, |
| 1029 | max_ofdm->fina_sync_err_cnt); |
| 1030 | pos += scnprintf(buf + pos, bufsz - pos, |
| 1031 | fmt_table, "sfd_timeout:", |
| 1032 | le32_to_cpu(ofdm->sfd_timeout), |
| 1033 | accum_ofdm->sfd_timeout, delta_ofdm->sfd_timeout, |
| 1034 | max_ofdm->sfd_timeout); |
| 1035 | pos += scnprintf(buf + pos, bufsz - pos, |
| 1036 | fmt_table, "fina_timeout:", |
| 1037 | le32_to_cpu(ofdm->fina_timeout), |
| 1038 | accum_ofdm->fina_timeout, delta_ofdm->fina_timeout, |
| 1039 | max_ofdm->fina_timeout); |
| 1040 | pos += scnprintf(buf + pos, bufsz - pos, |
| 1041 | fmt_table, "unresponded_rts:", |
| 1042 | le32_to_cpu(ofdm->unresponded_rts), |
| 1043 | accum_ofdm->unresponded_rts, |
| 1044 | delta_ofdm->unresponded_rts, |
| 1045 | max_ofdm->unresponded_rts); |
| 1046 | pos += scnprintf(buf + pos, bufsz - pos, |
| 1047 | fmt_table, "rxe_frame_lmt_ovrun:", |
| 1048 | le32_to_cpu(ofdm->rxe_frame_limit_overrun), |
| 1049 | accum_ofdm->rxe_frame_limit_overrun, |
| 1050 | delta_ofdm->rxe_frame_limit_overrun, |
| 1051 | max_ofdm->rxe_frame_limit_overrun); |
| 1052 | pos += scnprintf(buf + pos, bufsz - pos, |
| 1053 | fmt_table, "sent_ack_cnt:", |
| 1054 | le32_to_cpu(ofdm->sent_ack_cnt), |
| 1055 | accum_ofdm->sent_ack_cnt, delta_ofdm->sent_ack_cnt, |
| 1056 | max_ofdm->sent_ack_cnt); |
| 1057 | pos += scnprintf(buf + pos, bufsz - pos, |
| 1058 | fmt_table, "sent_cts_cnt:", |
| 1059 | le32_to_cpu(ofdm->sent_cts_cnt), |
| 1060 | accum_ofdm->sent_cts_cnt, delta_ofdm->sent_cts_cnt, |
| 1061 | max_ofdm->sent_cts_cnt); |
| 1062 | pos += scnprintf(buf + pos, bufsz - pos, |
| 1063 | fmt_table, "sent_ba_rsp_cnt:", |
| 1064 | le32_to_cpu(ofdm->sent_ba_rsp_cnt), |
| 1065 | accum_ofdm->sent_ba_rsp_cnt, |
| 1066 | delta_ofdm->sent_ba_rsp_cnt, |
| 1067 | max_ofdm->sent_ba_rsp_cnt); |
| 1068 | pos += scnprintf(buf + pos, bufsz - pos, |
| 1069 | fmt_table, "dsp_self_kill:", |
| 1070 | le32_to_cpu(ofdm->dsp_self_kill), |
| 1071 | accum_ofdm->dsp_self_kill, |
| 1072 | delta_ofdm->dsp_self_kill, |
| 1073 | max_ofdm->dsp_self_kill); |
| 1074 | pos += scnprintf(buf + pos, bufsz - pos, |
| 1075 | fmt_table, "mh_format_err:", |
| 1076 | le32_to_cpu(ofdm->mh_format_err), |
| 1077 | accum_ofdm->mh_format_err, |
| 1078 | delta_ofdm->mh_format_err, |
| 1079 | max_ofdm->mh_format_err); |
| 1080 | pos += scnprintf(buf + pos, bufsz - pos, |
| 1081 | fmt_table, "re_acq_main_rssi_sum:", |
| 1082 | le32_to_cpu(ofdm->re_acq_main_rssi_sum), |
| 1083 | accum_ofdm->re_acq_main_rssi_sum, |
| 1084 | delta_ofdm->re_acq_main_rssi_sum, |
| 1085 | max_ofdm->re_acq_main_rssi_sum); |
| 1086 | |
| 1087 | pos += scnprintf(buf + pos, bufsz - pos, |
| 1088 | fmt_header, "Statistics_Rx - CCK:"); |
| 1089 | pos += scnprintf(buf + pos, bufsz - pos, |
| 1090 | fmt_table, "ina_cnt:", |
| 1091 | le32_to_cpu(cck->ina_cnt), accum_cck->ina_cnt, |
| 1092 | delta_cck->ina_cnt, max_cck->ina_cnt); |
| 1093 | pos += scnprintf(buf + pos, bufsz - pos, |
| 1094 | fmt_table, "fina_cnt:", |
| 1095 | le32_to_cpu(cck->fina_cnt), accum_cck->fina_cnt, |
| 1096 | delta_cck->fina_cnt, max_cck->fina_cnt); |
| 1097 | pos += scnprintf(buf + pos, bufsz - pos, |
| 1098 | fmt_table, "plcp_err:", |
| 1099 | le32_to_cpu(cck->plcp_err), accum_cck->plcp_err, |
| 1100 | delta_cck->plcp_err, max_cck->plcp_err); |
| 1101 | pos += scnprintf(buf + pos, bufsz - pos, |
| 1102 | fmt_table, "crc32_err:", |
| 1103 | le32_to_cpu(cck->crc32_err), accum_cck->crc32_err, |
| 1104 | delta_cck->crc32_err, max_cck->crc32_err); |
| 1105 | pos += scnprintf(buf + pos, bufsz - pos, |
| 1106 | fmt_table, "overrun_err:", |
| 1107 | le32_to_cpu(cck->overrun_err), |
| 1108 | accum_cck->overrun_err, delta_cck->overrun_err, |
| 1109 | max_cck->overrun_err); |
| 1110 | pos += scnprintf(buf + pos, bufsz - pos, |
| 1111 | fmt_table, "early_overrun_err:", |
| 1112 | le32_to_cpu(cck->early_overrun_err), |
| 1113 | accum_cck->early_overrun_err, |
| 1114 | delta_cck->early_overrun_err, |
| 1115 | max_cck->early_overrun_err); |
| 1116 | pos += scnprintf(buf + pos, bufsz - pos, |
| 1117 | fmt_table, "crc32_good:", |
| 1118 | le32_to_cpu(cck->crc32_good), accum_cck->crc32_good, |
| 1119 | delta_cck->crc32_good, max_cck->crc32_good); |
| 1120 | pos += scnprintf(buf + pos, bufsz - pos, |
| 1121 | fmt_table, "false_alarm_cnt:", |
| 1122 | le32_to_cpu(cck->false_alarm_cnt), |
| 1123 | accum_cck->false_alarm_cnt, |
| 1124 | delta_cck->false_alarm_cnt, max_cck->false_alarm_cnt); |
| 1125 | pos += scnprintf(buf + pos, bufsz - pos, |
| 1126 | fmt_table, "fina_sync_err_cnt:", |
| 1127 | le32_to_cpu(cck->fina_sync_err_cnt), |
| 1128 | accum_cck->fina_sync_err_cnt, |
| 1129 | delta_cck->fina_sync_err_cnt, |
| 1130 | max_cck->fina_sync_err_cnt); |
| 1131 | pos += scnprintf(buf + pos, bufsz - pos, |
| 1132 | fmt_table, "sfd_timeout:", |
| 1133 | le32_to_cpu(cck->sfd_timeout), |
| 1134 | accum_cck->sfd_timeout, delta_cck->sfd_timeout, |
| 1135 | max_cck->sfd_timeout); |
| 1136 | pos += scnprintf(buf + pos, bufsz - pos, |
| 1137 | fmt_table, "fina_timeout:", |
| 1138 | le32_to_cpu(cck->fina_timeout), |
| 1139 | accum_cck->fina_timeout, delta_cck->fina_timeout, |
| 1140 | max_cck->fina_timeout); |
| 1141 | pos += scnprintf(buf + pos, bufsz - pos, |
| 1142 | fmt_table, "unresponded_rts:", |
| 1143 | le32_to_cpu(cck->unresponded_rts), |
| 1144 | accum_cck->unresponded_rts, delta_cck->unresponded_rts, |
| 1145 | max_cck->unresponded_rts); |
| 1146 | pos += scnprintf(buf + pos, bufsz - pos, |
| 1147 | fmt_table, "rxe_frame_lmt_ovrun:", |
| 1148 | le32_to_cpu(cck->rxe_frame_limit_overrun), |
| 1149 | accum_cck->rxe_frame_limit_overrun, |
| 1150 | delta_cck->rxe_frame_limit_overrun, |
| 1151 | max_cck->rxe_frame_limit_overrun); |
| 1152 | pos += scnprintf(buf + pos, bufsz - pos, |
| 1153 | fmt_table, "sent_ack_cnt:", |
| 1154 | le32_to_cpu(cck->sent_ack_cnt), |
| 1155 | accum_cck->sent_ack_cnt, delta_cck->sent_ack_cnt, |
| 1156 | max_cck->sent_ack_cnt); |
| 1157 | pos += scnprintf(buf + pos, bufsz - pos, |
| 1158 | fmt_table, "sent_cts_cnt:", |
| 1159 | le32_to_cpu(cck->sent_cts_cnt), |
| 1160 | accum_cck->sent_cts_cnt, delta_cck->sent_cts_cnt, |
| 1161 | max_cck->sent_cts_cnt); |
| 1162 | pos += scnprintf(buf + pos, bufsz - pos, |
| 1163 | fmt_table, "sent_ba_rsp_cnt:", |
| 1164 | le32_to_cpu(cck->sent_ba_rsp_cnt), |
| 1165 | accum_cck->sent_ba_rsp_cnt, |
| 1166 | delta_cck->sent_ba_rsp_cnt, |
| 1167 | max_cck->sent_ba_rsp_cnt); |
| 1168 | pos += scnprintf(buf + pos, bufsz - pos, |
| 1169 | fmt_table, "dsp_self_kill:", |
| 1170 | le32_to_cpu(cck->dsp_self_kill), |
| 1171 | accum_cck->dsp_self_kill, delta_cck->dsp_self_kill, |
| 1172 | max_cck->dsp_self_kill); |
| 1173 | pos += scnprintf(buf + pos, bufsz - pos, |
| 1174 | fmt_table, "mh_format_err:", |
| 1175 | le32_to_cpu(cck->mh_format_err), |
| 1176 | accum_cck->mh_format_err, delta_cck->mh_format_err, |
| 1177 | max_cck->mh_format_err); |
| 1178 | pos += scnprintf(buf + pos, bufsz - pos, |
| 1179 | fmt_table, "re_acq_main_rssi_sum:", |
| 1180 | le32_to_cpu(cck->re_acq_main_rssi_sum), |
| 1181 | accum_cck->re_acq_main_rssi_sum, |
| 1182 | delta_cck->re_acq_main_rssi_sum, |
| 1183 | max_cck->re_acq_main_rssi_sum); |
| 1184 | |
| 1185 | pos += scnprintf(buf + pos, bufsz - pos, |
| 1186 | fmt_header, "Statistics_Rx - GENERAL:"); |
| 1187 | pos += scnprintf(buf + pos, bufsz - pos, |
| 1188 | fmt_table, "bogus_cts:", |
| 1189 | le32_to_cpu(general->bogus_cts), |
| 1190 | accum_general->bogus_cts, delta_general->bogus_cts, |
| 1191 | max_general->bogus_cts); |
| 1192 | pos += scnprintf(buf + pos, bufsz - pos, |
| 1193 | fmt_table, "bogus_ack:", |
| 1194 | le32_to_cpu(general->bogus_ack), |
| 1195 | accum_general->bogus_ack, delta_general->bogus_ack, |
| 1196 | max_general->bogus_ack); |
| 1197 | pos += scnprintf(buf + pos, bufsz - pos, |
| 1198 | fmt_table, "non_bssid_frames:", |
| 1199 | le32_to_cpu(general->non_bssid_frames), |
| 1200 | accum_general->non_bssid_frames, |
| 1201 | delta_general->non_bssid_frames, |
| 1202 | max_general->non_bssid_frames); |
| 1203 | pos += scnprintf(buf + pos, bufsz - pos, |
| 1204 | fmt_table, "filtered_frames:", |
| 1205 | le32_to_cpu(general->filtered_frames), |
| 1206 | accum_general->filtered_frames, |
| 1207 | delta_general->filtered_frames, |
| 1208 | max_general->filtered_frames); |
| 1209 | pos += scnprintf(buf + pos, bufsz - pos, |
| 1210 | fmt_table, "non_channel_beacons:", |
| 1211 | le32_to_cpu(general->non_channel_beacons), |
| 1212 | accum_general->non_channel_beacons, |
| 1213 | delta_general->non_channel_beacons, |
| 1214 | max_general->non_channel_beacons); |
| 1215 | pos += scnprintf(buf + pos, bufsz - pos, |
| 1216 | fmt_table, "channel_beacons:", |
| 1217 | le32_to_cpu(general->channel_beacons), |
| 1218 | accum_general->channel_beacons, |
| 1219 | delta_general->channel_beacons, |
| 1220 | max_general->channel_beacons); |
| 1221 | pos += scnprintf(buf + pos, bufsz - pos, |
| 1222 | fmt_table, "num_missed_bcon:", |
| 1223 | le32_to_cpu(general->num_missed_bcon), |
| 1224 | accum_general->num_missed_bcon, |
| 1225 | delta_general->num_missed_bcon, |
| 1226 | max_general->num_missed_bcon); |
| 1227 | pos += scnprintf(buf + pos, bufsz - pos, |
| 1228 | fmt_table, "adc_rx_saturation_time:", |
| 1229 | le32_to_cpu(general->adc_rx_saturation_time), |
| 1230 | accum_general->adc_rx_saturation_time, |
| 1231 | delta_general->adc_rx_saturation_time, |
| 1232 | max_general->adc_rx_saturation_time); |
| 1233 | pos += scnprintf(buf + pos, bufsz - pos, |
| 1234 | fmt_table, "ina_detect_search_tm:", |
| 1235 | le32_to_cpu(general->ina_detection_search_time), |
| 1236 | accum_general->ina_detection_search_time, |
| 1237 | delta_general->ina_detection_search_time, |
| 1238 | max_general->ina_detection_search_time); |
| 1239 | pos += scnprintf(buf + pos, bufsz - pos, |
| 1240 | fmt_table, "beacon_silence_rssi_a:", |
| 1241 | le32_to_cpu(general->beacon_silence_rssi_a), |
| 1242 | accum_general->beacon_silence_rssi_a, |
| 1243 | delta_general->beacon_silence_rssi_a, |
| 1244 | max_general->beacon_silence_rssi_a); |
| 1245 | pos += scnprintf(buf + pos, bufsz - pos, |
| 1246 | fmt_table, "beacon_silence_rssi_b:", |
| 1247 | le32_to_cpu(general->beacon_silence_rssi_b), |
| 1248 | accum_general->beacon_silence_rssi_b, |
| 1249 | delta_general->beacon_silence_rssi_b, |
| 1250 | max_general->beacon_silence_rssi_b); |
| 1251 | pos += scnprintf(buf + pos, bufsz - pos, |
| 1252 | fmt_table, "beacon_silence_rssi_c:", |
| 1253 | le32_to_cpu(general->beacon_silence_rssi_c), |
| 1254 | accum_general->beacon_silence_rssi_c, |
| 1255 | delta_general->beacon_silence_rssi_c, |
| 1256 | max_general->beacon_silence_rssi_c); |
| 1257 | pos += scnprintf(buf + pos, bufsz - pos, |
| 1258 | fmt_table, "interference_data_flag:", |
| 1259 | le32_to_cpu(general->interference_data_flag), |
| 1260 | accum_general->interference_data_flag, |
| 1261 | delta_general->interference_data_flag, |
| 1262 | max_general->interference_data_flag); |
| 1263 | pos += scnprintf(buf + pos, bufsz - pos, |
| 1264 | fmt_table, "channel_load:", |
| 1265 | le32_to_cpu(general->channel_load), |
| 1266 | accum_general->channel_load, |
| 1267 | delta_general->channel_load, |
| 1268 | max_general->channel_load); |
| 1269 | pos += scnprintf(buf + pos, bufsz - pos, |
| 1270 | fmt_table, "dsp_false_alarms:", |
| 1271 | le32_to_cpu(general->dsp_false_alarms), |
| 1272 | accum_general->dsp_false_alarms, |
| 1273 | delta_general->dsp_false_alarms, |
| 1274 | max_general->dsp_false_alarms); |
| 1275 | pos += scnprintf(buf + pos, bufsz - pos, |
| 1276 | fmt_table, "beacon_rssi_a:", |
| 1277 | le32_to_cpu(general->beacon_rssi_a), |
| 1278 | accum_general->beacon_rssi_a, |
| 1279 | delta_general->beacon_rssi_a, |
| 1280 | max_general->beacon_rssi_a); |
| 1281 | pos += scnprintf(buf + pos, bufsz - pos, |
| 1282 | fmt_table, "beacon_rssi_b:", |
| 1283 | le32_to_cpu(general->beacon_rssi_b), |
| 1284 | accum_general->beacon_rssi_b, |
| 1285 | delta_general->beacon_rssi_b, |
| 1286 | max_general->beacon_rssi_b); |
| 1287 | pos += scnprintf(buf + pos, bufsz - pos, |
| 1288 | fmt_table, "beacon_rssi_c:", |
| 1289 | le32_to_cpu(general->beacon_rssi_c), |
| 1290 | accum_general->beacon_rssi_c, |
| 1291 | delta_general->beacon_rssi_c, |
| 1292 | max_general->beacon_rssi_c); |
| 1293 | pos += scnprintf(buf + pos, bufsz - pos, |
| 1294 | fmt_table, "beacon_energy_a:", |
| 1295 | le32_to_cpu(general->beacon_energy_a), |
| 1296 | accum_general->beacon_energy_a, |
| 1297 | delta_general->beacon_energy_a, |
| 1298 | max_general->beacon_energy_a); |
| 1299 | pos += scnprintf(buf + pos, bufsz - pos, |
| 1300 | fmt_table, "beacon_energy_b:", |
| 1301 | le32_to_cpu(general->beacon_energy_b), |
| 1302 | accum_general->beacon_energy_b, |
| 1303 | delta_general->beacon_energy_b, |
| 1304 | max_general->beacon_energy_b); |
| 1305 | pos += scnprintf(buf + pos, bufsz - pos, |
| 1306 | fmt_table, "beacon_energy_c:", |
| 1307 | le32_to_cpu(general->beacon_energy_c), |
| 1308 | accum_general->beacon_energy_c, |
| 1309 | delta_general->beacon_energy_c, |
| 1310 | max_general->beacon_energy_c); |
| 1311 | |
| 1312 | pos += scnprintf(buf + pos, bufsz - pos, |
| 1313 | fmt_header, "Statistics_Rx - OFDM_HT:"); |
| 1314 | pos += scnprintf(buf + pos, bufsz - pos, |
| 1315 | fmt_table, "plcp_err:", |
| 1316 | le32_to_cpu(ht->plcp_err), accum_ht->plcp_err, |
| 1317 | delta_ht->plcp_err, max_ht->plcp_err); |
| 1318 | pos += scnprintf(buf + pos, bufsz - pos, |
| 1319 | fmt_table, "overrun_err:", |
| 1320 | le32_to_cpu(ht->overrun_err), accum_ht->overrun_err, |
| 1321 | delta_ht->overrun_err, max_ht->overrun_err); |
| 1322 | pos += scnprintf(buf + pos, bufsz - pos, |
| 1323 | fmt_table, "early_overrun_err:", |
| 1324 | le32_to_cpu(ht->early_overrun_err), |
| 1325 | accum_ht->early_overrun_err, |
| 1326 | delta_ht->early_overrun_err, |
| 1327 | max_ht->early_overrun_err); |
| 1328 | pos += scnprintf(buf + pos, bufsz - pos, |
| 1329 | fmt_table, "crc32_good:", |
| 1330 | le32_to_cpu(ht->crc32_good), accum_ht->crc32_good, |
| 1331 | delta_ht->crc32_good, max_ht->crc32_good); |
| 1332 | pos += scnprintf(buf + pos, bufsz - pos, |
| 1333 | fmt_table, "crc32_err:", |
| 1334 | le32_to_cpu(ht->crc32_err), accum_ht->crc32_err, |
| 1335 | delta_ht->crc32_err, max_ht->crc32_err); |
| 1336 | pos += scnprintf(buf + pos, bufsz - pos, |
| 1337 | fmt_table, "mh_format_err:", |
| 1338 | le32_to_cpu(ht->mh_format_err), |
| 1339 | accum_ht->mh_format_err, |
| 1340 | delta_ht->mh_format_err, max_ht->mh_format_err); |
| 1341 | pos += scnprintf(buf + pos, bufsz - pos, |
| 1342 | fmt_table, "agg_crc32_good:", |
| 1343 | le32_to_cpu(ht->agg_crc32_good), |
| 1344 | accum_ht->agg_crc32_good, |
| 1345 | delta_ht->agg_crc32_good, max_ht->agg_crc32_good); |
| 1346 | pos += scnprintf(buf + pos, bufsz - pos, |
| 1347 | fmt_table, "agg_mpdu_cnt:", |
| 1348 | le32_to_cpu(ht->agg_mpdu_cnt), |
| 1349 | accum_ht->agg_mpdu_cnt, |
| 1350 | delta_ht->agg_mpdu_cnt, max_ht->agg_mpdu_cnt); |
| 1351 | pos += scnprintf(buf + pos, bufsz - pos, |
| 1352 | fmt_table, "agg_cnt:", |
| 1353 | le32_to_cpu(ht->agg_cnt), accum_ht->agg_cnt, |
| 1354 | delta_ht->agg_cnt, max_ht->agg_cnt); |
| 1355 | pos += scnprintf(buf + pos, bufsz - pos, |
| 1356 | fmt_table, "unsupport_mcs:", |
| 1357 | le32_to_cpu(ht->unsupport_mcs), |
| 1358 | accum_ht->unsupport_mcs, |
| 1359 | delta_ht->unsupport_mcs, max_ht->unsupport_mcs); |
| 1360 | |
Johannes Berg | 4ff70fc | 2012-03-05 11:24:26 -0800 | [diff] [blame] | 1361 | spin_unlock_bh(&priv->statistics.lock); |
| 1362 | |
Wey-Yi Guy | d6d023a | 2011-04-30 09:10:53 -0700 | [diff] [blame] | 1363 | ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos); |
| 1364 | kfree(buf); |
| 1365 | return ret; |
Wey-Yi Guy | e8fe59a | 2009-08-07 15:41:42 -0700 | [diff] [blame] | 1366 | } |
| 1367 | |
| 1368 | static ssize_t iwl_dbgfs_ucode_tx_stats_read(struct file *file, |
| 1369 | char __user *user_buf, |
| 1370 | size_t count, loff_t *ppos) |
| 1371 | { |
H Hartley Sweeten | 28f63a4 | 2010-01-08 16:14:10 -0700 | [diff] [blame] | 1372 | struct iwl_priv *priv = file->private_data; |
Wey-Yi Guy | d6d023a | 2011-04-30 09:10:53 -0700 | [diff] [blame] | 1373 | int pos = 0; |
| 1374 | char *buf; |
| 1375 | int bufsz = (sizeof(struct statistics_tx) * 48) + 250; |
| 1376 | ssize_t ret; |
| 1377 | struct statistics_tx *tx, *accum_tx, *delta_tx, *max_tx; |
| 1378 | |
Emmanuel Grumbach | 845a9c0 | 2011-08-25 23:11:04 -0700 | [diff] [blame] | 1379 | if (!iwl_is_alive(priv->shrd)) |
Wey-Yi Guy | d6d023a | 2011-04-30 09:10:53 -0700 | [diff] [blame] | 1380 | return -EAGAIN; |
| 1381 | |
| 1382 | buf = kzalloc(bufsz, GFP_KERNEL); |
| 1383 | if (!buf) { |
| 1384 | IWL_ERR(priv, "Can not allocate Buffer\n"); |
| 1385 | return -ENOMEM; |
| 1386 | } |
| 1387 | |
| 1388 | /* the statistic information display here is based on |
| 1389 | * the last statistics notification from uCode |
| 1390 | * might not reflect the current uCode activity |
| 1391 | */ |
Johannes Berg | 4ff70fc | 2012-03-05 11:24:26 -0800 | [diff] [blame] | 1392 | spin_lock_bh(&priv->statistics.lock); |
| 1393 | |
Wey-Yi Guy | d6d023a | 2011-04-30 09:10:53 -0700 | [diff] [blame] | 1394 | tx = &priv->statistics.tx; |
| 1395 | accum_tx = &priv->accum_stats.tx; |
| 1396 | delta_tx = &priv->delta_stats.tx; |
| 1397 | max_tx = &priv->max_delta_stats.tx; |
| 1398 | |
| 1399 | pos += iwl_statistics_flag(priv, buf, bufsz); |
| 1400 | pos += scnprintf(buf + pos, bufsz - pos, |
| 1401 | fmt_header, "Statistics_Tx:"); |
| 1402 | pos += scnprintf(buf + pos, bufsz - pos, |
| 1403 | fmt_table, "preamble:", |
| 1404 | le32_to_cpu(tx->preamble_cnt), |
| 1405 | accum_tx->preamble_cnt, |
| 1406 | delta_tx->preamble_cnt, max_tx->preamble_cnt); |
| 1407 | pos += scnprintf(buf + pos, bufsz - pos, |
| 1408 | fmt_table, "rx_detected_cnt:", |
| 1409 | le32_to_cpu(tx->rx_detected_cnt), |
| 1410 | accum_tx->rx_detected_cnt, |
| 1411 | delta_tx->rx_detected_cnt, max_tx->rx_detected_cnt); |
| 1412 | pos += scnprintf(buf + pos, bufsz - pos, |
| 1413 | fmt_table, "bt_prio_defer_cnt:", |
| 1414 | le32_to_cpu(tx->bt_prio_defer_cnt), |
| 1415 | accum_tx->bt_prio_defer_cnt, |
| 1416 | delta_tx->bt_prio_defer_cnt, |
| 1417 | max_tx->bt_prio_defer_cnt); |
| 1418 | pos += scnprintf(buf + pos, bufsz - pos, |
| 1419 | fmt_table, "bt_prio_kill_cnt:", |
| 1420 | le32_to_cpu(tx->bt_prio_kill_cnt), |
| 1421 | accum_tx->bt_prio_kill_cnt, |
| 1422 | delta_tx->bt_prio_kill_cnt, |
| 1423 | max_tx->bt_prio_kill_cnt); |
| 1424 | pos += scnprintf(buf + pos, bufsz - pos, |
| 1425 | fmt_table, "few_bytes_cnt:", |
| 1426 | le32_to_cpu(tx->few_bytes_cnt), |
| 1427 | accum_tx->few_bytes_cnt, |
| 1428 | delta_tx->few_bytes_cnt, max_tx->few_bytes_cnt); |
| 1429 | pos += scnprintf(buf + pos, bufsz - pos, |
| 1430 | fmt_table, "cts_timeout:", |
| 1431 | le32_to_cpu(tx->cts_timeout), accum_tx->cts_timeout, |
| 1432 | delta_tx->cts_timeout, max_tx->cts_timeout); |
| 1433 | pos += scnprintf(buf + pos, bufsz - pos, |
| 1434 | fmt_table, "ack_timeout:", |
| 1435 | le32_to_cpu(tx->ack_timeout), |
| 1436 | accum_tx->ack_timeout, |
| 1437 | delta_tx->ack_timeout, max_tx->ack_timeout); |
| 1438 | pos += scnprintf(buf + pos, bufsz - pos, |
| 1439 | fmt_table, "expected_ack_cnt:", |
| 1440 | le32_to_cpu(tx->expected_ack_cnt), |
| 1441 | accum_tx->expected_ack_cnt, |
| 1442 | delta_tx->expected_ack_cnt, |
| 1443 | max_tx->expected_ack_cnt); |
| 1444 | pos += scnprintf(buf + pos, bufsz - pos, |
| 1445 | fmt_table, "actual_ack_cnt:", |
| 1446 | le32_to_cpu(tx->actual_ack_cnt), |
| 1447 | accum_tx->actual_ack_cnt, |
| 1448 | delta_tx->actual_ack_cnt, |
| 1449 | max_tx->actual_ack_cnt); |
| 1450 | pos += scnprintf(buf + pos, bufsz - pos, |
| 1451 | fmt_table, "dump_msdu_cnt:", |
| 1452 | le32_to_cpu(tx->dump_msdu_cnt), |
| 1453 | accum_tx->dump_msdu_cnt, |
| 1454 | delta_tx->dump_msdu_cnt, |
| 1455 | max_tx->dump_msdu_cnt); |
| 1456 | pos += scnprintf(buf + pos, bufsz - pos, |
| 1457 | fmt_table, "abort_nxt_frame_mismatch:", |
| 1458 | le32_to_cpu(tx->burst_abort_next_frame_mismatch_cnt), |
| 1459 | accum_tx->burst_abort_next_frame_mismatch_cnt, |
| 1460 | delta_tx->burst_abort_next_frame_mismatch_cnt, |
| 1461 | max_tx->burst_abort_next_frame_mismatch_cnt); |
| 1462 | pos += scnprintf(buf + pos, bufsz - pos, |
| 1463 | fmt_table, "abort_missing_nxt_frame:", |
| 1464 | le32_to_cpu(tx->burst_abort_missing_next_frame_cnt), |
| 1465 | accum_tx->burst_abort_missing_next_frame_cnt, |
| 1466 | delta_tx->burst_abort_missing_next_frame_cnt, |
| 1467 | max_tx->burst_abort_missing_next_frame_cnt); |
| 1468 | pos += scnprintf(buf + pos, bufsz - pos, |
| 1469 | fmt_table, "cts_timeout_collision:", |
| 1470 | le32_to_cpu(tx->cts_timeout_collision), |
| 1471 | accum_tx->cts_timeout_collision, |
| 1472 | delta_tx->cts_timeout_collision, |
| 1473 | max_tx->cts_timeout_collision); |
| 1474 | pos += scnprintf(buf + pos, bufsz - pos, |
| 1475 | fmt_table, "ack_ba_timeout_collision:", |
| 1476 | le32_to_cpu(tx->ack_or_ba_timeout_collision), |
| 1477 | accum_tx->ack_or_ba_timeout_collision, |
| 1478 | delta_tx->ack_or_ba_timeout_collision, |
| 1479 | max_tx->ack_or_ba_timeout_collision); |
| 1480 | pos += scnprintf(buf + pos, bufsz - pos, |
| 1481 | fmt_table, "agg ba_timeout:", |
| 1482 | le32_to_cpu(tx->agg.ba_timeout), |
| 1483 | accum_tx->agg.ba_timeout, |
| 1484 | delta_tx->agg.ba_timeout, |
| 1485 | max_tx->agg.ba_timeout); |
| 1486 | pos += scnprintf(buf + pos, bufsz - pos, |
| 1487 | fmt_table, "agg ba_resched_frames:", |
| 1488 | le32_to_cpu(tx->agg.ba_reschedule_frames), |
| 1489 | accum_tx->agg.ba_reschedule_frames, |
| 1490 | delta_tx->agg.ba_reschedule_frames, |
| 1491 | max_tx->agg.ba_reschedule_frames); |
| 1492 | pos += scnprintf(buf + pos, bufsz - pos, |
| 1493 | fmt_table, "agg scd_query_agg_frame:", |
| 1494 | le32_to_cpu(tx->agg.scd_query_agg_frame_cnt), |
| 1495 | accum_tx->agg.scd_query_agg_frame_cnt, |
| 1496 | delta_tx->agg.scd_query_agg_frame_cnt, |
| 1497 | max_tx->agg.scd_query_agg_frame_cnt); |
| 1498 | pos += scnprintf(buf + pos, bufsz - pos, |
| 1499 | fmt_table, "agg scd_query_no_agg:", |
| 1500 | le32_to_cpu(tx->agg.scd_query_no_agg), |
| 1501 | accum_tx->agg.scd_query_no_agg, |
| 1502 | delta_tx->agg.scd_query_no_agg, |
| 1503 | max_tx->agg.scd_query_no_agg); |
| 1504 | pos += scnprintf(buf + pos, bufsz - pos, |
| 1505 | fmt_table, "agg scd_query_agg:", |
| 1506 | le32_to_cpu(tx->agg.scd_query_agg), |
| 1507 | accum_tx->agg.scd_query_agg, |
| 1508 | delta_tx->agg.scd_query_agg, |
| 1509 | max_tx->agg.scd_query_agg); |
| 1510 | pos += scnprintf(buf + pos, bufsz - pos, |
| 1511 | fmt_table, "agg scd_query_mismatch:", |
| 1512 | le32_to_cpu(tx->agg.scd_query_mismatch), |
| 1513 | accum_tx->agg.scd_query_mismatch, |
| 1514 | delta_tx->agg.scd_query_mismatch, |
| 1515 | max_tx->agg.scd_query_mismatch); |
| 1516 | pos += scnprintf(buf + pos, bufsz - pos, |
| 1517 | fmt_table, "agg frame_not_ready:", |
| 1518 | le32_to_cpu(tx->agg.frame_not_ready), |
| 1519 | accum_tx->agg.frame_not_ready, |
| 1520 | delta_tx->agg.frame_not_ready, |
| 1521 | max_tx->agg.frame_not_ready); |
| 1522 | pos += scnprintf(buf + pos, bufsz - pos, |
| 1523 | fmt_table, "agg underrun:", |
| 1524 | le32_to_cpu(tx->agg.underrun), |
| 1525 | accum_tx->agg.underrun, |
| 1526 | delta_tx->agg.underrun, max_tx->agg.underrun); |
| 1527 | pos += scnprintf(buf + pos, bufsz - pos, |
| 1528 | fmt_table, "agg bt_prio_kill:", |
| 1529 | le32_to_cpu(tx->agg.bt_prio_kill), |
| 1530 | accum_tx->agg.bt_prio_kill, |
| 1531 | delta_tx->agg.bt_prio_kill, |
| 1532 | max_tx->agg.bt_prio_kill); |
| 1533 | pos += scnprintf(buf + pos, bufsz - pos, |
| 1534 | fmt_table, "agg rx_ba_rsp_cnt:", |
| 1535 | le32_to_cpu(tx->agg.rx_ba_rsp_cnt), |
| 1536 | accum_tx->agg.rx_ba_rsp_cnt, |
| 1537 | delta_tx->agg.rx_ba_rsp_cnt, |
| 1538 | max_tx->agg.rx_ba_rsp_cnt); |
| 1539 | |
| 1540 | if (tx->tx_power.ant_a || tx->tx_power.ant_b || tx->tx_power.ant_c) { |
| 1541 | pos += scnprintf(buf + pos, bufsz - pos, |
| 1542 | "tx power: (1/2 dB step)\n"); |
Johannes Berg | 7e79a39 | 2012-03-05 11:24:32 -0800 | [diff] [blame] | 1543 | if ((hw_params(priv).valid_tx_ant & ANT_A) && |
| 1544 | tx->tx_power.ant_a) |
Wey-Yi Guy | d6d023a | 2011-04-30 09:10:53 -0700 | [diff] [blame] | 1545 | pos += scnprintf(buf + pos, bufsz - pos, |
| 1546 | fmt_hex, "antenna A:", |
| 1547 | tx->tx_power.ant_a); |
Johannes Berg | 7e79a39 | 2012-03-05 11:24:32 -0800 | [diff] [blame] | 1548 | if ((hw_params(priv).valid_tx_ant & ANT_B) && |
| 1549 | tx->tx_power.ant_b) |
Wey-Yi Guy | d6d023a | 2011-04-30 09:10:53 -0700 | [diff] [blame] | 1550 | pos += scnprintf(buf + pos, bufsz - pos, |
| 1551 | fmt_hex, "antenna B:", |
| 1552 | tx->tx_power.ant_b); |
Johannes Berg | 7e79a39 | 2012-03-05 11:24:32 -0800 | [diff] [blame] | 1553 | if ((hw_params(priv).valid_tx_ant & ANT_C) && |
| 1554 | tx->tx_power.ant_c) |
Wey-Yi Guy | d6d023a | 2011-04-30 09:10:53 -0700 | [diff] [blame] | 1555 | pos += scnprintf(buf + pos, bufsz - pos, |
| 1556 | fmt_hex, "antenna C:", |
| 1557 | tx->tx_power.ant_c); |
| 1558 | } |
Johannes Berg | 4ff70fc | 2012-03-05 11:24:26 -0800 | [diff] [blame] | 1559 | |
| 1560 | spin_unlock_bh(&priv->statistics.lock); |
| 1561 | |
Wey-Yi Guy | d6d023a | 2011-04-30 09:10:53 -0700 | [diff] [blame] | 1562 | ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos); |
| 1563 | kfree(buf); |
| 1564 | return ret; |
Wey-Yi Guy | e8fe59a | 2009-08-07 15:41:42 -0700 | [diff] [blame] | 1565 | } |
| 1566 | |
| 1567 | static ssize_t iwl_dbgfs_ucode_general_stats_read(struct file *file, |
| 1568 | char __user *user_buf, |
| 1569 | size_t count, loff_t *ppos) |
| 1570 | { |
H Hartley Sweeten | 28f63a4 | 2010-01-08 16:14:10 -0700 | [diff] [blame] | 1571 | struct iwl_priv *priv = file->private_data; |
Wey-Yi Guy | d6d023a | 2011-04-30 09:10:53 -0700 | [diff] [blame] | 1572 | int pos = 0; |
| 1573 | char *buf; |
| 1574 | int bufsz = sizeof(struct statistics_general) * 10 + 300; |
| 1575 | ssize_t ret; |
| 1576 | struct statistics_general_common *general, *accum_general; |
| 1577 | struct statistics_general_common *delta_general, *max_general; |
| 1578 | struct statistics_dbg *dbg, *accum_dbg, *delta_dbg, *max_dbg; |
| 1579 | struct statistics_div *div, *accum_div, *delta_div, *max_div; |
| 1580 | |
Emmanuel Grumbach | 845a9c0 | 2011-08-25 23:11:04 -0700 | [diff] [blame] | 1581 | if (!iwl_is_alive(priv->shrd)) |
Wey-Yi Guy | d6d023a | 2011-04-30 09:10:53 -0700 | [diff] [blame] | 1582 | return -EAGAIN; |
| 1583 | |
| 1584 | buf = kzalloc(bufsz, GFP_KERNEL); |
| 1585 | if (!buf) { |
| 1586 | IWL_ERR(priv, "Can not allocate Buffer\n"); |
| 1587 | return -ENOMEM; |
| 1588 | } |
| 1589 | |
| 1590 | /* the statistic information display here is based on |
| 1591 | * the last statistics notification from uCode |
| 1592 | * might not reflect the current uCode activity |
| 1593 | */ |
Johannes Berg | 4ff70fc | 2012-03-05 11:24:26 -0800 | [diff] [blame] | 1594 | |
| 1595 | spin_lock_bh(&priv->statistics.lock); |
| 1596 | |
Wey-Yi Guy | d6d023a | 2011-04-30 09:10:53 -0700 | [diff] [blame] | 1597 | general = &priv->statistics.common; |
| 1598 | dbg = &priv->statistics.common.dbg; |
| 1599 | div = &priv->statistics.common.div; |
| 1600 | accum_general = &priv->accum_stats.common; |
| 1601 | accum_dbg = &priv->accum_stats.common.dbg; |
| 1602 | accum_div = &priv->accum_stats.common.div; |
| 1603 | delta_general = &priv->delta_stats.common; |
| 1604 | max_general = &priv->max_delta_stats.common; |
| 1605 | delta_dbg = &priv->delta_stats.common.dbg; |
| 1606 | max_dbg = &priv->max_delta_stats.common.dbg; |
| 1607 | delta_div = &priv->delta_stats.common.div; |
| 1608 | max_div = &priv->max_delta_stats.common.div; |
| 1609 | |
| 1610 | pos += iwl_statistics_flag(priv, buf, bufsz); |
| 1611 | pos += scnprintf(buf + pos, bufsz - pos, |
| 1612 | fmt_header, "Statistics_General:"); |
| 1613 | pos += scnprintf(buf + pos, bufsz - pos, |
| 1614 | fmt_value, "temperature:", |
| 1615 | le32_to_cpu(general->temperature)); |
| 1616 | pos += scnprintf(buf + pos, bufsz - pos, |
| 1617 | fmt_value, "temperature_m:", |
| 1618 | le32_to_cpu(general->temperature_m)); |
| 1619 | pos += scnprintf(buf + pos, bufsz - pos, |
| 1620 | fmt_value, "ttl_timestamp:", |
| 1621 | le32_to_cpu(general->ttl_timestamp)); |
| 1622 | pos += scnprintf(buf + pos, bufsz - pos, |
| 1623 | fmt_table, "burst_check:", |
| 1624 | le32_to_cpu(dbg->burst_check), |
| 1625 | accum_dbg->burst_check, |
| 1626 | delta_dbg->burst_check, max_dbg->burst_check); |
| 1627 | pos += scnprintf(buf + pos, bufsz - pos, |
| 1628 | fmt_table, "burst_count:", |
| 1629 | le32_to_cpu(dbg->burst_count), |
| 1630 | accum_dbg->burst_count, |
| 1631 | delta_dbg->burst_count, max_dbg->burst_count); |
| 1632 | pos += scnprintf(buf + pos, bufsz - pos, |
| 1633 | fmt_table, "wait_for_silence_timeout_count:", |
| 1634 | le32_to_cpu(dbg->wait_for_silence_timeout_cnt), |
| 1635 | accum_dbg->wait_for_silence_timeout_cnt, |
| 1636 | delta_dbg->wait_for_silence_timeout_cnt, |
| 1637 | max_dbg->wait_for_silence_timeout_cnt); |
| 1638 | pos += scnprintf(buf + pos, bufsz - pos, |
| 1639 | fmt_table, "sleep_time:", |
| 1640 | le32_to_cpu(general->sleep_time), |
| 1641 | accum_general->sleep_time, |
| 1642 | delta_general->sleep_time, max_general->sleep_time); |
| 1643 | pos += scnprintf(buf + pos, bufsz - pos, |
| 1644 | fmt_table, "slots_out:", |
| 1645 | le32_to_cpu(general->slots_out), |
| 1646 | accum_general->slots_out, |
| 1647 | delta_general->slots_out, max_general->slots_out); |
| 1648 | pos += scnprintf(buf + pos, bufsz - pos, |
| 1649 | fmt_table, "slots_idle:", |
| 1650 | le32_to_cpu(general->slots_idle), |
| 1651 | accum_general->slots_idle, |
| 1652 | delta_general->slots_idle, max_general->slots_idle); |
| 1653 | pos += scnprintf(buf + pos, bufsz - pos, |
| 1654 | fmt_table, "tx_on_a:", |
| 1655 | le32_to_cpu(div->tx_on_a), accum_div->tx_on_a, |
| 1656 | delta_div->tx_on_a, max_div->tx_on_a); |
| 1657 | pos += scnprintf(buf + pos, bufsz - pos, |
| 1658 | fmt_table, "tx_on_b:", |
| 1659 | le32_to_cpu(div->tx_on_b), accum_div->tx_on_b, |
| 1660 | delta_div->tx_on_b, max_div->tx_on_b); |
| 1661 | pos += scnprintf(buf + pos, bufsz - pos, |
| 1662 | fmt_table, "exec_time:", |
| 1663 | le32_to_cpu(div->exec_time), accum_div->exec_time, |
| 1664 | delta_div->exec_time, max_div->exec_time); |
| 1665 | pos += scnprintf(buf + pos, bufsz - pos, |
| 1666 | fmt_table, "probe_time:", |
| 1667 | le32_to_cpu(div->probe_time), accum_div->probe_time, |
| 1668 | delta_div->probe_time, max_div->probe_time); |
| 1669 | pos += scnprintf(buf + pos, bufsz - pos, |
| 1670 | fmt_table, "rx_enable_counter:", |
| 1671 | le32_to_cpu(general->rx_enable_counter), |
| 1672 | accum_general->rx_enable_counter, |
| 1673 | delta_general->rx_enable_counter, |
| 1674 | max_general->rx_enable_counter); |
| 1675 | pos += scnprintf(buf + pos, bufsz - pos, |
| 1676 | fmt_table, "num_of_sos_states:", |
| 1677 | le32_to_cpu(general->num_of_sos_states), |
| 1678 | accum_general->num_of_sos_states, |
| 1679 | delta_general->num_of_sos_states, |
| 1680 | max_general->num_of_sos_states); |
Johannes Berg | 4ff70fc | 2012-03-05 11:24:26 -0800 | [diff] [blame] | 1681 | |
| 1682 | spin_unlock_bh(&priv->statistics.lock); |
| 1683 | |
Wey-Yi Guy | d6d023a | 2011-04-30 09:10:53 -0700 | [diff] [blame] | 1684 | ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos); |
| 1685 | kfree(buf); |
| 1686 | return ret; |
| 1687 | } |
| 1688 | |
| 1689 | static ssize_t iwl_dbgfs_ucode_bt_stats_read(struct file *file, |
| 1690 | char __user *user_buf, |
| 1691 | size_t count, loff_t *ppos) |
| 1692 | { |
| 1693 | struct iwl_priv *priv = (struct iwl_priv *)file->private_data; |
| 1694 | int pos = 0; |
| 1695 | char *buf; |
| 1696 | int bufsz = (sizeof(struct statistics_bt_activity) * 24) + 200; |
| 1697 | ssize_t ret; |
| 1698 | struct statistics_bt_activity *bt, *accum_bt; |
| 1699 | |
Emmanuel Grumbach | 845a9c0 | 2011-08-25 23:11:04 -0700 | [diff] [blame] | 1700 | if (!iwl_is_alive(priv->shrd)) |
Wey-Yi Guy | d6d023a | 2011-04-30 09:10:53 -0700 | [diff] [blame] | 1701 | return -EAGAIN; |
| 1702 | |
| 1703 | if (!priv->bt_enable_flag) |
| 1704 | return -EINVAL; |
| 1705 | |
| 1706 | /* make request to uCode to retrieve statistics information */ |
Johannes Berg | b1eea29 | 2012-03-06 13:30:42 -0800 | [diff] [blame] | 1707 | mutex_lock(&priv->mutex); |
Wey-Yi Guy | d6d023a | 2011-04-30 09:10:53 -0700 | [diff] [blame] | 1708 | ret = iwl_send_statistics_request(priv, CMD_SYNC, false); |
Johannes Berg | b1eea29 | 2012-03-06 13:30:42 -0800 | [diff] [blame] | 1709 | mutex_unlock(&priv->mutex); |
Wey-Yi Guy | d6d023a | 2011-04-30 09:10:53 -0700 | [diff] [blame] | 1710 | |
| 1711 | if (ret) { |
| 1712 | IWL_ERR(priv, |
| 1713 | "Error sending statistics request: %zd\n", ret); |
| 1714 | return -EAGAIN; |
| 1715 | } |
| 1716 | buf = kzalloc(bufsz, GFP_KERNEL); |
| 1717 | if (!buf) { |
| 1718 | IWL_ERR(priv, "Can not allocate Buffer\n"); |
| 1719 | return -ENOMEM; |
| 1720 | } |
| 1721 | |
| 1722 | /* |
| 1723 | * the statistic information display here is based on |
| 1724 | * the last statistics notification from uCode |
| 1725 | * might not reflect the current uCode activity |
| 1726 | */ |
Johannes Berg | 4ff70fc | 2012-03-05 11:24:26 -0800 | [diff] [blame] | 1727 | |
| 1728 | spin_lock_bh(&priv->statistics.lock); |
| 1729 | |
Wey-Yi Guy | d6d023a | 2011-04-30 09:10:53 -0700 | [diff] [blame] | 1730 | bt = &priv->statistics.bt_activity; |
| 1731 | accum_bt = &priv->accum_stats.bt_activity; |
| 1732 | |
| 1733 | pos += iwl_statistics_flag(priv, buf, bufsz); |
| 1734 | pos += scnprintf(buf + pos, bufsz - pos, "Statistics_BT:\n"); |
| 1735 | pos += scnprintf(buf + pos, bufsz - pos, |
| 1736 | "\t\t\tcurrent\t\t\taccumulative\n"); |
| 1737 | pos += scnprintf(buf + pos, bufsz - pos, |
| 1738 | "hi_priority_tx_req_cnt:\t\t%u\t\t\t%u\n", |
| 1739 | le32_to_cpu(bt->hi_priority_tx_req_cnt), |
| 1740 | accum_bt->hi_priority_tx_req_cnt); |
| 1741 | pos += scnprintf(buf + pos, bufsz - pos, |
| 1742 | "hi_priority_tx_denied_cnt:\t%u\t\t\t%u\n", |
| 1743 | le32_to_cpu(bt->hi_priority_tx_denied_cnt), |
| 1744 | accum_bt->hi_priority_tx_denied_cnt); |
| 1745 | pos += scnprintf(buf + pos, bufsz - pos, |
| 1746 | "lo_priority_tx_req_cnt:\t\t%u\t\t\t%u\n", |
| 1747 | le32_to_cpu(bt->lo_priority_tx_req_cnt), |
| 1748 | accum_bt->lo_priority_tx_req_cnt); |
| 1749 | pos += scnprintf(buf + pos, bufsz - pos, |
| 1750 | "lo_priority_tx_denied_cnt:\t%u\t\t\t%u\n", |
| 1751 | le32_to_cpu(bt->lo_priority_tx_denied_cnt), |
| 1752 | accum_bt->lo_priority_tx_denied_cnt); |
| 1753 | pos += scnprintf(buf + pos, bufsz - pos, |
| 1754 | "hi_priority_rx_req_cnt:\t\t%u\t\t\t%u\n", |
| 1755 | le32_to_cpu(bt->hi_priority_rx_req_cnt), |
| 1756 | accum_bt->hi_priority_rx_req_cnt); |
| 1757 | pos += scnprintf(buf + pos, bufsz - pos, |
| 1758 | "hi_priority_rx_denied_cnt:\t%u\t\t\t%u\n", |
| 1759 | le32_to_cpu(bt->hi_priority_rx_denied_cnt), |
| 1760 | accum_bt->hi_priority_rx_denied_cnt); |
| 1761 | pos += scnprintf(buf + pos, bufsz - pos, |
| 1762 | "lo_priority_rx_req_cnt:\t\t%u\t\t\t%u\n", |
| 1763 | le32_to_cpu(bt->lo_priority_rx_req_cnt), |
| 1764 | accum_bt->lo_priority_rx_req_cnt); |
| 1765 | pos += scnprintf(buf + pos, bufsz - pos, |
| 1766 | "lo_priority_rx_denied_cnt:\t%u\t\t\t%u\n", |
| 1767 | le32_to_cpu(bt->lo_priority_rx_denied_cnt), |
| 1768 | accum_bt->lo_priority_rx_denied_cnt); |
| 1769 | |
| 1770 | pos += scnprintf(buf + pos, bufsz - pos, |
| 1771 | "(rx)num_bt_kills:\t\t%u\t\t\t%u\n", |
| 1772 | le32_to_cpu(priv->statistics.num_bt_kills), |
| 1773 | priv->statistics.accum_num_bt_kills); |
| 1774 | |
Johannes Berg | 4ff70fc | 2012-03-05 11:24:26 -0800 | [diff] [blame] | 1775 | spin_unlock_bh(&priv->statistics.lock); |
| 1776 | |
Wey-Yi Guy | d6d023a | 2011-04-30 09:10:53 -0700 | [diff] [blame] | 1777 | ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos); |
| 1778 | kfree(buf); |
| 1779 | return ret; |
| 1780 | } |
| 1781 | |
| 1782 | static ssize_t iwl_dbgfs_reply_tx_error_read(struct file *file, |
| 1783 | char __user *user_buf, |
| 1784 | size_t count, loff_t *ppos) |
| 1785 | { |
| 1786 | struct iwl_priv *priv = (struct iwl_priv *)file->private_data; |
| 1787 | int pos = 0; |
| 1788 | char *buf; |
| 1789 | int bufsz = (sizeof(struct reply_tx_error_statistics) * 24) + |
| 1790 | (sizeof(struct reply_agg_tx_error_statistics) * 24) + 200; |
| 1791 | ssize_t ret; |
| 1792 | |
Emmanuel Grumbach | 845a9c0 | 2011-08-25 23:11:04 -0700 | [diff] [blame] | 1793 | if (!iwl_is_alive(priv->shrd)) |
Wey-Yi Guy | d6d023a | 2011-04-30 09:10:53 -0700 | [diff] [blame] | 1794 | return -EAGAIN; |
| 1795 | |
| 1796 | buf = kzalloc(bufsz, GFP_KERNEL); |
| 1797 | if (!buf) { |
| 1798 | IWL_ERR(priv, "Can not allocate Buffer\n"); |
| 1799 | return -ENOMEM; |
| 1800 | } |
| 1801 | |
| 1802 | pos += scnprintf(buf + pos, bufsz - pos, "Statistics_TX_Error:\n"); |
| 1803 | pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t\t\t%u\n", |
| 1804 | iwl_get_tx_fail_reason(TX_STATUS_POSTPONE_DELAY), |
Wey-Yi Guy | 898ed67 | 2011-07-13 08:38:57 -0700 | [diff] [blame] | 1805 | priv->reply_tx_stats.pp_delay); |
Wey-Yi Guy | d6d023a | 2011-04-30 09:10:53 -0700 | [diff] [blame] | 1806 | pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t\t%u\n", |
| 1807 | iwl_get_tx_fail_reason(TX_STATUS_POSTPONE_FEW_BYTES), |
Wey-Yi Guy | 898ed67 | 2011-07-13 08:38:57 -0700 | [diff] [blame] | 1808 | priv->reply_tx_stats.pp_few_bytes); |
Wey-Yi Guy | d6d023a | 2011-04-30 09:10:53 -0700 | [diff] [blame] | 1809 | pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t\t%u\n", |
| 1810 | iwl_get_tx_fail_reason(TX_STATUS_POSTPONE_BT_PRIO), |
Wey-Yi Guy | 898ed67 | 2011-07-13 08:38:57 -0700 | [diff] [blame] | 1811 | priv->reply_tx_stats.pp_bt_prio); |
Wey-Yi Guy | d6d023a | 2011-04-30 09:10:53 -0700 | [diff] [blame] | 1812 | pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t\t%u\n", |
| 1813 | iwl_get_tx_fail_reason(TX_STATUS_POSTPONE_QUIET_PERIOD), |
Wey-Yi Guy | 898ed67 | 2011-07-13 08:38:57 -0700 | [diff] [blame] | 1814 | priv->reply_tx_stats.pp_quiet_period); |
Wey-Yi Guy | d6d023a | 2011-04-30 09:10:53 -0700 | [diff] [blame] | 1815 | pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t\t%u\n", |
| 1816 | iwl_get_tx_fail_reason(TX_STATUS_POSTPONE_CALC_TTAK), |
Wey-Yi Guy | 898ed67 | 2011-07-13 08:38:57 -0700 | [diff] [blame] | 1817 | priv->reply_tx_stats.pp_calc_ttak); |
Wey-Yi Guy | d6d023a | 2011-04-30 09:10:53 -0700 | [diff] [blame] | 1818 | pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t%u\n", |
| 1819 | iwl_get_tx_fail_reason( |
| 1820 | TX_STATUS_FAIL_INTERNAL_CROSSED_RETRY), |
Wey-Yi Guy | 898ed67 | 2011-07-13 08:38:57 -0700 | [diff] [blame] | 1821 | priv->reply_tx_stats.int_crossed_retry); |
Wey-Yi Guy | d6d023a | 2011-04-30 09:10:53 -0700 | [diff] [blame] | 1822 | pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t\t%u\n", |
| 1823 | iwl_get_tx_fail_reason(TX_STATUS_FAIL_SHORT_LIMIT), |
Wey-Yi Guy | 898ed67 | 2011-07-13 08:38:57 -0700 | [diff] [blame] | 1824 | priv->reply_tx_stats.short_limit); |
Wey-Yi Guy | d6d023a | 2011-04-30 09:10:53 -0700 | [diff] [blame] | 1825 | pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t\t%u\n", |
| 1826 | iwl_get_tx_fail_reason(TX_STATUS_FAIL_LONG_LIMIT), |
Wey-Yi Guy | 898ed67 | 2011-07-13 08:38:57 -0700 | [diff] [blame] | 1827 | priv->reply_tx_stats.long_limit); |
Wey-Yi Guy | d6d023a | 2011-04-30 09:10:53 -0700 | [diff] [blame] | 1828 | pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t\t%u\n", |
| 1829 | iwl_get_tx_fail_reason(TX_STATUS_FAIL_FIFO_UNDERRUN), |
Wey-Yi Guy | 898ed67 | 2011-07-13 08:38:57 -0700 | [diff] [blame] | 1830 | priv->reply_tx_stats.fifo_underrun); |
Wey-Yi Guy | d6d023a | 2011-04-30 09:10:53 -0700 | [diff] [blame] | 1831 | pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t\t%u\n", |
| 1832 | iwl_get_tx_fail_reason(TX_STATUS_FAIL_DRAIN_FLOW), |
Wey-Yi Guy | 898ed67 | 2011-07-13 08:38:57 -0700 | [diff] [blame] | 1833 | priv->reply_tx_stats.drain_flow); |
Wey-Yi Guy | d6d023a | 2011-04-30 09:10:53 -0700 | [diff] [blame] | 1834 | pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t\t%u\n", |
| 1835 | iwl_get_tx_fail_reason(TX_STATUS_FAIL_RFKILL_FLUSH), |
Wey-Yi Guy | 898ed67 | 2011-07-13 08:38:57 -0700 | [diff] [blame] | 1836 | priv->reply_tx_stats.rfkill_flush); |
Wey-Yi Guy | d6d023a | 2011-04-30 09:10:53 -0700 | [diff] [blame] | 1837 | pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t\t%u\n", |
| 1838 | iwl_get_tx_fail_reason(TX_STATUS_FAIL_LIFE_EXPIRE), |
Wey-Yi Guy | 898ed67 | 2011-07-13 08:38:57 -0700 | [diff] [blame] | 1839 | priv->reply_tx_stats.life_expire); |
Wey-Yi Guy | d6d023a | 2011-04-30 09:10:53 -0700 | [diff] [blame] | 1840 | pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t\t%u\n", |
| 1841 | iwl_get_tx_fail_reason(TX_STATUS_FAIL_DEST_PS), |
Wey-Yi Guy | 898ed67 | 2011-07-13 08:38:57 -0700 | [diff] [blame] | 1842 | priv->reply_tx_stats.dest_ps); |
Wey-Yi Guy | d6d023a | 2011-04-30 09:10:53 -0700 | [diff] [blame] | 1843 | pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t\t%u\n", |
| 1844 | iwl_get_tx_fail_reason(TX_STATUS_FAIL_HOST_ABORTED), |
Wey-Yi Guy | 898ed67 | 2011-07-13 08:38:57 -0700 | [diff] [blame] | 1845 | priv->reply_tx_stats.host_abort); |
Wey-Yi Guy | d6d023a | 2011-04-30 09:10:53 -0700 | [diff] [blame] | 1846 | pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t\t%u\n", |
| 1847 | iwl_get_tx_fail_reason(TX_STATUS_FAIL_BT_RETRY), |
Wey-Yi Guy | 898ed67 | 2011-07-13 08:38:57 -0700 | [diff] [blame] | 1848 | priv->reply_tx_stats.pp_delay); |
Wey-Yi Guy | d6d023a | 2011-04-30 09:10:53 -0700 | [diff] [blame] | 1849 | pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t\t%u\n", |
| 1850 | iwl_get_tx_fail_reason(TX_STATUS_FAIL_STA_INVALID), |
Wey-Yi Guy | 898ed67 | 2011-07-13 08:38:57 -0700 | [diff] [blame] | 1851 | priv->reply_tx_stats.sta_invalid); |
Wey-Yi Guy | d6d023a | 2011-04-30 09:10:53 -0700 | [diff] [blame] | 1852 | pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t\t%u\n", |
| 1853 | iwl_get_tx_fail_reason(TX_STATUS_FAIL_FRAG_DROPPED), |
Wey-Yi Guy | 898ed67 | 2011-07-13 08:38:57 -0700 | [diff] [blame] | 1854 | priv->reply_tx_stats.frag_drop); |
Wey-Yi Guy | d6d023a | 2011-04-30 09:10:53 -0700 | [diff] [blame] | 1855 | pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t\t%u\n", |
| 1856 | iwl_get_tx_fail_reason(TX_STATUS_FAIL_TID_DISABLE), |
Wey-Yi Guy | 898ed67 | 2011-07-13 08:38:57 -0700 | [diff] [blame] | 1857 | priv->reply_tx_stats.tid_disable); |
Wey-Yi Guy | d6d023a | 2011-04-30 09:10:53 -0700 | [diff] [blame] | 1858 | pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t\t%u\n", |
| 1859 | iwl_get_tx_fail_reason(TX_STATUS_FAIL_FIFO_FLUSHED), |
Wey-Yi Guy | 898ed67 | 2011-07-13 08:38:57 -0700 | [diff] [blame] | 1860 | priv->reply_tx_stats.fifo_flush); |
Wey-Yi Guy | d6d023a | 2011-04-30 09:10:53 -0700 | [diff] [blame] | 1861 | pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t%u\n", |
| 1862 | iwl_get_tx_fail_reason( |
| 1863 | TX_STATUS_FAIL_INSUFFICIENT_CF_POLL), |
Wey-Yi Guy | 898ed67 | 2011-07-13 08:38:57 -0700 | [diff] [blame] | 1864 | priv->reply_tx_stats.insuff_cf_poll); |
Wey-Yi Guy | d6d023a | 2011-04-30 09:10:53 -0700 | [diff] [blame] | 1865 | pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t\t%u\n", |
| 1866 | iwl_get_tx_fail_reason(TX_STATUS_FAIL_PASSIVE_NO_RX), |
Wey-Yi Guy | 898ed67 | 2011-07-13 08:38:57 -0700 | [diff] [blame] | 1867 | priv->reply_tx_stats.fail_hw_drop); |
Wey-Yi Guy | d6d023a | 2011-04-30 09:10:53 -0700 | [diff] [blame] | 1868 | pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t%u\n", |
| 1869 | iwl_get_tx_fail_reason( |
| 1870 | TX_STATUS_FAIL_NO_BEACON_ON_RADAR), |
Wey-Yi Guy | 898ed67 | 2011-07-13 08:38:57 -0700 | [diff] [blame] | 1871 | priv->reply_tx_stats.sta_color_mismatch); |
Wey-Yi Guy | d6d023a | 2011-04-30 09:10:53 -0700 | [diff] [blame] | 1872 | pos += scnprintf(buf + pos, bufsz - pos, "UNKNOWN:\t\t\t%u\n", |
Wey-Yi Guy | 898ed67 | 2011-07-13 08:38:57 -0700 | [diff] [blame] | 1873 | priv->reply_tx_stats.unknown); |
Wey-Yi Guy | d6d023a | 2011-04-30 09:10:53 -0700 | [diff] [blame] | 1874 | |
| 1875 | pos += scnprintf(buf + pos, bufsz - pos, |
| 1876 | "\nStatistics_Agg_TX_Error:\n"); |
| 1877 | |
| 1878 | pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t\t%u\n", |
| 1879 | iwl_get_agg_tx_fail_reason(AGG_TX_STATE_UNDERRUN_MSK), |
Wey-Yi Guy | 898ed67 | 2011-07-13 08:38:57 -0700 | [diff] [blame] | 1880 | priv->reply_agg_tx_stats.underrun); |
Wey-Yi Guy | d6d023a | 2011-04-30 09:10:53 -0700 | [diff] [blame] | 1881 | pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t\t%u\n", |
| 1882 | iwl_get_agg_tx_fail_reason(AGG_TX_STATE_BT_PRIO_MSK), |
Wey-Yi Guy | 898ed67 | 2011-07-13 08:38:57 -0700 | [diff] [blame] | 1883 | priv->reply_agg_tx_stats.bt_prio); |
Wey-Yi Guy | d6d023a | 2011-04-30 09:10:53 -0700 | [diff] [blame] | 1884 | pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t\t%u\n", |
| 1885 | iwl_get_agg_tx_fail_reason(AGG_TX_STATE_FEW_BYTES_MSK), |
Wey-Yi Guy | 898ed67 | 2011-07-13 08:38:57 -0700 | [diff] [blame] | 1886 | priv->reply_agg_tx_stats.few_bytes); |
Wey-Yi Guy | d6d023a | 2011-04-30 09:10:53 -0700 | [diff] [blame] | 1887 | pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t\t%u\n", |
| 1888 | iwl_get_agg_tx_fail_reason(AGG_TX_STATE_ABORT_MSK), |
Wey-Yi Guy | 898ed67 | 2011-07-13 08:38:57 -0700 | [diff] [blame] | 1889 | priv->reply_agg_tx_stats.abort); |
Wey-Yi Guy | d6d023a | 2011-04-30 09:10:53 -0700 | [diff] [blame] | 1890 | pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t%u\n", |
| 1891 | iwl_get_agg_tx_fail_reason( |
| 1892 | AGG_TX_STATE_LAST_SENT_TTL_MSK), |
Wey-Yi Guy | 898ed67 | 2011-07-13 08:38:57 -0700 | [diff] [blame] | 1893 | priv->reply_agg_tx_stats.last_sent_ttl); |
Wey-Yi Guy | d6d023a | 2011-04-30 09:10:53 -0700 | [diff] [blame] | 1894 | pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t%u\n", |
| 1895 | iwl_get_agg_tx_fail_reason( |
| 1896 | AGG_TX_STATE_LAST_SENT_TRY_CNT_MSK), |
Wey-Yi Guy | 898ed67 | 2011-07-13 08:38:57 -0700 | [diff] [blame] | 1897 | priv->reply_agg_tx_stats.last_sent_try); |
Wey-Yi Guy | d6d023a | 2011-04-30 09:10:53 -0700 | [diff] [blame] | 1898 | pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t%u\n", |
| 1899 | iwl_get_agg_tx_fail_reason( |
| 1900 | AGG_TX_STATE_LAST_SENT_BT_KILL_MSK), |
Wey-Yi Guy | 898ed67 | 2011-07-13 08:38:57 -0700 | [diff] [blame] | 1901 | priv->reply_agg_tx_stats.last_sent_bt_kill); |
Wey-Yi Guy | d6d023a | 2011-04-30 09:10:53 -0700 | [diff] [blame] | 1902 | pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t\t%u\n", |
| 1903 | iwl_get_agg_tx_fail_reason(AGG_TX_STATE_SCD_QUERY_MSK), |
Wey-Yi Guy | 898ed67 | 2011-07-13 08:38:57 -0700 | [diff] [blame] | 1904 | priv->reply_agg_tx_stats.scd_query); |
Wey-Yi Guy | d6d023a | 2011-04-30 09:10:53 -0700 | [diff] [blame] | 1905 | pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t%u\n", |
| 1906 | iwl_get_agg_tx_fail_reason( |
| 1907 | AGG_TX_STATE_TEST_BAD_CRC32_MSK), |
Wey-Yi Guy | 898ed67 | 2011-07-13 08:38:57 -0700 | [diff] [blame] | 1908 | priv->reply_agg_tx_stats.bad_crc32); |
Wey-Yi Guy | d6d023a | 2011-04-30 09:10:53 -0700 | [diff] [blame] | 1909 | pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t\t%u\n", |
| 1910 | iwl_get_agg_tx_fail_reason(AGG_TX_STATE_RESPONSE_MSK), |
Wey-Yi Guy | 898ed67 | 2011-07-13 08:38:57 -0700 | [diff] [blame] | 1911 | priv->reply_agg_tx_stats.response); |
Wey-Yi Guy | d6d023a | 2011-04-30 09:10:53 -0700 | [diff] [blame] | 1912 | pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t\t%u\n", |
| 1913 | iwl_get_agg_tx_fail_reason(AGG_TX_STATE_DUMP_TX_MSK), |
Wey-Yi Guy | 898ed67 | 2011-07-13 08:38:57 -0700 | [diff] [blame] | 1914 | priv->reply_agg_tx_stats.dump_tx); |
Wey-Yi Guy | d6d023a | 2011-04-30 09:10:53 -0700 | [diff] [blame] | 1915 | pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t\t%u\n", |
| 1916 | iwl_get_agg_tx_fail_reason(AGG_TX_STATE_DELAY_TX_MSK), |
Wey-Yi Guy | 898ed67 | 2011-07-13 08:38:57 -0700 | [diff] [blame] | 1917 | priv->reply_agg_tx_stats.delay_tx); |
Wey-Yi Guy | d6d023a | 2011-04-30 09:10:53 -0700 | [diff] [blame] | 1918 | pos += scnprintf(buf + pos, bufsz - pos, "UNKNOWN:\t\t\t%u\n", |
Wey-Yi Guy | 898ed67 | 2011-07-13 08:38:57 -0700 | [diff] [blame] | 1919 | priv->reply_agg_tx_stats.unknown); |
Wey-Yi Guy | d6d023a | 2011-04-30 09:10:53 -0700 | [diff] [blame] | 1920 | |
| 1921 | ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos); |
| 1922 | kfree(buf); |
| 1923 | return ret; |
Wey-Yi Guy | e8fe59a | 2009-08-07 15:41:42 -0700 | [diff] [blame] | 1924 | } |
| 1925 | |
Wey-Yi Guy | 5225935 | 2009-08-07 15:41:43 -0700 | [diff] [blame] | 1926 | static ssize_t iwl_dbgfs_sensitivity_read(struct file *file, |
| 1927 | char __user *user_buf, |
| 1928 | size_t count, loff_t *ppos) { |
| 1929 | |
H Hartley Sweeten | 28f63a4 | 2010-01-08 16:14:10 -0700 | [diff] [blame] | 1930 | struct iwl_priv *priv = file->private_data; |
Wey-Yi Guy | 5225935 | 2009-08-07 15:41:43 -0700 | [diff] [blame] | 1931 | int pos = 0; |
| 1932 | int cnt = 0; |
| 1933 | char *buf; |
| 1934 | int bufsz = sizeof(struct iwl_sensitivity_data) * 4 + 100; |
| 1935 | ssize_t ret; |
| 1936 | struct iwl_sensitivity_data *data; |
| 1937 | |
| 1938 | data = &priv->sensitivity_data; |
| 1939 | buf = kzalloc(bufsz, GFP_KERNEL); |
| 1940 | if (!buf) { |
| 1941 | IWL_ERR(priv, "Can not allocate Buffer\n"); |
| 1942 | return -ENOMEM; |
| 1943 | } |
| 1944 | |
| 1945 | pos += scnprintf(buf + pos, bufsz - pos, "auto_corr_ofdm:\t\t\t %u\n", |
| 1946 | data->auto_corr_ofdm); |
| 1947 | pos += scnprintf(buf + pos, bufsz - pos, |
| 1948 | "auto_corr_ofdm_mrc:\t\t %u\n", |
| 1949 | data->auto_corr_ofdm_mrc); |
| 1950 | pos += scnprintf(buf + pos, bufsz - pos, "auto_corr_ofdm_x1:\t\t %u\n", |
| 1951 | data->auto_corr_ofdm_x1); |
| 1952 | pos += scnprintf(buf + pos, bufsz - pos, |
| 1953 | "auto_corr_ofdm_mrc_x1:\t\t %u\n", |
| 1954 | data->auto_corr_ofdm_mrc_x1); |
| 1955 | pos += scnprintf(buf + pos, bufsz - pos, "auto_corr_cck:\t\t\t %u\n", |
| 1956 | data->auto_corr_cck); |
| 1957 | pos += scnprintf(buf + pos, bufsz - pos, "auto_corr_cck_mrc:\t\t %u\n", |
| 1958 | data->auto_corr_cck_mrc); |
| 1959 | pos += scnprintf(buf + pos, bufsz - pos, |
| 1960 | "last_bad_plcp_cnt_ofdm:\t\t %u\n", |
| 1961 | data->last_bad_plcp_cnt_ofdm); |
| 1962 | pos += scnprintf(buf + pos, bufsz - pos, "last_fa_cnt_ofdm:\t\t %u\n", |
| 1963 | data->last_fa_cnt_ofdm); |
| 1964 | pos += scnprintf(buf + pos, bufsz - pos, |
| 1965 | "last_bad_plcp_cnt_cck:\t\t %u\n", |
| 1966 | data->last_bad_plcp_cnt_cck); |
| 1967 | pos += scnprintf(buf + pos, bufsz - pos, "last_fa_cnt_cck:\t\t %u\n", |
| 1968 | data->last_fa_cnt_cck); |
| 1969 | pos += scnprintf(buf + pos, bufsz - pos, "nrg_curr_state:\t\t\t %u\n", |
| 1970 | data->nrg_curr_state); |
| 1971 | pos += scnprintf(buf + pos, bufsz - pos, "nrg_prev_state:\t\t\t %u\n", |
| 1972 | data->nrg_prev_state); |
| 1973 | pos += scnprintf(buf + pos, bufsz - pos, "nrg_value:\t\t\t"); |
| 1974 | for (cnt = 0; cnt < 10; cnt++) { |
| 1975 | pos += scnprintf(buf + pos, bufsz - pos, " %u", |
| 1976 | data->nrg_value[cnt]); |
| 1977 | } |
| 1978 | pos += scnprintf(buf + pos, bufsz - pos, "\n"); |
| 1979 | pos += scnprintf(buf + pos, bufsz - pos, "nrg_silence_rssi:\t\t"); |
| 1980 | for (cnt = 0; cnt < NRG_NUM_PREV_STAT_L; cnt++) { |
| 1981 | pos += scnprintf(buf + pos, bufsz - pos, " %u", |
| 1982 | data->nrg_silence_rssi[cnt]); |
| 1983 | } |
| 1984 | pos += scnprintf(buf + pos, bufsz - pos, "\n"); |
| 1985 | pos += scnprintf(buf + pos, bufsz - pos, "nrg_silence_ref:\t\t %u\n", |
| 1986 | data->nrg_silence_ref); |
| 1987 | pos += scnprintf(buf + pos, bufsz - pos, "nrg_energy_idx:\t\t\t %u\n", |
| 1988 | data->nrg_energy_idx); |
| 1989 | pos += scnprintf(buf + pos, bufsz - pos, "nrg_silence_idx:\t\t %u\n", |
| 1990 | data->nrg_silence_idx); |
| 1991 | pos += scnprintf(buf + pos, bufsz - pos, "nrg_th_cck:\t\t\t %u\n", |
| 1992 | data->nrg_th_cck); |
| 1993 | pos += scnprintf(buf + pos, bufsz - pos, |
| 1994 | "nrg_auto_corr_silence_diff:\t %u\n", |
| 1995 | data->nrg_auto_corr_silence_diff); |
| 1996 | pos += scnprintf(buf + pos, bufsz - pos, "num_in_cck_no_fa:\t\t %u\n", |
| 1997 | data->num_in_cck_no_fa); |
| 1998 | pos += scnprintf(buf + pos, bufsz - pos, "nrg_th_ofdm:\t\t\t %u\n", |
| 1999 | data->nrg_th_ofdm); |
| 2000 | |
| 2001 | ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos); |
| 2002 | kfree(buf); |
| 2003 | return ret; |
| 2004 | } |
| 2005 | |
| 2006 | |
| 2007 | static ssize_t iwl_dbgfs_chain_noise_read(struct file *file, |
| 2008 | char __user *user_buf, |
| 2009 | size_t count, loff_t *ppos) { |
| 2010 | |
H Hartley Sweeten | 28f63a4 | 2010-01-08 16:14:10 -0700 | [diff] [blame] | 2011 | struct iwl_priv *priv = file->private_data; |
Wey-Yi Guy | 5225935 | 2009-08-07 15:41:43 -0700 | [diff] [blame] | 2012 | int pos = 0; |
| 2013 | int cnt = 0; |
| 2014 | char *buf; |
| 2015 | int bufsz = sizeof(struct iwl_chain_noise_data) * 4 + 100; |
| 2016 | ssize_t ret; |
| 2017 | struct iwl_chain_noise_data *data; |
| 2018 | |
| 2019 | data = &priv->chain_noise_data; |
| 2020 | buf = kzalloc(bufsz, GFP_KERNEL); |
| 2021 | if (!buf) { |
| 2022 | IWL_ERR(priv, "Can not allocate Buffer\n"); |
| 2023 | return -ENOMEM; |
| 2024 | } |
| 2025 | |
| 2026 | pos += scnprintf(buf + pos, bufsz - pos, "active_chains:\t\t\t %u\n", |
| 2027 | data->active_chains); |
| 2028 | pos += scnprintf(buf + pos, bufsz - pos, "chain_noise_a:\t\t\t %u\n", |
| 2029 | data->chain_noise_a); |
| 2030 | pos += scnprintf(buf + pos, bufsz - pos, "chain_noise_b:\t\t\t %u\n", |
| 2031 | data->chain_noise_b); |
| 2032 | pos += scnprintf(buf + pos, bufsz - pos, "chain_noise_c:\t\t\t %u\n", |
| 2033 | data->chain_noise_c); |
| 2034 | pos += scnprintf(buf + pos, bufsz - pos, "chain_signal_a:\t\t\t %u\n", |
| 2035 | data->chain_signal_a); |
| 2036 | pos += scnprintf(buf + pos, bufsz - pos, "chain_signal_b:\t\t\t %u\n", |
| 2037 | data->chain_signal_b); |
| 2038 | pos += scnprintf(buf + pos, bufsz - pos, "chain_signal_c:\t\t\t %u\n", |
| 2039 | data->chain_signal_c); |
| 2040 | pos += scnprintf(buf + pos, bufsz - pos, "beacon_count:\t\t\t %u\n", |
| 2041 | data->beacon_count); |
| 2042 | |
| 2043 | pos += scnprintf(buf + pos, bufsz - pos, "disconn_array:\t\t\t"); |
| 2044 | for (cnt = 0; cnt < NUM_RX_CHAINS; cnt++) { |
| 2045 | pos += scnprintf(buf + pos, bufsz - pos, " %u", |
| 2046 | data->disconn_array[cnt]); |
| 2047 | } |
| 2048 | pos += scnprintf(buf + pos, bufsz - pos, "\n"); |
| 2049 | pos += scnprintf(buf + pos, bufsz - pos, "delta_gain_code:\t\t"); |
| 2050 | for (cnt = 0; cnt < NUM_RX_CHAINS; cnt++) { |
| 2051 | pos += scnprintf(buf + pos, bufsz - pos, " %u", |
| 2052 | data->delta_gain_code[cnt]); |
| 2053 | } |
| 2054 | pos += scnprintf(buf + pos, bufsz - pos, "\n"); |
| 2055 | pos += scnprintf(buf + pos, bufsz - pos, "radio_write:\t\t\t %u\n", |
| 2056 | data->radio_write); |
| 2057 | pos += scnprintf(buf + pos, bufsz - pos, "state:\t\t\t\t %u\n", |
| 2058 | data->state); |
| 2059 | |
| 2060 | ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos); |
| 2061 | kfree(buf); |
| 2062 | return ret; |
| 2063 | } |
| 2064 | |
Wey-Yi Guy | c09430a | 2009-10-16 14:25:50 -0700 | [diff] [blame] | 2065 | static ssize_t iwl_dbgfs_power_save_status_read(struct file *file, |
| 2066 | char __user *user_buf, |
| 2067 | size_t count, loff_t *ppos) |
| 2068 | { |
H Hartley Sweeten | 28f63a4 | 2010-01-08 16:14:10 -0700 | [diff] [blame] | 2069 | struct iwl_priv *priv = file->private_data; |
Wey-Yi Guy | c09430a | 2009-10-16 14:25:50 -0700 | [diff] [blame] | 2070 | char buf[60]; |
| 2071 | int pos = 0; |
| 2072 | const size_t bufsz = sizeof(buf); |
| 2073 | u32 pwrsave_status; |
| 2074 | |
Emmanuel Grumbach | 1042db2 | 2012-01-03 16:56:15 +0200 | [diff] [blame] | 2075 | pwrsave_status = iwl_read32(trans(priv), CSR_GP_CNTRL) & |
Wey-Yi Guy | c09430a | 2009-10-16 14:25:50 -0700 | [diff] [blame] | 2076 | CSR_GP_REG_POWER_SAVE_STATUS_MSK; |
| 2077 | |
| 2078 | pos += scnprintf(buf + pos, bufsz - pos, "Power Save Status: "); |
| 2079 | pos += scnprintf(buf + pos, bufsz - pos, "%s\n", |
| 2080 | (pwrsave_status == CSR_GP_REG_NO_POWER_SAVE) ? "none" : |
| 2081 | (pwrsave_status == CSR_GP_REG_MAC_POWER_SAVE) ? "MAC" : |
| 2082 | (pwrsave_status == CSR_GP_REG_PHY_POWER_SAVE) ? "PHY" : |
| 2083 | "error"); |
| 2084 | |
| 2085 | return simple_read_from_buffer(user_buf, count, ppos, buf, pos); |
| 2086 | } |
| 2087 | |
Wey-Yi Guy | 7163b8a | 2009-11-20 12:04:56 -0800 | [diff] [blame] | 2088 | static ssize_t iwl_dbgfs_clear_ucode_statistics_write(struct file *file, |
Wey-Yi Guy | ef8d552 | 2009-11-13 11:56:28 -0800 | [diff] [blame] | 2089 | const char __user *user_buf, |
| 2090 | size_t count, loff_t *ppos) |
| 2091 | { |
| 2092 | struct iwl_priv *priv = file->private_data; |
| 2093 | char buf[8]; |
| 2094 | int buf_size; |
| 2095 | int clear; |
| 2096 | |
| 2097 | memset(buf, 0, sizeof(buf)); |
| 2098 | buf_size = min(count, sizeof(buf) - 1); |
| 2099 | if (copy_from_user(buf, user_buf, buf_size)) |
| 2100 | return -EFAULT; |
| 2101 | if (sscanf(buf, "%d", &clear) != 1) |
| 2102 | return -EFAULT; |
| 2103 | |
| 2104 | /* make request to uCode to retrieve statistics information */ |
Johannes Berg | b1eea29 | 2012-03-06 13:30:42 -0800 | [diff] [blame] | 2105 | mutex_lock(&priv->mutex); |
Wey-Yi Guy | ef8d552 | 2009-11-13 11:56:28 -0800 | [diff] [blame] | 2106 | iwl_send_statistics_request(priv, CMD_SYNC, true); |
Johannes Berg | b1eea29 | 2012-03-06 13:30:42 -0800 | [diff] [blame] | 2107 | mutex_unlock(&priv->mutex); |
Wey-Yi Guy | ef8d552 | 2009-11-13 11:56:28 -0800 | [diff] [blame] | 2108 | |
| 2109 | return count; |
| 2110 | } |
| 2111 | |
Wey-Yi Guy | a9e1cb6 | 2009-12-10 14:37:26 -0800 | [diff] [blame] | 2112 | static ssize_t iwl_dbgfs_ucode_tracing_read(struct file *file, |
| 2113 | char __user *user_buf, |
| 2114 | size_t count, loff_t *ppos) { |
| 2115 | |
Joe Perches | 5767430 | 2010-07-12 13:50:06 -0700 | [diff] [blame] | 2116 | struct iwl_priv *priv = file->private_data; |
Wey-Yi Guy | a9e1cb6 | 2009-12-10 14:37:26 -0800 | [diff] [blame] | 2117 | int pos = 0; |
| 2118 | char buf[128]; |
| 2119 | const size_t bufsz = sizeof(buf); |
Wey-Yi Guy | a9e1cb6 | 2009-12-10 14:37:26 -0800 | [diff] [blame] | 2120 | |
| 2121 | pos += scnprintf(buf + pos, bufsz - pos, "ucode trace timer is %s\n", |
| 2122 | priv->event_log.ucode_trace ? "On" : "Off"); |
| 2123 | pos += scnprintf(buf + pos, bufsz - pos, "non_wraps_count:\t\t %u\n", |
| 2124 | priv->event_log.non_wraps_count); |
| 2125 | pos += scnprintf(buf + pos, bufsz - pos, "wraps_once_count:\t\t %u\n", |
| 2126 | priv->event_log.wraps_once_count); |
| 2127 | pos += scnprintf(buf + pos, bufsz - pos, "wraps_more_count:\t\t %u\n", |
| 2128 | priv->event_log.wraps_more_count); |
| 2129 | |
Wey-Yi Guy | 4967c31 | 2010-02-18 15:22:07 -0800 | [diff] [blame] | 2130 | return simple_read_from_buffer(user_buf, count, ppos, buf, pos); |
Wey-Yi Guy | a9e1cb6 | 2009-12-10 14:37:26 -0800 | [diff] [blame] | 2131 | } |
| 2132 | |
| 2133 | static ssize_t iwl_dbgfs_ucode_tracing_write(struct file *file, |
| 2134 | const char __user *user_buf, |
| 2135 | size_t count, loff_t *ppos) |
| 2136 | { |
| 2137 | struct iwl_priv *priv = file->private_data; |
| 2138 | char buf[8]; |
| 2139 | int buf_size; |
| 2140 | int trace; |
| 2141 | |
| 2142 | memset(buf, 0, sizeof(buf)); |
| 2143 | buf_size = min(count, sizeof(buf) - 1); |
| 2144 | if (copy_from_user(buf, user_buf, buf_size)) |
| 2145 | return -EFAULT; |
| 2146 | if (sscanf(buf, "%d", &trace) != 1) |
| 2147 | return -EFAULT; |
| 2148 | |
| 2149 | if (trace) { |
| 2150 | priv->event_log.ucode_trace = true; |
Johannes Berg | 98d4bf0 | 2012-01-13 11:56:11 +0100 | [diff] [blame] | 2151 | if (iwl_is_alive(priv->shrd)) { |
| 2152 | /* start collecting data now */ |
| 2153 | mod_timer(&priv->ucode_trace, jiffies); |
| 2154 | } |
Wey-Yi Guy | a9e1cb6 | 2009-12-10 14:37:26 -0800 | [diff] [blame] | 2155 | } else { |
| 2156 | priv->event_log.ucode_trace = false; |
| 2157 | del_timer_sync(&priv->ucode_trace); |
| 2158 | } |
| 2159 | |
| 2160 | return count; |
| 2161 | } |
| 2162 | |
Johannes Berg | 6098720 | 2010-02-18 00:36:07 -0800 | [diff] [blame] | 2163 | static ssize_t iwl_dbgfs_rxon_flags_read(struct file *file, |
| 2164 | char __user *user_buf, |
| 2165 | size_t count, loff_t *ppos) { |
| 2166 | |
Joe Perches | 5767430 | 2010-07-12 13:50:06 -0700 | [diff] [blame] | 2167 | struct iwl_priv *priv = file->private_data; |
Johannes Berg | 6098720 | 2010-02-18 00:36:07 -0800 | [diff] [blame] | 2168 | int len = 0; |
| 2169 | char buf[20]; |
| 2170 | |
Johannes Berg | 246ed35 | 2010-08-23 10:46:32 +0200 | [diff] [blame] | 2171 | len = sprintf(buf, "0x%04X\n", |
| 2172 | le32_to_cpu(priv->contexts[IWL_RXON_CTX_BSS].active.flags)); |
Johannes Berg | 6098720 | 2010-02-18 00:36:07 -0800 | [diff] [blame] | 2173 | return simple_read_from_buffer(user_buf, count, ppos, buf, len); |
| 2174 | } |
| 2175 | |
| 2176 | static ssize_t iwl_dbgfs_rxon_filter_flags_read(struct file *file, |
| 2177 | char __user *user_buf, |
| 2178 | size_t count, loff_t *ppos) { |
| 2179 | |
Joe Perches | 5767430 | 2010-07-12 13:50:06 -0700 | [diff] [blame] | 2180 | struct iwl_priv *priv = file->private_data; |
Johannes Berg | 6098720 | 2010-02-18 00:36:07 -0800 | [diff] [blame] | 2181 | int len = 0; |
| 2182 | char buf[20]; |
| 2183 | |
| 2184 | len = sprintf(buf, "0x%04X\n", |
Johannes Berg | 246ed35 | 2010-08-23 10:46:32 +0200 | [diff] [blame] | 2185 | le32_to_cpu(priv->contexts[IWL_RXON_CTX_BSS].active.filter_flags)); |
Johannes Berg | 6098720 | 2010-02-18 00:36:07 -0800 | [diff] [blame] | 2186 | return simple_read_from_buffer(user_buf, count, ppos, buf, len); |
| 2187 | } |
| 2188 | |
Wey-Yi Guy | a13d276 | 2010-01-22 14:22:42 -0800 | [diff] [blame] | 2189 | static ssize_t iwl_dbgfs_missed_beacon_read(struct file *file, |
| 2190 | char __user *user_buf, |
| 2191 | size_t count, loff_t *ppos) { |
| 2192 | |
| 2193 | struct iwl_priv *priv = file->private_data; |
| 2194 | int pos = 0; |
| 2195 | char buf[12]; |
| 2196 | const size_t bufsz = sizeof(buf); |
Wey-Yi Guy | a13d276 | 2010-01-22 14:22:42 -0800 | [diff] [blame] | 2197 | |
| 2198 | pos += scnprintf(buf + pos, bufsz - pos, "%d\n", |
| 2199 | priv->missed_beacon_threshold); |
| 2200 | |
Wey-Yi Guy | 4967c31 | 2010-02-18 15:22:07 -0800 | [diff] [blame] | 2201 | return simple_read_from_buffer(user_buf, count, ppos, buf, pos); |
Wey-Yi Guy | a13d276 | 2010-01-22 14:22:42 -0800 | [diff] [blame] | 2202 | } |
| 2203 | |
| 2204 | static ssize_t iwl_dbgfs_missed_beacon_write(struct file *file, |
| 2205 | const char __user *user_buf, |
| 2206 | size_t count, loff_t *ppos) |
| 2207 | { |
| 2208 | struct iwl_priv *priv = file->private_data; |
| 2209 | char buf[8]; |
| 2210 | int buf_size; |
| 2211 | int missed; |
| 2212 | |
| 2213 | memset(buf, 0, sizeof(buf)); |
| 2214 | buf_size = min(count, sizeof(buf) - 1); |
| 2215 | if (copy_from_user(buf, user_buf, buf_size)) |
| 2216 | return -EFAULT; |
| 2217 | if (sscanf(buf, "%d", &missed) != 1) |
| 2218 | return -EINVAL; |
| 2219 | |
| 2220 | if (missed < IWL_MISSED_BEACON_THRESHOLD_MIN || |
| 2221 | missed > IWL_MISSED_BEACON_THRESHOLD_MAX) |
| 2222 | priv->missed_beacon_threshold = |
| 2223 | IWL_MISSED_BEACON_THRESHOLD_DEF; |
| 2224 | else |
| 2225 | priv->missed_beacon_threshold = missed; |
| 2226 | |
| 2227 | return count; |
| 2228 | } |
| 2229 | |
Trieu 'Andrew' Nguyen | 3e4fb5f | 2010-01-22 14:22:46 -0800 | [diff] [blame] | 2230 | static ssize_t iwl_dbgfs_plcp_delta_read(struct file *file, |
| 2231 | char __user *user_buf, |
| 2232 | size_t count, loff_t *ppos) { |
| 2233 | |
Joe Perches | 5767430 | 2010-07-12 13:50:06 -0700 | [diff] [blame] | 2234 | struct iwl_priv *priv = file->private_data; |
Trieu 'Andrew' Nguyen | 3e4fb5f | 2010-01-22 14:22:46 -0800 | [diff] [blame] | 2235 | int pos = 0; |
| 2236 | char buf[12]; |
| 2237 | const size_t bufsz = sizeof(buf); |
Trieu 'Andrew' Nguyen | 3e4fb5f | 2010-01-22 14:22:46 -0800 | [diff] [blame] | 2238 | |
| 2239 | pos += scnprintf(buf + pos, bufsz - pos, "%u\n", |
Johannes Berg | ab5c0f1 | 2012-03-06 13:30:53 -0800 | [diff] [blame] | 2240 | priv->plcp_delta_threshold); |
Trieu 'Andrew' Nguyen | 3e4fb5f | 2010-01-22 14:22:46 -0800 | [diff] [blame] | 2241 | |
Wey-Yi Guy | 4967c31 | 2010-02-18 15:22:07 -0800 | [diff] [blame] | 2242 | return simple_read_from_buffer(user_buf, count, ppos, buf, pos); |
Trieu 'Andrew' Nguyen | 3e4fb5f | 2010-01-22 14:22:46 -0800 | [diff] [blame] | 2243 | } |
| 2244 | |
| 2245 | static ssize_t iwl_dbgfs_plcp_delta_write(struct file *file, |
| 2246 | const char __user *user_buf, |
| 2247 | size_t count, loff_t *ppos) { |
| 2248 | |
| 2249 | struct iwl_priv *priv = file->private_data; |
| 2250 | char buf[8]; |
| 2251 | int buf_size; |
| 2252 | int plcp; |
| 2253 | |
| 2254 | memset(buf, 0, sizeof(buf)); |
| 2255 | buf_size = min(count, sizeof(buf) - 1); |
| 2256 | if (copy_from_user(buf, user_buf, buf_size)) |
| 2257 | return -EFAULT; |
| 2258 | if (sscanf(buf, "%d", &plcp) != 1) |
| 2259 | return -EINVAL; |
Wey-Yi Guy | 680788a | 2010-06-17 15:25:00 -0700 | [diff] [blame] | 2260 | if ((plcp < IWL_MAX_PLCP_ERR_THRESHOLD_MIN) || |
Trieu 'Andrew' Nguyen | 3e4fb5f | 2010-01-22 14:22:46 -0800 | [diff] [blame] | 2261 | (plcp > IWL_MAX_PLCP_ERR_THRESHOLD_MAX)) |
Johannes Berg | ab5c0f1 | 2012-03-06 13:30:53 -0800 | [diff] [blame] | 2262 | priv->plcp_delta_threshold = |
Wey-Yi Guy | 680788a | 2010-06-17 15:25:00 -0700 | [diff] [blame] | 2263 | IWL_MAX_PLCP_ERR_THRESHOLD_DISABLE; |
Trieu 'Andrew' Nguyen | 3e4fb5f | 2010-01-22 14:22:46 -0800 | [diff] [blame] | 2264 | else |
Johannes Berg | ab5c0f1 | 2012-03-06 13:30:53 -0800 | [diff] [blame] | 2265 | priv->plcp_delta_threshold = plcp; |
Trieu 'Andrew' Nguyen | 3e4fb5f | 2010-01-22 14:22:46 -0800 | [diff] [blame] | 2266 | return count; |
| 2267 | } |
| 2268 | |
Wey-Yi Guy | 528c312 | 2010-02-18 22:03:07 -0800 | [diff] [blame] | 2269 | static ssize_t iwl_dbgfs_force_reset_read(struct file *file, |
| 2270 | char __user *user_buf, |
Johannes Berg | ca934b6 | 2011-09-15 11:46:48 -0700 | [diff] [blame] | 2271 | size_t count, loff_t *ppos) |
| 2272 | { |
Wey-Yi Guy | 528c312 | 2010-02-18 22:03:07 -0800 | [diff] [blame] | 2273 | struct iwl_priv *priv = file->private_data; |
| 2274 | int i, pos = 0; |
| 2275 | char buf[300]; |
| 2276 | const size_t bufsz = sizeof(buf); |
| 2277 | struct iwl_force_reset *force_reset; |
| 2278 | |
| 2279 | for (i = 0; i < IWL_MAX_FORCE_RESET; i++) { |
| 2280 | force_reset = &priv->force_reset[i]; |
| 2281 | pos += scnprintf(buf + pos, bufsz - pos, |
| 2282 | "Force reset method %d\n", i); |
| 2283 | pos += scnprintf(buf + pos, bufsz - pos, |
| 2284 | "\tnumber of reset request: %d\n", |
| 2285 | force_reset->reset_request_count); |
| 2286 | pos += scnprintf(buf + pos, bufsz - pos, |
| 2287 | "\tnumber of reset request success: %d\n", |
| 2288 | force_reset->reset_success_count); |
| 2289 | pos += scnprintf(buf + pos, bufsz - pos, |
| 2290 | "\tnumber of reset request reject: %d\n", |
| 2291 | force_reset->reset_reject_count); |
| 2292 | pos += scnprintf(buf + pos, bufsz - pos, |
| 2293 | "\treset duration: %lu\n", |
| 2294 | force_reset->reset_duration); |
| 2295 | } |
| 2296 | return simple_read_from_buffer(user_buf, count, ppos, buf, pos); |
| 2297 | } |
| 2298 | |
Wey-Yi Guy | 04cafd7 | 2010-02-03 11:47:20 -0800 | [diff] [blame] | 2299 | static ssize_t iwl_dbgfs_force_reset_write(struct file *file, |
| 2300 | const char __user *user_buf, |
| 2301 | size_t count, loff_t *ppos) { |
| 2302 | |
| 2303 | struct iwl_priv *priv = file->private_data; |
| 2304 | char buf[8]; |
| 2305 | int buf_size; |
| 2306 | int reset, ret; |
| 2307 | |
| 2308 | memset(buf, 0, sizeof(buf)); |
| 2309 | buf_size = min(count, sizeof(buf) - 1); |
| 2310 | if (copy_from_user(buf, user_buf, buf_size)) |
| 2311 | return -EFAULT; |
| 2312 | if (sscanf(buf, "%d", &reset) != 1) |
| 2313 | return -EINVAL; |
| 2314 | switch (reset) { |
| 2315 | case IWL_RF_RESET: |
| 2316 | case IWL_FW_RESET: |
Wey-Yi Guy | c04f9f2 | 2010-06-21 16:52:55 -0700 | [diff] [blame] | 2317 | ret = iwl_force_reset(priv, reset, true); |
Wey-Yi Guy | 04cafd7 | 2010-02-03 11:47:20 -0800 | [diff] [blame] | 2318 | break; |
| 2319 | default: |
| 2320 | return -EINVAL; |
| 2321 | } |
| 2322 | return ret ? ret : count; |
| 2323 | } |
| 2324 | |
Wey-Yi Guy | 4bf49a9 | 2010-06-24 13:18:36 -0700 | [diff] [blame] | 2325 | static ssize_t iwl_dbgfs_txfifo_flush_write(struct file *file, |
| 2326 | const char __user *user_buf, |
| 2327 | size_t count, loff_t *ppos) { |
| 2328 | |
| 2329 | struct iwl_priv *priv = file->private_data; |
| 2330 | char buf[8]; |
| 2331 | int buf_size; |
| 2332 | int flush; |
| 2333 | |
| 2334 | memset(buf, 0, sizeof(buf)); |
| 2335 | buf_size = min(count, sizeof(buf) - 1); |
| 2336 | if (copy_from_user(buf, user_buf, buf_size)) |
| 2337 | return -EFAULT; |
| 2338 | if (sscanf(buf, "%d", &flush) != 1) |
| 2339 | return -EINVAL; |
| 2340 | |
Emmanuel Grumbach | 845a9c0 | 2011-08-25 23:11:04 -0700 | [diff] [blame] | 2341 | if (iwl_is_rfkill(priv->shrd)) |
Wey-Yi Guy | 4bf49a9 | 2010-06-24 13:18:36 -0700 | [diff] [blame] | 2342 | return -EFAULT; |
| 2343 | |
Wey-Yi Guy | c68744f | 2011-06-18 08:03:18 -0700 | [diff] [blame] | 2344 | iwlagn_dev_txfifo_flush(priv, IWL_DROP_ALL); |
Wey-Yi Guy | 4bf49a9 | 2010-06-24 13:18:36 -0700 | [diff] [blame] | 2345 | |
| 2346 | return count; |
| 2347 | } |
| 2348 | |
Stanislaw Gruszka | 22de94d | 2010-12-03 15:41:48 +0100 | [diff] [blame] | 2349 | static ssize_t iwl_dbgfs_wd_timeout_write(struct file *file, |
Wey-Yi Guy | 7bdc473 | 2010-08-23 07:57:07 -0700 | [diff] [blame] | 2350 | const char __user *user_buf, |
Johannes Berg | ca934b6 | 2011-09-15 11:46:48 -0700 | [diff] [blame] | 2351 | size_t count, loff_t *ppos) |
| 2352 | { |
Wey-Yi Guy | 7bdc473 | 2010-08-23 07:57:07 -0700 | [diff] [blame] | 2353 | struct iwl_priv *priv = file->private_data; |
| 2354 | char buf[8]; |
| 2355 | int buf_size; |
Stanislaw Gruszka | 22de94d | 2010-12-03 15:41:48 +0100 | [diff] [blame] | 2356 | int timeout; |
Wey-Yi Guy | 7bdc473 | 2010-08-23 07:57:07 -0700 | [diff] [blame] | 2357 | |
| 2358 | memset(buf, 0, sizeof(buf)); |
| 2359 | buf_size = min(count, sizeof(buf) - 1); |
| 2360 | if (copy_from_user(buf, user_buf, buf_size)) |
| 2361 | return -EFAULT; |
Stanislaw Gruszka | 22de94d | 2010-12-03 15:41:48 +0100 | [diff] [blame] | 2362 | if (sscanf(buf, "%d", &timeout) != 1) |
Wey-Yi Guy | 7bdc473 | 2010-08-23 07:57:07 -0700 | [diff] [blame] | 2363 | return -EINVAL; |
Stanislaw Gruszka | 22de94d | 2010-12-03 15:41:48 +0100 | [diff] [blame] | 2364 | if (timeout < 0 || timeout > IWL_MAX_WD_TIMEOUT) |
| 2365 | timeout = IWL_DEF_WD_TIMEOUT; |
Wey-Yi Guy | 7bdc473 | 2010-08-23 07:57:07 -0700 | [diff] [blame] | 2366 | |
Johannes Berg | e7a0943 | 2012-03-06 13:30:54 -0800 | [diff] [blame] | 2367 | hw_params(priv).wd_timeout = timeout; |
Stanislaw Gruszka | 22de94d | 2010-12-03 15:41:48 +0100 | [diff] [blame] | 2368 | iwl_setup_watchdog(priv); |
Wey-Yi Guy | 7bdc473 | 2010-08-23 07:57:07 -0700 | [diff] [blame] | 2369 | return count; |
| 2370 | } |
| 2371 | |
Wey-Yi Guy | befe8c4 | 2010-08-23 07:57:16 -0700 | [diff] [blame] | 2372 | static ssize_t iwl_dbgfs_bt_traffic_read(struct file *file, |
| 2373 | char __user *user_buf, |
| 2374 | size_t count, loff_t *ppos) { |
| 2375 | |
| 2376 | struct iwl_priv *priv = (struct iwl_priv *)file->private_data; |
| 2377 | int pos = 0; |
| 2378 | char buf[200]; |
| 2379 | const size_t bufsz = sizeof(buf); |
Wey-Yi Guy | befe8c4 | 2010-08-23 07:57:16 -0700 | [diff] [blame] | 2380 | |
Wey-Yi Guy | f21dd00 | 2010-12-08 15:34:52 -0800 | [diff] [blame] | 2381 | if (!priv->bt_enable_flag) { |
| 2382 | pos += scnprintf(buf + pos, bufsz - pos, "BT coex disabled\n"); |
Johannes Berg | 08960de | 2011-04-05 09:41:53 -0700 | [diff] [blame] | 2383 | return simple_read_from_buffer(user_buf, count, ppos, buf, pos); |
Wey-Yi Guy | f21dd00 | 2010-12-08 15:34:52 -0800 | [diff] [blame] | 2384 | } |
| 2385 | pos += scnprintf(buf + pos, bufsz - pos, "BT enable flag: 0x%x\n", |
| 2386 | priv->bt_enable_flag); |
Wey-Yi Guy | befe8c4 | 2010-08-23 07:57:16 -0700 | [diff] [blame] | 2387 | pos += scnprintf(buf + pos, bufsz - pos, "BT in %s mode\n", |
| 2388 | priv->bt_full_concurrent ? "full concurrency" : "3-wire"); |
| 2389 | pos += scnprintf(buf + pos, bufsz - pos, "BT status: %s, " |
| 2390 | "last traffic notif: %d\n", |
Wey-Yi Guy | 66e863a5 | 2010-11-08 14:54:37 -0800 | [diff] [blame] | 2391 | priv->bt_status ? "On" : "Off", priv->last_bt_traffic_load); |
Wey-Yi Guy | befe8c4 | 2010-08-23 07:57:16 -0700 | [diff] [blame] | 2392 | pos += scnprintf(buf + pos, bufsz - pos, "ch_announcement: %d, " |
Wey-Yi Guy | 187bc4f | 2011-01-27 13:01:33 -0800 | [diff] [blame] | 2393 | "kill_ack_mask: %x, kill_cts_mask: %x\n", |
| 2394 | priv->bt_ch_announce, priv->kill_ack_mask, |
| 2395 | priv->kill_cts_mask); |
Wey-Yi Guy | befe8c4 | 2010-08-23 07:57:16 -0700 | [diff] [blame] | 2396 | |
| 2397 | pos += scnprintf(buf + pos, bufsz - pos, "bluetooth traffic load: "); |
| 2398 | switch (priv->bt_traffic_load) { |
| 2399 | case IWL_BT_COEX_TRAFFIC_LOAD_CONTINUOUS: |
| 2400 | pos += scnprintf(buf + pos, bufsz - pos, "Continuous\n"); |
| 2401 | break; |
| 2402 | case IWL_BT_COEX_TRAFFIC_LOAD_HIGH: |
| 2403 | pos += scnprintf(buf + pos, bufsz - pos, "High\n"); |
| 2404 | break; |
| 2405 | case IWL_BT_COEX_TRAFFIC_LOAD_LOW: |
| 2406 | pos += scnprintf(buf + pos, bufsz - pos, "Low\n"); |
| 2407 | break; |
| 2408 | case IWL_BT_COEX_TRAFFIC_LOAD_NONE: |
| 2409 | default: |
| 2410 | pos += scnprintf(buf + pos, bufsz - pos, "None\n"); |
| 2411 | break; |
| 2412 | } |
| 2413 | |
Johannes Berg | 08960de | 2011-04-05 09:41:53 -0700 | [diff] [blame] | 2414 | return simple_read_from_buffer(user_buf, count, ppos, buf, pos); |
Wey-Yi Guy | befe8c4 | 2010-08-23 07:57:16 -0700 | [diff] [blame] | 2415 | } |
| 2416 | |
Wey-Yi Guy | c6abdc0 | 2010-09-01 17:10:51 -0700 | [diff] [blame] | 2417 | static ssize_t iwl_dbgfs_protection_mode_read(struct file *file, |
| 2418 | char __user *user_buf, |
| 2419 | size_t count, loff_t *ppos) |
| 2420 | { |
| 2421 | struct iwl_priv *priv = (struct iwl_priv *)file->private_data; |
| 2422 | |
| 2423 | int pos = 0; |
| 2424 | char buf[40]; |
| 2425 | const size_t bufsz = sizeof(buf); |
| 2426 | |
Don Fry | 3862241 | 2011-12-16 07:07:36 -0800 | [diff] [blame] | 2427 | if (cfg(priv)->ht_params) |
Wey-Yi Guy | 7cb1b08 | 2010-10-06 08:10:00 -0700 | [diff] [blame] | 2428 | pos += scnprintf(buf + pos, bufsz - pos, |
| 2429 | "use %s for aggregation\n", |
Johannes Berg | b9ad70d | 2012-03-06 13:30:55 -0800 | [diff] [blame] | 2430 | (hw_params(priv).use_rts_for_aggregation) ? |
Wey-Yi Guy | 7cb1b08 | 2010-10-06 08:10:00 -0700 | [diff] [blame] | 2431 | "rts/cts" : "cts-to-self"); |
| 2432 | else |
| 2433 | pos += scnprintf(buf + pos, bufsz - pos, "N/A"); |
| 2434 | |
Wey-Yi Guy | c6abdc0 | 2010-09-01 17:10:51 -0700 | [diff] [blame] | 2435 | return simple_read_from_buffer(user_buf, count, ppos, buf, pos); |
| 2436 | } |
| 2437 | |
| 2438 | static ssize_t iwl_dbgfs_protection_mode_write(struct file *file, |
| 2439 | const char __user *user_buf, |
| 2440 | size_t count, loff_t *ppos) { |
| 2441 | |
| 2442 | struct iwl_priv *priv = file->private_data; |
| 2443 | char buf[8]; |
| 2444 | int buf_size; |
| 2445 | int rts; |
| 2446 | |
Don Fry | 3862241 | 2011-12-16 07:07:36 -0800 | [diff] [blame] | 2447 | if (!cfg(priv)->ht_params) |
Wey-Yi Guy | 7cb1b08 | 2010-10-06 08:10:00 -0700 | [diff] [blame] | 2448 | return -EINVAL; |
| 2449 | |
Wey-Yi Guy | c6abdc0 | 2010-09-01 17:10:51 -0700 | [diff] [blame] | 2450 | memset(buf, 0, sizeof(buf)); |
| 2451 | buf_size = min(count, sizeof(buf) - 1); |
| 2452 | if (copy_from_user(buf, user_buf, buf_size)) |
| 2453 | return -EFAULT; |
| 2454 | if (sscanf(buf, "%d", &rts) != 1) |
| 2455 | return -EINVAL; |
| 2456 | if (rts) |
Johannes Berg | b9ad70d | 2012-03-06 13:30:55 -0800 | [diff] [blame] | 2457 | hw_params(priv).use_rts_for_aggregation = true; |
Wey-Yi Guy | c6abdc0 | 2010-09-01 17:10:51 -0700 | [diff] [blame] | 2458 | else |
Johannes Berg | b9ad70d | 2012-03-06 13:30:55 -0800 | [diff] [blame] | 2459 | hw_params(priv).use_rts_for_aggregation = false; |
Wey-Yi Guy | c6abdc0 | 2010-09-01 17:10:51 -0700 | [diff] [blame] | 2460 | return count; |
| 2461 | } |
| 2462 | |
Wey-Yi Guy | 7e4005c | 2011-10-10 07:26:51 -0700 | [diff] [blame] | 2463 | static ssize_t iwl_dbgfs_echo_test_write(struct file *file, |
| 2464 | const char __user *user_buf, |
| 2465 | size_t count, loff_t *ppos) |
| 2466 | { |
| 2467 | struct iwl_priv *priv = file->private_data; |
| 2468 | char buf[8]; |
| 2469 | int buf_size; |
| 2470 | |
| 2471 | memset(buf, 0, sizeof(buf)); |
| 2472 | buf_size = min(count, sizeof(buf) - 1); |
| 2473 | if (copy_from_user(buf, user_buf, buf_size)) |
| 2474 | return -EFAULT; |
| 2475 | |
| 2476 | iwl_cmd_echo_test(priv); |
| 2477 | return count; |
| 2478 | } |
| 2479 | |
Wey-Yi Guy | 7163b8a | 2009-11-20 12:04:56 -0800 | [diff] [blame] | 2480 | DEBUGFS_READ_FILE_OPS(rx_statistics); |
| 2481 | DEBUGFS_READ_FILE_OPS(tx_statistics); |
Emmanuel Grumbach | 41f5e04 | 2011-09-06 09:31:20 -0700 | [diff] [blame] | 2482 | DEBUGFS_READ_WRITE_FILE_OPS(traffic_log); |
Wey-Yi Guy | e8fe59a | 2009-08-07 15:41:42 -0700 | [diff] [blame] | 2483 | DEBUGFS_READ_FILE_OPS(ucode_rx_stats); |
| 2484 | DEBUGFS_READ_FILE_OPS(ucode_tx_stats); |
| 2485 | DEBUGFS_READ_FILE_OPS(ucode_general_stats); |
Wey-Yi Guy | 5225935 | 2009-08-07 15:41:43 -0700 | [diff] [blame] | 2486 | DEBUGFS_READ_FILE_OPS(sensitivity); |
| 2487 | DEBUGFS_READ_FILE_OPS(chain_noise); |
Wey-Yi Guy | c09430a | 2009-10-16 14:25:50 -0700 | [diff] [blame] | 2488 | DEBUGFS_READ_FILE_OPS(power_save_status); |
Wey-Yi Guy | 7163b8a | 2009-11-20 12:04:56 -0800 | [diff] [blame] | 2489 | DEBUGFS_WRITE_FILE_OPS(clear_ucode_statistics); |
| 2490 | DEBUGFS_WRITE_FILE_OPS(clear_traffic_statistics); |
Wey-Yi Guy | a9e1cb6 | 2009-12-10 14:37:26 -0800 | [diff] [blame] | 2491 | DEBUGFS_READ_WRITE_FILE_OPS(ucode_tracing); |
Wey-Yi Guy | a13d276 | 2010-01-22 14:22:42 -0800 | [diff] [blame] | 2492 | DEBUGFS_READ_WRITE_FILE_OPS(missed_beacon); |
Trieu 'Andrew' Nguyen | 3e4fb5f | 2010-01-22 14:22:46 -0800 | [diff] [blame] | 2493 | DEBUGFS_READ_WRITE_FILE_OPS(plcp_delta); |
Wey-Yi Guy | 528c312 | 2010-02-18 22:03:07 -0800 | [diff] [blame] | 2494 | DEBUGFS_READ_WRITE_FILE_OPS(force_reset); |
Johannes Berg | 6098720 | 2010-02-18 00:36:07 -0800 | [diff] [blame] | 2495 | DEBUGFS_READ_FILE_OPS(rxon_flags); |
| 2496 | DEBUGFS_READ_FILE_OPS(rxon_filter_flags); |
Wey-Yi Guy | 4bf49a9 | 2010-06-24 13:18:36 -0700 | [diff] [blame] | 2497 | DEBUGFS_WRITE_FILE_OPS(txfifo_flush); |
Wey-Yi Guy | ffb7d89 | 2010-07-14 08:09:55 -0700 | [diff] [blame] | 2498 | DEBUGFS_READ_FILE_OPS(ucode_bt_stats); |
Stanislaw Gruszka | 22de94d | 2010-12-03 15:41:48 +0100 | [diff] [blame] | 2499 | DEBUGFS_WRITE_FILE_OPS(wd_timeout); |
Wey-Yi Guy | befe8c4 | 2010-08-23 07:57:16 -0700 | [diff] [blame] | 2500 | DEBUGFS_READ_FILE_OPS(bt_traffic); |
Wey-Yi Guy | c6abdc0 | 2010-09-01 17:10:51 -0700 | [diff] [blame] | 2501 | DEBUGFS_READ_WRITE_FILE_OPS(protection_mode); |
Wey-Yi Guy | 54a9aa6 | 2010-09-05 10:49:42 -0700 | [diff] [blame] | 2502 | DEBUGFS_READ_FILE_OPS(reply_tx_error); |
Wey-Yi Guy | 7e4005c | 2011-10-10 07:26:51 -0700 | [diff] [blame] | 2503 | DEBUGFS_WRITE_FILE_OPS(echo_test); |
Wey-Yi Guy | 20594eb | 2009-08-07 15:41:39 -0700 | [diff] [blame] | 2504 | |
Tomas Winkler | 712b6cf | 2008-03-12 16:58:52 -0700 | [diff] [blame] | 2505 | /* |
| 2506 | * Create the debugfs files and directories |
| 2507 | * |
| 2508 | */ |
| 2509 | int iwl_dbgfs_register(struct iwl_priv *priv, const char *name) |
| 2510 | { |
Zhu Yi | 95b1a82 | 2008-05-29 16:34:50 +0800 | [diff] [blame] | 2511 | struct dentry *phyd = priv->hw->wiphy->debugfsdir; |
Johannes Berg | 4c84a8f | 2010-01-22 14:22:54 -0800 | [diff] [blame] | 2512 | struct dentry *dir_drv, *dir_data, *dir_rf, *dir_debug; |
Tomas Winkler | 712b6cf | 2008-03-12 16:58:52 -0700 | [diff] [blame] | 2513 | |
Johannes Berg | 4c84a8f | 2010-01-22 14:22:54 -0800 | [diff] [blame] | 2514 | dir_drv = debugfs_create_dir(name, phyd); |
| 2515 | if (!dir_drv) |
| 2516 | return -ENOMEM; |
| 2517 | |
| 2518 | priv->debugfs_dir = dir_drv; |
| 2519 | |
| 2520 | dir_data = debugfs_create_dir("data", dir_drv); |
| 2521 | if (!dir_data) |
Tomas Winkler | 712b6cf | 2008-03-12 16:58:52 -0700 | [diff] [blame] | 2522 | goto err; |
Johannes Berg | 4c84a8f | 2010-01-22 14:22:54 -0800 | [diff] [blame] | 2523 | dir_rf = debugfs_create_dir("rf", dir_drv); |
| 2524 | if (!dir_rf) |
Tomas Winkler | 712b6cf | 2008-03-12 16:58:52 -0700 | [diff] [blame] | 2525 | goto err; |
Johannes Berg | 4c84a8f | 2010-01-22 14:22:54 -0800 | [diff] [blame] | 2526 | dir_debug = debugfs_create_dir("debug", dir_drv); |
| 2527 | if (!dir_debug) |
| 2528 | goto err; |
Tomas Winkler | 712b6cf | 2008-03-12 16:58:52 -0700 | [diff] [blame] | 2529 | |
Johannes Berg | 4c84a8f | 2010-01-22 14:22:54 -0800 | [diff] [blame] | 2530 | DEBUGFS_ADD_FILE(nvm, dir_data, S_IRUSR); |
| 2531 | DEBUGFS_ADD_FILE(sram, dir_data, S_IWUSR | S_IRUSR); |
Johannes Berg | c8ac61c | 2011-07-15 13:23:45 -0700 | [diff] [blame] | 2532 | DEBUGFS_ADD_FILE(wowlan_sram, dir_data, S_IRUSR); |
Johannes Berg | 4c84a8f | 2010-01-22 14:22:54 -0800 | [diff] [blame] | 2533 | DEBUGFS_ADD_FILE(stations, dir_data, S_IRUSR); |
| 2534 | DEBUGFS_ADD_FILE(channels, dir_data, S_IRUSR); |
| 2535 | DEBUGFS_ADD_FILE(status, dir_data, S_IRUSR); |
Emmanuel Grumbach | 1f7b617 | 2011-08-25 23:10:59 -0700 | [diff] [blame] | 2536 | DEBUGFS_ADD_FILE(rx_handlers, dir_data, S_IWUSR | S_IRUSR); |
Johannes Berg | 4c84a8f | 2010-01-22 14:22:54 -0800 | [diff] [blame] | 2537 | DEBUGFS_ADD_FILE(qos, dir_data, S_IRUSR); |
Wey-Yi Guy | 23c0fcc | 2011-04-01 16:29:53 -0700 | [diff] [blame] | 2538 | DEBUGFS_ADD_FILE(sleep_level_override, dir_data, S_IWUSR | S_IRUSR); |
| 2539 | DEBUGFS_ADD_FILE(current_sleep_command, dir_data, S_IRUSR); |
Johannes Berg | 4c84a8f | 2010-01-22 14:22:54 -0800 | [diff] [blame] | 2540 | DEBUGFS_ADD_FILE(thermal_throttling, dir_data, S_IRUSR); |
| 2541 | DEBUGFS_ADD_FILE(disable_ht40, dir_data, S_IWUSR | S_IRUSR); |
Emmanuel Grumbach | 511afa3 | 2011-09-22 07:15:37 -0700 | [diff] [blame] | 2542 | DEBUGFS_ADD_FILE(temperature, dir_data, S_IRUSR); |
Johannes Berg | ca934b6 | 2011-09-15 11:46:48 -0700 | [diff] [blame] | 2543 | |
Johannes Berg | 4c84a8f | 2010-01-22 14:22:54 -0800 | [diff] [blame] | 2544 | DEBUGFS_ADD_FILE(rx_statistics, dir_debug, S_IRUSR); |
| 2545 | DEBUGFS_ADD_FILE(tx_statistics, dir_debug, S_IRUSR); |
Emmanuel Grumbach | 41f5e04 | 2011-09-06 09:31:20 -0700 | [diff] [blame] | 2546 | DEBUGFS_ADD_FILE(traffic_log, dir_debug, S_IWUSR | S_IRUSR); |
Johannes Berg | 4c84a8f | 2010-01-22 14:22:54 -0800 | [diff] [blame] | 2547 | DEBUGFS_ADD_FILE(power_save_status, dir_debug, S_IRUSR); |
| 2548 | DEBUGFS_ADD_FILE(clear_ucode_statistics, dir_debug, S_IWUSR); |
| 2549 | DEBUGFS_ADD_FILE(clear_traffic_statistics, dir_debug, S_IWUSR); |
Johannes Berg | 4c84a8f | 2010-01-22 14:22:54 -0800 | [diff] [blame] | 2550 | DEBUGFS_ADD_FILE(missed_beacon, dir_debug, S_IWUSR); |
Johannes Berg | 4c84a8f | 2010-01-22 14:22:54 -0800 | [diff] [blame] | 2551 | DEBUGFS_ADD_FILE(plcp_delta, dir_debug, S_IWUSR | S_IRUSR); |
Wey-Yi Guy | 528c312 | 2010-02-18 22:03:07 -0800 | [diff] [blame] | 2552 | DEBUGFS_ADD_FILE(force_reset, dir_debug, S_IWUSR | S_IRUSR); |
Abhijeet Kolekar | b8c7626 | 2010-04-08 15:29:07 -0700 | [diff] [blame] | 2553 | DEBUGFS_ADD_FILE(ucode_rx_stats, dir_debug, S_IRUSR); |
| 2554 | DEBUGFS_ADD_FILE(ucode_tx_stats, dir_debug, S_IRUSR); |
| 2555 | DEBUGFS_ADD_FILE(ucode_general_stats, dir_debug, S_IRUSR); |
Wey-Yi Guy | c68744f | 2011-06-18 08:03:18 -0700 | [diff] [blame] | 2556 | DEBUGFS_ADD_FILE(txfifo_flush, dir_debug, S_IWUSR); |
Wey-Yi Guy | c6abdc0 | 2010-09-01 17:10:51 -0700 | [diff] [blame] | 2557 | DEBUGFS_ADD_FILE(protection_mode, dir_debug, S_IWUSR | S_IRUSR); |
Wey-Yi Guy | 703bc58 | 2011-04-03 08:14:41 -0700 | [diff] [blame] | 2558 | DEBUGFS_ADD_FILE(sensitivity, dir_debug, S_IRUSR); |
| 2559 | DEBUGFS_ADD_FILE(chain_noise, dir_debug, S_IRUSR); |
Wey-Yi Guy | b7af6a9 | 2011-04-06 15:55:25 -0700 | [diff] [blame] | 2560 | DEBUGFS_ADD_FILE(ucode_tracing, dir_debug, S_IWUSR | S_IRUSR); |
Johannes Berg | 0da0e5b | 2011-04-08 08:14:56 -0700 | [diff] [blame] | 2561 | DEBUGFS_ADD_FILE(ucode_bt_stats, dir_debug, S_IRUSR); |
Wey-Yi Guy | 54a9aa6 | 2010-09-05 10:49:42 -0700 | [diff] [blame] | 2562 | DEBUGFS_ADD_FILE(reply_tx_error, dir_debug, S_IRUSR); |
Johannes Berg | 6098720 | 2010-02-18 00:36:07 -0800 | [diff] [blame] | 2563 | DEBUGFS_ADD_FILE(rxon_flags, dir_debug, S_IWUSR); |
| 2564 | DEBUGFS_ADD_FILE(rxon_filter_flags, dir_debug, S_IWUSR); |
Stanislaw Gruszka | 22de94d | 2010-12-03 15:41:48 +0100 | [diff] [blame] | 2565 | DEBUGFS_ADD_FILE(wd_timeout, dir_debug, S_IWUSR); |
Wey-Yi Guy | 7e4005c | 2011-10-10 07:26:51 -0700 | [diff] [blame] | 2566 | DEBUGFS_ADD_FILE(echo_test, dir_debug, S_IWUSR); |
Stanislaw Gruszka | 88e58fc | 2011-01-28 16:47:47 +0100 | [diff] [blame] | 2567 | if (iwl_advanced_bt_coexist(priv)) |
Wey-Yi Guy | befe8c4 | 2010-08-23 07:57:16 -0700 | [diff] [blame] | 2568 | DEBUGFS_ADD_FILE(bt_traffic, dir_debug, S_IRUSR); |
Johannes Berg | ca934b6 | 2011-09-15 11:46:48 -0700 | [diff] [blame] | 2569 | |
Wey-Yi Guy | 703bc58 | 2011-04-03 08:14:41 -0700 | [diff] [blame] | 2570 | DEBUGFS_ADD_BOOL(disable_sensitivity, dir_rf, |
| 2571 | &priv->disable_sens_cal); |
| 2572 | DEBUGFS_ADD_BOOL(disable_chain_noise, dir_rf, |
| 2573 | &priv->disable_chain_noise_cal); |
Emmanuel Grumbach | 87e5666 | 2011-08-25 23:10:50 -0700 | [diff] [blame] | 2574 | |
| 2575 | if (iwl_trans_dbgfs_register(trans(priv), dir_debug)) |
| 2576 | goto err; |
Tomas Winkler | 712b6cf | 2008-03-12 16:58:52 -0700 | [diff] [blame] | 2577 | return 0; |
| 2578 | |
| 2579 | err: |
Johannes Berg | 4c84a8f | 2010-01-22 14:22:54 -0800 | [diff] [blame] | 2580 | IWL_ERR(priv, "Can't create the debugfs directory\n"); |
Tomas Winkler | 712b6cf | 2008-03-12 16:58:52 -0700 | [diff] [blame] | 2581 | iwl_dbgfs_unregister(priv); |
Johannes Berg | 4c84a8f | 2010-01-22 14:22:54 -0800 | [diff] [blame] | 2582 | return -ENOMEM; |
Tomas Winkler | 712b6cf | 2008-03-12 16:58:52 -0700 | [diff] [blame] | 2583 | } |
Tomas Winkler | 712b6cf | 2008-03-12 16:58:52 -0700 | [diff] [blame] | 2584 | |
| 2585 | /** |
| 2586 | * Remove the debugfs files and directories |
| 2587 | * |
| 2588 | */ |
| 2589 | void iwl_dbgfs_unregister(struct iwl_priv *priv) |
| 2590 | { |
Johannes Berg | 4c84a8f | 2010-01-22 14:22:54 -0800 | [diff] [blame] | 2591 | if (!priv->debugfs_dir) |
Tomas Winkler | 712b6cf | 2008-03-12 16:58:52 -0700 | [diff] [blame] | 2592 | return; |
| 2593 | |
Johannes Berg | 4c84a8f | 2010-01-22 14:22:54 -0800 | [diff] [blame] | 2594 | debugfs_remove_recursive(priv->debugfs_dir); |
| 2595 | priv->debugfs_dir = NULL; |
Tomas Winkler | 712b6cf | 2008-03-12 16:58:52 -0700 | [diff] [blame] | 2596 | } |