policy: add roam-scan timeout

Add an optional timeout when a better roaming candidate is not found
after the scan-retry limit. The roam state-machine will not retry
scanning before this timeout has expired.

If the timeout is set to 0, the client is kicked instead, which
resembles the behavior prior this commit.

This is added, as without this patch, if a forced disconnect
is not desired before roam_scan_trigger is exceeded the client will
repeatedly be asked to return active beacon-reports. For battery powered
clients this can result in a noticeable battery drain.

Signed-off-by: David Bauer <mail@david-bauer.net>
This commit is contained in:
David Bauer
2021-12-21 15:30:14 +01:00
parent 7e999e0874
commit 9a78412ac5
6 changed files with 41 additions and 7 deletions

View File

@@ -272,6 +272,26 @@ usteer_roam_set_state(struct sta_info *si, enum roam_trigger_state state,
usteer_event(ev);
}
static void
usteer_roam_sm_start_scan(struct sta_info *si, struct uevent *ev)
{
/* Start scanning in case we are not timeout-constrained or timeout has expired */
if (config.roam_scan_timeout &&
current_time > si->roam_scan_timeout_start + config.roam_scan_timeout) {
usteer_roam_set_state(si, ROAM_TRIGGER_SCAN, ev);
return;
}
/* We are currently in scan timeout / cooldown.
* Check if we are in ROAM_TRIGGER_IDLE state and enter this stateif not.
*/
if (si->roam_state == ROAM_TRIGGER_IDLE)
return;
/* Enter idle state */
usteer_roam_set_state(si, ROAM_TRIGGER_IDLE, ev);
}
static bool
usteer_roam_trigger_sm(struct sta_info *si)
{
@@ -293,14 +313,20 @@ usteer_roam_trigger_sm(struct sta_info *si)
break;
}
if (config.roam_scan_tries &&
si->roam_tries >= config.roam_scan_tries) {
usteer_roam_set_state(si, ROAM_TRIGGER_WAIT_KICK, &ev);
if (config.roam_scan_tries && si->roam_tries >= config.roam_scan_tries) {
if (!config.roam_scan_timeout) {
/* Prepare to kick client */
usteer_roam_set_state(si, ROAM_TRIGGER_WAIT_KICK, &ev);
} else {
/* Kick in scan timeout */
si->roam_scan_timeout_start = current_time;
usteer_roam_set_state(si, ROAM_TRIGGER_IDLE, &ev);
}
break;
}
usteer_ubus_trigger_client_scan(si);
usteer_roam_set_state(si, ROAM_TRIGGER_SCAN, &ev);
usteer_roam_sm_start_scan(si, &ev);
break;
case ROAM_TRIGGER_IDLE:
@@ -309,13 +335,13 @@ usteer_roam_trigger_sm(struct sta_info *si)
break;
}
usteer_roam_set_state(si, ROAM_TRIGGER_SCAN, &ev);
usteer_roam_sm_start_scan(si, &ev);
break;
case ROAM_TRIGGER_SCAN_DONE:
/* Check for stale scan results, kick back to SCAN state if necessary */
if (current_time - si->roam_scan_done > 2 * config.roam_scan_interval) {
usteer_roam_set_state(si, ROAM_TRIGGER_SCAN, &ev);
usteer_roam_sm_start_scan(si, &ev);
break;
}