UAPI: (Scripted) Disintegrate arch/cris/include/arch-v32/arch
[deliverable/linux.git] / arch / cris / include / arch-v32 / arch / cryptocop.h
CommitLineData
51533b61
MS
1/*
2 * The device /dev/cryptocop is accessible using this driver using
3 * CRYPTOCOP_MAJOR (254) and minor number 0.
4 */
51533b61
MS
5#ifndef CRYPTOCOP_H
6#define CRYPTOCOP_H
7
98d848ea 8#include <uapi/arch-v32/arch/cryptocop.h>
51533b61
MS
9
10
51533b61
MS
11/********** The API to use from inside the kernel. ************/
12
556dcee7 13#include <arch/hwregs/dma.h>
51533b61
MS
14
15typedef enum {
16 cryptocop_alg_csum = 0,
17 cryptocop_alg_mem2mem,
18 cryptocop_alg_md5,
19 cryptocop_alg_sha1,
20 cryptocop_alg_des,
21 cryptocop_alg_3des,
22 cryptocop_alg_aes,
23 cryptocop_no_alg,
24} cryptocop_algorithm;
25
26typedef u8 cryptocop_tfrm_id;
27
28
29struct cryptocop_operation;
30
31typedef void (cryptocop_callback)(struct cryptocop_operation*, void*);
32
33struct cryptocop_transform_init {
34 cryptocop_algorithm alg;
35 /* Keydata for ciphers. */
36 unsigned char key[CRYPTOCOP_MAX_KEY_LENGTH];
37 unsigned int keylen;
38 cryptocop_cipher_mode cipher_mode;
39 cryptocop_3des_mode tdes_mode;
40 cryptocop_csum_type csum_mode; /* cryptocop_csum_none is not allowed when alg==cryptocop_alg_csum */
41
42 cryptocop_tfrm_id tid; /* Locally unique in session; assigned by user, checked by driver. */
43 struct cryptocop_transform_init *next;
44};
45
46
47typedef enum {
48 cryptocop_source_dma = 0,
49 cryptocop_source_des,
50 cryptocop_source_3des,
51 cryptocop_source_aes,
52 cryptocop_source_md5,
53 cryptocop_source_sha1,
54 cryptocop_source_csum,
55 cryptocop_source_none,
56} cryptocop_source;
57
58
59struct cryptocop_desc_cfg {
60 cryptocop_tfrm_id tid;
61 cryptocop_source src;
62 unsigned int last:1; /* Last use of this transform in the operation. Will push outdata when encountered. */
63 struct cryptocop_desc_cfg *next;
64};
65
66struct cryptocop_desc {
67 size_t length;
68 struct cryptocop_desc_cfg *cfg;
69 struct cryptocop_desc *next;
70};
71
72
73/* Flags for cryptocop_tfrm_cfg */
74#define CRYPTOCOP_NO_FLAG (0x00)
75#define CRYPTOCOP_ENCRYPT (0x01)
76#define CRYPTOCOP_DECRYPT (0x02)
77#define CRYPTOCOP_EXPLICIT_IV (0x04)
78
79struct cryptocop_tfrm_cfg {
80 cryptocop_tfrm_id tid;
81
82 unsigned int flags; /* DECRYPT, ENCRYPT, EXPLICIT_IV */
83
84 /* CBC initialisation vector for cihers. */
85 u8 iv[CRYPTOCOP_MAX_IV_LENGTH];
86
87 /* The position in output where to write the transform output. The order
88 in which the driver writes the output is unspecified, hence if several
89 transforms write on the same positions in the output the result is
90 unspecified. */
91 size_t inject_ix;
92
93 struct cryptocop_tfrm_cfg *next;
94};
95
96
97
98struct cryptocop_dma_list_operation{
99 /* The consumer can provide DMA lists to send to the co-processor. 'use_dmalists' in
100 struct cryptocop_operation must be set for the driver to use them. outlist,
101 out_data_buf, inlist and in_data_buf must all be physical addresses since they will
102 be loaded to DMA . */
103 dma_descr_data *outlist; /* Out from memory to the co-processor. */
104 char *out_data_buf;
105 dma_descr_data *inlist; /* In from the co-processor to memory. */
106 char *in_data_buf;
107
108 cryptocop_3des_mode tdes_mode;
109 cryptocop_csum_type csum_mode;
110};
111
112
113struct cryptocop_tfrm_operation{
114 /* Operation configuration, if not 'use_dmalists' is set. */
115 struct cryptocop_tfrm_cfg *tfrm_cfg;
116 struct cryptocop_desc *desc;
117
118 struct iovec *indata;
119 size_t incount;
120 size_t inlen; /* Total inlength. */
121
122 struct iovec *outdata;
123 size_t outcount;
124 size_t outlen; /* Total outlength. */
125};
126
127
128struct cryptocop_operation {
129 cryptocop_callback *cb;
130 void *cb_data;
131
132 cryptocop_session_id sid;
133
134 /* The status of the operation when returned to consumer. */
135 int operation_status; /* 0, -EAGAIN */
136
137 /* Flags */
138 unsigned int use_dmalists:1; /* Use outlist and inlist instead of the desc/tfrm_cfg configuration. */
139 unsigned int in_interrupt:1; /* Set if inserting job from interrupt context. */
140 unsigned int fast_callback:1; /* Set if fast callback wanted, i.e. from interrupt context. */
141
142 union{
143 struct cryptocop_dma_list_operation list_op;
144 struct cryptocop_tfrm_operation tfrm_op;
145 };
146};
147
148
149int cryptocop_new_session(cryptocop_session_id *sid, struct cryptocop_transform_init *tinit, int alloc_flag);
150int cryptocop_free_session(cryptocop_session_id sid);
151
152int cryptocop_job_queue_insert_csum(struct cryptocop_operation *operation);
153
154int cryptocop_job_queue_insert_crypto(struct cryptocop_operation *operation);
155
156int cryptocop_job_queue_insert_user_job(struct cryptocop_operation *operation);
157
51533b61 158#endif /* CRYPTOCOP_H */
This page took 0.551203 seconds and 5 git commands to generate.