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