Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions docs/api-guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -312,6 +312,15 @@ if (daqiri::is_tx_burst_available(burst)) {
}
```

For connection-oriented transports such as TCP socket mode, attach the connection ID before
sending when you need to target a specific peer. RX bursts from those transports can be
inspected with the matching getter:

```cpp
daqiri::set_connection_id(burst, conn_id);
auto rx_conn_id = daqiri::get_connection_id(rx_burst);
```

### Step 2: Fill packets

Use the header helper functions for standard UDP packets:
Expand Down
15 changes: 15 additions & 0 deletions docs/daqiri-api.html
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,7 @@
<div class="sb-group-label">Receive (RX)</div>
<a href="#get-rx-burst" class="sb-link">get_rx_burst <span class="lb lb-fn">fn</span></a>
<a href="#get-num-packets" class="sb-link">get_num_packets <span class="lb lb-fn">fn</span></a>
<a href="#connection-id" class="sb-link">connection ID <span class="lb lb-fn">fn</span></a>
<a href="#get-packet-ptr" class="sb-link">get_packet_ptr <span class="lb lb-fn">fn</span></a>
<a href="#get-packet-length" class="sb-link">get_packet_length <span class="lb lb-fn">fn</span></a>
<a href="#get-packet-flow-id" class="sb-link">get_packet_flow_id <span class="lb lb-fn">fn</span></a>
Expand Down Expand Up @@ -328,6 +329,20 @@ <h4 style="color:var(--text-pri);margin-bottom:.5rem;">Segments</h4>
</div>
</div>

<div class="method-card" id="connection-id">
<div class="method-hdr" onclick="toggleMethod(this)">
<span class="m-tag mt-fn">fn</span>
<span class="m-name">set_connection_id / get_connection_id</span>
<span class="m-params">(burst, conn_id?)</span>
<span class="m-expand">▼</span>
</div>
<div class="method-body">
<p class="m-desc">Sets or reads the transport connection ID carried by a burst. Connection-oriented transports use this to select a peer for TX and identify the peer that produced an RX burst.</p>
<pre>daqiri::<span class="fn">set_connection_id</span>(burst, conn_id);
uintptr_t rx_conn_id = daqiri::<span class="fn">get_connection_id</span>(rx_burst);</pre>
</div>
</div>

<div class="method-card" id="get-packet-ptr">
<div class="method-hdr" onclick="toggleMethod(this)">
<span class="m-tag mt-fn">fn</span>
Expand Down
3 changes: 1 addition & 2 deletions examples/socket_bench.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,7 @@ void socket_worker(const SocketBenchConfig& cfg, std::atomic<bool>& stop, Socket
std::memset(payload, static_cast<int>(stats.sent_packets & 0xff), cfg.message_size);
daqiri::set_packet_lengths(msg, 0, {cfg.message_size});

// Socket transport optionally consumes conn_id from the generic burst header.
msg->rdma_hdr.conn_id = conn_id;
daqiri::set_connection_id(msg, conn_id);

if (daqiri::send_tx_burst(msg) == daqiri::Status::SUCCESS) {
stats.sent_packets++;
Expand Down
15 changes: 15 additions & 0 deletions include/daqiri/common.h
Original file line number Diff line number Diff line change
Expand Up @@ -537,6 +537,21 @@ int64_t get_num_packets(BurstParams *burst);
*/
int64_t get_q_id(BurstParams *burst);

/**
* @brief Get the transport connection ID associated with a burst
*
* @param burst Burst structure with transport metadata
*/
uintptr_t get_connection_id(const BurstParams *burst);

/**
* @brief Set the transport connection ID associated with a burst
*
* @param burst Burst structure with transport metadata
* @param conn_id Connection ID representing a unique client/server connection
*/
void set_connection_id(BurstParams *burst, uintptr_t conn_id);

Comment on lines 537 to +554
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Commit references issue #0

The commit title is #0 - Add transport connection ID accessors. GitHub issue numbers start at #1; #0 does not correspond to a real issue. Per CONTRIBUTING.md, an approved issue must exist before coding starts. Please link to the actual tracking issue and update the commit title accordingly (or amend if needed).

Rule Used: Commit titles must use imperative mood and be pref... (source)

/**
* @brief Get mac address of an interface
*
Expand Down
4 changes: 2 additions & 2 deletions include/daqiri/types.h
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ enum class RDMAOpCode {

enum class RDMACompletionType { RX, TX, INVALID };

struct AdvNetRdmaBurstHdr {
struct BurstTransportHeader {
uint8_t version;
RDMAOpCode opcode;
Status status;
Expand Down Expand Up @@ -142,7 +142,7 @@ struct BurstHeader {
struct BurstParams {
union {
BurstHeader hdr;
AdvNetRdmaBurstHdr rdma_hdr;
BurstTransportHeader transport_hdr;
};

std::array<void**, MAX_NUM_SEGS> pkts;
Expand Down
12 changes: 7 additions & 5 deletions python/daqiri_common_pybind.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -448,16 +448,16 @@ void bind_config_types(py::module_ &m) {
.def(py::init<>())
.def_readwrite("hdr", &BurstParams::hdr)
.def_property(
"rdma_conn_id",
[](const BurstParams &burst) { return burst.rdma_hdr.conn_id; },
"connection_id",
[](const BurstParams &burst) { return get_connection_id(&burst); },
[](BurstParams &burst, uintptr_t conn_id) {
burst.rdma_hdr.conn_id = conn_id;
set_connection_id(&burst, conn_id);
})
.def_property(
"rdma_wr_id",
[](const BurstParams &burst) { return burst.rdma_hdr.wr_id; },
[](const BurstParams &burst) { return burst.transport_hdr.wr_id; },
[](BurstParams &burst, uint64_t wr_id) {
burst.rdma_hdr.wr_id = wr_id;
burst.transport_hdr.wr_id = wr_id;
});
Comment on lines 456 to 461
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 rdma_wr_id Python property still uses an RDMA-specific name and bypasses the new accessor pattern

conn_id was correctly genericized to connection_id via the new get_connection_id/set_connection_id accessors, but wr_id still carries the rdma_ prefix in the Python API and directly accesses transport_hdr.wr_id. This leaves the Python binding half-migrated: consumers see connection_id (generic) next to rdma_wr_id (RDMA-specific), and wr_id is the only BurstTransportHeader field still accessed directly from binding code.

Suggested change
.def_property(
"rdma_wr_id",
[](const BurstParams &burst) { return burst.rdma_hdr.wr_id; },
[](const BurstParams &burst) { return burst.transport_hdr.wr_id; },
[](BurstParams &burst, uint64_t wr_id) {
burst.rdma_hdr.wr_id = wr_id;
burst.transport_hdr.wr_id = wr_id;
});
.def_property(
"wr_id",
[](const BurstParams &burst) { return burst.transport_hdr.wr_id; },
[](BurstParams &burst, uint64_t wr_id) {
burst.transport_hdr.wr_id = wr_id;
});


py::class_<RDMAConfig>(m, "RDMAConfig")
Expand Down Expand Up @@ -728,6 +728,8 @@ PYBIND11_MODULE(_daqiri, m) {
m.def("set_num_packets", &set_num_packets, "burst"_a, "num"_a);
m.def("get_num_packets", &get_num_packets, "burst"_a);
m.def("get_q_id", &get_q_id, "burst"_a);
m.def("set_connection_id", &set_connection_id, "burst"_a, "conn_id"_a);
m.def("get_connection_id", &get_connection_id, "burst"_a);

m.def(
"get_segment_packet_ptr",
Expand Down
10 changes: 10 additions & 0 deletions src/common.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,16 @@ int64_t get_q_id(BurstParams* burst) {
return burst->hdr.hdr.q_id;
}

uintptr_t get_connection_id(const BurstParams* burst) {
assert(burst != nullptr && "burst is null");
return burst->transport_hdr.conn_id;
}

void set_connection_id(BurstParams* burst, uintptr_t conn_id) {
assert(burst != nullptr && "burst is null");
burst->transport_hdr.conn_id = conn_id;
}

void set_num_packets(BurstParams* burst, int64_t num) {
assert(burst != nullptr && "burst is null");
burst->hdr.hdr.num_pkts = num;
Expand Down
Loading
Loading