From 6c0ff9a912518bb5126733773edb252144f5d108 Mon Sep 17 00:00:00 2001 From: mwojcik Date: Tue, 9 Jan 2024 10:41:22 +0800 Subject: [PATCH] satman: fix targets without drtio routing --- artiq/firmware/satman/main.rs | 3 ++- artiq/firmware/satman/routing.rs | 16 ++++++++++++---- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/artiq/firmware/satman/main.rs b/artiq/firmware/satman/main.rs index a496afe3e..78c84103a 100644 --- a/artiq/firmware/satman/main.rs +++ b/artiq/firmware/satman/main.rs @@ -789,7 +789,8 @@ pub extern fn main() -> i32 { } kernelmgr.process_kern_requests(&mut router, &routing_table, rank, destination, &mut dma_manager); - + + #[cfg(has_drtio_routing)] if let Some((repno, packet)) = router.get_downstream_packet() { if let Err(e) = repeaters[repno].aux_send(&packet) { warn!("[REP#{}] Error when sending packet to satellite ({:?})", repno, e) diff --git a/artiq/firmware/satman/routing.rs b/artiq/firmware/satman/routing.rs index 6867575ea..169630dbd 100644 --- a/artiq/firmware/satman/routing.rs +++ b/artiq/firmware/satman/routing.rs @@ -1,5 +1,6 @@ use alloc::{vec::Vec, collections::vec_deque::VecDeque}; use board_artiq::{drtioaux, drtio_routing}; +#[cfg(has_drtio_routing)] use board_misoc::csr; use core::cmp::min; use proto_artiq::drtioaux_proto::PayloadStatus; @@ -72,6 +73,7 @@ impl Sliceable { pub struct Router { upstream_queue: VecDeque, local_queue: VecDeque, + #[cfg(has_drtio_routing)] downstream_queue: VecDeque<(usize, drtioaux::Packet)>, upstream_notified: bool, } @@ -81,6 +83,7 @@ impl Router { Router { upstream_queue: VecDeque::new(), local_queue: VecDeque::new(), + #[cfg(has_drtio_routing)] downstream_queue: VecDeque::new(), upstream_notified: false, } @@ -90,14 +93,14 @@ impl Router { // messages are always buffered for both upstream and downstream pub fn route(&mut self, packet: drtioaux::Packet, _routing_table: &drtio_routing::RoutingTable, _rank: u8, - _self_destination: u8 + self_destination: u8 ) { + let destination = packet.routable_destination(); #[cfg(has_drtio_routing)] { - let destination = packet.routable_destination(); if let Some(destination) = destination { let hop = _routing_table.0[destination as usize][_rank as usize] as usize; - if destination == _self_destination { + if destination == self_destination { self.local_queue.push_back(packet); } else if hop > 0 && hop < csr::DRTIOREP.len() { let repno = (hop - 1) as usize; @@ -111,7 +114,11 @@ impl Router { } #[cfg(not(has_drtio_routing))] { - self.upstream_queue.push_back(packet); + if destination == Some(self_destination) { + self.local_queue.push_back(packet); + } else { + self.upstream_queue.push_back(packet); + } } } @@ -166,6 +173,7 @@ impl Router { packet } + #[cfg(has_drtio_routing)] pub fn get_downstream_packet(&mut self) -> Option<(usize, drtioaux::Packet)> { self.downstream_queue.pop_front() }