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.
126 * - -EINVAL if input values are invalid.
129 rte_cryptodev_scheduler_load_user_scheduler(uint8_t scheduler_id,
130 struct rte_cryptodev_scheduler *scheduler);
133 * Attach a crypto device to the scheduler
135 * @param scheduler_id
136 * The target scheduler device ID
138 * Crypto device ID to be attached
141 * - 0 if the slave is attached.
142 * - -ENOTSUP if the operation is not supported.
143 * - -EBUSY if device is started.
144 * - -ENOMEM if the scheduler's slave list is full.
147 rte_cryptodev_scheduler_slave_attach(uint8_t scheduler_id, uint8_t slave_id);
150 * Detach a crypto device from the scheduler
152 * @param scheduler_id
153 * The target scheduler device ID
155 * Crypto device ID to be detached
158 * - 0 if the slave is detached.
159 * - -ENOTSUP if the operation is not supported.
160 * - -EBUSY if device is started.
163 rte_cryptodev_scheduler_slave_detach(uint8_t scheduler_id, uint8_t slave_id);
167 * Set the scheduling mode
169 * @param scheduler_id
170 * The target scheduler device ID
172 * The scheduling mode
175 * - 0 if the mode is set.
176 * - -ENOTSUP if the operation is not supported.
177 * - -EBUSY if device is started.
180 rte_cryptodev_scheduler_mode_set(uint8_t scheduler_id,
181 enum rte_cryptodev_scheduler_mode mode);
184 * Get the current scheduling mode
186 * @param scheduler_id
187 * The target scheduler device ID
190 * - non-negative enumerate value: the scheduling mode
191 * - -ENOTSUP if the operation is not supported.
193 enum rte_cryptodev_scheduler_mode
194 rte_cryptodev_scheduler_mode_get(uint8_t scheduler_id);
197 * Set the crypto ops reordering feature on/off
199 * @param scheduler_id
200 * The target scheduler device ID
201 * @param enable_reorder
202 * Set the crypto op reordering feature
203 * - 0: disable reordering
204 * - 1: enable reordering
207 * - 0 if the ordering is set.
208 * - -ENOTSUP if the operation is not supported.
209 * - -EBUSY if device is started.
212 rte_cryptodev_scheduler_ordering_set(uint8_t scheduler_id,
213 uint32_t enable_reorder);
216 * Get the current crypto ops reordering feature
218 * @param scheduler_id
219 * The target scheduler device ID
222 * - 0 if reordering is disabled
223 * - 1 if reordering is enabled
224 * - -ENOTSUP if the operation is not supported.
227 rte_cryptodev_scheduler_ordering_get(uint8_t scheduler_id);
230 * Get the the attached slaves' count and/or ID
232 * @param scheduler_id
233 * The target scheduler device ID
235 * If successful, the function will write back all slaves' device IDs to it.
236 * This parameter will either be an uint8_t array of
237 * RTE_CRYPTODEV_SCHEDULER_MAX_NB_SLAVES elements or NULL.
240 * - non-negative number: the number of slaves attached
241 * - -ENOTSUP if the operation is not supported.
244 rte_cryptodev_scheduler_slaves_get(uint8_t scheduler_id, uint8_t *slaves);
247 * Set the mode specific option
249 * @param scheduler_id
250 * The target scheduler device ID
252 * The option type enumerate
254 * The specific mode's option structure
258 * - negative integer if otherwise.
261 rte_cryptodev_scheduler_option_set(uint8_t scheduler_id,
262 enum rte_cryptodev_schedule_option_type option_type,
266 * Set the mode specific option
268 * @param scheduler_id
269 * The target scheduler device ID
271 * The option type enumerate
273 * If successful, the function will write back the current
277 * - negative integer if otherwise.
280 rte_cryptodev_scheduler_option_get(uint8_t scheduler_id,
281 enum rte_cryptodev_schedule_option_type option_type,
284 typedef uint16_t (*rte_cryptodev_scheduler_burst_enqueue_t)(void *qp_ctx,
285 struct rte_crypto_op **ops, uint16_t nb_ops);
287 typedef uint16_t (*rte_cryptodev_scheduler_burst_dequeue_t)(void *qp_ctx,
288 struct rte_crypto_op **ops, uint16_t nb_ops);
290 /** The data structure associated with each mode of scheduler. */
291 struct rte_cryptodev_scheduler {
292 const char *name; /**< Scheduler name */
293 const char *description; /**< Scheduler description */
294 enum rte_cryptodev_scheduler_mode mode; /**< Scheduling mode */
296 /** Pointer to scheduler operation structure */
297 struct rte_cryptodev_scheduler_ops *ops;
300 /** Round-robin mode scheduler */
301 extern struct rte_cryptodev_scheduler *roundrobin_scheduler;
302 /** Packet-size based distribution mode scheduler */
303 extern struct rte_cryptodev_scheduler *pkt_size_based_distr_scheduler;
304 /** Fail-over mode scheduler */
305 extern struct rte_cryptodev_scheduler *failover_scheduler;
306 /** multi-core mode scheduler */
307 extern struct rte_cryptodev_scheduler *multicore_scheduler;
312 #endif /* _RTE_CRYPTO_SCHEDULER_H */