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