| 89 | } |
| 90 | |
| 91 | static int setup_context(struct ctx *ctx) |
| 92 | { |
| 93 | struct io_uring_params params; |
| 94 | int ret; |
| 95 | |
| 96 | memset(¶ms, 0, sizeof(params)); |
| 97 | params.cq_entries = QD * 8; |
| 98 | params.flags = IORING_SETUP_SUBMIT_ALL | IORING_SETUP_COOP_TASKRUN | |
| 99 | IORING_SETUP_CQSIZE; |
| 100 | |
| 101 | ret = io_uring_queue_init_params(QD, &ctx->ring, ¶ms); |
| 102 | if (ret < 0) { |
| 103 | fprintf(stderr, "queue_init failed: %s\n" |
| 104 | "NB: This requires a kernel version >= 6.0\n", |
| 105 | strerror(-ret)); |
| 106 | return ret; |
| 107 | } |
| 108 | |
| 109 | ret = setup_buffer_pool(ctx); |
| 110 | if (ret) |
| 111 | io_uring_queue_exit(&ctx->ring); |
| 112 | |
| 113 | memset(&ctx->msg, 0, sizeof(ctx->msg)); |
| 114 | ctx->msg.msg_namelen = sizeof(struct sockaddr_storage); |
| 115 | ctx->msg.msg_controllen = CONTROLLEN; |
| 116 | return ret; |
| 117 | } |
| 118 | |
| 119 | static int setup_sock(int af, int port) |
| 120 | { |
no test coverage detected