Line data Source code
1 : #include "../../disco/topo/fd_topo.h"
2 : #include "../../util/pod/fd_pod_format.h"
3 : #include "../../disco/metrics/fd_metrics.h"
4 :
5 : #include "../../tango/mcache/fd_mcache.h"
6 : #include "../../tango/dcache/fd_dcache.h"
7 : #include "../../tango/fseq/fd_fseq.h"
8 : #include "../../tango/tempo/fd_tempo.h"
9 : #include "../../waltz/mib/fd_netdev_tbl.h"
10 : #include "../../waltz/neigh/fd_neigh4_map.h"
11 : #include "../../disco/keyguard/fd_keyswitch.h"
12 : #include "../../disco/node_info/fd_node_info.h"
13 : #include "../../disco/sleep/fd_sleep.h"
14 : #include "../../disco/wait_info/fd_wait_info.h"
15 : #include "../../discof/poh/fd_poh.h"
16 : #include "../../discof/replay/fd_execrp.h"
17 :
18 0 : #define VAL(name) (__extension__({ \
19 0 : ulong __x = fd_pod_queryf_ulong( topo->props, ULONG_MAX, "obj.%lu.%s", obj->id, name ); \
20 0 : if( FD_UNLIKELY( __x==ULONG_MAX ) ) FD_LOG_ERR(( "obj.%lu.%s was not set", obj->id, name )); \
21 0 : __x; }))
22 :
23 : static ulong
24 : mcache_footprint( fd_topo_t const * topo,
25 0 : fd_topo_obj_t const * obj ) {
26 0 : return fd_mcache_footprint( VAL("depth"), 0UL );
27 0 : }
28 :
29 : static ulong
30 : mcache_align( fd_topo_t const * topo FD_FN_UNUSED,
31 0 : fd_topo_obj_t const * obj FD_FN_UNUSED ) {
32 0 : return fd_mcache_align();
33 0 : }
34 :
35 : static void
36 : mcache_new( fd_topo_t const * topo,
37 0 : fd_topo_obj_t const * obj ) {
38 0 : FD_TEST( fd_mcache_new( fd_topo_obj_laddr( topo, obj->id ), VAL("depth"), 0UL, 0UL ) );
39 0 : }
40 :
41 : fd_topo_obj_callbacks_t fd_obj_cb_mcache = {
42 : .name = "mcache",
43 : .footprint = mcache_footprint,
44 : .align = mcache_align,
45 : .new = mcache_new,
46 : };
47 :
48 : static ulong
49 : dcache_footprint( fd_topo_t const * topo,
50 0 : fd_topo_obj_t const * obj ) {
51 0 : ulong app_sz = fd_pod_queryf_ulong( topo->props, 0UL, "obj.%lu.app_sz", obj->id );
52 0 : ulong data_sz = fd_pod_queryf_ulong( topo->props, ULONG_MAX, "obj.%lu.data_sz", obj->id );
53 0 : if( data_sz==ULONG_MAX ) {
54 0 : data_sz = fd_dcache_req_data_sz( VAL("mtu"), VAL("depth"), VAL("burst"), 1 );
55 0 : }
56 0 : return fd_dcache_footprint( data_sz, app_sz );
57 0 : }
58 :
59 : static ulong
60 : dcache_align( fd_topo_t const * topo FD_FN_UNUSED,
61 0 : fd_topo_obj_t const * obj FD_FN_UNUSED ) {
62 0 : return fd_dcache_align();
63 0 : }
64 :
65 : static void
66 : dcache_new( fd_topo_t const * topo,
67 0 : fd_topo_obj_t const * obj ) {
68 0 : ulong app_sz = fd_pod_queryf_ulong( topo->props, 0UL, "obj.%lu.app_sz", obj->id );
69 0 : ulong data_sz = fd_pod_queryf_ulong( topo->props, ULONG_MAX, "obj.%lu.data_sz", obj->id );
70 0 : if( data_sz==ULONG_MAX ) {
71 0 : data_sz = fd_dcache_req_data_sz( VAL("mtu"), VAL("depth"), VAL("burst"), 1 );
72 0 : }
73 0 : FD_TEST( fd_dcache_new( fd_topo_obj_laddr( topo, obj->id ), data_sz, app_sz ) );
74 0 : }
75 :
76 : fd_topo_obj_callbacks_t fd_obj_cb_dcache = {
77 : .name = "dcache",
78 : .footprint = dcache_footprint,
79 : .align = dcache_align,
80 : .new = dcache_new,
81 : };
82 :
83 : static ulong
84 : fseq_footprint( fd_topo_t const * topo FD_FN_UNUSED,
85 0 : fd_topo_obj_t const * obj FD_FN_UNUSED ) {
86 0 : return fd_fseq_footprint();
87 0 : }
88 :
89 : static ulong
90 : fseq_align( fd_topo_t const * topo FD_FN_UNUSED,
91 0 : fd_topo_obj_t const * obj FD_FN_UNUSED ) {
92 0 : return fd_fseq_align();
93 0 : }
94 :
95 : static void
96 : fseq_new( fd_topo_t const * topo,
97 0 : fd_topo_obj_t const * obj ) {
98 0 : FD_TEST( fd_fseq_new( fd_topo_obj_laddr( topo, obj->id ), ULONG_MAX ) );
99 0 : }
100 :
101 : fd_topo_obj_callbacks_t fd_obj_cb_fseq = {
102 : .name = "fseq",
103 : .footprint = fseq_footprint,
104 : .align = fseq_align,
105 : .new = fseq_new,
106 : };
107 :
108 : static ulong
109 : metrics_footprint( fd_topo_t const * topo,
110 24 : fd_topo_obj_t const * obj ) {
111 24 : return FD_METRICS_FOOTPRINT( VAL("in_cnt") );
112 24 : }
113 :
114 : static ulong
115 : metrics_align( fd_topo_t const * topo FD_FN_UNUSED,
116 24 : fd_topo_obj_t const * obj FD_FN_UNUSED ) {
117 24 : return FD_METRICS_ALIGN;
118 24 : }
119 :
120 : static void
121 : metrics_new( fd_topo_t const * topo,
122 0 : fd_topo_obj_t const * obj ) {
123 0 : FD_TEST( fd_metrics_new( fd_topo_obj_laddr( topo, obj->id ), VAL("in_cnt") ) );
124 0 : }
125 :
126 : fd_topo_obj_callbacks_t fd_obj_cb_metrics = {
127 : .name = "metrics",
128 : .footprint = metrics_footprint,
129 : .align = metrics_align,
130 : .new = metrics_new,
131 : };
132 :
133 : static ulong
134 : netdev_tbl_footprint( fd_topo_t const * topo,
135 0 : fd_topo_obj_t const * obj ) {
136 0 : return fd_netdev_tbl_footprint( VAL("dev_max"), VAL("bond_max") );
137 0 : }
138 :
139 : static inline ulong
140 : netdev_tbl_align( fd_topo_t const * topo FD_FN_UNUSED,
141 0 : fd_topo_obj_t const * obj FD_FN_UNUSED ) {
142 0 : return fd_netdev_tbl_align();
143 0 : }
144 :
145 : static void
146 : netdev_tbl_new( fd_topo_t const * topo,
147 0 : fd_topo_obj_t const * obj ) {
148 0 : FD_TEST( fd_netdev_tbl_new( fd_topo_obj_laddr( topo, obj->id ), VAL("dev_max"), VAL("bond_max") ) );
149 0 : }
150 :
151 : fd_topo_obj_callbacks_t fd_obj_cb_netdev_tbl = {
152 : .name = "netdev_tbl",
153 : .footprint = netdev_tbl_footprint,
154 : .align = netdev_tbl_align,
155 : .new = netdev_tbl_new,
156 : };
157 :
158 : static ulong
159 : neigh4_hmap_footprint( fd_topo_t const * topo,
160 0 : fd_topo_obj_t const * obj ) {
161 0 : ulong slot_cnt = fd_neigh4_hmap_est_slot_cnt( VAL("ele_max") );
162 0 : FD_TEST( (slot_cnt!=ULONG_MAX) & (slot_cnt!=0) );
163 0 : return fd_neigh4_hmap_footprint( slot_cnt );
164 0 : }
165 :
166 : static ulong
167 : neigh4_hmap_align( fd_topo_t const * topo FD_FN_UNUSED,
168 0 : fd_topo_obj_t const * obj FD_FN_UNUSED ) {
169 0 : return fd_neigh4_hmap_align();
170 0 : }
171 :
172 : static void
173 : neigh4_hmap_new( fd_topo_t const * topo,
174 0 : fd_topo_obj_t const * obj ) {
175 0 : ulong slot_cnt = fd_neigh4_hmap_est_slot_cnt( VAL("ele_max") );
176 0 : FD_TEST( fd_neigh4_hmap_new( fd_topo_obj_laddr( topo, obj->id ), slot_cnt, 1 ) );
177 0 : }
178 :
179 : fd_topo_obj_callbacks_t fd_obj_cb_neigh4_hmap = {
180 : .name = "neigh4_hmap",
181 : .footprint = neigh4_hmap_footprint,
182 : .align = neigh4_hmap_align,
183 : .new = neigh4_hmap_new,
184 : };
185 :
186 : static ulong
187 : keyswitch_footprint( fd_topo_t const * topo FD_FN_UNUSED,
188 0 : fd_topo_obj_t const * obj FD_FN_UNUSED ) {
189 0 : return fd_keyswitch_footprint();
190 0 : }
191 :
192 : static ulong
193 : keyswitch_align( fd_topo_t const * topo FD_FN_UNUSED,
194 0 : fd_topo_obj_t const * obj FD_FN_UNUSED ) {
195 0 : return fd_keyswitch_align();
196 0 : }
197 :
198 : static void
199 : keyswitch_new( fd_topo_t const * topo,
200 0 : fd_topo_obj_t const * obj ) {
201 0 : FD_TEST( fd_keyswitch_new( fd_topo_obj_laddr( topo, obj->id ), FD_KEYSWITCH_STATE_UNLOCKED ) );
202 0 : }
203 :
204 : fd_topo_obj_callbacks_t fd_obj_cb_keyswitch = {
205 : .name = "keyswitch",
206 : .footprint = keyswitch_footprint,
207 : .align = keyswitch_align,
208 : .new = keyswitch_new,
209 : };
210 :
211 : static ulong
212 : node_info_footprint( fd_topo_t const * topo FD_FN_UNUSED,
213 0 : fd_topo_obj_t const * obj FD_FN_UNUSED ) {
214 0 : return sizeof(fd_node_info_box_t);
215 0 : }
216 :
217 : static ulong
218 : node_info_align( fd_topo_t const * topo FD_FN_UNUSED,
219 0 : fd_topo_obj_t const * obj FD_FN_UNUSED ) {
220 0 : return alignof(fd_node_info_box_t);
221 0 : }
222 :
223 : static void
224 : node_info_new( fd_topo_t const * topo,
225 0 : fd_topo_obj_t const * obj ) {
226 0 : FD_TEST( fd_node_info_box_new( fd_topo_obj_laddr( topo, obj->id ) ) );
227 0 : }
228 :
229 : fd_topo_obj_callbacks_t fd_obj_cb_node_info = {
230 : .name = "node_info",
231 : .footprint = node_info_footprint,
232 : .align = node_info_align,
233 : .new = node_info_new,
234 : };
235 :
236 : static ulong
237 : leader_txn_timing_footprint( fd_topo_t const * topo,
238 0 : fd_topo_obj_t const * obj ) {
239 0 : return FD_LEADER_TXN_TIMING_TABLE_CNT*fd_leader_txn_timing_table_footprint( VAL("max_txn_per_slot") );
240 0 : }
241 :
242 : static ulong
243 : leader_txn_timing_align( fd_topo_t const * topo FD_FN_UNUSED,
244 0 : fd_topo_obj_t const * obj FD_FN_UNUSED ) {
245 0 : return alignof(fd_leader_txn_timing_table_t);
246 0 : }
247 :
248 : fd_topo_obj_callbacks_t fd_obj_cb_leader_txn_timing = {
249 : .name = "ldr_tt",
250 : .footprint = leader_txn_timing_footprint,
251 : .align = leader_txn_timing_align,
252 : };
253 :
254 : static ulong
255 : wait_info_footprint( fd_topo_t const * topo FD_FN_UNUSED,
256 0 : fd_topo_obj_t const * obj FD_FN_UNUSED ) {
257 0 : return sizeof(fd_wait_info_box_t);
258 0 : }
259 :
260 : static ulong
261 : wait_info_align( fd_topo_t const * topo FD_FN_UNUSED,
262 0 : fd_topo_obj_t const * obj FD_FN_UNUSED ) {
263 0 : return alignof(fd_wait_info_box_t);
264 0 : }
265 :
266 : static void
267 : wait_info_new( fd_topo_t const * topo,
268 0 : fd_topo_obj_t const * obj ) {
269 0 : FD_TEST( fd_wait_info_box_new( fd_topo_obj_laddr( topo, obj->id ) ) );
270 0 : }
271 :
272 : fd_topo_obj_callbacks_t fd_obj_cb_wait_info = {
273 : .name = "wait_info",
274 : .footprint = wait_info_footprint,
275 : .align = wait_info_align,
276 : .new = wait_info_new,
277 : };
278 :
279 : static ulong
280 : execrp_result_footprint( fd_topo_t const * topo,
281 0 : fd_topo_obj_t const * obj ) {
282 0 : return VAL("execrp_tile_cnt")*sizeof(fd_execrp_result_t);
283 0 : }
284 :
285 : static ulong
286 : execrp_result_align( fd_topo_t const * topo FD_FN_UNUSED,
287 0 : fd_topo_obj_t const * obj FD_FN_UNUSED ) {
288 0 : return alignof(fd_execrp_result_t);
289 0 : }
290 :
291 : fd_topo_obj_callbacks_t fd_obj_cb_execrp_result = {
292 : .name = "execrp_result",
293 : .footprint = execrp_result_footprint,
294 : .align = execrp_result_align,
295 : };
296 :
297 : fd_topo_run_tile_t
298 : fdctl_tile_run( fd_topo_tile_t const * tile );
299 :
300 : static ulong
301 : tile_footprint( fd_topo_t const * topo,
302 24 : fd_topo_obj_t const * obj ) {
303 24 : fd_topo_tile_t const * tile = NULL;
304 24 : for( ulong i=0UL; i<topo->tile_cnt; i++ ) {
305 24 : if( FD_LIKELY( topo->tiles[ i ].tile_obj_id==obj->id ) ) {
306 24 : tile = &topo->tiles[ i ];
307 24 : break;
308 24 : }
309 24 : }
310 24 : FD_TEST( tile );
311 :
312 24 : fd_topo_run_tile_t runner = fdctl_tile_run( tile );
313 24 : if( FD_LIKELY( runner.scratch_footprint ) ) return runner.scratch_footprint( tile );
314 0 : else return 0UL;
315 24 : }
316 :
317 : static ulong
318 : tile_loose( fd_topo_t const * topo,
319 24 : fd_topo_obj_t const * obj ) {
320 24 : fd_topo_tile_t const * tile = NULL;
321 24 : for( ulong i=0UL; i<topo->tile_cnt; i++ ) {
322 24 : if( FD_LIKELY( topo->tiles[ i ].tile_obj_id==obj->id ) ) {
323 24 : tile = &topo->tiles[ i ];
324 24 : break;
325 24 : }
326 24 : }
327 24 : FD_TEST( tile );
328 :
329 24 : fd_topo_run_tile_t runner = fdctl_tile_run( tile );
330 24 : if( FD_UNLIKELY( runner.loose_footprint ) ) return runner.loose_footprint( tile );
331 24 : else return 0UL;
332 24 : }
333 :
334 : static ulong
335 : tile_align( fd_topo_t const * topo,
336 24 : fd_topo_obj_t const * obj ) {
337 24 : fd_topo_tile_t const * tile = NULL;
338 24 : for( ulong i=0UL; i<topo->tile_cnt; i++ ) {
339 24 : if( FD_LIKELY( topo->tiles[ i ].tile_obj_id==obj->id ) ) {
340 24 : tile = &topo->tiles[ i ];
341 24 : break;
342 24 : }
343 24 : }
344 24 : FD_TEST( tile );
345 :
346 24 : fd_topo_run_tile_t runner = fdctl_tile_run( tile );
347 24 : if( FD_LIKELY( runner.scratch_align ) ) return runner.scratch_align();
348 0 : else return 1UL;
349 24 : }
350 :
351 : fd_topo_obj_callbacks_t fd_obj_cb_tile = {
352 : .name = "tile",
353 : .footprint = tile_footprint,
354 : .align = tile_align,
355 : .loose = tile_loose,
356 : .new = NULL,
357 : };
358 :
359 : static ulong
360 : sleep_footprint( fd_topo_t const * topo FD_FN_UNUSED,
361 0 : fd_topo_obj_t const * obj FD_FN_UNUSED ) {
362 0 : return fd_sleep_footprint();
363 0 : }
364 :
365 : static ulong
366 : sleep_align( fd_topo_t const * topo FD_FN_UNUSED,
367 0 : fd_topo_obj_t const * obj FD_FN_UNUSED ) {
368 0 : return fd_sleep_align();
369 0 : }
370 :
371 : static void
372 : sleep_new( fd_topo_t const * topo,
373 0 : fd_topo_obj_t const * obj ) {
374 0 : FD_TEST( fd_sleep_new( fd_topo_obj_laddr( topo, obj->id ), fd_tempo_tick_per_ns( NULL ) ) );
375 0 : }
376 :
377 : fd_topo_obj_callbacks_t fd_obj_cb_sleep = {
378 : .name = "sleep",
379 : .footprint = sleep_footprint,
380 : .align = sleep_align,
381 : .new = sleep_new,
382 : };
383 :
384 : #undef VAL
|