]> git.kernelconcepts.de Git - karo-tx-linux.git/blob - drivers/crypto/qce/dma.h
Merge commit 'v3.17' into next
[karo-tx-linux.git] / drivers / crypto / qce / dma.h
1 /*
2  * Copyright (c) 2011-2014, The Linux Foundation. All rights reserved.
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 and
6  * only version 2 as 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
14 #ifndef _DMA_H_
15 #define _DMA_H_
16
17 /* maximum data transfer block size between BAM and CE */
18 #define QCE_BAM_BURST_SIZE              64
19
20 #define QCE_AUTHIV_REGS_CNT             16
21 #define QCE_AUTH_BYTECOUNT_REGS_CNT     4
22 #define QCE_CNTRIV_REGS_CNT             4
23
24 struct qce_result_dump {
25         u32 auth_iv[QCE_AUTHIV_REGS_CNT];
26         u32 auth_byte_count[QCE_AUTH_BYTECOUNT_REGS_CNT];
27         u32 encr_cntr_iv[QCE_CNTRIV_REGS_CNT];
28         u32 status;
29         u32 status2;
30 };
31
32 #define QCE_IGNORE_BUF_SZ       (2 * QCE_BAM_BURST_SIZE)
33 #define QCE_RESULT_BUF_SZ       \
34                 ALIGN(sizeof(struct qce_result_dump), QCE_BAM_BURST_SIZE)
35
36 struct qce_dma_data {
37         struct dma_chan *txchan;
38         struct dma_chan *rxchan;
39         struct qce_result_dump *result_buf;
40         void *ignore_buf;
41 };
42
43 int qce_dma_request(struct device *dev, struct qce_dma_data *dma);
44 void qce_dma_release(struct qce_dma_data *dma);
45 int qce_dma_prep_sgs(struct qce_dma_data *dma, struct scatterlist *sg_in,
46                      int in_ents, struct scatterlist *sg_out, int out_ents,
47                      dma_async_tx_callback cb, void *cb_param);
48 void qce_dma_issue_pending(struct qce_dma_data *dma);
49 int qce_dma_terminate_all(struct qce_dma_data *dma);
50 int qce_countsg(struct scatterlist *sg_list, int nbytes, bool *chained);
51 void qce_unmapsg(struct device *dev, struct scatterlist *sg, int nents,
52                  enum dma_data_direction dir, bool chained);
53 int qce_mapsg(struct device *dev, struct scatterlist *sg, int nents,
54               enum dma_data_direction dir, bool chained);
55 struct scatterlist *
56 qce_sgtable_add(struct sg_table *sgt, struct scatterlist *sg_add);
57
58 #endif /* _DMA_H_ */