Received: by 2002:a05:6a10:2785:0:0:0:0 with SMTP id ia5csp312475pxb; Fri, 15 Jan 2021 04:04:48 -0800 (PST) X-Google-Smtp-Source: ABdhPJzkw32ncdv68tesWi4+nnbqAhFRlehGnnDXzUnHBsx2rj4oTqSV0DGT7BfFYLmgpswBASug X-Received: by 2002:a50:f392:: with SMTP id g18mr9328051edm.306.1610712288025; Fri, 15 Jan 2021 04:04:48 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1610712288; cv=none; d=google.com; s=arc-20160816; b=XgvylUVcjBGncqo5lnKxCc0V9EC9cVu8j1zEKqvXh+LKCLx+EXttquxs1RDNR02An4 iD9TooYKQCuR9GxCV8o7I9UowrWg873j75bLnBlyf/dU5b5AfWnnuk88NvPBm53D9DFx VwG2kLbdybYb/1ESTTcBlf2uhZoc6WF0sAdKFh+qpe6IGHexxKPn07zzGxhEotUFC7Ym 6Nyk40jpGM9sL1keVqVwPzkFMoeqyQdMeMIjyrKeqIPZA6giMqX9tX1LcCZyiXzohlNN qNjGHkYhzichuDPVgJstBKlNc1o66KRC5A7/CUIcSLwBCdbxm9XqwoBEDhzh5AUmZCB2 Emzw== 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=BI4dOLn6XJIWPSJsw9SU6tEKGEplQ+jrmF4XJ2pqXKM=; b=kqebeu2UJZYNDi6ZK6U7iX034E6/rC+z3Nq77+FLrG18pxeWj6lmP3aUNN2SV9pgkB 24RXfKdynW81jSdxJ6ZNI6VYFE4w8D5HFGIoW5sXRE6eDrsfsG0eh7GSH1H26zvk4aKU Ru4MzvJACjUlJvhmESGWNCpWAXmcmXbPvLpiPc4sOlMOv1cGX+ELpsP/yaVmv0cFldPn nJ5b9QApcboMAoULmU4x/fad1CwgYzlle/38X3INHVYtwAFlCeNw2DHJg1tDywoqUzFr jDojjgVEg8qYIdLyvuOZCGbclqTMYbAZ/liwxx6a2FiDhaZsRNweU4/aYoj80SqmwbgF Ud0A== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@nbd.name header.s=20160729 header.b=OOLlN2GD; 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 rp5si3663673ejb.285.2021.01.15.04.04.19; Fri, 15 Jan 2021 04:04:48 -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=OOLlN2GD; 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 S1729367AbhAOMDf (ORCPT + 99 others); Fri, 15 Jan 2021 07:03:35 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60742 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726182AbhAOMDc (ORCPT ); Fri, 15 Jan 2021 07:03:32 -0500 Received: from nbd.name (nbd.name [IPv6:2a01:4f8:221:3d45::2]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A2AAAC061798 for ; Fri, 15 Jan 2021 04:02:48 -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=BI4dOLn6XJIWPSJsw9SU6tEKGEplQ+jrmF4XJ2pqXKM=; b=OOLlN2GDr3q4llWQZkWxTnbUMF M35BgPEOshPmyR0tiSWEQpgmTBrg1i4TNiAQtB6t8Tr1Rah9A8Beo91o8gNbc9Y7fSfSTHIVD9qjp lhlD744ITf1t6g7XYC5VufsROz86e9Nc8rWXNztxO7LrzZTh9tYx6cWRgRVjnN2qGTX0=; 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 1l0NoT-0006Y0-Ha; Fri, 15 Jan 2021 13:02:45 +0100 From: Felix Fietkau To: linux-wireless@vger.kernel.org Cc: johannes@sipsolutions.net Subject: [PATCH v3 1/9] mac80211: minstrel_ht: clean up CCK code Date: Fri, 15 Jan 2021 13:02:34 +0100 Message-Id: <20210115120242.89616-2-nbd@nbd.name> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20210115120242.89616-1-nbd@nbd.name> References: <20210115120242.89616-1-nbd@nbd.name> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org - move ack overhead out of rate duration table - remove cck_supported, cck_supported_short Preparation for adding OFDM legacy rates support Signed-off-by: Felix Fietkau --- net/mac80211/rc80211_minstrel_ht.c | 54 +++++++++++++++++------------- net/mac80211/rc80211_minstrel_ht.h | 5 ++- 2 files changed, 32 insertions(+), 27 deletions(-) diff --git a/net/mac80211/rc80211_minstrel_ht.c b/net/mac80211/rc80211_minstrel_ht.c index b11a2af55b06..167d4fa5adf1 100644 --- a/net/mac80211/rc80211_minstrel_ht.c +++ b/net/mac80211/rc80211_minstrel_ht.c @@ -136,20 +136,16 @@ __VHT_GROUP(_streams, _sgi, _bw, \ VHT_GROUP_SHIFT(_streams, _sgi, _bw)) -#define CCK_DURATION(_bitrate, _short, _len) \ +#define CCK_DURATION(_bitrate, _short) \ (1000 * (10 /* SIFS */ + \ (_short ? 72 + 24 : 144 + 48) + \ - (8 * (_len + 4) * 10) / (_bitrate))) - -#define CCK_ACK_DURATION(_bitrate, _short) \ - (CCK_DURATION((_bitrate > 10 ? 20 : 10), false, 60) + \ - CCK_DURATION(_bitrate, _short, AVG_PKT_SIZE)) + (8 * (AVG_PKT_SIZE + 4) * 10) / (_bitrate))) #define CCK_DURATION_LIST(_short, _s) \ - CCK_ACK_DURATION(10, _short) >> _s, \ - CCK_ACK_DURATION(20, _short) >> _s, \ - CCK_ACK_DURATION(55, _short) >> _s, \ - CCK_ACK_DURATION(110, _short) >> _s + CCK_DURATION(10, _short) >> _s, \ + CCK_DURATION(20, _short) >> _s, \ + CCK_DURATION(55, _short) >> _s, \ + CCK_DURATION(110, _short) >> _s #define __CCK_GROUP(_s) \ [MINSTREL_CCK_GROUP] = { \ @@ -163,7 +159,7 @@ } #define CCK_GROUP_SHIFT \ - GROUP_SHIFT(CCK_ACK_DURATION(10, false)) + GROUP_SHIFT(CCK_DURATION(10, false)) #define CCK_GROUP __CCK_GROUP(CCK_GROUP_SHIFT) @@ -349,15 +345,19 @@ int minstrel_ht_get_tp_avg(struct minstrel_ht_sta *mi, int group, int rate, int prob_avg) { - unsigned int nsecs = 0; + unsigned int nsecs = 0, overhead = mi->overhead; + unsigned int ampdu_len = 1; /* do not account throughput if sucess prob is below 10% */ if (prob_avg < MINSTREL_FRAC(10, 100)) return 0; - if (group != MINSTREL_CCK_GROUP) - nsecs = 1000 * mi->overhead / minstrel_ht_avg_ampdu_len(mi); + if (group == MINSTREL_CCK_GROUP) + overhead = mi->overhead_legacy; + else + ampdu_len = minstrel_ht_avg_ampdu_len(mi); + nsecs = 1000 * overhead / ampdu_len; nsecs += minstrel_mcs_groups[group].duration[rate] << minstrel_mcs_groups[group].shift; @@ -1031,7 +1031,10 @@ minstrel_calc_retransmit(struct minstrel_priv *mp, struct minstrel_ht_sta *mi, ctime += (t_slot * cw) >> 1; cw = min((cw << 1) | 1, mp->cw_max); - if (index / MCS_GROUP_RATES != MINSTREL_CCK_GROUP) { + if (index / MCS_GROUP_RATES == MINSTREL_CCK_GROUP) { + overhead = mi->overhead_legacy; + overhead_rtscts = mi->overhead_legacy_rtscts; + } else { overhead = mi->overhead; overhead_rtscts = mi->overhead_rtscts; } @@ -1369,18 +1372,14 @@ minstrel_ht_update_cck(struct minstrel_priv *mp, struct minstrel_ht_sta *mi, if (!ieee80211_hw_check(mp->hw, SUPPORTS_HT_CCK_RATES)) return; - mi->cck_supported = 0; - mi->cck_supported_short = 0; for (i = 0; i < 4; i++) { if (!rate_supported(sta, sband->band, mp->cck_rates[i])) continue; - mi->cck_supported |= BIT(i); + mi->supported[MINSTREL_CCK_GROUP] |= BIT(i); if (sband->bitrates[i].flags & IEEE80211_RATE_SHORT_PREAMBLE) - mi->cck_supported_short |= BIT(i); + mi->supported[MINSTREL_CCK_GROUP] |= BIT(i + 4); } - - mi->supported[MINSTREL_CCK_GROUP] = mi->cck_supported; } static void @@ -1394,12 +1393,13 @@ minstrel_ht_update_caps(void *priv, struct ieee80211_supported_band *sband, struct ieee80211_mcs_info *mcs = &sta->ht_cap.mcs; u16 ht_cap = sta->ht_cap.cap; struct ieee80211_sta_vht_cap *vht_cap = &sta->vht_cap; + const struct ieee80211_rate *ctl_rate; + bool ldpc, erp; int use_vht; int n_supported = 0; int ack_dur; int stbc; int i; - bool ldpc; /* fall back to the old minstrel for legacy stations */ if (!sta->ht_cap.ht_supported) @@ -1423,6 +1423,14 @@ minstrel_ht_update_caps(void *priv, struct ieee80211_supported_band *sband, mi->overhead += ack_dur; mi->overhead_rtscts = mi->overhead + 2 * ack_dur; + ctl_rate = &sband->bitrates[rate_lowest_index(sband, sta)]; + erp = ctl_rate->flags & IEEE80211_RATE_ERP_G; + ack_dur = ieee80211_frame_duration(sband->band, 10, + ctl_rate->bitrate, erp, 1, + ieee80211_chandef_get_shift(chandef)); + mi->overhead_legacy = ack_dur; + mi->overhead_legacy_rtscts = mi->overhead_legacy + 2 * ack_dur; + mi->avg_ampdu_len = MINSTREL_FRAC(1, 1); /* When using MRR, sample more on the first attempt, without delay */ @@ -1523,8 +1531,6 @@ minstrel_ht_update_caps(void *priv, struct ieee80211_supported_band *sband, if (!n_supported) goto use_legacy; - mi->supported[MINSTREL_CCK_GROUP] |= mi->cck_supported_short << 4; - /* create an initial rate table with the lowest supported rates */ minstrel_ht_update_stats(mp, mi, true); minstrel_ht_update_rates(mp, mi); diff --git a/net/mac80211/rc80211_minstrel_ht.h b/net/mac80211/rc80211_minstrel_ht.h index 53ea3c29debf..11300fa48a2f 100644 --- a/net/mac80211/rc80211_minstrel_ht.h +++ b/net/mac80211/rc80211_minstrel_ht.h @@ -77,6 +77,8 @@ struct minstrel_ht_sta { /* overhead time in usec for each frame */ unsigned int overhead; unsigned int overhead_rtscts; + unsigned int overhead_legacy; + unsigned int overhead_legacy_rtscts; unsigned int total_packets_last; unsigned int total_packets_cur; @@ -97,9 +99,6 @@ struct minstrel_ht_sta { /* current MCS group to be sampled */ u8 sample_group; - u8 cck_supported; - u8 cck_supported_short; - /* Bitfield of supported MCS rates of all groups */ u16 supported[MINSTREL_GROUPS_NB]; -- 2.28.0