developer | ed7222c | 2023-04-14 07:19:52 +0800 | [diff] [blame^] | 1 | From c34a03c59c59f000b6f77387e88bc10800dcb466 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 | ed7222c | 2023-04-14 07:19:52 +0800 | [diff] [blame^] | 4 | Subject: [PATCH 10/16] 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 |
| 12 | index 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 | -- |
developer | aab8333 | 2023-03-07 18:17:19 +0800 | [diff] [blame] | 53 | 2.18.0 |
developer | 77ffbda | 2022-12-16 04:36:08 +0800 | [diff] [blame] | 54 | |