lcls2
C++ API: public headers of xtcdata, psalg, psdaq and psana
Loading...
Searching...
No Matches
Drp::MemPoolCpu Class Reference

MemPool for a PGP card accessed from the CPU: opens the device and maps its DMA buffers. More...

#include <drp.hh>

Inherits Drp::MemPool.

Public Member Functions

 MemPoolCpu (const Parameters &)
 Open para.device and map its DMA buffers (aborting on failure), write the 0xabababab sentinel at the end of each DMA buffer and initialize the base pool.
 
virtual ~MemPoolCpu ()
 Unmap the DMA buffers and close the device.
 
virtual int fd () const override
 Return the device file descriptor.
 
virtual int setMaskBytes (uint8_t laneMask, unsigned virtChan) override
 On the first successful call, set the driver mask to deliver each lane in laneMask on virtual channel virtChan; later calls do nothing.
 
- Public Member Functions inherited from Drp::MemPool
 MemPool (const Parameters &para)
 Create the transition buffer queue (TEB_TR_BUFFERS rounded up to a power of 2) and zero the counters.
 
virtual ~MemPool ()
 Does nothing; empty body.
 
unsigned dmaCount () const
 Return the number of DMA buffers reported by the driver.
 
unsigned nDmaBuffers () const
 Return dmaCount() rounded up to a power of 2.
 
unsigned dmaSize () const
 Return the size of one DMA buffer.
 
unsigned nbuffers () const
 Return the number of pebble (L1Accept) buffers.
 
size_t bufferSize () const
 Return the size of one pebble L1Accept buffer.
 
void shutdown ()
 Shut down the transition buffer queue and log how often DMA reads and returns failed.
 
Pds::EbDgram * allocateTr ()
 Pop a free transition buffer as an EbDgram pointer, or return nullptr if none is available.
 
void freeTr (Pds::EbDgram *dgram)
 Check the overrun sentinels of transition buffer dgram (logging the first overrun), then push it back onto the free queue.
 
unsigned allocateDma ()
 Count one DMA buffer allocation (the firmware does the actual allocation) and return the count before the increment.
 
ssize_t readDma (uint32_t count, int32_t *ret, uint32_t *index, uint32_t *flags, uint32_t *errors, uint32_t *dest)
 Read up to count DMA buffers with dmaReadBulkIndex() on fd(), filling the per-buffer return sizes, indices, flags, errors and destinations.
 
ssize_t freeDma (unsigned count, uint32_t *indices)
 Return count DMA buffers (by index) to the driver through the subclass and log errors; on success the frees are counted.
 
unsigned allocate ()
 Allocate the next pebble buffer index in order, blocking while all buffers are in use.
 
void freePebble (unsigned)
 Free the oldest pebble buffer (logging if the index is not the expected one), wake a blocked allocate() if the pool was full, and check that buffer's overrun sentinels.
 
void flushPebble ()
 Free pebble buffers in order until none is in use.
 
int64_t dmaInUse () const
 Return the number of DMA allocations minus frees.
 
int64_t inUse () const
 Return the number of pebble allocations minus frees.
 
int64_t trInUse () const
 Return guess_size() of the transition buffer queue.
 
void resetCounters ()
 Reset the DMA counters (only if no DMA buffer is in use, otherwise warn), the pebble counters (with a warning if buffers are still in use), the overrun flags and the error counts.
 
template<typename T >
T * getAs ()
 Return this pool cast with static_cast to T*.
 

Additional Inherited Members

- Public Attributes inherited from Drp::MemPool
Pebble pebble
 Pebble holding the L1Accept and transition buffers.
 
std::vector< PGPEvent > pgpEvents
 Events being assembled, indexed by event counter modulo nDmaBuffers().
 
std::vector< Pds::EbDgram * > transitionDgrams
 Transition datagram assigned to each pebble buffer index (set for non-L1Accept events).
 
void ** dmaBuffers
 DMA buffer addresses mapped from the driver.
 
- Protected Member Functions inherited from Drp::MemPool
void _initialize (const Parameters &)
 
- Protected Attributes inherited from Drp::MemPool
unsigned m_nDmaBuffers
 
unsigned m_nbuffers
 
unsigned m_dmaCount
 
unsigned m_dmaSize
 
SPSCQueue< void * > m_transitionBuffers
 
std::atomic< uint64_t > m_dmaAllocs
 
std::atomic< uint64_t > m_dmaFrees
 
std::atomic< uint64_t > m_allocs
 
std::atomic< uint64_t > m_frees
 
std::mutex m_lock
 
std::condition_variable m_condition
 
uint8_t m_dmaOverrun
 
uint8_t m_l1Overrun
 
uint8_t m_trOverrun
 
uint8_t m_pad
 
unsigned m_nDmaReadErr
 
unsigned m_nDmaRetErr
 

Detailed Description

MemPool for a PGP card accessed from the CPU: opens the device and maps its DMA buffers.

Constructor & Destructor Documentation

◆ MemPoolCpu()

Drp::MemPoolCpu::MemPoolCpu ( const Parameters &  )

Open para.device and map its DMA buffers (aborting on failure), write the 0xabababab sentinel at the end of each DMA buffer and initialize the base pool.

◆ ~MemPoolCpu()

virtual Drp::MemPoolCpu::~MemPoolCpu ( )
virtual

Unmap the DMA buffers and close the device.

Member Function Documentation

◆ fd()

virtual int Drp::MemPoolCpu::fd ( ) const
inlineoverridevirtual

Return the device file descriptor.

Implements Drp::MemPool.

◆ setMaskBytes()

virtual int Drp::MemPoolCpu::setMaskBytes ( uint8_t  laneMask,
unsigned  virtChan 
)
overridevirtual

On the first successful call, set the driver mask to deliver each lane in laneMask on virtual channel virtChan; later calls do nothing.

Returns 0, or 1 if dmaSetMaskBytes() failed.

Implements Drp::MemPool.


The documentation for this class was generated from the following file: