blob: eeb0bbd69d980a6f3b548baa3d2abda2dfcf88e5 [file] [log] [blame]
Johannes Berg7bcfaf22009-10-27 12:59:03 +01001
Jiri Bence9f207f2007-05-05 11:46:38 -07002/*
3 * mac80211 debugfs for wireless PHYs
4 *
5 * Copyright 2007 Johannes Berg <johannes@sipsolutions.net>
Johannes Bergd98ad832014-09-03 15:24:57 +03006 * Copyright 2013-2014 Intel Mobile Communications GmbH
Jiri Bence9f207f2007-05-05 11:46:38 -07007 *
8 * GPLv2
9 *
10 */
11
12#include <linux/debugfs.h>
13#include <linux/rtnetlink.h>
14#include "ieee80211_i.h"
Johannes Berg24487982009-04-23 18:52:52 +020015#include "driver-ops.h"
Johannes Berg2c8dccc2008-04-08 15:14:40 -040016#include "rate.h"
Jiri Bence9f207f2007-05-05 11:46:38 -070017#include "debugfs.h"
18
Eliad Peller07caf9d2010-10-27 14:58:29 +020019#define DEBUGFS_FORMAT_BUFFER_SIZE 100
20
Matti Gottliebad38bfc2013-11-18 19:06:45 +020021#define TX_LATENCY_BIN_DELIMTER_C ','
22#define TX_LATENCY_BIN_DELIMTER_S ","
23#define TX_LATENCY_BINS_DISABLED "enable(bins disabled)\n"
24#define TX_LATENCY_DISABLED "disable\n"
25
26
27/*
28 * Display if Tx latency statistics & bins are enabled/disabled
29 */
30static ssize_t sta_tx_latency_stat_read(struct file *file,
31 char __user *userbuf,
32 size_t count, loff_t *ppos)
33{
34 struct ieee80211_local *local = file->private_data;
35 struct ieee80211_tx_latency_bin_ranges *tx_latency;
36 char *buf;
37 int bufsz, i, ret;
38 int pos = 0;
39
40 rcu_read_lock();
41
42 tx_latency = rcu_dereference(local->tx_latency);
43
44 if (tx_latency && tx_latency->n_ranges) {
45 bufsz = tx_latency->n_ranges * 15;
46 buf = kzalloc(bufsz, GFP_ATOMIC);
47 if (!buf)
48 goto err;
49
50 for (i = 0; i < tx_latency->n_ranges; i++)
51 pos += scnprintf(buf + pos, bufsz - pos, "%d,",
52 tx_latency->ranges[i]);
53 pos += scnprintf(buf + pos, bufsz - pos, "\n");
54 } else if (tx_latency) {
55 bufsz = sizeof(TX_LATENCY_BINS_DISABLED) + 1;
56 buf = kzalloc(bufsz, GFP_ATOMIC);
57 if (!buf)
58 goto err;
59
60 pos += scnprintf(buf + pos, bufsz - pos, "%s\n",
61 TX_LATENCY_BINS_DISABLED);
62 } else {
63 bufsz = sizeof(TX_LATENCY_DISABLED) + 1;
64 buf = kzalloc(bufsz, GFP_ATOMIC);
65 if (!buf)
66 goto err;
67
68 pos += scnprintf(buf + pos, bufsz - pos, "%s\n",
69 TX_LATENCY_DISABLED);
70 }
71
72 rcu_read_unlock();
73
74 ret = simple_read_from_buffer(userbuf, count, ppos, buf, pos);
75 kfree(buf);
76
77 return ret;
78err:
79 rcu_read_unlock();
80 return -ENOMEM;
81}
82
83/*
84 * Receive input from user regarding Tx latency statistics
85 * The input should indicate if Tx latency statistics and bins are
86 * enabled/disabled.
87 * If bins are enabled input should indicate the amount of different bins and
88 * their ranges. Each bin will count how many Tx frames transmitted within the
89 * appropriate latency.
90 * Legal input is:
91 * a) "enable(bins disabled)" - to enable only general statistics
92 * b) "a,b,c,d,...z" - to enable general statistics and bins, where all are
93 * numbers and a < b < c < d.. < z
94 * c) "disable" - disable all statistics
95 * NOTE: must configure Tx latency statistics bins before stations connected.
96 */
97
98static ssize_t sta_tx_latency_stat_write(struct file *file,
99 const char __user *userbuf,
100 size_t count, loff_t *ppos)
101{
102 struct ieee80211_local *local = file->private_data;
103 char buf[128] = {};
104 char *bins = buf;
105 char *token;
106 int buf_size, i, alloc_size;
107 int prev_bin = 0;
108 int n_ranges = 0;
109 int ret = count;
110 struct ieee80211_tx_latency_bin_ranges *tx_latency;
111
112 if (sizeof(buf) <= count)
113 return -EINVAL;
114 buf_size = count;
115 if (copy_from_user(buf, userbuf, buf_size))
116 return -EFAULT;
117
118 mutex_lock(&local->sta_mtx);
119
120 /* cannot change config once we have stations */
121 if (local->num_sta)
122 goto unlock;
123
124 tx_latency =
125 rcu_dereference_protected(local->tx_latency,
126 lockdep_is_held(&local->sta_mtx));
127
128 /* disable Tx statistics */
129 if (!strcmp(buf, TX_LATENCY_DISABLED)) {
130 if (!tx_latency)
131 goto unlock;
Monam Agarwal0c2bef462014-03-24 00:51:43 +0530132 RCU_INIT_POINTER(local->tx_latency, NULL);
Matti Gottliebad38bfc2013-11-18 19:06:45 +0200133 synchronize_rcu();
134 kfree(tx_latency);
135 goto unlock;
136 }
137
138 /* Tx latency already enabled */
139 if (tx_latency)
140 goto unlock;
141
142 if (strcmp(TX_LATENCY_BINS_DISABLED, buf)) {
143 /* check how many bins and between what ranges user requested */
144 token = buf;
145 while (*token != '\0') {
146 if (*token == TX_LATENCY_BIN_DELIMTER_C)
147 n_ranges++;
148 token++;
149 }
150 n_ranges++;
151 }
152
153 alloc_size = sizeof(struct ieee80211_tx_latency_bin_ranges) +
154 n_ranges * sizeof(u32);
155 tx_latency = kzalloc(alloc_size, GFP_ATOMIC);
156 if (!tx_latency) {
157 ret = -ENOMEM;
158 goto unlock;
159 }
160 tx_latency->n_ranges = n_ranges;
161 for (i = 0; i < n_ranges; i++) { /* setting bin ranges */
162 token = strsep(&bins, TX_LATENCY_BIN_DELIMTER_S);
163 sscanf(token, "%d", &tx_latency->ranges[i]);
164 /* bins values should be in ascending order */
165 if (prev_bin >= tx_latency->ranges[i]) {
166 ret = -EINVAL;
167 kfree(tx_latency);
168 goto unlock;
169 }
170 prev_bin = tx_latency->ranges[i];
171 }
172 rcu_assign_pointer(local->tx_latency, tx_latency);
173
174unlock:
175 mutex_unlock(&local->sta_mtx);
176
177 return ret;
178}
179
180static const struct file_operations stats_tx_latency_ops = {
181 .write = sta_tx_latency_stat_write,
182 .read = sta_tx_latency_stat_read,
183 .open = simple_open,
184 .llseek = generic_file_llseek,
185};
186
Eliad Peller07caf9d2010-10-27 14:58:29 +0200187int mac80211_format_buffer(char __user *userbuf, size_t count,
188 loff_t *ppos, char *fmt, ...)
189{
190 va_list args;
191 char buf[DEBUGFS_FORMAT_BUFFER_SIZE];
192 int res;
193
194 va_start(args, fmt);
195 res = vscnprintf(buf, sizeof(buf), fmt, args);
196 va_end(args);
197
198 return simple_read_from_buffer(userbuf, count, ppos, buf, res);
199}
200
Ben Greear279daf62011-03-23 14:04:31 -0700201#define DEBUGFS_READONLY_FILE_FN(name, fmt, value...) \
Jiri Bence9f207f2007-05-05 11:46:38 -0700202static ssize_t name## _read(struct file *file, char __user *userbuf, \
203 size_t count, loff_t *ppos) \
204{ \
205 struct ieee80211_local *local = file->private_data; \
Jiri Bence9f207f2007-05-05 11:46:38 -0700206 \
Eliad Peller07caf9d2010-10-27 14:58:29 +0200207 return mac80211_format_buffer(userbuf, count, ppos, \
208 fmt "\n", ##value); \
Ben Greear279daf62011-03-23 14:04:31 -0700209}
210
211#define DEBUGFS_READONLY_FILE_OPS(name) \
Jiri Bence9f207f2007-05-05 11:46:38 -0700212static const struct file_operations name## _ops = { \
213 .read = name## _read, \
Stephen Boyd234e3402012-04-05 14:25:11 -0700214 .open = simple_open, \
Arnd Bergmann2b18ab362010-07-06 19:05:31 +0200215 .llseek = generic_file_llseek, \
Jiri Bence9f207f2007-05-05 11:46:38 -0700216};
217
Ben Greear279daf62011-03-23 14:04:31 -0700218#define DEBUGFS_READONLY_FILE(name, fmt, value...) \
219 DEBUGFS_READONLY_FILE_FN(name, fmt, value) \
220 DEBUGFS_READONLY_FILE_OPS(name)
221
Jiri Bence9f207f2007-05-05 11:46:38 -0700222#define DEBUGFS_ADD(name) \
Johannes Berg7bcfaf22009-10-27 12:59:03 +0100223 debugfs_create_file(#name, 0400, phyd, local, &name## _ops);
Jiri Bence9f207f2007-05-05 11:46:38 -0700224
Johannes Berg827b1fb2009-03-13 11:44:18 +0100225#define DEBUGFS_ADD_MODE(name, mode) \
Johannes Berg7bcfaf22009-10-27 12:59:03 +0100226 debugfs_create_file(#name, mode, phyd, local, &name## _ops);
Jiri Bence9f207f2007-05-05 11:46:38 -0700227
228
Ben Greear83bdf2a2011-02-15 13:11:22 -0800229DEBUGFS_READONLY_FILE(user_power, "%d",
230 local->user_power_level);
231DEBUGFS_READONLY_FILE(power, "%d",
232 local->hw.conf.power_level);
Eliad Peller07caf9d2010-10-27 14:58:29 +0200233DEBUGFS_READONLY_FILE(total_ps_buffered, "%d",
Jiri Bence9f207f2007-05-05 11:46:38 -0700234 local->total_ps_buffered);
Eliad Peller07caf9d2010-10-27 14:58:29 +0200235DEBUGFS_READONLY_FILE(wep_iv, "%#08x",
Jiri Bence9f207f2007-05-05 11:46:38 -0700236 local->wep_iv & 0xffffff);
Eliad Peller07caf9d2010-10-27 14:58:29 +0200237DEBUGFS_READONLY_FILE(rate_ctrl_alg, "%s",
Johannes Bergaf65cd962009-11-17 18:18:36 +0100238 local->rate_ctrl ? local->rate_ctrl->ops->name : "hw/driver");
Alina Friedrichsen3b5d6652009-01-24 07:09:59 +0100239
Johannes Berg2ad48142012-09-19 08:20:24 +0200240#ifdef CONFIG_PM
Johannes Berg827b1fb2009-03-13 11:44:18 +0100241static ssize_t reset_write(struct file *file, const char __user *user_buf,
242 size_t count, loff_t *ppos)
243{
244 struct ieee80211_local *local = file->private_data;
245
246 rtnl_lock();
Johannes Bergeecc4802011-05-04 15:37:29 +0200247 __ieee80211_suspend(&local->hw, NULL);
Johannes Berg827b1fb2009-03-13 11:44:18 +0100248 __ieee80211_resume(&local->hw);
249 rtnl_unlock();
250
251 return count;
252}
253
254static const struct file_operations reset_ops = {
255 .write = reset_write,
Stephen Boyd234e3402012-04-05 14:25:11 -0700256 .open = simple_open,
Arnd Bergmann6038f372010-08-15 18:52:59 +0200257 .llseek = noop_llseek,
Johannes Berg827b1fb2009-03-13 11:44:18 +0100258};
Johannes Berg2ad48142012-09-19 08:20:24 +0200259#endif
Johannes Berg827b1fb2009-03-13 11:44:18 +0100260
Ben Greear279daf62011-03-23 14:04:31 -0700261static ssize_t hwflags_read(struct file *file, char __user *user_buf,
262 size_t count, loff_t *ppos)
263{
264 struct ieee80211_local *local = file->private_data;
265 int mxln = 500;
266 ssize_t rv;
267 char *buf = kzalloc(mxln, GFP_KERNEL);
268 int sf = 0; /* how many written so far */
269
Joe Perchesd15b8452011-08-29 14:17:31 -0700270 if (!buf)
271 return 0;
272
Eliad Pellerf364ef92013-08-27 12:40:15 +0300273 sf += scnprintf(buf, mxln - sf, "0x%x\n", local->hw.flags);
Ben Greear279daf62011-03-23 14:04:31 -0700274 if (local->hw.flags & IEEE80211_HW_HAS_RATE_CONTROL)
Eliad Pellerf364ef92013-08-27 12:40:15 +0300275 sf += scnprintf(buf + sf, mxln - sf, "HAS_RATE_CONTROL\n");
Ben Greear279daf62011-03-23 14:04:31 -0700276 if (local->hw.flags & IEEE80211_HW_RX_INCLUDES_FCS)
Eliad Pellerf364ef92013-08-27 12:40:15 +0300277 sf += scnprintf(buf + sf, mxln - sf, "RX_INCLUDES_FCS\n");
Ben Greear279daf62011-03-23 14:04:31 -0700278 if (local->hw.flags & IEEE80211_HW_HOST_BROADCAST_PS_BUFFERING)
Eliad Pellerf364ef92013-08-27 12:40:15 +0300279 sf += scnprintf(buf + sf, mxln - sf,
280 "HOST_BCAST_PS_BUFFERING\n");
Ben Greear279daf62011-03-23 14:04:31 -0700281 if (local->hw.flags & IEEE80211_HW_2GHZ_SHORT_SLOT_INCAPABLE)
Eliad Pellerf364ef92013-08-27 12:40:15 +0300282 sf += scnprintf(buf + sf, mxln - sf,
283 "2GHZ_SHORT_SLOT_INCAPABLE\n");
Ben Greear279daf62011-03-23 14:04:31 -0700284 if (local->hw.flags & IEEE80211_HW_2GHZ_SHORT_PREAMBLE_INCAPABLE)
Eliad Pellerf364ef92013-08-27 12:40:15 +0300285 sf += scnprintf(buf + sf, mxln - sf,
286 "2GHZ_SHORT_PREAMBLE_INCAPABLE\n");
Ben Greear279daf62011-03-23 14:04:31 -0700287 if (local->hw.flags & IEEE80211_HW_SIGNAL_UNSPEC)
Eliad Pellerf364ef92013-08-27 12:40:15 +0300288 sf += scnprintf(buf + sf, mxln - sf, "SIGNAL_UNSPEC\n");
Ben Greear279daf62011-03-23 14:04:31 -0700289 if (local->hw.flags & IEEE80211_HW_SIGNAL_DBM)
Eliad Pellerf364ef92013-08-27 12:40:15 +0300290 sf += scnprintf(buf + sf, mxln - sf, "SIGNAL_DBM\n");
Emmanuel Grumbachc65dd142012-12-12 10:12:24 +0200291 if (local->hw.flags & IEEE80211_HW_NEED_DTIM_BEFORE_ASSOC)
Eliad Pellerf364ef92013-08-27 12:40:15 +0300292 sf += scnprintf(buf + sf, mxln - sf,
293 "NEED_DTIM_BEFORE_ASSOC\n");
Ben Greear279daf62011-03-23 14:04:31 -0700294 if (local->hw.flags & IEEE80211_HW_SPECTRUM_MGMT)
Eliad Pellerf364ef92013-08-27 12:40:15 +0300295 sf += scnprintf(buf + sf, mxln - sf, "SPECTRUM_MGMT\n");
Ben Greear279daf62011-03-23 14:04:31 -0700296 if (local->hw.flags & IEEE80211_HW_AMPDU_AGGREGATION)
Eliad Pellerf364ef92013-08-27 12:40:15 +0300297 sf += scnprintf(buf + sf, mxln - sf, "AMPDU_AGGREGATION\n");
Ben Greear279daf62011-03-23 14:04:31 -0700298 if (local->hw.flags & IEEE80211_HW_SUPPORTS_PS)
Eliad Pellerf364ef92013-08-27 12:40:15 +0300299 sf += scnprintf(buf + sf, mxln - sf, "SUPPORTS_PS\n");
Ben Greear279daf62011-03-23 14:04:31 -0700300 if (local->hw.flags & IEEE80211_HW_PS_NULLFUNC_STACK)
Eliad Pellerf364ef92013-08-27 12:40:15 +0300301 sf += scnprintf(buf + sf, mxln - sf, "PS_NULLFUNC_STACK\n");
Ben Greear279daf62011-03-23 14:04:31 -0700302 if (local->hw.flags & IEEE80211_HW_SUPPORTS_DYNAMIC_PS)
Eliad Pellerf364ef92013-08-27 12:40:15 +0300303 sf += scnprintf(buf + sf, mxln - sf, "SUPPORTS_DYNAMIC_PS\n");
Ben Greear279daf62011-03-23 14:04:31 -0700304 if (local->hw.flags & IEEE80211_HW_MFP_CAPABLE)
Eliad Pellerf364ef92013-08-27 12:40:15 +0300305 sf += scnprintf(buf + sf, mxln - sf, "MFP_CAPABLE\n");
Ben Greear279daf62011-03-23 14:04:31 -0700306 if (local->hw.flags & IEEE80211_HW_REPORTS_TX_ACK_STATUS)
Eliad Pellerf364ef92013-08-27 12:40:15 +0300307 sf += scnprintf(buf + sf, mxln - sf,
308 "REPORTS_TX_ACK_STATUS\n");
Ben Greear279daf62011-03-23 14:04:31 -0700309 if (local->hw.flags & IEEE80211_HW_CONNECTION_MONITOR)
Eliad Pellerf364ef92013-08-27 12:40:15 +0300310 sf += scnprintf(buf + sf, mxln - sf, "CONNECTION_MONITOR\n");
Ben Greear279daf62011-03-23 14:04:31 -0700311 if (local->hw.flags & IEEE80211_HW_SUPPORTS_PER_STA_GTK)
Eliad Pellerf364ef92013-08-27 12:40:15 +0300312 sf += scnprintf(buf + sf, mxln - sf, "SUPPORTS_PER_STA_GTK\n");
Ben Greear279daf62011-03-23 14:04:31 -0700313 if (local->hw.flags & IEEE80211_HW_AP_LINK_PS)
Eliad Pellerf364ef92013-08-27 12:40:15 +0300314 sf += scnprintf(buf + sf, mxln - sf, "AP_LINK_PS\n");
Arik Nemtsovedf6b782011-08-30 09:32:38 +0300315 if (local->hw.flags & IEEE80211_HW_TX_AMPDU_SETUP_IN_HW)
Eliad Pellerf364ef92013-08-27 12:40:15 +0300316 sf += scnprintf(buf + sf, mxln - sf, "TX_AMPDU_SETUP_IN_HW\n");
Ben Greear279daf62011-03-23 14:04:31 -0700317
318 rv = simple_read_from_buffer(user_buf, count, ppos, buf, strlen(buf));
319 kfree(buf);
320 return rv;
321}
Benoit Papillault199d69f2010-02-04 22:00:20 +0100322
Johannes Bergdb2e6bd2009-06-14 17:37:39 +0200323static ssize_t queues_read(struct file *file, char __user *user_buf,
324 size_t count, loff_t *ppos)
325{
326 struct ieee80211_local *local = file->private_data;
327 unsigned long flags;
328 char buf[IEEE80211_MAX_QUEUES * 20];
329 int q, res = 0;
330
331 spin_lock_irqsave(&local->queue_stop_reason_lock, flags);
332 for (q = 0; q < local->hw.queues; q++)
333 res += sprintf(buf + res, "%02d: %#.8lx/%d\n", q,
334 local->queue_stop_reasons[q],
Johannes Berg3b8d81e02009-06-17 17:43:56 +0200335 skb_queue_len(&local->pending[q]));
Johannes Bergdb2e6bd2009-06-14 17:37:39 +0200336 spin_unlock_irqrestore(&local->queue_stop_reason_lock, flags);
337
338 return simple_read_from_buffer(user_buf, count, ppos, buf, res);
339}
340
Ben Greear279daf62011-03-23 14:04:31 -0700341DEBUGFS_READONLY_FILE_OPS(hwflags);
Ben Greear279daf62011-03-23 14:04:31 -0700342DEBUGFS_READONLY_FILE_OPS(queues);
Johannes Bergdb2e6bd2009-06-14 17:37:39 +0200343
Jiri Bence9f207f2007-05-05 11:46:38 -0700344/* statistics stuff */
345
Jiri Bence9f207f2007-05-05 11:46:38 -0700346static ssize_t format_devstat_counter(struct ieee80211_local *local,
347 char __user *userbuf,
348 size_t count, loff_t *ppos,
349 int (*printvalue)(struct ieee80211_low_level_stats *stats, char *buf,
350 int buflen))
351{
352 struct ieee80211_low_level_stats stats;
353 char buf[20];
354 int res;
355
Johannes Berg75636522008-07-09 14:40:35 +0200356 rtnl_lock();
Johannes Berg24487982009-04-23 18:52:52 +0200357 res = drv_get_stats(local, &stats);
Jiri Bence9f207f2007-05-05 11:46:38 -0700358 rtnl_unlock();
Johannes Berg24487982009-04-23 18:52:52 +0200359 if (res)
360 return res;
361 res = printvalue(&stats, buf, sizeof(buf));
Jiri Bence9f207f2007-05-05 11:46:38 -0700362 return simple_read_from_buffer(userbuf, count, ppos, buf, res);
363}
364
365#define DEBUGFS_DEVSTATS_FILE(name) \
366static int print_devstats_##name(struct ieee80211_low_level_stats *stats,\
367 char *buf, int buflen) \
368{ \
369 return scnprintf(buf, buflen, "%u\n", stats->name); \
370} \
371static ssize_t stats_ ##name## _read(struct file *file, \
372 char __user *userbuf, \
373 size_t count, loff_t *ppos) \
374{ \
375 return format_devstat_counter(file->private_data, \
376 userbuf, \
377 count, \
378 ppos, \
379 print_devstats_##name); \
380} \
381 \
382static const struct file_operations stats_ ##name## _ops = { \
383 .read = stats_ ##name## _read, \
Stephen Boyd234e3402012-04-05 14:25:11 -0700384 .open = simple_open, \
Arnd Bergmann2b18ab362010-07-06 19:05:31 +0200385 .llseek = generic_file_llseek, \
Jiri Bence9f207f2007-05-05 11:46:38 -0700386};
387
Felix Fietkau2826bcd2010-06-02 02:57:34 +0200388#define DEBUGFS_STATS_ADD(name, field) \
389 debugfs_create_u32(#name, 0400, statsd, (u32 *) &field);
390#define DEBUGFS_DEVSTATS_ADD(name) \
Johannes Berg7bcfaf22009-10-27 12:59:03 +0100391 debugfs_create_file(#name, 0400, statsd, local, &stats_ ##name## _ops);
Jiri Bence9f207f2007-05-05 11:46:38 -0700392
Jiri Bence9f207f2007-05-05 11:46:38 -0700393DEBUGFS_DEVSTATS_FILE(dot11ACKFailureCount);
394DEBUGFS_DEVSTATS_FILE(dot11RTSFailureCount);
395DEBUGFS_DEVSTATS_FILE(dot11FCSErrorCount);
396DEBUGFS_DEVSTATS_FILE(dot11RTSSuccessCount);
397
Jiri Bence9f207f2007-05-05 11:46:38 -0700398void debugfs_hw_add(struct ieee80211_local *local)
399{
400 struct dentry *phyd = local->hw.wiphy->debugfsdir;
401 struct dentry *statsd;
402
403 if (!phyd)
404 return;
405
Jiri Bence9f207f2007-05-05 11:46:38 -0700406 local->debugfs.keys = debugfs_create_dir("keys", phyd);
407
Jiri Bence9f207f2007-05-05 11:46:38 -0700408 DEBUGFS_ADD(total_ps_buffered);
Jiri Bence9f207f2007-05-05 11:46:38 -0700409 DEBUGFS_ADD(wep_iv);
Johannes Bergdb2e6bd2009-06-14 17:37:39 +0200410 DEBUGFS_ADD(queues);
Johannes Berg2ad48142012-09-19 08:20:24 +0200411#ifdef CONFIG_PM
Johannes Berg827b1fb2009-03-13 11:44:18 +0100412 DEBUGFS_ADD_MODE(reset, 0200);
Johannes Berg2ad48142012-09-19 08:20:24 +0200413#endif
Ben Greear279daf62011-03-23 14:04:31 -0700414 DEBUGFS_ADD(hwflags);
Ben Greear83bdf2a2011-02-15 13:11:22 -0800415 DEBUGFS_ADD(user_power);
416 DEBUGFS_ADD(power);
Jiri Bence9f207f2007-05-05 11:46:38 -0700417
418 statsd = debugfs_create_dir("statistics", phyd);
Jiri Bence9f207f2007-05-05 11:46:38 -0700419
420 /* if the dir failed, don't put all the other things into the root! */
421 if (!statsd)
422 return;
423
Felix Fietkau2826bcd2010-06-02 02:57:34 +0200424 DEBUGFS_STATS_ADD(transmitted_fragment_count,
425 local->dot11TransmittedFragmentCount);
426 DEBUGFS_STATS_ADD(multicast_transmitted_frame_count,
427 local->dot11MulticastTransmittedFrameCount);
428 DEBUGFS_STATS_ADD(failed_count, local->dot11FailedCount);
429 DEBUGFS_STATS_ADD(retry_count, local->dot11RetryCount);
430 DEBUGFS_STATS_ADD(multiple_retry_count,
431 local->dot11MultipleRetryCount);
432 DEBUGFS_STATS_ADD(frame_duplicate_count,
433 local->dot11FrameDuplicateCount);
434 DEBUGFS_STATS_ADD(received_fragment_count,
435 local->dot11ReceivedFragmentCount);
436 DEBUGFS_STATS_ADD(multicast_received_frame_count,
437 local->dot11MulticastReceivedFrameCount);
438 DEBUGFS_STATS_ADD(transmitted_frame_count,
439 local->dot11TransmittedFrameCount);
Jiri Bence9f207f2007-05-05 11:46:38 -0700440#ifdef CONFIG_MAC80211_DEBUG_COUNTERS
Felix Fietkau2826bcd2010-06-02 02:57:34 +0200441 DEBUGFS_STATS_ADD(tx_handlers_drop, local->tx_handlers_drop);
442 DEBUGFS_STATS_ADD(tx_handlers_queued, local->tx_handlers_queued);
443 DEBUGFS_STATS_ADD(tx_handlers_drop_unencrypted,
444 local->tx_handlers_drop_unencrypted);
445 DEBUGFS_STATS_ADD(tx_handlers_drop_fragment,
446 local->tx_handlers_drop_fragment);
447 DEBUGFS_STATS_ADD(tx_handlers_drop_wep,
448 local->tx_handlers_drop_wep);
449 DEBUGFS_STATS_ADD(tx_handlers_drop_not_assoc,
450 local->tx_handlers_drop_not_assoc);
451 DEBUGFS_STATS_ADD(tx_handlers_drop_unauth_port,
452 local->tx_handlers_drop_unauth_port);
453 DEBUGFS_STATS_ADD(rx_handlers_drop, local->rx_handlers_drop);
454 DEBUGFS_STATS_ADD(rx_handlers_queued, local->rx_handlers_queued);
455 DEBUGFS_STATS_ADD(rx_handlers_drop_nullfunc,
456 local->rx_handlers_drop_nullfunc);
457 DEBUGFS_STATS_ADD(rx_handlers_drop_defrag,
458 local->rx_handlers_drop_defrag);
459 DEBUGFS_STATS_ADD(rx_handlers_drop_short,
460 local->rx_handlers_drop_short);
Felix Fietkau2826bcd2010-06-02 02:57:34 +0200461 DEBUGFS_STATS_ADD(tx_expand_skb_head,
462 local->tx_expand_skb_head);
463 DEBUGFS_STATS_ADD(tx_expand_skb_head_cloned,
464 local->tx_expand_skb_head_cloned);
465 DEBUGFS_STATS_ADD(rx_expand_skb_head,
466 local->rx_expand_skb_head);
467 DEBUGFS_STATS_ADD(rx_expand_skb_head2,
468 local->rx_expand_skb_head2);
469 DEBUGFS_STATS_ADD(rx_handlers_fragments,
470 local->rx_handlers_fragments);
471 DEBUGFS_STATS_ADD(tx_status_drop,
472 local->tx_status_drop);
Jiri Bence9f207f2007-05-05 11:46:38 -0700473#endif
Felix Fietkau2826bcd2010-06-02 02:57:34 +0200474 DEBUGFS_DEVSTATS_ADD(dot11ACKFailureCount);
475 DEBUGFS_DEVSTATS_ADD(dot11RTSFailureCount);
476 DEBUGFS_DEVSTATS_ADD(dot11FCSErrorCount);
477 DEBUGFS_DEVSTATS_ADD(dot11RTSSuccessCount);
Matti Gottliebad38bfc2013-11-18 19:06:45 +0200478
479 DEBUGFS_DEVSTATS_ADD(tx_latency);
Jiri Bence9f207f2007-05-05 11:46:38 -0700480}