[PATCH 3/3] wifi: ath11k: Populate the signal average field properly

From: Youghandhar Chintala
Date: Tue Apr 04 2023 - 03:23:41 EST


Currently on WCN6750, we are seeing an issue where signal average field
value in station dump is incorrect. Signal average field is populated
without checking for dB to dBm conversion. For WCN6750 devices, the
signal average value is already in dBm units, so no need to convert it
again.

If signal average is valid, then fill it based on dB to dBm conversion
condition to fix this.

Tested-on: WCN6750 hw1.0 AHB WLAN.MSL.1.0.1-00887-QCAMSLSWPLZ-1

Signed-off-by: Youghandhar Chintala <quic_youghand@xxxxxxxxxxx>
---
drivers/net/wireless/ath/ath11k/mac.c | 11 +++++++----
1 file changed, 7 insertions(+), 4 deletions(-)

diff --git a/drivers/net/wireless/ath/ath11k/mac.c b/drivers/net/wireless/ath/ath11k/mac.c
index cad832e0e6b8..531a881d8623 100644
--- a/drivers/net/wireless/ath/ath11k/mac.c
+++ b/drivers/net/wireless/ath/ath11k/mac.c
@@ -8278,7 +8278,7 @@ static void ath11k_mac_op_sta_statistics(struct ieee80211_hw *hw,
{
struct ath11k_sta *arsta = (struct ath11k_sta *)sta->drv_priv;
struct ath11k *ar = arsta->arvif->ar;
- s8 signal;
+ s8 signal, signal_avg;
bool db2dbm = test_bit(WMI_TLV_SERVICE_HW_DB2DBM_CONVERSION_SUPPORT,
ar->ab->wmi_ab.svc_map);

@@ -8330,9 +8330,12 @@ static void ath11k_mac_op_sta_statistics(struct ieee80211_hw *hw,
sinfo->filled |= BIT_ULL(NL80211_STA_INFO_SIGNAL);
}

- sinfo->signal_avg = ewma_avg_rssi_read(&arsta->avg_rssi) +
- ATH11K_DEFAULT_NOISE_FLOOR;
- sinfo->filled |= BIT_ULL(NL80211_STA_INFO_SIGNAL_AVG);
+ signal_avg = ewma_avg_rssi_read(&arsta->avg_rssi);
+ if (signal_avg) {
+ sinfo->signal_avg = db2dbm ? signal_avg : signal_avg + ATH11K_DEFAULT_NOISE_FLOOR;
+ sinfo->filled |= BIT_ULL(NL80211_STA_INFO_SIGNAL_AVG);
+ }
+
}

#if IS_ENABLED(CONFIG_IPV6)
--
2.38.0