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