1
1
use alloc:: { vec:: Vec , collections:: vec_deque:: VecDeque } ;
2
2
use board_artiq:: { drtioaux, drtio_routing} ;
3
+ #[ cfg( has_drtio_routing) ]
3
4
use board_misoc:: csr;
4
5
use core:: cmp:: min;
5
6
use proto_artiq:: drtioaux_proto:: PayloadStatus ;
@@ -72,6 +73,7 @@ impl Sliceable {
72
73
pub struct Router {
73
74
upstream_queue : VecDeque < drtioaux:: Packet > ,
74
75
local_queue : VecDeque < drtioaux:: Packet > ,
76
+ #[ cfg( has_drtio_routing) ]
75
77
downstream_queue : VecDeque < ( usize , drtioaux:: Packet ) > ,
76
78
upstream_notified : bool ,
77
79
}
@@ -81,6 +83,7 @@ impl Router {
81
83
Router {
82
84
upstream_queue : VecDeque :: new ( ) ,
83
85
local_queue : VecDeque :: new ( ) ,
86
+ #[ cfg( has_drtio_routing) ]
84
87
downstream_queue : VecDeque :: new ( ) ,
85
88
upstream_notified : false ,
86
89
}
@@ -90,14 +93,14 @@ impl Router {
90
93
// messages are always buffered for both upstream and downstream
91
94
pub fn route ( & mut self , packet : drtioaux:: Packet ,
92
95
_routing_table : & drtio_routing:: RoutingTable , _rank : u8 ,
93
- _self_destination : u8
96
+ self_destination : u8
94
97
) {
98
+ let destination = packet. routable_destination ( ) ;
95
99
#[ cfg( has_drtio_routing) ]
96
100
{
97
- let destination = packet. routable_destination ( ) ;
98
101
if let Some ( destination) = destination {
99
102
let hop = _routing_table. 0 [ destination as usize ] [ _rank as usize ] as usize ;
100
- if destination == _self_destination {
103
+ if destination == self_destination {
101
104
self . local_queue . push_back ( packet) ;
102
105
} else if hop > 0 && hop < csr:: DRTIOREP . len ( ) {
103
106
let repno = ( hop - 1 ) as usize ;
@@ -111,7 +114,11 @@ impl Router {
111
114
}
112
115
#[ cfg( not( has_drtio_routing) ) ]
113
116
{
114
- self . upstream_queue . push_back ( packet) ;
117
+ if destination == Some ( self_destination) {
118
+ self . local_queue . push_back ( packet) ;
119
+ } else {
120
+ self . upstream_queue . push_back ( packet) ;
121
+ }
115
122
}
116
123
}
117
124
@@ -166,6 +173,7 @@ impl Router {
166
173
packet
167
174
}
168
175
176
+ #[ cfg( has_drtio_routing) ]
169
177
pub fn get_downstream_packet ( & mut self ) -> Option < ( usize , drtioaux:: Packet ) > {
170
178
self . downstream_queue . pop_front ( )
171
179
}
0 commit comments