From c7830b531967cdcbcec5172877e5f0cb1766fc8a Mon Sep 17 00:00:00 2001 From: David Bauer Date: Sun, 23 Jan 2022 14:15:53 +0100 Subject: [PATCH] policy: add min_snr_kick_delay Currently the min_snr option will result in kicking clients the first time their SNR dips below. This might not be desirable, as drivers (notably ath10k) sometimes report a much lower RSSI for a short timeframe after returning to sensible values. Also, a device might be in the process of roaming just to be kicked before. Add the min_snr_kick_delay option. A client will be kicked after this timeframe when it's SNR is below the min_snr threshold value over the complete timeframe. Signed-off-by: David Bauer --- main.c | 2 ++ openwrt/usteer/files/etc/config/usteer | 3 +++ openwrt/usteer/files/etc/init.d/usteer | 2 +- policy.c | 10 +++++++++- ubus.c | 1 + usteer.h | 3 +++ 6 files changed, 19 insertions(+), 2 deletions(-) diff --git a/main.c b/main.c index 901a133..d8fdbf0 100644 --- a/main.c +++ b/main.c @@ -103,6 +103,8 @@ void usteer_init_defaults(void) config.roam_scan_interval = 10 * 1000; config.roam_trigger_interval = 60 * 1000; + config.min_snr_kick_delay = 5 * 1000; + config.load_kick_enabled = false; config.load_kick_threshold = 75; config.load_kick_delay = 10 * 1000; diff --git a/openwrt/usteer/files/etc/config/usteer b/openwrt/usteer/files/etc/config/usteer index cedb881..92e9443 100644 --- a/openwrt/usteer/files/etc/config/usteer +++ b/openwrt/usteer/files/etc/config/usteer @@ -56,6 +56,9 @@ config usteer # Minimum signal-to-noise ratio or signal level (dBm) to remain connected #option min_snr 0 + # Timeout after which a station with snr < min_snr will be kicked + #option min_snr_kick_delay 5000 + # Timeout (in ms) after which a association following a disassociation is not seen # as a roam #option roam_process_timeout 5000 diff --git a/openwrt/usteer/files/etc/init.d/usteer b/openwrt/usteer/files/etc/init.d/usteer index f05d8c4..921cccb 100755 --- a/openwrt/usteer/files/etc/init.d/usteer +++ b/openwrt/usteer/files/etc/init.d/usteer @@ -78,7 +78,7 @@ uci_usteer() { max_neighbor_reports max_retry_band seen_policy_timeout \ load_balancing_threshold band_steering_threshold \ remote_update_interval remote_node_timeout\ - min_connect_snr min_snr signal_diff_threshold \ + min_connect_snr min_snr min_snr_kick_delay signal_diff_threshold \ initial_connect_delay roam_process_timeout\ roam_kick_delay roam_scan_tries roam_scan_timeout \ roam_scan_snr roam_scan_interval \ diff --git a/policy.c b/policy.c index 9d03b30..29572f3 100644 --- a/policy.c +++ b/policy.c @@ -422,6 +422,7 @@ usteer_local_node_roam_check(struct usteer_local_node *ln, struct uevent *ev) static void usteer_local_node_snr_kick(struct usteer_local_node *ln) { + unsigned int min_count = DIV_ROUND_UP(config.min_snr_kick_delay, config.local_sta_update); struct uevent ev = { .node_local = &ln->node, }; @@ -438,7 +439,14 @@ usteer_local_node_snr_kick(struct usteer_local_node *ln) if (si->connected != STA_CONNECTED) continue; - if (si->signal >= min_signal) + if (si->signal >= min_signal) { + si->below_min_snr = 0; + continue; + } else { + si->below_min_snr++; + } + + if (si->below_min_snr <= min_count) continue; si->kick_count++; diff --git a/ubus.c b/ubus.c index eb5d0ff..6960464 100644 --- a/ubus.c +++ b/ubus.c @@ -156,6 +156,7 @@ struct cfg_item { _cfg(BOOL, assoc_steering), \ _cfg(I32, min_connect_snr), \ _cfg(I32, min_snr), \ + _cfg(U32, min_snr_kick_delay), \ _cfg(U32, roam_process_timeout), \ _cfg(I32, roam_scan_snr), \ _cfg(U32, roam_scan_tries), \ diff --git a/usteer.h b/usteer.h index 31ba1e4..f4ba800 100644 --- a/usteer.h +++ b/usteer.h @@ -165,6 +165,7 @@ struct usteer_config { uint32_t remote_node_timeout; int32_t min_snr; + uint32_t min_snr_kick_delay; int32_t min_connect_snr; uint32_t signal_diff_threshold; @@ -242,6 +243,8 @@ struct sta_info { int kick_count; + uint32_t below_min_snr; + uint8_t scan_band : 1; uint8_t connected : 2; }; -- 2.30.2