Transport protocol to transfer an IPbus buffer via PCIe. More...
#include <uhal/ProtocolPCIe.hpp>
Classes | |
class | File |
class | PacketFmt |
class | RobustMutex |
class | SharedObject |
Public Member Functions | |
PCIe (const std::string &aId, const URI &aUri) | |
Constructor. More... | |
virtual | ~PCIe () |
Destructor. More... | |
Private Types | |
typedef RobustMutex | IPCMutex_t |
typedef boost::unique_lock< IPCMutex_t > | IPCScopedLock_t |
typedef IPbus< 2, 0 > | InnerProtocol |
typedef boost::chrono::steady_clock | SteadyClock_t |
Private Member Functions | |
PCIe (const PCIe &aPCIe) | |
PCIe & | operator= (const PCIe &aPCIe) |
void | implementDispatch (boost::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 (IPCScopedLock_t &) |
Set up the connection to the device. More... | |
void | disconnect () |
Close the connection to the device. More... | |
void | write (const boost::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 | mDeviceFileHostToFPGA |
Host-to-FPGA device file. More... | |
File | mDeviceFileFPGAToHost |
FPGA-to-host device file. More... | |
File | mDeviceFileFPGAEvent |
FPGA-to-host interrupt (event) file. More... | |
SharedObject< IPCMutex_t > | mIPCMutex |
bool | mIPCExternalSessionActive |
uint64_t | mIPCSessionCount |
bool | mXdma7seriesWorkaround |
bool | mUseInterrupt |
boost::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< boost::shared_ptr< Buffers > > | mReplyQueue |
The list of buffers still awaiting a reply. More... | |
Transport protocol to transfer an IPbus buffer via PCIe.
Definition at line 88 of file ProtocolPCIe.hpp.
|
private |
Definition at line 214 of file ProtocolPCIe.hpp.
|
private |
Definition at line 181 of file ProtocolPCIe.hpp.
|
private |
Definition at line 182 of file ProtocolPCIe.hpp.
|
private |
Definition at line 216 of file ProtocolPCIe.hpp.
uhal::PCIe::PCIe | ( | 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 472 of file ProtocolPCIe.cpp.
References uhal::Info, uhal::log(), uhal::URI::mArguments, mDeviceFileFPGAEvent, uhal::URI::mHostname, mMaxInFlight, mMaxPacketSize, mSleepDuration, mUseInterrupt, mXdma7seriesWorkaround, uhal::Notice, uhal::Quote(), uhal::PCIe::File::setPath(), uhal::tests::uri, and uhal::Warning.
|
virtual |
|
private |
|
private |
Set up the connection to the device.
Definition at line 600 of file ProtocolPCIe.cpp.
References mIPCMutex.
Referenced by getMaxReplySize(), getMaxSendSize(), implementDispatch(), and write().
|
private |
Set up the connection to the device.
Definition at line 607 of file ProtocolPCIe.cpp.
References uhal::PCIe::File::createBuffer(), uhal::Debug, uhal::PCIe::File::getPath(), uhal::PCIe::File::haveLock(), uhal::Info, uhal::Integer(), uhal::log(), mConnected, mDeviceFileFPGAEvent, mDeviceFileFPGAToHost, mDeviceFileHostToFPGA, mIndexNextPage, mIPCExternalSessionActive, mIPCMutex, mIPCSessionCount, mMaxInFlight, mMaxPacketSize, mNumberOfPages, mPageSize, mPublishedReplyPageCount, mReadReplyPageCount, mUseInterrupt, uhal::PCIe::File::open(), uhal::Quote(), and uhal::PCIe::File::read().
|
private |
Close the connection to the device.
Definition at line 658 of file ProtocolPCIe.cpp.
References uhal::PCIe::File::close(), mConnected, mDeviceFileFPGAEvent, mDeviceFileFPGAToHost, and mDeviceFileHostToFPGA.
Referenced by dispatchExceptionHandler(), and ~PCIe().
|
privatevirtual |
Function which tidies up this protocol layer in the event of an exception.
Definition at line 568 of file ProtocolPCIe.cpp.
References disconnect(), uhal::log(), mDeviceFileHostToFPGA, mReplyQueue, uhal::Notice, uhal::Quote(), uhal::ClientInterface::returnBufferToPool(), uhal::PCIe::File::unlock(), and uhal::tests::uri.
|
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 555 of file ProtocolPCIe.cpp.
References uhal::Debug, uhal::log(), mDeviceFileHostToFPGA, mIPCMutex, mReplyQueue, uhal::Quote(), read(), uhal::PCIe::File::unlock(), and uhal::tests::uri.
|
private |
Return the maximum size of reply packet based on the buffer size in the target.
Definition at line 591 of file ProtocolPCIe.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 582 of file ProtocolPCIe.cpp.
References connect(), mConnected, and mMaxPacketSize.
|
staticprivate |
Definition at line 463 of file ProtocolPCIe.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 542 of file ProtocolPCIe.cpp.
References connect(), uhal::Debug, uhal::log(), mConnected, mMaxInFlight, mReplyQueue, uhal::Quote(), read(), uhal::tests::uri, and write().
|
private |
Read next pending reply packet from appropriate page of FPGA-to-host device file, and validate contents.
Definition at line 699 of file ProtocolPCIe.cpp.
References uhal::Debug, uhal::PCIe::File::getPath(), uhal::Info, uhal::Integer(), uhal::log(), mDeviceFileFPGAEvent, mDeviceFileFPGAToHost, mDeviceFileHostToFPGA, uhal::min, mIndexNextPage, mIPCMutex, mNumberOfPages, mPageSize, mPublishedReplyPageCount, mReadReplyPageCount, mReplyQueue, mSleepDuration, mUseInterrupt, mXdma7seriesWorkaround, uhal::Quote(), uhal::PCIe::File::read(), uhal::exception::exception::throwAsDerivedType(), uhal::tests::uri, uhal::ClientInterface::validate(), uhal::Warning, and uhal::exception::exception::what().
Referenced by Flush(), implementDispatch(), and uhal::PCIe::File::read().
|
private |
Write request packet to next page in host-to-FPGA device file.
Definition at line 667 of file ProtocolPCIe.cpp.
References connect(), uhal::Debug, uhal::PCIe::File::getPath(), uhal::PCIe::File::haveLock(), uhal::Info, uhal::Integer(), uhal::PCIe::File::lock(), uhal::log(), mDeviceFileHostToFPGA, mIndexNextPage, mIPCExternalSessionActive, mIPCMutex, mIPCSessionCount, mNumberOfPages, mPageSize, mReplyQueue, uhal::Quote(), uhal::tests::uri, and uhal::PCIe::File::write().
Referenced by implementDispatch(), and uhal::PCIe::File::write().
|
private |
Definition at line 245 of file ProtocolPCIe.hpp.
Referenced by connect(), disconnect(), getMaxReplySize(), getMaxSendSize(), and implementDispatch().
|
private |
FPGA-to-host interrupt (event) file.
Definition at line 252 of file ProtocolPCIe.hpp.
Referenced by connect(), disconnect(), PCIe(), and read().
|
private |
FPGA-to-host device file.
Definition at line 250 of file ProtocolPCIe.hpp.
Referenced by connect(), disconnect(), and read().
|
private |
Host-to-FPGA device file.
Definition at line 248 of file ProtocolPCIe.hpp.
Referenced by connect(), disconnect(), dispatchExceptionHandler(), Flush(), read(), and write().
|
private |
Definition at line 264 of file ProtocolPCIe.hpp.
|
private |
Definition at line 255 of file ProtocolPCIe.hpp.
|
private |
|
private |
Definition at line 256 of file ProtocolPCIe.hpp.
|
private |
Definition at line 264 of file ProtocolPCIe.hpp.
Referenced by connect(), implementDispatch(), and PCIe().
|
private |
Definition at line 264 of file ProtocolPCIe.hpp.
Referenced by connect(), getMaxReplySize(), getMaxSendSize(), and PCIe().
|
private |
Definition at line 264 of file ProtocolPCIe.hpp.
|
private |
Definition at line 264 of file ProtocolPCIe.hpp.
|
private |
Definition at line 264 of file ProtocolPCIe.hpp.
|
private |
Definition at line 264 of file ProtocolPCIe.hpp.
|
private |
The list of buffers still awaiting a reply.
Definition at line 267 of file ProtocolPCIe.hpp.
Referenced by dispatchExceptionHandler(), Flush(), implementDispatch(), read(), and write().
|
private |
Definition at line 262 of file ProtocolPCIe.hpp.
|
private |
Definition at line 260 of file ProtocolPCIe.hpp.
|
private |
Definition at line 258 of file ProtocolPCIe.hpp.