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:
38
policy.c
38
policy.c
@@ -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;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user