1 // SPDX-License-Identifier: GPL-2.0-only
3 * Copyright (c) 2006 Jiri Benc <jbenc@suse.cz>
4 * Copyright 2007 Johannes Berg <johannes@sipsolutions.net>
7 #include <linux/kernel.h>
8 #include <linux/device.h>
10 #include <linux/if_ether.h>
11 #include <linux/interrupt.h>
12 #include <linux/netdevice.h>
13 #include <linux/rtnetlink.h>
14 #include <linux/slab.h>
15 #include <linux/notifier.h>
16 #include <net/mac80211.h>
17 #include <net/cfg80211.h>
18 #include "ieee80211_i.h"
21 #include "debugfs_netdev.h"
22 #include "driver-ops.h"
24 static ssize_t
ieee80211_if_read(
25 struct ieee80211_sub_if_data
*sdata
,
27 size_t count
, loff_t
*ppos
,
28 ssize_t (*format
)(const struct ieee80211_sub_if_data
*, char *, int))
31 ssize_t ret
= -EINVAL
;
33 read_lock(&dev_base_lock
);
34 ret
= (*format
)(sdata
, buf
, sizeof(buf
));
35 read_unlock(&dev_base_lock
);
38 ret
= simple_read_from_buffer(userbuf
, count
, ppos
, buf
, ret
);
43 static ssize_t
ieee80211_if_write(
44 struct ieee80211_sub_if_data
*sdata
,
45 const char __user
*userbuf
,
46 size_t count
, loff_t
*ppos
,
47 ssize_t (*write
)(struct ieee80211_sub_if_data
*, const char *, int))
52 if (count
>= sizeof(buf
))
55 if (copy_from_user(buf
, userbuf
, count
))
61 ret
= (*write
)(sdata
, buf
, count
);
67 #define IEEE80211_IF_FMT(name, field, format_string) \
68 static ssize_t ieee80211_if_fmt_##name( \
69 const struct ieee80211_sub_if_data *sdata, char *buf, \
72 return scnprintf(buf, buflen, format_string, sdata->field); \
74 #define IEEE80211_IF_FMT_DEC(name, field) \
75 IEEE80211_IF_FMT(name, field, "%d\n")
76 #define IEEE80211_IF_FMT_HEX(name, field) \
77 IEEE80211_IF_FMT(name, field, "%#x\n")
78 #define IEEE80211_IF_FMT_LHEX(name, field) \
79 IEEE80211_IF_FMT(name, field, "%#lx\n")
80 #define IEEE80211_IF_FMT_SIZE(name, field) \
81 IEEE80211_IF_FMT(name, field, "%zd\n")
83 #define IEEE80211_IF_FMT_HEXARRAY(name, field) \
84 static ssize_t ieee80211_if_fmt_##name( \
85 const struct ieee80211_sub_if_data *sdata, \
86 char *buf, int buflen) \
90 for (i = 0; i < sizeof(sdata->field); i++) { \
91 p += scnprintf(p, buflen + buf - p, "%.2x ", \
94 p += scnprintf(p, buflen + buf - p, "\n"); \
98 #define IEEE80211_IF_FMT_ATOMIC(name, field) \
99 static ssize_t ieee80211_if_fmt_##name( \
100 const struct ieee80211_sub_if_data *sdata, \
101 char *buf, int buflen) \
103 return scnprintf(buf, buflen, "%d\n", atomic_read(&sdata->field));\
106 #define IEEE80211_IF_FMT_MAC(name, field) \
107 static ssize_t ieee80211_if_fmt_##name( \
108 const struct ieee80211_sub_if_data *sdata, char *buf, \
111 return scnprintf(buf, buflen, "%pM\n", sdata->field); \
114 #define IEEE80211_IF_FMT_JIFFIES_TO_MS(name, field) \
115 static ssize_t ieee80211_if_fmt_##name( \
116 const struct ieee80211_sub_if_data *sdata, \
117 char *buf, int buflen) \
119 return scnprintf(buf, buflen, "%d\n", \
120 jiffies_to_msecs(sdata->field)); \
123 #define _IEEE80211_IF_FILE_OPS(name, _read, _write) \
124 static const struct file_operations name##_ops = { \
127 .open = simple_open, \
128 .llseek = generic_file_llseek, \
131 #define _IEEE80211_IF_FILE_R_FN(name) \
132 static ssize_t ieee80211_if_read_##name(struct file *file, \
133 char __user *userbuf, \
134 size_t count, loff_t *ppos) \
136 return ieee80211_if_read(file->private_data, \
137 userbuf, count, ppos, \
138 ieee80211_if_fmt_##name); \
141 #define _IEEE80211_IF_FILE_W_FN(name) \
142 static ssize_t ieee80211_if_write_##name(struct file *file, \
143 const char __user *userbuf, \
144 size_t count, loff_t *ppos) \
146 return ieee80211_if_write(file->private_data, userbuf, count, \
147 ppos, ieee80211_if_parse_##name); \
150 #define IEEE80211_IF_FILE_R(name) \
151 _IEEE80211_IF_FILE_R_FN(name) \
152 _IEEE80211_IF_FILE_OPS(name, ieee80211_if_read_##name, NULL)
154 #define IEEE80211_IF_FILE_W(name) \
155 _IEEE80211_IF_FILE_W_FN(name) \
156 _IEEE80211_IF_FILE_OPS(name, NULL, ieee80211_if_write_##name)
158 #define IEEE80211_IF_FILE_RW(name) \
159 _IEEE80211_IF_FILE_R_FN(name) \
160 _IEEE80211_IF_FILE_W_FN(name) \
161 _IEEE80211_IF_FILE_OPS(name, ieee80211_if_read_##name, \
162 ieee80211_if_write_##name)
164 #define IEEE80211_IF_FILE(name, field, format) \
165 IEEE80211_IF_FMT_##format(name, field) \
166 IEEE80211_IF_FILE_R(name)
168 /* common attributes */
169 IEEE80211_IF_FILE(rc_rateidx_mask_2ghz
, rc_rateidx_mask
[NL80211_BAND_2GHZ
],
171 IEEE80211_IF_FILE(rc_rateidx_mask_5ghz
, rc_rateidx_mask
[NL80211_BAND_5GHZ
],
173 IEEE80211_IF_FILE(rc_rateidx_mcs_mask_2ghz
,
174 rc_rateidx_mcs_mask
[NL80211_BAND_2GHZ
], HEXARRAY
);
175 IEEE80211_IF_FILE(rc_rateidx_mcs_mask_5ghz
,
176 rc_rateidx_mcs_mask
[NL80211_BAND_5GHZ
], HEXARRAY
);
178 static ssize_t
ieee80211_if_fmt_rc_rateidx_vht_mcs_mask_2ghz(
179 const struct ieee80211_sub_if_data
*sdata
,
180 char *buf
, int buflen
)
183 const u16
*mask
= sdata
->rc_rateidx_vht_mcs_mask
[NL80211_BAND_2GHZ
];
185 for (i
= 0; i
< NL80211_VHT_NSS_MAX
; i
++)
186 len
+= scnprintf(buf
+ len
, buflen
- len
, "%04x ", mask
[i
]);
187 len
+= scnprintf(buf
+ len
, buflen
- len
, "\n");
192 IEEE80211_IF_FILE_R(rc_rateidx_vht_mcs_mask_2ghz
);
194 static ssize_t
ieee80211_if_fmt_rc_rateidx_vht_mcs_mask_5ghz(
195 const struct ieee80211_sub_if_data
*sdata
,
196 char *buf
, int buflen
)
199 const u16
*mask
= sdata
->rc_rateidx_vht_mcs_mask
[NL80211_BAND_5GHZ
];
201 for (i
= 0; i
< NL80211_VHT_NSS_MAX
; i
++)
202 len
+= scnprintf(buf
+ len
, buflen
- len
, "%04x ", mask
[i
]);
203 len
+= scnprintf(buf
+ len
, buflen
- len
, "\n");
208 IEEE80211_IF_FILE_R(rc_rateidx_vht_mcs_mask_5ghz
);
210 IEEE80211_IF_FILE(flags
, flags
, HEX
);
211 IEEE80211_IF_FILE(state
, state
, LHEX
);
212 IEEE80211_IF_FILE(txpower
, vif
.bss_conf
.txpower
, DEC
);
213 IEEE80211_IF_FILE(ap_power_level
, ap_power_level
, DEC
);
214 IEEE80211_IF_FILE(user_power_level
, user_power_level
, DEC
);
217 ieee80211_if_fmt_hw_queues(const struct ieee80211_sub_if_data
*sdata
,
218 char *buf
, int buflen
)
222 len
= scnprintf(buf
, buflen
, "AC queues: VO:%d VI:%d BE:%d BK:%d\n",
223 sdata
->vif
.hw_queue
[IEEE80211_AC_VO
],
224 sdata
->vif
.hw_queue
[IEEE80211_AC_VI
],
225 sdata
->vif
.hw_queue
[IEEE80211_AC_BE
],
226 sdata
->vif
.hw_queue
[IEEE80211_AC_BK
]);
228 if (sdata
->vif
.type
== NL80211_IFTYPE_AP
)
229 len
+= scnprintf(buf
+ len
, buflen
- len
, "cab queue: %d\n",
230 sdata
->vif
.cab_queue
);
234 IEEE80211_IF_FILE_R(hw_queues
);
237 IEEE80211_IF_FILE(bssid
, u
.mgd
.bssid
, MAC
);
238 IEEE80211_IF_FILE(aid
, u
.mgd
.aid
, DEC
);
239 IEEE80211_IF_FILE(beacon_timeout
, u
.mgd
.beacon_timeout
, JIFFIES_TO_MS
);
241 static int ieee80211_set_smps(struct ieee80211_sub_if_data
*sdata
,
242 enum ieee80211_smps_mode smps_mode
)
244 struct ieee80211_local
*local
= sdata
->local
;
247 if (!(local
->hw
.wiphy
->features
& NL80211_FEATURE_STATIC_SMPS
) &&
248 smps_mode
== IEEE80211_SMPS_STATIC
)
251 /* auto should be dynamic if in PS mode */
252 if (!(local
->hw
.wiphy
->features
& NL80211_FEATURE_DYNAMIC_SMPS
) &&
253 (smps_mode
== IEEE80211_SMPS_DYNAMIC
||
254 smps_mode
== IEEE80211_SMPS_AUTOMATIC
))
257 if (sdata
->vif
.type
!= NL80211_IFTYPE_STATION
&&
258 sdata
->vif
.type
!= NL80211_IFTYPE_AP
)
262 if (sdata
->vif
.type
== NL80211_IFTYPE_STATION
)
263 err
= __ieee80211_request_smps_mgd(sdata
, smps_mode
);
265 err
= __ieee80211_request_smps_ap(sdata
, smps_mode
);
271 static const char *smps_modes
[IEEE80211_SMPS_NUM_MODES
] = {
272 [IEEE80211_SMPS_AUTOMATIC
] = "auto",
273 [IEEE80211_SMPS_OFF
] = "off",
274 [IEEE80211_SMPS_STATIC
] = "static",
275 [IEEE80211_SMPS_DYNAMIC
] = "dynamic",
278 static ssize_t
ieee80211_if_fmt_smps(const struct ieee80211_sub_if_data
*sdata
,
279 char *buf
, int buflen
)
281 if (sdata
->vif
.type
== NL80211_IFTYPE_STATION
)
282 return snprintf(buf
, buflen
, "request: %s\nused: %s\n",
283 smps_modes
[sdata
->u
.mgd
.req_smps
],
284 smps_modes
[sdata
->smps_mode
]);
285 if (sdata
->vif
.type
== NL80211_IFTYPE_AP
)
286 return snprintf(buf
, buflen
, "request: %s\nused: %s\n",
287 smps_modes
[sdata
->u
.ap
.req_smps
],
288 smps_modes
[sdata
->smps_mode
]);
292 static ssize_t
ieee80211_if_parse_smps(struct ieee80211_sub_if_data
*sdata
,
293 const char *buf
, int buflen
)
295 enum ieee80211_smps_mode mode
;
297 for (mode
= 0; mode
< IEEE80211_SMPS_NUM_MODES
; mode
++) {
298 if (strncmp(buf
, smps_modes
[mode
], buflen
) == 0) {
299 int err
= ieee80211_set_smps(sdata
, mode
);
308 IEEE80211_IF_FILE_RW(smps
);
310 static ssize_t
ieee80211_if_parse_tkip_mic_test(
311 struct ieee80211_sub_if_data
*sdata
, const char *buf
, int buflen
)
313 struct ieee80211_local
*local
= sdata
->local
;
316 struct ieee80211_hdr
*hdr
;
319 if (!mac_pton(buf
, addr
))
322 if (!ieee80211_sdata_running(sdata
))
325 skb
= dev_alloc_skb(local
->hw
.extra_tx_headroom
+ 24 + 100);
328 skb_reserve(skb
, local
->hw
.extra_tx_headroom
);
330 hdr
= skb_put_zero(skb
, 24);
331 fc
= cpu_to_le16(IEEE80211_FTYPE_DATA
| IEEE80211_STYPE_DATA
);
333 switch (sdata
->vif
.type
) {
334 case NL80211_IFTYPE_AP
:
335 fc
|= cpu_to_le16(IEEE80211_FCTL_FROMDS
);
337 memcpy(hdr
->addr1
, addr
, ETH_ALEN
);
338 memcpy(hdr
->addr2
, sdata
->vif
.addr
, ETH_ALEN
);
339 memcpy(hdr
->addr3
, sdata
->vif
.addr
, ETH_ALEN
);
341 case NL80211_IFTYPE_STATION
:
342 fc
|= cpu_to_le16(IEEE80211_FCTL_TODS
);
345 if (!sdata
->u
.mgd
.associated
) {
350 memcpy(hdr
->addr1
, sdata
->u
.mgd
.associated
->bssid
, ETH_ALEN
);
351 memcpy(hdr
->addr2
, sdata
->vif
.addr
, ETH_ALEN
);
352 memcpy(hdr
->addr3
, addr
, ETH_ALEN
);
359 hdr
->frame_control
= fc
;
362 * Add some length to the test frame to make it look bit more valid.
363 * The exact contents does not matter since the recipient is required
364 * to drop this because of the Michael MIC failure.
366 skb_put_zero(skb
, 50);
368 IEEE80211_SKB_CB(skb
)->flags
|= IEEE80211_TX_INTFL_TKIP_MIC_FAILURE
;
370 ieee80211_tx_skb(sdata
, skb
);
374 IEEE80211_IF_FILE_W(tkip_mic_test
);
376 static ssize_t
ieee80211_if_parse_beacon_loss(
377 struct ieee80211_sub_if_data
*sdata
, const char *buf
, int buflen
)
379 if (!ieee80211_sdata_running(sdata
) || !sdata
->vif
.bss_conf
.assoc
)
382 ieee80211_beacon_loss(&sdata
->vif
);
386 IEEE80211_IF_FILE_W(beacon_loss
);
388 static ssize_t
ieee80211_if_fmt_uapsd_queues(
389 const struct ieee80211_sub_if_data
*sdata
, char *buf
, int buflen
)
391 const struct ieee80211_if_managed
*ifmgd
= &sdata
->u
.mgd
;
393 return snprintf(buf
, buflen
, "0x%x\n", ifmgd
->uapsd_queues
);
396 static ssize_t
ieee80211_if_parse_uapsd_queues(
397 struct ieee80211_sub_if_data
*sdata
, const char *buf
, int buflen
)
399 struct ieee80211_if_managed
*ifmgd
= &sdata
->u
.mgd
;
403 ret
= kstrtou8(buf
, 0, &val
);
407 if (val
& ~IEEE80211_WMM_IE_STA_QOSINFO_AC_MASK
)
410 ifmgd
->uapsd_queues
= val
;
414 IEEE80211_IF_FILE_RW(uapsd_queues
);
416 static ssize_t
ieee80211_if_fmt_uapsd_max_sp_len(
417 const struct ieee80211_sub_if_data
*sdata
, char *buf
, int buflen
)
419 const struct ieee80211_if_managed
*ifmgd
= &sdata
->u
.mgd
;
421 return snprintf(buf
, buflen
, "0x%x\n", ifmgd
->uapsd_max_sp_len
);
424 static ssize_t
ieee80211_if_parse_uapsd_max_sp_len(
425 struct ieee80211_sub_if_data
*sdata
, const char *buf
, int buflen
)
427 struct ieee80211_if_managed
*ifmgd
= &sdata
->u
.mgd
;
431 ret
= kstrtoul(buf
, 0, &val
);
435 if (val
& ~IEEE80211_WMM_IE_STA_QOSINFO_SP_MASK
)
438 ifmgd
->uapsd_max_sp_len
= val
;
442 IEEE80211_IF_FILE_RW(uapsd_max_sp_len
);
444 static ssize_t
ieee80211_if_fmt_tdls_wider_bw(
445 const struct ieee80211_sub_if_data
*sdata
, char *buf
, int buflen
)
447 const struct ieee80211_if_managed
*ifmgd
= &sdata
->u
.mgd
;
450 tdls_wider_bw
= ieee80211_hw_check(&sdata
->local
->hw
, TDLS_WIDER_BW
) &&
451 !ifmgd
->tdls_wider_bw_prohibited
;
453 return snprintf(buf
, buflen
, "%d\n", tdls_wider_bw
);
456 static ssize_t
ieee80211_if_parse_tdls_wider_bw(
457 struct ieee80211_sub_if_data
*sdata
, const char *buf
, int buflen
)
459 struct ieee80211_if_managed
*ifmgd
= &sdata
->u
.mgd
;
463 ret
= kstrtou8(buf
, 0, &val
);
467 ifmgd
->tdls_wider_bw_prohibited
= !val
;
470 IEEE80211_IF_FILE_RW(tdls_wider_bw
);
473 IEEE80211_IF_FILE(num_mcast_sta
, u
.ap
.num_mcast_sta
, ATOMIC
);
474 IEEE80211_IF_FILE(num_sta_ps
, u
.ap
.ps
.num_sta_ps
, ATOMIC
);
475 IEEE80211_IF_FILE(dtim_count
, u
.ap
.ps
.dtim_count
, DEC
);
476 IEEE80211_IF_FILE(num_mcast_sta_vlan
, u
.vlan
.num_mcast_sta
, ATOMIC
);
478 static ssize_t
ieee80211_if_fmt_num_buffered_multicast(
479 const struct ieee80211_sub_if_data
*sdata
, char *buf
, int buflen
)
481 return scnprintf(buf
, buflen
, "%u\n",
482 skb_queue_len(&sdata
->u
.ap
.ps
.bc_buf
));
484 IEEE80211_IF_FILE_R(num_buffered_multicast
);
486 static ssize_t
ieee80211_if_fmt_aqm(
487 const struct ieee80211_sub_if_data
*sdata
, char *buf
, int buflen
)
489 struct ieee80211_local
*local
= sdata
->local
;
490 struct txq_info
*txqi
= to_txq_info(sdata
->vif
.txq
);
493 spin_lock_bh(&local
->fq
.lock
);
498 "ac backlog-bytes backlog-packets new-flows drops marks overlimit collisions tx-bytes tx-packets\n"
499 "%u %u %u %u %u %u %u %u %u %u\n",
501 txqi
->tin
.backlog_bytes
,
502 txqi
->tin
.backlog_packets
,
504 txqi
->cstats
.drop_count
,
505 txqi
->cstats
.ecn_mark
,
507 txqi
->tin
.collisions
,
509 txqi
->tin
.tx_packets
);
512 spin_unlock_bh(&local
->fq
.lock
);
516 IEEE80211_IF_FILE_R(aqm
);
518 IEEE80211_IF_FILE(multicast_to_unicast
, u
.ap
.multicast_to_unicast
, HEX
);
520 /* IBSS attributes */
521 static ssize_t
ieee80211_if_fmt_tsf(
522 const struct ieee80211_sub_if_data
*sdata
, char *buf
, int buflen
)
524 struct ieee80211_local
*local
= sdata
->local
;
527 tsf
= drv_get_tsf(local
, (struct ieee80211_sub_if_data
*)sdata
);
529 return scnprintf(buf
, buflen
, "0x%016llx\n", (unsigned long long) tsf
);
532 static ssize_t
ieee80211_if_parse_tsf(
533 struct ieee80211_sub_if_data
*sdata
, const char *buf
, int buflen
)
535 struct ieee80211_local
*local
= sdata
->local
;
536 unsigned long long tsf
;
538 int tsf_is_delta
= 0;
540 if (strncmp(buf
, "reset", 5) == 0) {
541 if (local
->ops
->reset_tsf
) {
542 drv_reset_tsf(local
, sdata
);
543 wiphy_info(local
->hw
.wiphy
, "debugfs reset TSF\n");
546 if (buflen
> 10 && buf
[1] == '=') {
549 else if (buf
[0] == '-')
555 ret
= kstrtoull(buf
, 10, &tsf
);
558 if (tsf_is_delta
&& local
->ops
->offset_tsf
) {
559 drv_offset_tsf(local
, sdata
, tsf_is_delta
* tsf
);
560 wiphy_info(local
->hw
.wiphy
,
561 "debugfs offset TSF by %018lld\n",
563 } else if (local
->ops
->set_tsf
) {
565 tsf
= drv_get_tsf(local
, sdata
) +
567 drv_set_tsf(local
, sdata
, tsf
);
568 wiphy_info(local
->hw
.wiphy
,
569 "debugfs set TSF to %#018llx\n", tsf
);
573 ieee80211_recalc_dtim(local
, sdata
);
576 IEEE80211_IF_FILE_RW(tsf
);
580 IEEE80211_IF_FILE(peer
, u
.wds
.remote_addr
, MAC
);
582 #ifdef CONFIG_MAC80211_MESH
583 IEEE80211_IF_FILE(estab_plinks
, u
.mesh
.estab_plinks
, ATOMIC
);
585 /* Mesh stats attributes */
586 IEEE80211_IF_FILE(fwded_mcast
, u
.mesh
.mshstats
.fwded_mcast
, DEC
);
587 IEEE80211_IF_FILE(fwded_unicast
, u
.mesh
.mshstats
.fwded_unicast
, DEC
);
588 IEEE80211_IF_FILE(fwded_frames
, u
.mesh
.mshstats
.fwded_frames
, DEC
);
589 IEEE80211_IF_FILE(dropped_frames_ttl
, u
.mesh
.mshstats
.dropped_frames_ttl
, DEC
);
590 IEEE80211_IF_FILE(dropped_frames_congestion
,
591 u
.mesh
.mshstats
.dropped_frames_congestion
, DEC
);
592 IEEE80211_IF_FILE(dropped_frames_no_route
,
593 u
.mesh
.mshstats
.dropped_frames_no_route
, DEC
);
595 /* Mesh parameters */
596 IEEE80211_IF_FILE(dot11MeshMaxRetries
,
597 u
.mesh
.mshcfg
.dot11MeshMaxRetries
, DEC
);
598 IEEE80211_IF_FILE(dot11MeshRetryTimeout
,
599 u
.mesh
.mshcfg
.dot11MeshRetryTimeout
, DEC
);
600 IEEE80211_IF_FILE(dot11MeshConfirmTimeout
,
601 u
.mesh
.mshcfg
.dot11MeshConfirmTimeout
, DEC
);
602 IEEE80211_IF_FILE(dot11MeshHoldingTimeout
,
603 u
.mesh
.mshcfg
.dot11MeshHoldingTimeout
, DEC
);
604 IEEE80211_IF_FILE(dot11MeshTTL
, u
.mesh
.mshcfg
.dot11MeshTTL
, DEC
);
605 IEEE80211_IF_FILE(element_ttl
, u
.mesh
.mshcfg
.element_ttl
, DEC
);
606 IEEE80211_IF_FILE(auto_open_plinks
, u
.mesh
.mshcfg
.auto_open_plinks
, DEC
);
607 IEEE80211_IF_FILE(dot11MeshMaxPeerLinks
,
608 u
.mesh
.mshcfg
.dot11MeshMaxPeerLinks
, DEC
);
609 IEEE80211_IF_FILE(dot11MeshHWMPactivePathTimeout
,
610 u
.mesh
.mshcfg
.dot11MeshHWMPactivePathTimeout
, DEC
);
611 IEEE80211_IF_FILE(dot11MeshHWMPpreqMinInterval
,
612 u
.mesh
.mshcfg
.dot11MeshHWMPpreqMinInterval
, DEC
);
613 IEEE80211_IF_FILE(dot11MeshHWMPperrMinInterval
,
614 u
.mesh
.mshcfg
.dot11MeshHWMPperrMinInterval
, DEC
);
615 IEEE80211_IF_FILE(dot11MeshHWMPnetDiameterTraversalTime
,
616 u
.mesh
.mshcfg
.dot11MeshHWMPnetDiameterTraversalTime
, DEC
);
617 IEEE80211_IF_FILE(dot11MeshHWMPmaxPREQretries
,
618 u
.mesh
.mshcfg
.dot11MeshHWMPmaxPREQretries
, DEC
);
619 IEEE80211_IF_FILE(path_refresh_time
,
620 u
.mesh
.mshcfg
.path_refresh_time
, DEC
);
621 IEEE80211_IF_FILE(min_discovery_timeout
,
622 u
.mesh
.mshcfg
.min_discovery_timeout
, DEC
);
623 IEEE80211_IF_FILE(dot11MeshHWMPRootMode
,
624 u
.mesh
.mshcfg
.dot11MeshHWMPRootMode
, DEC
);
625 IEEE80211_IF_FILE(dot11MeshGateAnnouncementProtocol
,
626 u
.mesh
.mshcfg
.dot11MeshGateAnnouncementProtocol
, DEC
);
627 IEEE80211_IF_FILE(dot11MeshHWMPRannInterval
,
628 u
.mesh
.mshcfg
.dot11MeshHWMPRannInterval
, DEC
);
629 IEEE80211_IF_FILE(dot11MeshForwarding
, u
.mesh
.mshcfg
.dot11MeshForwarding
, DEC
);
630 IEEE80211_IF_FILE(rssi_threshold
, u
.mesh
.mshcfg
.rssi_threshold
, DEC
);
631 IEEE80211_IF_FILE(ht_opmode
, u
.mesh
.mshcfg
.ht_opmode
, DEC
);
632 IEEE80211_IF_FILE(dot11MeshHWMPactivePathToRootTimeout
,
633 u
.mesh
.mshcfg
.dot11MeshHWMPactivePathToRootTimeout
, DEC
);
634 IEEE80211_IF_FILE(dot11MeshHWMProotInterval
,
635 u
.mesh
.mshcfg
.dot11MeshHWMProotInterval
, DEC
);
636 IEEE80211_IF_FILE(dot11MeshHWMPconfirmationInterval
,
637 u
.mesh
.mshcfg
.dot11MeshHWMPconfirmationInterval
, DEC
);
638 IEEE80211_IF_FILE(power_mode
, u
.mesh
.mshcfg
.power_mode
, DEC
);
639 IEEE80211_IF_FILE(dot11MeshAwakeWindowDuration
,
640 u
.mesh
.mshcfg
.dot11MeshAwakeWindowDuration
, DEC
);
641 IEEE80211_IF_FILE(dot11MeshConnectedToMeshGate
,
642 u
.mesh
.mshcfg
.dot11MeshConnectedToMeshGate
, DEC
);
645 #define DEBUGFS_ADD_MODE(name, mode) \
646 debugfs_create_file(#name, mode, sdata->vif.debugfs_dir, \
649 #define DEBUGFS_ADD(name) DEBUGFS_ADD_MODE(name, 0400)
651 static void add_common_files(struct ieee80211_sub_if_data
*sdata
)
653 DEBUGFS_ADD(rc_rateidx_mask_2ghz
);
654 DEBUGFS_ADD(rc_rateidx_mask_5ghz
);
655 DEBUGFS_ADD(rc_rateidx_mcs_mask_2ghz
);
656 DEBUGFS_ADD(rc_rateidx_mcs_mask_5ghz
);
657 DEBUGFS_ADD(rc_rateidx_vht_mcs_mask_2ghz
);
658 DEBUGFS_ADD(rc_rateidx_vht_mcs_mask_5ghz
);
659 DEBUGFS_ADD(hw_queues
);
661 if (sdata
->local
->ops
->wake_tx_queue
)
665 static void add_sta_files(struct ieee80211_sub_if_data
*sdata
)
669 DEBUGFS_ADD(beacon_timeout
);
670 DEBUGFS_ADD_MODE(smps
, 0600);
671 DEBUGFS_ADD_MODE(tkip_mic_test
, 0200);
672 DEBUGFS_ADD_MODE(beacon_loss
, 0200);
673 DEBUGFS_ADD_MODE(uapsd_queues
, 0600);
674 DEBUGFS_ADD_MODE(uapsd_max_sp_len
, 0600);
675 DEBUGFS_ADD_MODE(tdls_wider_bw
, 0600);
678 static void add_ap_files(struct ieee80211_sub_if_data
*sdata
)
680 DEBUGFS_ADD(num_mcast_sta
);
681 DEBUGFS_ADD_MODE(smps
, 0600);
682 DEBUGFS_ADD(num_sta_ps
);
683 DEBUGFS_ADD(dtim_count
);
684 DEBUGFS_ADD(num_buffered_multicast
);
685 DEBUGFS_ADD_MODE(tkip_mic_test
, 0200);
686 DEBUGFS_ADD_MODE(multicast_to_unicast
, 0600);
689 static void add_vlan_files(struct ieee80211_sub_if_data
*sdata
)
691 /* add num_mcast_sta_vlan using name num_mcast_sta */
692 debugfs_create_file("num_mcast_sta", 0400, sdata
->vif
.debugfs_dir
,
693 sdata
, &num_mcast_sta_vlan_ops
);
696 static void add_ibss_files(struct ieee80211_sub_if_data
*sdata
)
698 DEBUGFS_ADD_MODE(tsf
, 0600);
701 static void add_wds_files(struct ieee80211_sub_if_data
*sdata
)
706 #ifdef CONFIG_MAC80211_MESH
708 static void add_mesh_files(struct ieee80211_sub_if_data
*sdata
)
710 DEBUGFS_ADD_MODE(tsf
, 0600);
711 DEBUGFS_ADD_MODE(estab_plinks
, 0400);
714 static void add_mesh_stats(struct ieee80211_sub_if_data
*sdata
)
716 struct dentry
*dir
= debugfs_create_dir("mesh_stats",
717 sdata
->vif
.debugfs_dir
);
718 #define MESHSTATS_ADD(name)\
719 debugfs_create_file(#name, 0400, dir, sdata, &name##_ops);
721 MESHSTATS_ADD(fwded_mcast
);
722 MESHSTATS_ADD(fwded_unicast
);
723 MESHSTATS_ADD(fwded_frames
);
724 MESHSTATS_ADD(dropped_frames_ttl
);
725 MESHSTATS_ADD(dropped_frames_no_route
);
726 MESHSTATS_ADD(dropped_frames_congestion
);
730 static void add_mesh_config(struct ieee80211_sub_if_data
*sdata
)
732 struct dentry
*dir
= debugfs_create_dir("mesh_config",
733 sdata
->vif
.debugfs_dir
);
735 #define MESHPARAMS_ADD(name) \
736 debugfs_create_file(#name, 0600, dir, sdata, &name##_ops);
738 MESHPARAMS_ADD(dot11MeshMaxRetries
);
739 MESHPARAMS_ADD(dot11MeshRetryTimeout
);
740 MESHPARAMS_ADD(dot11MeshConfirmTimeout
);
741 MESHPARAMS_ADD(dot11MeshHoldingTimeout
);
742 MESHPARAMS_ADD(dot11MeshTTL
);
743 MESHPARAMS_ADD(element_ttl
);
744 MESHPARAMS_ADD(auto_open_plinks
);
745 MESHPARAMS_ADD(dot11MeshMaxPeerLinks
);
746 MESHPARAMS_ADD(dot11MeshHWMPactivePathTimeout
);
747 MESHPARAMS_ADD(dot11MeshHWMPpreqMinInterval
);
748 MESHPARAMS_ADD(dot11MeshHWMPperrMinInterval
);
749 MESHPARAMS_ADD(dot11MeshHWMPnetDiameterTraversalTime
);
750 MESHPARAMS_ADD(dot11MeshHWMPmaxPREQretries
);
751 MESHPARAMS_ADD(path_refresh_time
);
752 MESHPARAMS_ADD(min_discovery_timeout
);
753 MESHPARAMS_ADD(dot11MeshHWMPRootMode
);
754 MESHPARAMS_ADD(dot11MeshHWMPRannInterval
);
755 MESHPARAMS_ADD(dot11MeshForwarding
);
756 MESHPARAMS_ADD(dot11MeshGateAnnouncementProtocol
);
757 MESHPARAMS_ADD(rssi_threshold
);
758 MESHPARAMS_ADD(ht_opmode
);
759 MESHPARAMS_ADD(dot11MeshHWMPactivePathToRootTimeout
);
760 MESHPARAMS_ADD(dot11MeshHWMProotInterval
);
761 MESHPARAMS_ADD(dot11MeshHWMPconfirmationInterval
);
762 MESHPARAMS_ADD(power_mode
);
763 MESHPARAMS_ADD(dot11MeshAwakeWindowDuration
);
764 MESHPARAMS_ADD(dot11MeshConnectedToMeshGate
);
765 #undef MESHPARAMS_ADD
769 static void add_files(struct ieee80211_sub_if_data
*sdata
)
771 if (!sdata
->vif
.debugfs_dir
)
776 DEBUGFS_ADD(txpower
);
777 DEBUGFS_ADD(user_power_level
);
778 DEBUGFS_ADD(ap_power_level
);
780 if (sdata
->vif
.type
!= NL80211_IFTYPE_MONITOR
)
781 add_common_files(sdata
);
783 switch (sdata
->vif
.type
) {
784 case NL80211_IFTYPE_MESH_POINT
:
785 #ifdef CONFIG_MAC80211_MESH
786 add_mesh_files(sdata
);
787 add_mesh_stats(sdata
);
788 add_mesh_config(sdata
);
791 case NL80211_IFTYPE_STATION
:
792 add_sta_files(sdata
);
794 case NL80211_IFTYPE_ADHOC
:
795 add_ibss_files(sdata
);
797 case NL80211_IFTYPE_AP
:
800 case NL80211_IFTYPE_AP_VLAN
:
801 add_vlan_files(sdata
);
803 case NL80211_IFTYPE_WDS
:
804 add_wds_files(sdata
);
811 void ieee80211_debugfs_add_netdev(struct ieee80211_sub_if_data
*sdata
)
813 char buf
[10+IFNAMSIZ
];
815 sprintf(buf
, "netdev:%s", sdata
->name
);
816 sdata
->vif
.debugfs_dir
= debugfs_create_dir(buf
,
817 sdata
->local
->hw
.wiphy
->debugfsdir
);
818 if (sdata
->vif
.debugfs_dir
)
819 sdata
->debugfs
.subdir_stations
= debugfs_create_dir("stations",
820 sdata
->vif
.debugfs_dir
);
824 void ieee80211_debugfs_remove_netdev(struct ieee80211_sub_if_data
*sdata
)
826 if (!sdata
->vif
.debugfs_dir
)
829 debugfs_remove_recursive(sdata
->vif
.debugfs_dir
);
830 sdata
->vif
.debugfs_dir
= NULL
;
831 sdata
->debugfs
.subdir_stations
= NULL
;
834 void ieee80211_debugfs_rename_netdev(struct ieee80211_sub_if_data
*sdata
)
837 char buf
[10 + IFNAMSIZ
];
839 dir
= sdata
->vif
.debugfs_dir
;
841 if (IS_ERR_OR_NULL(dir
))
844 sprintf(buf
, "netdev:%s", sdata
->name
);
845 if (!debugfs_rename(dir
->d_parent
, dir
, dir
->d_parent
, buf
))
847 "debugfs: failed to rename debugfs dir to %s\n",