3 * Copyright(c) 2015-2016 Intel Corporation. All rights reserved.
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
9 * * Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in
13 * the documentation and/or other materials provided with the
15 * * Neither the name of Intel Corporation nor the names of its
16 * contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
21 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
22 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
23 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
24 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
25 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
26 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
27 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
28 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
29 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32 #ifndef _RTE_CRYPTODEV_H_
33 #define _RTE_CRYPTODEV_H_
36 * @file rte_cryptodev.h
38 * RTE Cryptographic Device APIs
40 * Defines RTE Crypto Device APIs for the provisioning of cipher and
41 * authentication operations.
43 * @b EXPERIMENTAL: this API may change without prior notice
51 #include "rte_kvargs.h"
52 #include "rte_crypto.h"
55 #define CRYPTODEV_NAME_NULL_PMD ("cryptodev_null_pmd")
56 /**< Null crypto PMD device name */
57 #define CRYPTODEV_NAME_AESNI_MB_PMD ("cryptodev_aesni_mb_pmd")
58 /**< AES-NI Multi buffer PMD device name */
59 #define CRYPTODEV_NAME_AESNI_GCM_PMD ("cryptodev_aesni_gcm_pmd")
60 /**< AES-NI GCM PMD device name */
61 #define CRYPTODEV_NAME_QAT_SYM_PMD ("cryptodev_qat_sym_pmd")
62 /**< Intel QAT Symmetric Crypto PMD device name */
63 #define CRYPTODEV_NAME_SNOW3G_PMD ("cryptodev_snow3g_pmd")
64 /**< SNOW 3G PMD device name */
66 /** Crypto device type */
67 enum rte_cryptodev_type {
68 RTE_CRYPTODEV_NULL_PMD = 1, /**< Null crypto PMD */
69 RTE_CRYPTODEV_AESNI_GCM_PMD, /**< AES-NI GCM PMD */
70 RTE_CRYPTODEV_AESNI_MB_PMD, /**< AES-NI multi buffer PMD */
71 RTE_CRYPTODEV_QAT_SYM_PMD, /**< QAT PMD Symmetric Crypto */
72 RTE_CRYPTODEV_SNOW3G_PMD, /**< SNOW 3G PMD */
75 extern const char **rte_cyptodev_names;
79 #define CDEV_LOG_ERR(fmt, args...) \
80 RTE_LOG(ERR, CRYPTODEV, "%s() line %u: " fmt "\n", \
81 __func__, __LINE__, ## args)
83 #define CDEV_PMD_LOG_ERR(dev, fmt, args...) \
84 RTE_LOG(ERR, CRYPTODEV, "[%s] %s() line %u: " fmt "\n", \
85 dev, __func__, __LINE__, ## args)
87 #ifdef RTE_LIBRTE_CRYPTODEV_DEBUG
88 #define CDEV_LOG_DEBUG(fmt, args...) \
89 RTE_LOG(DEBUG, CRYPTODEV, "%s() line %u: " fmt "\n", \
90 __func__, __LINE__, ## args) \
92 #define CDEV_PMD_TRACE(fmt, args...) \
93 RTE_LOG(DEBUG, CRYPTODEV, "[%s] %s: " fmt "\n", \
94 dev, __func__, ## args)
97 #define CDEV_LOG_DEBUG(fmt, args...)
98 #define CDEV_PMD_TRACE(fmt, args...)
102 * Symmetric Crypto Capability
104 struct rte_cryptodev_symmetric_capability {
105 enum rte_crypto_sym_xform_type xform_type;
106 /**< Transform type : Authentication / Cipher */
109 enum rte_crypto_auth_algorithm algo;
110 /**< authentication algorithm */
112 /**< algorithm block size */
114 uint16_t min; /**< minimum key size */
115 uint16_t max; /**< maximum key size */
117 /**< if a range of sizes are supported,
118 * this parameter is used to indicate
119 * increments in byte size that are supported
120 * between the minimum and maximum */
122 /**< auth key size range */
124 uint16_t min; /**< minimum digest size */
125 uint16_t max; /**< maximum digest size */
127 /**< if a range of sizes are supported,
128 * this parameter is used to indicate
129 * increments in byte size that are supported
130 * between the minimum and maximum */
132 /**< digest size range */
134 uint16_t min; /**< minimum aad size */
135 uint16_t max; /**< maximum aad size */
137 /**< if a range of sizes are supported,
138 * this parameter is used to indicate
139 * increments in byte size that are supported
140 * between the minimum and maximum */
142 /**< Additional authentication data size range */
144 /**< Symmetric Authentication transform capabilities */
146 enum rte_crypto_cipher_algorithm algo;
147 /**< cipher algorithm */
149 /**< algorithm block size */
151 uint16_t min; /**< minimum key size */
152 uint16_t max; /**< maximum key size */
154 /**< if a range of sizes are supported,
155 * this parameter is used to indicate
156 * increments in byte size that are supported
157 * between the minimum and maximum */
159 /**< cipher key size range */
161 uint16_t min; /**< minimum iv size */
162 uint16_t max; /**< maximum iv size */
164 /**< if a range of sizes are supported,
165 * this parameter is used to indicate
166 * increments in byte size that are supported
167 * between the minimum and maximum */
169 /**< Initialisation vector data size range */
171 /**< Symmetric Cipher transform capabilities */
175 /** Structure used to capture a capability of a crypto device */
176 struct rte_cryptodev_capabilities {
177 enum rte_crypto_op_type op;
178 /**< Operation type */
181 struct rte_cryptodev_symmetric_capability sym;
182 /**< Symmetric operation capability parameters */
186 /** Macro used at end of crypto PMD list */
187 #define RTE_CRYPTODEV_END_OF_CAPABILITIES_LIST() \
188 { RTE_CRYPTO_OP_TYPE_UNDEFINED }
192 * Crypto device supported feature flags
195 * New features flags should be added to the end of the list
197 * Keep these flags synchronised with rte_cryptodev_get_feature_name()
199 #define RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO (1ULL << 0)
200 /**< Symmetric crypto operations are supported */
201 #define RTE_CRYPTODEV_FF_ASYMMETRIC_CRYPTO (1ULL << 1)
202 /**< Asymmetric crypto operations are supported */
203 #define RTE_CRYPTODEV_FF_SYM_OPERATION_CHAINING (1ULL << 2)
204 /**< Chaining symmetric crypto operations are supported */
205 #define RTE_CRYPTODEV_FF_CPU_SSE (1ULL << 3)
206 /**< Utilises CPU SIMD SSE instructions */
207 #define RTE_CRYPTODEV_FF_CPU_AVX (1ULL << 4)
208 /**< Utilises CPU SIMD AVX instructions */
209 #define RTE_CRYPTODEV_FF_CPU_AVX2 (1ULL << 5)
210 /**< Utilises CPU SIMD AVX2 instructions */
211 #define RTE_CRYPTODEV_FF_CPU_AESNI (1ULL << 6)
212 /**< Utilises CPU AES-NI instructions */
213 #define RTE_CRYPTODEV_FF_HW_ACCELERATED (1ULL << 7)
214 /**< Operations are off-loaded to an external hardware accelerator */
218 * Get the name of a crypto device feature flag
220 * @param flag The mask describing the flag.
223 * The name of this flag, or NULL if it's not a valid feature flag.
227 rte_cryptodev_get_feature_name(uint64_t flag);
229 /** Crypto device information */
230 struct rte_cryptodev_info {
231 const char *driver_name; /**< Driver name. */
232 enum rte_cryptodev_type dev_type; /**< Device type */
233 struct rte_pci_device *pci_dev; /**< PCI information. */
235 uint64_t feature_flags; /**< Feature flags */
237 const struct rte_cryptodev_capabilities *capabilities;
238 /**< Array of devices supported capabilities */
240 unsigned max_nb_queue_pairs;
241 /**< Maximum number of queues pairs supported by device. */
244 unsigned max_nb_sessions;
245 /**< Maximum number of sessions supported by device. */
249 #define RTE_CRYPTODEV_DETACHED (0)
250 #define RTE_CRYPTODEV_ATTACHED (1)
252 /** Definitions of Crypto device event types */
253 enum rte_cryptodev_event_type {
254 RTE_CRYPTODEV_EVENT_UNKNOWN, /**< unknown event type */
255 RTE_CRYPTODEV_EVENT_ERROR, /**< error interrupt event */
256 RTE_CRYPTODEV_EVENT_MAX /**< max value of this enum */
259 /** Crypto device queue pair configuration structure. */
260 struct rte_cryptodev_qp_conf {
261 uint32_t nb_descriptors; /**< Number of descriptors per queue pair */
265 * Typedef for application callback function to be registered by application
266 * software for notification of device events
268 * @param dev_id Crypto device identifier
269 * @param event Crypto device event to register for notification of.
270 * @param cb_arg User specified parameter to be passed as to passed to
271 * users callback function.
273 typedef void (*rte_cryptodev_cb_fn)(uint8_t dev_id,
274 enum rte_cryptodev_event_type event, void *cb_arg);
277 /** Crypto Device statistics */
278 struct rte_cryptodev_stats {
279 uint64_t enqueued_count;
280 /**< Count of all operations enqueued */
281 uint64_t dequeued_count;
282 /**< Count of all operations dequeued */
284 uint64_t enqueue_err_count;
285 /**< Total error count on operations enqueued */
286 uint64_t dequeue_err_count;
287 /**< Total error count on operations dequeued */
290 #define RTE_CRYPTODEV_VDEV_DEFAULT_MAX_NB_QUEUE_PAIRS 8
291 #define RTE_CRYPTODEV_VDEV_DEFAULT_MAX_NB_SESSIONS 2048
295 * Initialisation parameters for virtual crypto devices
297 struct rte_crypto_vdev_init_params {
298 unsigned max_nb_queue_pairs;
299 unsigned max_nb_sessions;
303 #define RTE_CRYPTODEV_VDEV_MAX_NB_QP_ARG ("max_nb_queue_pairs")
304 #define RTE_CRYPTODEV_VDEV_MAX_NB_SESS_ARG ("max_nb_sessions")
305 #define RTE_CRYPTODEV_VDEV_SOCKET_ID ("socket_id")
307 static const char *cryptodev_vdev_valid_params[] = {
308 RTE_CRYPTODEV_VDEV_MAX_NB_QP_ARG,
309 RTE_CRYPTODEV_VDEV_MAX_NB_SESS_ARG,
310 RTE_CRYPTODEV_VDEV_SOCKET_ID
313 static inline uint8_t
314 number_of_sockets(void)
318 const struct rte_memseg *ms = rte_eal_get_physmem_layout();
320 for (i = 0; ((i < RTE_MAX_MEMSEG) && (ms[i].addr != NULL)); i++) {
321 if (sockets < ms[i].socket_id)
322 sockets = ms[i].socket_id;
325 /* Number of sockets = maximum socket_id + 1 */
329 /** Parse integer from integer argument */
331 __rte_cryptodev_parse_integer_arg(const char *key __rte_unused,
332 const char *value, void *extra_args)
334 int *i = (int *) extra_args;
338 CDEV_LOG_ERR("Argument has to be positive.");
346 * Parse virtual device initialisation parameters input arguments
349 * @params params Initialisation parameters with defaults set.
350 * @params input_args Command line arguments
353 * 0 on successful parse
354 * <0 on failure to parse
357 rte_cryptodev_parse_vdev_init_params(struct rte_crypto_vdev_init_params *params,
358 const char *input_args)
360 struct rte_kvargs *kvlist;
367 kvlist = rte_kvargs_parse(input_args,
368 cryptodev_vdev_valid_params);
372 ret = rte_kvargs_process(kvlist,
373 RTE_CRYPTODEV_VDEV_MAX_NB_QP_ARG,
374 &__rte_cryptodev_parse_integer_arg,
375 ¶ms->max_nb_queue_pairs);
379 ret = rte_kvargs_process(kvlist,
380 RTE_CRYPTODEV_VDEV_MAX_NB_SESS_ARG,
381 &__rte_cryptodev_parse_integer_arg,
382 ¶ms->max_nb_sessions);
386 ret = rte_kvargs_process(kvlist, RTE_CRYPTODEV_VDEV_SOCKET_ID,
387 &__rte_cryptodev_parse_integer_arg,
392 if (params->socket_id >= number_of_sockets()) {
393 CDEV_LOG_ERR("Invalid socket id specified to create "
394 "the virtual crypto device on");
402 rte_kvargs_free(kvlist);
407 * Create a virtual crypto device
409 * @param name Cryptodev PMD name of device to be created.
410 * @param args Options arguments for device.
413 * - On successful creation of the cryptodev the device index is returned,
414 * which will be between 0 and rte_cryptodev_count().
415 * - In the case of a failure, returns -1.
418 rte_cryptodev_create_vdev(const char *name, const char *args);
421 * Get the device identifier for the named crypto device.
423 * @param name device name to select the device structure.
426 * - Returns crypto device identifier on success.
427 * - Return -1 on failure to find named crypto device.
430 rte_cryptodev_get_dev_id(const char *name);
433 * Get the total number of crypto devices that have been successfully
437 * - The total number of usable crypto devices.
440 rte_cryptodev_count(void);
443 rte_cryptodev_count_devtype(enum rte_cryptodev_type type);
445 * Return the NUMA socket to which a device is connected
448 * The identifier of the device
450 * The NUMA socket id to which the device is connected or
451 * a default of zero if the socket could not be determined.
452 * -1 if returned is the dev_id value is out of range.
455 rte_cryptodev_socket_id(uint8_t dev_id);
457 /** Crypto device configuration structure */
458 struct rte_cryptodev_config {
459 int socket_id; /**< Socket to allocate resources on */
460 uint16_t nb_queue_pairs;
461 /**< Number of queue pairs to configure on device */
464 uint32_t nb_objs; /**< Number of objects in mempool */
465 uint32_t cache_size; /**< l-core object cache size */
466 } session_mp; /**< Session mempool configuration */
470 * Configure a device.
472 * This function must be invoked first before any other function in the
473 * API. This function can also be re-invoked when a device is in the
476 * @param dev_id The identifier of the device to configure.
477 * @param config The crypto device configuration structure.
480 * - 0: Success, device configured.
481 * - <0: Error code returned by the driver configuration function.
484 rte_cryptodev_configure(uint8_t dev_id, struct rte_cryptodev_config *config);
489 * The device start step is the last one and consists of setting the configured
490 * offload features and in starting the transmit and the receive units of the
492 * On success, all basic functions exported by the API (link status,
493 * receive/transmit, and so on) can be invoked.
496 * The identifier of the device.
498 * - 0: Success, device started.
499 * - <0: Error code of the driver device start function.
502 rte_cryptodev_start(uint8_t dev_id);
505 * Stop an device. The device can be restarted with a call to
506 * rte_cryptodev_start()
508 * @param dev_id The identifier of the device.
511 rte_cryptodev_stop(uint8_t dev_id);
514 * Close an device. The device cannot be restarted!
516 * @param dev_id The identifier of the device.
519 * - 0 on successfully closing device
520 * - <0 on failure to close device
523 rte_cryptodev_close(uint8_t dev_id);
526 * Allocate and set up a receive queue pair for a device.
529 * @param dev_id The identifier of the device.
530 * @param queue_pair_id The index of the queue pairs to set up. The
531 * value must be in the range [0, nb_queue_pair
532 * - 1] previously supplied to
533 * rte_cryptodev_configure().
534 * @param qp_conf The pointer to the configuration data to be
535 * used for the queue pair. NULL value is
536 * allowed, in which case default configuration
538 * @param socket_id The *socket_id* argument is the socket
539 * identifier in case of NUMA. The value can be
540 * *SOCKET_ID_ANY* if there is no NUMA constraint
541 * for the DMA memory allocated for the receive
545 * - 0: Success, queue pair correctly set up.
546 * - <0: Queue pair configuration failed
549 rte_cryptodev_queue_pair_setup(uint8_t dev_id, uint16_t queue_pair_id,
550 const struct rte_cryptodev_qp_conf *qp_conf, int socket_id);
553 * Start a specified queue pair of a device. It is used
554 * when deferred_start flag of the specified queue is true.
556 * @param dev_id The identifier of the device
557 * @param queue_pair_id The index of the queue pair to start. The value
558 * must be in the range [0, nb_queue_pair - 1]
559 * previously supplied to
560 * rte_crypto_dev_configure().
562 * - 0: Success, the transmit queue is correctly set up.
563 * - -EINVAL: The dev_id or the queue_id out of range.
564 * - -ENOTSUP: The function not supported in PMD driver.
567 rte_cryptodev_queue_pair_start(uint8_t dev_id, uint16_t queue_pair_id);
570 * Stop specified queue pair of a device
572 * @param dev_id The identifier of the device
573 * @param queue_pair_id The index of the queue pair to stop. The value
574 * must be in the range [0, nb_queue_pair - 1]
575 * previously supplied to
576 * rte_cryptodev_configure().
578 * - 0: Success, the transmit queue is correctly set up.
579 * - -EINVAL: The dev_id or the queue_id out of range.
580 * - -ENOTSUP: The function not supported in PMD driver.
583 rte_cryptodev_queue_pair_stop(uint8_t dev_id, uint16_t queue_pair_id);
586 * Get the number of queue pairs on a specific crypto device
588 * @param dev_id Crypto device identifier.
590 * - The number of configured queue pairs.
593 rte_cryptodev_queue_pair_count(uint8_t dev_id);
597 * Retrieve the general I/O statistics of a device.
599 * @param dev_id The identifier of the device.
600 * @param stats A pointer to a structure of type
601 * *rte_cryptodev_stats* to be filled with the
602 * values of device counters.
604 * - Zero if successful.
605 * - Non-zero otherwise.
608 rte_cryptodev_stats_get(uint8_t dev_id, struct rte_cryptodev_stats *stats);
611 * Reset the general I/O statistics of a device.
613 * @param dev_id The identifier of the device.
616 rte_cryptodev_stats_reset(uint8_t dev_id);
619 * Retrieve the contextual information of a device.
621 * @param dev_id The identifier of the device.
622 * @param dev_info A pointer to a structure of type
623 * *rte_cryptodev_info* to be filled with the
624 * contextual information of the device.
627 rte_cryptodev_info_get(uint8_t dev_id, struct rte_cryptodev_info *dev_info);
631 * Register a callback function for specific device id.
633 * @param dev_id Device id.
634 * @param event Event interested.
635 * @param cb_fn User supplied callback function to be called.
636 * @param cb_arg Pointer to the parameters for the registered
640 * - On success, zero.
641 * - On failure, a negative value.
644 rte_cryptodev_callback_register(uint8_t dev_id,
645 enum rte_cryptodev_event_type event,
646 rte_cryptodev_cb_fn cb_fn, void *cb_arg);
649 * Unregister a callback function for specific device id.
651 * @param dev_id The device identifier.
652 * @param event Event interested.
653 * @param cb_fn User supplied callback function to be called.
654 * @param cb_arg Pointer to the parameters for the registered
658 * - On success, zero.
659 * - On failure, a negative value.
662 rte_cryptodev_callback_unregister(uint8_t dev_id,
663 enum rte_cryptodev_event_type event,
664 rte_cryptodev_cb_fn cb_fn, void *cb_arg);
667 typedef uint16_t (*dequeue_pkt_burst_t)(void *qp,
668 struct rte_crypto_op **ops, uint16_t nb_ops);
669 /**< Dequeue processed packets from queue pair of a device. */
671 typedef uint16_t (*enqueue_pkt_burst_t)(void *qp,
672 struct rte_crypto_op **ops, uint16_t nb_ops);
673 /**< Enqueue packets for processing on queue pair of a device. */
678 struct rte_cryptodev_callback;
680 /** Structure to keep track of registered callbacks */
681 TAILQ_HEAD(rte_cryptodev_cb_list, rte_cryptodev_callback);
683 /** The data structure associated with each crypto device. */
684 struct rte_cryptodev {
685 dequeue_pkt_burst_t dequeue_burst;
686 /**< Pointer to PMD receive function. */
687 enqueue_pkt_burst_t enqueue_burst;
688 /**< Pointer to PMD transmit function. */
690 const struct rte_cryptodev_driver *driver;
691 /**< Driver for this device */
692 struct rte_cryptodev_data *data;
693 /**< Pointer to device data */
694 struct rte_cryptodev_ops *dev_ops;
695 /**< Functions exported by PMD */
696 uint64_t feature_flags;
697 /**< Supported features */
698 struct rte_pci_device *pci_dev;
699 /**< PCI info. supplied by probing */
701 enum rte_cryptodev_type dev_type;
702 /**< Crypto device type */
703 enum pmd_type pmd_type;
704 /**< PMD type - PDEV / VDEV */
706 struct rte_cryptodev_cb_list link_intr_cbs;
707 /**< User application callback for interrupts if present */
709 uint8_t attached : 1;
710 /**< Flag indicating the device is attached */
711 } __rte_cache_aligned;
714 #define RTE_CRYPTODEV_NAME_MAX_LEN (64)
715 /**< Max length of name of crypto PMD */
719 * The data part, with no function pointers, associated with each device.
721 * This structure is safe to place in shared memory to be common among
722 * different processes in a multi-process configuration.
724 struct rte_cryptodev_data {
726 /**< Device ID for this instance */
728 /**< Socket ID where memory is allocated */
729 char name[RTE_CRYPTODEV_NAME_MAX_LEN];
730 /**< Unique identifier name */
732 uint8_t dev_started : 1;
733 /**< Device state: STARTED(1)/STOPPED(0) */
735 struct rte_mempool *session_pool;
736 /**< Session memory pool */
738 /**< Array of pointers to queue pairs. */
739 uint16_t nb_queue_pairs;
740 /**< Number of device queue pairs. */
743 /**< PMD-specific private data */
744 } __rte_cache_aligned;
746 extern struct rte_cryptodev *rte_cryptodevs;
749 * Dequeue a burst of processed crypto operations from a queue on the crypto
750 * device. The dequeued operation are stored in *rte_crypto_op* structures
751 * whose pointers are supplied in the *ops* array.
753 * The rte_cryptodev_dequeue_burst() function returns the number of ops
754 * actually dequeued, which is the number of *rte_crypto_op* data structures
755 * effectively supplied into the *ops* array.
757 * A return value equal to *nb_ops* indicates that the queue contained
758 * at least *nb_ops* operations, and this is likely to signify that other
759 * processed operations remain in the devices output queue. Applications
760 * implementing a "retrieve as many processed operations as possible" policy
761 * can check this specific case and keep invoking the
762 * rte_cryptodev_dequeue_burst() function until a value less than
763 * *nb_ops* is returned.
765 * The rte_cryptodev_dequeue_burst() function does not provide any error
766 * notification to avoid the corresponding overhead.
768 * @param dev_id The symmetric crypto device identifier
769 * @param qp_id The index of the queue pair from which to
770 * retrieve processed packets. The value must be
771 * in the range [0, nb_queue_pair - 1] previously
772 * supplied to rte_cryptodev_configure().
773 * @param ops The address of an array of pointers to
774 * *rte_crypto_op* structures that must be
775 * large enough to store *nb_ops* pointers in it.
776 * @param nb_ops The maximum number of operations to dequeue.
779 * - The number of operations actually dequeued, which is the number
780 * of pointers to *rte_crypto_op* structures effectively supplied to the
783 static inline uint16_t
784 rte_cryptodev_dequeue_burst(uint8_t dev_id, uint16_t qp_id,
785 struct rte_crypto_op **ops, uint16_t nb_ops)
787 struct rte_cryptodev *dev = &rte_cryptodevs[dev_id];
789 nb_ops = (*dev->dequeue_burst)
790 (dev->data->queue_pairs[qp_id], ops, nb_ops);
796 * Enqueue a burst of operations for processing on a crypto device.
798 * The rte_cryptodev_enqueue_burst() function is invoked to place
799 * crypto operations on the queue *qp_id* of the device designated by
802 * The *nb_ops* parameter is the number of operations to process which are
803 * supplied in the *ops* array of *rte_crypto_op* structures.
805 * The rte_cryptodev_enqueue_burst() function returns the number of
806 * operations it actually enqueued for processing. A return value equal to
807 * *nb_ops* means that all packets have been enqueued.
809 * @param dev_id The identifier of the device.
810 * @param qp_id The index of the queue pair which packets are
811 * to be enqueued for processing. The value
812 * must be in the range [0, nb_queue_pairs - 1]
813 * previously supplied to
814 * *rte_cryptodev_configure*.
815 * @param ops The address of an array of *nb_ops* pointers
816 * to *rte_crypto_op* structures which contain
817 * the crypto operations to be processed.
818 * @param nb_ops The number of operations to process.
821 * The number of operations actually enqueued on the crypto device. The return
822 * value can be less than the value of the *nb_ops* parameter when the
823 * crypto devices queue is full or if invalid parameters are specified in
826 static inline uint16_t
827 rte_cryptodev_enqueue_burst(uint8_t dev_id, uint16_t qp_id,
828 struct rte_crypto_op **ops, uint16_t nb_ops)
830 struct rte_cryptodev *dev = &rte_cryptodevs[dev_id];
832 return (*dev->enqueue_burst)(
833 dev->data->queue_pairs[qp_id], ops, nb_ops);
837 /** Cryptodev symmetric crypto session */
838 struct rte_cryptodev_sym_session {
842 enum rte_cryptodev_type type;
843 /** Crypto Device type session created on */
844 struct rte_mempool *mp;
845 /**< Mempool session allocated from */
847 /**< Public symmetric session details */
850 /**< Private session material */
855 * Initialise a session for symmetric cryptographic operations.
857 * This function is used by the client to initialize immutable
858 * parameters of symmetric cryptographic operation.
859 * To perform the operation the rte_cryptodev_enqueue_burst function is
860 * used. Each mbuf should contain a reference to the session
861 * pointer returned from this function contained within it's crypto_op if a
862 * session-based operation is being provisioned. Memory to contain the session
863 * information is allocated from within mempool managed by the cryptodev.
865 * The rte_cryptodev_session_free must be called to free allocated
866 * memory when the session is no longer required.
868 * @param dev_id The device identifier.
869 * @param xform Crypto transform chain.
873 * Pointer to the created session or NULL
875 extern struct rte_cryptodev_sym_session *
876 rte_cryptodev_sym_session_create(uint8_t dev_id,
877 struct rte_crypto_sym_xform *xform);
880 * Free the memory associated with a previously allocated session.
882 * @param dev_id The device identifier.
883 * @param session Session pointer previously allocated by
884 * *rte_cryptodev_sym_session_create*.
887 * NULL on successful freeing of session.
888 * Session pointer on failure to free session.
890 extern struct rte_cryptodev_sym_session *
891 rte_cryptodev_sym_session_free(uint8_t dev_id,
892 struct rte_cryptodev_sym_session *session);
899 #endif /* _RTE_CRYPTODEV_H_ */