4 * Copyright(c) 2017 Intel Corporation. All rights reserved.
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
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
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.
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.
34 #ifndef _RTE_CRYPTO_SCHEDULER_H
35 #define _RTE_CRYPTO_SCHEDULER_H
38 * @file rte_cryptodev_scheduler.h
40 * RTE Cryptodev Scheduler Device
42 * The RTE Cryptodev Scheduler Device allows the aggregation of multiple (slave)
43 * Cryptodevs into a single logical crypto device, and the scheduling the
44 * crypto operations to the slaves based on the mode of the specified mode of
45 * operation specified and supported. This implementation supports 3 modes of
46 * operation: round robin, packet-size based, and fail-over.
50 #include "rte_cryptodev_scheduler_operations.h"
56 /** Maximum number of bonded devices per device */
57 #ifndef RTE_CRYPTODEV_SCHEDULER_MAX_NB_SLAVES
58 #define RTE_CRYPTODEV_SCHEDULER_MAX_NB_SLAVES (8)
61 /** Maximum number of multi-core worker cores */
62 #define RTE_CRYPTODEV_SCHEDULER_MAX_NB_WORKER_CORES (64)
64 /** Round-robin scheduling mode string */
65 #define SCHEDULER_MODE_NAME_ROUND_ROBIN round-robin
66 /** Packet-size based distribution scheduling mode string */
67 #define SCHEDULER_MODE_NAME_PKT_SIZE_DISTR packet-size-distr
68 /** Fail-over scheduling mode string */
69 #define SCHEDULER_MODE_NAME_FAIL_OVER fail-over
70 /** multi-core scheduling mode string */
71 #define SCHEDULER_MODE_NAME_MULTI_CORE multi-core
74 * Crypto scheduler PMD operation modes
76 enum rte_cryptodev_scheduler_mode {
77 CDEV_SCHED_MODE_NOT_SET = 0,
78 /** User defined mode */
79 CDEV_SCHED_MODE_USERDEFINED,
80 /** Round-robin mode */
81 CDEV_SCHED_MODE_ROUNDROBIN,
82 /** Packet-size based distribution mode */
83 CDEV_SCHED_MODE_PKT_SIZE_DISTR,
85 CDEV_SCHED_MODE_FAILOVER,
86 /** multi-core mode */
87 CDEV_SCHED_MODE_MULTICORE,
89 CDEV_SCHED_MODE_COUNT /**< number of modes */
92 #define RTE_CRYPTODEV_SCHEDULER_NAME_MAX_LEN (64)
93 #define RTE_CRYPTODEV_SCHEDULER_DESC_MAX_LEN (256)
96 * Crypto scheduler option types
98 enum rte_cryptodev_schedule_option_type {
99 CDEV_SCHED_OPTION_NOT_SET = 0,
100 CDEV_SCHED_OPTION_THRESHOLD,
102 CDEV_SCHED_OPTION_COUNT
106 * Threshold option structure
108 struct rte_cryptodev_scheduler_threshold_option {
109 uint32_t threshold; /**< Threshold for packet-size mode */
112 struct rte_cryptodev_scheduler;
115 * Load a user defined scheduler
117 * @param scheduler_id
118 * The target scheduler device ID
120 * Pointer to the user defined scheduler
123 * - 0 if the scheduler is successfully loaded
124 * - -ENOTSUP if the operation is not supported.
125 * - -EBUSY if device is started.
128 rte_cryptodev_scheduler_load_user_scheduler(uint8_t scheduler_id,
129 struct rte_cryptodev_scheduler *scheduler);
132 * Attach a crypto device to the scheduler
134 * @param scheduler_id
135 * The target scheduler device ID
137 * Crypto device ID to be attached
140 * - 0 if the slave is attached.
141 * - -ENOTSUP if the operation is not supported.
142 * - -EBUSY if device is started.
143 * - -ENOMEM if the scheduler's slave list is full.
146 rte_cryptodev_scheduler_slave_attach(uint8_t scheduler_id, uint8_t slave_id);
149 * Detach a crypto device from the scheduler
151 * @param scheduler_id
152 * The target scheduler device ID
154 * Crypto device ID to be detached
157 * - 0 if the slave is detached.
158 * - -ENOTSUP if the operation is not supported.
159 * - -EBUSY if device is started.
162 rte_cryptodev_scheduler_slave_detach(uint8_t scheduler_id, uint8_t slave_id);
166 * Set the scheduling mode
168 * @param scheduler_id
169 * The target scheduler device ID
171 * The scheduling mode
174 * - 0 if the mode is set.
175 * - -ENOTSUP if the operation is not supported.
176 * - -EBUSY if device is started.
179 rte_cryptodev_scheduler_mode_set(uint8_t scheduler_id,
180 enum rte_cryptodev_scheduler_mode mode);
183 * Get the current scheduling mode
185 * @param scheduler_id
186 * The target scheduler device ID
189 * - non-negative enumerate value: the scheduling mode
190 * - -ENOTSUP if the operation is not supported.
192 enum rte_cryptodev_scheduler_mode
193 rte_cryptodev_scheduler_mode_get(uint8_t scheduler_id);
196 * Set the crypto ops reordering feature on/off
198 * @param scheduler_id
199 * The target scheduler device ID
200 * @param enable_reorder
201 * Set the crypto op reordering feature
202 * - 0: disable reordering
203 * - 1: enable reordering
206 * - 0 if the ordering is set.
207 * - -ENOTSUP if the operation is not supported.
208 * - -EBUSY if device is started.
211 rte_cryptodev_scheduler_ordering_set(uint8_t scheduler_id,
212 uint32_t enable_reorder);
215 * Get the current crypto ops reordering feature
217 * @param scheduler_id
218 * The target scheduler device ID
221 * - 0 if reordering is disabled
222 * - 1 if reordering is enabled
223 * - -ENOTSUP if the operation is not supported.
226 rte_cryptodev_scheduler_ordering_get(uint8_t scheduler_id);
229 * Get the the attached slaves' count and/or ID
231 * @param scheduler_id
232 * The target scheduler device ID
234 * If successful, the function will write back all slaves' device IDs to it.
235 * This parameter will either be an uint8_t array of
236 * RTE_CRYPTODEV_SCHEDULER_MAX_NB_SLAVES elements or NULL.
239 * - non-negative number: the number of slaves attached
240 * - -ENOTSUP if the operation is not supported.
243 rte_cryptodev_scheduler_slaves_get(uint8_t scheduler_id, uint8_t *slaves);
246 * Set the mode specific option
248 * @param scheduler_id
249 * The target scheduler device ID
251 * The option type enumerate
253 * The specific mode's option structure
257 * - negative integer if otherwise.
260 rte_cryptodev_scheduler_option_set(uint8_t scheduler_id,
261 enum rte_cryptodev_schedule_option_type option_type,
265 * Set the mode specific option
267 * @param scheduler_id
268 * The target scheduler device ID
270 * The option type enumerate
272 * If successful, the function will write back the current
276 * - negative integer if otherwise.
279 rte_cryptodev_scheduler_option_get(uint8_t scheduler_id,
280 enum rte_cryptodev_schedule_option_type option_type,
283 typedef uint16_t (*rte_cryptodev_scheduler_burst_enqueue_t)(void *qp_ctx,
284 struct rte_crypto_op **ops, uint16_t nb_ops);
286 typedef uint16_t (*rte_cryptodev_scheduler_burst_dequeue_t)(void *qp_ctx,
287 struct rte_crypto_op **ops, uint16_t nb_ops);
289 /** The data structure associated with each mode of scheduler. */
290 struct rte_cryptodev_scheduler {
291 const char *name; /**< Scheduler name */
292 const char *description; /**< Scheduler description */
293 enum rte_cryptodev_scheduler_mode mode; /**< Scheduling mode */
295 /** Pointer to scheduler operation structure */
296 struct rte_cryptodev_scheduler_ops *ops;
299 /** Round-robin mode scheduler */
300 extern struct rte_cryptodev_scheduler *roundrobin_scheduler;
301 /** Packet-size based distribution mode scheduler */
302 extern struct rte_cryptodev_scheduler *pkt_size_based_distr_scheduler;
303 /** Fail-over mode scheduler */
304 extern struct rte_cryptodev_scheduler *failover_scheduler;
305 /** multi-core mode scheduler */
306 extern struct rte_cryptodev_scheduler *multicore_scheduler;
311 #endif /* _RTE_CRYPTO_SCHEDULER_H */