ocfs2: fix several issues of append dio
[linux/fpc-iii.git] / drivers / scsi / snic / snic_stats.h
blob11e614849a8219b7c2b1932668fe61c885306763
1 /*
2 * Copyright 2014 Cisco Systems, Inc. All rights reserved.
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.
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.
18 #ifndef __SNIC_STATS_H
19 #define __SNIC_STATS_H
21 struct snic_io_stats {
22 atomic64_t active; /* Active IOs */
23 atomic64_t max_active; /* Max # active IOs */
24 atomic64_t max_sgl; /* Max # SGLs for any IO */
25 atomic64_t max_time; /* Max time to process IO */
26 atomic64_t max_qtime; /* Max time to Queue the IO */
27 atomic64_t max_cmpl_time; /* Max time to complete the IO */
28 atomic64_t sgl_cnt[SNIC_MAX_SG_DESC_CNT]; /* SGL Counters */
29 atomic64_t max_io_sz; /* Max IO Size */
30 atomic64_t compl; /* IO Completions */
31 atomic64_t fail; /* IO Failures */
32 atomic64_t req_null; /* req or req info is NULL */
33 atomic64_t alloc_fail; /* Alloc Failures */
34 atomic64_t sc_null;
35 atomic64_t io_not_found; /* IO Not Found */
36 atomic64_t num_ios; /* Number of IOs */
39 struct snic_abort_stats {
40 atomic64_t num; /* Abort counter */
41 atomic64_t fail; /* Abort Failure Counter */
42 atomic64_t drv_tmo; /* Abort Driver Timeouts */
43 atomic64_t fw_tmo; /* Abort Firmware Timeouts */
44 atomic64_t io_not_found;/* Abort IO Not Found */
47 struct snic_reset_stats {
48 atomic64_t dev_resets; /* Device Reset Counter */
49 atomic64_t dev_reset_fail; /* Device Reset Failures */
50 atomic64_t dev_reset_aborts; /* Device Reset Aborts */
51 atomic64_t dev_reset_tmo; /* Device Reset Timeout */
52 atomic64_t dev_reset_terms; /* Device Reset terminate */
53 atomic64_t hba_resets; /* hba/firmware resets */
54 atomic64_t hba_reset_cmpl; /* hba/firmware reset completions */
55 atomic64_t hba_reset_fail; /* hba/firmware failures */
56 atomic64_t snic_resets; /* snic resets */
57 atomic64_t snic_reset_compl; /* snic reset completions */
58 atomic64_t snic_reset_fail; /* snic reset failures */
61 struct snic_fw_stats {
62 atomic64_t actv_reqs; /* Active Requests */
63 atomic64_t max_actv_reqs; /* Max Active Requests */
64 atomic64_t out_of_res; /* Firmware Out Of Resources */
65 atomic64_t io_errs; /* Firmware IO Firmware Errors */
66 atomic64_t scsi_errs; /* Target hits check condition */
69 struct snic_misc_stats {
70 u64 last_isr_time;
71 u64 last_ack_time;
72 atomic64_t isr_cnt;
73 atomic64_t max_cq_ents; /* Max CQ Entries */
74 atomic64_t data_cnt_mismat; /* Data Count Mismatch */
75 atomic64_t io_tmo;
76 atomic64_t io_aborted;
77 atomic64_t sgl_inval; /* SGL Invalid */
78 atomic64_t abts_wq_alloc_fail; /* Abort Path WQ desc alloc failure */
79 atomic64_t devrst_wq_alloc_fail;/* Device Reset - WQ desc alloc fail */
80 atomic64_t wq_alloc_fail; /* IO WQ desc alloc failure */
81 atomic64_t no_icmnd_itmf_cmpls;
82 atomic64_t io_under_run;
83 atomic64_t qfull;
84 atomic64_t tgt_not_rdy;
87 struct snic_stats {
88 struct snic_io_stats io;
89 struct snic_abort_stats abts;
90 struct snic_reset_stats reset;
91 struct snic_fw_stats fw;
92 struct snic_misc_stats misc;
93 atomic64_t io_cmpl_skip;
96 int snic_stats_debugfs_init(struct snic *);
97 void snic_stats_debugfs_remove(struct snic *);
99 /* Auxillary function to update active IO counter */
100 static inline void
101 snic_stats_update_active_ios(struct snic_stats *s_stats)
103 struct snic_io_stats *io = &s_stats->io;
104 u32 nr_active_ios;
106 nr_active_ios = atomic64_inc_return(&io->active);
107 if (atomic64_read(&io->max_active) < nr_active_ios)
108 atomic64_set(&io->max_active, nr_active_ios);
110 atomic64_inc(&io->num_ios);
113 /* Auxillary function to update IO completion counter */
114 static inline void
115 snic_stats_update_io_cmpl(struct snic_stats *s_stats)
117 atomic64_dec(&s_stats->io.active);
118 if (unlikely(atomic64_read(&s_stats->io_cmpl_skip)))
119 atomic64_dec(&s_stats->io_cmpl_skip);
120 else
121 atomic64_inc(&s_stats->io.compl);
123 #endif /* __SNIC_STATS_H */