μHAL (v2.7.9)
Part of the IPbus software repository
Classes | Public Member Functions | Private Types | Private Member Functions | Static Private Member Functions | Private Attributes | List of all members
uhal::PCIe Class Reference

Transport protocol to transfer an IPbus buffer via PCIe. More...

#include <uhal/ProtocolPCIe.hpp>

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

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_tIPCScopedLock_t
 
typedef IPbus< 2, 0 > InnerProtocol
 
typedef boost::chrono::steady_clock SteadyClock_t
 

Private Member Functions

 PCIe (const PCIe &aPCIe)
 
PCIeoperator= (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_tmIPCMutex
 
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...
 

Detailed Description

Transport protocol to transfer an IPbus buffer via PCIe.

Definition at line 88 of file ProtocolPCIe.hpp.

Member Typedef Documentation

◆ InnerProtocol

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

Definition at line 214 of file ProtocolPCIe.hpp.

◆ IPCMutex_t

Definition at line 181 of file ProtocolPCIe.hpp.

◆ IPCScopedLock_t

typedef boost::unique_lock<IPCMutex_t> uhal::PCIe::IPCScopedLock_t
private

Definition at line 182 of file ProtocolPCIe.hpp.

◆ SteadyClock_t

typedef boost::chrono::steady_clock uhal::PCIe::SteadyClock_t
private

Definition at line 216 of file ProtocolPCIe.hpp.

Constructor & Destructor Documentation

◆ PCIe() [1/2]

uhal::PCIe::PCIe ( 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 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.

◆ ~PCIe()

uhal::PCIe::~PCIe ( )
virtual

Destructor.

Definition at line 536 of file ProtocolPCIe.cpp.

References disconnect().

◆ PCIe() [2/2]

uhal::PCIe::PCIe ( const PCIe aPCIe)
private

Member Function Documentation

◆ connect() [1/2]

void uhal::PCIe::connect ( )
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().

◆ connect() [2/2]

void uhal::PCIe::connect ( IPCScopedLock_t aGuard)
private

◆ disconnect()

void uhal::PCIe::disconnect ( )
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().

◆ dispatchExceptionHandler()

void uhal::PCIe::dispatchExceptionHandler ( )
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.

◆ Flush()

void uhal::PCIe::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 555 of file ProtocolPCIe.cpp.

References uhal::Debug, uhal::log(), mDeviceFileHostToFPGA, mIPCMutex, mReplyQueue, uhal::Quote(), read(), uhal::PCIe::File::unlock(), and uhal::tests::uri.

◆ getMaxReplySize()

uint32_t uhal::PCIe::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 591 of file ProtocolPCIe.cpp.

References connect(), mConnected, and mMaxPacketSize.

◆ getMaxSendSize()

uint32_t uhal::PCIe::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 582 of file ProtocolPCIe.cpp.

References connect(), mConnected, and mMaxPacketSize.

◆ getSharedMemName()

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

Definition at line 463 of file ProtocolPCIe.cpp.

◆ implementDispatch()

void uhal::PCIe::implementDispatch ( boost::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 542 of file ProtocolPCIe.cpp.

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

◆ operator=()

PCIe& uhal::PCIe::operator= ( const PCIe aPCIe)
private

◆ read()

void uhal::PCIe::read ( )
private

◆ write()

void uhal::PCIe::write ( const boost::shared_ptr< Buffers > &  aBuffers)
private

Member Data Documentation

◆ mConnected

bool uhal::PCIe::mConnected
private

◆ mDeviceFileFPGAEvent

File uhal::PCIe::mDeviceFileFPGAEvent
private

FPGA-to-host interrupt (event) file.

Definition at line 252 of file ProtocolPCIe.hpp.

Referenced by connect(), disconnect(), PCIe(), and read().

◆ mDeviceFileFPGAToHost

File uhal::PCIe::mDeviceFileFPGAToHost
private

FPGA-to-host device file.

Definition at line 250 of file ProtocolPCIe.hpp.

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

◆ mDeviceFileHostToFPGA

File uhal::PCIe::mDeviceFileHostToFPGA
private

Host-to-FPGA device file.

Definition at line 248 of file ProtocolPCIe.hpp.

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

◆ mIndexNextPage

uint32_t uhal::PCIe::mIndexNextPage
private

Definition at line 264 of file ProtocolPCIe.hpp.

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

◆ mIPCExternalSessionActive

bool uhal::PCIe::mIPCExternalSessionActive
private

Definition at line 255 of file ProtocolPCIe.hpp.

Referenced by connect(), and write().

◆ mIPCMutex

SharedObject<IPCMutex_t> uhal::PCIe::mIPCMutex
private

Definition at line 254 of file ProtocolPCIe.hpp.

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

◆ mIPCSessionCount

uint64_t uhal::PCIe::mIPCSessionCount
private

Definition at line 256 of file ProtocolPCIe.hpp.

Referenced by connect(), and write().

◆ mMaxInFlight

uint32_t uhal::PCIe::mMaxInFlight
private

Definition at line 264 of file ProtocolPCIe.hpp.

Referenced by connect(), implementDispatch(), and PCIe().

◆ mMaxPacketSize

uint32_t uhal::PCIe::mMaxPacketSize
private

Definition at line 264 of file ProtocolPCIe.hpp.

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

◆ mNumberOfPages

uint32_t uhal::PCIe::mNumberOfPages
private

Definition at line 264 of file ProtocolPCIe.hpp.

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

◆ mPageSize

uint32_t uhal::PCIe::mPageSize
private

Definition at line 264 of file ProtocolPCIe.hpp.

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

◆ mPublishedReplyPageCount

uint32_t uhal::PCIe::mPublishedReplyPageCount
private

Definition at line 264 of file ProtocolPCIe.hpp.

Referenced by connect(), and read().

◆ mReadReplyPageCount

uint32_t uhal::PCIe::mReadReplyPageCount
private

Definition at line 264 of file ProtocolPCIe.hpp.

Referenced by connect(), and read().

◆ mReplyQueue

std::deque< boost::shared_ptr< Buffers > > uhal::PCIe::mReplyQueue
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().

◆ mSleepDuration

boost::chrono::microseconds uhal::PCIe::mSleepDuration
private

Definition at line 262 of file ProtocolPCIe.hpp.

Referenced by PCIe(), and read().

◆ mUseInterrupt

bool uhal::PCIe::mUseInterrupt
private

Definition at line 260 of file ProtocolPCIe.hpp.

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

◆ mXdma7seriesWorkaround

bool uhal::PCIe::mXdma7seriesWorkaround
private

Definition at line 258 of file ProtocolPCIe.hpp.

Referenced by PCIe(), and read().


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