Skip to content

Commit 1024751

Browse files
committed
examples/zcrx: add forced sync refill
Signed-off-by: Pavel Begunkov <asml.silence@gmail.com>
1 parent bc8dc70 commit 1024751

1 file changed

Lines changed: 8 additions & 1 deletion

File tree

examples/zcrx.c

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ enum {
6969
REQ_TYPE_RX = 2,
7070
};
7171

72+
static int sync_refill;
7273
static int cfg_port = 8000;
7374
static const char *cfg_ifname;
7475
static int cfg_queue_id = -1;
@@ -298,6 +299,11 @@ static void verify_data(char *data, size_t size, unsigned long seq)
298299
}
299300
}
300301

302+
static inline bool need_sync_refill(void)
303+
{
304+
return sync_refill;
305+
}
306+
301307
static inline void fill_rqe(const struct io_uring_cqe *cqe,
302308
struct io_uring_zcrx_rqe *rqe)
303309
{
@@ -331,7 +337,8 @@ static void return_buffer(struct io_uring *ring,
331337
struct io_uring_zcrx_rqe *rqe;
332338
unsigned rq_mask = rq_ring->ring_entries - 1;
333339

334-
if (*rq_ring->ktail - rq_ring->rq_tail == rq_ring->ring_entries) {
340+
if (*rq_ring->ktail - rq_ring->rq_tail == rq_ring->ring_entries ||
341+
need_sync_refill()) {
335342
return_buffer_sync(ring, cqe);
336343
return;
337344
}

0 commit comments

Comments
 (0)