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 /** Round-robin scheduling mode string */
62 #define SCHEDULER_MODE_NAME_ROUND_ROBIN round-robin
63 /** Packet-size based distribution scheduling mode string */
64 #define SCHEDULER_MODE_NAME_PKT_SIZE_DISTR packet-size-distr
65 /** Fail-over scheduling mode string */
66 #define SCHEDULER_MODE_NAME_FAIL_OVER fail-over
69 * Crypto scheduler PMD operation modes
71 enum rte_cryptodev_scheduler_mode {
72 CDEV_SCHED_MODE_NOT_SET = 0,
73 /** User defined mode */
74 CDEV_SCHED_MODE_USERDEFINED,
75 /** Round-robin mode */
76 CDEV_SCHED_MODE_ROUNDROBIN,
77 /** Packet-size based distribution mode */
78 CDEV_SCHED_MODE_PKT_SIZE_DISTR,
80 CDEV_SCHED_MODE_FAILOVER,
82 CDEV_SCHED_MODE_COUNT /**< number of modes */
85 #define RTE_CRYPTODEV_SCHEDULER_NAME_MAX_LEN (64)
86 #define RTE_CRYPTODEV_SCHEDULER_DESC_MAX_LEN (256)
89 * Crypto scheduler option types
91 enum rte_cryptodev_schedule_option_type {
92 CDEV_SCHED_OPTION_NOT_SET = 0,
93 CDEV_SCHED_OPTION_THRESHOLD,
95 CDEV_SCHED_OPTION_COUNT
99 * Threshold option structure
101 struct rte_cryptodev_scheduler_threshold_option {
102 uint32_t threshold; /**< Threshold for packet-size mode */
105 struct rte_cryptodev_scheduler;
108 * Load a user defined scheduler
110 * @param scheduler_id
111 * The target scheduler device ID
113 * Pointer to the user defined scheduler
116 * - 0 if the scheduler is successfully loaded
117 * - -ENOTSUP if the operation is not supported.
118 * - -EBUSY if device is started.
119 * - -EINVAL if input values are invalid.
122 rte_cryptodev_scheduler_load_user_scheduler(uint8_t scheduler_id,
123 struct rte_cryptodev_scheduler *scheduler);
126 * Attach a crypto device to the scheduler
128 * @param scheduler_id
129 * The target scheduler device ID
131 * Crypto device ID to be attached
134 * - 0 if the slave is attached.
135 * - -ENOTSUP if the operation is not supported.
136 * - -EBUSY if device is started.
137 * - -ENOMEM if the scheduler's slave list is full.
140 rte_cryptodev_scheduler_slave_attach(uint8_t scheduler_id, uint8_t slave_id);
143 * Detach a crypto device from the scheduler
145 * @param scheduler_id
146 * The target scheduler device ID
148 * Crypto device ID to be detached
151 * - 0 if the slave is detached.
152 * - -ENOTSUP if the operation is not supported.
153 * - -EBUSY if device is started.
156 rte_cryptodev_scheduler_slave_detach(uint8_t scheduler_id, uint8_t slave_id);
160 * Set the scheduling mode
162 * @param scheduler_id
163 * The target scheduler device ID
165 * The scheduling mode
168 * - 0 if the mode is set.
169 * - -ENOTSUP if the operation is not supported.
170 * - -EBUSY if device is started.
173 rte_cryptodev_scheduler_mode_set(uint8_t scheduler_id,
174 enum rte_cryptodev_scheduler_mode mode);
177 * Get the current scheduling mode
179 * @param scheduler_id
180 * The target scheduler device ID
183 * - non-negative enumerate value: the scheduling mode
184 * - -ENOTSUP if the operation is not supported.
186 enum rte_cryptodev_scheduler_mode
187 rte_cryptodev_scheduler_mode_get(uint8_t scheduler_id);
191 * Set the scheduling mode
193 * @param scheduler_id
194 * The target scheduler device ID
196 * The scheduling mode
199 * 0 if attaching successful, negative integer if otherwise.
203 rte_crpytodev_scheduler_mode_set(uint8_t scheduler_id,
204 enum rte_cryptodev_scheduler_mode mode);
208 * Get the current scheduling mode
210 * @param scheduler_id
211 * The target scheduler device ID
214 * If successful, returns the scheduling mode, negative integer
218 enum rte_cryptodev_scheduler_mode
219 rte_crpytodev_scheduler_mode_get(uint8_t scheduler_id);
222 * Set the crypto ops reordering feature on/off
224 * @param scheduler_id
225 * The target scheduler device ID
226 * @param enable_reorder
227 * Set the crypto op reordering feature
228 * - 0: disable reordering
229 * - 1: enable reordering
232 * - 0 if the ordering is set.
233 * - -ENOTSUP if the operation is not supported.
234 * - -EBUSY if device is started.
237 rte_cryptodev_scheduler_ordering_set(uint8_t scheduler_id,
238 uint32_t enable_reorder);
241 * Get the current crypto ops reordering feature
243 * @param scheduler_id
244 * The target scheduler device ID
247 * - 0 if reordering is disabled
248 * - 1 if reordering is enabled
249 * - -ENOTSUP if the operation is not supported.
252 rte_cryptodev_scheduler_ordering_get(uint8_t scheduler_id);
255 * Get the the attached slaves' count and/or ID
257 * @param scheduler_id
258 * The target scheduler device ID
260 * If successful, the function will write back all slaves' device IDs to it.
261 * This parameter will either be an uint8_t array of
262 * RTE_CRYPTODEV_SCHEDULER_MAX_NB_SLAVES elements or NULL.
265 * - non-negative number: the number of slaves attached
266 * - -ENOTSUP if the operation is not supported.
269 rte_cryptodev_scheduler_slaves_get(uint8_t scheduler_id, uint8_t *slaves);
272 * Set the mode specific option
274 * @param scheduler_id
275 * The target scheduler device ID
277 * The option type enumerate
279 * The specific mode's option structure
283 * - negative integer if otherwise.
286 rte_cryptodev_scheduler_option_set(uint8_t scheduler_id,
287 enum rte_cryptodev_schedule_option_type option_type,
291 * Set the mode specific option
293 * @param scheduler_id
294 * The target scheduler device ID
296 * The option type enumerate
298 * If successful, the function will write back the current
302 * - negative integer if otherwise.
305 rte_cryptodev_scheduler_option_get(uint8_t scheduler_id,
306 enum rte_cryptodev_schedule_option_type option_type,
309 typedef uint16_t (*rte_cryptodev_scheduler_burst_enqueue_t)(void *qp_ctx,
310 struct rte_crypto_op **ops, uint16_t nb_ops);
312 typedef uint16_t (*rte_cryptodev_scheduler_burst_dequeue_t)(void *qp_ctx,
313 struct rte_crypto_op **ops, uint16_t nb_ops);
315 /** The data structure associated with each mode of scheduler. */
316 struct rte_cryptodev_scheduler {
317 const char *name; /**< Scheduler name */
318 const char *description; /**< Scheduler description */
319 enum rte_cryptodev_scheduler_mode mode; /**< Scheduling mode */
321 /** Pointer to scheduler operation structure */
322 struct rte_cryptodev_scheduler_ops *ops;
325 /** Round-robin mode scheduler */
326 extern struct rte_cryptodev_scheduler *roundrobin_scheduler;
327 /** Packet-size based distribution mode scheduler */
328 extern struct rte_cryptodev_scheduler *pkt_size_based_distr_scheduler;
329 /** Fail-over mode scheduler */
330 extern struct rte_cryptodev_scheduler *failover_scheduler;
335 #endif /* _RTE_CRYPTO_SCHEDULER_H */