blob: 4671638038844cc6eddc525c484d096f73331ffc [file] [log] [blame]
developer617abbd2024-04-23 14:50:01 +08001From 32cfa2d7e115d5cdeeb130fbec61a248e9fe3676 Mon Sep 17 00:00:00 2001
2From: Evelyn Tsai <evelyn.tsai@mediatek.com>
3Date: Fri, 16 Dec 2022 03:31:06 +0800
4Subject: [PATCH 13/61] mtk: mac80211: check the control channel before
5 downgrading the bandwidth
6
7Change-Id: I25f0495818194a18e4acf23d6c45393f12e32080
8---
9 net/mac80211/mlme.c | 23 +++++++++++++++++++++++
10 1 file changed, 23 insertions(+)
11
12diff --git a/net/mac80211/mlme.c b/net/mac80211/mlme.c
13index b653c7d..77e5898 100644
14--- a/net/mac80211/mlme.c
15+++ b/net/mac80211/mlme.c
16@@ -4994,6 +4994,26 @@ ieee80211_determine_our_sta_mode_assoc(struct ieee80211_sub_if_data *sdata,
17 conn->bw_limit, tmp.bw_limit);
18 }
19
20+static bool ieee80211_check_same_ctrl_channel(struct ieee80211_sub_if_data *sdata,
21+ const struct cfg80211_chan_def *chandef)
22+{
23+ struct ieee80211_local *local = sdata->local;
24+ struct ieee80211_chanctx *ctx;
25+
26+ lockdep_assert_wiphy(local->hw.wiphy);
27+
28+ list_for_each_entry(ctx, &local->chanctx_list, list) {
29+ if (ctx->replace_state == IEEE80211_CHANCTX_WILL_BE_REPLACED)
30+ continue;
31+ if (ctx->mode == IEEE80211_CHANCTX_EXCLUSIVE)
32+ continue;
33+ if (chandef->chan == ctx->conf.def.chan)
34+ return true;
35+ }
36+
37+ return false;
38+}
39+
40 static int ieee80211_prep_channel(struct ieee80211_sub_if_data *sdata,
41 struct ieee80211_link_data *link,
42 int link_id,
43@@ -5073,6 +5093,9 @@ static int ieee80211_prep_channel(struct ieee80211_sub_if_data *sdata,
44 chanreq.oper.width == NL80211_CHAN_WIDTH_10)
45 return ret;
46
47+ if (!ret || !ieee80211_check_same_ctrl_channel(sdata, &chanreq.oper))
48+ return ret;
49+
50 while (ret && chanreq.oper.width != NL80211_CHAN_WIDTH_20_NOHT) {
51 ieee80211_chanreq_downgrade(&chanreq, conn);
52
53--
542.39.2
55