Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp5463756pxu; Tue, 22 Dec 2020 18:54:15 -0800 (PST) X-Google-Smtp-Source: ABdhPJwNNM+jNasbA4Z5E4yY/IWbnW8AY3+PnDqgGRCMabw747b4zKBK9Gw+lY02TDF3pRxoKz4g X-Received: by 2002:a17:906:52d9:: with SMTP id w25mr21894920ejn.504.1608692054771; Tue, 22 Dec 2020 18:54:14 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1608692054; cv=none; d=google.com; s=arc-20160816; b=x4K41OgMGyA0+/w8KHRr7VfZfjVoG95jiWCvc2yC9x2WceU7hcHT4JykTNHaxuKvK7 UGmJroN1v3yWA/EPNHwScGaFdKHNISBtCQy5obC8GXqSQcdc9FxL8KpBGlW8a2GKy7IB 6LL+Khy0hbbyVyg3YbvAvMeWllQOmVdYlF93vk0Gc4urVRt8kmplCafStqU/z93QEQpw PpDDC4shYz972J/ova81gn6rR1v8w7YKNsne018cR7tpQJ9mq4VlPQjpFfBYIWLo7nbf nuJUVxG5v51oxcnxm1mYmmcUX16r6Vh1NI6+CJZXPghVyLJJBnIoM0zebYMnAvmCQDcE iQJw== 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=9MzqpkcQelvmLkwqaCn73N7ZXE0tDwuKnWfD5XcAASk=; b=lnccrDIeoKjzdMa9BQMppmPGLHYGZUX2g6CmLXjsbgP2qC0GbhAoZpJ4TY8paKsHNm o8ans+tB3YSpW6Aaizah3yRteaXtXjFK73GdtdDTEsRZUEdc493jtCBQ3ibqnYxhzi1m wCAQrZ76kp0MUS5PzIVVQ80hQu9RyGxJuwxQWqOiNoToB58VHww0JpvZn27zYmwXN6vp ggx39jbYtzdSs1SVYKojmJFf03yOuuwshkclLM/KWqLUH/qMqlbXKkbodl4LQZRmeiu9 VpZXhVJsFx4PfHzYaay/QQqn+dMvTD3GNNSk2sL5nM5BqCllqxlUw+VVEdVnOKL9pSQr RE2A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=hY8qtndb; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id s18si4685635eji.645.2020.12.22.18.53.52; Tue, 22 Dec 2020 18:54:14 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=hY8qtndb; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731156AbgLWCx0 (ORCPT + 99 others); Tue, 22 Dec 2020 21:53:26 -0500 Received: from mail.kernel.org ([198.145.29.99]:49690 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729258AbgLWCVO (ORCPT ); Tue, 22 Dec 2020 21:21:14 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id 890F0225AB; Wed, 23 Dec 2020 02:20:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1608690055; bh=o+1RjxRe1FBsODrZ9EI+1ezlVWFVys7WHHVS8yBV1As=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=hY8qtndb7MhH6d5LB2wv0GkVsVUE8OvAXyK4/z9lL8nbSsz2Tm8OJ345cdlX6Vxq6 5ROiJQ+UWZQDcBiWvexL6wUYGFUnGtHOQ1PfPPfhRdks6FJrjrtgpy8Hq9ocXEGi6c rW2GW7yO85JAb2WfL/+WdTo0drTbrhMpGpXpGmfcd9vxWZROeEc3kiUWiMO+wRLJk3 pOj90+RIZF8kaeA0QVCHz5O2lMGl8ijsE8cqESbI4uAmAMBRcnHLkwzvPW9J2JxqJC ouHZSnTEFZJTFn2Q+CvM1SqX+2TzH1QadzeUjW0Ra1anCSboWQ/8oYeRF7STBG88vy Bu2uTcpwJBOiA== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Ilan Peer , Luca Coelho , Johannes Berg , Sasha Levin , linux-wireless@vger.kernel.org, netdev@vger.kernel.org Subject: [PATCH AUTOSEL 5.4 125/130] mac80211: Update rate control on channel change Date: Tue, 22 Dec 2020 21:18:08 -0500 Message-Id: <20201223021813.2791612-125-sashal@kernel.org> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20201223021813.2791612-1-sashal@kernel.org> References: <20201223021813.2791612-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Ilan Peer [ Upstream commit 44b72ca8163b8cf94384a11fdec716f5478411bf ] A channel change or a channel bandwidth change can impact the rate control logic. However, the rate control logic was not updated before/after such a change, which might result in unexpected behavior. Fix this by updating the stations rate control logic when the corresponding channel context changes. Signed-off-by: Ilan Peer Signed-off-by: Luca Coelho Link: https://lore.kernel.org/r/iwlwifi.20201206145305.600d967fe3c9.I48305f25cfcc9c032c77c51396e9e9b882748a86@changeid Signed-off-by: Johannes Berg Signed-off-by: Sasha Levin --- net/mac80211/chan.c | 61 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 61 insertions(+) diff --git a/net/mac80211/chan.c b/net/mac80211/chan.c index aae4b36dd78d1..4f0d676e6e2c1 100644 --- a/net/mac80211/chan.c +++ b/net/mac80211/chan.c @@ -9,6 +9,7 @@ #include #include "ieee80211_i.h" #include "driver-ops.h" +#include "rate.h" static int ieee80211_chanctx_num_assigned(struct ieee80211_local *local, struct ieee80211_chanctx *ctx) @@ -340,10 +341,42 @@ void ieee80211_recalc_chanctx_min_def(struct ieee80211_local *local, drv_change_chanctx(local, ctx, IEEE80211_CHANCTX_CHANGE_MIN_WIDTH); } +static void ieee80211_chan_bw_change(struct ieee80211_local *local, + struct ieee80211_chanctx *ctx) +{ + struct sta_info *sta; + struct ieee80211_supported_band *sband = + local->hw.wiphy->bands[ctx->conf.def.chan->band]; + + rcu_read_lock(); + list_for_each_entry_rcu(sta, &local->sta_list, + list) { + enum ieee80211_sta_rx_bandwidth new_sta_bw; + + if (!ieee80211_sdata_running(sta->sdata)) + continue; + + if (rcu_access_pointer(sta->sdata->vif.chanctx_conf) != + &ctx->conf) + continue; + + new_sta_bw = ieee80211_sta_cur_vht_bw(sta); + if (new_sta_bw == sta->sta.bandwidth) + continue; + + sta->sta.bandwidth = new_sta_bw; + rate_control_rate_update(local, sband, sta, + IEEE80211_RC_BW_CHANGED); + } + rcu_read_unlock(); +} + static void ieee80211_change_chanctx(struct ieee80211_local *local, struct ieee80211_chanctx *ctx, const struct cfg80211_chan_def *chandef) { + enum nl80211_chan_width width; + if (cfg80211_chandef_identical(&ctx->conf.def, chandef)) { ieee80211_recalc_chanctx_min_def(local, ctx); return; @@ -351,7 +384,25 @@ static void ieee80211_change_chanctx(struct ieee80211_local *local, WARN_ON(!cfg80211_chandef_compatible(&ctx->conf.def, chandef)); + width = ctx->conf.def.width; ctx->conf.def = *chandef; + + /* expected to handle only 20/40/80/160 channel widths */ + switch (chandef->width) { + case NL80211_CHAN_WIDTH_20_NOHT: + case NL80211_CHAN_WIDTH_20: + case NL80211_CHAN_WIDTH_40: + case NL80211_CHAN_WIDTH_80: + case NL80211_CHAN_WIDTH_80P80: + case NL80211_CHAN_WIDTH_160: + break; + default: + WARN_ON(1); + } + + if (chandef->width < width) + ieee80211_chan_bw_change(local, ctx); + drv_change_chanctx(local, ctx, IEEE80211_CHANCTX_CHANGE_WIDTH); ieee80211_recalc_chanctx_min_def(local, ctx); @@ -359,6 +410,9 @@ static void ieee80211_change_chanctx(struct ieee80211_local *local, local->_oper_chandef = *chandef; ieee80211_hw_config(local, 0); } + + if (chandef->width > width) + ieee80211_chan_bw_change(local, ctx); } static struct ieee80211_chanctx * @@ -1041,8 +1095,14 @@ ieee80211_vif_use_reserved_reassign(struct ieee80211_sub_if_data *sdata) if (WARN_ON(!chandef)) return -EINVAL; + if (old_ctx->conf.def.width > new_ctx->conf.def.width) + ieee80211_chan_bw_change(local, new_ctx); + ieee80211_change_chanctx(local, new_ctx, chandef); + if (old_ctx->conf.def.width < new_ctx->conf.def.width) + ieee80211_chan_bw_change(local, new_ctx); + vif_chsw[0].vif = &sdata->vif; vif_chsw[0].old_ctx = &old_ctx->conf; vif_chsw[0].new_ctx = &new_ctx->conf; @@ -1433,6 +1493,7 @@ static int ieee80211_vif_use_reserved_switch(struct ieee80211_local *local) ieee80211_recalc_smps_chanctx(local, ctx); ieee80211_recalc_radar_chanctx(local, ctx); ieee80211_recalc_chanctx_min_def(local, ctx); + ieee80211_chan_bw_change(local, ctx); list_for_each_entry_safe(sdata, sdata_tmp, &ctx->reserved_vifs, reserved_chanctx_list) { -- 2.27.0