2 *------------------------------------------------------------------
3 * Copyright (c) 2019 Cisco and/or its affiliates.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at:
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 *------------------------------------------------------------------
18 #ifndef __crypto_native_h__
19 #define __crypto_native_h__
21 typedef void *(crypto_native_key_fn_t) (vnet_crypto_key_t * key);
22 typedef int (crypto_native_variant_probe_t) ();
24 typedef struct crypto_native_op_handler
26 struct crypto_native_op_handler *next;
27 vnet_crypto_op_id_t op_id;
28 vnet_crypto_ops_handler_t *fn;
29 vnet_crypto_chained_ops_handler_t *cfn;
30 crypto_native_variant_probe_t *probe;
32 } crypto_native_op_handler_t;
34 typedef struct crypto_native_key_handler
36 struct crypto_native_key_handler *next;
37 vnet_crypto_alg_t alg_id;
38 crypto_native_key_fn_t *key_fn;
39 crypto_native_variant_probe_t *probe;
41 } crypto_native_key_handler_t;
45 u32 crypto_engine_index;
46 crypto_native_key_fn_t *key_fn[VNET_CRYPTO_N_ALGS];
48 crypto_native_op_handler_t *op_handlers;
49 crypto_native_key_handler_t *key_handlers;
50 } crypto_native_main_t;
52 extern crypto_native_main_t crypto_native_main;
54 #define CRYPTO_NATIVE_OP_HANDLER(x) \
55 static crypto_native_op_handler_t __crypto_native_op_handler_##x; \
56 static void __clib_constructor __crypto_native_op_handler_cb_##x (void) \
58 crypto_native_main_t *cm = &crypto_native_main; \
59 int priority = __crypto_native_op_handler_##x.probe (); \
62 __crypto_native_op_handler_##x.priority = priority; \
63 __crypto_native_op_handler_##x.next = cm->op_handlers; \
64 cm->op_handlers = &__crypto_native_op_handler_##x; \
67 static crypto_native_op_handler_t __crypto_native_op_handler_##x
69 #define CRYPTO_NATIVE_KEY_HANDLER(x) \
70 static crypto_native_key_handler_t __crypto_native_key_handler_##x; \
71 static void __clib_constructor __crypto_native_key_handler_cb_##x (void) \
73 crypto_native_main_t *cm = &crypto_native_main; \
74 int priority = __crypto_native_key_handler_##x.probe (); \
77 __crypto_native_key_handler_##x.priority = priority; \
78 __crypto_native_key_handler_##x.next = cm->key_handlers; \
79 cm->key_handlers = &__crypto_native_key_handler_##x; \
82 static crypto_native_key_handler_t __crypto_native_key_handler_##x
83 #endif /* __crypto_native_h__ */