LCOV - code coverage report
Current view: top level - disco/net - fd_net_tile.h (source / functions) Hit Total Coverage
Test: cov.lcov Lines: 0 17 0.0 %
Date: 2025-07-01 05:00:49 Functions: 0 28 0.0 %

          Line data    Source code
       1             : #ifndef HEADER_fd_src_disco_net_fd_net_tile_h
       2             : #define HEADER_fd_src_disco_net_fd_net_tile_h
       3             : 
       4             : /* fd_net_tile.h contains APIs for providing XDP networking to a
       5             :    Firedancer topology using the 'net' tile. */
       6             : 
       7             : #include "../fd_disco_base.h"
       8             : #include "../../tango/dcache/fd_dcache.h"
       9             : 
      10             : struct fd_topo;
      11             : typedef struct fd_topo fd_topo_t;
      12             : 
      13             : /* Helpers for consumers of net tile RX packets */
      14             : 
      15             : struct fd_net_rx_bounds {
      16             :   ulong base;       /* base address of wksp containing dcache */
      17             :   ulong pkt_lo;     /* lowest permitted pointer to packet payload */
      18             :   ulong pkt_wmark;  /* highest " */
      19             : };
      20             : 
      21             : typedef struct fd_net_rx_bounds fd_net_rx_bounds_t;
      22             : 
      23             : FD_PROTOTYPES_BEGIN
      24             : 
      25             : /* fd_net_rx_bounds_init initializes a bounds checker for RX packets
      26             :    produced by the net tile.  dcache is a local join to a dcache that
      27             :    will carry packet payloads. */
      28             : 
      29             : FD_FN_UNUSED static void
      30             : fd_net_rx_bounds_init( fd_net_rx_bounds_t * bounds,
      31           0 :                        void *               dcache ) {
      32           0 :   bounds->base      = (ulong)fd_wksp_containing( dcache );
      33           0 :   bounds->pkt_lo    = (ulong)dcache;
      34           0 :   bounds->pkt_wmark = bounds->pkt_lo + fd_dcache_data_sz( dcache ) - FD_NET_MTU;
      35           0 :   if( FD_UNLIKELY( !bounds->base ) ) FD_LOG_ERR(( "Failed to find wksp containing dcache" ));
      36           0 : }
      37             : 
      38             : /* fd_net_rx_translate_frag helps net tile consumers locate packet
      39             :    paylads.  bounds is a net_rx_bounds object for the net tile that the
      40             :    frag was received from.  chunk, ctl, sz are frag_meta parameters.
      41             : 
      42             :    Returns a pointer in the local address space to the first byte of an
      43             :    incoming packet.  Terminates the application if the given {chunk,ctl}
      44             :    params would produce an out of bounds buffer. */
      45             : 
      46             : FD_FN_UNUSED static void const *
      47             : fd_net_rx_translate_frag( fd_net_rx_bounds_t const * bounds,
      48             :                           ulong                      chunk,
      49             :                           ulong                      ctl,
      50           0 :                           ulong                      sz ) {
      51           0 :   ulong p = ((ulong)bounds->base + (chunk<<FD_CHUNK_LG_SZ) + ctl);
      52           0 :   if( FD_UNLIKELY( !( (p  >= bounds->pkt_lo   ) &
      53           0 :                       (p  <= bounds->pkt_wmark) &
      54           0 :                       (sz <= FD_NET_MTU       ) ) ) ) {
      55           0 :     FD_LOG_ERR(( "frag %p (chunk=%lu ctl=%lu sz=%lu) is not in bounds [%p:%p]",
      56           0 :                  (void *)p, chunk, ctl, sz,
      57           0 :                  (void *)bounds->pkt_lo, (void *)bounds->pkt_wmark ));
      58           0 :   }
      59           0 :   return (void const *)p;
      60           0 : }
      61             : 
      62             : FD_PROTOTYPES_END
      63             : 
      64             : /* Topology APIs */
      65             : 
      66             : FD_PROTOTYPES_BEGIN
      67             : 
      68             : /* fd_topos_net_tiles appends the net and netlnk tiles to the
      69             :    topology.  These tiles provide fast XDP networking. */
      70             : 
      71             : /* FIXME layering violation */
      72             : struct fd_config_net;
      73             : typedef struct fd_config_net fd_config_net_t;
      74             : 
      75             : void
      76             : fd_topos_net_tiles( fd_topo_t *             topo,
      77             :                     ulong                   net_tile_cnt,
      78             :                     fd_config_net_t const * net_config,
      79             :                     ulong                   netlnk_max_routes,
      80             :                     ulong                   netlnk_max_neighbors,
      81             :                     ulong const             tile_to_cpu[ FD_TILE_MAX ] );
      82             : 
      83             : /* fd_topos_net_rx_link is like fd_topob_link, but for net->app tile
      84             :    packet RX links. */
      85             : 
      86             : void
      87             : fd_topos_net_rx_link( fd_topo_t *  topo,
      88             :                       char const * link_name,
      89             :                       ulong        net_kind_id,
      90             :                       ulong        depth );
      91             : 
      92             : /* fd_topob_tile_in_net registers a net TX link with all net tiles. */
      93             : 
      94             : void
      95             : fd_topos_tile_in_net( fd_topo_t *  topo,
      96             :                       char const * fseq_wksp,
      97             :                       char const * link_name,
      98             :                       ulong        link_kind_id,
      99             :                       int          reliable,
     100             :                       int          polled );
     101             : 
     102             : /* This should be called *after* all app<->net tile links have been
     103             :    created.  Should be called once per net tile. */
     104             : 
     105             : void
     106             : fd_topos_net_tile_finish( fd_topo_t * topo,
     107             :                           ulong       net_kind_id );
     108             : 
     109             : FD_PROTOTYPES_END
     110             : 
     111             : #endif /* HEADER_fd_src_disco_net_fd_net_tile_h */

Generated by: LCOV version 1.14