From 294ae64fdb83de975aebda9a6d593a0e26680fd4 Mon Sep 17 00:00:00 2001 From: Pavel Begunkov Date: Thu, 1 Aug 2024 02:50:17 +0100 Subject: [PATCH] zcrx/test: add RQ entries pow2 test Signed-off-by: Pavel Begunkov --- test/zcrx.c | 59 ++++++++++++++++++++++++++--------------------------- 1 file changed, 29 insertions(+), 30 deletions(-) diff --git a/test/zcrx.c b/test/zcrx.c index cab587bdf..9e62a4ec2 100644 --- a/test/zcrx.c +++ b/test/zcrx.c @@ -42,7 +42,7 @@ static int try_register_ifq(struct io_uring_zcrx_ifq_reg *reg) return ret; } -static int test_null_rq_entries_reg_struct(void *area) +static int test_rq_setup(void *area) { int ret; struct io_uring_zcrx_area_reg area_reg = { @@ -60,7 +60,33 @@ static int test_null_rq_entries_reg_struct(void *area) }; ret = try_register_ifq(®); - return ret ? T_EXIT_PASS : T_EXIT_FAIL; + if (ret != -EINVAL) { + fprintf(stderr, "registered 0 rq entries\n"); + return T_EXIT_FAIL; + } + + reg.rq_entries = (__u32)-1; + + ret = try_register_ifq(®); + if (ret != -EINVAL) { + fprintf(stderr, "registered unlimited nr of rq entries\n"); + return T_EXIT_FAIL; + } + + reg.rq_entries = 7; + ret = try_register_ifq(®); + if (ret != 0) { + fprintf(stderr, "ifq registration failed %i\n", ret); + return T_EXIT_FAIL; + } + + if (reg.rq_entries == 7) { + fprintf(stderr, "registered non pow2 refill entries %i\n", + reg.rq_entries); + return T_EXIT_FAIL; + } + + return T_EXIT_PASS; } static int test_null_area_reg_struct(void) @@ -147,27 +173,6 @@ static int test_larger_than_alloc_area(void *area) return ret ? T_EXIT_PASS : T_EXIT_FAIL; } -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, - .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(®); - return ret ? T_EXIT_PASS : T_EXIT_FAIL; -} - static int probe_ring_support(void) { struct io_uring ring; @@ -223,7 +228,7 @@ int main(int argc, char *argv[]) return T_EXIT_FAIL; } - ret = test_null_rq_entries_reg_struct(area); + ret = test_rq_setup(area); if (ret) { fprintf(stderr, "test_invalid_reg_struct failed\n"); return ret; @@ -253,12 +258,6 @@ int main(int argc, char *argv[]) return ret; } - ret = test_invalid_rq(area); - if (ret) { - fprintf(stderr, "test_invalid_rq failed\n"); - return ret; - } - munmap(area, AREA_SZ); return 0; }