2 * The device /dev/cryptocop is accessible using this driver using
3 * CRYPTOCOP_MAJOR (254) and minor number 0.
8 #include <uapi/arch-v32/arch/cryptocop.h>
11 /********** The API to use from inside the kernel. ************/
13 #include <arch/hwregs/dma.h>
16 cryptocop_alg_csum = 0,
17 cryptocop_alg_mem2mem,
24 } cryptocop_algorithm;
26 typedef u8 cryptocop_tfrm_id;
29 struct cryptocop_operation;
31 typedef void (cryptocop_callback)(struct cryptocop_operation*, void*);
33 struct cryptocop_transform_init {
34 cryptocop_algorithm alg;
35 /* Keydata for ciphers. */
36 unsigned char key[CRYPTOCOP_MAX_KEY_LENGTH];
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 */
42 cryptocop_tfrm_id tid; /* Locally unique in session; assigned by user, checked by driver. */
43 struct cryptocop_transform_init *next;
48 cryptocop_source_dma = 0,
50 cryptocop_source_3des,
53 cryptocop_source_sha1,
54 cryptocop_source_csum,
55 cryptocop_source_none,
59 struct cryptocop_desc_cfg {
60 cryptocop_tfrm_id tid;
62 unsigned int last:1; /* Last use of this transform in the operation. Will push outdata when encountered. */
63 struct cryptocop_desc_cfg *next;
66 struct cryptocop_desc {
68 struct cryptocop_desc_cfg *cfg;
69 struct cryptocop_desc *next;
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)
79 struct cryptocop_tfrm_cfg {
80 cryptocop_tfrm_id tid;
82 unsigned int flags; /* DECRYPT, ENCRYPT, EXPLICIT_IV */
84 /* CBC initialisation vector for ciphers. */
85 u8 iv[CRYPTOCOP_MAX_IV_LENGTH];
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
93 struct cryptocop_tfrm_cfg *next;
98 struct 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. */
105 dma_descr_data *inlist; /* In from the co-processor to memory. */
108 cryptocop_3des_mode tdes_mode;
109 cryptocop_csum_type csum_mode;
113 struct cryptocop_tfrm_operation{
114 /* Operation configuration, if not 'use_dmalists' is set. */
115 struct cryptocop_tfrm_cfg *tfrm_cfg;
116 struct cryptocop_desc *desc;
118 struct iovec *indata;
120 size_t inlen; /* Total inlength. */
122 struct iovec *outdata;
124 size_t outlen; /* Total outlength. */
128 struct cryptocop_operation {
129 cryptocop_callback *cb;
132 cryptocop_session_id sid;
134 /* The status of the operation when returned to consumer. */
135 int operation_status; /* 0, -EAGAIN */
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. */
143 struct cryptocop_dma_list_operation list_op;
144 struct cryptocop_tfrm_operation tfrm_op;
149 int cryptocop_new_session(cryptocop_session_id *sid, struct cryptocop_transform_init *tinit, int alloc_flag);
150 int cryptocop_free_session(cryptocop_session_id sid);
152 int cryptocop_job_queue_insert_csum(struct cryptocop_operation *operation);
154 int cryptocop_job_queue_insert_crypto(struct cryptocop_operation *operation);
156 int cryptocop_job_queue_insert_user_job(struct cryptocop_operation *operation);
158 #endif /* CRYPTOCOP_H */