Skip to content

Commit 1ac6130

Browse files
Luis R. Rodriguezlinvjw
authored andcommitted
mac80211/cfg80211: move wiphy specific debugfs entries to cfg80211
This moves the cfg80211 specific stuff to new cfg80211 debugfs entries. Non-mac80211 will also get these entries now. There were only 4 which we take: rts_threshold fragmentation_threshold short_retry_limit long_retry_limit Signed-off-by: Luis R. Rodriguez <lrodriguez@atheros.com> Signed-off-by: John W. Linville <linville@tuxdriver.com>
1 parent 294196a commit 1ac6130

8 files changed

Lines changed: 109 additions & 20 deletions

File tree

‎net/mac80211/debugfs.c‎

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -52,14 +52,6 @@ static const struct file_operations name## _ops = { \
5252

5353
DEBUGFS_READONLY_FILE(frequency, 20, "%d",
5454
local->hw.conf.channel->center_freq);
55-
DEBUGFS_READONLY_FILE(rts_threshold, 20, "%d",
56-
local->hw.wiphy->rts_threshold);
57-
DEBUGFS_READONLY_FILE(fragmentation_threshold, 20, "%d",
58-
local->hw.wiphy->frag_threshold);
59-
DEBUGFS_READONLY_FILE(short_retry_limit, 20, "%d",
60-
local->hw.wiphy->retry_short);
61-
DEBUGFS_READONLY_FILE(long_retry_limit, 20, "%d",
62-
local->hw.wiphy->retry_long);
6355
DEBUGFS_READONLY_FILE(total_ps_buffered, 20, "%d",
6456
local->total_ps_buffered);
6557
DEBUGFS_READONLY_FILE(wep_iv, 20, "%#08x",
@@ -303,10 +295,6 @@ void debugfs_hw_add(struct ieee80211_local *local)
303295
local->debugfs.keys = debugfs_create_dir("keys", phyd);
304296

305297
DEBUGFS_ADD(frequency);
306-
DEBUGFS_ADD(rts_threshold);
307-
DEBUGFS_ADD(fragmentation_threshold);
308-
DEBUGFS_ADD(short_retry_limit);
309-
DEBUGFS_ADD(long_retry_limit);
310298
DEBUGFS_ADD(total_ps_buffered);
311299
DEBUGFS_ADD(wep_iv);
312300
DEBUGFS_ADD(tsf);
@@ -359,10 +347,6 @@ void debugfs_hw_add(struct ieee80211_local *local)
359347
void debugfs_hw_del(struct ieee80211_local *local)
360348
{
361349
DEBUGFS_DEL(frequency);
362-
DEBUGFS_DEL(rts_threshold);
363-
DEBUGFS_DEL(fragmentation_threshold);
364-
DEBUGFS_DEL(short_retry_limit);
365-
DEBUGFS_DEL(long_retry_limit);
366350
DEBUGFS_DEL(total_ps_buffered);
367351
DEBUGFS_DEL(wep_iv);
368352
DEBUGFS_DEL(tsf);

‎net/mac80211/ieee80211_i.h‎

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -758,10 +758,6 @@ struct ieee80211_local {
758758
struct dentry *rcdir;
759759
struct dentry *rcname;
760760
struct dentry *frequency;
761-
struct dentry *rts_threshold;
762-
struct dentry *fragmentation_threshold;
763-
struct dentry *short_retry_limit;
764-
struct dentry *long_retry_limit;
765761
struct dentry *total_ps_buffered;
766762
struct dentry *wep_iv;
767763
struct dentry *tsf;

‎net/wireless/Kconfig‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,14 @@ config CFG80211_REG_DEBUG
1010

1111
If unsure, say N.
1212

13+
config CFG80211_DEBUGFS
14+
bool "cfg80211 DebugFS entries"
15+
depends on CFG80211 && DEBUG_FS
16+
---help---
17+
You can enable this if you want to debugfs entries for cfg80211.
18+
19+
If unsure, say N.
20+
1321
config WIRELESS_OLD_REGULATORY
1422
bool "Old wireless static regulatory definitions"
1523
default n

‎net/wireless/Makefile‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ obj-$(CONFIG_LIB80211_CRYPT_CCMP) += lib80211_crypt_ccmp.o
66
obj-$(CONFIG_LIB80211_CRYPT_TKIP) += lib80211_crypt_tkip.o
77

88
cfg80211-y += core.o sysfs.o radiotap.o util.o reg.o scan.o nl80211.o mlme.o ibss.o
9+
cfg80211-$(CONFIG_CFG80211_DEBUGFS) += debugfs.o
910
cfg80211-$(CONFIG_WIRELESS_EXT) += wext-compat.o
1011

1112
ccflags-y += -D__CHECK_ENDIAN__

‎net/wireless/core.c‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
#include "nl80211.h"
1818
#include "core.h"
1919
#include "sysfs.h"
20+
#include "debugfs.h"
2021

2122
/* name for sysfs, %d is appended */
2223
#define PHY_NAME "phy"
@@ -375,6 +376,8 @@ int wiphy_register(struct wiphy *wiphy)
375376
nl80211_send_reg_change_event(&request);
376377
}
377378

379+
cfg80211_debugfs_drv_add(drv);
380+
378381
res = 0;
379382
out_unlock:
380383
mutex_unlock(&cfg80211_mutex);
@@ -405,6 +408,8 @@ void wiphy_unregister(struct wiphy *wiphy)
405408
/* unlock again before freeing */
406409
mutex_unlock(&drv->mtx);
407410

411+
cfg80211_debugfs_drv_del(drv);
412+
408413
/* If this device got a regulatory hint tell core its
409414
* free to listen now to a new shiny device regulatory hint */
410415
reg_device_remove(wiphy);

‎net/wireless/core.h‎

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
#include <linux/netdevice.h>
1111
#include <linux/kref.h>
1212
#include <linux/rbtree.h>
13+
#include <linux/debugfs.h>
1314
#include <net/genetlink.h>
1415
#include <net/cfg80211.h>
1516
#include "reg.h"
@@ -50,6 +51,16 @@ struct cfg80211_registered_device {
5051
struct cfg80211_scan_request *scan_req; /* protected by RTNL */
5152
unsigned long suspend_at;
5253

54+
#ifdef CONFIG_MAC80211_DEBUGFS
55+
/* Debugfs entries */
56+
struct wiphy_debugfsdentries {
57+
struct dentry *rts_threshold;
58+
struct dentry *fragmentation_threshold;
59+
struct dentry *short_retry_limit;
60+
struct dentry *long_retry_limit;
61+
} debugfs;
62+
#endif
63+
5364
/* must be last because of the way we do wiphy_priv(),
5465
* and it should at least be aligned to NETDEV_ALIGN */
5566
struct wiphy wiphy __attribute__((__aligned__(NETDEV_ALIGN)));

‎net/wireless/debugfs.c‎

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
/*
2+
* cfg80211 debugfs
3+
*
4+
* Copyright 2009 Luis R. Rodriguez <lrodriguez@atheros.com>
5+
* Copyright 2007 Johannes Berg <johannes@sipsolutions.net>
6+
*
7+
* This program is free software; you can redistribute it and/or modify
8+
* it under the terms of the GNU General Public License version 2 as
9+
* published by the Free Software Foundation.
10+
*/
11+
12+
#include "core.h"
13+
#include "debugfs.h"
14+
15+
static int cfg80211_open_file_generic(struct inode *inode, struct file *file)
16+
{
17+
file->private_data = inode->i_private;
18+
return 0;
19+
}
20+
21+
#define DEBUGFS_READONLY_FILE(name, buflen, fmt, value...) \
22+
static ssize_t name## _read(struct file *file, char __user *userbuf, \
23+
size_t count, loff_t *ppos) \
24+
{ \
25+
struct wiphy *wiphy= file->private_data; \
26+
char buf[buflen]; \
27+
int res; \
28+
\
29+
res = scnprintf(buf, buflen, fmt "\n", ##value); \
30+
return simple_read_from_buffer(userbuf, count, ppos, buf, res); \
31+
} \
32+
\
33+
static const struct file_operations name## _ops = { \
34+
.read = name## _read, \
35+
.open = cfg80211_open_file_generic, \
36+
};
37+
38+
DEBUGFS_READONLY_FILE(rts_threshold, 20, "%d",
39+
wiphy->rts_threshold)
40+
DEBUGFS_READONLY_FILE(fragmentation_threshold, 20, "%d",
41+
wiphy->frag_threshold);
42+
DEBUGFS_READONLY_FILE(short_retry_limit, 20, "%d",
43+
wiphy->retry_short)
44+
DEBUGFS_READONLY_FILE(long_retry_limit, 20, "%d",
45+
wiphy->retry_long);
46+
47+
#define DEBUGFS_ADD(name) \
48+
drv->debugfs.name = debugfs_create_file(#name, S_IRUGO, phyd, \
49+
&drv->wiphy, &name## _ops);
50+
#define DEBUGFS_DEL(name) \
51+
debugfs_remove(drv->debugfs.name); \
52+
drv->debugfs.name = NULL;
53+
54+
void cfg80211_debugfs_drv_add(struct cfg80211_registered_device *drv)
55+
{
56+
struct dentry *phyd = drv->wiphy.debugfsdir;
57+
58+
DEBUGFS_ADD(rts_threshold);
59+
DEBUGFS_ADD(fragmentation_threshold);
60+
DEBUGFS_ADD(short_retry_limit);
61+
DEBUGFS_ADD(long_retry_limit);
62+
}
63+
64+
void cfg80211_debugfs_drv_del(struct cfg80211_registered_device *drv)
65+
{
66+
DEBUGFS_DEL(rts_threshold);
67+
DEBUGFS_DEL(fragmentation_threshold);
68+
DEBUGFS_DEL(short_retry_limit);
69+
DEBUGFS_DEL(long_retry_limit);
70+
}

‎net/wireless/debugfs.h‎

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#ifndef __CFG80211_DEBUGFS_H
2+
#define __CFG80211_DEBUGFS_H
3+
4+
#ifdef CONFIG_CFG80211_DEBUGFS
5+
void cfg80211_debugfs_drv_add(struct cfg80211_registered_device *drv);
6+
void cfg80211_debugfs_drv_del(struct cfg80211_registered_device *drv);
7+
#else
8+
static inline
9+
void cfg80211_debugfs_drv_add(struct cfg80211_registered_device *drv) {}
10+
static inline
11+
void cfg80211_debugfs_drv_del(struct cfg80211_registered_device *drv) {}
12+
#endif
13+
14+
#endif /* __CFG80211_DEBUGFS_H */

0 commit comments

Comments
 (0)