@@ -12,21 +12,55 @@ namespace condy {
1212
1313class ZeroCopyRxBufferPool ;
1414
15+ /* *
16+ * @brief Buffer from a ZeroCopyRxBufferPool.
17+ * @details This buffer type is used for buffers obtained from a
18+ * ZeroCopyRxBufferPool. It automatically returns the buffer to the pool when it
19+ * is out of scope.
20+ * @note The lifetime of the buffer must not exceed the lifetime of the
21+ * ZeroCopyRxBufferPool it is associated with.
22+ */
1523using ZeroCopyRxBuffer = detail::ManagedBuffer<ZeroCopyRxBufferPool>;
1624
25+ /* *
26+ * @brief Area for zero-copy receive buffers.
27+ */
1728struct ZeroCopyRxArea {
1829 void *addr = nullptr ;
1930 size_t size;
2031};
2132
33+ /* *
34+ * @brief Area for zero-copy receive buffers using DMA-BUF.
35+ */
2236struct ZeroCopyRxDMABufArea {
2337 int dmabuf_fd;
2438 size_t offset;
2539 size_t size;
2640};
2741
42+ /* *
43+ * @brief Buffer pool for zero-copy receive buffers.
44+ * @details This buffer pool utilizes the io_uring zcrx feature to provide
45+ * zero-copy receive buffers. It can be used to receive data directly into
46+ * user-space buffers without copying, which can improve performance for
47+ * high-throughput network applications.
48+ * @returns std::pair<int32_t, ZeroCopyRxBuffer> When passed to async
49+ * operations, the return type will be a pair of the operation result and the
50+ * @ref ZeroCopyRxBuffer.
51+ * @note The lifetime of this pool must not exceed the running period of the
52+ * associated Runtime, and the lifetime of any ZeroCopyRxBuffer obtained from
53+ * this pool must not exceed the lifetime of this pool.
54+ */
2855class ZeroCopyRxBufferPool {
2956public:
57+ /* *
58+ * @brief Construct a new Zero Copy Rx Buffer Pool object
59+ * @param if_idx Network interface index to register the buffer pool with.
60+ * @param if_rxq Receive queue index to register the buffer pool with.
61+ * @param rq_entries Number of receive queue entries.
62+ * @param area Area for zero-copy receive buffers.
63+ */
3064 ZeroCopyRxBufferPool (uint32_t if_idx, uint32_t if_rxq, uint32_t rq_entries,
3165 const ZeroCopyRxArea &area)
3266 : ZeroCopyRxBufferPool(if_idx, if_rxq, rq_entries, area, 0 ) {}
@@ -38,6 +72,13 @@ class ZeroCopyRxBufferPool {
3872 device_less_ = true ;
3973 }
4074
75+ /* *
76+ * @brief Construct a new Zero Copy Rx Buffer Pool object
77+ * @param if_idx Network interface index to register the buffer pool with.
78+ * @param if_rxq Receive queue index to register the buffer pool with.
79+ * @param rq_entries Number of receive queue entries.
80+ * @param area Area for zero-copy receive buffers using DMA-BUF.
81+ */
4182 ZeroCopyRxBufferPool (uint32_t if_idx, uint32_t if_rxq, uint32_t rq_entries,
4283 const ZeroCopyRxDMABufArea &area) {
4384 area_size_ = 0 ;
0 commit comments