LCOV - code coverage report
Current view: top level - disco/replay - fd_replay.h (source / functions) Hit Total Coverage
Test: cov.lcov Lines: 0 7 0.0 %
Date: 2024-11-13 11:58:15 Functions: 0 0 -

          Line data    Source code
       1             : #ifndef HEADER_fd_src_disco_replay_fd_replay_h
       2             : #define HEADER_fd_src_disco_replay_fd_replay_h
       3             : 
       4             : /* fd_replay provides services to replay data from a pcap file into a
       5             :    tango frag stream. */
       6             : 
       7             : #include "../fd_disco_base.h"
       8             : 
       9             : /* Beyond the standard FD_CNC_SIGNAL_HALT, FD_REPLAY_CNC_SIGNAL_ACK can
      10             :    be raised by a cnc thread with an open command session while the
      11             :    replay is in the RUN state.  The replay will transition from ACK->RUN
      12             :    the next time it processes cnc signals to indicate it is running
      13             :    normally.  If a signal other than ACK, HALT, or RUN is raised, it
      14             :    will be logged as unexpected and transitioned by back to RUN. */
      15             : 
      16             : #define FD_REPLAY_CNC_SIGNAL_ACK (4UL)
      17             : 
      18             : /* A fd_replay_tile will use the fseq and cnc application regions
      19             :    to accumulate flow control diagnostics in the standard ways.  It
      20             :    additionally will accumulate to the cnc application region the
      21             :    following tile specific counters:
      22             : 
      23             :      CHUNK_IDX     is the chunk idx where reply tile should start publishing payloads on boot (ignored if not valid on boot)
      24             :      PCAP_DONE     is cleared before the tile starts processing the pcap and is set when the pcap processing is done
      25             :      PCAP_PUB_CNT  is the number of pcap packets published by the replay
      26             :      PCAP_PUB_SZ   is the number of pcap packet payload bytes published by the replay
      27             :      PCAP_FILT_CNT is the number of pcap packets filtered by the replay
      28             :      PCAP_FILT_SZ  is the number of pcap packet payload bytes filtered by the replay
      29             : 
      30             :    As such, the cnc app region must be at least 64B in size.
      31             : 
      32             :    Except for IN_BACKP, none of the diagnostics are cleared at
      33             :    tile startup (as such that they can be accumulated over multiple
      34             :    runs).  Clearing is up to monitoring scripts. */
      35             : 
      36           0 : #define FD_REPLAY_CNC_DIAG_CHUNK_IDX     (2UL) /* On 1st cache line of app region, updated by producer, frequently */
      37           0 : #define FD_REPLAY_CNC_DIAG_PCAP_DONE     (3UL) /* ", rarely */
      38           0 : #define FD_REPLAY_CNC_DIAG_PCAP_PUB_CNT  (4UL) /* ", frequently */
      39           0 : #define FD_REPLAY_CNC_DIAG_PCAP_PUB_SZ   (5UL) /* ", frequently */
      40           0 : #define FD_REPLAY_CNC_DIAG_PCAP_FILT_CNT (6UL) /* ", frequently */
      41           0 : #define FD_REPLAY_CNC_DIAG_PCAP_FILT_SZ  (7UL) /* ", frequently */
      42             : 
      43             : /* FD_REPLAY_TILE_OUT_MAX are the maximum number of outputs a replay
      44             :    tile can have.  These limits are more or less arbitrary from a
      45             :    functional correctness POV.  They mostly exist to set some practical
      46             :    upper bounds for things like scratch footprint. */
      47             : 
      48             : #define FD_REPLAY_TILE_OUT_MAX FD_FRAG_META_ORIG_MAX
      49             : 
      50             : /* FD_REPLAY_TILE_SCRATCH_{ALIGN,FOOTPRINT} specify the alignment and
      51             :    footprint needed for a replay tile scratch region that can support
      52             :    out_cnt outputs.  ALIGN is an integer power of 2 of at least double
      53             :    cache line to mitigate various kinds of false sharing.  FOOTPRINT
      54             :    will be an integer multiple of ALIGN.  out_cnt is assumed to be valid
      55             :    (i.e. at most FD_REPLAY_TILE_OUT_MAX).  These are provided to
      56             :    facilitate compile time declarations. */
      57             : 
      58           0 : #define FD_REPLAY_TILE_SCRATCH_ALIGN (128UL)
      59             : #define FD_REPLAY_TILE_SCRATCH_FOOTPRINT( out_cnt )  \
      60             :   FD_LAYOUT_FINI( FD_LAYOUT_APPEND( FD_LAYOUT_INIT,  \
      61             :     FD_FCTL_ALIGN, FD_FCTL_FOOTPRINT( (out_cnt) ) ), \
      62             :     FD_REPLAY_TILE_SCRATCH_ALIGN )
      63             : 
      64             : FD_PROTOTYPES_BEGIN
      65             : 
      66             : /* fd_replay_tile replays a packets in a pcap file as a tango fragment
      67             :    stream from origin orig into the given mcache and dcache.  The tile
      68             :    can send to out_cnt reliable consumers and an arbitrary number of
      69             :    unreliable consumers.  (While reliable consumers are simple to reason
      70             :    about, they have especially high demands on their implementation as a
      71             :    single slow reliable consumer can backpressure the replay and _all_
      72             :    other consumers using the replay.)
      73             : 
      74             :    When this is called, the cnc should be in the BOOT state.  Returns 0
      75             :    on a successful run of the replay tile.  That is, the tile booted
      76             :    successfully (transitioning the cnc from BOOT->RUN), ran (handling
      77             :    any application specific cnc signals while running), and (after
      78             :    receiving a HALT signal) halted successfully (transitioning the cnc
      79             :    from HALT->BOOT before return).  Returns a non-zero error code if the
      80             :    tile fails to boot up (logs details ... the cnc will not be
      81             :    transitioned from its original state and thus is likely bootable
      82             :    again if its original state was BOOT).  For maximally robust
      83             :    operation in the current implementation, all reliable consumers
      84             :    should be halted and/or caught up before this tile is halted.
      85             : 
      86             :    There are no theoretical restrictions on the mcache depth.
      87             :    Practically, it is recommend it be as large as possible, especially
      88             :    for bursty streams and/or a large number of reliable consumers.  This
      89             :    implementation indexes chunks relative to the workspace used by the
      90             :    mcache to facilitate easy muxing.  The dcache size should be adequate
      91             :    for compact writing.
      92             : 
      93             :    cr_max is the maximum number of flow control credits the replay tile
      94             :    is allowed for publishing frags.  It represents the maximum number of
      95             :    frags a reliable out can lag behind the output stream.  In the
      96             :    general case, the optimal value is usually
      97             :    min(mcache.depth,out[*].lag_max).  If cr_max is zero, mcache.depth
      98             :    will be used as a default for cr_max.  This is equivalent to
      99             :    assuming, as is typically the case, outs are allowed to lag the
     100             :    replay by up mcache.depth frags.
     101             : 
     102             :    lazy is the ballpark interval in ns for how often to receive credits
     103             :    from consumers.  Too small a lazy will drown the system in cache
     104             :    coherence traffic.  Too large a lazy will degrade system throughput
     105             :    because of producers stalled, waiting for credits.  lazy should be
     106             :    roughly proportional to cr_max and the constant of proportionality
     107             :    should be less than the smaller of how fast a producer can generate
     108             :    frags / how fast a consumer can process frags typically.  <=0
     109             :    indicates to pick a conservative default.
     110             : 
     111             :    scratch points to tile scratch memory.  fd_replay_tile_scratch_align
     112             :    and fd_replay_tile_scratch_footprint return the required alignment
     113             :    and footprint needed for this region.  This memory region is
     114             :    exclusively owned by the replay tile while the tile is running and is
     115             :    ideally near the core running the replay tile.
     116             :    fd_replay_tile_scratch_align will return the same value as
     117             :    FD_REPLAY_TILE_SCRATCH_ALIGN.  If out_cnt is not valid,
     118             :    fd_replay_tile_scratch_footprint silently returns 0 so callers can
     119             :    diagnose configuration issues.  Otherwise,
     120             :    fd_replay_tile_scratch_footprint will return the same value as
     121             :    FD_REPLAY_TILE_SCRATCH_FOOTPRINT.
     122             :    
     123             :    The lifetime of the cnc, mcache, dcache, out_fseq[*], rng and scratch
     124             :    used by this tile should be a superset of this tile's lifetime.
     125             :    While this tile is running, no other tile should use cnc for its
     126             :    command and control, publish into mcache or dcache, use the rng for
     127             :    anything (and the rng should be seeded distinctly from all other rngs
     128             :    in the system), or use scratch for anything.  This tile uses the
     129             :    fseqs passed to it in the usual producer ways (e.g. discovering the
     130             :    location of reliable consumers in the mcache's sequence space and
     131             :    updating producer oriented diagnostics).  The out_fseq array and
     132             :    pcap_path cstr will not be used the after the tile has successfully
     133             :    booted (transitioned the cnc from BOOT to RUN) or returned (e.g.
     134             :    failed to boot), whichever comes first. */
     135             : 
     136             : FD_FN_CONST ulong
     137             : fd_replay_tile_scratch_align( void );
     138             : 
     139             : FD_FN_CONST ulong
     140             : fd_replay_tile_scratch_footprint( ulong out_cnt );
     141             : 
     142             : int
     143             : fd_replay_tile( fd_cnc_t *       cnc,       /* Local join to the replay's command-and-control */
     144             :                 char const *     pcap_path, /* Points to first byte of cstr with the path to the pcap to use */
     145             :                 ulong            pkt_max,   /* Upper bound of a size of packet in the pcap */
     146             :                 ulong            orig,      /* Origin for this pcap fragment stream, in [0,FD_FRAG_META_ORIG_MAX) */
     147             :                 fd_frag_meta_t * mcache,    /* Local join to the replay's frag stream output mcache */
     148             :                 uchar *          dcache,    /* Local join to the replay's frag stream output dcache */
     149             :                 ulong            out_cnt,   /* Number of reliable consumers, reliable consumers are indexed [0,out_cnt) */
     150             :                 ulong **         out_fseq,  /* out_fseq[out_idx] is the local join to reliable consumer out_idx's fseq */
     151             :                 ulong            cr_max,    /* Maximum number of flow control credits, 0 means use a reasonable default */
     152             :                 long             lazy,      /* Lazyiness, <=0 means use a reasonable default */
     153             :                 fd_rng_t *       rng,       /* Local join to the rng this replay should use */
     154             :                 void *           scratch ); /* Tile scratch memory */
     155             : 
     156             : FD_PROTOTYPES_END
     157             : 
     158             : #endif /* HEADER_fd_src_disco_replay_fd_replay_h */
     159             : 

Generated by: LCOV version 1.14