snic_stats.h 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  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. };
  43. struct snic_reset_stats {
  44. atomic64_t dev_resets; /* Device Reset Counter */
  45. atomic64_t dev_reset_fail; /* Device Reset Failures */
  46. atomic64_t dev_reset_aborts; /* Device Reset Aborts */
  47. atomic64_t dev_reset_tmo; /* Device Reset Timeout */
  48. atomic64_t dev_reset_terms; /* Device Reset terminate */
  49. atomic64_t hba_resets; /* hba/firmware resets */
  50. atomic64_t hba_reset_cmpl; /* hba/firmware reset completions */
  51. atomic64_t hba_reset_fail; /* hba/firmware failures */
  52. atomic64_t snic_resets; /* snic resets */
  53. atomic64_t snic_reset_compl; /* snic reset completions */
  54. atomic64_t snic_reset_fail; /* snic reset failures */
  55. };
  56. struct snic_fw_stats {
  57. atomic64_t actv_reqs; /* Active Requests */
  58. atomic64_t max_actv_reqs; /* Max Active Requests */
  59. atomic64_t out_of_res; /* Firmware Out Of Resources */
  60. atomic64_t io_errs; /* Firmware IO Firmware Errors */
  61. atomic64_t scsi_errs; /* Target hits check condition */
  62. };
  63. struct snic_misc_stats {
  64. u64 last_isr_time;
  65. u64 last_ack_time;
  66. atomic64_t isr_cnt;
  67. atomic64_t max_cq_ents; /* Max CQ Entries */
  68. atomic64_t data_cnt_mismat; /* Data Count Mismatch */
  69. atomic64_t io_tmo;
  70. atomic64_t io_aborted;
  71. atomic64_t sgl_inval; /* SGL Invalid */
  72. atomic64_t abts_wq_alloc_fail; /* Abort Path WQ desc alloc failure */
  73. atomic64_t devrst_wq_alloc_fail;/* Device Reset - WQ desc alloc fail */
  74. atomic64_t wq_alloc_fail; /* IO WQ desc alloc failure */
  75. atomic64_t no_icmnd_itmf_cmpls;
  76. atomic64_t io_under_run;
  77. atomic64_t qfull;
  78. atomic64_t tgt_not_rdy;
  79. };
  80. struct snic_stats {
  81. struct snic_io_stats io;
  82. struct snic_abort_stats abts;
  83. struct snic_reset_stats reset;
  84. struct snic_fw_stats fw;
  85. struct snic_misc_stats misc;
  86. atomic64_t io_cmpl_skip;
  87. };
  88. int snic_stats_debugfs_init(struct snic *);
  89. void snic_stats_debugfs_remove(struct snic *);
  90. /* Auxillary function to update active IO counter */
  91. static inline void
  92. snic_stats_update_active_ios(struct snic_stats *s_stats)
  93. {
  94. struct snic_io_stats *io = &s_stats->io;
  95. u32 nr_active_ios;
  96. nr_active_ios = atomic64_inc_return(&io->active);
  97. if (atomic64_read(&io->max_active) < nr_active_ios)
  98. atomic64_set(&io->max_active, nr_active_ios);
  99. atomic64_inc(&io->num_ios);
  100. }
  101. /* Auxillary function to update IO completion counter */
  102. static inline void
  103. snic_stats_update_io_cmpl(struct snic_stats *s_stats)
  104. {
  105. atomic64_dec(&s_stats->io.active);
  106. if (unlikely(atomic64_read(&s_stats->io_cmpl_skip)))
  107. atomic64_dec(&s_stats->io_cmpl_skip);
  108. else
  109. atomic64_inc(&s_stats->io.compl);
  110. }
  111. #endif /* __SNIC_STATS_H */