scif_debugfs.c 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  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. #include "../common/mic_dev.h"
  21. #include "scif_main.h"
  22. /* Debugfs parent dir */
  23. static struct dentry *scif_dbg;
  24. static int scif_dev_test(struct seq_file *s, void *unused)
  25. {
  26. int node;
  27. seq_printf(s, "Total Nodes %d Self Node Id %d Maxid %d\n",
  28. scif_info.total, scif_info.nodeid,
  29. scif_info.maxid);
  30. if (!scif_dev)
  31. return 0;
  32. seq_printf(s, "%-16s\t%-16s\n", "node_id", "state");
  33. for (node = 0; node <= scif_info.maxid; node++)
  34. seq_printf(s, "%-16d\t%-16s\n", scif_dev[node].node,
  35. _scifdev_alive(&scif_dev[node]) ?
  36. "Running" : "Offline");
  37. return 0;
  38. }
  39. static int scif_dev_test_open(struct inode *inode, struct file *file)
  40. {
  41. return single_open(file, scif_dev_test, inode->i_private);
  42. }
  43. static int scif_dev_test_release(struct inode *inode, struct file *file)
  44. {
  45. return single_release(inode, file);
  46. }
  47. static const struct file_operations scif_dev_ops = {
  48. .owner = THIS_MODULE,
  49. .open = scif_dev_test_open,
  50. .read = seq_read,
  51. .llseek = seq_lseek,
  52. .release = scif_dev_test_release
  53. };
  54. void __init scif_init_debugfs(void)
  55. {
  56. struct dentry *d;
  57. scif_dbg = debugfs_create_dir(KBUILD_MODNAME, NULL);
  58. if (!scif_dbg) {
  59. dev_err(scif_info.mdev.this_device,
  60. "can't create debugfs dir scif\n");
  61. return;
  62. }
  63. d = debugfs_create_file("scif_dev", 0444, scif_dbg,
  64. NULL, &scif_dev_ops);
  65. debugfs_create_u8("en_msg_log", 0666, scif_dbg, &scif_info.en_msg_log);
  66. debugfs_create_u8("p2p_enable", 0666, scif_dbg, &scif_info.p2p_enable);
  67. }
  68. void scif_exit_debugfs(void)
  69. {
  70. debugfs_remove_recursive(scif_dbg);
  71. }