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

View File

@ -197,7 +197,7 @@ mod remote_coremgmt {
);
match reply {
Ok(Packet::CoreMgmtAck) => {
Ok(Packet::CoreMgmtReply { succeeded: true }) => {
Reply::Success.write_to(stream)?;
Ok(())
}
@ -248,7 +248,7 @@ mod remote_coremgmt {
);
match reply {
Ok(Packet::CoreMgmtAck) => {
Ok(Packet::CoreMgmtReply { succeeded: true }) => {
Reply::Success.write_to(stream)?;
Ok(())
}
@ -274,7 +274,7 @@ mod remote_coremgmt {
);
match reply {
Ok(Packet::CoreMgmtAck) => {
Ok(Packet::CoreMgmtReply { succeeded: true }) => {
Reply::Success.write_to(stream)?;
Ok(())
}
@ -351,7 +351,7 @@ mod remote_coremgmt {
&Packet::CoreMgmtConfigWriteRequest {
destination: destination, length: len as u16, last: status.is_last(), data: *slice});
match reply {
Ok(Packet::CoreMgmtAck) => Ok(()),
Ok(Packet::CoreMgmtReply { succeeded: true }) => Ok(()),
Ok(packet) => {
error!("received unexpected aux packet: {:?}", packet);
Err(drtio::Error::UnexpectedReply)
@ -389,7 +389,7 @@ mod remote_coremgmt {
});
match reply {
Ok(Packet::CoreMgmtAck) => {
Ok(Packet::CoreMgmtReply { succeeded: true }) => {
Reply::Success.write_to(stream)?;
Ok(())
}
@ -416,7 +416,7 @@ mod remote_coremgmt {
});
match reply {
Ok(Packet::CoreMgmtAck) => {
Ok(Packet::CoreMgmtReply { succeeded: true }) => {
Reply::Success.write_to(stream)?;
Ok(())
}
@ -443,7 +443,7 @@ mod remote_coremgmt {
});
match reply {
Ok(Packet::CoreMgmtAck) => {
Ok(Packet::CoreMgmtReply { succeeded: true }) => {
Reply::RebootImminent.write_to(stream)?;
Ok(())
}
@ -470,7 +470,7 @@ mod remote_coremgmt {
});
match reply {
Ok(Packet::CoreMgmtAck) => Ok(()),
Ok(Packet::CoreMgmtReply { succeeded: true }) => Ok(()),
Ok(packet) => {
error!("received unexpected aux packet: {:?}", packet);
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);
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, .. } => {
forward!(router, _routing_table, _destination, *rank, *self_destination, _repeaters, &packet);
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 {
destination: _destination,
@ -518,7 +518,7 @@ fn process_aux_packet(dmamgr: &mut DmaManager, analyzer: &mut Analyzer, kernelmg
let key_slice = &key[..length as usize];
if !key_slice.is_ascii() {
error!("invalid key");
drtioaux::send(0, &drtioaux::Packet::CoreMgmtNack)
drtioaux::send(0, &drtioaux::Packet::CoreMgmtReply { succeeded: false })
} else {
let key = core::str::from_utf8(key_slice).unwrap();
if coremgr.fetch_config_value(key).is_ok() {
@ -532,7 +532,7 @@ fn process_aux_packet(dmamgr: &mut DmaManager, analyzer: &mut Analyzer, kernelmg
},
)
} 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 {
coremgr.write_config()
} else {
drtioaux::send(0, &drtioaux::Packet::CoreMgmtAck)
drtioaux::send(0, &drtioaux::Packet::CoreMgmtReply { succeeded: true })
}
}
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))
.is_ok();
if succeeded {
drtioaux::send(0, &drtioaux::Packet::CoreMgmtAck)
} else {
drtioaux::send(0, &drtioaux::Packet::CoreMgmtNack)
}
drtioaux::send(0, &drtioaux::Packet::CoreMgmtReply { succeeded })
}
drtioaux::Packet::CoreMgmtRebootRequest { destination: _destination } => {
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");
unsafe { spiflash::reload(); }
}

View File

@ -45,7 +45,7 @@ impl Manager {
Err(err) => {
self.clear_data();
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() {
"gateware" | "bootloader" | "firmware" => {
drtioaux::send(0, &drtioaux::Packet::CoreMgmtAck)?;
drtioaux::send(0, &drtioaux::Packet::CoreMgmtReply { succeeded: true })?;
#[cfg(not(soc_platform = "efc"))]
unsafe {
clock::spin_us(10000);
@ -71,11 +71,7 @@ impl Manager {
self.clear_data();
if succeeded {
drtioaux::send(0, &drtioaux::Packet::CoreMgmtAck)
} else {
drtioaux::send(0, &drtioaux::Packet::CoreMgmtNack)
}
drtioaux::send(0, &drtioaux::Packet::CoreMgmtReply { succeeded })
}
}
}