2 * QLogic iSCSI Offload Driver
3 * Copyright (c) 2016 Cavium Inc.
5 * This software is available under the terms of the GNU General Public License
6 * (GPL) Version 2, available from the file COPYING in the main directory of
13 #include <linux/uaccess.h>
14 #include <linux/debugfs.h>
15 #include <linux/module.h>
17 int qedi_do_not_recover
;
18 static struct dentry
*qedi_dbg_root
;
21 qedi_dbg_host_init(struct qedi_dbg_ctx
*qedi
,
22 const struct qedi_debugfs_ops
*dops
,
23 const struct file_operations
*fops
)
25 char host_dirname
[32];
27 sprintf(host_dirname
, "host%u", qedi
->host_no
);
28 qedi
->bdf_dentry
= debugfs_create_dir(host_dirname
, qedi_dbg_root
);
34 debugfs_create_file(dops
->name
, 0600, qedi
->bdf_dentry
, qedi
,
42 qedi_dbg_host_exit(struct qedi_dbg_ctx
*qedi
)
44 debugfs_remove_recursive(qedi
->bdf_dentry
);
45 qedi
->bdf_dentry
= NULL
;
49 qedi_dbg_init(char *drv_name
)
51 qedi_dbg_root
= debugfs_create_dir(drv_name
, NULL
);
57 debugfs_remove_recursive(qedi_dbg_root
);
62 qedi_dbg_do_not_recover_enable(struct qedi_dbg_ctx
*qedi_dbg
)
64 if (!qedi_do_not_recover
)
65 qedi_do_not_recover
= 1;
67 QEDI_INFO(qedi_dbg
, QEDI_LOG_DEBUGFS
, "do_not_recover=%d\n",
73 qedi_dbg_do_not_recover_disable(struct qedi_dbg_ctx
*qedi_dbg
)
75 if (qedi_do_not_recover
)
76 qedi_do_not_recover
= 0;
78 QEDI_INFO(qedi_dbg
, QEDI_LOG_DEBUGFS
, "do_not_recover=%d\n",
83 static struct qedi_list_of_funcs qedi_dbg_do_not_recover_ops
[] = {
84 { "enable", qedi_dbg_do_not_recover_enable
},
85 { "disable", qedi_dbg_do_not_recover_disable
},
89 const struct qedi_debugfs_ops qedi_debugfs_ops
[] = {
91 { "do_not_recover", qedi_dbg_do_not_recover_ops
},
97 qedi_dbg_do_not_recover_cmd_write(struct file
*filp
, const char __user
*buffer
,
98 size_t count
, loff_t
*ppos
)
101 struct qedi_dbg_ctx
*qedi_dbg
=
102 (struct qedi_dbg_ctx
*)filp
->private_data
;
103 struct qedi_list_of_funcs
*lof
= qedi_dbg_do_not_recover_ops
;
109 if (!(lof
->oper_str
))
112 if (!strncmp(lof
->oper_str
, buffer
, strlen(lof
->oper_str
))) {
113 cnt
= lof
->oper_func(qedi_dbg
);
119 return (count
- cnt
);
123 qedi_dbg_do_not_recover_cmd_read(struct file
*filp
, char __user
*buffer
,
124 size_t count
, loff_t
*ppos
)
131 cnt
= sprintf(buffer
, "do_not_recover=%d\n", qedi_do_not_recover
);
132 cnt
= min_t(int, count
, cnt
- *ppos
);
138 qedi_gbl_ctx_show(struct seq_file
*s
, void *unused
)
140 struct qedi_fastpath
*fp
= NULL
;
141 struct qed_sb_info
*sb_info
= NULL
;
142 struct status_block_e4
*sb
= NULL
;
143 struct global_queue
*que
= NULL
;
146 struct qedi_ctx
*qedi
= s
->private;
149 seq_puts(s
, " DUMP CQ CONTEXT:\n");
151 for (id
= 0; id
< MIN_NUM_CPUS_MSIX(qedi
); id
++) {
152 spin_lock_irqsave(&qedi
->hba_lock
, flags
);
153 seq_printf(s
, "=========FAST CQ PATH [%d] ==========\n", id
);
154 fp
= &qedi
->fp_array
[id
];
155 sb_info
= fp
->sb_info
;
156 sb
= sb_info
->sb_virt
;
157 prod_idx
= (sb
->pi_array
[QEDI_PROTO_CQ_PROD_IDX
] &
158 STATUS_BLOCK_E4_PROD_INDEX_MASK
);
159 seq_printf(s
, "SB PROD IDX: %d\n", prod_idx
);
160 que
= qedi
->global_queues
[fp
->sb_id
];
161 seq_printf(s
, "DRV CONS IDX: %d\n", que
->cq_cons_idx
);
162 seq_printf(s
, "CQ complete host memory: %d\n", fp
->sb_id
);
163 seq_puts(s
, "=========== END ==================\n\n\n");
164 spin_unlock_irqrestore(&qedi
->hba_lock
, flags
);
170 qedi_dbg_gbl_ctx_open(struct inode
*inode
, struct file
*file
)
172 struct qedi_dbg_ctx
*qedi_dbg
= inode
->i_private
;
173 struct qedi_ctx
*qedi
= container_of(qedi_dbg
, struct qedi_ctx
,
176 return single_open(file
, qedi_gbl_ctx_show
, qedi
);
180 qedi_io_trace_show(struct seq_file
*s
, void *unused
)
183 struct qedi_ctx
*qedi
= s
->private;
184 struct qedi_io_log
*io_log
;
187 seq_puts(s
, " DUMP IO LOGS:\n");
188 spin_lock_irqsave(&qedi
->io_trace_lock
, flags
);
189 idx
= qedi
->io_trace_idx
;
190 for (id
= 0; id
< QEDI_IO_TRACE_SIZE
; id
++) {
191 io_log
= &qedi
->io_trace_buf
[idx
];
192 seq_printf(s
, "iodir-%d:", io_log
->direction
);
193 seq_printf(s
, "tid-0x%x:", io_log
->task_id
);
194 seq_printf(s
, "cid-0x%x:", io_log
->cid
);
195 seq_printf(s
, "lun-%d:", io_log
->lun
);
196 seq_printf(s
, "op-0x%02x:", io_log
->op
);
197 seq_printf(s
, "0x%02x%02x%02x%02x:", io_log
->lba
[0],
198 io_log
->lba
[1], io_log
->lba
[2], io_log
->lba
[3]);
199 seq_printf(s
, "buflen-%d:", io_log
->bufflen
);
200 seq_printf(s
, "sgcnt-%d:", io_log
->sg_count
);
201 seq_printf(s
, "res-0x%08x:", io_log
->result
);
202 seq_printf(s
, "jif-%lu:", io_log
->jiffies
);
203 seq_printf(s
, "blk_req_cpu-%d:", io_log
->blk_req_cpu
);
204 seq_printf(s
, "req_cpu-%d:", io_log
->req_cpu
);
205 seq_printf(s
, "intr_cpu-%d:", io_log
->intr_cpu
);
206 seq_printf(s
, "blk_rsp_cpu-%d\n", io_log
->blk_rsp_cpu
);
209 if (idx
== QEDI_IO_TRACE_SIZE
)
212 spin_unlock_irqrestore(&qedi
->io_trace_lock
, flags
);
217 qedi_dbg_io_trace_open(struct inode
*inode
, struct file
*file
)
219 struct qedi_dbg_ctx
*qedi_dbg
= inode
->i_private
;
220 struct qedi_ctx
*qedi
= container_of(qedi_dbg
, struct qedi_ctx
,
223 return single_open(file
, qedi_io_trace_show
, qedi
);
226 const struct file_operations qedi_dbg_fops
[] = {
227 qedi_dbg_fileops_seq(qedi
, gbl_ctx
),
228 qedi_dbg_fileops(qedi
, do_not_recover
),
229 qedi_dbg_fileops_seq(qedi
, io_trace
),