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