1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright(c) 2017 Intel Corporation
5 #ifndef _RTE_CRYPTO_SCHEDULER_H
6 #define _RTE_CRYPTO_SCHEDULER_H
9 * @file rte_cryptodev_scheduler.h
11 * RTE Cryptodev Scheduler Device
13 * The RTE Cryptodev Scheduler Device allows the aggregation of multiple (slave)
14 * Cryptodevs into a single logical crypto device, and the scheduling the
15 * crypto operations to the slaves based on the mode of the specified mode of
16 * operation specified and supported. This implementation supports 3 modes of
17 * operation: round robin, packet-size based, and fail-over.
21 #include "rte_cryptodev_scheduler_operations.h"
27 /** Maximum number of bonded devices per device */
28 #ifndef RTE_CRYPTODEV_SCHEDULER_MAX_NB_SLAVES
29 #define RTE_CRYPTODEV_SCHEDULER_MAX_NB_SLAVES (8)
32 /** Maximum number of multi-core worker cores */
33 #define RTE_CRYPTODEV_SCHEDULER_MAX_NB_WORKER_CORES (RTE_MAX_LCORE - 1)
35 /** Round-robin scheduling mode string */
36 #define SCHEDULER_MODE_NAME_ROUND_ROBIN round-robin
37 /** Packet-size based distribution scheduling mode string */
38 #define SCHEDULER_MODE_NAME_PKT_SIZE_DISTR packet-size-distr
39 /** Fail-over scheduling mode string */
40 #define SCHEDULER_MODE_NAME_FAIL_OVER fail-over
41 /** multi-core scheduling mode string */
42 #define SCHEDULER_MODE_NAME_MULTI_CORE multi-core
45 * Crypto scheduler PMD operation modes
47 enum rte_cryptodev_scheduler_mode {
48 CDEV_SCHED_MODE_NOT_SET = 0,
49 /** User defined mode */
50 CDEV_SCHED_MODE_USERDEFINED,
51 /** Round-robin mode */
52 CDEV_SCHED_MODE_ROUNDROBIN,
53 /** Packet-size based distribution mode */
54 CDEV_SCHED_MODE_PKT_SIZE_DISTR,
56 CDEV_SCHED_MODE_FAILOVER,
57 /** multi-core mode */
58 CDEV_SCHED_MODE_MULTICORE,
60 CDEV_SCHED_MODE_COUNT /**< number of modes */
63 #define RTE_CRYPTODEV_SCHEDULER_NAME_MAX_LEN (64)
64 #define RTE_CRYPTODEV_SCHEDULER_DESC_MAX_LEN (256)
67 * Crypto scheduler option types
69 enum rte_cryptodev_schedule_option_type {
70 CDEV_SCHED_OPTION_NOT_SET = 0,
71 CDEV_SCHED_OPTION_THRESHOLD,
73 CDEV_SCHED_OPTION_COUNT
77 * Threshold option structure
79 #define RTE_CRYPTODEV_SCHEDULER_PARAM_THRES "threshold"
80 struct rte_cryptodev_scheduler_threshold_option {
81 uint32_t threshold; /**< Threshold for packet-size mode */
84 struct rte_cryptodev_scheduler;
87 * Load a user defined scheduler
90 * The target scheduler device ID
92 * Pointer to the user defined scheduler
95 * - 0 if the scheduler is successfully loaded
96 * - -ENOTSUP if the operation is not supported.
97 * - -EBUSY if device is started.
98 * - -EINVAL if input values are invalid.
101 rte_cryptodev_scheduler_load_user_scheduler(uint8_t scheduler_id,
102 struct rte_cryptodev_scheduler *scheduler);
105 * Attach a crypto device to the scheduler
107 * @param scheduler_id
108 * The target scheduler device ID
110 * Crypto device ID to be attached
113 * - 0 if the slave is attached.
114 * - -ENOTSUP if the operation is not supported.
115 * - -EBUSY if device is started.
116 * - -ENOMEM if the scheduler's slave list is full.
119 rte_cryptodev_scheduler_slave_attach(uint8_t scheduler_id, uint8_t slave_id);
122 * Detach a crypto device from the scheduler
124 * @param scheduler_id
125 * The target scheduler device ID
127 * Crypto device ID to be detached
130 * - 0 if the slave is detached.
131 * - -ENOTSUP if the operation is not supported.
132 * - -EBUSY if device is started.
135 rte_cryptodev_scheduler_slave_detach(uint8_t scheduler_id, uint8_t slave_id);
139 * Set the scheduling mode
141 * @param scheduler_id
142 * The target scheduler device ID
144 * The scheduling mode
147 * - 0 if the mode is set.
148 * - -ENOTSUP if the operation is not supported.
149 * - -EBUSY if device is started.
152 rte_cryptodev_scheduler_mode_set(uint8_t scheduler_id,
153 enum rte_cryptodev_scheduler_mode mode);
156 * Get the current scheduling mode
158 * @param scheduler_id
159 * The target scheduler device ID
162 * - non-negative enumerate value: the scheduling mode
163 * - -ENOTSUP if the operation is not supported.
165 enum rte_cryptodev_scheduler_mode
166 rte_cryptodev_scheduler_mode_get(uint8_t scheduler_id);
169 * Set the crypto ops reordering feature on/off
171 * @param scheduler_id
172 * The target scheduler device ID
173 * @param enable_reorder
174 * Set the crypto op reordering feature
175 * - 0: disable reordering
176 * - 1: enable reordering
179 * - 0 if the ordering is set.
180 * - -ENOTSUP if the operation is not supported.
181 * - -EBUSY if device is started.
184 rte_cryptodev_scheduler_ordering_set(uint8_t scheduler_id,
185 uint32_t enable_reorder);
188 * Get the current crypto ops reordering feature
190 * @param scheduler_id
191 * The target scheduler device ID
194 * - 0 if reordering is disabled
195 * - 1 if reordering is enabled
196 * - -ENOTSUP if the operation is not supported.
199 rte_cryptodev_scheduler_ordering_get(uint8_t scheduler_id);
202 * Get the attached slaves' count and/or ID
204 * @param scheduler_id
205 * The target scheduler device ID
207 * If successful, the function will write back all slaves' device IDs to it.
208 * This parameter will either be an uint8_t array of
209 * RTE_CRYPTODEV_SCHEDULER_MAX_NB_SLAVES elements or NULL.
212 * - non-negative number: the number of slaves attached
213 * - -ENOTSUP if the operation is not supported.
216 rte_cryptodev_scheduler_slaves_get(uint8_t scheduler_id, uint8_t *slaves);
219 * Set the mode specific option
221 * @param scheduler_id
222 * The target scheduler device ID
224 * The option type enumerate
226 * The specific mode's option structure
230 * - negative integer if otherwise.
233 rte_cryptodev_scheduler_option_set(uint8_t scheduler_id,
234 enum rte_cryptodev_schedule_option_type option_type,
238 * Set the mode specific option
240 * @param scheduler_id
241 * The target scheduler device ID
243 * The option type enumerate
245 * If successful, the function will write back the current
249 * - negative integer if otherwise.
252 rte_cryptodev_scheduler_option_get(uint8_t scheduler_id,
253 enum rte_cryptodev_schedule_option_type option_type,
256 typedef uint16_t (*rte_cryptodev_scheduler_burst_enqueue_t)(void *qp_ctx,
257 struct rte_crypto_op **ops, uint16_t nb_ops);
259 typedef uint16_t (*rte_cryptodev_scheduler_burst_dequeue_t)(void *qp_ctx,
260 struct rte_crypto_op **ops, uint16_t nb_ops);
262 /** The data structure associated with each mode of scheduler. */
263 struct rte_cryptodev_scheduler {
264 const char *name; /**< Scheduler name */
265 const char *description; /**< Scheduler description */
266 enum rte_cryptodev_scheduler_mode mode; /**< Scheduling mode */
268 /** Pointer to scheduler operation structure */
269 struct rte_cryptodev_scheduler_ops *ops;
272 /** Round-robin mode scheduler */
273 extern struct rte_cryptodev_scheduler *roundrobin_scheduler;
274 /** Packet-size based distribution mode scheduler */
275 extern struct rte_cryptodev_scheduler *pkt_size_based_distr_scheduler;
276 /** Fail-over mode scheduler */
277 extern struct rte_cryptodev_scheduler *failover_scheduler;
278 /** multi-core mode scheduler */
279 extern struct rte_cryptodev_scheduler *multicore_scheduler;
284 #endif /* _RTE_CRYPTO_SCHEDULER_H */