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 | *****************************************************************************/ |
Tomas Winkler | 712b6cf | 2008-03-12 16:58:52 -0700 | [diff] [blame] | 28 | #include <linux/ieee80211.h> |
| 29 | #include <net/mac80211.h> |
| 30 | |
| 31 | |
Tomas Winkler | 3e0d4cb | 2008-04-24 11:55:38 -0700 | [diff] [blame] | 32 | #include "iwl-dev.h" |
Tomas Winkler | 712b6cf | 2008-03-12 16:58:52 -0700 | [diff] [blame] | 33 | #include "iwl-debug.h" |
Tomas Winkler | fee1247 | 2008-04-03 16:05:21 -0700 | [diff] [blame] | 34 | #include "iwl-core.h" |
Tomas Winkler | 3395f6e | 2008-03-25 16:33:37 -0700 | [diff] [blame] | 35 | #include "iwl-io.h" |
Wey-Yi Guy | 5225935 | 2009-08-07 15:41:43 -0700 | [diff] [blame] | 36 | #include "iwl-calib.h" |
Tomas Winkler | 712b6cf | 2008-03-12 16:58:52 -0700 | [diff] [blame] | 37 | |
| 38 | /* create and remove of files */ |
Johannes Berg | 4c84a8f | 2010-01-22 14:22:54 -0800 | [diff] [blame] | 39 | #define DEBUGFS_ADD_FILE(name, parent, mode) do { \ |
| 40 | if (!debugfs_create_file(#name, mode, parent, priv, \ |
| 41 | &iwl_dbgfs_##name##_ops)) \ |
| 42 | goto err; \ |
Tomas Winkler | 712b6cf | 2008-03-12 16:58:52 -0700 | [diff] [blame] | 43 | } while (0) |
| 44 | |
Johannes Berg | 4c84a8f | 2010-01-22 14:22:54 -0800 | [diff] [blame] | 45 | #define DEBUGFS_ADD_BOOL(name, parent, ptr) do { \ |
| 46 | struct dentry *__tmp; \ |
| 47 | __tmp = debugfs_create_bool(#name, S_IWUSR | S_IRUSR, \ |
| 48 | parent, ptr); \ |
| 49 | if (IS_ERR(__tmp) || !__tmp) \ |
| 50 | goto err; \ |
Tomas Winkler | 712b6cf | 2008-03-12 16:58:52 -0700 | [diff] [blame] | 51 | } while (0) |
| 52 | |
Johannes Berg | 4c84a8f | 2010-01-22 14:22:54 -0800 | [diff] [blame] | 53 | #define DEBUGFS_ADD_X32(name, parent, ptr) do { \ |
| 54 | struct dentry *__tmp; \ |
| 55 | __tmp = debugfs_create_x32(#name, S_IWUSR | S_IRUSR, \ |
| 56 | parent, ptr); \ |
| 57 | if (IS_ERR(__tmp) || !__tmp) \ |
| 58 | goto err; \ |
Tomas Winkler | 445c2df | 2008-05-15 13:54:16 +0800 | [diff] [blame] | 59 | } while (0) |
| 60 | |
Tomas Winkler | 712b6cf | 2008-03-12 16:58:52 -0700 | [diff] [blame] | 61 | /* file operation */ |
| 62 | #define DEBUGFS_READ_FUNC(name) \ |
| 63 | static ssize_t iwl_dbgfs_##name##_read(struct file *file, \ |
| 64 | char __user *user_buf, \ |
| 65 | size_t count, loff_t *ppos); |
| 66 | |
| 67 | #define DEBUGFS_WRITE_FUNC(name) \ |
| 68 | static ssize_t iwl_dbgfs_##name##_write(struct file *file, \ |
| 69 | const char __user *user_buf, \ |
| 70 | size_t count, loff_t *ppos); |
| 71 | |
| 72 | |
| 73 | static int iwl_dbgfs_open_file_generic(struct inode *inode, struct file *file) |
| 74 | { |
| 75 | file->private_data = inode->i_private; |
| 76 | return 0; |
| 77 | } |
| 78 | |
| 79 | #define DEBUGFS_READ_FILE_OPS(name) \ |
| 80 | DEBUGFS_READ_FUNC(name); \ |
| 81 | static const struct file_operations iwl_dbgfs_##name##_ops = { \ |
| 82 | .read = iwl_dbgfs_##name##_read, \ |
| 83 | .open = iwl_dbgfs_open_file_generic, \ |
| 84 | }; |
| 85 | |
Ester Kummer | 189a2b5 | 2008-05-15 13:54:18 +0800 | [diff] [blame] | 86 | #define DEBUGFS_WRITE_FILE_OPS(name) \ |
| 87 | DEBUGFS_WRITE_FUNC(name); \ |
| 88 | static const struct file_operations iwl_dbgfs_##name##_ops = { \ |
| 89 | .write = iwl_dbgfs_##name##_write, \ |
| 90 | .open = iwl_dbgfs_open_file_generic, \ |
| 91 | }; |
| 92 | |
| 93 | |
Tomas Winkler | 712b6cf | 2008-03-12 16:58:52 -0700 | [diff] [blame] | 94 | #define DEBUGFS_READ_WRITE_FILE_OPS(name) \ |
| 95 | DEBUGFS_READ_FUNC(name); \ |
| 96 | DEBUGFS_WRITE_FUNC(name); \ |
| 97 | static const struct file_operations iwl_dbgfs_##name##_ops = { \ |
| 98 | .write = iwl_dbgfs_##name##_write, \ |
| 99 | .read = iwl_dbgfs_##name##_read, \ |
| 100 | .open = iwl_dbgfs_open_file_generic, \ |
| 101 | }; |
| 102 | |
Tomas Winkler | 712b6cf | 2008-03-12 16:58:52 -0700 | [diff] [blame] | 103 | static ssize_t iwl_dbgfs_tx_statistics_read(struct file *file, |
| 104 | char __user *user_buf, |
| 105 | size_t count, loff_t *ppos) { |
| 106 | |
H Hartley Sweeten | 28f63a4 | 2010-01-08 16:14:10 -0700 | [diff] [blame] | 107 | struct iwl_priv *priv = file->private_data; |
Wey-Yi Guy | 22fdf3c | 2009-08-07 15:41:40 -0700 | [diff] [blame] | 108 | char *buf; |
Tomas Winkler | 712b6cf | 2008-03-12 16:58:52 -0700 | [diff] [blame] | 109 | int pos = 0; |
| 110 | |
Wey-Yi Guy | 22fdf3c | 2009-08-07 15:41:40 -0700 | [diff] [blame] | 111 | int cnt; |
| 112 | ssize_t ret; |
Wey-Yi Guy | 98a7b43 | 2009-11-13 11:56:31 -0800 | [diff] [blame] | 113 | const size_t bufsz = 100 + |
| 114 | sizeof(char) * 50 * (MANAGEMENT_MAX + CONTROL_MAX); |
Wey-Yi Guy | 22fdf3c | 2009-08-07 15:41:40 -0700 | [diff] [blame] | 115 | buf = kzalloc(bufsz, GFP_KERNEL); |
| 116 | if (!buf) |
| 117 | return -ENOMEM; |
| 118 | pos += scnprintf(buf + pos, bufsz - pos, "Management:\n"); |
| 119 | for (cnt = 0; cnt < MANAGEMENT_MAX; cnt++) { |
| 120 | pos += scnprintf(buf + pos, bufsz - pos, |
Wey-Yi Guy | 98a7b43 | 2009-11-13 11:56:31 -0800 | [diff] [blame] | 121 | "\t%25s\t\t: %u\n", |
Wey-Yi Guy | 22fdf3c | 2009-08-07 15:41:40 -0700 | [diff] [blame] | 122 | get_mgmt_string(cnt), |
| 123 | priv->tx_stats.mgmt[cnt]); |
| 124 | } |
| 125 | pos += scnprintf(buf + pos, bufsz - pos, "Control\n"); |
| 126 | for (cnt = 0; cnt < CONTROL_MAX; cnt++) { |
| 127 | pos += scnprintf(buf + pos, bufsz - pos, |
Wey-Yi Guy | 98a7b43 | 2009-11-13 11:56:31 -0800 | [diff] [blame] | 128 | "\t%25s\t\t: %u\n", |
Wey-Yi Guy | 22fdf3c | 2009-08-07 15:41:40 -0700 | [diff] [blame] | 129 | get_ctrl_string(cnt), |
| 130 | priv->tx_stats.ctrl[cnt]); |
| 131 | } |
| 132 | pos += scnprintf(buf + pos, bufsz - pos, "Data:\n"); |
| 133 | pos += scnprintf(buf + pos, bufsz - pos, "\tcnt: %u\n", |
| 134 | priv->tx_stats.data_cnt); |
| 135 | pos += scnprintf(buf + pos, bufsz - pos, "\tbytes: %llu\n", |
| 136 | priv->tx_stats.data_bytes); |
| 137 | ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos); |
| 138 | kfree(buf); |
| 139 | return ret; |
| 140 | } |
Tomas Winkler | 712b6cf | 2008-03-12 16:58:52 -0700 | [diff] [blame] | 141 | |
Wey-Yi Guy | 7163b8a | 2009-11-20 12:04:56 -0800 | [diff] [blame] | 142 | 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] | 143 | const char __user *user_buf, |
| 144 | size_t count, loff_t *ppos) |
| 145 | { |
| 146 | struct iwl_priv *priv = file->private_data; |
| 147 | u32 clear_flag; |
| 148 | char buf[8]; |
| 149 | int buf_size; |
| 150 | |
| 151 | memset(buf, 0, sizeof(buf)); |
| 152 | buf_size = min(count, sizeof(buf) - 1); |
| 153 | if (copy_from_user(buf, user_buf, buf_size)) |
| 154 | return -EFAULT; |
| 155 | if (sscanf(buf, "%x", &clear_flag) != 1) |
| 156 | return -EFAULT; |
Wey-Yi Guy | 7163b8a | 2009-11-20 12:04:56 -0800 | [diff] [blame] | 157 | iwl_clear_traffic_stats(priv); |
Wey-Yi Guy | 22fdf3c | 2009-08-07 15:41:40 -0700 | [diff] [blame] | 158 | |
| 159 | return count; |
Tomas Winkler | 712b6cf | 2008-03-12 16:58:52 -0700 | [diff] [blame] | 160 | } |
| 161 | |
| 162 | static ssize_t iwl_dbgfs_rx_statistics_read(struct file *file, |
| 163 | char __user *user_buf, |
| 164 | size_t count, loff_t *ppos) { |
| 165 | |
H Hartley Sweeten | 28f63a4 | 2010-01-08 16:14:10 -0700 | [diff] [blame] | 166 | struct iwl_priv *priv = file->private_data; |
Wey-Yi Guy | 22fdf3c | 2009-08-07 15:41:40 -0700 | [diff] [blame] | 167 | char *buf; |
Tomas Winkler | 712b6cf | 2008-03-12 16:58:52 -0700 | [diff] [blame] | 168 | int pos = 0; |
Wey-Yi Guy | 22fdf3c | 2009-08-07 15:41:40 -0700 | [diff] [blame] | 169 | int cnt; |
| 170 | ssize_t ret; |
| 171 | const size_t bufsz = 100 + |
Wey-Yi Guy | 98a7b43 | 2009-11-13 11:56:31 -0800 | [diff] [blame] | 172 | sizeof(char) * 50 * (MANAGEMENT_MAX + CONTROL_MAX); |
Wey-Yi Guy | 22fdf3c | 2009-08-07 15:41:40 -0700 | [diff] [blame] | 173 | buf = kzalloc(bufsz, GFP_KERNEL); |
| 174 | if (!buf) |
| 175 | return -ENOMEM; |
Tomas Winkler | 712b6cf | 2008-03-12 16:58:52 -0700 | [diff] [blame] | 176 | |
Wey-Yi Guy | 22fdf3c | 2009-08-07 15:41:40 -0700 | [diff] [blame] | 177 | pos += scnprintf(buf + pos, bufsz - pos, "Management:\n"); |
| 178 | for (cnt = 0; cnt < MANAGEMENT_MAX; cnt++) { |
| 179 | pos += scnprintf(buf + pos, bufsz - pos, |
Wey-Yi Guy | 98a7b43 | 2009-11-13 11:56:31 -0800 | [diff] [blame] | 180 | "\t%25s\t\t: %u\n", |
Wey-Yi Guy | 22fdf3c | 2009-08-07 15:41:40 -0700 | [diff] [blame] | 181 | get_mgmt_string(cnt), |
| 182 | priv->rx_stats.mgmt[cnt]); |
| 183 | } |
| 184 | pos += scnprintf(buf + pos, bufsz - pos, "Control:\n"); |
| 185 | for (cnt = 0; cnt < CONTROL_MAX; cnt++) { |
| 186 | pos += scnprintf(buf + pos, bufsz - pos, |
Wey-Yi Guy | 98a7b43 | 2009-11-13 11:56:31 -0800 | [diff] [blame] | 187 | "\t%25s\t\t: %u\n", |
Wey-Yi Guy | 22fdf3c | 2009-08-07 15:41:40 -0700 | [diff] [blame] | 188 | get_ctrl_string(cnt), |
| 189 | priv->rx_stats.ctrl[cnt]); |
| 190 | } |
| 191 | pos += scnprintf(buf + pos, bufsz - pos, "Data:\n"); |
| 192 | pos += scnprintf(buf + pos, bufsz - pos, "\tcnt: %u\n", |
| 193 | priv->rx_stats.data_cnt); |
| 194 | pos += scnprintf(buf + pos, bufsz - pos, "\tbytes: %llu\n", |
| 195 | priv->rx_stats.data_bytes); |
Tomas Winkler | 712b6cf | 2008-03-12 16:58:52 -0700 | [diff] [blame] | 196 | |
Wey-Yi Guy | 22fdf3c | 2009-08-07 15:41:40 -0700 | [diff] [blame] | 197 | ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos); |
| 198 | kfree(buf); |
| 199 | return ret; |
| 200 | } |
| 201 | |
Tomas Winkler | 712b6cf | 2008-03-12 16:58:52 -0700 | [diff] [blame] | 202 | #define BYTE1_MASK 0x000000ff; |
| 203 | #define BYTE2_MASK 0x0000ffff; |
| 204 | #define BYTE3_MASK 0x00ffffff; |
| 205 | static ssize_t iwl_dbgfs_sram_read(struct file *file, |
| 206 | char __user *user_buf, |
| 207 | size_t count, loff_t *ppos) |
| 208 | { |
| 209 | u32 val; |
Wey-Yi Guy | 2943f13 | 2009-11-20 12:05:00 -0800 | [diff] [blame] | 210 | char *buf; |
Tomas Winkler | 712b6cf | 2008-03-12 16:58:52 -0700 | [diff] [blame] | 211 | ssize_t ret; |
| 212 | int i; |
| 213 | int pos = 0; |
H Hartley Sweeten | 28f63a4 | 2010-01-08 16:14:10 -0700 | [diff] [blame] | 214 | struct iwl_priv *priv = file->private_data; |
Wey-Yi Guy | 2943f13 | 2009-11-20 12:05:00 -0800 | [diff] [blame] | 215 | size_t bufsz; |
Tomas Winkler | 712b6cf | 2008-03-12 16:58:52 -0700 | [diff] [blame] | 216 | |
Wey-Yi Guy | 5ade1e4 | 2009-11-20 12:05:04 -0800 | [diff] [blame] | 217 | /* default is to dump the entire data segment */ |
Johannes Berg | 4c84a8f | 2010-01-22 14:22:54 -0800 | [diff] [blame] | 218 | if (!priv->dbgfs_sram_offset && !priv->dbgfs_sram_len) { |
| 219 | priv->dbgfs_sram_offset = 0x800000; |
Wey-Yi Guy | 5ade1e4 | 2009-11-20 12:05:04 -0800 | [diff] [blame] | 220 | if (priv->ucode_type == UCODE_INIT) |
Johannes Berg | 4c84a8f | 2010-01-22 14:22:54 -0800 | [diff] [blame] | 221 | priv->dbgfs_sram_len = priv->ucode_init_data.len; |
Wey-Yi Guy | 5ade1e4 | 2009-11-20 12:05:04 -0800 | [diff] [blame] | 222 | else |
Johannes Berg | 4c84a8f | 2010-01-22 14:22:54 -0800 | [diff] [blame] | 223 | priv->dbgfs_sram_len = priv->ucode_data.len; |
Wey-Yi Guy | 5ade1e4 | 2009-11-20 12:05:04 -0800 | [diff] [blame] | 224 | } |
Johannes Berg | 4c84a8f | 2010-01-22 14:22:54 -0800 | [diff] [blame] | 225 | bufsz = 30 + priv->dbgfs_sram_len * sizeof(char) * 10; |
Wey-Yi Guy | 2943f13 | 2009-11-20 12:05:00 -0800 | [diff] [blame] | 226 | buf = kmalloc(bufsz, GFP_KERNEL); |
| 227 | if (!buf) |
| 228 | return -ENOMEM; |
Wey-Yi Guy | 5ade1e4 | 2009-11-20 12:05:04 -0800 | [diff] [blame] | 229 | pos += scnprintf(buf + pos, bufsz - pos, "sram_len: 0x%x\n", |
Johannes Berg | 4c84a8f | 2010-01-22 14:22:54 -0800 | [diff] [blame] | 230 | priv->dbgfs_sram_len); |
Wey-Yi Guy | 5ade1e4 | 2009-11-20 12:05:04 -0800 | [diff] [blame] | 231 | pos += scnprintf(buf + pos, bufsz - pos, "sram_offset: 0x%x\n", |
Johannes Berg | 4c84a8f | 2010-01-22 14:22:54 -0800 | [diff] [blame] | 232 | priv->dbgfs_sram_offset); |
| 233 | for (i = priv->dbgfs_sram_len; i > 0; i -= 4) { |
| 234 | val = iwl_read_targ_mem(priv, priv->dbgfs_sram_offset + \ |
| 235 | priv->dbgfs_sram_len - i); |
Tomas Winkler | 712b6cf | 2008-03-12 16:58:52 -0700 | [diff] [blame] | 236 | if (i < 4) { |
| 237 | switch (i) { |
| 238 | case 1: |
| 239 | val &= BYTE1_MASK; |
| 240 | break; |
| 241 | case 2: |
| 242 | val &= BYTE2_MASK; |
| 243 | break; |
| 244 | case 3: |
| 245 | val &= BYTE3_MASK; |
| 246 | break; |
| 247 | } |
| 248 | } |
Wey-Yi Guy | 2943f13 | 2009-11-20 12:05:00 -0800 | [diff] [blame] | 249 | if (!(i % 16)) |
| 250 | pos += scnprintf(buf + pos, bufsz - pos, "\n"); |
Abhijeet Kolekar | db0589f | 2008-04-14 21:16:04 -0700 | [diff] [blame] | 251 | pos += scnprintf(buf + pos, bufsz - pos, "0x%08x ", val); |
Tomas Winkler | 712b6cf | 2008-03-12 16:58:52 -0700 | [diff] [blame] | 252 | } |
Abhijeet Kolekar | db0589f | 2008-04-14 21:16:04 -0700 | [diff] [blame] | 253 | pos += scnprintf(buf + pos, bufsz - pos, "\n"); |
Tomas Winkler | 712b6cf | 2008-03-12 16:58:52 -0700 | [diff] [blame] | 254 | |
| 255 | ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos); |
Wey-Yi Guy | 2943f13 | 2009-11-20 12:05:00 -0800 | [diff] [blame] | 256 | kfree(buf); |
Tomas Winkler | 712b6cf | 2008-03-12 16:58:52 -0700 | [diff] [blame] | 257 | return ret; |
| 258 | } |
| 259 | |
| 260 | static ssize_t iwl_dbgfs_sram_write(struct file *file, |
| 261 | const char __user *user_buf, |
| 262 | size_t count, loff_t *ppos) |
| 263 | { |
| 264 | struct iwl_priv *priv = file->private_data; |
| 265 | char buf[64]; |
| 266 | int buf_size; |
| 267 | u32 offset, len; |
| 268 | |
| 269 | memset(buf, 0, sizeof(buf)); |
| 270 | buf_size = min(count, sizeof(buf) - 1); |
| 271 | if (copy_from_user(buf, user_buf, buf_size)) |
| 272 | return -EFAULT; |
| 273 | |
| 274 | if (sscanf(buf, "%x,%x", &offset, &len) == 2) { |
Johannes Berg | 4c84a8f | 2010-01-22 14:22:54 -0800 | [diff] [blame] | 275 | priv->dbgfs_sram_offset = offset; |
| 276 | priv->dbgfs_sram_len = len; |
Tomas Winkler | 712b6cf | 2008-03-12 16:58:52 -0700 | [diff] [blame] | 277 | } else { |
Johannes Berg | 4c84a8f | 2010-01-22 14:22:54 -0800 | [diff] [blame] | 278 | priv->dbgfs_sram_offset = 0; |
| 279 | priv->dbgfs_sram_len = 0; |
Tomas Winkler | 712b6cf | 2008-03-12 16:58:52 -0700 | [diff] [blame] | 280 | } |
| 281 | |
| 282 | return count; |
| 283 | } |
| 284 | |
| 285 | static ssize_t iwl_dbgfs_stations_read(struct file *file, char __user *user_buf, |
| 286 | size_t count, loff_t *ppos) |
| 287 | { |
H Hartley Sweeten | 28f63a4 | 2010-01-08 16:14:10 -0700 | [diff] [blame] | 288 | struct iwl_priv *priv = file->private_data; |
Tomas Winkler | 6def976 | 2008-05-05 10:22:31 +0800 | [diff] [blame] | 289 | struct iwl_station_entry *station; |
Tomas Winkler | 5425e49 | 2008-04-15 16:01:38 -0700 | [diff] [blame] | 290 | int max_sta = priv->hw_params.max_stations; |
Tomas Winkler | 712b6cf | 2008-03-12 16:58:52 -0700 | [diff] [blame] | 291 | char *buf; |
| 292 | int i, j, pos = 0; |
| 293 | ssize_t ret; |
| 294 | /* Add 30 for initial string */ |
| 295 | const size_t bufsz = 30 + sizeof(char) * 500 * (priv->num_stations); |
Tomas Winkler | 712b6cf | 2008-03-12 16:58:52 -0700 | [diff] [blame] | 296 | |
| 297 | buf = kmalloc(bufsz, GFP_KERNEL); |
Tomas Winkler | 3ac7f14 | 2008-07-21 02:40:14 +0300 | [diff] [blame] | 298 | if (!buf) |
Tomas Winkler | 712b6cf | 2008-03-12 16:58:52 -0700 | [diff] [blame] | 299 | return -ENOMEM; |
| 300 | |
Abhijeet Kolekar | db0589f | 2008-04-14 21:16:04 -0700 | [diff] [blame] | 301 | pos += scnprintf(buf + pos, bufsz - pos, "num of stations: %d\n\n", |
Tomas Winkler | 712b6cf | 2008-03-12 16:58:52 -0700 | [diff] [blame] | 302 | priv->num_stations); |
| 303 | |
| 304 | for (i = 0; i < max_sta; i++) { |
| 305 | station = &priv->stations[i]; |
| 306 | if (station->used) { |
Abhijeet Kolekar | db0589f | 2008-04-14 21:16:04 -0700 | [diff] [blame] | 307 | pos += scnprintf(buf + pos, bufsz - pos, |
| 308 | "station %d:\ngeneral data:\n", i+1); |
Abhijeet Kolekar | db0589f | 2008-04-14 21:16:04 -0700 | [diff] [blame] | 309 | pos += scnprintf(buf + pos, bufsz - pos, "id: %u\n", |
Tomas Winkler | 712b6cf | 2008-03-12 16:58:52 -0700 | [diff] [blame] | 310 | station->sta.sta.sta_id); |
Abhijeet Kolekar | db0589f | 2008-04-14 21:16:04 -0700 | [diff] [blame] | 311 | pos += scnprintf(buf + pos, bufsz - pos, "mode: %u\n", |
Tomas Winkler | 712b6cf | 2008-03-12 16:58:52 -0700 | [diff] [blame] | 312 | station->sta.mode); |
Abhijeet Kolekar | db0589f | 2008-04-14 21:16:04 -0700 | [diff] [blame] | 313 | pos += scnprintf(buf + pos, bufsz - pos, |
| 314 | "flags: 0x%x\n", |
Tomas Winkler | 712b6cf | 2008-03-12 16:58:52 -0700 | [diff] [blame] | 315 | station->sta.station_flags_msk); |
Abhijeet Kolekar | db0589f | 2008-04-14 21:16:04 -0700 | [diff] [blame] | 316 | pos += scnprintf(buf + pos, bufsz - pos, "tid data:\n"); |
| 317 | pos += scnprintf(buf + pos, bufsz - pos, |
David S. Miller | 344234d | 2008-04-19 18:09:39 -0700 | [diff] [blame] | 318 | "seq_num\t\ttxq_id"); |
Abhijeet Kolekar | db0589f | 2008-04-14 21:16:04 -0700 | [diff] [blame] | 319 | pos += scnprintf(buf + pos, bufsz - pos, |
David S. Miller | 344234d | 2008-04-19 18:09:39 -0700 | [diff] [blame] | 320 | "\tframe_count\twait_for_ba\t"); |
Abhijeet Kolekar | db0589f | 2008-04-14 21:16:04 -0700 | [diff] [blame] | 321 | pos += scnprintf(buf + pos, bufsz - pos, |
| 322 | "start_idx\tbitmap0\t"); |
| 323 | pos += scnprintf(buf + pos, bufsz - pos, |
David S. Miller | 344234d | 2008-04-19 18:09:39 -0700 | [diff] [blame] | 324 | "bitmap1\trate_n_flags"); |
David S. Miller | 344234d | 2008-04-19 18:09:39 -0700 | [diff] [blame] | 325 | pos += scnprintf(buf + pos, bufsz - pos, "\n"); |
Tomas Winkler | 712b6cf | 2008-03-12 16:58:52 -0700 | [diff] [blame] | 326 | |
| 327 | for (j = 0; j < MAX_TID_COUNT; j++) { |
Abhijeet Kolekar | db0589f | 2008-04-14 21:16:04 -0700 | [diff] [blame] | 328 | pos += scnprintf(buf + pos, bufsz - pos, |
David S. Miller | 344234d | 2008-04-19 18:09:39 -0700 | [diff] [blame] | 329 | "[%d]:\t\t%u", j, |
Abhijeet Kolekar | db0589f | 2008-04-14 21:16:04 -0700 | [diff] [blame] | 330 | station->tid[j].seq_number); |
| 331 | pos += scnprintf(buf + pos, bufsz - pos, |
David S. Miller | 344234d | 2008-04-19 18:09:39 -0700 | [diff] [blame] | 332 | "\t%u\t\t%u\t\t%u\t\t", |
Tomas Winkler | 712b6cf | 2008-03-12 16:58:52 -0700 | [diff] [blame] | 333 | station->tid[j].agg.txq_id, |
| 334 | station->tid[j].agg.frame_count, |
| 335 | station->tid[j].agg.wait_for_ba); |
Abhijeet Kolekar | db0589f | 2008-04-14 21:16:04 -0700 | [diff] [blame] | 336 | pos += scnprintf(buf + pos, bufsz - pos, |
David S. Miller | 344234d | 2008-04-19 18:09:39 -0700 | [diff] [blame] | 337 | "%u\t%llu\t%u", |
Tomas Winkler | 712b6cf | 2008-03-12 16:58:52 -0700 | [diff] [blame] | 338 | station->tid[j].agg.start_idx, |
John W. Linville | 1678859 | 2008-04-01 20:59:32 -0400 | [diff] [blame] | 339 | (unsigned long long)station->tid[j].agg.bitmap, |
Tomas Winkler | 712b6cf | 2008-03-12 16:58:52 -0700 | [diff] [blame] | 340 | station->tid[j].agg.rate_n_flags); |
David S. Miller | 344234d | 2008-04-19 18:09:39 -0700 | [diff] [blame] | 341 | pos += scnprintf(buf + pos, bufsz - pos, "\n"); |
Tomas Winkler | 712b6cf | 2008-03-12 16:58:52 -0700 | [diff] [blame] | 342 | } |
Abhijeet Kolekar | db0589f | 2008-04-14 21:16:04 -0700 | [diff] [blame] | 343 | pos += scnprintf(buf + pos, bufsz - pos, "\n"); |
Tomas Winkler | 712b6cf | 2008-03-12 16:58:52 -0700 | [diff] [blame] | 344 | } |
| 345 | } |
| 346 | |
| 347 | ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos); |
| 348 | kfree(buf); |
| 349 | return ret; |
| 350 | } |
| 351 | |
Wey-Yi Guy | 0848e29 | 2009-05-22 11:01:46 -0700 | [diff] [blame] | 352 | static ssize_t iwl_dbgfs_nvm_read(struct file *file, |
Tomas Winkler | 8dd266e | 2008-05-05 10:22:32 +0800 | [diff] [blame] | 353 | char __user *user_buf, |
| 354 | size_t count, |
| 355 | loff_t *ppos) |
| 356 | { |
| 357 | ssize_t ret; |
H Hartley Sweeten | 28f63a4 | 2010-01-08 16:14:10 -0700 | [diff] [blame] | 358 | struct iwl_priv *priv = file->private_data; |
Tomas Winkler | 8dd266e | 2008-05-05 10:22:32 +0800 | [diff] [blame] | 359 | int pos = 0, ofs = 0, buf_size = 0; |
| 360 | const u8 *ptr; |
| 361 | char *buf; |
Wey-Yi Guy | e307ddc | 2009-09-11 10:38:16 -0700 | [diff] [blame] | 362 | u16 eeprom_ver; |
Tomas Winkler | 8dd266e | 2008-05-05 10:22:32 +0800 | [diff] [blame] | 363 | size_t eeprom_len = priv->cfg->eeprom_size; |
| 364 | buf_size = 4 * eeprom_len + 256; |
| 365 | |
| 366 | if (eeprom_len % 16) { |
Wey-Yi Guy | 0848e29 | 2009-05-22 11:01:46 -0700 | [diff] [blame] | 367 | IWL_ERR(priv, "NVM size is not multiple of 16.\n"); |
Tomas Winkler | 8dd266e | 2008-05-05 10:22:32 +0800 | [diff] [blame] | 368 | return -ENODATA; |
| 369 | } |
| 370 | |
Julia Lawall | c37457e | 2009-08-03 11:11:45 +0200 | [diff] [blame] | 371 | ptr = priv->eeprom; |
| 372 | if (!ptr) { |
| 373 | IWL_ERR(priv, "Invalid EEPROM/OTP memory\n"); |
| 374 | return -ENOMEM; |
| 375 | } |
| 376 | |
Tomas Winkler | 8dd266e | 2008-05-05 10:22:32 +0800 | [diff] [blame] | 377 | /* 4 characters for byte 0xYY */ |
| 378 | buf = kzalloc(buf_size, GFP_KERNEL); |
| 379 | if (!buf) { |
Winkler, Tomas | 15b1687 | 2008-12-19 10:37:33 +0800 | [diff] [blame] | 380 | IWL_ERR(priv, "Can not allocate Buffer\n"); |
Tomas Winkler | 8dd266e | 2008-05-05 10:22:32 +0800 | [diff] [blame] | 381 | return -ENOMEM; |
| 382 | } |
Wey-Yi Guy | e307ddc | 2009-09-11 10:38:16 -0700 | [diff] [blame] | 383 | eeprom_ver = iwl_eeprom_query16(priv, EEPROM_VERSION); |
| 384 | pos += scnprintf(buf + pos, buf_size - pos, "NVM Type: %s, " |
| 385 | "version: 0x%x\n", |
Wey-Yi Guy | 0848e29 | 2009-05-22 11:01:46 -0700 | [diff] [blame] | 386 | (priv->nvm_device_type == NVM_DEVICE_TYPE_OTP) |
Wey-Yi Guy | e307ddc | 2009-09-11 10:38:16 -0700 | [diff] [blame] | 387 | ? "OTP" : "EEPROM", eeprom_ver); |
Tomas Winkler | 8dd266e | 2008-05-05 10:22:32 +0800 | [diff] [blame] | 388 | for (ofs = 0 ; ofs < eeprom_len ; ofs += 16) { |
| 389 | pos += scnprintf(buf + pos, buf_size - pos, "0x%.4x ", ofs); |
| 390 | hex_dump_to_buffer(ptr + ofs, 16 , 16, 2, buf + pos, |
| 391 | buf_size - pos, 0); |
Reinette Chatre | 2fac971 | 2009-09-25 14:24:21 -0700 | [diff] [blame] | 392 | pos += strlen(buf + pos); |
Tomas Winkler | 8dd266e | 2008-05-05 10:22:32 +0800 | [diff] [blame] | 393 | if (buf_size - pos > 0) |
| 394 | buf[pos++] = '\n'; |
| 395 | } |
| 396 | |
| 397 | ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos); |
| 398 | kfree(buf); |
| 399 | return ret; |
| 400 | } |
Tomas Winkler | 712b6cf | 2008-03-12 16:58:52 -0700 | [diff] [blame] | 401 | |
Wey-Yi Guy | b03d7d0 | 2009-12-14 14:12:20 -0800 | [diff] [blame] | 402 | static ssize_t iwl_dbgfs_log_event_read(struct file *file, |
| 403 | char __user *user_buf, |
| 404 | size_t count, loff_t *ppos) |
| 405 | { |
| 406 | struct iwl_priv *priv = file->private_data; |
| 407 | char *buf; |
| 408 | int pos = 0; |
| 409 | ssize_t ret = -ENOMEM; |
| 410 | |
Wey-Yi Guy | 937c397 | 2010-01-15 13:43:36 -0800 | [diff] [blame] | 411 | ret = pos = priv->cfg->ops->lib->dump_nic_event_log( |
| 412 | priv, true, &buf, true); |
| 413 | if (buf) { |
Wey-Yi Guy | b03d7d0 | 2009-12-14 14:12:20 -0800 | [diff] [blame] | 414 | ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos); |
| 415 | kfree(buf); |
| 416 | } |
| 417 | return ret; |
| 418 | } |
| 419 | |
Ester Kummer | 189a2b5 | 2008-05-15 13:54:18 +0800 | [diff] [blame] | 420 | static ssize_t iwl_dbgfs_log_event_write(struct file *file, |
| 421 | const char __user *user_buf, |
| 422 | size_t count, loff_t *ppos) |
| 423 | { |
| 424 | struct iwl_priv *priv = file->private_data; |
| 425 | u32 event_log_flag; |
| 426 | char buf[8]; |
| 427 | int buf_size; |
| 428 | |
| 429 | memset(buf, 0, sizeof(buf)); |
| 430 | buf_size = min(count, sizeof(buf) - 1); |
| 431 | if (copy_from_user(buf, user_buf, buf_size)) |
| 432 | return -EFAULT; |
| 433 | if (sscanf(buf, "%d", &event_log_flag) != 1) |
| 434 | return -EFAULT; |
| 435 | if (event_log_flag == 1) |
Wey-Yi Guy | b03d7d0 | 2009-12-14 14:12:20 -0800 | [diff] [blame] | 436 | priv->cfg->ops->lib->dump_nic_event_log(priv, true, |
| 437 | NULL, false); |
Ester Kummer | 189a2b5 | 2008-05-15 13:54:18 +0800 | [diff] [blame] | 438 | |
| 439 | return count; |
| 440 | } |
| 441 | |
Winkler, Tomas | d366df5 | 2008-12-02 12:14:01 -0800 | [diff] [blame] | 442 | |
| 443 | |
| 444 | static ssize_t iwl_dbgfs_channels_read(struct file *file, char __user *user_buf, |
| 445 | size_t count, loff_t *ppos) |
| 446 | { |
H Hartley Sweeten | 28f63a4 | 2010-01-08 16:14:10 -0700 | [diff] [blame] | 447 | struct iwl_priv *priv = file->private_data; |
Winkler, Tomas | d366df5 | 2008-12-02 12:14:01 -0800 | [diff] [blame] | 448 | struct ieee80211_channel *channels = NULL; |
| 449 | const struct ieee80211_supported_band *supp_band = NULL; |
| 450 | int pos = 0, i, bufsz = PAGE_SIZE; |
| 451 | char *buf; |
| 452 | ssize_t ret; |
| 453 | |
| 454 | if (!test_bit(STATUS_GEO_CONFIGURED, &priv->status)) |
| 455 | return -EAGAIN; |
| 456 | |
| 457 | buf = kzalloc(bufsz, GFP_KERNEL); |
| 458 | if (!buf) { |
Winkler, Tomas | 15b1687 | 2008-12-19 10:37:33 +0800 | [diff] [blame] | 459 | IWL_ERR(priv, "Can not allocate Buffer\n"); |
Winkler, Tomas | d366df5 | 2008-12-02 12:14:01 -0800 | [diff] [blame] | 460 | return -ENOMEM; |
| 461 | } |
| 462 | |
| 463 | supp_band = iwl_get_hw_mode(priv, IEEE80211_BAND_2GHZ); |
Wey-Yi Guy | a2e2322 | 2009-05-22 11:01:55 -0700 | [diff] [blame] | 464 | if (supp_band) { |
| 465 | channels = supp_band->channels; |
Winkler, Tomas | d366df5 | 2008-12-02 12:14:01 -0800 | [diff] [blame] | 466 | |
Winkler, Tomas | d366df5 | 2008-12-02 12:14:01 -0800 | [diff] [blame] | 467 | pos += scnprintf(buf + pos, bufsz - pos, |
Wey-Yi Guy | a2e2322 | 2009-05-22 11:01:55 -0700 | [diff] [blame] | 468 | "Displaying %d channels in 2.4GHz band 802.11bg):\n", |
| 469 | supp_band->n_channels); |
Winkler, Tomas | d366df5 | 2008-12-02 12:14:01 -0800 | [diff] [blame] | 470 | |
Wey-Yi Guy | a2e2322 | 2009-05-22 11:01:55 -0700 | [diff] [blame] | 471 | for (i = 0; i < supp_band->n_channels; i++) |
| 472 | pos += scnprintf(buf + pos, bufsz - pos, |
| 473 | "%d: %ddBm: BSS%s%s, %s.\n", |
| 474 | ieee80211_frequency_to_channel( |
| 475 | channels[i].center_freq), |
| 476 | channels[i].max_power, |
| 477 | channels[i].flags & IEEE80211_CHAN_RADAR ? |
| 478 | " (IEEE 802.11h required)" : "", |
| 479 | ((channels[i].flags & IEEE80211_CHAN_NO_IBSS) |
| 480 | || (channels[i].flags & |
| 481 | IEEE80211_CHAN_RADAR)) ? "" : |
| 482 | ", IBSS", |
| 483 | channels[i].flags & |
| 484 | IEEE80211_CHAN_PASSIVE_SCAN ? |
| 485 | "passive only" : "active/passive"); |
| 486 | } |
Winkler, Tomas | d366df5 | 2008-12-02 12:14:01 -0800 | [diff] [blame] | 487 | supp_band = iwl_get_hw_mode(priv, IEEE80211_BAND_5GHZ); |
Wey-Yi Guy | a2e2322 | 2009-05-22 11:01:55 -0700 | [diff] [blame] | 488 | if (supp_band) { |
| 489 | channels = supp_band->channels; |
Winkler, Tomas | d366df5 | 2008-12-02 12:14:01 -0800 | [diff] [blame] | 490 | |
Winkler, Tomas | d366df5 | 2008-12-02 12:14:01 -0800 | [diff] [blame] | 491 | pos += scnprintf(buf + pos, bufsz - pos, |
Wey-Yi Guy | a2e2322 | 2009-05-22 11:01:55 -0700 | [diff] [blame] | 492 | "Displaying %d channels in 5.2GHz band (802.11a)\n", |
| 493 | supp_band->n_channels); |
| 494 | |
| 495 | for (i = 0; i < supp_band->n_channels; i++) |
| 496 | pos += scnprintf(buf + pos, bufsz - pos, |
| 497 | "%d: %ddBm: BSS%s%s, %s.\n", |
| 498 | ieee80211_frequency_to_channel( |
| 499 | channels[i].center_freq), |
| 500 | channels[i].max_power, |
| 501 | channels[i].flags & IEEE80211_CHAN_RADAR ? |
| 502 | " (IEEE 802.11h required)" : "", |
| 503 | ((channels[i].flags & IEEE80211_CHAN_NO_IBSS) |
| 504 | || (channels[i].flags & |
| 505 | IEEE80211_CHAN_RADAR)) ? "" : |
| 506 | ", IBSS", |
| 507 | channels[i].flags & |
| 508 | IEEE80211_CHAN_PASSIVE_SCAN ? |
| 509 | "passive only" : "active/passive"); |
| 510 | } |
Winkler, Tomas | d366df5 | 2008-12-02 12:14:01 -0800 | [diff] [blame] | 511 | ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos); |
| 512 | kfree(buf); |
| 513 | return ret; |
| 514 | } |
| 515 | |
Wey-Yi Guy | 08df05a | 2009-03-24 10:02:54 -0700 | [diff] [blame] | 516 | static ssize_t iwl_dbgfs_status_read(struct file *file, |
| 517 | char __user *user_buf, |
| 518 | size_t count, loff_t *ppos) { |
| 519 | |
H Hartley Sweeten | 28f63a4 | 2010-01-08 16:14:10 -0700 | [diff] [blame] | 520 | struct iwl_priv *priv = file->private_data; |
Wey-Yi Guy | 08df05a | 2009-03-24 10:02:54 -0700 | [diff] [blame] | 521 | char buf[512]; |
| 522 | int pos = 0; |
| 523 | const size_t bufsz = sizeof(buf); |
| 524 | |
| 525 | pos += scnprintf(buf + pos, bufsz - pos, "STATUS_HCMD_ACTIVE:\t %d\n", |
| 526 | test_bit(STATUS_HCMD_ACTIVE, &priv->status)); |
Wey-Yi Guy | 08df05a | 2009-03-24 10:02:54 -0700 | [diff] [blame] | 527 | pos += scnprintf(buf + pos, bufsz - pos, "STATUS_INT_ENABLED:\t %d\n", |
| 528 | test_bit(STATUS_INT_ENABLED, &priv->status)); |
| 529 | pos += scnprintf(buf + pos, bufsz - pos, "STATUS_RF_KILL_HW:\t %d\n", |
| 530 | test_bit(STATUS_RF_KILL_HW, &priv->status)); |
Wey-Yi Guy | 7812b16 | 2009-10-02 13:43:58 -0700 | [diff] [blame] | 531 | pos += scnprintf(buf + pos, bufsz - pos, "STATUS_CT_KILL:\t\t %d\n", |
| 532 | test_bit(STATUS_CT_KILL, &priv->status)); |
Wey-Yi Guy | 08df05a | 2009-03-24 10:02:54 -0700 | [diff] [blame] | 533 | pos += scnprintf(buf + pos, bufsz - pos, "STATUS_INIT:\t\t %d\n", |
| 534 | test_bit(STATUS_INIT, &priv->status)); |
| 535 | pos += scnprintf(buf + pos, bufsz - pos, "STATUS_ALIVE:\t\t %d\n", |
| 536 | test_bit(STATUS_ALIVE, &priv->status)); |
| 537 | pos += scnprintf(buf + pos, bufsz - pos, "STATUS_READY:\t\t %d\n", |
| 538 | test_bit(STATUS_READY, &priv->status)); |
| 539 | pos += scnprintf(buf + pos, bufsz - pos, "STATUS_TEMPERATURE:\t %d\n", |
| 540 | test_bit(STATUS_TEMPERATURE, &priv->status)); |
| 541 | pos += scnprintf(buf + pos, bufsz - pos, "STATUS_GEO_CONFIGURED:\t %d\n", |
| 542 | test_bit(STATUS_GEO_CONFIGURED, &priv->status)); |
| 543 | pos += scnprintf(buf + pos, bufsz - pos, "STATUS_EXIT_PENDING:\t %d\n", |
| 544 | test_bit(STATUS_EXIT_PENDING, &priv->status)); |
Wey-Yi Guy | 08df05a | 2009-03-24 10:02:54 -0700 | [diff] [blame] | 545 | pos += scnprintf(buf + pos, bufsz - pos, "STATUS_STATISTICS:\t %d\n", |
| 546 | test_bit(STATUS_STATISTICS, &priv->status)); |
| 547 | pos += scnprintf(buf + pos, bufsz - pos, "STATUS_SCANNING:\t %d\n", |
| 548 | test_bit(STATUS_SCANNING, &priv->status)); |
| 549 | pos += scnprintf(buf + pos, bufsz - pos, "STATUS_SCAN_ABORTING:\t %d\n", |
| 550 | test_bit(STATUS_SCAN_ABORTING, &priv->status)); |
| 551 | pos += scnprintf(buf + pos, bufsz - pos, "STATUS_SCAN_HW:\t\t %d\n", |
| 552 | test_bit(STATUS_SCAN_HW, &priv->status)); |
| 553 | pos += scnprintf(buf + pos, bufsz - pos, "STATUS_POWER_PMI:\t %d\n", |
| 554 | test_bit(STATUS_POWER_PMI, &priv->status)); |
| 555 | pos += scnprintf(buf + pos, bufsz - pos, "STATUS_FW_ERROR:\t %d\n", |
| 556 | test_bit(STATUS_FW_ERROR, &priv->status)); |
Wey-Yi Guy | 08df05a | 2009-03-24 10:02:54 -0700 | [diff] [blame] | 557 | return simple_read_from_buffer(user_buf, count, ppos, buf, pos); |
| 558 | } |
| 559 | |
Wey-Yi Guy | a83b914 | 2009-04-08 11:39:32 -0700 | [diff] [blame] | 560 | static ssize_t iwl_dbgfs_interrupt_read(struct file *file, |
| 561 | char __user *user_buf, |
| 562 | size_t count, loff_t *ppos) { |
| 563 | |
H Hartley Sweeten | 28f63a4 | 2010-01-08 16:14:10 -0700 | [diff] [blame] | 564 | struct iwl_priv *priv = file->private_data; |
Wey-Yi Guy | a83b914 | 2009-04-08 11:39:32 -0700 | [diff] [blame] | 565 | int pos = 0; |
| 566 | int cnt = 0; |
| 567 | char *buf; |
| 568 | int bufsz = 24 * 64; /* 24 items * 64 char per item */ |
| 569 | ssize_t ret; |
| 570 | |
| 571 | buf = kzalloc(bufsz, GFP_KERNEL); |
| 572 | if (!buf) { |
| 573 | IWL_ERR(priv, "Can not allocate Buffer\n"); |
| 574 | return -ENOMEM; |
| 575 | } |
| 576 | |
| 577 | pos += scnprintf(buf + pos, bufsz - pos, |
| 578 | "Interrupt Statistics Report:\n"); |
| 579 | |
| 580 | pos += scnprintf(buf + pos, bufsz - pos, "HW Error:\t\t\t %u\n", |
| 581 | priv->isr_stats.hw); |
| 582 | pos += scnprintf(buf + pos, bufsz - pos, "SW Error:\t\t\t %u\n", |
| 583 | priv->isr_stats.sw); |
| 584 | if (priv->isr_stats.sw > 0) { |
| 585 | pos += scnprintf(buf + pos, bufsz - pos, |
| 586 | "\tLast Restarting Code: 0x%X\n", |
| 587 | priv->isr_stats.sw_err); |
| 588 | } |
| 589 | #ifdef CONFIG_IWLWIFI_DEBUG |
| 590 | pos += scnprintf(buf + pos, bufsz - pos, "Frame transmitted:\t\t %u\n", |
| 591 | priv->isr_stats.sch); |
| 592 | pos += scnprintf(buf + pos, bufsz - pos, "Alive interrupt:\t\t %u\n", |
| 593 | priv->isr_stats.alive); |
| 594 | #endif |
| 595 | pos += scnprintf(buf + pos, bufsz - pos, |
| 596 | "HW RF KILL switch toggled:\t %u\n", |
| 597 | priv->isr_stats.rfkill); |
| 598 | |
| 599 | pos += scnprintf(buf + pos, bufsz - pos, "CT KILL:\t\t\t %u\n", |
| 600 | priv->isr_stats.ctkill); |
| 601 | |
| 602 | pos += scnprintf(buf + pos, bufsz - pos, "Wakeup Interrupt:\t\t %u\n", |
| 603 | priv->isr_stats.wakeup); |
| 604 | |
| 605 | pos += scnprintf(buf + pos, bufsz - pos, |
| 606 | "Rx command responses:\t\t %u\n", |
| 607 | priv->isr_stats.rx); |
| 608 | for (cnt = 0; cnt < REPLY_MAX; cnt++) { |
| 609 | if (priv->isr_stats.rx_handlers[cnt] > 0) |
| 610 | pos += scnprintf(buf + pos, bufsz - pos, |
| 611 | "\tRx handler[%36s]:\t\t %u\n", |
| 612 | get_cmd_string(cnt), |
| 613 | priv->isr_stats.rx_handlers[cnt]); |
| 614 | } |
| 615 | |
| 616 | pos += scnprintf(buf + pos, bufsz - pos, "Tx/FH interrupt:\t\t %u\n", |
| 617 | priv->isr_stats.tx); |
| 618 | |
| 619 | pos += scnprintf(buf + pos, bufsz - pos, "Unexpected INTA:\t\t %u\n", |
| 620 | priv->isr_stats.unhandled); |
| 621 | |
| 622 | ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos); |
| 623 | kfree(buf); |
| 624 | return ret; |
| 625 | } |
| 626 | |
| 627 | static ssize_t iwl_dbgfs_interrupt_write(struct file *file, |
| 628 | const char __user *user_buf, |
| 629 | size_t count, loff_t *ppos) |
| 630 | { |
| 631 | struct iwl_priv *priv = file->private_data; |
| 632 | char buf[8]; |
| 633 | int buf_size; |
| 634 | u32 reset_flag; |
| 635 | |
| 636 | memset(buf, 0, sizeof(buf)); |
| 637 | buf_size = min(count, sizeof(buf) - 1); |
| 638 | if (copy_from_user(buf, user_buf, buf_size)) |
| 639 | return -EFAULT; |
| 640 | if (sscanf(buf, "%x", &reset_flag) != 1) |
| 641 | return -EFAULT; |
| 642 | if (reset_flag == 0) |
| 643 | iwl_clear_isr_stats(priv); |
| 644 | |
| 645 | return count; |
| 646 | } |
| 647 | |
Wey-Yi Guy | f5ad69f | 2009-07-09 10:33:36 -0700 | [diff] [blame] | 648 | static ssize_t iwl_dbgfs_qos_read(struct file *file, char __user *user_buf, |
| 649 | size_t count, loff_t *ppos) |
| 650 | { |
H Hartley Sweeten | 28f63a4 | 2010-01-08 16:14:10 -0700 | [diff] [blame] | 651 | struct iwl_priv *priv = file->private_data; |
Wey-Yi Guy | f5ad69f | 2009-07-09 10:33:36 -0700 | [diff] [blame] | 652 | int pos = 0, i; |
| 653 | char buf[256]; |
| 654 | const size_t bufsz = sizeof(buf); |
Wey-Yi Guy | f5ad69f | 2009-07-09 10:33:36 -0700 | [diff] [blame] | 655 | |
| 656 | for (i = 0; i < AC_NUM; i++) { |
| 657 | pos += scnprintf(buf + pos, bufsz - pos, |
| 658 | "\tcw_min\tcw_max\taifsn\ttxop\n"); |
| 659 | pos += scnprintf(buf + pos, bufsz - pos, |
| 660 | "AC[%d]\t%u\t%u\t%u\t%u\n", i, |
| 661 | priv->qos_data.def_qos_parm.ac[i].cw_min, |
| 662 | priv->qos_data.def_qos_parm.ac[i].cw_max, |
| 663 | priv->qos_data.def_qos_parm.ac[i].aifsn, |
| 664 | priv->qos_data.def_qos_parm.ac[i].edca_txop); |
| 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 | 1e4247d | 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; |
| 739 | if (!iwl_is_associated(priv)) |
| 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 | 1e4247d | 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 | 1e4247d | 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 | 1e4247d | 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 | 1e4247d | 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 | 88804e2 | 2009-10-09 13:20:28 -0700 | [diff] [blame] | 875 | (priv->cfg->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 | d23db55 | 2009-11-20 12:04:59 -0800 | [diff] [blame] | 974 | const size_t bufsz = sizeof(char) * 64 * priv->cfg->num_of_queues; |
Wey-Yi Guy | 141b03e | 2009-08-07 15:41:41 -0700 | [diff] [blame] | 975 | |
Wey-Yi Guy | 88804e2 | 2009-10-09 13:20:28 -0700 | [diff] [blame] | 976 | if (!priv->txq) { |
| 977 | IWL_ERR(priv, "txq not ready\n"); |
| 978 | return -EAGAIN; |
| 979 | } |
Wey-Yi Guy | 141b03e | 2009-08-07 15:41:41 -0700 | [diff] [blame] | 980 | buf = kzalloc(bufsz, GFP_KERNEL); |
| 981 | if (!buf) |
| 982 | return -ENOMEM; |
| 983 | |
| 984 | for (cnt = 0; cnt < priv->hw_params.max_txq_num; cnt++) { |
| 985 | txq = &priv->txq[cnt]; |
| 986 | q = &txq->q; |
| 987 | pos += scnprintf(buf + pos, bufsz - pos, |
| 988 | "hwq %.2d: read=%u write=%u stop=%d" |
| 989 | " swq_id=%#.2x (ac %d/hwq %d)\n", |
| 990 | cnt, q->read_ptr, q->write_ptr, |
| 991 | !!test_bit(cnt, priv->queue_stopped), |
| 992 | txq->swq_id, |
| 993 | txq->swq_id & 0x80 ? txq->swq_id & 3 : |
| 994 | txq->swq_id, |
| 995 | txq->swq_id & 0x80 ? (txq->swq_id >> 2) & |
| 996 | 0x1f : txq->swq_id); |
| 997 | if (cnt >= 4) |
| 998 | continue; |
| 999 | /* for the ACs, display the stop count too */ |
| 1000 | pos += scnprintf(buf + pos, bufsz - pos, |
| 1001 | " stop-count: %d\n", |
| 1002 | atomic_read(&priv->queue_stop_count[cnt])); |
| 1003 | } |
| 1004 | ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos); |
| 1005 | kfree(buf); |
| 1006 | return ret; |
| 1007 | } |
| 1008 | |
| 1009 | static ssize_t iwl_dbgfs_rx_queue_read(struct file *file, |
| 1010 | char __user *user_buf, |
| 1011 | size_t count, loff_t *ppos) { |
| 1012 | |
H Hartley Sweeten | 28f63a4 | 2010-01-08 16:14:10 -0700 | [diff] [blame] | 1013 | struct iwl_priv *priv = file->private_data; |
Wey-Yi Guy | 141b03e | 2009-08-07 15:41:41 -0700 | [diff] [blame] | 1014 | struct iwl_rx_queue *rxq = &priv->rxq; |
| 1015 | char buf[256]; |
| 1016 | int pos = 0; |
| 1017 | const size_t bufsz = sizeof(buf); |
| 1018 | |
| 1019 | pos += scnprintf(buf + pos, bufsz - pos, "read: %u\n", |
| 1020 | rxq->read); |
| 1021 | pos += scnprintf(buf + pos, bufsz - pos, "write: %u\n", |
| 1022 | rxq->write); |
| 1023 | pos += scnprintf(buf + pos, bufsz - pos, "free_count: %u\n", |
| 1024 | rxq->free_count); |
| 1025 | pos += scnprintf(buf + pos, bufsz - pos, "closed_rb_num: %u\n", |
| 1026 | le16_to_cpu(rxq->rb_stts->closed_rb_num) & 0x0FFF); |
| 1027 | return simple_read_from_buffer(user_buf, count, ppos, buf, pos); |
| 1028 | } |
| 1029 | |
Wey-Yi Guy | e8fe59a | 2009-08-07 15:41:42 -0700 | [diff] [blame] | 1030 | static ssize_t iwl_dbgfs_ucode_rx_stats_read(struct file *file, |
| 1031 | char __user *user_buf, |
| 1032 | size_t count, loff_t *ppos) |
| 1033 | { |
H Hartley Sweeten | 28f63a4 | 2010-01-08 16:14:10 -0700 | [diff] [blame] | 1034 | struct iwl_priv *priv = file->private_data; |
Abhijeet Kolekar | 17f36fc | 2010-04-16 10:03:54 -0700 | [diff] [blame] | 1035 | return priv->cfg->ops->lib->debugfs_ops.rx_stats_read(file, |
| 1036 | user_buf, count, ppos); |
Wey-Yi Guy | e8fe59a | 2009-08-07 15:41:42 -0700 | [diff] [blame] | 1037 | } |
| 1038 | |
| 1039 | static ssize_t iwl_dbgfs_ucode_tx_stats_read(struct file *file, |
| 1040 | char __user *user_buf, |
| 1041 | size_t count, loff_t *ppos) |
| 1042 | { |
H Hartley Sweeten | 28f63a4 | 2010-01-08 16:14:10 -0700 | [diff] [blame] | 1043 | struct iwl_priv *priv = file->private_data; |
Abhijeet Kolekar | 17f36fc | 2010-04-16 10:03:54 -0700 | [diff] [blame] | 1044 | return priv->cfg->ops->lib->debugfs_ops.tx_stats_read(file, |
| 1045 | user_buf, count, ppos); |
Wey-Yi Guy | e8fe59a | 2009-08-07 15:41:42 -0700 | [diff] [blame] | 1046 | } |
| 1047 | |
| 1048 | static ssize_t iwl_dbgfs_ucode_general_stats_read(struct file *file, |
| 1049 | char __user *user_buf, |
| 1050 | size_t count, loff_t *ppos) |
| 1051 | { |
H Hartley Sweeten | 28f63a4 | 2010-01-08 16:14:10 -0700 | [diff] [blame] | 1052 | struct iwl_priv *priv = file->private_data; |
Abhijeet Kolekar | 17f36fc | 2010-04-16 10:03:54 -0700 | [diff] [blame] | 1053 | return priv->cfg->ops->lib->debugfs_ops.general_stats_read(file, |
| 1054 | user_buf, count, ppos); |
Wey-Yi Guy | e8fe59a | 2009-08-07 15:41:42 -0700 | [diff] [blame] | 1055 | } |
| 1056 | |
Wey-Yi Guy | 5225935 | 2009-08-07 15:41:43 -0700 | [diff] [blame] | 1057 | static ssize_t iwl_dbgfs_sensitivity_read(struct file *file, |
| 1058 | char __user *user_buf, |
| 1059 | size_t count, loff_t *ppos) { |
| 1060 | |
H Hartley Sweeten | 28f63a4 | 2010-01-08 16:14:10 -0700 | [diff] [blame] | 1061 | struct iwl_priv *priv = file->private_data; |
Wey-Yi Guy | 5225935 | 2009-08-07 15:41:43 -0700 | [diff] [blame] | 1062 | int pos = 0; |
| 1063 | int cnt = 0; |
| 1064 | char *buf; |
| 1065 | int bufsz = sizeof(struct iwl_sensitivity_data) * 4 + 100; |
| 1066 | ssize_t ret; |
| 1067 | struct iwl_sensitivity_data *data; |
| 1068 | |
| 1069 | data = &priv->sensitivity_data; |
| 1070 | buf = kzalloc(bufsz, GFP_KERNEL); |
| 1071 | if (!buf) { |
| 1072 | IWL_ERR(priv, "Can not allocate Buffer\n"); |
| 1073 | return -ENOMEM; |
| 1074 | } |
| 1075 | |
| 1076 | pos += scnprintf(buf + pos, bufsz - pos, "auto_corr_ofdm:\t\t\t %u\n", |
| 1077 | data->auto_corr_ofdm); |
| 1078 | pos += scnprintf(buf + pos, bufsz - pos, |
| 1079 | "auto_corr_ofdm_mrc:\t\t %u\n", |
| 1080 | data->auto_corr_ofdm_mrc); |
| 1081 | pos += scnprintf(buf + pos, bufsz - pos, "auto_corr_ofdm_x1:\t\t %u\n", |
| 1082 | data->auto_corr_ofdm_x1); |
| 1083 | pos += scnprintf(buf + pos, bufsz - pos, |
| 1084 | "auto_corr_ofdm_mrc_x1:\t\t %u\n", |
| 1085 | data->auto_corr_ofdm_mrc_x1); |
| 1086 | pos += scnprintf(buf + pos, bufsz - pos, "auto_corr_cck:\t\t\t %u\n", |
| 1087 | data->auto_corr_cck); |
| 1088 | pos += scnprintf(buf + pos, bufsz - pos, "auto_corr_cck_mrc:\t\t %u\n", |
| 1089 | data->auto_corr_cck_mrc); |
| 1090 | pos += scnprintf(buf + pos, bufsz - pos, |
| 1091 | "last_bad_plcp_cnt_ofdm:\t\t %u\n", |
| 1092 | data->last_bad_plcp_cnt_ofdm); |
| 1093 | pos += scnprintf(buf + pos, bufsz - pos, "last_fa_cnt_ofdm:\t\t %u\n", |
| 1094 | data->last_fa_cnt_ofdm); |
| 1095 | pos += scnprintf(buf + pos, bufsz - pos, |
| 1096 | "last_bad_plcp_cnt_cck:\t\t %u\n", |
| 1097 | data->last_bad_plcp_cnt_cck); |
| 1098 | pos += scnprintf(buf + pos, bufsz - pos, "last_fa_cnt_cck:\t\t %u\n", |
| 1099 | data->last_fa_cnt_cck); |
| 1100 | pos += scnprintf(buf + pos, bufsz - pos, "nrg_curr_state:\t\t\t %u\n", |
| 1101 | data->nrg_curr_state); |
| 1102 | pos += scnprintf(buf + pos, bufsz - pos, "nrg_prev_state:\t\t\t %u\n", |
| 1103 | data->nrg_prev_state); |
| 1104 | pos += scnprintf(buf + pos, bufsz - pos, "nrg_value:\t\t\t"); |
| 1105 | for (cnt = 0; cnt < 10; cnt++) { |
| 1106 | pos += scnprintf(buf + pos, bufsz - pos, " %u", |
| 1107 | data->nrg_value[cnt]); |
| 1108 | } |
| 1109 | pos += scnprintf(buf + pos, bufsz - pos, "\n"); |
| 1110 | pos += scnprintf(buf + pos, bufsz - pos, "nrg_silence_rssi:\t\t"); |
| 1111 | for (cnt = 0; cnt < NRG_NUM_PREV_STAT_L; cnt++) { |
| 1112 | pos += scnprintf(buf + pos, bufsz - pos, " %u", |
| 1113 | data->nrg_silence_rssi[cnt]); |
| 1114 | } |
| 1115 | pos += scnprintf(buf + pos, bufsz - pos, "\n"); |
| 1116 | pos += scnprintf(buf + pos, bufsz - pos, "nrg_silence_ref:\t\t %u\n", |
| 1117 | data->nrg_silence_ref); |
| 1118 | pos += scnprintf(buf + pos, bufsz - pos, "nrg_energy_idx:\t\t\t %u\n", |
| 1119 | data->nrg_energy_idx); |
| 1120 | pos += scnprintf(buf + pos, bufsz - pos, "nrg_silence_idx:\t\t %u\n", |
| 1121 | data->nrg_silence_idx); |
| 1122 | pos += scnprintf(buf + pos, bufsz - pos, "nrg_th_cck:\t\t\t %u\n", |
| 1123 | data->nrg_th_cck); |
| 1124 | pos += scnprintf(buf + pos, bufsz - pos, |
| 1125 | "nrg_auto_corr_silence_diff:\t %u\n", |
| 1126 | data->nrg_auto_corr_silence_diff); |
| 1127 | pos += scnprintf(buf + pos, bufsz - pos, "num_in_cck_no_fa:\t\t %u\n", |
| 1128 | data->num_in_cck_no_fa); |
| 1129 | pos += scnprintf(buf + pos, bufsz - pos, "nrg_th_ofdm:\t\t\t %u\n", |
| 1130 | data->nrg_th_ofdm); |
| 1131 | |
| 1132 | ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos); |
| 1133 | kfree(buf); |
| 1134 | return ret; |
| 1135 | } |
| 1136 | |
| 1137 | |
| 1138 | static ssize_t iwl_dbgfs_chain_noise_read(struct file *file, |
| 1139 | char __user *user_buf, |
| 1140 | size_t count, loff_t *ppos) { |
| 1141 | |
H Hartley Sweeten | 28f63a4 | 2010-01-08 16:14:10 -0700 | [diff] [blame] | 1142 | struct iwl_priv *priv = file->private_data; |
Wey-Yi Guy | 5225935 | 2009-08-07 15:41:43 -0700 | [diff] [blame] | 1143 | int pos = 0; |
| 1144 | int cnt = 0; |
| 1145 | char *buf; |
| 1146 | int bufsz = sizeof(struct iwl_chain_noise_data) * 4 + 100; |
| 1147 | ssize_t ret; |
| 1148 | struct iwl_chain_noise_data *data; |
| 1149 | |
| 1150 | data = &priv->chain_noise_data; |
| 1151 | buf = kzalloc(bufsz, GFP_KERNEL); |
| 1152 | if (!buf) { |
| 1153 | IWL_ERR(priv, "Can not allocate Buffer\n"); |
| 1154 | return -ENOMEM; |
| 1155 | } |
| 1156 | |
| 1157 | pos += scnprintf(buf + pos, bufsz - pos, "active_chains:\t\t\t %u\n", |
| 1158 | data->active_chains); |
| 1159 | pos += scnprintf(buf + pos, bufsz - pos, "chain_noise_a:\t\t\t %u\n", |
| 1160 | data->chain_noise_a); |
| 1161 | pos += scnprintf(buf + pos, bufsz - pos, "chain_noise_b:\t\t\t %u\n", |
| 1162 | data->chain_noise_b); |
| 1163 | pos += scnprintf(buf + pos, bufsz - pos, "chain_noise_c:\t\t\t %u\n", |
| 1164 | data->chain_noise_c); |
| 1165 | pos += scnprintf(buf + pos, bufsz - pos, "chain_signal_a:\t\t\t %u\n", |
| 1166 | data->chain_signal_a); |
| 1167 | pos += scnprintf(buf + pos, bufsz - pos, "chain_signal_b:\t\t\t %u\n", |
| 1168 | data->chain_signal_b); |
| 1169 | pos += scnprintf(buf + pos, bufsz - pos, "chain_signal_c:\t\t\t %u\n", |
| 1170 | data->chain_signal_c); |
| 1171 | pos += scnprintf(buf + pos, bufsz - pos, "beacon_count:\t\t\t %u\n", |
| 1172 | data->beacon_count); |
| 1173 | |
| 1174 | pos += scnprintf(buf + pos, bufsz - pos, "disconn_array:\t\t\t"); |
| 1175 | for (cnt = 0; cnt < NUM_RX_CHAINS; cnt++) { |
| 1176 | pos += scnprintf(buf + pos, bufsz - pos, " %u", |
| 1177 | data->disconn_array[cnt]); |
| 1178 | } |
| 1179 | pos += scnprintf(buf + pos, bufsz - pos, "\n"); |
| 1180 | pos += scnprintf(buf + pos, bufsz - pos, "delta_gain_code:\t\t"); |
| 1181 | for (cnt = 0; cnt < NUM_RX_CHAINS; cnt++) { |
| 1182 | pos += scnprintf(buf + pos, bufsz - pos, " %u", |
| 1183 | data->delta_gain_code[cnt]); |
| 1184 | } |
| 1185 | pos += scnprintf(buf + pos, bufsz - pos, "\n"); |
| 1186 | pos += scnprintf(buf + pos, bufsz - pos, "radio_write:\t\t\t %u\n", |
| 1187 | data->radio_write); |
| 1188 | pos += scnprintf(buf + pos, bufsz - pos, "state:\t\t\t\t %u\n", |
| 1189 | data->state); |
| 1190 | |
| 1191 | ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos); |
| 1192 | kfree(buf); |
| 1193 | return ret; |
| 1194 | } |
| 1195 | |
Wey-Yi Guy | c09430a | 2009-10-16 14:25:50 -0700 | [diff] [blame] | 1196 | static ssize_t iwl_dbgfs_power_save_status_read(struct file *file, |
| 1197 | char __user *user_buf, |
| 1198 | size_t count, loff_t *ppos) |
| 1199 | { |
H Hartley Sweeten | 28f63a4 | 2010-01-08 16:14:10 -0700 | [diff] [blame] | 1200 | struct iwl_priv *priv = file->private_data; |
Wey-Yi Guy | c09430a | 2009-10-16 14:25:50 -0700 | [diff] [blame] | 1201 | char buf[60]; |
| 1202 | int pos = 0; |
| 1203 | const size_t bufsz = sizeof(buf); |
| 1204 | u32 pwrsave_status; |
| 1205 | |
| 1206 | pwrsave_status = iwl_read32(priv, CSR_GP_CNTRL) & |
| 1207 | CSR_GP_REG_POWER_SAVE_STATUS_MSK; |
| 1208 | |
| 1209 | pos += scnprintf(buf + pos, bufsz - pos, "Power Save Status: "); |
| 1210 | pos += scnprintf(buf + pos, bufsz - pos, "%s\n", |
| 1211 | (pwrsave_status == CSR_GP_REG_NO_POWER_SAVE) ? "none" : |
| 1212 | (pwrsave_status == CSR_GP_REG_MAC_POWER_SAVE) ? "MAC" : |
| 1213 | (pwrsave_status == CSR_GP_REG_PHY_POWER_SAVE) ? "PHY" : |
| 1214 | "error"); |
| 1215 | |
| 1216 | return simple_read_from_buffer(user_buf, count, ppos, buf, pos); |
| 1217 | } |
| 1218 | |
Wey-Yi Guy | 7163b8a | 2009-11-20 12:04:56 -0800 | [diff] [blame] | 1219 | 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] | 1220 | const char __user *user_buf, |
| 1221 | size_t count, loff_t *ppos) |
| 1222 | { |
| 1223 | struct iwl_priv *priv = file->private_data; |
| 1224 | char buf[8]; |
| 1225 | int buf_size; |
| 1226 | int clear; |
| 1227 | |
| 1228 | memset(buf, 0, sizeof(buf)); |
| 1229 | buf_size = min(count, sizeof(buf) - 1); |
| 1230 | if (copy_from_user(buf, user_buf, buf_size)) |
| 1231 | return -EFAULT; |
| 1232 | if (sscanf(buf, "%d", &clear) != 1) |
| 1233 | return -EFAULT; |
| 1234 | |
| 1235 | /* make request to uCode to retrieve statistics information */ |
| 1236 | mutex_lock(&priv->mutex); |
| 1237 | iwl_send_statistics_request(priv, CMD_SYNC, true); |
| 1238 | mutex_unlock(&priv->mutex); |
| 1239 | |
| 1240 | return count; |
| 1241 | } |
| 1242 | |
Wey-Yi Guy | 696bdee | 2009-12-10 14:37:25 -0800 | [diff] [blame] | 1243 | static ssize_t iwl_dbgfs_csr_write(struct file *file, |
| 1244 | const char __user *user_buf, |
| 1245 | size_t count, loff_t *ppos) |
| 1246 | { |
| 1247 | struct iwl_priv *priv = file->private_data; |
| 1248 | char buf[8]; |
| 1249 | int buf_size; |
| 1250 | int csr; |
| 1251 | |
| 1252 | memset(buf, 0, sizeof(buf)); |
| 1253 | buf_size = min(count, sizeof(buf) - 1); |
| 1254 | if (copy_from_user(buf, user_buf, buf_size)) |
| 1255 | return -EFAULT; |
| 1256 | if (sscanf(buf, "%d", &csr) != 1) |
| 1257 | return -EFAULT; |
| 1258 | |
| 1259 | if (priv->cfg->ops->lib->dump_csr) |
| 1260 | priv->cfg->ops->lib->dump_csr(priv); |
| 1261 | |
| 1262 | return count; |
| 1263 | } |
| 1264 | |
Wey-Yi Guy | a9e1cb6 | 2009-12-10 14:37:26 -0800 | [diff] [blame] | 1265 | static ssize_t iwl_dbgfs_ucode_tracing_read(struct file *file, |
| 1266 | char __user *user_buf, |
| 1267 | size_t count, loff_t *ppos) { |
| 1268 | |
| 1269 | struct iwl_priv *priv = (struct iwl_priv *)file->private_data; |
| 1270 | int pos = 0; |
| 1271 | char buf[128]; |
| 1272 | const size_t bufsz = sizeof(buf); |
Wey-Yi Guy | a9e1cb6 | 2009-12-10 14:37:26 -0800 | [diff] [blame] | 1273 | |
| 1274 | pos += scnprintf(buf + pos, bufsz - pos, "ucode trace timer is %s\n", |
| 1275 | priv->event_log.ucode_trace ? "On" : "Off"); |
| 1276 | pos += scnprintf(buf + pos, bufsz - pos, "non_wraps_count:\t\t %u\n", |
| 1277 | priv->event_log.non_wraps_count); |
| 1278 | pos += scnprintf(buf + pos, bufsz - pos, "wraps_once_count:\t\t %u\n", |
| 1279 | priv->event_log.wraps_once_count); |
| 1280 | pos += scnprintf(buf + pos, bufsz - pos, "wraps_more_count:\t\t %u\n", |
| 1281 | priv->event_log.wraps_more_count); |
| 1282 | |
Wey-Yi Guy | 4967c31 | 2010-02-18 15:22:07 -0800 | [diff] [blame] | 1283 | return simple_read_from_buffer(user_buf, count, ppos, buf, pos); |
Wey-Yi Guy | a9e1cb6 | 2009-12-10 14:37:26 -0800 | [diff] [blame] | 1284 | } |
| 1285 | |
| 1286 | static ssize_t iwl_dbgfs_ucode_tracing_write(struct file *file, |
| 1287 | const char __user *user_buf, |
| 1288 | size_t count, loff_t *ppos) |
| 1289 | { |
| 1290 | struct iwl_priv *priv = file->private_data; |
| 1291 | char buf[8]; |
| 1292 | int buf_size; |
| 1293 | int trace; |
| 1294 | |
| 1295 | memset(buf, 0, sizeof(buf)); |
| 1296 | buf_size = min(count, sizeof(buf) - 1); |
| 1297 | if (copy_from_user(buf, user_buf, buf_size)) |
| 1298 | return -EFAULT; |
| 1299 | if (sscanf(buf, "%d", &trace) != 1) |
| 1300 | return -EFAULT; |
| 1301 | |
| 1302 | if (trace) { |
| 1303 | priv->event_log.ucode_trace = true; |
| 1304 | /* schedule the ucode timer to occur in UCODE_TRACE_PERIOD */ |
| 1305 | mod_timer(&priv->ucode_trace, |
| 1306 | jiffies + msecs_to_jiffies(UCODE_TRACE_PERIOD)); |
| 1307 | } else { |
| 1308 | priv->event_log.ucode_trace = false; |
| 1309 | del_timer_sync(&priv->ucode_trace); |
| 1310 | } |
| 1311 | |
| 1312 | return count; |
| 1313 | } |
| 1314 | |
Johannes Berg | 6098720 | 2010-02-18 00:36:07 -0800 | [diff] [blame] | 1315 | static ssize_t iwl_dbgfs_rxon_flags_read(struct file *file, |
| 1316 | char __user *user_buf, |
| 1317 | size_t count, loff_t *ppos) { |
| 1318 | |
| 1319 | struct iwl_priv *priv = (struct iwl_priv *)file->private_data; |
| 1320 | int len = 0; |
| 1321 | char buf[20]; |
| 1322 | |
| 1323 | len = sprintf(buf, "0x%04X\n", le32_to_cpu(priv->active_rxon.flags)); |
| 1324 | return simple_read_from_buffer(user_buf, count, ppos, buf, len); |
| 1325 | } |
| 1326 | |
| 1327 | static ssize_t iwl_dbgfs_rxon_filter_flags_read(struct file *file, |
| 1328 | char __user *user_buf, |
| 1329 | size_t count, loff_t *ppos) { |
| 1330 | |
| 1331 | struct iwl_priv *priv = (struct iwl_priv *)file->private_data; |
| 1332 | int len = 0; |
| 1333 | char buf[20]; |
| 1334 | |
| 1335 | len = sprintf(buf, "0x%04X\n", |
| 1336 | le32_to_cpu(priv->active_rxon.filter_flags)); |
| 1337 | return simple_read_from_buffer(user_buf, count, ppos, buf, len); |
| 1338 | } |
| 1339 | |
Wey-Yi Guy | 1b3eb82 | 2010-01-15 13:43:39 -0800 | [diff] [blame] | 1340 | static ssize_t iwl_dbgfs_fh_reg_read(struct file *file, |
| 1341 | char __user *user_buf, |
| 1342 | size_t count, loff_t *ppos) |
| 1343 | { |
| 1344 | struct iwl_priv *priv = (struct iwl_priv *)file->private_data; |
| 1345 | char *buf; |
| 1346 | int pos = 0; |
| 1347 | ssize_t ret = -EFAULT; |
| 1348 | |
| 1349 | if (priv->cfg->ops->lib->dump_fh) { |
| 1350 | ret = pos = priv->cfg->ops->lib->dump_fh(priv, &buf, true); |
| 1351 | if (buf) { |
| 1352 | ret = simple_read_from_buffer(user_buf, |
| 1353 | count, ppos, buf, pos); |
| 1354 | kfree(buf); |
| 1355 | } |
| 1356 | } |
| 1357 | |
| 1358 | return ret; |
| 1359 | } |
| 1360 | |
Wey-Yi Guy | a13d276 | 2010-01-22 14:22:42 -0800 | [diff] [blame] | 1361 | static ssize_t iwl_dbgfs_missed_beacon_read(struct file *file, |
| 1362 | char __user *user_buf, |
| 1363 | size_t count, loff_t *ppos) { |
| 1364 | |
| 1365 | struct iwl_priv *priv = file->private_data; |
| 1366 | int pos = 0; |
| 1367 | char buf[12]; |
| 1368 | const size_t bufsz = sizeof(buf); |
Wey-Yi Guy | a13d276 | 2010-01-22 14:22:42 -0800 | [diff] [blame] | 1369 | |
| 1370 | pos += scnprintf(buf + pos, bufsz - pos, "%d\n", |
| 1371 | priv->missed_beacon_threshold); |
| 1372 | |
Wey-Yi Guy | 4967c31 | 2010-02-18 15:22:07 -0800 | [diff] [blame] | 1373 | return simple_read_from_buffer(user_buf, count, ppos, buf, pos); |
Wey-Yi Guy | a13d276 | 2010-01-22 14:22:42 -0800 | [diff] [blame] | 1374 | } |
| 1375 | |
| 1376 | static ssize_t iwl_dbgfs_missed_beacon_write(struct file *file, |
| 1377 | const char __user *user_buf, |
| 1378 | size_t count, loff_t *ppos) |
| 1379 | { |
| 1380 | struct iwl_priv *priv = file->private_data; |
| 1381 | char buf[8]; |
| 1382 | int buf_size; |
| 1383 | int missed; |
| 1384 | |
| 1385 | memset(buf, 0, sizeof(buf)); |
| 1386 | buf_size = min(count, sizeof(buf) - 1); |
| 1387 | if (copy_from_user(buf, user_buf, buf_size)) |
| 1388 | return -EFAULT; |
| 1389 | if (sscanf(buf, "%d", &missed) != 1) |
| 1390 | return -EINVAL; |
| 1391 | |
| 1392 | if (missed < IWL_MISSED_BEACON_THRESHOLD_MIN || |
| 1393 | missed > IWL_MISSED_BEACON_THRESHOLD_MAX) |
| 1394 | priv->missed_beacon_threshold = |
| 1395 | IWL_MISSED_BEACON_THRESHOLD_DEF; |
| 1396 | else |
| 1397 | priv->missed_beacon_threshold = missed; |
| 1398 | |
| 1399 | return count; |
| 1400 | } |
| 1401 | |
Trieu 'Andrew' Nguyen | 3e4fb5f | 2010-01-22 14:22:46 -0800 | [diff] [blame] | 1402 | static ssize_t iwl_dbgfs_plcp_delta_read(struct file *file, |
| 1403 | char __user *user_buf, |
| 1404 | size_t count, loff_t *ppos) { |
| 1405 | |
| 1406 | struct iwl_priv *priv = (struct iwl_priv *)file->private_data; |
| 1407 | int pos = 0; |
| 1408 | char buf[12]; |
| 1409 | const size_t bufsz = sizeof(buf); |
Trieu 'Andrew' Nguyen | 3e4fb5f | 2010-01-22 14:22:46 -0800 | [diff] [blame] | 1410 | |
| 1411 | pos += scnprintf(buf + pos, bufsz - pos, "%u\n", |
| 1412 | priv->cfg->plcp_delta_threshold); |
| 1413 | |
Wey-Yi Guy | 4967c31 | 2010-02-18 15:22:07 -0800 | [diff] [blame] | 1414 | return simple_read_from_buffer(user_buf, count, ppos, buf, pos); |
Trieu 'Andrew' Nguyen | 3e4fb5f | 2010-01-22 14:22:46 -0800 | [diff] [blame] | 1415 | } |
| 1416 | |
| 1417 | static ssize_t iwl_dbgfs_plcp_delta_write(struct file *file, |
| 1418 | const char __user *user_buf, |
| 1419 | size_t count, loff_t *ppos) { |
| 1420 | |
| 1421 | struct iwl_priv *priv = file->private_data; |
| 1422 | char buf[8]; |
| 1423 | int buf_size; |
| 1424 | int plcp; |
| 1425 | |
| 1426 | memset(buf, 0, sizeof(buf)); |
| 1427 | buf_size = min(count, sizeof(buf) - 1); |
| 1428 | if (copy_from_user(buf, user_buf, buf_size)) |
| 1429 | return -EFAULT; |
| 1430 | if (sscanf(buf, "%d", &plcp) != 1) |
| 1431 | return -EINVAL; |
| 1432 | if ((plcp <= IWL_MAX_PLCP_ERR_THRESHOLD_MIN) || |
| 1433 | (plcp > IWL_MAX_PLCP_ERR_THRESHOLD_MAX)) |
| 1434 | priv->cfg->plcp_delta_threshold = |
| 1435 | IWL_MAX_PLCP_ERR_THRESHOLD_DEF; |
| 1436 | else |
| 1437 | priv->cfg->plcp_delta_threshold = plcp; |
| 1438 | return count; |
| 1439 | } |
| 1440 | |
Wey-Yi Guy | 528c312 | 2010-02-18 22:03:07 -0800 | [diff] [blame] | 1441 | static ssize_t iwl_dbgfs_force_reset_read(struct file *file, |
| 1442 | char __user *user_buf, |
| 1443 | size_t count, loff_t *ppos) { |
| 1444 | |
| 1445 | struct iwl_priv *priv = file->private_data; |
| 1446 | int i, pos = 0; |
| 1447 | char buf[300]; |
| 1448 | const size_t bufsz = sizeof(buf); |
| 1449 | struct iwl_force_reset *force_reset; |
| 1450 | |
| 1451 | for (i = 0; i < IWL_MAX_FORCE_RESET; i++) { |
| 1452 | force_reset = &priv->force_reset[i]; |
| 1453 | pos += scnprintf(buf + pos, bufsz - pos, |
| 1454 | "Force reset method %d\n", i); |
| 1455 | pos += scnprintf(buf + pos, bufsz - pos, |
| 1456 | "\tnumber of reset request: %d\n", |
| 1457 | force_reset->reset_request_count); |
| 1458 | pos += scnprintf(buf + pos, bufsz - pos, |
| 1459 | "\tnumber of reset request success: %d\n", |
| 1460 | force_reset->reset_success_count); |
| 1461 | pos += scnprintf(buf + pos, bufsz - pos, |
| 1462 | "\tnumber of reset request reject: %d\n", |
| 1463 | force_reset->reset_reject_count); |
| 1464 | pos += scnprintf(buf + pos, bufsz - pos, |
| 1465 | "\treset duration: %lu\n", |
| 1466 | force_reset->reset_duration); |
| 1467 | } |
| 1468 | return simple_read_from_buffer(user_buf, count, ppos, buf, pos); |
| 1469 | } |
| 1470 | |
Wey-Yi Guy | 04cafd7 | 2010-02-03 11:47:20 -0800 | [diff] [blame] | 1471 | static ssize_t iwl_dbgfs_force_reset_write(struct file *file, |
| 1472 | const char __user *user_buf, |
| 1473 | size_t count, loff_t *ppos) { |
| 1474 | |
| 1475 | struct iwl_priv *priv = file->private_data; |
| 1476 | char buf[8]; |
| 1477 | int buf_size; |
| 1478 | int reset, ret; |
| 1479 | |
| 1480 | memset(buf, 0, sizeof(buf)); |
| 1481 | buf_size = min(count, sizeof(buf) - 1); |
| 1482 | if (copy_from_user(buf, user_buf, buf_size)) |
| 1483 | return -EFAULT; |
| 1484 | if (sscanf(buf, "%d", &reset) != 1) |
| 1485 | return -EINVAL; |
| 1486 | switch (reset) { |
| 1487 | case IWL_RF_RESET: |
| 1488 | case IWL_FW_RESET: |
| 1489 | ret = iwl_force_reset(priv, reset); |
| 1490 | break; |
| 1491 | default: |
| 1492 | return -EINVAL; |
| 1493 | } |
| 1494 | return ret ? ret : count; |
| 1495 | } |
| 1496 | |
Wey-Yi Guy | 7163b8a | 2009-11-20 12:04:56 -0800 | [diff] [blame] | 1497 | DEBUGFS_READ_FILE_OPS(rx_statistics); |
| 1498 | DEBUGFS_READ_FILE_OPS(tx_statistics); |
Wey-Yi Guy | 20594eb | 2009-08-07 15:41:39 -0700 | [diff] [blame] | 1499 | DEBUGFS_READ_WRITE_FILE_OPS(traffic_log); |
Wey-Yi Guy | 141b03e | 2009-08-07 15:41:41 -0700 | [diff] [blame] | 1500 | DEBUGFS_READ_FILE_OPS(rx_queue); |
| 1501 | DEBUGFS_READ_FILE_OPS(tx_queue); |
Wey-Yi Guy | e8fe59a | 2009-08-07 15:41:42 -0700 | [diff] [blame] | 1502 | DEBUGFS_READ_FILE_OPS(ucode_rx_stats); |
| 1503 | DEBUGFS_READ_FILE_OPS(ucode_tx_stats); |
| 1504 | DEBUGFS_READ_FILE_OPS(ucode_general_stats); |
Wey-Yi Guy | 5225935 | 2009-08-07 15:41:43 -0700 | [diff] [blame] | 1505 | DEBUGFS_READ_FILE_OPS(sensitivity); |
| 1506 | DEBUGFS_READ_FILE_OPS(chain_noise); |
Wey-Yi Guy | c09430a | 2009-10-16 14:25:50 -0700 | [diff] [blame] | 1507 | DEBUGFS_READ_FILE_OPS(power_save_status); |
Wey-Yi Guy | 7163b8a | 2009-11-20 12:04:56 -0800 | [diff] [blame] | 1508 | DEBUGFS_WRITE_FILE_OPS(clear_ucode_statistics); |
| 1509 | DEBUGFS_WRITE_FILE_OPS(clear_traffic_statistics); |
Wey-Yi Guy | 696bdee | 2009-12-10 14:37:25 -0800 | [diff] [blame] | 1510 | DEBUGFS_WRITE_FILE_OPS(csr); |
Wey-Yi Guy | a9e1cb6 | 2009-12-10 14:37:26 -0800 | [diff] [blame] | 1511 | DEBUGFS_READ_WRITE_FILE_OPS(ucode_tracing); |
Wey-Yi Guy | 1b3eb82 | 2010-01-15 13:43:39 -0800 | [diff] [blame] | 1512 | DEBUGFS_READ_FILE_OPS(fh_reg); |
Wey-Yi Guy | a13d276 | 2010-01-22 14:22:42 -0800 | [diff] [blame] | 1513 | DEBUGFS_READ_WRITE_FILE_OPS(missed_beacon); |
Trieu 'Andrew' Nguyen | 3e4fb5f | 2010-01-22 14:22:46 -0800 | [diff] [blame] | 1514 | DEBUGFS_READ_WRITE_FILE_OPS(plcp_delta); |
Wey-Yi Guy | 528c312 | 2010-02-18 22:03:07 -0800 | [diff] [blame] | 1515 | DEBUGFS_READ_WRITE_FILE_OPS(force_reset); |
Johannes Berg | 6098720 | 2010-02-18 00:36:07 -0800 | [diff] [blame] | 1516 | DEBUGFS_READ_FILE_OPS(rxon_flags); |
| 1517 | DEBUGFS_READ_FILE_OPS(rxon_filter_flags); |
Wey-Yi Guy | 20594eb | 2009-08-07 15:41:39 -0700 | [diff] [blame] | 1518 | |
Tomas Winkler | 712b6cf | 2008-03-12 16:58:52 -0700 | [diff] [blame] | 1519 | /* |
| 1520 | * Create the debugfs files and directories |
| 1521 | * |
| 1522 | */ |
| 1523 | int iwl_dbgfs_register(struct iwl_priv *priv, const char *name) |
| 1524 | { |
Zhu Yi | 95b1a82 | 2008-05-29 16:34:50 +0800 | [diff] [blame] | 1525 | struct dentry *phyd = priv->hw->wiphy->debugfsdir; |
Johannes Berg | 4c84a8f | 2010-01-22 14:22:54 -0800 | [diff] [blame] | 1526 | struct dentry *dir_drv, *dir_data, *dir_rf, *dir_debug; |
Tomas Winkler | 712b6cf | 2008-03-12 16:58:52 -0700 | [diff] [blame] | 1527 | |
Johannes Berg | 4c84a8f | 2010-01-22 14:22:54 -0800 | [diff] [blame] | 1528 | dir_drv = debugfs_create_dir(name, phyd); |
| 1529 | if (!dir_drv) |
| 1530 | return -ENOMEM; |
| 1531 | |
| 1532 | priv->debugfs_dir = dir_drv; |
| 1533 | |
| 1534 | dir_data = debugfs_create_dir("data", dir_drv); |
| 1535 | if (!dir_data) |
Tomas Winkler | 712b6cf | 2008-03-12 16:58:52 -0700 | [diff] [blame] | 1536 | goto err; |
Johannes Berg | 4c84a8f | 2010-01-22 14:22:54 -0800 | [diff] [blame] | 1537 | dir_rf = debugfs_create_dir("rf", dir_drv); |
| 1538 | if (!dir_rf) |
Tomas Winkler | 712b6cf | 2008-03-12 16:58:52 -0700 | [diff] [blame] | 1539 | goto err; |
Johannes Berg | 4c84a8f | 2010-01-22 14:22:54 -0800 | [diff] [blame] | 1540 | dir_debug = debugfs_create_dir("debug", dir_drv); |
| 1541 | if (!dir_debug) |
| 1542 | goto err; |
Tomas Winkler | 712b6cf | 2008-03-12 16:58:52 -0700 | [diff] [blame] | 1543 | |
Johannes Berg | 4c84a8f | 2010-01-22 14:22:54 -0800 | [diff] [blame] | 1544 | DEBUGFS_ADD_FILE(nvm, dir_data, S_IRUSR); |
| 1545 | DEBUGFS_ADD_FILE(sram, dir_data, S_IWUSR | S_IRUSR); |
| 1546 | DEBUGFS_ADD_FILE(log_event, dir_data, S_IWUSR | S_IRUSR); |
| 1547 | DEBUGFS_ADD_FILE(stations, dir_data, S_IRUSR); |
| 1548 | DEBUGFS_ADD_FILE(channels, dir_data, S_IRUSR); |
| 1549 | DEBUGFS_ADD_FILE(status, dir_data, S_IRUSR); |
| 1550 | DEBUGFS_ADD_FILE(interrupt, dir_data, S_IWUSR | S_IRUSR); |
| 1551 | DEBUGFS_ADD_FILE(qos, dir_data, S_IRUSR); |
| 1552 | DEBUGFS_ADD_FILE(led, dir_data, S_IRUSR); |
Wey-Yi Guy | 381733c | 2010-04-25 09:39:46 -0700 | [diff] [blame] | 1553 | if (!priv->cfg->broken_powersave) { |
| 1554 | DEBUGFS_ADD_FILE(sleep_level_override, dir_data, |
| 1555 | S_IWUSR | S_IRUSR); |
| 1556 | DEBUGFS_ADD_FILE(current_sleep_command, dir_data, S_IRUSR); |
| 1557 | } |
Johannes Berg | 4c84a8f | 2010-01-22 14:22:54 -0800 | [diff] [blame] | 1558 | DEBUGFS_ADD_FILE(thermal_throttling, dir_data, S_IRUSR); |
| 1559 | DEBUGFS_ADD_FILE(disable_ht40, dir_data, S_IWUSR | S_IRUSR); |
| 1560 | DEBUGFS_ADD_FILE(rx_statistics, dir_debug, S_IRUSR); |
| 1561 | DEBUGFS_ADD_FILE(tx_statistics, dir_debug, S_IRUSR); |
| 1562 | DEBUGFS_ADD_FILE(traffic_log, dir_debug, S_IWUSR | S_IRUSR); |
| 1563 | DEBUGFS_ADD_FILE(rx_queue, dir_debug, S_IRUSR); |
| 1564 | DEBUGFS_ADD_FILE(tx_queue, dir_debug, S_IRUSR); |
Johannes Berg | 4c84a8f | 2010-01-22 14:22:54 -0800 | [diff] [blame] | 1565 | DEBUGFS_ADD_FILE(power_save_status, dir_debug, S_IRUSR); |
| 1566 | DEBUGFS_ADD_FILE(clear_ucode_statistics, dir_debug, S_IWUSR); |
| 1567 | DEBUGFS_ADD_FILE(clear_traffic_statistics, dir_debug, S_IWUSR); |
| 1568 | DEBUGFS_ADD_FILE(csr, dir_debug, S_IWUSR); |
| 1569 | DEBUGFS_ADD_FILE(fh_reg, dir_debug, S_IRUSR); |
| 1570 | DEBUGFS_ADD_FILE(missed_beacon, dir_debug, S_IWUSR); |
Johannes Berg | 4c84a8f | 2010-01-22 14:22:54 -0800 | [diff] [blame] | 1571 | DEBUGFS_ADD_FILE(plcp_delta, dir_debug, S_IWUSR | S_IRUSR); |
Wey-Yi Guy | 528c312 | 2010-02-18 22:03:07 -0800 | [diff] [blame] | 1572 | DEBUGFS_ADD_FILE(force_reset, dir_debug, S_IWUSR | S_IRUSR); |
Abhijeet Kolekar | b8c7626 | 2010-04-08 15:29:07 -0700 | [diff] [blame] | 1573 | DEBUGFS_ADD_FILE(ucode_rx_stats, dir_debug, S_IRUSR); |
| 1574 | DEBUGFS_ADD_FILE(ucode_tx_stats, dir_debug, S_IRUSR); |
| 1575 | DEBUGFS_ADD_FILE(ucode_general_stats, dir_debug, S_IRUSR); |
| 1576 | |
Wey-Yi Guy | 65d1f89 | 2010-04-25 15:41:43 -0700 | [diff] [blame] | 1577 | if (priv->cfg->sensitivity_calib_by_driver) |
Johannes Berg | 4c84a8f | 2010-01-22 14:22:54 -0800 | [diff] [blame] | 1578 | DEBUGFS_ADD_FILE(sensitivity, dir_debug, S_IRUSR); |
Wey-Yi Guy | 65d1f89 | 2010-04-25 15:41:43 -0700 | [diff] [blame] | 1579 | if (priv->cfg->chain_noise_calib_by_driver) |
Johannes Berg | 4c84a8f | 2010-01-22 14:22:54 -0800 | [diff] [blame] | 1580 | DEBUGFS_ADD_FILE(chain_noise, dir_debug, S_IRUSR); |
Wey-Yi Guy | 6e5c800 | 2010-04-27 14:00:28 -0700 | [diff] [blame] | 1581 | if (priv->cfg->ucode_tracing) |
| 1582 | DEBUGFS_ADD_FILE(ucode_tracing, dir_debug, S_IWUSR | S_IRUSR); |
Johannes Berg | 6098720 | 2010-02-18 00:36:07 -0800 | [diff] [blame] | 1583 | DEBUGFS_ADD_FILE(rxon_flags, dir_debug, S_IWUSR); |
| 1584 | DEBUGFS_ADD_FILE(rxon_filter_flags, dir_debug, S_IWUSR); |
Wey-Yi Guy | 65d1f89 | 2010-04-25 15:41:43 -0700 | [diff] [blame] | 1585 | if (priv->cfg->sensitivity_calib_by_driver) |
| 1586 | DEBUGFS_ADD_BOOL(disable_sensitivity, dir_rf, |
| 1587 | &priv->disable_sens_cal); |
| 1588 | if (priv->cfg->chain_noise_calib_by_driver) |
| 1589 | DEBUGFS_ADD_BOOL(disable_chain_noise, dir_rf, |
| 1590 | &priv->disable_chain_noise_cal); |
Wey-Yi Guy | 4e7033e | 2010-04-27 14:33:33 -0700 | [diff] [blame] | 1591 | if (priv->cfg->tx_power_by_driver) |
Johannes Berg | 4c84a8f | 2010-01-22 14:22:54 -0800 | [diff] [blame] | 1592 | DEBUGFS_ADD_BOOL(disable_tx_power, dir_rf, |
Wey-Yi Guy | 030b865 | 2009-06-12 13:22:55 -0700 | [diff] [blame] | 1593 | &priv->disable_tx_power_cal); |
Tomas Winkler | 712b6cf | 2008-03-12 16:58:52 -0700 | [diff] [blame] | 1594 | return 0; |
| 1595 | |
| 1596 | err: |
Johannes Berg | 4c84a8f | 2010-01-22 14:22:54 -0800 | [diff] [blame] | 1597 | IWL_ERR(priv, "Can't create the debugfs directory\n"); |
Tomas Winkler | 712b6cf | 2008-03-12 16:58:52 -0700 | [diff] [blame] | 1598 | iwl_dbgfs_unregister(priv); |
Johannes Berg | 4c84a8f | 2010-01-22 14:22:54 -0800 | [diff] [blame] | 1599 | return -ENOMEM; |
Tomas Winkler | 712b6cf | 2008-03-12 16:58:52 -0700 | [diff] [blame] | 1600 | } |
| 1601 | EXPORT_SYMBOL(iwl_dbgfs_register); |
| 1602 | |
| 1603 | /** |
| 1604 | * Remove the debugfs files and directories |
| 1605 | * |
| 1606 | */ |
| 1607 | void iwl_dbgfs_unregister(struct iwl_priv *priv) |
| 1608 | { |
Johannes Berg | 4c84a8f | 2010-01-22 14:22:54 -0800 | [diff] [blame] | 1609 | if (!priv->debugfs_dir) |
Tomas Winkler | 712b6cf | 2008-03-12 16:58:52 -0700 | [diff] [blame] | 1610 | return; |
| 1611 | |
Johannes Berg | 4c84a8f | 2010-01-22 14:22:54 -0800 | [diff] [blame] | 1612 | debugfs_remove_recursive(priv->debugfs_dir); |
| 1613 | priv->debugfs_dir = NULL; |
Tomas Winkler | 712b6cf | 2008-03-12 16:58:52 -0700 | [diff] [blame] | 1614 | } |
| 1615 | EXPORT_SYMBOL(iwl_dbgfs_unregister); |
| 1616 | |
| 1617 | |
Tomas Winkler | 445c2df | 2008-05-15 13:54:16 +0800 | [diff] [blame] | 1618 | |