Skip to content

Commit

Permalink
test/zcrx: pass required ring flags
Browse files Browse the repository at this point in the history
zcrx requires DEFER_TASKRUN and CQE32, without the features the
registration will always return -EINVAL and skip testing the meat.

Signed-off-by: Pavel Begunkov <asml.silence@gmail.com>
  • Loading branch information
isilence committed Aug 1, 2024
1 parent 22bf876 commit d8cb537
Showing 1 changed file with 24 additions and 26 deletions.
50 changes: 24 additions & 26 deletions test/zcrx.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,16 @@ static unsigned int ifidx, rxq;
#define AREA_SZ 8192
#define DEV_ENV_VAR "NETIF"
#define RXQ_ENV_VAR "NETRXQ"
#define RING_FLAGS (IORING_SETUP_DEFER_TASKRUN | \
IORING_SETUP_CQE32 | \
IORING_SETUP_SINGLE_ISSUER)

static int try_register_ifq(struct io_uring_zcrx_ifq_reg *reg)
{
struct io_uring ring;
int ret;

ret = t_create_ring(8, &ring, 0);
ret = t_create_ring(8, &ring, RING_FLAGS);
if (ret != T_SETUP_OK) {
fprintf(stderr, "ring create failed: %d\n", ret);
exit(T_EXIT_FAIL);
Expand Down Expand Up @@ -144,46 +147,43 @@ static int test_larger_than_alloc_area(void *area)
return ret ? T_EXIT_PASS : T_EXIT_FAIL;
}

static int test_smaller_than_alloc_area(void *area)
static int test_invalid_rq(void *area)
{
int ret;
struct io_uring_zcrx_area_reg area_reg = {
.addr = (__u64)(unsigned long)area,
.len = AREA_SZ - 4096,
.len = AREA_SZ,
.flags = 0,
.area_id = 0,
};

struct io_uring_zcrx_ifq_reg reg = {
.if_idx = ifidx,
.if_rxq = rxq,
.rq_entries = 4096,
.rq_entries = (__u32)-1,
.area_ptr = (__u64)(unsigned long)&area_reg,
};

ret = try_register_ifq(&reg);
return ret ? T_EXIT_PASS : T_EXIT_FAIL;
}

static int test_invalid_rq(void *area)
static int probe_ring_support(void)
{
struct io_uring ring;
int ret;
struct io_uring_zcrx_area_reg area_reg = {
.addr = (__u64)(unsigned long)area,
.len = AREA_SZ,
.flags = 0,
.area_id = 0,
};

struct io_uring_zcrx_ifq_reg reg = {
.if_idx = ifidx,
.if_rxq = rxq,
.rq_entries = (__u32)-1,
.area_ptr = (__u64)(unsigned long)&area_reg,
};

ret = try_register_ifq(&reg);
return ret ? T_EXIT_PASS : T_EXIT_FAIL;
ret = t_create_ring(8, &ring, RING_FLAGS);
io_uring_queue_exit(&ring);
if (ret == -EINVAL) {
printf("Required ring flags are not supported, skip\n");
return T_EXIT_SKIP;
}
if (ret) {
fprintf(stderr, "ring setup failure\n");
return T_EXIT_FAIL;
}
return 0;
}

int main(int argc, char *argv[])
Expand All @@ -195,6 +195,10 @@ int main(int argc, char *argv[])
if (argc > 1)
return 0;

ret = probe_ring_support();
if (ret != T_EXIT_PASS)
return ret;

dev = getenv(DEV_ENV_VAR);
if (!dev)
return T_EXIT_SKIP;
Expand Down Expand Up @@ -249,12 +253,6 @@ int main(int argc, char *argv[])
return ret;
}

ret = test_smaller_than_alloc_area(area);
if (ret) {
fprintf(stderr, "test_smaller_than_alloc_area failed\n");
return ret;
}

ret = test_invalid_rq(area);
if (ret) {
fprintf(stderr, "test_invalid_rq failed\n");
Expand Down

0 comments on commit d8cb537

Please sign in to comment.