brcmfmac: correctly report average RSSI in station info
[ Upstream commit 9a1590934d9a02e570636432b93052c0c035f31f ]
The rx_lastpkt_rssi field provided by the firmware is suitable for
NL80211_STA_INFO_{SIGNAL,CHAIN_SIGNAL}, while the rssi field is an
average. Fix up the assignments and set the correct STA_INFO bits. This
lets userspace know that the average RSSI is part of the station info.
Fixes: cae355dc90
("brcmfmac: Add RSSI information to get_station.")
Signed-off-by: Alvin Šipraga <alsi@bang-olufsen.dk>
Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
Link: https://lore.kernel.org/r/20210506132010.3964484-2-alsi@bang-olufsen.dk
Signed-off-by: Sasha Levin <sashal@kernel.org>
This commit is contained in:

committed by
Greg Kroah-Hartman

parent
db4de88d43
commit
5b8d0b0727
@@ -2767,8 +2767,9 @@ brcmf_cfg80211_get_station(struct wiphy *wiphy, struct net_device *ndev,
|
|||||||
struct brcmf_sta_info_le sta_info_le;
|
struct brcmf_sta_info_le sta_info_le;
|
||||||
u32 sta_flags;
|
u32 sta_flags;
|
||||||
u32 is_tdls_peer;
|
u32 is_tdls_peer;
|
||||||
s32 total_rssi;
|
s32 total_rssi_avg = 0;
|
||||||
s32 count_rssi;
|
s32 total_rssi = 0;
|
||||||
|
s32 count_rssi = 0;
|
||||||
int rssi;
|
int rssi;
|
||||||
u32 i;
|
u32 i;
|
||||||
|
|
||||||
@@ -2834,24 +2835,27 @@ brcmf_cfg80211_get_station(struct wiphy *wiphy, struct net_device *ndev,
|
|||||||
sinfo->filled |= BIT_ULL(NL80211_STA_INFO_RX_BYTES);
|
sinfo->filled |= BIT_ULL(NL80211_STA_INFO_RX_BYTES);
|
||||||
sinfo->rx_bytes = le64_to_cpu(sta_info_le.rx_tot_bytes);
|
sinfo->rx_bytes = le64_to_cpu(sta_info_le.rx_tot_bytes);
|
||||||
}
|
}
|
||||||
total_rssi = 0;
|
|
||||||
count_rssi = 0;
|
|
||||||
for (i = 0; i < BRCMF_ANT_MAX; i++) {
|
for (i = 0; i < BRCMF_ANT_MAX; i++) {
|
||||||
if (sta_info_le.rssi[i]) {
|
if (sta_info_le.rssi[i] == 0 ||
|
||||||
sinfo->chains |= BIT(count_rssi);
|
sta_info_le.rx_lastpkt_rssi[i] == 0)
|
||||||
sinfo->chain_signal_avg[count_rssi] =
|
continue;
|
||||||
sta_info_le.rssi[i];
|
sinfo->chains |= BIT(count_rssi);
|
||||||
sinfo->chain_signal[count_rssi] =
|
sinfo->chain_signal[count_rssi] =
|
||||||
sta_info_le.rssi[i];
|
sta_info_le.rx_lastpkt_rssi[i];
|
||||||
total_rssi += sta_info_le.rssi[i];
|
sinfo->chain_signal_avg[count_rssi] =
|
||||||
count_rssi++;
|
sta_info_le.rssi[i];
|
||||||
}
|
total_rssi += sta_info_le.rx_lastpkt_rssi[i];
|
||||||
|
total_rssi_avg += sta_info_le.rssi[i];
|
||||||
|
count_rssi++;
|
||||||
}
|
}
|
||||||
if (count_rssi) {
|
if (count_rssi) {
|
||||||
sinfo->filled |= BIT_ULL(NL80211_STA_INFO_CHAIN_SIGNAL);
|
|
||||||
sinfo->filled |= BIT_ULL(NL80211_STA_INFO_SIGNAL);
|
sinfo->filled |= BIT_ULL(NL80211_STA_INFO_SIGNAL);
|
||||||
total_rssi /= count_rssi;
|
sinfo->filled |= BIT_ULL(NL80211_STA_INFO_SIGNAL_AVG);
|
||||||
sinfo->signal = total_rssi;
|
sinfo->filled |= BIT_ULL(NL80211_STA_INFO_CHAIN_SIGNAL);
|
||||||
|
sinfo->filled |=
|
||||||
|
BIT_ULL(NL80211_STA_INFO_CHAIN_SIGNAL_AVG);
|
||||||
|
sinfo->signal = total_rssi / count_rssi;
|
||||||
|
sinfo->signal_avg = total_rssi_avg / count_rssi;
|
||||||
} else if (test_bit(BRCMF_VIF_STATUS_CONNECTED,
|
} else if (test_bit(BRCMF_VIF_STATUS_CONNECTED,
|
||||||
&ifp->vif->sme_state)) {
|
&ifp->vif->sme_state)) {
|
||||||
memset(&scb_val, 0, sizeof(scb_val));
|
memset(&scb_val, 0, sizeof(scb_val));
|
||||||
|
Reference in New Issue
Block a user