[][MAC80211][core][Add support to disable ZWDFS CAC when its channel is overlapped with operating channel]

[Description]
Add support to disable ZWDFS CAC when its channel is overlapped with
operating channel

[Release-log]
N/A

Change-Id: I66419a910ead719a7d8d9168da73a7e2cd888356
Reviewed-on: https://gerrit.mediatek.inc/c/openwrt/feeds/mtk_openwrt_feeds/+/7715824
diff --git a/autobuild_mac80211_release/package/kernel/mac80211/patches/subsys/mtk-0020-cfg80211-mtk-fix-early-return-in-cfg80211_stop_backg.patch b/autobuild_mac80211_release/package/kernel/mac80211/patches/subsys/mtk-0020-cfg80211-mtk-fix-early-return-in-cfg80211_stop_backg.patch
new file mode 100644
index 0000000..59dca9f
--- /dev/null
+++ b/autobuild_mac80211_release/package/kernel/mac80211/patches/subsys/mtk-0020-cfg80211-mtk-fix-early-return-in-cfg80211_stop_backg.patch
@@ -0,0 +1,29 @@
+From b95d01bc1cf24768794d43feac8baae225f2c2d8 Mon Sep 17 00:00:00 2001
+From: StanleyYP Wang <StanleyYP.Wang@mediatek.com>
+Date: Thu, 27 Jul 2023 10:25:59 +0800
+Subject: [PATCH 20/21] cfg80211: mtk: fix early return in
+ cfg80211_stop_background_radar_detection
+
+Signed-off-by: StanleyYP Wang <StanleyYP.Wang@mediatek.com>
+---
+ net/wireless/mlme.c | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/net/wireless/mlme.c b/net/wireless/mlme.c
+index 205c1bc..13abfc0 100644
+--- a/net/wireless/mlme.c
++++ b/net/wireless/mlme.c
+@@ -1113,9 +1113,9 @@ void cfg80211_stop_background_radar_detection(struct wireless_dev *wdev)
+ 		return;
+ 
+ 	rdev_set_radar_background(rdev, NULL);
+-	rdev->background_radar_wdev = NULL; /* Release offchain ownership */
+ 
+ 	__cfg80211_background_cac_event(rdev, wdev,
+ 					&rdev->background_radar_chandef,
+ 					NL80211_RADAR_CAC_ABORTED);
++	rdev->background_radar_wdev = NULL; /* Release offchain ownership */
+ }
+-- 
+2.18.0
+
diff --git a/autobuild_mac80211_release/package/kernel/mac80211/patches/subsys/mtk-0021-cfg80211-mtk-add-background-radar-stop-when-backgrou.patch b/autobuild_mac80211_release/package/kernel/mac80211/patches/subsys/mtk-0021-cfg80211-mtk-add-background-radar-stop-when-backgrou.patch
new file mode 100644
index 0000000..2d81600
--- /dev/null
+++ b/autobuild_mac80211_release/package/kernel/mac80211/patches/subsys/mtk-0021-cfg80211-mtk-add-background-radar-stop-when-backgrou.patch
@@ -0,0 +1,29 @@
+From b0c5d10ad1a23be569f168b4cc9f50cdb922b568 Mon Sep 17 00:00:00 2001
+From: StanleyYP Wang <StanleyYP.Wang@mediatek.com>
+Date: Thu, 27 Jul 2023 10:27:04 +0800
+Subject: [PATCH 21/21] cfg80211: mtk: add background radar stop when
+ background channel is overlapped with operating channel
+
+Signed-off-by: StanleyYP Wang <StanleyYP.Wang@mediatek.com>
+---
+ net/wireless/nl80211.c | 4 ++++
+ 1 file changed, 4 insertions(+)
+
+diff --git a/net/wireless/nl80211.c b/net/wireless/nl80211.c
+index 0917713..97c2833 100644
+--- a/net/wireless/nl80211.c
++++ b/net/wireless/nl80211.c
+@@ -9389,6 +9389,10 @@ static int nl80211_start_radar_detection(struct sk_buff *skb,
+ 		wdev->cac_started = true;
+ 		wdev->cac_start_time = jiffies;
+ 		wdev->cac_time_ms = cac_time_ms;
++		if (rdev->background_cac_started &&
++		    cfg80211_is_sub_chan(&chandef, rdev->background_radar_chandef.chan)) {
++			cfg80211_stop_background_radar_detection(rdev->background_radar_wdev);
++		}
+ 	}
+ unlock:
+ 	wiphy_unlock(wiphy);
+-- 
+2.18.0
+
diff --git a/autobuild_mac80211_release/package/kernel/mac80211_dev/patches/subsys/mtk-0018-cfg80211-mtk-fix-early-return-in-cfg80211_stop_backg.patch b/autobuild_mac80211_release/package/kernel/mac80211_dev/patches/subsys/mtk-0018-cfg80211-mtk-fix-early-return-in-cfg80211_stop_backg.patch
new file mode 100644
index 0000000..d57273b
--- /dev/null
+++ b/autobuild_mac80211_release/package/kernel/mac80211_dev/patches/subsys/mtk-0018-cfg80211-mtk-fix-early-return-in-cfg80211_stop_backg.patch
@@ -0,0 +1,29 @@
+From 435bf8765d44b694b86a400fb128fcf6d72b8aa6 Mon Sep 17 00:00:00 2001
+From: StanleyYP Wang <StanleyYP.Wang@mediatek.com>
+Date: Thu, 27 Jul 2023 10:25:59 +0800
+Subject: [PATCH 18/19] cfg80211: mtk: fix early return in
+ cfg80211_stop_background_radar_detection
+
+Signed-off-by: StanleyYP Wang <StanleyYP.Wang@mediatek.com>
+---
+ net/wireless/mlme.c | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/net/wireless/mlme.c b/net/wireless/mlme.c
+index 57b9bde..c2cf8aa 100644
+--- a/net/wireless/mlme.c
++++ b/net/wireless/mlme.c
+@@ -1145,9 +1145,9 @@ void cfg80211_stop_background_radar_detection(struct wireless_dev *wdev)
+ 		return;
+ 
+ 	rdev_set_radar_background(rdev, NULL);
+-	rdev->background_radar_wdev = NULL; /* Release offchain ownership */
+ 
+ 	__cfg80211_background_cac_event(rdev, wdev,
+ 					&rdev->background_radar_chandef,
+ 					NL80211_RADAR_CAC_ABORTED);
++	rdev->background_radar_wdev = NULL; /* Release offchain ownership */
+ }
+-- 
+2.18.0
+
diff --git a/autobuild_mac80211_release/package/kernel/mac80211_dev/patches/subsys/mtk-0019-cfg80211-mtk-add-background-radar-stop-when-backgrou.patch b/autobuild_mac80211_release/package/kernel/mac80211_dev/patches/subsys/mtk-0019-cfg80211-mtk-add-background-radar-stop-when-backgrou.patch
new file mode 100644
index 0000000..66d4d10
--- /dev/null
+++ b/autobuild_mac80211_release/package/kernel/mac80211_dev/patches/subsys/mtk-0019-cfg80211-mtk-add-background-radar-stop-when-backgrou.patch
@@ -0,0 +1,29 @@
+From 818c8f1d1a9ff9e5423ed0927b052692c282fdf4 Mon Sep 17 00:00:00 2001
+From: StanleyYP Wang <StanleyYP.Wang@mediatek.com>
+Date: Thu, 27 Jul 2023 10:27:04 +0800
+Subject: [PATCH 19/19] cfg80211: mtk: add background radar stop when
+ background channel is overlapped with operating channel
+
+Signed-off-by: StanleyYP Wang <StanleyYP.Wang@mediatek.com>
+---
+ net/wireless/nl80211.c | 4 ++++
+ 1 file changed, 4 insertions(+)
+
+diff --git a/net/wireless/nl80211.c b/net/wireless/nl80211.c
+index 53f32c6..ab61f8f 100644
+--- a/net/wireless/nl80211.c
++++ b/net/wireless/nl80211.c
+@@ -9852,6 +9852,10 @@ static int nl80211_start_radar_detection(struct sk_buff *skb,
+ 		wdev->cac_started = true;
+ 		wdev->cac_start_time = jiffies;
+ 		wdev->cac_time_ms = cac_time_ms;
++		if (rdev->background_cac_started &&
++		    cfg80211_is_sub_chan(&chandef, rdev->background_radar_chandef.chan, false)) {
++			cfg80211_stop_background_radar_detection(rdev->background_radar_wdev);
++		}
+ 	}
+ unlock:
+ 	wiphy_unlock(wiphy);
+-- 
+2.18.0
+