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 */
235 #define RTE_CRYPTODEV_FF_CPU_NEON (1ULL << 10)
236 /**< Utilises CPU NEON instructions */
237 #define RTE_CRYPTODEV_FF_CPU_ARM_CE (1ULL << 11)
238 /**< Utilises ARM CPU Cryptographic Extensions */
243 * Get the name of a crypto device feature flag
245 * @param flag The mask describing the flag.
248 * The name of this flag, or NULL if it's not a valid feature flag.
252 rte_cryptodev_get_feature_name(uint64_t flag);
254 /** Crypto device information */
255 struct rte_cryptodev_info {
256 const char *driver_name; /**< Driver name. */
257 enum rte_cryptodev_type dev_type; /**< Device type */
258 struct rte_pci_device *pci_dev; /**< PCI information. */
260 uint64_t feature_flags; /**< Feature flags */
262 const struct rte_cryptodev_capabilities *capabilities;
263 /**< Array of devices supported capabilities */
265 unsigned max_nb_queue_pairs;
266 /**< Maximum number of queues pairs supported by device. */
269 unsigned max_nb_sessions;
270 /**< Maximum number of sessions supported by device. */
274 #define RTE_CRYPTODEV_DETACHED (0)
275 #define RTE_CRYPTODEV_ATTACHED (1)
277 /** Definitions of Crypto device event types */
278 enum rte_cryptodev_event_type {
279 RTE_CRYPTODEV_EVENT_UNKNOWN, /**< unknown event type */
280 RTE_CRYPTODEV_EVENT_ERROR, /**< error interrupt event */
281 RTE_CRYPTODEV_EVENT_MAX /**< max value of this enum */
284 /** Crypto device queue pair configuration structure. */
285 struct rte_cryptodev_qp_conf {
286 uint32_t nb_descriptors; /**< Number of descriptors per queue pair */
290 * Typedef for application callback function to be registered by application
291 * software for notification of device events
293 * @param dev_id Crypto device identifier
294 * @param event Crypto device event to register for notification of.
295 * @param cb_arg User specified parameter to be passed as to passed to
296 * users callback function.
298 typedef void (*rte_cryptodev_cb_fn)(uint8_t dev_id,
299 enum rte_cryptodev_event_type event, void *cb_arg);
302 /** Crypto Device statistics */
303 struct rte_cryptodev_stats {
304 uint64_t enqueued_count;
305 /**< Count of all operations enqueued */
306 uint64_t dequeued_count;
307 /**< Count of all operations dequeued */
309 uint64_t enqueue_err_count;
310 /**< Total error count on operations enqueued */
311 uint64_t dequeue_err_count;
312 /**< Total error count on operations dequeued */
315 #define RTE_CRYPTODEV_NAME_MAX_LEN (64)
316 /**< Max length of name of crypto PMD */
317 #define RTE_CRYPTODEV_VDEV_DEFAULT_MAX_NB_QUEUE_PAIRS 8
318 #define RTE_CRYPTODEV_VDEV_DEFAULT_MAX_NB_SESSIONS 2048
322 * Initialisation parameters for virtual crypto devices
324 struct rte_crypto_vdev_init_params {
325 unsigned max_nb_queue_pairs;
326 unsigned max_nb_sessions;
328 char name[RTE_CRYPTODEV_NAME_MAX_LEN];
332 * Parse virtual device initialisation parameters input arguments
335 * @params params Initialisation parameters with defaults set.
336 * @params input_args Command line arguments
339 * 0 on successful parse
340 * <0 on failure to parse
343 rte_cryptodev_parse_vdev_init_params(
344 struct rte_crypto_vdev_init_params *params,
345 const char *input_args);
348 * Create a virtual crypto device
350 * @param name Cryptodev PMD name of device to be created.
351 * @param args Options arguments for device.
354 * - On successful creation of the cryptodev the device index is returned,
355 * which will be between 0 and rte_cryptodev_count().
356 * - In the case of a failure, returns -1.
359 rte_cryptodev_create_vdev(const char *name, const char *args);
362 * Get the device identifier for the named crypto device.
364 * @param name device name to select the device structure.
367 * - Returns crypto device identifier on success.
368 * - Return -1 on failure to find named crypto device.
371 rte_cryptodev_get_dev_id(const char *name);
374 * Get the total number of crypto devices that have been successfully
378 * - The total number of usable crypto devices.
381 rte_cryptodev_count(void);
384 rte_cryptodev_count_devtype(enum rte_cryptodev_type type);
386 * Return the NUMA socket to which a device is connected
389 * The identifier of the device
391 * The NUMA socket id to which the device is connected or
392 * a default of zero if the socket could not be determined.
393 * -1 if returned is the dev_id value is out of range.
396 rte_cryptodev_socket_id(uint8_t dev_id);
398 /** Crypto device configuration structure */
399 struct rte_cryptodev_config {
400 int socket_id; /**< Socket to allocate resources on */
401 uint16_t nb_queue_pairs;
402 /**< Number of queue pairs to configure on device */
405 uint32_t nb_objs; /**< Number of objects in mempool */
406 uint32_t cache_size; /**< l-core object cache size */
407 } session_mp; /**< Session mempool configuration */
411 * Configure a device.
413 * This function must be invoked first before any other function in the
414 * API. This function can also be re-invoked when a device is in the
417 * @param dev_id The identifier of the device to configure.
418 * @param config The crypto device configuration structure.
421 * - 0: Success, device configured.
422 * - <0: Error code returned by the driver configuration function.
425 rte_cryptodev_configure(uint8_t dev_id, struct rte_cryptodev_config *config);
430 * The device start step is the last one and consists of setting the configured
431 * offload features and in starting the transmit and the receive units of the
433 * On success, all basic functions exported by the API (link status,
434 * receive/transmit, and so on) can be invoked.
437 * The identifier of the device.
439 * - 0: Success, device started.
440 * - <0: Error code of the driver device start function.
443 rte_cryptodev_start(uint8_t dev_id);
446 * Stop an device. The device can be restarted with a call to
447 * rte_cryptodev_start()
449 * @param dev_id The identifier of the device.
452 rte_cryptodev_stop(uint8_t dev_id);
455 * Close an device. The device cannot be restarted!
457 * @param dev_id The identifier of the device.
460 * - 0 on successfully closing device
461 * - <0 on failure to close device
464 rte_cryptodev_close(uint8_t dev_id);
467 * Allocate and set up a receive queue pair for a device.
470 * @param dev_id The identifier of the device.
471 * @param queue_pair_id The index of the queue pairs to set up. The
472 * value must be in the range [0, nb_queue_pair
473 * - 1] previously supplied to
474 * rte_cryptodev_configure().
475 * @param qp_conf The pointer to the configuration data to be
476 * used for the queue pair. NULL value is
477 * allowed, in which case default configuration
479 * @param socket_id The *socket_id* argument is the socket
480 * identifier in case of NUMA. The value can be
481 * *SOCKET_ID_ANY* if there is no NUMA constraint
482 * for the DMA memory allocated for the receive
486 * - 0: Success, queue pair correctly set up.
487 * - <0: Queue pair configuration failed
490 rte_cryptodev_queue_pair_setup(uint8_t dev_id, uint16_t queue_pair_id,
491 const struct rte_cryptodev_qp_conf *qp_conf, int socket_id);
494 * Start a specified queue pair of a device. It is used
495 * when deferred_start flag of the specified queue is true.
497 * @param dev_id The identifier of the device
498 * @param queue_pair_id The index of the queue pair to start. The value
499 * must be in the range [0, nb_queue_pair - 1]
500 * previously supplied to
501 * rte_crypto_dev_configure().
503 * - 0: Success, the transmit queue is correctly set up.
504 * - -EINVAL: The dev_id or the queue_id out of range.
505 * - -ENOTSUP: The function not supported in PMD driver.
508 rte_cryptodev_queue_pair_start(uint8_t dev_id, uint16_t queue_pair_id);
511 * Stop specified queue pair of a device
513 * @param dev_id The identifier of the device
514 * @param queue_pair_id The index of the queue pair to stop. The value
515 * must be in the range [0, nb_queue_pair - 1]
516 * previously supplied to
517 * rte_cryptodev_configure().
519 * - 0: Success, the transmit queue is correctly set up.
520 * - -EINVAL: The dev_id or the queue_id out of range.
521 * - -ENOTSUP: The function not supported in PMD driver.
524 rte_cryptodev_queue_pair_stop(uint8_t dev_id, uint16_t queue_pair_id);
527 * Get the number of queue pairs on a specific crypto device
529 * @param dev_id Crypto device identifier.
531 * - The number of configured queue pairs.
534 rte_cryptodev_queue_pair_count(uint8_t dev_id);
538 * Retrieve the general I/O statistics of a device.
540 * @param dev_id The identifier of the device.
541 * @param stats A pointer to a structure of type
542 * *rte_cryptodev_stats* to be filled with the
543 * values of device counters.
545 * - Zero if successful.
546 * - Non-zero otherwise.
549 rte_cryptodev_stats_get(uint8_t dev_id, struct rte_cryptodev_stats *stats);
552 * Reset the general I/O statistics of a device.
554 * @param dev_id The identifier of the device.
557 rte_cryptodev_stats_reset(uint8_t dev_id);
560 * Retrieve the contextual information of a device.
562 * @param dev_id The identifier of the device.
563 * @param dev_info A pointer to a structure of type
564 * *rte_cryptodev_info* to be filled with the
565 * contextual information of the device.
568 rte_cryptodev_info_get(uint8_t dev_id, struct rte_cryptodev_info *dev_info);
572 * Register a callback function for specific device id.
574 * @param dev_id Device id.
575 * @param event Event interested.
576 * @param cb_fn User supplied callback function to be called.
577 * @param cb_arg Pointer to the parameters for the registered
581 * - On success, zero.
582 * - On failure, a negative value.
585 rte_cryptodev_callback_register(uint8_t dev_id,
586 enum rte_cryptodev_event_type event,
587 rte_cryptodev_cb_fn cb_fn, void *cb_arg);
590 * Unregister a callback function for specific device id.
592 * @param dev_id The device identifier.
593 * @param event Event interested.
594 * @param cb_fn User supplied callback function to be called.
595 * @param cb_arg Pointer to the parameters for the registered
599 * - On success, zero.
600 * - On failure, a negative value.
603 rte_cryptodev_callback_unregister(uint8_t dev_id,
604 enum rte_cryptodev_event_type event,
605 rte_cryptodev_cb_fn cb_fn, void *cb_arg);
608 typedef uint16_t (*dequeue_pkt_burst_t)(void *qp,
609 struct rte_crypto_op **ops, uint16_t nb_ops);
610 /**< Dequeue processed packets from queue pair of a device. */
612 typedef uint16_t (*enqueue_pkt_burst_t)(void *qp,
613 struct rte_crypto_op **ops, uint16_t nb_ops);
614 /**< Enqueue packets for processing on queue pair of a device. */
619 struct rte_cryptodev_callback;
621 /** Structure to keep track of registered callbacks */
622 TAILQ_HEAD(rte_cryptodev_cb_list, rte_cryptodev_callback);
624 /** The data structure associated with each crypto device. */
625 struct rte_cryptodev {
626 dequeue_pkt_burst_t dequeue_burst;
627 /**< Pointer to PMD receive function. */
628 enqueue_pkt_burst_t enqueue_burst;
629 /**< Pointer to PMD transmit function. */
631 const struct rte_cryptodev_driver *driver;
632 /**< Driver for this device */
633 struct rte_cryptodev_data *data;
634 /**< Pointer to device data */
635 struct rte_cryptodev_ops *dev_ops;
636 /**< Functions exported by PMD */
637 uint64_t feature_flags;
638 /**< Supported features */
639 struct rte_pci_device *pci_dev;
640 /**< PCI info. supplied by probing */
642 enum rte_cryptodev_type dev_type;
643 /**< Crypto device type */
645 struct rte_cryptodev_cb_list link_intr_cbs;
646 /**< User application callback for interrupts if present */
649 uint8_t attached : 1;
650 /**< Flag indicating the device is attached */
651 } __rte_cache_aligned;
655 * The data part, with no function pointers, associated with each device.
657 * This structure is safe to place in shared memory to be common among
658 * different processes in a multi-process configuration.
660 struct rte_cryptodev_data {
662 /**< Device ID for this instance */
664 /**< Socket ID where memory is allocated */
665 char name[RTE_CRYPTODEV_NAME_MAX_LEN];
666 /**< Unique identifier name */
669 uint8_t dev_started : 1;
670 /**< Device state: STARTED(1)/STOPPED(0) */
672 struct rte_mempool *session_pool;
673 /**< Session memory pool */
675 /**< Array of pointers to queue pairs. */
676 uint16_t nb_queue_pairs;
677 /**< Number of device queue pairs. */
680 /**< PMD-specific private data */
681 } __rte_cache_aligned;
683 extern struct rte_cryptodev *rte_cryptodevs;
686 * Dequeue a burst of processed crypto operations from a queue on the crypto
687 * device. The dequeued operation are stored in *rte_crypto_op* structures
688 * whose pointers are supplied in the *ops* array.
690 * The rte_cryptodev_dequeue_burst() function returns the number of ops
691 * actually dequeued, which is the number of *rte_crypto_op* data structures
692 * effectively supplied into the *ops* array.
694 * A return value equal to *nb_ops* indicates that the queue contained
695 * at least *nb_ops* operations, and this is likely to signify that other
696 * processed operations remain in the devices output queue. Applications
697 * implementing a "retrieve as many processed operations as possible" policy
698 * can check this specific case and keep invoking the
699 * rte_cryptodev_dequeue_burst() function until a value less than
700 * *nb_ops* is returned.
702 * The rte_cryptodev_dequeue_burst() function does not provide any error
703 * notification to avoid the corresponding overhead.
705 * @param dev_id The symmetric crypto device identifier
706 * @param qp_id The index of the queue pair from which to
707 * retrieve processed packets. The value must be
708 * in the range [0, nb_queue_pair - 1] previously
709 * supplied to rte_cryptodev_configure().
710 * @param ops The address of an array of pointers to
711 * *rte_crypto_op* structures that must be
712 * large enough to store *nb_ops* pointers in it.
713 * @param nb_ops The maximum number of operations to dequeue.
716 * - The number of operations actually dequeued, which is the number
717 * of pointers to *rte_crypto_op* structures effectively supplied to the
720 static inline uint16_t
721 rte_cryptodev_dequeue_burst(uint8_t dev_id, uint16_t qp_id,
722 struct rte_crypto_op **ops, uint16_t nb_ops)
724 struct rte_cryptodev *dev = &rte_cryptodevs[dev_id];
726 nb_ops = (*dev->dequeue_burst)
727 (dev->data->queue_pairs[qp_id], ops, nb_ops);
733 * Enqueue a burst of operations for processing on a crypto device.
735 * The rte_cryptodev_enqueue_burst() function is invoked to place
736 * crypto operations on the queue *qp_id* of the device designated by
739 * The *nb_ops* parameter is the number of operations to process which are
740 * supplied in the *ops* array of *rte_crypto_op* structures.
742 * The rte_cryptodev_enqueue_burst() function returns the number of
743 * operations it actually enqueued for processing. A return value equal to
744 * *nb_ops* means that all packets have been enqueued.
746 * @param dev_id The identifier of the device.
747 * @param qp_id The index of the queue pair which packets are
748 * to be enqueued for processing. The value
749 * must be in the range [0, nb_queue_pairs - 1]
750 * previously supplied to
751 * *rte_cryptodev_configure*.
752 * @param ops The address of an array of *nb_ops* pointers
753 * to *rte_crypto_op* structures which contain
754 * the crypto operations to be processed.
755 * @param nb_ops The number of operations to process.
758 * The number of operations actually enqueued on the crypto device. The return
759 * value can be less than the value of the *nb_ops* parameter when the
760 * crypto devices queue is full or if invalid parameters are specified in
763 static inline uint16_t
764 rte_cryptodev_enqueue_burst(uint8_t dev_id, uint16_t qp_id,
765 struct rte_crypto_op **ops, uint16_t nb_ops)
767 struct rte_cryptodev *dev = &rte_cryptodevs[dev_id];
769 return (*dev->enqueue_burst)(
770 dev->data->queue_pairs[qp_id], ops, nb_ops);
774 /** Cryptodev symmetric crypto session */
775 struct rte_cryptodev_sym_session {
780 enum rte_cryptodev_type dev_type;
781 /** Crypto Device type session created on */
782 struct rte_mempool *mp;
783 /**< Mempool session allocated from */
785 /**< Public symmetric session details */
787 __extension__ char _private[0];
788 /**< Private session material */
793 * Initialise a session for symmetric cryptographic operations.
795 * This function is used by the client to initialize immutable
796 * parameters of symmetric cryptographic operation.
797 * To perform the operation the rte_cryptodev_enqueue_burst function is
798 * used. Each mbuf should contain a reference to the session
799 * pointer returned from this function contained within it's crypto_op if a
800 * session-based operation is being provisioned. Memory to contain the session
801 * information is allocated from within mempool managed by the cryptodev.
803 * The rte_cryptodev_session_free must be called to free allocated
804 * memory when the session is no longer required.
806 * @param dev_id The device identifier.
807 * @param xform Crypto transform chain.
811 * Pointer to the created session or NULL
813 extern struct rte_cryptodev_sym_session *
814 rte_cryptodev_sym_session_create(uint8_t dev_id,
815 struct rte_crypto_sym_xform *xform);
818 * Free the memory associated with a previously allocated session.
820 * @param dev_id The device identifier.
821 * @param session Session pointer previously allocated by
822 * *rte_cryptodev_sym_session_create*.
825 * NULL on successful freeing of session.
826 * Session pointer on failure to free session.
828 extern struct rte_cryptodev_sym_session *
829 rte_cryptodev_sym_session_free(uint8_t dev_id,
830 struct rte_cryptodev_sym_session *session);
837 #endif /* _RTE_CRYPTODEV_H_ */