rtio_mgt: remove support for async messages

This commit is contained in:
mwojcik 2023-09-06 17:12:22 +08:00
parent 1890e443d1
commit 717848e022
1 changed files with 58 additions and 56 deletions

View File

@ -45,7 +45,7 @@ pub mod drtio {
unsafe { (csr::DRTIO[linkno].rx_up_read)() == 1 } unsafe { (csr::DRTIO[linkno].rx_up_read)() == 1 }
} }
async fn process_async_packets(linkno: u8, packet: Packet) -> Option<Packet> { async fn process_async_packets(aux_mutex: &Mutex<bool>, linkno: u8, packet: Packet) -> Option<Packet> {
// returns None if an async packet has been consumed // returns None if an async packet has been consumed
match packet { match packet {
Packet::DmaPlaybackStatus { Packet::DmaPlaybackStatus {
@ -71,6 +71,7 @@ pub mod drtio {
} => { } => {
subkernel::message_handle_incoming(id, last, length as usize, &data).await; subkernel::message_handle_incoming(id, last, length as usize, &data).await;
// acknowledge receiving part of the message // acknowledge receiving part of the message
let _lock = aux_mutex.async_lock().await;
drtioaux_async::send(linkno, &Packet::SubkernelMessageAck { destination: from }) drtioaux_async::send(linkno, &Packet::SubkernelMessageAck { destination: from })
.await .await
.unwrap(); .unwrap();
@ -102,14 +103,7 @@ pub mod drtio {
} }
let _lock = aux_mutex.async_lock().await; let _lock = aux_mutex.async_lock().await;
drtioaux_async::send(linkno, request).await.unwrap(); drtioaux_async::send(linkno, request).await.unwrap();
loop { Ok(recv_aux_timeout(linkno, 200, timer).await?)
let reply = recv_aux_timeout(linkno, 200, timer).await?;
let packet = process_async_packets(linkno, reply).await;
match packet {
Some(packet) => return Ok(packet),
None => (),
}
}
} }
async fn drain_buffer(linkno: u8, draining_time: Milliseconds, timer: GlobalTimer) { async fn drain_buffer(linkno: u8, draining_time: Milliseconds, timer: GlobalTimer) {
@ -219,7 +213,7 @@ pub mod drtio {
let _lock = aux_mutex.async_lock().await; let _lock = aux_mutex.async_lock().await;
match drtioaux_async::recv(linkno).await { match drtioaux_async::recv(linkno).await {
Ok(Some(packet)) => { Ok(Some(packet)) => {
if let Some(packet) = process_async_packets(linkno, packet).await { if let Some(packet) = process_async_packets(aux_mutex, linkno, packet).await {
warn!("[LINK#{}] unsolicited aux packet: {:?}", linkno, packet); warn!("[LINK#{}] unsolicited aux packet: {:?}", linkno, packet);
} }
} }
@ -291,53 +285,61 @@ pub mod drtio {
let linkno = hop - 1; let linkno = hop - 1;
if destination_up(up_destinations, destination).await { if destination_up(up_destinations, destination).await {
if up_links[linkno as usize] { if up_links[linkno as usize] {
let reply = aux_transact( loop {
aux_mutex, let reply = aux_transact(
linkno, aux_mutex,
&Packet::DestinationStatusRequest { linkno,
destination: destination, &Packet::DestinationStatusRequest {
}, destination: destination,
timer, },
) timer,
.await; )
match reply { .await;
Ok(Packet::DestinationDownReply) => { match reply {
destination_set_up(routing_table, up_destinations, destination, false).await; Ok(Packet::DestinationDownReply) => {
remote_dma::destination_changed(aux_mutex, routing_table, timer, destination, false) destination_set_up(routing_table, up_destinations, destination, false).await;
.await; remote_dma::destination_changed(aux_mutex, routing_table, timer, destination, false)
subkernel::destination_changed(aux_mutex, routing_table, timer, destination, false) .await;
.await; subkernel::destination_changed(aux_mutex, routing_table, timer, destination, false)
.await;
}
Ok(Packet::DestinationOkReply) => (),
Ok(Packet::DestinationSequenceErrorReply { channel }) => {
error!(
"[DEST#{}] RTIO sequence error involving channel 0x{:04x}:{}",
destination,
channel,
resolve_channel_name(channel as u32)
);
unsafe { SEEN_ASYNC_ERRORS |= ASYNC_ERROR_SEQUENCE_ERROR };
}
Ok(Packet::DestinationCollisionReply { channel }) => {
error!(
"[DEST#{}] RTIO collision involving channel 0x{:04x}:{}",
destination,
channel,
resolve_channel_name(channel as u32)
);
unsafe { SEEN_ASYNC_ERRORS |= ASYNC_ERROR_COLLISION };
}
Ok(Packet::DestinationBusyReply { channel }) => {
error!(
"[DEST#{}] RTIO busy error involving channel 0x{:04x}:{}",
destination,
channel,
resolve_channel_name(channel as u32)
);
unsafe { SEEN_ASYNC_ERRORS |= ASYNC_ERROR_BUSY };
}
Ok(packet) => {
match process_async_packets(aux_mutex, linkno, packet).await {
Some(packet) => error!("[DEST#{}] received unexpected aux packet: {:?}", destination, packet),
None => continue
}
},
Err(e) => error!("[DEST#{}] communication failed ({})", destination, e),
} }
Ok(Packet::DestinationOkReply) => (), break;
Ok(Packet::DestinationSequenceErrorReply { channel }) => {
error!(
"[DEST#{}] RTIO sequence error involving channel 0x{:04x}:{}",
destination,
channel,
resolve_channel_name(channel as u32)
);
unsafe { SEEN_ASYNC_ERRORS |= ASYNC_ERROR_SEQUENCE_ERROR };
}
Ok(Packet::DestinationCollisionReply { channel }) => {
error!(
"[DEST#{}] RTIO collision involving channel 0x{:04x}:{}",
destination,
channel,
resolve_channel_name(channel as u32)
);
unsafe { SEEN_ASYNC_ERRORS |= ASYNC_ERROR_COLLISION };
}
Ok(Packet::DestinationBusyReply { channel }) => {
error!(
"[DEST#{}] RTIO busy error involving channel 0x{:04x}:{}",
destination,
channel,
resolve_channel_name(channel as u32)
);
unsafe { SEEN_ASYNC_ERRORS |= ASYNC_ERROR_BUSY };
}
Ok(packet) => error!("[DEST#{}] received unexpected aux packet: {:?}", destination, packet),
Err(e) => error!("[DEST#{}] communication failed ({})", destination, e),
} }
} else { } else {
destination_set_up(routing_table, up_destinations, destination, false).await; destination_set_up(routing_table, up_destinations, destination, false).await;