]> git.proxmox.com Git - ceph.git/blob - ceph/src/dpdk/drivers/crypto/aesni_gcm/aesni_gcm_ops.h
bump version to 12.2.12-pve1
[ceph.git] / ceph / src / dpdk / drivers / crypto / aesni_gcm / aesni_gcm_ops.h
1 /*-
2 * BSD LICENSE
3 *
4 * Copyright(c) 2016 Intel Corporation. All rights reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
8 * are met:
9 *
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
15 * distribution.
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.
19 *
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.
31 */
32
33 #ifndef _AESNI_GCM_OPS_H_
34 #define _AESNI_GCM_OPS_H_
35
36 #ifndef LINUX
37 #define LINUX
38 #endif
39
40 #include <gcm_defines.h>
41 #include <aux_funcs.h>
42
43 /** Supported vector modes */
44 enum aesni_gcm_vector_mode {
45 RTE_AESNI_GCM_NOT_SUPPORTED = 0,
46 RTE_AESNI_GCM_SSE,
47 RTE_AESNI_GCM_AVX,
48 RTE_AESNI_GCM_AVX2
49 };
50
51 typedef void (*aes_keyexp_128_enc_t)(void *key, void *enc_exp_keys);
52
53 typedef void (*aesni_gcm_t)(gcm_data *my_ctx_data, u8 *out, const u8 *in,
54 u64 plaintext_len, u8 *iv, const u8 *aad, u64 aad_len,
55 u8 *auth_tag, u64 auth_tag_len);
56
57 typedef void (*aesni_gcm_precomp_t)(gcm_data *my_ctx_data, u8 *hash_subkey);
58
59 /** GCM library function pointer table */
60 struct aesni_gcm_ops {
61 struct {
62 struct {
63 aes_keyexp_128_enc_t aes128_enc;
64 /**< AES128 enc key expansion */
65 } keyexp;
66 /**< Key expansion functions */
67 } aux; /**< Auxiliary functions */
68
69 struct {
70 aesni_gcm_t enc; /**< GCM encode function pointer */
71 aesni_gcm_t dec; /**< GCM decode function pointer */
72 aesni_gcm_precomp_t precomp; /**< GCM pre-compute */
73 } gcm; /**< GCM functions */
74 };
75
76
77 static const struct aesni_gcm_ops gcm_ops[] = {
78 [RTE_AESNI_GCM_NOT_SUPPORTED] = {
79 .aux = {
80 .keyexp = {
81 NULL
82 }
83 },
84 .gcm = {
85 NULL
86 }
87 },
88 [RTE_AESNI_GCM_SSE] = {
89 .aux = {
90 .keyexp = {
91 aes_keyexp_128_enc_sse
92 }
93 },
94 .gcm = {
95 aesni_gcm_enc_sse,
96 aesni_gcm_dec_sse,
97 aesni_gcm_precomp_sse
98 }
99 },
100 [RTE_AESNI_GCM_AVX] = {
101 .aux = {
102 .keyexp = {
103 aes_keyexp_128_enc_avx,
104 }
105 },
106 .gcm = {
107 aesni_gcm_enc_avx_gen2,
108 aesni_gcm_dec_avx_gen2,
109 aesni_gcm_precomp_avx_gen2
110 }
111 },
112 [RTE_AESNI_GCM_AVX2] = {
113 .aux = {
114 .keyexp = {
115 aes_keyexp_128_enc_avx2,
116 }
117 },
118 .gcm = {
119 aesni_gcm_enc_avx_gen4,
120 aesni_gcm_dec_avx_gen4,
121 aesni_gcm_precomp_avx_gen4
122 }
123 }
124 };
125
126
127 #endif /* _AESNI_GCM_OPS_H_ */