|
lcls2
C++ API: public headers of xtcdata, psalg, psdaq and psana
|
Abstract set of buffer pools for one DRP: the DMA buffers (allocated by the driver; only counted here), the pebble buffers and the transition buffers. More...
#include <drp.hh>
Inherited by Drp::Gpu::MemPoolGpu, and Drp::MemPoolCpu.
Public Member Functions | |
| MemPool (const Parameters ¶) | |
| 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. | |
| virtual int | fd () const =0 |
| Pure virtual: return the device file descriptor. | |
| 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. | |
| virtual int | setMaskBytes (uint8_t laneMask, unsigned virtChan)=0 |
| Pure virtual: configure the driver to deliver the lanes in laneMask on virtual channel virtChan. | |
| template<typename T > | |
| T * | getAs () |
| Return this pool cast with static_cast to T*. | |
Public Attributes | |
| 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 | |
| void | _initialize (const Parameters &) |
Protected Attributes | |
| 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 |
Abstract set of buffer pools for one DRP: the DMA buffers (allocated by the driver; only counted here), the pebble buffers and the transition buffers.
Subclasses open the device and provide fd(), setMaskBytes() and the release of DMA buffers.
| 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.
The subclass calls _initialize() once the DMA buffer count and size are known.
|
inlinevirtual |
Does nothing; empty body.
|
protected |
| unsigned Drp::MemPool::allocate | ( | ) |
Allocate the next pebble buffer index in order, blocking while all buffers are in use.
Pebble buffers must be freed in allocation order.
| unsigned Drp::MemPool::allocateDma | ( | ) |
Count one DMA buffer allocation (the firmware does the actual allocation) and return the count before the increment.
| Pds::EbDgram * Drp::MemPool::allocateTr | ( | ) |
Pop a free transition buffer as an EbDgram pointer, or return nullptr if none is available.
|
inline |
Return the size of one pebble L1Accept buffer.
|
inline |
Return the number of DMA buffers reported by the driver.
|
inline |
Return the number of DMA allocations minus frees.
|
inline |
Return the size of one DMA buffer.
|
pure virtual |
Pure virtual: return the device file descriptor.
Implemented in Drp::MemPoolCpu, and Drp::Gpu::MemPoolGpu.
| void Drp::MemPool::flushPebble | ( | ) |
Free pebble buffers in order until none is in use.
| ssize_t Drp::MemPool::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.
Returns the subclass result.
| void Drp::MemPool::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 Drp::MemPool::freeTr | ( | Pds::EbDgram * | dgram | ) |
Check the overrun sentinels of transition buffer dgram (logging the first overrun), then push it back onto the free queue.
|
inline |
Return this pool cast with static_cast to T*.
|
inline |
Return the number of pebble allocations minus frees.
|
inline |
Return the number of pebble (L1Accept) buffers.
|
inline |
Return dmaCount() rounded up to a power of 2.
| ssize_t Drp::MemPool::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.
Returns its result; errors are logged (the first one at error level).
| void Drp::MemPool::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.
|
pure virtual |
Pure virtual: configure the driver to deliver the lanes in laneMask on virtual channel virtChan.
Implemented in Drp::MemPoolCpu, and Drp::Gpu::MemPoolGpu.
| void Drp::MemPool::shutdown | ( | ) |
Shut down the transition buffer queue and log how often DMA reads and returns failed.
|
inline |
Return guess_size() of the transition buffer queue.
That queue holds the free buffers, so despite the name this is the approximate number of free transition buffers.
| void** Drp::MemPool::dmaBuffers |
DMA buffer addresses mapped from the driver.
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
| std::vector<PGPEvent> Drp::MemPool::pgpEvents |
Events being assembled, indexed by event counter modulo nDmaBuffers().
| std::vector<Pds::EbDgram*> Drp::MemPool::transitionDgrams |
Transition datagram assigned to each pebble buffer index (set for non-L1Accept events).