2 * Copyright (c) 2018 Cisco and/or its affiliates.
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at:
7 * http://www.apache.org/licenses/LICENSE-2.0
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
17 #include <vlib/vlib.h>
18 #include <vnet/crypto/crypto.h>
20 vnet_crypto_main_t crypto_main;
22 static_always_inline void
23 crypto_set_op_status (vnet_crypto_op_t * ops[], u32 n_ops, int status)
27 ops[0]->status = status;
32 static_always_inline u32
33 vnet_crypto_process_ops_call_handler (vlib_main_t * vm,
34 vnet_crypto_main_t * cm,
35 vnet_crypto_op_id_t opt,
36 vnet_crypto_op_t * ops[],
37 vnet_crypto_op_chunk_t * chunks,
47 if (cm->chained_ops_handlers[opt] == 0)
48 crypto_set_op_status (ops, n_ops,
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)
56 crypto_set_op_status (ops, n_ops,
57 VNET_CRYPTO_OP_STATUS_FAIL_NO_HANDLER);
59 rv = (cm->ops_handlers[opt]) (vm, ops, n_ops);
64 static_always_inline u32
65 vnet_crypto_process_ops_inline (vlib_main_t * vm, vnet_crypto_op_t ops[],
66 vnet_crypto_op_chunk_t * chunks, u32 n_ops)
68 vnet_crypto_main_t *cm = &crypto_main;
69 const int op_q_size = VLIB_FRAME_SIZE;
70 vnet_crypto_op_t *op_queue[op_q_size];
71 vnet_crypto_op_id_t opt, current_op_type = ~0;
77 for (i = 0; i < n_ops; i++)
81 if (current_op_type != opt || n_op_queue >= op_q_size)
83 rv += vnet_crypto_process_ops_call_handler (vm, cm, current_op_type,
87 current_op_type = opt;
90 op_queue[n_op_queue++] = &ops[i];
93 rv += vnet_crypto_process_ops_call_handler (vm, cm, current_op_type,
94 op_queue, chunks, n_op_queue);
99 vnet_crypto_process_ops (vlib_main_t * vm, vnet_crypto_op_t ops[], u32 n_ops)
101 return vnet_crypto_process_ops_inline (vm, ops, 0, n_ops);
105 vnet_crypto_process_chained_ops (vlib_main_t * vm, vnet_crypto_op_t ops[],
106 vnet_crypto_op_chunk_t * chunks, u32 n_ops)
108 return vnet_crypto_process_ops_inline (vm, ops, chunks, n_ops);
112 vnet_crypto_register_engine (vlib_main_t * vm, char *name, int prio,
115 vnet_crypto_main_t *cm = &crypto_main;
116 vnet_crypto_engine_t *p;
118 vec_add2 (cm->engines, p, 1);
123 hash_set_mem (cm->engine_index_by_name, p->name, p - cm->engines);
125 return p - cm->engines;
128 static_always_inline void
129 crypto_set_active_engine (vnet_crypto_op_data_t * od,
130 vnet_crypto_op_id_t id, u32 ei,
131 crypto_op_class_type_t oct)
133 vnet_crypto_main_t *cm = &crypto_main;
134 vnet_crypto_engine_t *ce = vec_elt_at_index (cm->engines, ei);
136 if (oct == CRYPTO_OP_BOTH || oct == CRYPTO_OP_CHAINED)
138 if (ce->chained_ops_handlers[id])
140 od->active_engine_index_chained = ei;
141 cm->chained_ops_handlers[id] = ce->chained_ops_handlers[id];
145 if (oct == CRYPTO_OP_BOTH || oct == CRYPTO_OP_SIMPLE)
147 if (ce->ops_handlers[id])
149 od->active_engine_index_simple = ei;
150 cm->ops_handlers[id] = ce->ops_handlers[id];
156 vnet_crypto_set_handler2 (char *alg_name, char *engine,
157 crypto_op_class_type_t oct)
160 vnet_crypto_main_t *cm = &crypto_main;
161 vnet_crypto_alg_data_t *ad;
164 p = hash_get_mem (cm->alg_index_by_name, alg_name);
168 ad = vec_elt_at_index (cm->algs, p[0]);
170 p = hash_get_mem (cm->engine_index_by_name, engine);
174 for (i = 0; i < VNET_CRYPTO_OP_N_TYPES; i++)
176 vnet_crypto_op_data_t *od;
177 vnet_crypto_op_id_t id = ad->op_by_type[i];
181 od = cm->opt_data + id;
182 crypto_set_active_engine (od, id, p[0], oct);
189 vnet_crypto_is_set_handler (vnet_crypto_alg_t alg)
191 vnet_crypto_main_t *cm = &crypto_main;
192 vnet_crypto_op_id_t opt = 0;
195 if (alg > vec_len (cm->algs))
198 for (i = 0; i < VNET_CRYPTO_OP_N_TYPES; i++)
199 if ((opt = cm->algs[alg].op_by_type[i]) != 0)
202 return NULL != cm->ops_handlers[opt];
206 vnet_crypto_register_ops_handler_inline (vlib_main_t * vm, u32 engine_index,
207 vnet_crypto_op_id_t opt,
208 vnet_crypto_ops_handler_t * fn,
209 vnet_crypto_chained_ops_handler_t *
212 vnet_crypto_main_t *cm = &crypto_main;
213 vnet_crypto_engine_t *ae, *e = vec_elt_at_index (cm->engines, engine_index);
214 vnet_crypto_op_data_t *otd = cm->opt_data + opt;
215 vec_validate_aligned (cm->ops_handlers, VNET_CRYPTO_N_OP_IDS - 1,
216 CLIB_CACHE_LINE_BYTES);
217 vec_validate_aligned (cm->chained_ops_handlers, VNET_CRYPTO_N_OP_IDS - 1,
218 CLIB_CACHE_LINE_BYTES);
222 e->ops_handlers[opt] = fn;
223 if (otd->active_engine_index_simple == ~0)
225 otd->active_engine_index_simple = engine_index;
226 cm->ops_handlers[opt] = fn;
229 ae = vec_elt_at_index (cm->engines, otd->active_engine_index_simple);
230 if (ae->priority < e->priority)
231 crypto_set_active_engine (otd, opt, engine_index, CRYPTO_OP_SIMPLE);
236 e->chained_ops_handlers[opt] = cfn;
237 if (otd->active_engine_index_chained == ~0)
239 otd->active_engine_index_chained = engine_index;
240 cm->chained_ops_handlers[opt] = cfn;
243 ae = vec_elt_at_index (cm->engines, otd->active_engine_index_chained);
244 if (ae->priority < e->priority)
245 crypto_set_active_engine (otd, opt, engine_index, CRYPTO_OP_CHAINED);
252 vnet_crypto_register_ops_handler (vlib_main_t * vm, u32 engine_index,
253 vnet_crypto_op_id_t opt,
254 vnet_crypto_ops_handler_t * fn)
256 vnet_crypto_register_ops_handler_inline (vm, engine_index, opt, fn, 0);
260 vnet_crypto_register_chained_ops_handler (vlib_main_t * vm, u32 engine_index,
261 vnet_crypto_op_id_t opt,
262 vnet_crypto_chained_ops_handler_t *
265 vnet_crypto_register_ops_handler_inline (vm, engine_index, opt, 0, fn);
269 vnet_crypto_register_ops_handlers (vlib_main_t * vm, u32 engine_index,
270 vnet_crypto_op_id_t opt,
271 vnet_crypto_ops_handler_t * fn,
272 vnet_crypto_chained_ops_handler_t * cfn)
274 vnet_crypto_register_ops_handler_inline (vm, engine_index, opt, fn, cfn);
278 vnet_crypto_register_async_handler (vlib_main_t * vm, u32 engine_index,
279 vnet_crypto_async_op_id_t opt,
280 vnet_crypto_frame_enqueue_t * enqueue_hdl,
281 vnet_crypto_frame_dequeue_t * dequeue_hdl)
283 vnet_crypto_main_t *cm = &crypto_main;
284 vnet_crypto_engine_t *ae, *e = vec_elt_at_index (cm->engines, engine_index);
285 vnet_crypto_async_op_data_t *otd = cm->async_opt_data + opt;
286 vec_validate_aligned (cm->enqueue_handlers, VNET_CRYPTO_ASYNC_OP_N_IDS - 1,
287 CLIB_CACHE_LINE_BYTES);
288 vec_validate_aligned (cm->dequeue_handlers, VNET_CRYPTO_ASYNC_OP_N_IDS - 1,
289 CLIB_CACHE_LINE_BYTES);
291 /* both enqueue hdl and dequeue hdl should present */
292 if (!enqueue_hdl && !dequeue_hdl)
295 e->enqueue_handlers[opt] = enqueue_hdl;
296 e->dequeue_handlers[opt] = dequeue_hdl;
297 if (otd->active_engine_index_async == ~0)
299 otd->active_engine_index_async = engine_index;
300 cm->enqueue_handlers[opt] = enqueue_hdl;
301 cm->dequeue_handlers[opt] = dequeue_hdl;
304 ae = vec_elt_at_index (cm->engines, otd->active_engine_index_async);
305 if (ae->priority <= e->priority)
307 otd->active_engine_index_async = engine_index;
308 cm->enqueue_handlers[opt] = enqueue_hdl;
309 cm->dequeue_handlers[opt] = dequeue_hdl;
316 vnet_crypto_register_key_handler (vlib_main_t * vm, u32 engine_index,
317 vnet_crypto_key_handler_t * key_handler)
319 vnet_crypto_main_t *cm = &crypto_main;
320 vnet_crypto_engine_t *e = vec_elt_at_index (cm->engines, engine_index);
321 e->key_op_handler = key_handler;
326 vnet_crypto_key_len_check (vnet_crypto_alg_t alg, u16 length)
330 case VNET_CRYPTO_N_ALGS:
332 case VNET_CRYPTO_ALG_NONE:
336 case VNET_CRYPTO_ALG_##n: \
340 foreach_crypto_cipher_alg foreach_crypto_aead_alg
342 /* HMAC allows any key length */
344 case VNET_CRYPTO_ALG_HMAC_##n: \
346 foreach_crypto_hmac_alg
354 vnet_crypto_key_add (vlib_main_t * vm, vnet_crypto_alg_t alg, u8 * data,
358 vnet_crypto_main_t *cm = &crypto_main;
359 vnet_crypto_engine_t *engine;
360 vnet_crypto_key_t *key;
362 if (!vnet_crypto_key_len_check (alg, length))
365 pool_get_zero (cm->keys, key);
366 index = key - cm->keys;
367 key->type = VNET_CRYPTO_KEY_TYPE_DATA;
369 vec_validate_aligned (key->data, length - 1, CLIB_CACHE_LINE_BYTES);
370 clib_memcpy (key->data, data, length);
372 vec_foreach (engine, cm->engines)
373 if (engine->key_op_handler)
374 engine->key_op_handler (vm, VNET_CRYPTO_KEY_OP_ADD, index);
380 vnet_crypto_key_del (vlib_main_t * vm, vnet_crypto_key_index_t index)
382 vnet_crypto_main_t *cm = &crypto_main;
383 vnet_crypto_engine_t *engine;
384 vnet_crypto_key_t *key = pool_elt_at_index (cm->keys, index);
387 vec_foreach (engine, cm->engines)
388 if (engine->key_op_handler)
389 engine->key_op_handler (vm, VNET_CRYPTO_KEY_OP_DEL, index);
392 if (key->type == VNET_CRYPTO_KEY_TYPE_DATA)
394 clib_memset (key->data, 0, vec_len (key->data));
395 vec_free (key->data);
397 else if (key->type == VNET_CRYPTO_KEY_TYPE_LINK)
399 key->index_crypto = key->index_integ = 0;
402 pool_put (cm->keys, key);
405 vnet_crypto_async_alg_t
406 vnet_crypto_link_algs (vnet_crypto_alg_t crypto_alg,
407 vnet_crypto_alg_t integ_alg)
409 #define _(c, h, s, k ,d) \
410 if (crypto_alg == VNET_CRYPTO_ALG_##c && \
411 integ_alg == VNET_CRYPTO_ALG_HMAC_##h) \
412 return VNET_CRYPTO_ALG_##c##_##h##_TAG##d;
413 foreach_crypto_link_async_alg
419 vnet_crypto_key_add_linked (vlib_main_t * vm,
420 vnet_crypto_key_index_t index_crypto,
421 vnet_crypto_key_index_t index_integ)
424 vnet_crypto_main_t *cm = &crypto_main;
425 vnet_crypto_engine_t *engine;
426 vnet_crypto_key_t *key_crypto, *key_integ, *key;
427 vnet_crypto_async_alg_t linked_alg;
429 key_crypto = pool_elt_at_index (cm->keys, index_crypto);
430 key_integ = pool_elt_at_index (cm->keys, index_integ);
432 linked_alg = vnet_crypto_link_algs (key_crypto->alg, key_integ->alg);
433 if (linked_alg == ~0)
436 pool_get_zero (cm->keys, key);
437 index = key - cm->keys;
438 key->type = VNET_CRYPTO_KEY_TYPE_LINK;
439 key->index_crypto = index_crypto;
440 key->index_integ = index_integ;
441 key->async_alg = linked_alg;
444 vec_foreach (engine, cm->engines)
445 if (engine->key_op_handler)
446 engine->key_op_handler (vm, VNET_CRYPTO_KEY_OP_ADD, index);
453 crypto_dispatch_enable_disable (int is_enable)
455 vnet_crypto_main_t *cm = &crypto_main;
456 vlib_thread_main_t *tm = vlib_get_thread_main ();
457 u32 skip_master = vlib_num_workers () > 0, i;
458 vlib_node_state_t state = VLIB_NODE_STATE_DISABLED;
461 CLIB_MEMORY_STORE_BARRIER ();
462 if (is_enable && cm->async_refcnt > 0)
467 VNET_CRYPTO_ASYNC_DISPATCH_POLLING ? VLIB_NODE_STATE_POLLING :
468 VLIB_NODE_STATE_INTERRUPT;
471 if (!is_enable && cm->async_refcnt == 0)
474 state = VLIB_NODE_STATE_DISABLED;
478 for (i = skip_master; i < tm->n_vlib_mains; i++)
480 vlib_main_t *ovm = vlib_get_main_by_index (i);
481 if (state != vlib_node_get_state (ovm, cm->crypto_node_index))
482 vlib_node_set_state (ovm, cm->crypto_node_index, state);
487 static_always_inline void
488 crypto_set_active_async_engine (vnet_crypto_async_op_data_t * od,
489 vnet_crypto_async_op_id_t id, u32 ei)
491 vnet_crypto_main_t *cm = &crypto_main;
492 vnet_crypto_engine_t *ce = vec_elt_at_index (cm->engines, ei);
494 if (ce->enqueue_handlers[id] && ce->dequeue_handlers[id])
496 od->active_engine_index_async = ei;
497 cm->enqueue_handlers[id] = ce->enqueue_handlers[id];
498 cm->dequeue_handlers[id] = ce->dequeue_handlers[id];
503 vnet_crypto_set_async_handler2 (char *alg_name, char *engine)
506 vnet_crypto_main_t *cm = &crypto_main;
507 vnet_crypto_async_alg_data_t *ad;
510 p = hash_get_mem (cm->async_alg_index_by_name, alg_name);
514 ad = vec_elt_at_index (cm->async_algs, p[0]);
516 p = hash_get_mem (cm->engine_index_by_name, engine);
520 for (i = 0; i < VNET_CRYPTO_ASYNC_OP_N_TYPES; i++)
522 vnet_crypto_async_op_data_t *od;
523 vnet_crypto_async_op_id_t id = ad->op_by_type[i];
527 od = cm->async_opt_data + id;
528 crypto_set_active_async_engine (od, id, p[0]);
535 vnet_crypto_register_post_node (vlib_main_t * vm, char *post_node_name)
537 vnet_crypto_main_t *cm = &crypto_main;
538 vnet_crypto_async_next_node_t *nn = 0;
539 vlib_node_t *cc, *pn;
540 uword index = vec_len (cm->next_nodes);
542 pn = vlib_get_node_by_name (vm, (u8 *) post_node_name);
547 vec_foreach (cm->next_nodes, nn)
549 if (nn->node_idx == pn->index)
554 vec_validate (cm->next_nodes, index);
555 nn = vec_elt_at_index (cm->next_nodes, index);
557 cc = vlib_get_node_by_name (vm, (u8 *) "crypto-dispatch");
558 nn->next_idx = vlib_node_add_named_next (vm, cc->index, post_node_name);
559 nn->node_idx = pn->index;
565 vnet_crypto_request_async_mode (int is_enable)
567 vnet_crypto_main_t *cm = &crypto_main;
568 vlib_thread_main_t *tm = vlib_get_thread_main ();
569 u32 skip_master = vlib_num_workers () > 0, i;
570 vlib_node_state_t state = VLIB_NODE_STATE_DISABLED;
573 CLIB_MEMORY_STORE_BARRIER ();
574 if (is_enable && cm->async_refcnt == 0)
578 cm->dispatch_mode == VNET_CRYPTO_ASYNC_DISPATCH_POLLING ?
579 VLIB_NODE_STATE_POLLING : VLIB_NODE_STATE_INTERRUPT;
581 if (!is_enable && cm->async_refcnt == 1)
584 state = VLIB_NODE_STATE_DISABLED;
588 for (i = skip_master; i < tm->n_vlib_mains; i++)
590 vlib_main_t *ovm = vlib_get_main_by_index (i);
591 if (state != vlib_node_get_state (ovm, cm->crypto_node_index))
592 vlib_node_set_state (ovm, cm->crypto_node_index, state);
596 cm->async_refcnt += 1;
597 else if (cm->async_refcnt > 0)
598 cm->async_refcnt -= 1;
602 vnet_crypto_set_async_dispatch_mode (u8 mode)
604 vnet_crypto_main_t *cm = &crypto_main;
605 u32 skip_master = vlib_num_workers () > 0, i;
606 vlib_thread_main_t *tm = vlib_get_thread_main ();
607 vlib_node_state_t state = VLIB_NODE_STATE_DISABLED;
609 CLIB_MEMORY_STORE_BARRIER ();
610 cm->dispatch_mode = mode;
611 if (mode == VNET_CRYPTO_ASYNC_DISPATCH_INTERRUPT)
614 cm->async_refcnt == 0 ?
615 VLIB_NODE_STATE_DISABLED : VLIB_NODE_STATE_INTERRUPT;
617 else if (mode == VNET_CRYPTO_ASYNC_DISPATCH_POLLING)
620 cm->async_refcnt == 0 ?
621 VLIB_NODE_STATE_DISABLED : VLIB_NODE_STATE_POLLING;
624 for (i = skip_master; i < tm->n_vlib_mains; i++)
626 vlib_main_t *ovm = vlib_get_main_by_index (i);
627 if (state != vlib_node_get_state (ovm, cm->crypto_node_index))
628 vlib_node_set_state (ovm, cm->crypto_node_index, state);
633 vnet_crypto_is_set_async_handler (vnet_crypto_async_op_id_t op)
635 vnet_crypto_main_t *cm = &crypto_main;
637 return (op < vec_len (cm->enqueue_handlers) &&
638 NULL != cm->enqueue_handlers[op]);
642 vnet_crypto_init_cipher_data (vnet_crypto_alg_t alg, vnet_crypto_op_id_t eid,
643 vnet_crypto_op_id_t did, char *name, u8 is_aead)
645 vnet_crypto_op_type_t eopt, dopt;
646 vnet_crypto_main_t *cm = &crypto_main;
648 cm->algs[alg].name = name;
649 cm->opt_data[eid].alg = cm->opt_data[did].alg = alg;
650 cm->opt_data[eid].active_engine_index_simple = ~0;
651 cm->opt_data[did].active_engine_index_simple = ~0;
652 cm->opt_data[eid].active_engine_index_chained = ~0;
653 cm->opt_data[did].active_engine_index_chained = ~0;
656 eopt = VNET_CRYPTO_OP_TYPE_AEAD_ENCRYPT;
657 dopt = VNET_CRYPTO_OP_TYPE_AEAD_DECRYPT;
661 eopt = VNET_CRYPTO_OP_TYPE_ENCRYPT;
662 dopt = VNET_CRYPTO_OP_TYPE_DECRYPT;
664 cm->opt_data[eid].type = eopt;
665 cm->opt_data[did].type = dopt;
666 cm->algs[alg].op_by_type[eopt] = eid;
667 cm->algs[alg].op_by_type[dopt] = did;
668 hash_set_mem (cm->alg_index_by_name, name, alg);
672 vnet_crypto_init_hmac_data (vnet_crypto_alg_t alg,
673 vnet_crypto_op_id_t id, char *name)
675 vnet_crypto_main_t *cm = &crypto_main;
676 cm->algs[alg].name = name;
677 cm->algs[alg].op_by_type[VNET_CRYPTO_OP_TYPE_HMAC] = id;
678 cm->opt_data[id].alg = alg;
679 cm->opt_data[id].active_engine_index_simple = ~0;
680 cm->opt_data[id].active_engine_index_chained = ~0;
681 cm->opt_data[id].type = VNET_CRYPTO_OP_TYPE_HMAC;
682 hash_set_mem (cm->alg_index_by_name, name, alg);
686 vnet_crypto_init_async_data (vnet_crypto_async_alg_t alg,
687 vnet_crypto_async_op_id_t eid,
688 vnet_crypto_async_op_id_t did, char *name)
690 vnet_crypto_main_t *cm = &crypto_main;
692 cm->async_algs[alg].name = name;
693 cm->async_algs[alg].op_by_type[VNET_CRYPTO_ASYNC_OP_TYPE_ENCRYPT] = eid;
694 cm->async_algs[alg].op_by_type[VNET_CRYPTO_ASYNC_OP_TYPE_DECRYPT] = did;
695 cm->async_opt_data[eid].type = VNET_CRYPTO_ASYNC_OP_TYPE_ENCRYPT;
696 cm->async_opt_data[eid].alg = alg;
697 cm->async_opt_data[eid].active_engine_index_async = ~0;
698 cm->async_opt_data[eid].active_engine_index_async = ~0;
699 cm->async_opt_data[did].type = VNET_CRYPTO_ASYNC_OP_TYPE_DECRYPT;
700 cm->async_opt_data[did].alg = alg;
701 cm->async_opt_data[did].active_engine_index_async = ~0;
702 cm->async_opt_data[did].active_engine_index_async = ~0;
703 hash_set_mem (cm->async_alg_index_by_name, name, alg);
707 vnet_crypto_init (vlib_main_t * vm)
709 vnet_crypto_main_t *cm = &crypto_main;
710 vlib_thread_main_t *tm = vlib_get_thread_main ();
711 vnet_crypto_thread_t *ct = 0;
713 cm->dispatch_mode = VNET_CRYPTO_ASYNC_DISPATCH_POLLING;
714 cm->engine_index_by_name = hash_create_string ( /* size */ 0,
716 cm->alg_index_by_name = hash_create_string (0, sizeof (uword));
717 cm->async_alg_index_by_name = hash_create_string (0, sizeof (uword));
718 vec_validate_aligned (cm->threads, tm->n_vlib_mains, CLIB_CACHE_LINE_BYTES);
719 vec_foreach (ct, cm->threads)
720 pool_alloc_aligned (ct->frame_pool, VNET_CRYPTO_FRAME_POOL_SIZE,
721 CLIB_CACHE_LINE_BYTES);
722 vec_validate (cm->algs, VNET_CRYPTO_N_ALGS);
723 vec_validate (cm->async_algs, VNET_CRYPTO_N_ASYNC_ALGS);
724 clib_bitmap_validate (cm->async_active_ids, VNET_CRYPTO_ASYNC_OP_N_IDS - 1);
727 vnet_crypto_init_cipher_data (VNET_CRYPTO_ALG_##n, \
728 VNET_CRYPTO_OP_##n##_ENC, \
729 VNET_CRYPTO_OP_##n##_DEC, s, 0);
730 foreach_crypto_cipher_alg;
733 vnet_crypto_init_cipher_data (VNET_CRYPTO_ALG_##n, \
734 VNET_CRYPTO_OP_##n##_ENC, \
735 VNET_CRYPTO_OP_##n##_DEC, s, 1);
736 foreach_crypto_aead_alg;
739 vnet_crypto_init_hmac_data (VNET_CRYPTO_ALG_HMAC_##n, \
740 VNET_CRYPTO_OP_##n##_HMAC, "hmac-" s);
741 foreach_crypto_hmac_alg;
743 #define _(n, s, k, t, a) \
744 vnet_crypto_init_async_data (VNET_CRYPTO_ALG_##n##_TAG##t##_AAD##a, \
745 VNET_CRYPTO_OP_##n##_TAG##t##_AAD##a##_ENC, \
746 VNET_CRYPTO_OP_##n##_TAG##t##_AAD##a##_DEC, \
748 foreach_crypto_aead_async_alg
750 #define _(c, h, s, k ,d) \
751 vnet_crypto_init_async_data (VNET_CRYPTO_ALG_##c##_##h##_TAG##d, \
752 VNET_CRYPTO_OP_##c##_##h##_TAG##d##_ENC, \
753 VNET_CRYPTO_OP_##c##_##h##_TAG##d##_DEC, \
755 foreach_crypto_link_async_alg
757 cm->crypto_node_index =
758 vlib_get_node_by_name (vm, (u8 *) "crypto-dispatch")->index;
763 VLIB_INIT_FUNCTION (vnet_crypto_init);
766 * fd.io coding-style-patch-verification: ON
769 * eval: (c-set-style "gnu")