snic_stats.h 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  1. /*
  2. * Copyright 2014 Cisco Systems, Inc. All rights reserved.
  3. *
  4. * This program is free software; you may redistribute it and/or modify
  5. * it under the terms of the GNU General Public License as published by
  6. * the Free Software Foundation; version 2 of the License.
  7. *
  8. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  9. * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  10. * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
  11. * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
  12. * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
  13. * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
  14. * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  15. * SOFTWARE.
  16. */
  17. #ifndef __SNIC_STATS_H
  18. #define __SNIC_STATS_H
  19. struct snic_io_stats {
  20. atomic64_t active; /* Active IOs */
  21. atomic64_t max_active; /* Max # active IOs */
  22. atomic64_t max_sgl; /* Max # SGLs for any IO */
  23. atomic64_t max_time; /* Max time to process IO */
  24. atomic64_t max_qtime; /* Max time to Queue the IO */
  25. atomic64_t max_cmpl_time; /* Max time to complete the IO */
  26. atomic64_t sgl_cnt[SNIC_MAX_SG_DESC_CNT]; /* SGL Counters */
  27. atomic64_t max_io_sz; /* Max IO Size */
  28. atomic64_t compl; /* IO Completions */
  29. atomic64_t fail; /* IO Failures */
  30. atomic64_t req_null; /* req or req info is NULL */
  31. atomic64_t alloc_fail; /* Alloc Failures */
  32. atomic64_t sc_null;
  33. atomic64_t io_not_found; /* IO Not Found */
  34. atomic64_t num_ios; /* Number of IOs */
  35. };
  36. struct snic_abort_stats {
  37. atomic64_t num; /* Abort counter */
  38. atomic64_t fail; /* Abort Failure Counter */
  39. atomic64_t drv_tmo; /* Abort Driver Timeouts */
  40. atomic64_t fw_tmo; /* Abort Firmware Timeouts */
  41. atomic64_t io_not_found;/* Abort IO Not Found */
  42. atomic64_t q_fail; /* Abort Queuing Failed */
  43. };
  44. struct snic_reset_stats {
  45. atomic64_t dev_resets; /* Device Reset Counter */
  46. atomic64_t dev_reset_fail; /* Device Reset Failures */
  47. atomic64_t dev_reset_aborts; /* Device Reset Aborts */
  48. atomic64_t dev_reset_tmo; /* Device Reset Timeout */
  49. atomic64_t dev_reset_terms; /* Device Reset terminate */
  50. atomic64_t hba_resets; /* hba/firmware resets */
  51. atomic64_t hba_reset_cmpl; /* hba/firmware reset completions */
  52. atomic64_t hba_reset_fail; /* hba/firmware failures */
  53. atomic64_t snic_resets; /* snic resets */
  54. atomic64_t snic_reset_compl; /* snic reset completions */
  55. atomic64_t snic_reset_fail; /* snic reset failures */
  56. };
  57. struct snic_fw_stats {
  58. atomic64_t actv_reqs; /* Active Requests */
  59. atomic64_t max_actv_reqs; /* Max Active Requests */
  60. atomic64_t out_of_res; /* Firmware Out Of Resources */
  61. atomic64_t io_errs; /* Firmware IO Firmware Errors */
  62. atomic64_t scsi_errs; /* Target hits check condition */
  63. };
  64. struct snic_misc_stats {
  65. u64 last_isr_time;
  66. u64 last_ack_time;
  67. atomic64_t ack_isr_cnt;
  68. atomic64_t cmpl_isr_cnt;
  69. atomic64_t errnotify_isr_cnt;
  70. atomic64_t max_cq_ents; /* Max CQ Entries */
  71. atomic64_t data_cnt_mismat; /* Data Count Mismatch */
  72. atomic64_t io_tmo;
  73. atomic64_t io_aborted;
  74. atomic64_t sgl_inval; /* SGL Invalid */
  75. atomic64_t abts_wq_alloc_fail; /* Abort Path WQ desc alloc failure */
  76. atomic64_t devrst_wq_alloc_fail;/* Device Reset - WQ desc alloc fail */
  77. atomic64_t wq_alloc_fail; /* IO WQ desc alloc failure */
  78. atomic64_t no_icmnd_itmf_cmpls;
  79. atomic64_t io_under_run;
  80. atomic64_t qfull;
  81. atomic64_t qsz_rampup;
  82. atomic64_t qsz_rampdown;
  83. atomic64_t last_qsz;
  84. atomic64_t tgt_not_rdy;
  85. };
  86. struct snic_stats {
  87. struct snic_io_stats io;
  88. struct snic_abort_stats abts;
  89. struct snic_reset_stats reset;
  90. struct snic_fw_stats fw;
  91. struct snic_misc_stats misc;
  92. atomic64_t io_cmpl_skip;
  93. };
  94. void snic_stats_debugfs_init(struct snic *);
  95. void snic_stats_debugfs_remove(struct snic *);
  96. /* Auxillary function to update active IO counter */
  97. static inline void
  98. snic_stats_update_active_ios(struct snic_stats *s_stats)
  99. {
  100. struct snic_io_stats *io = &s_stats->io;
  101. int nr_active_ios;
  102. nr_active_ios = atomic64_read(&io->active);
  103. if (atomic64_read(&io->max_active) < nr_active_ios)
  104. atomic64_set(&io->max_active, nr_active_ios);
  105. atomic64_inc(&io->num_ios);
  106. }
  107. /* Auxillary function to update IO completion counter */
  108. static inline void
  109. snic_stats_update_io_cmpl(struct snic_stats *s_stats)
  110. {
  111. atomic64_dec(&s_stats->io.active);
  112. if (unlikely(atomic64_read(&s_stats->io_cmpl_skip)))
  113. atomic64_dec(&s_stats->io_cmpl_skip);
  114. else
  115. atomic64_inc(&s_stats->io.compl);
  116. }
  117. #endif /* __SNIC_STATS_H */