blob: 4671638038844cc6eddc525c484d096f73331ffc [file] [log] [blame]
From 32cfa2d7e115d5cdeeb130fbec61a248e9fe3676 Mon Sep 17 00:00:00 2001
From: Evelyn Tsai <evelyn.tsai@mediatek.com>
Date: Fri, 16 Dec 2022 03:31:06 +0800
Subject: [PATCH 13/61] mtk: mac80211: check the control channel before
downgrading the bandwidth
Change-Id: I25f0495818194a18e4acf23d6c45393f12e32080
---
net/mac80211/mlme.c | 23 +++++++++++++++++++++++
1 file changed, 23 insertions(+)
diff --git a/net/mac80211/mlme.c b/net/mac80211/mlme.c
index b653c7d..77e5898 100644
--- a/net/mac80211/mlme.c
+++ b/net/mac80211/mlme.c
@@ -4994,6 +4994,26 @@ ieee80211_determine_our_sta_mode_assoc(struct ieee80211_sub_if_data *sdata,
conn->bw_limit, tmp.bw_limit);
}
+static bool ieee80211_check_same_ctrl_channel(struct ieee80211_sub_if_data *sdata,
+ const struct cfg80211_chan_def *chandef)
+{
+ struct ieee80211_local *local = sdata->local;
+ struct ieee80211_chanctx *ctx;
+
+ lockdep_assert_wiphy(local->hw.wiphy);
+
+ list_for_each_entry(ctx, &local->chanctx_list, list) {
+ if (ctx->replace_state == IEEE80211_CHANCTX_WILL_BE_REPLACED)
+ continue;
+ if (ctx->mode == IEEE80211_CHANCTX_EXCLUSIVE)
+ continue;
+ if (chandef->chan == ctx->conf.def.chan)
+ return true;
+ }
+
+ return false;
+}
+
static int ieee80211_prep_channel(struct ieee80211_sub_if_data *sdata,
struct ieee80211_link_data *link,
int link_id,
@@ -5073,6 +5093,9 @@ static int ieee80211_prep_channel(struct ieee80211_sub_if_data *sdata,
chanreq.oper.width == NL80211_CHAN_WIDTH_10)
return ret;
+ if (!ret || !ieee80211_check_same_ctrl_channel(sdata, &chanreq.oper))
+ return ret;
+
while (ret && chanreq.oper.width != NL80211_CHAN_WIDTH_20_NOHT) {
ieee80211_chanreq_downgrade(&chanreq, conn);
--
2.39.2