μHAL (v2.7.9)
Part of the IPbus software repository
Public Member Functions | Protected Member Functions | Protected Attributes | Private Member Functions | Private Attributes | Friends | List of all members
uhal::ClientInterface Class Referenceabstract

An abstract base class for defining the interface to the various IPbus clients as well as providing the generalized packing functionality. More...

#include <uhal/ClientInterface.hpp>

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

Public Member Functions

virtual ~ClientInterface ()
 Destructor. More...
 
const std::string & id () const
 Return the identifier of the target for this client. More...
 
const std::string & uri () const
 Return the url of the target for this client. More...
 
void dispatch ()
 Method to dispatch all queued transactions, and wait until all corresponding responses have been received. More...
 
void setTimeoutPeriod (const uint32_t &aTimeoutPeriod=0)
 A method to modify the timeout period for any pending or future transactions. More...
 
uint64_t getTimeoutPeriod ()
 A method to retrieve the timeout period currently being used. More...
 
ValHeader write (const uint32_t &aAddr, const uint32_t &aValue)
 Write a single, unmasked word to a register. More...
 
ValHeader write (const uint32_t &aAddr, const uint32_t &aValue, const uint32_t &aMask)
 Write a single, masked word to a register. More...
 
ValHeader writeBlock (const uint32_t &aAddr, const std::vector< uint32_t > &aValues, const defs::BlockReadWriteMode &aMode=defs::INCREMENTAL)
 Write a block of data to a block of registers or a block-write port. More...
 
ValWord< uint32_t > read (const uint32_t &aAddr)
 Read a single, unmasked, unsigned word. More...
 
ValWord< uint32_t > read (const uint32_t &aAddr, const uint32_t &aMask)
 Read a single, masked, unsigned word. More...
 
ValVector< uint32_t > readBlock (const uint32_t &aAddr, const uint32_t &aSize, const defs::BlockReadWriteMode &aMode=defs::INCREMENTAL)
 Read a block of unsigned data from a block of registers or a block-read port. More...
 
ValWord< uint32_t > rmw_bits (const uint32_t &aAddr, const uint32_t &aANDterm, const uint32_t &aORterm)
 Read the value of a register, apply the AND-term, apply the OR-term, set the register to this new value and return a copy of the original value to the user. More...
 
ValWord< uint32_t > rmw_sum (const uint32_t &aAddr, const int32_t &aAddend)
 Read the value of a register, add the addend, set the register to this new value and return a copy of the original value to the user. More...
 

Protected Member Functions

 ClientInterface (const std::string &aId, const URI &aUri, const boost::posix_time::time_duration &aTimeoutPeriod)
 Constructor. More...
 
const boost::posix_time::time_duration & getBoostTimeoutPeriod ()
 A method to retrieve the timeout period currently being used. More...
 
virtual void implementDispatch (boost::shared_ptr< Buffers > aBuffers)=0
 Pure virtual function which actually performs the dispatch operation. More...
 
virtual void Flush ()
 Virtual function to dispatch all buffers and block until all replies are received. More...
 
virtual ValHeader implementBOT ()=0
 Send a byte order transaction. More...
 
virtual ValHeader implementWrite (const uint32_t &aAddr, const uint32_t &aValue)=0
 Write a single, unmasked word to a register. More...
 
virtual ValHeader implementWriteBlock (const uint32_t &aAddr, const std::vector< uint32_t > &aValues, const defs::BlockReadWriteMode &aMode=defs::INCREMENTAL)=0
 Write a block of data to a block of registers or a block-write port. More...
 
virtual ValWord< uint32_t > implementRead (const uint32_t &aAddr, const uint32_t &aMask=defs::NOMASK)=0
 Read a single, masked, unsigned word. More...
 
virtual ValVector< uint32_t > implementReadBlock (const uint32_t &aAddr, const uint32_t &aSize, const defs::BlockReadWriteMode &aMode=defs::INCREMENTAL)=0
 Read a block of unsigned data from a block of registers or a block-read port. More...
 
virtual ValWord< uint32_t > implementRMWbits (const uint32_t &aAddr, const uint32_t &aANDterm, const uint32_t &aORterm)=0
 Read the value of a register, apply the AND-term, apply the OR-term, set the register to this new value and return a copy of the new value to the user. More...
 
virtual ValWord< uint32_t > implementRMWsum (const uint32_t &aAddr, const int32_t &aAddend)=0
 Read the value of a register, add the addend, set the register to this new value and return a copy of the new value to the user. More...
 
virtual void preamble (boost::shared_ptr< Buffers > aBuffers)
 Add a preamble to an IPbus buffer. More...
 
virtual uint32_t getPreambleSize ()
 Return the size of the preamble. More...
 
virtual void predispatch (boost::shared_ptr< Buffers > aBuffers)
 Finalize the buffer before it is transmitted. More...
 
std::pair< ValHeader, _ValHeader_ * > CreateValHeader ()
 Helper function to create a ValHeader object. More...
 
std::pair< ValWord< uint32_t >, _ValWord_< uint32_t > * > CreateValWord (const uint32_t &aValue, const uint32_t &aMask=defs::NOMASK)
 Helper function to create a ValWord object. More...
 
std::pair< ValVector< uint32_t >, _ValVector_< uint32_t > * > CreateValVector (const uint32_t &aSize)
 Helper function to create a ValVector object. More...
 
virtual exception::exceptionvalidate (boost::shared_ptr< Buffers > aBuffers)
 Function which dispatch calls when the reply is received to check that the headers are as expected. More...
 
virtual exception::exceptionvalidate (uint8_t *aSendBufferStart, uint8_t *aSendBufferEnd, std::deque< std::pair< uint8_t *, uint32_t > >::iterator aReplyStartIt, std::deque< std::pair< uint8_t *, uint32_t > >::iterator aReplyEndIt)=0
 Function which the dispatch calls when the reply is received to check that the headers are as expected. More...
 
virtual void dispatchExceptionHandler ()
 Function which is called when an exception is thrown. More...
 
void returnBufferToPool (boost::shared_ptr< Buffers > &aBuffers)
 Function to return a buffer to the buffer pool. More...
 
void returnBufferToPool (std::deque< boost::shared_ptr< Buffers > > &aBuffers)
 Function to return a collection of buffers to the buffer pool. More...
 
void returnBufferToPool (std::vector< boost::shared_ptr< Buffers > > &aBuffers)
 Function to return a collection of buffers to the buffer pool. More...
 
void returnBufferToPool (std::deque< std::vector< boost::shared_ptr< Buffers > > > &aBuffers)
 Function to return a collection of buffers to the buffer pool. More...
 
virtual boost::shared_ptr< BufferscheckBufferSpace (const uint32_t &aSendSize, const uint32_t &aReplySize, uint32_t &aAvailableSendSize, uint32_t &aAvailableReplySize)
 Function which checks the available space in the currently filling buffer against requested send and receive sizes and, if there is insufficient space in the currently filling buffer, then dispatch it and create a new buffer. More...
 
virtual uint32_t getMaxNumberOfBuffers ()=0
 Return the maximum number of packets in flight. More...
 
virtual uint32_t getMaxSendSize ()=0
 Return the maximum size to be sent based on the buffer size in the target. More...
 
virtual uint32_t getMaxReplySize ()=0
 Return the maximum size of reply packet based on the buffer size in the target. More...
 

Protected Attributes

URI mUri
 a struct containing the full URI of the target for this client More...
 
std::string mUriString
 

Private Member Functions

 ClientInterface ()
 Default Constructor. More...
 
 ClientInterface (const ClientInterface &aClientInterface)
 Copy Constructor. More...
 
virtual ClientInterfaceoperator= (const ClientInterface &aClientInterface)
 Assignment operator. More...
 
void updateCurrentBuffers ()
 If the current buffer is null, allocate a buffer from the buffer pool for it If the buffer pool is empty, create 10 new buffers. More...
 
void deleteBuffers ()
 

Private Attributes

boost::mutex mUserSideMutex
 A MutEx lock used to make sure the access functions are thread safe. More...
 
boost::mutex mBufferMutex
 A MutEx lock used to make sure the access to the buffers is thread safe. More...
 
std::deque< boost::shared_ptr< Buffers > > mBuffers
 A memory pool of buffers which will be dispatched. More...
 
boost::shared_ptr< BuffersmCurrentBuffers
 A pointer to a buffer-wrapper object. More...
 
std::string mId
 the identifier of the target for this client More...
 
boost::posix_time::time_duration mTimeoutPeriod
 Timeout period for transactions. More...
 
boost::weak_ptr< NodemNode
 

Friends

class IPbusCore
 
class HwInterface
 
std::string detail::getAddressDescription (const ClientInterface &, const uint32_t, const size_t &)
 

Detailed Description

An abstract base class for defining the interface to the various IPbus clients as well as providing the generalized packing functionality.

Definition at line 99 of file ClientInterface.hpp.

Constructor & Destructor Documentation

◆ ClientInterface() [1/3]

uhal::ClientInterface::ClientInterface ( const std::string &  aId,
const URI aUri,
const boost::posix_time::time_duration &  aTimeoutPeriod 
)
protected

Constructor.

Parameters
aIdthe uinique identifier that the client will be given.
aUria struct containing the full URI of the target.
aTimeoutPeriodthe default timeout period for the protocol

Definition at line 51 of file ClientInterface.cpp.

◆ ClientInterface() [2/3]

uhal::ClientInterface::ClientInterface ( )
private

Default Constructor.

Definition at line 64 of file ClientInterface.cpp.

◆ ClientInterface() [3/3]

uhal::ClientInterface::ClientInterface ( const ClientInterface aClientInterface)
private

Copy Constructor.

Parameters
aClientInterfacea ClientInterface to copy

Definition at line 77 of file ClientInterface.cpp.

◆ ~ClientInterface()

uhal::ClientInterface::~ClientInterface ( )
virtual

Destructor.

Definition at line 101 of file ClientInterface.cpp.

References deleteBuffers().

Member Function Documentation

◆ checkBufferSpace()

boost::shared_ptr< Buffers > uhal::ClientInterface::checkBufferSpace ( const uint32_t &  aSendSize,
const uint32_t &  aReplySize,
uint32_t &  aAvailableSendSize,
uint32_t &  aAvailableReplySize 
)
protectedvirtual

Function which checks the available space in the currently filling buffer against requested send and receive sizes and, if there is insufficient space in the currently filling buffer, then dispatch it and create a new buffer.

Parameters
aSendSizethe amount of data that the current instruction wishes to send
aReplySizethe amount of data that the current instruction expects to receive
aAvailableSendSizereturn the amount of space available for outgoing IPbus packets
aAvailableReplySizereturn the amount of space available for incoming IPbus packets

Definition at line 285 of file ClientInterface.cpp.

References uhal::Debug, dispatchExceptionHandler(), getMaxReplySize(), getMaxSendSize(), implementDispatch(), uhal::log(), mCurrentBuffers, predispatch(), and updateCurrentBuffers().

Referenced by uhal::IPbusCore::implementBOT(), uhal::IPbusCore::implementRead(), uhal::IPbusCore::implementReadBlock(), uhal::IPbusCore::implementReadConfigurationSpace(), uhal::IPbusCore::implementRMWbits(), uhal::IPbusCore::implementRMWsum(), uhal::IPbusCore::implementWrite(), and uhal::IPbusCore::implementWriteBlock().

◆ CreateValHeader()

std::pair< ValHeader, _ValHeader_ * > uhal::ClientInterface::CreateValHeader ( )
protected

Helper function to create a ValHeader object.

Returns
a std::pair containing the ValHeader object and a pointer to the underlying memory object

Definition at line 391 of file ClientInterface.cpp.

References uhal::ValHeader::mMembers.

Referenced by uhal::IPbusCore::implementBOT(), uhal::IPbusCore::implementWrite(), and uhal::IPbusCore::implementWriteBlock().

◆ CreateValVector()

std::pair< ValVector< uint32_t >, _ValVector_< uint32_t > * > uhal::ClientInterface::CreateValVector ( const uint32_t &  aSize)
protected

Helper function to create a ValVector object.

Parameters
aSizethe size of the ValVector
Returns
a std::pair containing the ValVector object and a pointer to the underlying memory object

Definition at line 405 of file ClientInterface.cpp.

References uhal::ValVector< T >::mMembers.

Referenced by uhal::IPbusCore::implementReadBlock().

◆ CreateValWord()

std::pair< ValWord< uint32_t >, _ValWord_< uint32_t > * > uhal::ClientInterface::CreateValWord ( const uint32_t &  aValue,
const uint32_t &  aMask = defs::NOMASK 
)
protected

Helper function to create a ValWord object.

Parameters
aValuean initial value
aMaska bit-mask for selecting a subset of bits in the word
Returns
a std::pair containing the ValWord object and a pointer to the underlying memory object

Definition at line 398 of file ClientInterface.cpp.

References uhal::ValWord< T >::mMembers.

Referenced by uhal::IPbusCore::implementRead(), uhal::IPbusCore::implementReadConfigurationSpace(), uhal::IPbusCore::implementRMWbits(), and uhal::IPbusCore::implementRMWsum().

◆ deleteBuffers()

void uhal::ClientInterface::deleteBuffers ( )
private

Definition at line 368 of file ClientInterface.cpp.

References mBufferMutex, mBuffers, and mCurrentBuffers.

Referenced by dispatchExceptionHandler(), operator=(), and ~ClientInterface().

◆ dispatch()

void uhal::ClientInterface::dispatch ( )

◆ dispatchExceptionHandler()

void uhal::ClientInterface::dispatchExceptionHandler ( )
protectedvirtual

Function which is called when an exception is thrown.

Reimplemented in uhal::IPbus< 2, IPbus_minor >, uhal::IPbusCore, and uhal::IPbus< 1, IPbus_minor >.

Definition at line 385 of file ClientInterface.cpp.

References deleteBuffers().

Referenced by checkBufferSpace(), dispatch(), and uhal::IPbusCore::dispatchExceptionHandler().

◆ Flush()

void uhal::ClientInterface::Flush ( )
protectedvirtual

Virtual function to dispatch all buffers and block until all replies are received.

Definition at line 184 of file ClientInterface.cpp.

Referenced by dispatch().

◆ getBoostTimeoutPeriod()

const boost::posix_time::time_duration & uhal::ClientInterface::getBoostTimeoutPeriod ( )
protected

A method to retrieve the timeout period currently being used.

Warning
NOT protected by user mutex, so only for use from client side (not from user code - hence protected)
Returns
the timeout period currently being used as a boost time_duration

Definition at line 520 of file ClientInterface.cpp.

References mTimeoutPeriod.

◆ getMaxNumberOfBuffers()

virtual uint32_t uhal::ClientInterface::getMaxNumberOfBuffers ( )
protectedpure virtual

Return the maximum number of packets in flight.

Returns
the maximum number of packets in flight

Implemented in uhal::IPbus< 2, IPbus_minor >, uhal::IPbus< 1, IPbus_minor >, and uhal::tests::DummyClient.

◆ getMaxReplySize()

virtual uint32_t uhal::ClientInterface::getMaxReplySize ( )
protectedpure virtual

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

Returns
the maximum size of reply packet

Implemented in uhal::tests::DummyClient.

Referenced by checkBufferSpace().

◆ getMaxSendSize()

virtual uint32_t uhal::ClientInterface::getMaxSendSize ( )
protectedpure virtual

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

Returns
the maximum size to be sent

Implemented in uhal::tests::DummyClient.

Referenced by checkBufferSpace(), and updateCurrentBuffers().

◆ getPreambleSize()

uint32_t uhal::ClientInterface::getPreambleSize ( )
protectedvirtual

Return the size of the preamble.

Reimplemented in uhal::IPbus< 2, IPbus_minor >, and uhal::IPbus< 1, IPbus_minor >.

Definition at line 206 of file ClientInterface.cpp.

◆ getTimeoutPeriod()

uint64_t uhal::ClientInterface::getTimeoutPeriod ( )

A method to retrieve the timeout period currently being used.

Warning
Protected by user mutex, so only for use from user side (not from client code)
Returns
the timeout period currently being used in milliseconds

Definition at line 513 of file ClientInterface.cpp.

References mTimeoutPeriod, and mUserSideMutex.

◆ id()

const std::string & uhal::ClientInterface::id ( ) const

Return the identifier of the target for this client.

Returns
the identifier of the target for this client

Definition at line 106 of file ClientInterface.cpp.

References mId.

◆ implementBOT()

virtual ValHeader uhal::ClientInterface::implementBOT ( )
protectedpure virtual

Send a byte order transaction.

Implemented in uhal::IPbusCore, and uhal::tests::DummyClient.

◆ implementDispatch()

virtual void uhal::ClientInterface::implementDispatch ( boost::shared_ptr< Buffers aBuffers)
protectedpure virtual

Pure virtual function which actually performs the dispatch operation.

Parameters
aBuffersthe buffer to be dispatched

Implemented in uhal::tests::DummyClient.

Referenced by checkBufferSpace(), and dispatch().

◆ implementRead()

virtual ValWord< uint32_t > uhal::ClientInterface::implementRead ( const uint32_t &  aAddr,
const uint32_t &  aMask = defs::NOMASK 
)
protectedpure virtual

Read a single, masked, unsigned word.

Parameters
aAddrthe address of the register to read
aMaskthe mask to apply to the value after reading
Returns
a Validated Memory which wraps the location to which the reply data is to be written

Implemented in uhal::IPbusCore, and uhal::tests::DummyClient.

Referenced by read().

◆ implementReadBlock()

virtual ValVector< uint32_t > uhal::ClientInterface::implementReadBlock ( const uint32_t &  aAddr,
const uint32_t &  aSize,
const defs::BlockReadWriteMode aMode = defs::INCREMENTAL 
)
protectedpure virtual

Read a block of unsigned data from a block of registers or a block-read port.

Parameters
aAddrthe lowest address in the block of registers or the address of the block-read port
aSizethe number of words to read
aModewhether we are reading from a block of registers (INCREMENTAL) or a block-read port (NON_INCREMENTAL)
Returns
a Validated Memory which wraps the location to which the reply data is to be written

Implemented in uhal::IPbusCore, and uhal::tests::DummyClient.

Referenced by readBlock().

◆ implementRMWbits()

virtual ValWord< uint32_t > uhal::ClientInterface::implementRMWbits ( const uint32_t &  aAddr,
const uint32_t &  aANDterm,
const uint32_t &  aORterm 
)
protectedpure virtual

Read the value of a register, apply the AND-term, apply the OR-term, set the register to this new value and return a copy of the new value to the user.

Parameters
aAddrthe address of the register to read, modify, write
aANDtermthe AND-term to apply to existing value in the target register
aORtermthe OR-term to apply to existing value in the target register
Returns
a Validated Memory which wraps the location to which the reply data is to be written

Implemented in uhal::IPbusCore, and uhal::tests::DummyClient.

Referenced by rmw_bits(), and write().

◆ implementRMWsum()

virtual ValWord< uint32_t > uhal::ClientInterface::implementRMWsum ( const uint32_t &  aAddr,
const int32_t &  aAddend 
)
protectedpure virtual

Read the value of a register, add the addend, set the register to this new value and return a copy of the new value to the user.

Parameters
aAddrthe address of the register to read, modify, write
aAddendthe addend to add to the existing value in the target register
Returns
a Validated Memory which wraps the location to which the reply data is to be written

Implemented in uhal::IPbusCore, and uhal::tests::DummyClient.

Referenced by rmw_sum().

◆ implementWrite()

virtual ValHeader uhal::ClientInterface::implementWrite ( const uint32_t &  aAddr,
const uint32_t &  aValue 
)
protectedpure virtual

Write a single, unmasked word to a register.

Parameters
aAddrthe address of the register to write
aValuethe value to write to the register

Implemented in uhal::IPbusCore, and uhal::tests::DummyClient.

Referenced by write().

◆ implementWriteBlock()

virtual ValHeader uhal::ClientInterface::implementWriteBlock ( const uint32_t &  aAddr,
const std::vector< uint32_t > &  aValues,
const defs::BlockReadWriteMode aMode = defs::INCREMENTAL 
)
protectedpure virtual

Write a block of data to a block of registers or a block-write port.

Parameters
aAddrthe address of the register to write
aValuesthe values to write to the registers or a block-write port
aModewhether we are writing to a block of registers (INCREMENTAL) or a block-write port (NON_INCREMENTAL)

Implemented in uhal::IPbusCore, and uhal::tests::DummyClient.

Referenced by writeBlock().

◆ operator=()

ClientInterface & uhal::ClientInterface::operator= ( const ClientInterface aClientInterface)
privatevirtual

Assignment operator.

Parameters
aClientInterfacea ClientInterface to copy
Returns
reference to this object for chained assignment

Definition at line 90 of file ClientInterface.cpp.

References deleteBuffers(), mId, mTimeoutPeriod, mUri, and mUriString.

◆ preamble()

void uhal::ClientInterface::preamble ( boost::shared_ptr< Buffers aBuffers)
protectedvirtual

Add a preamble to an IPbus buffer.

Reimplemented in uhal::IPbus< 2, IPbus_minor >, and uhal::IPbus< 1, IPbus_minor >.

Definition at line 212 of file ClientInterface.cpp.

Referenced by updateCurrentBuffers().

◆ predispatch()

void uhal::ClientInterface::predispatch ( boost::shared_ptr< Buffers aBuffers)
protectedvirtual

Finalize the buffer before it is transmitted.

Parameters
aBuffersthe buffer to finalize before dispatch

Reimplemented in uhal::IPbus< 2, IPbus_minor >, and uhal::IPbus< 1, IPbus_minor >.

Definition at line 216 of file ClientInterface.cpp.

Referenced by checkBufferSpace(), and dispatch().

◆ read() [1/2]

ValWord< uint32_t > uhal::ClientInterface::read ( const uint32_t &  aAddr)

Read a single, unmasked, unsigned word.

Parameters
aAddrthe address of the register to read
Returns
a Validated Memory which wraps the location to which the reply data is to be written

Definition at line 458 of file ClientInterface.cpp.

References implementRead(), and mUserSideMutex.

Referenced by uhal::tests::DummyHardwareFixture< type >::DummyHardwareFixture(), uhal::Node::read(), uhal::tests::UHAL_TESTS_DEFINE_CLIENT_TEST_CASES(), uhal::tests::PerfTester::validation_test_single_write_read(), uhal::tests::PerfTester::validation_test_write_rmwbits_read(), and uhal::tests::PerfTester::validation_test_write_rmwsum_read().

◆ read() [2/2]

ValWord< uint32_t > uhal::ClientInterface::read ( const uint32_t &  aAddr,
const uint32_t &  aMask 
)

Read a single, masked, unsigned word.

Parameters
aAddrthe address of the register to read
aMaskthe mask to apply to the value after reading
Returns
a Validated Memory which wraps the location to which the reply data is to be written

Definition at line 465 of file ClientInterface.cpp.

References implementRead(), and mUserSideMutex.

◆ readBlock()

ValVector< uint32_t > uhal::ClientInterface::readBlock ( const uint32_t &  aAddr,
const uint32_t &  aSize,
const defs::BlockReadWriteMode aMode = defs::INCREMENTAL 
)

Read a block of unsigned data from a block of registers or a block-read port.

Parameters
aAddrthe lowest address in the block of registers or the address of the block-read port
aSizethe number of words to read
aModewhether we are reading from a block of registers (INCREMENTAL) or a block-read port (NON_INCREMENTAL)
Returns
a Validated Memory which wraps the location to which the reply data is to be written

Definition at line 472 of file ClientInterface.cpp.

References implementReadBlock(), and mUserSideMutex.

Referenced by uhal::tests::PerfTester::runValidationTest(), and uhal::tests::PerfTester::validation_test_block_write_read().

◆ returnBufferToPool() [1/4]

void uhal::ClientInterface::returnBufferToPool ( boost::shared_ptr< Buffers > &  aBuffers)
protected

◆ returnBufferToPool() [2/4]

void uhal::ClientInterface::returnBufferToPool ( std::deque< boost::shared_ptr< Buffers > > &  aBuffers)
protected

Function to return a collection of buffers to the buffer pool.

Parameters
aBuffersa collection of shared-pointers to a buffer to be returned to the buffer pool

Definition at line 233 of file ClientInterface.cpp.

References mBufferMutex, and mBuffers.

◆ returnBufferToPool() [3/4]

void uhal::ClientInterface::returnBufferToPool ( std::deque< std::vector< boost::shared_ptr< Buffers > > > &  aBuffers)
protected

Function to return a collection of buffers to the buffer pool.

Parameters
aBuffersa collection of shared-pointers to a buffer to be returned to the buffer pool

Definition at line 265 of file ClientInterface.cpp.

References mBufferMutex, and mBuffers.

◆ returnBufferToPool() [4/4]

void uhal::ClientInterface::returnBufferToPool ( std::vector< boost::shared_ptr< Buffers > > &  aBuffers)
protected

Function to return a collection of buffers to the buffer pool.

Parameters
aBuffersa collection of shared-pointers to a buffer to be returned to the buffer pool

Definition at line 249 of file ClientInterface.cpp.

References mBufferMutex, and mBuffers.

◆ rmw_bits()

ValWord< uint32_t > uhal::ClientInterface::rmw_bits ( const uint32_t &  aAddr,
const uint32_t &  aANDterm,
const uint32_t &  aORterm 
)

Read the value of a register, apply the AND-term, apply the OR-term, set the register to this new value and return a copy of the original value to the user.

Parameters
aAddrthe address of the register to read, modify, write
aANDtermthe AND-term to apply to existing value in the target register
aORtermthe OR-term to apply to existing value in the target register
Returns
a Validated Memory which wraps the location to which the reply data is to be written

Definition at line 481 of file ClientInterface.cpp.

References implementRMWbits(), and mUserSideMutex.

Referenced by uhal::tests::PerfTester::runValidationTest(), uhal::tests::UHAL_TESTS_DEFINE_CLIENT_TEST_CASES(), and uhal::tests::PerfTester::validation_test_write_rmwbits_read().

◆ rmw_sum()

ValWord< uint32_t > uhal::ClientInterface::rmw_sum ( const uint32_t &  aAddr,
const int32_t &  aAddend 
)

Read the value of a register, add the addend, set the register to this new value and return a copy of the original value to the user.

Parameters
aAddrthe address of the register to read, modify, write
aAddendthe addend to add to the existing value in the target register
Returns
a Validated Memory which wraps the location to which the reply data is to be written

Definition at line 490 of file ClientInterface.cpp.

References implementRMWsum(), and mUserSideMutex.

Referenced by uhal::tests::PerfTester::runValidationTest(), and uhal::tests::PerfTester::validation_test_write_rmwsum_read().

◆ setTimeoutPeriod()

void uhal::ClientInterface::setTimeoutPeriod ( const uint32_t &  aTimeoutPeriod = 0)

A method to modify the timeout period for any pending or future transactions.

Warning
Protected by user mutex, so only for use from user side (not from client code)
Parameters
aTimeoutPeriodthe desired timeout period in milliseconds

Definition at line 498 of file ClientInterface.cpp.

References mTimeoutPeriod, and mUserSideMutex.

◆ updateCurrentBuffers()

void uhal::ClientInterface::updateCurrentBuffers ( )
private

If the current buffer is null, allocate a buffer from the buffer pool for it If the buffer pool is empty, create 10 new buffers.

Definition at line 344 of file ClientInterface.cpp.

References getMaxSendSize(), mBufferMutex, mBuffers, mCurrentBuffers, and preamble().

Referenced by checkBufferSpace().

◆ uri()

const std::string & uhal::ClientInterface::uri ( ) const

◆ validate() [1/2]

exception::exception * uhal::ClientInterface::validate ( boost::shared_ptr< Buffers aBuffers)
protectedvirtual

Function which dispatch calls when the reply is received to check that the headers are as expected.

Parameters
aBuffersthe buffer to validate when it is propagated with replies
Returns
whether the returned packet is valid

Definition at line 188 of file ClientInterface.cpp.

References returnBufferToPool().

Referenced by uhal::Mmap::read(), uhal::PCIe::read(), uhal::TCP< InnerProtocol, nr_buffers_per_send >::read_callback(), and uhal::UDP< InnerProtocol >::read_callback().

◆ validate() [2/2]

virtual exception::exception* uhal::ClientInterface::validate ( uint8_t *  aSendBufferStart,
uint8_t *  aSendBufferEnd,
std::deque< std::pair< uint8_t *, uint32_t > >::iterator  aReplyStartIt,
std::deque< std::pair< uint8_t *, uint32_t > >::iterator  aReplyEndIt 
)
protectedpure virtual

Function which the dispatch calls when the reply is received to check that the headers are as expected.

Parameters
aSendBufferStarta pointer to the start of the first word of IPbus data which was sent (i.e. with no preamble)
aSendBufferEnda pointer to the end of the last word of IPbus data which was sent
aReplyStartItan iterator to the start of the list of memory locations in to which the reply was written
aReplyEndItan iterator to the end (one past last valid entry) of the list of memory locations in to which the reply was written
Returns
whether the returned IPbus packet is valid

Implemented in uhal::IPbus< 2, IPbus_minor >, uhal::IPbusCore, and uhal::tests::DummyClient.

◆ write() [1/2]

ValHeader uhal::ClientInterface::write ( const uint32_t &  aAddr,
const uint32_t &  aValue 
)

Write a single, unmasked word to a register.

Parameters
aAddrthe address of the register to write
aValuethe value to write to the register

Definition at line 413 of file ClientInterface.cpp.

References implementWrite(), and mUserSideMutex.

Referenced by uhal::tests::UHAL_TESTS_DEFINE_CLIENT_TEST_CASES(), uhal::tests::PerfTester::validation_test_single_write_read(), uhal::tests::PerfTester::validation_test_write_rmwbits_read(), uhal::tests::PerfTester::validation_test_write_rmwsum_read(), and uhal::Node::write().

◆ write() [2/2]

ValHeader uhal::ClientInterface::write ( const uint32_t &  aAddr,
const uint32_t &  aValue,
const uint32_t &  aMask 
)

Write a single, masked word to a register.

Parameters
aAddrthe address of the register to write
aValuethe value to write to the register
aMaskthe mask to apply to the value

Definition at line 420 of file ClientInterface.cpp.

References implementRMWbits(), uhal::Integer(), uhal::log(), mUserSideMutex, and uhal::utilities::TrailingRightBits().

◆ writeBlock()

ValHeader uhal::ClientInterface::writeBlock ( const uint32_t &  aAddr,
const std::vector< uint32_t > &  aValues,
const defs::BlockReadWriteMode aMode = defs::INCREMENTAL 
)

Write a block of data to a block of registers or a block-write port.

Parameters
aAddrthe address of the register to write
aValuesthe values to write to the registers or a block-write port
aModewhether we are writing to a block of registers (INCREMENTAL) or a block-write port (NON_INCREMENTAL)

Definition at line 449 of file ClientInterface.cpp.

References implementWriteBlock(), and mUserSideMutex.

Referenced by uhal::tests::PerfTester::runValidationTest(), and uhal::tests::PerfTester::validation_test_block_write_read().

Friends And Related Function Documentation

◆ detail::getAddressDescription

std::string detail::getAddressDescription ( const ClientInterface ,
const uint32_t  ,
const size_t &   
)
friend

◆ HwInterface

friend class HwInterface
friend

Definition at line 418 of file ClientInterface.hpp.

◆ IPbusCore

friend class IPbusCore
friend

Definition at line 417 of file ClientInterface.hpp.

Member Data Documentation

◆ mBufferMutex

boost::mutex uhal::ClientInterface::mBufferMutex
private

A MutEx lock used to make sure the access to the buffers is thread safe.

Definition at line 396 of file ClientInterface.hpp.

Referenced by deleteBuffers(), dispatch(), returnBufferToPool(), and updateCurrentBuffers().

◆ mBuffers

std::deque< boost::shared_ptr< Buffers > > uhal::ClientInterface::mBuffers
private

A memory pool of buffers which will be dispatched.

Definition at line 399 of file ClientInterface.hpp.

Referenced by deleteBuffers(), returnBufferToPool(), and updateCurrentBuffers().

◆ mCurrentBuffers

boost::shared_ptr< Buffers > uhal::ClientInterface::mCurrentBuffers
private

A pointer to a buffer-wrapper object.

Definition at line 407 of file ClientInterface.hpp.

Referenced by checkBufferSpace(), deleteBuffers(), dispatch(), and updateCurrentBuffers().

◆ mId

std::string uhal::ClientInterface::mId
private

the identifier of the target for this client

Definition at line 410 of file ClientInterface.hpp.

Referenced by id(), and operator=().

◆ mNode

boost::weak_ptr<Node> uhal::ClientInterface::mNode
private

Definition at line 415 of file ClientInterface.hpp.

Referenced by uhal::detail::getAddressDescription().

◆ mTimeoutPeriod

boost::posix_time::time_duration uhal::ClientInterface::mTimeoutPeriod
private

Timeout period for transactions.

Definition at line 413 of file ClientInterface.hpp.

Referenced by getBoostTimeoutPeriod(), getTimeoutPeriod(), operator=(), and setTimeoutPeriod().

◆ mUri

URI uhal::ClientInterface::mUri
protected

a struct containing the full URI of the target for this client

Definition at line 424 of file ClientInterface.hpp.

Referenced by operator=().

◆ mUriString

std::string uhal::ClientInterface::mUriString
protected

Definition at line 426 of file ClientInterface.hpp.

Referenced by operator=(), and uri().

◆ mUserSideMutex

boost::mutex uhal::ClientInterface::mUserSideMutex
private

A MutEx lock used to make sure the access functions are thread safe.

Definition at line 393 of file ClientInterface.hpp.

Referenced by dispatch(), getTimeoutPeriod(), read(), readBlock(), uhal::IPbusCore::readConfigurationSpace(), rmw_bits(), rmw_sum(), setTimeoutPeriod(), write(), and writeBlock().


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