Tomas Winkler | 712b6cf | 2008-03-12 16:58:52 -0700 | [diff] [blame] | 1 | /****************************************************************************** |
| 2 | * |
| 3 | * GPL LICENSE SUMMARY |
| 4 | * |
Reinette Chatre | 01f8162 | 2009-01-08 10:20:02 -0800 | [diff] [blame] | 5 | * Copyright(c) 2008 - 2009 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 | |
| 29 | #include <linux/kernel.h> |
| 30 | #include <linux/module.h> |
| 31 | #include <linux/debugfs.h> |
| 32 | |
| 33 | #include <linux/ieee80211.h> |
| 34 | #include <net/mac80211.h> |
| 35 | |
| 36 | |
Tomas Winkler | 3e0d4cb | 2008-04-24 11:55:38 -0700 | [diff] [blame] | 37 | #include "iwl-dev.h" |
Tomas Winkler | 712b6cf | 2008-03-12 16:58:52 -0700 | [diff] [blame] | 38 | #include "iwl-debug.h" |
Tomas Winkler | fee1247 | 2008-04-03 16:05:21 -0700 | [diff] [blame] | 39 | #include "iwl-core.h" |
Tomas Winkler | 3395f6e | 2008-03-25 16:33:37 -0700 | [diff] [blame] | 40 | #include "iwl-io.h" |
Wey-Yi Guy | 5225935 | 2009-08-07 15:41:43 -0700 | [diff] [blame] | 41 | #include "iwl-calib.h" |
Tomas Winkler | 712b6cf | 2008-03-12 16:58:52 -0700 | [diff] [blame] | 42 | |
| 43 | /* create and remove of files */ |
| 44 | #define DEBUGFS_ADD_DIR(name, parent) do { \ |
| 45 | dbgfs->dir_##name = debugfs_create_dir(#name, parent); \ |
| 46 | if (!(dbgfs->dir_##name)) \ |
| 47 | goto err; \ |
| 48 | } while (0) |
| 49 | |
Wey-Yi Guy | 43e8511 | 2009-11-20 12:04:58 -0800 | [diff] [blame] | 50 | #define DEBUGFS_ADD_FILE(name, parent, mode) do { \ |
Tomas Winkler | 712b6cf | 2008-03-12 16:58:52 -0700 | [diff] [blame] | 51 | dbgfs->dbgfs_##parent##_files.file_##name = \ |
Wey-Yi Guy | 43e8511 | 2009-11-20 12:04:58 -0800 | [diff] [blame] | 52 | debugfs_create_file(#name, mode, \ |
Reinette Chatre | fcf89d0 | 2009-07-09 10:33:38 -0700 | [diff] [blame] | 53 | dbgfs->dir_##parent, priv, \ |
Tomas Winkler | 712b6cf | 2008-03-12 16:58:52 -0700 | [diff] [blame] | 54 | &iwl_dbgfs_##name##_ops); \ |
| 55 | if (!(dbgfs->dbgfs_##parent##_files.file_##name)) \ |
| 56 | goto err; \ |
| 57 | } while (0) |
| 58 | |
Tomas Winkler | 445c2df | 2008-05-15 13:54:16 +0800 | [diff] [blame] | 59 | #define DEBUGFS_ADD_BOOL(name, parent, ptr) do { \ |
| 60 | dbgfs->dbgfs_##parent##_files.file_##name = \ |
Reinette Chatre | fcf89d0 | 2009-07-09 10:33:38 -0700 | [diff] [blame] | 61 | debugfs_create_bool(#name, S_IWUSR | S_IRUSR, \ |
| 62 | dbgfs->dir_##parent, ptr); \ |
Zhaolei | 9b24001 | 2008-10-22 17:06:12 +0800 | [diff] [blame] | 63 | if (IS_ERR(dbgfs->dbgfs_##parent##_files.file_##name) \ |
| 64 | || !dbgfs->dbgfs_##parent##_files.file_##name) \ |
Tomas Winkler | 445c2df | 2008-05-15 13:54:16 +0800 | [diff] [blame] | 65 | goto err; \ |
| 66 | } while (0) |
| 67 | |
Winkler, Tomas | 2ddfa12 | 2008-12-22 11:31:20 +0800 | [diff] [blame] | 68 | #define DEBUGFS_ADD_X32(name, parent, ptr) do { \ |
| 69 | dbgfs->dbgfs_##parent##_files.file_##name = \ |
Reinette Chatre | fcf89d0 | 2009-07-09 10:33:38 -0700 | [diff] [blame] | 70 | debugfs_create_x32(#name, S_IRUSR, dbgfs->dir_##parent, ptr); \ |
Winkler, Tomas | 2ddfa12 | 2008-12-22 11:31:20 +0800 | [diff] [blame] | 71 | if (IS_ERR(dbgfs->dbgfs_##parent##_files.file_##name) \ |
| 72 | || !dbgfs->dbgfs_##parent##_files.file_##name) \ |
| 73 | goto err; \ |
| 74 | } while (0) |
| 75 | |
Tomas Winkler | 712b6cf | 2008-03-12 16:58:52 -0700 | [diff] [blame] | 76 | #define DEBUGFS_REMOVE(name) do { \ |
| 77 | debugfs_remove(name); \ |
| 78 | name = NULL; \ |
| 79 | } while (0); |
| 80 | |
| 81 | /* file operation */ |
| 82 | #define DEBUGFS_READ_FUNC(name) \ |
| 83 | static ssize_t iwl_dbgfs_##name##_read(struct file *file, \ |
| 84 | char __user *user_buf, \ |
| 85 | size_t count, loff_t *ppos); |
| 86 | |
| 87 | #define DEBUGFS_WRITE_FUNC(name) \ |
| 88 | static ssize_t iwl_dbgfs_##name##_write(struct file *file, \ |
| 89 | const char __user *user_buf, \ |
| 90 | size_t count, loff_t *ppos); |
| 91 | |
| 92 | |
| 93 | static int iwl_dbgfs_open_file_generic(struct inode *inode, struct file *file) |
| 94 | { |
| 95 | file->private_data = inode->i_private; |
| 96 | return 0; |
| 97 | } |
| 98 | |
| 99 | #define DEBUGFS_READ_FILE_OPS(name) \ |
| 100 | DEBUGFS_READ_FUNC(name); \ |
| 101 | static const struct file_operations iwl_dbgfs_##name##_ops = { \ |
| 102 | .read = iwl_dbgfs_##name##_read, \ |
| 103 | .open = iwl_dbgfs_open_file_generic, \ |
| 104 | }; |
| 105 | |
Ester Kummer | 189a2b5 | 2008-05-15 13:54:18 +0800 | [diff] [blame] | 106 | #define DEBUGFS_WRITE_FILE_OPS(name) \ |
| 107 | DEBUGFS_WRITE_FUNC(name); \ |
| 108 | static const struct file_operations iwl_dbgfs_##name##_ops = { \ |
| 109 | .write = iwl_dbgfs_##name##_write, \ |
| 110 | .open = iwl_dbgfs_open_file_generic, \ |
| 111 | }; |
| 112 | |
| 113 | |
Tomas Winkler | 712b6cf | 2008-03-12 16:58:52 -0700 | [diff] [blame] | 114 | #define DEBUGFS_READ_WRITE_FILE_OPS(name) \ |
| 115 | DEBUGFS_READ_FUNC(name); \ |
| 116 | DEBUGFS_WRITE_FUNC(name); \ |
| 117 | static const struct file_operations iwl_dbgfs_##name##_ops = { \ |
| 118 | .write = iwl_dbgfs_##name##_write, \ |
| 119 | .read = iwl_dbgfs_##name##_read, \ |
| 120 | .open = iwl_dbgfs_open_file_generic, \ |
| 121 | }; |
| 122 | |
| 123 | |
| 124 | static ssize_t iwl_dbgfs_tx_statistics_read(struct file *file, |
| 125 | char __user *user_buf, |
| 126 | size_t count, loff_t *ppos) { |
| 127 | |
| 128 | struct iwl_priv *priv = (struct iwl_priv *)file->private_data; |
Wey-Yi Guy | 22fdf3c | 2009-08-07 15:41:40 -0700 | [diff] [blame] | 129 | char *buf; |
Tomas Winkler | 712b6cf | 2008-03-12 16:58:52 -0700 | [diff] [blame] | 130 | int pos = 0; |
| 131 | |
Wey-Yi Guy | 22fdf3c | 2009-08-07 15:41:40 -0700 | [diff] [blame] | 132 | int cnt; |
| 133 | ssize_t ret; |
Wey-Yi Guy | 98a7b43 | 2009-11-13 11:56:31 -0800 | [diff] [blame] | 134 | const size_t bufsz = 100 + |
| 135 | sizeof(char) * 50 * (MANAGEMENT_MAX + CONTROL_MAX); |
Wey-Yi Guy | 22fdf3c | 2009-08-07 15:41:40 -0700 | [diff] [blame] | 136 | buf = kzalloc(bufsz, GFP_KERNEL); |
| 137 | if (!buf) |
| 138 | return -ENOMEM; |
| 139 | pos += scnprintf(buf + pos, bufsz - pos, "Management:\n"); |
| 140 | for (cnt = 0; cnt < MANAGEMENT_MAX; cnt++) { |
| 141 | pos += scnprintf(buf + pos, bufsz - pos, |
Wey-Yi Guy | 98a7b43 | 2009-11-13 11:56:31 -0800 | [diff] [blame] | 142 | "\t%25s\t\t: %u\n", |
Wey-Yi Guy | 22fdf3c | 2009-08-07 15:41:40 -0700 | [diff] [blame] | 143 | get_mgmt_string(cnt), |
| 144 | priv->tx_stats.mgmt[cnt]); |
| 145 | } |
| 146 | pos += scnprintf(buf + pos, bufsz - pos, "Control\n"); |
| 147 | for (cnt = 0; cnt < CONTROL_MAX; cnt++) { |
| 148 | pos += scnprintf(buf + pos, bufsz - pos, |
Wey-Yi Guy | 98a7b43 | 2009-11-13 11:56:31 -0800 | [diff] [blame] | 149 | "\t%25s\t\t: %u\n", |
Wey-Yi Guy | 22fdf3c | 2009-08-07 15:41:40 -0700 | [diff] [blame] | 150 | get_ctrl_string(cnt), |
| 151 | priv->tx_stats.ctrl[cnt]); |
| 152 | } |
| 153 | pos += scnprintf(buf + pos, bufsz - pos, "Data:\n"); |
| 154 | pos += scnprintf(buf + pos, bufsz - pos, "\tcnt: %u\n", |
| 155 | priv->tx_stats.data_cnt); |
| 156 | pos += scnprintf(buf + pos, bufsz - pos, "\tbytes: %llu\n", |
| 157 | priv->tx_stats.data_bytes); |
| 158 | ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos); |
| 159 | kfree(buf); |
| 160 | return ret; |
| 161 | } |
Tomas Winkler | 712b6cf | 2008-03-12 16:58:52 -0700 | [diff] [blame] | 162 | |
Wey-Yi Guy | 7163b8a | 2009-11-20 12:04:56 -0800 | [diff] [blame] | 163 | 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] | 164 | const char __user *user_buf, |
| 165 | size_t count, loff_t *ppos) |
| 166 | { |
| 167 | struct iwl_priv *priv = file->private_data; |
| 168 | u32 clear_flag; |
| 169 | char buf[8]; |
| 170 | int buf_size; |
| 171 | |
| 172 | memset(buf, 0, sizeof(buf)); |
| 173 | buf_size = min(count, sizeof(buf) - 1); |
| 174 | if (copy_from_user(buf, user_buf, buf_size)) |
| 175 | return -EFAULT; |
| 176 | if (sscanf(buf, "%x", &clear_flag) != 1) |
| 177 | return -EFAULT; |
Wey-Yi Guy | 7163b8a | 2009-11-20 12:04:56 -0800 | [diff] [blame] | 178 | iwl_clear_traffic_stats(priv); |
Wey-Yi Guy | 22fdf3c | 2009-08-07 15:41:40 -0700 | [diff] [blame] | 179 | |
| 180 | return count; |
Tomas Winkler | 712b6cf | 2008-03-12 16:58:52 -0700 | [diff] [blame] | 181 | } |
| 182 | |
| 183 | static ssize_t iwl_dbgfs_rx_statistics_read(struct file *file, |
| 184 | char __user *user_buf, |
| 185 | size_t count, loff_t *ppos) { |
| 186 | |
| 187 | struct iwl_priv *priv = (struct iwl_priv *)file->private_data; |
Wey-Yi Guy | 22fdf3c | 2009-08-07 15:41:40 -0700 | [diff] [blame] | 188 | char *buf; |
Tomas Winkler | 712b6cf | 2008-03-12 16:58:52 -0700 | [diff] [blame] | 189 | int pos = 0; |
Wey-Yi Guy | 22fdf3c | 2009-08-07 15:41:40 -0700 | [diff] [blame] | 190 | int cnt; |
| 191 | ssize_t ret; |
| 192 | const size_t bufsz = 100 + |
Wey-Yi Guy | 98a7b43 | 2009-11-13 11:56:31 -0800 | [diff] [blame] | 193 | sizeof(char) * 50 * (MANAGEMENT_MAX + CONTROL_MAX); |
Wey-Yi Guy | 22fdf3c | 2009-08-07 15:41:40 -0700 | [diff] [blame] | 194 | buf = kzalloc(bufsz, GFP_KERNEL); |
| 195 | if (!buf) |
| 196 | return -ENOMEM; |
Tomas Winkler | 712b6cf | 2008-03-12 16:58:52 -0700 | [diff] [blame] | 197 | |
Wey-Yi Guy | 22fdf3c | 2009-08-07 15:41:40 -0700 | [diff] [blame] | 198 | pos += scnprintf(buf + pos, bufsz - pos, "Management:\n"); |
| 199 | for (cnt = 0; cnt < MANAGEMENT_MAX; cnt++) { |
| 200 | pos += scnprintf(buf + pos, bufsz - pos, |
Wey-Yi Guy | 98a7b43 | 2009-11-13 11:56:31 -0800 | [diff] [blame] | 201 | "\t%25s\t\t: %u\n", |
Wey-Yi Guy | 22fdf3c | 2009-08-07 15:41:40 -0700 | [diff] [blame] | 202 | get_mgmt_string(cnt), |
| 203 | priv->rx_stats.mgmt[cnt]); |
| 204 | } |
| 205 | pos += scnprintf(buf + pos, bufsz - pos, "Control:\n"); |
| 206 | for (cnt = 0; cnt < CONTROL_MAX; cnt++) { |
| 207 | pos += scnprintf(buf + pos, bufsz - pos, |
Wey-Yi Guy | 98a7b43 | 2009-11-13 11:56:31 -0800 | [diff] [blame] | 208 | "\t%25s\t\t: %u\n", |
Wey-Yi Guy | 22fdf3c | 2009-08-07 15:41:40 -0700 | [diff] [blame] | 209 | get_ctrl_string(cnt), |
| 210 | priv->rx_stats.ctrl[cnt]); |
| 211 | } |
| 212 | pos += scnprintf(buf + pos, bufsz - pos, "Data:\n"); |
| 213 | pos += scnprintf(buf + pos, bufsz - pos, "\tcnt: %u\n", |
| 214 | priv->rx_stats.data_cnt); |
| 215 | pos += scnprintf(buf + pos, bufsz - pos, "\tbytes: %llu\n", |
| 216 | priv->rx_stats.data_bytes); |
Tomas Winkler | 712b6cf | 2008-03-12 16:58:52 -0700 | [diff] [blame] | 217 | |
Wey-Yi Guy | 22fdf3c | 2009-08-07 15:41:40 -0700 | [diff] [blame] | 218 | ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos); |
| 219 | kfree(buf); |
| 220 | return ret; |
| 221 | } |
| 222 | |
Tomas Winkler | 712b6cf | 2008-03-12 16:58:52 -0700 | [diff] [blame] | 223 | #define BYTE1_MASK 0x000000ff; |
| 224 | #define BYTE2_MASK 0x0000ffff; |
| 225 | #define BYTE3_MASK 0x00ffffff; |
| 226 | static ssize_t iwl_dbgfs_sram_read(struct file *file, |
| 227 | char __user *user_buf, |
| 228 | size_t count, loff_t *ppos) |
| 229 | { |
| 230 | u32 val; |
Wey-Yi Guy | 2943f13 | 2009-11-20 12:05:00 -0800 | [diff] [blame] | 231 | char *buf; |
Tomas Winkler | 712b6cf | 2008-03-12 16:58:52 -0700 | [diff] [blame] | 232 | ssize_t ret; |
| 233 | int i; |
| 234 | int pos = 0; |
| 235 | struct iwl_priv *priv = (struct iwl_priv *)file->private_data; |
Wey-Yi Guy | 2943f13 | 2009-11-20 12:05:00 -0800 | [diff] [blame] | 236 | size_t bufsz; |
Tomas Winkler | 712b6cf | 2008-03-12 16:58:52 -0700 | [diff] [blame] | 237 | |
Wey-Yi Guy | 5ade1e4 | 2009-11-20 12:05:04 -0800 | [diff] [blame] | 238 | /* default is to dump the entire data segment */ |
| 239 | if (!priv->dbgfs->sram_offset && !priv->dbgfs->sram_len) { |
| 240 | priv->dbgfs->sram_offset = 0x800000; |
| 241 | if (priv->ucode_type == UCODE_INIT) |
| 242 | priv->dbgfs->sram_len = priv->ucode_init_data.len; |
| 243 | else |
| 244 | priv->dbgfs->sram_len = priv->ucode_data.len; |
| 245 | } |
| 246 | bufsz = 30 + priv->dbgfs->sram_len * sizeof(char) * 10; |
Wey-Yi Guy | 2943f13 | 2009-11-20 12:05:00 -0800 | [diff] [blame] | 247 | buf = kmalloc(bufsz, GFP_KERNEL); |
| 248 | if (!buf) |
| 249 | return -ENOMEM; |
Wey-Yi Guy | 5ade1e4 | 2009-11-20 12:05:04 -0800 | [diff] [blame] | 250 | pos += scnprintf(buf + pos, bufsz - pos, "sram_len: 0x%x\n", |
Wey-Yi Guy | 2943f13 | 2009-11-20 12:05:00 -0800 | [diff] [blame] | 251 | priv->dbgfs->sram_len); |
Wey-Yi Guy | 5ade1e4 | 2009-11-20 12:05:04 -0800 | [diff] [blame] | 252 | pos += scnprintf(buf + pos, bufsz - pos, "sram_offset: 0x%x\n", |
Wey-Yi Guy | 2943f13 | 2009-11-20 12:05:00 -0800 | [diff] [blame] | 253 | priv->dbgfs->sram_offset); |
Tomas Winkler | 712b6cf | 2008-03-12 16:58:52 -0700 | [diff] [blame] | 254 | for (i = priv->dbgfs->sram_len; i > 0; i -= 4) { |
Tomas Winkler | 3395f6e | 2008-03-25 16:33:37 -0700 | [diff] [blame] | 255 | val = iwl_read_targ_mem(priv, priv->dbgfs->sram_offset + \ |
Tomas Winkler | 712b6cf | 2008-03-12 16:58:52 -0700 | [diff] [blame] | 256 | priv->dbgfs->sram_len - i); |
| 257 | if (i < 4) { |
| 258 | switch (i) { |
| 259 | case 1: |
| 260 | val &= BYTE1_MASK; |
| 261 | break; |
| 262 | case 2: |
| 263 | val &= BYTE2_MASK; |
| 264 | break; |
| 265 | case 3: |
| 266 | val &= BYTE3_MASK; |
| 267 | break; |
| 268 | } |
| 269 | } |
Wey-Yi Guy | 2943f13 | 2009-11-20 12:05:00 -0800 | [diff] [blame] | 270 | if (!(i % 16)) |
| 271 | pos += scnprintf(buf + pos, bufsz - pos, "\n"); |
Abhijeet Kolekar | db0589f | 2008-04-14 21:16:04 -0700 | [diff] [blame] | 272 | pos += scnprintf(buf + pos, bufsz - pos, "0x%08x ", val); |
Tomas Winkler | 712b6cf | 2008-03-12 16:58:52 -0700 | [diff] [blame] | 273 | } |
Abhijeet Kolekar | db0589f | 2008-04-14 21:16:04 -0700 | [diff] [blame] | 274 | pos += scnprintf(buf + pos, bufsz - pos, "\n"); |
Tomas Winkler | 712b6cf | 2008-03-12 16:58:52 -0700 | [diff] [blame] | 275 | |
| 276 | ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos); |
Wey-Yi Guy | 2943f13 | 2009-11-20 12:05:00 -0800 | [diff] [blame] | 277 | kfree(buf); |
Tomas Winkler | 712b6cf | 2008-03-12 16:58:52 -0700 | [diff] [blame] | 278 | return ret; |
| 279 | } |
| 280 | |
| 281 | static ssize_t iwl_dbgfs_sram_write(struct file *file, |
| 282 | const char __user *user_buf, |
| 283 | size_t count, loff_t *ppos) |
| 284 | { |
| 285 | struct iwl_priv *priv = file->private_data; |
| 286 | char buf[64]; |
| 287 | int buf_size; |
| 288 | u32 offset, len; |
| 289 | |
| 290 | memset(buf, 0, sizeof(buf)); |
| 291 | buf_size = min(count, sizeof(buf) - 1); |
| 292 | if (copy_from_user(buf, user_buf, buf_size)) |
| 293 | return -EFAULT; |
| 294 | |
| 295 | if (sscanf(buf, "%x,%x", &offset, &len) == 2) { |
| 296 | priv->dbgfs->sram_offset = offset; |
| 297 | priv->dbgfs->sram_len = len; |
| 298 | } else { |
| 299 | priv->dbgfs->sram_offset = 0; |
| 300 | priv->dbgfs->sram_len = 0; |
| 301 | } |
| 302 | |
| 303 | return count; |
| 304 | } |
| 305 | |
| 306 | static ssize_t iwl_dbgfs_stations_read(struct file *file, char __user *user_buf, |
| 307 | size_t count, loff_t *ppos) |
| 308 | { |
| 309 | struct iwl_priv *priv = (struct iwl_priv *)file->private_data; |
Tomas Winkler | 6def976 | 2008-05-05 10:22:31 +0800 | [diff] [blame] | 310 | struct iwl_station_entry *station; |
Tomas Winkler | 5425e49 | 2008-04-15 16:01:38 -0700 | [diff] [blame] | 311 | int max_sta = priv->hw_params.max_stations; |
Tomas Winkler | 712b6cf | 2008-03-12 16:58:52 -0700 | [diff] [blame] | 312 | char *buf; |
| 313 | int i, j, pos = 0; |
| 314 | ssize_t ret; |
| 315 | /* Add 30 for initial string */ |
| 316 | const size_t bufsz = 30 + sizeof(char) * 500 * (priv->num_stations); |
Tomas Winkler | 712b6cf | 2008-03-12 16:58:52 -0700 | [diff] [blame] | 317 | |
| 318 | buf = kmalloc(bufsz, GFP_KERNEL); |
Tomas Winkler | 3ac7f14 | 2008-07-21 02:40:14 +0300 | [diff] [blame] | 319 | if (!buf) |
Tomas Winkler | 712b6cf | 2008-03-12 16:58:52 -0700 | [diff] [blame] | 320 | return -ENOMEM; |
| 321 | |
Abhijeet Kolekar | db0589f | 2008-04-14 21:16:04 -0700 | [diff] [blame] | 322 | pos += scnprintf(buf + pos, bufsz - pos, "num of stations: %d\n\n", |
Tomas Winkler | 712b6cf | 2008-03-12 16:58:52 -0700 | [diff] [blame] | 323 | priv->num_stations); |
| 324 | |
| 325 | for (i = 0; i < max_sta; i++) { |
| 326 | station = &priv->stations[i]; |
| 327 | if (station->used) { |
Abhijeet Kolekar | db0589f | 2008-04-14 21:16:04 -0700 | [diff] [blame] | 328 | pos += scnprintf(buf + pos, bufsz - pos, |
| 329 | "station %d:\ngeneral data:\n", i+1); |
Abhijeet Kolekar | db0589f | 2008-04-14 21:16:04 -0700 | [diff] [blame] | 330 | pos += scnprintf(buf + pos, bufsz - pos, "id: %u\n", |
Tomas Winkler | 712b6cf | 2008-03-12 16:58:52 -0700 | [diff] [blame] | 331 | station->sta.sta.sta_id); |
Abhijeet Kolekar | db0589f | 2008-04-14 21:16:04 -0700 | [diff] [blame] | 332 | pos += scnprintf(buf + pos, bufsz - pos, "mode: %u\n", |
Tomas Winkler | 712b6cf | 2008-03-12 16:58:52 -0700 | [diff] [blame] | 333 | station->sta.mode); |
Abhijeet Kolekar | db0589f | 2008-04-14 21:16:04 -0700 | [diff] [blame] | 334 | pos += scnprintf(buf + pos, bufsz - pos, |
| 335 | "flags: 0x%x\n", |
Tomas Winkler | 712b6cf | 2008-03-12 16:58:52 -0700 | [diff] [blame] | 336 | station->sta.station_flags_msk); |
Abhijeet Kolekar | db0589f | 2008-04-14 21:16:04 -0700 | [diff] [blame] | 337 | pos += scnprintf(buf + pos, bufsz - pos, "tid data:\n"); |
| 338 | pos += scnprintf(buf + pos, bufsz - pos, |
David S. Miller | 344234d | 2008-04-19 18:09:39 -0700 | [diff] [blame] | 339 | "seq_num\t\ttxq_id"); |
Abhijeet Kolekar | db0589f | 2008-04-14 21:16:04 -0700 | [diff] [blame] | 340 | pos += scnprintf(buf + pos, bufsz - pos, |
David S. Miller | 344234d | 2008-04-19 18:09:39 -0700 | [diff] [blame] | 341 | "\tframe_count\twait_for_ba\t"); |
Abhijeet Kolekar | db0589f | 2008-04-14 21:16:04 -0700 | [diff] [blame] | 342 | pos += scnprintf(buf + pos, bufsz - pos, |
| 343 | "start_idx\tbitmap0\t"); |
| 344 | pos += scnprintf(buf + pos, bufsz - pos, |
David S. Miller | 344234d | 2008-04-19 18:09:39 -0700 | [diff] [blame] | 345 | "bitmap1\trate_n_flags"); |
David S. Miller | 344234d | 2008-04-19 18:09:39 -0700 | [diff] [blame] | 346 | pos += scnprintf(buf + pos, bufsz - pos, "\n"); |
Tomas Winkler | 712b6cf | 2008-03-12 16:58:52 -0700 | [diff] [blame] | 347 | |
| 348 | for (j = 0; j < MAX_TID_COUNT; j++) { |
Abhijeet Kolekar | db0589f | 2008-04-14 21:16:04 -0700 | [diff] [blame] | 349 | pos += scnprintf(buf + pos, bufsz - pos, |
David S. Miller | 344234d | 2008-04-19 18:09:39 -0700 | [diff] [blame] | 350 | "[%d]:\t\t%u", j, |
Abhijeet Kolekar | db0589f | 2008-04-14 21:16:04 -0700 | [diff] [blame] | 351 | station->tid[j].seq_number); |
| 352 | pos += scnprintf(buf + pos, bufsz - pos, |
David S. Miller | 344234d | 2008-04-19 18:09:39 -0700 | [diff] [blame] | 353 | "\t%u\t\t%u\t\t%u\t\t", |
Tomas Winkler | 712b6cf | 2008-03-12 16:58:52 -0700 | [diff] [blame] | 354 | station->tid[j].agg.txq_id, |
| 355 | station->tid[j].agg.frame_count, |
| 356 | station->tid[j].agg.wait_for_ba); |
Abhijeet Kolekar | db0589f | 2008-04-14 21:16:04 -0700 | [diff] [blame] | 357 | pos += scnprintf(buf + pos, bufsz - pos, |
David S. Miller | 344234d | 2008-04-19 18:09:39 -0700 | [diff] [blame] | 358 | "%u\t%llu\t%u", |
Tomas Winkler | 712b6cf | 2008-03-12 16:58:52 -0700 | [diff] [blame] | 359 | station->tid[j].agg.start_idx, |
John W. Linville | 1678859 | 2008-04-01 20:59:32 -0400 | [diff] [blame] | 360 | (unsigned long long)station->tid[j].agg.bitmap, |
Tomas Winkler | 712b6cf | 2008-03-12 16:58:52 -0700 | [diff] [blame] | 361 | station->tid[j].agg.rate_n_flags); |
David S. Miller | 344234d | 2008-04-19 18:09:39 -0700 | [diff] [blame] | 362 | pos += scnprintf(buf + pos, bufsz - pos, "\n"); |
Tomas Winkler | 712b6cf | 2008-03-12 16:58:52 -0700 | [diff] [blame] | 363 | } |
Abhijeet Kolekar | db0589f | 2008-04-14 21:16:04 -0700 | [diff] [blame] | 364 | pos += scnprintf(buf + pos, bufsz - pos, "\n"); |
Tomas Winkler | 712b6cf | 2008-03-12 16:58:52 -0700 | [diff] [blame] | 365 | } |
| 366 | } |
| 367 | |
| 368 | ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos); |
| 369 | kfree(buf); |
| 370 | return ret; |
| 371 | } |
| 372 | |
Wey-Yi Guy | 0848e29 | 2009-05-22 11:01:46 -0700 | [diff] [blame] | 373 | static ssize_t iwl_dbgfs_nvm_read(struct file *file, |
Tomas Winkler | 8dd266e | 2008-05-05 10:22:32 +0800 | [diff] [blame] | 374 | char __user *user_buf, |
| 375 | size_t count, |
| 376 | loff_t *ppos) |
| 377 | { |
| 378 | ssize_t ret; |
| 379 | struct iwl_priv *priv = (struct iwl_priv *)file->private_data; |
| 380 | int pos = 0, ofs = 0, buf_size = 0; |
| 381 | const u8 *ptr; |
| 382 | char *buf; |
Wey-Yi Guy | e307ddc | 2009-09-11 10:38:16 -0700 | [diff] [blame] | 383 | u16 eeprom_ver; |
Tomas Winkler | 8dd266e | 2008-05-05 10:22:32 +0800 | [diff] [blame] | 384 | size_t eeprom_len = priv->cfg->eeprom_size; |
| 385 | buf_size = 4 * eeprom_len + 256; |
| 386 | |
| 387 | if (eeprom_len % 16) { |
Wey-Yi Guy | 0848e29 | 2009-05-22 11:01:46 -0700 | [diff] [blame] | 388 | IWL_ERR(priv, "NVM size is not multiple of 16.\n"); |
Tomas Winkler | 8dd266e | 2008-05-05 10:22:32 +0800 | [diff] [blame] | 389 | return -ENODATA; |
| 390 | } |
| 391 | |
Julia Lawall | c37457e | 2009-08-03 11:11:45 +0200 | [diff] [blame] | 392 | ptr = priv->eeprom; |
| 393 | if (!ptr) { |
| 394 | IWL_ERR(priv, "Invalid EEPROM/OTP memory\n"); |
| 395 | return -ENOMEM; |
| 396 | } |
| 397 | |
Tomas Winkler | 8dd266e | 2008-05-05 10:22:32 +0800 | [diff] [blame] | 398 | /* 4 characters for byte 0xYY */ |
| 399 | buf = kzalloc(buf_size, GFP_KERNEL); |
| 400 | if (!buf) { |
Winkler, Tomas | 15b1687 | 2008-12-19 10:37:33 +0800 | [diff] [blame] | 401 | IWL_ERR(priv, "Can not allocate Buffer\n"); |
Tomas Winkler | 8dd266e | 2008-05-05 10:22:32 +0800 | [diff] [blame] | 402 | return -ENOMEM; |
| 403 | } |
Wey-Yi Guy | e307ddc | 2009-09-11 10:38:16 -0700 | [diff] [blame] | 404 | eeprom_ver = iwl_eeprom_query16(priv, EEPROM_VERSION); |
| 405 | pos += scnprintf(buf + pos, buf_size - pos, "NVM Type: %s, " |
| 406 | "version: 0x%x\n", |
Wey-Yi Guy | 0848e29 | 2009-05-22 11:01:46 -0700 | [diff] [blame] | 407 | (priv->nvm_device_type == NVM_DEVICE_TYPE_OTP) |
Wey-Yi Guy | e307ddc | 2009-09-11 10:38:16 -0700 | [diff] [blame] | 408 | ? "OTP" : "EEPROM", eeprom_ver); |
Tomas Winkler | 8dd266e | 2008-05-05 10:22:32 +0800 | [diff] [blame] | 409 | for (ofs = 0 ; ofs < eeprom_len ; ofs += 16) { |
| 410 | pos += scnprintf(buf + pos, buf_size - pos, "0x%.4x ", ofs); |
| 411 | hex_dump_to_buffer(ptr + ofs, 16 , 16, 2, buf + pos, |
| 412 | buf_size - pos, 0); |
Reinette Chatre | 2fac971 | 2009-09-25 14:24:21 -0700 | [diff] [blame] | 413 | pos += strlen(buf + pos); |
Tomas Winkler | 8dd266e | 2008-05-05 10:22:32 +0800 | [diff] [blame] | 414 | if (buf_size - pos > 0) |
| 415 | buf[pos++] = '\n'; |
| 416 | } |
| 417 | |
| 418 | ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos); |
| 419 | kfree(buf); |
| 420 | return ret; |
| 421 | } |
Tomas Winkler | 712b6cf | 2008-03-12 16:58:52 -0700 | [diff] [blame] | 422 | |
Wey-Yi Guy | b03d7d0 | 2009-12-14 14:12:20 -0800 | [diff] [blame] | 423 | static ssize_t iwl_dbgfs_log_event_read(struct file *file, |
| 424 | char __user *user_buf, |
| 425 | size_t count, loff_t *ppos) |
| 426 | { |
| 427 | struct iwl_priv *priv = file->private_data; |
| 428 | char *buf; |
| 429 | int pos = 0; |
| 430 | ssize_t ret = -ENOMEM; |
| 431 | |
| 432 | pos = priv->cfg->ops->lib->dump_nic_event_log(priv, true, &buf, true); |
| 433 | if (pos && buf) { |
| 434 | ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos); |
| 435 | kfree(buf); |
| 436 | } |
| 437 | return ret; |
| 438 | } |
| 439 | |
Ester Kummer | 189a2b5 | 2008-05-15 13:54:18 +0800 | [diff] [blame] | 440 | static ssize_t iwl_dbgfs_log_event_write(struct file *file, |
| 441 | const char __user *user_buf, |
| 442 | size_t count, loff_t *ppos) |
| 443 | { |
| 444 | struct iwl_priv *priv = file->private_data; |
| 445 | u32 event_log_flag; |
| 446 | char buf[8]; |
| 447 | int buf_size; |
| 448 | |
| 449 | memset(buf, 0, sizeof(buf)); |
| 450 | buf_size = min(count, sizeof(buf) - 1); |
| 451 | if (copy_from_user(buf, user_buf, buf_size)) |
| 452 | return -EFAULT; |
| 453 | if (sscanf(buf, "%d", &event_log_flag) != 1) |
| 454 | return -EFAULT; |
| 455 | if (event_log_flag == 1) |
Wey-Yi Guy | b03d7d0 | 2009-12-14 14:12:20 -0800 | [diff] [blame] | 456 | priv->cfg->ops->lib->dump_nic_event_log(priv, true, |
| 457 | NULL, false); |
Ester Kummer | 189a2b5 | 2008-05-15 13:54:18 +0800 | [diff] [blame] | 458 | |
| 459 | return count; |
| 460 | } |
| 461 | |
Winkler, Tomas | d366df5 | 2008-12-02 12:14:01 -0800 | [diff] [blame] | 462 | |
| 463 | |
| 464 | static ssize_t iwl_dbgfs_channels_read(struct file *file, char __user *user_buf, |
| 465 | size_t count, loff_t *ppos) |
| 466 | { |
| 467 | struct iwl_priv *priv = (struct iwl_priv *)file->private_data; |
| 468 | struct ieee80211_channel *channels = NULL; |
| 469 | const struct ieee80211_supported_band *supp_band = NULL; |
| 470 | int pos = 0, i, bufsz = PAGE_SIZE; |
| 471 | char *buf; |
| 472 | ssize_t ret; |
| 473 | |
| 474 | if (!test_bit(STATUS_GEO_CONFIGURED, &priv->status)) |
| 475 | return -EAGAIN; |
| 476 | |
| 477 | buf = kzalloc(bufsz, GFP_KERNEL); |
| 478 | if (!buf) { |
Winkler, Tomas | 15b1687 | 2008-12-19 10:37:33 +0800 | [diff] [blame] | 479 | IWL_ERR(priv, "Can not allocate Buffer\n"); |
Winkler, Tomas | d366df5 | 2008-12-02 12:14:01 -0800 | [diff] [blame] | 480 | return -ENOMEM; |
| 481 | } |
| 482 | |
| 483 | supp_band = iwl_get_hw_mode(priv, IEEE80211_BAND_2GHZ); |
Wey-Yi Guy | a2e2322 | 2009-05-22 11:01:55 -0700 | [diff] [blame] | 484 | if (supp_band) { |
| 485 | channels = supp_band->channels; |
Winkler, Tomas | d366df5 | 2008-12-02 12:14:01 -0800 | [diff] [blame] | 486 | |
Winkler, Tomas | d366df5 | 2008-12-02 12:14:01 -0800 | [diff] [blame] | 487 | pos += scnprintf(buf + pos, bufsz - pos, |
Wey-Yi Guy | a2e2322 | 2009-05-22 11:01:55 -0700 | [diff] [blame] | 488 | "Displaying %d channels in 2.4GHz band 802.11bg):\n", |
| 489 | supp_band->n_channels); |
Winkler, Tomas | d366df5 | 2008-12-02 12:14:01 -0800 | [diff] [blame] | 490 | |
Wey-Yi Guy | a2e2322 | 2009-05-22 11:01:55 -0700 | [diff] [blame] | 491 | for (i = 0; i < supp_band->n_channels; i++) |
| 492 | pos += scnprintf(buf + pos, bufsz - pos, |
| 493 | "%d: %ddBm: BSS%s%s, %s.\n", |
| 494 | ieee80211_frequency_to_channel( |
| 495 | channels[i].center_freq), |
| 496 | channels[i].max_power, |
| 497 | channels[i].flags & IEEE80211_CHAN_RADAR ? |
| 498 | " (IEEE 802.11h required)" : "", |
| 499 | ((channels[i].flags & IEEE80211_CHAN_NO_IBSS) |
| 500 | || (channels[i].flags & |
| 501 | IEEE80211_CHAN_RADAR)) ? "" : |
| 502 | ", IBSS", |
| 503 | channels[i].flags & |
| 504 | IEEE80211_CHAN_PASSIVE_SCAN ? |
| 505 | "passive only" : "active/passive"); |
| 506 | } |
Winkler, Tomas | d366df5 | 2008-12-02 12:14:01 -0800 | [diff] [blame] | 507 | supp_band = iwl_get_hw_mode(priv, IEEE80211_BAND_5GHZ); |
Wey-Yi Guy | a2e2322 | 2009-05-22 11:01:55 -0700 | [diff] [blame] | 508 | if (supp_band) { |
| 509 | channels = supp_band->channels; |
Winkler, Tomas | d366df5 | 2008-12-02 12:14:01 -0800 | [diff] [blame] | 510 | |
Winkler, Tomas | d366df5 | 2008-12-02 12:14:01 -0800 | [diff] [blame] | 511 | pos += scnprintf(buf + pos, bufsz - pos, |
Wey-Yi Guy | a2e2322 | 2009-05-22 11:01:55 -0700 | [diff] [blame] | 512 | "Displaying %d channels in 5.2GHz band (802.11a)\n", |
| 513 | supp_band->n_channels); |
| 514 | |
| 515 | for (i = 0; i < supp_band->n_channels; i++) |
| 516 | pos += scnprintf(buf + pos, bufsz - pos, |
| 517 | "%d: %ddBm: BSS%s%s, %s.\n", |
| 518 | ieee80211_frequency_to_channel( |
| 519 | channels[i].center_freq), |
| 520 | channels[i].max_power, |
| 521 | channels[i].flags & IEEE80211_CHAN_RADAR ? |
| 522 | " (IEEE 802.11h required)" : "", |
| 523 | ((channels[i].flags & IEEE80211_CHAN_NO_IBSS) |
| 524 | || (channels[i].flags & |
| 525 | IEEE80211_CHAN_RADAR)) ? "" : |
| 526 | ", IBSS", |
| 527 | channels[i].flags & |
| 528 | IEEE80211_CHAN_PASSIVE_SCAN ? |
| 529 | "passive only" : "active/passive"); |
| 530 | } |
Winkler, Tomas | d366df5 | 2008-12-02 12:14:01 -0800 | [diff] [blame] | 531 | ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos); |
| 532 | kfree(buf); |
| 533 | return ret; |
| 534 | } |
| 535 | |
Wey-Yi Guy | 08df05a | 2009-03-24 10:02:54 -0700 | [diff] [blame] | 536 | static ssize_t iwl_dbgfs_status_read(struct file *file, |
| 537 | char __user *user_buf, |
| 538 | size_t count, loff_t *ppos) { |
| 539 | |
| 540 | struct iwl_priv *priv = (struct iwl_priv *)file->private_data; |
| 541 | char buf[512]; |
| 542 | int pos = 0; |
| 543 | const size_t bufsz = sizeof(buf); |
| 544 | |
| 545 | pos += scnprintf(buf + pos, bufsz - pos, "STATUS_HCMD_ACTIVE:\t %d\n", |
| 546 | test_bit(STATUS_HCMD_ACTIVE, &priv->status)); |
| 547 | pos += scnprintf(buf + pos, bufsz - pos, "STATUS_HCMD_SYNC_ACTIVE: %d\n", |
| 548 | test_bit(STATUS_HCMD_SYNC_ACTIVE, &priv->status)); |
| 549 | pos += scnprintf(buf + pos, bufsz - pos, "STATUS_INT_ENABLED:\t %d\n", |
| 550 | test_bit(STATUS_INT_ENABLED, &priv->status)); |
| 551 | pos += scnprintf(buf + pos, bufsz - pos, "STATUS_RF_KILL_HW:\t %d\n", |
| 552 | test_bit(STATUS_RF_KILL_HW, &priv->status)); |
Wey-Yi Guy | 7812b16 | 2009-10-02 13:43:58 -0700 | [diff] [blame] | 553 | pos += scnprintf(buf + pos, bufsz - pos, "STATUS_CT_KILL:\t\t %d\n", |
| 554 | test_bit(STATUS_CT_KILL, &priv->status)); |
Wey-Yi Guy | 08df05a | 2009-03-24 10:02:54 -0700 | [diff] [blame] | 555 | pos += scnprintf(buf + pos, bufsz - pos, "STATUS_INIT:\t\t %d\n", |
| 556 | test_bit(STATUS_INIT, &priv->status)); |
| 557 | pos += scnprintf(buf + pos, bufsz - pos, "STATUS_ALIVE:\t\t %d\n", |
| 558 | test_bit(STATUS_ALIVE, &priv->status)); |
| 559 | pos += scnprintf(buf + pos, bufsz - pos, "STATUS_READY:\t\t %d\n", |
| 560 | test_bit(STATUS_READY, &priv->status)); |
| 561 | pos += scnprintf(buf + pos, bufsz - pos, "STATUS_TEMPERATURE:\t %d\n", |
| 562 | test_bit(STATUS_TEMPERATURE, &priv->status)); |
| 563 | pos += scnprintf(buf + pos, bufsz - pos, "STATUS_GEO_CONFIGURED:\t %d\n", |
| 564 | test_bit(STATUS_GEO_CONFIGURED, &priv->status)); |
| 565 | pos += scnprintf(buf + pos, bufsz - pos, "STATUS_EXIT_PENDING:\t %d\n", |
| 566 | test_bit(STATUS_EXIT_PENDING, &priv->status)); |
Wey-Yi Guy | 08df05a | 2009-03-24 10:02:54 -0700 | [diff] [blame] | 567 | pos += scnprintf(buf + pos, bufsz - pos, "STATUS_STATISTICS:\t %d\n", |
| 568 | test_bit(STATUS_STATISTICS, &priv->status)); |
| 569 | pos += scnprintf(buf + pos, bufsz - pos, "STATUS_SCANNING:\t %d\n", |
| 570 | test_bit(STATUS_SCANNING, &priv->status)); |
| 571 | pos += scnprintf(buf + pos, bufsz - pos, "STATUS_SCAN_ABORTING:\t %d\n", |
| 572 | test_bit(STATUS_SCAN_ABORTING, &priv->status)); |
| 573 | pos += scnprintf(buf + pos, bufsz - pos, "STATUS_SCAN_HW:\t\t %d\n", |
| 574 | test_bit(STATUS_SCAN_HW, &priv->status)); |
| 575 | pos += scnprintf(buf + pos, bufsz - pos, "STATUS_POWER_PMI:\t %d\n", |
| 576 | test_bit(STATUS_POWER_PMI, &priv->status)); |
| 577 | pos += scnprintf(buf + pos, bufsz - pos, "STATUS_FW_ERROR:\t %d\n", |
| 578 | test_bit(STATUS_FW_ERROR, &priv->status)); |
| 579 | pos += scnprintf(buf + pos, bufsz - pos, "STATUS_MODE_PENDING:\t %d\n", |
| 580 | test_bit(STATUS_MODE_PENDING, &priv->status)); |
| 581 | return simple_read_from_buffer(user_buf, count, ppos, buf, pos); |
| 582 | } |
| 583 | |
Wey-Yi Guy | a83b914 | 2009-04-08 11:39:32 -0700 | [diff] [blame] | 584 | static ssize_t iwl_dbgfs_interrupt_read(struct file *file, |
| 585 | char __user *user_buf, |
| 586 | size_t count, loff_t *ppos) { |
| 587 | |
| 588 | struct iwl_priv *priv = (struct iwl_priv *)file->private_data; |
| 589 | int pos = 0; |
| 590 | int cnt = 0; |
| 591 | char *buf; |
| 592 | int bufsz = 24 * 64; /* 24 items * 64 char per item */ |
| 593 | ssize_t ret; |
| 594 | |
| 595 | buf = kzalloc(bufsz, GFP_KERNEL); |
| 596 | if (!buf) { |
| 597 | IWL_ERR(priv, "Can not allocate Buffer\n"); |
| 598 | return -ENOMEM; |
| 599 | } |
| 600 | |
| 601 | pos += scnprintf(buf + pos, bufsz - pos, |
| 602 | "Interrupt Statistics Report:\n"); |
| 603 | |
| 604 | pos += scnprintf(buf + pos, bufsz - pos, "HW Error:\t\t\t %u\n", |
| 605 | priv->isr_stats.hw); |
| 606 | pos += scnprintf(buf + pos, bufsz - pos, "SW Error:\t\t\t %u\n", |
| 607 | priv->isr_stats.sw); |
| 608 | if (priv->isr_stats.sw > 0) { |
| 609 | pos += scnprintf(buf + pos, bufsz - pos, |
| 610 | "\tLast Restarting Code: 0x%X\n", |
| 611 | priv->isr_stats.sw_err); |
| 612 | } |
| 613 | #ifdef CONFIG_IWLWIFI_DEBUG |
| 614 | pos += scnprintf(buf + pos, bufsz - pos, "Frame transmitted:\t\t %u\n", |
| 615 | priv->isr_stats.sch); |
| 616 | pos += scnprintf(buf + pos, bufsz - pos, "Alive interrupt:\t\t %u\n", |
| 617 | priv->isr_stats.alive); |
| 618 | #endif |
| 619 | pos += scnprintf(buf + pos, bufsz - pos, |
| 620 | "HW RF KILL switch toggled:\t %u\n", |
| 621 | priv->isr_stats.rfkill); |
| 622 | |
| 623 | pos += scnprintf(buf + pos, bufsz - pos, "CT KILL:\t\t\t %u\n", |
| 624 | priv->isr_stats.ctkill); |
| 625 | |
| 626 | pos += scnprintf(buf + pos, bufsz - pos, "Wakeup Interrupt:\t\t %u\n", |
| 627 | priv->isr_stats.wakeup); |
| 628 | |
| 629 | pos += scnprintf(buf + pos, bufsz - pos, |
| 630 | "Rx command responses:\t\t %u\n", |
| 631 | priv->isr_stats.rx); |
| 632 | for (cnt = 0; cnt < REPLY_MAX; cnt++) { |
| 633 | if (priv->isr_stats.rx_handlers[cnt] > 0) |
| 634 | pos += scnprintf(buf + pos, bufsz - pos, |
| 635 | "\tRx handler[%36s]:\t\t %u\n", |
| 636 | get_cmd_string(cnt), |
| 637 | priv->isr_stats.rx_handlers[cnt]); |
| 638 | } |
| 639 | |
| 640 | pos += scnprintf(buf + pos, bufsz - pos, "Tx/FH interrupt:\t\t %u\n", |
| 641 | priv->isr_stats.tx); |
| 642 | |
| 643 | pos += scnprintf(buf + pos, bufsz - pos, "Unexpected INTA:\t\t %u\n", |
| 644 | priv->isr_stats.unhandled); |
| 645 | |
| 646 | ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos); |
| 647 | kfree(buf); |
| 648 | return ret; |
| 649 | } |
| 650 | |
| 651 | static ssize_t iwl_dbgfs_interrupt_write(struct file *file, |
| 652 | const char __user *user_buf, |
| 653 | size_t count, loff_t *ppos) |
| 654 | { |
| 655 | struct iwl_priv *priv = file->private_data; |
| 656 | char buf[8]; |
| 657 | int buf_size; |
| 658 | u32 reset_flag; |
| 659 | |
| 660 | memset(buf, 0, sizeof(buf)); |
| 661 | buf_size = min(count, sizeof(buf) - 1); |
| 662 | if (copy_from_user(buf, user_buf, buf_size)) |
| 663 | return -EFAULT; |
| 664 | if (sscanf(buf, "%x", &reset_flag) != 1) |
| 665 | return -EFAULT; |
| 666 | if (reset_flag == 0) |
| 667 | iwl_clear_isr_stats(priv); |
| 668 | |
| 669 | return count; |
| 670 | } |
| 671 | |
Wey-Yi Guy | f5ad69f | 2009-07-09 10:33:36 -0700 | [diff] [blame] | 672 | static ssize_t iwl_dbgfs_qos_read(struct file *file, char __user *user_buf, |
| 673 | size_t count, loff_t *ppos) |
| 674 | { |
| 675 | struct iwl_priv *priv = (struct iwl_priv *)file->private_data; |
| 676 | int pos = 0, i; |
| 677 | char buf[256]; |
| 678 | const size_t bufsz = sizeof(buf); |
| 679 | ssize_t ret; |
| 680 | |
| 681 | for (i = 0; i < AC_NUM; i++) { |
| 682 | pos += scnprintf(buf + pos, bufsz - pos, |
| 683 | "\tcw_min\tcw_max\taifsn\ttxop\n"); |
| 684 | pos += scnprintf(buf + pos, bufsz - pos, |
| 685 | "AC[%d]\t%u\t%u\t%u\t%u\n", i, |
| 686 | priv->qos_data.def_qos_parm.ac[i].cw_min, |
| 687 | priv->qos_data.def_qos_parm.ac[i].cw_max, |
| 688 | priv->qos_data.def_qos_parm.ac[i].aifsn, |
| 689 | priv->qos_data.def_qos_parm.ac[i].edca_txop); |
| 690 | } |
| 691 | ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos); |
| 692 | return ret; |
| 693 | } |
Wey-Yi Guy | a83b914 | 2009-04-08 11:39:32 -0700 | [diff] [blame] | 694 | |
Wey-Yi Guy | a283c01 | 2009-07-17 09:30:19 -0700 | [diff] [blame] | 695 | static ssize_t iwl_dbgfs_led_read(struct file *file, char __user *user_buf, |
| 696 | size_t count, loff_t *ppos) |
| 697 | { |
| 698 | struct iwl_priv *priv = (struct iwl_priv *)file->private_data; |
| 699 | int pos = 0; |
| 700 | char buf[256]; |
| 701 | const size_t bufsz = sizeof(buf); |
| 702 | ssize_t ret; |
| 703 | |
| 704 | pos += scnprintf(buf + pos, bufsz - pos, |
| 705 | "allow blinking: %s\n", |
| 706 | (priv->allow_blinking) ? "True" : "False"); |
| 707 | if (priv->allow_blinking) { |
| 708 | pos += scnprintf(buf + pos, bufsz - pos, |
| 709 | "Led blinking rate: %u\n", |
| 710 | priv->last_blink_rate); |
| 711 | pos += scnprintf(buf + pos, bufsz - pos, |
| 712 | "Last blink time: %lu\n", |
| 713 | priv->last_blink_time); |
| 714 | } |
| 715 | |
| 716 | ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos); |
| 717 | return ret; |
| 718 | } |
Wey-Yi Guy | a283c01 | 2009-07-17 09:30:19 -0700 | [diff] [blame] | 719 | |
Wey-Yi Guy | fbf3a2a | 2009-07-24 11:13:04 -0700 | [diff] [blame] | 720 | static ssize_t iwl_dbgfs_thermal_throttling_read(struct file *file, |
| 721 | char __user *user_buf, |
| 722 | size_t count, loff_t *ppos) |
| 723 | { |
| 724 | struct iwl_priv *priv = (struct iwl_priv *)file->private_data; |
Johannes Berg | 3ad3b92 | 2009-08-07 15:41:48 -0700 | [diff] [blame] | 725 | struct iwl_tt_mgmt *tt = &priv->thermal_throttle; |
Wey-Yi Guy | fbf3a2a | 2009-07-24 11:13:04 -0700 | [diff] [blame] | 726 | struct iwl_tt_restriction *restriction; |
| 727 | char buf[100]; |
| 728 | int pos = 0; |
| 729 | const size_t bufsz = sizeof(buf); |
| 730 | ssize_t ret; |
| 731 | |
| 732 | pos += scnprintf(buf + pos, bufsz - pos, |
| 733 | "Thermal Throttling Mode: %s\n", |
Johannes Berg | 3ad3b92 | 2009-08-07 15:41:48 -0700 | [diff] [blame] | 734 | tt->advanced_tt ? "Advance" : "Legacy"); |
Wey-Yi Guy | fbf3a2a | 2009-07-24 11:13:04 -0700 | [diff] [blame] | 735 | pos += scnprintf(buf + pos, bufsz - pos, |
| 736 | "Thermal Throttling State: %d\n", |
| 737 | tt->state); |
Johannes Berg | 3ad3b92 | 2009-08-07 15:41:48 -0700 | [diff] [blame] | 738 | if (tt->advanced_tt) { |
Wey-Yi Guy | fbf3a2a | 2009-07-24 11:13:04 -0700 | [diff] [blame] | 739 | restriction = tt->restriction + tt->state; |
| 740 | pos += scnprintf(buf + pos, bufsz - pos, |
| 741 | "Tx mode: %d\n", |
| 742 | restriction->tx_stream); |
| 743 | pos += scnprintf(buf + pos, bufsz - pos, |
| 744 | "Rx mode: %d\n", |
| 745 | restriction->rx_stream); |
| 746 | pos += scnprintf(buf + pos, bufsz - pos, |
| 747 | "HT mode: %d\n", |
| 748 | restriction->is_ht); |
| 749 | } |
| 750 | ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos); |
| 751 | return ret; |
| 752 | } |
| 753 | |
Wey-Yi Guy | 1e4247d | 2009-07-27 13:50:15 -0700 | [diff] [blame] | 754 | static ssize_t iwl_dbgfs_disable_ht40_write(struct file *file, |
| 755 | const char __user *user_buf, |
| 756 | size_t count, loff_t *ppos) |
| 757 | { |
| 758 | struct iwl_priv *priv = file->private_data; |
| 759 | char buf[8]; |
| 760 | int buf_size; |
| 761 | int ht40; |
| 762 | |
| 763 | memset(buf, 0, sizeof(buf)); |
| 764 | buf_size = min(count, sizeof(buf) - 1); |
| 765 | if (copy_from_user(buf, user_buf, buf_size)) |
| 766 | return -EFAULT; |
| 767 | if (sscanf(buf, "%d", &ht40) != 1) |
| 768 | return -EFAULT; |
| 769 | if (!iwl_is_associated(priv)) |
| 770 | priv->disable_ht40 = ht40 ? true : false; |
| 771 | else { |
| 772 | IWL_ERR(priv, "Sta associated with AP - " |
| 773 | "Change to 40MHz channel support is not allowed\n"); |
| 774 | return -EINVAL; |
| 775 | } |
| 776 | |
| 777 | return count; |
| 778 | } |
| 779 | |
| 780 | static ssize_t iwl_dbgfs_disable_ht40_read(struct file *file, |
| 781 | char __user *user_buf, |
| 782 | size_t count, loff_t *ppos) |
| 783 | { |
| 784 | struct iwl_priv *priv = (struct iwl_priv *)file->private_data; |
| 785 | char buf[100]; |
| 786 | int pos = 0; |
| 787 | const size_t bufsz = sizeof(buf); |
| 788 | ssize_t ret; |
| 789 | |
| 790 | pos += scnprintf(buf + pos, bufsz - pos, |
| 791 | "11n 40MHz Mode: %s\n", |
| 792 | priv->disable_ht40 ? "Disabled" : "Enabled"); |
| 793 | ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos); |
| 794 | return ret; |
| 795 | } |
| 796 | |
Johannes Berg | e312c24 | 2009-08-07 15:41:51 -0700 | [diff] [blame] | 797 | static ssize_t iwl_dbgfs_sleep_level_override_write(struct file *file, |
| 798 | const char __user *user_buf, |
| 799 | size_t count, loff_t *ppos) |
| 800 | { |
| 801 | struct iwl_priv *priv = file->private_data; |
| 802 | char buf[8]; |
| 803 | int buf_size; |
| 804 | int value; |
| 805 | |
| 806 | memset(buf, 0, sizeof(buf)); |
| 807 | buf_size = min(count, sizeof(buf) - 1); |
| 808 | if (copy_from_user(buf, user_buf, buf_size)) |
| 809 | return -EFAULT; |
| 810 | |
| 811 | if (sscanf(buf, "%d", &value) != 1) |
| 812 | return -EINVAL; |
| 813 | |
| 814 | /* |
| 815 | * Our users expect 0 to be "CAM", but 0 isn't actually |
| 816 | * valid here. However, let's not confuse them and present |
| 817 | * IWL_POWER_INDEX_1 as "1", not "0". |
| 818 | */ |
Reinette Chatre | 1a34c04 | 2009-10-09 13:20:25 -0700 | [diff] [blame] | 819 | if (value == 0) |
| 820 | return -EINVAL; |
| 821 | else if (value > 0) |
Johannes Berg | e312c24 | 2009-08-07 15:41:51 -0700 | [diff] [blame] | 822 | value -= 1; |
| 823 | |
| 824 | if (value != -1 && (value < 0 || value >= IWL_POWER_NUM)) |
| 825 | return -EINVAL; |
| 826 | |
Wey-Yi Guy | 4ad177b | 2009-10-16 14:25:58 -0700 | [diff] [blame] | 827 | if (!iwl_is_ready_rf(priv)) |
| 828 | return -EAGAIN; |
| 829 | |
Johannes Berg | e312c24 | 2009-08-07 15:41:51 -0700 | [diff] [blame] | 830 | priv->power_data.debug_sleep_level_override = value; |
| 831 | |
Wey-Yi Guy | 4ad177b | 2009-10-16 14:25:58 -0700 | [diff] [blame] | 832 | iwl_power_update_mode(priv, true); |
Johannes Berg | e312c24 | 2009-08-07 15:41:51 -0700 | [diff] [blame] | 833 | |
| 834 | return count; |
| 835 | } |
| 836 | |
| 837 | static ssize_t iwl_dbgfs_sleep_level_override_read(struct file *file, |
| 838 | char __user *user_buf, |
| 839 | size_t count, loff_t *ppos) |
| 840 | { |
| 841 | struct iwl_priv *priv = (struct iwl_priv *)file->private_data; |
| 842 | char buf[10]; |
| 843 | int pos, value; |
| 844 | const size_t bufsz = sizeof(buf); |
| 845 | |
| 846 | /* see the write function */ |
| 847 | value = priv->power_data.debug_sleep_level_override; |
| 848 | if (value >= 0) |
| 849 | value += 1; |
| 850 | |
| 851 | pos = scnprintf(buf, bufsz, "%d\n", value); |
| 852 | return simple_read_from_buffer(user_buf, count, ppos, buf, pos); |
| 853 | } |
| 854 | |
| 855 | static ssize_t iwl_dbgfs_current_sleep_command_read(struct file *file, |
| 856 | char __user *user_buf, |
| 857 | size_t count, loff_t *ppos) |
| 858 | { |
| 859 | struct iwl_priv *priv = (struct iwl_priv *)file->private_data; |
| 860 | char buf[200]; |
| 861 | int pos = 0, i; |
| 862 | const size_t bufsz = sizeof(buf); |
| 863 | struct iwl_powertable_cmd *cmd = &priv->power_data.sleep_cmd; |
| 864 | |
| 865 | pos += scnprintf(buf + pos, bufsz - pos, |
| 866 | "flags: %#.2x\n", le16_to_cpu(cmd->flags)); |
| 867 | pos += scnprintf(buf + pos, bufsz - pos, |
| 868 | "RX/TX timeout: %d/%d usec\n", |
| 869 | le32_to_cpu(cmd->rx_data_timeout), |
| 870 | le32_to_cpu(cmd->tx_data_timeout)); |
| 871 | for (i = 0; i < IWL_POWER_VEC_SIZE; i++) |
| 872 | pos += scnprintf(buf + pos, bufsz - pos, |
| 873 | "sleep_interval[%d]: %d\n", i, |
| 874 | le32_to_cpu(cmd->sleep_interval[i])); |
| 875 | |
| 876 | return simple_read_from_buffer(user_buf, count, ppos, buf, pos); |
| 877 | } |
| 878 | |
Tomas Winkler | 712b6cf | 2008-03-12 16:58:52 -0700 | [diff] [blame] | 879 | DEBUGFS_READ_WRITE_FILE_OPS(sram); |
Wey-Yi Guy | b03d7d0 | 2009-12-14 14:12:20 -0800 | [diff] [blame] | 880 | DEBUGFS_READ_WRITE_FILE_OPS(log_event); |
Wey-Yi Guy | 0848e29 | 2009-05-22 11:01:46 -0700 | [diff] [blame] | 881 | DEBUGFS_READ_FILE_OPS(nvm); |
Tomas Winkler | 712b6cf | 2008-03-12 16:58:52 -0700 | [diff] [blame] | 882 | DEBUGFS_READ_FILE_OPS(stations); |
Winkler, Tomas | d366df5 | 2008-12-02 12:14:01 -0800 | [diff] [blame] | 883 | DEBUGFS_READ_FILE_OPS(channels); |
Wey-Yi Guy | 08df05a | 2009-03-24 10:02:54 -0700 | [diff] [blame] | 884 | DEBUGFS_READ_FILE_OPS(status); |
Wey-Yi Guy | a83b914 | 2009-04-08 11:39:32 -0700 | [diff] [blame] | 885 | DEBUGFS_READ_WRITE_FILE_OPS(interrupt); |
Wey-Yi Guy | f5ad69f | 2009-07-09 10:33:36 -0700 | [diff] [blame] | 886 | DEBUGFS_READ_FILE_OPS(qos); |
Wey-Yi Guy | a283c01 | 2009-07-17 09:30:19 -0700 | [diff] [blame] | 887 | DEBUGFS_READ_FILE_OPS(led); |
Wey-Yi Guy | fbf3a2a | 2009-07-24 11:13:04 -0700 | [diff] [blame] | 888 | DEBUGFS_READ_FILE_OPS(thermal_throttling); |
Wey-Yi Guy | 1e4247d | 2009-07-27 13:50:15 -0700 | [diff] [blame] | 889 | DEBUGFS_READ_WRITE_FILE_OPS(disable_ht40); |
Johannes Berg | e312c24 | 2009-08-07 15:41:51 -0700 | [diff] [blame] | 890 | DEBUGFS_READ_WRITE_FILE_OPS(sleep_level_override); |
| 891 | DEBUGFS_READ_FILE_OPS(current_sleep_command); |
Tomas Winkler | 712b6cf | 2008-03-12 16:58:52 -0700 | [diff] [blame] | 892 | |
Wey-Yi Guy | 20594eb | 2009-08-07 15:41:39 -0700 | [diff] [blame] | 893 | static ssize_t iwl_dbgfs_traffic_log_read(struct file *file, |
| 894 | char __user *user_buf, |
| 895 | size_t count, loff_t *ppos) |
| 896 | { |
| 897 | struct iwl_priv *priv = file->private_data; |
| 898 | int pos = 0, ofs = 0; |
| 899 | int cnt = 0, entry; |
| 900 | struct iwl_tx_queue *txq; |
| 901 | struct iwl_queue *q; |
| 902 | struct iwl_rx_queue *rxq = &priv->rxq; |
| 903 | char *buf; |
| 904 | int bufsz = ((IWL_TRAFFIC_ENTRIES * IWL_TRAFFIC_ENTRY_SIZE * 64) * 2) + |
Wey-Yi Guy | 88804e2 | 2009-10-09 13:20:28 -0700 | [diff] [blame] | 905 | (priv->cfg->num_of_queues * 32 * 8) + 400; |
Wey-Yi Guy | 20594eb | 2009-08-07 15:41:39 -0700 | [diff] [blame] | 906 | const u8 *ptr; |
| 907 | ssize_t ret; |
| 908 | |
Wey-Yi Guy | 88804e2 | 2009-10-09 13:20:28 -0700 | [diff] [blame] | 909 | if (!priv->txq) { |
| 910 | IWL_ERR(priv, "txq not ready\n"); |
| 911 | return -EAGAIN; |
| 912 | } |
Wey-Yi Guy | 20594eb | 2009-08-07 15:41:39 -0700 | [diff] [blame] | 913 | buf = kzalloc(bufsz, GFP_KERNEL); |
| 914 | if (!buf) { |
| 915 | IWL_ERR(priv, "Can not allocate buffer\n"); |
| 916 | return -ENOMEM; |
| 917 | } |
| 918 | pos += scnprintf(buf + pos, bufsz - pos, "Tx Queue\n"); |
| 919 | for (cnt = 0; cnt < priv->hw_params.max_txq_num; cnt++) { |
| 920 | txq = &priv->txq[cnt]; |
| 921 | q = &txq->q; |
| 922 | pos += scnprintf(buf + pos, bufsz - pos, |
| 923 | "q[%d]: read_ptr: %u, write_ptr: %u\n", |
| 924 | cnt, q->read_ptr, q->write_ptr); |
| 925 | } |
| 926 | if (priv->tx_traffic && (iwl_debug_level & IWL_DL_TX)) { |
| 927 | ptr = priv->tx_traffic; |
| 928 | pos += scnprintf(buf + pos, bufsz - pos, |
| 929 | "Tx Traffic idx: %u\n", priv->tx_traffic_idx); |
| 930 | for (cnt = 0, ofs = 0; cnt < IWL_TRAFFIC_ENTRIES; cnt++) { |
| 931 | for (entry = 0; entry < IWL_TRAFFIC_ENTRY_SIZE / 16; |
| 932 | entry++, ofs += 16) { |
| 933 | pos += scnprintf(buf + pos, bufsz - pos, |
| 934 | "0x%.4x ", ofs); |
| 935 | hex_dump_to_buffer(ptr + ofs, 16, 16, 2, |
| 936 | buf + pos, bufsz - pos, 0); |
Reinette Chatre | 2fac971 | 2009-09-25 14:24:21 -0700 | [diff] [blame] | 937 | pos += strlen(buf + pos); |
Wey-Yi Guy | 20594eb | 2009-08-07 15:41:39 -0700 | [diff] [blame] | 938 | if (bufsz - pos > 0) |
| 939 | buf[pos++] = '\n'; |
| 940 | } |
| 941 | } |
| 942 | } |
| 943 | |
| 944 | pos += scnprintf(buf + pos, bufsz - pos, "Rx Queue\n"); |
| 945 | pos += scnprintf(buf + pos, bufsz - pos, |
| 946 | "read: %u, write: %u\n", |
| 947 | rxq->read, rxq->write); |
| 948 | |
| 949 | if (priv->rx_traffic && (iwl_debug_level & IWL_DL_RX)) { |
| 950 | ptr = priv->rx_traffic; |
| 951 | pos += scnprintf(buf + pos, bufsz - pos, |
| 952 | "Rx Traffic idx: %u\n", priv->rx_traffic_idx); |
| 953 | for (cnt = 0, ofs = 0; cnt < IWL_TRAFFIC_ENTRIES; cnt++) { |
| 954 | for (entry = 0; entry < IWL_TRAFFIC_ENTRY_SIZE / 16; |
| 955 | entry++, ofs += 16) { |
| 956 | pos += scnprintf(buf + pos, bufsz - pos, |
| 957 | "0x%.4x ", ofs); |
| 958 | hex_dump_to_buffer(ptr + ofs, 16, 16, 2, |
| 959 | buf + pos, bufsz - pos, 0); |
Reinette Chatre | 2fac971 | 2009-09-25 14:24:21 -0700 | [diff] [blame] | 960 | pos += strlen(buf + pos); |
Wey-Yi Guy | 20594eb | 2009-08-07 15:41:39 -0700 | [diff] [blame] | 961 | if (bufsz - pos > 0) |
| 962 | buf[pos++] = '\n'; |
| 963 | } |
| 964 | } |
| 965 | } |
| 966 | |
| 967 | ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos); |
| 968 | kfree(buf); |
| 969 | return ret; |
| 970 | } |
| 971 | |
| 972 | static ssize_t iwl_dbgfs_traffic_log_write(struct file *file, |
| 973 | const char __user *user_buf, |
| 974 | size_t count, loff_t *ppos) |
| 975 | { |
| 976 | struct iwl_priv *priv = file->private_data; |
| 977 | char buf[8]; |
| 978 | int buf_size; |
| 979 | int traffic_log; |
| 980 | |
| 981 | memset(buf, 0, sizeof(buf)); |
| 982 | buf_size = min(count, sizeof(buf) - 1); |
| 983 | if (copy_from_user(buf, user_buf, buf_size)) |
| 984 | return -EFAULT; |
| 985 | if (sscanf(buf, "%d", &traffic_log) != 1) |
| 986 | return -EFAULT; |
| 987 | if (traffic_log == 0) |
| 988 | iwl_reset_traffic_log(priv); |
| 989 | |
| 990 | return count; |
| 991 | } |
| 992 | |
Wey-Yi Guy | 141b03e | 2009-08-07 15:41:41 -0700 | [diff] [blame] | 993 | static ssize_t iwl_dbgfs_tx_queue_read(struct file *file, |
| 994 | char __user *user_buf, |
| 995 | size_t count, loff_t *ppos) { |
| 996 | |
| 997 | struct iwl_priv *priv = (struct iwl_priv *)file->private_data; |
| 998 | struct iwl_tx_queue *txq; |
| 999 | struct iwl_queue *q; |
| 1000 | char *buf; |
| 1001 | int pos = 0; |
| 1002 | int cnt; |
| 1003 | int ret; |
Wey-Yi Guy | d23db55 | 2009-11-20 12:04:59 -0800 | [diff] [blame] | 1004 | 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] | 1005 | |
Wey-Yi Guy | 88804e2 | 2009-10-09 13:20:28 -0700 | [diff] [blame] | 1006 | if (!priv->txq) { |
| 1007 | IWL_ERR(priv, "txq not ready\n"); |
| 1008 | return -EAGAIN; |
| 1009 | } |
Wey-Yi Guy | 141b03e | 2009-08-07 15:41:41 -0700 | [diff] [blame] | 1010 | buf = kzalloc(bufsz, GFP_KERNEL); |
| 1011 | if (!buf) |
| 1012 | return -ENOMEM; |
| 1013 | |
| 1014 | for (cnt = 0; cnt < priv->hw_params.max_txq_num; cnt++) { |
| 1015 | txq = &priv->txq[cnt]; |
| 1016 | q = &txq->q; |
| 1017 | pos += scnprintf(buf + pos, bufsz - pos, |
| 1018 | "hwq %.2d: read=%u write=%u stop=%d" |
| 1019 | " swq_id=%#.2x (ac %d/hwq %d)\n", |
| 1020 | cnt, q->read_ptr, q->write_ptr, |
| 1021 | !!test_bit(cnt, priv->queue_stopped), |
| 1022 | txq->swq_id, |
| 1023 | txq->swq_id & 0x80 ? txq->swq_id & 3 : |
| 1024 | txq->swq_id, |
| 1025 | txq->swq_id & 0x80 ? (txq->swq_id >> 2) & |
| 1026 | 0x1f : txq->swq_id); |
| 1027 | if (cnt >= 4) |
| 1028 | continue; |
| 1029 | /* for the ACs, display the stop count too */ |
| 1030 | pos += scnprintf(buf + pos, bufsz - pos, |
| 1031 | " stop-count: %d\n", |
| 1032 | atomic_read(&priv->queue_stop_count[cnt])); |
| 1033 | } |
| 1034 | ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos); |
| 1035 | kfree(buf); |
| 1036 | return ret; |
| 1037 | } |
| 1038 | |
| 1039 | static ssize_t iwl_dbgfs_rx_queue_read(struct file *file, |
| 1040 | char __user *user_buf, |
| 1041 | size_t count, loff_t *ppos) { |
| 1042 | |
| 1043 | struct iwl_priv *priv = (struct iwl_priv *)file->private_data; |
| 1044 | struct iwl_rx_queue *rxq = &priv->rxq; |
| 1045 | char buf[256]; |
| 1046 | int pos = 0; |
| 1047 | const size_t bufsz = sizeof(buf); |
| 1048 | |
| 1049 | pos += scnprintf(buf + pos, bufsz - pos, "read: %u\n", |
| 1050 | rxq->read); |
| 1051 | pos += scnprintf(buf + pos, bufsz - pos, "write: %u\n", |
| 1052 | rxq->write); |
| 1053 | pos += scnprintf(buf + pos, bufsz - pos, "free_count: %u\n", |
| 1054 | rxq->free_count); |
| 1055 | pos += scnprintf(buf + pos, bufsz - pos, "closed_rb_num: %u\n", |
| 1056 | le16_to_cpu(rxq->rb_stts->closed_rb_num) & 0x0FFF); |
| 1057 | return simple_read_from_buffer(user_buf, count, ppos, buf, pos); |
| 1058 | } |
| 1059 | |
Wey-Yi Guy | e8fe59a | 2009-08-07 15:41:42 -0700 | [diff] [blame] | 1060 | static int iwl_dbgfs_statistics_flag(struct iwl_priv *priv, char *buf, |
| 1061 | int bufsz) |
| 1062 | { |
| 1063 | int p = 0; |
| 1064 | |
| 1065 | p += scnprintf(buf + p, bufsz - p, |
| 1066 | "Statistics Flag(0x%X):\n", |
| 1067 | le32_to_cpu(priv->statistics.flag)); |
| 1068 | if (le32_to_cpu(priv->statistics.flag) & UCODE_STATISTICS_CLEAR_MSK) |
| 1069 | p += scnprintf(buf + p, bufsz - p, |
| 1070 | "\tStatistics have been cleared\n"); |
| 1071 | p += scnprintf(buf + p, bufsz - p, |
| 1072 | "\tOperational Frequency: %s\n", |
| 1073 | (le32_to_cpu(priv->statistics.flag) & |
| 1074 | UCODE_STATISTICS_FREQUENCY_MSK) |
| 1075 | ? "2.4 GHz" : "5.2 GHz"); |
| 1076 | p += scnprintf(buf + p, bufsz - p, |
| 1077 | "\tTGj Narrow Band: %s\n", |
| 1078 | (le32_to_cpu(priv->statistics.flag) & |
| 1079 | UCODE_STATISTICS_NARROW_BAND_MSK) |
| 1080 | ? "enabled" : "disabled"); |
| 1081 | return p; |
| 1082 | } |
| 1083 | |
| 1084 | |
| 1085 | static ssize_t iwl_dbgfs_ucode_rx_stats_read(struct file *file, |
| 1086 | char __user *user_buf, |
| 1087 | size_t count, loff_t *ppos) |
| 1088 | { |
| 1089 | struct iwl_priv *priv = (struct iwl_priv *)file->private_data; |
| 1090 | int pos = 0; |
| 1091 | char *buf; |
| 1092 | int bufsz = sizeof(struct statistics_rx_phy) * 20 + |
| 1093 | sizeof(struct statistics_rx_non_phy) * 20 + |
| 1094 | sizeof(struct statistics_rx_ht_phy) * 20 + 400; |
| 1095 | ssize_t ret; |
Wey-Yi Guy | 92a35bd | 2009-10-09 13:20:29 -0700 | [diff] [blame] | 1096 | struct statistics_rx_phy *ofdm, *accum_ofdm; |
| 1097 | struct statistics_rx_phy *cck, *accum_cck; |
| 1098 | struct statistics_rx_non_phy *general, *accum_general; |
| 1099 | struct statistics_rx_ht_phy *ht, *accum_ht; |
Wey-Yi Guy | e8fe59a | 2009-08-07 15:41:42 -0700 | [diff] [blame] | 1100 | |
| 1101 | if (!iwl_is_alive(priv)) |
| 1102 | return -EAGAIN; |
| 1103 | |
| 1104 | /* make request to uCode to retrieve statistics information */ |
| 1105 | mutex_lock(&priv->mutex); |
Wey-Yi Guy | ef8d552 | 2009-11-13 11:56:28 -0800 | [diff] [blame] | 1106 | ret = iwl_send_statistics_request(priv, CMD_SYNC, false); |
Wey-Yi Guy | e8fe59a | 2009-08-07 15:41:42 -0700 | [diff] [blame] | 1107 | mutex_unlock(&priv->mutex); |
| 1108 | |
| 1109 | if (ret) { |
| 1110 | IWL_ERR(priv, |
| 1111 | "Error sending statistics request: %zd\n", ret); |
| 1112 | return -EAGAIN; |
| 1113 | } |
| 1114 | buf = kzalloc(bufsz, GFP_KERNEL); |
| 1115 | if (!buf) { |
| 1116 | IWL_ERR(priv, "Can not allocate Buffer\n"); |
| 1117 | return -ENOMEM; |
| 1118 | } |
| 1119 | |
| 1120 | /* the statistic information display here is based on |
| 1121 | * the last statistics notification from uCode |
| 1122 | * might not reflect the current uCode activity |
| 1123 | */ |
| 1124 | ofdm = &priv->statistics.rx.ofdm; |
| 1125 | cck = &priv->statistics.rx.cck; |
| 1126 | general = &priv->statistics.rx.general; |
| 1127 | ht = &priv->statistics.rx.ofdm_ht; |
Wey-Yi Guy | 92a35bd | 2009-10-09 13:20:29 -0700 | [diff] [blame] | 1128 | accum_ofdm = &priv->accum_statistics.rx.ofdm; |
| 1129 | accum_cck = &priv->accum_statistics.rx.cck; |
| 1130 | accum_general = &priv->accum_statistics.rx.general; |
| 1131 | accum_ht = &priv->accum_statistics.rx.ofdm_ht; |
Wey-Yi Guy | e8fe59a | 2009-08-07 15:41:42 -0700 | [diff] [blame] | 1132 | pos += iwl_dbgfs_statistics_flag(priv, buf, bufsz); |
| 1133 | pos += scnprintf(buf + pos, bufsz - pos, "Statistics_Rx - OFDM:\n"); |
Wey-Yi Guy | e8fe59a | 2009-08-07 15:41:42 -0700 | [diff] [blame] | 1134 | pos += scnprintf(buf + pos, bufsz - pos, |
Wey-Yi Guy | 92a35bd | 2009-10-09 13:20:29 -0700 | [diff] [blame] | 1135 | "\t\t\tcurrent\t\t\taccumulative\n"); |
| 1136 | pos += scnprintf(buf + pos, bufsz - pos, "ina_cnt:\t\t%u\t\t\t%u\n", |
| 1137 | le32_to_cpu(ofdm->ina_cnt), accum_ofdm->ina_cnt); |
| 1138 | pos += scnprintf(buf + pos, bufsz - pos, "fina_cnt:\t\t%u\t\t\t%u\n", |
| 1139 | le32_to_cpu(ofdm->fina_cnt), accum_ofdm->fina_cnt); |
| 1140 | pos += scnprintf(buf + pos, bufsz - pos, "plcp_err:\t\t%u\t\t\t%u\n", |
| 1141 | le32_to_cpu(ofdm->plcp_err), accum_ofdm->plcp_err); |
| 1142 | pos += scnprintf(buf + pos, bufsz - pos, "crc32_err:\t\t%u\t\t\t%u\n", |
| 1143 | le32_to_cpu(ofdm->crc32_err), accum_ofdm->crc32_err); |
| 1144 | pos += scnprintf(buf + pos, bufsz - pos, |
| 1145 | "overrun_err:\t\t%u\t\t\t%u\n", |
| 1146 | le32_to_cpu(ofdm->overrun_err), |
| 1147 | accum_ofdm->overrun_err); |
| 1148 | pos += scnprintf(buf + pos, bufsz - pos, |
| 1149 | "early_overrun_err:\t%u\t\t\t%u\n", |
| 1150 | le32_to_cpu(ofdm->early_overrun_err), |
| 1151 | accum_ofdm->early_overrun_err); |
| 1152 | pos += scnprintf(buf + pos, bufsz - pos, "crc32_good:\t\t%u\t\t\t%u\n", |
| 1153 | le32_to_cpu(ofdm->crc32_good), |
| 1154 | accum_ofdm->crc32_good); |
| 1155 | pos += scnprintf(buf + pos, bufsz - pos, |
| 1156 | "false_alarm_cnt:\t%u\t\t\t%u\n", |
| 1157 | le32_to_cpu(ofdm->false_alarm_cnt), |
| 1158 | accum_ofdm->false_alarm_cnt); |
| 1159 | pos += scnprintf(buf + pos, bufsz - pos, |
| 1160 | "fina_sync_err_cnt:\t%u\t\t\t%u\n", |
| 1161 | le32_to_cpu(ofdm->fina_sync_err_cnt), |
| 1162 | accum_ofdm->fina_sync_err_cnt); |
| 1163 | pos += scnprintf(buf + pos, bufsz - pos, |
| 1164 | "sfd_timeout:\t\t%u\t\t\t%u\n", |
| 1165 | le32_to_cpu(ofdm->sfd_timeout), |
| 1166 | accum_ofdm->sfd_timeout); |
| 1167 | pos += scnprintf(buf + pos, bufsz - pos, |
| 1168 | "fina_timeout:\t\t%u\t\t\t%u\n", |
| 1169 | le32_to_cpu(ofdm->fina_timeout), |
| 1170 | accum_ofdm->fina_timeout); |
| 1171 | pos += scnprintf(buf + pos, bufsz - pos, |
| 1172 | "unresponded_rts:\t%u\t\t\t%u\n", |
| 1173 | le32_to_cpu(ofdm->unresponded_rts), |
| 1174 | accum_ofdm->unresponded_rts); |
| 1175 | pos += scnprintf(buf + pos, bufsz - pos, |
| 1176 | "rxe_frame_lmt_ovrun:\t%u\t\t\t%u\n", |
| 1177 | le32_to_cpu(ofdm->rxe_frame_limit_overrun), |
| 1178 | accum_ofdm->rxe_frame_limit_overrun); |
| 1179 | pos += scnprintf(buf + pos, bufsz - pos, |
| 1180 | "sent_ack_cnt:\t\t%u\t\t\t%u\n", |
| 1181 | le32_to_cpu(ofdm->sent_ack_cnt), |
| 1182 | accum_ofdm->sent_ack_cnt); |
| 1183 | pos += scnprintf(buf + pos, bufsz - pos, |
| 1184 | "sent_cts_cnt:\t\t%u\t\t\t%u\n", |
| 1185 | le32_to_cpu(ofdm->sent_cts_cnt), |
| 1186 | accum_ofdm->sent_cts_cnt); |
| 1187 | pos += scnprintf(buf + pos, bufsz - pos, |
| 1188 | "sent_ba_rsp_cnt:\t%u\t\t\t%u\n", |
| 1189 | le32_to_cpu(ofdm->sent_ba_rsp_cnt), |
| 1190 | accum_ofdm->sent_ba_rsp_cnt); |
| 1191 | pos += scnprintf(buf + pos, bufsz - pos, |
| 1192 | "dsp_self_kill:\t\t%u\t\t\t%u\n", |
| 1193 | le32_to_cpu(ofdm->dsp_self_kill), |
| 1194 | accum_ofdm->dsp_self_kill); |
| 1195 | pos += scnprintf(buf + pos, bufsz - pos, |
| 1196 | "mh_format_err:\t\t%u\t\t\t%u\n", |
| 1197 | le32_to_cpu(ofdm->mh_format_err), |
| 1198 | accum_ofdm->mh_format_err); |
| 1199 | pos += scnprintf(buf + pos, bufsz - pos, |
| 1200 | "re_acq_main_rssi_sum:\t%u\t\t\t%u\n", |
| 1201 | le32_to_cpu(ofdm->re_acq_main_rssi_sum), |
| 1202 | accum_ofdm->re_acq_main_rssi_sum); |
Wey-Yi Guy | e8fe59a | 2009-08-07 15:41:42 -0700 | [diff] [blame] | 1203 | |
| 1204 | pos += scnprintf(buf + pos, bufsz - pos, "Statistics_Rx - CCK:\n"); |
Wey-Yi Guy | e8fe59a | 2009-08-07 15:41:42 -0700 | [diff] [blame] | 1205 | pos += scnprintf(buf + pos, bufsz - pos, |
Wey-Yi Guy | 92a35bd | 2009-10-09 13:20:29 -0700 | [diff] [blame] | 1206 | "\t\t\tcurrent\t\t\taccumulative\n"); |
| 1207 | pos += scnprintf(buf + pos, bufsz - pos, "ina_cnt:\t\t%u\t\t\t%u\n", |
| 1208 | le32_to_cpu(cck->ina_cnt), accum_cck->ina_cnt); |
| 1209 | pos += scnprintf(buf + pos, bufsz - pos, "fina_cnt:\t\t%u\t\t\t%u\n", |
| 1210 | le32_to_cpu(cck->fina_cnt), accum_cck->fina_cnt); |
| 1211 | pos += scnprintf(buf + pos, bufsz - pos, "plcp_err:\t\t%u\t\t\t%u\n", |
| 1212 | le32_to_cpu(cck->plcp_err), accum_cck->plcp_err); |
| 1213 | pos += scnprintf(buf + pos, bufsz - pos, "crc32_err:\t\t%u\t\t\t%u\n", |
| 1214 | le32_to_cpu(cck->crc32_err), accum_cck->crc32_err); |
| 1215 | pos += scnprintf(buf + pos, bufsz - pos, |
| 1216 | "overrun_err:\t\t%u\t\t\t%u\n", |
| 1217 | le32_to_cpu(cck->overrun_err), |
| 1218 | accum_cck->overrun_err); |
| 1219 | pos += scnprintf(buf + pos, bufsz - pos, |
| 1220 | "early_overrun_err:\t%u\t\t\t%u\n", |
| 1221 | le32_to_cpu(cck->early_overrun_err), |
| 1222 | accum_cck->early_overrun_err); |
| 1223 | pos += scnprintf(buf + pos, bufsz - pos, "crc32_good:\t\t%u\t\t\t%u\n", |
| 1224 | le32_to_cpu(cck->crc32_good), accum_cck->crc32_good); |
| 1225 | pos += scnprintf(buf + pos, bufsz - pos, |
| 1226 | "false_alarm_cnt:\t%u\t\t\t%u\n", |
| 1227 | le32_to_cpu(cck->false_alarm_cnt), |
| 1228 | accum_cck->false_alarm_cnt); |
| 1229 | pos += scnprintf(buf + pos, bufsz - pos, |
| 1230 | "fina_sync_err_cnt:\t%u\t\t\t%u\n", |
| 1231 | le32_to_cpu(cck->fina_sync_err_cnt), |
| 1232 | accum_cck->fina_sync_err_cnt); |
| 1233 | pos += scnprintf(buf + pos, bufsz - pos, |
| 1234 | "sfd_timeout:\t\t%u\t\t\t%u\n", |
| 1235 | le32_to_cpu(cck->sfd_timeout), |
| 1236 | accum_cck->sfd_timeout); |
| 1237 | pos += scnprintf(buf + pos, bufsz - pos, |
| 1238 | "fina_timeout:\t\t%u\t\t\t%u\n", |
| 1239 | le32_to_cpu(cck->fina_timeout), |
| 1240 | accum_cck->fina_timeout); |
| 1241 | pos += scnprintf(buf + pos, bufsz - pos, |
| 1242 | "unresponded_rts:\t%u\t\t\t%u\n", |
| 1243 | le32_to_cpu(cck->unresponded_rts), |
| 1244 | accum_cck->unresponded_rts); |
| 1245 | pos += scnprintf(buf + pos, bufsz - pos, |
| 1246 | "rxe_frame_lmt_ovrun:\t%u\t\t\t%u\n", |
| 1247 | le32_to_cpu(cck->rxe_frame_limit_overrun), |
| 1248 | accum_cck->rxe_frame_limit_overrun); |
| 1249 | pos += scnprintf(buf + pos, bufsz - pos, |
| 1250 | "sent_ack_cnt:\t\t%u\t\t\t%u\n", |
| 1251 | le32_to_cpu(cck->sent_ack_cnt), |
| 1252 | accum_cck->sent_ack_cnt); |
| 1253 | pos += scnprintf(buf + pos, bufsz - pos, |
| 1254 | "sent_cts_cnt:\t\t%u\t\t\t%u\n", |
| 1255 | le32_to_cpu(cck->sent_cts_cnt), |
| 1256 | accum_cck->sent_cts_cnt); |
| 1257 | pos += scnprintf(buf + pos, bufsz - pos, |
| 1258 | "sent_ba_rsp_cnt:\t%u\t\t\t%u\n", |
| 1259 | le32_to_cpu(cck->sent_ba_rsp_cnt), |
| 1260 | accum_cck->sent_ba_rsp_cnt); |
| 1261 | pos += scnprintf(buf + pos, bufsz - pos, |
| 1262 | "dsp_self_kill:\t\t%u\t\t\t%u\n", |
| 1263 | le32_to_cpu(cck->dsp_self_kill), |
| 1264 | accum_cck->dsp_self_kill); |
| 1265 | pos += scnprintf(buf + pos, bufsz - pos, |
| 1266 | "mh_format_err:\t\t%u\t\t\t%u\n", |
| 1267 | le32_to_cpu(cck->mh_format_err), |
| 1268 | accum_cck->mh_format_err); |
| 1269 | pos += scnprintf(buf + pos, bufsz - pos, |
| 1270 | "re_acq_main_rssi_sum:\t%u\t\t\t%u\n", |
| 1271 | le32_to_cpu(cck->re_acq_main_rssi_sum), |
| 1272 | accum_cck->re_acq_main_rssi_sum); |
Wey-Yi Guy | e8fe59a | 2009-08-07 15:41:42 -0700 | [diff] [blame] | 1273 | |
| 1274 | pos += scnprintf(buf + pos, bufsz - pos, "Statistics_Rx - GENERAL:\n"); |
Wey-Yi Guy | e8fe59a | 2009-08-07 15:41:42 -0700 | [diff] [blame] | 1275 | pos += scnprintf(buf + pos, bufsz - pos, |
Wey-Yi Guy | 92a35bd | 2009-10-09 13:20:29 -0700 | [diff] [blame] | 1276 | "\t\t\tcurrent\t\t\taccumulative\n"); |
| 1277 | pos += scnprintf(buf + pos, bufsz - pos, "bogus_cts:\t\t%u\t\t\t%u\n", |
| 1278 | le32_to_cpu(general->bogus_cts), |
| 1279 | accum_general->bogus_cts); |
| 1280 | pos += scnprintf(buf + pos, bufsz - pos, "bogus_ack:\t\t%u\t\t\t%u\n", |
| 1281 | le32_to_cpu(general->bogus_ack), |
| 1282 | accum_general->bogus_ack); |
Wey-Yi Guy | e8fe59a | 2009-08-07 15:41:42 -0700 | [diff] [blame] | 1283 | pos += scnprintf(buf + pos, bufsz - pos, |
Wey-Yi Guy | 92a35bd | 2009-10-09 13:20:29 -0700 | [diff] [blame] | 1284 | "non_bssid_frames:\t%u\t\t\t%u\n", |
| 1285 | le32_to_cpu(general->non_bssid_frames), |
| 1286 | accum_general->non_bssid_frames); |
Wey-Yi Guy | e8fe59a | 2009-08-07 15:41:42 -0700 | [diff] [blame] | 1287 | pos += scnprintf(buf + pos, bufsz - pos, |
Wey-Yi Guy | 92a35bd | 2009-10-09 13:20:29 -0700 | [diff] [blame] | 1288 | "filtered_frames:\t%u\t\t\t%u\n", |
| 1289 | le32_to_cpu(general->filtered_frames), |
| 1290 | accum_general->filtered_frames); |
| 1291 | pos += scnprintf(buf + pos, bufsz - pos, |
| 1292 | "non_channel_beacons:\t%u\t\t\t%u\n", |
| 1293 | le32_to_cpu(general->non_channel_beacons), |
| 1294 | accum_general->non_channel_beacons); |
| 1295 | pos += scnprintf(buf + pos, bufsz - pos, |
| 1296 | "channel_beacons:\t%u\t\t\t%u\n", |
| 1297 | le32_to_cpu(general->channel_beacons), |
| 1298 | accum_general->channel_beacons); |
| 1299 | pos += scnprintf(buf + pos, bufsz - pos, |
| 1300 | "num_missed_bcon:\t%u\t\t\t%u\n", |
| 1301 | le32_to_cpu(general->num_missed_bcon), |
| 1302 | accum_general->num_missed_bcon); |
| 1303 | pos += scnprintf(buf + pos, bufsz - pos, |
| 1304 | "adc_rx_saturation_time:\t%u\t\t\t%u\n", |
| 1305 | le32_to_cpu(general->adc_rx_saturation_time), |
| 1306 | accum_general->adc_rx_saturation_time); |
| 1307 | pos += scnprintf(buf + pos, bufsz - pos, |
| 1308 | "ina_detect_search_tm:\t%u\t\t\t%u\n", |
| 1309 | le32_to_cpu(general->ina_detection_search_time), |
| 1310 | accum_general->ina_detection_search_time); |
| 1311 | pos += scnprintf(buf + pos, bufsz - pos, |
| 1312 | "beacon_silence_rssi_a:\t%u\t\t\t%u\n", |
| 1313 | le32_to_cpu(general->beacon_silence_rssi_a), |
| 1314 | accum_general->beacon_silence_rssi_a); |
| 1315 | pos += scnprintf(buf + pos, bufsz - pos, |
| 1316 | "beacon_silence_rssi_b:\t%u\t\t\t%u\n", |
| 1317 | le32_to_cpu(general->beacon_silence_rssi_b), |
| 1318 | accum_general->beacon_silence_rssi_b); |
| 1319 | pos += scnprintf(buf + pos, bufsz - pos, |
| 1320 | "beacon_silence_rssi_c:\t%u\t\t\t%u\n", |
| 1321 | le32_to_cpu(general->beacon_silence_rssi_c), |
| 1322 | accum_general->beacon_silence_rssi_c); |
| 1323 | pos += scnprintf(buf + pos, bufsz - pos, |
| 1324 | "interference_data_flag:\t%u\t\t\t%u\n", |
| 1325 | le32_to_cpu(general->interference_data_flag), |
| 1326 | accum_general->interference_data_flag); |
| 1327 | pos += scnprintf(buf + pos, bufsz - pos, |
| 1328 | "channel_load:\t\t%u\t\t\t%u\n", |
| 1329 | le32_to_cpu(general->channel_load), |
| 1330 | accum_general->channel_load); |
| 1331 | pos += scnprintf(buf + pos, bufsz - pos, |
| 1332 | "dsp_false_alarms:\t%u\t\t\t%u\n", |
| 1333 | le32_to_cpu(general->dsp_false_alarms), |
| 1334 | accum_general->dsp_false_alarms); |
| 1335 | pos += scnprintf(buf + pos, bufsz - pos, |
| 1336 | "beacon_rssi_a:\t\t%u\t\t\t%u\n", |
| 1337 | le32_to_cpu(general->beacon_rssi_a), |
| 1338 | accum_general->beacon_rssi_a); |
| 1339 | pos += scnprintf(buf + pos, bufsz - pos, |
| 1340 | "beacon_rssi_b:\t\t%u\t\t\t%u\n", |
| 1341 | le32_to_cpu(general->beacon_rssi_b), |
| 1342 | accum_general->beacon_rssi_b); |
| 1343 | pos += scnprintf(buf + pos, bufsz - pos, |
| 1344 | "beacon_rssi_c:\t\t%u\t\t\t%u\n", |
| 1345 | le32_to_cpu(general->beacon_rssi_c), |
| 1346 | accum_general->beacon_rssi_c); |
| 1347 | pos += scnprintf(buf + pos, bufsz - pos, |
| 1348 | "beacon_energy_a:\t%u\t\t\t%u\n", |
| 1349 | le32_to_cpu(general->beacon_energy_a), |
| 1350 | accum_general->beacon_energy_a); |
| 1351 | pos += scnprintf(buf + pos, bufsz - pos, |
| 1352 | "beacon_energy_b:\t%u\t\t\t%u\n", |
| 1353 | le32_to_cpu(general->beacon_energy_b), |
| 1354 | accum_general->beacon_energy_b); |
| 1355 | pos += scnprintf(buf + pos, bufsz - pos, |
| 1356 | "beacon_energy_c:\t%u\t\t\t%u\n", |
| 1357 | le32_to_cpu(general->beacon_energy_c), |
| 1358 | accum_general->beacon_energy_c); |
Wey-Yi Guy | e8fe59a | 2009-08-07 15:41:42 -0700 | [diff] [blame] | 1359 | |
| 1360 | pos += scnprintf(buf + pos, bufsz - pos, "Statistics_Rx - OFDM_HT:\n"); |
Wey-Yi Guy | 92a35bd | 2009-10-09 13:20:29 -0700 | [diff] [blame] | 1361 | pos += scnprintf(buf + pos, bufsz - pos, |
| 1362 | "\t\t\tcurrent\t\t\taccumulative\n"); |
| 1363 | pos += scnprintf(buf + pos, bufsz - pos, "plcp_err:\t\t%u\t\t\t%u\n", |
| 1364 | le32_to_cpu(ht->plcp_err), accum_ht->plcp_err); |
| 1365 | pos += scnprintf(buf + pos, bufsz - pos, |
| 1366 | "overrun_err:\t\t%u\t\t\t%u\n", |
| 1367 | le32_to_cpu(ht->overrun_err), accum_ht->overrun_err); |
| 1368 | pos += scnprintf(buf + pos, bufsz - pos, |
| 1369 | "early_overrun_err:\t%u\t\t\t%u\n", |
| 1370 | le32_to_cpu(ht->early_overrun_err), |
| 1371 | accum_ht->early_overrun_err); |
| 1372 | pos += scnprintf(buf + pos, bufsz - pos, "crc32_good:\t\t%u\t\t\t%u\n", |
| 1373 | le32_to_cpu(ht->crc32_good), accum_ht->crc32_good); |
| 1374 | pos += scnprintf(buf + pos, bufsz - pos, "crc32_err:\t\t%u\t\t\t%u\n", |
| 1375 | le32_to_cpu(ht->crc32_err), accum_ht->crc32_err); |
| 1376 | pos += scnprintf(buf + pos, bufsz - pos, |
| 1377 | "mh_format_err:\t\t%u\t\t\t%u\n", |
| 1378 | le32_to_cpu(ht->mh_format_err), |
| 1379 | accum_ht->mh_format_err); |
| 1380 | pos += scnprintf(buf + pos, bufsz - pos, |
| 1381 | "agg_crc32_good:\t\t%u\t\t\t%u\n", |
| 1382 | le32_to_cpu(ht->agg_crc32_good), |
| 1383 | accum_ht->agg_crc32_good); |
| 1384 | pos += scnprintf(buf + pos, bufsz - pos, |
| 1385 | "agg_mpdu_cnt:\t\t%u\t\t\t%u\n", |
| 1386 | le32_to_cpu(ht->agg_mpdu_cnt), |
| 1387 | accum_ht->agg_mpdu_cnt); |
| 1388 | pos += scnprintf(buf + pos, bufsz - pos, "agg_cnt:\t\t%u\t\t\t%u\n", |
| 1389 | le32_to_cpu(ht->agg_cnt), accum_ht->agg_cnt); |
Wey-Yi Guy | f0118a4 | 2010-01-08 10:04:42 -0800 | [diff] [blame^] | 1390 | pos += scnprintf(buf + pos, bufsz - pos, "unsupport_mcs:\t\t%u\t\t\t%u\n", |
| 1391 | le32_to_cpu(ht->unsupport_mcs), |
| 1392 | accum_ht->unsupport_mcs); |
Wey-Yi Guy | e8fe59a | 2009-08-07 15:41:42 -0700 | [diff] [blame] | 1393 | |
| 1394 | ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos); |
| 1395 | kfree(buf); |
| 1396 | return ret; |
| 1397 | } |
| 1398 | |
| 1399 | static ssize_t iwl_dbgfs_ucode_tx_stats_read(struct file *file, |
| 1400 | char __user *user_buf, |
| 1401 | size_t count, loff_t *ppos) |
| 1402 | { |
| 1403 | struct iwl_priv *priv = (struct iwl_priv *)file->private_data; |
| 1404 | int pos = 0; |
| 1405 | char *buf; |
| 1406 | int bufsz = (sizeof(struct statistics_tx) * 24) + 250; |
| 1407 | ssize_t ret; |
Wey-Yi Guy | 92a35bd | 2009-10-09 13:20:29 -0700 | [diff] [blame] | 1408 | struct statistics_tx *tx, *accum_tx; |
Wey-Yi Guy | e8fe59a | 2009-08-07 15:41:42 -0700 | [diff] [blame] | 1409 | |
| 1410 | if (!iwl_is_alive(priv)) |
| 1411 | return -EAGAIN; |
| 1412 | |
| 1413 | /* make request to uCode to retrieve statistics information */ |
| 1414 | mutex_lock(&priv->mutex); |
Wey-Yi Guy | ef8d552 | 2009-11-13 11:56:28 -0800 | [diff] [blame] | 1415 | ret = iwl_send_statistics_request(priv, CMD_SYNC, false); |
Wey-Yi Guy | e8fe59a | 2009-08-07 15:41:42 -0700 | [diff] [blame] | 1416 | mutex_unlock(&priv->mutex); |
| 1417 | |
| 1418 | if (ret) { |
| 1419 | IWL_ERR(priv, |
| 1420 | "Error sending statistics request: %zd\n", ret); |
| 1421 | return -EAGAIN; |
| 1422 | } |
| 1423 | buf = kzalloc(bufsz, GFP_KERNEL); |
| 1424 | if (!buf) { |
| 1425 | IWL_ERR(priv, "Can not allocate Buffer\n"); |
| 1426 | return -ENOMEM; |
| 1427 | } |
| 1428 | |
| 1429 | /* the statistic information display here is based on |
| 1430 | * the last statistics notification from uCode |
| 1431 | * might not reflect the current uCode activity |
| 1432 | */ |
| 1433 | tx = &priv->statistics.tx; |
Wey-Yi Guy | 92a35bd | 2009-10-09 13:20:29 -0700 | [diff] [blame] | 1434 | accum_tx = &priv->accum_statistics.tx; |
Wey-Yi Guy | e8fe59a | 2009-08-07 15:41:42 -0700 | [diff] [blame] | 1435 | pos += iwl_dbgfs_statistics_flag(priv, buf, bufsz); |
| 1436 | pos += scnprintf(buf + pos, bufsz - pos, "Statistics_Tx:\n"); |
Wey-Yi Guy | e8fe59a | 2009-08-07 15:41:42 -0700 | [diff] [blame] | 1437 | pos += scnprintf(buf + pos, bufsz - pos, |
Wey-Yi Guy | 92a35bd | 2009-10-09 13:20:29 -0700 | [diff] [blame] | 1438 | "\t\t\tcurrent\t\t\taccumulative\n"); |
| 1439 | pos += scnprintf(buf + pos, bufsz - pos, "preamble:\t\t\t%u\t\t\t%u\n", |
| 1440 | le32_to_cpu(tx->preamble_cnt), |
| 1441 | accum_tx->preamble_cnt); |
Wey-Yi Guy | e8fe59a | 2009-08-07 15:41:42 -0700 | [diff] [blame] | 1442 | pos += scnprintf(buf + pos, bufsz - pos, |
Wey-Yi Guy | 92a35bd | 2009-10-09 13:20:29 -0700 | [diff] [blame] | 1443 | "rx_detected_cnt:\t\t%u\t\t\t%u\n", |
| 1444 | le32_to_cpu(tx->rx_detected_cnt), |
| 1445 | accum_tx->rx_detected_cnt); |
Wey-Yi Guy | e8fe59a | 2009-08-07 15:41:42 -0700 | [diff] [blame] | 1446 | pos += scnprintf(buf + pos, bufsz - pos, |
Wey-Yi Guy | 92a35bd | 2009-10-09 13:20:29 -0700 | [diff] [blame] | 1447 | "bt_prio_defer_cnt:\t\t%u\t\t\t%u\n", |
| 1448 | le32_to_cpu(tx->bt_prio_defer_cnt), |
| 1449 | accum_tx->bt_prio_defer_cnt); |
Wey-Yi Guy | e8fe59a | 2009-08-07 15:41:42 -0700 | [diff] [blame] | 1450 | pos += scnprintf(buf + pos, bufsz - pos, |
Wey-Yi Guy | 92a35bd | 2009-10-09 13:20:29 -0700 | [diff] [blame] | 1451 | "bt_prio_kill_cnt:\t\t%u\t\t\t%u\n", |
| 1452 | le32_to_cpu(tx->bt_prio_kill_cnt), |
| 1453 | accum_tx->bt_prio_kill_cnt); |
Wey-Yi Guy | e8fe59a | 2009-08-07 15:41:42 -0700 | [diff] [blame] | 1454 | pos += scnprintf(buf + pos, bufsz - pos, |
Wey-Yi Guy | 92a35bd | 2009-10-09 13:20:29 -0700 | [diff] [blame] | 1455 | "few_bytes_cnt:\t\t\t%u\t\t\t%u\n", |
| 1456 | le32_to_cpu(tx->few_bytes_cnt), |
| 1457 | accum_tx->few_bytes_cnt); |
Wey-Yi Guy | e8fe59a | 2009-08-07 15:41:42 -0700 | [diff] [blame] | 1458 | pos += scnprintf(buf + pos, bufsz - pos, |
Wey-Yi Guy | 92a35bd | 2009-10-09 13:20:29 -0700 | [diff] [blame] | 1459 | "cts_timeout:\t\t\t%u\t\t\t%u\n", |
| 1460 | le32_to_cpu(tx->cts_timeout), accum_tx->cts_timeout); |
| 1461 | pos += scnprintf(buf + pos, bufsz - pos, |
| 1462 | "ack_timeout:\t\t\t%u\t\t\t%u\n", |
| 1463 | le32_to_cpu(tx->ack_timeout), |
| 1464 | accum_tx->ack_timeout); |
| 1465 | pos += scnprintf(buf + pos, bufsz - pos, |
| 1466 | "expected_ack_cnt:\t\t%u\t\t\t%u\n", |
| 1467 | le32_to_cpu(tx->expected_ack_cnt), |
| 1468 | accum_tx->expected_ack_cnt); |
| 1469 | pos += scnprintf(buf + pos, bufsz - pos, |
| 1470 | "actual_ack_cnt:\t\t\t%u\t\t\t%u\n", |
| 1471 | le32_to_cpu(tx->actual_ack_cnt), |
| 1472 | accum_tx->actual_ack_cnt); |
| 1473 | pos += scnprintf(buf + pos, bufsz - pos, |
| 1474 | "dump_msdu_cnt:\t\t\t%u\t\t\t%u\n", |
| 1475 | le32_to_cpu(tx->dump_msdu_cnt), |
| 1476 | accum_tx->dump_msdu_cnt); |
| 1477 | pos += scnprintf(buf + pos, bufsz - pos, |
| 1478 | "abort_nxt_frame_mismatch:" |
| 1479 | "\t%u\t\t\t%u\n", |
| 1480 | le32_to_cpu(tx->burst_abort_next_frame_mismatch_cnt), |
| 1481 | accum_tx->burst_abort_next_frame_mismatch_cnt); |
| 1482 | pos += scnprintf(buf + pos, bufsz - pos, |
| 1483 | "abort_missing_nxt_frame:" |
| 1484 | "\t%u\t\t\t%u\n", |
| 1485 | le32_to_cpu(tx->burst_abort_missing_next_frame_cnt), |
| 1486 | accum_tx->burst_abort_missing_next_frame_cnt); |
| 1487 | pos += scnprintf(buf + pos, bufsz - pos, |
| 1488 | "cts_timeout_collision:\t\t%u\t\t\t%u\n", |
| 1489 | le32_to_cpu(tx->cts_timeout_collision), |
| 1490 | accum_tx->cts_timeout_collision); |
| 1491 | pos += scnprintf(buf + pos, bufsz - pos, |
| 1492 | "ack_ba_timeout_collision:\t%u\t\t\t%u\n", |
| 1493 | le32_to_cpu(tx->ack_or_ba_timeout_collision), |
| 1494 | accum_tx->ack_or_ba_timeout_collision); |
| 1495 | pos += scnprintf(buf + pos, bufsz - pos, |
| 1496 | "agg ba_timeout:\t\t\t%u\t\t\t%u\n", |
| 1497 | le32_to_cpu(tx->agg.ba_timeout), |
| 1498 | accum_tx->agg.ba_timeout); |
| 1499 | pos += scnprintf(buf + pos, bufsz - pos, |
| 1500 | "agg ba_resched_frames:\t\t%u\t\t\t%u\n", |
| 1501 | le32_to_cpu(tx->agg.ba_reschedule_frames), |
| 1502 | accum_tx->agg.ba_reschedule_frames); |
| 1503 | pos += scnprintf(buf + pos, bufsz - pos, |
| 1504 | "agg scd_query_agg_frame:\t%u\t\t\t%u\n", |
| 1505 | le32_to_cpu(tx->agg.scd_query_agg_frame_cnt), |
| 1506 | accum_tx->agg.scd_query_agg_frame_cnt); |
| 1507 | pos += scnprintf(buf + pos, bufsz - pos, |
| 1508 | "agg scd_query_no_agg:\t\t%u\t\t\t%u\n", |
| 1509 | le32_to_cpu(tx->agg.scd_query_no_agg), |
| 1510 | accum_tx->agg.scd_query_no_agg); |
| 1511 | pos += scnprintf(buf + pos, bufsz - pos, |
| 1512 | "agg scd_query_agg:\t\t%u\t\t\t%u\n", |
| 1513 | le32_to_cpu(tx->agg.scd_query_agg), |
| 1514 | accum_tx->agg.scd_query_agg); |
| 1515 | pos += scnprintf(buf + pos, bufsz - pos, |
| 1516 | "agg scd_query_mismatch:\t\t%u\t\t\t%u\n", |
| 1517 | le32_to_cpu(tx->agg.scd_query_mismatch), |
| 1518 | accum_tx->agg.scd_query_mismatch); |
| 1519 | pos += scnprintf(buf + pos, bufsz - pos, |
| 1520 | "agg frame_not_ready:\t\t%u\t\t\t%u\n", |
| 1521 | le32_to_cpu(tx->agg.frame_not_ready), |
| 1522 | accum_tx->agg.frame_not_ready); |
| 1523 | pos += scnprintf(buf + pos, bufsz - pos, |
| 1524 | "agg underrun:\t\t\t%u\t\t\t%u\n", |
| 1525 | le32_to_cpu(tx->agg.underrun), |
| 1526 | accum_tx->agg.underrun); |
| 1527 | pos += scnprintf(buf + pos, bufsz - pos, |
| 1528 | "agg bt_prio_kill:\t\t%u\t\t\t%u\n", |
| 1529 | le32_to_cpu(tx->agg.bt_prio_kill), |
| 1530 | accum_tx->agg.bt_prio_kill); |
| 1531 | pos += scnprintf(buf + pos, bufsz - pos, |
| 1532 | "agg rx_ba_rsp_cnt:\t\t%u\t\t\t%u\n", |
| 1533 | le32_to_cpu(tx->agg.rx_ba_rsp_cnt), |
| 1534 | accum_tx->agg.rx_ba_rsp_cnt); |
Wey-Yi Guy | e8fe59a | 2009-08-07 15:41:42 -0700 | [diff] [blame] | 1535 | |
| 1536 | ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos); |
| 1537 | kfree(buf); |
| 1538 | return ret; |
| 1539 | } |
| 1540 | |
| 1541 | static ssize_t iwl_dbgfs_ucode_general_stats_read(struct file *file, |
| 1542 | char __user *user_buf, |
| 1543 | size_t count, loff_t *ppos) |
| 1544 | { |
| 1545 | struct iwl_priv *priv = (struct iwl_priv *)file->private_data; |
| 1546 | int pos = 0; |
| 1547 | char *buf; |
| 1548 | int bufsz = sizeof(struct statistics_general) * 4 + 250; |
| 1549 | ssize_t ret; |
Wey-Yi Guy | 92a35bd | 2009-10-09 13:20:29 -0700 | [diff] [blame] | 1550 | struct statistics_general *general, *accum_general; |
| 1551 | struct statistics_dbg *dbg, *accum_dbg; |
| 1552 | struct statistics_div *div, *accum_div; |
Wey-Yi Guy | e8fe59a | 2009-08-07 15:41:42 -0700 | [diff] [blame] | 1553 | |
| 1554 | if (!iwl_is_alive(priv)) |
| 1555 | return -EAGAIN; |
| 1556 | |
| 1557 | /* make request to uCode to retrieve statistics information */ |
| 1558 | mutex_lock(&priv->mutex); |
Wey-Yi Guy | ef8d552 | 2009-11-13 11:56:28 -0800 | [diff] [blame] | 1559 | ret = iwl_send_statistics_request(priv, CMD_SYNC, false); |
Wey-Yi Guy | e8fe59a | 2009-08-07 15:41:42 -0700 | [diff] [blame] | 1560 | mutex_unlock(&priv->mutex); |
| 1561 | |
| 1562 | if (ret) { |
| 1563 | IWL_ERR(priv, |
| 1564 | "Error sending statistics request: %zd\n", ret); |
| 1565 | return -EAGAIN; |
| 1566 | } |
| 1567 | buf = kzalloc(bufsz, GFP_KERNEL); |
| 1568 | if (!buf) { |
| 1569 | IWL_ERR(priv, "Can not allocate Buffer\n"); |
| 1570 | return -ENOMEM; |
| 1571 | } |
| 1572 | |
| 1573 | /* the statistic information display here is based on |
| 1574 | * the last statistics notification from uCode |
| 1575 | * might not reflect the current uCode activity |
| 1576 | */ |
| 1577 | general = &priv->statistics.general; |
| 1578 | dbg = &priv->statistics.general.dbg; |
| 1579 | div = &priv->statistics.general.div; |
Wey-Yi Guy | 92a35bd | 2009-10-09 13:20:29 -0700 | [diff] [blame] | 1580 | accum_general = &priv->accum_statistics.general; |
| 1581 | accum_dbg = &priv->accum_statistics.general.dbg; |
| 1582 | accum_div = &priv->accum_statistics.general.div; |
Wey-Yi Guy | e8fe59a | 2009-08-07 15:41:42 -0700 | [diff] [blame] | 1583 | pos += iwl_dbgfs_statistics_flag(priv, buf, bufsz); |
| 1584 | pos += scnprintf(buf + pos, bufsz - pos, "Statistics_General:\n"); |
Wey-Yi Guy | 92a35bd | 2009-10-09 13:20:29 -0700 | [diff] [blame] | 1585 | pos += scnprintf(buf + pos, bufsz - pos, |
| 1586 | "\t\t\tcurrent\t\t\taccumulative\n"); |
| 1587 | pos += scnprintf(buf + pos, bufsz - pos, "temperature:\t\t\t%u\n", |
Wey-Yi Guy | e8fe59a | 2009-08-07 15:41:42 -0700 | [diff] [blame] | 1588 | le32_to_cpu(general->temperature)); |
Wey-Yi Guy | 92a35bd | 2009-10-09 13:20:29 -0700 | [diff] [blame] | 1589 | pos += scnprintf(buf + pos, bufsz - pos, "temperature_m:\t\t\t%u\n", |
Wey-Yi Guy | e8fe59a | 2009-08-07 15:41:42 -0700 | [diff] [blame] | 1590 | le32_to_cpu(general->temperature_m)); |
Wey-Yi Guy | 92a35bd | 2009-10-09 13:20:29 -0700 | [diff] [blame] | 1591 | pos += scnprintf(buf + pos, bufsz - pos, |
| 1592 | "burst_check:\t\t\t%u\t\t\t%u\n", |
| 1593 | le32_to_cpu(dbg->burst_check), |
| 1594 | accum_dbg->burst_check); |
| 1595 | pos += scnprintf(buf + pos, bufsz - pos, |
| 1596 | "burst_count:\t\t\t%u\t\t\t%u\n", |
| 1597 | le32_to_cpu(dbg->burst_count), |
| 1598 | accum_dbg->burst_count); |
| 1599 | pos += scnprintf(buf + pos, bufsz - pos, |
| 1600 | "sleep_time:\t\t\t%u\t\t\t%u\n", |
| 1601 | le32_to_cpu(general->sleep_time), |
| 1602 | accum_general->sleep_time); |
| 1603 | pos += scnprintf(buf + pos, bufsz - pos, |
| 1604 | "slots_out:\t\t\t%u\t\t\t%u\n", |
| 1605 | le32_to_cpu(general->slots_out), |
| 1606 | accum_general->slots_out); |
| 1607 | pos += scnprintf(buf + pos, bufsz - pos, |
| 1608 | "slots_idle:\t\t\t%u\t\t\t%u\n", |
| 1609 | le32_to_cpu(general->slots_idle), |
| 1610 | accum_general->slots_idle); |
| 1611 | pos += scnprintf(buf + pos, bufsz - pos, "ttl_timestamp:\t\t\t%u\n", |
Wey-Yi Guy | e8fe59a | 2009-08-07 15:41:42 -0700 | [diff] [blame] | 1612 | le32_to_cpu(general->ttl_timestamp)); |
Wey-Yi Guy | 92a35bd | 2009-10-09 13:20:29 -0700 | [diff] [blame] | 1613 | pos += scnprintf(buf + pos, bufsz - pos, "tx_on_a:\t\t\t%u\t\t\t%u\n", |
| 1614 | le32_to_cpu(div->tx_on_a), accum_div->tx_on_a); |
| 1615 | pos += scnprintf(buf + pos, bufsz - pos, "tx_on_b:\t\t\t%u\t\t\t%u\n", |
| 1616 | le32_to_cpu(div->tx_on_b), accum_div->tx_on_b); |
| 1617 | pos += scnprintf(buf + pos, bufsz - pos, |
| 1618 | "exec_time:\t\t\t%u\t\t\t%u\n", |
| 1619 | le32_to_cpu(div->exec_time), accum_div->exec_time); |
| 1620 | pos += scnprintf(buf + pos, bufsz - pos, |
| 1621 | "probe_time:\t\t\t%u\t\t\t%u\n", |
| 1622 | le32_to_cpu(div->probe_time), accum_div->probe_time); |
| 1623 | pos += scnprintf(buf + pos, bufsz - pos, |
| 1624 | "rx_enable_counter:\t\t%u\t\t\t%u\n", |
| 1625 | le32_to_cpu(general->rx_enable_counter), |
| 1626 | accum_general->rx_enable_counter); |
Wey-Yi Guy | e8fe59a | 2009-08-07 15:41:42 -0700 | [diff] [blame] | 1627 | ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos); |
| 1628 | kfree(buf); |
| 1629 | return ret; |
| 1630 | } |
| 1631 | |
Wey-Yi Guy | 5225935 | 2009-08-07 15:41:43 -0700 | [diff] [blame] | 1632 | static ssize_t iwl_dbgfs_sensitivity_read(struct file *file, |
| 1633 | char __user *user_buf, |
| 1634 | size_t count, loff_t *ppos) { |
| 1635 | |
| 1636 | struct iwl_priv *priv = (struct iwl_priv *)file->private_data; |
| 1637 | int pos = 0; |
| 1638 | int cnt = 0; |
| 1639 | char *buf; |
| 1640 | int bufsz = sizeof(struct iwl_sensitivity_data) * 4 + 100; |
| 1641 | ssize_t ret; |
| 1642 | struct iwl_sensitivity_data *data; |
| 1643 | |
| 1644 | data = &priv->sensitivity_data; |
| 1645 | buf = kzalloc(bufsz, GFP_KERNEL); |
| 1646 | if (!buf) { |
| 1647 | IWL_ERR(priv, "Can not allocate Buffer\n"); |
| 1648 | return -ENOMEM; |
| 1649 | } |
| 1650 | |
| 1651 | pos += scnprintf(buf + pos, bufsz - pos, "auto_corr_ofdm:\t\t\t %u\n", |
| 1652 | data->auto_corr_ofdm); |
| 1653 | pos += scnprintf(buf + pos, bufsz - pos, |
| 1654 | "auto_corr_ofdm_mrc:\t\t %u\n", |
| 1655 | data->auto_corr_ofdm_mrc); |
| 1656 | pos += scnprintf(buf + pos, bufsz - pos, "auto_corr_ofdm_x1:\t\t %u\n", |
| 1657 | data->auto_corr_ofdm_x1); |
| 1658 | pos += scnprintf(buf + pos, bufsz - pos, |
| 1659 | "auto_corr_ofdm_mrc_x1:\t\t %u\n", |
| 1660 | data->auto_corr_ofdm_mrc_x1); |
| 1661 | pos += scnprintf(buf + pos, bufsz - pos, "auto_corr_cck:\t\t\t %u\n", |
| 1662 | data->auto_corr_cck); |
| 1663 | pos += scnprintf(buf + pos, bufsz - pos, "auto_corr_cck_mrc:\t\t %u\n", |
| 1664 | data->auto_corr_cck_mrc); |
| 1665 | pos += scnprintf(buf + pos, bufsz - pos, |
| 1666 | "last_bad_plcp_cnt_ofdm:\t\t %u\n", |
| 1667 | data->last_bad_plcp_cnt_ofdm); |
| 1668 | pos += scnprintf(buf + pos, bufsz - pos, "last_fa_cnt_ofdm:\t\t %u\n", |
| 1669 | data->last_fa_cnt_ofdm); |
| 1670 | pos += scnprintf(buf + pos, bufsz - pos, |
| 1671 | "last_bad_plcp_cnt_cck:\t\t %u\n", |
| 1672 | data->last_bad_plcp_cnt_cck); |
| 1673 | pos += scnprintf(buf + pos, bufsz - pos, "last_fa_cnt_cck:\t\t %u\n", |
| 1674 | data->last_fa_cnt_cck); |
| 1675 | pos += scnprintf(buf + pos, bufsz - pos, "nrg_curr_state:\t\t\t %u\n", |
| 1676 | data->nrg_curr_state); |
| 1677 | pos += scnprintf(buf + pos, bufsz - pos, "nrg_prev_state:\t\t\t %u\n", |
| 1678 | data->nrg_prev_state); |
| 1679 | pos += scnprintf(buf + pos, bufsz - pos, "nrg_value:\t\t\t"); |
| 1680 | for (cnt = 0; cnt < 10; cnt++) { |
| 1681 | pos += scnprintf(buf + pos, bufsz - pos, " %u", |
| 1682 | data->nrg_value[cnt]); |
| 1683 | } |
| 1684 | pos += scnprintf(buf + pos, bufsz - pos, "\n"); |
| 1685 | pos += scnprintf(buf + pos, bufsz - pos, "nrg_silence_rssi:\t\t"); |
| 1686 | for (cnt = 0; cnt < NRG_NUM_PREV_STAT_L; cnt++) { |
| 1687 | pos += scnprintf(buf + pos, bufsz - pos, " %u", |
| 1688 | data->nrg_silence_rssi[cnt]); |
| 1689 | } |
| 1690 | pos += scnprintf(buf + pos, bufsz - pos, "\n"); |
| 1691 | pos += scnprintf(buf + pos, bufsz - pos, "nrg_silence_ref:\t\t %u\n", |
| 1692 | data->nrg_silence_ref); |
| 1693 | pos += scnprintf(buf + pos, bufsz - pos, "nrg_energy_idx:\t\t\t %u\n", |
| 1694 | data->nrg_energy_idx); |
| 1695 | pos += scnprintf(buf + pos, bufsz - pos, "nrg_silence_idx:\t\t %u\n", |
| 1696 | data->nrg_silence_idx); |
| 1697 | pos += scnprintf(buf + pos, bufsz - pos, "nrg_th_cck:\t\t\t %u\n", |
| 1698 | data->nrg_th_cck); |
| 1699 | pos += scnprintf(buf + pos, bufsz - pos, |
| 1700 | "nrg_auto_corr_silence_diff:\t %u\n", |
| 1701 | data->nrg_auto_corr_silence_diff); |
| 1702 | pos += scnprintf(buf + pos, bufsz - pos, "num_in_cck_no_fa:\t\t %u\n", |
| 1703 | data->num_in_cck_no_fa); |
| 1704 | pos += scnprintf(buf + pos, bufsz - pos, "nrg_th_ofdm:\t\t\t %u\n", |
| 1705 | data->nrg_th_ofdm); |
| 1706 | |
| 1707 | ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos); |
| 1708 | kfree(buf); |
| 1709 | return ret; |
| 1710 | } |
| 1711 | |
| 1712 | |
| 1713 | static ssize_t iwl_dbgfs_chain_noise_read(struct file *file, |
| 1714 | char __user *user_buf, |
| 1715 | size_t count, loff_t *ppos) { |
| 1716 | |
| 1717 | struct iwl_priv *priv = (struct iwl_priv *)file->private_data; |
| 1718 | int pos = 0; |
| 1719 | int cnt = 0; |
| 1720 | char *buf; |
| 1721 | int bufsz = sizeof(struct iwl_chain_noise_data) * 4 + 100; |
| 1722 | ssize_t ret; |
| 1723 | struct iwl_chain_noise_data *data; |
| 1724 | |
| 1725 | data = &priv->chain_noise_data; |
| 1726 | buf = kzalloc(bufsz, GFP_KERNEL); |
| 1727 | if (!buf) { |
| 1728 | IWL_ERR(priv, "Can not allocate Buffer\n"); |
| 1729 | return -ENOMEM; |
| 1730 | } |
| 1731 | |
| 1732 | pos += scnprintf(buf + pos, bufsz - pos, "active_chains:\t\t\t %u\n", |
| 1733 | data->active_chains); |
| 1734 | pos += scnprintf(buf + pos, bufsz - pos, "chain_noise_a:\t\t\t %u\n", |
| 1735 | data->chain_noise_a); |
| 1736 | pos += scnprintf(buf + pos, bufsz - pos, "chain_noise_b:\t\t\t %u\n", |
| 1737 | data->chain_noise_b); |
| 1738 | pos += scnprintf(buf + pos, bufsz - pos, "chain_noise_c:\t\t\t %u\n", |
| 1739 | data->chain_noise_c); |
| 1740 | pos += scnprintf(buf + pos, bufsz - pos, "chain_signal_a:\t\t\t %u\n", |
| 1741 | data->chain_signal_a); |
| 1742 | pos += scnprintf(buf + pos, bufsz - pos, "chain_signal_b:\t\t\t %u\n", |
| 1743 | data->chain_signal_b); |
| 1744 | pos += scnprintf(buf + pos, bufsz - pos, "chain_signal_c:\t\t\t %u\n", |
| 1745 | data->chain_signal_c); |
| 1746 | pos += scnprintf(buf + pos, bufsz - pos, "beacon_count:\t\t\t %u\n", |
| 1747 | data->beacon_count); |
| 1748 | |
| 1749 | pos += scnprintf(buf + pos, bufsz - pos, "disconn_array:\t\t\t"); |
| 1750 | for (cnt = 0; cnt < NUM_RX_CHAINS; cnt++) { |
| 1751 | pos += scnprintf(buf + pos, bufsz - pos, " %u", |
| 1752 | data->disconn_array[cnt]); |
| 1753 | } |
| 1754 | pos += scnprintf(buf + pos, bufsz - pos, "\n"); |
| 1755 | pos += scnprintf(buf + pos, bufsz - pos, "delta_gain_code:\t\t"); |
| 1756 | for (cnt = 0; cnt < NUM_RX_CHAINS; cnt++) { |
| 1757 | pos += scnprintf(buf + pos, bufsz - pos, " %u", |
| 1758 | data->delta_gain_code[cnt]); |
| 1759 | } |
| 1760 | pos += scnprintf(buf + pos, bufsz - pos, "\n"); |
| 1761 | pos += scnprintf(buf + pos, bufsz - pos, "radio_write:\t\t\t %u\n", |
| 1762 | data->radio_write); |
| 1763 | pos += scnprintf(buf + pos, bufsz - pos, "state:\t\t\t\t %u\n", |
| 1764 | data->state); |
| 1765 | |
| 1766 | ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos); |
| 1767 | kfree(buf); |
| 1768 | return ret; |
| 1769 | } |
| 1770 | |
Wey-Yi Guy | f204b24 | 2009-08-21 13:34:19 -0700 | [diff] [blame] | 1771 | static ssize_t iwl_dbgfs_tx_power_read(struct file *file, |
| 1772 | char __user *user_buf, |
| 1773 | size_t count, loff_t *ppos) { |
| 1774 | |
| 1775 | struct iwl_priv *priv = (struct iwl_priv *)file->private_data; |
| 1776 | char buf[128]; |
| 1777 | int pos = 0; |
| 1778 | ssize_t ret; |
| 1779 | const size_t bufsz = sizeof(buf); |
| 1780 | struct statistics_tx *tx; |
| 1781 | |
| 1782 | if (!iwl_is_alive(priv)) |
| 1783 | pos += scnprintf(buf + pos, bufsz - pos, "N/A\n"); |
| 1784 | else { |
| 1785 | /* make request to uCode to retrieve statistics information */ |
| 1786 | mutex_lock(&priv->mutex); |
Wey-Yi Guy | ef8d552 | 2009-11-13 11:56:28 -0800 | [diff] [blame] | 1787 | ret = iwl_send_statistics_request(priv, CMD_SYNC, false); |
Wey-Yi Guy | f204b24 | 2009-08-21 13:34:19 -0700 | [diff] [blame] | 1788 | mutex_unlock(&priv->mutex); |
| 1789 | |
| 1790 | if (ret) { |
| 1791 | IWL_ERR(priv, "Error sending statistics request: %zd\n", |
| 1792 | ret); |
| 1793 | return -EAGAIN; |
| 1794 | } |
| 1795 | tx = &priv->statistics.tx; |
| 1796 | if (tx->tx_power.ant_a || |
| 1797 | tx->tx_power.ant_b || |
| 1798 | tx->tx_power.ant_c) { |
| 1799 | pos += scnprintf(buf + pos, bufsz - pos, |
| 1800 | "tx power: (1/2 dB step)\n"); |
| 1801 | if ((priv->cfg->valid_tx_ant & ANT_A) && |
| 1802 | tx->tx_power.ant_a) |
| 1803 | pos += scnprintf(buf + pos, bufsz - pos, |
| 1804 | "\tantenna A: 0x%X\n", |
| 1805 | tx->tx_power.ant_a); |
| 1806 | if ((priv->cfg->valid_tx_ant & ANT_B) && |
| 1807 | tx->tx_power.ant_b) |
| 1808 | pos += scnprintf(buf + pos, bufsz - pos, |
| 1809 | "\tantenna B: 0x%X\n", |
| 1810 | tx->tx_power.ant_b); |
| 1811 | if ((priv->cfg->valid_tx_ant & ANT_C) && |
| 1812 | tx->tx_power.ant_c) |
| 1813 | pos += scnprintf(buf + pos, bufsz - pos, |
| 1814 | "\tantenna C: 0x%X\n", |
| 1815 | tx->tx_power.ant_c); |
| 1816 | } else |
| 1817 | pos += scnprintf(buf + pos, bufsz - pos, "N/A\n"); |
| 1818 | } |
| 1819 | return simple_read_from_buffer(user_buf, count, ppos, buf, pos); |
| 1820 | } |
| 1821 | |
Wey-Yi Guy | c09430a | 2009-10-16 14:25:50 -0700 | [diff] [blame] | 1822 | static ssize_t iwl_dbgfs_power_save_status_read(struct file *file, |
| 1823 | char __user *user_buf, |
| 1824 | size_t count, loff_t *ppos) |
| 1825 | { |
| 1826 | struct iwl_priv *priv = (struct iwl_priv *)file->private_data; |
| 1827 | char buf[60]; |
| 1828 | int pos = 0; |
| 1829 | const size_t bufsz = sizeof(buf); |
| 1830 | u32 pwrsave_status; |
| 1831 | |
| 1832 | pwrsave_status = iwl_read32(priv, CSR_GP_CNTRL) & |
| 1833 | CSR_GP_REG_POWER_SAVE_STATUS_MSK; |
| 1834 | |
| 1835 | pos += scnprintf(buf + pos, bufsz - pos, "Power Save Status: "); |
| 1836 | pos += scnprintf(buf + pos, bufsz - pos, "%s\n", |
| 1837 | (pwrsave_status == CSR_GP_REG_NO_POWER_SAVE) ? "none" : |
| 1838 | (pwrsave_status == CSR_GP_REG_MAC_POWER_SAVE) ? "MAC" : |
| 1839 | (pwrsave_status == CSR_GP_REG_PHY_POWER_SAVE) ? "PHY" : |
| 1840 | "error"); |
| 1841 | |
| 1842 | return simple_read_from_buffer(user_buf, count, ppos, buf, pos); |
| 1843 | } |
| 1844 | |
Wey-Yi Guy | 7163b8a | 2009-11-20 12:04:56 -0800 | [diff] [blame] | 1845 | 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] | 1846 | const char __user *user_buf, |
| 1847 | size_t count, loff_t *ppos) |
| 1848 | { |
| 1849 | struct iwl_priv *priv = file->private_data; |
| 1850 | char buf[8]; |
| 1851 | int buf_size; |
| 1852 | int clear; |
| 1853 | |
| 1854 | memset(buf, 0, sizeof(buf)); |
| 1855 | buf_size = min(count, sizeof(buf) - 1); |
| 1856 | if (copy_from_user(buf, user_buf, buf_size)) |
| 1857 | return -EFAULT; |
| 1858 | if (sscanf(buf, "%d", &clear) != 1) |
| 1859 | return -EFAULT; |
| 1860 | |
| 1861 | /* make request to uCode to retrieve statistics information */ |
| 1862 | mutex_lock(&priv->mutex); |
| 1863 | iwl_send_statistics_request(priv, CMD_SYNC, true); |
| 1864 | mutex_unlock(&priv->mutex); |
| 1865 | |
| 1866 | return count; |
| 1867 | } |
| 1868 | |
Wey-Yi Guy | 696bdee | 2009-12-10 14:37:25 -0800 | [diff] [blame] | 1869 | static ssize_t iwl_dbgfs_csr_write(struct file *file, |
| 1870 | const char __user *user_buf, |
| 1871 | size_t count, loff_t *ppos) |
| 1872 | { |
| 1873 | struct iwl_priv *priv = file->private_data; |
| 1874 | char buf[8]; |
| 1875 | int buf_size; |
| 1876 | int csr; |
| 1877 | |
| 1878 | memset(buf, 0, sizeof(buf)); |
| 1879 | buf_size = min(count, sizeof(buf) - 1); |
| 1880 | if (copy_from_user(buf, user_buf, buf_size)) |
| 1881 | return -EFAULT; |
| 1882 | if (sscanf(buf, "%d", &csr) != 1) |
| 1883 | return -EFAULT; |
| 1884 | |
| 1885 | if (priv->cfg->ops->lib->dump_csr) |
| 1886 | priv->cfg->ops->lib->dump_csr(priv); |
| 1887 | |
| 1888 | return count; |
| 1889 | } |
| 1890 | |
Wey-Yi Guy | a9e1cb6 | 2009-12-10 14:37:26 -0800 | [diff] [blame] | 1891 | static ssize_t iwl_dbgfs_ucode_tracing_read(struct file *file, |
| 1892 | char __user *user_buf, |
| 1893 | size_t count, loff_t *ppos) { |
| 1894 | |
| 1895 | struct iwl_priv *priv = (struct iwl_priv *)file->private_data; |
| 1896 | int pos = 0; |
| 1897 | char buf[128]; |
| 1898 | const size_t bufsz = sizeof(buf); |
| 1899 | ssize_t ret; |
| 1900 | |
| 1901 | pos += scnprintf(buf + pos, bufsz - pos, "ucode trace timer is %s\n", |
| 1902 | priv->event_log.ucode_trace ? "On" : "Off"); |
| 1903 | pos += scnprintf(buf + pos, bufsz - pos, "non_wraps_count:\t\t %u\n", |
| 1904 | priv->event_log.non_wraps_count); |
| 1905 | pos += scnprintf(buf + pos, bufsz - pos, "wraps_once_count:\t\t %u\n", |
| 1906 | priv->event_log.wraps_once_count); |
| 1907 | pos += scnprintf(buf + pos, bufsz - pos, "wraps_more_count:\t\t %u\n", |
| 1908 | priv->event_log.wraps_more_count); |
| 1909 | |
| 1910 | ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos); |
| 1911 | return ret; |
| 1912 | } |
| 1913 | |
| 1914 | static ssize_t iwl_dbgfs_ucode_tracing_write(struct file *file, |
| 1915 | const char __user *user_buf, |
| 1916 | size_t count, loff_t *ppos) |
| 1917 | { |
| 1918 | struct iwl_priv *priv = file->private_data; |
| 1919 | char buf[8]; |
| 1920 | int buf_size; |
| 1921 | int trace; |
| 1922 | |
| 1923 | memset(buf, 0, sizeof(buf)); |
| 1924 | buf_size = min(count, sizeof(buf) - 1); |
| 1925 | if (copy_from_user(buf, user_buf, buf_size)) |
| 1926 | return -EFAULT; |
| 1927 | if (sscanf(buf, "%d", &trace) != 1) |
| 1928 | return -EFAULT; |
| 1929 | |
| 1930 | if (trace) { |
| 1931 | priv->event_log.ucode_trace = true; |
| 1932 | /* schedule the ucode timer to occur in UCODE_TRACE_PERIOD */ |
| 1933 | mod_timer(&priv->ucode_trace, |
| 1934 | jiffies + msecs_to_jiffies(UCODE_TRACE_PERIOD)); |
| 1935 | } else { |
| 1936 | priv->event_log.ucode_trace = false; |
| 1937 | del_timer_sync(&priv->ucode_trace); |
| 1938 | } |
| 1939 | |
| 1940 | return count; |
| 1941 | } |
| 1942 | |
Wey-Yi Guy | 7163b8a | 2009-11-20 12:04:56 -0800 | [diff] [blame] | 1943 | DEBUGFS_READ_FILE_OPS(rx_statistics); |
| 1944 | DEBUGFS_READ_FILE_OPS(tx_statistics); |
Wey-Yi Guy | 20594eb | 2009-08-07 15:41:39 -0700 | [diff] [blame] | 1945 | DEBUGFS_READ_WRITE_FILE_OPS(traffic_log); |
Wey-Yi Guy | 141b03e | 2009-08-07 15:41:41 -0700 | [diff] [blame] | 1946 | DEBUGFS_READ_FILE_OPS(rx_queue); |
| 1947 | DEBUGFS_READ_FILE_OPS(tx_queue); |
Wey-Yi Guy | e8fe59a | 2009-08-07 15:41:42 -0700 | [diff] [blame] | 1948 | DEBUGFS_READ_FILE_OPS(ucode_rx_stats); |
| 1949 | DEBUGFS_READ_FILE_OPS(ucode_tx_stats); |
| 1950 | DEBUGFS_READ_FILE_OPS(ucode_general_stats); |
Wey-Yi Guy | 5225935 | 2009-08-07 15:41:43 -0700 | [diff] [blame] | 1951 | DEBUGFS_READ_FILE_OPS(sensitivity); |
| 1952 | DEBUGFS_READ_FILE_OPS(chain_noise); |
Wey-Yi Guy | f204b24 | 2009-08-21 13:34:19 -0700 | [diff] [blame] | 1953 | DEBUGFS_READ_FILE_OPS(tx_power); |
Wey-Yi Guy | c09430a | 2009-10-16 14:25:50 -0700 | [diff] [blame] | 1954 | DEBUGFS_READ_FILE_OPS(power_save_status); |
Wey-Yi Guy | 7163b8a | 2009-11-20 12:04:56 -0800 | [diff] [blame] | 1955 | DEBUGFS_WRITE_FILE_OPS(clear_ucode_statistics); |
| 1956 | DEBUGFS_WRITE_FILE_OPS(clear_traffic_statistics); |
Wey-Yi Guy | 696bdee | 2009-12-10 14:37:25 -0800 | [diff] [blame] | 1957 | DEBUGFS_WRITE_FILE_OPS(csr); |
Wey-Yi Guy | a9e1cb6 | 2009-12-10 14:37:26 -0800 | [diff] [blame] | 1958 | DEBUGFS_READ_WRITE_FILE_OPS(ucode_tracing); |
Wey-Yi Guy | 20594eb | 2009-08-07 15:41:39 -0700 | [diff] [blame] | 1959 | |
Tomas Winkler | 712b6cf | 2008-03-12 16:58:52 -0700 | [diff] [blame] | 1960 | /* |
| 1961 | * Create the debugfs files and directories |
| 1962 | * |
| 1963 | */ |
| 1964 | int iwl_dbgfs_register(struct iwl_priv *priv, const char *name) |
| 1965 | { |
| 1966 | struct iwl_debugfs *dbgfs; |
Zhu Yi | 95b1a82 | 2008-05-29 16:34:50 +0800 | [diff] [blame] | 1967 | struct dentry *phyd = priv->hw->wiphy->debugfsdir; |
Tomas Winkler | 3ac7f14 | 2008-07-21 02:40:14 +0300 | [diff] [blame] | 1968 | int ret = 0; |
Tomas Winkler | 712b6cf | 2008-03-12 16:58:52 -0700 | [diff] [blame] | 1969 | |
| 1970 | dbgfs = kzalloc(sizeof(struct iwl_debugfs), GFP_KERNEL); |
| 1971 | if (!dbgfs) { |
Tomas Winkler | 3ac7f14 | 2008-07-21 02:40:14 +0300 | [diff] [blame] | 1972 | ret = -ENOMEM; |
Tomas Winkler | 712b6cf | 2008-03-12 16:58:52 -0700 | [diff] [blame] | 1973 | goto err; |
| 1974 | } |
| 1975 | |
| 1976 | priv->dbgfs = dbgfs; |
| 1977 | dbgfs->name = name; |
Zhu Yi | 95b1a82 | 2008-05-29 16:34:50 +0800 | [diff] [blame] | 1978 | dbgfs->dir_drv = debugfs_create_dir(name, phyd); |
Tomas Winkler | 3ac7f14 | 2008-07-21 02:40:14 +0300 | [diff] [blame] | 1979 | if (!dbgfs->dir_drv || IS_ERR(dbgfs->dir_drv)) { |
| 1980 | ret = -ENOENT; |
Tomas Winkler | 712b6cf | 2008-03-12 16:58:52 -0700 | [diff] [blame] | 1981 | goto err; |
| 1982 | } |
| 1983 | |
| 1984 | DEBUGFS_ADD_DIR(data, dbgfs->dir_drv); |
Tomas Winkler | 445c2df | 2008-05-15 13:54:16 +0800 | [diff] [blame] | 1985 | DEBUGFS_ADD_DIR(rf, dbgfs->dir_drv); |
Wey-Yi Guy | 20594eb | 2009-08-07 15:41:39 -0700 | [diff] [blame] | 1986 | DEBUGFS_ADD_DIR(debug, dbgfs->dir_drv); |
Wey-Yi Guy | 43e8511 | 2009-11-20 12:04:58 -0800 | [diff] [blame] | 1987 | DEBUGFS_ADD_FILE(nvm, data, S_IRUSR); |
| 1988 | DEBUGFS_ADD_FILE(sram, data, S_IWUSR | S_IRUSR); |
Wey-Yi Guy | b03d7d0 | 2009-12-14 14:12:20 -0800 | [diff] [blame] | 1989 | DEBUGFS_ADD_FILE(log_event, data, S_IWUSR | S_IRUSR); |
Wey-Yi Guy | 43e8511 | 2009-11-20 12:04:58 -0800 | [diff] [blame] | 1990 | DEBUGFS_ADD_FILE(stations, data, S_IRUSR); |
| 1991 | DEBUGFS_ADD_FILE(channels, data, S_IRUSR); |
| 1992 | DEBUGFS_ADD_FILE(status, data, S_IRUSR); |
| 1993 | DEBUGFS_ADD_FILE(interrupt, data, S_IWUSR | S_IRUSR); |
| 1994 | DEBUGFS_ADD_FILE(qos, data, S_IRUSR); |
| 1995 | DEBUGFS_ADD_FILE(led, data, S_IRUSR); |
| 1996 | DEBUGFS_ADD_FILE(sleep_level_override, data, S_IWUSR | S_IRUSR); |
| 1997 | DEBUGFS_ADD_FILE(current_sleep_command, data, S_IRUSR); |
| 1998 | DEBUGFS_ADD_FILE(thermal_throttling, data, S_IRUSR); |
| 1999 | DEBUGFS_ADD_FILE(disable_ht40, data, S_IWUSR | S_IRUSR); |
| 2000 | DEBUGFS_ADD_FILE(rx_statistics, debug, S_IRUSR); |
| 2001 | DEBUGFS_ADD_FILE(tx_statistics, debug, S_IRUSR); |
| 2002 | DEBUGFS_ADD_FILE(traffic_log, debug, S_IWUSR | S_IRUSR); |
| 2003 | DEBUGFS_ADD_FILE(rx_queue, debug, S_IRUSR); |
| 2004 | DEBUGFS_ADD_FILE(tx_queue, debug, S_IRUSR); |
| 2005 | DEBUGFS_ADD_FILE(tx_power, debug, S_IRUSR); |
| 2006 | DEBUGFS_ADD_FILE(power_save_status, debug, S_IRUSR); |
| 2007 | DEBUGFS_ADD_FILE(clear_ucode_statistics, debug, S_IWUSR); |
| 2008 | DEBUGFS_ADD_FILE(clear_traffic_statistics, debug, S_IWUSR); |
Wey-Yi Guy | 696bdee | 2009-12-10 14:37:25 -0800 | [diff] [blame] | 2009 | DEBUGFS_ADD_FILE(csr, debug, S_IWUSR); |
Wey-Yi Guy | e8fe59a | 2009-08-07 15:41:42 -0700 | [diff] [blame] | 2010 | if ((priv->hw_rev & CSR_HW_REV_TYPE_MSK) != CSR_HW_REV_TYPE_3945) { |
Wey-Yi Guy | 43e8511 | 2009-11-20 12:04:58 -0800 | [diff] [blame] | 2011 | DEBUGFS_ADD_FILE(ucode_rx_stats, debug, S_IRUSR); |
| 2012 | DEBUGFS_ADD_FILE(ucode_tx_stats, debug, S_IRUSR); |
| 2013 | DEBUGFS_ADD_FILE(ucode_general_stats, debug, S_IRUSR); |
| 2014 | DEBUGFS_ADD_FILE(sensitivity, debug, S_IRUSR); |
| 2015 | DEBUGFS_ADD_FILE(chain_noise, debug, S_IRUSR); |
Wey-Yi Guy | a9e1cb6 | 2009-12-10 14:37:26 -0800 | [diff] [blame] | 2016 | DEBUGFS_ADD_FILE(ucode_tracing, debug, S_IWUSR | S_IRUSR); |
Wey-Yi Guy | e8fe59a | 2009-08-07 15:41:42 -0700 | [diff] [blame] | 2017 | } |
Tomas Winkler | 445c2df | 2008-05-15 13:54:16 +0800 | [diff] [blame] | 2018 | DEBUGFS_ADD_BOOL(disable_sensitivity, rf, &priv->disable_sens_cal); |
| 2019 | DEBUGFS_ADD_BOOL(disable_chain_noise, rf, |
| 2020 | &priv->disable_chain_noise_cal); |
Wey-Yi Guy | 030b865 | 2009-06-12 13:22:55 -0700 | [diff] [blame] | 2021 | if (((priv->hw_rev & CSR_HW_REV_TYPE_MSK) == CSR_HW_REV_TYPE_4965) || |
| 2022 | ((priv->hw_rev & CSR_HW_REV_TYPE_MSK) == CSR_HW_REV_TYPE_3945)) |
| 2023 | DEBUGFS_ADD_BOOL(disable_tx_power, rf, |
| 2024 | &priv->disable_tx_power_cal); |
Tomas Winkler | 712b6cf | 2008-03-12 16:58:52 -0700 | [diff] [blame] | 2025 | return 0; |
| 2026 | |
| 2027 | err: |
Winkler, Tomas | 15b1687 | 2008-12-19 10:37:33 +0800 | [diff] [blame] | 2028 | IWL_ERR(priv, "Can't open the debugfs directory\n"); |
Tomas Winkler | 712b6cf | 2008-03-12 16:58:52 -0700 | [diff] [blame] | 2029 | iwl_dbgfs_unregister(priv); |
Tomas Winkler | 3ac7f14 | 2008-07-21 02:40:14 +0300 | [diff] [blame] | 2030 | return ret; |
Tomas Winkler | 712b6cf | 2008-03-12 16:58:52 -0700 | [diff] [blame] | 2031 | } |
| 2032 | EXPORT_SYMBOL(iwl_dbgfs_register); |
| 2033 | |
| 2034 | /** |
| 2035 | * Remove the debugfs files and directories |
| 2036 | * |
| 2037 | */ |
| 2038 | void iwl_dbgfs_unregister(struct iwl_priv *priv) |
| 2039 | { |
Tomas Winkler | 3ac7f14 | 2008-07-21 02:40:14 +0300 | [diff] [blame] | 2040 | if (!priv->dbgfs) |
Tomas Winkler | 712b6cf | 2008-03-12 16:58:52 -0700 | [diff] [blame] | 2041 | return; |
| 2042 | |
Johannes Berg | e312c24 | 2009-08-07 15:41:51 -0700 | [diff] [blame] | 2043 | DEBUGFS_REMOVE(priv->dbgfs->dbgfs_data_files.file_sleep_level_override); |
| 2044 | DEBUGFS_REMOVE(priv->dbgfs->dbgfs_data_files.file_current_sleep_command); |
Wey-Yi Guy | 0848e29 | 2009-05-22 11:01:46 -0700 | [diff] [blame] | 2045 | DEBUGFS_REMOVE(priv->dbgfs->dbgfs_data_files.file_nvm); |
Tomas Winkler | 712b6cf | 2008-03-12 16:58:52 -0700 | [diff] [blame] | 2046 | DEBUGFS_REMOVE(priv->dbgfs->dbgfs_data_files.file_sram); |
Ester Kummer | 189a2b5 | 2008-05-15 13:54:18 +0800 | [diff] [blame] | 2047 | DEBUGFS_REMOVE(priv->dbgfs->dbgfs_data_files.file_log_event); |
Tomas Winkler | 712b6cf | 2008-03-12 16:58:52 -0700 | [diff] [blame] | 2048 | DEBUGFS_REMOVE(priv->dbgfs->dbgfs_data_files.file_stations); |
Winkler, Tomas | d366df5 | 2008-12-02 12:14:01 -0800 | [diff] [blame] | 2049 | DEBUGFS_REMOVE(priv->dbgfs->dbgfs_data_files.file_channels); |
Wey-Yi Guy | 08df05a | 2009-03-24 10:02:54 -0700 | [diff] [blame] | 2050 | DEBUGFS_REMOVE(priv->dbgfs->dbgfs_data_files.file_status); |
Wey-Yi Guy | a83b914 | 2009-04-08 11:39:32 -0700 | [diff] [blame] | 2051 | DEBUGFS_REMOVE(priv->dbgfs->dbgfs_data_files.file_interrupt); |
Wey-Yi Guy | f5ad69f | 2009-07-09 10:33:36 -0700 | [diff] [blame] | 2052 | DEBUGFS_REMOVE(priv->dbgfs->dbgfs_data_files.file_qos); |
Wey-Yi Guy | a283c01 | 2009-07-17 09:30:19 -0700 | [diff] [blame] | 2053 | DEBUGFS_REMOVE(priv->dbgfs->dbgfs_data_files.file_led); |
Wey-Yi Guy | fbf3a2a | 2009-07-24 11:13:04 -0700 | [diff] [blame] | 2054 | DEBUGFS_REMOVE(priv->dbgfs->dbgfs_data_files.file_thermal_throttling); |
Wey-Yi Guy | 1e4247d | 2009-07-27 13:50:15 -0700 | [diff] [blame] | 2055 | DEBUGFS_REMOVE(priv->dbgfs->dbgfs_data_files.file_disable_ht40); |
Tomas Winkler | 712b6cf | 2008-03-12 16:58:52 -0700 | [diff] [blame] | 2056 | DEBUGFS_REMOVE(priv->dbgfs->dir_data); |
Wey-Yi Guy | 22fdf3c | 2009-08-07 15:41:40 -0700 | [diff] [blame] | 2057 | DEBUGFS_REMOVE(priv->dbgfs->dbgfs_debug_files.file_rx_statistics); |
| 2058 | DEBUGFS_REMOVE(priv->dbgfs->dbgfs_debug_files.file_tx_statistics); |
Wey-Yi Guy | 20594eb | 2009-08-07 15:41:39 -0700 | [diff] [blame] | 2059 | DEBUGFS_REMOVE(priv->dbgfs->dbgfs_debug_files.file_traffic_log); |
Wey-Yi Guy | 141b03e | 2009-08-07 15:41:41 -0700 | [diff] [blame] | 2060 | DEBUGFS_REMOVE(priv->dbgfs->dbgfs_debug_files.file_rx_queue); |
| 2061 | DEBUGFS_REMOVE(priv->dbgfs->dbgfs_debug_files.file_tx_queue); |
Wey-Yi Guy | f204b24 | 2009-08-21 13:34:19 -0700 | [diff] [blame] | 2062 | DEBUGFS_REMOVE(priv->dbgfs->dbgfs_debug_files.file_tx_power); |
Wey-Yi Guy | c09430a | 2009-10-16 14:25:50 -0700 | [diff] [blame] | 2063 | DEBUGFS_REMOVE(priv->dbgfs->dbgfs_debug_files.file_power_save_status); |
Wey-Yi Guy | 7163b8a | 2009-11-20 12:04:56 -0800 | [diff] [blame] | 2064 | DEBUGFS_REMOVE(priv->dbgfs->dbgfs_debug_files. |
| 2065 | file_clear_ucode_statistics); |
| 2066 | DEBUGFS_REMOVE(priv->dbgfs->dbgfs_debug_files. |
| 2067 | file_clear_traffic_statistics); |
Wey-Yi Guy | 696bdee | 2009-12-10 14:37:25 -0800 | [diff] [blame] | 2068 | DEBUGFS_REMOVE(priv->dbgfs->dbgfs_debug_files.file_csr); |
Wey-Yi Guy | e8fe59a | 2009-08-07 15:41:42 -0700 | [diff] [blame] | 2069 | if ((priv->hw_rev & CSR_HW_REV_TYPE_MSK) != CSR_HW_REV_TYPE_3945) { |
| 2070 | DEBUGFS_REMOVE(priv->dbgfs->dbgfs_debug_files. |
| 2071 | file_ucode_rx_stats); |
| 2072 | DEBUGFS_REMOVE(priv->dbgfs->dbgfs_debug_files. |
| 2073 | file_ucode_tx_stats); |
| 2074 | DEBUGFS_REMOVE(priv->dbgfs->dbgfs_debug_files. |
| 2075 | file_ucode_general_stats); |
Wey-Yi Guy | 5225935 | 2009-08-07 15:41:43 -0700 | [diff] [blame] | 2076 | DEBUGFS_REMOVE(priv->dbgfs->dbgfs_debug_files. |
| 2077 | file_sensitivity); |
| 2078 | DEBUGFS_REMOVE(priv->dbgfs->dbgfs_debug_files. |
| 2079 | file_chain_noise); |
Wey-Yi Guy | a9e1cb6 | 2009-12-10 14:37:26 -0800 | [diff] [blame] | 2080 | DEBUGFS_REMOVE(priv->dbgfs->dbgfs_debug_files. |
| 2081 | file_ucode_tracing); |
Wey-Yi Guy | e8fe59a | 2009-08-07 15:41:42 -0700 | [diff] [blame] | 2082 | } |
Wey-Yi Guy | 20594eb | 2009-08-07 15:41:39 -0700 | [diff] [blame] | 2083 | DEBUGFS_REMOVE(priv->dbgfs->dir_debug); |
Tomas Winkler | 445c2df | 2008-05-15 13:54:16 +0800 | [diff] [blame] | 2084 | DEBUGFS_REMOVE(priv->dbgfs->dbgfs_rf_files.file_disable_sensitivity); |
| 2085 | DEBUGFS_REMOVE(priv->dbgfs->dbgfs_rf_files.file_disable_chain_noise); |
Wey-Yi Guy | 030b865 | 2009-06-12 13:22:55 -0700 | [diff] [blame] | 2086 | if (((priv->hw_rev & CSR_HW_REV_TYPE_MSK) == CSR_HW_REV_TYPE_4965) || |
| 2087 | ((priv->hw_rev & CSR_HW_REV_TYPE_MSK) == CSR_HW_REV_TYPE_3945)) |
| 2088 | DEBUGFS_REMOVE(priv->dbgfs->dbgfs_rf_files.file_disable_tx_power); |
Tomas Winkler | 445c2df | 2008-05-15 13:54:16 +0800 | [diff] [blame] | 2089 | DEBUGFS_REMOVE(priv->dbgfs->dir_rf); |
Tomas Winkler | 712b6cf | 2008-03-12 16:58:52 -0700 | [diff] [blame] | 2090 | DEBUGFS_REMOVE(priv->dbgfs->dir_drv); |
| 2091 | kfree(priv->dbgfs); |
| 2092 | priv->dbgfs = NULL; |
| 2093 | } |
| 2094 | EXPORT_SYMBOL(iwl_dbgfs_unregister); |
| 2095 | |
| 2096 | |
Tomas Winkler | 445c2df | 2008-05-15 13:54:16 +0800 | [diff] [blame] | 2097 | |