forked from M-Labs/artiq-zynq
drtio mgmt: differentiate aux error and fail packets
This commit is contained in:
parent
6590084a1f
commit
bfa9327a8e
|
@ -154,7 +154,7 @@ mod remote_coremgmt {
|
||||||
) -> Result<()> {
|
) -> Result<()> {
|
||||||
let mut buffer = Vec::new();
|
let mut buffer = Vec::new();
|
||||||
loop {
|
loop {
|
||||||
match drtio::aux_transact(
|
let reply = drtio::aux_transact(
|
||||||
aux_mutex,
|
aux_mutex,
|
||||||
linkno,
|
linkno,
|
||||||
routing_table,
|
routing_table,
|
||||||
|
@ -163,10 +163,10 @@ mod remote_coremgmt {
|
||||||
clear: false,
|
clear: false,
|
||||||
},
|
},
|
||||||
timer,
|
timer,
|
||||||
)
|
).await;
|
||||||
.await?
|
|
||||||
{
|
match reply {
|
||||||
Packet::CoreMgmtGetLogReply { last, length, data } => {
|
Ok(Packet::CoreMgmtGetLogReply { last, length, data }) => {
|
||||||
buffer.extend(&data[..length as usize]);
|
buffer.extend(&data[..length as usize]);
|
||||||
if last {
|
if last {
|
||||||
write_i8(stream, Reply::LogContent as i8).await?;
|
write_i8(stream, Reply::LogContent as i8).await?;
|
||||||
|
@ -174,10 +174,16 @@ mod remote_coremgmt {
|
||||||
return Ok(());
|
return Ok(());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
_ => {
|
Ok(packet) => {
|
||||||
|
error!("received unexpected aux packet: {:?}", packet);
|
||||||
write_i8(stream, Reply::Error as i8).await?;
|
write_i8(stream, Reply::Error as i8).await?;
|
||||||
return Err(drtio::Error::UnexpectedReply.into());
|
return Err(drtio::Error::UnexpectedReply.into());
|
||||||
}
|
}
|
||||||
|
Err(e) => {
|
||||||
|
error!("aux packet error ({})", e);
|
||||||
|
write_i8(stream, Reply::Error as i8).await?;
|
||||||
|
return Err(e.into());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -197,16 +203,22 @@ mod remote_coremgmt {
|
||||||
&Packet::CoreMgmtClearLogRequest { destination },
|
&Packet::CoreMgmtClearLogRequest { destination },
|
||||||
timer,
|
timer,
|
||||||
)
|
)
|
||||||
.await?;
|
.await;
|
||||||
|
|
||||||
match reply {
|
match reply {
|
||||||
Packet::CoreMgmtAck => {
|
Ok(Packet::CoreMgmtAck) => {
|
||||||
write_i8(stream, Reply::Success as i8).await?;
|
write_i8(stream, Reply::Success as i8).await?;
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
_ => {
|
Ok(packet) => {
|
||||||
|
error!("received unexpected aux packet: {:?}", packet);
|
||||||
write_i8(stream, Reply::Error as i8).await?;
|
write_i8(stream, Reply::Error as i8).await?;
|
||||||
return Err(drtio::Error::UnexpectedReply.into());
|
Err(drtio::Error::UnexpectedReply.into())
|
||||||
|
}
|
||||||
|
Err(e) => {
|
||||||
|
error!("aux packet error ({})", e);
|
||||||
|
write_i8(stream, Reply::Error as i8).await?;
|
||||||
|
Err(e.into())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -232,7 +244,7 @@ mod remote_coremgmt {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
match drtio::aux_transact(
|
let reply = drtio::aux_transact(
|
||||||
aux_mutex,
|
aux_mutex,
|
||||||
linkno,
|
linkno,
|
||||||
routing_table,
|
routing_table,
|
||||||
|
@ -242,13 +254,20 @@ mod remote_coremgmt {
|
||||||
},
|
},
|
||||||
timer,
|
timer,
|
||||||
)
|
)
|
||||||
.await
|
.await;
|
||||||
{
|
|
||||||
|
match reply {
|
||||||
Ok(Packet::CoreMgmtGetLogReply { last: _, length, data }) => {
|
Ok(Packet::CoreMgmtGetLogReply { last: _, length, data }) => {
|
||||||
write_chunk(stream, &data[..length as usize]).await?;
|
write_chunk(stream, &data[..length as usize]).await?;
|
||||||
}
|
}
|
||||||
|
Ok(packet) => {
|
||||||
_ => return Err(drtio::Error::UnexpectedReply.into()),
|
error!("received unexpected aux packet: {:?}", packet);
|
||||||
|
return Err(drtio::Error::UnexpectedReply.into());
|
||||||
|
}
|
||||||
|
Err(e) => {
|
||||||
|
error!("aux packet error ({})", e);
|
||||||
|
return Err(e.into());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -274,16 +293,22 @@ mod remote_coremgmt {
|
||||||
},
|
},
|
||||||
timer,
|
timer,
|
||||||
)
|
)
|
||||||
.await?;
|
.await;
|
||||||
|
|
||||||
match reply {
|
match reply {
|
||||||
Packet::CoreMgmtAck => {
|
Ok(Packet::CoreMgmtAck) => {
|
||||||
write_i8(stream, Reply::Success as i8).await?;
|
write_i8(stream, Reply::Success as i8).await?;
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
_ => {
|
Ok(packet) => {
|
||||||
|
error!("received unexpected aux packet: {:?}", packet);
|
||||||
write_i8(stream, Reply::Error as i8).await?;
|
write_i8(stream, Reply::Error as i8).await?;
|
||||||
return Err(drtio::Error::UnexpectedReply.into());
|
Err(drtio::Error::UnexpectedReply.into())
|
||||||
|
}
|
||||||
|
Err(e) => {
|
||||||
|
error!("aux packet error ({})", e);
|
||||||
|
write_i8(stream, Reply::Error as i8).await?;
|
||||||
|
Err(e.into())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -307,16 +332,22 @@ mod remote_coremgmt {
|
||||||
},
|
},
|
||||||
timer,
|
timer,
|
||||||
)
|
)
|
||||||
.await?;
|
.await;
|
||||||
|
|
||||||
match reply {
|
match reply {
|
||||||
Packet::CoreMgmtAck => {
|
Ok(Packet::CoreMgmtAck) => {
|
||||||
write_i8(stream, Reply::Success as i8).await?;
|
write_i8(stream, Reply::Success as i8).await?;
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
_ => {
|
Ok(packet) => {
|
||||||
|
error!("received unexpected aux packet: {:?}", packet);
|
||||||
write_i8(stream, Reply::Error as i8).await?;
|
write_i8(stream, Reply::Error as i8).await?;
|
||||||
return Err(drtio::Error::UnexpectedReply.into());
|
Err(drtio::Error::UnexpectedReply.into())
|
||||||
|
}
|
||||||
|
Err(e) => {
|
||||||
|
error!("aux packet error ({})", e);
|
||||||
|
write_i8(stream, Reply::Error as i8).await?;
|
||||||
|
Err(e.into())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -346,12 +377,12 @@ mod remote_coremgmt {
|
||||||
},
|
},
|
||||||
timer,
|
timer,
|
||||||
)
|
)
|
||||||
.await?;
|
.await;
|
||||||
|
|
||||||
let mut buffer = Vec::<u8>::new();
|
let mut buffer = Vec::<u8>::new();
|
||||||
loop {
|
loop {
|
||||||
match reply {
|
match reply {
|
||||||
Packet::CoreMgmtConfigReadReply { last, length, value } => {
|
Ok(Packet::CoreMgmtConfigReadReply { last, length, value }) => {
|
||||||
buffer.extend(&value[..length as usize]);
|
buffer.extend(&value[..length as usize]);
|
||||||
|
|
||||||
if last {
|
if last {
|
||||||
|
@ -369,13 +400,18 @@ mod remote_coremgmt {
|
||||||
},
|
},
|
||||||
timer,
|
timer,
|
||||||
)
|
)
|
||||||
.await?;
|
.await;
|
||||||
}
|
}
|
||||||
|
Ok(packet) => {
|
||||||
_ => {
|
error!("received unexpected aux packet: {:?}", packet);
|
||||||
write_i8(stream, Reply::Error as i8).await?;
|
write_i8(stream, Reply::Error as i8).await?;
|
||||||
return Err(drtio::Error::UnexpectedReply.into());
|
return Err(drtio::Error::UnexpectedReply.into());
|
||||||
}
|
}
|
||||||
|
Err(e) => {
|
||||||
|
error!("aux packet error ({})", e);
|
||||||
|
write_i8(stream, Reply::Error as i8).await?;
|
||||||
|
return Err(e.into());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -409,9 +445,9 @@ mod remote_coremgmt {
|
||||||
},
|
},
|
||||||
|reply| match reply {
|
|reply| match reply {
|
||||||
Packet::CoreMgmtAck => Ok(()),
|
Packet::CoreMgmtAck => Ok(()),
|
||||||
_ => {
|
packet => {
|
||||||
error!("received unknown packet");
|
error!("received unexpected aux packet: {:?}", packet);
|
||||||
Err(drtio::Error::UnexpectedReply.into())
|
Err(drtio::Error::UnexpectedReply)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
@ -421,9 +457,10 @@ mod remote_coremgmt {
|
||||||
write_i8(stream, Reply::Success as i8).await?;
|
write_i8(stream, Reply::Success as i8).await?;
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
error => {
|
Err(e) => {
|
||||||
|
error!("aux packet error ({})", e);
|
||||||
write_i8(stream, Reply::Error as i8).await?;
|
write_i8(stream, Reply::Error as i8).await?;
|
||||||
error
|
Err(e.into())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -453,17 +490,23 @@ mod remote_coremgmt {
|
||||||
},
|
},
|
||||||
timer,
|
timer,
|
||||||
)
|
)
|
||||||
.await?;
|
.await;
|
||||||
|
|
||||||
match reply {
|
match reply {
|
||||||
Packet::CoreMgmtAck => {
|
Ok(Packet::CoreMgmtAck) => {
|
||||||
write_i8(stream, Reply::Success as i8).await?;
|
write_i8(stream, Reply::Success as i8).await?;
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
_ => {
|
Ok(packet) => {
|
||||||
|
error!("received unexpected aux packet: {:?}", packet);
|
||||||
write_i8(stream, Reply::Error as i8).await?;
|
write_i8(stream, Reply::Error as i8).await?;
|
||||||
Err(drtio::Error::UnexpectedReply.into())
|
Err(drtio::Error::UnexpectedReply.into())
|
||||||
}
|
}
|
||||||
|
Err(e) => {
|
||||||
|
error!("aux packet error ({})", e);
|
||||||
|
write_i8(stream, Reply::Error as i8).await?;
|
||||||
|
Err(e.into())
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -484,17 +527,23 @@ mod remote_coremgmt {
|
||||||
},
|
},
|
||||||
timer,
|
timer,
|
||||||
)
|
)
|
||||||
.await?;
|
.await;
|
||||||
|
|
||||||
match reply {
|
match reply {
|
||||||
Packet::CoreMgmtAck => {
|
Ok(Packet::CoreMgmtAck) => {
|
||||||
write_i8(stream, Reply::Success as i8).await?;
|
write_i8(stream, Reply::Success as i8).await?;
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
_ => {
|
Ok(packet) => {
|
||||||
|
error!("received unexpected aux packet: {:?}", packet);
|
||||||
write_i8(stream, Reply::Error as i8).await?;
|
write_i8(stream, Reply::Error as i8).await?;
|
||||||
Err(drtio::Error::UnexpectedReply.into())
|
Err(drtio::Error::UnexpectedReply.into())
|
||||||
}
|
}
|
||||||
|
Err(e) => {
|
||||||
|
error!("aux packet error ({})", e);
|
||||||
|
write_i8(stream, Reply::Error as i8).await?;
|
||||||
|
Err(e.into())
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -516,18 +565,23 @@ mod remote_coremgmt {
|
||||||
},
|
},
|
||||||
timer,
|
timer,
|
||||||
)
|
)
|
||||||
.await?;
|
.await;
|
||||||
|
|
||||||
match reply {
|
match reply {
|
||||||
Packet::CoreMgmtAck => {
|
Ok(Packet::CoreMgmtAck) => {
|
||||||
write_i8(stream, Reply::RebootImminent as i8).await?;
|
write_i8(stream, Reply::RebootImminent as i8).await?;
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
_ => {
|
Ok(packet) => {
|
||||||
error!("received unknown packet");
|
error!("received unexpected aux packet: {:?}", packet);
|
||||||
write_i8(stream, Reply::Error as i8).await?;
|
write_i8(stream, Reply::Error as i8).await?;
|
||||||
Err(drtio::Error::UnexpectedReply.into())
|
Err(drtio::Error::UnexpectedReply.into())
|
||||||
}
|
}
|
||||||
|
Err(e) => {
|
||||||
|
error!("aux packet error ({})", e);
|
||||||
|
write_i8(stream, Reply::Error as i8).await?;
|
||||||
|
Err(e.into())
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -548,18 +602,21 @@ mod remote_coremgmt {
|
||||||
},
|
},
|
||||||
timer,
|
timer,
|
||||||
)
|
)
|
||||||
.await?;
|
.await;
|
||||||
|
|
||||||
match reply {
|
match reply {
|
||||||
Packet::CoreMgmtAck => {
|
Ok(Packet::CoreMgmtAck) => {
|
||||||
write_i8(stream, Reply::Success as i8).await?;
|
write_i8(stream, Reply::Success as i8).await?;
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
_ => {
|
Ok(packet) => {
|
||||||
error!("received unknown packet");
|
error!("received unexpected aux packet: {:?}", packet);
|
||||||
write_i8(stream, Reply::Error as i8).await?;
|
|
||||||
Err(drtio::Error::UnexpectedReply.into())
|
Err(drtio::Error::UnexpectedReply.into())
|
||||||
}
|
}
|
||||||
|
Err(e) => {
|
||||||
|
error!("aux packet error ({})", e);
|
||||||
|
Err(e.into())
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue