1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright(c) 2015-2020 Intel Corporation.
5 #ifndef _RTE_CRYPTODEV_H_
6 #define _RTE_CRYPTODEV_H_
9 * @file rte_cryptodev.h
11 * RTE Cryptographic Device APIs
13 * Defines RTE Crypto Device APIs for the provisioning of cipher and
14 * authentication operations.
21 #include "rte_kvargs.h"
22 #include "rte_crypto.h"
24 #include <rte_common.h>
25 #include <rte_config.h>
27 #include "rte_cryptodev_trace_fp.h"
29 extern const char **rte_cyptodev_names;
33 #define CDEV_LOG_ERR(...) \
34 RTE_LOG(ERR, CRYPTODEV, \
35 RTE_FMT("%s() line %u: " RTE_FMT_HEAD(__VA_ARGS__,) "\n", \
36 __func__, __LINE__, RTE_FMT_TAIL(__VA_ARGS__,)))
38 #define CDEV_LOG_INFO(...) \
39 RTE_LOG(INFO, CRYPTODEV, \
40 RTE_FMT(RTE_FMT_HEAD(__VA_ARGS__,) "\n", \
41 RTE_FMT_TAIL(__VA_ARGS__,)))
43 #define CDEV_LOG_DEBUG(...) \
44 RTE_LOG(DEBUG, CRYPTODEV, \
45 RTE_FMT("%s() line %u: " RTE_FMT_HEAD(__VA_ARGS__,) "\n", \
46 __func__, __LINE__, RTE_FMT_TAIL(__VA_ARGS__,)))
48 #define CDEV_PMD_TRACE(...) \
49 RTE_LOG(DEBUG, CRYPTODEV, \
50 RTE_FMT("[%s] %s: " RTE_FMT_HEAD(__VA_ARGS__,) "\n", \
51 dev, __func__, RTE_FMT_TAIL(__VA_ARGS__,)))
54 * A macro that points to an offset from the start
55 * of the crypto operation structure (rte_crypto_op)
57 * The returned pointer is cast to type t.
60 * The crypto operation.
62 * The offset from the start of the crypto operation.
64 * The type to cast the result into.
66 #define rte_crypto_op_ctod_offset(c, t, o) \
67 ((t)((char *)(c) + (o)))
70 * A macro that returns the physical address that points
71 * to an offset from the start of the crypto operation
75 * The crypto operation.
77 * The offset from the start of the crypto operation
78 * to calculate address from.
80 #define rte_crypto_op_ctophys_offset(c, o) \
81 (rte_iova_t)((c)->phys_addr + (o))
84 * Crypto parameters range description
86 struct rte_crypto_param_range {
87 uint16_t min; /**< minimum size */
88 uint16_t max; /**< maximum size */
90 /**< if a range of sizes are supported,
91 * this parameter is used to indicate
92 * increments in byte size that are supported
93 * between the minimum and maximum
98 * Symmetric Crypto Capability
100 struct rte_cryptodev_symmetric_capability {
101 enum rte_crypto_sym_xform_type xform_type;
102 /**< Transform type : Authentication / Cipher / AEAD */
106 enum rte_crypto_auth_algorithm algo;
107 /**< authentication algorithm */
109 /**< algorithm block size */
110 struct rte_crypto_param_range key_size;
111 /**< auth key size range */
112 struct rte_crypto_param_range digest_size;
113 /**< digest size range */
114 struct rte_crypto_param_range aad_size;
115 /**< Additional authentication data size range */
116 struct rte_crypto_param_range iv_size;
117 /**< Initialisation vector data size range */
119 /**< Symmetric Authentication transform capabilities */
121 enum rte_crypto_cipher_algorithm algo;
122 /**< cipher algorithm */
124 /**< algorithm block size */
125 struct rte_crypto_param_range key_size;
126 /**< cipher key size range */
127 struct rte_crypto_param_range iv_size;
128 /**< Initialisation vector data size range */
130 /**< Symmetric Cipher transform capabilities */
132 enum rte_crypto_aead_algorithm algo;
133 /**< AEAD algorithm */
135 /**< algorithm block size */
136 struct rte_crypto_param_range key_size;
137 /**< AEAD key size range */
138 struct rte_crypto_param_range digest_size;
139 /**< digest size range */
140 struct rte_crypto_param_range aad_size;
141 /**< Additional authentication data size range */
142 struct rte_crypto_param_range iv_size;
143 /**< Initialisation vector data size range */
149 * Asymmetric Xform Crypto Capability
152 struct rte_cryptodev_asymmetric_xform_capability {
153 enum rte_crypto_asym_xform_type xform_type;
154 /**< Transform type: RSA/MODEXP/DH/DSA/MODINV */
157 /**< bitmask for supported rte_crypto_asym_op_type */
161 struct rte_crypto_param_range modlen;
162 /**< Range of modulus length supported by modulus based xform.
163 * Value 0 mean implementation default
169 * Asymmetric Crypto Capability
172 struct rte_cryptodev_asymmetric_capability {
173 struct rte_cryptodev_asymmetric_xform_capability xform_capa;
177 /** Structure used to capture a capability of a crypto device */
178 struct rte_cryptodev_capabilities {
179 enum rte_crypto_op_type op;
180 /**< Operation type */
184 struct rte_cryptodev_symmetric_capability sym;
185 /**< Symmetric operation capability parameters */
186 struct rte_cryptodev_asymmetric_capability asym;
187 /**< Asymmetric operation capability parameters */
191 /** Structure used to describe crypto algorithms */
192 struct rte_cryptodev_sym_capability_idx {
193 enum rte_crypto_sym_xform_type type;
195 enum rte_crypto_cipher_algorithm cipher;
196 enum rte_crypto_auth_algorithm auth;
197 enum rte_crypto_aead_algorithm aead;
202 * Structure used to describe asymmetric crypto xforms
203 * Each xform maps to one asym algorithm.
206 struct rte_cryptodev_asym_capability_idx {
207 enum rte_crypto_asym_xform_type type;
208 /**< Asymmetric xform (algo) type */
212 * Provide capabilities available for defined device and algorithm
214 * @param dev_id The identifier of the device.
215 * @param idx Description of crypto algorithms.
218 * - Return description of the symmetric crypto capability if exist.
219 * - Return NULL if the capability not exist.
221 const struct rte_cryptodev_symmetric_capability *
222 rte_cryptodev_sym_capability_get(uint8_t dev_id,
223 const struct rte_cryptodev_sym_capability_idx *idx);
226 * Provide capabilities available for defined device and xform
228 * @param dev_id The identifier of the device.
229 * @param idx Description of asym crypto xform.
232 * - Return description of the asymmetric crypto capability if exist.
233 * - Return NULL if the capability not exist.
236 const struct rte_cryptodev_asymmetric_xform_capability *
237 rte_cryptodev_asym_capability_get(uint8_t dev_id,
238 const struct rte_cryptodev_asym_capability_idx *idx);
241 * Check if key size and initial vector are supported
242 * in crypto cipher capability
244 * @param capability Description of the symmetric crypto capability.
245 * @param key_size Cipher key size.
246 * @param iv_size Cipher initial vector size.
249 * - Return 0 if the parameters are in range of the capability.
250 * - Return -1 if the parameters are out of range of the capability.
253 rte_cryptodev_sym_capability_check_cipher(
254 const struct rte_cryptodev_symmetric_capability *capability,
255 uint16_t key_size, uint16_t iv_size);
258 * Check if key size and initial vector are supported
259 * in crypto auth capability
261 * @param capability Description of the symmetric crypto capability.
262 * @param key_size Auth key size.
263 * @param digest_size Auth digest size.
264 * @param iv_size Auth initial vector size.
267 * - Return 0 if the parameters are in range of the capability.
268 * - Return -1 if the parameters are out of range of the capability.
271 rte_cryptodev_sym_capability_check_auth(
272 const struct rte_cryptodev_symmetric_capability *capability,
273 uint16_t key_size, uint16_t digest_size, uint16_t iv_size);
276 * Check if key, digest, AAD and initial vector sizes are supported
277 * in crypto AEAD capability
279 * @param capability Description of the symmetric crypto capability.
280 * @param key_size AEAD key size.
281 * @param digest_size AEAD digest size.
282 * @param aad_size AEAD AAD size.
283 * @param iv_size AEAD IV size.
286 * - Return 0 if the parameters are in range of the capability.
287 * - Return -1 if the parameters are out of range of the capability.
290 rte_cryptodev_sym_capability_check_aead(
291 const struct rte_cryptodev_symmetric_capability *capability,
292 uint16_t key_size, uint16_t digest_size, uint16_t aad_size,
296 * Check if op type is supported
298 * @param capability Description of the asymmetric crypto capability.
299 * @param op_type op type
302 * - Return 1 if the op type is supported
303 * - Return 0 if unsupported
307 rte_cryptodev_asym_xform_capability_check_optype(
308 const struct rte_cryptodev_asymmetric_xform_capability *capability,
309 enum rte_crypto_asym_op_type op_type);
312 * Check if modulus length is in supported range
314 * @param capability Description of the asymmetric crypto capability.
315 * @param modlen modulus length.
318 * - Return 0 if the parameters are in range of the capability.
319 * - Return -1 if the parameters are out of range of the capability.
323 rte_cryptodev_asym_xform_capability_check_modlen(
324 const struct rte_cryptodev_asymmetric_xform_capability *capability,
328 * Provide the cipher algorithm enum, given an algorithm string
330 * @param algo_enum A pointer to the cipher algorithm
332 * @param algo_string Authentication algo string
335 * - Return -1 if string is not valid
336 * - Return 0 is the string is valid
339 rte_cryptodev_get_cipher_algo_enum(enum rte_crypto_cipher_algorithm *algo_enum,
340 const char *algo_string);
343 * Provide the authentication algorithm enum, given an algorithm string
345 * @param algo_enum A pointer to the authentication algorithm
347 * @param algo_string Authentication algo string
350 * - Return -1 if string is not valid
351 * - Return 0 is the string is valid
354 rte_cryptodev_get_auth_algo_enum(enum rte_crypto_auth_algorithm *algo_enum,
355 const char *algo_string);
358 * Provide the AEAD algorithm enum, given an algorithm string
360 * @param algo_enum A pointer to the AEAD algorithm
362 * @param algo_string AEAD algorithm string
365 * - Return -1 if string is not valid
366 * - Return 0 is the string is valid
369 rte_cryptodev_get_aead_algo_enum(enum rte_crypto_aead_algorithm *algo_enum,
370 const char *algo_string);
373 * Provide the Asymmetric xform enum, given an xform string
375 * @param xform_enum A pointer to the xform type
377 * @param xform_string xform string
380 * - Return -1 if string is not valid
381 * - Return 0 if the string is valid
385 rte_cryptodev_asym_get_xform_enum(enum rte_crypto_asym_xform_type *xform_enum,
386 const char *xform_string);
389 /** Macro used at end of crypto PMD list */
390 #define RTE_CRYPTODEV_END_OF_CAPABILITIES_LIST() \
391 { RTE_CRYPTO_OP_TYPE_UNDEFINED }
395 * Crypto device supported feature flags
398 * New features flags should be added to the end of the list
400 * Keep these flags synchronised with rte_cryptodev_get_feature_name()
402 #define RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO (1ULL << 0)
403 /**< Symmetric crypto operations are supported */
404 #define RTE_CRYPTODEV_FF_ASYMMETRIC_CRYPTO (1ULL << 1)
405 /**< Asymmetric crypto operations are supported */
406 #define RTE_CRYPTODEV_FF_SYM_OPERATION_CHAINING (1ULL << 2)
407 /**< Chaining symmetric crypto operations are supported */
408 #define RTE_CRYPTODEV_FF_CPU_SSE (1ULL << 3)
409 /**< Utilises CPU SIMD SSE instructions */
410 #define RTE_CRYPTODEV_FF_CPU_AVX (1ULL << 4)
411 /**< Utilises CPU SIMD AVX instructions */
412 #define RTE_CRYPTODEV_FF_CPU_AVX2 (1ULL << 5)
413 /**< Utilises CPU SIMD AVX2 instructions */
414 #define RTE_CRYPTODEV_FF_CPU_AESNI (1ULL << 6)
415 /**< Utilises CPU AES-NI instructions */
416 #define RTE_CRYPTODEV_FF_HW_ACCELERATED (1ULL << 7)
417 /**< Operations are off-loaded to an
418 * external hardware accelerator
420 #define RTE_CRYPTODEV_FF_CPU_AVX512 (1ULL << 8)
421 /**< Utilises CPU SIMD AVX512 instructions */
422 #define RTE_CRYPTODEV_FF_IN_PLACE_SGL (1ULL << 9)
423 /**< In-place Scatter-gather (SGL) buffers, with multiple segments,
426 #define RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT (1ULL << 10)
427 /**< Out-of-place Scatter-gather (SGL) buffers are
428 * supported in input and output
430 #define RTE_CRYPTODEV_FF_OOP_SGL_IN_LB_OUT (1ULL << 11)
431 /**< Out-of-place Scatter-gather (SGL) buffers are supported
432 * in input, combined with linear buffers (LB), with a
433 * single segment in output
435 #define RTE_CRYPTODEV_FF_OOP_LB_IN_SGL_OUT (1ULL << 12)
436 /**< Out-of-place Scatter-gather (SGL) buffers are supported
437 * in output, combined with linear buffers (LB) in input
439 #define RTE_CRYPTODEV_FF_OOP_LB_IN_LB_OUT (1ULL << 13)
440 /**< Out-of-place linear buffers (LB) are supported in input and output */
441 #define RTE_CRYPTODEV_FF_CPU_NEON (1ULL << 14)
442 /**< Utilises CPU NEON instructions */
443 #define RTE_CRYPTODEV_FF_CPU_ARM_CE (1ULL << 15)
444 /**< Utilises ARM CPU Cryptographic Extensions */
445 #define RTE_CRYPTODEV_FF_SECURITY (1ULL << 16)
446 /**< Support Security Protocol Processing */
447 #define RTE_CRYPTODEV_FF_RSA_PRIV_OP_KEY_EXP (1ULL << 17)
448 /**< Support RSA Private Key OP with exponent */
449 #define RTE_CRYPTODEV_FF_RSA_PRIV_OP_KEY_QT (1ULL << 18)
450 /**< Support RSA Private Key OP with CRT (quintuple) Keys */
451 #define RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED (1ULL << 19)
452 /**< Support encrypted-digest operations where digest is appended to data */
453 #define RTE_CRYPTODEV_FF_ASYM_SESSIONLESS (1ULL << 20)
454 /**< Support asymmetric session-less operations */
455 #define RTE_CRYPTODEV_FF_SYM_CPU_CRYPTO (1ULL << 21)
456 /**< Support symmetric cpu-crypto processing */
457 #define RTE_CRYPTODEV_FF_SYM_SESSIONLESS (1ULL << 22)
458 /**< Support symmetric session-less operations */
459 #define RTE_CRYPTODEV_FF_NON_BYTE_ALIGNED_DATA (1ULL << 23)
460 /**< Support operations on data which is not byte aligned */
461 #define RTE_CRYPTODEV_FF_SYM_RAW_DP (1ULL << 24)
462 /**< Support accelerator specific symmetric raw data-path APIs */
465 * Get the name of a crypto device feature flag
467 * @param flag The mask describing the flag.
470 * The name of this flag, or NULL if it's not a valid feature flag.
474 rte_cryptodev_get_feature_name(uint64_t flag);
476 /** Crypto device information */
477 struct rte_cryptodev_info {
478 const char *driver_name; /**< Driver name. */
479 uint8_t driver_id; /**< Driver identifier */
480 struct rte_device *device; /**< Generic device information. */
482 uint64_t feature_flags;
483 /**< Feature flags exposes HW/SW features for the given device */
485 const struct rte_cryptodev_capabilities *capabilities;
486 /**< Array of devices supported capabilities */
488 unsigned max_nb_queue_pairs;
489 /**< Maximum number of queues pairs supported by device. */
491 uint16_t min_mbuf_headroom_req;
492 /**< Minimum mbuf headroom required by device */
494 uint16_t min_mbuf_tailroom_req;
495 /**< Minimum mbuf tailroom required by device */
498 unsigned max_nb_sessions;
499 /**< Maximum number of sessions supported by device.
500 * If 0, the device does not have any limitation in
501 * number of sessions that can be used.
506 #define RTE_CRYPTODEV_DETACHED (0)
507 #define RTE_CRYPTODEV_ATTACHED (1)
509 /** Definitions of Crypto device event types */
510 enum rte_cryptodev_event_type {
511 RTE_CRYPTODEV_EVENT_UNKNOWN, /**< unknown event type */
512 RTE_CRYPTODEV_EVENT_ERROR, /**< error interrupt event */
513 RTE_CRYPTODEV_EVENT_MAX /**< max value of this enum */
516 /** Crypto device queue pair configuration structure. */
517 struct rte_cryptodev_qp_conf {
518 uint32_t nb_descriptors; /**< Number of descriptors per queue pair */
519 struct rte_mempool *mp_session;
520 /**< The mempool for creating session in sessionless mode */
521 struct rte_mempool *mp_session_private;
522 /**< The mempool for creating sess private data in sessionless mode */
526 * Typedef for application callback function to be registered by application
527 * software for notification of device events
529 * @param dev_id Crypto device identifier
530 * @param event Crypto device event to register for notification of.
531 * @param cb_arg User specified parameter to be passed as to passed to
532 * users callback function.
534 typedef void (*rte_cryptodev_cb_fn)(uint8_t dev_id,
535 enum rte_cryptodev_event_type event, void *cb_arg);
538 /** Crypto Device statistics */
539 struct rte_cryptodev_stats {
540 uint64_t enqueued_count;
541 /**< Count of all operations enqueued */
542 uint64_t dequeued_count;
543 /**< Count of all operations dequeued */
545 uint64_t enqueue_err_count;
546 /**< Total error count on operations enqueued */
547 uint64_t dequeue_err_count;
548 /**< Total error count on operations dequeued */
551 #define RTE_CRYPTODEV_NAME_MAX_LEN (64)
552 /**< Max length of name of crypto PMD */
555 * Get the device identifier for the named crypto device.
557 * @param name device name to select the device structure.
560 * - Returns crypto device identifier on success.
561 * - Return -1 on failure to find named crypto device.
564 rte_cryptodev_get_dev_id(const char *name);
567 * Get the crypto device name given a device identifier.
570 * The identifier of the device
573 * - Returns crypto device name.
574 * - Returns NULL if crypto device is not present.
577 rte_cryptodev_name_get(uint8_t dev_id);
580 * Get the total number of crypto devices that have been successfully
584 * - The total number of usable crypto devices.
587 rte_cryptodev_count(void);
590 * Get number of crypto device defined type.
592 * @param driver_id driver identifier.
595 * Returns number of crypto device.
598 rte_cryptodev_device_count_by_driver(uint8_t driver_id);
601 * Get number and identifiers of attached crypto devices that
602 * use the same crypto driver.
604 * @param driver_name driver name.
605 * @param devices output devices identifiers.
606 * @param nb_devices maximal number of devices.
609 * Returns number of attached crypto device.
612 rte_cryptodev_devices_get(const char *driver_name, uint8_t *devices,
615 * Return the NUMA socket to which a device is connected
618 * The identifier of the device
620 * The NUMA socket id to which the device is connected or
621 * a default of zero if the socket could not be determined.
622 * -1 if returned is the dev_id value is out of range.
625 rte_cryptodev_socket_id(uint8_t dev_id);
627 /** Crypto device configuration structure */
628 struct rte_cryptodev_config {
629 int socket_id; /**< Socket to allocate resources on */
630 uint16_t nb_queue_pairs;
631 /**< Number of queue pairs to configure on device */
633 /**< Feature flags to be disabled. Only the following features are
634 * allowed to be disabled,
635 * - RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO
636 * - RTE_CRYPTODEV_FF_ASYMMETRIC_CRYPTO
637 * - RTE_CRYTPODEV_FF_SECURITY
642 * Configure a device.
644 * This function must be invoked first before any other function in the
645 * API. This function can also be re-invoked when a device is in the
648 * @param dev_id The identifier of the device to configure.
649 * @param config The crypto device configuration structure.
652 * - 0: Success, device configured.
653 * - <0: Error code returned by the driver configuration function.
656 rte_cryptodev_configure(uint8_t dev_id, struct rte_cryptodev_config *config);
661 * The device start step is the last one and consists of setting the configured
662 * offload features and in starting the transmit and the receive units of the
664 * On success, all basic functions exported by the API (link status,
665 * receive/transmit, and so on) can be invoked.
668 * The identifier of the device.
670 * - 0: Success, device started.
671 * - <0: Error code of the driver device start function.
674 rte_cryptodev_start(uint8_t dev_id);
677 * Stop an device. The device can be restarted with a call to
678 * rte_cryptodev_start()
680 * @param dev_id The identifier of the device.
683 rte_cryptodev_stop(uint8_t dev_id);
686 * Close an device. The device cannot be restarted!
688 * @param dev_id The identifier of the device.
691 * - 0 on successfully closing device
692 * - <0 on failure to close device
695 rte_cryptodev_close(uint8_t dev_id);
698 * Allocate and set up a receive queue pair for a device.
701 * @param dev_id The identifier of the device.
702 * @param queue_pair_id The index of the queue pairs to set up. The
703 * value must be in the range [0, nb_queue_pair
704 * - 1] previously supplied to
705 * rte_cryptodev_configure().
706 * @param qp_conf The pointer to the configuration data to be
707 * used for the queue pair.
708 * @param socket_id The *socket_id* argument is the socket
709 * identifier in case of NUMA. The value can be
710 * *SOCKET_ID_ANY* if there is no NUMA constraint
711 * for the DMA memory allocated for the receive
715 * - 0: Success, queue pair correctly set up.
716 * - <0: Queue pair configuration failed
719 rte_cryptodev_queue_pair_setup(uint8_t dev_id, uint16_t queue_pair_id,
720 const struct rte_cryptodev_qp_conf *qp_conf, int socket_id);
723 * Get the status of queue pairs setup on a specific crypto device
725 * @param dev_id Crypto device identifier.
726 * @param queue_pair_id The index of the queue pairs to set up. The
727 * value must be in the range [0, nb_queue_pair
728 * - 1] previously supplied to
729 * rte_cryptodev_configure().
731 * - 0: qp was not configured
732 * - 1: qp was configured
733 * - -EINVAL: device was not configured
737 rte_cryptodev_get_qp_status(uint8_t dev_id, uint16_t queue_pair_id);
740 * Get the number of queue pairs on a specific crypto device
742 * @param dev_id Crypto device identifier.
744 * - The number of configured queue pairs.
747 rte_cryptodev_queue_pair_count(uint8_t dev_id);
751 * Retrieve the general I/O statistics of a device.
753 * @param dev_id The identifier of the device.
754 * @param stats A pointer to a structure of type
755 * *rte_cryptodev_stats* to be filled with the
756 * values of device counters.
758 * - Zero if successful.
759 * - Non-zero otherwise.
762 rte_cryptodev_stats_get(uint8_t dev_id, struct rte_cryptodev_stats *stats);
765 * Reset the general I/O statistics of a device.
767 * @param dev_id The identifier of the device.
770 rte_cryptodev_stats_reset(uint8_t dev_id);
773 * Retrieve the contextual information of a device.
775 * @param dev_id The identifier of the device.
776 * @param dev_info A pointer to a structure of type
777 * *rte_cryptodev_info* to be filled with the
778 * contextual information of the device.
780 * @note The capabilities field of dev_info is set to point to the first
781 * element of an array of struct rte_cryptodev_capabilities. The element after
782 * the last valid element has it's op field set to
783 * RTE_CRYPTO_OP_TYPE_UNDEFINED.
786 rte_cryptodev_info_get(uint8_t dev_id, struct rte_cryptodev_info *dev_info);
790 * Register a callback function for specific device id.
792 * @param dev_id Device id.
793 * @param event Event interested.
794 * @param cb_fn User supplied callback function to be called.
795 * @param cb_arg Pointer to the parameters for the registered
799 * - On success, zero.
800 * - On failure, a negative value.
803 rte_cryptodev_callback_register(uint8_t dev_id,
804 enum rte_cryptodev_event_type event,
805 rte_cryptodev_cb_fn cb_fn, void *cb_arg);
808 * Unregister a callback function for specific device id.
810 * @param dev_id The device identifier.
811 * @param event Event interested.
812 * @param cb_fn User supplied callback function to be called.
813 * @param cb_arg Pointer to the parameters for the registered
817 * - On success, zero.
818 * - On failure, a negative value.
821 rte_cryptodev_callback_unregister(uint8_t dev_id,
822 enum rte_cryptodev_event_type event,
823 rte_cryptodev_cb_fn cb_fn, void *cb_arg);
826 typedef uint16_t (*dequeue_pkt_burst_t)(void *qp,
827 struct rte_crypto_op **ops, uint16_t nb_ops);
828 /**< Dequeue processed packets from queue pair of a device. */
830 typedef uint16_t (*enqueue_pkt_burst_t)(void *qp,
831 struct rte_crypto_op **ops, uint16_t nb_ops);
832 /**< Enqueue packets for processing on queue pair of a device. */
837 struct rte_cryptodev_callback;
839 /** Structure to keep track of registered callbacks */
840 TAILQ_HEAD(rte_cryptodev_cb_list, rte_cryptodev_callback);
842 /** The data structure associated with each crypto device. */
843 struct rte_cryptodev {
844 dequeue_pkt_burst_t dequeue_burst;
845 /**< Pointer to PMD receive function. */
846 enqueue_pkt_burst_t enqueue_burst;
847 /**< Pointer to PMD transmit function. */
849 struct rte_cryptodev_data *data;
850 /**< Pointer to device data */
851 struct rte_cryptodev_ops *dev_ops;
852 /**< Functions exported by PMD */
853 uint64_t feature_flags;
854 /**< Feature flags exposes HW/SW features for the given device */
855 struct rte_device *device;
856 /**< Backing device */
859 /**< Crypto driver identifier*/
861 struct rte_cryptodev_cb_list link_intr_cbs;
862 /**< User application callback for interrupts if present */
865 /**< Context for security ops */
868 uint8_t attached : 1;
869 /**< Flag indicating the device is attached */
870 } __rte_cache_aligned;
873 rte_cryptodev_get_sec_ctx(uint8_t dev_id);
877 * The data part, with no function pointers, associated with each device.
879 * This structure is safe to place in shared memory to be common among
880 * different processes in a multi-process configuration.
882 struct rte_cryptodev_data {
884 /**< Device ID for this instance */
886 /**< Socket ID where memory is allocated */
887 char name[RTE_CRYPTODEV_NAME_MAX_LEN];
888 /**< Unique identifier name */
891 uint8_t dev_started : 1;
892 /**< Device state: STARTED(1)/STOPPED(0) */
894 struct rte_mempool *session_pool;
895 /**< Session memory pool */
897 /**< Array of pointers to queue pairs. */
898 uint16_t nb_queue_pairs;
899 /**< Number of device queue pairs. */
902 /**< PMD-specific private data */
903 } __rte_cache_aligned;
905 extern struct rte_cryptodev *rte_cryptodevs;
908 * Dequeue a burst of processed crypto operations from a queue on the crypto
909 * device. The dequeued operation are stored in *rte_crypto_op* structures
910 * whose pointers are supplied in the *ops* array.
912 * The rte_cryptodev_dequeue_burst() function returns the number of ops
913 * actually dequeued, which is the number of *rte_crypto_op* data structures
914 * effectively supplied into the *ops* array.
916 * A return value equal to *nb_ops* indicates that the queue contained
917 * at least *nb_ops* operations, and this is likely to signify that other
918 * processed operations remain in the devices output queue. Applications
919 * implementing a "retrieve as many processed operations as possible" policy
920 * can check this specific case and keep invoking the
921 * rte_cryptodev_dequeue_burst() function until a value less than
922 * *nb_ops* is returned.
924 * The rte_cryptodev_dequeue_burst() function does not provide any error
925 * notification to avoid the corresponding overhead.
927 * @param dev_id The symmetric crypto device identifier
928 * @param qp_id The index of the queue pair from which to
929 * retrieve processed packets. The value must be
930 * in the range [0, nb_queue_pair - 1] previously
931 * supplied to rte_cryptodev_configure().
932 * @param ops The address of an array of pointers to
933 * *rte_crypto_op* structures that must be
934 * large enough to store *nb_ops* pointers in it.
935 * @param nb_ops The maximum number of operations to dequeue.
938 * - The number of operations actually dequeued, which is the number
939 * of pointers to *rte_crypto_op* structures effectively supplied to the
942 static inline uint16_t
943 rte_cryptodev_dequeue_burst(uint8_t dev_id, uint16_t qp_id,
944 struct rte_crypto_op **ops, uint16_t nb_ops)
946 struct rte_cryptodev *dev = &rte_cryptodevs[dev_id];
948 nb_ops = (*dev->dequeue_burst)
949 (dev->data->queue_pairs[qp_id], ops, nb_ops);
951 rte_cryptodev_trace_dequeue_burst(dev_id, qp_id, (void **)ops, nb_ops);
956 * Enqueue a burst of operations for processing on a crypto device.
958 * The rte_cryptodev_enqueue_burst() function is invoked to place
959 * crypto operations on the queue *qp_id* of the device designated by
962 * The *nb_ops* parameter is the number of operations to process which are
963 * supplied in the *ops* array of *rte_crypto_op* structures.
965 * The rte_cryptodev_enqueue_burst() function returns the number of
966 * operations it actually enqueued for processing. A return value equal to
967 * *nb_ops* means that all packets have been enqueued.
969 * @param dev_id The identifier of the device.
970 * @param qp_id The index of the queue pair which packets are
971 * to be enqueued for processing. The value
972 * must be in the range [0, nb_queue_pairs - 1]
973 * previously supplied to
974 * *rte_cryptodev_configure*.
975 * @param ops The address of an array of *nb_ops* pointers
976 * to *rte_crypto_op* structures which contain
977 * the crypto operations to be processed.
978 * @param nb_ops The number of operations to process.
981 * The number of operations actually enqueued on the crypto device. The return
982 * value can be less than the value of the *nb_ops* parameter when the
983 * crypto devices queue is full or if invalid parameters are specified in
986 static inline uint16_t
987 rte_cryptodev_enqueue_burst(uint8_t dev_id, uint16_t qp_id,
988 struct rte_crypto_op **ops, uint16_t nb_ops)
990 struct rte_cryptodev *dev = &rte_cryptodevs[dev_id];
992 rte_cryptodev_trace_enqueue_burst(dev_id, qp_id, (void **)ops, nb_ops);
993 return (*dev->enqueue_burst)(
994 dev->data->queue_pairs[qp_id], ops, nb_ops);
998 /** Cryptodev symmetric crypto session
999 * Each session is derived from a fixed xform chain. Therefore each session
1000 * has a fixed algo, key, op-type, digest_len etc.
1002 struct rte_cryptodev_sym_session {
1003 uint64_t opaque_data;
1004 /**< Can be used for external metadata */
1005 uint16_t nb_drivers;
1006 /**< number of elements in sess_data array */
1007 uint16_t user_data_sz;
1008 /**< session user data will be placed after sess_data */
1009 __extension__ struct {
1013 /**< Driver specific session material, variable size */
1016 /** Cryptodev asymmetric crypto session */
1017 struct rte_cryptodev_asym_session {
1018 __extension__ void *sess_private_data[0];
1019 /**< Private asymmetric session material */
1023 * Create a symmetric session mempool.
1026 * The unique mempool name.
1028 * The number of elements in the mempool.
1030 * The size of the element. This value will be ignored if it is smaller than
1031 * the minimum session header size required for the system. For the user who
1032 * want to use the same mempool for sym session and session private data it
1033 * can be the maximum value of all existing devices' private data and session
1036 * The number of per-lcore cache elements
1038 * The private data size of each session.
1040 * The *socket_id* argument is the socket identifier in the case of
1041 * NUMA. The value can be *SOCKET_ID_ANY* if there is no NUMA
1042 * constraint for the reserved zone.
1045 * - On success return size of the session
1046 * - On failure returns 0
1049 struct rte_mempool *
1050 rte_cryptodev_sym_session_pool_create(const char *name, uint32_t nb_elts,
1051 uint32_t elt_size, uint32_t cache_size, uint16_t priv_size,
1055 * Create symmetric crypto session header (generic with no private data)
1057 * @param mempool Symmetric session mempool to allocate session
1060 * - On success return pointer to sym-session
1061 * - On failure returns NULL
1063 struct rte_cryptodev_sym_session *
1064 rte_cryptodev_sym_session_create(struct rte_mempool *mempool);
1067 * Create asymmetric crypto session header (generic with no private data)
1069 * @param mempool mempool to allocate asymmetric session
1072 * - On success return pointer to asym-session
1073 * - On failure returns NULL
1076 struct rte_cryptodev_asym_session *
1077 rte_cryptodev_asym_session_create(struct rte_mempool *mempool);
1080 * Frees symmetric crypto session header, after checking that all
1081 * the device private data has been freed, returning it
1082 * to its original mempool.
1084 * @param sess Session header to be freed.
1087 * - 0 if successful.
1088 * - -EINVAL if session is NULL.
1089 * - -EBUSY if not all device private data has been freed.
1092 rte_cryptodev_sym_session_free(struct rte_cryptodev_sym_session *sess);
1095 * Frees asymmetric crypto session header, after checking that all
1096 * the device private data has been freed, returning it
1097 * to its original mempool.
1099 * @param sess Session header to be freed.
1102 * - 0 if successful.
1103 * - -EINVAL if session is NULL.
1104 * - -EBUSY if not all device private data has been freed.
1108 rte_cryptodev_asym_session_free(struct rte_cryptodev_asym_session *sess);
1111 * Fill out private data for the device id, based on its device type.
1113 * @param dev_id ID of device that we want the session to be used on
1114 * @param sess Session where the private data will be attached to
1115 * @param xforms Symmetric crypto transform operations to apply on flow
1116 * processed with this session
1117 * @param mempool Mempool where the private data is allocated.
1120 * - On success, zero.
1121 * - -EINVAL if input parameters are invalid.
1122 * - -ENOTSUP if crypto device does not support the crypto transform or
1123 * does not support symmetric operations.
1124 * - -ENOMEM if the private session could not be allocated.
1127 rte_cryptodev_sym_session_init(uint8_t dev_id,
1128 struct rte_cryptodev_sym_session *sess,
1129 struct rte_crypto_sym_xform *xforms,
1130 struct rte_mempool *mempool);
1133 * Initialize asymmetric session on a device with specific asymmetric xform
1135 * @param dev_id ID of device that we want the session to be used on
1136 * @param sess Session to be set up on a device
1137 * @param xforms Asymmetric crypto transform operations to apply on flow
1138 * processed with this session
1139 * @param mempool Mempool to be used for internal allocation.
1142 * - On success, zero.
1143 * - -EINVAL if input parameters are invalid.
1144 * - -ENOTSUP if crypto device does not support the crypto transform.
1145 * - -ENOMEM if the private session could not be allocated.
1149 rte_cryptodev_asym_session_init(uint8_t dev_id,
1150 struct rte_cryptodev_asym_session *sess,
1151 struct rte_crypto_asym_xform *xforms,
1152 struct rte_mempool *mempool);
1155 * Frees private data for the device id, based on its device type,
1156 * returning it to its mempool. It is the application's responsibility
1157 * to ensure that private session data is not cleared while there are
1158 * still in-flight operations using it.
1160 * @param dev_id ID of device that uses the session.
1161 * @param sess Session containing the reference to the private data
1164 * - 0 if successful.
1165 * - -EINVAL if device is invalid or session is NULL.
1166 * - -ENOTSUP if crypto device does not support symmetric operations.
1169 rte_cryptodev_sym_session_clear(uint8_t dev_id,
1170 struct rte_cryptodev_sym_session *sess);
1173 * Frees resources held by asymmetric session during rte_cryptodev_session_init
1175 * @param dev_id ID of device that uses the asymmetric session.
1176 * @param sess Asymmetric session setup on device using
1177 * rte_cryptodev_session_init
1179 * - 0 if successful.
1180 * - -EINVAL if device is invalid or session is NULL.
1184 rte_cryptodev_asym_session_clear(uint8_t dev_id,
1185 struct rte_cryptodev_asym_session *sess);
1188 * Get the size of the header session, for all registered drivers excluding
1189 * the user data size.
1192 * Size of the symmetric header session.
1195 rte_cryptodev_sym_get_header_session_size(void);
1198 * Get the size of the header session from created session.
1201 * The sym cryptodev session pointer
1204 * - If sess is not NULL, return the size of the header session including
1205 * the private data size defined within sess.
1206 * - If sess is NULL, return 0.
1210 rte_cryptodev_sym_get_existing_header_session_size(
1211 struct rte_cryptodev_sym_session *sess);
1214 * Get the size of the asymmetric session header, for all registered drivers.
1217 * Size of the asymmetric header session.
1221 rte_cryptodev_asym_get_header_session_size(void);
1224 * Get the size of the private symmetric session data
1227 * @param dev_id The device identifier.
1230 * - Size of the private data, if successful
1231 * - 0 if device is invalid or does not have private
1235 rte_cryptodev_sym_get_private_session_size(uint8_t dev_id);
1238 * Get the size of the private data for asymmetric session
1241 * @param dev_id The device identifier.
1244 * - Size of the asymmetric private data, if successful
1245 * - 0 if device is invalid or does not have private session
1249 rte_cryptodev_asym_get_private_session_size(uint8_t dev_id);
1252 * Provide driver identifier.
1255 * The pointer to a driver name.
1257 * The driver type identifier or -1 if no driver found
1259 int rte_cryptodev_driver_id_get(const char *name);
1262 * Provide driver name.
1265 * The driver identifier.
1267 * The driver name or null if no driver found
1269 const char *rte_cryptodev_driver_name_get(uint8_t driver_id);
1272 * Store user data in a session.
1274 * @param sess Session pointer allocated by
1275 * *rte_cryptodev_sym_session_create*.
1276 * @param data Pointer to the user data.
1277 * @param size Size of the user data.
1280 * - On success, zero.
1281 * - On failure, a negative value.
1285 rte_cryptodev_sym_session_set_user_data(
1286 struct rte_cryptodev_sym_session *sess,
1291 * Get user data stored in a session.
1293 * @param sess Session pointer allocated by
1294 * *rte_cryptodev_sym_session_create*.
1297 * - On success return pointer to user data.
1298 * - On failure returns NULL.
1302 rte_cryptodev_sym_session_get_user_data(
1303 struct rte_cryptodev_sym_session *sess);
1306 * Perform actual crypto processing (encrypt/digest or auth/decrypt)
1307 * on user provided data.
1309 * @param dev_id The device identifier.
1310 * @param sess Cryptodev session structure
1311 * @param ofs Start and stop offsets for auth and cipher operations
1312 * @param vec Vectorized operation descriptor
1315 * - Returns number of successfully processed packets.
1319 rte_cryptodev_sym_cpu_crypto_process(uint8_t dev_id,
1320 struct rte_cryptodev_sym_session *sess, union rte_crypto_sym_ofs ofs,
1321 struct rte_crypto_sym_vec *vec);
1324 * Get the size of the raw data-path context buffer.
1326 * @param dev_id The device identifier.
1329 * - If the device supports raw data-path APIs, return the context size.
1330 * - If the device does not support the APIs, return -1.
1334 rte_cryptodev_get_raw_dp_ctx_size(uint8_t dev_id);
1337 * Union of different crypto session types, including session-less xform
1340 union rte_cryptodev_session_ctx {
1341 struct rte_cryptodev_sym_session *crypto_sess;
1342 struct rte_crypto_sym_xform *xform;
1343 struct rte_security_session *sec_sess;
1347 * Enqueue a vectorized operation descriptor into the device queue but the
1348 * driver may or may not start processing until rte_cryptodev_raw_enqueue_done()
1351 * @param qp Driver specific queue pair data.
1352 * @param drv_ctx Driver specific context data.
1353 * @param vec Vectorized operation descriptor.
1354 * @param ofs Start and stop offsets for auth and cipher
1356 * @param user_data The array of user data for dequeue later.
1357 * @param enqueue_status Driver written value to specify the
1358 * enqueue status. Possible values:
1359 * - 1: The number of operations returned are
1360 * enqueued successfully.
1361 * - 0: The number of operations returned are
1362 * cached into the queue but are not processed
1363 * until rte_cryptodev_raw_enqueue_done() is
1365 * - negative integer: Error occurred.
1367 * - The number of operations in the descriptor successfully enqueued or
1368 * cached into the queue but not enqueued yet, depends on the
1369 * "enqueue_status" value.
1371 typedef uint32_t (*cryptodev_sym_raw_enqueue_burst_t)(
1372 void *qp, uint8_t *drv_ctx, struct rte_crypto_sym_vec *vec,
1373 union rte_crypto_sym_ofs ofs, void *user_data[], int *enqueue_status);
1376 * Enqueue single raw data vector into the device queue but the driver may or
1377 * may not start processing until rte_cryptodev_raw_enqueue_done() is called.
1379 * @param qp Driver specific queue pair data.
1380 * @param drv_ctx Driver specific context data.
1381 * @param data_vec The buffer data vector.
1382 * @param n_data_vecs Number of buffer data vectors.
1383 * @param ofs Start and stop offsets for auth and cipher
1385 * @param iv IV virtual and IOVA addresses
1386 * @param digest digest virtual and IOVA addresses
1387 * @param aad_or_auth_iv AAD or auth IV virtual and IOVA addresses,
1388 * depends on the algorithm used.
1389 * @param user_data The user data.
1391 * - 1: The data vector is enqueued successfully.
1392 * - 0: The data vector is cached into the queue but is not processed
1393 * until rte_cryptodev_raw_enqueue_done() is called.
1394 * - negative integer: failure.
1396 typedef int (*cryptodev_sym_raw_enqueue_t)(
1397 void *qp, uint8_t *drv_ctx, struct rte_crypto_vec *data_vec,
1398 uint16_t n_data_vecs, union rte_crypto_sym_ofs ofs,
1399 struct rte_crypto_va_iova_ptr *iv,
1400 struct rte_crypto_va_iova_ptr *digest,
1401 struct rte_crypto_va_iova_ptr *aad_or_auth_iv,
1405 * Inform the cryptodev queue pair to start processing or finish dequeuing all
1406 * enqueued/dequeued operations.
1408 * @param qp Driver specific queue pair data.
1409 * @param drv_ctx Driver specific context data.
1410 * @param n The total number of processed operations.
1412 * - On success return 0.
1413 * - On failure return negative integer.
1415 typedef int (*cryptodev_sym_raw_operation_done_t)(void *qp, uint8_t *drv_ctx,
1419 * Typedef that the user provided for the driver to get the dequeue count.
1420 * The function may return a fixed number or the number parsed from the user
1421 * data stored in the first processed operation.
1423 * @param user_data Dequeued user data.
1425 * - The number of operations to be dequeued.
1427 typedef uint32_t (*rte_cryptodev_raw_get_dequeue_count_t)(void *user_data);
1430 * Typedef that the user provided to deal with post dequeue operation, such
1431 * as filling status.
1433 * @param user_data Dequeued user data.
1434 * @param index Index number of the processed descriptor.
1435 * @param is_op_success Operation status provided by the driver.
1437 typedef void (*rte_cryptodev_raw_post_dequeue_t)(void *user_data,
1438 uint32_t index, uint8_t is_op_success);
1441 * Dequeue a burst of symmetric crypto processing.
1443 * @param qp Driver specific queue pair data.
1444 * @param drv_ctx Driver specific context data.
1445 * @param get_dequeue_count User provided callback function to
1446 * obtain dequeue operation count.
1447 * @param post_dequeue User provided callback function to
1448 * post-process a dequeued operation.
1449 * @param out_user_data User data pointer array to be retrieve
1450 * from device queue. In case of
1451 * *is_user_data_array* is set there
1452 * should be enough room to store all
1454 * @param is_user_data_array Set 1 if every dequeued user data will
1455 * be written into out_user_data array.
1456 * Set 0 if only the first user data will
1457 * be written into out_user_data array.
1458 * @param n_success Driver written value to specific the
1459 * total successful operations count.
1460 * @param dequeue_status Driver written value to specify the
1461 * dequeue status. Possible values:
1462 * - 1: Successfully dequeued the number
1463 * of operations returned. The user
1464 * data previously set during enqueue
1465 * is stored in the "out_user_data".
1466 * - 0: The number of operations returned
1467 * are completed and the user data is
1468 * stored in the "out_user_data", but
1469 * they are not freed from the queue
1471 * rte_cryptodev_raw_dequeue_done()
1473 * - negative integer: Error occurred.
1475 * - The number of operations dequeued or completed but not freed from the
1476 * queue, depends on "dequeue_status" value.
1478 typedef uint32_t (*cryptodev_sym_raw_dequeue_burst_t)(void *qp,
1480 rte_cryptodev_raw_get_dequeue_count_t get_dequeue_count,
1481 rte_cryptodev_raw_post_dequeue_t post_dequeue,
1482 void **out_user_data, uint8_t is_user_data_array,
1483 uint32_t *n_success, int *dequeue_status);
1486 * Dequeue a symmetric crypto processing.
1488 * @param qp Driver specific queue pair data.
1489 * @param drv_ctx Driver specific context data.
1490 * @param dequeue_status Driver written value to specify the
1491 * dequeue status. Possible values:
1492 * - 1: Successfully dequeued a operation.
1493 * The user data is returned.
1494 * - 0: The first operation in the queue
1495 * is completed and the user data
1496 * previously set during enqueue is
1497 * returned, but it is not freed from
1499 * rte_cryptodev_raw_dequeue_done() is
1501 * - negative integer: Error occurred.
1502 * @param op_status Driver written value to specify
1505 * - The user data pointer retrieved from device queue or NULL if no
1506 * operation is ready for dequeue.
1508 typedef void * (*cryptodev_sym_raw_dequeue_t)(
1509 void *qp, uint8_t *drv_ctx, int *dequeue_status,
1510 enum rte_crypto_op_status *op_status);
1513 * Context data for raw data-path API crypto process. The buffer of this
1514 * structure is to be allocated by the user application with the size equal
1515 * or bigger than rte_cryptodev_get_raw_dp_ctx_size() returned value.
1517 struct rte_crypto_raw_dp_ctx {
1520 cryptodev_sym_raw_enqueue_t enqueue;
1521 cryptodev_sym_raw_enqueue_burst_t enqueue_burst;
1522 cryptodev_sym_raw_operation_done_t enqueue_done;
1523 cryptodev_sym_raw_dequeue_t dequeue;
1524 cryptodev_sym_raw_dequeue_burst_t dequeue_burst;
1525 cryptodev_sym_raw_operation_done_t dequeue_done;
1527 /* Driver specific context data */
1528 __extension__ uint8_t drv_ctx_data[];
1532 * Configure raw data-path context data.
1535 * After the context data is configured, the user should call
1536 * rte_cryptodev_raw_attach_session() before using it in
1537 * rte_cryptodev_raw_enqueue/dequeue function call.
1539 * @param dev_id The device identifier.
1540 * @param qp_id The index of the queue pair from which to
1541 * retrieve processed packets. The value must be
1542 * in the range [0, nb_queue_pair - 1] previously
1543 * supplied to rte_cryptodev_configure().
1544 * @param ctx The raw data-path context data.
1545 * @param sess_type session type.
1546 * @param session_ctx Session context data.
1547 * @param is_update Set 0 if it is to initialize the ctx.
1548 * Set 1 if ctx is initialized and only to update
1549 * session context data.
1551 * - On success return 0.
1552 * - On failure return negative integer.
1556 rte_cryptodev_configure_raw_dp_ctx(uint8_t dev_id, uint16_t qp_id,
1557 struct rte_crypto_raw_dp_ctx *ctx,
1558 enum rte_crypto_op_sess_type sess_type,
1559 union rte_cryptodev_session_ctx session_ctx,
1563 * Enqueue a vectorized operation descriptor into the device queue but the
1564 * driver may or may not start processing until rte_cryptodev_raw_enqueue_done()
1567 * @param ctx The initialized raw data-path context data.
1568 * @param vec Vectorized operation descriptor.
1569 * @param ofs Start and stop offsets for auth and cipher
1571 * @param user_data The array of user data for dequeue later.
1572 * @param enqueue_status Driver written value to specify the
1573 * enqueue status. Possible values:
1574 * - 1: The number of operations returned are
1575 * enqueued successfully.
1576 * - 0: The number of operations returned are
1577 * cached into the queue but are not processed
1578 * until rte_cryptodev_raw_enqueue_done() is
1580 * - negative integer: Error occurred.
1582 * - The number of operations in the descriptor successfully enqueued or
1583 * cached into the queue but not enqueued yet, depends on the
1584 * "enqueue_status" value.
1588 rte_cryptodev_raw_enqueue_burst(struct rte_crypto_raw_dp_ctx *ctx,
1589 struct rte_crypto_sym_vec *vec, union rte_crypto_sym_ofs ofs,
1590 void **user_data, int *enqueue_status);
1593 * Enqueue single raw data vector into the device queue but the driver may or
1594 * may not start processing until rte_cryptodev_raw_enqueue_done() is called.
1596 * @param ctx The initialized raw data-path context data.
1597 * @param data_vec The buffer data vector.
1598 * @param n_data_vecs Number of buffer data vectors.
1599 * @param ofs Start and stop offsets for auth and cipher
1601 * @param iv IV virtual and IOVA addresses
1602 * @param digest digest virtual and IOVA addresses
1603 * @param aad_or_auth_iv AAD or auth IV virtual and IOVA addresses,
1604 * depends on the algorithm used.
1605 * @param user_data The user data.
1607 * - 1: The data vector is enqueued successfully.
1608 * - 0: The data vector is cached into the queue but is not processed
1609 * until rte_cryptodev_raw_enqueue_done() is called.
1610 * - negative integer: failure.
1613 static __rte_always_inline int
1614 rte_cryptodev_raw_enqueue(struct rte_crypto_raw_dp_ctx *ctx,
1615 struct rte_crypto_vec *data_vec, uint16_t n_data_vecs,
1616 union rte_crypto_sym_ofs ofs,
1617 struct rte_crypto_va_iova_ptr *iv,
1618 struct rte_crypto_va_iova_ptr *digest,
1619 struct rte_crypto_va_iova_ptr *aad_or_auth_iv,
1622 return (*ctx->enqueue)(ctx->qp_data, ctx->drv_ctx_data, data_vec,
1623 n_data_vecs, ofs, iv, digest, aad_or_auth_iv, user_data);
1627 * Start processing all enqueued operations from last
1628 * rte_cryptodev_configure_raw_dp_ctx() call.
1630 * @param ctx The initialized raw data-path context data.
1631 * @param n The number of operations cached.
1633 * - On success return 0.
1634 * - On failure return negative integer.
1638 rte_cryptodev_raw_enqueue_done(struct rte_crypto_raw_dp_ctx *ctx,
1642 * Dequeue a burst of symmetric crypto processing.
1644 * @param ctx The initialized raw data-path context
1646 * @param get_dequeue_count User provided callback function to
1647 * obtain dequeue operation count.
1648 * @param post_dequeue User provided callback function to
1649 * post-process a dequeued operation.
1650 * @param out_user_data User data pointer array to be retrieve
1651 * from device queue. In case of
1652 * *is_user_data_array* is set there
1653 * should be enough room to store all
1655 * @param is_user_data_array Set 1 if every dequeued user data will
1656 * be written into out_user_data array.
1657 * Set 0 if only the first user data will
1658 * be written into out_user_data array.
1659 * @param n_success Driver written value to specific the
1660 * total successful operations count.
1661 * @param dequeue_status Driver written value to specify the
1662 * dequeue status. Possible values:
1663 * - 1: Successfully dequeued the number
1664 * of operations returned. The user
1665 * data previously set during enqueue
1666 * is stored in the "out_user_data".
1667 * - 0: The number of operations returned
1668 * are completed and the user data is
1669 * stored in the "out_user_data", but
1670 * they are not freed from the queue
1672 * rte_cryptodev_raw_dequeue_done()
1674 * - negative integer: Error occurred.
1676 * - The number of operations dequeued or completed but not freed from the
1677 * queue, depends on "dequeue_status" value.
1681 rte_cryptodev_raw_dequeue_burst(struct rte_crypto_raw_dp_ctx *ctx,
1682 rte_cryptodev_raw_get_dequeue_count_t get_dequeue_count,
1683 rte_cryptodev_raw_post_dequeue_t post_dequeue,
1684 void **out_user_data, uint8_t is_user_data_array,
1685 uint32_t *n_success, int *dequeue_status);
1688 * Dequeue a symmetric crypto processing.
1690 * @param ctx The initialized raw data-path context
1692 * @param dequeue_status Driver written value to specify the
1693 * dequeue status. Possible values:
1694 * - 1: Successfully dequeued a operation.
1695 * The user data is returned.
1696 * - 0: The first operation in the queue
1697 * is completed and the user data
1698 * previously set during enqueue is
1699 * returned, but it is not freed from
1701 * rte_cryptodev_raw_dequeue_done() is
1703 * - negative integer: Error occurred.
1704 * @param op_status Driver written value to specify
1707 * - The user data pointer retrieved from device queue or NULL if no
1708 * operation is ready for dequeue.
1711 static __rte_always_inline void *
1712 rte_cryptodev_raw_dequeue(struct rte_crypto_raw_dp_ctx *ctx,
1713 int *dequeue_status, enum rte_crypto_op_status *op_status)
1715 return (*ctx->dequeue)(ctx->qp_data, ctx->drv_ctx_data, dequeue_status,
1720 * Inform the queue pair dequeue operations is finished.
1722 * @param ctx The initialized raw data-path context data.
1723 * @param n The number of operations.
1725 * - On success return 0.
1726 * - On failure return negative integer.
1730 rte_cryptodev_raw_dequeue_done(struct rte_crypto_raw_dp_ctx *ctx,
1737 #endif /* _RTE_CRYPTODEV_H_ */