Line data Source code
1 : #ifndef HEADER_fd_src_disco_stem_fd_stem_h 2 : #define HEADER_fd_src_disco_stem_fd_stem_h 3 : 4 : #include "../fd_disco_base.h" 5 : 6 0 : #define FD_STEM_SCRATCH_ALIGN (128UL) 7 : 8 : struct fd_stem_context { 9 : fd_frag_meta_t ** mcaches; 10 : ulong * seqs; 11 : ulong * depths; 12 : 13 : ulong * cr_avail; 14 : ulong cr_decrement_amount; 15 : }; 16 : 17 : typedef struct fd_stem_context fd_stem_context_t; 18 : 19 : struct __attribute__((aligned(64))) fd_stem_tile_in { 20 : fd_frag_meta_t const * mcache; /* local join to this in's mcache */ 21 : uint depth; /* == fd_mcache_depth( mcache ), depth of this in's cache (const) */ 22 : uint idx; /* index of this in in the list of providers, [0, in_cnt) */ 23 : ulong seq; /* sequence number of next frag expected from the upstream producer, 24 : updated when frag from this in is published */ 25 : fd_frag_meta_t const * mline; /* == mcache + fd_mcache_line_idx( seq, depth ), location to poll next */ 26 : ulong * fseq; /* local join to the fseq used to return flow control credits to the in */ 27 : uint accum[6]; /* local diagnostic accumulators. These are drained during in housekeeping. */ 28 : /* Assumes FD_FSEQ_DIAG_{PUB_CNT,PUB_SZ,FILT_CNT,FILT_SZ,OVRNP_CNT,OVRNP_FRAG_CNT} are 0:5 */ 29 : }; 30 : 31 : typedef struct fd_stem_tile_in fd_stem_tile_in_t; 32 : 33 : static inline void 34 : fd_stem_publish( fd_stem_context_t * stem, 35 : ulong out_idx, 36 : ulong sig, 37 : ulong chunk, 38 : ulong sz, 39 : ulong ctl, 40 : ulong tsorig, 41 0 : ulong tspub ) { 42 0 : ulong * seqp = &stem->seqs[ out_idx ]; 43 0 : ulong seq = *seqp; 44 0 : fd_mcache_publish( stem->mcaches[ out_idx ], stem->depths[ out_idx ], seq, sig, chunk, sz, ctl, tsorig, tspub ); 45 0 : *stem->cr_avail -= stem->cr_decrement_amount; 46 0 : *seqp = fd_seq_inc( seq, 1UL ); 47 0 : } 48 : 49 : static inline ulong 50 : fd_stem_advance( fd_stem_context_t * stem, 51 0 : ulong out_idx ) { 52 0 : ulong * seqp = &stem->seqs[ out_idx ]; 53 0 : ulong seq = *seqp; 54 0 : *stem->cr_avail -= stem->cr_decrement_amount; 55 0 : *seqp = fd_seq_inc( seq, 1UL ); 56 0 : return seq; 57 0 : } 58 : 59 : #endif /* HEADER_fd_src_disco_stem_fd_stem_h */