Fix contention window calculation in sample and minstrel code
authorproski <proski@0192ed92-7a03-0410-a25b-9323aeb14dbd>
Sat, 19 Sep 2009 04:03:53 +0000 (04:03 +0000)
committerproski <proski@0192ed92-7a03-0410-a25b-9323aeb14dbd>
Sat, 19 Sep 2009 04:03:53 +0000 (04:03 +0000)
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 <dhalperi@cs.washington.edu>

git-svn-id: http://madwifi-project.org/svn/madwifi/trunk@4097 0192ed92-7a03-0410-a25b-9323aeb14dbd

ath_rate/minstrel/minstrel.c
ath_rate/sample/sample.c

index 947667dbcceb363c302867f189c4e48610b2cc1c..75e43437ca38d70dd6d0797fbd6cae75119238e9 100644 (file)
@@ -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;
index 8c78cdd04bc13dd145fb9115f62ebd3737c40310..8417346a5343c1ff8bab3b1b33b38f174a83c323 100644 (file)
@@ -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;