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