4 * Copyright(c) 2016-2017 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 _AESNI_GCM_OPS_H_
34 #define _AESNI_GCM_OPS_H_
40 #include <gcm_defines.h>
41 #include <aux_funcs.h>
43 /** Supported vector modes */
44 enum aesni_gcm_vector_mode {
45 RTE_AESNI_GCM_NOT_SUPPORTED = 0,
49 RTE_AESNI_GCM_VECTOR_NUM
60 typedef void (*aesni_gcm_t)(const struct gcm_key_data *gcm_key_data,
61 struct gcm_context_data *gcm_ctx_data, uint8_t *out,
62 const uint8_t *in, uint64_t plaintext_len, const uint8_t *iv,
63 const uint8_t *aad, uint64_t aad_len,
64 uint8_t *auth_tag, uint64_t auth_tag_len);
66 typedef void (*aesni_gcm_precomp_t)(const void *key, struct gcm_key_data *gcm_data);
68 typedef void (*aesni_gcm_init_t)(const struct gcm_key_data *gcm_key_data,
69 struct gcm_context_data *gcm_ctx_data,
74 typedef void (*aesni_gcm_update_t)(const struct gcm_key_data *gcm_key_data,
75 struct gcm_context_data *gcm_ctx_data,
78 uint64_t plaintext_len);
80 typedef void (*aesni_gcm_finalize_t)(const struct gcm_key_data *gcm_key_data,
81 struct gcm_context_data *gcm_ctx_data,
83 uint64_t auth_tag_len);
85 /** GCM library function pointer table */
86 struct aesni_gcm_ops {
87 aesni_gcm_t enc; /**< GCM encode function pointer */
88 aesni_gcm_t dec; /**< GCM decode function pointer */
89 aesni_gcm_precomp_t precomp; /**< GCM pre-compute */
90 aesni_gcm_init_t init;
91 aesni_gcm_update_t update_enc;
92 aesni_gcm_update_t update_dec;
93 aesni_gcm_finalize_t finalize;
96 #define AES_GCM_FN(keylen, arch) \
97 aes_gcm_enc_##keylen##_##arch,\
98 aes_gcm_dec_##keylen##_##arch,\
99 aes_gcm_pre_##keylen##_##arch,\
100 aes_gcm_init_##keylen##_##arch,\
101 aes_gcm_enc_##keylen##_update_##arch,\
102 aes_gcm_dec_##keylen##_update_##arch,\
103 aes_gcm_enc_##keylen##_finalize_##arch,
105 static const struct aesni_gcm_ops gcm_ops[RTE_AESNI_GCM_VECTOR_NUM][AESNI_GCM_KEY_NUM] = {
106 [RTE_AESNI_GCM_NOT_SUPPORTED] = {
107 [AESNI_GCM_KEY_128] = {NULL},
108 [AESNI_GCM_KEY_192] = {NULL},
109 [AESNI_GCM_KEY_256] = {NULL}
111 [RTE_AESNI_GCM_SSE] = {
112 [AESNI_GCM_KEY_128] = {
115 [AESNI_GCM_KEY_192] = {
118 [AESNI_GCM_KEY_256] = {
122 [RTE_AESNI_GCM_AVX] = {
123 [AESNI_GCM_KEY_128] = {
124 AES_GCM_FN(128, avx_gen2)
126 [AESNI_GCM_KEY_192] = {
127 AES_GCM_FN(192, avx_gen2)
129 [AESNI_GCM_KEY_256] = {
130 AES_GCM_FN(256, avx_gen2)
133 [RTE_AESNI_GCM_AVX2] = {
134 [AESNI_GCM_KEY_128] = {
135 AES_GCM_FN(128, avx_gen4)
137 [AESNI_GCM_KEY_192] = {
138 AES_GCM_FN(192, avx_gen4)
140 [AESNI_GCM_KEY_256] = {
141 AES_GCM_FN(256, avx_gen4)
145 #endif /* _AESNI_GCM_OPS_H_ */