Compare commits

...

3 Commits

Author SHA1 Message Date
occheung 31936bee98 cargo fmt 2024-08-21 15:30:15 +08:00
occheung 60c347693f drtio_mgmt: impl unsuppported packets 2024-08-21 15:05:21 +08:00
occheung cc5a666dc6 drtio_proto; remove pull log request 2024-08-21 12:10:12 +08:00
3 changed files with 124 additions and 41 deletions

View File

@ -305,15 +305,6 @@ pub enum Packet {
CoreMgmtClearLogRequest {
destination: u8,
},
CoreMgmtPullLogRequest {
destination: u8,
},
CoreMgmtPullLogReply {
destination: u8,
last: bool,
length: u16,
data: [u8; CORE_MGMT_PAYLOAD_MAX_SIZE],
},
CoreMgmtSetLogLevelRequest {
destination: u8,
log_level: u8,
@ -653,22 +644,6 @@ impl Packet {
0xd2 => Packet::CoreMgmtClearLogRequest {
destination: reader.read_u8()?,
},
0xd3 => Packet::CoreMgmtPullLogRequest {
destination: reader.read_u8()?,
},
0xd4 => {
let destination = reader.read_u8()?;
let last = reader.read_bool()?;
let length = reader.read_u16()?;
let mut data: [u8; CORE_MGMT_PAYLOAD_MAX_SIZE] = [0; CORE_MGMT_PAYLOAD_MAX_SIZE];
reader.read_exact(&mut data[0..length as usize])?;
Packet::CoreMgmtPullLogReply {
destination: destination,
last: last,
length: length,
data: data,
}
}
0xd5 => Packet::CoreMgmtSetLogLevelRequest {
destination: reader.read_u8()?,
log_level: reader.read_u8()?,
@ -1131,22 +1106,6 @@ impl Packet {
writer.write_u8(0xd2)?;
writer.write_u8(destination)?;
}
Packet::CoreMgmtPullLogRequest { destination } => {
writer.write_u8(0xd3)?;
writer.write_u8(destination)?;
}
Packet::CoreMgmtPullLogReply {
destination,
last,
length,
data,
} => {
writer.write_u8(0xd4)?;
writer.write_u8(destination)?;
writer.write_bool(last)?;
writer.write_u16(length)?;
writer.write_all(&data[0..length as usize])?;
}
Packet::CoreMgmtSetLogLevelRequest { destination, log_level } => {
writer.write_u8(0xd5)?;
writer.write_u8(destination)?;

View File

@ -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<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(
stream: &mut TcpStream,
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 {
@ -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,19 @@ 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
)
}
}?;
}
}

View File

@ -1264,6 +1264,23 @@ 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 +1301,23 @@ 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);