From: greearb@candelatech.com
To: linux-wireless@vger.kernel.org
Cc: Ben Greear <greearb@candelatech.com>
Subject: [RFC 2/2] mac80211: Support getting sta_info stats via ethtool.
Date: Thu, 15 Mar 2012 10:39:19 -0700 [thread overview]
Message-ID: <1331833159-12694-2-git-send-email-greearb@candelatech.com> (raw)
In-Reply-To: <1331833159-12694-1-git-send-email-greearb@candelatech.com>
From: Ben Greear <greearb@candelatech.com>
This lets ethtool print out stats related to station
interfaces. Does not yet get stats from the underlying
driver.
Signed-off-by: Ben Greear <greearb@candelatech.com>
---
:100644 100644 cf5b08a... 2acd0ea... M net/mac80211/cfg.c
net/mac80211/cfg.c | 69 ++++++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 69 insertions(+), 0 deletions(-)
diff --git a/net/mac80211/cfg.c b/net/mac80211/cfg.c
index cf5b08a..2acd0ea 100644
--- a/net/mac80211/cfg.c
+++ b/net/mac80211/cfg.c
@@ -112,6 +112,72 @@ static int ieee80211_set_noack_map(struct wiphy *wiphy,
return 0;
}
+static const char ieee80211_gstrings_sta_stats[][ETH_GSTRING_LEN] = {
+ "rx_packets", "rx_bytes", "wep_weak_iv_count",
+ "rx_duplicates", "rx_fragments", "rx_dropped",
+ "tx_packets", "tx_bytes", "tx_fragments",
+ "tx_filtered", "tx_retry_failed", "tx_retries",
+ "beacon_loss"
+};
+#define STA_STATS_LEN ARRAY_SIZE(ieee80211_gstrings_sta_stats)
+
+static int ieee80211_get_et_sset_count(struct wiphy *wiphy,
+ struct net_device *dev,
+ int sset)
+{
+ switch (sset) {
+ case ETH_SS_STATS:
+ return STA_STATS_LEN;
+ default:
+ return -EOPNOTSUPP;
+ }
+}
+
+static void ieee80211_get_et_stats(struct wiphy *wiphy,
+ struct net_device *dev,
+ struct ethtool_stats *stats,
+ u64 *data)
+{
+ struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
+ struct sta_info *sta;
+
+ memset(data, 0, sizeof(u64) * STA_STATS_LEN);
+
+ mutex_lock(&sdata->local->sta_mtx);
+ list_for_each_entry(sta, &sdata->local->sta_list, list) {
+ int i = 0;
+ data[i++] += sta->rx_packets;
+ data[i++] += sta->rx_bytes;
+ data[i++] += sta->wep_weak_iv_count;
+ data[i++] += sta->num_duplicates;
+ data[i++] += sta->rx_fragments;
+ data[i++] += sta->rx_dropped;
+
+ data[i++] += sta->tx_packets;
+ data[i++] += sta->tx_bytes;
+ data[i++] += sta->tx_fragments;
+ data[i++] += sta->tx_filtered_count;
+ data[i++] += sta->tx_retry_failed;
+ data[i++] += sta->tx_retry_count;
+ data[i++] += sta->beacon_loss_count;
+ BUG_ON(i != STA_STATS_LEN);
+ }
+ mutex_unlock(&sdata->local->sta_mtx);
+}
+
+static void ieee80211_get_et_strings(struct wiphy *wiphy,
+ struct net_device *dev,
+ u32 sset, u8 *data)
+{
+ switch (sset) {
+ case ETH_SS_STATS:
+ memcpy(data, *ieee80211_gstrings_sta_stats,
+ sizeof(ieee80211_gstrings_sta_stats));
+ break;
+ }
+}
+
+
static int ieee80211_add_key(struct wiphy *wiphy, struct net_device *dev,
u8 key_idx, bool pairwise, const u8 *mac_addr,
struct key_params *params)
@@ -2768,4 +2834,7 @@ struct cfg80211_ops mac80211_config_ops = {
.probe_client = ieee80211_probe_client,
.get_channel = ieee80211_wiphy_get_channel,
.set_noack_map = ieee80211_set_noack_map,
+ .get_et_sset_count = ieee80211_get_et_sset_count,
+ .get_et_stats = ieee80211_get_et_stats,
+ .get_et_strings = ieee80211_get_et_strings,
};
--
1.7.3.4
next prev parent reply other threads:[~2012-03-15 17:39 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-03-15 17:39 [RFC 1/2] cfg80211: Add framework to support ethtool stats greearb
2012-03-15 17:39 ` greearb [this message]
2012-03-15 18:52 ` [RFC 2/2] mac80211: Support getting sta_info stats via ethtool Johannes Berg
2012-03-15 18:56 ` Ben Greear
2012-03-16 13:49 ` John W. Linville
2012-03-16 14:18 ` Florian Fainelli
2012-03-16 14:54 ` Ben Greear
2012-03-16 14:59 ` Florian Fainelli
2012-03-16 16:39 ` Ben Greear
2012-03-16 17:14 ` Rick Jones
2012-03-15 18:55 ` Johannes Berg
2012-03-15 19:03 ` Ben Greear
2012-03-15 19:05 ` Johannes Berg
2012-03-15 18:50 ` [RFC 1/2] cfg80211: Add framework to support ethtool stats Johannes Berg
2012-03-15 18:52 ` Ben Greear
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=1331833159-12694-2-git-send-email-greearb@candelatech.com \
--to=greearb@candelatech.com \
--cc=linux-wireless@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).