1 /* SPDX-License-Identifier: GPL-2.0-only */
2 /* Copyright 2012 Cisco Systems, Inc. All rights reserved. */
4 #ifndef __FNIC_TRACE_H__
5 #define __FNIC_TRACE_H__
7 #define FNIC_ENTRY_SIZE_BYTES 64
8 #define FC_TRC_SIZE_BYTES 256
9 #define FC_TRC_HEADER_SIZE sizeof(struct fc_trace_hdr)
12 * Fisrt bit of FNIC_FC_RECV and FNIC_FC_SEND is used to represent the type
13 * of frame 1 => Eth frame, 0=> FC frame
16 #define FNIC_FC_RECV 0x52 /* Character R */
17 #define FNIC_FC_SEND 0x54 /* Character T */
18 #define FNIC_FC_LE 0x4C /* Character L */
20 extern ssize_t
simple_read_from_buffer(void __user
*to
,
26 extern unsigned int fnic_trace_max_pages
;
27 extern int fnic_tracing_enabled
;
28 extern unsigned int trace_max_pages
;
30 extern unsigned int fnic_fc_trace_max_pages
;
31 extern int fnic_fc_tracing_enabled
;
32 extern int fnic_fc_trace_cleared
;
34 typedef struct fnic_trace_dbg
{
37 unsigned long *page_offset
;
40 typedef struct fnic_dbgfs
{
45 struct fnic_trace_data
{
56 } __attribute__((__packed__
));
58 typedef struct fnic_trace_data fnic_trace_data_t
;
61 struct timespec64 time_stamp
;
65 } __attribute__((__packed__
));
67 #define FC_TRACE_ADDRESS(a) \
68 ((unsigned long)(a) + sizeof(struct fc_trace_hdr))
70 #define FNIC_TRACE_ENTRY_SIZE \
71 (FNIC_ENTRY_SIZE_BYTES - sizeof(fnic_trace_data_t))
73 #define FNIC_TRACE(_fn, _hn, _t, _a, _b, _c, _d, _e) \
74 if (unlikely(fnic_tracing_enabled)) { \
75 fnic_trace_data_t *trace_buf = fnic_trace_get_buf(); \
77 if (sizeof(unsigned long) < 8) { \
78 trace_buf->timestamp.low = jiffies; \
79 trace_buf->fnaddr.low = (u32)(unsigned long)_fn; \
81 trace_buf->timestamp.val = jiffies; \
82 trace_buf->fnaddr.val = (u64)(unsigned long)_fn; \
84 trace_buf->host_no = _hn; \
85 trace_buf->tag = _t; \
86 trace_buf->data[0] = (u64)(unsigned long)_a; \
87 trace_buf->data[1] = (u64)(unsigned long)_b; \
88 trace_buf->data[2] = (u64)(unsigned long)_c; \
89 trace_buf->data[3] = (u64)(unsigned long)_d; \
90 trace_buf->data[4] = (u64)(unsigned long)_e; \
94 fnic_trace_data_t
*fnic_trace_get_buf(void);
95 int fnic_get_trace_data(fnic_dbgfs_t
*);
96 int fnic_trace_buf_init(void);
97 void fnic_trace_free(void);
98 int fnic_debugfs_init(void);
99 void fnic_debugfs_terminate(void);
100 void fnic_trace_debugfs_init(void);
101 void fnic_trace_debugfs_terminate(void);
103 /* Fnic FC CTLR Trace releated function */
104 int fnic_fc_trace_init(void);
105 void fnic_fc_trace_free(void);
106 int fnic_fc_trace_set_data(u32 host_no
, u8 frame_type
,
107 char *frame
, u32 fc_frame_len
);
108 int fnic_fc_trace_get_data(fnic_dbgfs_t
*fnic_dbgfs_prt
, u8 rdata_flag
);
109 void copy_and_format_trace_data(struct fc_trace_hdr
*tdata
,
110 fnic_dbgfs_t
*fnic_dbgfs_prt
,
111 int *len
, u8 rdata_flag
);
112 void fnic_fc_trace_debugfs_init(void);
113 void fnic_fc_trace_debugfs_terminate(void);