[][MAC80211][core][Fix weather CAC time not applied issue]
[Description]
Fix weather CAC time not applied when operating channel
is overlapped with weather radar channel in ETSI.
[Release-log]
N/A
Change-Id: Ic56d6a0369dcd430f6d30e9c583e7916033f8845
Reviewed-on: https://gerrit.mediatek.inc/c/openwrt/feeds/mtk_openwrt_feeds/+/7602306
diff --git a/autobuild_mac80211_release/package/kernel/mac80211/patches/subsys/mtk-0002-cfg80211-mtk-extend-CAC-time-for-weather-radar-chann.patch b/autobuild_mac80211_release/package/kernel/mac80211/patches/subsys/mtk-0002-cfg80211-mtk-extend-CAC-time-for-weather-radar-chann.patch
new file mode 100644
index 0000000..f5b52c4
--- /dev/null
+++ b/autobuild_mac80211_release/package/kernel/mac80211/patches/subsys/mtk-0002-cfg80211-mtk-extend-CAC-time-for-weather-radar-chann.patch
@@ -0,0 +1,59 @@
+From b6a99ac9380eb282d251a349709483579186bc51 Mon Sep 17 00:00:00 2001
+From: Shayne Chen <shayne.chen@mediatek.com>
+Date: Tue, 29 Mar 2022 16:06:30 +0800
+Subject: [PATCH] cfg80211: mtk: extend CAC time for weather radar channels
+
+Signed-off-by: Shayne Chen <shayne.chen@mediatek.com>
+Signed-off-by: StanleyYP Wang <StanleyYP.Wang@mediatek.com>
+---
+ include/net/cfg80211.h | 1 +
+ net/wireless/chan.c | 6 ++++++
+ net/wireless/nl80211.c | 3 +++
+ 3 files changed, 10 insertions(+)
+
+diff --git a/include/net/cfg80211.h b/include/net/cfg80211.h
+index 8e05f55..585d934 100644
+--- a/include/net/cfg80211.h
++++ b/include/net/cfg80211.h
+@@ -142,6 +142,7 @@ enum ieee80211_channel_flags {
+ (IEEE80211_CHAN_NO_HT40PLUS | IEEE80211_CHAN_NO_HT40MINUS)
+
+ #define IEEE80211_DFS_MIN_CAC_TIME_MS 60000
++#define IEEE80211_DFS_WEATHER_MIN_CAC_TIME_MS 600000
+ #define IEEE80211_DFS_MIN_NOP_TIME_MS (30 * 60 * 1000)
+
+ /**
+diff --git a/net/wireless/chan.c b/net/wireless/chan.c
+index 5f50ac4..6b42040 100644
+--- a/net/wireless/chan.c
++++ b/net/wireless/chan.c
+@@ -843,6 +843,12 @@ static unsigned int cfg80211_get_chans_dfs_cac_time(struct wiphy *wiphy,
+ if (!(c->flags & IEEE80211_CHAN_RADAR))
+ continue;
+
++ /* weather radar in ETSI */
++ if (reg_get_dfs_region(wiphy) == NL80211_DFS_ETSI &&
++ freq >= MHZ_TO_KHZ(5590) && freq <= MHZ_TO_KHZ(5650) &&
++ dfs_cac_ms < IEEE80211_DFS_WEATHER_MIN_CAC_TIME_MS)
++ dfs_cac_ms = IEEE80211_DFS_WEATHER_MIN_CAC_TIME_MS;
++
+ if (c->dfs_cac_ms > dfs_cac_ms)
+ dfs_cac_ms = c->dfs_cac_ms;
+ }
+diff --git a/net/wireless/nl80211.c b/net/wireless/nl80211.c
+index bc6b5ac..bc07fe8 100644
+--- a/net/wireless/nl80211.c
++++ b/net/wireless/nl80211.c
+@@ -9354,6 +9354,9 @@ static int nl80211_start_radar_detection(struct sk_buff *skb,
+ if (WARN_ON(!cac_time_ms))
+ cac_time_ms = IEEE80211_DFS_MIN_CAC_TIME_MS;
+
++ pr_info("%s: region = %u, center freq1 = %u, center freq2 = %u, cac time ms = %u\n",
++ __func__, dfs_region, chandef.center_freq1, chandef.center_freq2, cac_time_ms);
++
+ err = rdev_start_radar_detection(rdev, dev, &chandef, cac_time_ms);
+ if (!err) {
+ wdev->chandef = chandef;
+--
+2.18.0
+