diff mbox series

[2/4] station: start roam on beacon loss event

Message ID 20231030134837.452957-3-prestwoj@gmail.com (mailing list archive)
State New
Headers show
Series Packet/beacon loss roaming improvements | expand

Checks

Context Check Description
tedd_an/pre-ci_am success Success
prestwoj/iwd-ci-gitlint fail [2/4] station: start roam on beacon loss event 16: B1 Line exceeds max length (89>80): "11:30:29 iwd[1407046]: src/netdev.c:netdev_mlme_notify() MLME notification Notify CQM(64)" 17: B1 Line exceeds max length (82>80): "11:30:29 iwd[1407046]: src/station.c:station_packets_lost() Packets lost event: 10" 19: B1 Line exceeds max length (84>80): "11:30:29 iwd[1407046]: src/wiphy.c:wiphy_radio_work_insert() Inserting work item 144" 20: B1 Line exceeds max length (81>80): "11:30:29 iwd[1407046]: src/wiphy.c:wiphy_radio_work_next() Starting work item 144" 21: B1 Line exceeds max length (95>80): "11:30:29 iwd[1407046]: src/station.c:station_start_roam() Using cached neighbor report for roam" 22: B1 Line exceeds max length (82>80): "11:30:29 iwd[1407046]: src/scan.c:scan_notify() Scan notification Trigger Scan(33)" 23: B1 Line exceeds max length (91>80): "11:30:29 iwd[1407046]: src/scan.c:scan_request_triggered() Active scan triggered for wdev 4" 25: B1 Line exceeds max length (90>80): "11:30:29 iwd[1407046]: src/netdev.c:netdev_mlme_notify() MLME notification Del Station(20)" 26: B1 Line exceeds max length (93>80): "11:30:29 iwd[1407046]: src/netdev.c:netdev_mlme_notify() MLME notification Deauthenticate(39)" 28: B1 Line exceeds max length (89>80): "11:30:29 iwd[1407046]: src/netdev.c:netdev_mlme_notify() MLME notification Disconnect(48)" 30: B1 Line exceeds max length (81>80): "11:30:29 iwd[1407046]: Received Deauthentication event, reason: 4, from_ap: false"

Commit Message

James Prestwood Oct. 30, 2023, 1:48 p.m. UTC
In past testing the beacon loss event seemed to always be followed
immediately by a disconnect. It was determined at the time that there
wasn't much point in even attempting a roam because a disconnect
would happen before the roam could finish. This was a bit short
sighted because its hardware dependent when the beacon loss event
is sent.

Recently it was seen that some hardware (ath10k in this case)
actually gives some time before the kernel finally disconnects.
In this example a beacon loss event came and IWD remained connected
for 4 seconds (until a packet loss which issued a roam scan).

11:30:25 iwd[1407046]: src/netdev.c:netdev_cqm_event() Beacon lost event
11:30:29 iwd[1407046]: src/netdev.c:netdev_mlme_notify() MLME notification Notify CQM(64)
11:30:29 iwd[1407046]: src/station.c:station_packets_lost() Packets lost event: 10
11:30:29 iwd[1407046]: src/station.c:station_roam_scan() ifindex: 6
11:30:29 iwd[1407046]: src/wiphy.c:wiphy_radio_work_insert() Inserting work item 144
11:30:29 iwd[1407046]: src/wiphy.c:wiphy_radio_work_next() Starting work item 144
11:30:29 iwd[1407046]: src/station.c:station_start_roam() Using cached neighbor report for roam
11:30:29 iwd[1407046]: src/scan.c:scan_notify() Scan notification Trigger Scan(33)
11:30:29 iwd[1407046]: src/scan.c:scan_request_triggered() Active scan triggered for wdev 4
11:30:29 iwd[1407046]: src/netdev.c:netdev_link_notify() event 16 on ifindex 6
11:30:29 iwd[1407046]: src/netdev.c:netdev_mlme_notify() MLME notification Del Station(20)
11:30:29 iwd[1407046]: src/netdev.c:netdev_mlme_notify() MLME notification Deauthenticate(39)
11:30:29 iwd[1407046]: src/netdev.c:netdev_deauthenticate_event()
11:30:29 iwd[1407046]: src/netdev.c:netdev_mlme_notify() MLME notification Disconnect(48)
11:30:29 iwd[1407046]: src/netdev.c:netdev_disconnect_event()
11:30:29 iwd[1407046]: Received Deauthentication event, reason: 4, from_ap: false

It makes sense to also handle beacon loss events and attempt a
roam, potentially saving the connection. One difference here is
the beacon loss event will force a roam (similar to ap directed
roaming when the imminent bit is set).
---
 src/netdev.h  |  1 +
 src/station.c | 17 +++++++++++++++++
 2 files changed, 18 insertions(+)
diff mbox series

Patch

diff --git a/src/netdev.h b/src/netdev.h
index 73d38c32..f27130f1 100644
--- a/src/netdev.h
+++ b/src/netdev.h
@@ -51,6 +51,7 @@  enum netdev_event {
 	NETDEV_EVENT_RSSI_LEVEL_NOTIFY,
 	NETDEV_EVENT_PACKET_LOSS_NOTIFY,
 	NETDEV_EVENT_FT_ROAMED,
+	NETDEV_EVENT_BEACON_LOSS_NOTIFY,
 };
 
 enum netdev_watch_event {
diff --git a/src/station.c b/src/station.c
index a2358d95..8c87b3e0 100644
--- a/src/station.c
+++ b/src/station.c
@@ -3347,6 +3347,20 @@  static void station_packets_lost(struct station *station, uint32_t num_pkts)
 	station_start_roam(station);
 }
 
+static void station_beacon_lost(struct station *station)
+{
+	l_debug("Beacon lost event");
+
+	if (station_cannot_roam(station))
+		return;
+
+	station->force_roam = true;
+
+	station_debug_event(station, "beacon-loss-roam");
+
+	station_start_roam(station);
+}
+
 static void station_netdev_event(struct netdev *netdev, enum netdev_event event,
 					void *event_data, void *user_data)
 {
@@ -3391,6 +3405,9 @@  static void station_netdev_event(struct netdev *netdev, enum netdev_event event,
 
 		station_roamed(station);
 		break;
+	case NETDEV_EVENT_BEACON_LOSS_NOTIFY:
+		station_beacon_lost(station);
+		break;
 	}
 }