blob: 653ce5d9e6e04c4e31a517338c7c7e88ef4594b7 [file] [log] [blame]
Jiri Bence9f207f2007-05-05 11:46:38 -07001/*
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 Berg28656a12012-11-05 20:24:38 +010013#include <linux/if_ether.h>
Jiri Bence9f207f2007-05-05 11:46:38 -070014#include <linux/interrupt.h>
15#include <linux/netdevice.h>
16#include <linux/rtnetlink.h>
Tejun Heo5a0e3ad2010-03-24 17:04:11 +090017#include <linux/slab.h>
Jiri Bence9f207f2007-05-05 11:46:38 -070018#include <linux/notifier.h>
19#include <net/mac80211.h>
20#include <net/cfg80211.h>
21#include "ieee80211_i.h"
Johannes Berg2c8dccc2008-04-08 15:14:40 -040022#include "rate.h"
Jiri Bence9f207f2007-05-05 11:46:38 -070023#include "debugfs.h"
24#include "debugfs_netdev.h"
Eliad Peller37a41b42011-09-21 14:06:11 +030025#include "driver-ops.h"
Jiri Bence9f207f2007-05-05 11:46:38 -070026
27static 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{
33 char buf[70];
34 ssize_t ret = -EINVAL;
35
36 read_lock(&dev_base_lock);
Arik Nemtsovc7e59232014-05-26 14:40:51 +030037 ret = (*format)(sdata, buf, sizeof(buf));
Jiri Bence9f207f2007-05-05 11:46:38 -070038 read_unlock(&dev_base_lock);
Luis Carlos Cobo73bb3e42008-03-31 15:10:22 -070039
Jouni Malinen681d1192011-02-03 18:35:19 +020040 if (ret >= 0)
Luis Carlos Cobo73bb3e42008-03-31 15:10:22 -070041 ret = simple_read_from_buffer(userbuf, count, ppos, buf, ret);
42
Jiri Bence9f207f2007-05-05 11:46:38 -070043 return ret;
44}
45
Johannes Berg0f782312009-12-01 13:37:02 +010046static 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 Pellerada577c2012-03-14 16:15:02 +020052 char buf[64];
Eric Dumazet51f5f8c2010-03-10 17:13:36 +010053 ssize_t ret;
Johannes Berg0f782312009-12-01 13:37:02 +010054
Eliad Pellerada577c2012-03-14 16:15:02 +020055 if (count >= sizeof(buf))
56 return -E2BIG;
Johannes Berg0f782312009-12-01 13:37:02 +010057
58 if (copy_from_user(buf, userbuf, count))
Eliad Pellerada577c2012-03-14 16:15:02 +020059 return -EFAULT;
60 buf[count] = '\0';
Johannes Berg0f782312009-12-01 13:37:02 +010061
Eric Dumazet51f5f8c2010-03-10 17:13:36 +010062 ret = -ENODEV;
Johannes Berg0f782312009-12-01 13:37:02 +010063 rtnl_lock();
Arik Nemtsovc7e59232014-05-26 14:40:51 +030064 ret = (*write)(sdata, buf, count);
Johannes Berg0f782312009-12-01 13:37:02 +010065 rtnl_unlock();
66
67 return ret;
68}
69
Jiri Bence9f207f2007-05-05 11:46:38 -070070#define IEEE80211_IF_FMT(name, field, format_string) \
71static 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 Greear4914b3b2011-01-27 22:09:34 -080081#define IEEE80211_IF_FMT_LHEX(name, field) \
82 IEEE80211_IF_FMT(name, field, "%#lx\n")
Jiri Bence9f207f2007-05-05 11:46:38 -070083#define IEEE80211_IF_FMT_SIZE(name, field) \
84 IEEE80211_IF_FMT(name, field, "%zd\n")
85
Simon Wunderlich19468412012-01-28 17:25:33 +010086#define IEEE80211_IF_FMT_HEXARRAY(name, field) \
87static 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 Bence9f207f2007-05-05 11:46:38 -0700101#define IEEE80211_IF_FMT_ATOMIC(name, field) \
102static 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) \
110static ssize_t ieee80211_if_fmt_##name( \
111 const struct ieee80211_sub_if_data *sdata, char *buf, \
112 int buflen) \
113{ \
Johannes Berg0c68ae262008-10-27 15:56:10 -0700114 return scnprintf(buf, buflen, "%pM\n", sdata->field); \
Jiri Bence9f207f2007-05-05 11:46:38 -0700115}
116
Jouni Malinen17e4ec12010-03-29 23:28:30 -0700117#define IEEE80211_IF_FMT_DEC_DIV_16(name, field) \
118static 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", sdata->field / 16); \
123}
124
Ben Greear78e443e2013-03-25 11:19:34 -0700125#define IEEE80211_IF_FMT_JIFFIES_TO_MS(name, field) \
126static ssize_t ieee80211_if_fmt_##name( \
127 const struct ieee80211_sub_if_data *sdata, \
128 char *buf, int buflen) \
129{ \
130 return scnprintf(buf, buflen, "%d\n", \
131 jiffies_to_msecs(sdata->field)); \
132}
133
Johannes Berg4cd3c4e2014-01-06 15:47:15 +0100134#define _IEEE80211_IF_FILE_OPS(name, _read, _write) \
135static const struct file_operations name##_ops = { \
136 .read = (_read), \
137 .write = (_write), \
138 .open = simple_open, \
139 .llseek = generic_file_llseek, \
140}
141
142#define _IEEE80211_IF_FILE_R_FN(name) \
Jiri Bence9f207f2007-05-05 11:46:38 -0700143static ssize_t ieee80211_if_read_##name(struct file *file, \
144 char __user *userbuf, \
145 size_t count, loff_t *ppos) \
146{ \
147 return ieee80211_if_read(file->private_data, \
148 userbuf, count, ppos, \
149 ieee80211_if_fmt_##name); \
Jiri Bence9f207f2007-05-05 11:46:38 -0700150}
151
Johannes Berg4cd3c4e2014-01-06 15:47:15 +0100152#define _IEEE80211_IF_FILE_W_FN(name) \
Johannes Berg0f782312009-12-01 13:37:02 +0100153static ssize_t ieee80211_if_write_##name(struct file *file, \
154 const char __user *userbuf, \
155 size_t count, loff_t *ppos) \
156{ \
157 return ieee80211_if_write(file->private_data, userbuf, count, \
158 ppos, ieee80211_if_parse_##name); \
Johannes Berg4cd3c4e2014-01-06 15:47:15 +0100159}
Johannes Berg0f782312009-12-01 13:37:02 +0100160
Johannes Berg4cd3c4e2014-01-06 15:47:15 +0100161#define IEEE80211_IF_FILE_R(name) \
162 _IEEE80211_IF_FILE_R_FN(name) \
163 _IEEE80211_IF_FILE_OPS(name, ieee80211_if_read_##name, NULL)
164
165#define IEEE80211_IF_FILE_W(name) \
166 _IEEE80211_IF_FILE_W_FN(name) \
167 _IEEE80211_IF_FILE_OPS(name, NULL, ieee80211_if_write_##name)
168
169#define IEEE80211_IF_FILE_RW(name) \
170 _IEEE80211_IF_FILE_R_FN(name) \
171 _IEEE80211_IF_FILE_W_FN(name) \
172 _IEEE80211_IF_FILE_OPS(name, ieee80211_if_read_##name, \
173 ieee80211_if_write_##name)
Johannes Berg0f782312009-12-01 13:37:02 +0100174
Jiri Bence9f207f2007-05-05 11:46:38 -0700175#define IEEE80211_IF_FILE(name, field, format) \
Johannes Berg4cd3c4e2014-01-06 15:47:15 +0100176 IEEE80211_IF_FMT_##format(name, field) \
177 IEEE80211_IF_FILE_R(name)
Jiri Bence9f207f2007-05-05 11:46:38 -0700178
179/* common attributes */
Jiri Bence9f207f2007-05-05 11:46:38 -0700180IEEE80211_IF_FILE(drop_unencrypted, drop_unencrypted, DEC);
Jouni Malinen37eb0b12010-01-06 13:09:08 +0200181IEEE80211_IF_FILE(rc_rateidx_mask_2ghz, rc_rateidx_mask[IEEE80211_BAND_2GHZ],
182 HEX);
183IEEE80211_IF_FILE(rc_rateidx_mask_5ghz, rc_rateidx_mask[IEEE80211_BAND_5GHZ],
184 HEX);
Simon Wunderlich19468412012-01-28 17:25:33 +0100185IEEE80211_IF_FILE(rc_rateidx_mcs_mask_2ghz,
186 rc_rateidx_mcs_mask[IEEE80211_BAND_2GHZ], HEXARRAY);
187IEEE80211_IF_FILE(rc_rateidx_mcs_mask_5ghz,
188 rc_rateidx_mcs_mask[IEEE80211_BAND_5GHZ], HEXARRAY);
189
Ben Greear4914b3b2011-01-27 22:09:34 -0800190IEEE80211_IF_FILE(flags, flags, HEX);
191IEEE80211_IF_FILE(state, state, LHEX);
Johannes Berg1ea6f9c2012-10-24 10:59:25 +0200192IEEE80211_IF_FILE(txpower, vif.bss_conf.txpower, DEC);
193IEEE80211_IF_FILE(ap_power_level, ap_power_level, DEC);
194IEEE80211_IF_FILE(user_power_level, user_power_level, DEC);
Jiri Bence9f207f2007-05-05 11:46:38 -0700195
Johannes Berg08643312012-11-08 15:29:28 +0100196static ssize_t
197ieee80211_if_fmt_hw_queues(const struct ieee80211_sub_if_data *sdata,
198 char *buf, int buflen)
199{
200 int len;
201
202 len = scnprintf(buf, buflen, "AC queues: VO:%d VI:%d BE:%d BK:%d\n",
203 sdata->vif.hw_queue[IEEE80211_AC_VO],
204 sdata->vif.hw_queue[IEEE80211_AC_VI],
205 sdata->vif.hw_queue[IEEE80211_AC_BE],
206 sdata->vif.hw_queue[IEEE80211_AC_BK]);
207
208 if (sdata->vif.type == NL80211_IFTYPE_AP)
209 len += scnprintf(buf + len, buflen - len, "cab queue: %d\n",
210 sdata->vif.cab_queue);
211
212 return len;
213}
Johannes Berg4cd3c4e2014-01-06 15:47:15 +0100214IEEE80211_IF_FILE_R(hw_queues);
Johannes Berg08643312012-11-08 15:29:28 +0100215
Johannes Berg46900292009-02-15 12:44:28 +0100216/* STA attributes */
Johannes Berg46900292009-02-15 12:44:28 +0100217IEEE80211_IF_FILE(bssid, u.mgd.bssid, MAC);
Johannes Berg46900292009-02-15 12:44:28 +0100218IEEE80211_IF_FILE(aid, u.mgd.aid, DEC);
Jouni Malinen17e4ec12010-03-29 23:28:30 -0700219IEEE80211_IF_FILE(last_beacon, u.mgd.last_beacon_signal, DEC);
220IEEE80211_IF_FILE(ave_beacon, u.mgd.ave_beacon_signal, DEC_DIV_16);
Ben Greear78e443e2013-03-25 11:19:34 -0700221IEEE80211_IF_FILE(beacon_timeout, u.mgd.beacon_timeout, JIFFIES_TO_MS);
Jiri Bence9f207f2007-05-05 11:46:38 -0700222
Johannes Berg0f782312009-12-01 13:37:02 +0100223static int ieee80211_set_smps(struct ieee80211_sub_if_data *sdata,
224 enum ieee80211_smps_mode smps_mode)
225{
226 struct ieee80211_local *local = sdata->local;
227 int err;
228
229 if (!(local->hw.flags & IEEE80211_HW_SUPPORTS_STATIC_SMPS) &&
230 smps_mode == IEEE80211_SMPS_STATIC)
231 return -EINVAL;
232
233 /* auto should be dynamic if in PS mode */
234 if (!(local->hw.flags & IEEE80211_HW_SUPPORTS_DYNAMIC_SMPS) &&
235 (smps_mode == IEEE80211_SMPS_DYNAMIC ||
236 smps_mode == IEEE80211_SMPS_AUTOMATIC))
237 return -EINVAL;
238
Emmanuel Grumbach687da132013-10-01 16:45:43 +0300239 if (sdata->vif.type != NL80211_IFTYPE_STATION &&
240 sdata->vif.type != NL80211_IFTYPE_AP)
Johannes Berg0f782312009-12-01 13:37:02 +0100241 return -EOPNOTSUPP;
242
Johannes Berg8d61ffa2013-05-10 12:32:47 +0200243 sdata_lock(sdata);
Emmanuel Grumbach687da132013-10-01 16:45:43 +0300244 if (sdata->vif.type == NL80211_IFTYPE_STATION)
245 err = __ieee80211_request_smps_mgd(sdata, smps_mode);
246 else
247 err = __ieee80211_request_smps_ap(sdata, smps_mode);
Johannes Berg8d61ffa2013-05-10 12:32:47 +0200248 sdata_unlock(sdata);
Johannes Berg0f782312009-12-01 13:37:02 +0100249
250 return err;
251}
252
253static const char *smps_modes[IEEE80211_SMPS_NUM_MODES] = {
254 [IEEE80211_SMPS_AUTOMATIC] = "auto",
255 [IEEE80211_SMPS_OFF] = "off",
256 [IEEE80211_SMPS_STATIC] = "static",
257 [IEEE80211_SMPS_DYNAMIC] = "dynamic",
258};
259
260static ssize_t ieee80211_if_fmt_smps(const struct ieee80211_sub_if_data *sdata,
261 char *buf, int buflen)
262{
Emmanuel Grumbach687da132013-10-01 16:45:43 +0300263 if (sdata->vif.type == NL80211_IFTYPE_STATION)
264 return snprintf(buf, buflen, "request: %s\nused: %s\n",
265 smps_modes[sdata->u.mgd.req_smps],
266 smps_modes[sdata->smps_mode]);
267 if (sdata->vif.type == NL80211_IFTYPE_AP)
268 return snprintf(buf, buflen, "request: %s\nused: %s\n",
269 smps_modes[sdata->u.ap.req_smps],
270 smps_modes[sdata->smps_mode]);
271 return -EINVAL;
Johannes Berg0f782312009-12-01 13:37:02 +0100272}
273
274static ssize_t ieee80211_if_parse_smps(struct ieee80211_sub_if_data *sdata,
275 const char *buf, int buflen)
276{
277 enum ieee80211_smps_mode mode;
278
279 for (mode = 0; mode < IEEE80211_SMPS_NUM_MODES; mode++) {
280 if (strncmp(buf, smps_modes[mode], buflen) == 0) {
281 int err = ieee80211_set_smps(sdata, mode);
282 if (!err)
283 return buflen;
284 return err;
285 }
286 }
287
288 return -EINVAL;
289}
Johannes Berg4cd3c4e2014-01-06 15:47:15 +0100290IEEE80211_IF_FILE_RW(smps);
Jouni Malinen681d1192011-02-03 18:35:19 +0200291
Jouni Malinen681d1192011-02-03 18:35:19 +0200292static ssize_t ieee80211_if_parse_tkip_mic_test(
293 struct ieee80211_sub_if_data *sdata, const char *buf, int buflen)
294{
295 struct ieee80211_local *local = sdata->local;
296 u8 addr[ETH_ALEN];
297 struct sk_buff *skb;
298 struct ieee80211_hdr *hdr;
299 __le16 fc;
300
Johannes Berg28656a12012-11-05 20:24:38 +0100301 if (!mac_pton(buf, addr))
Jouni Malinen681d1192011-02-03 18:35:19 +0200302 return -EINVAL;
303
304 if (!ieee80211_sdata_running(sdata))
305 return -ENOTCONN;
306
307 skb = dev_alloc_skb(local->hw.extra_tx_headroom + 24 + 100);
308 if (!skb)
309 return -ENOMEM;
310 skb_reserve(skb, local->hw.extra_tx_headroom);
311
312 hdr = (struct ieee80211_hdr *) skb_put(skb, 24);
313 memset(hdr, 0, 24);
314 fc = cpu_to_le16(IEEE80211_FTYPE_DATA | IEEE80211_STYPE_DATA);
315
316 switch (sdata->vif.type) {
317 case NL80211_IFTYPE_AP:
318 fc |= cpu_to_le16(IEEE80211_FCTL_FROMDS);
319 /* DA BSSID SA */
320 memcpy(hdr->addr1, addr, ETH_ALEN);
321 memcpy(hdr->addr2, sdata->vif.addr, ETH_ALEN);
322 memcpy(hdr->addr3, sdata->vif.addr, ETH_ALEN);
323 break;
324 case NL80211_IFTYPE_STATION:
325 fc |= cpu_to_le16(IEEE80211_FCTL_TODS);
326 /* BSSID SA DA */
Johannes Berg8d61ffa2013-05-10 12:32:47 +0200327 sdata_lock(sdata);
Johannes Berg41c97a22012-11-05 20:27:57 +0100328 if (!sdata->u.mgd.associated) {
Johannes Berg8d61ffa2013-05-10 12:32:47 +0200329 sdata_unlock(sdata);
Jouni Malinen681d1192011-02-03 18:35:19 +0200330 dev_kfree_skb(skb);
331 return -ENOTCONN;
332 }
Johannes Berg41c97a22012-11-05 20:27:57 +0100333 memcpy(hdr->addr1, sdata->u.mgd.associated->bssid, ETH_ALEN);
Jouni Malinen681d1192011-02-03 18:35:19 +0200334 memcpy(hdr->addr2, sdata->vif.addr, ETH_ALEN);
335 memcpy(hdr->addr3, addr, ETH_ALEN);
Johannes Berg8d61ffa2013-05-10 12:32:47 +0200336 sdata_unlock(sdata);
Jouni Malinen681d1192011-02-03 18:35:19 +0200337 break;
338 default:
339 dev_kfree_skb(skb);
340 return -EOPNOTSUPP;
341 }
342 hdr->frame_control = fc;
343
344 /*
345 * Add some length to the test frame to make it look bit more valid.
346 * The exact contents does not matter since the recipient is required
347 * to drop this because of the Michael MIC failure.
348 */
349 memset(skb_put(skb, 50), 0, 50);
350
351 IEEE80211_SKB_CB(skb)->flags |= IEEE80211_TX_INTFL_TKIP_MIC_FAILURE;
352
353 ieee80211_tx_skb(sdata, skb);
354
355 return buflen;
356}
Johannes Berg4cd3c4e2014-01-06 15:47:15 +0100357IEEE80211_IF_FILE_W(tkip_mic_test);
Jouni Malinen681d1192011-02-03 18:35:19 +0200358
Eliad Pellerdc41e4d2012-03-14 16:15:03 +0200359static ssize_t ieee80211_if_fmt_uapsd_queues(
360 const struct ieee80211_sub_if_data *sdata, char *buf, int buflen)
361{
362 const struct ieee80211_if_managed *ifmgd = &sdata->u.mgd;
363
364 return snprintf(buf, buflen, "0x%x\n", ifmgd->uapsd_queues);
365}
366
367static ssize_t ieee80211_if_parse_uapsd_queues(
368 struct ieee80211_sub_if_data *sdata, const char *buf, int buflen)
369{
370 struct ieee80211_if_managed *ifmgd = &sdata->u.mgd;
371 u8 val;
372 int ret;
373
374 ret = kstrtou8(buf, 0, &val);
375 if (ret)
376 return ret;
377
378 if (val & ~IEEE80211_WMM_IE_STA_QOSINFO_AC_MASK)
379 return -ERANGE;
380
381 ifmgd->uapsd_queues = val;
382
383 return buflen;
384}
Johannes Berg4cd3c4e2014-01-06 15:47:15 +0100385IEEE80211_IF_FILE_RW(uapsd_queues);
Eliad Pellerdc41e4d2012-03-14 16:15:03 +0200386
387static ssize_t ieee80211_if_fmt_uapsd_max_sp_len(
388 const struct ieee80211_sub_if_data *sdata, char *buf, int buflen)
389{
390 const struct ieee80211_if_managed *ifmgd = &sdata->u.mgd;
391
392 return snprintf(buf, buflen, "0x%x\n", ifmgd->uapsd_max_sp_len);
393}
394
395static ssize_t ieee80211_if_parse_uapsd_max_sp_len(
396 struct ieee80211_sub_if_data *sdata, const char *buf, int buflen)
397{
398 struct ieee80211_if_managed *ifmgd = &sdata->u.mgd;
399 unsigned long val;
400 int ret;
401
402 ret = kstrtoul(buf, 0, &val);
403 if (ret)
404 return -EINVAL;
405
406 if (val & ~IEEE80211_WMM_IE_STA_QOSINFO_SP_MASK)
407 return -ERANGE;
408
409 ifmgd->uapsd_max_sp_len = val;
410
411 return buflen;
412}
Johannes Berg4cd3c4e2014-01-06 15:47:15 +0100413IEEE80211_IF_FILE_RW(uapsd_max_sp_len);
Eliad Pellerdc41e4d2012-03-14 16:15:03 +0200414
Jiri Bence9f207f2007-05-05 11:46:38 -0700415/* AP attributes */
Felix Fietkau030ef8f2012-04-23 19:49:02 +0200416IEEE80211_IF_FILE(num_mcast_sta, u.ap.num_mcast_sta, ATOMIC);
Marco Porschd012a602012-10-10 12:39:50 -0700417IEEE80211_IF_FILE(num_sta_ps, u.ap.ps.num_sta_ps, ATOMIC);
418IEEE80211_IF_FILE(dtim_count, u.ap.ps.dtim_count, DEC);
Jiri Bence9f207f2007-05-05 11:46:38 -0700419
420static ssize_t ieee80211_if_fmt_num_buffered_multicast(
421 const struct ieee80211_sub_if_data *sdata, char *buf, int buflen)
422{
423 return scnprintf(buf, buflen, "%u\n",
Marco Porschd012a602012-10-10 12:39:50 -0700424 skb_queue_len(&sdata->u.ap.ps.bc_buf));
Jiri Bence9f207f2007-05-05 11:46:38 -0700425}
Johannes Berg4cd3c4e2014-01-06 15:47:15 +0100426IEEE80211_IF_FILE_R(num_buffered_multicast);
Jiri Bence9f207f2007-05-05 11:46:38 -0700427
Eliad Peller37a41b42011-09-21 14:06:11 +0300428/* IBSS attributes */
429static ssize_t ieee80211_if_fmt_tsf(
430 const struct ieee80211_sub_if_data *sdata, char *buf, int buflen)
431{
432 struct ieee80211_local *local = sdata->local;
433 u64 tsf;
434
435 tsf = drv_get_tsf(local, (struct ieee80211_sub_if_data *)sdata);
436
437 return scnprintf(buf, buflen, "0x%016llx\n", (unsigned long long) tsf);
438}
439
440static ssize_t ieee80211_if_parse_tsf(
441 struct ieee80211_sub_if_data *sdata, const char *buf, int buflen)
442{
443 struct ieee80211_local *local = sdata->local;
444 unsigned long long tsf;
445 int ret;
Javier Cardona9bdd3a62012-03-31 11:31:31 -0700446 int tsf_is_delta = 0;
Eliad Peller37a41b42011-09-21 14:06:11 +0300447
448 if (strncmp(buf, "reset", 5) == 0) {
449 if (local->ops->reset_tsf) {
450 drv_reset_tsf(local, sdata);
451 wiphy_info(local->hw.wiphy, "debugfs reset TSF\n");
452 }
453 } else {
Javier Cardona9bdd3a62012-03-31 11:31:31 -0700454 if (buflen > 10 && buf[1] == '=') {
455 if (buf[0] == '+')
456 tsf_is_delta = 1;
457 else if (buf[0] == '-')
458 tsf_is_delta = -1;
459 else
460 return -EINVAL;
461 buf += 2;
462 }
Eliad Peller37a41b42011-09-21 14:06:11 +0300463 ret = kstrtoull(buf, 10, &tsf);
464 if (ret < 0)
Johannes Berg6fc1da92012-11-05 20:30:39 +0100465 return ret;
Javier Cardona9bdd3a62012-03-31 11:31:31 -0700466 if (tsf_is_delta)
467 tsf = drv_get_tsf(local, sdata) + tsf_is_delta * tsf;
Eliad Peller37a41b42011-09-21 14:06:11 +0300468 if (local->ops->set_tsf) {
469 drv_set_tsf(local, sdata, tsf);
470 wiphy_info(local->hw.wiphy,
471 "debugfs set TSF to %#018llx\n", tsf);
472 }
473 }
474
Thomas Pedersen057d5f42013-12-19 10:25:15 -0800475 ieee80211_recalc_dtim(local, sdata);
Eliad Peller37a41b42011-09-21 14:06:11 +0300476 return buflen;
477}
Johannes Berg4cd3c4e2014-01-06 15:47:15 +0100478IEEE80211_IF_FILE_RW(tsf);
Eliad Peller37a41b42011-09-21 14:06:11 +0300479
480
Jiri Bence9f207f2007-05-05 11:46:38 -0700481/* WDS attributes */
482IEEE80211_IF_FILE(peer, u.wds.remote_addr, MAC);
483
Luis Carlos Cobo9f42f602008-02-23 15:17:16 +0100484#ifdef CONFIG_MAC80211_MESH
Ashok Nagarajand4a5a482013-05-13 17:08:04 -0700485IEEE80211_IF_FILE(estab_plinks, u.mesh.estab_plinks, ATOMIC);
486
Luis Carlos Cobo9f42f602008-02-23 15:17:16 +0100487/* Mesh stats attributes */
Daniel Walkerc8a61a72009-08-18 10:59:00 -0700488IEEE80211_IF_FILE(fwded_mcast, u.mesh.mshstats.fwded_mcast, DEC);
489IEEE80211_IF_FILE(fwded_unicast, u.mesh.mshstats.fwded_unicast, DEC);
Johannes Berg472dbc42008-09-11 00:01:49 +0200490IEEE80211_IF_FILE(fwded_frames, u.mesh.mshstats.fwded_frames, DEC);
491IEEE80211_IF_FILE(dropped_frames_ttl, u.mesh.mshstats.dropped_frames_ttl, DEC);
Javier Cardonacfee66b2011-09-06 13:05:21 -0700492IEEE80211_IF_FILE(dropped_frames_congestion,
Chun-Yeow Yeoha4f606e2012-06-11 11:59:36 +0800493 u.mesh.mshstats.dropped_frames_congestion, DEC);
Luis Carlos Cobo9f42f602008-02-23 15:17:16 +0100494IEEE80211_IF_FILE(dropped_frames_no_route,
Chun-Yeow Yeoha4f606e2012-06-11 11:59:36 +0800495 u.mesh.mshstats.dropped_frames_no_route, DEC);
Luis Carlos Cobo9f42f602008-02-23 15:17:16 +0100496
497/* Mesh parameters */
Johannes Berg36ff3822008-10-07 12:04:31 +0200498IEEE80211_IF_FILE(dot11MeshMaxRetries,
Chun-Yeow Yeoha4f606e2012-06-11 11:59:36 +0800499 u.mesh.mshcfg.dot11MeshMaxRetries, DEC);
Johannes Berg36ff3822008-10-07 12:04:31 +0200500IEEE80211_IF_FILE(dot11MeshRetryTimeout,
Chun-Yeow Yeoha4f606e2012-06-11 11:59:36 +0800501 u.mesh.mshcfg.dot11MeshRetryTimeout, DEC);
Johannes Berg36ff3822008-10-07 12:04:31 +0200502IEEE80211_IF_FILE(dot11MeshConfirmTimeout,
Chun-Yeow Yeoha4f606e2012-06-11 11:59:36 +0800503 u.mesh.mshcfg.dot11MeshConfirmTimeout, DEC);
Johannes Berg36ff3822008-10-07 12:04:31 +0200504IEEE80211_IF_FILE(dot11MeshHoldingTimeout,
Chun-Yeow Yeoha4f606e2012-06-11 11:59:36 +0800505 u.mesh.mshcfg.dot11MeshHoldingTimeout, DEC);
Johannes Berg36ff3822008-10-07 12:04:31 +0200506IEEE80211_IF_FILE(dot11MeshTTL, u.mesh.mshcfg.dot11MeshTTL, DEC);
Javier Cardona45904f22010-12-03 09:20:40 +0100507IEEE80211_IF_FILE(element_ttl, u.mesh.mshcfg.element_ttl, DEC);
Johannes Berg36ff3822008-10-07 12:04:31 +0200508IEEE80211_IF_FILE(auto_open_plinks, u.mesh.mshcfg.auto_open_plinks, DEC);
509IEEE80211_IF_FILE(dot11MeshMaxPeerLinks,
Chun-Yeow Yeoha4f606e2012-06-11 11:59:36 +0800510 u.mesh.mshcfg.dot11MeshMaxPeerLinks, DEC);
Johannes Berg36ff3822008-10-07 12:04:31 +0200511IEEE80211_IF_FILE(dot11MeshHWMPactivePathTimeout,
Chun-Yeow Yeoha4f606e2012-06-11 11:59:36 +0800512 u.mesh.mshcfg.dot11MeshHWMPactivePathTimeout, DEC);
Johannes Berg36ff3822008-10-07 12:04:31 +0200513IEEE80211_IF_FILE(dot11MeshHWMPpreqMinInterval,
Chun-Yeow Yeoha4f606e2012-06-11 11:59:36 +0800514 u.mesh.mshcfg.dot11MeshHWMPpreqMinInterval, DEC);
Thomas Pedersendca7e942011-11-24 17:15:24 -0800515IEEE80211_IF_FILE(dot11MeshHWMPperrMinInterval,
Chun-Yeow Yeoha4f606e2012-06-11 11:59:36 +0800516 u.mesh.mshcfg.dot11MeshHWMPperrMinInterval, DEC);
Johannes Berg36ff3822008-10-07 12:04:31 +0200517IEEE80211_IF_FILE(dot11MeshHWMPnetDiameterTraversalTime,
Chun-Yeow Yeoha4f606e2012-06-11 11:59:36 +0800518 u.mesh.mshcfg.dot11MeshHWMPnetDiameterTraversalTime, DEC);
Johannes Berg36ff3822008-10-07 12:04:31 +0200519IEEE80211_IF_FILE(dot11MeshHWMPmaxPREQretries,
Chun-Yeow Yeoha4f606e2012-06-11 11:59:36 +0800520 u.mesh.mshcfg.dot11MeshHWMPmaxPREQretries, DEC);
Johannes Berg36ff3822008-10-07 12:04:31 +0200521IEEE80211_IF_FILE(path_refresh_time,
Chun-Yeow Yeoha4f606e2012-06-11 11:59:36 +0800522 u.mesh.mshcfg.path_refresh_time, DEC);
Johannes Berg36ff3822008-10-07 12:04:31 +0200523IEEE80211_IF_FILE(min_discovery_timeout,
Chun-Yeow Yeoha4f606e2012-06-11 11:59:36 +0800524 u.mesh.mshcfg.min_discovery_timeout, DEC);
Rui Paulo63c57232009-11-09 23:46:57 +0000525IEEE80211_IF_FILE(dot11MeshHWMPRootMode,
Chun-Yeow Yeoha4f606e2012-06-11 11:59:36 +0800526 u.mesh.mshcfg.dot11MeshHWMPRootMode, DEC);
Javier Cardona16dd7262011-08-09 16:45:11 -0700527IEEE80211_IF_FILE(dot11MeshGateAnnouncementProtocol,
Chun-Yeow Yeoha4f606e2012-06-11 11:59:36 +0800528 u.mesh.mshcfg.dot11MeshGateAnnouncementProtocol, DEC);
Javier Cardona0507e152011-08-09 16:45:10 -0700529IEEE80211_IF_FILE(dot11MeshHWMPRannInterval,
Chun-Yeow Yeoha4f606e2012-06-11 11:59:36 +0800530 u.mesh.mshcfg.dot11MeshHWMPRannInterval, DEC);
Chun-Yeow Yeoh94f90652012-01-21 01:02:16 +0800531IEEE80211_IF_FILE(dot11MeshForwarding, u.mesh.mshcfg.dot11MeshForwarding, DEC);
Ashok Nagarajan55335132012-02-28 17:04:08 -0800532IEEE80211_IF_FILE(rssi_threshold, u.mesh.mshcfg.rssi_threshold, DEC);
Ashok Nagarajan4416f5d2012-05-07 21:00:32 -0700533IEEE80211_IF_FILE(ht_opmode, u.mesh.mshcfg.ht_opmode, DEC);
Chun-Yeow Yeohac1073a2012-06-14 02:06:06 +0800534IEEE80211_IF_FILE(dot11MeshHWMPactivePathToRootTimeout,
535 u.mesh.mshcfg.dot11MeshHWMPactivePathToRootTimeout, DEC);
536IEEE80211_IF_FILE(dot11MeshHWMProotInterval,
537 u.mesh.mshcfg.dot11MeshHWMProotInterval, DEC);
Chun-Yeow Yeoh728b19e2012-06-14 02:06:10 +0800538IEEE80211_IF_FILE(dot11MeshHWMPconfirmationInterval,
539 u.mesh.mshcfg.dot11MeshHWMPconfirmationInterval, DEC);
Marco Porsch3f52b7e2013-01-30 18:14:08 +0100540IEEE80211_IF_FILE(power_mode, u.mesh.mshcfg.power_mode, DEC);
541IEEE80211_IF_FILE(dot11MeshAwakeWindowDuration,
542 u.mesh.mshcfg.dot11MeshAwakeWindowDuration, DEC);
Luis Carlos Cobo9f42f602008-02-23 15:17:16 +0100543#endif
544
Johannes Berg0f782312009-12-01 13:37:02 +0100545#define DEBUGFS_ADD_MODE(name, mode) \
Stanislaw Gruszkaddbfe862013-03-08 14:46:14 +0100546 debugfs_create_file(#name, mode, sdata->vif.debugfs_dir, \
Johannes Berg0f782312009-12-01 13:37:02 +0100547 sdata, &name##_ops);
548
Felix Fietkaufcb2c9e2012-03-18 22:58:05 +0100549#define DEBUGFS_ADD(name) DEBUGFS_ADD_MODE(name, 0400)
550
551static void add_common_files(struct ieee80211_sub_if_data *sdata)
Jiri Bence9f207f2007-05-05 11:46:38 -0700552{
Johannes Berg2d46d7c2010-01-10 17:12:41 +0100553 DEBUGFS_ADD(drop_unencrypted);
554 DEBUGFS_ADD(rc_rateidx_mask_2ghz);
555 DEBUGFS_ADD(rc_rateidx_mask_5ghz);
Simon Wunderlich19468412012-01-28 17:25:33 +0100556 DEBUGFS_ADD(rc_rateidx_mcs_mask_2ghz);
557 DEBUGFS_ADD(rc_rateidx_mcs_mask_5ghz);
Johannes Berg08643312012-11-08 15:29:28 +0100558 DEBUGFS_ADD(hw_queues);
Felix Fietkaufcb2c9e2012-03-18 22:58:05 +0100559}
Johannes Berg3e122be2008-07-09 14:40:34 +0200560
Felix Fietkaufcb2c9e2012-03-18 22:58:05 +0100561static void add_sta_files(struct ieee80211_sub_if_data *sdata)
562{
Johannes Berg2d46d7c2010-01-10 17:12:41 +0100563 DEBUGFS_ADD(bssid);
564 DEBUGFS_ADD(aid);
Jouni Malinen17e4ec12010-03-29 23:28:30 -0700565 DEBUGFS_ADD(last_beacon);
566 DEBUGFS_ADD(ave_beacon);
Ben Greear78e443e2013-03-25 11:19:34 -0700567 DEBUGFS_ADD(beacon_timeout);
Johannes Berg0f782312009-12-01 13:37:02 +0100568 DEBUGFS_ADD_MODE(smps, 0600);
Jouni Malinen681d1192011-02-03 18:35:19 +0200569 DEBUGFS_ADD_MODE(tkip_mic_test, 0200);
Eliad Pellerdc41e4d2012-03-14 16:15:03 +0200570 DEBUGFS_ADD_MODE(uapsd_queues, 0600);
571 DEBUGFS_ADD_MODE(uapsd_max_sp_len, 0600);
Jiri Bence9f207f2007-05-05 11:46:38 -0700572}
573
574static void add_ap_files(struct ieee80211_sub_if_data *sdata)
575{
Felix Fietkau030ef8f2012-04-23 19:49:02 +0200576 DEBUGFS_ADD(num_mcast_sta);
Emmanuel Grumbach687da132013-10-01 16:45:43 +0300577 DEBUGFS_ADD_MODE(smps, 0600);
Johannes Berg2d46d7c2010-01-10 17:12:41 +0100578 DEBUGFS_ADD(num_sta_ps);
579 DEBUGFS_ADD(dtim_count);
580 DEBUGFS_ADD(num_buffered_multicast);
Jouni Malinen681d1192011-02-03 18:35:19 +0200581 DEBUGFS_ADD_MODE(tkip_mic_test, 0200);
Jiri Bence9f207f2007-05-05 11:46:38 -0700582}
583
Eliad Peller37a41b42011-09-21 14:06:11 +0300584static void add_ibss_files(struct ieee80211_sub_if_data *sdata)
585{
586 DEBUGFS_ADD_MODE(tsf, 0600);
587}
588
Jiri Bence9f207f2007-05-05 11:46:38 -0700589static void add_wds_files(struct ieee80211_sub_if_data *sdata)
590{
Johannes Berg2d46d7c2010-01-10 17:12:41 +0100591 DEBUGFS_ADD(peer);
Jiri Bence9f207f2007-05-05 11:46:38 -0700592}
593
Luis Carlos Cobo9f42f602008-02-23 15:17:16 +0100594#ifdef CONFIG_MAC80211_MESH
Luis Carlos Cobo9f42f602008-02-23 15:17:16 +0100595
Javier Cardona12ce8ba2012-03-05 17:20:38 -0800596static void add_mesh_files(struct ieee80211_sub_if_data *sdata)
597{
598 DEBUGFS_ADD_MODE(tsf, 0600);
Ashok Nagarajand4a5a482013-05-13 17:08:04 -0700599 DEBUGFS_ADD_MODE(estab_plinks, 0400);
Javier Cardona12ce8ba2012-03-05 17:20:38 -0800600}
601
Luis Carlos Cobo9f42f602008-02-23 15:17:16 +0100602static void add_mesh_stats(struct ieee80211_sub_if_data *sdata)
603{
Johannes Berg7bcfaf22009-10-27 12:59:03 +0100604 struct dentry *dir = debugfs_create_dir("mesh_stats",
Stanislaw Gruszkaddbfe862013-03-08 14:46:14 +0100605 sdata->vif.debugfs_dir);
Johannes Berg7bcfaf22009-10-27 12:59:03 +0100606#define MESHSTATS_ADD(name)\
607 debugfs_create_file(#name, 0400, dir, sdata, &name##_ops);
608
Daniel Walkerc8a61a72009-08-18 10:59:00 -0700609 MESHSTATS_ADD(fwded_mcast);
610 MESHSTATS_ADD(fwded_unicast);
Luis Carlos Cobo9f42f602008-02-23 15:17:16 +0100611 MESHSTATS_ADD(fwded_frames);
612 MESHSTATS_ADD(dropped_frames_ttl);
613 MESHSTATS_ADD(dropped_frames_no_route);
Javier Cardonacfee66b2011-09-06 13:05:21 -0700614 MESHSTATS_ADD(dropped_frames_congestion);
Johannes Berg7bcfaf22009-10-27 12:59:03 +0100615#undef MESHSTATS_ADD
Luis Carlos Cobo9f42f602008-02-23 15:17:16 +0100616}
617
Luis Carlos Cobo9f42f602008-02-23 15:17:16 +0100618static void add_mesh_config(struct ieee80211_sub_if_data *sdata)
619{
Johannes Berg7bcfaf22009-10-27 12:59:03 +0100620 struct dentry *dir = debugfs_create_dir("mesh_config",
Stanislaw Gruszkaddbfe862013-03-08 14:46:14 +0100621 sdata->vif.debugfs_dir);
Johannes Berg7bcfaf22009-10-27 12:59:03 +0100622
623#define MESHPARAMS_ADD(name) \
624 debugfs_create_file(#name, 0600, dir, sdata, &name##_ops);
625
Luis Carlos Cobo9f42f602008-02-23 15:17:16 +0100626 MESHPARAMS_ADD(dot11MeshMaxRetries);
627 MESHPARAMS_ADD(dot11MeshRetryTimeout);
628 MESHPARAMS_ADD(dot11MeshConfirmTimeout);
629 MESHPARAMS_ADD(dot11MeshHoldingTimeout);
630 MESHPARAMS_ADD(dot11MeshTTL);
Javier Cardona45904f22010-12-03 09:20:40 +0100631 MESHPARAMS_ADD(element_ttl);
Luis Carlos Cobo9f42f602008-02-23 15:17:16 +0100632 MESHPARAMS_ADD(auto_open_plinks);
633 MESHPARAMS_ADD(dot11MeshMaxPeerLinks);
634 MESHPARAMS_ADD(dot11MeshHWMPactivePathTimeout);
635 MESHPARAMS_ADD(dot11MeshHWMPpreqMinInterval);
Thomas Pedersendca7e942011-11-24 17:15:24 -0800636 MESHPARAMS_ADD(dot11MeshHWMPperrMinInterval);
Luis Carlos Cobo9f42f602008-02-23 15:17:16 +0100637 MESHPARAMS_ADD(dot11MeshHWMPnetDiameterTraversalTime);
638 MESHPARAMS_ADD(dot11MeshHWMPmaxPREQretries);
639 MESHPARAMS_ADD(path_refresh_time);
640 MESHPARAMS_ADD(min_discovery_timeout);
Javier Cardona699403d2011-08-09 16:45:09 -0700641 MESHPARAMS_ADD(dot11MeshHWMPRootMode);
Javier Cardona0507e152011-08-09 16:45:10 -0700642 MESHPARAMS_ADD(dot11MeshHWMPRannInterval);
Chun-Yeow Yeoh8c06e8c2012-05-31 18:17:30 +0800643 MESHPARAMS_ADD(dot11MeshForwarding);
Javier Cardona16dd7262011-08-09 16:45:11 -0700644 MESHPARAMS_ADD(dot11MeshGateAnnouncementProtocol);
Ashok Nagarajan55335132012-02-28 17:04:08 -0800645 MESHPARAMS_ADD(rssi_threshold);
Ashok Nagarajan4416f5d2012-05-07 21:00:32 -0700646 MESHPARAMS_ADD(ht_opmode);
Chun-Yeow Yeohac1073a2012-06-14 02:06:06 +0800647 MESHPARAMS_ADD(dot11MeshHWMPactivePathToRootTimeout);
648 MESHPARAMS_ADD(dot11MeshHWMProotInterval);
Chun-Yeow Yeoh728b19e2012-06-14 02:06:10 +0800649 MESHPARAMS_ADD(dot11MeshHWMPconfirmationInterval);
Marco Porsch3f52b7e2013-01-30 18:14:08 +0100650 MESHPARAMS_ADD(power_mode);
651 MESHPARAMS_ADD(dot11MeshAwakeWindowDuration);
Johannes Berg7bcfaf22009-10-27 12:59:03 +0100652#undef MESHPARAMS_ADD
Luis Carlos Cobo9f42f602008-02-23 15:17:16 +0100653}
654#endif
655
Jiri Bence9f207f2007-05-05 11:46:38 -0700656static void add_files(struct ieee80211_sub_if_data *sdata)
657{
Stanislaw Gruszkaddbfe862013-03-08 14:46:14 +0100658 if (!sdata->vif.debugfs_dir)
Jiri Bence9f207f2007-05-05 11:46:38 -0700659 return;
660
Felix Fietkaufcb2c9e2012-03-18 22:58:05 +0100661 DEBUGFS_ADD(flags);
662 DEBUGFS_ADD(state);
Johannes Berg1ea6f9c2012-10-24 10:59:25 +0200663 DEBUGFS_ADD(txpower);
664 DEBUGFS_ADD(user_power_level);
665 DEBUGFS_ADD(ap_power_level);
Felix Fietkaufcb2c9e2012-03-18 22:58:05 +0100666
667 if (sdata->vif.type != NL80211_IFTYPE_MONITOR)
668 add_common_files(sdata);
669
Johannes Berg51fb61e2007-12-19 01:31:27 +0100670 switch (sdata->vif.type) {
Johannes Berg05c914f2008-09-11 00:01:58 +0200671 case NL80211_IFTYPE_MESH_POINT:
Luis Carlos Cobo9f42f602008-02-23 15:17:16 +0100672#ifdef CONFIG_MAC80211_MESH
Javier Cardona12ce8ba2012-03-05 17:20:38 -0800673 add_mesh_files(sdata);
Luis Carlos Cobo9f42f602008-02-23 15:17:16 +0100674 add_mesh_stats(sdata);
675 add_mesh_config(sdata);
676#endif
Johannes Berg472dbc42008-09-11 00:01:49 +0200677 break;
Johannes Berg05c914f2008-09-11 00:01:58 +0200678 case NL80211_IFTYPE_STATION:
Jiri Bence9f207f2007-05-05 11:46:38 -0700679 add_sta_files(sdata);
680 break;
Johannes Berg46900292009-02-15 12:44:28 +0100681 case NL80211_IFTYPE_ADHOC:
Eliad Peller37a41b42011-09-21 14:06:11 +0300682 add_ibss_files(sdata);
Johannes Berg46900292009-02-15 12:44:28 +0100683 break;
Johannes Berg05c914f2008-09-11 00:01:58 +0200684 case NL80211_IFTYPE_AP:
Jiri Bence9f207f2007-05-05 11:46:38 -0700685 add_ap_files(sdata);
686 break;
Johannes Berg05c914f2008-09-11 00:01:58 +0200687 case NL80211_IFTYPE_WDS:
Jiri Bence9f207f2007-05-05 11:46:38 -0700688 add_wds_files(sdata);
689 break;
Jiri Bence9f207f2007-05-05 11:46:38 -0700690 default:
691 break;
692 }
693}
694
Jiri Bence9f207f2007-05-05 11:46:38 -0700695void ieee80211_debugfs_add_netdev(struct ieee80211_sub_if_data *sdata)
696{
697 char buf[10+IFNAMSIZ];
698
Johannes Berg47846c92009-11-25 17:46:19 +0100699 sprintf(buf, "netdev:%s", sdata->name);
Stanislaw Gruszkaddbfe862013-03-08 14:46:14 +0100700 sdata->vif.debugfs_dir = debugfs_create_dir(buf,
Jiri Bence9f207f2007-05-05 11:46:38 -0700701 sdata->local->hw.wiphy->debugfsdir);
Stanislaw Gruszkaddbfe862013-03-08 14:46:14 +0100702 if (sdata->vif.debugfs_dir)
Ben Greear295bafb2010-09-22 20:29:01 -0700703 sdata->debugfs.subdir_stations = debugfs_create_dir("stations",
Stanislaw Gruszkaddbfe862013-03-08 14:46:14 +0100704 sdata->vif.debugfs_dir);
Johannes Berg75636522008-07-09 14:40:35 +0200705 add_files(sdata);
Jiri Bence9f207f2007-05-05 11:46:38 -0700706}
707
708void ieee80211_debugfs_remove_netdev(struct ieee80211_sub_if_data *sdata)
709{
Stanislaw Gruszkaddbfe862013-03-08 14:46:14 +0100710 if (!sdata->vif.debugfs_dir)
Johannes Berg7bcfaf22009-10-27 12:59:03 +0100711 return;
712
Stanislaw Gruszkaddbfe862013-03-08 14:46:14 +0100713 debugfs_remove_recursive(sdata->vif.debugfs_dir);
714 sdata->vif.debugfs_dir = NULL;
Jiri Bence9f207f2007-05-05 11:46:38 -0700715}
716
Johannes Berg47846c92009-11-25 17:46:19 +0100717void ieee80211_debugfs_rename_netdev(struct ieee80211_sub_if_data *sdata)
Jiri Bence9f207f2007-05-05 11:46:38 -0700718{
Johannes Berg7c8081e2007-06-21 18:30:19 +0200719 struct dentry *dir;
Johannes Berg47846c92009-11-25 17:46:19 +0100720 char buf[10 + IFNAMSIZ];
Johannes Berg3e122be2008-07-09 14:40:34 +0200721
Stanislaw Gruszkaddbfe862013-03-08 14:46:14 +0100722 dir = sdata->vif.debugfs_dir;
Johannes Bergc74e90a2008-10-08 10:18:36 +0200723
724 if (!dir)
Johannes Berg47846c92009-11-25 17:46:19 +0100725 return;
Johannes Bergc74e90a2008-10-08 10:18:36 +0200726
Johannes Berg47846c92009-11-25 17:46:19 +0100727 sprintf(buf, "netdev:%s", sdata->name);
Johannes Berg7c8081e2007-06-21 18:30:19 +0200728 if (!debugfs_rename(dir->d_parent, dir, dir->d_parent, buf))
Johannes Bergbdcbd8e2012-06-22 11:29:50 +0200729 sdata_err(sdata,
730 "debugfs: failed to rename debugfs dir to %s\n",
731 buf);
Jiri Bence9f207f2007-05-05 11:46:38 -0700732}