2 * Copyright 2012 Cisco Systems, Inc. All rights reserved.
4 * This program is free software; you may redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; version 2 of the License.
8 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
9 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
10 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
11 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
12 * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
13 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
14 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
18 #ifndef __FNIC_TRACE_H__
19 #define __FNIC_TRACE_H__
21 #define FNIC_ENTRY_SIZE_BYTES 64
22 #define FC_TRC_SIZE_BYTES 256
23 #define FC_TRC_HEADER_SIZE sizeof(struct fc_trace_hdr)
26 * Fisrt bit of FNIC_FC_RECV and FNIC_FC_SEND is used to represent the type
27 * of frame 1 => Eth frame, 0=> FC frame
30 #define FNIC_FC_RECV 0x52 /* Character R */
31 #define FNIC_FC_SEND 0x54 /* Character T */
32 #define FNIC_FC_LE 0x4C /* Character L */
34 extern ssize_t
simple_read_from_buffer(void __user
*to
,
40 extern unsigned int fnic_trace_max_pages
;
41 extern int fnic_tracing_enabled
;
42 extern unsigned int trace_max_pages
;
44 extern unsigned int fnic_fc_trace_max_pages
;
45 extern int fnic_fc_tracing_enabled
;
46 extern int fnic_fc_trace_cleared
;
48 typedef struct fnic_trace_dbg
{
51 unsigned long *page_offset
;
54 typedef struct fnic_dbgfs
{
59 struct fnic_trace_data
{
70 } __attribute__((__packed__
));
72 typedef struct fnic_trace_data fnic_trace_data_t
;
75 struct timespec time_stamp
;
79 } __attribute__((__packed__
));
81 #define FC_TRACE_ADDRESS(a) \
82 ((unsigned long)(a) + sizeof(struct fc_trace_hdr))
84 #define FNIC_TRACE_ENTRY_SIZE \
85 (FNIC_ENTRY_SIZE_BYTES - sizeof(fnic_trace_data_t))
87 #define FNIC_TRACE(_fn, _hn, _t, _a, _b, _c, _d, _e) \
88 if (unlikely(fnic_tracing_enabled)) { \
89 fnic_trace_data_t *trace_buf = fnic_trace_get_buf(); \
91 if (sizeof(unsigned long) < 8) { \
92 trace_buf->timestamp.low = jiffies; \
93 trace_buf->fnaddr.low = (u32)(unsigned long)_fn; \
95 trace_buf->timestamp.val = jiffies; \
96 trace_buf->fnaddr.val = (u64)(unsigned long)_fn; \
98 trace_buf->host_no = _hn; \
99 trace_buf->tag = _t; \
100 trace_buf->data[0] = (u64)(unsigned long)_a; \
101 trace_buf->data[1] = (u64)(unsigned long)_b; \
102 trace_buf->data[2] = (u64)(unsigned long)_c; \
103 trace_buf->data[3] = (u64)(unsigned long)_d; \
104 trace_buf->data[4] = (u64)(unsigned long)_e; \
108 fnic_trace_data_t
*fnic_trace_get_buf(void);
109 int fnic_get_trace_data(fnic_dbgfs_t
*);
110 int fnic_trace_buf_init(void);
111 void fnic_trace_free(void);
112 int fnic_debugfs_init(void);
113 void fnic_debugfs_terminate(void);
114 int fnic_trace_debugfs_init(void);
115 void fnic_trace_debugfs_terminate(void);
117 /* Fnic FC CTLR Trace releated function */
118 int fnic_fc_trace_init(void);
119 void fnic_fc_trace_free(void);
120 int fnic_fc_trace_set_data(u32 host_no
, u8 frame_type
,
121 char *frame
, u32 fc_frame_len
);
122 int fnic_fc_trace_get_data(fnic_dbgfs_t
*fnic_dbgfs_prt
, u8 rdata_flag
);
123 void copy_and_format_trace_data(struct fc_trace_hdr
*tdata
,
124 fnic_dbgfs_t
*fnic_dbgfs_prt
,
125 int *len
, u8 rdata_flag
);
126 int fnic_fc_trace_debugfs_init(void);
127 void fnic_fc_trace_debugfs_terminate(void);