GNU Linux-libre 4.14.295-gnu1
[releases.git] / drivers / staging / ccree / ssi_buffer_mgr.h
1 /*
2  * Copyright (C) 2012-2017 ARM Limited or its affiliates.
3  *
4  * This program is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License version 2 as
6  * published by the Free Software Foundation.
7  *
8  * This program is distributed in the hope that it will be useful,
9  * but WITHOUT ANY WARRANTY; without even the implied warranty of
10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11  * GNU General Public License for more details.
12  *
13  * You should have received a copy of the GNU General Public License
14  * along with this program; if not, see <http://www.gnu.org/licenses/>.
15  */
16
17 /* \file buffer_mgr.h
18  * Buffer Manager
19  */
20
21 #ifndef __SSI_BUFFER_MGR_H__
22 #define __SSI_BUFFER_MGR_H__
23
24 #include <crypto/algapi.h>
25
26 #include "ssi_config.h"
27 #include "ssi_driver.h"
28
29 enum ssi_req_dma_buf_type {
30         SSI_DMA_BUF_NULL = 0,
31         SSI_DMA_BUF_DLLI,
32         SSI_DMA_BUF_MLLI
33 };
34
35 enum ssi_sg_cpy_direct {
36         SSI_SG_TO_BUF = 0,
37         SSI_SG_FROM_BUF = 1
38 };
39
40 struct ssi_mlli {
41         ssi_sram_addr_t sram_addr;
42         unsigned int nents; //sg nents
43         unsigned int mlli_nents; //mlli nents might be different than the above
44 };
45
46 struct mlli_params {
47         struct dma_pool *curr_pool;
48         u8 *mlli_virt_addr;
49         dma_addr_t mlli_dma_addr;
50         u32 mlli_len;
51 };
52
53 int ssi_buffer_mgr_init(struct ssi_drvdata *drvdata);
54
55 int ssi_buffer_mgr_fini(struct ssi_drvdata *drvdata);
56
57 int ssi_buffer_mgr_map_blkcipher_request(
58         struct ssi_drvdata *drvdata,
59         void *ctx,
60         unsigned int ivsize,
61         unsigned int nbytes,
62         void *info,
63         struct scatterlist *src,
64         struct scatterlist *dst);
65
66 void ssi_buffer_mgr_unmap_blkcipher_request(
67         struct device *dev,
68         void *ctx,
69         unsigned int ivsize,
70         struct scatterlist *src,
71         struct scatterlist *dst);
72
73 int ssi_buffer_mgr_map_aead_request(struct ssi_drvdata *drvdata, struct aead_request *req);
74
75 void ssi_buffer_mgr_unmap_aead_request(struct device *dev, struct aead_request *req);
76
77 int ssi_buffer_mgr_map_hash_request_final(struct ssi_drvdata *drvdata, void *ctx, struct scatterlist *src, unsigned int nbytes, bool do_update);
78
79 int ssi_buffer_mgr_map_hash_request_update(struct ssi_drvdata *drvdata, void *ctx, struct scatterlist *src, unsigned int nbytes, unsigned int block_size);
80
81 void ssi_buffer_mgr_unmap_hash_request(struct device *dev, void *ctx, struct scatterlist *src, bool do_revert);
82
83 void ssi_buffer_mgr_copy_scatterlist_portion(u8 *dest, struct scatterlist *sg, u32 to_skip, u32 end, enum ssi_sg_cpy_direct direct);
84
85 void ssi_buffer_mgr_zero_sgl(struct scatterlist *sgl, u32 data_len);
86
87 #endif /*__BUFFER_MGR_H__*/
88