TSG-10708 KNI使用io_uring替换read/write以实现I/O加速

* support iouring: 按需动态分配内存
This commit is contained in:
luwenpeng
2022-05-31 17:38:00 +08:00
parent f7ea81dad8
commit 990d8ae173
11 changed files with 441 additions and 39 deletions

View File

@@ -7,6 +7,7 @@
#include <tsg/tsg_statistic.h>
#include "tfe_mgr.h"
#include <tsg/tsg_label.h>
#include "kni_iouring.h"
#define BURST_MAX 1
#define CALLER_SAPP 0
@@ -196,6 +197,9 @@ struct per_thread_handle{
MESA_htable_handle tuple2stream_htable;
MESA_htable_handle traceid2sslinfo_htable;
struct expiry_dablooms_handle *dabloom_handle;
#if (SUPPORT_LIBURING)
struct io_uring_handle *iouring_handle;
#endif
};
struct tuple2stream_htable_value{
@@ -211,6 +215,7 @@ struct security_policy_shunt_tsg_diagnose{
};
struct kni_handle{
struct io_uring_conf iouring_conf;
struct kni_marsio_handle *marsio_handle;
struct bpf_ctx *tap_bpf_ctx;
struct kni_maat_handle *maat_handle;

View File

@@ -0,0 +1,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

View File

@@ -6,7 +6,7 @@ extern "C"
{
#endif
#define TAP_RSS_LOG_TAG "TAP_RSS :"
#define TAP_RSS_LOG_TAG "TAP_RSS: "
struct bpf_ctx;