From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from nbd.name (nbd.name [46.4.11.11]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 72D2D38B145 for ; Mon, 23 Mar 2026 10:19:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=46.4.11.11 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774261200; cv=none; b=qHnAfn72sSV4LblSgSUx1DwnBsBVbNLULSTLAxg+pA1ZcqSk/bkRfy609KxlU4fNIljz5S9O8UzTdrgDYIUjqz1nOse8m/2uY14vNwgzal1gJT4/LMufd7z1m5eF87AH4mavPSD99CfupSO4OW3JTG/X+nbGgQLNqTRs9X5AXFI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774261200; c=relaxed/simple; bh=hEN6vVeVXRajinyQurlghyRr50SpFgAdCvnZtom7gME=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=JqaoWLTzj8kXtFvqnjTX0fFzq8B4kkF++/n7xGlRQ/OE2oQM4wWp/EKT3ZFt9OkibN488cQvp80wIO0FyEJA8zl9lT08J4OmJdi5cwz9oOBKQr2KQX3k8XtEJcA5J6f/pO2fXUAKkC8+KNHLQe5Sy67u/+xDBpI2tct4ZvMV12A= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=nbd.name; spf=pass smtp.mailfrom=nbd.name; dkim=pass (1024-bit key) header.d=nbd.name header.i=@nbd.name header.b=fphDP8MW; arc=none smtp.client-ip=46.4.11.11 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=nbd.name Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=nbd.name Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=nbd.name header.i=@nbd.name header.b="fphDP8MW" 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=CLuw3UtfxSre6eFcGibdyl77ORqwpkWrRuEcMo6jxlQ=; b=fphDP8MWeEPtqDjGejYXRf3QbV 8hp5VjiOmktqkrqEOtmO/WT/XoMSHQzxySPi5Zde5xQ3eh18+gnUXXZDfpGZOT8VsRRzSB8RZKkFM k9sktRa5Y7vxAEXDmXmq7Olupu9r+TMkIvU8n+dE0EL6V98S33u6om2JAzLeCyKlmjyM=; Received: from p200300cadf30ee00000000000000085c.dip0.t-ipconnect.de ([2003:ca:df30:ee00::85c] helo=max) by ds12 with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1w4cO4-00ALUX-2y; Mon, 23 Mar 2026 11:19:56 +0100 From: Felix Fietkau To: linux-wireless@vger.kernel.org Cc: johannes@sipsolutions.net Subject: [PATCH 2/4] wifi: mac80211: estimate expected throughput if not provided by driver/rc Date: Mon, 23 Mar 2026 10:19:52 +0000 Message-ID: <20260323101954.874299-2-nbd@nbd.name> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20260323101954.874299-1-nbd@nbd.name> References: <20260323101954.874299-1-nbd@nbd.name> Precedence: bulk X-Mailing-List: linux-wireless@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Estimate the tx throughput based on the expected per-packet tx time. This is useful for mesh implementations that rely on expected throughput, e.g. 802.11s or batman-adv. Signed-off-by: Felix Fietkau --- net/mac80211/sta_info.c | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/net/mac80211/sta_info.c b/net/mac80211/sta_info.c index 4259e9c13ed7..912f00d905b8 100644 --- a/net/mac80211/sta_info.c +++ b/net/mac80211/sta_info.c @@ -2978,6 +2978,27 @@ static void sta_set_link_sinfo(struct sta_info *sta, } } +static u32 sta_estimate_expected_throughput(struct sta_info *sta, + struct station_info *sinfo) +{ + struct ieee80211_sub_if_data *sdata = sta->sdata; + struct ieee80211_local *local = sdata->local; + struct rate_info *ri = &sinfo->txrate; + struct ieee80211_hw *hw = &local->hw; + struct ieee80211_chanctx_conf *conf; + u32 duration; + u8 band = 0; + + conf = rcu_dereference(sdata->vif.bss_conf.chanctx_conf); + if (conf) + band = conf->def.chan->band; + + duration = ieee80211_rate_expected_tx_airtime(hw, NULL, ri, band, true, 1024); + duration += duration >> 4; /* add assumed packet error rate of ~6% */ + + return ((1024 * USEC_PER_SEC) / duration) * 8; +} + void sta_set_sinfo(struct sta_info *sta, struct station_info *sinfo, bool tidstats) { @@ -3202,6 +3223,8 @@ void sta_set_sinfo(struct sta_info *sta, struct station_info *sinfo, sinfo->sta_flags.set |= BIT(NL80211_STA_FLAG_TDLS_PEER); thr = sta_get_expected_throughput(sta); + if (!thr && (sinfo->filled & BIT_ULL(NL80211_STA_INFO_TX_BITRATE))) + thr = sta_estimate_expected_throughput(sta, sinfo); if (thr != 0) { sinfo->filled |= BIT_ULL(NL80211_STA_INFO_EXPECTED_THROUGHPUT); -- 2.51.0