blob: ce63f41f2bfe9cb4438dc9fffdd917ed066c7c22 [file] [log] [blame]
developer43a264f2024-03-26 14:09:54 +08001From a2cb7d582c92644990fb3833b70ea3f18a539a02 Mon Sep 17 00:00:00 2001
developer2aa1e642022-12-19 11:33:22 +08002From: Evelyn Tsai <evelyn.tsai@mediatek.com>
3Date: Fri, 16 Dec 2022 03:31:06 +0800
developerd243af02023-12-21 14:49:33 +08004Subject: [PATCH 07/37] mtk: mac80211: check the control channel before
developer2aa1e642022-12-19 11:33:22 +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
developer43a264f2024-03-26 14:09:54 +080012index 73f8df0..24d34d4 100644
developer2aa1e642022-12-19 11:33:22 +080013--- a/net/mac80211/mlme.c
14+++ b/net/mac80211/mlme.c
developer43a264f2024-03-26 14:09:54 +080015@@ -4814,6 +4814,26 @@ ieee80211_verify_sta_eht_mcs_support(struct ieee80211_sub_if_data *sdata,
developere35b8e42023-10-16 11:04:00 +080016 return true;
developer2aa1e642022-12-19 11:33:22 +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,
developer43a264f2024-03-26 14:09:54 +080042@@ -5056,6 +5076,9 @@ static int ieee80211_prep_channel(struct ieee80211_sub_if_data *sdata,
developer2aa1e642022-12-19 11:33:22 +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--
developerd243af02023-12-21 14:49:33 +0800532.18.0
developer2aa1e642022-12-19 11:33:22 +080054