drtio_mgmt: impl unsuppported packets

This commit is contained in:
occheung 2024-08-21 15:05:21 +08:00
parent cc5a666dc6
commit 60c347693f
2 changed files with 113 additions and 0 deletions

View File

@ -67,6 +67,9 @@ pub enum Request {
ConfigRead = 12, ConfigRead = 12,
ConfigWrite = 13, ConfigWrite = 13,
ConfigRemove = 14, ConfigRemove = 14,
ConfigErase = 15,
DebugAllocator = 8
} }
#[repr(i8)] #[repr(i8)]
@ -469,6 +472,37 @@ mod remote_coremgmt {
} }
} }
pub async fn config_erase(
stream: &mut TcpStream,
aux_mutex: &Rc<Mutex<bool>>,
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( pub async fn reboot(
stream: &mut TcpStream, stream: &mut TcpStream,
aux_mutex: &Rc<Mutex<bool>>, aux_mutex: &Rc<Mutex<bool>>,
@ -501,6 +535,38 @@ mod remote_coremgmt {
} }
} }
} }
pub async fn debug_allocator(
stream: &mut TcpStream,
aux_mutex: &Rc<Mutex<bool>>,
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 { mod local_coremgmt {
@ -607,6 +673,12 @@ mod local_coremgmt {
Ok(()) 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<()> { pub async fn reboot(stream: &mut TcpStream) -> Result<()> {
info!("rebooting"); info!("rebooting");
write_i8(stream, Reply::RebootImminent as i8).await?; write_i8(stream, Reply::RebootImminent as i8).await?;
@ -615,6 +687,11 @@ mod local_coremgmt {
unreachable!() unreachable!()
} }
pub async fn debug_allocator(_stream: &mut TcpStream) -> Result<()> {
error!("zynq device does not support allocator debug print");
Ok(())
}
} }
#[cfg(has_drtio)] #[cfg(has_drtio)]
@ -743,6 +820,12 @@ async fn handle_connection(
Request::Reboot => { Request::Reboot => {
process!(stream, _timer, _aux_mutex, _routing_table, _destination, 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)
}
}?; }?;
} }
} }

View File

@ -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 { drtioaux::Packet::CoreMgmtRebootRequest {
destination: _destination, destination: _destination,
} => { } => {
@ -1284,6 +1299,21 @@ fn process_aux_packet(
slcr::reboot(); slcr::reboot();
Ok(()) 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 => { p => {
warn!("received unexpected aux packet: {:?}", p); warn!("received unexpected aux packet: {:?}", p);