|
| 1 | +/* |
| 2 | + * Intel MIC Platform Software Stack (MPSS) |
| 3 | + * |
| 4 | + * Copyright(c) 2014 Intel Corporation. |
| 5 | + * |
| 6 | + * This program is free software; you can redistribute it and/or modify |
| 7 | + * it under the terms of the GNU General Public License, version 2, as |
| 8 | + * published by the Free Software Foundation. |
| 9 | + * |
| 10 | + * This program is distributed in the hope that it will be useful, but |
| 11 | + * WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 13 | + * General Public License for more details. |
| 14 | + * |
| 15 | + * Intel SCIF driver. |
| 16 | + * |
| 17 | + */ |
| 18 | +#include <linux/debugfs.h> |
| 19 | +#include <linux/seq_file.h> |
| 20 | + |
| 21 | +#include "../common/mic_dev.h" |
| 22 | +#include "scif_main.h" |
| 23 | + |
| 24 | +/* Debugfs parent dir */ |
| 25 | +static struct dentry *scif_dbg; |
| 26 | + |
| 27 | +static int scif_dev_test(struct seq_file *s, void *unused) |
| 28 | +{ |
| 29 | + int node; |
| 30 | + |
| 31 | + seq_printf(s, "Total Nodes %d Self Node Id %d Maxid %d\n", |
| 32 | + scif_info.total, scif_info.nodeid, |
| 33 | + scif_info.maxid); |
| 34 | + |
| 35 | + if (!scif_dev) |
| 36 | + return 0; |
| 37 | + |
| 38 | + seq_printf(s, "%-16s\t%-16s\n", "node_id", "state"); |
| 39 | + |
| 40 | + for (node = 0; node <= scif_info.maxid; node++) |
| 41 | + seq_printf(s, "%-16d\t%-16s\n", scif_dev[node].node, |
| 42 | + _scifdev_alive(&scif_dev[node]) ? |
| 43 | + "Running" : "Offline"); |
| 44 | + return 0; |
| 45 | +} |
| 46 | + |
| 47 | +static int scif_dev_test_open(struct inode *inode, struct file *file) |
| 48 | +{ |
| 49 | + return single_open(file, scif_dev_test, inode->i_private); |
| 50 | +} |
| 51 | + |
| 52 | +static int scif_dev_test_release(struct inode *inode, struct file *file) |
| 53 | +{ |
| 54 | + return single_release(inode, file); |
| 55 | +} |
| 56 | + |
| 57 | +static const struct file_operations scif_dev_ops = { |
| 58 | + .owner = THIS_MODULE, |
| 59 | + .open = scif_dev_test_open, |
| 60 | + .read = seq_read, |
| 61 | + .llseek = seq_lseek, |
| 62 | + .release = scif_dev_test_release |
| 63 | +}; |
| 64 | + |
| 65 | +void __init scif_init_debugfs(void) |
| 66 | +{ |
| 67 | + struct dentry *d; |
| 68 | + |
| 69 | + scif_dbg = debugfs_create_dir(KBUILD_MODNAME, NULL); |
| 70 | + if (!scif_dbg) { |
| 71 | + dev_err(scif_info.mdev.this_device, |
| 72 | + "can't create debugfs dir scif\n"); |
| 73 | + return; |
| 74 | + } |
| 75 | + |
| 76 | + d = debugfs_create_file("scif_dev", 0444, scif_dbg, |
| 77 | + NULL, &scif_dev_ops); |
| 78 | + debugfs_create_u8("en_msg_log", 0666, scif_dbg, &scif_info.en_msg_log); |
| 79 | + debugfs_create_u8("p2p_enable", 0666, scif_dbg, &scif_info.p2p_enable); |
| 80 | +} |
| 81 | + |
| 82 | +void scif_exit_debugfs(void) |
| 83 | +{ |
| 84 | + debugfs_remove_recursive(scif_dbg); |
| 85 | +} |
0 commit comments