20 #define STA_READ(name, field, format_string) \
21 static ssize_t sta_ ##name## _read(struct file *file, \
22 char __user *userbuf, \
23 size_t count, loff_t *ppos) \
25 struct sta_info *sta = file->private_data; \
26 return mac80211_format_buffer(userbuf, count, ppos, \
27 format_string, sta->field); \
29 #define STA_READ_D(name, field) STA_READ(name, field, "%d\n")
30 #define STA_READ_U(name, field) STA_READ(name, field, "%u\n")
31 #define STA_READ_S(name, field) STA_READ(name, field, "%s\n")
33 #define STA_OPS(name) \
34 static const struct file_operations sta_ ##name## _ops = { \
35 .read = sta_##name##_read, \
36 .open = simple_open, \
37 .llseek = generic_file_llseek, \
40 #define STA_OPS_RW(name) \
41 static const struct file_operations sta_ ##name## _ops = { \
42 .read = sta_##name##_read, \
43 .write = sta_##name##_write, \
44 .open = simple_open, \
45 .llseek = generic_file_llseek, \
48 #define STA_FILE(name, field, format) \
49 STA_READ_##format(name, field) \
57 size_t count, loff_t *ppos)
63 test_sta_flag(sta, WLAN_STA_##flg) ? #flg "\n" : ""
66 "%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s",
73 TEST(TDLS_PEER_AUTH),
TEST(4ADDR_EVENT),
81 static ssize_t sta_num_ps_buf_frames_read(
struct file *file,
83 size_t count, loff_t *ppos)
90 p +=
scnprintf(p,
sizeof(buf)+buf-p,
"AC%d: %d\n", ac,
97 static ssize_t sta_inactive_ms_read(
struct file *file,
char __user *userbuf,
98 size_t count, loff_t *ppos)
107 static ssize_t sta_connected_time_read(
struct file *file,
char __user *userbuf,
108 size_t count, loff_t *ppos)
113 long connected_time_secs;
122 "years - %ld\nmonths - %d\ndays - %d\nclock - %d:%d:%d\n\n",
131 static ssize_t sta_last_seq_ctrl_read(
struct file *file,
char __user *userbuf,
132 size_t count, loff_t *ppos)
138 p +=
scnprintf(p,
sizeof(buf)+buf-p,
"%x ",
140 p +=
scnprintf(p,
sizeof(buf)+buf-p,
"\n");
145 static ssize_t sta_agg_status_read(
struct file *file,
char __user *userbuf,
146 size_t count, loff_t *ppos)
156 p +=
scnprintf(p,
sizeof(buf) + buf - p,
"next dialog_token: %#02x\n",
159 "TID\t\tRX active\tDTKN\tSSN\t\tTX\tDTKN\tpending\n");
165 p +=
scnprintf(p,
sizeof(buf) + buf - p,
"%02d", i);
166 p +=
scnprintf(p,
sizeof(buf) + buf - p,
"\t\t%x", !!tid_rx);
167 p +=
scnprintf(p,
sizeof(buf) + buf - p,
"\t%#.2x",
169 p +=
scnprintf(p,
sizeof(buf) + buf - p,
"\t%#.3x",
170 tid_rx ? tid_rx->
ssn : 0);
172 p +=
scnprintf(p,
sizeof(buf) + buf - p,
"\t\t%x", !!tid_tx);
173 p +=
scnprintf(p,
sizeof(buf) + buf - p,
"\t%#.2x",
175 p +=
scnprintf(p,
sizeof(buf) + buf - p,
"\t%03d",
176 tid_tx ? skb_queue_len(&tid_tx->
pending) : 0);
177 p +=
scnprintf(p,
sizeof(buf) + buf - p,
"\n");
184 static ssize_t sta_agg_status_write(
struct file *file,
const char __user *userbuf,
185 size_t count, loff_t *ppos)
187 char _buf[12], *buf = _buf;
193 if (count >
sizeof(_buf))
199 buf[
sizeof(_buf) - 1] =
'\0';
201 if (
strncmp(buf,
"tx ", 3) == 0) {
204 }
else if (
strncmp(buf,
"rx ", 3) == 0) {
210 if (
strncmp(buf,
"start ", 6) == 0) {
215 }
else if (
strncmp(buf,
"stop ", 5) == 0) {
223 if (tid >= STA_TID_NUM)
241 static ssize_t sta_ht_capa_read(
struct file *file,
char __user *userbuf,
242 size_t count, loff_t *ppos)
244 #define PRINT_HT_CAP(_cond, _str) \
247 p += scnprintf(p, sizeof(buf)+buf-p, "\t" _str "\n"); \
249 char buf[512], *p =
buf;
254 p +=
scnprintf(p,
sizeof(buf) + buf - p,
"ht %ssupported\n",
257 p +=
scnprintf(p,
sizeof(buf)+buf-p,
"cap: %#.4x\n", htc->
cap);
299 p +=
scnprintf(p,
sizeof(buf)+buf-p,
"ampdu factor/density: %d/%d\n",
301 p +=
scnprintf(p,
sizeof(buf)+buf-p,
"MCS mask:");
304 p +=
scnprintf(p,
sizeof(buf)+buf-p,
" %.2x",
305 htc->
mcs.rx_mask[i]);
306 p +=
scnprintf(p,
sizeof(buf)+buf-p,
"\n");
311 "MCS rx highest: %d Mbps\n",
315 p +=
scnprintf(p,
sizeof(buf)+buf-p,
"MCS tx params: %x\n",
323 #define DEBUGFS_ADD(name) \
324 debugfs_create_file(#name, 0400, \
325 sta->debugfs.dir, sta, &sta_ ##name## _ops);
327 #define DEBUGFS_ADD_COUNTER(name, field) \
328 if (sizeof(sta->field) == sizeof(u32)) \
329 debugfs_create_u32(#name, 0400, sta->debugfs.dir, \
330 (u32 *) &sta->field); \
332 debugfs_create_u64(#name, 0400, sta->debugfs.dir, \
333 (u64 *) &sta->field);
337 struct dentry *stations_dir = sta->
sdata->debugfs.subdir_stations;
340 sta->debugfs.add_has_run =
true;
357 if (!sta->debugfs.dir)
387 sta->debugfs.dir =
NULL;