crypto: encrypt/decrypt queues sw_scheduler
[vpp.git] / src / plugins / crypto_sw_scheduler / crypto_sw_scheduler.h
1 /*
2  * Copyright (c) 2020 Intel 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 <vnet/crypto/crypto.h>
17
18 #ifndef __crypto_sw_scheduler_h__
19 #define __crypto_sw_scheduler_h__
20
21 #define CRYPTO_SW_SCHEDULER_QUEUE_SIZE 64
22 #define CRYPTO_SW_SCHEDULER_QUEUE_MASK (CRYPTO_SW_SCHEDULER_QUEUE_SIZE - 1)
23
24 STATIC_ASSERT ((0 == (CRYPTO_SW_SCHEDULER_QUEUE_SIZE &
25                       (CRYPTO_SW_SCHEDULER_QUEUE_SIZE - 1))),
26                "CRYPTO_SW_SCHEDULER_QUEUE_SIZE is not pow2");
27
28 typedef enum crypto_sw_scheduler_queue_type_t_
29 {
30   CRYPTO_SW_SCHED_QUEUE_TYPE_ENCRYPT = 0,
31   CRYPTO_SW_SCHED_QUEUE_TYPE_DECRYPT,
32   CRYPTO_SW_SCHED_QUEUE_N_TYPES
33 } crypto_sw_scheduler_queue_type_t;
34
35 typedef struct
36 {
37   CLIB_CACHE_LINE_ALIGN_MARK (cacheline0);
38   u32 head;
39   u32 tail;
40   vnet_crypto_async_frame_t **jobs;
41 } crypto_sw_scheduler_queue_t;
42
43 typedef struct
44 {
45   CLIB_CACHE_LINE_ALIGN_MARK (cacheline0);
46   crypto_sw_scheduler_queue_t queue[CRYPTO_SW_SCHED_QUEUE_N_TYPES];
47   u32 last_serve_lcore_id;
48   u8 last_serve_encrypt;
49   u8 last_return_queue;
50   vnet_crypto_op_t *crypto_ops;
51   vnet_crypto_op_t *integ_ops;
52   vnet_crypto_op_t *chained_crypto_ops;
53   vnet_crypto_op_t *chained_integ_ops;
54   vnet_crypto_op_chunk_t *chunks;
55   u8 self_crypto_enabled;
56 } crypto_sw_scheduler_per_thread_data_t;
57
58 typedef struct
59 {
60   u32 crypto_engine_index;
61   crypto_sw_scheduler_per_thread_data_t *per_thread_data;
62   vnet_crypto_key_t *keys;
63 } crypto_sw_scheduler_main_t;
64
65 extern crypto_sw_scheduler_main_t crypto_sw_scheduler_main;
66
67 extern int crypto_sw_scheduler_set_worker_crypto (u32 worker_idx, u8 enabled);
68
69 extern clib_error_t *crypto_sw_scheduler_api_init (vlib_main_t * vm);
70
71 #endif // __crypto_native_h__
72
73 /*
74  * fd.io coding-style-patch-verification: ON
75  *
76  * Local Variables:
77  * eval: (c-set-style "gnu")
78  * End:
79  */