LCOV - code coverage report
Current view: top level - app/shared - fd_obj_callbacks.c (source / functions) Hit Total Coverage
Test: cov.lcov Lines: 131 134 97.8 %
Date: 2025-09-18 04:41:32 Functions: 29 60 48.3 %

          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        1539 : #define VAL(name) (__extension__({                                                             \
      15        1539 :   ulong __x = fd_pod_queryf_ulong( topo->props, ULONG_MAX, "obj.%lu.%s", obj->id, name );      \
      16        1539 :   if( FD_UNLIKELY( __x==ULONG_MAX ) ) FD_LOG_ERR(( "obj.%lu.%s was not set", obj->id, name )); \
      17        1539 :   __x; }))
      18             : 
      19             : static ulong
      20             : mcache_footprint( fd_topo_t const *     topo,
      21         342 :                   fd_topo_obj_t const * obj ) {
      22         342 :   return fd_mcache_footprint( VAL("depth"), 0UL );
      23         342 : }
      24             : 
      25             : static ulong
      26             : mcache_align( fd_topo_t const *     topo FD_FN_UNUSED,
      27         342 :               fd_topo_obj_t const * obj  FD_FN_UNUSED ) {
      28         342 :   return fd_mcache_align();
      29         342 : }
      30             : 
      31             : static void
      32             : mcache_new( fd_topo_t const *     topo,
      33          75 :             fd_topo_obj_t const * obj ) {
      34          75 :   FD_TEST( fd_mcache_new( fd_topo_obj_laddr( topo, obj->id ), VAL("depth"), 0UL, 0UL ) );
      35          75 : }
      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         318 :                    fd_topo_obj_t const * obj ) {
      47         318 :   ulong app_sz  = fd_pod_queryf_ulong( topo->props, 0UL,       "obj.%lu.app_sz",  obj->id );
      48         318 :   ulong data_sz = fd_pod_queryf_ulong( topo->props, ULONG_MAX, "obj.%lu.data_sz", obj->id );
      49         318 :   if( data_sz==ULONG_MAX ) {
      50         318 :     data_sz = fd_dcache_req_data_sz( VAL("mtu"), VAL("depth"), VAL("burst"), 1 );
      51         318 :   }
      52         318 :   return fd_dcache_footprint( data_sz, app_sz );
      53         318 : }
      54             : 
      55             : static ulong
      56             : dcache_align( fd_topo_t const *     topo FD_FN_UNUSED,
      57         318 :               fd_topo_obj_t const * obj  FD_FN_UNUSED ) {
      58         318 :   return fd_dcache_align();
      59         318 : }
      60             : 
      61             : static void
      62             : dcache_new( fd_topo_t const *     topo,
      63          60 :             fd_topo_obj_t const * obj ) {
      64          60 :   ulong app_sz  = fd_pod_queryf_ulong( topo->props, 0UL,       "obj.%lu.app_sz",  obj->id );
      65          60 :   ulong data_sz = fd_pod_queryf_ulong( topo->props, ULONG_MAX, "obj.%lu.data_sz", obj->id );
      66          60 :   if( data_sz==ULONG_MAX ) {
      67          60 :     data_sz = fd_dcache_req_data_sz( VAL("mtu"), VAL("depth"), VAL("burst"), 1 );
      68          60 :   }
      69          60 :   FD_TEST( fd_dcache_new( fd_topo_obj_laddr( topo, obj->id ), data_sz, app_sz ) );
      70          60 : }
      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         501 :                 fd_topo_obj_t const * obj  FD_FN_UNUSED ) {
      82         501 :   return fd_fseq_footprint();
      83         501 : }
      84             : 
      85             : static ulong
      86             : fseq_align( fd_topo_t const *     topo FD_FN_UNUSED,
      87         501 :             fd_topo_obj_t const * obj  FD_FN_UNUSED ) {
      88         501 :   return fd_fseq_align();
      89         501 : }
      90             : 
      91             : static void
      92             : fseq_new( fd_topo_t const *     topo,
      93         495 :           fd_topo_obj_t const * obj ) {
      94         495 :   FD_TEST( fd_fseq_new( fd_topo_obj_laddr( topo, obj->id ), ULONG_MAX ) );
      95         495 : }
      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         183 :                    fd_topo_obj_t const * obj ) {
     107         183 :   return FD_METRICS_FOOTPRINT( VAL("in_cnt"), VAL("cons_cnt") );
     108         183 : }
     109             : 
     110             : static ulong
     111             : metrics_align( fd_topo_t const *     topo FD_FN_UNUSED,
     112         183 :                fd_topo_obj_t const * obj  FD_FN_UNUSED ) {
     113         183 :   return FD_METRICS_ALIGN;
     114         183 : }
     115             : 
     116             : static void
     117             : metrics_new( fd_topo_t const *     topo,
     118         183 :              fd_topo_obj_t const * obj ) {
     119         183 :   FD_TEST( fd_metrics_new( fd_topo_obj_laddr( topo, obj->id ), VAL("in_cnt"), VAL("cons_cnt") ) );
     120         183 : }
     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           6 :                   fd_topo_obj_t const * obj  FD_FN_UNUSED ) {
     132           6 :   return VAL("footprint");
     133           6 : }
     134             : 
     135             : static ulong
     136             : opaque_align( fd_topo_t const *     topo FD_FN_UNUSED,
     137           6 :               fd_topo_obj_t const * obj  FD_FN_UNUSED ) {
     138           6 :   return VAL("align");
     139           6 : }
     140             : 
     141             : static void
     142             : opaque_new( fd_topo_t const *     topo,
     143           3 :               fd_topo_obj_t const * obj ) {
     144           3 :   fd_memset( fd_topo_obj_laddr( topo, obj->id ), 0, VAL("footprint") );
     145           3 : }
     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           6 :                    fd_topo_obj_t const * obj ) {
     157           6 :   return fd_dbl_buf_footprint( VAL("mtu") );
     158           6 : }
     159             : 
     160             : static ulong
     161             : dbl_buf_align( fd_topo_t const *     topo FD_FN_UNUSED,
     162           6 :                fd_topo_obj_t const * obj  FD_FN_UNUSED ) {
     163           6 :   return fd_dbl_buf_align();
     164           6 : }
     165             : 
     166             : static void
     167             : dbl_buf_new( fd_topo_t const *     topo,
     168           3 :               fd_topo_obj_t const * obj ) {
     169           3 :   FD_TEST( fd_dbl_buf_new( fd_topo_obj_laddr( topo, obj->id ), VAL("mtu"), 1UL ) );
     170           3 : }
     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           6 :                    fd_topo_obj_t const * obj ) {
     182           6 :   return fd_neigh4_hmap_footprint( VAL("ele_max"), VAL("lock_cnt"), VAL("probe_max") );
     183           6 : }
     184             : 
     185             : static ulong
     186             : neigh4_hmap_align( fd_topo_t const *     topo FD_FN_UNUSED,
     187           6 :                    fd_topo_obj_t const * obj  FD_FN_UNUSED ) {
     188           6 :   return fd_neigh4_hmap_align();
     189           6 : }
     190             : 
     191             : static void
     192             : neigh4_hmap_new( fd_topo_t const *     topo,
     193           3 :                  fd_topo_obj_t const * obj ) {
     194           3 :   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           3 : }
     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          12 :                 fd_topo_obj_t const * obj ) {
     207          12 :   return fd_fib4_footprint( VAL("route_max"), VAL("route_peer_max") );
     208          12 : }
     209             : 
     210             : static ulong
     211             : fib4_align( fd_topo_t const *     topo FD_FN_UNUSED,
     212          12 :             fd_topo_obj_t const * obj  FD_FN_UNUSED ) {
     213          12 :   return fd_fib4_align();
     214          12 : }
     215             : 
     216             : static void
     217             : fib4_new( fd_topo_t const *     topo,
     218           6 :            fd_topo_obj_t const * obj ) {
     219           6 :   FD_TEST( fd_fib4_new( fd_topo_obj_laddr( topo, obj->id ), VAL("route_max"), VAL("route_peer_max"), VAL("route_peer_seed") ) );
     220           6 : }
     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          33 :                      fd_topo_obj_t const * obj  FD_FN_UNUSED ) {
     232          33 :   return fd_keyswitch_footprint();
     233          33 : }
     234             : 
     235             : static ulong
     236             : keyswitch_align( fd_topo_t const *     topo FD_FN_UNUSED,
     237          33 :                  fd_topo_obj_t const * obj  FD_FN_UNUSED ) {
     238          33 :   return fd_keyswitch_align();
     239          33 : }
     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         183 :                 fd_topo_obj_t const * obj ) {
     260         183 :   fd_topo_tile_t const * tile = NULL;
     261        3009 :   for( ulong i=0UL; i<topo->tile_cnt; i++ ) {
     262        3009 :     if( FD_LIKELY( topo->tiles[ i ].tile_obj_id==obj->id ) ) {
     263         183 :       tile = &topo->tiles[ i ];
     264         183 :       break;
     265         183 :     }
     266        3009 :   }
     267         183 :   FD_TEST( tile );
     268             : 
     269         183 :   fd_topo_run_tile_t runner = fdctl_tile_run( tile );
     270         183 :   if( FD_LIKELY( runner.scratch_footprint ) ) return runner.scratch_footprint( tile );
     271         177 :   else                                        return 0UL;
     272         183 : }
     273             : 
     274             : static ulong
     275             : tile_loose( fd_topo_t const *     topo,
     276         183 :             fd_topo_obj_t const * obj ) {
     277         183 :   fd_topo_tile_t const * tile = NULL;
     278        3009 :   for( ulong i=0UL; i<topo->tile_cnt; i++ ) {
     279        3009 :     if( FD_LIKELY( topo->tiles[ i ].tile_obj_id==obj->id ) ) {
     280         183 :       tile = &topo->tiles[ i ];
     281         183 :       break;
     282         183 :     }
     283        3009 :   }
     284         183 :   FD_TEST( tile );
     285             : 
     286         183 :   fd_topo_run_tile_t runner = fdctl_tile_run( tile );
     287         183 :   if( FD_UNLIKELY( runner.loose_footprint ) ) return runner.loose_footprint( tile );
     288         183 :   else                                        return 0UL;
     289         183 : }
     290             : 
     291             : static ulong
     292             : tile_align( fd_topo_t const *     topo,
     293         183 :             fd_topo_obj_t const * obj ) {
     294         183 :   fd_topo_tile_t const * tile = NULL;
     295        3009 :   for( ulong i=0UL; i<topo->tile_cnt; i++ ) {
     296        3009 :     if( FD_LIKELY( topo->tiles[ i ].tile_obj_id==obj->id ) ) {
     297         183 :       tile = &topo->tiles[ i ];
     298         183 :       break;
     299         183 :     }
     300        3009 :   }
     301         183 :   FD_TEST( tile );
     302             : 
     303         183 :   fd_topo_run_tile_t runner = fdctl_tile_run( tile );
     304         183 :   if( FD_LIKELY( runner.scratch_align ) ) return runner.scratch_align();
     305         177 :   else                                    return 1UL;
     306         183 : }
     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

Generated by: LCOV version 1.14