All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/2] brcmfmac: fix setting of station info chains bitmask
@ 2021-05-06 13:20 Alvin Šipraga
  2021-05-06 13:20 ` [PATCH 2/2] brcmfmac: correctly report average RSSI in station info Alvin Šipraga
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Alvin Šipraga @ 2021-05-06 13:20 UTC (permalink / raw)
  To: Arend van Spriel, Franky Lin, Hante Meuleman, Chi-hsien Lin,
	Wright Feng, Chung-hsien Hsu, Kalle Valo
  Cc: linux-wireless, brcm80211-dev-list.pdl, SHA-cyfmac-dev-list,
	Alvin Šipraga

The sinfo->chains field is a bitmask for filled values in chain_signal
and chain_signal_avg, not a count. Treat it as such so that the driver
can properly report per-chain RSSI information.

Before (MIMO mode):

  $ iw dev wlan0 station dump
      ...
      signal: -51 [-51] dBm

After (MIMO mode):

  $ iw dev wlan0 station dump
      ...
      signal: -53 [-53, -54] dBm

Signed-off-by: Alvin Šipraga <alsi@bang-olufsen.dk>
Fixes: cae355dc90db ("brcmfmac: Add RSSI information to get_station.")
---
 drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c
index f4405d7861b6..afa75cb83221 100644
--- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c
+++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c
@@ -2838,6 +2838,7 @@ brcmf_cfg80211_get_station(struct wiphy *wiphy, struct net_device *ndev,
 		count_rssi = 0;
 		for (i = 0; i < BRCMF_ANT_MAX; i++) {
 			if (sta_info_le.rssi[i]) {
+				sinfo->chains |= BIT(count_rssi);
 				sinfo->chain_signal_avg[count_rssi] =
 					sta_info_le.rssi[i];
 				sinfo->chain_signal[count_rssi] =
@@ -2848,8 +2849,6 @@ brcmf_cfg80211_get_station(struct wiphy *wiphy, struct net_device *ndev,
 		}
 		if (count_rssi) {
 			sinfo->filled |= BIT_ULL(NL80211_STA_INFO_CHAIN_SIGNAL);
-			sinfo->chains = count_rssi;
-
 			sinfo->filled |= BIT_ULL(NL80211_STA_INFO_SIGNAL);
 			total_rssi /= count_rssi;
 			sinfo->signal = total_rssi;
-- 
2.31.1

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH 2/2] brcmfmac: correctly report average RSSI in station info
  2021-05-06 13:20 [PATCH 1/2] brcmfmac: fix setting of station info chains bitmask Alvin Šipraga
@ 2021-05-06 13:20 ` Alvin Šipraga
  2021-06-14 13:21 ` [PATCH 1/2] brcmfmac: fix setting of station info chains bitmask Alvin Šipraga
  2021-06-15 10:36 ` [1/2] " Kalle Valo
  2 siblings, 0 replies; 6+ messages in thread
From: Alvin Šipraga @ 2021-05-06 13:20 UTC (permalink / raw)
  To: Arend van Spriel, Franky Lin, Hante Meuleman, Chi-hsien Lin,
	Wright Feng, Chung-hsien Hsu, Kalle Valo
  Cc: linux-wireless, brcm80211-dev-list.pdl, SHA-cyfmac-dev-list,
	Alvin Šipraga

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.

Signed-off-by: Alvin Šipraga <alsi@bang-olufsen.dk>
Fixes: cae355dc90db ("brcmfmac: Add RSSI information to get_station.")
---
 .../broadcom/brcm80211/brcmfmac/cfg80211.c    | 36 ++++++++++---------
 1 file changed, 20 insertions(+), 16 deletions(-)

diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c
index afa75cb83221..d8822a01d277 100644
--- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c
+++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c
@@ -2767,8 +2767,9 @@ brcmf_cfg80211_get_station(struct wiphy *wiphy, struct net_device *ndev,
 	struct brcmf_sta_info_le sta_info_le;
 	u32 sta_flags;
 	u32 is_tdls_peer;
-	s32 total_rssi;
-	s32 count_rssi;
+	s32 total_rssi_avg = 0;
+	s32 total_rssi = 0;
+	s32 count_rssi = 0;
 	int rssi;
 	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->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++) {
-			if (sta_info_le.rssi[i]) {
-				sinfo->chains |= BIT(count_rssi);
-				sinfo->chain_signal_avg[count_rssi] =
-					sta_info_le.rssi[i];
-				sinfo->chain_signal[count_rssi] =
-					sta_info_le.rssi[i];
-				total_rssi += sta_info_le.rssi[i];
-				count_rssi++;
-			}
+			if (sta_info_le.rssi[i] == 0 ||
+			    sta_info_le.rx_lastpkt_rssi[i] == 0)
+				continue;
+			sinfo->chains |= BIT(count_rssi);
+			sinfo->chain_signal[count_rssi] =
+				sta_info_le.rx_lastpkt_rssi[i];
+			sinfo->chain_signal_avg[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) {
-			sinfo->filled |= BIT_ULL(NL80211_STA_INFO_CHAIN_SIGNAL);
 			sinfo->filled |= BIT_ULL(NL80211_STA_INFO_SIGNAL);
-			total_rssi /= count_rssi;
-			sinfo->signal = total_rssi;
+			sinfo->filled |= BIT_ULL(NL80211_STA_INFO_SIGNAL_AVG);
+			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,
 			&ifp->vif->sme_state)) {
 			memset(&scb_val, 0, sizeof(scb_val));
-- 
2.31.1

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH 1/2] brcmfmac: fix setting of station info chains bitmask
  2021-05-06 13:20 [PATCH 1/2] brcmfmac: fix setting of station info chains bitmask Alvin Šipraga
  2021-05-06 13:20 ` [PATCH 2/2] brcmfmac: correctly report average RSSI in station info Alvin Šipraga
@ 2021-06-14 13:21 ` Alvin Šipraga
  2021-06-14 14:33   ` Kalle Valo
  2021-06-15 10:36 ` [1/2] " Kalle Valo
  2 siblings, 1 reply; 6+ messages in thread
From: Alvin Šipraga @ 2021-06-14 13:21 UTC (permalink / raw)
  To: Arend van Spriel, Franky Lin, Hante Meuleman, Chi-hsien Lin,
	Wright Feng, Chung-hsien Hsu, Kalle Valo
  Cc: linux-wireless, brcm80211-dev-list.pdl, SHA-cyfmac-dev-list

Hello,

On 5/6/21 3:20 PM, Alvin Šipraga wrote:
> The sinfo->chains field is a bitmask for filled values in chain_signal
> and chain_signal_avg, not a count. Treat it as such so that the driver
> can properly report per-chain RSSI information.
> 

<snip>

This is a gentle ping to see if these two patches got lost. I was told 
on another mailing list recently that mail sent from my work address is 
finding its way into peoples' junk folders.

I will resend the patches in the near future if I don't see any response 
here.

Thanks,
Alvin

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH 1/2] brcmfmac: fix setting of station info chains bitmask
  2021-06-14 13:21 ` [PATCH 1/2] brcmfmac: fix setting of station info chains bitmask Alvin Šipraga
@ 2021-06-14 14:33   ` Kalle Valo
  2021-06-14 17:18     ` Alvin Šipraga
  0 siblings, 1 reply; 6+ messages in thread
From: Kalle Valo @ 2021-06-14 14:33 UTC (permalink / raw)
  To: Alvin Šipraga
  Cc: Arend van Spriel, Franky Lin, Hante Meuleman, Chi-hsien Lin,
	Wright Feng, Chung-hsien Hsu, linux-wireless,
	brcm80211-dev-list.pdl, SHA-cyfmac-dev-list

Alvin Šipraga <alvin@pqrs.dk> writes:

> Hello,
>
> On 5/6/21 3:20 PM, Alvin Šipraga wrote:
>> The sinfo->chains field is a bitmask for filled values in chain_signal
>> and chain_signal_avg, not a count. Treat it as such so that the driver
>> can properly report per-chain RSSI information.
>>
>
> <snip>
>
> This is a gentle ping to see if these two patches got lost. I was told
> on another mailing list recently that mail sent from my work address
> is finding its way into peoples' junk folders.
>
> I will resend the patches in the near future if I don't see any
> response here.

I just have been busy and heavily backlogged. The patches are in
patchwork, so no need to resend:

https://patchwork.kernel.org/project/linux-wireless/list/?series=477877&state=*

-- 
https://patchwork.kernel.org/project/linux-wireless/list/

https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH 1/2] brcmfmac: fix setting of station info chains bitmask
  2021-06-14 14:33   ` Kalle Valo
@ 2021-06-14 17:18     ` Alvin Šipraga
  0 siblings, 0 replies; 6+ messages in thread
From: Alvin Šipraga @ 2021-06-14 17:18 UTC (permalink / raw)
  To: Kalle Valo, Alvin Šipraga
  Cc: Arend van Spriel, Franky Lin, Hante Meuleman, Chi-hsien Lin,
	Wright Feng, Chung-hsien Hsu, linux-wireless,
	brcm80211-dev-list.pdl, SHA-cyfmac-dev-list

Hi Kalle,

On 6/14/21 4:33 PM, Kalle Valo wrote:
> Alvin Šipraga <alvin@pqrs.dk> writes:
> 
>> Hello,
>>
>> On 5/6/21 3:20 PM, Alvin Šipraga wrote:
>>> The sinfo->chains field is a bitmask for filled values in chain_signal
>>> and chain_signal_avg, not a count. Treat it as such so that the driver
>>> can properly report per-chain RSSI information.
>>>
>>
>> <snip>
>>
>> This is a gentle ping to see if these two patches got lost. I was told
>> on another mailing list recently that mail sent from my work address
>> is finding its way into peoples' junk folders.
>>
>> I will resend the patches in the near future if I don't see any
>> response here.
> 
> I just have been busy and heavily backlogged. The patches are in
> patchwork, so no need to resend:
> 
> https://patchwork.kernel.org/project/linux-wireless/list/?series=477877&state=*>> 

Great - thanks for the quick reply. I will not resend.

Kind regards,
Alvin

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [1/2] brcmfmac: fix setting of station info chains bitmask
  2021-05-06 13:20 [PATCH 1/2] brcmfmac: fix setting of station info chains bitmask Alvin Šipraga
  2021-05-06 13:20 ` [PATCH 2/2] brcmfmac: correctly report average RSSI in station info Alvin Šipraga
  2021-06-14 13:21 ` [PATCH 1/2] brcmfmac: fix setting of station info chains bitmask Alvin Šipraga
@ 2021-06-15 10:36 ` Kalle Valo
  2 siblings, 0 replies; 6+ messages in thread
From: Kalle Valo @ 2021-06-15 10:36 UTC (permalink / raw)
  To: Alvin Šipraga
  Cc: Arend van Spriel, Franky Lin, Hante Meuleman, Chi-hsien Lin,
	Wright Feng, Chung-hsien Hsu, linux-wireless,
	brcm80211-dev-list.pdl, SHA-cyfmac-dev-list, Alvin Šipraga

Alvin Šipraga <ALSI@bang-olufsen.dk> wrote:

> The sinfo->chains field is a bitmask for filled values in chain_signal
> and chain_signal_avg, not a count. Treat it as such so that the driver
> can properly report per-chain RSSI information.
> 
> Before (MIMO mode):
> 
>   $ iw dev wlan0 station dump
>       ...
>       signal: -51 [-51] dBm
> 
> After (MIMO mode):
> 
>   $ iw dev wlan0 station dump
>       ...
>       signal: -53 [-53, -54] dBm
> 
> Fixes: cae355dc90db ("brcmfmac: Add RSSI information to get_station.")
> Signed-off-by: Alvin Šipraga <alsi@bang-olufsen.dk>

2 patches applied to wireless-drivers-next.git, thanks.

feb456437621 brcmfmac: fix setting of station info chains bitmask
9a1590934d9a brcmfmac: correctly report average RSSI in station info

-- 
https://patchwork.kernel.org/project/linux-wireless/patch/20210506132010.3964484-1-alsi@bang-olufsen.dk/

https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2021-06-15 10:37 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-05-06 13:20 [PATCH 1/2] brcmfmac: fix setting of station info chains bitmask Alvin Šipraga
2021-05-06 13:20 ` [PATCH 2/2] brcmfmac: correctly report average RSSI in station info Alvin Šipraga
2021-06-14 13:21 ` [PATCH 1/2] brcmfmac: fix setting of station info chains bitmask Alvin Šipraga
2021-06-14 14:33   ` Kalle Valo
2021-06-14 17:18     ` Alvin Šipraga
2021-06-15 10:36 ` [1/2] " Kalle Valo

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.