From acbbdd0bb6b6738034d2f30ab34f650969dc5c88 Mon Sep 17 00:00:00 2001 From: proski Date: Sat, 19 Sep 2009 04:03:53 +0000 Subject: [PATCH] Fix contention window calculation in sample and minstrel code The contention window is supposed to be a power of two minus one, i.e. 15, 31, 63, 127... Due to a wrong formula, the actual sequence was 15, 32, 66, 134... Bug reported by Dan Halperin git-svn-id: http://madwifi-project.org/svn/madwifi/trunk@4097 0192ed92-7a03-0410-a25b-9323aeb14dbd --- ath_rate/minstrel/minstrel.c | 2 +- ath_rate/sample/sample.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/ath_rate/minstrel/minstrel.c b/ath_rate/minstrel/minstrel.c index 947667d..75e4343 100644 --- a/ath_rate/minstrel/minstrel.c +++ b/ath_rate/minstrel/minstrel.c @@ -283,7 +283,7 @@ calc_usecs_unicast_packet(struct ath_softc *sc, int length, tt += (long_retries + 1) * ath_hal_computetxtime(sc->sc_ah, rt, length, rix, AH_TRUE); for (x = 0; x <= short_retries + long_retries; x++) { - cw = MIN(ATH_DEFAULT_CWMAX, (cw + 1) * 2); + cw = MIN(ATH_DEFAULT_CWMAX, (cw << 1) | 1); tt += (t_slot * cw / 2); } return tt; diff --git a/ath_rate/sample/sample.c b/ath_rate/sample/sample.c index 8c78cdd..8417346 100644 --- a/ath_rate/sample/sample.c +++ b/ath_rate/sample/sample.c @@ -254,7 +254,7 @@ calc_usecs_unicast_packet(struct ath_softc *sc, int length, tt += (long_retries+1)*ath_hal_computetxtime(sc->sc_ah, rt, length, rix, AH_TRUE); for (x = 0; x <= short_retries + long_retries; x++) { - cw = MIN(ATH_DEFAULT_CWMAX, (cw + 1) * 2); + cw = MIN(ATH_DEFAULT_CWMAX, (cw << 1) | 1); tt += (t_slot * cw / 2); } return tt; -- 2.35.1