* [PATCH (v3) 1/4] mac80211: move PHY things to debugfs
2007-03-07 16:45 [PATCH (v3) 0/4] move everything in mac80211 from sysfs to debugfs johannes
@ 2007-03-07 16:45 ` johannes
2007-03-07 16:45 ` [PATCH (v3) 2/4] mac80211: move sta dir " johannes
` (3 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: johannes @ 2007-03-07 16:45 UTC (permalink / raw)
To: John W. Linville; +Cc: linux-wireless
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.
Signed-off-by: Johannes Berg <johannes@sipsolutions.net>
---
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(-)
--- wireless-dev.orig/net/mac80211/Makefile 2007-03-07 13:02:31.334710923 +0100
+++ wireless-dev/net/mac80211/Makefile 2007-03-07 13:03:54.934710923 +0100
@@ -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 \
--- wireless-dev.orig/net/mac80211/ieee80211.c 2007-03-07 13:03:53.334710923 +0100
+++ wireless-dev/net/mac80211/ieee80211.c 2007-03-07 13:03:54.934710923 +0100
@@ -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]);
--- wireless-dev.orig/net/mac80211/ieee80211_rate.h 2007-03-07 13:03:50.454710923 +0100
+++ wireless-dev/net/mac80211/ieee80211_rate.h 2007-03-07 13:03:54.934710923 +0100
@@ -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)
{
--- /dev/null 1970-01-01 00:00:00.000000000 +0000
+++ wireless-dev/net/mac80211/debugfs.h 2007-03-07 13:03:54.934710923 +0100
@@ -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 */
--- wireless-dev.orig/net/mac80211/ieee80211_sysfs.c 2007-03-07 13:02:31.484710923 +0100
+++ wireless-dev/net/mac80211/ieee80211_sysfs.c 2007-03-07 13:03:54.944710923 +0100
@@ -34,334 +34,6 @@ static inline int rtnl_lock_local(struct
return 0;
}
-static const char *ieee80211_mode_str_short(int mode)
-{
- switch (mode) {
- case MODE_IEEE80211A:
- return "802.11a";
- case MODE_IEEE80211B:
- return "802.11b";
- case MODE_IEEE80211G:
- return "802.11g";
- case MODE_ATHEROS_TURBO:
- return "AtherosTurbo";
- default:
- return "UNKNOWN";
- }
-}
-
-static const char *ieee80211_mode_str(int mode)
-{
- switch (mode) {
- case MODE_IEEE80211A:
- return "IEEE 802.11a";
- case MODE_IEEE80211B:
- return "IEEE 802.11b";
- case MODE_IEEE80211G:
- return "IEEE 802.11g";
- case MODE_ATHEROS_TURBO:
- return "Atheros Turbo (5 GHz)";
- default:
- return "UNKNOWN";
- }
-}
-
-/* attributes in /sys/class/ieee80211/phyX/ */
-
-static ssize_t store_rate_ctrl_alg(struct device *dev,
- struct device_attribute *attr,
- const char *buf, size_t len)
-{
- struct ieee80211_local *local = to_ieee80211_local(dev);
- int res;
-
- if (!capable(CAP_NET_ADMIN))
- return -EPERM;
- res = rtnl_lock_local(local);
- if (res)
- return res;
- res = ieee80211_init_rate_ctrl_alg(local, buf);
- rtnl_unlock();
- return res < 0 ? res : len;
-}
-
-static ssize_t ieee80211_local_show(
- struct device *dev,
- struct device_attribute *attr,
- char *buf,
- ssize_t (*format)(struct ieee80211_local *, char *))
-{
- struct ieee80211_local *local = to_ieee80211_local(dev);
- ssize_t ret = -EINVAL;
-
- if (local->reg_state == IEEE80211_DEV_REGISTERED)
- ret = (*format)(local, buf);
- return ret;
-}
-
-#define IEEE80211_LOCAL_FMT(name, field, format_string) \
-static ssize_t ieee80211_local_fmt_##name(struct ieee80211_local *local,\
- char *buf) \
-{ \
- return sprintf(buf, format_string, local->field); \
-}
-
-#define __IEEE80211_LOCAL_SHOW(name) \
-static ssize_t ieee80211_local_show_##name(struct device *dev, \
- struct device_attribute *attr,\
- char *buf) \
-{ \
- return ieee80211_local_show(dev, attr, buf, \
- ieee80211_local_fmt_##name); \
-}
-
-#define IEEE80211_LOCAL_SHOW(name, field, format) \
- IEEE80211_LOCAL_FMT(name, field, format "\n") \
- __IEEE80211_LOCAL_SHOW(name)
-
-IEEE80211_LOCAL_SHOW(channel, hw.conf.channel, "%d");
-IEEE80211_LOCAL_SHOW(frequency, hw.conf.freq, "%d");
-IEEE80211_LOCAL_SHOW(radar_detect, hw.conf.radar_detect, "%d");
-IEEE80211_LOCAL_SHOW(antenna_sel_tx, hw.conf.antenna_sel_tx, "%d");
-IEEE80211_LOCAL_SHOW(antenna_sel_rx, hw.conf.antenna_sel_rx, "%d");
-IEEE80211_LOCAL_SHOW(bridge_packets, bridge_packets, "%d");
-IEEE80211_LOCAL_SHOW(key_tx_rx_threshold, key_tx_rx_threshold, "%d");
-IEEE80211_LOCAL_SHOW(rts_threshold, rts_threshold, "%d");
-IEEE80211_LOCAL_SHOW(fragmentation_threshold, fragmentation_threshold, "%d");
-IEEE80211_LOCAL_SHOW(short_retry_limit, short_retry_limit, "%d");
-IEEE80211_LOCAL_SHOW(long_retry_limit, long_retry_limit, "%d");
-IEEE80211_LOCAL_SHOW(total_ps_buffered, total_ps_buffered, "%d");
-
-static ssize_t ieee80211_local_fmt_mode(struct ieee80211_local *local,
- char *buf)
-{
- return sprintf(buf, "%s\n", ieee80211_mode_str(local->hw.conf.phymode));
-}
-__IEEE80211_LOCAL_SHOW(mode);
-
-static ssize_t ieee80211_local_fmt_wep_iv(struct ieee80211_local *local,
- char *buf)
-{
- return sprintf(buf, "%#06x\n", local->wep_iv & 0xffffff);
-}
-__IEEE80211_LOCAL_SHOW(wep_iv);
-
-static ssize_t ieee80211_local_fmt_tx_power_reduction(struct ieee80211_local
- *local, char *buf)
-{
- short tx_power_reduction = local->hw.conf.tx_power_reduction;
-
- return sprintf(buf, "%d.%d dBm\n", tx_power_reduction / 10,
- tx_power_reduction % 10);
-}
-__IEEE80211_LOCAL_SHOW(tx_power_reduction);
-
-static ssize_t ieee80211_local_fmt_modes(struct ieee80211_local *local,
- char *buf)
-{
- struct ieee80211_hw_mode *mode;
- char *p = buf;
-
- /* FIXME: Locking? Could register a mode in the meantime. */
- list_for_each_entry(mode, &local->modes_list, list)
- p += sprintf(p, "%s\n", ieee80211_mode_str_short(mode->mode));
-
- return (p - buf);
-}
-__IEEE80211_LOCAL_SHOW(modes);
-
-static ssize_t ieee80211_local_fmt_rate_ctrl_alg(struct ieee80211_local *local,
- char *buf)
-{
- struct rate_control_ref *ref = local->rate_ctrl;
- if (ref)
- return sprintf(buf, "%s\n", ref->ops->name);
- return 0;
-}
-__IEEE80211_LOCAL_SHOW(rate_ctrl_alg);
-
-static struct device_attribute ieee80211_dev_attrs[] = {
- __ATTR(channel, S_IRUGO, ieee80211_local_show_channel, NULL),
- __ATTR(frequency, S_IRUGO, ieee80211_local_show_frequency, NULL),
- __ATTR(radar_detect, S_IRUGO, ieee80211_local_show_radar_detect, NULL),
- __ATTR(antenna_sel_tx, S_IRUGO, ieee80211_local_show_antenna_sel_tx, NULL),
- __ATTR(antenna_sel_rx, S_IRUGO, ieee80211_local_show_antenna_sel_rx, NULL),
- __ATTR(bridge_packets, S_IRUGO, ieee80211_local_show_bridge_packets, NULL),
- __ATTR(key_tx_rx_threshold, S_IRUGO, ieee80211_local_show_key_tx_rx_threshold, NULL),
- __ATTR(rts_threshold, S_IRUGO, ieee80211_local_show_rts_threshold, NULL),
- __ATTR(fragmentation_threshold, S_IRUGO, ieee80211_local_show_fragmentation_threshold, NULL),
- __ATTR(short_retry_limit, S_IRUGO, ieee80211_local_show_short_retry_limit, NULL),
- __ATTR(long_retry_limit, S_IRUGO, ieee80211_local_show_long_retry_limit, NULL),
- __ATTR(total_ps_buffered, S_IRUGO, ieee80211_local_show_total_ps_buffered, NULL),
- __ATTR(mode, S_IRUGO, ieee80211_local_show_mode, NULL),
- __ATTR(wep_iv, S_IRUGO, ieee80211_local_show_wep_iv, NULL),
- __ATTR(tx_power_reduction, S_IRUGO, ieee80211_local_show_tx_power_reduction, NULL),
- __ATTR(modes, S_IRUGO, ieee80211_local_show_modes, NULL),
- __ATTR(rate_ctrl_alg, S_IRUGO | S_IWUGO, ieee80211_local_show_rate_ctrl_alg, store_rate_ctrl_alg),
-};
-
-/* attributes in /sys/class/ieee80211/phyX/statistics/ */
-
-#define IEEE80211_LOCAL_ATTR(name, field, format) \
-IEEE80211_LOCAL_SHOW(name, field, format) \
-static DEVICE_ATTR(name, S_IRUGO, ieee80211_local_show_##name, NULL);
-
-IEEE80211_LOCAL_ATTR(transmitted_fragment_count, dot11TransmittedFragmentCount, "%u");
-IEEE80211_LOCAL_ATTR(multicast_transmitted_frame_count, dot11MulticastTransmittedFrameCount, "%u");
-IEEE80211_LOCAL_ATTR(failed_count, dot11FailedCount, "%u");
-IEEE80211_LOCAL_ATTR(retry_count, dot11RetryCount, "%u");
-IEEE80211_LOCAL_ATTR(multiple_retry_count, dot11MultipleRetryCount, "%u");
-IEEE80211_LOCAL_ATTR(frame_duplicate_count, dot11FrameDuplicateCount, "%u");
-IEEE80211_LOCAL_ATTR(received_fragment_count, dot11ReceivedFragmentCount, "%u");
-IEEE80211_LOCAL_ATTR(multicast_received_frame_count, dot11MulticastReceivedFrameCount, "%u");
-IEEE80211_LOCAL_ATTR(transmitted_frame_count, dot11TransmittedFrameCount, "%u");
-IEEE80211_LOCAL_ATTR(wep_undecryptable_count, dot11WEPUndecryptableCount, "%u");
-IEEE80211_LOCAL_ATTR(num_scans, scan.num_scans, "%u");
-
-#ifdef CONFIG_MAC80211_DEBUG_COUNTERS
-IEEE80211_LOCAL_ATTR(tx_handlers_drop, tx_handlers_drop, "%u");
-IEEE80211_LOCAL_ATTR(tx_handlers_queued, tx_handlers_queued, "%u");
-IEEE80211_LOCAL_ATTR(tx_handlers_drop_unencrypted, tx_handlers_drop_unencrypted, "%u");
-IEEE80211_LOCAL_ATTR(tx_handlers_drop_fragment, tx_handlers_drop_fragment, "%u");
-IEEE80211_LOCAL_ATTR(tx_handlers_drop_wep, tx_handlers_drop_wep, "%u");
-IEEE80211_LOCAL_ATTR(tx_handlers_drop_not_assoc, tx_handlers_drop_not_assoc, "%u");
-IEEE80211_LOCAL_ATTR(tx_handlers_drop_unauth_port, tx_handlers_drop_unauth_port, "%u");
-IEEE80211_LOCAL_ATTR(rx_handlers_drop, rx_handlers_drop, "%u");
-IEEE80211_LOCAL_ATTR(rx_handlers_queued, rx_handlers_queued, "%u");
-IEEE80211_LOCAL_ATTR(rx_handlers_drop_nullfunc, rx_handlers_drop_nullfunc, "%u");
-IEEE80211_LOCAL_ATTR(rx_handlers_drop_defrag, rx_handlers_drop_defrag, "%u");
-IEEE80211_LOCAL_ATTR(rx_handlers_drop_short, rx_handlers_drop_short, "%u");
-IEEE80211_LOCAL_ATTR(rx_handlers_drop_passive_scan, rx_handlers_drop_passive_scan, "%u");
-IEEE80211_LOCAL_ATTR(tx_expand_skb_head, tx_expand_skb_head, "%u");
-IEEE80211_LOCAL_ATTR(tx_expand_skb_head_cloned, tx_expand_skb_head_cloned, "%u");
-IEEE80211_LOCAL_ATTR(rx_expand_skb_head, rx_expand_skb_head, "%u");
-IEEE80211_LOCAL_ATTR(rx_expand_skb_head2, rx_expand_skb_head2, "%u");
-IEEE80211_LOCAL_ATTR(rx_handlers_fragments, rx_handlers_fragments, "%u");
-IEEE80211_LOCAL_ATTR(tx_status_drop, tx_status_drop, "%u");
-
-static ssize_t ieee80211_local_fmt_wme_rx_queue(struct ieee80211_local *local,
- char *buf)
-{
- int i;
- char *p = buf;
-
- for (i = 0; i < NUM_RX_DATA_QUEUES; i++)
- p += sprintf(p, "%u\n", local->wme_rx_queue[i]);
- return (p - buf);
-}
-__IEEE80211_LOCAL_SHOW(wme_rx_queue);
-static DEVICE_ATTR(wme_rx_queue, S_IRUGO,
- ieee80211_local_show_wme_rx_queue, NULL);
-
-static ssize_t ieee80211_local_fmt_wme_tx_queue(struct ieee80211_local *local,
- char *buf)
-{
- int i;
- char *p = buf;
-
- for (i = 0; i < NUM_RX_DATA_QUEUES; i++)
- p += sprintf(p, "%u\n", local->wme_tx_queue[i]);
- return (p - buf);
-}
-__IEEE80211_LOCAL_SHOW(wme_tx_queue);
-static DEVICE_ATTR(wme_tx_queue, S_IRUGO,
- ieee80211_local_show_wme_tx_queue, NULL);
-#endif
-
-static ssize_t ieee80211_stats_show(struct device *dev,
- struct device_attribute *attr,
- char *buf,
- ssize_t (*format)(struct ieee80211_low_level_stats *, char *))
-{
- struct ieee80211_local *local = to_ieee80211_local(dev);
- struct ieee80211_low_level_stats stats;
- ssize_t ret = -EINVAL;
-
- if (!local->ops->get_stats)
- return -EOPNOTSUPP;
- ret = rtnl_lock_local(local);
- if (ret)
- return ret;
- ret = local->ops->get_stats(local_to_hw(local), &stats);
- rtnl_unlock();
- if (!ret)
- ret = (*format)(&stats, buf);
- return ret;
-}
-
-#define IEEE80211_STATS_FMT(name, field, format_string) \
-static ssize_t ieee80211_stats_fmt_##name(struct ieee80211_low_level_stats \
- *stats, char *buf) \
-{ \
- return sprintf(buf, format_string, stats->field); \
-}
-
-#define __IEEE80211_STATS_SHOW(name) \
-static ssize_t ieee80211_stats_show_##name(struct device *dev, \
- struct device_attribute *attr,\
- char *buf) \
-{ \
- return ieee80211_stats_show(dev, attr, buf, \
- ieee80211_stats_fmt_##name); \
-}
-
-#define IEEE80211_STATS_ATTR(name, field, format) \
-IEEE80211_STATS_FMT(name, field, format "\n") \
-__IEEE80211_STATS_SHOW(name) \
-static DEVICE_ATTR(name, S_IRUGO, ieee80211_stats_show_##name, NULL);
-
-IEEE80211_STATS_ATTR(ack_failure_count, dot11ACKFailureCount, "%u");
-IEEE80211_STATS_ATTR(rts_failure_count, dot11RTSFailureCount, "%u");
-IEEE80211_STATS_ATTR(fcs_error_count, dot11FCSErrorCount, "%u");
-IEEE80211_STATS_ATTR(rts_success_count, dot11RTSSuccessCount, "%u");
-
-static struct attribute *ieee80211_stats_attrs[] = {
- &dev_attr_transmitted_fragment_count.attr,
- &dev_attr_multicast_transmitted_frame_count.attr,
- &dev_attr_failed_count.attr,
- &dev_attr_retry_count.attr,
- &dev_attr_multiple_retry_count.attr,
- &dev_attr_frame_duplicate_count.attr,
- &dev_attr_received_fragment_count.attr,
- &dev_attr_multicast_received_frame_count.attr,
- &dev_attr_transmitted_frame_count.attr,
- &dev_attr_wep_undecryptable_count.attr,
- &dev_attr_ack_failure_count.attr,
- &dev_attr_rts_failure_count.attr,
- &dev_attr_fcs_error_count.attr,
- &dev_attr_rts_success_count.attr,
- &dev_attr_num_scans.attr,
-#ifdef CONFIG_MAC80211_DEBUG_COUNTERS
- &dev_attr_tx_handlers_drop.attr,
- &dev_attr_tx_handlers_queued.attr,
- &dev_attr_tx_handlers_drop_unencrypted.attr,
- &dev_attr_tx_handlers_drop_fragment.attr,
- &dev_attr_tx_handlers_drop_wep.attr,
- &dev_attr_tx_handlers_drop_not_assoc.attr,
- &dev_attr_tx_handlers_drop_unauth_port.attr,
- &dev_attr_rx_handlers_drop.attr,
- &dev_attr_rx_handlers_queued.attr,
- &dev_attr_rx_handlers_drop_nullfunc.attr,
- &dev_attr_rx_handlers_drop_defrag.attr,
- &dev_attr_rx_handlers_drop_short.attr,
- &dev_attr_rx_handlers_drop_passive_scan.attr,
- &dev_attr_tx_expand_skb_head.attr,
- &dev_attr_tx_expand_skb_head_cloned.attr,
- &dev_attr_rx_expand_skb_head.attr,
- &dev_attr_rx_expand_skb_head2.attr,
- &dev_attr_rx_handlers_fragments.attr,
- &dev_attr_tx_status_drop.attr,
- &dev_attr_wme_rx_queue.attr,
- &dev_attr_wme_tx_queue.attr,
-#endif
- NULL,
-};
-
-static struct attribute_group ieee80211_stats_group = {
- .name = "statistics",
- .attrs = ieee80211_stats_attrs,
-};
-
/* attributes in /sys/class/net/X/ */
static ssize_t ieee80211_if_show(struct device *d,
@@ -595,53 +267,6 @@ static struct attribute_group ieee80211_
.attrs = ieee80211_monitor_attrs,
};
-int ieee80211_dev_sysfs_add(struct ieee80211_local *local)
-{
- const struct device_attribute *attr;
- int i, err;
-
- for (i = 0; i < ARRAY_SIZE(ieee80211_dev_attrs); i++) {
- attr = &ieee80211_dev_attrs[i];
- err = sysfs_create_file(&local->hw.wiphy->dev.kobj,
- &attr->attr);
- if (err)
- goto unwind;
- }
-
- err = sysfs_create_group(&local->hw.wiphy->dev.kobj,
- &ieee80211_stats_group);
-
- if (err == 0)
- return err;
-
- unwind:
- /* one after the failed/last one */
- i--;
- while (i >= 0) {
- attr = &ieee80211_dev_attrs[i];
- sysfs_remove_file(&local->hw.wiphy->dev.kobj,
- &attr->attr);
- i--;
- }
- return err;
-}
-
-void ieee80211_dev_sysfs_del(struct ieee80211_local *local)
-{
- const struct device_attribute *attr;
- int i;
-
- sysfs_remove_group(&local->hw.wiphy->dev.kobj,
- &ieee80211_stats_group);
-
- for (i = 0; i < ARRAY_SIZE(ieee80211_dev_attrs); i++) {
- attr = &ieee80211_dev_attrs[i];
- sysfs_remove_file(&local->hw.wiphy->dev.kobj,
- &attr->attr);
- }
-}
-
-
/* /sys/class/net/X functions */
static void __ieee80211_remove_if_group(struct kobject *kobj,
--- wireless-dev.orig/net/mac80211/ieee80211_sysfs.h 2007-03-07 13:02:31.544710923 +0100
+++ wireless-dev/net/mac80211/ieee80211_sysfs.h 2007-03-07 13:03:54.944710923 +0100
@@ -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 */
--- /dev/null 1970-01-01 00:00:00.000000000 +0000
+++ wireless-dev/net/mac80211/debugfs.c 2007-03-07 13:03:54.944710923 +0100
@@ -0,0 +1,429 @@
+/*
+ * mac80211 debugfs for wireless PHYs
+ *
+ * Copyright 2007 Johannes Berg <johannes@sipsolutions.net>
+ *
+ * GPLv2
+ *
+ */
+
+#include <linux/debugfs.h>
+#include <linux/rtnetlink.h>
+#include "ieee80211_i.h"
+#include "ieee80211_rate.h"
+#include "debugfs.h"
+
+static int mac80211_open_file_generic(struct inode *inode, struct file *file)
+{
+ file->private_data = inode->i_private;
+ return 0;
+}
+
+static const char *ieee80211_mode_str(int mode)
+{
+ switch (mode) {
+ case MODE_IEEE80211A:
+ return "IEEE 802.11a";
+ case MODE_IEEE80211B:
+ return "IEEE 802.11b";
+ case MODE_IEEE80211G:
+ return "IEEE 802.11g";
+ case MODE_ATHEROS_TURBO:
+ return "Atheros Turbo (5 GHz)";
+ default:
+ return "UNKNOWN";
+ }
+}
+
+static ssize_t modes_read(struct file *file, char __user *userbuf,
+ size_t count, loff_t *ppos)
+{
+ struct ieee80211_local *local = file->private_data;
+ struct ieee80211_hw_mode *mode;
+ char buf[150], *p = buf;
+
+ /* FIXME: locking! */
+ list_for_each_entry(mode, &local->modes_list, list) {
+ p += scnprintf(p, sizeof(buf)+buf-p,
+ "%s\n", ieee80211_mode_str(mode->mode));
+ }
+
+ return simple_read_from_buffer(userbuf, count, ppos, buf, p-buf);
+}
+
+static const struct file_operations modes_ops = {
+ .read = modes_read,
+ .open = mac80211_open_file_generic,
+};
+
+#define DEBUGFS_READONLY_FILE(name, buflen, fmt, value...) \
+static ssize_t name## _read(struct file *file, char __user *userbuf, \
+ size_t count, loff_t *ppos) \
+{ \
+ struct ieee80211_local *local = file->private_data; \
+ char buf[buflen]; \
+ int res; \
+ \
+ res = scnprintf(buf, buflen, fmt "\n", ##value); \
+ return simple_read_from_buffer(userbuf, count, ppos, buf, res); \
+} \
+ \
+static const struct file_operations name## _ops = { \
+ .read = name## _read, \
+ .open = mac80211_open_file_generic, \
+};
+
+#define DEBUGFS_ADD(name) \
+ local->debugfs.name = debugfs_create_file(#name, 0444, phyd, \
+ local, &name## _ops);
+
+#define DEBUGFS_DEL(name) \
+ debugfs_remove(local->debugfs.name); \
+ local->debugfs.name = NULL;
+
+
+DEBUGFS_READONLY_FILE(channel, 20, "%d",
+ local->hw.conf.channel);
+DEBUGFS_READONLY_FILE(frequency, 20, "%d",
+ local->hw.conf.freq);
+DEBUGFS_READONLY_FILE(radar_detect, 20, "%d",
+ local->hw.conf.radar_detect);
+DEBUGFS_READONLY_FILE(antenna_sel_tx, 20, "%d",
+ local->hw.conf.antenna_sel_tx);
+DEBUGFS_READONLY_FILE(antenna_sel_rx, 20, "%d",
+ local->hw.conf.antenna_sel_rx);
+DEBUGFS_READONLY_FILE(bridge_packets, 20, "%d",
+ local->bridge_packets);
+DEBUGFS_READONLY_FILE(key_tx_rx_threshold, 20, "%d",
+ local->key_tx_rx_threshold);
+DEBUGFS_READONLY_FILE(rts_threshold, 20, "%d",
+ local->rts_threshold);
+DEBUGFS_READONLY_FILE(fragmentation_threshold, 20, "%d",
+ local->fragmentation_threshold);
+DEBUGFS_READONLY_FILE(short_retry_limit, 20, "%d",
+ local->short_retry_limit);
+DEBUGFS_READONLY_FILE(long_retry_limit, 20, "%d",
+ local->long_retry_limit);
+DEBUGFS_READONLY_FILE(total_ps_buffered, 20, "%d",
+ local->total_ps_buffered);
+DEBUGFS_READONLY_FILE(mode, 20, "%s",
+ ieee80211_mode_str(local->hw.conf.phymode));
+DEBUGFS_READONLY_FILE(wep_iv, 20, "%#06x",
+ local->wep_iv & 0xffffff);
+DEBUGFS_READONLY_FILE(tx_power_reduction, 20, "%d.%d dBm",
+ local->hw.conf.tx_power_reduction / 10,
+ local->hw.conf.tx_power_reduction & 10);
+DEBUGFS_READONLY_FILE(rate_ctrl_alg, 100, "%s",
+ local->rate_ctrl ? local->rate_ctrl->ops->name : "<unset>");
+
+/* statistics stuff */
+
+static inline int rtnl_lock_local(struct ieee80211_local *local)
+{
+ rtnl_lock();
+ if (unlikely(local->reg_state != IEEE80211_DEV_REGISTERED)) {
+ rtnl_unlock();
+ return -ENODEV;
+ }
+ return 0;
+}
+
+#define DEBUGFS_STATS_FILE(name, buflen, fmt, value...) \
+ DEBUGFS_READONLY_FILE(stats_ ##name, buflen, fmt, ##value)
+
+static ssize_t format_devstat_counter(struct ieee80211_local *local,
+ char __user *userbuf,
+ size_t count, loff_t *ppos,
+ int (*printvalue)(struct ieee80211_low_level_stats *stats, char *buf,
+ int buflen))
+{
+ struct ieee80211_low_level_stats stats;
+ char buf[20];
+ int res;
+
+ if (!local->ops->get_stats)
+ return -EOPNOTSUPP;
+
+ res = rtnl_lock_local(local);
+ if (res)
+ return res;
+
+ res = local->ops->get_stats(local_to_hw(local), &stats);
+ rtnl_unlock();
+ if (!res)
+ res = printvalue(&stats, buf, sizeof(buf));
+ return simple_read_from_buffer(userbuf, count, ppos, buf, res);
+}
+
+#define DEBUGFS_DEVSTATS_FILE(name) \
+static int print_devstats_##name(struct ieee80211_low_level_stats *stats,\
+ char *buf, int buflen) \
+{ \
+ return scnprintf(buf, buflen, "%u\n", stats->name); \
+} \
+static ssize_t stats_ ##name## _read(struct file *file, \
+ char __user *userbuf, \
+ size_t count, loff_t *ppos) \
+{ \
+ return format_devstat_counter(file->private_data, \
+ userbuf, \
+ count, \
+ ppos, \
+ print_devstats_##name); \
+} \
+ \
+static const struct file_operations stats_ ##name## _ops = { \
+ .read = stats_ ##name## _read, \
+ .open = mac80211_open_file_generic, \
+};
+
+#define DEBUGFS_STATS_ADD(name) \
+ local->debugfs.stats.name = debugfs_create_file(#name, 0444, statsd,\
+ local, &stats_ ##name## _ops);
+
+#define DEBUGFS_STATS_DEL(name) \
+ debugfs_remove(local->debugfs.stats.name); \
+ local->debugfs.stats.name = NULL;
+
+DEBUGFS_STATS_FILE(transmitted_fragment_count, 20, "%u",
+ local->dot11TransmittedFragmentCount);
+DEBUGFS_STATS_FILE(multicast_transmitted_frame_count, 20, "%u",
+ local->dot11MulticastTransmittedFrameCount);
+DEBUGFS_STATS_FILE(failed_count, 20, "%u",
+ local->dot11FailedCount);
+DEBUGFS_STATS_FILE(retry_count, 20, "%u",
+ local->dot11RetryCount);
+DEBUGFS_STATS_FILE(multiple_retry_count, 20, "%u",
+ local->dot11MultipleRetryCount);
+DEBUGFS_STATS_FILE(frame_duplicate_count, 20, "%u",
+ local->dot11FrameDuplicateCount);
+DEBUGFS_STATS_FILE(received_fragment_count, 20, "%u",
+ local->dot11ReceivedFragmentCount);
+DEBUGFS_STATS_FILE(multicast_received_frame_count, 20, "%u",
+ local->dot11MulticastReceivedFrameCount);
+DEBUGFS_STATS_FILE(transmitted_frame_count, 20, "%u",
+ local->dot11TransmittedFrameCount);
+DEBUGFS_STATS_FILE(wep_undecryptable_count, 20, "%u",
+ local->dot11WEPUndecryptableCount);
+DEBUGFS_STATS_FILE(num_scans, 20, "%u",
+ local->scan.num_scans);
+#ifdef CONFIG_MAC80211_DEBUG_COUNTERS
+DEBUGFS_STATS_FILE(tx_handlers_drop, 20, "%u",
+ local->tx_handlers_drop);
+DEBUGFS_STATS_FILE(tx_handlers_queued, 20, "%u",
+ local->tx_handlers_queued);
+DEBUGFS_STATS_FILE(tx_handlers_drop_unencrypted, 20, "%u",
+ local->tx_handlers_drop_unencrypted);
+DEBUGFS_STATS_FILE(tx_handlers_drop_fragment, 20, "%u",
+ local->tx_handlers_drop_fragment);
+DEBUGFS_STATS_FILE(tx_handlers_drop_wep, 20, "%u",
+ local->tx_handlers_drop_wep);
+DEBUGFS_STATS_FILE(tx_handlers_drop_not_assoc, 20, "%u",
+ local->tx_handlers_drop_not_assoc);
+DEBUGFS_STATS_FILE(tx_handlers_drop_unauth_port, 20, "%u",
+ local->tx_handlers_drop_unauth_port);
+DEBUGFS_STATS_FILE(rx_handlers_drop, 20, "%u",
+ local->rx_handlers_drop);
+DEBUGFS_STATS_FILE(rx_handlers_queued, 20, "%u",
+ local->rx_handlers_queued);
+DEBUGFS_STATS_FILE(rx_handlers_drop_nullfunc, 20, "%u",
+ local->rx_handlers_drop_nullfunc);
+DEBUGFS_STATS_FILE(rx_handlers_drop_defrag, 20, "%u",
+ local->rx_handlers_drop_defrag);
+DEBUGFS_STATS_FILE(rx_handlers_drop_short, 20, "%u",
+ local->rx_handlers_drop_short);
+DEBUGFS_STATS_FILE(rx_handlers_drop_passive_scan, 20, "%u",
+ local->rx_handlers_drop_passive_scan);
+DEBUGFS_STATS_FILE(tx_expand_skb_head, 20, "%u",
+ local->tx_expand_skb_head);
+DEBUGFS_STATS_FILE(tx_expand_skb_head_cloned, 20, "%u",
+ local->tx_expand_skb_head_cloned);
+DEBUGFS_STATS_FILE(rx_expand_skb_head, 20, "%u",
+ local->rx_expand_skb_head);
+DEBUGFS_STATS_FILE(rx_expand_skb_head2, 20, "%u",
+ local->rx_expand_skb_head2);
+DEBUGFS_STATS_FILE(rx_handlers_fragments, 20, "%u",
+ local->rx_handlers_fragments);
+DEBUGFS_STATS_FILE(tx_status_drop, 20, "%u",
+ local->tx_status_drop);
+#endif
+
+DEBUGFS_DEVSTATS_FILE(dot11ACKFailureCount);
+DEBUGFS_DEVSTATS_FILE(dot11RTSFailureCount);
+DEBUGFS_DEVSTATS_FILE(dot11FCSErrorCount);
+DEBUGFS_DEVSTATS_FILE(dot11RTSSuccessCount);
+
+static ssize_t stats_wme_rx_queue_read(struct file *file,
+ char __user *userbuf,
+ size_t count, loff_t *ppos)
+{
+ struct ieee80211_local *local = file->private_data;
+ char buf[NUM_RX_DATA_QUEUES*15], *p = buf;
+ int i;
+
+ for (i = 0; i < NUM_RX_DATA_QUEUES; i++)
+ p += scnprintf(p, sizeof(buf)+buf-p,
+ "%u\n", local->wme_rx_queue[i]);
+
+ return simple_read_from_buffer(userbuf, count, ppos, buf, p-buf);
+}
+
+static const struct file_operations stats_wme_rx_queue_ops = {
+ .read = stats_wme_rx_queue_read,
+ .open = mac80211_open_file_generic,
+};
+
+static ssize_t stats_wme_tx_queue_read(struct file *file,
+ char __user *userbuf,
+ size_t count, loff_t *ppos)
+{
+ struct ieee80211_local *local = file->private_data;
+ char buf[NUM_TX_DATA_QUEUES*15], *p = buf;
+ int i;
+
+ for (i = 0; i < NUM_TX_DATA_QUEUES; i++)
+ p += scnprintf(p, sizeof(buf)+buf-p,
+ "%u\n", local->wme_tx_queue[i]);
+
+ return simple_read_from_buffer(userbuf, count, ppos, buf, p-buf);
+}
+
+static const struct file_operations stats_wme_tx_queue_ops = {
+ .read = stats_wme_tx_queue_read,
+ .open = mac80211_open_file_generic,
+};
+
+
+void debugfs_hw_add(struct ieee80211_local *local)
+{
+ struct dentry *phyd = local->hw.wiphy->debugfsdir;
+ struct dentry *statsd;
+
+ if (!phyd)
+ return;
+
+ DEBUGFS_ADD(channel);
+ DEBUGFS_ADD(frequency);
+ DEBUGFS_ADD(radar_detect);
+ DEBUGFS_ADD(antenna_sel_tx);
+ DEBUGFS_ADD(antenna_sel_rx);
+ DEBUGFS_ADD(bridge_packets);
+ DEBUGFS_ADD(key_tx_rx_threshold);
+ DEBUGFS_ADD(rts_threshold);
+ DEBUGFS_ADD(fragmentation_threshold);
+ DEBUGFS_ADD(short_retry_limit);
+ DEBUGFS_ADD(long_retry_limit);
+ DEBUGFS_ADD(total_ps_buffered);
+ DEBUGFS_ADD(mode);
+ DEBUGFS_ADD(wep_iv);
+ DEBUGFS_ADD(tx_power_reduction);
+ DEBUGFS_ADD(modes);
+
+ statsd = debugfs_create_dir("statistics", phyd);
+ local->debugfs.statistics = statsd;
+
+ /* if the dir failed, don't put all the other things into the root! */
+ if (!statsd)
+ return;
+
+ DEBUGFS_STATS_ADD(transmitted_fragment_count);
+ DEBUGFS_STATS_ADD(multicast_transmitted_frame_count);
+ DEBUGFS_STATS_ADD(failed_count);
+ DEBUGFS_STATS_ADD(retry_count);
+ DEBUGFS_STATS_ADD(multiple_retry_count);
+ DEBUGFS_STATS_ADD(frame_duplicate_count);
+ DEBUGFS_STATS_ADD(received_fragment_count);
+ DEBUGFS_STATS_ADD(multicast_received_frame_count);
+ DEBUGFS_STATS_ADD(transmitted_frame_count);
+ DEBUGFS_STATS_ADD(wep_undecryptable_count);
+ DEBUGFS_STATS_ADD(num_scans);
+#ifdef CONFIG_MAC80211_DEBUG_COUNTERS
+ DEBUGFS_STATS_ADD(tx_handlers_drop);
+ DEBUGFS_STATS_ADD(tx_handlers_queued);
+ DEBUGFS_STATS_ADD(tx_handlers_drop_unencrypted);
+ DEBUGFS_STATS_ADD(tx_handlers_drop_fragment);
+ DEBUGFS_STATS_ADD(tx_handlers_drop_wep);
+ DEBUGFS_STATS_ADD(tx_handlers_drop_not_assoc);
+ DEBUGFS_STATS_ADD(tx_handlers_drop_unauth_port);
+ DEBUGFS_STATS_ADD(rx_handlers_drop);
+ DEBUGFS_STATS_ADD(rx_handlers_queued);
+ DEBUGFS_STATS_ADD(rx_handlers_drop_nullfunc);
+ DEBUGFS_STATS_ADD(rx_handlers_drop_defrag);
+ DEBUGFS_STATS_ADD(rx_handlers_drop_short);
+ DEBUGFS_STATS_ADD(rx_handlers_drop_passive_scan);
+ DEBUGFS_STATS_ADD(tx_expand_skb_head);
+ DEBUGFS_STATS_ADD(tx_expand_skb_head_cloned);
+ DEBUGFS_STATS_ADD(rx_expand_skb_head);
+ DEBUGFS_STATS_ADD(rx_expand_skb_head2);
+ DEBUGFS_STATS_ADD(rx_handlers_fragments);
+ DEBUGFS_STATS_ADD(tx_status_drop);
+#endif
+ DEBUGFS_STATS_ADD(dot11ACKFailureCount);
+ DEBUGFS_STATS_ADD(dot11RTSFailureCount);
+ DEBUGFS_STATS_ADD(dot11FCSErrorCount);
+ DEBUGFS_STATS_ADD(dot11RTSSuccessCount);
+ DEBUGFS_STATS_ADD(wme_tx_queue);
+ DEBUGFS_STATS_ADD(wme_rx_queue);
+}
+
+void debugfs_hw_del(struct ieee80211_local *local)
+{
+ DEBUGFS_DEL(channel);
+ DEBUGFS_DEL(frequency);
+ DEBUGFS_DEL(radar_detect);
+ DEBUGFS_DEL(antenna_sel_tx);
+ DEBUGFS_DEL(antenna_sel_rx);
+ DEBUGFS_DEL(bridge_packets);
+ DEBUGFS_DEL(key_tx_rx_threshold);
+ DEBUGFS_DEL(rts_threshold);
+ DEBUGFS_DEL(fragmentation_threshold);
+ DEBUGFS_DEL(short_retry_limit);
+ DEBUGFS_DEL(long_retry_limit);
+ DEBUGFS_DEL(total_ps_buffered);
+ DEBUGFS_DEL(mode);
+ DEBUGFS_DEL(wep_iv);
+ DEBUGFS_DEL(tx_power_reduction);
+ DEBUGFS_DEL(modes);
+
+ DEBUGFS_STATS_DEL(transmitted_fragment_count);
+ DEBUGFS_STATS_DEL(multicast_transmitted_frame_count);
+ DEBUGFS_STATS_DEL(failed_count);
+ DEBUGFS_STATS_DEL(retry_count);
+ DEBUGFS_STATS_DEL(multiple_retry_count);
+ DEBUGFS_STATS_DEL(frame_duplicate_count);
+ DEBUGFS_STATS_DEL(received_fragment_count);
+ DEBUGFS_STATS_DEL(multicast_received_frame_count);
+ DEBUGFS_STATS_DEL(transmitted_frame_count);
+ DEBUGFS_STATS_DEL(wep_undecryptable_count);
+ DEBUGFS_STATS_DEL(num_scans);
+#ifdef CONFIG_MAC80211_DEBUG_COUNTERS
+ DEBUGFS_STATS_DEL(tx_handlers_drop);
+ DEBUGFS_STATS_DEL(tx_handlers_queued);
+ DEBUGFS_STATS_DEL(tx_handlers_drop_unencrypted);
+ DEBUGFS_STATS_DEL(tx_handlers_drop_fragment);
+ DEBUGFS_STATS_DEL(tx_handlers_drop_wep);
+ DEBUGFS_STATS_DEL(tx_handlers_drop_not_assoc);
+ DEBUGFS_STATS_DEL(tx_handlers_drop_unauth_port);
+ DEBUGFS_STATS_DEL(rx_handlers_drop);
+ DEBUGFS_STATS_DEL(rx_handlers_queued);
+ DEBUGFS_STATS_DEL(rx_handlers_drop_nullfunc);
+ DEBUGFS_STATS_DEL(rx_handlers_drop_defrag);
+ DEBUGFS_STATS_DEL(rx_handlers_drop_short);
+ DEBUGFS_STATS_DEL(rx_handlers_drop_passive_scan);
+ DEBUGFS_STATS_DEL(tx_expand_skb_head);
+ DEBUGFS_STATS_DEL(tx_expand_skb_head_cloned);
+ DEBUGFS_STATS_DEL(rx_expand_skb_head);
+ DEBUGFS_STATS_DEL(rx_expand_skb_head2);
+ DEBUGFS_STATS_DEL(rx_handlers_fragments);
+ DEBUGFS_STATS_DEL(tx_status_drop);
+#endif
+ DEBUGFS_STATS_DEL(dot11ACKFailureCount);
+ DEBUGFS_STATS_DEL(dot11RTSFailureCount);
+ DEBUGFS_STATS_DEL(dot11FCSErrorCount);
+ DEBUGFS_STATS_DEL(dot11RTSSuccessCount);
+ DEBUGFS_STATS_DEL(wme_tx_queue);
+ DEBUGFS_STATS_DEL(wme_rx_queue);
+
+ debugfs_remove(local->debugfs.statistics);
+ local->debugfs.statistics = NULL;
+}
--- wireless-dev.orig/net/mac80211/ieee80211_i.h 2007-03-07 13:03:50.454710923 +0100
+++ wireless-dev/net/mac80211/ieee80211_i.h 2007-03-07 13:03:54.944710923 +0100
@@ -539,6 +539,68 @@ struct ieee80211_local {
* (1 << MODE_*) */
int user_space_mlme;
+
+#ifdef CONFIG_DEBUG_FS
+ struct local_debugfsdentries {
+ struct dentry *channel;
+ struct dentry *frequency;
+ struct dentry *radar_detect;
+ struct dentry *antenna_sel_tx;
+ struct dentry *antenna_sel_rx;
+ struct dentry *bridge_packets;
+ struct dentry *key_tx_rx_threshold;
+ struct dentry *rts_threshold;
+ struct dentry *fragmentation_threshold;
+ struct dentry *short_retry_limit;
+ struct dentry *long_retry_limit;
+ struct dentry *total_ps_buffered;
+ struct dentry *mode;
+ struct dentry *wep_iv;
+ struct dentry *tx_power_reduction;
+ struct dentry *modes;
+ struct dentry *statistics;
+ struct local_debugfsdentries_statsdentries {
+ struct dentry *transmitted_fragment_count;
+ struct dentry *multicast_transmitted_frame_count;
+ struct dentry *failed_count;
+ struct dentry *retry_count;
+ struct dentry *multiple_retry_count;
+ struct dentry *frame_duplicate_count;
+ struct dentry *received_fragment_count;
+ struct dentry *multicast_received_frame_count;
+ struct dentry *transmitted_frame_count;
+ struct dentry *wep_undecryptable_count;
+ struct dentry *num_scans;
+#ifdef CONFIG_MAC80211_DEBUG_COUNTERS
+ struct dentry *tx_handlers_drop;
+ struct dentry *tx_handlers_queued;
+ struct dentry *tx_handlers_drop_unencrypted;
+ struct dentry *tx_handlers_drop_fragment;
+ struct dentry *tx_handlers_drop_wep;
+ struct dentry *tx_handlers_drop_not_assoc;
+ struct dentry *tx_handlers_drop_unauth_port;
+ struct dentry *rx_handlers_drop;
+ struct dentry *rx_handlers_queued;
+ struct dentry *rx_handlers_drop_nullfunc;
+ struct dentry *rx_handlers_drop_defrag;
+ struct dentry *rx_handlers_drop_short;
+ struct dentry *rx_handlers_drop_passive_scan;
+ struct dentry *tx_expand_skb_head;
+ struct dentry *tx_expand_skb_head_cloned;
+ struct dentry *rx_expand_skb_head;
+ struct dentry *rx_expand_skb_head2;
+ struct dentry *rx_handlers_fragments;
+ struct dentry *tx_status_drop;
+#endif
+ struct dentry *dot11ACKFailureCount;
+ struct dentry *dot11RTSFailureCount;
+ struct dentry *dot11FCSErrorCount;
+ struct dentry *dot11RTSSuccessCount;
+ struct dentry *wme_tx_queue;
+ struct dentry *wme_rx_queue;
+ } stats;
+ } debugfs;
+#endif
};
static inline struct ieee80211_local *hw_to_local(
--
^ permalink raw reply [flat|nested] 6+ messages in thread* [PATCH (v3) 2/4] mac80211: move sta dir to debugfs
2007-03-07 16:45 [PATCH (v3) 0/4] move everything in mac80211 from sysfs to debugfs johannes
2007-03-07 16:45 ` [PATCH (v3) 1/4] mac80211: move PHY things " johannes
@ 2007-03-07 16:45 ` johannes
2007-03-07 16:45 ` [PATCH (v3) 3/4] mac80211: move per-netdev and key stuff " johannes
` (2 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: johannes @ 2007-03-07 16:45 UTC (permalink / raw)
To: John W. Linville; +Cc: linux-wireless
This patch moves the "sta" dir to a new debugfs dir "stations".
Signed-off-by: Johannes Berg <johannes@sipsolutions.net>
---
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(-)
--- wireless-dev.orig/net/mac80211/ieee80211_sysfs_sta.c 2007-03-07 13:03:50.464710923 +0100
+++ /dev/null 1970-01-01 00:00:00.000000000 +0000
@@ -1,439 +0,0 @@
-/*
- * Copyright 2003-2005, Devicescape Software, Inc.
- * Copyright (c) 2006 Jiri Benc <jbenc@suse.cz>
- *
- * 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");
-}
--- wireless-dev.orig/net/mac80211/ieee80211_i.h 2007-03-07 13:03:54.944710923 +0100
+++ wireless-dev/net/mac80211/ieee80211_i.h 2007-03-07 13:03:56.054710923 +0100
@@ -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 */
--- wireless-dev.orig/net/mac80211/Makefile 2007-03-07 13:03:54.934710923 +0100
+++ wireless-dev/net/mac80211/Makefile 2007-03-07 13:03:56.054710923 +0100
@@ -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),)
--- wireless-dev.orig/net/mac80211/debugfs.c 2007-03-07 13:03:54.944710923 +0100
+++ wireless-dev/net/mac80211/debugfs.c 2007-03-07 13:03:56.054710923 +0100
@@ -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;
}
--- wireless-dev.orig/net/mac80211/debugfs.h 2007-03-07 13:03:54.934710923 +0100
+++ wireless-dev/net/mac80211/debugfs.h 2007-03-07 13:03:56.054710923 +0100
@@ -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)
{
--- wireless-dev.orig/net/mac80211/sta_info.c 2007-03-07 13:03:50.464710923 +0100
+++ wireless-dev/net/mac80211/sta_info.c 2007-03-07 13:03:56.064710923 +0100
@@ -8,7 +8,6 @@
#include <linux/module.h>
#include <linux/init.h>
-#include <linux/kobject.h>
#include <linux/netdevice.h>
#include <linux/types.h>
#include <linux/slab.h>
@@ -19,7 +18,8 @@
#include "ieee80211_i.h"
#include "ieee80211_rate.h"
#include "sta_info.h"
-
+#include "key_sysfs.h"
+#include "debugfs_sta.h"
/* Caller must hold local->sta_lock */
static void sta_info_hash_add(struct ieee80211_local *local,
@@ -53,12 +53,12 @@ static void sta_info_hash_del(struct iee
"hash table\n", local->mdev->name, MAC_ARG(sta->addr));
}
-static inline struct sta_info *__sta_info_get(struct sta_info *sta)
+static inline void __sta_info_get(struct sta_info *sta)
{
- return kobject_get(&sta->kobj) ? sta : NULL;
+ kref_get(&sta->kref);
}
-struct sta_info * sta_info_get(struct ieee80211_local *local, u8 *addr)
+struct sta_info *sta_info_get(struct ieee80211_local *local, u8 *addr)
{
struct sta_info *sta;
@@ -102,15 +102,9 @@ int sta_info_min_txrate_get(struct ieee8
}
-void sta_info_put(struct sta_info *sta)
+void sta_info_release(struct kref *kref)
{
- kobject_put(&sta->kobj);
-}
-EXPORT_SYMBOL(sta_info_put);
-
-void sta_info_release(struct kobject *kobj)
-{
- struct sta_info *sta = container_of(kobj, struct sta_info, kobj);
+ struct sta_info *sta = container_of(kref, struct sta_info, kref);
struct ieee80211_local *local = sta->local;
struct sk_buff *skb;
@@ -131,6 +125,13 @@ void sta_info_release(struct kobject *ko
}
+void sta_info_put(struct sta_info *sta)
+{
+ kref_put(&sta->kref, sta_info_release);
+}
+EXPORT_SYMBOL(sta_info_put);
+
+
struct sta_info * sta_info_add(struct ieee80211_local *local,
struct net_device *dev, u8 *addr, gfp_t gfp)
{
@@ -140,18 +141,13 @@ struct sta_info * sta_info_add(struct ie
if (!sta)
return NULL;
- if (kobject_set_name(&sta->kobj, MAC_FMT, MAC_ARG(addr))) {
- kfree(sta);
- return NULL;
- }
- sta->kobj.kset = &local->sta_kset;
- kobject_init(&sta->kobj);
+ kref_init(&sta->kref);
sta->rate_ctrl = rate_control_get(local->rate_ctrl);
sta->rate_ctrl_priv = rate_control_alloc_sta(sta->rate_ctrl, gfp);
if (!sta->rate_ctrl_priv) {
rate_control_put(sta->rate_ctrl);
- kobject_put(&sta->kobj);
+ kref_put(&sta->kref, sta_info_release);
kfree(sta);
return NULL;
}
@@ -180,8 +176,8 @@ struct sta_info * sta_info_add(struct ie
if (!in_interrupt()) {
sta->sysfs_registered = 1;
- ieee80211_sta_sysfs_add(sta);
- rate_control_add_sta_attrs(sta, &sta->kobj);
+ ieee80211_sta_debugfs_add(sta);
+ rate_control_add_sta_debugfs(sta);
} else {
/* procfs entry adding might sleep, so schedule process context
* task for adding proc entry for STAs that do not yet have
@@ -206,8 +202,8 @@ static void finish_sta_info_free(struct
sta->key = NULL;
}
- rate_control_remove_sta_attrs(sta, &sta->kobj);
- ieee80211_sta_sysfs_remove(sta);
+ rate_control_remove_sta_debugfs(sta);
+ ieee80211_sta_debugfs_remove(sta);
sta_info_put(sta);
}
@@ -380,8 +376,8 @@ static void sta_info_proc_add_task(struc
break;
sta->sysfs_registered = 1;
- ieee80211_sta_sysfs_add(sta);
- rate_control_add_sta_attrs(sta, &sta->kobj);
+ ieee80211_sta_debugfs_add(sta);
+ rate_control_add_sta_debugfs(sta);
sta_info_put(sta);
}
}
@@ -403,11 +399,6 @@ void sta_info_init(struct ieee80211_loca
int sta_info_start(struct ieee80211_local *local)
{
- int res;
-
- res = ieee80211_sta_kset_sysfs_register(local);
- if (res)
- return res;
add_timer(&local->sta_cleanup);
return 0;
}
@@ -425,10 +416,8 @@ void sta_info_stop(struct ieee80211_loca
* point. */
sta_info_free(sta, 0);
}
- ieee80211_sta_kset_sysfs_unregister(local);
}
-
void sta_info_remove_aid_ptr(struct sta_info *sta)
{
struct ieee80211_sub_if_data *sdata;
--- /dev/null 1970-01-01 00:00:00.000000000 +0000
+++ wireless-dev/net/mac80211/key_sysfs.c 2007-03-07 13:03:56.064710923 +0100
@@ -0,0 +1,217 @@
+/*
+ * Copyright 2003-2005 Devicescape Software, Inc.
+ * Copyright (c) 2006 Jiri Benc <jbenc@suse.cz>
+ * Copyright 2007 Johannes Berg <johannes@sipsolutions.net>
+ *
+ * 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"
+
+/* 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 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);
+}
+
+static struct sysfs_ops key_ktype_ops = {
+ .show = key_sysfs_show,
+};
+
+static struct kobj_type key_ktype = {
+ .release = ieee80211_key_release,
+ .sysfs_ops = &key_ktype_ops,
+ .default_attrs = key_ktype_attrs,
+};
+
+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);
+}
+
+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");
+}
--- wireless-dev.orig/net/mac80211/ieee80211.c 2007-03-07 13:03:54.934710923 +0100
+++ wireless-dev/net/mac80211/ieee80211.c 2007-03-07 13:03:56.064710923 +0100
@@ -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) */
--- wireless-dev.orig/net/mac80211/ieee80211_ioctl.c 2007-03-07 13:03:50.454710923 +0100
+++ wireless-dev/net/mac80211/ieee80211_ioctl.c 2007-03-07 13:03:56.074710923 +0100
@@ -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;
--- wireless-dev.orig/net/mac80211/ieee80211_sysfs.c 2007-03-07 13:03:54.944710923 +0100
+++ wireless-dev/net/mac80211/ieee80211_sysfs.c 2007-03-07 13:03:56.074710923 +0100
@@ -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)
{
--- /dev/null 1970-01-01 00:00:00.000000000 +0000
+++ wireless-dev/net/mac80211/key_sysfs.h 2007-03-07 13:03:56.074710923 +0100
@@ -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 */
--- wireless-dev.orig/net/mac80211/sta_info.h 2007-03-07 13:02:30.814710923 +0100
+++ wireless-dev/net/mac80211/sta_info.h 2007-03-07 13:03:56.074710923 +0100
@@ -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);
--- /dev/null 1970-01-01 00:00:00.000000000 +0000
+++ wireless-dev/net/mac80211/debugfs_sta.c 2007-03-07 13:03:56.074710923 +0100
@@ -0,0 +1,242 @@
+/*
+ * Copyright 2003-2005 Devicescape Software, Inc.
+ * Copyright (c) 2006 Jiri Benc <jbenc@suse.cz>
+ * Copyright 2007 Johannes Berg <johannes@sipsolutions.net>
+ *
+ * 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/debugfs.h>
+#include <linux/ieee80211.h>
+#include "ieee80211_i.h"
+#include "debugfs.h"
+#include "debugfs_sta.h"
+#include "sta_info.h"
+
+/* sta attributtes */
+
+#define STA_READ(name, buflen, field, format_string) \
+static ssize_t sta_ ##name## _read(struct file *file, \
+ char __user *userbuf, \
+ size_t count, loff_t *ppos) \
+{ \
+ int res; \
+ struct sta_info *sta = file->private_data; \
+ char buf[buflen]; \
+ res = scnprintf(buf, buflen, format_string, sta->field); \
+ return simple_read_from_buffer(userbuf, count, ppos, buf, res); \
+}
+#define STA_READ_D(name, field) STA_READ(name, 20, field, "%d\n")
+#define STA_READ_U(name, field) STA_READ(name, 20, field, "%u\n")
+#define STA_READ_LU(name, field) STA_READ(name, 20, field, "%lu\n")
+#define STA_READ_S(name, field) STA_READ(name, 20, field, "%s\n")
+
+#define STA_READ_RATE(name, field) \
+static ssize_t sta_##name##_read(struct file *file, \
+ char __user *userbuf, \
+ size_t count, loff_t *ppos) \
+{ \
+ struct sta_info *sta = file->private_data; \
+ struct ieee80211_local *local = wdev_priv(sta->dev->ieee80211_ptr);\
+ struct ieee80211_hw_mode *mode = local->oper_hw_mode; \
+ char buf[20]; \
+ int res = scnprintf(buf, sizeof(buf), "%d\n", \
+ (sta->field >= 0 && \
+ sta->field < mode->num_rates) ? \
+ mode->rates[sta->field].rate : -1); \
+ return simple_read_from_buffer(userbuf, count, ppos, buf, res); \
+}
+
+#define STA_OPS(name) \
+static const struct file_operations sta_ ##name## _ops = { \
+ .read = sta_##name##_read, \
+ .open = mac80211_open_file_generic, \
+}
+
+#define STA_FILE(name, field, format) \
+ STA_READ_##format(name, field) \
+ STA_OPS(name)
+
+STA_FILE(aid, aid, D);
+STA_FILE(key_idx_compression, key_idx_compression, D);
+STA_FILE(dev, dev->name, S);
+STA_FILE(vlan_id, vlan_id, D);
+STA_FILE(rx_packets, rx_packets, LU);
+STA_FILE(tx_packets, tx_packets, LU);
+STA_FILE(rx_bytes, rx_bytes, LU);
+STA_FILE(tx_bytes, tx_bytes, LU);
+STA_FILE(rx_duplicates, num_duplicates, LU);
+STA_FILE(rx_fragments, rx_fragments, LU);
+STA_FILE(rx_dropped, rx_dropped, LU);
+STA_FILE(tx_fragments, tx_fragments, LU);
+STA_FILE(tx_filtered, tx_filtered_count, LU);
+STA_FILE(txrate, txrate, RATE);
+STA_FILE(last_txrate, last_txrate, RATE);
+STA_FILE(tx_retry_failed, tx_retry_failed, LU);
+STA_FILE(tx_retry_count, tx_retry_count, LU);
+STA_FILE(last_rssi, last_rssi, D);
+STA_FILE(last_signal, last_signal, D);
+STA_FILE(last_noise, last_noise, D);
+STA_FILE(channel_use, channel_use, D);
+STA_FILE(wep_weak_iv_count, wep_weak_iv_count, D);
+
+static ssize_t sta_flags_read(struct file *file, char __user *userbuf,
+ size_t count, loff_t *ppos)
+{
+ char buf[100];
+ struct sta_info *sta = file->private_data;
+ int res = scnprintf(buf, sizeof(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" : "");
+ return simple_read_from_buffer(userbuf, count, ppos, buf, res);
+}
+STA_OPS(flags);
+
+static ssize_t sta_num_ps_buf_frames_read(struct file *file,
+ char __user *userbuf,
+ size_t count, loff_t *ppos)
+{
+ char buf[20];
+ struct sta_info *sta = file->private_data;
+ int res = scnprintf(buf, sizeof(buf), "%u\n",
+ skb_queue_len(&sta->ps_tx_buf));
+ return simple_read_from_buffer(userbuf, count, ppos, buf, res);
+}
+STA_OPS(num_ps_buf_frames);
+
+static ssize_t sta_last_ack_rssi_read(struct file *file, char __user *userbuf,
+ size_t count, loff_t *ppos)
+{
+ char buf[100];
+ struct sta_info *sta = file->private_data;
+ int res = scnprintf(buf, sizeof(buf), "%d %d %d\n",
+ sta->last_ack_rssi[0],
+ sta->last_ack_rssi[1],
+ sta->last_ack_rssi[2]);
+ return simple_read_from_buffer(userbuf, count, ppos, buf, res);
+}
+STA_OPS(last_ack_rssi);
+
+static ssize_t sta_last_ack_ms_read(struct file *file, char __user *userbuf,
+ size_t count, loff_t *ppos)
+{
+ char buf[20];
+ struct sta_info *sta = file->private_data;
+ int res = scnprintf(buf, sizeof(buf), "%d\n",
+ sta->last_ack ?
+ jiffies_to_msecs(jiffies - sta->last_ack) : -1);
+ return simple_read_from_buffer(userbuf, count, ppos, buf, res);
+}
+STA_OPS(last_ack_ms);
+
+static ssize_t sta_inactive_ms_read(struct file *file, char __user *userbuf,
+ size_t count, loff_t *ppos)
+{
+ char buf[20];
+ struct sta_info *sta = file->private_data;
+ int res = scnprintf(buf, sizeof(buf), "%d\n",
+ jiffies_to_msecs(jiffies - sta->last_rx));
+ return simple_read_from_buffer(userbuf, count, ppos, buf, res);
+}
+STA_OPS(inactive_ms);
+
+static ssize_t sta_last_seq_ctrl_read(struct file *file, char __user *userbuf,
+ size_t count, loff_t *ppos)
+{
+ char buf[15*NUM_RX_DATA_QUEUES], *p = buf;
+ int i;
+ struct sta_info *sta = file->private_data;
+ for (i = 0; i < NUM_RX_DATA_QUEUES; i++)
+ p += scnprintf(p, sizeof(buf)+buf-p, "%x ",
+ sta->last_seq_ctrl[i]);
+ p += scnprintf(p, sizeof(buf)+buf-p, "\n");
+ return simple_read_from_buffer(userbuf, count, ppos, buf, p - buf);
+}
+STA_OPS(last_seq_ctrl);
+
+#ifdef CONFIG_MAC80211_DEBUG_COUNTERS
+static ssize_t sta_wme_rx_queue_read(struct file *file, char __user *userbuf,
+ size_t count, loff_t *ppos)
+{
+ char buf[15*NUM_RX_DATA_QUEUES], *p = buf;
+ int i;
+ struct sta_info *sta = file->private_data;
+ for (i = 0; i < NUM_RX_DATA_QUEUES; i++)
+ p += scnprintf(p, sizeof(buf)+buf-p, "%u ",
+ sta->wme_rx_queue[i]);
+ p += scnprintf(p, sizeof(buf)+buf-p, "\n");
+ return simple_read_from_buffer(userbuf, count, ppos, buf, p - buf);
+}
+STA_OPS(wme_rx_queue);
+
+static ssize_t sta_wme_tx_queue_read(struct file *file, char __user *userbuf,
+ size_t count, loff_t *ppos)
+{
+ char buf[15*NUM_TX_DATA_QUEUES], *p = buf;
+ int i;
+ struct sta_info *sta = file->private_data;
+ for (i = 0; i < NUM_TX_DATA_QUEUES; i++)
+ p += scnprintf(p, sizeof(buf)+buf-p, "%u ",
+ sta->wme_tx_queue[i]);
+ p += scnprintf(p, sizeof(buf)+buf-p, "\n");
+ return simple_read_from_buffer(userbuf, count, ppos, buf, p - buf);
+}
+STA_OPS(wme_tx_queue);
+#endif
+
+#define DEBUGFS_ADD(name) \
+ sta->debugfs.name = debugfs_create_file(#name, 0444, \
+ sta->debugfs.dir, sta, &sta_ ##name## _ops);
+
+#define DEBUGFS_DEL(name) \
+ debugfs_remove(sta->debugfs.name);\
+ sta->debugfs.name = NULL;
+
+
+void ieee80211_sta_debugfs_add(struct sta_info *sta)
+{
+ char buf[3*6];
+ struct dentry *stations_dir = sta->local->debugfs.stations;
+
+ if (!stations_dir)
+ return;
+
+ sprintf(buf, MAC_FMT, MAC_ARG(sta->addr));
+
+ sta->debugfs.dir = debugfs_create_dir(buf, stations_dir);
+ if (!sta->debugfs.dir)
+ return;
+
+ DEBUGFS_ADD(flags);
+ DEBUGFS_ADD(num_ps_buf_frames);
+ DEBUGFS_ADD(last_ack_rssi);
+ DEBUGFS_ADD(last_ack_ms);
+ DEBUGFS_ADD(inactive_ms);
+ DEBUGFS_ADD(last_seq_ctrl);
+ DEBUGFS_ADD(wme_rx_queue);
+ DEBUGFS_ADD(wme_tx_queue);
+}
+
+void ieee80211_sta_debugfs_remove(struct sta_info *sta)
+{
+ DEBUGFS_DEL(flags);
+ DEBUGFS_DEL(num_ps_buf_frames);
+ DEBUGFS_DEL(last_ack_rssi);
+ DEBUGFS_DEL(last_ack_ms);
+ DEBUGFS_DEL(inactive_ms);
+ DEBUGFS_DEL(last_seq_ctrl);
+ DEBUGFS_DEL(wme_rx_queue);
+ DEBUGFS_DEL(wme_tx_queue);
+
+ debugfs_remove(sta->debugfs.dir);
+ sta->debugfs.dir = NULL;
+}
--- /dev/null 1970-01-01 00:00:00.000000000 +0000
+++ wireless-dev/net/mac80211/debugfs_sta.h 2007-03-07 13:03:56.074710923 +0100
@@ -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 */
--- wireless-dev.orig/net/mac80211/ieee80211_rate.h 2007-03-07 13:03:54.934710923 +0100
+++ wireless-dev/net/mac80211/ieee80211_rate.h 2007-03-07 13:03:56.084710923 +0100
@@ -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 */
--- wireless-dev.orig/net/mac80211/rc80211_simple.c 2007-03-07 13:03:50.464710923 +0100
+++ wireless-dev/net/mac80211/rc80211_simple.c 2007-03-07 13:03:56.084710923 +0100
@@ -18,6 +18,7 @@
#include <net/mac80211.h>
#include "ieee80211_i.h"
#include "ieee80211_rate.h"
+#include "debugfs.h"
/* This is a minimal implementation of TX rate controlling that can be used
@@ -121,6 +122,11 @@ struct sta_rate_control {
unsigned long avg_rate_update;
u32 tx_avg_rate_sum;
u32 tx_avg_rate_num;
+
+#ifdef CONFIG_DEBUG_FS
+ struct dentry *tx_avg_rate_sum_dentry;
+ struct dentry *tx_avg_rate_num_dentry;
+#endif
};
@@ -327,47 +333,67 @@ static void rate_control_simple_free_sta
kfree(rctrl);
}
-static ssize_t show_sta_tx_avg_rate_sum(const struct sta_info *sta, char *buf)
-{
- struct sta_rate_control *srctrl = sta->rate_ctrl_priv;
+#ifdef CONFIG_DEBUG_FS
- return sprintf(buf, "%d\n", srctrl->tx_avg_rate_sum);
+static int open_file_generic(struct inode *inode, struct file *file)
+{
+ file->private_data = inode->i_private;
+ return 0;
}
-static ssize_t show_sta_tx_avg_rate_num(const struct sta_info *sta, char *buf)
+static ssize_t sta_tx_avg_rate_sum_read(struct file *file,
+ char __user *userbuf,
+ size_t count, loff_t *ppos)
{
- struct sta_rate_control *srctrl = sta->rate_ctrl_priv;
+ struct sta_rate_control *srctrl = file->private_data;
+ char buf[20];
- return sprintf(buf, "%d\n", srctrl->tx_avg_rate_num);
+ sprintf(buf, "%d\n", srctrl->tx_avg_rate_sum);
+ return simple_read_from_buffer(userbuf, count, ppos, buf, strlen(buf));
}
-static struct sta_attribute sta_attr_tx_avg_rate_sum =
- __ATTR(tx_avg_rate_sum, S_IRUSR, show_sta_tx_avg_rate_sum, NULL);
-static struct sta_attribute sta_attr_tx_avg_rate_num =
- __ATTR(tx_avg_rate_num, S_IRUSR, show_sta_tx_avg_rate_num, NULL);
-
-static struct attribute *rate_control_simple_sta_attrs[] = {
- &sta_attr_tx_avg_rate_sum.attr,
- &sta_attr_tx_avg_rate_num.attr,
- NULL,
+static const struct file_operations sta_tx_avg_rate_sum_ops = {
+ .read = sta_tx_avg_rate_sum_read,
+ .open = open_file_generic,
};
-static struct attribute_group rate_control_simple_sta_group = {
- .name = "rate_control_simple",
- .attrs = rate_control_simple_sta_attrs,
+static ssize_t sta_tx_avg_rate_num_read(struct file *file,
+ char __user *userbuf,
+ size_t count, loff_t *ppos)
+{
+ struct sta_rate_control *srctrl = file->private_data;
+ char buf[20];
+
+ sprintf(buf, "%d\n", srctrl->tx_avg_rate_num);
+ return simple_read_from_buffer(userbuf, count, ppos, buf, strlen(buf));
+}
+
+static const struct file_operations sta_tx_avg_rate_num_ops = {
+ .read = sta_tx_avg_rate_num_read,
+ .open = open_file_generic,
};
-static int rate_control_simple_add_sta_attrs(void *priv, void *priv_sta,
- struct kobject *kobj)
+static void rate_control_simple_add_sta_debugfs(void *priv, void *priv_sta,
+ struct dentry *dir)
{
- return sysfs_create_group(kobj, &rate_control_simple_sta_group);
+ struct sta_rate_control *srctrl = priv_sta;
+
+ srctrl->tx_avg_rate_num_dentry =
+ debugfs_create_file("rc_simple_sta_tx_avg_rate_num", 0400,
+ dir, srctrl, &sta_tx_avg_rate_num_ops);
+ srctrl->tx_avg_rate_sum_dentry =
+ debugfs_create_file("rc_simple_sta_tx_avg_rate_sum", 0400,
+ dir, srctrl, &sta_tx_avg_rate_sum_ops);
}
-static void rate_control_simple_remove_sta_attrs(void *priv, void *priv_sta,
- struct kobject *kobj)
+static void rate_control_simple_remove_sta_debugfs(void *priv, void *priv_sta)
{
- sysfs_remove_group(kobj, &rate_control_simple_sta_group);
+ struct sta_rate_control *srctrl = priv_sta;
+
+ debugfs_remove(srctrl->tx_avg_rate_sum_dentry);
+ debugfs_remove(srctrl->tx_avg_rate_num_dentry);
}
+#endif
static struct rate_control_ops rate_control_simple = {
.module = THIS_MODULE,
@@ -380,8 +406,10 @@ 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,
- .add_sta_attrs = rate_control_simple_add_sta_attrs,
- .remove_sta_attrs = rate_control_simple_remove_sta_attrs,
+#ifdef CONFIG_DEBUG_FS
+ .add_sta_debugfs = rate_control_simple_add_sta_debugfs,
+ .remove_sta_debugfs = rate_control_simple_remove_sta_debugfs,
+#endif
};
--
^ permalink raw reply [flat|nested] 6+ messages in thread* [PATCH (v3) 3/4] mac80211: move per-netdev and key stuff to debugfs
2007-03-07 16:45 [PATCH (v3) 0/4] move everything in mac80211 from sysfs to debugfs johannes
2007-03-07 16:45 ` [PATCH (v3) 1/4] mac80211: move PHY things " johannes
2007-03-07 16:45 ` [PATCH (v3) 2/4] mac80211: move sta dir " johannes
@ 2007-03-07 16:45 ` johannes
2007-03-07 16:45 ` [PATCH (v3) 4/4] mac80211 debugfs Kconfig johannes
2007-03-23 18:04 ` [PATCH (v3) 0/4] move everything in mac80211 from sysfs to debugfs Jiri Benc
4 siblings, 0 replies; 6+ messages in thread
From: johannes @ 2007-03-07 16:45 UTC (permalink / raw)
To: John W. Linville; +Cc: linux-wireless
This patch moves the remaining sysfs stuff from mac80211 into debugfs.
Signed-off-by: Johannes Berg <johannes@sipsolutions.net>
---
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(-)
--- wireless-dev.orig/net/mac80211/Makefile 2007-03-07 13:03:56.054710923 +0100
+++ wireless-dev/net/mac80211/Makefile 2007-03-07 13:03:58.974710923 +0100
@@ -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),)
--- /dev/null 1970-01-01 00:00:00.000000000 +0000
+++ wireless-dev/net/mac80211/debugfs_netdev.c 2007-03-07 13:03:58.974710923 +0100
@@ -0,0 +1,440 @@
+/*
+ * Copyright (c) 2006 Jiri Benc <jbenc@suse.cz>
+ * Copyright 2007 Johannes Berg <johannes@sipsolutions.net>
+ *
+ * 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/kernel.h>
+#include <linux/device.h>
+#include <linux/if.h>
+#include <linux/interrupt.h>
+#include <linux/netdevice.h>
+#include <linux/rtnetlink.h>
+#include <linux/notifier.h>
+#include <net/mac80211.h>
+#include <net/cfg80211.h>
+#include "ieee80211_i.h"
+#include "ieee80211_rate.h"
+#include "debugfs.h"
+#include "debugfs_netdev.h"
+
+static ssize_t ieee80211_if_read(
+ struct ieee80211_sub_if_data *sdata,
+ char __user *userbuf,
+ size_t count, loff_t *ppos,
+ ssize_t (*format)(const struct ieee80211_sub_if_data *, char *, int))
+{
+ char buf[70];
+ ssize_t ret = -EINVAL;
+
+ read_lock(&dev_base_lock);
+ if (sdata->dev->reg_state == NETREG_REGISTERED) {
+ ret = (*format)(sdata, buf, sizeof(buf));
+ ret = simple_read_from_buffer(userbuf, count, ppos, buf, ret);
+ }
+ read_unlock(&dev_base_lock);
+ return ret;
+}
+
+#define IEEE80211_IF_FMT(name, field, format_string) \
+static ssize_t ieee80211_if_fmt_##name( \
+ const struct ieee80211_sub_if_data *sdata, char *buf, \
+ int buflen) \
+{ \
+ return scnprintf(buf, buflen, format_string, sdata->field); \
+}
+#define IEEE80211_IF_FMT_DEC(name, field) \
+ IEEE80211_IF_FMT(name, field, "%d\n")
+#define IEEE80211_IF_FMT_HEX(name, field) \
+ IEEE80211_IF_FMT(name, field, "%#x\n")
+#define IEEE80211_IF_FMT_SIZE(name, field) \
+ IEEE80211_IF_FMT(name, field, "%zd\n")
+
+#define IEEE80211_IF_FMT_ATOMIC(name, field) \
+static ssize_t ieee80211_if_fmt_##name( \
+ const struct ieee80211_sub_if_data *sdata, \
+ char *buf, int buflen) \
+{ \
+ return scnprintf(buf, buflen, "%d\n", atomic_read(&sdata->field));\
+}
+
+#define IEEE80211_IF_FMT_MAC(name, field) \
+static ssize_t ieee80211_if_fmt_##name( \
+ const struct ieee80211_sub_if_data *sdata, char *buf, \
+ int buflen) \
+{ \
+ return scnprintf(buf, buflen, MAC_FMT "\n", MAC_ARG(sdata->field));\
+}
+
+#define __IEEE80211_IF_FILE(name) \
+static ssize_t ieee80211_if_read_##name(struct file *file, \
+ char __user *userbuf, \
+ size_t count, loff_t *ppos) \
+{ \
+ return ieee80211_if_read(file->private_data, \
+ userbuf, count, ppos, \
+ ieee80211_if_fmt_##name); \
+} \
+static const struct file_operations name##_ops = { \
+ .read = ieee80211_if_read_##name, \
+ .open = mac80211_open_file_generic, \
+}
+
+#define IEEE80211_IF_FILE(name, field, format) \
+ IEEE80211_IF_FMT_##format(name, field) \
+ __IEEE80211_IF_FILE(name)
+
+/* common attributes */
+IEEE80211_IF_FILE(channel_use, channel_use, DEC);
+IEEE80211_IF_FILE(drop_unencrypted, drop_unencrypted, DEC);
+IEEE80211_IF_FILE(eapol, eapol, DEC);
+IEEE80211_IF_FILE(ieee8021_x, ieee802_1x, DEC);
+
+/* STA/IBSS attributes */
+IEEE80211_IF_FILE(state, u.sta.state, DEC);
+IEEE80211_IF_FILE(bssid, u.sta.bssid, MAC);
+IEEE80211_IF_FILE(prev_bssid, u.sta.prev_bssid, MAC);
+IEEE80211_IF_FILE(ssid_len, u.sta.ssid_len, SIZE);
+IEEE80211_IF_FILE(aid, u.sta.aid, DEC);
+IEEE80211_IF_FILE(ap_capab, u.sta.ap_capab, HEX);
+IEEE80211_IF_FILE(capab, u.sta.capab, HEX);
+IEEE80211_IF_FILE(extra_ie_len, u.sta.extra_ie_len, SIZE);
+IEEE80211_IF_FILE(auth_tries, u.sta.auth_tries, DEC);
+IEEE80211_IF_FILE(assoc_tries, u.sta.assoc_tries, DEC);
+IEEE80211_IF_FILE(auth_algs, u.sta.auth_algs, HEX);
+IEEE80211_IF_FILE(auth_alg, u.sta.auth_alg, DEC);
+IEEE80211_IF_FILE(auth_transaction, u.sta.auth_transaction, DEC);
+
+static ssize_t ieee80211_if_fmt_flags(
+ const struct ieee80211_sub_if_data *sdata, char *buf, int buflen)
+{
+ return scnprintf(buf, buflen, "%s%s%s%s%s%s%s\n",
+ sdata->u.sta.ssid_set ? "SSID\n" : "",
+ sdata->u.sta.bssid_set ? "BSSID\n" : "",
+ sdata->u.sta.prev_bssid_set ? "prev BSSID\n" : "",
+ sdata->u.sta.authenticated ? "AUTH\n" : "",
+ sdata->u.sta.associated ? "ASSOC\n" : "",
+ sdata->u.sta.probereq_poll ? "PROBEREQ POLL\n" : "",
+ sdata->u.sta.use_protection ? "CTS prot\n" : "");
+}
+__IEEE80211_IF_FILE(flags);
+
+/* AP attributes */
+IEEE80211_IF_FILE(num_sta_ps, u.ap.num_sta_ps, ATOMIC);
+IEEE80211_IF_FILE(dtim_period, u.ap.dtim_period, DEC);
+IEEE80211_IF_FILE(dtim_count, u.ap.dtim_count, DEC);
+IEEE80211_IF_FILE(num_beacons, u.ap.num_beacons, DEC);
+IEEE80211_IF_FILE(force_unicast_rateidx, u.ap.force_unicast_rateidx, DEC);
+IEEE80211_IF_FILE(max_ratectrl_rateidx, u.ap.max_ratectrl_rateidx, DEC);
+
+static ssize_t ieee80211_if_fmt_num_buffered_multicast(
+ const struct ieee80211_sub_if_data *sdata, char *buf, int buflen)
+{
+ return scnprintf(buf, buflen, "%u\n",
+ skb_queue_len(&sdata->u.ap.ps_bc_buf));
+}
+__IEEE80211_IF_FILE(num_buffered_multicast);
+
+static ssize_t ieee80211_if_fmt_beacon_head_len(
+ const struct ieee80211_sub_if_data *sdata, char *buf, int buflen)
+{
+ if (sdata->u.ap.beacon_head)
+ return scnprintf(buf, buflen, "%d\n",
+ sdata->u.ap.beacon_head_len);
+ return scnprintf(buf, buflen, "\n");
+}
+__IEEE80211_IF_FILE(beacon_head_len);
+
+static ssize_t ieee80211_if_fmt_beacon_tail_len(
+ const struct ieee80211_sub_if_data *sdata, char *buf, int buflen)
+{
+ if (sdata->u.ap.beacon_tail)
+ return scnprintf(buf, buflen, "%d\n",
+ sdata->u.ap.beacon_tail_len);
+ return scnprintf(buf, buflen, "\n");
+}
+__IEEE80211_IF_FILE(beacon_tail_len);
+
+/* WDS attributes */
+IEEE80211_IF_FILE(peer, u.wds.remote_addr, MAC);
+
+/* VLAN attributes */
+IEEE80211_IF_FILE(vlan_id, u.vlan.id, DEC);
+
+/* MONITOR attributes */
+static ssize_t ieee80211_if_fmt_mode(
+ const struct ieee80211_sub_if_data *sdata, char *buf, int buflen)
+{
+ struct ieee80211_local *local = sdata->local;
+
+ return scnprintf(buf, buflen, "%s\n",
+ ((local->hw.flags & IEEE80211_HW_MONITOR_DURING_OPER) ||
+ local->open_count == local->monitors) ?
+ "hard" : "soft");
+}
+__IEEE80211_IF_FILE(mode);
+
+
+#define DEBUGFS_ADD(name, type)\
+ sdata->debugfs.type.name = debugfs_create_file(#name, 0444,\
+ sdata->debugfsdir, sdata, &name##_ops);
+
+static void add_sta_files(struct ieee80211_sub_if_data *sdata)
+{
+ DEBUGFS_ADD(channel_use, sta);
+ DEBUGFS_ADD(drop_unencrypted, sta);
+ DEBUGFS_ADD(eapol, sta);
+ DEBUGFS_ADD(ieee8021_x, sta);
+ DEBUGFS_ADD(state, sta);
+ DEBUGFS_ADD(bssid, sta);
+ DEBUGFS_ADD(prev_bssid, sta);
+ DEBUGFS_ADD(ssid_len, sta);
+ DEBUGFS_ADD(aid, sta);
+ DEBUGFS_ADD(ap_capab, sta);
+ DEBUGFS_ADD(capab, sta);
+ DEBUGFS_ADD(extra_ie_len, sta);
+ DEBUGFS_ADD(auth_tries, sta);
+ DEBUGFS_ADD(assoc_tries, sta);
+ DEBUGFS_ADD(auth_algs, sta);
+ DEBUGFS_ADD(auth_alg, sta);
+ DEBUGFS_ADD(auth_transaction, sta);
+ DEBUGFS_ADD(flags, sta);
+}
+
+static void add_ap_files(struct ieee80211_sub_if_data *sdata)
+{
+ DEBUGFS_ADD(channel_use, ap);
+ DEBUGFS_ADD(drop_unencrypted, ap);
+ DEBUGFS_ADD(eapol, ap);
+ DEBUGFS_ADD(ieee8021_x, ap);
+ DEBUGFS_ADD(num_sta_ps, ap);
+ DEBUGFS_ADD(dtim_period, ap);
+ DEBUGFS_ADD(dtim_count, ap);
+ DEBUGFS_ADD(num_beacons, ap);
+ DEBUGFS_ADD(force_unicast_rateidx, ap);
+ DEBUGFS_ADD(max_ratectrl_rateidx, ap);
+ DEBUGFS_ADD(num_buffered_multicast, ap);
+ DEBUGFS_ADD(beacon_head_len, ap);
+ DEBUGFS_ADD(beacon_tail_len, ap);
+}
+
+static void add_wds_files(struct ieee80211_sub_if_data *sdata)
+{
+ DEBUGFS_ADD(channel_use, wds);
+ DEBUGFS_ADD(drop_unencrypted, wds);
+ DEBUGFS_ADD(eapol, wds);
+ DEBUGFS_ADD(ieee8021_x, wds);
+ DEBUGFS_ADD(peer, wds);
+}
+
+static void add_vlan_files(struct ieee80211_sub_if_data *sdata)
+{
+ DEBUGFS_ADD(channel_use, vlan);
+ DEBUGFS_ADD(drop_unencrypted, vlan);
+ DEBUGFS_ADD(eapol, vlan);
+ DEBUGFS_ADD(ieee8021_x, vlan);
+ DEBUGFS_ADD(vlan_id, vlan);
+}
+
+static void add_monitor_files(struct ieee80211_sub_if_data *sdata)
+{
+ DEBUGFS_ADD(mode, monitor);
+}
+
+void add_files(struct ieee80211_sub_if_data *sdata)
+{
+ if (!sdata->debugfsdir)
+ return;
+
+ switch (sdata->type) {
+ case IEEE80211_IF_TYPE_STA:
+ case IEEE80211_IF_TYPE_IBSS:
+ add_sta_files(sdata);
+ break;
+ case IEEE80211_IF_TYPE_AP:
+ add_ap_files(sdata);
+ break;
+ case IEEE80211_IF_TYPE_WDS:
+ add_wds_files(sdata);
+ break;
+ case IEEE80211_IF_TYPE_MNTR:
+ add_monitor_files(sdata);
+ break;
+ case IEEE80211_IF_TYPE_VLAN:
+ add_vlan_files(sdata);
+ break;
+ default:
+ break;
+ }
+}
+
+#define DEBUGFS_DEL(name, type)\
+ debugfs_remove(sdata->debugfs.type.name);\
+ sdata->debugfs.type.name = NULL;
+
+static void del_sta_files(struct ieee80211_sub_if_data *sdata)
+{
+ DEBUGFS_DEL(channel_use, sta);
+ DEBUGFS_DEL(drop_unencrypted, sta);
+ DEBUGFS_DEL(eapol, sta);
+ DEBUGFS_DEL(ieee8021_x, sta);
+ DEBUGFS_DEL(state, sta);
+ DEBUGFS_DEL(bssid, sta);
+ DEBUGFS_DEL(prev_bssid, sta);
+ DEBUGFS_DEL(ssid_len, sta);
+ DEBUGFS_DEL(aid, sta);
+ DEBUGFS_DEL(ap_capab, sta);
+ DEBUGFS_DEL(capab, sta);
+ DEBUGFS_DEL(extra_ie_len, sta);
+ DEBUGFS_DEL(auth_tries, sta);
+ DEBUGFS_DEL(assoc_tries, sta);
+ DEBUGFS_DEL(auth_algs, sta);
+ DEBUGFS_DEL(auth_alg, sta);
+ DEBUGFS_DEL(auth_transaction, sta);
+ DEBUGFS_DEL(flags, sta);
+}
+
+static void del_ap_files(struct ieee80211_sub_if_data *sdata)
+{
+ DEBUGFS_DEL(channel_use, ap);
+ DEBUGFS_DEL(drop_unencrypted, ap);
+ DEBUGFS_DEL(eapol, ap);
+ DEBUGFS_DEL(ieee8021_x, ap);
+ DEBUGFS_DEL(num_sta_ps, ap);
+ DEBUGFS_DEL(dtim_period, ap);
+ DEBUGFS_DEL(dtim_count, ap);
+ DEBUGFS_DEL(num_beacons, ap);
+ DEBUGFS_DEL(force_unicast_rateidx, ap);
+ DEBUGFS_DEL(max_ratectrl_rateidx, ap);
+ DEBUGFS_DEL(num_buffered_multicast, ap);
+ DEBUGFS_DEL(beacon_head_len, ap);
+ DEBUGFS_DEL(beacon_tail_len, ap);
+}
+
+static void del_wds_files(struct ieee80211_sub_if_data *sdata)
+{
+ DEBUGFS_DEL(channel_use, wds);
+ DEBUGFS_DEL(drop_unencrypted, wds);
+ DEBUGFS_DEL(eapol, wds);
+ DEBUGFS_DEL(ieee8021_x, wds);
+ DEBUGFS_DEL(peer, wds);
+}
+
+static void del_vlan_files(struct ieee80211_sub_if_data *sdata)
+{
+ DEBUGFS_DEL(channel_use, vlan);
+ DEBUGFS_DEL(drop_unencrypted, vlan);
+ DEBUGFS_DEL(eapol, vlan);
+ DEBUGFS_DEL(ieee8021_x, vlan);
+ DEBUGFS_DEL(vlan_id, vlan);
+}
+
+static void del_monitor_files(struct ieee80211_sub_if_data *sdata)
+{
+ DEBUGFS_DEL(mode, monitor);
+}
+
+void del_files(struct ieee80211_sub_if_data *sdata, int type)
+{
+ if (!sdata->debugfsdir)
+ return;
+
+ switch (type) {
+ case IEEE80211_IF_TYPE_STA:
+ case IEEE80211_IF_TYPE_IBSS:
+ del_sta_files(sdata);
+ break;
+ case IEEE80211_IF_TYPE_AP:
+ del_ap_files(sdata);
+ break;
+ case IEEE80211_IF_TYPE_WDS:
+ del_wds_files(sdata);
+ break;
+ case IEEE80211_IF_TYPE_MNTR:
+ del_monitor_files(sdata);
+ break;
+ case IEEE80211_IF_TYPE_VLAN:
+ del_vlan_files(sdata);
+ break;
+ default:
+ break;
+ }
+}
+
+static int notif_registered;
+
+void ieee80211_debugfs_add_netdev(struct ieee80211_sub_if_data *sdata)
+{
+ char buf[10+IFNAMSIZ];
+
+ if (!notif_registered)
+ return;
+
+ sprintf(buf, "netdev:%s", sdata->dev->name);
+ sdata->debugfsdir = debugfs_create_dir(buf,
+ sdata->local->hw.wiphy->debugfsdir);
+}
+
+void ieee80211_debugfs_remove_netdev(struct ieee80211_sub_if_data *sdata)
+{
+ del_files(sdata, sdata->type);
+ debugfs_remove(sdata->debugfsdir);
+ sdata->debugfsdir = NULL;
+}
+
+void ieee80211_debugfs_change_if_type(struct ieee80211_sub_if_data *sdata,
+ int oldtype)
+{
+ del_files(sdata, oldtype);
+ add_files(sdata);
+}
+
+static int netdev_notify(struct notifier_block * nb,
+ unsigned long state,
+ void *ndev)
+{
+ struct net_device *dev = ndev;
+ char buf[10+IFNAMSIZ];
+
+ if (state != NETDEV_CHANGENAME)
+ return 0;
+
+ if (!dev->ieee80211_ptr || !dev->ieee80211_ptr->wiphy)
+ return 0;
+
+ if (dev->ieee80211_ptr->wiphy->privid != mac80211_wiphy_privid)
+ return 0;
+
+ /* TODO
+ sprintf(buf, "netdev:%s", dev->name);
+ debugfs_rename(IEEE80211_DEV_TO_SUB_IF(dev)->debugfsdir, buf);
+ */
+
+ return 0;
+}
+
+static struct notifier_block mac80211_debugfs_netdev_notifier = {
+ .notifier_call = netdev_notify,
+};
+
+void ieee80211_debugfs_netdev_init(void)
+{
+ int err;
+
+ err = register_netdevice_notifier(&mac80211_debugfs_netdev_notifier);
+ if (err) {
+ printk(KERN_ERR
+ "mac80211: failed to install netdev notifier,"
+ " disabling per-netdev debugfs!\n");
+ } else
+ notif_registered = 1;
+}
+
+void ieee80211_debugfs_netdev_exit(void)
+{
+ unregister_netdevice_notifier(&mac80211_debugfs_netdev_notifier);
+ notif_registered = 0;
+}
--- /dev/null 1970-01-01 00:00:00.000000000 +0000
+++ wireless-dev/net/mac80211/debugfs_netdev.h 2007-03-07 13:03:58.974710923 +0100
@@ -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 */
--- wireless-dev.orig/net/mac80211/ieee80211.c 2007-03-07 13:03:56.064710923 +0100
+++ wireless-dev/net/mac80211/ieee80211.c 2007-03-07 13:03:58.984710923 +0100
@@ -33,9 +33,12 @@
#include "aes_ccm.h"
#include "ieee80211_led.h"
#include "ieee80211_cfg.h"
-#include "ieee80211_sysfs.h"
#include "debugfs.h"
-#include "key_sysfs.h"
+#include "debugfs_netdev.h"
+#include "debugfs_key.h"
+
+/* privid for wiphys to determine whether they belong to us or not */
+void *mac80211_wiphy_privid = &mac80211_wiphy_privid;
/* See IEEE 802.1H for LLC/SNAP encapsulation/decapsulation */
/* Ethernet-II snap header (RFC1042 for most EtherTypes) */
@@ -86,40 +89,31 @@ struct ieee80211_key *ieee80211_key_allo
int idx, size_t key_len, gfp_t flags)
{
struct ieee80211_key *key;
- int res;
key = kzalloc(sizeof(struct ieee80211_key) + key_len, flags);
if (!key)
return NULL;
- if (sdata)
- res = kobject_set_name(&key->kobj, "%d", idx);
- else
- res = kobject_set_name(&key->kobj, "key");
- if (res) {
- kfree(key);
- return NULL;
- }
- ieee80211_key_sysfs_set_kset(key, sdata ? &sdata->key_kset : NULL);
- kobject_init(&key->kobj);
+ kref_init(&key->kref);
return key;
}
-void ieee80211_key_free(struct ieee80211_key *key)
-{
- if (key)
- kobject_put(&key->kobj);
-}
-
-void ieee80211_key_release(struct kobject *kobj)
+void ieee80211_key_release(struct kref *kref)
{
struct ieee80211_key *key;
- key = container_of(kobj, struct ieee80211_key, kobj);
+ key = container_of(kref, struct ieee80211_key, kref);
if (key->alg == ALG_CCMP)
ieee80211_aes_key_free(key->u.ccmp.tfm);
+ ieee80211_debugfs_key_remove(key);
kfree(key);
}
+void ieee80211_key_free(struct ieee80211_key *key)
+{
+ if (key)
+ kref_put(&key->kref, ieee80211_key_release);
+}
+
static int rate_list_match(const int *rate_list, int rate)
{
int i;
@@ -4516,6 +4510,8 @@ struct ieee80211_hw *ieee80211_alloc_hw(
if (!wiphy)
return NULL;
+ wiphy->privid = mac80211_wiphy_privid;
+
local = wiphy_priv(wiphy);
local->hw.wiphy = wiphy;
@@ -4646,11 +4642,8 @@ int ieee80211_register_hw(struct ieee802
rtnl_unlock();
goto fail_dev;
}
- result = ieee80211_sysfs_add_netdevice(local->mdev);
- if (result < 0) {
- rtnl_unlock();
- goto fail_if_sysfs;
- }
+
+ ieee80211_debugfs_add_netdev(IEEE80211_DEV_TO_SUB_IF(local->mdev));
result = ieee80211_init_rate_ctrl_alg(local, NULL);
rtnl_unlock();
@@ -4687,8 +4680,7 @@ int ieee80211_register_hw(struct ieee802
fail_wep:
rate_control_deinitialize(local);
fail_rate:
- ieee80211_sysfs_remove_netdevice(local->mdev);
-fail_if_sysfs:
+ ieee80211_debugfs_remove_netdev(IEEE80211_DEV_TO_SUB_IF(local->mdev));
unregister_netdev(local->mdev);
fail_dev:
sta_info_stop(local);
@@ -4899,6 +4891,8 @@ static int __init ieee80211_init(void)
return ret;
}
+ ieee80211_debugfs_netdev_init();
+
return 0;
}
@@ -4906,6 +4900,7 @@ static int __init ieee80211_init(void)
static void __exit ieee80211_exit(void)
{
ieee80211_wme_unregister();
+ ieee80211_debugfs_netdev_exit();
}
--- wireless-dev.orig/net/mac80211/ieee80211_i.h 2007-03-07 13:03:56.054710923 +0100
+++ wireless-dev/net/mac80211/ieee80211_i.h 2007-03-07 13:03:58.984710923 +0100
@@ -325,7 +325,6 @@ struct ieee80211_sub_if_data {
#define NUM_DEFAULT_KEYS 4
struct ieee80211_key *keys[NUM_DEFAULT_KEYS];
struct ieee80211_key *default_key;
- struct kset key_kset;
struct ieee80211_if_ap *bss; /* BSS that this device belongs to */
@@ -338,7 +337,64 @@ struct ieee80211_sub_if_data {
int channel_use;
int channel_use_raw;
- struct attribute_group *sysfs_group;
+#ifdef CONFIG_DEBUG_FS
+ struct dentry *debugfsdir;
+ union {
+ struct {
+ struct dentry *channel_use;
+ struct dentry *drop_unencrypted;
+ struct dentry *eapol;
+ struct dentry *ieee8021_x;
+ struct dentry *state;
+ struct dentry *bssid;
+ struct dentry *prev_bssid;
+ struct dentry *ssid_len;
+ struct dentry *aid;
+ struct dentry *ap_capab;
+ struct dentry *capab;
+ struct dentry *extra_ie_len;
+ struct dentry *auth_tries;
+ struct dentry *assoc_tries;
+ struct dentry *auth_algs;
+ struct dentry *auth_alg;
+ struct dentry *auth_transaction;
+ struct dentry *flags;
+ } sta;
+ struct {
+ struct dentry *channel_use;
+ struct dentry *drop_unencrypted;
+ struct dentry *eapol;
+ struct dentry *ieee8021_x;
+ struct dentry *num_sta_ps;
+ struct dentry *dtim_period;
+ struct dentry *dtim_count;
+ struct dentry *num_beacons;
+ struct dentry *force_unicast_rateidx;
+ struct dentry *max_ratectrl_rateidx;
+ struct dentry *num_buffered_multicast;
+ struct dentry *beacon_head_len;
+ struct dentry *beacon_tail_len;
+ } ap;
+ struct {
+ struct dentry *channel_use;
+ struct dentry *drop_unencrypted;
+ struct dentry *eapol;
+ struct dentry *ieee8021_x;
+ struct dentry *peer;
+ } wds;
+ struct {
+ struct dentry *channel_use;
+ struct dentry *drop_unencrypted;
+ struct dentry *eapol;
+ struct dentry *ieee8021_x;
+ struct dentry *vlan_id;
+ } vlan;
+ struct {
+ struct dentry *mode;
+ } monitor;
+ struct dentry *default_key;
+ } debugfs;
+#endif
};
#define IEEE80211_DEV_TO_SUB_IF(dev) netdev_priv(dev)
@@ -599,6 +655,7 @@ struct ieee80211_local {
struct dentry *wme_rx_queue;
} stats;
struct dentry *stations;
+ struct dentry *keys;
} debugfs;
#endif
};
@@ -670,7 +727,6 @@ ieee80211_key_data2conf(struct ieee80211
struct ieee80211_key *ieee80211_key_alloc(struct ieee80211_sub_if_data *sdata,
int idx, size_t key_len, gfp_t flags);
void ieee80211_key_free(struct ieee80211_key *key);
-void ieee80211_key_release(struct kobject *kobj);
void ieee80211_rx_mgmt(struct ieee80211_local *local, struct sk_buff *skb,
struct ieee80211_rx_status *status, u32 msg_type);
void ieee80211_prepare_rates(struct ieee80211_local *local);
@@ -763,4 +819,7 @@ 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);
+/* for wiphy privid */
+extern void *mac80211_wiphy_privid;
+
#endif /* IEEE80211_I_H */
--- wireless-dev.orig/net/mac80211/ieee80211_iface.c 2007-03-07 13:02:29.234710923 +0100
+++ wireless-dev/net/mac80211/ieee80211_iface.c 2007-03-07 13:03:58.984710923 +0100
@@ -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). */
--- wireless-dev.orig/net/mac80211/ieee80211_key.h 2007-03-07 13:02:29.324710923 +0100
+++ wireless-dev/net/mac80211/ieee80211_key.h 2007-03-07 13:03:58.984710923 +0100
@@ -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];
};
--- wireless-dev.orig/net/mac80211/ieee80211_sysfs.c 2007-03-07 13:03:56.074710923 +0100
+++ /dev/null 1970-01-01 00:00:00.000000000 +0000
@@ -1,344 +0,0 @@
-/*
- * Copyright (c) 2006 Jiri Benc <jbenc@suse.cz>
- *
- * 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/kernel.h>
-#include <linux/device.h>
-#include <linux/if.h>
-#include <linux/interrupt.h>
-#include <linux/netdevice.h>
-#include <linux/rtnetlink.h>
-#include <net/mac80211.h>
-#include <net/cfg80211.h>
-#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)
-{
- struct wiphy *wiphy = container_of(dev, struct wiphy, dev);
- return wiphy_priv(wiphy);
-}
-
-static inline int rtnl_lock_local(struct ieee80211_local *local)
-{
- rtnl_lock();
- if (unlikely(local->reg_state != IEEE80211_DEV_REGISTERED)) {
- rtnl_unlock();
- return -ENODEV;
- }
- return 0;
-}
-
-/* attributes in /sys/class/net/X/ */
-
-static ssize_t ieee80211_if_show(struct device *d,
- struct device_attribute *attr, char *buf,
- ssize_t (*format)(const struct ieee80211_sub_if_data *,
- char *))
-{
- struct net_device *dev = to_net_dev(d);
- struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
- ssize_t ret = -EINVAL;
-
- read_lock(&dev_base_lock);
- if (dev->reg_state == NETREG_REGISTERED) {
- ret = (*format)(sdata, buf);
- }
- read_unlock(&dev_base_lock);
- return ret;
-}
-
-#define IEEE80211_IF_FMT(name, field, format_string) \
-static ssize_t ieee80211_if_fmt_##name(const struct \
- ieee80211_sub_if_data *sdata, char *buf) \
-{ \
- return sprintf(buf, format_string, sdata->field); \
-}
-#define IEEE80211_IF_FMT_DEC(name, field) \
- IEEE80211_IF_FMT(name, field, "%d\n")
-#define IEEE80211_IF_FMT_HEX(name, field) \
- IEEE80211_IF_FMT(name, field, "%#x\n")
-#define IEEE80211_IF_FMT_SIZE(name, field) \
- IEEE80211_IF_FMT(name, field, "%zd\n")
-
-#define IEEE80211_IF_FMT_ATOMIC(name, field) \
-static ssize_t ieee80211_if_fmt_##name(const struct \
- ieee80211_sub_if_data *sdata, char *buf) \
-{ \
- return sprintf(buf, "%d\n", atomic_read(&sdata->field)); \
-}
-
-#define IEEE80211_IF_FMT_MAC(name, field) \
-static ssize_t ieee80211_if_fmt_##name(const struct \
- ieee80211_sub_if_data *sdata, char *buf) \
-{ \
- return sprintf(buf, MAC_FMT "\n", MAC_ARG(sdata->field)); \
-}
-
-#define __IEEE80211_IF_SHOW(name) \
-static ssize_t ieee80211_if_show_##name(struct device *d, \
- struct device_attribute *attr, \
- char *buf) \
-{ \
- return ieee80211_if_show(d, attr, buf, ieee80211_if_fmt_##name);\
-} \
-static DEVICE_ATTR(name, S_IRUGO, ieee80211_if_show_##name, NULL);
-
-#define IEEE80211_IF_SHOW(name, field, format) \
- IEEE80211_IF_FMT_##format(name, field) \
- __IEEE80211_IF_SHOW(name)
-
-/* common attributes */
-IEEE80211_IF_SHOW(channel_use, channel_use, DEC);
-IEEE80211_IF_SHOW(drop_unencrypted, drop_unencrypted, DEC);
-IEEE80211_IF_SHOW(eapol, eapol, DEC);
-IEEE80211_IF_SHOW(ieee8021_x, ieee802_1x, DEC);
-
-/* STA/IBSS attributes */
-IEEE80211_IF_SHOW(state, u.sta.state, DEC);
-IEEE80211_IF_SHOW(bssid, u.sta.bssid, MAC);
-IEEE80211_IF_SHOW(prev_bssid, u.sta.prev_bssid, MAC);
-IEEE80211_IF_SHOW(ssid_len, u.sta.ssid_len, SIZE);
-IEEE80211_IF_SHOW(aid, u.sta.aid, DEC);
-IEEE80211_IF_SHOW(ap_capab, u.sta.ap_capab, HEX);
-IEEE80211_IF_SHOW(capab, u.sta.capab, HEX);
-IEEE80211_IF_SHOW(extra_ie_len, u.sta.extra_ie_len, SIZE);
-IEEE80211_IF_SHOW(auth_tries, u.sta.auth_tries, DEC);
-IEEE80211_IF_SHOW(assoc_tries, u.sta.assoc_tries, DEC);
-IEEE80211_IF_SHOW(auth_algs, u.sta.auth_algs, HEX);
-IEEE80211_IF_SHOW(auth_alg, u.sta.auth_alg, DEC);
-IEEE80211_IF_SHOW(auth_transaction, u.sta.auth_transaction, DEC);
-
-static ssize_t ieee80211_if_fmt_flags(const struct
- ieee80211_sub_if_data *sdata, char *buf)
-{
- return sprintf(buf, "%s%s%s%s%s%s%s\n",
- sdata->u.sta.ssid_set ? "SSID\n" : "",
- sdata->u.sta.bssid_set ? "BSSID\n" : "",
- sdata->u.sta.prev_bssid_set ? "prev BSSID\n" : "",
- sdata->u.sta.authenticated ? "AUTH\n" : "",
- sdata->u.sta.associated ? "ASSOC\n" : "",
- sdata->u.sta.probereq_poll ? "PROBEREQ POLL\n" : "",
- sdata->u.sta.use_protection ? "CTS prot\n" : "");
-}
-__IEEE80211_IF_SHOW(flags);
-
-/* AP attributes */
-IEEE80211_IF_SHOW(num_sta_ps, u.ap.num_sta_ps, ATOMIC);
-IEEE80211_IF_SHOW(dtim_period, u.ap.dtim_period, DEC);
-IEEE80211_IF_SHOW(dtim_count, u.ap.dtim_count, DEC);
-IEEE80211_IF_SHOW(num_beacons, u.ap.num_beacons, DEC);
-IEEE80211_IF_SHOW(force_unicast_rateidx, u.ap.force_unicast_rateidx, DEC);
-IEEE80211_IF_SHOW(max_ratectrl_rateidx, u.ap.max_ratectrl_rateidx, DEC);
-
-static ssize_t ieee80211_if_fmt_num_buffered_multicast(const struct
- ieee80211_sub_if_data *sdata, char *buf)
-{
- return sprintf(buf, "%u\n", skb_queue_len(&sdata->u.ap.ps_bc_buf));
-}
-__IEEE80211_IF_SHOW(num_buffered_multicast);
-
-static ssize_t ieee80211_if_fmt_beacon_head_len(const struct
- ieee80211_sub_if_data *sdata, char *buf)
-{
- if (sdata->u.ap.beacon_head)
- return sprintf(buf, "%d\n", sdata->u.ap.beacon_head_len);
- return sprintf(buf, "\n");
-}
-__IEEE80211_IF_SHOW(beacon_head_len);
-
-static ssize_t ieee80211_if_fmt_beacon_tail_len(const struct
- ieee80211_sub_if_data *sdata, char *buf)
-{
- if (sdata->u.ap.beacon_tail)
- return sprintf(buf, "%d\n", sdata->u.ap.beacon_tail_len);
- return sprintf(buf, "\n");
-}
-__IEEE80211_IF_SHOW(beacon_tail_len);
-
-/* WDS attributes */
-IEEE80211_IF_SHOW(peer, u.wds.remote_addr, MAC);
-
-/* VLAN attributes */
-IEEE80211_IF_SHOW(vlan_id, u.vlan.id, DEC);
-
-/* MONITOR attributes */
-static ssize_t ieee80211_if_fmt_mode(const struct
- ieee80211_sub_if_data *sdata, char *buf)
-{
- struct ieee80211_local *local = sdata->local;
-
- return sprintf(buf, "%s\n",
- ((local->hw.flags & IEEE80211_HW_MONITOR_DURING_OPER) ||
- local->open_count == local->monitors) ?
- "hard" : "soft");
-}
-__IEEE80211_IF_SHOW(mode);
-
-static struct attribute *ieee80211_sta_attrs[] = {
- &dev_attr_channel_use.attr,
- &dev_attr_drop_unencrypted.attr,
- &dev_attr_eapol.attr,
- &dev_attr_ieee8021_x.attr,
- &dev_attr_state.attr,
- &dev_attr_bssid.attr,
- &dev_attr_prev_bssid.attr,
- &dev_attr_ssid_len.attr,
- &dev_attr_aid.attr,
- &dev_attr_ap_capab.attr,
- &dev_attr_capab.attr,
- &dev_attr_extra_ie_len.attr,
- &dev_attr_auth_tries.attr,
- &dev_attr_assoc_tries.attr,
- &dev_attr_auth_algs.attr,
- &dev_attr_auth_alg.attr,
- &dev_attr_auth_transaction.attr,
- &dev_attr_flags.attr,
- NULL
-};
-
-static struct attribute *ieee80211_ap_attrs[] = {
- &dev_attr_channel_use.attr,
- &dev_attr_drop_unencrypted.attr,
- &dev_attr_eapol.attr,
- &dev_attr_ieee8021_x.attr,
- &dev_attr_num_sta_ps.attr,
- &dev_attr_dtim_period.attr,
- &dev_attr_dtim_count.attr,
- &dev_attr_num_beacons.attr,
- &dev_attr_force_unicast_rateidx.attr,
- &dev_attr_max_ratectrl_rateidx.attr,
- &dev_attr_num_buffered_multicast.attr,
- &dev_attr_beacon_head_len.attr,
- &dev_attr_beacon_tail_len.attr,
- NULL
-};
-
-static struct attribute *ieee80211_wds_attrs[] = {
- &dev_attr_channel_use.attr,
- &dev_attr_drop_unencrypted.attr,
- &dev_attr_eapol.attr,
- &dev_attr_ieee8021_x.attr,
- &dev_attr_peer.attr,
- NULL
-};
-
-static struct attribute *ieee80211_vlan_attrs[] = {
- &dev_attr_channel_use.attr,
- &dev_attr_drop_unencrypted.attr,
- &dev_attr_eapol.attr,
- &dev_attr_ieee8021_x.attr,
- &dev_attr_vlan_id.attr,
- NULL
-};
-
-static struct attribute *ieee80211_monitor_attrs[] = {
- &dev_attr_mode.attr,
- NULL
-};
-
-static struct attribute_group ieee80211_sta_group = {
- .name = "sta",
- .attrs = ieee80211_sta_attrs,
-};
-
-static struct attribute_group ieee80211_ap_group = {
- .name = "ap",
- .attrs = ieee80211_ap_attrs,
-};
-
-static struct attribute_group ieee80211_wds_group = {
- .name = "wds",
- .attrs = ieee80211_wds_attrs,
-};
-
-static struct attribute_group ieee80211_vlan_group = {
- .name = "vlan",
- .attrs = ieee80211_vlan_attrs,
-};
-
-static struct attribute_group ieee80211_monitor_group = {
- .name = "monitor",
- .attrs = ieee80211_monitor_attrs,
-};
-
-/* /sys/class/net/X functions */
-
-static void __ieee80211_remove_if_group(struct kobject *kobj,
- struct ieee80211_sub_if_data *sdata)
-{
- if (sdata->sysfs_group) {
- sysfs_remove_group(kobj, sdata->sysfs_group);
- sdata->sysfs_group = NULL;
- }
-}
-
-static inline void ieee80211_remove_if_group(struct kobject *kobj,
- struct net_device *dev)
-{
- __ieee80211_remove_if_group(kobj, IEEE80211_DEV_TO_SUB_IF(dev));
-}
-
-static int ieee80211_add_if_group(struct kobject *kobj,
- struct net_device *dev)
-{
- struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
- int res = 0;
-
- __ieee80211_remove_if_group(kobj, sdata);
- switch (sdata->type) {
- case IEEE80211_IF_TYPE_STA:
- sdata->sysfs_group = &ieee80211_sta_group;
- break;
- case IEEE80211_IF_TYPE_AP:
- sdata->sysfs_group = &ieee80211_ap_group;
- break;
- case IEEE80211_IF_TYPE_WDS:
- sdata->sysfs_group = &ieee80211_wds_group;
- break;
- case IEEE80211_IF_TYPE_VLAN:
- sdata->sysfs_group = &ieee80211_vlan_group;
- break;
- case IEEE80211_IF_TYPE_MNTR:
- sdata->sysfs_group = &ieee80211_monitor_group;
- break;
- default:
- goto out;
- }
- res = sysfs_create_group(kobj, sdata->sysfs_group);
- if (res)
- sdata->sysfs_group = NULL;
-out:
- return res;
-}
-
-int ieee80211_sysfs_change_if_type(struct net_device *dev)
-{
- return ieee80211_add_if_group(&dev->dev.kobj, dev);
-}
-
-int ieee80211_sysfs_add_netdevice(struct net_device *dev)
-{
- int res;
-
- res = ieee80211_add_if_group(&dev->dev.kobj, dev);
- if (res)
- goto err_fail_if_group;
- res = ieee80211_key_kset_sysfs_register(IEEE80211_DEV_TO_SUB_IF(dev));
- return res;
-
-err_fail_if_group:
- return res;
-}
-
-void ieee80211_sysfs_remove_netdevice(struct net_device *dev)
-{
- ieee80211_key_kset_sysfs_unregister(IEEE80211_DEV_TO_SUB_IF(dev));
- ieee80211_remove_if_group(&dev->dev.kobj, dev);
-}
--- wireless-dev.orig/net/mac80211/ieee80211_sysfs.h 2007-03-07 13:03:54.944710923 +0100
+++ /dev/null 1970-01-01 00:00:00.000000000 +0000
@@ -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 */
--- /dev/null 1970-01-01 00:00:00.000000000 +0000
+++ wireless-dev/net/mac80211/debugfs_key.c 2007-03-07 13:03:58.994710923 +0100
@@ -0,0 +1,253 @@
+/*
+ * Copyright 2003-2005 Devicescape Software, Inc.
+ * Copyright (c) 2006 Jiri Benc <jbenc@suse.cz>
+ * Copyright 2007 Johannes Berg <johannes@sipsolutions.net>
+ *
+ * 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 "debugfs.h"
+#include "debugfs_key.h"
+
+#define KEY_READ(name, buflen, format_string) \
+static ssize_t key_##name##_read(struct file *file, \
+ char __user *userbuf, \
+ size_t count, loff_t *ppos) \
+{ \
+ char buf[buflen]; \
+ struct ieee80211_key *key = file->private_data; \
+ int res = scnprintf(buf, buflen, format_string, key->name); \
+ return simple_read_from_buffer(userbuf, count, ppos, buf, res); \
+}
+#define KEY_READ_D(name) KEY_READ(name, 20, "%d\n")
+
+#define KEY_OPS(name) \
+static const struct file_operations key_ ##name## _ops = { \
+ .read = key_##name##_read, \
+ .open = mac80211_open_file_generic, \
+}
+
+#define KEY_FILE(name, format) \
+ KEY_READ_##format(name) \
+ KEY_OPS(name)
+
+KEY_FILE(keylen, D);
+KEY_FILE(force_sw_encrypt, D);
+KEY_FILE(keyidx, D);
+KEY_FILE(hw_key_idx, D);
+KEY_FILE(tx_rx_count, D);
+
+static ssize_t key_algorithm_read(struct file *file,
+ char __user *userbuf,
+ size_t count, loff_t *ppos)
+{
+ char *alg;
+ struct ieee80211_key *key = file->private_data;
+
+ switch (key->alg) {
+ case ALG_WEP:
+ alg = "WEP\n";
+ break;
+ case ALG_TKIP:
+ alg = "TKIP\n";
+ break;
+ case ALG_CCMP:
+ alg = "CCMP\n";
+ break;
+ default:
+ return 0;
+ }
+ return simple_read_from_buffer(userbuf, count, ppos, alg, strlen(alg));
+}
+KEY_OPS(algorithm);
+
+static ssize_t key_tx_spec_read(struct file *file, char __user *userbuf,
+ size_t count, loff_t *ppos)
+{
+ const u8 *tpn;
+ char buf[20];
+ int len;
+ struct ieee80211_key *key = file->private_data;
+
+ switch (key->alg) {
+ case ALG_WEP:
+ len = scnprintf(buf, sizeof(buf), "\n");
+ case ALG_TKIP:
+ len = scnprintf(buf, sizeof(buf), "%08x %04x\n",
+ key->u.tkip.iv32,
+ key->u.tkip.iv16);
+ case ALG_CCMP:
+ tpn = key->u.ccmp.tx_pn;
+ len = scnprintf(buf, sizeof(buf), "%02x%02x%02x%02x%02x%02x\n",
+ tpn[0], tpn[1], tpn[2], tpn[3], tpn[4], tpn[5]);
+ default:
+ return 0;
+ }
+ return simple_read_from_buffer(userbuf, count, ppos, buf, len);
+}
+KEY_OPS(tx_spec);
+
+static ssize_t key_rx_spec_read(struct file *file, char __user *userbuf,
+ size_t count, loff_t *ppos)
+{
+ struct ieee80211_key *key = file->private_data;
+ char buf[14*NUM_RX_DATA_QUEUES+1], *p = buf;
+ int i, len;
+ const u8 *rpn;
+
+ switch (key->alg) {
+ case ALG_WEP:
+ len = scnprintf(buf, sizeof(buf), "\n");
+ case ALG_TKIP:
+ for (i = 0; i < NUM_RX_DATA_QUEUES; i++)
+ p += scnprintf(p, sizeof(buf)+buf-p,
+ "%08x %04x\n",
+ key->u.tkip.iv32_rx[i],
+ key->u.tkip.iv16_rx[i]);
+ len = p - buf;
+ case ALG_CCMP:
+ for (i = 0; i < NUM_RX_DATA_QUEUES; i++) {
+ rpn = key->u.ccmp.rx_pn[i];
+ p += scnprintf(p, sizeof(buf)+buf-p,
+ "%02x%02x%02x%02x%02x%02x\n",
+ rpn[0], rpn[1], rpn[2],
+ rpn[3], rpn[4], rpn[5]);
+ }
+ len = p - buf;
+ default:
+ return 0;
+ }
+ return simple_read_from_buffer(userbuf, count, ppos, buf, len);
+}
+KEY_OPS(rx_spec);
+
+static ssize_t key_replays_read(struct file *file, char __user *userbuf,
+ size_t count, loff_t *ppos)
+{
+ struct ieee80211_key *key = file->private_data;
+ char buf[20];
+ int len;
+
+ if (key->alg != ALG_CCMP)
+ return 0;
+ len = scnprintf(buf, sizeof(buf), "%u\n", key->u.ccmp.replays);
+ return simple_read_from_buffer(userbuf, count, ppos, buf, len);
+}
+KEY_OPS(replays);
+
+static ssize_t key_key_read(struct file *file, char __user *userbuf,
+ size_t count, loff_t *ppos)
+{
+ struct ieee80211_key *key = file->private_data;
+ int i, res, bufsize = 2*key->keylen+2;
+ char *buf = kmalloc(bufsize, GFP_KERNEL);
+ char *p = buf;
+
+ for (i = 0; i < key->keylen; i++)
+ p += scnprintf(p, bufsize+buf-p, "%02x", key->key[i]);
+ p += scnprintf(p, bufsize+buf-p, "\n");
+ res = simple_read_from_buffer(userbuf, count, ppos, buf, p - buf);
+ kfree(buf);
+ return res;
+}
+KEY_OPS(key);
+
+#define DEBUGFS_ADD(name) \
+ key->debugfs.name = debugfs_create_file(#name, 0400,\
+ key->debugfs.dir, key, &key_##name##_ops);
+
+void ieee80211_debugfs_key_add(struct ieee80211_local *local,
+ struct ieee80211_key *key)
+{
+ char buf[20];
+
+ if (!local->debugfs.keys)
+ return;
+
+ sprintf(buf, "%d", key->keyidx);
+ key->debugfs.dir = debugfs_create_dir(buf,
+ local->debugfs.keys);
+
+ if (!key->debugfs.dir)
+ return;
+
+ DEBUGFS_ADD(keylen);
+ DEBUGFS_ADD(force_sw_encrypt);
+ DEBUGFS_ADD(keyidx);
+ DEBUGFS_ADD(hw_key_idx);
+ DEBUGFS_ADD(tx_rx_count);
+ DEBUGFS_ADD(algorithm);
+ DEBUGFS_ADD(tx_spec);
+ DEBUGFS_ADD(rx_spec);
+ DEBUGFS_ADD(replays);
+ DEBUGFS_ADD(key);
+};
+
+#define DEBUGFS_DEL(name) \
+ debugfs_remove(key->debugfs.name); key->debugfs.name = NULL;
+
+void ieee80211_debugfs_key_remove(struct ieee80211_key *key)
+{
+ if (!key)
+ return;
+
+ DEBUGFS_DEL(keylen);
+ DEBUGFS_DEL(force_sw_encrypt);
+ DEBUGFS_DEL(keyidx);
+ DEBUGFS_DEL(hw_key_idx);
+ DEBUGFS_DEL(tx_rx_count);
+ DEBUGFS_DEL(algorithm);
+ DEBUGFS_DEL(tx_spec);
+ DEBUGFS_DEL(rx_spec);
+ DEBUGFS_DEL(replays);
+ DEBUGFS_DEL(key);
+
+ debugfs_remove(key->debugfs.stalink);
+ key->debugfs.stalink = NULL;
+ debugfs_remove(key->debugfs.dir);
+ key->debugfs.dir = NULL;
+}
+void ieee80211_debugfs_key_add_default(struct ieee80211_sub_if_data *sdata)
+{
+ char buf[50];
+
+ if (!sdata->debugfsdir)
+ return;
+
+ sprintf(buf, "../keys/%d", sdata->default_key->keyidx);
+ sdata->debugfs.default_key =
+ debugfs_create_symlink("default_key", sdata->debugfsdir, buf);
+}
+void ieee80211_debugfs_key_remove_default(struct ieee80211_sub_if_data *sdata)
+{
+ if (!sdata)
+ return;
+
+ debugfs_remove(sdata->debugfs.default_key);
+ sdata->debugfs.default_key = NULL;
+}
+void ieee80211_debugfs_key_sta_link(struct ieee80211_key *key,
+ struct sta_info *sta)
+{
+ char buf[50];
+
+ if (!key->debugfs.dir)
+ return;
+
+ sprintf(buf, "../sta/" MAC_FMT, MAC_ARG(sta->addr));
+ key->debugfs.stalink =
+ debugfs_create_symlink("station", key->debugfs.dir, buf);
+}
+
+void ieee80211_debugfs_key_sta_del(struct ieee80211_key *key,
+ struct sta_info *sta)
+{
+ debugfs_remove(key->debugfs.stalink);
+ key->debugfs.stalink = NULL;
+}
--- /dev/null 1970-01-01 00:00:00.000000000 +0000
+++ wireless-dev/net/mac80211/debugfs_key.h 2007-03-07 13:03:58.994710923 +0100
@@ -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 */
--- wireless-dev.orig/net/mac80211/ieee80211_ioctl.c 2007-03-07 13:03:56.074710923 +0100
+++ wireless-dev/net/mac80211/ieee80211_ioctl.c 2007-03-07 13:03:58.994710923 +0100
@@ -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;
}
--- wireless-dev.orig/net/mac80211/key_sysfs.c 2007-03-07 13:03:56.064710923 +0100
+++ /dev/null 1970-01-01 00:00:00.000000000 +0000
@@ -1,217 +0,0 @@
-/*
- * Copyright 2003-2005 Devicescape Software, Inc.
- * Copyright (c) 2006 Jiri Benc <jbenc@suse.cz>
- * Copyright 2007 Johannes Berg <johannes@sipsolutions.net>
- *
- * 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"
-
-/* 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 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);
-}
-
-static struct sysfs_ops key_ktype_ops = {
- .show = key_sysfs_show,
-};
-
-static struct kobj_type key_ktype = {
- .release = ieee80211_key_release,
- .sysfs_ops = &key_ktype_ops,
- .default_attrs = key_ktype_attrs,
-};
-
-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);
-}
-
-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");
-}
--- wireless-dev.orig/net/mac80211/key_sysfs.h 2007-03-07 13:03:56.074710923 +0100
+++ /dev/null 1970-01-01 00:00:00.000000000 +0000
@@ -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 */
--- wireless-dev.orig/net/mac80211/sta_info.c 2007-03-07 13:03:56.064710923 +0100
+++ wireless-dev/net/mac80211/sta_info.c 2007-03-07 13:03:59.004710923 +0100
@@ -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;
}
--- wireless-dev.orig/net/mac80211/debugfs.c 2007-03-07 13:03:56.054710923 +0100
+++ wireless-dev/net/mac80211/debugfs.c 2007-03-07 13:03:59.004710923 +0100
@@ -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;
}
--
^ permalink raw reply [flat|nested] 6+ messages in thread* [PATCH (v3) 4/4] mac80211 debugfs Kconfig
2007-03-07 16:45 [PATCH (v3) 0/4] move everything in mac80211 from sysfs to debugfs johannes
` (2 preceding siblings ...)
2007-03-07 16:45 ` [PATCH (v3) 3/4] mac80211: move per-netdev and key stuff " johannes
@ 2007-03-07 16:45 ` johannes
2007-03-23 18:04 ` [PATCH (v3) 0/4] move everything in mac80211 from sysfs to debugfs Jiri Benc
4 siblings, 0 replies; 6+ messages in thread
From: johannes @ 2007-03-07 16:45 UTC (permalink / raw)
To: John W. Linville; +Cc: linux-wireless
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.
Signed-off-by: Johannes Berg <johannes@sipsolutions.net>
---
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(-)
--- wireless-dev.orig/net/mac80211/Kconfig 2007-03-07 13:03:43.954710923 +0100
+++ wireless-dev/net/mac80211/Kconfig 2007-03-07 13:04:00.514710923 +0100
@@ -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
--- wireless-dev.orig/net/mac80211/Makefile 2007-03-07 13:03:58.974710923 +0100
+++ wireless-dev/net/mac80211/Makefile 2007-03-07 13:04:00.514710923 +0100
@@ -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 \
--- wireless-dev.orig/net/mac80211/debugfs.h 2007-03-07 13:03:56.054710923 +0100
+++ wireless-dev/net/mac80211/debugfs.h 2007-03-07 13:04:00.514710923 +0100
@@ -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);
--- wireless-dev.orig/net/mac80211/debugfs_key.h 2007-03-07 13:03:58.994710923 +0100
+++ wireless-dev/net/mac80211/debugfs_key.h 2007-03-07 13:04:00.514710923 +0100
@@ -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);
--- wireless-dev.orig/net/mac80211/debugfs_netdev.h 2007-03-07 13:03:58.974710923 +0100
+++ wireless-dev/net/mac80211/debugfs_netdev.h 2007-03-07 13:04:00.514710923 +0100
@@ -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,
--- wireless-dev.orig/net/mac80211/debugfs_sta.h 2007-03-07 13:03:56.074710923 +0100
+++ wireless-dev/net/mac80211/debugfs_sta.h 2007-03-07 13:04:00.514710923 +0100
@@ -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
--- wireless-dev.orig/net/mac80211/ieee80211_i.h 2007-03-07 13:03:58.984710923 +0100
+++ wireless-dev/net/mac80211/ieee80211_i.h 2007-03-07 13:04:00.514710923 +0100
@@ -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;
--- wireless-dev.orig/net/mac80211/ieee80211_key.h 2007-03-07 13:03:58.984710923 +0100
+++ wireless-dev/net/mac80211/ieee80211_key.h 2007-03-07 13:04:00.514710923 +0100
@@ -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;
--- wireless-dev.orig/net/mac80211/rc80211_simple.c 2007-03-07 13:03:56.084710923 +0100
+++ wireless-dev/net/mac80211/rc80211_simple.c 2007-03-07 13:04:00.514710923 +0100
@@ -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
--- wireless-dev.orig/net/mac80211/sta_info.h 2007-03-07 13:03:56.074710923 +0100
+++ wireless-dev/net/mac80211/sta_info.h 2007-03-07 13:04:00.524710923 +0100
@@ -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;
--- wireless-dev.orig/net/mac80211/ieee80211_rate.h 2007-03-07 13:03:56.084710923 +0100
+++ wireless-dev/net/mac80211/ieee80211_rate.h 2007-03-07 13:04:00.524710923 +0100
@@ -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);
--
^ permalink raw reply [flat|nested] 6+ messages in thread* Re: [PATCH (v3) 0/4] move everything in mac80211 from sysfs to debugfs
2007-03-07 16:45 [PATCH (v3) 0/4] move everything in mac80211 from sysfs to debugfs johannes
` (3 preceding siblings ...)
2007-03-07 16:45 ` [PATCH (v3) 4/4] mac80211 debugfs Kconfig johannes
@ 2007-03-23 18:04 ` Jiri Benc
4 siblings, 0 replies; 6+ messages in thread
From: Jiri Benc @ 2007-03-23 18:04 UTC (permalink / raw)
To: johannes; +Cc: John W. Linville, linux-wireless
On Wed, 07 Mar 2007 17:45:31 +0100, johannes@sipsolutions.net 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
--
Jiri Benc
SUSE Labs
^ permalink raw reply [flat|nested] 6+ messages in thread