From patchwork Tue Oct 26 20:41:44 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Seiderer X-Patchwork-Id: 12585659 X-Patchwork-Delegate: johannes@sipsolutions.net 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 mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id E1EBCC433FE for ; Tue, 26 Oct 2021 20:41:58 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id BF7F460EFF for ; Tue, 26 Oct 2021 20:41:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239256AbhJZUoU (ORCPT ); Tue, 26 Oct 2021 16:44:20 -0400 Received: from mout.gmx.net ([212.227.17.22]:58335 "EHLO mout.gmx.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235537AbhJZUoU (ORCPT ); Tue, 26 Oct 2021 16:44:20 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.net; s=badeba3b8450; t=1635280906; bh=v+XY08vZpQVeYCTLMobBSviFEDs9CwqOP/SAnjIBBL8=; h=X-UI-Sender-Class:From:To:Cc:Subject:Date; b=QEv6Dto0WCSib72OloIbko36ITuSrvUjOXLZrsURjstxi3b+/bk4cZGwEFcdS5bsP KBMWA4dlcyngM80OkyXTfazyZPStjRB1k/YwIkOJ8qQ12iIU2dbpR1wd+skvFNWSlA pHZJJN0JBnspvL21ZT4zwx6QR5gdGCf9wmupH45E= X-UI-Sender-Class: 01bb95c1-4bf8-414a-932a-4f6e2808ef9c Received: from localhost.fritz.box ([62.216.209.136]) by mail.gmx.net (mrgmx104 [212.227.17.168]) with ESMTPSA (Nemesis) id 1MG9g4-1mR9Ow0tgq-00GZK6; Tue, 26 Oct 2021 22:41:46 +0200 From: Peter Seiderer To: linux-wireless@vger.kernel.org Cc: Johannes Berg , "David S . Miller" , Jakub Kicinski , Felix Fietkau , linux-kernel@vger.kernel.org, netdev@vger.kernel.org Subject: [RFC v1] mac80211: minstrel_ht: respect RTS threshold setting Date: Tue, 26 Oct 2021 22:41:44 +0200 Message-Id: <20211026204144.29250-1-ps.report@gmx.net> X-Mailer: git-send-email 2.33.1 MIME-Version: 1.0 X-Provags-ID: V03:K1:pR+qU758i91AxY7933p+jceGVA+yXismQySMPccxp7XPI/i2JVy CpQNLcy8mBk+1xdHrXS+ZQT2/fhzWNQNPts81tvZTvWBLmh5ZfUEvM9CFQk8TPUd5rH+LO+ xffPoHK09y9irptrajUuIeai9/XHPz03J0RJjg3HaaTQ4AdLwmchCVYUcTpPLV0rUby8MsM trLV3PrIP03Hflgvd/FiQ== X-UI-Out-Filterresults: notjunk:1;V03:K0:IYD0AfuUPHQ=:WWOuUupcMAInMVdcYeCvWi PAYfa271PiPntCblNjnQywoqEZBotHhRCEFzcTX8JCAleMjp/oonaZAiRfe7HsMIzORHty0E6 NhxqtWaTT79VbUgH48dZotd0q2QOP/qPoMT3m8M+vS6yNyt9VFJ2BOlQu4AdUpSZN9zH3TOwx XjD4XKBTDo84DuaS24r/36I/vcnz4pwy2JcENAN17FCS1sy0bgaEXzvZuAs12UNG/q5hN/tfN RR9OREmEAbxqCeIKGdzV9skERIgnhhPC8G4ic/EmPyfW/xW1Bhjylc7YDXQQ4umQoL4xkmBNC fNRMzeFMr8KNjsNUAeY0xTOes8x6saQkAaBenJZU2uZSfMtoWqXevrJ/9wXVHmAuw7RtzzAR7 OXpqT4RchBkzVCUeJeLjp95PKQk3+FzlDzWBF/Lnw2LjeJy9aatqPTnWP1zQbngaMiFlFeyHO YDMaY3Y8XDl6nHaiLKtOFh41C+0SLyDDCbxH4bgORCHk1EHwMnmbO4F30kGlj9KqwdAY1M9T3 LjBI8e/igD/Zj2BrYjlsiunv8tcM+qdKE2aadBBAnzcGvUmhmDLjT+AHuXEycwyrAYYbeqBOI oJ4Y49FoYf2pALKD2lZqBfWYIB0/pC9KuOtY5RPZYI7kF4aPkXyFmBoaWAWAYOcc78hBxAsUc awDusDfoeUhHANUu/eBNm6PAwozx1lQOrHue+LJMZxgfEkH6mlN3gZktsQgDqUyD8oECzx/+I PFkFRWeVaGOPrVkN5M3NEvnje/hpQIznQH9otJE8YHeiVQ/4znZ1HWlyYl/5heVagItdub8QQ z4aNTUrxqoiYMo+HbEzHQhTDf2N3o4ldzXF+4E3yOZ3n92UW2YEU3qk7/zWiqbJL3fcy2eq3G AxoxS5ipm5t6rVdJR26tj+aaF4db/gBizUfSAHWf/7xMKvLBNCh79aI8cscZjTnO4DZnQYrK7 CvkNVXJovEFYGlG+3C0z2cUShZ95zitVR6j8Ma8Vj5TV5aTiUbM3967lZ9IHcA8vdWGEDJP1M kRpV8sOKIx99jfwOqCxfc+WJetqSqk+IE6XZn+TQT69GqUOpibJDGgfa41uT0SI7gCAOznS5U 4pLnseQ6RkQK4E= Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org Despite the 'RTS thr:off' setting a wireshark trace of IBSS traffic with HT40 mode enabled between two ath9k cards revealed some RTS/CTS traffic. Debug and code analysis showed that most places setting IEEE80211_TX_RC_USE_RTS_CTS respect the RTS strategy by evaluating rts_threshold, e.g. net/mac80211/tx.c: 698 /* set up RTS protection if desired */ 699 if (len > tx->local->hw.wiphy->rts_threshold) { 700 txrc.rts = true; 701 } 702 703 info->control.use_rts = txrc.rts; or drivers/net/wireless/ath/ath9k/xmit.c 1238 /* 1239 * Handle RTS threshold for unaggregated HT frames. 1240 */ 1241 if (bf_isampdu(bf) && !bf_isaggr(bf) && 1242 (rates[i].flags & IEEE80211_TX_RC_MCS) && 1243 unlikely(rts_thresh != (u32) -1)) { 1244 if (!rts_thresh || (len > rts_thresh)) 1245 rts = true; 1246 } The only place setting IEEE80211_TX_RC_USE_RTS_CTS unconditionally was found in net/mac80211/rc80211_minstrel_ht.c. Fix this by propagating the calculated use_rts value to the minstrel_ht_set_rate() function and evaluate it accordingly before setting IEEE80211_TX_RC_USE_RTS_CTS. Signed-off-by: Peter Seiderer --- net/mac80211/rc80211_minstrel_ht.c | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/net/mac80211/rc80211_minstrel_ht.c b/net/mac80211/rc80211_minstrel_ht.c index 72b44d4c42d0..f52edef443fa 100644 --- a/net/mac80211/rc80211_minstrel_ht.c +++ b/net/mac80211/rc80211_minstrel_ht.c @@ -276,7 +276,8 @@ static const u8 minstrel_sample_seq[] = { }; static void -minstrel_ht_update_rates(struct minstrel_priv *mp, struct minstrel_ht_sta *mi); +minstrel_ht_update_rates(struct minstrel_priv *mp, struct minstrel_ht_sta *mi, + bool use_rts); /* * Some VHT MCSes are invalid (when Ndbps / Nes is not an integer) @@ -1254,7 +1255,7 @@ minstrel_ht_tx_status(void *priv, struct ieee80211_supported_band *sband, } if (update) - minstrel_ht_update_rates(mp, mi); + minstrel_ht_update_rates(mp, mi, info->control.use_rts); } static void @@ -1319,7 +1320,8 @@ minstrel_calc_retransmit(struct minstrel_priv *mp, struct minstrel_ht_sta *mi, static void minstrel_ht_set_rate(struct minstrel_priv *mp, struct minstrel_ht_sta *mi, - struct ieee80211_sta_rates *ratetbl, int offset, int index) + struct ieee80211_sta_rates *ratetbl, int offset, int index, + bool use_rts) { int group_idx = MI_RATE_GROUP(index); const struct mcs_group *group = &minstrel_mcs_groups[group_idx]; @@ -1357,7 +1359,7 @@ minstrel_ht_set_rate(struct minstrel_priv *mp, struct minstrel_ht_sta *mi, * - if station is in dynamic SMPS (and streams > 1) * - for fallback rates, to increase chances of getting through */ - if (offset > 0 || + if ((offset > 0 && use_rts) || (mi->sta->smps_mode == IEEE80211_SMPS_DYNAMIC && group->streams > 1)) { ratetbl->rate[offset].count = ratetbl->rate[offset].count_rts; @@ -1426,7 +1428,8 @@ minstrel_ht_get_max_amsdu_len(struct minstrel_ht_sta *mi) } static void -minstrel_ht_update_rates(struct minstrel_priv *mp, struct minstrel_ht_sta *mi) +minstrel_ht_update_rates(struct minstrel_priv *mp, struct minstrel_ht_sta *mi, + bool use_rts) { struct ieee80211_sta_rates *rates; int i = 0; @@ -1436,15 +1439,15 @@ minstrel_ht_update_rates(struct minstrel_priv *mp, struct minstrel_ht_sta *mi) return; /* Start with max_tp_rate[0] */ - minstrel_ht_set_rate(mp, mi, rates, i++, mi->max_tp_rate[0]); + minstrel_ht_set_rate(mp, mi, rates, i++, mi->max_tp_rate[0], use_rts); if (mp->hw->max_rates >= 3) { /* At least 3 tx rates supported, use max_tp_rate[1] next */ - minstrel_ht_set_rate(mp, mi, rates, i++, mi->max_tp_rate[1]); + minstrel_ht_set_rate(mp, mi, rates, i++, mi->max_tp_rate[1], use_rts); } if (mp->hw->max_rates >= 2) { - minstrel_ht_set_rate(mp, mi, rates, i++, mi->max_prob_rate); + minstrel_ht_set_rate(mp, mi, rates, i++, mi->max_prob_rate, use_rts); } mi->sta->max_rc_amsdu_len = minstrel_ht_get_max_amsdu_len(mi); @@ -1705,7 +1708,7 @@ minstrel_ht_update_caps(void *priv, struct ieee80211_supported_band *sband, /* create an initial rate table with the lowest supported rates */ minstrel_ht_update_stats(mp, mi); - minstrel_ht_update_rates(mp, mi); + minstrel_ht_update_rates(mp, mi, false); } static void