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 /** AESNI_MB PMD LOGTYPE DRIVER */
14 int aesni_mb_logtype_driver;
16 #define AESNI_MB_LOG(level, fmt, ...) \
17 rte_log(RTE_LOG_ ## level, aesni_mb_logtype_driver, \
18 "%s() line %u: " fmt "\n", __func__, __LINE__, \
22 #define HMAC_IPAD_VALUE (0x36)
23 #define HMAC_OPAD_VALUE (0x5C)
25 /* Maximum length for digest (SHA-512 truncated needs 32 bytes) */
26 #define DIGEST_LENGTH_MAX 32
27 static const unsigned auth_blocksize[] = {
39 * Get the blocksize in bytes for a specified authentication algorithm
41 * @Note: this function will not return a valid value for a non-valid
42 * authentication algorithm
44 static inline unsigned
45 get_auth_algo_blocksize(JOB_HASH_ALG algo)
47 return auth_blocksize[algo];
50 static const unsigned auth_truncated_digest_byte_lengths[] = {
64 * Get the IPsec specified truncated length in bytes of the HMAC digest for a
65 * specified authentication algorithm
67 * @Note: this function will not return a valid value for a non-valid
68 * authentication algorithm
70 static inline unsigned
71 get_truncated_digest_byte_length(JOB_HASH_ALG algo)
73 return auth_truncated_digest_byte_lengths[algo];
76 static const unsigned auth_digest_byte_lengths[] = {
89 * Get the output digest size in bytes for a specified authentication algorithm
91 * @Note: this function will not return a valid value for a non-valid
92 * authentication algorithm
94 static inline unsigned
95 get_digest_byte_length(JOB_HASH_ALG algo)
97 return auth_digest_byte_lengths[algo];
100 enum aesni_mb_operation {
101 AESNI_MB_OP_HASH_CIPHER,
102 AESNI_MB_OP_CIPHER_HASH,
103 AESNI_MB_OP_HASH_ONLY,
104 AESNI_MB_OP_CIPHER_ONLY,
105 AESNI_MB_OP_AEAD_HASH_CIPHER,
106 AESNI_MB_OP_AEAD_CIPHER_HASH,
107 AESNI_MB_OP_NOT_SUPPORTED
110 /** private data structure for each virtual AESNI device */
111 struct aesni_mb_private {
112 enum aesni_mb_vector_mode vector_mode;
113 /**< CPU vector instruction set mode */
114 unsigned max_nb_queue_pairs;
115 /**< Max number of queue pairs supported by device */
116 unsigned max_nb_sessions;
117 /**< Max number of sessions supported by device */
120 /** AESNI Multi buffer queue pair */
123 /**< Queue Pair Identifier */
124 char name[RTE_CRYPTODEV_NAME_MAX_LEN];
125 /**< Unique Queue Pair Name */
126 const struct aesni_mb_op_fns *op_fns;
127 /**< Vector mode dependent pointer table of the multi-buffer APIs */
129 /**< Multi-buffer instance */
130 struct rte_ring *ingress_queue;
131 /**< Ring for placing operations ready for processing */
132 struct rte_mempool *sess_mp;
133 /**< Session Mempool */
134 struct rte_cryptodev_stats stats;
135 /**< Queue pair statistics */
137 /**< Index of the next slot to be used in temp_digests,
138 * to store the digest for a given operation
140 uint8_t temp_digests[MAX_JOBS][DIGEST_LENGTH_MAX];
141 /**< Buffers used to store the digest generated
142 * by the driver when verifying a digest provided
143 * by the user (using authentication verify operation)
145 } __rte_cache_aligned;
147 /** AES-NI multi-buffer private session structure */
148 struct aesni_mb_session {
149 JOB_CHAIN_ORDER chain_order;
154 /**< IV parameters */
156 /** Cipher Parameters */
158 /** Cipher direction - encrypt / decrypt */
159 JOB_CIPHER_DIRECTION direction;
160 /** Cipher mode - CBC / Counter */
161 JOB_CIPHER_MODE mode;
163 uint64_t key_length_in_bytes;
166 uint32_t encode[60] __rte_aligned(16);
168 uint32_t decode[60] __rte_aligned(16);
171 /**< Expanded AES keys - Allocating space to
172 * contain the maximum expanded key size which
173 * is 240 bytes for 256 bit AES, calculate by:
174 * ((key size (bytes)) *
175 * ((number of rounds) + 1))
179 /** Authentication Parameters */
181 JOB_HASH_ALG algo; /**< Authentication Algorithm */
182 enum rte_crypto_auth_operation operation;
183 /**< auth operation generate or verify */
186 uint8_t inner[128] __rte_aligned(16);
188 uint8_t outer[128] __rte_aligned(16);
191 /**< HMAC Authentication pads -
192 * allocating space for the maximum pad
193 * size supported which is 128 bytes for
198 uint32_t k1_expanded[44] __rte_aligned(16);
199 /**< k1 (expanded key). */
200 uint8_t k2[16] __rte_aligned(16);
202 uint8_t k3[16] __rte_aligned(16);
207 uint32_t expkey[60] __rte_aligned(16);
208 /**< k1 (expanded key). */
209 uint32_t skey1[4] __rte_aligned(16);
211 uint32_t skey2[4] __rte_aligned(16);
214 /**< Expanded XCBC authentication keys */
221 /** AAD data length */
224 } __rte_cache_aligned;
231 aesni_mb_set_session_parameters(const struct aesni_mb_op_fns *mb_ops,
232 struct aesni_mb_session *sess,
233 const struct rte_crypto_sym_xform *xform);
236 /** device specific operations function pointer structure */
237 extern struct rte_cryptodev_ops *rte_aesni_mb_pmd_ops;
241 #endif /* _RTE_AESNI_MB_PMD_PRIVATE_H_ */