Skip to contentSkip to conversation

move everything in mac80211 from sysfs to debugfs

PATCH Applied [email protected] 2 participants 6 messages Mar 7, 2007 – Mar 23, 2007 mac80211

lore
Share & tools
lore

[email protected]

author maintainer
#0 lore raw

cover move everything in mac80211 from sysfs to debugfs

In order to not export internal details via sysfs (which is a userspace ABI) this patch series moves everything from sysfs into debugfs.

There's still the problem with following renames in debugfs, but the code is almost there so we only need to change two lines of code once we get debugfs_rename().

Over the previously posted series this fixes a small bug with a key's station symlink, introduces a new configuration symbol for the debugfs interface and fixes a few other bugs for the compiling-without-debugfs case.

I've now tested this in station mode with and without encryption and in hostap mode.

johannes

author maintainer
#1 lore raw

PATCH 1/4 mac80211: move PHY things to debugfs

This patch moves everything except the "sta" and "key" directories from the phy sysfs to phy debugfs. Since the current rate control algorithm isn't using any global sysfs entries it also removes the ability for a rate control algorithm to do so. That can be re-added to debugfs when necessary.

---
 net/mac80211/Makefile          |    1 
 net/mac80211/debugfs.c         |  429 +++++++++++++++++++++++++++++++++++++++++
 net/mac80211/debugfs.h         |   15 +
 net/mac80211/ieee80211.c       |   20 -
 net/mac80211/ieee80211_i.h     |   62 +++++
 net/mac80211/ieee80211_rate.h  |   15 -
 net/mac80211/ieee80211_sysfs.c |  375 -----------------------------------
 net/mac80211/ieee80211_sysfs.h |    2 
 8 files changed, 511 insertions(+), 408 deletions(-)
net/mac80211/Makefile +1 -0
@@ -1,6 +1,7 @@
 obj-$(CONFIG_MAC80211) += mac80211.o rc80211_simple.o
 
 mac80211-objs-$(CONFIG_MAC80211_LEDS) += ieee80211_led.o
+mac80211-objs-$(CONFIG_DEBUG_FS) += debugfs.o
 
 mac80211-objs := \
 	ieee80211.o \
net/mac80211/ieee80211.c +4 -16
@@ -34,6 +34,7 @@
 #include "ieee80211_led.h"
 #include "ieee80211_cfg.h"
 #include "ieee80211_sysfs.h"
+#include "debugfs.h"
 
 /* See IEEE 802.1H for LLC/SNAP encapsulation/decapsulation */
 /* Ethernet-II snap header (RFC1042 for most EtherTypes) */
@@ -4444,7 +4445,6 @@ int ieee80211_init_rate_ctrl_alg(struct 
 				 const char *name)
 {
 	struct rate_control_ref *ref, *old;
-	int res;
 
 	ASSERT_RTNL();
 	if (local->open_count || netif_running(local->mdev) ||
@@ -4457,18 +4457,10 @@ int ieee80211_init_rate_ctrl_alg(struct 
 		       "algorithm\n", local->mdev->name);
 		return -ENOENT;
 	}
-	res = rate_control_add_attrs(ref, &local->hw.wiphy->dev.kobj);
-	if (res < 0) {
-		printk(KERN_DEBUG "%s: Failed to register sysfs attributes "
-		       "for rate control\n", local->mdev->name);
-		rate_control_put(ref);
-		return res;
-	}
 
 	old = local->rate_ctrl;
 	local->rate_ctrl = ref;
 	if (old) {
-		rate_control_remove_attrs(ref, &local->hw.wiphy->dev.kobj);
 		rate_control_put(old);
 		sta_info_flush(local, NULL);
 	}
@@ -4487,7 +4479,6 @@ static void rate_control_deinitialize(st
 
 	ref = local->rate_ctrl;
 	local->rate_ctrl = NULL;
-	rate_control_remove_attrs(ref, &local->hw.wiphy->dev.kobj);
 	rate_control_put(ref);
 }
 
@@ -4622,9 +4613,7 @@ int ieee80211_register_hw(struct ieee802
 	if (result < 0)
 		return result;
 
-	result = ieee80211_dev_sysfs_add(local);
-	if (result < 0)
-		goto fail_sysfs;
+	debugfs_hw_add(local);
 
 	local->hw.conf.beacon_int = 1000;
 
@@ -4703,8 +4692,7 @@ fail_if_sysfs:
 fail_dev:
 	sta_info_stop(local);
 fail_sta_info:
-	ieee80211_dev_sysfs_del(local);
-fail_sysfs:
+	debugfs_hw_del(local);
 	wiphy_unregister(local->hw.wiphy);
 	return result;
 }
@@ -4777,7 +4765,7 @@ void ieee80211_unregister_hw(struct ieee
 	ieee80211_clear_tx_pending(local);
 	sta_info_stop(local);
 	rate_control_deinitialize(local);
-	ieee80211_dev_sysfs_del(local);
+	debugfs_hw_del(local);
 
 	for (i = 0; i < NUM_IEEE80211_MODES; i++) {
 		kfree(local->supp_rates[i]);
net/mac80211/ieee80211_rate.h +0 -15
@@ -123,21 +123,6 @@ static inline void rate_control_free_sta
 	ref->ops->free_sta(ref->priv, priv);
 }
 
-static inline int rate_control_add_attrs(struct rate_control_ref *ref,
-					 struct kobject *kobj)
-{
-	if (ref->ops->add_attrs)
-		return ref->ops->add_attrs(ref->priv, kobj);
-	return 0;
-}
-
-static inline void rate_control_remove_attrs(struct rate_control_ref *ref,
-					     struct kobject *kobj)
-{
-	if (ref->ops->remove_attrs)
-		ref->ops->remove_attrs(ref->priv, kobj);
-}
-
 static inline int rate_control_add_sta_attrs(struct sta_info *sta,
 					     struct kobject *kobj)
 {
net/mac80211/debugfs.h new file +15 -0
@@ -0,0 +1,15 @@
+#ifndef __MAC80211_DEBUGFS_H
+#define __MAC80211_DEBUGFS_H
+
+#ifdef CONFIG_DEBUG_FS
+extern void debugfs_hw_add(struct ieee80211_local *local);
+extern void debugfs_hw_del(struct ieee80211_local *local);
+#else
+static inline void debugfs_hw_add(struct ieee80211_local *local)
+{
+	return;
+}
+static inline void debugfs_hw_del(struct ieee80211_local *local) {}
+#endif
+
+#endif /* __MAC80211_DEBUGFS_H */
net/mac80211/ieee80211_sysfs.c +0 -375

387 lines not on this page · raw message

net/mac80211/ieee80211_sysfs.h +0 -2
@@ -6,7 +6,5 @@
 int ieee80211_sysfs_add_netdevice(struct net_device *dev);
 void ieee80211_sysfs_remove_netdevice(struct net_device *dev);
 int ieee80211_sysfs_change_if_type(struct net_device *dev);
-int ieee80211_dev_sysfs_add(struct ieee80211_local *local);
-void ieee80211_dev_sysfs_del(struct ieee80211_local *local);
 
 #endif /* __IEEE80211_SYSFS_H */
net/mac80211/debugfs.c new file +429 -0

429 lines not on this page · raw message

net/mac80211/ieee80211_i.h +62 -0

68 lines not on this page · raw message

--

author maintainer
#2 lore raw

PATCH 2/4 mac80211: move sta dir to debugfs

In reply to [email protected]

This patch moves the "sta" dir to a new debugfs dir "stations".

---
 net/mac80211/Makefile              |    4 
 net/mac80211/debugfs.c             |    6 
 net/mac80211/debugfs.h             |    1 
 net/mac80211/debugfs_sta.c         |  242 ++++++++++++++++++++
 net/mac80211/debugfs_sta.h         |   12 +
 net/mac80211/ieee80211.c           |    1 
 net/mac80211/ieee80211_i.h         |   15 -
 net/mac80211/ieee80211_ioctl.c     |    4 
 net/mac80211/ieee80211_rate.h      |   29 +-
 net/mac80211/ieee80211_sysfs.c     |    1 
 net/mac80211/ieee80211_sysfs_sta.c |  439 -------------------------------------
 net/mac80211/key_sysfs.c           |  217 ++++++++++++++++++
 net/mac80211/key_sysfs.h           |   12 +
 net/mac80211/rc80211_simple.c      |   82 ++++--
 net/mac80211/sta_info.c            |   55 +---
 net/mac80211/sta_info.h            |   18 +
 16 files changed, 602 insertions(+), 536 deletions(-)
net/mac80211/ieee80211_sysfs_sta.c deleted +0 -439
@@ -1,439 +0,0 @@
-/*
- * Copyright 2003-2005, Devicescape Software, Inc.
- * Copyright (c) 2006 Jiri Benc <[email protected]>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 as
- * published by the Free Software Foundation.
- */
-
-#include <linux/kobject.h>
-#include <linux/sysfs.h>
-#include "ieee80211_i.h"
-#include "ieee80211_key.h"
-#include "sta_info.h"
-
-static ssize_t sta_sysfs_show(struct kobject *, struct attribute *, char *);
-static ssize_t key_sysfs_show(struct kobject *, struct attribute *, char *);
-
-static struct sysfs_ops sta_ktype_ops = {
-	.show = sta_sysfs_show,
-};
-
-static struct sysfs_ops key_ktype_ops = {
-	.show = key_sysfs_show,
-};
-
-/* sta attributtes */
-
-#define STA_SHOW(name, field, format_string)				\
-static ssize_t show_sta_##name(const struct sta_info *sta, char *buf)	\
-{									\
-	return sprintf(buf, format_string, sta->field);			\
-}
-#define STA_SHOW_D(name, field) STA_SHOW(name, field, "%d\n")
-#define STA_SHOW_U(name, field) STA_SHOW(name, field, "%u\n")
-#define STA_SHOW_LU(name, field) STA_SHOW(name, field, "%lu\n")
-#define STA_SHOW_S(name, field) STA_SHOW(name, field, "%s\n")
-
-#define STA_SHOW_RATE(name, field)					\
-static ssize_t show_sta_##name(const struct sta_info *sta, char *buf)	\
-{									\
-	struct ieee80211_local *local = wdev_priv(sta->dev->ieee80211_ptr);\
-	struct ieee80211_hw_mode *mode = local->oper_hw_mode;		\
-	return sprintf(buf, "%d\n",					\
-		       (sta->field >= 0 &&				\
-			sta->field < mode->num_rates) ?			\
-		       mode->rates[sta->field].rate : -1);		\
-}
-
-#define __STA_ATTR(name)						\
-static struct sta_attribute sta_attr_##name =				\
-	__ATTR(name, S_IRUGO, show_sta_##name, NULL)
-
-#define STA_ATTR(name, field, format)					\
-		STA_SHOW_##format(name, field)				\
-		__STA_ATTR(name)
-
-STA_ATTR(aid, aid, D);
-STA_ATTR(key_idx_compression, key_idx_compression, D);
-STA_ATTR(dev, dev->name, S);
-STA_ATTR(vlan_id, vlan_id, D);
-STA_ATTR(rx_packets, rx_packets, LU);
-STA_ATTR(tx_packets, tx_packets, LU);
-STA_ATTR(rx_bytes, rx_bytes, LU);
-STA_ATTR(tx_bytes, tx_bytes, LU);
-STA_ATTR(rx_duplicates, num_duplicates, LU);
-STA_ATTR(rx_fragments, rx_fragments, LU);
-STA_ATTR(rx_dropped, rx_dropped, LU);
-STA_ATTR(tx_fragments, tx_fragments, LU);
-STA_ATTR(tx_filtered, tx_filtered_count, LU);
-STA_ATTR(txrate, txrate, RATE);
-STA_ATTR(last_txrate, last_txrate, RATE);
-STA_ATTR(tx_retry_failed, tx_retry_failed, LU);
-STA_ATTR(tx_retry_count, tx_retry_count, LU);
-STA_ATTR(last_rssi, last_rssi, D);
-STA_ATTR(last_signal, last_signal, D);
-STA_ATTR(last_noise, last_noise, D);
-STA_ATTR(channel_use, channel_use, D);
-STA_ATTR(wep_weak_iv_count, wep_weak_iv_count, D);
-
-static ssize_t show_sta_flags(const struct sta_info *sta, char *buf)
-{
-	return sprintf(buf, "%s%s%s%s%s%s%s%s%s",
-		       sta->flags & WLAN_STA_AUTH ? "AUTH\n" : "",
-		       sta->flags & WLAN_STA_ASSOC ? "ASSOC\n" : "",
-		       sta->flags & WLAN_STA_PS ? "PS\n" : "",
-		       sta->flags & WLAN_STA_TIM ? "TIM\n" : "",
-		       sta->flags & WLAN_STA_PERM ? "PERM\n" : "",
-		       sta->flags & WLAN_STA_AUTHORIZED ? "AUTHORIZED\n" : "",
-		       sta->flags & WLAN_STA_SHORT_PREAMBLE ?
-		       "SHORT PREAMBLE\n" : "",
-		       sta->flags & WLAN_STA_WME ? "WME\n" : "",
-		       sta->flags & WLAN_STA_WDS ? "WDS\n" : "");
-}
-__STA_ATTR(flags);
-
-static ssize_t show_sta_num_ps_buf_frames(const struct sta_info *sta, char *buf)
-{
-	return sprintf(buf, "%u\n", skb_queue_len(&sta->ps_tx_buf));
-}
-__STA_ATTR(num_ps_buf_frames);
-
-static ssize_t show_sta_last_ack_rssi(const struct sta_info *sta, char *buf)
-{
-	return sprintf(buf, "%d %d %d\n", sta->last_ack_rssi[0],
-		       sta->last_ack_rssi[1], sta->last_ack_rssi[2]);
-}
-__STA_ATTR(last_ack_rssi);
-
-static ssize_t show_sta_last_ack_ms(const struct sta_info *sta, char *buf)
-{
-	return sprintf(buf, "%d\n", sta->last_ack ?
-		       jiffies_to_msecs(jiffies - sta->last_ack) : -1);
-}
-__STA_ATTR(last_ack_ms);
-
-static ssize_t show_sta_inactive_ms(const struct sta_info *sta, char *buf)
-{
-	return sprintf(buf, "%d\n", jiffies_to_msecs(jiffies - sta->last_rx));
-}
-__STA_ATTR(inactive_ms);
-
-static ssize_t show_sta_last_seq_ctrl(const struct sta_info *sta, char *buf)
-{
-	int i;
-	char *p = buf;
-
-	for (i = 0; i < NUM_RX_DATA_QUEUES; i++)
-		p += sprintf(p, "%x ", sta->last_seq_ctrl[i]);
-	p += sprintf(p, "\n");
-	return (p - buf);
-}
-__STA_ATTR(last_seq_ctrl);
-
-#ifdef CONFIG_MAC80211_DEBUG_COUNTERS
-static ssize_t show_sta_wme_rx_queue(const struct sta_info *sta, char *buf)
-{
-	int i;
-	char *p = buf;
-
-	for (i = 0; i < NUM_RX_DATA_QUEUES; i++)
-		p += sprintf(p, "%u ", sta->wme_rx_queue[i]);
-	p += sprintf(p, "\n");
-	return (p - buf);
-}
-__STA_ATTR(wme_rx_queue);
-
-static ssize_t show_sta_wme_tx_queue(const struct sta_info *sta, char *buf)
-{
-	int i;
-	char *p = buf;
-
-	for (i = 0; i < NUM_RX_DATA_QUEUES; i++)
-		p += sprintf(p, "%u ", sta->wme_tx_queue[i]);
-	p += sprintf(p, "\n");
-	return (p - buf);
-}
-__STA_ATTR(wme_tx_queue);
-#endif
-
-static struct attribute *sta_ktype_attrs[] = {
-	&sta_attr_aid.attr,
-	&sta_attr_key_idx_compression.attr,
-	&sta_attr_dev.attr,
-	&sta_attr_vlan_id.attr,
-	&sta_attr_rx_packets.attr,
-	&sta_attr_tx_packets.attr,
-	&sta_attr_rx_bytes.attr,
-	&sta_attr_tx_bytes.attr,
-	&sta_attr_rx_duplicates.attr,
-	&sta_attr_rx_fragments.attr,
-	&sta_attr_rx_dropped.attr,
-	&sta_attr_tx_fragments.attr,
-	&sta_attr_tx_filtered.attr,
-	&sta_attr_txrate.attr,
-	&sta_attr_last_txrate.attr,
-	&sta_attr_tx_retry_failed.attr,
-	&sta_attr_tx_retry_count.attr,
-	&sta_attr_last_rssi.attr,
-	&sta_attr_last_signal.attr,
-	&sta_attr_last_noise.attr,
-	&sta_attr_channel_use.attr,
-	&sta_attr_wep_weak_iv_count.attr,
-
-	&sta_attr_flags.attr,
-	&sta_attr_num_ps_buf_frames.attr,
-	&sta_attr_last_ack_rssi.attr,
-	&sta_attr_last_ack_ms.attr,
-	&sta_attr_inactive_ms.attr,
-	&sta_attr_last_seq_ctrl.attr,
-#ifdef CONFIG_MAC80211_DEBUG_COUNTERS
-	&sta_attr_wme_rx_queue.attr,
-	&sta_attr_wme_tx_queue.attr,
-#endif
-	NULL
-};
-
-/* keys attributtes */
-
-struct key_attribute {
-	struct attribute attr;
-	ssize_t (*show)(const struct ieee80211_key *, char *buf);
-	ssize_t (*store)(struct ieee80211_key *, const char *buf,
-			 size_t count);
-};
-
-#define KEY_SHOW(name, field, format_string)				\
-static ssize_t show_key_##name(const struct ieee80211_key *key, char *buf)\
-{									\
-	return sprintf(buf, format_string, key->field);			\
-}
-#define KEY_SHOW_D(name, field) KEY_SHOW(name, field, "%d\n")
-
-#define __KEY_ATTR(name)						\
-static struct key_attribute key_attr_##name =				\
-	__ATTR(name, S_IRUSR, show_key_##name, NULL)
-
-#define KEY_ATTR(name, field, format)					\
-		KEY_SHOW_##format(name, field)				\
-		__KEY_ATTR(name)
-
-KEY_ATTR(length, keylen, D);
-KEY_ATTR(sw_encrypt, force_sw_encrypt, D);
-KEY_ATTR(index, keyidx, D);
-KEY_ATTR(hw_index, hw_key_idx, D);
-KEY_ATTR(tx_rx_count, tx_rx_count, D);
-
-static ssize_t show_key_algorithm(const struct ieee80211_key *key, char *buf)
-{
-	char *alg;
-
-	switch (key->alg) {
-	case ALG_WEP:
-		alg = "WEP";
-		break;
-	case ALG_TKIP:
-		alg = "TKIP";
-		break;
-	case ALG_CCMP:
-		alg = "CCMP";
-		break;
-	default:
-		return 0;
-	}
-	return sprintf(buf, "%s\n", alg);
-}
-__KEY_ATTR(algorithm);
-
-static ssize_t show_key_tx_spec(const struct ieee80211_key *key, char *buf)
-{
-	const u8 *tpn;
-
-	switch (key->alg) {
-	case ALG_WEP:
-		return sprintf(buf, "\n");
-	case ALG_TKIP:
-		return sprintf(buf, "%08x %04x\n", key->u.tkip.iv32,
-			       key->u.tkip.iv16);
-	case ALG_CCMP:
-		tpn = key->u.ccmp.tx_pn;
-		return sprintf(buf, "%02x%02x%02x%02x%02x%02x\n", tpn[0],
-			       tpn[1], tpn[2], tpn[3], tpn[4], tpn[5]);
-	default:
-		return 0;
-	}
-}
-__KEY_ATTR(tx_spec);
-
-static ssize_t show_key_rx_spec(const struct ieee80211_key *key, char *buf)
-{
-	int i;
-	const u8 *rpn;
-	char *p = buf;
-
-	switch (key->alg) {
-	case ALG_WEP:
-		return sprintf(buf, "\n");
-	case ALG_TKIP:
-		for (i = 0; i < NUM_RX_DATA_QUEUES; i++)
-			p += sprintf(p, "%08x %04x\n",
-				     key->u.tkip.iv32_rx[i],
-				     key->u.tkip.iv16_rx[i]);
-		return (p - buf);
-	case ALG_CCMP:
-		for (i = 0; i < NUM_RX_DATA_QUEUES; i++) {
-			rpn = key->u.ccmp.rx_pn[i];
-			p += sprintf(p, "%02x%02x%02x%02x%02x%02x\n", rpn[0],
-				     rpn[1], rpn[2], rpn[3], rpn[4], rpn[5]);
-		}
-		return (p - buf);
-	default:
-		return 0;
-	}
-}
-__KEY_ATTR(rx_spec);
-
-static ssize_t show_key_replays(const struct ieee80211_key *key, char *buf)
-{
-	if (key->alg != ALG_CCMP)
-		return 0;
-	return sprintf(buf, "%u\n", key->u.ccmp.replays);
-}
-__KEY_ATTR(replays);
-
-static ssize_t show_key_key(const struct ieee80211_key *key, char *buf)
-{
-	int i;
-	char *p = buf;
-
-	for (i = 0; i < key->keylen; i++)
-		p += sprintf(p, "%02x", key->key[i]);
-	p += sprintf(p, "\n");
-	return (p - buf);
-}
-__KEY_ATTR(key);
-
-static struct attribute *key_ktype_attrs[] = {
-	&key_attr_length.attr,
-	&key_attr_sw_encrypt.attr,
-	&key_attr_index.attr,
-	&key_attr_hw_index.attr,
-	&key_attr_tx_rx_count.attr,
-	&key_attr_algorithm.attr,
-	&key_attr_tx_spec.attr,
-	&key_attr_rx_spec.attr,
-	&key_attr_replays.attr,
-	&key_attr_key.attr,
-	NULL
-};
-
-/* structures and functions */
-
-static struct kobj_type sta_ktype = {
-	.release = sta_info_release,
-	.sysfs_ops = &sta_ktype_ops,
-	.default_attrs = sta_ktype_attrs,
-};
-
-static struct kobj_type key_ktype = {
-	.release = ieee80211_key_release,
-	.sysfs_ops = &key_ktype_ops,
-	.default_attrs = key_ktype_attrs,
-};
-
-static ssize_t sta_sysfs_show(struct kobject *kobj, struct attribute *attr,
-			      char *buf)
-{
-	struct sta_attribute *sta_attr;
-	struct sta_info *sta;
-
-	sta_attr = container_of(attr, struct sta_attribute, attr);
-	sta = container_of(kobj, struct sta_info, kobj);
-	return sta_attr->show(sta, buf);
-}
-
-static ssize_t key_sysfs_show(struct kobject *kobj, struct attribute *attr,
-			      char *buf)
-{
-	struct key_attribute *key_attr;
-	struct ieee80211_key *key;
-
-	key_attr = container_of(attr, struct key_attribute, attr);
-	key = container_of(kobj, struct ieee80211_key, kobj);
-	return key_attr->show(key, buf);
-}
-
-int ieee80211_sta_kset_sysfs_register(struct ieee80211_local *local)
-{
-	int res;
-
-	res = kobject_set_name(&local->sta_kset.kobj, "sta");
-	if (res)
-		return res;
-	local->sta_kset.kobj.parent = &local->hw.wiphy->dev.kobj;
-	local->sta_kset.ktype = &sta_ktype;
-	return kset_register(&local->sta_kset);
-}
-
-void ieee80211_sta_kset_sysfs_unregister(struct ieee80211_local *local)
-{
-	kset_unregister(&local->sta_kset);
-}
-
-int ieee80211_key_kset_sysfs_register(struct ieee80211_sub_if_data *sdata)
-{
-	int res;
-
-	res = kobject_set_name(&sdata->key_kset.kobj, "keys");
-	if (res)
-		return res;
-	sdata->key_kset.kobj.parent = &sdata->dev->dev.kobj;
-	sdata->key_kset.ktype = &key_ktype;
-	return kset_register(&sdata->key_kset);
-}
-
-void ieee80211_key_kset_sysfs_unregister(struct ieee80211_sub_if_data *sdata)
-{
-	kset_unregister(&sdata->key_kset);
-}
-
-int ieee80211_sta_sysfs_add(struct sta_info *sta)
-{
-	return kobject_add(&sta->kobj);
-}
-
-void ieee80211_sta_sysfs_remove(struct sta_info *sta)
-{
-	kobject_del(&sta->kobj);
-}
-
-void ieee80211_key_sysfs_set_kset(struct ieee80211_key *key, struct kset *kset)
-{
-	key->kobj.kset = kset;
-	if (!kset)
-		key->kobj.ktype = &key_ktype;
-}
-
-int ieee80211_key_sysfs_add(struct ieee80211_key *key)
-{
-	return kobject_add(&key->kobj);
-}
-
-void ieee80211_key_sysfs_remove(struct ieee80211_key *key)
-{
-	if (key)
-		kobject_del(&key->kobj);
-}
-
-int ieee80211_key_sysfs_add_default(struct ieee80211_sub_if_data *sdata)
-{
-	return sysfs_create_link(&sdata->key_kset.kobj,
-				 &sdata->default_key->kobj, "default");
-}
-
-void ieee80211_key_sysfs_remove_default(struct ieee80211_sub_if_data *sdata)
-{
-	if (sdata->default_key)
-		sysfs_remove_link(&sdata->key_kset.kobj, "default");
-}
net/mac80211/ieee80211_i.h +1 -14
@@ -381,7 +381,6 @@ struct ieee80211_local {
 	} ieee80211_msg_enum;
 
 	/* Station data structures */
-	struct kset sta_kset;
 	spinlock_t sta_lock; /* mutex for STA data structures */
 	int num_sta; /* number of stations in sta_list */
 	struct list_head sta_list;
@@ -599,6 +598,7 @@ struct ieee80211_local {
 			struct dentry *wme_tx_queue;
 			struct dentry *wme_rx_queue;
 		} stats;
+		struct dentry *stations;
 	} debugfs;
 #endif
 };
@@ -763,17 +763,4 @@ void ieee80211_if_sdata_init(struct ieee
 int ieee80211_if_add_mgmt(struct ieee80211_local *local);
 void ieee80211_if_del_mgmt(struct ieee80211_local *local);
 
-/* ieee80211_sysfs_sta.c */
-int ieee80211_sta_kset_sysfs_register(struct ieee80211_local *local);
-void ieee80211_sta_kset_sysfs_unregister(struct ieee80211_local *local);
-int ieee80211_sta_sysfs_add(struct sta_info *sta);
-void ieee80211_sta_sysfs_remove(struct sta_info *sta);
-int ieee80211_key_kset_sysfs_register(struct ieee80211_sub_if_data *sdata);
-void ieee80211_key_kset_sysfs_unregister(struct ieee80211_sub_if_data *sdata);
-void ieee80211_key_sysfs_set_kset(struct ieee80211_key *key, struct kset *kset);
-int ieee80211_key_sysfs_add(struct ieee80211_key *key);
-void ieee80211_key_sysfs_remove(struct ieee80211_key *key);
-int ieee80211_key_sysfs_add_default(struct ieee80211_sub_if_data *sdata);
-void ieee80211_key_sysfs_remove_default(struct ieee80211_sub_if_data *sdata);
-
 #endif /* IEEE80211_I_H */
net/mac80211/Makefile +2 -2
@@ -1,7 +1,7 @@
 obj-$(CONFIG_MAC80211) += mac80211.o rc80211_simple.o
 
 mac80211-objs-$(CONFIG_MAC80211_LEDS) += ieee80211_led.o
-mac80211-objs-$(CONFIG_DEBUG_FS) += debugfs.o
+mac80211-objs-$(CONFIG_DEBUG_FS) += debugfs.o debugfs_sta.o
 
 mac80211-objs := \
 	ieee80211.o \
@@ -14,12 +14,12 @@ mac80211-objs := \
 	ieee80211_iface.o \
 	ieee80211_rate.o \
 	ieee80211_sysfs.o \
-	ieee80211_sysfs_sta.o \
 	michael.o \
 	tkip.o \
 	aes_ccm.o \
 	wme.o \
 	ieee80211_cfg.o \
+	key_sysfs.o \
 	$(mac80211-objs-y)
 
 ifeq ($(CONFIG_NET_SCHED),)
net/mac80211/debugfs.c +5 -1
@@ -13,7 +13,7 @@
 #include "ieee80211_rate.h"
 #include "debugfs.h"
 
-static int mac80211_open_file_generic(struct inode *inode, struct file *file)
+int mac80211_open_file_generic(struct inode *inode, struct file *file)
 {
 	file->private_data = inode->i_private;
 	return 0;
@@ -302,6 +302,8 @@ void debugfs_hw_add(struct ieee80211_loc
 	if (!phyd)
 		return;
 
+	local->debugfs.stations = debugfs_create_dir("stations", phyd);
+
 	DEBUGFS_ADD(channel);
 	DEBUGFS_ADD(frequency);
 	DEBUGFS_ADD(radar_detect);
@@ -426,4 +428,6 @@ void debugfs_hw_del(struct ieee80211_loc
 
 	debugfs_remove(local->debugfs.statistics);
 	local->debugfs.statistics = NULL;
+	debugfs_remove(local->debugfs.stations);
+	local->debugfs.stations = NULL;
 }
net/mac80211/debugfs.h +1 -0
@@ -4,6 +4,7 @@
 #ifdef CONFIG_DEBUG_FS
 extern void debugfs_hw_add(struct ieee80211_local *local);
 extern void debugfs_hw_del(struct ieee80211_local *local);
+extern int mac80211_open_file_generic(struct inode *inode, struct file *file);
 #else
 static inline void debugfs_hw_add(struct ieee80211_local *local)
 {
net/mac80211/sta_info.c +22 -33

132 lines not on this page · raw message

net/mac80211/key_sysfs.c new file +217 -0

217 lines not on this page · raw message

net/mac80211/ieee80211.c +1 -0
@@ -35,6 +35,7 @@
 #include "ieee80211_cfg.h"
 #include "ieee80211_sysfs.h"
 #include "debugfs.h"
+#include "key_sysfs.h"
 
 /* See IEEE 802.1H for LLC/SNAP encapsulation/decapsulation */
 /* Ethernet-II snap header (RFC1042 for most EtherTypes) */
net/mac80211/ieee80211_ioctl.c +1 -3
@@ -25,7 +25,7 @@
 #include "ieee80211_rate.h"
 #include "wpa.h"
 #include "aes_ccm.h"
-
+#include "key_sysfs.h"
 
 static int ieee80211_regdom = 0x10; /* FCC */
 module_param(ieee80211_regdom, int, 0444);
@@ -687,8 +687,6 @@ static int ieee80211_set_encryption(stru
 		else
 			sdata->keys[idx] = key;
 		ieee80211_key_free(old_key);
-		if (sta)
-			key->kobj.parent = &sta->kobj;
 		ret = ieee80211_key_sysfs_add(key);
 		if (ret)
 			goto err_null;
net/mac80211/ieee80211_sysfs.c +1 -0
@@ -17,6 +17,7 @@
 #include "ieee80211_i.h"
 #include "ieee80211_rate.h"
 #include "ieee80211_sysfs.h"
+#include "key_sysfs.h"
 
 static inline struct ieee80211_local *to_ieee80211_local(struct device *dev)
 {
net/mac80211/key_sysfs.h new file +12 -0
@@ -0,0 +1,12 @@
+#ifndef __MAC80211_KEY_SYSFS_H
+#define __MAC80211_KEY_SYSFS_H
+
+int ieee80211_key_kset_sysfs_register(struct ieee80211_sub_if_data *sdata);
+void ieee80211_key_kset_sysfs_unregister(struct ieee80211_sub_if_data *sdata);
+void ieee80211_key_sysfs_set_kset(struct ieee80211_key *key, struct kset *kset);
+int ieee80211_key_sysfs_add(struct ieee80211_key *key);
+void ieee80211_key_sysfs_remove(struct ieee80211_key *key);
+int ieee80211_key_sysfs_add_default(struct ieee80211_sub_if_data *sdata);
+void ieee80211_key_sysfs_remove_default(struct ieee80211_sub_if_data *sdata);
+
+#endif /* __MAC80211_KEY_SYSFS_H */
net/mac80211/sta_info.h +16 -2
@@ -12,6 +12,7 @@
 #include <linux/list.h>
 #include <linux/types.h>
 #include <linux/if_ether.h>
+#include <linux/kref.h>
 #include "ieee80211_key.h"
 
 /* Stations flags (struct sta_info::flags) */
@@ -30,8 +31,8 @@
 
 
 struct sta_info {
+	struct kref kref;
 	struct list_head list;
-	struct kobject kobj;
 	struct sta_info *hnext; /* next entry in hash table list */
 
 	struct ieee80211_local *local;
@@ -113,6 +114,20 @@ struct sta_info {
 	int vlan_id;
 
 	u16 listen_interval;
+
+#ifdef CONFIG_DEBUG_FS
+	struct sta_info_debugfsdentries {
+		struct dentry *dir;
+		struct dentry *flags;
+		struct dentry *num_ps_buf_frames;
+		struct dentry *last_ack_rssi;
+		struct dentry *last_ack_ms;
+		struct dentry *inactive_ms;
+		struct dentry *last_seq_ctrl;
+		struct dentry *wme_rx_queue;
+		struct dentry *wme_tx_queue;
+	} debugfs;
+#endif
 };
 
 
@@ -140,7 +155,6 @@ void sta_info_put(struct sta_info *sta);
 struct sta_info * sta_info_add(struct ieee80211_local *local,
 			       struct net_device *dev, u8 *addr, gfp_t gfp);
 void sta_info_free(struct sta_info *sta, int locked);
-void sta_info_release(struct kobject *kobj);
 void sta_info_init(struct ieee80211_local *local);
 int sta_info_start(struct ieee80211_local *local);
 void sta_info_stop(struct ieee80211_local *local);
net/mac80211/debugfs_sta.c new file +242 -0

242 lines not on this page · raw message

net/mac80211/debugfs_sta.h new file +12 -0
@@ -0,0 +1,12 @@
+#ifndef __MAC80211_DEBUGFS_STA_H
+#define __MAC80211_DEBUGFS_STA_H
+
+#ifdef CONFIG_DEBUG_FS
+void ieee80211_sta_debugfs_add(struct sta_info *sta);
+void ieee80211_sta_debugfs_remove(struct sta_info *sta);
+#else
+static inline void ieee80211_sta_debugfs_add(struct sta_info *sta) {}
+static inline void ieee80211_sta_debugfs_remove(struct sta_info *sta) {}
+#endif
+
+#endif /* __MAC80211_DEBUGFS_STA_H */
net/mac80211/ieee80211_rate.h +14 -15
@@ -56,10 +56,9 @@ struct rate_control_ops {
 
 	int (*add_attrs)(void *priv, struct kobject *kobj);
 	void (*remove_attrs)(void *priv, struct kobject *kobj);
-	int (*add_sta_attrs)(void *priv, void *priv_sta,
-			     struct kobject *kobj);
-	void (*remove_sta_attrs)(void *priv, void *priv_sta,
-				 struct kobject *kobj);
+	void (*add_sta_debugfs)(void *priv, void *priv_sta,
+				struct dentry *dir);
+	void (*remove_sta_debugfs)(void *priv, void *priv_sta);
 };
 
 struct rate_control_ref {
@@ -123,23 +122,23 @@ static inline void rate_control_free_sta
 	ref->ops->free_sta(ref->priv, priv);
 }
 
-static inline int rate_control_add_sta_attrs(struct sta_info *sta,
-					     struct kobject *kobj)
+static inline void rate_control_add_sta_debugfs(struct sta_info *sta)
 {
+#ifdef CONFIG_DEBUG_FS
 	struct rate_control_ref *ref = sta->rate_ctrl;
-	if (ref->ops->add_sta_attrs)
-		return ref->ops->add_sta_attrs(ref->priv, sta->rate_ctrl_priv,
-					       kobj);
-	return 0;
+	if (sta->debugfs.dir && ref->ops->add_sta_debugfs)
+		ref->ops->add_sta_debugfs(ref->priv, sta->rate_ctrl_priv,
+					  sta->debugfs.dir);
+#endif
 }
 
-static inline void rate_control_remove_sta_attrs(struct sta_info *sta,
-						 struct kobject *kobj)
+static inline void rate_control_remove_sta_debugfs(struct sta_info *sta)
 {
+#ifdef CONFIG_DEBUG_FS
 	struct rate_control_ref *ref = sta->rate_ctrl;
-	if (ref->ops->remove_sta_attrs)
-		ref->ops->remove_sta_attrs(ref->priv, sta->rate_ctrl_priv,
-					   kobj);
+	if (ref->ops->remove_sta_debugfs)
+		ref->ops->remove_sta_debugfs(ref->priv, sta->rate_ctrl_priv);
+#endif
 }
 
 #endif /* IEEE80211_RATE_H */
net/mac80211/rc80211_simple.c +55 -27

122 lines not on this page · raw message

--

author maintainer
#3 lore raw

PATCH 3/4 mac80211: move per-netdev and key stuff to debugfs

In reply to [email protected]

This patch moves the remaining sysfs stuff from mac80211 into debugfs.

---
 net/mac80211/Makefile          |    4 
 net/mac80211/debugfs.c         |    3 
 net/mac80211/debugfs_key.c     |  253 +++++++++++++++++++++++
 net/mac80211/debugfs_key.h     |   34 +++
 net/mac80211/debugfs_netdev.c  |  440 +++++++++++++++++++++++++++++++++++++++++
 net/mac80211/debugfs_netdev.h  |   30 ++
 net/mac80211/ieee80211.c       |   51 ++--
 net/mac80211/ieee80211_i.h     |   65 +++++-
 net/mac80211/ieee80211_iface.c |   25 --
 net/mac80211/ieee80211_ioctl.c |   31 +-
 net/mac80211/ieee80211_key.h   |   21 +
 net/mac80211/ieee80211_sysfs.c |  344 --------------------------------
 net/mac80211/ieee80211_sysfs.h |   10 
 net/mac80211/key_sysfs.c       |  217 --------------------
 net/mac80211/key_sysfs.h       |   12 -
 net/mac80211/sta_info.c        |    6 
 16 files changed, 891 insertions(+), 655 deletions(-)
net/mac80211/Makefile +1 -3
@@ -1,7 +1,7 @@
 obj-$(CONFIG_MAC80211) += mac80211.o rc80211_simple.o
 
 mac80211-objs-$(CONFIG_MAC80211_LEDS) += ieee80211_led.o
-mac80211-objs-$(CONFIG_DEBUG_FS) += debugfs.o debugfs_sta.o
+mac80211-objs-$(CONFIG_DEBUG_FS) += debugfs.o debugfs_sta.o debugfs_netdev.o debugfs_key.o
 
 mac80211-objs := \
 	ieee80211.o \
@@ -13,13 +13,11 @@ mac80211-objs := \
 	ieee80211_sta.o \
 	ieee80211_iface.o \
 	ieee80211_rate.o \
-	ieee80211_sysfs.o \
 	michael.o \
 	tkip.o \
 	aes_ccm.o \
 	wme.o \
 	ieee80211_cfg.o \
-	key_sysfs.o \
 	$(mac80211-objs-y)
 
 ifeq ($(CONFIG_NET_SCHED),)
net/mac80211/debugfs_netdev.c new file +440 -0

440 lines not on this page · raw message

net/mac80211/debugfs_netdev.h new file +30 -0
@@ -0,0 +1,30 @@
+/* routines exported for sysfs handling */
+
+#ifndef __IEEE80211_SYSFS_H
+#define __IEEE80211_SYSFS_H
+
+#ifdef CONFIG_DEBUG_FS
+void ieee80211_debugfs_add_netdev(struct ieee80211_sub_if_data *sdata);
+void ieee80211_debugfs_remove_netdev(struct ieee80211_sub_if_data *sdata);
+void ieee80211_debugfs_change_if_type(struct ieee80211_sub_if_data *sdata,
+				     int oldtype);
+void ieee80211_debugfs_netdev_init(void);
+void ieee80211_debugfs_netdev_exit(void);
+#else
+static inline void ieee80211_debugfs_add_netdev(
+	struct ieee80211_sub_if_data *sdata)
+{}
+static inline void ieee80211_debugfs_remove_netdev(
+	struct ieee80211_sub_if_data *sdata)
+{}
+static inline void ieee80211_debugfs_change_if_type(
+	struct ieee80211_sub_if_data *sdata, int oldtype)
+{}
+static inline void ieee80211_debugfs_netdev_init(void)
+{}
+
+static inline void ieee80211_debugfs_netdev_exit(void)
+{}
+#endif
+
+#endif /* __IEEE80211_SYSFS_H */
net/mac80211/ieee80211.c +23 -28

109 lines not on this page · raw message

net/mac80211/ieee80211_i.h +62 -3

93 lines not on this page · raw message

net/mac80211/ieee80211_iface.c +9 -16
@@ -14,7 +14,7 @@
 #include <net/mac80211.h>
 #include "ieee80211_i.h"
 #include "sta_info.h"
-#include "ieee80211_sysfs.h"
+#include "debugfs_netdev.h"
 
 void ieee80211_if_sdata_init(struct ieee80211_sub_if_data *sdata)
 {
@@ -81,14 +81,8 @@ int ieee80211_if_add(struct net_device *
 	ret = register_netdevice(ndev);
 	if (ret)
 		goto fail;
-	ret = ieee80211_sysfs_add_netdevice(ndev);
-	if (ret) {
-		/* ndev will be freed by ndev->destructor */
-		unregister_netdevice(ndev);
-		*new_dev = NULL;
-		return ret;
-	}
 
+	ieee80211_debugfs_add_netdev(sdata);
 	list_add(&sdata->list, &local->sub_if_list);
 	ieee80211_update_default_wep_only(local);
 
@@ -130,16 +124,14 @@ int ieee80211_if_add_mgmt(struct ieee802
 	ret = register_netdevice(ndev);
 	if (ret)
 		goto fail;
-	ret = ieee80211_sysfs_add_netdevice(ndev);
-	if (ret)
-		goto fail_sysfs;
+
+	ieee80211_debugfs_add_netdev(nsdata);
+
 	if (local->open_count > 0)
 		dev_open(ndev);
 	local->apdev = ndev;
 	return 0;
 
-fail_sysfs:
-	unregister_netdevice(ndev);
 fail:
 	free_netdev(ndev);
 	return ret;
@@ -151,7 +143,7 @@ void ieee80211_if_del_mgmt(struct ieee80
 
 	ASSERT_RTNL();
 	apdev = local->apdev;
-	ieee80211_sysfs_remove_netdevice(apdev);
+	ieee80211_debugfs_remove_netdev(IEEE80211_DEV_TO_SUB_IF(apdev));
 	local->apdev = NULL;
 	unregister_netdevice(apdev);
 }
@@ -160,6 +152,7 @@ void ieee80211_if_set_type(struct net_de
 {
 	struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
 	struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr);
+	int oldtype = sdata->type;
 
 	sdata->type = type;
 	switch (type) {
@@ -205,7 +198,7 @@ void ieee80211_if_set_type(struct net_de
 		printk(KERN_WARNING "%s: %s: Unknown interface type 0x%x",
 		       dev->name, __FUNCTION__, type);
 	}
-	ieee80211_sysfs_change_if_type(dev);
+	ieee80211_debugfs_change_if_type(sdata, oldtype);
 	ieee80211_update_default_wep_only(local);
 }
 
@@ -309,7 +302,7 @@ void __ieee80211_if_del(struct ieee80211
 	struct net_device *dev = sdata->dev;
 
 	list_del(&sdata->list);
-	ieee80211_sysfs_remove_netdevice(dev);
+	ieee80211_debugfs_remove_netdev(sdata);
 	unregister_netdevice(dev);
 	/* Except master interface, the net_device will be freed by
 	 * net_device->destructor (i. e. ieee80211_if_free). */
net/mac80211/ieee80211_key.h +19 -2
@@ -11,7 +11,7 @@
 #define IEEE80211_KEY_H
 
 #include <linux/types.h>
-#include <linux/kobject.h>
+#include <linux/kref.h>
 #include <linux/crypto.h>
 #include <net/mac80211.h>
 
@@ -42,7 +42,7 @@
 #define NUM_RX_DATA_QUEUES 17
 
 struct ieee80211_key {
-	struct kobject kobj;
+	struct kref kref;
 
 	int hw_key_idx; /* filled and used by low-level driver */
 	ieee80211_key_alg alg;
@@ -83,6 +83,23 @@ struct ieee80211_key {
 					* (used only for broadcast keys). */
 	s8 keyidx; /* WEP key index */
 
+#ifdef CONFIG_DEBUG_FS
+	struct {
+		struct dentry *stalink;
+		struct dentry *dir;
+		struct dentry *keylen;
+		struct dentry *force_sw_encrypt;
+		struct dentry *keyidx;
+		struct dentry *hw_key_idx;
+		struct dentry *tx_rx_count;
+		struct dentry *algorithm;
+		struct dentry *tx_spec;
+		struct dentry *rx_spec;
+		struct dentry *replays;
+		struct dentry *key;
+	} debugfs;
+#endif
+
 	u8 key[0];
 };
 
net/mac80211/ieee80211_sysfs.c deleted +0 -344

344 lines not on this page · raw message

net/mac80211/ieee80211_sysfs.h deleted +0 -10
@@ -1,10 +0,0 @@
-/* routines exported for sysfs handling */
-
-#ifndef __IEEE80211_SYSFS_H
-#define __IEEE80211_SYSFS_H
-
-int ieee80211_sysfs_add_netdevice(struct net_device *dev);
-void ieee80211_sysfs_remove_netdevice(struct net_device *dev);
-int ieee80211_sysfs_change_if_type(struct net_device *dev);
-
-#endif /* __IEEE80211_SYSFS_H */
net/mac80211/debugfs_key.c new file +253 -0

253 lines not on this page · raw message

net/mac80211/debugfs_key.h new file +34 -0
@@ -0,0 +1,34 @@
+#ifndef __MAC80211_DEBUGFS_KEY_H
+#define __MAC80211_DEBUGFS_KEY_H
+
+#ifdef CONFIG_DEBUG_FS
+void ieee80211_debugfs_key_add(struct ieee80211_local *local,
+			       struct ieee80211_key *key);
+void ieee80211_debugfs_key_remove(struct ieee80211_key *key);
+void ieee80211_debugfs_key_add_default(struct ieee80211_sub_if_data *sdata);
+void ieee80211_debugfs_key_remove_default(struct ieee80211_sub_if_data *sdata);
+void ieee80211_debugfs_key_sta_link(struct ieee80211_key *key,
+				    struct sta_info *sta);
+void ieee80211_debugfs_key_sta_del(struct ieee80211_key *key,
+				   struct sta_info *sta);
+#else
+static inline void ieee80211_debugfs_key_add(struct ieee80211_local *local,
+					     struct ieee80211_key *key)
+{}
+static inline void ieee80211_debugfs_key_remove(struct ieee80211_key *key)
+{}
+static inline void ieee80211_debugfs_key_add_default(
+	struct ieee80211_sub_if_data *sdata)
+{}
+static inline void ieee80211_debugfs_key_remove_default(
+	struct ieee80211_sub_if_data *sdata)
+{}
+static inline void ieee80211_debugfs_key_sta_link(
+	struct ieee80211_key *key, struct sta_info *sta)
+{}
+static inline void ieee80211_debugfs_key_sta_del(struct ieee80211_key *key,
+						 struct sta_info *sta)
+{}
+#endif
+
+#endif /* __MAC80211_DEBUGFS_KEY_H */
net/mac80211/ieee80211_ioctl.c +13 -18
@@ -25,7 +25,7 @@
 #include "ieee80211_rate.h"
 #include "wpa.h"
 #include "aes_ccm.h"
-#include "key_sysfs.h"
+#include "debugfs_key.h"
 
 static int ieee80211_regdom = 0x10; /* FCC */
 module_param(ieee80211_regdom, int, 0444);
@@ -634,10 +634,10 @@ static int ieee80211_set_encryption(stru
 		kfree(keyconf);
 
 		if (set_tx_key || sdata->default_key == key) {
-			ieee80211_key_sysfs_remove_default(sdata);
+			ieee80211_debugfs_key_remove_default(sdata);
 			sdata->default_key = NULL;
 		}
-		ieee80211_key_sysfs_remove(key);
+		ieee80211_debugfs_key_remove(key);
 		if (sta)
 			sta->key = NULL;
 		else
@@ -678,18 +678,18 @@ static int ieee80211_set_encryption(stru
 		}
 
 		if (set_tx_key || sdata->default_key == old_key) {
-			ieee80211_key_sysfs_remove_default(sdata);
+			ieee80211_debugfs_key_remove_default(sdata);
 			sdata->default_key = NULL;
 		}
-		ieee80211_key_sysfs_remove(old_key);
+		ieee80211_debugfs_key_remove(old_key);
 		if (sta)
 			sta->key = key;
 		else
 			sdata->keys[idx] = key;
 		ieee80211_key_free(old_key);
-		ret = ieee80211_key_sysfs_add(key);
-		if (ret)
-			goto err_null;
+		ieee80211_debugfs_key_add(local, key);
+		if (sta)
+			ieee80211_debugfs_key_sta_link(key, sta);
 
 		if (try_hwaccel &&
 		    (alg == ALG_WEP || alg == ALG_TKIP || alg == ALG_CCMP)) {
@@ -702,9 +702,9 @@ static int ieee80211_set_encryption(stru
 
 	if (set_tx_key || (!sta && !sdata->default_key && key)) {
 		sdata->default_key = key;
-		if (key && ieee80211_key_sysfs_add_default(sdata))
-			printk(KERN_WARNING "%s: cannot create symlink to "
-			       "default key\n", dev->name);
+		if (key)
+			ieee80211_debugfs_key_add_default(sdata);
+
 		if (local->ops->set_key_idx &&
 		    local->ops->set_key_idx(local_to_hw(local), idx))
 			printk(KERN_DEBUG "%s: failed to set TX key idx for "
@@ -716,11 +716,6 @@ static int ieee80211_set_encryption(stru
 
 	return 0;
 
-err_null:
-	if (sta)
-		sta->key = NULL;
-	else
-		sdata->keys[idx] = NULL;
 err_free:
 	ieee80211_key_free(key);
 err_out:
@@ -2949,10 +2944,10 @@ static int ieee80211_ioctl_siwencode(str
 	else if (erq->length == 0) {
 		/* No key data - just set the default TX key index */
 		if (sdata->default_key != sdata->keys[idx]) {
-			ieee80211_key_sysfs_remove_default(sdata);
+			ieee80211_debugfs_key_remove_default(sdata);
 			sdata->default_key = sdata->keys[idx];
 			if (sdata->default_key)
-				ieee80211_key_sysfs_add_default(sdata);
+				ieee80211_debugfs_key_add_default(sdata);
 		}
 		return 0;
 	}
net/mac80211/key_sysfs.c deleted +0 -217

217 lines not on this page · raw message

net/mac80211/key_sysfs.h deleted +0 -12
@@ -1,12 +0,0 @@
-#ifndef __MAC80211_KEY_SYSFS_H
-#define __MAC80211_KEY_SYSFS_H
-
-int ieee80211_key_kset_sysfs_register(struct ieee80211_sub_if_data *sdata);
-void ieee80211_key_kset_sysfs_unregister(struct ieee80211_sub_if_data *sdata);
-void ieee80211_key_sysfs_set_kset(struct ieee80211_key *key, struct kset *kset);
-int ieee80211_key_sysfs_add(struct ieee80211_key *key);
-void ieee80211_key_sysfs_remove(struct ieee80211_key *key);
-int ieee80211_key_sysfs_add_default(struct ieee80211_sub_if_data *sdata);
-void ieee80211_key_sysfs_remove_default(struct ieee80211_sub_if_data *sdata);
-
-#endif /* __MAC80211_KEY_SYSFS_H */
net/mac80211/sta_info.c +4 -2
@@ -18,7 +18,7 @@
 #include "ieee80211_i.h"
 #include "ieee80211_rate.h"
 #include "sta_info.h"
-#include "key_sysfs.h"
+#include "debugfs_key.h"
 #include "debugfs_sta.h"
 
 /* Caller must hold local->sta_lock */
@@ -121,6 +121,8 @@ void sta_info_release(struct kref *kref)
 	}
 	rate_control_free_sta(sta->rate_ctrl, sta->rate_ctrl_priv);
 	rate_control_put(sta->rate_ctrl);
+	if (sta->key)
+		ieee80211_debugfs_key_sta_del(sta->key, sta);
 	kfree(sta);
 }
 
@@ -197,7 +199,7 @@ static void finish_sta_info_free(struct 
 #endif /* CONFIG_MAC80211_VERBOSE_DEBUG */
 
 	if (sta->key) {
-		ieee80211_key_sysfs_remove(sta->key);
+		ieee80211_debugfs_key_remove(sta->key);
 		ieee80211_key_free(sta->key);
 		sta->key = NULL;
 	}
net/mac80211/debugfs.c +3 -0
@@ -303,6 +303,7 @@ void debugfs_hw_add(struct ieee80211_loc
 		return;
 
 	local->debugfs.stations = debugfs_create_dir("stations", phyd);
+	local->debugfs.keys = debugfs_create_dir("keys", phyd);
 
 	DEBUGFS_ADD(channel);
 	DEBUGFS_ADD(frequency);
@@ -430,4 +431,6 @@ void debugfs_hw_del(struct ieee80211_loc
 	local->debugfs.statistics = NULL;
 	debugfs_remove(local->debugfs.stations);
 	local->debugfs.stations = NULL;
+	debugfs_remove(local->debugfs.keys);
+	local->debugfs.keys = NULL;
 }

--

author maintainer
#4 lore raw

PATCH 4/4 mac80211 debugfs Kconfig

In reply to [email protected]

This patch adds a configuration option to mac80211 that lets you enable or disable the debugfs internal state export.

I intentionally made this option not depend on MAC80211_DEBUG because that option always generates debug messages in the kernel log; this way you can see the internal state without seeing any debugging message.

---
 net/mac80211/Kconfig          |    9 +++++++++
 net/mac80211/Makefile         |    2 +-
 net/mac80211/debugfs.h        |    2 +-
 net/mac80211/debugfs_key.h    |    2 +-
 net/mac80211/debugfs_netdev.h |    2 +-
 net/mac80211/debugfs_sta.h    |    2 +-
 net/mac80211/ieee80211_i.h    |    4 ++--
 net/mac80211/ieee80211_key.h  |    2 +-
 net/mac80211/ieee80211_rate.h |    4 ++--
 net/mac80211/rc80211_simple.c |    6 +++---
 net/mac80211/sta_info.h       |    2 +-
 11 files changed, 23 insertions(+), 14 deletions(-)
net/mac80211/Kconfig +9 -0
@@ -18,6 +18,15 @@ config MAC80211_LEDS
 	This option enables a few LED triggers for different
 	packet receive/transmit events.
 
+config MAC80211_DEBUGFS
+	bool "Export mac80211 internals in DebugFS"
+	depends on MAC80211 && DEBUG_FS
+	---help---
+	  Select this to see extensive information about
+	  the internal state of mac80211 in debugfs.
+
+	  Say N unless you know you need this.
+
 config MAC80211_DEBUG
 	bool "Enable debugging output"
 	depends on MAC80211
net/mac80211/Makefile +1 -1
@@ -1,7 +1,7 @@
 obj-$(CONFIG_MAC80211) += mac80211.o rc80211_simple.o
 
 mac80211-objs-$(CONFIG_MAC80211_LEDS) += ieee80211_led.o
-mac80211-objs-$(CONFIG_DEBUG_FS) += debugfs.o debugfs_sta.o debugfs_netdev.o debugfs_key.o
+mac80211-objs-$(CONFIG_MAC80211_DEBUGFS) += debugfs.o debugfs_sta.o debugfs_netdev.o debugfs_key.o
 
 mac80211-objs := \
 	ieee80211.o \
net/mac80211/debugfs.h +1 -1
@@ -1,7 +1,7 @@
 #ifndef __MAC80211_DEBUGFS_H
 #define __MAC80211_DEBUGFS_H
 
-#ifdef CONFIG_DEBUG_FS
+#ifdef CONFIG_MAC80211_DEBUGFS
 extern void debugfs_hw_add(struct ieee80211_local *local);
 extern void debugfs_hw_del(struct ieee80211_local *local);
 extern int mac80211_open_file_generic(struct inode *inode, struct file *file);
net/mac80211/debugfs_key.h +1 -1
@@ -1,7 +1,7 @@
 #ifndef __MAC80211_DEBUGFS_KEY_H
 #define __MAC80211_DEBUGFS_KEY_H
 
-#ifdef CONFIG_DEBUG_FS
+#ifdef CONFIG_MAC80211_DEBUGFS
 void ieee80211_debugfs_key_add(struct ieee80211_local *local,
 			       struct ieee80211_key *key);
 void ieee80211_debugfs_key_remove(struct ieee80211_key *key);
net/mac80211/debugfs_netdev.h +1 -1
@@ -3,7 +3,7 @@
 #ifndef __IEEE80211_SYSFS_H
 #define __IEEE80211_SYSFS_H
 
-#ifdef CONFIG_DEBUG_FS
+#ifdef CONFIG_MAC80211_DEBUGFS
 void ieee80211_debugfs_add_netdev(struct ieee80211_sub_if_data *sdata);
 void ieee80211_debugfs_remove_netdev(struct ieee80211_sub_if_data *sdata);
 void ieee80211_debugfs_change_if_type(struct ieee80211_sub_if_data *sdata,
net/mac80211/debugfs_sta.h +1 -1
@@ -1,7 +1,7 @@
 #ifndef __MAC80211_DEBUGFS_STA_H
 #define __MAC80211_DEBUGFS_STA_H
 
-#ifdef CONFIG_DEBUG_FS
+#ifdef CONFIG_MAC80211_DEBUGFS
 void ieee80211_sta_debugfs_add(struct sta_info *sta);
 void ieee80211_sta_debugfs_remove(struct sta_info *sta);
 #else
net/mac80211/ieee80211_i.h +2 -2
@@ -337,7 +337,7 @@ struct ieee80211_sub_if_data {
 	int channel_use;
 	int channel_use_raw;
 
-#ifdef CONFIG_DEBUG_FS
+#ifdef CONFIG_MAC80211_DEBUGFS
 	struct dentry *debugfsdir;
 	union {
 		struct {
@@ -595,7 +595,7 @@ struct ieee80211_local {
 
 	int user_space_mlme;
 
-#ifdef CONFIG_DEBUG_FS
+#ifdef CONFIG_MAC80211_DEBUGFS
 	struct local_debugfsdentries {
 		struct dentry *channel;
 		struct dentry *frequency;
net/mac80211/ieee80211_key.h +1 -1
@@ -83,7 +83,7 @@ struct ieee80211_key {
 					* (used only for broadcast keys). */
 	s8 keyidx; /* WEP key index */
 
-#ifdef CONFIG_DEBUG_FS
+#ifdef CONFIG_MAC80211_DEBUGFS
 	struct {
 		struct dentry *stalink;
 		struct dentry *dir;
net/mac80211/rc80211_simple.c +3 -3
@@ -123,7 +123,7 @@ struct sta_rate_control {
 	u32 tx_avg_rate_sum;
 	u32 tx_avg_rate_num;
 
-#ifdef CONFIG_DEBUG_FS
+#ifdef CONFIG_MAC80211_DEBUGFS
 	struct dentry *tx_avg_rate_sum_dentry;
 	struct dentry *tx_avg_rate_num_dentry;
 #endif
@@ -333,7 +333,7 @@ static void rate_control_simple_free_sta
 	kfree(rctrl);
 }
 
-#ifdef CONFIG_DEBUG_FS
+#ifdef CONFIG_MAC80211_DEBUGFS
 
 static int open_file_generic(struct inode *inode, struct file *file)
 {
@@ -406,7 +406,7 @@ static struct rate_control_ops rate_cont
 	.free = rate_control_simple_free,
 	.alloc_sta = rate_control_simple_alloc_sta,
 	.free_sta = rate_control_simple_free_sta,
-#ifdef CONFIG_DEBUG_FS
+#ifdef CONFIG_MAC80211_DEBUGFS
 	.add_sta_debugfs = rate_control_simple_add_sta_debugfs,
 	.remove_sta_debugfs = rate_control_simple_remove_sta_debugfs,
 #endif
net/mac80211/sta_info.h +1 -1
@@ -115,7 +115,7 @@ struct sta_info {
 
 	u16 listen_interval;
 
-#ifdef CONFIG_DEBUG_FS
+#ifdef CONFIG_MAC80211_DEBUGFS
 	struct sta_info_debugfsdentries {
 		struct dentry *dir;
 		struct dentry *flags;
net/mac80211/ieee80211_rate.h +2 -2
@@ -124,7 +124,7 @@ static inline void rate_control_free_sta
 
 static inline void rate_control_add_sta_debugfs(struct sta_info *sta)
 {
-#ifdef CONFIG_DEBUG_FS
+#ifdef CONFIG_MAC80211_DEBUGFS
 	struct rate_control_ref *ref = sta->rate_ctrl;
 	if (sta->debugfs.dir && ref->ops->add_sta_debugfs)
 		ref->ops->add_sta_debugfs(ref->priv, sta->rate_ctrl_priv,
@@ -134,7 +134,7 @@ static inline void rate_control_add_sta_
 
 static inline void rate_control_remove_sta_debugfs(struct sta_info *sta)
 {
-#ifdef CONFIG_DEBUG_FS
+#ifdef CONFIG_MAC80211_DEBUGFS
 	struct rate_control_ref *ref = sta->rate_ctrl;
 	if (ref->ops->remove_sta_debugfs)
 		ref->ops->remove_sta_debugfs(ref->priv, sta->rate_ctrl_priv);

--

Applied
#5 lore raw
In reply to [email protected]
Quoted 3 lines · On Wed, 07 Mar 2007 17:45:31 +0100, [email protected] wrote:

In order to not export internal details via sysfs (which is a userspace ABI) this patch series moves everything from sysfs into debugfs.

Applied to my tree, thanks!

Jiri

Signature · 2 lines
Jiri Benc
SUSE Labs