1// SPDX-License-Identifier: GPL-2.0
2#include <linux/seq_file.h>
3#include <linux/debugfs.h>
4
5#include "nitrox_csr.h"
6#include "nitrox_debugfs.h"
7#include "nitrox_dev.h"
8
9static int firmware_show(struct seq_file *s, void *v)
10{
11 struct nitrox_device *ndev = s->private;
12
13 seq_printf(m: s, fmt: "Version: %s\n", ndev->hw.fw_name[0]);
14 seq_printf(m: s, fmt: "Version: %s\n", ndev->hw.fw_name[1]);
15 return 0;
16}
17
18DEFINE_SHOW_ATTRIBUTE(firmware);
19
20static int device_show(struct seq_file *s, void *v)
21{
22 struct nitrox_device *ndev = s->private;
23
24 seq_printf(m: s, fmt: "NITROX [%d]\n", ndev->idx);
25 seq_printf(m: s, fmt: " Part Name: %s\n", ndev->hw.partname);
26 seq_printf(m: s, fmt: " Frequency: %d MHz\n", ndev->hw.freq);
27 seq_printf(m: s, fmt: " Device ID: 0x%0x\n", ndev->hw.device_id);
28 seq_printf(m: s, fmt: " Revision ID: 0x%0x\n", ndev->hw.revision_id);
29 seq_printf(m: s, fmt: " Cores: [AE=%u SE=%u ZIP=%u]\n",
30 ndev->hw.ae_cores, ndev->hw.se_cores, ndev->hw.zip_cores);
31
32 return 0;
33}
34
35DEFINE_SHOW_ATTRIBUTE(device);
36
37static int stats_show(struct seq_file *s, void *v)
38{
39 struct nitrox_device *ndev = s->private;
40
41 seq_printf(m: s, fmt: "NITROX [%d] Request Statistics\n", ndev->idx);
42 seq_printf(m: s, fmt: " Posted: %llu\n",
43 (u64)atomic64_read(v: &ndev->stats.posted));
44 seq_printf(m: s, fmt: " Completed: %llu\n",
45 (u64)atomic64_read(v: &ndev->stats.completed));
46 seq_printf(m: s, fmt: " Dropped: %llu\n",
47 (u64)atomic64_read(v: &ndev->stats.dropped));
48
49 return 0;
50}
51
52DEFINE_SHOW_ATTRIBUTE(stats);
53
54void nitrox_debugfs_exit(struct nitrox_device *ndev)
55{
56 debugfs_remove_recursive(dentry: ndev->debugfs_dir);
57 ndev->debugfs_dir = NULL;
58}
59
60void nitrox_debugfs_init(struct nitrox_device *ndev)
61{
62 struct dentry *dir;
63
64 dir = debugfs_create_dir(KBUILD_MODNAME, NULL);
65
66 ndev->debugfs_dir = dir;
67 debugfs_create_file(name: "firmware", mode: 0400, parent: dir, data: ndev, fops: &firmware_fops);
68 debugfs_create_file(name: "device", mode: 0400, parent: dir, data: ndev, fops: &device_fops);
69 debugfs_create_file(name: "stats", mode: 0400, parent: dir, data: ndev, fops: &stats_fops);
70}
71

source code of linux/drivers/crypto/cavium/nitrox/nitrox_debugfs.c