1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright(c) 2018 Cavium, Inc
5 #ifndef _CPT_MCODE_DEFINES_H_
6 #define _CPT_MCODE_DEFINES_H_
8 #include <rte_byteorder.h>
9 #include <rte_memory.h>
12 * This file defines macros and structures according to microcode spec
16 #define CPT_BYTE_16 16
17 #define CPT_BYTE_24 24
18 #define CPT_BYTE_32 32
19 #define CPT_MAX_SG_IN_OUT_CNT 32
20 #define CPT_MAX_SG_CNT (CPT_MAX_SG_IN_OUT_CNT/2)
22 #define COMPLETION_CODE_SIZE 8
23 #define COMPLETION_CODE_INIT 0
25 #define SG_LIST_HDR_SIZE (8u)
26 #define SG_ENTRY_SIZE sizeof(sg_comp_t)
28 #define CPT_DMA_MODE (1 << 7)
30 #define CPT_FROM_CTX 0
31 #define CPT_FROM_DPTR 1
34 #define ZUC_SNOW3G 0x2
43 #define CPT_OP_CIPHER_ENCRYPT 0x1
44 #define CPT_OP_CIPHER_DECRYPT 0x2
45 #define CPT_OP_CIPHER_MASK 0x3
47 #define CPT_OP_AUTH_VERIFY 0x4
48 #define CPT_OP_AUTH_GENERATE 0x8
49 #define CPT_OP_AUTH_MASK 0xC
51 #define CPT_OP_ENCODE (CPT_OP_CIPHER_ENCRYPT | CPT_OP_AUTH_GENERATE)
52 #define CPT_OP_DECODE (CPT_OP_CIPHER_DECRYPT | CPT_OP_AUTH_VERIFY)
54 /* #define CPT_ALWAYS_USE_SG_MODE */
55 #define CPT_ALWAYS_USE_SEPARATE_BUF
73 /* These are only for software use */
81 /* To support passthrough */
84 * These are defined by MC for Flexi crypto
96 /* These are only for software use */
100 KASUMI_F8_ECB = 0x93,
110 typedef struct sglist_comp {
120 struct cpt_sess_misc {
123 /** ZUC, SNOW3G & KASUMI flags */
125 /** Flag for AES GCM */
127 /** Flag for AES CTR */
129 /** Flag for NULL cipher/auth */
135 /** MAC len in bytes */
137 /** IV length in bytes */
139 /** Auth IV length in bytes */
140 uint8_t auth_iv_length;
141 /** Reserved field */
143 /** IV offset in bytes */
145 /** Auth IV offset in bytes */
146 uint16_t auth_iv_offset;
149 /** Context DMA address */
150 phys_addr_t ctx_dma_addr;
156 #if RTE_BYTE_ORDER == RTE_BIG_ENDIAN
157 uint64_t enc_cipher : 4;
158 uint64_t reserved1 : 1;
159 uint64_t aes_key : 2;
160 uint64_t iv_source : 1;
161 uint64_t hash_type : 4;
162 uint64_t reserved2 : 3;
163 uint64_t auth_input_type : 1;
164 uint64_t mac_len : 8;
165 uint64_t reserved3 : 8;
166 uint64_t encr_offset : 16;
167 uint64_t iv_offset : 8;
168 uint64_t auth_offset : 8;
170 uint64_t auth_offset : 8;
171 uint64_t iv_offset : 8;
172 uint64_t encr_offset : 16;
173 uint64_t reserved3 : 8;
174 uint64_t mac_len : 8;
175 uint64_t auth_input_type : 1;
176 uint64_t reserved2 : 3;
177 uint64_t hash_type : 4;
178 uint64_t iv_source : 1;
179 uint64_t aes_key : 2;
180 uint64_t reserved1 : 1;
181 uint64_t enc_cipher : 4;
187 encr_ctrl_t enc_ctrl;
188 uint8_t encr_key[32];
195 } mc_fc_hmac_context_t;
198 mc_enc_context_t enc;
199 mc_fc_hmac_context_t hmac;
203 uint8_t encr_auth_iv[16];
205 uint8_t zuc_const[32];
206 } mc_zuc_snow3g_ctx_t;
214 /* Below fields are accessed by sw */
215 uint64_t enc_cipher :8;
216 uint64_t hash_type :8;
218 uint64_t auth_key_len :8;
221 uint64_t zsk_flags :3;
225 /* Below fields are accessed by hardware */
227 mc_fc_context_t fctx;
228 mc_zuc_snow3g_ctx_t zs_ctx;
229 mc_kasumi_ctx_t k_ctx;
231 uint8_t auth_key[64];
234 typedef struct fc_params digest_params_t;
236 /* Cipher Algorithms */
237 typedef mc_cipher_type_t cipher_type_t;
239 /* Auth Algorithms */
240 typedef mc_hash_type_t auth_type_t;
242 #define CPT_P_ENC_CTRL(fctx) fctx->enc.enc_ctrl.e
244 #define SESS_PRIV(__sess) \
245 (void *)((uint8_t *)__sess + sizeof(struct cpt_sess_misc))
247 #endif /* _CPT_MCODE_DEFINES_H_ */