blob: c37aac7427172b33454d670c7f763132f81f4700 [file] [log] [blame]
developer8eb72a32023-03-30 08:32:07 +08001From f498afc5b130da3d23a2c86729368c64e487e6d8 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
developer8eb72a32023-03-30 08:32:07 +08004Subject: [PATCH 10/15] 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
12index d8484cd..8ab5c52 100644
13--- a/net/mac80211/mlme.c
14+++ b/net/mac80211/mlme.c
15@@ -4582,6 +4582,26 @@ ieee80211_verify_sta_he_mcs_support(struct ieee80211_sub_if_data *sdata,
16 return false;
17 }
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,
42@@ -4808,6 +4828,9 @@ static int ieee80211_prep_channel(struct ieee80211_sub_if_data *sdata,
43 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--
developeraab83332023-03-07 18:17:19 +0800532.18.0
developer77ffbda2022-12-16 04:36:08 +080054