lcls2
C++ API: public headers of xtcdata, psalg, psdaq and psana
Loading...
Searching...
No Matches
Pds::Eb::EbLfLink Class Reference

One libfabric connection between an event-builder client and server. More...

#include <EbLfLink.hh>

Inherited by Pds::Eb::EbLfCltLink, and Pds::Eb::EbLfSvrLink.

Public Member Functions

 EbLfLink (Fabrics::Endpoint *, const unsigned depth, const unsigned &verbose, volatile uint64_t &pending, volatile uint64_t &posting)
 Wrap the endpoint with depth receive credits, zero the shared pending and posting words and post depth zero-length receives.
 
 ~EbLfLink ()
 Zero the pending and posting words and print a message if fewer than depth credits are posted.
 
int recvU32 (uint32_t *u32, const char *peer, const char *name)
 Wait up to 7 s for one immediate data value and store its low 32 bits in u32.
 
int sendU32 (uint32_t u32, const char *peer, const char *name)
 Send u32 as immediate data with post(); returns 0, or the error after printing a message.
 
int sendMr (Fabrics::MemoryRegion *, const char *peer)
 Send a RemoteAddress built from the memory region (start address, length, key) to the peer as a series of 32-bit immediate data values; returns 0 or a negative error.
 
int recvMr (Fabrics::RemoteAddress &, const char *peer)
 Receive a RemoteAddress into ra as a series of 32-bit immediate data values (as sent by sendMr()), waiting up to 7 s for each; returns 0 or the poll() error.
 
void * lclAdx (size_t offset) const
 Return the local address that is offset bytes from the start of the local memory region.
 
size_t lclOfs (const void *buffer) const
 Return the byte offset of buffer from the start of the local memory region.
 
uintptr_t rmtAdx (size_t offset) const
 Return the remote address that is offset bytes from the start of the remote region.
 
size_t rmtOfs (uintptr_t buffer) const
 Return the byte offset of the remote address buffer from the start of the remote region.
 
Fabrics::Endpoint * endpoint () const
 Return the libfabric endpoint.
 
unsigned id () const
 Return the peer ID received in exchangeId(); (unsigned)-1 before that.
 
const uint64_t & tmoCnt () const
 Return the number of timeouts counted by post() and poll().
 
int post (const void *buf, size_t len, uint64_t immData)
 Send len bytes from buf with immediate data immData using Endpoint::injectdata(), retrying -FI_EAGAIN for up to 300 s.
 
int post (uint64_t immData)
 Send only the immediate data immData; same as post(nullptr, 0, immData).
 
int poll (uint64_t *data)
 Check the receive completion queue once without waiting and re-post the consumed receive.
 
int poll (uint64_t *data, int msTmo)
 Like poll(uint64_t*), but waits up to msTmo milliseconds for a completion.
 
ssize_t postCompRecv (const unsigned count)
 Consume count receive credits, then re-post zero-length receives until depth credits are posted again (on -FI_EAGAIN, retry up to 100000 times with 10 us sleeps).
 

Public Attributes

const unsigned _depth
 Number of receive buffers (credits) to keep posted.
 
unsigned _credits
 Number of receive buffers currently posted.
 

Protected Types

enum  { _BegSync = 0x11111111 , _EndSync = 0x22222222 , _SvrSync = 0x33333333 , _CltSync = 0x44444444 }
 

Protected Attributes

unsigned _id
 
Fabrics::Endpoint * _ep
 
Fabrics::MemoryRegion * _mr
 
Fabrics::RemoteAddress _ra
 
const unsigned & _verbose
 
uint64_t _timedOut
 
volatile uint64_t & _pending
 
volatile uint64_t & _posting
 

Detailed Description

One libfabric connection between an event-builder client and server.

Small values are exchanged as immediate data, a fixed number of zero-length receives (credits) is kept posted, and addresses are translated to and from offsets in the local and remote memory regions.

Member Enumeration Documentation

◆ anonymous enum

anonymous enum
protected
Enumerator
_BegSync 
_EndSync 
_SvrSync 
_CltSync 

Constructor & Destructor Documentation

◆ EbLfLink()

Pds::Eb::EbLfLink::EbLfLink ( Fabrics::Endpoint *  ,
const unsigned  depth,
const unsigned &  verbose,
volatile uint64_t &  pending,
volatile uint64_t &  posting 
)

Wrap the endpoint with depth receive credits, zero the shared pending and posting words and post depth zero-length receives.

The peer ID starts as (unsigned)-1.

◆ ~EbLfLink()

Pds::Eb::EbLfLink::~EbLfLink ( )

Zero the pending and posting words and print a message if fewer than depth credits are posted.

The endpoint is not deleted.

Member Function Documentation

◆ endpoint()

Fabrics::Endpoint * Pds::Eb::EbLfLink::endpoint ( ) const
inline

Return the libfabric endpoint.

◆ id()

unsigned Pds::Eb::EbLfLink::id ( ) const
inline

Return the peer ID received in exchangeId(); (unsigned)-1 before that.

◆ lclAdx()

void * Pds::Eb::EbLfLink::lclAdx ( size_t  offset) const
inline

Return the local address that is offset bytes from the start of the local memory region.

◆ lclOfs()

size_t Pds::Eb::EbLfLink::lclOfs ( const void *  buffer) const
inline

Return the byte offset of buffer from the start of the local memory region.

◆ poll() [1/2]

int Pds::Eb::EbLfLink::poll ( uint64_t *  data)

Check the receive completion queue once without waiting and re-post the consumed receive.

On a completion, store its immediate data in data and return 0; otherwise return -FI_EAGAIN (counted as a timeout), -FI_ENOTCONN if the peer has shut down, or another negative error.

◆ poll() [2/2]

int Pds::Eb::EbLfLink::poll ( uint64_t *  data,
int  msTmo 
)

Like poll(uint64_t*), but waits up to msTmo milliseconds for a completion.

The shared pending word is incremented while waiting.

◆ post() [1/2]

int Pds::Eb::EbLfLink::post ( const void *  buf,
size_t  len,
uint64_t  immData 
)

Send len bytes from buf with immediate data immData using Endpoint::injectdata(), retrying -FI_EAGAIN for up to 300 s.

This peer's bit is set in the posting word while sending. Returns 0 or the last error (a timeout is counted).

◆ post() [2/2]

int Pds::Eb::EbLfLink::post ( uint64_t  immData)
inline

Send only the immediate data immData; same as post(nullptr, 0, immData).

◆ postCompRecv()

ssize_t Pds::Eb::EbLfLink::postCompRecv ( const unsigned  count)

Consume count receive credits, then re-post zero-length receives until depth credits are posted again (on -FI_EAGAIN, retry up to 100000 times with 10 us sleeps).

Returns 0 or a negative error other than -FI_EAGAIN.

◆ recvMr()

int Pds::Eb::EbLfLink::recvMr ( Fabrics::RemoteAddress &  ,
const char *  peer 
)

Receive a RemoteAddress into ra as a series of 32-bit immediate data values (as sent by sendMr()), waiting up to 7 s for each; returns 0 or the poll() error.

◆ recvU32()

int Pds::Eb::EbLfLink::recvU32 ( uint32_t *  u32,
const char *  peer,
const char *  name 
)

Wait up to 7 s for one immediate data value and store its low 32 bits in u32.

Returns 0, or the poll() error after printing a message naming name and peer.

◆ rmtAdx()

uintptr_t Pds::Eb::EbLfLink::rmtAdx ( size_t  offset) const
inline

Return the remote address that is offset bytes from the start of the remote region.

◆ rmtOfs()

size_t Pds::Eb::EbLfLink::rmtOfs ( uintptr_t  buffer) const
inline

Return the byte offset of the remote address buffer from the start of the remote region.

◆ sendMr()

int Pds::Eb::EbLfLink::sendMr ( Fabrics::MemoryRegion *  ,
const char *  peer 
)

Send a RemoteAddress built from the memory region (start address, length, key) to the peer as a series of 32-bit immediate data values; returns 0 or a negative error.

◆ sendU32()

int Pds::Eb::EbLfLink::sendU32 ( uint32_t  u32,
const char *  peer,
const char *  name 
)

Send u32 as immediate data with post(); returns 0, or the error after printing a message.

◆ tmoCnt()

const uint64_t & Pds::Eb::EbLfLink::tmoCnt ( ) const
inline

Return the number of timeouts counted by post() and poll().

Member Data Documentation

◆ _credits

unsigned Pds::Eb::EbLfLink::_credits

Number of receive buffers currently posted.

◆ _depth

const unsigned Pds::Eb::EbLfLink::_depth

Number of receive buffers (credits) to keep posted.

◆ _ep

Fabrics::Endpoint* Pds::Eb::EbLfLink::_ep
protected

◆ _id

unsigned Pds::Eb::EbLfLink::_id
protected

◆ _mr

Fabrics::MemoryRegion* Pds::Eb::EbLfLink::_mr
protected

◆ _pending

volatile uint64_t& Pds::Eb::EbLfLink::_pending
protected

◆ _posting

volatile uint64_t& Pds::Eb::EbLfLink::_posting
protected

◆ _ra

Fabrics::RemoteAddress Pds::Eb::EbLfLink::_ra
protected

◆ _timedOut

uint64_t Pds::Eb::EbLfLink::_timedOut
protected

◆ _verbose

const unsigned& Pds::Eb::EbLfLink::_verbose
protected

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