blob: 2268adddf4c05b60b5170666369ad1a22f94b01b [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 = { \
86 .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;
Emmanuel Grumbach21522682012-03-22 17:51:44 +0200306 size_t eeprom_len = priv->cfg->base_params->eeprom_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 Berg11483b52012-04-09 17:46:58 -0700312 ptr = priv->eeprom;
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 Berg11483b52012-04-09 17:46:58 -0700321 eeprom_ver = iwl_eeprom_query16(priv, EEPROM_VERSION);
Wey-Yi Guye307ddc2009-09-11 10:38:16 -0700322 pos += scnprintf(buf + pos, buf_size - pos, "NVM Type: %s, "
323 "version: 0x%x\n",
Johannes Berg11483b52012-04-09 17:46:58 -0700324 (priv->nvm_device_type == NVM_DEVICE_TYPE_OTP)
Wey-Yi Guye307ddc2009-09-11 10:38:16 -0700325 ? "OTP" : "EEPROM", eeprom_ver);
Tomas Winkler8dd266e2008-05-05 10:22:32 +0800326 for (ofs = 0 ; ofs < eeprom_len ; ofs += 16) {
327 pos += scnprintf(buf + pos, buf_size - pos, "0x%.4x ", ofs);
328 hex_dump_to_buffer(ptr + ofs, 16 , 16, 2, buf + pos,
329 buf_size - pos, 0);
Reinette Chatre2fac9712009-09-25 14:24:21 -0700330 pos += strlen(buf + pos);
Tomas Winkler8dd266e2008-05-05 10:22:32 +0800331 if (buf_size - pos > 0)
332 buf[pos++] = '\n';
333 }
334
335 ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos);
336 kfree(buf);
337 return ret;
338}
Tomas Winkler712b6cf2008-03-12 16:58:52 -0700339
Winkler, Tomasd366df52008-12-02 12:14:01 -0800340static ssize_t iwl_dbgfs_channels_read(struct file *file, char __user *user_buf,
341 size_t count, loff_t *ppos)
342{
H Hartley Sweeten28f63a42010-01-08 16:14:10 -0700343 struct iwl_priv *priv = file->private_data;
Winkler, Tomasd366df52008-12-02 12:14:01 -0800344 struct ieee80211_channel *channels = NULL;
345 const struct ieee80211_supported_band *supp_band = NULL;
346 int pos = 0, i, bufsz = PAGE_SIZE;
347 char *buf;
348 ssize_t ret;
349
Don Fry83626402012-03-07 09:52:37 -0800350 if (!test_bit(STATUS_GEO_CONFIGURED, &priv->status))
Winkler, Tomasd366df52008-12-02 12:14:01 -0800351 return -EAGAIN;
352
353 buf = kzalloc(bufsz, GFP_KERNEL);
Johannes Bergf9e75442012-03-30 09:37:39 +0200354 if (!buf)
Winkler, Tomasd366df52008-12-02 12:14:01 -0800355 return -ENOMEM;
Winkler, Tomasd366df52008-12-02 12:14:01 -0800356
357 supp_band = iwl_get_hw_mode(priv, IEEE80211_BAND_2GHZ);
Wey-Yi Guya2e23222009-05-22 11:01:55 -0700358 if (supp_band) {
359 channels = supp_band->channels;
Winkler, Tomasd366df52008-12-02 12:14:01 -0800360
Winkler, Tomasd366df52008-12-02 12:14:01 -0800361 pos += scnprintf(buf + pos, bufsz - pos,
Wey-Yi Guya2e23222009-05-22 11:01:55 -0700362 "Displaying %d channels in 2.4GHz band 802.11bg):\n",
363 supp_band->n_channels);
Winkler, Tomasd366df52008-12-02 12:14:01 -0800364
Wey-Yi Guya2e23222009-05-22 11:01:55 -0700365 for (i = 0; i < supp_band->n_channels; i++)
366 pos += scnprintf(buf + pos, bufsz - pos,
367 "%d: %ddBm: BSS%s%s, %s.\n",
Shanyu Zhao81e95432010-07-28 13:40:27 -0700368 channels[i].hw_value,
Wey-Yi Guya2e23222009-05-22 11:01:55 -0700369 channels[i].max_power,
370 channels[i].flags & IEEE80211_CHAN_RADAR ?
371 " (IEEE 802.11h required)" : "",
372 ((channels[i].flags & IEEE80211_CHAN_NO_IBSS)
373 || (channels[i].flags &
374 IEEE80211_CHAN_RADAR)) ? "" :
375 ", IBSS",
376 channels[i].flags &
377 IEEE80211_CHAN_PASSIVE_SCAN ?
378 "passive only" : "active/passive");
379 }
Winkler, Tomasd366df52008-12-02 12:14:01 -0800380 supp_band = iwl_get_hw_mode(priv, IEEE80211_BAND_5GHZ);
Wey-Yi Guya2e23222009-05-22 11:01:55 -0700381 if (supp_band) {
382 channels = supp_band->channels;
Winkler, Tomasd366df52008-12-02 12:14:01 -0800383
Winkler, Tomasd366df52008-12-02 12:14:01 -0800384 pos += scnprintf(buf + pos, bufsz - pos,
Wey-Yi Guya2e23222009-05-22 11:01:55 -0700385 "Displaying %d channels in 5.2GHz band (802.11a)\n",
386 supp_band->n_channels);
387
388 for (i = 0; i < supp_band->n_channels; i++)
389 pos += scnprintf(buf + pos, bufsz - pos,
390 "%d: %ddBm: BSS%s%s, %s.\n",
Shanyu Zhao81e95432010-07-28 13:40:27 -0700391 channels[i].hw_value,
Wey-Yi Guya2e23222009-05-22 11:01:55 -0700392 channels[i].max_power,
393 channels[i].flags & IEEE80211_CHAN_RADAR ?
394 " (IEEE 802.11h required)" : "",
395 ((channels[i].flags & IEEE80211_CHAN_NO_IBSS)
396 || (channels[i].flags &
397 IEEE80211_CHAN_RADAR)) ? "" :
398 ", IBSS",
399 channels[i].flags &
400 IEEE80211_CHAN_PASSIVE_SCAN ?
401 "passive only" : "active/passive");
402 }
Winkler, Tomasd366df52008-12-02 12:14:01 -0800403 ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos);
404 kfree(buf);
405 return ret;
406}
407
Wey-Yi Guy08df05a2009-03-24 10:02:54 -0700408static ssize_t iwl_dbgfs_status_read(struct file *file,
409 char __user *user_buf,
410 size_t count, loff_t *ppos) {
411
H Hartley Sweeten28f63a42010-01-08 16:14:10 -0700412 struct iwl_priv *priv = file->private_data;
Wey-Yi Guy08df05a2009-03-24 10:02:54 -0700413 char buf[512];
414 int pos = 0;
415 const size_t bufsz = sizeof(buf);
416
Wey-Yi Guy08df05a2009-03-24 10:02:54 -0700417 pos += scnprintf(buf + pos, bufsz - pos, "STATUS_RF_KILL_HW:\t %d\n",
Don Fry83626402012-03-07 09:52:37 -0800418 test_bit(STATUS_RF_KILL_HW, &priv->status));
Wey-Yi Guy7812b162009-10-02 13:43:58 -0700419 pos += scnprintf(buf + pos, bufsz - pos, "STATUS_CT_KILL:\t\t %d\n",
Don Fry9a716862012-03-07 09:52:32 -0800420 test_bit(STATUS_CT_KILL, &priv->status));
Wey-Yi Guy08df05a2009-03-24 10:02:54 -0700421 pos += scnprintf(buf + pos, bufsz - pos, "STATUS_ALIVE:\t\t %d\n",
Don Fry83626402012-03-07 09:52:37 -0800422 test_bit(STATUS_ALIVE, &priv->status));
Wey-Yi Guy08df05a2009-03-24 10:02:54 -0700423 pos += scnprintf(buf + pos, bufsz - pos, "STATUS_READY:\t\t %d\n",
Don Fry83626402012-03-07 09:52:37 -0800424 test_bit(STATUS_READY, &priv->status));
Wey-Yi Guy08df05a2009-03-24 10:02:54 -0700425 pos += scnprintf(buf + pos, bufsz - pos, "STATUS_GEO_CONFIGURED:\t %d\n",
Don Fry83626402012-03-07 09:52:37 -0800426 test_bit(STATUS_GEO_CONFIGURED, &priv->status));
Wey-Yi Guy08df05a2009-03-24 10:02:54 -0700427 pos += scnprintf(buf + pos, bufsz - pos, "STATUS_EXIT_PENDING:\t %d\n",
Don Fry83626402012-03-07 09:52:37 -0800428 test_bit(STATUS_EXIT_PENDING, &priv->status));
Wey-Yi Guy08df05a2009-03-24 10:02:54 -0700429 pos += scnprintf(buf + pos, bufsz - pos, "STATUS_STATISTICS:\t %d\n",
Don Fry83626402012-03-07 09:52:37 -0800430 test_bit(STATUS_STATISTICS, &priv->status));
Wey-Yi Guy08df05a2009-03-24 10:02:54 -0700431 pos += scnprintf(buf + pos, bufsz - pos, "STATUS_SCANNING:\t %d\n",
Don Fry83626402012-03-07 09:52:37 -0800432 test_bit(STATUS_SCANNING, &priv->status));
Wey-Yi Guy08df05a2009-03-24 10:02:54 -0700433 pos += scnprintf(buf + pos, bufsz - pos, "STATUS_SCAN_ABORTING:\t %d\n",
Don Fry83626402012-03-07 09:52:37 -0800434 test_bit(STATUS_SCAN_ABORTING, &priv->status));
Wey-Yi Guy08df05a2009-03-24 10:02:54 -0700435 pos += scnprintf(buf + pos, bufsz - pos, "STATUS_SCAN_HW:\t\t %d\n",
Don Fry83626402012-03-07 09:52:37 -0800436 test_bit(STATUS_SCAN_HW, &priv->status));
Wey-Yi Guy08df05a2009-03-24 10:02:54 -0700437 pos += scnprintf(buf + pos, bufsz - pos, "STATUS_POWER_PMI:\t %d\n",
Don Fry47107e82012-03-15 13:27:06 -0700438 test_bit(STATUS_POWER_PMI, &priv->status));
Wey-Yi Guy08df05a2009-03-24 10:02:54 -0700439 pos += scnprintf(buf + pos, bufsz - pos, "STATUS_FW_ERROR:\t %d\n",
Don Fry17acd0b2012-03-15 13:27:05 -0700440 test_bit(STATUS_FW_ERROR, &priv->status));
Wey-Yi Guy08df05a2009-03-24 10:02:54 -0700441 return simple_read_from_buffer(user_buf, count, ppos, buf, pos);
442}
443
Emmanuel Grumbach1f7b6172011-08-25 23:10:59 -0700444static ssize_t iwl_dbgfs_rx_handlers_read(struct file *file,
Wey-Yi Guya83b9142009-04-08 11:39:32 -0700445 char __user *user_buf,
446 size_t count, loff_t *ppos) {
447
H Hartley Sweeten28f63a42010-01-08 16:14:10 -0700448 struct iwl_priv *priv = file->private_data;
Emmanuel Grumbach1f7b6172011-08-25 23:10:59 -0700449
Wey-Yi Guya83b9142009-04-08 11:39:32 -0700450 int pos = 0;
451 int cnt = 0;
452 char *buf;
453 int bufsz = 24 * 64; /* 24 items * 64 char per item */
454 ssize_t ret;
455
456 buf = kzalloc(bufsz, GFP_KERNEL);
Johannes Bergf9e75442012-03-30 09:37:39 +0200457 if (!buf)
Wey-Yi Guya83b9142009-04-08 11:39:32 -0700458 return -ENOMEM;
Wey-Yi Guya83b9142009-04-08 11:39:32 -0700459
Wey-Yi Guya83b9142009-04-08 11:39:32 -0700460 for (cnt = 0; cnt < REPLY_MAX; cnt++) {
Emmanuel Grumbach1f7b6172011-08-25 23:10:59 -0700461 if (priv->rx_handlers_stats[cnt] > 0)
Wey-Yi Guya83b9142009-04-08 11:39:32 -0700462 pos += scnprintf(buf + pos, bufsz - pos,
463 "\tRx handler[%36s]:\t\t %u\n",
Johannes Bergd9fb6462012-03-26 08:23:39 -0700464 iwl_dvm_get_cmd_string(cnt),
Emmanuel Grumbach1f7b6172011-08-25 23:10:59 -0700465 priv->rx_handlers_stats[cnt]);
Wey-Yi Guya83b9142009-04-08 11:39:32 -0700466 }
467
Wey-Yi Guya83b9142009-04-08 11:39:32 -0700468 ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos);
469 kfree(buf);
470 return ret;
471}
472
Emmanuel Grumbach1f7b6172011-08-25 23:10:59 -0700473static ssize_t iwl_dbgfs_rx_handlers_write(struct file *file,
Wey-Yi Guya83b9142009-04-08 11:39:32 -0700474 const char __user *user_buf,
475 size_t count, loff_t *ppos)
476{
477 struct iwl_priv *priv = file->private_data;
Emmanuel Grumbach1f7b6172011-08-25 23:10:59 -0700478
Wey-Yi Guya83b9142009-04-08 11:39:32 -0700479 char buf[8];
480 int buf_size;
481 u32 reset_flag;
482
483 memset(buf, 0, sizeof(buf));
484 buf_size = min(count, sizeof(buf) - 1);
485 if (copy_from_user(buf, user_buf, buf_size))
486 return -EFAULT;
487 if (sscanf(buf, "%x", &reset_flag) != 1)
488 return -EFAULT;
489 if (reset_flag == 0)
Emmanuel Grumbach1f7b6172011-08-25 23:10:59 -0700490 memset(&priv->rx_handlers_stats[0], 0,
491 sizeof(priv->rx_handlers_stats));
Wey-Yi Guya83b9142009-04-08 11:39:32 -0700492
493 return count;
494}
495
Wey-Yi Guyf5ad69f2009-07-09 10:33:36 -0700496static ssize_t iwl_dbgfs_qos_read(struct file *file, char __user *user_buf,
497 size_t count, loff_t *ppos)
498{
H Hartley Sweeten28f63a42010-01-08 16:14:10 -0700499 struct iwl_priv *priv = file->private_data;
Johannes Berg8dfdb9d2010-08-23 10:46:38 +0200500 struct iwl_rxon_context *ctx;
Wey-Yi Guyf5ad69f2009-07-09 10:33:36 -0700501 int pos = 0, i;
Johannes Berg8dfdb9d2010-08-23 10:46:38 +0200502 char buf[256 * NUM_IWL_RXON_CTX];
Wey-Yi Guyf5ad69f2009-07-09 10:33:36 -0700503 const size_t bufsz = sizeof(buf);
Wey-Yi Guyf5ad69f2009-07-09 10:33:36 -0700504
Johannes Berg8dfdb9d2010-08-23 10:46:38 +0200505 for_each_context(priv, ctx) {
506 pos += scnprintf(buf + pos, bufsz - pos, "context %d:\n",
507 ctx->ctxid);
508 for (i = 0; i < AC_NUM; i++) {
509 pos += scnprintf(buf + pos, bufsz - pos,
510 "\tcw_min\tcw_max\taifsn\ttxop\n");
511 pos += scnprintf(buf + pos, bufsz - pos,
Wey-Yi Guyf5ad69f2009-07-09 10:33:36 -0700512 "AC[%d]\t%u\t%u\t%u\t%u\n", i,
Johannes Berg8dfdb9d2010-08-23 10:46:38 +0200513 ctx->qos_data.def_qos_parm.ac[i].cw_min,
514 ctx->qos_data.def_qos_parm.ac[i].cw_max,
515 ctx->qos_data.def_qos_parm.ac[i].aifsn,
516 ctx->qos_data.def_qos_parm.ac[i].edca_txop);
517 }
518 pos += scnprintf(buf + pos, bufsz - pos, "\n");
Wey-Yi Guyf5ad69f2009-07-09 10:33:36 -0700519 }
Wey-Yi Guy4967c312010-02-18 15:22:07 -0800520 return simple_read_from_buffer(user_buf, count, ppos, buf, pos);
Wey-Yi Guyf5ad69f2009-07-09 10:33:36 -0700521}
Wey-Yi Guya83b9142009-04-08 11:39:32 -0700522
Wey-Yi Guyfbf3a2a2009-07-24 11:13:04 -0700523static ssize_t iwl_dbgfs_thermal_throttling_read(struct file *file,
524 char __user *user_buf,
525 size_t count, loff_t *ppos)
526{
H Hartley Sweeten28f63a42010-01-08 16:14:10 -0700527 struct iwl_priv *priv = file->private_data;
Johannes Berg3ad3b922009-08-07 15:41:48 -0700528 struct iwl_tt_mgmt *tt = &priv->thermal_throttle;
Wey-Yi Guyfbf3a2a2009-07-24 11:13:04 -0700529 struct iwl_tt_restriction *restriction;
530 char buf[100];
531 int pos = 0;
532 const size_t bufsz = sizeof(buf);
Wey-Yi Guyfbf3a2a2009-07-24 11:13:04 -0700533
534 pos += scnprintf(buf + pos, bufsz - pos,
535 "Thermal Throttling Mode: %s\n",
Johannes Berg3ad3b922009-08-07 15:41:48 -0700536 tt->advanced_tt ? "Advance" : "Legacy");
Wey-Yi Guyfbf3a2a2009-07-24 11:13:04 -0700537 pos += scnprintf(buf + pos, bufsz - pos,
538 "Thermal Throttling State: %d\n",
539 tt->state);
Johannes Berg3ad3b922009-08-07 15:41:48 -0700540 if (tt->advanced_tt) {
Wey-Yi Guyfbf3a2a2009-07-24 11:13:04 -0700541 restriction = tt->restriction + tt->state;
542 pos += scnprintf(buf + pos, bufsz - pos,
543 "Tx mode: %d\n",
544 restriction->tx_stream);
545 pos += scnprintf(buf + pos, bufsz - pos,
546 "Rx mode: %d\n",
547 restriction->rx_stream);
548 pos += scnprintf(buf + pos, bufsz - pos,
549 "HT mode: %d\n",
550 restriction->is_ht);
551 }
Wey-Yi Guy4967c312010-02-18 15:22:07 -0800552 return simple_read_from_buffer(user_buf, count, ppos, buf, pos);
Wey-Yi Guyfbf3a2a2009-07-24 11:13:04 -0700553}
554
Wey-Yi Guy1e4247d2009-07-27 13:50:15 -0700555static ssize_t iwl_dbgfs_disable_ht40_write(struct file *file,
556 const char __user *user_buf,
557 size_t count, loff_t *ppos)
558{
559 struct iwl_priv *priv = file->private_data;
560 char buf[8];
561 int buf_size;
562 int ht40;
563
564 memset(buf, 0, sizeof(buf));
565 buf_size = min(count, sizeof(buf) - 1);
566 if (copy_from_user(buf, user_buf, buf_size))
567 return -EFAULT;
568 if (sscanf(buf, "%d", &ht40) != 1)
569 return -EFAULT;
Johannes Berg246ed352010-08-23 10:46:32 +0200570 if (!iwl_is_any_associated(priv))
Wey-Yi Guy1e4247d2009-07-27 13:50:15 -0700571 priv->disable_ht40 = ht40 ? true : false;
Johannes Bergf9e75442012-03-30 09:37:39 +0200572 else
Wey-Yi Guy1e4247d2009-07-27 13:50:15 -0700573 return -EINVAL;
Wey-Yi Guy1e4247d2009-07-27 13:50:15 -0700574
575 return count;
576}
577
578static ssize_t iwl_dbgfs_disable_ht40_read(struct file *file,
579 char __user *user_buf,
580 size_t count, loff_t *ppos)
581{
H Hartley Sweeten28f63a42010-01-08 16:14:10 -0700582 struct iwl_priv *priv = file->private_data;
Wey-Yi Guy1e4247d2009-07-27 13:50:15 -0700583 char buf[100];
584 int pos = 0;
585 const size_t bufsz = sizeof(buf);
Wey-Yi Guy1e4247d2009-07-27 13:50:15 -0700586
587 pos += scnprintf(buf + pos, bufsz - pos,
588 "11n 40MHz Mode: %s\n",
589 priv->disable_ht40 ? "Disabled" : "Enabled");
Wey-Yi Guy4967c312010-02-18 15:22:07 -0800590 return simple_read_from_buffer(user_buf, count, ppos, buf, pos);
Wey-Yi Guy1e4247d2009-07-27 13:50:15 -0700591}
592
Emmanuel Grumbach511afa32011-09-22 07:15:37 -0700593static ssize_t iwl_dbgfs_temperature_read(struct file *file,
594 char __user *user_buf,
595 size_t count, loff_t *ppos)
596{
597 struct iwl_priv *priv = file->private_data;
598 char buf[8];
599 int pos = 0;
600 const size_t bufsz = sizeof(buf);
601
602 pos += scnprintf(buf + pos, bufsz - pos, "%d\n", priv->temperature);
603 return simple_read_from_buffer(user_buf, count, ppos, buf, pos);
604}
605
606
Johannes Berge312c242009-08-07 15:41:51 -0700607static ssize_t iwl_dbgfs_sleep_level_override_write(struct file *file,
608 const char __user *user_buf,
609 size_t count, loff_t *ppos)
610{
611 struct iwl_priv *priv = file->private_data;
612 char buf[8];
613 int buf_size;
614 int value;
615
616 memset(buf, 0, sizeof(buf));
617 buf_size = min(count, sizeof(buf) - 1);
618 if (copy_from_user(buf, user_buf, buf_size))
619 return -EFAULT;
620
621 if (sscanf(buf, "%d", &value) != 1)
622 return -EINVAL;
623
624 /*
625 * Our users expect 0 to be "CAM", but 0 isn't actually
626 * valid here. However, let's not confuse them and present
627 * IWL_POWER_INDEX_1 as "1", not "0".
628 */
Reinette Chatre1a34c042009-10-09 13:20:25 -0700629 if (value == 0)
630 return -EINVAL;
631 else if (value > 0)
Johannes Berge312c242009-08-07 15:41:51 -0700632 value -= 1;
633
634 if (value != -1 && (value < 0 || value >= IWL_POWER_NUM))
635 return -EINVAL;
636
Don Fry83626402012-03-07 09:52:37 -0800637 if (!iwl_is_ready_rf(priv))
Wey-Yi Guy4ad177b2009-10-16 14:25:58 -0700638 return -EAGAIN;
639
Johannes Berge312c242009-08-07 15:41:51 -0700640 priv->power_data.debug_sleep_level_override = value;
641
Johannes Bergb1eea292012-03-06 13:30:42 -0800642 mutex_lock(&priv->mutex);
Wey-Yi Guy4ad177b2009-10-16 14:25:58 -0700643 iwl_power_update_mode(priv, true);
Johannes Bergb1eea292012-03-06 13:30:42 -0800644 mutex_unlock(&priv->mutex);
Johannes Berge312c242009-08-07 15:41:51 -0700645
646 return count;
647}
648
649static ssize_t iwl_dbgfs_sleep_level_override_read(struct file *file,
650 char __user *user_buf,
651 size_t count, loff_t *ppos)
652{
H Hartley Sweeten28f63a42010-01-08 16:14:10 -0700653 struct iwl_priv *priv = file->private_data;
Johannes Berge312c242009-08-07 15:41:51 -0700654 char buf[10];
655 int pos, value;
656 const size_t bufsz = sizeof(buf);
657
658 /* see the write function */
659 value = priv->power_data.debug_sleep_level_override;
660 if (value >= 0)
661 value += 1;
662
663 pos = scnprintf(buf, bufsz, "%d\n", value);
664 return simple_read_from_buffer(user_buf, count, ppos, buf, pos);
665}
666
667static ssize_t iwl_dbgfs_current_sleep_command_read(struct file *file,
668 char __user *user_buf,
669 size_t count, loff_t *ppos)
670{
H Hartley Sweeten28f63a42010-01-08 16:14:10 -0700671 struct iwl_priv *priv = file->private_data;
Johannes Berge312c242009-08-07 15:41:51 -0700672 char buf[200];
673 int pos = 0, i;
674 const size_t bufsz = sizeof(buf);
675 struct iwl_powertable_cmd *cmd = &priv->power_data.sleep_cmd;
676
677 pos += scnprintf(buf + pos, bufsz - pos,
678 "flags: %#.2x\n", le16_to_cpu(cmd->flags));
679 pos += scnprintf(buf + pos, bufsz - pos,
680 "RX/TX timeout: %d/%d usec\n",
681 le32_to_cpu(cmd->rx_data_timeout),
682 le32_to_cpu(cmd->tx_data_timeout));
683 for (i = 0; i < IWL_POWER_VEC_SIZE; i++)
684 pos += scnprintf(buf + pos, bufsz - pos,
685 "sleep_interval[%d]: %d\n", i,
686 le32_to_cpu(cmd->sleep_interval[i]));
687
688 return simple_read_from_buffer(user_buf, count, ppos, buf, pos);
689}
690
Tomas Winkler712b6cf2008-03-12 16:58:52 -0700691DEBUGFS_READ_WRITE_FILE_OPS(sram);
Johannes Bergc8ac61c2011-07-15 13:23:45 -0700692DEBUGFS_READ_FILE_OPS(wowlan_sram);
Wey-Yi Guy0848e292009-05-22 11:01:46 -0700693DEBUGFS_READ_FILE_OPS(nvm);
Tomas Winkler712b6cf2008-03-12 16:58:52 -0700694DEBUGFS_READ_FILE_OPS(stations);
Winkler, Tomasd366df52008-12-02 12:14:01 -0800695DEBUGFS_READ_FILE_OPS(channels);
Wey-Yi Guy08df05a2009-03-24 10:02:54 -0700696DEBUGFS_READ_FILE_OPS(status);
Emmanuel Grumbach1f7b6172011-08-25 23:10:59 -0700697DEBUGFS_READ_WRITE_FILE_OPS(rx_handlers);
Wey-Yi Guyf5ad69f2009-07-09 10:33:36 -0700698DEBUGFS_READ_FILE_OPS(qos);
Wey-Yi Guyfbf3a2a2009-07-24 11:13:04 -0700699DEBUGFS_READ_FILE_OPS(thermal_throttling);
Wey-Yi Guy1e4247d2009-07-27 13:50:15 -0700700DEBUGFS_READ_WRITE_FILE_OPS(disable_ht40);
Emmanuel Grumbach511afa32011-09-22 07:15:37 -0700701DEBUGFS_READ_FILE_OPS(temperature);
Johannes Berge312c242009-08-07 15:41:51 -0700702DEBUGFS_READ_WRITE_FILE_OPS(sleep_level_override);
703DEBUGFS_READ_FILE_OPS(current_sleep_command);
Tomas Winkler712b6cf2008-03-12 16:58:52 -0700704
Wey-Yi Guyd6d023a2011-04-30 09:10:53 -0700705static const char *fmt_value = " %-30s %10u\n";
706static const char *fmt_hex = " %-30s 0x%02X\n";
707static const char *fmt_table = " %-30s %10u %10u %10u %10u\n";
708static const char *fmt_header =
709 "%-32s current cumulative delta max\n";
710
711static int iwl_statistics_flag(struct iwl_priv *priv, char *buf, int bufsz)
712{
713 int p = 0;
714 u32 flag;
715
Johannes Berg4ff70fcd2012-03-05 11:24:26 -0800716 lockdep_assert_held(&priv->statistics.lock);
717
Wey-Yi Guyd6d023a2011-04-30 09:10:53 -0700718 flag = le32_to_cpu(priv->statistics.flag);
719
720 p += scnprintf(buf + p, bufsz - p, "Statistics Flag(0x%X):\n", flag);
721 if (flag & UCODE_STATISTICS_CLEAR_MSK)
722 p += scnprintf(buf + p, bufsz - p,
723 "\tStatistics have been cleared\n");
724 p += scnprintf(buf + p, bufsz - p, "\tOperational Frequency: %s\n",
725 (flag & UCODE_STATISTICS_FREQUENCY_MSK)
726 ? "2.4 GHz" : "5.2 GHz");
727 p += scnprintf(buf + p, bufsz - p, "\tTGj Narrow Band: %s\n",
728 (flag & UCODE_STATISTICS_NARROW_BAND_MSK)
729 ? "enabled" : "disabled");
730
731 return p;
732}
733
Wey-Yi Guye8fe59a2009-08-07 15:41:42 -0700734static ssize_t iwl_dbgfs_ucode_rx_stats_read(struct file *file,
735 char __user *user_buf,
736 size_t count, loff_t *ppos)
737{
H Hartley Sweeten28f63a42010-01-08 16:14:10 -0700738 struct iwl_priv *priv = file->private_data;
Wey-Yi Guyd6d023a2011-04-30 09:10:53 -0700739 int pos = 0;
740 char *buf;
741 int bufsz = sizeof(struct statistics_rx_phy) * 40 +
742 sizeof(struct statistics_rx_non_phy) * 40 +
743 sizeof(struct statistics_rx_ht_phy) * 40 + 400;
744 ssize_t ret;
745 struct statistics_rx_phy *ofdm, *accum_ofdm, *delta_ofdm, *max_ofdm;
746 struct statistics_rx_phy *cck, *accum_cck, *delta_cck, *max_cck;
747 struct statistics_rx_non_phy *general, *accum_general;
748 struct statistics_rx_non_phy *delta_general, *max_general;
749 struct statistics_rx_ht_phy *ht, *accum_ht, *delta_ht, *max_ht;
750
Don Fry83626402012-03-07 09:52:37 -0800751 if (!iwl_is_alive(priv))
Wey-Yi Guyd6d023a2011-04-30 09:10:53 -0700752 return -EAGAIN;
753
754 buf = kzalloc(bufsz, GFP_KERNEL);
Johannes Bergf9e75442012-03-30 09:37:39 +0200755 if (!buf)
Wey-Yi Guyd6d023a2011-04-30 09:10:53 -0700756 return -ENOMEM;
Wey-Yi Guyd6d023a2011-04-30 09:10:53 -0700757
758 /*
759 * the statistic information display here is based on
760 * the last statistics notification from uCode
761 * might not reflect the current uCode activity
762 */
Johannes Berg4ff70fcd2012-03-05 11:24:26 -0800763 spin_lock_bh(&priv->statistics.lock);
Wey-Yi Guyd6d023a2011-04-30 09:10:53 -0700764 ofdm = &priv->statistics.rx_ofdm;
765 cck = &priv->statistics.rx_cck;
766 general = &priv->statistics.rx_non_phy;
767 ht = &priv->statistics.rx_ofdm_ht;
768 accum_ofdm = &priv->accum_stats.rx_ofdm;
769 accum_cck = &priv->accum_stats.rx_cck;
770 accum_general = &priv->accum_stats.rx_non_phy;
771 accum_ht = &priv->accum_stats.rx_ofdm_ht;
772 delta_ofdm = &priv->delta_stats.rx_ofdm;
773 delta_cck = &priv->delta_stats.rx_cck;
774 delta_general = &priv->delta_stats.rx_non_phy;
775 delta_ht = &priv->delta_stats.rx_ofdm_ht;
776 max_ofdm = &priv->max_delta_stats.rx_ofdm;
777 max_cck = &priv->max_delta_stats.rx_cck;
778 max_general = &priv->max_delta_stats.rx_non_phy;
779 max_ht = &priv->max_delta_stats.rx_ofdm_ht;
780
781 pos += iwl_statistics_flag(priv, buf, bufsz);
782 pos += scnprintf(buf + pos, bufsz - pos,
783 fmt_header, "Statistics_Rx - OFDM:");
784 pos += scnprintf(buf + pos, bufsz - pos,
785 fmt_table, "ina_cnt:",
786 le32_to_cpu(ofdm->ina_cnt),
787 accum_ofdm->ina_cnt,
788 delta_ofdm->ina_cnt, max_ofdm->ina_cnt);
789 pos += scnprintf(buf + pos, bufsz - pos,
790 fmt_table, "fina_cnt:",
791 le32_to_cpu(ofdm->fina_cnt), accum_ofdm->fina_cnt,
792 delta_ofdm->fina_cnt, max_ofdm->fina_cnt);
793 pos += scnprintf(buf + pos, bufsz - pos,
794 fmt_table, "plcp_err:",
795 le32_to_cpu(ofdm->plcp_err), accum_ofdm->plcp_err,
796 delta_ofdm->plcp_err, max_ofdm->plcp_err);
797 pos += scnprintf(buf + pos, bufsz - pos,
798 fmt_table, "crc32_err:",
799 le32_to_cpu(ofdm->crc32_err), accum_ofdm->crc32_err,
800 delta_ofdm->crc32_err, max_ofdm->crc32_err);
801 pos += scnprintf(buf + pos, bufsz - pos,
802 fmt_table, "overrun_err:",
803 le32_to_cpu(ofdm->overrun_err),
804 accum_ofdm->overrun_err, delta_ofdm->overrun_err,
805 max_ofdm->overrun_err);
806 pos += scnprintf(buf + pos, bufsz - pos,
807 fmt_table, "early_overrun_err:",
808 le32_to_cpu(ofdm->early_overrun_err),
809 accum_ofdm->early_overrun_err,
810 delta_ofdm->early_overrun_err,
811 max_ofdm->early_overrun_err);
812 pos += scnprintf(buf + pos, bufsz - pos,
813 fmt_table, "crc32_good:",
814 le32_to_cpu(ofdm->crc32_good),
815 accum_ofdm->crc32_good, delta_ofdm->crc32_good,
816 max_ofdm->crc32_good);
817 pos += scnprintf(buf + pos, bufsz - pos,
818 fmt_table, "false_alarm_cnt:",
819 le32_to_cpu(ofdm->false_alarm_cnt),
820 accum_ofdm->false_alarm_cnt,
821 delta_ofdm->false_alarm_cnt,
822 max_ofdm->false_alarm_cnt);
823 pos += scnprintf(buf + pos, bufsz - pos,
824 fmt_table, "fina_sync_err_cnt:",
825 le32_to_cpu(ofdm->fina_sync_err_cnt),
826 accum_ofdm->fina_sync_err_cnt,
827 delta_ofdm->fina_sync_err_cnt,
828 max_ofdm->fina_sync_err_cnt);
829 pos += scnprintf(buf + pos, bufsz - pos,
830 fmt_table, "sfd_timeout:",
831 le32_to_cpu(ofdm->sfd_timeout),
832 accum_ofdm->sfd_timeout, delta_ofdm->sfd_timeout,
833 max_ofdm->sfd_timeout);
834 pos += scnprintf(buf + pos, bufsz - pos,
835 fmt_table, "fina_timeout:",
836 le32_to_cpu(ofdm->fina_timeout),
837 accum_ofdm->fina_timeout, delta_ofdm->fina_timeout,
838 max_ofdm->fina_timeout);
839 pos += scnprintf(buf + pos, bufsz - pos,
840 fmt_table, "unresponded_rts:",
841 le32_to_cpu(ofdm->unresponded_rts),
842 accum_ofdm->unresponded_rts,
843 delta_ofdm->unresponded_rts,
844 max_ofdm->unresponded_rts);
845 pos += scnprintf(buf + pos, bufsz - pos,
846 fmt_table, "rxe_frame_lmt_ovrun:",
847 le32_to_cpu(ofdm->rxe_frame_limit_overrun),
848 accum_ofdm->rxe_frame_limit_overrun,
849 delta_ofdm->rxe_frame_limit_overrun,
850 max_ofdm->rxe_frame_limit_overrun);
851 pos += scnprintf(buf + pos, bufsz - pos,
852 fmt_table, "sent_ack_cnt:",
853 le32_to_cpu(ofdm->sent_ack_cnt),
854 accum_ofdm->sent_ack_cnt, delta_ofdm->sent_ack_cnt,
855 max_ofdm->sent_ack_cnt);
856 pos += scnprintf(buf + pos, bufsz - pos,
857 fmt_table, "sent_cts_cnt:",
858 le32_to_cpu(ofdm->sent_cts_cnt),
859 accum_ofdm->sent_cts_cnt, delta_ofdm->sent_cts_cnt,
860 max_ofdm->sent_cts_cnt);
861 pos += scnprintf(buf + pos, bufsz - pos,
862 fmt_table, "sent_ba_rsp_cnt:",
863 le32_to_cpu(ofdm->sent_ba_rsp_cnt),
864 accum_ofdm->sent_ba_rsp_cnt,
865 delta_ofdm->sent_ba_rsp_cnt,
866 max_ofdm->sent_ba_rsp_cnt);
867 pos += scnprintf(buf + pos, bufsz - pos,
868 fmt_table, "dsp_self_kill:",
869 le32_to_cpu(ofdm->dsp_self_kill),
870 accum_ofdm->dsp_self_kill,
871 delta_ofdm->dsp_self_kill,
872 max_ofdm->dsp_self_kill);
873 pos += scnprintf(buf + pos, bufsz - pos,
874 fmt_table, "mh_format_err:",
875 le32_to_cpu(ofdm->mh_format_err),
876 accum_ofdm->mh_format_err,
877 delta_ofdm->mh_format_err,
878 max_ofdm->mh_format_err);
879 pos += scnprintf(buf + pos, bufsz - pos,
880 fmt_table, "re_acq_main_rssi_sum:",
881 le32_to_cpu(ofdm->re_acq_main_rssi_sum),
882 accum_ofdm->re_acq_main_rssi_sum,
883 delta_ofdm->re_acq_main_rssi_sum,
884 max_ofdm->re_acq_main_rssi_sum);
885
886 pos += scnprintf(buf + pos, bufsz - pos,
887 fmt_header, "Statistics_Rx - CCK:");
888 pos += scnprintf(buf + pos, bufsz - pos,
889 fmt_table, "ina_cnt:",
890 le32_to_cpu(cck->ina_cnt), accum_cck->ina_cnt,
891 delta_cck->ina_cnt, max_cck->ina_cnt);
892 pos += scnprintf(buf + pos, bufsz - pos,
893 fmt_table, "fina_cnt:",
894 le32_to_cpu(cck->fina_cnt), accum_cck->fina_cnt,
895 delta_cck->fina_cnt, max_cck->fina_cnt);
896 pos += scnprintf(buf + pos, bufsz - pos,
897 fmt_table, "plcp_err:",
898 le32_to_cpu(cck->plcp_err), accum_cck->plcp_err,
899 delta_cck->plcp_err, max_cck->plcp_err);
900 pos += scnprintf(buf + pos, bufsz - pos,
901 fmt_table, "crc32_err:",
902 le32_to_cpu(cck->crc32_err), accum_cck->crc32_err,
903 delta_cck->crc32_err, max_cck->crc32_err);
904 pos += scnprintf(buf + pos, bufsz - pos,
905 fmt_table, "overrun_err:",
906 le32_to_cpu(cck->overrun_err),
907 accum_cck->overrun_err, delta_cck->overrun_err,
908 max_cck->overrun_err);
909 pos += scnprintf(buf + pos, bufsz - pos,
910 fmt_table, "early_overrun_err:",
911 le32_to_cpu(cck->early_overrun_err),
912 accum_cck->early_overrun_err,
913 delta_cck->early_overrun_err,
914 max_cck->early_overrun_err);
915 pos += scnprintf(buf + pos, bufsz - pos,
916 fmt_table, "crc32_good:",
917 le32_to_cpu(cck->crc32_good), accum_cck->crc32_good,
918 delta_cck->crc32_good, max_cck->crc32_good);
919 pos += scnprintf(buf + pos, bufsz - pos,
920 fmt_table, "false_alarm_cnt:",
921 le32_to_cpu(cck->false_alarm_cnt),
922 accum_cck->false_alarm_cnt,
923 delta_cck->false_alarm_cnt, max_cck->false_alarm_cnt);
924 pos += scnprintf(buf + pos, bufsz - pos,
925 fmt_table, "fina_sync_err_cnt:",
926 le32_to_cpu(cck->fina_sync_err_cnt),
927 accum_cck->fina_sync_err_cnt,
928 delta_cck->fina_sync_err_cnt,
929 max_cck->fina_sync_err_cnt);
930 pos += scnprintf(buf + pos, bufsz - pos,
931 fmt_table, "sfd_timeout:",
932 le32_to_cpu(cck->sfd_timeout),
933 accum_cck->sfd_timeout, delta_cck->sfd_timeout,
934 max_cck->sfd_timeout);
935 pos += scnprintf(buf + pos, bufsz - pos,
936 fmt_table, "fina_timeout:",
937 le32_to_cpu(cck->fina_timeout),
938 accum_cck->fina_timeout, delta_cck->fina_timeout,
939 max_cck->fina_timeout);
940 pos += scnprintf(buf + pos, bufsz - pos,
941 fmt_table, "unresponded_rts:",
942 le32_to_cpu(cck->unresponded_rts),
943 accum_cck->unresponded_rts, delta_cck->unresponded_rts,
944 max_cck->unresponded_rts);
945 pos += scnprintf(buf + pos, bufsz - pos,
946 fmt_table, "rxe_frame_lmt_ovrun:",
947 le32_to_cpu(cck->rxe_frame_limit_overrun),
948 accum_cck->rxe_frame_limit_overrun,
949 delta_cck->rxe_frame_limit_overrun,
950 max_cck->rxe_frame_limit_overrun);
951 pos += scnprintf(buf + pos, bufsz - pos,
952 fmt_table, "sent_ack_cnt:",
953 le32_to_cpu(cck->sent_ack_cnt),
954 accum_cck->sent_ack_cnt, delta_cck->sent_ack_cnt,
955 max_cck->sent_ack_cnt);
956 pos += scnprintf(buf + pos, bufsz - pos,
957 fmt_table, "sent_cts_cnt:",
958 le32_to_cpu(cck->sent_cts_cnt),
959 accum_cck->sent_cts_cnt, delta_cck->sent_cts_cnt,
960 max_cck->sent_cts_cnt);
961 pos += scnprintf(buf + pos, bufsz - pos,
962 fmt_table, "sent_ba_rsp_cnt:",
963 le32_to_cpu(cck->sent_ba_rsp_cnt),
964 accum_cck->sent_ba_rsp_cnt,
965 delta_cck->sent_ba_rsp_cnt,
966 max_cck->sent_ba_rsp_cnt);
967 pos += scnprintf(buf + pos, bufsz - pos,
968 fmt_table, "dsp_self_kill:",
969 le32_to_cpu(cck->dsp_self_kill),
970 accum_cck->dsp_self_kill, delta_cck->dsp_self_kill,
971 max_cck->dsp_self_kill);
972 pos += scnprintf(buf + pos, bufsz - pos,
973 fmt_table, "mh_format_err:",
974 le32_to_cpu(cck->mh_format_err),
975 accum_cck->mh_format_err, delta_cck->mh_format_err,
976 max_cck->mh_format_err);
977 pos += scnprintf(buf + pos, bufsz - pos,
978 fmt_table, "re_acq_main_rssi_sum:",
979 le32_to_cpu(cck->re_acq_main_rssi_sum),
980 accum_cck->re_acq_main_rssi_sum,
981 delta_cck->re_acq_main_rssi_sum,
982 max_cck->re_acq_main_rssi_sum);
983
984 pos += scnprintf(buf + pos, bufsz - pos,
985 fmt_header, "Statistics_Rx - GENERAL:");
986 pos += scnprintf(buf + pos, bufsz - pos,
987 fmt_table, "bogus_cts:",
988 le32_to_cpu(general->bogus_cts),
989 accum_general->bogus_cts, delta_general->bogus_cts,
990 max_general->bogus_cts);
991 pos += scnprintf(buf + pos, bufsz - pos,
992 fmt_table, "bogus_ack:",
993 le32_to_cpu(general->bogus_ack),
994 accum_general->bogus_ack, delta_general->bogus_ack,
995 max_general->bogus_ack);
996 pos += scnprintf(buf + pos, bufsz - pos,
997 fmt_table, "non_bssid_frames:",
998 le32_to_cpu(general->non_bssid_frames),
999 accum_general->non_bssid_frames,
1000 delta_general->non_bssid_frames,
1001 max_general->non_bssid_frames);
1002 pos += scnprintf(buf + pos, bufsz - pos,
1003 fmt_table, "filtered_frames:",
1004 le32_to_cpu(general->filtered_frames),
1005 accum_general->filtered_frames,
1006 delta_general->filtered_frames,
1007 max_general->filtered_frames);
1008 pos += scnprintf(buf + pos, bufsz - pos,
1009 fmt_table, "non_channel_beacons:",
1010 le32_to_cpu(general->non_channel_beacons),
1011 accum_general->non_channel_beacons,
1012 delta_general->non_channel_beacons,
1013 max_general->non_channel_beacons);
1014 pos += scnprintf(buf + pos, bufsz - pos,
1015 fmt_table, "channel_beacons:",
1016 le32_to_cpu(general->channel_beacons),
1017 accum_general->channel_beacons,
1018 delta_general->channel_beacons,
1019 max_general->channel_beacons);
1020 pos += scnprintf(buf + pos, bufsz - pos,
1021 fmt_table, "num_missed_bcon:",
1022 le32_to_cpu(general->num_missed_bcon),
1023 accum_general->num_missed_bcon,
1024 delta_general->num_missed_bcon,
1025 max_general->num_missed_bcon);
1026 pos += scnprintf(buf + pos, bufsz - pos,
1027 fmt_table, "adc_rx_saturation_time:",
1028 le32_to_cpu(general->adc_rx_saturation_time),
1029 accum_general->adc_rx_saturation_time,
1030 delta_general->adc_rx_saturation_time,
1031 max_general->adc_rx_saturation_time);
1032 pos += scnprintf(buf + pos, bufsz - pos,
1033 fmt_table, "ina_detect_search_tm:",
1034 le32_to_cpu(general->ina_detection_search_time),
1035 accum_general->ina_detection_search_time,
1036 delta_general->ina_detection_search_time,
1037 max_general->ina_detection_search_time);
1038 pos += scnprintf(buf + pos, bufsz - pos,
1039 fmt_table, "beacon_silence_rssi_a:",
1040 le32_to_cpu(general->beacon_silence_rssi_a),
1041 accum_general->beacon_silence_rssi_a,
1042 delta_general->beacon_silence_rssi_a,
1043 max_general->beacon_silence_rssi_a);
1044 pos += scnprintf(buf + pos, bufsz - pos,
1045 fmt_table, "beacon_silence_rssi_b:",
1046 le32_to_cpu(general->beacon_silence_rssi_b),
1047 accum_general->beacon_silence_rssi_b,
1048 delta_general->beacon_silence_rssi_b,
1049 max_general->beacon_silence_rssi_b);
1050 pos += scnprintf(buf + pos, bufsz - pos,
1051 fmt_table, "beacon_silence_rssi_c:",
1052 le32_to_cpu(general->beacon_silence_rssi_c),
1053 accum_general->beacon_silence_rssi_c,
1054 delta_general->beacon_silence_rssi_c,
1055 max_general->beacon_silence_rssi_c);
1056 pos += scnprintf(buf + pos, bufsz - pos,
1057 fmt_table, "interference_data_flag:",
1058 le32_to_cpu(general->interference_data_flag),
1059 accum_general->interference_data_flag,
1060 delta_general->interference_data_flag,
1061 max_general->interference_data_flag);
1062 pos += scnprintf(buf + pos, bufsz - pos,
1063 fmt_table, "channel_load:",
1064 le32_to_cpu(general->channel_load),
1065 accum_general->channel_load,
1066 delta_general->channel_load,
1067 max_general->channel_load);
1068 pos += scnprintf(buf + pos, bufsz - pos,
1069 fmt_table, "dsp_false_alarms:",
1070 le32_to_cpu(general->dsp_false_alarms),
1071 accum_general->dsp_false_alarms,
1072 delta_general->dsp_false_alarms,
1073 max_general->dsp_false_alarms);
1074 pos += scnprintf(buf + pos, bufsz - pos,
1075 fmt_table, "beacon_rssi_a:",
1076 le32_to_cpu(general->beacon_rssi_a),
1077 accum_general->beacon_rssi_a,
1078 delta_general->beacon_rssi_a,
1079 max_general->beacon_rssi_a);
1080 pos += scnprintf(buf + pos, bufsz - pos,
1081 fmt_table, "beacon_rssi_b:",
1082 le32_to_cpu(general->beacon_rssi_b),
1083 accum_general->beacon_rssi_b,
1084 delta_general->beacon_rssi_b,
1085 max_general->beacon_rssi_b);
1086 pos += scnprintf(buf + pos, bufsz - pos,
1087 fmt_table, "beacon_rssi_c:",
1088 le32_to_cpu(general->beacon_rssi_c),
1089 accum_general->beacon_rssi_c,
1090 delta_general->beacon_rssi_c,
1091 max_general->beacon_rssi_c);
1092 pos += scnprintf(buf + pos, bufsz - pos,
1093 fmt_table, "beacon_energy_a:",
1094 le32_to_cpu(general->beacon_energy_a),
1095 accum_general->beacon_energy_a,
1096 delta_general->beacon_energy_a,
1097 max_general->beacon_energy_a);
1098 pos += scnprintf(buf + pos, bufsz - pos,
1099 fmt_table, "beacon_energy_b:",
1100 le32_to_cpu(general->beacon_energy_b),
1101 accum_general->beacon_energy_b,
1102 delta_general->beacon_energy_b,
1103 max_general->beacon_energy_b);
1104 pos += scnprintf(buf + pos, bufsz - pos,
1105 fmt_table, "beacon_energy_c:",
1106 le32_to_cpu(general->beacon_energy_c),
1107 accum_general->beacon_energy_c,
1108 delta_general->beacon_energy_c,
1109 max_general->beacon_energy_c);
1110
1111 pos += scnprintf(buf + pos, bufsz - pos,
1112 fmt_header, "Statistics_Rx - OFDM_HT:");
1113 pos += scnprintf(buf + pos, bufsz - pos,
1114 fmt_table, "plcp_err:",
1115 le32_to_cpu(ht->plcp_err), accum_ht->plcp_err,
1116 delta_ht->plcp_err, max_ht->plcp_err);
1117 pos += scnprintf(buf + pos, bufsz - pos,
1118 fmt_table, "overrun_err:",
1119 le32_to_cpu(ht->overrun_err), accum_ht->overrun_err,
1120 delta_ht->overrun_err, max_ht->overrun_err);
1121 pos += scnprintf(buf + pos, bufsz - pos,
1122 fmt_table, "early_overrun_err:",
1123 le32_to_cpu(ht->early_overrun_err),
1124 accum_ht->early_overrun_err,
1125 delta_ht->early_overrun_err,
1126 max_ht->early_overrun_err);
1127 pos += scnprintf(buf + pos, bufsz - pos,
1128 fmt_table, "crc32_good:",
1129 le32_to_cpu(ht->crc32_good), accum_ht->crc32_good,
1130 delta_ht->crc32_good, max_ht->crc32_good);
1131 pos += scnprintf(buf + pos, bufsz - pos,
1132 fmt_table, "crc32_err:",
1133 le32_to_cpu(ht->crc32_err), accum_ht->crc32_err,
1134 delta_ht->crc32_err, max_ht->crc32_err);
1135 pos += scnprintf(buf + pos, bufsz - pos,
1136 fmt_table, "mh_format_err:",
1137 le32_to_cpu(ht->mh_format_err),
1138 accum_ht->mh_format_err,
1139 delta_ht->mh_format_err, max_ht->mh_format_err);
1140 pos += scnprintf(buf + pos, bufsz - pos,
1141 fmt_table, "agg_crc32_good:",
1142 le32_to_cpu(ht->agg_crc32_good),
1143 accum_ht->agg_crc32_good,
1144 delta_ht->agg_crc32_good, max_ht->agg_crc32_good);
1145 pos += scnprintf(buf + pos, bufsz - pos,
1146 fmt_table, "agg_mpdu_cnt:",
1147 le32_to_cpu(ht->agg_mpdu_cnt),
1148 accum_ht->agg_mpdu_cnt,
1149 delta_ht->agg_mpdu_cnt, max_ht->agg_mpdu_cnt);
1150 pos += scnprintf(buf + pos, bufsz - pos,
1151 fmt_table, "agg_cnt:",
1152 le32_to_cpu(ht->agg_cnt), accum_ht->agg_cnt,
1153 delta_ht->agg_cnt, max_ht->agg_cnt);
1154 pos += scnprintf(buf + pos, bufsz - pos,
1155 fmt_table, "unsupport_mcs:",
1156 le32_to_cpu(ht->unsupport_mcs),
1157 accum_ht->unsupport_mcs,
1158 delta_ht->unsupport_mcs, max_ht->unsupport_mcs);
1159
Johannes Berg4ff70fcd2012-03-05 11:24:26 -08001160 spin_unlock_bh(&priv->statistics.lock);
1161
Wey-Yi Guyd6d023a2011-04-30 09:10:53 -07001162 ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos);
1163 kfree(buf);
1164 return ret;
Wey-Yi Guye8fe59a2009-08-07 15:41:42 -07001165}
1166
1167static ssize_t iwl_dbgfs_ucode_tx_stats_read(struct file *file,
1168 char __user *user_buf,
1169 size_t count, loff_t *ppos)
1170{
H Hartley Sweeten28f63a42010-01-08 16:14:10 -07001171 struct iwl_priv *priv = file->private_data;
Wey-Yi Guyd6d023a2011-04-30 09:10:53 -07001172 int pos = 0;
1173 char *buf;
1174 int bufsz = (sizeof(struct statistics_tx) * 48) + 250;
1175 ssize_t ret;
1176 struct statistics_tx *tx, *accum_tx, *delta_tx, *max_tx;
1177
Don Fry83626402012-03-07 09:52:37 -08001178 if (!iwl_is_alive(priv))
Wey-Yi Guyd6d023a2011-04-30 09:10:53 -07001179 return -EAGAIN;
1180
1181 buf = kzalloc(bufsz, GFP_KERNEL);
Johannes Bergf9e75442012-03-30 09:37:39 +02001182 if (!buf)
Wey-Yi Guyd6d023a2011-04-30 09:10:53 -07001183 return -ENOMEM;
Wey-Yi Guyd6d023a2011-04-30 09:10:53 -07001184
1185 /* the statistic information display here is based on
1186 * the last statistics notification from uCode
1187 * might not reflect the current uCode activity
1188 */
Johannes Berg4ff70fcd2012-03-05 11:24:26 -08001189 spin_lock_bh(&priv->statistics.lock);
1190
Wey-Yi Guyd6d023a2011-04-30 09:10:53 -07001191 tx = &priv->statistics.tx;
1192 accum_tx = &priv->accum_stats.tx;
1193 delta_tx = &priv->delta_stats.tx;
1194 max_tx = &priv->max_delta_stats.tx;
1195
1196 pos += iwl_statistics_flag(priv, buf, bufsz);
1197 pos += scnprintf(buf + pos, bufsz - pos,
1198 fmt_header, "Statistics_Tx:");
1199 pos += scnprintf(buf + pos, bufsz - pos,
1200 fmt_table, "preamble:",
1201 le32_to_cpu(tx->preamble_cnt),
1202 accum_tx->preamble_cnt,
1203 delta_tx->preamble_cnt, max_tx->preamble_cnt);
1204 pos += scnprintf(buf + pos, bufsz - pos,
1205 fmt_table, "rx_detected_cnt:",
1206 le32_to_cpu(tx->rx_detected_cnt),
1207 accum_tx->rx_detected_cnt,
1208 delta_tx->rx_detected_cnt, max_tx->rx_detected_cnt);
1209 pos += scnprintf(buf + pos, bufsz - pos,
1210 fmt_table, "bt_prio_defer_cnt:",
1211 le32_to_cpu(tx->bt_prio_defer_cnt),
1212 accum_tx->bt_prio_defer_cnt,
1213 delta_tx->bt_prio_defer_cnt,
1214 max_tx->bt_prio_defer_cnt);
1215 pos += scnprintf(buf + pos, bufsz - pos,
1216 fmt_table, "bt_prio_kill_cnt:",
1217 le32_to_cpu(tx->bt_prio_kill_cnt),
1218 accum_tx->bt_prio_kill_cnt,
1219 delta_tx->bt_prio_kill_cnt,
1220 max_tx->bt_prio_kill_cnt);
1221 pos += scnprintf(buf + pos, bufsz - pos,
1222 fmt_table, "few_bytes_cnt:",
1223 le32_to_cpu(tx->few_bytes_cnt),
1224 accum_tx->few_bytes_cnt,
1225 delta_tx->few_bytes_cnt, max_tx->few_bytes_cnt);
1226 pos += scnprintf(buf + pos, bufsz - pos,
1227 fmt_table, "cts_timeout:",
1228 le32_to_cpu(tx->cts_timeout), accum_tx->cts_timeout,
1229 delta_tx->cts_timeout, max_tx->cts_timeout);
1230 pos += scnprintf(buf + pos, bufsz - pos,
1231 fmt_table, "ack_timeout:",
1232 le32_to_cpu(tx->ack_timeout),
1233 accum_tx->ack_timeout,
1234 delta_tx->ack_timeout, max_tx->ack_timeout);
1235 pos += scnprintf(buf + pos, bufsz - pos,
1236 fmt_table, "expected_ack_cnt:",
1237 le32_to_cpu(tx->expected_ack_cnt),
1238 accum_tx->expected_ack_cnt,
1239 delta_tx->expected_ack_cnt,
1240 max_tx->expected_ack_cnt);
1241 pos += scnprintf(buf + pos, bufsz - pos,
1242 fmt_table, "actual_ack_cnt:",
1243 le32_to_cpu(tx->actual_ack_cnt),
1244 accum_tx->actual_ack_cnt,
1245 delta_tx->actual_ack_cnt,
1246 max_tx->actual_ack_cnt);
1247 pos += scnprintf(buf + pos, bufsz - pos,
1248 fmt_table, "dump_msdu_cnt:",
1249 le32_to_cpu(tx->dump_msdu_cnt),
1250 accum_tx->dump_msdu_cnt,
1251 delta_tx->dump_msdu_cnt,
1252 max_tx->dump_msdu_cnt);
1253 pos += scnprintf(buf + pos, bufsz - pos,
1254 fmt_table, "abort_nxt_frame_mismatch:",
1255 le32_to_cpu(tx->burst_abort_next_frame_mismatch_cnt),
1256 accum_tx->burst_abort_next_frame_mismatch_cnt,
1257 delta_tx->burst_abort_next_frame_mismatch_cnt,
1258 max_tx->burst_abort_next_frame_mismatch_cnt);
1259 pos += scnprintf(buf + pos, bufsz - pos,
1260 fmt_table, "abort_missing_nxt_frame:",
1261 le32_to_cpu(tx->burst_abort_missing_next_frame_cnt),
1262 accum_tx->burst_abort_missing_next_frame_cnt,
1263 delta_tx->burst_abort_missing_next_frame_cnt,
1264 max_tx->burst_abort_missing_next_frame_cnt);
1265 pos += scnprintf(buf + pos, bufsz - pos,
1266 fmt_table, "cts_timeout_collision:",
1267 le32_to_cpu(tx->cts_timeout_collision),
1268 accum_tx->cts_timeout_collision,
1269 delta_tx->cts_timeout_collision,
1270 max_tx->cts_timeout_collision);
1271 pos += scnprintf(buf + pos, bufsz - pos,
1272 fmt_table, "ack_ba_timeout_collision:",
1273 le32_to_cpu(tx->ack_or_ba_timeout_collision),
1274 accum_tx->ack_or_ba_timeout_collision,
1275 delta_tx->ack_or_ba_timeout_collision,
1276 max_tx->ack_or_ba_timeout_collision);
1277 pos += scnprintf(buf + pos, bufsz - pos,
1278 fmt_table, "agg ba_timeout:",
1279 le32_to_cpu(tx->agg.ba_timeout),
1280 accum_tx->agg.ba_timeout,
1281 delta_tx->agg.ba_timeout,
1282 max_tx->agg.ba_timeout);
1283 pos += scnprintf(buf + pos, bufsz - pos,
1284 fmt_table, "agg ba_resched_frames:",
1285 le32_to_cpu(tx->agg.ba_reschedule_frames),
1286 accum_tx->agg.ba_reschedule_frames,
1287 delta_tx->agg.ba_reschedule_frames,
1288 max_tx->agg.ba_reschedule_frames);
1289 pos += scnprintf(buf + pos, bufsz - pos,
1290 fmt_table, "agg scd_query_agg_frame:",
1291 le32_to_cpu(tx->agg.scd_query_agg_frame_cnt),
1292 accum_tx->agg.scd_query_agg_frame_cnt,
1293 delta_tx->agg.scd_query_agg_frame_cnt,
1294 max_tx->agg.scd_query_agg_frame_cnt);
1295 pos += scnprintf(buf + pos, bufsz - pos,
1296 fmt_table, "agg scd_query_no_agg:",
1297 le32_to_cpu(tx->agg.scd_query_no_agg),
1298 accum_tx->agg.scd_query_no_agg,
1299 delta_tx->agg.scd_query_no_agg,
1300 max_tx->agg.scd_query_no_agg);
1301 pos += scnprintf(buf + pos, bufsz - pos,
1302 fmt_table, "agg scd_query_agg:",
1303 le32_to_cpu(tx->agg.scd_query_agg),
1304 accum_tx->agg.scd_query_agg,
1305 delta_tx->agg.scd_query_agg,
1306 max_tx->agg.scd_query_agg);
1307 pos += scnprintf(buf + pos, bufsz - pos,
1308 fmt_table, "agg scd_query_mismatch:",
1309 le32_to_cpu(tx->agg.scd_query_mismatch),
1310 accum_tx->agg.scd_query_mismatch,
1311 delta_tx->agg.scd_query_mismatch,
1312 max_tx->agg.scd_query_mismatch);
1313 pos += scnprintf(buf + pos, bufsz - pos,
1314 fmt_table, "agg frame_not_ready:",
1315 le32_to_cpu(tx->agg.frame_not_ready),
1316 accum_tx->agg.frame_not_ready,
1317 delta_tx->agg.frame_not_ready,
1318 max_tx->agg.frame_not_ready);
1319 pos += scnprintf(buf + pos, bufsz - pos,
1320 fmt_table, "agg underrun:",
1321 le32_to_cpu(tx->agg.underrun),
1322 accum_tx->agg.underrun,
1323 delta_tx->agg.underrun, max_tx->agg.underrun);
1324 pos += scnprintf(buf + pos, bufsz - pos,
1325 fmt_table, "agg bt_prio_kill:",
1326 le32_to_cpu(tx->agg.bt_prio_kill),
1327 accum_tx->agg.bt_prio_kill,
1328 delta_tx->agg.bt_prio_kill,
1329 max_tx->agg.bt_prio_kill);
1330 pos += scnprintf(buf + pos, bufsz - pos,
1331 fmt_table, "agg rx_ba_rsp_cnt:",
1332 le32_to_cpu(tx->agg.rx_ba_rsp_cnt),
1333 accum_tx->agg.rx_ba_rsp_cnt,
1334 delta_tx->agg.rx_ba_rsp_cnt,
1335 max_tx->agg.rx_ba_rsp_cnt);
1336
1337 if (tx->tx_power.ant_a || tx->tx_power.ant_b || tx->tx_power.ant_c) {
1338 pos += scnprintf(buf + pos, bufsz - pos,
1339 "tx power: (1/2 dB step)\n");
Johannes Berg9e295112012-04-09 17:46:55 -07001340 if ((priv->hw_params.valid_tx_ant & ANT_A) &&
Johannes Berg7e79a392012-03-05 11:24:32 -08001341 tx->tx_power.ant_a)
Wey-Yi Guyd6d023a2011-04-30 09:10:53 -07001342 pos += scnprintf(buf + pos, bufsz - pos,
1343 fmt_hex, "antenna A:",
1344 tx->tx_power.ant_a);
Johannes Berg9e295112012-04-09 17:46:55 -07001345 if ((priv->hw_params.valid_tx_ant & ANT_B) &&
Johannes Berg7e79a392012-03-05 11:24:32 -08001346 tx->tx_power.ant_b)
Wey-Yi Guyd6d023a2011-04-30 09:10:53 -07001347 pos += scnprintf(buf + pos, bufsz - pos,
1348 fmt_hex, "antenna B:",
1349 tx->tx_power.ant_b);
Johannes Berg9e295112012-04-09 17:46:55 -07001350 if ((priv->hw_params.valid_tx_ant & ANT_C) &&
Johannes Berg7e79a392012-03-05 11:24:32 -08001351 tx->tx_power.ant_c)
Wey-Yi Guyd6d023a2011-04-30 09:10:53 -07001352 pos += scnprintf(buf + pos, bufsz - pos,
1353 fmt_hex, "antenna C:",
1354 tx->tx_power.ant_c);
1355 }
Johannes Berg4ff70fcd2012-03-05 11:24:26 -08001356
1357 spin_unlock_bh(&priv->statistics.lock);
1358
Wey-Yi Guyd6d023a2011-04-30 09:10:53 -07001359 ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos);
1360 kfree(buf);
1361 return ret;
Wey-Yi Guye8fe59a2009-08-07 15:41:42 -07001362}
1363
1364static ssize_t iwl_dbgfs_ucode_general_stats_read(struct file *file,
1365 char __user *user_buf,
1366 size_t count, loff_t *ppos)
1367{
H Hartley Sweeten28f63a42010-01-08 16:14:10 -07001368 struct iwl_priv *priv = file->private_data;
Wey-Yi Guyd6d023a2011-04-30 09:10:53 -07001369 int pos = 0;
1370 char *buf;
1371 int bufsz = sizeof(struct statistics_general) * 10 + 300;
1372 ssize_t ret;
1373 struct statistics_general_common *general, *accum_general;
1374 struct statistics_general_common *delta_general, *max_general;
1375 struct statistics_dbg *dbg, *accum_dbg, *delta_dbg, *max_dbg;
1376 struct statistics_div *div, *accum_div, *delta_div, *max_div;
1377
Don Fry83626402012-03-07 09:52:37 -08001378 if (!iwl_is_alive(priv))
Wey-Yi Guyd6d023a2011-04-30 09:10:53 -07001379 return -EAGAIN;
1380
1381 buf = kzalloc(bufsz, GFP_KERNEL);
Johannes Bergf9e75442012-03-30 09:37:39 +02001382 if (!buf)
Wey-Yi Guyd6d023a2011-04-30 09:10:53 -07001383 return -ENOMEM;
Wey-Yi Guyd6d023a2011-04-30 09:10:53 -07001384
1385 /* the statistic information display here is based on
1386 * the last statistics notification from uCode
1387 * might not reflect the current uCode activity
1388 */
Johannes Berg4ff70fcd2012-03-05 11:24:26 -08001389
1390 spin_lock_bh(&priv->statistics.lock);
1391
Wey-Yi Guyd6d023a2011-04-30 09:10:53 -07001392 general = &priv->statistics.common;
1393 dbg = &priv->statistics.common.dbg;
1394 div = &priv->statistics.common.div;
1395 accum_general = &priv->accum_stats.common;
1396 accum_dbg = &priv->accum_stats.common.dbg;
1397 accum_div = &priv->accum_stats.common.div;
1398 delta_general = &priv->delta_stats.common;
1399 max_general = &priv->max_delta_stats.common;
1400 delta_dbg = &priv->delta_stats.common.dbg;
1401 max_dbg = &priv->max_delta_stats.common.dbg;
1402 delta_div = &priv->delta_stats.common.div;
1403 max_div = &priv->max_delta_stats.common.div;
1404
1405 pos += iwl_statistics_flag(priv, buf, bufsz);
1406 pos += scnprintf(buf + pos, bufsz - pos,
1407 fmt_header, "Statistics_General:");
1408 pos += scnprintf(buf + pos, bufsz - pos,
1409 fmt_value, "temperature:",
1410 le32_to_cpu(general->temperature));
1411 pos += scnprintf(buf + pos, bufsz - pos,
1412 fmt_value, "temperature_m:",
1413 le32_to_cpu(general->temperature_m));
1414 pos += scnprintf(buf + pos, bufsz - pos,
1415 fmt_value, "ttl_timestamp:",
1416 le32_to_cpu(general->ttl_timestamp));
1417 pos += scnprintf(buf + pos, bufsz - pos,
1418 fmt_table, "burst_check:",
1419 le32_to_cpu(dbg->burst_check),
1420 accum_dbg->burst_check,
1421 delta_dbg->burst_check, max_dbg->burst_check);
1422 pos += scnprintf(buf + pos, bufsz - pos,
1423 fmt_table, "burst_count:",
1424 le32_to_cpu(dbg->burst_count),
1425 accum_dbg->burst_count,
1426 delta_dbg->burst_count, max_dbg->burst_count);
1427 pos += scnprintf(buf + pos, bufsz - pos,
1428 fmt_table, "wait_for_silence_timeout_count:",
1429 le32_to_cpu(dbg->wait_for_silence_timeout_cnt),
1430 accum_dbg->wait_for_silence_timeout_cnt,
1431 delta_dbg->wait_for_silence_timeout_cnt,
1432 max_dbg->wait_for_silence_timeout_cnt);
1433 pos += scnprintf(buf + pos, bufsz - pos,
1434 fmt_table, "sleep_time:",
1435 le32_to_cpu(general->sleep_time),
1436 accum_general->sleep_time,
1437 delta_general->sleep_time, max_general->sleep_time);
1438 pos += scnprintf(buf + pos, bufsz - pos,
1439 fmt_table, "slots_out:",
1440 le32_to_cpu(general->slots_out),
1441 accum_general->slots_out,
1442 delta_general->slots_out, max_general->slots_out);
1443 pos += scnprintf(buf + pos, bufsz - pos,
1444 fmt_table, "slots_idle:",
1445 le32_to_cpu(general->slots_idle),
1446 accum_general->slots_idle,
1447 delta_general->slots_idle, max_general->slots_idle);
1448 pos += scnprintf(buf + pos, bufsz - pos,
1449 fmt_table, "tx_on_a:",
1450 le32_to_cpu(div->tx_on_a), accum_div->tx_on_a,
1451 delta_div->tx_on_a, max_div->tx_on_a);
1452 pos += scnprintf(buf + pos, bufsz - pos,
1453 fmt_table, "tx_on_b:",
1454 le32_to_cpu(div->tx_on_b), accum_div->tx_on_b,
1455 delta_div->tx_on_b, max_div->tx_on_b);
1456 pos += scnprintf(buf + pos, bufsz - pos,
1457 fmt_table, "exec_time:",
1458 le32_to_cpu(div->exec_time), accum_div->exec_time,
1459 delta_div->exec_time, max_div->exec_time);
1460 pos += scnprintf(buf + pos, bufsz - pos,
1461 fmt_table, "probe_time:",
1462 le32_to_cpu(div->probe_time), accum_div->probe_time,
1463 delta_div->probe_time, max_div->probe_time);
1464 pos += scnprintf(buf + pos, bufsz - pos,
1465 fmt_table, "rx_enable_counter:",
1466 le32_to_cpu(general->rx_enable_counter),
1467 accum_general->rx_enable_counter,
1468 delta_general->rx_enable_counter,
1469 max_general->rx_enable_counter);
1470 pos += scnprintf(buf + pos, bufsz - pos,
1471 fmt_table, "num_of_sos_states:",
1472 le32_to_cpu(general->num_of_sos_states),
1473 accum_general->num_of_sos_states,
1474 delta_general->num_of_sos_states,
1475 max_general->num_of_sos_states);
Johannes Berg4ff70fcd2012-03-05 11:24:26 -08001476
1477 spin_unlock_bh(&priv->statistics.lock);
1478
Wey-Yi Guyd6d023a2011-04-30 09:10:53 -07001479 ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos);
1480 kfree(buf);
1481 return ret;
1482}
1483
1484static ssize_t iwl_dbgfs_ucode_bt_stats_read(struct file *file,
1485 char __user *user_buf,
1486 size_t count, loff_t *ppos)
1487{
1488 struct iwl_priv *priv = (struct iwl_priv *)file->private_data;
1489 int pos = 0;
1490 char *buf;
1491 int bufsz = (sizeof(struct statistics_bt_activity) * 24) + 200;
1492 ssize_t ret;
1493 struct statistics_bt_activity *bt, *accum_bt;
1494
Don Fry83626402012-03-07 09:52:37 -08001495 if (!iwl_is_alive(priv))
Wey-Yi Guyd6d023a2011-04-30 09:10:53 -07001496 return -EAGAIN;
1497
1498 if (!priv->bt_enable_flag)
1499 return -EINVAL;
1500
1501 /* make request to uCode to retrieve statistics information */
Johannes Bergb1eea292012-03-06 13:30:42 -08001502 mutex_lock(&priv->mutex);
Wey-Yi Guyd6d023a2011-04-30 09:10:53 -07001503 ret = iwl_send_statistics_request(priv, CMD_SYNC, false);
Johannes Bergb1eea292012-03-06 13:30:42 -08001504 mutex_unlock(&priv->mutex);
Wey-Yi Guyd6d023a2011-04-30 09:10:53 -07001505
Johannes Bergf9e75442012-03-30 09:37:39 +02001506 if (ret)
Wey-Yi Guyd6d023a2011-04-30 09:10:53 -07001507 return -EAGAIN;
Wey-Yi Guyd6d023a2011-04-30 09:10:53 -07001508 buf = kzalloc(bufsz, GFP_KERNEL);
Johannes Bergf9e75442012-03-30 09:37:39 +02001509 if (!buf)
Wey-Yi Guyd6d023a2011-04-30 09:10:53 -07001510 return -ENOMEM;
Wey-Yi Guyd6d023a2011-04-30 09:10:53 -07001511
1512 /*
1513 * the statistic information display here is based on
1514 * the last statistics notification from uCode
1515 * might not reflect the current uCode activity
1516 */
Johannes Berg4ff70fcd2012-03-05 11:24:26 -08001517
1518 spin_lock_bh(&priv->statistics.lock);
1519
Wey-Yi Guyd6d023a2011-04-30 09:10:53 -07001520 bt = &priv->statistics.bt_activity;
1521 accum_bt = &priv->accum_stats.bt_activity;
1522
1523 pos += iwl_statistics_flag(priv, buf, bufsz);
1524 pos += scnprintf(buf + pos, bufsz - pos, "Statistics_BT:\n");
1525 pos += scnprintf(buf + pos, bufsz - pos,
1526 "\t\t\tcurrent\t\t\taccumulative\n");
1527 pos += scnprintf(buf + pos, bufsz - pos,
1528 "hi_priority_tx_req_cnt:\t\t%u\t\t\t%u\n",
1529 le32_to_cpu(bt->hi_priority_tx_req_cnt),
1530 accum_bt->hi_priority_tx_req_cnt);
1531 pos += scnprintf(buf + pos, bufsz - pos,
1532 "hi_priority_tx_denied_cnt:\t%u\t\t\t%u\n",
1533 le32_to_cpu(bt->hi_priority_tx_denied_cnt),
1534 accum_bt->hi_priority_tx_denied_cnt);
1535 pos += scnprintf(buf + pos, bufsz - pos,
1536 "lo_priority_tx_req_cnt:\t\t%u\t\t\t%u\n",
1537 le32_to_cpu(bt->lo_priority_tx_req_cnt),
1538 accum_bt->lo_priority_tx_req_cnt);
1539 pos += scnprintf(buf + pos, bufsz - pos,
1540 "lo_priority_tx_denied_cnt:\t%u\t\t\t%u\n",
1541 le32_to_cpu(bt->lo_priority_tx_denied_cnt),
1542 accum_bt->lo_priority_tx_denied_cnt);
1543 pos += scnprintf(buf + pos, bufsz - pos,
1544 "hi_priority_rx_req_cnt:\t\t%u\t\t\t%u\n",
1545 le32_to_cpu(bt->hi_priority_rx_req_cnt),
1546 accum_bt->hi_priority_rx_req_cnt);
1547 pos += scnprintf(buf + pos, bufsz - pos,
1548 "hi_priority_rx_denied_cnt:\t%u\t\t\t%u\n",
1549 le32_to_cpu(bt->hi_priority_rx_denied_cnt),
1550 accum_bt->hi_priority_rx_denied_cnt);
1551 pos += scnprintf(buf + pos, bufsz - pos,
1552 "lo_priority_rx_req_cnt:\t\t%u\t\t\t%u\n",
1553 le32_to_cpu(bt->lo_priority_rx_req_cnt),
1554 accum_bt->lo_priority_rx_req_cnt);
1555 pos += scnprintf(buf + pos, bufsz - pos,
1556 "lo_priority_rx_denied_cnt:\t%u\t\t\t%u\n",
1557 le32_to_cpu(bt->lo_priority_rx_denied_cnt),
1558 accum_bt->lo_priority_rx_denied_cnt);
1559
1560 pos += scnprintf(buf + pos, bufsz - pos,
1561 "(rx)num_bt_kills:\t\t%u\t\t\t%u\n",
1562 le32_to_cpu(priv->statistics.num_bt_kills),
1563 priv->statistics.accum_num_bt_kills);
1564
Johannes Berg4ff70fcd2012-03-05 11:24:26 -08001565 spin_unlock_bh(&priv->statistics.lock);
1566
Wey-Yi Guyd6d023a2011-04-30 09:10:53 -07001567 ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos);
1568 kfree(buf);
1569 return ret;
1570}
1571
1572static ssize_t iwl_dbgfs_reply_tx_error_read(struct file *file,
1573 char __user *user_buf,
1574 size_t count, loff_t *ppos)
1575{
1576 struct iwl_priv *priv = (struct iwl_priv *)file->private_data;
1577 int pos = 0;
1578 char *buf;
1579 int bufsz = (sizeof(struct reply_tx_error_statistics) * 24) +
1580 (sizeof(struct reply_agg_tx_error_statistics) * 24) + 200;
1581 ssize_t ret;
1582
Don Fry83626402012-03-07 09:52:37 -08001583 if (!iwl_is_alive(priv))
Wey-Yi Guyd6d023a2011-04-30 09:10:53 -07001584 return -EAGAIN;
1585
1586 buf = kzalloc(bufsz, GFP_KERNEL);
Johannes Bergf9e75442012-03-30 09:37:39 +02001587 if (!buf)
Wey-Yi Guyd6d023a2011-04-30 09:10:53 -07001588 return -ENOMEM;
Wey-Yi Guyd6d023a2011-04-30 09:10:53 -07001589
1590 pos += scnprintf(buf + pos, bufsz - pos, "Statistics_TX_Error:\n");
1591 pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t\t\t%u\n",
1592 iwl_get_tx_fail_reason(TX_STATUS_POSTPONE_DELAY),
Wey-Yi Guy898ed672011-07-13 08:38:57 -07001593 priv->reply_tx_stats.pp_delay);
Wey-Yi Guyd6d023a2011-04-30 09:10:53 -07001594 pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t\t%u\n",
1595 iwl_get_tx_fail_reason(TX_STATUS_POSTPONE_FEW_BYTES),
Wey-Yi Guy898ed672011-07-13 08:38:57 -07001596 priv->reply_tx_stats.pp_few_bytes);
Wey-Yi Guyd6d023a2011-04-30 09:10:53 -07001597 pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t\t%u\n",
1598 iwl_get_tx_fail_reason(TX_STATUS_POSTPONE_BT_PRIO),
Wey-Yi Guy898ed672011-07-13 08:38:57 -07001599 priv->reply_tx_stats.pp_bt_prio);
Wey-Yi Guyd6d023a2011-04-30 09:10:53 -07001600 pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t\t%u\n",
1601 iwl_get_tx_fail_reason(TX_STATUS_POSTPONE_QUIET_PERIOD),
Wey-Yi Guy898ed672011-07-13 08:38:57 -07001602 priv->reply_tx_stats.pp_quiet_period);
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_POSTPONE_CALC_TTAK),
Wey-Yi Guy898ed672011-07-13 08:38:57 -07001605 priv->reply_tx_stats.pp_calc_ttak);
Wey-Yi Guyd6d023a2011-04-30 09:10:53 -07001606 pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t%u\n",
1607 iwl_get_tx_fail_reason(
1608 TX_STATUS_FAIL_INTERNAL_CROSSED_RETRY),
Wey-Yi Guy898ed672011-07-13 08:38:57 -07001609 priv->reply_tx_stats.int_crossed_retry);
Wey-Yi Guyd6d023a2011-04-30 09:10:53 -07001610 pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t\t%u\n",
1611 iwl_get_tx_fail_reason(TX_STATUS_FAIL_SHORT_LIMIT),
Wey-Yi Guy898ed672011-07-13 08:38:57 -07001612 priv->reply_tx_stats.short_limit);
Wey-Yi Guyd6d023a2011-04-30 09:10:53 -07001613 pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t\t%u\n",
1614 iwl_get_tx_fail_reason(TX_STATUS_FAIL_LONG_LIMIT),
Wey-Yi Guy898ed672011-07-13 08:38:57 -07001615 priv->reply_tx_stats.long_limit);
Wey-Yi Guyd6d023a2011-04-30 09:10:53 -07001616 pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t\t%u\n",
1617 iwl_get_tx_fail_reason(TX_STATUS_FAIL_FIFO_UNDERRUN),
Wey-Yi Guy898ed672011-07-13 08:38:57 -07001618 priv->reply_tx_stats.fifo_underrun);
Wey-Yi Guyd6d023a2011-04-30 09:10:53 -07001619 pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t\t%u\n",
1620 iwl_get_tx_fail_reason(TX_STATUS_FAIL_DRAIN_FLOW),
Wey-Yi Guy898ed672011-07-13 08:38:57 -07001621 priv->reply_tx_stats.drain_flow);
Wey-Yi Guyd6d023a2011-04-30 09:10:53 -07001622 pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t\t%u\n",
1623 iwl_get_tx_fail_reason(TX_STATUS_FAIL_RFKILL_FLUSH),
Wey-Yi Guy898ed672011-07-13 08:38:57 -07001624 priv->reply_tx_stats.rfkill_flush);
Wey-Yi Guyd6d023a2011-04-30 09:10:53 -07001625 pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t\t%u\n",
1626 iwl_get_tx_fail_reason(TX_STATUS_FAIL_LIFE_EXPIRE),
Wey-Yi Guy898ed672011-07-13 08:38:57 -07001627 priv->reply_tx_stats.life_expire);
Wey-Yi Guyd6d023a2011-04-30 09:10:53 -07001628 pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t\t%u\n",
1629 iwl_get_tx_fail_reason(TX_STATUS_FAIL_DEST_PS),
Wey-Yi Guy898ed672011-07-13 08:38:57 -07001630 priv->reply_tx_stats.dest_ps);
Wey-Yi Guyd6d023a2011-04-30 09:10:53 -07001631 pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t\t%u\n",
1632 iwl_get_tx_fail_reason(TX_STATUS_FAIL_HOST_ABORTED),
Wey-Yi Guy898ed672011-07-13 08:38:57 -07001633 priv->reply_tx_stats.host_abort);
Wey-Yi Guyd6d023a2011-04-30 09:10:53 -07001634 pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t\t%u\n",
1635 iwl_get_tx_fail_reason(TX_STATUS_FAIL_BT_RETRY),
Wey-Yi Guy898ed672011-07-13 08:38:57 -07001636 priv->reply_tx_stats.pp_delay);
Wey-Yi Guyd6d023a2011-04-30 09:10:53 -07001637 pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t\t%u\n",
1638 iwl_get_tx_fail_reason(TX_STATUS_FAIL_STA_INVALID),
Wey-Yi Guy898ed672011-07-13 08:38:57 -07001639 priv->reply_tx_stats.sta_invalid);
Wey-Yi Guyd6d023a2011-04-30 09:10:53 -07001640 pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t\t%u\n",
1641 iwl_get_tx_fail_reason(TX_STATUS_FAIL_FRAG_DROPPED),
Wey-Yi Guy898ed672011-07-13 08:38:57 -07001642 priv->reply_tx_stats.frag_drop);
Wey-Yi Guyd6d023a2011-04-30 09:10:53 -07001643 pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t\t%u\n",
1644 iwl_get_tx_fail_reason(TX_STATUS_FAIL_TID_DISABLE),
Wey-Yi Guy898ed672011-07-13 08:38:57 -07001645 priv->reply_tx_stats.tid_disable);
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_FIFO_FLUSHED),
Wey-Yi Guy898ed672011-07-13 08:38:57 -07001648 priv->reply_tx_stats.fifo_flush);
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_INSUFFICIENT_CF_POLL),
Wey-Yi Guy898ed672011-07-13 08:38:57 -07001652 priv->reply_tx_stats.insuff_cf_poll);
Wey-Yi Guyd6d023a2011-04-30 09:10:53 -07001653 pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t\t%u\n",
1654 iwl_get_tx_fail_reason(TX_STATUS_FAIL_PASSIVE_NO_RX),
Wey-Yi Guy898ed672011-07-13 08:38:57 -07001655 priv->reply_tx_stats.fail_hw_drop);
Wey-Yi Guyd6d023a2011-04-30 09:10:53 -07001656 pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t%u\n",
1657 iwl_get_tx_fail_reason(
1658 TX_STATUS_FAIL_NO_BEACON_ON_RADAR),
Wey-Yi Guy898ed672011-07-13 08:38:57 -07001659 priv->reply_tx_stats.sta_color_mismatch);
Wey-Yi Guyd6d023a2011-04-30 09:10:53 -07001660 pos += scnprintf(buf + pos, bufsz - pos, "UNKNOWN:\t\t\t%u\n",
Wey-Yi Guy898ed672011-07-13 08:38:57 -07001661 priv->reply_tx_stats.unknown);
Wey-Yi Guyd6d023a2011-04-30 09:10:53 -07001662
1663 pos += scnprintf(buf + pos, bufsz - pos,
1664 "\nStatistics_Agg_TX_Error:\n");
1665
1666 pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t\t%u\n",
1667 iwl_get_agg_tx_fail_reason(AGG_TX_STATE_UNDERRUN_MSK),
Wey-Yi Guy898ed672011-07-13 08:38:57 -07001668 priv->reply_agg_tx_stats.underrun);
Wey-Yi Guyd6d023a2011-04-30 09:10:53 -07001669 pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t\t%u\n",
1670 iwl_get_agg_tx_fail_reason(AGG_TX_STATE_BT_PRIO_MSK),
Wey-Yi Guy898ed672011-07-13 08:38:57 -07001671 priv->reply_agg_tx_stats.bt_prio);
Wey-Yi Guyd6d023a2011-04-30 09:10:53 -07001672 pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t\t%u\n",
1673 iwl_get_agg_tx_fail_reason(AGG_TX_STATE_FEW_BYTES_MSK),
Wey-Yi Guy898ed672011-07-13 08:38:57 -07001674 priv->reply_agg_tx_stats.few_bytes);
Wey-Yi Guyd6d023a2011-04-30 09:10:53 -07001675 pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t\t%u\n",
1676 iwl_get_agg_tx_fail_reason(AGG_TX_STATE_ABORT_MSK),
Wey-Yi Guy898ed672011-07-13 08:38:57 -07001677 priv->reply_agg_tx_stats.abort);
Wey-Yi Guyd6d023a2011-04-30 09:10:53 -07001678 pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t%u\n",
1679 iwl_get_agg_tx_fail_reason(
1680 AGG_TX_STATE_LAST_SENT_TTL_MSK),
Wey-Yi Guy898ed672011-07-13 08:38:57 -07001681 priv->reply_agg_tx_stats.last_sent_ttl);
Wey-Yi Guyd6d023a2011-04-30 09:10:53 -07001682 pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t%u\n",
1683 iwl_get_agg_tx_fail_reason(
1684 AGG_TX_STATE_LAST_SENT_TRY_CNT_MSK),
Wey-Yi Guy898ed672011-07-13 08:38:57 -07001685 priv->reply_agg_tx_stats.last_sent_try);
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_LAST_SENT_BT_KILL_MSK),
Wey-Yi Guy898ed672011-07-13 08:38:57 -07001689 priv->reply_agg_tx_stats.last_sent_bt_kill);
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_SCD_QUERY_MSK),
Wey-Yi Guy898ed672011-07-13 08:38:57 -07001692 priv->reply_agg_tx_stats.scd_query);
Wey-Yi Guyd6d023a2011-04-30 09:10:53 -07001693 pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t%u\n",
1694 iwl_get_agg_tx_fail_reason(
1695 AGG_TX_STATE_TEST_BAD_CRC32_MSK),
Wey-Yi Guy898ed672011-07-13 08:38:57 -07001696 priv->reply_agg_tx_stats.bad_crc32);
Wey-Yi Guyd6d023a2011-04-30 09:10:53 -07001697 pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t\t%u\n",
1698 iwl_get_agg_tx_fail_reason(AGG_TX_STATE_RESPONSE_MSK),
Wey-Yi Guy898ed672011-07-13 08:38:57 -07001699 priv->reply_agg_tx_stats.response);
Wey-Yi Guyd6d023a2011-04-30 09:10:53 -07001700 pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t\t%u\n",
1701 iwl_get_agg_tx_fail_reason(AGG_TX_STATE_DUMP_TX_MSK),
Wey-Yi Guy898ed672011-07-13 08:38:57 -07001702 priv->reply_agg_tx_stats.dump_tx);
Wey-Yi Guyd6d023a2011-04-30 09:10:53 -07001703 pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t\t%u\n",
1704 iwl_get_agg_tx_fail_reason(AGG_TX_STATE_DELAY_TX_MSK),
Wey-Yi Guy898ed672011-07-13 08:38:57 -07001705 priv->reply_agg_tx_stats.delay_tx);
Wey-Yi Guyd6d023a2011-04-30 09:10:53 -07001706 pos += scnprintf(buf + pos, bufsz - pos, "UNKNOWN:\t\t\t%u\n",
Wey-Yi Guy898ed672011-07-13 08:38:57 -07001707 priv->reply_agg_tx_stats.unknown);
Wey-Yi Guyd6d023a2011-04-30 09:10:53 -07001708
1709 ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos);
1710 kfree(buf);
1711 return ret;
Wey-Yi Guye8fe59a2009-08-07 15:41:42 -07001712}
1713
Wey-Yi Guy52259352009-08-07 15:41:43 -07001714static ssize_t iwl_dbgfs_sensitivity_read(struct file *file,
1715 char __user *user_buf,
1716 size_t count, loff_t *ppos) {
1717
H Hartley Sweeten28f63a42010-01-08 16:14:10 -07001718 struct iwl_priv *priv = file->private_data;
Wey-Yi Guy52259352009-08-07 15:41:43 -07001719 int pos = 0;
1720 int cnt = 0;
1721 char *buf;
1722 int bufsz = sizeof(struct iwl_sensitivity_data) * 4 + 100;
1723 ssize_t ret;
1724 struct iwl_sensitivity_data *data;
1725
1726 data = &priv->sensitivity_data;
1727 buf = kzalloc(bufsz, GFP_KERNEL);
Johannes Bergf9e75442012-03-30 09:37:39 +02001728 if (!buf)
Wey-Yi Guy52259352009-08-07 15:41:43 -07001729 return -ENOMEM;
Wey-Yi Guy52259352009-08-07 15:41:43 -07001730
1731 pos += scnprintf(buf + pos, bufsz - pos, "auto_corr_ofdm:\t\t\t %u\n",
1732 data->auto_corr_ofdm);
1733 pos += scnprintf(buf + pos, bufsz - pos,
1734 "auto_corr_ofdm_mrc:\t\t %u\n",
1735 data->auto_corr_ofdm_mrc);
1736 pos += scnprintf(buf + pos, bufsz - pos, "auto_corr_ofdm_x1:\t\t %u\n",
1737 data->auto_corr_ofdm_x1);
1738 pos += scnprintf(buf + pos, bufsz - pos,
1739 "auto_corr_ofdm_mrc_x1:\t\t %u\n",
1740 data->auto_corr_ofdm_mrc_x1);
1741 pos += scnprintf(buf + pos, bufsz - pos, "auto_corr_cck:\t\t\t %u\n",
1742 data->auto_corr_cck);
1743 pos += scnprintf(buf + pos, bufsz - pos, "auto_corr_cck_mrc:\t\t %u\n",
1744 data->auto_corr_cck_mrc);
1745 pos += scnprintf(buf + pos, bufsz - pos,
1746 "last_bad_plcp_cnt_ofdm:\t\t %u\n",
1747 data->last_bad_plcp_cnt_ofdm);
1748 pos += scnprintf(buf + pos, bufsz - pos, "last_fa_cnt_ofdm:\t\t %u\n",
1749 data->last_fa_cnt_ofdm);
1750 pos += scnprintf(buf + pos, bufsz - pos,
1751 "last_bad_plcp_cnt_cck:\t\t %u\n",
1752 data->last_bad_plcp_cnt_cck);
1753 pos += scnprintf(buf + pos, bufsz - pos, "last_fa_cnt_cck:\t\t %u\n",
1754 data->last_fa_cnt_cck);
1755 pos += scnprintf(buf + pos, bufsz - pos, "nrg_curr_state:\t\t\t %u\n",
1756 data->nrg_curr_state);
1757 pos += scnprintf(buf + pos, bufsz - pos, "nrg_prev_state:\t\t\t %u\n",
1758 data->nrg_prev_state);
1759 pos += scnprintf(buf + pos, bufsz - pos, "nrg_value:\t\t\t");
1760 for (cnt = 0; cnt < 10; cnt++) {
1761 pos += scnprintf(buf + pos, bufsz - pos, " %u",
1762 data->nrg_value[cnt]);
1763 }
1764 pos += scnprintf(buf + pos, bufsz - pos, "\n");
1765 pos += scnprintf(buf + pos, bufsz - pos, "nrg_silence_rssi:\t\t");
1766 for (cnt = 0; cnt < NRG_NUM_PREV_STAT_L; cnt++) {
1767 pos += scnprintf(buf + pos, bufsz - pos, " %u",
1768 data->nrg_silence_rssi[cnt]);
1769 }
1770 pos += scnprintf(buf + pos, bufsz - pos, "\n");
1771 pos += scnprintf(buf + pos, bufsz - pos, "nrg_silence_ref:\t\t %u\n",
1772 data->nrg_silence_ref);
1773 pos += scnprintf(buf + pos, bufsz - pos, "nrg_energy_idx:\t\t\t %u\n",
1774 data->nrg_energy_idx);
1775 pos += scnprintf(buf + pos, bufsz - pos, "nrg_silence_idx:\t\t %u\n",
1776 data->nrg_silence_idx);
1777 pos += scnprintf(buf + pos, bufsz - pos, "nrg_th_cck:\t\t\t %u\n",
1778 data->nrg_th_cck);
1779 pos += scnprintf(buf + pos, bufsz - pos,
1780 "nrg_auto_corr_silence_diff:\t %u\n",
1781 data->nrg_auto_corr_silence_diff);
1782 pos += scnprintf(buf + pos, bufsz - pos, "num_in_cck_no_fa:\t\t %u\n",
1783 data->num_in_cck_no_fa);
1784 pos += scnprintf(buf + pos, bufsz - pos, "nrg_th_ofdm:\t\t\t %u\n",
1785 data->nrg_th_ofdm);
1786
1787 ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos);
1788 kfree(buf);
1789 return ret;
1790}
1791
1792
1793static ssize_t iwl_dbgfs_chain_noise_read(struct file *file,
1794 char __user *user_buf,
1795 size_t count, loff_t *ppos) {
1796
H Hartley Sweeten28f63a42010-01-08 16:14:10 -07001797 struct iwl_priv *priv = file->private_data;
Wey-Yi Guy52259352009-08-07 15:41:43 -07001798 int pos = 0;
1799 int cnt = 0;
1800 char *buf;
1801 int bufsz = sizeof(struct iwl_chain_noise_data) * 4 + 100;
1802 ssize_t ret;
1803 struct iwl_chain_noise_data *data;
1804
1805 data = &priv->chain_noise_data;
1806 buf = kzalloc(bufsz, GFP_KERNEL);
Johannes Bergf9e75442012-03-30 09:37:39 +02001807 if (!buf)
Wey-Yi Guy52259352009-08-07 15:41:43 -07001808 return -ENOMEM;
Wey-Yi Guy52259352009-08-07 15:41:43 -07001809
1810 pos += scnprintf(buf + pos, bufsz - pos, "active_chains:\t\t\t %u\n",
1811 data->active_chains);
1812 pos += scnprintf(buf + pos, bufsz - pos, "chain_noise_a:\t\t\t %u\n",
1813 data->chain_noise_a);
1814 pos += scnprintf(buf + pos, bufsz - pos, "chain_noise_b:\t\t\t %u\n",
1815 data->chain_noise_b);
1816 pos += scnprintf(buf + pos, bufsz - pos, "chain_noise_c:\t\t\t %u\n",
1817 data->chain_noise_c);
1818 pos += scnprintf(buf + pos, bufsz - pos, "chain_signal_a:\t\t\t %u\n",
1819 data->chain_signal_a);
1820 pos += scnprintf(buf + pos, bufsz - pos, "chain_signal_b:\t\t\t %u\n",
1821 data->chain_signal_b);
1822 pos += scnprintf(buf + pos, bufsz - pos, "chain_signal_c:\t\t\t %u\n",
1823 data->chain_signal_c);
1824 pos += scnprintf(buf + pos, bufsz - pos, "beacon_count:\t\t\t %u\n",
1825 data->beacon_count);
1826
1827 pos += scnprintf(buf + pos, bufsz - pos, "disconn_array:\t\t\t");
1828 for (cnt = 0; cnt < NUM_RX_CHAINS; cnt++) {
1829 pos += scnprintf(buf + pos, bufsz - pos, " %u",
1830 data->disconn_array[cnt]);
1831 }
1832 pos += scnprintf(buf + pos, bufsz - pos, "\n");
1833 pos += scnprintf(buf + pos, bufsz - pos, "delta_gain_code:\t\t");
1834 for (cnt = 0; cnt < NUM_RX_CHAINS; cnt++) {
1835 pos += scnprintf(buf + pos, bufsz - pos, " %u",
1836 data->delta_gain_code[cnt]);
1837 }
1838 pos += scnprintf(buf + pos, bufsz - pos, "\n");
1839 pos += scnprintf(buf + pos, bufsz - pos, "radio_write:\t\t\t %u\n",
1840 data->radio_write);
1841 pos += scnprintf(buf + pos, bufsz - pos, "state:\t\t\t\t %u\n",
1842 data->state);
1843
1844 ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos);
1845 kfree(buf);
1846 return ret;
1847}
1848
Wey-Yi Guyc09430a2009-10-16 14:25:50 -07001849static ssize_t iwl_dbgfs_power_save_status_read(struct file *file,
1850 char __user *user_buf,
1851 size_t count, loff_t *ppos)
1852{
H Hartley Sweeten28f63a42010-01-08 16:14:10 -07001853 struct iwl_priv *priv = file->private_data;
Wey-Yi Guyc09430a2009-10-16 14:25:50 -07001854 char buf[60];
1855 int pos = 0;
1856 const size_t bufsz = sizeof(buf);
1857 u32 pwrsave_status;
1858
Emmanuel Grumbach68e8dfd2012-04-18 07:28:17 -07001859 pwrsave_status = iwl_read32(priv->trans, CSR_GP_CNTRL) &
Wey-Yi Guyc09430a2009-10-16 14:25:50 -07001860 CSR_GP_REG_POWER_SAVE_STATUS_MSK;
1861
1862 pos += scnprintf(buf + pos, bufsz - pos, "Power Save Status: ");
1863 pos += scnprintf(buf + pos, bufsz - pos, "%s\n",
1864 (pwrsave_status == CSR_GP_REG_NO_POWER_SAVE) ? "none" :
1865 (pwrsave_status == CSR_GP_REG_MAC_POWER_SAVE) ? "MAC" :
1866 (pwrsave_status == CSR_GP_REG_PHY_POWER_SAVE) ? "PHY" :
1867 "error");
1868
1869 return simple_read_from_buffer(user_buf, count, ppos, buf, pos);
1870}
1871
Wey-Yi Guy7163b8a2009-11-20 12:04:56 -08001872static ssize_t iwl_dbgfs_clear_ucode_statistics_write(struct file *file,
Wey-Yi Guyef8d5522009-11-13 11:56:28 -08001873 const char __user *user_buf,
1874 size_t count, loff_t *ppos)
1875{
1876 struct iwl_priv *priv = file->private_data;
1877 char buf[8];
1878 int buf_size;
1879 int clear;
1880
1881 memset(buf, 0, sizeof(buf));
1882 buf_size = min(count, sizeof(buf) - 1);
1883 if (copy_from_user(buf, user_buf, buf_size))
1884 return -EFAULT;
1885 if (sscanf(buf, "%d", &clear) != 1)
1886 return -EFAULT;
1887
1888 /* make request to uCode to retrieve statistics information */
Johannes Bergb1eea292012-03-06 13:30:42 -08001889 mutex_lock(&priv->mutex);
Wey-Yi Guyef8d5522009-11-13 11:56:28 -08001890 iwl_send_statistics_request(priv, CMD_SYNC, true);
Johannes Bergb1eea292012-03-06 13:30:42 -08001891 mutex_unlock(&priv->mutex);
Wey-Yi Guyef8d5522009-11-13 11:56:28 -08001892
1893 return count;
1894}
1895
Wey-Yi Guya9e1cb62009-12-10 14:37:26 -08001896static ssize_t iwl_dbgfs_ucode_tracing_read(struct file *file,
1897 char __user *user_buf,
1898 size_t count, loff_t *ppos) {
1899
Joe Perches57674302010-07-12 13:50:06 -07001900 struct iwl_priv *priv = file->private_data;
Wey-Yi Guya9e1cb62009-12-10 14:37:26 -08001901 int pos = 0;
1902 char buf[128];
1903 const size_t bufsz = sizeof(buf);
Wey-Yi Guya9e1cb62009-12-10 14:37:26 -08001904
1905 pos += scnprintf(buf + pos, bufsz - pos, "ucode trace timer is %s\n",
1906 priv->event_log.ucode_trace ? "On" : "Off");
1907 pos += scnprintf(buf + pos, bufsz - pos, "non_wraps_count:\t\t %u\n",
1908 priv->event_log.non_wraps_count);
1909 pos += scnprintf(buf + pos, bufsz - pos, "wraps_once_count:\t\t %u\n",
1910 priv->event_log.wraps_once_count);
1911 pos += scnprintf(buf + pos, bufsz - pos, "wraps_more_count:\t\t %u\n",
1912 priv->event_log.wraps_more_count);
1913
Wey-Yi Guy4967c312010-02-18 15:22:07 -08001914 return simple_read_from_buffer(user_buf, count, ppos, buf, pos);
Wey-Yi Guya9e1cb62009-12-10 14:37:26 -08001915}
1916
1917static ssize_t iwl_dbgfs_ucode_tracing_write(struct file *file,
1918 const char __user *user_buf,
1919 size_t count, loff_t *ppos)
1920{
1921 struct iwl_priv *priv = file->private_data;
1922 char buf[8];
1923 int buf_size;
1924 int trace;
1925
1926 memset(buf, 0, sizeof(buf));
1927 buf_size = min(count, sizeof(buf) - 1);
1928 if (copy_from_user(buf, user_buf, buf_size))
1929 return -EFAULT;
1930 if (sscanf(buf, "%d", &trace) != 1)
1931 return -EFAULT;
1932
1933 if (trace) {
1934 priv->event_log.ucode_trace = true;
Don Fry83626402012-03-07 09:52:37 -08001935 if (iwl_is_alive(priv)) {
Johannes Berg98d4bf02012-01-13 11:56:11 +01001936 /* start collecting data now */
1937 mod_timer(&priv->ucode_trace, jiffies);
1938 }
Wey-Yi Guya9e1cb62009-12-10 14:37:26 -08001939 } else {
1940 priv->event_log.ucode_trace = false;
1941 del_timer_sync(&priv->ucode_trace);
1942 }
1943
1944 return count;
1945}
1946
Johannes Berg60987202010-02-18 00:36:07 -08001947static ssize_t iwl_dbgfs_rxon_flags_read(struct file *file,
1948 char __user *user_buf,
1949 size_t count, loff_t *ppos) {
1950
Joe Perches57674302010-07-12 13:50:06 -07001951 struct iwl_priv *priv = file->private_data;
Johannes Berg60987202010-02-18 00:36:07 -08001952 int len = 0;
1953 char buf[20];
1954
Johannes Berg246ed352010-08-23 10:46:32 +02001955 len = sprintf(buf, "0x%04X\n",
1956 le32_to_cpu(priv->contexts[IWL_RXON_CTX_BSS].active.flags));
Johannes Berg60987202010-02-18 00:36:07 -08001957 return simple_read_from_buffer(user_buf, count, ppos, buf, len);
1958}
1959
1960static ssize_t iwl_dbgfs_rxon_filter_flags_read(struct file *file,
1961 char __user *user_buf,
1962 size_t count, loff_t *ppos) {
1963
Joe Perches57674302010-07-12 13:50:06 -07001964 struct iwl_priv *priv = file->private_data;
Johannes Berg60987202010-02-18 00:36:07 -08001965 int len = 0;
1966 char buf[20];
1967
1968 len = sprintf(buf, "0x%04X\n",
Johannes Berg246ed352010-08-23 10:46:32 +02001969 le32_to_cpu(priv->contexts[IWL_RXON_CTX_BSS].active.filter_flags));
Johannes Berg60987202010-02-18 00:36:07 -08001970 return simple_read_from_buffer(user_buf, count, ppos, buf, len);
1971}
1972
Wey-Yi Guya13d2762010-01-22 14:22:42 -08001973static ssize_t iwl_dbgfs_missed_beacon_read(struct file *file,
1974 char __user *user_buf,
1975 size_t count, loff_t *ppos) {
1976
1977 struct iwl_priv *priv = file->private_data;
1978 int pos = 0;
1979 char buf[12];
1980 const size_t bufsz = sizeof(buf);
Wey-Yi Guya13d2762010-01-22 14:22:42 -08001981
1982 pos += scnprintf(buf + pos, bufsz - pos, "%d\n",
1983 priv->missed_beacon_threshold);
1984
Wey-Yi Guy4967c312010-02-18 15:22:07 -08001985 return simple_read_from_buffer(user_buf, count, ppos, buf, pos);
Wey-Yi Guya13d2762010-01-22 14:22:42 -08001986}
1987
1988static ssize_t iwl_dbgfs_missed_beacon_write(struct file *file,
1989 const char __user *user_buf,
1990 size_t count, loff_t *ppos)
1991{
1992 struct iwl_priv *priv = file->private_data;
1993 char buf[8];
1994 int buf_size;
1995 int missed;
1996
1997 memset(buf, 0, sizeof(buf));
1998 buf_size = min(count, sizeof(buf) - 1);
1999 if (copy_from_user(buf, user_buf, buf_size))
2000 return -EFAULT;
2001 if (sscanf(buf, "%d", &missed) != 1)
2002 return -EINVAL;
2003
2004 if (missed < IWL_MISSED_BEACON_THRESHOLD_MIN ||
2005 missed > IWL_MISSED_BEACON_THRESHOLD_MAX)
2006 priv->missed_beacon_threshold =
2007 IWL_MISSED_BEACON_THRESHOLD_DEF;
2008 else
2009 priv->missed_beacon_threshold = missed;
2010
2011 return count;
2012}
2013
Trieu 'Andrew' Nguyen3e4fb5f2010-01-22 14:22:46 -08002014static ssize_t iwl_dbgfs_plcp_delta_read(struct file *file,
2015 char __user *user_buf,
2016 size_t count, loff_t *ppos) {
2017
Joe Perches57674302010-07-12 13:50:06 -07002018 struct iwl_priv *priv = file->private_data;
Trieu 'Andrew' Nguyen3e4fb5f2010-01-22 14:22:46 -08002019 int pos = 0;
2020 char buf[12];
2021 const size_t bufsz = sizeof(buf);
Trieu 'Andrew' Nguyen3e4fb5f2010-01-22 14:22:46 -08002022
2023 pos += scnprintf(buf + pos, bufsz - pos, "%u\n",
Johannes Bergab5c0f12012-03-06 13:30:53 -08002024 priv->plcp_delta_threshold);
Trieu 'Andrew' Nguyen3e4fb5f2010-01-22 14:22:46 -08002025
Wey-Yi Guy4967c312010-02-18 15:22:07 -08002026 return simple_read_from_buffer(user_buf, count, ppos, buf, pos);
Trieu 'Andrew' Nguyen3e4fb5f2010-01-22 14:22:46 -08002027}
2028
2029static ssize_t iwl_dbgfs_plcp_delta_write(struct file *file,
2030 const char __user *user_buf,
2031 size_t count, loff_t *ppos) {
2032
2033 struct iwl_priv *priv = file->private_data;
2034 char buf[8];
2035 int buf_size;
2036 int plcp;
2037
2038 memset(buf, 0, sizeof(buf));
2039 buf_size = min(count, sizeof(buf) - 1);
2040 if (copy_from_user(buf, user_buf, buf_size))
2041 return -EFAULT;
2042 if (sscanf(buf, "%d", &plcp) != 1)
2043 return -EINVAL;
Wey-Yi Guy680788a2010-06-17 15:25:00 -07002044 if ((plcp < IWL_MAX_PLCP_ERR_THRESHOLD_MIN) ||
Trieu 'Andrew' Nguyen3e4fb5f2010-01-22 14:22:46 -08002045 (plcp > IWL_MAX_PLCP_ERR_THRESHOLD_MAX))
Johannes Bergab5c0f12012-03-06 13:30:53 -08002046 priv->plcp_delta_threshold =
Wey-Yi Guy680788a2010-06-17 15:25:00 -07002047 IWL_MAX_PLCP_ERR_THRESHOLD_DISABLE;
Trieu 'Andrew' Nguyen3e4fb5f2010-01-22 14:22:46 -08002048 else
Johannes Bergab5c0f12012-03-06 13:30:53 -08002049 priv->plcp_delta_threshold = plcp;
Trieu 'Andrew' Nguyen3e4fb5f2010-01-22 14:22:46 -08002050 return count;
2051}
2052
Johannes Berg48dffd32012-04-09 17:46:57 -07002053static ssize_t iwl_dbgfs_rf_reset_read(struct file *file,
2054 char __user *user_buf,
2055 size_t count, loff_t *ppos)
Johannes Bergca934b62011-09-15 11:46:48 -07002056{
Wey-Yi Guy528c3122010-02-18 22:03:07 -08002057 struct iwl_priv *priv = file->private_data;
Johannes Berg48dffd32012-04-09 17:46:57 -07002058 int pos = 0;
Wey-Yi Guy528c3122010-02-18 22:03:07 -08002059 char buf[300];
2060 const size_t bufsz = sizeof(buf);
Johannes Berg48dffd32012-04-09 17:46:57 -07002061 struct iwl_rf_reset *rf_reset = &priv->rf_reset;
Wey-Yi Guy528c3122010-02-18 22:03:07 -08002062
Johannes Berg48dffd32012-04-09 17:46:57 -07002063 pos += scnprintf(buf + pos, bufsz - pos,
2064 "RF reset statistics\n");
2065 pos += scnprintf(buf + pos, bufsz - pos,
2066 "\tnumber of reset request: %d\n",
2067 rf_reset->reset_request_count);
2068 pos += scnprintf(buf + pos, bufsz - pos,
2069 "\tnumber of reset request success: %d\n",
2070 rf_reset->reset_success_count);
2071 pos += scnprintf(buf + pos, bufsz - pos,
2072 "\tnumber of reset request reject: %d\n",
2073 rf_reset->reset_reject_count);
2074
Wey-Yi Guy528c3122010-02-18 22:03:07 -08002075 return simple_read_from_buffer(user_buf, count, ppos, buf, pos);
2076}
2077
Johannes Berg48dffd32012-04-09 17:46:57 -07002078static ssize_t iwl_dbgfs_rf_reset_write(struct file *file,
Wey-Yi Guy04cafd72010-02-03 11:47:20 -08002079 const char __user *user_buf,
2080 size_t count, loff_t *ppos) {
2081
2082 struct iwl_priv *priv = file->private_data;
Johannes Berg48dffd32012-04-09 17:46:57 -07002083 int ret;
Wey-Yi Guy04cafd72010-02-03 11:47:20 -08002084
Johannes Berg48dffd32012-04-09 17:46:57 -07002085 ret = iwl_force_rf_reset(priv, true);
Wey-Yi Guy04cafd72010-02-03 11:47:20 -08002086 return ret ? ret : count;
2087}
2088
Wey-Yi Guy4bf49a92010-06-24 13:18:36 -07002089static ssize_t iwl_dbgfs_txfifo_flush_write(struct file *file,
2090 const char __user *user_buf,
2091 size_t count, loff_t *ppos) {
2092
2093 struct iwl_priv *priv = file->private_data;
2094 char buf[8];
2095 int buf_size;
2096 int flush;
2097
2098 memset(buf, 0, sizeof(buf));
2099 buf_size = min(count, sizeof(buf) - 1);
2100 if (copy_from_user(buf, user_buf, buf_size))
2101 return -EFAULT;
2102 if (sscanf(buf, "%d", &flush) != 1)
2103 return -EINVAL;
2104
Don Fry83626402012-03-07 09:52:37 -08002105 if (iwl_is_rfkill(priv))
Wey-Yi Guy4bf49a92010-06-24 13:18:36 -07002106 return -EFAULT;
2107
Wey-Yi Guyc68744f2011-06-18 08:03:18 -07002108 iwlagn_dev_txfifo_flush(priv, IWL_DROP_ALL);
Wey-Yi Guy4bf49a92010-06-24 13:18:36 -07002109
2110 return count;
2111}
2112
Wey-Yi Guybefe8c42010-08-23 07:57:16 -07002113static ssize_t iwl_dbgfs_bt_traffic_read(struct file *file,
2114 char __user *user_buf,
2115 size_t count, loff_t *ppos) {
2116
2117 struct iwl_priv *priv = (struct iwl_priv *)file->private_data;
2118 int pos = 0;
2119 char buf[200];
2120 const size_t bufsz = sizeof(buf);
Wey-Yi Guybefe8c42010-08-23 07:57:16 -07002121
Wey-Yi Guyf21dd002010-12-08 15:34:52 -08002122 if (!priv->bt_enable_flag) {
2123 pos += scnprintf(buf + pos, bufsz - pos, "BT coex disabled\n");
Johannes Berg08960de2011-04-05 09:41:53 -07002124 return simple_read_from_buffer(user_buf, count, ppos, buf, pos);
Wey-Yi Guyf21dd002010-12-08 15:34:52 -08002125 }
2126 pos += scnprintf(buf + pos, bufsz - pos, "BT enable flag: 0x%x\n",
2127 priv->bt_enable_flag);
Wey-Yi Guybefe8c42010-08-23 07:57:16 -07002128 pos += scnprintf(buf + pos, bufsz - pos, "BT in %s mode\n",
2129 priv->bt_full_concurrent ? "full concurrency" : "3-wire");
2130 pos += scnprintf(buf + pos, bufsz - pos, "BT status: %s, "
2131 "last traffic notif: %d\n",
Wey-Yi Guy66e863a52010-11-08 14:54:37 -08002132 priv->bt_status ? "On" : "Off", priv->last_bt_traffic_load);
Wey-Yi Guybefe8c42010-08-23 07:57:16 -07002133 pos += scnprintf(buf + pos, bufsz - pos, "ch_announcement: %d, "
Wey-Yi Guy187bc4f2011-01-27 13:01:33 -08002134 "kill_ack_mask: %x, kill_cts_mask: %x\n",
2135 priv->bt_ch_announce, priv->kill_ack_mask,
2136 priv->kill_cts_mask);
Wey-Yi Guybefe8c42010-08-23 07:57:16 -07002137
2138 pos += scnprintf(buf + pos, bufsz - pos, "bluetooth traffic load: ");
2139 switch (priv->bt_traffic_load) {
2140 case IWL_BT_COEX_TRAFFIC_LOAD_CONTINUOUS:
2141 pos += scnprintf(buf + pos, bufsz - pos, "Continuous\n");
2142 break;
2143 case IWL_BT_COEX_TRAFFIC_LOAD_HIGH:
2144 pos += scnprintf(buf + pos, bufsz - pos, "High\n");
2145 break;
2146 case IWL_BT_COEX_TRAFFIC_LOAD_LOW:
2147 pos += scnprintf(buf + pos, bufsz - pos, "Low\n");
2148 break;
2149 case IWL_BT_COEX_TRAFFIC_LOAD_NONE:
2150 default:
2151 pos += scnprintf(buf + pos, bufsz - pos, "None\n");
2152 break;
2153 }
2154
Johannes Berg08960de2011-04-05 09:41:53 -07002155 return simple_read_from_buffer(user_buf, count, ppos, buf, pos);
Wey-Yi Guybefe8c42010-08-23 07:57:16 -07002156}
2157
Wey-Yi Guyc6abdc02010-09-01 17:10:51 -07002158static ssize_t iwl_dbgfs_protection_mode_read(struct file *file,
2159 char __user *user_buf,
2160 size_t count, loff_t *ppos)
2161{
2162 struct iwl_priv *priv = (struct iwl_priv *)file->private_data;
2163
2164 int pos = 0;
2165 char buf[40];
2166 const size_t bufsz = sizeof(buf);
2167
Emmanuel Grumbach21522682012-03-22 17:51:44 +02002168 if (priv->cfg->ht_params)
Wey-Yi Guy7cb1b082010-10-06 08:10:00 -07002169 pos += scnprintf(buf + pos, bufsz - pos,
2170 "use %s for aggregation\n",
Johannes Berg9e295112012-04-09 17:46:55 -07002171 (priv->hw_params.use_rts_for_aggregation) ?
Wey-Yi Guy7cb1b082010-10-06 08:10:00 -07002172 "rts/cts" : "cts-to-self");
2173 else
2174 pos += scnprintf(buf + pos, bufsz - pos, "N/A");
2175
Wey-Yi Guyc6abdc02010-09-01 17:10:51 -07002176 return simple_read_from_buffer(user_buf, count, ppos, buf, pos);
2177}
2178
2179static ssize_t iwl_dbgfs_protection_mode_write(struct file *file,
2180 const char __user *user_buf,
2181 size_t count, loff_t *ppos) {
2182
2183 struct iwl_priv *priv = file->private_data;
2184 char buf[8];
2185 int buf_size;
2186 int rts;
2187
Emmanuel Grumbach21522682012-03-22 17:51:44 +02002188 if (!priv->cfg->ht_params)
Wey-Yi Guy7cb1b082010-10-06 08:10:00 -07002189 return -EINVAL;
2190
Wey-Yi Guyc6abdc02010-09-01 17:10:51 -07002191 memset(buf, 0, sizeof(buf));
2192 buf_size = min(count, sizeof(buf) - 1);
2193 if (copy_from_user(buf, user_buf, buf_size))
2194 return -EFAULT;
2195 if (sscanf(buf, "%d", &rts) != 1)
2196 return -EINVAL;
2197 if (rts)
Johannes Berg9e295112012-04-09 17:46:55 -07002198 priv->hw_params.use_rts_for_aggregation = true;
Wey-Yi Guyc6abdc02010-09-01 17:10:51 -07002199 else
Johannes Berg9e295112012-04-09 17:46:55 -07002200 priv->hw_params.use_rts_for_aggregation = false;
Wey-Yi Guyc6abdc02010-09-01 17:10:51 -07002201 return count;
2202}
2203
Johannes Bergc98c8d92012-04-02 15:15:58 +02002204static int iwl_cmd_echo_test(struct iwl_priv *priv)
2205{
2206 int ret;
2207 struct iwl_host_cmd cmd = {
2208 .id = REPLY_ECHO,
2209 .len = { 0 },
2210 .flags = CMD_SYNC,
2211 };
2212
2213 ret = iwl_dvm_send_cmd(priv, &cmd);
2214 if (ret)
2215 IWL_ERR(priv, "echo testing fail: 0X%x\n", ret);
2216 else
2217 IWL_DEBUG_INFO(priv, "echo testing pass\n");
2218 return ret;
2219}
2220
Wey-Yi Guy7e4005c2011-10-10 07:26:51 -07002221static ssize_t iwl_dbgfs_echo_test_write(struct file *file,
2222 const char __user *user_buf,
2223 size_t count, loff_t *ppos)
2224{
2225 struct iwl_priv *priv = file->private_data;
2226 char buf[8];
2227 int buf_size;
2228
2229 memset(buf, 0, sizeof(buf));
2230 buf_size = min(count, sizeof(buf) - 1);
2231 if (copy_from_user(buf, user_buf, buf_size))
2232 return -EFAULT;
2233
2234 iwl_cmd_echo_test(priv);
2235 return count;
2236}
2237
Meenakshi Venkataraman2fdfc472012-03-15 13:26:56 -07002238static ssize_t iwl_dbgfs_log_event_read(struct file *file,
2239 char __user *user_buf,
2240 size_t count, loff_t *ppos)
2241{
2242 struct iwl_priv *priv = file->private_data;
2243 char *buf;
2244 int pos = 0;
2245 ssize_t ret = -ENOMEM;
2246
2247 ret = pos = iwl_dump_nic_event_log(priv, true, &buf, true);
2248 if (buf) {
2249 ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos);
2250 kfree(buf);
2251 }
2252 return ret;
2253}
2254
2255static ssize_t iwl_dbgfs_log_event_write(struct file *file,
2256 const char __user *user_buf,
2257 size_t count, loff_t *ppos)
2258{
2259 struct iwl_priv *priv = file->private_data;
2260 u32 event_log_flag;
2261 char buf[8];
2262 int buf_size;
2263
2264 memset(buf, 0, sizeof(buf));
2265 buf_size = min(count, sizeof(buf) - 1);
2266 if (copy_from_user(buf, user_buf, buf_size))
2267 return -EFAULT;
2268 if (sscanf(buf, "%d", &event_log_flag) != 1)
2269 return -EFAULT;
2270 if (event_log_flag == 1)
2271 iwl_dump_nic_event_log(priv, true, NULL, false);
2272
2273 return count;
2274}
2275
Dor Shaishbfb45f52012-03-26 08:20:55 -07002276static ssize_t iwl_dbgfs_calib_disabled_read(struct file *file,
2277 char __user *user_buf,
2278 size_t count, loff_t *ppos)
2279{
2280 struct iwl_priv *priv = file->private_data;
2281 char buf[120];
2282 int pos = 0;
2283 const size_t bufsz = sizeof(buf);
2284
2285 pos += scnprintf(buf + pos, bufsz - pos,
2286 "Sensitivity calibrations %s\n",
2287 (priv->calib_disabled &
2288 IWL_SENSITIVITY_CALIB_DISABLED) ?
2289 "DISABLED" : "ENABLED");
2290 pos += scnprintf(buf + pos, bufsz - pos,
2291 "Chain noise calibrations %s\n",
2292 (priv->calib_disabled &
2293 IWL_CHAIN_NOISE_CALIB_DISABLED) ?
2294 "DISABLED" : "ENABLED");
2295 pos += scnprintf(buf + pos, bufsz - pos,
2296 "Tx power calibrations %s\n",
2297 (priv->calib_disabled &
2298 IWL_TX_POWER_CALIB_DISABLED) ?
2299 "DISABLED" : "ENABLED");
2300
2301 return simple_read_from_buffer(user_buf, count, ppos, buf, pos);
2302}
2303
David Spinadel647ad132012-03-31 08:31:05 -07002304static ssize_t iwl_dbgfs_calib_disabled_write(struct file *file,
2305 const char __user *user_buf,
2306 size_t count, loff_t *ppos)
2307{
2308 struct iwl_priv *priv = file->private_data;
2309 char buf[8];
2310 u32 calib_disabled;
2311 int buf_size;
2312
2313 memset(buf, 0, sizeof(buf));
2314 buf_size = min(count, sizeof(buf) - 1);
2315 if (copy_from_user(buf, user_buf, buf_size))
2316 return -EFAULT;
2317 if (sscanf(buf, "%x", &calib_disabled) != 1)
2318 return -EFAULT;
2319
2320 priv->calib_disabled = calib_disabled;
2321
2322 return count;
2323}
2324
Wey-Yi Guye8fe59a2009-08-07 15:41:42 -07002325DEBUGFS_READ_FILE_OPS(ucode_rx_stats);
2326DEBUGFS_READ_FILE_OPS(ucode_tx_stats);
2327DEBUGFS_READ_FILE_OPS(ucode_general_stats);
Wey-Yi Guy52259352009-08-07 15:41:43 -07002328DEBUGFS_READ_FILE_OPS(sensitivity);
2329DEBUGFS_READ_FILE_OPS(chain_noise);
Wey-Yi Guyc09430a2009-10-16 14:25:50 -07002330DEBUGFS_READ_FILE_OPS(power_save_status);
Wey-Yi Guy7163b8a2009-11-20 12:04:56 -08002331DEBUGFS_WRITE_FILE_OPS(clear_ucode_statistics);
Wey-Yi Guya9e1cb62009-12-10 14:37:26 -08002332DEBUGFS_READ_WRITE_FILE_OPS(ucode_tracing);
Wey-Yi Guya13d2762010-01-22 14:22:42 -08002333DEBUGFS_READ_WRITE_FILE_OPS(missed_beacon);
Trieu 'Andrew' Nguyen3e4fb5f2010-01-22 14:22:46 -08002334DEBUGFS_READ_WRITE_FILE_OPS(plcp_delta);
Johannes Berg48dffd32012-04-09 17:46:57 -07002335DEBUGFS_READ_WRITE_FILE_OPS(rf_reset);
Johannes Berg60987202010-02-18 00:36:07 -08002336DEBUGFS_READ_FILE_OPS(rxon_flags);
2337DEBUGFS_READ_FILE_OPS(rxon_filter_flags);
Wey-Yi Guy4bf49a92010-06-24 13:18:36 -07002338DEBUGFS_WRITE_FILE_OPS(txfifo_flush);
Wey-Yi Guyffb7d892010-07-14 08:09:55 -07002339DEBUGFS_READ_FILE_OPS(ucode_bt_stats);
Wey-Yi Guybefe8c42010-08-23 07:57:16 -07002340DEBUGFS_READ_FILE_OPS(bt_traffic);
Wey-Yi Guyc6abdc02010-09-01 17:10:51 -07002341DEBUGFS_READ_WRITE_FILE_OPS(protection_mode);
Wey-Yi Guy54a9aa62010-09-05 10:49:42 -07002342DEBUGFS_READ_FILE_OPS(reply_tx_error);
Wey-Yi Guy7e4005c2011-10-10 07:26:51 -07002343DEBUGFS_WRITE_FILE_OPS(echo_test);
Meenakshi Venkataraman2fdfc472012-03-15 13:26:56 -07002344DEBUGFS_READ_WRITE_FILE_OPS(log_event);
David Spinadel647ad132012-03-31 08:31:05 -07002345DEBUGFS_READ_WRITE_FILE_OPS(calib_disabled);
Wey-Yi Guy20594eb2009-08-07 15:41:39 -07002346
Tomas Winkler712b6cf2008-03-12 16:58:52 -07002347/*
2348 * Create the debugfs files and directories
2349 *
2350 */
2351int iwl_dbgfs_register(struct iwl_priv *priv, const char *name)
2352{
Zhu Yi95b1a822008-05-29 16:34:50 +08002353 struct dentry *phyd = priv->hw->wiphy->debugfsdir;
Johannes Berg4c84a8f2010-01-22 14:22:54 -08002354 struct dentry *dir_drv, *dir_data, *dir_rf, *dir_debug;
Tomas Winkler712b6cf2008-03-12 16:58:52 -07002355
Johannes Berg4c84a8f2010-01-22 14:22:54 -08002356 dir_drv = debugfs_create_dir(name, phyd);
2357 if (!dir_drv)
2358 return -ENOMEM;
2359
2360 priv->debugfs_dir = dir_drv;
2361
2362 dir_data = debugfs_create_dir("data", dir_drv);
2363 if (!dir_data)
Tomas Winkler712b6cf2008-03-12 16:58:52 -07002364 goto err;
Johannes Berg4c84a8f2010-01-22 14:22:54 -08002365 dir_rf = debugfs_create_dir("rf", dir_drv);
2366 if (!dir_rf)
Tomas Winkler712b6cf2008-03-12 16:58:52 -07002367 goto err;
Johannes Berg4c84a8f2010-01-22 14:22:54 -08002368 dir_debug = debugfs_create_dir("debug", dir_drv);
2369 if (!dir_debug)
2370 goto err;
Tomas Winkler712b6cf2008-03-12 16:58:52 -07002371
Johannes Berg4c84a8f2010-01-22 14:22:54 -08002372 DEBUGFS_ADD_FILE(nvm, dir_data, S_IRUSR);
2373 DEBUGFS_ADD_FILE(sram, dir_data, S_IWUSR | S_IRUSR);
Johannes Bergc8ac61c2011-07-15 13:23:45 -07002374 DEBUGFS_ADD_FILE(wowlan_sram, dir_data, S_IRUSR);
Johannes Berg4c84a8f2010-01-22 14:22:54 -08002375 DEBUGFS_ADD_FILE(stations, dir_data, S_IRUSR);
2376 DEBUGFS_ADD_FILE(channels, dir_data, S_IRUSR);
2377 DEBUGFS_ADD_FILE(status, dir_data, S_IRUSR);
Emmanuel Grumbach1f7b6172011-08-25 23:10:59 -07002378 DEBUGFS_ADD_FILE(rx_handlers, dir_data, S_IWUSR | S_IRUSR);
Johannes Berg4c84a8f2010-01-22 14:22:54 -08002379 DEBUGFS_ADD_FILE(qos, dir_data, S_IRUSR);
Wey-Yi Guy23c0fcc2011-04-01 16:29:53 -07002380 DEBUGFS_ADD_FILE(sleep_level_override, dir_data, S_IWUSR | S_IRUSR);
2381 DEBUGFS_ADD_FILE(current_sleep_command, dir_data, S_IRUSR);
Johannes Berg4c84a8f2010-01-22 14:22:54 -08002382 DEBUGFS_ADD_FILE(thermal_throttling, dir_data, S_IRUSR);
2383 DEBUGFS_ADD_FILE(disable_ht40, dir_data, S_IWUSR | S_IRUSR);
Emmanuel Grumbach511afa32011-09-22 07:15:37 -07002384 DEBUGFS_ADD_FILE(temperature, dir_data, S_IRUSR);
Johannes Bergca934b62011-09-15 11:46:48 -07002385
Johannes Berg4c84a8f2010-01-22 14:22:54 -08002386 DEBUGFS_ADD_FILE(power_save_status, dir_debug, S_IRUSR);
2387 DEBUGFS_ADD_FILE(clear_ucode_statistics, dir_debug, S_IWUSR);
Johannes Berg4c84a8f2010-01-22 14:22:54 -08002388 DEBUGFS_ADD_FILE(missed_beacon, dir_debug, S_IWUSR);
Johannes Berg4c84a8f2010-01-22 14:22:54 -08002389 DEBUGFS_ADD_FILE(plcp_delta, dir_debug, S_IWUSR | S_IRUSR);
Johannes Berg48dffd32012-04-09 17:46:57 -07002390 DEBUGFS_ADD_FILE(rf_reset, dir_debug, S_IWUSR | S_IRUSR);
Abhijeet Kolekarb8c76262010-04-08 15:29:07 -07002391 DEBUGFS_ADD_FILE(ucode_rx_stats, dir_debug, S_IRUSR);
2392 DEBUGFS_ADD_FILE(ucode_tx_stats, dir_debug, S_IRUSR);
2393 DEBUGFS_ADD_FILE(ucode_general_stats, dir_debug, S_IRUSR);
Wey-Yi Guyc68744f2011-06-18 08:03:18 -07002394 DEBUGFS_ADD_FILE(txfifo_flush, dir_debug, S_IWUSR);
Wey-Yi Guyc6abdc02010-09-01 17:10:51 -07002395 DEBUGFS_ADD_FILE(protection_mode, dir_debug, S_IWUSR | S_IRUSR);
Wey-Yi Guy703bc582011-04-03 08:14:41 -07002396 DEBUGFS_ADD_FILE(sensitivity, dir_debug, S_IRUSR);
2397 DEBUGFS_ADD_FILE(chain_noise, dir_debug, S_IRUSR);
Wey-Yi Guyb7af6a92011-04-06 15:55:25 -07002398 DEBUGFS_ADD_FILE(ucode_tracing, dir_debug, S_IWUSR | S_IRUSR);
Johannes Berg0da0e5b2011-04-08 08:14:56 -07002399 DEBUGFS_ADD_FILE(ucode_bt_stats, dir_debug, S_IRUSR);
Wey-Yi Guy54a9aa62010-09-05 10:49:42 -07002400 DEBUGFS_ADD_FILE(reply_tx_error, dir_debug, S_IRUSR);
Johannes Berg60987202010-02-18 00:36:07 -08002401 DEBUGFS_ADD_FILE(rxon_flags, dir_debug, S_IWUSR);
2402 DEBUGFS_ADD_FILE(rxon_filter_flags, dir_debug, S_IWUSR);
Wey-Yi Guy7e4005c2011-10-10 07:26:51 -07002403 DEBUGFS_ADD_FILE(echo_test, dir_debug, S_IWUSR);
Meenakshi Venkataraman2fdfc472012-03-15 13:26:56 -07002404 DEBUGFS_ADD_FILE(log_event, dir_debug, S_IWUSR | S_IRUSR);
2405
Stanislaw Gruszka88e58fc2011-01-28 16:47:47 +01002406 if (iwl_advanced_bt_coexist(priv))
Wey-Yi Guybefe8c42010-08-23 07:57:16 -07002407 DEBUGFS_ADD_FILE(bt_traffic, dir_debug, S_IRUSR);
Johannes Bergca934b62011-09-15 11:46:48 -07002408
Dor Shaishbfb45f52012-03-26 08:20:55 -07002409 /* Calibrations disabled/enabled status*/
David Spinadel647ad132012-03-31 08:31:05 -07002410 DEBUGFS_ADD_FILE(calib_disabled, dir_rf, S_IWUSR | S_IRUSR);
Emmanuel Grumbach87e56662011-08-25 23:10:50 -07002411
Emmanuel Grumbach68e8dfd2012-04-18 07:28:17 -07002412 if (iwl_trans_dbgfs_register(priv->trans, dir_debug))
Emmanuel Grumbach87e56662011-08-25 23:10:50 -07002413 goto err;
Tomas Winkler712b6cf2008-03-12 16:58:52 -07002414 return 0;
2415
2416err:
Johannes Berg4c84a8f2010-01-22 14:22:54 -08002417 IWL_ERR(priv, "Can't create the debugfs directory\n");
Tomas Winkler712b6cf2008-03-12 16:58:52 -07002418 iwl_dbgfs_unregister(priv);
Johannes Berg4c84a8f2010-01-22 14:22:54 -08002419 return -ENOMEM;
Tomas Winkler712b6cf2008-03-12 16:58:52 -07002420}
Tomas Winkler712b6cf2008-03-12 16:58:52 -07002421
2422/**
2423 * Remove the debugfs files and directories
2424 *
2425 */
2426void iwl_dbgfs_unregister(struct iwl_priv *priv)
2427{
Johannes Berg4c84a8f2010-01-22 14:22:54 -08002428 if (!priv->debugfs_dir)
Tomas Winkler712b6cf2008-03-12 16:58:52 -07002429 return;
2430
Johannes Berg4c84a8f2010-01-22 14:22:54 -08002431 debugfs_remove_recursive(priv->debugfs_dir);
2432 priv->debugfs_dir = NULL;
Tomas Winkler712b6cf2008-03-12 16:58:52 -07002433}