From: Jiri Benc <jbenc@suse.cz>
To: netdev@vger.kernel.org
Cc: "John W. Linville" <linville@tuxdriver.com>
Subject: [PATCH 10/12] d80211: rate_control sysfs attributes
Date: Thu, 8 Jun 2006 09:49:14 +0200 (CEST) [thread overview]
Message-ID: <20060608074914.7D3B64838E@silver.suse.cz> (raw)
In-Reply-To: <20060608094822.014829000.midnight@suse.cz>
Add support for sysfs attributes for rate_control modules.
Signed-off-by: Jiri Benc <jbenc@suse.cz>
---
net/d80211/ieee80211.c | 13 ++++++++++++-
net/d80211/rate_control.c | 42 ++++++++++++++++++++++++++++++++++++++++++
net/d80211/rate_control.h | 36 ++++++++++++++++++++++++++++++++++++
net/d80211/sta_info.c | 4 ++++
4 files changed, 94 insertions(+), 1 deletions(-)
9acfab1d1a4e4a82dace4055a089d605d5efa97f
diff --git a/net/d80211/ieee80211.c b/net/d80211/ieee80211.c
index 75aaa99..e4ac701 100644
--- a/net/d80211/ieee80211.c
+++ b/net/d80211/ieee80211.c
@@ -4215,6 +4215,13 @@ int ieee80211_register_hw(struct net_dev
"algorithm\n", dev->name);
goto fail_rate;
}
+ result = rate_control_add_attrs(local, local->rate_ctrl_priv,
+ &local->class_dev.kobj);
+ if (result < 0) {
+ printk(KERN_DEBUG "%s: Failed to register sysfs attributes "
+ "for rate control\n", dev->name);
+ goto fail_rate_attrs;
+ }
/* TODO: add rtnl locking around device creation and qdisc install */
ieee80211_install_qdisc(dev);
@@ -4233,6 +4240,8 @@ int ieee80211_register_hw(struct net_dev
return 0;
+fail_rate_attrs:
+ rate_control_free(local);
fail_rate:
ieee80211_sysfs_remove_netdevice(dev);
fail_if_sysfs:
@@ -4308,6 +4317,8 @@ void ieee80211_unregister_hw(struct net_
rtnl_unlock();
sta_info_stop(local);
+ rate_control_remove_attrs(local, local->rate_ctrl_priv,
+ &local->class_dev.kobj);
ieee80211_dev_sysfs_del(local);
for (i = 0; i < IEEE80211_FRAGMENT_MAX; i++)
@@ -4327,7 +4338,6 @@ void ieee80211_unregister_hw(struct net_
skb_queue_purge(&local->skb_queue);
skb_queue_purge(&local->skb_queue_unreliable);
- rate_control_free(local);
ieee80211_dev_free_index(local);
}
@@ -4341,6 +4351,7 @@ void ieee80211_free_hw(struct net_device
void ieee80211_release_hw(struct ieee80211_local *local)
{
+ rate_control_free(local);
kfree(local);
}
diff --git a/net/d80211/rate_control.c b/net/d80211/rate_control.c
index e7e6791..33ba8e2 100644
--- a/net/d80211/rate_control.c
+++ b/net/d80211/rate_control.c
@@ -350,6 +350,46 @@ static int rate_control_simple_status_gl
return 0;
}
+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;
+
+ return sprintf(buf, "%d\n", srctrl->tx_avg_rate_sum);
+}
+
+static ssize_t show_sta_tx_avg_rate_num(const struct sta_info *sta, char *buf)
+{
+ struct sta_rate_control *srctrl = sta->rate_ctrl_priv;
+
+ return sprintf(buf, "%d\n", srctrl->tx_avg_rate_num);
+}
+
+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 struct attribute_group rate_control_simple_sta_group = {
+ .name = "rate_control_simple",
+ .attrs = rate_control_simple_sta_attrs,
+};
+
+static int rate_control_simple_add_sta_attrs(void *priv, struct kobject *kobj)
+{
+ return sysfs_create_group(kobj, &rate_control_simple_sta_group);
+}
+
+static void rate_control_simple_remove_sta_attrs(void *priv,
+ struct kobject *kobj)
+{
+ sysfs_remove_group(kobj, &rate_control_simple_sta_group);
+}
static struct rate_control_ops rate_control_simple = {
.name = "simple",
@@ -363,6 +403,8 @@ 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,
};
diff --git a/net/d80211/rate_control.h b/net/d80211/rate_control.h
index b509539..7705fb2 100644
--- a/net/d80211/rate_control.h
+++ b/net/d80211/rate_control.h
@@ -53,6 +53,11 @@ struct rate_control_ops {
void (*free)(void *priv);
void * (*alloc_sta)(void);
void (*free_sta)(void *priv);
+
+ int (*add_attrs)(void *priv, struct kobject *kobj);
+ void (*remove_attrs)(void *priv, struct kobject *kobj);
+ int (*add_sta_attrs)(void *priv, struct kobject *kobj);
+ void (*remove_sta_attrs)(void *priv, struct kobject *kobj);
};
@@ -132,4 +137,35 @@ static inline void rate_control_free_sta
local->rate_ctrl->free_sta(priv);
}
+static inline int rate_control_add_attrs(struct ieee80211_local *local,
+ void *priv, struct kobject *kobj)
+{
+ if (local->rate_ctrl->add_attrs)
+ return local->rate_ctrl->add_attrs(priv, kobj);
+ return 0;
+}
+
+static inline void rate_control_remove_attrs(struct ieee80211_local *local,
+ void *priv, struct kobject *kobj)
+{
+ if (local->rate_ctrl->remove_attrs)
+ local->rate_ctrl->remove_attrs(priv, kobj);
+}
+
+static inline int rate_control_add_sta_attrs(struct ieee80211_local *local,
+ void *priv, struct kobject *kobj)
+{
+ if (local->rate_ctrl->add_sta_attrs)
+ return local->rate_ctrl->add_sta_attrs(priv, kobj);
+ return 0;
+}
+
+static inline void rate_control_remove_sta_attrs(struct ieee80211_local *local,
+ void *priv,
+ struct kobject *kobj)
+{
+ if (local->rate_ctrl->remove_sta_attrs)
+ local->rate_ctrl->remove_sta_attrs(priv, kobj);
+}
+
#endif /* RATE_CONTROL */
diff --git a/net/d80211/sta_info.c b/net/d80211/sta_info.c
index 9c6adaa..96e8dc4 100644
--- a/net/d80211/sta_info.c
+++ b/net/d80211/sta_info.c
@@ -178,6 +178,8 @@ #endif /* CONFIG_D80211_VERBOSE_DEBUG */
if (!in_interrupt()) {
sta->sysfs_registered = 1;
ieee80211_sta_sysfs_add(sta);
+ rate_control_add_sta_attrs(local, sta->rate_ctrl_priv,
+ &sta->kobj);
ieee80211_proc_init_sta(local, sta);
} else {
/* procfs entry adding might sleep, so schedule process context
@@ -197,6 +199,7 @@ #ifdef CONFIG_D80211_VERBOSE_DEBUG
local->mdev->name, MAC2STR(sta->addr));
#endif /* CONFIG_D80211_VERBOSE_DEBUG */
+ rate_control_remove_sta_attrs(local, sta->rate_ctrl_priv, &sta->kobj);
ieee80211_proc_deinit_sta(local, sta);
ieee80211_sta_sysfs_remove(sta);
@@ -367,6 +370,7 @@ static void sta_info_proc_add_task(void
sta->sysfs_registered = 1;
ieee80211_sta_sysfs_add(sta);
+ rate_control_add_sta_attrs(local, sta->rate_ctrl_priv, &sta->kobj);
ieee80211_proc_init_sta(local, sta);
sta_info_put(sta);
}
--
1.3.0
next prev parent reply other threads:[~2006-06-08 7:48 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-06-08 7:49 [PATCH 0/12] d80211: use sysfs instead of procfs Jiri Benc
2006-06-08 7:49 ` [PATCH 1/12] d80211: deinit sysfs in case of an error Jiri Benc
2006-06-08 7:49 ` [PATCH 2/12] d80211: better sysfs registration of symlinks to wiphy Jiri Benc
2006-06-08 7:49 ` [PATCH 3/12] d80211: separate allocation of ieee80211_local Jiri Benc
2006-06-12 19:35 ` Jiri Benc
2006-06-12 19:52 ` John W. Linville
2006-06-08 7:49 ` [PATCH 4/12] d80211: fix Oops when writing to add_ and remove_iface Jiri Benc
2006-06-08 7:49 ` [PATCH 5/12] d80211: wiphy sysfs attributes Jiri Benc
2006-06-08 7:49 ` [PATCH 6/12] d80211: network interface " Jiri Benc
2006-06-08 7:49 ` [PATCH 7/12] d80211: rename sta_info_relase to sta_info_put Jiri Benc
2006-06-08 7:49 ` [PATCH 8/12] d80211: sysfs attributes for associated stations Jiri Benc
2006-06-08 7:49 ` [PATCH 9/12] d80211: remove useless parameters Jiri Benc
2006-06-08 7:49 ` Jiri Benc [this message]
2006-06-08 7:49 ` [PATCH 11/12] d80211: encryption keys sysfs attributes Jiri Benc
2006-06-08 7:49 ` [PATCH 12/12] d80211: remove procfs files Jiri Benc
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20060608074914.7D3B64838E@silver.suse.cz \
--to=jbenc@suse.cz \
--cc=linville@tuxdriver.com \
--cc=netdev@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).