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.
48 #include "rte_kvargs.h"
49 #include "rte_crypto.h"
51 #include <rte_common.h>
53 #define CRYPTODEV_NAME_NULL_PMD crypto_null
54 /**< Null crypto PMD device name */
55 #define CRYPTODEV_NAME_AESNI_MB_PMD crypto_aesni_mb
56 /**< AES-NI Multi buffer PMD device name */
57 #define CRYPTODEV_NAME_AESNI_GCM_PMD crypto_aesni_gcm
58 /**< AES-NI GCM PMD device name */
59 #define CRYPTODEV_NAME_OPENSSL_PMD crypto_openssl
60 /**< Open SSL Crypto PMD device name */
61 #define CRYPTODEV_NAME_QAT_SYM_PMD crypto_qat
62 /**< Intel QAT Symmetric Crypto PMD device name */
63 #define CRYPTODEV_NAME_SNOW3G_PMD crypto_snow3g
64 /**< SNOW 3G PMD device name */
65 #define CRYPTODEV_NAME_KASUMI_PMD crypto_kasumi
66 /**< KASUMI PMD device name */
67 #define CRYPTODEV_NAME_ZUC_PMD crypto_zuc
68 /**< KASUMI PMD device name */
69 #define CRYPTODEV_NAME_ARMV8_PMD crypto_armv8
70 /**< ARMv8 Crypto PMD device name */
72 /** Crypto device type */
73 enum rte_cryptodev_type {
74 RTE_CRYPTODEV_NULL_PMD = 1, /**< Null crypto PMD */
75 RTE_CRYPTODEV_AESNI_GCM_PMD, /**< AES-NI GCM PMD */
76 RTE_CRYPTODEV_AESNI_MB_PMD, /**< AES-NI multi buffer PMD */
77 RTE_CRYPTODEV_QAT_SYM_PMD, /**< QAT PMD Symmetric Crypto */
78 RTE_CRYPTODEV_SNOW3G_PMD, /**< SNOW 3G PMD */
79 RTE_CRYPTODEV_KASUMI_PMD, /**< KASUMI PMD */
80 RTE_CRYPTODEV_ZUC_PMD, /**< ZUC PMD */
81 RTE_CRYPTODEV_OPENSSL_PMD, /**< OpenSSL PMD */
82 RTE_CRYPTODEV_ARMV8_PMD, /**< ARMv8 crypto PMD */
85 extern const char **rte_cyptodev_names;
89 #define CDEV_LOG_ERR(...) \
90 RTE_LOG(ERR, CRYPTODEV, \
91 RTE_FMT("%s() line %u: " RTE_FMT_HEAD(__VA_ARGS__,) "\n", \
92 __func__, __LINE__, RTE_FMT_TAIL(__VA_ARGS__,)))
94 #define CDEV_PMD_LOG_ERR(dev, ...) \
95 RTE_LOG(ERR, CRYPTODEV, \
96 RTE_FMT("[%s] %s() line %u: " RTE_FMT_HEAD(__VA_ARGS__,) "\n", \
97 dev, __func__, __LINE__, RTE_FMT_TAIL(__VA_ARGS__,)))
99 #ifdef RTE_LIBRTE_CRYPTODEV_DEBUG
100 #define CDEV_LOG_DEBUG(...) \
101 RTE_LOG(DEBUG, CRYPTODEV, \
102 RTE_FMT("%s() line %u: " RTE_FMT_HEAD(__VA_ARGS__,) "\n", \
103 __func__, __LINE__, RTE_FMT_TAIL(__VA_ARGS__,)))
105 #define CDEV_PMD_TRACE(...) \
106 RTE_LOG(DEBUG, CRYPTODEV, \
107 RTE_FMT("[%s] %s: " RTE_FMT_HEAD(__VA_ARGS__,) "\n", \
108 dev, __func__, RTE_FMT_TAIL(__VA_ARGS__,)))
111 #define CDEV_LOG_DEBUG(...) (void)0
112 #define CDEV_PMD_TRACE(...) (void)0
116 * Symmetric Crypto Capability
118 struct rte_cryptodev_symmetric_capability {
119 enum rte_crypto_sym_xform_type xform_type;
120 /**< Transform type : Authentication / Cipher */
124 enum rte_crypto_auth_algorithm algo;
125 /**< authentication algorithm */
127 /**< algorithm block size */
129 uint16_t min; /**< minimum key size */
130 uint16_t max; /**< maximum key size */
132 /**< if a range of sizes are supported,
133 * this parameter is used to indicate
134 * increments in byte size that are supported
135 * between the minimum and maximum */
137 /**< auth key size range */
139 uint16_t min; /**< minimum digest size */
140 uint16_t max; /**< maximum digest size */
142 /**< if a range of sizes are supported,
143 * this parameter is used to indicate
144 * increments in byte size that are supported
145 * between the minimum and maximum */
147 /**< digest size range */
149 uint16_t min; /**< minimum aad size */
150 uint16_t max; /**< maximum aad size */
152 /**< if a range of sizes are supported,
153 * this parameter is used to indicate
154 * increments in byte size that are supported
155 * between the minimum and maximum */
157 /**< Additional authentication data size range */
159 /**< Symmetric Authentication transform capabilities */
161 enum rte_crypto_cipher_algorithm algo;
162 /**< cipher algorithm */
164 /**< algorithm block size */
166 uint16_t min; /**< minimum key size */
167 uint16_t max; /**< maximum key size */
169 /**< if a range of sizes are supported,
170 * this parameter is used to indicate
171 * increments in byte size that are supported
172 * between the minimum and maximum */
174 /**< cipher key size range */
176 uint16_t min; /**< minimum iv size */
177 uint16_t max; /**< maximum iv size */
179 /**< if a range of sizes are supported,
180 * this parameter is used to indicate
181 * increments in byte size that are supported
182 * between the minimum and maximum */
184 /**< Initialisation vector data size range */
186 /**< Symmetric Cipher transform capabilities */
190 /** Structure used to capture a capability of a crypto device */
191 struct rte_cryptodev_capabilities {
192 enum rte_crypto_op_type op;
193 /**< Operation type */
197 struct rte_cryptodev_symmetric_capability sym;
198 /**< Symmetric operation capability parameters */
202 /** Macro used at end of crypto PMD list */
203 #define RTE_CRYPTODEV_END_OF_CAPABILITIES_LIST() \
204 { RTE_CRYPTO_OP_TYPE_UNDEFINED }
208 * Crypto device supported feature flags
211 * New features flags should be added to the end of the list
213 * Keep these flags synchronised with rte_cryptodev_get_feature_name()
215 #define RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO (1ULL << 0)
216 /**< Symmetric crypto operations are supported */
217 #define RTE_CRYPTODEV_FF_ASYMMETRIC_CRYPTO (1ULL << 1)
218 /**< Asymmetric crypto operations are supported */
219 #define RTE_CRYPTODEV_FF_SYM_OPERATION_CHAINING (1ULL << 2)
220 /**< Chaining symmetric crypto operations are supported */
221 #define RTE_CRYPTODEV_FF_CPU_SSE (1ULL << 3)
222 /**< Utilises CPU SIMD SSE instructions */
223 #define RTE_CRYPTODEV_FF_CPU_AVX (1ULL << 4)
224 /**< Utilises CPU SIMD AVX instructions */
225 #define RTE_CRYPTODEV_FF_CPU_AVX2 (1ULL << 5)
226 /**< Utilises CPU SIMD AVX2 instructions */
227 #define RTE_CRYPTODEV_FF_CPU_AESNI (1ULL << 6)
228 /**< Utilises CPU AES-NI instructions */
229 #define RTE_CRYPTODEV_FF_HW_ACCELERATED (1ULL << 7)
230 /**< Operations are off-loaded to an external hardware accelerator */
231 #define RTE_CRYPTODEV_FF_CPU_AVX512 (1ULL << 8)
232 /**< Utilises CPU SIMD AVX512 instructions */
233 #define RTE_CRYPTODEV_FF_MBUF_SCATTER_GATHER (1ULL << 9)
234 /**< Scatter-gather mbufs are supported */
238 * Get the name of a crypto device feature flag
240 * @param flag The mask describing the flag.
243 * The name of this flag, or NULL if it's not a valid feature flag.
247 rte_cryptodev_get_feature_name(uint64_t flag);
249 /** Crypto device information */
250 struct rte_cryptodev_info {
251 const char *driver_name; /**< Driver name. */
252 enum rte_cryptodev_type dev_type; /**< Device type */
253 struct rte_pci_device *pci_dev; /**< PCI information. */
255 uint64_t feature_flags; /**< Feature flags */
257 const struct rte_cryptodev_capabilities *capabilities;
258 /**< Array of devices supported capabilities */
260 unsigned max_nb_queue_pairs;
261 /**< Maximum number of queues pairs supported by device. */
264 unsigned max_nb_sessions;
265 /**< Maximum number of sessions supported by device. */
269 #define RTE_CRYPTODEV_DETACHED (0)
270 #define RTE_CRYPTODEV_ATTACHED (1)
272 /** Definitions of Crypto device event types */
273 enum rte_cryptodev_event_type {
274 RTE_CRYPTODEV_EVENT_UNKNOWN, /**< unknown event type */
275 RTE_CRYPTODEV_EVENT_ERROR, /**< error interrupt event */
276 RTE_CRYPTODEV_EVENT_MAX /**< max value of this enum */
279 /** Crypto device queue pair configuration structure. */
280 struct rte_cryptodev_qp_conf {
281 uint32_t nb_descriptors; /**< Number of descriptors per queue pair */
285 * Typedef for application callback function to be registered by application
286 * software for notification of device events
288 * @param dev_id Crypto device identifier
289 * @param event Crypto device event to register for notification of.
290 * @param cb_arg User specified parameter to be passed as to passed to
291 * users callback function.
293 typedef void (*rte_cryptodev_cb_fn)(uint8_t dev_id,
294 enum rte_cryptodev_event_type event, void *cb_arg);
297 /** Crypto Device statistics */
298 struct rte_cryptodev_stats {
299 uint64_t enqueued_count;
300 /**< Count of all operations enqueued */
301 uint64_t dequeued_count;
302 /**< Count of all operations dequeued */
304 uint64_t enqueue_err_count;
305 /**< Total error count on operations enqueued */
306 uint64_t dequeue_err_count;
307 /**< Total error count on operations dequeued */
310 #define RTE_CRYPTODEV_NAME_MAX_LEN (64)
311 /**< Max length of name of crypto PMD */
312 #define RTE_CRYPTODEV_VDEV_DEFAULT_MAX_NB_QUEUE_PAIRS 8
313 #define RTE_CRYPTODEV_VDEV_DEFAULT_MAX_NB_SESSIONS 2048
317 * Initialisation parameters for virtual crypto devices
319 struct rte_crypto_vdev_init_params {
320 unsigned max_nb_queue_pairs;
321 unsigned max_nb_sessions;
323 char name[RTE_CRYPTODEV_NAME_MAX_LEN];
327 * Parse virtual device initialisation parameters input arguments
330 * @params params Initialisation parameters with defaults set.
331 * @params input_args Command line arguments
334 * 0 on successful parse
335 * <0 on failure to parse
338 rte_cryptodev_parse_vdev_init_params(
339 struct rte_crypto_vdev_init_params *params,
340 const char *input_args);
343 * Create a virtual crypto device
345 * @param name Cryptodev PMD name of device to be created.
346 * @param args Options arguments for device.
349 * - On successful creation of the cryptodev the device index is returned,
350 * which will be between 0 and rte_cryptodev_count().
351 * - In the case of a failure, returns -1.
354 rte_cryptodev_create_vdev(const char *name, const char *args);
357 * Get the device identifier for the named crypto device.
359 * @param name device name to select the device structure.
362 * - Returns crypto device identifier on success.
363 * - Return -1 on failure to find named crypto device.
366 rte_cryptodev_get_dev_id(const char *name);
369 * Get the total number of crypto devices that have been successfully
373 * - The total number of usable crypto devices.
376 rte_cryptodev_count(void);
379 rte_cryptodev_count_devtype(enum rte_cryptodev_type type);
381 * Return the NUMA socket to which a device is connected
384 * The identifier of the device
386 * The NUMA socket id to which the device is connected or
387 * a default of zero if the socket could not be determined.
388 * -1 if returned is the dev_id value is out of range.
391 rte_cryptodev_socket_id(uint8_t dev_id);
393 /** Crypto device configuration structure */
394 struct rte_cryptodev_config {
395 int socket_id; /**< Socket to allocate resources on */
396 uint16_t nb_queue_pairs;
397 /**< Number of queue pairs to configure on device */
400 uint32_t nb_objs; /**< Number of objects in mempool */
401 uint32_t cache_size; /**< l-core object cache size */
402 } session_mp; /**< Session mempool configuration */
406 * Configure a device.
408 * This function must be invoked first before any other function in the
409 * API. This function can also be re-invoked when a device is in the
412 * @param dev_id The identifier of the device to configure.
413 * @param config The crypto device configuration structure.
416 * - 0: Success, device configured.
417 * - <0: Error code returned by the driver configuration function.
420 rte_cryptodev_configure(uint8_t dev_id, struct rte_cryptodev_config *config);
425 * The device start step is the last one and consists of setting the configured
426 * offload features and in starting the transmit and the receive units of the
428 * On success, all basic functions exported by the API (link status,
429 * receive/transmit, and so on) can be invoked.
432 * The identifier of the device.
434 * - 0: Success, device started.
435 * - <0: Error code of the driver device start function.
438 rte_cryptodev_start(uint8_t dev_id);
441 * Stop an device. The device can be restarted with a call to
442 * rte_cryptodev_start()
444 * @param dev_id The identifier of the device.
447 rte_cryptodev_stop(uint8_t dev_id);
450 * Close an device. The device cannot be restarted!
452 * @param dev_id The identifier of the device.
455 * - 0 on successfully closing device
456 * - <0 on failure to close device
459 rte_cryptodev_close(uint8_t dev_id);
462 * Allocate and set up a receive queue pair for a device.
465 * @param dev_id The identifier of the device.
466 * @param queue_pair_id The index of the queue pairs to set up. The
467 * value must be in the range [0, nb_queue_pair
468 * - 1] previously supplied to
469 * rte_cryptodev_configure().
470 * @param qp_conf The pointer to the configuration data to be
471 * used for the queue pair. NULL value is
472 * allowed, in which case default configuration
474 * @param socket_id The *socket_id* argument is the socket
475 * identifier in case of NUMA. The value can be
476 * *SOCKET_ID_ANY* if there is no NUMA constraint
477 * for the DMA memory allocated for the receive
481 * - 0: Success, queue pair correctly set up.
482 * - <0: Queue pair configuration failed
485 rte_cryptodev_queue_pair_setup(uint8_t dev_id, uint16_t queue_pair_id,
486 const struct rte_cryptodev_qp_conf *qp_conf, int socket_id);
489 * Start a specified queue pair of a device. It is used
490 * when deferred_start flag of the specified queue is true.
492 * @param dev_id The identifier of the device
493 * @param queue_pair_id The index of the queue pair to start. The value
494 * must be in the range [0, nb_queue_pair - 1]
495 * previously supplied to
496 * rte_crypto_dev_configure().
498 * - 0: Success, the transmit queue is correctly set up.
499 * - -EINVAL: The dev_id or the queue_id out of range.
500 * - -ENOTSUP: The function not supported in PMD driver.
503 rte_cryptodev_queue_pair_start(uint8_t dev_id, uint16_t queue_pair_id);
506 * Stop specified queue pair of a device
508 * @param dev_id The identifier of the device
509 * @param queue_pair_id The index of the queue pair to stop. The value
510 * must be in the range [0, nb_queue_pair - 1]
511 * previously supplied to
512 * rte_cryptodev_configure().
514 * - 0: Success, the transmit queue is correctly set up.
515 * - -EINVAL: The dev_id or the queue_id out of range.
516 * - -ENOTSUP: The function not supported in PMD driver.
519 rte_cryptodev_queue_pair_stop(uint8_t dev_id, uint16_t queue_pair_id);
522 * Get the number of queue pairs on a specific crypto device
524 * @param dev_id Crypto device identifier.
526 * - The number of configured queue pairs.
529 rte_cryptodev_queue_pair_count(uint8_t dev_id);
533 * Retrieve the general I/O statistics of a device.
535 * @param dev_id The identifier of the device.
536 * @param stats A pointer to a structure of type
537 * *rte_cryptodev_stats* to be filled with the
538 * values of device counters.
540 * - Zero if successful.
541 * - Non-zero otherwise.
544 rte_cryptodev_stats_get(uint8_t dev_id, struct rte_cryptodev_stats *stats);
547 * Reset the general I/O statistics of a device.
549 * @param dev_id The identifier of the device.
552 rte_cryptodev_stats_reset(uint8_t dev_id);
555 * Retrieve the contextual information of a device.
557 * @param dev_id The identifier of the device.
558 * @param dev_info A pointer to a structure of type
559 * *rte_cryptodev_info* to be filled with the
560 * contextual information of the device.
563 rte_cryptodev_info_get(uint8_t dev_id, struct rte_cryptodev_info *dev_info);
567 * Register a callback function for specific device id.
569 * @param dev_id Device id.
570 * @param event Event interested.
571 * @param cb_fn User supplied callback function to be called.
572 * @param cb_arg Pointer to the parameters for the registered
576 * - On success, zero.
577 * - On failure, a negative value.
580 rte_cryptodev_callback_register(uint8_t dev_id,
581 enum rte_cryptodev_event_type event,
582 rte_cryptodev_cb_fn cb_fn, void *cb_arg);
585 * Unregister a callback function for specific device id.
587 * @param dev_id The device identifier.
588 * @param event Event interested.
589 * @param cb_fn User supplied callback function to be called.
590 * @param cb_arg Pointer to the parameters for the registered
594 * - On success, zero.
595 * - On failure, a negative value.
598 rte_cryptodev_callback_unregister(uint8_t dev_id,
599 enum rte_cryptodev_event_type event,
600 rte_cryptodev_cb_fn cb_fn, void *cb_arg);
603 typedef uint16_t (*dequeue_pkt_burst_t)(void *qp,
604 struct rte_crypto_op **ops, uint16_t nb_ops);
605 /**< Dequeue processed packets from queue pair of a device. */
607 typedef uint16_t (*enqueue_pkt_burst_t)(void *qp,
608 struct rte_crypto_op **ops, uint16_t nb_ops);
609 /**< Enqueue packets for processing on queue pair of a device. */
614 struct rte_cryptodev_callback;
616 /** Structure to keep track of registered callbacks */
617 TAILQ_HEAD(rte_cryptodev_cb_list, rte_cryptodev_callback);
619 /** The data structure associated with each crypto device. */
620 struct rte_cryptodev {
621 dequeue_pkt_burst_t dequeue_burst;
622 /**< Pointer to PMD receive function. */
623 enqueue_pkt_burst_t enqueue_burst;
624 /**< Pointer to PMD transmit function. */
626 const struct rte_cryptodev_driver *driver;
627 /**< Driver for this device */
628 struct rte_cryptodev_data *data;
629 /**< Pointer to device data */
630 struct rte_cryptodev_ops *dev_ops;
631 /**< Functions exported by PMD */
632 uint64_t feature_flags;
633 /**< Supported features */
634 struct rte_pci_device *pci_dev;
635 /**< PCI info. supplied by probing */
637 enum rte_cryptodev_type dev_type;
638 /**< Crypto device type */
640 struct rte_cryptodev_cb_list link_intr_cbs;
641 /**< User application callback for interrupts if present */
644 uint8_t attached : 1;
645 /**< Flag indicating the device is attached */
646 } __rte_cache_aligned;
650 * The data part, with no function pointers, associated with each device.
652 * This structure is safe to place in shared memory to be common among
653 * different processes in a multi-process configuration.
655 struct rte_cryptodev_data {
657 /**< Device ID for this instance */
659 /**< Socket ID where memory is allocated */
660 char name[RTE_CRYPTODEV_NAME_MAX_LEN];
661 /**< Unique identifier name */
664 uint8_t dev_started : 1;
665 /**< Device state: STARTED(1)/STOPPED(0) */
667 struct rte_mempool *session_pool;
668 /**< Session memory pool */
670 /**< Array of pointers to queue pairs. */
671 uint16_t nb_queue_pairs;
672 /**< Number of device queue pairs. */
675 /**< PMD-specific private data */
676 } __rte_cache_aligned;
678 extern struct rte_cryptodev *rte_cryptodevs;
681 * Dequeue a burst of processed crypto operations from a queue on the crypto
682 * device. The dequeued operation are stored in *rte_crypto_op* structures
683 * whose pointers are supplied in the *ops* array.
685 * The rte_cryptodev_dequeue_burst() function returns the number of ops
686 * actually dequeued, which is the number of *rte_crypto_op* data structures
687 * effectively supplied into the *ops* array.
689 * A return value equal to *nb_ops* indicates that the queue contained
690 * at least *nb_ops* operations, and this is likely to signify that other
691 * processed operations remain in the devices output queue. Applications
692 * implementing a "retrieve as many processed operations as possible" policy
693 * can check this specific case and keep invoking the
694 * rte_cryptodev_dequeue_burst() function until a value less than
695 * *nb_ops* is returned.
697 * The rte_cryptodev_dequeue_burst() function does not provide any error
698 * notification to avoid the corresponding overhead.
700 * @param dev_id The symmetric crypto device identifier
701 * @param qp_id The index of the queue pair from which to
702 * retrieve processed packets. The value must be
703 * in the range [0, nb_queue_pair - 1] previously
704 * supplied to rte_cryptodev_configure().
705 * @param ops The address of an array of pointers to
706 * *rte_crypto_op* structures that must be
707 * large enough to store *nb_ops* pointers in it.
708 * @param nb_ops The maximum number of operations to dequeue.
711 * - The number of operations actually dequeued, which is the number
712 * of pointers to *rte_crypto_op* structures effectively supplied to the
715 static inline uint16_t
716 rte_cryptodev_dequeue_burst(uint8_t dev_id, uint16_t qp_id,
717 struct rte_crypto_op **ops, uint16_t nb_ops)
719 struct rte_cryptodev *dev = &rte_cryptodevs[dev_id];
721 nb_ops = (*dev->dequeue_burst)
722 (dev->data->queue_pairs[qp_id], ops, nb_ops);
728 * Enqueue a burst of operations for processing on a crypto device.
730 * The rte_cryptodev_enqueue_burst() function is invoked to place
731 * crypto operations on the queue *qp_id* of the device designated by
734 * The *nb_ops* parameter is the number of operations to process which are
735 * supplied in the *ops* array of *rte_crypto_op* structures.
737 * The rte_cryptodev_enqueue_burst() function returns the number of
738 * operations it actually enqueued for processing. A return value equal to
739 * *nb_ops* means that all packets have been enqueued.
741 * @param dev_id The identifier of the device.
742 * @param qp_id The index of the queue pair which packets are
743 * to be enqueued for processing. The value
744 * must be in the range [0, nb_queue_pairs - 1]
745 * previously supplied to
746 * *rte_cryptodev_configure*.
747 * @param ops The address of an array of *nb_ops* pointers
748 * to *rte_crypto_op* structures which contain
749 * the crypto operations to be processed.
750 * @param nb_ops The number of operations to process.
753 * The number of operations actually enqueued on the crypto device. The return
754 * value can be less than the value of the *nb_ops* parameter when the
755 * crypto devices queue is full or if invalid parameters are specified in
758 static inline uint16_t
759 rte_cryptodev_enqueue_burst(uint8_t dev_id, uint16_t qp_id,
760 struct rte_crypto_op **ops, uint16_t nb_ops)
762 struct rte_cryptodev *dev = &rte_cryptodevs[dev_id];
764 return (*dev->enqueue_burst)(
765 dev->data->queue_pairs[qp_id], ops, nb_ops);
769 /** Cryptodev symmetric crypto session */
770 struct rte_cryptodev_sym_session {
775 enum rte_cryptodev_type dev_type;
776 /** Crypto Device type session created on */
777 struct rte_mempool *mp;
778 /**< Mempool session allocated from */
780 /**< Public symmetric session details */
782 __extension__ char _private[0];
783 /**< Private session material */
788 * Initialise a session for symmetric cryptographic operations.
790 * This function is used by the client to initialize immutable
791 * parameters of symmetric cryptographic operation.
792 * To perform the operation the rte_cryptodev_enqueue_burst function is
793 * used. Each mbuf should contain a reference to the session
794 * pointer returned from this function contained within it's crypto_op if a
795 * session-based operation is being provisioned. Memory to contain the session
796 * information is allocated from within mempool managed by the cryptodev.
798 * The rte_cryptodev_session_free must be called to free allocated
799 * memory when the session is no longer required.
801 * @param dev_id The device identifier.
802 * @param xform Crypto transform chain.
806 * Pointer to the created session or NULL
808 extern struct rte_cryptodev_sym_session *
809 rte_cryptodev_sym_session_create(uint8_t dev_id,
810 struct rte_crypto_sym_xform *xform);
813 * Free the memory associated with a previously allocated session.
815 * @param dev_id The device identifier.
816 * @param session Session pointer previously allocated by
817 * *rte_cryptodev_sym_session_create*.
820 * NULL on successful freeing of session.
821 * Session pointer on failure to free session.
823 extern struct rte_cryptodev_sym_session *
824 rte_cryptodev_sym_session_free(uint8_t dev_id,
825 struct rte_cryptodev_sym_session *session);
832 #endif /* _RTE_CRYPTODEV_H_ */