69 lines
1.2 KiB
C
69 lines
1.2 KiB
C
#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 |