crypto: ccp - Add debugfs entries for CCP information
Subsystems (2)
PATCH 1/1 crypto: ccp - Add debugfs entries for CCP information
Expose some data about the configuration and operation of the CCP through debugfs entries: device name, capabilities, configuration, statistics.
Allow the user to reset the counters to zero by writing (any value) to the 'stats' file. This can be done per queue or per device.
Signed-off-by Gary R Hook <[email protected]>
--- drivers/crypto/ccp/Makefile | 3 drivers/crypto/ccp/ccp-debugfs.c | 345 ++++++++++++++++++++++++++++++++++++++ drivers/crypto/ccp/ccp-dev-v5.c | 28 +++ drivers/crypto/ccp/ccp-dev.c | 2 drivers/crypto/ccp/ccp-dev.h | 20 ++ 5 files changed, 395 insertions(+), 3 deletions(-) create mode 100644 drivers/crypto/ccp/ccp-debugfs.c
drivers/crypto/ccp/Makefile +2 -1
@@ -4,7 +4,8 @@ ccp-objs := ccp-dev.o \ ccp-dev-v3.o \ ccp-dev-v5.o \ ccp-platform.o \ - ccp-dmaengine.o + ccp-dmaengine.o \ + ccp-debugfs.o ccp-$(CONFIG_PCI) += ccp-pci.o obj-$(CONFIG_CRYPTO_DEV_CCP_CRYPTO) += ccp-crypto.o
drivers/crypto/ccp/ccp-debugfs.c new file +345 -0
345 lines not on this page · raw message
drivers/crypto/ccp/ccp-dev-v5.c +27 -1
@@ -14,6 +14,7 @@#include <linux/kernel.h> #include <linux/pci.h> #include <linux/kthread.h> +#include <linux/debugfs.h> #include <linux/dma-mapping.h> #include <linux/interrupt.h> #include <linux/compiler.h>
@@ -231,6 +232,8 @@ static int ccp5_do_cmd(struct ccp5_desc *desc,int i;int ret =0 ; + cmd_q->total_ops++; +if (CCP5_CMD_SOC (desc)) {CCP5_CMD_IOC (desc) =1 ;CCP5_CMD_SOC (desc) =0 ;
@@ -282,6 +285,8 @@ static int ccp5_perform_aes(struct ccp_op *op)union ccp_function function;u32 key_addr = op->sb_key *LSB_ITEM_SIZE ; + op->cmd_q->total_aes_ops++; +/* Zero out all the fields of the command desc */ memset (&desc,0 ,Q_DESC_SIZE );
@@ -325,6 +330,8 @@ static int ccp5_perform_xts_aes(struct ccp_op *op)union ccp_function function;u32 key_addr = op->sb_key *LSB_ITEM_SIZE ; + op->cmd_q->total_xts_aes_ops++; +/* Zero out all the fields of the command desc */ memset (&desc,0 ,Q_DESC_SIZE );
@@ -364,6 +371,8 @@ static int ccp5_perform_sha(struct ccp_op *op)struct ccp5_desc desc;union ccp_function function; + op->cmd_q->total_sha_ops++; +/* Zero out all the fields of the command desc */ memset (&desc,0 ,Q_DESC_SIZE );
@@ -404,6 +413,8 @@ static int ccp5_perform_des3(struct ccp_op *op)union ccp_function function;u32 key_addr = op->sb_key *LSB_ITEM_SIZE ; + op->cmd_q->total_3des_ops++; +/* Zero out all the fields of the command desc */ memset (&desc,0 ,sizeof (struct ccp5_desc ));
@@ -444,6 +455,8 @@ static int ccp5_perform_rsa(struct ccp_op *op)struct ccp5_desc desc;union ccp_function function; + op->cmd_q->total_rsa_ops++; +/* Zero out all the fields of the command desc */ memset (&desc,0 ,Q_DESC_SIZE );
@@ -487,6 +500,8 @@ static int ccp5_perform_passthru(struct ccp_op *op)struct ccp_dma_info *daddr = &op->dst.u.dma; + op->cmd_q->total_pt_ops++; +memset (&desc,0 ,Q_DESC_SIZE );CCP5_CMD_ENGINE (&desc) =CCP_ENGINE_PASSTHRU ;
@@ -543,6 +558,8 @@ static int ccp5_perform_ecc(struct ccp_op *op)struct ccp5_desc desc;union ccp_function function; + op->cmd_q->total_ecc_ops++; +/* Zero out all the fields of the command desc */ memset (&desc,0 ,Q_DESC_SIZE );
@@ -592,7 +609,6 @@ static int ccp_find_lsb_regions(struct ccp_cmd_queue *cmd_q, u64 status)return queues ?0 : -EINVAL ; } -static int ccp_find_and_assign_lsb_to_q (struct ccp_device *ccp,int lsb_cnt,int n_lsbs,unsigned long *lsb_pub)
@@ -757,6 +773,7 @@ static irqreturn_t ccp5_irq_handler(int irq, void *data)struct ccp_device *ccp =dev_get_drvdata (dev);ccp5_disable_queue_interrupts (ccp); + ccp->total_interrupts++;if (ccp->use_tasklet)tasklet_schedule (&ccp->irq_tasklet);else
@@ -956,6 +973,9 @@ static int ccp5_init(struct ccp_device *ccp)if (ret) goto e_hwrng; +/* Set up debugfs entries */ +ccp5_debugfs_setup (ccp); +return 0 ; e_hwrng:
@@ -992,6 +1012,12 @@ static void ccp5_destroy(struct ccp_device *ccp)/* Remove this device from the list of available units first */ ccp_del_device (ccp); +/* We're in the process of tearing down the entire driver; +* when all the devices are gone clean up debugfs +*/ +if (!ccp_present ()) +ccp5_debugfs_destroy (); +/* Disable and clear interrupts */ ccp5_disable_queue_interrupts (ccp);for (i =0 ; i < ccp->cmd_q_count; i++) {
drivers/crypto/ccp/ccp-dev.c +1 -1
@@ -33,7 +33,7 @@MODULE_AUTHOR ("Tom Lendacky <[email protected]>" );MODULE_AUTHOR ("Gary R Hook <[email protected]>" );MODULE_LICENSE ("GPL" ); -MODULE_VERSION ("1.0.0" ); +MODULE_VERSION ("1.1.0" );MODULE_DESCRIPTION ("AMD Cryptographic Coprocessor driver" );struct ccp_tasklet_data {
drivers/crypto/ccp/ccp-dev.h +20 -0
@@ -70,6 +70,7 @@#define LSB_PUBLIC_MASK_HI_OFFSET 0x1C#define LSB_PRIVATE_MASK_LO_OFFSET 0x20#define LSB_PRIVATE_MASK_HI_OFFSET 0x24 +#define CMD5_PSP_CCP_VERSION 0x100#define CMD5_Q_CONTROL_BASE 0x0000#define CMD5_Q_TAIL_LO_BASE 0x0004
@@ -322,6 +323,16 @@ struct ccp_cmd_queue {/* Interrupt wait queue */ wait_queue_head_t int_queue;unsigned int int_rcvd; + +/* Per-queue Statistics */ +unsigned long total_ops; +unsigned long total_aes_ops; +unsigned long total_xts_aes_ops; +unsigned long total_3des_ops; +unsigned long total_sha_ops; +unsigned long total_rsa_ops; +unsigned long total_pt_ops; +unsigned long total_ecc_ops; }____cacheline_aligned ;struct ccp_device {
@@ -419,6 +430,12 @@ struct ccp_device {/* DMA caching attribute support */ unsigned int axcache; + +/* Device Statistics */ +unsigned long total_interrupts; + +/* DebugFS info */ +struct dentry *debugfs_instance; };enum ccp_memtype {
@@ -632,6 +649,9 @@ struct ccp5_desc {int ccp_dmaengine_register (struct ccp_device *ccp);void ccp_dmaengine_unregister (struct ccp_device *ccp); +void ccp5_debugfs_setup (struct ccp_device *ccp); +void ccp5_debugfs_destroy (void ); +/* Structure for computation functions that are device-specific */ struct ccp_actions {int (*aes)(struct ccp_op *);