[][MAC80211][core][Fix channel switch failed issue while switching to the same control channel but different bw]

[Description]
Fix channel switch failed issue while switching to the same control channel but different bw.
It will fail since switch_vif_chanctx is not supported by mt76.
However, switch_vif_chanctx should not be called when driver does not
use chanctx.

[Release-log]
N/A

Change-Id: Id9b7a698dbacafafc4dd6c19517c15a895986e0f
Reviewed-on: https://gerrit.mediatek.inc/c/openwrt/feeds/mtk_openwrt_feeds/+/7853699
diff --git a/autobuild_mac80211_release/package/kernel/mac80211_dev/patches/subsys/mtk-0021-mac80211-mtk-avoid-calling-switch_vif_chanctx-when-u.patch b/autobuild_mac80211_release/package/kernel/mac80211_dev/patches/subsys/mtk-0021-mac80211-mtk-avoid-calling-switch_vif_chanctx-when-u.patch
new file mode 100644
index 0000000..d9fcacf
--- /dev/null
+++ b/autobuild_mac80211_release/package/kernel/mac80211_dev/patches/subsys/mtk-0021-mac80211-mtk-avoid-calling-switch_vif_chanctx-when-u.patch
@@ -0,0 +1,40 @@
+From d5104c3407f3f1d476d072a8242ba40cc96ae566 Mon Sep 17 00:00:00 2001
+From: StanleyYP Wang <StanleyYP.Wang@mediatek.com>
+Date: Mon, 7 Aug 2023 19:00:53 +0800
+Subject: [PATCH] mac80211: mtk: avoid calling switch_vif_chanctx when
+ use_chanctx is false
+
+Signed-off-by: StanleyYP Wang <StanleyYP.Wang@mediatek.com>
+---
+ net/mac80211/chan.c | 14 ++++++++------
+ 1 file changed, 8 insertions(+), 6 deletions(-)
+
+diff --git a/net/mac80211/chan.c b/net/mac80211/chan.c
+index dbc34fb..f9d1a8a 100644
+--- a/net/mac80211/chan.c
++++ b/net/mac80211/chan.c
+@@ -1280,13 +1280,15 @@ ieee80211_link_use_reserved_reassign(struct ieee80211_link_data *link)
+ 	list_del(&link->reserved_chanctx_list);
+ 	link->reserved_chanctx = NULL;
+ 
+-	err = drv_switch_vif_chanctx(local, vif_chsw, 1,
+-				     CHANCTX_SWMODE_REASSIGN_VIF);
+-	if (err) {
+-		if (ieee80211_chanctx_refcount(local, new_ctx) == 0)
+-			ieee80211_free_chanctx(local, new_ctx);
++	if (local->use_chanctx) {
++		err = drv_switch_vif_chanctx(local, vif_chsw, 1,
++					     CHANCTX_SWMODE_REASSIGN_VIF);
++		if (err) {
++			if (ieee80211_chanctx_refcount(local, new_ctx) == 0)
++				ieee80211_free_chanctx(local, new_ctx);
+ 
+-		goto out;
++			goto out;
++		}
+ 	}
+ 
+ 	list_move(&link->assigned_chanctx_list, &new_ctx->assigned_links);
+-- 
+2.18.0
+