14c3f9727SGilad Ben-Yossef /* SPDX-License-Identifier: GPL-2.0 */ 203963caeSGilad Ben-Yossef /* Copyright (C) 2012-2019 ARM Limited (or its affiliates). */ 34c3f9727SGilad Ben-Yossef 44c3f9727SGilad Ben-Yossef /* \file cc_buffer_mgr.h 54c3f9727SGilad Ben-Yossef * Buffer Manager 64c3f9727SGilad Ben-Yossef */ 74c3f9727SGilad Ben-Yossef 84c3f9727SGilad Ben-Yossef #ifndef __CC_BUFFER_MGR_H__ 94c3f9727SGilad Ben-Yossef #define __CC_BUFFER_MGR_H__ 104c3f9727SGilad Ben-Yossef 114c3f9727SGilad Ben-Yossef #include <crypto/algapi.h> 124c3f9727SGilad Ben-Yossef 134c3f9727SGilad Ben-Yossef #include "cc_driver.h" 144c3f9727SGilad Ben-Yossef 154c3f9727SGilad Ben-Yossef enum cc_req_dma_buf_type { 164c3f9727SGilad Ben-Yossef CC_DMA_BUF_NULL = 0, 174c3f9727SGilad Ben-Yossef CC_DMA_BUF_DLLI, 184c3f9727SGilad Ben-Yossef CC_DMA_BUF_MLLI 194c3f9727SGilad Ben-Yossef }; 204c3f9727SGilad Ben-Yossef 214c3f9727SGilad Ben-Yossef enum cc_sg_cpy_direct { 224c3f9727SGilad Ben-Yossef CC_SG_TO_BUF = 0, 234c3f9727SGilad Ben-Yossef CC_SG_FROM_BUF = 1 244c3f9727SGilad Ben-Yossef }; 254c3f9727SGilad Ben-Yossef 264c3f9727SGilad Ben-Yossef struct cc_mlli { 27*1a895f1dSGeert Uytterhoeven u32 sram_addr; 28ce0fc6dbSGilad Ben-Yossef unsigned int mapped_nents; 294c3f9727SGilad Ben-Yossef unsigned int nents; //sg nents 304c3f9727SGilad Ben-Yossef unsigned int mlli_nents; //mlli nents might be different than the above 314c3f9727SGilad Ben-Yossef }; 324c3f9727SGilad Ben-Yossef 334c3f9727SGilad Ben-Yossef struct mlli_params { 344c3f9727SGilad Ben-Yossef struct dma_pool *curr_pool; 35ba99b6f9SGeert Uytterhoeven void *mlli_virt_addr; 364c3f9727SGilad Ben-Yossef dma_addr_t mlli_dma_addr; 374c3f9727SGilad Ben-Yossef u32 mlli_len; 384c3f9727SGilad Ben-Yossef }; 394c3f9727SGilad Ben-Yossef 404c3f9727SGilad Ben-Yossef int cc_buffer_mgr_init(struct cc_drvdata *drvdata); 414c3f9727SGilad Ben-Yossef 424c3f9727SGilad Ben-Yossef int cc_buffer_mgr_fini(struct cc_drvdata *drvdata); 434c3f9727SGilad Ben-Yossef 4463ee04c8SGilad Ben-Yossef int cc_map_cipher_request(struct cc_drvdata *drvdata, void *ctx, 4563ee04c8SGilad Ben-Yossef unsigned int ivsize, unsigned int nbytes, 4663ee04c8SGilad Ben-Yossef void *info, struct scatterlist *src, 4763ee04c8SGilad Ben-Yossef struct scatterlist *dst, gfp_t flags); 4863ee04c8SGilad Ben-Yossef 4963ee04c8SGilad Ben-Yossef void cc_unmap_cipher_request(struct device *dev, void *ctx, unsigned int ivsize, 5063ee04c8SGilad Ben-Yossef struct scatterlist *src, struct scatterlist *dst); 5163ee04c8SGilad Ben-Yossef 52ff27e85aSGilad Ben-Yossef int cc_map_aead_request(struct cc_drvdata *drvdata, struct aead_request *req); 53ff27e85aSGilad Ben-Yossef 54ff27e85aSGilad Ben-Yossef void cc_unmap_aead_request(struct device *dev, struct aead_request *req); 55ff27e85aSGilad Ben-Yossef 564c3f9727SGilad Ben-Yossef int cc_map_hash_request_final(struct cc_drvdata *drvdata, void *ctx, 574c3f9727SGilad Ben-Yossef struct scatterlist *src, unsigned int nbytes, 584c3f9727SGilad Ben-Yossef bool do_update, gfp_t flags); 594c3f9727SGilad Ben-Yossef 604c3f9727SGilad Ben-Yossef int cc_map_hash_request_update(struct cc_drvdata *drvdata, void *ctx, 614c3f9727SGilad Ben-Yossef struct scatterlist *src, unsigned int nbytes, 624c3f9727SGilad Ben-Yossef unsigned int block_size, gfp_t flags); 634c3f9727SGilad Ben-Yossef 644c3f9727SGilad Ben-Yossef void cc_unmap_hash_request(struct device *dev, void *ctx, 654c3f9727SGilad Ben-Yossef struct scatterlist *src, bool do_revert); 664c3f9727SGilad Ben-Yossef 674c3f9727SGilad Ben-Yossef void cc_copy_sg_portion(struct device *dev, u8 *dest, struct scatterlist *sg, 684c3f9727SGilad Ben-Yossef u32 to_skip, u32 end, enum cc_sg_cpy_direct direct); 694c3f9727SGilad Ben-Yossef 704c3f9727SGilad Ben-Yossef #endif /*__BUFFER_MGR_H__*/ 71