1 /* SPDX-License-Identifier: GPL-2.0 */
2 /* Copyright (C) 2012-2019 ARM Limited (or its affiliates). */
3 
4 /* \file cc_buffer_mgr.h
5  * Buffer Manager
6  */
7 
8 #ifndef __CC_BUFFER_MGR_H__
9 #define __CC_BUFFER_MGR_H__
10 
11 #include <crypto/algapi.h>
12 
13 #include "cc_driver.h"
14 
15 enum cc_req_dma_buf_type {
16 	CC_DMA_BUF_NULL = 0,
17 	CC_DMA_BUF_DLLI,
18 	CC_DMA_BUF_MLLI
19 };
20 
21 enum cc_sg_cpy_direct {
22 	CC_SG_TO_BUF = 0,
23 	CC_SG_FROM_BUF = 1
24 };
25 
26 struct cc_mlli {
27 	cc_sram_addr_t sram_addr;
28 	unsigned int nents; //sg nents
29 	unsigned int mlli_nents; //mlli nents might be different than the above
30 };
31 
32 struct mlli_params {
33 	struct dma_pool *curr_pool;
34 	u8 *mlli_virt_addr;
35 	dma_addr_t mlli_dma_addr;
36 	u32 mlli_len;
37 };
38 
39 int cc_buffer_mgr_init(struct cc_drvdata *drvdata);
40 
41 int cc_buffer_mgr_fini(struct cc_drvdata *drvdata);
42 
43 int cc_map_cipher_request(struct cc_drvdata *drvdata, void *ctx,
44 			  unsigned int ivsize, unsigned int nbytes,
45 			  void *info, struct scatterlist *src,
46 			  struct scatterlist *dst, gfp_t flags);
47 
48 void cc_unmap_cipher_request(struct device *dev, void *ctx, unsigned int ivsize,
49 			     struct scatterlist *src, struct scatterlist *dst);
50 
51 int cc_map_aead_request(struct cc_drvdata *drvdata, struct aead_request *req);
52 
53 void cc_unmap_aead_request(struct device *dev, struct aead_request *req);
54 
55 int cc_map_hash_request_final(struct cc_drvdata *drvdata, void *ctx,
56 			      struct scatterlist *src, unsigned int nbytes,
57 			      bool do_update, gfp_t flags);
58 
59 int cc_map_hash_request_update(struct cc_drvdata *drvdata, void *ctx,
60 			       struct scatterlist *src, unsigned int nbytes,
61 			       unsigned int block_size, gfp_t flags);
62 
63 void cc_unmap_hash_request(struct device *dev, void *ctx,
64 			   struct scatterlist *src, bool do_revert);
65 
66 void cc_copy_sg_portion(struct device *dev, u8 *dest, struct scatterlist *sg,
67 			u32 to_skip, u32 end, enum cc_sg_cpy_direct direct);
68 
69 #endif /*__BUFFER_MGR_H__*/
70