From 282f3a5ce1dcef8de511599ae3571404c9c95afb Mon Sep 17 00:00:00 2001 From: Ruben Columbus Date: Thu, 24 Oct 2019 18:25:02 -0700 Subject: [PATCH] qcacmn: RSSI averaging function accuracy improvement on function for avergaging rssi accuracy Change-Id: I4fb231aacb2ed76a2e5e1b5843a8b095e9901406 --- dp/inc/cdp_txrx_stats_struct.h | 11 +++++++++++ dp/wifi3.0/dp_rx_mon_status.c | 8 ++++---- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/dp/inc/cdp_txrx_stats_struct.h b/dp/inc/cdp_txrx_stats_struct.h index 279b70c94a..31fbe75085 100644 --- a/dp/inc/cdp_txrx_stats_struct.h +++ b/dp/inc/cdp_txrx_stats_struct.h @@ -116,6 +116,17 @@ #define INVALID_RSSI 255 +#define CDP_RSSI_MULTIPLIER BIT(8) +#define CDP_RSSI_MUL(x, mul) ((x) * (mul)) +#define CDP_RSSI_RND(x, mul) ((((x) % (mul)) >= ((mul) / 2)) ?\ + ((x) + ((mul) - 1)) / (mul) : (x) / (mul)) + +#define CDP_RSSI_OUT(x) (CDP_RSSI_RND((x), CDP_RSSI_MULTIPLIER)) +#define CDP_RSSI_IN(x) (CDP_RSSI_MUL((x), CDP_RSSI_MULTIPLIER)) +#define CDP_RSSI_AVG(x, y) ((((x) << 2) + (y) - (x)) >> 2) + +#define CDP_RSSI_UPDATE_AVG(x, y) x = CDP_RSSI_AVG((x), CDP_RSSI_IN((y))) + /*Max SU EVM count */ #define DP_RX_MAX_SU_EVM_COUNT 32 diff --git a/dp/wifi3.0/dp_rx_mon_status.c b/dp/wifi3.0/dp_rx_mon_status.c index e23f4694b4..fc98f13c96 100644 --- a/dp/wifi3.0/dp_rx_mon_status.c +++ b/dp/wifi3.0/dp_rx_mon_status.c @@ -506,11 +506,11 @@ static void dp_rx_stats_update(struct dp_pdev *pdev, DP_STATS_UPD(peer, rx.rssi, (ppdu->rssi + pkt_bw_offset)); if (peer->stats.rx.avg_rssi == INVALID_RSSI) - peer->stats.rx.avg_rssi = ppdu->rssi; - else peer->stats.rx.avg_rssi = - DP_GET_AVG_RSSI(peer->stats.rx.avg_rssi, - ppdu->rssi); + CDP_RSSI_IN(peer->stats.rx.rssi); + else + CDP_RSSI_UPDATE_AVG(peer->stats.rx.avg_rssi, + peer->stats.rx.rssi); if ((preamble == DOT11_A) || (preamble == DOT11_B)) nss = 1;