crypto: Add async crypto APIs
[vpp.git] / src / plugins / crypto_sw_scheduler / api.c
1 /*
2  * Copyright (c) 2020 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:
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
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.
14  */
15
16 #include <stddef.h>
17
18 #include <vnet/vnet.h>
19 #include <vnet/plugin/plugin.h>
20
21 #include <vnet/ip/ip_types_api.h>
22 #include <vpp/app/version.h>
23
24 #include <vlibapi/api.h>
25 #include <vlibmemory/api.h>
26
27 #include <crypto_sw_scheduler/crypto_sw_scheduler.h>
28
29 /* define message IDs */
30 #include <vnet/format_fns.h>
31 #include <crypto_sw_scheduler/crypto_sw_scheduler.api_enum.h>
32 #include <crypto_sw_scheduler/crypto_sw_scheduler.api_types.h>
33
34 /**
35  * Base message ID fot the plugin
36  */
37 static u32 crypto_sw_scheduler_base_msg_id;
38
39 #define REPLY_MSG_ID_BASE crypto_sw_scheduler_base_msg_id
40
41 #include <vlibapi/api_helper_macros.h>
42
43 static void
44   vl_api_crypto_sw_scheduler_set_worker_t_handler
45   (vl_api_crypto_sw_scheduler_set_worker_t * mp)
46 {
47   vl_api_crypto_sw_scheduler_set_worker_reply_t *rmp;
48   u32 worker_index;
49   u8 crypto_enable;
50   int rv;
51
52   worker_index = ntohl (mp->worker_index);
53   crypto_enable = mp->crypto_enable;
54
55   rv = crypto_sw_scheduler_set_worker_crypto (worker_index, crypto_enable);
56
57   REPLY_MACRO (VL_API_CRYPTO_SW_SCHEDULER_SET_WORKER_REPLY);
58 }
59
60 #include <crypto_sw_scheduler/crypto_sw_scheduler.api.c>
61
62 clib_error_t *
63 crypto_sw_scheduler_api_init (vlib_main_t * vm)
64 {
65   /* Ask for a correctly-sized block of API message decode slots */
66   crypto_sw_scheduler_base_msg_id = setup_message_id_table ();
67
68   return 0;
69 }
70
71 /*
72  * fd.io coding-style-patch-verification: ON
73  *
74  * Local Variables:
75  * eval: (c-set-style "gnu")
76  * End:
77  */