Thomas Gleixner | d2912cb | 2019-06-04 10:11:33 +0200 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0-only |
Jiri Benc | e9f207f | 2007-05-05 11:46:38 -0700 | [diff] [blame] | 2 | /* |
| 3 | * Copyright (c) 2006 Jiri Benc <jbenc@suse.cz> |
| 4 | * Copyright 2007 Johannes Berg <johannes@sipsolutions.net> |
Ilan Peer | 52b4810 | 2020-01-31 13:12:56 +0200 | [diff] [blame] | 5 | * Copyright (C) 2020 Intel Corporation |
Jiri Benc | e9f207f | 2007-05-05 11:46:38 -0700 | [diff] [blame] | 6 | */ |
| 7 | |
| 8 | #include <linux/kernel.h> |
| 9 | #include <linux/device.h> |
| 10 | #include <linux/if.h> |
Johannes Berg | 28656a1 | 2012-11-05 20:24:38 +0100 | [diff] [blame] | 11 | #include <linux/if_ether.h> |
Jiri Benc | e9f207f | 2007-05-05 11:46:38 -0700 | [diff] [blame] | 12 | #include <linux/interrupt.h> |
| 13 | #include <linux/netdevice.h> |
| 14 | #include <linux/rtnetlink.h> |
Tejun Heo | 5a0e3ad | 2010-03-24 17:04:11 +0900 | [diff] [blame] | 15 | #include <linux/slab.h> |
Jiri Benc | e9f207f | 2007-05-05 11:46:38 -0700 | [diff] [blame] | 16 | #include <linux/notifier.h> |
| 17 | #include <net/mac80211.h> |
| 18 | #include <net/cfg80211.h> |
| 19 | #include "ieee80211_i.h" |
Johannes Berg | 2c8dccc | 2008-04-08 15:14:40 -0400 | [diff] [blame] | 20 | #include "rate.h" |
Jiri Benc | e9f207f | 2007-05-05 11:46:38 -0700 | [diff] [blame] | 21 | #include "debugfs.h" |
| 22 | #include "debugfs_netdev.h" |
Eliad Peller | 37a41b4 | 2011-09-21 14:06:11 +0300 | [diff] [blame] | 23 | #include "driver-ops.h" |
Jiri Benc | e9f207f | 2007-05-05 11:46:38 -0700 | [diff] [blame] | 24 | |
| 25 | static ssize_t ieee80211_if_read( |
| 26 | struct ieee80211_sub_if_data *sdata, |
| 27 | char __user *userbuf, |
| 28 | size_t count, loff_t *ppos, |
| 29 | ssize_t (*format)(const struct ieee80211_sub_if_data *, char *, int)) |
| 30 | { |
Toke Høiland-Jørgensen | 8d51dbb | 2016-09-12 15:55:43 +0200 | [diff] [blame] | 31 | char buf[200]; |
Jiri Benc | e9f207f | 2007-05-05 11:46:38 -0700 | [diff] [blame] | 32 | ssize_t ret = -EINVAL; |
| 33 | |
| 34 | read_lock(&dev_base_lock); |
Arik Nemtsov | 923eaf3 | 2014-05-26 14:40:51 +0300 | [diff] [blame] | 35 | ret = (*format)(sdata, buf, sizeof(buf)); |
Jiri Benc | e9f207f | 2007-05-05 11:46:38 -0700 | [diff] [blame] | 36 | read_unlock(&dev_base_lock); |
Luis Carlos Cobo | 73bb3e4 | 2008-03-31 15:10:22 -0700 | [diff] [blame] | 37 | |
Jouni Malinen | 681d119 | 2011-02-03 18:35:19 +0200 | [diff] [blame] | 38 | if (ret >= 0) |
Luis Carlos Cobo | 73bb3e4 | 2008-03-31 15:10:22 -0700 | [diff] [blame] | 39 | ret = simple_read_from_buffer(userbuf, count, ppos, buf, ret); |
| 40 | |
Jiri Benc | e9f207f | 2007-05-05 11:46:38 -0700 | [diff] [blame] | 41 | return ret; |
| 42 | } |
| 43 | |
Johannes Berg | 0f78231 | 2009-12-01 13:37:02 +0100 | [diff] [blame] | 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)) |
| 49 | { |
Eliad Peller | ada577c | 2012-03-14 16:15:02 +0200 | [diff] [blame] | 50 | char buf[64]; |
Eric Dumazet | 51f5f8c | 2010-03-10 17:13:36 +0100 | [diff] [blame] | 51 | ssize_t ret; |
Johannes Berg | 0f78231 | 2009-12-01 13:37:02 +0100 | [diff] [blame] | 52 | |
Eliad Peller | ada577c | 2012-03-14 16:15:02 +0200 | [diff] [blame] | 53 | if (count >= sizeof(buf)) |
| 54 | return -E2BIG; |
Johannes Berg | 0f78231 | 2009-12-01 13:37:02 +0100 | [diff] [blame] | 55 | |
| 56 | if (copy_from_user(buf, userbuf, count)) |
Eliad Peller | ada577c | 2012-03-14 16:15:02 +0200 | [diff] [blame] | 57 | return -EFAULT; |
| 58 | buf[count] = '\0'; |
Johannes Berg | 0f78231 | 2009-12-01 13:37:02 +0100 | [diff] [blame] | 59 | |
| 60 | rtnl_lock(); |
Arik Nemtsov | 923eaf3 | 2014-05-26 14:40:51 +0300 | [diff] [blame] | 61 | ret = (*write)(sdata, buf, count); |
Johannes Berg | 0f78231 | 2009-12-01 13:37:02 +0100 | [diff] [blame] | 62 | rtnl_unlock(); |
| 63 | |
| 64 | return ret; |
| 65 | } |
| 66 | |
Jiri Benc | e9f207f | 2007-05-05 11:46:38 -0700 | [diff] [blame] | 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, \ |
| 70 | int buflen) \ |
| 71 | { \ |
| 72 | return scnprintf(buf, buflen, format_string, sdata->field); \ |
| 73 | } |
| 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") |
Ben Greear | 4914b3b | 2011-01-27 22:09:34 -0800 | [diff] [blame] | 78 | #define IEEE80211_IF_FMT_LHEX(name, field) \ |
| 79 | IEEE80211_IF_FMT(name, field, "%#lx\n") |
Jiri Benc | e9f207f | 2007-05-05 11:46:38 -0700 | [diff] [blame] | 80 | #define IEEE80211_IF_FMT_SIZE(name, field) \ |
| 81 | IEEE80211_IF_FMT(name, field, "%zd\n") |
| 82 | |
Simon Wunderlich | 1946841 | 2012-01-28 17:25:33 +0100 | [diff] [blame] | 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) \ |
| 87 | { \ |
| 88 | char *p = buf; \ |
| 89 | int i; \ |
| 90 | for (i = 0; i < sizeof(sdata->field); i++) { \ |
| 91 | p += scnprintf(p, buflen + buf - p, "%.2x ", \ |
| 92 | sdata->field[i]); \ |
| 93 | } \ |
| 94 | p += scnprintf(p, buflen + buf - p, "\n"); \ |
| 95 | return p - buf; \ |
| 96 | } |
| 97 | |
Jiri Benc | e9f207f | 2007-05-05 11:46:38 -0700 | [diff] [blame] | 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) \ |
| 102 | { \ |
| 103 | return scnprintf(buf, buflen, "%d\n", atomic_read(&sdata->field));\ |
| 104 | } |
| 105 | |
| 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, \ |
| 109 | int buflen) \ |
| 110 | { \ |
Johannes Berg | 0c68ae26 | 2008-10-27 15:56:10 -0700 | [diff] [blame] | 111 | return scnprintf(buf, buflen, "%pM\n", sdata->field); \ |
Jiri Benc | e9f207f | 2007-05-05 11:46:38 -0700 | [diff] [blame] | 112 | } |
| 113 | |
Ben Greear | 78e443e | 2013-03-25 11:19:34 -0700 | [diff] [blame] | 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) \ |
| 118 | { \ |
| 119 | return scnprintf(buf, buflen, "%d\n", \ |
| 120 | jiffies_to_msecs(sdata->field)); \ |
| 121 | } |
| 122 | |
Johannes Berg | 4cd3c4e | 2014-01-06 15:47:15 +0100 | [diff] [blame] | 123 | #define _IEEE80211_IF_FILE_OPS(name, _read, _write) \ |
| 124 | static const struct file_operations name##_ops = { \ |
| 125 | .read = (_read), \ |
| 126 | .write = (_write), \ |
| 127 | .open = simple_open, \ |
| 128 | .llseek = generic_file_llseek, \ |
| 129 | } |
| 130 | |
| 131 | #define _IEEE80211_IF_FILE_R_FN(name) \ |
Jiri Benc | e9f207f | 2007-05-05 11:46:38 -0700 | [diff] [blame] | 132 | static ssize_t ieee80211_if_read_##name(struct file *file, \ |
| 133 | char __user *userbuf, \ |
| 134 | size_t count, loff_t *ppos) \ |
| 135 | { \ |
| 136 | return ieee80211_if_read(file->private_data, \ |
| 137 | userbuf, count, ppos, \ |
| 138 | ieee80211_if_fmt_##name); \ |
Jiri Benc | e9f207f | 2007-05-05 11:46:38 -0700 | [diff] [blame] | 139 | } |
| 140 | |
Johannes Berg | 4cd3c4e | 2014-01-06 15:47:15 +0100 | [diff] [blame] | 141 | #define _IEEE80211_IF_FILE_W_FN(name) \ |
Johannes Berg | 0f78231 | 2009-12-01 13:37:02 +0100 | [diff] [blame] | 142 | static ssize_t ieee80211_if_write_##name(struct file *file, \ |
| 143 | const char __user *userbuf, \ |
| 144 | size_t count, loff_t *ppos) \ |
| 145 | { \ |
| 146 | return ieee80211_if_write(file->private_data, userbuf, count, \ |
| 147 | ppos, ieee80211_if_parse_##name); \ |
Johannes Berg | 4cd3c4e | 2014-01-06 15:47:15 +0100 | [diff] [blame] | 148 | } |
Johannes Berg | 0f78231 | 2009-12-01 13:37:02 +0100 | [diff] [blame] | 149 | |
Johannes Berg | 4cd3c4e | 2014-01-06 15:47:15 +0100 | [diff] [blame] | 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) |
| 153 | |
| 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) |
| 157 | |
| 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) |
Johannes Berg | 0f78231 | 2009-12-01 13:37:02 +0100 | [diff] [blame] | 163 | |
Jiri Benc | e9f207f | 2007-05-05 11:46:38 -0700 | [diff] [blame] | 164 | #define IEEE80211_IF_FILE(name, field, format) \ |
Johannes Berg | 4cd3c4e | 2014-01-06 15:47:15 +0100 | [diff] [blame] | 165 | IEEE80211_IF_FMT_##format(name, field) \ |
| 166 | IEEE80211_IF_FILE_R(name) |
Jiri Benc | e9f207f | 2007-05-05 11:46:38 -0700 | [diff] [blame] | 167 | |
| 168 | /* common attributes */ |
Johannes Berg | 57fbcce | 2016-04-12 15:56:15 +0200 | [diff] [blame] | 169 | IEEE80211_IF_FILE(rc_rateidx_mask_2ghz, rc_rateidx_mask[NL80211_BAND_2GHZ], |
Jouni Malinen | 37eb0b1 | 2010-01-06 13:09:08 +0200 | [diff] [blame] | 170 | HEX); |
Johannes Berg | 57fbcce | 2016-04-12 15:56:15 +0200 | [diff] [blame] | 171 | IEEE80211_IF_FILE(rc_rateidx_mask_5ghz, rc_rateidx_mask[NL80211_BAND_5GHZ], |
Jouni Malinen | 37eb0b1 | 2010-01-06 13:09:08 +0200 | [diff] [blame] | 172 | HEX); |
Simon Wunderlich | 1946841 | 2012-01-28 17:25:33 +0100 | [diff] [blame] | 173 | IEEE80211_IF_FILE(rc_rateidx_mcs_mask_2ghz, |
Johannes Berg | 57fbcce | 2016-04-12 15:56:15 +0200 | [diff] [blame] | 174 | rc_rateidx_mcs_mask[NL80211_BAND_2GHZ], HEXARRAY); |
Simon Wunderlich | 1946841 | 2012-01-28 17:25:33 +0100 | [diff] [blame] | 175 | IEEE80211_IF_FILE(rc_rateidx_mcs_mask_5ghz, |
Johannes Berg | 57fbcce | 2016-04-12 15:56:15 +0200 | [diff] [blame] | 176 | rc_rateidx_mcs_mask[NL80211_BAND_5GHZ], HEXARRAY); |
Simon Wunderlich | 1946841 | 2012-01-28 17:25:33 +0100 | [diff] [blame] | 177 | |
Lorenzo Bianconi | b119ad6 | 2015-08-06 23:47:33 +0200 | [diff] [blame] | 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) |
| 181 | { |
| 182 | int i, len = 0; |
Johannes Berg | 57fbcce | 2016-04-12 15:56:15 +0200 | [diff] [blame] | 183 | const u16 *mask = sdata->rc_rateidx_vht_mcs_mask[NL80211_BAND_2GHZ]; |
Lorenzo Bianconi | b119ad6 | 2015-08-06 23:47:33 +0200 | [diff] [blame] | 184 | |
| 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"); |
| 188 | |
| 189 | return len; |
| 190 | } |
| 191 | |
| 192 | IEEE80211_IF_FILE_R(rc_rateidx_vht_mcs_mask_2ghz); |
| 193 | |
| 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) |
| 197 | { |
| 198 | int i, len = 0; |
Johannes Berg | 57fbcce | 2016-04-12 15:56:15 +0200 | [diff] [blame] | 199 | const u16 *mask = sdata->rc_rateidx_vht_mcs_mask[NL80211_BAND_5GHZ]; |
Lorenzo Bianconi | b119ad6 | 2015-08-06 23:47:33 +0200 | [diff] [blame] | 200 | |
| 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"); |
| 204 | |
| 205 | return len; |
| 206 | } |
| 207 | |
| 208 | IEEE80211_IF_FILE_R(rc_rateidx_vht_mcs_mask_5ghz); |
| 209 | |
Ben Greear | 4914b3b | 2011-01-27 22:09:34 -0800 | [diff] [blame] | 210 | IEEE80211_IF_FILE(flags, flags, HEX); |
| 211 | IEEE80211_IF_FILE(state, state, LHEX); |
Johannes Berg | 1ea6f9c | 2012-10-24 10:59:25 +0200 | [diff] [blame] | 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); |
Jiri Benc | e9f207f | 2007-05-05 11:46:38 -0700 | [diff] [blame] | 215 | |
Johannes Berg | 0864331 | 2012-11-08 15:29:28 +0100 | [diff] [blame] | 216 | static ssize_t |
| 217 | ieee80211_if_fmt_hw_queues(const struct ieee80211_sub_if_data *sdata, |
| 218 | char *buf, int buflen) |
| 219 | { |
| 220 | int len; |
| 221 | |
| 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]); |
| 227 | |
| 228 | if (sdata->vif.type == NL80211_IFTYPE_AP) |
| 229 | len += scnprintf(buf + len, buflen - len, "cab queue: %d\n", |
| 230 | sdata->vif.cab_queue); |
| 231 | |
| 232 | return len; |
| 233 | } |
Johannes Berg | 4cd3c4e | 2014-01-06 15:47:15 +0100 | [diff] [blame] | 234 | IEEE80211_IF_FILE_R(hw_queues); |
Johannes Berg | 0864331 | 2012-11-08 15:29:28 +0100 | [diff] [blame] | 235 | |
Johannes Berg | 4690029 | 2009-02-15 12:44:28 +0100 | [diff] [blame] | 236 | /* STA attributes */ |
Johannes Berg | 4690029 | 2009-02-15 12:44:28 +0100 | [diff] [blame] | 237 | IEEE80211_IF_FILE(bssid, u.mgd.bssid, MAC); |
Johannes Berg | 1db364c | 2020-04-17 12:38:04 +0200 | [diff] [blame] | 238 | IEEE80211_IF_FILE(aid, vif.bss_conf.aid, DEC); |
Ben Greear | 78e443e | 2013-03-25 11:19:34 -0700 | [diff] [blame] | 239 | IEEE80211_IF_FILE(beacon_timeout, u.mgd.beacon_timeout, JIFFIES_TO_MS); |
Jiri Benc | e9f207f | 2007-05-05 11:46:38 -0700 | [diff] [blame] | 240 | |
Johannes Berg | 0f78231 | 2009-12-01 13:37:02 +0100 | [diff] [blame] | 241 | static int ieee80211_set_smps(struct ieee80211_sub_if_data *sdata, |
| 242 | enum ieee80211_smps_mode smps_mode) |
| 243 | { |
| 244 | struct ieee80211_local *local = sdata->local; |
| 245 | int err; |
| 246 | |
Eliad Peller | 0d8614b | 2014-09-10 14:07:36 +0300 | [diff] [blame] | 247 | if (!(local->hw.wiphy->features & NL80211_FEATURE_STATIC_SMPS) && |
Johannes Berg | 0f78231 | 2009-12-01 13:37:02 +0100 | [diff] [blame] | 248 | smps_mode == IEEE80211_SMPS_STATIC) |
| 249 | return -EINVAL; |
| 250 | |
| 251 | /* auto should be dynamic if in PS mode */ |
Eliad Peller | 0d8614b | 2014-09-10 14:07:36 +0300 | [diff] [blame] | 252 | if (!(local->hw.wiphy->features & NL80211_FEATURE_DYNAMIC_SMPS) && |
Johannes Berg | 0f78231 | 2009-12-01 13:37:02 +0100 | [diff] [blame] | 253 | (smps_mode == IEEE80211_SMPS_DYNAMIC || |
| 254 | smps_mode == IEEE80211_SMPS_AUTOMATIC)) |
| 255 | return -EINVAL; |
| 256 | |
Ilan Peer | 52b4810 | 2020-01-31 13:12:56 +0200 | [diff] [blame] | 257 | if (sdata->vif.type != NL80211_IFTYPE_STATION) |
Johannes Berg | 0f78231 | 2009-12-01 13:37:02 +0100 | [diff] [blame] | 258 | return -EOPNOTSUPP; |
| 259 | |
Johannes Berg | 8d61ffa | 2013-05-10 12:32:47 +0200 | [diff] [blame] | 260 | sdata_lock(sdata); |
Ilan Peer | 52b4810 | 2020-01-31 13:12:56 +0200 | [diff] [blame] | 261 | err = __ieee80211_request_smps_mgd(sdata, smps_mode); |
Johannes Berg | 8d61ffa | 2013-05-10 12:32:47 +0200 | [diff] [blame] | 262 | sdata_unlock(sdata); |
Johannes Berg | 0f78231 | 2009-12-01 13:37:02 +0100 | [diff] [blame] | 263 | |
| 264 | return err; |
| 265 | } |
| 266 | |
| 267 | static const char *smps_modes[IEEE80211_SMPS_NUM_MODES] = { |
| 268 | [IEEE80211_SMPS_AUTOMATIC] = "auto", |
| 269 | [IEEE80211_SMPS_OFF] = "off", |
| 270 | [IEEE80211_SMPS_STATIC] = "static", |
| 271 | [IEEE80211_SMPS_DYNAMIC] = "dynamic", |
| 272 | }; |
| 273 | |
| 274 | static ssize_t ieee80211_if_fmt_smps(const struct ieee80211_sub_if_data *sdata, |
| 275 | char *buf, int buflen) |
| 276 | { |
Emmanuel Grumbach | 687da13 | 2013-10-01 16:45:43 +0300 | [diff] [blame] | 277 | if (sdata->vif.type == NL80211_IFTYPE_STATION) |
| 278 | return snprintf(buf, buflen, "request: %s\nused: %s\n", |
| 279 | smps_modes[sdata->u.mgd.req_smps], |
| 280 | smps_modes[sdata->smps_mode]); |
Emmanuel Grumbach | 687da13 | 2013-10-01 16:45:43 +0300 | [diff] [blame] | 281 | return -EINVAL; |
Johannes Berg | 0f78231 | 2009-12-01 13:37:02 +0100 | [diff] [blame] | 282 | } |
| 283 | |
| 284 | static ssize_t ieee80211_if_parse_smps(struct ieee80211_sub_if_data *sdata, |
| 285 | const char *buf, int buflen) |
| 286 | { |
| 287 | enum ieee80211_smps_mode mode; |
| 288 | |
| 289 | for (mode = 0; mode < IEEE80211_SMPS_NUM_MODES; mode++) { |
| 290 | if (strncmp(buf, smps_modes[mode], buflen) == 0) { |
| 291 | int err = ieee80211_set_smps(sdata, mode); |
| 292 | if (!err) |
| 293 | return buflen; |
| 294 | return err; |
| 295 | } |
| 296 | } |
| 297 | |
| 298 | return -EINVAL; |
| 299 | } |
Johannes Berg | 4cd3c4e | 2014-01-06 15:47:15 +0100 | [diff] [blame] | 300 | IEEE80211_IF_FILE_RW(smps); |
Jouni Malinen | 681d119 | 2011-02-03 18:35:19 +0200 | [diff] [blame] | 301 | |
Jouni Malinen | 681d119 | 2011-02-03 18:35:19 +0200 | [diff] [blame] | 302 | static ssize_t ieee80211_if_parse_tkip_mic_test( |
| 303 | struct ieee80211_sub_if_data *sdata, const char *buf, int buflen) |
| 304 | { |
| 305 | struct ieee80211_local *local = sdata->local; |
| 306 | u8 addr[ETH_ALEN]; |
| 307 | struct sk_buff *skb; |
| 308 | struct ieee80211_hdr *hdr; |
| 309 | __le16 fc; |
| 310 | |
Johannes Berg | 28656a1 | 2012-11-05 20:24:38 +0100 | [diff] [blame] | 311 | if (!mac_pton(buf, addr)) |
Jouni Malinen | 681d119 | 2011-02-03 18:35:19 +0200 | [diff] [blame] | 312 | return -EINVAL; |
| 313 | |
| 314 | if (!ieee80211_sdata_running(sdata)) |
| 315 | return -ENOTCONN; |
| 316 | |
| 317 | skb = dev_alloc_skb(local->hw.extra_tx_headroom + 24 + 100); |
| 318 | if (!skb) |
| 319 | return -ENOMEM; |
| 320 | skb_reserve(skb, local->hw.extra_tx_headroom); |
| 321 | |
Johannes Berg | b080db5 | 2017-06-16 14:29:19 +0200 | [diff] [blame] | 322 | hdr = skb_put_zero(skb, 24); |
Jouni Malinen | 681d119 | 2011-02-03 18:35:19 +0200 | [diff] [blame] | 323 | fc = cpu_to_le16(IEEE80211_FTYPE_DATA | IEEE80211_STYPE_DATA); |
| 324 | |
| 325 | switch (sdata->vif.type) { |
| 326 | case NL80211_IFTYPE_AP: |
| 327 | fc |= cpu_to_le16(IEEE80211_FCTL_FROMDS); |
| 328 | /* DA BSSID SA */ |
| 329 | memcpy(hdr->addr1, addr, ETH_ALEN); |
| 330 | memcpy(hdr->addr2, sdata->vif.addr, ETH_ALEN); |
| 331 | memcpy(hdr->addr3, sdata->vif.addr, ETH_ALEN); |
| 332 | break; |
| 333 | case NL80211_IFTYPE_STATION: |
| 334 | fc |= cpu_to_le16(IEEE80211_FCTL_TODS); |
| 335 | /* BSSID SA DA */ |
Johannes Berg | 8d61ffa | 2013-05-10 12:32:47 +0200 | [diff] [blame] | 336 | sdata_lock(sdata); |
Johannes Berg | 41c97a2 | 2012-11-05 20:27:57 +0100 | [diff] [blame] | 337 | if (!sdata->u.mgd.associated) { |
Johannes Berg | 8d61ffa | 2013-05-10 12:32:47 +0200 | [diff] [blame] | 338 | sdata_unlock(sdata); |
Jouni Malinen | 681d119 | 2011-02-03 18:35:19 +0200 | [diff] [blame] | 339 | dev_kfree_skb(skb); |
| 340 | return -ENOTCONN; |
| 341 | } |
Johannes Berg | 41c97a2 | 2012-11-05 20:27:57 +0100 | [diff] [blame] | 342 | memcpy(hdr->addr1, sdata->u.mgd.associated->bssid, ETH_ALEN); |
Jouni Malinen | 681d119 | 2011-02-03 18:35:19 +0200 | [diff] [blame] | 343 | memcpy(hdr->addr2, sdata->vif.addr, ETH_ALEN); |
| 344 | memcpy(hdr->addr3, addr, ETH_ALEN); |
Johannes Berg | 8d61ffa | 2013-05-10 12:32:47 +0200 | [diff] [blame] | 345 | sdata_unlock(sdata); |
Jouni Malinen | 681d119 | 2011-02-03 18:35:19 +0200 | [diff] [blame] | 346 | break; |
| 347 | default: |
| 348 | dev_kfree_skb(skb); |
| 349 | return -EOPNOTSUPP; |
| 350 | } |
| 351 | hdr->frame_control = fc; |
| 352 | |
| 353 | /* |
| 354 | * Add some length to the test frame to make it look bit more valid. |
| 355 | * The exact contents does not matter since the recipient is required |
| 356 | * to drop this because of the Michael MIC failure. |
| 357 | */ |
Johannes Berg | b080db5 | 2017-06-16 14:29:19 +0200 | [diff] [blame] | 358 | skb_put_zero(skb, 50); |
Jouni Malinen | 681d119 | 2011-02-03 18:35:19 +0200 | [diff] [blame] | 359 | |
| 360 | IEEE80211_SKB_CB(skb)->flags |= IEEE80211_TX_INTFL_TKIP_MIC_FAILURE; |
| 361 | |
| 362 | ieee80211_tx_skb(sdata, skb); |
| 363 | |
| 364 | return buflen; |
| 365 | } |
Johannes Berg | 4cd3c4e | 2014-01-06 15:47:15 +0100 | [diff] [blame] | 366 | IEEE80211_IF_FILE_W(tkip_mic_test); |
Jouni Malinen | 681d119 | 2011-02-03 18:35:19 +0200 | [diff] [blame] | 367 | |
Eliad Peller | 802ee9e | 2014-02-11 12:36:18 +0200 | [diff] [blame] | 368 | static ssize_t ieee80211_if_parse_beacon_loss( |
| 369 | struct ieee80211_sub_if_data *sdata, const char *buf, int buflen) |
| 370 | { |
| 371 | if (!ieee80211_sdata_running(sdata) || !sdata->vif.bss_conf.assoc) |
| 372 | return -ENOTCONN; |
| 373 | |
| 374 | ieee80211_beacon_loss(&sdata->vif); |
| 375 | |
| 376 | return buflen; |
| 377 | } |
| 378 | IEEE80211_IF_FILE_W(beacon_loss); |
| 379 | |
Eliad Peller | dc41e4d | 2012-03-14 16:15:03 +0200 | [diff] [blame] | 380 | static ssize_t ieee80211_if_fmt_uapsd_queues( |
| 381 | const struct ieee80211_sub_if_data *sdata, char *buf, int buflen) |
| 382 | { |
| 383 | const struct ieee80211_if_managed *ifmgd = &sdata->u.mgd; |
| 384 | |
| 385 | return snprintf(buf, buflen, "0x%x\n", ifmgd->uapsd_queues); |
| 386 | } |
| 387 | |
| 388 | static ssize_t ieee80211_if_parse_uapsd_queues( |
| 389 | struct ieee80211_sub_if_data *sdata, const char *buf, int buflen) |
| 390 | { |
| 391 | struct ieee80211_if_managed *ifmgd = &sdata->u.mgd; |
| 392 | u8 val; |
| 393 | int ret; |
| 394 | |
| 395 | ret = kstrtou8(buf, 0, &val); |
| 396 | if (ret) |
| 397 | return ret; |
| 398 | |
| 399 | if (val & ~IEEE80211_WMM_IE_STA_QOSINFO_AC_MASK) |
| 400 | return -ERANGE; |
| 401 | |
| 402 | ifmgd->uapsd_queues = val; |
| 403 | |
| 404 | return buflen; |
| 405 | } |
Johannes Berg | 4cd3c4e | 2014-01-06 15:47:15 +0100 | [diff] [blame] | 406 | IEEE80211_IF_FILE_RW(uapsd_queues); |
Eliad Peller | dc41e4d | 2012-03-14 16:15:03 +0200 | [diff] [blame] | 407 | |
| 408 | static ssize_t ieee80211_if_fmt_uapsd_max_sp_len( |
| 409 | const struct ieee80211_sub_if_data *sdata, char *buf, int buflen) |
| 410 | { |
| 411 | const struct ieee80211_if_managed *ifmgd = &sdata->u.mgd; |
| 412 | |
| 413 | return snprintf(buf, buflen, "0x%x\n", ifmgd->uapsd_max_sp_len); |
| 414 | } |
| 415 | |
| 416 | static ssize_t ieee80211_if_parse_uapsd_max_sp_len( |
| 417 | struct ieee80211_sub_if_data *sdata, const char *buf, int buflen) |
| 418 | { |
| 419 | struct ieee80211_if_managed *ifmgd = &sdata->u.mgd; |
| 420 | unsigned long val; |
| 421 | int ret; |
| 422 | |
| 423 | ret = kstrtoul(buf, 0, &val); |
| 424 | if (ret) |
| 425 | return -EINVAL; |
| 426 | |
| 427 | if (val & ~IEEE80211_WMM_IE_STA_QOSINFO_SP_MASK) |
| 428 | return -ERANGE; |
| 429 | |
| 430 | ifmgd->uapsd_max_sp_len = val; |
| 431 | |
| 432 | return buflen; |
| 433 | } |
Johannes Berg | 4cd3c4e | 2014-01-06 15:47:15 +0100 | [diff] [blame] | 434 | IEEE80211_IF_FILE_RW(uapsd_max_sp_len); |
Eliad Peller | dc41e4d | 2012-03-14 16:15:03 +0200 | [diff] [blame] | 435 | |
Arik Nemtsov | 82c0cc90d | 2015-08-15 22:39:46 +0300 | [diff] [blame] | 436 | static ssize_t ieee80211_if_fmt_tdls_wider_bw( |
| 437 | const struct ieee80211_sub_if_data *sdata, char *buf, int buflen) |
| 438 | { |
| 439 | const struct ieee80211_if_managed *ifmgd = &sdata->u.mgd; |
| 440 | bool tdls_wider_bw; |
| 441 | |
| 442 | tdls_wider_bw = ieee80211_hw_check(&sdata->local->hw, TDLS_WIDER_BW) && |
| 443 | !ifmgd->tdls_wider_bw_prohibited; |
| 444 | |
| 445 | return snprintf(buf, buflen, "%d\n", tdls_wider_bw); |
| 446 | } |
| 447 | |
| 448 | static ssize_t ieee80211_if_parse_tdls_wider_bw( |
| 449 | struct ieee80211_sub_if_data *sdata, const char *buf, int buflen) |
| 450 | { |
| 451 | struct ieee80211_if_managed *ifmgd = &sdata->u.mgd; |
| 452 | u8 val; |
| 453 | int ret; |
| 454 | |
| 455 | ret = kstrtou8(buf, 0, &val); |
| 456 | if (ret) |
| 457 | return ret; |
| 458 | |
| 459 | ifmgd->tdls_wider_bw_prohibited = !val; |
| 460 | return buflen; |
| 461 | } |
| 462 | IEEE80211_IF_FILE_RW(tdls_wider_bw); |
| 463 | |
Jiri Benc | e9f207f | 2007-05-05 11:46:38 -0700 | [diff] [blame] | 464 | /* AP attributes */ |
Felix Fietkau | 030ef8f | 2012-04-23 19:49:02 +0200 | [diff] [blame] | 465 | IEEE80211_IF_FILE(num_mcast_sta, u.ap.num_mcast_sta, ATOMIC); |
Marco Porsch | d012a60 | 2012-10-10 12:39:50 -0700 | [diff] [blame] | 466 | IEEE80211_IF_FILE(num_sta_ps, u.ap.ps.num_sta_ps, ATOMIC); |
| 467 | IEEE80211_IF_FILE(dtim_count, u.ap.ps.dtim_count, DEC); |
Michael Braun | 72f15d5 | 2016-10-10 19:12:21 +0200 | [diff] [blame] | 468 | IEEE80211_IF_FILE(num_mcast_sta_vlan, u.vlan.num_mcast_sta, ATOMIC); |
Jiri Benc | e9f207f | 2007-05-05 11:46:38 -0700 | [diff] [blame] | 469 | |
| 470 | static ssize_t ieee80211_if_fmt_num_buffered_multicast( |
| 471 | const struct ieee80211_sub_if_data *sdata, char *buf, int buflen) |
| 472 | { |
| 473 | return scnprintf(buf, buflen, "%u\n", |
Marco Porsch | d012a60 | 2012-10-10 12:39:50 -0700 | [diff] [blame] | 474 | skb_queue_len(&sdata->u.ap.ps.bc_buf)); |
Jiri Benc | e9f207f | 2007-05-05 11:46:38 -0700 | [diff] [blame] | 475 | } |
Johannes Berg | 4cd3c4e | 2014-01-06 15:47:15 +0100 | [diff] [blame] | 476 | IEEE80211_IF_FILE_R(num_buffered_multicast); |
Jiri Benc | e9f207f | 2007-05-05 11:46:38 -0700 | [diff] [blame] | 477 | |
Toke Høiland-Jørgensen | 8d51dbb | 2016-09-12 15:55:43 +0200 | [diff] [blame] | 478 | static ssize_t ieee80211_if_fmt_aqm( |
| 479 | const struct ieee80211_sub_if_data *sdata, char *buf, int buflen) |
| 480 | { |
| 481 | struct ieee80211_local *local = sdata->local; |
Miaoqing Pan | 8ed31a2 | 2019-09-27 10:03:16 +0800 | [diff] [blame] | 482 | struct txq_info *txqi; |
Toke Høiland-Jørgensen | 8d51dbb | 2016-09-12 15:55:43 +0200 | [diff] [blame] | 483 | int len; |
| 484 | |
Miaoqing Pan | 8ed31a2 | 2019-09-27 10:03:16 +0800 | [diff] [blame] | 485 | if (!sdata->vif.txq) |
| 486 | return 0; |
| 487 | |
| 488 | txqi = to_txq_info(sdata->vif.txq); |
| 489 | |
Toke Høiland-Jørgensen | 8d51dbb | 2016-09-12 15:55:43 +0200 | [diff] [blame] | 490 | spin_lock_bh(&local->fq.lock); |
| 491 | rcu_read_lock(); |
| 492 | |
| 493 | len = scnprintf(buf, |
| 494 | buflen, |
| 495 | "ac backlog-bytes backlog-packets new-flows drops marks overlimit collisions tx-bytes tx-packets\n" |
| 496 | "%u %u %u %u %u %u %u %u %u %u\n", |
| 497 | txqi->txq.ac, |
| 498 | txqi->tin.backlog_bytes, |
| 499 | txqi->tin.backlog_packets, |
| 500 | txqi->tin.flows, |
| 501 | txqi->cstats.drop_count, |
| 502 | txqi->cstats.ecn_mark, |
| 503 | txqi->tin.overlimit, |
| 504 | txqi->tin.collisions, |
| 505 | txqi->tin.tx_bytes, |
| 506 | txqi->tin.tx_packets); |
| 507 | |
| 508 | rcu_read_unlock(); |
| 509 | spin_unlock_bh(&local->fq.lock); |
| 510 | |
| 511 | return len; |
| 512 | } |
| 513 | IEEE80211_IF_FILE_R(aqm); |
| 514 | |
Toke Høiland-Jørgensen | 2433647 | 2021-06-23 15:47:55 +0200 | [diff] [blame] | 515 | static ssize_t ieee80211_if_fmt_airtime( |
| 516 | const struct ieee80211_sub_if_data *sdata, char *buf, int buflen) |
| 517 | { |
| 518 | struct ieee80211_local *local = sdata->local; |
| 519 | struct ieee80211_txq *txq = sdata->vif.txq; |
| 520 | struct airtime_info *air_info; |
| 521 | int len; |
| 522 | |
| 523 | if (!txq) |
| 524 | return 0; |
| 525 | |
| 526 | spin_lock_bh(&local->airtime[txq->ac].lock); |
| 527 | air_info = to_airtime_info(txq); |
| 528 | len = scnprintf(buf, |
| 529 | buflen, |
| 530 | "RX: %llu us\nTX: %llu us\nWeight: %u\n" |
| 531 | "Virt-T: %lld us\n", |
| 532 | air_info->rx_airtime, |
| 533 | air_info->tx_airtime, |
| 534 | air_info->weight, |
| 535 | air_info->v_t); |
| 536 | spin_unlock_bh(&local->airtime[txq->ac].lock); |
| 537 | |
| 538 | return len; |
| 539 | } |
| 540 | |
| 541 | IEEE80211_IF_FILE_R(airtime); |
| 542 | |
Michael Braun | ebceec8 | 2016-11-22 11:52:18 +0100 | [diff] [blame] | 543 | IEEE80211_IF_FILE(multicast_to_unicast, u.ap.multicast_to_unicast, HEX); |
| 544 | |
Eliad Peller | 37a41b4 | 2011-09-21 14:06:11 +0300 | [diff] [blame] | 545 | /* IBSS attributes */ |
| 546 | static ssize_t ieee80211_if_fmt_tsf( |
| 547 | const struct ieee80211_sub_if_data *sdata, char *buf, int buflen) |
| 548 | { |
| 549 | struct ieee80211_local *local = sdata->local; |
| 550 | u64 tsf; |
| 551 | |
| 552 | tsf = drv_get_tsf(local, (struct ieee80211_sub_if_data *)sdata); |
| 553 | |
| 554 | return scnprintf(buf, buflen, "0x%016llx\n", (unsigned long long) tsf); |
| 555 | } |
| 556 | |
| 557 | static ssize_t ieee80211_if_parse_tsf( |
| 558 | struct ieee80211_sub_if_data *sdata, const char *buf, int buflen) |
| 559 | { |
| 560 | struct ieee80211_local *local = sdata->local; |
| 561 | unsigned long long tsf; |
| 562 | int ret; |
Javier Cardona | 9bdd3a6 | 2012-03-31 11:31:31 -0700 | [diff] [blame] | 563 | int tsf_is_delta = 0; |
Eliad Peller | 37a41b4 | 2011-09-21 14:06:11 +0300 | [diff] [blame] | 564 | |
| 565 | if (strncmp(buf, "reset", 5) == 0) { |
| 566 | if (local->ops->reset_tsf) { |
| 567 | drv_reset_tsf(local, sdata); |
| 568 | wiphy_info(local->hw.wiphy, "debugfs reset TSF\n"); |
| 569 | } |
| 570 | } else { |
Javier Cardona | 9bdd3a6 | 2012-03-31 11:31:31 -0700 | [diff] [blame] | 571 | if (buflen > 10 && buf[1] == '=') { |
| 572 | if (buf[0] == '+') |
| 573 | tsf_is_delta = 1; |
| 574 | else if (buf[0] == '-') |
| 575 | tsf_is_delta = -1; |
| 576 | else |
| 577 | return -EINVAL; |
| 578 | buf += 2; |
| 579 | } |
Eliad Peller | 37a41b4 | 2011-09-21 14:06:11 +0300 | [diff] [blame] | 580 | ret = kstrtoull(buf, 10, &tsf); |
| 581 | if (ret < 0) |
Johannes Berg | 6fc1da9 | 2012-11-05 20:30:39 +0100 | [diff] [blame] | 582 | return ret; |
Pedersen, Thomas | 354d381 | 2016-09-28 16:56:28 -0700 | [diff] [blame] | 583 | if (tsf_is_delta && local->ops->offset_tsf) { |
| 584 | drv_offset_tsf(local, sdata, tsf_is_delta * tsf); |
| 585 | wiphy_info(local->hw.wiphy, |
| 586 | "debugfs offset TSF by %018lld\n", |
| 587 | tsf_is_delta * tsf); |
| 588 | } else if (local->ops->set_tsf) { |
| 589 | if (tsf_is_delta) |
| 590 | tsf = drv_get_tsf(local, sdata) + |
| 591 | tsf_is_delta * tsf; |
Eliad Peller | 37a41b4 | 2011-09-21 14:06:11 +0300 | [diff] [blame] | 592 | drv_set_tsf(local, sdata, tsf); |
| 593 | wiphy_info(local->hw.wiphy, |
| 594 | "debugfs set TSF to %#018llx\n", tsf); |
| 595 | } |
| 596 | } |
| 597 | |
Thomas Pedersen | 057d5f4 | 2013-12-19 10:25:15 -0800 | [diff] [blame] | 598 | ieee80211_recalc_dtim(local, sdata); |
Eliad Peller | 37a41b4 | 2011-09-21 14:06:11 +0300 | [diff] [blame] | 599 | return buflen; |
| 600 | } |
Johannes Berg | 4cd3c4e | 2014-01-06 15:47:15 +0100 | [diff] [blame] | 601 | IEEE80211_IF_FILE_RW(tsf); |
Eliad Peller | 37a41b4 | 2011-09-21 14:06:11 +0300 | [diff] [blame] | 602 | |
| 603 | |
Luis Carlos Cobo | 9f42f60 | 2008-02-23 15:17:16 +0100 | [diff] [blame] | 604 | #ifdef CONFIG_MAC80211_MESH |
Ashok Nagarajan | d4a5a48 | 2013-05-13 17:08:04 -0700 | [diff] [blame] | 605 | IEEE80211_IF_FILE(estab_plinks, u.mesh.estab_plinks, ATOMIC); |
| 606 | |
Luis Carlos Cobo | 9f42f60 | 2008-02-23 15:17:16 +0100 | [diff] [blame] | 607 | /* Mesh stats attributes */ |
Daniel Walker | c8a61a7 | 2009-08-18 10:59:00 -0700 | [diff] [blame] | 608 | IEEE80211_IF_FILE(fwded_mcast, u.mesh.mshstats.fwded_mcast, DEC); |
| 609 | IEEE80211_IF_FILE(fwded_unicast, u.mesh.mshstats.fwded_unicast, DEC); |
Johannes Berg | 472dbc4 | 2008-09-11 00:01:49 +0200 | [diff] [blame] | 610 | IEEE80211_IF_FILE(fwded_frames, u.mesh.mshstats.fwded_frames, DEC); |
| 611 | IEEE80211_IF_FILE(dropped_frames_ttl, u.mesh.mshstats.dropped_frames_ttl, DEC); |
Javier Cardona | cfee66b | 2011-09-06 13:05:21 -0700 | [diff] [blame] | 612 | IEEE80211_IF_FILE(dropped_frames_congestion, |
Chun-Yeow Yeoh | a4f606e | 2012-06-11 11:59:36 +0800 | [diff] [blame] | 613 | u.mesh.mshstats.dropped_frames_congestion, DEC); |
Luis Carlos Cobo | 9f42f60 | 2008-02-23 15:17:16 +0100 | [diff] [blame] | 614 | IEEE80211_IF_FILE(dropped_frames_no_route, |
Chun-Yeow Yeoh | a4f606e | 2012-06-11 11:59:36 +0800 | [diff] [blame] | 615 | u.mesh.mshstats.dropped_frames_no_route, DEC); |
Luis Carlos Cobo | 9f42f60 | 2008-02-23 15:17:16 +0100 | [diff] [blame] | 616 | |
| 617 | /* Mesh parameters */ |
Johannes Berg | 36ff382 | 2008-10-07 12:04:31 +0200 | [diff] [blame] | 618 | IEEE80211_IF_FILE(dot11MeshMaxRetries, |
Chun-Yeow Yeoh | a4f606e | 2012-06-11 11:59:36 +0800 | [diff] [blame] | 619 | u.mesh.mshcfg.dot11MeshMaxRetries, DEC); |
Johannes Berg | 36ff382 | 2008-10-07 12:04:31 +0200 | [diff] [blame] | 620 | IEEE80211_IF_FILE(dot11MeshRetryTimeout, |
Chun-Yeow Yeoh | a4f606e | 2012-06-11 11:59:36 +0800 | [diff] [blame] | 621 | u.mesh.mshcfg.dot11MeshRetryTimeout, DEC); |
Johannes Berg | 36ff382 | 2008-10-07 12:04:31 +0200 | [diff] [blame] | 622 | IEEE80211_IF_FILE(dot11MeshConfirmTimeout, |
Chun-Yeow Yeoh | a4f606e | 2012-06-11 11:59:36 +0800 | [diff] [blame] | 623 | u.mesh.mshcfg.dot11MeshConfirmTimeout, DEC); |
Johannes Berg | 36ff382 | 2008-10-07 12:04:31 +0200 | [diff] [blame] | 624 | IEEE80211_IF_FILE(dot11MeshHoldingTimeout, |
Chun-Yeow Yeoh | a4f606e | 2012-06-11 11:59:36 +0800 | [diff] [blame] | 625 | u.mesh.mshcfg.dot11MeshHoldingTimeout, DEC); |
Johannes Berg | 36ff382 | 2008-10-07 12:04:31 +0200 | [diff] [blame] | 626 | IEEE80211_IF_FILE(dot11MeshTTL, u.mesh.mshcfg.dot11MeshTTL, DEC); |
Javier Cardona | 45904f2 | 2010-12-03 09:20:40 +0100 | [diff] [blame] | 627 | IEEE80211_IF_FILE(element_ttl, u.mesh.mshcfg.element_ttl, DEC); |
Johannes Berg | 36ff382 | 2008-10-07 12:04:31 +0200 | [diff] [blame] | 628 | IEEE80211_IF_FILE(auto_open_plinks, u.mesh.mshcfg.auto_open_plinks, DEC); |
| 629 | IEEE80211_IF_FILE(dot11MeshMaxPeerLinks, |
Chun-Yeow Yeoh | a4f606e | 2012-06-11 11:59:36 +0800 | [diff] [blame] | 630 | u.mesh.mshcfg.dot11MeshMaxPeerLinks, DEC); |
Johannes Berg | 36ff382 | 2008-10-07 12:04:31 +0200 | [diff] [blame] | 631 | IEEE80211_IF_FILE(dot11MeshHWMPactivePathTimeout, |
Chun-Yeow Yeoh | a4f606e | 2012-06-11 11:59:36 +0800 | [diff] [blame] | 632 | u.mesh.mshcfg.dot11MeshHWMPactivePathTimeout, DEC); |
Johannes Berg | 36ff382 | 2008-10-07 12:04:31 +0200 | [diff] [blame] | 633 | IEEE80211_IF_FILE(dot11MeshHWMPpreqMinInterval, |
Chun-Yeow Yeoh | a4f606e | 2012-06-11 11:59:36 +0800 | [diff] [blame] | 634 | u.mesh.mshcfg.dot11MeshHWMPpreqMinInterval, DEC); |
Thomas Pedersen | dca7e94 | 2011-11-24 17:15:24 -0800 | [diff] [blame] | 635 | IEEE80211_IF_FILE(dot11MeshHWMPperrMinInterval, |
Chun-Yeow Yeoh | a4f606e | 2012-06-11 11:59:36 +0800 | [diff] [blame] | 636 | u.mesh.mshcfg.dot11MeshHWMPperrMinInterval, DEC); |
Johannes Berg | 36ff382 | 2008-10-07 12:04:31 +0200 | [diff] [blame] | 637 | IEEE80211_IF_FILE(dot11MeshHWMPnetDiameterTraversalTime, |
Chun-Yeow Yeoh | a4f606e | 2012-06-11 11:59:36 +0800 | [diff] [blame] | 638 | u.mesh.mshcfg.dot11MeshHWMPnetDiameterTraversalTime, DEC); |
Johannes Berg | 36ff382 | 2008-10-07 12:04:31 +0200 | [diff] [blame] | 639 | IEEE80211_IF_FILE(dot11MeshHWMPmaxPREQretries, |
Chun-Yeow Yeoh | a4f606e | 2012-06-11 11:59:36 +0800 | [diff] [blame] | 640 | u.mesh.mshcfg.dot11MeshHWMPmaxPREQretries, DEC); |
Johannes Berg | 36ff382 | 2008-10-07 12:04:31 +0200 | [diff] [blame] | 641 | IEEE80211_IF_FILE(path_refresh_time, |
Chun-Yeow Yeoh | a4f606e | 2012-06-11 11:59:36 +0800 | [diff] [blame] | 642 | u.mesh.mshcfg.path_refresh_time, DEC); |
Johannes Berg | 36ff382 | 2008-10-07 12:04:31 +0200 | [diff] [blame] | 643 | IEEE80211_IF_FILE(min_discovery_timeout, |
Chun-Yeow Yeoh | a4f606e | 2012-06-11 11:59:36 +0800 | [diff] [blame] | 644 | u.mesh.mshcfg.min_discovery_timeout, DEC); |
Rui Paulo | 63c5723 | 2009-11-09 23:46:57 +0000 | [diff] [blame] | 645 | IEEE80211_IF_FILE(dot11MeshHWMPRootMode, |
Chun-Yeow Yeoh | a4f606e | 2012-06-11 11:59:36 +0800 | [diff] [blame] | 646 | u.mesh.mshcfg.dot11MeshHWMPRootMode, DEC); |
Javier Cardona | 16dd726 | 2011-08-09 16:45:11 -0700 | [diff] [blame] | 647 | IEEE80211_IF_FILE(dot11MeshGateAnnouncementProtocol, |
Chun-Yeow Yeoh | a4f606e | 2012-06-11 11:59:36 +0800 | [diff] [blame] | 648 | u.mesh.mshcfg.dot11MeshGateAnnouncementProtocol, DEC); |
Javier Cardona | 0507e15 | 2011-08-09 16:45:10 -0700 | [diff] [blame] | 649 | IEEE80211_IF_FILE(dot11MeshHWMPRannInterval, |
Chun-Yeow Yeoh | a4f606e | 2012-06-11 11:59:36 +0800 | [diff] [blame] | 650 | u.mesh.mshcfg.dot11MeshHWMPRannInterval, DEC); |
Chun-Yeow Yeoh | 94f9065 | 2012-01-21 01:02:16 +0800 | [diff] [blame] | 651 | IEEE80211_IF_FILE(dot11MeshForwarding, u.mesh.mshcfg.dot11MeshForwarding, DEC); |
Ashok Nagarajan | 5533513 | 2012-02-28 17:04:08 -0800 | [diff] [blame] | 652 | IEEE80211_IF_FILE(rssi_threshold, u.mesh.mshcfg.rssi_threshold, DEC); |
Ashok Nagarajan | 4416f5d | 2012-05-07 21:00:32 -0700 | [diff] [blame] | 653 | IEEE80211_IF_FILE(ht_opmode, u.mesh.mshcfg.ht_opmode, DEC); |
Chun-Yeow Yeoh | ac1073a | 2012-06-14 02:06:06 +0800 | [diff] [blame] | 654 | IEEE80211_IF_FILE(dot11MeshHWMPactivePathToRootTimeout, |
| 655 | u.mesh.mshcfg.dot11MeshHWMPactivePathToRootTimeout, DEC); |
| 656 | IEEE80211_IF_FILE(dot11MeshHWMProotInterval, |
| 657 | u.mesh.mshcfg.dot11MeshHWMProotInterval, DEC); |
Chun-Yeow Yeoh | 728b19e | 2012-06-14 02:06:10 +0800 | [diff] [blame] | 658 | IEEE80211_IF_FILE(dot11MeshHWMPconfirmationInterval, |
| 659 | u.mesh.mshcfg.dot11MeshHWMPconfirmationInterval, DEC); |
Marco Porsch | 3f52b7e | 2013-01-30 18:14:08 +0100 | [diff] [blame] | 660 | IEEE80211_IF_FILE(power_mode, u.mesh.mshcfg.power_mode, DEC); |
| 661 | IEEE80211_IF_FILE(dot11MeshAwakeWindowDuration, |
| 662 | u.mesh.mshcfg.dot11MeshAwakeWindowDuration, DEC); |
Bob Copeland | 01d66fb | 2018-10-25 17:36:34 -0400 | [diff] [blame] | 663 | IEEE80211_IF_FILE(dot11MeshConnectedToMeshGate, |
| 664 | u.mesh.mshcfg.dot11MeshConnectedToMeshGate, DEC); |
Linus Lüssing | e3718a6 | 2020-06-17 09:30:33 +0200 | [diff] [blame] | 665 | IEEE80211_IF_FILE(dot11MeshNolearn, u.mesh.mshcfg.dot11MeshNolearn, DEC); |
Markus Theil | 184eebe | 2020-06-11 16:02:37 +0200 | [diff] [blame] | 666 | IEEE80211_IF_FILE(dot11MeshConnectedToAuthServer, |
| 667 | u.mesh.mshcfg.dot11MeshConnectedToAuthServer, DEC); |
Luis Carlos Cobo | 9f42f60 | 2008-02-23 15:17:16 +0100 | [diff] [blame] | 668 | #endif |
| 669 | |
Johannes Berg | 0f78231 | 2009-12-01 13:37:02 +0100 | [diff] [blame] | 670 | #define DEBUGFS_ADD_MODE(name, mode) \ |
Stanislaw Gruszka | ddbfe86 | 2013-03-08 14:46:14 +0100 | [diff] [blame] | 671 | debugfs_create_file(#name, mode, sdata->vif.debugfs_dir, \ |
Tom Rix | 84674ef | 2020-11-27 11:38:42 -0800 | [diff] [blame] | 672 | sdata, &name##_ops) |
Johannes Berg | 0f78231 | 2009-12-01 13:37:02 +0100 | [diff] [blame] | 673 | |
Felix Fietkau | fcb2c9e | 2012-03-18 22:58:05 +0100 | [diff] [blame] | 674 | #define DEBUGFS_ADD(name) DEBUGFS_ADD_MODE(name, 0400) |
| 675 | |
| 676 | static void add_common_files(struct ieee80211_sub_if_data *sdata) |
Jiri Benc | e9f207f | 2007-05-05 11:46:38 -0700 | [diff] [blame] | 677 | { |
Johannes Berg | 2d46d7c | 2010-01-10 17:12:41 +0100 | [diff] [blame] | 678 | DEBUGFS_ADD(rc_rateidx_mask_2ghz); |
| 679 | DEBUGFS_ADD(rc_rateidx_mask_5ghz); |
Simon Wunderlich | 1946841 | 2012-01-28 17:25:33 +0100 | [diff] [blame] | 680 | DEBUGFS_ADD(rc_rateidx_mcs_mask_2ghz); |
| 681 | DEBUGFS_ADD(rc_rateidx_mcs_mask_5ghz); |
Lorenzo Bianconi | b119ad6 | 2015-08-06 23:47:33 +0200 | [diff] [blame] | 682 | DEBUGFS_ADD(rc_rateidx_vht_mcs_mask_2ghz); |
| 683 | DEBUGFS_ADD(rc_rateidx_vht_mcs_mask_5ghz); |
Johannes Berg | 0864331 | 2012-11-08 15:29:28 +0100 | [diff] [blame] | 684 | DEBUGFS_ADD(hw_queues); |
Toke Høiland-Jørgensen | 8d51dbb | 2016-09-12 15:55:43 +0200 | [diff] [blame] | 685 | |
Miaoqing Pan | 8ed31a2 | 2019-09-27 10:03:16 +0800 | [diff] [blame] | 686 | if (sdata->local->ops->wake_tx_queue && |
| 687 | sdata->vif.type != NL80211_IFTYPE_P2P_DEVICE && |
Toke Høiland-Jørgensen | 2433647 | 2021-06-23 15:47:55 +0200 | [diff] [blame] | 688 | sdata->vif.type != NL80211_IFTYPE_NAN) { |
Toke Høiland-Jørgensen | 8d51dbb | 2016-09-12 15:55:43 +0200 | [diff] [blame] | 689 | DEBUGFS_ADD(aqm); |
Toke Høiland-Jørgensen | 2433647 | 2021-06-23 15:47:55 +0200 | [diff] [blame] | 690 | DEBUGFS_ADD(airtime); |
| 691 | } |
Felix Fietkau | fcb2c9e | 2012-03-18 22:58:05 +0100 | [diff] [blame] | 692 | } |
Johannes Berg | 3e122be | 2008-07-09 14:40:34 +0200 | [diff] [blame] | 693 | |
Felix Fietkau | fcb2c9e | 2012-03-18 22:58:05 +0100 | [diff] [blame] | 694 | static void add_sta_files(struct ieee80211_sub_if_data *sdata) |
| 695 | { |
Johannes Berg | 2d46d7c | 2010-01-10 17:12:41 +0100 | [diff] [blame] | 696 | DEBUGFS_ADD(bssid); |
| 697 | DEBUGFS_ADD(aid); |
Ben Greear | 78e443e | 2013-03-25 11:19:34 -0700 | [diff] [blame] | 698 | DEBUGFS_ADD(beacon_timeout); |
Johannes Berg | 0f78231 | 2009-12-01 13:37:02 +0100 | [diff] [blame] | 699 | DEBUGFS_ADD_MODE(smps, 0600); |
Jouni Malinen | 681d119 | 2011-02-03 18:35:19 +0200 | [diff] [blame] | 700 | DEBUGFS_ADD_MODE(tkip_mic_test, 0200); |
Eliad Peller | 802ee9e | 2014-02-11 12:36:18 +0200 | [diff] [blame] | 701 | DEBUGFS_ADD_MODE(beacon_loss, 0200); |
Eliad Peller | dc41e4d | 2012-03-14 16:15:03 +0200 | [diff] [blame] | 702 | DEBUGFS_ADD_MODE(uapsd_queues, 0600); |
| 703 | DEBUGFS_ADD_MODE(uapsd_max_sp_len, 0600); |
Arik Nemtsov | 82c0cc90d | 2015-08-15 22:39:46 +0300 | [diff] [blame] | 704 | DEBUGFS_ADD_MODE(tdls_wider_bw, 0600); |
Jiri Benc | e9f207f | 2007-05-05 11:46:38 -0700 | [diff] [blame] | 705 | } |
| 706 | |
| 707 | static void add_ap_files(struct ieee80211_sub_if_data *sdata) |
| 708 | { |
Felix Fietkau | 030ef8f | 2012-04-23 19:49:02 +0200 | [diff] [blame] | 709 | DEBUGFS_ADD(num_mcast_sta); |
Emmanuel Grumbach | 687da13 | 2013-10-01 16:45:43 +0300 | [diff] [blame] | 710 | DEBUGFS_ADD_MODE(smps, 0600); |
Johannes Berg | 2d46d7c | 2010-01-10 17:12:41 +0100 | [diff] [blame] | 711 | DEBUGFS_ADD(num_sta_ps); |
| 712 | DEBUGFS_ADD(dtim_count); |
| 713 | DEBUGFS_ADD(num_buffered_multicast); |
Jouni Malinen | 681d119 | 2011-02-03 18:35:19 +0200 | [diff] [blame] | 714 | DEBUGFS_ADD_MODE(tkip_mic_test, 0200); |
Michael Braun | ebceec8 | 2016-11-22 11:52:18 +0100 | [diff] [blame] | 715 | DEBUGFS_ADD_MODE(multicast_to_unicast, 0600); |
Jiri Benc | e9f207f | 2007-05-05 11:46:38 -0700 | [diff] [blame] | 716 | } |
| 717 | |
Michael Braun | 72f15d5 | 2016-10-10 19:12:21 +0200 | [diff] [blame] | 718 | static void add_vlan_files(struct ieee80211_sub_if_data *sdata) |
| 719 | { |
| 720 | /* add num_mcast_sta_vlan using name num_mcast_sta */ |
| 721 | debugfs_create_file("num_mcast_sta", 0400, sdata->vif.debugfs_dir, |
| 722 | sdata, &num_mcast_sta_vlan_ops); |
| 723 | } |
| 724 | |
Eliad Peller | 37a41b4 | 2011-09-21 14:06:11 +0300 | [diff] [blame] | 725 | static void add_ibss_files(struct ieee80211_sub_if_data *sdata) |
| 726 | { |
| 727 | DEBUGFS_ADD_MODE(tsf, 0600); |
| 728 | } |
| 729 | |
Luis Carlos Cobo | 9f42f60 | 2008-02-23 15:17:16 +0100 | [diff] [blame] | 730 | #ifdef CONFIG_MAC80211_MESH |
Luis Carlos Cobo | 9f42f60 | 2008-02-23 15:17:16 +0100 | [diff] [blame] | 731 | |
Javier Cardona | 12ce8ba | 2012-03-05 17:20:38 -0800 | [diff] [blame] | 732 | static void add_mesh_files(struct ieee80211_sub_if_data *sdata) |
| 733 | { |
| 734 | DEBUGFS_ADD_MODE(tsf, 0600); |
Ashok Nagarajan | d4a5a48 | 2013-05-13 17:08:04 -0700 | [diff] [blame] | 735 | DEBUGFS_ADD_MODE(estab_plinks, 0400); |
Javier Cardona | 12ce8ba | 2012-03-05 17:20:38 -0800 | [diff] [blame] | 736 | } |
| 737 | |
Luis Carlos Cobo | 9f42f60 | 2008-02-23 15:17:16 +0100 | [diff] [blame] | 738 | static void add_mesh_stats(struct ieee80211_sub_if_data *sdata) |
| 739 | { |
Johannes Berg | 7bcfaf2 | 2009-10-27 12:59:03 +0100 | [diff] [blame] | 740 | struct dentry *dir = debugfs_create_dir("mesh_stats", |
Stanislaw Gruszka | ddbfe86 | 2013-03-08 14:46:14 +0100 | [diff] [blame] | 741 | sdata->vif.debugfs_dir); |
Johannes Berg | 7bcfaf2 | 2009-10-27 12:59:03 +0100 | [diff] [blame] | 742 | #define MESHSTATS_ADD(name)\ |
Tom Rix | 84674ef | 2020-11-27 11:38:42 -0800 | [diff] [blame] | 743 | debugfs_create_file(#name, 0400, dir, sdata, &name##_ops) |
Johannes Berg | 7bcfaf2 | 2009-10-27 12:59:03 +0100 | [diff] [blame] | 744 | |
Daniel Walker | c8a61a7 | 2009-08-18 10:59:00 -0700 | [diff] [blame] | 745 | MESHSTATS_ADD(fwded_mcast); |
| 746 | MESHSTATS_ADD(fwded_unicast); |
Luis Carlos Cobo | 9f42f60 | 2008-02-23 15:17:16 +0100 | [diff] [blame] | 747 | MESHSTATS_ADD(fwded_frames); |
| 748 | MESHSTATS_ADD(dropped_frames_ttl); |
| 749 | MESHSTATS_ADD(dropped_frames_no_route); |
Javier Cardona | cfee66b | 2011-09-06 13:05:21 -0700 | [diff] [blame] | 750 | MESHSTATS_ADD(dropped_frames_congestion); |
Johannes Berg | 7bcfaf2 | 2009-10-27 12:59:03 +0100 | [diff] [blame] | 751 | #undef MESHSTATS_ADD |
Luis Carlos Cobo | 9f42f60 | 2008-02-23 15:17:16 +0100 | [diff] [blame] | 752 | } |
| 753 | |
Luis Carlos Cobo | 9f42f60 | 2008-02-23 15:17:16 +0100 | [diff] [blame] | 754 | static void add_mesh_config(struct ieee80211_sub_if_data *sdata) |
| 755 | { |
Johannes Berg | 7bcfaf2 | 2009-10-27 12:59:03 +0100 | [diff] [blame] | 756 | struct dentry *dir = debugfs_create_dir("mesh_config", |
Stanislaw Gruszka | ddbfe86 | 2013-03-08 14:46:14 +0100 | [diff] [blame] | 757 | sdata->vif.debugfs_dir); |
Johannes Berg | 7bcfaf2 | 2009-10-27 12:59:03 +0100 | [diff] [blame] | 758 | |
| 759 | #define MESHPARAMS_ADD(name) \ |
Tom Rix | 84674ef | 2020-11-27 11:38:42 -0800 | [diff] [blame] | 760 | debugfs_create_file(#name, 0600, dir, sdata, &name##_ops) |
Johannes Berg | 7bcfaf2 | 2009-10-27 12:59:03 +0100 | [diff] [blame] | 761 | |
Luis Carlos Cobo | 9f42f60 | 2008-02-23 15:17:16 +0100 | [diff] [blame] | 762 | MESHPARAMS_ADD(dot11MeshMaxRetries); |
| 763 | MESHPARAMS_ADD(dot11MeshRetryTimeout); |
| 764 | MESHPARAMS_ADD(dot11MeshConfirmTimeout); |
| 765 | MESHPARAMS_ADD(dot11MeshHoldingTimeout); |
| 766 | MESHPARAMS_ADD(dot11MeshTTL); |
Javier Cardona | 45904f2 | 2010-12-03 09:20:40 +0100 | [diff] [blame] | 767 | MESHPARAMS_ADD(element_ttl); |
Luis Carlos Cobo | 9f42f60 | 2008-02-23 15:17:16 +0100 | [diff] [blame] | 768 | MESHPARAMS_ADD(auto_open_plinks); |
| 769 | MESHPARAMS_ADD(dot11MeshMaxPeerLinks); |
| 770 | MESHPARAMS_ADD(dot11MeshHWMPactivePathTimeout); |
| 771 | MESHPARAMS_ADD(dot11MeshHWMPpreqMinInterval); |
Thomas Pedersen | dca7e94 | 2011-11-24 17:15:24 -0800 | [diff] [blame] | 772 | MESHPARAMS_ADD(dot11MeshHWMPperrMinInterval); |
Luis Carlos Cobo | 9f42f60 | 2008-02-23 15:17:16 +0100 | [diff] [blame] | 773 | MESHPARAMS_ADD(dot11MeshHWMPnetDiameterTraversalTime); |
| 774 | MESHPARAMS_ADD(dot11MeshHWMPmaxPREQretries); |
| 775 | MESHPARAMS_ADD(path_refresh_time); |
| 776 | MESHPARAMS_ADD(min_discovery_timeout); |
Javier Cardona | 699403d | 2011-08-09 16:45:09 -0700 | [diff] [blame] | 777 | MESHPARAMS_ADD(dot11MeshHWMPRootMode); |
Javier Cardona | 0507e15 | 2011-08-09 16:45:10 -0700 | [diff] [blame] | 778 | MESHPARAMS_ADD(dot11MeshHWMPRannInterval); |
Chun-Yeow Yeoh | 8c06e8c | 2012-05-31 18:17:30 +0800 | [diff] [blame] | 779 | MESHPARAMS_ADD(dot11MeshForwarding); |
Javier Cardona | 16dd726 | 2011-08-09 16:45:11 -0700 | [diff] [blame] | 780 | MESHPARAMS_ADD(dot11MeshGateAnnouncementProtocol); |
Ashok Nagarajan | 5533513 | 2012-02-28 17:04:08 -0800 | [diff] [blame] | 781 | MESHPARAMS_ADD(rssi_threshold); |
Ashok Nagarajan | 4416f5d | 2012-05-07 21:00:32 -0700 | [diff] [blame] | 782 | MESHPARAMS_ADD(ht_opmode); |
Chun-Yeow Yeoh | ac1073a | 2012-06-14 02:06:06 +0800 | [diff] [blame] | 783 | MESHPARAMS_ADD(dot11MeshHWMPactivePathToRootTimeout); |
| 784 | MESHPARAMS_ADD(dot11MeshHWMProotInterval); |
Chun-Yeow Yeoh | 728b19e | 2012-06-14 02:06:10 +0800 | [diff] [blame] | 785 | MESHPARAMS_ADD(dot11MeshHWMPconfirmationInterval); |
Marco Porsch | 3f52b7e | 2013-01-30 18:14:08 +0100 | [diff] [blame] | 786 | MESHPARAMS_ADD(power_mode); |
| 787 | MESHPARAMS_ADD(dot11MeshAwakeWindowDuration); |
Bob Copeland | 01d66fb | 2018-10-25 17:36:34 -0400 | [diff] [blame] | 788 | MESHPARAMS_ADD(dot11MeshConnectedToMeshGate); |
Linus Lüssing | e3718a6 | 2020-06-17 09:30:33 +0200 | [diff] [blame] | 789 | MESHPARAMS_ADD(dot11MeshNolearn); |
Markus Theil | 184eebe | 2020-06-11 16:02:37 +0200 | [diff] [blame] | 790 | MESHPARAMS_ADD(dot11MeshConnectedToAuthServer); |
Johannes Berg | 7bcfaf2 | 2009-10-27 12:59:03 +0100 | [diff] [blame] | 791 | #undef MESHPARAMS_ADD |
Luis Carlos Cobo | 9f42f60 | 2008-02-23 15:17:16 +0100 | [diff] [blame] | 792 | } |
| 793 | #endif |
| 794 | |
Jiri Benc | e9f207f | 2007-05-05 11:46:38 -0700 | [diff] [blame] | 795 | static void add_files(struct ieee80211_sub_if_data *sdata) |
| 796 | { |
Stanislaw Gruszka | ddbfe86 | 2013-03-08 14:46:14 +0100 | [diff] [blame] | 797 | if (!sdata->vif.debugfs_dir) |
Jiri Benc | e9f207f | 2007-05-05 11:46:38 -0700 | [diff] [blame] | 798 | return; |
| 799 | |
Felix Fietkau | fcb2c9e | 2012-03-18 22:58:05 +0100 | [diff] [blame] | 800 | DEBUGFS_ADD(flags); |
| 801 | DEBUGFS_ADD(state); |
Johannes Berg | 1ea6f9c | 2012-10-24 10:59:25 +0200 | [diff] [blame] | 802 | DEBUGFS_ADD(txpower); |
| 803 | DEBUGFS_ADD(user_power_level); |
| 804 | DEBUGFS_ADD(ap_power_level); |
Felix Fietkau | fcb2c9e | 2012-03-18 22:58:05 +0100 | [diff] [blame] | 805 | |
| 806 | if (sdata->vif.type != NL80211_IFTYPE_MONITOR) |
| 807 | add_common_files(sdata); |
| 808 | |
Johannes Berg | 51fb61e | 2007-12-19 01:31:27 +0100 | [diff] [blame] | 809 | switch (sdata->vif.type) { |
Johannes Berg | 05c914f | 2008-09-11 00:01:58 +0200 | [diff] [blame] | 810 | case NL80211_IFTYPE_MESH_POINT: |
Luis Carlos Cobo | 9f42f60 | 2008-02-23 15:17:16 +0100 | [diff] [blame] | 811 | #ifdef CONFIG_MAC80211_MESH |
Javier Cardona | 12ce8ba | 2012-03-05 17:20:38 -0800 | [diff] [blame] | 812 | add_mesh_files(sdata); |
Luis Carlos Cobo | 9f42f60 | 2008-02-23 15:17:16 +0100 | [diff] [blame] | 813 | add_mesh_stats(sdata); |
| 814 | add_mesh_config(sdata); |
| 815 | #endif |
Johannes Berg | 472dbc4 | 2008-09-11 00:01:49 +0200 | [diff] [blame] | 816 | break; |
Johannes Berg | 05c914f | 2008-09-11 00:01:58 +0200 | [diff] [blame] | 817 | case NL80211_IFTYPE_STATION: |
Jiri Benc | e9f207f | 2007-05-05 11:46:38 -0700 | [diff] [blame] | 818 | add_sta_files(sdata); |
| 819 | break; |
Johannes Berg | 4690029 | 2009-02-15 12:44:28 +0100 | [diff] [blame] | 820 | case NL80211_IFTYPE_ADHOC: |
Eliad Peller | 37a41b4 | 2011-09-21 14:06:11 +0300 | [diff] [blame] | 821 | add_ibss_files(sdata); |
Johannes Berg | 4690029 | 2009-02-15 12:44:28 +0100 | [diff] [blame] | 822 | break; |
Johannes Berg | 05c914f | 2008-09-11 00:01:58 +0200 | [diff] [blame] | 823 | case NL80211_IFTYPE_AP: |
Jiri Benc | e9f207f | 2007-05-05 11:46:38 -0700 | [diff] [blame] | 824 | add_ap_files(sdata); |
| 825 | break; |
Michael Braun | 72f15d5 | 2016-10-10 19:12:21 +0200 | [diff] [blame] | 826 | case NL80211_IFTYPE_AP_VLAN: |
| 827 | add_vlan_files(sdata); |
| 828 | break; |
Jiri Benc | e9f207f | 2007-05-05 11:46:38 -0700 | [diff] [blame] | 829 | default: |
| 830 | break; |
| 831 | } |
| 832 | } |
| 833 | |
Jiri Benc | e9f207f | 2007-05-05 11:46:38 -0700 | [diff] [blame] | 834 | void ieee80211_debugfs_add_netdev(struct ieee80211_sub_if_data *sdata) |
| 835 | { |
| 836 | char buf[10+IFNAMSIZ]; |
| 837 | |
Johannes Berg | 47846c9 | 2009-11-25 17:46:19 +0100 | [diff] [blame] | 838 | sprintf(buf, "netdev:%s", sdata->name); |
Stanislaw Gruszka | ddbfe86 | 2013-03-08 14:46:14 +0100 | [diff] [blame] | 839 | sdata->vif.debugfs_dir = debugfs_create_dir(buf, |
Jiri Benc | e9f207f | 2007-05-05 11:46:38 -0700 | [diff] [blame] | 840 | sdata->local->hw.wiphy->debugfsdir); |
Greg Kroah-Hartman | 5a7bb7c | 2019-06-14 08:59:34 +0200 | [diff] [blame] | 841 | sdata->debugfs.subdir_stations = debugfs_create_dir("stations", |
| 842 | sdata->vif.debugfs_dir); |
Johannes Berg | 7563652 | 2008-07-09 14:40:35 +0200 | [diff] [blame] | 843 | add_files(sdata); |
Jiri Benc | e9f207f | 2007-05-05 11:46:38 -0700 | [diff] [blame] | 844 | } |
| 845 | |
| 846 | void ieee80211_debugfs_remove_netdev(struct ieee80211_sub_if_data *sdata) |
| 847 | { |
Stanislaw Gruszka | ddbfe86 | 2013-03-08 14:46:14 +0100 | [diff] [blame] | 848 | if (!sdata->vif.debugfs_dir) |
Johannes Berg | 7bcfaf2 | 2009-10-27 12:59:03 +0100 | [diff] [blame] | 849 | return; |
| 850 | |
Stanislaw Gruszka | ddbfe86 | 2013-03-08 14:46:14 +0100 | [diff] [blame] | 851 | debugfs_remove_recursive(sdata->vif.debugfs_dir); |
| 852 | sdata->vif.debugfs_dir = NULL; |
Tom Hughes | 4479004 | 2015-06-29 19:41:49 +0100 | [diff] [blame] | 853 | sdata->debugfs.subdir_stations = NULL; |
Jiri Benc | e9f207f | 2007-05-05 11:46:38 -0700 | [diff] [blame] | 854 | } |
| 855 | |
Johannes Berg | 47846c9 | 2009-11-25 17:46:19 +0100 | [diff] [blame] | 856 | void ieee80211_debugfs_rename_netdev(struct ieee80211_sub_if_data *sdata) |
Jiri Benc | e9f207f | 2007-05-05 11:46:38 -0700 | [diff] [blame] | 857 | { |
Johannes Berg | 7c8081e | 2007-06-21 18:30:19 +0200 | [diff] [blame] | 858 | struct dentry *dir; |
Johannes Berg | 47846c9 | 2009-11-25 17:46:19 +0100 | [diff] [blame] | 859 | char buf[10 + IFNAMSIZ]; |
Johannes Berg | 3e122be | 2008-07-09 14:40:34 +0200 | [diff] [blame] | 860 | |
Stanislaw Gruszka | ddbfe86 | 2013-03-08 14:46:14 +0100 | [diff] [blame] | 861 | dir = sdata->vif.debugfs_dir; |
Johannes Berg | c74e90a | 2008-10-08 10:18:36 +0200 | [diff] [blame] | 862 | |
Johannes Berg | 5178791 | 2019-04-15 11:39:33 +0200 | [diff] [blame] | 863 | if (IS_ERR_OR_NULL(dir)) |
Johannes Berg | 47846c9 | 2009-11-25 17:46:19 +0100 | [diff] [blame] | 864 | return; |
Johannes Berg | c74e90a | 2008-10-08 10:18:36 +0200 | [diff] [blame] | 865 | |
Johannes Berg | 47846c9 | 2009-11-25 17:46:19 +0100 | [diff] [blame] | 866 | sprintf(buf, "netdev:%s", sdata->name); |
Greg Kroah-Hartman | 5a7bb7c | 2019-06-14 08:59:34 +0200 | [diff] [blame] | 867 | debugfs_rename(dir->d_parent, dir, dir->d_parent, buf); |
Jiri Benc | e9f207f | 2007-05-05 11:46:38 -0700 | [diff] [blame] | 868 | } |