aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBruno Randolf <br1@einfach.org>2010-11-15 20:58:43 -0500
committerJohn W. Linville <linville@tuxdriver.com>2010-11-18 14:22:19 -0500
commiteef39befaae2a1559efe197d795c376a317af2af (patch)
tree341245e6b696b69ae01a0bbbfd7da57df515ec50
parentc5485a7e7569ab32eea240c850198519e2a765ef (diff)
ath5k: Use generic EWMA library
Remove ath5k's private moving average implementation in favour of the generic library version. Signed-off-by: Bruno Randolf <br1@einfach.org> Signed-off-by: John W. Linville <linville@tuxdriver.com>
-rw-r--r--drivers/net/wireless/ath/ath5k/Kconfig1
-rw-r--r--drivers/net/wireless/ath/ath5k/ani.c4
-rw-r--r--drivers/net/wireless/ath/ath5k/ath5k.h26
-rw-r--r--drivers/net/wireless/ath/ath5k/base.c4
-rw-r--r--drivers/net/wireless/ath/ath5k/debug.c2
5 files changed, 8 insertions, 29 deletions
diff --git a/drivers/net/wireless/ath/ath5k/Kconfig b/drivers/net/wireless/ath/ath5k/Kconfig
index eb83b7b4d0e3..47844575caa3 100644
--- a/drivers/net/wireless/ath/ath5k/Kconfig
+++ b/drivers/net/wireless/ath/ath5k/Kconfig
@@ -4,6 +4,7 @@ config ATH5K
4 select MAC80211_LEDS 4 select MAC80211_LEDS
5 select LEDS_CLASS 5 select LEDS_CLASS
6 select NEW_LEDS 6 select NEW_LEDS
7 select AVERAGE
7 ---help--- 8 ---help---
8 This module adds support for wireless adapters based on 9 This module adds support for wireless adapters based on
9 Atheros 5xxx chipset. 10 Atheros 5xxx chipset.
diff --git a/drivers/net/wireless/ath/ath5k/ani.c b/drivers/net/wireless/ath/ath5k/ani.c
index f1419198a479..db98a853ff35 100644
--- a/drivers/net/wireless/ath/ath5k/ani.c
+++ b/drivers/net/wireless/ath/ath5k/ani.c
@@ -216,7 +216,7 @@ static void
216ath5k_ani_raise_immunity(struct ath5k_hw *ah, struct ath5k_ani_state *as, 216ath5k_ani_raise_immunity(struct ath5k_hw *ah, struct ath5k_ani_state *as,
217 bool ofdm_trigger) 217 bool ofdm_trigger)
218{ 218{
219 int rssi = ah->ah_beacon_rssi_avg.avg; 219 int rssi = ewma_read(&ah->ah_beacon_rssi_avg);
220 220
221 ATH5K_DBG_UNLIMIT(ah->ah_sc, ATH5K_DEBUG_ANI, "raise immunity (%s)", 221 ATH5K_DBG_UNLIMIT(ah->ah_sc, ATH5K_DEBUG_ANI, "raise immunity (%s)",
222 ofdm_trigger ? "ODFM" : "CCK"); 222 ofdm_trigger ? "ODFM" : "CCK");
@@ -301,7 +301,7 @@ ath5k_ani_raise_immunity(struct ath5k_hw *ah, struct ath5k_ani_state *as,
301static void 301static void
302ath5k_ani_lower_immunity(struct ath5k_hw *ah, struct ath5k_ani_state *as) 302ath5k_ani_lower_immunity(struct ath5k_hw *ah, struct ath5k_ani_state *as)
303{ 303{
304 int rssi = ah->ah_beacon_rssi_avg.avg; 304 int rssi = ewma_read(&ah->ah_beacon_rssi_avg);
305 305
306 ATH5K_DBG_UNLIMIT(ah->ah_sc, ATH5K_DEBUG_ANI, "lower immunity"); 306 ATH5K_DBG_UNLIMIT(ah->ah_sc, ATH5K_DEBUG_ANI, "lower immunity");
307 307
diff --git a/drivers/net/wireless/ath/ath5k/ath5k.h b/drivers/net/wireless/ath/ath5k/ath5k.h
index 308b79e1ff08..2718136e4886 100644
--- a/drivers/net/wireless/ath/ath5k/ath5k.h
+++ b/drivers/net/wireless/ath/ath5k/ath5k.h
@@ -25,6 +25,7 @@
25 25
26#include <linux/io.h> 26#include <linux/io.h>
27#include <linux/types.h> 27#include <linux/types.h>
28#include <linux/average.h>
28#include <net/mac80211.h> 29#include <net/mac80211.h>
29 30
30/* RX/TX descriptor hw structs 31/* RX/TX descriptor hw structs
@@ -1102,7 +1103,7 @@ struct ath5k_hw {
1102 struct ath5k_nfcal_hist ah_nfcal_hist; 1103 struct ath5k_nfcal_hist ah_nfcal_hist;
1103 1104
1104 /* average beacon RSSI in our BSS (used by ANI) */ 1105 /* average beacon RSSI in our BSS (used by ANI) */
1105 struct ath5k_avg_val ah_beacon_rssi_avg; 1106 struct ewma ah_beacon_rssi_avg;
1106 1107
1107 /* noise floor from last periodic calibration */ 1108 /* noise floor from last periodic calibration */
1108 s32 ah_noise_floor; 1109 s32 ah_noise_floor;
@@ -1315,27 +1316,4 @@ static inline u32 ath5k_hw_bitswap(u32 val, unsigned int bits)
1315 return retval; 1316 return retval;
1316} 1317}
1317 1318
1318#define AVG_SAMPLES 8
1319#define AVG_FACTOR 1000
1320
1321/**
1322 * ath5k_moving_average - Exponentially weighted moving average
1323 * @avg: average structure
1324 * @val: current value
1325 *
1326 * This implementation make use of a struct ath5k_avg_val to prevent rounding
1327 * errors.
1328 */
1329static inline struct ath5k_avg_val
1330ath5k_moving_average(const struct ath5k_avg_val avg, const int val)
1331{
1332 struct ath5k_avg_val new;
1333 new.avg_weight = avg.avg_weight ?
1334 (((avg.avg_weight * ((AVG_SAMPLES) - 1)) +
1335 (val * (AVG_FACTOR))) / (AVG_SAMPLES)) :
1336 (val * (AVG_FACTOR));
1337 new.avg = new.avg_weight / (AVG_FACTOR);
1338 return new;
1339}
1340
1341#endif 1319#endif
diff --git a/drivers/net/wireless/ath/ath5k/base.c b/drivers/net/wireless/ath/ath5k/base.c
index 13735cc899a5..7f783d9462aa 100644
--- a/drivers/net/wireless/ath/ath5k/base.c
+++ b/drivers/net/wireless/ath/ath5k/base.c
@@ -1301,8 +1301,7 @@ ath5k_update_beacon_rssi(struct ath5k_softc *sc, struct sk_buff *skb, int rssi)
1301 memcmp(mgmt->bssid, common->curbssid, ETH_ALEN) != 0) 1301 memcmp(mgmt->bssid, common->curbssid, ETH_ALEN) != 0)
1302 return; 1302 return;
1303 1303
1304 ah->ah_beacon_rssi_avg = ath5k_moving_average(ah->ah_beacon_rssi_avg, 1304 ewma_add(&ah->ah_beacon_rssi_avg, rssi);
1305 rssi);
1306 1305
1307 /* in IBSS mode we should keep RSSI statistics per neighbour */ 1306 /* in IBSS mode we should keep RSSI statistics per neighbour */
1308 /* le16_to_cpu(mgmt->u.beacon.capab_info) & WLAN_CAPABILITY_IBSS */ 1307 /* le16_to_cpu(mgmt->u.beacon.capab_info) & WLAN_CAPABILITY_IBSS */
@@ -2556,6 +2555,7 @@ ath5k_reset(struct ath5k_softc *sc, struct ieee80211_channel *chan)
2556 ah->ah_cal_next_full = jiffies; 2555 ah->ah_cal_next_full = jiffies;
2557 ah->ah_cal_next_ani = jiffies; 2556 ah->ah_cal_next_ani = jiffies;
2558 ah->ah_cal_next_nf = jiffies; 2557 ah->ah_cal_next_nf = jiffies;
2558 ewma_init(&ah->ah_beacon_rssi_avg, 1000, 8);
2559 2559
2560 /* 2560 /*
2561 * Change channels and update the h/w rate map if we're switching; 2561 * Change channels and update the h/w rate map if we're switching;
diff --git a/drivers/net/wireless/ath/ath5k/debug.c b/drivers/net/wireless/ath/ath5k/debug.c
index 54dcf77e9646..7d785cb60ce0 100644
--- a/drivers/net/wireless/ath/ath5k/debug.c
+++ b/drivers/net/wireless/ath/ath5k/debug.c
@@ -719,7 +719,7 @@ static ssize_t read_file_ani(struct file *file, char __user *user_buf,
719 st->mib_intr); 719 st->mib_intr);
720 len += snprintf(buf+len, sizeof(buf)-len, 720 len += snprintf(buf+len, sizeof(buf)-len,
721 "beacon RSSI average:\t%d\n", 721 "beacon RSSI average:\t%d\n",
722 sc->ah->ah_beacon_rssi_avg.avg); 722 (int)ewma_read(&sc->ah->ah_beacon_rssi_avg));
723 723
724#define CC_PRINT(_struct, _field) \ 724#define CC_PRINT(_struct, _field) \
725 _struct._field, \ 725 _struct._field, \