Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp9900283pxu; Tue, 29 Dec 2020 08:04:01 -0800 (PST) X-Google-Smtp-Source: ABdhPJx/+G4lU4oKwdb1YX0LG/vZvZXrXTzvRLJWwUqhF/Kf2VydSL+mziIOLMIuA/a+anJDhKEg X-Received: by 2002:a17:907:28d4:: with SMTP id en20mr46865849ejc.196.1609257841453; Tue, 29 Dec 2020 08:04:01 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1609257841; cv=none; d=google.com; s=arc-20160816; b=V8U+Q14ipLlXYjRmbWGJwUnc7gZVkHHQjY0itqnvRAwrQ0+9n4DjY8hs3FiTHqLDeu PgUz5cC4FnJld/oM9vcdQbF5gZy8t9RaCAvH9MwreHzQC8AAgsuW4sYRNOLNlJRaHwh4 3ch3zo0PnCzh3Iyh6qDxK7DC2sqDTsABg10eTCMCjd4z4VM40BIHLsOXuJSbbbINwDbW ZKvM7CC3tpGpVtnNGgfpuyR4UtYYqUvDoIgbylgrAMPyGn8iyTklelEo4h1HgSAVwQX7 t+hKKLmapfJEe1fJWA/4L5erHhEhR4/4/cr4TrlfhZYZyJ0YPV6G0bpme5YWidyPYtcT JpVA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=JuVHklXh3+qr+96gL8tswkfFmb2W3TeisauOl2TtJeM=; b=HfTY0murPl1YCoaeZlRIvIfhjsIKoSRxOBD6cgE3bCGo3jBB3XZ5FGFifCgGT/dedI UfrRhfYNupXBG2fDY6UkzQlYU418/s98PvEScVEsn+EY2mw8oXYYigyQbmFU6QlTW75D 2J9RM6urOGaYgGhVbLAsSC696f298WegqZuJ/DRCkIM6GaF8PFLfvGt0MHSqbUjhkOcQ u5uUgepJNYqGYObKYpStYX6KRn70xMzfiwVIfl1g1xGFbIYrTcsSIEg4OKGMDur18NgM ovxDG9/Ixk6eouqmGQ0FSLCTYspcDAg1Dd/0RlPywlgz6vgViy9KmEVw6t2xbythv8BD TBpQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@nbd.name header.s=20160729 header.b=jRp7vrwY; spf=pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-wireless-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id hs21si21210355ejc.395.2020.12.29.08.03.38; Tue, 29 Dec 2020 08:04:01 -0800 (PST) Received-SPF: pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=fail header.i=@nbd.name header.s=20160729 header.b=jRp7vrwY; spf=pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-wireless-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726651AbgL2QC1 (ORCPT + 99 others); Tue, 29 Dec 2020 11:02:27 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44296 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726388AbgL2QC0 (ORCPT ); Tue, 29 Dec 2020 11:02:26 -0500 Received: from nbd.name (nbd.name [IPv6:2a01:4f8:221:3d45::2]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4578FC061796 for ; Tue, 29 Dec 2020 08:01:31 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=nbd.name; s=20160729; h=Content-Transfer-Encoding:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To:Content-Type:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=JuVHklXh3+qr+96gL8tswkfFmb2W3TeisauOl2TtJeM=; b=jRp7vrwYdWS0/q5hkY2mvz4d4e gfh0SdMXpgnPb0q3eRu8liubnhmo8cfez9/HwfsSbF4wHipvRUoO6jbc8z2YTJHh7ivSs47n6j+M6 O/ifNG2mTfycj2R0BIqOcL4ygXnI+jP0x3DByUD3p+n7SI6n4Dv1BAs41kgsO9HsPbLs=; Received: from p54ae91f2.dip0.t-ipconnect.de ([84.174.145.242] helo=localhost.localdomain) by ds12 with esmtpsa (TLS1.2:ECDHE_RSA_AES_128_CBC_SHA1:128) (Exim 4.89) (envelope-from ) id 1kuHRA-0005ka-Bf; Tue, 29 Dec 2020 17:01:28 +0100 From: Felix Fietkau To: linux-wireless@vger.kernel.org Cc: johannes@sipsolutions.net Subject: [PATCH 5/8] mac80211: minstrel_ht: improve ampdu length estimation Date: Tue, 29 Dec 2020 17:01:22 +0100 Message-Id: <20201229160125.92794-5-nbd@nbd.name> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20201229160125.92794-1-nbd@nbd.name> References: <20201229160125.92794-1-nbd@nbd.name> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org If the driver does not report A-MPDU length, estimate it based on the rate. Signed-off-by: Felix Fietkau --- net/mac80211/rc80211_minstrel_ht.c | 38 +++++++++++++++++++++--------- 1 file changed, 27 insertions(+), 11 deletions(-) diff --git a/net/mac80211/rc80211_minstrel_ht.c b/net/mac80211/rc80211_minstrel_ht.c index 62bb3c1b0bb5..950e6d2b4525 100644 --- a/net/mac80211/rc80211_minstrel_ht.c +++ b/net/mac80211/rc80211_minstrel_ht.c @@ -382,13 +382,37 @@ minstrel_get_ratestats(struct minstrel_ht_sta *mi, int index) return &mi->groups[index / MCS_GROUP_RATES].rates[index % MCS_GROUP_RATES]; } +static inline int +minstrel_get_duration(int index) +{ + const struct mcs_group *group = &minstrel_mcs_groups[index / MCS_GROUP_RATES]; + unsigned int duration = group->duration[index % MCS_GROUP_RATES]; + return duration << group->shift; +} + static unsigned int minstrel_ht_avg_ampdu_len(struct minstrel_ht_sta *mi) { - if (!mi->avg_ampdu_len) - return AVG_AMPDU_SIZE; + int duration; + + if (mi->avg_ampdu_len) + return MINSTREL_TRUNC(mi->avg_ampdu_len); + + if (minstrel_ht_is_legacy_group(mi->max_tp_rate[0] / MCS_GROUP_RATES)) + return 1; + + duration = minstrel_get_duration(mi->max_tp_rate[0]); - return MINSTREL_TRUNC(mi->avg_ampdu_len); + if (duration > 400 * 1000) + return 2; + + if (duration > 250 * 1000) + return 4; + + if (duration > 150 * 1000) + return 8; + + return 16; } /* @@ -588,14 +612,6 @@ minstrel_ht_prob_rate_reduce_streams(struct minstrel_ht_sta *mi) } } -static inline int -minstrel_get_duration(int index) -{ - const struct mcs_group *group = &minstrel_mcs_groups[index / MCS_GROUP_RATES]; - unsigned int duration = group->duration[index % MCS_GROUP_RATES]; - return duration << group->shift; -} - static bool minstrel_ht_probe_group(struct minstrel_ht_sta *mi, const struct mcs_group *tp_group, int tp_idx, const struct mcs_group *group) -- 2.28.0