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 */
70 /** Crypto device type */
71 enum rte_cryptodev_type {
72 RTE_CRYPTODEV_NULL_PMD = 1, /**< Null crypto PMD */
73 RTE_CRYPTODEV_AESNI_GCM_PMD, /**< AES-NI GCM PMD */
74 RTE_CRYPTODEV_AESNI_MB_PMD, /**< AES-NI multi buffer PMD */
75 RTE_CRYPTODEV_QAT_SYM_PMD, /**< QAT PMD Symmetric Crypto */
76 RTE_CRYPTODEV_SNOW3G_PMD, /**< SNOW 3G PMD */
77 RTE_CRYPTODEV_KASUMI_PMD, /**< KASUMI PMD */
78 RTE_CRYPTODEV_ZUC_PMD, /**< ZUC PMD */
79 RTE_CRYPTODEV_OPENSSL_PMD, /**< OpenSSL PMD */
82 extern const char **rte_cyptodev_names;
86 #define CDEV_LOG_ERR(...) \
87 RTE_LOG(ERR, CRYPTODEV, \
88 RTE_FMT("%s() line %u: " RTE_FMT_HEAD(__VA_ARGS__,) "\n", \
89 __func__, __LINE__, RTE_FMT_TAIL(__VA_ARGS__,)))
91 #define CDEV_PMD_LOG_ERR(dev, ...) \
92 RTE_LOG(ERR, CRYPTODEV, \
93 RTE_FMT("[%s] %s() line %u: " RTE_FMT_HEAD(__VA_ARGS__,) "\n", \
94 dev, __func__, __LINE__, RTE_FMT_TAIL(__VA_ARGS__,)))
96 #ifdef RTE_LIBRTE_CRYPTODEV_DEBUG
97 #define CDEV_LOG_DEBUG(...) \
98 RTE_LOG(DEBUG, CRYPTODEV, \
99 RTE_FMT("%s() line %u: " RTE_FMT_HEAD(__VA_ARGS__,) "\n", \
100 __func__, __LINE__, RTE_FMT_TAIL(__VA_ARGS__,)))
102 #define CDEV_PMD_TRACE(...) \
103 RTE_LOG(DEBUG, CRYPTODEV, \
104 RTE_FMT("[%s] %s: " RTE_FMT_HEAD(__VA_ARGS__,) "\n", \
105 dev, __func__, RTE_FMT_TAIL(__VA_ARGS__,)))
108 #define CDEV_LOG_DEBUG(...) (void)0
109 #define CDEV_PMD_TRACE(...) (void)0
113 * Symmetric Crypto Capability
115 struct rte_cryptodev_symmetric_capability {
116 enum rte_crypto_sym_xform_type xform_type;
117 /**< Transform type : Authentication / Cipher */
121 enum rte_crypto_auth_algorithm algo;
122 /**< authentication algorithm */
124 /**< algorithm block size */
126 uint16_t min; /**< minimum key size */
127 uint16_t max; /**< maximum key size */
129 /**< if a range of sizes are supported,
130 * this parameter is used to indicate
131 * increments in byte size that are supported
132 * between the minimum and maximum */
134 /**< auth key size range */
136 uint16_t min; /**< minimum digest size */
137 uint16_t max; /**< maximum digest size */
139 /**< if a range of sizes are supported,
140 * this parameter is used to indicate
141 * increments in byte size that are supported
142 * between the minimum and maximum */
144 /**< digest size range */
146 uint16_t min; /**< minimum aad size */
147 uint16_t max; /**< maximum aad size */
149 /**< if a range of sizes are supported,
150 * this parameter is used to indicate
151 * increments in byte size that are supported
152 * between the minimum and maximum */
154 /**< Additional authentication data size range */
156 /**< Symmetric Authentication transform capabilities */
158 enum rte_crypto_cipher_algorithm algo;
159 /**< cipher algorithm */
161 /**< algorithm block size */
163 uint16_t min; /**< minimum key size */
164 uint16_t max; /**< maximum key size */
166 /**< if a range of sizes are supported,
167 * this parameter is used to indicate
168 * increments in byte size that are supported
169 * between the minimum and maximum */
171 /**< cipher key size range */
173 uint16_t min; /**< minimum iv size */
174 uint16_t max; /**< maximum iv size */
176 /**< if a range of sizes are supported,
177 * this parameter is used to indicate
178 * increments in byte size that are supported
179 * between the minimum and maximum */
181 /**< Initialisation vector data size range */
183 /**< Symmetric Cipher transform capabilities */
187 /** Structure used to capture a capability of a crypto device */
188 struct rte_cryptodev_capabilities {
189 enum rte_crypto_op_type op;
190 /**< Operation type */
194 struct rte_cryptodev_symmetric_capability sym;
195 /**< Symmetric operation capability parameters */
199 /** Macro used at end of crypto PMD list */
200 #define RTE_CRYPTODEV_END_OF_CAPABILITIES_LIST() \
201 { RTE_CRYPTO_OP_TYPE_UNDEFINED }
205 * Crypto device supported feature flags
208 * New features flags should be added to the end of the list
210 * Keep these flags synchronised with rte_cryptodev_get_feature_name()
212 #define RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO (1ULL << 0)
213 /**< Symmetric crypto operations are supported */
214 #define RTE_CRYPTODEV_FF_ASYMMETRIC_CRYPTO (1ULL << 1)
215 /**< Asymmetric crypto operations are supported */
216 #define RTE_CRYPTODEV_FF_SYM_OPERATION_CHAINING (1ULL << 2)
217 /**< Chaining symmetric crypto operations are supported */
218 #define RTE_CRYPTODEV_FF_CPU_SSE (1ULL << 3)
219 /**< Utilises CPU SIMD SSE instructions */
220 #define RTE_CRYPTODEV_FF_CPU_AVX (1ULL << 4)
221 /**< Utilises CPU SIMD AVX instructions */
222 #define RTE_CRYPTODEV_FF_CPU_AVX2 (1ULL << 5)
223 /**< Utilises CPU SIMD AVX2 instructions */
224 #define RTE_CRYPTODEV_FF_CPU_AESNI (1ULL << 6)
225 /**< Utilises CPU AES-NI instructions */
226 #define RTE_CRYPTODEV_FF_HW_ACCELERATED (1ULL << 7)
227 /**< Operations are off-loaded to an external hardware accelerator */
228 #define RTE_CRYPTODEV_FF_CPU_AVX512 (1ULL << 8)
229 /**< Utilises CPU SIMD AVX512 instructions */
230 #define RTE_CRYPTODEV_FF_MBUF_SCATTER_GATHER (1ULL << 9)
231 /**< Scatter-gather mbufs are supported */
235 * Get the name of a crypto device feature flag
237 * @param flag The mask describing the flag.
240 * The name of this flag, or NULL if it's not a valid feature flag.
244 rte_cryptodev_get_feature_name(uint64_t flag);
246 /** Crypto device information */
247 struct rte_cryptodev_info {
248 const char *driver_name; /**< Driver name. */
249 enum rte_cryptodev_type dev_type; /**< Device type */
250 struct rte_pci_device *pci_dev; /**< PCI information. */
252 uint64_t feature_flags; /**< Feature flags */
254 const struct rte_cryptodev_capabilities *capabilities;
255 /**< Array of devices supported capabilities */
257 unsigned max_nb_queue_pairs;
258 /**< Maximum number of queues pairs supported by device. */
261 unsigned max_nb_sessions;
262 /**< Maximum number of sessions supported by device. */
266 #define RTE_CRYPTODEV_DETACHED (0)
267 #define RTE_CRYPTODEV_ATTACHED (1)
269 /** Definitions of Crypto device event types */
270 enum rte_cryptodev_event_type {
271 RTE_CRYPTODEV_EVENT_UNKNOWN, /**< unknown event type */
272 RTE_CRYPTODEV_EVENT_ERROR, /**< error interrupt event */
273 RTE_CRYPTODEV_EVENT_MAX /**< max value of this enum */
276 /** Crypto device queue pair configuration structure. */
277 struct rte_cryptodev_qp_conf {
278 uint32_t nb_descriptors; /**< Number of descriptors per queue pair */
282 * Typedef for application callback function to be registered by application
283 * software for notification of device events
285 * @param dev_id Crypto device identifier
286 * @param event Crypto device event to register for notification of.
287 * @param cb_arg User specified parameter to be passed as to passed to
288 * users callback function.
290 typedef void (*rte_cryptodev_cb_fn)(uint8_t dev_id,
291 enum rte_cryptodev_event_type event, void *cb_arg);
294 /** Crypto Device statistics */
295 struct rte_cryptodev_stats {
296 uint64_t enqueued_count;
297 /**< Count of all operations enqueued */
298 uint64_t dequeued_count;
299 /**< Count of all operations dequeued */
301 uint64_t enqueue_err_count;
302 /**< Total error count on operations enqueued */
303 uint64_t dequeue_err_count;
304 /**< Total error count on operations dequeued */
307 #define RTE_CRYPTODEV_NAME_MAX_LEN (64)
308 /**< Max length of name of crypto PMD */
309 #define RTE_CRYPTODEV_VDEV_DEFAULT_MAX_NB_QUEUE_PAIRS 8
310 #define RTE_CRYPTODEV_VDEV_DEFAULT_MAX_NB_SESSIONS 2048
314 * Initialisation parameters for virtual crypto devices
316 struct rte_crypto_vdev_init_params {
317 unsigned max_nb_queue_pairs;
318 unsigned max_nb_sessions;
320 char name[RTE_CRYPTODEV_NAME_MAX_LEN];
324 * Parse virtual device initialisation parameters input arguments
327 * @params params Initialisation parameters with defaults set.
328 * @params input_args Command line arguments
331 * 0 on successful parse
332 * <0 on failure to parse
335 rte_cryptodev_parse_vdev_init_params(
336 struct rte_crypto_vdev_init_params *params,
337 const char *input_args);
340 * Create a virtual crypto device
342 * @param name Cryptodev PMD name of device to be created.
343 * @param args Options arguments for device.
346 * - On successful creation of the cryptodev the device index is returned,
347 * which will be between 0 and rte_cryptodev_count().
348 * - In the case of a failure, returns -1.
351 rte_cryptodev_create_vdev(const char *name, const char *args);
354 * Get the device identifier for the named crypto device.
356 * @param name device name to select the device structure.
359 * - Returns crypto device identifier on success.
360 * - Return -1 on failure to find named crypto device.
363 rte_cryptodev_get_dev_id(const char *name);
366 * Get the total number of crypto devices that have been successfully
370 * - The total number of usable crypto devices.
373 rte_cryptodev_count(void);
376 rte_cryptodev_count_devtype(enum rte_cryptodev_type type);
378 * Return the NUMA socket to which a device is connected
381 * The identifier of the device
383 * The NUMA socket id to which the device is connected or
384 * a default of zero if the socket could not be determined.
385 * -1 if returned is the dev_id value is out of range.
388 rte_cryptodev_socket_id(uint8_t dev_id);
390 /** Crypto device configuration structure */
391 struct rte_cryptodev_config {
392 int socket_id; /**< Socket to allocate resources on */
393 uint16_t nb_queue_pairs;
394 /**< Number of queue pairs to configure on device */
397 uint32_t nb_objs; /**< Number of objects in mempool */
398 uint32_t cache_size; /**< l-core object cache size */
399 } session_mp; /**< Session mempool configuration */
403 * Configure a device.
405 * This function must be invoked first before any other function in the
406 * API. This function can also be re-invoked when a device is in the
409 * @param dev_id The identifier of the device to configure.
410 * @param config The crypto device configuration structure.
413 * - 0: Success, device configured.
414 * - <0: Error code returned by the driver configuration function.
417 rte_cryptodev_configure(uint8_t dev_id, struct rte_cryptodev_config *config);
422 * The device start step is the last one and consists of setting the configured
423 * offload features and in starting the transmit and the receive units of the
425 * On success, all basic functions exported by the API (link status,
426 * receive/transmit, and so on) can be invoked.
429 * The identifier of the device.
431 * - 0: Success, device started.
432 * - <0: Error code of the driver device start function.
435 rte_cryptodev_start(uint8_t dev_id);
438 * Stop an device. The device can be restarted with a call to
439 * rte_cryptodev_start()
441 * @param dev_id The identifier of the device.
444 rte_cryptodev_stop(uint8_t dev_id);
447 * Close an device. The device cannot be restarted!
449 * @param dev_id The identifier of the device.
452 * - 0 on successfully closing device
453 * - <0 on failure to close device
456 rte_cryptodev_close(uint8_t dev_id);
459 * Allocate and set up a receive queue pair for a device.
462 * @param dev_id The identifier of the device.
463 * @param queue_pair_id The index of the queue pairs to set up. The
464 * value must be in the range [0, nb_queue_pair
465 * - 1] previously supplied to
466 * rte_cryptodev_configure().
467 * @param qp_conf The pointer to the configuration data to be
468 * used for the queue pair. NULL value is
469 * allowed, in which case default configuration
471 * @param socket_id The *socket_id* argument is the socket
472 * identifier in case of NUMA. The value can be
473 * *SOCKET_ID_ANY* if there is no NUMA constraint
474 * for the DMA memory allocated for the receive
478 * - 0: Success, queue pair correctly set up.
479 * - <0: Queue pair configuration failed
482 rte_cryptodev_queue_pair_setup(uint8_t dev_id, uint16_t queue_pair_id,
483 const struct rte_cryptodev_qp_conf *qp_conf, int socket_id);
486 * Start a specified queue pair of a device. It is used
487 * when deferred_start flag of the specified queue is true.
489 * @param dev_id The identifier of the device
490 * @param queue_pair_id The index of the queue pair to start. The value
491 * must be in the range [0, nb_queue_pair - 1]
492 * previously supplied to
493 * rte_crypto_dev_configure().
495 * - 0: Success, the transmit queue is correctly set up.
496 * - -EINVAL: The dev_id or the queue_id out of range.
497 * - -ENOTSUP: The function not supported in PMD driver.
500 rte_cryptodev_queue_pair_start(uint8_t dev_id, uint16_t queue_pair_id);
503 * Stop specified queue pair of a device
505 * @param dev_id The identifier of the device
506 * @param queue_pair_id The index of the queue pair to stop. The value
507 * must be in the range [0, nb_queue_pair - 1]
508 * previously supplied to
509 * rte_cryptodev_configure().
511 * - 0: Success, the transmit queue is correctly set up.
512 * - -EINVAL: The dev_id or the queue_id out of range.
513 * - -ENOTSUP: The function not supported in PMD driver.
516 rte_cryptodev_queue_pair_stop(uint8_t dev_id, uint16_t queue_pair_id);
519 * Get the number of queue pairs on a specific crypto device
521 * @param dev_id Crypto device identifier.
523 * - The number of configured queue pairs.
526 rte_cryptodev_queue_pair_count(uint8_t dev_id);
530 * Retrieve the general I/O statistics of a device.
532 * @param dev_id The identifier of the device.
533 * @param stats A pointer to a structure of type
534 * *rte_cryptodev_stats* to be filled with the
535 * values of device counters.
537 * - Zero if successful.
538 * - Non-zero otherwise.
541 rte_cryptodev_stats_get(uint8_t dev_id, struct rte_cryptodev_stats *stats);
544 * Reset the general I/O statistics of a device.
546 * @param dev_id The identifier of the device.
549 rte_cryptodev_stats_reset(uint8_t dev_id);
552 * Retrieve the contextual information of a device.
554 * @param dev_id The identifier of the device.
555 * @param dev_info A pointer to a structure of type
556 * *rte_cryptodev_info* to be filled with the
557 * contextual information of the device.
560 rte_cryptodev_info_get(uint8_t dev_id, struct rte_cryptodev_info *dev_info);
564 * Register a callback function for specific device id.
566 * @param dev_id Device id.
567 * @param event Event interested.
568 * @param cb_fn User supplied callback function to be called.
569 * @param cb_arg Pointer to the parameters for the registered
573 * - On success, zero.
574 * - On failure, a negative value.
577 rte_cryptodev_callback_register(uint8_t dev_id,
578 enum rte_cryptodev_event_type event,
579 rte_cryptodev_cb_fn cb_fn, void *cb_arg);
582 * Unregister a callback function for specific device id.
584 * @param dev_id The device identifier.
585 * @param event Event interested.
586 * @param cb_fn User supplied callback function to be called.
587 * @param cb_arg Pointer to the parameters for the registered
591 * - On success, zero.
592 * - On failure, a negative value.
595 rte_cryptodev_callback_unregister(uint8_t dev_id,
596 enum rte_cryptodev_event_type event,
597 rte_cryptodev_cb_fn cb_fn, void *cb_arg);
600 typedef uint16_t (*dequeue_pkt_burst_t)(void *qp,
601 struct rte_crypto_op **ops, uint16_t nb_ops);
602 /**< Dequeue processed packets from queue pair of a device. */
604 typedef uint16_t (*enqueue_pkt_burst_t)(void *qp,
605 struct rte_crypto_op **ops, uint16_t nb_ops);
606 /**< Enqueue packets for processing on queue pair of a device. */
611 struct rte_cryptodev_callback;
613 /** Structure to keep track of registered callbacks */
614 TAILQ_HEAD(rte_cryptodev_cb_list, rte_cryptodev_callback);
616 /** The data structure associated with each crypto device. */
617 struct rte_cryptodev {
618 dequeue_pkt_burst_t dequeue_burst;
619 /**< Pointer to PMD receive function. */
620 enqueue_pkt_burst_t enqueue_burst;
621 /**< Pointer to PMD transmit function. */
623 const struct rte_cryptodev_driver *driver;
624 /**< Driver for this device */
625 struct rte_cryptodev_data *data;
626 /**< Pointer to device data */
627 struct rte_cryptodev_ops *dev_ops;
628 /**< Functions exported by PMD */
629 uint64_t feature_flags;
630 /**< Supported features */
631 struct rte_pci_device *pci_dev;
632 /**< PCI info. supplied by probing */
634 enum rte_cryptodev_type dev_type;
635 /**< Crypto device type */
637 struct rte_cryptodev_cb_list link_intr_cbs;
638 /**< User application callback for interrupts if present */
641 uint8_t attached : 1;
642 /**< Flag indicating the device is attached */
643 } __rte_cache_aligned;
647 * The data part, with no function pointers, associated with each device.
649 * This structure is safe to place in shared memory to be common among
650 * different processes in a multi-process configuration.
652 struct rte_cryptodev_data {
654 /**< Device ID for this instance */
656 /**< Socket ID where memory is allocated */
657 char name[RTE_CRYPTODEV_NAME_MAX_LEN];
658 /**< Unique identifier name */
661 uint8_t dev_started : 1;
662 /**< Device state: STARTED(1)/STOPPED(0) */
664 struct rte_mempool *session_pool;
665 /**< Session memory pool */
667 /**< Array of pointers to queue pairs. */
668 uint16_t nb_queue_pairs;
669 /**< Number of device queue pairs. */
672 /**< PMD-specific private data */
673 } __rte_cache_aligned;
675 extern struct rte_cryptodev *rte_cryptodevs;
678 * Dequeue a burst of processed crypto operations from a queue on the crypto
679 * device. The dequeued operation are stored in *rte_crypto_op* structures
680 * whose pointers are supplied in the *ops* array.
682 * The rte_cryptodev_dequeue_burst() function returns the number of ops
683 * actually dequeued, which is the number of *rte_crypto_op* data structures
684 * effectively supplied into the *ops* array.
686 * A return value equal to *nb_ops* indicates that the queue contained
687 * at least *nb_ops* operations, and this is likely to signify that other
688 * processed operations remain in the devices output queue. Applications
689 * implementing a "retrieve as many processed operations as possible" policy
690 * can check this specific case and keep invoking the
691 * rte_cryptodev_dequeue_burst() function until a value less than
692 * *nb_ops* is returned.
694 * The rte_cryptodev_dequeue_burst() function does not provide any error
695 * notification to avoid the corresponding overhead.
697 * @param dev_id The symmetric crypto device identifier
698 * @param qp_id The index of the queue pair from which to
699 * retrieve processed packets. The value must be
700 * in the range [0, nb_queue_pair - 1] previously
701 * supplied to rte_cryptodev_configure().
702 * @param ops The address of an array of pointers to
703 * *rte_crypto_op* structures that must be
704 * large enough to store *nb_ops* pointers in it.
705 * @param nb_ops The maximum number of operations to dequeue.
708 * - The number of operations actually dequeued, which is the number
709 * of pointers to *rte_crypto_op* structures effectively supplied to the
712 static inline uint16_t
713 rte_cryptodev_dequeue_burst(uint8_t dev_id, uint16_t qp_id,
714 struct rte_crypto_op **ops, uint16_t nb_ops)
716 struct rte_cryptodev *dev = &rte_cryptodevs[dev_id];
718 nb_ops = (*dev->dequeue_burst)
719 (dev->data->queue_pairs[qp_id], ops, nb_ops);
725 * Enqueue a burst of operations for processing on a crypto device.
727 * The rte_cryptodev_enqueue_burst() function is invoked to place
728 * crypto operations on the queue *qp_id* of the device designated by
731 * The *nb_ops* parameter is the number of operations to process which are
732 * supplied in the *ops* array of *rte_crypto_op* structures.
734 * The rte_cryptodev_enqueue_burst() function returns the number of
735 * operations it actually enqueued for processing. A return value equal to
736 * *nb_ops* means that all packets have been enqueued.
738 * @param dev_id The identifier of the device.
739 * @param qp_id The index of the queue pair which packets are
740 * to be enqueued for processing. The value
741 * must be in the range [0, nb_queue_pairs - 1]
742 * previously supplied to
743 * *rte_cryptodev_configure*.
744 * @param ops The address of an array of *nb_ops* pointers
745 * to *rte_crypto_op* structures which contain
746 * the crypto operations to be processed.
747 * @param nb_ops The number of operations to process.
750 * The number of operations actually enqueued on the crypto device. The return
751 * value can be less than the value of the *nb_ops* parameter when the
752 * crypto devices queue is full or if invalid parameters are specified in
755 static inline uint16_t
756 rte_cryptodev_enqueue_burst(uint8_t dev_id, uint16_t qp_id,
757 struct rte_crypto_op **ops, uint16_t nb_ops)
759 struct rte_cryptodev *dev = &rte_cryptodevs[dev_id];
761 return (*dev->enqueue_burst)(
762 dev->data->queue_pairs[qp_id], ops, nb_ops);
766 /** Cryptodev symmetric crypto session */
767 struct rte_cryptodev_sym_session {
772 enum rte_cryptodev_type dev_type;
773 /** Crypto Device type session created on */
774 struct rte_mempool *mp;
775 /**< Mempool session allocated from */
777 /**< Public symmetric session details */
779 __extension__ char _private[0];
780 /**< Private session material */
785 * Initialise a session for symmetric cryptographic operations.
787 * This function is used by the client to initialize immutable
788 * parameters of symmetric cryptographic operation.
789 * To perform the operation the rte_cryptodev_enqueue_burst function is
790 * used. Each mbuf should contain a reference to the session
791 * pointer returned from this function contained within it's crypto_op if a
792 * session-based operation is being provisioned. Memory to contain the session
793 * information is allocated from within mempool managed by the cryptodev.
795 * The rte_cryptodev_session_free must be called to free allocated
796 * memory when the session is no longer required.
798 * @param dev_id The device identifier.
799 * @param xform Crypto transform chain.
803 * Pointer to the created session or NULL
805 extern struct rte_cryptodev_sym_session *
806 rte_cryptodev_sym_session_create(uint8_t dev_id,
807 struct rte_crypto_sym_xform *xform);
810 * Free the memory associated with a previously allocated session.
812 * @param dev_id The device identifier.
813 * @param session Session pointer previously allocated by
814 * *rte_cryptodev_sym_session_create*.
817 * NULL on successful freeing of session.
818 * Session pointer on failure to free session.
820 extern struct rte_cryptodev_sym_session *
821 rte_cryptodev_sym_session_free(uint8_t dev_id,
822 struct rte_cryptodev_sym_session *session);
829 #endif /* _RTE_CRYPTODEV_H_ */