Skip to content

Commit

Permalink
zcrx: rely on the returned refill q size
Browse files Browse the repository at this point in the history
Kernel might decide to change the refill queue size and the user has to
recheck the size returned in struct io_uring_zcrx_ifq_reg::rq_entries.
Use the returned value instead of assuming RQ_ENTRIES.

Signed-off-by: Pavel Begunkov <asml.silence@gmail.com>
  • Loading branch information
isilence committed Aug 30, 2024
1 parent 6c3fea0 commit 19bd3f2
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions test/zcrx.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ static unsigned int ifidx, rxq;
#define AREA_PAGES 132
#define PAGE_SIZE 4096
#define AREA_SZ AREA_PAGES * PAGE_SIZE
#define RQ_ENTRIES 64
#define RQ_ENTRIES 128
/* this is one more than the # of free pages after filling hw rxq */
#define LOOP_COUNT 5
#define DEV_ENV_VAR "NETIF"
Expand All @@ -49,7 +49,7 @@ static int probe_zcrx(void *area)
struct io_uring_zcrx_ifq_reg reg = {
.if_idx = ifidx,
.if_rxq = rxq,
.rq_entries = 8,
.rq_entries = RQ_ENTRIES,
.area_ptr = (__u64)(unsigned long)&area_reg,
};
struct io_uring ring;
Expand Down Expand Up @@ -105,7 +105,7 @@ static int test_invalid_if(void *area)
struct io_uring_zcrx_ifq_reg reg = {
.if_idx = -1,
.if_rxq = rxq,
.rq_entries = 8,
.rq_entries = RQ_ENTRIES,
.area_ptr = (__u64)(unsigned long)&area_reg,
};

Expand Down Expand Up @@ -137,7 +137,7 @@ static int test_invalid_ifq_collision(void *area)
struct io_uring_zcrx_ifq_reg reg = {
.if_idx = ifidx,
.if_rxq = rxq,
.rq_entries = 8,
.rq_entries = RQ_ENTRIES,
.area_ptr = (__u64)(unsigned long)&area_reg,
};
int ret;
Expand Down Expand Up @@ -207,14 +207,14 @@ static int test_rq_setup(void *area)
return T_EXIT_FAIL;
}

reg.rq_entries = 7;
reg.rq_entries = RQ_ENTRIES - 1;
ret = try_register_ifq(&reg);
if (ret != 0) {
fprintf(stderr, "ifq registration failed %i\n", ret);
return T_EXIT_FAIL;
}

if (reg.rq_entries == 7) {
if (reg.rq_entries == RQ_ENTRIES - 1) {
fprintf(stderr, "registered non pow2 refill entries %i\n",
reg.rq_entries);
return T_EXIT_FAIL;
Expand Down Expand Up @@ -570,7 +570,7 @@ static void refill_garbage(struct recv_data *rd, uint64_t area_token)
rqe->off += AREA_SZ;
i++;

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

0 comments on commit 19bd3f2

Please sign in to comment.