blob: 1f115ef12d2d175cc61c7e66d10c71d7fc58abbd [file] [log] [blame]
developerd2c03a22022-12-13 11:09:19 +08001From 8fe4d8388de19d99992da0dd6ba0ae90ed4141e9 Mon Sep 17 00:00:00 2001
2From: mtk31095 <michael-cy.lee@mediatek.com>
3Date: Fri, 16 Dec 2022 10:37:53 +0800
4Subject: [PATCH] mac80211: mtk: check the control channel before downgrading
5 the bandwidth
6
7Signed-off-by: mtk31095 <michael-cy.lee@mediatek.com>
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 f97bf2b..8ee325a 100644
14--- a/net/mac80211/mlme.c
15+++ b/net/mac80211/mlme.c
16@@ -5019,6 +5019,26 @@ ieee80211_verify_sta_he_mcs_support(struct ieee80211_sub_if_data *sdata,
17 return false;
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+ mutex_lock(&local->chanctx_mtx);
27+ list_for_each_entry(ctx, &local->chanctx_list, list) {
28+ if (ctx->replace_state == IEEE80211_CHANCTX_WILL_BE_REPLACED)
29+ continue;
30+ if (ctx->mode == IEEE80211_CHANCTX_EXCLUSIVE)
31+ continue;
32+ if (chandef->chan == ctx->conf.def.chan)
33+ return true;
34+ }
35+
36+ mutex_unlock(&local->chanctx_mtx);
37+ return false;
38+}
39+
40 static int ieee80211_prep_channel(struct ieee80211_sub_if_data *sdata,
41 struct cfg80211_bss *cbss)
42 {
43@@ -5179,6 +5199,9 @@ static int ieee80211_prep_channel(struct ieee80211_sub_if_data *sdata,
44 chandef.width == NL80211_CHAN_WIDTH_10)
45 goto out;
46
47+ if (!ret || !ieee80211_check_same_ctrl_channel(sdata, &chandef))
48+ goto out;
49+
50 while (ret && chandef.width != NL80211_CHAN_WIDTH_20_NOHT) {
51 ifmgd->flags |= ieee80211_chandef_downgrade(&chandef);
52 ret = ieee80211_vif_use_channel(sdata, &chandef,
53--
542.25.1
55