From 0fe964fbb4ee8a9f0bc84a01e4b55a3e4e711b80 Mon Sep 17 00:00:00 2001 From: Tyler Smith <74526874+tylertms@users.noreply.github.com> Date: Sat, 31 Oct 2026 01:47:33 +0000 Subject: [PATCH] fix(wifi): keep what an Intel scan heard through its later parts --- .../coexistence_tests/link_tests.rs | 47 +++++++++++++++++-- .../stela-driver-net/src/wifi/intel/link.rs | 11 +++-- .../src/wifi/intel/link/station.rs | 21 +++++++-- 3 files changed, 68 insertions(+), 11 deletions(-) diff --git a/crates/stela-driver-net/src/wifi/intel/boot/tests/ax200_native_scan_tests/phy_tests/transmit_power_tests/binding_tests/peer_tests/mld_tests/queue_tests/coexistence_tests/link_tests.rs b/crates/stela-driver-net/src/wifi/intel/boot/tests/ax200_native_scan_tests/phy_tests/transmit_power_tests/binding_tests/peer_tests/mld_tests/queue_tests/coexistence_tests/link_tests.rs index 3b0418ddab..0f431b4a29 100644 --- a/crates/stela-driver-net/src/wifi/intel/boot/tests/ax200_native_scan_tests/phy_tests/transmit_power_tests/binding_tests/peer_tests/mld_tests/queue_tests/coexistence_tests/link_tests.rs +++ b/crates/stela-driver-net/src/wifi/intel/boot/tests/ax200_native_scan_tests/phy_tests/transmit_power_tests/binding_tests/peer_tests/mld_tests/queue_tests/coexistence_tests/link_tests.rs @@ -70,6 +70,9 @@ struct Device<'n> { block_acks: Vec>, /// Each scan request. scans: Vec>, + /// The second channel's rules, when they differ from the first's, and the + /// AP then only heard from the first scan. + second: Option, /// Whether frames are acknowledged in Block Ack notifications alone, as /// the firmware reports those it aggregated. aggregating: bool, @@ -134,7 +137,8 @@ impl Device<'_> { }; let mut payload = mcc_payload(country, request[2], 51); payload[20..24].copy_from_slice(&self.channel.to_le_bytes()); - payload[24..28].copy_from_slice(&self.channel.to_le_bytes()); + let second = self.second.unwrap_or(self.channel); + payload[24..28].copy_from_slice(&second.to_le_bytes()); payload } (1 | 5, 0x08) => vec![0x9b], @@ -172,8 +176,10 @@ impl Device<'_> { } if (id.group, id.opcode) == (1, 0x0d) { self.scans.push(request.to_vec()); - for ssid in self.beacons.clone() { - self.inject(rom, &beacon(ssid, self.quality, self.elements)); + if self.second.is_none() || self.scans.len() == 1 { + for ssid in self.beacons.clone() { + self.inject(rom, &beacon(ssid, self.quality, self.elements)); + } } let mut body = [0; 16]; body[6] = 1; @@ -376,6 +382,23 @@ fn raise_beside<'n>( channel: u32, quality: bool, elements: &'static [u8], +) -> (Station, Phase, Device<'n>) { + raise_split( + native, country, beacons, flags, channel, quality, elements, None, + ) +} + +/// [`raise_beside`], with [`Device::second`]. +#[expect(clippy::too_many_arguments, reason = "each is a fixture's own knob")] +fn raise_split<'n>( + native: &'n Native, + country: Option<[u8; 2]>, + beacons: Vec<&'static [u8]>, + flags: u8, + channel: u32, + quality: bool, + elements: &'static [u8], + second: Option, ) -> (Station, Phase, Device<'n>) { let catalog: &'static resources::Catalog = Box::leak(Box::new(catalog_for( &profile(), @@ -415,6 +438,7 @@ fn raise_beside<'n>( configuration: Vec::new(), block_acks: Vec::new(), scans: Vec::new(), + second, aggregating: false, }; device.inject(&boot, &alive); @@ -1058,6 +1082,23 @@ fn a_scan_probes_where_a_frame_may_start_and_listens_elsewhere() { assert_eq!(scan[48], 0); } +#[test] +fn a_network_one_scan_part_heard_outlives_the_parts_after_it() { + let native = Native::default(); + let (_, phase, device) = raise_split( + &native, + Some(*b"US"), + vec![b"test"], + 0, + OPEN, + true, + &[], + Some(OPEN & !8), + ); + assert_eq!(device.scans.len(), 2); + assert_eq!(phase, Phase::AuthenticationRequired); +} + /// An AP's HE capabilities, one stream with its ACK and HTC bits, then its /// operation: 3 us packet extension, RTS threshold 5, color 9. Random access /// and MU EDCA parameters follow it. diff --git a/crates/stela-driver-net/src/wifi/intel/link.rs b/crates/stela-driver-net/src/wifi/intel/link.rs index 377807cd0c..6e60084d94 100644 --- a/crates/stela-driver-net/src/wifi/intel/link.rs +++ b/crates/stela-driver-net/src/wifi/intel/link.rs @@ -740,15 +740,18 @@ impl Wifi { { beacons.heard(bss.channel); } - let observed = Arc::new(association::NativeBssObservation { bss: bss.clone() }); + let heard = station::Heard { + observation: Arc::new(association::NativeBssObservation { bss: bss.clone() }), + at: self.clock.now_us(), + }; match self .client .observed .iter_mut() - .find(|known| known.bss().bssid == bss.bssid) + .find(|known| known.observation.bss().bssid == bss.bssid) { - Some(known) => *known = observed, - None => self.client.observed.push(observed), + Some(known) => *known = heard, + None => self.client.observed.push(heard), } } } diff --git a/crates/stela-driver-net/src/wifi/intel/link/station.rs b/crates/stela-driver-net/src/wifi/intel/link/station.rs index 3e3d3b5522..0cf283c3ea 100644 --- a/crates/stela-driver-net/src/wifi/intel/link/station.rs +++ b/crates/stela-driver-net/src/wifi/intel/link/station.rs @@ -188,10 +188,19 @@ pub struct ManagementKey { } /// The association's state beside the kept chain. +/// `IEEE80211_SCAN_RESULT_EXPIRE`. +const BSS_EXPIRY_US: u64 = 30_000_000; + +/// A BSS and when it was last heard, a `cfg80211_internal_bss`. +pub(super) struct Heard { + pub(super) observation: Arc, + pub(super) at: u64, +} + pub(super) struct Client { station: Station, pub(super) plan: Option, - pub(super) observed: Vec>, + pub(super) observed: Vec, pub(super) channels: Vec<(Channel, u32)>, pub(super) regulatory: Option, steps: VecDeque, @@ -1352,7 +1361,7 @@ impl Wifi { self.client .observed .get(handle) - .cloned() + .map(|heard| heard.observation.clone()) .ok_or(Error::Refused("BSS")) } } @@ -1683,7 +1692,11 @@ impl Radio for Wifi { owner.poll_pre_scan_receive().map_err(Error::Scan)?, MpduProgress::Pending | MpduProgress::Backpressure { .. } ) {} - self.client.observed.clear(); + // A scan runs in parts, whose results `choose` takes together. + let now = self.clock.now_us(); + self.client + .observed + .retain(|heard| now.saturating_sub(heard.at) < BSS_EXPIRY_US); let started = match probe { // SAFETY: `new`'s contract covers the scan's pages. Some(probe) => unsafe { owner.start_probing(request, &probe, budget_us, pages) }, @@ -1720,7 +1733,7 @@ impl Radio for Wifi { .observed .iter() .enumerate() - .map(|(handle, observed)| (handle, observed.bss())) + .map(|(handle, heard)| (handle, heard.observation.bss())) .collect() }