fjes_debugfs.c 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. // SPDX-License-Identifier: GPL-2.0-only
  2. /*
  3. * FUJITSU Extended Socket Network Device driver
  4. * Copyright (c) 2015-2016 FUJITSU LIMITED
  5. */
  6. /* debugfs support for fjes driver */
  7. #ifdef CONFIG_DEBUG_FS
  8. #include <linux/debugfs.h>
  9. #include <linux/seq_file.h>
  10. #include <linux/platform_device.h>
  11. #include "fjes.h"
  12. static struct dentry *fjes_debug_root;
  13. static const char * const ep_status_string[] = {
  14. "unshared",
  15. "shared",
  16. "waiting",
  17. "complete",
  18. };
  19. static int fjes_dbg_status_show(struct seq_file *m, void *v)
  20. {
  21. struct fjes_adapter *adapter = m->private;
  22. struct fjes_hw *hw = &adapter->hw;
  23. int max_epid = hw->max_epid;
  24. int my_epid = hw->my_epid;
  25. int epidx;
  26. seq_puts(m, "EPID\tSTATUS SAME_ZONE CONNECTED\n");
  27. for (epidx = 0; epidx < max_epid; epidx++) {
  28. if (epidx == my_epid) {
  29. seq_printf(m, "ep%d\t%-16c %-16c %-16c\n",
  30. epidx, '-', '-', '-');
  31. } else {
  32. seq_printf(m, "ep%d\t%-16s %-16c %-16c\n",
  33. epidx,
  34. ep_status_string[fjes_hw_get_partner_ep_status(hw, epidx)],
  35. fjes_hw_epid_is_same_zone(hw, epidx) ? 'Y' : 'N',
  36. fjes_hw_epid_is_shared(hw->hw_info.share, epidx) ? 'Y' : 'N');
  37. }
  38. }
  39. return 0;
  40. }
  41. DEFINE_SHOW_ATTRIBUTE(fjes_dbg_status);
  42. void fjes_dbg_adapter_init(struct fjes_adapter *adapter)
  43. {
  44. const char *name = dev_name(&adapter->plat_dev->dev);
  45. adapter->dbg_adapter = debugfs_create_dir(name, fjes_debug_root);
  46. debugfs_create_file("status", 0444, adapter->dbg_adapter, adapter,
  47. &fjes_dbg_status_fops);
  48. }
  49. void fjes_dbg_adapter_exit(struct fjes_adapter *adapter)
  50. {
  51. debugfs_remove_recursive(adapter->dbg_adapter);
  52. adapter->dbg_adapter = NULL;
  53. }
  54. void fjes_dbg_init(void)
  55. {
  56. fjes_debug_root = debugfs_create_dir(fjes_driver_name, NULL);
  57. }
  58. void fjes_dbg_exit(void)
  59. {
  60. debugfs_remove_recursive(fjes_debug_root);
  61. fjes_debug_root = NULL;
  62. }
  63. #endif /* CONFIG_DEBUG_FS */