forked from M-Labs/artiq
1
0
Fork 0

drtio-proto: merge coremgmt ACK adn NACK

This commit is contained in:
occheung 2024-08-29 13:08:38 +08:00
parent 18e18bdb46
commit cd6e5ff378
4 changed files with 26 additions and 32 deletions

View File

@ -141,8 +141,7 @@ pub enum Packet {
CoreMgmtAllocatorDebugRequest { destination: u8 }, CoreMgmtAllocatorDebugRequest { destination: u8 },
CoreMgmtGetLogReply { last: bool, length: u16, data: [u8; SAT_PAYLOAD_MAX_SIZE] }, CoreMgmtGetLogReply { last: bool, length: u16, data: [u8; SAT_PAYLOAD_MAX_SIZE] },
CoreMgmtConfigReadReply { last: bool, length: u16, value: [u8; SAT_PAYLOAD_MAX_SIZE] }, CoreMgmtConfigReadReply { last: bool, length: u16, value: [u8; SAT_PAYLOAD_MAX_SIZE] },
CoreMgmtAck, CoreMgmtReply { succeeded: bool },
CoreMgmtNack,
} }
impl Packet { impl Packet {
@ -501,8 +500,9 @@ impl Packet {
value: value, value: value,
} }
}, },
0xdd => Packet::CoreMgmtAck, 0xdd => Packet::CoreMgmtReply {
0xde => Packet::CoreMgmtNack, succeeded: reader.read_bool()?,
},
ty => return Err(Error::UnknownPacket(ty)) ty => return Err(Error::UnknownPacket(ty))
}) })
@ -869,8 +869,10 @@ impl Packet {
writer.write_u16(length)?; writer.write_u16(length)?;
writer.write_all(&value[0..length as usize])?; writer.write_all(&value[0..length as usize])?;
}, },
Packet::CoreMgmtAck => writer.write_u8(0xdd)?, Packet::CoreMgmtReply { succeeded } => {
Packet::CoreMgmtNack => writer.write_u8(0xde)?, writer.write_u8(0xdd)?;
writer.write_bool(succeeded)?;
},
} }
Ok(()) Ok(())
} }

View File

@ -197,7 +197,7 @@ mod remote_coremgmt {
); );
match reply { match reply {
Ok(Packet::CoreMgmtAck) => { Ok(Packet::CoreMgmtReply { succeeded: true }) => {
Reply::Success.write_to(stream)?; Reply::Success.write_to(stream)?;
Ok(()) Ok(())
} }
@ -248,7 +248,7 @@ mod remote_coremgmt {
); );
match reply { match reply {
Ok(Packet::CoreMgmtAck) => { Ok(Packet::CoreMgmtReply { succeeded: true }) => {
Reply::Success.write_to(stream)?; Reply::Success.write_to(stream)?;
Ok(()) Ok(())
} }
@ -274,7 +274,7 @@ mod remote_coremgmt {
); );
match reply { match reply {
Ok(Packet::CoreMgmtAck) => { Ok(Packet::CoreMgmtReply { succeeded: true }) => {
Reply::Success.write_to(stream)?; Reply::Success.write_to(stream)?;
Ok(()) Ok(())
} }
@ -351,7 +351,7 @@ mod remote_coremgmt {
&Packet::CoreMgmtConfigWriteRequest { &Packet::CoreMgmtConfigWriteRequest {
destination: destination, length: len as u16, last: status.is_last(), data: *slice}); destination: destination, length: len as u16, last: status.is_last(), data: *slice});
match reply { match reply {
Ok(Packet::CoreMgmtAck) => Ok(()), Ok(Packet::CoreMgmtReply { succeeded: true }) => Ok(()),
Ok(packet) => { Ok(packet) => {
error!("received unexpected aux packet: {:?}", packet); error!("received unexpected aux packet: {:?}", packet);
Err(drtio::Error::UnexpectedReply) Err(drtio::Error::UnexpectedReply)
@ -389,7 +389,7 @@ mod remote_coremgmt {
}); });
match reply { match reply {
Ok(Packet::CoreMgmtAck) => { Ok(Packet::CoreMgmtReply { succeeded: true }) => {
Reply::Success.write_to(stream)?; Reply::Success.write_to(stream)?;
Ok(()) Ok(())
} }
@ -416,7 +416,7 @@ mod remote_coremgmt {
}); });
match reply { match reply {
Ok(Packet::CoreMgmtAck) => { Ok(Packet::CoreMgmtReply { succeeded: true }) => {
Reply::Success.write_to(stream)?; Reply::Success.write_to(stream)?;
Ok(()) Ok(())
} }
@ -443,7 +443,7 @@ mod remote_coremgmt {
}); });
match reply { match reply {
Ok(Packet::CoreMgmtAck) => { Ok(Packet::CoreMgmtReply { succeeded: true }) => {
Reply::RebootImminent.write_to(stream)?; Reply::RebootImminent.write_to(stream)?;
Ok(()) Ok(())
} }
@ -470,7 +470,7 @@ mod remote_coremgmt {
}); });
match reply { match reply {
Ok(Packet::CoreMgmtAck) => Ok(()), Ok(Packet::CoreMgmtReply { succeeded: true }) => Ok(()),
Ok(packet) => { Ok(packet) => {
error!("received unexpected aux packet: {:?}", packet); error!("received unexpected aux packet: {:?}", packet);
Err(drtio::Error::UnexpectedReply.into()) Err(drtio::Error::UnexpectedReply.into())

View File

@ -498,13 +498,13 @@ fn process_aux_packet(dmamgr: &mut DmaManager, analyzer: &mut Analyzer, kernelmg
forward!(router, _routing_table, _destination, *rank, *self_destination, _repeaters, &packet); forward!(router, _routing_table, _destination, *rank, *self_destination, _repeaters, &packet);
error!("RISC-V satellite devices do not support buffered logging"); error!("RISC-V satellite devices do not support buffered logging");
drtioaux::send(0, &drtioaux::Packet::CoreMgmtNack) drtioaux::send(0, &drtioaux::Packet::CoreMgmtReply { succeeded: false })
} }
drtioaux::Packet::CoreMgmtSetUartLogLevelRequest { destination: _destination, .. } => { drtioaux::Packet::CoreMgmtSetUartLogLevelRequest { destination: _destination, .. } => {
forward!(router, _routing_table, _destination, *rank, *self_destination, _repeaters, &packet); forward!(router, _routing_table, _destination, *rank, *self_destination, _repeaters, &packet);
error!("RISC-V satellite devices has fixed UART log level fixed at TRACE"); error!("RISC-V satellite devices has fixed UART log level fixed at TRACE");
drtioaux::send(0, &drtioaux::Packet::CoreMgmtNack) drtioaux::send(0, &drtioaux::Packet::CoreMgmtReply { succeeded: false })
} }
drtioaux::Packet::CoreMgmtConfigReadRequest { drtioaux::Packet::CoreMgmtConfigReadRequest {
destination: _destination, destination: _destination,
@ -518,7 +518,7 @@ fn process_aux_packet(dmamgr: &mut DmaManager, analyzer: &mut Analyzer, kernelmg
let key_slice = &key[..length as usize]; let key_slice = &key[..length as usize];
if !key_slice.is_ascii() { if !key_slice.is_ascii() {
error!("invalid key"); error!("invalid key");
drtioaux::send(0, &drtioaux::Packet::CoreMgmtNack) drtioaux::send(0, &drtioaux::Packet::CoreMgmtReply { succeeded: false })
} else { } else {
let key = core::str::from_utf8(key_slice).unwrap(); let key = core::str::from_utf8(key_slice).unwrap();
if coremgr.fetch_config_value(key).is_ok() { if coremgr.fetch_config_value(key).is_ok() {
@ -532,7 +532,7 @@ fn process_aux_packet(dmamgr: &mut DmaManager, analyzer: &mut Analyzer, kernelmg
}, },
) )
} else { } else {
drtioaux::send(0, &drtioaux::Packet::CoreMgmtNack) drtioaux::send(0, &drtioaux::Packet::CoreMgmtReply { succeeded: false })
} }
} }
} }
@ -559,7 +559,7 @@ fn process_aux_packet(dmamgr: &mut DmaManager, analyzer: &mut Analyzer, kernelmg
if last { if last {
coremgr.write_config() coremgr.write_config()
} else { } else {
drtioaux::send(0, &drtioaux::Packet::CoreMgmtAck) drtioaux::send(0, &drtioaux::Packet::CoreMgmtReply { succeeded: true })
} }
} }
drtioaux::Packet::CoreMgmtConfigRemoveRequest { destination: _destination, length, key } => { drtioaux::Packet::CoreMgmtConfigRemoveRequest { destination: _destination, length, key } => {
@ -570,16 +570,12 @@ fn process_aux_packet(dmamgr: &mut DmaManager, analyzer: &mut Analyzer, kernelmg
.map_err(|err| warn!("error on removing config: {:?}", err)) .map_err(|err| warn!("error on removing config: {:?}", err))
.is_ok(); .is_ok();
if succeeded { drtioaux::send(0, &drtioaux::Packet::CoreMgmtReply { succeeded })
drtioaux::send(0, &drtioaux::Packet::CoreMgmtAck)
} else {
drtioaux::send(0, &drtioaux::Packet::CoreMgmtNack)
}
} }
drtioaux::Packet::CoreMgmtRebootRequest { destination: _destination } => { drtioaux::Packet::CoreMgmtRebootRequest { destination: _destination } => {
forward!(router, _routing_table, _destination, *rank, *self_destination, _repeaters, &packet); forward!(router, _routing_table, _destination, *rank, *self_destination, _repeaters, &packet);
drtioaux::send(0, &drtioaux::Packet::CoreMgmtAck)?; drtioaux::send(0, &drtioaux::Packet::CoreMgmtReply { succeeded: true })?;
warn!("restarting"); warn!("restarting");
unsafe { spiflash::reload(); } unsafe { spiflash::reload(); }
} }

View File

@ -45,7 +45,7 @@ impl Manager {
Err(err) => { Err(err) => {
self.clear_data(); self.clear_data();
error!("error on reading key: {:?}", err); error!("error on reading key: {:?}", err);
return drtioaux::send(0, &drtioaux::Packet::CoreMgmtNack); return drtioaux::send(0, &drtioaux::Packet::CoreMgmtReply { succeeded: false });
} }
}; };
@ -53,7 +53,7 @@ impl Manager {
match key.as_str() { match key.as_str() {
"gateware" | "bootloader" | "firmware" => { "gateware" | "bootloader" | "firmware" => {
drtioaux::send(0, &drtioaux::Packet::CoreMgmtAck)?; drtioaux::send(0, &drtioaux::Packet::CoreMgmtReply { succeeded: true })?;
#[cfg(not(soc_platform = "efc"))] #[cfg(not(soc_platform = "efc"))]
unsafe { unsafe {
clock::spin_us(10000); clock::spin_us(10000);
@ -71,11 +71,7 @@ impl Manager {
self.clear_data(); self.clear_data();
if succeeded { drtioaux::send(0, &drtioaux::Packet::CoreMgmtReply { succeeded })
drtioaux::send(0, &drtioaux::Packet::CoreMgmtAck)
} else {
drtioaux::send(0, &drtioaux::Packet::CoreMgmtNack)
}
} }
} }
} }