rt2x00: Fix rounding errors in RSSI average calculation

Small changes in signal level was not detected up by the
MOVING_AVERAGE() due to a rounding error, using 'int' type.

rt2x00lib_antenna_diversity_eval:
rssi:	  -62 -62 -62 -62 -62 -62 -62 -62 -62 -62 -62 -62 -62 -62 -62
rssi_avg: -57 -57 -57 -57 -57 -57 -57 -57 -57 -57 -57 -57 -57 -57 -57

The signal level reported back could be significantly (5dBm)
different from the actual value. A level +3dBm is the same as
double the AP output power.

Signed-off-by: Lars Ericsson <Lars_Ericsson@telia.com>
Signed-off-by: Ivo van Doorn <IvDoorn@gmail.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
This commit is contained in:
Lars Ericsson
2009-08-08 23:54:51 +02:00
committed by John W. Linville
parent 193df183b1
commit 66679a65ef
2 changed files with 52 additions and 28 deletions

View File

@@ -133,6 +133,17 @@
#define SHORT_EIFS ( SIFS + SHORT_DIFS + \
GET_DURATION(IEEE80211_HEADER + ACK_SIZE, 10) )
/*
* Structure for average calculation
* The avg field contains the actual average value,
* but avg_weight is internally used during calculations
* to prevent rounding errors.
*/
struct avg_val {
int avg;
int avg_weight;
};
/*
* Chipset identification
* The chipset on the device is composed of a RT and RF chip.
@@ -256,7 +267,7 @@ struct link_ant {
* Similar to the avg_rssi in the link_qual structure
* this value is updated by using the walking average.
*/
int rssi_ant;
struct avg_val rssi_ant;
};
/*
@@ -285,7 +296,7 @@ struct link {
/*
* Currently active average RSSI value
*/
int avg_rssi;
struct avg_val avg_rssi;
/*
* Currently precalculated percentages of successful