crypto: ccp - Register the CCP as a DMA resource
Subsystems (2)
PATCH v2 1/1 crypto: ccp - Register the CCP as a DMA resource
The CCP has the ability to provide DMA services to the kernel using pass-through mode of the device. Register these services as general purpose DMA channels.
--- drivers/crypto/ccp/Kconfig | 1 drivers/crypto/ccp/Makefile | 6 drivers/crypto/ccp/ccp-dev-v3.c | 11 + drivers/crypto/ccp/ccp-dev.h | 47 ++ drivers/crypto/ccp/ccp-dmaengine.c | 727 ++++++++++++++++++++++++++++++++++++ drivers/crypto/ccp/ccp-ops.c | 69 +++ include/linux/ccp.h | 36 ++ 7 files changed, 893 insertions(+), 4 deletions(-) create mode 100644 drivers/crypto/ccp/ccp-dmaengine.c
drivers/crypto/ccp/Kconfig +1 -0
@@ -3,6 +3,7 @@ config CRYPTO_DEV_CCP_DD depends on CRYPTO_DEV_CCP default m select HW_RANDOM + select DMA_ENGINE select CRYPTO_SHA1 select CRYPTO_SHA256 help
drivers/crypto/ccp/Makefile +5 -1
@@ -1,5 +1,9 @@ obj-$(CONFIG_CRYPTO_DEV_CCP_DD) += ccp.o -ccp-objs := ccp-dev.o ccp-ops.o ccp-dev-v3.o ccp-platform.o +ccp-objs := ccp-dev.o \ + ccp-ops.o \ + ccp-dev-v3.o \ + ccp-platform.o \ + ccp-dmaengine.o ccp-$(CONFIG_PCI) += ccp-pci.o obj-$(CONFIG_CRYPTO_DEV_CCP_CRYPTO) += ccp-crypto.o
drivers/crypto/ccp/ccp-dev-v3.c +11 -0
@@ -406,6 +406,11 @@ static int ccp_init(struct ccp_device *ccp) goto e_kthread; } +/* Register the DMA engine support */ + ret =ccp_dmaengine_register (ccp); +if (ret) + goto e_hwrng; +ccp_add_device (ccp);/* Enable interrupts */
@@ -413,6 +418,9 @@ static int ccp_init(struct ccp_device *ccp)return 0 ; +e_hwrng: +hwrng_unregister (&ccp->hwrng); + e_kthread:for (i =0 ; i < ccp->cmd_q_count; i++)if (ccp->cmd_q[i].kthread)
@@ -436,6 +444,9 @@ static void ccp_destroy(struct ccp_device *ccp)/* Remove this device from the list of available units first */ ccp_del_device (ccp); +/* Unregister the DMA engine */ +ccp_dmaengine_unregister (ccp); +/* Unregister the RNG */ hwrng_unregister (&ccp->hwrng);
drivers/crypto/ccp/ccp-dev.h +47 -0
69 lines not on this page · raw message
drivers/crypto/ccp/ccp-dmaengine.c new file +727 -0
727 lines not on this page · raw message
drivers/crypto/ccp/ccp-ops.c +68 -1
81 lines not on this page · raw message
include/linux/ccp.h +34 -2
@@ -1,9 +1,10 @@/* * AMD Cryptographic Coprocessor (CCP) driver * -* Copyright (C) 2013 Advanced Micro Devices, Inc. +* Copyright (C) 2013,2016 Advanced Micro Devices, Inc. * * Author: Tom Lendacky <[email protected]> +* Author: Gary R Hook <[email protected]> * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as
@@ -381,6 +382,35 @@ struct ccp_passthru_engine {u32 final; }; +/** +* struct ccp_passthru_nomap_engine - CCP pass-through operation +* without performing DMA mapping +* @bit_mod: bitwise operation to perform +* @byte_swap: byteswap operation to perform +* @mask: mask to be applied to data +* @mask_len: length in bytes of mask +* @src: data to be used for this operation +* @dst: data produced by this operation +* @src_len: length in bytes of data used for this operation +* @final: indicate final pass-through operation +* +* Variables required to be set when calling ccp_enqueue_cmd(): +* - bit_mod, byte_swap, src, dst, src_len +* - mask, mask_len if bit_mod is not CCP_PASSTHRU_BITWISE_NOOP +*/ +struct ccp_passthru_nomap_engine { +enum ccp_passthru_bitwise bit_mod; +enum ccp_passthru_byteswap byte_swap; + +dma_addr_t mask; +u32 mask_len;/* In bytes */ + +dma_addr_t src_dma, dst_dma; +u64 src_len;/* In bytes */ + +u32 final; +}; +/***** ECC engine *****/ #define CCP_ECC_MODULUS_BYTES 48/* 384-bits */ #define CCP_ECC_MAX_OPERANDS 6
@@ -522,7 +552,8 @@ enum ccp_engine { };/* Flag values for flags member of ccp_cmd */ -#define CCP_CMD_MAY_BACKLOG 0x00000001 +#define CCP_CMD_MAY_BACKLOG 0x00000001 +#define CCP_CMD_PASSTHRU_NO_DMA_MAP 0x00000002/** * struct ccp_cmd - CPP operation request
@@ -562,6 +593,7 @@ struct ccp_cmd {struct ccp_sha_engine sha;struct ccp_rsa_engine rsa;struct ccp_passthru_engine passthru; +struct ccp_passthru_nomap_engine passthru_nomap;struct ccp_ecc_engine ecc; } u;
Herbert Xu
maintainerQuoted 3 lines · Gary R Hook
The CCP has the ability to provide DMA services to the kernel using pass-through mode of the device. Register these services as general purpose DMA channels.
You forgot the Signed-off-by.
Signature · 3 lines
Email: Herbert Xu <[email protected]> Home Page: http://gondor.apana.org.au/~herbert/ PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt