2
0
mirror of https://github.com/m-labs/artiq.git synced 2025-01-13 20:38:56 +08:00

drtio-proto: merge coremgmt ACK adn NACK

This commit is contained in:
occheung 2024-08-29 13:08:38 +08:00
parent 7af8511de3
commit 5502aefa39
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 {
@ -505,8 +504,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))
}) })
@ -876,8 +876,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

@ -216,7 +216,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(())
} }
@ -267,7 +267,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(())
} }
@ -293,7 +293,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(())
} }
@ -371,7 +371,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)
@ -410,7 +410,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(())
} }
@ -437,7 +437,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(())
} }
@ -464,7 +464,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(())
} }
@ -491,7 +491,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

@ -504,13 +504,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,
@ -524,7 +524,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() {
@ -538,7 +538,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 })
} }
} }
} }
@ -565,7 +565,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 } => {
@ -576,16 +576,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)
}
} }
} }
} }