11#include <rdma/fabric.h>
37 bool isIdle()
const noexcept;
71 void transferGrain(
Endpoint const& ep, std::uint64_t localIndex, std::uint64_t remoteIndex, std::uint64_t remotePayloadOffset,
123 using State = std::variant<Idle, Activated, Removing, Done>;
165 virtual void transferGrain(std::uint64_t grainIndex, std::uint16_t startSlice, std::uint16_t endSlice)
final;
170 std::uint16_t startSlice, std::uint16_t endSlice)
final;
212 void blockOnCQ(std::chrono::steady_clock::duration timeout);
256 std::unique_ptr<EgressProtocolTemplate>
_proto;
259 std::map<Completion::Token, RDMInitiatorTarget>
_targets{};
Data variant of the completion entry instance.
Error variant of the completion entry instance.
Type to represent a completion entry from a CompletionQueue.
std::uintptr_t Token
A token used to associate a completion entry with an endpoint.
RAII Wrapper around a libfabric endpoint (fi_ep).
std::uintptr_t Id
An id type that can be used to reference this endpoint from completions and events.
Non-owning view of a FabricInfo. Returned when iterating over a FabricInfoList.
Abstract base class for Initiator implementations.
std::variant< Ready, NotReady, Interrupted > MakeProgressResult
A single endpoint within an RDMInitiator.
void handleCompletion(Endpoint &ep, Completion completion)
Handle a completion event for this endpoint.
bool canEvict() const noexcept
Returns true if the target was shut down and can be evicted from the initiator.
void transferGrain(Endpoint const &ep, std::uint64_t localIndex, std::uint64_t remoteIndex, std::uint64_t remotePayloadOffset, SliceRange const &sliceRange)
Post a grain data transfer request to this endpoint.
bool isIdle() const noexcept
Returns true if the endpoint is idle and could be actived.
RDMInitiatorTarget(std::unique_ptr< EgressProtocol > proto, TargetInfo remoteInfo)
Construct a new RDMInitiatorEndpoint object.
bool hasPendingWork() const noexcept
Returns true if there's pending work for this target.
std::variant< Idle, Activated, Removing, Done > State
The various states that the endpoint can be in are stored inside a variant that we move from and then...
void finishRemoval(Endpoint &ep)
Complete the removal once all outstanding writes have completed or RemoveTimeout has elapsed.
void transferSamples(Endpoint const &ep, std::uint64_t headIndex, std::size_t count)
Post a sample data transfer request to this endpoint.
void shutdown(Endpoint &ep)
Stop transfers to this target.
void activate(Endpoint &ep)
Try to activate the endpoint.
std::unique_ptr< EgressProtocol > _proto
static constexpr auto RemoveTimeout
Upper bound for the removing state. A target that disappears may never complete the outstanding write...
std::map< Completion::Token, RDMInitiatorTarget > _targets
virtual void removeTarget(TargetInfo const &remoteTargetInfo) final
Remove a target from the initiator.
std::unique_ptr< EgressProtocolTemplate > _proto
std::map< Endpoint::Id, Completion::Token > _remoteEndpoints
RDMInitiator(Endpoint ep, std::unique_ptr< EgressProtocolTemplate > proto)
Construct a new RDMInitiator object.
Initiator::MakeProgressResult afterProgressResult() const noexcept
Returns true if any of the endpoints contained in this initiator have pending work.
virtual void addTarget(TargetInfo const &remoteTargetInfo) final
Add a target to the initiator.
void processCompletion(Completion completion)
Consume a completion entry.
static constexpr auto ShutdownPollInterval
Sleep time between two queue reads in shutdown().
void blockOnCQ(std::chrono::steady_clock::duration timeout)
Block on the completion queue until a completion arrives or the timeout elapses, then process all ava...
void evictRemovedTargets()
Complete the removal of targets whose outstanding writes have completed, and evict them.
void handleCompletionError(Completion::Error error)
Handle a completion error event.
virtual void transferGrainToTarget(Endpoint::Id targetId, std::uint64_t localIndex, std::uint64_t remoteIndex, std::uint64_t payloadOffset, std::uint16_t startSlice, std::uint16_t endSlice) final
Transfer a grain to a specific target.
virtual Initiator::MakeProgressResult makeProgressBlocking(std::chrono::steady_clock::duration timeout) final
Attempts to progress execution, including connection management and data operations.
static std::unique_ptr< RDMInitiator > setup(mxlFabricsInitiatorConfig const &config, FabricInfoView info, InitiatorSetupOptions const &options={})
Set up a new RDMInitiator.
virtual void transferSamples(std::uint64_t headIndex, std::size_t count) final
Transfer samples to all targets.
void handleCompletionData(Completion::Data data)
Handle a completion data event.
static constexpr auto ShutdownTimeout
Upper bound for shutdown(). It is longer than RDMInitiatorTarget::RemoveTimeout, so that each removal...
void activateIdleEndpoints()
Try to activate any idle endpoints.
RDMInitiatorTarget & findRemoteByEndpoint(Endpoint::Id id)
Find a remote target by its endpoint id.
void drainCQ()
Process completions until the completion queue is empty.
virtual void transferGrain(std::uint64_t grainIndex, std::uint16_t startSlice, std::uint16_t endSlice) final
Transfer a grain to all targets.
virtual Initiator::MakeProgressResult makeProgress() final
Attempts to progress execution, including connection management and data operations.
virtual void shutdown() final
Shut down the initiator gracefully.
void forEachTarget(F &&transfer)
Offer a transfer to every target.
RDMInitiatorTarget & findRemoteByToken(Completion::Token token)
Find a remote target by its completion token.
A SliceRange represents a range of slices within a grain.
struct mxlFabricsInitiatorConfig_t mxlFabricsInitiatorConfig
std::size_t count(uuids::uuid id) const noexcept
Returns the number of writers registered for flow id 'id'.
Provider-independent tuning options for initiator setup.
The endpoint activated state.
The endpoint is done and can be evicted from the initiator.
std::chrono::steady_clock::time_point deadline
TargetInfo contains all the information required by an initiator to operate transfers to the given ta...