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", |
Emmanuel Grumbach | 63013ae | 2011-08-25 23:10:42 -0700 | [diff] [blame] | 533 | test_bit(STATUS_CT_KILL, &priv->shrd->status)); |
Wey-Yi Guy | 08df05a | 2009-03-24 10:02:54 -0700 | [diff] [blame] | 534 | pos += scnprintf(buf + pos, bufsz - pos, "STATUS_INIT:\t\t %d\n", |
Emmanuel Grumbach | 63013ae | 2011-08-25 23:10:42 -0700 | [diff] [blame] | 535 | test_bit(STATUS_INIT, &priv->shrd->status)); |
Wey-Yi Guy | 08df05a | 2009-03-24 10:02:54 -0700 | [diff] [blame] | 536 | pos += scnprintf(buf + pos, bufsz - pos, "STATUS_ALIVE:\t\t %d\n", |
Emmanuel Grumbach | 63013ae | 2011-08-25 23:10:42 -0700 | [diff] [blame] | 537 | test_bit(STATUS_ALIVE, &priv->shrd->status)); |
Wey-Yi Guy | 08df05a | 2009-03-24 10:02:54 -0700 | [diff] [blame] | 538 | pos += scnprintf(buf + pos, bufsz - pos, "STATUS_READY:\t\t %d\n", |
Emmanuel Grumbach | 63013ae | 2011-08-25 23:10:42 -0700 | [diff] [blame] | 539 | test_bit(STATUS_READY, &priv->shrd->status)); |
Wey-Yi Guy | 08df05a | 2009-03-24 10:02:54 -0700 | [diff] [blame] | 540 | pos += scnprintf(buf + pos, bufsz - pos, "STATUS_TEMPERATURE:\t %d\n", |
Emmanuel Grumbach | 63013ae | 2011-08-25 23:10:42 -0700 | [diff] [blame] | 541 | test_bit(STATUS_TEMPERATURE, &priv->shrd->status)); |
Wey-Yi Guy | 08df05a | 2009-03-24 10:02:54 -0700 | [diff] [blame] | 542 | pos += scnprintf(buf + pos, bufsz - pos, "STATUS_GEO_CONFIGURED:\t %d\n", |
Emmanuel Grumbach | 63013ae | 2011-08-25 23:10:42 -0700 | [diff] [blame] | 543 | test_bit(STATUS_GEO_CONFIGURED, &priv->shrd->status)); |
Wey-Yi Guy | 08df05a | 2009-03-24 10:02:54 -0700 | [diff] [blame] | 544 | pos += scnprintf(buf + pos, bufsz - pos, "STATUS_EXIT_PENDING:\t %d\n", |
Emmanuel Grumbach | 63013ae | 2011-08-25 23:10:42 -0700 | [diff] [blame] | 545 | test_bit(STATUS_EXIT_PENDING, &priv->shrd->status)); |
Wey-Yi Guy | 08df05a | 2009-03-24 10:02:54 -0700 | [diff] [blame] | 546 | pos += scnprintf(buf + pos, bufsz - pos, "STATUS_STATISTICS:\t %d\n", |
Emmanuel Grumbach | 63013ae | 2011-08-25 23:10:42 -0700 | [diff] [blame] | 547 | test_bit(STATUS_STATISTICS, &priv->shrd->status)); |
Wey-Yi Guy | 08df05a | 2009-03-24 10:02:54 -0700 | [diff] [blame] | 548 | pos += scnprintf(buf + pos, bufsz - pos, "STATUS_SCANNING:\t %d\n", |
Emmanuel Grumbach | 63013ae | 2011-08-25 23:10:42 -0700 | [diff] [blame] | 549 | test_bit(STATUS_SCANNING, &priv->shrd->status)); |
Wey-Yi Guy | 08df05a | 2009-03-24 10:02:54 -0700 | [diff] [blame] | 550 | pos += scnprintf(buf + pos, bufsz - pos, "STATUS_SCAN_ABORTING:\t %d\n", |
Emmanuel Grumbach | 63013ae | 2011-08-25 23:10:42 -0700 | [diff] [blame] | 551 | test_bit(STATUS_SCAN_ABORTING, &priv->shrd->status)); |
Wey-Yi Guy | 08df05a | 2009-03-24 10:02:54 -0700 | [diff] [blame] | 552 | 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] | 553 | test_bit(STATUS_SCAN_HW, &priv->shrd->status)); |
Wey-Yi Guy | 08df05a | 2009-03-24 10:02:54 -0700 | [diff] [blame] | 554 | pos += scnprintf(buf + pos, bufsz - pos, "STATUS_POWER_PMI:\t %d\n", |
Emmanuel Grumbach | 63013ae | 2011-08-25 23:10:42 -0700 | [diff] [blame] | 555 | test_bit(STATUS_POWER_PMI, &priv->shrd->status)); |
Wey-Yi Guy | 08df05a | 2009-03-24 10:02:54 -0700 | [diff] [blame] | 556 | pos += scnprintf(buf + pos, bufsz - pos, "STATUS_FW_ERROR:\t %d\n", |
Emmanuel Grumbach | 63013ae | 2011-08-25 23:10:42 -0700 | [diff] [blame] | 557 | test_bit(STATUS_FW_ERROR, &priv->shrd->status)); |
Wey-Yi Guy | 08df05a | 2009-03-24 10:02:54 -0700 | [diff] [blame] | 558 | return simple_read_from_buffer(user_buf, count, ppos, buf, pos); |
| 559 | } |
| 560 | |
Emmanuel Grumbach | 1f7b617 | 2011-08-25 23:10:59 -0700 | [diff] [blame] | 561 | static ssize_t iwl_dbgfs_rx_handlers_read(struct file *file, |
Wey-Yi Guy | a83b914 | 2009-04-08 11:39:32 -0700 | [diff] [blame] | 562 | char __user *user_buf, |
| 563 | size_t count, loff_t *ppos) { |
| 564 | |
H Hartley Sweeten | 28f63a4 | 2010-01-08 16:14:10 -0700 | [diff] [blame] | 565 | struct iwl_priv *priv = file->private_data; |
Emmanuel Grumbach | 1f7b617 | 2011-08-25 23:10:59 -0700 | [diff] [blame] | 566 | |
Wey-Yi Guy | a83b914 | 2009-04-08 11:39:32 -0700 | [diff] [blame] | 567 | int pos = 0; |
| 568 | int cnt = 0; |
| 569 | char *buf; |
| 570 | int bufsz = 24 * 64; /* 24 items * 64 char per item */ |
| 571 | ssize_t ret; |
| 572 | |
| 573 | buf = kzalloc(bufsz, GFP_KERNEL); |
| 574 | if (!buf) { |
| 575 | IWL_ERR(priv, "Can not allocate Buffer\n"); |
| 576 | return -ENOMEM; |
| 577 | } |
| 578 | |
Wey-Yi Guy | a83b914 | 2009-04-08 11:39:32 -0700 | [diff] [blame] | 579 | for (cnt = 0; cnt < REPLY_MAX; cnt++) { |
Emmanuel Grumbach | 1f7b617 | 2011-08-25 23:10:59 -0700 | [diff] [blame] | 580 | if (priv->rx_handlers_stats[cnt] > 0) |
Wey-Yi Guy | a83b914 | 2009-04-08 11:39:32 -0700 | [diff] [blame] | 581 | pos += scnprintf(buf + pos, bufsz - pos, |
| 582 | "\tRx handler[%36s]:\t\t %u\n", |
| 583 | get_cmd_string(cnt), |
Emmanuel Grumbach | 1f7b617 | 2011-08-25 23:10:59 -0700 | [diff] [blame] | 584 | priv->rx_handlers_stats[cnt]); |
Wey-Yi Guy | a83b914 | 2009-04-08 11:39:32 -0700 | [diff] [blame] | 585 | } |
| 586 | |
Wey-Yi Guy | a83b914 | 2009-04-08 11:39:32 -0700 | [diff] [blame] | 587 | ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos); |
| 588 | kfree(buf); |
| 589 | return ret; |
| 590 | } |
| 591 | |
Emmanuel Grumbach | 1f7b617 | 2011-08-25 23:10:59 -0700 | [diff] [blame] | 592 | static ssize_t iwl_dbgfs_rx_handlers_write(struct file *file, |
Wey-Yi Guy | a83b914 | 2009-04-08 11:39:32 -0700 | [diff] [blame] | 593 | const char __user *user_buf, |
| 594 | size_t count, loff_t *ppos) |
| 595 | { |
| 596 | struct iwl_priv *priv = file->private_data; |
Emmanuel Grumbach | 1f7b617 | 2011-08-25 23:10:59 -0700 | [diff] [blame] | 597 | |
Wey-Yi Guy | a83b914 | 2009-04-08 11:39:32 -0700 | [diff] [blame] | 598 | char buf[8]; |
| 599 | int buf_size; |
| 600 | u32 reset_flag; |
| 601 | |
| 602 | memset(buf, 0, sizeof(buf)); |
| 603 | buf_size = min(count, sizeof(buf) - 1); |
| 604 | if (copy_from_user(buf, user_buf, buf_size)) |
| 605 | return -EFAULT; |
| 606 | if (sscanf(buf, "%x", &reset_flag) != 1) |
| 607 | return -EFAULT; |
| 608 | if (reset_flag == 0) |
Emmanuel Grumbach | 1f7b617 | 2011-08-25 23:10:59 -0700 | [diff] [blame] | 609 | memset(&priv->rx_handlers_stats[0], 0, |
| 610 | sizeof(priv->rx_handlers_stats)); |
Wey-Yi Guy | a83b914 | 2009-04-08 11:39:32 -0700 | [diff] [blame] | 611 | |
| 612 | return count; |
| 613 | } |
| 614 | |
Wey-Yi Guy | f5ad69f | 2009-07-09 10:33:36 -0700 | [diff] [blame] | 615 | static ssize_t iwl_dbgfs_qos_read(struct file *file, char __user *user_buf, |
| 616 | size_t count, loff_t *ppos) |
| 617 | { |
H Hartley Sweeten | 28f63a4 | 2010-01-08 16:14:10 -0700 | [diff] [blame] | 618 | struct iwl_priv *priv = file->private_data; |
Johannes Berg | 8dfdb9d | 2010-08-23 10:46:38 +0200 | [diff] [blame] | 619 | struct iwl_rxon_context *ctx; |
Wey-Yi Guy | f5ad69f | 2009-07-09 10:33:36 -0700 | [diff] [blame] | 620 | int pos = 0, i; |
Johannes Berg | 8dfdb9d | 2010-08-23 10:46:38 +0200 | [diff] [blame] | 621 | char buf[256 * NUM_IWL_RXON_CTX]; |
Wey-Yi Guy | f5ad69f | 2009-07-09 10:33:36 -0700 | [diff] [blame] | 622 | const size_t bufsz = sizeof(buf); |
Wey-Yi Guy | f5ad69f | 2009-07-09 10:33:36 -0700 | [diff] [blame] | 623 | |
Johannes Berg | 8dfdb9d | 2010-08-23 10:46:38 +0200 | [diff] [blame] | 624 | for_each_context(priv, ctx) { |
| 625 | pos += scnprintf(buf + pos, bufsz - pos, "context %d:\n", |
| 626 | ctx->ctxid); |
| 627 | for (i = 0; i < AC_NUM; i++) { |
| 628 | pos += scnprintf(buf + pos, bufsz - pos, |
| 629 | "\tcw_min\tcw_max\taifsn\ttxop\n"); |
| 630 | pos += scnprintf(buf + pos, bufsz - pos, |
Wey-Yi Guy | f5ad69f | 2009-07-09 10:33:36 -0700 | [diff] [blame] | 631 | "AC[%d]\t%u\t%u\t%u\t%u\n", i, |
Johannes Berg | 8dfdb9d | 2010-08-23 10:46:38 +0200 | [diff] [blame] | 632 | ctx->qos_data.def_qos_parm.ac[i].cw_min, |
| 633 | ctx->qos_data.def_qos_parm.ac[i].cw_max, |
| 634 | ctx->qos_data.def_qos_parm.ac[i].aifsn, |
| 635 | ctx->qos_data.def_qos_parm.ac[i].edca_txop); |
| 636 | } |
| 637 | pos += scnprintf(buf + pos, bufsz - pos, "\n"); |
Wey-Yi Guy | f5ad69f | 2009-07-09 10:33:36 -0700 | [diff] [blame] | 638 | } |
Wey-Yi Guy | 4967c31 | 2010-02-18 15:22:07 -0800 | [diff] [blame] | 639 | return simple_read_from_buffer(user_buf, count, ppos, buf, pos); |
Wey-Yi Guy | f5ad69f | 2009-07-09 10:33:36 -0700 | [diff] [blame] | 640 | } |
Wey-Yi Guy | a83b914 | 2009-04-08 11:39:32 -0700 | [diff] [blame] | 641 | |
Wey-Yi Guy | fbf3a2a | 2009-07-24 11:13:04 -0700 | [diff] [blame] | 642 | static ssize_t iwl_dbgfs_thermal_throttling_read(struct file *file, |
| 643 | char __user *user_buf, |
| 644 | size_t count, loff_t *ppos) |
| 645 | { |
H Hartley Sweeten | 28f63a4 | 2010-01-08 16:14:10 -0700 | [diff] [blame] | 646 | struct iwl_priv *priv = file->private_data; |
Johannes Berg | 3ad3b92 | 2009-08-07 15:41:48 -0700 | [diff] [blame] | 647 | struct iwl_tt_mgmt *tt = &priv->thermal_throttle; |
Wey-Yi Guy | fbf3a2a | 2009-07-24 11:13:04 -0700 | [diff] [blame] | 648 | struct iwl_tt_restriction *restriction; |
| 649 | char buf[100]; |
| 650 | int pos = 0; |
| 651 | const size_t bufsz = sizeof(buf); |
Wey-Yi Guy | fbf3a2a | 2009-07-24 11:13:04 -0700 | [diff] [blame] | 652 | |
| 653 | pos += scnprintf(buf + pos, bufsz - pos, |
| 654 | "Thermal Throttling Mode: %s\n", |
Johannes Berg | 3ad3b92 | 2009-08-07 15:41:48 -0700 | [diff] [blame] | 655 | tt->advanced_tt ? "Advance" : "Legacy"); |
Wey-Yi Guy | fbf3a2a | 2009-07-24 11:13:04 -0700 | [diff] [blame] | 656 | pos += scnprintf(buf + pos, bufsz - pos, |
| 657 | "Thermal Throttling State: %d\n", |
| 658 | tt->state); |
Johannes Berg | 3ad3b92 | 2009-08-07 15:41:48 -0700 | [diff] [blame] | 659 | if (tt->advanced_tt) { |
Wey-Yi Guy | fbf3a2a | 2009-07-24 11:13:04 -0700 | [diff] [blame] | 660 | restriction = tt->restriction + tt->state; |
| 661 | pos += scnprintf(buf + pos, bufsz - pos, |
| 662 | "Tx mode: %d\n", |
| 663 | restriction->tx_stream); |
| 664 | pos += scnprintf(buf + pos, bufsz - pos, |
| 665 | "Rx mode: %d\n", |
| 666 | restriction->rx_stream); |
| 667 | pos += scnprintf(buf + pos, bufsz - pos, |
| 668 | "HT mode: %d\n", |
| 669 | restriction->is_ht); |
| 670 | } |
Wey-Yi Guy | 4967c31 | 2010-02-18 15:22:07 -0800 | [diff] [blame] | 671 | return simple_read_from_buffer(user_buf, count, ppos, buf, pos); |
Wey-Yi Guy | fbf3a2a | 2009-07-24 11:13:04 -0700 | [diff] [blame] | 672 | } |
| 673 | |
Wey-Yi Guy | 1e4247d | 2009-07-27 13:50:15 -0700 | [diff] [blame] | 674 | static ssize_t iwl_dbgfs_disable_ht40_write(struct file *file, |
| 675 | const char __user *user_buf, |
| 676 | size_t count, loff_t *ppos) |
| 677 | { |
| 678 | struct iwl_priv *priv = file->private_data; |
| 679 | char buf[8]; |
| 680 | int buf_size; |
| 681 | int ht40; |
| 682 | |
| 683 | memset(buf, 0, sizeof(buf)); |
| 684 | buf_size = min(count, sizeof(buf) - 1); |
| 685 | if (copy_from_user(buf, user_buf, buf_size)) |
| 686 | return -EFAULT; |
| 687 | if (sscanf(buf, "%d", &ht40) != 1) |
| 688 | return -EFAULT; |
Johannes Berg | 246ed35 | 2010-08-23 10:46:32 +0200 | [diff] [blame] | 689 | if (!iwl_is_any_associated(priv)) |
Wey-Yi Guy | 1e4247d | 2009-07-27 13:50:15 -0700 | [diff] [blame] | 690 | priv->disable_ht40 = ht40 ? true : false; |
| 691 | else { |
| 692 | IWL_ERR(priv, "Sta associated with AP - " |
| 693 | "Change to 40MHz channel support is not allowed\n"); |
| 694 | return -EINVAL; |
| 695 | } |
| 696 | |
| 697 | return count; |
| 698 | } |
| 699 | |
| 700 | static ssize_t iwl_dbgfs_disable_ht40_read(struct file *file, |
| 701 | char __user *user_buf, |
| 702 | size_t count, loff_t *ppos) |
| 703 | { |
H Hartley Sweeten | 28f63a4 | 2010-01-08 16:14:10 -0700 | [diff] [blame] | 704 | struct iwl_priv *priv = file->private_data; |
Wey-Yi Guy | 1e4247d | 2009-07-27 13:50:15 -0700 | [diff] [blame] | 705 | char buf[100]; |
| 706 | int pos = 0; |
| 707 | const size_t bufsz = sizeof(buf); |
Wey-Yi Guy | 1e4247d | 2009-07-27 13:50:15 -0700 | [diff] [blame] | 708 | |
| 709 | pos += scnprintf(buf + pos, bufsz - pos, |
| 710 | "11n 40MHz Mode: %s\n", |
| 711 | priv->disable_ht40 ? "Disabled" : "Enabled"); |
Wey-Yi Guy | 4967c31 | 2010-02-18 15:22:07 -0800 | [diff] [blame] | 712 | return simple_read_from_buffer(user_buf, count, ppos, buf, pos); |
Wey-Yi Guy | 1e4247d | 2009-07-27 13:50:15 -0700 | [diff] [blame] | 713 | } |
| 714 | |
Emmanuel Grumbach | 511afa3 | 2011-09-22 07:15:37 -0700 | [diff] [blame] | 715 | static ssize_t iwl_dbgfs_temperature_read(struct file *file, |
| 716 | char __user *user_buf, |
| 717 | size_t count, loff_t *ppos) |
| 718 | { |
| 719 | struct iwl_priv *priv = file->private_data; |
| 720 | char buf[8]; |
| 721 | int pos = 0; |
| 722 | const size_t bufsz = sizeof(buf); |
| 723 | |
| 724 | pos += scnprintf(buf + pos, bufsz - pos, "%d\n", priv->temperature); |
| 725 | return simple_read_from_buffer(user_buf, count, ppos, buf, pos); |
| 726 | } |
| 727 | |
| 728 | |
Johannes Berg | e312c24 | 2009-08-07 15:41:51 -0700 | [diff] [blame] | 729 | static ssize_t iwl_dbgfs_sleep_level_override_write(struct file *file, |
| 730 | const char __user *user_buf, |
| 731 | size_t count, loff_t *ppos) |
| 732 | { |
| 733 | struct iwl_priv *priv = file->private_data; |
| 734 | char buf[8]; |
| 735 | int buf_size; |
| 736 | int value; |
| 737 | |
| 738 | memset(buf, 0, sizeof(buf)); |
| 739 | buf_size = min(count, sizeof(buf) - 1); |
| 740 | if (copy_from_user(buf, user_buf, buf_size)) |
| 741 | return -EFAULT; |
| 742 | |
| 743 | if (sscanf(buf, "%d", &value) != 1) |
| 744 | return -EINVAL; |
| 745 | |
| 746 | /* |
| 747 | * Our users expect 0 to be "CAM", but 0 isn't actually |
| 748 | * valid here. However, let's not confuse them and present |
| 749 | * IWL_POWER_INDEX_1 as "1", not "0". |
| 750 | */ |
Reinette Chatre | 1a34c04 | 2009-10-09 13:20:25 -0700 | [diff] [blame] | 751 | if (value == 0) |
| 752 | return -EINVAL; |
| 753 | else if (value > 0) |
Johannes Berg | e312c24 | 2009-08-07 15:41:51 -0700 | [diff] [blame] | 754 | value -= 1; |
| 755 | |
| 756 | if (value != -1 && (value < 0 || value >= IWL_POWER_NUM)) |
| 757 | return -EINVAL; |
| 758 | |
Emmanuel Grumbach | 845a9c0 | 2011-08-25 23:11:04 -0700 | [diff] [blame] | 759 | if (!iwl_is_ready_rf(priv->shrd)) |
Wey-Yi Guy | 4ad177b | 2009-10-16 14:25:58 -0700 | [diff] [blame] | 760 | return -EAGAIN; |
| 761 | |
Johannes Berg | e312c24 | 2009-08-07 15:41:51 -0700 | [diff] [blame] | 762 | priv->power_data.debug_sleep_level_override = value; |
| 763 | |
Johannes Berg | b1eea29 | 2012-03-06 13:30:42 -0800 | [diff] [blame^] | 764 | mutex_lock(&priv->mutex); |
Wey-Yi Guy | 4ad177b | 2009-10-16 14:25:58 -0700 | [diff] [blame] | 765 | iwl_power_update_mode(priv, true); |
Johannes Berg | b1eea29 | 2012-03-06 13:30:42 -0800 | [diff] [blame^] | 766 | mutex_unlock(&priv->mutex); |
Johannes Berg | e312c24 | 2009-08-07 15:41:51 -0700 | [diff] [blame] | 767 | |
| 768 | return count; |
| 769 | } |
| 770 | |
| 771 | static ssize_t iwl_dbgfs_sleep_level_override_read(struct file *file, |
| 772 | char __user *user_buf, |
| 773 | size_t count, loff_t *ppos) |
| 774 | { |
H Hartley Sweeten | 28f63a4 | 2010-01-08 16:14:10 -0700 | [diff] [blame] | 775 | struct iwl_priv *priv = file->private_data; |
Johannes Berg | e312c24 | 2009-08-07 15:41:51 -0700 | [diff] [blame] | 776 | char buf[10]; |
| 777 | int pos, value; |
| 778 | const size_t bufsz = sizeof(buf); |
| 779 | |
| 780 | /* see the write function */ |
| 781 | value = priv->power_data.debug_sleep_level_override; |
| 782 | if (value >= 0) |
| 783 | value += 1; |
| 784 | |
| 785 | pos = scnprintf(buf, bufsz, "%d\n", value); |
| 786 | return simple_read_from_buffer(user_buf, count, ppos, buf, pos); |
| 787 | } |
| 788 | |
| 789 | static ssize_t iwl_dbgfs_current_sleep_command_read(struct file *file, |
| 790 | char __user *user_buf, |
| 791 | size_t count, loff_t *ppos) |
| 792 | { |
H Hartley Sweeten | 28f63a4 | 2010-01-08 16:14:10 -0700 | [diff] [blame] | 793 | struct iwl_priv *priv = file->private_data; |
Johannes Berg | e312c24 | 2009-08-07 15:41:51 -0700 | [diff] [blame] | 794 | char buf[200]; |
| 795 | int pos = 0, i; |
| 796 | const size_t bufsz = sizeof(buf); |
| 797 | struct iwl_powertable_cmd *cmd = &priv->power_data.sleep_cmd; |
| 798 | |
| 799 | pos += scnprintf(buf + pos, bufsz - pos, |
| 800 | "flags: %#.2x\n", le16_to_cpu(cmd->flags)); |
| 801 | pos += scnprintf(buf + pos, bufsz - pos, |
| 802 | "RX/TX timeout: %d/%d usec\n", |
| 803 | le32_to_cpu(cmd->rx_data_timeout), |
| 804 | le32_to_cpu(cmd->tx_data_timeout)); |
| 805 | for (i = 0; i < IWL_POWER_VEC_SIZE; i++) |
| 806 | pos += scnprintf(buf + pos, bufsz - pos, |
| 807 | "sleep_interval[%d]: %d\n", i, |
| 808 | le32_to_cpu(cmd->sleep_interval[i])); |
| 809 | |
| 810 | return simple_read_from_buffer(user_buf, count, ppos, buf, pos); |
| 811 | } |
| 812 | |
Tomas Winkler | 712b6cf | 2008-03-12 16:58:52 -0700 | [diff] [blame] | 813 | DEBUGFS_READ_WRITE_FILE_OPS(sram); |
Johannes Berg | c8ac61c | 2011-07-15 13:23:45 -0700 | [diff] [blame] | 814 | DEBUGFS_READ_FILE_OPS(wowlan_sram); |
Wey-Yi Guy | 0848e29 | 2009-05-22 11:01:46 -0700 | [diff] [blame] | 815 | DEBUGFS_READ_FILE_OPS(nvm); |
Tomas Winkler | 712b6cf | 2008-03-12 16:58:52 -0700 | [diff] [blame] | 816 | DEBUGFS_READ_FILE_OPS(stations); |
Winkler, Tomas | d366df5 | 2008-12-02 12:14:01 -0800 | [diff] [blame] | 817 | DEBUGFS_READ_FILE_OPS(channels); |
Wey-Yi Guy | 08df05a | 2009-03-24 10:02:54 -0700 | [diff] [blame] | 818 | DEBUGFS_READ_FILE_OPS(status); |
Emmanuel Grumbach | 1f7b617 | 2011-08-25 23:10:59 -0700 | [diff] [blame] | 819 | DEBUGFS_READ_WRITE_FILE_OPS(rx_handlers); |
Wey-Yi Guy | f5ad69f | 2009-07-09 10:33:36 -0700 | [diff] [blame] | 820 | DEBUGFS_READ_FILE_OPS(qos); |
Wey-Yi Guy | fbf3a2a | 2009-07-24 11:13:04 -0700 | [diff] [blame] | 821 | DEBUGFS_READ_FILE_OPS(thermal_throttling); |
Wey-Yi Guy | 1e4247d | 2009-07-27 13:50:15 -0700 | [diff] [blame] | 822 | DEBUGFS_READ_WRITE_FILE_OPS(disable_ht40); |
Emmanuel Grumbach | 511afa3 | 2011-09-22 07:15:37 -0700 | [diff] [blame] | 823 | DEBUGFS_READ_FILE_OPS(temperature); |
Johannes Berg | e312c24 | 2009-08-07 15:41:51 -0700 | [diff] [blame] | 824 | DEBUGFS_READ_WRITE_FILE_OPS(sleep_level_override); |
| 825 | DEBUGFS_READ_FILE_OPS(current_sleep_command); |
Tomas Winkler | 712b6cf | 2008-03-12 16:58:52 -0700 | [diff] [blame] | 826 | |
Emmanuel Grumbach | 41f5e04 | 2011-09-06 09:31:20 -0700 | [diff] [blame] | 827 | static ssize_t iwl_dbgfs_traffic_log_read(struct file *file, |
| 828 | char __user *user_buf, |
| 829 | size_t count, loff_t *ppos) |
| 830 | { |
| 831 | struct iwl_priv *priv = file->private_data; |
| 832 | int pos = 0, ofs = 0; |
| 833 | int cnt = 0, entry; |
| 834 | |
| 835 | char *buf; |
| 836 | int bufsz = ((IWL_TRAFFIC_ENTRIES * IWL_TRAFFIC_ENTRY_SIZE * 64) * 2) + |
| 837 | (hw_params(priv).max_txq_num * 32 * 8) + 400; |
| 838 | const u8 *ptr; |
| 839 | ssize_t ret; |
| 840 | |
| 841 | buf = kzalloc(bufsz, GFP_KERNEL); |
| 842 | if (!buf) { |
| 843 | IWL_ERR(priv, "Can not allocate buffer\n"); |
| 844 | return -ENOMEM; |
| 845 | } |
Johannes Berg | a8bceb3 | 2012-03-05 11:24:30 -0800 | [diff] [blame] | 846 | if (priv->tx_traffic && iwl_have_debug_level(IWL_DL_TX)) { |
Emmanuel Grumbach | 41f5e04 | 2011-09-06 09:31:20 -0700 | [diff] [blame] | 847 | ptr = priv->tx_traffic; |
| 848 | pos += scnprintf(buf + pos, bufsz - pos, |
| 849 | "Tx Traffic idx: %u\n", priv->tx_traffic_idx); |
| 850 | for (cnt = 0, ofs = 0; cnt < IWL_TRAFFIC_ENTRIES; cnt++) { |
| 851 | for (entry = 0; entry < IWL_TRAFFIC_ENTRY_SIZE / 16; |
| 852 | entry++, ofs += 16) { |
| 853 | pos += scnprintf(buf + pos, bufsz - pos, |
| 854 | "0x%.4x ", ofs); |
| 855 | hex_dump_to_buffer(ptr + ofs, 16, 16, 2, |
| 856 | buf + pos, bufsz - pos, 0); |
| 857 | pos += strlen(buf + pos); |
| 858 | if (bufsz - pos > 0) |
| 859 | buf[pos++] = '\n'; |
| 860 | } |
| 861 | } |
| 862 | } |
| 863 | |
Johannes Berg | a8bceb3 | 2012-03-05 11:24:30 -0800 | [diff] [blame] | 864 | if (priv->rx_traffic && iwl_have_debug_level(IWL_DL_RX)) { |
Emmanuel Grumbach | 41f5e04 | 2011-09-06 09:31:20 -0700 | [diff] [blame] | 865 | ptr = priv->rx_traffic; |
| 866 | pos += scnprintf(buf + pos, bufsz - pos, |
| 867 | "Rx Traffic idx: %u\n", priv->rx_traffic_idx); |
| 868 | for (cnt = 0, ofs = 0; cnt < IWL_TRAFFIC_ENTRIES; cnt++) { |
| 869 | for (entry = 0; entry < IWL_TRAFFIC_ENTRY_SIZE / 16; |
| 870 | entry++, ofs += 16) { |
| 871 | pos += scnprintf(buf + pos, bufsz - pos, |
| 872 | "0x%.4x ", ofs); |
| 873 | hex_dump_to_buffer(ptr + ofs, 16, 16, 2, |
| 874 | buf + pos, bufsz - pos, 0); |
| 875 | pos += strlen(buf + pos); |
| 876 | if (bufsz - pos > 0) |
| 877 | buf[pos++] = '\n'; |
| 878 | } |
| 879 | } |
| 880 | } |
| 881 | |
| 882 | ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos); |
| 883 | kfree(buf); |
| 884 | return ret; |
| 885 | } |
| 886 | |
| 887 | static ssize_t iwl_dbgfs_traffic_log_write(struct file *file, |
| 888 | const char __user *user_buf, |
| 889 | size_t count, loff_t *ppos) |
| 890 | { |
| 891 | struct iwl_priv *priv = file->private_data; |
| 892 | char buf[8]; |
| 893 | int buf_size; |
| 894 | int traffic_log; |
| 895 | |
| 896 | memset(buf, 0, sizeof(buf)); |
| 897 | buf_size = min(count, sizeof(buf) - 1); |
| 898 | if (copy_from_user(buf, user_buf, buf_size)) |
| 899 | return -EFAULT; |
| 900 | if (sscanf(buf, "%d", &traffic_log) != 1) |
| 901 | return -EFAULT; |
| 902 | if (traffic_log == 0) |
| 903 | iwl_reset_traffic_log(priv); |
| 904 | |
| 905 | return count; |
| 906 | } |
| 907 | |
Wey-Yi Guy | d6d023a | 2011-04-30 09:10:53 -0700 | [diff] [blame] | 908 | static const char *fmt_value = " %-30s %10u\n"; |
| 909 | static const char *fmt_hex = " %-30s 0x%02X\n"; |
| 910 | static const char *fmt_table = " %-30s %10u %10u %10u %10u\n"; |
| 911 | static const char *fmt_header = |
| 912 | "%-32s current cumulative delta max\n"; |
| 913 | |
| 914 | static int iwl_statistics_flag(struct iwl_priv *priv, char *buf, int bufsz) |
| 915 | { |
| 916 | int p = 0; |
| 917 | u32 flag; |
| 918 | |
Johannes Berg | 4ff70fc | 2012-03-05 11:24:26 -0800 | [diff] [blame] | 919 | lockdep_assert_held(&priv->statistics.lock); |
| 920 | |
Wey-Yi Guy | d6d023a | 2011-04-30 09:10:53 -0700 | [diff] [blame] | 921 | flag = le32_to_cpu(priv->statistics.flag); |
| 922 | |
| 923 | p += scnprintf(buf + p, bufsz - p, "Statistics Flag(0x%X):\n", flag); |
| 924 | if (flag & UCODE_STATISTICS_CLEAR_MSK) |
| 925 | p += scnprintf(buf + p, bufsz - p, |
| 926 | "\tStatistics have been cleared\n"); |
| 927 | p += scnprintf(buf + p, bufsz - p, "\tOperational Frequency: %s\n", |
| 928 | (flag & UCODE_STATISTICS_FREQUENCY_MSK) |
| 929 | ? "2.4 GHz" : "5.2 GHz"); |
| 930 | p += scnprintf(buf + p, bufsz - p, "\tTGj Narrow Band: %s\n", |
| 931 | (flag & UCODE_STATISTICS_NARROW_BAND_MSK) |
| 932 | ? "enabled" : "disabled"); |
| 933 | |
| 934 | return p; |
| 935 | } |
| 936 | |
Wey-Yi Guy | e8fe59a | 2009-08-07 15:41:42 -0700 | [diff] [blame] | 937 | static ssize_t iwl_dbgfs_ucode_rx_stats_read(struct file *file, |
| 938 | char __user *user_buf, |
| 939 | size_t count, loff_t *ppos) |
| 940 | { |
H Hartley Sweeten | 28f63a4 | 2010-01-08 16:14:10 -0700 | [diff] [blame] | 941 | struct iwl_priv *priv = file->private_data; |
Wey-Yi Guy | d6d023a | 2011-04-30 09:10:53 -0700 | [diff] [blame] | 942 | int pos = 0; |
| 943 | char *buf; |
| 944 | int bufsz = sizeof(struct statistics_rx_phy) * 40 + |
| 945 | sizeof(struct statistics_rx_non_phy) * 40 + |
| 946 | sizeof(struct statistics_rx_ht_phy) * 40 + 400; |
| 947 | ssize_t ret; |
| 948 | struct statistics_rx_phy *ofdm, *accum_ofdm, *delta_ofdm, *max_ofdm; |
| 949 | struct statistics_rx_phy *cck, *accum_cck, *delta_cck, *max_cck; |
| 950 | struct statistics_rx_non_phy *general, *accum_general; |
| 951 | struct statistics_rx_non_phy *delta_general, *max_general; |
| 952 | struct statistics_rx_ht_phy *ht, *accum_ht, *delta_ht, *max_ht; |
| 953 | |
Emmanuel Grumbach | 845a9c0 | 2011-08-25 23:11:04 -0700 | [diff] [blame] | 954 | if (!iwl_is_alive(priv->shrd)) |
Wey-Yi Guy | d6d023a | 2011-04-30 09:10:53 -0700 | [diff] [blame] | 955 | return -EAGAIN; |
| 956 | |
| 957 | buf = kzalloc(bufsz, GFP_KERNEL); |
| 958 | if (!buf) { |
| 959 | IWL_ERR(priv, "Can not allocate Buffer\n"); |
| 960 | return -ENOMEM; |
| 961 | } |
| 962 | |
| 963 | /* |
| 964 | * the statistic information display here is based on |
| 965 | * the last statistics notification from uCode |
| 966 | * might not reflect the current uCode activity |
| 967 | */ |
Johannes Berg | 4ff70fc | 2012-03-05 11:24:26 -0800 | [diff] [blame] | 968 | spin_lock_bh(&priv->statistics.lock); |
Wey-Yi Guy | d6d023a | 2011-04-30 09:10:53 -0700 | [diff] [blame] | 969 | ofdm = &priv->statistics.rx_ofdm; |
| 970 | cck = &priv->statistics.rx_cck; |
| 971 | general = &priv->statistics.rx_non_phy; |
| 972 | ht = &priv->statistics.rx_ofdm_ht; |
| 973 | accum_ofdm = &priv->accum_stats.rx_ofdm; |
| 974 | accum_cck = &priv->accum_stats.rx_cck; |
| 975 | accum_general = &priv->accum_stats.rx_non_phy; |
| 976 | accum_ht = &priv->accum_stats.rx_ofdm_ht; |
| 977 | delta_ofdm = &priv->delta_stats.rx_ofdm; |
| 978 | delta_cck = &priv->delta_stats.rx_cck; |
| 979 | delta_general = &priv->delta_stats.rx_non_phy; |
| 980 | delta_ht = &priv->delta_stats.rx_ofdm_ht; |
| 981 | max_ofdm = &priv->max_delta_stats.rx_ofdm; |
| 982 | max_cck = &priv->max_delta_stats.rx_cck; |
| 983 | max_general = &priv->max_delta_stats.rx_non_phy; |
| 984 | max_ht = &priv->max_delta_stats.rx_ofdm_ht; |
| 985 | |
| 986 | pos += iwl_statistics_flag(priv, buf, bufsz); |
| 987 | pos += scnprintf(buf + pos, bufsz - pos, |
| 988 | fmt_header, "Statistics_Rx - OFDM:"); |
| 989 | pos += scnprintf(buf + pos, bufsz - pos, |
| 990 | fmt_table, "ina_cnt:", |
| 991 | le32_to_cpu(ofdm->ina_cnt), |
| 992 | accum_ofdm->ina_cnt, |
| 993 | delta_ofdm->ina_cnt, max_ofdm->ina_cnt); |
| 994 | pos += scnprintf(buf + pos, bufsz - pos, |
| 995 | fmt_table, "fina_cnt:", |
| 996 | le32_to_cpu(ofdm->fina_cnt), accum_ofdm->fina_cnt, |
| 997 | delta_ofdm->fina_cnt, max_ofdm->fina_cnt); |
| 998 | pos += scnprintf(buf + pos, bufsz - pos, |
| 999 | fmt_table, "plcp_err:", |
| 1000 | le32_to_cpu(ofdm->plcp_err), accum_ofdm->plcp_err, |
| 1001 | delta_ofdm->plcp_err, max_ofdm->plcp_err); |
| 1002 | pos += scnprintf(buf + pos, bufsz - pos, |
| 1003 | fmt_table, "crc32_err:", |
| 1004 | le32_to_cpu(ofdm->crc32_err), accum_ofdm->crc32_err, |
| 1005 | delta_ofdm->crc32_err, max_ofdm->crc32_err); |
| 1006 | pos += scnprintf(buf + pos, bufsz - pos, |
| 1007 | fmt_table, "overrun_err:", |
| 1008 | le32_to_cpu(ofdm->overrun_err), |
| 1009 | accum_ofdm->overrun_err, delta_ofdm->overrun_err, |
| 1010 | max_ofdm->overrun_err); |
| 1011 | pos += scnprintf(buf + pos, bufsz - pos, |
| 1012 | fmt_table, "early_overrun_err:", |
| 1013 | le32_to_cpu(ofdm->early_overrun_err), |
| 1014 | accum_ofdm->early_overrun_err, |
| 1015 | delta_ofdm->early_overrun_err, |
| 1016 | max_ofdm->early_overrun_err); |
| 1017 | pos += scnprintf(buf + pos, bufsz - pos, |
| 1018 | fmt_table, "crc32_good:", |
| 1019 | le32_to_cpu(ofdm->crc32_good), |
| 1020 | accum_ofdm->crc32_good, delta_ofdm->crc32_good, |
| 1021 | max_ofdm->crc32_good); |
| 1022 | pos += scnprintf(buf + pos, bufsz - pos, |
| 1023 | fmt_table, "false_alarm_cnt:", |
| 1024 | le32_to_cpu(ofdm->false_alarm_cnt), |
| 1025 | accum_ofdm->false_alarm_cnt, |
| 1026 | delta_ofdm->false_alarm_cnt, |
| 1027 | max_ofdm->false_alarm_cnt); |
| 1028 | pos += scnprintf(buf + pos, bufsz - pos, |
| 1029 | fmt_table, "fina_sync_err_cnt:", |
| 1030 | le32_to_cpu(ofdm->fina_sync_err_cnt), |
| 1031 | accum_ofdm->fina_sync_err_cnt, |
| 1032 | delta_ofdm->fina_sync_err_cnt, |
| 1033 | max_ofdm->fina_sync_err_cnt); |
| 1034 | pos += scnprintf(buf + pos, bufsz - pos, |
| 1035 | fmt_table, "sfd_timeout:", |
| 1036 | le32_to_cpu(ofdm->sfd_timeout), |
| 1037 | accum_ofdm->sfd_timeout, delta_ofdm->sfd_timeout, |
| 1038 | max_ofdm->sfd_timeout); |
| 1039 | pos += scnprintf(buf + pos, bufsz - pos, |
| 1040 | fmt_table, "fina_timeout:", |
| 1041 | le32_to_cpu(ofdm->fina_timeout), |
| 1042 | accum_ofdm->fina_timeout, delta_ofdm->fina_timeout, |
| 1043 | max_ofdm->fina_timeout); |
| 1044 | pos += scnprintf(buf + pos, bufsz - pos, |
| 1045 | fmt_table, "unresponded_rts:", |
| 1046 | le32_to_cpu(ofdm->unresponded_rts), |
| 1047 | accum_ofdm->unresponded_rts, |
| 1048 | delta_ofdm->unresponded_rts, |
| 1049 | max_ofdm->unresponded_rts); |
| 1050 | pos += scnprintf(buf + pos, bufsz - pos, |
| 1051 | fmt_table, "rxe_frame_lmt_ovrun:", |
| 1052 | le32_to_cpu(ofdm->rxe_frame_limit_overrun), |
| 1053 | accum_ofdm->rxe_frame_limit_overrun, |
| 1054 | delta_ofdm->rxe_frame_limit_overrun, |
| 1055 | max_ofdm->rxe_frame_limit_overrun); |
| 1056 | pos += scnprintf(buf + pos, bufsz - pos, |
| 1057 | fmt_table, "sent_ack_cnt:", |
| 1058 | le32_to_cpu(ofdm->sent_ack_cnt), |
| 1059 | accum_ofdm->sent_ack_cnt, delta_ofdm->sent_ack_cnt, |
| 1060 | max_ofdm->sent_ack_cnt); |
| 1061 | pos += scnprintf(buf + pos, bufsz - pos, |
| 1062 | fmt_table, "sent_cts_cnt:", |
| 1063 | le32_to_cpu(ofdm->sent_cts_cnt), |
| 1064 | accum_ofdm->sent_cts_cnt, delta_ofdm->sent_cts_cnt, |
| 1065 | max_ofdm->sent_cts_cnt); |
| 1066 | pos += scnprintf(buf + pos, bufsz - pos, |
| 1067 | fmt_table, "sent_ba_rsp_cnt:", |
| 1068 | le32_to_cpu(ofdm->sent_ba_rsp_cnt), |
| 1069 | accum_ofdm->sent_ba_rsp_cnt, |
| 1070 | delta_ofdm->sent_ba_rsp_cnt, |
| 1071 | max_ofdm->sent_ba_rsp_cnt); |
| 1072 | pos += scnprintf(buf + pos, bufsz - pos, |
| 1073 | fmt_table, "dsp_self_kill:", |
| 1074 | le32_to_cpu(ofdm->dsp_self_kill), |
| 1075 | accum_ofdm->dsp_self_kill, |
| 1076 | delta_ofdm->dsp_self_kill, |
| 1077 | max_ofdm->dsp_self_kill); |
| 1078 | pos += scnprintf(buf + pos, bufsz - pos, |
| 1079 | fmt_table, "mh_format_err:", |
| 1080 | le32_to_cpu(ofdm->mh_format_err), |
| 1081 | accum_ofdm->mh_format_err, |
| 1082 | delta_ofdm->mh_format_err, |
| 1083 | max_ofdm->mh_format_err); |
| 1084 | pos += scnprintf(buf + pos, bufsz - pos, |
| 1085 | fmt_table, "re_acq_main_rssi_sum:", |
| 1086 | le32_to_cpu(ofdm->re_acq_main_rssi_sum), |
| 1087 | accum_ofdm->re_acq_main_rssi_sum, |
| 1088 | delta_ofdm->re_acq_main_rssi_sum, |
| 1089 | max_ofdm->re_acq_main_rssi_sum); |
| 1090 | |
| 1091 | pos += scnprintf(buf + pos, bufsz - pos, |
| 1092 | fmt_header, "Statistics_Rx - CCK:"); |
| 1093 | pos += scnprintf(buf + pos, bufsz - pos, |
| 1094 | fmt_table, "ina_cnt:", |
| 1095 | le32_to_cpu(cck->ina_cnt), accum_cck->ina_cnt, |
| 1096 | delta_cck->ina_cnt, max_cck->ina_cnt); |
| 1097 | pos += scnprintf(buf + pos, bufsz - pos, |
| 1098 | fmt_table, "fina_cnt:", |
| 1099 | le32_to_cpu(cck->fina_cnt), accum_cck->fina_cnt, |
| 1100 | delta_cck->fina_cnt, max_cck->fina_cnt); |
| 1101 | pos += scnprintf(buf + pos, bufsz - pos, |
| 1102 | fmt_table, "plcp_err:", |
| 1103 | le32_to_cpu(cck->plcp_err), accum_cck->plcp_err, |
| 1104 | delta_cck->plcp_err, max_cck->plcp_err); |
| 1105 | pos += scnprintf(buf + pos, bufsz - pos, |
| 1106 | fmt_table, "crc32_err:", |
| 1107 | le32_to_cpu(cck->crc32_err), accum_cck->crc32_err, |
| 1108 | delta_cck->crc32_err, max_cck->crc32_err); |
| 1109 | pos += scnprintf(buf + pos, bufsz - pos, |
| 1110 | fmt_table, "overrun_err:", |
| 1111 | le32_to_cpu(cck->overrun_err), |
| 1112 | accum_cck->overrun_err, delta_cck->overrun_err, |
| 1113 | max_cck->overrun_err); |
| 1114 | pos += scnprintf(buf + pos, bufsz - pos, |
| 1115 | fmt_table, "early_overrun_err:", |
| 1116 | le32_to_cpu(cck->early_overrun_err), |
| 1117 | accum_cck->early_overrun_err, |
| 1118 | delta_cck->early_overrun_err, |
| 1119 | max_cck->early_overrun_err); |
| 1120 | pos += scnprintf(buf + pos, bufsz - pos, |
| 1121 | fmt_table, "crc32_good:", |
| 1122 | le32_to_cpu(cck->crc32_good), accum_cck->crc32_good, |
| 1123 | delta_cck->crc32_good, max_cck->crc32_good); |
| 1124 | pos += scnprintf(buf + pos, bufsz - pos, |
| 1125 | fmt_table, "false_alarm_cnt:", |
| 1126 | le32_to_cpu(cck->false_alarm_cnt), |
| 1127 | accum_cck->false_alarm_cnt, |
| 1128 | delta_cck->false_alarm_cnt, max_cck->false_alarm_cnt); |
| 1129 | pos += scnprintf(buf + pos, bufsz - pos, |
| 1130 | fmt_table, "fina_sync_err_cnt:", |
| 1131 | le32_to_cpu(cck->fina_sync_err_cnt), |
| 1132 | accum_cck->fina_sync_err_cnt, |
| 1133 | delta_cck->fina_sync_err_cnt, |
| 1134 | max_cck->fina_sync_err_cnt); |
| 1135 | pos += scnprintf(buf + pos, bufsz - pos, |
| 1136 | fmt_table, "sfd_timeout:", |
| 1137 | le32_to_cpu(cck->sfd_timeout), |
| 1138 | accum_cck->sfd_timeout, delta_cck->sfd_timeout, |
| 1139 | max_cck->sfd_timeout); |
| 1140 | pos += scnprintf(buf + pos, bufsz - pos, |
| 1141 | fmt_table, "fina_timeout:", |
| 1142 | le32_to_cpu(cck->fina_timeout), |
| 1143 | accum_cck->fina_timeout, delta_cck->fina_timeout, |
| 1144 | max_cck->fina_timeout); |
| 1145 | pos += scnprintf(buf + pos, bufsz - pos, |
| 1146 | fmt_table, "unresponded_rts:", |
| 1147 | le32_to_cpu(cck->unresponded_rts), |
| 1148 | accum_cck->unresponded_rts, delta_cck->unresponded_rts, |
| 1149 | max_cck->unresponded_rts); |
| 1150 | pos += scnprintf(buf + pos, bufsz - pos, |
| 1151 | fmt_table, "rxe_frame_lmt_ovrun:", |
| 1152 | le32_to_cpu(cck->rxe_frame_limit_overrun), |
| 1153 | accum_cck->rxe_frame_limit_overrun, |
| 1154 | delta_cck->rxe_frame_limit_overrun, |
| 1155 | max_cck->rxe_frame_limit_overrun); |
| 1156 | pos += scnprintf(buf + pos, bufsz - pos, |
| 1157 | fmt_table, "sent_ack_cnt:", |
| 1158 | le32_to_cpu(cck->sent_ack_cnt), |
| 1159 | accum_cck->sent_ack_cnt, delta_cck->sent_ack_cnt, |
| 1160 | max_cck->sent_ack_cnt); |
| 1161 | pos += scnprintf(buf + pos, bufsz - pos, |
| 1162 | fmt_table, "sent_cts_cnt:", |
| 1163 | le32_to_cpu(cck->sent_cts_cnt), |
| 1164 | accum_cck->sent_cts_cnt, delta_cck->sent_cts_cnt, |
| 1165 | max_cck->sent_cts_cnt); |
| 1166 | pos += scnprintf(buf + pos, bufsz - pos, |
| 1167 | fmt_table, "sent_ba_rsp_cnt:", |
| 1168 | le32_to_cpu(cck->sent_ba_rsp_cnt), |
| 1169 | accum_cck->sent_ba_rsp_cnt, |
| 1170 | delta_cck->sent_ba_rsp_cnt, |
| 1171 | max_cck->sent_ba_rsp_cnt); |
| 1172 | pos += scnprintf(buf + pos, bufsz - pos, |
| 1173 | fmt_table, "dsp_self_kill:", |
| 1174 | le32_to_cpu(cck->dsp_self_kill), |
| 1175 | accum_cck->dsp_self_kill, delta_cck->dsp_self_kill, |
| 1176 | max_cck->dsp_self_kill); |
| 1177 | pos += scnprintf(buf + pos, bufsz - pos, |
| 1178 | fmt_table, "mh_format_err:", |
| 1179 | le32_to_cpu(cck->mh_format_err), |
| 1180 | accum_cck->mh_format_err, delta_cck->mh_format_err, |
| 1181 | max_cck->mh_format_err); |
| 1182 | pos += scnprintf(buf + pos, bufsz - pos, |
| 1183 | fmt_table, "re_acq_main_rssi_sum:", |
| 1184 | le32_to_cpu(cck->re_acq_main_rssi_sum), |
| 1185 | accum_cck->re_acq_main_rssi_sum, |
| 1186 | delta_cck->re_acq_main_rssi_sum, |
| 1187 | max_cck->re_acq_main_rssi_sum); |
| 1188 | |
| 1189 | pos += scnprintf(buf + pos, bufsz - pos, |
| 1190 | fmt_header, "Statistics_Rx - GENERAL:"); |
| 1191 | pos += scnprintf(buf + pos, bufsz - pos, |
| 1192 | fmt_table, "bogus_cts:", |
| 1193 | le32_to_cpu(general->bogus_cts), |
| 1194 | accum_general->bogus_cts, delta_general->bogus_cts, |
| 1195 | max_general->bogus_cts); |
| 1196 | pos += scnprintf(buf + pos, bufsz - pos, |
| 1197 | fmt_table, "bogus_ack:", |
| 1198 | le32_to_cpu(general->bogus_ack), |
| 1199 | accum_general->bogus_ack, delta_general->bogus_ack, |
| 1200 | max_general->bogus_ack); |
| 1201 | pos += scnprintf(buf + pos, bufsz - pos, |
| 1202 | fmt_table, "non_bssid_frames:", |
| 1203 | le32_to_cpu(general->non_bssid_frames), |
| 1204 | accum_general->non_bssid_frames, |
| 1205 | delta_general->non_bssid_frames, |
| 1206 | max_general->non_bssid_frames); |
| 1207 | pos += scnprintf(buf + pos, bufsz - pos, |
| 1208 | fmt_table, "filtered_frames:", |
| 1209 | le32_to_cpu(general->filtered_frames), |
| 1210 | accum_general->filtered_frames, |
| 1211 | delta_general->filtered_frames, |
| 1212 | max_general->filtered_frames); |
| 1213 | pos += scnprintf(buf + pos, bufsz - pos, |
| 1214 | fmt_table, "non_channel_beacons:", |
| 1215 | le32_to_cpu(general->non_channel_beacons), |
| 1216 | accum_general->non_channel_beacons, |
| 1217 | delta_general->non_channel_beacons, |
| 1218 | max_general->non_channel_beacons); |
| 1219 | pos += scnprintf(buf + pos, bufsz - pos, |
| 1220 | fmt_table, "channel_beacons:", |
| 1221 | le32_to_cpu(general->channel_beacons), |
| 1222 | accum_general->channel_beacons, |
| 1223 | delta_general->channel_beacons, |
| 1224 | max_general->channel_beacons); |
| 1225 | pos += scnprintf(buf + pos, bufsz - pos, |
| 1226 | fmt_table, "num_missed_bcon:", |
| 1227 | le32_to_cpu(general->num_missed_bcon), |
| 1228 | accum_general->num_missed_bcon, |
| 1229 | delta_general->num_missed_bcon, |
| 1230 | max_general->num_missed_bcon); |
| 1231 | pos += scnprintf(buf + pos, bufsz - pos, |
| 1232 | fmt_table, "adc_rx_saturation_time:", |
| 1233 | le32_to_cpu(general->adc_rx_saturation_time), |
| 1234 | accum_general->adc_rx_saturation_time, |
| 1235 | delta_general->adc_rx_saturation_time, |
| 1236 | max_general->adc_rx_saturation_time); |
| 1237 | pos += scnprintf(buf + pos, bufsz - pos, |
| 1238 | fmt_table, "ina_detect_search_tm:", |
| 1239 | le32_to_cpu(general->ina_detection_search_time), |
| 1240 | accum_general->ina_detection_search_time, |
| 1241 | delta_general->ina_detection_search_time, |
| 1242 | max_general->ina_detection_search_time); |
| 1243 | pos += scnprintf(buf + pos, bufsz - pos, |
| 1244 | fmt_table, "beacon_silence_rssi_a:", |
| 1245 | le32_to_cpu(general->beacon_silence_rssi_a), |
| 1246 | accum_general->beacon_silence_rssi_a, |
| 1247 | delta_general->beacon_silence_rssi_a, |
| 1248 | max_general->beacon_silence_rssi_a); |
| 1249 | pos += scnprintf(buf + pos, bufsz - pos, |
| 1250 | fmt_table, "beacon_silence_rssi_b:", |
| 1251 | le32_to_cpu(general->beacon_silence_rssi_b), |
| 1252 | accum_general->beacon_silence_rssi_b, |
| 1253 | delta_general->beacon_silence_rssi_b, |
| 1254 | max_general->beacon_silence_rssi_b); |
| 1255 | pos += scnprintf(buf + pos, bufsz - pos, |
| 1256 | fmt_table, "beacon_silence_rssi_c:", |
| 1257 | le32_to_cpu(general->beacon_silence_rssi_c), |
| 1258 | accum_general->beacon_silence_rssi_c, |
| 1259 | delta_general->beacon_silence_rssi_c, |
| 1260 | max_general->beacon_silence_rssi_c); |
| 1261 | pos += scnprintf(buf + pos, bufsz - pos, |
| 1262 | fmt_table, "interference_data_flag:", |
| 1263 | le32_to_cpu(general->interference_data_flag), |
| 1264 | accum_general->interference_data_flag, |
| 1265 | delta_general->interference_data_flag, |
| 1266 | max_general->interference_data_flag); |
| 1267 | pos += scnprintf(buf + pos, bufsz - pos, |
| 1268 | fmt_table, "channel_load:", |
| 1269 | le32_to_cpu(general->channel_load), |
| 1270 | accum_general->channel_load, |
| 1271 | delta_general->channel_load, |
| 1272 | max_general->channel_load); |
| 1273 | pos += scnprintf(buf + pos, bufsz - pos, |
| 1274 | fmt_table, "dsp_false_alarms:", |
| 1275 | le32_to_cpu(general->dsp_false_alarms), |
| 1276 | accum_general->dsp_false_alarms, |
| 1277 | delta_general->dsp_false_alarms, |
| 1278 | max_general->dsp_false_alarms); |
| 1279 | pos += scnprintf(buf + pos, bufsz - pos, |
| 1280 | fmt_table, "beacon_rssi_a:", |
| 1281 | le32_to_cpu(general->beacon_rssi_a), |
| 1282 | accum_general->beacon_rssi_a, |
| 1283 | delta_general->beacon_rssi_a, |
| 1284 | max_general->beacon_rssi_a); |
| 1285 | pos += scnprintf(buf + pos, bufsz - pos, |
| 1286 | fmt_table, "beacon_rssi_b:", |
| 1287 | le32_to_cpu(general->beacon_rssi_b), |
| 1288 | accum_general->beacon_rssi_b, |
| 1289 | delta_general->beacon_rssi_b, |
| 1290 | max_general->beacon_rssi_b); |
| 1291 | pos += scnprintf(buf + pos, bufsz - pos, |
| 1292 | fmt_table, "beacon_rssi_c:", |
| 1293 | le32_to_cpu(general->beacon_rssi_c), |
| 1294 | accum_general->beacon_rssi_c, |
| 1295 | delta_general->beacon_rssi_c, |
| 1296 | max_general->beacon_rssi_c); |
| 1297 | pos += scnprintf(buf + pos, bufsz - pos, |
| 1298 | fmt_table, "beacon_energy_a:", |
| 1299 | le32_to_cpu(general->beacon_energy_a), |
| 1300 | accum_general->beacon_energy_a, |
| 1301 | delta_general->beacon_energy_a, |
| 1302 | max_general->beacon_energy_a); |
| 1303 | pos += scnprintf(buf + pos, bufsz - pos, |
| 1304 | fmt_table, "beacon_energy_b:", |
| 1305 | le32_to_cpu(general->beacon_energy_b), |
| 1306 | accum_general->beacon_energy_b, |
| 1307 | delta_general->beacon_energy_b, |
| 1308 | max_general->beacon_energy_b); |
| 1309 | pos += scnprintf(buf + pos, bufsz - pos, |
| 1310 | fmt_table, "beacon_energy_c:", |
| 1311 | le32_to_cpu(general->beacon_energy_c), |
| 1312 | accum_general->beacon_energy_c, |
| 1313 | delta_general->beacon_energy_c, |
| 1314 | max_general->beacon_energy_c); |
| 1315 | |
| 1316 | pos += scnprintf(buf + pos, bufsz - pos, |
| 1317 | fmt_header, "Statistics_Rx - OFDM_HT:"); |
| 1318 | pos += scnprintf(buf + pos, bufsz - pos, |
| 1319 | fmt_table, "plcp_err:", |
| 1320 | le32_to_cpu(ht->plcp_err), accum_ht->plcp_err, |
| 1321 | delta_ht->plcp_err, max_ht->plcp_err); |
| 1322 | pos += scnprintf(buf + pos, bufsz - pos, |
| 1323 | fmt_table, "overrun_err:", |
| 1324 | le32_to_cpu(ht->overrun_err), accum_ht->overrun_err, |
| 1325 | delta_ht->overrun_err, max_ht->overrun_err); |
| 1326 | pos += scnprintf(buf + pos, bufsz - pos, |
| 1327 | fmt_table, "early_overrun_err:", |
| 1328 | le32_to_cpu(ht->early_overrun_err), |
| 1329 | accum_ht->early_overrun_err, |
| 1330 | delta_ht->early_overrun_err, |
| 1331 | max_ht->early_overrun_err); |
| 1332 | pos += scnprintf(buf + pos, bufsz - pos, |
| 1333 | fmt_table, "crc32_good:", |
| 1334 | le32_to_cpu(ht->crc32_good), accum_ht->crc32_good, |
| 1335 | delta_ht->crc32_good, max_ht->crc32_good); |
| 1336 | pos += scnprintf(buf + pos, bufsz - pos, |
| 1337 | fmt_table, "crc32_err:", |
| 1338 | le32_to_cpu(ht->crc32_err), accum_ht->crc32_err, |
| 1339 | delta_ht->crc32_err, max_ht->crc32_err); |
| 1340 | pos += scnprintf(buf + pos, bufsz - pos, |
| 1341 | fmt_table, "mh_format_err:", |
| 1342 | le32_to_cpu(ht->mh_format_err), |
| 1343 | accum_ht->mh_format_err, |
| 1344 | delta_ht->mh_format_err, max_ht->mh_format_err); |
| 1345 | pos += scnprintf(buf + pos, bufsz - pos, |
| 1346 | fmt_table, "agg_crc32_good:", |
| 1347 | le32_to_cpu(ht->agg_crc32_good), |
| 1348 | accum_ht->agg_crc32_good, |
| 1349 | delta_ht->agg_crc32_good, max_ht->agg_crc32_good); |
| 1350 | pos += scnprintf(buf + pos, bufsz - pos, |
| 1351 | fmt_table, "agg_mpdu_cnt:", |
| 1352 | le32_to_cpu(ht->agg_mpdu_cnt), |
| 1353 | accum_ht->agg_mpdu_cnt, |
| 1354 | delta_ht->agg_mpdu_cnt, max_ht->agg_mpdu_cnt); |
| 1355 | pos += scnprintf(buf + pos, bufsz - pos, |
| 1356 | fmt_table, "agg_cnt:", |
| 1357 | le32_to_cpu(ht->agg_cnt), accum_ht->agg_cnt, |
| 1358 | delta_ht->agg_cnt, max_ht->agg_cnt); |
| 1359 | pos += scnprintf(buf + pos, bufsz - pos, |
| 1360 | fmt_table, "unsupport_mcs:", |
| 1361 | le32_to_cpu(ht->unsupport_mcs), |
| 1362 | accum_ht->unsupport_mcs, |
| 1363 | delta_ht->unsupport_mcs, max_ht->unsupport_mcs); |
| 1364 | |
Johannes Berg | 4ff70fc | 2012-03-05 11:24:26 -0800 | [diff] [blame] | 1365 | spin_unlock_bh(&priv->statistics.lock); |
| 1366 | |
Wey-Yi Guy | d6d023a | 2011-04-30 09:10:53 -0700 | [diff] [blame] | 1367 | ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos); |
| 1368 | kfree(buf); |
| 1369 | return ret; |
Wey-Yi Guy | e8fe59a | 2009-08-07 15:41:42 -0700 | [diff] [blame] | 1370 | } |
| 1371 | |
| 1372 | static ssize_t iwl_dbgfs_ucode_tx_stats_read(struct file *file, |
| 1373 | char __user *user_buf, |
| 1374 | size_t count, loff_t *ppos) |
| 1375 | { |
H Hartley Sweeten | 28f63a4 | 2010-01-08 16:14:10 -0700 | [diff] [blame] | 1376 | struct iwl_priv *priv = file->private_data; |
Wey-Yi Guy | d6d023a | 2011-04-30 09:10:53 -0700 | [diff] [blame] | 1377 | int pos = 0; |
| 1378 | char *buf; |
| 1379 | int bufsz = (sizeof(struct statistics_tx) * 48) + 250; |
| 1380 | ssize_t ret; |
| 1381 | struct statistics_tx *tx, *accum_tx, *delta_tx, *max_tx; |
| 1382 | |
Emmanuel Grumbach | 845a9c0 | 2011-08-25 23:11:04 -0700 | [diff] [blame] | 1383 | if (!iwl_is_alive(priv->shrd)) |
Wey-Yi Guy | d6d023a | 2011-04-30 09:10:53 -0700 | [diff] [blame] | 1384 | return -EAGAIN; |
| 1385 | |
| 1386 | buf = kzalloc(bufsz, GFP_KERNEL); |
| 1387 | if (!buf) { |
| 1388 | IWL_ERR(priv, "Can not allocate Buffer\n"); |
| 1389 | return -ENOMEM; |
| 1390 | } |
| 1391 | |
| 1392 | /* the statistic information display here is based on |
| 1393 | * the last statistics notification from uCode |
| 1394 | * might not reflect the current uCode activity |
| 1395 | */ |
Johannes Berg | 4ff70fc | 2012-03-05 11:24:26 -0800 | [diff] [blame] | 1396 | spin_lock_bh(&priv->statistics.lock); |
| 1397 | |
Wey-Yi Guy | d6d023a | 2011-04-30 09:10:53 -0700 | [diff] [blame] | 1398 | tx = &priv->statistics.tx; |
| 1399 | accum_tx = &priv->accum_stats.tx; |
| 1400 | delta_tx = &priv->delta_stats.tx; |
| 1401 | max_tx = &priv->max_delta_stats.tx; |
| 1402 | |
| 1403 | pos += iwl_statistics_flag(priv, buf, bufsz); |
| 1404 | pos += scnprintf(buf + pos, bufsz - pos, |
| 1405 | fmt_header, "Statistics_Tx:"); |
| 1406 | pos += scnprintf(buf + pos, bufsz - pos, |
| 1407 | fmt_table, "preamble:", |
| 1408 | le32_to_cpu(tx->preamble_cnt), |
| 1409 | accum_tx->preamble_cnt, |
| 1410 | delta_tx->preamble_cnt, max_tx->preamble_cnt); |
| 1411 | pos += scnprintf(buf + pos, bufsz - pos, |
| 1412 | fmt_table, "rx_detected_cnt:", |
| 1413 | le32_to_cpu(tx->rx_detected_cnt), |
| 1414 | accum_tx->rx_detected_cnt, |
| 1415 | delta_tx->rx_detected_cnt, max_tx->rx_detected_cnt); |
| 1416 | pos += scnprintf(buf + pos, bufsz - pos, |
| 1417 | fmt_table, "bt_prio_defer_cnt:", |
| 1418 | le32_to_cpu(tx->bt_prio_defer_cnt), |
| 1419 | accum_tx->bt_prio_defer_cnt, |
| 1420 | delta_tx->bt_prio_defer_cnt, |
| 1421 | max_tx->bt_prio_defer_cnt); |
| 1422 | pos += scnprintf(buf + pos, bufsz - pos, |
| 1423 | fmt_table, "bt_prio_kill_cnt:", |
| 1424 | le32_to_cpu(tx->bt_prio_kill_cnt), |
| 1425 | accum_tx->bt_prio_kill_cnt, |
| 1426 | delta_tx->bt_prio_kill_cnt, |
| 1427 | max_tx->bt_prio_kill_cnt); |
| 1428 | pos += scnprintf(buf + pos, bufsz - pos, |
| 1429 | fmt_table, "few_bytes_cnt:", |
| 1430 | le32_to_cpu(tx->few_bytes_cnt), |
| 1431 | accum_tx->few_bytes_cnt, |
| 1432 | delta_tx->few_bytes_cnt, max_tx->few_bytes_cnt); |
| 1433 | pos += scnprintf(buf + pos, bufsz - pos, |
| 1434 | fmt_table, "cts_timeout:", |
| 1435 | le32_to_cpu(tx->cts_timeout), accum_tx->cts_timeout, |
| 1436 | delta_tx->cts_timeout, max_tx->cts_timeout); |
| 1437 | pos += scnprintf(buf + pos, bufsz - pos, |
| 1438 | fmt_table, "ack_timeout:", |
| 1439 | le32_to_cpu(tx->ack_timeout), |
| 1440 | accum_tx->ack_timeout, |
| 1441 | delta_tx->ack_timeout, max_tx->ack_timeout); |
| 1442 | pos += scnprintf(buf + pos, bufsz - pos, |
| 1443 | fmt_table, "expected_ack_cnt:", |
| 1444 | le32_to_cpu(tx->expected_ack_cnt), |
| 1445 | accum_tx->expected_ack_cnt, |
| 1446 | delta_tx->expected_ack_cnt, |
| 1447 | max_tx->expected_ack_cnt); |
| 1448 | pos += scnprintf(buf + pos, bufsz - pos, |
| 1449 | fmt_table, "actual_ack_cnt:", |
| 1450 | le32_to_cpu(tx->actual_ack_cnt), |
| 1451 | accum_tx->actual_ack_cnt, |
| 1452 | delta_tx->actual_ack_cnt, |
| 1453 | max_tx->actual_ack_cnt); |
| 1454 | pos += scnprintf(buf + pos, bufsz - pos, |
| 1455 | fmt_table, "dump_msdu_cnt:", |
| 1456 | le32_to_cpu(tx->dump_msdu_cnt), |
| 1457 | accum_tx->dump_msdu_cnt, |
| 1458 | delta_tx->dump_msdu_cnt, |
| 1459 | max_tx->dump_msdu_cnt); |
| 1460 | pos += scnprintf(buf + pos, bufsz - pos, |
| 1461 | fmt_table, "abort_nxt_frame_mismatch:", |
| 1462 | le32_to_cpu(tx->burst_abort_next_frame_mismatch_cnt), |
| 1463 | accum_tx->burst_abort_next_frame_mismatch_cnt, |
| 1464 | delta_tx->burst_abort_next_frame_mismatch_cnt, |
| 1465 | max_tx->burst_abort_next_frame_mismatch_cnt); |
| 1466 | pos += scnprintf(buf + pos, bufsz - pos, |
| 1467 | fmt_table, "abort_missing_nxt_frame:", |
| 1468 | le32_to_cpu(tx->burst_abort_missing_next_frame_cnt), |
| 1469 | accum_tx->burst_abort_missing_next_frame_cnt, |
| 1470 | delta_tx->burst_abort_missing_next_frame_cnt, |
| 1471 | max_tx->burst_abort_missing_next_frame_cnt); |
| 1472 | pos += scnprintf(buf + pos, bufsz - pos, |
| 1473 | fmt_table, "cts_timeout_collision:", |
| 1474 | le32_to_cpu(tx->cts_timeout_collision), |
| 1475 | accum_tx->cts_timeout_collision, |
| 1476 | delta_tx->cts_timeout_collision, |
| 1477 | max_tx->cts_timeout_collision); |
| 1478 | pos += scnprintf(buf + pos, bufsz - pos, |
| 1479 | fmt_table, "ack_ba_timeout_collision:", |
| 1480 | le32_to_cpu(tx->ack_or_ba_timeout_collision), |
| 1481 | accum_tx->ack_or_ba_timeout_collision, |
| 1482 | delta_tx->ack_or_ba_timeout_collision, |
| 1483 | max_tx->ack_or_ba_timeout_collision); |
| 1484 | pos += scnprintf(buf + pos, bufsz - pos, |
| 1485 | fmt_table, "agg ba_timeout:", |
| 1486 | le32_to_cpu(tx->agg.ba_timeout), |
| 1487 | accum_tx->agg.ba_timeout, |
| 1488 | delta_tx->agg.ba_timeout, |
| 1489 | max_tx->agg.ba_timeout); |
| 1490 | pos += scnprintf(buf + pos, bufsz - pos, |
| 1491 | fmt_table, "agg ba_resched_frames:", |
| 1492 | le32_to_cpu(tx->agg.ba_reschedule_frames), |
| 1493 | accum_tx->agg.ba_reschedule_frames, |
| 1494 | delta_tx->agg.ba_reschedule_frames, |
| 1495 | max_tx->agg.ba_reschedule_frames); |
| 1496 | pos += scnprintf(buf + pos, bufsz - pos, |
| 1497 | fmt_table, "agg scd_query_agg_frame:", |
| 1498 | le32_to_cpu(tx->agg.scd_query_agg_frame_cnt), |
| 1499 | accum_tx->agg.scd_query_agg_frame_cnt, |
| 1500 | delta_tx->agg.scd_query_agg_frame_cnt, |
| 1501 | max_tx->agg.scd_query_agg_frame_cnt); |
| 1502 | pos += scnprintf(buf + pos, bufsz - pos, |
| 1503 | fmt_table, "agg scd_query_no_agg:", |
| 1504 | le32_to_cpu(tx->agg.scd_query_no_agg), |
| 1505 | accum_tx->agg.scd_query_no_agg, |
| 1506 | delta_tx->agg.scd_query_no_agg, |
| 1507 | max_tx->agg.scd_query_no_agg); |
| 1508 | pos += scnprintf(buf + pos, bufsz - pos, |
| 1509 | fmt_table, "agg scd_query_agg:", |
| 1510 | le32_to_cpu(tx->agg.scd_query_agg), |
| 1511 | accum_tx->agg.scd_query_agg, |
| 1512 | delta_tx->agg.scd_query_agg, |
| 1513 | max_tx->agg.scd_query_agg); |
| 1514 | pos += scnprintf(buf + pos, bufsz - pos, |
| 1515 | fmt_table, "agg scd_query_mismatch:", |
| 1516 | le32_to_cpu(tx->agg.scd_query_mismatch), |
| 1517 | accum_tx->agg.scd_query_mismatch, |
| 1518 | delta_tx->agg.scd_query_mismatch, |
| 1519 | max_tx->agg.scd_query_mismatch); |
| 1520 | pos += scnprintf(buf + pos, bufsz - pos, |
| 1521 | fmt_table, "agg frame_not_ready:", |
| 1522 | le32_to_cpu(tx->agg.frame_not_ready), |
| 1523 | accum_tx->agg.frame_not_ready, |
| 1524 | delta_tx->agg.frame_not_ready, |
| 1525 | max_tx->agg.frame_not_ready); |
| 1526 | pos += scnprintf(buf + pos, bufsz - pos, |
| 1527 | fmt_table, "agg underrun:", |
| 1528 | le32_to_cpu(tx->agg.underrun), |
| 1529 | accum_tx->agg.underrun, |
| 1530 | delta_tx->agg.underrun, max_tx->agg.underrun); |
| 1531 | pos += scnprintf(buf + pos, bufsz - pos, |
| 1532 | fmt_table, "agg bt_prio_kill:", |
| 1533 | le32_to_cpu(tx->agg.bt_prio_kill), |
| 1534 | accum_tx->agg.bt_prio_kill, |
| 1535 | delta_tx->agg.bt_prio_kill, |
| 1536 | max_tx->agg.bt_prio_kill); |
| 1537 | pos += scnprintf(buf + pos, bufsz - pos, |
| 1538 | fmt_table, "agg rx_ba_rsp_cnt:", |
| 1539 | le32_to_cpu(tx->agg.rx_ba_rsp_cnt), |
| 1540 | accum_tx->agg.rx_ba_rsp_cnt, |
| 1541 | delta_tx->agg.rx_ba_rsp_cnt, |
| 1542 | max_tx->agg.rx_ba_rsp_cnt); |
| 1543 | |
| 1544 | if (tx->tx_power.ant_a || tx->tx_power.ant_b || tx->tx_power.ant_c) { |
| 1545 | pos += scnprintf(buf + pos, bufsz - pos, |
| 1546 | "tx power: (1/2 dB step)\n"); |
Johannes Berg | 7e79a39 | 2012-03-05 11:24:32 -0800 | [diff] [blame] | 1547 | if ((hw_params(priv).valid_tx_ant & ANT_A) && |
| 1548 | tx->tx_power.ant_a) |
Wey-Yi Guy | d6d023a | 2011-04-30 09:10:53 -0700 | [diff] [blame] | 1549 | pos += scnprintf(buf + pos, bufsz - pos, |
| 1550 | fmt_hex, "antenna A:", |
| 1551 | tx->tx_power.ant_a); |
Johannes Berg | 7e79a39 | 2012-03-05 11:24:32 -0800 | [diff] [blame] | 1552 | if ((hw_params(priv).valid_tx_ant & ANT_B) && |
| 1553 | tx->tx_power.ant_b) |
Wey-Yi Guy | d6d023a | 2011-04-30 09:10:53 -0700 | [diff] [blame] | 1554 | pos += scnprintf(buf + pos, bufsz - pos, |
| 1555 | fmt_hex, "antenna B:", |
| 1556 | tx->tx_power.ant_b); |
Johannes Berg | 7e79a39 | 2012-03-05 11:24:32 -0800 | [diff] [blame] | 1557 | if ((hw_params(priv).valid_tx_ant & ANT_C) && |
| 1558 | tx->tx_power.ant_c) |
Wey-Yi Guy | d6d023a | 2011-04-30 09:10:53 -0700 | [diff] [blame] | 1559 | pos += scnprintf(buf + pos, bufsz - pos, |
| 1560 | fmt_hex, "antenna C:", |
| 1561 | tx->tx_power.ant_c); |
| 1562 | } |
Johannes Berg | 4ff70fc | 2012-03-05 11:24:26 -0800 | [diff] [blame] | 1563 | |
| 1564 | spin_unlock_bh(&priv->statistics.lock); |
| 1565 | |
Wey-Yi Guy | d6d023a | 2011-04-30 09:10:53 -0700 | [diff] [blame] | 1566 | ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos); |
| 1567 | kfree(buf); |
| 1568 | return ret; |
Wey-Yi Guy | e8fe59a | 2009-08-07 15:41:42 -0700 | [diff] [blame] | 1569 | } |
| 1570 | |
| 1571 | static ssize_t iwl_dbgfs_ucode_general_stats_read(struct file *file, |
| 1572 | char __user *user_buf, |
| 1573 | size_t count, loff_t *ppos) |
| 1574 | { |
H Hartley Sweeten | 28f63a4 | 2010-01-08 16:14:10 -0700 | [diff] [blame] | 1575 | struct iwl_priv *priv = file->private_data; |
Wey-Yi Guy | d6d023a | 2011-04-30 09:10:53 -0700 | [diff] [blame] | 1576 | int pos = 0; |
| 1577 | char *buf; |
| 1578 | int bufsz = sizeof(struct statistics_general) * 10 + 300; |
| 1579 | ssize_t ret; |
| 1580 | struct statistics_general_common *general, *accum_general; |
| 1581 | struct statistics_general_common *delta_general, *max_general; |
| 1582 | struct statistics_dbg *dbg, *accum_dbg, *delta_dbg, *max_dbg; |
| 1583 | struct statistics_div *div, *accum_div, *delta_div, *max_div; |
| 1584 | |
Emmanuel Grumbach | 845a9c0 | 2011-08-25 23:11:04 -0700 | [diff] [blame] | 1585 | if (!iwl_is_alive(priv->shrd)) |
Wey-Yi Guy | d6d023a | 2011-04-30 09:10:53 -0700 | [diff] [blame] | 1586 | return -EAGAIN; |
| 1587 | |
| 1588 | buf = kzalloc(bufsz, GFP_KERNEL); |
| 1589 | if (!buf) { |
| 1590 | IWL_ERR(priv, "Can not allocate Buffer\n"); |
| 1591 | return -ENOMEM; |
| 1592 | } |
| 1593 | |
| 1594 | /* the statistic information display here is based on |
| 1595 | * the last statistics notification from uCode |
| 1596 | * might not reflect the current uCode activity |
| 1597 | */ |
Johannes Berg | 4ff70fc | 2012-03-05 11:24:26 -0800 | [diff] [blame] | 1598 | |
| 1599 | spin_lock_bh(&priv->statistics.lock); |
| 1600 | |
Wey-Yi Guy | d6d023a | 2011-04-30 09:10:53 -0700 | [diff] [blame] | 1601 | general = &priv->statistics.common; |
| 1602 | dbg = &priv->statistics.common.dbg; |
| 1603 | div = &priv->statistics.common.div; |
| 1604 | accum_general = &priv->accum_stats.common; |
| 1605 | accum_dbg = &priv->accum_stats.common.dbg; |
| 1606 | accum_div = &priv->accum_stats.common.div; |
| 1607 | delta_general = &priv->delta_stats.common; |
| 1608 | max_general = &priv->max_delta_stats.common; |
| 1609 | delta_dbg = &priv->delta_stats.common.dbg; |
| 1610 | max_dbg = &priv->max_delta_stats.common.dbg; |
| 1611 | delta_div = &priv->delta_stats.common.div; |
| 1612 | max_div = &priv->max_delta_stats.common.div; |
| 1613 | |
| 1614 | pos += iwl_statistics_flag(priv, buf, bufsz); |
| 1615 | pos += scnprintf(buf + pos, bufsz - pos, |
| 1616 | fmt_header, "Statistics_General:"); |
| 1617 | pos += scnprintf(buf + pos, bufsz - pos, |
| 1618 | fmt_value, "temperature:", |
| 1619 | le32_to_cpu(general->temperature)); |
| 1620 | pos += scnprintf(buf + pos, bufsz - pos, |
| 1621 | fmt_value, "temperature_m:", |
| 1622 | le32_to_cpu(general->temperature_m)); |
| 1623 | pos += scnprintf(buf + pos, bufsz - pos, |
| 1624 | fmt_value, "ttl_timestamp:", |
| 1625 | le32_to_cpu(general->ttl_timestamp)); |
| 1626 | pos += scnprintf(buf + pos, bufsz - pos, |
| 1627 | fmt_table, "burst_check:", |
| 1628 | le32_to_cpu(dbg->burst_check), |
| 1629 | accum_dbg->burst_check, |
| 1630 | delta_dbg->burst_check, max_dbg->burst_check); |
| 1631 | pos += scnprintf(buf + pos, bufsz - pos, |
| 1632 | fmt_table, "burst_count:", |
| 1633 | le32_to_cpu(dbg->burst_count), |
| 1634 | accum_dbg->burst_count, |
| 1635 | delta_dbg->burst_count, max_dbg->burst_count); |
| 1636 | pos += scnprintf(buf + pos, bufsz - pos, |
| 1637 | fmt_table, "wait_for_silence_timeout_count:", |
| 1638 | le32_to_cpu(dbg->wait_for_silence_timeout_cnt), |
| 1639 | accum_dbg->wait_for_silence_timeout_cnt, |
| 1640 | delta_dbg->wait_for_silence_timeout_cnt, |
| 1641 | max_dbg->wait_for_silence_timeout_cnt); |
| 1642 | pos += scnprintf(buf + pos, bufsz - pos, |
| 1643 | fmt_table, "sleep_time:", |
| 1644 | le32_to_cpu(general->sleep_time), |
| 1645 | accum_general->sleep_time, |
| 1646 | delta_general->sleep_time, max_general->sleep_time); |
| 1647 | pos += scnprintf(buf + pos, bufsz - pos, |
| 1648 | fmt_table, "slots_out:", |
| 1649 | le32_to_cpu(general->slots_out), |
| 1650 | accum_general->slots_out, |
| 1651 | delta_general->slots_out, max_general->slots_out); |
| 1652 | pos += scnprintf(buf + pos, bufsz - pos, |
| 1653 | fmt_table, "slots_idle:", |
| 1654 | le32_to_cpu(general->slots_idle), |
| 1655 | accum_general->slots_idle, |
| 1656 | delta_general->slots_idle, max_general->slots_idle); |
| 1657 | pos += scnprintf(buf + pos, bufsz - pos, |
| 1658 | fmt_table, "tx_on_a:", |
| 1659 | le32_to_cpu(div->tx_on_a), accum_div->tx_on_a, |
| 1660 | delta_div->tx_on_a, max_div->tx_on_a); |
| 1661 | pos += scnprintf(buf + pos, bufsz - pos, |
| 1662 | fmt_table, "tx_on_b:", |
| 1663 | le32_to_cpu(div->tx_on_b), accum_div->tx_on_b, |
| 1664 | delta_div->tx_on_b, max_div->tx_on_b); |
| 1665 | pos += scnprintf(buf + pos, bufsz - pos, |
| 1666 | fmt_table, "exec_time:", |
| 1667 | le32_to_cpu(div->exec_time), accum_div->exec_time, |
| 1668 | delta_div->exec_time, max_div->exec_time); |
| 1669 | pos += scnprintf(buf + pos, bufsz - pos, |
| 1670 | fmt_table, "probe_time:", |
| 1671 | le32_to_cpu(div->probe_time), accum_div->probe_time, |
| 1672 | delta_div->probe_time, max_div->probe_time); |
| 1673 | pos += scnprintf(buf + pos, bufsz - pos, |
| 1674 | fmt_table, "rx_enable_counter:", |
| 1675 | le32_to_cpu(general->rx_enable_counter), |
| 1676 | accum_general->rx_enable_counter, |
| 1677 | delta_general->rx_enable_counter, |
| 1678 | max_general->rx_enable_counter); |
| 1679 | pos += scnprintf(buf + pos, bufsz - pos, |
| 1680 | fmt_table, "num_of_sos_states:", |
| 1681 | le32_to_cpu(general->num_of_sos_states), |
| 1682 | accum_general->num_of_sos_states, |
| 1683 | delta_general->num_of_sos_states, |
| 1684 | max_general->num_of_sos_states); |
Johannes Berg | 4ff70fc | 2012-03-05 11:24:26 -0800 | [diff] [blame] | 1685 | |
| 1686 | spin_unlock_bh(&priv->statistics.lock); |
| 1687 | |
Wey-Yi Guy | d6d023a | 2011-04-30 09:10:53 -0700 | [diff] [blame] | 1688 | ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos); |
| 1689 | kfree(buf); |
| 1690 | return ret; |
| 1691 | } |
| 1692 | |
| 1693 | static ssize_t iwl_dbgfs_ucode_bt_stats_read(struct file *file, |
| 1694 | char __user *user_buf, |
| 1695 | size_t count, loff_t *ppos) |
| 1696 | { |
| 1697 | struct iwl_priv *priv = (struct iwl_priv *)file->private_data; |
| 1698 | int pos = 0; |
| 1699 | char *buf; |
| 1700 | int bufsz = (sizeof(struct statistics_bt_activity) * 24) + 200; |
| 1701 | ssize_t ret; |
| 1702 | struct statistics_bt_activity *bt, *accum_bt; |
| 1703 | |
Emmanuel Grumbach | 845a9c0 | 2011-08-25 23:11:04 -0700 | [diff] [blame] | 1704 | if (!iwl_is_alive(priv->shrd)) |
Wey-Yi Guy | d6d023a | 2011-04-30 09:10:53 -0700 | [diff] [blame] | 1705 | return -EAGAIN; |
| 1706 | |
| 1707 | if (!priv->bt_enable_flag) |
| 1708 | return -EINVAL; |
| 1709 | |
| 1710 | /* make request to uCode to retrieve statistics information */ |
Johannes Berg | b1eea29 | 2012-03-06 13:30:42 -0800 | [diff] [blame^] | 1711 | mutex_lock(&priv->mutex); |
Wey-Yi Guy | d6d023a | 2011-04-30 09:10:53 -0700 | [diff] [blame] | 1712 | ret = iwl_send_statistics_request(priv, CMD_SYNC, false); |
Johannes Berg | b1eea29 | 2012-03-06 13:30:42 -0800 | [diff] [blame^] | 1713 | mutex_unlock(&priv->mutex); |
Wey-Yi Guy | d6d023a | 2011-04-30 09:10:53 -0700 | [diff] [blame] | 1714 | |
| 1715 | if (ret) { |
| 1716 | IWL_ERR(priv, |
| 1717 | "Error sending statistics request: %zd\n", ret); |
| 1718 | return -EAGAIN; |
| 1719 | } |
| 1720 | buf = kzalloc(bufsz, GFP_KERNEL); |
| 1721 | if (!buf) { |
| 1722 | IWL_ERR(priv, "Can not allocate Buffer\n"); |
| 1723 | return -ENOMEM; |
| 1724 | } |
| 1725 | |
| 1726 | /* |
| 1727 | * the statistic information display here is based on |
| 1728 | * the last statistics notification from uCode |
| 1729 | * might not reflect the current uCode activity |
| 1730 | */ |
Johannes Berg | 4ff70fc | 2012-03-05 11:24:26 -0800 | [diff] [blame] | 1731 | |
| 1732 | spin_lock_bh(&priv->statistics.lock); |
| 1733 | |
Wey-Yi Guy | d6d023a | 2011-04-30 09:10:53 -0700 | [diff] [blame] | 1734 | bt = &priv->statistics.bt_activity; |
| 1735 | accum_bt = &priv->accum_stats.bt_activity; |
| 1736 | |
| 1737 | pos += iwl_statistics_flag(priv, buf, bufsz); |
| 1738 | pos += scnprintf(buf + pos, bufsz - pos, "Statistics_BT:\n"); |
| 1739 | pos += scnprintf(buf + pos, bufsz - pos, |
| 1740 | "\t\t\tcurrent\t\t\taccumulative\n"); |
| 1741 | pos += scnprintf(buf + pos, bufsz - pos, |
| 1742 | "hi_priority_tx_req_cnt:\t\t%u\t\t\t%u\n", |
| 1743 | le32_to_cpu(bt->hi_priority_tx_req_cnt), |
| 1744 | accum_bt->hi_priority_tx_req_cnt); |
| 1745 | pos += scnprintf(buf + pos, bufsz - pos, |
| 1746 | "hi_priority_tx_denied_cnt:\t%u\t\t\t%u\n", |
| 1747 | le32_to_cpu(bt->hi_priority_tx_denied_cnt), |
| 1748 | accum_bt->hi_priority_tx_denied_cnt); |
| 1749 | pos += scnprintf(buf + pos, bufsz - pos, |
| 1750 | "lo_priority_tx_req_cnt:\t\t%u\t\t\t%u\n", |
| 1751 | le32_to_cpu(bt->lo_priority_tx_req_cnt), |
| 1752 | accum_bt->lo_priority_tx_req_cnt); |
| 1753 | pos += scnprintf(buf + pos, bufsz - pos, |
| 1754 | "lo_priority_tx_denied_cnt:\t%u\t\t\t%u\n", |
| 1755 | le32_to_cpu(bt->lo_priority_tx_denied_cnt), |
| 1756 | accum_bt->lo_priority_tx_denied_cnt); |
| 1757 | pos += scnprintf(buf + pos, bufsz - pos, |
| 1758 | "hi_priority_rx_req_cnt:\t\t%u\t\t\t%u\n", |
| 1759 | le32_to_cpu(bt->hi_priority_rx_req_cnt), |
| 1760 | accum_bt->hi_priority_rx_req_cnt); |
| 1761 | pos += scnprintf(buf + pos, bufsz - pos, |
| 1762 | "hi_priority_rx_denied_cnt:\t%u\t\t\t%u\n", |
| 1763 | le32_to_cpu(bt->hi_priority_rx_denied_cnt), |
| 1764 | accum_bt->hi_priority_rx_denied_cnt); |
| 1765 | pos += scnprintf(buf + pos, bufsz - pos, |
| 1766 | "lo_priority_rx_req_cnt:\t\t%u\t\t\t%u\n", |
| 1767 | le32_to_cpu(bt->lo_priority_rx_req_cnt), |
| 1768 | accum_bt->lo_priority_rx_req_cnt); |
| 1769 | pos += scnprintf(buf + pos, bufsz - pos, |
| 1770 | "lo_priority_rx_denied_cnt:\t%u\t\t\t%u\n", |
| 1771 | le32_to_cpu(bt->lo_priority_rx_denied_cnt), |
| 1772 | accum_bt->lo_priority_rx_denied_cnt); |
| 1773 | |
| 1774 | pos += scnprintf(buf + pos, bufsz - pos, |
| 1775 | "(rx)num_bt_kills:\t\t%u\t\t\t%u\n", |
| 1776 | le32_to_cpu(priv->statistics.num_bt_kills), |
| 1777 | priv->statistics.accum_num_bt_kills); |
| 1778 | |
Johannes Berg | 4ff70fc | 2012-03-05 11:24:26 -0800 | [diff] [blame] | 1779 | spin_unlock_bh(&priv->statistics.lock); |
| 1780 | |
Wey-Yi Guy | d6d023a | 2011-04-30 09:10:53 -0700 | [diff] [blame] | 1781 | ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos); |
| 1782 | kfree(buf); |
| 1783 | return ret; |
| 1784 | } |
| 1785 | |
| 1786 | static ssize_t iwl_dbgfs_reply_tx_error_read(struct file *file, |
| 1787 | char __user *user_buf, |
| 1788 | size_t count, loff_t *ppos) |
| 1789 | { |
| 1790 | struct iwl_priv *priv = (struct iwl_priv *)file->private_data; |
| 1791 | int pos = 0; |
| 1792 | char *buf; |
| 1793 | int bufsz = (sizeof(struct reply_tx_error_statistics) * 24) + |
| 1794 | (sizeof(struct reply_agg_tx_error_statistics) * 24) + 200; |
| 1795 | ssize_t ret; |
| 1796 | |
Emmanuel Grumbach | 845a9c0 | 2011-08-25 23:11:04 -0700 | [diff] [blame] | 1797 | if (!iwl_is_alive(priv->shrd)) |
Wey-Yi Guy | d6d023a | 2011-04-30 09:10:53 -0700 | [diff] [blame] | 1798 | return -EAGAIN; |
| 1799 | |
| 1800 | buf = kzalloc(bufsz, GFP_KERNEL); |
| 1801 | if (!buf) { |
| 1802 | IWL_ERR(priv, "Can not allocate Buffer\n"); |
| 1803 | return -ENOMEM; |
| 1804 | } |
| 1805 | |
| 1806 | pos += scnprintf(buf + pos, bufsz - pos, "Statistics_TX_Error:\n"); |
| 1807 | pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t\t\t%u\n", |
| 1808 | iwl_get_tx_fail_reason(TX_STATUS_POSTPONE_DELAY), |
Wey-Yi Guy | 898ed67 | 2011-07-13 08:38:57 -0700 | [diff] [blame] | 1809 | priv->reply_tx_stats.pp_delay); |
Wey-Yi Guy | d6d023a | 2011-04-30 09:10:53 -0700 | [diff] [blame] | 1810 | pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t\t%u\n", |
| 1811 | iwl_get_tx_fail_reason(TX_STATUS_POSTPONE_FEW_BYTES), |
Wey-Yi Guy | 898ed67 | 2011-07-13 08:38:57 -0700 | [diff] [blame] | 1812 | priv->reply_tx_stats.pp_few_bytes); |
Wey-Yi Guy | d6d023a | 2011-04-30 09:10:53 -0700 | [diff] [blame] | 1813 | pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t\t%u\n", |
| 1814 | iwl_get_tx_fail_reason(TX_STATUS_POSTPONE_BT_PRIO), |
Wey-Yi Guy | 898ed67 | 2011-07-13 08:38:57 -0700 | [diff] [blame] | 1815 | priv->reply_tx_stats.pp_bt_prio); |
Wey-Yi Guy | d6d023a | 2011-04-30 09:10:53 -0700 | [diff] [blame] | 1816 | pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t\t%u\n", |
| 1817 | iwl_get_tx_fail_reason(TX_STATUS_POSTPONE_QUIET_PERIOD), |
Wey-Yi Guy | 898ed67 | 2011-07-13 08:38:57 -0700 | [diff] [blame] | 1818 | priv->reply_tx_stats.pp_quiet_period); |
Wey-Yi Guy | d6d023a | 2011-04-30 09:10:53 -0700 | [diff] [blame] | 1819 | pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t\t%u\n", |
| 1820 | iwl_get_tx_fail_reason(TX_STATUS_POSTPONE_CALC_TTAK), |
Wey-Yi Guy | 898ed67 | 2011-07-13 08:38:57 -0700 | [diff] [blame] | 1821 | priv->reply_tx_stats.pp_calc_ttak); |
Wey-Yi Guy | d6d023a | 2011-04-30 09:10:53 -0700 | [diff] [blame] | 1822 | pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t%u\n", |
| 1823 | iwl_get_tx_fail_reason( |
| 1824 | TX_STATUS_FAIL_INTERNAL_CROSSED_RETRY), |
Wey-Yi Guy | 898ed67 | 2011-07-13 08:38:57 -0700 | [diff] [blame] | 1825 | priv->reply_tx_stats.int_crossed_retry); |
Wey-Yi Guy | d6d023a | 2011-04-30 09:10:53 -0700 | [diff] [blame] | 1826 | pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t\t%u\n", |
| 1827 | iwl_get_tx_fail_reason(TX_STATUS_FAIL_SHORT_LIMIT), |
Wey-Yi Guy | 898ed67 | 2011-07-13 08:38:57 -0700 | [diff] [blame] | 1828 | priv->reply_tx_stats.short_limit); |
Wey-Yi Guy | d6d023a | 2011-04-30 09:10:53 -0700 | [diff] [blame] | 1829 | pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t\t%u\n", |
| 1830 | iwl_get_tx_fail_reason(TX_STATUS_FAIL_LONG_LIMIT), |
Wey-Yi Guy | 898ed67 | 2011-07-13 08:38:57 -0700 | [diff] [blame] | 1831 | priv->reply_tx_stats.long_limit); |
Wey-Yi Guy | d6d023a | 2011-04-30 09:10:53 -0700 | [diff] [blame] | 1832 | pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t\t%u\n", |
| 1833 | iwl_get_tx_fail_reason(TX_STATUS_FAIL_FIFO_UNDERRUN), |
Wey-Yi Guy | 898ed67 | 2011-07-13 08:38:57 -0700 | [diff] [blame] | 1834 | priv->reply_tx_stats.fifo_underrun); |
Wey-Yi Guy | d6d023a | 2011-04-30 09:10:53 -0700 | [diff] [blame] | 1835 | pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t\t%u\n", |
| 1836 | iwl_get_tx_fail_reason(TX_STATUS_FAIL_DRAIN_FLOW), |
Wey-Yi Guy | 898ed67 | 2011-07-13 08:38:57 -0700 | [diff] [blame] | 1837 | priv->reply_tx_stats.drain_flow); |
Wey-Yi Guy | d6d023a | 2011-04-30 09:10:53 -0700 | [diff] [blame] | 1838 | pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t\t%u\n", |
| 1839 | iwl_get_tx_fail_reason(TX_STATUS_FAIL_RFKILL_FLUSH), |
Wey-Yi Guy | 898ed67 | 2011-07-13 08:38:57 -0700 | [diff] [blame] | 1840 | priv->reply_tx_stats.rfkill_flush); |
Wey-Yi Guy | d6d023a | 2011-04-30 09:10:53 -0700 | [diff] [blame] | 1841 | pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t\t%u\n", |
| 1842 | iwl_get_tx_fail_reason(TX_STATUS_FAIL_LIFE_EXPIRE), |
Wey-Yi Guy | 898ed67 | 2011-07-13 08:38:57 -0700 | [diff] [blame] | 1843 | priv->reply_tx_stats.life_expire); |
Wey-Yi Guy | d6d023a | 2011-04-30 09:10:53 -0700 | [diff] [blame] | 1844 | pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t\t%u\n", |
| 1845 | iwl_get_tx_fail_reason(TX_STATUS_FAIL_DEST_PS), |
Wey-Yi Guy | 898ed67 | 2011-07-13 08:38:57 -0700 | [diff] [blame] | 1846 | priv->reply_tx_stats.dest_ps); |
Wey-Yi Guy | d6d023a | 2011-04-30 09:10:53 -0700 | [diff] [blame] | 1847 | pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t\t%u\n", |
| 1848 | iwl_get_tx_fail_reason(TX_STATUS_FAIL_HOST_ABORTED), |
Wey-Yi Guy | 898ed67 | 2011-07-13 08:38:57 -0700 | [diff] [blame] | 1849 | priv->reply_tx_stats.host_abort); |
Wey-Yi Guy | d6d023a | 2011-04-30 09:10:53 -0700 | [diff] [blame] | 1850 | pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t\t%u\n", |
| 1851 | iwl_get_tx_fail_reason(TX_STATUS_FAIL_BT_RETRY), |
Wey-Yi Guy | 898ed67 | 2011-07-13 08:38:57 -0700 | [diff] [blame] | 1852 | priv->reply_tx_stats.pp_delay); |
Wey-Yi Guy | d6d023a | 2011-04-30 09:10:53 -0700 | [diff] [blame] | 1853 | pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t\t%u\n", |
| 1854 | iwl_get_tx_fail_reason(TX_STATUS_FAIL_STA_INVALID), |
Wey-Yi Guy | 898ed67 | 2011-07-13 08:38:57 -0700 | [diff] [blame] | 1855 | priv->reply_tx_stats.sta_invalid); |
Wey-Yi Guy | d6d023a | 2011-04-30 09:10:53 -0700 | [diff] [blame] | 1856 | pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t\t%u\n", |
| 1857 | iwl_get_tx_fail_reason(TX_STATUS_FAIL_FRAG_DROPPED), |
Wey-Yi Guy | 898ed67 | 2011-07-13 08:38:57 -0700 | [diff] [blame] | 1858 | priv->reply_tx_stats.frag_drop); |
Wey-Yi Guy | d6d023a | 2011-04-30 09:10:53 -0700 | [diff] [blame] | 1859 | pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t\t%u\n", |
| 1860 | iwl_get_tx_fail_reason(TX_STATUS_FAIL_TID_DISABLE), |
Wey-Yi Guy | 898ed67 | 2011-07-13 08:38:57 -0700 | [diff] [blame] | 1861 | priv->reply_tx_stats.tid_disable); |
Wey-Yi Guy | d6d023a | 2011-04-30 09:10:53 -0700 | [diff] [blame] | 1862 | pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t\t%u\n", |
| 1863 | iwl_get_tx_fail_reason(TX_STATUS_FAIL_FIFO_FLUSHED), |
Wey-Yi Guy | 898ed67 | 2011-07-13 08:38:57 -0700 | [diff] [blame] | 1864 | priv->reply_tx_stats.fifo_flush); |
Wey-Yi Guy | d6d023a | 2011-04-30 09:10:53 -0700 | [diff] [blame] | 1865 | pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t%u\n", |
| 1866 | iwl_get_tx_fail_reason( |
| 1867 | TX_STATUS_FAIL_INSUFFICIENT_CF_POLL), |
Wey-Yi Guy | 898ed67 | 2011-07-13 08:38:57 -0700 | [diff] [blame] | 1868 | priv->reply_tx_stats.insuff_cf_poll); |
Wey-Yi Guy | d6d023a | 2011-04-30 09:10:53 -0700 | [diff] [blame] | 1869 | pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t\t%u\n", |
| 1870 | iwl_get_tx_fail_reason(TX_STATUS_FAIL_PASSIVE_NO_RX), |
Wey-Yi Guy | 898ed67 | 2011-07-13 08:38:57 -0700 | [diff] [blame] | 1871 | priv->reply_tx_stats.fail_hw_drop); |
Wey-Yi Guy | d6d023a | 2011-04-30 09:10:53 -0700 | [diff] [blame] | 1872 | pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t%u\n", |
| 1873 | iwl_get_tx_fail_reason( |
| 1874 | TX_STATUS_FAIL_NO_BEACON_ON_RADAR), |
Wey-Yi Guy | 898ed67 | 2011-07-13 08:38:57 -0700 | [diff] [blame] | 1875 | priv->reply_tx_stats.sta_color_mismatch); |
Wey-Yi Guy | d6d023a | 2011-04-30 09:10:53 -0700 | [diff] [blame] | 1876 | 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] | 1877 | priv->reply_tx_stats.unknown); |
Wey-Yi Guy | d6d023a | 2011-04-30 09:10:53 -0700 | [diff] [blame] | 1878 | |
| 1879 | pos += scnprintf(buf + pos, bufsz - pos, |
| 1880 | "\nStatistics_Agg_TX_Error:\n"); |
| 1881 | |
| 1882 | pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t\t%u\n", |
| 1883 | iwl_get_agg_tx_fail_reason(AGG_TX_STATE_UNDERRUN_MSK), |
Wey-Yi Guy | 898ed67 | 2011-07-13 08:38:57 -0700 | [diff] [blame] | 1884 | priv->reply_agg_tx_stats.underrun); |
Wey-Yi Guy | d6d023a | 2011-04-30 09:10:53 -0700 | [diff] [blame] | 1885 | pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t\t%u\n", |
| 1886 | 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] | 1887 | priv->reply_agg_tx_stats.bt_prio); |
Wey-Yi Guy | d6d023a | 2011-04-30 09:10:53 -0700 | [diff] [blame] | 1888 | pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t\t%u\n", |
| 1889 | 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] | 1890 | priv->reply_agg_tx_stats.few_bytes); |
Wey-Yi Guy | d6d023a | 2011-04-30 09:10:53 -0700 | [diff] [blame] | 1891 | pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t\t%u\n", |
| 1892 | iwl_get_agg_tx_fail_reason(AGG_TX_STATE_ABORT_MSK), |
Wey-Yi Guy | 898ed67 | 2011-07-13 08:38:57 -0700 | [diff] [blame] | 1893 | priv->reply_agg_tx_stats.abort); |
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_TTL_MSK), |
Wey-Yi Guy | 898ed67 | 2011-07-13 08:38:57 -0700 | [diff] [blame] | 1897 | priv->reply_agg_tx_stats.last_sent_ttl); |
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_TRY_CNT_MSK), |
Wey-Yi Guy | 898ed67 | 2011-07-13 08:38:57 -0700 | [diff] [blame] | 1901 | priv->reply_agg_tx_stats.last_sent_try); |
Wey-Yi Guy | d6d023a | 2011-04-30 09:10:53 -0700 | [diff] [blame] | 1902 | pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t%u\n", |
| 1903 | iwl_get_agg_tx_fail_reason( |
| 1904 | AGG_TX_STATE_LAST_SENT_BT_KILL_MSK), |
Wey-Yi Guy | 898ed67 | 2011-07-13 08:38:57 -0700 | [diff] [blame] | 1905 | priv->reply_agg_tx_stats.last_sent_bt_kill); |
Wey-Yi Guy | d6d023a | 2011-04-30 09:10:53 -0700 | [diff] [blame] | 1906 | pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t\t%u\n", |
| 1907 | 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] | 1908 | priv->reply_agg_tx_stats.scd_query); |
Wey-Yi Guy | d6d023a | 2011-04-30 09:10:53 -0700 | [diff] [blame] | 1909 | pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t%u\n", |
| 1910 | iwl_get_agg_tx_fail_reason( |
| 1911 | AGG_TX_STATE_TEST_BAD_CRC32_MSK), |
Wey-Yi Guy | 898ed67 | 2011-07-13 08:38:57 -0700 | [diff] [blame] | 1912 | priv->reply_agg_tx_stats.bad_crc32); |
Wey-Yi Guy | d6d023a | 2011-04-30 09:10:53 -0700 | [diff] [blame] | 1913 | pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t\t%u\n", |
| 1914 | iwl_get_agg_tx_fail_reason(AGG_TX_STATE_RESPONSE_MSK), |
Wey-Yi Guy | 898ed67 | 2011-07-13 08:38:57 -0700 | [diff] [blame] | 1915 | priv->reply_agg_tx_stats.response); |
Wey-Yi Guy | d6d023a | 2011-04-30 09:10:53 -0700 | [diff] [blame] | 1916 | pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t\t%u\n", |
| 1917 | 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] | 1918 | priv->reply_agg_tx_stats.dump_tx); |
Wey-Yi Guy | d6d023a | 2011-04-30 09:10:53 -0700 | [diff] [blame] | 1919 | pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t\t%u\n", |
| 1920 | 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] | 1921 | priv->reply_agg_tx_stats.delay_tx); |
Wey-Yi Guy | d6d023a | 2011-04-30 09:10:53 -0700 | [diff] [blame] | 1922 | 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] | 1923 | priv->reply_agg_tx_stats.unknown); |
Wey-Yi Guy | d6d023a | 2011-04-30 09:10:53 -0700 | [diff] [blame] | 1924 | |
| 1925 | ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos); |
| 1926 | kfree(buf); |
| 1927 | return ret; |
Wey-Yi Guy | e8fe59a | 2009-08-07 15:41:42 -0700 | [diff] [blame] | 1928 | } |
| 1929 | |
Wey-Yi Guy | 5225935 | 2009-08-07 15:41:43 -0700 | [diff] [blame] | 1930 | static ssize_t iwl_dbgfs_sensitivity_read(struct file *file, |
| 1931 | char __user *user_buf, |
| 1932 | size_t count, loff_t *ppos) { |
| 1933 | |
H Hartley Sweeten | 28f63a4 | 2010-01-08 16:14:10 -0700 | [diff] [blame] | 1934 | struct iwl_priv *priv = file->private_data; |
Wey-Yi Guy | 5225935 | 2009-08-07 15:41:43 -0700 | [diff] [blame] | 1935 | int pos = 0; |
| 1936 | int cnt = 0; |
| 1937 | char *buf; |
| 1938 | int bufsz = sizeof(struct iwl_sensitivity_data) * 4 + 100; |
| 1939 | ssize_t ret; |
| 1940 | struct iwl_sensitivity_data *data; |
| 1941 | |
| 1942 | data = &priv->sensitivity_data; |
| 1943 | buf = kzalloc(bufsz, GFP_KERNEL); |
| 1944 | if (!buf) { |
| 1945 | IWL_ERR(priv, "Can not allocate Buffer\n"); |
| 1946 | return -ENOMEM; |
| 1947 | } |
| 1948 | |
| 1949 | pos += scnprintf(buf + pos, bufsz - pos, "auto_corr_ofdm:\t\t\t %u\n", |
| 1950 | data->auto_corr_ofdm); |
| 1951 | pos += scnprintf(buf + pos, bufsz - pos, |
| 1952 | "auto_corr_ofdm_mrc:\t\t %u\n", |
| 1953 | data->auto_corr_ofdm_mrc); |
| 1954 | pos += scnprintf(buf + pos, bufsz - pos, "auto_corr_ofdm_x1:\t\t %u\n", |
| 1955 | data->auto_corr_ofdm_x1); |
| 1956 | pos += scnprintf(buf + pos, bufsz - pos, |
| 1957 | "auto_corr_ofdm_mrc_x1:\t\t %u\n", |
| 1958 | data->auto_corr_ofdm_mrc_x1); |
| 1959 | pos += scnprintf(buf + pos, bufsz - pos, "auto_corr_cck:\t\t\t %u\n", |
| 1960 | data->auto_corr_cck); |
| 1961 | pos += scnprintf(buf + pos, bufsz - pos, "auto_corr_cck_mrc:\t\t %u\n", |
| 1962 | data->auto_corr_cck_mrc); |
| 1963 | pos += scnprintf(buf + pos, bufsz - pos, |
| 1964 | "last_bad_plcp_cnt_ofdm:\t\t %u\n", |
| 1965 | data->last_bad_plcp_cnt_ofdm); |
| 1966 | pos += scnprintf(buf + pos, bufsz - pos, "last_fa_cnt_ofdm:\t\t %u\n", |
| 1967 | data->last_fa_cnt_ofdm); |
| 1968 | pos += scnprintf(buf + pos, bufsz - pos, |
| 1969 | "last_bad_plcp_cnt_cck:\t\t %u\n", |
| 1970 | data->last_bad_plcp_cnt_cck); |
| 1971 | pos += scnprintf(buf + pos, bufsz - pos, "last_fa_cnt_cck:\t\t %u\n", |
| 1972 | data->last_fa_cnt_cck); |
| 1973 | pos += scnprintf(buf + pos, bufsz - pos, "nrg_curr_state:\t\t\t %u\n", |
| 1974 | data->nrg_curr_state); |
| 1975 | pos += scnprintf(buf + pos, bufsz - pos, "nrg_prev_state:\t\t\t %u\n", |
| 1976 | data->nrg_prev_state); |
| 1977 | pos += scnprintf(buf + pos, bufsz - pos, "nrg_value:\t\t\t"); |
| 1978 | for (cnt = 0; cnt < 10; cnt++) { |
| 1979 | pos += scnprintf(buf + pos, bufsz - pos, " %u", |
| 1980 | data->nrg_value[cnt]); |
| 1981 | } |
| 1982 | pos += scnprintf(buf + pos, bufsz - pos, "\n"); |
| 1983 | pos += scnprintf(buf + pos, bufsz - pos, "nrg_silence_rssi:\t\t"); |
| 1984 | for (cnt = 0; cnt < NRG_NUM_PREV_STAT_L; cnt++) { |
| 1985 | pos += scnprintf(buf + pos, bufsz - pos, " %u", |
| 1986 | data->nrg_silence_rssi[cnt]); |
| 1987 | } |
| 1988 | pos += scnprintf(buf + pos, bufsz - pos, "\n"); |
| 1989 | pos += scnprintf(buf + pos, bufsz - pos, "nrg_silence_ref:\t\t %u\n", |
| 1990 | data->nrg_silence_ref); |
| 1991 | pos += scnprintf(buf + pos, bufsz - pos, "nrg_energy_idx:\t\t\t %u\n", |
| 1992 | data->nrg_energy_idx); |
| 1993 | pos += scnprintf(buf + pos, bufsz - pos, "nrg_silence_idx:\t\t %u\n", |
| 1994 | data->nrg_silence_idx); |
| 1995 | pos += scnprintf(buf + pos, bufsz - pos, "nrg_th_cck:\t\t\t %u\n", |
| 1996 | data->nrg_th_cck); |
| 1997 | pos += scnprintf(buf + pos, bufsz - pos, |
| 1998 | "nrg_auto_corr_silence_diff:\t %u\n", |
| 1999 | data->nrg_auto_corr_silence_diff); |
| 2000 | pos += scnprintf(buf + pos, bufsz - pos, "num_in_cck_no_fa:\t\t %u\n", |
| 2001 | data->num_in_cck_no_fa); |
| 2002 | pos += scnprintf(buf + pos, bufsz - pos, "nrg_th_ofdm:\t\t\t %u\n", |
| 2003 | data->nrg_th_ofdm); |
| 2004 | |
| 2005 | ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos); |
| 2006 | kfree(buf); |
| 2007 | return ret; |
| 2008 | } |
| 2009 | |
| 2010 | |
| 2011 | static ssize_t iwl_dbgfs_chain_noise_read(struct file *file, |
| 2012 | char __user *user_buf, |
| 2013 | size_t count, loff_t *ppos) { |
| 2014 | |
H Hartley Sweeten | 28f63a4 | 2010-01-08 16:14:10 -0700 | [diff] [blame] | 2015 | struct iwl_priv *priv = file->private_data; |
Wey-Yi Guy | 5225935 | 2009-08-07 15:41:43 -0700 | [diff] [blame] | 2016 | int pos = 0; |
| 2017 | int cnt = 0; |
| 2018 | char *buf; |
| 2019 | int bufsz = sizeof(struct iwl_chain_noise_data) * 4 + 100; |
| 2020 | ssize_t ret; |
| 2021 | struct iwl_chain_noise_data *data; |
| 2022 | |
| 2023 | data = &priv->chain_noise_data; |
| 2024 | buf = kzalloc(bufsz, GFP_KERNEL); |
| 2025 | if (!buf) { |
| 2026 | IWL_ERR(priv, "Can not allocate Buffer\n"); |
| 2027 | return -ENOMEM; |
| 2028 | } |
| 2029 | |
| 2030 | pos += scnprintf(buf + pos, bufsz - pos, "active_chains:\t\t\t %u\n", |
| 2031 | data->active_chains); |
| 2032 | pos += scnprintf(buf + pos, bufsz - pos, "chain_noise_a:\t\t\t %u\n", |
| 2033 | data->chain_noise_a); |
| 2034 | pos += scnprintf(buf + pos, bufsz - pos, "chain_noise_b:\t\t\t %u\n", |
| 2035 | data->chain_noise_b); |
| 2036 | pos += scnprintf(buf + pos, bufsz - pos, "chain_noise_c:\t\t\t %u\n", |
| 2037 | data->chain_noise_c); |
| 2038 | pos += scnprintf(buf + pos, bufsz - pos, "chain_signal_a:\t\t\t %u\n", |
| 2039 | data->chain_signal_a); |
| 2040 | pos += scnprintf(buf + pos, bufsz - pos, "chain_signal_b:\t\t\t %u\n", |
| 2041 | data->chain_signal_b); |
| 2042 | pos += scnprintf(buf + pos, bufsz - pos, "chain_signal_c:\t\t\t %u\n", |
| 2043 | data->chain_signal_c); |
| 2044 | pos += scnprintf(buf + pos, bufsz - pos, "beacon_count:\t\t\t %u\n", |
| 2045 | data->beacon_count); |
| 2046 | |
| 2047 | pos += scnprintf(buf + pos, bufsz - pos, "disconn_array:\t\t\t"); |
| 2048 | for (cnt = 0; cnt < NUM_RX_CHAINS; cnt++) { |
| 2049 | pos += scnprintf(buf + pos, bufsz - pos, " %u", |
| 2050 | data->disconn_array[cnt]); |
| 2051 | } |
| 2052 | pos += scnprintf(buf + pos, bufsz - pos, "\n"); |
| 2053 | pos += scnprintf(buf + pos, bufsz - pos, "delta_gain_code:\t\t"); |
| 2054 | for (cnt = 0; cnt < NUM_RX_CHAINS; cnt++) { |
| 2055 | pos += scnprintf(buf + pos, bufsz - pos, " %u", |
| 2056 | data->delta_gain_code[cnt]); |
| 2057 | } |
| 2058 | pos += scnprintf(buf + pos, bufsz - pos, "\n"); |
| 2059 | pos += scnprintf(buf + pos, bufsz - pos, "radio_write:\t\t\t %u\n", |
| 2060 | data->radio_write); |
| 2061 | pos += scnprintf(buf + pos, bufsz - pos, "state:\t\t\t\t %u\n", |
| 2062 | data->state); |
| 2063 | |
| 2064 | ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos); |
| 2065 | kfree(buf); |
| 2066 | return ret; |
| 2067 | } |
| 2068 | |
Wey-Yi Guy | c09430a | 2009-10-16 14:25:50 -0700 | [diff] [blame] | 2069 | static ssize_t iwl_dbgfs_power_save_status_read(struct file *file, |
| 2070 | char __user *user_buf, |
| 2071 | size_t count, loff_t *ppos) |
| 2072 | { |
H Hartley Sweeten | 28f63a4 | 2010-01-08 16:14:10 -0700 | [diff] [blame] | 2073 | struct iwl_priv *priv = file->private_data; |
Wey-Yi Guy | c09430a | 2009-10-16 14:25:50 -0700 | [diff] [blame] | 2074 | char buf[60]; |
| 2075 | int pos = 0; |
| 2076 | const size_t bufsz = sizeof(buf); |
| 2077 | u32 pwrsave_status; |
| 2078 | |
Emmanuel Grumbach | 1042db2 | 2012-01-03 16:56:15 +0200 | [diff] [blame] | 2079 | pwrsave_status = iwl_read32(trans(priv), CSR_GP_CNTRL) & |
Wey-Yi Guy | c09430a | 2009-10-16 14:25:50 -0700 | [diff] [blame] | 2080 | CSR_GP_REG_POWER_SAVE_STATUS_MSK; |
| 2081 | |
| 2082 | pos += scnprintf(buf + pos, bufsz - pos, "Power Save Status: "); |
| 2083 | pos += scnprintf(buf + pos, bufsz - pos, "%s\n", |
| 2084 | (pwrsave_status == CSR_GP_REG_NO_POWER_SAVE) ? "none" : |
| 2085 | (pwrsave_status == CSR_GP_REG_MAC_POWER_SAVE) ? "MAC" : |
| 2086 | (pwrsave_status == CSR_GP_REG_PHY_POWER_SAVE) ? "PHY" : |
| 2087 | "error"); |
| 2088 | |
| 2089 | return simple_read_from_buffer(user_buf, count, ppos, buf, pos); |
| 2090 | } |
| 2091 | |
Wey-Yi Guy | 7163b8a | 2009-11-20 12:04:56 -0800 | [diff] [blame] | 2092 | 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] | 2093 | const char __user *user_buf, |
| 2094 | size_t count, loff_t *ppos) |
| 2095 | { |
| 2096 | struct iwl_priv *priv = file->private_data; |
| 2097 | char buf[8]; |
| 2098 | int buf_size; |
| 2099 | int clear; |
| 2100 | |
| 2101 | memset(buf, 0, sizeof(buf)); |
| 2102 | buf_size = min(count, sizeof(buf) - 1); |
| 2103 | if (copy_from_user(buf, user_buf, buf_size)) |
| 2104 | return -EFAULT; |
| 2105 | if (sscanf(buf, "%d", &clear) != 1) |
| 2106 | return -EFAULT; |
| 2107 | |
| 2108 | /* make request to uCode to retrieve statistics information */ |
Johannes Berg | b1eea29 | 2012-03-06 13:30:42 -0800 | [diff] [blame^] | 2109 | mutex_lock(&priv->mutex); |
Wey-Yi Guy | ef8d552 | 2009-11-13 11:56:28 -0800 | [diff] [blame] | 2110 | iwl_send_statistics_request(priv, CMD_SYNC, true); |
Johannes Berg | b1eea29 | 2012-03-06 13:30:42 -0800 | [diff] [blame^] | 2111 | mutex_unlock(&priv->mutex); |
Wey-Yi Guy | ef8d552 | 2009-11-13 11:56:28 -0800 | [diff] [blame] | 2112 | |
| 2113 | return count; |
| 2114 | } |
| 2115 | |
Wey-Yi Guy | a9e1cb6 | 2009-12-10 14:37:26 -0800 | [diff] [blame] | 2116 | static ssize_t iwl_dbgfs_ucode_tracing_read(struct file *file, |
| 2117 | char __user *user_buf, |
| 2118 | size_t count, loff_t *ppos) { |
| 2119 | |
Joe Perches | 5767430 | 2010-07-12 13:50:06 -0700 | [diff] [blame] | 2120 | struct iwl_priv *priv = file->private_data; |
Wey-Yi Guy | a9e1cb6 | 2009-12-10 14:37:26 -0800 | [diff] [blame] | 2121 | int pos = 0; |
| 2122 | char buf[128]; |
| 2123 | const size_t bufsz = sizeof(buf); |
Wey-Yi Guy | a9e1cb6 | 2009-12-10 14:37:26 -0800 | [diff] [blame] | 2124 | |
| 2125 | pos += scnprintf(buf + pos, bufsz - pos, "ucode trace timer is %s\n", |
| 2126 | priv->event_log.ucode_trace ? "On" : "Off"); |
| 2127 | pos += scnprintf(buf + pos, bufsz - pos, "non_wraps_count:\t\t %u\n", |
| 2128 | priv->event_log.non_wraps_count); |
| 2129 | pos += scnprintf(buf + pos, bufsz - pos, "wraps_once_count:\t\t %u\n", |
| 2130 | priv->event_log.wraps_once_count); |
| 2131 | pos += scnprintf(buf + pos, bufsz - pos, "wraps_more_count:\t\t %u\n", |
| 2132 | priv->event_log.wraps_more_count); |
| 2133 | |
Wey-Yi Guy | 4967c31 | 2010-02-18 15:22:07 -0800 | [diff] [blame] | 2134 | return simple_read_from_buffer(user_buf, count, ppos, buf, pos); |
Wey-Yi Guy | a9e1cb6 | 2009-12-10 14:37:26 -0800 | [diff] [blame] | 2135 | } |
| 2136 | |
| 2137 | static ssize_t iwl_dbgfs_ucode_tracing_write(struct file *file, |
| 2138 | const char __user *user_buf, |
| 2139 | size_t count, loff_t *ppos) |
| 2140 | { |
| 2141 | struct iwl_priv *priv = file->private_data; |
| 2142 | char buf[8]; |
| 2143 | int buf_size; |
| 2144 | int trace; |
| 2145 | |
| 2146 | memset(buf, 0, sizeof(buf)); |
| 2147 | buf_size = min(count, sizeof(buf) - 1); |
| 2148 | if (copy_from_user(buf, user_buf, buf_size)) |
| 2149 | return -EFAULT; |
| 2150 | if (sscanf(buf, "%d", &trace) != 1) |
| 2151 | return -EFAULT; |
| 2152 | |
| 2153 | if (trace) { |
| 2154 | priv->event_log.ucode_trace = true; |
Johannes Berg | 98d4bf0 | 2012-01-13 11:56:11 +0100 | [diff] [blame] | 2155 | if (iwl_is_alive(priv->shrd)) { |
| 2156 | /* start collecting data now */ |
| 2157 | mod_timer(&priv->ucode_trace, jiffies); |
| 2158 | } |
Wey-Yi Guy | a9e1cb6 | 2009-12-10 14:37:26 -0800 | [diff] [blame] | 2159 | } else { |
| 2160 | priv->event_log.ucode_trace = false; |
| 2161 | del_timer_sync(&priv->ucode_trace); |
| 2162 | } |
| 2163 | |
| 2164 | return count; |
| 2165 | } |
| 2166 | |
Johannes Berg | 6098720 | 2010-02-18 00:36:07 -0800 | [diff] [blame] | 2167 | static ssize_t iwl_dbgfs_rxon_flags_read(struct file *file, |
| 2168 | char __user *user_buf, |
| 2169 | size_t count, loff_t *ppos) { |
| 2170 | |
Joe Perches | 5767430 | 2010-07-12 13:50:06 -0700 | [diff] [blame] | 2171 | struct iwl_priv *priv = file->private_data; |
Johannes Berg | 6098720 | 2010-02-18 00:36:07 -0800 | [diff] [blame] | 2172 | int len = 0; |
| 2173 | char buf[20]; |
| 2174 | |
Johannes Berg | 246ed35 | 2010-08-23 10:46:32 +0200 | [diff] [blame] | 2175 | len = sprintf(buf, "0x%04X\n", |
| 2176 | le32_to_cpu(priv->contexts[IWL_RXON_CTX_BSS].active.flags)); |
Johannes Berg | 6098720 | 2010-02-18 00:36:07 -0800 | [diff] [blame] | 2177 | return simple_read_from_buffer(user_buf, count, ppos, buf, len); |
| 2178 | } |
| 2179 | |
| 2180 | static ssize_t iwl_dbgfs_rxon_filter_flags_read(struct file *file, |
| 2181 | char __user *user_buf, |
| 2182 | size_t count, loff_t *ppos) { |
| 2183 | |
Joe Perches | 5767430 | 2010-07-12 13:50:06 -0700 | [diff] [blame] | 2184 | struct iwl_priv *priv = file->private_data; |
Johannes Berg | 6098720 | 2010-02-18 00:36:07 -0800 | [diff] [blame] | 2185 | int len = 0; |
| 2186 | char buf[20]; |
| 2187 | |
| 2188 | len = sprintf(buf, "0x%04X\n", |
Johannes Berg | 246ed35 | 2010-08-23 10:46:32 +0200 | [diff] [blame] | 2189 | le32_to_cpu(priv->contexts[IWL_RXON_CTX_BSS].active.filter_flags)); |
Johannes Berg | 6098720 | 2010-02-18 00:36:07 -0800 | [diff] [blame] | 2190 | return simple_read_from_buffer(user_buf, count, ppos, buf, len); |
| 2191 | } |
| 2192 | |
Wey-Yi Guy | a13d276 | 2010-01-22 14:22:42 -0800 | [diff] [blame] | 2193 | static ssize_t iwl_dbgfs_missed_beacon_read(struct file *file, |
| 2194 | char __user *user_buf, |
| 2195 | size_t count, loff_t *ppos) { |
| 2196 | |
| 2197 | struct iwl_priv *priv = file->private_data; |
| 2198 | int pos = 0; |
| 2199 | char buf[12]; |
| 2200 | const size_t bufsz = sizeof(buf); |
Wey-Yi Guy | a13d276 | 2010-01-22 14:22:42 -0800 | [diff] [blame] | 2201 | |
| 2202 | pos += scnprintf(buf + pos, bufsz - pos, "%d\n", |
| 2203 | priv->missed_beacon_threshold); |
| 2204 | |
Wey-Yi Guy | 4967c31 | 2010-02-18 15:22:07 -0800 | [diff] [blame] | 2205 | return simple_read_from_buffer(user_buf, count, ppos, buf, pos); |
Wey-Yi Guy | a13d276 | 2010-01-22 14:22:42 -0800 | [diff] [blame] | 2206 | } |
| 2207 | |
| 2208 | static ssize_t iwl_dbgfs_missed_beacon_write(struct file *file, |
| 2209 | const char __user *user_buf, |
| 2210 | size_t count, loff_t *ppos) |
| 2211 | { |
| 2212 | struct iwl_priv *priv = file->private_data; |
| 2213 | char buf[8]; |
| 2214 | int buf_size; |
| 2215 | int missed; |
| 2216 | |
| 2217 | memset(buf, 0, sizeof(buf)); |
| 2218 | buf_size = min(count, sizeof(buf) - 1); |
| 2219 | if (copy_from_user(buf, user_buf, buf_size)) |
| 2220 | return -EFAULT; |
| 2221 | if (sscanf(buf, "%d", &missed) != 1) |
| 2222 | return -EINVAL; |
| 2223 | |
| 2224 | if (missed < IWL_MISSED_BEACON_THRESHOLD_MIN || |
| 2225 | missed > IWL_MISSED_BEACON_THRESHOLD_MAX) |
| 2226 | priv->missed_beacon_threshold = |
| 2227 | IWL_MISSED_BEACON_THRESHOLD_DEF; |
| 2228 | else |
| 2229 | priv->missed_beacon_threshold = missed; |
| 2230 | |
| 2231 | return count; |
| 2232 | } |
| 2233 | |
Trieu 'Andrew' Nguyen | 3e4fb5f | 2010-01-22 14:22:46 -0800 | [diff] [blame] | 2234 | static ssize_t iwl_dbgfs_plcp_delta_read(struct file *file, |
| 2235 | char __user *user_buf, |
| 2236 | size_t count, loff_t *ppos) { |
| 2237 | |
Joe Perches | 5767430 | 2010-07-12 13:50:06 -0700 | [diff] [blame] | 2238 | struct iwl_priv *priv = file->private_data; |
Trieu 'Andrew' Nguyen | 3e4fb5f | 2010-01-22 14:22:46 -0800 | [diff] [blame] | 2239 | int pos = 0; |
| 2240 | char buf[12]; |
| 2241 | const size_t bufsz = sizeof(buf); |
Trieu 'Andrew' Nguyen | 3e4fb5f | 2010-01-22 14:22:46 -0800 | [diff] [blame] | 2242 | |
| 2243 | pos += scnprintf(buf + pos, bufsz - pos, "%u\n", |
Don Fry | 3862241 | 2011-12-16 07:07:36 -0800 | [diff] [blame] | 2244 | cfg(priv)->base_params->plcp_delta_threshold); |
Trieu 'Andrew' Nguyen | 3e4fb5f | 2010-01-22 14:22:46 -0800 | [diff] [blame] | 2245 | |
Wey-Yi Guy | 4967c31 | 2010-02-18 15:22:07 -0800 | [diff] [blame] | 2246 | return simple_read_from_buffer(user_buf, count, ppos, buf, pos); |
Trieu 'Andrew' Nguyen | 3e4fb5f | 2010-01-22 14:22:46 -0800 | [diff] [blame] | 2247 | } |
| 2248 | |
| 2249 | static ssize_t iwl_dbgfs_plcp_delta_write(struct file *file, |
| 2250 | const char __user *user_buf, |
| 2251 | size_t count, loff_t *ppos) { |
| 2252 | |
| 2253 | struct iwl_priv *priv = file->private_data; |
| 2254 | char buf[8]; |
| 2255 | int buf_size; |
| 2256 | int plcp; |
| 2257 | |
| 2258 | memset(buf, 0, sizeof(buf)); |
| 2259 | buf_size = min(count, sizeof(buf) - 1); |
| 2260 | if (copy_from_user(buf, user_buf, buf_size)) |
| 2261 | return -EFAULT; |
| 2262 | if (sscanf(buf, "%d", &plcp) != 1) |
| 2263 | return -EINVAL; |
Wey-Yi Guy | 680788a | 2010-06-17 15:25:00 -0700 | [diff] [blame] | 2264 | if ((plcp < IWL_MAX_PLCP_ERR_THRESHOLD_MIN) || |
Trieu 'Andrew' Nguyen | 3e4fb5f | 2010-01-22 14:22:46 -0800 | [diff] [blame] | 2265 | (plcp > IWL_MAX_PLCP_ERR_THRESHOLD_MAX)) |
Don Fry | 3862241 | 2011-12-16 07:07:36 -0800 | [diff] [blame] | 2266 | cfg(priv)->base_params->plcp_delta_threshold = |
Wey-Yi Guy | 680788a | 2010-06-17 15:25:00 -0700 | [diff] [blame] | 2267 | IWL_MAX_PLCP_ERR_THRESHOLD_DISABLE; |
Trieu 'Andrew' Nguyen | 3e4fb5f | 2010-01-22 14:22:46 -0800 | [diff] [blame] | 2268 | else |
Don Fry | 3862241 | 2011-12-16 07:07:36 -0800 | [diff] [blame] | 2269 | cfg(priv)->base_params->plcp_delta_threshold = plcp; |
Trieu 'Andrew' Nguyen | 3e4fb5f | 2010-01-22 14:22:46 -0800 | [diff] [blame] | 2270 | return count; |
| 2271 | } |
| 2272 | |
Wey-Yi Guy | 528c312 | 2010-02-18 22:03:07 -0800 | [diff] [blame] | 2273 | static ssize_t iwl_dbgfs_force_reset_read(struct file *file, |
| 2274 | char __user *user_buf, |
Johannes Berg | ca934b6 | 2011-09-15 11:46:48 -0700 | [diff] [blame] | 2275 | size_t count, loff_t *ppos) |
| 2276 | { |
Wey-Yi Guy | 528c312 | 2010-02-18 22:03:07 -0800 | [diff] [blame] | 2277 | struct iwl_priv *priv = file->private_data; |
| 2278 | int i, pos = 0; |
| 2279 | char buf[300]; |
| 2280 | const size_t bufsz = sizeof(buf); |
| 2281 | struct iwl_force_reset *force_reset; |
| 2282 | |
| 2283 | for (i = 0; i < IWL_MAX_FORCE_RESET; i++) { |
| 2284 | force_reset = &priv->force_reset[i]; |
| 2285 | pos += scnprintf(buf + pos, bufsz - pos, |
| 2286 | "Force reset method %d\n", i); |
| 2287 | pos += scnprintf(buf + pos, bufsz - pos, |
| 2288 | "\tnumber of reset request: %d\n", |
| 2289 | force_reset->reset_request_count); |
| 2290 | pos += scnprintf(buf + pos, bufsz - pos, |
| 2291 | "\tnumber of reset request success: %d\n", |
| 2292 | force_reset->reset_success_count); |
| 2293 | pos += scnprintf(buf + pos, bufsz - pos, |
| 2294 | "\tnumber of reset request reject: %d\n", |
| 2295 | force_reset->reset_reject_count); |
| 2296 | pos += scnprintf(buf + pos, bufsz - pos, |
| 2297 | "\treset duration: %lu\n", |
| 2298 | force_reset->reset_duration); |
| 2299 | } |
| 2300 | return simple_read_from_buffer(user_buf, count, ppos, buf, pos); |
| 2301 | } |
| 2302 | |
Wey-Yi Guy | 04cafd7 | 2010-02-03 11:47:20 -0800 | [diff] [blame] | 2303 | static ssize_t iwl_dbgfs_force_reset_write(struct file *file, |
| 2304 | const char __user *user_buf, |
| 2305 | size_t count, loff_t *ppos) { |
| 2306 | |
| 2307 | struct iwl_priv *priv = file->private_data; |
| 2308 | char buf[8]; |
| 2309 | int buf_size; |
| 2310 | int reset, ret; |
| 2311 | |
| 2312 | memset(buf, 0, sizeof(buf)); |
| 2313 | buf_size = min(count, sizeof(buf) - 1); |
| 2314 | if (copy_from_user(buf, user_buf, buf_size)) |
| 2315 | return -EFAULT; |
| 2316 | if (sscanf(buf, "%d", &reset) != 1) |
| 2317 | return -EINVAL; |
| 2318 | switch (reset) { |
| 2319 | case IWL_RF_RESET: |
| 2320 | case IWL_FW_RESET: |
Wey-Yi Guy | c04f9f2 | 2010-06-21 16:52:55 -0700 | [diff] [blame] | 2321 | ret = iwl_force_reset(priv, reset, true); |
Wey-Yi Guy | 04cafd7 | 2010-02-03 11:47:20 -0800 | [diff] [blame] | 2322 | break; |
| 2323 | default: |
| 2324 | return -EINVAL; |
| 2325 | } |
| 2326 | return ret ? ret : count; |
| 2327 | } |
| 2328 | |
Wey-Yi Guy | 4bf49a9 | 2010-06-24 13:18:36 -0700 | [diff] [blame] | 2329 | static ssize_t iwl_dbgfs_txfifo_flush_write(struct file *file, |
| 2330 | const char __user *user_buf, |
| 2331 | size_t count, loff_t *ppos) { |
| 2332 | |
| 2333 | struct iwl_priv *priv = file->private_data; |
| 2334 | char buf[8]; |
| 2335 | int buf_size; |
| 2336 | int flush; |
| 2337 | |
| 2338 | memset(buf, 0, sizeof(buf)); |
| 2339 | buf_size = min(count, sizeof(buf) - 1); |
| 2340 | if (copy_from_user(buf, user_buf, buf_size)) |
| 2341 | return -EFAULT; |
| 2342 | if (sscanf(buf, "%d", &flush) != 1) |
| 2343 | return -EINVAL; |
| 2344 | |
Emmanuel Grumbach | 845a9c0 | 2011-08-25 23:11:04 -0700 | [diff] [blame] | 2345 | if (iwl_is_rfkill(priv->shrd)) |
Wey-Yi Guy | 4bf49a9 | 2010-06-24 13:18:36 -0700 | [diff] [blame] | 2346 | return -EFAULT; |
| 2347 | |
Wey-Yi Guy | c68744f | 2011-06-18 08:03:18 -0700 | [diff] [blame] | 2348 | iwlagn_dev_txfifo_flush(priv, IWL_DROP_ALL); |
Wey-Yi Guy | 4bf49a9 | 2010-06-24 13:18:36 -0700 | [diff] [blame] | 2349 | |
| 2350 | return count; |
| 2351 | } |
| 2352 | |
Stanislaw Gruszka | 22de94d | 2010-12-03 15:41:48 +0100 | [diff] [blame] | 2353 | static ssize_t iwl_dbgfs_wd_timeout_write(struct file *file, |
Wey-Yi Guy | 7bdc473 | 2010-08-23 07:57:07 -0700 | [diff] [blame] | 2354 | const char __user *user_buf, |
Johannes Berg | ca934b6 | 2011-09-15 11:46:48 -0700 | [diff] [blame] | 2355 | size_t count, loff_t *ppos) |
| 2356 | { |
Wey-Yi Guy | 7bdc473 | 2010-08-23 07:57:07 -0700 | [diff] [blame] | 2357 | struct iwl_priv *priv = file->private_data; |
| 2358 | char buf[8]; |
| 2359 | int buf_size; |
Stanislaw Gruszka | 22de94d | 2010-12-03 15:41:48 +0100 | [diff] [blame] | 2360 | int timeout; |
Wey-Yi Guy | 7bdc473 | 2010-08-23 07:57:07 -0700 | [diff] [blame] | 2361 | |
| 2362 | memset(buf, 0, sizeof(buf)); |
| 2363 | buf_size = min(count, sizeof(buf) - 1); |
| 2364 | if (copy_from_user(buf, user_buf, buf_size)) |
| 2365 | return -EFAULT; |
Stanislaw Gruszka | 22de94d | 2010-12-03 15:41:48 +0100 | [diff] [blame] | 2366 | if (sscanf(buf, "%d", &timeout) != 1) |
Wey-Yi Guy | 7bdc473 | 2010-08-23 07:57:07 -0700 | [diff] [blame] | 2367 | return -EINVAL; |
Stanislaw Gruszka | 22de94d | 2010-12-03 15:41:48 +0100 | [diff] [blame] | 2368 | if (timeout < 0 || timeout > IWL_MAX_WD_TIMEOUT) |
| 2369 | timeout = IWL_DEF_WD_TIMEOUT; |
Wey-Yi Guy | 7bdc473 | 2010-08-23 07:57:07 -0700 | [diff] [blame] | 2370 | |
Don Fry | 3862241 | 2011-12-16 07:07:36 -0800 | [diff] [blame] | 2371 | cfg(priv)->base_params->wd_timeout = timeout; |
Stanislaw Gruszka | 22de94d | 2010-12-03 15:41:48 +0100 | [diff] [blame] | 2372 | iwl_setup_watchdog(priv); |
Wey-Yi Guy | 7bdc473 | 2010-08-23 07:57:07 -0700 | [diff] [blame] | 2373 | return count; |
| 2374 | } |
| 2375 | |
Wey-Yi Guy | befe8c4 | 2010-08-23 07:57:16 -0700 | [diff] [blame] | 2376 | static ssize_t iwl_dbgfs_bt_traffic_read(struct file *file, |
| 2377 | char __user *user_buf, |
| 2378 | size_t count, loff_t *ppos) { |
| 2379 | |
| 2380 | struct iwl_priv *priv = (struct iwl_priv *)file->private_data; |
| 2381 | int pos = 0; |
| 2382 | char buf[200]; |
| 2383 | const size_t bufsz = sizeof(buf); |
Wey-Yi Guy | befe8c4 | 2010-08-23 07:57:16 -0700 | [diff] [blame] | 2384 | |
Wey-Yi Guy | f21dd00 | 2010-12-08 15:34:52 -0800 | [diff] [blame] | 2385 | if (!priv->bt_enable_flag) { |
| 2386 | pos += scnprintf(buf + pos, bufsz - pos, "BT coex disabled\n"); |
Johannes Berg | 08960de | 2011-04-05 09:41:53 -0700 | [diff] [blame] | 2387 | return simple_read_from_buffer(user_buf, count, ppos, buf, pos); |
Wey-Yi Guy | f21dd00 | 2010-12-08 15:34:52 -0800 | [diff] [blame] | 2388 | } |
| 2389 | pos += scnprintf(buf + pos, bufsz - pos, "BT enable flag: 0x%x\n", |
| 2390 | priv->bt_enable_flag); |
Wey-Yi Guy | befe8c4 | 2010-08-23 07:57:16 -0700 | [diff] [blame] | 2391 | pos += scnprintf(buf + pos, bufsz - pos, "BT in %s mode\n", |
| 2392 | priv->bt_full_concurrent ? "full concurrency" : "3-wire"); |
| 2393 | pos += scnprintf(buf + pos, bufsz - pos, "BT status: %s, " |
| 2394 | "last traffic notif: %d\n", |
Wey-Yi Guy | 66e863a5 | 2010-11-08 14:54:37 -0800 | [diff] [blame] | 2395 | priv->bt_status ? "On" : "Off", priv->last_bt_traffic_load); |
Wey-Yi Guy | befe8c4 | 2010-08-23 07:57:16 -0700 | [diff] [blame] | 2396 | pos += scnprintf(buf + pos, bufsz - pos, "ch_announcement: %d, " |
Wey-Yi Guy | 187bc4f | 2011-01-27 13:01:33 -0800 | [diff] [blame] | 2397 | "kill_ack_mask: %x, kill_cts_mask: %x\n", |
| 2398 | priv->bt_ch_announce, priv->kill_ack_mask, |
| 2399 | priv->kill_cts_mask); |
Wey-Yi Guy | befe8c4 | 2010-08-23 07:57:16 -0700 | [diff] [blame] | 2400 | |
| 2401 | pos += scnprintf(buf + pos, bufsz - pos, "bluetooth traffic load: "); |
| 2402 | switch (priv->bt_traffic_load) { |
| 2403 | case IWL_BT_COEX_TRAFFIC_LOAD_CONTINUOUS: |
| 2404 | pos += scnprintf(buf + pos, bufsz - pos, "Continuous\n"); |
| 2405 | break; |
| 2406 | case IWL_BT_COEX_TRAFFIC_LOAD_HIGH: |
| 2407 | pos += scnprintf(buf + pos, bufsz - pos, "High\n"); |
| 2408 | break; |
| 2409 | case IWL_BT_COEX_TRAFFIC_LOAD_LOW: |
| 2410 | pos += scnprintf(buf + pos, bufsz - pos, "Low\n"); |
| 2411 | break; |
| 2412 | case IWL_BT_COEX_TRAFFIC_LOAD_NONE: |
| 2413 | default: |
| 2414 | pos += scnprintf(buf + pos, bufsz - pos, "None\n"); |
| 2415 | break; |
| 2416 | } |
| 2417 | |
Johannes Berg | 08960de | 2011-04-05 09:41:53 -0700 | [diff] [blame] | 2418 | return simple_read_from_buffer(user_buf, count, ppos, buf, pos); |
Wey-Yi Guy | befe8c4 | 2010-08-23 07:57:16 -0700 | [diff] [blame] | 2419 | } |
| 2420 | |
Wey-Yi Guy | c6abdc0 | 2010-09-01 17:10:51 -0700 | [diff] [blame] | 2421 | static ssize_t iwl_dbgfs_protection_mode_read(struct file *file, |
| 2422 | char __user *user_buf, |
| 2423 | size_t count, loff_t *ppos) |
| 2424 | { |
| 2425 | struct iwl_priv *priv = (struct iwl_priv *)file->private_data; |
| 2426 | |
| 2427 | int pos = 0; |
| 2428 | char buf[40]; |
| 2429 | const size_t bufsz = sizeof(buf); |
| 2430 | |
Don Fry | 3862241 | 2011-12-16 07:07:36 -0800 | [diff] [blame] | 2431 | if (cfg(priv)->ht_params) |
Wey-Yi Guy | 7cb1b08 | 2010-10-06 08:10:00 -0700 | [diff] [blame] | 2432 | pos += scnprintf(buf + pos, bufsz - pos, |
| 2433 | "use %s for aggregation\n", |
Don Fry | 3862241 | 2011-12-16 07:07:36 -0800 | [diff] [blame] | 2434 | (cfg(priv)->ht_params->use_rts_for_aggregation) ? |
Wey-Yi Guy | 7cb1b08 | 2010-10-06 08:10:00 -0700 | [diff] [blame] | 2435 | "rts/cts" : "cts-to-self"); |
| 2436 | else |
| 2437 | pos += scnprintf(buf + pos, bufsz - pos, "N/A"); |
| 2438 | |
Wey-Yi Guy | c6abdc0 | 2010-09-01 17:10:51 -0700 | [diff] [blame] | 2439 | return simple_read_from_buffer(user_buf, count, ppos, buf, pos); |
| 2440 | } |
| 2441 | |
| 2442 | static ssize_t iwl_dbgfs_protection_mode_write(struct file *file, |
| 2443 | const char __user *user_buf, |
| 2444 | size_t count, loff_t *ppos) { |
| 2445 | |
| 2446 | struct iwl_priv *priv = file->private_data; |
| 2447 | char buf[8]; |
| 2448 | int buf_size; |
| 2449 | int rts; |
| 2450 | |
Don Fry | 3862241 | 2011-12-16 07:07:36 -0800 | [diff] [blame] | 2451 | if (!cfg(priv)->ht_params) |
Wey-Yi Guy | 7cb1b08 | 2010-10-06 08:10:00 -0700 | [diff] [blame] | 2452 | return -EINVAL; |
| 2453 | |
Wey-Yi Guy | c6abdc0 | 2010-09-01 17:10:51 -0700 | [diff] [blame] | 2454 | memset(buf, 0, sizeof(buf)); |
| 2455 | buf_size = min(count, sizeof(buf) - 1); |
| 2456 | if (copy_from_user(buf, user_buf, buf_size)) |
| 2457 | return -EFAULT; |
| 2458 | if (sscanf(buf, "%d", &rts) != 1) |
| 2459 | return -EINVAL; |
| 2460 | if (rts) |
Don Fry | 3862241 | 2011-12-16 07:07:36 -0800 | [diff] [blame] | 2461 | cfg(priv)->ht_params->use_rts_for_aggregation = true; |
Wey-Yi Guy | c6abdc0 | 2010-09-01 17:10:51 -0700 | [diff] [blame] | 2462 | else |
Don Fry | 3862241 | 2011-12-16 07:07:36 -0800 | [diff] [blame] | 2463 | cfg(priv)->ht_params->use_rts_for_aggregation = false; |
Wey-Yi Guy | c6abdc0 | 2010-09-01 17:10:51 -0700 | [diff] [blame] | 2464 | return count; |
| 2465 | } |
| 2466 | |
Wey-Yi Guy | 7e4005c | 2011-10-10 07:26:51 -0700 | [diff] [blame] | 2467 | static ssize_t iwl_dbgfs_echo_test_write(struct file *file, |
| 2468 | const char __user *user_buf, |
| 2469 | size_t count, loff_t *ppos) |
| 2470 | { |
| 2471 | struct iwl_priv *priv = file->private_data; |
| 2472 | char buf[8]; |
| 2473 | int buf_size; |
| 2474 | |
| 2475 | memset(buf, 0, sizeof(buf)); |
| 2476 | buf_size = min(count, sizeof(buf) - 1); |
| 2477 | if (copy_from_user(buf, user_buf, buf_size)) |
| 2478 | return -EFAULT; |
| 2479 | |
| 2480 | iwl_cmd_echo_test(priv); |
| 2481 | return count; |
| 2482 | } |
| 2483 | |
Wey-Yi Guy | 7163b8a | 2009-11-20 12:04:56 -0800 | [diff] [blame] | 2484 | DEBUGFS_READ_FILE_OPS(rx_statistics); |
| 2485 | DEBUGFS_READ_FILE_OPS(tx_statistics); |
Emmanuel Grumbach | 41f5e04 | 2011-09-06 09:31:20 -0700 | [diff] [blame] | 2486 | DEBUGFS_READ_WRITE_FILE_OPS(traffic_log); |
Wey-Yi Guy | e8fe59a | 2009-08-07 15:41:42 -0700 | [diff] [blame] | 2487 | DEBUGFS_READ_FILE_OPS(ucode_rx_stats); |
| 2488 | DEBUGFS_READ_FILE_OPS(ucode_tx_stats); |
| 2489 | DEBUGFS_READ_FILE_OPS(ucode_general_stats); |
Wey-Yi Guy | 5225935 | 2009-08-07 15:41:43 -0700 | [diff] [blame] | 2490 | DEBUGFS_READ_FILE_OPS(sensitivity); |
| 2491 | DEBUGFS_READ_FILE_OPS(chain_noise); |
Wey-Yi Guy | c09430a | 2009-10-16 14:25:50 -0700 | [diff] [blame] | 2492 | DEBUGFS_READ_FILE_OPS(power_save_status); |
Wey-Yi Guy | 7163b8a | 2009-11-20 12:04:56 -0800 | [diff] [blame] | 2493 | DEBUGFS_WRITE_FILE_OPS(clear_ucode_statistics); |
| 2494 | DEBUGFS_WRITE_FILE_OPS(clear_traffic_statistics); |
Wey-Yi Guy | a9e1cb6 | 2009-12-10 14:37:26 -0800 | [diff] [blame] | 2495 | DEBUGFS_READ_WRITE_FILE_OPS(ucode_tracing); |
Wey-Yi Guy | a13d276 | 2010-01-22 14:22:42 -0800 | [diff] [blame] | 2496 | DEBUGFS_READ_WRITE_FILE_OPS(missed_beacon); |
Trieu 'Andrew' Nguyen | 3e4fb5f | 2010-01-22 14:22:46 -0800 | [diff] [blame] | 2497 | DEBUGFS_READ_WRITE_FILE_OPS(plcp_delta); |
Wey-Yi Guy | 528c312 | 2010-02-18 22:03:07 -0800 | [diff] [blame] | 2498 | DEBUGFS_READ_WRITE_FILE_OPS(force_reset); |
Johannes Berg | 6098720 | 2010-02-18 00:36:07 -0800 | [diff] [blame] | 2499 | DEBUGFS_READ_FILE_OPS(rxon_flags); |
| 2500 | DEBUGFS_READ_FILE_OPS(rxon_filter_flags); |
Wey-Yi Guy | 4bf49a9 | 2010-06-24 13:18:36 -0700 | [diff] [blame] | 2501 | DEBUGFS_WRITE_FILE_OPS(txfifo_flush); |
Wey-Yi Guy | ffb7d89 | 2010-07-14 08:09:55 -0700 | [diff] [blame] | 2502 | DEBUGFS_READ_FILE_OPS(ucode_bt_stats); |
Stanislaw Gruszka | 22de94d | 2010-12-03 15:41:48 +0100 | [diff] [blame] | 2503 | DEBUGFS_WRITE_FILE_OPS(wd_timeout); |
Wey-Yi Guy | befe8c4 | 2010-08-23 07:57:16 -0700 | [diff] [blame] | 2504 | DEBUGFS_READ_FILE_OPS(bt_traffic); |
Wey-Yi Guy | c6abdc0 | 2010-09-01 17:10:51 -0700 | [diff] [blame] | 2505 | DEBUGFS_READ_WRITE_FILE_OPS(protection_mode); |
Wey-Yi Guy | 54a9aa6 | 2010-09-05 10:49:42 -0700 | [diff] [blame] | 2506 | DEBUGFS_READ_FILE_OPS(reply_tx_error); |
Wey-Yi Guy | 7e4005c | 2011-10-10 07:26:51 -0700 | [diff] [blame] | 2507 | DEBUGFS_WRITE_FILE_OPS(echo_test); |
Wey-Yi Guy | 20594eb | 2009-08-07 15:41:39 -0700 | [diff] [blame] | 2508 | |
Tomas Winkler | 712b6cf | 2008-03-12 16:58:52 -0700 | [diff] [blame] | 2509 | /* |
| 2510 | * Create the debugfs files and directories |
| 2511 | * |
| 2512 | */ |
| 2513 | int iwl_dbgfs_register(struct iwl_priv *priv, const char *name) |
| 2514 | { |
Zhu Yi | 95b1a82 | 2008-05-29 16:34:50 +0800 | [diff] [blame] | 2515 | struct dentry *phyd = priv->hw->wiphy->debugfsdir; |
Johannes Berg | 4c84a8f | 2010-01-22 14:22:54 -0800 | [diff] [blame] | 2516 | struct dentry *dir_drv, *dir_data, *dir_rf, *dir_debug; |
Tomas Winkler | 712b6cf | 2008-03-12 16:58:52 -0700 | [diff] [blame] | 2517 | |
Johannes Berg | 4c84a8f | 2010-01-22 14:22:54 -0800 | [diff] [blame] | 2518 | dir_drv = debugfs_create_dir(name, phyd); |
| 2519 | if (!dir_drv) |
| 2520 | return -ENOMEM; |
| 2521 | |
| 2522 | priv->debugfs_dir = dir_drv; |
| 2523 | |
| 2524 | dir_data = debugfs_create_dir("data", dir_drv); |
| 2525 | if (!dir_data) |
Tomas Winkler | 712b6cf | 2008-03-12 16:58:52 -0700 | [diff] [blame] | 2526 | goto err; |
Johannes Berg | 4c84a8f | 2010-01-22 14:22:54 -0800 | [diff] [blame] | 2527 | dir_rf = debugfs_create_dir("rf", dir_drv); |
| 2528 | if (!dir_rf) |
Tomas Winkler | 712b6cf | 2008-03-12 16:58:52 -0700 | [diff] [blame] | 2529 | goto err; |
Johannes Berg | 4c84a8f | 2010-01-22 14:22:54 -0800 | [diff] [blame] | 2530 | dir_debug = debugfs_create_dir("debug", dir_drv); |
| 2531 | if (!dir_debug) |
| 2532 | goto err; |
Tomas Winkler | 712b6cf | 2008-03-12 16:58:52 -0700 | [diff] [blame] | 2533 | |
Johannes Berg | 4c84a8f | 2010-01-22 14:22:54 -0800 | [diff] [blame] | 2534 | DEBUGFS_ADD_FILE(nvm, dir_data, S_IRUSR); |
| 2535 | DEBUGFS_ADD_FILE(sram, dir_data, S_IWUSR | S_IRUSR); |
Johannes Berg | c8ac61c | 2011-07-15 13:23:45 -0700 | [diff] [blame] | 2536 | DEBUGFS_ADD_FILE(wowlan_sram, dir_data, S_IRUSR); |
Johannes Berg | 4c84a8f | 2010-01-22 14:22:54 -0800 | [diff] [blame] | 2537 | DEBUGFS_ADD_FILE(stations, dir_data, S_IRUSR); |
| 2538 | DEBUGFS_ADD_FILE(channels, dir_data, S_IRUSR); |
| 2539 | DEBUGFS_ADD_FILE(status, dir_data, S_IRUSR); |
Emmanuel Grumbach | 1f7b617 | 2011-08-25 23:10:59 -0700 | [diff] [blame] | 2540 | DEBUGFS_ADD_FILE(rx_handlers, dir_data, S_IWUSR | S_IRUSR); |
Johannes Berg | 4c84a8f | 2010-01-22 14:22:54 -0800 | [diff] [blame] | 2541 | DEBUGFS_ADD_FILE(qos, dir_data, S_IRUSR); |
Wey-Yi Guy | 23c0fcc | 2011-04-01 16:29:53 -0700 | [diff] [blame] | 2542 | DEBUGFS_ADD_FILE(sleep_level_override, dir_data, S_IWUSR | S_IRUSR); |
| 2543 | DEBUGFS_ADD_FILE(current_sleep_command, dir_data, S_IRUSR); |
Johannes Berg | 4c84a8f | 2010-01-22 14:22:54 -0800 | [diff] [blame] | 2544 | DEBUGFS_ADD_FILE(thermal_throttling, dir_data, S_IRUSR); |
| 2545 | DEBUGFS_ADD_FILE(disable_ht40, dir_data, S_IWUSR | S_IRUSR); |
Emmanuel Grumbach | 511afa3 | 2011-09-22 07:15:37 -0700 | [diff] [blame] | 2546 | DEBUGFS_ADD_FILE(temperature, dir_data, S_IRUSR); |
Johannes Berg | ca934b6 | 2011-09-15 11:46:48 -0700 | [diff] [blame] | 2547 | |
Johannes Berg | 4c84a8f | 2010-01-22 14:22:54 -0800 | [diff] [blame] | 2548 | DEBUGFS_ADD_FILE(rx_statistics, dir_debug, S_IRUSR); |
| 2549 | DEBUGFS_ADD_FILE(tx_statistics, dir_debug, S_IRUSR); |
Emmanuel Grumbach | 41f5e04 | 2011-09-06 09:31:20 -0700 | [diff] [blame] | 2550 | DEBUGFS_ADD_FILE(traffic_log, dir_debug, S_IWUSR | S_IRUSR); |
Johannes Berg | 4c84a8f | 2010-01-22 14:22:54 -0800 | [diff] [blame] | 2551 | DEBUGFS_ADD_FILE(power_save_status, dir_debug, S_IRUSR); |
| 2552 | DEBUGFS_ADD_FILE(clear_ucode_statistics, dir_debug, S_IWUSR); |
| 2553 | DEBUGFS_ADD_FILE(clear_traffic_statistics, dir_debug, S_IWUSR); |
Johannes Berg | 4c84a8f | 2010-01-22 14:22:54 -0800 | [diff] [blame] | 2554 | DEBUGFS_ADD_FILE(missed_beacon, dir_debug, S_IWUSR); |
Johannes Berg | 4c84a8f | 2010-01-22 14:22:54 -0800 | [diff] [blame] | 2555 | DEBUGFS_ADD_FILE(plcp_delta, dir_debug, S_IWUSR | S_IRUSR); |
Wey-Yi Guy | 528c312 | 2010-02-18 22:03:07 -0800 | [diff] [blame] | 2556 | DEBUGFS_ADD_FILE(force_reset, dir_debug, S_IWUSR | S_IRUSR); |
Abhijeet Kolekar | b8c7626 | 2010-04-08 15:29:07 -0700 | [diff] [blame] | 2557 | DEBUGFS_ADD_FILE(ucode_rx_stats, dir_debug, S_IRUSR); |
| 2558 | DEBUGFS_ADD_FILE(ucode_tx_stats, dir_debug, S_IRUSR); |
| 2559 | DEBUGFS_ADD_FILE(ucode_general_stats, dir_debug, S_IRUSR); |
Wey-Yi Guy | c68744f | 2011-06-18 08:03:18 -0700 | [diff] [blame] | 2560 | DEBUGFS_ADD_FILE(txfifo_flush, dir_debug, S_IWUSR); |
Wey-Yi Guy | c6abdc0 | 2010-09-01 17:10:51 -0700 | [diff] [blame] | 2561 | DEBUGFS_ADD_FILE(protection_mode, dir_debug, S_IWUSR | S_IRUSR); |
Wey-Yi Guy | 703bc58 | 2011-04-03 08:14:41 -0700 | [diff] [blame] | 2562 | DEBUGFS_ADD_FILE(sensitivity, dir_debug, S_IRUSR); |
| 2563 | DEBUGFS_ADD_FILE(chain_noise, dir_debug, S_IRUSR); |
Wey-Yi Guy | b7af6a9 | 2011-04-06 15:55:25 -0700 | [diff] [blame] | 2564 | DEBUGFS_ADD_FILE(ucode_tracing, dir_debug, S_IWUSR | S_IRUSR); |
Johannes Berg | 0da0e5b | 2011-04-08 08:14:56 -0700 | [diff] [blame] | 2565 | DEBUGFS_ADD_FILE(ucode_bt_stats, dir_debug, S_IRUSR); |
Wey-Yi Guy | 54a9aa6 | 2010-09-05 10:49:42 -0700 | [diff] [blame] | 2566 | DEBUGFS_ADD_FILE(reply_tx_error, dir_debug, S_IRUSR); |
Johannes Berg | 6098720 | 2010-02-18 00:36:07 -0800 | [diff] [blame] | 2567 | DEBUGFS_ADD_FILE(rxon_flags, dir_debug, S_IWUSR); |
| 2568 | DEBUGFS_ADD_FILE(rxon_filter_flags, dir_debug, S_IWUSR); |
Stanislaw Gruszka | 22de94d | 2010-12-03 15:41:48 +0100 | [diff] [blame] | 2569 | DEBUGFS_ADD_FILE(wd_timeout, dir_debug, S_IWUSR); |
Wey-Yi Guy | 7e4005c | 2011-10-10 07:26:51 -0700 | [diff] [blame] | 2570 | DEBUGFS_ADD_FILE(echo_test, dir_debug, S_IWUSR); |
Stanislaw Gruszka | 88e58fc | 2011-01-28 16:47:47 +0100 | [diff] [blame] | 2571 | if (iwl_advanced_bt_coexist(priv)) |
Wey-Yi Guy | befe8c4 | 2010-08-23 07:57:16 -0700 | [diff] [blame] | 2572 | DEBUGFS_ADD_FILE(bt_traffic, dir_debug, S_IRUSR); |
Johannes Berg | ca934b6 | 2011-09-15 11:46:48 -0700 | [diff] [blame] | 2573 | |
Wey-Yi Guy | 703bc58 | 2011-04-03 08:14:41 -0700 | [diff] [blame] | 2574 | DEBUGFS_ADD_BOOL(disable_sensitivity, dir_rf, |
| 2575 | &priv->disable_sens_cal); |
| 2576 | DEBUGFS_ADD_BOOL(disable_chain_noise, dir_rf, |
| 2577 | &priv->disable_chain_noise_cal); |
Emmanuel Grumbach | 87e5666 | 2011-08-25 23:10:50 -0700 | [diff] [blame] | 2578 | |
| 2579 | if (iwl_trans_dbgfs_register(trans(priv), dir_debug)) |
| 2580 | goto err; |
Tomas Winkler | 712b6cf | 2008-03-12 16:58:52 -0700 | [diff] [blame] | 2581 | return 0; |
| 2582 | |
| 2583 | err: |
Johannes Berg | 4c84a8f | 2010-01-22 14:22:54 -0800 | [diff] [blame] | 2584 | IWL_ERR(priv, "Can't create the debugfs directory\n"); |
Tomas Winkler | 712b6cf | 2008-03-12 16:58:52 -0700 | [diff] [blame] | 2585 | iwl_dbgfs_unregister(priv); |
Johannes Berg | 4c84a8f | 2010-01-22 14:22:54 -0800 | [diff] [blame] | 2586 | return -ENOMEM; |
Tomas Winkler | 712b6cf | 2008-03-12 16:58:52 -0700 | [diff] [blame] | 2587 | } |
Tomas Winkler | 712b6cf | 2008-03-12 16:58:52 -0700 | [diff] [blame] | 2588 | |
| 2589 | /** |
| 2590 | * Remove the debugfs files and directories |
| 2591 | * |
| 2592 | */ |
| 2593 | void iwl_dbgfs_unregister(struct iwl_priv *priv) |
| 2594 | { |
Johannes Berg | 4c84a8f | 2010-01-22 14:22:54 -0800 | [diff] [blame] | 2595 | if (!priv->debugfs_dir) |
Tomas Winkler | 712b6cf | 2008-03-12 16:58:52 -0700 | [diff] [blame] | 2596 | return; |
| 2597 | |
Johannes Berg | 4c84a8f | 2010-01-22 14:22:54 -0800 | [diff] [blame] | 2598 | debugfs_remove_recursive(priv->debugfs_dir); |
| 2599 | priv->debugfs_dir = NULL; |
Tomas Winkler | 712b6cf | 2008-03-12 16:58:52 -0700 | [diff] [blame] | 2600 | } |