1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright(c) 2016-2017 Intel Corporation
5 #ifndef _AESNI_GCM_OPS_H_
6 #define _AESNI_GCM_OPS_H_
12 #include <intel-ipsec-mb.h>
14 /** Supported vector modes */
15 enum aesni_gcm_vector_mode {
16 RTE_AESNI_GCM_NOT_SUPPORTED = 0,
20 RTE_AESNI_GCM_VECTOR_NUM
31 typedef void (*aesni_gcm_t)(const struct gcm_key_data *gcm_key_data,
32 struct gcm_context_data *gcm_ctx_data, uint8_t *out,
33 const uint8_t *in, uint64_t plaintext_len, const uint8_t *iv,
34 const uint8_t *aad, uint64_t aad_len,
35 uint8_t *auth_tag, uint64_t auth_tag_len);
37 typedef void (*aesni_gcm_precomp_t)(const void *key, struct gcm_key_data *gcm_data);
39 typedef void (*aesni_gcm_init_t)(const struct gcm_key_data *gcm_key_data,
40 struct gcm_context_data *gcm_ctx_data,
45 typedef void (*aesni_gcm_update_t)(const struct gcm_key_data *gcm_key_data,
46 struct gcm_context_data *gcm_ctx_data,
49 uint64_t plaintext_len);
51 typedef void (*aesni_gcm_finalize_t)(const struct gcm_key_data *gcm_key_data,
52 struct gcm_context_data *gcm_ctx_data,
54 uint64_t auth_tag_len);
56 /** GCM library function pointer table */
57 struct aesni_gcm_ops {
58 aesni_gcm_t enc; /**< GCM encode function pointer */
59 aesni_gcm_t dec; /**< GCM decode function pointer */
60 aesni_gcm_precomp_t precomp; /**< GCM pre-compute */
61 aesni_gcm_init_t init;
62 aesni_gcm_update_t update_enc;
63 aesni_gcm_update_t update_dec;
64 aesni_gcm_finalize_t finalize;
67 #define AES_GCM_FN(keylen, arch) \
68 aes_gcm_enc_##keylen##_##arch,\
69 aes_gcm_dec_##keylen##_##arch,\
70 aes_gcm_pre_##keylen##_##arch,\
71 aes_gcm_init_##keylen##_##arch,\
72 aes_gcm_enc_##keylen##_update_##arch,\
73 aes_gcm_dec_##keylen##_update_##arch,\
74 aes_gcm_enc_##keylen##_finalize_##arch,
76 static const struct aesni_gcm_ops gcm_ops[RTE_AESNI_GCM_VECTOR_NUM][AESNI_GCM_KEY_NUM] = {
77 [RTE_AESNI_GCM_NOT_SUPPORTED] = {
78 [AESNI_GCM_KEY_128] = {NULL},
79 [AESNI_GCM_KEY_192] = {NULL},
80 [AESNI_GCM_KEY_256] = {NULL}
82 [RTE_AESNI_GCM_SSE] = {
83 [AESNI_GCM_KEY_128] = {
86 [AESNI_GCM_KEY_192] = {
89 [AESNI_GCM_KEY_256] = {
93 [RTE_AESNI_GCM_AVX] = {
94 [AESNI_GCM_KEY_128] = {
95 AES_GCM_FN(128, avx_gen2)
97 [AESNI_GCM_KEY_192] = {
98 AES_GCM_FN(192, avx_gen2)
100 [AESNI_GCM_KEY_256] = {
101 AES_GCM_FN(256, avx_gen2)
104 [RTE_AESNI_GCM_AVX2] = {
105 [AESNI_GCM_KEY_128] = {
106 AES_GCM_FN(128, avx_gen4)
108 [AESNI_GCM_KEY_192] = {
109 AES_GCM_FN(192, avx_gen4)
111 [AESNI_GCM_KEY_256] = {
112 AES_GCM_FN(256, avx_gen4)
116 #endif /* _AESNI_GCM_OPS_H_ */