Linux kernel mirror (for testing)
git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel
os
linux
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_dev.h"
7
8static int firmware_show(struct seq_file *s, void *v)
9{
10 struct nitrox_device *ndev = s->private;
11
12 seq_printf(s, "Version: %s\n", ndev->hw.fw_name);
13 return 0;
14}
15
16DEFINE_SHOW_ATTRIBUTE(firmware);
17
18static int device_show(struct seq_file *s, void *v)
19{
20 struct nitrox_device *ndev = s->private;
21
22 seq_printf(s, "NITROX [%d]\n", ndev->idx);
23 seq_printf(s, " Part Name: %s\n", ndev->hw.partname);
24 seq_printf(s, " Frequency: %d MHz\n", ndev->hw.freq);
25 seq_printf(s, " Device ID: 0x%0x\n", ndev->hw.device_id);
26 seq_printf(s, " Revision ID: 0x%0x\n", ndev->hw.revision_id);
27 seq_printf(s, " Cores: [AE=%u SE=%u ZIP=%u]\n",
28 ndev->hw.ae_cores, ndev->hw.se_cores, ndev->hw.zip_cores);
29
30 return 0;
31}
32
33DEFINE_SHOW_ATTRIBUTE(device);
34
35static int stats_show(struct seq_file *s, void *v)
36{
37 struct nitrox_device *ndev = s->private;
38
39 seq_printf(s, "NITROX [%d] Request Statistics\n", ndev->idx);
40 seq_printf(s, " Posted: %llu\n",
41 (u64)atomic64_read(&ndev->stats.posted));
42 seq_printf(s, " Completed: %llu\n",
43 (u64)atomic64_read(&ndev->stats.completed));
44 seq_printf(s, " Dropped: %llu\n",
45 (u64)atomic64_read(&ndev->stats.dropped));
46
47 return 0;
48}
49
50DEFINE_SHOW_ATTRIBUTE(stats);
51
52void nitrox_debugfs_exit(struct nitrox_device *ndev)
53{
54 debugfs_remove_recursive(ndev->debugfs_dir);
55 ndev->debugfs_dir = NULL;
56}
57
58void nitrox_debugfs_init(struct nitrox_device *ndev)
59{
60 struct dentry *dir;
61
62 dir = debugfs_create_dir(KBUILD_MODNAME, NULL);
63
64 ndev->debugfs_dir = dir;
65 debugfs_create_file("firmware", 0400, dir, ndev, &firmware_fops);
66 debugfs_create_file("device", 0400, dir, ndev, &device_fops);
67 debugfs_create_file("stats", 0400, dir, ndev, &stats_fops);
68}