summaryrefslogtreecommitdiff
path: root/drivers/crypto/nx/nx_debugfs.c
blob: 03e4f0363c6addb4f3d7fec521901f78f685c768 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
// SPDX-License-Identifier: GPL-2.0-only
/**
 * debugfs routines supporting the Power 7+ Nest Accelerators driver
 *
 * Copyright (C) 2011-2012 International Business Machines Inc.
 *
 * Author: Kent Yoder <yoder1@us.ibm.com>
 */

#include <linux/device.h>
#include <linux/kobject.h>
#include <linux/string.h>
#include <linux/debugfs.h>
#include <linux/module.h>
#include <linux/init.h>
#include <linux/crypto.h>
#include <crypto/hash.h>
#include <asm/vio.h>

#include "nx_csbcpb.h"
#include "nx.h"

#ifdef CONFIG_DEBUG_FS

/*
 * debugfs
 *
 * For documentation on these attributes, please see:
 *
 * Documentation/ABI/testing/debugfs-pfo-nx-crypto
 */

int nx_debugfs_init(struct nx_crypto_driver *drv)
{
	struct nx_debugfs *dfs = &drv->dfs;

	dfs->dfs_root = debugfs_create_dir(NX_NAME, NULL);

	dfs->dfs_aes_ops =
		debugfs_create_u32("aes_ops",
				   S_IRUSR | S_IRGRP | S_IROTH,
				   dfs->dfs_root, (u32 *)&drv->stats.aes_ops);
	dfs->dfs_sha256_ops =
		debugfs_create_u32("sha256_ops",
				   S_IRUSR | S_IRGRP | S_IROTH,
				   dfs->dfs_root,
				   (u32 *)&drv->stats.sha256_ops);
	dfs->dfs_sha512_ops =
		debugfs_create_u32("sha512_ops",
				   S_IRUSR | S_IRGRP | S_IROTH,
				   dfs->dfs_root,
				   (u32 *)&drv->stats.sha512_ops);
	dfs->dfs_aes_bytes =
		debugfs_create_u64("aes_bytes",
				   S_IRUSR | S_IRGRP | S_IROTH,
				   dfs->dfs_root,
				   (u64 *)&drv->stats.aes_bytes);
	dfs->dfs_sha256_bytes =
		debugfs_create_u64("sha256_bytes",
				   S_IRUSR | S_IRGRP | S_IROTH,
				   dfs->dfs_root,
				   (u64 *)&drv->stats.sha256_bytes);
	dfs->dfs_sha512_bytes =
		debugfs_create_u64("sha512_bytes",
				   S_IRUSR | S_IRGRP | S_IROTH,
				   dfs->dfs_root,
				   (u64 *)&drv->stats.sha512_bytes);
	dfs->dfs_errors =
		debugfs_create_u32("errors",
				   S_IRUSR | S_IRGRP | S_IROTH,
				   dfs->dfs_root, (u32 *)&drv->stats.errors);
	dfs->dfs_last_error =
		debugfs_create_u32("last_error",
				   S_IRUSR | S_IRGRP | S_IROTH,
				   dfs->dfs_root,
				   (u32 *)&drv->stats.last_error);
	dfs->dfs_last_error_pid =
		debugfs_create_u32("last_error_pid",
				   S_IRUSR | S_IRGRP | S_IROTH,
				   dfs->dfs_root,
				   (u32 *)&drv->stats.last_error_pid);
	return 0;
}

void
nx_debugfs_fini(struct nx_crypto_driver *drv)
{
	debugfs_remove_recursive(drv->dfs.dfs_root);
}

#endif