You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
> io_uring also supports Zero Copy Rx. Condy will support this feature in the future.
648
-
649
646
### File Registration
650
647
651
648
io_uring allows you to register files with the kernel. Normally, each asynchronous operation increments/decrements the file's reference count, but registering files with the kernel can skip this process and improve performance.
int main() { return condy::sync_wait(co_main()); }
846
843
```
847
844
845
+
### Zero Copy Rx
846
+
847
+
Similar to Zero Copy Tx, io_uring also supports receiving data directly into user-space memory, allowing the NIC to write incoming data without kernel-to-user copies. Condy provides the `condy::ZeroCopyRxBufferPool` type to encapsulate this feature.
848
+
849
+
`condy::ZeroCopyRxBufferPool` manages a set of pre-registered buffers. When used with `condy::async_recv_multishot()`, each received packet is placed into a buffer from the pool, and the coroutine receives a `condy::ZeroCopyRxBuffer` — an RAII type that automatically returns the buffer to the pool when it goes out of scope.
850
+
851
+
Constructing a `condy::ZeroCopyRxBufferPool` requires:
852
+
- A network interface index (`if_idx`) and receive queue index (`if_rxq`).
853
+
- The number of receive queue entries (`rq_entries`).
854
+
- A `condy::ZeroCopyRxArea` describing the memory region, or a `condy::ZeroCopyRxDMABufArea` for DMA-BUF scenarios.
855
+
856
+
> [!NOTE]
857
+
> See https://docs.kernel.org/networking/iou-zcrx.html for more information.
858
+
859
+
The following example demonstrates a echo server using Zero Copy Rx. The structure is similar to the Provided Buffers example above — `condy::ZeroCopyRxBufferPool` and `condy::ProvidedBufferPool` share the same usage pattern with `condy::async_recv_multishot()`.
860
+
861
+
```cpp
862
+
#include<arpa/inet.h>
863
+
#include<condy.hpp>
864
+
865
+
// Background coroutine: handle buffers from the Channel
As mentioned earlier, the `condy::Runtime` type can accept a `condy::RuntimeOptions` object, which contains a series of configurable initialization parameters for `condy::Runtime`. These parameters can be set using chained calls as shown below:
0 commit comments