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 qla2x00_dfs_tgt_sess_show(struct seq_file
*s
, void *unused
)
18 scsi_qla_host_t
*vha
= s
->private;
19 struct qla_hw_data
*ha
= vha
->hw
;
21 struct fc_port
*sess
= NULL
;
22 struct qla_tgt
*tgt
= vha
->vha_tgt
.qla_tgt
;
24 seq_printf(s
, "%s\n", vha
->host_str
);
26 seq_puts(s
, "Port ID Port Name Handle\n");
28 spin_lock_irqsave(&ha
->tgt
.sess_lock
, flags
);
29 list_for_each_entry(sess
, &vha
->vp_fcports
, list
)
30 seq_printf(s
, "%02x:%02x:%02x %8phC %d\n",
31 sess
->d_id
.b
.domain
, sess
->d_id
.b
.area
,
32 sess
->d_id
.b
.al_pa
, sess
->port_name
,
34 spin_unlock_irqrestore(&ha
->tgt
.sess_lock
, flags
);
41 qla2x00_dfs_tgt_sess_open(struct inode
*inode
, struct file
*file
)
43 scsi_qla_host_t
*vha
= inode
->i_private
;
44 return single_open(file
, qla2x00_dfs_tgt_sess_show
, vha
);
47 static const struct file_operations dfs_tgt_sess_ops
= {
48 .open
= qla2x00_dfs_tgt_sess_open
,
51 .release
= single_release
,
55 qla2x00_dfs_tgt_port_database_show(struct seq_file
*s
, void *unused
)
57 scsi_qla_host_t
*vha
= s
->private;
58 struct qla_hw_data
*ha
= vha
->hw
;
59 struct gid_list_info
*gid_list
;
60 dma_addr_t gid_list_dma
;
64 uint16_t entries
, loop_id
;
65 struct qla_tgt
*tgt
= vha
->vha_tgt
.qla_tgt
;
67 seq_printf(s
, "%s\n", vha
->host_str
);
69 gid_list
= dma_alloc_coherent(&ha
->pdev
->dev
,
70 qla2x00_gid_list_size(ha
),
71 &gid_list_dma
, GFP_KERNEL
);
73 ql_dbg(ql_dbg_user
, vha
, 0x705c,
74 "DMA allocation failed for %u\n",
75 qla2x00_gid_list_size(ha
));
79 rc
= qla24xx_gidlist_wait(vha
, gid_list
, gid_list_dma
,
81 if (rc
!= QLA_SUCCESS
)
82 goto out_free_id_list
;
84 id_iter
= (char *)gid_list
;
86 seq_puts(s
, "Port Name Port ID Loop ID\n");
88 for (i
= 0; i
< entries
; i
++) {
89 struct gid_list_info
*gid
=
90 (struct gid_list_info
*)id_iter
;
91 loop_id
= le16_to_cpu(gid
->loop_id
);
92 memset(&fc_port
, 0, sizeof(fc_port_t
));
94 fc_port
.loop_id
= loop_id
;
96 rc
= qla24xx_gpdb_wait(vha
, &fc_port
, 0);
97 seq_printf(s
, "%8phC %02x%02x%02x %d\n",
98 fc_port
.port_name
, fc_port
.d_id
.b
.domain
,
99 fc_port
.d_id
.b
.area
, fc_port
.d_id
.b
.al_pa
,
101 id_iter
+= ha
->gid_list_info_size
;
104 dma_free_coherent(&ha
->pdev
->dev
, qla2x00_gid_list_size(ha
),
105 gid_list
, gid_list_dma
);
112 qla2x00_dfs_tgt_port_database_open(struct inode
*inode
, struct file
*file
)
114 scsi_qla_host_t
*vha
= inode
->i_private
;
116 return single_open(file
, qla2x00_dfs_tgt_port_database_show
, vha
);
119 static const struct file_operations dfs_tgt_port_database_ops
= {
120 .open
= qla2x00_dfs_tgt_port_database_open
,
123 .release
= single_release
,
127 qla_dfs_fw_resource_cnt_show(struct seq_file
*s
, void *unused
)
129 struct scsi_qla_host
*vha
= s
->private;
130 struct qla_hw_data
*ha
= vha
->hw
;
132 seq_puts(s
, "FW Resource count\n\n");
133 seq_printf(s
, "Original TGT exchg count[%d]\n",
134 ha
->orig_fw_tgt_xcb_count
);
135 seq_printf(s
, "current TGT exchg count[%d]\n",
136 ha
->cur_fw_tgt_xcb_count
);
137 seq_printf(s
, "original Initiator Exchange count[%d]\n",
138 ha
->orig_fw_xcb_count
);
139 seq_printf(s
, "Current Initiator Exchange count[%d]\n",
140 ha
->cur_fw_xcb_count
);
141 seq_printf(s
, "Original IOCB count[%d]\n", ha
->orig_fw_iocb_count
);
142 seq_printf(s
, "Current IOCB count[%d]\n", ha
->cur_fw_iocb_count
);
143 seq_printf(s
, "MAX VP count[%d]\n", ha
->max_npiv_vports
);
144 seq_printf(s
, "MAX FCF count[%d]\n", ha
->fw_max_fcf_count
);
150 qla_dfs_fw_resource_cnt_open(struct inode
*inode
, struct file
*file
)
152 struct scsi_qla_host
*vha
= inode
->i_private
;
153 return single_open(file
, qla_dfs_fw_resource_cnt_show
, vha
);
156 static const struct file_operations dfs_fw_resource_cnt_ops
= {
157 .open
= qla_dfs_fw_resource_cnt_open
,
160 .release
= single_release
,
164 qla_dfs_tgt_counters_show(struct seq_file
*s
, void *unused
)
166 struct scsi_qla_host
*vha
= s
->private;
168 seq_puts(s
, "Target Counters\n");
169 seq_printf(s
, "qla_core_sbt_cmd = %lld\n",
170 vha
->tgt_counters
.qla_core_sbt_cmd
);
171 seq_printf(s
, "qla_core_ret_sta_ctio = %lld\n",
172 vha
->tgt_counters
.qla_core_ret_sta_ctio
);
173 seq_printf(s
, "qla_core_ret_ctio = %lld\n",
174 vha
->tgt_counters
.qla_core_ret_ctio
);
175 seq_printf(s
, "core_qla_que_buf = %lld\n",
176 vha
->tgt_counters
.core_qla_que_buf
);
177 seq_printf(s
, "core_qla_snd_status = %lld\n",
178 vha
->tgt_counters
.core_qla_snd_status
);
179 seq_printf(s
, "core_qla_free_cmd = %lld\n",
180 vha
->tgt_counters
.core_qla_free_cmd
);
181 seq_printf(s
, "num alloc iocb failed = %lld\n",
182 vha
->tgt_counters
.num_alloc_iocb_failed
);
183 seq_printf(s
, "num term exchange sent = %lld\n",
184 vha
->tgt_counters
.num_term_xchg_sent
);
185 seq_printf(s
, "num Q full sent = %lld\n",
186 vha
->tgt_counters
.num_q_full_sent
);
189 seq_printf(s
, "DIF Inp Bytes = %lld\n",
190 vha
->qla_stats
.qla_dif_stats
.dif_input_bytes
);
191 seq_printf(s
, "DIF Outp Bytes = %lld\n",
192 vha
->qla_stats
.qla_dif_stats
.dif_output_bytes
);
193 seq_printf(s
, "DIF Inp Req = %lld\n",
194 vha
->qla_stats
.qla_dif_stats
.dif_input_requests
);
195 seq_printf(s
, "DIF Outp Req = %lld\n",
196 vha
->qla_stats
.qla_dif_stats
.dif_output_requests
);
197 seq_printf(s
, "DIF Guard err = %d\n",
198 vha
->qla_stats
.qla_dif_stats
.dif_guard_err
);
199 seq_printf(s
, "DIF Ref tag err = %d\n",
200 vha
->qla_stats
.qla_dif_stats
.dif_ref_tag_err
);
201 seq_printf(s
, "DIF App tag err = %d\n",
202 vha
->qla_stats
.qla_dif_stats
.dif_app_tag_err
);
207 qla_dfs_tgt_counters_open(struct inode
*inode
, struct file
*file
)
209 struct scsi_qla_host
*vha
= inode
->i_private
;
210 return single_open(file
, qla_dfs_tgt_counters_show
, vha
);
213 static const struct file_operations dfs_tgt_counters_ops
= {
214 .open
= qla_dfs_tgt_counters_open
,
217 .release
= single_release
,
221 qla2x00_dfs_fce_show(struct seq_file
*s
, void *unused
)
223 scsi_qla_host_t
*vha
= s
->private;
227 struct qla_hw_data
*ha
= vha
->hw
;
229 mutex_lock(&ha
->fce_mutex
);
231 seq_puts(s
, "FCE Trace Buffer\n");
232 seq_printf(s
, "In Pointer = %llx\n\n", (unsigned long long)ha
->fce_wr
);
233 seq_printf(s
, "Base = %llx\n\n", (unsigned long long) ha
->fce_dma
);
234 seq_puts(s
, "FCE Enable Registers\n");
235 seq_printf(s
, "%08x %08x %08x %08x %08x %08x\n",
236 ha
->fce_mb
[0], ha
->fce_mb
[2], ha
->fce_mb
[3], ha
->fce_mb
[4],
237 ha
->fce_mb
[5], ha
->fce_mb
[6]);
239 fce
= (uint32_t *) ha
->fce
;
240 fce_start
= (unsigned long long) ha
->fce_dma
;
241 for (cnt
= 0; cnt
< fce_calc_size(ha
->fce_bufs
) / 4; cnt
++) {
243 seq_printf(s
, "\n%llx: ",
244 (unsigned long long)((cnt
* 4) + fce_start
));
247 seq_printf(s
, "%08x", *fce
++);
250 seq_puts(s
, "\nEnd\n");
252 mutex_unlock(&ha
->fce_mutex
);
258 qla2x00_dfs_fce_open(struct inode
*inode
, struct file
*file
)
260 scsi_qla_host_t
*vha
= inode
->i_private
;
261 struct qla_hw_data
*ha
= vha
->hw
;
264 if (!ha
->flags
.fce_enabled
)
267 mutex_lock(&ha
->fce_mutex
);
269 /* Pause tracing to flush FCE buffers. */
270 rval
= qla2x00_disable_fce_trace(vha
, &ha
->fce_wr
, &ha
->fce_rd
);
272 ql_dbg(ql_dbg_user
, vha
, 0x705c,
273 "DebugFS: Unable to disable FCE (%d).\n", rval
);
275 ha
->flags
.fce_enabled
= 0;
277 mutex_unlock(&ha
->fce_mutex
);
279 return single_open(file
, qla2x00_dfs_fce_show
, vha
);
283 qla2x00_dfs_fce_release(struct inode
*inode
, struct file
*file
)
285 scsi_qla_host_t
*vha
= inode
->i_private
;
286 struct qla_hw_data
*ha
= vha
->hw
;
289 if (ha
->flags
.fce_enabled
)
292 mutex_lock(&ha
->fce_mutex
);
294 /* Re-enable FCE tracing. */
295 ha
->flags
.fce_enabled
= 1;
296 memset(ha
->fce
, 0, fce_calc_size(ha
->fce_bufs
));
297 rval
= qla2x00_enable_fce_trace(vha
, ha
->fce_dma
, ha
->fce_bufs
,
298 ha
->fce_mb
, &ha
->fce_bufs
);
300 ql_dbg(ql_dbg_user
, vha
, 0x700d,
301 "DebugFS: Unable to reinitialize FCE (%d).\n", rval
);
302 ha
->flags
.fce_enabled
= 0;
305 mutex_unlock(&ha
->fce_mutex
);
307 return single_release(inode
, file
);
310 static const struct file_operations dfs_fce_ops
= {
311 .open
= qla2x00_dfs_fce_open
,
314 .release
= qla2x00_dfs_fce_release
,
318 qla2x00_dfs_setup(scsi_qla_host_t
*vha
)
320 struct qla_hw_data
*ha
= vha
->hw
;
322 if (!IS_QLA25XX(ha
) && !IS_QLA81XX(ha
) && !IS_QLA83XX(ha
) &&
328 if (qla2x00_dfs_root
)
331 atomic_set(&qla2x00_dfs_root_count
, 0);
332 qla2x00_dfs_root
= debugfs_create_dir(QLA2XXX_DRIVER_NAME
, NULL
);
333 if (!qla2x00_dfs_root
) {
334 ql_log(ql_log_warn
, vha
, 0x00f7,
335 "Unable to create debugfs root directory.\n");
343 mutex_init(&ha
->fce_mutex
);
344 ha
->dfs_dir
= debugfs_create_dir(vha
->host_str
, qla2x00_dfs_root
);
346 ql_log(ql_log_warn
, vha
, 0x00f8,
347 "Unable to create debugfs ha directory.\n");
351 atomic_inc(&qla2x00_dfs_root_count
);
354 ha
->dfs_fw_resource_cnt
= debugfs_create_file("fw_resource_count",
355 S_IRUSR
, ha
->dfs_dir
, vha
, &dfs_fw_resource_cnt_ops
);
356 if (!ha
->dfs_fw_resource_cnt
) {
357 ql_log(ql_log_warn
, vha
, 0x00fd,
358 "Unable to create debugFS fw_resource_count node.\n");
362 ha
->dfs_tgt_counters
= debugfs_create_file("tgt_counters", S_IRUSR
,
363 ha
->dfs_dir
, vha
, &dfs_tgt_counters_ops
);
364 if (!ha
->dfs_tgt_counters
) {
365 ql_log(ql_log_warn
, vha
, 0xd301,
366 "Unable to create debugFS tgt_counters node.\n");
370 ha
->tgt
.dfs_tgt_port_database
= debugfs_create_file("tgt_port_database",
371 S_IRUSR
, ha
->dfs_dir
, vha
, &dfs_tgt_port_database_ops
);
372 if (!ha
->tgt
.dfs_tgt_port_database
) {
373 ql_log(ql_log_warn
, vha
, 0xffff,
374 "Unable to create debugFS tgt_port_database node.\n");
378 ha
->dfs_fce
= debugfs_create_file("fce", S_IRUSR
, ha
->dfs_dir
, vha
,
381 ql_log(ql_log_warn
, vha
, 0x00f9,
382 "Unable to create debugfs fce node.\n");
386 ha
->tgt
.dfs_tgt_sess
= debugfs_create_file("tgt_sess",
387 S_IRUSR
, ha
->dfs_dir
, vha
, &dfs_tgt_sess_ops
);
388 if (!ha
->tgt
.dfs_tgt_sess
) {
389 ql_log(ql_log_warn
, vha
, 0xffff,
390 "Unable to create debugFS tgt_sess node.\n");
399 qla2x00_dfs_remove(scsi_qla_host_t
*vha
)
401 struct qla_hw_data
*ha
= vha
->hw
;
403 if (ha
->tgt
.dfs_tgt_sess
) {
404 debugfs_remove(ha
->tgt
.dfs_tgt_sess
);
405 ha
->tgt
.dfs_tgt_sess
= NULL
;
408 if (ha
->tgt
.dfs_tgt_port_database
) {
409 debugfs_remove(ha
->tgt
.dfs_tgt_port_database
);
410 ha
->tgt
.dfs_tgt_port_database
= NULL
;
413 if (ha
->dfs_fw_resource_cnt
) {
414 debugfs_remove(ha
->dfs_fw_resource_cnt
);
415 ha
->dfs_fw_resource_cnt
= NULL
;
418 if (ha
->dfs_tgt_counters
) {
419 debugfs_remove(ha
->dfs_tgt_counters
);
420 ha
->dfs_tgt_counters
= NULL
;
424 debugfs_remove(ha
->dfs_fce
);
429 debugfs_remove(ha
->dfs_dir
);
431 atomic_dec(&qla2x00_dfs_root_count
);
434 if (atomic_read(&qla2x00_dfs_root_count
) == 0 &&
436 debugfs_remove(qla2x00_dfs_root
);
437 qla2x00_dfs_root
= NULL
;