blob: 6c614fe624402d039954326133b296380d5b71e1 [file] [log] [blame]
developer83ad30d2023-09-12 17:28:06 +08001From cc5889f25d7d72cf4ecbaefbe885ad654d50e730 Mon Sep 17 00:00:00 2001
developer77ffbda2022-12-16 04:36:08 +08002From: Evelyn Tsai <evelyn.tsai@mediatek.com>
3Date: Fri, 16 Dec 2022 03:31:06 +0800
developer83ad30d2023-09-12 17:28:06 +08004Subject: [PATCH 08/21] mac80211: mtk: check the control channel before
developer77ffbda2022-12-16 04:36:08 +08005 downgrading the bandwidth
6
7---
8 net/mac80211/mlme.c | 23 +++++++++++++++++++++++
9 1 file changed, 23 insertions(+)
10
11diff --git a/net/mac80211/mlme.c b/net/mac80211/mlme.c
developer83ad30d2023-09-12 17:28:06 +080012index f93eb38..86f762d 100644
developer77ffbda2022-12-16 04:36:08 +080013--- a/net/mac80211/mlme.c
14+++ b/net/mac80211/mlme.c
developer83ad30d2023-09-12 17:28:06 +080015@@ -4791,6 +4791,26 @@ ieee80211_verify_sta_eht_mcs_support(struct ieee80211_sub_if_data *sdata,
16 return true;
developer77ffbda2022-12-16 04:36:08 +080017 }
18
19+static bool ieee80211_check_same_ctrl_channel(struct ieee80211_sub_if_data *sdata,
20+ const struct cfg80211_chan_def *chandef)
21+{
22+ struct ieee80211_local *local = sdata->local;
23+ struct ieee80211_chanctx *ctx;
24+
25+ mutex_lock(&local->chanctx_mtx);
26+ list_for_each_entry(ctx, &local->chanctx_list, list) {
27+ if (ctx->replace_state == IEEE80211_CHANCTX_WILL_BE_REPLACED)
28+ continue;
29+ if (ctx->mode == IEEE80211_CHANCTX_EXCLUSIVE)
30+ continue;
31+ if (chandef->chan == ctx->conf.def.chan)
32+ return true;
33+ }
34+
35+ mutex_unlock(&local->chanctx_mtx);
36+ return false;
37+}
38+
39 static int ieee80211_prep_channel(struct ieee80211_sub_if_data *sdata,
40 struct ieee80211_link_data *link,
41 struct cfg80211_bss *cbss,
developer83ad30d2023-09-12 17:28:06 +080042@@ -5033,6 +5053,9 @@ static int ieee80211_prep_channel(struct ieee80211_sub_if_data *sdata,
developer77ffbda2022-12-16 04:36:08 +080043 chandef.width == NL80211_CHAN_WIDTH_10)
44 goto out;
45
46+ if (!ret || !ieee80211_check_same_ctrl_channel(sdata, &chandef))
47+ goto out;
48+
49 while (ret && chandef.width != NL80211_CHAN_WIDTH_20_NOHT) {
50 *conn_flags |=
51 ieee80211_chandef_downgrade(&chandef);
52--
developerebaa5512023-04-19 18:23:21 +0800532.39.2
developer77ffbda2022-12-16 04:36:08 +080054