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