diff mbox

[5/5] ath5k: Add busy ratios to survey data

Message ID 20101005095531.3083.39403.stgit@tt-desk (mailing list archive)
State Not Applicable, archived
Headers show

Commit Message

Bruno Randolf Oct. 5, 2010, 9:55 a.m. UTC
None
diff mbox

Patch

diff --git a/drivers/net/wireless/ath/ath5k/base.c b/drivers/net/wireless/ath/ath5k/base.c
index c158f2e..a33d9f2 100644
--- a/drivers/net/wireless/ath/ath5k/base.c
+++ b/drivers/net/wireless/ath/ath5k/base.c
@@ -3008,6 +3008,7 @@  static int ath5k_get_survey(struct ieee80211_hw *hw, int idx,
 {
 	struct ath5k_softc *sc = hw->priv;
 	struct ieee80211_conf *conf = &hw->conf;
+	struct ath_common *common = ath5k_hw_common(sc->ah);
 
 	 if (idx != 0)
 		return -ENOENT;
@@ -3016,6 +3017,22 @@  static int ath5k_get_survey(struct ieee80211_hw *hw, int idx,
 	survey->filled = SURVEY_INFO_NOISE_DBM;
 	survey->noise = sc->ah->ah_noise_floor;
 
+	ath_hw_cycle_counters_lock(common);
+	ath_hw_cycle_counters_update(common);
+	if (common->cc_survey.cycles > 0) {
+		survey->filled |= SURVEY_INFO_BUSY |
+				SURVEY_INFO_BUSY_TX | SURVEY_INFO_BUSY_RX;
+		survey->busy = common->cc_survey.rx_busy * 255 /
+					common->cc_survey.cycles;
+		survey->busy_tx = common->cc_survey.tx_frame * 255 /
+					common->cc_survey.cycles;
+		survey->busy_rx = common->cc_survey.rx_frame * 255 /
+					common->cc_survey.cycles;
+	}
+
+	memset(&common->cc_survey, 0, sizeof(struct ath_cycle_counters));
+	ath_hw_cycle_counters_unlock(common);
+
 	return 0;
 }