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