Skip to navigation

hololink::module::RoceReceiverInterfaceV1

View as Markdown

Controller that manages data reception via RoCE packets.

This is usually driven by e.g. RoceReceiverOp and serves to set up the host for RDMA data reception, configure the HSB device for compatible data transmission, and provides a routine that observes received data indications and queues those up for application reception.

#include <hololink/module/roce_receiver.hpp>

Inherits from: hololink::module::ConfigurableService< RoceReceiverInterfaceV1 > (public)


Methods

start

virtual hololink_module_status_t hololink::module::RoceReceiverInterfaceV1::start(
const std::string &ibv_name,
unsigned ibv_port,
uint64_t cu_buffer,
size_t cu_buffer_size,
size_t cu_frame_size,
size_t cu_page_size,
unsigned pages,
size_t metadata_offset,
const std::string &peer_ip,
unsigned queue_size
)

Configure the receiver and network adapter for RDMA.

Frames are delivered into cu_buffer, which is a single contiguous region with enough space to accommodate the total number of frames indicated by the pages parameter; each frame is cu_page_size bytes apart; cu_page_size needs to include space for received frame metadata (and its alignment).

Returns: HOLOLINK_MODULE_OK or an error status.

Throws: std::runtime_error if the receiver cannot be brought up, for example the named device is not found or peer_ip is not a valid address.

Parameters

ibv_name
const std::string &

Name of the InfiniBand verbs device of the network adapter that receives the frames, e.g. “roceP5p3s0f0”.

ibv_port
unsigned

Port of that device to use.

cu_buffer
uint64_t

CUDA memory frames are delivered into, as a CUdeviceptr.

cu_buffer_size
size_t

Bytes available at cu_buffer.

cu_frame_size
size_t

Bytes of frame data expected for each received data frame: the HSB device is programmed to trigger an end-of-frame when this many bytes are received; but an earlier TLAST signal will trigger end-of-frame at an earlier point.

cu_page_size
size_t

Bytes from one page to the next.

pages
unsigned

Pages the device cycles through.

metadata_offset
size_t

Offset, in bytes from the start of a page, of the metadata block the device writes after the frame data.

peer_ip
const std::string &

IPv4 address of the device, in dotted-decimal form. The receiver accepts data only from this address.

queue_size
unsigned

Completed frames the receiver holds while the application is busy with an earlier one. When a frame completes with this many already waiting, the oldest waiting frame is discarded (see RoceReceiverFrameInfoV1::dropped).

close

virtual void hololink::module::RoceReceiverInterfaceV1::close()

End the run, returning blocking_monitor() to its caller.

Callable from any thread, including while blocking_monitor() runs. Does nothing if the receiver was never started.

blocking_monitor

virtual void hololink::module::RoceReceiverInterfaceV1::blocking_monitor()

Run the receiver until close() is called.

Frames arrive only while this runs, so it gets a thread of its own, and that thread carries the CUDA context the receiver was started with. Clients typically execute this in its own thread.

Throws: std::runtime_error if start() has not been called.

get_next_frame

virtual bool hololink::module::RoceReceiverInterfaceV1::get_next_frame(
unsigned timeout_ms,
)

Take the next completed frame.

Waits up to timeout_ms for a frame. On successful reception of a frame, info is updated with various metadata about the data, which is present at the indicated address within the cu_buffer passed to start. Frames are returned in the order they are received.

Returns: True when a frame was taken; false when the timeout elapsed first.

Throws: std::runtime_error if start() has not been called.

Parameters

timeout_ms
unsigned

How long to wait for a frame, in milliseconds.

info
RoceReceiverFrameInfoV1 &

Describes the frame that was taken.

frames_ready

virtual bool hololink::module::RoceReceiverInterfaceV1::frames_ready()

Returns: False when get_next_frame() will block waiting for a new frame to arrive.

set_frame_ready

virtual void hololink::module::RoceReceiverInterfaceV1::set_frame_ready(
std::function<void()> callback
)

Register a callback run each time a frame becomes available.

An application that cannot afford to wait in get_next_frame() is told from here that a frame is waiting, and takes it when it is ready to. The callback runs on the thread running blocking_monitor(). Register it before that starts; pass an empty std::function to stop being called. It stays registered across calls to start().

Parameters

callback
std::function<void()>

Run once per frame that becomes available.

get_qp_number

virtual uint32_t hololink::module::RoceReceiverInterfaceV1::get_qp_number()

The number of the queue pair that receives this channel’s frames.

The channel programs this into the device so it sends to the right queue pair.

Returns: The number. Only meaningful once start() has run.

Throws: std::runtime_error if start() has not been called.

get_rkey

virtual uint32_t hololink::module::RoceReceiverInterfaceV1::get_rkey()

The key the device presents when it writes a frame into the receiver’s memory.

Returns: The key. Only meaningful once start() has run.

Throws: std::runtime_error if start() has not been called.

external_frame_memory

virtual uint64_t hololink::module::RoceReceiverInterfaceV1::external_frame_memory()

The address, in the device’s view of the receiver’s memory, where the first page begins.

The device addresses page n at this value plus n times page_size(). This is not a CUDA address.

Returns: The address. Only meaningful once start() has run.

Throws: std::runtime_error if start() has not been called.

frame_size

virtual size_t hololink::module::RoceReceiverInterfaceV1::frame_size()

Bytes of frame data the device sends per frame.

Returns: The cu_frame_size start() was given.

page_size

virtual size_t hololink::module::RoceReceiverInterfaceV1::page_size()

Bytes from one page to the next.

Returns: The cu_page_size start() was given.

pages

virtual unsigned hololink::module::RoceReceiverInterfaceV1::pages()

Pages the device cycles through.

Returns: The pages start() was given.

configure

virtual void hololink::module::ConfigurableService<RoceReceiverInterfaceV1>::configure(
)

Use metadata contents to initialize this instance.

This routine is guaranteed to be called the first time a call to get_service(metadata) is called on a specific service instance.

module

std::shared_ptr<Module> hololink::module::ServiceBase::module() const

The Module that this service was published from.

The service holds no strong reference to its Module, so this does not extend the Module’s lifetime.

Returns: The owning Module, or an empty pointer if the service has not been published or its Module no longer exists.


Static methods

get_service

static std::shared_ptr<RoceReceiverInterfaceV1> hololink::module::ConfigurableService<RoceReceiverInterfaceV1>::get_service(
const EnumerationMetadata &metadata,
bool allow_null = false
)

Fetch a service, configured by EnumerationMetadata.

Module usually caches service objects; so when a specific service instance isn’t found, it will be constructed with the current values in EnumerationMetadata. Later calls to get_service are likely to return that cached instance, ignoring changes to any enumeration metadata that aren’t specifically related to service addressing.

Returns: A shared pointer to the requested service (<Derived>).

Throws: std::runtime_error when allow_null==false and the service lookup (or construction) fails.

Parameters

metadata
const EnumerationMetadata &

Addressing and configuration for the service.

allow_null
boolDefaults to false

Use true to return nullptr when the service cannot be resolved; the default false value raises a std::runtime_error.

for_each_type_id

static bool hololink::module::Service<RoceReceiverInterfaceV1>::for_each_type_id(
Callback &&cb
)

Iterate over every type_id supported by this instance.

The callback signature is bool(const char*) — returning false halts the walk; true continues. Iteration is depth-first, so you’ll see the most specific implementation types first.