LCOV - code coverage report
Current view: top level - app/shared - fd_obj_callbacks.c (source / functions) Hit Total Coverage
Test: cov.lcov Lines: 0 128 0.0 %
Date: 2025-12-16 05:08:26 Functions: 0 54 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/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             : dbl_buf_footprint( fd_topo_t const *     topo,
     131           0 :                    fd_topo_obj_t const * obj ) {
     132           0 :   return fd_dbl_buf_footprint( VAL("mtu") );
     133           0 : }
     134             : 
     135             : static ulong
     136             : dbl_buf_align( fd_topo_t const *     topo FD_FN_UNUSED,
     137           0 :                fd_topo_obj_t const * obj  FD_FN_UNUSED ) {
     138           0 :   return fd_dbl_buf_align();
     139           0 : }
     140             : 
     141             : static void
     142             : dbl_buf_new( fd_topo_t const *     topo,
     143           0 :               fd_topo_obj_t const * obj ) {
     144           0 :   FD_TEST( fd_dbl_buf_new( fd_topo_obj_laddr( topo, obj->id ), VAL("mtu"), 1UL ) );
     145           0 : }
     146             : 
     147             : fd_topo_obj_callbacks_t fd_obj_cb_dbl_buf = {
     148             :   .name      = "dbl_buf",
     149             :   .footprint = dbl_buf_footprint,
     150             :   .align     = dbl_buf_align,
     151             :   .new       = dbl_buf_new,
     152             : };
     153             : 
     154             : static ulong
     155             : neigh4_hmap_footprint( fd_topo_t const * topo,
     156           0 :                    fd_topo_obj_t const * obj ) {
     157           0 :   ulong slot_cnt = fd_neigh4_hmap_est_slot_cnt( VAL("ele_max") );
     158           0 :   FD_TEST( (slot_cnt!=ULONG_MAX) & (slot_cnt!=0) );
     159           0 :   return fd_neigh4_hmap_footprint( slot_cnt );
     160           0 : }
     161             : 
     162             : static ulong
     163             : neigh4_hmap_align( fd_topo_t const *     topo FD_FN_UNUSED,
     164           0 :                    fd_topo_obj_t const * obj  FD_FN_UNUSED ) {
     165           0 :   return fd_neigh4_hmap_align();
     166           0 : }
     167             : 
     168             : static void
     169             : neigh4_hmap_new( fd_topo_t const *     topo,
     170           0 :                  fd_topo_obj_t const * obj ) {
     171           0 :   ulong slot_cnt = fd_neigh4_hmap_est_slot_cnt( VAL("ele_max") );
     172           0 :   FD_TEST( fd_neigh4_hmap_new( fd_topo_obj_laddr( topo, obj->id ), slot_cnt, 1 ) );
     173           0 : }
     174             : 
     175             : fd_topo_obj_callbacks_t fd_obj_cb_neigh4_hmap = {
     176             :   .name      = "neigh4_hmap",
     177             :   .footprint = neigh4_hmap_footprint,
     178             :   .align     = neigh4_hmap_align,
     179             :   .new       = neigh4_hmap_new,
     180             : };
     181             : 
     182             : static ulong
     183             : fib4_footprint( fd_topo_t const *     topo,
     184           0 :                 fd_topo_obj_t const * obj ) {
     185           0 :   return fd_fib4_footprint( VAL("route_max"), VAL("route_peer_max") );
     186           0 : }
     187             : 
     188             : static ulong
     189             : fib4_align( fd_topo_t const *     topo FD_FN_UNUSED,
     190           0 :             fd_topo_obj_t const * obj  FD_FN_UNUSED ) {
     191           0 :   return fd_fib4_align();
     192           0 : }
     193             : 
     194             : static void
     195             : fib4_new( fd_topo_t const *     topo,
     196           0 :            fd_topo_obj_t const * obj ) {
     197           0 :   FD_TEST( fd_fib4_new( fd_topo_obj_laddr( topo, obj->id ), VAL("route_max"), VAL("route_peer_max"), VAL("route_peer_seed") ) );
     198           0 : }
     199             : 
     200             : fd_topo_obj_callbacks_t fd_obj_cb_fib4 = {
     201             :   .name      = "fib4",
     202             :   .footprint = fib4_footprint,
     203             :   .align     = fib4_align,
     204             :   .new       = fib4_new,
     205             : };
     206             : 
     207             : static ulong
     208             : keyswitch_footprint( fd_topo_t const *     topo FD_FN_UNUSED,
     209           0 :                      fd_topo_obj_t const * obj  FD_FN_UNUSED ) {
     210           0 :   return fd_keyswitch_footprint();
     211           0 : }
     212             : 
     213             : static ulong
     214             : keyswitch_align( fd_topo_t const *     topo FD_FN_UNUSED,
     215           0 :                  fd_topo_obj_t const * obj  FD_FN_UNUSED ) {
     216           0 :   return fd_keyswitch_align();
     217           0 : }
     218             : 
     219             : static void
     220             : keyswitch_new( fd_topo_t const *     topo,
     221           0 :                  fd_topo_obj_t const * obj ) {
     222           0 :   FD_TEST( fd_keyswitch_new( fd_topo_obj_laddr( topo, obj->id ), FD_KEYSWITCH_STATE_UNLOCKED ) );
     223           0 : }
     224             : 
     225             : fd_topo_obj_callbacks_t fd_obj_cb_keyswitch = {
     226             :   .name      = "keyswitch",
     227             :   .footprint = keyswitch_footprint,
     228             :   .align     = keyswitch_align,
     229             :   .new       = keyswitch_new,
     230             : };
     231             : 
     232             : fd_topo_run_tile_t
     233             : fdctl_tile_run( fd_topo_tile_t const * tile );
     234             : 
     235             : static ulong
     236             : tile_footprint( fd_topo_t const *     topo,
     237           0 :                 fd_topo_obj_t const * obj ) {
     238           0 :   fd_topo_tile_t const * tile = NULL;
     239           0 :   for( ulong i=0UL; i<topo->tile_cnt; i++ ) {
     240           0 :     if( FD_LIKELY( topo->tiles[ i ].tile_obj_id==obj->id ) ) {
     241           0 :       tile = &topo->tiles[ i ];
     242           0 :       break;
     243           0 :     }
     244           0 :   }
     245           0 :   FD_TEST( tile );
     246             : 
     247           0 :   fd_topo_run_tile_t runner = fdctl_tile_run( tile );
     248           0 :   if( FD_LIKELY( runner.scratch_footprint ) ) return runner.scratch_footprint( tile );
     249           0 :   else                                        return 0UL;
     250           0 : }
     251             : 
     252             : static ulong
     253             : tile_loose( fd_topo_t const *     topo,
     254           0 :             fd_topo_obj_t const * obj ) {
     255           0 :   fd_topo_tile_t const * tile = NULL;
     256           0 :   for( ulong i=0UL; i<topo->tile_cnt; i++ ) {
     257           0 :     if( FD_LIKELY( topo->tiles[ i ].tile_obj_id==obj->id ) ) {
     258           0 :       tile = &topo->tiles[ i ];
     259           0 :       break;
     260           0 :     }
     261           0 :   }
     262           0 :   FD_TEST( tile );
     263             : 
     264           0 :   fd_topo_run_tile_t runner = fdctl_tile_run( tile );
     265           0 :   if( FD_UNLIKELY( runner.loose_footprint ) ) return runner.loose_footprint( tile );
     266           0 :   else                                        return 0UL;
     267           0 : }
     268             : 
     269             : static ulong
     270             : tile_align( fd_topo_t const *     topo,
     271           0 :             fd_topo_obj_t const * obj ) {
     272           0 :   fd_topo_tile_t const * tile = NULL;
     273           0 :   for( ulong i=0UL; i<topo->tile_cnt; i++ ) {
     274           0 :     if( FD_LIKELY( topo->tiles[ i ].tile_obj_id==obj->id ) ) {
     275           0 :       tile = &topo->tiles[ i ];
     276           0 :       break;
     277           0 :     }
     278           0 :   }
     279           0 :   FD_TEST( tile );
     280             : 
     281           0 :   fd_topo_run_tile_t runner = fdctl_tile_run( tile );
     282           0 :   if( FD_LIKELY( runner.scratch_align ) ) return runner.scratch_align();
     283           0 :   else                                    return 1UL;
     284           0 : }
     285             : 
     286             : fd_topo_obj_callbacks_t fd_obj_cb_tile = {
     287             :   .name      = "tile",
     288             :   .footprint = tile_footprint,
     289             :   .align     = tile_align,
     290             :   .loose     = tile_loose,
     291             :   .new       = NULL,
     292             : };
     293             : 
     294             : #undef VAL

Generated by: LCOV version 1.14