From: Nev Young When only one packet is sent at the sample rate, its stats are processed but its evidence (a measure of whether the rate has recent stats) stays at zero, because the evidence is updated before the final decision on whether to process the stats for that rate. With zero evidence the rate is skipped as a candidate for best rate, so the rate never increases. To fix, update the evidence only after deciding to process the stats for a rate, so a sampled rate with valid stats is considered for best rate. Signed-off-by: Nev Young Signed-off-by: Lachlan Hodges --- drivers/net/wireless/morsemicro/mm81x/mmrc.c | 38 ++++++++++++-------- 1 file changed, 23 insertions(+), 15 deletions(-) diff --git a/drivers/net/wireless/morsemicro/mm81x/mmrc.c b/drivers/net/wireless/morsemicro/mm81x/mmrc.c index 3f87b50ce391..bad4fec03d86 100644 --- a/drivers/net/wireless/morsemicro/mm81x/mmrc.c +++ b/drivers/net/wireless/morsemicro/mm81x/mmrc.c @@ -1067,6 +1067,13 @@ static void mmrc_process_variation(struct mmrc_table *tb, u16 current_success, } } +static bool enough_stats(struct mmrc_table *tb, u32 min_stats, u32 index, + u32 attempts_for_stats) +{ + return attempts_for_stats >= min_stats || + (attempts_for_stats > 0 && tb->table[index].prob > 0); +} + void mmrc_update(struct mmrc_table *tb) { u32 i; @@ -1078,6 +1085,7 @@ void mmrc_update(struct mmrc_table *tb) u32 success_for_stats; u32 min_stats; u32 throughput; + bool process_this_rate; u32 evidence_sent; tb->cycle_cnt++; @@ -1111,19 +1119,6 @@ void mmrc_update(struct mmrc_table *tb) scaled_ewma = scale * EWMA / 100; - /* - * Only count new packets for evidence if we will process - * them - */ - evidence_sent = - tb->table[i].sent >= min_stats ? tb->table[i].sent : 0; - tb->table[i].evidence = calc_ewma_average( - tb->table[i].evidence, evidence_sent * EVIDENCE_SCALE, - scaled_ewma); - - if (tb->table[i].evidence > EVIDENCE_MAX) - tb->table[i].evidence = EVIDENCE_MAX; - /* Try to use statistics from acknowledged AMPDUs first */ attempts_for_stats = tb->table[i].back_mpdu_success + tb->table[i].back_mpdu_failure; @@ -1142,8 +1137,21 @@ void mmrc_update(struct mmrc_table *tb) success_for_stats = tb->table[i].sent_success; } - if (attempts_for_stats >= min_stats || - (attempts_for_stats > 0 && tb->table[i].prob > 0)) { + process_this_rate = + enough_stats(tb, min_stats, i, attempts_for_stats); + + /* + * Only count new packets for evidence if we will process + * them + */ + evidence_sent = process_this_rate ? tb->table[i].sent : 0; + tb->table[i].evidence = calc_ewma_average( + tb->table[i].evidence, evidence_sent * EVIDENCE_SCALE, + scaled_ewma); + if (tb->table[i].evidence > EVIDENCE_MAX) + tb->table[i].evidence = EVIDENCE_MAX; + + if (process_this_rate) { new_stats = 1; this_success = (100 * success_for_stats) / attempts_for_stats; -- 2.43.0