Server
Server is the RC QP receive server. It inherits Core for the
ibverbs resources and inherits rogue::interfaces::stream::Master and
rogue::interfaces::stream::Slave so it participates in the Rogue stream
graph. A background thread polls the completion queue and re-posts receive
work requests as downstream consumers release frames (zero-copy slab).
For conceptual guidance, see RoCEv2 Protocol.
Threading and Lifecycle
The constructor allocates the slab, MR, CQ, and RC QP and transitions the QP to
INIT. It does not spawn the background poll thread.The receive thread is started by
completeConnection()once the FPGA QPN is known and the QP has been moved toRTR/RTS. It is stopped bystop()or the destructor.The poll thread holds
rogue::GilReleaseacross blocking ibverbs calls.IBV_WC_WR_FLUSH_ERRexits the thread cleanly instead of spin-looping.An ibverbs failure inside
postRecvWr()is caught inside the poll thread; the thread logs the error and exits cleanly instead of escaping the thread entry point and triggeringstd::terminate.
Python binding
This C++ class is also exported into Python as
rogue.protocols.rocev2.Server.
Python API page:
Class Reference
-
class rogue::protocols::rocev2::Server : public rogue::protocols::rocev2::Core, public rogue::interfaces::stream::Master, public rogue::interfaces::stream::Slave
RC Queue Pair receive server. Owns the Completion Queue (CQ), Queue Pair (QP, type
IBV_QPT_RC), and Memory Region (MR), runs the RX completion-queue polling thread, and re-posts receive work requests as frames are returned by downstream consumers (zero-copy slab).-
static std::shared_ptr<Server> create(const std::string &deviceName, uint8_t ibPort, uint8_t gidIndex, uint32_t maxPayload = 9000, uint32_t rxQueueDepth = 256)
Factory method. Returns a shared pointer to a new
Server.- Parameters:
deviceName – ibverbs device name (e.g.
rxe0,mlx5_0)ibPort – ibverbs port number (almost always
1)gidIndex – GID table index for the host NIC’s RoCEv2 entry
maxPayload – maximum bytes per RDMA WRITE (default: 9000)
rxQueueDepth – number of pre-posted receive slots (default: 256)
- Returns:
ServerPtr(shared pointer to the new server)
-
Server(const std::string &deviceName, uint8_t ibPort, uint8_t gidIndex, uint32_t maxPayload, uint32_t rxQueueDepth)
Constructor. Allocates the slab memory region, registers it with the HCA, creates the CQ and RC QP, and transitions the QP to
INIT. The receive thread is not started here — it is spawned later bycompleteConnection()after the FPGA QPN is known. Throwsrogue::GeneralErroron ibverbs failures; partial-init resources are released before the throw propagates.
-
~Server()
Calls
stop();stop()releases the slab MR and CQ/QP resources, and the inheritedCoredestructor releases the PD and ibverbs context.
-
void stop()
Signals the receive thread to exit, joins and deletes it, then releases the ibverbs resources owned by
Server: destroys the QP and CQ, deregisters the MR, and frees the slab. Idempotent — safe to call multiple times (also called by~Server()).
-
void setFpgaGid(const std::string &gidBytes)
- Parameters:
gidBytes – 16-byte FPGA GID (IPv4-mapped IPv6) as a raw byte string
MUST be called before
completeConnection().
-
void completeConnection(uint32_t fpgaQpn, uint32_t fpgaRqPsn, uint32_t pmtu = 5, uint32_t minRnrTimer = 1)
Transitions the QP from
INITtoRTRand thenRTSusing the FPGA’s QPN and RQ PSN.- Parameters:
fpgaQpn – FPGA QP number (24-bit)
fpgaRqPsn – FPGA receive-queue starting PSN
pmtu – Path MTU enum (1=256, 2=512, 3=1024, 4=2048, 5=4096; default: 5)
minRnrTimer – IB-spec RNR timer code (1=0.01ms, 14=1ms, 18=4ms, 22=16ms, 31=491ms; default: 1)
-
uint32_t getQpn() const
- Returns:
Host RC QP number (24-bit).
-
std::string getGid() const
- Returns:
Host GID as a colon-separated 8-group hex string (NIC RoCEv2 address).
-
uint32_t getRqPsn() const
- Returns:
Host receive-queue starting PSN. The FPGA’s send-queue PSN must match this.
-
uint32_t getSqPsn() const
- Returns:
Host send-queue starting PSN. The FPGA’s receive-queue PSN must match this.
-
uint64_t getMrAddr() const
- Returns:
Host MR virtual base address. The FPGA RDMA-WRITEs at this address.
-
uint32_t getMrRkey() const
- Returns:
Host MR rkey. Hand this to the FPGA so it can target the host MR.
-
uint64_t getFrameCount() const
- Returns:
Total frames received since construction.
-
uint64_t getByteCount() const
- Returns:
Total bytes received since construction.
-
void acceptFrame(rogue::interfaces::stream::FramePtr frame) override
stream::Slaveoverride. RoCEv2 RX is currently one-directional (FPGA-to-host);acceptFrame()is intentionally a no-op for v1 (TX support is tracked in FUT-01).
-
static void setup_python()
Registers the
rogue.protocols.rocev2.ServerBoost.Python class and inherited-base conversions toCorePtr,MasterPtr, andSlavePtr. Called bymodule.cpp.
-
static std::shared_ptr<Server> create(const std::string &deviceName, uint8_t ibPort, uint8_t gidIndex, uint32_t maxPayload = 9000, uint32_t rxQueueDepth = 256)