From 9a42d08c1b0d5cafc7a0567e7bb881c86dec167f Mon Sep 17 00:00:00 2001 From: Harshitha Prem Date: Wed, 19 Oct 2022 23:32:54 +0530 Subject: [PATCH 2/4] cfg80211: add minimum background cac timeout As per ETSI standard ETSI EN 301 893 V1.7.1 (2012-06), annex D, the DFS parameters should be as follows Minimum offchannel CAC timeout - 6 minutes Maxmimum offchannel CAC timeout - 4 hours For channels whose nominal bandwidth falls completely or partly within the band 5600 MHz to 5650 MHz, the CAC Time shall be 10 minutes. For channels whose nominal bandwidth falls completely or partly within the band 5600 MHz to 5650 MHz, the Off-Channel CAC Time shall be within the range 1 to 24 hours. Signed-off-by: Harshitha Prem --- net/wireless/chan.c | 13 +++++++++++-- net/wireless/core.h | 2 +- 2 files changed, 12 insertions(+), 3 deletions(-) Index: backports-20220822-5.4.213-ef7197996efe/net/wireless/chan.c =================================================================== --- backports-20220822-5.4.213-ef7197996efe.orig/net/wireless/chan.c 2023-05-30 15:25:55.521564440 +0530 +++ backports-20220822-5.4.213-ef7197996efe/net/wireless/chan.c 2023-05-30 15:25:55.517564430 +0530 @@ -1079,10 +1079,10 @@ static unsigned int cfg80211_get_chans_d unsigned int cfg80211_chandef_dfs_cac_time(struct wiphy *wiphy, - const struct cfg80211_chan_def *chandef) + const struct cfg80211_chan_def *chandef, bool is_bgcac) { int width; - unsigned int t1 = 0, t2 = 0; + unsigned int t1 = 0, t2 = 0, dfs_cac_time; if (WARN_ON(!cfg80211_chandef_valid(chandef))) return 0; @@ -1096,13 +1096,33 @@ cfg80211_chandef_dfs_cac_time(struct wip width, chandef->ru_punct_bitmap); if (!chandef->center_freq2) - return t1; + goto exit; t2 = cfg80211_get_chans_dfs_cac_time(wiphy, MHZ_TO_KHZ(chandef->center_freq2), width, chandef->ru_punct_bitmap); - return max(t1, t2); +exit: + dfs_cac_time = max(t1, t2); + if (is_bgcac) { + if (regulatory_pre_cac_allowed(wiphy)) { + + /* For ETSI, + off-channel CAC time = 6 * CAC time + e.g., off-channel CAC time = (6 * 60) secs = 6 mins + weather-radar off-channel CAC time = (6 * 10) mins = 1 hour + */ + dfs_cac_time = dfs_cac_time * 6; + } else { + /* For FCC, + off-channel CAC time = CAC time + 2 + e.g., off-channel CAC time = (60 + 2) seconds + */ + dfs_cac_time = dfs_cac_time + REG_BG_PRE_CAC_EXPIRY_GRACE_MS; + } + } + + return dfs_cac_time; } static bool cfg80211_secondary_chans_ok(struct wiphy *wiphy, Index: backports-20220822-5.4.213-ef7197996efe/net/wireless/core.h =================================================================== --- backports-20220822-5.4.213-ef7197996efe.orig/net/wireless/core.h 2023-05-30 15:25:55.521564440 +0530 +++ backports-20220822-5.4.213-ef7197996efe/net/wireless/core.h 2023-05-30 15:25:55.517564430 +0530 @@ -480,7 +480,7 @@ void cfg80211_dfs_channels_update_work(s unsigned int cfg80211_chandef_dfs_cac_time(struct wiphy *wiphy, - const struct cfg80211_chan_def *chandef); + const struct cfg80211_chan_def *chandef, bool is_bgcac); void cfg80211_sched_dfs_chan_update(struct cfg80211_registered_device *rdev); Index: backports-20220822-5.4.213-ef7197996efe/net/wireless/mlme.c =================================================================== --- backports-20220822-5.4.213-ef7197996efe.orig/net/wireless/mlme.c 2023-05-30 15:25:55.521564440 +0530 +++ backports-20220822-5.4.213-ef7197996efe/net/wireless/mlme.c 2023-05-30 15:25:55.517564430 +0530 @@ -1122,7 +1122,8 @@ cfg80211_start_background_radar_detectio if (err) return err; - cac_time_ms = cfg80211_chandef_dfs_cac_time(&rdev->wiphy, chandef); + cac_time_ms = cfg80211_chandef_dfs_cac_time(&rdev->wiphy, chandef, + true); if (!cac_time_ms) cac_time_ms = IEEE80211_DFS_MIN_CAC_TIME_MS; Index: backports-20220822-5.4.213-ef7197996efe/net/wireless/nl80211.c =================================================================== --- backports-20220822-5.4.213-ef7197996efe.orig/net/wireless/nl80211.c 2023-05-30 15:25:55.521564440 +0530 +++ backports-20220822-5.4.213-ef7197996efe/net/wireless/nl80211.c 2023-05-30 15:25:55.521564440 +0530 @@ -10183,7 +10183,8 @@ static int nl80211_start_radar_detection goto unlock; } - cac_time_ms = cfg80211_chandef_dfs_cac_time(&rdev->wiphy, &chandef); + cac_time_ms = cfg80211_chandef_dfs_cac_time(&rdev->wiphy, &chandef, + false); if (WARN_ON(!cac_time_ms)) cac_time_ms = IEEE80211_DFS_MIN_CAC_TIME_MS; Index: backports-20220822-5.4.213-ef7197996efe/net/wireless/reg.h =================================================================== --- backports-20220822-5.4.213-ef7197996efe.orig/net/wireless/reg.h 2023-05-12 14:29:40.000000000 +0530 +++ backports-20220822-5.4.213-ef7197996efe/net/wireless/reg.h 2023-05-30 15:26:33.597655373 +0530 @@ -154,6 +154,8 @@ bool regulatory_indoor_allowed(void); */ #define REG_PRE_CAC_EXPIRY_GRACE_MS 2000 +#define REG_BG_PRE_CAC_EXPIRY_GRACE_MS 2000 + /** * regulatory_propagate_dfs_state - Propagate DFS channel state to other wiphys * @wiphy - wiphy on which radar is detected and the event will be propagated