Transport protocol to transfer an IPbus buffer via device file, using mmap. More...
#include <uhal/ProtocolMmap.hpp>
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) | |
Mmap & | operator= (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::RobustSessionMutex > | mIPCMutex |
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... | |
Transport protocol to transfer an IPbus buffer via device file, using mmap.
Definition at line 80 of file ProtocolMmap.hpp.
|
private |
Definition at line 159 of file ProtocolMmap.hpp.
|
private |
Definition at line 161 of file ProtocolMmap.hpp.
|
private |
uhal::Mmap::Mmap | ( | const std::string & | aId, |
const URI & | aUri | ||
) |
Constructor.
aId | the uinique identifier that the client will be given. |
aUri | a 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.
|
virtual |
|
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().
|
private |
Set up the connection to the device.
Definition at line 395 of file ProtocolMmap.cpp.
References uhal::Debug, uhal::Mmap::File::getPath(), uhal::Mmap::File::haveLock(), uhal::Info, uhal::Integer(), uhal::log(), mConnected, mDeviceFile, mIndexNextPage, mIPCExternalSessionActive, mIPCMutex, mIPCSessionCount, mMaxInFlight, mMaxPacketSize, mNumberOfPages, mPageSize, mPublishedReplyPageCount, mReadReplyPageCount, uhal::Quote(), and uhal::Mmap::File::read().
|
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().
|
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().
|
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().
|
private |
Return the maximum size of reply packet based on the buffer size in the target.
Definition at line 379 of file ProtocolMmap.cpp.
References connect(), mConnected, and mMaxPacketSize.
|
private |
Return the maximum size to be sent based on the buffer size in the target.
Definition at line 370 of file ProtocolMmap.cpp.
References connect(), mConnected, and mMaxPacketSize.
|
staticprivate |
Definition at line 274 of file ProtocolMmap.cpp.
|
private |
Send the IPbus buffer to the target, read back the response and call the packing-protocol's validate function.
aBuffers | the 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().
|
private |
Read next pending reply packet from appropriate page of FPGA-to-host device file, and validate contents.
Definition at line 473 of file ProtocolMmap.cpp.
References uhal::Debug, uhal::Mmap::File::getPath(), uhal::Info, uhal::Integer(), uhal::log(), mDeviceFile, mIndexNextPage, mIPCMutex, mNumberOfPages, mPageSize, mPublishedReplyPageCount, mReadReplyPageCount, mReplyQueue, mSleepDuration, uhal::Quote(), uhal::Mmap::File::read(), uhal::exception::exception::throwAsDerivedType(), uhal::ClientInterface::validate(), uhal::Warning, and uhal::exception::exception::what().
Referenced by Flush(), and implementDispatch().
|
private |
Write request packet to next page in host-to-FPGA device file.
Definition at line 441 of file ProtocolMmap.cpp.
References connect(), uhal::Debug, uhal::Mmap::File::getPath(), uhal::Mmap::File::haveLock(), uhal::Info, uhal::Integer(), uhal::Mmap::File::lock(), uhal::log(), mDeviceFile, mIndexNextPage, mIPCExternalSessionActive, mIPCMutex, mIPCSessionCount, mNumberOfPages, mPageSize, mReplyQueue, uhal::Quote(), and uhal::Mmap::File::write().
Referenced by implementDispatch().
|
private |
Definition at line 190 of file ProtocolMmap.hpp.
Referenced by connect(), disconnect(), getMaxReplySize(), getMaxSendSize(), and implementDispatch().
|
private |
Definition at line 192 of file ProtocolMmap.hpp.
Referenced by connect(), disconnect(), dispatchExceptionHandler(), Flush(), Mmap(), read(), and write().
|
private |
Definition at line 200 of file ProtocolMmap.hpp.
|
private |
Definition at line 195 of file ProtocolMmap.hpp.
|
private |
|
private |
Definition at line 196 of file ProtocolMmap.hpp.
|
private |
Definition at line 200 of file ProtocolMmap.hpp.
|
private |
Definition at line 200 of file ProtocolMmap.hpp.
Referenced by connect(), getMaxReplySize(), getMaxSendSize(), and Mmap().
|
private |
Definition at line 200 of file ProtocolMmap.hpp.
Referenced by connect(), implementDispatch(), read(), and write().
|
private |
Definition at line 200 of file ProtocolMmap.hpp.
|
private |
Definition at line 200 of file ProtocolMmap.hpp.
|
private |
Definition at line 200 of file ProtocolMmap.hpp.
|
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().
|
private |
Definition at line 198 of file ProtocolMmap.hpp.