• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /* SPDX-License-Identifier: MIT */
2 /*
3  * Description: test CQ ring sizing
4  */
5 #include <errno.h>
6 #include <stdio.h>
7 #include <unistd.h>
8 #include <stdlib.h>
9 #include <string.h>
10 #include <fcntl.h>
11 
12 #include "liburing.h"
13 
main(int argc,char * argv[])14 int main(int argc, char *argv[])
15 {
16 	struct io_uring_params p;
17 	struct io_uring ring;
18 	int ret;
19 
20 	if (argc > 1)
21 		return 0;
22 
23 	memset(&p, 0, sizeof(p));
24 	p.flags = IORING_SETUP_CQSIZE;
25 	p.cq_entries = 64;
26 
27 	ret = io_uring_queue_init_params(4, &ring, &p);
28 	if (ret) {
29 		if (ret == -EINVAL) {
30 			printf("Skipped, not supported on this kernel\n");
31 			goto done;
32 		}
33 		printf("ring setup failed\n");
34 		return 1;
35 	}
36 
37 	if (p.cq_entries < 64) {
38 		printf("cq entries invalid (%d)\n", p.cq_entries);
39 		goto err;
40 	}
41 	io_uring_queue_exit(&ring);
42 
43 	memset(&p, 0, sizeof(p));
44 	p.flags = IORING_SETUP_CQSIZE;
45 	p.cq_entries = 0;
46 
47 	ret = io_uring_queue_init_params(4, &ring, &p);
48 	if (ret >= 0 || errno != EINVAL) {
49 		printf("zero sized cq ring succeeded\n");
50 		goto err;
51 	}
52 
53 done:
54 	return 0;
55 err:
56 	io_uring_queue_exit(&ring);
57 	return 1;
58 }
59