Tomas Winkler | 712b6cf | 2008-03-12 16:58:52 -0700 | [diff] [blame] | 1 | /****************************************************************************** |
| 2 | * |
| 3 | * GPL LICENSE SUMMARY |
| 4 | * |
Reinette Chatre | 1f44780 | 2010-01-15 13:43:41 -0800 | [diff] [blame] | 5 | * Copyright(c) 2008 - 2010 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" |
Tomas Winkler | 712b6cf | 2008-03-12 16:58:52 -0700 | [diff] [blame] | 42 | |
| 43 | /* create and remove of files */ |
Johannes Berg | 4c84a8f | 2010-01-22 14:22:54 -0800 | [diff] [blame] | 44 | #define DEBUGFS_ADD_FILE(name, parent, mode) do { \ |
| 45 | if (!debugfs_create_file(#name, mode, parent, priv, \ |
| 46 | &iwl_dbgfs_##name##_ops)) \ |
| 47 | goto err; \ |
Tomas Winkler | 712b6cf | 2008-03-12 16:58:52 -0700 | [diff] [blame] | 48 | } while (0) |
| 49 | |
Johannes Berg | 4c84a8f | 2010-01-22 14:22:54 -0800 | [diff] [blame] | 50 | #define DEBUGFS_ADD_BOOL(name, parent, ptr) do { \ |
| 51 | struct dentry *__tmp; \ |
| 52 | __tmp = debugfs_create_bool(#name, S_IWUSR | S_IRUSR, \ |
| 53 | parent, ptr); \ |
| 54 | if (IS_ERR(__tmp) || !__tmp) \ |
| 55 | goto err; \ |
Tomas Winkler | 712b6cf | 2008-03-12 16:58:52 -0700 | [diff] [blame] | 56 | } while (0) |
| 57 | |
Johannes Berg | 4c84a8f | 2010-01-22 14:22:54 -0800 | [diff] [blame] | 58 | #define DEBUGFS_ADD_X32(name, parent, ptr) do { \ |
| 59 | struct dentry *__tmp; \ |
| 60 | __tmp = debugfs_create_x32(#name, S_IWUSR | S_IRUSR, \ |
| 61 | parent, ptr); \ |
| 62 | if (IS_ERR(__tmp) || !__tmp) \ |
| 63 | goto err; \ |
Tomas Winkler | 445c2df | 2008-05-15 13:54:16 +0800 | [diff] [blame] | 64 | } while (0) |
| 65 | |
Tomas Winkler | 712b6cf | 2008-03-12 16:58:52 -0700 | [diff] [blame] | 66 | /* file operation */ |
| 67 | #define DEBUGFS_READ_FUNC(name) \ |
| 68 | static ssize_t iwl_dbgfs_##name##_read(struct file *file, \ |
| 69 | char __user *user_buf, \ |
| 70 | size_t count, loff_t *ppos); |
| 71 | |
| 72 | #define DEBUGFS_WRITE_FUNC(name) \ |
| 73 | static ssize_t iwl_dbgfs_##name##_write(struct file *file, \ |
| 74 | const char __user *user_buf, \ |
| 75 | size_t count, loff_t *ppos); |
| 76 | |
| 77 | |
| 78 | static int iwl_dbgfs_open_file_generic(struct inode *inode, struct file *file) |
| 79 | { |
| 80 | file->private_data = inode->i_private; |
| 81 | return 0; |
| 82 | } |
| 83 | |
| 84 | #define DEBUGFS_READ_FILE_OPS(name) \ |
| 85 | DEBUGFS_READ_FUNC(name); \ |
| 86 | static const struct file_operations iwl_dbgfs_##name##_ops = { \ |
| 87 | .read = iwl_dbgfs_##name##_read, \ |
| 88 | .open = iwl_dbgfs_open_file_generic, \ |
Arnd Bergmann | 2b18ab36 | 2010-07-06 19:05:31 +0200 | [diff] [blame] | 89 | .llseek = generic_file_llseek, \ |
Tomas Winkler | 712b6cf | 2008-03-12 16:58:52 -0700 | [diff] [blame] | 90 | }; |
| 91 | |
Ester Kummer | 189a2b5 | 2008-05-15 13:54:18 +0800 | [diff] [blame] | 92 | #define DEBUGFS_WRITE_FILE_OPS(name) \ |
| 93 | DEBUGFS_WRITE_FUNC(name); \ |
| 94 | static const struct file_operations iwl_dbgfs_##name##_ops = { \ |
| 95 | .write = iwl_dbgfs_##name##_write, \ |
| 96 | .open = iwl_dbgfs_open_file_generic, \ |
Arnd Bergmann | 2b18ab36 | 2010-07-06 19:05:31 +0200 | [diff] [blame] | 97 | .llseek = generic_file_llseek, \ |
Ester Kummer | 189a2b5 | 2008-05-15 13:54:18 +0800 | [diff] [blame] | 98 | }; |
| 99 | |
| 100 | |
Tomas Winkler | 712b6cf | 2008-03-12 16:58:52 -0700 | [diff] [blame] | 101 | #define DEBUGFS_READ_WRITE_FILE_OPS(name) \ |
| 102 | DEBUGFS_READ_FUNC(name); \ |
| 103 | DEBUGFS_WRITE_FUNC(name); \ |
| 104 | static const struct file_operations iwl_dbgfs_##name##_ops = { \ |
| 105 | .write = iwl_dbgfs_##name##_write, \ |
| 106 | .read = iwl_dbgfs_##name##_read, \ |
| 107 | .open = iwl_dbgfs_open_file_generic, \ |
Arnd Bergmann | 2b18ab36 | 2010-07-06 19:05:31 +0200 | [diff] [blame] | 108 | .llseek = generic_file_llseek, \ |
Tomas Winkler | 712b6cf | 2008-03-12 16:58:52 -0700 | [diff] [blame] | 109 | }; |
| 110 | |
Tomas Winkler | 712b6cf | 2008-03-12 16:58:52 -0700 | [diff] [blame] | 111 | static ssize_t iwl_dbgfs_tx_statistics_read(struct file *file, |
| 112 | char __user *user_buf, |
| 113 | size_t count, loff_t *ppos) { |
| 114 | |
H Hartley Sweeten | 28f63a4 | 2010-01-08 16:14:10 -0700 | [diff] [blame] | 115 | struct iwl_priv *priv = file->private_data; |
Wey-Yi Guy | 22fdf3c | 2009-08-07 15:41:40 -0700 | [diff] [blame] | 116 | char *buf; |
Tomas Winkler | 712b6cf | 2008-03-12 16:58:52 -0700 | [diff] [blame] | 117 | int pos = 0; |
| 118 | |
Wey-Yi Guy | 22fdf3c | 2009-08-07 15:41:40 -0700 | [diff] [blame] | 119 | int cnt; |
| 120 | ssize_t ret; |
Wey-Yi Guy | 98a7b43 | 2009-11-13 11:56:31 -0800 | [diff] [blame] | 121 | const size_t bufsz = 100 + |
| 122 | sizeof(char) * 50 * (MANAGEMENT_MAX + CONTROL_MAX); |
Wey-Yi Guy | 22fdf3c | 2009-08-07 15:41:40 -0700 | [diff] [blame] | 123 | buf = kzalloc(bufsz, GFP_KERNEL); |
| 124 | if (!buf) |
| 125 | return -ENOMEM; |
| 126 | pos += scnprintf(buf + pos, bufsz - pos, "Management:\n"); |
| 127 | for (cnt = 0; cnt < MANAGEMENT_MAX; cnt++) { |
| 128 | pos += scnprintf(buf + pos, bufsz - pos, |
Wey-Yi Guy | 98a7b43 | 2009-11-13 11:56:31 -0800 | [diff] [blame] | 129 | "\t%25s\t\t: %u\n", |
Wey-Yi Guy | 22fdf3c | 2009-08-07 15:41:40 -0700 | [diff] [blame] | 130 | get_mgmt_string(cnt), |
| 131 | priv->tx_stats.mgmt[cnt]); |
| 132 | } |
| 133 | pos += scnprintf(buf + pos, bufsz - pos, "Control\n"); |
| 134 | for (cnt = 0; cnt < CONTROL_MAX; cnt++) { |
| 135 | pos += scnprintf(buf + pos, bufsz - pos, |
Wey-Yi Guy | 98a7b43 | 2009-11-13 11:56:31 -0800 | [diff] [blame] | 136 | "\t%25s\t\t: %u\n", |
Wey-Yi Guy | 22fdf3c | 2009-08-07 15:41:40 -0700 | [diff] [blame] | 137 | get_ctrl_string(cnt), |
| 138 | priv->tx_stats.ctrl[cnt]); |
| 139 | } |
| 140 | pos += scnprintf(buf + pos, bufsz - pos, "Data:\n"); |
| 141 | pos += scnprintf(buf + pos, bufsz - pos, "\tcnt: %u\n", |
| 142 | priv->tx_stats.data_cnt); |
| 143 | pos += scnprintf(buf + pos, bufsz - pos, "\tbytes: %llu\n", |
| 144 | priv->tx_stats.data_bytes); |
| 145 | ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos); |
| 146 | kfree(buf); |
| 147 | return ret; |
| 148 | } |
Tomas Winkler | 712b6cf | 2008-03-12 16:58:52 -0700 | [diff] [blame] | 149 | |
Wey-Yi Guy | 7163b8a | 2009-11-20 12:04:56 -0800 | [diff] [blame] | 150 | 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] | 151 | const char __user *user_buf, |
| 152 | size_t count, loff_t *ppos) |
| 153 | { |
| 154 | struct iwl_priv *priv = file->private_data; |
| 155 | u32 clear_flag; |
| 156 | char buf[8]; |
| 157 | int buf_size; |
| 158 | |
| 159 | memset(buf, 0, sizeof(buf)); |
| 160 | buf_size = min(count, sizeof(buf) - 1); |
| 161 | if (copy_from_user(buf, user_buf, buf_size)) |
| 162 | return -EFAULT; |
| 163 | if (sscanf(buf, "%x", &clear_flag) != 1) |
| 164 | return -EFAULT; |
Wey-Yi Guy | 7163b8a | 2009-11-20 12:04:56 -0800 | [diff] [blame] | 165 | iwl_clear_traffic_stats(priv); |
Wey-Yi Guy | 22fdf3c | 2009-08-07 15:41:40 -0700 | [diff] [blame] | 166 | |
| 167 | return count; |
Tomas Winkler | 712b6cf | 2008-03-12 16:58:52 -0700 | [diff] [blame] | 168 | } |
| 169 | |
| 170 | static ssize_t iwl_dbgfs_rx_statistics_read(struct file *file, |
| 171 | char __user *user_buf, |
| 172 | size_t count, loff_t *ppos) { |
| 173 | |
H Hartley Sweeten | 28f63a4 | 2010-01-08 16:14:10 -0700 | [diff] [blame] | 174 | struct iwl_priv *priv = file->private_data; |
Wey-Yi Guy | 22fdf3c | 2009-08-07 15:41:40 -0700 | [diff] [blame] | 175 | char *buf; |
Tomas Winkler | 712b6cf | 2008-03-12 16:58:52 -0700 | [diff] [blame] | 176 | int pos = 0; |
Wey-Yi Guy | 22fdf3c | 2009-08-07 15:41:40 -0700 | [diff] [blame] | 177 | int cnt; |
| 178 | ssize_t ret; |
| 179 | const size_t bufsz = 100 + |
Wey-Yi Guy | 98a7b43 | 2009-11-13 11:56:31 -0800 | [diff] [blame] | 180 | sizeof(char) * 50 * (MANAGEMENT_MAX + CONTROL_MAX); |
Wey-Yi Guy | 22fdf3c | 2009-08-07 15:41:40 -0700 | [diff] [blame] | 181 | buf = kzalloc(bufsz, GFP_KERNEL); |
| 182 | if (!buf) |
| 183 | return -ENOMEM; |
Tomas Winkler | 712b6cf | 2008-03-12 16:58:52 -0700 | [diff] [blame] | 184 | |
Wey-Yi Guy | 22fdf3c | 2009-08-07 15:41:40 -0700 | [diff] [blame] | 185 | pos += scnprintf(buf + pos, bufsz - pos, "Management:\n"); |
| 186 | for (cnt = 0; cnt < MANAGEMENT_MAX; cnt++) { |
| 187 | pos += scnprintf(buf + pos, bufsz - pos, |
Wey-Yi Guy | 98a7b43 | 2009-11-13 11:56:31 -0800 | [diff] [blame] | 188 | "\t%25s\t\t: %u\n", |
Wey-Yi Guy | 22fdf3c | 2009-08-07 15:41:40 -0700 | [diff] [blame] | 189 | get_mgmt_string(cnt), |
| 190 | priv->rx_stats.mgmt[cnt]); |
| 191 | } |
| 192 | pos += scnprintf(buf + pos, bufsz - pos, "Control:\n"); |
| 193 | for (cnt = 0; cnt < CONTROL_MAX; cnt++) { |
| 194 | pos += scnprintf(buf + pos, bufsz - pos, |
Wey-Yi Guy | 98a7b43 | 2009-11-13 11:56:31 -0800 | [diff] [blame] | 195 | "\t%25s\t\t: %u\n", |
Wey-Yi Guy | 22fdf3c | 2009-08-07 15:41:40 -0700 | [diff] [blame] | 196 | get_ctrl_string(cnt), |
| 197 | priv->rx_stats.ctrl[cnt]); |
| 198 | } |
| 199 | pos += scnprintf(buf + pos, bufsz - pos, "Data:\n"); |
| 200 | pos += scnprintf(buf + pos, bufsz - pos, "\tcnt: %u\n", |
| 201 | priv->rx_stats.data_cnt); |
| 202 | pos += scnprintf(buf + pos, bufsz - pos, "\tbytes: %llu\n", |
| 203 | priv->rx_stats.data_bytes); |
Tomas Winkler | 712b6cf | 2008-03-12 16:58:52 -0700 | [diff] [blame] | 204 | |
Wey-Yi Guy | 22fdf3c | 2009-08-07 15:41:40 -0700 | [diff] [blame] | 205 | ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos); |
| 206 | kfree(buf); |
| 207 | return ret; |
| 208 | } |
| 209 | |
Tomas Winkler | 712b6cf | 2008-03-12 16:58:52 -0700 | [diff] [blame] | 210 | #define BYTE1_MASK 0x000000ff; |
| 211 | #define BYTE2_MASK 0x0000ffff; |
| 212 | #define BYTE3_MASK 0x00ffffff; |
| 213 | static ssize_t iwl_dbgfs_sram_read(struct file *file, |
| 214 | char __user *user_buf, |
| 215 | size_t count, loff_t *ppos) |
| 216 | { |
| 217 | u32 val; |
Wey-Yi Guy | 2943f13 | 2009-11-20 12:05:00 -0800 | [diff] [blame] | 218 | char *buf; |
Tomas Winkler | 712b6cf | 2008-03-12 16:58:52 -0700 | [diff] [blame] | 219 | ssize_t ret; |
| 220 | int i; |
| 221 | int pos = 0; |
H Hartley Sweeten | 28f63a4 | 2010-01-08 16:14:10 -0700 | [diff] [blame] | 222 | struct iwl_priv *priv = file->private_data; |
Wey-Yi Guy | 2943f13 | 2009-11-20 12:05:00 -0800 | [diff] [blame] | 223 | size_t bufsz; |
Tomas Winkler | 712b6cf | 2008-03-12 16:58:52 -0700 | [diff] [blame] | 224 | |
Wey-Yi Guy | 5ade1e4 | 2009-11-20 12:05:04 -0800 | [diff] [blame] | 225 | /* default is to dump the entire data segment */ |
Johannes Berg | 4c84a8f | 2010-01-22 14:22:54 -0800 | [diff] [blame] | 226 | if (!priv->dbgfs_sram_offset && !priv->dbgfs_sram_len) { |
| 227 | priv->dbgfs_sram_offset = 0x800000; |
Wey-Yi Guy | 5ade1e4 | 2009-11-20 12:05:04 -0800 | [diff] [blame] | 228 | if (priv->ucode_type == UCODE_INIT) |
Johannes Berg | 4c84a8f | 2010-01-22 14:22:54 -0800 | [diff] [blame] | 229 | priv->dbgfs_sram_len = priv->ucode_init_data.len; |
Wey-Yi Guy | 5ade1e4 | 2009-11-20 12:05:04 -0800 | [diff] [blame] | 230 | else |
Johannes Berg | 4c84a8f | 2010-01-22 14:22:54 -0800 | [diff] [blame] | 231 | priv->dbgfs_sram_len = priv->ucode_data.len; |
Wey-Yi Guy | 5ade1e4 | 2009-11-20 12:05:04 -0800 | [diff] [blame] | 232 | } |
Johannes Berg | 4c84a8f | 2010-01-22 14:22:54 -0800 | [diff] [blame] | 233 | bufsz = 30 + priv->dbgfs_sram_len * sizeof(char) * 10; |
Wey-Yi Guy | 2943f13 | 2009-11-20 12:05:00 -0800 | [diff] [blame] | 234 | buf = kmalloc(bufsz, GFP_KERNEL); |
| 235 | if (!buf) |
| 236 | return -ENOMEM; |
Wey-Yi Guy | 5ade1e4 | 2009-11-20 12:05:04 -0800 | [diff] [blame] | 237 | pos += scnprintf(buf + pos, bufsz - pos, "sram_len: 0x%x\n", |
Johannes Berg | 4c84a8f | 2010-01-22 14:22:54 -0800 | [diff] [blame] | 238 | priv->dbgfs_sram_len); |
Wey-Yi Guy | 5ade1e4 | 2009-11-20 12:05:04 -0800 | [diff] [blame] | 239 | pos += scnprintf(buf + pos, bufsz - pos, "sram_offset: 0x%x\n", |
Johannes Berg | 4c84a8f | 2010-01-22 14:22:54 -0800 | [diff] [blame] | 240 | priv->dbgfs_sram_offset); |
| 241 | for (i = priv->dbgfs_sram_len; i > 0; i -= 4) { |
| 242 | val = iwl_read_targ_mem(priv, priv->dbgfs_sram_offset + \ |
| 243 | priv->dbgfs_sram_len - i); |
Tomas Winkler | 712b6cf | 2008-03-12 16:58:52 -0700 | [diff] [blame] | 244 | if (i < 4) { |
| 245 | switch (i) { |
| 246 | case 1: |
| 247 | val &= BYTE1_MASK; |
| 248 | break; |
| 249 | case 2: |
| 250 | val &= BYTE2_MASK; |
| 251 | break; |
| 252 | case 3: |
| 253 | val &= BYTE3_MASK; |
| 254 | break; |
| 255 | } |
| 256 | } |
Wey-Yi Guy | 2943f13 | 2009-11-20 12:05:00 -0800 | [diff] [blame] | 257 | if (!(i % 16)) |
| 258 | pos += scnprintf(buf + pos, bufsz - pos, "\n"); |
Abhijeet Kolekar | db0589f | 2008-04-14 21:16:04 -0700 | [diff] [blame] | 259 | pos += scnprintf(buf + pos, bufsz - pos, "0x%08x ", val); |
Tomas Winkler | 712b6cf | 2008-03-12 16:58:52 -0700 | [diff] [blame] | 260 | } |
Abhijeet Kolekar | db0589f | 2008-04-14 21:16:04 -0700 | [diff] [blame] | 261 | pos += scnprintf(buf + pos, bufsz - pos, "\n"); |
Tomas Winkler | 712b6cf | 2008-03-12 16:58:52 -0700 | [diff] [blame] | 262 | |
| 263 | ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos); |
Wey-Yi Guy | 2943f13 | 2009-11-20 12:05:00 -0800 | [diff] [blame] | 264 | kfree(buf); |
Tomas Winkler | 712b6cf | 2008-03-12 16:58:52 -0700 | [diff] [blame] | 265 | return ret; |
| 266 | } |
| 267 | |
| 268 | static ssize_t iwl_dbgfs_sram_write(struct file *file, |
| 269 | const char __user *user_buf, |
| 270 | size_t count, loff_t *ppos) |
| 271 | { |
| 272 | struct iwl_priv *priv = file->private_data; |
| 273 | char buf[64]; |
| 274 | int buf_size; |
| 275 | u32 offset, len; |
| 276 | |
| 277 | memset(buf, 0, sizeof(buf)); |
| 278 | buf_size = min(count, sizeof(buf) - 1); |
| 279 | if (copy_from_user(buf, user_buf, buf_size)) |
| 280 | return -EFAULT; |
| 281 | |
| 282 | if (sscanf(buf, "%x,%x", &offset, &len) == 2) { |
Johannes Berg | 4c84a8f | 2010-01-22 14:22:54 -0800 | [diff] [blame] | 283 | priv->dbgfs_sram_offset = offset; |
| 284 | priv->dbgfs_sram_len = len; |
Tomas Winkler | 712b6cf | 2008-03-12 16:58:52 -0700 | [diff] [blame] | 285 | } else { |
Johannes Berg | 4c84a8f | 2010-01-22 14:22:54 -0800 | [diff] [blame] | 286 | priv->dbgfs_sram_offset = 0; |
| 287 | priv->dbgfs_sram_len = 0; |
Tomas Winkler | 712b6cf | 2008-03-12 16:58:52 -0700 | [diff] [blame] | 288 | } |
| 289 | |
| 290 | return count; |
| 291 | } |
| 292 | |
| 293 | static ssize_t iwl_dbgfs_stations_read(struct file *file, char __user *user_buf, |
| 294 | size_t count, loff_t *ppos) |
| 295 | { |
H Hartley Sweeten | 28f63a4 | 2010-01-08 16:14:10 -0700 | [diff] [blame] | 296 | struct iwl_priv *priv = file->private_data; |
Tomas Winkler | 6def976 | 2008-05-05 10:22:31 +0800 | [diff] [blame] | 297 | struct iwl_station_entry *station; |
Tomas Winkler | 5425e49 | 2008-04-15 16:01:38 -0700 | [diff] [blame] | 298 | int max_sta = priv->hw_params.max_stations; |
Tomas Winkler | 712b6cf | 2008-03-12 16:58:52 -0700 | [diff] [blame] | 299 | char *buf; |
| 300 | int i, j, pos = 0; |
| 301 | ssize_t ret; |
| 302 | /* Add 30 for initial string */ |
| 303 | const size_t bufsz = 30 + sizeof(char) * 500 * (priv->num_stations); |
Tomas Winkler | 712b6cf | 2008-03-12 16:58:52 -0700 | [diff] [blame] | 304 | |
| 305 | buf = kmalloc(bufsz, GFP_KERNEL); |
Tomas Winkler | 3ac7f14 | 2008-07-21 02:40:14 +0300 | [diff] [blame] | 306 | if (!buf) |
Tomas Winkler | 712b6cf | 2008-03-12 16:58:52 -0700 | [diff] [blame] | 307 | return -ENOMEM; |
| 308 | |
Abhijeet Kolekar | db0589f | 2008-04-14 21:16:04 -0700 | [diff] [blame] | 309 | pos += scnprintf(buf + pos, bufsz - pos, "num of stations: %d\n\n", |
Tomas Winkler | 712b6cf | 2008-03-12 16:58:52 -0700 | [diff] [blame] | 310 | priv->num_stations); |
| 311 | |
| 312 | for (i = 0; i < max_sta; i++) { |
| 313 | station = &priv->stations[i]; |
Johannes Berg | da73511 | 2010-05-03 01:25:24 -0700 | [diff] [blame] | 314 | if (!station->used) |
| 315 | continue; |
| 316 | pos += scnprintf(buf + pos, bufsz - pos, |
| 317 | "station %d - addr: %pM, flags: %#x\n", |
| 318 | i, station->sta.sta.addr, |
| 319 | station->sta.station_flags_msk); |
| 320 | pos += scnprintf(buf + pos, bufsz - pos, |
| 321 | "TID\tseq_num\ttxq_id\tframes\ttfds\t"); |
| 322 | pos += scnprintf(buf + pos, bufsz - pos, |
| 323 | "start_idx\tbitmap\t\t\trate_n_flags\n"); |
Tomas Winkler | 712b6cf | 2008-03-12 16:58:52 -0700 | [diff] [blame] | 324 | |
Johannes Berg | da73511 | 2010-05-03 01:25:24 -0700 | [diff] [blame] | 325 | for (j = 0; j < MAX_TID_COUNT; j++) { |
| 326 | pos += scnprintf(buf + pos, bufsz - pos, |
| 327 | "%d:\t%#x\t%#x\t%u\t%u\t%u\t\t%#.16llx\t%#x", |
| 328 | j, station->tid[j].seq_number, |
| 329 | station->tid[j].agg.txq_id, |
| 330 | station->tid[j].agg.frame_count, |
| 331 | station->tid[j].tfds_in_queue, |
| 332 | station->tid[j].agg.start_idx, |
| 333 | station->tid[j].agg.bitmap, |
| 334 | station->tid[j].agg.rate_n_flags); |
| 335 | |
| 336 | if (station->tid[j].agg.wait_for_ba) |
Abhijeet Kolekar | db0589f | 2008-04-14 21:16:04 -0700 | [diff] [blame] | 337 | pos += scnprintf(buf + pos, bufsz - pos, |
Johannes Berg | da73511 | 2010-05-03 01:25:24 -0700 | [diff] [blame] | 338 | " - waitforba"); |
Abhijeet Kolekar | db0589f | 2008-04-14 21:16:04 -0700 | [diff] [blame] | 339 | pos += scnprintf(buf + pos, bufsz - pos, "\n"); |
Tomas Winkler | 712b6cf | 2008-03-12 16:58:52 -0700 | [diff] [blame] | 340 | } |
Johannes Berg | da73511 | 2010-05-03 01:25:24 -0700 | [diff] [blame] | 341 | |
| 342 | pos += scnprintf(buf + pos, bufsz - pos, "\n"); |
Tomas Winkler | 712b6cf | 2008-03-12 16:58:52 -0700 | [diff] [blame] | 343 | } |
| 344 | |
| 345 | ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos); |
| 346 | kfree(buf); |
| 347 | return ret; |
| 348 | } |
| 349 | |
Wey-Yi Guy | 0848e29 | 2009-05-22 11:01:46 -0700 | [diff] [blame] | 350 | static ssize_t iwl_dbgfs_nvm_read(struct file *file, |
Tomas Winkler | 8dd266e | 2008-05-05 10:22:32 +0800 | [diff] [blame] | 351 | char __user *user_buf, |
| 352 | size_t count, |
| 353 | loff_t *ppos) |
| 354 | { |
| 355 | ssize_t ret; |
H Hartley Sweeten | 28f63a4 | 2010-01-08 16:14:10 -0700 | [diff] [blame] | 356 | struct iwl_priv *priv = file->private_data; |
Tomas Winkler | 8dd266e | 2008-05-05 10:22:32 +0800 | [diff] [blame] | 357 | int pos = 0, ofs = 0, buf_size = 0; |
| 358 | const u8 *ptr; |
| 359 | char *buf; |
Wey-Yi Guy | e307ddc | 2009-09-11 10:38:16 -0700 | [diff] [blame] | 360 | u16 eeprom_ver; |
Wey-Yi Guy | 7cb1b08 | 2010-10-06 08:10:00 -0700 | [diff] [blame] | 361 | size_t eeprom_len = priv->cfg->base_params->eeprom_size; |
Tomas Winkler | 8dd266e | 2008-05-05 10:22:32 +0800 | [diff] [blame] | 362 | buf_size = 4 * eeprom_len + 256; |
| 363 | |
| 364 | if (eeprom_len % 16) { |
Wey-Yi Guy | 0848e29 | 2009-05-22 11:01:46 -0700 | [diff] [blame] | 365 | IWL_ERR(priv, "NVM size is not multiple of 16.\n"); |
Tomas Winkler | 8dd266e | 2008-05-05 10:22:32 +0800 | [diff] [blame] | 366 | return -ENODATA; |
| 367 | } |
| 368 | |
Julia Lawall | c37457e | 2009-08-03 11:11:45 +0200 | [diff] [blame] | 369 | ptr = priv->eeprom; |
| 370 | if (!ptr) { |
| 371 | IWL_ERR(priv, "Invalid EEPROM/OTP memory\n"); |
| 372 | return -ENOMEM; |
| 373 | } |
| 374 | |
Tomas Winkler | 8dd266e | 2008-05-05 10:22:32 +0800 | [diff] [blame] | 375 | /* 4 characters for byte 0xYY */ |
| 376 | buf = kzalloc(buf_size, GFP_KERNEL); |
| 377 | if (!buf) { |
Winkler, Tomas | 15b1687 | 2008-12-19 10:37:33 +0800 | [diff] [blame] | 378 | IWL_ERR(priv, "Can not allocate Buffer\n"); |
Tomas Winkler | 8dd266e | 2008-05-05 10:22:32 +0800 | [diff] [blame] | 379 | return -ENOMEM; |
| 380 | } |
Wey-Yi Guy | e307ddc | 2009-09-11 10:38:16 -0700 | [diff] [blame] | 381 | eeprom_ver = iwl_eeprom_query16(priv, EEPROM_VERSION); |
| 382 | pos += scnprintf(buf + pos, buf_size - pos, "NVM Type: %s, " |
| 383 | "version: 0x%x\n", |
Wey-Yi Guy | 0848e29 | 2009-05-22 11:01:46 -0700 | [diff] [blame] | 384 | (priv->nvm_device_type == NVM_DEVICE_TYPE_OTP) |
Wey-Yi Guy | e307ddc | 2009-09-11 10:38:16 -0700 | [diff] [blame] | 385 | ? "OTP" : "EEPROM", eeprom_ver); |
Tomas Winkler | 8dd266e | 2008-05-05 10:22:32 +0800 | [diff] [blame] | 386 | for (ofs = 0 ; ofs < eeprom_len ; ofs += 16) { |
| 387 | pos += scnprintf(buf + pos, buf_size - pos, "0x%.4x ", ofs); |
| 388 | hex_dump_to_buffer(ptr + ofs, 16 , 16, 2, buf + pos, |
| 389 | buf_size - pos, 0); |
Reinette Chatre | 2fac971 | 2009-09-25 14:24:21 -0700 | [diff] [blame] | 390 | pos += strlen(buf + pos); |
Tomas Winkler | 8dd266e | 2008-05-05 10:22:32 +0800 | [diff] [blame] | 391 | if (buf_size - pos > 0) |
| 392 | buf[pos++] = '\n'; |
| 393 | } |
| 394 | |
| 395 | ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos); |
| 396 | kfree(buf); |
| 397 | return ret; |
| 398 | } |
Tomas Winkler | 712b6cf | 2008-03-12 16:58:52 -0700 | [diff] [blame] | 399 | |
Wey-Yi Guy | b03d7d0 | 2009-12-14 14:12:20 -0800 | [diff] [blame] | 400 | static ssize_t iwl_dbgfs_log_event_read(struct file *file, |
| 401 | char __user *user_buf, |
| 402 | size_t count, loff_t *ppos) |
| 403 | { |
| 404 | struct iwl_priv *priv = file->private_data; |
| 405 | char *buf; |
| 406 | int pos = 0; |
| 407 | ssize_t ret = -ENOMEM; |
| 408 | |
Wey-Yi Guy | 937c397 | 2010-01-15 13:43:36 -0800 | [diff] [blame] | 409 | ret = pos = priv->cfg->ops->lib->dump_nic_event_log( |
| 410 | priv, true, &buf, true); |
| 411 | if (buf) { |
Wey-Yi Guy | b03d7d0 | 2009-12-14 14:12:20 -0800 | [diff] [blame] | 412 | ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos); |
| 413 | kfree(buf); |
| 414 | } |
| 415 | return ret; |
| 416 | } |
| 417 | |
Ester Kummer | 189a2b5 | 2008-05-15 13:54:18 +0800 | [diff] [blame] | 418 | static ssize_t iwl_dbgfs_log_event_write(struct file *file, |
| 419 | const char __user *user_buf, |
| 420 | size_t count, loff_t *ppos) |
| 421 | { |
| 422 | struct iwl_priv *priv = file->private_data; |
| 423 | u32 event_log_flag; |
| 424 | char buf[8]; |
| 425 | int buf_size; |
| 426 | |
| 427 | memset(buf, 0, sizeof(buf)); |
| 428 | buf_size = min(count, sizeof(buf) - 1); |
| 429 | if (copy_from_user(buf, user_buf, buf_size)) |
| 430 | return -EFAULT; |
| 431 | if (sscanf(buf, "%d", &event_log_flag) != 1) |
| 432 | return -EFAULT; |
| 433 | if (event_log_flag == 1) |
Wey-Yi Guy | b03d7d0 | 2009-12-14 14:12:20 -0800 | [diff] [blame] | 434 | priv->cfg->ops->lib->dump_nic_event_log(priv, true, |
| 435 | NULL, false); |
Ester Kummer | 189a2b5 | 2008-05-15 13:54:18 +0800 | [diff] [blame] | 436 | |
| 437 | return count; |
| 438 | } |
| 439 | |
Winkler, Tomas | d366df5 | 2008-12-02 12:14:01 -0800 | [diff] [blame] | 440 | |
| 441 | |
| 442 | static ssize_t iwl_dbgfs_channels_read(struct file *file, char __user *user_buf, |
| 443 | size_t count, loff_t *ppos) |
| 444 | { |
H Hartley Sweeten | 28f63a4 | 2010-01-08 16:14:10 -0700 | [diff] [blame] | 445 | struct iwl_priv *priv = file->private_data; |
Winkler, Tomas | d366df5 | 2008-12-02 12:14:01 -0800 | [diff] [blame] | 446 | struct ieee80211_channel *channels = NULL; |
| 447 | const struct ieee80211_supported_band *supp_band = NULL; |
| 448 | int pos = 0, i, bufsz = PAGE_SIZE; |
| 449 | char *buf; |
| 450 | ssize_t ret; |
| 451 | |
| 452 | if (!test_bit(STATUS_GEO_CONFIGURED, &priv->status)) |
| 453 | return -EAGAIN; |
| 454 | |
| 455 | buf = kzalloc(bufsz, GFP_KERNEL); |
| 456 | if (!buf) { |
Winkler, Tomas | 15b1687 | 2008-12-19 10:37:33 +0800 | [diff] [blame] | 457 | IWL_ERR(priv, "Can not allocate Buffer\n"); |
Winkler, Tomas | d366df5 | 2008-12-02 12:14:01 -0800 | [diff] [blame] | 458 | return -ENOMEM; |
| 459 | } |
| 460 | |
| 461 | supp_band = iwl_get_hw_mode(priv, IEEE80211_BAND_2GHZ); |
Wey-Yi Guy | a2e2322 | 2009-05-22 11:01:55 -0700 | [diff] [blame] | 462 | if (supp_band) { |
| 463 | channels = supp_band->channels; |
Winkler, Tomas | d366df5 | 2008-12-02 12:14:01 -0800 | [diff] [blame] | 464 | |
Winkler, Tomas | d366df5 | 2008-12-02 12:14:01 -0800 | [diff] [blame] | 465 | pos += scnprintf(buf + pos, bufsz - pos, |
Wey-Yi Guy | a2e2322 | 2009-05-22 11:01:55 -0700 | [diff] [blame] | 466 | "Displaying %d channels in 2.4GHz band 802.11bg):\n", |
| 467 | supp_band->n_channels); |
Winkler, Tomas | d366df5 | 2008-12-02 12:14:01 -0800 | [diff] [blame] | 468 | |
Wey-Yi Guy | a2e2322 | 2009-05-22 11:01:55 -0700 | [diff] [blame] | 469 | for (i = 0; i < supp_band->n_channels; i++) |
| 470 | pos += scnprintf(buf + pos, bufsz - pos, |
| 471 | "%d: %ddBm: BSS%s%s, %s.\n", |
Shanyu Zhao | 81e9543 | 2010-07-28 13:40:27 -0700 | [diff] [blame] | 472 | channels[i].hw_value, |
Wey-Yi Guy | a2e2322 | 2009-05-22 11:01:55 -0700 | [diff] [blame] | 473 | channels[i].max_power, |
| 474 | channels[i].flags & IEEE80211_CHAN_RADAR ? |
| 475 | " (IEEE 802.11h required)" : "", |
| 476 | ((channels[i].flags & IEEE80211_CHAN_NO_IBSS) |
| 477 | || (channels[i].flags & |
| 478 | IEEE80211_CHAN_RADAR)) ? "" : |
| 479 | ", IBSS", |
| 480 | channels[i].flags & |
| 481 | IEEE80211_CHAN_PASSIVE_SCAN ? |
| 482 | "passive only" : "active/passive"); |
| 483 | } |
Winkler, Tomas | d366df5 | 2008-12-02 12:14:01 -0800 | [diff] [blame] | 484 | supp_band = iwl_get_hw_mode(priv, IEEE80211_BAND_5GHZ); |
Wey-Yi Guy | a2e2322 | 2009-05-22 11:01:55 -0700 | [diff] [blame] | 485 | if (supp_band) { |
| 486 | channels = supp_band->channels; |
Winkler, Tomas | d366df5 | 2008-12-02 12:14:01 -0800 | [diff] [blame] | 487 | |
Winkler, Tomas | d366df5 | 2008-12-02 12:14:01 -0800 | [diff] [blame] | 488 | pos += scnprintf(buf + pos, bufsz - pos, |
Wey-Yi Guy | a2e2322 | 2009-05-22 11:01:55 -0700 | [diff] [blame] | 489 | "Displaying %d channels in 5.2GHz band (802.11a)\n", |
| 490 | supp_band->n_channels); |
| 491 | |
| 492 | for (i = 0; i < supp_band->n_channels; i++) |
| 493 | pos += scnprintf(buf + pos, bufsz - pos, |
| 494 | "%d: %ddBm: BSS%s%s, %s.\n", |
Shanyu Zhao | 81e9543 | 2010-07-28 13:40:27 -0700 | [diff] [blame] | 495 | channels[i].hw_value, |
Wey-Yi Guy | a2e2322 | 2009-05-22 11:01:55 -0700 | [diff] [blame] | 496 | channels[i].max_power, |
| 497 | channels[i].flags & IEEE80211_CHAN_RADAR ? |
| 498 | " (IEEE 802.11h required)" : "", |
| 499 | ((channels[i].flags & IEEE80211_CHAN_NO_IBSS) |
| 500 | || (channels[i].flags & |
| 501 | IEEE80211_CHAN_RADAR)) ? "" : |
| 502 | ", IBSS", |
| 503 | channels[i].flags & |
| 504 | IEEE80211_CHAN_PASSIVE_SCAN ? |
| 505 | "passive only" : "active/passive"); |
| 506 | } |
Winkler, Tomas | d366df5 | 2008-12-02 12:14:01 -0800 | [diff] [blame] | 507 | ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos); |
| 508 | kfree(buf); |
| 509 | return ret; |
| 510 | } |
| 511 | |
Wey-Yi Guy | 08df05a | 2009-03-24 10:02:54 -0700 | [diff] [blame] | 512 | static ssize_t iwl_dbgfs_status_read(struct file *file, |
| 513 | char __user *user_buf, |
| 514 | size_t count, loff_t *ppos) { |
| 515 | |
H Hartley Sweeten | 28f63a4 | 2010-01-08 16:14:10 -0700 | [diff] [blame] | 516 | struct iwl_priv *priv = file->private_data; |
Wey-Yi Guy | 08df05a | 2009-03-24 10:02:54 -0700 | [diff] [blame] | 517 | char buf[512]; |
| 518 | int pos = 0; |
| 519 | const size_t bufsz = sizeof(buf); |
| 520 | |
| 521 | pos += scnprintf(buf + pos, bufsz - pos, "STATUS_HCMD_ACTIVE:\t %d\n", |
| 522 | test_bit(STATUS_HCMD_ACTIVE, &priv->status)); |
Wey-Yi Guy | 08df05a | 2009-03-24 10:02:54 -0700 | [diff] [blame] | 523 | pos += scnprintf(buf + pos, bufsz - pos, "STATUS_INT_ENABLED:\t %d\n", |
| 524 | test_bit(STATUS_INT_ENABLED, &priv->status)); |
| 525 | pos += scnprintf(buf + pos, bufsz - pos, "STATUS_RF_KILL_HW:\t %d\n", |
| 526 | test_bit(STATUS_RF_KILL_HW, &priv->status)); |
Wey-Yi Guy | 7812b16 | 2009-10-02 13:43:58 -0700 | [diff] [blame] | 527 | pos += scnprintf(buf + pos, bufsz - pos, "STATUS_CT_KILL:\t\t %d\n", |
| 528 | test_bit(STATUS_CT_KILL, &priv->status)); |
Wey-Yi Guy | 08df05a | 2009-03-24 10:02:54 -0700 | [diff] [blame] | 529 | pos += scnprintf(buf + pos, bufsz - pos, "STATUS_INIT:\t\t %d\n", |
| 530 | test_bit(STATUS_INIT, &priv->status)); |
| 531 | pos += scnprintf(buf + pos, bufsz - pos, "STATUS_ALIVE:\t\t %d\n", |
| 532 | test_bit(STATUS_ALIVE, &priv->status)); |
| 533 | pos += scnprintf(buf + pos, bufsz - pos, "STATUS_READY:\t\t %d\n", |
| 534 | test_bit(STATUS_READY, &priv->status)); |
| 535 | pos += scnprintf(buf + pos, bufsz - pos, "STATUS_TEMPERATURE:\t %d\n", |
| 536 | test_bit(STATUS_TEMPERATURE, &priv->status)); |
| 537 | pos += scnprintf(buf + pos, bufsz - pos, "STATUS_GEO_CONFIGURED:\t %d\n", |
| 538 | test_bit(STATUS_GEO_CONFIGURED, &priv->status)); |
| 539 | pos += scnprintf(buf + pos, bufsz - pos, "STATUS_EXIT_PENDING:\t %d\n", |
| 540 | test_bit(STATUS_EXIT_PENDING, &priv->status)); |
Wey-Yi Guy | 08df05a | 2009-03-24 10:02:54 -0700 | [diff] [blame] | 541 | pos += scnprintf(buf + pos, bufsz - pos, "STATUS_STATISTICS:\t %d\n", |
| 542 | test_bit(STATUS_STATISTICS, &priv->status)); |
| 543 | pos += scnprintf(buf + pos, bufsz - pos, "STATUS_SCANNING:\t %d\n", |
| 544 | test_bit(STATUS_SCANNING, &priv->status)); |
| 545 | pos += scnprintf(buf + pos, bufsz - pos, "STATUS_SCAN_ABORTING:\t %d\n", |
| 546 | test_bit(STATUS_SCAN_ABORTING, &priv->status)); |
| 547 | pos += scnprintf(buf + pos, bufsz - pos, "STATUS_SCAN_HW:\t\t %d\n", |
| 548 | test_bit(STATUS_SCAN_HW, &priv->status)); |
| 549 | pos += scnprintf(buf + pos, bufsz - pos, "STATUS_POWER_PMI:\t %d\n", |
| 550 | test_bit(STATUS_POWER_PMI, &priv->status)); |
| 551 | pos += scnprintf(buf + pos, bufsz - pos, "STATUS_FW_ERROR:\t %d\n", |
| 552 | test_bit(STATUS_FW_ERROR, &priv->status)); |
Wey-Yi Guy | 08df05a | 2009-03-24 10:02:54 -0700 | [diff] [blame] | 553 | return simple_read_from_buffer(user_buf, count, ppos, buf, pos); |
| 554 | } |
| 555 | |
Wey-Yi Guy | a83b914 | 2009-04-08 11:39:32 -0700 | [diff] [blame] | 556 | static ssize_t iwl_dbgfs_interrupt_read(struct file *file, |
| 557 | char __user *user_buf, |
| 558 | size_t count, loff_t *ppos) { |
| 559 | |
H Hartley Sweeten | 28f63a4 | 2010-01-08 16:14:10 -0700 | [diff] [blame] | 560 | struct iwl_priv *priv = file->private_data; |
Wey-Yi Guy | a83b914 | 2009-04-08 11:39:32 -0700 | [diff] [blame] | 561 | int pos = 0; |
| 562 | int cnt = 0; |
| 563 | char *buf; |
| 564 | int bufsz = 24 * 64; /* 24 items * 64 char per item */ |
| 565 | ssize_t ret; |
| 566 | |
| 567 | buf = kzalloc(bufsz, GFP_KERNEL); |
| 568 | if (!buf) { |
| 569 | IWL_ERR(priv, "Can not allocate Buffer\n"); |
| 570 | return -ENOMEM; |
| 571 | } |
| 572 | |
| 573 | pos += scnprintf(buf + pos, bufsz - pos, |
| 574 | "Interrupt Statistics Report:\n"); |
| 575 | |
| 576 | pos += scnprintf(buf + pos, bufsz - pos, "HW Error:\t\t\t %u\n", |
| 577 | priv->isr_stats.hw); |
| 578 | pos += scnprintf(buf + pos, bufsz - pos, "SW Error:\t\t\t %u\n", |
| 579 | priv->isr_stats.sw); |
Wey-Yi Guy | 6e6ebf4 | 2010-08-27 10:41:37 -0700 | [diff] [blame] | 580 | if (priv->isr_stats.sw || priv->isr_stats.hw) { |
Wey-Yi Guy | a83b914 | 2009-04-08 11:39:32 -0700 | [diff] [blame] | 581 | pos += scnprintf(buf + pos, bufsz - pos, |
| 582 | "\tLast Restarting Code: 0x%X\n", |
Wey-Yi Guy | 6e6ebf4 | 2010-08-27 10:41:37 -0700 | [diff] [blame] | 583 | priv->isr_stats.err_code); |
Wey-Yi Guy | a83b914 | 2009-04-08 11:39:32 -0700 | [diff] [blame] | 584 | } |
| 585 | #ifdef CONFIG_IWLWIFI_DEBUG |
| 586 | pos += scnprintf(buf + pos, bufsz - pos, "Frame transmitted:\t\t %u\n", |
| 587 | priv->isr_stats.sch); |
| 588 | pos += scnprintf(buf + pos, bufsz - pos, "Alive interrupt:\t\t %u\n", |
| 589 | priv->isr_stats.alive); |
| 590 | #endif |
| 591 | pos += scnprintf(buf + pos, bufsz - pos, |
| 592 | "HW RF KILL switch toggled:\t %u\n", |
| 593 | priv->isr_stats.rfkill); |
| 594 | |
| 595 | pos += scnprintf(buf + pos, bufsz - pos, "CT KILL:\t\t\t %u\n", |
| 596 | priv->isr_stats.ctkill); |
| 597 | |
| 598 | pos += scnprintf(buf + pos, bufsz - pos, "Wakeup Interrupt:\t\t %u\n", |
| 599 | priv->isr_stats.wakeup); |
| 600 | |
| 601 | pos += scnprintf(buf + pos, bufsz - pos, |
| 602 | "Rx command responses:\t\t %u\n", |
| 603 | priv->isr_stats.rx); |
| 604 | for (cnt = 0; cnt < REPLY_MAX; cnt++) { |
| 605 | if (priv->isr_stats.rx_handlers[cnt] > 0) |
| 606 | pos += scnprintf(buf + pos, bufsz - pos, |
| 607 | "\tRx handler[%36s]:\t\t %u\n", |
| 608 | get_cmd_string(cnt), |
| 609 | priv->isr_stats.rx_handlers[cnt]); |
| 610 | } |
| 611 | |
| 612 | pos += scnprintf(buf + pos, bufsz - pos, "Tx/FH interrupt:\t\t %u\n", |
| 613 | priv->isr_stats.tx); |
| 614 | |
| 615 | pos += scnprintf(buf + pos, bufsz - pos, "Unexpected INTA:\t\t %u\n", |
| 616 | priv->isr_stats.unhandled); |
| 617 | |
| 618 | ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos); |
| 619 | kfree(buf); |
| 620 | return ret; |
| 621 | } |
| 622 | |
| 623 | static ssize_t iwl_dbgfs_interrupt_write(struct file *file, |
| 624 | const char __user *user_buf, |
| 625 | size_t count, loff_t *ppos) |
| 626 | { |
| 627 | struct iwl_priv *priv = file->private_data; |
| 628 | char buf[8]; |
| 629 | int buf_size; |
| 630 | u32 reset_flag; |
| 631 | |
| 632 | memset(buf, 0, sizeof(buf)); |
| 633 | buf_size = min(count, sizeof(buf) - 1); |
| 634 | if (copy_from_user(buf, user_buf, buf_size)) |
| 635 | return -EFAULT; |
| 636 | if (sscanf(buf, "%x", &reset_flag) != 1) |
| 637 | return -EFAULT; |
| 638 | if (reset_flag == 0) |
| 639 | iwl_clear_isr_stats(priv); |
| 640 | |
| 641 | return count; |
| 642 | } |
| 643 | |
Wey-Yi Guy | f5ad69f | 2009-07-09 10:33:36 -0700 | [diff] [blame] | 644 | static ssize_t iwl_dbgfs_qos_read(struct file *file, char __user *user_buf, |
| 645 | size_t count, loff_t *ppos) |
| 646 | { |
H Hartley Sweeten | 28f63a4 | 2010-01-08 16:14:10 -0700 | [diff] [blame] | 647 | struct iwl_priv *priv = file->private_data; |
Johannes Berg | 8dfdb9d | 2010-08-23 10:46:38 +0200 | [diff] [blame] | 648 | struct iwl_rxon_context *ctx; |
Wey-Yi Guy | f5ad69f | 2009-07-09 10:33:36 -0700 | [diff] [blame] | 649 | int pos = 0, i; |
Johannes Berg | 8dfdb9d | 2010-08-23 10:46:38 +0200 | [diff] [blame] | 650 | char buf[256 * NUM_IWL_RXON_CTX]; |
Wey-Yi Guy | f5ad69f | 2009-07-09 10:33:36 -0700 | [diff] [blame] | 651 | const size_t bufsz = sizeof(buf); |
Wey-Yi Guy | f5ad69f | 2009-07-09 10:33:36 -0700 | [diff] [blame] | 652 | |
Johannes Berg | 8dfdb9d | 2010-08-23 10:46:38 +0200 | [diff] [blame] | 653 | for_each_context(priv, ctx) { |
| 654 | pos += scnprintf(buf + pos, bufsz - pos, "context %d:\n", |
| 655 | ctx->ctxid); |
| 656 | for (i = 0; i < AC_NUM; i++) { |
| 657 | pos += scnprintf(buf + pos, bufsz - pos, |
| 658 | "\tcw_min\tcw_max\taifsn\ttxop\n"); |
| 659 | pos += scnprintf(buf + pos, bufsz - pos, |
Wey-Yi Guy | f5ad69f | 2009-07-09 10:33:36 -0700 | [diff] [blame] | 660 | "AC[%d]\t%u\t%u\t%u\t%u\n", i, |
Johannes Berg | 8dfdb9d | 2010-08-23 10:46:38 +0200 | [diff] [blame] | 661 | ctx->qos_data.def_qos_parm.ac[i].cw_min, |
| 662 | ctx->qos_data.def_qos_parm.ac[i].cw_max, |
| 663 | ctx->qos_data.def_qos_parm.ac[i].aifsn, |
| 664 | ctx->qos_data.def_qos_parm.ac[i].edca_txop); |
| 665 | } |
| 666 | pos += scnprintf(buf + pos, bufsz - pos, "\n"); |
Wey-Yi Guy | f5ad69f | 2009-07-09 10:33:36 -0700 | [diff] [blame] | 667 | } |
Wey-Yi Guy | 4967c31 | 2010-02-18 15:22:07 -0800 | [diff] [blame] | 668 | return simple_read_from_buffer(user_buf, count, ppos, buf, pos); |
Wey-Yi Guy | f5ad69f | 2009-07-09 10:33:36 -0700 | [diff] [blame] | 669 | } |
Wey-Yi Guy | a83b914 | 2009-04-08 11:39:32 -0700 | [diff] [blame] | 670 | |
Wey-Yi Guy | fbf3a2a | 2009-07-24 11:13:04 -0700 | [diff] [blame] | 671 | static ssize_t iwl_dbgfs_thermal_throttling_read(struct file *file, |
| 672 | char __user *user_buf, |
| 673 | size_t count, loff_t *ppos) |
| 674 | { |
H Hartley Sweeten | 28f63a4 | 2010-01-08 16:14:10 -0700 | [diff] [blame] | 675 | struct iwl_priv *priv = file->private_data; |
Johannes Berg | 3ad3b92 | 2009-08-07 15:41:48 -0700 | [diff] [blame] | 676 | struct iwl_tt_mgmt *tt = &priv->thermal_throttle; |
Wey-Yi Guy | fbf3a2a | 2009-07-24 11:13:04 -0700 | [diff] [blame] | 677 | struct iwl_tt_restriction *restriction; |
| 678 | char buf[100]; |
| 679 | int pos = 0; |
| 680 | const size_t bufsz = sizeof(buf); |
Wey-Yi Guy | fbf3a2a | 2009-07-24 11:13:04 -0700 | [diff] [blame] | 681 | |
| 682 | pos += scnprintf(buf + pos, bufsz - pos, |
| 683 | "Thermal Throttling Mode: %s\n", |
Johannes Berg | 3ad3b92 | 2009-08-07 15:41:48 -0700 | [diff] [blame] | 684 | tt->advanced_tt ? "Advance" : "Legacy"); |
Wey-Yi Guy | fbf3a2a | 2009-07-24 11:13:04 -0700 | [diff] [blame] | 685 | pos += scnprintf(buf + pos, bufsz - pos, |
| 686 | "Thermal Throttling State: %d\n", |
| 687 | tt->state); |
Johannes Berg | 3ad3b92 | 2009-08-07 15:41:48 -0700 | [diff] [blame] | 688 | if (tt->advanced_tt) { |
Wey-Yi Guy | fbf3a2a | 2009-07-24 11:13:04 -0700 | [diff] [blame] | 689 | restriction = tt->restriction + tt->state; |
| 690 | pos += scnprintf(buf + pos, bufsz - pos, |
| 691 | "Tx mode: %d\n", |
| 692 | restriction->tx_stream); |
| 693 | pos += scnprintf(buf + pos, bufsz - pos, |
| 694 | "Rx mode: %d\n", |
| 695 | restriction->rx_stream); |
| 696 | pos += scnprintf(buf + pos, bufsz - pos, |
| 697 | "HT mode: %d\n", |
| 698 | restriction->is_ht); |
| 699 | } |
Wey-Yi Guy | 4967c31 | 2010-02-18 15:22:07 -0800 | [diff] [blame] | 700 | return simple_read_from_buffer(user_buf, count, ppos, buf, pos); |
Wey-Yi Guy | fbf3a2a | 2009-07-24 11:13:04 -0700 | [diff] [blame] | 701 | } |
| 702 | |
Wey-Yi Guy | 1e4247d | 2009-07-27 13:50:15 -0700 | [diff] [blame] | 703 | static ssize_t iwl_dbgfs_disable_ht40_write(struct file *file, |
| 704 | const char __user *user_buf, |
| 705 | size_t count, loff_t *ppos) |
| 706 | { |
| 707 | struct iwl_priv *priv = file->private_data; |
| 708 | char buf[8]; |
| 709 | int buf_size; |
| 710 | int ht40; |
| 711 | |
| 712 | memset(buf, 0, sizeof(buf)); |
| 713 | buf_size = min(count, sizeof(buf) - 1); |
| 714 | if (copy_from_user(buf, user_buf, buf_size)) |
| 715 | return -EFAULT; |
| 716 | if (sscanf(buf, "%d", &ht40) != 1) |
| 717 | return -EFAULT; |
Johannes Berg | 246ed35 | 2010-08-23 10:46:32 +0200 | [diff] [blame] | 718 | if (!iwl_is_any_associated(priv)) |
Wey-Yi Guy | 1e4247d | 2009-07-27 13:50:15 -0700 | [diff] [blame] | 719 | priv->disable_ht40 = ht40 ? true : false; |
| 720 | else { |
| 721 | IWL_ERR(priv, "Sta associated with AP - " |
| 722 | "Change to 40MHz channel support is not allowed\n"); |
| 723 | return -EINVAL; |
| 724 | } |
| 725 | |
| 726 | return count; |
| 727 | } |
| 728 | |
| 729 | static ssize_t iwl_dbgfs_disable_ht40_read(struct file *file, |
| 730 | char __user *user_buf, |
| 731 | size_t count, loff_t *ppos) |
| 732 | { |
H Hartley Sweeten | 28f63a4 | 2010-01-08 16:14:10 -0700 | [diff] [blame] | 733 | struct iwl_priv *priv = file->private_data; |
Wey-Yi Guy | 1e4247d | 2009-07-27 13:50:15 -0700 | [diff] [blame] | 734 | char buf[100]; |
| 735 | int pos = 0; |
| 736 | const size_t bufsz = sizeof(buf); |
Wey-Yi Guy | 1e4247d | 2009-07-27 13:50:15 -0700 | [diff] [blame] | 737 | |
| 738 | pos += scnprintf(buf + pos, bufsz - pos, |
| 739 | "11n 40MHz Mode: %s\n", |
| 740 | priv->disable_ht40 ? "Disabled" : "Enabled"); |
Wey-Yi Guy | 4967c31 | 2010-02-18 15:22:07 -0800 | [diff] [blame] | 741 | return simple_read_from_buffer(user_buf, count, ppos, buf, pos); |
Wey-Yi Guy | 1e4247d | 2009-07-27 13:50:15 -0700 | [diff] [blame] | 742 | } |
| 743 | |
Johannes Berg | e312c24 | 2009-08-07 15:41:51 -0700 | [diff] [blame] | 744 | static ssize_t iwl_dbgfs_sleep_level_override_write(struct file *file, |
| 745 | const char __user *user_buf, |
| 746 | size_t count, loff_t *ppos) |
| 747 | { |
| 748 | struct iwl_priv *priv = file->private_data; |
| 749 | char buf[8]; |
| 750 | int buf_size; |
| 751 | int value; |
| 752 | |
| 753 | memset(buf, 0, sizeof(buf)); |
| 754 | buf_size = min(count, sizeof(buf) - 1); |
| 755 | if (copy_from_user(buf, user_buf, buf_size)) |
| 756 | return -EFAULT; |
| 757 | |
| 758 | if (sscanf(buf, "%d", &value) != 1) |
| 759 | return -EINVAL; |
| 760 | |
| 761 | /* |
| 762 | * Our users expect 0 to be "CAM", but 0 isn't actually |
| 763 | * valid here. However, let's not confuse them and present |
| 764 | * IWL_POWER_INDEX_1 as "1", not "0". |
| 765 | */ |
Reinette Chatre | 1a34c04 | 2009-10-09 13:20:25 -0700 | [diff] [blame] | 766 | if (value == 0) |
| 767 | return -EINVAL; |
| 768 | else if (value > 0) |
Johannes Berg | e312c24 | 2009-08-07 15:41:51 -0700 | [diff] [blame] | 769 | value -= 1; |
| 770 | |
| 771 | if (value != -1 && (value < 0 || value >= IWL_POWER_NUM)) |
| 772 | return -EINVAL; |
| 773 | |
Wey-Yi Guy | 4ad177b | 2009-10-16 14:25:58 -0700 | [diff] [blame] | 774 | if (!iwl_is_ready_rf(priv)) |
| 775 | return -EAGAIN; |
| 776 | |
Johannes Berg | e312c24 | 2009-08-07 15:41:51 -0700 | [diff] [blame] | 777 | priv->power_data.debug_sleep_level_override = value; |
| 778 | |
Reinette Chatre | d3a5719 | 2010-01-21 11:52:28 -0800 | [diff] [blame] | 779 | mutex_lock(&priv->mutex); |
Wey-Yi Guy | 4ad177b | 2009-10-16 14:25:58 -0700 | [diff] [blame] | 780 | iwl_power_update_mode(priv, true); |
Reinette Chatre | d3a5719 | 2010-01-21 11:52:28 -0800 | [diff] [blame] | 781 | mutex_unlock(&priv->mutex); |
Johannes Berg | e312c24 | 2009-08-07 15:41:51 -0700 | [diff] [blame] | 782 | |
| 783 | return count; |
| 784 | } |
| 785 | |
| 786 | static ssize_t iwl_dbgfs_sleep_level_override_read(struct file *file, |
| 787 | char __user *user_buf, |
| 788 | size_t count, loff_t *ppos) |
| 789 | { |
H Hartley Sweeten | 28f63a4 | 2010-01-08 16:14:10 -0700 | [diff] [blame] | 790 | struct iwl_priv *priv = file->private_data; |
Johannes Berg | e312c24 | 2009-08-07 15:41:51 -0700 | [diff] [blame] | 791 | char buf[10]; |
| 792 | int pos, value; |
| 793 | const size_t bufsz = sizeof(buf); |
| 794 | |
| 795 | /* see the write function */ |
| 796 | value = priv->power_data.debug_sleep_level_override; |
| 797 | if (value >= 0) |
| 798 | value += 1; |
| 799 | |
| 800 | pos = scnprintf(buf, bufsz, "%d\n", value); |
| 801 | return simple_read_from_buffer(user_buf, count, ppos, buf, pos); |
| 802 | } |
| 803 | |
| 804 | static ssize_t iwl_dbgfs_current_sleep_command_read(struct file *file, |
| 805 | char __user *user_buf, |
| 806 | size_t count, loff_t *ppos) |
| 807 | { |
H Hartley Sweeten | 28f63a4 | 2010-01-08 16:14:10 -0700 | [diff] [blame] | 808 | struct iwl_priv *priv = file->private_data; |
Johannes Berg | e312c24 | 2009-08-07 15:41:51 -0700 | [diff] [blame] | 809 | char buf[200]; |
| 810 | int pos = 0, i; |
| 811 | const size_t bufsz = sizeof(buf); |
| 812 | struct iwl_powertable_cmd *cmd = &priv->power_data.sleep_cmd; |
| 813 | |
| 814 | pos += scnprintf(buf + pos, bufsz - pos, |
| 815 | "flags: %#.2x\n", le16_to_cpu(cmd->flags)); |
| 816 | pos += scnprintf(buf + pos, bufsz - pos, |
| 817 | "RX/TX timeout: %d/%d usec\n", |
| 818 | le32_to_cpu(cmd->rx_data_timeout), |
| 819 | le32_to_cpu(cmd->tx_data_timeout)); |
| 820 | for (i = 0; i < IWL_POWER_VEC_SIZE; i++) |
| 821 | pos += scnprintf(buf + pos, bufsz - pos, |
| 822 | "sleep_interval[%d]: %d\n", i, |
| 823 | le32_to_cpu(cmd->sleep_interval[i])); |
| 824 | |
| 825 | return simple_read_from_buffer(user_buf, count, ppos, buf, pos); |
| 826 | } |
| 827 | |
Tomas Winkler | 712b6cf | 2008-03-12 16:58:52 -0700 | [diff] [blame] | 828 | DEBUGFS_READ_WRITE_FILE_OPS(sram); |
Wey-Yi Guy | b03d7d0 | 2009-12-14 14:12:20 -0800 | [diff] [blame] | 829 | DEBUGFS_READ_WRITE_FILE_OPS(log_event); |
Wey-Yi Guy | 0848e29 | 2009-05-22 11:01:46 -0700 | [diff] [blame] | 830 | DEBUGFS_READ_FILE_OPS(nvm); |
Tomas Winkler | 712b6cf | 2008-03-12 16:58:52 -0700 | [diff] [blame] | 831 | DEBUGFS_READ_FILE_OPS(stations); |
Winkler, Tomas | d366df5 | 2008-12-02 12:14:01 -0800 | [diff] [blame] | 832 | DEBUGFS_READ_FILE_OPS(channels); |
Wey-Yi Guy | 08df05a | 2009-03-24 10:02:54 -0700 | [diff] [blame] | 833 | DEBUGFS_READ_FILE_OPS(status); |
Wey-Yi Guy | a83b914 | 2009-04-08 11:39:32 -0700 | [diff] [blame] | 834 | DEBUGFS_READ_WRITE_FILE_OPS(interrupt); |
Wey-Yi Guy | f5ad69f | 2009-07-09 10:33:36 -0700 | [diff] [blame] | 835 | DEBUGFS_READ_FILE_OPS(qos); |
Wey-Yi Guy | fbf3a2a | 2009-07-24 11:13:04 -0700 | [diff] [blame] | 836 | DEBUGFS_READ_FILE_OPS(thermal_throttling); |
Wey-Yi Guy | 1e4247d | 2009-07-27 13:50:15 -0700 | [diff] [blame] | 837 | DEBUGFS_READ_WRITE_FILE_OPS(disable_ht40); |
Johannes Berg | e312c24 | 2009-08-07 15:41:51 -0700 | [diff] [blame] | 838 | DEBUGFS_READ_WRITE_FILE_OPS(sleep_level_override); |
| 839 | DEBUGFS_READ_FILE_OPS(current_sleep_command); |
Tomas Winkler | 712b6cf | 2008-03-12 16:58:52 -0700 | [diff] [blame] | 840 | |
Wey-Yi Guy | 20594eb | 2009-08-07 15:41:39 -0700 | [diff] [blame] | 841 | static ssize_t iwl_dbgfs_traffic_log_read(struct file *file, |
| 842 | char __user *user_buf, |
| 843 | size_t count, loff_t *ppos) |
| 844 | { |
| 845 | struct iwl_priv *priv = file->private_data; |
| 846 | int pos = 0, ofs = 0; |
| 847 | int cnt = 0, entry; |
| 848 | struct iwl_tx_queue *txq; |
| 849 | struct iwl_queue *q; |
| 850 | struct iwl_rx_queue *rxq = &priv->rxq; |
| 851 | char *buf; |
| 852 | int bufsz = ((IWL_TRAFFIC_ENTRIES * IWL_TRAFFIC_ENTRY_SIZE * 64) * 2) + |
Wey-Yi Guy | 7cb1b08 | 2010-10-06 08:10:00 -0700 | [diff] [blame] | 853 | (priv->cfg->base_params->num_of_queues * 32 * 8) + 400; |
Wey-Yi Guy | 20594eb | 2009-08-07 15:41:39 -0700 | [diff] [blame] | 854 | const u8 *ptr; |
| 855 | ssize_t ret; |
| 856 | |
Wey-Yi Guy | 88804e2 | 2009-10-09 13:20:28 -0700 | [diff] [blame] | 857 | if (!priv->txq) { |
| 858 | IWL_ERR(priv, "txq not ready\n"); |
| 859 | return -EAGAIN; |
| 860 | } |
Wey-Yi Guy | 20594eb | 2009-08-07 15:41:39 -0700 | [diff] [blame] | 861 | buf = kzalloc(bufsz, GFP_KERNEL); |
| 862 | if (!buf) { |
| 863 | IWL_ERR(priv, "Can not allocate buffer\n"); |
| 864 | return -ENOMEM; |
| 865 | } |
| 866 | pos += scnprintf(buf + pos, bufsz - pos, "Tx Queue\n"); |
| 867 | for (cnt = 0; cnt < priv->hw_params.max_txq_num; cnt++) { |
| 868 | txq = &priv->txq[cnt]; |
| 869 | q = &txq->q; |
| 870 | pos += scnprintf(buf + pos, bufsz - pos, |
| 871 | "q[%d]: read_ptr: %u, write_ptr: %u\n", |
| 872 | cnt, q->read_ptr, q->write_ptr); |
| 873 | } |
| 874 | if (priv->tx_traffic && (iwl_debug_level & IWL_DL_TX)) { |
| 875 | ptr = priv->tx_traffic; |
| 876 | pos += scnprintf(buf + pos, bufsz - pos, |
| 877 | "Tx Traffic idx: %u\n", priv->tx_traffic_idx); |
| 878 | for (cnt = 0, ofs = 0; cnt < IWL_TRAFFIC_ENTRIES; cnt++) { |
| 879 | for (entry = 0; entry < IWL_TRAFFIC_ENTRY_SIZE / 16; |
| 880 | entry++, ofs += 16) { |
| 881 | pos += scnprintf(buf + pos, bufsz - pos, |
| 882 | "0x%.4x ", ofs); |
| 883 | hex_dump_to_buffer(ptr + ofs, 16, 16, 2, |
| 884 | buf + pos, bufsz - pos, 0); |
Reinette Chatre | 2fac971 | 2009-09-25 14:24:21 -0700 | [diff] [blame] | 885 | pos += strlen(buf + pos); |
Wey-Yi Guy | 20594eb | 2009-08-07 15:41:39 -0700 | [diff] [blame] | 886 | if (bufsz - pos > 0) |
| 887 | buf[pos++] = '\n'; |
| 888 | } |
| 889 | } |
| 890 | } |
| 891 | |
| 892 | pos += scnprintf(buf + pos, bufsz - pos, "Rx Queue\n"); |
| 893 | pos += scnprintf(buf + pos, bufsz - pos, |
| 894 | "read: %u, write: %u\n", |
| 895 | rxq->read, rxq->write); |
| 896 | |
| 897 | if (priv->rx_traffic && (iwl_debug_level & IWL_DL_RX)) { |
| 898 | ptr = priv->rx_traffic; |
| 899 | pos += scnprintf(buf + pos, bufsz - pos, |
| 900 | "Rx Traffic idx: %u\n", priv->rx_traffic_idx); |
| 901 | for (cnt = 0, ofs = 0; cnt < IWL_TRAFFIC_ENTRIES; cnt++) { |
| 902 | for (entry = 0; entry < IWL_TRAFFIC_ENTRY_SIZE / 16; |
| 903 | entry++, ofs += 16) { |
| 904 | pos += scnprintf(buf + pos, bufsz - pos, |
| 905 | "0x%.4x ", ofs); |
| 906 | hex_dump_to_buffer(ptr + ofs, 16, 16, 2, |
| 907 | buf + pos, bufsz - pos, 0); |
Reinette Chatre | 2fac971 | 2009-09-25 14:24:21 -0700 | [diff] [blame] | 908 | pos += strlen(buf + pos); |
Wey-Yi Guy | 20594eb | 2009-08-07 15:41:39 -0700 | [diff] [blame] | 909 | if (bufsz - pos > 0) |
| 910 | buf[pos++] = '\n'; |
| 911 | } |
| 912 | } |
| 913 | } |
| 914 | |
| 915 | ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos); |
| 916 | kfree(buf); |
| 917 | return ret; |
| 918 | } |
| 919 | |
| 920 | static ssize_t iwl_dbgfs_traffic_log_write(struct file *file, |
| 921 | const char __user *user_buf, |
| 922 | size_t count, loff_t *ppos) |
| 923 | { |
| 924 | struct iwl_priv *priv = file->private_data; |
| 925 | char buf[8]; |
| 926 | int buf_size; |
| 927 | int traffic_log; |
| 928 | |
| 929 | memset(buf, 0, sizeof(buf)); |
| 930 | buf_size = min(count, sizeof(buf) - 1); |
| 931 | if (copy_from_user(buf, user_buf, buf_size)) |
| 932 | return -EFAULT; |
| 933 | if (sscanf(buf, "%d", &traffic_log) != 1) |
| 934 | return -EFAULT; |
| 935 | if (traffic_log == 0) |
| 936 | iwl_reset_traffic_log(priv); |
| 937 | |
| 938 | return count; |
| 939 | } |
| 940 | |
Wey-Yi Guy | 141b03e | 2009-08-07 15:41:41 -0700 | [diff] [blame] | 941 | static ssize_t iwl_dbgfs_tx_queue_read(struct file *file, |
| 942 | char __user *user_buf, |
| 943 | size_t count, loff_t *ppos) { |
| 944 | |
H Hartley Sweeten | 28f63a4 | 2010-01-08 16:14:10 -0700 | [diff] [blame] | 945 | struct iwl_priv *priv = file->private_data; |
Wey-Yi Guy | 141b03e | 2009-08-07 15:41:41 -0700 | [diff] [blame] | 946 | struct iwl_tx_queue *txq; |
| 947 | struct iwl_queue *q; |
| 948 | char *buf; |
| 949 | int pos = 0; |
| 950 | int cnt; |
| 951 | int ret; |
Wey-Yi Guy | 7cb1b08 | 2010-10-06 08:10:00 -0700 | [diff] [blame] | 952 | const size_t bufsz = sizeof(char) * 64 * |
| 953 | priv->cfg->base_params->num_of_queues; |
Wey-Yi Guy | 141b03e | 2009-08-07 15:41:41 -0700 | [diff] [blame] | 954 | |
Wey-Yi Guy | 88804e2 | 2009-10-09 13:20:28 -0700 | [diff] [blame] | 955 | if (!priv->txq) { |
| 956 | IWL_ERR(priv, "txq not ready\n"); |
| 957 | return -EAGAIN; |
| 958 | } |
Wey-Yi Guy | 141b03e | 2009-08-07 15:41:41 -0700 | [diff] [blame] | 959 | buf = kzalloc(bufsz, GFP_KERNEL); |
| 960 | if (!buf) |
| 961 | return -ENOMEM; |
| 962 | |
| 963 | for (cnt = 0; cnt < priv->hw_params.max_txq_num; cnt++) { |
| 964 | txq = &priv->txq[cnt]; |
| 965 | q = &txq->q; |
| 966 | pos += scnprintf(buf + pos, bufsz - pos, |
| 967 | "hwq %.2d: read=%u write=%u stop=%d" |
| 968 | " swq_id=%#.2x (ac %d/hwq %d)\n", |
| 969 | cnt, q->read_ptr, q->write_ptr, |
| 970 | !!test_bit(cnt, priv->queue_stopped), |
Johannes Berg | ea9b307 | 2010-11-10 18:25:45 -0800 | [diff] [blame] | 971 | txq->swq_id, txq->swq_id & 3, |
| 972 | (txq->swq_id >> 2) & 0x1f); |
Wey-Yi Guy | 141b03e | 2009-08-07 15:41:41 -0700 | [diff] [blame] | 973 | if (cnt >= 4) |
| 974 | continue; |
| 975 | /* for the ACs, display the stop count too */ |
| 976 | pos += scnprintf(buf + pos, bufsz - pos, |
| 977 | " stop-count: %d\n", |
| 978 | atomic_read(&priv->queue_stop_count[cnt])); |
| 979 | } |
| 980 | ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos); |
| 981 | kfree(buf); |
| 982 | return ret; |
| 983 | } |
| 984 | |
| 985 | static ssize_t iwl_dbgfs_rx_queue_read(struct file *file, |
| 986 | char __user *user_buf, |
| 987 | size_t count, loff_t *ppos) { |
| 988 | |
H Hartley Sweeten | 28f63a4 | 2010-01-08 16:14:10 -0700 | [diff] [blame] | 989 | struct iwl_priv *priv = file->private_data; |
Wey-Yi Guy | 141b03e | 2009-08-07 15:41:41 -0700 | [diff] [blame] | 990 | struct iwl_rx_queue *rxq = &priv->rxq; |
| 991 | char buf[256]; |
| 992 | int pos = 0; |
| 993 | const size_t bufsz = sizeof(buf); |
| 994 | |
| 995 | pos += scnprintf(buf + pos, bufsz - pos, "read: %u\n", |
| 996 | rxq->read); |
| 997 | pos += scnprintf(buf + pos, bufsz - pos, "write: %u\n", |
| 998 | rxq->write); |
| 999 | pos += scnprintf(buf + pos, bufsz - pos, "free_count: %u\n", |
| 1000 | rxq->free_count); |
Dor Shaish | f5cc6a2 | 2010-06-01 00:04:08 -0700 | [diff] [blame] | 1001 | if (rxq->rb_stts) { |
| 1002 | pos += scnprintf(buf + pos, bufsz - pos, "closed_rb_num: %u\n", |
Wey-Yi Guy | 141b03e | 2009-08-07 15:41:41 -0700 | [diff] [blame] | 1003 | le16_to_cpu(rxq->rb_stts->closed_rb_num) & 0x0FFF); |
Dor Shaish | f5cc6a2 | 2010-06-01 00:04:08 -0700 | [diff] [blame] | 1004 | } else { |
| 1005 | pos += scnprintf(buf + pos, bufsz - pos, |
| 1006 | "closed_rb_num: Not Allocated\n"); |
| 1007 | } |
Wey-Yi Guy | 141b03e | 2009-08-07 15:41:41 -0700 | [diff] [blame] | 1008 | return simple_read_from_buffer(user_buf, count, ppos, buf, pos); |
| 1009 | } |
| 1010 | |
Wey-Yi Guy | e8fe59a | 2009-08-07 15:41:42 -0700 | [diff] [blame] | 1011 | static ssize_t iwl_dbgfs_ucode_rx_stats_read(struct file *file, |
| 1012 | char __user *user_buf, |
| 1013 | size_t count, loff_t *ppos) |
| 1014 | { |
H Hartley Sweeten | 28f63a4 | 2010-01-08 16:14:10 -0700 | [diff] [blame] | 1015 | struct iwl_priv *priv = file->private_data; |
Abhijeet Kolekar | 17f36fc | 2010-04-16 10:03:54 -0700 | [diff] [blame] | 1016 | return priv->cfg->ops->lib->debugfs_ops.rx_stats_read(file, |
| 1017 | user_buf, count, ppos); |
Wey-Yi Guy | e8fe59a | 2009-08-07 15:41:42 -0700 | [diff] [blame] | 1018 | } |
| 1019 | |
| 1020 | static ssize_t iwl_dbgfs_ucode_tx_stats_read(struct file *file, |
| 1021 | char __user *user_buf, |
| 1022 | size_t count, loff_t *ppos) |
| 1023 | { |
H Hartley Sweeten | 28f63a4 | 2010-01-08 16:14:10 -0700 | [diff] [blame] | 1024 | struct iwl_priv *priv = file->private_data; |
Abhijeet Kolekar | 17f36fc | 2010-04-16 10:03:54 -0700 | [diff] [blame] | 1025 | return priv->cfg->ops->lib->debugfs_ops.tx_stats_read(file, |
| 1026 | user_buf, count, ppos); |
Wey-Yi Guy | e8fe59a | 2009-08-07 15:41:42 -0700 | [diff] [blame] | 1027 | } |
| 1028 | |
| 1029 | static ssize_t iwl_dbgfs_ucode_general_stats_read(struct file *file, |
| 1030 | char __user *user_buf, |
| 1031 | size_t count, loff_t *ppos) |
| 1032 | { |
H Hartley Sweeten | 28f63a4 | 2010-01-08 16:14:10 -0700 | [diff] [blame] | 1033 | struct iwl_priv *priv = file->private_data; |
Abhijeet Kolekar | 17f36fc | 2010-04-16 10:03:54 -0700 | [diff] [blame] | 1034 | return priv->cfg->ops->lib->debugfs_ops.general_stats_read(file, |
| 1035 | user_buf, count, ppos); |
Wey-Yi Guy | e8fe59a | 2009-08-07 15:41:42 -0700 | [diff] [blame] | 1036 | } |
| 1037 | |
Wey-Yi Guy | 5225935 | 2009-08-07 15:41:43 -0700 | [diff] [blame] | 1038 | static ssize_t iwl_dbgfs_sensitivity_read(struct file *file, |
| 1039 | char __user *user_buf, |
| 1040 | size_t count, loff_t *ppos) { |
| 1041 | |
H Hartley Sweeten | 28f63a4 | 2010-01-08 16:14:10 -0700 | [diff] [blame] | 1042 | struct iwl_priv *priv = file->private_data; |
Wey-Yi Guy | 5225935 | 2009-08-07 15:41:43 -0700 | [diff] [blame] | 1043 | int pos = 0; |
| 1044 | int cnt = 0; |
| 1045 | char *buf; |
| 1046 | int bufsz = sizeof(struct iwl_sensitivity_data) * 4 + 100; |
| 1047 | ssize_t ret; |
| 1048 | struct iwl_sensitivity_data *data; |
| 1049 | |
| 1050 | data = &priv->sensitivity_data; |
| 1051 | buf = kzalloc(bufsz, GFP_KERNEL); |
| 1052 | if (!buf) { |
| 1053 | IWL_ERR(priv, "Can not allocate Buffer\n"); |
| 1054 | return -ENOMEM; |
| 1055 | } |
| 1056 | |
| 1057 | pos += scnprintf(buf + pos, bufsz - pos, "auto_corr_ofdm:\t\t\t %u\n", |
| 1058 | data->auto_corr_ofdm); |
| 1059 | pos += scnprintf(buf + pos, bufsz - pos, |
| 1060 | "auto_corr_ofdm_mrc:\t\t %u\n", |
| 1061 | data->auto_corr_ofdm_mrc); |
| 1062 | pos += scnprintf(buf + pos, bufsz - pos, "auto_corr_ofdm_x1:\t\t %u\n", |
| 1063 | data->auto_corr_ofdm_x1); |
| 1064 | pos += scnprintf(buf + pos, bufsz - pos, |
| 1065 | "auto_corr_ofdm_mrc_x1:\t\t %u\n", |
| 1066 | data->auto_corr_ofdm_mrc_x1); |
| 1067 | pos += scnprintf(buf + pos, bufsz - pos, "auto_corr_cck:\t\t\t %u\n", |
| 1068 | data->auto_corr_cck); |
| 1069 | pos += scnprintf(buf + pos, bufsz - pos, "auto_corr_cck_mrc:\t\t %u\n", |
| 1070 | data->auto_corr_cck_mrc); |
| 1071 | pos += scnprintf(buf + pos, bufsz - pos, |
| 1072 | "last_bad_plcp_cnt_ofdm:\t\t %u\n", |
| 1073 | data->last_bad_plcp_cnt_ofdm); |
| 1074 | pos += scnprintf(buf + pos, bufsz - pos, "last_fa_cnt_ofdm:\t\t %u\n", |
| 1075 | data->last_fa_cnt_ofdm); |
| 1076 | pos += scnprintf(buf + pos, bufsz - pos, |
| 1077 | "last_bad_plcp_cnt_cck:\t\t %u\n", |
| 1078 | data->last_bad_plcp_cnt_cck); |
| 1079 | pos += scnprintf(buf + pos, bufsz - pos, "last_fa_cnt_cck:\t\t %u\n", |
| 1080 | data->last_fa_cnt_cck); |
| 1081 | pos += scnprintf(buf + pos, bufsz - pos, "nrg_curr_state:\t\t\t %u\n", |
| 1082 | data->nrg_curr_state); |
| 1083 | pos += scnprintf(buf + pos, bufsz - pos, "nrg_prev_state:\t\t\t %u\n", |
| 1084 | data->nrg_prev_state); |
| 1085 | pos += scnprintf(buf + pos, bufsz - pos, "nrg_value:\t\t\t"); |
| 1086 | for (cnt = 0; cnt < 10; cnt++) { |
| 1087 | pos += scnprintf(buf + pos, bufsz - pos, " %u", |
| 1088 | data->nrg_value[cnt]); |
| 1089 | } |
| 1090 | pos += scnprintf(buf + pos, bufsz - pos, "\n"); |
| 1091 | pos += scnprintf(buf + pos, bufsz - pos, "nrg_silence_rssi:\t\t"); |
| 1092 | for (cnt = 0; cnt < NRG_NUM_PREV_STAT_L; cnt++) { |
| 1093 | pos += scnprintf(buf + pos, bufsz - pos, " %u", |
| 1094 | data->nrg_silence_rssi[cnt]); |
| 1095 | } |
| 1096 | pos += scnprintf(buf + pos, bufsz - pos, "\n"); |
| 1097 | pos += scnprintf(buf + pos, bufsz - pos, "nrg_silence_ref:\t\t %u\n", |
| 1098 | data->nrg_silence_ref); |
| 1099 | pos += scnprintf(buf + pos, bufsz - pos, "nrg_energy_idx:\t\t\t %u\n", |
| 1100 | data->nrg_energy_idx); |
| 1101 | pos += scnprintf(buf + pos, bufsz - pos, "nrg_silence_idx:\t\t %u\n", |
| 1102 | data->nrg_silence_idx); |
| 1103 | pos += scnprintf(buf + pos, bufsz - pos, "nrg_th_cck:\t\t\t %u\n", |
| 1104 | data->nrg_th_cck); |
| 1105 | pos += scnprintf(buf + pos, bufsz - pos, |
| 1106 | "nrg_auto_corr_silence_diff:\t %u\n", |
| 1107 | data->nrg_auto_corr_silence_diff); |
| 1108 | pos += scnprintf(buf + pos, bufsz - pos, "num_in_cck_no_fa:\t\t %u\n", |
| 1109 | data->num_in_cck_no_fa); |
| 1110 | pos += scnprintf(buf + pos, bufsz - pos, "nrg_th_ofdm:\t\t\t %u\n", |
| 1111 | data->nrg_th_ofdm); |
| 1112 | |
| 1113 | ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos); |
| 1114 | kfree(buf); |
| 1115 | return ret; |
| 1116 | } |
| 1117 | |
| 1118 | |
| 1119 | static ssize_t iwl_dbgfs_chain_noise_read(struct file *file, |
| 1120 | char __user *user_buf, |
| 1121 | size_t count, loff_t *ppos) { |
| 1122 | |
H Hartley Sweeten | 28f63a4 | 2010-01-08 16:14:10 -0700 | [diff] [blame] | 1123 | struct iwl_priv *priv = file->private_data; |
Wey-Yi Guy | 5225935 | 2009-08-07 15:41:43 -0700 | [diff] [blame] | 1124 | int pos = 0; |
| 1125 | int cnt = 0; |
| 1126 | char *buf; |
| 1127 | int bufsz = sizeof(struct iwl_chain_noise_data) * 4 + 100; |
| 1128 | ssize_t ret; |
| 1129 | struct iwl_chain_noise_data *data; |
| 1130 | |
| 1131 | data = &priv->chain_noise_data; |
| 1132 | buf = kzalloc(bufsz, GFP_KERNEL); |
| 1133 | if (!buf) { |
| 1134 | IWL_ERR(priv, "Can not allocate Buffer\n"); |
| 1135 | return -ENOMEM; |
| 1136 | } |
| 1137 | |
| 1138 | pos += scnprintf(buf + pos, bufsz - pos, "active_chains:\t\t\t %u\n", |
| 1139 | data->active_chains); |
| 1140 | pos += scnprintf(buf + pos, bufsz - pos, "chain_noise_a:\t\t\t %u\n", |
| 1141 | data->chain_noise_a); |
| 1142 | pos += scnprintf(buf + pos, bufsz - pos, "chain_noise_b:\t\t\t %u\n", |
| 1143 | data->chain_noise_b); |
| 1144 | pos += scnprintf(buf + pos, bufsz - pos, "chain_noise_c:\t\t\t %u\n", |
| 1145 | data->chain_noise_c); |
| 1146 | pos += scnprintf(buf + pos, bufsz - pos, "chain_signal_a:\t\t\t %u\n", |
| 1147 | data->chain_signal_a); |
| 1148 | pos += scnprintf(buf + pos, bufsz - pos, "chain_signal_b:\t\t\t %u\n", |
| 1149 | data->chain_signal_b); |
| 1150 | pos += scnprintf(buf + pos, bufsz - pos, "chain_signal_c:\t\t\t %u\n", |
| 1151 | data->chain_signal_c); |
| 1152 | pos += scnprintf(buf + pos, bufsz - pos, "beacon_count:\t\t\t %u\n", |
| 1153 | data->beacon_count); |
| 1154 | |
| 1155 | pos += scnprintf(buf + pos, bufsz - pos, "disconn_array:\t\t\t"); |
| 1156 | for (cnt = 0; cnt < NUM_RX_CHAINS; cnt++) { |
| 1157 | pos += scnprintf(buf + pos, bufsz - pos, " %u", |
| 1158 | data->disconn_array[cnt]); |
| 1159 | } |
| 1160 | pos += scnprintf(buf + pos, bufsz - pos, "\n"); |
| 1161 | pos += scnprintf(buf + pos, bufsz - pos, "delta_gain_code:\t\t"); |
| 1162 | for (cnt = 0; cnt < NUM_RX_CHAINS; cnt++) { |
| 1163 | pos += scnprintf(buf + pos, bufsz - pos, " %u", |
| 1164 | data->delta_gain_code[cnt]); |
| 1165 | } |
| 1166 | pos += scnprintf(buf + pos, bufsz - pos, "\n"); |
| 1167 | pos += scnprintf(buf + pos, bufsz - pos, "radio_write:\t\t\t %u\n", |
| 1168 | data->radio_write); |
| 1169 | pos += scnprintf(buf + pos, bufsz - pos, "state:\t\t\t\t %u\n", |
| 1170 | data->state); |
| 1171 | |
| 1172 | ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos); |
| 1173 | kfree(buf); |
| 1174 | return ret; |
| 1175 | } |
| 1176 | |
Wey-Yi Guy | c09430a | 2009-10-16 14:25:50 -0700 | [diff] [blame] | 1177 | static ssize_t iwl_dbgfs_power_save_status_read(struct file *file, |
| 1178 | char __user *user_buf, |
| 1179 | size_t count, loff_t *ppos) |
| 1180 | { |
H Hartley Sweeten | 28f63a4 | 2010-01-08 16:14:10 -0700 | [diff] [blame] | 1181 | struct iwl_priv *priv = file->private_data; |
Wey-Yi Guy | c09430a | 2009-10-16 14:25:50 -0700 | [diff] [blame] | 1182 | char buf[60]; |
| 1183 | int pos = 0; |
| 1184 | const size_t bufsz = sizeof(buf); |
| 1185 | u32 pwrsave_status; |
| 1186 | |
| 1187 | pwrsave_status = iwl_read32(priv, CSR_GP_CNTRL) & |
| 1188 | CSR_GP_REG_POWER_SAVE_STATUS_MSK; |
| 1189 | |
| 1190 | pos += scnprintf(buf + pos, bufsz - pos, "Power Save Status: "); |
| 1191 | pos += scnprintf(buf + pos, bufsz - pos, "%s\n", |
| 1192 | (pwrsave_status == CSR_GP_REG_NO_POWER_SAVE) ? "none" : |
| 1193 | (pwrsave_status == CSR_GP_REG_MAC_POWER_SAVE) ? "MAC" : |
| 1194 | (pwrsave_status == CSR_GP_REG_PHY_POWER_SAVE) ? "PHY" : |
| 1195 | "error"); |
| 1196 | |
| 1197 | return simple_read_from_buffer(user_buf, count, ppos, buf, pos); |
| 1198 | } |
| 1199 | |
Wey-Yi Guy | 7163b8a | 2009-11-20 12:04:56 -0800 | [diff] [blame] | 1200 | 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] | 1201 | const char __user *user_buf, |
| 1202 | size_t count, loff_t *ppos) |
| 1203 | { |
| 1204 | struct iwl_priv *priv = file->private_data; |
| 1205 | char buf[8]; |
| 1206 | int buf_size; |
| 1207 | int clear; |
| 1208 | |
| 1209 | memset(buf, 0, sizeof(buf)); |
| 1210 | buf_size = min(count, sizeof(buf) - 1); |
| 1211 | if (copy_from_user(buf, user_buf, buf_size)) |
| 1212 | return -EFAULT; |
| 1213 | if (sscanf(buf, "%d", &clear) != 1) |
| 1214 | return -EFAULT; |
| 1215 | |
| 1216 | /* make request to uCode to retrieve statistics information */ |
| 1217 | mutex_lock(&priv->mutex); |
| 1218 | iwl_send_statistics_request(priv, CMD_SYNC, true); |
| 1219 | mutex_unlock(&priv->mutex); |
| 1220 | |
| 1221 | return count; |
| 1222 | } |
| 1223 | |
Wey-Yi Guy | 696bdee | 2009-12-10 14:37:25 -0800 | [diff] [blame] | 1224 | static ssize_t iwl_dbgfs_csr_write(struct file *file, |
| 1225 | const char __user *user_buf, |
| 1226 | size_t count, loff_t *ppos) |
| 1227 | { |
| 1228 | struct iwl_priv *priv = file->private_data; |
| 1229 | char buf[8]; |
| 1230 | int buf_size; |
| 1231 | int csr; |
| 1232 | |
| 1233 | memset(buf, 0, sizeof(buf)); |
| 1234 | buf_size = min(count, sizeof(buf) - 1); |
| 1235 | if (copy_from_user(buf, user_buf, buf_size)) |
| 1236 | return -EFAULT; |
| 1237 | if (sscanf(buf, "%d", &csr) != 1) |
| 1238 | return -EFAULT; |
| 1239 | |
| 1240 | if (priv->cfg->ops->lib->dump_csr) |
| 1241 | priv->cfg->ops->lib->dump_csr(priv); |
| 1242 | |
| 1243 | return count; |
| 1244 | } |
| 1245 | |
Wey-Yi Guy | a9e1cb6 | 2009-12-10 14:37:26 -0800 | [diff] [blame] | 1246 | static ssize_t iwl_dbgfs_ucode_tracing_read(struct file *file, |
| 1247 | char __user *user_buf, |
| 1248 | size_t count, loff_t *ppos) { |
| 1249 | |
Joe Perches | 5767430 | 2010-07-12 13:50:06 -0700 | [diff] [blame] | 1250 | struct iwl_priv *priv = file->private_data; |
Wey-Yi Guy | a9e1cb6 | 2009-12-10 14:37:26 -0800 | [diff] [blame] | 1251 | int pos = 0; |
| 1252 | char buf[128]; |
| 1253 | const size_t bufsz = sizeof(buf); |
Wey-Yi Guy | a9e1cb6 | 2009-12-10 14:37:26 -0800 | [diff] [blame] | 1254 | |
| 1255 | pos += scnprintf(buf + pos, bufsz - pos, "ucode trace timer is %s\n", |
| 1256 | priv->event_log.ucode_trace ? "On" : "Off"); |
| 1257 | pos += scnprintf(buf + pos, bufsz - pos, "non_wraps_count:\t\t %u\n", |
| 1258 | priv->event_log.non_wraps_count); |
| 1259 | pos += scnprintf(buf + pos, bufsz - pos, "wraps_once_count:\t\t %u\n", |
| 1260 | priv->event_log.wraps_once_count); |
| 1261 | pos += scnprintf(buf + pos, bufsz - pos, "wraps_more_count:\t\t %u\n", |
| 1262 | priv->event_log.wraps_more_count); |
| 1263 | |
Wey-Yi Guy | 4967c31 | 2010-02-18 15:22:07 -0800 | [diff] [blame] | 1264 | return simple_read_from_buffer(user_buf, count, ppos, buf, pos); |
Wey-Yi Guy | a9e1cb6 | 2009-12-10 14:37:26 -0800 | [diff] [blame] | 1265 | } |
| 1266 | |
| 1267 | static ssize_t iwl_dbgfs_ucode_tracing_write(struct file *file, |
| 1268 | const char __user *user_buf, |
| 1269 | size_t count, loff_t *ppos) |
| 1270 | { |
| 1271 | struct iwl_priv *priv = file->private_data; |
| 1272 | char buf[8]; |
| 1273 | int buf_size; |
| 1274 | int trace; |
| 1275 | |
| 1276 | memset(buf, 0, sizeof(buf)); |
| 1277 | buf_size = min(count, sizeof(buf) - 1); |
| 1278 | if (copy_from_user(buf, user_buf, buf_size)) |
| 1279 | return -EFAULT; |
| 1280 | if (sscanf(buf, "%d", &trace) != 1) |
| 1281 | return -EFAULT; |
| 1282 | |
| 1283 | if (trace) { |
| 1284 | priv->event_log.ucode_trace = true; |
| 1285 | /* schedule the ucode timer to occur in UCODE_TRACE_PERIOD */ |
| 1286 | mod_timer(&priv->ucode_trace, |
| 1287 | jiffies + msecs_to_jiffies(UCODE_TRACE_PERIOD)); |
| 1288 | } else { |
| 1289 | priv->event_log.ucode_trace = false; |
| 1290 | del_timer_sync(&priv->ucode_trace); |
| 1291 | } |
| 1292 | |
| 1293 | return count; |
| 1294 | } |
| 1295 | |
Johannes Berg | 6098720 | 2010-02-18 00:36:07 -0800 | [diff] [blame] | 1296 | static ssize_t iwl_dbgfs_rxon_flags_read(struct file *file, |
| 1297 | char __user *user_buf, |
| 1298 | size_t count, loff_t *ppos) { |
| 1299 | |
Joe Perches | 5767430 | 2010-07-12 13:50:06 -0700 | [diff] [blame] | 1300 | struct iwl_priv *priv = file->private_data; |
Johannes Berg | 6098720 | 2010-02-18 00:36:07 -0800 | [diff] [blame] | 1301 | int len = 0; |
| 1302 | char buf[20]; |
| 1303 | |
Johannes Berg | 246ed35 | 2010-08-23 10:46:32 +0200 | [diff] [blame] | 1304 | len = sprintf(buf, "0x%04X\n", |
| 1305 | le32_to_cpu(priv->contexts[IWL_RXON_CTX_BSS].active.flags)); |
Johannes Berg | 6098720 | 2010-02-18 00:36:07 -0800 | [diff] [blame] | 1306 | return simple_read_from_buffer(user_buf, count, ppos, buf, len); |
| 1307 | } |
| 1308 | |
| 1309 | static ssize_t iwl_dbgfs_rxon_filter_flags_read(struct file *file, |
| 1310 | char __user *user_buf, |
| 1311 | size_t count, loff_t *ppos) { |
| 1312 | |
Joe Perches | 5767430 | 2010-07-12 13:50:06 -0700 | [diff] [blame] | 1313 | struct iwl_priv *priv = file->private_data; |
Johannes Berg | 6098720 | 2010-02-18 00:36:07 -0800 | [diff] [blame] | 1314 | int len = 0; |
| 1315 | char buf[20]; |
| 1316 | |
| 1317 | len = sprintf(buf, "0x%04X\n", |
Johannes Berg | 246ed35 | 2010-08-23 10:46:32 +0200 | [diff] [blame] | 1318 | le32_to_cpu(priv->contexts[IWL_RXON_CTX_BSS].active.filter_flags)); |
Johannes Berg | 6098720 | 2010-02-18 00:36:07 -0800 | [diff] [blame] | 1319 | return simple_read_from_buffer(user_buf, count, ppos, buf, len); |
| 1320 | } |
| 1321 | |
Wey-Yi Guy | 1b3eb82 | 2010-01-15 13:43:39 -0800 | [diff] [blame] | 1322 | static ssize_t iwl_dbgfs_fh_reg_read(struct file *file, |
| 1323 | char __user *user_buf, |
| 1324 | size_t count, loff_t *ppos) |
| 1325 | { |
Joe Perches | 5767430 | 2010-07-12 13:50:06 -0700 | [diff] [blame] | 1326 | struct iwl_priv *priv = file->private_data; |
Wey-Yi Guy | 1b3eb82 | 2010-01-15 13:43:39 -0800 | [diff] [blame] | 1327 | char *buf; |
| 1328 | int pos = 0; |
| 1329 | ssize_t ret = -EFAULT; |
| 1330 | |
| 1331 | if (priv->cfg->ops->lib->dump_fh) { |
| 1332 | ret = pos = priv->cfg->ops->lib->dump_fh(priv, &buf, true); |
| 1333 | if (buf) { |
| 1334 | ret = simple_read_from_buffer(user_buf, |
| 1335 | count, ppos, buf, pos); |
| 1336 | kfree(buf); |
| 1337 | } |
| 1338 | } |
| 1339 | |
| 1340 | return ret; |
| 1341 | } |
| 1342 | |
Wey-Yi Guy | a13d276 | 2010-01-22 14:22:42 -0800 | [diff] [blame] | 1343 | static ssize_t iwl_dbgfs_missed_beacon_read(struct file *file, |
| 1344 | char __user *user_buf, |
| 1345 | size_t count, loff_t *ppos) { |
| 1346 | |
| 1347 | struct iwl_priv *priv = file->private_data; |
| 1348 | int pos = 0; |
| 1349 | char buf[12]; |
| 1350 | const size_t bufsz = sizeof(buf); |
Wey-Yi Guy | a13d276 | 2010-01-22 14:22:42 -0800 | [diff] [blame] | 1351 | |
| 1352 | pos += scnprintf(buf + pos, bufsz - pos, "%d\n", |
| 1353 | priv->missed_beacon_threshold); |
| 1354 | |
Wey-Yi Guy | 4967c31 | 2010-02-18 15:22:07 -0800 | [diff] [blame] | 1355 | return simple_read_from_buffer(user_buf, count, ppos, buf, pos); |
Wey-Yi Guy | a13d276 | 2010-01-22 14:22:42 -0800 | [diff] [blame] | 1356 | } |
| 1357 | |
| 1358 | static ssize_t iwl_dbgfs_missed_beacon_write(struct file *file, |
| 1359 | const char __user *user_buf, |
| 1360 | size_t count, loff_t *ppos) |
| 1361 | { |
| 1362 | struct iwl_priv *priv = file->private_data; |
| 1363 | char buf[8]; |
| 1364 | int buf_size; |
| 1365 | int missed; |
| 1366 | |
| 1367 | memset(buf, 0, sizeof(buf)); |
| 1368 | buf_size = min(count, sizeof(buf) - 1); |
| 1369 | if (copy_from_user(buf, user_buf, buf_size)) |
| 1370 | return -EFAULT; |
| 1371 | if (sscanf(buf, "%d", &missed) != 1) |
| 1372 | return -EINVAL; |
| 1373 | |
| 1374 | if (missed < IWL_MISSED_BEACON_THRESHOLD_MIN || |
| 1375 | missed > IWL_MISSED_BEACON_THRESHOLD_MAX) |
| 1376 | priv->missed_beacon_threshold = |
| 1377 | IWL_MISSED_BEACON_THRESHOLD_DEF; |
| 1378 | else |
| 1379 | priv->missed_beacon_threshold = missed; |
| 1380 | |
| 1381 | return count; |
| 1382 | } |
| 1383 | |
Trieu 'Andrew' Nguyen | 3e4fb5f | 2010-01-22 14:22:46 -0800 | [diff] [blame] | 1384 | static ssize_t iwl_dbgfs_plcp_delta_read(struct file *file, |
| 1385 | char __user *user_buf, |
| 1386 | size_t count, loff_t *ppos) { |
| 1387 | |
Joe Perches | 5767430 | 2010-07-12 13:50:06 -0700 | [diff] [blame] | 1388 | struct iwl_priv *priv = file->private_data; |
Trieu 'Andrew' Nguyen | 3e4fb5f | 2010-01-22 14:22:46 -0800 | [diff] [blame] | 1389 | int pos = 0; |
| 1390 | char buf[12]; |
| 1391 | const size_t bufsz = sizeof(buf); |
Trieu 'Andrew' Nguyen | 3e4fb5f | 2010-01-22 14:22:46 -0800 | [diff] [blame] | 1392 | |
| 1393 | pos += scnprintf(buf + pos, bufsz - pos, "%u\n", |
Wey-Yi Guy | 7cb1b08 | 2010-10-06 08:10:00 -0700 | [diff] [blame] | 1394 | priv->cfg->base_params->plcp_delta_threshold); |
Trieu 'Andrew' Nguyen | 3e4fb5f | 2010-01-22 14:22:46 -0800 | [diff] [blame] | 1395 | |
Wey-Yi Guy | 4967c31 | 2010-02-18 15:22:07 -0800 | [diff] [blame] | 1396 | return simple_read_from_buffer(user_buf, count, ppos, buf, pos); |
Trieu 'Andrew' Nguyen | 3e4fb5f | 2010-01-22 14:22:46 -0800 | [diff] [blame] | 1397 | } |
| 1398 | |
| 1399 | static ssize_t iwl_dbgfs_plcp_delta_write(struct file *file, |
| 1400 | const char __user *user_buf, |
| 1401 | size_t count, loff_t *ppos) { |
| 1402 | |
| 1403 | struct iwl_priv *priv = file->private_data; |
| 1404 | char buf[8]; |
| 1405 | int buf_size; |
| 1406 | int plcp; |
| 1407 | |
| 1408 | memset(buf, 0, sizeof(buf)); |
| 1409 | buf_size = min(count, sizeof(buf) - 1); |
| 1410 | if (copy_from_user(buf, user_buf, buf_size)) |
| 1411 | return -EFAULT; |
| 1412 | if (sscanf(buf, "%d", &plcp) != 1) |
| 1413 | return -EINVAL; |
Wey-Yi Guy | 680788a | 2010-06-17 15:25:00 -0700 | [diff] [blame] | 1414 | if ((plcp < IWL_MAX_PLCP_ERR_THRESHOLD_MIN) || |
Trieu 'Andrew' Nguyen | 3e4fb5f | 2010-01-22 14:22:46 -0800 | [diff] [blame] | 1415 | (plcp > IWL_MAX_PLCP_ERR_THRESHOLD_MAX)) |
Wey-Yi Guy | 7cb1b08 | 2010-10-06 08:10:00 -0700 | [diff] [blame] | 1416 | priv->cfg->base_params->plcp_delta_threshold = |
Wey-Yi Guy | 680788a | 2010-06-17 15:25:00 -0700 | [diff] [blame] | 1417 | IWL_MAX_PLCP_ERR_THRESHOLD_DISABLE; |
Trieu 'Andrew' Nguyen | 3e4fb5f | 2010-01-22 14:22:46 -0800 | [diff] [blame] | 1418 | else |
Wey-Yi Guy | 7cb1b08 | 2010-10-06 08:10:00 -0700 | [diff] [blame] | 1419 | priv->cfg->base_params->plcp_delta_threshold = plcp; |
Trieu 'Andrew' Nguyen | 3e4fb5f | 2010-01-22 14:22:46 -0800 | [diff] [blame] | 1420 | return count; |
| 1421 | } |
| 1422 | |
Wey-Yi Guy | 528c312 | 2010-02-18 22:03:07 -0800 | [diff] [blame] | 1423 | static ssize_t iwl_dbgfs_force_reset_read(struct file *file, |
| 1424 | char __user *user_buf, |
| 1425 | size_t count, loff_t *ppos) { |
| 1426 | |
| 1427 | struct iwl_priv *priv = file->private_data; |
| 1428 | int i, pos = 0; |
| 1429 | char buf[300]; |
| 1430 | const size_t bufsz = sizeof(buf); |
| 1431 | struct iwl_force_reset *force_reset; |
| 1432 | |
| 1433 | for (i = 0; i < IWL_MAX_FORCE_RESET; i++) { |
| 1434 | force_reset = &priv->force_reset[i]; |
| 1435 | pos += scnprintf(buf + pos, bufsz - pos, |
| 1436 | "Force reset method %d\n", i); |
| 1437 | pos += scnprintf(buf + pos, bufsz - pos, |
| 1438 | "\tnumber of reset request: %d\n", |
| 1439 | force_reset->reset_request_count); |
| 1440 | pos += scnprintf(buf + pos, bufsz - pos, |
| 1441 | "\tnumber of reset request success: %d\n", |
| 1442 | force_reset->reset_success_count); |
| 1443 | pos += scnprintf(buf + pos, bufsz - pos, |
| 1444 | "\tnumber of reset request reject: %d\n", |
| 1445 | force_reset->reset_reject_count); |
| 1446 | pos += scnprintf(buf + pos, bufsz - pos, |
| 1447 | "\treset duration: %lu\n", |
| 1448 | force_reset->reset_duration); |
| 1449 | } |
| 1450 | return simple_read_from_buffer(user_buf, count, ppos, buf, pos); |
| 1451 | } |
| 1452 | |
Wey-Yi Guy | 04cafd7 | 2010-02-03 11:47:20 -0800 | [diff] [blame] | 1453 | static ssize_t iwl_dbgfs_force_reset_write(struct file *file, |
| 1454 | const char __user *user_buf, |
| 1455 | size_t count, loff_t *ppos) { |
| 1456 | |
| 1457 | struct iwl_priv *priv = file->private_data; |
| 1458 | char buf[8]; |
| 1459 | int buf_size; |
| 1460 | int reset, ret; |
| 1461 | |
| 1462 | memset(buf, 0, sizeof(buf)); |
| 1463 | buf_size = min(count, sizeof(buf) - 1); |
| 1464 | if (copy_from_user(buf, user_buf, buf_size)) |
| 1465 | return -EFAULT; |
| 1466 | if (sscanf(buf, "%d", &reset) != 1) |
| 1467 | return -EINVAL; |
| 1468 | switch (reset) { |
| 1469 | case IWL_RF_RESET: |
| 1470 | case IWL_FW_RESET: |
Wey-Yi Guy | c04f9f2 | 2010-06-21 16:52:55 -0700 | [diff] [blame] | 1471 | ret = iwl_force_reset(priv, reset, true); |
Wey-Yi Guy | 04cafd7 | 2010-02-03 11:47:20 -0800 | [diff] [blame] | 1472 | break; |
| 1473 | default: |
| 1474 | return -EINVAL; |
| 1475 | } |
| 1476 | return ret ? ret : count; |
| 1477 | } |
| 1478 | |
Wey-Yi Guy | 4bf49a9 | 2010-06-24 13:18:36 -0700 | [diff] [blame] | 1479 | static ssize_t iwl_dbgfs_txfifo_flush_write(struct file *file, |
| 1480 | const char __user *user_buf, |
| 1481 | size_t count, loff_t *ppos) { |
| 1482 | |
| 1483 | struct iwl_priv *priv = file->private_data; |
| 1484 | char buf[8]; |
| 1485 | int buf_size; |
| 1486 | int flush; |
| 1487 | |
| 1488 | memset(buf, 0, sizeof(buf)); |
| 1489 | buf_size = min(count, sizeof(buf) - 1); |
| 1490 | if (copy_from_user(buf, user_buf, buf_size)) |
| 1491 | return -EFAULT; |
| 1492 | if (sscanf(buf, "%d", &flush) != 1) |
| 1493 | return -EINVAL; |
| 1494 | |
| 1495 | if (iwl_is_rfkill(priv)) |
| 1496 | return -EFAULT; |
| 1497 | |
| 1498 | priv->cfg->ops->lib->dev_txfifo_flush(priv, IWL_DROP_ALL); |
| 1499 | |
| 1500 | return count; |
| 1501 | } |
| 1502 | |
Wey-Yi Guy | ffb7d89 | 2010-07-14 08:09:55 -0700 | [diff] [blame] | 1503 | static ssize_t iwl_dbgfs_ucode_bt_stats_read(struct file *file, |
| 1504 | char __user *user_buf, |
| 1505 | size_t count, loff_t *ppos) |
| 1506 | { |
| 1507 | struct iwl_priv *priv = (struct iwl_priv *)file->private_data; |
| 1508 | |
| 1509 | return priv->cfg->ops->lib->debugfs_ops.bt_stats_read(file, |
| 1510 | user_buf, count, ppos); |
| 1511 | } |
| 1512 | |
Stanislaw Gruszka | 22de94d | 2010-12-03 15:41:48 +0100 | [diff] [blame] | 1513 | static ssize_t iwl_dbgfs_wd_timeout_write(struct file *file, |
Wey-Yi Guy | 7bdc473 | 2010-08-23 07:57:07 -0700 | [diff] [blame] | 1514 | const char __user *user_buf, |
| 1515 | size_t count, loff_t *ppos) { |
| 1516 | |
| 1517 | struct iwl_priv *priv = file->private_data; |
| 1518 | char buf[8]; |
| 1519 | int buf_size; |
Stanislaw Gruszka | 22de94d | 2010-12-03 15:41:48 +0100 | [diff] [blame] | 1520 | int timeout; |
Wey-Yi Guy | 7bdc473 | 2010-08-23 07:57:07 -0700 | [diff] [blame] | 1521 | |
| 1522 | memset(buf, 0, sizeof(buf)); |
| 1523 | buf_size = min(count, sizeof(buf) - 1); |
| 1524 | if (copy_from_user(buf, user_buf, buf_size)) |
| 1525 | return -EFAULT; |
Stanislaw Gruszka | 22de94d | 2010-12-03 15:41:48 +0100 | [diff] [blame] | 1526 | if (sscanf(buf, "%d", &timeout) != 1) |
Wey-Yi Guy | 7bdc473 | 2010-08-23 07:57:07 -0700 | [diff] [blame] | 1527 | return -EINVAL; |
Stanislaw Gruszka | 22de94d | 2010-12-03 15:41:48 +0100 | [diff] [blame] | 1528 | if (timeout < 0 || timeout > IWL_MAX_WD_TIMEOUT) |
| 1529 | timeout = IWL_DEF_WD_TIMEOUT; |
Wey-Yi Guy | 7bdc473 | 2010-08-23 07:57:07 -0700 | [diff] [blame] | 1530 | |
Stanislaw Gruszka | 22de94d | 2010-12-03 15:41:48 +0100 | [diff] [blame] | 1531 | priv->cfg->base_params->wd_timeout = timeout; |
| 1532 | iwl_setup_watchdog(priv); |
Wey-Yi Guy | 7bdc473 | 2010-08-23 07:57:07 -0700 | [diff] [blame] | 1533 | return count; |
| 1534 | } |
| 1535 | |
Wey-Yi Guy | befe8c4 | 2010-08-23 07:57:16 -0700 | [diff] [blame] | 1536 | static ssize_t iwl_dbgfs_bt_traffic_read(struct file *file, |
| 1537 | char __user *user_buf, |
| 1538 | size_t count, loff_t *ppos) { |
| 1539 | |
| 1540 | struct iwl_priv *priv = (struct iwl_priv *)file->private_data; |
| 1541 | int pos = 0; |
| 1542 | char buf[200]; |
| 1543 | const size_t bufsz = sizeof(buf); |
| 1544 | ssize_t ret; |
| 1545 | |
Wey-Yi Guy | f21dd00 | 2010-12-08 15:34:52 -0800 | [diff] [blame] | 1546 | if (!priv->bt_enable_flag) { |
| 1547 | pos += scnprintf(buf + pos, bufsz - pos, "BT coex disabled\n"); |
| 1548 | ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos); |
| 1549 | return ret; |
| 1550 | } |
| 1551 | pos += scnprintf(buf + pos, bufsz - pos, "BT enable flag: 0x%x\n", |
| 1552 | priv->bt_enable_flag); |
Wey-Yi Guy | befe8c4 | 2010-08-23 07:57:16 -0700 | [diff] [blame] | 1553 | pos += scnprintf(buf + pos, bufsz - pos, "BT in %s mode\n", |
| 1554 | priv->bt_full_concurrent ? "full concurrency" : "3-wire"); |
| 1555 | pos += scnprintf(buf + pos, bufsz - pos, "BT status: %s, " |
| 1556 | "last traffic notif: %d\n", |
Wey-Yi Guy | 66e863a5 | 2010-11-08 14:54:37 -0800 | [diff] [blame] | 1557 | priv->bt_status ? "On" : "Off", priv->last_bt_traffic_load); |
Wey-Yi Guy | befe8c4 | 2010-08-23 07:57:16 -0700 | [diff] [blame] | 1558 | pos += scnprintf(buf + pos, bufsz - pos, "ch_announcement: %d, " |
| 1559 | "sco_active: %d, kill_ack_mask: %x, " |
| 1560 | "kill_cts_mask: %x\n", |
| 1561 | priv->bt_ch_announce, priv->bt_sco_active, |
| 1562 | priv->kill_ack_mask, priv->kill_cts_mask); |
| 1563 | |
| 1564 | pos += scnprintf(buf + pos, bufsz - pos, "bluetooth traffic load: "); |
| 1565 | switch (priv->bt_traffic_load) { |
| 1566 | case IWL_BT_COEX_TRAFFIC_LOAD_CONTINUOUS: |
| 1567 | pos += scnprintf(buf + pos, bufsz - pos, "Continuous\n"); |
| 1568 | break; |
| 1569 | case IWL_BT_COEX_TRAFFIC_LOAD_HIGH: |
| 1570 | pos += scnprintf(buf + pos, bufsz - pos, "High\n"); |
| 1571 | break; |
| 1572 | case IWL_BT_COEX_TRAFFIC_LOAD_LOW: |
| 1573 | pos += scnprintf(buf + pos, bufsz - pos, "Low\n"); |
| 1574 | break; |
| 1575 | case IWL_BT_COEX_TRAFFIC_LOAD_NONE: |
| 1576 | default: |
| 1577 | pos += scnprintf(buf + pos, bufsz - pos, "None\n"); |
| 1578 | break; |
| 1579 | } |
| 1580 | |
| 1581 | ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos); |
| 1582 | return ret; |
| 1583 | } |
| 1584 | |
Wey-Yi Guy | c6abdc0 | 2010-09-01 17:10:51 -0700 | [diff] [blame] | 1585 | static ssize_t iwl_dbgfs_protection_mode_read(struct file *file, |
| 1586 | char __user *user_buf, |
| 1587 | size_t count, loff_t *ppos) |
| 1588 | { |
| 1589 | struct iwl_priv *priv = (struct iwl_priv *)file->private_data; |
| 1590 | |
| 1591 | int pos = 0; |
| 1592 | char buf[40]; |
| 1593 | const size_t bufsz = sizeof(buf); |
| 1594 | |
Wey-Yi Guy | 7cb1b08 | 2010-10-06 08:10:00 -0700 | [diff] [blame] | 1595 | if (priv->cfg->ht_params) |
| 1596 | pos += scnprintf(buf + pos, bufsz - pos, |
| 1597 | "use %s for aggregation\n", |
| 1598 | (priv->cfg->ht_params->use_rts_for_aggregation) ? |
| 1599 | "rts/cts" : "cts-to-self"); |
| 1600 | else |
| 1601 | pos += scnprintf(buf + pos, bufsz - pos, "N/A"); |
| 1602 | |
Wey-Yi Guy | c6abdc0 | 2010-09-01 17:10:51 -0700 | [diff] [blame] | 1603 | return simple_read_from_buffer(user_buf, count, ppos, buf, pos); |
| 1604 | } |
| 1605 | |
| 1606 | static ssize_t iwl_dbgfs_protection_mode_write(struct file *file, |
| 1607 | const char __user *user_buf, |
| 1608 | size_t count, loff_t *ppos) { |
| 1609 | |
| 1610 | struct iwl_priv *priv = file->private_data; |
| 1611 | char buf[8]; |
| 1612 | int buf_size; |
| 1613 | int rts; |
| 1614 | |
Wey-Yi Guy | 7cb1b08 | 2010-10-06 08:10:00 -0700 | [diff] [blame] | 1615 | if (!priv->cfg->ht_params) |
| 1616 | return -EINVAL; |
| 1617 | |
Wey-Yi Guy | c6abdc0 | 2010-09-01 17:10:51 -0700 | [diff] [blame] | 1618 | memset(buf, 0, sizeof(buf)); |
| 1619 | buf_size = min(count, sizeof(buf) - 1); |
| 1620 | if (copy_from_user(buf, user_buf, buf_size)) |
| 1621 | return -EFAULT; |
| 1622 | if (sscanf(buf, "%d", &rts) != 1) |
| 1623 | return -EINVAL; |
| 1624 | if (rts) |
Wey-Yi Guy | 7cb1b08 | 2010-10-06 08:10:00 -0700 | [diff] [blame] | 1625 | priv->cfg->ht_params->use_rts_for_aggregation = true; |
Wey-Yi Guy | c6abdc0 | 2010-09-01 17:10:51 -0700 | [diff] [blame] | 1626 | else |
Wey-Yi Guy | 7cb1b08 | 2010-10-06 08:10:00 -0700 | [diff] [blame] | 1627 | priv->cfg->ht_params->use_rts_for_aggregation = false; |
Wey-Yi Guy | c6abdc0 | 2010-09-01 17:10:51 -0700 | [diff] [blame] | 1628 | return count; |
| 1629 | } |
| 1630 | |
Wey-Yi Guy | 54a9aa6 | 2010-09-05 10:49:42 -0700 | [diff] [blame] | 1631 | static ssize_t iwl_dbgfs_reply_tx_error_read(struct file *file, |
| 1632 | char __user *user_buf, |
| 1633 | size_t count, loff_t *ppos) |
| 1634 | { |
| 1635 | struct iwl_priv *priv = file->private_data; |
| 1636 | |
| 1637 | if (priv->cfg->ops->lib->debugfs_ops.reply_tx_error) |
| 1638 | return priv->cfg->ops->lib->debugfs_ops.reply_tx_error( |
| 1639 | file, user_buf, count, ppos); |
| 1640 | else |
| 1641 | return -ENODATA; |
| 1642 | } |
Wey-Yi Guy | 7163b8a | 2009-11-20 12:04:56 -0800 | [diff] [blame] | 1643 | DEBUGFS_READ_FILE_OPS(rx_statistics); |
| 1644 | DEBUGFS_READ_FILE_OPS(tx_statistics); |
Wey-Yi Guy | 20594eb | 2009-08-07 15:41:39 -0700 | [diff] [blame] | 1645 | DEBUGFS_READ_WRITE_FILE_OPS(traffic_log); |
Wey-Yi Guy | 141b03e | 2009-08-07 15:41:41 -0700 | [diff] [blame] | 1646 | DEBUGFS_READ_FILE_OPS(rx_queue); |
| 1647 | DEBUGFS_READ_FILE_OPS(tx_queue); |
Wey-Yi Guy | e8fe59a | 2009-08-07 15:41:42 -0700 | [diff] [blame] | 1648 | DEBUGFS_READ_FILE_OPS(ucode_rx_stats); |
| 1649 | DEBUGFS_READ_FILE_OPS(ucode_tx_stats); |
| 1650 | DEBUGFS_READ_FILE_OPS(ucode_general_stats); |
Wey-Yi Guy | 5225935 | 2009-08-07 15:41:43 -0700 | [diff] [blame] | 1651 | DEBUGFS_READ_FILE_OPS(sensitivity); |
| 1652 | DEBUGFS_READ_FILE_OPS(chain_noise); |
Wey-Yi Guy | c09430a | 2009-10-16 14:25:50 -0700 | [diff] [blame] | 1653 | DEBUGFS_READ_FILE_OPS(power_save_status); |
Wey-Yi Guy | 7163b8a | 2009-11-20 12:04:56 -0800 | [diff] [blame] | 1654 | DEBUGFS_WRITE_FILE_OPS(clear_ucode_statistics); |
| 1655 | DEBUGFS_WRITE_FILE_OPS(clear_traffic_statistics); |
Wey-Yi Guy | 696bdee | 2009-12-10 14:37:25 -0800 | [diff] [blame] | 1656 | DEBUGFS_WRITE_FILE_OPS(csr); |
Wey-Yi Guy | a9e1cb6 | 2009-12-10 14:37:26 -0800 | [diff] [blame] | 1657 | DEBUGFS_READ_WRITE_FILE_OPS(ucode_tracing); |
Wey-Yi Guy | 1b3eb82 | 2010-01-15 13:43:39 -0800 | [diff] [blame] | 1658 | DEBUGFS_READ_FILE_OPS(fh_reg); |
Wey-Yi Guy | a13d276 | 2010-01-22 14:22:42 -0800 | [diff] [blame] | 1659 | DEBUGFS_READ_WRITE_FILE_OPS(missed_beacon); |
Trieu 'Andrew' Nguyen | 3e4fb5f | 2010-01-22 14:22:46 -0800 | [diff] [blame] | 1660 | DEBUGFS_READ_WRITE_FILE_OPS(plcp_delta); |
Wey-Yi Guy | 528c312 | 2010-02-18 22:03:07 -0800 | [diff] [blame] | 1661 | DEBUGFS_READ_WRITE_FILE_OPS(force_reset); |
Johannes Berg | 6098720 | 2010-02-18 00:36:07 -0800 | [diff] [blame] | 1662 | DEBUGFS_READ_FILE_OPS(rxon_flags); |
| 1663 | DEBUGFS_READ_FILE_OPS(rxon_filter_flags); |
Wey-Yi Guy | 4bf49a9 | 2010-06-24 13:18:36 -0700 | [diff] [blame] | 1664 | DEBUGFS_WRITE_FILE_OPS(txfifo_flush); |
Wey-Yi Guy | ffb7d89 | 2010-07-14 08:09:55 -0700 | [diff] [blame] | 1665 | DEBUGFS_READ_FILE_OPS(ucode_bt_stats); |
Stanislaw Gruszka | 22de94d | 2010-12-03 15:41:48 +0100 | [diff] [blame] | 1666 | DEBUGFS_WRITE_FILE_OPS(wd_timeout); |
Wey-Yi Guy | befe8c4 | 2010-08-23 07:57:16 -0700 | [diff] [blame] | 1667 | DEBUGFS_READ_FILE_OPS(bt_traffic); |
Wey-Yi Guy | c6abdc0 | 2010-09-01 17:10:51 -0700 | [diff] [blame] | 1668 | DEBUGFS_READ_WRITE_FILE_OPS(protection_mode); |
Wey-Yi Guy | 54a9aa6 | 2010-09-05 10:49:42 -0700 | [diff] [blame] | 1669 | DEBUGFS_READ_FILE_OPS(reply_tx_error); |
Wey-Yi Guy | 20594eb | 2009-08-07 15:41:39 -0700 | [diff] [blame] | 1670 | |
Tomas Winkler | 712b6cf | 2008-03-12 16:58:52 -0700 | [diff] [blame] | 1671 | /* |
| 1672 | * Create the debugfs files and directories |
| 1673 | * |
| 1674 | */ |
| 1675 | int iwl_dbgfs_register(struct iwl_priv *priv, const char *name) |
| 1676 | { |
Zhu Yi | 95b1a82 | 2008-05-29 16:34:50 +0800 | [diff] [blame] | 1677 | struct dentry *phyd = priv->hw->wiphy->debugfsdir; |
Johannes Berg | 4c84a8f | 2010-01-22 14:22:54 -0800 | [diff] [blame] | 1678 | struct dentry *dir_drv, *dir_data, *dir_rf, *dir_debug; |
Tomas Winkler | 712b6cf | 2008-03-12 16:58:52 -0700 | [diff] [blame] | 1679 | |
Johannes Berg | 4c84a8f | 2010-01-22 14:22:54 -0800 | [diff] [blame] | 1680 | dir_drv = debugfs_create_dir(name, phyd); |
| 1681 | if (!dir_drv) |
| 1682 | return -ENOMEM; |
| 1683 | |
| 1684 | priv->debugfs_dir = dir_drv; |
| 1685 | |
| 1686 | dir_data = debugfs_create_dir("data", dir_drv); |
| 1687 | if (!dir_data) |
Tomas Winkler | 712b6cf | 2008-03-12 16:58:52 -0700 | [diff] [blame] | 1688 | goto err; |
Johannes Berg | 4c84a8f | 2010-01-22 14:22:54 -0800 | [diff] [blame] | 1689 | dir_rf = debugfs_create_dir("rf", dir_drv); |
| 1690 | if (!dir_rf) |
Tomas Winkler | 712b6cf | 2008-03-12 16:58:52 -0700 | [diff] [blame] | 1691 | goto err; |
Johannes Berg | 4c84a8f | 2010-01-22 14:22:54 -0800 | [diff] [blame] | 1692 | dir_debug = debugfs_create_dir("debug", dir_drv); |
| 1693 | if (!dir_debug) |
| 1694 | goto err; |
Tomas Winkler | 712b6cf | 2008-03-12 16:58:52 -0700 | [diff] [blame] | 1695 | |
Johannes Berg | 4c84a8f | 2010-01-22 14:22:54 -0800 | [diff] [blame] | 1696 | DEBUGFS_ADD_FILE(nvm, dir_data, S_IRUSR); |
| 1697 | DEBUGFS_ADD_FILE(sram, dir_data, S_IWUSR | S_IRUSR); |
| 1698 | DEBUGFS_ADD_FILE(log_event, dir_data, S_IWUSR | S_IRUSR); |
| 1699 | DEBUGFS_ADD_FILE(stations, dir_data, S_IRUSR); |
| 1700 | DEBUGFS_ADD_FILE(channels, dir_data, S_IRUSR); |
| 1701 | DEBUGFS_ADD_FILE(status, dir_data, S_IRUSR); |
| 1702 | DEBUGFS_ADD_FILE(interrupt, dir_data, S_IWUSR | S_IRUSR); |
| 1703 | DEBUGFS_ADD_FILE(qos, dir_data, S_IRUSR); |
Wey-Yi Guy | 7cb1b08 | 2010-10-06 08:10:00 -0700 | [diff] [blame] | 1704 | if (!priv->cfg->base_params->broken_powersave) { |
Wey-Yi Guy | 381733c | 2010-04-25 09:39:46 -0700 | [diff] [blame] | 1705 | DEBUGFS_ADD_FILE(sleep_level_override, dir_data, |
| 1706 | S_IWUSR | S_IRUSR); |
| 1707 | DEBUGFS_ADD_FILE(current_sleep_command, dir_data, S_IRUSR); |
| 1708 | } |
Johannes Berg | 4c84a8f | 2010-01-22 14:22:54 -0800 | [diff] [blame] | 1709 | DEBUGFS_ADD_FILE(thermal_throttling, dir_data, S_IRUSR); |
| 1710 | DEBUGFS_ADD_FILE(disable_ht40, dir_data, S_IWUSR | S_IRUSR); |
| 1711 | DEBUGFS_ADD_FILE(rx_statistics, dir_debug, S_IRUSR); |
| 1712 | DEBUGFS_ADD_FILE(tx_statistics, dir_debug, S_IRUSR); |
| 1713 | DEBUGFS_ADD_FILE(traffic_log, dir_debug, S_IWUSR | S_IRUSR); |
| 1714 | DEBUGFS_ADD_FILE(rx_queue, dir_debug, S_IRUSR); |
| 1715 | DEBUGFS_ADD_FILE(tx_queue, dir_debug, S_IRUSR); |
Johannes Berg | 4c84a8f | 2010-01-22 14:22:54 -0800 | [diff] [blame] | 1716 | DEBUGFS_ADD_FILE(power_save_status, dir_debug, S_IRUSR); |
| 1717 | DEBUGFS_ADD_FILE(clear_ucode_statistics, dir_debug, S_IWUSR); |
| 1718 | DEBUGFS_ADD_FILE(clear_traffic_statistics, dir_debug, S_IWUSR); |
| 1719 | DEBUGFS_ADD_FILE(csr, dir_debug, S_IWUSR); |
| 1720 | DEBUGFS_ADD_FILE(fh_reg, dir_debug, S_IRUSR); |
| 1721 | DEBUGFS_ADD_FILE(missed_beacon, dir_debug, S_IWUSR); |
Johannes Berg | 4c84a8f | 2010-01-22 14:22:54 -0800 | [diff] [blame] | 1722 | DEBUGFS_ADD_FILE(plcp_delta, dir_debug, S_IWUSR | S_IRUSR); |
Wey-Yi Guy | 528c312 | 2010-02-18 22:03:07 -0800 | [diff] [blame] | 1723 | DEBUGFS_ADD_FILE(force_reset, dir_debug, S_IWUSR | S_IRUSR); |
Abhijeet Kolekar | b8c7626 | 2010-04-08 15:29:07 -0700 | [diff] [blame] | 1724 | DEBUGFS_ADD_FILE(ucode_rx_stats, dir_debug, S_IRUSR); |
| 1725 | DEBUGFS_ADD_FILE(ucode_tx_stats, dir_debug, S_IRUSR); |
| 1726 | DEBUGFS_ADD_FILE(ucode_general_stats, dir_debug, S_IRUSR); |
Wey-Yi Guy | 4bf49a9 | 2010-06-24 13:18:36 -0700 | [diff] [blame] | 1727 | if (priv->cfg->ops->lib->dev_txfifo_flush) |
| 1728 | DEBUGFS_ADD_FILE(txfifo_flush, dir_debug, S_IWUSR); |
Wey-Yi Guy | c6abdc0 | 2010-09-01 17:10:51 -0700 | [diff] [blame] | 1729 | DEBUGFS_ADD_FILE(protection_mode, dir_debug, S_IWUSR | S_IRUSR); |
Abhijeet Kolekar | b8c7626 | 2010-04-08 15:29:07 -0700 | [diff] [blame] | 1730 | |
Wey-Yi Guy | 7cb1b08 | 2010-10-06 08:10:00 -0700 | [diff] [blame] | 1731 | if (priv->cfg->base_params->sensitivity_calib_by_driver) |
Johannes Berg | 4c84a8f | 2010-01-22 14:22:54 -0800 | [diff] [blame] | 1732 | DEBUGFS_ADD_FILE(sensitivity, dir_debug, S_IRUSR); |
Wey-Yi Guy | 7cb1b08 | 2010-10-06 08:10:00 -0700 | [diff] [blame] | 1733 | if (priv->cfg->base_params->chain_noise_calib_by_driver) |
Johannes Berg | 4c84a8f | 2010-01-22 14:22:54 -0800 | [diff] [blame] | 1734 | DEBUGFS_ADD_FILE(chain_noise, dir_debug, S_IRUSR); |
Wey-Yi Guy | 7cb1b08 | 2010-10-06 08:10:00 -0700 | [diff] [blame] | 1735 | if (priv->cfg->base_params->ucode_tracing) |
Johannes Berg | 4c84a8f | 2010-01-22 14:22:54 -0800 | [diff] [blame] | 1736 | DEBUGFS_ADD_FILE(ucode_tracing, dir_debug, S_IWUSR | S_IRUSR); |
Wey-Yi Guy | 7cb1b08 | 2010-10-06 08:10:00 -0700 | [diff] [blame] | 1737 | if (priv->cfg->bt_params && priv->cfg->bt_params->bt_statistics) |
Wey-Yi Guy | ffb7d89 | 2010-07-14 08:09:55 -0700 | [diff] [blame] | 1738 | DEBUGFS_ADD_FILE(ucode_bt_stats, dir_debug, S_IRUSR); |
Wey-Yi Guy | 54a9aa6 | 2010-09-05 10:49:42 -0700 | [diff] [blame] | 1739 | DEBUGFS_ADD_FILE(reply_tx_error, dir_debug, S_IRUSR); |
Johannes Berg | 6098720 | 2010-02-18 00:36:07 -0800 | [diff] [blame] | 1740 | DEBUGFS_ADD_FILE(rxon_flags, dir_debug, S_IWUSR); |
| 1741 | DEBUGFS_ADD_FILE(rxon_filter_flags, dir_debug, S_IWUSR); |
Stanislaw Gruszka | 22de94d | 2010-12-03 15:41:48 +0100 | [diff] [blame] | 1742 | DEBUGFS_ADD_FILE(wd_timeout, dir_debug, S_IWUSR); |
Wey-Yi Guy | 7cb1b08 | 2010-10-06 08:10:00 -0700 | [diff] [blame] | 1743 | if (priv->cfg->bt_params && priv->cfg->bt_params->advanced_bt_coexist) |
Wey-Yi Guy | befe8c4 | 2010-08-23 07:57:16 -0700 | [diff] [blame] | 1744 | DEBUGFS_ADD_FILE(bt_traffic, dir_debug, S_IRUSR); |
Wey-Yi Guy | 7cb1b08 | 2010-10-06 08:10:00 -0700 | [diff] [blame] | 1745 | if (priv->cfg->base_params->sensitivity_calib_by_driver) |
Wey-Yi Guy | 65d1f89 | 2010-04-25 15:41:43 -0700 | [diff] [blame] | 1746 | DEBUGFS_ADD_BOOL(disable_sensitivity, dir_rf, |
| 1747 | &priv->disable_sens_cal); |
Wey-Yi Guy | 7cb1b08 | 2010-10-06 08:10:00 -0700 | [diff] [blame] | 1748 | if (priv->cfg->base_params->chain_noise_calib_by_driver) |
Wey-Yi Guy | 65d1f89 | 2010-04-25 15:41:43 -0700 | [diff] [blame] | 1749 | DEBUGFS_ADD_BOOL(disable_chain_noise, dir_rf, |
| 1750 | &priv->disable_chain_noise_cal); |
Wey-Yi Guy | 7cb1b08 | 2010-10-06 08:10:00 -0700 | [diff] [blame] | 1751 | if (priv->cfg->base_params->tx_power_by_driver) |
Johannes Berg | 4c84a8f | 2010-01-22 14:22:54 -0800 | [diff] [blame] | 1752 | DEBUGFS_ADD_BOOL(disable_tx_power, dir_rf, |
Wey-Yi Guy | 030b865 | 2009-06-12 13:22:55 -0700 | [diff] [blame] | 1753 | &priv->disable_tx_power_cal); |
Tomas Winkler | 712b6cf | 2008-03-12 16:58:52 -0700 | [diff] [blame] | 1754 | return 0; |
| 1755 | |
| 1756 | err: |
Johannes Berg | 4c84a8f | 2010-01-22 14:22:54 -0800 | [diff] [blame] | 1757 | IWL_ERR(priv, "Can't create the debugfs directory\n"); |
Tomas Winkler | 712b6cf | 2008-03-12 16:58:52 -0700 | [diff] [blame] | 1758 | iwl_dbgfs_unregister(priv); |
Johannes Berg | 4c84a8f | 2010-01-22 14:22:54 -0800 | [diff] [blame] | 1759 | return -ENOMEM; |
Tomas Winkler | 712b6cf | 2008-03-12 16:58:52 -0700 | [diff] [blame] | 1760 | } |
| 1761 | EXPORT_SYMBOL(iwl_dbgfs_register); |
| 1762 | |
| 1763 | /** |
| 1764 | * Remove the debugfs files and directories |
| 1765 | * |
| 1766 | */ |
| 1767 | void iwl_dbgfs_unregister(struct iwl_priv *priv) |
| 1768 | { |
Johannes Berg | 4c84a8f | 2010-01-22 14:22:54 -0800 | [diff] [blame] | 1769 | if (!priv->debugfs_dir) |
Tomas Winkler | 712b6cf | 2008-03-12 16:58:52 -0700 | [diff] [blame] | 1770 | return; |
| 1771 | |
Johannes Berg | 4c84a8f | 2010-01-22 14:22:54 -0800 | [diff] [blame] | 1772 | debugfs_remove_recursive(priv->debugfs_dir); |
| 1773 | priv->debugfs_dir = NULL; |
Tomas Winkler | 712b6cf | 2008-03-12 16:58:52 -0700 | [diff] [blame] | 1774 | } |
| 1775 | EXPORT_SYMBOL(iwl_dbgfs_unregister); |
| 1776 | |
| 1777 | |
Tomas Winkler | 445c2df | 2008-05-15 13:54:16 +0800 | [diff] [blame] | 1778 | |