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>
5 * Copyright (C) 2020 Intel Corporation
8 #include <linux/kernel.h>
9 #include <linux/device.h>
11 #include <linux/if_ether.h>
12 #include <linux/interrupt.h>
13 #include <linux/netdevice.h>
14 #include <linux/rtnetlink.h>
15 #include <linux/slab.h>
16 #include <linux/notifier.h>
17 #include <net/mac80211.h>
18 #include <net/cfg80211.h>
19 #include "ieee80211_i.h"
22 #include "debugfs_netdev.h"
23 #include "driver-ops.h"
25 static ssize_t
ieee80211_if_read(
26 struct ieee80211_sub_if_data
*sdata
,
28 size_t count
, loff_t
*ppos
,
29 ssize_t (*format
)(const struct ieee80211_sub_if_data
*, char *, int))
32 ssize_t ret
= -EINVAL
;
34 read_lock(&dev_base_lock
);
35 ret
= (*format
)(sdata
, buf
, sizeof(buf
));
36 read_unlock(&dev_base_lock
);
39 ret
= simple_read_from_buffer(userbuf
, count
, ppos
, buf
, ret
);
44 static ssize_t
ieee80211_if_write(
45 struct ieee80211_sub_if_data
*sdata
,
46 const char __user
*userbuf
,
47 size_t count
, loff_t
*ppos
,
48 ssize_t (*write
)(struct ieee80211_sub_if_data
*, const char *, int))
53 if (count
>= sizeof(buf
))
56 if (copy_from_user(buf
, userbuf
, count
))
62 ret
= (*write
)(sdata
, buf
, count
);
68 #define IEEE80211_IF_FMT(name, field, format_string) \
69 static ssize_t ieee80211_if_fmt_##name( \
70 const struct ieee80211_sub_if_data *sdata, char *buf, \
73 return scnprintf(buf, buflen, format_string, sdata->field); \
75 #define IEEE80211_IF_FMT_DEC(name, field) \
76 IEEE80211_IF_FMT(name, field, "%d\n")
77 #define IEEE80211_IF_FMT_HEX(name, field) \
78 IEEE80211_IF_FMT(name, field, "%#x\n")
79 #define IEEE80211_IF_FMT_LHEX(name, field) \
80 IEEE80211_IF_FMT(name, field, "%#lx\n")
81 #define IEEE80211_IF_FMT_SIZE(name, field) \
82 IEEE80211_IF_FMT(name, field, "%zd\n")
84 #define IEEE80211_IF_FMT_HEXARRAY(name, field) \
85 static ssize_t ieee80211_if_fmt_##name( \
86 const struct ieee80211_sub_if_data *sdata, \
87 char *buf, int buflen) \
91 for (i = 0; i < sizeof(sdata->field); i++) { \
92 p += scnprintf(p, buflen + buf - p, "%.2x ", \
95 p += scnprintf(p, buflen + buf - p, "\n"); \
99 #define IEEE80211_IF_FMT_ATOMIC(name, field) \
100 static ssize_t ieee80211_if_fmt_##name( \
101 const struct ieee80211_sub_if_data *sdata, \
102 char *buf, int buflen) \
104 return scnprintf(buf, buflen, "%d\n", atomic_read(&sdata->field));\
107 #define IEEE80211_IF_FMT_MAC(name, field) \
108 static ssize_t ieee80211_if_fmt_##name( \
109 const struct ieee80211_sub_if_data *sdata, char *buf, \
112 return scnprintf(buf, buflen, "%pM\n", sdata->field); \
115 #define IEEE80211_IF_FMT_JIFFIES_TO_MS(name, field) \
116 static ssize_t ieee80211_if_fmt_##name( \
117 const struct ieee80211_sub_if_data *sdata, \
118 char *buf, int buflen) \
120 return scnprintf(buf, buflen, "%d\n", \
121 jiffies_to_msecs(sdata->field)); \
124 #define _IEEE80211_IF_FILE_OPS(name, _read, _write) \
125 static const struct file_operations name##_ops = { \
128 .open = simple_open, \
129 .llseek = generic_file_llseek, \
132 #define _IEEE80211_IF_FILE_R_FN(name) \
133 static ssize_t ieee80211_if_read_##name(struct file *file, \
134 char __user *userbuf, \
135 size_t count, loff_t *ppos) \
137 return ieee80211_if_read(file->private_data, \
138 userbuf, count, ppos, \
139 ieee80211_if_fmt_##name); \
142 #define _IEEE80211_IF_FILE_W_FN(name) \
143 static ssize_t ieee80211_if_write_##name(struct file *file, \
144 const char __user *userbuf, \
145 size_t count, loff_t *ppos) \
147 return ieee80211_if_write(file->private_data, userbuf, count, \
148 ppos, ieee80211_if_parse_##name); \
151 #define IEEE80211_IF_FILE_R(name) \
152 _IEEE80211_IF_FILE_R_FN(name) \
153 _IEEE80211_IF_FILE_OPS(name, ieee80211_if_read_##name, NULL)
155 #define IEEE80211_IF_FILE_W(name) \
156 _IEEE80211_IF_FILE_W_FN(name) \
157 _IEEE80211_IF_FILE_OPS(name, NULL, ieee80211_if_write_##name)
159 #define IEEE80211_IF_FILE_RW(name) \
160 _IEEE80211_IF_FILE_R_FN(name) \
161 _IEEE80211_IF_FILE_W_FN(name) \
162 _IEEE80211_IF_FILE_OPS(name, ieee80211_if_read_##name, \
163 ieee80211_if_write_##name)
165 #define IEEE80211_IF_FILE(name, field, format) \
166 IEEE80211_IF_FMT_##format(name, field) \
167 IEEE80211_IF_FILE_R(name)
169 /* common attributes */
170 IEEE80211_IF_FILE(rc_rateidx_mask_2ghz
, rc_rateidx_mask
[NL80211_BAND_2GHZ
],
172 IEEE80211_IF_FILE(rc_rateidx_mask_5ghz
, rc_rateidx_mask
[NL80211_BAND_5GHZ
],
174 IEEE80211_IF_FILE(rc_rateidx_mcs_mask_2ghz
,
175 rc_rateidx_mcs_mask
[NL80211_BAND_2GHZ
], HEXARRAY
);
176 IEEE80211_IF_FILE(rc_rateidx_mcs_mask_5ghz
,
177 rc_rateidx_mcs_mask
[NL80211_BAND_5GHZ
], HEXARRAY
);
179 static ssize_t
ieee80211_if_fmt_rc_rateidx_vht_mcs_mask_2ghz(
180 const struct ieee80211_sub_if_data
*sdata
,
181 char *buf
, int buflen
)
184 const u16
*mask
= sdata
->rc_rateidx_vht_mcs_mask
[NL80211_BAND_2GHZ
];
186 for (i
= 0; i
< NL80211_VHT_NSS_MAX
; i
++)
187 len
+= scnprintf(buf
+ len
, buflen
- len
, "%04x ", mask
[i
]);
188 len
+= scnprintf(buf
+ len
, buflen
- len
, "\n");
193 IEEE80211_IF_FILE_R(rc_rateidx_vht_mcs_mask_2ghz
);
195 static ssize_t
ieee80211_if_fmt_rc_rateidx_vht_mcs_mask_5ghz(
196 const struct ieee80211_sub_if_data
*sdata
,
197 char *buf
, int buflen
)
200 const u16
*mask
= sdata
->rc_rateidx_vht_mcs_mask
[NL80211_BAND_5GHZ
];
202 for (i
= 0; i
< NL80211_VHT_NSS_MAX
; i
++)
203 len
+= scnprintf(buf
+ len
, buflen
- len
, "%04x ", mask
[i
]);
204 len
+= scnprintf(buf
+ len
, buflen
- len
, "\n");
209 IEEE80211_IF_FILE_R(rc_rateidx_vht_mcs_mask_5ghz
);
211 IEEE80211_IF_FILE(flags
, flags
, HEX
);
212 IEEE80211_IF_FILE(state
, state
, LHEX
);
213 IEEE80211_IF_FILE(txpower
, vif
.bss_conf
.txpower
, DEC
);
214 IEEE80211_IF_FILE(ap_power_level
, ap_power_level
, DEC
);
215 IEEE80211_IF_FILE(user_power_level
, user_power_level
, DEC
);
218 ieee80211_if_fmt_hw_queues(const struct ieee80211_sub_if_data
*sdata
,
219 char *buf
, int buflen
)
223 len
= scnprintf(buf
, buflen
, "AC queues: VO:%d VI:%d BE:%d BK:%d\n",
224 sdata
->vif
.hw_queue
[IEEE80211_AC_VO
],
225 sdata
->vif
.hw_queue
[IEEE80211_AC_VI
],
226 sdata
->vif
.hw_queue
[IEEE80211_AC_BE
],
227 sdata
->vif
.hw_queue
[IEEE80211_AC_BK
]);
229 if (sdata
->vif
.type
== NL80211_IFTYPE_AP
)
230 len
+= scnprintf(buf
+ len
, buflen
- len
, "cab queue: %d\n",
231 sdata
->vif
.cab_queue
);
235 IEEE80211_IF_FILE_R(hw_queues
);
238 IEEE80211_IF_FILE(bssid
, u
.mgd
.bssid
, MAC
);
239 IEEE80211_IF_FILE(aid
, vif
.bss_conf
.aid
, DEC
);
240 IEEE80211_IF_FILE(beacon_timeout
, u
.mgd
.beacon_timeout
, JIFFIES_TO_MS
);
242 static int ieee80211_set_smps(struct ieee80211_sub_if_data
*sdata
,
243 enum ieee80211_smps_mode smps_mode
)
245 struct ieee80211_local
*local
= sdata
->local
;
248 if (!(local
->hw
.wiphy
->features
& NL80211_FEATURE_STATIC_SMPS
) &&
249 smps_mode
== IEEE80211_SMPS_STATIC
)
252 /* auto should be dynamic if in PS mode */
253 if (!(local
->hw
.wiphy
->features
& NL80211_FEATURE_DYNAMIC_SMPS
) &&
254 (smps_mode
== IEEE80211_SMPS_DYNAMIC
||
255 smps_mode
== IEEE80211_SMPS_AUTOMATIC
))
258 if (sdata
->vif
.type
!= NL80211_IFTYPE_STATION
)
262 err
= __ieee80211_request_smps_mgd(sdata
, smps_mode
);
268 static const char *smps_modes
[IEEE80211_SMPS_NUM_MODES
] = {
269 [IEEE80211_SMPS_AUTOMATIC
] = "auto",
270 [IEEE80211_SMPS_OFF
] = "off",
271 [IEEE80211_SMPS_STATIC
] = "static",
272 [IEEE80211_SMPS_DYNAMIC
] = "dynamic",
275 static ssize_t
ieee80211_if_fmt_smps(const struct ieee80211_sub_if_data
*sdata
,
276 char *buf
, int buflen
)
278 if (sdata
->vif
.type
== NL80211_IFTYPE_STATION
)
279 return snprintf(buf
, buflen
, "request: %s\nused: %s\n",
280 smps_modes
[sdata
->u
.mgd
.req_smps
],
281 smps_modes
[sdata
->smps_mode
]);
285 static ssize_t
ieee80211_if_parse_smps(struct ieee80211_sub_if_data
*sdata
,
286 const char *buf
, int buflen
)
288 enum ieee80211_smps_mode mode
;
290 for (mode
= 0; mode
< IEEE80211_SMPS_NUM_MODES
; mode
++) {
291 if (strncmp(buf
, smps_modes
[mode
], buflen
) == 0) {
292 int err
= ieee80211_set_smps(sdata
, mode
);
301 IEEE80211_IF_FILE_RW(smps
);
303 static ssize_t
ieee80211_if_parse_tkip_mic_test(
304 struct ieee80211_sub_if_data
*sdata
, const char *buf
, int buflen
)
306 struct ieee80211_local
*local
= sdata
->local
;
309 struct ieee80211_hdr
*hdr
;
312 if (!mac_pton(buf
, addr
))
315 if (!ieee80211_sdata_running(sdata
))
318 skb
= dev_alloc_skb(local
->hw
.extra_tx_headroom
+ 24 + 100);
321 skb_reserve(skb
, local
->hw
.extra_tx_headroom
);
323 hdr
= skb_put_zero(skb
, 24);
324 fc
= cpu_to_le16(IEEE80211_FTYPE_DATA
| IEEE80211_STYPE_DATA
);
326 switch (sdata
->vif
.type
) {
327 case NL80211_IFTYPE_AP
:
328 fc
|= cpu_to_le16(IEEE80211_FCTL_FROMDS
);
330 memcpy(hdr
->addr1
, addr
, ETH_ALEN
);
331 memcpy(hdr
->addr2
, sdata
->vif
.addr
, ETH_ALEN
);
332 memcpy(hdr
->addr3
, sdata
->vif
.addr
, ETH_ALEN
);
334 case NL80211_IFTYPE_STATION
:
335 fc
|= cpu_to_le16(IEEE80211_FCTL_TODS
);
338 if (!sdata
->u
.mgd
.associated
) {
343 memcpy(hdr
->addr1
, sdata
->u
.mgd
.associated
->bssid
, ETH_ALEN
);
344 memcpy(hdr
->addr2
, sdata
->vif
.addr
, ETH_ALEN
);
345 memcpy(hdr
->addr3
, addr
, ETH_ALEN
);
352 hdr
->frame_control
= fc
;
355 * Add some length to the test frame to make it look bit more valid.
356 * The exact contents does not matter since the recipient is required
357 * to drop this because of the Michael MIC failure.
359 skb_put_zero(skb
, 50);
361 IEEE80211_SKB_CB(skb
)->flags
|= IEEE80211_TX_INTFL_TKIP_MIC_FAILURE
;
363 ieee80211_tx_skb(sdata
, skb
);
367 IEEE80211_IF_FILE_W(tkip_mic_test
);
369 static ssize_t
ieee80211_if_parse_beacon_loss(
370 struct ieee80211_sub_if_data
*sdata
, const char *buf
, int buflen
)
372 if (!ieee80211_sdata_running(sdata
) || !sdata
->vif
.bss_conf
.assoc
)
375 ieee80211_beacon_loss(&sdata
->vif
);
379 IEEE80211_IF_FILE_W(beacon_loss
);
381 static ssize_t
ieee80211_if_fmt_uapsd_queues(
382 const struct ieee80211_sub_if_data
*sdata
, char *buf
, int buflen
)
384 const struct ieee80211_if_managed
*ifmgd
= &sdata
->u
.mgd
;
386 return snprintf(buf
, buflen
, "0x%x\n", ifmgd
->uapsd_queues
);
389 static ssize_t
ieee80211_if_parse_uapsd_queues(
390 struct ieee80211_sub_if_data
*sdata
, const char *buf
, int buflen
)
392 struct ieee80211_if_managed
*ifmgd
= &sdata
->u
.mgd
;
396 ret
= kstrtou8(buf
, 0, &val
);
400 if (val
& ~IEEE80211_WMM_IE_STA_QOSINFO_AC_MASK
)
403 ifmgd
->uapsd_queues
= val
;
407 IEEE80211_IF_FILE_RW(uapsd_queues
);
409 static ssize_t
ieee80211_if_fmt_uapsd_max_sp_len(
410 const struct ieee80211_sub_if_data
*sdata
, char *buf
, int buflen
)
412 const struct ieee80211_if_managed
*ifmgd
= &sdata
->u
.mgd
;
414 return snprintf(buf
, buflen
, "0x%x\n", ifmgd
->uapsd_max_sp_len
);
417 static ssize_t
ieee80211_if_parse_uapsd_max_sp_len(
418 struct ieee80211_sub_if_data
*sdata
, const char *buf
, int buflen
)
420 struct ieee80211_if_managed
*ifmgd
= &sdata
->u
.mgd
;
424 ret
= kstrtoul(buf
, 0, &val
);
428 if (val
& ~IEEE80211_WMM_IE_STA_QOSINFO_SP_MASK
)
431 ifmgd
->uapsd_max_sp_len
= val
;
435 IEEE80211_IF_FILE_RW(uapsd_max_sp_len
);
437 static ssize_t
ieee80211_if_fmt_tdls_wider_bw(
438 const struct ieee80211_sub_if_data
*sdata
, char *buf
, int buflen
)
440 const struct ieee80211_if_managed
*ifmgd
= &sdata
->u
.mgd
;
443 tdls_wider_bw
= ieee80211_hw_check(&sdata
->local
->hw
, TDLS_WIDER_BW
) &&
444 !ifmgd
->tdls_wider_bw_prohibited
;
446 return snprintf(buf
, buflen
, "%d\n", tdls_wider_bw
);
449 static ssize_t
ieee80211_if_parse_tdls_wider_bw(
450 struct ieee80211_sub_if_data
*sdata
, const char *buf
, int buflen
)
452 struct ieee80211_if_managed
*ifmgd
= &sdata
->u
.mgd
;
456 ret
= kstrtou8(buf
, 0, &val
);
460 ifmgd
->tdls_wider_bw_prohibited
= !val
;
463 IEEE80211_IF_FILE_RW(tdls_wider_bw
);
466 IEEE80211_IF_FILE(num_mcast_sta
, u
.ap
.num_mcast_sta
, ATOMIC
);
467 IEEE80211_IF_FILE(num_sta_ps
, u
.ap
.ps
.num_sta_ps
, ATOMIC
);
468 IEEE80211_IF_FILE(dtim_count
, u
.ap
.ps
.dtim_count
, DEC
);
469 IEEE80211_IF_FILE(num_mcast_sta_vlan
, u
.vlan
.num_mcast_sta
, ATOMIC
);
471 static ssize_t
ieee80211_if_fmt_num_buffered_multicast(
472 const struct ieee80211_sub_if_data
*sdata
, char *buf
, int buflen
)
474 return scnprintf(buf
, buflen
, "%u\n",
475 skb_queue_len(&sdata
->u
.ap
.ps
.bc_buf
));
477 IEEE80211_IF_FILE_R(num_buffered_multicast
);
479 static ssize_t
ieee80211_if_fmt_aqm(
480 const struct ieee80211_sub_if_data
*sdata
, char *buf
, int buflen
)
482 struct ieee80211_local
*local
= sdata
->local
;
483 struct txq_info
*txqi
;
489 txqi
= to_txq_info(sdata
->vif
.txq
);
491 spin_lock_bh(&local
->fq
.lock
);
496 "ac backlog-bytes backlog-packets new-flows drops marks overlimit collisions tx-bytes tx-packets\n"
497 "%u %u %u %u %u %u %u %u %u %u\n",
499 txqi
->tin
.backlog_bytes
,
500 txqi
->tin
.backlog_packets
,
502 txqi
->cstats
.drop_count
,
503 txqi
->cstats
.ecn_mark
,
505 txqi
->tin
.collisions
,
507 txqi
->tin
.tx_packets
);
510 spin_unlock_bh(&local
->fq
.lock
);
514 IEEE80211_IF_FILE_R(aqm
);
516 IEEE80211_IF_FILE(multicast_to_unicast
, u
.ap
.multicast_to_unicast
, HEX
);
518 /* IBSS attributes */
519 static ssize_t
ieee80211_if_fmt_tsf(
520 const struct ieee80211_sub_if_data
*sdata
, char *buf
, int buflen
)
522 struct ieee80211_local
*local
= sdata
->local
;
525 tsf
= drv_get_tsf(local
, (struct ieee80211_sub_if_data
*)sdata
);
527 return scnprintf(buf
, buflen
, "0x%016llx\n", (unsigned long long) tsf
);
530 static ssize_t
ieee80211_if_parse_tsf(
531 struct ieee80211_sub_if_data
*sdata
, const char *buf
, int buflen
)
533 struct ieee80211_local
*local
= sdata
->local
;
534 unsigned long long tsf
;
536 int tsf_is_delta
= 0;
538 if (strncmp(buf
, "reset", 5) == 0) {
539 if (local
->ops
->reset_tsf
) {
540 drv_reset_tsf(local
, sdata
);
541 wiphy_info(local
->hw
.wiphy
, "debugfs reset TSF\n");
544 if (buflen
> 10 && buf
[1] == '=') {
547 else if (buf
[0] == '-')
553 ret
= kstrtoull(buf
, 10, &tsf
);
556 if (tsf_is_delta
&& local
->ops
->offset_tsf
) {
557 drv_offset_tsf(local
, sdata
, tsf_is_delta
* tsf
);
558 wiphy_info(local
->hw
.wiphy
,
559 "debugfs offset TSF by %018lld\n",
561 } else if (local
->ops
->set_tsf
) {
563 tsf
= drv_get_tsf(local
, sdata
) +
565 drv_set_tsf(local
, sdata
, tsf
);
566 wiphy_info(local
->hw
.wiphy
,
567 "debugfs set TSF to %#018llx\n", tsf
);
571 ieee80211_recalc_dtim(local
, sdata
);
574 IEEE80211_IF_FILE_RW(tsf
);
577 #ifdef CONFIG_MAC80211_MESH
578 IEEE80211_IF_FILE(estab_plinks
, u
.mesh
.estab_plinks
, ATOMIC
);
580 /* Mesh stats attributes */
581 IEEE80211_IF_FILE(fwded_mcast
, u
.mesh
.mshstats
.fwded_mcast
, DEC
);
582 IEEE80211_IF_FILE(fwded_unicast
, u
.mesh
.mshstats
.fwded_unicast
, DEC
);
583 IEEE80211_IF_FILE(fwded_frames
, u
.mesh
.mshstats
.fwded_frames
, DEC
);
584 IEEE80211_IF_FILE(dropped_frames_ttl
, u
.mesh
.mshstats
.dropped_frames_ttl
, DEC
);
585 IEEE80211_IF_FILE(dropped_frames_congestion
,
586 u
.mesh
.mshstats
.dropped_frames_congestion
, DEC
);
587 IEEE80211_IF_FILE(dropped_frames_no_route
,
588 u
.mesh
.mshstats
.dropped_frames_no_route
, DEC
);
590 /* Mesh parameters */
591 IEEE80211_IF_FILE(dot11MeshMaxRetries
,
592 u
.mesh
.mshcfg
.dot11MeshMaxRetries
, DEC
);
593 IEEE80211_IF_FILE(dot11MeshRetryTimeout
,
594 u
.mesh
.mshcfg
.dot11MeshRetryTimeout
, DEC
);
595 IEEE80211_IF_FILE(dot11MeshConfirmTimeout
,
596 u
.mesh
.mshcfg
.dot11MeshConfirmTimeout
, DEC
);
597 IEEE80211_IF_FILE(dot11MeshHoldingTimeout
,
598 u
.mesh
.mshcfg
.dot11MeshHoldingTimeout
, DEC
);
599 IEEE80211_IF_FILE(dot11MeshTTL
, u
.mesh
.mshcfg
.dot11MeshTTL
, DEC
);
600 IEEE80211_IF_FILE(element_ttl
, u
.mesh
.mshcfg
.element_ttl
, DEC
);
601 IEEE80211_IF_FILE(auto_open_plinks
, u
.mesh
.mshcfg
.auto_open_plinks
, DEC
);
602 IEEE80211_IF_FILE(dot11MeshMaxPeerLinks
,
603 u
.mesh
.mshcfg
.dot11MeshMaxPeerLinks
, DEC
);
604 IEEE80211_IF_FILE(dot11MeshHWMPactivePathTimeout
,
605 u
.mesh
.mshcfg
.dot11MeshHWMPactivePathTimeout
, DEC
);
606 IEEE80211_IF_FILE(dot11MeshHWMPpreqMinInterval
,
607 u
.mesh
.mshcfg
.dot11MeshHWMPpreqMinInterval
, DEC
);
608 IEEE80211_IF_FILE(dot11MeshHWMPperrMinInterval
,
609 u
.mesh
.mshcfg
.dot11MeshHWMPperrMinInterval
, DEC
);
610 IEEE80211_IF_FILE(dot11MeshHWMPnetDiameterTraversalTime
,
611 u
.mesh
.mshcfg
.dot11MeshHWMPnetDiameterTraversalTime
, DEC
);
612 IEEE80211_IF_FILE(dot11MeshHWMPmaxPREQretries
,
613 u
.mesh
.mshcfg
.dot11MeshHWMPmaxPREQretries
, DEC
);
614 IEEE80211_IF_FILE(path_refresh_time
,
615 u
.mesh
.mshcfg
.path_refresh_time
, DEC
);
616 IEEE80211_IF_FILE(min_discovery_timeout
,
617 u
.mesh
.mshcfg
.min_discovery_timeout
, DEC
);
618 IEEE80211_IF_FILE(dot11MeshHWMPRootMode
,
619 u
.mesh
.mshcfg
.dot11MeshHWMPRootMode
, DEC
);
620 IEEE80211_IF_FILE(dot11MeshGateAnnouncementProtocol
,
621 u
.mesh
.mshcfg
.dot11MeshGateAnnouncementProtocol
, DEC
);
622 IEEE80211_IF_FILE(dot11MeshHWMPRannInterval
,
623 u
.mesh
.mshcfg
.dot11MeshHWMPRannInterval
, DEC
);
624 IEEE80211_IF_FILE(dot11MeshForwarding
, u
.mesh
.mshcfg
.dot11MeshForwarding
, DEC
);
625 IEEE80211_IF_FILE(rssi_threshold
, u
.mesh
.mshcfg
.rssi_threshold
, DEC
);
626 IEEE80211_IF_FILE(ht_opmode
, u
.mesh
.mshcfg
.ht_opmode
, DEC
);
627 IEEE80211_IF_FILE(dot11MeshHWMPactivePathToRootTimeout
,
628 u
.mesh
.mshcfg
.dot11MeshHWMPactivePathToRootTimeout
, DEC
);
629 IEEE80211_IF_FILE(dot11MeshHWMProotInterval
,
630 u
.mesh
.mshcfg
.dot11MeshHWMProotInterval
, DEC
);
631 IEEE80211_IF_FILE(dot11MeshHWMPconfirmationInterval
,
632 u
.mesh
.mshcfg
.dot11MeshHWMPconfirmationInterval
, DEC
);
633 IEEE80211_IF_FILE(power_mode
, u
.mesh
.mshcfg
.power_mode
, DEC
);
634 IEEE80211_IF_FILE(dot11MeshAwakeWindowDuration
,
635 u
.mesh
.mshcfg
.dot11MeshAwakeWindowDuration
, DEC
);
636 IEEE80211_IF_FILE(dot11MeshConnectedToMeshGate
,
637 u
.mesh
.mshcfg
.dot11MeshConnectedToMeshGate
, DEC
);
638 IEEE80211_IF_FILE(dot11MeshNolearn
, u
.mesh
.mshcfg
.dot11MeshNolearn
, DEC
);
639 IEEE80211_IF_FILE(dot11MeshConnectedToAuthServer
,
640 u
.mesh
.mshcfg
.dot11MeshConnectedToAuthServer
, DEC
);
643 #define DEBUGFS_ADD_MODE(name, mode) \
644 debugfs_create_file(#name, mode, sdata->vif.debugfs_dir, \
647 #define DEBUGFS_ADD(name) DEBUGFS_ADD_MODE(name, 0400)
649 static void add_common_files(struct ieee80211_sub_if_data
*sdata
)
651 DEBUGFS_ADD(rc_rateidx_mask_2ghz
);
652 DEBUGFS_ADD(rc_rateidx_mask_5ghz
);
653 DEBUGFS_ADD(rc_rateidx_mcs_mask_2ghz
);
654 DEBUGFS_ADD(rc_rateidx_mcs_mask_5ghz
);
655 DEBUGFS_ADD(rc_rateidx_vht_mcs_mask_2ghz
);
656 DEBUGFS_ADD(rc_rateidx_vht_mcs_mask_5ghz
);
657 DEBUGFS_ADD(hw_queues
);
659 if (sdata
->local
->ops
->wake_tx_queue
&&
660 sdata
->vif
.type
!= NL80211_IFTYPE_P2P_DEVICE
&&
661 sdata
->vif
.type
!= NL80211_IFTYPE_NAN
)
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 #ifdef CONFIG_MAC80211_MESH
703 static void add_mesh_files(struct ieee80211_sub_if_data
*sdata
)
705 DEBUGFS_ADD_MODE(tsf
, 0600);
706 DEBUGFS_ADD_MODE(estab_plinks
, 0400);
709 static void add_mesh_stats(struct ieee80211_sub_if_data
*sdata
)
711 struct dentry
*dir
= debugfs_create_dir("mesh_stats",
712 sdata
->vif
.debugfs_dir
);
713 #define MESHSTATS_ADD(name)\
714 debugfs_create_file(#name, 0400, dir, sdata, &name##_ops)
716 MESHSTATS_ADD(fwded_mcast
);
717 MESHSTATS_ADD(fwded_unicast
);
718 MESHSTATS_ADD(fwded_frames
);
719 MESHSTATS_ADD(dropped_frames_ttl
);
720 MESHSTATS_ADD(dropped_frames_no_route
);
721 MESHSTATS_ADD(dropped_frames_congestion
);
725 static void add_mesh_config(struct ieee80211_sub_if_data
*sdata
)
727 struct dentry
*dir
= debugfs_create_dir("mesh_config",
728 sdata
->vif
.debugfs_dir
);
730 #define MESHPARAMS_ADD(name) \
731 debugfs_create_file(#name, 0600, dir, sdata, &name##_ops)
733 MESHPARAMS_ADD(dot11MeshMaxRetries
);
734 MESHPARAMS_ADD(dot11MeshRetryTimeout
);
735 MESHPARAMS_ADD(dot11MeshConfirmTimeout
);
736 MESHPARAMS_ADD(dot11MeshHoldingTimeout
);
737 MESHPARAMS_ADD(dot11MeshTTL
);
738 MESHPARAMS_ADD(element_ttl
);
739 MESHPARAMS_ADD(auto_open_plinks
);
740 MESHPARAMS_ADD(dot11MeshMaxPeerLinks
);
741 MESHPARAMS_ADD(dot11MeshHWMPactivePathTimeout
);
742 MESHPARAMS_ADD(dot11MeshHWMPpreqMinInterval
);
743 MESHPARAMS_ADD(dot11MeshHWMPperrMinInterval
);
744 MESHPARAMS_ADD(dot11MeshHWMPnetDiameterTraversalTime
);
745 MESHPARAMS_ADD(dot11MeshHWMPmaxPREQretries
);
746 MESHPARAMS_ADD(path_refresh_time
);
747 MESHPARAMS_ADD(min_discovery_timeout
);
748 MESHPARAMS_ADD(dot11MeshHWMPRootMode
);
749 MESHPARAMS_ADD(dot11MeshHWMPRannInterval
);
750 MESHPARAMS_ADD(dot11MeshForwarding
);
751 MESHPARAMS_ADD(dot11MeshGateAnnouncementProtocol
);
752 MESHPARAMS_ADD(rssi_threshold
);
753 MESHPARAMS_ADD(ht_opmode
);
754 MESHPARAMS_ADD(dot11MeshHWMPactivePathToRootTimeout
);
755 MESHPARAMS_ADD(dot11MeshHWMProotInterval
);
756 MESHPARAMS_ADD(dot11MeshHWMPconfirmationInterval
);
757 MESHPARAMS_ADD(power_mode
);
758 MESHPARAMS_ADD(dot11MeshAwakeWindowDuration
);
759 MESHPARAMS_ADD(dot11MeshConnectedToMeshGate
);
760 MESHPARAMS_ADD(dot11MeshNolearn
);
761 MESHPARAMS_ADD(dot11MeshConnectedToAuthServer
);
762 #undef MESHPARAMS_ADD
766 static void add_files(struct ieee80211_sub_if_data
*sdata
)
768 if (!sdata
->vif
.debugfs_dir
)
773 DEBUGFS_ADD(txpower
);
774 DEBUGFS_ADD(user_power_level
);
775 DEBUGFS_ADD(ap_power_level
);
777 if (sdata
->vif
.type
!= NL80211_IFTYPE_MONITOR
)
778 add_common_files(sdata
);
780 switch (sdata
->vif
.type
) {
781 case NL80211_IFTYPE_MESH_POINT
:
782 #ifdef CONFIG_MAC80211_MESH
783 add_mesh_files(sdata
);
784 add_mesh_stats(sdata
);
785 add_mesh_config(sdata
);
788 case NL80211_IFTYPE_STATION
:
789 add_sta_files(sdata
);
791 case NL80211_IFTYPE_ADHOC
:
792 add_ibss_files(sdata
);
794 case NL80211_IFTYPE_AP
:
797 case NL80211_IFTYPE_AP_VLAN
:
798 add_vlan_files(sdata
);
805 void ieee80211_debugfs_add_netdev(struct ieee80211_sub_if_data
*sdata
)
807 char buf
[10+IFNAMSIZ
];
809 sprintf(buf
, "netdev:%s", sdata
->name
);
810 sdata
->vif
.debugfs_dir
= debugfs_create_dir(buf
,
811 sdata
->local
->hw
.wiphy
->debugfsdir
);
812 sdata
->debugfs
.subdir_stations
= debugfs_create_dir("stations",
813 sdata
->vif
.debugfs_dir
);
817 void ieee80211_debugfs_remove_netdev(struct ieee80211_sub_if_data
*sdata
)
819 if (!sdata
->vif
.debugfs_dir
)
822 debugfs_remove_recursive(sdata
->vif
.debugfs_dir
);
823 sdata
->vif
.debugfs_dir
= NULL
;
824 sdata
->debugfs
.subdir_stations
= NULL
;
827 void ieee80211_debugfs_rename_netdev(struct ieee80211_sub_if_data
*sdata
)
830 char buf
[10 + IFNAMSIZ
];
832 dir
= sdata
->vif
.debugfs_dir
;
834 if (IS_ERR_OR_NULL(dir
))
837 sprintf(buf
, "netdev:%s", sdata
->name
);
838 debugfs_rename(dir
->d_parent
, dir
, dir
->d_parent
, buf
);