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/cnc/fd_cnc.h"
6 : #include "../../tango/mcache/fd_mcache.h"
7 : #include "../../tango/dcache/fd_dcache.h"
8 : #include "../../tango/fseq/fd_fseq.h"
9 : #include "../../waltz/mib/fd_dbl_buf.h"
10 : #include "../../waltz/neigh/fd_neigh4_map.h"
11 : #include "../../waltz/ip/fd_fib4.h"
12 : #include "../../disco/keyguard/fd_keyswitch.h"
13 :
14 0 : #define VAL(name) (__extension__({ \
15 0 : ulong __x = fd_pod_queryf_ulong( topo->props, ULONG_MAX, "obj.%lu.%s", obj->id, name ); \
16 0 : if( FD_UNLIKELY( __x==ULONG_MAX ) ) FD_LOG_ERR(( "obj.%lu.%s was not set", obj->id, name )); \
17 0 : __x; }))
18 :
19 : static ulong
20 : mcache_footprint( fd_topo_t const * topo,
21 0 : fd_topo_obj_t const * obj ) {
22 0 : return fd_mcache_footprint( VAL("depth"), 0UL );
23 0 : }
24 :
25 : static ulong
26 : mcache_align( fd_topo_t const * topo FD_FN_UNUSED,
27 0 : fd_topo_obj_t const * obj FD_FN_UNUSED ) {
28 0 : return fd_mcache_align();
29 0 : }
30 :
31 : static void
32 : mcache_new( fd_topo_t const * topo,
33 0 : fd_topo_obj_t const * obj ) {
34 0 : FD_TEST( fd_mcache_new( fd_topo_obj_laddr( topo, obj->id ), VAL("depth"), 0UL, 0UL ) );
35 0 : }
36 :
37 : fd_topo_obj_callbacks_t fd_obj_cb_mcache = {
38 : .name = "mcache",
39 : .footprint = mcache_footprint,
40 : .align = mcache_align,
41 : .new = mcache_new,
42 : };
43 :
44 : static ulong
45 : dcache_footprint( fd_topo_t const * topo,
46 0 : fd_topo_obj_t const * obj ) {
47 0 : ulong app_sz = fd_pod_queryf_ulong( topo->props, 0UL, "obj.%lu.app_sz", obj->id );
48 0 : ulong data_sz = fd_pod_queryf_ulong( topo->props, ULONG_MAX, "obj.%lu.data_sz", obj->id );
49 0 : if( data_sz==ULONG_MAX ) {
50 0 : data_sz = fd_dcache_req_data_sz( VAL("mtu"), VAL("depth"), VAL("burst"), 1 );
51 0 : }
52 0 : return fd_dcache_footprint( data_sz, app_sz );
53 0 : }
54 :
55 : static ulong
56 : dcache_align( fd_topo_t const * topo FD_FN_UNUSED,
57 0 : fd_topo_obj_t const * obj FD_FN_UNUSED ) {
58 0 : return fd_dcache_align();
59 0 : }
60 :
61 : static void
62 : dcache_new( fd_topo_t const * topo,
63 0 : fd_topo_obj_t const * obj ) {
64 0 : ulong app_sz = fd_pod_queryf_ulong( topo->props, 0UL, "obj.%lu.app_sz", obj->id );
65 0 : ulong data_sz = fd_pod_queryf_ulong( topo->props, ULONG_MAX, "obj.%lu.data_sz", obj->id );
66 0 : if( data_sz==ULONG_MAX ) {
67 0 : data_sz = fd_dcache_req_data_sz( VAL("mtu"), VAL("depth"), VAL("burst"), 1 );
68 0 : }
69 0 : FD_TEST( fd_dcache_new( fd_topo_obj_laddr( topo, obj->id ), data_sz, app_sz ) );
70 0 : }
71 :
72 : fd_topo_obj_callbacks_t fd_obj_cb_dcache = {
73 : .name = "dcache",
74 : .footprint = dcache_footprint,
75 : .align = dcache_align,
76 : .new = dcache_new,
77 : };
78 :
79 : static ulong
80 : fseq_footprint( fd_topo_t const * topo FD_FN_UNUSED,
81 0 : fd_topo_obj_t const * obj FD_FN_UNUSED ) {
82 0 : return fd_fseq_footprint();
83 0 : }
84 :
85 : static ulong
86 : fseq_align( fd_topo_t const * topo FD_FN_UNUSED,
87 0 : fd_topo_obj_t const * obj FD_FN_UNUSED ) {
88 0 : return fd_fseq_align();
89 0 : }
90 :
91 : static void
92 : fseq_new( fd_topo_t const * topo,
93 0 : fd_topo_obj_t const * obj ) {
94 0 : FD_TEST( fd_fseq_new( fd_topo_obj_laddr( topo, obj->id ), ULONG_MAX ) );
95 0 : }
96 :
97 : fd_topo_obj_callbacks_t fd_obj_cb_fseq = {
98 : .name = "fseq",
99 : .footprint = fseq_footprint,
100 : .align = fseq_align,
101 : .new = fseq_new,
102 : };
103 :
104 : static ulong
105 : metrics_footprint( fd_topo_t const * topo,
106 0 : fd_topo_obj_t const * obj ) {
107 0 : return FD_METRICS_FOOTPRINT( VAL("in_cnt"), VAL("cons_cnt") );
108 0 : }
109 :
110 : static ulong
111 : metrics_align( fd_topo_t const * topo FD_FN_UNUSED,
112 0 : fd_topo_obj_t const * obj FD_FN_UNUSED ) {
113 0 : return FD_METRICS_ALIGN;
114 0 : }
115 :
116 : static void
117 : metrics_new( fd_topo_t const * topo,
118 0 : fd_topo_obj_t const * obj ) {
119 0 : FD_TEST( fd_metrics_new( fd_topo_obj_laddr( topo, obj->id ), VAL("in_cnt"), VAL("cons_cnt") ) );
120 0 : }
121 :
122 : fd_topo_obj_callbacks_t fd_obj_cb_metrics = {
123 : .name = "metrics",
124 : .footprint = metrics_footprint,
125 : .align = metrics_align,
126 : .new = metrics_new,
127 : };
128 :
129 : static ulong
130 : opaque_footprint( fd_topo_t const * topo FD_FN_UNUSED,
131 0 : fd_topo_obj_t const * obj FD_FN_UNUSED ) {
132 0 : return VAL("footprint");
133 0 : }
134 :
135 : static ulong
136 : opaque_align( fd_topo_t const * topo FD_FN_UNUSED,
137 0 : fd_topo_obj_t const * obj FD_FN_UNUSED ) {
138 0 : return VAL("align");
139 0 : }
140 :
141 : static void
142 : opaque_new( fd_topo_t const * topo,
143 0 : fd_topo_obj_t const * obj ) {
144 0 : fd_memset( fd_topo_obj_laddr( topo, obj->id ), 0, VAL("footprint") );
145 0 : }
146 :
147 : fd_topo_obj_callbacks_t fd_obj_cb_opaque = {
148 : .name = "opaque",
149 : .footprint = opaque_footprint,
150 : .align = opaque_align,
151 : .new = opaque_new,
152 : };
153 :
154 : static ulong
155 : dbl_buf_footprint( fd_topo_t const * topo,
156 0 : fd_topo_obj_t const * obj ) {
157 0 : return fd_dbl_buf_footprint( VAL("mtu") );
158 0 : }
159 :
160 : static ulong
161 : dbl_buf_align( fd_topo_t const * topo FD_FN_UNUSED,
162 0 : fd_topo_obj_t const * obj FD_FN_UNUSED ) {
163 0 : return fd_dbl_buf_align();
164 0 : }
165 :
166 : static void
167 : dbl_buf_new( fd_topo_t const * topo,
168 0 : fd_topo_obj_t const * obj ) {
169 0 : FD_TEST( fd_dbl_buf_new( fd_topo_obj_laddr( topo, obj->id ), VAL("mtu"), 1UL ) );
170 0 : }
171 :
172 : fd_topo_obj_callbacks_t fd_obj_cb_dbl_buf = {
173 : .name = "dbl_buf",
174 : .footprint = dbl_buf_footprint,
175 : .align = dbl_buf_align,
176 : .new = dbl_buf_new,
177 : };
178 :
179 : static ulong
180 : neigh4_hmap_footprint( fd_topo_t const * topo,
181 0 : fd_topo_obj_t const * obj ) {
182 0 : return fd_neigh4_hmap_footprint( VAL("ele_max"), VAL("lock_cnt"), VAL("probe_max") );
183 0 : }
184 :
185 : static ulong
186 : neigh4_hmap_align( fd_topo_t const * topo FD_FN_UNUSED,
187 0 : fd_topo_obj_t const * obj FD_FN_UNUSED ) {
188 0 : return fd_neigh4_hmap_align();
189 0 : }
190 :
191 : static void
192 : neigh4_hmap_new( fd_topo_t const * topo,
193 0 : fd_topo_obj_t const * obj ) {
194 0 : FD_TEST( fd_neigh4_hmap_new( fd_topo_obj_laddr( topo, obj->id ), VAL("ele_max"), VAL("lock_cnt"), VAL("probe_max"), VAL("seed") ) );
195 0 : }
196 :
197 : fd_topo_obj_callbacks_t fd_obj_cb_neigh4_hmap = {
198 : .name = "neigh4_hmap",
199 : .footprint = neigh4_hmap_footprint,
200 : .align = neigh4_hmap_align,
201 : .new = neigh4_hmap_new,
202 : };
203 :
204 : static ulong
205 : fib4_footprint( fd_topo_t const * topo,
206 0 : fd_topo_obj_t const * obj ) {
207 0 : return fd_fib4_footprint( VAL("route_max"), VAL("route_peer_max") );
208 0 : }
209 :
210 : static ulong
211 : fib4_align( fd_topo_t const * topo FD_FN_UNUSED,
212 0 : fd_topo_obj_t const * obj FD_FN_UNUSED ) {
213 0 : return fd_fib4_align();
214 0 : }
215 :
216 : static void
217 : fib4_new( fd_topo_t const * topo,
218 0 : fd_topo_obj_t const * obj ) {
219 0 : FD_TEST( fd_fib4_new( fd_topo_obj_laddr( topo, obj->id ), VAL("route_max"), VAL("route_peer_max"), VAL("route_peer_seed") ) );
220 0 : }
221 :
222 : fd_topo_obj_callbacks_t fd_obj_cb_fib4 = {
223 : .name = "fib4",
224 : .footprint = fib4_footprint,
225 : .align = fib4_align,
226 : .new = fib4_new,
227 : };
228 :
229 : static ulong
230 : keyswitch_footprint( fd_topo_t const * topo FD_FN_UNUSED,
231 0 : fd_topo_obj_t const * obj FD_FN_UNUSED ) {
232 0 : return fd_keyswitch_footprint();
233 0 : }
234 :
235 : static ulong
236 : keyswitch_align( fd_topo_t const * topo FD_FN_UNUSED,
237 0 : fd_topo_obj_t const * obj FD_FN_UNUSED ) {
238 0 : return fd_keyswitch_align();
239 0 : }
240 :
241 : static void
242 : keyswitch_new( fd_topo_t const * topo,
243 0 : fd_topo_obj_t const * obj ) {
244 0 : FD_TEST( fd_keyswitch_new( fd_topo_obj_laddr( topo, obj->id ), FD_KEYSWITCH_STATE_UNLOCKED ) );
245 0 : }
246 :
247 : fd_topo_obj_callbacks_t fd_obj_cb_keyswitch = {
248 : .name = "keyswitch",
249 : .footprint = keyswitch_footprint,
250 : .align = keyswitch_align,
251 : .new = keyswitch_new,
252 : };
253 :
254 : fd_topo_run_tile_t
255 : fdctl_tile_run( fd_topo_tile_t const * tile );
256 :
257 : static ulong
258 : tile_footprint( fd_topo_t const * topo,
259 0 : fd_topo_obj_t const * obj ) {
260 0 : fd_topo_tile_t const * tile = NULL;
261 0 : for( ulong i=0UL; i<topo->tile_cnt; i++ ) {
262 0 : if( FD_LIKELY( topo->tiles[ i ].tile_obj_id==obj->id ) ) {
263 0 : tile = &topo->tiles[ i ];
264 0 : break;
265 0 : }
266 0 : }
267 0 : FD_TEST( tile );
268 :
269 0 : fd_topo_run_tile_t runner = fdctl_tile_run( tile );
270 0 : if( FD_LIKELY( runner.scratch_footprint ) ) return runner.scratch_footprint( tile );
271 0 : else return 0UL;
272 0 : }
273 :
274 : static ulong
275 : tile_loose( fd_topo_t const * topo,
276 0 : fd_topo_obj_t const * obj ) {
277 0 : fd_topo_tile_t const * tile = NULL;
278 0 : for( ulong i=0UL; i<topo->tile_cnt; i++ ) {
279 0 : if( FD_LIKELY( topo->tiles[ i ].tile_obj_id==obj->id ) ) {
280 0 : tile = &topo->tiles[ i ];
281 0 : break;
282 0 : }
283 0 : }
284 0 : FD_TEST( tile );
285 :
286 0 : fd_topo_run_tile_t runner = fdctl_tile_run( tile );
287 0 : if( FD_UNLIKELY( runner.loose_footprint ) ) return runner.loose_footprint( tile );
288 0 : else return 0UL;
289 0 : }
290 :
291 : static ulong
292 : tile_align( fd_topo_t const * topo,
293 0 : fd_topo_obj_t const * obj ) {
294 0 : fd_topo_tile_t const * tile = NULL;
295 0 : for( ulong i=0UL; i<topo->tile_cnt; i++ ) {
296 0 : if( FD_LIKELY( topo->tiles[ i ].tile_obj_id==obj->id ) ) {
297 0 : tile = &topo->tiles[ i ];
298 0 : break;
299 0 : }
300 0 : }
301 0 : FD_TEST( tile );
302 :
303 0 : fd_topo_run_tile_t runner = fdctl_tile_run( tile );
304 0 : if( FD_LIKELY( runner.scratch_align ) ) return runner.scratch_align();
305 0 : else return 1UL;
306 0 : }
307 :
308 : fd_topo_obj_callbacks_t fd_obj_cb_tile = {
309 : .name = "tile",
310 : .footprint = tile_footprint,
311 : .align = tile_align,
312 : .loose = tile_loose,
313 : .new = NULL,
314 : };
315 :
316 : #undef VAL
|