diff mbox series

wifi: mac80211: Initialize EWMA fail avg to 1

Message ID 20230317144432.10477-1-quic_karm@quicinc.com (mailing list archive)
State Changes Requested
Delegated to: Johannes Berg
Headers show
Series wifi: mac80211: Initialize EWMA fail avg to 1 | expand

Commit Message

Karthik M March 17, 2023, 2:44 p.m. UTC
If the average value has been rounded to 0 (success),
reset it to the smallest nonzero value (similarly to the initialization) to
avoid a case where a single failure would result in an average value
that goes beyond the threshold value of 95.

Signed-off-by: Tamizh Chelvam Raja <quic_tamizhr@quicinc.com>
Signed-off-by: Karthik M <quic_karm@quicinc.com>
---
 net/mac80211/mesh_hwmp.c | 11 +++++++++++
 1 file changed, 11 insertions(+)

Comments

Johannes Berg March 30, 2023, 10:06 a.m. UTC | #1
On Fri, 2023-03-17 at 20:14 +0530, Karthik M wrote:
> If the average value has been rounded to 0 (success),
> reset it to the smallest nonzero value (similarly to the initialization) to
> avoid a case where a single failure would result in an average value
> that goes beyond the threshold value of 95.

What does 95 have to do with it?

Also the whole commit message doesn't even mention mesh a single time.


> Signed-off-by: Tamizh Chelvam Raja <quic_tamizhr@quicinc.com>
> Signed-off-by: Karthik M <quic_karm@quicinc.com>
> ---
>  net/mac80211/mesh_hwmp.c | 11 +++++++++++
>  1 file changed, 11 insertions(+)
> 
> diff --git a/net/mac80211/mesh_hwmp.c b/net/mac80211/mesh_hwmp.c
> index 9b1ce7c3925a..e9fcaff9cc7e 100644
> --- a/net/mac80211/mesh_hwmp.c
> +++ b/net/mac80211/mesh_hwmp.c
> @@ -298,10 +298,21 @@ void ieee80211s_update_metric(struct ieee80211_local *local,
>  {
>  	struct ieee80211_tx_info *txinfo = st->info;
>  	int failed;
> +	u32 fail_avg;
>  	struct rate_info rinfo;
>  
>  	failed = !(txinfo->flags & IEEE80211_TX_STAT_ACK);
>  
> +	fail_avg = ewma_mesh_fail_avg_read(&sta->mesh->fail_avg);
> +	if (!fail_avg) {
> +		/* If the average value has been rounded to 0 (success), 
> +		 * reset it to the smallest nonzero value (similarly to 
> +		 * the initialization) to avoid a case where a single 
> +		 * failure would result in an average value that goes 
> +		 * beyond the threshold value of 95 */

Comment style, trailing whitespace ... please run at least some kind of
checkpatch yourself.

johannes
diff mbox series

Patch

diff --git a/net/mac80211/mesh_hwmp.c b/net/mac80211/mesh_hwmp.c
index 9b1ce7c3925a..e9fcaff9cc7e 100644
--- a/net/mac80211/mesh_hwmp.c
+++ b/net/mac80211/mesh_hwmp.c
@@ -298,10 +298,21 @@  void ieee80211s_update_metric(struct ieee80211_local *local,
 {
 	struct ieee80211_tx_info *txinfo = st->info;
 	int failed;
+	u32 fail_avg;
 	struct rate_info rinfo;
 
 	failed = !(txinfo->flags & IEEE80211_TX_STAT_ACK);
 
+	fail_avg = ewma_mesh_fail_avg_read(&sta->mesh->fail_avg);
+	if (!fail_avg) {
+		/* If the average value has been rounded to 0 (success), 
+		 * reset it to the smallest nonzero value (similarly to 
+		 * the initialization) to avoid a case where a single 
+		 * failure would result in an average value that goes 
+		 * beyond the threshold value of 95 */
+		ewma_mesh_fail_avg_add(&sta->mesh->fail_avg, 1);
+	}
+
 	/* moving average, scaled to 100.
 	 * feed failure as 100 and success as 0
 	 */