#ifndef _TFE_ACCEPTOR_KNI_H #define _TFE_ACCEPTOR_KNI_H #ifdef __cpluscplus extern "C" { #endif #include #include // #include "proxy.h" #include "tfe_utils.h" #include "tfe_timestamp.h" #include "tfe_packet_io.h" #include "tfe_session_table.h" /****************************************************************************** * Struct For tap ******************************************************************************/ struct tap_config { int enable_iouring; int enable_debuglog; int ring_size; int buff_size; int flags; int sq_thread_idle; char src_mac[6]; char tap_mac[6]; char tap_c_mac[6]; char tap_s_mac[6]; char tap_device[16]; char tap_c_device[16]; char tap_s_device[16]; int tap_rps_enable; char tap_rps_mask[TFE_SYMBOL_MAX]; struct bpf_ctx *tap_bpf_ctx; }; struct tap_ctx { int tap_s; int tap_c; int tap_fd; struct io_uring_instance *io_uring_fd; struct io_uring_instance *io_uring_c; struct io_uring_instance *io_uring_s; int buff_size; char *buff; }; /****************************************************************************** * Struct For Thread ******************************************************************************/ struct acceptor_thread_ctx { pthread_t tid; int thread_index; struct tap_ctx *tap_ctx; struct session_table *session_table; struct sf_metrics *sf_metrics; struct tap_config *ref_tap_config; struct packet_io *ref_io; struct global_metrics *ref_metrics; struct policy_enforcer *ref_enforcer; struct acceptor_ctx *ref_acceptor_ctx; struct tfe_proxy *ref_proxy; int session_table_need_reset; }; /****************************************************************************** * Struct For Session ******************************************************************************/ struct packet_info { int is_e2i_dir; struct addr_tuple4 tuple4; char *header_data; int header_len; }; struct session_ctx { int policy_ids; uint64_t session_id; char *session_addr; char client_mac[6]; char server_mac[6]; struct packet_info c2s_info; struct packet_info s2c_info; struct metadata *raw_meta_i2e; struct metadata *raw_meta_e2i; struct metadata *ctrl_meta; struct tfe_cmsg *cmsg; struct acceptor_thread_ctx *ref_thread_ctx; }; struct session_ctx *session_ctx_new(); void session_ctx_free(struct session_ctx *ctx); /****************************************************************************** * Struct For KNI ******************************************************************************/ struct acceptor_ctx { int firewall_sids; int sce_sids; int nr_worker_threads; int cpu_affinity_mask[TFE_THREAD_MAX]; cpu_set_t coremask; struct tap_config *config; struct packet_io *io; struct global_metrics *metrics; struct acceptor_thread_ctx work_threads[TFE_THREAD_MAX]; struct tfe_proxy *ref_proxy; }; struct acceptor_ctx *acceptor_ctx_create(const char *profile); void acceptor_ctx_destory(struct acceptor_ctx *ctx); #ifdef __cpluscplus } #endif #endif