2 * QLogic Fibre Channel HBA Driver
3 * Copyright (c) 2003-2014 QLogic Corporation
5 * See LICENSE.qla2xxx for copyright and licensing details.
9 #include <linux/debugfs.h>
10 #include <linux/seq_file.h>
12 static struct dentry
*qla2x00_dfs_root
;
13 static atomic_t qla2x00_dfs_root_count
;
16 qla_dfs_tgt_counters_show(struct seq_file
*s
, void *unused
)
18 struct scsi_qla_host
*vha
= s
->private;
20 seq_puts(s
, "Target Counters\n");
21 seq_printf(s
, "qla_core_sbt_cmd = %lld\n",
22 vha
->tgt_counters
.qla_core_sbt_cmd
);
23 seq_printf(s
, "qla_core_ret_sta_ctio = %lld\n",
24 vha
->tgt_counters
.qla_core_ret_sta_ctio
);
25 seq_printf(s
, "qla_core_ret_ctio = %lld\n",
26 vha
->tgt_counters
.qla_core_ret_ctio
);
27 seq_printf(s
, "core_qla_que_buf = %lld\n",
28 vha
->tgt_counters
.core_qla_que_buf
);
29 seq_printf(s
, "core_qla_snd_status = %lld\n",
30 vha
->tgt_counters
.core_qla_snd_status
);
31 seq_printf(s
, "core_qla_free_cmd = %lld\n",
32 vha
->tgt_counters
.core_qla_free_cmd
);
33 seq_printf(s
, "num alloc iocb failed = %lld\n",
34 vha
->tgt_counters
.num_alloc_iocb_failed
);
35 seq_printf(s
, "num term exchange sent = %lld\n",
36 vha
->tgt_counters
.num_term_xchg_sent
);
37 seq_printf(s
, "num Q full sent = %lld\n",
38 vha
->tgt_counters
.num_q_full_sent
);
44 qla_dfs_tgt_counters_open(struct inode
*inode
, struct file
*file
)
46 struct scsi_qla_host
*vha
= inode
->i_private
;
47 return single_open(file
, qla_dfs_tgt_counters_show
, vha
);
50 static const struct file_operations dfs_tgt_counters_ops
= {
51 .open
= qla_dfs_tgt_counters_open
,
54 .release
= single_release
,
58 qla2x00_dfs_fce_show(struct seq_file
*s
, void *unused
)
60 scsi_qla_host_t
*vha
= s
->private;
64 struct qla_hw_data
*ha
= vha
->hw
;
66 mutex_lock(&ha
->fce_mutex
);
68 seq_puts(s
, "FCE Trace Buffer\n");
69 seq_printf(s
, "In Pointer = %llx\n\n", (unsigned long long)ha
->fce_wr
);
70 seq_printf(s
, "Base = %llx\n\n", (unsigned long long) ha
->fce_dma
);
71 seq_puts(s
, "FCE Enable Registers\n");
72 seq_printf(s
, "%08x %08x %08x %08x %08x %08x\n",
73 ha
->fce_mb
[0], ha
->fce_mb
[2], ha
->fce_mb
[3], ha
->fce_mb
[4],
74 ha
->fce_mb
[5], ha
->fce_mb
[6]);
76 fce
= (uint32_t *) ha
->fce
;
77 fce_start
= (unsigned long long) ha
->fce_dma
;
78 for (cnt
= 0; cnt
< fce_calc_size(ha
->fce_bufs
) / 4; cnt
++) {
80 seq_printf(s
, "\n%llx: ",
81 (unsigned long long)((cnt
* 4) + fce_start
));
84 seq_printf(s
, "%08x", *fce
++);
87 seq_puts(s
, "\nEnd\n");
89 mutex_unlock(&ha
->fce_mutex
);
95 qla2x00_dfs_fce_open(struct inode
*inode
, struct file
*file
)
97 scsi_qla_host_t
*vha
= inode
->i_private
;
98 struct qla_hw_data
*ha
= vha
->hw
;
101 if (!ha
->flags
.fce_enabled
)
104 mutex_lock(&ha
->fce_mutex
);
106 /* Pause tracing to flush FCE buffers. */
107 rval
= qla2x00_disable_fce_trace(vha
, &ha
->fce_wr
, &ha
->fce_rd
);
109 ql_dbg(ql_dbg_user
, vha
, 0x705c,
110 "DebugFS: Unable to disable FCE (%d).\n", rval
);
112 ha
->flags
.fce_enabled
= 0;
114 mutex_unlock(&ha
->fce_mutex
);
116 return single_open(file
, qla2x00_dfs_fce_show
, vha
);
120 qla2x00_dfs_fce_release(struct inode
*inode
, struct file
*file
)
122 scsi_qla_host_t
*vha
= inode
->i_private
;
123 struct qla_hw_data
*ha
= vha
->hw
;
126 if (ha
->flags
.fce_enabled
)
129 mutex_lock(&ha
->fce_mutex
);
131 /* Re-enable FCE tracing. */
132 ha
->flags
.fce_enabled
= 1;
133 memset(ha
->fce
, 0, fce_calc_size(ha
->fce_bufs
));
134 rval
= qla2x00_enable_fce_trace(vha
, ha
->fce_dma
, ha
->fce_bufs
,
135 ha
->fce_mb
, &ha
->fce_bufs
);
137 ql_dbg(ql_dbg_user
, vha
, 0x700d,
138 "DebugFS: Unable to reinitialize FCE (%d).\n", rval
);
139 ha
->flags
.fce_enabled
= 0;
142 mutex_unlock(&ha
->fce_mutex
);
144 return single_release(inode
, file
);
147 static const struct file_operations dfs_fce_ops
= {
148 .open
= qla2x00_dfs_fce_open
,
151 .release
= qla2x00_dfs_fce_release
,
155 qla2x00_dfs_setup(scsi_qla_host_t
*vha
)
157 struct qla_hw_data
*ha
= vha
->hw
;
159 if (!IS_QLA25XX(ha
) && !IS_QLA81XX(ha
) && !IS_QLA83XX(ha
) &&
165 if (qla2x00_dfs_root
)
168 atomic_set(&qla2x00_dfs_root_count
, 0);
169 qla2x00_dfs_root
= debugfs_create_dir(QLA2XXX_DRIVER_NAME
, NULL
);
170 if (!qla2x00_dfs_root
) {
171 ql_log(ql_log_warn
, vha
, 0x00f7,
172 "Unable to create debugfs root directory.\n");
180 mutex_init(&ha
->fce_mutex
);
181 ha
->dfs_dir
= debugfs_create_dir(vha
->host_str
, qla2x00_dfs_root
);
183 ql_log(ql_log_warn
, vha
, 0x00f8,
184 "Unable to create debugfs ha directory.\n");
188 atomic_inc(&qla2x00_dfs_root_count
);
191 ha
->dfs_tgt_counters
= debugfs_create_file("tgt_counters", S_IRUSR
,
192 ha
->dfs_dir
, vha
, &dfs_tgt_counters_ops
);
193 if (!ha
->dfs_tgt_counters
) {
194 ql_log(ql_log_warn
, vha
, 0xd301,
195 "Unable to create debugFS tgt_counters node.\n");
199 ha
->dfs_fce
= debugfs_create_file("fce", S_IRUSR
, ha
->dfs_dir
, vha
,
202 ql_log(ql_log_warn
, vha
, 0x00f9,
203 "Unable to create debugfs fce node.\n");
211 qla2x00_dfs_remove(scsi_qla_host_t
*vha
)
213 struct qla_hw_data
*ha
= vha
->hw
;
215 if (ha
->dfs_tgt_counters
) {
216 debugfs_remove(ha
->dfs_tgt_counters
);
217 ha
->dfs_tgt_counters
= NULL
;
221 debugfs_remove(ha
->dfs_fce
);
226 debugfs_remove(ha
->dfs_dir
);
228 atomic_dec(&qla2x00_dfs_root_count
);
231 if (atomic_read(&qla2x00_dfs_root_count
) == 0 &&
233 debugfs_remove(qla2x00_dfs_root
);
234 qla2x00_dfs_root
= NULL
;