blob: 653441b6542e1fb143599af6e3c3c6ac77e750fa [file] [log] [blame]
Gilad Ben-Yossef4c3f9722018-01-22 09:27:00 +00001/* SPDX-License-Identifier: GPL-2.0 */
Gilad Ben-Yossef03963ca2019-04-18 16:38:53 +03002/* Copyright (C) 2012-2019 ARM Limited (or its affiliates). */
Gilad Ben-Yossef4c3f9722018-01-22 09:27:00 +00003
4/* \file cc_buffer_mgr.h
5 * Buffer Manager
6 */
7
8#ifndef __CC_BUFFER_MGR_H__
9#define __CC_BUFFER_MGR_H__
10
11#include <crypto/algapi.h>
12
13#include "cc_driver.h"
14
15enum cc_req_dma_buf_type {
16 CC_DMA_BUF_NULL = 0,
17 CC_DMA_BUF_DLLI,
18 CC_DMA_BUF_MLLI
19};
20
21enum cc_sg_cpy_direct {
22 CC_SG_TO_BUF = 0,
23 CC_SG_FROM_BUF = 1
24};
25
26struct cc_mlli {
Geert Uytterhoeven1a895f12020-02-11 19:19:07 +010027 u32 sram_addr;
Gilad Ben-Yossefce0fc6d2020-01-29 16:37:54 +020028 unsigned int mapped_nents;
Gilad Ben-Yossef4c3f9722018-01-22 09:27:00 +000029 unsigned int nents; //sg nents
30 unsigned int mlli_nents; //mlli nents might be different than the above
31};
32
33struct mlli_params {
34 struct dma_pool *curr_pool;
Geert Uytterhoevenba99b6f2020-02-11 19:19:03 +010035 void *mlli_virt_addr;
Gilad Ben-Yossef4c3f9722018-01-22 09:27:00 +000036 dma_addr_t mlli_dma_addr;
37 u32 mlli_len;
38};
39
40int cc_buffer_mgr_init(struct cc_drvdata *drvdata);
41
42int cc_buffer_mgr_fini(struct cc_drvdata *drvdata);
43
Gilad Ben-Yossef63ee04c2018-01-22 09:27:01 +000044int cc_map_cipher_request(struct cc_drvdata *drvdata, void *ctx,
45 unsigned int ivsize, unsigned int nbytes,
46 void *info, struct scatterlist *src,
47 struct scatterlist *dst, gfp_t flags);
48
49void cc_unmap_cipher_request(struct device *dev, void *ctx, unsigned int ivsize,
50 struct scatterlist *src, struct scatterlist *dst);
51
Gilad Ben-Yossefff27e852018-01-22 09:27:03 +000052int cc_map_aead_request(struct cc_drvdata *drvdata, struct aead_request *req);
53
54void cc_unmap_aead_request(struct device *dev, struct aead_request *req);
55
Gilad Ben-Yossef4c3f9722018-01-22 09:27:00 +000056int cc_map_hash_request_final(struct cc_drvdata *drvdata, void *ctx,
57 struct scatterlist *src, unsigned int nbytes,
58 bool do_update, gfp_t flags);
59
60int cc_map_hash_request_update(struct cc_drvdata *drvdata, void *ctx,
61 struct scatterlist *src, unsigned int nbytes,
62 unsigned int block_size, gfp_t flags);
63
64void cc_unmap_hash_request(struct device *dev, void *ctx,
65 struct scatterlist *src, bool do_revert);
66
67void cc_copy_sg_portion(struct device *dev, u8 *dest, struct scatterlist *sg,
68 u32 to_skip, u32 end, enum cc_sg_cpy_direct direct);
69
Gilad Ben-Yossef4c3f9722018-01-22 09:27:00 +000070#endif /*__BUFFER_MGR_H__*/