policy: add min_snr_kick_delay
authorDavid Bauer <mail@david-bauer.net>
Sun, 23 Jan 2022 13:15:53 +0000 (14:15 +0100)
committerDavid Bauer <mail@david-bauer.net>
Tue, 1 Feb 2022 17:41:57 +0000 (18:41 +0100)
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 <mail@david-bauer.net>
main.c
openwrt/usteer/files/etc/config/usteer
openwrt/usteer/files/etc/init.d/usteer
policy.c
ubus.c
usteer.h

diff --git a/main.c b/main.c
index 901a133e1c40ec9a2a993acddecaadde4f470adb..d8fdbf0421c0cf92695bc56ebf4d074f0dea1f30 100644 (file)
--- 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;
index cedb8816fe31648a00f0a556cc61a89601c85871..92e9443af9c535c21701db9a6940a683e4198e62 100644 (file)
@@ -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
index f05d8c4ab47a6c8a05bd0daee709c3b678b11b1c..921cccb9a2eb38be03ddf576162d18e429f2835c 100755 (executable)
@@ -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 \
index 9d03b30b9ba23ea6e32f44ccf939647ae82d3d00..29572f3c104582ebd5ca63c49b1d820fd8ab4091 100644 (file)
--- 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 eb5d0fffa447ce452ed20c67c2769f1981371300..69604645f0d401b40b142fee9fcce91b1ad1409d 100644 (file)
--- 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), \
index 31ba1e4877c8fe63f0ad83c91af1d4a2acdf7c18..f4ba8004a30fcaf5d77d95b904f2ded064a3ee9f 100644 (file)
--- 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;
 };