0001
0002
0003
0004 #ifndef __SNIC_TRC_H
0005 #define __SNIC_TRC_H
0006
0007 #ifdef CONFIG_SCSI_SNIC_DEBUG_FS
0008
0009 extern ssize_t simple_read_from_buffer(void __user *to,
0010 size_t count,
0011 loff_t *ppos,
0012 const void *from,
0013 size_t available);
0014
0015 extern unsigned int snic_trace_max_pages;
0016
0017
0018 struct snic_trc_data {
0019 u64 ts;
0020 char *fn;
0021 u32 hno;
0022 u32 tag;
0023 u64 data[5];
0024 } __attribute__((__packed__));
0025
0026 #define SNIC_TRC_ENTRY_SZ 64
0027
0028 struct snic_trc {
0029 spinlock_t lock;
0030 struct snic_trc_data *buf;
0031 u32 max_idx;
0032 u32 rd_idx;
0033 u32 wr_idx;
0034 bool enable;
0035 };
0036
0037 int snic_trc_init(void);
0038 void snic_trc_free(void);
0039 void snic_trc_debugfs_init(void);
0040 void snic_trc_debugfs_term(void);
0041 struct snic_trc_data *snic_get_trc_buf(void);
0042 int snic_get_trc_data(char *buf, int buf_sz);
0043
0044 void snic_debugfs_init(void);
0045 void snic_debugfs_term(void);
0046
0047 static inline void
0048 snic_trace(char *fn, u16 hno, u32 tag, u64 d1, u64 d2, u64 d3, u64 d4, u64 d5)
0049 {
0050 struct snic_trc_data *tr_rec = snic_get_trc_buf();
0051
0052 if (!tr_rec)
0053 return;
0054
0055 tr_rec->fn = (char *)fn;
0056 tr_rec->hno = hno;
0057 tr_rec->tag = tag;
0058 tr_rec->data[0] = d1;
0059 tr_rec->data[1] = d2;
0060 tr_rec->data[2] = d3;
0061 tr_rec->data[3] = d4;
0062 tr_rec->data[4] = d5;
0063 tr_rec->ts = jiffies;
0064 }
0065
0066 #define SNIC_TRC(_hno, _tag, d1, d2, d3, d4, d5) \
0067 do { \
0068 if (unlikely(snic_glob->trc.enable)) \
0069 snic_trace((char *)__func__, \
0070 (u16)(_hno), \
0071 (u32)(_tag), \
0072 (u64)(d1), \
0073 (u64)(d2), \
0074 (u64)(d3), \
0075 (u64)(d4), \
0076 (u64)(d5)); \
0077 } while (0)
0078 #else
0079
0080 #define SNIC_TRC(_hno, _tag, d1, d2, d3, d4, d5) \
0081 do { \
0082 if (unlikely(snic_log_level & 0x2)) \
0083 SNIC_DBG("SnicTrace: %s %2u %2u %llx %llx %llx %llx %llx", \
0084 (char *)__func__, \
0085 (u16)(_hno), \
0086 (u32)(_tag), \
0087 (u64)(d1), \
0088 (u64)(d2), \
0089 (u64)(d3), \
0090 (u64)(d4), \
0091 (u64)(d5)); \
0092 } while (0)
0093 #endif
0094
0095 #define SNIC_TRC_CMD(sc) \
0096 ((u64)sc->cmnd[0] << 56 | (u64)sc->cmnd[7] << 40 | \
0097 (u64)sc->cmnd[8] << 32 | (u64)sc->cmnd[2] << 24 | \
0098 (u64)sc->cmnd[3] << 16 | (u64)sc->cmnd[4] << 8 | \
0099 (u64)sc->cmnd[5])
0100
0101 #define SNIC_TRC_CMD_STATE_FLAGS(sc) \
0102 ((u64) CMD_FLAGS(sc) << 32 | CMD_STATE(sc))
0103
0104 #endif