feat(wifi): scan AX210's 6 GHz channels as firmware plans them

This commit is contained in:
Tyler Smith committed 2026-10-31 01:56:55 +00:00
1 parent 721908d34f
commit 838e11b1db
7 files changed
+425 -77

No files matched your search

@@ -30,6 +30,10 @@ const MAX_SCAN_US: u64 = 30_000_000;
const DS_PARAMETERS: u32 = 9;
/// `IWL_UCODE_TLV_CAPA_WFA_TPC_REP_IE_SUPPORT`.
const TPC_REPORT: u32 = 10;
/// `IWL_UCODE_TLV_CAPA_HIDDEN_6GHZ_SCAN`.
const HIDDEN_SIX_GHZ: u32 = 59;
/// `IWL_UCODE_TLV_CAPA_SCAN_DONT_TOGGLE_ANT`.
const FIXED_ANTENNA: u32 = 111;
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum Ax200ScanPhase {
NotStarted,
@@ -248,11 +252,10 @@ impl<Q: BootIo, B: BiosIo, O: CountryIo + OsPolicy> Ax200Scan<'_, Q, B, O> {
let band = match observation.channel.band {
crate::wifi::intel::mcc::channel::Band::Ghz2 => Band::Ghz2,
crate::wifi::intel::mcc::channel::Band::Ghz5 => Band::Ghz5,
crate::wifi::intel::mcc::channel::Band::Ghz6 => return None,
crate::wifi::intel::mcc::channel::Band::Ghz6 => Band::Ghz6,
};
hardware.channel(band, observation.channel.number)
})
.take(protocol::MAX_CHANNELS)
.collect()
}
/// The same channels with the regulatory flags their firmware
@@ -549,9 +552,11 @@ impl<Q: BootIo, B: BiosIo, O: CountryIo + OsPolicy> Ax200Scan<'_, Q, B, O> {
.initialized
.boot;
let version = wire::validate(&boot.firmware)?;
let measurement = wire::Measurement {
let abilities = wire::Abilities {
ds_parameters: boot.firmware.supports_capability(DS_PARAMETERS),
tpc_report: boot.firmware.supports_capability(TPC_REPORT),
hidden_six_ghz: boot.firmware.supports_capability(HIDDEN_SIX_GHZ),
fixed_antenna: boot.firmware.supports_capability(FIXED_ANTENNA),
};
// Capture every already-completed RB before admitting a new request.
// This exclusive owner never rearms inside the loop, so the real fixed
@@ -623,7 +628,7 @@ impl<Q: BootIo, B: BiosIo, O: CountryIo + OsPolicy> Ax200Scan<'_, Q, B, O> {
version,
scanner.local(),
probe,
measurement,
abilities,
)?;
let mut checked = policy::CheckedRequest(operation.request());
let now = options.clock.now_us();
@@ -21,18 +21,17 @@ impl<'a, Q: BootIo, B: BiosIo> Hardware<'_, 'a, Q, B> {
}
pub(super) fn channel(&self, band: Band, number: u16) -> Option<Channel> {
let information = &self.board.initialized_nvm().information;
let sku_bit = match band {
Band::Ghz2 => 1,
Band::Ghz5 => 2,
Band::Ghz6 => return None,
};
// NVM has no 6 GHz bit: `iwl_init_channel_map` counts it with 5 GHz.
let sku_bit = if band == Band::Ghz2 { 1 } else { 2 };
if information.lar_enabled == 0 || information.mac_sku_flags & sku_bit == 0 {
return None;
}
let observation = self.channels.iter().find(|ch| {
let matches_band = matches!(
(ch.channel.band, band),
(channel::Band::Ghz2, Band::Ghz2) | (channel::Band::Ghz5, Band::Ghz5)
(channel::Band::Ghz2, Band::Ghz2)
| (channel::Band::Ghz5, Band::Ghz5)
| (channel::Band::Ghz6, Band::Ghz6)
);
matches_band
&& ch.channel.number == number
@@ -8,17 +8,23 @@ use super::*;
/// elements, which they share.
#[derive(Clone, Debug)]
pub struct Probe {
/// `ieee80211_build_preq_ies`' per-band parts for 2.4 and for 5 GHz.
pub elements: [Vec<u8>; 2],
/// `ieee80211_build_preq_ies`' per-band parts for 2.4, 5 and 6 GHz.
pub elements: [Vec<u8>; 3],
/// The legacy rates firmware probes at, under the country's limit it holds.
pub profiles: regulatory::ProbeProfiles,
}
/// `iwl_mvm_rrm_scan_needed`: firmware that fills a DS Parameter Set placeholder
/// for the channel it probes, and writes a WFA TPC report itself.
/// What firmware does in a scan by itself.
#[derive(Clone, Copy, Debug)]
pub(super) struct Measurement {
pub(super) struct Abilities {
/// `iwl_mvm_rrm_scan_needed`: it fills a DS Parameter Set placeholder for
/// the channel it probes.
pub(super) ds_parameters: bool,
/// It writes a WFA TPC report itself.
pub(super) tpc_report: bool,
/// It probes a 6 GHz channel for a hidden SSID's name.
pub(super) hidden_six_ghz: bool,
/// It keeps one antenna through a 6 GHz scan.
pub(super) fixed_antenna: bool,
}
pub(super) const REQUEST: Id = Id {
group: 1,
@@ -44,8 +50,10 @@ const PROBE_SEGMENTS: usize = 5 * 4;
const PROBE_BUFFER_BYTES: usize = 512;
const SSID_ENTRY_BYTES: usize = 34;
const DIRECT_SSIDS: usize = 20 * SSID_ENTRY_BYTES;
const SHORT_SSIDS: usize = 8 * 4;
const BSSIDS: usize = 16 * 6;
const SHORT_SSID_ENTRIES: usize = 8;
const SHORT_SSIDS: usize = SHORT_SSID_ENTRIES * 4;
const BSSID_ENTRIES: usize = 16;
const BSSIDS: usize = BSSID_ENTRIES * 6;
const SSIDS: usize = PROBE + PROBE_SEGMENTS + PROBE_BUFFER_BYTES + 4;
pub(super) const REQUEST_BYTES: usize = SSIDS + DIRECT_SSIDS + SHORT_SSIDS + BSSIDS;
/// A management header and the wildcard SSID firmware replaces.
@@ -62,6 +70,15 @@ const PASS_ALL: u16 = 1 << 1;
const USE_ALL_RX_CHAINS: u16 = 1 << 6;
const ADAPTIVE_DWELL: u16 = 1 << 7;
const ENABLE_CHANNEL_ORDER: u8 = 1 << 5;
const PSC_NO_FILTER: u8 = 1 << 6;
const FLAGS2: usize = GENERAL + 9;
/// `IWL_UMAC_SCAN_GEN_PARAMS_FLAGS2_DONT_TOGGLE_ANT`.
const DONT_TOGGLE_ANTENNA: u8 = 1 << 2;
const UNSOLICITED_PROBE_RESPONSE: u32 = 1 << 24;
const PSC_NO_LISTEN: u32 = 1 << 25;
const CHANNEL_FORCE_PASSIVE: u32 = 1 << 26;
/// `IEEE80211_RNR_TBTT_PARAMS_PSD_RESERVED`.
const PSD_RESERVED: i8 = -128;
const PRIORITY_EXT_6: u32 = 6;
const ACTIVE_DWELL: u8 = 10;
const PASSIVE_DWELL: u8 = 110;
@@ -135,36 +152,42 @@ pub(super) fn encode(
version: u8,
local: crate::Mac,
probe: Option<&Probe>,
measurement: Measurement,
abilities: Abilities,
) -> Result<Vec<u8>, Ax200ScanError> {
if request.active() != probe.is_some() {
return Err(Ax200ScanError::ProbePowerRequired);
}
// cfg80211 splits a scan, so a request is all 6 GHz or none of it.
let six_ghz = request
.channels()
.first()
.is_some_and(|ch| ch.band == Band::Ghz6);
if request.channels().is_empty()
|| request.channels().len() > FIRMWARE_CHANNELS
|| !request.six_ghz().is_empty()
|| (!six_ghz && !request.six_ghz().is_empty())
|| request
.channels()
.iter()
.any(|ch| ch.band == Band::Ghz6 || ch.number > u8::MAX.into())
.any(|ch| (ch.band == Band::Ghz6) != six_ghz || ch.number > u8::MAX.into())
{
return Err(Ax200ScanError::UnsupportedRequest);
}
let (ghz2, ghz5) = match probe {
Some(probe) if measurement.ds_parameters => (
let [ghz2, ghz5, ghz6] = match probe {
Some(probe) if abilities.ds_parameters => [
with_ds_placeholder(&probe.elements[0]),
probe.elements[1].clone(),
),
Some(probe) => (probe.elements[0].clone(), probe.elements[1].clone()),
None => (Vec::new(), Vec::new()),
probe.elements[2].clone(),
],
Some(probe) => probe.elements.clone(),
None => [Vec::new(), Vec::new(), Vec::new()],
};
let mut common = Vec::from(request.extra_elements());
if probe.is_some() && measurement.ds_parameters && !measurement.tpc_report {
if probe.is_some() && abilities.ds_parameters && !abilities.tpc_report {
common.extend_from_slice(&TPC_REPORT);
}
// Even a passive scan's unused template is bounded and keeps every caller
// IE. It sets no direct SSID, so no firmware probe selector can transmit.
if HEADER + ghz2.len() + ghz5.len() + common.len() > PROBE_BUFFER_BYTES {
if HEADER + ghz2.len() + ghz5.len() + ghz6.len() + common.len() > PROBE_BUFFER_BYTES {
return Err(Ax200ScanError::UnsupportedRequest);
}
let ssids = request.ssids();
@@ -196,26 +219,16 @@ pub(super) fn encode(
bytes[GENERAL + 32..GENERAL + 34].fill(PASSIVE_DWELL);
// Both LMAC timing arrays are zero for the unassociated MAC.
// EBS is disabled: no previous successful EBS is invented.
let bitmap = direct_ssids(&mut bytes[SSIDS..SSIDS + DIRECT_SSIDS], ssids);
bytes[CHANNELS] = ENABLE_CHANNEL_ORDER;
bytes[CHANNELS + 1] = request.channels().len() as u8;
bytes[CHANNELS + 2..CHANNELS + 4].copy_from_slice(&[10, 2]);
for (i, channel) in request.channels().iter().enumerate() {
let at = CHANNELS + 4 + i * CHANNEL_CONFIG_BYTES;
let band = match channel.band {
Band::Ghz2 => PHY_BAND_24,
Band::Ghz5 => PHY_BAND_5,
Band::Ghz6 => PHY_BAND_6,
};
let flags = if version < BAND_IN_FLAGS {
bytes[at + 5] = band;
bitmap
} else {
bitmap | u32::from(band) << BAND_SHIFT
};
bytes[at..at + 4].copy_from_slice(&flags.to_le_bytes());
bytes[at + 4] = channel.number as u8;
bytes[at + 6] = 1;
if six_ghz {
encode_six_ghz(&mut bytes, request, version, abilities)?;
} else {
let bitmap = direct_ssids(&mut bytes[SSIDS..SSIDS + DIRECT_SSIDS], ssids);
bytes[CHANNELS] = ENABLE_CHANNEL_ORDER;
bytes[CHANNELS + 1] = request.channels().len() as u8;
bytes[CHANNELS + 2..CHANNELS + 4].copy_from_slice(&[10, 2]);
for (index, &channel) in request.channels().iter().enumerate() {
put_channel(&mut bytes, index, channel, bitmap, version);
}
}
bytes[PERIODIC + 2] = 1; // one ordinary iteration, interval/delay zero
bytes[PROBE + 2..PROBE + 4].copy_from_slice(&(HEADER as u16).to_le_bytes());
@@ -225,7 +238,7 @@ pub(super) fn encode(
bytes[frame + 10..frame + 16].copy_from_slice(&local.0);
bytes[frame + 16..frame + 22].fill(0xff);
let mut offset = HEADER;
let parts: [&[u8]; 4] = [&ghz2, &ghz5, &[], &common];
let parts: [&[u8]; 4] = [&ghz2, &ghz5, &ghz6, &common];
for (segment, part) in parts.into_iter().enumerate() {
let at = PROBE + (segment + 1) * 4;
bytes[at..at + 2].copy_from_slice(&(offset as u16).to_le_bytes());
@@ -236,6 +249,176 @@ pub(super) fn encode(
Ok(bytes)
}
/// One `iwl_scan_channel_cfg_umac`: its one iteration, and its band where
/// `version` reads it.
fn put_channel(bytes: &mut [u8], index: usize, channel: Channel, flags: u32, version: u8) {
let at = CHANNELS + 4 + index * CHANNEL_CONFIG_BYTES;
let band = match channel.band {
Band::Ghz2 => PHY_BAND_24,
Band::Ghz5 => PHY_BAND_5,
Band::Ghz6 => PHY_BAND_6,
};
let flags = if version < BAND_IN_FLAGS {
bytes[at + 5] = band;
flags
} else {
flags | u32::from(band) << BAND_SHIFT
};
bytes[at..at + 4].copy_from_slice(&flags.to_le_bytes());
bytes[at + 4] = channel.number as u8;
bytes[at + 6] = 1;
}
/// The short SSIDs and BSSIDs a 6 GHz scan's channels index.
struct SixGhzTables {
/// Each short SSID, and whether its full name is also in the table.
short_ssids: Vec<(u32, bool)>,
bssids: Vec<crate::Mac>,
}
/// `iwl_mvm_umac_scan_fill_6g_chan_list`.
fn six_ghz_tables(bytes: &mut [u8], request: &protocol::Request, hidden: bool) -> SixGhzTables {
let mut tables = SixGhzTables {
short_ssids: Vec::new(),
bssids: Vec::new(),
};
let named = request.ssids().iter().filter(|ssid| !ssid.is_empty());
for (index, ssid) in named.take(SHORT_SSID_ENTRIES).enumerate() {
if hidden {
let entry = &mut bytes[SSIDS + index * SSID_ENTRY_BYTES..][..SSID_ENTRY_BYTES];
entry[1] = ssid.len() as u8;
entry[2..2 + ssid.len()].copy_from_slice(ssid);
}
let short = protocol::six_ghz::short_ssid(ssid);
tables.short_ssids.push((short, hidden));
}
for target in request.six_ghz() {
if let Some(short) = target.short_ssid
&& tables.short_ssids.len() < SHORT_SSID_ENTRIES
&& !tables.short_ssids.iter().any(|known| known.0 == short)
{
tables.short_ssids.push((short, false));
}
if tables.bssids.len() < BSSID_ENTRIES
&& !tables.bssids.contains(&target.bssid)
&& !target.bssid.is_multicast()
&& target.bssid.0 != [0; 6]
{
tables.bssids.push(target.bssid);
}
}
let shorts = SSIDS + DIRECT_SSIDS;
for (index, (short, _)) in tables.short_ssids.iter().enumerate() {
bytes[shorts + index * 4..][..4].copy_from_slice(&short.to_le_bytes());
}
for (index, bssid) in tables.bssids.iter().enumerate() {
bytes[shorts + SHORT_SSIDS + index * 6..][..6].copy_from_slice(&bssid.0);
}
bytes[SSIDS - 4] = tables.short_ssids.len() as u8;
bytes[SSIDS - 3] = tables.bssids.len() as u8;
tables
}
/// `iwl_mvm_umac_scan_cfg_channels_v7_6g`, for the unfragmented scan of an idle
/// station: which of the tables' entries each channel probes for.
fn encode_six_ghz(
bytes: &mut [u8],
request: &protocol::Request,
version: u8,
abilities: Abilities,
) -> Result<(), Ax200ScanError> {
let tables = six_ghz_tables(bytes, request, abilities.hidden_six_ghz);
let targets = request.six_ghz();
let ssids = request.ssids();
let mut count = 0;
for (index, &channel) in request.channels().iter().enumerate() {
let psc = protocol::six_ghz::is_psc(channel);
if !psc && targets.is_empty() && !ssids.is_empty() {
continue;
}
let here = || {
targets
.iter()
.filter(|target| target.channel_index == index)
};
let unsolicited = here().any(|target| target.unsolicited_probe);
let no_listen = here().any(|target| target.psc_no_listen);
let psd = here()
.map(|target| target.psd_20)
.filter(|&psd| psd != PSD_RESERVED)
.max()
.unwrap_or(PSD_RESERVED);
let (most_shorts, most_bssids) = if (!psc || no_listen) && !unsolicited {
(3, 9)
} else {
(2, 6)
};
let (mut short_bitmap, mut bssid_bitmap) = (0u32, 0u32);
let (mut shorts, mut bssids) = (0, 0);
let (mut force_passive, mut allow_passive) = (false, true);
for target in here() {
// Probing a short SSID covers every BSS of it in one dwell, so three
// direct BSSIDs go with each, and a hidden AP takes one regardless.
let short = tables
.short_ssids
.iter()
.enumerate()
.find(|(_, known)| !target.unsolicited_probe && target.short_ssid == Some(known.0))
.filter(|_| shorts < most_shorts);
if let Some((entry, &(_, named))) = short {
if short_bitmap & 1 << entry != 0 {
continue;
}
if 3 * shorts <= bssids || named {
allow_passive &= !named;
short_bitmap |= 1 << entry;
shorts += 1;
continue;
}
}
let Some(entry) = tables.bssids.iter().position(|b| *b == target.bssid) else {
continue;
};
if bssid_bitmap & 1 << entry == 0 {
if bssids < most_bssids {
bssid_bitmap |= 1 << entry;
bssids += 1;
} else {
force_passive = true;
}
}
}
let mut flags = 0;
if psc && no_listen {
flags |= PSC_NO_LISTEN;
}
if unsolicited {
flags |= UNSOLICITED_PROBE_RESPONSE;
}
if (allow_passive && force_passive) || (bssid_bitmap | short_bitmap == 0 && !psc) {
flags |= CHANNEL_FORCE_PASSIVE;
} else {
flags |= bssid_bitmap | short_bitmap << 16;
}
put_channel(bytes, count, channel, flags, version);
if version >= BAND_IN_FLAGS {
bytes[CHANNELS + 4 + count * CHANNEL_CONFIG_BYTES + 5] = psd as u8;
}
count += 1;
}
if count == 0 {
return Err(Ax200ScanError::UnsupportedRequest);
}
bytes[CHANNELS + 1] = count as u8;
if ssids.is_empty() || (ssids.len() == 1 && ssids[0].is_empty()) {
bytes[CHANNELS] = PSC_NO_FILTER;
}
if version >= 15 && abilities.fixed_antenna {
bytes[FLAGS2] = DONT_TOGGLE_ANTENNA;
}
Ok(())
}
#[cfg(test)]
mod tests {
use super::*;
@@ -263,7 +446,11 @@ mod tests {
max_eirp_mbm: 2000,
};
Probe {
elements: [vec![1, 1, 2, 50, 1, 96, 45, 1, 9], vec![1, 1, 12]],
elements: [
vec![1, 1, 2, 50, 1, 96, 45, 1, 9],
vec![1, 1, 12],
vec![1, 1, 12, 255, 3, 59, 0, 0],
],
profiles: regulatory::ProbeProfiles::uniform(profile),
}
}
@@ -277,11 +464,141 @@ mod tests {
&bytes[FRAME + usize::from(word(bytes, at))..][..usize::from(word(bytes, at + 2))]
}
const MEASURED: Measurement = Measurement {
const MEASURED: Abilities = Abilities {
ds_parameters: true,
tpc_report: false,
hidden_six_ghz: false,
fixed_antenna: false,
};
const SIX_1: Channel = Channel {
band: Band::Ghz6,
number: 1,
frequency_mhz: 5955,
};
const SIX_5: Channel = Channel {
band: Band::Ghz6,
number: 5,
frequency_mhz: 5975,
};
fn target(channel_index: usize, last: u8) -> protocol::SixGhz {
protocol::SixGhz {
channel_index,
bssid: crate::Mac([2, 0, 0, 0, 1, last]),
short_ssid: None,
unsolicited_probe: false,
psc_no_listen: false,
psd_20: PSD_RESERVED,
}
}
fn six_ghz(
channels: Vec<Channel>,
ssids: Vec<Vec<u8>>,
targets: Vec<protocol::SixGhz>,
) -> Vec<u8> {
let request = protocol::Request::with_six_ghz(channels, ssids, vec![], targets).unwrap();
encode(&request, 17, LOCAL, Some(&probe()), MEASURED).unwrap()
}
fn flags(bytes: &[u8], index: usize) -> u32 {
let at = CHANNELS + 4 + index * CHANNEL_CONFIG_BYTES;
u32::from_le_bytes(bytes[at..at + 4].try_into().unwrap())
}
const BAND_6: u32 = (PHY_BAND_6 as u32) << BAND_SHIFT;
#[test]
fn a_six_ghz_scan_probes_each_channel_for_what_is_known_on_it() {
let reported = protocol::SixGhz {
short_ssid: Some(0xaabb_ccdd),
psd_20: 4,
..target(1, 1)
};
let bytes = six_ghz(vec![SIX_5, SIX_1], vec![vec![]], vec![reported]);
assert_eq!(bytes[CHANNELS], PSC_NO_FILTER);
assert_eq!(bytes[CHANNELS + 1], 2);
assert_eq!(bytes[SSIDS - 4..SSIDS - 2], [1, 1]);
let tables = SSIDS + DIRECT_SSIDS;
assert_eq!(bytes[tables..tables + 4], 0xaabb_ccddu32.to_le_bytes());
assert_eq!(
bytes[tables + SHORT_SSIDS..tables + SHORT_SSIDS + 6],
[2, 0, 0, 0, 1, 1]
);
assert_eq!(flags(&bytes, 0), BAND_6);
assert_eq!(bytes[CHANNELS + 4 + 5], PSD_RESERVED as u8);
assert_eq!(flags(&bytes, 1), BAND_6 | 1 << 16);
assert_eq!(bytes[CHANNELS + 4 + CHANNEL_CONFIG_BYTES + 4], 1);
assert_eq!(bytes[CHANNELS + 4 + CHANNEL_CONFIG_BYTES + 5], 4);
assert_eq!(segment(&bytes, 3), probe().elements[2]);
}
#[test]
fn a_channel_that_answers_by_itself_takes_its_bssids() {
let reported = protocol::SixGhz {
short_ssid: Some(1),
unsolicited_probe: true,
..target(0, 1)
};
let bytes = six_ghz(vec![SIX_1], vec![vec![]], vec![reported]);
assert_eq!(flags(&bytes, 0), BAND_6 | UNSOLICITED_PROBE_RESPONSE | 1);
}
#[test]
fn too_many_bssids_listen_instead() {
let many = (0..10).map(|last| target(0, last)).collect();
let bytes = six_ghz(vec![SIX_1], vec![vec![]], many);
assert_eq!(flags(&bytes, 0), BAND_6 | CHANNEL_FORCE_PASSIVE);
}
#[test]
fn a_hidden_ap_is_named_and_never_listened_for() {
let ssid = b"net".to_vec();
let short = protocol::six_ghz::short_ssid(&ssid);
let reported = protocol::SixGhz {
short_ssid: Some(short),
..target(0, 1)
};
let request = protocol::Request::with_six_ghz(
vec![SIX_1],
vec![ssid.clone()],
vec![],
vec![reported],
)
.unwrap();
let abilities = Abilities {
hidden_six_ghz: true,
fixed_antenna: true,
..MEASURED
};
let bytes = encode(&request, 17, LOCAL, Some(&probe()), abilities).unwrap();
assert_eq!(bytes[SSIDS..SSIDS + 5], [0, 3, b'n', b'e', b't']);
assert_eq!(bytes[FLAGS2], DONT_TOGGLE_ANTENNA);
assert_eq!(bytes[CHANNELS], 0);
assert_eq!(flags(&bytes, 0), BAND_6 | 1 << 16);
}
#[test]
fn an_unreported_channel_outside_the_psc_is_skipped() {
let request = protocol::Request::new(vec![SIX_1], vec![vec![]], vec![]).unwrap();
assert_eq!(
encode(&request, 17, LOCAL, Some(&probe()), MEASURED).unwrap_err(),
Ax200ScanError::UnsupportedRequest
);
}
#[test]
fn a_request_never_mixes_6_ghz_with_other_bands() {
let mut mixed = channels();
mixed.push(SIX_5);
let request = protocol::Request::new(mixed, vec![vec![]], vec![]).unwrap();
assert_eq!(
encode(&request, 17, LOCAL, Some(&probe()), MEASURED).unwrap_err(),
Ax200ScanError::UnsupportedRequest
);
}
#[test]
fn each_channel_names_its_band_where_its_version_reads_it() {
let request = protocol::Request::new(channels(), vec![vec![]], vec![]).unwrap();
@@ -324,7 +641,7 @@ mod tests {
"the placeholder follows the rates"
);
assert_eq!(segment(&bytes, 2), [1, 1, 12]);
assert_eq!(segment(&bytes, 3), []);
assert_eq!(segment(&bytes, 3), probe().elements[2]);
assert_eq!(segment(&bytes, 4)[..3], [221, 1, 7]);
assert_eq!(segment(&bytes, 4)[3..], TPC_REPORT);
}
@@ -332,13 +649,17 @@ mod tests {
#[test]
fn firmware_that_writes_the_power_report_is_left_to() {
let request = protocol::Request::new(channels(), vec![vec![]], vec![]).unwrap();
let reports = Measurement {
let reports = Abilities {
hidden_six_ghz: false,
fixed_antenna: false,
ds_parameters: true,
tpc_report: true,
};
let bytes = encode(&request, 15, LOCAL, Some(&probe()), reports).unwrap();
assert_eq!(segment(&bytes, 4), []);
let quiet = Measurement {
let quiet = Abilities {
hidden_six_ghz: false,
fixed_antenna: false,
ds_parameters: false,
tpc_report: false,
};
@@ -25,7 +25,10 @@ use crate::wifi::{
response::{Response, block_ack_queues},
},
},
regulatory::channel::{NO_80MHZ, NO_160MHZ, NO_HT40MINUS, NO_HT40PLUS, NO_IR},
regulatory::channel::{
NO_6GHZ_AFC_CLIENT, NO_6GHZ_VLP_CLIENT, NO_80MHZ, NO_160MHZ, NO_HT40MINUS, NO_HT40PLUS,
NO_IR,
},
regulatory::{self, Operation, ProbeProfiles, Purpose, TxProfile, Width, database},
security::{
Cipher, InstallOutcome, InstallTicket, Integrity, KeyIdentity, KeyScope, KeySlot,
@@ -1495,16 +1498,19 @@ fn probe_elements(band: Band, family: Family, chains: (u32, u32), wide: bool) ->
element(191, &vht);
}
elements.extend(he::capability(band, family, chains.0 & chains.1 == 3, wide));
if band == Band::Ghz6 {
elements.extend(he::six_ghz_capability(tx, rx));
}
elements
}
impl<Q: BootIo, B: BiosIo> Wifi<Q, B> {
/// Whether a 5 GHz channel takes 160 MHz.
fn wide(&self) -> bool {
/// Whether a channel of `band` takes 160 MHz.
fn wide(&self, band: Band) -> bool {
self.client
.channels
.iter()
.any(|(channel, flags)| channel.band == Band::Ghz5 && flags & NO_160MHZ == 0)
.any(|(channel, flags)| channel.band == band && flags & NO_160MHZ == 0)
}
/// What firmware's probes radiate: its lowest legacy rate of each band,
@@ -1527,6 +1533,7 @@ impl<Q: BootIo, B: BiosIo> Wifi<Q, B> {
ProbeProfiles {
ghz2: profile(Band::Ghz2, regulatory::LegacyRate::Cck1),
ghz5: profile(Band::Ghz5, regulatory::LegacyRate::Ofdm6),
ghz6: profile(Band::Ghz6, regulatory::LegacyRate::Ofdm6),
}
}
@@ -1537,12 +1544,9 @@ impl<Q: BootIo, B: BiosIo> Wifi<Q, B> {
.regulatory
.as_ref()
.ok_or(Error::Refused("scan"))?;
let (family, chains, wide) = (self.family, self.chains, self.wide());
let elements = |band| probe_elements(band, self.family, self.chains, self.wide(band));
Ok(boot::Probe {
elements: [
probe_elements(Band::Ghz2, family, chains, wide),
probe_elements(Band::Ghz5, family, chains, wide),
],
elements: [Band::Ghz2, Band::Ghz5, Band::Ghz6].map(elements),
profiles: self.probe_profiles(country),
})
}
@@ -1639,11 +1643,7 @@ impl<Q: BootIo, B: BiosIo> Radio for Wifi<Q, B> {
Operation::Transmit {
channel,
purpose: Purpose::Probe,
profile: if channel.band == Band::Ghz2 {
profiles.ghz2
} else {
profiles.ghz5
},
profile: profiles.on(channel),
},
)
}
@@ -1667,7 +1667,7 @@ impl<Q: BootIo, B: BiosIo> Radio for Wifi<Q, B> {
if band == Band::Ghz6 {
return Err(Error::Unsupported("6 GHz on Intel Wi-Fi"));
}
let elements = capability_elements(band, self.family, self.chains, self.wide());
let elements = capability_elements(band, self.family, self.chains, self.wide(band));
let capabilities = Capabilities::parse(band, Role::Station, &elements)
.map_err(|_| Error::Refused("advertisement"))?;
Ok(Advertisement {
@@ -1722,10 +1722,12 @@ impl<Q: BootIo, B: BiosIo> Radio for Wifi<Q, B> {
fn six_ghz_scan(
&self,
_: &scan::Request,
_: scan::six_ghz::Options,
request: &scan::Request,
options: scan::six_ghz::Options,
) -> Result<Option<scan::Request>, Error> {
Ok(None)
let known = self.client.observed.iter();
scan::six_ghz::second_part(request, options, known.map(|heard| heard.observation.bss()))
.map_err(|error| Error::Scan(boot::Ax200ScanError::Protocol(error)))
}
fn bss(&self) -> Vec<(usize, &Bss)> {
@@ -2187,5 +2189,11 @@ pub fn channel_flags(restrictions: &crate::wifi::intel::mcc::channel::Restrictio
if restrictions.no_initiate_radiation {
flags |= NO_IR;
}
if restrictions.no_6ghz_vlp_client {
flags |= NO_6GHZ_VLP_CLIENT;
}
if restrictions.no_6ghz_afc_client {
flags |= NO_6GHZ_AFC_CLIENT;
}
flags
}
@@ -10,6 +10,7 @@ use alloc::vec::Vec;
const EXTENSION: u8 = 255;
const HE_CAPABILITIES: u8 = 35;
const HE_6GHZ_CAPABILITIES: u8 = 59;
/// PPET16 at 0 and PPET8 at 7, for two streams.
const THRESHOLDS: [u8; 4] = [0x61, 0x1c, 0xc7, 0x71];
/// Every MCS of one stream, or of two.
@@ -30,6 +31,20 @@ pub(super) fn maps(two_streams: bool) -> [McsMaps; 3] {
]
}
/// The HE 6 GHz Band Capabilities `iwl_init_he_6ghz_capa` derives from a
/// station's HT and VHT ones, with spatial multiplexing power save off as
/// `ieee80211_put_he_6ghz_cap` writes it.
pub(super) fn six_ghz_capability(tx: u32, rx: u32) -> [u8; 5] {
let capability: u16 = 5 // 4 us A-MPDU spacing
| 7 << 3 // 1 MB A-MPDUs
| 2 << 6 // 11454-byte MPDUs
| 3 << 9 // SMPS off
| u16::from(rx == 1) << 12
| u16::from(tx == 1) << 13;
let [low, high] = capability.to_le_bytes();
[EXTENSION, 3, HE_6GHZ_CAPABILITIES, low, high]
}
/// The element for `band`. `two_streams` is both directions having both
/// antennas; `wide` is 160 MHz being usable.
pub(super) fn capability(band: Band, family: Family, two_streams: bool, wide: bool) -> Vec<u8> {
@@ -95,6 +95,7 @@ pub struct TxProfile {
pub struct ProbeProfiles {
pub ghz2: TxProfile,
pub ghz5: TxProfile,
pub ghz6: TxProfile,
}
impl ProbeProfiles {
@@ -102,13 +103,15 @@ impl ProbeProfiles {
Self {
ghz2: profile,
ghz5: profile,
ghz6: profile,
}
}
const fn on(self, channel: Channel) -> TxProfile {
pub const fn on(self, channel: Channel) -> TxProfile {
match channel.band {
Band::Ghz2 => self.ghz2,
Band::Ghz5 | Band::Ghz6 => self.ghz5,
Band::Ghz5 => self.ghz5,
Band::Ghz6 => self.ghz6,
}
}
}
@@ -132,9 +135,6 @@ impl Operation {
fn validate(self) -> Result<(), Error> {
let channel = self.channel();
if channel.band == Band::Ghz6 {
return Err(Error::Unsupported);
}
if let Self::Transmit { profile, .. } = self
&& ((profile.rate.cck() && channel.band != Band::Ghz2)
|| (profile.short_preamble
@@ -286,7 +286,7 @@ fn later_channel_failure_and_active_profile_never_publish_a_partial_scan() {
.unwrap();
assert!(matches!(
owner.admit_scan(&six, None),
Err(Error::Unsupported)
Err(Error::HardwareDenied)
));
}
#[test]