Back to home page

OSCL-LXR

 
 

    


0001 // SPDX-License-Identifier: GPL-2.0
0002 #include <linux/seq_file.h>
0003 #include <linux/debugfs.h>
0004 
0005 #include "nitrox_csr.h"
0006 #include "nitrox_debugfs.h"
0007 #include "nitrox_dev.h"
0008 
0009 static int firmware_show(struct seq_file *s, void *v)
0010 {
0011     struct nitrox_device *ndev = s->private;
0012 
0013     seq_printf(s, "Version: %s\n", ndev->hw.fw_name[0]);
0014     seq_printf(s, "Version: %s\n", ndev->hw.fw_name[1]);
0015     return 0;
0016 }
0017 
0018 DEFINE_SHOW_ATTRIBUTE(firmware);
0019 
0020 static int device_show(struct seq_file *s, void *v)
0021 {
0022     struct nitrox_device *ndev = s->private;
0023 
0024     seq_printf(s, "NITROX [%d]\n", ndev->idx);
0025     seq_printf(s, "  Part Name: %s\n", ndev->hw.partname);
0026     seq_printf(s, "  Frequency: %d MHz\n", ndev->hw.freq);
0027     seq_printf(s, "  Device ID: 0x%0x\n", ndev->hw.device_id);
0028     seq_printf(s, "  Revision ID: 0x%0x\n", ndev->hw.revision_id);
0029     seq_printf(s, "  Cores: [AE=%u  SE=%u  ZIP=%u]\n",
0030            ndev->hw.ae_cores, ndev->hw.se_cores, ndev->hw.zip_cores);
0031 
0032     return 0;
0033 }
0034 
0035 DEFINE_SHOW_ATTRIBUTE(device);
0036 
0037 static int stats_show(struct seq_file *s, void *v)
0038 {
0039     struct nitrox_device *ndev = s->private;
0040 
0041     seq_printf(s, "NITROX [%d] Request Statistics\n", ndev->idx);
0042     seq_printf(s, "  Posted: %llu\n",
0043            (u64)atomic64_read(&ndev->stats.posted));
0044     seq_printf(s, "  Completed: %llu\n",
0045            (u64)atomic64_read(&ndev->stats.completed));
0046     seq_printf(s, "  Dropped: %llu\n",
0047            (u64)atomic64_read(&ndev->stats.dropped));
0048 
0049     return 0;
0050 }
0051 
0052 DEFINE_SHOW_ATTRIBUTE(stats);
0053 
0054 void nitrox_debugfs_exit(struct nitrox_device *ndev)
0055 {
0056     debugfs_remove_recursive(ndev->debugfs_dir);
0057     ndev->debugfs_dir = NULL;
0058 }
0059 
0060 void nitrox_debugfs_init(struct nitrox_device *ndev)
0061 {
0062     struct dentry *dir;
0063 
0064     dir = debugfs_create_dir(KBUILD_MODNAME, NULL);
0065 
0066     ndev->debugfs_dir = dir;
0067     debugfs_create_file("firmware", 0400, dir, ndev, &firmware_fops);
0068     debugfs_create_file("device", 0400, dir, ndev, &device_fops);
0069     debugfs_create_file("stats", 0400, dir, ndev, &stats_fops);
0070 }