From 60c347693f8f9e4e80387a9e067426cabf91830a Mon Sep 17 00:00:00 2001 From: occheung Date: Wed, 21 Aug 2024 15:05:21 +0800 Subject: [PATCH] drtio_mgmt: impl unsuppported packets --- src/runtime/src/mgmt.rs | 83 +++++++++++++++++++++++++++++++++++++++++ src/satman/src/main.rs | 30 +++++++++++++++ 2 files changed, 113 insertions(+) diff --git a/src/runtime/src/mgmt.rs b/src/runtime/src/mgmt.rs index a2687bc..32b580e 100644 --- a/src/runtime/src/mgmt.rs +++ b/src/runtime/src/mgmt.rs @@ -67,6 +67,9 @@ pub enum Request { ConfigRead = 12, ConfigWrite = 13, ConfigRemove = 14, + ConfigErase = 15, + + DebugAllocator = 8 } #[repr(i8)] @@ -469,6 +472,37 @@ mod remote_coremgmt { } } + pub async fn config_erase( + stream: &mut TcpStream, + aux_mutex: &Rc>, + routing_table: &drtio_routing::RoutingTable, + timer: GlobalTimer, + linkno: u8, + destination: u8, + ) -> Result<()> { + let reply = drtio::aux_transact( + aux_mutex, + linkno, + routing_table, + &Packet::CoreMgmtConfigEraseRequest { + destination: destination, + }, + timer, + ) + .await?; + + match reply { + Packet::CoreMgmtAck { succeeded: true } => { + write_i8(stream, Reply::Success as i8).await?; + Ok(()) + } + _ => { + write_i8(stream, Reply::Error as i8).await?; + Err(drtio::Error::UnexpectedReply.into()) + } + } + } + pub async fn reboot( stream: &mut TcpStream, aux_mutex: &Rc>, @@ -501,6 +535,38 @@ mod remote_coremgmt { } } } + + pub async fn debug_allocator( + stream: &mut TcpStream, + aux_mutex: &Rc>, + routing_table: &drtio_routing::RoutingTable, + timer: GlobalTimer, + linkno: u8, + destination: u8, + ) -> Result<()> { + let reply = drtio::aux_transact( + aux_mutex, + linkno, + routing_table, + &Packet::CoreMgmtAllocatorDebugRequest { + destination: destination, + }, + timer, + ) + .await?; + + match reply { + Packet::CoreMgmtAck { succeeded: true } => { + write_i8(stream, Reply::Success as i8).await?; + Ok(()) + } + _ => { + error!("received unknown packet"); + write_i8(stream, Reply::Error as i8).await?; + Err(drtio::Error::UnexpectedReply.into()) + } + } + } } mod local_coremgmt { @@ -607,6 +673,12 @@ mod local_coremgmt { Ok(()) } + pub async fn config_erase(stream: &mut TcpStream) -> Result<()> { + error!("zynq device does not support config erase"); + write_i8(stream, Reply::Error as i8).await?; + Ok(()) + } + pub async fn reboot(stream: &mut TcpStream) -> Result<()> { info!("rebooting"); write_i8(stream, Reply::RebootImminent as i8).await?; @@ -615,6 +687,11 @@ mod local_coremgmt { unreachable!() } + + pub async fn debug_allocator(_stream: &mut TcpStream) -> Result<()> { + error!("zynq device does not support allocator debug print"); + Ok(()) + } } #[cfg(has_drtio)] @@ -743,6 +820,12 @@ async fn handle_connection( Request::Reboot => { process!(stream, _timer, _aux_mutex, _routing_table, _destination, reboot) } + Request::ConfigErase => { + process!(stream, _timer, _aux_mutex, _routing_table, _destination, config_erase) + } + Request::DebugAllocator => { + process!(stream, _timer, _aux_mutex, _routing_table, _destination, debug_allocator) + } }?; } } diff --git a/src/satman/src/main.rs b/src/satman/src/main.rs index 89f2086..f8f4437 100644 --- a/src/satman/src/main.rs +++ b/src/satman/src/main.rs @@ -1264,6 +1264,21 @@ fn process_aux_packet( } } } + drtioaux::Packet::CoreMgmtConfigEraseRequest { destination: _destination } => { + forward!( + router, + _routing_table, + _destination, + *rank, + *self_destination, + _repeaters, + &packet, + timer + ); + + error!("config erasen not supported on zynq device"); + Ok(()) + } drtioaux::Packet::CoreMgmtRebootRequest { destination: _destination, } => { @@ -1284,6 +1299,21 @@ fn process_aux_packet( slcr::reboot(); Ok(()) } + drtioaux::Packet::CoreMgmtAllocatorDebugRequest { destination: _destination } => { + forward!( + router, + _routing_table, + _destination, + *rank, + *self_destination, + _repeaters, + &packet, + timer + ); + + error!("debug allocator not supported on zynq device"); + Ok(()) + } p => { warn!("received unexpected aux packet: {:?}", p);