Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0-only */
0002 /*
0003  * AMD Cryptographic Coprocessor (CCP) driver
0004  *
0005  * Copyright (C) 2013,2017 Advanced Micro Devices, Inc.
0006  *
0007  * Author: Tom Lendacky <thomas.lendacky@amd.com>
0008  * Author: Gary R Hook <gary.hook@amd.com>
0009  */
0010 
0011 #ifndef __CCP_H__
0012 #define __CCP_H__
0013 
0014 #include <linux/scatterlist.h>
0015 #include <linux/workqueue.h>
0016 #include <linux/list.h>
0017 #include <crypto/aes.h>
0018 #include <crypto/sha1.h>
0019 #include <crypto/sha2.h>
0020 
0021 struct ccp_device;
0022 struct ccp_cmd;
0023 
0024 #if defined(CONFIG_CRYPTO_DEV_SP_CCP)
0025 
0026 /**
0027  * ccp_present - check if a CCP device is present
0028  *
0029  * Returns zero if a CCP device is present, -ENODEV otherwise.
0030  */
0031 int ccp_present(void);
0032 
0033 #define CCP_VSIZE 16
0034 #define CCP_VMASK       ((unsigned int)((1 << CCP_VSIZE) - 1))
0035 #define CCP_VERSION(v, r)   ((unsigned int)((v << CCP_VSIZE) \
0036                            | (r & CCP_VMASK)))
0037 
0038 /**
0039  * ccp_version - get the version of the CCP
0040  *
0041  * Returns a positive version number, or zero if no CCP
0042  */
0043 unsigned int ccp_version(void);
0044 
0045 /**
0046  * ccp_enqueue_cmd - queue an operation for processing by the CCP
0047  *
0048  * @cmd: ccp_cmd struct to be processed
0049  *
0050  * Refer to the ccp_cmd struct below for required fields.
0051  *
0052  * Queue a cmd to be processed by the CCP. If queueing the cmd
0053  * would exceed the defined length of the cmd queue the cmd will
0054  * only be queued if the CCP_CMD_MAY_BACKLOG flag is set and will
0055  * result in a return code of -EBUSY.
0056  *
0057  * The callback routine specified in the ccp_cmd struct will be
0058  * called to notify the caller of completion (if the cmd was not
0059  * backlogged) or advancement out of the backlog. If the cmd has
0060  * advanced out of the backlog the "err" value of the callback
0061  * will be -EINPROGRESS. Any other "err" value during callback is
0062  * the result of the operation.
0063  *
0064  * The cmd has been successfully queued if:
0065  *   the return code is -EINPROGRESS or
0066  *   the return code is -EBUSY and CCP_CMD_MAY_BACKLOG flag is set
0067  */
0068 int ccp_enqueue_cmd(struct ccp_cmd *cmd);
0069 
0070 #else /* CONFIG_CRYPTO_DEV_CCP_SP_DEV is not enabled */
0071 
0072 static inline int ccp_present(void)
0073 {
0074     return -ENODEV;
0075 }
0076 
0077 static inline unsigned int ccp_version(void)
0078 {
0079     return 0;
0080 }
0081 
0082 static inline int ccp_enqueue_cmd(struct ccp_cmd *cmd)
0083 {
0084     return -ENODEV;
0085 }
0086 
0087 #endif /* CONFIG_CRYPTO_DEV_SP_CCP */
0088 
0089 
0090 /***** AES engine *****/
0091 /**
0092  * ccp_aes_type - AES key size
0093  *
0094  * @CCP_AES_TYPE_128: 128-bit key
0095  * @CCP_AES_TYPE_192: 192-bit key
0096  * @CCP_AES_TYPE_256: 256-bit key
0097  */
0098 enum ccp_aes_type {
0099     CCP_AES_TYPE_128 = 0,
0100     CCP_AES_TYPE_192,
0101     CCP_AES_TYPE_256,
0102     CCP_AES_TYPE__LAST,
0103 };
0104 
0105 /**
0106  * ccp_aes_mode - AES operation mode
0107  *
0108  * @CCP_AES_MODE_ECB: ECB mode
0109  * @CCP_AES_MODE_CBC: CBC mode
0110  * @CCP_AES_MODE_OFB: OFB mode
0111  * @CCP_AES_MODE_CFB: CFB mode
0112  * @CCP_AES_MODE_CTR: CTR mode
0113  * @CCP_AES_MODE_CMAC: CMAC mode
0114  */
0115 enum ccp_aes_mode {
0116     CCP_AES_MODE_ECB = 0,
0117     CCP_AES_MODE_CBC,
0118     CCP_AES_MODE_OFB,
0119     CCP_AES_MODE_CFB,
0120     CCP_AES_MODE_CTR,
0121     CCP_AES_MODE_CMAC,
0122     CCP_AES_MODE_GHASH,
0123     CCP_AES_MODE_GCTR,
0124     CCP_AES_MODE_GCM,
0125     CCP_AES_MODE_GMAC,
0126     CCP_AES_MODE__LAST,
0127 };
0128 
0129 /**
0130  * ccp_aes_mode - AES operation mode
0131  *
0132  * @CCP_AES_ACTION_DECRYPT: AES decrypt operation
0133  * @CCP_AES_ACTION_ENCRYPT: AES encrypt operation
0134  */
0135 enum ccp_aes_action {
0136     CCP_AES_ACTION_DECRYPT = 0,
0137     CCP_AES_ACTION_ENCRYPT,
0138     CCP_AES_ACTION__LAST,
0139 };
0140 /* Overloaded field */
0141 #define CCP_AES_GHASHAAD    CCP_AES_ACTION_DECRYPT
0142 #define CCP_AES_GHASHFINAL  CCP_AES_ACTION_ENCRYPT
0143 
0144 /**
0145  * struct ccp_aes_engine - CCP AES operation
0146  * @type: AES operation key size
0147  * @mode: AES operation mode
0148  * @action: AES operation (decrypt/encrypt)
0149  * @key: key to be used for this AES operation
0150  * @key_len: length in bytes of key
0151  * @iv: IV to be used for this AES operation
0152  * @iv_len: length in bytes of iv
0153  * @src: data to be used for this operation
0154  * @dst: data produced by this operation
0155  * @src_len: length in bytes of data used for this operation
0156  * @cmac_final: indicates final operation when running in CMAC mode
0157  * @cmac_key: K1/K2 key used in final CMAC operation
0158  * @cmac_key_len: length in bytes of cmac_key
0159  *
0160  * Variables required to be set when calling ccp_enqueue_cmd():
0161  *   - type, mode, action, key, key_len, src, dst, src_len
0162  *   - iv, iv_len for any mode other than ECB
0163  *   - cmac_final for CMAC mode
0164  *   - cmac_key, cmac_key_len for CMAC mode if cmac_final is non-zero
0165  *
0166  * The iv variable is used as both input and output. On completion of the
0167  * AES operation the new IV overwrites the old IV.
0168  */
0169 struct ccp_aes_engine {
0170     enum ccp_aes_type type;
0171     enum ccp_aes_mode mode;
0172     enum ccp_aes_action action;
0173 
0174     u32 authsize;
0175 
0176     struct scatterlist *key;
0177     u32 key_len;        /* In bytes */
0178 
0179     struct scatterlist *iv;
0180     u32 iv_len;     /* In bytes */
0181 
0182     struct scatterlist *src, *dst;
0183     u64 src_len;        /* In bytes */
0184 
0185     u32 cmac_final;     /* Indicates final cmac cmd */
0186     struct scatterlist *cmac_key;   /* K1/K2 cmac key required for
0187                      * final cmac cmd */
0188     u32 cmac_key_len;   /* In bytes */
0189 
0190     u32 aad_len;        /* In bytes */
0191 };
0192 
0193 /***** XTS-AES engine *****/
0194 /**
0195  * ccp_xts_aes_unit_size - XTS unit size
0196  *
0197  * @CCP_XTS_AES_UNIT_SIZE_16: Unit size of 16 bytes
0198  * @CCP_XTS_AES_UNIT_SIZE_512: Unit size of 512 bytes
0199  * @CCP_XTS_AES_UNIT_SIZE_1024: Unit size of 1024 bytes
0200  * @CCP_XTS_AES_UNIT_SIZE_2048: Unit size of 2048 bytes
0201  * @CCP_XTS_AES_UNIT_SIZE_4096: Unit size of 4096 bytes
0202  */
0203 enum ccp_xts_aes_unit_size {
0204     CCP_XTS_AES_UNIT_SIZE_16 = 0,
0205     CCP_XTS_AES_UNIT_SIZE_512,
0206     CCP_XTS_AES_UNIT_SIZE_1024,
0207     CCP_XTS_AES_UNIT_SIZE_2048,
0208     CCP_XTS_AES_UNIT_SIZE_4096,
0209     CCP_XTS_AES_UNIT_SIZE__LAST,
0210 };
0211 
0212 /**
0213  * struct ccp_xts_aes_engine - CCP XTS AES operation
0214  * @action: AES operation (decrypt/encrypt)
0215  * @unit_size: unit size of the XTS operation
0216  * @key: key to be used for this XTS AES operation
0217  * @key_len: length in bytes of key
0218  * @iv: IV to be used for this XTS AES operation
0219  * @iv_len: length in bytes of iv
0220  * @src: data to be used for this operation
0221  * @dst: data produced by this operation
0222  * @src_len: length in bytes of data used for this operation
0223  * @final: indicates final XTS operation
0224  *
0225  * Variables required to be set when calling ccp_enqueue_cmd():
0226  *   - action, unit_size, key, key_len, iv, iv_len, src, dst, src_len, final
0227  *
0228  * The iv variable is used as both input and output. On completion of the
0229  * AES operation the new IV overwrites the old IV.
0230  */
0231 struct ccp_xts_aes_engine {
0232     enum ccp_aes_type type;
0233     enum ccp_aes_action action;
0234     enum ccp_xts_aes_unit_size unit_size;
0235 
0236     struct scatterlist *key;
0237     u32 key_len;        /* In bytes */
0238 
0239     struct scatterlist *iv;
0240     u32 iv_len;     /* In bytes */
0241 
0242     struct scatterlist *src, *dst;
0243     u64 src_len;        /* In bytes */
0244 
0245     u32 final;
0246 };
0247 
0248 /***** SHA engine *****/
0249 /**
0250  * ccp_sha_type - type of SHA operation
0251  *
0252  * @CCP_SHA_TYPE_1: SHA-1 operation
0253  * @CCP_SHA_TYPE_224: SHA-224 operation
0254  * @CCP_SHA_TYPE_256: SHA-256 operation
0255  */
0256 enum ccp_sha_type {
0257     CCP_SHA_TYPE_1 = 1,
0258     CCP_SHA_TYPE_224,
0259     CCP_SHA_TYPE_256,
0260     CCP_SHA_TYPE_384,
0261     CCP_SHA_TYPE_512,
0262     CCP_SHA_TYPE__LAST,
0263 };
0264 
0265 /**
0266  * struct ccp_sha_engine - CCP SHA operation
0267  * @type: Type of SHA operation
0268  * @ctx: current hash value
0269  * @ctx_len: length in bytes of hash value
0270  * @src: data to be used for this operation
0271  * @src_len: length in bytes of data used for this operation
0272  * @opad: data to be used for final HMAC operation
0273  * @opad_len: length in bytes of data used for final HMAC operation
0274  * @first: indicates first SHA operation
0275  * @final: indicates final SHA operation
0276  * @msg_bits: total length of the message in bits used in final SHA operation
0277  *
0278  * Variables required to be set when calling ccp_enqueue_cmd():
0279  *   - type, ctx, ctx_len, src, src_len, final
0280  *   - msg_bits if final is non-zero
0281  *
0282  * The ctx variable is used as both input and output. On completion of the
0283  * SHA operation the new hash value overwrites the old hash value.
0284  */
0285 struct ccp_sha_engine {
0286     enum ccp_sha_type type;
0287 
0288     struct scatterlist *ctx;
0289     u32 ctx_len;        /* In bytes */
0290 
0291     struct scatterlist *src;
0292     u64 src_len;        /* In bytes */
0293 
0294     struct scatterlist *opad;
0295     u32 opad_len;       /* In bytes */
0296 
0297     u32 first;      /* Indicates first sha cmd */
0298     u32 final;      /* Indicates final sha cmd */
0299     u64 msg_bits;       /* Message length in bits required for
0300                  * final sha cmd */
0301 };
0302 
0303 /***** 3DES engine *****/
0304 enum ccp_des3_mode {
0305     CCP_DES3_MODE_ECB = 0,
0306     CCP_DES3_MODE_CBC,
0307     CCP_DES3_MODE_CFB,
0308     CCP_DES3_MODE__LAST,
0309 };
0310 
0311 enum ccp_des3_type {
0312     CCP_DES3_TYPE_168 = 1,
0313     CCP_DES3_TYPE__LAST,
0314     };
0315 
0316 enum ccp_des3_action {
0317     CCP_DES3_ACTION_DECRYPT = 0,
0318     CCP_DES3_ACTION_ENCRYPT,
0319     CCP_DES3_ACTION__LAST,
0320 };
0321 
0322 /**
0323  * struct ccp_des3_engine - CCP SHA operation
0324  * @type: Type of 3DES operation
0325  * @mode: cipher mode
0326  * @action: 3DES operation (decrypt/encrypt)
0327  * @key: key to be used for this 3DES operation
0328  * @key_len: length of key (in bytes)
0329  * @iv: IV to be used for this AES operation
0330  * @iv_len: length in bytes of iv
0331  * @src: input data to be used for this operation
0332  * @src_len: length of input data used for this operation (in bytes)
0333  * @dst: output data produced by this operation
0334  *
0335  * Variables required to be set when calling ccp_enqueue_cmd():
0336  *   - type, mode, action, key, key_len, src, dst, src_len
0337  *   - iv, iv_len for any mode other than ECB
0338  *
0339  * The iv variable is used as both input and output. On completion of the
0340  * 3DES operation the new IV overwrites the old IV.
0341  */
0342 struct ccp_des3_engine {
0343     enum ccp_des3_type type;
0344     enum ccp_des3_mode mode;
0345     enum ccp_des3_action action;
0346 
0347     struct scatterlist *key;
0348     u32 key_len;        /* In bytes */
0349 
0350     struct scatterlist *iv;
0351     u32 iv_len;      /* In bytes */
0352 
0353     struct scatterlist *src, *dst;
0354     u64 src_len;        /* In bytes */
0355 };
0356 
0357 /***** RSA engine *****/
0358 /**
0359  * struct ccp_rsa_engine - CCP RSA operation
0360  * @key_size: length in bits of RSA key
0361  * @exp: RSA exponent
0362  * @exp_len: length in bytes of exponent
0363  * @mod: RSA modulus
0364  * @mod_len: length in bytes of modulus
0365  * @src: data to be used for this operation
0366  * @dst: data produced by this operation
0367  * @src_len: length in bytes of data used for this operation
0368  *
0369  * Variables required to be set when calling ccp_enqueue_cmd():
0370  *   - key_size, exp, exp_len, mod, mod_len, src, dst, src_len
0371  */
0372 struct ccp_rsa_engine {
0373     u32 key_size;       /* In bits */
0374 
0375     struct scatterlist *exp;
0376     u32 exp_len;        /* In bytes */
0377 
0378     struct scatterlist *mod;
0379     u32 mod_len;        /* In bytes */
0380 
0381     struct scatterlist *src, *dst;
0382     u32 src_len;        /* In bytes */
0383 };
0384 
0385 /***** Passthru engine *****/
0386 /**
0387  * ccp_passthru_bitwise - type of bitwise passthru operation
0388  *
0389  * @CCP_PASSTHRU_BITWISE_NOOP: no bitwise operation performed
0390  * @CCP_PASSTHRU_BITWISE_AND: perform bitwise AND of src with mask
0391  * @CCP_PASSTHRU_BITWISE_OR: perform bitwise OR of src with mask
0392  * @CCP_PASSTHRU_BITWISE_XOR: perform bitwise XOR of src with mask
0393  * @CCP_PASSTHRU_BITWISE_MASK: overwrite with mask
0394  */
0395 enum ccp_passthru_bitwise {
0396     CCP_PASSTHRU_BITWISE_NOOP = 0,
0397     CCP_PASSTHRU_BITWISE_AND,
0398     CCP_PASSTHRU_BITWISE_OR,
0399     CCP_PASSTHRU_BITWISE_XOR,
0400     CCP_PASSTHRU_BITWISE_MASK,
0401     CCP_PASSTHRU_BITWISE__LAST,
0402 };
0403 
0404 /**
0405  * ccp_passthru_byteswap - type of byteswap passthru operation
0406  *
0407  * @CCP_PASSTHRU_BYTESWAP_NOOP: no byte swapping performed
0408  * @CCP_PASSTHRU_BYTESWAP_32BIT: swap bytes within 32-bit words
0409  * @CCP_PASSTHRU_BYTESWAP_256BIT: swap bytes within 256-bit words
0410  */
0411 enum ccp_passthru_byteswap {
0412     CCP_PASSTHRU_BYTESWAP_NOOP = 0,
0413     CCP_PASSTHRU_BYTESWAP_32BIT,
0414     CCP_PASSTHRU_BYTESWAP_256BIT,
0415     CCP_PASSTHRU_BYTESWAP__LAST,
0416 };
0417 
0418 /**
0419  * struct ccp_passthru_engine - CCP pass-through operation
0420  * @bit_mod: bitwise operation to perform
0421  * @byte_swap: byteswap operation to perform
0422  * @mask: mask to be applied to data
0423  * @mask_len: length in bytes of mask
0424  * @src: data to be used for this operation
0425  * @dst: data produced by this operation
0426  * @src_len: length in bytes of data used for this operation
0427  * @final: indicate final pass-through operation
0428  *
0429  * Variables required to be set when calling ccp_enqueue_cmd():
0430  *   - bit_mod, byte_swap, src, dst, src_len
0431  *   - mask, mask_len if bit_mod is not CCP_PASSTHRU_BITWISE_NOOP
0432  */
0433 struct ccp_passthru_engine {
0434     enum ccp_passthru_bitwise bit_mod;
0435     enum ccp_passthru_byteswap byte_swap;
0436 
0437     struct scatterlist *mask;
0438     u32 mask_len;       /* In bytes */
0439 
0440     struct scatterlist *src, *dst;
0441     u64 src_len;        /* In bytes */
0442 
0443     u32 final;
0444 };
0445 
0446 /**
0447  * struct ccp_passthru_nomap_engine - CCP pass-through operation
0448  *   without performing DMA mapping
0449  * @bit_mod: bitwise operation to perform
0450  * @byte_swap: byteswap operation to perform
0451  * @mask: mask to be applied to data
0452  * @mask_len: length in bytes of mask
0453  * @src: data to be used for this operation
0454  * @dst: data produced by this operation
0455  * @src_len: length in bytes of data used for this operation
0456  * @final: indicate final pass-through operation
0457  *
0458  * Variables required to be set when calling ccp_enqueue_cmd():
0459  *   - bit_mod, byte_swap, src, dst, src_len
0460  *   - mask, mask_len if bit_mod is not CCP_PASSTHRU_BITWISE_NOOP
0461  */
0462 struct ccp_passthru_nomap_engine {
0463     enum ccp_passthru_bitwise bit_mod;
0464     enum ccp_passthru_byteswap byte_swap;
0465 
0466     dma_addr_t mask;
0467     u32 mask_len;       /* In bytes */
0468 
0469     dma_addr_t src_dma, dst_dma;
0470     u64 src_len;        /* In bytes */
0471 
0472     u32 final;
0473 };
0474 
0475 /***** ECC engine *****/
0476 #define CCP_ECC_MODULUS_BYTES   48  /* 384-bits */
0477 #define CCP_ECC_MAX_OPERANDS    6
0478 #define CCP_ECC_MAX_OUTPUTS 3
0479 
0480 /**
0481  * ccp_ecc_function - type of ECC function
0482  *
0483  * @CCP_ECC_FUNCTION_MMUL_384BIT: 384-bit modular multiplication
0484  * @CCP_ECC_FUNCTION_MADD_384BIT: 384-bit modular addition
0485  * @CCP_ECC_FUNCTION_MINV_384BIT: 384-bit multiplicative inverse
0486  * @CCP_ECC_FUNCTION_PADD_384BIT: 384-bit point addition
0487  * @CCP_ECC_FUNCTION_PMUL_384BIT: 384-bit point multiplication
0488  * @CCP_ECC_FUNCTION_PDBL_384BIT: 384-bit point doubling
0489  */
0490 enum ccp_ecc_function {
0491     CCP_ECC_FUNCTION_MMUL_384BIT = 0,
0492     CCP_ECC_FUNCTION_MADD_384BIT,
0493     CCP_ECC_FUNCTION_MINV_384BIT,
0494     CCP_ECC_FUNCTION_PADD_384BIT,
0495     CCP_ECC_FUNCTION_PMUL_384BIT,
0496     CCP_ECC_FUNCTION_PDBL_384BIT,
0497 };
0498 
0499 /**
0500  * struct ccp_ecc_modular_math - CCP ECC modular math parameters
0501  * @operand_1: first operand for the modular math operation
0502  * @operand_1_len: length of the first operand
0503  * @operand_2: second operand for the modular math operation
0504  *         (not used for CCP_ECC_FUNCTION_MINV_384BIT)
0505  * @operand_2_len: length of the second operand
0506  *         (not used for CCP_ECC_FUNCTION_MINV_384BIT)
0507  * @result: result of the modular math operation
0508  * @result_len: length of the supplied result buffer
0509  */
0510 struct ccp_ecc_modular_math {
0511     struct scatterlist *operand_1;
0512     unsigned int operand_1_len; /* In bytes */
0513 
0514     struct scatterlist *operand_2;
0515     unsigned int operand_2_len; /* In bytes */
0516 
0517     struct scatterlist *result;
0518     unsigned int result_len;    /* In bytes */
0519 };
0520 
0521 /**
0522  * struct ccp_ecc_point - CCP ECC point definition
0523  * @x: the x coordinate of the ECC point
0524  * @x_len: the length of the x coordinate
0525  * @y: the y coordinate of the ECC point
0526  * @y_len: the length of the y coordinate
0527  */
0528 struct ccp_ecc_point {
0529     struct scatterlist *x;
0530     unsigned int x_len; /* In bytes */
0531 
0532     struct scatterlist *y;
0533     unsigned int y_len; /* In bytes */
0534 };
0535 
0536 /**
0537  * struct ccp_ecc_point_math - CCP ECC point math parameters
0538  * @point_1: the first point of the ECC point math operation
0539  * @point_2: the second point of the ECC point math operation
0540  *       (only used for CCP_ECC_FUNCTION_PADD_384BIT)
0541  * @domain_a: the a parameter of the ECC curve
0542  * @domain_a_len: the length of the a parameter
0543  * @scalar: the scalar parameter for the point match operation
0544  *      (only used for CCP_ECC_FUNCTION_PMUL_384BIT)
0545  * @scalar_len: the length of the scalar parameter
0546  *      (only used for CCP_ECC_FUNCTION_PMUL_384BIT)
0547  * @result: the point resulting from the point math operation
0548  */
0549 struct ccp_ecc_point_math {
0550     struct ccp_ecc_point point_1;
0551     struct ccp_ecc_point point_2;
0552 
0553     struct scatterlist *domain_a;
0554     unsigned int domain_a_len;  /* In bytes */
0555 
0556     struct scatterlist *scalar;
0557     unsigned int scalar_len;    /* In bytes */
0558 
0559     struct ccp_ecc_point result;
0560 };
0561 
0562 /**
0563  * struct ccp_ecc_engine - CCP ECC operation
0564  * @function: ECC function to perform
0565  * @mod: ECC modulus
0566  * @mod_len: length in bytes of modulus
0567  * @mm: module math parameters
0568  * @pm: point math parameters
0569  * @ecc_result: result of the ECC operation
0570  *
0571  * Variables required to be set when calling ccp_enqueue_cmd():
0572  *   - function, mod, mod_len
0573  *   - operand, operand_len, operand_count, output, output_len, output_count
0574  *   - ecc_result
0575  */
0576 struct ccp_ecc_engine {
0577     enum ccp_ecc_function function;
0578 
0579     struct scatterlist *mod;
0580     u32 mod_len;        /* In bytes */
0581 
0582     union {
0583         struct ccp_ecc_modular_math mm;
0584         struct ccp_ecc_point_math pm;
0585     } u;
0586 
0587     u16 ecc_result;
0588 };
0589 
0590 
0591 /**
0592  * ccp_engine - CCP operation identifiers
0593  *
0594  * @CCP_ENGINE_AES: AES operation
0595  * @CCP_ENGINE_XTS_AES: 128-bit XTS AES operation
0596  * @CCP_ENGINE_RSVD1: unused
0597  * @CCP_ENGINE_SHA: SHA operation
0598  * @CCP_ENGINE_RSA: RSA operation
0599  * @CCP_ENGINE_PASSTHRU: pass-through operation
0600  * @CCP_ENGINE_ZLIB_DECOMPRESS: unused
0601  * @CCP_ENGINE_ECC: ECC operation
0602  */
0603 enum ccp_engine {
0604     CCP_ENGINE_AES = 0,
0605     CCP_ENGINE_XTS_AES_128,
0606     CCP_ENGINE_DES3,
0607     CCP_ENGINE_SHA,
0608     CCP_ENGINE_RSA,
0609     CCP_ENGINE_PASSTHRU,
0610     CCP_ENGINE_ZLIB_DECOMPRESS,
0611     CCP_ENGINE_ECC,
0612     CCP_ENGINE__LAST,
0613 };
0614 
0615 /* Flag values for flags member of ccp_cmd */
0616 #define CCP_CMD_MAY_BACKLOG     0x00000001
0617 #define CCP_CMD_PASSTHRU_NO_DMA_MAP 0x00000002
0618 
0619 /**
0620  * struct ccp_cmd - CCP operation request
0621  * @entry: list element (ccp driver use only)
0622  * @work: work element used for callbacks (ccp driver use only)
0623  * @ccp: CCP device to be run on
0624  * @ret: operation return code (ccp driver use only)
0625  * @flags: cmd processing flags
0626  * @engine: CCP operation to perform
0627  * @engine_error: CCP engine return code
0628  * @u: engine specific structures, refer to specific engine struct below
0629  * @callback: operation completion callback function
0630  * @data: parameter value to be supplied to the callback function
0631  *
0632  * Variables required to be set when calling ccp_enqueue_cmd():
0633  *   - engine, callback
0634  *   - See the operation structures below for what is required for each
0635  *     operation.
0636  */
0637 struct ccp_cmd {
0638     /* The list_head, work_struct, ccp and ret variables are for use
0639      * by the CCP driver only.
0640      */
0641     struct list_head entry;
0642     struct work_struct work;
0643     struct ccp_device *ccp;
0644     int ret;
0645 
0646     u32 flags;
0647 
0648     enum ccp_engine engine;
0649     u32 engine_error;
0650 
0651     union {
0652         struct ccp_aes_engine aes;
0653         struct ccp_xts_aes_engine xts;
0654         struct ccp_des3_engine des3;
0655         struct ccp_sha_engine sha;
0656         struct ccp_rsa_engine rsa;
0657         struct ccp_passthru_engine passthru;
0658         struct ccp_passthru_nomap_engine passthru_nomap;
0659         struct ccp_ecc_engine ecc;
0660     } u;
0661 
0662     /* Completion callback support */
0663     void (*callback)(void *data, int err);
0664     void *data;
0665 };
0666 
0667 #endif