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 <intel-ipsec-mb.h>
10 enum aesni_mb_vector_mode {
11 RTE_AESNI_MB_NOT_SUPPORTED = 0,
18 #define CRYPTODEV_NAME_AESNI_MB_PMD crypto_aesni_mb
19 /**< AES-NI Multi buffer PMD device name */
21 /** AESNI_MB PMD LOGTYPE DRIVER */
22 int aesni_mb_logtype_driver;
24 #define AESNI_MB_LOG(level, fmt, ...) \
25 rte_log(RTE_LOG_ ## level, aesni_mb_logtype_driver, \
26 "%s() line %u: " fmt "\n", __func__, __LINE__, \
30 #define HMAC_IPAD_VALUE (0x36)
31 #define HMAC_OPAD_VALUE (0x5C)
33 /* Maximum length for digest */
34 #define DIGEST_LENGTH_MAX 64
35 static const unsigned auth_blocksize[] = {
47 * Get the blocksize in bytes for a specified authentication algorithm
49 * @Note: this function will not return a valid value for a non-valid
50 * authentication algorithm
52 static inline unsigned
53 get_auth_algo_blocksize(JOB_HASH_ALG algo)
55 return auth_blocksize[algo];
58 static const unsigned auth_truncated_digest_byte_lengths[] = {
72 * Get the IPsec specified truncated length in bytes of the HMAC digest for a
73 * specified authentication algorithm
75 * @Note: this function will not return a valid value for a non-valid
76 * authentication algorithm
78 static inline unsigned
79 get_truncated_digest_byte_length(JOB_HASH_ALG algo)
81 return auth_truncated_digest_byte_lengths[algo];
84 static const unsigned auth_digest_byte_lengths[] = {
100 /**< Vector mode dependent pointer table of the multi-buffer APIs */
105 * Get the full digest size in bytes for a specified authentication algorithm
106 * (if available in the Multi-buffer library)
108 * @Note: this function will not return a valid value for a non-valid
109 * authentication algorithm
111 static inline unsigned
112 get_digest_byte_length(JOB_HASH_ALG algo)
114 return auth_digest_byte_lengths[algo];
117 enum aesni_mb_operation {
118 AESNI_MB_OP_HASH_CIPHER,
119 AESNI_MB_OP_CIPHER_HASH,
120 AESNI_MB_OP_HASH_ONLY,
121 AESNI_MB_OP_CIPHER_ONLY,
122 AESNI_MB_OP_AEAD_HASH_CIPHER,
123 AESNI_MB_OP_AEAD_CIPHER_HASH,
124 AESNI_MB_OP_NOT_SUPPORTED
127 /** private data structure for each virtual AESNI device */
128 struct aesni_mb_private {
129 enum aesni_mb_vector_mode vector_mode;
130 /**< CPU vector instruction set mode */
131 unsigned max_nb_queue_pairs;
132 /**< Max number of queue pairs supported by device */
134 /**< Multi-buffer instance */
137 /** AESNI Multi buffer queue pair */
140 /**< Queue Pair Identifier */
141 char name[RTE_CRYPTODEV_NAME_MAX_LEN];
142 /**< Unique Queue Pair Name */
144 /**< Multi-buffer instance */
145 struct rte_ring *ingress_queue;
146 /**< Ring for placing operations ready for processing */
147 struct rte_mempool *sess_mp;
148 /**< Session Mempool */
149 struct rte_mempool *sess_mp_priv;
150 /**< Session Private Data Mempool */
151 struct rte_cryptodev_stats stats;
152 /**< Queue pair statistics */
154 /**< Index of the next slot to be used in temp_digests,
155 * to store the digest for a given operation
157 uint8_t temp_digests[MAX_JOBS][DIGEST_LENGTH_MAX];
158 /**< Buffers used to store the digest generated
159 * by the driver when verifying a digest provided
160 * by the user (using authentication verify operation)
162 } __rte_cache_aligned;
164 /** AES-NI multi-buffer private session structure */
165 struct aesni_mb_session {
166 JOB_CHAIN_ORDER chain_order;
171 /**< IV parameters */
173 /** Cipher Parameters */const struct aesni_mb_op_fns *op_fns;
174 /**< Vector mode dependent pointer table of the multi-buffer APIs */
177 /** Cipher direction - encrypt / decrypt */
178 JOB_CIPHER_DIRECTION direction;
179 /** Cipher mode - CBC / Counter */
180 JOB_CIPHER_MODE mode;
182 uint64_t key_length_in_bytes;
186 uint32_t encode[60] __rte_aligned(16);
188 uint32_t decode[60] __rte_aligned(16);
192 const void *ks_ptr[3];
196 struct gcm_key_data gcm_key;
198 /**< Expanded AES keys - Allocating space to
199 * contain the maximum expanded key size which
200 * is 240 bytes for 256 bit AES, calculate by:
201 * ((key size (bytes)) *
202 * ((number of rounds) + 1))
206 /** Authentication Parameters */
208 JOB_HASH_ALG algo; /**< Authentication Algorithm */
209 enum rte_crypto_auth_operation operation;
210 /**< auth operation generate or verify */
213 uint8_t inner[128] __rte_aligned(16);
215 uint8_t outer[128] __rte_aligned(16);
218 /**< HMAC Authentication pads -
219 * allocating space for the maximum pad
220 * size supported which is 128 bytes for
225 uint32_t k1_expanded[44] __rte_aligned(16);
226 /**< k1 (expanded key). */
227 uint8_t k2[16] __rte_aligned(16);
229 uint8_t k3[16] __rte_aligned(16);
234 uint32_t expkey[60] __rte_aligned(16);
235 /**< k1 (expanded key). */
236 uint32_t skey1[4] __rte_aligned(16);
238 uint32_t skey2[4] __rte_aligned(16);
241 /**< Expanded XCBC authentication keys */
243 /** Generated digest size by the Multi-buffer library */
244 uint16_t gen_digest_len;
245 /** Requested digest size from Cryptodev */
246 uint16_t req_digest_len;
250 /** AAD data length */
253 } __rte_cache_aligned;
256 aesni_mb_set_session_parameters(const MB_MGR *mb_mgr,
257 struct aesni_mb_session *sess,
258 const struct rte_crypto_sym_xform *xform);
260 /** device specific operations function pointer structure */
261 extern struct rte_cryptodev_ops *rte_aesni_mb_pmd_ops;
265 #endif /* _RTE_AESNI_MB_PMD_PRIVATE_H_ */