developer | ebaa551 | 2023-04-19 18:23:21 +0800 | [diff] [blame] | 1 | From 74dec28f086c6d919d936fb159bfb3fada5f4ca7 Mon Sep 17 00:00:00 2001 |
developer | 77ffbda | 2022-12-16 04:36:08 +0800 | [diff] [blame] | 2 | From: Evelyn Tsai <evelyn.tsai@mediatek.com> |
| 3 | Date: Fri, 16 Dec 2022 03:31:06 +0800 |
developer | ebaa551 | 2023-04-19 18:23:21 +0800 | [diff] [blame] | 4 | Subject: [PATCH 08/14] mac80211: mtk: check the control channel before |
developer | 77ffbda | 2022-12-16 04:36:08 +0800 | [diff] [blame] | 5 | downgrading the bandwidth |
| 6 | |
| 7 | --- |
| 8 | net/mac80211/mlme.c | 23 +++++++++++++++++++++++ |
| 9 | 1 file changed, 23 insertions(+) |
| 10 | |
| 11 | diff --git a/net/mac80211/mlme.c b/net/mac80211/mlme.c |
developer | ebaa551 | 2023-04-19 18:23:21 +0800 | [diff] [blame] | 12 | index d63434b..72d153f 100644 |
developer | 77ffbda | 2022-12-16 04:36:08 +0800 | [diff] [blame] | 13 | --- a/net/mac80211/mlme.c |
| 14 | +++ b/net/mac80211/mlme.c |
developer | ebaa551 | 2023-04-19 18:23:21 +0800 | [diff] [blame] | 15 | @@ -4657,6 +4657,26 @@ ieee80211_verify_sta_he_mcs_support(struct ieee80211_sub_if_data *sdata, |
developer | 77ffbda | 2022-12-16 04:36:08 +0800 | [diff] [blame] | 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, |
developer | ebaa551 | 2023-04-19 18:23:21 +0800 | [diff] [blame] | 42 | @@ -4883,6 +4903,9 @@ static int ieee80211_prep_channel(struct ieee80211_sub_if_data *sdata, |
developer | 77ffbda | 2022-12-16 04:36:08 +0800 | [diff] [blame] | 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 | -- |
developer | ebaa551 | 2023-04-19 18:23:21 +0800 | [diff] [blame] | 53 | 2.39.2 |
developer | 77ffbda | 2022-12-16 04:36:08 +0800 | [diff] [blame] | 54 | |