Skip to content

Commit fcdbaf9

Browse files
authored
Add transport connection ID accessors
Signed-off-by: Cliff Burdick <cburdick@nvidia.com>
1 parent ff3c15a commit fcdbaf9

9 files changed

Lines changed: 123 additions & 69 deletions

File tree

docs/api-guide.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -314,6 +314,15 @@ if (daqiri::is_tx_burst_available(burst)) {
314314
}
315315
```
316316

317+
For connection-oriented transports such as TCP socket mode, attach the connection ID before
318+
sending when you need to target a specific peer. RX bursts from those transports can be
319+
inspected with the matching getter:
320+
321+
```cpp
322+
daqiri::set_connection_id(burst, conn_id);
323+
auto rx_conn_id = daqiri::get_connection_id(rx_burst);
324+
```
325+
317326
### Step 2: Fill packets
318327
319328
Use the header helper functions for standard UDP packets:

docs/daqiri-api.html

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,7 @@
198198
<div class="sb-group-label">Receive (RX)</div>
199199
<a href="#get-rx-burst" class="sb-link">get_rx_burst <span class="lb lb-fn">fn</span></a>
200200
<a href="#get-num-packets" class="sb-link">get_num_packets <span class="lb lb-fn">fn</span></a>
201+
<a href="#connection-id" class="sb-link">connection ID <span class="lb lb-fn">fn</span></a>
201202
<a href="#get-packet-ptr" class="sb-link">get_packet_ptr <span class="lb lb-fn">fn</span></a>
202203
<a href="#get-packet-length" class="sb-link">get_packet_length <span class="lb lb-fn">fn</span></a>
203204
<a href="#get-packet-flow-id" class="sb-link">get_packet_flow_id <span class="lb lb-fn">fn</span></a>
@@ -327,6 +328,20 @@ <h4 style="color:var(--text-pri);margin-bottom:.5rem;">Segments</h4>
327328
</div>
328329
</div>
329330

331+
<div class="method-card" id="connection-id">
332+
<div class="method-hdr" onclick="toggleMethod(this)">
333+
<span class="m-tag mt-fn">fn</span>
334+
<span class="m-name">set_connection_id / get_connection_id</span>
335+
<span class="m-params">(burst, conn_id?)</span>
336+
<span class="m-expand"></span>
337+
</div>
338+
<div class="method-body">
339+
<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>
340+
<pre>daqiri::<span class="fn">set_connection_id</span>(burst, conn_id);
341+
uintptr_t rx_conn_id = daqiri::<span class="fn">get_connection_id</span>(rx_burst);</pre>
342+
</div>
343+
</div>
344+
330345
<div class="method-card" id="get-packet-ptr">
331346
<div class="method-hdr" onclick="toggleMethod(this)">
332347
<span class="m-tag mt-fn">fn</span>

examples/socket_bench.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,8 +105,7 @@ void socket_worker(const SocketBenchConfig& cfg, std::atomic<bool>& stop, Socket
105105
std::memset(payload, static_cast<int>(stats.sent_packets & 0xff), cfg.message_size);
106106
daqiri::set_packet_lengths(msg, 0, {cfg.message_size});
107107

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

111110
if (daqiri::send_tx_burst(msg) == daqiri::Status::SUCCESS) {
112111
stats.sent_packets++;

include/daqiri/common.h

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -537,6 +537,21 @@ int64_t get_num_packets(BurstParams *burst);
537537
*/
538538
int64_t get_q_id(BurstParams *burst);
539539

540+
/**
541+
* @brief Get the transport connection ID associated with a burst
542+
*
543+
* @param burst Burst structure with transport metadata
544+
*/
545+
uintptr_t get_connection_id(const BurstParams *burst);
546+
547+
/**
548+
* @brief Set the transport connection ID associated with a burst
549+
*
550+
* @param burst Burst structure with transport metadata
551+
* @param conn_id Connection ID representing a unique client/server connection
552+
*/
553+
void set_connection_id(BurstParams *burst, uintptr_t conn_id);
554+
540555
/**
541556
* @brief Get mac address of an interface
542557
*

include/daqiri/types.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ enum class RDMAOpCode {
8585

8686
enum class RDMACompletionType { RX, TX, INVALID };
8787

88-
struct AdvNetRdmaBurstHdr {
88+
struct BurstTransportHeader {
8989
uint8_t version;
9090
RDMAOpCode opcode;
9191
Status status;
@@ -142,7 +142,7 @@ struct BurstHeader {
142142
struct BurstParams {
143143
union {
144144
BurstHeader hdr;
145-
AdvNetRdmaBurstHdr rdma_hdr;
145+
BurstTransportHeader transport_hdr;
146146
};
147147

148148
std::array<void**, MAX_NUM_SEGS> pkts;

python/daqiri_common_pybind.cpp

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -448,16 +448,16 @@ void bind_config_types(py::module_ &m) {
448448
.def(py::init<>())
449449
.def_readwrite("hdr", &BurstParams::hdr)
450450
.def_property(
451-
"rdma_conn_id",
452-
[](const BurstParams &burst) { return burst.rdma_hdr.conn_id; },
451+
"connection_id",
452+
[](const BurstParams &burst) { return get_connection_id(&burst); },
453453
[](BurstParams &burst, uintptr_t conn_id) {
454-
burst.rdma_hdr.conn_id = conn_id;
454+
set_connection_id(&burst, conn_id);
455455
})
456456
.def_property(
457457
"rdma_wr_id",
458-
[](const BurstParams &burst) { return burst.rdma_hdr.wr_id; },
458+
[](const BurstParams &burst) { return burst.transport_hdr.wr_id; },
459459
[](BurstParams &burst, uint64_t wr_id) {
460-
burst.rdma_hdr.wr_id = wr_id;
460+
burst.transport_hdr.wr_id = wr_id;
461461
});
462462

463463
py::class_<RDMAConfig>(m, "RDMAConfig")
@@ -728,6 +728,8 @@ PYBIND11_MODULE(_daqiri, m) {
728728
m.def("set_num_packets", &set_num_packets, "burst"_a, "num"_a);
729729
m.def("get_num_packets", &get_num_packets, "burst"_a);
730730
m.def("get_q_id", &get_q_id, "burst"_a);
731+
m.def("set_connection_id", &set_connection_id, "burst"_a, "conn_id"_a);
732+
m.def("get_connection_id", &get_connection_id, "burst"_a);
731733

732734
m.def(
733735
"get_segment_packet_ptr",

src/common.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -243,6 +243,16 @@ int64_t get_q_id(BurstParams* burst) {
243243
return burst->hdr.hdr.q_id;
244244
}
245245

246+
uintptr_t get_connection_id(const BurstParams* burst) {
247+
assert(burst != nullptr && "burst is null");
248+
return burst->transport_hdr.conn_id;
249+
}
250+
251+
void set_connection_id(BurstParams* burst, uintptr_t conn_id) {
252+
assert(burst != nullptr && "burst is null");
253+
burst->transport_hdr.conn_id = conn_id;
254+
}
255+
246256
void set_num_packets(BurstParams* burst, int64_t num) {
247257
assert(burst != nullptr && "burst is null");
248258
burst->hdr.hdr.num_pkts = num;

0 commit comments

Comments
 (0)