1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright(c) 2015-2016 Intel Corporation
5 #ifndef _RTE_AESNI_MB_PMD_PRIVATE_H_
6 #define _RTE_AESNI_MB_PMD_PRIVATE_H_
8 #include "aesni_mb_ops.h"
10 #define CRYPTODEV_NAME_AESNI_MB_PMD crypto_aesni_mb
11 /**< AES-NI Multi buffer PMD device name */
13 #define MB_LOG_ERR(fmt, args...) \
14 RTE_LOG(ERR, CRYPTODEV, "[%s] %s() line %u: " fmt "\n", \
15 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD), \
16 __func__, __LINE__, ## args)
18 #ifdef RTE_LIBRTE_AESNI_MB_DEBUG
19 #define MB_LOG_INFO(fmt, args...) \
20 RTE_LOG(INFO, CRYPTODEV, "[%s] %s() line %u: " fmt "\n", \
21 CRYPTODEV_NAME_AESNI_MB_PMD, \
22 __func__, __LINE__, ## args)
24 #define MB_LOG_DBG(fmt, args...) \
25 RTE_LOG(DEBUG, CRYPTODEV, "[%s] %s() line %u: " fmt "\n", \
26 CRYPTODEV_NAME_AESNI_MB_PMD, \
27 __func__, __LINE__, ## args)
29 #define MB_LOG_INFO(fmt, args...)
30 #define MB_LOG_DBG(fmt, args...)
33 #define HMAC_IPAD_VALUE (0x36)
34 #define HMAC_OPAD_VALUE (0x5C)
36 /* Maximum length for digest (SHA-512 truncated needs 32 bytes) */
37 #define DIGEST_LENGTH_MAX 32
38 static const unsigned auth_blocksize[] = {
50 * Get the blocksize in bytes for a specified authentication algorithm
52 * @Note: this function will not return a valid value for a non-valid
53 * authentication algorithm
55 static inline unsigned
56 get_auth_algo_blocksize(JOB_HASH_ALG algo)
58 return auth_blocksize[algo];
61 static const unsigned auth_truncated_digest_byte_lengths[] = {
74 * Get the IPsec specified truncated length in bytes of the HMAC digest for a
75 * specified authentication algorithm
77 * @Note: this function will not return a valid value for a non-valid
78 * authentication algorithm
80 static inline unsigned
81 get_truncated_digest_byte_length(JOB_HASH_ALG algo)
83 return auth_truncated_digest_byte_lengths[algo];
86 static const unsigned auth_digest_byte_lengths[] = {
98 * Get the output digest size in bytes for a specified authentication algorithm
100 * @Note: this function will not return a valid value for a non-valid
101 * authentication algorithm
103 static inline unsigned
104 get_digest_byte_length(JOB_HASH_ALG algo)
106 return auth_digest_byte_lengths[algo];
109 enum aesni_mb_operation {
110 AESNI_MB_OP_HASH_CIPHER,
111 AESNI_MB_OP_CIPHER_HASH,
112 AESNI_MB_OP_HASH_ONLY,
113 AESNI_MB_OP_CIPHER_ONLY,
114 AESNI_MB_OP_AEAD_HASH_CIPHER,
115 AESNI_MB_OP_AEAD_CIPHER_HASH,
116 AESNI_MB_OP_NOT_SUPPORTED
119 /** private data structure for each virtual AESNI device */
120 struct aesni_mb_private {
121 enum aesni_mb_vector_mode vector_mode;
122 /**< CPU vector instruction set mode */
123 unsigned max_nb_queue_pairs;
124 /**< Max number of queue pairs supported by device */
125 unsigned max_nb_sessions;
126 /**< Max number of sessions supported by device */
129 /** AESNI Multi buffer queue pair */
132 /**< Queue Pair Identifier */
133 char name[RTE_CRYPTODEV_NAME_LEN];
134 /**< Unique Queue Pair Name */
135 const struct aesni_mb_op_fns *op_fns;
136 /**< Vector mode dependent pointer table of the multi-buffer APIs */
138 /**< Multi-buffer instance */
139 struct rte_ring *ingress_queue;
140 /**< Ring for placing operations ready for processing */
141 struct rte_mempool *sess_mp;
142 /**< Session Mempool */
143 struct rte_cryptodev_stats stats;
144 /**< Queue pair statistics */
146 /**< Index of the next slot to be used in temp_digests,
147 * to store the digest for a given operation
149 uint8_t temp_digests[MAX_JOBS][DIGEST_LENGTH_MAX];
150 /**< Buffers used to store the digest generated
151 * by the driver when verifying a digest provided
152 * by the user (using authentication verify operation)
154 } __rte_cache_aligned;
156 /** AES-NI multi-buffer private session structure */
157 struct aesni_mb_session {
158 JOB_CHAIN_ORDER chain_order;
163 /**< IV parameters */
165 /** Cipher Parameters */
167 /** Cipher direction - encrypt / decrypt */
168 JOB_CIPHER_DIRECTION direction;
169 /** Cipher mode - CBC / Counter */
170 JOB_CIPHER_MODE mode;
172 uint64_t key_length_in_bytes;
175 uint32_t encode[60] __rte_aligned(16);
177 uint32_t decode[60] __rte_aligned(16);
180 /**< Expanded AES keys - Allocating space to
181 * contain the maximum expanded key size which
182 * is 240 bytes for 256 bit AES, calculate by:
183 * ((key size (bytes)) *
184 * ((number of rounds) + 1))
188 /** Authentication Parameters */
190 JOB_HASH_ALG algo; /**< Authentication Algorithm */
191 enum rte_crypto_auth_operation operation;
192 /**< auth operation generate or verify */
195 uint8_t inner[128] __rte_aligned(16);
197 uint8_t outer[128] __rte_aligned(16);
200 /**< HMAC Authentication pads -
201 * allocating space for the maximum pad
202 * size supported which is 128 bytes for
207 uint32_t k1_expanded[44] __rte_aligned(16);
208 /**< k1 (expanded key). */
209 uint8_t k2[16] __rte_aligned(16);
211 uint8_t k3[16] __rte_aligned(16);
214 /**< Expanded XCBC authentication keys */
218 /** AAD data length */
223 } __rte_cache_aligned;
230 aesni_mb_set_session_parameters(const struct aesni_mb_op_fns *mb_ops,
231 struct aesni_mb_session *sess,
232 const struct rte_crypto_sym_xform *xform);
235 /** device specific operations function pointer structure */
236 extern struct rte_cryptodev_ops *rte_aesni_mb_pmd_ops;
240 #endif /* _RTE_AESNI_MB_PMD_PRIVATE_H_ */