2020-05-04 15:42:24

by Markus Theil

[permalink] [raw]
Subject: [PATCH 2/2] ath11k: use cumulative survey statistics

ath11k currently reports survey results for the last interval between each
invocation of NL80211_CMD_GET_SURVEY. For concurrent invocations, this
can lead to unexpectedly small results, e.g. when hostapd uses survey
data and iw survey dump is invoked in parallel. Fix this by returning
cumulative results, that don't depend on the last invocation. Other
drivers, e.g. ath9k or mt76 also use this behavior.

Signed-off-by: Markus Theil <[email protected]>
---
drivers/net/wireless/ath/ath11k/wmi.c | 20 ++++++++++----------
1 file changed, 10 insertions(+), 10 deletions(-)

diff --git a/drivers/net/wireless/ath/ath11k/wmi.c b/drivers/net/wireless/ath/ath11k/wmi.c
index c2a972377687..322ddfda5bfd 100644
--- a/drivers/net/wireless/ath/ath11k/wmi.c
+++ b/drivers/net/wireless/ath/ath11k/wmi.c
@@ -5610,16 +5610,16 @@ ath11k_pdev_bss_chan_info_event(struct ath11k_base *ab, struct sk_buff *skb)

survey = &ar->survey[idx];

- survey->noise = bss_ch_info_ev.noise_floor;
- survey->time = div_u64(total, cc_freq_hz);
- survey->time_busy = div_u64(busy, cc_freq_hz);
- survey->time_rx = div_u64(rx_bss, cc_freq_hz);
- survey->time_tx = div_u64(tx, cc_freq_hz);
- survey->filled |= (SURVEY_INFO_NOISE_DBM |
- SURVEY_INFO_TIME |
- SURVEY_INFO_TIME_BUSY |
- SURVEY_INFO_TIME_RX |
- SURVEY_INFO_TIME_TX);
+ survey->noise = bss_ch_info_ev.noise_floor;
+ survey->time += div_u64(total, cc_freq_hz);
+ survey->time_busy += div_u64(busy, cc_freq_hz);
+ survey->time_rx += div_u64(rx_bss, cc_freq_hz);
+ survey->time_tx += div_u64(tx, cc_freq_hz);
+ survey->filled |= (SURVEY_INFO_NOISE_DBM |
+ SURVEY_INFO_TIME |
+ SURVEY_INFO_TIME_BUSY |
+ SURVEY_INFO_TIME_RX |
+ SURVEY_INFO_TIME_TX);
exit:
spin_unlock_bh(&ar->data_lock);
complete(&ar->bss_survey_done);
--
2.26.2


2020-05-04 16:40:03

by Sven Eckelmann

[permalink] [raw]
Subject: Re: [PATCH 2/2] ath11k: use cumulative survey statistics

On Monday, 4 May 2020 17:41:22 CEST Markus Theil wrote:
[...]
> diff --git a/drivers/net/wireless/ath/ath11k/wmi.c b/drivers/net/wireless/ath/ath11k/wmi.c
> index c2a972377687..322ddfda5bfd 100644
> --- a/drivers/net/wireless/ath/ath11k/wmi.c
> +++ b/drivers/net/wireless/ath/ath11k/wmi.c
> @@ -5610,16 +5610,16 @@ ath11k_pdev_bss_chan_info_event(struct ath11k_base *ab, struct sk_buff *skb)
[...]

What about the survey modifying code in ath11k_chan_info_event?

Kind regards,
Sven


Attachments:
signature.asc (849.00 B)
This is a digitally signed message part.

2020-05-04 23:43:05

by Rajkumar Manoharan

[permalink] [raw]
Subject: Re: [PATCH 2/2] ath11k: use cumulative survey statistics

On 2020-05-04 08:41, Markus Theil wrote:
> ath11k currently reports survey results for the last interval between
> each
> invocation of NL80211_CMD_GET_SURVEY. For concurrent invocations, this
> can lead to unexpectedly small results, e.g. when hostapd uses survey
> data and iw survey dump is invoked in parallel. Fix this by returning
> cumulative results, that don't depend on the last invocation. Other
> drivers, e.g. ath9k or mt76 also use this behavior.
>
> Signed-off-by: Markus Theil <[email protected]>
> ---
> drivers/net/wireless/ath/ath11k/wmi.c | 20 ++++++++++----------
> 1 file changed, 10 insertions(+), 10 deletions(-)
>
> diff --git a/drivers/net/wireless/ath/ath11k/wmi.c
> b/drivers/net/wireless/ath/ath11k/wmi.c
> index c2a972377687..322ddfda5bfd 100644
> --- a/drivers/net/wireless/ath/ath11k/wmi.c
> +++ b/drivers/net/wireless/ath/ath11k/wmi.c
> @@ -5610,16 +5610,16 @@ ath11k_pdev_bss_chan_info_event(struct
> ath11k_base *ab, struct sk_buff *skb)
>
> survey = &ar->survey[idx];
>
> - survey->noise = bss_ch_info_ev.noise_floor;
> - survey->time = div_u64(total, cc_freq_hz);
> - survey->time_busy = div_u64(busy, cc_freq_hz);
> - survey->time_rx = div_u64(rx_bss, cc_freq_hz);
> - survey->time_tx = div_u64(tx, cc_freq_hz);
> - survey->filled |= (SURVEY_INFO_NOISE_DBM |
> - SURVEY_INFO_TIME |
> - SURVEY_INFO_TIME_BUSY |
> - SURVEY_INFO_TIME_RX |
> - SURVEY_INFO_TIME_TX);
> + survey->noise = bss_ch_info_ev.noise_floor;
> + survey->time += div_u64(total, cc_freq_hz);
> + survey->time_busy += div_u64(busy, cc_freq_hz);
> + survey->time_rx += div_u64(rx_bss, cc_freq_hz);
> + survey->time_tx += div_u64(tx, cc_freq_hz);
> + survey->filled |= (SURVEY_INFO_NOISE_DBM |
> + SURVEY_INFO_TIME |
> + SURVEY_INFO_TIME_BUSY |
> + SURVEY_INFO_TIME_RX |
> + SURVEY_INFO_TIME_TX);

Markus,

It depends on type of survey request is given to firmware. In ath11k,
firmware reports
accumulated values. So the above addition is wrong and report double
value. Have you
tested this change?

-Rajkumar

2020-05-05 06:53:59

by Markus Theil

[permalink] [raw]
Subject: Re: [PATCH 2/2] ath11k: use cumulative survey statistics

Am 05.05.2020 um 01:37 schrieb Rajkumar Manoharan:
> On 2020-05-04 08:41, Markus Theil wrote:
>> ath11k currently reports survey results for the last interval between
>> each
>> invocation of NL80211_CMD_GET_SURVEY. For concurrent invocations, this
>> can lead to unexpectedly small results, e.g. when hostapd uses survey
>> data and iw survey dump is invoked in parallel. Fix this by returning
>> cumulative results, that don't depend on the last invocation. Other
>> drivers, e.g. ath9k or mt76 also use this behavior.
>>
>> Signed-off-by: Markus Theil <[email protected]>
>> ---
>>  drivers/net/wireless/ath/ath11k/wmi.c | 20 ++++++++++----------
>>  1 file changed, 10 insertions(+), 10 deletions(-)
>>
>> diff --git a/drivers/net/wireless/ath/ath11k/wmi.c
>> b/drivers/net/wireless/ath/ath11k/wmi.c
>> index c2a972377687..322ddfda5bfd 100644
>> --- a/drivers/net/wireless/ath/ath11k/wmi.c
>> +++ b/drivers/net/wireless/ath/ath11k/wmi.c
>> @@ -5610,16 +5610,16 @@ ath11k_pdev_bss_chan_info_event(struct
>> ath11k_base *ab, struct sk_buff *skb)
>>
>>      survey = &ar->survey[idx];
>>
>> -    survey->noise     = bss_ch_info_ev.noise_floor;
>> -    survey->time      = div_u64(total, cc_freq_hz);
>> -    survey->time_busy = div_u64(busy, cc_freq_hz);
>> -    survey->time_rx   = div_u64(rx_bss, cc_freq_hz);
>> -    survey->time_tx   = div_u64(tx, cc_freq_hz);
>> -    survey->filled   |= (SURVEY_INFO_NOISE_DBM |
>> -                 SURVEY_INFO_TIME |
>> -                 SURVEY_INFO_TIME_BUSY |
>> -                 SURVEY_INFO_TIME_RX |
>> -                 SURVEY_INFO_TIME_TX);
>> +    survey->noise      = bss_ch_info_ev.noise_floor;
>> +    survey->time      += div_u64(total, cc_freq_hz);
>> +    survey->time_busy += div_u64(busy, cc_freq_hz);
>> +    survey->time_rx   += div_u64(rx_bss, cc_freq_hz);
>> +    survey->time_tx   += div_u64(tx, cc_freq_hz);
>> +    survey->filled    |= (SURVEY_INFO_NOISE_DBM |
>> +                  SURVEY_INFO_TIME |
>> +                  SURVEY_INFO_TIME_BUSY |
>> +                  SURVEY_INFO_TIME_RX |
>> +                  SURVEY_INFO_TIME_TX);
>
> Markus,
>
> It depends on type of survey request is given to firmware. In ath11k,
> firmware reports
> accumulated values. So the above addition is wrong and report double
> value. Have you
> tested this change?
>
> -Rajkumar
Ok, so please drop both of my patches. My assumptions were incomplete
and too humble. I just assumed, ath10k and ath11k both use incremental
surveys.

2020-05-05 17:36:00

by Rajkumar Manoharan

[permalink] [raw]
Subject: Re: [PATCH 2/2] ath11k: use cumulative survey statistics

On 2020-05-04 23:53, Markus Theil wrote:
> Am 05.05.2020 um 01:37 schrieb Rajkumar Manoharan:
>> On 2020-05-04 08:41, Markus Theil wrote:
>>> ath11k currently reports survey results for the last interval between
>>> each
>>> invocation of NL80211_CMD_GET_SURVEY. For concurrent invocations,
>>> this
>>> can lead to unexpectedly small results, e.g. when hostapd uses survey
>>> data and iw survey dump is invoked in parallel. Fix this by returning
>>> cumulative results, that don't depend on the last invocation. Other
>>> drivers, e.g. ath9k or mt76 also use this behavior.
>>>
[...]
>> Markus,
>>
>> It depends on type of survey request is given to firmware. In ath11k,
>> firmware reports
>> accumulated values. So the above addition is wrong and report double
>> value. Have you
>> tested this change?
>>
>> -Rajkumar
> Ok, so please drop both of my patches. My assumptions were incomplete
> and too humble. I just assumed, ath10k and ath11k both use incremental
> surveys.
>
Markus,

The ath10k driver still counts survey stats incrementally. But it should
be handled by sending
appropriate survey request_type to firmware.

-Rajkumar