18c2ecf20Sopenharmony_ci// SPDX-License-Identifier: GPL-2.0-only
28c2ecf20Sopenharmony_ci/**
38c2ecf20Sopenharmony_ci * debugfs routines supporting the Power 7+ Nest Accelerators driver
48c2ecf20Sopenharmony_ci *
58c2ecf20Sopenharmony_ci * Copyright (C) 2011-2012 International Business Machines Inc.
68c2ecf20Sopenharmony_ci *
78c2ecf20Sopenharmony_ci * Author: Kent Yoder <yoder1@us.ibm.com>
88c2ecf20Sopenharmony_ci */
98c2ecf20Sopenharmony_ci
108c2ecf20Sopenharmony_ci#include <linux/device.h>
118c2ecf20Sopenharmony_ci#include <linux/kobject.h>
128c2ecf20Sopenharmony_ci#include <linux/string.h>
138c2ecf20Sopenharmony_ci#include <linux/debugfs.h>
148c2ecf20Sopenharmony_ci#include <linux/module.h>
158c2ecf20Sopenharmony_ci#include <linux/init.h>
168c2ecf20Sopenharmony_ci#include <linux/crypto.h>
178c2ecf20Sopenharmony_ci#include <crypto/hash.h>
188c2ecf20Sopenharmony_ci#include <asm/vio.h>
198c2ecf20Sopenharmony_ci
208c2ecf20Sopenharmony_ci#include "nx_csbcpb.h"
218c2ecf20Sopenharmony_ci#include "nx.h"
228c2ecf20Sopenharmony_ci
238c2ecf20Sopenharmony_ci#ifdef CONFIG_DEBUG_FS
248c2ecf20Sopenharmony_ci
258c2ecf20Sopenharmony_ci/*
268c2ecf20Sopenharmony_ci * debugfs
278c2ecf20Sopenharmony_ci *
288c2ecf20Sopenharmony_ci * For documentation on these attributes, please see:
298c2ecf20Sopenharmony_ci *
308c2ecf20Sopenharmony_ci * Documentation/ABI/testing/debugfs-pfo-nx-crypto
318c2ecf20Sopenharmony_ci */
328c2ecf20Sopenharmony_ci
338c2ecf20Sopenharmony_civoid nx_debugfs_init(struct nx_crypto_driver *drv)
348c2ecf20Sopenharmony_ci{
358c2ecf20Sopenharmony_ci	struct dentry *root;
368c2ecf20Sopenharmony_ci
378c2ecf20Sopenharmony_ci	root = debugfs_create_dir(NX_NAME, NULL);
388c2ecf20Sopenharmony_ci	drv->dfs_root = root;
398c2ecf20Sopenharmony_ci
408c2ecf20Sopenharmony_ci	debugfs_create_u32("aes_ops", S_IRUSR | S_IRGRP | S_IROTH,
418c2ecf20Sopenharmony_ci			   root, &drv->stats.aes_ops.counter);
428c2ecf20Sopenharmony_ci	debugfs_create_u32("sha256_ops", S_IRUSR | S_IRGRP | S_IROTH,
438c2ecf20Sopenharmony_ci			   root, &drv->stats.sha256_ops.counter);
448c2ecf20Sopenharmony_ci	debugfs_create_u32("sha512_ops", S_IRUSR | S_IRGRP | S_IROTH,
458c2ecf20Sopenharmony_ci			   root, &drv->stats.sha512_ops.counter);
468c2ecf20Sopenharmony_ci	debugfs_create_u64("aes_bytes", S_IRUSR | S_IRGRP | S_IROTH,
478c2ecf20Sopenharmony_ci			   root, &drv->stats.aes_bytes.counter);
488c2ecf20Sopenharmony_ci	debugfs_create_u64("sha256_bytes", S_IRUSR | S_IRGRP | S_IROTH,
498c2ecf20Sopenharmony_ci			   root, &drv->stats.sha256_bytes.counter);
508c2ecf20Sopenharmony_ci	debugfs_create_u64("sha512_bytes", S_IRUSR | S_IRGRP | S_IROTH,
518c2ecf20Sopenharmony_ci			   root, &drv->stats.sha512_bytes.counter);
528c2ecf20Sopenharmony_ci	debugfs_create_u32("errors", S_IRUSR | S_IRGRP | S_IROTH,
538c2ecf20Sopenharmony_ci			   root, &drv->stats.errors.counter);
548c2ecf20Sopenharmony_ci	debugfs_create_u32("last_error", S_IRUSR | S_IRGRP | S_IROTH,
558c2ecf20Sopenharmony_ci			   root, &drv->stats.last_error.counter);
568c2ecf20Sopenharmony_ci	debugfs_create_u32("last_error_pid", S_IRUSR | S_IRGRP | S_IROTH,
578c2ecf20Sopenharmony_ci			   root, &drv->stats.last_error_pid.counter);
588c2ecf20Sopenharmony_ci}
598c2ecf20Sopenharmony_ci
608c2ecf20Sopenharmony_civoid
618c2ecf20Sopenharmony_cinx_debugfs_fini(struct nx_crypto_driver *drv)
628c2ecf20Sopenharmony_ci{
638c2ecf20Sopenharmony_ci	debugfs_remove_recursive(drv->dfs_root);
648c2ecf20Sopenharmony_ci}
658c2ecf20Sopenharmony_ci
668c2ecf20Sopenharmony_ci#endif
67