Skip to content

Commit

Permalink
zcrx: more types of refill garbage
Browse files Browse the repository at this point in the history
Signed-off-by: Pavel Begunkov <asml.silence@gmail.com>
  • Loading branch information
isilence committed Aug 30, 2024
1 parent 8b3b0a6 commit 6c3fea0
Showing 1 changed file with 31 additions and 10 deletions.
41 changes: 31 additions & 10 deletions test/zcrx.c
Original file line number Diff line number Diff line change
Expand Up @@ -543,28 +543,49 @@ static int recv_prep(struct io_uring *ring, struct recv_data *rd, int *sock)
return 1;
}

static void refill_garbage(struct recv_data *rd)
static struct io_uring_zcrx_rqe* get_refill_entry(struct io_uring_zcrx_rq *rq_ring)
{
unsigned mask = rq_ring->ring_entries - 1;
struct io_uring_zcrx_rqe* rqe;
struct io_uring_zcrx_rq *rq_ring = &rd->rq_ring;

unsigned mask = rq_ring->ring_entries - 1;
rqe = &rq_ring->rqes[(rq_ring->rq_tail & mask)];
rqe->off = 512 * 4096;
rqe->len = 0;
rqe = &rq_ring->rqes[rq_ring->rq_tail & mask];
rq_ring->rq_tail++;
return rqe;
}

static void refill_garbage(struct recv_data *rd, uint64_t area_token)
{
struct io_uring_zcrx_rq *rq_ring = &rd->rq_ring;
struct io_uring_zcrx_rqe* rqe;
int i = 0;

/* invalid area */
rqe = get_refill_entry(rq_ring);
rqe->off = (area_token + 1) << IORING_ZCRX_AREA_SHIFT;
i++;

/* invalid area offset */
rqe = get_refill_entry(rq_ring);
rqe->off = AREA_SZ | (area_token << IORING_ZCRX_AREA_SHIFT);
rqe->off += AREA_SZ;
i++;

for (; i < RQ_ENTRIES; i++) {
rqe = get_refill_entry(rq_ring);
rqe->off = ((uint64_t)1 << IORING_ZCRX_AREA_SHIFT) - 1;
}

io_uring_smp_store_release(rq_ring->ktail, rq_ring->rq_tail);
}

static int do_recv(struct io_uring *ring, struct recv_data *rd)
static int do_recv(struct io_uring *ring, struct recv_data *rd,
uint64_t refill_area_token)
{
struct io_uring_cqe *cqe;
struct io_uring_zcrx_cqe *zcqe;
int i, ret;

for (i = 0; i < RQ_ENTRIES; i++)
refill_garbage(rd);
refill_garbage(rd, refill_area_token);

for (i = 0; i < LOOP_COUNT - 1; i++) {
ret = io_uring_wait_cqe(ring, &cqe);
Expand Down Expand Up @@ -675,7 +696,7 @@ static void *recv_fn(void *data)
fprintf(stderr, "recv_prep failed: %d\n", ret);
goto err;
}
ret = do_recv(&ring, rd);
ret = do_recv(&ring, rd, area_reg.rq_area_token);

close(sock);
close(rd->accept_fd);
Expand Down

0 comments on commit 6c3fea0

Please sign in to comment.