Received: by 2002:a5d:925a:0:0:0:0:0 with SMTP id e26csp737939iol; Sat, 11 Jun 2022 17:32:51 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx9v+x57QJnN7bW8naWB29fGcTenTWiCqv0KohqtRN43cqFd3d+IEPk9qRfsbiJNAfMW5sq X-Received: by 2002:a63:ed46:0:b0:3fe:2b89:cbf6 with SMTP id m6-20020a63ed46000000b003fe2b89cbf6mr18814343pgk.112.1654993970980; Sat, 11 Jun 2022 17:32:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1654993970; cv=none; d=google.com; s=arc-20160816; b=m5rmPQCGdTZdZdv+oos6x7s7U3P3aKXxcLFFIch62EqVHsERrA59wBvvalusMFe55g oUj5Oc3XKHq5RyNBwTIVMLXYROiqjlcXdeKVCGlQu8ALlw7Rw+SPEuinW7I6d5eBj+yx udsPU5icChY8Tgv2wjMZzTfMF//Qu+iaCwB6jNDjb3xYh2O+bGqykechsavClbJdh8o9 ctA404T7s+K0MnnRsYlpa5L8C5gQNt3YMFnZoXHLhhciN7o6ZCy7Vo2ByCEcoll6muJq kuaotjd2gq+N3P/0CbhC1j/krIJArmTxlWWaFue82AwDp+tAOKKXo9hOnpSIHzSygBym p83g== 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=ybmJYgyT6wVmtTzw362Og5U3wOSpEWgrLtZv05kJ1Lk=; b=ZYXSON91QJEhvmw0yfC0EtCkdA5X1sjToA461LIBkjnlFmQWrUEUCOpmoWkL/KMo5O DfRNEgV1ndmo5OmYaiZoxdghYTSyq9Eyf4CBv3FTE3y2hfnR+CLF5VYAlEe6DuTm+q54 e4TBwwSj8C2qlWca7+NOxQDTo95MkqAumbPCF2WVKg2GNRYImxCmTmOEKLgVOtcr5D/w E5DfgTjJrRimDkD5y3BEOetN4VYJoRTcyuKZkQwfkZfWu1XP95u1oWsEdqv3E3x0tAYO WdEyoAYizlev8gEU+/2edoJDjiuE6gVdO/hnwq/6QgucFLdlLOgGz3UrRe24kHve4tTD ssaw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@nbd.name header.s=20160729 header.b=pTli8K1f; spf=pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-wireless-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id s125-20020a632c83000000b003fa95b7538fsi3986130pgs.871.2022.06.11.17.32.42; Sat, 11 Jun 2022 17:32:50 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=fail header.i=@nbd.name header.s=20160729 header.b=pTli8K1f; spf=pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-wireless-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231502AbiFKUBW (ORCPT + 65 others); Sat, 11 Jun 2022 16:01:22 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57020 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229594AbiFKUBQ (ORCPT ); Sat, 11 Jun 2022 16:01:16 -0400 Received: from nbd.name (nbd.name [IPv6:2a01:4f8:221:3d45::2]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3BD8C5047D for ; Sat, 11 Jun 2022 13:01:11 -0700 (PDT) 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=ybmJYgyT6wVmtTzw362Og5U3wOSpEWgrLtZv05kJ1Lk=; b=pTli8K1fpkbuaRtu9P0PYJZPox J0zkoKwg5jx7P0YYCX/XQVIWqqfilci9mbDK6tG07mA+9sA4jM1drEyukDPLysYl1CGZXw+NkezbR WN8V0qslrdDBve/Jj8LAHYvQYAOmU6EOhwz0wPWbuG7PnkZ1swTSa15UPmt8uJPqRjrc=; Received: from p57a6f441.dip0.t-ipconnect.de ([87.166.244.65] helo=localhost.localdomain) by ds12 with esmtpsa (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.89) (envelope-from ) id 1o07ID-0006oU-26; Sat, 11 Jun 2022 22:01:09 +0200 From: Felix Fietkau To: linux-wireless@vger.kernel.org Cc: johannes@sipsolutions.net, toke@kernel.org Subject: [PATCH v2 2/4] mac80211: improve AQL tx time estimation Date: Sat, 11 Jun 2022 22:01:04 +0200 Message-Id: <20220611200106.34319-2-nbd@nbd.name> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220611200106.34319-1-nbd@nbd.name> References: <20220611200106.34319-1-nbd@nbd.name> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_NONE, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org If airtime cannot be calculated because of missing or unsupported rate info, use the smallest possible non-zero value for estimated tx time. This improves handling of these cases by preventing queueing of as many packets as the driver/hardware queue can hold for these stations. Also slightly improve limiting queueing by explicitly rounding up small values. Signed-off-by: Felix Fietkau --- include/net/mac80211.h | 18 +++++++++++------- net/mac80211/status.c | 2 ++ net/mac80211/tx.c | 13 ++++++------- 3 files changed, 19 insertions(+), 14 deletions(-) diff --git a/include/net/mac80211.h b/include/net/mac80211.h index ebadb2103968..d8c4d49bcc49 100644 --- a/include/net/mac80211.h +++ b/include/net/mac80211.h @@ -1127,20 +1127,24 @@ struct ieee80211_tx_info { }; }; +#define IEEE80211_TX_TIME_EST_UNIT 4 + +static inline u16 +ieee80211_info_get_tx_time_est(struct ieee80211_tx_info *info) +{ + return info->tx_time_est * IEEE80211_TX_TIME_EST_UNIT; +} + static inline u16 ieee80211_info_set_tx_time_est(struct ieee80211_tx_info *info, u16 tx_time_est) { /* We only have 10 bits in tx_time_est, so store airtime * in increments of 4us and clamp the maximum to 2**12-1 */ - info->tx_time_est = min_t(u16, tx_time_est, 4095) >> 2; - return info->tx_time_est << 2; -} + tx_time_est = DIV_ROUND_UP(tx_time_est, IEEE80211_TX_TIME_EST_UNIT); + info->tx_time_est = min_t(u16, tx_time_est, BIT(10) - 1); -static inline u16 -ieee80211_info_get_tx_time_est(struct ieee80211_tx_info *info) -{ - return info->tx_time_est << 2; + return ieee80211_info_get_tx_time_est(info); } /*** diff --git a/net/mac80211/status.c b/net/mac80211/status.c index e69272139437..cea053d89dbb 100644 --- a/net/mac80211/status.c +++ b/net/mac80211/status.c @@ -1014,6 +1014,8 @@ static void __ieee80211_tx_status(struct ieee80211_hw *hw, NULL, skb->len, false); + if (!airtime) + airtime = IEEE80211_TX_TIME_EST_UNIT; ieee80211_register_airtime(txq, airtime, 0); } diff --git a/net/mac80211/tx.c b/net/mac80211/tx.c index 0e4efc08c762..ecb3975680bc 100644 --- a/net/mac80211/tx.c +++ b/net/mac80211/tx.c @@ -3797,13 +3797,12 @@ struct sk_buff *ieee80211_tx_dequeue(struct ieee80211_hw *hw, airtime = ieee80211_calc_expected_tx_airtime(hw, vif, txq->sta, skb->len, ampdu); - if (airtime) { - airtime = ieee80211_info_set_tx_time_est(info, airtime); - ieee80211_sta_update_pending_airtime(local, tx.sta, - txq->ac, - airtime, - false); - } + if (!airtime) + airtime = IEEE80211_TX_TIME_EST_UNIT; + + airtime = ieee80211_info_set_tx_time_est(info, airtime); + ieee80211_sta_update_pending_airtime(local, tx.sta, txq->ac, + airtime, false); } return skb; -- 2.36.1