qdio_perf.c 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147
  1. /*
  2. * drivers/s390/cio/qdio_perf.c
  3. *
  4. * Copyright IBM Corp. 2008
  5. *
  6. * Author: Jan Glauber (jang@linux.vnet.ibm.com)
  7. */
  8. #include <linux/kernel.h>
  9. #include <linux/proc_fs.h>
  10. #include <linux/seq_file.h>
  11. #include <asm/ccwdev.h>
  12. #include "cio.h"
  13. #include "css.h"
  14. #include "device.h"
  15. #include "ioasm.h"
  16. #include "chsc.h"
  17. #include "qdio_debug.h"
  18. #include "qdio_perf.h"
  19. int qdio_performance_stats;
  20. struct qdio_perf_stats perf_stats;
  21. #ifdef CONFIG_PROC_FS
  22. static struct proc_dir_entry *qdio_perf_pde;
  23. #endif
  24. /*
  25. * procfs functions
  26. */
  27. static int qdio_perf_proc_show(struct seq_file *m, void *v)
  28. {
  29. seq_printf(m, "Number of qdio interrupts\t\t\t: %li\n",
  30. (long)atomic_long_read(&perf_stats.qdio_int));
  31. seq_printf(m, "Number of PCI interrupts\t\t\t: %li\n",
  32. (long)atomic_long_read(&perf_stats.pci_int));
  33. seq_printf(m, "Number of adapter interrupts\t\t\t: %li\n",
  34. (long)atomic_long_read(&perf_stats.thin_int));
  35. seq_printf(m, "\n");
  36. seq_printf(m, "Inbound tasklet runs\t\t\t\t: %li\n",
  37. (long)atomic_long_read(&perf_stats.tasklet_inbound));
  38. seq_printf(m, "Outbound tasklet runs\t\t\t\t: %li\n",
  39. (long)atomic_long_read(&perf_stats.tasklet_outbound));
  40. seq_printf(m, "Adapter interrupt tasklet runs/loops\t\t: %li/%li\n",
  41. (long)atomic_long_read(&perf_stats.tasklet_thinint),
  42. (long)atomic_long_read(&perf_stats.tasklet_thinint_loop));
  43. seq_printf(m, "Adapter interrupt inbound tasklet runs/loops\t: %li/%li\n",
  44. (long)atomic_long_read(&perf_stats.thinint_inbound),
  45. (long)atomic_long_read(&perf_stats.thinint_inbound_loop));
  46. seq_printf(m, "\n");
  47. seq_printf(m, "Number of SIGA In issued\t\t\t: %li\n",
  48. (long)atomic_long_read(&perf_stats.siga_in));
  49. seq_printf(m, "Number of SIGA Out issued\t\t\t: %li\n",
  50. (long)atomic_long_read(&perf_stats.siga_out));
  51. seq_printf(m, "Number of SIGA Sync issued\t\t\t: %li\n",
  52. (long)atomic_long_read(&perf_stats.siga_sync));
  53. seq_printf(m, "\n");
  54. seq_printf(m, "Number of inbound transfers\t\t\t: %li\n",
  55. (long)atomic_long_read(&perf_stats.inbound_handler));
  56. seq_printf(m, "Number of outbound transfers\t\t\t: %li\n",
  57. (long)atomic_long_read(&perf_stats.outbound_handler));
  58. seq_printf(m, "\n");
  59. seq_printf(m, "Number of fast requeues (outg. SBAL w/o SIGA)\t: %li\n",
  60. (long)atomic_long_read(&perf_stats.fast_requeue));
  61. seq_printf(m, "Number of outbound target full condition\t: %li\n",
  62. (long)atomic_long_read(&perf_stats.outbound_target_full));
  63. seq_printf(m, "Number of outbound tasklet mod_timer calls\t: %li\n",
  64. (long)atomic_long_read(&perf_stats.debug_tl_out_timer));
  65. seq_printf(m, "Number of stop polling calls\t\t\t: %li\n",
  66. (long)atomic_long_read(&perf_stats.debug_stop_polling));
  67. seq_printf(m, "AI inbound tasklet loops after stop polling\t: %li\n",
  68. (long)atomic_long_read(&perf_stats.thinint_inbound_loop2));
  69. seq_printf(m, "QEBSM EQBS total/incomplete\t\t\t: %li/%li\n",
  70. (long)atomic_long_read(&perf_stats.debug_eqbs_all),
  71. (long)atomic_long_read(&perf_stats.debug_eqbs_incomplete));
  72. seq_printf(m, "QEBSM SQBS total/incomplete\t\t\t: %li/%li\n",
  73. (long)atomic_long_read(&perf_stats.debug_sqbs_all),
  74. (long)atomic_long_read(&perf_stats.debug_sqbs_incomplete));
  75. seq_printf(m, "\n");
  76. return 0;
  77. }
  78. static int qdio_perf_seq_open(struct inode *inode, struct file *filp)
  79. {
  80. return single_open(filp, qdio_perf_proc_show, NULL);
  81. }
  82. static const struct file_operations qdio_perf_proc_fops = {
  83. .owner = THIS_MODULE,
  84. .open = qdio_perf_seq_open,
  85. .read = seq_read,
  86. .llseek = seq_lseek,
  87. .release = single_release,
  88. };
  89. /*
  90. * sysfs functions
  91. */
  92. static ssize_t qdio_perf_stats_show(struct bus_type *bus, char *buf)
  93. {
  94. return sprintf(buf, "%i\n", qdio_performance_stats ? 1 : 0);
  95. }
  96. static ssize_t qdio_perf_stats_store(struct bus_type *bus,
  97. const char *buf, size_t count)
  98. {
  99. unsigned long i;
  100. if (strict_strtoul(buf, 16, &i) != 0)
  101. return -EINVAL;
  102. if ((i != 0) && (i != 1))
  103. return -EINVAL;
  104. if (i == qdio_performance_stats)
  105. return count;
  106. qdio_performance_stats = i;
  107. /* reset performance statistics */
  108. if (i == 0)
  109. memset(&perf_stats, 0, sizeof(struct qdio_perf_stats));
  110. return count;
  111. }
  112. static BUS_ATTR(qdio_performance_stats, 0644, qdio_perf_stats_show,
  113. qdio_perf_stats_store);
  114. int __init qdio_setup_perf_stats(void)
  115. {
  116. int rc;
  117. rc = bus_create_file(&ccw_bus_type, &bus_attr_qdio_performance_stats);
  118. if (rc)
  119. return rc;
  120. #ifdef CONFIG_PROC_FS
  121. memset(&perf_stats, 0, sizeof(struct qdio_perf_stats));
  122. qdio_perf_pde = proc_create("qdio_perf", S_IFREG | S_IRUGO,
  123. NULL, &qdio_perf_proc_fops);
  124. #endif
  125. return 0;
  126. }
  127. void qdio_remove_perf_stats(void)
  128. {
  129. #ifdef CONFIG_PROC_FS
  130. remove_proc_entry("qdio_perf", NULL);
  131. #endif
  132. bus_remove_file(&ccw_bus_type, &bus_attr_qdio_performance_stats);
  133. }