feat(mediatek): program MT7921 and MT7922 SIFS and slot time in the MAC timing registers at association and on slot changes, as mt792x_mac_set_timeing does
This commit is contained in:
1 parent
f4049ebd35
commit
6ecaf7e49a
7 files changed
+254
-166
No files matched your search
@@ -583,6 +583,11 @@ impl<I: BarIo, Q: QueueIo, C: 'static> Client<I, Q, C> {
|
||||
.clear_peer_admission(p.wcid)
|
||||
.map_err(|e| Error::Bootstrap(super::Error::Control(e)))?;
|
||||
Self::command(s, Command::StationRecord, &peer)?;
|
||||
// BSS_CHANGED_ERP_SLOT: connac2's MAC timing
|
||||
// (mt7921_bss_info_changed); the MT7925 keeps its own.
|
||||
if s.controller.state().identity.chip != Chip::Mt7925 {
|
||||
Self::set_timing(&mut s.controller, p)?;
|
||||
}
|
||||
Self::command(s, Command::StationRecord, &broadcast)?;
|
||||
let beacon_filter = codec.beacon_filter(p).map_err(Error::Codec)?;
|
||||
Self::send(s, &beacon_filter)?;
|
||||
|
||||
@@ -447,17 +447,9 @@ impl<I: BarIo, Q: QueueIo, C: 'static> Client<I, Q, C> {
|
||||
Self::command_ready(s)?;
|
||||
let mut profile = s.profile.ok_or(Error::WrongPhase)?;
|
||||
profile.slot_time = slot;
|
||||
let Some(body) = Self::codec(s).timing(profile).map_err(Error::Codec)? else {
|
||||
// connac2 keeps the slot time in the MAC's timing registers
|
||||
// (`mt792x_mac_set_timeing`), which this driver does not
|
||||
// program: report the change and keep the current timing.
|
||||
s.slot_time = None;
|
||||
s.csa.ready.try_reserve(1).map_err(|_| Error::NoMemory)?;
|
||||
s.csa.ready.push(Event::Unsupported(
|
||||
"a 2.4 GHz slot time change on MT7921 or MT7922: the MAC keeps its timing",
|
||||
));
|
||||
return Ok(());
|
||||
};
|
||||
// connac2 keeps the slot time in the MAC's timing registers
|
||||
// (`mt792x_mac_set_timeing`); the MT7925 takes a BSS_INFO_UPDATE.
|
||||
let body = Self::codec(s).timing(profile).map_err(Error::Codec)?;
|
||||
s.replies.try_reserve(1).map_err(|_| Error::NoMemory)?;
|
||||
let phase = &mut s.phase;
|
||||
let current = &mut s.profile;
|
||||
@@ -471,7 +463,12 @@ impl<I: BarIo, Q: QueueIo, C: 'static> Client<I, Q, C> {
|
||||
wifi::regulatory::AssociationUse::Management,
|
||||
|_, _| {
|
||||
*phase = Phase::Quarantined;
|
||||
Self::command_parts(controller, replies, Command::BssInfo, &body)?;
|
||||
match &body {
|
||||
Some(body) => {
|
||||
Self::command_parts(controller, replies, Command::BssInfo, body)?
|
||||
}
|
||||
None => Self::set_timing(controller, profile)?,
|
||||
}
|
||||
*current = Some(profile);
|
||||
*phase = Phase::Associated;
|
||||
Ok(())
|
||||
@@ -483,6 +480,19 @@ impl<I: BarIo, Q: QueueIo, C: 'static> Client<I, Q, C> {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// `mt792x_mac_set_timeing` on a connac2 chip: the profile's band's
|
||||
/// SIFS and its slot time in the MAC's timing registers.
|
||||
pub(super) fn set_timing(
|
||||
controller: &mut Controller<I, Q, C>,
|
||||
profile: Profile,
|
||||
) -> Result<(), Error> {
|
||||
controller
|
||||
.state_mut()
|
||||
.control
|
||||
.set_timing(profile.channel.band == wifi::Band::Ghz2, profile.slot_time)
|
||||
.map_err(|e| Error::Bootstrap(super::super::Error::Control(e)))
|
||||
}
|
||||
|
||||
/// No received event waits ahead of a command's reply.
|
||||
pub(super) fn command_ready(s: &Owned<I, Q, C>) -> Result<(), Error> {
|
||||
let controller = s.controller.state();
|
||||
|
||||
@@ -9,6 +9,9 @@ pub(super) struct Configuration {
|
||||
context: Arc<AssociationContext>,
|
||||
pub(super) wire: wire::modern::Configuration,
|
||||
commands: Vec<wire::Outgoing>,
|
||||
/// How many of `commands` lead them as the BSS's: one MT7925 request,
|
||||
/// or connac2's sequence.
|
||||
bss_commands: usize,
|
||||
filter: crate::wifi::mediatek::mcu::init::Request,
|
||||
completed: usize,
|
||||
pub(super) prepared_edca: [station::phy::AccessCategory; 4],
|
||||
@@ -330,6 +333,7 @@ impl<I: BarIo, Q: QueueIo, C: 'static> Client<I, Q, C> {
|
||||
let format = &mut s.format_generation;
|
||||
let links = &mut s.links;
|
||||
let m = s.modern.as_mut().unwrap();
|
||||
let connac2 = roc.controller.state().identity.chip != Chip::Mt7925;
|
||||
// SAFETY: covered by this function's own safety contract.
|
||||
unsafe {
|
||||
authority.publish_association(
|
||||
@@ -340,7 +344,9 @@ impl<I: BarIo, Q: QueueIo, C: 'static> Client<I, Q, C> {
|
||||
started = true;
|
||||
*format = None;
|
||||
for (index, outgoing) in m.commands.iter().enumerate() {
|
||||
if index == 1 {
|
||||
// The admission counters clear after the BSS's
|
||||
// requests (mt7921_mac_sta_assoc).
|
||||
if index == m.bss_commands {
|
||||
roc.controller
|
||||
.state_mut()
|
||||
.control
|
||||
@@ -349,6 +355,11 @@ impl<I: BarIo, Q: QueueIo, C: 'static> Client<I, Q, C> {
|
||||
Error::Bootstrap(super::super::Error::Control(e))
|
||||
})?;
|
||||
}
|
||||
// BSS_CHANGED_ERP_SLOT after the peer's record:
|
||||
// connac2's MAC timing (mt7921_bss_info_changed).
|
||||
if connac2 && index == m.bss_commands + 1 {
|
||||
Self::set_timing(roc.controller, p)?;
|
||||
}
|
||||
// Source filter transport precedes the final awake update;
|
||||
// preserve its one-way/raw fact rather than inventing ACK.
|
||||
if index + 1 == m.commands.len() {
|
||||
@@ -478,6 +489,7 @@ impl<I: BarIo, Q: QueueIo, C: 'static> Client<I, Q, C> {
|
||||
}
|
||||
let codec = Self::codec(s);
|
||||
let bss = codec.bss(p, Some(&wire), true).map_err(Error::Codec)?;
|
||||
let bss_commands = bss.len();
|
||||
let mut commands = Vec::new();
|
||||
commands
|
||||
.try_reserve_exact(6 + bss.len())
|
||||
@@ -523,6 +535,7 @@ impl<I: BarIo, Q: QueueIo, C: 'static> Client<I, Q, C> {
|
||||
context,
|
||||
wire,
|
||||
commands,
|
||||
bss_commands,
|
||||
filter,
|
||||
completed: 0,
|
||||
prepared_edca,
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
extern crate std;
|
||||
use super::super::tests::{CHIPS, done, setup_modern, setup_modern_radio, setup_on};
|
||||
use super::super::tests::{CHIPS, done, setup_modern, setup_on, setup_radio_on};
|
||||
use super::*;
|
||||
use crate::bus::dma::memory::{CacheAttribute, MemoryError, PageGeometry, PinnedPages};
|
||||
use crate::wifi::mediatek::{
|
||||
@@ -821,160 +821,174 @@ fn actual_2ghz_he20_profile_scans_associates_and_carries_ethernet_on_its_real_ch
|
||||
number: 1,
|
||||
frequency_mhz: 2412,
|
||||
};
|
||||
let (client, model) = setup_modern_radio(false, channel);
|
||||
let actual = client.local_advertisement(Band::Ghz2).unwrap();
|
||||
let mut local = vec![0, 1, b'x'];
|
||||
let mut at = 0;
|
||||
while at < actual.elements().len() {
|
||||
let n = usize::from(actual.elements()[at + 1]);
|
||||
let ie = &actual.elements()[at..at + 2 + n];
|
||||
// A real frontend can select the HE subset. Preserve its
|
||||
// original source maps after parsing exactly the advertised bytes.
|
||||
if ie[0] != 255 || ie[2] != 108 {
|
||||
local.extend_from_slice(ie);
|
||||
for chip in CHIPS {
|
||||
let (client, model) = setup_radio_on(chip, channel);
|
||||
let actual = client.local_advertisement(Band::Ghz2).unwrap();
|
||||
let mut local = vec![0, 1, b'x'];
|
||||
let mut at = 0;
|
||||
while at < actual.elements().len() {
|
||||
let n = usize::from(actual.elements()[at + 1]);
|
||||
let ie = &actual.elements()[at..at + 2 + n];
|
||||
// A real frontend can select the HE subset. Preserve its
|
||||
// original source maps after parsing exactly the advertised bytes.
|
||||
if ie[0] != 255 || ie[2] != 108 {
|
||||
local.extend_from_slice(ie);
|
||||
}
|
||||
at += 2 + n;
|
||||
}
|
||||
at += 2 + n;
|
||||
}
|
||||
local.extend_from_slice(&[
|
||||
48, 18, 1, 0, 0, 15, 172, 4, 1, 0, 0, 15, 172, 4, 1, 0, 0, 15, 172, 2,
|
||||
]);
|
||||
let caps = Capabilities::parse(Band::Ghz2, Role::Station, &local)
|
||||
.unwrap()
|
||||
.with_local_he_source_maps(*actual.he_source_maps())
|
||||
local.extend_from_slice(&[
|
||||
48, 18, 1, 0, 0, 15, 172, 4, 1, 0, 0, 15, 172, 4, 1, 0, 0, 15, 172, 2,
|
||||
]);
|
||||
let caps = Capabilities::parse(Band::Ghz2, Role::Station, &local)
|
||||
.unwrap()
|
||||
.with_local_he_source_maps(*actual.he_source_maps())
|
||||
.unwrap();
|
||||
let request = AssociationRequest::new_modern_with_local(
|
||||
0x11,
|
||||
10,
|
||||
local.clone(),
|
||||
caps,
|
||||
Mode::He,
|
||||
Width::Mhz20,
|
||||
)
|
||||
.unwrap();
|
||||
let request = AssociationRequest::new_modern_with_local(
|
||||
0x11,
|
||||
10,
|
||||
local.clone(),
|
||||
caps,
|
||||
Mode::He,
|
||||
Width::Mhz20,
|
||||
)
|
||||
.unwrap();
|
||||
let mut ap = Vec::new();
|
||||
at = 0;
|
||||
while at < local.len() {
|
||||
let n = usize::from(local[at + 1]);
|
||||
let ie = &local[at..at + 2 + n];
|
||||
if ie[0] == 221 {
|
||||
ap.extend_from_slice(&[
|
||||
221, 24, 0, 0x50, 0xf2, 2, 1, 1, 0x80, 0, 3, 0xa4, 0, 0, 0x27, 0xa4, 0, 0, 0x42,
|
||||
0x43, 94, 0, 0x62, 0x32, 47, 0,
|
||||
]);
|
||||
} else {
|
||||
let offset = ap.len();
|
||||
ap.extend_from_slice(ie);
|
||||
if ie[0] == 1 {
|
||||
for q in 0..4 {
|
||||
ap[offset + 2 + q] |= 0x80;
|
||||
let mut ap = Vec::new();
|
||||
at = 0;
|
||||
while at < local.len() {
|
||||
let n = usize::from(local[at + 1]);
|
||||
let ie = &local[at..at + 2 + n];
|
||||
if ie[0] == 221 {
|
||||
ap.extend_from_slice(&[
|
||||
221, 24, 0, 0x50, 0xf2, 2, 1, 1, 0x80, 0, 3, 0xa4, 0, 0, 0x27, 0xa4, 0, 0,
|
||||
0x42, 0x43, 94, 0, 0x62, 0x32, 47, 0,
|
||||
]);
|
||||
} else {
|
||||
let offset = ap.len();
|
||||
ap.extend_from_slice(ie);
|
||||
if ie[0] == 1 {
|
||||
for q in 0..4 {
|
||||
ap[offset + 2 + q] |= 0x80;
|
||||
}
|
||||
}
|
||||
}
|
||||
at += 2 + n;
|
||||
}
|
||||
at += 2 + n;
|
||||
let mut ht = [0; 22];
|
||||
ht[0] = 1;
|
||||
ap.extend_from_slice(&[61, 22]);
|
||||
ap.extend_from_slice(&ht);
|
||||
ap.extend_from_slice(&[255, 7, 36, 3, 0, 0, 0, 0xff, 0xff, 5, 4, 0, 2, 0, 0]);
|
||||
let drops = Arc::new(AtomicUsize::new(0));
|
||||
let client = ManagedClient::new(client, country(), Environment::Indoor).unwrap();
|
||||
let mut link = ManagedLink::new(
|
||||
client,
|
||||
Provider(drops.clone(), core::sync::atomic::AtomicBool::new(false)),
|
||||
)
|
||||
.unwrap();
|
||||
let receive = |bytes: &[u8], pn: Option<u64>| {
|
||||
let mut raw = incoming_bytes_on(chip, bytes, pn.map(|n| (1, 0, n)), false);
|
||||
raw[13] = 1;
|
||||
device_receive(&model.queues[&0xd4520], &raw, true, 0);
|
||||
};
|
||||
link.begin_scan(
|
||||
scan::Request::new(vec![channel], vec![], vec![]).unwrap(),
|
||||
1_000_000,
|
||||
)
|
||||
.unwrap();
|
||||
let mut body = vec![0; 8];
|
||||
body.extend_from_slice(&100u16.to_le_bytes());
|
||||
body.extend_from_slice(&0x11u16.to_le_bytes());
|
||||
body.extend_from_slice(&ap);
|
||||
let mut beacon = response(0x80, &body);
|
||||
beacon[4..10].fill(255);
|
||||
receive(&beacon, None);
|
||||
link.service().unwrap();
|
||||
let handle = link.bss().next().unwrap().0;
|
||||
done(&model);
|
||||
link.service().unwrap();
|
||||
// SAFETY: completed model scan/radio/RX work independently drained.
|
||||
unsafe { link.retire_scan_after_drain() }.unwrap();
|
||||
let mut profile = profile();
|
||||
profile.channel = channel;
|
||||
profile.basic_rates = 15;
|
||||
profile.supported_rates = 0xfff;
|
||||
profile.slot_time = 20;
|
||||
let join = Join {
|
||||
bssid: AP,
|
||||
channel,
|
||||
policy: station::PortPolicy::Controlled,
|
||||
request,
|
||||
};
|
||||
link.join(handle, join, profile).unwrap();
|
||||
assert_eq!(finish_tx_on(&model, 1)[0][..2], [0xb0, 0]);
|
||||
link.service().unwrap();
|
||||
receive(&response(0xb0, &[0, 0, 2, 0, 0, 0]), None);
|
||||
link.service().unwrap();
|
||||
assert_eq!(finish_tx_on(&model, 1)[0][..2], [0, 0]);
|
||||
link.service().unwrap();
|
||||
let mut assoc = vec![0x11, 0, 0, 0, 1, 0xc0];
|
||||
assoc.extend_from_slice(&ap);
|
||||
receive(&response(0x10, &assoc), None);
|
||||
link.service().unwrap();
|
||||
link.configure().unwrap();
|
||||
secure(&mut link);
|
||||
// The authorized port enters power save first.
|
||||
link.service().unwrap();
|
||||
// The association's long slot, in connac2's MAC timing registers
|
||||
// (mt792x_mac_set_timeing): the 2.4 GHz SIFS and 20 us.
|
||||
let icr0 = |slot: u32| (1, 0x210a4, 360 | (2 << 10) | (10 << 16) | (slot << 24));
|
||||
if chip != Chip::Mt7925 {
|
||||
let log = model.bar.0.lock().unwrap().log.clone();
|
||||
assert!(log.contains(&icr0(20)));
|
||||
assert!(!log.contains(&icr0(9)));
|
||||
}
|
||||
// A beacon turning on Short Slot Time moves the BSS to 9 us, as
|
||||
// mt7925_mcu_set_timing sends it and mt792x_mac_set_timeing programs it.
|
||||
let mut short = beacon.clone();
|
||||
short[35] |= 0x04;
|
||||
receive(&short, None);
|
||||
link.service().unwrap();
|
||||
if chip == Chip::Mt7925 {
|
||||
let command = model
|
||||
.response
|
||||
.lock()
|
||||
.unwrap()
|
||||
.client_commands
|
||||
.last()
|
||||
.unwrap()
|
||||
.clone();
|
||||
assert_eq!(command[48 + 4..48 + 14], [23, 0, 20, 0, 1, 0, 0, 0, 9, 0]);
|
||||
} else {
|
||||
assert!(model.bar.0.lock().unwrap().log.contains(&icr0(9)));
|
||||
}
|
||||
assert_eq!(
|
||||
link.state()
|
||||
.client
|
||||
.client
|
||||
.state()
|
||||
.profile
|
||||
.unwrap()
|
||||
.slot_time,
|
||||
9
|
||||
);
|
||||
link.transmit(ð(0x800)).unwrap();
|
||||
assert_eq!(finish_tx_on(&model, 1).len(), 1);
|
||||
link.service().unwrap();
|
||||
// Its TX-free starts TID 0's block-ack session, as
|
||||
// mt7925_tx_check_aggr does, and the next frame waits for it.
|
||||
drain_notices(&mut link);
|
||||
assert!(link.state().client.client.state().transmit_ba[0].is_some());
|
||||
link.transmit(ð(0x800)).unwrap();
|
||||
assert_eq!(link.state().held.len(), 1);
|
||||
receive(&data(false), Some(1));
|
||||
let frame = link.receive().unwrap().unwrap();
|
||||
assert_eq!(&frame[12..14], &0x800u16.to_be_bytes());
|
||||
assert_eq!(model.response.lock().unwrap().home_channel, Some(1));
|
||||
stop(&mut link, &model);
|
||||
drop(link);
|
||||
assert_eq!(drops.load(Ordering::Relaxed), 1);
|
||||
assert_eq!(model.drops.load(Ordering::Relaxed), 1);
|
||||
}
|
||||
let mut ht = [0; 22];
|
||||
ht[0] = 1;
|
||||
ap.extend_from_slice(&[61, 22]);
|
||||
ap.extend_from_slice(&ht);
|
||||
ap.extend_from_slice(&[255, 7, 36, 3, 0, 0, 0, 0xff, 0xff, 5, 4, 0, 2, 0, 0]);
|
||||
let drops = Arc::new(AtomicUsize::new(0));
|
||||
let client = ManagedClient::new(client, country(), Environment::Indoor).unwrap();
|
||||
let mut link = ManagedLink::new(
|
||||
client,
|
||||
Provider(drops.clone(), core::sync::atomic::AtomicBool::new(false)),
|
||||
)
|
||||
.unwrap();
|
||||
let receive = |bytes: &[u8], pn: Option<u64>| {
|
||||
let mut raw = incoming_bytes(bytes, pn.map(|n| (1, 0, n)), false);
|
||||
raw[13] = 1;
|
||||
device_receive(&model.queues[&0xd4520], &raw, true, 0);
|
||||
};
|
||||
link.begin_scan(
|
||||
scan::Request::new(vec![channel], vec![], vec![]).unwrap(),
|
||||
1_000_000,
|
||||
)
|
||||
.unwrap();
|
||||
let mut body = vec![0; 8];
|
||||
body.extend_from_slice(&100u16.to_le_bytes());
|
||||
body.extend_from_slice(&0x11u16.to_le_bytes());
|
||||
body.extend_from_slice(&ap);
|
||||
let mut beacon = response(0x80, &body);
|
||||
beacon[4..10].fill(255);
|
||||
receive(&beacon, None);
|
||||
link.service().unwrap();
|
||||
let handle = link.bss().next().unwrap().0;
|
||||
done(&model);
|
||||
link.service().unwrap();
|
||||
// SAFETY: completed model scan/radio/RX work independently drained.
|
||||
unsafe { link.retire_scan_after_drain() }.unwrap();
|
||||
let mut profile = profile();
|
||||
profile.channel = channel;
|
||||
profile.basic_rates = 15;
|
||||
profile.supported_rates = 0xfff;
|
||||
profile.slot_time = 20;
|
||||
let join = Join {
|
||||
bssid: AP,
|
||||
channel,
|
||||
policy: station::PortPolicy::Controlled,
|
||||
request,
|
||||
};
|
||||
link.join(handle, join, profile).unwrap();
|
||||
assert_eq!(finish_tx_on(&model, 1)[0][..2], [0xb0, 0]);
|
||||
link.service().unwrap();
|
||||
receive(&response(0xb0, &[0, 0, 2, 0, 0, 0]), None);
|
||||
link.service().unwrap();
|
||||
assert_eq!(finish_tx_on(&model, 1)[0][..2], [0, 0]);
|
||||
link.service().unwrap();
|
||||
let mut assoc = vec![0x11, 0, 0, 0, 1, 0xc0];
|
||||
assoc.extend_from_slice(&ap);
|
||||
receive(&response(0x10, &assoc), None);
|
||||
link.service().unwrap();
|
||||
link.configure().unwrap();
|
||||
secure(&mut link);
|
||||
// The authorized port enters power save first.
|
||||
link.service().unwrap();
|
||||
// A beacon turning on Short Slot Time moves the BSS to 9 us, as
|
||||
// mt7925_mcu_set_timing sends it.
|
||||
let mut short = beacon.clone();
|
||||
short[35] |= 0x04;
|
||||
receive(&short, None);
|
||||
link.service().unwrap();
|
||||
let command = model
|
||||
.response
|
||||
.lock()
|
||||
.unwrap()
|
||||
.client_commands
|
||||
.last()
|
||||
.unwrap()
|
||||
.clone();
|
||||
assert_eq!(command[48 + 4..48 + 14], [23, 0, 20, 0, 1, 0, 0, 0, 9, 0]);
|
||||
assert_eq!(
|
||||
link.state()
|
||||
.client
|
||||
.client
|
||||
.state()
|
||||
.profile
|
||||
.unwrap()
|
||||
.slot_time,
|
||||
9
|
||||
);
|
||||
link.transmit(ð(0x800)).unwrap();
|
||||
assert_eq!(finish_tx_on(&model, 1).len(), 1);
|
||||
link.service().unwrap();
|
||||
// Its TX-free starts TID 0's block-ack session, as
|
||||
// mt7925_tx_check_aggr does, and the next frame waits for it.
|
||||
drain_notices(&mut link);
|
||||
assert!(link.state().client.client.state().transmit_ba[0].is_some());
|
||||
link.transmit(ð(0x800)).unwrap();
|
||||
assert_eq!(link.state().held.len(), 1);
|
||||
receive(&data(false), Some(1));
|
||||
let frame = link.receive().unwrap().unwrap();
|
||||
assert_eq!(&frame[12..14], &0x800u16.to_be_bytes());
|
||||
assert_eq!(model.response.lock().unwrap().home_channel, Some(1));
|
||||
stop(&mut link, &model);
|
||||
drop(link);
|
||||
assert_eq!(drops.load(Ordering::Relaxed), 1);
|
||||
assert_eq!(model.drops.load(Ordering::Relaxed), 1);
|
||||
}
|
||||
#[test]
|
||||
fn native_rx_ring_failure_cannot_leave_cached_association_carrier_up() {
|
||||
|
||||
@@ -20,10 +20,7 @@ pub(super) fn setup_modern() -> (Client<Bar, Q, NativeGuard>, Model) {
|
||||
fn setup_modern_power(split: bool) -> (Client<Bar, Q, NativeGuard>, Model) {
|
||||
setup_modern_radio(split, CHANNEL)
|
||||
}
|
||||
pub(super) fn setup_modern_radio(
|
||||
split: bool,
|
||||
channel: Channel,
|
||||
) -> (Client<Bar, Q, NativeGuard>, Model) {
|
||||
fn setup_modern_radio(split: bool, channel: Channel) -> (Client<Bar, Q, NativeGuard>, Model) {
|
||||
setup_modern_bands(Chip::Mt7925, split, channel, 0, None)
|
||||
}
|
||||
/// A modern client whose board also programs 6 GHz channel 1 with `flags`.
|
||||
@@ -150,6 +147,10 @@ pub(super) fn done(model: &Model) {
|
||||
pub(crate) fn setup_on(chip: Chip) -> (Client<Bar, Q, NativeGuard>, Model) {
|
||||
setup_modern_bands(chip, false, CHANNEL, 0, None)
|
||||
}
|
||||
/// [`setup_on`] started on `channel`.
|
||||
pub(crate) fn setup_radio_on(chip: Chip, channel: Channel) -> (Client<Bar, Q, NativeGuard>, Model) {
|
||||
setup_modern_bands(chip, false, channel, 0, None)
|
||||
}
|
||||
/// The chips whose station journeys run in the model.
|
||||
pub(crate) const CHIPS: [Chip; 3] = [Chip::Mt7925, Chip::Mt7921, Chip::Mt7922];
|
||||
/// connac2's unsolicited SCAN_DONE event, 0x0d, after its 24-byte RXD.
|
||||
|
||||
@@ -77,6 +77,9 @@ pub enum Error {
|
||||
last: u32,
|
||||
},
|
||||
Poisoned,
|
||||
/// A timing the MAC's registers cannot hold, or a chip whose firmware
|
||||
/// keeps it.
|
||||
UnsupportedTiming,
|
||||
}
|
||||
impl From<registers::Error> for Error {
|
||||
fn from(e: registers::Error) -> Self {
|
||||
|
||||
@@ -262,6 +262,48 @@ impl<I: BarIo> Control<I> {
|
||||
})();
|
||||
self.finish(result)
|
||||
}
|
||||
/// `mt792x_mac_set_timeing` for band 0 at coverage class 0: with the
|
||||
/// arbiter's TX and RX held, the CCK and OFDM PLCP and CCA timeouts,
|
||||
/// the band's SIFS (10 us on 2.4 GHz, else 16) and `slot_time`, and the
|
||||
/// CF-End rate (11 Mbps CCK only for a 2.4 GHz long slot). Connac2 only;
|
||||
/// the MT7925's firmware takes the slot time.
|
||||
pub(in crate::wifi::mediatek) fn set_timing(
|
||||
&mut self,
|
||||
two_ghz: bool,
|
||||
slot_time: u16,
|
||||
) -> Result<(), Error> {
|
||||
const ARB_SCR: u32 = 0x820e3080;
|
||||
const TX_RX_DISABLE: u32 = (1 << 8) | (1 << 9);
|
||||
const TMAC_CDTR: u32 = 0x820e4090;
|
||||
const TMAC_ODTR: u32 = 0x820e4094;
|
||||
const TMAC_ICR0: u32 = 0x820e40a4;
|
||||
const AGG_ACR0: u32 = 0x820e2084;
|
||||
if self.chip() == Chip::Mt7925 || slot_time > 0x7f {
|
||||
return Err(Error::UnsupportedTiming);
|
||||
}
|
||||
self.guard(true)?;
|
||||
let result = (|| {
|
||||
self.mac_modify(ARB_SCR, 0, TX_RX_DISABLE)?;
|
||||
block_on(until(self.clock.deadline(1)));
|
||||
self.registers.write32(TMAC_CDTR, 231 | (48 << 16))?;
|
||||
self.registers.write32(TMAC_ODTR, 60 | (28 << 16))?;
|
||||
let sifs = if two_ghz { 10 } else { 16 };
|
||||
self.registers.write32(
|
||||
TMAC_ICR0,
|
||||
360 | (2 << 10) | (sifs << 16) | (u32::from(slot_time) << 24),
|
||||
)?;
|
||||
// MT792x_CFEND_RATE_11B or MT792x_CFEND_RATE_DEFAULT (OFDM 24M).
|
||||
let cf_end = if slot_time < 20 || !two_ghz {
|
||||
0x49
|
||||
} else {
|
||||
0x03
|
||||
};
|
||||
self.mac_modify(AGG_ACR0, 0x3fff, cf_end)?;
|
||||
self.mac_modify(ARB_SCR, TX_RX_DISABLE, 0)?;
|
||||
Ok(())
|
||||
})();
|
||||
self.finish(result)
|
||||
}
|
||||
/// Read-to-clear and airtime reset effects. Host accounting/time
|
||||
/// is held by the lifecycle; no air/duration result is invented.
|
||||
pub(in crate::wifi::mediatek) fn reset_mac_counters(&mut self) -> Result<[u32; 11], Error> {
|
||||
|
||||
Reference in new issue
Block a user