.. | .. |
---|
5 | 5 | #include <crypto/aes.h> |
---|
6 | 6 | #include <crypto/internal/des.h> |
---|
7 | 7 | #include <crypto/algapi.h> |
---|
| 8 | +#include <linux/dma-mapping.h> |
---|
8 | 9 | #include <linux/interrupt.h> |
---|
9 | 10 | #include <linux/delay.h> |
---|
10 | 11 | #include <linux/scatterlist.h> |
---|
| 12 | +#include <crypto/engine.h> |
---|
11 | 13 | #include <crypto/internal/hash.h> |
---|
12 | 14 | #include <crypto/internal/skcipher.h> |
---|
13 | 15 | |
---|
.. | .. |
---|
192 | 194 | struct reset_control *rst; |
---|
193 | 195 | void __iomem *reg; |
---|
194 | 196 | int irq; |
---|
195 | | - struct crypto_queue queue; |
---|
196 | | - struct tasklet_struct queue_task; |
---|
197 | | - struct tasklet_struct done_task; |
---|
198 | | - struct crypto_async_request *async_req; |
---|
199 | | - int err; |
---|
200 | | - /* device lock */ |
---|
201 | | - spinlock_t lock; |
---|
202 | 197 | |
---|
203 | | - /* the public variable */ |
---|
204 | | - struct scatterlist *sg_src; |
---|
205 | | - struct scatterlist *sg_dst; |
---|
206 | | - struct scatterlist sg_tmp; |
---|
207 | | - struct scatterlist *first; |
---|
208 | | - unsigned int left_bytes; |
---|
209 | | - void *addr_vir; |
---|
210 | | - int aligned; |
---|
211 | | - int align_size; |
---|
212 | | - size_t src_nents; |
---|
213 | | - size_t dst_nents; |
---|
214 | | - unsigned int total; |
---|
215 | | - unsigned int count; |
---|
216 | | - dma_addr_t addr_in; |
---|
217 | | - dma_addr_t addr_out; |
---|
218 | | - bool busy; |
---|
219 | | - int (*start)(struct rk_crypto_info *dev); |
---|
220 | | - int (*update)(struct rk_crypto_info *dev); |
---|
221 | | - void (*complete)(struct crypto_async_request *base, int err); |
---|
222 | | - int (*enable_clk)(struct rk_crypto_info *dev); |
---|
223 | | - void (*disable_clk)(struct rk_crypto_info *dev); |
---|
224 | | - int (*load_data)(struct rk_crypto_info *dev, |
---|
225 | | - struct scatterlist *sg_src, |
---|
226 | | - struct scatterlist *sg_dst); |
---|
227 | | - void (*unload_data)(struct rk_crypto_info *dev); |
---|
228 | | - int (*enqueue)(struct rk_crypto_info *dev, |
---|
229 | | - struct crypto_async_request *async_req); |
---|
| 198 | + struct crypto_engine *engine; |
---|
| 199 | + struct completion complete; |
---|
| 200 | + int status; |
---|
230 | 201 | }; |
---|
231 | 202 | |
---|
232 | 203 | /* the private variable of hash */ |
---|
233 | 204 | struct rk_ahash_ctx { |
---|
| 205 | + struct crypto_engine_ctx enginectx; |
---|
234 | 206 | struct rk_crypto_info *dev; |
---|
235 | 207 | /* for fallback */ |
---|
236 | 208 | struct crypto_ahash *fallback_tfm; |
---|
.. | .. |
---|
240 | 212 | struct rk_ahash_rctx { |
---|
241 | 213 | struct ahash_request fallback_req; |
---|
242 | 214 | u32 mode; |
---|
| 215 | + int nrsg; |
---|
243 | 216 | }; |
---|
244 | 217 | |
---|
245 | 218 | /* the private variable of cipher */ |
---|
246 | 219 | struct rk_cipher_ctx { |
---|
| 220 | + struct crypto_engine_ctx enginectx; |
---|
247 | 221 | struct rk_crypto_info *dev; |
---|
248 | 222 | unsigned int keylen; |
---|
249 | | - u32 mode; |
---|
| 223 | + u8 key[AES_MAX_KEY_SIZE]; |
---|
250 | 224 | u8 iv[AES_BLOCK_SIZE]; |
---|
| 225 | + struct crypto_skcipher *fallback_tfm; |
---|
| 226 | +}; |
---|
| 227 | + |
---|
| 228 | +struct rk_cipher_rctx { |
---|
| 229 | + u8 backup_iv[AES_BLOCK_SIZE]; |
---|
| 230 | + u32 mode; |
---|
| 231 | + struct skcipher_request fallback_req; // keep at the end |
---|
251 | 232 | }; |
---|
252 | 233 | |
---|
253 | 234 | enum alg_type { |
---|