net/bnxt: check access denied for HWRM commands
[dpdk.git] / drivers / crypto / aesni_gcm / aesni_gcm_ops.h
1 /* SPDX-License-Identifier: BSD-3-Clause
2  * Copyright(c) 2016-2017 Intel Corporation
3  */
4
5 #ifndef _AESNI_GCM_OPS_H_
6 #define _AESNI_GCM_OPS_H_
7
8 #ifndef LINUX
9 #define LINUX
10 #endif
11
12 #include <intel-ipsec-mb.h>
13
14 /** Supported vector modes */
15 enum aesni_gcm_vector_mode {
16         RTE_AESNI_GCM_NOT_SUPPORTED = 0,
17         RTE_AESNI_GCM_SSE,
18         RTE_AESNI_GCM_AVX,
19         RTE_AESNI_GCM_AVX2,
20         RTE_AESNI_GCM_VECTOR_NUM
21 };
22
23 enum aesni_gcm_key {
24         AESNI_GCM_KEY_128,
25         AESNI_GCM_KEY_192,
26         AESNI_GCM_KEY_256,
27         AESNI_GCM_KEY_NUM
28 };
29
30
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);
36
37 typedef void (*aesni_gcm_precomp_t)(const void *key, struct gcm_key_data *gcm_data);
38
39 typedef void (*aesni_gcm_init_t)(const struct gcm_key_data *gcm_key_data,
40                 struct gcm_context_data *gcm_ctx_data,
41                 const uint8_t *iv,
42                 uint8_t const *aad,
43                 uint64_t aad_len);
44
45 typedef void (*aesni_gcm_update_t)(const struct gcm_key_data *gcm_key_data,
46                 struct gcm_context_data *gcm_ctx_data,
47                 uint8_t *out,
48                 const uint8_t *in,
49                 uint64_t plaintext_len);
50
51 typedef void (*aesni_gcm_finalize_t)(const struct gcm_key_data *gcm_key_data,
52                 struct gcm_context_data *gcm_ctx_data,
53                 uint8_t *auth_tag,
54                 uint64_t auth_tag_len);
55
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;
65 };
66
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,
75
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}
81         },
82         [RTE_AESNI_GCM_SSE] = {
83                 [AESNI_GCM_KEY_128] = {
84                         AES_GCM_FN(128, sse)
85                 },
86                 [AESNI_GCM_KEY_192] = {
87                         AES_GCM_FN(192, sse)
88                 },
89                 [AESNI_GCM_KEY_256] = {
90                         AES_GCM_FN(256, sse)
91                 }
92         },
93         [RTE_AESNI_GCM_AVX] = {
94                 [AESNI_GCM_KEY_128] = {
95                         AES_GCM_FN(128, avx_gen2)
96                 },
97                 [AESNI_GCM_KEY_192] = {
98                         AES_GCM_FN(192, avx_gen2)
99                 },
100                 [AESNI_GCM_KEY_256] = {
101                         AES_GCM_FN(256, avx_gen2)
102                 }
103         },
104         [RTE_AESNI_GCM_AVX2] = {
105                 [AESNI_GCM_KEY_128] = {
106                         AES_GCM_FN(128, avx_gen4)
107                 },
108                 [AESNI_GCM_KEY_192] = {
109                         AES_GCM_FN(192, avx_gen4)
110                 },
111                 [AESNI_GCM_KEY_256] = {
112                         AES_GCM_FN(256, avx_gen4)
113                 }
114         }
115 };
116 #endif /* _AESNI_GCM_OPS_H_ */