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
37 #include "rte_cryptodev_scheduler_operations.h"
44 * Crypto scheduler PMD operation modes
46 enum rte_cryptodev_scheduler_mode {
47 CDEV_SCHED_MODE_NOT_SET = 0,
48 CDEV_SCHED_MODE_USERDEFINED,
49 CDEV_SCHED_MODE_ROUNDROBIN,
50 /** packet-size based distribution mode */
51 CDEV_SCHED_MODE_PKT_SIZE_DISTR,
53 CDEV_SCHED_MODE_FAILOVER,
55 CDEV_SCHED_MODE_COUNT /* number of modes */
58 #define RTE_CRYPTODEV_SCHEDULER_NAME_MAX_LEN (64)
59 #define RTE_CRYPTODEV_SCHEDULER_DESC_MAX_LEN (256)
61 struct rte_cryptodev_scheduler;
64 * Load a user defined scheduler
66 * @param scheduler_id The target scheduler device ID
67 * scheduler Pointer to the user defined scheduler
70 * 0 if loading successful, negative integer if otherwise.
73 rte_cryptodev_scheduler_load_user_scheduler(uint8_t scheduler_id,
74 struct rte_cryptodev_scheduler *scheduler);
77 * Attach a pre-configured crypto device to the scheduler
79 * @param scheduler_id The target scheduler device ID
80 * slave_id crypto device ID to be attached
83 * 0 if attaching successful, negative int if otherwise.
86 rte_cryptodev_scheduler_slave_attach(uint8_t scheduler_id, uint8_t slave_id);
89 * Detach a attached crypto device to the scheduler
91 * @param scheduler_id The target scheduler device ID
92 * slave_id crypto device ID to be detached
95 * 0 if detaching successful, negative int if otherwise.
98 rte_cryptodev_scheduler_slave_detach(uint8_t scheduler_id, uint8_t slave_id);
101 * Set the scheduling mode
103 * @param scheduler_id The target scheduler device ID
104 * mode The scheduling mode
107 * 0 if attaching successful, negative integer if otherwise.
110 rte_crpytodev_scheduler_mode_set(uint8_t scheduler_id,
111 enum rte_cryptodev_scheduler_mode mode);
114 * Get the current scheduling mode
116 * @param scheduler_id The target scheduler device ID
117 * mode Pointer to write the scheduling mode
119 enum rte_cryptodev_scheduler_mode
120 rte_crpytodev_scheduler_mode_get(uint8_t scheduler_id);
123 * Set the crypto ops reordering feature on/off
125 * @param dev_id The target scheduler device ID
126 * enable_reorder set the crypto op reordering feature
127 * 0: disable reordering
128 * 1: enable reordering
131 * 0 if setting successful, negative integer if otherwise.
134 rte_cryptodev_scheduler_ordering_set(uint8_t scheduler_id,
135 uint32_t enable_reorder);
138 * Get the current crypto ops reordering feature
140 * @param dev_id The target scheduler device ID
143 * 0 if reordering is disabled
144 * 1 if reordering is enabled
145 * negative integer if otherwise.
148 rte_cryptodev_scheduler_ordering_get(uint8_t scheduler_id);
150 typedef uint16_t (*rte_cryptodev_scheduler_burst_enqueue_t)(void *qp_ctx,
151 struct rte_crypto_op **ops, uint16_t nb_ops);
153 typedef uint16_t (*rte_cryptodev_scheduler_burst_dequeue_t)(void *qp_ctx,
154 struct rte_crypto_op **ops, uint16_t nb_ops);
156 struct rte_cryptodev_scheduler {
158 const char *description;
159 enum rte_cryptodev_scheduler_mode mode;
161 struct rte_cryptodev_scheduler_ops *ops;
164 extern struct rte_cryptodev_scheduler *roundrobin_scheduler;
165 extern struct rte_cryptodev_scheduler *pkt_size_based_distr_scheduler;
166 extern struct rte_cryptodev_scheduler *failover_scheduler;
171 #endif /* _RTE_CRYPTO_SCHEDULER_H */