20 #include <openssl/engine.h> 23 #define MAX_SESSION 4096 24 #define MAX_VECTOR_ASYNC 256 26 #define SSL_ASYNC_INFLIGHT 1 27 #define SSL_ASYNC_PENDING 2 28 #define SSL_ASYNC_READY 3 30 #define EMPTY_STRUCT {0} 64 void (*polling) (void);
65 void (*polling_conf) (void);
79 void (*polling) (void);
80 void (*pre_init) (void);
81 void (*polling_conf) (void);
105 TLS_DBG (2,
"Totally there is %d thread\n", num_threads);
113 for (i = 0; i < num_threads; i++)
129 int i, registered = -1;
134 for (i = 0; i <
ARRAY_LEN (engine_list); i++)
136 if (!strcmp (engine_list[i].engine, engine_name))
149 ENGINE_load_builtin_engines ();
150 ENGINE_load_dynamic ();
151 engine = ENGINE_by_id (engine_name);
160 p = engine_list[registered].
pre_init;
166 if (!ENGINE_set_default_string (engine, algorithm))
169 engine_name, algorithm);
175 if (!ENGINE_set_default (engine, ENGINE_METHOD_ALL))
177 clib_warning (
"Failed to set engine %s to all algorithm",
226 if (*evt_run_tail == event_idx)
245 return ((*evt)->event_index);
259 TLS_DBG (2,
"Set event %d to run\n", event_index);
270 if (*evt_run_tail >= 0)
276 if (*evt_run_head < 0)
292 int *evt_pending_head;
293 u32 thread_id = ctx->c_thread_index;
300 event->handler = handler;
301 event->cb_args.event_index = eidx;
302 event->cb_args.thread_index = thread_id;
304 event->engine_callback.arg = &
event->cb_args;
308 event->next = *evt_pending_head;
309 *evt_pending_head = eidx;
311 return &
event->engine_callback;
320 u32 thread_id = ctx->c_thread_index;
327 event->handler = handler;
328 event->cb_args.event_index = eidx;
329 event->cb_args.thread_index = thread_id;
331 event->engine_callback.arg = &
event->cb_args;
356 (*handler) (
ctx, tls_session);
377 while (*evt_pending >= 0)
379 TLS_DBG (2,
"polling... current head = %d\n", *evt_pending);
381 *evt_pending =
event->next;
384 engine_cb = &
event->engine_callback;
396 ENGINE_ctrl_cmd (om->
engine,
"ENABLE_EXTERNAL_POLLING", 0,
NULL,
NULL, 0);
411 ENGINE_ctrl_cmd (om->
engine,
"SET_INSTANCE_FOR_THREAD", thread_index,
415 TLS_DBG (2,
"set thread %d and instance %d mapping\n", thread_index,
428 ENGINE_ctrl_cmd (om->
engine,
"POLL", 0, &poll_status,
NULL, 0);
445 u8 state = is_en ? VLIB_NODE_STATE_POLLING : VLIB_NODE_STATE_DISABLED;
481 if (*evt_run_head < 0)
486 if (*evt_run_head >= 0)
489 TLS_DBG (2,
"event run = %d\n", *evt_run_head);
492 *evt_run_head =
event->next;
538 .name =
"tls-async-process",
#define vec_validate(V, I)
Make sure vector is long enough for given index (no header, unspecified alignment) ...
openssl_evt_t *** evt_pool
int openssl_evt_free(int event_idx, u8 thread_index)
int tls_async_do_job(int eidx, u32 thread_index)
void openssl_async_node_enable_disable(u8 is_en)
static clib_error_t * tls_async_init(vlib_main_t *vm)
static openssl_evt_t * openssl_evt_get(u32 evt_index)
int(* callback)(void *arg)
static stream_session_t * session_get_from_handle(session_handle_t handle)
#define pool_get(P, E)
Allocate an object E from a pool P (unspecified alignment).
static openssl_evt_t * openssl_evt_get_w_thread(int evt_index, u8 thread_index)
static u32 openssl_evt_alloc(void)
static vlib_node_registration_t tls_async_process_node
(constructor) VLIB_REGISTER_NODE (tls_async_process_node)
memset(h->entries, 0, sizeof(h->entries[0])*entries)
void qat_polling_config()
#define VLIB_INIT_FUNCTION(x)
void session_send_rpc_evt_to_thread(u32 thread_index, void *fp, void *rpc_args)
struct openssl_async_ openssl_async_t
int openssl_engine_register(char *engine_name, char *algorithm)
vhost_vring_state_t state
void openssl_async_polling()
int openssl_async_run(void *evt)
struct _stream_session_t stream_session_t
openssl_async_status_t * status
#define pool_elt_at_index(p, i)
Returns pointer to element at given index.
int tls_resume_from_crypto(int thread_index)
int vpp_add_async_run_event(tls_ctx_t *ctx, openssl_resume_handler *handler)
int openssl_resume_handler(tls_ctx_t *ctx, stream_session_t *tls_session)
void(* polling_conf)(void)
#define foreach_vlib_main(body)
openssl_resume_handler * handler
#define VLIB_REGISTER_NODE(x,...)
static_always_inline uword vlib_get_thread_index(void)
openssl_tls_callback_arg_t cb_args
struct openssl_tls_callback_arg_ openssl_tls_callback_arg_t
#define clib_warning(format, args...)
void evt_pool_init(vlib_main_t *vm)
void event_handler(void *tls_async)
#define pool_put_index(p, i)
Free pool element with given index.
#define SSL_ASYNC_PENDING
static void vlib_node_set_state(vlib_main_t *vm, u32 node_index, vlib_node_state_t new_state)
Set node dispatch state.
static void * clib_mem_alloc(uword size)
openssl_async_t openssl_async_main
struct openssl_async_status_ openssl_async_status_t
tls_ctx_t * openssl_ctx_get_w_thread(u32 ctx_index, u8 thread_index)
struct _vlib_node_registration vlib_node_registration_t
openssl_tls_callback_t * vpp_add_async_pending_event(tls_ctx_t *ctx, openssl_resume_handler *handler)
void(* polling_conf)(void)
static vlib_thread_main_t * vlib_get_thread_main()
openssl_tls_callback_t engine_callback
struct openssl_event_ openssl_evt_t
#define TLS_DBG(_lvl, _fmt, _args...)
static uword tls_async_process(vlib_main_t *vm, vlib_node_runtime_t *rt, vlib_frame_t *f)
static uword pool_elts(void *v)
Number of active elements in a pool.