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