crypto/scheduler: add round-robin mode
[dpdk.git] / drivers / crypto / scheduler / rte_cryptodev_scheduler.h
1 /*-
2  *   BSD LICENSE
3  *
4  *   Copyright(c) 2017 Intel Corporation. All rights reserved.
5  *   All rights reserved.
6  *
7  *   Redistribution and use in source and binary forms, with or without
8  *   modification, are permitted provided that the following conditions
9  *   are met:
10  *
11  *     * Redistributions of source code must retain the above copyright
12  *       notice, this list of conditions and the following disclaimer.
13  *     * Redistributions in binary form must reproduce the above copyright
14  *       notice, this list of conditions and the following disclaimer in
15  *       the documentation and/or other materials provided with the
16  *       distribution.
17  *     * Neither the name of Intel Corporation nor the names of its
18  *       contributors may be used to endorse or promote products derived
19  *       from this software without specific prior written permission.
20  *
21  *   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22  *   "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23  *   LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
24  *   A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
25  *   OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
26  *   SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
27  *   LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
28  *   DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
29  *   THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
30  *   (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
31  *   OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32  */
33
34 #ifndef _RTE_CRYPTO_SCHEDULER_H
35 #define _RTE_CRYPTO_SCHEDULER_H
36
37 #include <rte_cryptodev_scheduler_operations.h>
38
39 #ifdef __cplusplus
40 extern "C" {
41 #endif
42
43 /**
44  * Crypto scheduler PMD operation modes
45  */
46 enum rte_cryptodev_scheduler_mode {
47         CDEV_SCHED_MODE_NOT_SET = 0,
48         CDEV_SCHED_MODE_USERDEFINED,
49         CDEV_SCHED_MODE_ROUNDROBIN,
50
51         CDEV_SCHED_MODE_COUNT /* number of modes */
52 };
53
54 #define RTE_CRYPTODEV_SCHEDULER_NAME_MAX_LEN    (64)
55 #define RTE_CRYPTODEV_SCHEDULER_DESC_MAX_LEN    (256)
56
57 struct rte_cryptodev_scheduler;
58
59 /**
60  * Load a user defined scheduler
61  *
62  * @param       scheduler_id    The target scheduler device ID
63  *              scheduler       Pointer to the user defined scheduler
64  *
65  * @return
66  *      0 if loading successful, negative integer if otherwise.
67  */
68 int
69 rte_cryptodev_scheduler_load_user_scheduler(uint8_t scheduler_id,
70                 struct rte_cryptodev_scheduler *scheduler);
71
72 /**
73  * Attach a pre-configured crypto device to the scheduler
74  *
75  * @param       scheduler_id    The target scheduler device ID
76  *              slave_id        crypto device ID to be attached
77  *
78  * @return
79  *      0 if attaching successful, negative int if otherwise.
80  */
81 int
82 rte_cryptodev_scheduler_slave_attach(uint8_t scheduler_id, uint8_t slave_id);
83
84 /**
85  * Detach a attached crypto device to the scheduler
86  *
87  * @param       scheduler_id    The target scheduler device ID
88  *              slave_id        crypto device ID to be detached
89  *
90  * @return
91  *      0 if detaching successful, negative int if otherwise.
92  */
93 int
94 rte_cryptodev_scheduler_slave_detach(uint8_t scheduler_id, uint8_t slave_id);
95
96 /**
97  * Set the scheduling mode
98  *
99  * @param       scheduler_id    The target scheduler device ID
100  *              mode            The scheduling mode
101  *
102  * @return
103  *      0 if attaching successful, negative integer if otherwise.
104  */
105 int
106 rte_crpytodev_scheduler_mode_set(uint8_t scheduler_id,
107                 enum rte_cryptodev_scheduler_mode mode);
108
109 /**
110  * Get the current scheduling mode
111  *
112  * @param       scheduler_id    The target scheduler device ID
113  *              mode            Pointer to write the scheduling mode
114  */
115 enum rte_cryptodev_scheduler_mode
116 rte_crpytodev_scheduler_mode_get(uint8_t scheduler_id);
117
118 /**
119  * Set the crypto ops reordering feature on/off
120  *
121  * @param       dev_id          The target scheduler device ID
122  *              enable_reorder  set the crypto op reordering feature
123  *                              0: disable reordering
124  *                              1: enable reordering
125  *
126  * @return
127  *      0 if setting successful, negative integer if otherwise.
128  */
129 int
130 rte_cryptodev_scheduler_ordering_set(uint8_t scheduler_id,
131                 uint32_t enable_reorder);
132
133 /**
134  * Get the current crypto ops reordering feature
135  *
136  * @param       dev_id          The target scheduler device ID
137  *
138  * @return
139  *      0 if reordering is disabled
140  *      1 if reordering is enabled
141  *      negative integer if otherwise.
142  */
143 int
144 rte_cryptodev_scheduler_ordering_get(uint8_t scheduler_id);
145
146 typedef uint16_t (*rte_cryptodev_scheduler_burst_enqueue_t)(void *qp_ctx,
147                 struct rte_crypto_op **ops, uint16_t nb_ops);
148
149 typedef uint16_t (*rte_cryptodev_scheduler_burst_dequeue_t)(void *qp_ctx,
150                 struct rte_crypto_op **ops, uint16_t nb_ops);
151
152 struct rte_cryptodev_scheduler {
153         const char *name;
154         const char *description;
155         enum rte_cryptodev_scheduler_mode mode;
156
157         struct rte_cryptodev_scheduler_ops *ops;
158 };
159
160 extern struct rte_cryptodev_scheduler *roundrobin_scheduler;
161
162 #ifdef __cplusplus
163 }
164 #endif
165 #endif /* _RTE_CRYPTO_SCHEDULER_H */