14d7007b4SHiral Patel /* 24d7007b4SHiral Patel * Copyright 2012 Cisco Systems, Inc. All rights reserved. 34d7007b4SHiral Patel * 44d7007b4SHiral Patel * This program is free software; you may redistribute it and/or modify 54d7007b4SHiral Patel * it under the terms of the GNU General Public License as published by 64d7007b4SHiral Patel * the Free Software Foundation; version 2 of the License. 74d7007b4SHiral Patel * 84d7007b4SHiral Patel * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 94d7007b4SHiral Patel * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 104d7007b4SHiral Patel * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 114d7007b4SHiral Patel * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 124d7007b4SHiral Patel * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 134d7007b4SHiral Patel * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 144d7007b4SHiral Patel * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 154d7007b4SHiral Patel * SOFTWARE. 164d7007b4SHiral Patel */ 174d7007b4SHiral Patel 184d7007b4SHiral Patel #include <linux/module.h> 194d7007b4SHiral Patel #include <linux/errno.h> 204d7007b4SHiral Patel #include <linux/debugfs.h> 21d6472302SStephen Rothwell #include <linux/vmalloc.h> 224d7007b4SHiral Patel #include "fnic.h" 234d7007b4SHiral Patel 244d7007b4SHiral Patel static struct dentry *fnic_trace_debugfs_root; 254d7007b4SHiral Patel static struct dentry *fnic_trace_debugfs_file; 264d7007b4SHiral Patel static struct dentry *fnic_trace_enable; 2767125b02SHiral Patel static struct dentry *fnic_stats_debugfs_root; 2867125b02SHiral Patel 29abb14148SHiral Shah static struct dentry *fnic_fc_trace_debugfs_file; 30abb14148SHiral Shah static struct dentry *fnic_fc_rdata_trace_debugfs_file; 31abb14148SHiral Shah static struct dentry *fnic_fc_trace_enable; 32abb14148SHiral Shah static struct dentry *fnic_fc_trace_clear; 33abb14148SHiral Shah 34abb14148SHiral Shah struct fc_trace_flag_type { 35abb14148SHiral Shah u8 fc_row_file; 36abb14148SHiral Shah u8 fc_normal_file; 37abb14148SHiral Shah u8 fnic_trace; 38abb14148SHiral Shah u8 fc_trace; 39abb14148SHiral Shah u8 fc_clear; 40abb14148SHiral Shah }; 41abb14148SHiral Shah 42abb14148SHiral Shah static struct fc_trace_flag_type *fc_trc_flag; 43abb14148SHiral Shah 4467125b02SHiral Patel /* 4567125b02SHiral Patel * fnic_debugfs_init - Initialize debugfs for fnic debug logging 4667125b02SHiral Patel * 4767125b02SHiral Patel * Description: 4867125b02SHiral Patel * When Debugfs is configured this routine sets up the fnic debugfs 4967125b02SHiral Patel * file system. If not already created, this routine will create the 5067125b02SHiral Patel * fnic directory and statistics directory for trace buffer and 5167125b02SHiral Patel * stats logging. 5267125b02SHiral Patel */ 5367125b02SHiral Patel int fnic_debugfs_init(void) 5467125b02SHiral Patel { 5567125b02SHiral Patel int rc = -1; 5667125b02SHiral Patel fnic_trace_debugfs_root = debugfs_create_dir("fnic", NULL); 5767125b02SHiral Patel if (!fnic_trace_debugfs_root) { 5867125b02SHiral Patel printk(KERN_DEBUG "Cannot create debugfs root\n"); 5967125b02SHiral Patel return rc; 6067125b02SHiral Patel } 6167125b02SHiral Patel 6267125b02SHiral Patel if (!fnic_trace_debugfs_root) { 6367125b02SHiral Patel printk(KERN_DEBUG 6467125b02SHiral Patel "fnic root directory doesn't exist in debugfs\n"); 6567125b02SHiral Patel return rc; 6667125b02SHiral Patel } 6767125b02SHiral Patel 6867125b02SHiral Patel fnic_stats_debugfs_root = debugfs_create_dir("statistics", 6967125b02SHiral Patel fnic_trace_debugfs_root); 7067125b02SHiral Patel if (!fnic_stats_debugfs_root) { 7167125b02SHiral Patel printk(KERN_DEBUG "Cannot create Statistics directory\n"); 7267125b02SHiral Patel return rc; 7367125b02SHiral Patel } 7467125b02SHiral Patel 75abb14148SHiral Shah /* Allocate memory to structure */ 76abb14148SHiral Shah fc_trc_flag = (struct fc_trace_flag_type *) 77abb14148SHiral Shah vmalloc(sizeof(struct fc_trace_flag_type)); 78abb14148SHiral Shah 79abb14148SHiral Shah if (fc_trc_flag) { 80abb14148SHiral Shah fc_trc_flag->fc_row_file = 0; 81abb14148SHiral Shah fc_trc_flag->fc_normal_file = 1; 82abb14148SHiral Shah fc_trc_flag->fnic_trace = 2; 83abb14148SHiral Shah fc_trc_flag->fc_trace = 3; 84abb14148SHiral Shah fc_trc_flag->fc_clear = 4; 85abb14148SHiral Shah } 86abb14148SHiral Shah 8767125b02SHiral Patel rc = 0; 8867125b02SHiral Patel return rc; 8967125b02SHiral Patel } 9067125b02SHiral Patel 9167125b02SHiral Patel /* 9267125b02SHiral Patel * fnic_debugfs_terminate - Tear down debugfs infrastructure 9367125b02SHiral Patel * 9467125b02SHiral Patel * Description: 9567125b02SHiral Patel * When Debugfs is configured this routine removes debugfs file system 9667125b02SHiral Patel * elements that are specific to fnic. 9767125b02SHiral Patel */ 9867125b02SHiral Patel void fnic_debugfs_terminate(void) 9967125b02SHiral Patel { 10067125b02SHiral Patel debugfs_remove(fnic_stats_debugfs_root); 10167125b02SHiral Patel fnic_stats_debugfs_root = NULL; 10267125b02SHiral Patel 10367125b02SHiral Patel debugfs_remove(fnic_trace_debugfs_root); 10467125b02SHiral Patel fnic_trace_debugfs_root = NULL; 105abb14148SHiral Shah 106abb14148SHiral Shah if (fc_trc_flag) 107abb14148SHiral Shah vfree(fc_trc_flag); 10867125b02SHiral Patel } 1094d7007b4SHiral Patel 1104d7007b4SHiral Patel /* 111abb14148SHiral Shah * fnic_trace_ctrl_read - 112abb14148SHiral Shah * Read trace_enable ,fc_trace_enable 113abb14148SHiral Shah * or fc_trace_clear debugfs file 1144d7007b4SHiral Patel * @filp: The file pointer to read from. 1154d7007b4SHiral Patel * @ubuf: The buffer to copy the data to. 1164d7007b4SHiral Patel * @cnt: The number of bytes to read. 1174d7007b4SHiral Patel * @ppos: The position in the file to start reading from. 1184d7007b4SHiral Patel * 1194d7007b4SHiral Patel * Description: 120abb14148SHiral Shah * This routine reads value of variable fnic_tracing_enabled or 121abb14148SHiral Shah * fnic_fc_tracing_enabled or fnic_fc_trace_cleared 122abb14148SHiral Shah * and stores into local @buf. 123abb14148SHiral Shah * It will start reading file at @ppos and 1244d7007b4SHiral Patel * copy up to @cnt of data to @ubuf from @buf. 1254d7007b4SHiral Patel * 1264d7007b4SHiral Patel * Returns: 1274d7007b4SHiral Patel * This function returns the amount of data that was read. 1284d7007b4SHiral Patel */ 1294d7007b4SHiral Patel static ssize_t fnic_trace_ctrl_read(struct file *filp, 1304d7007b4SHiral Patel char __user *ubuf, 1314d7007b4SHiral Patel size_t cnt, loff_t *ppos) 1324d7007b4SHiral Patel { 1334d7007b4SHiral Patel char buf[64]; 1344d7007b4SHiral Patel int len; 135abb14148SHiral Shah u8 *trace_type; 136abb14148SHiral Shah len = 0; 137abb14148SHiral Shah trace_type = (u8 *)filp->private_data; 138abb14148SHiral Shah if (*trace_type == fc_trc_flag->fnic_trace) 1394d7007b4SHiral Patel len = sprintf(buf, "%u\n", fnic_tracing_enabled); 140abb14148SHiral Shah else if (*trace_type == fc_trc_flag->fc_trace) 141abb14148SHiral Shah len = sprintf(buf, "%u\n", fnic_fc_tracing_enabled); 142abb14148SHiral Shah else if (*trace_type == fc_trc_flag->fc_clear) 143abb14148SHiral Shah len = sprintf(buf, "%u\n", fnic_fc_trace_cleared); 144abb14148SHiral Shah else 145abb14148SHiral Shah pr_err("fnic: Cannot read to any debugfs file\n"); 1464d7007b4SHiral Patel 1474d7007b4SHiral Patel return simple_read_from_buffer(ubuf, cnt, ppos, buf, len); 1484d7007b4SHiral Patel } 1494d7007b4SHiral Patel 1504d7007b4SHiral Patel /* 151abb14148SHiral Shah * fnic_trace_ctrl_write - 152abb14148SHiral Shah * Write to trace_enable, fc_trace_enable or 153abb14148SHiral Shah * fc_trace_clear debugfs file 1544d7007b4SHiral Patel * @filp: The file pointer to write from. 1554d7007b4SHiral Patel * @ubuf: The buffer to copy the data from. 1564d7007b4SHiral Patel * @cnt: The number of bytes to write. 1574d7007b4SHiral Patel * @ppos: The position in the file to start writing to. 1584d7007b4SHiral Patel * 1594d7007b4SHiral Patel * Description: 1604d7007b4SHiral Patel * This routine writes data from user buffer @ubuf to buffer @buf and 161abb14148SHiral Shah * sets fc_trace_enable ,tracing_enable or fnic_fc_trace_cleared 162abb14148SHiral Shah * value as per user input. 1634d7007b4SHiral Patel * 1644d7007b4SHiral Patel * Returns: 1654d7007b4SHiral Patel * This function returns the amount of data that was written. 1664d7007b4SHiral Patel */ 1674d7007b4SHiral Patel static ssize_t fnic_trace_ctrl_write(struct file *filp, 1684d7007b4SHiral Patel const char __user *ubuf, 1694d7007b4SHiral Patel size_t cnt, loff_t *ppos) 1704d7007b4SHiral Patel { 1714d7007b4SHiral Patel char buf[64]; 1724d7007b4SHiral Patel unsigned long val; 1734d7007b4SHiral Patel int ret; 174abb14148SHiral Shah u8 *trace_type; 175abb14148SHiral Shah trace_type = (u8 *)filp->private_data; 1764d7007b4SHiral Patel 1774d7007b4SHiral Patel if (cnt >= sizeof(buf)) 1784d7007b4SHiral Patel return -EINVAL; 1794d7007b4SHiral Patel 1804d7007b4SHiral Patel if (copy_from_user(&buf, ubuf, cnt)) 1814d7007b4SHiral Patel return -EFAULT; 1824d7007b4SHiral Patel 1834d7007b4SHiral Patel buf[cnt] = 0; 1844d7007b4SHiral Patel 1854d7007b4SHiral Patel ret = kstrtoul(buf, 10, &val); 1864d7007b4SHiral Patel if (ret < 0) 1874d7007b4SHiral Patel return ret; 1884d7007b4SHiral Patel 189abb14148SHiral Shah if (*trace_type == fc_trc_flag->fnic_trace) 1904d7007b4SHiral Patel fnic_tracing_enabled = val; 191abb14148SHiral Shah else if (*trace_type == fc_trc_flag->fc_trace) 192abb14148SHiral Shah fnic_fc_tracing_enabled = val; 193abb14148SHiral Shah else if (*trace_type == fc_trc_flag->fc_clear) 194abb14148SHiral Shah fnic_fc_trace_cleared = val; 195abb14148SHiral Shah else 1961a84db56SMasanari Iida pr_err("fnic: cannot write to any debugfs file\n"); 197abb14148SHiral Shah 1984d7007b4SHiral Patel (*ppos)++; 1994d7007b4SHiral Patel 2004d7007b4SHiral Patel return cnt; 2014d7007b4SHiral Patel } 2024d7007b4SHiral Patel 203abb14148SHiral Shah static const struct file_operations fnic_trace_ctrl_fops = { 204abb14148SHiral Shah .owner = THIS_MODULE, 205*d9462140SVasyl Gomonovych .open = simple_open, 206abb14148SHiral Shah .read = fnic_trace_ctrl_read, 207abb14148SHiral Shah .write = fnic_trace_ctrl_write, 208abb14148SHiral Shah }; 209abb14148SHiral Shah 2104d7007b4SHiral Patel /* 2114d7007b4SHiral Patel * fnic_trace_debugfs_open - Open the fnic trace log 2124d7007b4SHiral Patel * @inode: The inode pointer 2134d7007b4SHiral Patel * @file: The file pointer to attach the log output 2144d7007b4SHiral Patel * 2154d7007b4SHiral Patel * Description: 2164d7007b4SHiral Patel * This routine is the entry point for the debugfs open file operation. 2174d7007b4SHiral Patel * It allocates the necessary buffer for the log, fills the buffer from 2184d7007b4SHiral Patel * the in-memory log and then returns a pointer to that log in 2194d7007b4SHiral Patel * the private_data field in @file. 2204d7007b4SHiral Patel * 2214d7007b4SHiral Patel * Returns: 2224d7007b4SHiral Patel * This function returns zero if successful. On error it will return 2234d7007b4SHiral Patel * a negative error value. 2244d7007b4SHiral Patel */ 2254d7007b4SHiral Patel static int fnic_trace_debugfs_open(struct inode *inode, 2264d7007b4SHiral Patel struct file *file) 2274d7007b4SHiral Patel { 2284d7007b4SHiral Patel fnic_dbgfs_t *fnic_dbg_prt; 229abb14148SHiral Shah u8 *rdata_ptr; 230abb14148SHiral Shah rdata_ptr = (u8 *)inode->i_private; 2314d7007b4SHiral Patel fnic_dbg_prt = kzalloc(sizeof(fnic_dbgfs_t), GFP_KERNEL); 2324d7007b4SHiral Patel if (!fnic_dbg_prt) 2334d7007b4SHiral Patel return -ENOMEM; 2344d7007b4SHiral Patel 235abb14148SHiral Shah if (*rdata_ptr == fc_trc_flag->fnic_trace) { 236abb14148SHiral Shah fnic_dbg_prt->buffer = vmalloc(3 * 237abb14148SHiral Shah (trace_max_pages * PAGE_SIZE)); 2384d7007b4SHiral Patel if (!fnic_dbg_prt->buffer) { 2394d7007b4SHiral Patel kfree(fnic_dbg_prt); 2404d7007b4SHiral Patel return -ENOMEM; 2414d7007b4SHiral Patel } 2424d7007b4SHiral Patel memset((void *)fnic_dbg_prt->buffer, 0, 243abb14148SHiral Shah 3 * (trace_max_pages * PAGE_SIZE)); 2444d7007b4SHiral Patel fnic_dbg_prt->buffer_len = fnic_get_trace_data(fnic_dbg_prt); 245abb14148SHiral Shah } else { 246abb14148SHiral Shah fnic_dbg_prt->buffer = 247abb14148SHiral Shah vmalloc(3 * (fnic_fc_trace_max_pages * PAGE_SIZE)); 248abb14148SHiral Shah if (!fnic_dbg_prt->buffer) { 249abb14148SHiral Shah kfree(fnic_dbg_prt); 250abb14148SHiral Shah return -ENOMEM; 251abb14148SHiral Shah } 252abb14148SHiral Shah memset((void *)fnic_dbg_prt->buffer, 0, 253abb14148SHiral Shah 3 * (fnic_fc_trace_max_pages * PAGE_SIZE)); 254abb14148SHiral Shah fnic_dbg_prt->buffer_len = 255abb14148SHiral Shah fnic_fc_trace_get_data(fnic_dbg_prt, *rdata_ptr); 256abb14148SHiral Shah } 2574d7007b4SHiral Patel file->private_data = fnic_dbg_prt; 258abb14148SHiral Shah 2594d7007b4SHiral Patel return 0; 2604d7007b4SHiral Patel } 2614d7007b4SHiral Patel 2624d7007b4SHiral Patel /* 2634d7007b4SHiral Patel * fnic_trace_debugfs_lseek - Seek through a debugfs file 2644d7007b4SHiral Patel * @file: The file pointer to seek through. 2654d7007b4SHiral Patel * @offset: The offset to seek to or the amount to seek by. 2664d7007b4SHiral Patel * @howto: Indicates how to seek. 2674d7007b4SHiral Patel * 2684d7007b4SHiral Patel * Description: 2694d7007b4SHiral Patel * This routine is the entry point for the debugfs lseek file operation. 2704d7007b4SHiral Patel * The @howto parameter indicates whether @offset is the offset to directly 2714d7007b4SHiral Patel * seek to, or if it is a value to seek forward or reverse by. This function 2724d7007b4SHiral Patel * figures out what the new offset of the debugfs file will be and assigns 2734d7007b4SHiral Patel * that value to the f_pos field of @file. 2744d7007b4SHiral Patel * 2754d7007b4SHiral Patel * Returns: 2764d7007b4SHiral Patel * This function returns the new offset if successful and returns a negative 2774d7007b4SHiral Patel * error if unable to process the seek. 2784d7007b4SHiral Patel */ 2794d7007b4SHiral Patel static loff_t fnic_trace_debugfs_lseek(struct file *file, 2804d7007b4SHiral Patel loff_t offset, 2814d7007b4SHiral Patel int howto) 2824d7007b4SHiral Patel { 2834d7007b4SHiral Patel fnic_dbgfs_t *fnic_dbg_prt = file->private_data; 284eb5881d3SAl Viro return fixed_size_llseek(file, offset, howto, 285eb5881d3SAl Viro fnic_dbg_prt->buffer_len); 2864d7007b4SHiral Patel } 2874d7007b4SHiral Patel 2884d7007b4SHiral Patel /* 2894d7007b4SHiral Patel * fnic_trace_debugfs_read - Read a debugfs file 2904d7007b4SHiral Patel * @file: The file pointer to read from. 2914d7007b4SHiral Patel * @ubuf: The buffer to copy the data to. 2924d7007b4SHiral Patel * @nbytes: The number of bytes to read. 2934d7007b4SHiral Patel * @pos: The position in the file to start reading from. 2944d7007b4SHiral Patel * 2954d7007b4SHiral Patel * Description: 2964d7007b4SHiral Patel * This routine reads data from the buffer indicated in the private_data 2974d7007b4SHiral Patel * field of @file. It will start reading at @pos and copy up to @nbytes of 2984d7007b4SHiral Patel * data to @ubuf. 2994d7007b4SHiral Patel * 3004d7007b4SHiral Patel * Returns: 3014d7007b4SHiral Patel * This function returns the amount of data that was read (this could be 3024d7007b4SHiral Patel * less than @nbytes if the end of the file was reached). 3034d7007b4SHiral Patel */ 3044d7007b4SHiral Patel static ssize_t fnic_trace_debugfs_read(struct file *file, 3054d7007b4SHiral Patel char __user *ubuf, 3064d7007b4SHiral Patel size_t nbytes, 3074d7007b4SHiral Patel loff_t *pos) 3084d7007b4SHiral Patel { 3094d7007b4SHiral Patel fnic_dbgfs_t *fnic_dbg_prt = file->private_data; 3104d7007b4SHiral Patel int rc = 0; 3114d7007b4SHiral Patel rc = simple_read_from_buffer(ubuf, nbytes, pos, 3124d7007b4SHiral Patel fnic_dbg_prt->buffer, 3134d7007b4SHiral Patel fnic_dbg_prt->buffer_len); 3144d7007b4SHiral Patel return rc; 3154d7007b4SHiral Patel } 3164d7007b4SHiral Patel 3174d7007b4SHiral Patel /* 3184d7007b4SHiral Patel * fnic_trace_debugfs_release - Release the buffer used to store 3194d7007b4SHiral Patel * debugfs file data 3204d7007b4SHiral Patel * @inode: The inode pointer 3214d7007b4SHiral Patel * @file: The file pointer that contains the buffer to release 3224d7007b4SHiral Patel * 3234d7007b4SHiral Patel * Description: 3244d7007b4SHiral Patel * This routine frees the buffer that was allocated when the debugfs 3254d7007b4SHiral Patel * file was opened. 3264d7007b4SHiral Patel * 3274d7007b4SHiral Patel * Returns: 3284d7007b4SHiral Patel * This function returns zero. 3294d7007b4SHiral Patel */ 3304d7007b4SHiral Patel static int fnic_trace_debugfs_release(struct inode *inode, 3314d7007b4SHiral Patel struct file *file) 3324d7007b4SHiral Patel { 3334d7007b4SHiral Patel fnic_dbgfs_t *fnic_dbg_prt = file->private_data; 3344d7007b4SHiral Patel 3354d7007b4SHiral Patel vfree(fnic_dbg_prt->buffer); 3364d7007b4SHiral Patel kfree(fnic_dbg_prt); 3374d7007b4SHiral Patel return 0; 3384d7007b4SHiral Patel } 3394d7007b4SHiral Patel 3404d7007b4SHiral Patel static const struct file_operations fnic_trace_debugfs_fops = { 3414d7007b4SHiral Patel .owner = THIS_MODULE, 3424d7007b4SHiral Patel .open = fnic_trace_debugfs_open, 3434d7007b4SHiral Patel .llseek = fnic_trace_debugfs_lseek, 3444d7007b4SHiral Patel .read = fnic_trace_debugfs_read, 3454d7007b4SHiral Patel .release = fnic_trace_debugfs_release, 3464d7007b4SHiral Patel }; 3474d7007b4SHiral Patel 3484d7007b4SHiral Patel /* 3494d7007b4SHiral Patel * fnic_trace_debugfs_init - Initialize debugfs for fnic trace logging 3504d7007b4SHiral Patel * 3514d7007b4SHiral Patel * Description: 3524d7007b4SHiral Patel * When Debugfs is configured this routine sets up the fnic debugfs 3534d7007b4SHiral Patel * file system. If not already created, this routine will create the 35467125b02SHiral Patel * create file trace to log fnic trace buffer output into debugfs and 35567125b02SHiral Patel * it will also create file trace_enable to control enable/disable of 35667125b02SHiral Patel * trace logging into trace buffer. 3574d7007b4SHiral Patel */ 3584d7007b4SHiral Patel int fnic_trace_debugfs_init(void) 3594d7007b4SHiral Patel { 3604d7007b4SHiral Patel int rc = -1; 3614d7007b4SHiral Patel if (!fnic_trace_debugfs_root) { 36267125b02SHiral Patel printk(KERN_DEBUG 36367125b02SHiral Patel "FNIC Debugfs root directory doesn't exist\n"); 3644d7007b4SHiral Patel return rc; 3654d7007b4SHiral Patel } 3664d7007b4SHiral Patel fnic_trace_enable = debugfs_create_file("tracing_enable", 3674d7007b4SHiral Patel S_IFREG|S_IRUGO|S_IWUSR, 3684d7007b4SHiral Patel fnic_trace_debugfs_root, 369abb14148SHiral Shah &(fc_trc_flag->fnic_trace), 370abb14148SHiral Shah &fnic_trace_ctrl_fops); 3714d7007b4SHiral Patel 3724d7007b4SHiral Patel if (!fnic_trace_enable) { 37367125b02SHiral Patel printk(KERN_DEBUG 37467125b02SHiral Patel "Cannot create trace_enable file under debugfs\n"); 3754d7007b4SHiral Patel return rc; 3764d7007b4SHiral Patel } 3774d7007b4SHiral Patel 3784d7007b4SHiral Patel fnic_trace_debugfs_file = debugfs_create_file("trace", 3794d7007b4SHiral Patel S_IFREG|S_IRUGO|S_IWUSR, 3804d7007b4SHiral Patel fnic_trace_debugfs_root, 381abb14148SHiral Shah &(fc_trc_flag->fnic_trace), 3824d7007b4SHiral Patel &fnic_trace_debugfs_fops); 3834d7007b4SHiral Patel 3844d7007b4SHiral Patel if (!fnic_trace_debugfs_file) { 38567125b02SHiral Patel printk(KERN_DEBUG 38667125b02SHiral Patel "Cannot create trace file under debugfs\n"); 3874d7007b4SHiral Patel return rc; 3884d7007b4SHiral Patel } 3894d7007b4SHiral Patel rc = 0; 3904d7007b4SHiral Patel return rc; 3914d7007b4SHiral Patel } 3924d7007b4SHiral Patel 3934d7007b4SHiral Patel /* 3944d7007b4SHiral Patel * fnic_trace_debugfs_terminate - Tear down debugfs infrastructure 3954d7007b4SHiral Patel * 3964d7007b4SHiral Patel * Description: 3974d7007b4SHiral Patel * When Debugfs is configured this routine removes debugfs file system 3984d7007b4SHiral Patel * elements that are specific to fnic trace logging. 3994d7007b4SHiral Patel */ 4004d7007b4SHiral Patel void fnic_trace_debugfs_terminate(void) 4014d7007b4SHiral Patel { 4024d7007b4SHiral Patel debugfs_remove(fnic_trace_debugfs_file); 4034d7007b4SHiral Patel fnic_trace_debugfs_file = NULL; 404abb14148SHiral Shah 4054d7007b4SHiral Patel debugfs_remove(fnic_trace_enable); 4064d7007b4SHiral Patel fnic_trace_enable = NULL; 4074d7007b4SHiral Patel } 408abb14148SHiral Shah 409abb14148SHiral Shah /* 410abb14148SHiral Shah * fnic_fc_trace_debugfs_init - 411abb14148SHiral Shah * Initialize debugfs for fnic control frame trace logging 412abb14148SHiral Shah * 413abb14148SHiral Shah * Description: 414abb14148SHiral Shah * When Debugfs is configured this routine sets up the fnic_fc debugfs 415abb14148SHiral Shah * file system. If not already created, this routine will create the 416abb14148SHiral Shah * create file trace to log fnic fc trace buffer output into debugfs and 417abb14148SHiral Shah * it will also create file fc_trace_enable to control enable/disable of 418abb14148SHiral Shah * trace logging into trace buffer. 419abb14148SHiral Shah */ 420abb14148SHiral Shah 421abb14148SHiral Shah int fnic_fc_trace_debugfs_init(void) 422abb14148SHiral Shah { 423abb14148SHiral Shah int rc = -1; 424abb14148SHiral Shah 425abb14148SHiral Shah if (!fnic_trace_debugfs_root) { 426abb14148SHiral Shah pr_err("fnic:Debugfs root directory doesn't exist\n"); 427abb14148SHiral Shah return rc; 428abb14148SHiral Shah } 429abb14148SHiral Shah 430abb14148SHiral Shah fnic_fc_trace_enable = debugfs_create_file("fc_trace_enable", 431abb14148SHiral Shah S_IFREG|S_IRUGO|S_IWUSR, 432abb14148SHiral Shah fnic_trace_debugfs_root, 433abb14148SHiral Shah &(fc_trc_flag->fc_trace), 434abb14148SHiral Shah &fnic_trace_ctrl_fops); 435abb14148SHiral Shah 436abb14148SHiral Shah if (!fnic_fc_trace_enable) { 437abb14148SHiral Shah pr_err("fnic: Failed create fc_trace_enable file\n"); 438abb14148SHiral Shah return rc; 439abb14148SHiral Shah } 440abb14148SHiral Shah 441abb14148SHiral Shah fnic_fc_trace_clear = debugfs_create_file("fc_trace_clear", 442abb14148SHiral Shah S_IFREG|S_IRUGO|S_IWUSR, 443abb14148SHiral Shah fnic_trace_debugfs_root, 444abb14148SHiral Shah &(fc_trc_flag->fc_clear), 445abb14148SHiral Shah &fnic_trace_ctrl_fops); 446abb14148SHiral Shah 447abb14148SHiral Shah if (!fnic_fc_trace_clear) { 448abb14148SHiral Shah pr_err("fnic: Failed to create fc_trace_enable file\n"); 449abb14148SHiral Shah return rc; 450abb14148SHiral Shah } 451abb14148SHiral Shah 452abb14148SHiral Shah fnic_fc_rdata_trace_debugfs_file = 453abb14148SHiral Shah debugfs_create_file("fc_trace_rdata", 454abb14148SHiral Shah S_IFREG|S_IRUGO|S_IWUSR, 455abb14148SHiral Shah fnic_trace_debugfs_root, 456abb14148SHiral Shah &(fc_trc_flag->fc_normal_file), 457abb14148SHiral Shah &fnic_trace_debugfs_fops); 458abb14148SHiral Shah 459abb14148SHiral Shah if (!fnic_fc_rdata_trace_debugfs_file) { 460abb14148SHiral Shah pr_err("fnic: Failed create fc_rdata_trace file\n"); 461abb14148SHiral Shah return rc; 462abb14148SHiral Shah } 463abb14148SHiral Shah 464abb14148SHiral Shah fnic_fc_trace_debugfs_file = 465abb14148SHiral Shah debugfs_create_file("fc_trace", 466abb14148SHiral Shah S_IFREG|S_IRUGO|S_IWUSR, 467abb14148SHiral Shah fnic_trace_debugfs_root, 468abb14148SHiral Shah &(fc_trc_flag->fc_row_file), 469abb14148SHiral Shah &fnic_trace_debugfs_fops); 470abb14148SHiral Shah 471abb14148SHiral Shah if (!fnic_fc_trace_debugfs_file) { 472abb14148SHiral Shah pr_err("fnic: Failed to create fc_trace file\n"); 473abb14148SHiral Shah return rc; 474abb14148SHiral Shah } 475abb14148SHiral Shah rc = 0; 476abb14148SHiral Shah return rc; 477abb14148SHiral Shah } 478abb14148SHiral Shah 479abb14148SHiral Shah /* 480abb14148SHiral Shah * fnic_fc_trace_debugfs_terminate - Tear down debugfs infrastructure 481abb14148SHiral Shah * 482abb14148SHiral Shah * Description: 483abb14148SHiral Shah * When Debugfs is configured this routine removes debugfs file system 484abb14148SHiral Shah * elements that are specific to fnic_fc trace logging. 485abb14148SHiral Shah */ 486abb14148SHiral Shah 487abb14148SHiral Shah void fnic_fc_trace_debugfs_terminate(void) 488abb14148SHiral Shah { 489abb14148SHiral Shah debugfs_remove(fnic_fc_trace_debugfs_file); 490abb14148SHiral Shah fnic_fc_trace_debugfs_file = NULL; 491abb14148SHiral Shah 492abb14148SHiral Shah debugfs_remove(fnic_fc_rdata_trace_debugfs_file); 493abb14148SHiral Shah fnic_fc_rdata_trace_debugfs_file = NULL; 494abb14148SHiral Shah 495abb14148SHiral Shah debugfs_remove(fnic_fc_trace_enable); 496abb14148SHiral Shah fnic_fc_trace_enable = NULL; 497abb14148SHiral Shah 498abb14148SHiral Shah debugfs_remove(fnic_fc_trace_clear); 499abb14148SHiral Shah fnic_fc_trace_clear = NULL; 5004d7007b4SHiral Patel } 50167125b02SHiral Patel 50267125b02SHiral Patel /* 50367125b02SHiral Patel * fnic_reset_stats_open - Open the reset_stats file 50467125b02SHiral Patel * @inode: The inode pointer. 50567125b02SHiral Patel * @file: The file pointer to attach the stats reset flag. 50667125b02SHiral Patel * 50767125b02SHiral Patel * Description: 50867125b02SHiral Patel * This routine opens a debugsfs file reset_stats and stores i_private data 50967125b02SHiral Patel * to debug structure to retrieve later for while performing other 51067125b02SHiral Patel * file oprations. 51167125b02SHiral Patel * 51267125b02SHiral Patel * Returns: 51367125b02SHiral Patel * This function returns zero if successful. 51467125b02SHiral Patel */ 51567125b02SHiral Patel static int fnic_reset_stats_open(struct inode *inode, struct file *file) 51667125b02SHiral Patel { 51767125b02SHiral Patel struct stats_debug_info *debug; 51867125b02SHiral Patel 51967125b02SHiral Patel debug = kzalloc(sizeof(struct stats_debug_info), GFP_KERNEL); 52067125b02SHiral Patel if (!debug) 52167125b02SHiral Patel return -ENOMEM; 52267125b02SHiral Patel 52367125b02SHiral Patel debug->i_private = inode->i_private; 52467125b02SHiral Patel 52567125b02SHiral Patel file->private_data = debug; 52667125b02SHiral Patel 52767125b02SHiral Patel return 0; 52867125b02SHiral Patel } 52967125b02SHiral Patel 53067125b02SHiral Patel /* 53167125b02SHiral Patel * fnic_reset_stats_read - Read a reset_stats debugfs file 53267125b02SHiral Patel * @filp: The file pointer to read from. 53367125b02SHiral Patel * @ubuf: The buffer to copy the data to. 53467125b02SHiral Patel * @cnt: The number of bytes to read. 53567125b02SHiral Patel * @ppos: The position in the file to start reading from. 53667125b02SHiral Patel * 53767125b02SHiral Patel * Description: 53867125b02SHiral Patel * This routine reads value of variable reset_stats 53967125b02SHiral Patel * and stores into local @buf. It will start reading file at @ppos and 54067125b02SHiral Patel * copy up to @cnt of data to @ubuf from @buf. 54167125b02SHiral Patel * 54267125b02SHiral Patel * Returns: 54367125b02SHiral Patel * This function returns the amount of data that was read. 54467125b02SHiral Patel */ 54567125b02SHiral Patel static ssize_t fnic_reset_stats_read(struct file *file, 54667125b02SHiral Patel char __user *ubuf, 54767125b02SHiral Patel size_t cnt, loff_t *ppos) 54867125b02SHiral Patel { 54967125b02SHiral Patel struct stats_debug_info *debug = file->private_data; 55067125b02SHiral Patel struct fnic *fnic = (struct fnic *)debug->i_private; 55167125b02SHiral Patel char buf[64]; 55267125b02SHiral Patel int len; 55367125b02SHiral Patel 55467125b02SHiral Patel len = sprintf(buf, "%u\n", fnic->reset_stats); 55567125b02SHiral Patel 55667125b02SHiral Patel return simple_read_from_buffer(ubuf, cnt, ppos, buf, len); 55767125b02SHiral Patel } 55867125b02SHiral Patel 55967125b02SHiral Patel /* 56067125b02SHiral Patel * fnic_reset_stats_write - Write to reset_stats debugfs file 56167125b02SHiral Patel * @filp: The file pointer to write from. 56267125b02SHiral Patel * @ubuf: The buffer to copy the data from. 56367125b02SHiral Patel * @cnt: The number of bytes to write. 56467125b02SHiral Patel * @ppos: The position in the file to start writing to. 56567125b02SHiral Patel * 56667125b02SHiral Patel * Description: 56767125b02SHiral Patel * This routine writes data from user buffer @ubuf to buffer @buf and 56867125b02SHiral Patel * resets cumulative stats of fnic. 56967125b02SHiral Patel * 57067125b02SHiral Patel * Returns: 57167125b02SHiral Patel * This function returns the amount of data that was written. 57267125b02SHiral Patel */ 57367125b02SHiral Patel static ssize_t fnic_reset_stats_write(struct file *file, 57467125b02SHiral Patel const char __user *ubuf, 57567125b02SHiral Patel size_t cnt, loff_t *ppos) 57667125b02SHiral Patel { 57767125b02SHiral Patel struct stats_debug_info *debug = file->private_data; 57867125b02SHiral Patel struct fnic *fnic = (struct fnic *)debug->i_private; 57967125b02SHiral Patel struct fnic_stats *stats = &fnic->fnic_stats; 58067125b02SHiral Patel u64 *io_stats_p = (u64 *)&stats->io_stats; 58167125b02SHiral Patel u64 *fw_stats_p = (u64 *)&stats->fw_stats; 58267125b02SHiral Patel char buf[64]; 58367125b02SHiral Patel unsigned long val; 58467125b02SHiral Patel int ret; 58567125b02SHiral Patel 58667125b02SHiral Patel if (cnt >= sizeof(buf)) 58767125b02SHiral Patel return -EINVAL; 58867125b02SHiral Patel 58967125b02SHiral Patel if (copy_from_user(&buf, ubuf, cnt)) 59067125b02SHiral Patel return -EFAULT; 59167125b02SHiral Patel 59267125b02SHiral Patel buf[cnt] = 0; 59367125b02SHiral Patel 59467125b02SHiral Patel ret = kstrtoul(buf, 10, &val); 59567125b02SHiral Patel if (ret < 0) 59667125b02SHiral Patel return ret; 59767125b02SHiral Patel 59867125b02SHiral Patel fnic->reset_stats = val; 59967125b02SHiral Patel 60067125b02SHiral Patel if (fnic->reset_stats) { 60167125b02SHiral Patel /* Skip variable is used to avoid descrepancies to Num IOs 60267125b02SHiral Patel * and IO Completions stats. Skip incrementing No IO Compls 60367125b02SHiral Patel * for pending active IOs after reset stats 60467125b02SHiral Patel */ 60567125b02SHiral Patel atomic64_set(&fnic->io_cmpl_skip, 60667125b02SHiral Patel atomic64_read(&stats->io_stats.active_ios)); 60767125b02SHiral Patel memset(&stats->abts_stats, 0, sizeof(struct abort_stats)); 60867125b02SHiral Patel memset(&stats->term_stats, 0, 60967125b02SHiral Patel sizeof(struct terminate_stats)); 61067125b02SHiral Patel memset(&stats->reset_stats, 0, sizeof(struct reset_stats)); 61167125b02SHiral Patel memset(&stats->misc_stats, 0, sizeof(struct misc_stats)); 61267125b02SHiral Patel memset(&stats->vlan_stats, 0, sizeof(struct vlan_stats)); 61367125b02SHiral Patel memset(io_stats_p+1, 0, 61467125b02SHiral Patel sizeof(struct io_path_stats) - sizeof(u64)); 61567125b02SHiral Patel memset(fw_stats_p+1, 0, 61667125b02SHiral Patel sizeof(struct fw_stats) - sizeof(u64)); 61743caa03fSSatish Kharat getnstimeofday(&stats->stats_timestamps.last_reset_time); 61867125b02SHiral Patel } 61967125b02SHiral Patel 62067125b02SHiral Patel (*ppos)++; 62167125b02SHiral Patel return cnt; 62267125b02SHiral Patel } 62367125b02SHiral Patel 62467125b02SHiral Patel /* 62567125b02SHiral Patel * fnic_reset_stats_release - Release the buffer used to store 62667125b02SHiral Patel * debugfs file data 62767125b02SHiral Patel * @inode: The inode pointer 62867125b02SHiral Patel * @file: The file pointer that contains the buffer to release 62967125b02SHiral Patel * 63067125b02SHiral Patel * Description: 63167125b02SHiral Patel * This routine frees the buffer that was allocated when the debugfs 63267125b02SHiral Patel * file was opened. 63367125b02SHiral Patel * 63467125b02SHiral Patel * Returns: 63567125b02SHiral Patel * This function returns zero. 63667125b02SHiral Patel */ 63767125b02SHiral Patel static int fnic_reset_stats_release(struct inode *inode, 63867125b02SHiral Patel struct file *file) 63967125b02SHiral Patel { 64067125b02SHiral Patel struct stats_debug_info *debug = file->private_data; 64167125b02SHiral Patel kfree(debug); 64267125b02SHiral Patel return 0; 64367125b02SHiral Patel } 64467125b02SHiral Patel 64567125b02SHiral Patel /* 64667125b02SHiral Patel * fnic_stats_debugfs_open - Open the stats file for specific host 64767125b02SHiral Patel * and get fnic stats. 64867125b02SHiral Patel * @inode: The inode pointer. 64967125b02SHiral Patel * @file: The file pointer to attach the specific host statistics. 65067125b02SHiral Patel * 65167125b02SHiral Patel * Description: 65267125b02SHiral Patel * This routine opens a debugsfs file stats of specific host and print 65367125b02SHiral Patel * fnic stats. 65467125b02SHiral Patel * 65567125b02SHiral Patel * Returns: 65667125b02SHiral Patel * This function returns zero if successful. 65767125b02SHiral Patel */ 65867125b02SHiral Patel static int fnic_stats_debugfs_open(struct inode *inode, 65967125b02SHiral Patel struct file *file) 66067125b02SHiral Patel { 66167125b02SHiral Patel struct fnic *fnic = inode->i_private; 66267125b02SHiral Patel struct fnic_stats *fnic_stats = &fnic->fnic_stats; 66367125b02SHiral Patel struct stats_debug_info *debug; 66467125b02SHiral Patel int buf_size = 2 * PAGE_SIZE; 66567125b02SHiral Patel 66667125b02SHiral Patel debug = kzalloc(sizeof(struct stats_debug_info), GFP_KERNEL); 66767125b02SHiral Patel if (!debug) 66867125b02SHiral Patel return -ENOMEM; 66967125b02SHiral Patel 67067125b02SHiral Patel debug->debug_buffer = vmalloc(buf_size); 67167125b02SHiral Patel if (!debug->debug_buffer) { 67267125b02SHiral Patel kfree(debug); 67367125b02SHiral Patel return -ENOMEM; 67467125b02SHiral Patel } 67567125b02SHiral Patel 67667125b02SHiral Patel debug->buf_size = buf_size; 67767125b02SHiral Patel memset((void *)debug->debug_buffer, 0, buf_size); 67867125b02SHiral Patel debug->buffer_len = fnic_get_stats_data(debug, fnic_stats); 67967125b02SHiral Patel 68067125b02SHiral Patel file->private_data = debug; 68167125b02SHiral Patel 68267125b02SHiral Patel return 0; 68367125b02SHiral Patel } 68467125b02SHiral Patel 68567125b02SHiral Patel /* 68667125b02SHiral Patel * fnic_stats_debugfs_read - Read a debugfs file 68767125b02SHiral Patel * @file: The file pointer to read from. 68867125b02SHiral Patel * @ubuf: The buffer to copy the data to. 68967125b02SHiral Patel * @nbytes: The number of bytes to read. 69067125b02SHiral Patel * @pos: The position in the file to start reading from. 69167125b02SHiral Patel * 69267125b02SHiral Patel * Description: 69367125b02SHiral Patel * This routine reads data from the buffer indicated in the private_data 69467125b02SHiral Patel * field of @file. It will start reading at @pos and copy up to @nbytes of 69567125b02SHiral Patel * data to @ubuf. 69667125b02SHiral Patel * 69767125b02SHiral Patel * Returns: 69867125b02SHiral Patel * This function returns the amount of data that was read (this could be 69967125b02SHiral Patel * less than @nbytes if the end of the file was reached). 70067125b02SHiral Patel */ 70167125b02SHiral Patel static ssize_t fnic_stats_debugfs_read(struct file *file, 70267125b02SHiral Patel char __user *ubuf, 70367125b02SHiral Patel size_t nbytes, 70467125b02SHiral Patel loff_t *pos) 70567125b02SHiral Patel { 70667125b02SHiral Patel struct stats_debug_info *debug = file->private_data; 70767125b02SHiral Patel int rc = 0; 70867125b02SHiral Patel rc = simple_read_from_buffer(ubuf, nbytes, pos, 70967125b02SHiral Patel debug->debug_buffer, 71067125b02SHiral Patel debug->buffer_len); 71167125b02SHiral Patel return rc; 71267125b02SHiral Patel } 71367125b02SHiral Patel 71467125b02SHiral Patel /* 71567125b02SHiral Patel * fnic_stats_stats_release - Release the buffer used to store 71667125b02SHiral Patel * debugfs file data 71767125b02SHiral Patel * @inode: The inode pointer 71867125b02SHiral Patel * @file: The file pointer that contains the buffer to release 71967125b02SHiral Patel * 72067125b02SHiral Patel * Description: 72167125b02SHiral Patel * This routine frees the buffer that was allocated when the debugfs 72267125b02SHiral Patel * file was opened. 72367125b02SHiral Patel * 72467125b02SHiral Patel * Returns: 72567125b02SHiral Patel * This function returns zero. 72667125b02SHiral Patel */ 72767125b02SHiral Patel static int fnic_stats_debugfs_release(struct inode *inode, 72867125b02SHiral Patel struct file *file) 72967125b02SHiral Patel { 73067125b02SHiral Patel struct stats_debug_info *debug = file->private_data; 73167125b02SHiral Patel vfree(debug->debug_buffer); 73267125b02SHiral Patel kfree(debug); 73367125b02SHiral Patel return 0; 73467125b02SHiral Patel } 73567125b02SHiral Patel 73667125b02SHiral Patel static const struct file_operations fnic_stats_debugfs_fops = { 73767125b02SHiral Patel .owner = THIS_MODULE, 73867125b02SHiral Patel .open = fnic_stats_debugfs_open, 73967125b02SHiral Patel .read = fnic_stats_debugfs_read, 74067125b02SHiral Patel .release = fnic_stats_debugfs_release, 74167125b02SHiral Patel }; 74267125b02SHiral Patel 74367125b02SHiral Patel static const struct file_operations fnic_reset_debugfs_fops = { 74467125b02SHiral Patel .owner = THIS_MODULE, 74567125b02SHiral Patel .open = fnic_reset_stats_open, 74667125b02SHiral Patel .read = fnic_reset_stats_read, 74767125b02SHiral Patel .write = fnic_reset_stats_write, 74867125b02SHiral Patel .release = fnic_reset_stats_release, 74967125b02SHiral Patel }; 75067125b02SHiral Patel 75167125b02SHiral Patel /* 75267125b02SHiral Patel * fnic_stats_init - Initialize stats struct and create stats file per fnic 75367125b02SHiral Patel * 75467125b02SHiral Patel * Description: 75567125b02SHiral Patel * When Debugfs is configured this routine sets up the stats file per fnic 75667125b02SHiral Patel * It will create file stats and reset_stats under statistics/host# directory 75767125b02SHiral Patel * to log per fnic stats. 75867125b02SHiral Patel */ 75967125b02SHiral Patel int fnic_stats_debugfs_init(struct fnic *fnic) 76067125b02SHiral Patel { 76167125b02SHiral Patel int rc = -1; 76267125b02SHiral Patel char name[16]; 76367125b02SHiral Patel 76467125b02SHiral Patel snprintf(name, sizeof(name), "host%d", fnic->lport->host->host_no); 76567125b02SHiral Patel 76667125b02SHiral Patel if (!fnic_stats_debugfs_root) { 76767125b02SHiral Patel printk(KERN_DEBUG "fnic_stats root doesn't exist\n"); 76867125b02SHiral Patel return rc; 76967125b02SHiral Patel } 77067125b02SHiral Patel fnic->fnic_stats_debugfs_host = debugfs_create_dir(name, 77167125b02SHiral Patel fnic_stats_debugfs_root); 77267125b02SHiral Patel if (!fnic->fnic_stats_debugfs_host) { 77367125b02SHiral Patel printk(KERN_DEBUG "Cannot create host directory\n"); 77467125b02SHiral Patel return rc; 77567125b02SHiral Patel } 77667125b02SHiral Patel 77767125b02SHiral Patel fnic->fnic_stats_debugfs_file = debugfs_create_file("stats", 77867125b02SHiral Patel S_IFREG|S_IRUGO|S_IWUSR, 77967125b02SHiral Patel fnic->fnic_stats_debugfs_host, 78067125b02SHiral Patel fnic, 78167125b02SHiral Patel &fnic_stats_debugfs_fops); 78267125b02SHiral Patel if (!fnic->fnic_stats_debugfs_file) { 78367125b02SHiral Patel printk(KERN_DEBUG "Cannot create host stats file\n"); 78467125b02SHiral Patel return rc; 78567125b02SHiral Patel } 78667125b02SHiral Patel 78767125b02SHiral Patel fnic->fnic_reset_debugfs_file = debugfs_create_file("reset_stats", 78867125b02SHiral Patel S_IFREG|S_IRUGO|S_IWUSR, 78967125b02SHiral Patel fnic->fnic_stats_debugfs_host, 79067125b02SHiral Patel fnic, 79167125b02SHiral Patel &fnic_reset_debugfs_fops); 79267125b02SHiral Patel if (!fnic->fnic_reset_debugfs_file) { 79367125b02SHiral Patel printk(KERN_DEBUG "Cannot create host stats file\n"); 79467125b02SHiral Patel return rc; 79567125b02SHiral Patel } 79667125b02SHiral Patel rc = 0; 79767125b02SHiral Patel return rc; 79867125b02SHiral Patel } 79967125b02SHiral Patel 80067125b02SHiral Patel /* 80167125b02SHiral Patel * fnic_stats_debugfs_remove - Tear down debugfs infrastructure of stats 80267125b02SHiral Patel * 80367125b02SHiral Patel * Description: 80467125b02SHiral Patel * When Debugfs is configured this routine removes debugfs file system 80567125b02SHiral Patel * elements that are specific to fnic stats. 80667125b02SHiral Patel */ 80767125b02SHiral Patel void fnic_stats_debugfs_remove(struct fnic *fnic) 80867125b02SHiral Patel { 80967125b02SHiral Patel if (!fnic) 81067125b02SHiral Patel return; 81167125b02SHiral Patel 81267125b02SHiral Patel debugfs_remove(fnic->fnic_stats_debugfs_file); 81367125b02SHiral Patel fnic->fnic_stats_debugfs_file = NULL; 81467125b02SHiral Patel 81567125b02SHiral Patel debugfs_remove(fnic->fnic_reset_debugfs_file); 81667125b02SHiral Patel fnic->fnic_reset_debugfs_file = NULL; 81767125b02SHiral Patel 81867125b02SHiral Patel debugfs_remove(fnic->fnic_stats_debugfs_host); 81967125b02SHiral Patel fnic->fnic_stats_debugfs_host = NULL; 8204d7007b4SHiral Patel } 821