From patchwork Fri Mar 13 09:54:44 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Felix Fietkau X-Patchwork-Id: 6003991 X-Patchwork-Delegate: johannes@sipsolutions.net Return-Path: X-Original-To: patchwork-linux-wireless@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 854499F380 for ; Fri, 13 Mar 2015 09:54:52 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id A6402202B4 for ; Fri, 13 Mar 2015 09:54:51 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id D51F22025A for ; Fri, 13 Mar 2015 09:54:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752869AbbCMJys (ORCPT ); Fri, 13 Mar 2015 05:54:48 -0400 Received: from static.88-198-24-112.clients.your-server.de ([88.198.24.112]:34199 "EHLO nbd.name" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751778AbbCMJys (ORCPT ); Fri, 13 Mar 2015 05:54:48 -0400 Received: by nf.local (Postfix, from userid 501) id 8AC10CA1704F; Fri, 13 Mar 2015 10:54:44 +0100 (CET) From: Felix Fietkau To: linux-wireless@vger.kernel.org Cc: johannes@sipsolutions.net, karl.beldan@gmail.com Subject: [PATCH] mac80211: minstrel_ht: fix rounding issue in MCS duration calculation Date: Fri, 13 Mar 2015 10:54:44 +0100 Message-Id: <1426240484-37307-1-git-send-email-nbd@openwrt.org> X-Mailer: git-send-email 2.2.2 Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP On very high MCS bitrates, the calculated duration of rates that are next to each other can be very imprecise, due to the small packet size used as reference (1200 bytes). This is most visible in VHT80 nss=2 MCS8/9, for which minstrel shows the same throughput when the probability is also the same. This leads to a bad rate selection for such rates. Fix this issue by introducing an average A-MPDU size factor into the calculation. Signed-off-by: Felix Fietkau --- net/mac80211/rc80211_minstrel_ht.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/net/mac80211/rc80211_minstrel_ht.c b/net/mac80211/rc80211_minstrel_ht.c index 80452cf..60698fc 100644 --- a/net/mac80211/rc80211_minstrel_ht.c +++ b/net/mac80211/rc80211_minstrel_ht.c @@ -17,10 +17,11 @@ #include "rc80211_minstrel.h" #include "rc80211_minstrel_ht.h" +#define AVG_AMPDU_SIZE 16 #define AVG_PKT_SIZE 1200 /* Number of bits for an average sized packet */ -#define MCS_NBITS (AVG_PKT_SIZE << 3) +#define MCS_NBITS ((AVG_PKT_SIZE * AVG_AMPDU_SIZE) << 3) /* Number of symbols for a packet with (bps) bits per symbol */ #define MCS_NSYMS(bps) DIV_ROUND_UP(MCS_NBITS, (bps)) @@ -33,7 +34,8 @@ ) /* Transmit duration for the raw data part of an average sized packet */ -#define MCS_DURATION(streams, sgi, bps) MCS_SYMBOL_TIME(sgi, MCS_NSYMS((streams) * (bps))) +#define MCS_DURATION(streams, sgi, bps) \ + (MCS_SYMBOL_TIME(sgi, MCS_NSYMS((streams) * (bps))) / AVG_AMPDU_SIZE) #define BW_20 0 #define BW_40 1