^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1) // SPDX-License-Identifier: GPL-2.0-only
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3) * debugfs routines supporting the Power 7+ Nest Accelerators driver
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5) * Copyright (C) 2011-2012 International Business Machines Inc.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7) * Author: Kent Yoder <yoder1@us.ibm.com>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) #include <linux/device.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) #include <linux/kobject.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) #include <linux/string.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) #include <linux/debugfs.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) #include <linux/module.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) #include <linux/init.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) #include <linux/crypto.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) #include <crypto/hash.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) #include <asm/vio.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) #include "nx_csbcpb.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) #include "nx.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) #ifdef CONFIG_DEBUG_FS
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) * debugfs
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) * For documentation on these attributes, please see:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) * Documentation/ABI/testing/debugfs-pfo-nx-crypto
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) void nx_debugfs_init(struct nx_crypto_driver *drv)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) struct dentry *root;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) root = debugfs_create_dir(NX_NAME, NULL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) drv->dfs_root = root;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) debugfs_create_u32("aes_ops", S_IRUSR | S_IRGRP | S_IROTH,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) root, &drv->stats.aes_ops.counter);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) debugfs_create_u32("sha256_ops", S_IRUSR | S_IRGRP | S_IROTH,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) root, &drv->stats.sha256_ops.counter);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) debugfs_create_u32("sha512_ops", S_IRUSR | S_IRGRP | S_IROTH,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) root, &drv->stats.sha512_ops.counter);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) debugfs_create_u64("aes_bytes", S_IRUSR | S_IRGRP | S_IROTH,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47) root, &drv->stats.aes_bytes.counter);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) debugfs_create_u64("sha256_bytes", S_IRUSR | S_IRGRP | S_IROTH,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) root, &drv->stats.sha256_bytes.counter);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50) debugfs_create_u64("sha512_bytes", S_IRUSR | S_IRGRP | S_IROTH,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51) root, &drv->stats.sha512_bytes.counter);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52) debugfs_create_u32("errors", S_IRUSR | S_IRGRP | S_IROTH,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53) root, &drv->stats.errors.counter);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54) debugfs_create_u32("last_error", S_IRUSR | S_IRGRP | S_IROTH,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55) root, &drv->stats.last_error.counter);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56) debugfs_create_u32("last_error_pid", S_IRUSR | S_IRGRP | S_IROTH,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57) root, &drv->stats.last_error_pid.counter);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60) void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61) nx_debugfs_fini(struct nx_crypto_driver *drv)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63) debugfs_remove_recursive(drv->dfs_root);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 65)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 66) #endif