diff --git a/flake.lock b/flake.lock index d355ba6..ff735d5 100644 --- a/flake.lock +++ b/flake.lock @@ -3,19 +3,19 @@ "artiq": { "inputs": { "artiq-comtools": "artiq-comtools", - "mozilla-overlay": "mozilla-overlay", "nixpkgs": "nixpkgs", + "rust-overlay": "rust-overlay", "sipyco": "sipyco", "src-migen": "src-migen", "src-misoc": "src-misoc", "src-pythonparser": "src-pythonparser" }, "locked": { - "lastModified": 1717638354, - "narHash": "sha256-eyI8OsOrn/j8ChbCpyFpS5VXBW8xSNGGIboFGQj/d4I=", + "lastModified": 1720514025, + "narHash": "sha256-eU9Lux5olHTxRCwSiApKSPEdNhrlZ2OJ9ZqSofqp9Uk=", "ref": "refs/heads/master", - "rev": "ebc1e3fb767d6c0eac6eac20c3afeaba2ab70d1a", - "revCount": 8833, + "rev": "7a50afd9a96be8e6510d5c952808f39f0b74202a", + "revCount": 8887, "type": "git", "url": "https://github.com/m-labs/artiq.git" }, @@ -100,29 +100,13 @@ "type": "github" } }, - "mozilla-overlay_3": { - "flake": false, - "locked": { - "lastModified": 1704373101, - "narHash": "sha256-+gi59LRWRQmwROrmE1E2b3mtocwueCQqZ60CwLG+gbg=", - "owner": "mozilla", - "repo": "nixpkgs-mozilla", - "rev": "9b11a87c0cc54e308fa83aac5b4ee1816d5418a2", - "type": "github" - }, - "original": { - "owner": "mozilla", - "repo": "nixpkgs-mozilla", - "type": "github" - } - }, "nixpkgs": { "locked": { - "lastModified": 1717281328, - "narHash": "sha256-evZPzpf59oNcDUXxh2GHcxHkTEG4fjae2ytWP85jXRo=", + "lastModified": 1720386169, + "narHash": "sha256-NGKVY4PjzwAa4upkGtAMz1npHGoRzWotlSnVlqI40mo=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "b3b2b28c1daa04fe2ae47c21bb76fd226eac4ca1", + "rev": "194846768975b7ad2c4988bdb82572c00222c0d7", "type": "github" }, "original": { @@ -135,10 +119,31 @@ "root": { "inputs": { "artiq": "artiq", - "mozilla-overlay": "mozilla-overlay_2", + "mozilla-overlay": "mozilla-overlay", "zynq-rs": "zynq-rs" } }, + "rust-overlay": { + "inputs": { + "nixpkgs": [ + "artiq", + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1720491570, + "narHash": "sha256-PHS2BcQ9kxBpu9GKlDg3uAlrX/ahQOoAiVmwGl6BjD4=", + "owner": "oxalica", + "repo": "rust-overlay", + "rev": "b970af40fdc4bd80fd764796c5f97c15e2b564eb", + "type": "github" + }, + "original": { + "owner": "oxalica", + "repo": "rust-overlay", + "type": "github" + } + }, "sipyco": { "inputs": { "nixpkgs": [ @@ -163,11 +168,11 @@ "src-migen": { "flake": false, "locked": { - "lastModified": 1715484909, - "narHash": "sha256-4DCHBUBfc/VA+7NW2Hr0+JP4NnKPru2uVJyZjCCk0Ws=", + "lastModified": 1720332047, + "narHash": "sha256-FdYVEHVtXHrzPhBqpXOTo9uHQAtuCsDPmAPY8JrfHOY=", "owner": "m-labs", "repo": "migen", - "rev": "4790bb577681a8c3a8d226bc196a4e5deb39e4df", + "rev": "60739a161e64630ce7ba62d1a5bac1252b66c3b9", "type": "github" }, "original": { @@ -227,18 +232,18 @@ }, "zynq-rs": { "inputs": { - "mozilla-overlay": "mozilla-overlay_3", + "mozilla-overlay": "mozilla-overlay_2", "nixpkgs": [ "artiq", "nixpkgs" ] }, "locked": { - "lastModified": 1716889070, - "narHash": "sha256-w+M5NfukmcMTt73+u6Cmltjn4qpQH8bcoTGskB2IzBE=", + "lastModified": 1717654016, + "narHash": "sha256-y/c0EZNDNlxb/yLy/D23X9PLoiQ8I9mXAA0zsVOy2t8=", "ref": "refs/heads/master", - "rev": "51b8111e799ebe90ca231ae4d02f84ede32632d5", - "revCount": 646, + "rev": "0efbbe39fe643c03f15e29c208bff3247a987766", + "revCount": 647, "type": "git", "url": "https://git.m-labs.hk/m-labs/zynq-rs" }, diff --git a/src/gateware/kasli_soc.py b/src/gateware/kasli_soc.py index 45183ad..98d6f41 100755 --- a/src/gateware/kasli_soc.py +++ b/src/gateware/kasli_soc.py @@ -560,7 +560,10 @@ class GenericSatellite(SoCCore): self.submodules.local_io = SyncRTIO( self.rtio_tsc, self.rtio_channels, lane_count=description["sed_lanes"] ) - self.comb += self.drtiosat.async_errors.eq(self.local_io.async_errors) + self.comb += [ + self.drtiosat.async_errors.eq(self.local_io.async_errors), + self.local_io.sed_spread_enable.eq(self.drtiosat.sed_spread_enable.storage) + ] self.submodules.cri_con = rtio.CRIInterconnectShared( [self.drtiosat.cri, self.rtio_dma.cri, self.rtio.cri], diff --git a/src/gateware/zc706.py b/src/gateware/zc706.py index 92c9208..395d6c6 100755 --- a/src/gateware/zc706.py +++ b/src/gateware/zc706.py @@ -487,6 +487,10 @@ class _SatelliteBase(SoCCore): self.csr_devices.append("rtio_dma") self.submodules.local_io = SyncRTIO(self.rtio_tsc, rtio_channels) + self.comb += [ + self.drtiosat.async_errors.eq(self.local_io.async_errors), + self.local_io.sed_spread_enable.eq(self.drtiosat.sed_spread_enable.storage) + ] self.submodules.cri_con = rtio.CRIInterconnectShared( [self.drtiosat.cri, self.rtio_dma.cri, self.rtio.cri], [self.local_io.cri] + self.drtio_cri, diff --git a/src/libksupport/src/kernel/api.rs b/src/libksupport/src/kernel/api.rs index a25d979..836e81e 100644 --- a/src/libksupport/src/kernel/api.rs +++ b/src/libksupport/src/kernel/api.rs @@ -303,6 +303,7 @@ pub fn resolve(required: &[u8]) -> Option { api_libm_f64f64f64!(nextafter), api_libm_f64f64f64!(pow), api_libm_f64f64!(round), + api_libm_f64f64!(rint), api_libm_f64f64!(sin), api_libm_f64f64!(sinh), api_libm_f64f64!(sqrt), diff --git a/src/runtime/src/comms.rs b/src/runtime/src/comms.rs index 7747850..3ee3201 100644 --- a/src/runtime/src/comms.rs +++ b/src/runtime/src/comms.rs @@ -771,7 +771,7 @@ pub fn main(timer: GlobalTimer, cfg: Config) { #[cfg(has_drtio_routing)] drtio_routing::interconnect_disable_all(); - rtio_mgt::startup(&aux_mutex, &drtio_routing_table, &up_destinations, timer); + rtio_mgt::startup(&aux_mutex, &drtio_routing_table, &up_destinations, &cfg, timer); ksupport::setup_device_map(&cfg); analyzer::start(&aux_mutex, &drtio_routing_table, &up_destinations, timer); diff --git a/src/runtime/src/rtio_mgt.rs b/src/runtime/src/rtio_mgt.rs index 60e2fbb..8644e90 100644 --- a/src/runtime/src/rtio_mgt.rs +++ b/src/runtime/src/rtio_mgt.rs @@ -3,7 +3,9 @@ use core::cell::RefCell; use libboard_artiq::{drtio_routing, drtio_routing::RoutingTable, pl::csr}; use libboard_zynq::timer::GlobalTimer; +use libconfig::Config; use libcortex_a9::mutex::Mutex; +use log::{info, warn}; #[cfg(has_drtio)] pub mod drtio { @@ -898,12 +900,36 @@ pub mod drtio { pub fn reset(_aux_mutex: Rc>, _routing_table: &RoutingTable, mut _timer: GlobalTimer) {} } +fn toggle_sed_spread(val: u8) { + unsafe { + csr::rtio_core::sed_spread_enable_write(val); + } +} + +fn setup_sed_spread(cfg: &Config) { + if let Ok(spread_enable) = cfg.read_str("sed_spread_enable") { + match spread_enable.as_ref() { + "1" => toggle_sed_spread(1), + "0" => toggle_sed_spread(0), + _ => { + warn!("sed_spread_enable value not supported (only 1, 0 allowed), disabling by default"); + toggle_sed_spread(0) + } + }; + } else { + info!("SED spreading disabled by default"); + toggle_sed_spread(0); + } +} + pub fn startup( aux_mutex: &Rc>, routing_table: &Rc>, up_destinations: &Rc>, + cfg: &Config, timer: GlobalTimer, ) { + setup_sed_spread(cfg); drtio::startup(aux_mutex, routing_table, up_destinations, timer); unsafe { csr::rtio_core::reset_phy_write(1); diff --git a/src/satman/src/main.rs b/src/satman/src/main.rs index bb41fda..422b260 100644 --- a/src/satman/src/main.rs +++ b/src/satman/src/main.rs @@ -12,6 +12,7 @@ extern crate io; extern crate ksupport; extern crate libboard_artiq; extern crate libboard_zynq; +extern crate libconfig; extern crate libcortex_a9; extern crate libregister; extern crate libsupport_zynq; @@ -38,6 +39,7 @@ use libboard_artiq::{drtio_routing, drtioaux, #[cfg(feature = "target_kasli_soc")] use libboard_zynq::error_led::ErrorLED; use libboard_zynq::{i2c::I2c, print, println, time::Milliseconds, timer::GlobalTimer}; +use libconfig::Config; use libcortex_a9::{l2c::enable_l2_cache, regs::MPIDR}; use libregister::RegisterR; use libsupport_zynq::{exception_vectors, ram}; @@ -81,15 +83,37 @@ fn drtiosat_tsc_loaded() -> bool { } } +fn toggle_sed_spread(val: u8) { + unsafe { + csr::drtiosat::sed_spread_enable_write(val); + } +} + #[cfg(has_drtio_routing)] macro_rules! forward { - ($routing_table:expr, $destination:expr, $rank:expr, $repeaters:expr, $packet:expr, $timer:expr) => {{ + ( + $router:expr, + $routing_table:expr, + $destination:expr, + $rank:expr, + $self_destination:expr, + $repeaters:expr, + $packet:expr, + $timer:expr + ) => {{ let hop = $routing_table.0[$destination as usize][$rank as usize]; if hop != 0 { let repno = (hop - 1) as usize; if repno < $repeaters.len() { if $packet.expects_response() { - return $repeaters[repno].aux_forward($packet, $timer); + return $repeaters[repno].aux_forward( + $packet, + $router, + $routing_table, + $rank, + $self_destination, + $timer, + ); } else { return $repeaters[repno].aux_send($packet); } @@ -102,7 +126,16 @@ macro_rules! forward { #[cfg(not(has_drtio_routing))] macro_rules! forward { - ($routing_table:expr, $destination:expr, $rank:expr, $repeaters:expr, $packet:expr, $timer:expr) => {}; + ( + $router:expr, + $routing_table:expr, + $destination:expr, + $rank:expr, + $self_destination:expr, + $repeaters:expr, + $packet:expr, + $timer:expr + ) => {}; } fn process_aux_packet( @@ -183,6 +216,10 @@ fn process_aux_packet( &drtioaux::Packet::DestinationStatusRequest { destination: destination, }, + router, + _routing_table, + *rank, + *self_destination, timer, ) { Ok(()) => (), @@ -244,7 +281,16 @@ fn process_aux_packet( channel, probe, } => { - forward!(_routing_table, _destination, *rank, _repeaters, &packet, timer); + forward!( + router, + _routing_table, + _destination, + *rank, + *self_destination, + _repeaters, + &packet, + timer + ); let value; #[cfg(has_rtio_moninj)] unsafe { @@ -266,7 +312,16 @@ fn process_aux_packet( overrd, value, } => { - forward!(_routing_table, _destination, *rank, _repeaters, &packet, timer); + forward!( + router, + _routing_table, + _destination, + *rank, + *self_destination, + _repeaters, + &packet, + timer + ); #[cfg(has_rtio_moninj)] unsafe { csr::rtio_moninj::inj_chan_sel_write(channel as _); @@ -280,7 +335,16 @@ fn process_aux_packet( channel, overrd, } => { - forward!(_routing_table, _destination, *rank, _repeaters, &packet, timer); + forward!( + router, + _routing_table, + _destination, + *rank, + *self_destination, + _repeaters, + &packet, + timer + ); let value; #[cfg(has_rtio_moninj)] unsafe { @@ -299,7 +363,16 @@ fn process_aux_packet( destination: _destination, busno: _busno, } => { - forward!(_routing_table, _destination, *rank, _repeaters, &packet, timer); + forward!( + router, + _routing_table, + _destination, + *rank, + *self_destination, + _repeaters, + &packet, + timer + ); let succeeded = i2c.start().is_ok(); drtioaux::send(0, &drtioaux::Packet::I2cBasicReply { succeeded: succeeded }) } @@ -307,7 +380,16 @@ fn process_aux_packet( destination: _destination, busno: _busno, } => { - forward!(_routing_table, _destination, *rank, _repeaters, &packet, timer); + forward!( + router, + _routing_table, + _destination, + *rank, + *self_destination, + _repeaters, + &packet, + timer + ); let succeeded = i2c.restart().is_ok(); drtioaux::send(0, &drtioaux::Packet::I2cBasicReply { succeeded: succeeded }) } @@ -315,7 +397,16 @@ fn process_aux_packet( destination: _destination, busno: _busno, } => { - forward!(_routing_table, _destination, *rank, _repeaters, &packet, timer); + forward!( + router, + _routing_table, + _destination, + *rank, + *self_destination, + _repeaters, + &packet, + timer + ); let succeeded = i2c.stop().is_ok(); drtioaux::send(0, &drtioaux::Packet::I2cBasicReply { succeeded: succeeded }) } @@ -324,7 +415,16 @@ fn process_aux_packet( busno: _busno, data, } => { - forward!(_routing_table, _destination, *rank, _repeaters, &packet, timer); + forward!( + router, + _routing_table, + _destination, + *rank, + *self_destination, + _repeaters, + &packet, + timer + ); match i2c.write(data) { Ok(ack) => drtioaux::send( 0, @@ -347,7 +447,16 @@ fn process_aux_packet( busno: _busno, ack, } => { - forward!(_routing_table, _destination, *rank, _repeaters, &packet, timer); + forward!( + router, + _routing_table, + _destination, + *rank, + *self_destination, + _repeaters, + &packet, + timer + ); match i2c.read(ack) { Ok(data) => drtioaux::send( 0, @@ -371,7 +480,16 @@ fn process_aux_packet( address, mask, } => { - forward!(_routing_table, _destination, *rank, _repeaters, &packet, timer); + forward!( + router, + _routing_table, + _destination, + *rank, + *self_destination, + _repeaters, + &packet, + timer + ); let ch = match mask { //decode from mainline, PCA9548-centric API 0x00 => None, @@ -397,7 +515,16 @@ fn process_aux_packet( div: _div, cs: _cs, } => { - forward!(_routing_table, _destination, *rank, _repeaters, &packet, timer); + forward!( + router, + _routing_table, + _destination, + *rank, + *self_destination, + _repeaters, + &packet, + timer + ); // todo: reimplement when/if SPI is available //let succeeded = spi::set_config(busno, flags, length, div, cs).is_ok(); drtioaux::send(0, &drtioaux::Packet::SpiBasicReply { succeeded: false }) @@ -407,7 +534,16 @@ fn process_aux_packet( busno: _busno, data: _data, } => { - forward!(_routing_table, _destination, *rank, _repeaters, &packet, timer); + forward!( + router, + _routing_table, + _destination, + *rank, + *self_destination, + _repeaters, + &packet, + timer + ); // todo: reimplement when/if SPI is available //let succeeded = spi::write(busno, data).is_ok(); drtioaux::send(0, &drtioaux::Packet::SpiBasicReply { succeeded: false }) @@ -416,7 +552,16 @@ fn process_aux_packet( destination: _destination, busno: _busno, } => { - forward!(_routing_table, _destination, *rank, _repeaters, &packet, timer); + forward!( + router, + _routing_table, + _destination, + *rank, + *self_destination, + _repeaters, + &packet, + timer + ); // todo: reimplement when/if SPI is available // match spi::read(busno) { // Ok(data) => drtioaux::send(0, @@ -436,7 +581,16 @@ fn process_aux_packet( drtioaux::Packet::AnalyzerHeaderRequest { destination: _destination, } => { - forward!(_routing_table, _destination, *rank, _repeaters, &packet, timer); + forward!( + router, + _routing_table, + _destination, + *rank, + *self_destination, + _repeaters, + &packet, + timer + ); let header = analyzer.get_header(); drtioaux::send( 0, @@ -450,7 +604,16 @@ fn process_aux_packet( drtioaux::Packet::AnalyzerDataRequest { destination: _destination, } => { - forward!(_routing_table, _destination, *rank, _repeaters, &packet, timer); + forward!( + router, + _routing_table, + _destination, + *rank, + *self_destination, + _repeaters, + &packet, + timer + ); let mut data_slice: [u8; SAT_PAYLOAD_MAX_SIZE] = [0; SAT_PAYLOAD_MAX_SIZE]; let meta = analyzer.get_data(&mut data_slice); drtioaux::send( @@ -471,7 +634,16 @@ fn process_aux_packet( length, trace, } => { - forward!(_routing_table, destination, *rank, _repeaters, &packet, timer); + forward!( + router, + _routing_table, + destination, + *rank, + *self_destination, + _repeaters, + &packet, + timer + ); *self_destination = destination; let succeeded = dma_manager.add(source, id, status, &trace, length as usize).is_ok(); router.send( @@ -492,7 +664,16 @@ fn process_aux_packet( id, succeeded, } => { - forward!(_routing_table, _destination, *rank, _repeaters, &packet, timer); + forward!( + router, + _routing_table, + _destination, + *rank, + *self_destination, + _repeaters, + &packet, + timer + ); dma_manager.ack_upload( kernel_manager, source, @@ -510,7 +691,16 @@ fn process_aux_packet( destination: _destination, id, } => { - forward!(_routing_table, _destination, *rank, _repeaters, &packet, timer); + forward!( + router, + _routing_table, + _destination, + *rank, + *self_destination, + _repeaters, + &packet, + timer + ); let succeeded = dma_manager.erase(source, id).is_ok(); router.send( drtioaux::Packet::DmaRemoveTraceReply { @@ -526,7 +716,16 @@ fn process_aux_packet( destination: _destination, succeeded: _, } => { - forward!(_routing_table, _destination, *rank, _repeaters, &packet, timer); + forward!( + router, + _routing_table, + _destination, + *rank, + *self_destination, + _repeaters, + &packet, + timer + ); Ok(()) } drtioaux::Packet::DmaPlaybackRequest { @@ -535,7 +734,16 @@ fn process_aux_packet( id, timestamp, } => { - forward!(_routing_table, _destination, *rank, _repeaters, &packet, timer); + forward!( + router, + _routing_table, + _destination, + *rank, + *self_destination, + _repeaters, + &packet, + timer + ); let succeeded = if !kernel_manager.running() { dma_manager.playback(source, id, timestamp).is_ok() } else { @@ -555,7 +763,16 @@ fn process_aux_packet( destination: _destination, succeeded, } => { - forward!(_routing_table, _destination, *rank, _repeaters, &packet, timer); + forward!( + router, + _routing_table, + _destination, + *rank, + *self_destination, + _repeaters, + &packet, + timer + ); if !succeeded { kernel_manager.ddma_nack(); } @@ -569,7 +786,16 @@ fn process_aux_packet( channel, timestamp, } => { - forward!(_routing_table, _destination, *rank, _repeaters, &packet, timer); + forward!( + router, + _routing_table, + _destination, + *rank, + *self_destination, + _repeaters, + &packet, + timer + ); dma_manager.remote_finished(kernel_manager, id, error, channel, timestamp); Ok(()) } @@ -581,7 +807,16 @@ fn process_aux_packet( length, data, } => { - forward!(_routing_table, destination, *rank, _repeaters, &packet, timer); + forward!( + router, + _routing_table, + destination, + *rank, + *self_destination, + _repeaters, + &packet, + timer + ); *self_destination = destination; let succeeded = kernel_manager.add(id, status, &data, length as usize).is_ok(); drtioaux::send(0, &drtioaux::Packet::SubkernelAddDataReply { succeeded: succeeded }) @@ -592,7 +827,16 @@ fn process_aux_packet( id, run, } => { - forward!(_routing_table, _destination, *rank, _repeaters, &packet, timer); + forward!( + router, + _routing_table, + _destination, + *rank, + *self_destination, + _repeaters, + &packet, + timer + ); let mut succeeded = kernel_manager.load(id).is_ok(); // allow preloading a kernel with delayed run if run { @@ -617,7 +861,16 @@ fn process_aux_packet( destination: _destination, succeeded, } => { - forward!(_routing_table, _destination, *rank, _repeaters, &packet, timer); + forward!( + router, + _routing_table, + _destination, + *rank, + *self_destination, + _repeaters, + &packet, + timer + ); // received if local subkernel started another, remote subkernel kernel_manager.subkernel_load_run_reply(succeeded); Ok(()) @@ -628,14 +881,32 @@ fn process_aux_packet( with_exception, exception_src, } => { - forward!(_routing_table, _destination, *rank, _repeaters, &packet, timer); + forward!( + router, + _routing_table, + _destination, + *rank, + *self_destination, + _repeaters, + &packet, + timer + ); kernel_manager.remote_subkernel_finished(id, with_exception, exception_src); Ok(()) } drtioaux::Packet::SubkernelExceptionRequest { destination: _destination, } => { - forward!(_routing_table, _destination, *rank, _repeaters, &packet, timer); + forward!( + router, + _routing_table, + _destination, + *rank, + *self_destination, + _repeaters, + &packet, + timer + ); let mut data_slice: [u8; SAT_PAYLOAD_MAX_SIZE] = [0; SAT_PAYLOAD_MAX_SIZE]; let meta = kernel_manager.exception_get_slice(&mut data_slice); drtioaux::send( @@ -655,7 +926,16 @@ fn process_aux_packet( length, data, } => { - forward!(_routing_table, _destination, *rank, _repeaters, &packet, timer); + forward!( + router, + _routing_table, + _destination, + *rank, + *self_destination, + _repeaters, + &packet, + timer + ); kernel_manager.message_handle_incoming(status, id, length as usize, &data); router.send( drtioaux::Packet::SubkernelMessageAck { destination: source }, @@ -667,7 +947,16 @@ fn process_aux_packet( drtioaux::Packet::SubkernelMessageAck { destination: _destination, } => { - forward!(_routing_table, _destination, *rank, _repeaters, &packet, timer); + forward!( + router, + _routing_table, + _destination, + *rank, + *self_destination, + _repeaters, + &packet, + timer + ); if kernel_manager.message_ack_slice() { let mut data_slice: [u8; MASTER_PAYLOAD_MAX_SIZE] = [0; MASTER_PAYLOAD_MAX_SIZE]; if let Some(meta) = kernel_manager.message_get_slice(&mut data_slice) { @@ -920,6 +1209,28 @@ pub extern "C" fn main_core0() -> i32 { #[cfg(has_si549)] si549::helper_setup(&mut timer, &SI549_SETTINGS).expect("cannot initialize helper Si549"); + let cfg = match Config::new() { + Ok(cfg) => cfg, + Err(err) => { + warn!("config initialization failed: {}", err); + Config::new_dummy() + } + }; + + if let Ok(spread_enable) = cfg.read_str("sed_spread_enable") { + match spread_enable.as_ref() { + "1" => toggle_sed_spread(1), + "0" => toggle_sed_spread(0), + _ => { + warn!("sed_spread_enable value not supported (only 1, 0 allowed), disabling by default"); + toggle_sed_spread(0) + } + }; + } else { + info!("SED spreading disabled by default"); + toggle_sed_spread(0); + } + #[cfg(has_drtio_routing)] let mut repeaters = [repeater::Repeater::default(); csr::DRTIOREP.len()]; #[cfg(not(has_drtio_routing))] diff --git a/src/satman/src/repeater.rs b/src/satman/src/repeater.rs index 9ebc9b7..7834007 100644 --- a/src/satman/src/repeater.rs +++ b/src/satman/src/repeater.rs @@ -208,10 +208,37 @@ impl Repeater { } } - pub fn aux_forward(&self, request: &drtioaux::Packet, timer: &mut GlobalTimer) -> Result<(), drtioaux::Error> { + pub fn aux_forward( + &self, + request: &drtioaux::Packet, + router: &mut Router, + routing_table: &drtio_routing::RoutingTable, + rank: u8, + self_destination: u8, + timer: &mut GlobalTimer, + ) -> Result<(), drtioaux::Error> { self.aux_send(request)?; - let reply = self.recv_aux_timeout(200, timer)?; - drtioaux::send(0, &reply).unwrap(); + loop { + let reply = self.recv_aux_timeout(200, timer)?; + match reply { + // async/locally requested packets to be consumed or routed + // these may come while a packet would be forwarded + drtioaux::Packet::DmaPlaybackStatus { .. } + | drtioaux::Packet::SubkernelFinished { .. } + | drtioaux::Packet::SubkernelMessage { .. } + | drtioaux::Packet::SubkernelMessageAck { .. } + | drtioaux::Packet::SubkernelLoadRunReply { .. } + | drtioaux::Packet::SubkernelException { .. } + | drtioaux::Packet::DmaAddTraceReply { .. } + | drtioaux::Packet::DmaPlaybackReply { .. } => { + router.route(reply, routing_table, rank, self_destination); + } + _ => { + drtioaux::send(0, &reply).unwrap(); + break; + } + } + } Ok(()) }