2 * Copyright (C) 2012-2017 ARM Limited or its affiliates.
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.
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.
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/>.
21 #ifndef __SSI_BUFFER_MGR_H__
22 #define __SSI_BUFFER_MGR_H__
24 #include <crypto/algapi.h>
26 #include "ssi_config.h"
27 #include "ssi_driver.h"
30 enum ssi_req_dma_buf_type
{
36 enum ssi_sg_cpy_direct
{
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
48 struct dma_pool
*curr_pool
;
49 uint8_t *mlli_virt_addr
;
50 dma_addr_t mlli_dma_addr
;
54 int ssi_buffer_mgr_init(struct ssi_drvdata
*drvdata
);
56 int ssi_buffer_mgr_fini(struct ssi_drvdata
*drvdata
);
58 int ssi_buffer_mgr_map_blkcipher_request(
59 struct ssi_drvdata
*drvdata
,
64 struct scatterlist
*src
,
65 struct scatterlist
*dst
);
67 void ssi_buffer_mgr_unmap_blkcipher_request(
71 struct scatterlist
*src
,
72 struct scatterlist
*dst
);
74 int ssi_buffer_mgr_map_aead_request(struct ssi_drvdata
*drvdata
, struct aead_request
*req
);
76 void ssi_buffer_mgr_unmap_aead_request(struct device
*dev
, struct aead_request
*req
);
78 int ssi_buffer_mgr_map_hash_request_final(struct ssi_drvdata
*drvdata
, void *ctx
, struct scatterlist
*src
, unsigned int nbytes
, bool do_update
);
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
);
82 void ssi_buffer_mgr_unmap_hash_request(struct device
*dev
, void *ctx
, struct scatterlist
*src
, bool do_revert
);
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
);
86 void ssi_buffer_mgr_zero_sgl(struct scatterlist
*sgl
, uint32_t data_len
);
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
);
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)
99 #define SSI_UPDATE_DMA_ADDR_TO_48BIT(addr,size) addr = addr
100 #define SSI_RESTORE_DMA_ADDR_TO_48BIT(addr) addr = addr
104 #endif /*__BUFFER_MGR_H__*/