^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2) * Copyright 2014 Cisco Systems, Inc. All rights reserved.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4) * This program is free software; you may redistribute it and/or modify
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5) * it under the terms of the GNU General Public License as published by
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6) * the Free Software Foundation; version 2 of the License.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8) * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9) * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) * SOFTWARE.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) #include <linux/module.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) #include <linux/errno.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) #include <linux/debugfs.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) #include "snic.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) * snic_debugfs_init - Initialize debugfs for snic debug logging
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) * Description:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) * When Debugfs is configured this routine sets up fnic debugfs
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) * filesystem. If not already created. this routine will crate the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) * fnic directory and statistics directory for trace buffer and
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) * stats logging
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) void snic_debugfs_init(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) snic_glob->trc_root = debugfs_create_dir("snic", NULL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) snic_glob->stats_root = debugfs_create_dir("statistics",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) snic_glob->trc_root);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) * snic_debugfs_term - Tear down debugfs intrastructure
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) * Description:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) * When Debufs is configured this routine removes debugfs file system
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) * elements that are specific to snic
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) snic_debugfs_term(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51) debugfs_remove(snic_glob->stats_root);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52) snic_glob->stats_root = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54) debugfs_remove(snic_glob->trc_root);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55) snic_glob->trc_root = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59) * snic_reset_stats_open - Open the reset_stats file
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61) static int
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62) snic_reset_stats_open(struct inode *inode, struct file *filp)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64) SNIC_BUG_ON(!inode->i_private);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 65) filp->private_data = inode->i_private;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 66)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 67) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 68) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 69)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 70) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 71) * snic_reset_stats_read - Read a reset_stats debugfs file
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 72) * @filp: The file pointer to read from.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 73) * @ubuf: The buffer tocopy the data to.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 74) * @cnt: The number of bytes to read.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 75) * @ppos: The position in the file to start reading frm.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 76) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 77) * Description:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 78) * This routine reads value of variable reset_stats
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 79) * and stores into local @buf. It will start reading file @ppos and
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 80) * copy up to @cnt of data to @ubuf from @buf.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 81) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 82) * Returns:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 83) * This function returns the amount of data that was read.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 84) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 85) static ssize_t
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 86) snic_reset_stats_read(struct file *filp,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 87) char __user *ubuf,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 88) size_t cnt,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 89) loff_t *ppos)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 90) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 91) struct snic *snic = (struct snic *) filp->private_data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 92) char buf[64];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 93) int len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 94)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 95) len = sprintf(buf, "%u\n", snic->reset_stats);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 96)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 97) return simple_read_from_buffer(ubuf, cnt, ppos, buf, len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 98) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 99)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) * snic_reset_stats_write - Write to reset_stats debugfs file
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) * @filp: The file pointer to write from
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) * @ubuf: The buffer to copy the data from.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) * @cnt: The number of bytes to write.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) * @ppos: The position in the file to start writing to.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) * Description:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) * This routine writes data from user buffer @ubuf to buffer @buf and
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) * resets cumulative stats of snic.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) * Returns:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) * This function returns the amount of data that was written.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) static ssize_t
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) snic_reset_stats_write(struct file *filp,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) const char __user *ubuf,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) size_t cnt,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) loff_t *ppos)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) struct snic *snic = (struct snic *) filp->private_data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) struct snic_stats *stats = &snic->s_stats;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) u64 *io_stats_p = (u64 *) &stats->io;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) u64 *fw_stats_p = (u64 *) &stats->fw;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) char buf[64];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) unsigned long val;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) int ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128) if (cnt >= sizeof(buf))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129) return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) if (copy_from_user(&buf, ubuf, cnt))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132) return -EFAULT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134) buf[cnt] = '\0';
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136) ret = kstrtoul(buf, 10, &val);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137) if (ret < 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138) return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140) snic->reset_stats = val;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142) if (snic->reset_stats) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143) /* Skip variable is used to avoid descrepancies to Num IOs
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144) * and IO Completions stats. Skip incrementing No IO Compls
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145) * for pending active IOs after reset_stats
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147) atomic64_set(&snic->io_cmpl_skip,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148) atomic64_read(&stats->io.active));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149) memset(&stats->abts, 0, sizeof(struct snic_abort_stats));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150) memset(&stats->reset, 0, sizeof(struct snic_reset_stats));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151) memset(&stats->misc, 0, sizeof(struct snic_misc_stats));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152) memset(io_stats_p+1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153) 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154) sizeof(struct snic_io_stats) - sizeof(u64));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155) memset(fw_stats_p+1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156) 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157) sizeof(struct snic_fw_stats) - sizeof(u64));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160) (*ppos)++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162) SNIC_HOST_INFO(snic->shost, "Reset Op: Driver statistics.\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164) return cnt;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167) static int
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168) snic_reset_stats_release(struct inode *inode, struct file *filp)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170) filp->private_data = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 174)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 175) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 176) * snic_stats_show - Formats and prints per host specific driver stats.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 177) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 178) static int
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 179) snic_stats_show(struct seq_file *sfp, void *data)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 180) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 181) struct snic *snic = (struct snic *) sfp->private;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 182) struct snic_stats *stats = &snic->s_stats;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 183) struct timespec64 last_isr_tms, last_ack_tms;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 184) u64 maxio_tm;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 185) int i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 186)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 187) /* Dump IO Stats */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 188) seq_printf(sfp,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 189) "------------------------------------------\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 190) "\t\t IO Statistics\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 191) "------------------------------------------\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 192)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 193) maxio_tm = (u64) atomic64_read(&stats->io.max_time);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 194) seq_printf(sfp,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 195) "Active IOs : %lld\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 196) "Max Active IOs : %lld\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 197) "Total IOs : %lld\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 198) "IOs Completed : %lld\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 199) "IOs Failed : %lld\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 200) "IOs Not Found : %lld\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 201) "Memory Alloc Failures : %lld\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 202) "REQs Null : %lld\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 203) "SCSI Cmd Pointers Null : %lld\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 204) "Max SGL for any IO : %lld\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 205) "Max IO Size : %lld Sectors\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 206) "Max Queuing Time : %lld\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 207) "Max Completion Time : %lld\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 208) "Max IO Process Time(FW) : %lld (%u msec)\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 209) (u64) atomic64_read(&stats->io.active),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 210) (u64) atomic64_read(&stats->io.max_active),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 211) (u64) atomic64_read(&stats->io.num_ios),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 212) (u64) atomic64_read(&stats->io.compl),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 213) (u64) atomic64_read(&stats->io.fail),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 214) (u64) atomic64_read(&stats->io.io_not_found),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 215) (u64) atomic64_read(&stats->io.alloc_fail),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 216) (u64) atomic64_read(&stats->io.req_null),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 217) (u64) atomic64_read(&stats->io.sc_null),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 218) (u64) atomic64_read(&stats->io.max_sgl),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 219) (u64) atomic64_read(&stats->io.max_io_sz),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 220) (u64) atomic64_read(&stats->io.max_qtime),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 221) (u64) atomic64_read(&stats->io.max_cmpl_time),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 222) maxio_tm,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 223) jiffies_to_msecs(maxio_tm));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 224)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 225) seq_puts(sfp, "\nSGL Counters\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 226)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 227) for (i = 0; i < SNIC_MAX_SG_DESC_CNT; i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 228) seq_printf(sfp,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 229) "%10lld ",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 230) (u64) atomic64_read(&stats->io.sgl_cnt[i]));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 231)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 232) if ((i + 1) % 8 == 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 233) seq_puts(sfp, "\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 234) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 235)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 236) /* Dump Abort Stats */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 237) seq_printf(sfp,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 238) "\n-------------------------------------------\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 239) "\t\t Abort Statistics\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 240) "---------------------------------------------\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 241)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 242) seq_printf(sfp,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 243) "Aborts : %lld\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 244) "Aborts Fail : %lld\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 245) "Aborts Driver Timeout : %lld\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 246) "Abort FW Timeout : %lld\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 247) "Abort IO NOT Found : %lld\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 248) "Abort Queuing Failed : %lld\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 249) (u64) atomic64_read(&stats->abts.num),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 250) (u64) atomic64_read(&stats->abts.fail),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 251) (u64) atomic64_read(&stats->abts.drv_tmo),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 252) (u64) atomic64_read(&stats->abts.fw_tmo),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 253) (u64) atomic64_read(&stats->abts.io_not_found),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 254) (u64) atomic64_read(&stats->abts.q_fail));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 255)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 256) /* Dump Reset Stats */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 257) seq_printf(sfp,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 258) "\n-------------------------------------------\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 259) "\t\t Reset Statistics\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 260) "---------------------------------------------\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 261)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 262) seq_printf(sfp,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 263) "HBA Resets : %lld\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 264) "HBA Reset Cmpls : %lld\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 265) "HBA Reset Fail : %lld\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 266) (u64) atomic64_read(&stats->reset.hba_resets),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 267) (u64) atomic64_read(&stats->reset.hba_reset_cmpl),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 268) (u64) atomic64_read(&stats->reset.hba_reset_fail));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 269)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 270) /* Dump Firmware Stats */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 271) seq_printf(sfp,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 272) "\n-------------------------------------------\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 273) "\t\t Firmware Statistics\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 274) "---------------------------------------------\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 275)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 276) seq_printf(sfp,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 277) "Active FW Requests : %lld\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 278) "Max FW Requests : %lld\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 279) "FW Out Of Resource Errs : %lld\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 280) "FW IO Errors : %lld\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 281) "FW SCSI Errors : %lld\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 282) (u64) atomic64_read(&stats->fw.actv_reqs),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 283) (u64) atomic64_read(&stats->fw.max_actv_reqs),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 284) (u64) atomic64_read(&stats->fw.out_of_res),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 285) (u64) atomic64_read(&stats->fw.io_errs),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 286) (u64) atomic64_read(&stats->fw.scsi_errs));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 287)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 288)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 289) /* Dump Miscellenous Stats */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 290) seq_printf(sfp,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 291) "\n---------------------------------------------\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 292) "\t\t Other Statistics\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 293) "\n---------------------------------------------\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 294)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 295) jiffies_to_timespec64(stats->misc.last_isr_time, &last_isr_tms);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 296) jiffies_to_timespec64(stats->misc.last_ack_time, &last_ack_tms);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 297)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 298) seq_printf(sfp,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 299) "Last ISR Time : %llu (%8llu.%09lu)\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 300) "Last Ack Time : %llu (%8llu.%09lu)\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 301) "Ack ISRs : %llu\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 302) "IO Cmpl ISRs : %llu\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 303) "Err Notify ISRs : %llu\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 304) "Max CQ Entries : %lld\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 305) "Data Count Mismatch : %lld\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 306) "IOs w/ Timeout Status : %lld\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 307) "IOs w/ Aborted Status : %lld\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 308) "IOs w/ SGL Invalid Stat : %lld\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 309) "WQ Desc Alloc Fail : %lld\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 310) "Queue Full : %lld\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 311) "Queue Ramp Up : %lld\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 312) "Queue Ramp Down : %lld\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 313) "Queue Last Queue Depth : %lld\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 314) "Target Not Ready : %lld\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 315) (u64) stats->misc.last_isr_time,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 316) last_isr_tms.tv_sec, last_isr_tms.tv_nsec,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 317) (u64)stats->misc.last_ack_time,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 318) last_ack_tms.tv_sec, last_ack_tms.tv_nsec,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 319) (u64) atomic64_read(&stats->misc.ack_isr_cnt),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 320) (u64) atomic64_read(&stats->misc.cmpl_isr_cnt),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 321) (u64) atomic64_read(&stats->misc.errnotify_isr_cnt),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 322) (u64) atomic64_read(&stats->misc.max_cq_ents),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 323) (u64) atomic64_read(&stats->misc.data_cnt_mismat),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 324) (u64) atomic64_read(&stats->misc.io_tmo),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 325) (u64) atomic64_read(&stats->misc.io_aborted),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 326) (u64) atomic64_read(&stats->misc.sgl_inval),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 327) (u64) atomic64_read(&stats->misc.wq_alloc_fail),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 328) (u64) atomic64_read(&stats->misc.qfull),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 329) (u64) atomic64_read(&stats->misc.qsz_rampup),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 330) (u64) atomic64_read(&stats->misc.qsz_rampdown),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 331) (u64) atomic64_read(&stats->misc.last_qsz),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 332) (u64) atomic64_read(&stats->misc.tgt_not_rdy));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 333)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 334) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 335) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 336)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 337) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 338) * snic_stats_open - Open the stats file for specific host
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 339) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 340) * Description:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 341) * This routine opens a debugfs file stats of specific host
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 342) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 343) static int
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 344) snic_stats_open(struct inode *inode, struct file *filp)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 345) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 346) return single_open(filp, snic_stats_show, inode->i_private);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 347) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 348)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 349) static const struct file_operations snic_stats_fops = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 350) .owner = THIS_MODULE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 351) .open = snic_stats_open,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 352) .read = seq_read,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 353) .llseek = seq_lseek,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 354) .release = single_release,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 355) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 356)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 357) static const struct file_operations snic_reset_stats_fops = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 358) .owner = THIS_MODULE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 359) .open = snic_reset_stats_open,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 360) .read = snic_reset_stats_read,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 361) .write = snic_reset_stats_write,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 362) .release = snic_reset_stats_release,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 363) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 364)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 365) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 366) * snic_stats_init - Initialize stats struct and create stats file
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 367) * per snic
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 368) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 369) * Description:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 370) * When debugfs is cofigured this routine sets up the stats file per snic
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 371) * It will create file stats and reset_stats under statistics/host# directory
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 372) * to log per snic stats
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 373) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 374) void snic_stats_debugfs_init(struct snic *snic)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 375) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 376) char name[16];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 377)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 378) snprintf(name, sizeof(name), "host%d", snic->shost->host_no);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 379)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 380) snic->stats_host = debugfs_create_dir(name, snic_glob->stats_root);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 381)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 382) snic->stats_file = debugfs_create_file("stats", S_IFREG|S_IRUGO,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 383) snic->stats_host, snic,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 384) &snic_stats_fops);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 385)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 386) snic->reset_stats_file = debugfs_create_file("reset_stats",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 387) S_IFREG|S_IRUGO|S_IWUSR,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 388) snic->stats_host, snic,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 389) &snic_reset_stats_fops);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 390) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 391)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 392) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 393) * snic_stats_debugfs_remove - Tear down debugfs infrastructure of stats
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 394) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 395) * Description:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 396) * When Debufs is configured this routine removes debugfs file system
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 397) * elements that are specific to to snic stats
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 398) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 399) void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 400) snic_stats_debugfs_remove(struct snic *snic)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 401) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 402) debugfs_remove(snic->stats_file);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 403) snic->stats_file = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 404)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 405) debugfs_remove(snic->reset_stats_file);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 406) snic->reset_stats_file = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 407)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 408) debugfs_remove(snic->stats_host);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 409) snic->stats_host = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 410) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 411)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 412) /* Trace Facility related API */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 413) static void *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 414) snic_trc_seq_start(struct seq_file *sfp, loff_t *pos)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 415) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 416) return &snic_glob->trc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 417) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 418)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 419) static void *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 420) snic_trc_seq_next(struct seq_file *sfp, void *data, loff_t *pos)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 421) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 422) return NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 423) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 424)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 425) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 426) snic_trc_seq_stop(struct seq_file *sfp, void *data)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 427) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 428) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 429)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 430) #define SNIC_TRC_PBLEN 256
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 431) static int
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 432) snic_trc_seq_show(struct seq_file *sfp, void *data)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 433) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 434) char buf[SNIC_TRC_PBLEN];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 435)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 436) if (snic_get_trc_data(buf, SNIC_TRC_PBLEN) > 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 437) seq_printf(sfp, "%s\n", buf);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 438)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 439) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 440) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 441)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 442) static const struct seq_operations snic_trc_sops = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 443) .start = snic_trc_seq_start,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 444) .next = snic_trc_seq_next,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 445) .stop = snic_trc_seq_stop,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 446) .show = snic_trc_seq_show,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 447) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 448)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 449) DEFINE_SEQ_ATTRIBUTE(snic_trc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 450)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 451) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 452) * snic_trc_debugfs_init : creates trace/tracing_enable files for trace
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 453) * under debugfs
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 454) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 455) void snic_trc_debugfs_init(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 456) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 457) snic_glob->trc.trc_enable = debugfs_create_bool("tracing_enable",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 458) S_IFREG | S_IRUGO | S_IWUSR,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 459) snic_glob->trc_root,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 460) &snic_glob->trc.enable);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 461)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 462) snic_glob->trc.trc_file = debugfs_create_file("trace",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 463) S_IFREG | S_IRUGO | S_IWUSR,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 464) snic_glob->trc_root, NULL,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 465) &snic_trc_fops);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 466) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 467)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 468) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 469) * snic_trc_debugfs_term : cleans up the files created for trace under debugfs
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 470) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 471) void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 472) snic_trc_debugfs_term(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 473) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 474) debugfs_remove(snic_glob->trc.trc_file);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 475) snic_glob->trc.trc_file = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 476)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 477) debugfs_remove(snic_glob->trc.trc_enable);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 478) snic_glob->trc.trc_enable = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 479) }