18c2ecf20Sopenharmony_ci/* 28c2ecf20Sopenharmony_ci * Copyright 2014 Cisco Systems, Inc. All rights reserved. 38c2ecf20Sopenharmony_ci * 48c2ecf20Sopenharmony_ci * This program is free software; you may redistribute it and/or modify 58c2ecf20Sopenharmony_ci * it under the terms of the GNU General Public License as published by 68c2ecf20Sopenharmony_ci * the Free Software Foundation; version 2 of the License. 78c2ecf20Sopenharmony_ci * 88c2ecf20Sopenharmony_ci * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 98c2ecf20Sopenharmony_ci * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 108c2ecf20Sopenharmony_ci * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 118c2ecf20Sopenharmony_ci * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 128c2ecf20Sopenharmony_ci * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 138c2ecf20Sopenharmony_ci * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 148c2ecf20Sopenharmony_ci * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 158c2ecf20Sopenharmony_ci * SOFTWARE. 168c2ecf20Sopenharmony_ci */ 178c2ecf20Sopenharmony_ci 188c2ecf20Sopenharmony_ci#ifndef __SNIC_STATS_H 198c2ecf20Sopenharmony_ci#define __SNIC_STATS_H 208c2ecf20Sopenharmony_ci 218c2ecf20Sopenharmony_cistruct snic_io_stats { 228c2ecf20Sopenharmony_ci atomic64_t active; /* Active IOs */ 238c2ecf20Sopenharmony_ci atomic64_t max_active; /* Max # active IOs */ 248c2ecf20Sopenharmony_ci atomic64_t max_sgl; /* Max # SGLs for any IO */ 258c2ecf20Sopenharmony_ci atomic64_t max_time; /* Max time to process IO */ 268c2ecf20Sopenharmony_ci atomic64_t max_qtime; /* Max time to Queue the IO */ 278c2ecf20Sopenharmony_ci atomic64_t max_cmpl_time; /* Max time to complete the IO */ 288c2ecf20Sopenharmony_ci atomic64_t sgl_cnt[SNIC_MAX_SG_DESC_CNT]; /* SGL Counters */ 298c2ecf20Sopenharmony_ci atomic64_t max_io_sz; /* Max IO Size */ 308c2ecf20Sopenharmony_ci atomic64_t compl; /* IO Completions */ 318c2ecf20Sopenharmony_ci atomic64_t fail; /* IO Failures */ 328c2ecf20Sopenharmony_ci atomic64_t req_null; /* req or req info is NULL */ 338c2ecf20Sopenharmony_ci atomic64_t alloc_fail; /* Alloc Failures */ 348c2ecf20Sopenharmony_ci atomic64_t sc_null; 358c2ecf20Sopenharmony_ci atomic64_t io_not_found; /* IO Not Found */ 368c2ecf20Sopenharmony_ci atomic64_t num_ios; /* Number of IOs */ 378c2ecf20Sopenharmony_ci}; 388c2ecf20Sopenharmony_ci 398c2ecf20Sopenharmony_cistruct snic_abort_stats { 408c2ecf20Sopenharmony_ci atomic64_t num; /* Abort counter */ 418c2ecf20Sopenharmony_ci atomic64_t fail; /* Abort Failure Counter */ 428c2ecf20Sopenharmony_ci atomic64_t drv_tmo; /* Abort Driver Timeouts */ 438c2ecf20Sopenharmony_ci atomic64_t fw_tmo; /* Abort Firmware Timeouts */ 448c2ecf20Sopenharmony_ci atomic64_t io_not_found;/* Abort IO Not Found */ 458c2ecf20Sopenharmony_ci atomic64_t q_fail; /* Abort Queuing Failed */ 468c2ecf20Sopenharmony_ci}; 478c2ecf20Sopenharmony_ci 488c2ecf20Sopenharmony_cistruct snic_reset_stats { 498c2ecf20Sopenharmony_ci atomic64_t dev_resets; /* Device Reset Counter */ 508c2ecf20Sopenharmony_ci atomic64_t dev_reset_fail; /* Device Reset Failures */ 518c2ecf20Sopenharmony_ci atomic64_t dev_reset_aborts; /* Device Reset Aborts */ 528c2ecf20Sopenharmony_ci atomic64_t dev_reset_tmo; /* Device Reset Timeout */ 538c2ecf20Sopenharmony_ci atomic64_t dev_reset_terms; /* Device Reset terminate */ 548c2ecf20Sopenharmony_ci atomic64_t hba_resets; /* hba/firmware resets */ 558c2ecf20Sopenharmony_ci atomic64_t hba_reset_cmpl; /* hba/firmware reset completions */ 568c2ecf20Sopenharmony_ci atomic64_t hba_reset_fail; /* hba/firmware failures */ 578c2ecf20Sopenharmony_ci atomic64_t snic_resets; /* snic resets */ 588c2ecf20Sopenharmony_ci atomic64_t snic_reset_compl; /* snic reset completions */ 598c2ecf20Sopenharmony_ci atomic64_t snic_reset_fail; /* snic reset failures */ 608c2ecf20Sopenharmony_ci}; 618c2ecf20Sopenharmony_ci 628c2ecf20Sopenharmony_cistruct snic_fw_stats { 638c2ecf20Sopenharmony_ci atomic64_t actv_reqs; /* Active Requests */ 648c2ecf20Sopenharmony_ci atomic64_t max_actv_reqs; /* Max Active Requests */ 658c2ecf20Sopenharmony_ci atomic64_t out_of_res; /* Firmware Out Of Resources */ 668c2ecf20Sopenharmony_ci atomic64_t io_errs; /* Firmware IO Firmware Errors */ 678c2ecf20Sopenharmony_ci atomic64_t scsi_errs; /* Target hits check condition */ 688c2ecf20Sopenharmony_ci}; 698c2ecf20Sopenharmony_ci 708c2ecf20Sopenharmony_cistruct snic_misc_stats { 718c2ecf20Sopenharmony_ci u64 last_isr_time; 728c2ecf20Sopenharmony_ci u64 last_ack_time; 738c2ecf20Sopenharmony_ci atomic64_t ack_isr_cnt; 748c2ecf20Sopenharmony_ci atomic64_t cmpl_isr_cnt; 758c2ecf20Sopenharmony_ci atomic64_t errnotify_isr_cnt; 768c2ecf20Sopenharmony_ci atomic64_t max_cq_ents; /* Max CQ Entries */ 778c2ecf20Sopenharmony_ci atomic64_t data_cnt_mismat; /* Data Count Mismatch */ 788c2ecf20Sopenharmony_ci atomic64_t io_tmo; 798c2ecf20Sopenharmony_ci atomic64_t io_aborted; 808c2ecf20Sopenharmony_ci atomic64_t sgl_inval; /* SGL Invalid */ 818c2ecf20Sopenharmony_ci atomic64_t abts_wq_alloc_fail; /* Abort Path WQ desc alloc failure */ 828c2ecf20Sopenharmony_ci atomic64_t devrst_wq_alloc_fail;/* Device Reset - WQ desc alloc fail */ 838c2ecf20Sopenharmony_ci atomic64_t wq_alloc_fail; /* IO WQ desc alloc failure */ 848c2ecf20Sopenharmony_ci atomic64_t no_icmnd_itmf_cmpls; 858c2ecf20Sopenharmony_ci atomic64_t io_under_run; 868c2ecf20Sopenharmony_ci atomic64_t qfull; 878c2ecf20Sopenharmony_ci atomic64_t qsz_rampup; 888c2ecf20Sopenharmony_ci atomic64_t qsz_rampdown; 898c2ecf20Sopenharmony_ci atomic64_t last_qsz; 908c2ecf20Sopenharmony_ci atomic64_t tgt_not_rdy; 918c2ecf20Sopenharmony_ci}; 928c2ecf20Sopenharmony_ci 938c2ecf20Sopenharmony_cistruct snic_stats { 948c2ecf20Sopenharmony_ci struct snic_io_stats io; 958c2ecf20Sopenharmony_ci struct snic_abort_stats abts; 968c2ecf20Sopenharmony_ci struct snic_reset_stats reset; 978c2ecf20Sopenharmony_ci struct snic_fw_stats fw; 988c2ecf20Sopenharmony_ci struct snic_misc_stats misc; 998c2ecf20Sopenharmony_ci atomic64_t io_cmpl_skip; 1008c2ecf20Sopenharmony_ci}; 1018c2ecf20Sopenharmony_ci 1028c2ecf20Sopenharmony_civoid snic_stats_debugfs_init(struct snic *); 1038c2ecf20Sopenharmony_civoid snic_stats_debugfs_remove(struct snic *); 1048c2ecf20Sopenharmony_ci 1058c2ecf20Sopenharmony_ci/* Auxillary function to update active IO counter */ 1068c2ecf20Sopenharmony_cistatic inline void 1078c2ecf20Sopenharmony_cisnic_stats_update_active_ios(struct snic_stats *s_stats) 1088c2ecf20Sopenharmony_ci{ 1098c2ecf20Sopenharmony_ci struct snic_io_stats *io = &s_stats->io; 1108c2ecf20Sopenharmony_ci int nr_active_ios; 1118c2ecf20Sopenharmony_ci 1128c2ecf20Sopenharmony_ci nr_active_ios = atomic64_read(&io->active); 1138c2ecf20Sopenharmony_ci if (atomic64_read(&io->max_active) < nr_active_ios) 1148c2ecf20Sopenharmony_ci atomic64_set(&io->max_active, nr_active_ios); 1158c2ecf20Sopenharmony_ci 1168c2ecf20Sopenharmony_ci atomic64_inc(&io->num_ios); 1178c2ecf20Sopenharmony_ci} 1188c2ecf20Sopenharmony_ci 1198c2ecf20Sopenharmony_ci/* Auxillary function to update IO completion counter */ 1208c2ecf20Sopenharmony_cistatic inline void 1218c2ecf20Sopenharmony_cisnic_stats_update_io_cmpl(struct snic_stats *s_stats) 1228c2ecf20Sopenharmony_ci{ 1238c2ecf20Sopenharmony_ci atomic64_dec(&s_stats->io.active); 1248c2ecf20Sopenharmony_ci if (unlikely(atomic64_read(&s_stats->io_cmpl_skip))) 1258c2ecf20Sopenharmony_ci atomic64_dec(&s_stats->io_cmpl_skip); 1268c2ecf20Sopenharmony_ci else 1278c2ecf20Sopenharmony_ci atomic64_inc(&s_stats->io.compl); 1288c2ecf20Sopenharmony_ci} 1298c2ecf20Sopenharmony_ci#endif /* __SNIC_STATS_H */ 130