μHAL (v2.8.17)
Part of the IPbus software repository
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
Classes | Public Member Functions | Private Types | Private Member Functions | Static Private Member Functions | Private Attributes | List of all members
uhal::Mmap Class Reference

Transport protocol to transfer an IPbus buffer via device file, using mmap. More...

#include <uhal/ProtocolMmap.hpp>

Inheritance diagram for uhal::Mmap:
[legend]
Collaboration diagram for uhal::Mmap:
[legend]

Classes

class  File
 
struct  HexTo
 

Public Member Functions

 Mmap (const std::string &aId, const URI &aUri)
 Constructor. More...
 
virtual ~Mmap ()
 Destructor. More...
 

Private Types

typedef IPbus< 2, 0 > InnerProtocol
 
typedef std::chrono::steady_clock SteadyClock_t
 

Private Member Functions

 Mmap (const Mmap &aMmap)
 
Mmapoperator= (const Mmap &aMmap)
 
void implementDispatch (std::shared_ptr< Buffers > aBuffers)
 Send the IPbus buffer to the target, read back the response and call the packing-protocol's validate function. More...
 
virtual void Flush ()
 Concrete implementation of the synchronization function to block until all buffers have been sent, all replies received and all data validated. More...
 
virtual void dispatchExceptionHandler ()
 Function which tidies up this protocol layer in the event of an exception. More...
 
uint32_t getMaxSendSize ()
 Return the maximum size to be sent based on the buffer size in the target. More...
 
uint32_t getMaxReplySize ()
 Return the maximum size of reply packet based on the buffer size in the target. More...
 
void connect ()
 Set up the connection to the device. More...
 
void connect (detail::ScopedSessionLock &)
 Set up the connection to the device. More...
 
void disconnect ()
 Close the connection to the device. More...
 
void write (const std::shared_ptr< Buffers > &aBuffers)
 Write request packet to next page in host-to-FPGA device file. More...
 
void read ()
 Read next pending reply packet from appropriate page of FPGA-to-host device file, and validate contents. More...
 

Static Private Member Functions

static std::string getSharedMemName (const std::string &)
 

Private Attributes

bool mConnected
 
File mDeviceFile
 
detail::SharedObject< detail::RobustSessionMutexmIPCMutex
 
bool mIPCExternalSessionActive
 
uint64_t mIPCSessionCount
 
std::chrono::microseconds mSleepDuration
 
uint32_t mNumberOfPages
 
uint32_t mMaxInFlight
 
uint32_t mPageSize
 
uint32_t mMaxPacketSize
 
uint32_t mIndexNextPage
 
uint32_t mPublishedReplyPageCount
 
uint32_t mReadReplyPageCount
 
std::deque< std::shared_ptr< Buffers > > mReplyQueue
 The list of buffers still awaiting a reply. More...
 

Detailed Description

Transport protocol to transfer an IPbus buffer via device file, using mmap.

Definition at line 80 of file ProtocolMmap.hpp.

Member Typedef Documentation

◆ InnerProtocol

typedef IPbus< 2 , 0 > uhal::Mmap::InnerProtocol
private

Definition at line 159 of file ProtocolMmap.hpp.

◆ SteadyClock_t

typedef std::chrono::steady_clock uhal::Mmap::SteadyClock_t
private

Definition at line 161 of file ProtocolMmap.hpp.

Constructor & Destructor Documentation

◆ Mmap() [1/2]

uhal::Mmap::Mmap ( const Mmap aMmap)
private

◆ Mmap() [2/2]

uhal::Mmap::Mmap ( const std::string &  aId,
const URI aUri 
)

Constructor.

Parameters
aIdthe uinique identifier that the client will be given.
aUria struct containing the full URI of the target.

Definition at line 283 of file ProtocolMmap.cpp.

References uhal::Integer(), uhal::log(), uhal::URI::mArguments, mDeviceFile, mMaxInFlight, mMaxPacketSize, mSleepDuration, uhal::Notice, uhal::Quote(), uhal::Mmap::File::setOffset(), and uhal::Warning.

◆ ~Mmap()

uhal::Mmap::~Mmap ( )
virtual

Destructor.

Definition at line 324 of file ProtocolMmap.cpp.

References disconnect().

Member Function Documentation

◆ connect() [1/2]

void uhal::Mmap::connect ( )
private

Set up the connection to the device.

Definition at line 388 of file ProtocolMmap.cpp.

References connect(), and mIPCMutex.

Referenced by connect(), getMaxReplySize(), getMaxSendSize(), implementDispatch(), and write().

◆ connect() [2/2]

void uhal::Mmap::connect ( detail::ScopedSessionLock aGuard)
private

◆ disconnect()

void uhal::Mmap::disconnect ( )
private

Close the connection to the device.

Definition at line 434 of file ProtocolMmap.cpp.

References uhal::Mmap::File::close(), mConnected, and mDeviceFile.

Referenced by dispatchExceptionHandler(), and ~Mmap().

◆ dispatchExceptionHandler()

void uhal::Mmap::dispatchExceptionHandler ( )
privatevirtual

Function which tidies up this protocol layer in the event of an exception.

Definition at line 356 of file ProtocolMmap.cpp.

References disconnect(), uhal::Info, uhal::log(), mDeviceFile, mReplyQueue, uhal::Quote(), uhal::ClientInterface::returnBufferToPool(), and uhal::Mmap::File::unlock().

◆ Flush()

void uhal::Mmap::Flush ( )
privatevirtual

Concrete implementation of the synchronization function to block until all buffers have been sent, all replies received and all data validated.

Definition at line 343 of file ProtocolMmap.cpp.

References uhal::Debug, uhal::log(), mDeviceFile, mIPCMutex, mReplyQueue, uhal::Quote(), read(), and uhal::Mmap::File::unlock().

◆ getMaxReplySize()

uint32_t uhal::Mmap::getMaxReplySize ( )
private

Return the maximum size of reply packet based on the buffer size in the target.

Returns
the maximum size of reply packet

Definition at line 379 of file ProtocolMmap.cpp.

References connect(), mConnected, and mMaxPacketSize.

◆ getMaxSendSize()

uint32_t uhal::Mmap::getMaxSendSize ( )
private

Return the maximum size to be sent based on the buffer size in the target.

Returns
the maximum size to be sent

Definition at line 370 of file ProtocolMmap.cpp.

References connect(), mConnected, and mMaxPacketSize.

◆ getSharedMemName()

std::string uhal::Mmap::getSharedMemName ( const std::string &  aPath)
staticprivate

Definition at line 274 of file ProtocolMmap.cpp.

◆ implementDispatch()

void uhal::Mmap::implementDispatch ( std::shared_ptr< Buffers aBuffers)
private

Send the IPbus buffer to the target, read back the response and call the packing-protocol's validate function.

Parameters
aBuffersthe buffer object wrapping the send and recieve buffers that are to be transported If multithreaded, adds buffer to the dispatch queue and returns. If single-threaded, calls the dispatch-worker dispatch function directly and blocks until the response is validated.

Definition at line 330 of file ProtocolMmap.cpp.

References connect(), uhal::Debug, uhal::log(), mConnected, mNumberOfPages, mReplyQueue, uhal::Quote(), read(), and write().

◆ operator=()

Mmap & uhal::Mmap::operator= ( const Mmap aMmap)
private

◆ read()

void uhal::Mmap::read ( )
private

◆ write()

void uhal::Mmap::write ( const std::shared_ptr< Buffers > &  aBuffers)
private

Member Data Documentation

◆ mConnected

bool uhal::Mmap::mConnected
private

◆ mDeviceFile

File uhal::Mmap::mDeviceFile
private

Definition at line 192 of file ProtocolMmap.hpp.

Referenced by connect(), disconnect(), dispatchExceptionHandler(), Flush(), Mmap(), read(), and write().

◆ mIndexNextPage

uint32_t uhal::Mmap::mIndexNextPage
private

Definition at line 200 of file ProtocolMmap.hpp.

Referenced by connect(), read(), and write().

◆ mIPCExternalSessionActive

bool uhal::Mmap::mIPCExternalSessionActive
private

Definition at line 195 of file ProtocolMmap.hpp.

Referenced by connect(), and write().

◆ mIPCMutex

detail::SharedObject<detail::RobustSessionMutex> uhal::Mmap::mIPCMutex
private

Definition at line 194 of file ProtocolMmap.hpp.

Referenced by connect(), Flush(), read(), and write().

◆ mIPCSessionCount

uint64_t uhal::Mmap::mIPCSessionCount
private

Definition at line 196 of file ProtocolMmap.hpp.

Referenced by connect(), and write().

◆ mMaxInFlight

uint32_t uhal::Mmap::mMaxInFlight
private

Definition at line 200 of file ProtocolMmap.hpp.

Referenced by connect(), and Mmap().

◆ mMaxPacketSize

uint32_t uhal::Mmap::mMaxPacketSize
private

Definition at line 200 of file ProtocolMmap.hpp.

Referenced by connect(), getMaxReplySize(), getMaxSendSize(), and Mmap().

◆ mNumberOfPages

uint32_t uhal::Mmap::mNumberOfPages
private

Definition at line 200 of file ProtocolMmap.hpp.

Referenced by connect(), implementDispatch(), read(), and write().

◆ mPageSize

uint32_t uhal::Mmap::mPageSize
private

Definition at line 200 of file ProtocolMmap.hpp.

Referenced by connect(), read(), and write().

◆ mPublishedReplyPageCount

uint32_t uhal::Mmap::mPublishedReplyPageCount
private

Definition at line 200 of file ProtocolMmap.hpp.

Referenced by connect(), and read().

◆ mReadReplyPageCount

uint32_t uhal::Mmap::mReadReplyPageCount
private

Definition at line 200 of file ProtocolMmap.hpp.

Referenced by connect(), and read().

◆ mReplyQueue

std::deque< std::shared_ptr< Buffers > > uhal::Mmap::mReplyQueue
private

The list of buffers still awaiting a reply.

Definition at line 203 of file ProtocolMmap.hpp.

Referenced by dispatchExceptionHandler(), Flush(), implementDispatch(), read(), and write().

◆ mSleepDuration

std::chrono::microseconds uhal::Mmap::mSleepDuration
private

Definition at line 198 of file ProtocolMmap.hpp.

Referenced by Mmap(), and read().


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