2 * Copyright (c) 2006 Jiri Benc <jbenc@suse.cz>
3 * Copyright 2007 Johannes Berg <johannes@sipsolutions.net>
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License version 2 as
7 * published by the Free Software Foundation.
10 #include <linux/kernel.h>
11 #include <linux/device.h>
13 #include <linux/if_ether.h>
14 #include <linux/interrupt.h>
15 #include <linux/netdevice.h>
16 #include <linux/rtnetlink.h>
17 #include <linux/slab.h>
18 #include <linux/notifier.h>
19 #include <net/mac80211.h>
20 #include <net/cfg80211.h>
21 #include "ieee80211_i.h"
24 #include "debugfs_netdev.h"
25 #include "driver-ops.h"
27 static ssize_t
ieee80211_if_read(
28 struct ieee80211_sub_if_data
*sdata
,
30 size_t count
, loff_t
*ppos
,
31 ssize_t (*format
)(const struct ieee80211_sub_if_data
*, char *, int))
34 ssize_t ret
= -EINVAL
;
36 read_lock(&dev_base_lock
);
37 ret
= (*format
)(sdata
, buf
, sizeof(buf
));
38 read_unlock(&dev_base_lock
);
41 ret
= simple_read_from_buffer(userbuf
, count
, ppos
, buf
, ret
);
46 static ssize_t
ieee80211_if_write(
47 struct ieee80211_sub_if_data
*sdata
,
48 const char __user
*userbuf
,
49 size_t count
, loff_t
*ppos
,
50 ssize_t (*write
)(struct ieee80211_sub_if_data
*, const char *, int))
55 if (count
>= sizeof(buf
))
58 if (copy_from_user(buf
, userbuf
, count
))
64 ret
= (*write
)(sdata
, buf
, count
);
70 #define IEEE80211_IF_FMT(name, field, format_string) \
71 static ssize_t ieee80211_if_fmt_##name( \
72 const struct ieee80211_sub_if_data *sdata, char *buf, \
75 return scnprintf(buf, buflen, format_string, sdata->field); \
77 #define IEEE80211_IF_FMT_DEC(name, field) \
78 IEEE80211_IF_FMT(name, field, "%d\n")
79 #define IEEE80211_IF_FMT_HEX(name, field) \
80 IEEE80211_IF_FMT(name, field, "%#x\n")
81 #define IEEE80211_IF_FMT_LHEX(name, field) \
82 IEEE80211_IF_FMT(name, field, "%#lx\n")
83 #define IEEE80211_IF_FMT_SIZE(name, field) \
84 IEEE80211_IF_FMT(name, field, "%zd\n")
86 #define IEEE80211_IF_FMT_HEXARRAY(name, field) \
87 static ssize_t ieee80211_if_fmt_##name( \
88 const struct ieee80211_sub_if_data *sdata, \
89 char *buf, int buflen) \
93 for (i = 0; i < sizeof(sdata->field); i++) { \
94 p += scnprintf(p, buflen + buf - p, "%.2x ", \
97 p += scnprintf(p, buflen + buf - p, "\n"); \
101 #define IEEE80211_IF_FMT_ATOMIC(name, field) \
102 static ssize_t ieee80211_if_fmt_##name( \
103 const struct ieee80211_sub_if_data *sdata, \
104 char *buf, int buflen) \
106 return scnprintf(buf, buflen, "%d\n", atomic_read(&sdata->field));\
109 #define IEEE80211_IF_FMT_MAC(name, field) \
110 static ssize_t ieee80211_if_fmt_##name( \
111 const struct ieee80211_sub_if_data *sdata, char *buf, \
114 return scnprintf(buf, buflen, "%pM\n", sdata->field); \
117 #define IEEE80211_IF_FMT_DEC_DIV_16(name, field) \
118 static ssize_t ieee80211_if_fmt_##name( \
119 const struct ieee80211_sub_if_data *sdata, \
120 char *buf, int buflen) \
122 return scnprintf(buf, buflen, "%d\n", sdata->field / 16); \
125 #define IEEE80211_IF_FMT_JIFFIES_TO_MS(name, field) \
126 static ssize_t ieee80211_if_fmt_##name( \
127 const struct ieee80211_sub_if_data *sdata, \
128 char *buf, int buflen) \
130 return scnprintf(buf, buflen, "%d\n", \
131 jiffies_to_msecs(sdata->field)); \
134 #define _IEEE80211_IF_FILE_OPS(name, _read, _write) \
135 static const struct file_operations name##_ops = { \
138 .open = simple_open, \
139 .llseek = generic_file_llseek, \
142 #define _IEEE80211_IF_FILE_R_FN(name) \
143 static ssize_t ieee80211_if_read_##name(struct file *file, \
144 char __user *userbuf, \
145 size_t count, loff_t *ppos) \
147 return ieee80211_if_read(file->private_data, \
148 userbuf, count, ppos, \
149 ieee80211_if_fmt_##name); \
152 #define _IEEE80211_IF_FILE_W_FN(name) \
153 static ssize_t ieee80211_if_write_##name(struct file *file, \
154 const char __user *userbuf, \
155 size_t count, loff_t *ppos) \
157 return ieee80211_if_write(file->private_data, userbuf, count, \
158 ppos, ieee80211_if_parse_##name); \
161 #define IEEE80211_IF_FILE_R(name) \
162 _IEEE80211_IF_FILE_R_FN(name) \
163 _IEEE80211_IF_FILE_OPS(name, ieee80211_if_read_##name, NULL)
165 #define IEEE80211_IF_FILE_W(name) \
166 _IEEE80211_IF_FILE_W_FN(name) \
167 _IEEE80211_IF_FILE_OPS(name, NULL, ieee80211_if_write_##name)
169 #define IEEE80211_IF_FILE_RW(name) \
170 _IEEE80211_IF_FILE_R_FN(name) \
171 _IEEE80211_IF_FILE_W_FN(name) \
172 _IEEE80211_IF_FILE_OPS(name, ieee80211_if_read_##name, \
173 ieee80211_if_write_##name)
175 #define IEEE80211_IF_FILE(name, field, format) \
176 IEEE80211_IF_FMT_##format(name, field) \
177 IEEE80211_IF_FILE_R(name)
179 /* common attributes */
180 IEEE80211_IF_FILE(rc_rateidx_mask_2ghz
, rc_rateidx_mask
[IEEE80211_BAND_2GHZ
],
182 IEEE80211_IF_FILE(rc_rateidx_mask_5ghz
, rc_rateidx_mask
[IEEE80211_BAND_5GHZ
],
184 IEEE80211_IF_FILE(rc_rateidx_mcs_mask_2ghz
,
185 rc_rateidx_mcs_mask
[IEEE80211_BAND_2GHZ
], HEXARRAY
);
186 IEEE80211_IF_FILE(rc_rateidx_mcs_mask_5ghz
,
187 rc_rateidx_mcs_mask
[IEEE80211_BAND_5GHZ
], HEXARRAY
);
189 IEEE80211_IF_FILE(flags
, flags
, HEX
);
190 IEEE80211_IF_FILE(state
, state
, LHEX
);
191 IEEE80211_IF_FILE(txpower
, vif
.bss_conf
.txpower
, DEC
);
192 IEEE80211_IF_FILE(ap_power_level
, ap_power_level
, DEC
);
193 IEEE80211_IF_FILE(user_power_level
, user_power_level
, DEC
);
196 ieee80211_if_fmt_hw_queues(const struct ieee80211_sub_if_data
*sdata
,
197 char *buf
, int buflen
)
201 len
= scnprintf(buf
, buflen
, "AC queues: VO:%d VI:%d BE:%d BK:%d\n",
202 sdata
->vif
.hw_queue
[IEEE80211_AC_VO
],
203 sdata
->vif
.hw_queue
[IEEE80211_AC_VI
],
204 sdata
->vif
.hw_queue
[IEEE80211_AC_BE
],
205 sdata
->vif
.hw_queue
[IEEE80211_AC_BK
]);
207 if (sdata
->vif
.type
== NL80211_IFTYPE_AP
)
208 len
+= scnprintf(buf
+ len
, buflen
- len
, "cab queue: %d\n",
209 sdata
->vif
.cab_queue
);
213 IEEE80211_IF_FILE_R(hw_queues
);
216 IEEE80211_IF_FILE(bssid
, u
.mgd
.bssid
, MAC
);
217 IEEE80211_IF_FILE(aid
, u
.mgd
.aid
, DEC
);
218 IEEE80211_IF_FILE(last_beacon
, u
.mgd
.last_beacon_signal
, DEC
);
219 IEEE80211_IF_FILE(ave_beacon
, u
.mgd
.ave_beacon_signal
, DEC_DIV_16
);
220 IEEE80211_IF_FILE(beacon_timeout
, u
.mgd
.beacon_timeout
, JIFFIES_TO_MS
);
222 static int ieee80211_set_smps(struct ieee80211_sub_if_data
*sdata
,
223 enum ieee80211_smps_mode smps_mode
)
225 struct ieee80211_local
*local
= sdata
->local
;
228 if (!(local
->hw
.wiphy
->features
& NL80211_FEATURE_STATIC_SMPS
) &&
229 smps_mode
== IEEE80211_SMPS_STATIC
)
232 /* auto should be dynamic if in PS mode */
233 if (!(local
->hw
.wiphy
->features
& NL80211_FEATURE_DYNAMIC_SMPS
) &&
234 (smps_mode
== IEEE80211_SMPS_DYNAMIC
||
235 smps_mode
== IEEE80211_SMPS_AUTOMATIC
))
238 if (sdata
->vif
.type
!= NL80211_IFTYPE_STATION
&&
239 sdata
->vif
.type
!= NL80211_IFTYPE_AP
)
243 if (sdata
->vif
.type
== NL80211_IFTYPE_STATION
)
244 err
= __ieee80211_request_smps_mgd(sdata
, smps_mode
);
246 err
= __ieee80211_request_smps_ap(sdata
, smps_mode
);
252 static const char *smps_modes
[IEEE80211_SMPS_NUM_MODES
] = {
253 [IEEE80211_SMPS_AUTOMATIC
] = "auto",
254 [IEEE80211_SMPS_OFF
] = "off",
255 [IEEE80211_SMPS_STATIC
] = "static",
256 [IEEE80211_SMPS_DYNAMIC
] = "dynamic",
259 static ssize_t
ieee80211_if_fmt_smps(const struct ieee80211_sub_if_data
*sdata
,
260 char *buf
, int buflen
)
262 if (sdata
->vif
.type
== NL80211_IFTYPE_STATION
)
263 return snprintf(buf
, buflen
, "request: %s\nused: %s\n",
264 smps_modes
[sdata
->u
.mgd
.req_smps
],
265 smps_modes
[sdata
->smps_mode
]);
266 if (sdata
->vif
.type
== NL80211_IFTYPE_AP
)
267 return snprintf(buf
, buflen
, "request: %s\nused: %s\n",
268 smps_modes
[sdata
->u
.ap
.req_smps
],
269 smps_modes
[sdata
->smps_mode
]);
273 static ssize_t
ieee80211_if_parse_smps(struct ieee80211_sub_if_data
*sdata
,
274 const char *buf
, int buflen
)
276 enum ieee80211_smps_mode mode
;
278 for (mode
= 0; mode
< IEEE80211_SMPS_NUM_MODES
; mode
++) {
279 if (strncmp(buf
, smps_modes
[mode
], buflen
) == 0) {
280 int err
= ieee80211_set_smps(sdata
, mode
);
289 IEEE80211_IF_FILE_RW(smps
);
291 static ssize_t
ieee80211_if_parse_tkip_mic_test(
292 struct ieee80211_sub_if_data
*sdata
, const char *buf
, int buflen
)
294 struct ieee80211_local
*local
= sdata
->local
;
297 struct ieee80211_hdr
*hdr
;
300 if (!mac_pton(buf
, addr
))
303 if (!ieee80211_sdata_running(sdata
))
306 skb
= dev_alloc_skb(local
->hw
.extra_tx_headroom
+ 24 + 100);
309 skb_reserve(skb
, local
->hw
.extra_tx_headroom
);
311 hdr
= (struct ieee80211_hdr
*) skb_put(skb
, 24);
313 fc
= cpu_to_le16(IEEE80211_FTYPE_DATA
| IEEE80211_STYPE_DATA
);
315 switch (sdata
->vif
.type
) {
316 case NL80211_IFTYPE_AP
:
317 fc
|= cpu_to_le16(IEEE80211_FCTL_FROMDS
);
319 memcpy(hdr
->addr1
, addr
, ETH_ALEN
);
320 memcpy(hdr
->addr2
, sdata
->vif
.addr
, ETH_ALEN
);
321 memcpy(hdr
->addr3
, sdata
->vif
.addr
, ETH_ALEN
);
323 case NL80211_IFTYPE_STATION
:
324 fc
|= cpu_to_le16(IEEE80211_FCTL_TODS
);
327 if (!sdata
->u
.mgd
.associated
) {
332 memcpy(hdr
->addr1
, sdata
->u
.mgd
.associated
->bssid
, ETH_ALEN
);
333 memcpy(hdr
->addr2
, sdata
->vif
.addr
, ETH_ALEN
);
334 memcpy(hdr
->addr3
, addr
, ETH_ALEN
);
341 hdr
->frame_control
= fc
;
344 * Add some length to the test frame to make it look bit more valid.
345 * The exact contents does not matter since the recipient is required
346 * to drop this because of the Michael MIC failure.
348 memset(skb_put(skb
, 50), 0, 50);
350 IEEE80211_SKB_CB(skb
)->flags
|= IEEE80211_TX_INTFL_TKIP_MIC_FAILURE
;
352 ieee80211_tx_skb(sdata
, skb
);
356 IEEE80211_IF_FILE_W(tkip_mic_test
);
358 static ssize_t
ieee80211_if_parse_beacon_loss(
359 struct ieee80211_sub_if_data
*sdata
, const char *buf
, int buflen
)
361 if (!ieee80211_sdata_running(sdata
) || !sdata
->vif
.bss_conf
.assoc
)
364 ieee80211_beacon_loss(&sdata
->vif
);
368 IEEE80211_IF_FILE_W(beacon_loss
);
370 static ssize_t
ieee80211_if_fmt_uapsd_queues(
371 const struct ieee80211_sub_if_data
*sdata
, char *buf
, int buflen
)
373 const struct ieee80211_if_managed
*ifmgd
= &sdata
->u
.mgd
;
375 return snprintf(buf
, buflen
, "0x%x\n", ifmgd
->uapsd_queues
);
378 static ssize_t
ieee80211_if_parse_uapsd_queues(
379 struct ieee80211_sub_if_data
*sdata
, const char *buf
, int buflen
)
381 struct ieee80211_if_managed
*ifmgd
= &sdata
->u
.mgd
;
385 ret
= kstrtou8(buf
, 0, &val
);
389 if (val
& ~IEEE80211_WMM_IE_STA_QOSINFO_AC_MASK
)
392 ifmgd
->uapsd_queues
= val
;
396 IEEE80211_IF_FILE_RW(uapsd_queues
);
398 static ssize_t
ieee80211_if_fmt_uapsd_max_sp_len(
399 const struct ieee80211_sub_if_data
*sdata
, char *buf
, int buflen
)
401 const struct ieee80211_if_managed
*ifmgd
= &sdata
->u
.mgd
;
403 return snprintf(buf
, buflen
, "0x%x\n", ifmgd
->uapsd_max_sp_len
);
406 static ssize_t
ieee80211_if_parse_uapsd_max_sp_len(
407 struct ieee80211_sub_if_data
*sdata
, const char *buf
, int buflen
)
409 struct ieee80211_if_managed
*ifmgd
= &sdata
->u
.mgd
;
413 ret
= kstrtoul(buf
, 0, &val
);
417 if (val
& ~IEEE80211_WMM_IE_STA_QOSINFO_SP_MASK
)
420 ifmgd
->uapsd_max_sp_len
= val
;
424 IEEE80211_IF_FILE_RW(uapsd_max_sp_len
);
427 IEEE80211_IF_FILE(num_mcast_sta
, u
.ap
.num_mcast_sta
, ATOMIC
);
428 IEEE80211_IF_FILE(num_sta_ps
, u
.ap
.ps
.num_sta_ps
, ATOMIC
);
429 IEEE80211_IF_FILE(dtim_count
, u
.ap
.ps
.dtim_count
, DEC
);
431 static ssize_t
ieee80211_if_fmt_num_buffered_multicast(
432 const struct ieee80211_sub_if_data
*sdata
, char *buf
, int buflen
)
434 return scnprintf(buf
, buflen
, "%u\n",
435 skb_queue_len(&sdata
->u
.ap
.ps
.bc_buf
));
437 IEEE80211_IF_FILE_R(num_buffered_multicast
);
439 /* IBSS attributes */
440 static ssize_t
ieee80211_if_fmt_tsf(
441 const struct ieee80211_sub_if_data
*sdata
, char *buf
, int buflen
)
443 struct ieee80211_local
*local
= sdata
->local
;
446 tsf
= drv_get_tsf(local
, (struct ieee80211_sub_if_data
*)sdata
);
448 return scnprintf(buf
, buflen
, "0x%016llx\n", (unsigned long long) tsf
);
451 static ssize_t
ieee80211_if_parse_tsf(
452 struct ieee80211_sub_if_data
*sdata
, const char *buf
, int buflen
)
454 struct ieee80211_local
*local
= sdata
->local
;
455 unsigned long long tsf
;
457 int tsf_is_delta
= 0;
459 if (strncmp(buf
, "reset", 5) == 0) {
460 if (local
->ops
->reset_tsf
) {
461 drv_reset_tsf(local
, sdata
);
462 wiphy_info(local
->hw
.wiphy
, "debugfs reset TSF\n");
465 if (buflen
> 10 && buf
[1] == '=') {
468 else if (buf
[0] == '-')
474 ret
= kstrtoull(buf
, 10, &tsf
);
478 tsf
= drv_get_tsf(local
, sdata
) + tsf_is_delta
* tsf
;
479 if (local
->ops
->set_tsf
) {
480 drv_set_tsf(local
, sdata
, tsf
);
481 wiphy_info(local
->hw
.wiphy
,
482 "debugfs set TSF to %#018llx\n", tsf
);
486 ieee80211_recalc_dtim(local
, sdata
);
489 IEEE80211_IF_FILE_RW(tsf
);
493 IEEE80211_IF_FILE(peer
, u
.wds
.remote_addr
, MAC
);
495 #ifdef CONFIG_MAC80211_MESH
496 IEEE80211_IF_FILE(estab_plinks
, u
.mesh
.estab_plinks
, ATOMIC
);
498 /* Mesh stats attributes */
499 IEEE80211_IF_FILE(fwded_mcast
, u
.mesh
.mshstats
.fwded_mcast
, DEC
);
500 IEEE80211_IF_FILE(fwded_unicast
, u
.mesh
.mshstats
.fwded_unicast
, DEC
);
501 IEEE80211_IF_FILE(fwded_frames
, u
.mesh
.mshstats
.fwded_frames
, DEC
);
502 IEEE80211_IF_FILE(dropped_frames_ttl
, u
.mesh
.mshstats
.dropped_frames_ttl
, DEC
);
503 IEEE80211_IF_FILE(dropped_frames_congestion
,
504 u
.mesh
.mshstats
.dropped_frames_congestion
, DEC
);
505 IEEE80211_IF_FILE(dropped_frames_no_route
,
506 u
.mesh
.mshstats
.dropped_frames_no_route
, DEC
);
508 /* Mesh parameters */
509 IEEE80211_IF_FILE(dot11MeshMaxRetries
,
510 u
.mesh
.mshcfg
.dot11MeshMaxRetries
, DEC
);
511 IEEE80211_IF_FILE(dot11MeshRetryTimeout
,
512 u
.mesh
.mshcfg
.dot11MeshRetryTimeout
, DEC
);
513 IEEE80211_IF_FILE(dot11MeshConfirmTimeout
,
514 u
.mesh
.mshcfg
.dot11MeshConfirmTimeout
, DEC
);
515 IEEE80211_IF_FILE(dot11MeshHoldingTimeout
,
516 u
.mesh
.mshcfg
.dot11MeshHoldingTimeout
, DEC
);
517 IEEE80211_IF_FILE(dot11MeshTTL
, u
.mesh
.mshcfg
.dot11MeshTTL
, DEC
);
518 IEEE80211_IF_FILE(element_ttl
, u
.mesh
.mshcfg
.element_ttl
, DEC
);
519 IEEE80211_IF_FILE(auto_open_plinks
, u
.mesh
.mshcfg
.auto_open_plinks
, DEC
);
520 IEEE80211_IF_FILE(dot11MeshMaxPeerLinks
,
521 u
.mesh
.mshcfg
.dot11MeshMaxPeerLinks
, DEC
);
522 IEEE80211_IF_FILE(dot11MeshHWMPactivePathTimeout
,
523 u
.mesh
.mshcfg
.dot11MeshHWMPactivePathTimeout
, DEC
);
524 IEEE80211_IF_FILE(dot11MeshHWMPpreqMinInterval
,
525 u
.mesh
.mshcfg
.dot11MeshHWMPpreqMinInterval
, DEC
);
526 IEEE80211_IF_FILE(dot11MeshHWMPperrMinInterval
,
527 u
.mesh
.mshcfg
.dot11MeshHWMPperrMinInterval
, DEC
);
528 IEEE80211_IF_FILE(dot11MeshHWMPnetDiameterTraversalTime
,
529 u
.mesh
.mshcfg
.dot11MeshHWMPnetDiameterTraversalTime
, DEC
);
530 IEEE80211_IF_FILE(dot11MeshHWMPmaxPREQretries
,
531 u
.mesh
.mshcfg
.dot11MeshHWMPmaxPREQretries
, DEC
);
532 IEEE80211_IF_FILE(path_refresh_time
,
533 u
.mesh
.mshcfg
.path_refresh_time
, DEC
);
534 IEEE80211_IF_FILE(min_discovery_timeout
,
535 u
.mesh
.mshcfg
.min_discovery_timeout
, DEC
);
536 IEEE80211_IF_FILE(dot11MeshHWMPRootMode
,
537 u
.mesh
.mshcfg
.dot11MeshHWMPRootMode
, DEC
);
538 IEEE80211_IF_FILE(dot11MeshGateAnnouncementProtocol
,
539 u
.mesh
.mshcfg
.dot11MeshGateAnnouncementProtocol
, DEC
);
540 IEEE80211_IF_FILE(dot11MeshHWMPRannInterval
,
541 u
.mesh
.mshcfg
.dot11MeshHWMPRannInterval
, DEC
);
542 IEEE80211_IF_FILE(dot11MeshForwarding
, u
.mesh
.mshcfg
.dot11MeshForwarding
, DEC
);
543 IEEE80211_IF_FILE(rssi_threshold
, u
.mesh
.mshcfg
.rssi_threshold
, DEC
);
544 IEEE80211_IF_FILE(ht_opmode
, u
.mesh
.mshcfg
.ht_opmode
, DEC
);
545 IEEE80211_IF_FILE(dot11MeshHWMPactivePathToRootTimeout
,
546 u
.mesh
.mshcfg
.dot11MeshHWMPactivePathToRootTimeout
, DEC
);
547 IEEE80211_IF_FILE(dot11MeshHWMProotInterval
,
548 u
.mesh
.mshcfg
.dot11MeshHWMProotInterval
, DEC
);
549 IEEE80211_IF_FILE(dot11MeshHWMPconfirmationInterval
,
550 u
.mesh
.mshcfg
.dot11MeshHWMPconfirmationInterval
, DEC
);
551 IEEE80211_IF_FILE(power_mode
, u
.mesh
.mshcfg
.power_mode
, DEC
);
552 IEEE80211_IF_FILE(dot11MeshAwakeWindowDuration
,
553 u
.mesh
.mshcfg
.dot11MeshAwakeWindowDuration
, DEC
);
556 #define DEBUGFS_ADD_MODE(name, mode) \
557 debugfs_create_file(#name, mode, sdata->vif.debugfs_dir, \
560 #define DEBUGFS_ADD(name) DEBUGFS_ADD_MODE(name, 0400)
562 static void add_common_files(struct ieee80211_sub_if_data
*sdata
)
564 DEBUGFS_ADD(rc_rateidx_mask_2ghz
);
565 DEBUGFS_ADD(rc_rateidx_mask_5ghz
);
566 DEBUGFS_ADD(rc_rateidx_mcs_mask_2ghz
);
567 DEBUGFS_ADD(rc_rateidx_mcs_mask_5ghz
);
568 DEBUGFS_ADD(hw_queues
);
571 static void add_sta_files(struct ieee80211_sub_if_data
*sdata
)
575 DEBUGFS_ADD(last_beacon
);
576 DEBUGFS_ADD(ave_beacon
);
577 DEBUGFS_ADD(beacon_timeout
);
578 DEBUGFS_ADD_MODE(smps
, 0600);
579 DEBUGFS_ADD_MODE(tkip_mic_test
, 0200);
580 DEBUGFS_ADD_MODE(beacon_loss
, 0200);
581 DEBUGFS_ADD_MODE(uapsd_queues
, 0600);
582 DEBUGFS_ADD_MODE(uapsd_max_sp_len
, 0600);
585 static void add_ap_files(struct ieee80211_sub_if_data
*sdata
)
587 DEBUGFS_ADD(num_mcast_sta
);
588 DEBUGFS_ADD_MODE(smps
, 0600);
589 DEBUGFS_ADD(num_sta_ps
);
590 DEBUGFS_ADD(dtim_count
);
591 DEBUGFS_ADD(num_buffered_multicast
);
592 DEBUGFS_ADD_MODE(tkip_mic_test
, 0200);
595 static void add_ibss_files(struct ieee80211_sub_if_data
*sdata
)
597 DEBUGFS_ADD_MODE(tsf
, 0600);
600 static void add_wds_files(struct ieee80211_sub_if_data
*sdata
)
605 #ifdef CONFIG_MAC80211_MESH
607 static void add_mesh_files(struct ieee80211_sub_if_data
*sdata
)
609 DEBUGFS_ADD_MODE(tsf
, 0600);
610 DEBUGFS_ADD_MODE(estab_plinks
, 0400);
613 static void add_mesh_stats(struct ieee80211_sub_if_data
*sdata
)
615 struct dentry
*dir
= debugfs_create_dir("mesh_stats",
616 sdata
->vif
.debugfs_dir
);
617 #define MESHSTATS_ADD(name)\
618 debugfs_create_file(#name, 0400, dir, sdata, &name##_ops);
620 MESHSTATS_ADD(fwded_mcast
);
621 MESHSTATS_ADD(fwded_unicast
);
622 MESHSTATS_ADD(fwded_frames
);
623 MESHSTATS_ADD(dropped_frames_ttl
);
624 MESHSTATS_ADD(dropped_frames_no_route
);
625 MESHSTATS_ADD(dropped_frames_congestion
);
629 static void add_mesh_config(struct ieee80211_sub_if_data
*sdata
)
631 struct dentry
*dir
= debugfs_create_dir("mesh_config",
632 sdata
->vif
.debugfs_dir
);
634 #define MESHPARAMS_ADD(name) \
635 debugfs_create_file(#name, 0600, dir, sdata, &name##_ops);
637 MESHPARAMS_ADD(dot11MeshMaxRetries
);
638 MESHPARAMS_ADD(dot11MeshRetryTimeout
);
639 MESHPARAMS_ADD(dot11MeshConfirmTimeout
);
640 MESHPARAMS_ADD(dot11MeshHoldingTimeout
);
641 MESHPARAMS_ADD(dot11MeshTTL
);
642 MESHPARAMS_ADD(element_ttl
);
643 MESHPARAMS_ADD(auto_open_plinks
);
644 MESHPARAMS_ADD(dot11MeshMaxPeerLinks
);
645 MESHPARAMS_ADD(dot11MeshHWMPactivePathTimeout
);
646 MESHPARAMS_ADD(dot11MeshHWMPpreqMinInterval
);
647 MESHPARAMS_ADD(dot11MeshHWMPperrMinInterval
);
648 MESHPARAMS_ADD(dot11MeshHWMPnetDiameterTraversalTime
);
649 MESHPARAMS_ADD(dot11MeshHWMPmaxPREQretries
);
650 MESHPARAMS_ADD(path_refresh_time
);
651 MESHPARAMS_ADD(min_discovery_timeout
);
652 MESHPARAMS_ADD(dot11MeshHWMPRootMode
);
653 MESHPARAMS_ADD(dot11MeshHWMPRannInterval
);
654 MESHPARAMS_ADD(dot11MeshForwarding
);
655 MESHPARAMS_ADD(dot11MeshGateAnnouncementProtocol
);
656 MESHPARAMS_ADD(rssi_threshold
);
657 MESHPARAMS_ADD(ht_opmode
);
658 MESHPARAMS_ADD(dot11MeshHWMPactivePathToRootTimeout
);
659 MESHPARAMS_ADD(dot11MeshHWMProotInterval
);
660 MESHPARAMS_ADD(dot11MeshHWMPconfirmationInterval
);
661 MESHPARAMS_ADD(power_mode
);
662 MESHPARAMS_ADD(dot11MeshAwakeWindowDuration
);
663 #undef MESHPARAMS_ADD
667 static void add_files(struct ieee80211_sub_if_data
*sdata
)
669 if (!sdata
->vif
.debugfs_dir
)
674 DEBUGFS_ADD(txpower
);
675 DEBUGFS_ADD(user_power_level
);
676 DEBUGFS_ADD(ap_power_level
);
678 if (sdata
->vif
.type
!= NL80211_IFTYPE_MONITOR
)
679 add_common_files(sdata
);
681 switch (sdata
->vif
.type
) {
682 case NL80211_IFTYPE_MESH_POINT
:
683 #ifdef CONFIG_MAC80211_MESH
684 add_mesh_files(sdata
);
685 add_mesh_stats(sdata
);
686 add_mesh_config(sdata
);
689 case NL80211_IFTYPE_STATION
:
690 add_sta_files(sdata
);
692 case NL80211_IFTYPE_ADHOC
:
693 add_ibss_files(sdata
);
695 case NL80211_IFTYPE_AP
:
698 case NL80211_IFTYPE_WDS
:
699 add_wds_files(sdata
);
706 void ieee80211_debugfs_add_netdev(struct ieee80211_sub_if_data
*sdata
)
708 char buf
[10+IFNAMSIZ
];
710 sprintf(buf
, "netdev:%s", sdata
->name
);
711 sdata
->vif
.debugfs_dir
= debugfs_create_dir(buf
,
712 sdata
->local
->hw
.wiphy
->debugfsdir
);
713 if (sdata
->vif
.debugfs_dir
)
714 sdata
->debugfs
.subdir_stations
= debugfs_create_dir("stations",
715 sdata
->vif
.debugfs_dir
);
719 void ieee80211_debugfs_remove_netdev(struct ieee80211_sub_if_data
*sdata
)
721 if (!sdata
->vif
.debugfs_dir
)
724 debugfs_remove_recursive(sdata
->vif
.debugfs_dir
);
725 sdata
->vif
.debugfs_dir
= NULL
;
728 void ieee80211_debugfs_rename_netdev(struct ieee80211_sub_if_data
*sdata
)
731 char buf
[10 + IFNAMSIZ
];
733 dir
= sdata
->vif
.debugfs_dir
;
738 sprintf(buf
, "netdev:%s", sdata
->name
);
739 if (!debugfs_rename(dir
->d_parent
, dir
, dir
->d_parent
, buf
))
741 "debugfs: failed to rename debugfs dir to %s\n",