blob: f5903f0c8e9e63029a6565007912b55ccd2c0eba [file] [log] [blame]
developer3d0130f2023-02-20 17:46:38 +08001From 750e991ce9cf04af982bb11e6058c133d205d879 Mon Sep 17 00:00:00 2001
developerd2c03a22022-12-13 11:09:19 +08002From: mtk31095 <michael-cy.lee@mediatek.com>
3Date: Fri, 16 Dec 2022 10:37:53 +0800
developer3d0130f2023-02-20 17:46:38 +08004Subject: [PATCH 12/14] mac80211: mtk: check the control channel before
developer77ffbda2022-12-16 04:36:08 +08005 downgrading the bandwidth
developerd2c03a22022-12-13 11:09:19 +08006
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--
developer3d0130f2023-02-20 17:46:38 +0800542.18.0
developerd2c03a22022-12-13 11:09:19 +080055