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