]>
Commit | Line | Data |
---|---|---|
abefd674 GBY |
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 | ||
30 | enum ssi_req_dma_buf_type { | |
31 | SSI_DMA_BUF_NULL = 0, | |
32 | SSI_DMA_BUF_DLLI, | |
33 | SSI_DMA_BUF_MLLI | |
34 | }; | |
35 | ||
36 | enum ssi_sg_cpy_direct { | |
37 | SSI_SG_TO_BUF = 0, | |
38 | SSI_SG_FROM_BUF = 1 | |
39 | }; | |
40 | ||
41 | struct ssi_mlli { | |
42 | ssi_sram_addr_t sram_addr; | |
43 | unsigned int nents; //sg nents | |
44 | unsigned int mlli_nents; //mlli nents might be different than the above | |
45 | }; | |
46 | ||
47 | struct mlli_params { | |
48 | struct dma_pool *curr_pool; | |
49 | uint8_t *mlli_virt_addr; | |
50 | dma_addr_t mlli_dma_addr; | |
51 | uint32_t mlli_len; | |
52 | }; | |
53 | ||
54 | int ssi_buffer_mgr_init(struct ssi_drvdata *drvdata); | |
55 | ||
56 | int ssi_buffer_mgr_fini(struct ssi_drvdata *drvdata); | |
57 | ||
302ef8eb GBY |
58 | int ssi_buffer_mgr_map_blkcipher_request( |
59 | struct ssi_drvdata *drvdata, | |
60 | void *ctx, | |
61 | unsigned int ivsize, | |
62 | unsigned int nbytes, | |
63 | void *info, | |
64 | struct scatterlist *src, | |
65 | struct scatterlist *dst); | |
66 | ||
67 | void ssi_buffer_mgr_unmap_blkcipher_request( | |
68 | struct device *dev, | |
69 | void *ctx, | |
70 | unsigned int ivsize, | |
71 | struct scatterlist *src, | |
72 | struct scatterlist *dst); | |
73 | ||
fe0a1951 GBY |
74 | int ssi_buffer_mgr_map_aead_request(struct ssi_drvdata *drvdata, struct aead_request *req); |
75 | ||
76 | void ssi_buffer_mgr_unmap_aead_request(struct device *dev, struct aead_request *req); | |
77 | ||
50cfbbb7 GBY |
78 | int ssi_buffer_mgr_map_hash_request_final(struct ssi_drvdata *drvdata, void *ctx, struct scatterlist *src, unsigned int nbytes, bool do_update); |
79 | ||
80 | int ssi_buffer_mgr_map_hash_request_update(struct ssi_drvdata *drvdata, void *ctx, struct scatterlist *src, unsigned int nbytes, unsigned int block_size); | |
81 | ||
82 | void ssi_buffer_mgr_unmap_hash_request(struct device *dev, void *ctx, struct scatterlist *src, bool do_revert); | |
83 | ||
abefd674 GBY |
84 | void ssi_buffer_mgr_copy_scatterlist_portion(u8 *dest, struct scatterlist *sg, uint32_t to_skip, uint32_t end, enum ssi_sg_cpy_direct direct); |
85 | ||
86 | void ssi_buffer_mgr_zero_sgl(struct scatterlist *sgl, uint32_t data_len); | |
87 | ||
88 | ||
89 | #ifdef CC_DMA_48BIT_SIM | |
90 | dma_addr_t ssi_buff_mgr_update_dma_addr(dma_addr_t orig_addr, uint32_t data_len); | |
91 | dma_addr_t ssi_buff_mgr_restore_dma_addr(dma_addr_t orig_addr); | |
92 | ||
93 | #define SSI_UPDATE_DMA_ADDR_TO_48BIT(addr,size) addr = \ | |
94 | ssi_buff_mgr_update_dma_addr(addr,size) | |
95 | #define SSI_RESTORE_DMA_ADDR_TO_48BIT(addr) addr = \ | |
96 | ssi_buff_mgr_restore_dma_addr(addr) | |
97 | #else | |
98 | ||
99 | #define SSI_UPDATE_DMA_ADDR_TO_48BIT(addr,size) addr = addr | |
100 | #define SSI_RESTORE_DMA_ADDR_TO_48BIT(addr) addr = addr | |
101 | ||
102 | #endif | |
103 | ||
104 | #endif /*__BUFFER_MGR_H__*/ | |
105 |