From patchwork Wed Jun 1 11:29:01 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Baligh GASMI X-Patchwork-Id: 578053 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5566AC43217 for ; Wed, 1 Jun 2022 11:31:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1352806AbiFALbm (ORCPT ); Wed, 1 Jun 2022 07:31:42 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35074 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1352815AbiFALbf (ORCPT ); Wed, 1 Jun 2022 07:31:35 -0400 Received: from mail-wr1-x431.google.com (mail-wr1-x431.google.com [IPv6:2a00:1450:4864:20::431]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C1AA3703F4; Wed, 1 Jun 2022 04:31:31 -0700 (PDT) Received: by mail-wr1-x431.google.com with SMTP id t6so1937636wra.4; Wed, 01 Jun 2022 04:31:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=5s4FyOD0JyFiMGlz28RbDzh/LKYdCROZ/+g320kSKFU=; b=Oa3Xf8dWYpvQCyr+csNsh81DcqeZjCwtlDoXrHF+nC+IqvbDICTX+uIntMxo4dO+b5 dXdHmLfQlUht5W+9UVpHOLNEBAJZFRoPrzXdEkHlYxr4WPe6nnufmZJbdagGhcVdcjjX 7uhYFVpYkwfgUI2IHIFGCwRi57mnrGcb+cRiDl6r/1nMJ/fBjrT0Iet/8e4rqNilfMXV bjcJ8bxXjKGupYc1KyFP9Xnt6g2h/+IaXS/xhXcp0C+CI3DJlTOYnj6p1kx+vXq6tFK7 J6VWjM8+GFS95Lek4YZeEeqVhyz5l5pm+NBDSRAHfbjTpzMan6uSlV26PYOvd9Hawyjw J7Zg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=5s4FyOD0JyFiMGlz28RbDzh/LKYdCROZ/+g320kSKFU=; b=qWW3JiVGsnO8ZZrQQgnhu81nltVGqhJw33tCg3BgLYn1k9VOmhNddDFc4SyeIVMkWz HLhxdWjTMJHLEWRKXGHvzAZxI8EXq+95jS+yTITTg0umY+2az+Y9cYAwCveArYdwv74Y IMX0GZzCcWbd7qWWNDyap5rZEa+bn0ijpgBn5gXvS2Zrd83nwNRJx3P7YqR/KzpGhakL dchfF9VnLvAO/MxyW/qRGF61b9dTdmsRrS5tJ/PSsuFd/eRVC4Kqv33xK7ysCRwDGL2A zOS0pFLE783blO4+/HHCn+mYIq721T14Ykj1LlU7hpL0957uUpfV+qPZ+Y+swdLLH6fh tI5Q== X-Gm-Message-State: AOAM533qXiVoias6mcPwK1/BidXv9ia/8iHP2YiiINnvmshGUCapwfGD hID2HgfESh6T7yQbWQ3bMy8aKJNjclBK7w== X-Google-Smtp-Source: ABdhPJyvCukLWQ7Yu0y0CXMyIm7d9uEfVaVwj/HWA45dAmkWpMj9jROw9s3EVQHO1w32ZogwYQ3vVA== X-Received: by 2002:adf:d1c6:0:b0:20f:c91f:ba9a with SMTP id b6-20020adfd1c6000000b0020fc91fba9amr44422113wrd.132.1654083090331; Wed, 01 Jun 2022 04:31:30 -0700 (PDT) Received: from baligh-ThinkCentre-M720q.iliad.local (freebox.vlq16.iliad.fr. [213.36.7.13]) by smtp.googlemail.com with ESMTPSA id j14-20020a05600c190e00b00397381a7ae8sm6196724wmq.30.2022.06.01.04.31.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 01 Jun 2022 04:31:30 -0700 (PDT) From: Baligh Gasmi To: Johannes Berg Cc: "David S . Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , linux-wireless@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Baligh Gasmi , kernel test robot , Felix Fietkau Subject: [RFC PATCH v4 1/3] mac80211: use AQL airtime for expected throughput. Date: Wed, 1 Jun 2022 13:29:01 +0200 Message-Id: <20220601112903.2346319-2-gasmibal@gmail.com> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220601112903.2346319-1-gasmibal@gmail.com> References: <20220601112903.2346319-1-gasmibal@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org Since the integration of AQL, packet TX airtime estimation is calculated and counted to be used for the dequeue limit. Use this estimated airtime to compute expected throughput for each station. It will be a generic mac80211 implementation. that can be used if the driver do not have get_expected_throughput implementation. Useful for L2 routing protocols, like B.A.T.M.A.N. Signed-off-by: Baligh Gasmi Reported-by: kernel test robot CC: Felix Fietkau --- net/mac80211/driver-ops.h | 2 ++ net/mac80211/sta_info.c | 39 +++++++++++++++++++++++++++++++++++++++ net/mac80211/sta_info.h | 11 +++++++++++ net/mac80211/status.c | 2 ++ net/mac80211/tx.c | 8 +++++++- 5 files changed, 61 insertions(+), 1 deletion(-) diff --git a/net/mac80211/driver-ops.h b/net/mac80211/driver-ops.h index 4e2fc1a08681..fa9952154795 100644 --- a/net/mac80211/driver-ops.h +++ b/net/mac80211/driver-ops.h @@ -1142,6 +1142,8 @@ static inline u32 drv_get_expected_throughput(struct ieee80211_local *local, trace_drv_get_expected_throughput(&sta->sta); if (local->ops->get_expected_throughput && sta->uploaded) ret = local->ops->get_expected_throughput(&local->hw, &sta->sta); + else + ret = ewma_avg_est_tp_read(&sta->deflink.status_stats.avg_est_tp); trace_drv_return_u32(local, ret); return ret; diff --git a/net/mac80211/sta_info.c b/net/mac80211/sta_info.c index e04a0905e941..201aab465234 100644 --- a/net/mac80211/sta_info.c +++ b/net/mac80211/sta_info.c @@ -1993,6 +1993,45 @@ void ieee80211_sta_update_pending_airtime(struct ieee80211_local *local, tx_pending, 0); } +void ieee80211_sta_update_tp(struct ieee80211_local *local, + struct sta_info *sta, + struct sk_buff *skb, + u16 tx_time_est, + bool ack, int retry) +{ + unsigned long diff; + struct rate_control_ref *ref = NULL; + + if (!skb || !sta || !tx_time_est) + return; + + if (test_sta_flag(sta, WLAN_STA_RATE_CONTROL)) + ref = sta->rate_ctrl; + + if (ref && ref->ops->get_expected_throughput) + return; + + if (local->ops->get_expected_throughput) + return; + + tx_time_est += ack ? 4 : 0; + tx_time_est += retry ? retry * 2 : 2; + + sta->deflink.tx_stats.tp_tx_size += (skb->len * 8) * 1000; + sta->deflink.tx_stats.tp_tx_time_est += tx_time_est; + + diff = jiffies - sta->deflink.status_stats.last_tp_update; + if (diff > HZ / 10) { + ewma_avg_est_tp_add(&sta->deflink.status_stats.avg_est_tp, + sta->deflink.tx_stats.tp_tx_size / + sta->deflink.tx_stats.tp_tx_time_est); + + sta->deflink.tx_stats.tp_tx_size = 0; + sta->deflink.tx_stats.tp_tx_time_est = 0; + sta->deflink.status_stats.last_tp_update = jiffies; + } +} + int sta_info_move_state(struct sta_info *sta, enum ieee80211_sta_state new_state) { diff --git a/net/mac80211/sta_info.h b/net/mac80211/sta_info.h index 35c390bedfba..4200856fefcd 100644 --- a/net/mac80211/sta_info.h +++ b/net/mac80211/sta_info.h @@ -123,6 +123,7 @@ enum ieee80211_sta_info_flags { #define HT_AGG_STATE_STOP_CB 7 #define HT_AGG_STATE_SENT_ADDBA 8 +DECLARE_EWMA(avg_est_tp, 8, 16) DECLARE_EWMA(avg_signal, 10, 8) enum ieee80211_agg_stop_reason { AGG_STOP_DECLINED, @@ -157,6 +158,12 @@ void ieee80211_register_airtime(struct ieee80211_txq *txq, struct sta_info; +void ieee80211_sta_update_tp(struct ieee80211_local *local, + struct sta_info *sta, + struct sk_buff *skb, + u16 tx_time_est, + bool ack, int retry); + /** * struct tid_ampdu_tx - TID aggregation information (Tx). * @@ -549,6 +556,8 @@ struct link_sta_info { s8 last_ack_signal; bool ack_signal_filled; struct ewma_avg_signal avg_ack_signal; + struct ewma_avg_est_tp avg_est_tp; + unsigned long last_tp_update; } status_stats; /* Updated from TX path only, no locking requirements */ @@ -558,6 +567,8 @@ struct link_sta_info { struct ieee80211_tx_rate last_rate; struct rate_info last_rate_info; u64 msdu[IEEE80211_NUM_TIDS + 1]; + u64 tp_tx_size; + u64 tp_tx_time_est; } tx_stats; enum ieee80211_sta_rx_bandwidth cur_max_bandwidth; diff --git a/net/mac80211/status.c b/net/mac80211/status.c index e69272139437..1fb93abc1709 100644 --- a/net/mac80211/status.c +++ b/net/mac80211/status.c @@ -1152,6 +1152,8 @@ void ieee80211_tx_status_ext(struct ieee80211_hw *hw, ack_signal_valid = !!(info->status.flags & IEEE80211_TX_STATUS_ACK_SIGNAL_VALID); + ieee80211_sta_update_tp(local, sta, skb, tx_time_est, acked, retry_count); + if (pubsta) { struct ieee80211_sub_if_data *sdata = sta->sdata; diff --git a/net/mac80211/tx.c b/net/mac80211/tx.c index 0e4efc08c762..b7c14ea621de 100644 --- a/net/mac80211/tx.c +++ b/net/mac80211/tx.c @@ -3632,6 +3632,7 @@ struct sk_buff *ieee80211_tx_dequeue(struct ieee80211_hw *hw, struct ieee80211_tx_data tx; ieee80211_tx_result r; struct ieee80211_vif *vif = txq->vif; + struct rate_control_ref *ref = NULL; WARN_ON_ONCE(softirq_count() == 0); @@ -3790,8 +3791,13 @@ struct sk_buff *ieee80211_tx_dequeue(struct ieee80211_hw *hw, encap_out: IEEE80211_SKB_CB(skb)->control.vif = vif; + if (tx.sta && test_sta_flag(tx.sta, WLAN_STA_RATE_CONTROL)) + ref = tx.sta->rate_ctrl; + if (vif && - wiphy_ext_feature_isset(local->hw.wiphy, NL80211_EXT_FEATURE_AQL)) { + ((!local->ops->get_expected_throughput && + (!ref || !ref->ops->get_expected_throughput)) || + wiphy_ext_feature_isset(local->hw.wiphy, NL80211_EXT_FEATURE_AQL))) { bool ampdu = txq->ac != IEEE80211_AC_VO; u32 airtime; From patchwork Wed Jun 1 11:29:02 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Baligh GASMI X-Patchwork-Id: 578473 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6FBC9C433EF for ; Wed, 1 Jun 2022 11:31:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1352690AbiFALbj (ORCPT ); Wed, 1 Jun 2022 07:31:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35078 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1352819AbiFALbf (ORCPT ); Wed, 1 Jun 2022 07:31:35 -0400 Received: from mail-wr1-x42d.google.com (mail-wr1-x42d.google.com [IPv6:2a00:1450:4864:20::42d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 61350703F3; Wed, 1 Jun 2022 04:31:33 -0700 (PDT) Received: by mail-wr1-x42d.google.com with SMTP id k19so1919429wrd.8; Wed, 01 Jun 2022 04:31:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=DjC4XPc3pHJcR2WcSokV5/EvwHKyghpLbBxl/e5UR/c=; b=ghSOQ5id8TKh2BaBsLyS2j946ZQzeNgQEVJWTTsnDs0eVCUpTSHmCdo04lXGyHnuRj PbtzYXEam3clKmg+R/QZFGxzZHhyFdl68+Cmiwwigu7f9y+TYCSGwowtb0qr6YQxBtq+ p+0NR/X6vUiTwzU6kZcOdxcePREZG820t7v7c0lWWCVtRNCBWtuTexdreTP3UzFCHX2L Nhe2/M+YJD+BwLVrC6HBbGKkQG/2GH+4iskbBt7gvgJtIQDLGHAPRLEUMVD6mDyJ2r9G U8eNgruOXmaXgbZQxLC6S47iJUGPtW2tnxoVE7q1DOAleJtx8noONTI6MCij47jqncwZ 7faw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=DjC4XPc3pHJcR2WcSokV5/EvwHKyghpLbBxl/e5UR/c=; b=g7nXOJxnwN/l+ina1+QkheYmtJQExyB6+ZOUUiUDuAx6raivp49oMHF1sAhELkfko/ kWopKyXJRQoUng4AX5RYr2Nzg9TgiLZjEGPlgqoYjqm/ygUQomwVlygjL/65pxZxyOCh o3UBsd+Qtnz/xblewYNZ3WJQqwukHeVY1zpC5QP2Q4EEPSNsuttGMry42PXAs6iIcX2O FEuBgLFq6YS9OPO2tbkvoFnN/iSaZtBygmwwrc4E/n/p8Frh3idASoJgxyXeAcCVAgdp zQagq1QbT4QFqUlIs/+FiaZdtmmRSiBiJr0Nh10hxbc/XOuSsm/oWHQgD3xcT5dZzMhs ajUA== X-Gm-Message-State: AOAM533k2r/LM8MNBSmzOamgTg35ylCgRzYZQxEYsa74wcX5ymTNo+kN xevkqILWT8TJzltlFrbhCcekXgUsiO/1AA== X-Google-Smtp-Source: ABdhPJyDFaFVDgmZaPQmgYXbzyRn/h1+JpR4ncoSGamGjxz+1HJf9faNqR9m2ogf2xjHKmNSDBjVOA== X-Received: by 2002:adf:fbce:0:b0:20f:ca5b:c4cf with SMTP id d14-20020adffbce000000b0020fca5bc4cfmr43732009wrs.421.1654083092508; Wed, 01 Jun 2022 04:31:32 -0700 (PDT) Received: from baligh-ThinkCentre-M720q.iliad.local (freebox.vlq16.iliad.fr. [213.36.7.13]) by smtp.googlemail.com with ESMTPSA id j14-20020a05600c190e00b00397381a7ae8sm6196724wmq.30.2022.06.01.04.31.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 01 Jun 2022 04:31:32 -0700 (PDT) From: Baligh Gasmi To: Johannes Berg Cc: "David S . Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , linux-wireless@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Baligh Gasmi Subject: [RFC PATCH v4 2/3] mac80211: add periodic monitor for channel busy time Date: Wed, 1 Jun 2022 13:29:02 +0200 Message-Id: <20220601112903.2346319-3-gasmibal@gmail.com> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220601112903.2346319-1-gasmibal@gmail.com> References: <20220601112903.2346319-1-gasmibal@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org Add a worker scheduled periodicaly to calculate the busy time average of the current channel. This will be used in the estimation for expected throughput. Signed-off-by: Baligh Gasmi --- net/mac80211/ieee80211_i.h | 6 ++++ net/mac80211/iface.c | 65 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 71 insertions(+) diff --git a/net/mac80211/ieee80211_i.h b/net/mac80211/ieee80211_i.h index 86ef0a46a68c..2cb388335ce8 100644 --- a/net/mac80211/ieee80211_i.h +++ b/net/mac80211/ieee80211_i.h @@ -901,6 +901,7 @@ struct ieee80211_if_nan { struct idr function_inst_ids; }; +DECLARE_EWMA(avg_busy, 8, 4) struct ieee80211_sub_if_data { struct list_head list; @@ -1024,6 +1025,11 @@ struct ieee80211_sub_if_data { } debugfs; #endif + struct delayed_work monitor_work; + u64 last_time; + u64 last_time_busy; + struct ewma_avg_busy avg_busy; + /* must be last, dynamically sized area in this! */ struct ieee80211_vif vif; }; diff --git a/net/mac80211/iface.c b/net/mac80211/iface.c index 41531478437c..45b860c59d79 100644 --- a/net/mac80211/iface.c +++ b/net/mac80211/iface.c @@ -1970,6 +1970,64 @@ static void ieee80211_assign_perm_addr(struct ieee80211_local *local, mutex_unlock(&local->iflist_mtx); } +#define DEFAULT_MONITOR_INTERVAL_MS 1000 + +static void ieee80211_if_monitor_work(struct work_struct *work) +{ + struct delayed_work *delayed_work = to_delayed_work(work); + struct ieee80211_sub_if_data *sdata = + container_of(delayed_work, struct ieee80211_sub_if_data, + monitor_work); + struct survey_info survey; + struct ieee80211_local *local = sdata->local; + struct ieee80211_chanctx_conf *chanctx_conf; + struct ieee80211_channel *channel = NULL; + int q = 0; + u64 interval = DEFAULT_MONITOR_INTERVAL_MS; + + rcu_read_lock(); + chanctx_conf = rcu_dereference(sdata->vif.chanctx_conf); + if (chanctx_conf) + channel = chanctx_conf->def.chan; + rcu_read_unlock(); + + if (!channel) + goto end; + + if (!local->started) + goto end; + + do { + survey.filled = 0; + if (drv_get_survey(local, q++, &survey) != 0) { + survey.filled = 0; + break; + } + } while (channel != survey.channel); + + if (survey.filled & SURVEY_INFO_TIME) { + /* real interval */ + interval = survey.time - sdata->last_time; + /* store last time */ + sdata->last_time = survey.time; + } + + if (survey.filled & SURVEY_INFO_TIME_BUSY) { + /* busy */ + u64 busy = survey.time_busy < sdata->last_time_busy ? 0 : + survey.time_busy - sdata->last_time_busy; + /* average percent busy time */ + ewma_avg_busy_add(&sdata->avg_busy, + (busy * 100) / interval); + /* store last busy time */ + sdata->last_time_busy = survey.time_busy; + } + +end: + schedule_delayed_work(&sdata->monitor_work, + msecs_to_jiffies(DEFAULT_MONITOR_INTERVAL_MS)); +} + int ieee80211_if_add(struct ieee80211_local *local, const char *name, unsigned char name_assign_type, struct wireless_dev **new_wdev, enum nl80211_iftype type, @@ -2083,6 +2141,8 @@ int ieee80211_if_add(struct ieee80211_local *local, const char *name, ieee80211_dfs_cac_timer_work); INIT_DELAYED_WORK(&sdata->dec_tailroom_needed_wk, ieee80211_delayed_tailroom_dec); + INIT_DELAYED_WORK(&sdata->monitor_work, + ieee80211_if_monitor_work); for (i = 0; i < NUM_NL80211_BANDS; i++) { struct ieee80211_supported_band *sband; @@ -2154,6 +2214,9 @@ int ieee80211_if_add(struct ieee80211_local *local, const char *name, list_add_tail_rcu(&sdata->list, &local->interfaces); mutex_unlock(&local->iflist_mtx); + schedule_delayed_work(&sdata->monitor_work, + msecs_to_jiffies(DEFAULT_MONITOR_INTERVAL_MS)); + if (new_wdev) *new_wdev = &sdata->wdev; @@ -2164,6 +2227,8 @@ void ieee80211_if_remove(struct ieee80211_sub_if_data *sdata) { ASSERT_RTNL(); + cancel_delayed_work_sync(&sdata->monitor_work); + mutex_lock(&sdata->local->iflist_mtx); list_del_rcu(&sdata->list); mutex_unlock(&sdata->local->iflist_mtx); From patchwork Wed Jun 1 11:29:03 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Baligh GASMI X-Patchwork-Id: 578472 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 43304C433EF for ; Wed, 1 Jun 2022 11:31:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1352802AbiFALbp (ORCPT ); Wed, 1 Jun 2022 07:31:45 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35152 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1352807AbiFALbg (ORCPT ); Wed, 1 Jun 2022 07:31:36 -0400 Received: from mail-wr1-x432.google.com (mail-wr1-x432.google.com [IPv6:2a00:1450:4864:20::432]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0F3F670367; Wed, 1 Jun 2022 04:31:35 -0700 (PDT) Received: by mail-wr1-x432.google.com with SMTP id x17so1936693wrg.6; Wed, 01 Jun 2022 04:31:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=dxtIkLrQ+uEkp6mtT2vSgs4p16WW1MiV+wwrEChzYxE=; b=iO6RppWGp5s3SMMWxYTaus2hDNnRvlUkzGk/rnnBNXxXEfsmwkhLCvIFpSFqFi/KDA 0hQzZJoyptsPBwq1PdlAT+IMac0DBp4bBjCI45Dib2kFHpCJQDk40+wNmNILqs8a34eM 7vXgFhHVVFpjklCZynBL5x2o2P+E6w17PiZ5mibCmokrYe/Ary/JSYCttvedmnBjEaKl HWEYXkHRcxh/UTYiXJP8Myfr1c9JUl5kRhhmVbn+Uwnl9IPSqoAJuKIAU+sV1DtMeaWR An7LSjCx0J2e4wE+0GXail4zUya2nclEyGeuFZQSzaiVK/OvViaIShNNwlLp/fYBwT3V N6ZQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=dxtIkLrQ+uEkp6mtT2vSgs4p16WW1MiV+wwrEChzYxE=; b=3uOqURhd4Arux77LPEAtodRi+11R9cjJ86mm7WuKaljcC7b/h9YGr8I4UqohYKKM0v IuEQz6xuugA+hKvKJUCP0DQmf8Pmo7rNO21Xgmc+LU2hJWHfB22bBOjv2CTpbm6hVkBb b6y8Nj5q3ReXAkiE0FwNbRt8TfHND5h7ZlwCpywcYUYiHZ6wYe16RwUuyB4G+RJUgP+I jsMo2jGBUZyvyvfV0u2LTBxSGKf3m6b2o068HK6n9oR8M+QqEuE/FSRUAGHTEl/MVOYd f/XdbFj+TPSjpqwPRMVrI4XUcKpeGBlLXYIjQwWVuAL5wtl6218j3eZqbFleTMtN47Bi ACbQ== X-Gm-Message-State: AOAM530fg36Li6XvsoWSPzaUG+8MtNFnu5GEdd0OUrrkJuMPPDqPP+pX viagVfm9ccyhZbUzWKBwc9Y= X-Google-Smtp-Source: ABdhPJzrVmsK0GkBO/VJ2D/KHo0BKBl30TFWTTJv88GhKJFOl+a41CMtKClPhivLeV/F32jVfy9cvQ== X-Received: by 2002:a05:6000:1625:b0:210:29c9:3e30 with SMTP id v5-20020a056000162500b0021029c93e30mr15622721wrb.252.1654083094480; Wed, 01 Jun 2022 04:31:34 -0700 (PDT) Received: from baligh-ThinkCentre-M720q.iliad.local (freebox.vlq16.iliad.fr. [213.36.7.13]) by smtp.googlemail.com with ESMTPSA id j14-20020a05600c190e00b00397381a7ae8sm6196724wmq.30.2022.06.01.04.31.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 01 Jun 2022 04:31:34 -0700 (PDT) From: Baligh Gasmi To: Johannes Berg Cc: "David S . Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , linux-wireless@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Baligh Gasmi Subject: [RFC PATCH v4 3/3] mac80211: add busy time factor into expected throughput Date: Wed, 1 Jun 2022 13:29:03 +0200 Message-Id: <20220601112903.2346319-4-gasmibal@gmail.com> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220601112903.2346319-1-gasmibal@gmail.com> References: <20220601112903.2346319-1-gasmibal@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org When estimating the expected throughput, take into account the busy time of the current channel. Signed-off-by: Baligh Gasmi --- net/mac80211/sta_info.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/net/mac80211/sta_info.c b/net/mac80211/sta_info.c index 201aab465234..9f977cf13dd5 100644 --- a/net/mac80211/sta_info.c +++ b/net/mac80211/sta_info.c @@ -2000,6 +2000,8 @@ void ieee80211_sta_update_tp(struct ieee80211_local *local, bool ack, int retry) { unsigned long diff; + struct ieee80211_sub_if_data *sdata; + u32 avg_busy; struct rate_control_ref *ref = NULL; if (!skb || !sta || !tx_time_est) @@ -2014,6 +2016,7 @@ void ieee80211_sta_update_tp(struct ieee80211_local *local, if (local->ops->get_expected_throughput) return; + sdata = sta->sdata; tx_time_est += ack ? 4 : 0; tx_time_est += retry ? retry * 2 : 2; @@ -2022,6 +2025,10 @@ void ieee80211_sta_update_tp(struct ieee80211_local *local, diff = jiffies - sta->deflink.status_stats.last_tp_update; if (diff > HZ / 10) { + avg_busy = ewma_avg_busy_read(&sdata->avg_busy) >> 1; + sta->deflink.tx_stats.tp_tx_time_est += + (sta->deflin.tx_stats.tp_tx_time_est * avg_busy) / 100; + ewma_avg_est_tp_add(&sta->deflink.status_stats.avg_est_tp, sta->deflink.tx_stats.tp_tx_size / sta->deflink.tx_stats.tp_tx_time_est);