fjes_debugfs.c 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. /*
  2. * FUJITSU Extended Socket Network Device driver
  3. * Copyright (c) 2015-2016 FUJITSU LIMITED
  4. *
  5. * This program is free software; you can redistribute it and/or modify it
  6. * under the terms and conditions of the GNU General Public License,
  7. * version 2, as published by the Free Software Foundation.
  8. *
  9. * This program is distributed in the hope it will be useful, but WITHOUT
  10. * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11. * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
  12. * more details.
  13. *
  14. * You should have received a copy of the GNU General Public License along with
  15. * this program; if not, see <http://www.gnu.org/licenses/>.
  16. *
  17. * The full GNU General Public License is included in this distribution in
  18. * the file called "COPYING".
  19. *
  20. */
  21. /* debugfs support for fjes driver */
  22. #ifdef CONFIG_DEBUG_FS
  23. #include <linux/debugfs.h>
  24. #include <linux/seq_file.h>
  25. #include <linux/platform_device.h>
  26. #include "fjes.h"
  27. static struct dentry *fjes_debug_root;
  28. static const char * const ep_status_string[] = {
  29. "unshared",
  30. "shared",
  31. "waiting",
  32. "complete",
  33. };
  34. static int fjes_dbg_status_show(struct seq_file *m, void *v)
  35. {
  36. struct fjes_adapter *adapter = m->private;
  37. struct fjes_hw *hw = &adapter->hw;
  38. int max_epid = hw->max_epid;
  39. int my_epid = hw->my_epid;
  40. int epidx;
  41. seq_puts(m, "EPID\tSTATUS SAME_ZONE CONNECTED\n");
  42. for (epidx = 0; epidx < max_epid; epidx++) {
  43. if (epidx == my_epid) {
  44. seq_printf(m, "ep%d\t%-16c %-16c %-16c\n",
  45. epidx, '-', '-', '-');
  46. } else {
  47. seq_printf(m, "ep%d\t%-16s %-16c %-16c\n",
  48. epidx,
  49. ep_status_string[fjes_hw_get_partner_ep_status(hw, epidx)],
  50. fjes_hw_epid_is_same_zone(hw, epidx) ? 'Y' : 'N',
  51. fjes_hw_epid_is_shared(hw->hw_info.share, epidx) ? 'Y' : 'N');
  52. }
  53. }
  54. return 0;
  55. }
  56. static int fjes_dbg_status_open(struct inode *inode, struct file *file)
  57. {
  58. return single_open(file, fjes_dbg_status_show, inode->i_private);
  59. }
  60. static const struct file_operations fjes_dbg_status_fops = {
  61. .owner = THIS_MODULE,
  62. .open = fjes_dbg_status_open,
  63. .read = seq_read,
  64. .llseek = seq_lseek,
  65. .release = single_release,
  66. };
  67. void fjes_dbg_adapter_init(struct fjes_adapter *adapter)
  68. {
  69. const char *name = dev_name(&adapter->plat_dev->dev);
  70. struct dentry *pfile;
  71. adapter->dbg_adapter = debugfs_create_dir(name, fjes_debug_root);
  72. if (!adapter->dbg_adapter) {
  73. dev_err(&adapter->plat_dev->dev,
  74. "debugfs entry for %s failed\n", name);
  75. return;
  76. }
  77. pfile = debugfs_create_file("status", 0444, adapter->dbg_adapter,
  78. adapter, &fjes_dbg_status_fops);
  79. if (!pfile)
  80. dev_err(&adapter->plat_dev->dev,
  81. "debugfs status for %s failed\n", name);
  82. }
  83. void fjes_dbg_adapter_exit(struct fjes_adapter *adapter)
  84. {
  85. debugfs_remove_recursive(adapter->dbg_adapter);
  86. adapter->dbg_adapter = NULL;
  87. }
  88. void fjes_dbg_init(void)
  89. {
  90. fjes_debug_root = debugfs_create_dir(fjes_driver_name, NULL);
  91. if (!fjes_debug_root)
  92. pr_info("init of debugfs failed\n");
  93. }
  94. void fjes_dbg_exit(void)
  95. {
  96. debugfs_remove_recursive(fjes_debug_root);
  97. fjes_debug_root = NULL;
  98. }
  99. #endif /* CONFIG_DEBUG_FS */