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