From 8fddddff0ad4ccc2787464207eba9ed3063e69cd Mon Sep 17 00:00:00 2001 From: Daniel Halperin Date: Tue, 10 May 2011 19:00:45 -0700 Subject: mac80211: fix contention time computation in minstrel, minstrel_ht When transmitting a frame, the transmitter waits a random number of slots between 0 and cw. Thus, the contention time is (cw / 2) * t_slot which we can represent instead as (cw * t_slot) >> 1. Also fix a few other accounting bugs around contention time, and add comments. Signed-off-by: Daniel Halperin Signed-off-by: John W. Linville --- net/mac80211/rc80211_minstrel.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'net/mac80211/rc80211_minstrel.c') diff --git a/net/mac80211/rc80211_minstrel.c b/net/mac80211/rc80211_minstrel.c index 778c604d7939..8adac67395f7 100644 --- a/net/mac80211/rc80211_minstrel.c +++ b/net/mac80211/rc80211_minstrel.c @@ -417,8 +417,8 @@ minstrel_rate_init(void *priv, struct ieee80211_supported_band *sband, tx_time_single = mr->ack_time + mr->perfect_tx_time; /* contention window */ - tx_time_single += t_slot + min(cw, mp->cw_max); - cw = (cw << 1) | 1; + tx_time_single += (t_slot * cw) >> 1; + cw = min((cw << 1) | 1, mp->cw_max); tx_time += tx_time_single; tx_time_cts += tx_time_single + mi->sp_ack_dur; -- cgit v1.2.3