[][MAC80211][mt76][Fix DFS CAC tx emission issue during second time interface setup]

[Description]
Fix DFS CAC tx emission issue during second time interface setup.
This patch will be upstreamed later.

[Release-log]
N/A

Change-Id: I035d07b1095142de330efa90c57a53c7e9b2bf6a
Reviewed-on: https://gerrit.mediatek.inc/c/openwrt/feeds/mtk_openwrt_feeds/+/7503659
diff --git a/autobuild_mac80211_release/package/kernel/mt76/patches/0006-wifi-mt76-mt7915-fix-DFS-CAC-tx-emission-issue-after.patch b/autobuild_mac80211_release/package/kernel/mt76/patches/0006-wifi-mt76-mt7915-fix-DFS-CAC-tx-emission-issue-after.patch
new file mode 100644
index 0000000..c468427
--- /dev/null
+++ b/autobuild_mac80211_release/package/kernel/mt76/patches/0006-wifi-mt76-mt7915-fix-DFS-CAC-tx-emission-issue-after.patch
@@ -0,0 +1,40 @@
+From 11737f3523ed3dff2a2ed35b658f562478022896 Mon Sep 17 00:00:00 2001
+From: StanleyYP Wang <StanleyYP.Wang@mediatek.com>
+Date: Wed, 17 May 2023 17:34:55 +0800
+Subject: [PATCH] wifi: mt76: mt7915: fix DFS CAC tx emission issue after
+ interface down up
+
+FW's channel state is set during the first wifi interface setup. If the switch reason for
+setting the tx/rx path during second-time wifi interface setup is CH_SWITCH_NORMAL,
+then the FW would perform runtime dpd channel calibration during DFS CAC, which leads to
+tx emission. Therefore, in order to bypass tx calibration during DFS CAC, set the switch reason
+to CH_SWITCH_DFS whenever chandef is set to DFS channel.
+
+Signed-off-by: StanleyYP Wang <StanleyYP.Wang@mediatek.com>
+---
+ mt7915/mcu.c | 6 +++---
+ 1 file changed, 3 insertions(+), 3 deletions(-)
+
+diff --git a/mt7915/mcu.c b/mt7915/mcu.c
+index a9f8a88..a759214 100644
+--- a/mt7915/mcu.c
++++ b/mt7915/mcu.c
+@@ -2773,12 +2773,12 @@ int mt7915_mcu_set_chan_info(struct mt7915_phy *phy, int cmd)
+ 	if (mt76_connac_spe_idx(phy->mt76->antenna_mask))
+ 		req.tx_path_num = fls(phy->mt76->antenna_mask);
+ 
+-	if (cmd == MCU_EXT_CMD(SET_RX_PATH) ||
+-	    dev->mt76.hw->conf.flags & IEEE80211_CONF_MONITOR)
++	if (dev->mt76.hw->conf.flags & IEEE80211_CONF_MONITOR)
+ 		req.switch_reason = CH_SWITCH_NORMAL;
+ 	else if (phy->mt76->hw->conf.flags & IEEE80211_CONF_OFFCHANNEL)
+ 		req.switch_reason = CH_SWITCH_SCAN_BYPASS_DPD;
+-	else if (!cfg80211_reg_can_beacon(phy->mt76->hw->wiphy, chandef,
++	else if (cfg80211_chandef_valid(chandef) &&
++		 !cfg80211_reg_can_beacon(phy->mt76->hw->wiphy, chandef,
+ 					  NL80211_IFTYPE_AP))
+ 		req.switch_reason = CH_SWITCH_DFS;
+ 	else
+-- 
+2.18.0
+