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