Class HeaderBuffer

Nested Relationships

Nested Types

Class Documentation

class HeaderBuffer

Represents a buffer for storing headers for zero-copy sending.

One buffer is allocated for all headers and registered as a single memory region. For each send operation, one slot is returned to fill in the header information. The key corresponding to the slot is saved and can be retrieved in the CQ callback to return to the caller.

The API of the buffer is thread safe.

Public Functions

inline explicit HeaderBuffer(DomainContext &domain)

Constructs a HeaderBuffer object.

The domain is required to keep track of the number of registered MRs per domain.

Parameters:

domain – The domain context

inline HeaderWrapper get_header(const std::span<const std::uint8_t> &data, const std::uint64_t key)

Store data in the buffer and get the corresponding header slot.

Returns status (OK or NO_RESOURCES (no slot left) or FAILED (data larger than slot)), buffer ID and ioc of stored data.

Parameters:
  • data – The data to be stored

  • key – The key assiociated to the send operation

Returns:

The HeaderWrapper containing the header information

inline std::uint64_t return_header(const std::size_t idx)

Returns a slot to the available pool.

After a send is completed, the buffer ID can be exchanged for the key.

Parameters:

idx – The index of the buffer to return

Returns:

The key of the returned header

inline char *get_buffer()

Retrieves the underlying buffer as a char pointer.

Returns:

The underlying buffer as a char pointer

inline std::size_t get_size() const

Retrieves the size of the buffer.

Returns:

The size of the buffer

inline DomainContext &get_domain()

Returns the domain.

Returns:

Domain of the buffer

inline std::size_t get_num_available_buffers()

Retrieves the number of available header buffers.

Returns the mininum number of available buffers since the last call to this function.

Returns:

The number of available buffers

std::vector<std::uint64_t> get_pending_sends()

Retrieves the keys of pending send operations.

Returns:

The keys of pending send operations

Public Members

fid_mr *mr = {nullptr}
struct HeaderWrapper

Wrapper struct for the header information.

Public Members

NetioStatus status = {NetioStatus::OK}

The status of the get_buffer operation.

std::size_t bufnum = {}

The buffer number ID.

iovec data = {}

The data stored in the buffer.