summaryrefslogtreecommitdiff
path: root/entry/include/kni_iouring.h
blob: 35c5ec0a4100dfb778863ddc6dc39eb677f8e147 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
#ifndef _KNI_IOURING_H_
#define _KNI_IOURING_H_

#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <unistd.h>
#include <arpa/inet.h>

#if (SUPPORT_LIBURING)
#include <liburing.h>
#endif

#ifdef __cplusplus
extern "C"
{
#endif

#define MAX_BATCH_CQE_NUM 128

    struct io_uring_conf
    {
        int enable_iouring;
        int enable_debuglog;

        int ring_size;
        int buff_size;

        int flags;
        int sq_thread_idle; // milliseconds
    };

#if (SUPPORT_LIBURING)
    enum evtype
    {
        EVTYPE_UNKNOWN = 0,
        EVTYPE_READ = 1,
        EVTYPE_WRITE = 2,
    };

    struct user_data
    {
        int sockfd;
        enum evtype type;
        struct iovec vec;
    };

    struct io_uring_handle
    {
        struct io_uring ring;
        struct io_uring_params params;

        int ring_size;
        int buff_size;
    };

    struct user_data *io_uring_user_data_create(int sockfd, enum evtype type, int buff_size);
    void io_uring_user_data_destory(struct user_data *conn);

    struct io_uring_handle *io_uring_handle_create(int ring_size, int buff_size, int flags, int sq_thread_idle);
    void io_uring_handle_destory(struct io_uring_handle *handle);

#endif

#ifdef __cplusplus
}
#endif

#endif