2012-03-19 18:51:53

by Ben Greear

[permalink] [raw]
Subject: [PATCH v3 1/4] cfg80211: Add framework to support ethtool stats.

From: Ben Greear <[email protected]>

Signed-off-by: Ben Greear <[email protected]>
---

v3: Add reference to ethtool_ops in comments.
This doesn't actually make kdoc generate links,
but hopefully a human can figure it out.

:100644 100644 9ed8021... c60b180... M include/net/cfg80211.h
:100644 100644 9bde4d1... 7eecdf4... M net/wireless/ethtool.c
include/net/cfg80211.h | 17 +++++++++++++++++
net/wireless/ethtool.c | 29 +++++++++++++++++++++++++++++
2 files changed, 46 insertions(+), 0 deletions(-)

diff --git a/include/net/cfg80211.h b/include/net/cfg80211.h
index 9ed8021..c60b180 100644
--- a/include/net/cfg80211.h
+++ b/include/net/cfg80211.h
@@ -1491,6 +1491,16 @@ struct cfg80211_gtk_rekey_data {
* later passes to cfg80211_probe_status().
*
* @set_noack_map: Set the NoAck Map for the TIDs.
+ *
+ * @get_et_sset_count: Ethtool API to get string-set count.
+ * See @ethtool_ops.get_sset_count
+ *
+ * @get_et_stats: Ethtool API to get a set of u64 stats.
+ * See @ethtool_ops.get_ethtool_stats
+ *
+ * @get_et_strings: Ethtool API to get a set of strings to describe stats
+ * and perhaps other supported types of ethtool data-sets.
+ * See @ethtool_ops.get_strings
*/
struct cfg80211_ops {
int (*suspend)(struct wiphy *wiphy, struct cfg80211_wowlan *wow);
@@ -1689,6 +1699,13 @@ struct cfg80211_ops {
u16 noack_map);

struct ieee80211_channel *(*get_channel)(struct wiphy *wiphy);
+
+ int (*get_et_sset_count)(struct wiphy *wiphy,
+ struct net_device *dev, int sset);
+ void (*get_et_stats)(struct wiphy *wiphy, struct net_device *dev,
+ struct ethtool_stats *stats, u64 *data);
+ void (*get_et_strings)(struct wiphy *wiphy, struct net_device *dev,
+ u32 sset, u8 *data);
};

/*
diff --git a/net/wireless/ethtool.c b/net/wireless/ethtool.c
index 9bde4d1..7eecdf4 100644
--- a/net/wireless/ethtool.c
+++ b/net/wireless/ethtool.c
@@ -68,6 +68,32 @@ static int cfg80211_set_ringparam(struct net_device *dev,
return -ENOTSUPP;
}

+static int cfg80211_get_sset_count(struct net_device *dev, int sset)
+{
+ struct wireless_dev *wdev = dev->ieee80211_ptr;
+ struct cfg80211_registered_device *rdev = wiphy_to_dev(wdev->wiphy);
+ if (rdev->ops->get_et_sset_count)
+ return rdev->ops->get_et_sset_count(wdev->wiphy, dev, sset);
+ return -EOPNOTSUPP;
+}
+
+static void cfg80211_get_stats(struct net_device *dev,
+ struct ethtool_stats *stats, u64 *data)
+{
+ struct wireless_dev *wdev = dev->ieee80211_ptr;
+ struct cfg80211_registered_device *rdev = wiphy_to_dev(wdev->wiphy);
+ if (rdev->ops->get_et_stats)
+ rdev->ops->get_et_stats(wdev->wiphy, dev, stats, data);
+}
+
+static void cfg80211_get_strings(struct net_device *dev, u32 sset, u8 *data)
+{
+ struct wireless_dev *wdev = dev->ieee80211_ptr;
+ struct cfg80211_registered_device *rdev = wiphy_to_dev(wdev->wiphy);
+ if (rdev->ops->get_et_strings)
+ rdev->ops->get_et_strings(wdev->wiphy, dev, sset, data);
+}
+
const struct ethtool_ops cfg80211_ethtool_ops = {
.get_drvinfo = cfg80211_get_drvinfo,
.get_regs_len = cfg80211_get_regs_len,
@@ -75,4 +101,7 @@ const struct ethtool_ops cfg80211_ethtool_ops = {
.get_link = ethtool_op_get_link,
.get_ringparam = cfg80211_get_ringparam,
.set_ringparam = cfg80211_set_ringparam,
+ .get_strings = cfg80211_get_strings,
+ .get_ethtool_stats = cfg80211_get_stats,
+ .get_sset_count = cfg80211_get_sset_count,
};
--
1.7.3.4



2012-03-19 18:53:14

by Ben Greear

[permalink] [raw]
Subject: [PATCH v3 3/4] mac80211: Framework to get wifi-driver stats via ethtool.

From: Ben Greear <[email protected]>

This adds hooks to call into the driver to get additional
stats for the ethtool API.

Signed-off-by: Ben Greear <[email protected]>
---
v3: No changes from v2.

:100644 100644 d49928b... a90cc8e... M include/net/mac80211.h
:100644 100644 bb834d7... f82b285... M net/mac80211/cfg.c
:100644 100644 b6ef8e7... c2d1661... M net/mac80211/driver-ops.h
:100644 100644 6e9df8f... f05fc9c... M net/mac80211/driver-trace.h
include/net/mac80211.h | 17 +++++++++++++++++
net/mac80211/cfg.c | 19 ++++++++++++++++---
net/mac80211/driver-ops.h | 37 +++++++++++++++++++++++++++++++++++++
net/mac80211/driver-trace.h | 15 +++++++++++++++
4 files changed, 85 insertions(+), 3 deletions(-)

diff --git a/include/net/mac80211.h b/include/net/mac80211.h
index d49928b..a90cc8e 100644
--- a/include/net/mac80211.h
+++ b/include/net/mac80211.h
@@ -2108,6 +2108,14 @@ enum ieee80211_frame_release_type {
* The @tids parameter is a bitmap and tells the driver which TIDs the
* frames will be on; it will at most have two bits set.
* This callback must be atomic.
+ *
+ * @get_et_sset_count: Ethtool API to get string-set count.
+ *
+ * @get_et_stats: Ethtool API to get a set of u64 stats.
+ *
+ * @get_et_strings: Ethtool API to get a set of strings to describe stats
+ * and perhaps other supported types of ethtool data-sets.
+ *
*/
struct ieee80211_ops {
void (*tx)(struct ieee80211_hw *hw, struct sk_buff *skb);
@@ -2236,6 +2244,15 @@ struct ieee80211_ops {
u16 tids, int num_frames,
enum ieee80211_frame_release_type reason,
bool more_data);
+
+ int (*get_et_sset_count)(struct ieee80211_hw *hw,
+ struct ieee80211_vif *vif, int sset);
+ void (*get_et_stats)(struct ieee80211_hw *hw,
+ struct ieee80211_vif *vif,
+ struct ethtool_stats *stats, u64 *data);
+ void (*get_et_strings)(struct ieee80211_hw *hw,
+ struct ieee80211_vif *vif,
+ u32 sset, u8 *data);
};

/**
diff --git a/net/mac80211/cfg.c b/net/mac80211/cfg.c
index bb834d7..f82b285 100644
--- a/net/mac80211/cfg.c
+++ b/net/mac80211/cfg.c
@@ -125,10 +125,17 @@ static int ieee80211_get_et_sset_count(struct wiphy *wiphy,
struct net_device *dev,
int sset)
{
+ struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
+ int rv = 0;
+
if (sset == ETH_SS_STATS)
- return STA_STATS_LEN;
+ rv += STA_STATS_LEN;

- return -EOPNOTSUPP;
+ rv += drv_get_et_sset_count(sdata, sset);
+
+ if (rv == 0)
+ return -EOPNOTSUPP;
+ return rv;
}

static void ieee80211_get_et_stats(struct wiphy *wiphy,
@@ -167,16 +174,22 @@ static void ieee80211_get_et_stats(struct wiphy *wiphy,
BUG_ON(i != STA_STATS_LEN);
}
rcu_read_unlock();
+
+ drv_get_et_stats(sdata, stats, &(data[STA_STATS_LEN]));
}

static void ieee80211_get_et_strings(struct wiphy *wiphy,
struct net_device *dev,
u32 sset, u8 *data)
{
+ struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
+ int sz_sta_stats = 0;
+
if (sset == ETH_SS_STATS) {
- int sz_sta_stats = sizeof(ieee80211_gstrings_sta_stats);
+ sz_sta_stats = sizeof(ieee80211_gstrings_sta_stats);
memcpy(data, *ieee80211_gstrings_sta_stats, sz_sta_stats);
}
+ drv_get_et_strings(sdata, sset, &(data[sz_sta_stats]));
}


diff --git a/net/mac80211/driver-ops.h b/net/mac80211/driver-ops.h
index b6ef8e7..c2d1661 100644
--- a/net/mac80211/driver-ops.h
+++ b/net/mac80211/driver-ops.h
@@ -35,6 +35,43 @@ static inline void drv_tx_frags(struct ieee80211_local *local,
local->ops->tx_frags(&local->hw, vif, sta, skbs);
}

+static inline void drv_get_et_strings(struct ieee80211_sub_if_data *sdata,
+ u32 sset, u8 *data)
+{
+ struct ieee80211_local *local = sdata->local;
+ if (local->ops->get_et_strings) {
+ trace_drv_get_et_strings(local, sset);
+ local->ops->get_et_strings(&local->hw, &sdata->vif, sset, data);
+ trace_drv_return_void(local);
+ }
+}
+
+static inline void drv_get_et_stats(struct ieee80211_sub_if_data *sdata,
+ struct ethtool_stats *stats,
+ u64 *data)
+{
+ struct ieee80211_local *local = sdata->local;
+ if (local->ops->get_et_stats) {
+ trace_drv_get_et_stats(local);
+ local->ops->get_et_stats(&local->hw, &sdata->vif, stats, data);
+ trace_drv_return_void(local);
+ }
+}
+
+static inline int drv_get_et_sset_count(struct ieee80211_sub_if_data *sdata,
+ int sset)
+{
+ struct ieee80211_local *local = sdata->local;
+ int rv = 0;
+ if (local->ops->get_et_sset_count) {
+ trace_drv_get_et_sset_count(local, sset);
+ rv = local->ops->get_et_sset_count(&local->hw, &sdata->vif,
+ sset);
+ trace_drv_return_int(local, rv);
+ }
+ return rv;
+}
+
static inline int drv_start(struct ieee80211_local *local)
{
int ret;
diff --git a/net/mac80211/driver-trace.h b/net/mac80211/driver-trace.h
index 6e9df8f..f05fc9c 100644
--- a/net/mac80211/driver-trace.h
+++ b/net/mac80211/driver-trace.h
@@ -161,6 +161,21 @@ DEFINE_EVENT(local_only_evt, drv_start,
TP_ARGS(local)
);

+DEFINE_EVENT(local_u32_evt, drv_get_et_strings,
+ TP_PROTO(struct ieee80211_local *local, u32 sset),
+ TP_ARGS(local, sset)
+);
+
+DEFINE_EVENT(local_u32_evt, drv_get_et_sset_count,
+ TP_PROTO(struct ieee80211_local *local, u32 sset),
+ TP_ARGS(local, sset)
+);
+
+DEFINE_EVENT(local_only_evt, drv_get_et_stats,
+ TP_PROTO(struct ieee80211_local *local),
+ TP_ARGS(local)
+);
+
DEFINE_EVENT(local_only_evt, drv_suspend,
TP_PROTO(struct ieee80211_local *local),
TP_ARGS(local)
--
1.7.3.4


2012-03-20 16:47:42

by Ben Greear

[permalink] [raw]
Subject: Re: [PATCH v3 4/4] ath9k: Support ethtool getstats api.

On 03/20/2012 01:42 AM, Florian Fainelli wrote:
> Hi,
>
> Le 03/19/12 19:51, [email protected] a écrit :
>> From: Ben Greear<[email protected]>
>>
>> This returns many of the values that formerly could
>> only be obtained from debugfs. This should be an
>> improvement when trying to access these counters
>> programatically. Currently this support is only
>> enabled when DEBUGFS is enabled because otherwise
>> these stats are not accumulated.
>>
>> Signed-off-by: Ben Greear<[email protected]>
>> ---
>>
>> v3: No changes from v2
>>
>> :100644 100644 4a00806... 7261f88... M drivers/net/wireless/ath/ath9k/main.c
>> drivers/net/wireless/ath/ath9k/main.c | 134 +++++++++++++++++++++++++++++++++
>> 1 files changed, 134 insertions(+), 0 deletions(-)
>>
>> diff --git a/drivers/net/wireless/ath/ath9k/main.c b/drivers/net/wireless/ath/ath9k/main.c
>> index 4a00806..7261f88 100644
>> --- a/drivers/net/wireless/ath/ath9k/main.c
>> +++ b/drivers/net/wireless/ath/ath9k/main.c
>> @@ -2430,6 +2430,134 @@ static int ath9k_get_antenna(struct ieee80211_hw *hw, u32 *tx_ant, u32 *rx_ant)
>> return 0;
>> }
>>
>> +#ifdef CONFIG_ATH9K_DEBUGFS
>
> These are ethtool knobs, so you might want to introduce a new config symbol dedicated to it, which depends on CONFIG_ATH9K_DEBUGFS eventually.

I'd like to gather at least most stats always, so ethtool can work regardless of
debugfs. But, that can be follow on patches in my opinion. If it turns out
that we need another config option for this, then that is fine too.

Thanks,
Ben

--
Ben Greear <[email protected]>
Candela Technologies Inc http://www.candelatech.com


2012-03-19 18:52:18

by Ben Greear

[permalink] [raw]
Subject: [PATCH v3 2/4] mac80211: Support getting sta_info stats via ethtool.

From: Ben Greear <[email protected]>

This lets ethtool print out stats related to stations
connected to the interface. Does not yet get stats
from the underlying driver.

Signed-off-by: Ben Greear <[email protected]>
---

v3: Update patch description.

:100644 100644 cf5b08a... bb834d7... M net/mac80211/cfg.c
net/mac80211/cfg.c | 71 ++++++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 71 insertions(+), 0 deletions(-)

diff --git a/net/mac80211/cfg.c b/net/mac80211/cfg.c
index cf5b08a..bb834d7 100644
--- a/net/mac80211/cfg.c
+++ b/net/mac80211/cfg.c
@@ -112,6 +112,74 @@ 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)
+{
+ if (sset == ETH_SS_STATS)
+ return STA_STATS_LEN;
+
+ 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;
+ struct ieee80211_local *local = sdata->local;
+
+ memset(data, 0, sizeof(u64) * STA_STATS_LEN);
+
+ rcu_read_lock();
+ list_for_each_entry_rcu(sta, &local->sta_list, list) {
+ int i = 0;
+
+ /* Make sure this station belongs to the proper dev */
+ if (sta->sdata->dev != dev)
+ continue;
+
+ 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);
+ }
+ rcu_read_unlock();
+}
+
+static void ieee80211_get_et_strings(struct wiphy *wiphy,
+ struct net_device *dev,
+ u32 sset, u8 *data)
+{
+ if (sset == ETH_SS_STATS) {
+ int sz_sta_stats = sizeof(ieee80211_gstrings_sta_stats);
+ memcpy(data, *ieee80211_gstrings_sta_stats, sz_sta_stats);
+ }
+}
+
+
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 +2836,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


2012-03-21 16:11:08

by Ben Hutchings

[permalink] [raw]
Subject: Re: [PATCH v3 4/4] ath9k: Support ethtool getstats api.

On Wed, 2012-03-21 at 12:37 +0530, Sujith Manoharan wrote:
> Ben Greear wrote:
> > I'd like to gather at least most stats always, so ethtool can work regardless
> > of debugfs. But, that can be follow on patches in my opinion. If it turns
> > out that we need another config option for this, then that is fine too.
>
> It would be good to have an option to compile this out. The information is
> available via the debugfs interface, so this is basically duplicating things.
> On APs using OpenWRT, debugfs is enabled by default, so we can just read
> the debugfs files.

ethtool is the normal way to expose extended network stats, so the
debugfs interface should be dropped in favour of this.

Ben.

--
Ben Hutchings, Staff Engineer, Solarflare
Not speaking for my employer; that's the marketing department's job.
They asked us to note that Solarflare product names are trademarked.


2012-03-21 16:20:19

by Ben Greear

[permalink] [raw]
Subject: Re: [PATCH v3 4/4] ath9k: Support ethtool getstats api.

On 03/21/2012 09:10 AM, Ben Hutchings wrote:
> On Wed, 2012-03-21 at 12:37 +0530, Sujith Manoharan wrote:
>> Ben Greear wrote:
>>> I'd like to gather at least most stats always, so ethtool can work regardless
>>> of debugfs. But, that can be follow on patches in my opinion. If it turns
>>> out that we need another config option for this, then that is fine too.
>>
>> It would be good to have an option to compile this out. The information is
>> available via the debugfs interface, so this is basically duplicating things.
>> On APs using OpenWRT, debugfs is enabled by default, so we can just read
>> the debugfs files.
>
> ethtool is the normal way to expose extended network stats, so the
> debugfs interface should be dropped in favour of this.

No...ath9k debugfs offers a lot of additional info that is not easily
packaged into ethtool stats, and is better formatted for reading
by humans.

So, both should be kept..though we can optionally compile
out both/either/none.

Thanks,
Ben


--
Ben Greear <[email protected]>
Candela Technologies Inc http://www.candelatech.com


2012-03-19 18:52:42

by Ben Greear

[permalink] [raw]
Subject: [PATCH v3 4/4] ath9k: Support ethtool getstats api.

From: Ben Greear <[email protected]>

This returns many of the values that formerly could
only be obtained from debugfs. This should be an
improvement when trying to access these counters
programatically. Currently this support is only
enabled when DEBUGFS is enabled because otherwise
these stats are not accumulated.

Signed-off-by: Ben Greear <[email protected]>
---

v3: No changes from v2

:100644 100644 4a00806... 7261f88... M drivers/net/wireless/ath/ath9k/main.c
drivers/net/wireless/ath/ath9k/main.c | 134 +++++++++++++++++++++++++++++++++
1 files changed, 134 insertions(+), 0 deletions(-)

diff --git a/drivers/net/wireless/ath/ath9k/main.c b/drivers/net/wireless/ath/ath9k/main.c
index 4a00806..7261f88 100644
--- a/drivers/net/wireless/ath/ath9k/main.c
+++ b/drivers/net/wireless/ath/ath9k/main.c
@@ -2430,6 +2430,134 @@ static int ath9k_get_antenna(struct ieee80211_hw *hw, u32 *tx_ant, u32 *rx_ant)
return 0;
}

+#ifdef CONFIG_ATH9K_DEBUGFS
+
+/* Ethtool support for get-stats */
+
+#define AMKSTR(nm) #nm "_BE", #nm "_BK", #nm "_VI", #nm "_VO"
+static const char ath9k_gstrings_stats[][ETH_GSTRING_LEN] = {
+ "tx_pkts_nic",
+ "tx_bytes_nic",
+ "rx_pkts_nic",
+ "rx_bytes_nic",
+ AMKSTR(d_tx_pkts),
+ AMKSTR(d_tx_bytes),
+ AMKSTR(d_tx_mpdus_queued),
+ AMKSTR(d_tx_mpdus_completed),
+ AMKSTR(d_tx_mpdu_retries),
+ AMKSTR(d_tx_aggregates),
+ AMKSTR(d_tx_ampdus_queued_hw),
+ AMKSTR(d_tx_ampdus_queued_sw),
+ AMKSTR(d_tx_ampdus_completed),
+ AMKSTR(d_tx_ampdu_retries),
+ AMKSTR(d_tx_ampdu_xretries),
+ AMKSTR(d_tx_fifo_underrun),
+ AMKSTR(d_tx_op_exceeded),
+ AMKSTR(d_tx_timer_expiry),
+ AMKSTR(d_tx_desc_cfg_err),
+ AMKSTR(d_tx_data_underrun),
+ AMKSTR(d_tx_delim_underrun),
+
+ "d_rx_decrypt_crc_err",
+ "d_rx_phy_err",
+ "d_rx_mic_err",
+ "d_rx_pre_delim_crc_err",
+ "d_rx_post_delim_crc_err",
+ "d_rx_decrypt_busy_err",
+
+ "d_rx_phyerr_radar",
+ "d_rx_phyerr_ofdm_timing",
+ "d_rx_phyerr_cck_timing",
+
+};
+#define ATH9K_SSTATS_LEN ARRAY_SIZE(ath9k_gstrings_stats)
+
+static void ath9k_get_et_strings(struct ieee80211_hw *hw,
+ struct ieee80211_vif *vif,
+ u32 sset, u8 *data)
+{
+ if (sset == ETH_SS_STATS)
+ memcpy(data, *ath9k_gstrings_stats,
+ sizeof(ath9k_gstrings_stats));
+}
+
+static int ath9k_get_et_sset_count(struct ieee80211_hw *hw,
+ struct ieee80211_vif *vif, int sset)
+{
+ if (sset == ETH_SS_STATS)
+ return ATH9K_SSTATS_LEN;
+ return 0;
+}
+
+#define PR_QNUM(_n) (sc->tx.txq_map[_n]->axq_qnum)
+#define AWDATA(elem) \
+ do { \
+ data[i++] = sc->debug.stats.txstats[PR_QNUM(WME_AC_BE)].elem; \
+ data[i++] = sc->debug.stats.txstats[PR_QNUM(WME_AC_BK)].elem; \
+ data[i++] = sc->debug.stats.txstats[PR_QNUM(WME_AC_VI)].elem; \
+ data[i++] = sc->debug.stats.txstats[PR_QNUM(WME_AC_VO)].elem; \
+ } while (0)
+
+#define AWDATA_RX(elem) \
+ do { \
+ data[i++] = sc->debug.stats.rxstats.elem; \
+ } while (0)
+
+static void ath9k_get_et_stats(struct ieee80211_hw *hw,
+ struct ieee80211_vif *vif,
+ struct ethtool_stats *stats, u64 *data)
+{
+ struct ath_softc *sc = hw->priv;
+ int i = 0;
+
+ data[i++] = (sc->debug.stats.txstats[PR_QNUM(WME_AC_BE)].tx_pkts_all +
+ sc->debug.stats.txstats[PR_QNUM(WME_AC_BK)].tx_pkts_all +
+ sc->debug.stats.txstats[PR_QNUM(WME_AC_VI)].tx_pkts_all +
+ sc->debug.stats.txstats[PR_QNUM(WME_AC_VO)].tx_pkts_all);
+ data[i++] = (sc->debug.stats.txstats[PR_QNUM(WME_AC_BE)].tx_bytes_all +
+ sc->debug.stats.txstats[PR_QNUM(WME_AC_BK)].tx_bytes_all +
+ sc->debug.stats.txstats[PR_QNUM(WME_AC_VI)].tx_bytes_all +
+ sc->debug.stats.txstats[PR_QNUM(WME_AC_VO)].tx_bytes_all);
+ AWDATA_RX(rx_pkts_all);
+ AWDATA_RX(rx_bytes_all);
+
+ AWDATA(tx_pkts_all);
+ AWDATA(tx_bytes_all);
+ AWDATA(queued);
+ AWDATA(completed);
+ AWDATA(xretries);
+ AWDATA(a_aggr);
+ AWDATA(a_queued_hw);
+ AWDATA(a_queued_sw);
+ AWDATA(a_completed);
+ AWDATA(a_retries);
+ AWDATA(a_xretries);
+ AWDATA(fifo_underrun);
+ AWDATA(xtxop);
+ AWDATA(timer_exp);
+ AWDATA(desc_cfg_err);
+ AWDATA(data_underrun);
+ AWDATA(delim_underrun);
+
+ AWDATA_RX(decrypt_crc_err);
+ AWDATA_RX(phy_err);
+ AWDATA_RX(mic_err);
+ AWDATA_RX(pre_delim_crc_err);
+ AWDATA_RX(post_delim_crc_err);
+ AWDATA_RX(decrypt_busy_err);
+
+ AWDATA_RX(phy_err_stats[ATH9K_PHYERR_RADAR]);
+ AWDATA_RX(phy_err_stats[ATH9K_PHYERR_OFDM_TIMING]);
+ AWDATA_RX(phy_err_stats[ATH9K_PHYERR_CCK_TIMING]);
+
+ BUG_ON(i != ATH9K_SSTATS_LEN);
+}
+
+/* End of ethtool get-stats functions */
+
+#endif
+
+
struct ieee80211_ops ath9k_ops = {
.tx = ath9k_tx,
.start = ath9k_start,
@@ -2458,4 +2586,10 @@ struct ieee80211_ops ath9k_ops = {
.get_stats = ath9k_get_stats,
.set_antenna = ath9k_set_antenna,
.get_antenna = ath9k_get_antenna,
+
+#ifdef CONFIG_ATH9K_DEBUGFS
+ .get_et_sset_count = ath9k_get_et_sset_count,
+ .get_et_stats = ath9k_get_et_stats,
+ .get_et_strings = ath9k_get_et_strings,
+#endif
};
--
1.7.3.4


2012-03-20 08:43:45

by Florian Fainelli

[permalink] [raw]
Subject: Re: [PATCH v3 4/4] ath9k: Support ethtool getstats api.

Hi,

Le 03/19/12 19:51, [email protected] a écrit :
> From: Ben Greear<[email protected]>
>
> This returns many of the values that formerly could
> only be obtained from debugfs. This should be an
> improvement when trying to access these counters
> programatically. Currently this support is only
> enabled when DEBUGFS is enabled because otherwise
> these stats are not accumulated.
>
> Signed-off-by: Ben Greear<[email protected]>
> ---
>
> v3: No changes from v2
>
> :100644 100644 4a00806... 7261f88... M drivers/net/wireless/ath/ath9k/main.c
> drivers/net/wireless/ath/ath9k/main.c | 134 +++++++++++++++++++++++++++++++++
> 1 files changed, 134 insertions(+), 0 deletions(-)
>
> diff --git a/drivers/net/wireless/ath/ath9k/main.c b/drivers/net/wireless/ath/ath9k/main.c
> index 4a00806..7261f88 100644
> --- a/drivers/net/wireless/ath/ath9k/main.c
> +++ b/drivers/net/wireless/ath/ath9k/main.c
> @@ -2430,6 +2430,134 @@ static int ath9k_get_antenna(struct ieee80211_hw *hw, u32 *tx_ant, u32 *rx_ant)
> return 0;
> }
>
> +#ifdef CONFIG_ATH9K_DEBUGFS

These are ethtool knobs, so you might want to introduce a new config
symbol dedicated to it, which depends on CONFIG_ATH9K_DEBUGFS eventually.

> +
> +/* Ethtool support for get-stats */
> +
> +#define AMKSTR(nm) #nm "_BE", #nm "_BK", #nm "_VI", #nm "_VO"
> +static const char ath9k_gstrings_stats[][ETH_GSTRING_LEN] = {
> + "tx_pkts_nic",
> + "tx_bytes_nic",
> + "rx_pkts_nic",
> + "rx_bytes_nic",
> + AMKSTR(d_tx_pkts),
> + AMKSTR(d_tx_bytes),
> + AMKSTR(d_tx_mpdus_queued),
> + AMKSTR(d_tx_mpdus_completed),
> + AMKSTR(d_tx_mpdu_retries),
> + AMKSTR(d_tx_aggregates),
> + AMKSTR(d_tx_ampdus_queued_hw),
> + AMKSTR(d_tx_ampdus_queued_sw),
> + AMKSTR(d_tx_ampdus_completed),
> + AMKSTR(d_tx_ampdu_retries),
> + AMKSTR(d_tx_ampdu_xretries),
> + AMKSTR(d_tx_fifo_underrun),
> + AMKSTR(d_tx_op_exceeded),
> + AMKSTR(d_tx_timer_expiry),
> + AMKSTR(d_tx_desc_cfg_err),
> + AMKSTR(d_tx_data_underrun),
> + AMKSTR(d_tx_delim_underrun),
> +
> + "d_rx_decrypt_crc_err",
> + "d_rx_phy_err",
> + "d_rx_mic_err",
> + "d_rx_pre_delim_crc_err",
> + "d_rx_post_delim_crc_err",
> + "d_rx_decrypt_busy_err",
> +
> + "d_rx_phyerr_radar",
> + "d_rx_phyerr_ofdm_timing",
> + "d_rx_phyerr_cck_timing",
> +
> +};
> +#define ATH9K_SSTATS_LEN ARRAY_SIZE(ath9k_gstrings_stats)
> +
> +static void ath9k_get_et_strings(struct ieee80211_hw *hw,
> + struct ieee80211_vif *vif,
> + u32 sset, u8 *data)
> +{
> + if (sset == ETH_SS_STATS)
> + memcpy(data, *ath9k_gstrings_stats,
> + sizeof(ath9k_gstrings_stats));
> +}
> +
> +static int ath9k_get_et_sset_count(struct ieee80211_hw *hw,
> + struct ieee80211_vif *vif, int sset)
> +{
> + if (sset == ETH_SS_STATS)
> + return ATH9K_SSTATS_LEN;
> + return 0;
> +}
> +
> +#define PR_QNUM(_n) (sc->tx.txq_map[_n]->axq_qnum)
> +#define AWDATA(elem) \
> + do { \
> + data[i++] = sc->debug.stats.txstats[PR_QNUM(WME_AC_BE)].elem; \
> + data[i++] = sc->debug.stats.txstats[PR_QNUM(WME_AC_BK)].elem; \
> + data[i++] = sc->debug.stats.txstats[PR_QNUM(WME_AC_VI)].elem; \
> + data[i++] = sc->debug.stats.txstats[PR_QNUM(WME_AC_VO)].elem; \
> + } while (0)
> +
> +#define AWDATA_RX(elem) \
> + do { \
> + data[i++] = sc->debug.stats.rxstats.elem; \
> + } while (0)
> +
> +static void ath9k_get_et_stats(struct ieee80211_hw *hw,
> + struct ieee80211_vif *vif,
> + struct ethtool_stats *stats, u64 *data)
> +{
> + struct ath_softc *sc = hw->priv;
> + int i = 0;
> +
> + data[i++] = (sc->debug.stats.txstats[PR_QNUM(WME_AC_BE)].tx_pkts_all +
> + sc->debug.stats.txstats[PR_QNUM(WME_AC_BK)].tx_pkts_all +
> + sc->debug.stats.txstats[PR_QNUM(WME_AC_VI)].tx_pkts_all +
> + sc->debug.stats.txstats[PR_QNUM(WME_AC_VO)].tx_pkts_all);
> + data[i++] = (sc->debug.stats.txstats[PR_QNUM(WME_AC_BE)].tx_bytes_all +
> + sc->debug.stats.txstats[PR_QNUM(WME_AC_BK)].tx_bytes_all +
> + sc->debug.stats.txstats[PR_QNUM(WME_AC_VI)].tx_bytes_all +
> + sc->debug.stats.txstats[PR_QNUM(WME_AC_VO)].tx_bytes_all);
> + AWDATA_RX(rx_pkts_all);
> + AWDATA_RX(rx_bytes_all);
> +
> + AWDATA(tx_pkts_all);
> + AWDATA(tx_bytes_all);
> + AWDATA(queued);
> + AWDATA(completed);
> + AWDATA(xretries);
> + AWDATA(a_aggr);
> + AWDATA(a_queued_hw);
> + AWDATA(a_queued_sw);
> + AWDATA(a_completed);
> + AWDATA(a_retries);
> + AWDATA(a_xretries);
> + AWDATA(fifo_underrun);
> + AWDATA(xtxop);
> + AWDATA(timer_exp);
> + AWDATA(desc_cfg_err);
> + AWDATA(data_underrun);
> + AWDATA(delim_underrun);
> +
> + AWDATA_RX(decrypt_crc_err);
> + AWDATA_RX(phy_err);
> + AWDATA_RX(mic_err);
> + AWDATA_RX(pre_delim_crc_err);
> + AWDATA_RX(post_delim_crc_err);
> + AWDATA_RX(decrypt_busy_err);
> +
> + AWDATA_RX(phy_err_stats[ATH9K_PHYERR_RADAR]);
> + AWDATA_RX(phy_err_stats[ATH9K_PHYERR_OFDM_TIMING]);
> + AWDATA_RX(phy_err_stats[ATH9K_PHYERR_CCK_TIMING]);
> +
> + BUG_ON(i != ATH9K_SSTATS_LEN);
> +}
> +
> +/* End of ethtool get-stats functions */
> +
> +#endif
> +
> +
> struct ieee80211_ops ath9k_ops = {
> .tx = ath9k_tx,
> .start = ath9k_start,
> @@ -2458,4 +2586,10 @@ struct ieee80211_ops ath9k_ops = {
> .get_stats = ath9k_get_stats,
> .set_antenna = ath9k_set_antenna,
> .get_antenna = ath9k_get_antenna,
> +
> +#ifdef CONFIG_ATH9K_DEBUGFS
> + .get_et_sset_count = ath9k_get_et_sset_count,
> + .get_et_stats = ath9k_get_et_stats,
> + .get_et_strings = ath9k_get_et_strings,
> +#endif
> };

2012-03-21 07:08:42

by Sujith Manoharan

[permalink] [raw]
Subject: Re: [PATCH v3 4/4] ath9k: Support ethtool getstats api.

Ben Greear wrote:
> I'd like to gather at least most stats always, so ethtool can work regardless
> of debugfs. But, that can be follow on patches in my opinion. If it turns
> out that we need another config option for this, then that is fine too.

It would be good to have an option to compile this out. The information is
available via the debugfs interface, so this is basically duplicating things.
On APs using OpenWRT, debugfs is enabled by default, so we can just read
the debugfs files.

Sujith

2012-03-21 15:12:07

by Ben Greear

[permalink] [raw]
Subject: Re: [PATCH v3 4/4] ath9k: Support ethtool getstats api.

On 03/21/2012 12:07 AM, Sujith Manoharan wrote:
> Ben Greear wrote:
>> I'd like to gather at least most stats always, so ethtool can work regardless
>> of debugfs. But, that can be follow on patches in my opinion. If it turns
>> out that we need another config option for this, then that is fine too.
>
> It would be good to have an option to compile this out. The information is
> available via the debugfs interface, so this is basically duplicating things.
> On APs using OpenWRT, debugfs is enabled by default, so we can just read
> the debugfs files.

Ok. Hopefully at least the first 3 patches will go in, and when they do
I'll post some more patches for consideration.

Thanks,
Ben

--
Ben Greear <[email protected]>
Candela Technologies Inc http://www.candelatech.com