4 * Copyright(c) 2015-2016 Intel Corporation. All rights reserved.
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
10 * * Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * * Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in
14 * the documentation and/or other materials provided with the
16 * * Neither the name of Intel Corporation nor the names of its
17 * contributors may be used to endorse or promote products derived
18 * from this software without specific prior written permission.
20 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
23 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
24 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
25 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
26 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
27 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
28 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
30 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33 #ifndef _RTE_AESNI_MB_PMD_PRIVATE_H_
34 #define _RTE_AESNI_MB_PMD_PRIVATE_H_
36 #include "aesni_mb_ops.h"
38 #define MB_LOG_ERR(fmt, args...) \
39 RTE_LOG(ERR, CRYPTODEV, "[%s] %s() line %u: " fmt "\n", \
40 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD), \
41 __func__, __LINE__, ## args)
43 #ifdef RTE_LIBRTE_AESNI_MB_DEBUG
44 #define MB_LOG_INFO(fmt, args...) \
45 RTE_LOG(INFO, CRYPTODEV, "[%s] %s() line %u: " fmt "\n", \
46 CRYPTODEV_NAME_AESNI_MB_PMD, \
47 __func__, __LINE__, ## args)
49 #define MB_LOG_DBG(fmt, args...) \
50 RTE_LOG(DEBUG, CRYPTODEV, "[%s] %s() line %u: " fmt "\n", \
51 CRYPTODEV_NAME_AESNI_MB_PMD, \
52 __func__, __LINE__, ## args)
54 #define MB_LOG_INFO(fmt, args...)
55 #define MB_LOG_DBG(fmt, args...)
58 #define HMAC_IPAD_VALUE (0x36)
59 #define HMAC_OPAD_VALUE (0x5C)
61 static const unsigned auth_blocksize[] = {
72 * Get the blocksize in bytes for a specified authentication algorithm
74 * @Note: this function will not return a valid value for a non-valid
75 * authentication algorithm
77 static inline unsigned
78 get_auth_algo_blocksize(JOB_HASH_ALG algo)
80 return auth_blocksize[algo];
83 static const unsigned auth_truncated_digest_byte_lengths[] = {
95 * Get the IPsec specified truncated length in bytes of the HMAC digest for a
96 * specified authentication algorithm
98 * @Note: this function will not return a valid value for a non-valid
99 * authentication algorithm
101 static inline unsigned
102 get_truncated_digest_byte_length(JOB_HASH_ALG algo)
104 return auth_truncated_digest_byte_lengths[algo];
107 static const unsigned auth_digest_byte_lengths[] = {
119 * Get the output digest size in bytes for a specified authentication algorithm
121 * @Note: this function will not return a valid value for a non-valid
122 * authentication algorithm
124 static inline unsigned
125 get_digest_byte_length(JOB_HASH_ALG algo)
127 return auth_digest_byte_lengths[algo];
130 enum aesni_mb_operation {
131 AESNI_MB_OP_HASH_CIPHER,
132 AESNI_MB_OP_CIPHER_HASH,
133 AESNI_MB_OP_HASH_ONLY,
134 AESNI_MB_OP_CIPHER_ONLY,
135 AESNI_MB_OP_NOT_SUPPORTED
138 /** private data structure for each virtual AESNI device */
139 struct aesni_mb_private {
140 enum aesni_mb_vector_mode vector_mode;
141 /**< CPU vector instruction set mode */
142 unsigned max_nb_queue_pairs;
143 /**< Max number of queue pairs supported by device */
144 unsigned max_nb_sessions;
145 /**< Max number of sessions supported by device */
148 /** AESNI Multi buffer queue pair */
151 /**< Queue Pair Identifier */
152 char name[RTE_CRYPTODEV_NAME_LEN];
153 /**< Unique Queue Pair Name */
154 const struct aesni_mb_op_fns *op_fns;
155 /**< Vector mode dependent pointer table of the multi-buffer APIs */
157 /**< Multi-buffer instance */
158 struct rte_ring *ingress_queue;
159 /**< Ring for placing operations ready for processing */
160 struct rte_mempool *sess_mp;
161 /**< Session Mempool */
162 struct rte_cryptodev_stats stats;
163 /**< Queue pair statistics */
164 } __rte_cache_aligned;
167 /** AES-NI multi-buffer private session structure */
168 struct aesni_mb_session {
169 JOB_CHAIN_ORDER chain_order;
174 /**< IV parameters */
176 /** Cipher Parameters */
178 /** Cipher direction - encrypt / decrypt */
179 JOB_CIPHER_DIRECTION direction;
180 /** Cipher mode - CBC / Counter */
181 JOB_CIPHER_MODE mode;
183 uint64_t key_length_in_bytes;
186 uint32_t encode[60] __rte_aligned(16);
188 uint32_t decode[60] __rte_aligned(16);
191 /**< Expanded AES keys - Allocating space to
192 * contain the maximum expanded key size which
193 * is 240 bytes for 256 bit AES, calculate by:
194 * ((key size (bytes)) *
195 * ((number of rounds) + 1))
199 /** Authentication Parameters */
201 JOB_HASH_ALG algo; /**< Authentication Algorithm */
202 enum rte_crypto_auth_operation operation;
203 /**< auth operation generate or verify */
206 uint8_t inner[128] __rte_aligned(16);
208 uint8_t outer[128] __rte_aligned(16);
211 /**< HMAC Authentication pads -
212 * allocating space for the maximum pad
213 * size supported which is 128 bytes for
218 uint32_t k1_expanded[44] __rte_aligned(16);
219 /**< k1 (expanded key). */
220 uint8_t k2[16] __rte_aligned(16);
222 uint8_t k3[16] __rte_aligned(16);
225 /**< Expanded XCBC authentication keys */
228 } __rte_cache_aligned;
235 aesni_mb_set_session_parameters(const struct aesni_mb_op_fns *mb_ops,
236 struct aesni_mb_session *sess,
237 const struct rte_crypto_sym_xform *xform);
240 /** device specific operations function pointer structure */
241 extern struct rte_cryptodev_ops *rte_aesni_mb_pmd_ops;
245 #endif /* _RTE_AESNI_MB_PMD_PRIVATE_H_ */