blob: fa026174892079c4518b853cb129609eefce9fe5 [file] [log] [blame]
Tom Lendacky63b94502013-11-12 11:46:16 -06001/*
2 * AMD Cryptographic Coprocessor (CCP) driver
3 *
Gary R Hook58ea8ab2016-04-18 09:21:44 -05004 * Copyright (C) 2013,2016 Advanced Micro Devices, Inc.
Tom Lendacky63b94502013-11-12 11:46:16 -06005 *
6 * Author: Tom Lendacky <thomas.lendacky@amd.com>
Gary R Hook58ea8ab2016-04-18 09:21:44 -05007 * Author: Gary R Hook <gary.hook@amd.com>
Tom Lendacky63b94502013-11-12 11:46:16 -06008 *
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License version 2 as
11 * published by the Free Software Foundation.
12 */
13
Paul Bollec8d283ff2016-10-20 21:20:59 +020014#ifndef __CCP_H__
15#define __CCP_H__
Tom Lendacky63b94502013-11-12 11:46:16 -060016
17#include <linux/scatterlist.h>
18#include <linux/workqueue.h>
19#include <linux/list.h>
20#include <crypto/aes.h>
21#include <crypto/sha.h>
22
23
24struct ccp_device;
25struct ccp_cmd;
26
Tom Lendackydb34cf92014-01-06 13:34:29 -060027#if defined(CONFIG_CRYPTO_DEV_CCP_DD) || \
28 defined(CONFIG_CRYPTO_DEV_CCP_DD_MODULE)
29
Tom Lendacky63b94502013-11-12 11:46:16 -060030/**
Tom Lendackyc9f21cb2014-09-05 10:31:09 -050031 * ccp_present - check if a CCP device is present
32 *
33 * Returns zero if a CCP device is present, -ENODEV otherwise.
34 */
35int ccp_present(void);
36
Gary R Hookc7019c42016-03-01 13:49:15 -060037#define CCP_VSIZE 16
38#define CCP_VMASK ((unsigned int)((1 << CCP_VSIZE) - 1))
39#define CCP_VERSION(v, r) ((unsigned int)((v << CCP_VSIZE) \
40 | (r & CCP_VMASK)))
41
42/**
43 * ccp_version - get the version of the CCP
44 *
45 * Returns a positive version number, or zero if no CCP
46 */
47unsigned int ccp_version(void);
48
Tom Lendackyc9f21cb2014-09-05 10:31:09 -050049/**
Tom Lendacky63b94502013-11-12 11:46:16 -060050 * ccp_enqueue_cmd - queue an operation for processing by the CCP
51 *
52 * @cmd: ccp_cmd struct to be processed
53 *
54 * Refer to the ccp_cmd struct below for required fields.
55 *
56 * Queue a cmd to be processed by the CCP. If queueing the cmd
57 * would exceed the defined length of the cmd queue the cmd will
58 * only be queued if the CCP_CMD_MAY_BACKLOG flag is set and will
59 * result in a return code of -EBUSY.
60 *
61 * The callback routine specified in the ccp_cmd struct will be
62 * called to notify the caller of completion (if the cmd was not
63 * backlogged) or advancement out of the backlog. If the cmd has
64 * advanced out of the backlog the "err" value of the callback
65 * will be -EINPROGRESS. Any other "err" value during callback is
66 * the result of the operation.
67 *
68 * The cmd has been successfully queued if:
69 * the return code is -EINPROGRESS or
70 * the return code is -EBUSY and CCP_CMD_MAY_BACKLOG flag is set
71 */
72int ccp_enqueue_cmd(struct ccp_cmd *cmd);
73
Tom Lendackydb34cf92014-01-06 13:34:29 -060074#else /* CONFIG_CRYPTO_DEV_CCP_DD is not enabled */
75
Tom Lendackyc9f21cb2014-09-05 10:31:09 -050076static inline int ccp_present(void)
77{
78 return -ENODEV;
79}
80
Gary R Hookc7019c42016-03-01 13:49:15 -060081static inline unsigned int ccp_version(void)
82{
83 return 0;
84}
85
Tom Lendackydb34cf92014-01-06 13:34:29 -060086static inline int ccp_enqueue_cmd(struct ccp_cmd *cmd)
87{
88 return -ENODEV;
89}
90
91#endif /* CONFIG_CRYPTO_DEV_CCP_DD */
92
Tom Lendacky63b94502013-11-12 11:46:16 -060093
94/***** AES engine *****/
95/**
96 * ccp_aes_type - AES key size
97 *
98 * @CCP_AES_TYPE_128: 128-bit key
99 * @CCP_AES_TYPE_192: 192-bit key
100 * @CCP_AES_TYPE_256: 256-bit key
101 */
102enum ccp_aes_type {
103 CCP_AES_TYPE_128 = 0,
104 CCP_AES_TYPE_192,
105 CCP_AES_TYPE_256,
106 CCP_AES_TYPE__LAST,
107};
108
109/**
110 * ccp_aes_mode - AES operation mode
111 *
112 * @CCP_AES_MODE_ECB: ECB mode
113 * @CCP_AES_MODE_CBC: CBC mode
114 * @CCP_AES_MODE_OFB: OFB mode
115 * @CCP_AES_MODE_CFB: CFB mode
116 * @CCP_AES_MODE_CTR: CTR mode
117 * @CCP_AES_MODE_CMAC: CMAC mode
118 */
119enum ccp_aes_mode {
120 CCP_AES_MODE_ECB = 0,
121 CCP_AES_MODE_CBC,
122 CCP_AES_MODE_OFB,
123 CCP_AES_MODE_CFB,
124 CCP_AES_MODE_CTR,
125 CCP_AES_MODE_CMAC,
126 CCP_AES_MODE__LAST,
127};
128
129/**
130 * ccp_aes_mode - AES operation mode
131 *
132 * @CCP_AES_ACTION_DECRYPT: AES decrypt operation
133 * @CCP_AES_ACTION_ENCRYPT: AES encrypt operation
134 */
135enum ccp_aes_action {
136 CCP_AES_ACTION_DECRYPT = 0,
137 CCP_AES_ACTION_ENCRYPT,
138 CCP_AES_ACTION__LAST,
139};
140
141/**
142 * struct ccp_aes_engine - CCP AES operation
143 * @type: AES operation key size
144 * @mode: AES operation mode
145 * @action: AES operation (decrypt/encrypt)
146 * @key: key to be used for this AES operation
147 * @key_len: length in bytes of key
148 * @iv: IV to be used for this AES operation
149 * @iv_len: length in bytes of iv
150 * @src: data to be used for this operation
151 * @dst: data produced by this operation
152 * @src_len: length in bytes of data used for this operation
153 * @cmac_final: indicates final operation when running in CMAC mode
154 * @cmac_key: K1/K2 key used in final CMAC operation
155 * @cmac_key_len: length in bytes of cmac_key
156 *
157 * Variables required to be set when calling ccp_enqueue_cmd():
158 * - type, mode, action, key, key_len, src, dst, src_len
159 * - iv, iv_len for any mode other than ECB
160 * - cmac_final for CMAC mode
161 * - cmac_key, cmac_key_len for CMAC mode if cmac_final is non-zero
162 *
163 * The iv variable is used as both input and output. On completion of the
164 * AES operation the new IV overwrites the old IV.
165 */
166struct ccp_aes_engine {
167 enum ccp_aes_type type;
168 enum ccp_aes_mode mode;
169 enum ccp_aes_action action;
170
171 struct scatterlist *key;
172 u32 key_len; /* In bytes */
173
174 struct scatterlist *iv;
175 u32 iv_len; /* In bytes */
176
177 struct scatterlist *src, *dst;
Tom Lendacky81a59f02014-01-06 13:34:17 -0600178 u64 src_len; /* In bytes */
Tom Lendacky63b94502013-11-12 11:46:16 -0600179
180 u32 cmac_final; /* Indicates final cmac cmd */
181 struct scatterlist *cmac_key; /* K1/K2 cmac key required for
182 * final cmac cmd */
183 u32 cmac_key_len; /* In bytes */
184};
185
186/***** XTS-AES engine *****/
187/**
188 * ccp_xts_aes_unit_size - XTS unit size
189 *
190 * @CCP_XTS_AES_UNIT_SIZE_16: Unit size of 16 bytes
191 * @CCP_XTS_AES_UNIT_SIZE_512: Unit size of 512 bytes
192 * @CCP_XTS_AES_UNIT_SIZE_1024: Unit size of 1024 bytes
193 * @CCP_XTS_AES_UNIT_SIZE_2048: Unit size of 2048 bytes
194 * @CCP_XTS_AES_UNIT_SIZE_4096: Unit size of 4096 bytes
195 */
196enum ccp_xts_aes_unit_size {
197 CCP_XTS_AES_UNIT_SIZE_16 = 0,
198 CCP_XTS_AES_UNIT_SIZE_512,
199 CCP_XTS_AES_UNIT_SIZE_1024,
200 CCP_XTS_AES_UNIT_SIZE_2048,
201 CCP_XTS_AES_UNIT_SIZE_4096,
202 CCP_XTS_AES_UNIT_SIZE__LAST,
203};
204
205/**
206 * struct ccp_xts_aes_engine - CCP XTS AES operation
207 * @action: AES operation (decrypt/encrypt)
208 * @unit_size: unit size of the XTS operation
209 * @key: key to be used for this XTS AES operation
210 * @key_len: length in bytes of key
211 * @iv: IV to be used for this XTS AES operation
212 * @iv_len: length in bytes of iv
213 * @src: data to be used for this operation
214 * @dst: data produced by this operation
215 * @src_len: length in bytes of data used for this operation
216 * @final: indicates final XTS operation
217 *
218 * Variables required to be set when calling ccp_enqueue_cmd():
219 * - action, unit_size, key, key_len, iv, iv_len, src, dst, src_len, final
220 *
221 * The iv variable is used as both input and output. On completion of the
222 * AES operation the new IV overwrites the old IV.
223 */
224struct ccp_xts_aes_engine {
225 enum ccp_aes_action action;
226 enum ccp_xts_aes_unit_size unit_size;
227
228 struct scatterlist *key;
229 u32 key_len; /* In bytes */
230
231 struct scatterlist *iv;
232 u32 iv_len; /* In bytes */
233
234 struct scatterlist *src, *dst;
Tom Lendacky81a59f02014-01-06 13:34:17 -0600235 u64 src_len; /* In bytes */
Tom Lendacky63b94502013-11-12 11:46:16 -0600236
237 u32 final;
238};
239
240/***** SHA engine *****/
Tom Lendacky63b94502013-11-12 11:46:16 -0600241/**
242 * ccp_sha_type - type of SHA operation
243 *
244 * @CCP_SHA_TYPE_1: SHA-1 operation
245 * @CCP_SHA_TYPE_224: SHA-224 operation
246 * @CCP_SHA_TYPE_256: SHA-256 operation
247 */
248enum ccp_sha_type {
249 CCP_SHA_TYPE_1 = 1,
250 CCP_SHA_TYPE_224,
251 CCP_SHA_TYPE_256,
Gary R Hookccebcf32017-03-15 13:20:43 -0500252 CCP_SHA_TYPE_384,
253 CCP_SHA_TYPE_512,
Tom Lendacky63b94502013-11-12 11:46:16 -0600254 CCP_SHA_TYPE__LAST,
255};
256
257/**
258 * struct ccp_sha_engine - CCP SHA operation
259 * @type: Type of SHA operation
260 * @ctx: current hash value
261 * @ctx_len: length in bytes of hash value
262 * @src: data to be used for this operation
263 * @src_len: length in bytes of data used for this operation
Tom Lendackyc11baa02014-01-24 16:18:02 -0600264 * @opad: data to be used for final HMAC operation
265 * @opad_len: length in bytes of data used for final HMAC operation
266 * @first: indicates first SHA operation
Tom Lendacky63b94502013-11-12 11:46:16 -0600267 * @final: indicates final SHA operation
268 * @msg_bits: total length of the message in bits used in final SHA operation
269 *
270 * Variables required to be set when calling ccp_enqueue_cmd():
271 * - type, ctx, ctx_len, src, src_len, final
272 * - msg_bits if final is non-zero
273 *
274 * The ctx variable is used as both input and output. On completion of the
275 * SHA operation the new hash value overwrites the old hash value.
276 */
277struct ccp_sha_engine {
278 enum ccp_sha_type type;
279
280 struct scatterlist *ctx;
281 u32 ctx_len; /* In bytes */
282
283 struct scatterlist *src;
Tom Lendacky81a59f02014-01-06 13:34:17 -0600284 u64 src_len; /* In bytes */
Tom Lendacky63b94502013-11-12 11:46:16 -0600285
Tom Lendackyc11baa02014-01-24 16:18:02 -0600286 struct scatterlist *opad;
287 u32 opad_len; /* In bytes */
288
289 u32 first; /* Indicates first sha cmd */
Tom Lendacky63b94502013-11-12 11:46:16 -0600290 u32 final; /* Indicates final sha cmd */
291 u64 msg_bits; /* Message length in bits required for
292 * final sha cmd */
293};
294
Gary R Hook990672d2017-03-15 13:20:52 -0500295/***** 3DES engine *****/
296enum ccp_des3_mode {
297 CCP_DES3_MODE_ECB = 0,
298 CCP_DES3_MODE_CBC,
299 CCP_DES3_MODE_CFB,
300 CCP_DES3_MODE__LAST,
301};
302
303enum ccp_des3_type {
304 CCP_DES3_TYPE_168 = 1,
305 CCP_DES3_TYPE__LAST,
306 };
307
308enum ccp_des3_action {
309 CCP_DES3_ACTION_DECRYPT = 0,
310 CCP_DES3_ACTION_ENCRYPT,
311 CCP_DES3_ACTION__LAST,
312};
313
314/**
315 * struct ccp_des3_engine - CCP SHA operation
316 * @type: Type of 3DES operation
317 * @mode: cipher mode
318 * @action: 3DES operation (decrypt/encrypt)
319 * @key: key to be used for this 3DES operation
320 * @key_len: length of key (in bytes)
321 * @iv: IV to be used for this AES operation
322 * @iv_len: length in bytes of iv
323 * @src: input data to be used for this operation
324 * @src_len: length of input data used for this operation (in bytes)
325 * @dst: output data produced by this operation
326 *
327 * Variables required to be set when calling ccp_enqueue_cmd():
328 * - type, mode, action, key, key_len, src, dst, src_len
329 * - iv, iv_len for any mode other than ECB
330 *
331 * The iv variable is used as both input and output. On completion of the
332 * 3DES operation the new IV overwrites the old IV.
333 */
334struct ccp_des3_engine {
335 enum ccp_des3_type type;
336 enum ccp_des3_mode mode;
337 enum ccp_des3_action action;
338
339 struct scatterlist *key;
340 u32 key_len; /* In bytes */
341
342 struct scatterlist *iv;
343 u32 iv_len; /* In bytes */
344
345 struct scatterlist *src, *dst;
346 u64 src_len; /* In bytes */
347};
348
Tom Lendacky63b94502013-11-12 11:46:16 -0600349/***** RSA engine *****/
350/**
351 * struct ccp_rsa_engine - CCP RSA operation
352 * @key_size: length in bits of RSA key
353 * @exp: RSA exponent
354 * @exp_len: length in bytes of exponent
355 * @mod: RSA modulus
356 * @mod_len: length in bytes of modulus
357 * @src: data to be used for this operation
358 * @dst: data produced by this operation
359 * @src_len: length in bytes of data used for this operation
360 *
361 * Variables required to be set when calling ccp_enqueue_cmd():
362 * - key_size, exp, exp_len, mod, mod_len, src, dst, src_len
363 */
364struct ccp_rsa_engine {
365 u32 key_size; /* In bits */
366
367 struct scatterlist *exp;
368 u32 exp_len; /* In bytes */
369
370 struct scatterlist *mod;
371 u32 mod_len; /* In bytes */
372
373 struct scatterlist *src, *dst;
374 u32 src_len; /* In bytes */
375};
376
377/***** Passthru engine *****/
378/**
379 * ccp_passthru_bitwise - type of bitwise passthru operation
380 *
381 * @CCP_PASSTHRU_BITWISE_NOOP: no bitwise operation performed
382 * @CCP_PASSTHRU_BITWISE_AND: perform bitwise AND of src with mask
383 * @CCP_PASSTHRU_BITWISE_OR: perform bitwise OR of src with mask
384 * @CCP_PASSTHRU_BITWISE_XOR: perform bitwise XOR of src with mask
385 * @CCP_PASSTHRU_BITWISE_MASK: overwrite with mask
386 */
387enum ccp_passthru_bitwise {
388 CCP_PASSTHRU_BITWISE_NOOP = 0,
389 CCP_PASSTHRU_BITWISE_AND,
390 CCP_PASSTHRU_BITWISE_OR,
391 CCP_PASSTHRU_BITWISE_XOR,
392 CCP_PASSTHRU_BITWISE_MASK,
393 CCP_PASSTHRU_BITWISE__LAST,
394};
395
396/**
397 * ccp_passthru_byteswap - type of byteswap passthru operation
398 *
399 * @CCP_PASSTHRU_BYTESWAP_NOOP: no byte swapping performed
400 * @CCP_PASSTHRU_BYTESWAP_32BIT: swap bytes within 32-bit words
401 * @CCP_PASSTHRU_BYTESWAP_256BIT: swap bytes within 256-bit words
402 */
403enum ccp_passthru_byteswap {
404 CCP_PASSTHRU_BYTESWAP_NOOP = 0,
405 CCP_PASSTHRU_BYTESWAP_32BIT,
406 CCP_PASSTHRU_BYTESWAP_256BIT,
407 CCP_PASSTHRU_BYTESWAP__LAST,
408};
409
410/**
411 * struct ccp_passthru_engine - CCP pass-through operation
412 * @bit_mod: bitwise operation to perform
413 * @byte_swap: byteswap operation to perform
414 * @mask: mask to be applied to data
415 * @mask_len: length in bytes of mask
416 * @src: data to be used for this operation
417 * @dst: data produced by this operation
418 * @src_len: length in bytes of data used for this operation
419 * @final: indicate final pass-through operation
420 *
421 * Variables required to be set when calling ccp_enqueue_cmd():
422 * - bit_mod, byte_swap, src, dst, src_len
423 * - mask, mask_len if bit_mod is not CCP_PASSTHRU_BITWISE_NOOP
424 */
425struct ccp_passthru_engine {
426 enum ccp_passthru_bitwise bit_mod;
427 enum ccp_passthru_byteswap byte_swap;
428
429 struct scatterlist *mask;
430 u32 mask_len; /* In bytes */
431
432 struct scatterlist *src, *dst;
Tom Lendacky81a59f02014-01-06 13:34:17 -0600433 u64 src_len; /* In bytes */
Tom Lendacky63b94502013-11-12 11:46:16 -0600434
435 u32 final;
436};
437
Gary R Hook58ea8ab2016-04-18 09:21:44 -0500438/**
439 * struct ccp_passthru_nomap_engine - CCP pass-through operation
440 * without performing DMA mapping
441 * @bit_mod: bitwise operation to perform
442 * @byte_swap: byteswap operation to perform
443 * @mask: mask to be applied to data
444 * @mask_len: length in bytes of mask
445 * @src: data to be used for this operation
446 * @dst: data produced by this operation
447 * @src_len: length in bytes of data used for this operation
448 * @final: indicate final pass-through operation
449 *
450 * Variables required to be set when calling ccp_enqueue_cmd():
451 * - bit_mod, byte_swap, src, dst, src_len
452 * - mask, mask_len if bit_mod is not CCP_PASSTHRU_BITWISE_NOOP
453 */
454struct ccp_passthru_nomap_engine {
455 enum ccp_passthru_bitwise bit_mod;
456 enum ccp_passthru_byteswap byte_swap;
457
458 dma_addr_t mask;
459 u32 mask_len; /* In bytes */
460
461 dma_addr_t src_dma, dst_dma;
462 u64 src_len; /* In bytes */
463
464 u32 final;
465};
466
Tom Lendacky63b94502013-11-12 11:46:16 -0600467/***** ECC engine *****/
468#define CCP_ECC_MODULUS_BYTES 48 /* 384-bits */
469#define CCP_ECC_MAX_OPERANDS 6
470#define CCP_ECC_MAX_OUTPUTS 3
471
472/**
473 * ccp_ecc_function - type of ECC function
474 *
475 * @CCP_ECC_FUNCTION_MMUL_384BIT: 384-bit modular multiplication
476 * @CCP_ECC_FUNCTION_MADD_384BIT: 384-bit modular addition
477 * @CCP_ECC_FUNCTION_MINV_384BIT: 384-bit multiplicative inverse
478 * @CCP_ECC_FUNCTION_PADD_384BIT: 384-bit point addition
479 * @CCP_ECC_FUNCTION_PMUL_384BIT: 384-bit point multiplication
480 * @CCP_ECC_FUNCTION_PDBL_384BIT: 384-bit point doubling
481 */
482enum ccp_ecc_function {
483 CCP_ECC_FUNCTION_MMUL_384BIT = 0,
484 CCP_ECC_FUNCTION_MADD_384BIT,
485 CCP_ECC_FUNCTION_MINV_384BIT,
486 CCP_ECC_FUNCTION_PADD_384BIT,
487 CCP_ECC_FUNCTION_PMUL_384BIT,
488 CCP_ECC_FUNCTION_PDBL_384BIT,
489};
490
491/**
492 * struct ccp_ecc_modular_math - CCP ECC modular math parameters
493 * @operand_1: first operand for the modular math operation
494 * @operand_1_len: length of the first operand
495 * @operand_2: second operand for the modular math operation
496 * (not used for CCP_ECC_FUNCTION_MINV_384BIT)
497 * @operand_2_len: length of the second operand
498 * (not used for CCP_ECC_FUNCTION_MINV_384BIT)
499 * @result: result of the modular math operation
500 * @result_len: length of the supplied result buffer
501 */
502struct ccp_ecc_modular_math {
503 struct scatterlist *operand_1;
504 unsigned int operand_1_len; /* In bytes */
505
506 struct scatterlist *operand_2;
507 unsigned int operand_2_len; /* In bytes */
508
509 struct scatterlist *result;
510 unsigned int result_len; /* In bytes */
511};
512
513/**
514 * struct ccp_ecc_point - CCP ECC point definition
515 * @x: the x coordinate of the ECC point
516 * @x_len: the length of the x coordinate
517 * @y: the y coordinate of the ECC point
518 * @y_len: the length of the y coordinate
519 */
520struct ccp_ecc_point {
521 struct scatterlist *x;
522 unsigned int x_len; /* In bytes */
523
524 struct scatterlist *y;
525 unsigned int y_len; /* In bytes */
526};
527
528/**
529 * struct ccp_ecc_point_math - CCP ECC point math parameters
530 * @point_1: the first point of the ECC point math operation
531 * @point_2: the second point of the ECC point math operation
532 * (only used for CCP_ECC_FUNCTION_PADD_384BIT)
533 * @domain_a: the a parameter of the ECC curve
534 * @domain_a_len: the length of the a parameter
535 * @scalar: the scalar parameter for the point match operation
536 * (only used for CCP_ECC_FUNCTION_PMUL_384BIT)
537 * @scalar_len: the length of the scalar parameter
538 * (only used for CCP_ECC_FUNCTION_PMUL_384BIT)
539 * @result: the point resulting from the point math operation
540 */
541struct ccp_ecc_point_math {
542 struct ccp_ecc_point point_1;
543 struct ccp_ecc_point point_2;
544
545 struct scatterlist *domain_a;
546 unsigned int domain_a_len; /* In bytes */
547
548 struct scatterlist *scalar;
549 unsigned int scalar_len; /* In bytes */
550
551 struct ccp_ecc_point result;
552};
553
554/**
555 * struct ccp_ecc_engine - CCP ECC operation
556 * @function: ECC function to perform
557 * @mod: ECC modulus
558 * @mod_len: length in bytes of modulus
559 * @mm: module math parameters
560 * @pm: point math parameters
561 * @ecc_result: result of the ECC operation
562 *
563 * Variables required to be set when calling ccp_enqueue_cmd():
564 * - function, mod, mod_len
565 * - operand, operand_len, operand_count, output, output_len, output_count
566 * - ecc_result
567 */
568struct ccp_ecc_engine {
569 enum ccp_ecc_function function;
570
571 struct scatterlist *mod;
572 u32 mod_len; /* In bytes */
573
574 union {
575 struct ccp_ecc_modular_math mm;
576 struct ccp_ecc_point_math pm;
577 } u;
578
579 u16 ecc_result;
580};
581
582
583/**
584 * ccp_engine - CCP operation identifiers
585 *
586 * @CCP_ENGINE_AES: AES operation
587 * @CCP_ENGINE_XTS_AES: 128-bit XTS AES operation
588 * @CCP_ENGINE_RSVD1: unused
589 * @CCP_ENGINE_SHA: SHA operation
590 * @CCP_ENGINE_RSA: RSA operation
591 * @CCP_ENGINE_PASSTHRU: pass-through operation
592 * @CCP_ENGINE_ZLIB_DECOMPRESS: unused
593 * @CCP_ENGINE_ECC: ECC operation
594 */
595enum ccp_engine {
596 CCP_ENGINE_AES = 0,
597 CCP_ENGINE_XTS_AES_128,
Gary R Hook990672d2017-03-15 13:20:52 -0500598 CCP_ENGINE_DES3,
Tom Lendacky63b94502013-11-12 11:46:16 -0600599 CCP_ENGINE_SHA,
600 CCP_ENGINE_RSA,
601 CCP_ENGINE_PASSTHRU,
602 CCP_ENGINE_ZLIB_DECOMPRESS,
603 CCP_ENGINE_ECC,
604 CCP_ENGINE__LAST,
605};
606
607/* Flag values for flags member of ccp_cmd */
Gary R Hook58ea8ab2016-04-18 09:21:44 -0500608#define CCP_CMD_MAY_BACKLOG 0x00000001
609#define CCP_CMD_PASSTHRU_NO_DMA_MAP 0x00000002
Tom Lendacky63b94502013-11-12 11:46:16 -0600610
611/**
Paul Bollec8d283ff2016-10-20 21:20:59 +0200612 * struct ccp_cmd - CCP operation request
Tom Lendacky63b94502013-11-12 11:46:16 -0600613 * @entry: list element (ccp driver use only)
614 * @work: work element used for callbacks (ccp driver use only)
615 * @ccp: CCP device to be run on (ccp driver use only)
616 * @ret: operation return code (ccp driver use only)
617 * @flags: cmd processing flags
618 * @engine: CCP operation to perform
619 * @engine_error: CCP engine return code
620 * @u: engine specific structures, refer to specific engine struct below
621 * @callback: operation completion callback function
622 * @data: parameter value to be supplied to the callback function
623 *
624 * Variables required to be set when calling ccp_enqueue_cmd():
625 * - engine, callback
626 * - See the operation structures below for what is required for each
627 * operation.
628 */
629struct ccp_cmd {
630 /* The list_head, work_struct, ccp and ret variables are for use
631 * by the CCP driver only.
632 */
633 struct list_head entry;
634 struct work_struct work;
635 struct ccp_device *ccp;
636 int ret;
637
638 u32 flags;
639
640 enum ccp_engine engine;
641 u32 engine_error;
642
643 union {
644 struct ccp_aes_engine aes;
645 struct ccp_xts_aes_engine xts;
Gary R Hook990672d2017-03-15 13:20:52 -0500646 struct ccp_des3_engine des3;
Tom Lendacky63b94502013-11-12 11:46:16 -0600647 struct ccp_sha_engine sha;
648 struct ccp_rsa_engine rsa;
649 struct ccp_passthru_engine passthru;
Gary R Hook58ea8ab2016-04-18 09:21:44 -0500650 struct ccp_passthru_nomap_engine passthru_nomap;
Tom Lendacky63b94502013-11-12 11:46:16 -0600651 struct ccp_ecc_engine ecc;
652 } u;
653
654 /* Completion callback support */
655 void (*callback)(void *data, int err);
656 void *data;
657};
658
659#endif