blob: b0f125c985cd4fac49e06f98a91eb4b741624d41 [file] [log] [blame]
Tomas Winkler712b6cf2008-03-12 16:58:52 -07001/******************************************************************************
2 *
3 * GPL LICENSE SUMMARY
4 *
Wey-Yi Guy4e318262011-12-27 11:21:32 -08005 * Copyright(c) 2008 - 2012 Intel Corporation. All rights reserved.
Tomas Winkler712b6cf2008-03-12 16:58:52 -07006 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of version 2 of the GNU General Public License as
9 * published by the Free Software Foundation.
10 *
11 * This program is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110,
19 * USA
20 *
21 * The full GNU General Public License is included in this distribution
22 * in the file called LICENSE.GPL.
23 *
24 * Contact Information:
Winkler, Tomas759ef892008-12-09 11:28:58 -080025 * Intel Linux Wireless <ilw@linux.intel.com>
Tomas Winkler712b6cf2008-03-12 16:58:52 -070026 * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
27 *****************************************************************************/
28
Tejun Heo5a0e3ad2010-03-24 17:04:11 +090029#include <linux/slab.h>
Tomas Winkler712b6cf2008-03-12 16:58:52 -070030#include <linux/kernel.h>
31#include <linux/module.h>
32#include <linux/debugfs.h>
Tomas Winkler712b6cf2008-03-12 16:58:52 -070033#include <linux/ieee80211.h>
34#include <net/mac80211.h>
Tomas Winkler712b6cf2008-03-12 16:58:52 -070035#include "iwl-debug.h"
Tomas Winkler3395f6e2008-03-25 16:33:37 -070036#include "iwl-io.h"
Johannes Berg1023fdc2012-05-15 12:16:34 +020037#include "dev.h"
38#include "agn.h"
Tomas Winkler712b6cf2008-03-12 16:58:52 -070039
40/* create and remove of files */
Johannes Berg4c84a8f2010-01-22 14:22:54 -080041#define DEBUGFS_ADD_FILE(name, parent, mode) do { \
42 if (!debugfs_create_file(#name, mode, parent, priv, \
43 &iwl_dbgfs_##name##_ops)) \
44 goto err; \
Tomas Winkler712b6cf2008-03-12 16:58:52 -070045} while (0)
46
Johannes Berg4c84a8f2010-01-22 14:22:54 -080047#define DEBUGFS_ADD_BOOL(name, parent, ptr) do { \
48 struct dentry *__tmp; \
49 __tmp = debugfs_create_bool(#name, S_IWUSR | S_IRUSR, \
50 parent, ptr); \
51 if (IS_ERR(__tmp) || !__tmp) \
52 goto err; \
Tomas Winkler712b6cf2008-03-12 16:58:52 -070053} while (0)
54
Johannes Berg4c84a8f2010-01-22 14:22:54 -080055#define DEBUGFS_ADD_X32(name, parent, ptr) do { \
56 struct dentry *__tmp; \
57 __tmp = debugfs_create_x32(#name, S_IWUSR | S_IRUSR, \
58 parent, ptr); \
59 if (IS_ERR(__tmp) || !__tmp) \
60 goto err; \
Tomas Winkler445c2df2008-05-15 13:54:16 +080061} while (0)
62
Johannes Bergca934b62011-09-15 11:46:48 -070063#define DEBUGFS_ADD_U32(name, parent, ptr, mode) do { \
64 struct dentry *__tmp; \
65 __tmp = debugfs_create_u32(#name, mode, \
66 parent, ptr); \
67 if (IS_ERR(__tmp) || !__tmp) \
68 goto err; \
69} while (0)
70
Tomas Winkler712b6cf2008-03-12 16:58:52 -070071/* file operation */
72#define DEBUGFS_READ_FUNC(name) \
73static ssize_t iwl_dbgfs_##name##_read(struct file *file, \
74 char __user *user_buf, \
75 size_t count, loff_t *ppos);
76
77#define DEBUGFS_WRITE_FUNC(name) \
78static ssize_t iwl_dbgfs_##name##_write(struct file *file, \
79 const char __user *user_buf, \
80 size_t count, loff_t *ppos);
81
82
Tomas Winkler712b6cf2008-03-12 16:58:52 -070083#define DEBUGFS_READ_FILE_OPS(name) \
84 DEBUGFS_READ_FUNC(name); \
85static const struct file_operations iwl_dbgfs_##name##_ops = { \
Richard A. Griffiths0ff1bd32012-06-28 13:14:11 -070086 .read = iwl_dbgfs_##name##_read, \
Stephen Boyd234e3402012-04-05 14:25:11 -070087 .open = simple_open, \
Arnd Bergmann2b18ab362010-07-06 19:05:31 +020088 .llseek = generic_file_llseek, \
Tomas Winkler712b6cf2008-03-12 16:58:52 -070089};
90
Ester Kummer189a2b52008-05-15 13:54:18 +080091#define DEBUGFS_WRITE_FILE_OPS(name) \
92 DEBUGFS_WRITE_FUNC(name); \
93static const struct file_operations iwl_dbgfs_##name##_ops = { \
94 .write = iwl_dbgfs_##name##_write, \
Stephen Boyd234e3402012-04-05 14:25:11 -070095 .open = simple_open, \
Arnd Bergmann2b18ab362010-07-06 19:05:31 +020096 .llseek = generic_file_llseek, \
Ester Kummer189a2b52008-05-15 13:54:18 +080097};
98
99
Tomas Winkler712b6cf2008-03-12 16:58:52 -0700100#define DEBUGFS_READ_WRITE_FILE_OPS(name) \
101 DEBUGFS_READ_FUNC(name); \
102 DEBUGFS_WRITE_FUNC(name); \
103static const struct file_operations iwl_dbgfs_##name##_ops = { \
104 .write = iwl_dbgfs_##name##_write, \
105 .read = iwl_dbgfs_##name##_read, \
Stephen Boyd234e3402012-04-05 14:25:11 -0700106 .open = simple_open, \
Arnd Bergmann2b18ab362010-07-06 19:05:31 +0200107 .llseek = generic_file_llseek, \
Tomas Winkler712b6cf2008-03-12 16:58:52 -0700108};
109
Tomas Winkler712b6cf2008-03-12 16:58:52 -0700110static ssize_t iwl_dbgfs_sram_read(struct file *file,
111 char __user *user_buf,
112 size_t count, loff_t *ppos)
113{
Jay Sternberg24834d22011-01-11 15:41:00 -0800114 u32 val = 0;
Wey-Yi Guy2943f132009-11-20 12:05:00 -0800115 char *buf;
Tomas Winkler712b6cf2008-03-12 16:58:52 -0700116 ssize_t ret;
Jay Sternberg24834d22011-01-11 15:41:00 -0800117 int i = 0;
118 bool device_format = false;
119 int offset = 0;
120 int len = 0;
Tomas Winkler712b6cf2008-03-12 16:58:52 -0700121 int pos = 0;
Jay Sternberg24834d22011-01-11 15:41:00 -0800122 int sram;
H Hartley Sweeten28f63a42010-01-08 16:14:10 -0700123 struct iwl_priv *priv = file->private_data;
David Spinadel6dfa8d02012-03-10 13:00:14 -0800124 const struct fw_img *img;
Wey-Yi Guy2943f132009-11-20 12:05:00 -0800125 size_t bufsz;
Tomas Winkler712b6cf2008-03-12 16:58:52 -0700126
Wey-Yi Guy5ade1e42009-11-20 12:05:04 -0800127 /* default is to dump the entire data segment */
Johannes Berg4c84a8f2010-01-22 14:22:54 -0800128 if (!priv->dbgfs_sram_offset && !priv->dbgfs_sram_len) {
129 priv->dbgfs_sram_offset = 0x800000;
Johannes Bergf9e75442012-03-30 09:37:39 +0200130 if (!priv->ucode_loaded)
David Spinadel8f7ffbe2012-03-10 13:00:10 -0800131 return -EINVAL;
Meenakshi Venkataramana42506e2012-03-15 13:26:57 -0700132 img = &priv->fw->img[priv->cur_ucode];
David Spinadel6dfa8d02012-03-10 13:00:14 -0800133 priv->dbgfs_sram_len = img->sec[IWL_UCODE_SECTION_DATA].len;
Wey-Yi Guy5ade1e42009-11-20 12:05:04 -0800134 }
Jay Sternberg24834d22011-01-11 15:41:00 -0800135 len = priv->dbgfs_sram_len;
136
137 if (len == -4) {
138 device_format = true;
139 len = 4;
140 }
141
142 bufsz = 50 + len * 4;
Wey-Yi Guy2943f132009-11-20 12:05:00 -0800143 buf = kmalloc(bufsz, GFP_KERNEL);
144 if (!buf)
145 return -ENOMEM;
Jay Sternberg24834d22011-01-11 15:41:00 -0800146
Wey-Yi Guy5ade1e42009-11-20 12:05:04 -0800147 pos += scnprintf(buf + pos, bufsz - pos, "sram_len: 0x%x\n",
Jay Sternberg24834d22011-01-11 15:41:00 -0800148 len);
Wey-Yi Guy5ade1e42009-11-20 12:05:04 -0800149 pos += scnprintf(buf + pos, bufsz - pos, "sram_offset: 0x%x\n",
Johannes Berg4c84a8f2010-01-22 14:22:54 -0800150 priv->dbgfs_sram_offset);
Jay Sternberg24834d22011-01-11 15:41:00 -0800151
152 /* adjust sram address since reads are only on even u32 boundaries */
153 offset = priv->dbgfs_sram_offset & 0x3;
154 sram = priv->dbgfs_sram_offset & ~0x3;
155
156 /* read the first u32 from sram */
Emmanuel Grumbach68e8dfd2012-04-18 07:28:17 -0700157 val = iwl_read_targ_mem(priv->trans, sram);
Jay Sternberg24834d22011-01-11 15:41:00 -0800158
159 for (; len; len--) {
160 /* put the address at the start of every line */
161 if (i == 0)
162 pos += scnprintf(buf + pos, bufsz - pos,
163 "%08X: ", sram + offset);
164
165 if (device_format)
166 pos += scnprintf(buf + pos, bufsz - pos,
167 "%02x", (val >> (8 * (3 - offset))) & 0xff);
168 else
169 pos += scnprintf(buf + pos, bufsz - pos,
170 "%02x ", (val >> (8 * offset)) & 0xff);
171
172 /* if all bytes processed, read the next u32 from sram */
173 if (++offset == 4) {
174 sram += 4;
175 offset = 0;
Emmanuel Grumbach68e8dfd2012-04-18 07:28:17 -0700176 val = iwl_read_targ_mem(priv->trans, sram);
Tomas Winkler712b6cf2008-03-12 16:58:52 -0700177 }
Jay Sternberg24834d22011-01-11 15:41:00 -0800178
179 /* put in extra spaces and split lines for human readability */
180 if (++i == 16) {
181 i = 0;
Wey-Yi Guy2943f132009-11-20 12:05:00 -0800182 pos += scnprintf(buf + pos, bufsz - pos, "\n");
Jay Sternberg24834d22011-01-11 15:41:00 -0800183 } else if (!(i & 7)) {
184 pos += scnprintf(buf + pos, bufsz - pos, " ");
185 } else if (!(i & 3)) {
186 pos += scnprintf(buf + pos, bufsz - pos, " ");
187 }
Tomas Winkler712b6cf2008-03-12 16:58:52 -0700188 }
Jay Sternberg24834d22011-01-11 15:41:00 -0800189 if (i)
190 pos += scnprintf(buf + pos, bufsz - pos, "\n");
Tomas Winkler712b6cf2008-03-12 16:58:52 -0700191
192 ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos);
Wey-Yi Guy2943f132009-11-20 12:05:00 -0800193 kfree(buf);
Tomas Winkler712b6cf2008-03-12 16:58:52 -0700194 return ret;
195}
196
197static ssize_t iwl_dbgfs_sram_write(struct file *file,
198 const char __user *user_buf,
199 size_t count, loff_t *ppos)
200{
201 struct iwl_priv *priv = file->private_data;
202 char buf[64];
203 int buf_size;
204 u32 offset, len;
205
206 memset(buf, 0, sizeof(buf));
207 buf_size = min(count, sizeof(buf) - 1);
208 if (copy_from_user(buf, user_buf, buf_size))
209 return -EFAULT;
210
211 if (sscanf(buf, "%x,%x", &offset, &len) == 2) {
Johannes Berg4c84a8f2010-01-22 14:22:54 -0800212 priv->dbgfs_sram_offset = offset;
213 priv->dbgfs_sram_len = len;
Jay Sternberg24834d22011-01-11 15:41:00 -0800214 } else if (sscanf(buf, "%x", &offset) == 1) {
215 priv->dbgfs_sram_offset = offset;
216 priv->dbgfs_sram_len = -4;
Tomas Winkler712b6cf2008-03-12 16:58:52 -0700217 } else {
Johannes Berg4c84a8f2010-01-22 14:22:54 -0800218 priv->dbgfs_sram_offset = 0;
219 priv->dbgfs_sram_len = 0;
Tomas Winkler712b6cf2008-03-12 16:58:52 -0700220 }
221
222 return count;
223}
224
Johannes Bergc8ac61c2011-07-15 13:23:45 -0700225static ssize_t iwl_dbgfs_wowlan_sram_read(struct file *file,
226 char __user *user_buf,
227 size_t count, loff_t *ppos)
228{
229 struct iwl_priv *priv = file->private_data;
David Spinadel6dfa8d02012-03-10 13:00:14 -0800230 const struct fw_img *img = &priv->fw->img[IWL_UCODE_WOWLAN];
Johannes Bergc8ac61c2011-07-15 13:23:45 -0700231
232 if (!priv->wowlan_sram)
233 return -ENODATA;
234
235 return simple_read_from_buffer(user_buf, count, ppos,
236 priv->wowlan_sram,
David Spinadel6dfa8d02012-03-10 13:00:14 -0800237 img->sec[IWL_UCODE_SECTION_DATA].len);
Johannes Bergc8ac61c2011-07-15 13:23:45 -0700238}
Tomas Winkler712b6cf2008-03-12 16:58:52 -0700239static ssize_t iwl_dbgfs_stations_read(struct file *file, char __user *user_buf,
240 size_t count, loff_t *ppos)
241{
H Hartley Sweeten28f63a42010-01-08 16:14:10 -0700242 struct iwl_priv *priv = file->private_data;
Tomas Winkler6def9762008-05-05 10:22:31 +0800243 struct iwl_station_entry *station;
Emmanuel Grumbach5f85a782011-08-25 23:11:18 -0700244 struct iwl_tid_data *tid_data;
Tomas Winkler712b6cf2008-03-12 16:58:52 -0700245 char *buf;
246 int i, j, pos = 0;
247 ssize_t ret;
248 /* Add 30 for initial string */
249 const size_t bufsz = 30 + sizeof(char) * 500 * (priv->num_stations);
Tomas Winkler712b6cf2008-03-12 16:58:52 -0700250
251 buf = kmalloc(bufsz, GFP_KERNEL);
Tomas Winkler3ac7f142008-07-21 02:40:14 +0300252 if (!buf)
Tomas Winkler712b6cf2008-03-12 16:58:52 -0700253 return -ENOMEM;
254
Abhijeet Kolekardb0589f2008-04-14 21:16:04 -0700255 pos += scnprintf(buf + pos, bufsz - pos, "num of stations: %d\n\n",
Tomas Winkler712b6cf2008-03-12 16:58:52 -0700256 priv->num_stations);
257
Emmanuel Grumbach3eae4bb2011-10-10 07:26:55 -0700258 for (i = 0; i < IWLAGN_STATION_COUNT; i++) {
Tomas Winkler712b6cf2008-03-12 16:58:52 -0700259 station = &priv->stations[i];
Johannes Bergda735112010-05-03 01:25:24 -0700260 if (!station->used)
261 continue;
262 pos += scnprintf(buf + pos, bufsz - pos,
263 "station %d - addr: %pM, flags: %#x\n",
264 i, station->sta.sta.addr,
265 station->sta.station_flags_msk);
266 pos += scnprintf(buf + pos, bufsz - pos,
Johannes Berg9eae88f2012-03-15 13:26:52 -0700267 "TID seqno next_rclmd "
268 "rate_n_flags state txq\n");
Tomas Winkler712b6cf2008-03-12 16:58:52 -0700269
Emmanuel Grumbach5f85a782011-08-25 23:11:18 -0700270 for (j = 0; j < IWL_MAX_TID_COUNT; j++) {
Emmanuel Grumbach04cf6822011-11-23 11:06:12 +0200271 tid_data = &priv->tid_data[i][j];
Johannes Bergda735112010-05-03 01:25:24 -0700272 pos += scnprintf(buf + pos, bufsz - pos,
Johannes Berg9eae88f2012-03-15 13:26:52 -0700273 "%d: 0x%.4x 0x%.4x 0x%.8x "
274 "%d %.2d",
Emmanuel Grumbach5f85a782011-08-25 23:11:18 -0700275 j, tid_data->seq_number,
Johannes Berg9eae88f2012-03-15 13:26:52 -0700276 tid_data->next_reclaimed,
277 tid_data->agg.rate_n_flags,
278 tid_data->agg.state,
279 tid_data->agg.txq_id);
Johannes Bergda735112010-05-03 01:25:24 -0700280
Emmanuel Grumbach5f85a782011-08-25 23:11:18 -0700281 if (tid_data->agg.wait_for_ba)
Abhijeet Kolekardb0589f2008-04-14 21:16:04 -0700282 pos += scnprintf(buf + pos, bufsz - pos,
Johannes Bergda735112010-05-03 01:25:24 -0700283 " - waitforba");
Abhijeet Kolekardb0589f2008-04-14 21:16:04 -0700284 pos += scnprintf(buf + pos, bufsz - pos, "\n");
Tomas Winkler712b6cf2008-03-12 16:58:52 -0700285 }
Johannes Bergda735112010-05-03 01:25:24 -0700286
287 pos += scnprintf(buf + pos, bufsz - pos, "\n");
Tomas Winkler712b6cf2008-03-12 16:58:52 -0700288 }
289
290 ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos);
291 kfree(buf);
292 return ret;
293}
294
Wey-Yi Guy0848e292009-05-22 11:01:46 -0700295static ssize_t iwl_dbgfs_nvm_read(struct file *file,
Tomas Winkler8dd266e2008-05-05 10:22:32 +0800296 char __user *user_buf,
297 size_t count,
298 loff_t *ppos)
299{
300 ssize_t ret;
H Hartley Sweeten28f63a42010-01-08 16:14:10 -0700301 struct iwl_priv *priv = file->private_data;
Tomas Winkler8dd266e2008-05-05 10:22:32 +0800302 int pos = 0, ofs = 0, buf_size = 0;
303 const u8 *ptr;
304 char *buf;
Wey-Yi Guye307ddc2009-09-11 10:38:16 -0700305 u16 eeprom_ver;
Johannes Berg26a7ca92012-05-21 11:55:54 +0200306 size_t eeprom_len = priv->eeprom_blob_size;
Tomas Winkler8dd266e2008-05-05 10:22:32 +0800307 buf_size = 4 * eeprom_len + 256;
308
Johannes Bergf9e75442012-03-30 09:37:39 +0200309 if (eeprom_len % 16)
Tomas Winkler8dd266e2008-05-05 10:22:32 +0800310 return -ENODATA;
Tomas Winkler8dd266e2008-05-05 10:22:32 +0800311
Johannes Berg26a7ca92012-05-21 11:55:54 +0200312 ptr = priv->eeprom_blob;
Johannes Bergf9e75442012-03-30 09:37:39 +0200313 if (!ptr)
Julia Lawallc37457e2009-08-03 11:11:45 +0200314 return -ENOMEM;
Julia Lawallc37457e2009-08-03 11:11:45 +0200315
Tomas Winkler8dd266e2008-05-05 10:22:32 +0800316 /* 4 characters for byte 0xYY */
317 buf = kzalloc(buf_size, GFP_KERNEL);
Johannes Bergf9e75442012-03-30 09:37:39 +0200318 if (!buf)
Tomas Winkler8dd266e2008-05-05 10:22:32 +0800319 return -ENOMEM;
Johannes Bergf9e75442012-03-30 09:37:39 +0200320
Johannes Berg26a7ca92012-05-21 11:55:54 +0200321 eeprom_ver = priv->eeprom_data->eeprom_version;
322 pos += scnprintf(buf + pos, buf_size - pos,
323 "NVM version: 0x%x\n", eeprom_ver);
Tomas Winkler8dd266e2008-05-05 10:22:32 +0800324 for (ofs = 0 ; ofs < eeprom_len ; ofs += 16) {
325 pos += scnprintf(buf + pos, buf_size - pos, "0x%.4x ", ofs);
326 hex_dump_to_buffer(ptr + ofs, 16 , 16, 2, buf + pos,
327 buf_size - pos, 0);
Reinette Chatre2fac9712009-09-25 14:24:21 -0700328 pos += strlen(buf + pos);
Tomas Winkler8dd266e2008-05-05 10:22:32 +0800329 if (buf_size - pos > 0)
330 buf[pos++] = '\n';
331 }
332
333 ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos);
334 kfree(buf);
335 return ret;
336}
Tomas Winkler712b6cf2008-03-12 16:58:52 -0700337
Winkler, Tomasd366df52008-12-02 12:14:01 -0800338static ssize_t iwl_dbgfs_channels_read(struct file *file, char __user *user_buf,
339 size_t count, loff_t *ppos)
340{
H Hartley Sweeten28f63a42010-01-08 16:14:10 -0700341 struct iwl_priv *priv = file->private_data;
Winkler, Tomasd366df52008-12-02 12:14:01 -0800342 struct ieee80211_channel *channels = NULL;
343 const struct ieee80211_supported_band *supp_band = NULL;
344 int pos = 0, i, bufsz = PAGE_SIZE;
345 char *buf;
346 ssize_t ret;
347
Winkler, Tomasd366df52008-12-02 12:14:01 -0800348 buf = kzalloc(bufsz, GFP_KERNEL);
Johannes Bergf9e75442012-03-30 09:37:39 +0200349 if (!buf)
Winkler, Tomasd366df52008-12-02 12:14:01 -0800350 return -ENOMEM;
Winkler, Tomasd366df52008-12-02 12:14:01 -0800351
352 supp_band = iwl_get_hw_mode(priv, IEEE80211_BAND_2GHZ);
Wey-Yi Guya2e23222009-05-22 11:01:55 -0700353 if (supp_band) {
354 channels = supp_band->channels;
Winkler, Tomasd366df52008-12-02 12:14:01 -0800355
Winkler, Tomasd366df52008-12-02 12:14:01 -0800356 pos += scnprintf(buf + pos, bufsz - pos,
Wey-Yi Guya2e23222009-05-22 11:01:55 -0700357 "Displaying %d channels in 2.4GHz band 802.11bg):\n",
358 supp_band->n_channels);
Winkler, Tomasd366df52008-12-02 12:14:01 -0800359
Wey-Yi Guya2e23222009-05-22 11:01:55 -0700360 for (i = 0; i < supp_band->n_channels; i++)
361 pos += scnprintf(buf + pos, bufsz - pos,
362 "%d: %ddBm: BSS%s%s, %s.\n",
Shanyu Zhao81e95432010-07-28 13:40:27 -0700363 channels[i].hw_value,
Wey-Yi Guya2e23222009-05-22 11:01:55 -0700364 channels[i].max_power,
365 channels[i].flags & IEEE80211_CHAN_RADAR ?
366 " (IEEE 802.11h required)" : "",
367 ((channels[i].flags & IEEE80211_CHAN_NO_IBSS)
368 || (channels[i].flags &
369 IEEE80211_CHAN_RADAR)) ? "" :
370 ", IBSS",
371 channels[i].flags &
372 IEEE80211_CHAN_PASSIVE_SCAN ?
373 "passive only" : "active/passive");
374 }
Winkler, Tomasd366df52008-12-02 12:14:01 -0800375 supp_band = iwl_get_hw_mode(priv, IEEE80211_BAND_5GHZ);
Wey-Yi Guya2e23222009-05-22 11:01:55 -0700376 if (supp_band) {
377 channels = supp_band->channels;
Winkler, Tomasd366df52008-12-02 12:14:01 -0800378
Winkler, Tomasd366df52008-12-02 12:14:01 -0800379 pos += scnprintf(buf + pos, bufsz - pos,
Wey-Yi Guya2e23222009-05-22 11:01:55 -0700380 "Displaying %d channels in 5.2GHz band (802.11a)\n",
381 supp_band->n_channels);
382
383 for (i = 0; i < supp_band->n_channels; i++)
384 pos += scnprintf(buf + pos, bufsz - pos,
385 "%d: %ddBm: BSS%s%s, %s.\n",
Shanyu Zhao81e95432010-07-28 13:40:27 -0700386 channels[i].hw_value,
Wey-Yi Guya2e23222009-05-22 11:01:55 -0700387 channels[i].max_power,
388 channels[i].flags & IEEE80211_CHAN_RADAR ?
389 " (IEEE 802.11h required)" : "",
390 ((channels[i].flags & IEEE80211_CHAN_NO_IBSS)
391 || (channels[i].flags &
392 IEEE80211_CHAN_RADAR)) ? "" :
393 ", IBSS",
394 channels[i].flags &
395 IEEE80211_CHAN_PASSIVE_SCAN ?
396 "passive only" : "active/passive");
397 }
Winkler, Tomasd366df52008-12-02 12:14:01 -0800398 ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos);
399 kfree(buf);
400 return ret;
401}
402
Wey-Yi Guy08df05a2009-03-24 10:02:54 -0700403static ssize_t iwl_dbgfs_status_read(struct file *file,
404 char __user *user_buf,
405 size_t count, loff_t *ppos) {
406
H Hartley Sweeten28f63a42010-01-08 16:14:10 -0700407 struct iwl_priv *priv = file->private_data;
Wey-Yi Guy08df05a2009-03-24 10:02:54 -0700408 char buf[512];
409 int pos = 0;
410 const size_t bufsz = sizeof(buf);
411
Wey-Yi Guy08df05a2009-03-24 10:02:54 -0700412 pos += scnprintf(buf + pos, bufsz - pos, "STATUS_RF_KILL_HW:\t %d\n",
Don Fry83626402012-03-07 09:52:37 -0800413 test_bit(STATUS_RF_KILL_HW, &priv->status));
Wey-Yi Guy7812b162009-10-02 13:43:58 -0700414 pos += scnprintf(buf + pos, bufsz - pos, "STATUS_CT_KILL:\t\t %d\n",
Don Fry9a716862012-03-07 09:52:32 -0800415 test_bit(STATUS_CT_KILL, &priv->status));
Wey-Yi Guy08df05a2009-03-24 10:02:54 -0700416 pos += scnprintf(buf + pos, bufsz - pos, "STATUS_ALIVE:\t\t %d\n",
Don Fry83626402012-03-07 09:52:37 -0800417 test_bit(STATUS_ALIVE, &priv->status));
Wey-Yi Guy08df05a2009-03-24 10:02:54 -0700418 pos += scnprintf(buf + pos, bufsz - pos, "STATUS_READY:\t\t %d\n",
Don Fry83626402012-03-07 09:52:37 -0800419 test_bit(STATUS_READY, &priv->status));
Wey-Yi Guy08df05a2009-03-24 10:02:54 -0700420 pos += scnprintf(buf + pos, bufsz - pos, "STATUS_EXIT_PENDING:\t %d\n",
Don Fry83626402012-03-07 09:52:37 -0800421 test_bit(STATUS_EXIT_PENDING, &priv->status));
Wey-Yi Guy08df05a2009-03-24 10:02:54 -0700422 pos += scnprintf(buf + pos, bufsz - pos, "STATUS_STATISTICS:\t %d\n",
Don Fry83626402012-03-07 09:52:37 -0800423 test_bit(STATUS_STATISTICS, &priv->status));
Wey-Yi Guy08df05a2009-03-24 10:02:54 -0700424 pos += scnprintf(buf + pos, bufsz - pos, "STATUS_SCANNING:\t %d\n",
Don Fry83626402012-03-07 09:52:37 -0800425 test_bit(STATUS_SCANNING, &priv->status));
Wey-Yi Guy08df05a2009-03-24 10:02:54 -0700426 pos += scnprintf(buf + pos, bufsz - pos, "STATUS_SCAN_ABORTING:\t %d\n",
Don Fry83626402012-03-07 09:52:37 -0800427 test_bit(STATUS_SCAN_ABORTING, &priv->status));
Wey-Yi Guy08df05a2009-03-24 10:02:54 -0700428 pos += scnprintf(buf + pos, bufsz - pos, "STATUS_SCAN_HW:\t\t %d\n",
Don Fry83626402012-03-07 09:52:37 -0800429 test_bit(STATUS_SCAN_HW, &priv->status));
Wey-Yi Guy08df05a2009-03-24 10:02:54 -0700430 pos += scnprintf(buf + pos, bufsz - pos, "STATUS_POWER_PMI:\t %d\n",
Don Fry47107e82012-03-15 13:27:06 -0700431 test_bit(STATUS_POWER_PMI, &priv->status));
Wey-Yi Guy08df05a2009-03-24 10:02:54 -0700432 pos += scnprintf(buf + pos, bufsz - pos, "STATUS_FW_ERROR:\t %d\n",
Don Fry17acd0b2012-03-15 13:27:05 -0700433 test_bit(STATUS_FW_ERROR, &priv->status));
Wey-Yi Guy08df05a2009-03-24 10:02:54 -0700434 return simple_read_from_buffer(user_buf, count, ppos, buf, pos);
435}
436
Emmanuel Grumbach1f7b6172011-08-25 23:10:59 -0700437static ssize_t iwl_dbgfs_rx_handlers_read(struct file *file,
Wey-Yi Guya83b9142009-04-08 11:39:32 -0700438 char __user *user_buf,
439 size_t count, loff_t *ppos) {
440
H Hartley Sweeten28f63a42010-01-08 16:14:10 -0700441 struct iwl_priv *priv = file->private_data;
Emmanuel Grumbach1f7b6172011-08-25 23:10:59 -0700442
Wey-Yi Guya83b9142009-04-08 11:39:32 -0700443 int pos = 0;
444 int cnt = 0;
445 char *buf;
446 int bufsz = 24 * 64; /* 24 items * 64 char per item */
447 ssize_t ret;
448
449 buf = kzalloc(bufsz, GFP_KERNEL);
Johannes Bergf9e75442012-03-30 09:37:39 +0200450 if (!buf)
Wey-Yi Guya83b9142009-04-08 11:39:32 -0700451 return -ENOMEM;
Wey-Yi Guya83b9142009-04-08 11:39:32 -0700452
Wey-Yi Guya83b9142009-04-08 11:39:32 -0700453 for (cnt = 0; cnt < REPLY_MAX; cnt++) {
Emmanuel Grumbach1f7b6172011-08-25 23:10:59 -0700454 if (priv->rx_handlers_stats[cnt] > 0)
Wey-Yi Guya83b9142009-04-08 11:39:32 -0700455 pos += scnprintf(buf + pos, bufsz - pos,
456 "\tRx handler[%36s]:\t\t %u\n",
Johannes Bergd9fb6462012-03-26 08:23:39 -0700457 iwl_dvm_get_cmd_string(cnt),
Emmanuel Grumbach1f7b6172011-08-25 23:10:59 -0700458 priv->rx_handlers_stats[cnt]);
Wey-Yi Guya83b9142009-04-08 11:39:32 -0700459 }
460
Wey-Yi Guya83b9142009-04-08 11:39:32 -0700461 ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos);
462 kfree(buf);
463 return ret;
464}
465
Emmanuel Grumbach1f7b6172011-08-25 23:10:59 -0700466static ssize_t iwl_dbgfs_rx_handlers_write(struct file *file,
Wey-Yi Guya83b9142009-04-08 11:39:32 -0700467 const char __user *user_buf,
468 size_t count, loff_t *ppos)
469{
470 struct iwl_priv *priv = file->private_data;
Emmanuel Grumbach1f7b6172011-08-25 23:10:59 -0700471
Wey-Yi Guya83b9142009-04-08 11:39:32 -0700472 char buf[8];
473 int buf_size;
474 u32 reset_flag;
475
476 memset(buf, 0, sizeof(buf));
477 buf_size = min(count, sizeof(buf) - 1);
478 if (copy_from_user(buf, user_buf, buf_size))
479 return -EFAULT;
480 if (sscanf(buf, "%x", &reset_flag) != 1)
481 return -EFAULT;
482 if (reset_flag == 0)
Emmanuel Grumbach1f7b6172011-08-25 23:10:59 -0700483 memset(&priv->rx_handlers_stats[0], 0,
484 sizeof(priv->rx_handlers_stats));
Wey-Yi Guya83b9142009-04-08 11:39:32 -0700485
486 return count;
487}
488
Wey-Yi Guyf5ad69f2009-07-09 10:33:36 -0700489static ssize_t iwl_dbgfs_qos_read(struct file *file, char __user *user_buf,
490 size_t count, loff_t *ppos)
491{
H Hartley Sweeten28f63a42010-01-08 16:14:10 -0700492 struct iwl_priv *priv = file->private_data;
Johannes Berg8dfdb9d2010-08-23 10:46:38 +0200493 struct iwl_rxon_context *ctx;
Wey-Yi Guyf5ad69f2009-07-09 10:33:36 -0700494 int pos = 0, i;
Johannes Berg8dfdb9d2010-08-23 10:46:38 +0200495 char buf[256 * NUM_IWL_RXON_CTX];
Wey-Yi Guyf5ad69f2009-07-09 10:33:36 -0700496 const size_t bufsz = sizeof(buf);
Wey-Yi Guyf5ad69f2009-07-09 10:33:36 -0700497
Johannes Berg8dfdb9d2010-08-23 10:46:38 +0200498 for_each_context(priv, ctx) {
499 pos += scnprintf(buf + pos, bufsz - pos, "context %d:\n",
500 ctx->ctxid);
501 for (i = 0; i < AC_NUM; i++) {
502 pos += scnprintf(buf + pos, bufsz - pos,
503 "\tcw_min\tcw_max\taifsn\ttxop\n");
504 pos += scnprintf(buf + pos, bufsz - pos,
Wey-Yi Guyf5ad69f2009-07-09 10:33:36 -0700505 "AC[%d]\t%u\t%u\t%u\t%u\n", i,
Johannes Berg8dfdb9d2010-08-23 10:46:38 +0200506 ctx->qos_data.def_qos_parm.ac[i].cw_min,
507 ctx->qos_data.def_qos_parm.ac[i].cw_max,
508 ctx->qos_data.def_qos_parm.ac[i].aifsn,
509 ctx->qos_data.def_qos_parm.ac[i].edca_txop);
510 }
511 pos += scnprintf(buf + pos, bufsz - pos, "\n");
Wey-Yi Guyf5ad69f2009-07-09 10:33:36 -0700512 }
Wey-Yi Guy4967c312010-02-18 15:22:07 -0800513 return simple_read_from_buffer(user_buf, count, ppos, buf, pos);
Wey-Yi Guyf5ad69f2009-07-09 10:33:36 -0700514}
Wey-Yi Guya83b9142009-04-08 11:39:32 -0700515
Wey-Yi Guyfbf3a2a2009-07-24 11:13:04 -0700516static ssize_t iwl_dbgfs_thermal_throttling_read(struct file *file,
517 char __user *user_buf,
518 size_t count, loff_t *ppos)
519{
H Hartley Sweeten28f63a42010-01-08 16:14:10 -0700520 struct iwl_priv *priv = file->private_data;
Johannes Berg3ad3b922009-08-07 15:41:48 -0700521 struct iwl_tt_mgmt *tt = &priv->thermal_throttle;
Wey-Yi Guyfbf3a2a2009-07-24 11:13:04 -0700522 struct iwl_tt_restriction *restriction;
523 char buf[100];
524 int pos = 0;
525 const size_t bufsz = sizeof(buf);
Wey-Yi Guyfbf3a2a2009-07-24 11:13:04 -0700526
527 pos += scnprintf(buf + pos, bufsz - pos,
528 "Thermal Throttling Mode: %s\n",
Johannes Berg3ad3b922009-08-07 15:41:48 -0700529 tt->advanced_tt ? "Advance" : "Legacy");
Wey-Yi Guyfbf3a2a2009-07-24 11:13:04 -0700530 pos += scnprintf(buf + pos, bufsz - pos,
531 "Thermal Throttling State: %d\n",
532 tt->state);
Johannes Berg3ad3b922009-08-07 15:41:48 -0700533 if (tt->advanced_tt) {
Wey-Yi Guyfbf3a2a2009-07-24 11:13:04 -0700534 restriction = tt->restriction + tt->state;
535 pos += scnprintf(buf + pos, bufsz - pos,
536 "Tx mode: %d\n",
537 restriction->tx_stream);
538 pos += scnprintf(buf + pos, bufsz - pos,
539 "Rx mode: %d\n",
540 restriction->rx_stream);
541 pos += scnprintf(buf + pos, bufsz - pos,
542 "HT mode: %d\n",
543 restriction->is_ht);
544 }
Wey-Yi Guy4967c312010-02-18 15:22:07 -0800545 return simple_read_from_buffer(user_buf, count, ppos, buf, pos);
Wey-Yi Guyfbf3a2a2009-07-24 11:13:04 -0700546}
547
Wey-Yi Guy1e4247d2009-07-27 13:50:15 -0700548static ssize_t iwl_dbgfs_disable_ht40_write(struct file *file,
549 const char __user *user_buf,
550 size_t count, loff_t *ppos)
551{
552 struct iwl_priv *priv = file->private_data;
553 char buf[8];
554 int buf_size;
555 int ht40;
556
557 memset(buf, 0, sizeof(buf));
558 buf_size = min(count, sizeof(buf) - 1);
559 if (copy_from_user(buf, user_buf, buf_size))
560 return -EFAULT;
561 if (sscanf(buf, "%d", &ht40) != 1)
562 return -EFAULT;
Johannes Berg246ed352010-08-23 10:46:32 +0200563 if (!iwl_is_any_associated(priv))
Wey-Yi Guy1e4247d2009-07-27 13:50:15 -0700564 priv->disable_ht40 = ht40 ? true : false;
Johannes Bergf9e75442012-03-30 09:37:39 +0200565 else
Wey-Yi Guy1e4247d2009-07-27 13:50:15 -0700566 return -EINVAL;
Wey-Yi Guy1e4247d2009-07-27 13:50:15 -0700567
568 return count;
569}
570
571static ssize_t iwl_dbgfs_disable_ht40_read(struct file *file,
572 char __user *user_buf,
573 size_t count, loff_t *ppos)
574{
H Hartley Sweeten28f63a42010-01-08 16:14:10 -0700575 struct iwl_priv *priv = file->private_data;
Wey-Yi Guy1e4247d2009-07-27 13:50:15 -0700576 char buf[100];
577 int pos = 0;
578 const size_t bufsz = sizeof(buf);
Wey-Yi Guy1e4247d2009-07-27 13:50:15 -0700579
580 pos += scnprintf(buf + pos, bufsz - pos,
581 "11n 40MHz Mode: %s\n",
582 priv->disable_ht40 ? "Disabled" : "Enabled");
Wey-Yi Guy4967c312010-02-18 15:22:07 -0800583 return simple_read_from_buffer(user_buf, count, ppos, buf, pos);
Wey-Yi Guy1e4247d2009-07-27 13:50:15 -0700584}
585
Emmanuel Grumbach511afa32011-09-22 07:15:37 -0700586static ssize_t iwl_dbgfs_temperature_read(struct file *file,
587 char __user *user_buf,
588 size_t count, loff_t *ppos)
589{
590 struct iwl_priv *priv = file->private_data;
591 char buf[8];
592 int pos = 0;
593 const size_t bufsz = sizeof(buf);
594
595 pos += scnprintf(buf + pos, bufsz - pos, "%d\n", priv->temperature);
596 return simple_read_from_buffer(user_buf, count, ppos, buf, pos);
597}
598
599
Johannes Berge312c242009-08-07 15:41:51 -0700600static ssize_t iwl_dbgfs_sleep_level_override_write(struct file *file,
601 const char __user *user_buf,
602 size_t count, loff_t *ppos)
603{
604 struct iwl_priv *priv = file->private_data;
605 char buf[8];
606 int buf_size;
607 int value;
608
609 memset(buf, 0, sizeof(buf));
610 buf_size = min(count, sizeof(buf) - 1);
611 if (copy_from_user(buf, user_buf, buf_size))
612 return -EFAULT;
613
614 if (sscanf(buf, "%d", &value) != 1)
615 return -EINVAL;
616
617 /*
618 * Our users expect 0 to be "CAM", but 0 isn't actually
619 * valid here. However, let's not confuse them and present
620 * IWL_POWER_INDEX_1 as "1", not "0".
621 */
Reinette Chatre1a34c042009-10-09 13:20:25 -0700622 if (value == 0)
623 return -EINVAL;
624 else if (value > 0)
Johannes Berge312c242009-08-07 15:41:51 -0700625 value -= 1;
626
627 if (value != -1 && (value < 0 || value >= IWL_POWER_NUM))
628 return -EINVAL;
629
Don Fry83626402012-03-07 09:52:37 -0800630 if (!iwl_is_ready_rf(priv))
Wey-Yi Guy4ad177b2009-10-16 14:25:58 -0700631 return -EAGAIN;
632
Johannes Berge312c242009-08-07 15:41:51 -0700633 priv->power_data.debug_sleep_level_override = value;
634
Johannes Bergb1eea292012-03-06 13:30:42 -0800635 mutex_lock(&priv->mutex);
Wey-Yi Guy4ad177b2009-10-16 14:25:58 -0700636 iwl_power_update_mode(priv, true);
Johannes Bergb1eea292012-03-06 13:30:42 -0800637 mutex_unlock(&priv->mutex);
Johannes Berge312c242009-08-07 15:41:51 -0700638
639 return count;
640}
641
642static ssize_t iwl_dbgfs_sleep_level_override_read(struct file *file,
643 char __user *user_buf,
644 size_t count, loff_t *ppos)
645{
H Hartley Sweeten28f63a42010-01-08 16:14:10 -0700646 struct iwl_priv *priv = file->private_data;
Johannes Berge312c242009-08-07 15:41:51 -0700647 char buf[10];
648 int pos, value;
649 const size_t bufsz = sizeof(buf);
650
651 /* see the write function */
652 value = priv->power_data.debug_sleep_level_override;
653 if (value >= 0)
654 value += 1;
655
656 pos = scnprintf(buf, bufsz, "%d\n", value);
657 return simple_read_from_buffer(user_buf, count, ppos, buf, pos);
658}
659
660static ssize_t iwl_dbgfs_current_sleep_command_read(struct file *file,
661 char __user *user_buf,
662 size_t count, loff_t *ppos)
663{
H Hartley Sweeten28f63a42010-01-08 16:14:10 -0700664 struct iwl_priv *priv = file->private_data;
Johannes Berge312c242009-08-07 15:41:51 -0700665 char buf[200];
666 int pos = 0, i;
667 const size_t bufsz = sizeof(buf);
668 struct iwl_powertable_cmd *cmd = &priv->power_data.sleep_cmd;
669
670 pos += scnprintf(buf + pos, bufsz - pos,
671 "flags: %#.2x\n", le16_to_cpu(cmd->flags));
672 pos += scnprintf(buf + pos, bufsz - pos,
673 "RX/TX timeout: %d/%d usec\n",
674 le32_to_cpu(cmd->rx_data_timeout),
675 le32_to_cpu(cmd->tx_data_timeout));
676 for (i = 0; i < IWL_POWER_VEC_SIZE; i++)
677 pos += scnprintf(buf + pos, bufsz - pos,
678 "sleep_interval[%d]: %d\n", i,
679 le32_to_cpu(cmd->sleep_interval[i]));
680
681 return simple_read_from_buffer(user_buf, count, ppos, buf, pos);
682}
683
Tomas Winkler712b6cf2008-03-12 16:58:52 -0700684DEBUGFS_READ_WRITE_FILE_OPS(sram);
Johannes Bergc8ac61c2011-07-15 13:23:45 -0700685DEBUGFS_READ_FILE_OPS(wowlan_sram);
Wey-Yi Guy0848e292009-05-22 11:01:46 -0700686DEBUGFS_READ_FILE_OPS(nvm);
Tomas Winkler712b6cf2008-03-12 16:58:52 -0700687DEBUGFS_READ_FILE_OPS(stations);
Winkler, Tomasd366df52008-12-02 12:14:01 -0800688DEBUGFS_READ_FILE_OPS(channels);
Wey-Yi Guy08df05a2009-03-24 10:02:54 -0700689DEBUGFS_READ_FILE_OPS(status);
Emmanuel Grumbach1f7b6172011-08-25 23:10:59 -0700690DEBUGFS_READ_WRITE_FILE_OPS(rx_handlers);
Wey-Yi Guyf5ad69f2009-07-09 10:33:36 -0700691DEBUGFS_READ_FILE_OPS(qos);
Wey-Yi Guyfbf3a2a2009-07-24 11:13:04 -0700692DEBUGFS_READ_FILE_OPS(thermal_throttling);
Wey-Yi Guy1e4247d2009-07-27 13:50:15 -0700693DEBUGFS_READ_WRITE_FILE_OPS(disable_ht40);
Emmanuel Grumbach511afa32011-09-22 07:15:37 -0700694DEBUGFS_READ_FILE_OPS(temperature);
Johannes Berge312c242009-08-07 15:41:51 -0700695DEBUGFS_READ_WRITE_FILE_OPS(sleep_level_override);
696DEBUGFS_READ_FILE_OPS(current_sleep_command);
Tomas Winkler712b6cf2008-03-12 16:58:52 -0700697
Wey-Yi Guyd6d023a2011-04-30 09:10:53 -0700698static const char *fmt_value = " %-30s %10u\n";
699static const char *fmt_hex = " %-30s 0x%02X\n";
700static const char *fmt_table = " %-30s %10u %10u %10u %10u\n";
701static const char *fmt_header =
702 "%-32s current cumulative delta max\n";
703
704static int iwl_statistics_flag(struct iwl_priv *priv, char *buf, int bufsz)
705{
706 int p = 0;
707 u32 flag;
708
Johannes Berg4ff70fcd2012-03-05 11:24:26 -0800709 lockdep_assert_held(&priv->statistics.lock);
710
Wey-Yi Guyd6d023a2011-04-30 09:10:53 -0700711 flag = le32_to_cpu(priv->statistics.flag);
712
713 p += scnprintf(buf + p, bufsz - p, "Statistics Flag(0x%X):\n", flag);
714 if (flag & UCODE_STATISTICS_CLEAR_MSK)
715 p += scnprintf(buf + p, bufsz - p,
716 "\tStatistics have been cleared\n");
717 p += scnprintf(buf + p, bufsz - p, "\tOperational Frequency: %s\n",
718 (flag & UCODE_STATISTICS_FREQUENCY_MSK)
719 ? "2.4 GHz" : "5.2 GHz");
720 p += scnprintf(buf + p, bufsz - p, "\tTGj Narrow Band: %s\n",
721 (flag & UCODE_STATISTICS_NARROW_BAND_MSK)
722 ? "enabled" : "disabled");
723
724 return p;
725}
726
Wey-Yi Guye8fe59a2009-08-07 15:41:42 -0700727static ssize_t iwl_dbgfs_ucode_rx_stats_read(struct file *file,
728 char __user *user_buf,
729 size_t count, loff_t *ppos)
730{
H Hartley Sweeten28f63a42010-01-08 16:14:10 -0700731 struct iwl_priv *priv = file->private_data;
Wey-Yi Guyd6d023a2011-04-30 09:10:53 -0700732 int pos = 0;
733 char *buf;
734 int bufsz = sizeof(struct statistics_rx_phy) * 40 +
735 sizeof(struct statistics_rx_non_phy) * 40 +
736 sizeof(struct statistics_rx_ht_phy) * 40 + 400;
737 ssize_t ret;
738 struct statistics_rx_phy *ofdm, *accum_ofdm, *delta_ofdm, *max_ofdm;
739 struct statistics_rx_phy *cck, *accum_cck, *delta_cck, *max_cck;
740 struct statistics_rx_non_phy *general, *accum_general;
741 struct statistics_rx_non_phy *delta_general, *max_general;
742 struct statistics_rx_ht_phy *ht, *accum_ht, *delta_ht, *max_ht;
743
Don Fry83626402012-03-07 09:52:37 -0800744 if (!iwl_is_alive(priv))
Wey-Yi Guyd6d023a2011-04-30 09:10:53 -0700745 return -EAGAIN;
746
747 buf = kzalloc(bufsz, GFP_KERNEL);
Johannes Bergf9e75442012-03-30 09:37:39 +0200748 if (!buf)
Wey-Yi Guyd6d023a2011-04-30 09:10:53 -0700749 return -ENOMEM;
Wey-Yi Guyd6d023a2011-04-30 09:10:53 -0700750
751 /*
752 * the statistic information display here is based on
753 * the last statistics notification from uCode
754 * might not reflect the current uCode activity
755 */
Johannes Berg4ff70fcd2012-03-05 11:24:26 -0800756 spin_lock_bh(&priv->statistics.lock);
Wey-Yi Guyd6d023a2011-04-30 09:10:53 -0700757 ofdm = &priv->statistics.rx_ofdm;
758 cck = &priv->statistics.rx_cck;
759 general = &priv->statistics.rx_non_phy;
760 ht = &priv->statistics.rx_ofdm_ht;
761 accum_ofdm = &priv->accum_stats.rx_ofdm;
762 accum_cck = &priv->accum_stats.rx_cck;
763 accum_general = &priv->accum_stats.rx_non_phy;
764 accum_ht = &priv->accum_stats.rx_ofdm_ht;
765 delta_ofdm = &priv->delta_stats.rx_ofdm;
766 delta_cck = &priv->delta_stats.rx_cck;
767 delta_general = &priv->delta_stats.rx_non_phy;
768 delta_ht = &priv->delta_stats.rx_ofdm_ht;
769 max_ofdm = &priv->max_delta_stats.rx_ofdm;
770 max_cck = &priv->max_delta_stats.rx_cck;
771 max_general = &priv->max_delta_stats.rx_non_phy;
772 max_ht = &priv->max_delta_stats.rx_ofdm_ht;
773
774 pos += iwl_statistics_flag(priv, buf, bufsz);
775 pos += scnprintf(buf + pos, bufsz - pos,
776 fmt_header, "Statistics_Rx - OFDM:");
777 pos += scnprintf(buf + pos, bufsz - pos,
778 fmt_table, "ina_cnt:",
779 le32_to_cpu(ofdm->ina_cnt),
780 accum_ofdm->ina_cnt,
781 delta_ofdm->ina_cnt, max_ofdm->ina_cnt);
782 pos += scnprintf(buf + pos, bufsz - pos,
783 fmt_table, "fina_cnt:",
784 le32_to_cpu(ofdm->fina_cnt), accum_ofdm->fina_cnt,
785 delta_ofdm->fina_cnt, max_ofdm->fina_cnt);
786 pos += scnprintf(buf + pos, bufsz - pos,
787 fmt_table, "plcp_err:",
788 le32_to_cpu(ofdm->plcp_err), accum_ofdm->plcp_err,
789 delta_ofdm->plcp_err, max_ofdm->plcp_err);
790 pos += scnprintf(buf + pos, bufsz - pos,
791 fmt_table, "crc32_err:",
792 le32_to_cpu(ofdm->crc32_err), accum_ofdm->crc32_err,
793 delta_ofdm->crc32_err, max_ofdm->crc32_err);
794 pos += scnprintf(buf + pos, bufsz - pos,
795 fmt_table, "overrun_err:",
796 le32_to_cpu(ofdm->overrun_err),
797 accum_ofdm->overrun_err, delta_ofdm->overrun_err,
798 max_ofdm->overrun_err);
799 pos += scnprintf(buf + pos, bufsz - pos,
800 fmt_table, "early_overrun_err:",
801 le32_to_cpu(ofdm->early_overrun_err),
802 accum_ofdm->early_overrun_err,
803 delta_ofdm->early_overrun_err,
804 max_ofdm->early_overrun_err);
805 pos += scnprintf(buf + pos, bufsz - pos,
806 fmt_table, "crc32_good:",
807 le32_to_cpu(ofdm->crc32_good),
808 accum_ofdm->crc32_good, delta_ofdm->crc32_good,
809 max_ofdm->crc32_good);
810 pos += scnprintf(buf + pos, bufsz - pos,
811 fmt_table, "false_alarm_cnt:",
812 le32_to_cpu(ofdm->false_alarm_cnt),
813 accum_ofdm->false_alarm_cnt,
814 delta_ofdm->false_alarm_cnt,
815 max_ofdm->false_alarm_cnt);
816 pos += scnprintf(buf + pos, bufsz - pos,
817 fmt_table, "fina_sync_err_cnt:",
818 le32_to_cpu(ofdm->fina_sync_err_cnt),
819 accum_ofdm->fina_sync_err_cnt,
820 delta_ofdm->fina_sync_err_cnt,
821 max_ofdm->fina_sync_err_cnt);
822 pos += scnprintf(buf + pos, bufsz - pos,
823 fmt_table, "sfd_timeout:",
824 le32_to_cpu(ofdm->sfd_timeout),
825 accum_ofdm->sfd_timeout, delta_ofdm->sfd_timeout,
826 max_ofdm->sfd_timeout);
827 pos += scnprintf(buf + pos, bufsz - pos,
828 fmt_table, "fina_timeout:",
829 le32_to_cpu(ofdm->fina_timeout),
830 accum_ofdm->fina_timeout, delta_ofdm->fina_timeout,
831 max_ofdm->fina_timeout);
832 pos += scnprintf(buf + pos, bufsz - pos,
833 fmt_table, "unresponded_rts:",
834 le32_to_cpu(ofdm->unresponded_rts),
835 accum_ofdm->unresponded_rts,
836 delta_ofdm->unresponded_rts,
837 max_ofdm->unresponded_rts);
838 pos += scnprintf(buf + pos, bufsz - pos,
839 fmt_table, "rxe_frame_lmt_ovrun:",
840 le32_to_cpu(ofdm->rxe_frame_limit_overrun),
841 accum_ofdm->rxe_frame_limit_overrun,
842 delta_ofdm->rxe_frame_limit_overrun,
843 max_ofdm->rxe_frame_limit_overrun);
844 pos += scnprintf(buf + pos, bufsz - pos,
845 fmt_table, "sent_ack_cnt:",
846 le32_to_cpu(ofdm->sent_ack_cnt),
847 accum_ofdm->sent_ack_cnt, delta_ofdm->sent_ack_cnt,
848 max_ofdm->sent_ack_cnt);
849 pos += scnprintf(buf + pos, bufsz - pos,
850 fmt_table, "sent_cts_cnt:",
851 le32_to_cpu(ofdm->sent_cts_cnt),
852 accum_ofdm->sent_cts_cnt, delta_ofdm->sent_cts_cnt,
853 max_ofdm->sent_cts_cnt);
854 pos += scnprintf(buf + pos, bufsz - pos,
855 fmt_table, "sent_ba_rsp_cnt:",
856 le32_to_cpu(ofdm->sent_ba_rsp_cnt),
857 accum_ofdm->sent_ba_rsp_cnt,
858 delta_ofdm->sent_ba_rsp_cnt,
859 max_ofdm->sent_ba_rsp_cnt);
860 pos += scnprintf(buf + pos, bufsz - pos,
861 fmt_table, "dsp_self_kill:",
862 le32_to_cpu(ofdm->dsp_self_kill),
863 accum_ofdm->dsp_self_kill,
864 delta_ofdm->dsp_self_kill,
865 max_ofdm->dsp_self_kill);
866 pos += scnprintf(buf + pos, bufsz - pos,
867 fmt_table, "mh_format_err:",
868 le32_to_cpu(ofdm->mh_format_err),
869 accum_ofdm->mh_format_err,
870 delta_ofdm->mh_format_err,
871 max_ofdm->mh_format_err);
872 pos += scnprintf(buf + pos, bufsz - pos,
873 fmt_table, "re_acq_main_rssi_sum:",
874 le32_to_cpu(ofdm->re_acq_main_rssi_sum),
875 accum_ofdm->re_acq_main_rssi_sum,
876 delta_ofdm->re_acq_main_rssi_sum,
877 max_ofdm->re_acq_main_rssi_sum);
878
879 pos += scnprintf(buf + pos, bufsz - pos,
880 fmt_header, "Statistics_Rx - CCK:");
881 pos += scnprintf(buf + pos, bufsz - pos,
882 fmt_table, "ina_cnt:",
883 le32_to_cpu(cck->ina_cnt), accum_cck->ina_cnt,
884 delta_cck->ina_cnt, max_cck->ina_cnt);
885 pos += scnprintf(buf + pos, bufsz - pos,
886 fmt_table, "fina_cnt:",
887 le32_to_cpu(cck->fina_cnt), accum_cck->fina_cnt,
888 delta_cck->fina_cnt, max_cck->fina_cnt);
889 pos += scnprintf(buf + pos, bufsz - pos,
890 fmt_table, "plcp_err:",
891 le32_to_cpu(cck->plcp_err), accum_cck->plcp_err,
892 delta_cck->plcp_err, max_cck->plcp_err);
893 pos += scnprintf(buf + pos, bufsz - pos,
894 fmt_table, "crc32_err:",
895 le32_to_cpu(cck->crc32_err), accum_cck->crc32_err,
896 delta_cck->crc32_err, max_cck->crc32_err);
897 pos += scnprintf(buf + pos, bufsz - pos,
898 fmt_table, "overrun_err:",
899 le32_to_cpu(cck->overrun_err),
900 accum_cck->overrun_err, delta_cck->overrun_err,
901 max_cck->overrun_err);
902 pos += scnprintf(buf + pos, bufsz - pos,
903 fmt_table, "early_overrun_err:",
904 le32_to_cpu(cck->early_overrun_err),
905 accum_cck->early_overrun_err,
906 delta_cck->early_overrun_err,
907 max_cck->early_overrun_err);
908 pos += scnprintf(buf + pos, bufsz - pos,
909 fmt_table, "crc32_good:",
910 le32_to_cpu(cck->crc32_good), accum_cck->crc32_good,
911 delta_cck->crc32_good, max_cck->crc32_good);
912 pos += scnprintf(buf + pos, bufsz - pos,
913 fmt_table, "false_alarm_cnt:",
914 le32_to_cpu(cck->false_alarm_cnt),
915 accum_cck->false_alarm_cnt,
916 delta_cck->false_alarm_cnt, max_cck->false_alarm_cnt);
917 pos += scnprintf(buf + pos, bufsz - pos,
918 fmt_table, "fina_sync_err_cnt:",
919 le32_to_cpu(cck->fina_sync_err_cnt),
920 accum_cck->fina_sync_err_cnt,
921 delta_cck->fina_sync_err_cnt,
922 max_cck->fina_sync_err_cnt);
923 pos += scnprintf(buf + pos, bufsz - pos,
924 fmt_table, "sfd_timeout:",
925 le32_to_cpu(cck->sfd_timeout),
926 accum_cck->sfd_timeout, delta_cck->sfd_timeout,
927 max_cck->sfd_timeout);
928 pos += scnprintf(buf + pos, bufsz - pos,
929 fmt_table, "fina_timeout:",
930 le32_to_cpu(cck->fina_timeout),
931 accum_cck->fina_timeout, delta_cck->fina_timeout,
932 max_cck->fina_timeout);
933 pos += scnprintf(buf + pos, bufsz - pos,
934 fmt_table, "unresponded_rts:",
935 le32_to_cpu(cck->unresponded_rts),
936 accum_cck->unresponded_rts, delta_cck->unresponded_rts,
937 max_cck->unresponded_rts);
938 pos += scnprintf(buf + pos, bufsz - pos,
939 fmt_table, "rxe_frame_lmt_ovrun:",
940 le32_to_cpu(cck->rxe_frame_limit_overrun),
941 accum_cck->rxe_frame_limit_overrun,
942 delta_cck->rxe_frame_limit_overrun,
943 max_cck->rxe_frame_limit_overrun);
944 pos += scnprintf(buf + pos, bufsz - pos,
945 fmt_table, "sent_ack_cnt:",
946 le32_to_cpu(cck->sent_ack_cnt),
947 accum_cck->sent_ack_cnt, delta_cck->sent_ack_cnt,
948 max_cck->sent_ack_cnt);
949 pos += scnprintf(buf + pos, bufsz - pos,
950 fmt_table, "sent_cts_cnt:",
951 le32_to_cpu(cck->sent_cts_cnt),
952 accum_cck->sent_cts_cnt, delta_cck->sent_cts_cnt,
953 max_cck->sent_cts_cnt);
954 pos += scnprintf(buf + pos, bufsz - pos,
955 fmt_table, "sent_ba_rsp_cnt:",
956 le32_to_cpu(cck->sent_ba_rsp_cnt),
957 accum_cck->sent_ba_rsp_cnt,
958 delta_cck->sent_ba_rsp_cnt,
959 max_cck->sent_ba_rsp_cnt);
960 pos += scnprintf(buf + pos, bufsz - pos,
961 fmt_table, "dsp_self_kill:",
962 le32_to_cpu(cck->dsp_self_kill),
963 accum_cck->dsp_self_kill, delta_cck->dsp_self_kill,
964 max_cck->dsp_self_kill);
965 pos += scnprintf(buf + pos, bufsz - pos,
966 fmt_table, "mh_format_err:",
967 le32_to_cpu(cck->mh_format_err),
968 accum_cck->mh_format_err, delta_cck->mh_format_err,
969 max_cck->mh_format_err);
970 pos += scnprintf(buf + pos, bufsz - pos,
971 fmt_table, "re_acq_main_rssi_sum:",
972 le32_to_cpu(cck->re_acq_main_rssi_sum),
973 accum_cck->re_acq_main_rssi_sum,
974 delta_cck->re_acq_main_rssi_sum,
975 max_cck->re_acq_main_rssi_sum);
976
977 pos += scnprintf(buf + pos, bufsz - pos,
978 fmt_header, "Statistics_Rx - GENERAL:");
979 pos += scnprintf(buf + pos, bufsz - pos,
980 fmt_table, "bogus_cts:",
981 le32_to_cpu(general->bogus_cts),
982 accum_general->bogus_cts, delta_general->bogus_cts,
983 max_general->bogus_cts);
984 pos += scnprintf(buf + pos, bufsz - pos,
985 fmt_table, "bogus_ack:",
986 le32_to_cpu(general->bogus_ack),
987 accum_general->bogus_ack, delta_general->bogus_ack,
988 max_general->bogus_ack);
989 pos += scnprintf(buf + pos, bufsz - pos,
990 fmt_table, "non_bssid_frames:",
991 le32_to_cpu(general->non_bssid_frames),
992 accum_general->non_bssid_frames,
993 delta_general->non_bssid_frames,
994 max_general->non_bssid_frames);
995 pos += scnprintf(buf + pos, bufsz - pos,
996 fmt_table, "filtered_frames:",
997 le32_to_cpu(general->filtered_frames),
998 accum_general->filtered_frames,
999 delta_general->filtered_frames,
1000 max_general->filtered_frames);
1001 pos += scnprintf(buf + pos, bufsz - pos,
1002 fmt_table, "non_channel_beacons:",
1003 le32_to_cpu(general->non_channel_beacons),
1004 accum_general->non_channel_beacons,
1005 delta_general->non_channel_beacons,
1006 max_general->non_channel_beacons);
1007 pos += scnprintf(buf + pos, bufsz - pos,
1008 fmt_table, "channel_beacons:",
1009 le32_to_cpu(general->channel_beacons),
1010 accum_general->channel_beacons,
1011 delta_general->channel_beacons,
1012 max_general->channel_beacons);
1013 pos += scnprintf(buf + pos, bufsz - pos,
1014 fmt_table, "num_missed_bcon:",
1015 le32_to_cpu(general->num_missed_bcon),
1016 accum_general->num_missed_bcon,
1017 delta_general->num_missed_bcon,
1018 max_general->num_missed_bcon);
1019 pos += scnprintf(buf + pos, bufsz - pos,
1020 fmt_table, "adc_rx_saturation_time:",
1021 le32_to_cpu(general->adc_rx_saturation_time),
1022 accum_general->adc_rx_saturation_time,
1023 delta_general->adc_rx_saturation_time,
1024 max_general->adc_rx_saturation_time);
1025 pos += scnprintf(buf + pos, bufsz - pos,
1026 fmt_table, "ina_detect_search_tm:",
1027 le32_to_cpu(general->ina_detection_search_time),
1028 accum_general->ina_detection_search_time,
1029 delta_general->ina_detection_search_time,
1030 max_general->ina_detection_search_time);
1031 pos += scnprintf(buf + pos, bufsz - pos,
1032 fmt_table, "beacon_silence_rssi_a:",
1033 le32_to_cpu(general->beacon_silence_rssi_a),
1034 accum_general->beacon_silence_rssi_a,
1035 delta_general->beacon_silence_rssi_a,
1036 max_general->beacon_silence_rssi_a);
1037 pos += scnprintf(buf + pos, bufsz - pos,
1038 fmt_table, "beacon_silence_rssi_b:",
1039 le32_to_cpu(general->beacon_silence_rssi_b),
1040 accum_general->beacon_silence_rssi_b,
1041 delta_general->beacon_silence_rssi_b,
1042 max_general->beacon_silence_rssi_b);
1043 pos += scnprintf(buf + pos, bufsz - pos,
1044 fmt_table, "beacon_silence_rssi_c:",
1045 le32_to_cpu(general->beacon_silence_rssi_c),
1046 accum_general->beacon_silence_rssi_c,
1047 delta_general->beacon_silence_rssi_c,
1048 max_general->beacon_silence_rssi_c);
1049 pos += scnprintf(buf + pos, bufsz - pos,
1050 fmt_table, "interference_data_flag:",
1051 le32_to_cpu(general->interference_data_flag),
1052 accum_general->interference_data_flag,
1053 delta_general->interference_data_flag,
1054 max_general->interference_data_flag);
1055 pos += scnprintf(buf + pos, bufsz - pos,
1056 fmt_table, "channel_load:",
1057 le32_to_cpu(general->channel_load),
1058 accum_general->channel_load,
1059 delta_general->channel_load,
1060 max_general->channel_load);
1061 pos += scnprintf(buf + pos, bufsz - pos,
1062 fmt_table, "dsp_false_alarms:",
1063 le32_to_cpu(general->dsp_false_alarms),
1064 accum_general->dsp_false_alarms,
1065 delta_general->dsp_false_alarms,
1066 max_general->dsp_false_alarms);
1067 pos += scnprintf(buf + pos, bufsz - pos,
1068 fmt_table, "beacon_rssi_a:",
1069 le32_to_cpu(general->beacon_rssi_a),
1070 accum_general->beacon_rssi_a,
1071 delta_general->beacon_rssi_a,
1072 max_general->beacon_rssi_a);
1073 pos += scnprintf(buf + pos, bufsz - pos,
1074 fmt_table, "beacon_rssi_b:",
1075 le32_to_cpu(general->beacon_rssi_b),
1076 accum_general->beacon_rssi_b,
1077 delta_general->beacon_rssi_b,
1078 max_general->beacon_rssi_b);
1079 pos += scnprintf(buf + pos, bufsz - pos,
1080 fmt_table, "beacon_rssi_c:",
1081 le32_to_cpu(general->beacon_rssi_c),
1082 accum_general->beacon_rssi_c,
1083 delta_general->beacon_rssi_c,
1084 max_general->beacon_rssi_c);
1085 pos += scnprintf(buf + pos, bufsz - pos,
1086 fmt_table, "beacon_energy_a:",
1087 le32_to_cpu(general->beacon_energy_a),
1088 accum_general->beacon_energy_a,
1089 delta_general->beacon_energy_a,
1090 max_general->beacon_energy_a);
1091 pos += scnprintf(buf + pos, bufsz - pos,
1092 fmt_table, "beacon_energy_b:",
1093 le32_to_cpu(general->beacon_energy_b),
1094 accum_general->beacon_energy_b,
1095 delta_general->beacon_energy_b,
1096 max_general->beacon_energy_b);
1097 pos += scnprintf(buf + pos, bufsz - pos,
1098 fmt_table, "beacon_energy_c:",
1099 le32_to_cpu(general->beacon_energy_c),
1100 accum_general->beacon_energy_c,
1101 delta_general->beacon_energy_c,
1102 max_general->beacon_energy_c);
1103
1104 pos += scnprintf(buf + pos, bufsz - pos,
1105 fmt_header, "Statistics_Rx - OFDM_HT:");
1106 pos += scnprintf(buf + pos, bufsz - pos,
1107 fmt_table, "plcp_err:",
1108 le32_to_cpu(ht->plcp_err), accum_ht->plcp_err,
1109 delta_ht->plcp_err, max_ht->plcp_err);
1110 pos += scnprintf(buf + pos, bufsz - pos,
1111 fmt_table, "overrun_err:",
1112 le32_to_cpu(ht->overrun_err), accum_ht->overrun_err,
1113 delta_ht->overrun_err, max_ht->overrun_err);
1114 pos += scnprintf(buf + pos, bufsz - pos,
1115 fmt_table, "early_overrun_err:",
1116 le32_to_cpu(ht->early_overrun_err),
1117 accum_ht->early_overrun_err,
1118 delta_ht->early_overrun_err,
1119 max_ht->early_overrun_err);
1120 pos += scnprintf(buf + pos, bufsz - pos,
1121 fmt_table, "crc32_good:",
1122 le32_to_cpu(ht->crc32_good), accum_ht->crc32_good,
1123 delta_ht->crc32_good, max_ht->crc32_good);
1124 pos += scnprintf(buf + pos, bufsz - pos,
1125 fmt_table, "crc32_err:",
1126 le32_to_cpu(ht->crc32_err), accum_ht->crc32_err,
1127 delta_ht->crc32_err, max_ht->crc32_err);
1128 pos += scnprintf(buf + pos, bufsz - pos,
1129 fmt_table, "mh_format_err:",
1130 le32_to_cpu(ht->mh_format_err),
1131 accum_ht->mh_format_err,
1132 delta_ht->mh_format_err, max_ht->mh_format_err);
1133 pos += scnprintf(buf + pos, bufsz - pos,
1134 fmt_table, "agg_crc32_good:",
1135 le32_to_cpu(ht->agg_crc32_good),
1136 accum_ht->agg_crc32_good,
1137 delta_ht->agg_crc32_good, max_ht->agg_crc32_good);
1138 pos += scnprintf(buf + pos, bufsz - pos,
1139 fmt_table, "agg_mpdu_cnt:",
1140 le32_to_cpu(ht->agg_mpdu_cnt),
1141 accum_ht->agg_mpdu_cnt,
1142 delta_ht->agg_mpdu_cnt, max_ht->agg_mpdu_cnt);
1143 pos += scnprintf(buf + pos, bufsz - pos,
1144 fmt_table, "agg_cnt:",
1145 le32_to_cpu(ht->agg_cnt), accum_ht->agg_cnt,
1146 delta_ht->agg_cnt, max_ht->agg_cnt);
1147 pos += scnprintf(buf + pos, bufsz - pos,
1148 fmt_table, "unsupport_mcs:",
1149 le32_to_cpu(ht->unsupport_mcs),
1150 accum_ht->unsupport_mcs,
1151 delta_ht->unsupport_mcs, max_ht->unsupport_mcs);
1152
Johannes Berg4ff70fcd2012-03-05 11:24:26 -08001153 spin_unlock_bh(&priv->statistics.lock);
1154
Wey-Yi Guyd6d023a2011-04-30 09:10:53 -07001155 ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos);
1156 kfree(buf);
1157 return ret;
Wey-Yi Guye8fe59a2009-08-07 15:41:42 -07001158}
1159
1160static ssize_t iwl_dbgfs_ucode_tx_stats_read(struct file *file,
1161 char __user *user_buf,
1162 size_t count, loff_t *ppos)
1163{
H Hartley Sweeten28f63a42010-01-08 16:14:10 -07001164 struct iwl_priv *priv = file->private_data;
Wey-Yi Guyd6d023a2011-04-30 09:10:53 -07001165 int pos = 0;
1166 char *buf;
1167 int bufsz = (sizeof(struct statistics_tx) * 48) + 250;
1168 ssize_t ret;
1169 struct statistics_tx *tx, *accum_tx, *delta_tx, *max_tx;
1170
Don Fry83626402012-03-07 09:52:37 -08001171 if (!iwl_is_alive(priv))
Wey-Yi Guyd6d023a2011-04-30 09:10:53 -07001172 return -EAGAIN;
1173
1174 buf = kzalloc(bufsz, GFP_KERNEL);
Johannes Bergf9e75442012-03-30 09:37:39 +02001175 if (!buf)
Wey-Yi Guyd6d023a2011-04-30 09:10:53 -07001176 return -ENOMEM;
Wey-Yi Guyd6d023a2011-04-30 09:10:53 -07001177
1178 /* the statistic information display here is based on
1179 * the last statistics notification from uCode
1180 * might not reflect the current uCode activity
1181 */
Johannes Berg4ff70fcd2012-03-05 11:24:26 -08001182 spin_lock_bh(&priv->statistics.lock);
1183
Wey-Yi Guyd6d023a2011-04-30 09:10:53 -07001184 tx = &priv->statistics.tx;
1185 accum_tx = &priv->accum_stats.tx;
1186 delta_tx = &priv->delta_stats.tx;
1187 max_tx = &priv->max_delta_stats.tx;
1188
1189 pos += iwl_statistics_flag(priv, buf, bufsz);
1190 pos += scnprintf(buf + pos, bufsz - pos,
1191 fmt_header, "Statistics_Tx:");
1192 pos += scnprintf(buf + pos, bufsz - pos,
1193 fmt_table, "preamble:",
1194 le32_to_cpu(tx->preamble_cnt),
1195 accum_tx->preamble_cnt,
1196 delta_tx->preamble_cnt, max_tx->preamble_cnt);
1197 pos += scnprintf(buf + pos, bufsz - pos,
1198 fmt_table, "rx_detected_cnt:",
1199 le32_to_cpu(tx->rx_detected_cnt),
1200 accum_tx->rx_detected_cnt,
1201 delta_tx->rx_detected_cnt, max_tx->rx_detected_cnt);
1202 pos += scnprintf(buf + pos, bufsz - pos,
1203 fmt_table, "bt_prio_defer_cnt:",
1204 le32_to_cpu(tx->bt_prio_defer_cnt),
1205 accum_tx->bt_prio_defer_cnt,
1206 delta_tx->bt_prio_defer_cnt,
1207 max_tx->bt_prio_defer_cnt);
1208 pos += scnprintf(buf + pos, bufsz - pos,
1209 fmt_table, "bt_prio_kill_cnt:",
1210 le32_to_cpu(tx->bt_prio_kill_cnt),
1211 accum_tx->bt_prio_kill_cnt,
1212 delta_tx->bt_prio_kill_cnt,
1213 max_tx->bt_prio_kill_cnt);
1214 pos += scnprintf(buf + pos, bufsz - pos,
1215 fmt_table, "few_bytes_cnt:",
1216 le32_to_cpu(tx->few_bytes_cnt),
1217 accum_tx->few_bytes_cnt,
1218 delta_tx->few_bytes_cnt, max_tx->few_bytes_cnt);
1219 pos += scnprintf(buf + pos, bufsz - pos,
1220 fmt_table, "cts_timeout:",
1221 le32_to_cpu(tx->cts_timeout), accum_tx->cts_timeout,
1222 delta_tx->cts_timeout, max_tx->cts_timeout);
1223 pos += scnprintf(buf + pos, bufsz - pos,
1224 fmt_table, "ack_timeout:",
1225 le32_to_cpu(tx->ack_timeout),
1226 accum_tx->ack_timeout,
1227 delta_tx->ack_timeout, max_tx->ack_timeout);
1228 pos += scnprintf(buf + pos, bufsz - pos,
1229 fmt_table, "expected_ack_cnt:",
1230 le32_to_cpu(tx->expected_ack_cnt),
1231 accum_tx->expected_ack_cnt,
1232 delta_tx->expected_ack_cnt,
1233 max_tx->expected_ack_cnt);
1234 pos += scnprintf(buf + pos, bufsz - pos,
1235 fmt_table, "actual_ack_cnt:",
1236 le32_to_cpu(tx->actual_ack_cnt),
1237 accum_tx->actual_ack_cnt,
1238 delta_tx->actual_ack_cnt,
1239 max_tx->actual_ack_cnt);
1240 pos += scnprintf(buf + pos, bufsz - pos,
1241 fmt_table, "dump_msdu_cnt:",
1242 le32_to_cpu(tx->dump_msdu_cnt),
1243 accum_tx->dump_msdu_cnt,
1244 delta_tx->dump_msdu_cnt,
1245 max_tx->dump_msdu_cnt);
1246 pos += scnprintf(buf + pos, bufsz - pos,
1247 fmt_table, "abort_nxt_frame_mismatch:",
1248 le32_to_cpu(tx->burst_abort_next_frame_mismatch_cnt),
1249 accum_tx->burst_abort_next_frame_mismatch_cnt,
1250 delta_tx->burst_abort_next_frame_mismatch_cnt,
1251 max_tx->burst_abort_next_frame_mismatch_cnt);
1252 pos += scnprintf(buf + pos, bufsz - pos,
1253 fmt_table, "abort_missing_nxt_frame:",
1254 le32_to_cpu(tx->burst_abort_missing_next_frame_cnt),
1255 accum_tx->burst_abort_missing_next_frame_cnt,
1256 delta_tx->burst_abort_missing_next_frame_cnt,
1257 max_tx->burst_abort_missing_next_frame_cnt);
1258 pos += scnprintf(buf + pos, bufsz - pos,
1259 fmt_table, "cts_timeout_collision:",
1260 le32_to_cpu(tx->cts_timeout_collision),
1261 accum_tx->cts_timeout_collision,
1262 delta_tx->cts_timeout_collision,
1263 max_tx->cts_timeout_collision);
1264 pos += scnprintf(buf + pos, bufsz - pos,
1265 fmt_table, "ack_ba_timeout_collision:",
1266 le32_to_cpu(tx->ack_or_ba_timeout_collision),
1267 accum_tx->ack_or_ba_timeout_collision,
1268 delta_tx->ack_or_ba_timeout_collision,
1269 max_tx->ack_or_ba_timeout_collision);
1270 pos += scnprintf(buf + pos, bufsz - pos,
1271 fmt_table, "agg ba_timeout:",
1272 le32_to_cpu(tx->agg.ba_timeout),
1273 accum_tx->agg.ba_timeout,
1274 delta_tx->agg.ba_timeout,
1275 max_tx->agg.ba_timeout);
1276 pos += scnprintf(buf + pos, bufsz - pos,
1277 fmt_table, "agg ba_resched_frames:",
1278 le32_to_cpu(tx->agg.ba_reschedule_frames),
1279 accum_tx->agg.ba_reschedule_frames,
1280 delta_tx->agg.ba_reschedule_frames,
1281 max_tx->agg.ba_reschedule_frames);
1282 pos += scnprintf(buf + pos, bufsz - pos,
1283 fmt_table, "agg scd_query_agg_frame:",
1284 le32_to_cpu(tx->agg.scd_query_agg_frame_cnt),
1285 accum_tx->agg.scd_query_agg_frame_cnt,
1286 delta_tx->agg.scd_query_agg_frame_cnt,
1287 max_tx->agg.scd_query_agg_frame_cnt);
1288 pos += scnprintf(buf + pos, bufsz - pos,
1289 fmt_table, "agg scd_query_no_agg:",
1290 le32_to_cpu(tx->agg.scd_query_no_agg),
1291 accum_tx->agg.scd_query_no_agg,
1292 delta_tx->agg.scd_query_no_agg,
1293 max_tx->agg.scd_query_no_agg);
1294 pos += scnprintf(buf + pos, bufsz - pos,
1295 fmt_table, "agg scd_query_agg:",
1296 le32_to_cpu(tx->agg.scd_query_agg),
1297 accum_tx->agg.scd_query_agg,
1298 delta_tx->agg.scd_query_agg,
1299 max_tx->agg.scd_query_agg);
1300 pos += scnprintf(buf + pos, bufsz - pos,
1301 fmt_table, "agg scd_query_mismatch:",
1302 le32_to_cpu(tx->agg.scd_query_mismatch),
1303 accum_tx->agg.scd_query_mismatch,
1304 delta_tx->agg.scd_query_mismatch,
1305 max_tx->agg.scd_query_mismatch);
1306 pos += scnprintf(buf + pos, bufsz - pos,
1307 fmt_table, "agg frame_not_ready:",
1308 le32_to_cpu(tx->agg.frame_not_ready),
1309 accum_tx->agg.frame_not_ready,
1310 delta_tx->agg.frame_not_ready,
1311 max_tx->agg.frame_not_ready);
1312 pos += scnprintf(buf + pos, bufsz - pos,
1313 fmt_table, "agg underrun:",
1314 le32_to_cpu(tx->agg.underrun),
1315 accum_tx->agg.underrun,
1316 delta_tx->agg.underrun, max_tx->agg.underrun);
1317 pos += scnprintf(buf + pos, bufsz - pos,
1318 fmt_table, "agg bt_prio_kill:",
1319 le32_to_cpu(tx->agg.bt_prio_kill),
1320 accum_tx->agg.bt_prio_kill,
1321 delta_tx->agg.bt_prio_kill,
1322 max_tx->agg.bt_prio_kill);
1323 pos += scnprintf(buf + pos, bufsz - pos,
1324 fmt_table, "agg rx_ba_rsp_cnt:",
1325 le32_to_cpu(tx->agg.rx_ba_rsp_cnt),
1326 accum_tx->agg.rx_ba_rsp_cnt,
1327 delta_tx->agg.rx_ba_rsp_cnt,
1328 max_tx->agg.rx_ba_rsp_cnt);
1329
1330 if (tx->tx_power.ant_a || tx->tx_power.ant_b || tx->tx_power.ant_c) {
1331 pos += scnprintf(buf + pos, bufsz - pos,
1332 "tx power: (1/2 dB step)\n");
Johannes Berg26a7ca92012-05-21 11:55:54 +02001333 if ((priv->eeprom_data->valid_tx_ant & ANT_A) &&
Johannes Berg7e79a392012-03-05 11:24:32 -08001334 tx->tx_power.ant_a)
Wey-Yi Guyd6d023a2011-04-30 09:10:53 -07001335 pos += scnprintf(buf + pos, bufsz - pos,
1336 fmt_hex, "antenna A:",
1337 tx->tx_power.ant_a);
Johannes Berg26a7ca92012-05-21 11:55:54 +02001338 if ((priv->eeprom_data->valid_tx_ant & ANT_B) &&
Johannes Berg7e79a392012-03-05 11:24:32 -08001339 tx->tx_power.ant_b)
Wey-Yi Guyd6d023a2011-04-30 09:10:53 -07001340 pos += scnprintf(buf + pos, bufsz - pos,
1341 fmt_hex, "antenna B:",
1342 tx->tx_power.ant_b);
Johannes Berg26a7ca92012-05-21 11:55:54 +02001343 if ((priv->eeprom_data->valid_tx_ant & ANT_C) &&
Johannes Berg7e79a392012-03-05 11:24:32 -08001344 tx->tx_power.ant_c)
Wey-Yi Guyd6d023a2011-04-30 09:10:53 -07001345 pos += scnprintf(buf + pos, bufsz - pos,
1346 fmt_hex, "antenna C:",
1347 tx->tx_power.ant_c);
1348 }
Johannes Berg4ff70fcd2012-03-05 11:24:26 -08001349
1350 spin_unlock_bh(&priv->statistics.lock);
1351
Wey-Yi Guyd6d023a2011-04-30 09:10:53 -07001352 ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos);
1353 kfree(buf);
1354 return ret;
Wey-Yi Guye8fe59a2009-08-07 15:41:42 -07001355}
1356
1357static ssize_t iwl_dbgfs_ucode_general_stats_read(struct file *file,
1358 char __user *user_buf,
1359 size_t count, loff_t *ppos)
1360{
H Hartley Sweeten28f63a42010-01-08 16:14:10 -07001361 struct iwl_priv *priv = file->private_data;
Wey-Yi Guyd6d023a2011-04-30 09:10:53 -07001362 int pos = 0;
1363 char *buf;
1364 int bufsz = sizeof(struct statistics_general) * 10 + 300;
1365 ssize_t ret;
1366 struct statistics_general_common *general, *accum_general;
1367 struct statistics_general_common *delta_general, *max_general;
1368 struct statistics_dbg *dbg, *accum_dbg, *delta_dbg, *max_dbg;
1369 struct statistics_div *div, *accum_div, *delta_div, *max_div;
1370
Don Fry83626402012-03-07 09:52:37 -08001371 if (!iwl_is_alive(priv))
Wey-Yi Guyd6d023a2011-04-30 09:10:53 -07001372 return -EAGAIN;
1373
1374 buf = kzalloc(bufsz, GFP_KERNEL);
Johannes Bergf9e75442012-03-30 09:37:39 +02001375 if (!buf)
Wey-Yi Guyd6d023a2011-04-30 09:10:53 -07001376 return -ENOMEM;
Wey-Yi Guyd6d023a2011-04-30 09:10:53 -07001377
1378 /* the statistic information display here is based on
1379 * the last statistics notification from uCode
1380 * might not reflect the current uCode activity
1381 */
Johannes Berg4ff70fcd2012-03-05 11:24:26 -08001382
1383 spin_lock_bh(&priv->statistics.lock);
1384
Wey-Yi Guyd6d023a2011-04-30 09:10:53 -07001385 general = &priv->statistics.common;
1386 dbg = &priv->statistics.common.dbg;
1387 div = &priv->statistics.common.div;
1388 accum_general = &priv->accum_stats.common;
1389 accum_dbg = &priv->accum_stats.common.dbg;
1390 accum_div = &priv->accum_stats.common.div;
1391 delta_general = &priv->delta_stats.common;
1392 max_general = &priv->max_delta_stats.common;
1393 delta_dbg = &priv->delta_stats.common.dbg;
1394 max_dbg = &priv->max_delta_stats.common.dbg;
1395 delta_div = &priv->delta_stats.common.div;
1396 max_div = &priv->max_delta_stats.common.div;
1397
1398 pos += iwl_statistics_flag(priv, buf, bufsz);
1399 pos += scnprintf(buf + pos, bufsz - pos,
1400 fmt_header, "Statistics_General:");
1401 pos += scnprintf(buf + pos, bufsz - pos,
1402 fmt_value, "temperature:",
1403 le32_to_cpu(general->temperature));
1404 pos += scnprintf(buf + pos, bufsz - pos,
1405 fmt_value, "temperature_m:",
1406 le32_to_cpu(general->temperature_m));
1407 pos += scnprintf(buf + pos, bufsz - pos,
1408 fmt_value, "ttl_timestamp:",
1409 le32_to_cpu(general->ttl_timestamp));
1410 pos += scnprintf(buf + pos, bufsz - pos,
1411 fmt_table, "burst_check:",
1412 le32_to_cpu(dbg->burst_check),
1413 accum_dbg->burst_check,
1414 delta_dbg->burst_check, max_dbg->burst_check);
1415 pos += scnprintf(buf + pos, bufsz - pos,
1416 fmt_table, "burst_count:",
1417 le32_to_cpu(dbg->burst_count),
1418 accum_dbg->burst_count,
1419 delta_dbg->burst_count, max_dbg->burst_count);
1420 pos += scnprintf(buf + pos, bufsz - pos,
1421 fmt_table, "wait_for_silence_timeout_count:",
1422 le32_to_cpu(dbg->wait_for_silence_timeout_cnt),
1423 accum_dbg->wait_for_silence_timeout_cnt,
1424 delta_dbg->wait_for_silence_timeout_cnt,
1425 max_dbg->wait_for_silence_timeout_cnt);
1426 pos += scnprintf(buf + pos, bufsz - pos,
1427 fmt_table, "sleep_time:",
1428 le32_to_cpu(general->sleep_time),
1429 accum_general->sleep_time,
1430 delta_general->sleep_time, max_general->sleep_time);
1431 pos += scnprintf(buf + pos, bufsz - pos,
1432 fmt_table, "slots_out:",
1433 le32_to_cpu(general->slots_out),
1434 accum_general->slots_out,
1435 delta_general->slots_out, max_general->slots_out);
1436 pos += scnprintf(buf + pos, bufsz - pos,
1437 fmt_table, "slots_idle:",
1438 le32_to_cpu(general->slots_idle),
1439 accum_general->slots_idle,
1440 delta_general->slots_idle, max_general->slots_idle);
1441 pos += scnprintf(buf + pos, bufsz - pos,
1442 fmt_table, "tx_on_a:",
1443 le32_to_cpu(div->tx_on_a), accum_div->tx_on_a,
1444 delta_div->tx_on_a, max_div->tx_on_a);
1445 pos += scnprintf(buf + pos, bufsz - pos,
1446 fmt_table, "tx_on_b:",
1447 le32_to_cpu(div->tx_on_b), accum_div->tx_on_b,
1448 delta_div->tx_on_b, max_div->tx_on_b);
1449 pos += scnprintf(buf + pos, bufsz - pos,
1450 fmt_table, "exec_time:",
1451 le32_to_cpu(div->exec_time), accum_div->exec_time,
1452 delta_div->exec_time, max_div->exec_time);
1453 pos += scnprintf(buf + pos, bufsz - pos,
1454 fmt_table, "probe_time:",
1455 le32_to_cpu(div->probe_time), accum_div->probe_time,
1456 delta_div->probe_time, max_div->probe_time);
1457 pos += scnprintf(buf + pos, bufsz - pos,
1458 fmt_table, "rx_enable_counter:",
1459 le32_to_cpu(general->rx_enable_counter),
1460 accum_general->rx_enable_counter,
1461 delta_general->rx_enable_counter,
1462 max_general->rx_enable_counter);
1463 pos += scnprintf(buf + pos, bufsz - pos,
1464 fmt_table, "num_of_sos_states:",
1465 le32_to_cpu(general->num_of_sos_states),
1466 accum_general->num_of_sos_states,
1467 delta_general->num_of_sos_states,
1468 max_general->num_of_sos_states);
Johannes Berg4ff70fcd2012-03-05 11:24:26 -08001469
1470 spin_unlock_bh(&priv->statistics.lock);
1471
Wey-Yi Guyd6d023a2011-04-30 09:10:53 -07001472 ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos);
1473 kfree(buf);
1474 return ret;
1475}
1476
1477static ssize_t iwl_dbgfs_ucode_bt_stats_read(struct file *file,
1478 char __user *user_buf,
1479 size_t count, loff_t *ppos)
1480{
1481 struct iwl_priv *priv = (struct iwl_priv *)file->private_data;
1482 int pos = 0;
1483 char *buf;
1484 int bufsz = (sizeof(struct statistics_bt_activity) * 24) + 200;
1485 ssize_t ret;
1486 struct statistics_bt_activity *bt, *accum_bt;
1487
Don Fry83626402012-03-07 09:52:37 -08001488 if (!iwl_is_alive(priv))
Wey-Yi Guyd6d023a2011-04-30 09:10:53 -07001489 return -EAGAIN;
1490
1491 if (!priv->bt_enable_flag)
1492 return -EINVAL;
1493
1494 /* make request to uCode to retrieve statistics information */
Johannes Bergb1eea292012-03-06 13:30:42 -08001495 mutex_lock(&priv->mutex);
Wey-Yi Guyd6d023a2011-04-30 09:10:53 -07001496 ret = iwl_send_statistics_request(priv, CMD_SYNC, false);
Johannes Bergb1eea292012-03-06 13:30:42 -08001497 mutex_unlock(&priv->mutex);
Wey-Yi Guyd6d023a2011-04-30 09:10:53 -07001498
Johannes Bergf9e75442012-03-30 09:37:39 +02001499 if (ret)
Wey-Yi Guyd6d023a2011-04-30 09:10:53 -07001500 return -EAGAIN;
Wey-Yi Guyd6d023a2011-04-30 09:10:53 -07001501 buf = kzalloc(bufsz, GFP_KERNEL);
Johannes Bergf9e75442012-03-30 09:37:39 +02001502 if (!buf)
Wey-Yi Guyd6d023a2011-04-30 09:10:53 -07001503 return -ENOMEM;
Wey-Yi Guyd6d023a2011-04-30 09:10:53 -07001504
1505 /*
1506 * the statistic information display here is based on
1507 * the last statistics notification from uCode
1508 * might not reflect the current uCode activity
1509 */
Johannes Berg4ff70fcd2012-03-05 11:24:26 -08001510
1511 spin_lock_bh(&priv->statistics.lock);
1512
Wey-Yi Guyd6d023a2011-04-30 09:10:53 -07001513 bt = &priv->statistics.bt_activity;
1514 accum_bt = &priv->accum_stats.bt_activity;
1515
1516 pos += iwl_statistics_flag(priv, buf, bufsz);
1517 pos += scnprintf(buf + pos, bufsz - pos, "Statistics_BT:\n");
1518 pos += scnprintf(buf + pos, bufsz - pos,
1519 "\t\t\tcurrent\t\t\taccumulative\n");
1520 pos += scnprintf(buf + pos, bufsz - pos,
1521 "hi_priority_tx_req_cnt:\t\t%u\t\t\t%u\n",
1522 le32_to_cpu(bt->hi_priority_tx_req_cnt),
1523 accum_bt->hi_priority_tx_req_cnt);
1524 pos += scnprintf(buf + pos, bufsz - pos,
1525 "hi_priority_tx_denied_cnt:\t%u\t\t\t%u\n",
1526 le32_to_cpu(bt->hi_priority_tx_denied_cnt),
1527 accum_bt->hi_priority_tx_denied_cnt);
1528 pos += scnprintf(buf + pos, bufsz - pos,
1529 "lo_priority_tx_req_cnt:\t\t%u\t\t\t%u\n",
1530 le32_to_cpu(bt->lo_priority_tx_req_cnt),
1531 accum_bt->lo_priority_tx_req_cnt);
1532 pos += scnprintf(buf + pos, bufsz - pos,
1533 "lo_priority_tx_denied_cnt:\t%u\t\t\t%u\n",
1534 le32_to_cpu(bt->lo_priority_tx_denied_cnt),
1535 accum_bt->lo_priority_tx_denied_cnt);
1536 pos += scnprintf(buf + pos, bufsz - pos,
1537 "hi_priority_rx_req_cnt:\t\t%u\t\t\t%u\n",
1538 le32_to_cpu(bt->hi_priority_rx_req_cnt),
1539 accum_bt->hi_priority_rx_req_cnt);
1540 pos += scnprintf(buf + pos, bufsz - pos,
1541 "hi_priority_rx_denied_cnt:\t%u\t\t\t%u\n",
1542 le32_to_cpu(bt->hi_priority_rx_denied_cnt),
1543 accum_bt->hi_priority_rx_denied_cnt);
1544 pos += scnprintf(buf + pos, bufsz - pos,
1545 "lo_priority_rx_req_cnt:\t\t%u\t\t\t%u\n",
1546 le32_to_cpu(bt->lo_priority_rx_req_cnt),
1547 accum_bt->lo_priority_rx_req_cnt);
1548 pos += scnprintf(buf + pos, bufsz - pos,
1549 "lo_priority_rx_denied_cnt:\t%u\t\t\t%u\n",
1550 le32_to_cpu(bt->lo_priority_rx_denied_cnt),
1551 accum_bt->lo_priority_rx_denied_cnt);
1552
1553 pos += scnprintf(buf + pos, bufsz - pos,
1554 "(rx)num_bt_kills:\t\t%u\t\t\t%u\n",
1555 le32_to_cpu(priv->statistics.num_bt_kills),
1556 priv->statistics.accum_num_bt_kills);
1557
Johannes Berg4ff70fcd2012-03-05 11:24:26 -08001558 spin_unlock_bh(&priv->statistics.lock);
1559
Wey-Yi Guyd6d023a2011-04-30 09:10:53 -07001560 ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos);
1561 kfree(buf);
1562 return ret;
1563}
1564
1565static ssize_t iwl_dbgfs_reply_tx_error_read(struct file *file,
1566 char __user *user_buf,
1567 size_t count, loff_t *ppos)
1568{
1569 struct iwl_priv *priv = (struct iwl_priv *)file->private_data;
1570 int pos = 0;
1571 char *buf;
1572 int bufsz = (sizeof(struct reply_tx_error_statistics) * 24) +
1573 (sizeof(struct reply_agg_tx_error_statistics) * 24) + 200;
1574 ssize_t ret;
1575
Don Fry83626402012-03-07 09:52:37 -08001576 if (!iwl_is_alive(priv))
Wey-Yi Guyd6d023a2011-04-30 09:10:53 -07001577 return -EAGAIN;
1578
1579 buf = kzalloc(bufsz, GFP_KERNEL);
Johannes Bergf9e75442012-03-30 09:37:39 +02001580 if (!buf)
Wey-Yi Guyd6d023a2011-04-30 09:10:53 -07001581 return -ENOMEM;
Wey-Yi Guyd6d023a2011-04-30 09:10:53 -07001582
1583 pos += scnprintf(buf + pos, bufsz - pos, "Statistics_TX_Error:\n");
1584 pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t\t\t%u\n",
1585 iwl_get_tx_fail_reason(TX_STATUS_POSTPONE_DELAY),
Wey-Yi Guy898ed672011-07-13 08:38:57 -07001586 priv->reply_tx_stats.pp_delay);
Wey-Yi Guyd6d023a2011-04-30 09:10:53 -07001587 pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t\t%u\n",
1588 iwl_get_tx_fail_reason(TX_STATUS_POSTPONE_FEW_BYTES),
Wey-Yi Guy898ed672011-07-13 08:38:57 -07001589 priv->reply_tx_stats.pp_few_bytes);
Wey-Yi Guyd6d023a2011-04-30 09:10:53 -07001590 pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t\t%u\n",
1591 iwl_get_tx_fail_reason(TX_STATUS_POSTPONE_BT_PRIO),
Wey-Yi Guy898ed672011-07-13 08:38:57 -07001592 priv->reply_tx_stats.pp_bt_prio);
Wey-Yi Guyd6d023a2011-04-30 09:10:53 -07001593 pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t\t%u\n",
1594 iwl_get_tx_fail_reason(TX_STATUS_POSTPONE_QUIET_PERIOD),
Wey-Yi Guy898ed672011-07-13 08:38:57 -07001595 priv->reply_tx_stats.pp_quiet_period);
Wey-Yi Guyd6d023a2011-04-30 09:10:53 -07001596 pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t\t%u\n",
1597 iwl_get_tx_fail_reason(TX_STATUS_POSTPONE_CALC_TTAK),
Wey-Yi Guy898ed672011-07-13 08:38:57 -07001598 priv->reply_tx_stats.pp_calc_ttak);
Wey-Yi Guyd6d023a2011-04-30 09:10:53 -07001599 pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t%u\n",
1600 iwl_get_tx_fail_reason(
1601 TX_STATUS_FAIL_INTERNAL_CROSSED_RETRY),
Wey-Yi Guy898ed672011-07-13 08:38:57 -07001602 priv->reply_tx_stats.int_crossed_retry);
Wey-Yi Guyd6d023a2011-04-30 09:10:53 -07001603 pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t\t%u\n",
1604 iwl_get_tx_fail_reason(TX_STATUS_FAIL_SHORT_LIMIT),
Wey-Yi Guy898ed672011-07-13 08:38:57 -07001605 priv->reply_tx_stats.short_limit);
Wey-Yi Guyd6d023a2011-04-30 09:10:53 -07001606 pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t\t%u\n",
1607 iwl_get_tx_fail_reason(TX_STATUS_FAIL_LONG_LIMIT),
Wey-Yi Guy898ed672011-07-13 08:38:57 -07001608 priv->reply_tx_stats.long_limit);
Wey-Yi Guyd6d023a2011-04-30 09:10:53 -07001609 pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t\t%u\n",
1610 iwl_get_tx_fail_reason(TX_STATUS_FAIL_FIFO_UNDERRUN),
Wey-Yi Guy898ed672011-07-13 08:38:57 -07001611 priv->reply_tx_stats.fifo_underrun);
Wey-Yi Guyd6d023a2011-04-30 09:10:53 -07001612 pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t\t%u\n",
1613 iwl_get_tx_fail_reason(TX_STATUS_FAIL_DRAIN_FLOW),
Wey-Yi Guy898ed672011-07-13 08:38:57 -07001614 priv->reply_tx_stats.drain_flow);
Wey-Yi Guyd6d023a2011-04-30 09:10:53 -07001615 pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t\t%u\n",
1616 iwl_get_tx_fail_reason(TX_STATUS_FAIL_RFKILL_FLUSH),
Wey-Yi Guy898ed672011-07-13 08:38:57 -07001617 priv->reply_tx_stats.rfkill_flush);
Wey-Yi Guyd6d023a2011-04-30 09:10:53 -07001618 pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t\t%u\n",
1619 iwl_get_tx_fail_reason(TX_STATUS_FAIL_LIFE_EXPIRE),
Wey-Yi Guy898ed672011-07-13 08:38:57 -07001620 priv->reply_tx_stats.life_expire);
Wey-Yi Guyd6d023a2011-04-30 09:10:53 -07001621 pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t\t%u\n",
1622 iwl_get_tx_fail_reason(TX_STATUS_FAIL_DEST_PS),
Wey-Yi Guy898ed672011-07-13 08:38:57 -07001623 priv->reply_tx_stats.dest_ps);
Wey-Yi Guyd6d023a2011-04-30 09:10:53 -07001624 pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t\t%u\n",
1625 iwl_get_tx_fail_reason(TX_STATUS_FAIL_HOST_ABORTED),
Wey-Yi Guy898ed672011-07-13 08:38:57 -07001626 priv->reply_tx_stats.host_abort);
Wey-Yi Guyd6d023a2011-04-30 09:10:53 -07001627 pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t\t%u\n",
1628 iwl_get_tx_fail_reason(TX_STATUS_FAIL_BT_RETRY),
Wey-Yi Guy898ed672011-07-13 08:38:57 -07001629 priv->reply_tx_stats.pp_delay);
Wey-Yi Guyd6d023a2011-04-30 09:10:53 -07001630 pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t\t%u\n",
1631 iwl_get_tx_fail_reason(TX_STATUS_FAIL_STA_INVALID),
Wey-Yi Guy898ed672011-07-13 08:38:57 -07001632 priv->reply_tx_stats.sta_invalid);
Wey-Yi Guyd6d023a2011-04-30 09:10:53 -07001633 pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t\t%u\n",
1634 iwl_get_tx_fail_reason(TX_STATUS_FAIL_FRAG_DROPPED),
Wey-Yi Guy898ed672011-07-13 08:38:57 -07001635 priv->reply_tx_stats.frag_drop);
Wey-Yi Guyd6d023a2011-04-30 09:10:53 -07001636 pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t\t%u\n",
1637 iwl_get_tx_fail_reason(TX_STATUS_FAIL_TID_DISABLE),
Wey-Yi Guy898ed672011-07-13 08:38:57 -07001638 priv->reply_tx_stats.tid_disable);
Wey-Yi Guyd6d023a2011-04-30 09:10:53 -07001639 pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t\t%u\n",
1640 iwl_get_tx_fail_reason(TX_STATUS_FAIL_FIFO_FLUSHED),
Wey-Yi Guy898ed672011-07-13 08:38:57 -07001641 priv->reply_tx_stats.fifo_flush);
Wey-Yi Guyd6d023a2011-04-30 09:10:53 -07001642 pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t%u\n",
1643 iwl_get_tx_fail_reason(
1644 TX_STATUS_FAIL_INSUFFICIENT_CF_POLL),
Wey-Yi Guy898ed672011-07-13 08:38:57 -07001645 priv->reply_tx_stats.insuff_cf_poll);
Wey-Yi Guyd6d023a2011-04-30 09:10:53 -07001646 pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t\t%u\n",
1647 iwl_get_tx_fail_reason(TX_STATUS_FAIL_PASSIVE_NO_RX),
Wey-Yi Guy898ed672011-07-13 08:38:57 -07001648 priv->reply_tx_stats.fail_hw_drop);
Wey-Yi Guyd6d023a2011-04-30 09:10:53 -07001649 pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t%u\n",
1650 iwl_get_tx_fail_reason(
1651 TX_STATUS_FAIL_NO_BEACON_ON_RADAR),
Wey-Yi Guy898ed672011-07-13 08:38:57 -07001652 priv->reply_tx_stats.sta_color_mismatch);
Wey-Yi Guyd6d023a2011-04-30 09:10:53 -07001653 pos += scnprintf(buf + pos, bufsz - pos, "UNKNOWN:\t\t\t%u\n",
Wey-Yi Guy898ed672011-07-13 08:38:57 -07001654 priv->reply_tx_stats.unknown);
Wey-Yi Guyd6d023a2011-04-30 09:10:53 -07001655
1656 pos += scnprintf(buf + pos, bufsz - pos,
1657 "\nStatistics_Agg_TX_Error:\n");
1658
1659 pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t\t%u\n",
1660 iwl_get_agg_tx_fail_reason(AGG_TX_STATE_UNDERRUN_MSK),
Wey-Yi Guy898ed672011-07-13 08:38:57 -07001661 priv->reply_agg_tx_stats.underrun);
Wey-Yi Guyd6d023a2011-04-30 09:10:53 -07001662 pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t\t%u\n",
1663 iwl_get_agg_tx_fail_reason(AGG_TX_STATE_BT_PRIO_MSK),
Wey-Yi Guy898ed672011-07-13 08:38:57 -07001664 priv->reply_agg_tx_stats.bt_prio);
Wey-Yi Guyd6d023a2011-04-30 09:10:53 -07001665 pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t\t%u\n",
1666 iwl_get_agg_tx_fail_reason(AGG_TX_STATE_FEW_BYTES_MSK),
Wey-Yi Guy898ed672011-07-13 08:38:57 -07001667 priv->reply_agg_tx_stats.few_bytes);
Wey-Yi Guyd6d023a2011-04-30 09:10:53 -07001668 pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t\t%u\n",
1669 iwl_get_agg_tx_fail_reason(AGG_TX_STATE_ABORT_MSK),
Wey-Yi Guy898ed672011-07-13 08:38:57 -07001670 priv->reply_agg_tx_stats.abort);
Wey-Yi Guyd6d023a2011-04-30 09:10:53 -07001671 pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t%u\n",
1672 iwl_get_agg_tx_fail_reason(
1673 AGG_TX_STATE_LAST_SENT_TTL_MSK),
Wey-Yi Guy898ed672011-07-13 08:38:57 -07001674 priv->reply_agg_tx_stats.last_sent_ttl);
Wey-Yi Guyd6d023a2011-04-30 09:10:53 -07001675 pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t%u\n",
1676 iwl_get_agg_tx_fail_reason(
1677 AGG_TX_STATE_LAST_SENT_TRY_CNT_MSK),
Wey-Yi Guy898ed672011-07-13 08:38:57 -07001678 priv->reply_agg_tx_stats.last_sent_try);
Wey-Yi Guyd6d023a2011-04-30 09:10:53 -07001679 pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t%u\n",
1680 iwl_get_agg_tx_fail_reason(
1681 AGG_TX_STATE_LAST_SENT_BT_KILL_MSK),
Wey-Yi Guy898ed672011-07-13 08:38:57 -07001682 priv->reply_agg_tx_stats.last_sent_bt_kill);
Wey-Yi Guyd6d023a2011-04-30 09:10:53 -07001683 pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t\t%u\n",
1684 iwl_get_agg_tx_fail_reason(AGG_TX_STATE_SCD_QUERY_MSK),
Wey-Yi Guy898ed672011-07-13 08:38:57 -07001685 priv->reply_agg_tx_stats.scd_query);
Wey-Yi Guyd6d023a2011-04-30 09:10:53 -07001686 pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t%u\n",
1687 iwl_get_agg_tx_fail_reason(
1688 AGG_TX_STATE_TEST_BAD_CRC32_MSK),
Wey-Yi Guy898ed672011-07-13 08:38:57 -07001689 priv->reply_agg_tx_stats.bad_crc32);
Wey-Yi Guyd6d023a2011-04-30 09:10:53 -07001690 pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t\t%u\n",
1691 iwl_get_agg_tx_fail_reason(AGG_TX_STATE_RESPONSE_MSK),
Wey-Yi Guy898ed672011-07-13 08:38:57 -07001692 priv->reply_agg_tx_stats.response);
Wey-Yi Guyd6d023a2011-04-30 09:10:53 -07001693 pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t\t%u\n",
1694 iwl_get_agg_tx_fail_reason(AGG_TX_STATE_DUMP_TX_MSK),
Wey-Yi Guy898ed672011-07-13 08:38:57 -07001695 priv->reply_agg_tx_stats.dump_tx);
Wey-Yi Guyd6d023a2011-04-30 09:10:53 -07001696 pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t\t%u\n",
1697 iwl_get_agg_tx_fail_reason(AGG_TX_STATE_DELAY_TX_MSK),
Wey-Yi Guy898ed672011-07-13 08:38:57 -07001698 priv->reply_agg_tx_stats.delay_tx);
Wey-Yi Guyd6d023a2011-04-30 09:10:53 -07001699 pos += scnprintf(buf + pos, bufsz - pos, "UNKNOWN:\t\t\t%u\n",
Wey-Yi Guy898ed672011-07-13 08:38:57 -07001700 priv->reply_agg_tx_stats.unknown);
Wey-Yi Guyd6d023a2011-04-30 09:10:53 -07001701
1702 ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos);
1703 kfree(buf);
1704 return ret;
Wey-Yi Guye8fe59a2009-08-07 15:41:42 -07001705}
1706
Wey-Yi Guy52259352009-08-07 15:41:43 -07001707static ssize_t iwl_dbgfs_sensitivity_read(struct file *file,
1708 char __user *user_buf,
1709 size_t count, loff_t *ppos) {
1710
H Hartley Sweeten28f63a42010-01-08 16:14:10 -07001711 struct iwl_priv *priv = file->private_data;
Wey-Yi Guy52259352009-08-07 15:41:43 -07001712 int pos = 0;
1713 int cnt = 0;
1714 char *buf;
1715 int bufsz = sizeof(struct iwl_sensitivity_data) * 4 + 100;
1716 ssize_t ret;
1717 struct iwl_sensitivity_data *data;
1718
1719 data = &priv->sensitivity_data;
1720 buf = kzalloc(bufsz, GFP_KERNEL);
Johannes Bergf9e75442012-03-30 09:37:39 +02001721 if (!buf)
Wey-Yi Guy52259352009-08-07 15:41:43 -07001722 return -ENOMEM;
Wey-Yi Guy52259352009-08-07 15:41:43 -07001723
1724 pos += scnprintf(buf + pos, bufsz - pos, "auto_corr_ofdm:\t\t\t %u\n",
1725 data->auto_corr_ofdm);
1726 pos += scnprintf(buf + pos, bufsz - pos,
1727 "auto_corr_ofdm_mrc:\t\t %u\n",
1728 data->auto_corr_ofdm_mrc);
1729 pos += scnprintf(buf + pos, bufsz - pos, "auto_corr_ofdm_x1:\t\t %u\n",
1730 data->auto_corr_ofdm_x1);
1731 pos += scnprintf(buf + pos, bufsz - pos,
1732 "auto_corr_ofdm_mrc_x1:\t\t %u\n",
1733 data->auto_corr_ofdm_mrc_x1);
1734 pos += scnprintf(buf + pos, bufsz - pos, "auto_corr_cck:\t\t\t %u\n",
1735 data->auto_corr_cck);
1736 pos += scnprintf(buf + pos, bufsz - pos, "auto_corr_cck_mrc:\t\t %u\n",
1737 data->auto_corr_cck_mrc);
1738 pos += scnprintf(buf + pos, bufsz - pos,
1739 "last_bad_plcp_cnt_ofdm:\t\t %u\n",
1740 data->last_bad_plcp_cnt_ofdm);
1741 pos += scnprintf(buf + pos, bufsz - pos, "last_fa_cnt_ofdm:\t\t %u\n",
1742 data->last_fa_cnt_ofdm);
1743 pos += scnprintf(buf + pos, bufsz - pos,
1744 "last_bad_plcp_cnt_cck:\t\t %u\n",
1745 data->last_bad_plcp_cnt_cck);
1746 pos += scnprintf(buf + pos, bufsz - pos, "last_fa_cnt_cck:\t\t %u\n",
1747 data->last_fa_cnt_cck);
1748 pos += scnprintf(buf + pos, bufsz - pos, "nrg_curr_state:\t\t\t %u\n",
1749 data->nrg_curr_state);
1750 pos += scnprintf(buf + pos, bufsz - pos, "nrg_prev_state:\t\t\t %u\n",
1751 data->nrg_prev_state);
1752 pos += scnprintf(buf + pos, bufsz - pos, "nrg_value:\t\t\t");
1753 for (cnt = 0; cnt < 10; cnt++) {
1754 pos += scnprintf(buf + pos, bufsz - pos, " %u",
1755 data->nrg_value[cnt]);
1756 }
1757 pos += scnprintf(buf + pos, bufsz - pos, "\n");
1758 pos += scnprintf(buf + pos, bufsz - pos, "nrg_silence_rssi:\t\t");
1759 for (cnt = 0; cnt < NRG_NUM_PREV_STAT_L; cnt++) {
1760 pos += scnprintf(buf + pos, bufsz - pos, " %u",
1761 data->nrg_silence_rssi[cnt]);
1762 }
1763 pos += scnprintf(buf + pos, bufsz - pos, "\n");
1764 pos += scnprintf(buf + pos, bufsz - pos, "nrg_silence_ref:\t\t %u\n",
1765 data->nrg_silence_ref);
1766 pos += scnprintf(buf + pos, bufsz - pos, "nrg_energy_idx:\t\t\t %u\n",
1767 data->nrg_energy_idx);
1768 pos += scnprintf(buf + pos, bufsz - pos, "nrg_silence_idx:\t\t %u\n",
1769 data->nrg_silence_idx);
1770 pos += scnprintf(buf + pos, bufsz - pos, "nrg_th_cck:\t\t\t %u\n",
1771 data->nrg_th_cck);
1772 pos += scnprintf(buf + pos, bufsz - pos,
1773 "nrg_auto_corr_silence_diff:\t %u\n",
1774 data->nrg_auto_corr_silence_diff);
1775 pos += scnprintf(buf + pos, bufsz - pos, "num_in_cck_no_fa:\t\t %u\n",
1776 data->num_in_cck_no_fa);
1777 pos += scnprintf(buf + pos, bufsz - pos, "nrg_th_ofdm:\t\t\t %u\n",
1778 data->nrg_th_ofdm);
1779
1780 ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos);
1781 kfree(buf);
1782 return ret;
1783}
1784
1785
1786static ssize_t iwl_dbgfs_chain_noise_read(struct file *file,
1787 char __user *user_buf,
1788 size_t count, loff_t *ppos) {
1789
H Hartley Sweeten28f63a42010-01-08 16:14:10 -07001790 struct iwl_priv *priv = file->private_data;
Wey-Yi Guy52259352009-08-07 15:41:43 -07001791 int pos = 0;
1792 int cnt = 0;
1793 char *buf;
1794 int bufsz = sizeof(struct iwl_chain_noise_data) * 4 + 100;
1795 ssize_t ret;
1796 struct iwl_chain_noise_data *data;
1797
1798 data = &priv->chain_noise_data;
1799 buf = kzalloc(bufsz, GFP_KERNEL);
Johannes Bergf9e75442012-03-30 09:37:39 +02001800 if (!buf)
Wey-Yi Guy52259352009-08-07 15:41:43 -07001801 return -ENOMEM;
Wey-Yi Guy52259352009-08-07 15:41:43 -07001802
1803 pos += scnprintf(buf + pos, bufsz - pos, "active_chains:\t\t\t %u\n",
1804 data->active_chains);
1805 pos += scnprintf(buf + pos, bufsz - pos, "chain_noise_a:\t\t\t %u\n",
1806 data->chain_noise_a);
1807 pos += scnprintf(buf + pos, bufsz - pos, "chain_noise_b:\t\t\t %u\n",
1808 data->chain_noise_b);
1809 pos += scnprintf(buf + pos, bufsz - pos, "chain_noise_c:\t\t\t %u\n",
1810 data->chain_noise_c);
1811 pos += scnprintf(buf + pos, bufsz - pos, "chain_signal_a:\t\t\t %u\n",
1812 data->chain_signal_a);
1813 pos += scnprintf(buf + pos, bufsz - pos, "chain_signal_b:\t\t\t %u\n",
1814 data->chain_signal_b);
1815 pos += scnprintf(buf + pos, bufsz - pos, "chain_signal_c:\t\t\t %u\n",
1816 data->chain_signal_c);
1817 pos += scnprintf(buf + pos, bufsz - pos, "beacon_count:\t\t\t %u\n",
1818 data->beacon_count);
1819
1820 pos += scnprintf(buf + pos, bufsz - pos, "disconn_array:\t\t\t");
1821 for (cnt = 0; cnt < NUM_RX_CHAINS; cnt++) {
1822 pos += scnprintf(buf + pos, bufsz - pos, " %u",
1823 data->disconn_array[cnt]);
1824 }
1825 pos += scnprintf(buf + pos, bufsz - pos, "\n");
1826 pos += scnprintf(buf + pos, bufsz - pos, "delta_gain_code:\t\t");
1827 for (cnt = 0; cnt < NUM_RX_CHAINS; cnt++) {
1828 pos += scnprintf(buf + pos, bufsz - pos, " %u",
1829 data->delta_gain_code[cnt]);
1830 }
1831 pos += scnprintf(buf + pos, bufsz - pos, "\n");
1832 pos += scnprintf(buf + pos, bufsz - pos, "radio_write:\t\t\t %u\n",
1833 data->radio_write);
1834 pos += scnprintf(buf + pos, bufsz - pos, "state:\t\t\t\t %u\n",
1835 data->state);
1836
1837 ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos);
1838 kfree(buf);
1839 return ret;
1840}
1841
Wey-Yi Guyc09430a2009-10-16 14:25:50 -07001842static ssize_t iwl_dbgfs_power_save_status_read(struct file *file,
1843 char __user *user_buf,
1844 size_t count, loff_t *ppos)
1845{
H Hartley Sweeten28f63a42010-01-08 16:14:10 -07001846 struct iwl_priv *priv = file->private_data;
Wey-Yi Guyc09430a2009-10-16 14:25:50 -07001847 char buf[60];
1848 int pos = 0;
1849 const size_t bufsz = sizeof(buf);
1850 u32 pwrsave_status;
1851
Emmanuel Grumbach68e8dfd2012-04-18 07:28:17 -07001852 pwrsave_status = iwl_read32(priv->trans, CSR_GP_CNTRL) &
Wey-Yi Guyc09430a2009-10-16 14:25:50 -07001853 CSR_GP_REG_POWER_SAVE_STATUS_MSK;
1854
1855 pos += scnprintf(buf + pos, bufsz - pos, "Power Save Status: ");
1856 pos += scnprintf(buf + pos, bufsz - pos, "%s\n",
1857 (pwrsave_status == CSR_GP_REG_NO_POWER_SAVE) ? "none" :
1858 (pwrsave_status == CSR_GP_REG_MAC_POWER_SAVE) ? "MAC" :
1859 (pwrsave_status == CSR_GP_REG_PHY_POWER_SAVE) ? "PHY" :
1860 "error");
1861
1862 return simple_read_from_buffer(user_buf, count, ppos, buf, pos);
1863}
1864
Wey-Yi Guy7163b8a2009-11-20 12:04:56 -08001865static ssize_t iwl_dbgfs_clear_ucode_statistics_write(struct file *file,
Wey-Yi Guyef8d5522009-11-13 11:56:28 -08001866 const char __user *user_buf,
1867 size_t count, loff_t *ppos)
1868{
1869 struct iwl_priv *priv = file->private_data;
1870 char buf[8];
1871 int buf_size;
1872 int clear;
1873
1874 memset(buf, 0, sizeof(buf));
1875 buf_size = min(count, sizeof(buf) - 1);
1876 if (copy_from_user(buf, user_buf, buf_size))
1877 return -EFAULT;
1878 if (sscanf(buf, "%d", &clear) != 1)
1879 return -EFAULT;
1880
1881 /* make request to uCode to retrieve statistics information */
Johannes Bergb1eea292012-03-06 13:30:42 -08001882 mutex_lock(&priv->mutex);
Wey-Yi Guyef8d5522009-11-13 11:56:28 -08001883 iwl_send_statistics_request(priv, CMD_SYNC, true);
Johannes Bergb1eea292012-03-06 13:30:42 -08001884 mutex_unlock(&priv->mutex);
Wey-Yi Guyef8d5522009-11-13 11:56:28 -08001885
1886 return count;
1887}
1888
Wey-Yi Guya9e1cb62009-12-10 14:37:26 -08001889static ssize_t iwl_dbgfs_ucode_tracing_read(struct file *file,
1890 char __user *user_buf,
1891 size_t count, loff_t *ppos) {
1892
Joe Perches57674302010-07-12 13:50:06 -07001893 struct iwl_priv *priv = file->private_data;
Wey-Yi Guya9e1cb62009-12-10 14:37:26 -08001894 int pos = 0;
1895 char buf[128];
1896 const size_t bufsz = sizeof(buf);
Wey-Yi Guya9e1cb62009-12-10 14:37:26 -08001897
1898 pos += scnprintf(buf + pos, bufsz - pos, "ucode trace timer is %s\n",
1899 priv->event_log.ucode_trace ? "On" : "Off");
1900 pos += scnprintf(buf + pos, bufsz - pos, "non_wraps_count:\t\t %u\n",
1901 priv->event_log.non_wraps_count);
1902 pos += scnprintf(buf + pos, bufsz - pos, "wraps_once_count:\t\t %u\n",
1903 priv->event_log.wraps_once_count);
1904 pos += scnprintf(buf + pos, bufsz - pos, "wraps_more_count:\t\t %u\n",
1905 priv->event_log.wraps_more_count);
1906
Wey-Yi Guy4967c312010-02-18 15:22:07 -08001907 return simple_read_from_buffer(user_buf, count, ppos, buf, pos);
Wey-Yi Guya9e1cb62009-12-10 14:37:26 -08001908}
1909
1910static ssize_t iwl_dbgfs_ucode_tracing_write(struct file *file,
1911 const char __user *user_buf,
1912 size_t count, loff_t *ppos)
1913{
1914 struct iwl_priv *priv = file->private_data;
1915 char buf[8];
1916 int buf_size;
1917 int trace;
1918
1919 memset(buf, 0, sizeof(buf));
1920 buf_size = min(count, sizeof(buf) - 1);
1921 if (copy_from_user(buf, user_buf, buf_size))
1922 return -EFAULT;
1923 if (sscanf(buf, "%d", &trace) != 1)
1924 return -EFAULT;
1925
1926 if (trace) {
1927 priv->event_log.ucode_trace = true;
Don Fry83626402012-03-07 09:52:37 -08001928 if (iwl_is_alive(priv)) {
Johannes Berg98d4bf02012-01-13 11:56:11 +01001929 /* start collecting data now */
1930 mod_timer(&priv->ucode_trace, jiffies);
1931 }
Wey-Yi Guya9e1cb62009-12-10 14:37:26 -08001932 } else {
1933 priv->event_log.ucode_trace = false;
1934 del_timer_sync(&priv->ucode_trace);
1935 }
1936
1937 return count;
1938}
1939
Johannes Berg60987202010-02-18 00:36:07 -08001940static ssize_t iwl_dbgfs_rxon_flags_read(struct file *file,
1941 char __user *user_buf,
1942 size_t count, loff_t *ppos) {
1943
Joe Perches57674302010-07-12 13:50:06 -07001944 struct iwl_priv *priv = file->private_data;
Johannes Berg60987202010-02-18 00:36:07 -08001945 int len = 0;
1946 char buf[20];
1947
Johannes Berg246ed352010-08-23 10:46:32 +02001948 len = sprintf(buf, "0x%04X\n",
1949 le32_to_cpu(priv->contexts[IWL_RXON_CTX_BSS].active.flags));
Johannes Berg60987202010-02-18 00:36:07 -08001950 return simple_read_from_buffer(user_buf, count, ppos, buf, len);
1951}
1952
1953static ssize_t iwl_dbgfs_rxon_filter_flags_read(struct file *file,
1954 char __user *user_buf,
1955 size_t count, loff_t *ppos) {
1956
Joe Perches57674302010-07-12 13:50:06 -07001957 struct iwl_priv *priv = file->private_data;
Johannes Berg60987202010-02-18 00:36:07 -08001958 int len = 0;
1959 char buf[20];
1960
1961 len = sprintf(buf, "0x%04X\n",
Johannes Berg246ed352010-08-23 10:46:32 +02001962 le32_to_cpu(priv->contexts[IWL_RXON_CTX_BSS].active.filter_flags));
Johannes Berg60987202010-02-18 00:36:07 -08001963 return simple_read_from_buffer(user_buf, count, ppos, buf, len);
1964}
1965
Wey-Yi Guya13d2762010-01-22 14:22:42 -08001966static ssize_t iwl_dbgfs_missed_beacon_read(struct file *file,
1967 char __user *user_buf,
1968 size_t count, loff_t *ppos) {
1969
1970 struct iwl_priv *priv = file->private_data;
1971 int pos = 0;
1972 char buf[12];
1973 const size_t bufsz = sizeof(buf);
Wey-Yi Guya13d2762010-01-22 14:22:42 -08001974
1975 pos += scnprintf(buf + pos, bufsz - pos, "%d\n",
1976 priv->missed_beacon_threshold);
1977
Wey-Yi Guy4967c312010-02-18 15:22:07 -08001978 return simple_read_from_buffer(user_buf, count, ppos, buf, pos);
Wey-Yi Guya13d2762010-01-22 14:22:42 -08001979}
1980
1981static ssize_t iwl_dbgfs_missed_beacon_write(struct file *file,
1982 const char __user *user_buf,
1983 size_t count, loff_t *ppos)
1984{
1985 struct iwl_priv *priv = file->private_data;
1986 char buf[8];
1987 int buf_size;
1988 int missed;
1989
1990 memset(buf, 0, sizeof(buf));
1991 buf_size = min(count, sizeof(buf) - 1);
1992 if (copy_from_user(buf, user_buf, buf_size))
1993 return -EFAULT;
1994 if (sscanf(buf, "%d", &missed) != 1)
1995 return -EINVAL;
1996
1997 if (missed < IWL_MISSED_BEACON_THRESHOLD_MIN ||
1998 missed > IWL_MISSED_BEACON_THRESHOLD_MAX)
1999 priv->missed_beacon_threshold =
2000 IWL_MISSED_BEACON_THRESHOLD_DEF;
2001 else
2002 priv->missed_beacon_threshold = missed;
2003
2004 return count;
2005}
2006
Trieu 'Andrew' Nguyen3e4fb5f2010-01-22 14:22:46 -08002007static ssize_t iwl_dbgfs_plcp_delta_read(struct file *file,
2008 char __user *user_buf,
2009 size_t count, loff_t *ppos) {
2010
Joe Perches57674302010-07-12 13:50:06 -07002011 struct iwl_priv *priv = file->private_data;
Trieu 'Andrew' Nguyen3e4fb5f2010-01-22 14:22:46 -08002012 int pos = 0;
2013 char buf[12];
2014 const size_t bufsz = sizeof(buf);
Trieu 'Andrew' Nguyen3e4fb5f2010-01-22 14:22:46 -08002015
2016 pos += scnprintf(buf + pos, bufsz - pos, "%u\n",
Johannes Bergab5c0f12012-03-06 13:30:53 -08002017 priv->plcp_delta_threshold);
Trieu 'Andrew' Nguyen3e4fb5f2010-01-22 14:22:46 -08002018
Wey-Yi Guy4967c312010-02-18 15:22:07 -08002019 return simple_read_from_buffer(user_buf, count, ppos, buf, pos);
Trieu 'Andrew' Nguyen3e4fb5f2010-01-22 14:22:46 -08002020}
2021
2022static ssize_t iwl_dbgfs_plcp_delta_write(struct file *file,
2023 const char __user *user_buf,
2024 size_t count, loff_t *ppos) {
2025
2026 struct iwl_priv *priv = file->private_data;
2027 char buf[8];
2028 int buf_size;
2029 int plcp;
2030
2031 memset(buf, 0, sizeof(buf));
2032 buf_size = min(count, sizeof(buf) - 1);
2033 if (copy_from_user(buf, user_buf, buf_size))
2034 return -EFAULT;
2035 if (sscanf(buf, "%d", &plcp) != 1)
2036 return -EINVAL;
Wey-Yi Guy680788a2010-06-17 15:25:00 -07002037 if ((plcp < IWL_MAX_PLCP_ERR_THRESHOLD_MIN) ||
Trieu 'Andrew' Nguyen3e4fb5f2010-01-22 14:22:46 -08002038 (plcp > IWL_MAX_PLCP_ERR_THRESHOLD_MAX))
Johannes Bergab5c0f12012-03-06 13:30:53 -08002039 priv->plcp_delta_threshold =
Wey-Yi Guy680788a2010-06-17 15:25:00 -07002040 IWL_MAX_PLCP_ERR_THRESHOLD_DISABLE;
Trieu 'Andrew' Nguyen3e4fb5f2010-01-22 14:22:46 -08002041 else
Johannes Bergab5c0f12012-03-06 13:30:53 -08002042 priv->plcp_delta_threshold = plcp;
Trieu 'Andrew' Nguyen3e4fb5f2010-01-22 14:22:46 -08002043 return count;
2044}
2045
Johannes Berg48dffd32012-04-09 17:46:57 -07002046static ssize_t iwl_dbgfs_rf_reset_read(struct file *file,
2047 char __user *user_buf,
2048 size_t count, loff_t *ppos)
Johannes Bergca934b62011-09-15 11:46:48 -07002049{
Wey-Yi Guy528c3122010-02-18 22:03:07 -08002050 struct iwl_priv *priv = file->private_data;
Johannes Berg48dffd32012-04-09 17:46:57 -07002051 int pos = 0;
Wey-Yi Guy528c3122010-02-18 22:03:07 -08002052 char buf[300];
2053 const size_t bufsz = sizeof(buf);
Johannes Berg48dffd32012-04-09 17:46:57 -07002054 struct iwl_rf_reset *rf_reset = &priv->rf_reset;
Wey-Yi Guy528c3122010-02-18 22:03:07 -08002055
Johannes Berg48dffd32012-04-09 17:46:57 -07002056 pos += scnprintf(buf + pos, bufsz - pos,
2057 "RF reset statistics\n");
2058 pos += scnprintf(buf + pos, bufsz - pos,
2059 "\tnumber of reset request: %d\n",
2060 rf_reset->reset_request_count);
2061 pos += scnprintf(buf + pos, bufsz - pos,
2062 "\tnumber of reset request success: %d\n",
2063 rf_reset->reset_success_count);
2064 pos += scnprintf(buf + pos, bufsz - pos,
2065 "\tnumber of reset request reject: %d\n",
2066 rf_reset->reset_reject_count);
2067
Wey-Yi Guy528c3122010-02-18 22:03:07 -08002068 return simple_read_from_buffer(user_buf, count, ppos, buf, pos);
2069}
2070
Johannes Berg48dffd32012-04-09 17:46:57 -07002071static ssize_t iwl_dbgfs_rf_reset_write(struct file *file,
Wey-Yi Guy04cafd72010-02-03 11:47:20 -08002072 const char __user *user_buf,
2073 size_t count, loff_t *ppos) {
2074
2075 struct iwl_priv *priv = file->private_data;
Johannes Berg48dffd32012-04-09 17:46:57 -07002076 int ret;
Wey-Yi Guy04cafd72010-02-03 11:47:20 -08002077
Johannes Berg48dffd32012-04-09 17:46:57 -07002078 ret = iwl_force_rf_reset(priv, true);
Wey-Yi Guy04cafd72010-02-03 11:47:20 -08002079 return ret ? ret : count;
2080}
2081
Wey-Yi Guy4bf49a92010-06-24 13:18:36 -07002082static ssize_t iwl_dbgfs_txfifo_flush_write(struct file *file,
2083 const char __user *user_buf,
2084 size_t count, loff_t *ppos) {
2085
2086 struct iwl_priv *priv = file->private_data;
2087 char buf[8];
2088 int buf_size;
2089 int flush;
2090
2091 memset(buf, 0, sizeof(buf));
2092 buf_size = min(count, sizeof(buf) - 1);
2093 if (copy_from_user(buf, user_buf, buf_size))
2094 return -EFAULT;
2095 if (sscanf(buf, "%d", &flush) != 1)
2096 return -EINVAL;
2097
Don Fry83626402012-03-07 09:52:37 -08002098 if (iwl_is_rfkill(priv))
Wey-Yi Guy4bf49a92010-06-24 13:18:36 -07002099 return -EFAULT;
2100
Wey-Yi Guyc68744f2011-06-18 08:03:18 -07002101 iwlagn_dev_txfifo_flush(priv, IWL_DROP_ALL);
Wey-Yi Guy4bf49a92010-06-24 13:18:36 -07002102
2103 return count;
2104}
2105
Wey-Yi Guybefe8c42010-08-23 07:57:16 -07002106static ssize_t iwl_dbgfs_bt_traffic_read(struct file *file,
2107 char __user *user_buf,
2108 size_t count, loff_t *ppos) {
2109
2110 struct iwl_priv *priv = (struct iwl_priv *)file->private_data;
2111 int pos = 0;
2112 char buf[200];
2113 const size_t bufsz = sizeof(buf);
Wey-Yi Guybefe8c42010-08-23 07:57:16 -07002114
Wey-Yi Guyf21dd002010-12-08 15:34:52 -08002115 if (!priv->bt_enable_flag) {
2116 pos += scnprintf(buf + pos, bufsz - pos, "BT coex disabled\n");
Johannes Berg08960de2011-04-05 09:41:53 -07002117 return simple_read_from_buffer(user_buf, count, ppos, buf, pos);
Wey-Yi Guyf21dd002010-12-08 15:34:52 -08002118 }
2119 pos += scnprintf(buf + pos, bufsz - pos, "BT enable flag: 0x%x\n",
2120 priv->bt_enable_flag);
Wey-Yi Guybefe8c42010-08-23 07:57:16 -07002121 pos += scnprintf(buf + pos, bufsz - pos, "BT in %s mode\n",
2122 priv->bt_full_concurrent ? "full concurrency" : "3-wire");
2123 pos += scnprintf(buf + pos, bufsz - pos, "BT status: %s, "
2124 "last traffic notif: %d\n",
Wey-Yi Guy66e863a52010-11-08 14:54:37 -08002125 priv->bt_status ? "On" : "Off", priv->last_bt_traffic_load);
Wey-Yi Guybefe8c42010-08-23 07:57:16 -07002126 pos += scnprintf(buf + pos, bufsz - pos, "ch_announcement: %d, "
Wey-Yi Guy187bc4f2011-01-27 13:01:33 -08002127 "kill_ack_mask: %x, kill_cts_mask: %x\n",
2128 priv->bt_ch_announce, priv->kill_ack_mask,
2129 priv->kill_cts_mask);
Wey-Yi Guybefe8c42010-08-23 07:57:16 -07002130
2131 pos += scnprintf(buf + pos, bufsz - pos, "bluetooth traffic load: ");
2132 switch (priv->bt_traffic_load) {
2133 case IWL_BT_COEX_TRAFFIC_LOAD_CONTINUOUS:
2134 pos += scnprintf(buf + pos, bufsz - pos, "Continuous\n");
2135 break;
2136 case IWL_BT_COEX_TRAFFIC_LOAD_HIGH:
2137 pos += scnprintf(buf + pos, bufsz - pos, "High\n");
2138 break;
2139 case IWL_BT_COEX_TRAFFIC_LOAD_LOW:
2140 pos += scnprintf(buf + pos, bufsz - pos, "Low\n");
2141 break;
2142 case IWL_BT_COEX_TRAFFIC_LOAD_NONE:
2143 default:
2144 pos += scnprintf(buf + pos, bufsz - pos, "None\n");
2145 break;
2146 }
2147
Johannes Berg08960de2011-04-05 09:41:53 -07002148 return simple_read_from_buffer(user_buf, count, ppos, buf, pos);
Wey-Yi Guybefe8c42010-08-23 07:57:16 -07002149}
2150
Wey-Yi Guyc6abdc02010-09-01 17:10:51 -07002151static ssize_t iwl_dbgfs_protection_mode_read(struct file *file,
2152 char __user *user_buf,
2153 size_t count, loff_t *ppos)
2154{
2155 struct iwl_priv *priv = (struct iwl_priv *)file->private_data;
2156
2157 int pos = 0;
2158 char buf[40];
2159 const size_t bufsz = sizeof(buf);
2160
Emmanuel Grumbach21522682012-03-22 17:51:44 +02002161 if (priv->cfg->ht_params)
Wey-Yi Guy7cb1b082010-10-06 08:10:00 -07002162 pos += scnprintf(buf + pos, bufsz - pos,
2163 "use %s for aggregation\n",
Johannes Berg9e295112012-04-09 17:46:55 -07002164 (priv->hw_params.use_rts_for_aggregation) ?
Wey-Yi Guy7cb1b082010-10-06 08:10:00 -07002165 "rts/cts" : "cts-to-self");
2166 else
2167 pos += scnprintf(buf + pos, bufsz - pos, "N/A");
2168
Wey-Yi Guyc6abdc02010-09-01 17:10:51 -07002169 return simple_read_from_buffer(user_buf, count, ppos, buf, pos);
2170}
2171
2172static ssize_t iwl_dbgfs_protection_mode_write(struct file *file,
2173 const char __user *user_buf,
2174 size_t count, loff_t *ppos) {
2175
2176 struct iwl_priv *priv = file->private_data;
2177 char buf[8];
2178 int buf_size;
2179 int rts;
2180
Emmanuel Grumbach21522682012-03-22 17:51:44 +02002181 if (!priv->cfg->ht_params)
Wey-Yi Guy7cb1b082010-10-06 08:10:00 -07002182 return -EINVAL;
2183
Wey-Yi Guyc6abdc02010-09-01 17:10:51 -07002184 memset(buf, 0, sizeof(buf));
2185 buf_size = min(count, sizeof(buf) - 1);
2186 if (copy_from_user(buf, user_buf, buf_size))
2187 return -EFAULT;
2188 if (sscanf(buf, "%d", &rts) != 1)
2189 return -EINVAL;
2190 if (rts)
Johannes Berg9e295112012-04-09 17:46:55 -07002191 priv->hw_params.use_rts_for_aggregation = true;
Wey-Yi Guyc6abdc02010-09-01 17:10:51 -07002192 else
Johannes Berg9e295112012-04-09 17:46:55 -07002193 priv->hw_params.use_rts_for_aggregation = false;
Wey-Yi Guyc6abdc02010-09-01 17:10:51 -07002194 return count;
2195}
2196
Johannes Bergc98c8d92012-04-02 15:15:58 +02002197static int iwl_cmd_echo_test(struct iwl_priv *priv)
2198{
2199 int ret;
2200 struct iwl_host_cmd cmd = {
2201 .id = REPLY_ECHO,
2202 .len = { 0 },
2203 .flags = CMD_SYNC,
2204 };
2205
2206 ret = iwl_dvm_send_cmd(priv, &cmd);
2207 if (ret)
2208 IWL_ERR(priv, "echo testing fail: 0X%x\n", ret);
2209 else
2210 IWL_DEBUG_INFO(priv, "echo testing pass\n");
2211 return ret;
2212}
2213
Wey-Yi Guy7e4005c2011-10-10 07:26:51 -07002214static ssize_t iwl_dbgfs_echo_test_write(struct file *file,
2215 const char __user *user_buf,
2216 size_t count, loff_t *ppos)
2217{
2218 struct iwl_priv *priv = file->private_data;
2219 char buf[8];
2220 int buf_size;
2221
2222 memset(buf, 0, sizeof(buf));
2223 buf_size = min(count, sizeof(buf) - 1);
2224 if (copy_from_user(buf, user_buf, buf_size))
2225 return -EFAULT;
2226
2227 iwl_cmd_echo_test(priv);
2228 return count;
2229}
2230
Meenakshi Venkataraman2fdfc472012-03-15 13:26:56 -07002231static ssize_t iwl_dbgfs_log_event_read(struct file *file,
2232 char __user *user_buf,
2233 size_t count, loff_t *ppos)
2234{
2235 struct iwl_priv *priv = file->private_data;
2236 char *buf;
2237 int pos = 0;
2238 ssize_t ret = -ENOMEM;
2239
2240 ret = pos = iwl_dump_nic_event_log(priv, true, &buf, true);
2241 if (buf) {
2242 ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos);
2243 kfree(buf);
2244 }
2245 return ret;
2246}
2247
2248static ssize_t iwl_dbgfs_log_event_write(struct file *file,
2249 const char __user *user_buf,
2250 size_t count, loff_t *ppos)
2251{
2252 struct iwl_priv *priv = file->private_data;
2253 u32 event_log_flag;
2254 char buf[8];
2255 int buf_size;
2256
Richard A. Griffiths0ff1bd32012-06-28 13:14:11 -07002257 /* check that the interface is up */
2258 if (!iwl_is_ready(priv))
2259 return -EAGAIN;
2260
Meenakshi Venkataraman2fdfc472012-03-15 13:26:56 -07002261 memset(buf, 0, sizeof(buf));
2262 buf_size = min(count, sizeof(buf) - 1);
2263 if (copy_from_user(buf, user_buf, buf_size))
2264 return -EFAULT;
2265 if (sscanf(buf, "%d", &event_log_flag) != 1)
2266 return -EFAULT;
2267 if (event_log_flag == 1)
2268 iwl_dump_nic_event_log(priv, true, NULL, false);
2269
2270 return count;
2271}
2272
Dor Shaishbfb45f52012-03-26 08:20:55 -07002273static ssize_t iwl_dbgfs_calib_disabled_read(struct file *file,
2274 char __user *user_buf,
2275 size_t count, loff_t *ppos)
2276{
2277 struct iwl_priv *priv = file->private_data;
2278 char buf[120];
2279 int pos = 0;
2280 const size_t bufsz = sizeof(buf);
2281
2282 pos += scnprintf(buf + pos, bufsz - pos,
2283 "Sensitivity calibrations %s\n",
2284 (priv->calib_disabled &
2285 IWL_SENSITIVITY_CALIB_DISABLED) ?
2286 "DISABLED" : "ENABLED");
2287 pos += scnprintf(buf + pos, bufsz - pos,
2288 "Chain noise calibrations %s\n",
2289 (priv->calib_disabled &
2290 IWL_CHAIN_NOISE_CALIB_DISABLED) ?
2291 "DISABLED" : "ENABLED");
2292 pos += scnprintf(buf + pos, bufsz - pos,
2293 "Tx power calibrations %s\n",
2294 (priv->calib_disabled &
2295 IWL_TX_POWER_CALIB_DISABLED) ?
2296 "DISABLED" : "ENABLED");
2297
2298 return simple_read_from_buffer(user_buf, count, ppos, buf, pos);
2299}
2300
David Spinadel647ad132012-03-31 08:31:05 -07002301static ssize_t iwl_dbgfs_calib_disabled_write(struct file *file,
2302 const char __user *user_buf,
2303 size_t count, loff_t *ppos)
2304{
2305 struct iwl_priv *priv = file->private_data;
2306 char buf[8];
2307 u32 calib_disabled;
2308 int buf_size;
2309
2310 memset(buf, 0, sizeof(buf));
2311 buf_size = min(count, sizeof(buf) - 1);
2312 if (copy_from_user(buf, user_buf, buf_size))
2313 return -EFAULT;
2314 if (sscanf(buf, "%x", &calib_disabled) != 1)
2315 return -EFAULT;
2316
2317 priv->calib_disabled = calib_disabled;
2318
2319 return count;
2320}
2321
Wey-Yi Guye8fe59a2009-08-07 15:41:42 -07002322DEBUGFS_READ_FILE_OPS(ucode_rx_stats);
2323DEBUGFS_READ_FILE_OPS(ucode_tx_stats);
2324DEBUGFS_READ_FILE_OPS(ucode_general_stats);
Wey-Yi Guy52259352009-08-07 15:41:43 -07002325DEBUGFS_READ_FILE_OPS(sensitivity);
2326DEBUGFS_READ_FILE_OPS(chain_noise);
Wey-Yi Guyc09430a2009-10-16 14:25:50 -07002327DEBUGFS_READ_FILE_OPS(power_save_status);
Wey-Yi Guy7163b8a2009-11-20 12:04:56 -08002328DEBUGFS_WRITE_FILE_OPS(clear_ucode_statistics);
Wey-Yi Guya9e1cb62009-12-10 14:37:26 -08002329DEBUGFS_READ_WRITE_FILE_OPS(ucode_tracing);
Wey-Yi Guya13d2762010-01-22 14:22:42 -08002330DEBUGFS_READ_WRITE_FILE_OPS(missed_beacon);
Trieu 'Andrew' Nguyen3e4fb5f2010-01-22 14:22:46 -08002331DEBUGFS_READ_WRITE_FILE_OPS(plcp_delta);
Johannes Berg48dffd32012-04-09 17:46:57 -07002332DEBUGFS_READ_WRITE_FILE_OPS(rf_reset);
Johannes Berg60987202010-02-18 00:36:07 -08002333DEBUGFS_READ_FILE_OPS(rxon_flags);
2334DEBUGFS_READ_FILE_OPS(rxon_filter_flags);
Wey-Yi Guy4bf49a92010-06-24 13:18:36 -07002335DEBUGFS_WRITE_FILE_OPS(txfifo_flush);
Wey-Yi Guyffb7d892010-07-14 08:09:55 -07002336DEBUGFS_READ_FILE_OPS(ucode_bt_stats);
Wey-Yi Guybefe8c42010-08-23 07:57:16 -07002337DEBUGFS_READ_FILE_OPS(bt_traffic);
Wey-Yi Guyc6abdc02010-09-01 17:10:51 -07002338DEBUGFS_READ_WRITE_FILE_OPS(protection_mode);
Wey-Yi Guy54a9aa62010-09-05 10:49:42 -07002339DEBUGFS_READ_FILE_OPS(reply_tx_error);
Wey-Yi Guy7e4005c2011-10-10 07:26:51 -07002340DEBUGFS_WRITE_FILE_OPS(echo_test);
Meenakshi Venkataraman2fdfc472012-03-15 13:26:56 -07002341DEBUGFS_READ_WRITE_FILE_OPS(log_event);
David Spinadel647ad132012-03-31 08:31:05 -07002342DEBUGFS_READ_WRITE_FILE_OPS(calib_disabled);
Wey-Yi Guy20594eb2009-08-07 15:41:39 -07002343
Tomas Winkler712b6cf2008-03-12 16:58:52 -07002344/*
2345 * Create the debugfs files and directories
2346 *
2347 */
2348int iwl_dbgfs_register(struct iwl_priv *priv, const char *name)
2349{
Zhu Yi95b1a822008-05-29 16:34:50 +08002350 struct dentry *phyd = priv->hw->wiphy->debugfsdir;
Johannes Berg4c84a8f2010-01-22 14:22:54 -08002351 struct dentry *dir_drv, *dir_data, *dir_rf, *dir_debug;
Tomas Winkler712b6cf2008-03-12 16:58:52 -07002352
Johannes Berg4c84a8f2010-01-22 14:22:54 -08002353 dir_drv = debugfs_create_dir(name, phyd);
2354 if (!dir_drv)
2355 return -ENOMEM;
2356
2357 priv->debugfs_dir = dir_drv;
2358
2359 dir_data = debugfs_create_dir("data", dir_drv);
2360 if (!dir_data)
Tomas Winkler712b6cf2008-03-12 16:58:52 -07002361 goto err;
Johannes Berg4c84a8f2010-01-22 14:22:54 -08002362 dir_rf = debugfs_create_dir("rf", dir_drv);
2363 if (!dir_rf)
Tomas Winkler712b6cf2008-03-12 16:58:52 -07002364 goto err;
Johannes Berg4c84a8f2010-01-22 14:22:54 -08002365 dir_debug = debugfs_create_dir("debug", dir_drv);
2366 if (!dir_debug)
2367 goto err;
Tomas Winkler712b6cf2008-03-12 16:58:52 -07002368
Johannes Berg4c84a8f2010-01-22 14:22:54 -08002369 DEBUGFS_ADD_FILE(nvm, dir_data, S_IRUSR);
2370 DEBUGFS_ADD_FILE(sram, dir_data, S_IWUSR | S_IRUSR);
Johannes Bergc8ac61c2011-07-15 13:23:45 -07002371 DEBUGFS_ADD_FILE(wowlan_sram, dir_data, S_IRUSR);
Johannes Berg4c84a8f2010-01-22 14:22:54 -08002372 DEBUGFS_ADD_FILE(stations, dir_data, S_IRUSR);
2373 DEBUGFS_ADD_FILE(channels, dir_data, S_IRUSR);
2374 DEBUGFS_ADD_FILE(status, dir_data, S_IRUSR);
Emmanuel Grumbach1f7b6172011-08-25 23:10:59 -07002375 DEBUGFS_ADD_FILE(rx_handlers, dir_data, S_IWUSR | S_IRUSR);
Johannes Berg4c84a8f2010-01-22 14:22:54 -08002376 DEBUGFS_ADD_FILE(qos, dir_data, S_IRUSR);
Wey-Yi Guy23c0fcc2011-04-01 16:29:53 -07002377 DEBUGFS_ADD_FILE(sleep_level_override, dir_data, S_IWUSR | S_IRUSR);
2378 DEBUGFS_ADD_FILE(current_sleep_command, dir_data, S_IRUSR);
Johannes Berg4c84a8f2010-01-22 14:22:54 -08002379 DEBUGFS_ADD_FILE(thermal_throttling, dir_data, S_IRUSR);
2380 DEBUGFS_ADD_FILE(disable_ht40, dir_data, S_IWUSR | S_IRUSR);
Emmanuel Grumbach511afa32011-09-22 07:15:37 -07002381 DEBUGFS_ADD_FILE(temperature, dir_data, S_IRUSR);
Johannes Bergca934b62011-09-15 11:46:48 -07002382
Johannes Berg4c84a8f2010-01-22 14:22:54 -08002383 DEBUGFS_ADD_FILE(power_save_status, dir_debug, S_IRUSR);
2384 DEBUGFS_ADD_FILE(clear_ucode_statistics, dir_debug, S_IWUSR);
Johannes Berg4c84a8f2010-01-22 14:22:54 -08002385 DEBUGFS_ADD_FILE(missed_beacon, dir_debug, S_IWUSR);
Johannes Berg4c84a8f2010-01-22 14:22:54 -08002386 DEBUGFS_ADD_FILE(plcp_delta, dir_debug, S_IWUSR | S_IRUSR);
Johannes Berg48dffd32012-04-09 17:46:57 -07002387 DEBUGFS_ADD_FILE(rf_reset, dir_debug, S_IWUSR | S_IRUSR);
Abhijeet Kolekarb8c76262010-04-08 15:29:07 -07002388 DEBUGFS_ADD_FILE(ucode_rx_stats, dir_debug, S_IRUSR);
2389 DEBUGFS_ADD_FILE(ucode_tx_stats, dir_debug, S_IRUSR);
2390 DEBUGFS_ADD_FILE(ucode_general_stats, dir_debug, S_IRUSR);
Wey-Yi Guyc68744f2011-06-18 08:03:18 -07002391 DEBUGFS_ADD_FILE(txfifo_flush, dir_debug, S_IWUSR);
Wey-Yi Guyc6abdc02010-09-01 17:10:51 -07002392 DEBUGFS_ADD_FILE(protection_mode, dir_debug, S_IWUSR | S_IRUSR);
Wey-Yi Guy703bc582011-04-03 08:14:41 -07002393 DEBUGFS_ADD_FILE(sensitivity, dir_debug, S_IRUSR);
2394 DEBUGFS_ADD_FILE(chain_noise, dir_debug, S_IRUSR);
Wey-Yi Guyb7af6a92011-04-06 15:55:25 -07002395 DEBUGFS_ADD_FILE(ucode_tracing, dir_debug, S_IWUSR | S_IRUSR);
Johannes Berg0da0e5b2011-04-08 08:14:56 -07002396 DEBUGFS_ADD_FILE(ucode_bt_stats, dir_debug, S_IRUSR);
Wey-Yi Guy54a9aa62010-09-05 10:49:42 -07002397 DEBUGFS_ADD_FILE(reply_tx_error, dir_debug, S_IRUSR);
Johannes Berg60987202010-02-18 00:36:07 -08002398 DEBUGFS_ADD_FILE(rxon_flags, dir_debug, S_IWUSR);
2399 DEBUGFS_ADD_FILE(rxon_filter_flags, dir_debug, S_IWUSR);
Wey-Yi Guy7e4005c2011-10-10 07:26:51 -07002400 DEBUGFS_ADD_FILE(echo_test, dir_debug, S_IWUSR);
Meenakshi Venkataraman2fdfc472012-03-15 13:26:56 -07002401 DEBUGFS_ADD_FILE(log_event, dir_debug, S_IWUSR | S_IRUSR);
2402
Stanislaw Gruszka88e58fc2011-01-28 16:47:47 +01002403 if (iwl_advanced_bt_coexist(priv))
Wey-Yi Guybefe8c42010-08-23 07:57:16 -07002404 DEBUGFS_ADD_FILE(bt_traffic, dir_debug, S_IRUSR);
Johannes Bergca934b62011-09-15 11:46:48 -07002405
Dor Shaishbfb45f52012-03-26 08:20:55 -07002406 /* Calibrations disabled/enabled status*/
David Spinadel647ad132012-03-31 08:31:05 -07002407 DEBUGFS_ADD_FILE(calib_disabled, dir_rf, S_IWUSR | S_IRUSR);
Emmanuel Grumbach87e56662011-08-25 23:10:50 -07002408
Emmanuel Grumbach68e8dfd2012-04-18 07:28:17 -07002409 if (iwl_trans_dbgfs_register(priv->trans, dir_debug))
Emmanuel Grumbach87e56662011-08-25 23:10:50 -07002410 goto err;
Tomas Winkler712b6cf2008-03-12 16:58:52 -07002411 return 0;
2412
2413err:
Johannes Berg4c84a8f2010-01-22 14:22:54 -08002414 IWL_ERR(priv, "Can't create the debugfs directory\n");
Tomas Winkler712b6cf2008-03-12 16:58:52 -07002415 iwl_dbgfs_unregister(priv);
Johannes Berg4c84a8f2010-01-22 14:22:54 -08002416 return -ENOMEM;
Tomas Winkler712b6cf2008-03-12 16:58:52 -07002417}
Tomas Winkler712b6cf2008-03-12 16:58:52 -07002418
2419/**
2420 * Remove the debugfs files and directories
2421 *
2422 */
2423void iwl_dbgfs_unregister(struct iwl_priv *priv)
2424{
Johannes Berg4c84a8f2010-01-22 14:22:54 -08002425 if (!priv->debugfs_dir)
Tomas Winkler712b6cf2008-03-12 16:58:52 -07002426 return;
2427
Johannes Berg4c84a8f2010-01-22 14:22:54 -08002428 debugfs_remove_recursive(priv->debugfs_dir);
2429 priv->debugfs_dir = NULL;
Tomas Winkler712b6cf2008-03-12 16:58:52 -07002430}