Received: by 2002:a19:771d:0:0:0:0:0 with SMTP id s29csp1262980lfc; Wed, 1 Jun 2022 13:28:57 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzp10r0gaoLtvEFf3m2aJwQNWd9juTeRyoOKqiAkm7N3MiUdeiArqVedISI6ztPRt29NWs8 X-Received: by 2002:a17:902:cccc:b0:15a:30ec:2f56 with SMTP id z12-20020a170902cccc00b0015a30ec2f56mr1152936ple.169.1654115337413; Wed, 01 Jun 2022 13:28:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1654115337; cv=none; d=google.com; s=arc-20160816; b=U19DYOtyZvJLhE28Py8e45SU9wy6dn9L9PeYmB0IEffnI+6afl+kPsnuBB3x/eFhKg minoPxVQFPuLxGAPHGnmt+dQH1zPYVWGWywdAeB61BL2haKhgqTrnIHD9S+WRBHPmNld e5ZrgTWYl0qY0cD1rSzjqdW0aONpjmGUulg77I9FHOUBjFXhHBLkUHkYUiuD+JdjLKJH KBrqj6MPrjY04idfrKExoJn1/j20UIUV2HmtgJPnmClEZucPA+gUK92XAnc+UsPfHTxf tsjz6oOaldWfVvRiSsIMB7Z5YSi1sEh+Ks97XIJcQcnz4BwFBzv3cAM6fRXJo1OwBS2X Ybkg== 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 :message-id:date:subject:cc:to:from:dkim-signature; bh=PSCX4PHCAROocqljRy3ZnI/Dr3u/fImtm88PpfecH+0=; b=soRTQsXfDkMIDV7P4alHSDEe4CkAugauwwP9k0FXWc84xGK9Gu4q93jL1ulIdX1aas lXZS+zSnI7QlmZC6anDtCUWbsIxIB9ms90bVwPrmdJvVuoOR3U/WfRe4ZRwPWLQMqUsi T/IGTNSYdUxuRE83WYjCFLqEjJpi5ojlPnTncngPq1yVTNpUiBODtBjJN9Wpd29EHNOz 99UeJZt9Yr48LhGPZDFwsD0H5gZhLTCIfuIlvpNuT2xDF6PYFwiKieRuyq35eP24apHj H6yAjjrkjnUL2c3O9NbvkzQIbvg01+cL3qSC7C5/l/PxjSJZ4VpHe2xv5ho3nd4+ClXV pUDw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=hgL7i4Xh; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id l17-20020a170902e2d100b00162359521b5si3053114plc.514.2022.06.01.13.28.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 01 Jun 2022 13:28:57 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=hgL7i4Xh; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 746741EA04D; Wed, 1 Jun 2022 12:44:15 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S245429AbiEaKJ6 (ORCPT + 99 others); Tue, 31 May 2022 06:09:58 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44640 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S245400AbiEaKJu (ORCPT ); Tue, 31 May 2022 06:09:50 -0400 Received: from mail-wr1-x42c.google.com (mail-wr1-x42c.google.com [IPv6:2a00:1450:4864:20::42c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 80E68996AD; Tue, 31 May 2022 03:09:48 -0700 (PDT) Received: by mail-wr1-x42c.google.com with SMTP id k16so13642271wrg.7; Tue, 31 May 2022 03:09:48 -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:mime-version :content-transfer-encoding; bh=PSCX4PHCAROocqljRy3ZnI/Dr3u/fImtm88PpfecH+0=; b=hgL7i4XhVKnDz+kV6ZUE7M1I5YWxgyeFW2IZF2mSrdg4RvA1wzUpEjpZp0UL8CTzy4 +6zDKiJjI/xbhMEf/hdKbj+GEz7nQr3s94DqNwb4DnmCKFcUxk0OeQ9vQCKA6ez2anWb QbVooWUWhpKl2Yn7AHI9HP6ngfob1aHHe5a9xbOSfuj2OmrK4N9X477rxL8O9b1OsD+g PtUvha7RK1clPNKDMorU2IBsVZJQsvxfkCMkcfShi9SxTLwHDC7bnNoB0Lxi8+/+AkuR HCru7e1wLgDwrbmJYV3oA2c3aN4+ehq1Vicg0eUYQqvQ1+C0RNIh4ob3SZt4spKW/PxT i8Ag== 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:mime-version :content-transfer-encoding; bh=PSCX4PHCAROocqljRy3ZnI/Dr3u/fImtm88PpfecH+0=; b=LZzoGtgAci/jXSpdWjGrhinc4o/sUt+cQXdag+rSLtNDMYiAuc2iQnHFJI3WEKRxO4 strcHSNd5+7myhZzJVg4ho7XCEWjaYMCJf7xf39NGtk4bmqn5gUlHKbpHZUEE5ezSHWg 3xfMb5qkAxQpAwTUOBmYZgTmv711zX+gY+xymVRKt0S4h9EBv89K/ELBKKLbCLnTmQfN McXVr1ws15hSW/3g8XerGVj4KiV6aLl9rK5itdCOar+yu2ciEEMYKs1uFV7zS23123nt 0uovx2uwZVYCgbtf7XPP3Wso36jpM/s9/a3bT77ySqCqeC0PArWRelHEe1kbVBW25Nis CChg== X-Gm-Message-State: AOAM533QdCfhHe4mtuCJTLst/RNiWMUnotfZgJN2Drrgn0POF/k7iglI tWCtES4wkLVfvEf3afp6y4M= X-Received: by 2002:a05:6000:1542:b0:20f:f809:cf89 with SMTP id 2-20020a056000154200b0020ff809cf89mr27658582wry.361.1653991786933; Tue, 31 May 2022 03:09:46 -0700 (PDT) Received: from baligh-ThinkCentre-M720q.iliad.local (freebox.vlq16.iliad.fr. [213.36.7.13]) by smtp.googlemail.com with ESMTPSA id n6-20020a05600c4f8600b0039b006bd6d9sm1975543wmq.6.2022.05.31.03.09.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 31 May 2022 03:09:46 -0700 (PDT) From: Baligh Gasmi To: Johannes Berg Cc: Baligh Gasmi , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , linux-wireless@vger.kernel.org (open list:MAC80211), netdev@vger.kernel.org (open list:NETWORKING [GENERAL]), linux-kernel@vger.kernel.org (open list) Subject: [RFC PATCH v3 1/1] mac80211: use AQL airtime for expected throughput. Date: Tue, 31 May 2022 12:09:22 +0200 Message-Id: <20220531100922.491344-1-gasmibal@gmail.com> X-Mailer: git-send-email 2.36.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-1.7 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RDNS_NONE, SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no 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-kernel@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. If the driver has get_expected_throughput implementation, it will be used instead. Useful for L2 routing protocols, like B.A.T.M.A.N. Signed-off-by: Baligh Gasmi --- 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..e58d89c108a4 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->deflink.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; -- 2.36.1