^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2) * Copyright 2012 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/mempool.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) #include <linux/errno.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) #include <linux/spinlock.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) #include <linux/kallsyms.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) #include <linux/time.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) #include <linux/vmalloc.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) #include "fnic_io.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) #include "fnic.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) unsigned int trace_max_pages;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) static int fnic_max_trace_entries;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) static unsigned long fnic_trace_buf_p;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) static DEFINE_SPINLOCK(fnic_trace_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) static fnic_trace_dbg_t fnic_trace_entries;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) int fnic_tracing_enabled = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) /* static char *fnic_fc_ctlr_trace_buf_p; */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) static int fc_trace_max_entries;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) static unsigned long fnic_fc_ctlr_trace_buf_p;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) static fnic_trace_dbg_t fc_trace_entries;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) int fnic_fc_tracing_enabled = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) int fnic_fc_trace_cleared = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) static DEFINE_SPINLOCK(fnic_fc_trace_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) * fnic_trace_get_buf - Give buffer pointer to user to fill up trace information
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50) * Description:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51) * This routine gets next available trace buffer entry location @wr_idx
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52) * from allocated trace buffer pages and give that memory location
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53) * to user to store the trace information.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55) * Return Value:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56) * This routine returns pointer to next available trace entry
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57) * @fnic_buf_head for user to fill trace information.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59) fnic_trace_data_t *fnic_trace_get_buf(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61) unsigned long fnic_buf_head;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62) unsigned long flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64) spin_lock_irqsave(&fnic_trace_lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 65)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 66) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 67) * Get next available memory location for writing trace information
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 68) * at @wr_idx and increment @wr_idx
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 69) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 70) fnic_buf_head =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 71) fnic_trace_entries.page_offset[fnic_trace_entries.wr_idx];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 72) fnic_trace_entries.wr_idx++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 73)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 74) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 75) * Verify if trace buffer is full then change wd_idx to
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 76) * start from zero
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 77) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 78) if (fnic_trace_entries.wr_idx >= fnic_max_trace_entries)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 79) fnic_trace_entries.wr_idx = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 80)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 81) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 82) * Verify if write index @wr_idx and read index @rd_idx are same then
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 83) * increment @rd_idx to move to next entry in trace buffer
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 84) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 85) if (fnic_trace_entries.wr_idx == fnic_trace_entries.rd_idx) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 86) fnic_trace_entries.rd_idx++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 87) if (fnic_trace_entries.rd_idx >= fnic_max_trace_entries)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 88) fnic_trace_entries.rd_idx = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 89) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 90) spin_unlock_irqrestore(&fnic_trace_lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 91) return (fnic_trace_data_t *)fnic_buf_head;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 92) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 93)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 94) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 95) * fnic_get_trace_data - Copy trace buffer to a memory file
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 96) * @fnic_dbgfs_t: pointer to debugfs trace buffer
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 97) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 98) * Description:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 99) * This routine gathers the fnic trace debugfs data from the fnic_trace_data_t
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) * buffer and dumps it to fnic_dbgfs_t. It will start at the rd_idx entry in
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) * the log and process the log until the end of the buffer. Then it will gather
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) * from the beginning of the log and process until the current entry @wr_idx.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) * Return Value:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) * This routine returns the amount of bytes that were dumped into fnic_dbgfs_t
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) int fnic_get_trace_data(fnic_dbgfs_t *fnic_dbgfs_prt)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) int rd_idx;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) int wr_idx;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) int len = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) unsigned long flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) char str[KSYM_SYMBOL_LEN];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) struct timespec64 val;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) fnic_trace_data_t *tbp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) spin_lock_irqsave(&fnic_trace_lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) rd_idx = fnic_trace_entries.rd_idx;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) wr_idx = fnic_trace_entries.wr_idx;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) if (wr_idx < rd_idx) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) while (1) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) /* Start from read index @rd_idx */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) tbp = (fnic_trace_data_t *)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) fnic_trace_entries.page_offset[rd_idx];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) if (!tbp) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) spin_unlock_irqrestore(&fnic_trace_lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129) /* Convert function pointer to function name */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130) if (sizeof(unsigned long) < 8) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) sprint_symbol(str, tbp->fnaddr.low);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132) jiffies_to_timespec64(tbp->timestamp.low, &val);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134) sprint_symbol(str, tbp->fnaddr.val);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135) jiffies_to_timespec64(tbp->timestamp.val, &val);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138) * Dump trace buffer entry to memory file
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139) * and increment read index @rd_idx
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141) len += scnprintf(fnic_dbgfs_prt->buffer + len,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142) (trace_max_pages * PAGE_SIZE * 3) - len,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143) "%16llu.%09lu %-50s %8x %8x %16llx %16llx "
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144) "%16llx %16llx %16llx\n", (u64)val.tv_sec,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145) val.tv_nsec, str, tbp->host_no, tbp->tag,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146) tbp->data[0], tbp->data[1], tbp->data[2],
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147) tbp->data[3], tbp->data[4]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148) rd_idx++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150) * If rd_idx is reached to maximum trace entries
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151) * then move rd_idx to zero
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153) if (rd_idx > (fnic_max_trace_entries-1))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154) rd_idx = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156) * Continure dumpping trace buffer entries into
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157) * memory file till rd_idx reaches write index
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159) if (rd_idx == wr_idx)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162) } else if (wr_idx > rd_idx) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163) while (1) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164) /* Start from read index @rd_idx */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165) tbp = (fnic_trace_data_t *)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166) fnic_trace_entries.page_offset[rd_idx];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167) if (!tbp) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168) spin_unlock_irqrestore(&fnic_trace_lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171) /* Convert function pointer to function name */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172) if (sizeof(unsigned long) < 8) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173) sprint_symbol(str, tbp->fnaddr.low);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 174) jiffies_to_timespec64(tbp->timestamp.low, &val);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 175) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 176) sprint_symbol(str, tbp->fnaddr.val);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 177) jiffies_to_timespec64(tbp->timestamp.val, &val);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 178) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 179) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 180) * Dump trace buffer entry to memory file
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 181) * and increment read index @rd_idx
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 182) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 183) len += scnprintf(fnic_dbgfs_prt->buffer + len,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 184) (trace_max_pages * PAGE_SIZE * 3) - len,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 185) "%16llu.%09lu %-50s %8x %8x %16llx %16llx "
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 186) "%16llx %16llx %16llx\n", (u64)val.tv_sec,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 187) val.tv_nsec, str, tbp->host_no, tbp->tag,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 188) tbp->data[0], tbp->data[1], tbp->data[2],
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 189) tbp->data[3], tbp->data[4]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 190) rd_idx++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 191) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 192) * Continue dumpping trace buffer entries into
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 193) * memory file till rd_idx reaches write index
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 194) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 195) if (rd_idx == wr_idx)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 196) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 197) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 198) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 199) spin_unlock_irqrestore(&fnic_trace_lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 200) return len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 201) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 202)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 203) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 204) * fnic_get_stats_data - Copy fnic stats buffer to a memory file
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 205) * @fnic_dbgfs_t: pointer to debugfs fnic stats buffer
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 206) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 207) * Description:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 208) * This routine gathers the fnic stats debugfs data from the fnic_stats struct
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 209) * and dumps it to stats_debug_info.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 210) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 211) * Return Value:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 212) * This routine returns the amount of bytes that were dumped into
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 213) * stats_debug_info
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 214) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 215) int fnic_get_stats_data(struct stats_debug_info *debug,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 216) struct fnic_stats *stats)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 217) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 218) int len = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 219) int buf_size = debug->buf_size;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 220) struct timespec64 val1, val2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 221)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 222) ktime_get_real_ts64(&val1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 223) len = scnprintf(debug->debug_buffer + len, buf_size - len,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 224) "------------------------------------------\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 225) "\t\tTime\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 226) "------------------------------------------\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 227)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 228) len += scnprintf(debug->debug_buffer + len, buf_size - len,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 229) "Current time : [%lld:%ld]\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 230) "Last stats reset time: [%lld:%09ld]\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 231) "Last stats read time: [%lld:%ld]\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 232) "delta since last reset: [%lld:%ld]\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 233) "delta since last read: [%lld:%ld]\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 234) (s64)val1.tv_sec, val1.tv_nsec,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 235) (s64)stats->stats_timestamps.last_reset_time.tv_sec,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 236) stats->stats_timestamps.last_reset_time.tv_nsec,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 237) (s64)stats->stats_timestamps.last_read_time.tv_sec,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 238) stats->stats_timestamps.last_read_time.tv_nsec,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 239) (s64)timespec64_sub(val1, stats->stats_timestamps.last_reset_time).tv_sec,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 240) timespec64_sub(val1, stats->stats_timestamps.last_reset_time).tv_nsec,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 241) (s64)timespec64_sub(val1, stats->stats_timestamps.last_read_time).tv_sec,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 242) timespec64_sub(val1, stats->stats_timestamps.last_read_time).tv_nsec);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 243)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 244) stats->stats_timestamps.last_read_time = val1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 245)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 246) len += scnprintf(debug->debug_buffer + len, buf_size - len,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 247) "------------------------------------------\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 248) "\t\tIO Statistics\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 249) "------------------------------------------\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 250) len += scnprintf(debug->debug_buffer + len, buf_size - len,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 251) "Number of Active IOs: %lld\nMaximum Active IOs: %lld\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 252) "Number of IOs: %lld\nNumber of IO Completions: %lld\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 253) "Number of IO Failures: %lld\nNumber of IO NOT Found: %lld\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 254) "Number of Memory alloc Failures: %lld\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 255) "Number of IOREQ Null: %lld\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 256) "Number of SCSI cmd pointer Null: %lld\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 257)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 258) "\nIO completion times: \n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 259) " < 10 ms : %lld\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 260) " 10 ms - 100 ms : %lld\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 261) " 100 ms - 500 ms : %lld\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 262) " 500 ms - 5 sec: %lld\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 263) " 5 sec - 10 sec: %lld\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 264) " 10 sec - 30 sec: %lld\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 265) " > 30 sec: %lld\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 266) (u64)atomic64_read(&stats->io_stats.active_ios),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 267) (u64)atomic64_read(&stats->io_stats.max_active_ios),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 268) (u64)atomic64_read(&stats->io_stats.num_ios),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 269) (u64)atomic64_read(&stats->io_stats.io_completions),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 270) (u64)atomic64_read(&stats->io_stats.io_failures),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 271) (u64)atomic64_read(&stats->io_stats.io_not_found),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 272) (u64)atomic64_read(&stats->io_stats.alloc_failures),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 273) (u64)atomic64_read(&stats->io_stats.ioreq_null),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 274) (u64)atomic64_read(&stats->io_stats.sc_null),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 275) (u64)atomic64_read(&stats->io_stats.io_btw_0_to_10_msec),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 276) (u64)atomic64_read(&stats->io_stats.io_btw_10_to_100_msec),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 277) (u64)atomic64_read(&stats->io_stats.io_btw_100_to_500_msec),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 278) (u64)atomic64_read(&stats->io_stats.io_btw_500_to_5000_msec),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 279) (u64)atomic64_read(&stats->io_stats.io_btw_5000_to_10000_msec),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 280) (u64)atomic64_read(&stats->io_stats.io_btw_10000_to_30000_msec),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 281) (u64)atomic64_read(&stats->io_stats.io_greater_than_30000_msec));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 282)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 283) len += scnprintf(debug->debug_buffer + len, buf_size - len,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 284) "\nCurrent Max IO time : %lld\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 285) (u64)atomic64_read(&stats->io_stats.current_max_io_time));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 286)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 287) len += scnprintf(debug->debug_buffer + len, buf_size - len,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 288) "\n------------------------------------------\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 289) "\t\tAbort Statistics\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 290) "------------------------------------------\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 291)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 292) len += scnprintf(debug->debug_buffer + len, buf_size - len,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 293) "Number of Aborts: %lld\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 294) "Number of Abort Failures: %lld\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 295) "Number of Abort Driver Timeouts: %lld\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 296) "Number of Abort FW Timeouts: %lld\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 297) "Number of Abort IO NOT Found: %lld\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 298)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 299) "Abort issued times: \n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 300) " < 6 sec : %lld\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 301) " 6 sec - 20 sec : %lld\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 302) " 20 sec - 30 sec : %lld\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 303) " 30 sec - 40 sec : %lld\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 304) " 40 sec - 50 sec : %lld\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 305) " 50 sec - 60 sec : %lld\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 306) " > 60 sec: %lld\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 307)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 308) (u64)atomic64_read(&stats->abts_stats.aborts),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 309) (u64)atomic64_read(&stats->abts_stats.abort_failures),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 310) (u64)atomic64_read(&stats->abts_stats.abort_drv_timeouts),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 311) (u64)atomic64_read(&stats->abts_stats.abort_fw_timeouts),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 312) (u64)atomic64_read(&stats->abts_stats.abort_io_not_found),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 313) (u64)atomic64_read(&stats->abts_stats.abort_issued_btw_0_to_6_sec),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 314) (u64)atomic64_read(&stats->abts_stats.abort_issued_btw_6_to_20_sec),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 315) (u64)atomic64_read(&stats->abts_stats.abort_issued_btw_20_to_30_sec),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 316) (u64)atomic64_read(&stats->abts_stats.abort_issued_btw_30_to_40_sec),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 317) (u64)atomic64_read(&stats->abts_stats.abort_issued_btw_40_to_50_sec),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 318) (u64)atomic64_read(&stats->abts_stats.abort_issued_btw_50_to_60_sec),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 319) (u64)atomic64_read(&stats->abts_stats.abort_issued_greater_than_60_sec));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 320)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 321) len += scnprintf(debug->debug_buffer + len, buf_size - len,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 322) "\n------------------------------------------\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 323) "\t\tTerminate Statistics\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 324) "------------------------------------------\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 325)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 326) len += scnprintf(debug->debug_buffer + len, buf_size - len,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 327) "Number of Terminates: %lld\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 328) "Maximum Terminates: %lld\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 329) "Number of Terminate Driver Timeouts: %lld\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 330) "Number of Terminate FW Timeouts: %lld\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 331) "Number of Terminate IO NOT Found: %lld\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 332) "Number of Terminate Failures: %lld\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 333) (u64)atomic64_read(&stats->term_stats.terminates),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 334) (u64)atomic64_read(&stats->term_stats.max_terminates),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 335) (u64)atomic64_read(&stats->term_stats.terminate_drv_timeouts),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 336) (u64)atomic64_read(&stats->term_stats.terminate_fw_timeouts),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 337) (u64)atomic64_read(&stats->term_stats.terminate_io_not_found),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 338) (u64)atomic64_read(&stats->term_stats.terminate_failures));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 339)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 340) len += scnprintf(debug->debug_buffer + len, buf_size - len,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 341) "\n------------------------------------------\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 342) "\t\tReset Statistics\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 343) "------------------------------------------\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 344)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 345) len += scnprintf(debug->debug_buffer + len, buf_size - len,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 346) "Number of Device Resets: %lld\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 347) "Number of Device Reset Failures: %lld\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 348) "Number of Device Reset Aborts: %lld\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 349) "Number of Device Reset Timeouts: %lld\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 350) "Number of Device Reset Terminates: %lld\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 351) "Number of FW Resets: %lld\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 352) "Number of FW Reset Completions: %lld\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 353) "Number of FW Reset Failures: %lld\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 354) "Number of Fnic Reset: %lld\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 355) "Number of Fnic Reset Completions: %lld\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 356) "Number of Fnic Reset Failures: %lld\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 357) (u64)atomic64_read(&stats->reset_stats.device_resets),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 358) (u64)atomic64_read(&stats->reset_stats.device_reset_failures),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 359) (u64)atomic64_read(&stats->reset_stats.device_reset_aborts),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 360) (u64)atomic64_read(&stats->reset_stats.device_reset_timeouts),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 361) (u64)atomic64_read(
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 362) &stats->reset_stats.device_reset_terminates),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 363) (u64)atomic64_read(&stats->reset_stats.fw_resets),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 364) (u64)atomic64_read(&stats->reset_stats.fw_reset_completions),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 365) (u64)atomic64_read(&stats->reset_stats.fw_reset_failures),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 366) (u64)atomic64_read(&stats->reset_stats.fnic_resets),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 367) (u64)atomic64_read(
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 368) &stats->reset_stats.fnic_reset_completions),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 369) (u64)atomic64_read(&stats->reset_stats.fnic_reset_failures));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 370)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 371) len += scnprintf(debug->debug_buffer + len, buf_size - len,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 372) "\n------------------------------------------\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 373) "\t\tFirmware Statistics\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 374) "------------------------------------------\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 375)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 376) len += scnprintf(debug->debug_buffer + len, buf_size - len,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 377) "Number of Active FW Requests %lld\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 378) "Maximum FW Requests: %lld\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 379) "Number of FW out of resources: %lld\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 380) "Number of FW IO errors: %lld\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 381) (u64)atomic64_read(&stats->fw_stats.active_fw_reqs),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 382) (u64)atomic64_read(&stats->fw_stats.max_fw_reqs),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 383) (u64)atomic64_read(&stats->fw_stats.fw_out_of_resources),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 384) (u64)atomic64_read(&stats->fw_stats.io_fw_errs));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 385)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 386) len += scnprintf(debug->debug_buffer + len, buf_size - len,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 387) "\n------------------------------------------\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 388) "\t\tVlan Discovery Statistics\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 389) "------------------------------------------\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 390)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 391) len += scnprintf(debug->debug_buffer + len, buf_size - len,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 392) "Number of Vlan Discovery Requests Sent %lld\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 393) "Vlan Response Received with no FCF VLAN ID: %lld\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 394) "No solicitations recvd after vlan set, expiry count: %lld\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 395) "Flogi rejects count: %lld\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 396) (u64)atomic64_read(&stats->vlan_stats.vlan_disc_reqs),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 397) (u64)atomic64_read(&stats->vlan_stats.resp_withno_vlanID),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 398) (u64)atomic64_read(&stats->vlan_stats.sol_expiry_count),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 399) (u64)atomic64_read(&stats->vlan_stats.flogi_rejects));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 400)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 401) len += scnprintf(debug->debug_buffer + len, buf_size - len,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 402) "\n------------------------------------------\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 403) "\t\tOther Important Statistics\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 404) "------------------------------------------\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 405)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 406) jiffies_to_timespec64(stats->misc_stats.last_isr_time, &val1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 407) jiffies_to_timespec64(stats->misc_stats.last_ack_time, &val2);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 408)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 409) len += scnprintf(debug->debug_buffer + len, buf_size - len,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 410) "Last ISR time: %llu (%8llu.%09lu)\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 411) "Last ACK time: %llu (%8llu.%09lu)\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 412) "Max ISR jiffies: %llu\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 413) "Max ISR time (ms) (0 denotes < 1 ms): %llu\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 414) "Corr. work done: %llu\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 415) "Number of ISRs: %lld\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 416) "Maximum CQ Entries: %lld\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 417) "Number of ACK index out of range: %lld\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 418) "Number of data count mismatch: %lld\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 419) "Number of FCPIO Timeouts: %lld\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 420) "Number of FCPIO Aborted: %lld\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 421) "Number of SGL Invalid: %lld\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 422) "Number of Copy WQ Alloc Failures for ABTs: %lld\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 423) "Number of Copy WQ Alloc Failures for Device Reset: %lld\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 424) "Number of Copy WQ Alloc Failures for IOs: %lld\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 425) "Number of no icmnd itmf Completions: %lld\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 426) "Number of Check Conditions encountered: %lld\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 427) "Number of QUEUE Fulls: %lld\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 428) "Number of rport not ready: %lld\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 429) "Number of receive frame errors: %lld\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 430) (u64)stats->misc_stats.last_isr_time,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 431) (s64)val1.tv_sec, val1.tv_nsec,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 432) (u64)stats->misc_stats.last_ack_time,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 433) (s64)val2.tv_sec, val2.tv_nsec,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 434) (u64)atomic64_read(&stats->misc_stats.max_isr_jiffies),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 435) (u64)atomic64_read(&stats->misc_stats.max_isr_time_ms),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 436) (u64)atomic64_read(&stats->misc_stats.corr_work_done),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 437) (u64)atomic64_read(&stats->misc_stats.isr_count),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 438) (u64)atomic64_read(&stats->misc_stats.max_cq_entries),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 439) (u64)atomic64_read(&stats->misc_stats.ack_index_out_of_range),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 440) (u64)atomic64_read(&stats->misc_stats.data_count_mismatch),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 441) (u64)atomic64_read(&stats->misc_stats.fcpio_timeout),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 442) (u64)atomic64_read(&stats->misc_stats.fcpio_aborted),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 443) (u64)atomic64_read(&stats->misc_stats.sgl_invalid),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 444) (u64)atomic64_read(
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 445) &stats->misc_stats.abts_cpwq_alloc_failures),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 446) (u64)atomic64_read(
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 447) &stats->misc_stats.devrst_cpwq_alloc_failures),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 448) (u64)atomic64_read(&stats->misc_stats.io_cpwq_alloc_failures),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 449) (u64)atomic64_read(&stats->misc_stats.no_icmnd_itmf_cmpls),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 450) (u64)atomic64_read(&stats->misc_stats.check_condition),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 451) (u64)atomic64_read(&stats->misc_stats.queue_fulls),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 452) (u64)atomic64_read(&stats->misc_stats.rport_not_ready),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 453) (u64)atomic64_read(&stats->misc_stats.frame_errors));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 454)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 455) len += scnprintf(debug->debug_buffer + len, buf_size - len,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 456) "Firmware reported port speed: %llu\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 457) (u64)atomic64_read(
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 458) &stats->misc_stats.current_port_speed));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 459)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 460) return len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 461)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 462) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 463)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 464) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 465) * fnic_trace_buf_init - Initialize fnic trace buffer logging facility
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 466) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 467) * Description:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 468) * Initialize trace buffer data structure by allocating required memory and
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 469) * setting page_offset information for every trace entry by adding trace entry
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 470) * length to previous page_offset value.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 471) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 472) int fnic_trace_buf_init(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 473) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 474) unsigned long fnic_buf_head;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 475) int i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 476) int err = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 477)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 478) trace_max_pages = fnic_trace_max_pages;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 479) fnic_max_trace_entries = (trace_max_pages * PAGE_SIZE)/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 480) FNIC_ENTRY_SIZE_BYTES;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 481)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 482) fnic_trace_buf_p = (unsigned long)vzalloc(trace_max_pages * PAGE_SIZE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 483) if (!fnic_trace_buf_p) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 484) printk(KERN_ERR PFX "Failed to allocate memory "
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 485) "for fnic_trace_buf_p\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 486) err = -ENOMEM;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 487) goto err_fnic_trace_buf_init;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 488) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 489)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 490) fnic_trace_entries.page_offset =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 491) vmalloc(array_size(fnic_max_trace_entries,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 492) sizeof(unsigned long)));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 493) if (!fnic_trace_entries.page_offset) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 494) printk(KERN_ERR PFX "Failed to allocate memory for"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 495) " page_offset\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 496) if (fnic_trace_buf_p) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 497) vfree((void *)fnic_trace_buf_p);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 498) fnic_trace_buf_p = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 499) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 500) err = -ENOMEM;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 501) goto err_fnic_trace_buf_init;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 502) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 503) memset((void *)fnic_trace_entries.page_offset, 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 504) (fnic_max_trace_entries * sizeof(unsigned long)));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 505) fnic_trace_entries.wr_idx = fnic_trace_entries.rd_idx = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 506) fnic_buf_head = fnic_trace_buf_p;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 507)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 508) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 509) * Set page_offset field of fnic_trace_entries struct by
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 510) * calculating memory location for every trace entry using
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 511) * length of each trace entry
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 512) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 513) for (i = 0; i < fnic_max_trace_entries; i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 514) fnic_trace_entries.page_offset[i] = fnic_buf_head;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 515) fnic_buf_head += FNIC_ENTRY_SIZE_BYTES;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 516) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 517) fnic_trace_debugfs_init();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 518) pr_info("fnic: Successfully Initialized Trace Buffer\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 519) return err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 520)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 521) err_fnic_trace_buf_init:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 522) return err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 523) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 524)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 525) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 526) * fnic_trace_free - Free memory of fnic trace data structures.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 527) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 528) void fnic_trace_free(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 529) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 530) fnic_tracing_enabled = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 531) fnic_trace_debugfs_terminate();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 532) if (fnic_trace_entries.page_offset) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 533) vfree((void *)fnic_trace_entries.page_offset);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 534) fnic_trace_entries.page_offset = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 535) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 536) if (fnic_trace_buf_p) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 537) vfree((void *)fnic_trace_buf_p);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 538) fnic_trace_buf_p = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 539) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 540) printk(KERN_INFO PFX "Successfully Freed Trace Buffer\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 541) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 542)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 543) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 544) * fnic_fc_ctlr_trace_buf_init -
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 545) * Initialize trace buffer to log fnic control frames
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 546) * Description:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 547) * Initialize trace buffer data structure by allocating
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 548) * required memory for trace data as well as for Indexes.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 549) * Frame size is 256 bytes and
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 550) * memory is allocated for 1024 entries of 256 bytes.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 551) * Page_offset(Index) is set to the address of trace entry
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 552) * and page_offset is initialized by adding frame size
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 553) * to the previous page_offset entry.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 554) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 555)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 556) int fnic_fc_trace_init(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 557) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 558) unsigned long fc_trace_buf_head;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 559) int err = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 560) int i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 561)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 562) fc_trace_max_entries = (fnic_fc_trace_max_pages * PAGE_SIZE)/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 563) FC_TRC_SIZE_BYTES;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 564) fnic_fc_ctlr_trace_buf_p =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 565) (unsigned long)vmalloc(array_size(PAGE_SIZE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 566) fnic_fc_trace_max_pages));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 567) if (!fnic_fc_ctlr_trace_buf_p) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 568) pr_err("fnic: Failed to allocate memory for "
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 569) "FC Control Trace Buf\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 570) err = -ENOMEM;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 571) goto err_fnic_fc_ctlr_trace_buf_init;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 572) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 573)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 574) memset((void *)fnic_fc_ctlr_trace_buf_p, 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 575) fnic_fc_trace_max_pages * PAGE_SIZE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 576)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 577) /* Allocate memory for page offset */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 578) fc_trace_entries.page_offset =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 579) vmalloc(array_size(fc_trace_max_entries,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 580) sizeof(unsigned long)));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 581) if (!fc_trace_entries.page_offset) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 582) pr_err("fnic:Failed to allocate memory for page_offset\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 583) if (fnic_fc_ctlr_trace_buf_p) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 584) pr_err("fnic: Freeing FC Control Trace Buf\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 585) vfree((void *)fnic_fc_ctlr_trace_buf_p);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 586) fnic_fc_ctlr_trace_buf_p = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 587) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 588) err = -ENOMEM;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 589) goto err_fnic_fc_ctlr_trace_buf_init;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 590) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 591) memset((void *)fc_trace_entries.page_offset, 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 592) (fc_trace_max_entries * sizeof(unsigned long)));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 593)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 594) fc_trace_entries.rd_idx = fc_trace_entries.wr_idx = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 595) fc_trace_buf_head = fnic_fc_ctlr_trace_buf_p;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 596)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 597) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 598) * Set up fc_trace_entries.page_offset field with memory location
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 599) * for every trace entry
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 600) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 601) for (i = 0; i < fc_trace_max_entries; i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 602) fc_trace_entries.page_offset[i] = fc_trace_buf_head;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 603) fc_trace_buf_head += FC_TRC_SIZE_BYTES;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 604) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 605) fnic_fc_trace_debugfs_init();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 606) pr_info("fnic: Successfully Initialized FC_CTLR Trace Buffer\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 607) return err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 608)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 609) err_fnic_fc_ctlr_trace_buf_init:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 610) return err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 611) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 612)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 613) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 614) * Fnic_fc_ctlr_trace_free - Free memory of fnic_fc_ctlr trace data structures.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 615) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 616) void fnic_fc_trace_free(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 617) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 618) fnic_fc_tracing_enabled = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 619) fnic_fc_trace_debugfs_terminate();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 620) if (fc_trace_entries.page_offset) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 621) vfree((void *)fc_trace_entries.page_offset);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 622) fc_trace_entries.page_offset = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 623) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 624) if (fnic_fc_ctlr_trace_buf_p) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 625) vfree((void *)fnic_fc_ctlr_trace_buf_p);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 626) fnic_fc_ctlr_trace_buf_p = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 627) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 628) pr_info("fnic:Successfully FC_CTLR Freed Trace Buffer\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 629) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 630)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 631) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 632) * fnic_fc_ctlr_set_trace_data:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 633) * Maintain rd & wr idx accordingly and set data
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 634) * Passed parameters:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 635) * host_no: host number accociated with fnic
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 636) * frame_type: send_frame, rece_frame or link event
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 637) * fc_frame: pointer to fc_frame
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 638) * frame_len: Length of the fc_frame
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 639) * Description:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 640) * This routine will get next available wr_idx and
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 641) * copy all passed trace data to the buffer pointed by wr_idx
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 642) * and increment wr_idx. It will also make sure that we dont
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 643) * overwrite the entry which we are reading and also
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 644) * wrap around if we reach the maximum entries.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 645) * Returned Value:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 646) * It will return 0 for success or -1 for failure
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 647) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 648) int fnic_fc_trace_set_data(u32 host_no, u8 frame_type,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 649) char *frame, u32 fc_trc_frame_len)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 650) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 651) unsigned long flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 652) struct fc_trace_hdr *fc_buf;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 653) unsigned long eth_fcoe_hdr_len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 654) char *fc_trace;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 655)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 656) if (fnic_fc_tracing_enabled == 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 657) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 658)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 659) spin_lock_irqsave(&fnic_fc_trace_lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 660)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 661) if (fnic_fc_trace_cleared == 1) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 662) fc_trace_entries.rd_idx = fc_trace_entries.wr_idx = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 663) pr_info("fnic: Resetting the read idx\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 664) memset((void *)fnic_fc_ctlr_trace_buf_p, 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 665) fnic_fc_trace_max_pages * PAGE_SIZE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 666) fnic_fc_trace_cleared = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 667) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 668)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 669) fc_buf = (struct fc_trace_hdr *)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 670) fc_trace_entries.page_offset[fc_trace_entries.wr_idx];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 671)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 672) fc_trace_entries.wr_idx++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 673)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 674) if (fc_trace_entries.wr_idx >= fc_trace_max_entries)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 675) fc_trace_entries.wr_idx = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 676)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 677) if (fc_trace_entries.wr_idx == fc_trace_entries.rd_idx) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 678) fc_trace_entries.rd_idx++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 679) if (fc_trace_entries.rd_idx >= fc_trace_max_entries)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 680) fc_trace_entries.rd_idx = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 681) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 682)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 683) ktime_get_real_ts64(&fc_buf->time_stamp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 684) fc_buf->host_no = host_no;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 685) fc_buf->frame_type = frame_type;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 686)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 687) fc_trace = (char *)FC_TRACE_ADDRESS(fc_buf);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 688)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 689) /* During the receive path, we do not have eth hdr as well as fcoe hdr
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 690) * at trace entry point so we will stuff 0xff just to make it generic.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 691) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 692) if (frame_type == FNIC_FC_RECV) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 693) eth_fcoe_hdr_len = sizeof(struct ethhdr) +
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 694) sizeof(struct fcoe_hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 695) memset((char *)fc_trace, 0xff, eth_fcoe_hdr_len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 696) /* Copy the rest of data frame */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 697) memcpy((char *)(fc_trace + eth_fcoe_hdr_len), (void *)frame,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 698) min_t(u8, fc_trc_frame_len,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 699) (u8)(FC_TRC_SIZE_BYTES - FC_TRC_HEADER_SIZE
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 700) - eth_fcoe_hdr_len)));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 701) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 702) memcpy((char *)fc_trace, (void *)frame,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 703) min_t(u8, fc_trc_frame_len,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 704) (u8)(FC_TRC_SIZE_BYTES - FC_TRC_HEADER_SIZE)));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 705) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 706)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 707) /* Store the actual received length */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 708) fc_buf->frame_len = fc_trc_frame_len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 709)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 710) spin_unlock_irqrestore(&fnic_fc_trace_lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 711) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 712) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 713)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 714) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 715) * fnic_fc_ctlr_get_trace_data: Copy trace buffer to a memory file
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 716) * Passed parameter:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 717) * @fnic_dbgfs_t: pointer to debugfs trace buffer
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 718) * rdata_flag: 1 => Unformated file
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 719) * 0 => formated file
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 720) * Description:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 721) * This routine will copy the trace data to memory file with
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 722) * proper formatting and also copy to another memory
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 723) * file without formatting for further procesing.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 724) * Retrun Value:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 725) * Number of bytes that were dumped into fnic_dbgfs_t
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 726) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 727)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 728) int fnic_fc_trace_get_data(fnic_dbgfs_t *fnic_dbgfs_prt, u8 rdata_flag)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 729) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 730) int rd_idx, wr_idx;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 731) unsigned long flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 732) int len = 0, j;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 733) struct fc_trace_hdr *tdata;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 734) char *fc_trace;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 735)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 736) spin_lock_irqsave(&fnic_fc_trace_lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 737) if (fc_trace_entries.wr_idx == fc_trace_entries.rd_idx) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 738) spin_unlock_irqrestore(&fnic_fc_trace_lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 739) pr_info("fnic: Buffer is empty\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 740) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 741) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 742) rd_idx = fc_trace_entries.rd_idx;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 743) wr_idx = fc_trace_entries.wr_idx;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 744) if (rdata_flag == 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 745) len += scnprintf(fnic_dbgfs_prt->buffer + len,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 746) (fnic_fc_trace_max_pages * PAGE_SIZE * 3) - len,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 747) "Time Stamp (UTC)\t\t"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 748) "Host No: F Type: len: FCoE_FRAME:\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 749) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 750)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 751) while (rd_idx != wr_idx) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 752) tdata = (struct fc_trace_hdr *)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 753) fc_trace_entries.page_offset[rd_idx];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 754) if (!tdata) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 755) pr_info("fnic: Rd data is NULL\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 756) spin_unlock_irqrestore(&fnic_fc_trace_lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 757) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 758) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 759) if (rdata_flag == 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 760) copy_and_format_trace_data(tdata,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 761) fnic_dbgfs_prt, &len, rdata_flag);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 762) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 763) fc_trace = (char *)tdata;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 764) for (j = 0; j < FC_TRC_SIZE_BYTES; j++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 765) len += scnprintf(fnic_dbgfs_prt->buffer + len,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 766) (fnic_fc_trace_max_pages * PAGE_SIZE * 3)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 767) - len, "%02x", fc_trace[j] & 0xff);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 768) } /* for loop */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 769) len += scnprintf(fnic_dbgfs_prt->buffer + len,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 770) (fnic_fc_trace_max_pages * PAGE_SIZE * 3) - len,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 771) "\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 772) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 773) rd_idx++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 774) if (rd_idx > (fc_trace_max_entries - 1))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 775) rd_idx = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 776) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 777)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 778) spin_unlock_irqrestore(&fnic_fc_trace_lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 779) return len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 780) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 781)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 782) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 783) * copy_and_format_trace_data: Copy formatted data to char * buffer
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 784) * Passed Parameter:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 785) * @fc_trace_hdr_t: pointer to trace data
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 786) * @fnic_dbgfs_t: pointer to debugfs trace buffer
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 787) * @orig_len: pointer to len
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 788) * rdata_flag: 0 => Formated file, 1 => Unformated file
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 789) * Description:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 790) * This routine will format and copy the passed trace data
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 791) * for formated file or unformated file accordingly.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 792) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 793)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 794) void copy_and_format_trace_data(struct fc_trace_hdr *tdata,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 795) fnic_dbgfs_t *fnic_dbgfs_prt, int *orig_len,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 796) u8 rdata_flag)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 797) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 798) struct tm tm;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 799) int j, i = 1, len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 800) char *fc_trace, *fmt;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 801) int ethhdr_len = sizeof(struct ethhdr) - 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 802) int fcoehdr_len = sizeof(struct fcoe_hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 803) int fchdr_len = sizeof(struct fc_frame_header);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 804) int max_size = fnic_fc_trace_max_pages * PAGE_SIZE * 3;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 805)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 806) tdata->frame_type = tdata->frame_type & 0x7F;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 807)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 808) len = *orig_len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 809)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 810) time64_to_tm(tdata->time_stamp.tv_sec, 0, &tm);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 811)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 812) fmt = "%02d:%02d:%04ld %02d:%02d:%02d.%09lu ns%8x %c%8x\t";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 813) len += scnprintf(fnic_dbgfs_prt->buffer + len,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 814) max_size - len,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 815) fmt,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 816) tm.tm_mon + 1, tm.tm_mday, tm.tm_year + 1900,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 817) tm.tm_hour, tm.tm_min, tm.tm_sec,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 818) tdata->time_stamp.tv_nsec, tdata->host_no,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 819) tdata->frame_type, tdata->frame_len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 820)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 821) fc_trace = (char *)FC_TRACE_ADDRESS(tdata);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 822)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 823) for (j = 0; j < min_t(u8, tdata->frame_len,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 824) (u8)(FC_TRC_SIZE_BYTES - FC_TRC_HEADER_SIZE)); j++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 825) if (tdata->frame_type == FNIC_FC_LE) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 826) len += scnprintf(fnic_dbgfs_prt->buffer + len,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 827) max_size - len, "%c", fc_trace[j]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 828) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 829) len += scnprintf(fnic_dbgfs_prt->buffer + len,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 830) max_size - len, "%02x", fc_trace[j] & 0xff);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 831) len += scnprintf(fnic_dbgfs_prt->buffer + len,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 832) max_size - len, " ");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 833) if (j == ethhdr_len ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 834) j == ethhdr_len + fcoehdr_len ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 835) j == ethhdr_len + fcoehdr_len + fchdr_len ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 836) (i > 3 && j%fchdr_len == 0)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 837) len += scnprintf(fnic_dbgfs_prt->buffer
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 838) + len, max_size - len,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 839) "\n\t\t\t\t\t\t\t\t");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 840) i++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 841) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 842) } /* end of else*/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 843) } /* End of for loop*/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 844) len += scnprintf(fnic_dbgfs_prt->buffer + len,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 845) max_size - len, "\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 846) *orig_len = len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 847) }