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