1 /* SPDX-License-Identifier: GPL-2.0-only */
2 /* Copyright 2014 Cisco Systems, Inc. All rights reserved. */
7 #ifdef CONFIG_SCSI_SNIC_DEBUG_FS
9 extern ssize_t
simple_read_from_buffer(void __user
*to
,
15 extern unsigned int snic_trace_max_pages
;
17 /* Global Data structure for trace to manage trace functionality */
18 struct snic_trc_data
{
19 u64 ts
; /* Time Stamp */
20 char *fn
; /* Ptr to Function Name */
21 u32 hno
; /* SCSI Host ID */
22 u32 tag
; /* Command Tag */
24 } __attribute__((__packed__
));
26 #define SNIC_TRC_ENTRY_SZ 64 /* in Bytes */
30 struct snic_trc_data
*buf
; /* Trace Buffer */
31 u32 max_idx
; /* Max Index into trace buffer */
34 bool enable
; /* Control Variable for Tracing */
37 int snic_trc_init(void);
38 void snic_trc_free(void);
39 void snic_trc_debugfs_init(void);
40 void snic_trc_debugfs_term(void);
41 struct snic_trc_data
*snic_get_trc_buf(void);
42 int snic_get_trc_data(char *buf
, int buf_sz
);
44 void snic_debugfs_init(void);
45 void snic_debugfs_term(void);
48 snic_trace(char *fn
, u16 hno
, u32 tag
, u64 d1
, u64 d2
, u64 d3
, u64 d4
, u64 d5
)
50 struct snic_trc_data
*tr_rec
= snic_get_trc_buf();
55 tr_rec
->fn
= (char *)fn
;
63 tr_rec
->ts
= jiffies
; /* Update time stamp at last */
66 #define SNIC_TRC(_hno, _tag, d1, d2, d3, d4, d5) \
68 if (unlikely(snic_glob->trc.enable)) \
69 snic_trace((char *)__func__, \
80 #define SNIC_TRC(_hno, _tag, d1, d2, d3, d4, d5) \
82 if (unlikely(snic_log_level & 0x2)) \
83 SNIC_DBG("SnicTrace: %s %2u %2u %llx %llx %llx %llx %llx", \
93 #endif /* end of CONFIG_SCSI_SNIC_DEBUG_FS */
95 #define SNIC_TRC_CMD(sc) \
96 ((u64)sc->cmnd[0] << 56 | (u64)sc->cmnd[7] << 40 | \
97 (u64)sc->cmnd[8] << 32 | (u64)sc->cmnd[2] << 24 | \
98 (u64)sc->cmnd[3] << 16 | (u64)sc->cmnd[4] << 8 | \
101 #define SNIC_TRC_CMD_STATE_FLAGS(sc) \
102 ((u64) CMD_FLAGS(sc) << 32 | CMD_STATE(sc))
104 #endif /* end of __SNIC_TRC_H */