From: Bruno Randolf <br1@einfach.org>
To: linville@tuxdriver.com
Cc: nbd@openwrt.org, ath5k-devel@lists.ath5k.org,
linux-wireless@vger.kernel.org, adrian@freebsd.org,
vasanth@atheros.com
Subject: [PATCH 2/5] ath5k: Use common cycle counters for ANI
Date: Tue, 05 Oct 2010 18:55:15 +0900 [thread overview]
Message-ID: <20101005095515.3083.93927.stgit@tt-desk> (raw)
In-Reply-To: <20101005095510.3083.46174.stgit@tt-desk>
Update ath5k to use the common cycle counters in it's ANI implementation.
Signed-off-by: Bruno Randolf <br1@einfach.org>
---
drivers/net/wireless/ath/ath5k/ani.c | 34 ++++++++++++--------------------
drivers/net/wireless/ath/ath5k/ani.h | 5 +----
drivers/net/wireless/ath/ath5k/debug.c | 21 ++++++++++----------
3 files changed, 25 insertions(+), 35 deletions(-)
diff --git a/drivers/net/wireless/ath/ath5k/ani.c b/drivers/net/wireless/ath/ath5k/ani.c
index e4a5f04..67b41d9 100644
--- a/drivers/net/wireless/ath/ath5k/ani.c
+++ b/drivers/net/wireless/ath/ath5k/ani.c
@@ -360,36 +360,28 @@ ath5k_ani_lower_immunity(struct ath5k_hw *ah, struct ath5k_ani_state *as)
* Return an approximation of the time spent "listening" in milliseconds (ms)
* since the last call of this function by deducting the cycles spent
* transmitting and receiving from the total cycle count.
- * Save profile count values for debugging/statistics and because we might want
- * to use them later.
- *
- * We assume no one else clears these registers!
*/
static int
ath5k_hw_ani_get_listen_time(struct ath5k_hw *ah, struct ath5k_ani_state *as)
{
+ struct ath_common *common = ath5k_hw_common(ah);
int listen;
- /* freeze */
- ath5k_hw_reg_write(ah, AR5K_MIBC_FMC, AR5K_MIBC);
- /* read */
- as->pfc_cycles = ath5k_hw_reg_read(ah, AR5K_PROFCNT_CYCLE);
- as->pfc_busy = ath5k_hw_reg_read(ah, AR5K_PROFCNT_RXCLR);
- as->pfc_tx = ath5k_hw_reg_read(ah, AR5K_PROFCNT_TX);
- as->pfc_rx = ath5k_hw_reg_read(ah, AR5K_PROFCNT_RX);
- /* clear */
- ath5k_hw_reg_write(ah, 0, AR5K_PROFCNT_TX);
- ath5k_hw_reg_write(ah, 0, AR5K_PROFCNT_RX);
- ath5k_hw_reg_write(ah, 0, AR5K_PROFCNT_RXCLR);
- ath5k_hw_reg_write(ah, 0, AR5K_PROFCNT_CYCLE);
- /* un-freeze */
- ath5k_hw_reg_write(ah, 0, AR5K_MIBC);
+ ath_hw_cycle_counters_lock(common);
+ ath_hw_cycle_counters_update(common);
/* TODO: where does 44000 come from? (11g clock rate?) */
- listen = (as->pfc_cycles - as->pfc_rx - as->pfc_tx) / 44000;
+ listen = (common->cc_ani.cycles - common->cc_ani.rx_frame -
+ common->cc_ani.tx_frame) / 44000;
+
+ if (common->cc_ani.cycles == 0 || listen < 0)
+ listen = 0;
+
+ memcpy(&as->last_cc, &common->cc_ani, sizeof(struct ath_cycle_counters));
+ memset(&common->cc_ani, 0, sizeof(struct ath_cycle_counters));
+
+ ath_hw_cycle_counters_unlock(common);
- if (as->pfc_cycles == 0 || listen < 0)
- return 0;
return listen;
}
diff --git a/drivers/net/wireless/ath/ath5k/ani.h b/drivers/net/wireless/ath/ath5k/ani.h
index 55cf26d..d0a6640 100644
--- a/drivers/net/wireless/ath/ath5k/ani.h
+++ b/drivers/net/wireless/ath/ath5k/ani.h
@@ -75,10 +75,7 @@ struct ath5k_ani_state {
unsigned int cck_errors;
/* debug/statistics only: numbers from last ANI calibration */
- unsigned int pfc_tx;
- unsigned int pfc_rx;
- unsigned int pfc_busy;
- unsigned int pfc_cycles;
+ struct ath_cycle_counters last_cc;
unsigned int last_listen;
unsigned int last_ofdm_errors;
unsigned int last_cck_errors;
diff --git a/drivers/net/wireless/ath/ath5k/debug.c b/drivers/net/wireless/ath/ath5k/debug.c
index 0f06e84..f0f8e43 100644
--- a/drivers/net/wireless/ath/ath5k/debug.c
+++ b/drivers/net/wireless/ath/ath5k/debug.c
@@ -711,20 +711,21 @@ static ssize_t read_file_ani(struct file *file, char __user *user_buf,
len += snprintf(buf+len, sizeof(buf)-len,
"beacon RSSI average:\t%d\n",
sc->ah->ah_beacon_rssi_avg.avg);
+
+#define CC_PRINT(_struct, _field) \
+ _struct._field, \
+ _struct.cycles > 0 ? \
+ _struct._field*100/_struct.cycles : 0
+
len += snprintf(buf+len, sizeof(buf)-len, "profcnt tx\t\t%u\t(%d%%)\n",
- as->pfc_tx,
- as->pfc_cycles > 0 ?
- as->pfc_tx*100/as->pfc_cycles : 0);
+ CC_PRINT(as->last_cc, tx_frame));
len += snprintf(buf+len, sizeof(buf)-len, "profcnt rx\t\t%u\t(%d%%)\n",
- as->pfc_rx,
- as->pfc_cycles > 0 ?
- as->pfc_rx*100/as->pfc_cycles : 0);
+ CC_PRINT(as->last_cc, rx_frame));
len += snprintf(buf+len, sizeof(buf)-len, "profcnt busy\t\t%u\t(%d%%)\n",
- as->pfc_busy,
- as->pfc_cycles > 0 ?
- as->pfc_busy*100/as->pfc_cycles : 0);
+ CC_PRINT(as->last_cc, rx_busy));
+#undef CC_PRINT
len += snprintf(buf+len, sizeof(buf)-len, "profcnt cycles\t\t%u\n",
- as->pfc_cycles);
+ as->last_cc.cycles);
len += snprintf(buf+len, sizeof(buf)-len,
"listen time\t\t%d\tlast: %d\n",
as->listen_time, as->last_listen);
next prev parent reply other threads:[~2010-10-05 9:55 UTC|newest]
Thread overview: 27+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-10-05 9:55 [PATCH 1/5] ath: Add common function for reading cycle counters Bruno Randolf
2010-10-05 9:55 ` Bruno Randolf [this message]
2010-10-05 9:55 ` [PATCH 3/5] ath9k: Use common " Bruno Randolf
2010-10-05 20:14 ` [ath5k-devel] " Luis R. Rodriguez
2010-10-06 1:10 ` Bruno Randolf
2010-10-06 1:13 ` Luis R. Rodriguez
2010-10-06 1:18 ` Luis R. Rodriguez
2010-10-06 2:00 ` Bruno Randolf
2010-10-06 2:15 ` [ath5k-devel] " Luis R. Rodriguez
2010-10-05 9:55 ` [PATCH 4/5] nl80211/mac80211: Add channel utilization to survey Bruno Randolf
2010-10-05 22:36 ` Luis R. Rodriguez
2010-10-06 2:35 ` Bruno Randolf
2010-10-06 9:54 ` Helmut Schaa
2010-10-07 1:03 ` Bruno Randolf
2010-10-07 3:02 ` [ath5k-devel] " Luis R. Rodriguez
2010-10-07 6:51 ` Helmut Schaa
2010-10-07 7:06 ` Bruno Randolf
2010-10-07 7:35 ` Jonathan Guerin
2010-10-07 7:44 ` Helmut Schaa
2010-10-07 7:52 ` Johannes Berg
2010-10-08 17:41 ` Helmut Schaa
2010-10-05 9:55 ` [PATCH 5/5] ath5k: Add busy ratios to survey data Bruno Randolf
2010-10-05 22:38 ` Luis R. Rodriguez
2010-10-06 2:25 ` Bruno Randolf
2010-10-06 2:45 ` Felix Fietkau
2010-10-06 2:50 ` Bruno Randolf
2010-10-06 14:13 ` Luis R. Rodriguez
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=20101005095515.3083.93927.stgit@tt-desk \
--to=br1@einfach.org \
--cc=adrian@freebsd.org \
--cc=ath5k-devel@lists.ath5k.org \
--cc=linux-wireless@vger.kernel.org \
--cc=linville@tuxdriver.com \
--cc=nbd@openwrt.org \
--cc=vasanth@atheros.com \
/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