10 #include <linux/kernel.h>
11 #include <linux/device.h>
14 #include <linux/netdevice.h>
15 #include <linux/rtnetlink.h>
16 #include <linux/slab.h>
26 static ssize_t ieee80211_if_read(
29 size_t count, loff_t *ppos,
36 if (sdata->
dev->reg_state == NETREG_REGISTERED)
46 static ssize_t ieee80211_if_write(
48 const char __user *userbuf,
49 size_t count, loff_t *ppos,
55 if (count >=
sizeof(buf))
64 if (sdata->
dev->reg_state == NETREG_REGISTERED)
71 #define IEEE80211_IF_FMT(name, field, format_string) \
72 static ssize_t ieee80211_if_fmt_##name( \
73 const struct ieee80211_sub_if_data *sdata, char *buf, \
76 return scnprintf(buf, buflen, format_string, sdata->field); \
78 #define IEEE80211_IF_FMT_DEC(name, field) \
79 IEEE80211_IF_FMT(name, field, "%d\n")
80 #define IEEE80211_IF_FMT_HEX(name, field) \
81 IEEE80211_IF_FMT(name, field, "%#x\n")
82 #define IEEE80211_IF_FMT_LHEX(name, field) \
83 IEEE80211_IF_FMT(name, field, "%#lx\n")
84 #define IEEE80211_IF_FMT_SIZE(name, field) \
85 IEEE80211_IF_FMT(name, field, "%zd\n")
87 #define IEEE80211_IF_FMT_HEXARRAY(name, field) \
88 static ssize_t ieee80211_if_fmt_##name( \
89 const struct ieee80211_sub_if_data *sdata, \
90 char *buf, int buflen) \
94 for (i = 0; i < sizeof(sdata->field); i++) { \
95 p += scnprintf(p, buflen + buf - p, "%.2x ", \
98 p += scnprintf(p, buflen + buf - p, "\n"); \
102 #define IEEE80211_IF_FMT_ATOMIC(name, field) \
103 static ssize_t ieee80211_if_fmt_##name( \
104 const struct ieee80211_sub_if_data *sdata, \
105 char *buf, int buflen) \
107 return scnprintf(buf, buflen, "%d\n", atomic_read(&sdata->field));\
110 #define IEEE80211_IF_FMT_MAC(name, field) \
111 static ssize_t ieee80211_if_fmt_##name( \
112 const struct ieee80211_sub_if_data *sdata, char *buf, \
115 return scnprintf(buf, buflen, "%pM\n", sdata->field); \
118 #define IEEE80211_IF_FMT_DEC_DIV_16(name, field) \
119 static ssize_t ieee80211_if_fmt_##name( \
120 const struct ieee80211_sub_if_data *sdata, \
121 char *buf, int buflen) \
123 return scnprintf(buf, buflen, "%d\n", sdata->field / 16); \
126 #define __IEEE80211_IF_FILE(name, _write) \
127 static ssize_t ieee80211_if_read_##name(struct file *file, \
128 char __user *userbuf, \
129 size_t count, loff_t *ppos) \
131 return ieee80211_if_read(file->private_data, \
132 userbuf, count, ppos, \
133 ieee80211_if_fmt_##name); \
135 static const struct file_operations name##_ops = { \
136 .read = ieee80211_if_read_##name, \
138 .open = simple_open, \
139 .llseek = generic_file_llseek, \
142 #define __IEEE80211_IF_FILE_W(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); \
150 __IEEE80211_IF_FILE(name, ieee80211_if_write_##name)
153 #define IEEE80211_IF_FILE(name, field, format) \
154 IEEE80211_IF_FMT_##format(name, field) \
155 __IEEE80211_IF_FILE(name, NULL)
218 return snprintf(buf, buflen,
"request: %s\nused: %s\n",
219 smps_modes[sdata->
u.
mgd.req_smps],
220 smps_modes[sdata->
u.
mgd.ap_smps]);
224 const char *buf,
int buflen)
229 if (
strncmp(buf, smps_modes[mode], buflen) == 0) {
230 int err = ieee80211_set_smps(sdata, mode);
242 static ssize_t ieee80211_if_fmt_tkip_mic_test(
248 static int hwaddr_aton(
const char *txt,
u8 *
addr)
261 *addr++ = (a << 4) | b;
262 if (i < 5 && *txt++ !=
':')
269 static ssize_t ieee80211_if_parse_tkip_mic_test(
282 if (buflen < 3 * ETH_ALEN - 1)
284 if (hwaddr_aton(buf, addr) < 0)
287 if (!ieee80211_sdata_running(sdata))
290 skb = dev_alloc_skb(local->
hw.extra_tx_headroom + 24 + 100);
293 skb_reserve(skb, local->
hw.extra_tx_headroom);
299 switch (sdata->
vif.type) {
310 if (sdata->
vif.bss_conf.bssid ==
NULL) {
333 ieee80211_tx_skb(sdata, skb);
340 static ssize_t ieee80211_if_fmt_uapsd_queues(
348 static ssize_t ieee80211_if_parse_uapsd_queues(
368 static ssize_t ieee80211_if_fmt_uapsd_max_sp_len(
376 static ssize_t ieee80211_if_parse_uapsd_max_sp_len(
383 ret = kstrtoul(buf, 0, &val);
401 static ssize_t ieee80211_if_fmt_num_buffered_multicast(
405 skb_queue_len(&sdata->
u.
ap.ps_bc_buf));
410 static ssize_t ieee80211_if_fmt_tsf(
418 return scnprintf(buf, buflen,
"0x%016llx\n", (
unsigned long long) tsf);
421 static ssize_t ieee80211_if_parse_tsf(
425 unsigned long long tsf;
427 int tsf_is_delta = 0;
429 if (
strncmp(buf,
"reset", 5) == 0) {
430 if (local->
ops->reset_tsf) {
431 drv_reset_tsf(local, sdata);
435 if (buflen > 10 && buf[1] ==
'=') {
438 else if (buf[0] ==
'-')
448 tsf = drv_get_tsf(local, sdata) + tsf_is_delta *
tsf;
449 if (local->
ops->set_tsf) {
450 drv_set_tsf(local, sdata, tsf);
452 "debugfs set TSF to %#018llx\n", tsf);
464 #ifdef CONFIG_MAC80211_MESH
471 u.mesh.mshstats.dropped_frames_congestion,
DEC);
473 u.mesh.mshstats.dropped_frames_no_route,
DEC);
478 u.mesh.mshcfg.dot11MeshMaxRetries,
DEC);
480 u.mesh.mshcfg.dot11MeshRetryTimeout,
DEC);
482 u.mesh.mshcfg.dot11MeshConfirmTimeout,
DEC);
484 u.mesh.mshcfg.dot11MeshHoldingTimeout,
DEC);
489 u.mesh.mshcfg.dot11MeshMaxPeerLinks,
DEC);
491 u.mesh.mshcfg.dot11MeshHWMPactivePathTimeout,
DEC);
493 u.mesh.mshcfg.dot11MeshHWMPpreqMinInterval,
DEC);
495 u.mesh.mshcfg.dot11MeshHWMPperrMinInterval,
DEC);
497 u.mesh.mshcfg.dot11MeshHWMPnetDiameterTraversalTime,
DEC);
499 u.mesh.mshcfg.dot11MeshHWMPmaxPREQretries,
DEC);
501 u.mesh.mshcfg.path_refresh_time,
DEC);
503 u.mesh.mshcfg.min_discovery_timeout,
DEC);
505 u.mesh.mshcfg.dot11MeshHWMPRootMode,
DEC);
507 u.mesh.mshcfg.dot11MeshGateAnnouncementProtocol,
DEC);
509 u.mesh.mshcfg.dot11MeshHWMPRannInterval,
DEC);
514 u.mesh.mshcfg.dot11MeshHWMPactivePathToRootTimeout,
DEC);
516 u.mesh.mshcfg.dot11MeshHWMProotInterval,
DEC);
518 u.mesh.mshcfg.dot11MeshHWMPconfirmationInterval,
DEC);
521 #define DEBUGFS_ADD_MODE(name, mode) \
522 debugfs_create_file(#name, mode, sdata->debugfs.dir, \
525 #define DEBUGFS_ADD(name) DEBUGFS_ADD_MODE(name, 0400)
567 #ifdef CONFIG_MAC80211_MESH
578 #define MESHSTATS_ADD(name)\
579 debugfs_create_file(#name, 0400, dir, sdata, &name##_ops);
581 MESHSTATS_ADD(fwded_mcast);
582 MESHSTATS_ADD(fwded_unicast);
583 MESHSTATS_ADD(fwded_frames);
584 MESHSTATS_ADD(dropped_frames_ttl);
585 MESHSTATS_ADD(dropped_frames_no_route);
586 MESHSTATS_ADD(dropped_frames_congestion);
587 MESHSTATS_ADD(estab_plinks);
596 #define MESHPARAMS_ADD(name) \
597 debugfs_create_file(#name, 0600, dir, sdata, &name##_ops);
603 MESHPARAMS_ADD(dot11MeshTTL);
604 MESHPARAMS_ADD(element_ttl);
605 MESHPARAMS_ADD(auto_open_plinks);
607 MESHPARAMS_ADD(dot11MeshHWMPactivePathTimeout);
608 MESHPARAMS_ADD(dot11MeshHWMPpreqMinInterval);
609 MESHPARAMS_ADD(dot11MeshHWMPperrMinInterval);
610 MESHPARAMS_ADD(dot11MeshHWMPnetDiameterTraversalTime);
611 MESHPARAMS_ADD(dot11MeshHWMPmaxPREQretries);
612 MESHPARAMS_ADD(path_refresh_time);
613 MESHPARAMS_ADD(min_discovery_timeout);
614 MESHPARAMS_ADD(dot11MeshHWMPRootMode);
615 MESHPARAMS_ADD(dot11MeshHWMPRannInterval);
616 MESHPARAMS_ADD(dot11MeshForwarding);
617 MESHPARAMS_ADD(dot11MeshGateAnnouncementProtocol);
618 MESHPARAMS_ADD(rssi_threshold);
619 MESHPARAMS_ADD(ht_opmode);
620 MESHPARAMS_ADD(dot11MeshHWMPactivePathToRootTimeout);
621 MESHPARAMS_ADD(dot11MeshHWMProotInterval);
622 MESHPARAMS_ADD(dot11MeshHWMPconfirmationInterval);
623 #undef MESHPARAMS_ADD
629 if (!sdata->debugfs.dir)
637 add_common_files(sdata);
639 switch (sdata->
vif.type) {
641 #ifdef CONFIG_MAC80211_MESH
642 add_mesh_files(sdata);
643 add_mesh_stats(sdata);
644 add_mesh_config(sdata);
648 add_sta_files(sdata);
651 add_ibss_files(sdata);
657 add_wds_files(sdata);
670 sdata->
local->hw.wiphy->debugfsdir);
671 if (sdata->debugfs.dir)
679 if (!sdata->debugfs.dir)
683 sdata->debugfs.dir =
NULL;
691 dir = sdata->debugfs.dir;
699 "debugfs: failed to rename debugfs dir to %s\n",