161d8658bSDupuis, Chad /* 261d8658bSDupuis, Chad * QLogic FCoE Offload Driver 35d1c8b5bSChad Dupuis * Copyright (c) 2016-2018 QLogic Corporation 461d8658bSDupuis, Chad * 561d8658bSDupuis, Chad * This software is available under the terms of the GNU General Public License 661d8658bSDupuis, Chad * (GPL) Version 2, available from the file COPYING in the main directory of 761d8658bSDupuis, Chad * this source tree. 861d8658bSDupuis, Chad */ 961d8658bSDupuis, Chad #ifdef CONFIG_DEBUG_FS 1061d8658bSDupuis, Chad 1161d8658bSDupuis, Chad #include <linux/uaccess.h> 1261d8658bSDupuis, Chad #include <linux/debugfs.h> 1361d8658bSDupuis, Chad #include <linux/module.h> 1461d8658bSDupuis, Chad 1561d8658bSDupuis, Chad #include "qedf.h" 1661d8658bSDupuis, Chad #include "qedf_dbg.h" 1761d8658bSDupuis, Chad 1861d8658bSDupuis, Chad static struct dentry *qedf_dbg_root; 1961d8658bSDupuis, Chad 2061d8658bSDupuis, Chad /** 2161d8658bSDupuis, Chad * qedf_dbg_host_init - setup the debugfs file for the pf 2261d8658bSDupuis, Chad * @pf: the pf that is starting up 2361d8658bSDupuis, Chad **/ 2461d8658bSDupuis, Chad void 2561d8658bSDupuis, Chad qedf_dbg_host_init(struct qedf_dbg_ctx *qedf, 26d9ea463aSArnd Bergmann const struct qedf_debugfs_ops *dops, 27d9ea463aSArnd Bergmann const struct file_operations *fops) 2861d8658bSDupuis, Chad { 2961d8658bSDupuis, Chad char host_dirname[32]; 3061d8658bSDupuis, Chad 3161d8658bSDupuis, Chad QEDF_INFO(qedf, QEDF_LOG_DEBUGFS, "Creating debugfs host node\n"); 3261d8658bSDupuis, Chad /* create pf dir */ 3361d8658bSDupuis, Chad sprintf(host_dirname, "host%u", qedf->host_no); 3461d8658bSDupuis, Chad qedf->bdf_dentry = debugfs_create_dir(host_dirname, qedf_dbg_root); 3561d8658bSDupuis, Chad 3661d8658bSDupuis, Chad /* create debugfs files */ 3761d8658bSDupuis, Chad while (dops) { 3861d8658bSDupuis, Chad if (!(dops->name)) 3961d8658bSDupuis, Chad break; 4061d8658bSDupuis, Chad 41*26febfb3SGreg Kroah-Hartman debugfs_create_file(dops->name, 0600, qedf->bdf_dentry, qedf, 4261d8658bSDupuis, Chad fops); 4361d8658bSDupuis, Chad dops++; 4461d8658bSDupuis, Chad fops++; 4561d8658bSDupuis, Chad } 4661d8658bSDupuis, Chad } 4761d8658bSDupuis, Chad 4861d8658bSDupuis, Chad /** 4961d8658bSDupuis, Chad * qedf_dbg_host_exit - clear out the pf's debugfs entries 5061d8658bSDupuis, Chad * @pf: the pf that is stopping 5161d8658bSDupuis, Chad **/ 5261d8658bSDupuis, Chad void 5361d8658bSDupuis, Chad qedf_dbg_host_exit(struct qedf_dbg_ctx *qedf) 5461d8658bSDupuis, Chad { 5561d8658bSDupuis, Chad QEDF_INFO(qedf, QEDF_LOG_DEBUGFS, "Destroying debugfs host " 5661d8658bSDupuis, Chad "entry\n"); 5761d8658bSDupuis, Chad /* remove debugfs entries of this PF */ 5861d8658bSDupuis, Chad debugfs_remove_recursive(qedf->bdf_dentry); 5961d8658bSDupuis, Chad qedf->bdf_dentry = NULL; 6061d8658bSDupuis, Chad } 6161d8658bSDupuis, Chad 6261d8658bSDupuis, Chad /** 6361d8658bSDupuis, Chad * qedf_dbg_init - start up debugfs for the driver 6461d8658bSDupuis, Chad **/ 6561d8658bSDupuis, Chad void 6661d8658bSDupuis, Chad qedf_dbg_init(char *drv_name) 6761d8658bSDupuis, Chad { 6861d8658bSDupuis, Chad QEDF_INFO(NULL, QEDF_LOG_DEBUGFS, "Creating debugfs root node\n"); 6961d8658bSDupuis, Chad 7061d8658bSDupuis, Chad /* create qed dir in root of debugfs. NULL means debugfs root */ 7161d8658bSDupuis, Chad qedf_dbg_root = debugfs_create_dir(drv_name, NULL); 7261d8658bSDupuis, Chad } 7361d8658bSDupuis, Chad 7461d8658bSDupuis, Chad /** 7561d8658bSDupuis, Chad * qedf_dbg_exit - clean out the driver's debugfs entries 7661d8658bSDupuis, Chad **/ 7761d8658bSDupuis, Chad void 7861d8658bSDupuis, Chad qedf_dbg_exit(void) 7961d8658bSDupuis, Chad { 8061d8658bSDupuis, Chad QEDF_INFO(NULL, QEDF_LOG_DEBUGFS, "Destroying debugfs root " 8161d8658bSDupuis, Chad "entry\n"); 8261d8658bSDupuis, Chad 8361d8658bSDupuis, Chad /* remove qed dir in root of debugfs */ 8461d8658bSDupuis, Chad debugfs_remove_recursive(qedf_dbg_root); 8561d8658bSDupuis, Chad qedf_dbg_root = NULL; 8661d8658bSDupuis, Chad } 8761d8658bSDupuis, Chad 88d9ea463aSArnd Bergmann const struct qedf_debugfs_ops qedf_debugfs_ops[] = { 8961d8658bSDupuis, Chad { "fp_int", NULL }, 9061d8658bSDupuis, Chad { "io_trace", NULL }, 9161d8658bSDupuis, Chad { "debug", NULL }, 9261d8658bSDupuis, Chad { "stop_io_on_error", NULL}, 9361d8658bSDupuis, Chad { "driver_stats", NULL}, 9461d8658bSDupuis, Chad { "clear_stats", NULL}, 9561d8658bSDupuis, Chad { "offload_stats", NULL}, 9661d8658bSDupuis, Chad /* This must be last */ 9761d8658bSDupuis, Chad { NULL, NULL } 9861d8658bSDupuis, Chad }; 9961d8658bSDupuis, Chad 10061d8658bSDupuis, Chad DECLARE_PER_CPU(struct qedf_percpu_iothread_s, qedf_percpu_iothreads); 10161d8658bSDupuis, Chad 10261d8658bSDupuis, Chad static ssize_t 10361d8658bSDupuis, Chad qedf_dbg_fp_int_cmd_read(struct file *filp, char __user *buffer, size_t count, 10461d8658bSDupuis, Chad loff_t *ppos) 10561d8658bSDupuis, Chad { 10661d8658bSDupuis, Chad size_t cnt = 0; 10761d8658bSDupuis, Chad int id; 10861d8658bSDupuis, Chad struct qedf_fastpath *fp = NULL; 10961d8658bSDupuis, Chad struct qedf_dbg_ctx *qedf_dbg = 11061d8658bSDupuis, Chad (struct qedf_dbg_ctx *)filp->private_data; 11161d8658bSDupuis, Chad struct qedf_ctx *qedf = container_of(qedf_dbg, 11261d8658bSDupuis, Chad struct qedf_ctx, dbg_ctx); 11361d8658bSDupuis, Chad 11461d8658bSDupuis, Chad QEDF_INFO(qedf_dbg, QEDF_LOG_DEBUGFS, "entered\n"); 11561d8658bSDupuis, Chad 11661d8658bSDupuis, Chad cnt = sprintf(buffer, "\nFastpath I/O completions\n\n"); 11761d8658bSDupuis, Chad 11861d8658bSDupuis, Chad for (id = 0; id < qedf->num_queues; id++) { 11961d8658bSDupuis, Chad fp = &(qedf->fp_array[id]); 12061d8658bSDupuis, Chad if (fp->sb_id == QEDF_SB_ID_NULL) 12161d8658bSDupuis, Chad continue; 12261d8658bSDupuis, Chad cnt += sprintf((buffer + cnt), "#%d: %lu\n", id, 12361d8658bSDupuis, Chad fp->completions); 12461d8658bSDupuis, Chad } 12561d8658bSDupuis, Chad 12661d8658bSDupuis, Chad cnt = min_t(int, count, cnt - *ppos); 12761d8658bSDupuis, Chad *ppos += cnt; 12861d8658bSDupuis, Chad return cnt; 12961d8658bSDupuis, Chad } 13061d8658bSDupuis, Chad 13161d8658bSDupuis, Chad static ssize_t 13261d8658bSDupuis, Chad qedf_dbg_fp_int_cmd_write(struct file *filp, const char __user *buffer, 13361d8658bSDupuis, Chad size_t count, loff_t *ppos) 13461d8658bSDupuis, Chad { 13561d8658bSDupuis, Chad if (!count || *ppos) 13661d8658bSDupuis, Chad return 0; 13761d8658bSDupuis, Chad 13861d8658bSDupuis, Chad return count; 13961d8658bSDupuis, Chad } 14061d8658bSDupuis, Chad 14161d8658bSDupuis, Chad static ssize_t 14261d8658bSDupuis, Chad qedf_dbg_debug_cmd_read(struct file *filp, char __user *buffer, size_t count, 14361d8658bSDupuis, Chad loff_t *ppos) 14461d8658bSDupuis, Chad { 14561d8658bSDupuis, Chad int cnt; 14661d8658bSDupuis, Chad struct qedf_dbg_ctx *qedf = 14761d8658bSDupuis, Chad (struct qedf_dbg_ctx *)filp->private_data; 14861d8658bSDupuis, Chad 14961d8658bSDupuis, Chad QEDF_INFO(qedf, QEDF_LOG_DEBUGFS, "entered\n"); 15061d8658bSDupuis, Chad cnt = sprintf(buffer, "debug mask = 0x%x\n", qedf_debug); 15161d8658bSDupuis, Chad 15261d8658bSDupuis, Chad cnt = min_t(int, count, cnt - *ppos); 15361d8658bSDupuis, Chad *ppos += cnt; 15461d8658bSDupuis, Chad return cnt; 15561d8658bSDupuis, Chad } 15661d8658bSDupuis, Chad 15761d8658bSDupuis, Chad static ssize_t 15861d8658bSDupuis, Chad qedf_dbg_debug_cmd_write(struct file *filp, const char __user *buffer, 15961d8658bSDupuis, Chad size_t count, loff_t *ppos) 16061d8658bSDupuis, Chad { 16161d8658bSDupuis, Chad uint32_t val; 16261d8658bSDupuis, Chad void *kern_buf; 16361d8658bSDupuis, Chad int rval; 16461d8658bSDupuis, Chad struct qedf_dbg_ctx *qedf = 16561d8658bSDupuis, Chad (struct qedf_dbg_ctx *)filp->private_data; 16661d8658bSDupuis, Chad 16761d8658bSDupuis, Chad if (!count || *ppos) 16861d8658bSDupuis, Chad return 0; 16961d8658bSDupuis, Chad 17061d8658bSDupuis, Chad kern_buf = memdup_user(buffer, count); 17161d8658bSDupuis, Chad if (IS_ERR(kern_buf)) 17261d8658bSDupuis, Chad return PTR_ERR(kern_buf); 17361d8658bSDupuis, Chad 17461d8658bSDupuis, Chad rval = kstrtouint(kern_buf, 10, &val); 17561d8658bSDupuis, Chad kfree(kern_buf); 17661d8658bSDupuis, Chad if (rval) 17761d8658bSDupuis, Chad return rval; 17861d8658bSDupuis, Chad 17961d8658bSDupuis, Chad if (val == 1) 18061d8658bSDupuis, Chad qedf_debug = QEDF_DEFAULT_LOG_MASK; 18161d8658bSDupuis, Chad else 18261d8658bSDupuis, Chad qedf_debug = val; 18361d8658bSDupuis, Chad 18461d8658bSDupuis, Chad QEDF_INFO(qedf, QEDF_LOG_DEBUGFS, "Setting debug=0x%x.\n", val); 18561d8658bSDupuis, Chad return count; 18661d8658bSDupuis, Chad } 18761d8658bSDupuis, Chad 18861d8658bSDupuis, Chad static ssize_t 18961d8658bSDupuis, Chad qedf_dbg_stop_io_on_error_cmd_read(struct file *filp, char __user *buffer, 19061d8658bSDupuis, Chad size_t count, loff_t *ppos) 19161d8658bSDupuis, Chad { 19261d8658bSDupuis, Chad int cnt; 19361d8658bSDupuis, Chad struct qedf_dbg_ctx *qedf_dbg = 19461d8658bSDupuis, Chad (struct qedf_dbg_ctx *)filp->private_data; 19561d8658bSDupuis, Chad struct qedf_ctx *qedf = container_of(qedf_dbg, 19661d8658bSDupuis, Chad struct qedf_ctx, dbg_ctx); 19761d8658bSDupuis, Chad 19861d8658bSDupuis, Chad QEDF_INFO(qedf_dbg, QEDF_LOG_DEBUGFS, "entered\n"); 19961d8658bSDupuis, Chad cnt = sprintf(buffer, "%s\n", 20061d8658bSDupuis, Chad qedf->stop_io_on_error ? "true" : "false"); 20161d8658bSDupuis, Chad 20261d8658bSDupuis, Chad cnt = min_t(int, count, cnt - *ppos); 20361d8658bSDupuis, Chad *ppos += cnt; 20461d8658bSDupuis, Chad return cnt; 20561d8658bSDupuis, Chad } 20661d8658bSDupuis, Chad 20761d8658bSDupuis, Chad static ssize_t 20861d8658bSDupuis, Chad qedf_dbg_stop_io_on_error_cmd_write(struct file *filp, 20961d8658bSDupuis, Chad const char __user *buffer, size_t count, 21061d8658bSDupuis, Chad loff_t *ppos) 21161d8658bSDupuis, Chad { 21261d8658bSDupuis, Chad void *kern_buf; 21361d8658bSDupuis, Chad struct qedf_dbg_ctx *qedf_dbg = 21461d8658bSDupuis, Chad (struct qedf_dbg_ctx *)filp->private_data; 21561d8658bSDupuis, Chad struct qedf_ctx *qedf = container_of(qedf_dbg, struct qedf_ctx, 21661d8658bSDupuis, Chad dbg_ctx); 21761d8658bSDupuis, Chad 21861d8658bSDupuis, Chad QEDF_INFO(qedf_dbg, QEDF_LOG_DEBUGFS, "entered\n"); 21961d8658bSDupuis, Chad 22061d8658bSDupuis, Chad if (!count || *ppos) 22161d8658bSDupuis, Chad return 0; 22261d8658bSDupuis, Chad 22361d8658bSDupuis, Chad kern_buf = memdup_user(buffer, 6); 22461d8658bSDupuis, Chad if (IS_ERR(kern_buf)) 22561d8658bSDupuis, Chad return PTR_ERR(kern_buf); 22661d8658bSDupuis, Chad 22761d8658bSDupuis, Chad if (strncmp(kern_buf, "false", 5) == 0) 22861d8658bSDupuis, Chad qedf->stop_io_on_error = false; 22961d8658bSDupuis, Chad else if (strncmp(kern_buf, "true", 4) == 0) 23061d8658bSDupuis, Chad qedf->stop_io_on_error = true; 23161d8658bSDupuis, Chad else if (strncmp(kern_buf, "now", 3) == 0) 23261d8658bSDupuis, Chad /* Trigger from user to stop all I/O on this host */ 23361d8658bSDupuis, Chad set_bit(QEDF_DBG_STOP_IO, &qedf->flags); 23461d8658bSDupuis, Chad 23561d8658bSDupuis, Chad kfree(kern_buf); 23661d8658bSDupuis, Chad return count; 23761d8658bSDupuis, Chad } 23861d8658bSDupuis, Chad 23961d8658bSDupuis, Chad static int 24061d8658bSDupuis, Chad qedf_io_trace_show(struct seq_file *s, void *unused) 24161d8658bSDupuis, Chad { 24261d8658bSDupuis, Chad int i, idx = 0; 24361d8658bSDupuis, Chad struct qedf_ctx *qedf = s->private; 24461d8658bSDupuis, Chad struct qedf_dbg_ctx *qedf_dbg = &qedf->dbg_ctx; 24561d8658bSDupuis, Chad struct qedf_io_log *io_log; 24661d8658bSDupuis, Chad unsigned long flags; 24761d8658bSDupuis, Chad 24861d8658bSDupuis, Chad if (!qedf_io_tracing) { 24961d8658bSDupuis, Chad seq_puts(s, "I/O tracing not enabled.\n"); 25061d8658bSDupuis, Chad goto out; 25161d8658bSDupuis, Chad } 25261d8658bSDupuis, Chad 25361d8658bSDupuis, Chad QEDF_INFO(qedf_dbg, QEDF_LOG_DEBUGFS, "entered\n"); 25461d8658bSDupuis, Chad 25561d8658bSDupuis, Chad spin_lock_irqsave(&qedf->io_trace_lock, flags); 25661d8658bSDupuis, Chad idx = qedf->io_trace_idx; 25761d8658bSDupuis, Chad for (i = 0; i < QEDF_IO_TRACE_SIZE; i++) { 25861d8658bSDupuis, Chad io_log = &qedf->io_trace_buf[idx]; 25961d8658bSDupuis, Chad seq_printf(s, "%d:", io_log->direction); 26061d8658bSDupuis, Chad seq_printf(s, "0x%x:", io_log->task_id); 26161d8658bSDupuis, Chad seq_printf(s, "0x%06x:", io_log->port_id); 26261d8658bSDupuis, Chad seq_printf(s, "%d:", io_log->lun); 26361d8658bSDupuis, Chad seq_printf(s, "0x%02x:", io_log->op); 26461d8658bSDupuis, Chad seq_printf(s, "0x%02x%02x%02x%02x:", io_log->lba[0], 26561d8658bSDupuis, Chad io_log->lba[1], io_log->lba[2], io_log->lba[3]); 26661d8658bSDupuis, Chad seq_printf(s, "%d:", io_log->bufflen); 26761d8658bSDupuis, Chad seq_printf(s, "%d:", io_log->sg_count); 26861d8658bSDupuis, Chad seq_printf(s, "0x%08x:", io_log->result); 26961d8658bSDupuis, Chad seq_printf(s, "%lu:", io_log->jiffies); 27061d8658bSDupuis, Chad seq_printf(s, "%d:", io_log->refcount); 27161d8658bSDupuis, Chad seq_printf(s, "%d:", io_log->req_cpu); 27261d8658bSDupuis, Chad seq_printf(s, "%d:", io_log->int_cpu); 27361d8658bSDupuis, Chad seq_printf(s, "%d:", io_log->rsp_cpu); 27461d8658bSDupuis, Chad seq_printf(s, "%d\n", io_log->sge_type); 27561d8658bSDupuis, Chad 27661d8658bSDupuis, Chad idx++; 27761d8658bSDupuis, Chad if (idx == QEDF_IO_TRACE_SIZE) 27861d8658bSDupuis, Chad idx = 0; 27961d8658bSDupuis, Chad } 28061d8658bSDupuis, Chad spin_unlock_irqrestore(&qedf->io_trace_lock, flags); 28161d8658bSDupuis, Chad 28261d8658bSDupuis, Chad out: 28361d8658bSDupuis, Chad return 0; 28461d8658bSDupuis, Chad } 28561d8658bSDupuis, Chad 28661d8658bSDupuis, Chad static int 28761d8658bSDupuis, Chad qedf_dbg_io_trace_open(struct inode *inode, struct file *file) 28861d8658bSDupuis, Chad { 28961d8658bSDupuis, Chad struct qedf_dbg_ctx *qedf_dbg = inode->i_private; 29061d8658bSDupuis, Chad struct qedf_ctx *qedf = container_of(qedf_dbg, 29161d8658bSDupuis, Chad struct qedf_ctx, dbg_ctx); 29261d8658bSDupuis, Chad 29361d8658bSDupuis, Chad return single_open(file, qedf_io_trace_show, qedf); 29461d8658bSDupuis, Chad } 29561d8658bSDupuis, Chad 29661d8658bSDupuis, Chad static int 29761d8658bSDupuis, Chad qedf_driver_stats_show(struct seq_file *s, void *unused) 29861d8658bSDupuis, Chad { 29961d8658bSDupuis, Chad struct qedf_ctx *qedf = s->private; 30061d8658bSDupuis, Chad struct qedf_rport *fcport; 30161d8658bSDupuis, Chad struct fc_rport_priv *rdata; 30261d8658bSDupuis, Chad 30361d8658bSDupuis, Chad seq_printf(s, "cmg_mgr free io_reqs: %d\n", 30461d8658bSDupuis, Chad atomic_read(&qedf->cmd_mgr->free_list_cnt)); 30561d8658bSDupuis, Chad seq_printf(s, "slow SGEs: %d\n", qedf->slow_sge_ios); 30661d8658bSDupuis, Chad seq_printf(s, "single SGEs: %d\n", qedf->single_sge_ios); 30761d8658bSDupuis, Chad seq_printf(s, "fast SGEs: %d\n\n", qedf->fast_sge_ios); 30861d8658bSDupuis, Chad 30961d8658bSDupuis, Chad seq_puts(s, "Offloaded ports:\n\n"); 31061d8658bSDupuis, Chad 31161d8658bSDupuis, Chad rcu_read_lock(); 31261d8658bSDupuis, Chad list_for_each_entry_rcu(fcport, &qedf->fcports, peers) { 31361d8658bSDupuis, Chad rdata = fcport->rdata; 31461d8658bSDupuis, Chad if (rdata == NULL) 31561d8658bSDupuis, Chad continue; 31661d8658bSDupuis, Chad seq_printf(s, "%06x: free_sqes: %d, num_active_ios: %d\n", 31761d8658bSDupuis, Chad rdata->ids.port_id, atomic_read(&fcport->free_sqes), 31861d8658bSDupuis, Chad atomic_read(&fcport->num_active_ios)); 31961d8658bSDupuis, Chad } 32061d8658bSDupuis, Chad rcu_read_unlock(); 32161d8658bSDupuis, Chad 32261d8658bSDupuis, Chad return 0; 32361d8658bSDupuis, Chad } 32461d8658bSDupuis, Chad 32561d8658bSDupuis, Chad static int 32661d8658bSDupuis, Chad qedf_dbg_driver_stats_open(struct inode *inode, struct file *file) 32761d8658bSDupuis, Chad { 32861d8658bSDupuis, Chad struct qedf_dbg_ctx *qedf_dbg = inode->i_private; 32961d8658bSDupuis, Chad struct qedf_ctx *qedf = container_of(qedf_dbg, 33061d8658bSDupuis, Chad struct qedf_ctx, dbg_ctx); 33161d8658bSDupuis, Chad 33261d8658bSDupuis, Chad return single_open(file, qedf_driver_stats_show, qedf); 33361d8658bSDupuis, Chad } 33461d8658bSDupuis, Chad 33561d8658bSDupuis, Chad static ssize_t 33661d8658bSDupuis, Chad qedf_dbg_clear_stats_cmd_read(struct file *filp, char __user *buffer, 33761d8658bSDupuis, Chad size_t count, loff_t *ppos) 33861d8658bSDupuis, Chad { 33961d8658bSDupuis, Chad int cnt = 0; 34061d8658bSDupuis, Chad 34161d8658bSDupuis, Chad /* Essentially a read stub */ 34261d8658bSDupuis, Chad cnt = min_t(int, count, cnt - *ppos); 34361d8658bSDupuis, Chad *ppos += cnt; 34461d8658bSDupuis, Chad return cnt; 34561d8658bSDupuis, Chad } 34661d8658bSDupuis, Chad 34761d8658bSDupuis, Chad static ssize_t 34861d8658bSDupuis, Chad qedf_dbg_clear_stats_cmd_write(struct file *filp, 34961d8658bSDupuis, Chad const char __user *buffer, size_t count, 35061d8658bSDupuis, Chad loff_t *ppos) 35161d8658bSDupuis, Chad { 35261d8658bSDupuis, Chad struct qedf_dbg_ctx *qedf_dbg = 35361d8658bSDupuis, Chad (struct qedf_dbg_ctx *)filp->private_data; 35461d8658bSDupuis, Chad struct qedf_ctx *qedf = container_of(qedf_dbg, struct qedf_ctx, 35561d8658bSDupuis, Chad dbg_ctx); 35661d8658bSDupuis, Chad 35761d8658bSDupuis, Chad QEDF_INFO(qedf_dbg, QEDF_LOG_DEBUGFS, "Clearing stat counters.\n"); 35861d8658bSDupuis, Chad 35961d8658bSDupuis, Chad if (!count || *ppos) 36061d8658bSDupuis, Chad return 0; 36161d8658bSDupuis, Chad 36261d8658bSDupuis, Chad /* Clear stat counters exposed by 'stats' node */ 36361d8658bSDupuis, Chad qedf->slow_sge_ios = 0; 36461d8658bSDupuis, Chad qedf->single_sge_ios = 0; 36561d8658bSDupuis, Chad qedf->fast_sge_ios = 0; 36661d8658bSDupuis, Chad 36761d8658bSDupuis, Chad return count; 36861d8658bSDupuis, Chad } 36961d8658bSDupuis, Chad 37061d8658bSDupuis, Chad static int 37161d8658bSDupuis, Chad qedf_offload_stats_show(struct seq_file *s, void *unused) 37261d8658bSDupuis, Chad { 37361d8658bSDupuis, Chad struct qedf_ctx *qedf = s->private; 37461d8658bSDupuis, Chad struct qed_fcoe_stats *fw_fcoe_stats; 37561d8658bSDupuis, Chad 37661d8658bSDupuis, Chad fw_fcoe_stats = kmalloc(sizeof(struct qed_fcoe_stats), GFP_KERNEL); 37761d8658bSDupuis, Chad if (!fw_fcoe_stats) { 37861d8658bSDupuis, Chad QEDF_ERR(&(qedf->dbg_ctx), "Could not allocate memory for " 37961d8658bSDupuis, Chad "fw_fcoe_stats.\n"); 38061d8658bSDupuis, Chad goto out; 38161d8658bSDupuis, Chad } 38261d8658bSDupuis, Chad 38361d8658bSDupuis, Chad /* Query firmware for offload stats */ 38461d8658bSDupuis, Chad qed_ops->get_stats(qedf->cdev, fw_fcoe_stats); 38561d8658bSDupuis, Chad 38661d8658bSDupuis, Chad seq_printf(s, "fcoe_rx_byte_cnt=%llu\n" 38761d8658bSDupuis, Chad "fcoe_rx_data_pkt_cnt=%llu\n" 38861d8658bSDupuis, Chad "fcoe_rx_xfer_pkt_cnt=%llu\n" 38961d8658bSDupuis, Chad "fcoe_rx_other_pkt_cnt=%llu\n" 39061d8658bSDupuis, Chad "fcoe_silent_drop_pkt_cmdq_full_cnt=%u\n" 39161d8658bSDupuis, Chad "fcoe_silent_drop_pkt_crc_error_cnt=%u\n" 39261d8658bSDupuis, Chad "fcoe_silent_drop_pkt_task_invalid_cnt=%u\n" 39361d8658bSDupuis, Chad "fcoe_silent_drop_total_pkt_cnt=%u\n" 39461d8658bSDupuis, Chad "fcoe_silent_drop_pkt_rq_full_cnt=%u\n" 39561d8658bSDupuis, Chad "fcoe_tx_byte_cnt=%llu\n" 39661d8658bSDupuis, Chad "fcoe_tx_data_pkt_cnt=%llu\n" 39761d8658bSDupuis, Chad "fcoe_tx_xfer_pkt_cnt=%llu\n" 39861d8658bSDupuis, Chad "fcoe_tx_other_pkt_cnt=%llu\n", 39961d8658bSDupuis, Chad fw_fcoe_stats->fcoe_rx_byte_cnt, 40061d8658bSDupuis, Chad fw_fcoe_stats->fcoe_rx_data_pkt_cnt, 40161d8658bSDupuis, Chad fw_fcoe_stats->fcoe_rx_xfer_pkt_cnt, 40261d8658bSDupuis, Chad fw_fcoe_stats->fcoe_rx_other_pkt_cnt, 40361d8658bSDupuis, Chad fw_fcoe_stats->fcoe_silent_drop_pkt_cmdq_full_cnt, 40461d8658bSDupuis, Chad fw_fcoe_stats->fcoe_silent_drop_pkt_crc_error_cnt, 40561d8658bSDupuis, Chad fw_fcoe_stats->fcoe_silent_drop_pkt_task_invalid_cnt, 40661d8658bSDupuis, Chad fw_fcoe_stats->fcoe_silent_drop_total_pkt_cnt, 40761d8658bSDupuis, Chad fw_fcoe_stats->fcoe_silent_drop_pkt_rq_full_cnt, 40861d8658bSDupuis, Chad fw_fcoe_stats->fcoe_tx_byte_cnt, 40961d8658bSDupuis, Chad fw_fcoe_stats->fcoe_tx_data_pkt_cnt, 41061d8658bSDupuis, Chad fw_fcoe_stats->fcoe_tx_xfer_pkt_cnt, 41161d8658bSDupuis, Chad fw_fcoe_stats->fcoe_tx_other_pkt_cnt); 41261d8658bSDupuis, Chad 41361d8658bSDupuis, Chad kfree(fw_fcoe_stats); 41461d8658bSDupuis, Chad out: 41561d8658bSDupuis, Chad return 0; 41661d8658bSDupuis, Chad } 41761d8658bSDupuis, Chad 41861d8658bSDupuis, Chad static int 41961d8658bSDupuis, Chad qedf_dbg_offload_stats_open(struct inode *inode, struct file *file) 42061d8658bSDupuis, Chad { 42161d8658bSDupuis, Chad struct qedf_dbg_ctx *qedf_dbg = inode->i_private; 42261d8658bSDupuis, Chad struct qedf_ctx *qedf = container_of(qedf_dbg, 42361d8658bSDupuis, Chad struct qedf_ctx, dbg_ctx); 42461d8658bSDupuis, Chad 42561d8658bSDupuis, Chad return single_open(file, qedf_offload_stats_show, qedf); 42661d8658bSDupuis, Chad } 42761d8658bSDupuis, Chad 42861d8658bSDupuis, Chad const struct file_operations qedf_dbg_fops[] = { 42961d8658bSDupuis, Chad qedf_dbg_fileops(qedf, fp_int), 43061d8658bSDupuis, Chad qedf_dbg_fileops_seq(qedf, io_trace), 43161d8658bSDupuis, Chad qedf_dbg_fileops(qedf, debug), 43261d8658bSDupuis, Chad qedf_dbg_fileops(qedf, stop_io_on_error), 43361d8658bSDupuis, Chad qedf_dbg_fileops_seq(qedf, driver_stats), 43461d8658bSDupuis, Chad qedf_dbg_fileops(qedf, clear_stats), 43561d8658bSDupuis, Chad qedf_dbg_fileops_seq(qedf, offload_stats), 43661d8658bSDupuis, Chad /* This must be last */ 437efacae6dSKees Cook { }, 43861d8658bSDupuis, Chad }; 43961d8658bSDupuis, Chad 44061d8658bSDupuis, Chad #else /* CONFIG_DEBUG_FS */ 44161d8658bSDupuis, Chad void qedf_dbg_host_init(struct qedf_dbg_ctx *); 44261d8658bSDupuis, Chad void qedf_dbg_host_exit(struct qedf_dbg_ctx *); 44361d8658bSDupuis, Chad void qedf_dbg_init(char *); 44461d8658bSDupuis, Chad void qedf_dbg_exit(void); 44561d8658bSDupuis, Chad #endif /* CONFIG_DEBUG_FS */ 446