|
FD.io VPP
v21.10.1-2-g0a485f517
Vector Packet Processing
|
Go to the documentation of this file.
47 if (
cm->chained_ops_handlers[opt] == 0)
49 VNET_CRYPTO_OP_STATUS_FAIL_NO_HANDLER);
51 rv = (
cm->chained_ops_handlers[opt]) (
vm, ops, chunks, n_ops);
55 if (
cm->ops_handlers[opt] == 0)
57 VNET_CRYPTO_OP_STATUS_FAIL_NO_HANDLER);
59 rv = (
cm->ops_handlers[opt]) (
vm, ops, n_ops);
77 for (
i = 0;
i < n_ops;
i++)
81 if (current_op_type != opt || n_op_queue >= op_q_size)
87 current_op_type = opt;
90 op_queue[n_op_queue++] = &ops[
i];
94 op_queue, chunks, n_op_queue);
125 return p -
cm->engines;
181 od =
cm->opt_data +
id;
199 if ((opt =
cm->algs[alg].op_by_type[
i]) != 0)
202 return NULL !=
cm->ops_handlers[opt];
226 cm->ops_handlers[opt] = fn;
240 cm->chained_ops_handlers[opt] = cfn;
292 if (!enqueue_hdl && !dequeue_hdl)
300 cm->enqueue_handlers[opt] = enqueue_hdl;
301 cm->dequeue_handlers[opt] = dequeue_hdl;
308 cm->enqueue_handlers[opt] = enqueue_hdl;
309 cm->dequeue_handlers[opt] = dequeue_hdl;
336 case VNET_CRYPTO_ALG_##n: \
344 case VNET_CRYPTO_ALG_HMAC_##n: \
350 case VNET_CRYPTO_ALG_HASH_##n: \
405 key->index_crypto =
key->index_integ = 0;
415 #define _(c, h, s, k ,d) \
416 if (crypto_alg == VNET_CRYPTO_ALG_##c && \
417 integ_alg == VNET_CRYPTO_ALG_HMAC_##h) \
418 return VNET_CRYPTO_ALG_##c##_##h##_TAG##d;
439 if (linked_alg == ~0)
445 key->index_crypto = index_crypto;
446 key->index_integ = index_integ;
447 key->async_alg = linked_alg;
468 if (is_enable &&
cm->async_refcnt > 0)
474 VLIB_NODE_STATE_INTERRUPT;
477 if (!is_enable &&
cm->async_refcnt == 0)
480 state = VLIB_NODE_STATE_DISABLED;
533 od =
cm->async_opt_data +
id;
580 if (is_enable &&
cm->async_refcnt == 0)
585 VLIB_NODE_STATE_POLLING : VLIB_NODE_STATE_INTERRUPT;
587 if (!is_enable &&
cm->async_refcnt == 1)
590 state = VLIB_NODE_STATE_DISABLED;
602 cm->async_refcnt += 1;
603 else if (
cm->async_refcnt > 0)
604 cm->async_refcnt -= 1;
620 cm->async_refcnt == 0 ?
621 VLIB_NODE_STATE_DISABLED : VLIB_NODE_STATE_INTERRUPT;
626 cm->async_refcnt == 0 ?
627 VLIB_NODE_STATE_DISABLED : VLIB_NODE_STATE_POLLING;
643 return (op <
vec_len (
cm->enqueue_handlers) &&
644 NULL !=
cm->enqueue_handlers[op]);
654 cm->algs[alg].name =
name;
655 cm->opt_data[
eid].alg =
cm->opt_data[did].alg = alg;
656 cm->opt_data[
eid].active_engine_index_simple = ~0;
657 cm->opt_data[did].active_engine_index_simple = ~0;
658 cm->opt_data[
eid].active_engine_index_chained = ~0;
659 cm->opt_data[did].active_engine_index_chained = ~0;
662 eopt = VNET_CRYPTO_OP_TYPE_AEAD_ENCRYPT;
663 dopt = VNET_CRYPTO_OP_TYPE_AEAD_DECRYPT;
667 eopt = VNET_CRYPTO_OP_TYPE_ENCRYPT;
668 dopt = VNET_CRYPTO_OP_TYPE_DECRYPT;
670 cm->opt_data[
eid].type = eopt;
671 cm->opt_data[did].type = dopt;
672 cm->algs[alg].op_by_type[eopt] =
eid;
673 cm->algs[alg].op_by_type[dopt] = did;
682 cm->algs[alg].name =
name;
683 cm->algs[alg].op_by_type[VNET_CRYPTO_OP_TYPE_HASH] =
id;
684 cm->opt_data[
id].alg = alg;
685 cm->opt_data[
id].active_engine_index_simple = ~0;
686 cm->opt_data[
id].active_engine_index_chained = ~0;
687 cm->opt_data[
id].type = VNET_CRYPTO_OP_TYPE_HASH;
696 cm->algs[alg].name =
name;
697 cm->algs[alg].op_by_type[VNET_CRYPTO_OP_TYPE_HMAC] =
id;
698 cm->opt_data[
id].alg = alg;
699 cm->opt_data[
id].active_engine_index_simple = ~0;
700 cm->opt_data[
id].active_engine_index_chained = ~0;
701 cm->opt_data[
id].type = VNET_CRYPTO_OP_TYPE_HMAC;
712 cm->async_algs[alg].name =
name;
713 cm->async_algs[alg].op_by_type[VNET_CRYPTO_ASYNC_OP_TYPE_ENCRYPT] =
eid;
714 cm->async_algs[alg].op_by_type[VNET_CRYPTO_ASYNC_OP_TYPE_DECRYPT] = did;
715 cm->async_opt_data[
eid].type = VNET_CRYPTO_ASYNC_OP_TYPE_ENCRYPT;
716 cm->async_opt_data[
eid].alg = alg;
717 cm->async_opt_data[
eid].active_engine_index_async = ~0;
718 cm->async_opt_data[
eid].active_engine_index_async = ~0;
719 cm->async_opt_data[did].type = VNET_CRYPTO_ASYNC_OP_TYPE_DECRYPT;
720 cm->async_opt_data[did].alg = alg;
721 cm->async_opt_data[did].active_engine_index_async = ~0;
722 cm->async_opt_data[did].active_engine_index_async = ~0;
747 vnet_crypto_init_cipher_data (VNET_CRYPTO_ALG_##n, \
748 VNET_CRYPTO_OP_##n##_ENC, \
749 VNET_CRYPTO_OP_##n##_DEC, s, 0);
753 vnet_crypto_init_cipher_data (VNET_CRYPTO_ALG_##n, \
754 VNET_CRYPTO_OP_##n##_ENC, \
755 VNET_CRYPTO_OP_##n##_DEC, s, 1);
759 vnet_crypto_init_hmac_data (VNET_CRYPTO_ALG_HMAC_##n, \
760 VNET_CRYPTO_OP_##n##_HMAC, "hmac-" s);
764 vnet_crypto_init_hash_data (VNET_CRYPTO_ALG_HASH_##n, \
765 VNET_CRYPTO_OP_##n##_HASH, s);
768 #define _(n, s, k, t, a) \
769 vnet_crypto_init_async_data (VNET_CRYPTO_ALG_##n##_TAG##t##_AAD##a, \
770 VNET_CRYPTO_OP_##n##_TAG##t##_AAD##a##_ENC, \
771 VNET_CRYPTO_OP_##n##_TAG##t##_AAD##a##_DEC, \
775 #define _(c, h, s, k ,d) \
776 vnet_crypto_init_async_data (VNET_CRYPTO_ALG_##c##_##h##_TAG##d, \
777 VNET_CRYPTO_OP_##c##_##h##_TAG##d##_ENC, \
778 VNET_CRYPTO_OP_##c##_##h##_TAG##d##_DEC, \
782 cm->crypto_node_index =
static void vnet_crypto_init_cipher_data(vnet_crypto_alg_t alg, vnet_crypto_op_id_t eid, vnet_crypto_op_id_t did, char *name, u8 is_aead)
vnet_crypto_async_frame_t *() vnet_crypto_frame_dequeue_t(vlib_main_t *vm, u32 *nb_elts_processed, u32 *enqueue_thread_idx)
void vnet_crypto_register_async_handler(vlib_main_t *vm, u32 engine_index, vnet_crypto_async_op_id_t opt, vnet_crypto_frame_enqueue_t *enqueue_hdl, vnet_crypto_frame_dequeue_t *dequeue_hdl)
static u32 vlib_num_workers()
vnet_crypto_async_frame_t * frame_pool
#define foreach_crypto_aead_async_alg
async crypto
#define clib_memcpy(d, s, n)
void vnet_crypto_key_del(vlib_main_t *vm, vnet_crypto_key_index_t index)
#define foreach_crypto_link_async_alg
@ VNET_CRYPTO_ASYNC_OP_N_IDS
@ VNET_CRYPTO_ASYNC_OP_N_TYPES
void vnet_crypto_register_ops_handler(vlib_main_t *vm, u32 engine_index, vnet_crypto_op_id_t opt, vnet_crypto_ops_handler_t *fn)
static void vlib_node_set_state(vlib_main_t *vm, u32 node_index, vlib_node_state_t new_state)
Set node dispatch state.
#define pool_elt_at_index(p, i)
Returns pointer to element at given index.
vnet_crypto_op_status_t status
#define foreach_crypto_hash_alg
#define hash_create_string(elts, value_bytes)
int vnet_crypto_is_set_async_handler(vnet_crypto_async_op_id_t op)
@ VNET_CRYPTO_N_ASYNC_ALGS
void() vnet_crypto_key_handler_t(vlib_main_t *vm, vnet_crypto_key_op_t kop, vnet_crypto_key_index_t idx)
u32 vnet_crypto_key_index_t
#define hash_set_mem(h, key, value)
#define foreach_crypto_hmac_alg
vl_api_tunnel_mode_t mode
void vnet_crypto_register_chained_ops_handler(vlib_main_t *vm, u32 engine_index, vnet_crypto_op_id_t opt, vnet_crypto_chained_ops_handler_t *fn)
#define pool_put(P, E)
Free an object E in pool P.
vlib_main_t * vm
X-connect all packets from the HOST to the PHY.
vl_api_dhcp_client_state_t state
vnet_crypto_async_op_id_t op_by_type[VNET_CRYPTO_ASYNC_OP_N_TYPES]
#define VNET_CRYPTO_ASYNC_DISPATCH_INTERRUPT
static_always_inline u32 vnet_crypto_process_ops_inline(vlib_main_t *vm, vnet_crypto_op_t ops[], vnet_crypto_op_chunk_t *chunks, u32 n_ops)
u32 vnet_crypto_register_engine(vlib_main_t *vm, char *name, int prio, char *desc)
clib_error_t * vnet_crypto_init(vlib_main_t *vm)
#define VNET_CRYPTO_ASYNC_DISPATCH_POLLING
static_always_inline void crypto_set_op_status(vnet_crypto_op_t *ops[], u32 n_ops, int status)
static int vnet_crypto_key_len_check(vnet_crypto_alg_t alg, u16 length)
u32 vnet_crypto_process_ops(vlib_main_t *vm, vnet_crypto_op_t ops[], u32 n_ops)
static void vnet_crypto_init_async_data(vnet_crypto_async_alg_t alg, vnet_crypto_async_op_id_t eid, vnet_crypto_async_op_id_t did, char *name)
#define vec_len(v)
Number of elements in vector (rvalue-only, NULL tolerant)
int() vnet_crypto_frame_enqueue_t(vlib_main_t *vm, vnet_crypto_async_frame_t *frame)
async crypto function handlers
#define CLIB_MEMORY_STORE_BARRIER()
#define vec_add2(V, P, N)
Add N elements to end of vector V, return pointer to new elements in P.
void vnet_crypto_set_async_dispatch_mode(u8 mode)
#define vec_elt_at_index(v, i)
Get vector value at index i checking that i is in bounds.
u32 vnet_crypto_key_add_linked(vlib_main_t *vm, vnet_crypto_key_index_t index_crypto, vnet_crypto_key_index_t index_integ)
Use 2 created keys to generate new key for linked algs (cipher + integ) The returned key index is to ...
u32 vnet_crypto_process_chained_ops(vlib_main_t *vm, vnet_crypto_op_t ops[], vnet_crypto_op_chunk_t *chunks, u32 n_ops)
vnet_crypto_frame_enqueue_t * enqueue_handlers[VNET_CRYPTO_ASYNC_OP_N_IDS]
#define foreach_crypto_aead_alg
#define vec_validate_aligned(V, I, A)
Make sure vector is long enough for given index (no header, specified alignment)
#define static_always_inline
static_always_inline void crypto_set_active_async_engine(vnet_crypto_async_op_data_t *od, vnet_crypto_async_op_id_t id, u32 ei)
u32 active_engine_index_simple
static void vnet_crypto_init_hmac_data(vnet_crypto_alg_t alg, vnet_crypto_op_id_t id, char *name)
void vnet_crypto_register_ops_handler_inline(vlib_main_t *vm, u32 engine_index, vnet_crypto_op_id_t opt, vnet_crypto_ops_handler_t *fn, vnet_crypto_chained_ops_handler_t *cfn)
vnet_feature_config_main_t * cm
void vnet_crypto_request_async_mode(int is_enable)
#define vec_validate(V, I)
Make sure vector is long enough for given index (no header, unspecified alignment)
u32() vnet_crypto_chained_ops_handler_t(vlib_main_t *vm, vnet_crypto_op_t *ops[], vnet_crypto_op_chunk_t *chunks, u32 n_ops)
#define CLIB_CACHE_LINE_BYTES
vnet_crypto_key_handler_t * key_op_handler
vnet_crypto_main_t crypto_main
#define pool_alloc_aligned(P, N, A)
Allocate N more free elements to pool (general version).
int vnet_crypto_is_set_handler(vnet_crypto_alg_t alg)
static void vnet_crypto_init_hash_data(vnet_crypto_alg_t alg, vnet_crypto_op_id_t id, char *name)
#define clib_bitmap_validate(v, n_bits)
u32 active_engine_index_chained
#define hash_get_mem(h, key)
u32 vnet_crypto_key_add(vlib_main_t *vm, vnet_crypto_alg_t alg, u8 *data, u16 length)
#define vec_free(V)
Free vector's memory (no header).
vlib_node_t * vlib_get_node_by_name(vlib_main_t *vm, u8 *name)
#define VNET_CRYPTO_KEY_TYPE_DATA
void vnet_crypto_register_key_handler(vlib_main_t *vm, u32 engine_index, vnet_crypto_key_handler_t *key_handler)
vnet_crypto_op_id_t op_by_type[VNET_CRYPTO_OP_N_TYPES]
#define VLIB_INIT_FUNCTION(x)
static_always_inline void crypto_set_active_engine(vnet_crypto_op_data_t *od, vnet_crypto_op_id_t id, u32 ei, crypto_op_class_type_t oct)
#define vec_foreach(var, vec)
Vector iterator.
static uword vlib_node_add_named_next(vlib_main_t *vm, uword node, char *name)
static vlib_main_t * vlib_get_main_by_index(u32 thread_index)
int vnet_crypto_set_async_handler2(char *alg_name, char *engine)
vnet_crypto_frame_dequeue_t * dequeue_handlers[VNET_CRYPTO_ASYNC_OP_N_IDS]
vnet_crypto_ops_handler_t * ops_handlers[VNET_CRYPTO_N_OP_IDS]
clib_error_t * crypto_dispatch_enable_disable(int is_enable)
clib_memset(h->entries, 0, sizeof(h->entries[0]) *entries)
#define pool_get_zero(P, E)
Allocate an object E from a pool P and zero it.
vnet_crypto_async_op_id_t
clib_error_t *() vlib_init_function_t(struct vlib_main_t *vm)
u32 vnet_crypto_register_post_node(vlib_main_t *vm, char *post_node_name)
async crypto register functions
u32() vnet_crypto_ops_handler_t(vlib_main_t *vm, vnet_crypto_op_t *ops[], u32 n_ops)
#define foreach_crypto_cipher_alg
u32 active_engine_index_async
void vnet_crypto_register_ops_handlers(vlib_main_t *vm, u32 engine_index, vnet_crypto_op_id_t opt, vnet_crypto_ops_handler_t *fn, vnet_crypto_chained_ops_handler_t *cfn)
static vlib_thread_main_t * vlib_get_thread_main()
vnet_crypto_async_alg_t vnet_crypto_link_algs(vnet_crypto_alg_t crypto_alg, vnet_crypto_alg_t integ_alg)
static_always_inline u32 vnet_crypto_process_ops_call_handler(vlib_main_t *vm, vnet_crypto_main_t *cm, vnet_crypto_op_id_t opt, vnet_crypto_op_t *ops[], vnet_crypto_op_chunk_t *chunks, u32 n_ops)
int vnet_crypto_set_handler2(char *alg_name, char *engine, crypto_op_class_type_t oct)
#define VNET_CRYPTO_FRAME_POOL_SIZE
#define VNET_CRYPTO_KEY_TYPE_LINK
static vlib_node_state_t vlib_node_get_state(vlib_main_t *vm, u32 node_index)
Get node dispatch state.
vnet_crypto_chained_ops_handler_t * chained_ops_handlers[VNET_CRYPTO_N_OP_IDS]