LCOV - code coverage report
Current view: top level - app/shared - fd_obj_callbacks.c (source / functions) Hit Total Coverage
Test: cov.lcov Lines: 0 152 0.0 %
Date: 2026-10-22 18:10:43 Functions: 0 35 0.0 %

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

Generated by: LCOV version 1.14