μ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::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
 

Public Member Functions

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

Private Types

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

Private Member Functions

 PCIe (const PCIe &aPCIe)
 
PCIeoperator= (const PCIe &aPCIe)
 
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 mDeviceFileHostToFPGA
 Host-to-FPGA device file. More...
 
File mDeviceFileFPGAToHost
 FPGA-to-host device file. More...
 
File mDeviceFileFPGAEvent
 FPGA-to-host interrupt (event) file. More...
 
detail::SharedObject< detail::RobustSessionMutexmIPCMutex
 
bool mIPCExternalSessionActive
 
uint64_t mIPCSessionCount
 
bool mXdma7seriesWorkaround
 
bool mUseInterrupt
 
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 PCIe.

Definition at line 79 of file ProtocolPCIe.hpp.

Member Typedef Documentation

◆ InnerProtocol

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

Definition at line 152 of file ProtocolPCIe.hpp.

◆ SteadyClock_t

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

Definition at line 154 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 315 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(), and uhal::Warning.

◆ ~PCIe()

uhal::PCIe::~PCIe ( )
virtual

Destructor.

Definition at line 379 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 443 of file ProtocolPCIe.cpp.

References connect(), and mIPCMutex.

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

◆ connect() [2/2]

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

◆ disconnect()

void uhal::PCIe::disconnect ( )
private

Close the connection to the device.

Definition at line 501 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 411 of file ProtocolPCIe.cpp.

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

◆ 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 398 of file ProtocolPCIe.cpp.

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

◆ 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 434 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 425 of file ProtocolPCIe.cpp.

References connect(), mConnected, and mMaxPacketSize.

◆ getSharedMemName()

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

Definition at line 306 of file ProtocolPCIe.cpp.

◆ implementDispatch()

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

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

◆ operator=()

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

◆ read()

void uhal::PCIe::read ( )
private

◆ write()

void uhal::PCIe::write ( const std::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 190 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 188 of file ProtocolPCIe.hpp.

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

◆ mDeviceFileHostToFPGA

File uhal::PCIe::mDeviceFileHostToFPGA
private

Host-to-FPGA device file.

Definition at line 186 of file ProtocolPCIe.hpp.

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

◆ mIndexNextPage

uint32_t uhal::PCIe::mIndexNextPage
private

Definition at line 202 of file ProtocolPCIe.hpp.

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

◆ mIPCExternalSessionActive

bool uhal::PCIe::mIPCExternalSessionActive
private

Definition at line 193 of file ProtocolPCIe.hpp.

Referenced by connect(), and write().

◆ mIPCMutex

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

Definition at line 192 of file ProtocolPCIe.hpp.

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

◆ mIPCSessionCount

uint64_t uhal::PCIe::mIPCSessionCount
private

Definition at line 194 of file ProtocolPCIe.hpp.

Referenced by connect(), and write().

◆ mMaxInFlight

uint32_t uhal::PCIe::mMaxInFlight
private

Definition at line 202 of file ProtocolPCIe.hpp.

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

◆ mMaxPacketSize

uint32_t uhal::PCIe::mMaxPacketSize
private

Definition at line 202 of file ProtocolPCIe.hpp.

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

◆ mNumberOfPages

uint32_t uhal::PCIe::mNumberOfPages
private

Definition at line 202 of file ProtocolPCIe.hpp.

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

◆ mPageSize

uint32_t uhal::PCIe::mPageSize
private

Definition at line 202 of file ProtocolPCIe.hpp.

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

◆ mPublishedReplyPageCount

uint32_t uhal::PCIe::mPublishedReplyPageCount
private

Definition at line 202 of file ProtocolPCIe.hpp.

Referenced by connect(), and read().

◆ mReadReplyPageCount

uint32_t uhal::PCIe::mReadReplyPageCount
private

Definition at line 202 of file ProtocolPCIe.hpp.

Referenced by connect(), and read().

◆ mReplyQueue

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

The list of buffers still awaiting a reply.

Definition at line 205 of file ProtocolPCIe.hpp.

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

◆ mSleepDuration

std::chrono::microseconds uhal::PCIe::mSleepDuration
private

Definition at line 200 of file ProtocolPCIe.hpp.

Referenced by PCIe(), and read().

◆ mUseInterrupt

bool uhal::PCIe::mUseInterrupt
private

Definition at line 198 of file ProtocolPCIe.hpp.

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

◆ mXdma7seriesWorkaround

bool uhal::PCIe::mXdma7seriesWorkaround
private

Definition at line 196 of file ProtocolPCIe.hpp.

Referenced by PCIe(), and read().


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